public class LILSparseMatrix extends Object implements SparseMatrix
SparseMatrix.Entry, SparseMatrix.ValueArray| Constructor and Description |
|---|
LILSparseMatrix(int nRows,
int nCols)
Construct a sparse matrix in LIL format.
|
LILSparseMatrix(int nRows,
int nCols,
int[] rowIndices,
int[] columnIndices,
double[] value)
Construct a sparse matrix in LIL format.
|
LILSparseMatrix(int nRows,
int nCols,
List<SparseMatrix.Entry> entries)
Construct a sparse matrix in LIL format by a list of non-zero entries.
|
LILSparseMatrix(LILSparseMatrix that)
Copy constructor.
|
| Modifier and Type | Method and Description |
|---|---|
Matrix |
add(Matrix that)
this + that
|
LILSparseMatrix |
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 row,
int col)
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.
|
LILSparseMatrix |
ONE()
Get an identity matrix that has the same dimension as this matrix.
|
LILSparseMatrix |
opposite()
Get the opposite of this matrix.
|
LILSparseMatrix |
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.
|
LILSparseMatrix |
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() |
LILSparseMatrix |
ZERO()
Get a zero matrix that has the same dimension as this matrix.
|
public LILSparseMatrix(int nRows,
int nCols)
nRows - the number of rowsnCols - the number of columnspublic LILSparseMatrix(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 LILSparseMatrix(int nRows,
int nCols,
List<SparseMatrix.Entry> entries)
nRows - the number of rowsnCols - the number of columnsentries - the list of entriespublic LILSparseMatrix(LILSparseMatrix 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 double get(int row,
int col)
MatrixAccessget in interface MatrixAccessrow - the row indexcol - the column indexpublic 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 SparseVector getRow(int i)
Matrixpublic SparseVector getColumn(int j)
Matrixpublic 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 LILSparseMatrix scaled(double c)
Matrixpublic LILSparseMatrix opposite()
MatrixRingopposite in interface MatrixRingopposite in interface AbelianGroup<Matrix>public LILSparseMatrix t()
MatrixRingt in interface MatrixRingpublic LILSparseMatrix ZERO()
MatrixRingZERO in interface MatrixRingZERO in interface AbelianGroup<Matrix>public LILSparseMatrix ONE()
MatrixRingONE in interface MatrixRingONE in interface Monoid<Matrix>public LILSparseMatrix 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.