public class SparseMatrix extends Matrix
Matrix.ElementVisitorFunction, Matrix.ReadOnlyElementVisitorFunction| Constructor and Description |
|---|
SparseMatrix(int numRows,
int numCols,
int initialCapacityPerRow)
Creates a new matrix of the specified size which has a given capacity for each row.
|
| Modifier and Type | Method and Description |
|---|---|
protected Matrix |
create(int numRows,
int numCols)
Creates a new matrix.
|
protected void |
forEach(Matrix.ElementVisitorFunction func)
Calls the specified function for every non-zero element.
|
void |
forEach(Matrix.ReadOnlyElementVisitorFunction func)
Calls the specified function for every non-zero element.
|
protected double |
getAtUnchecked(int row,
int col)
Gets the value at the specified row and column.
|
int |
getNonZeroColumnCount(int row)
Gets the number of non zero columns of a row.
|
MatrixNonZeroElementRowIterator |
getNonZeroElementRowIterator(int row)
Gets the non-zero matrix row element iterator for a given row index.
|
int |
getNumEntries()
Returns the number of entries (values that have been set) in this sparse matrix.
|
int |
getRowCapacity(int row)
Gets the capacity of a row.
|
protected void |
setAtUnchecked(int row,
int col,
double val)
Sets a value at the specified row and column.
|
java.lang.String |
toString() |
abs, absSum, add, addElementWise, equals, getAt, getColumnCount, getColumnSumVector, getElementCount, getRowCount, getRowSumVector, hashCode, incrementAt, isSameSize, isZeroMatrix, multiply, multiply, multiplyElementWise, normalizeColumns, removeLessThan, removeNegatives, roundTo, scale, setAt, sqrt, sum, transposepublic SparseMatrix(int numRows,
int numCols,
int initialCapacityPerRow)
numRows - The desired number of rows to represent.numCols - The desired number of columns to represent.initialCapacityPerRow - The initial capacity of a row. Choose carefully to avoid
reallocation!protected final Matrix create(int numRows, int numCols)
Matrixprotected final double getAtUnchecked(int row,
int col)
MatrixgetAtUnchecked in class Matrixrow - The row.col - The column.protected final void setAtUnchecked(int row,
int col,
double val)
MatrixsetAtUnchecked in class Matrixrow - The row.col - The column.val - The value.protected final void forEach(Matrix.ElementVisitorFunction func)
Matrixpublic final void forEach(Matrix.ReadOnlyElementVisitorFunction func)
Matrixpublic MatrixNonZeroElementRowIterator getNonZeroElementRowIterator(int row)
MatrixgetNonZeroElementRowIterator in class Matrixrow - The row index.public int getNonZeroColumnCount(int row)
row - The row.public int getRowCapacity(int row)
row - The row.public java.lang.String toString()
toString in class java.lang.Objectpublic int getNumEntries()