public class SparseMatrix extends java.lang.Object implements java.lang.Iterable<MatrixEntry>
Constructor and Description |
---|
SparseMatrix(int rows,
int cols,
com.google.common.collect.Table<java.lang.Integer,java.lang.Integer,java.lang.Double> dataTable)
Construct a sparse matrix with only CRS structures
|
SparseMatrix(int rows,
int cols,
com.google.common.collect.Table<java.lang.Integer,java.lang.Integer,java.lang.Double> dataTable,
boolean isCCSUsed)
Deprecated.
I don't recommend to use this method as it (takes time and)
is better to constructe the column structure at the time when
you construct the row structure (of data table). This method
is put here (as an example) to show how to construct column
structure according to the data table.
|
SparseMatrix(int rows,
int cols,
com.google.common.collect.Table<java.lang.Integer,java.lang.Integer,java.lang.Double> dataTable,
com.google.common.collect.Multimap<java.lang.Integer,java.lang.Integer> colMap)
Construct a sparse matrix with both CRS and CCS structures
|
SparseMatrix(SparseMatrix mat) |
SparseMatrix(SparseMatrix mat,
boolean deap)
Construct a sparse matrix from another sparse matrix
|
Modifier and Type | Method and Description |
---|---|
void |
add(int row,
int column,
double val)
Add a value to entry [row, column]
|
SparseMatrix |
clone()
Make a deep clone of current matrix
|
SparseVector |
column(int col)
get a col sparse vector of a matrix
|
java.util.List<java.lang.Integer> |
columns() |
int |
columnSize(int col)
query the size of a specific col
|
java.util.List<java.lang.Integer> |
columnZeros(int col)
get a list of entries (for a specific column) with values 0
|
double |
get(int row,
int column)
Retrieve value at entry [row, column]
|
int[] |
getColumnIndices() |
double[] |
getData() |
int[] |
getRowPointers() |
java.util.Iterator<MatrixEntry> |
iterator() |
double |
mean() |
int |
numColumns() |
int |
numRows() |
SparseVector |
row(int row)
get a row sparse vector of a matrix
|
SparseVector |
row(int row,
int except)
get a row sparse vector of a matrix
|
java.util.List<java.lang.Integer> |
rows() |
int |
rowSize(int row)
query the size of a specific row
|
java.util.List<java.lang.Integer> |
rowZeros(int row)
get a list of entries (for a specific row) with values 0
|
void |
set(int row,
int column,
double val)
Set a value to entry [row, column]
|
int |
size() |
double |
sum() |
java.lang.String |
toString() |
SparseMatrix |
transpose() |
public SparseMatrix(int rows, int cols, com.google.common.collect.Table<java.lang.Integer,java.lang.Integer,java.lang.Double> dataTable, com.google.common.collect.Multimap<java.lang.Integer,java.lang.Integer> colMap)
public SparseMatrix(int rows, int cols, com.google.common.collect.Table<java.lang.Integer,java.lang.Integer,java.lang.Double> dataTable)
public SparseMatrix(int rows, int cols, com.google.common.collect.Table<java.lang.Integer,java.lang.Integer,java.lang.Double> dataTable, boolean isCCSUsed)
public SparseMatrix(SparseMatrix mat)
public SparseMatrix(SparseMatrix mat, boolean deap)
mat
- the original sparse matrixdeap
- whether to copy the CCS structurespublic SparseMatrix clone()
clone
in class java.lang.Object
public SparseMatrix transpose()
public int[] getRowPointers()
public int[] getColumnIndices()
public int size()
public int numRows()
public int numColumns()
public double[] getData()
public void set(int row, int column, double val)
row
- row idcolumn
- column idval
- value to setpublic void add(int row, int column, double val)
row
- row idcolumn
- column idval
- value to addpublic double get(int row, int column)
row
- row idcolumn
- column idpublic SparseVector row(int row)
row
- row idpublic java.util.List<java.lang.Integer> rowZeros(int row)
row
- row idpublic SparseVector row(int row, int except)
row
- row idexcept
- row id to be excludedpublic int rowSize(int row)
row
- row idpublic java.util.List<java.lang.Integer> rows()
public SparseVector column(int col)
col
- col idpublic java.util.List<java.lang.Integer> columnZeros(int col)
col
- column idpublic int columnSize(int col)
col
- col idpublic java.util.List<java.lang.Integer> columns()
public double sum()
public double mean()
public java.lang.String toString()
toString
in class java.lang.Object
public java.util.Iterator<MatrixEntry> iterator()
iterator
in interface java.lang.Iterable<MatrixEntry>