edu.northwestern.at.utils.math.matrix
Class MatrixToString

java.lang.Object
  extended by edu.northwestern.at.utils.math.matrix.MatrixToString

public class MatrixToString
extends java.lang.Object

Converts matrix entries to string for output.


Field Summary
protected static java.lang.String defaultEndEntryString
          Default end of matrix entry string.
protected static java.lang.String defaultEndLastEntryString
          Default end of last matrix entry in row string.
protected static java.lang.String defaultEndLastRowString
          Default end of last matrix row string.
protected static java.lang.String defaultEndMatrixString
          Default end of matrix string.
protected static java.lang.String defaultEndRowString
          Default end of matrix row string.
protected static java.lang.String defaultFormatString
          Default PrintfFormat string for converting matrix entries to strings.
protected static java.lang.String defaultStartEntryString
          Default start of matrix entry string.
protected static java.lang.String defaultStartMatrixString
          Default start of matrix string.
protected static java.lang.String defaultStartRowString
          Default start of matrix row string.
protected static int defaultWidthOption
          Default column alignment: Align columns to minimum entry width.
static int FORMATWIDTH
          Each entry uses the width specified by the format width.
static int INDIVIDUALWIDTH
          Each entry placed in field just large enough to hold it.
static int MAXIMUMELEMENTWIDTH
          Each entry placed in constant width field just large enough to hold maximum width element.
 
Constructor Summary
MatrixToString()
           
 
Method Summary
static java.lang.String toGaussString(Matrix matrix)
          Convert matrix entries to a string in Gauss format.
static java.lang.String toMathMLString(Matrix matrix)
          Convert matrix entries to a string in MathML format.
static java.lang.String toMatlabString(Matrix matrix)
          Convert matrix entries to a string in Matlab/Scilab format.
static java.lang.String toString(Matrix matrix)
          Convert matrix entries to a string.
static java.lang.String toString(Matrix matrix, int decimals)
          Convert matrix entries to a string.
static java.lang.String toString(Matrix matrix, java.lang.String title, boolean titleEmbedded, java.lang.String[] columnNames, boolean columnNamesEmbedded, java.lang.String startTitleString, java.lang.String endTitleString, java.lang.String startColumnNamesString, java.lang.String endColumnNamesString, java.lang.String startColumnNameString, java.lang.String endColumnNameString, java.lang.String startMatrixString, java.lang.String endMatrixString, java.lang.String startMatrixRowString, java.lang.String endMatrixRowString, java.lang.String endLastMatrixRowString, java.lang.String startMatrixEntryString, java.lang.String endMatrixEntryString, java.lang.String endLastMatrixEntryString, java.lang.String formatString, int widthOption)
          Convert matrix entries to a string.
static java.lang.String toString(Matrix matrix, java.lang.String title, java.lang.String[] columnNames)
          Convert matrix entries to a string.
static java.lang.String toString(Matrix matrix, java.lang.String title, java.lang.String[] columnNames, java.lang.String formatString)
          Convert matrix entries to a string.
static java.lang.String toXHTMLString(Matrix matrix)
          Convert matrix entries to a string in XHTML table format.
static java.lang.String toXHTMLString(Matrix matrix, java.lang.String title, java.lang.String[] columnNames)
          Convert matrix entries to a string in XHTML table format.
static java.lang.String toXHTMLString(Matrix matrix, java.lang.String title, java.lang.String[] columnNames, int border, java.lang.String formatString)
          Convert matrix entries to a string in XHTML table format.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

defaultStartMatrixString

protected static java.lang.String defaultStartMatrixString
Default start of matrix string.


defaultEndMatrixString

protected static java.lang.String defaultEndMatrixString
Default end of matrix string.


defaultStartRowString

protected static java.lang.String defaultStartRowString
Default start of matrix row string.


defaultEndRowString

protected static java.lang.String defaultEndRowString
Default end of matrix row string.


defaultEndLastRowString

protected static java.lang.String defaultEndLastRowString
Default end of last matrix row string.


defaultStartEntryString

protected static java.lang.String defaultStartEntryString
Default start of matrix entry string.


defaultEndEntryString

protected static java.lang.String defaultEndEntryString
Default end of matrix entry string.


defaultEndLastEntryString

protected static java.lang.String defaultEndLastEntryString
Default end of last matrix entry in row string.


defaultFormatString

