Package org.apache.commons.math.linear
Class SparseFieldMatrix<T extends FieldElement<T>>
java.lang.Object
org.apache.commons.math.linear.AbstractFieldMatrix<T>
org.apache.commons.math.linear.SparseFieldMatrix<T>
- Type Parameters:
T- the type of the field elements
- All Implemented Interfaces:
AnyMatrix,FieldMatrix<T>
Sparse matrix implementation based on an open addressed map.
- Since:
- 2.0
-
Constructor Summary
ConstructorsConstructorDescriptionSparseFieldMatrix(Field<T> field) Creates a matrix with no data.SparseFieldMatrix(Field<T> field, int rowDimension, int columnDimension) Create a new SparseFieldMatrixwith the supplied row and column dimensions. SparseFieldMatrix(FieldMatrix<T> other) Generic copy constructor.SparseFieldMatrix(SparseFieldMatrix<T> other) Copy constructor. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddToEntry(int row, int column, T 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 FieldMatrixof the same type as the instance with the supplied row and column dimensions. intReturns the number of columns in the matrix.getEntry(int row, int column) Returns the entry in the specified row and column.intReturns the number of rows in the matrix.voidmultiplyEntry(int row, int column, T factor) Change an entry in the specified row and column.voidSet the entry in the specified row and column.Methods inherited from class org.apache.commons.math.linear.AbstractFieldMatrix
add, copySubMatrix, copySubMatrix, equals, getColumn, getColumnMatrix, getColumnVector, getData, getField, getRow, getRowMatrix, getRowVector, getSubMatrix, getSubMatrix, getTrace, hashCode, isSquare, multiply, operate, operate, preMultiply, preMultiply, preMultiply, scalarAdd, scalarMultiply, setColumn, setColumnMatrix, setColumnVector, setRow, setRowMatrix, setRowVector, setSubMatrix, subtract, toString, transpose, walkInColumnOrder, walkInColumnOrder, walkInColumnOrder, walkInColumnOrder, walkInOptimizedOrder, walkInOptimizedOrder, walkInOptimizedOrder, walkInOptimizedOrder, walkInRowOrder, walkInRowOrder, walkInRowOrder, walkInRowOrder
-
Constructor Details
-
SparseFieldMatrix
Creates a matrix with no data.- Parameters:
field- field to which the elements belong
-
SparseFieldMatrix
public SparseFieldMatrix(Field<T> field, int rowDimension, int columnDimension) throws IllegalArgumentException Create a new SparseFieldMatrixwith the supplied row and column dimensions. - Parameters:
field- field to which the elements belongrowDimension- the number of rows in the new matrixcolumnDimension- the number of columns in the new matrix- Throws:
IllegalArgumentException- if row or column dimension is not positive
-
SparseFieldMatrix
Copy constructor.- Parameters:
other- The instance to copy
-
SparseFieldMatrix
Generic copy constructor.- Parameters:
other- The instance to copy
-
-
Method Details
-
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 interfaceFieldMatrix<T extends FieldElement<T>>- Specified by:
addToEntryin classAbstractFieldMatrix<T extends FieldElement<T>>- 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
-
copy
Returns a (deep) copy of this.- Specified by:
copyin interfaceFieldMatrix<T extends FieldElement<T>>- Specified by:
copyin classAbstractFieldMatrix<T extends FieldElement<T>>- Returns:
- matrix copy
-
createMatrix
public FieldMatrix<T> createMatrix(int rowDimension, int columnDimension) throws IllegalArgumentException Create a new FieldMatrixof the same type as the instance with the supplied row and column dimensions. - Specified by:
createMatrixin interfaceFieldMatrix<T extends FieldElement<T>>- Specified by:
createMatrixin classAbstractFieldMatrix<T extends FieldElement<T>>- 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 classAbstractFieldMatrix<T extends FieldElement<T>>- Returns:
- columnDimension
-
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 interfaceFieldMatrix<T extends FieldElement<T>>- Specified by:
getEntryin classAbstractFieldMatrix<T extends FieldElement<T>>- 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 classAbstractFieldMatrix<T extends FieldElement<T>>- Returns:
- rowDimension
-
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 interfaceFieldMatrix<T extends FieldElement<T>>- Specified by:
multiplyEntryin classAbstractFieldMatrix<T extends FieldElement<T>>- 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
-
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 interfaceFieldMatrix<T extends FieldElement<T>>- Specified by:
setEntryin classAbstractFieldMatrix<T extends FieldElement<T>>- 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
-