

Public Member Functions | |
| Matrix (int m, int n) | |
| Matrix (int m, int n, double s) | |
| int | getNumRows () |
| int | getNumColumns () |
| Matrix (double[][] A) | |
| Matrix (double[][] A, int m, int n) | |
| Matrix (double vals[], int m) | |
| Matrix | copy () |
| Object | clone () |
| double[][] | getArray () |
| double[][] | getArrayCopy () |
| double[] | getColumnPackedCopy () |
| double[] | getRowPackedCopy () |
| int | getRowDimension () |
| int | getColumnDimension () |
| double | get (int i, int j) |
| double[] | getRow (int i) |
| double[] | getColumn (int j) |
| Matrix | getMatrix (int i0, int i1, int j0, int j1) |
| Matrix | getMatrix (int[] r, int[] c) |
| Matrix | getMatrix (int i0, int i1, int[] c) |
| Matrix | getMatrix (int[] r, int j0, int j1) |
| void | set (int i, int j, double s) |
| void | setMatrix (int i0, int i1, int j0, int j1, Matrix X) |
| void | setMatrix (int[] r, int[] c, Matrix X) |
| void | setMatrix (int[] r, int j0, int j1, Matrix X) |
| void | setMatrix (int i0, int i1, int[] c, Matrix X) |
| Matrix | transpose () |
| double | norm1 () |
| double | norm2 () |
| double | normInf () |
| double | normF () |
| Matrix | uminus () |
| Matrix | plus (Matrix B) |
| Matrix | plusEquals (Matrix B) |
| Matrix | minus (Matrix B) |
| Matrix | minusEquals (Matrix B) |
| Matrix | arrayTimes (Matrix B) |
| Matrix | arrayTimesEquals (Matrix B) |
| Matrix | arrayRightDivide (Matrix B) |
| Matrix | arrayRightDivideEquals (Matrix B) |
| Matrix | arrayLeftDivide (Matrix B) |
| Matrix | arrayLeftDivideEquals (Matrix B) |
| Matrix | times (double s) |
| Matrix | timesEquals (double s) |
| Matrix | times (Matrix B) |
| LUDecomposition | lu () |
| QRDecomposition | qr () |
| CholeskyDecomposition | chol () |
| SingularValueDecomposition | svd () |
| EigenvalueDecomposition | eig () |
| Matrix | solve (Matrix B) |
| Matrix | solveTranspose (Matrix B) |
| Matrix | inverse () |
| double | det () |
| int | rank () |
| double | cond () |
| double | trace () |
| void | print (int w, int d) |
| void | print (PrintWriter output, int w, int d) |
| void | print (NumberFormat format, int width) |
| void | print (PrintWriter output, NumberFormat format, int width) |
| boolean | isSymmetric () |
| boolean | isDiagonal () |
| void | quantileNormalizeColumns () |
| Matrix | sortColumnsKeepingIndex (Matrix index) |
| Matrix | sortColumns () |
| void | setColumn (int column, double[] vals) |
| boolean | setRow (int row, double[] vals) |
| boolean | setRow (int row, int[] vals) |
| String | toString () |
| void | write (String save, double[] observed) throws IOException |
Static Public Member Functions | |
| static Matrix | constructWithCopy (double[][] A) |
| static Matrix | random (int m, int n) |
| static Matrix | identity (int m, int n) |
| static Matrix | read (BufferedReader input) throws java.io.IOException |
The Java Matrix Class provides the fundamental operations of numerical linear algebra. Various constructors create Matrices from two dimensional arrays of double precision floating point numbers. Various "gets" and "sets" provide access to submatrices and matrix elements. Several methods implement basic matrix arithmetic, including matrix addition and multiplication, matrix norms, and element-by-element array operations. Methods for reading and printing matrices are also included. All the operations in this version of the Matrix Class involve real matrices. Complex matrices may be handled in a future version.
Five fundamental matrix decompositions, which consist of pairs or triples of matrices, permutation vectors, and the like, produce results in five decomposition classes. These decompositions are accessed by the Matrix class to compute solutions of simultaneous linear equations, determinants, inverses and other matrix functions. The five decompositions are:
Solve a linear system A x = b and compute the residual norm, ||b - A x||.
double[][] vals = {{1.,2.,3},{4.,5.,6.},{7.,8.,10.}};
Matrix A = new Matrix(vals);
Matrix b = Matrix.random(3,1);
Matrix x = A.solve(b);
Matrix r = A.times(x).minus(b);
double rnorm = r.normInf();
| Jama.Matrix.Matrix | ( | int | m, |
| int | n | ||
| ) |
Construct an m-by-n matrix of zeros.
| m | Number of rows. |
| n | Number of colums. |

| Jama.Matrix.Matrix | ( | int | m, |
| int | n, | ||
| double | s | ||
| ) |
Construct an m-by-n constant matrix.
| m | Number of rows. |
| n | Number of colums. |
| s | Fill the matrix with this scalar value. |
| Jama.Matrix.Matrix | ( | double | A[][] | ) |
Construct a matrix from a 2-D array.
| A | Two-dimensional array of doubles. |
| IllegalArgumentException | All rows must have the same length |
| Jama.Matrix.Matrix | ( | double | A[][], |
| int | m, | ||
| int | n | ||
| ) |
Construct a matrix quickly without checking arguments.
| A | Two-dimensional array of doubles. |
| m | Number of rows. |
| n | Number of colums. |
| Jama.Matrix.Matrix | ( | double | vals[], |
| int | m | ||
| ) |
Construct a matrix from a one-dimensional packed array
| vals | One-dimensional array of doubles, packed by columns (ala Fortran). |
| m | Number of rows. |
| IllegalArgumentException | Array length must be a multiple of m. |
Element-by-element left division, C = A.
| B | another matrix |

Element-by-element left division in place, A = A.
| B | another matrix |
Element-by-element right division, C = A./B
| B | another matrix |

Element-by-element right division in place, A = A./B
| B | another matrix |
Element-by-element multiplication, C = A.*B
| B | another matrix |

Element-by-element multiplication in place, A = A.*B
| B | another matrix |
| CholeskyDecomposition Jama.Matrix.chol | ( | ) |
| Object Jama.Matrix.clone | ( | ) |
Clone the Matrix object.
| double Jama.Matrix.cond | ( | ) |
Matrix condition (2 norm)
|
static |
Construct a matrix from a copy of a 2-D array.
| A | Two-dimensional array of doubles. |
| IllegalArgumentException | All rows must have the same length |

| Matrix Jama.Matrix.copy | ( | ) |
Make a deep copy of a matrix


| double Jama.Matrix.det | ( | ) |
Matrix determinant
| EigenvalueDecomposition Jama.Matrix.eig | ( | ) |
| double Jama.Matrix.get | ( | int | i, |
| int | j | ||
| ) |
Get a single element.
| i | Row index. |
| j | Column index. |
| ArrayIndexOutOfBoundsException |

| double [][] Jama.Matrix.getArray | ( | ) |
Access the internal two-dimensional array.
| double [][] Jama.Matrix.getArrayCopy | ( | ) |
Copy the internal two-dimensional array.
| double [] Jama.Matrix.getColumn | ( | int | j | ) |

| int Jama.Matrix.getColumnDimension | ( | ) |
Get column dimension.

| double [] Jama.Matrix.getColumnPackedCopy | ( | ) |
Make a one-dimensional column packed copy of the internal array.
| Matrix Jama.Matrix.getMatrix | ( | int | i0, |
| int | i1, | ||
| int | j0, | ||
| int | j1 | ||
| ) |
Get a submatrix.
| i0 | Initial row index |
| i1 | Final row index |
| j0 | Initial column index |
| j1 | Final column index |
| ArrayIndexOutOfBoundsException | Submatrix indices |

| Matrix Jama.Matrix.getMatrix | ( | int[] | r, |
| int[] | c | ||
| ) |
Get a submatrix.
| r | Array of row indices. |
| c | Array of column indices. |
| ArrayIndexOutOfBoundsException | Submatrix indices |

| Matrix Jama.Matrix.getMatrix | ( | int | i0, |
| int | i1, | ||
| int[] | c | ||
| ) |
Get a submatrix.
| i0 | Initial row index |
| i1 | Final row index |
| c | Array of column indices. |
| ArrayIndexOutOfBoundsException | Submatrix indices |

| Matrix Jama.Matrix.getMatrix | ( | int[] | r, |
| int | j0, | ||
| int | j1 | ||
| ) |
Get a submatrix.
| r | Array of row indices. |
| i0 | Initial column index |
| i1 | Final column index |
| ArrayIndexOutOfBoundsException | Submatrix indices |

| int Jama.Matrix.getNumColumns | ( | ) |
| int Jama.Matrix.getNumRows | ( | ) |

| double [] Jama.Matrix.getRow | ( | int | i | ) |
| int Jama.Matrix.getRowDimension | ( | ) |
Get row dimension.

| double [] Jama.Matrix.getRowPackedCopy | ( | ) |
Make a one-dimensional row packed copy of the internal array.
|
static |
Generate identity matrix
| m | Number of rows. |
| n | Number of colums. |


| Matrix Jama.Matrix.inverse | ( | ) |
Matrix inverse or pseudoinverse

| boolean Jama.Matrix.isDiagonal | ( | ) |
| boolean Jama.Matrix.isSymmetric | ( | ) |
| LUDecomposition Jama.Matrix.lu | ( | ) |
C = A - B
| B | another matrix |

| double Jama.Matrix.norm1 | ( | ) |
One norm
| double Jama.Matrix.norm2 | ( | ) |
Two norm
| double Jama.Matrix.normF | ( | ) |
Frobenius norm
| double Jama.Matrix.normInf | ( | ) |
Infinity norm
C = A + B
| B | another matrix |

