public class JMatrix extends java.lang.Object implements DenseMatrix
| Constructor and Description |
|---|
JMatrix(double[] A)
Constructor of a column vector/matrix with given array as the internal storage.
|
JMatrix(double[][] A)
Constructor.
|
JMatrix(int rows,
int cols)
Constructor of all-zero matrix.
|
JMatrix(int rows,
int cols,
double value)
Constructor.
|
JMatrix(int rows,
int cols,
double[] value)
Constructor.
|
| Modifier and Type | Method and Description |
|---|---|
JMatrix |
aat()
Returns A * A'
|
JMatrix |
abmm(DenseMatrix B)
Returns the result of matrix multiplication A * B.
|
JMatrix |
abtmm(DenseMatrix B)
Returns the result of matrix multiplication A * B'.
|
JMatrix |
add(DenseMatrix b)
In place addition A = A + B
|
DenseMatrix |
add(DenseMatrix b,
DenseMatrix c)
C = A + B
|
JMatrix |
add(double x)
In place element-wise addition A = A + x
|
DenseMatrix |
add(double x,
DenseMatrix c)
Element-wise addition C = A + x
|
JMatrix |
add(double x,
JMatrix c) |
double |
add(int i,
int j,
double x)
A[i][j] += x
|
JMatrix |
add(JMatrix b) |
JMatrix |
add(JMatrix b,
JMatrix c) |
JMatrix |
ata()
Returns A' * A
|
JMatrix |
atbmm(DenseMatrix B)
Returns the result of matrix multiplication A' * B.
|
JMatrix |
atbtmm(DenseMatrix B)
Returns the result of matrix multiplication A' * B'.
|
double[] |
atx(double[] x,
double[] y)
y = A' * x
|
double[] |
atxpy(double[] x,
double[] y)
y = A' * x + y
|
double[] |
atxpy(double[] x,
double[] y,
double b)
y = A' * x + b * y
|
double[] |
ax(double[] x,
double[] y)
y = A * x
|
double[] |
axpy(double[] x,
double[] y)
y = A * x + y
|
double[] |
axpy(double[] x,
double[] y,
double b)
y = A * x + b * y
|
Cholesky |
cholesky()
Cholesky decomposition for symmetric and positive definite matrix.
|
JMatrix |
copy()
Returns a copy of this matrix.
|
double[] |
data()
Returns the array that backs this matrix (optional operation).
|
JMatrix |
div(DenseMatrix b)
In place element-wise division A = A / B
A = A - B
|
DenseMatrix |
div(DenseMatrix b,
DenseMatrix c)
C = A / B
|
JMatrix |
div(double x)
In place element-wise division A = A / x
|
DenseMatrix |
div(double x,
DenseMatrix c)
Element-wise addition C = A / x
|
JMatrix |
div(double x,
JMatrix c) |
double |
div(int i,
int j,
double x)
A[i][j] /= x
|
JMatrix |
div(JMatrix b) |
JMatrix |
div(JMatrix b,
JMatrix c) |
double[] |
eig()
Returns the eigen values in an array of size 2N.
|
EVD |
eigen()
Returns the eigen value decomposition.
|
void |
fill(double x)
Fill the matrix with a value.
|
double |
get(int i,
int j)
Returns the entry value at row i and column j.
|
boolean |
isSymmetric()
Returns true if the matrix is symmetric.
|
LU |
lu()
LU decomposition is computed by a "left-looking", dot-product, Crout/Doolittle algorithm.
|
JMatrix |
mul(DenseMatrix b)
In place element-wise multiplication A = A * B
|
DenseMatrix |
mul(DenseMatrix b,
DenseMatrix c)
C = A * B
|
JMatrix |
mul(double x)
In place element-wise multiplication A = A * x
|
DenseMatrix |
mul(double x,
DenseMatrix c)
Element-wise addition C = A * x
|
JMatrix |
mul(double x,
JMatrix c) |
double |
mul(int i,
int j,
double x)
A[i][j] *= x
|
JMatrix |
mul(JMatrix b) |
JMatrix |
mul(JMatrix b,
JMatrix c) |
int |
ncols()
Returns the number of columns.
|
int |
nrows()
Returns the number of rows.
|
QR |
qr()
QR Decomposition is computed by Householder reflections.
|
QR |
qr(double tol)
QR Decomposition is computed by Householder reflections.
|
JMatrix |
replaceNaN(double x)
Replaces NaN's with given value.
|
double |
set(int i,
int j,
double x)
Set the entry value at row i and column j.
|
void |
setSymmetric(boolean symmetric)
Sets if the matrix is symmetric.
|
protected static void |
sort(double[] d,
double[] e)
Sort eigenvalues.
|
protected static void |
sort(double[] d,
double[] e,
DenseMatrix V)
Sort eigenvalues and eigenvectors.
|
JMatrix |
sub(DenseMatrix b)
In place subtraction A = A - B
|
DenseMatrix |
sub(DenseMatrix b,
DenseMatrix c)
C = A - B
|
JMatrix |
sub(double x)
In place element-wise subtraction A = A - x
|
DenseMatrix |
sub(double x,
DenseMatrix c)
Element-wise addition C = A - x
|
JMatrix |
sub(double x,
JMatrix c) |
double |
sub(int i,
int j,
double x)
A[i][j] -= x
|
JMatrix |
sub(JMatrix b) |
JMatrix |
sub(JMatrix b,
JMatrix c) |
double |
sum()
Returns the sum of all elements in the matrix.
|
SVD |
svd()
Returns the singular value decomposition.
|
java.lang.String |
toString() |
JMatrix |
transpose()
Returns the matrix transpose.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitpublic JMatrix(double[][] A)
A - the array of matrix.public JMatrix(double[] A)
A - the array of column vector.public JMatrix(int rows,
int cols)
public JMatrix(int rows,
int cols,
double value)
public JMatrix(int rows,
int cols,
double[] value)
value - the array of matrix values arranged in column major formatpublic boolean isSymmetric()
MatrixisSymmetric in interface Matrixpublic void setSymmetric(boolean symmetric)
MatrixsetSymmetric in interface Matrixpublic JMatrix copy()
DenseMatrixcopy in interface DenseMatrixpublic double[] data()
DenseMatrixdata in interface DenseMatrixpublic void fill(double x)
DenseMatrixfill in interface DenseMatrixpublic JMatrix transpose()
DenseMatrixtranspose in interface DenseMatrixtranspose in interface Matrixpublic java.lang.String toString()
toString in class java.lang.Objectpublic int nrows()
Matrixpublic int ncols()
Matrixpublic double get(int i,
int j)
Matrixpublic double set(int i,
int j,
double x)
DenseMatrixset in interface DenseMatrixpublic double add(int i,
int j,
double x)
DenseMatrixadd in interface DenseMatrixpublic double sub(int i,
int j,
double x)
DenseMatrixsub in interface DenseMatrixpublic double mul(int i,
int j,
double x)
DenseMatrixmul in interface DenseMatrixpublic double div(int i,
int j,
double x)
DenseMatrixdiv in interface DenseMatrixpublic JMatrix add(DenseMatrix b)
DenseMatrixadd in interface DenseMatrixpublic DenseMatrix add(DenseMatrix b, DenseMatrix c)
DenseMatrixadd in interface DenseMatrixpublic JMatrix sub(DenseMatrix b)
DenseMatrixsub in interface DenseMatrixpublic DenseMatrix sub(DenseMatrix b, DenseMatrix c)
DenseMatrixsub in interface DenseMatrixpublic JMatrix mul(DenseMatrix b)
DenseMatrixmul in interface DenseMatrixpublic DenseMatrix mul(DenseMatrix b, DenseMatrix c)
DenseMatrixmul in interface DenseMatrixpublic JMatrix div(DenseMatrix b)
DenseMatrixdiv in interface DenseMatrixpublic DenseMatrix div(DenseMatrix b, DenseMatrix c)
DenseMatrixdiv in interface DenseMatrixpublic JMatrix add(double x)
DenseMatrixadd in interface DenseMatrixpublic DenseMatrix add(double x, DenseMatrix c)
DenseMatrixadd in interface DenseMatrixpublic JMatrix sub(double x)
DenseMatrixsub in interface DenseMatrixpublic DenseMatrix sub(double x, DenseMatrix c)
DenseMatrixsub in interface DenseMatrixpublic JMatrix mul(double x)
DenseMatrixmul in interface DenseMatrixpublic DenseMatrix mul(double x, DenseMatrix c)
DenseMatrixmul in interface DenseMatrixpublic JMatrix div(double x)
DenseMatrixdiv in interface DenseMatrixpublic DenseMatrix div(double x, DenseMatrix c)
DenseMatrixdiv in interface DenseMatrixpublic JMatrix replaceNaN(double x)
DenseMatrixreplaceNaN in interface DenseMatrixpublic double sum()
DenseMatrixsum in interface DenseMatrixpublic JMatrix ata()
Matrixata in interface DenseMatrixata in interface Matrixpublic JMatrix aat()
Matrixaat in interface DenseMatrixaat in interface Matrixpublic double[] ax(double[] x,
double[] y)
Matrixpublic double[] axpy(double[] x,
double[] y)
Matrixpublic double[] axpy(double[] x,
double[] y,
double b)
Matrixpublic double[] atx(double[] x,
double[] y)
Matrixpublic double[] atxpy(double[] x,
double[] y)
Matrixpublic double[] atxpy(double[] x,
double[] y,
double b)
Matrixpublic JMatrix abmm(DenseMatrix B)
MatrixMultiplicationabmm in interface MatrixMultiplication<DenseMatrix,DenseMatrix>public JMatrix abtmm(DenseMatrix B)
MatrixMultiplicationabtmm in interface MatrixMultiplication<DenseMatrix,DenseMatrix>public JMatrix atbmm(DenseMatrix B)
MatrixMultiplicationatbmm in interface MatrixMultiplication<DenseMatrix,DenseMatrix>public JMatrix atbtmm(DenseMatrix B)
MatrixMultiplicationatbtmm in interface MatrixMultiplication<DenseMatrix,DenseMatrix>public LU lu()
lu in interface DenseMatrixpublic Cholesky cholesky()
cholesky in interface DenseMatrixjava.lang.IllegalArgumentException - if the matrix is not positive definite.public QR qr()
qr in interface DenseMatrixpublic QR qr(double tol)
tol - the tolerance for detecting linear dependencies
in the column vectors.public SVD svd()
DenseMatrixsvd in interface DenseMatrixpublic double[] eig()
DenseMatrixeig in interface DenseMatrixpublic EVD eigen()
DenseMatrixeigen in interface DenseMatrixprotected static void sort(double[] d,
double[] e)
protected static void sort(double[] d,
double[] e,
DenseMatrix V)