protected static java.lang.String defaultFormatString
Default PrintfFormat string for converting matrix entries to strings.


INDIVIDUALWIDTH

public static final int INDIVIDUALWIDTH
Each entry placed in field just large enough to hold it.

See Also:
Constant Field Values

MAXIMUMELEMENTWIDTH

public static final int MAXIMUMELEMENTWIDTH
Each entry placed in constant width field just large enough to hold maximum width element.

See Also:
Constant Field Values

FORMATWIDTH

public static final int FORMATWIDTH
Each entry uses the width specified by the format width.

See Also:
Constant Field Values

defaultWidthOption

protected static int defaultWidthOption
Default column alignment: Align columns to minimum entry width.

Constructor Detail

MatrixToString

public MatrixToString()
Method Detail

toString

public static java.lang.String toString(Matrix matrix,
                                        java.lang.String title,
                                        java.lang.String[] columnNames,
                                        java.lang.String formatString)
Convert matrix entries to a string.

Parameters:
matrix - The matrix to convert to XHTML string.
title - Title for matrix.
columnNames - Column names.
formatString - PrintFformat format string for all entries.

This produces a matrix with columns of constant width in which the matrix entries are separated by a blank and the rows of the matrix are separated by a linefeed. The specified format is used to format each matrix entry.


toString

public static java.lang.String toString(Matrix matrix,
                                        java.lang.String title,
                                        java.lang.String[] columnNames)
Convert matrix entries to a string.

Parameters:
matrix - The matrix to convert to XHTML string.
title - Title for matrix.
columnNames - Column names.

This produces a matrix with columns of constant width in which the matrix entries are separated by a blank and the rows of the matrix are separated by a linefeed. A Fortran style "G" format is used so that entries which have no fractional portion print as integers and numbers between 10^^-4 and 10^4 appear in ordinary decimal format. Numbers outside this range appear in scientific notation with an "E" exponent.


toString

public static java.lang.String toString(Matrix matrix)
Convert matrix entries to a string.

Parameters:
matrix - The matrix to convert to a string.

This produces a matrix with columns of constant width in which the matrix entries are separated by a blank and the rows of the matrix are separated by a linefeed. A Fortran style "G" format is used so that entries which have no fractional portion print as integers and numbers between 10^^-4 and 10^4 appear in ordinary decimal format. Numbers outside this range appear in scientific notation with an "E" exponent.


toString

public static java.lang.String toString(Matrix matrix,
                                        int decimals)
Convert matrix entries to a string.

Parameters:
matrix - The matrix to convert to a string.
decimals - Decimal places for each entry.

This produces a matrix with columns of constant width in which the matrix entries are separated by a blank and the rows of the matrix are separated by a linefeed. A fixed format with "decimals" decimal places is used.


toMatlabString

public static java.lang.String toMatlabString(Matrix matrix)
Convert matrix entries to a string in Matlab/Scilab format.

Parameters:
matrix - The matrix to convert to a string.

This produces a matrix with columns of variable width in which the matrix entries are separated by a comma and the rows by a semicolon. Left and right brackets surround the the entire matrix output.

Example: "[-2,3.5,6; 7,8, 9.0; 10,-11,12]"


toGaussString

public static java.lang.String toGaussString(Matrix matrix)
Convert matrix entries to a string in Gauss format.

Parameters:
matrix - The matrix to convert to a string.

This produces a matrix with columns of variable width in which the matrix entries are separated by a blank and the rows by a comma. Left and right braces surround the the entire matrix output.

Example: "{-2 3.5 6, 7 8 9.0, 10,-11,12}"


toMathMLString

public static java.lang.String toMathMLString(Matrix matrix)
Convert matrix entries to a string in MathML format.

Parameters:
matrix - The matrix to convert to a string.

This produces a MathML version of the matrix. See the w3C Math Home page for information about MathML.

Example:

<matrix> <matrixrow> <cn>-2</cn> <cn>3.5</cn> <cn>6</cn> </matrixrow> <matrixrow> <cn>7</cn> <cn>8</cn> <cn>9.0</cn> </matrixrow> <matrixrow> <cn>19</cn> <cn>-11</cn> <cn>12</cn> </matrixrow> </matrix>


toXHTMLString

public static java.lang.String toXHTMLString(Matrix matrix)
Convert matrix entries to a string in XHTML table format.

