MatrixType
- Type of Matrix created by the factory.public abstract class MatrixFactory<MatrixType extends Matrix>
extends java.lang.Object
implements java.io.Serializable
Matrix
objects.Modifier and Type | Field and Description |
---|---|
protected static MatrixFactory<? extends Matrix> |
DEFAULT_DENSE_INSTANCE
The default dense implementation of a
MatrixFactory . |
protected static DiagonalMatrixFactoryMTJ |
DEFAULT_DIAGONAL_INSTANCE
The default implementation of a factory that creates a DiagonalMatrix
|
protected static MatrixFactory<? extends Matrix> |
DEFAULT_SPARSE_INSTANCE
The default sparse implementation of a
MatrixFactory . |
Modifier | Constructor and Description |
---|---|
protected |
MatrixFactory()
Creates a new
MatrixFactory . |
Modifier and Type | Method and Description |
---|---|
MatrixType |
copyArray(double[][] values)
Copies the values from the array into the Matrix
|
MatrixType |
copyColumnVectors(java.util.Collection<? extends Vectorizable> columns)
Creates a new matrix by copying the given set of column vectors.
|
MatrixType |
copyColumnVectors(Vectorizable... columns)
Creates a new matrix by copying the given set of column vectors.
|
abstract MatrixType |
copyMatrix(Matrix m)
Creates a deep copy new Matrix given another, argument is unchanged
|
MatrixType |
copyRowVectors(java.util.Collection<? extends Vectorizable> rows)
Creates a new matrix by copying the given set of row vectors.
|
MatrixType |
copyRowVectors(Vectorizable... rows)
Creates a new matrix by copying the given set of row vectors.
|
MatrixType |
createDiagonal(Vectorizable diagonal)
Creates a new square matrix whose number of rows and columns match the
dimensionality of the given vector.
|
MatrixType |
createGaussianRandom(int numRows,
int numColumns,
java.util.Random random)
Creates a new Matrix filled with values sampled from a Gaussian
distribution with mean 0 and variance 1.
|
MatrixType |
createIdentity(int numRowsAndColumns)
Creates a Matrix with ones (1) on the diagonal, and zeros (0) elsewhere
|
MatrixType |
createIdentity(int numRows,
int numColumns)
Creates a Matrix with ones (1) on the diagonal, and zeros (0) elsewhere
|
abstract MatrixType |
createMatrix(int numRows,
int numColumns)
Creates an empty Matrix of the specified dimensions, all elements
must be all zeros!
|
MatrixType |
createMatrix(int numRows,
int numColumns,
double initialValue)
Creates a matrix with the given initial value.
|
MatrixType |
createUniformRandom(int numRows,
int numColumns,
double min,
double max,
java.util.Random random)
Creates a new Matrix of the given size with random values for the
entries, uniformly distributed between the given minimum and maximum
values.
|
MatrixType |
createUniformRandom(int numRows,
int numColumns,
java.util.Random random)
Creates a new Matrix filled with values sampled uniformly between 0 and
1.
|
static MatrixFactory<? extends Matrix> |
getDefault()
Gets the default implementation of
MatrixFactory . |
static MatrixFactory<? extends Matrix> |
getDenseDefault()
Gets the default implementation of
MatrixFactory for dense
matrices. |
static MatrixFactory<? extends DiagonalMatrix> |
getDiagonalDefault()
Gets the default implementation of
MatrixFactory for diagonal
matrices. |
static MatrixFactory<? extends Matrix> |
getSparseDefault()
Gets the default implementation of
MatrixFactory for sparse
matrices. |
protected static final MatrixFactory<? extends Matrix> DEFAULT_DENSE_INSTANCE
MatrixFactory
.protected static final MatrixFactory<? extends Matrix> DEFAULT_SPARSE_INSTANCE
MatrixFactory
.protected static final DiagonalMatrixFactoryMTJ DEFAULT_DIAGONAL_INSTANCE
public static MatrixFactory<? extends Matrix> getDefault()
MatrixFactory
.MatrixFactory
.public static MatrixFactory<? extends Matrix> getDenseDefault()
MatrixFactory
for dense
matrices.MatrixFactory
.public static MatrixFactory<? extends Matrix> getSparseDefault()
MatrixFactory
for sparse
matrices.MatrixFactory
.public static MatrixFactory<? extends DiagonalMatrix> getDiagonalDefault()
MatrixFactory
for diagonal
matrices.DiagonalMatrixFactory
.public abstract MatrixType copyMatrix(Matrix m)
m
- Matrix to copypublic MatrixType copyArray(double[][] values)
values
- Values to copypublic abstract MatrixType createMatrix(int numRows, int numColumns)
numRows
- number of rows in the MatrixnumColumns
- number of columns in the Matrixpublic MatrixType createIdentity(int numRowsAndColumns)
numRowsAndColumns
- number of rows and columns in the Matrixpublic MatrixType createIdentity(int numRows, int numColumns)
numRows
- number of rows in the MatrixnumColumns
- number of columns in the Matrixpublic MatrixType createUniformRandom(int numRows, int numColumns, java.util.Random random)
numRows
- The number of rows.numColumns
- The number of columns.random
- The random number generator to use.public MatrixType createUniformRandom(int numRows, int numColumns, double min, double max, java.util.Random random)
numRows
- The number of rows in the Matrix.numColumns
- The number of columns in the Matrix.min
- The minimum range of the uniform distribution.max
- The maximum range of the uniform distribution.random
- The random number generator.public MatrixType createGaussianRandom(int numRows, int numColumns, java.util.Random random)
numRows
- The number of rows.numColumns
- The number of columns.random
- The random number generator to use.public MatrixType copyRowVectors(java.util.Collection<? extends Vectorizable> rows)
rows
- The row vectors to create a matrix from. Must all be the same
dimensionality.public MatrixType copyRowVectors(Vectorizable... rows)
rows
- The row vectors to create a matrix from. Must all be the same
dimensionality.public MatrixType copyColumnVectors(java.util.Collection<? extends Vectorizable> columns)
columns
- The column vectors to create a matrix from. Must all be the same
dimensionality.public MatrixType copyColumnVectors(Vectorizable... columns)
columns
- The column vectors to create a matrix from. Must all be the same
dimensionality.public MatrixType createMatrix(int numRows, int numColumns, double initialValue)
numRows
- The number of rows. Cannot be negative.numColumns
- The number of columns. Cannot be negative.initialValue
- The initial value to set all elements to.public MatrixType createDiagonal(Vectorizable diagonal)
diagonal
- The vector of diagonal values.