public class SparseSymmetricMatrix extends AbstractMatrix implements SparseMatrix, Serializable
SparseMatrix that keeps only the upper
triangular values while providing a symmetric view of the data. This class
only records changes values where row > col. For all other values, the
row and column values are swapped and then the backing matrix is updated.
Note, that if the provided backing matrix has existing values for indices row
< col, these values will be ignored and never returned from any method.
Note the original perfomance characteristics of the backing matrix are
retained by this class.
The primary benfit of this class is for storing large symmetric sparse matrices in half of the memory.
Matrix.Type| Constructor and Description |
|---|
SparseSymmetricMatrix(SparseMatrix backing)
Constructs a sparse matrix with the specified dimensions.
|
| Modifier and Type | Method and Description |
|---|---|
int |
columns()
Returns the number of columns in this
Matrix. |
double |
get(int row,
int column)
Returns the value of the
Matrix at the provided row and column. |
SparseDoubleVector |
getColumnVector(int column)
Returns the column as a vector.
|
SparseDoubleVector |
getRowVector(int row)
Returns a
DoubleVector for an entire row. |
int |
rows()
Returns the number of rows in this
Matrix. |
void |
set(int row,
int column,
double val)
Throws an
UnsupportedOperationException if called (matrix is
unmodifiable). |
equals, getColumn, getRow, hashCode, setColumn, setColumn, setRow, setRow, toDenseArraypublic SparseSymmetricMatrix(SparseMatrix backing)
public int columns()
Matrix.columns in interface Matrixcolumns in class AbstractMatrixMatrix.public double get(int row,
int column)
Matrix at the provided row and column.get in interface Matrixget in class AbstractMatrixrow - The row values of the cell to return.column - The column value of the cell to return.row and col.public SparseDoubleVector getColumnVector(int column)
SparseVector instance.getColumnVector in interface MatrixgetColumnVector in interface SparseMatrixgetColumnVector in class AbstractMatrixcolumn - The column to return a DoubleVector for.DoubleVector representing the column at column.public SparseDoubleVector getRowVector(int row)
DoubleVector for an entire row. Implementations should
return an approriately typed DoubleVector. Whether updates to the vector
are written through to the backing matrix is left open to the specific
implementation. Implementations that maintain their data in a sparse
format are encouraged to return a SparseVector instance.getRowVector in interface MatrixgetRowVector in interface SparseMatrixgetRowVector in class AbstractMatrixrow - the index of the row to return.DoubleVector representing the row at row.public int rows()
Matrix.rows in interface Matrixrows in class AbstractMatrixMatrix.public void set(int row,
int column,
double val)
UnsupportedOperationException if called (matrix is
unmodifiable).set in interface Matrixset in class AbstractMatrixrow - The row of the cell to update.column - The column of the cell to update.val - The new value of the specified cell.Copyright © 2012. All Rights Reserved.