Parameters:
matrix - The matrix to convert to XHTML string.

This produces an XHTML version of the matrix.

Example:

<matrix> <matrixrow> <cn>-2</cn> <cn>3.5</cn> <cn>6</cn> </matrixrow> <matrixrow> <cn>7</cn> <cn>8</cn> <cn>9.0</cn> </matrixrow> <matrixrow> <cn>19</cn> <cn>-11</cn> <cn>12</cn> </matrixrow> </matrix>


toXHTMLString

public static java.lang.String toXHTMLString(Matrix matrix,
                                             java.lang.String title,
                                             java.lang.String[] columnNames)
Convert matrix entries to a string in XHTML table format.

Parameters:
matrix - The matrix to convert to XHTML string.
title - Title for matrix.
columnNames - Column names.

This produces an XHTML version of the matrix with a title and column names.

Example:

<matrix> <matrixrow> <cn>-2</cn> <cn>3.5</cn> <cn>6</cn> </matrixrow> <matrixrow> <cn>7</cn> <cn>8</cn> <cn>9.0</cn> </matrixrow> <matrixrow> <cn>19</cn> <cn>-11</cn> <cn>12</cn> </matrixrow> </matrix>


toXHTMLString

public static java.lang.String toXHTMLString(Matrix matrix,
                                             java.lang.String title,
                                             java.lang.String[] columnNames,
                                             int border,
                                             java.lang.String formatString)
Convert matrix entries to a string in XHTML table format.

Parameters:
matrix - The matrix to convert to XHTML string.
title - Title for matrix.
columnNames - Column names.
border - Border value for table (0=no border).
formatString - Format string for matrix entries.

This produces an XHTML version of the matrix with a title and column names and with entries in a specified format.

Example:

<matrix> <matrixrow> <cn>-2</cn> <cn>3.5</cn> <cn>6</cn> </matrixrow> <matrixrow> <cn>7</cn> <cn>8</cn> <cn>9.0</cn> </matrixrow> <matrixrow> <cn>19</cn> <cn>-11</cn> <cn>12</cn> </matrixrow> </matrix>


toString

public static java.lang.String toString(Matrix matrix,
                                        java.lang.String title,
                                        boolean titleEmbedded,
                                        java.lang.String[] columnNames,
                                        boolean columnNamesEmbedded,
                                        java.lang.String startTitleString,
                                        java.lang.String endTitleString,
                                        java.lang.String startColumnNamesString,
                                        java.lang.String endColumnNamesString,
                                        java.lang.String startColumnNameString,
                                        java.lang.String endColumnNameString,
                                        java.lang.String startMatrixString,
                                        java.lang.String endMatrixString,
                                        java.lang.String startMatrixRowString,
                                        java.lang.String endMatrixRowString,
                                        java.lang.String endLastMatrixRowString,
                                        java.lang.String startMatrixEntryString,
                                        java.lang.String endMatrixEntryString,
                                        java.lang.String endLastMatrixEntryString,
                                        java.lang.String formatString,
                                        int widthOption)
Convert matrix entries to a string.

Parameters:
matrix - The matrix to convert to a string.
title - Title for matrix. If null, no title output.
titleEmbedded - True to output title after startMatrixString, false to output before StartMatrixString.
columnNames - Names for each column in matrix. If null, no column names output.
columnNamesEmbedded - True to output column names embedded, false otherwise.
startTitleString - String to output before title.
endTitleString - String to output after title.
startColumnNamesString - String to output at start of column names row.
endColumnNamesString - String to output at end of column names row. Wparam startColumnNameString String to output before column name.
endColumnNameString - String to output after column name.
startMatrixString - String to output before the first matrix entry.
endMatrixString - String to output after the last matrix entry.
startMatrixRowString - String to output at start of each matrix row.
endMatrixRowString - String to output at end of each matrix row except last.
endLastMatrixRowString - String to output at end of last matrix row.
startMatrixEntryString - String to output before each matrix entry.
endMatrixEntryString - String to output after each matrix entry except last in row.
endLastMatrixEntryString - String to output after last entry in row.
formatString - PrintfFormat format specification to convert matrix entries.
widthOption - Output width option. "Matrix entry output width options" above for possible values.

If the number of column names specified is less than the number of columns in the matrix, blank column names are used for the remainder. If you do not want any column names, specify null as the value of the columnNames parameter.