public abstract class Matrix extends Object
Constructor and Description |
---|
Matrix() |
Modifier and Type | Method and Description |
---|---|
double |
add(int row,
int column,
double value)
Add to the value at the given row/column
|
double[][] |
asArray()
Get the matrix data as a 2D dense array
|
double[] |
asColumnMajorArray()
Get in col-major format
|
Vector |
column(int column)
Get the given column as a vector
|
abstract int |
columnCount()
Get the number of columns
|
Iterable<Vector> |
columns()
Get an
Iterable over the columns |
static Matrix |
dense(int n,
int m)
Create a zeroed dense matrix
|
double |
density()
Get the density
|
int |
elementCount() |
static Matrix |
from(int n,
int m,
double... values)
Build a matrix from the given values (row-major)
|
abstract double |
get(int row,
int column) |
int[] |
getHistogram() |
static int |
indexOf(Vector vec)
Get the index of the given vector
|
boolean |
isSquare() |
double |
max() |
double |
mean() |
double |
min() |
Vector |
mult(Vector x)
Returns
y = Ax . |
Matrix |
newInstance() |
abstract Matrix |
newInstance(int rows,
int cols) |
abstract double |
put(int row,
int column,
double value)
Set the value at the given row/column
|
Vector |
row(int row)
Get the given row as a vector
|
abstract int |
rowCount() |
Iterable<Vector> |
rows()
Get an
Iterable over the rows |
double[] |
rowwiseMean() |
static SparseMatrix |
sparse(int n,
int m)
Create a sparse matrix
|
void |
storeSparseOn(Appendable appendable)
I/O
|
void |
storeSparseOn(String fname)
Write to file
|
String |
toString() |
Vector |
transposeMultiply(Vector x)
Returns
y = (A^T)x . |
Vector |
transposeNonTransposeMultiply(Vector x)
Returns
y = (A^T)Ax . |
double[][] |
unwrap() |
abstract int |
used() |
public Matrix()
public double add(int row, int column, double value)
row
- column
- value
- public Iterable<Vector> rows()
Iterable
over the rowsIterable
over the rowspublic Iterable<Vector> columns()
Iterable
over the columnsIterable
over the columnspublic abstract int columnCount()
public double density()
public int elementCount()
public abstract double get(int row, int column)
row
- column
- public abstract double put(int row, int column, double value)
row
- column
- value
- public abstract int rowCount()
public abstract int used()
public void storeSparseOn(Appendable appendable) throws IOException
appendable
- IOException
public void storeSparseOn(String fname) throws IOException
fname
- filenameIOException
public Vector column(int column)
column
- public double[][] asArray()
public static int indexOf(Vector vec)
vec
- public Vector transposeMultiply(Vector x)
y = (A^T)x
.x
- public Vector transposeNonTransposeMultiply(Vector x)
y = (A^T)Ax
.
Useful for doing singular decomposition using ARPACK's dsaupd routine.
x
- public static Matrix from(int n, int m, double... values)
n
- m
- values
- public static Matrix dense(int n, int m)
n
- m
- public boolean isSquare()
public double[] asColumnMajorArray()
public static SparseMatrix sparse(int n, int m)
n
- m
- public double max()
public double min()
public double mean()
public double[][] unwrap()
public double[] rowwiseMean()
public int[] getHistogram()
public Matrix newInstance()
public abstract Matrix newInstance(int rows, int cols)
rows
- cols
-