public class SparseMatrix extends Object implements Matrix
1.0 0.0 4.0
0.0 3.0 5.0
2.0 0.0 6.0
is stored as values: [1.0, 2.0, 3.0, 4.0, 5.0, 6.0]
,
rowIndices=[0, 2, 1, 0, 1, 2]
, colPointers=[0, 2, 3, 6]
.
Constructor and Description |
---|
SparseMatrix(int numRows,
int numCols,
int[] colPtrs,
int[] rowIndices,
double[] values) |
Modifier and Type | Method and Description |
---|---|
double |
apply(int i,
int j)
Gets the (i, j)-th element.
|
int[] |
colPtrs() |
SparseMatrix |
copy()
Get a deep copy of the matrix.
|
int |
index(int i,
int j)
Return the index for the (i, j)-th element in the backing array.
|
int |
numCols()
Number of columns.
|
int |
numRows()
Number of rows.
|
int[] |
rowIndices() |
double[] |
toArray()
Converts to a dense array in column major.
|
breeze.linalg.Matrix<Object> |
toBreeze()
Converts to a breeze matrix.
|
void |
update(int i,
int j,
double v)
Update element at (i, j)
|
double[] |
values() |
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
multiply, multiply, toString, transposeMultiply, transposeMultiply
public SparseMatrix(int numRows, int numCols, int[] colPtrs, int[] rowIndices, double[] values)
public int numRows()
Matrix
public int numCols()
Matrix
public int[] colPtrs()
public int[] rowIndices()
public double[] values()
public double[] toArray()
Matrix
public breeze.linalg.Matrix<Object> toBreeze()
Matrix
public double apply(int i, int j)
Matrix
public int index(int i, int j)
Matrix
public void update(int i, int j, double v)
Matrix
public SparseMatrix copy()
Matrix