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.Entry s. |
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()
Table
public int nCols()
Table
public List<SparseMatrix.Entry> getEntryList()
SparseMatrix
SparseMatrix.Entry
s. 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 SparseMatrix
public SparseMatrix.ValueArray getValueArray()
SparseMatrix
getValueArray
in interface SparseMatrix
SparseMatrix.ValueArray
public double get(int row, int col)
MatrixAccess
get
in interface MatrixAccess
row
- the row indexcol
- the column indexpublic void set(int row, int col, double value)
MatrixAccess
set
in interface MatrixAccess
row
- the row indexcol
- the column indexvalue
- the value to set A[i,j] topublic SparseVector getRow(int i)
Matrix
public SparseVector getColumn(int j)
Matrix
public Matrix add(Matrix that)
MatrixRing
add
in interface MatrixRing
add
in interface AbelianGroup<Matrix>
that
- a matrixthis
and that
public Matrix minus(Matrix that)
MatrixRing
minus
in interface MatrixRing
minus
in interface AbelianGroup<Matrix>
that
- a matrixthis
and that
public Matrix multiply(Matrix that)
MatrixRing
multiply
in interface MatrixRing
multiply
in interface Monoid<Matrix>
that
- a matrixthis
and that
public Vector multiply(Vector v)
Matrix
public LILSparseMatrix scaled(double c)
Matrix
public LILSparseMatrix opposite()
MatrixRing
opposite
in interface MatrixRing
opposite
in interface AbelianGroup<Matrix>
public LILSparseMatrix t()
MatrixRing
t
in interface MatrixRing
public LILSparseMatrix ZERO()
MatrixRing
ZERO
in interface MatrixRing
ZERO
in interface AbelianGroup<Matrix>
public LILSparseMatrix ONE()
MatrixRing
ONE
in interface MatrixRing
ONE
in interface Monoid<Matrix>
public LILSparseMatrix deepCopy()
DeepCopyable
this
by the copy
constructor of the class, or just this
if the instance itself is
immutable.deepCopy
in interface Matrix
deepCopy
in interface DeepCopyable
public DenseMatrix toDense()
Densifiable
DenseMatrix
.toDense
in interface Densifiable
DenseMatrix
public int nNonZeros()
SparseStructure
nNonZeros
in interface SparseStructure
Copyright © 2010-2020 NM FinTech Ltd.. All Rights Reserved.