Package org.apache.commons.math.linear
Class OpenMapRealMatrix
java.lang.Object
org.apache.commons.math.linear.AbstractRealMatrix
org.apache.commons.math.linear.OpenMapRealMatrix
- All Implemented Interfaces:
Serializable,AnyMatrix,RealMatrix,SparseRealMatrix
Sparse matrix implementation based on an open addressed map.
- Since:
- 2.0
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionOpenMapRealMatrix(int rowDimension, int columnDimension) Build a sparse matrix with the supplied row and column dimensions.OpenMapRealMatrix(OpenMapRealMatrix matrix) Build a matrix by copying another one. -
Method Summary
Modifier and TypeMethodDescriptionCompute the sum of this andm.add(RealMatrix m) Compute the sum of this and m.voidaddToEntry(int row, int column, double increment) Change an entry in the specified row and column.copy()Returns a (deep) copy of this.createMatrix(int rowDimension, int columnDimension) Create a new RealMatrix of the same type as the instance with the supplied row and column dimensions.intReturns the number of columns in the matrix.doublegetEntry(int row, int column) Returns the entry in the specified row and column.intReturns the number of rows in the matrix.Returns the result of postmultiplying this by m.Returns the result of postmultiplying this by m.voidmultiplyEntry(int row, int column, double factor) Change an entry in the specified row and column.voidsetEntry(int row, int column, double value) Set the entry in the specified row and column.Compute this minusm.Compute this minus m.Methods inherited from class org.apache.commons.math.linear.AbstractRealMatrix
copySubMatrix, copySubMatrix, equals, getColumn, getColumnMatrix, getColumnVector, getData, getDeterminant, getFrobeniusNorm, getNorm, getRow, getRowMatrix, getRowVector, getSubMatrix, getSubMatrix, getTrace, hashCode, inverse, isSingular, isSquare, luDecompose, operate, operate, preMultiply, preMultiply, preMultiply, scalarAdd, scalarMultiply, setColumn, setColumnMatrix, setColumnVector, setRow, setRowMatrix, setRowVector, setSubMatrix, solve, solve, toString, transpose, walkInColumnOrder, walkInColumnOrder, walkInColumnOrder, walkInColumnOrder, walkInOptimizedOrder, walkInOptimizedOrder, walkInOptimizedOrder, walkInOptimizedOrder, walkInRowOrder, walkInRowOrder, walkInRowOrder, walkInRowOrderMethods inherited from interface org.apache.commons.math.linear.RealMatrix
copySubMatrix, copySubMatrix, getColumn, getColumnMatrix, getColumnVector, getData, getDeterminant, getFrobeniusNorm, getNorm, getRow, getRowMatrix, getRowVector, getSubMatrix, getSubMatrix, getTrace, inverse, isSingular, operate, operate, preMultiply, preMultiply, preMultiply, scalarAdd, scalarMultiply, setColumn, setColumnMatrix, setColumnVector, setRow, setRowMatrix, setRowVector, setSubMatrix, solve, solve, transpose, walkInColumnOrder, walkInColumnOrder, walkInColumnOrder, walkInColumnOrder, walkInOptimizedOrder, walkInOptimizedOrder, walkInOptimizedOrder, walkInOptimizedOrder, walkInRowOrder, walkInRowOrder, walkInRowOrder, walkInRowOrder
-
Constructor Details
-
OpenMapRealMatrix
public OpenMapRealMatrix(int rowDimension, int columnDimension) Build a sparse matrix with the supplied row and column dimensions.- Parameters:
rowDimension- number of rows of the matrixcolumnDimension- number of columns of the matrix
-
OpenMapRealMatrix
Build a matrix by copying another one.- Parameters:
matrix- matrix to copy
-
-
Method Details
-
copy
Returns a (deep) copy of this.- Specified by:
copyin interfaceRealMatrix- Specified by:
copyin classAbstractRealMatrix- Returns:
- matrix copy
-
createMatrix
public OpenMapRealMatrix createMatrix(int rowDimension, int columnDimension) throws IllegalArgumentException Create a new RealMatrix of the same type as the instance with the supplied row and column dimensions.- Specified by:
createMatrixin interfaceRealMatrix- Specified by:
createMatrixin classAbstractRealMatrix- Parameters:
rowDimension- the number of rows in the new matrixcolumnDimension- the number of columns in the new matrix- Returns:
- a new matrix of the same type as the instance
- Throws:
IllegalArgumentException- if row or column dimension is not positive
-
getColumnDimension
public int getColumnDimension()Returns the number of columns in the matrix.- Specified by:
getColumnDimensionin interfaceAnyMatrix- Specified by:
getColumnDimensionin classAbstractRealMatrix- Returns:
- columnDimension
-
add
Compute the sum of this and m.- Specified by:
addin interfaceRealMatrix- Overrides:
addin classAbstractRealMatrix- Parameters:
m- matrix to be added- Returns:
- this + m
- Throws:
IllegalArgumentException- if m is not the same size as this
-
add
Compute the sum of this andm.- Parameters:
m- matrix to be added- Returns:
- this + m
- Throws:
IllegalArgumentException- if m is not the same size as this
-
subtract
Compute this minus m.- Specified by:
subtractin interfaceRealMatrix- Overrides:
subtractin classAbstractRealMatrix- Parameters:
m- matrix to be subtracted- Returns:
- this - m
- Throws:
IllegalArgumentException- if m is not the same size as this
-
subtract
Compute this minusm.- Parameters:
m- matrix to be subtracted- Returns:
- this - m
- Throws:
IllegalArgumentException- if m is not the same size as this
-
multiply
Returns the result of postmultiplying this by m.- Specified by:
multiplyin interfaceRealMatrix- Overrides:
multiplyin classAbstractRealMatrix- Parameters:
m- matrix to postmultiply by- Returns:
- this * m
- Throws:
IllegalArgumentException- if columnDimension(this) != rowDimension(m)
-
multiply
Returns the result of postmultiplying this by m.- Parameters:
m- matrix to postmultiply by- Returns:
- this * m
- Throws:
IllegalArgumentException- if columnDimension(this) != rowDimension(m)
-
getEntry
Returns the entry in the specified row and column.Row and column indices start at 0 and must satisfy
0 invalid input: '<'= row invalid input: '<' rowDimension0 invalid input: '<'= column invalid input: '<' columnDimension
MatrixIndexExceptionis thrown.- Specified by:
getEntryin interfaceRealMatrix- Specified by:
getEntryin classAbstractRealMatrix- Parameters:
row- row location of entry to be fetchedcolumn- column location of entry to be fetched- Returns:
- matrix entry in row,column
- Throws:
MatrixIndexException- if the row or column index is not valid
-
getRowDimension
public int getRowDimension()Returns the number of rows in the matrix.- Specified by:
getRowDimensionin interfaceAnyMatrix- Specified by:
getRowDimensionin classAbstractRealMatrix- Returns:
- rowDimension
-
setEntry
Set the entry in the specified row and column.Row and column indices start at 0 and must satisfy
0 invalid input: '<'= row invalid input: '<' rowDimension0 invalid input: '<'= column invalid input: '<' columnDimension
MatrixIndexExceptionis thrown.- Specified by:
setEntryin interfaceRealMatrix- Specified by:
setEntryin classAbstractRealMatrix- Parameters:
row- row location of entry to be setcolumn- column location of entry to be setvalue- matrix entry to be set in row,column- Throws:
MatrixIndexException- if the row or column index is not valid
-
addToEntry
Change an entry in the specified row and column.Row and column indices start at 0 and must satisfy
0 invalid input: '<'= row invalid input: '<' rowDimension0 invalid input: '<'= column invalid input: '<' columnDimension
MatrixIndexExceptionis thrown.- Specified by:
addToEntryin interfaceRealMatrix- Specified by:
addToEntryin classAbstractRealMatrix- Parameters:
row- row location of entry to be setcolumn- column location of entry to be setincrement- value to add to the current matrix entry in row,column- Throws:
MatrixIndexException- if the row or column index is not valid
-
multiplyEntry
Change an entry in the specified row and column.Row and column indices start at 0 and must satisfy
0 invalid input: '<'= row invalid input: '<' rowDimension0 invalid input: '<'= column invalid input: '<' columnDimension
MatrixIndexExceptionis thrown.- Specified by:
multiplyEntryin interfaceRealMatrix- Specified by:
multiplyEntryin classAbstractRealMatrix- Parameters:
row- row location of entry to be setcolumn- column location of entry to be setfactor- multiplication factor for the current matrix entry in row,column- Throws:
MatrixIndexException- if the row or column index is not valid
-