|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object edu.northwestern.at.utils.math.matrix.MatrixFromString
public class MatrixFromString
MatrixFromString provides methods for parsing a string containing a matrix.
MatrixFromString can parse the following types of matrix input.
A matrix specified in Matlab/Scilab format.
Example: [ -2,3.5,6; 7,8, 9.0; 10,-11,12 ]
A matrix specified in Gauss format.
Example: { 2 -3.5 6 , 7 -8 9.0, 10 11 12}
A matrix specified in plain text format, with linefeeds separating rows of the matrix.
Example:
2 -3.5 6
7 -8 9.0
10 11 12
A matrix specified in MathML format.
<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>
You can use the method MatrixFromStringParser to parse other types of matrix definition strings as long as these can be specified in terms of regular expressions. MatrixFromStringParser underlies all the parsing methods here.
While it is possible to parse simple MathML using regular expressions, as we do here, it may be better to use an XML parser. To do this, uncomment the imports above for org.jdom.* and see the comments below preceding the method fromMathMLString .
Nested Class Summary | |
---|---|
static class |
MatrixFromString.MatrixFromStringParser
General recursive descent parser class for matrices whose forma can be parsed with regular expressions. |
Constructor Summary | |
---|---|
protected |
MatrixFromString()
Don't allow instantiation, but do allow overrides. |
Method Summary | |
---|---|
static Matrix |
fromGaussString(java.lang.String src)
Parse a matrix definition string in Gauss format. |
static Matrix |
fromMathMLString(java.lang.String src)
Parse a matrix definition string in MathML format. |
static Matrix |
fromMatlabString(java.lang.String src)
Parse a matrix definition string in Matlab format. |
static Matrix |
fromPlainTextString(java.lang.String src)
Parse a matrix definition string in plain text format. |
static Matrix |
parseMatrix(java.lang.String src,
MatrixFromString.MatrixFromStringParser parser)
Parse a matrix definition string with a specified Matrix parser. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final MatrixFromString.MatrixFromStringParser matlabMatrixFromString
public static final MatrixFromString.MatrixFromStringParser gaussMatrixFromString
public static final MatrixFromString.MatrixFromStringParser plainTextMatrixFromString
public static final MatrixFromString.MatrixFromStringParser mathMLMatrixFromString
Constructor Detail |
---|
protected MatrixFromString()
Method Detail |
---|
public static Matrix parseMatrix(java.lang.String src, MatrixFromString.MatrixFromStringParser parser)
src
- String containing matrix definition.parser
- The matrix parser to use.
public static Matrix fromMatlabString(java.lang.String src)
src
- String containing matrix definition.
Sample matrix definition: [ -2,3.5,6; 7,8, 9.0; 10,-11,12 ]
public static Matrix fromGaussString(java.lang.String src)
src
- String containing matrix definition.
Sample matrix definition: { 2 -3.5 6 , 7 -8 9.0, 10 11 12}
public static Matrix fromPlainTextString(java.lang.String src)
src
- String containing matrix definition.
Sample matrix definition:
2 -3.5 6
7 -8 9.0
10 11 12
public static Matrix fromMathMLString(java.lang.String src)
src
- String containing matrix definition.
Sample matrix definition:
<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>
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |