|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Interface defining a real-valued matrix with basic algebraic operations.
Matrix element indexing is 0-based -- e.g., getEntry(0, 0)
returns the element in the first row, first column of the matrix.
Method Summary | |
RealMatrix |
add(RealMatrix m)
Compute the sum of this and m. |
RealMatrix |
copy()
Returns a (deep) copy of this. |
double[] |
getColumn(int col)
Returns the entries in column number col as an array. |
int |
getColumnDimension()
Returns the number of columns in the matrix. |
RealMatrix |
getColumnMatrix(int column)
Returns the entries in column number column
as a column matrix. |
double[][] |
getData()
Returns matrix entries as a two-dimensional array. |
double |
getDeterminant()
Returns the determinant of this matrix. |
double |
getEntry(int row,
int column)
Returns the entry in the specified row and column. |
double |
getNorm()
Returns the maximum absolute row sum norm of the matrix. |
double[] |
getRow(int row)
Returns the entries in row number row as an array. |
int |
getRowDimension()
Returns the number of rows in the matrix. |
RealMatrix |
getRowMatrix(int row)
Returns the entries in row number row
as a row matrix. |
RealMatrix |
getSubMatrix(int[] selectedRows,
int[] selectedColumns)
Gets a submatrix. |
RealMatrix |
getSubMatrix(int startRow,
int endRow,
int startColumn,
int endColumn)
Gets a submatrix. |
double |
getTrace()
Returns the trace of the matrix (the sum of the elements on the main diagonal). |
RealMatrix |
inverse()
Returns the inverse of this matrix. |
boolean |
isSingular()
Is this a singular matrix? |
boolean |
isSquare()
Is this a square matrix? |
RealMatrix |
multiply(RealMatrix m)
Returns the result of postmultiplying this by m. |
double[] |
operate(double[] v)
Returns the result of multiplying this by the vector v . |
double[] |
preMultiply(double[] v)
Returns the (row) vector result of premultiplying this by the vector v . |
RealMatrix |
preMultiply(RealMatrix m)
Returns the result premultiplying this by m . |
RealMatrix |
scalarAdd(double d)
Returns the result of adding d to each entry of this. |
RealMatrix |
scalarMultiply(double d)
Returns the result multiplying each entry of this by d. |
double[] |
solve(double[] b)
Returns the solution vector for a linear system with coefficient matrix = this and constant vector = b . |
RealMatrix |
solve(RealMatrix b)
Returns a matrix of (column) solution vectors for linear systems with coefficient matrix = this and constant vectors = columns of b . |
RealMatrix |
subtract(RealMatrix m)
Compute this minus m. |
RealMatrix |
transpose()
Returns the transpose of this matrix. |
Method Detail |
public RealMatrix copy()
public RealMatrix add(RealMatrix m) throws IllegalArgumentException
m
- matrix to be added
IllegalArgumentException
- if m is not the same size as thispublic RealMatrix subtract(RealMatrix m) throws IllegalArgumentException
m
- matrix to be subtracted
IllegalArgumentException
- if m is not the same size as thispublic RealMatrix scalarAdd(double d)
d
- value to be added to each entry
public RealMatrix scalarMultiply(double d)
d
- value to multiply all entries by
public RealMatrix multiply(RealMatrix m) throws IllegalArgumentException
m
- matrix to postmultiply by
IllegalArgumentException
- if columnDimension(this) != rowDimension(m)public RealMatrix preMultiply(RealMatrix m) throws IllegalArgumentException
m
.
m
- matrix to premultiply by
IllegalArgumentException
- if rowDimension(this) != columnDimension(m)public double[][] getData()
public double getNorm()
public RealMatrix getSubMatrix(int startRow, int endRow, int startColumn, int endColumn) throws MatrixIndexException
startRow
- Initial row indexendRow
- Final row indexstartColumn
- Initial column indexendColumn
- Final column index
MatrixIndexException
- if the indices are not validpublic RealMatrix getSubMatrix(int[] selectedRows, int[] selectedColumns) throws MatrixIndexException
selectedRows
- Array of row indices.selectedColumns
- Array of column indices.
MatrixIndexException
- if row or column selections are not validpublic RealMatrix getRowMatrix(int row) throws MatrixIndexException
row
as a row matrix. Row indices start at 0.
row
- the row to be fetched
MatrixIndexException
- if the specified row index is invalidpublic RealMatrix getColumnMatrix(int column) throws MatrixIndexException
column
as a column matrix. Column indices start at 0.
column
- the column to be fetched
MatrixIndexException
- if the specified column index is invalidpublic double[] getRow(int row) throws MatrixIndexException
row
as an array.
Row indices start at 0. A MatrixIndexException
is thrown
unless 0 <= row < rowDimension.
row
- the row to be fetched
MatrixIndexException
- if the specified row index is not validpublic double[] getColumn(int col) throws MatrixIndexException
col
as an array.
Column indices start at 0. A MatrixIndexException
is thrown
unless 0 <= column < columnDimension.
col
- the column to be fetched
MatrixIndexException
- if the specified column index is not validpublic double getEntry(int row, int column) throws MatrixIndexException
Row and column indices start at 0 and must satisfy
0 <= row < rowDimension
0 <= column < columnDimension
MatrixIndexException
is thrown.
row
- row location of entry to be fetchedcolumn
- column location of entry to be fetched
MatrixIndexException
- if the row or column index is not validpublic RealMatrix transpose()
public RealMatrix inverse() throws InvalidMatrixException
InvalidMatrixException
- if this is not invertiblepublic double getDeterminant()
public boolean isSquare()
public boolean isSingular()
public int getRowDimension()
public int getColumnDimension()
public double getTrace()
public double[] operate(double[] v) throws IllegalArgumentException
v
.
v
- the vector to operate on
IllegalArgumentException
- if columnDimension != v.size()public double[] preMultiply(double[] v) throws IllegalArgumentException
v
.
v
- the row vector to premultiply by
IllegalArgumentException
- if rowDimension != v.size()public double[] solve(double[] b) throws IllegalArgumentException, InvalidMatrixException
b
.
b
- constant vector
IllegalArgumentException
- if this.rowDimension != b.length
InvalidMatrixException
- if this matrix is not square or is singularpublic RealMatrix solve(RealMatrix b) throws IllegalArgumentException, InvalidMatrixException
b
.
b
- matrix of constant vectors forming RHS of linear systems to
to solve
IllegalArgumentException
- if this.rowDimension != row dimension
InvalidMatrixException
- if this matrix is not square or is singular
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |