public class Matrices
extends Object
Matrix
.Constructor and Description |
---|
Matrices() |
Modifier and Type | Method and Description |
---|---|
static Matrix |
dense(int numRows,
int numCols,
double[] values)
Creates a column-major dense matrix.
|
static Matrix |
diag(Vector vector)
Generate a diagonal matrix in
DenseMatrix format from the supplied values. |
static Matrix |
eye(int n)
Generate an Identity Matrix in
DenseMatrix format. |
static Matrix |
fromBreeze(breeze.linalg.Matrix<Object> breeze)
Creates a Matrix instance from a breeze matrix.
|
static Matrix |
ones(int numRows,
int numCols)
Generate a
DenseMatrix consisting of ones. |
static Matrix |
rand(int numRows,
int numCols,
java.util.Random rng)
Generate a
DenseMatrix consisting of i.i.d. |
static Matrix |
randn(int numRows,
int numCols,
java.util.Random rng)
Generate a
DenseMatrix consisting of i.i.d. |
static Matrix |
sparse(int numRows,
int numCols,
int[] colPtrs,
int[] rowIndices,
double[] values)
Creates a column-major sparse matrix in Compressed Sparse Column (CSC) format.
|
static Matrix |
zeros(int numRows,
int numCols)
Generate a
DenseMatrix consisting of zeros. |
public static Matrix dense(int numRows, int numCols, double[] values)
numRows
- number of rowsnumCols
- number of columnsvalues
- matrix entries in column majorpublic static Matrix sparse(int numRows, int numCols, int[] colPtrs, int[] rowIndices, double[] values)
numRows
- number of rowsnumCols
- number of columnscolPtrs
- the index corresponding to the start of a new columnrowIndices
- the row index of the entryvalues
- non-zero matrix entries in column majorpublic static Matrix fromBreeze(breeze.linalg.Matrix<Object> breeze)
breeze
- a breeze matrixpublic static Matrix zeros(int numRows, int numCols)
DenseMatrix
consisting of zeros.numRows
- number of rows of the matrixnumCols
- number of columns of the matrixDenseMatrix
with size numRows
x numCols
and values of zerospublic static Matrix ones(int numRows, int numCols)
DenseMatrix
consisting of ones.numRows
- number of rows of the matrixnumCols
- number of columns of the matrixDenseMatrix
with size numRows
x numCols
and values of onespublic static Matrix eye(int n)
DenseMatrix
format.n
- number of rows and columns of the matrixDenseMatrix
with size n
x n
and values of ones on the diagonalpublic static Matrix rand(int numRows, int numCols, java.util.Random rng)
DenseMatrix
consisting of i.i.d. uniform random numbers.numRows
- number of rows of the matrixnumCols
- number of columns of the matrixrng
- a random number generatorDenseMatrix
with size numRows
x numCols
and values in U(0, 1)public static Matrix randn(int numRows, int numCols, java.util.Random rng)
DenseMatrix
consisting of i.i.d. gaussian random numbers.numRows
- number of rows of the matrixnumCols
- number of columns of the matrixrng
- a random number generatorDenseMatrix
with size numRows
x numCols
and values in N(0, 1)