public class SparseMatrix extends Matrix
Constructor and Description |
---|
SparseMatrix(double[][] values)
Construct with the given values
|
SparseMatrix(int rows,
int columns)
Construct with the given size
|
Modifier and Type | Method and Description |
---|---|
double |
add(int row,
int column,
double sum)
Add to the value at the given row/column
|
int |
addColumn()
Add a new column to the end, increasing the number of columns by 1
|
int |
addRow()
Add a new row to the end, increasing the number of rows by 1
|
protected int |
addRow(double[] values) |
void |
addToRow(int row,
Vector values)
Add the given values to the given row
|
double[][] |
asDenseDoubleDouble()
Convert to a dense 2d double array
|
int |
columnCount()
Get the number of columns
|
boolean |
equals(Object obj) |
double |
get(int row,
int column) |
int |
hashCode() |
Vector |
mult(Vector dense)
Returns
y = Ax . |
Matrix |
newInstance(int rows,
int cols) |
double |
put(int row,
int column,
double value)
Set the value at the given row/column
|
static SparseMatrix |
random(int n,
int m,
double density)
Create a random matrix
|
static SparseMatrix |
readFrom(Scanner scan)
Read matrix from
Scanner |
Vector |
row(int row)
Get the given row as a vector
|
int |
rowCount() |
Iterable<Vector> |
rows()
Get an
Iterable over the rows |
void |
setRow(int row,
SparseVector values)
Sets the row, no check is made on
SparseVector.size() Use with
care. |
Vector |
transposeMultiply(Vector dense)
Returns
y = (A^T)x . |
void |
trim()
Trim each row
|
int |
used() |
asArray, asColumnMajorArray, column, columns, dense, density, elementCount, from, getHistogram, indexOf, isSquare, max, mean, min, newInstance, rowwiseMean, sparse, storeSparseOn, storeSparseOn, toString, transposeNonTransposeMultiply, unwrap
public SparseMatrix(double[][] values)
values
- public SparseMatrix(int rows, int columns)
rows
- columns
- public double add(int row, int column, double sum)
Matrix
public int addColumn()
public int addRow()
protected int addRow(double[] values)
public void addToRow(int row, Vector values)
row
- values
- public double[][] asDenseDoubleDouble()
public int columnCount()
Matrix
columnCount
in class Matrix
public double get(int row, int column)
public double put(int row, int column, double value)
Matrix
public Iterable<Vector> rows()
Matrix
Iterable
over the rowspublic void setRow(int row, SparseVector values)
SparseVector.size()
Use with
care.row
- values
- public void trim()
public static SparseMatrix readFrom(Scanner scan)
Scanner
scan
- public static SparseMatrix random(int n, int m, double density)
n
- m
- density
- public Vector transposeMultiply(Vector dense)
Matrix
y = (A^T)x
.transposeMultiply
in class Matrix
public Matrix newInstance(int rows, int cols)
newInstance
in class Matrix