public final class FloatMatrix extends Object
Constructor and Description |
---|
FloatMatrix()
Make an empty matrix.
|
FloatMatrix(float[][] gridData)
Make a matrix by assuming the given data.
|
FloatMatrix(float[] data,
int numRows,
int numCols)
Make a matrix by assuming the given data.
|
FloatMatrix(float[] data,
int numRows,
int numCols,
boolean copy)
Make a matrix using existing data.
|
Modifier and Type | Method and Description |
---|---|
FloatMatrix |
add(float val)
Scalar addition (not in-place).
|
FloatMatrix |
add(float val,
boolean inPlace)
Scalar addition.
|
float[] |
asColumnArray()
Get a copy of this matrix's data as a 1D column-major array.
|
float[][] |
asGrid()
Get a copy of this matrix's data as a 2D-array.
|
float[] |
asRowArray()
Get a copy of this matrix's data as a 1D row-major array.
|
void |
assume(float[] data,
int numRows,
int numCols)
Take on all the given information.
|
float |
blas_sdot(FloatMatrix y)
Call sdot from BLAS.
|
FloatMatrix |
blas_sgemm(FloatMatrix b,
FloatMatrix c,
boolean transposeA,
boolean transposeB,
float alpha,
float beta)
Call sgemm from BLAS.
|
FloatMatrix |
choleskyDecomposition()
Cholesky factorization (not in-place).
|
FloatMatrix |
choleskyDecomposition(boolean inPlace)
Compute the Cholesky factorization of this real symmetric positive definite matrix.
|
static FloatMatrix |
columnVector(float[] data) |
static FloatMatrix |
columnVector(float[] data,
boolean copy) |
FloatMatrix |
copy()
Get a copy of this matrix.
|
FloatMatrix |
div(float val)
Scalar division (not in-place).
|
FloatMatrix |
div(float val,
boolean inPlace)
Scalar division.
|
float |
dot(FloatMatrix other)
Dot product.
|
FloatMatrix |
elementAdd(FloatMatrix other)
Element-wise addition (not in-place).
|
FloatMatrix |
elementAdd(FloatMatrix other,
boolean inPlace)
Element-wise addition.
|
FloatMatrix |
elementDiv(FloatMatrix other)
Element-wise division (not in-place).
|
FloatMatrix |
elementDiv(FloatMatrix other,
boolean inPlace)
Element-wise division.
|
FloatMatrix |
elementLog()
Element-wise natural log (not in-place).
|
FloatMatrix |
elementLog(boolean inPlace)
Element-wise natural log.
|
FloatMatrix |
elementMul(FloatMatrix other)
Element-wise multiplication (not in-place).
|
FloatMatrix |
elementMul(FloatMatrix other,
boolean inPlace)
Element-wise multiplication.
|
FloatMatrix |
elementSub(FloatMatrix other)
Element-wise difference (not in-place).
|
FloatMatrix |
elementSub(FloatMatrix other,
boolean inPlace)
Element-wise difference.
|
boolean |
equals(Object otherObj) |
static FloatMatrix |
eye(int size)
Make an identity matrix.
|
float |
get(int row,
int col) |
FloatMatrix |
inverse()
Compute the inversion of this matrix.
|
int[] |
lapack_sgesv(FloatMatrix b)
Call sgesv from LAPACK.
|
void |
lapack_spotrf(boolean upper)
Call spotrf from LAPACK.
|
FloatMatrix |
mul(float val)
Scalar multiplication (not in-place).
|
FloatMatrix |
mul(float val,
boolean inPlace)
Scalar multiplication.
|
FloatMatrix |
mul(FloatMatrix b)
Matrix multiplication without transposition or scaling.
|
FloatMatrix |
mul(FloatMatrix b,
boolean transposeA,
boolean transposeB,
float alpha)
Matrix multiplication.
|
FloatMatrix |
mul(FloatMatrix b,
FloatMatrix c,
boolean transposeA,
boolean transposeB,
float alpha,
float beta)
Matrix multiplication.
|
float |
norm1()
Get the 1-norm (sum of absolute values).
|
float |
norm2()
Get the 2-norm (Euclidean norm) (square root of sum of squared values).
|
int |
numCols() |
int |
numRows() |
static FloatMatrix |
ones(int numRows,
int numCols)
Make a ones matrix.
|
static FloatMatrix |
rowVector(float[] data) |
static FloatMatrix |
rowVector(float[] data,
boolean copy) |
void |
set(int row,
int col,
float value) |
int |
size() |
FloatMatrix |
sub(float val)
Scalar difference (not in-place).
|
FloatMatrix |
sub(float val,
boolean inPlace)
Scalar difference.
|
String |
toString() |
FloatMatrix |
transpose()
Transpose.
|
static FloatMatrix |
zeroes(int numRows,
int numCols)
Make a zero matrix.
|
public FloatMatrix()
public FloatMatrix(float[] data, int numRows, int numCols)
data
- A column-major representation of the data.public FloatMatrix(float[] data, int numRows, int numCols, boolean copy)
data
- A column-major representation of the data.copy
- If true, the passed in array will be deep copied.
Otherwise, the caller forfeits control of the data.public FloatMatrix(float[][] gridData)
public void assume(float[] data, int numRows, int numCols)
public static FloatMatrix zeroes(int numRows, int numCols)
public static FloatMatrix ones(int numRows, int numCols)
public static FloatMatrix eye(int size)
public static FloatMatrix columnVector(float[] data)
public static FloatMatrix columnVector(float[] data, boolean copy)
public static FloatMatrix rowVector(float[] data)
public static FloatMatrix rowVector(float[] data, boolean copy)
public FloatMatrix copy()
public float[][] asGrid()
public float[] asColumnArray()
public float[] asRowArray()
public float get(int row, int col)
public void set(int row, int col, float value)
public int size()
public int numRows()
public int numCols()
public FloatMatrix elementSub(FloatMatrix other)
public FloatMatrix elementSub(FloatMatrix other, boolean inPlace)
inPlace
- If true, then this matrix will be used and no copies made.public FloatMatrix elementAdd(FloatMatrix other)
public FloatMatrix elementAdd(FloatMatrix other, boolean inPlace)
inPlace
- If true, then this matrix will be used and no copies made.public FloatMatrix elementMul(FloatMatrix other)
public FloatMatrix elementMul(FloatMatrix other, boolean inPlace)
inPlace
- If true, then this matrix will be used and no copies made.public FloatMatrix elementDiv(FloatMatrix other)
public FloatMatrix elementDiv(FloatMatrix other, boolean inPlace)
inPlace
- If true, then this matrix will be used and no copies made.public FloatMatrix elementLog()
public FloatMatrix elementLog(boolean inPlace)
inPlace
- If true, then this matrix will be used and no copies made.public FloatMatrix sub(float val)
public FloatMatrix sub(float val, boolean inPlace)
inPlace
- If true, then this matrix will be used and no copies made.public FloatMatrix add(float val)
public FloatMatrix add(float val, boolean inPlace)
inPlace
- If true, then this matrix will be used and no copies made.public FloatMatrix mul(float val)
public FloatMatrix mul(float val, boolean inPlace)
inPlace
- If true, then this matrix will be used and no copies made.public FloatMatrix div(float val)
public FloatMatrix div(float val, boolean inPlace)
inPlace
- If true, then this matrix will be used and no copies made.public float norm1()
public float norm2()
public FloatMatrix transpose()
public FloatMatrix mul(FloatMatrix b)
public FloatMatrix mul(FloatMatrix b, boolean transposeA, boolean transposeB, float alpha)
public FloatMatrix mul(FloatMatrix b, FloatMatrix c, boolean transposeA, boolean transposeB, float alpha, float beta)
c
- This matrix is used to store the result from BLAS, and it will be returned.
If null, a new matrix will be allocated for the result.public float dot(FloatMatrix other)
public FloatMatrix inverse()
public FloatMatrix choleskyDecomposition()
public FloatMatrix choleskyDecomposition(boolean inPlace)
inPlace
- If true, then this matrix will be used and no copies made.public int[] lapack_sgesv(FloatMatrix b)
b
- The matrix on the LHS in this equation.
X will be put into b on successful completion of this method.public void lapack_spotrf(boolean upper)
upper
- True if the upper triangle is to be used, false for the lower.public FloatMatrix blas_sgemm(FloatMatrix b, FloatMatrix c, boolean transposeA, boolean transposeB, float alpha, float beta)
b
- The matrix used as B.c
- The matrix used as C.
May be null, and a new (zero) matrix will get created and used.transposeA
- True if A should be transposed.transposeB
- True if B should be transposed.alpha
- The multiplier on AB.beta
- The multiplier on C.public float blas_sdot(FloatMatrix y)
y
- The other matrix in this dot product.Copyright © 2020 University of California, Santa Cruz. All rights reserved.