public class DOKSparseMatrix extends Object implements SparseMatrix
SparseMatrix.Entry, SparseMatrix.ValueArray| Constructor and Description |
|---|
DOKSparseMatrix(DOKSparseMatrix that)
Copy constructor.
|
DOKSparseMatrix(int nRows,
int nCols)
Construct a sparse matrix in DOK format.
|
DOKSparseMatrix(int nRows,
int nCols,
int[] rowIndices,
int[] columnIndices,
double[] value)
Construct a sparse matrix in DOK format.
|
DOKSparseMatrix(int nRows,
int nCols,
List<SparseMatrix.Entry> entries)
Construct a sparse matrix in DOK format by a list of non-zero entries.
|
| Modifier and Type | Method and Description |
|---|---|
Matrix |
add(Matrix that)
this + that
|
DOKSparseMatrix |
deepCopy()
The implementation returns an instance created from
this by the copy
constructor of the class, or just this if the instance itself is
immutable. |
boolean |
equals(Object obj) |
double |
get(int i,
int j)
Get the matrix entry at [i,j].
|
SparseVector |
getColumn(int j)
Get the specified column in the matrix as a vector.
|
List<SparseMatrix.Entry> |
getEntryList()
Exports the non-zero values in the matrix as a list of
SparseMatrix.Entrys. |
SparseVector |
getRow(int i)
Get the specified row in the matrix as a vector.
|
SparseMatrix.ValueArray |
getValueArray()
Exports the non-zero values in the matrix as arrays of row/column indices
and values.
|
int |
hashCode() |
Matrix |
minus(Matrix that)
this - that
|
Matrix |
multiply(Matrix that)
this * that
|
Vector |
multiply(Vector v)
Right multiply this matrix, A, by a vector.
|
int |
nCols()
Gets the number of columns.
|
int |
nNonZeros()
Get the number of non-zero entries in the structure.
|
int |
nRows()
Gets the number of rows.
|
DOKSparseMatrix |
ONE()
Get an identity matrix that has the same dimension as this matrix.
|
DOKSparseMatrix |
opposite()
Get the opposite of this matrix.
|
DOKSparseMatrix |
scaled(double c)
Scale this matrix, A, by a constant.
|
void |
set(int row,
int col,
double value)
Set the matrix entry at [i,j] to a value.
|
DOKSparseMatrix |
t()
Get the transpose of this matrix.
|
DenseMatrix |
toDense()
Densify a matrix, i.e., convert a matrix implementation to the standard dense matrix,
DenseMatrix. |
String |
toString() |
DOKSparseMatrix |
ZERO()
Get a zero matrix that has the same dimension as this matrix.
|
public DOKSparseMatrix(int nRows,
int nCols)
nRows - the number of rowsnCols - the number of columnspublic DOKSparseMatrix(int nRows,
int nCols,
int[] rowIndices,
int[] columnIndices,
double[] value)
nRows - the number of rowsnCols - the number of columnsrowIndices - the row indices of the non-zeros valuescolumnIndices - the column indices of the non-zeros valuesvalue - the non-zero valuespublic DOKSparseMatrix(int nRows,
int nCols,
List<SparseMatrix.Entry> entries)
nRows - the number of rowsnCols - the number of columnsentries - the entry listpublic DOKSparseMatrix(DOKSparseMatrix that)
that - the matrix to be copiedpublic int nRows()
Tablepublic int nCols()
Tablepublic List<SparseMatrix.Entry> getEntryList()
SparseMatrixSparseMatrix.Entrys. This is useful
for converting between the different formats of SparseMatrix.Entry. For example,
// construct matrix using DOK DOKSparseMatrix dok = new DOKSparseMatrix(5, 5); // ... insert some values to DOK matrix // convert to CSR matrix for efficient matrix operations CSRSparseMatrix csr = new CSRSparseMatrix(5, 5, dok.getEntryList());
getEntryList in interface SparseMatrixpublic SparseMatrix.ValueArray getValueArray()
SparseMatrixgetValueArray in interface SparseMatrixSparseMatrix.ValueArraypublic void set(int row,
int col,
double value)
MatrixAccessset in interface MatrixAccessrow - the row indexcol - the column indexvalue - the value to set A[i,j] topublic double get(int i,
int j)
MatrixAccessget in interface MatrixAccessi - the row indexj - the column indexpublic SparseVector getRow(int i) throws MatrixAccessException
MatrixgetRow in interface Matrixi - the row indexMatrixAccessException - when i < 1, or when i > the number of rowspublic SparseVector getColumn(int j) throws MatrixAccessException
MatrixgetColumn in interface Matrixj - the column indexMatrixAccessException - when j < 1, or when j > the number of columnspublic Matrix add(Matrix that)
MatrixRingadd in interface MatrixRingadd in interface AbelianGroup<Matrix>that - a matrixthis and thatpublic Matrix minus(Matrix that)
MatrixRingminus in interface MatrixRingminus in interface AbelianGroup<Matrix>that - a matrixthis and thatpublic Matrix multiply(Matrix that)
MatrixRingmultiply in interface MatrixRingmultiply in interface Monoid<Matrix>that - a matrixthis and thatpublic Vector multiply(Vector v)
Matrixpublic DOKSparseMatrix scaled(double c)
Matrixpublic DOKSparseMatrix opposite()
MatrixRingopposite in interface MatrixRingopposite in interface AbelianGroup<Matrix>public DOKSparseMatrix t()
MatrixRingt in interface MatrixRingpublic DOKSparseMatrix ZERO()
MatrixRingZERO in interface MatrixRingZERO in interface AbelianGroup<Matrix>public DOKSparseMatrix ONE()
MatrixRingONE in interface MatrixRingONE in interface Monoid<Matrix>public DOKSparseMatrix deepCopy()
DeepCopyablethis by the copy
constructor of the class, or just this if the instance itself is
immutable.deepCopy in interface MatrixdeepCopy in interface DeepCopyablepublic DenseMatrix toDense()
DensifiableDenseMatrix.toDense in interface DensifiableDenseMatrixpublic int nNonZeros()
SparseStructurenNonZeros in interface SparseStructureCopyright © 2010-2020 NM FinTech Ltd.. All Rights Reserved.