| void Jama.Matrix.print | ( | int | w, |
| int | d | ||
| ) |
Print the matrix to stdout. Line the elements up in columns with a Fortran-like 'Fw.d' style format.
| w | Column width. |
| d | Number of digits after the decimal. |

| void Jama.Matrix.print | ( | PrintWriter | output, |
| int | w, | ||
| int | d | ||
| ) |
Print the matrix to the output stream. Line the elements up in columns with a Fortran-like 'Fw.d' style format.
| output | Output stream. |
| w | Column width. |
| d | Number of digits after the decimal. |

| void Jama.Matrix.print | ( | NumberFormat | format, |
| int | width | ||
| ) |
Print the matrix to stdout. Line the elements up in columns. Use the format object, and right justify within columns of width characters. Note that is the matrix is to be read back in, you probably will want to use a NumberFormat that is set to US Locale.
| format | A Formatting object for individual elements. |
| width | Field width for each column. |

| void Jama.Matrix.print | ( | PrintWriter | output, |
| NumberFormat | format, | ||
| int | width | ||
| ) |
Print the matrix to the output stream. Line the elements up in columns. Use the format object, and right justify within columns of width characters. Note that is the matrix is to be read back in, you probably will want to use a NumberFormat that is set to US Locale.
| output | the output stream. |
| format | A formatting object to format the matrix elements |
| width | Column width. |
| QRDecomposition Jama.Matrix.qr | ( | ) |
| void Jama.Matrix.quantileNormalizeColumns | ( | ) |

|
static |
Generate matrix with random elements
| m | Number of rows. |
| n | Number of colums. |

| int Jama.Matrix.rank | ( | ) |
Matrix rank
|
static |
Read a matrix from a stream. The format is the same the print method, so printed matrices can be read back in (provided they were printed using US Locale). Elements are separated by whitespace, all the elements for each row appear on a single line, the last row is followed by a blank line.
| input | the input stream. |

| void Jama.Matrix.set | ( | int | i, |
| int | j, | ||
| double | s | ||
| ) |
Set a single element.
| i | Row index. |
| j | Column index. |
| s | A(i,j). |
| ArrayIndexOutOfBoundsException |

| void Jama.Matrix.setColumn | ( | int | column, |
| double[] | vals | ||
| ) |

| void Jama.Matrix.setMatrix | ( | int | i0, |
| int | i1, | ||
| int | j0, | ||
| int | j1, | ||
| Matrix | X | ||
| ) |
Set a submatrix.
| i0 | Initial row index |
| i1 | Final row index |
| j0 | Initial column index |
| j1 | Final column index |
| X | A(i0:i1,j0:j1) |
| ArrayIndexOutOfBoundsException | Submatrix indices |
| void Jama.Matrix.setMatrix | ( | int[] | r, |
| int[] | c, | ||
| Matrix | X | ||
| ) |
Set a submatrix.
| r | Array of row indices. |
| c | Array of column indices. |
| X | A(r(:),c(:)) |
| ArrayIndexOutOfBoundsException | Submatrix indices |
| void Jama.Matrix.setMatrix | ( | int[] | r, |
| int | j0, | ||
| int | j1, | ||
| Matrix | X | ||
| ) |
Set a submatrix.
| r | Array of row indices. |
| j0 | Initial column index |
| j1 | Final column index |
| X | A(r(:),j0:j1) |
| ArrayIndexOutOfBoundsException | Submatrix indices |
| void Jama.Matrix.setMatrix | ( | int | i0, |
| int | i1, | ||
| int[] | c, | ||
| Matrix | X | ||
| ) |
Set a submatrix.
| i0 | Initial row index |
| i1 | Final row index |
| c | Array of column indices. |
| X | A(i0:i1,c(:)) |
| ArrayIndexOutOfBoundsException | Submatrix indices |
| boolean Jama.Matrix.setRow | ( | int | row, |
| double[] | vals | ||
| ) |

| boolean Jama.Matrix.setRow | ( | int | row, |
| int[] | vals | ||
| ) |

Solve A*X = B
| B | right hand side |

Solve X*A = B, which is also A'*X' = B'
| B | right hand side |

| Matrix Jama.Matrix.sortColumns | ( | ) |



| SingularValueDecomposition Jama.Matrix.svd | ( | ) |
| Matrix Jama.Matrix.times | ( | double | s | ) |
Multiply a matrix by a scalar, C = s*A
| s | scalar |

| Matrix Jama.Matrix.timesEquals | ( | double | s | ) |
Multiply a matrix by a scalar in place, A = s*A
| s | scalar |
| String Jama.Matrix.toString | ( | ) |
| double Jama.Matrix.trace | ( | ) |
Matrix trace.
| Matrix Jama.Matrix.transpose | ( | ) |
Matrix transpose.


| Matrix Jama.Matrix.uminus | ( | ) |
Unary minus

| void Jama.Matrix.write | ( | String | save, |
| double[] | observed | ||
| ) | throws IOException |
1.8.7