public final class Matrix extends Object
| Modifier and Type | Class and Description |
|---|---|
static class |
Matrix.IdentityBuilder
A class that allows one to start with an identity matrix, then set specific elements before creating
an immutable Matrix.
|
static class |
Matrix.Order |
| Constructor and Description |
|---|
Matrix(double[][] matrixData,
Matrix.Order order)
Create a new matrix from the given two-dimensional array of data.
|
Matrix(int nrow,
int ncol,
double value)
Create a new matrix with the given dimensions filled with the supplied value.
|
| Modifier and Type | Method and Description |
|---|---|
static Matrix |
create(int nrow,
int ncol,
double[] data)
Create a new matrix with the supplied data and dimensions.
|
double[] |
data()
Obtain the array of data underlying this matrix in row-major order.
|
double[][] |
data2D(Matrix.Order order)
Obtain the data in this matrix as a two-dimensional array.
|
double[] |
diagonal()
Retrieve the elements on the diagonal of this matrix.
|
boolean |
equals(Object o) |
int |
hashCode() |
Matrix |
minus(Matrix other)
Subtract the given matrix from this matrix and return the resulting difference.
|
int |
ncol() |
int |
nrow() |
Matrix |
plus(Matrix other)
Add this matrix to the given matrix and return the resulting sum.
|
Matrix |
scaledBy(double c)
Scale this matrix by the given value and return the scaled matrix.
|
Matrix |
times(Matrix other)
Multiply this matrix by the given matrix and return the resulting product.
|
Vector |
times(Vector vector)
Multiply this matrix by the given vector and return the resulting transformation.
|
String |
toString() |
Matrix |
transpose()
Transpose this matrix and return the resulting transposition.
|
public Matrix(int nrow,
int ncol,
double value)
nrow - the number of rows for the matrix.ncol - the number of columns for the matrix.value - the data point to fill the matrix with.public Matrix(double[][] matrixData,
Matrix.Order order)
matrixData - the two-dimensional array of data constituting the matrix.order - the storage order of the elements in the matrix data.public int nrow()
public int ncol()
public static Matrix create(int nrow, int ncol, double[] data)
nrow - the number of rows for the matrix.ncol - the number of columns for the matrix.data - the data in row-major order.public Matrix plus(Matrix other)
other - the matrix to add to this one.public Matrix times(Matrix other)
other - the matrix to multiply by.public Vector times(Vector vector)
vector - the vector to multiply.public Matrix scaledBy(double c)
c - the value to scale this matrix by.public Matrix minus(Matrix other)
other - the matrix to subtract from this one.public Matrix transpose()
public double[] diagonal()
public double[] data()
public double[][] data2D(Matrix.Order order)
order - the storage order of the elements in the matrix data.