Package smile.math.matrix
Interface DenseMatrix
-
- All Superinterfaces:
Matrix,MatrixMultiplication<DenseMatrix,DenseMatrix>,java.io.Serializable
- All Known Implementing Classes:
JMatrix
public interface DenseMatrix extends Matrix, MatrixMultiplication<DenseMatrix,DenseMatrix>
An abstract interface of dense matrix.- Author:
- Haifeng Li
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description DenseMatrixaat()Returns A * A'default DenseMatrixadd(double x)In place element-wise addition A = A + xdefault DenseMatrixadd(double x, DenseMatrix c)Element-wise addition C = A + xdoubleadd(int i, int j, double x)A[i][j] += xdefault DenseMatrixadd(DenseMatrix b)In place addition A = A + Bdefault DenseMatrixadd(DenseMatrix b, DenseMatrix c)C = A + Bdefault double[][]array()Return the two-dimensional array of matrix.DenseMatrixata()Returns A' * ACholeskycholesky()Returns the Cholesky decomposition.default Choleskycholesky(boolean inPlace)Returns the Cholesky decomposition.default double[]colMeans()Returns the mean of each column for a matrix.default double[]colSums()Returns the sum of each column for a matrix.DenseMatrixcopy()Returns a copy of this matrix.double[]data()Returns the array of storing the matrix.default DenseMatrixdiv(double x)In place element-wise division A = A / xdefault DenseMatrixdiv(double x, DenseMatrix c)Element-wise addition C = A / xdoublediv(int i, int j, double x)A[i][j] /= xdefault DenseMatrixdiv(DenseMatrix b)In place element-wise division A = A / B A = A - Bdefault DenseMatrixdiv(DenseMatrix b, DenseMatrix c)C = A / Bdouble[]eig()Returns the eigen values in an array of size 2N.default double[]eig(boolean inPlace)Returns the eigen values in an array of size 2N.EVDeigen()Returns the eigen value decomposition.default EVDeigen(boolean inPlace)Returns the eigen value decomposition.default DenseMatrixinverse()Returns the inverse matrix.default DenseMatrixinverse(boolean inPlace)Returns the inverse matrix.intld()The LDA (and LDB, LDC, etc.) parameter in BLAS is effectively the stride of the matrix as it is laid out in linear memory.LUlu()Returns the LU decomposition.default LUlu(boolean inPlace)Returns the LU decomposition.default DenseMatrixmul(double x)In place element-wise multiplication A = A * xdefault DenseMatrixmul(double x, DenseMatrix c)Element-wise addition C = A * xdoublemul(int i, int j, double x)A[i][j] *= xdefault DenseMatrixmul(DenseMatrix b)In place element-wise multiplication A = A * Bdefault DenseMatrixmul(DenseMatrix b, DenseMatrix c)C = A * Bdefault doublenorm()L2 matrix norm.default doublenorm1()L1 matrix norm.default doublenorm2()L2 matrix norm.default doublenormFro()Frobenius matrix norm.default doublenormInf()Infinity matrix norm.QRqr()Returns the QR decomposition.default QRqr(boolean inPlace)Returns the QR decomposition.default DenseMatrixreplaceNaN(double x)Replaces NaN's with given value.default double[]rowMeans()Returns the mean of each row for a matrix.default double[]rowSums()Returns the sum of each row for a matrix.doubleset(int i, int j, double x)Set the entry value at row i and column j.default DenseMatrixsub(double x)In place element-wise subtraction A = A - xdefault DenseMatrixsub(double x, DenseMatrix c)Element-wise addition C = A - xdoublesub(int i, int j, double x)A[i][j] -= xdefault DenseMatrixsub(DenseMatrix b)In place subtraction A = A - Bdefault DenseMatrixsub(DenseMatrix b, DenseMatrix c)C = A - Bdefault doublesum()Returns the sum of all elements in the matrix.SVDsvd()Returns the singular value decomposition.default SVDsvd(boolean inPlace)Returns the singular value decomposition.DenseMatrixtranspose()Returns the matrix transpose.default doubleupdate(int i, int j, double x)Set the entry value at row i and column j.default doublexax(double[] x)Returns x' * A * x.-
Methods inherited from interface smile.math.matrix.Matrix
apply, atx, atxpy, atxpy, ax, axpy, axpy, diag, eigen, eigen, get, isSymmetric, ncols, nrows, setSymmetric, svd, svd, toString, trace
-
Methods inherited from interface smile.math.matrix.MatrixMultiplication
abmm, abtmm, atbmm
-
-
-
-
Method Detail
-
data
double[] data()
Returns the array of storing the matrix.
-
ld
int ld()
The LDA (and LDB, LDC, etc.) parameter in BLAS is effectively the stride of the matrix as it is laid out in linear memory. It is perfectly valid to have an LDA value which is larger than the leading dimension of the matrix which is being operated on. Typical cases where it is either useful or necessary to use a larger LDA value are when you are operating on a sub matrix from a larger dense matrix, and when hardware or algorithms offer performance advantages when storage is padded to round multiples of some optimal size (cache lines or GPU memory transaction size, or load balance in multiprocessor implementations, for example).- Returns:
- the leading dimension
-
set
double set(int i, int j, double x)Set the entry value at row i and column j.
-
update
default double update(int i, int j, double x)Set the entry value at row i and column j. For Scala users.
-
lu
LU lu()
Returns the LU decomposition. This input matrix will be overwritten with the decomposition.
-
lu
default LU lu(boolean inPlace)
Returns the LU decomposition.- Parameters:
inPlace- if true, this matrix will be used for matrix decomposition.
-
cholesky
Cholesky cholesky()
Returns the Cholesky decomposition. This input matrix will be overwritten with the decomposition.- Throws:
java.lang.IllegalArgumentException- if the matrix is not positive definite.
-
cholesky
default Cholesky cholesky(boolean inPlace)
Returns the Cholesky decomposition.- Parameters:
inPlace- if true, this matrix will be used for matrix decomposition.- Throws:
java.lang.IllegalArgumentException- if the matrix is not positive definite.
-
qr
QR qr()
Returns the QR decomposition. This input matrix will be overwritten with the decomposition.
-
qr
default QR qr(boolean inPlace)
Returns the QR decomposition.- Parameters:
inPlace- if true, this matrix will be used for matrix decomposition.
-
svd
SVD svd()
Returns the singular value decomposition. Note that the input matrix will hold U on output.
-
svd
default SVD svd(boolean inPlace)
Returns the singular value decomposition.- Parameters:
inPlace- if true, this matrix will hold U on output.
-
eigen
EVD eigen()
Returns the eigen value decomposition. Note that the input matrix will be overwritten on output.
-
eigen
default EVD eigen(boolean inPlace)
Returns the eigen value decomposition.- Parameters:
inPlace- if true, this matrix will be overwritten U on output.
-
eig
double[] eig()
Returns the eigen values in an array of size 2N. The first half and second half of returned array contain the real and imaginary parts, respectively, of the computed eigenvalues.
-
eig
default double[] eig(boolean inPlace)
Returns the eigen values in an array of size 2N. The first half and second half of returned array contain the real and imaginary parts, respectively, of the computed eigenvalues.- Parameters:
inPlace- if true, this matrix will be overwritten U on output.
-
transpose
DenseMatrix transpose()
Returns the matrix transpose.
-
inverse
default DenseMatrix inverse()
Returns the inverse matrix.
-
inverse
default DenseMatrix inverse(boolean inPlace)
Returns the inverse matrix.- Parameters:
inPlace- if true, this matrix will be used for matrix decomposition.
-
norm1
default double norm1()
L1 matrix norm. Maximum column sum.
-
norm2
default double norm2()
L2 matrix norm. Maximum singular value.
-
norm
default double norm()
L2 matrix norm. Maximum singular value.
-
normInf
default double normInf()
Infinity matrix norm. Maximum row sum.
-
normFro
default double normFro()
Frobenius matrix norm. Sqrt of sum of squares of all elements.
-
xax
default double xax(double[] x)
Returns x' * A * x. The left upper submatrix of A is used in the computation based on the size of x.
-
rowSums
default double[] rowSums()
Returns the sum of each row for a matrix.
-
rowMeans
default double[] rowMeans()
Returns the mean of each row for a matrix.
-
colSums
default double[] colSums()
Returns the sum of each column for a matrix.
-
colMeans
default double[] colMeans()
Returns the mean of each column for a matrix.
-
copy
DenseMatrix copy()
Returns a copy of this matrix.
-
ata
DenseMatrix ata()
Description copied from interface:MatrixReturns A' * A
-
aat
DenseMatrix aat()
Description copied from interface:MatrixReturns A * A'
-
add
double add(int i, int j, double x)A[i][j] += x
-
sub
double sub(int i, int j, double x)A[i][j] -= x
-
mul
double mul(int i, int j, double x)A[i][j] *= x
-
div
double div(int i, int j, double x)A[i][j] /= x
-
add
default DenseMatrix add(DenseMatrix b, DenseMatrix c)
C = A + B- Returns:
- the result matrix
-
add
default DenseMatrix add(DenseMatrix b)
In place addition A = A + B- Returns:
- this matrix
-
sub
default DenseMatrix sub(DenseMatrix b, DenseMatrix c)
C = A - B- Returns:
- the result matrix
-
sub
default DenseMatrix sub(DenseMatrix b)
In place subtraction A = A - B- Returns:
- this matrix
-
mul
default DenseMatrix mul(DenseMatrix b, DenseMatrix c)
C = A * B- Returns:
- the result matrix
-
mul
default DenseMatrix mul(DenseMatrix b)
In place element-wise multiplication A = A * B- Returns:
- this matrix
-
div
default DenseMatrix div(DenseMatrix b, DenseMatrix c)
C = A / B- Returns:
- the result matrix
-
div
default DenseMatrix div(DenseMatrix b)
In place element-wise division A = A / B A = A - B- Returns:
- this matrix
-
add
default DenseMatrix add(double x, DenseMatrix c)
Element-wise addition C = A + x
-
add
default DenseMatrix add(double x)
In place element-wise addition A = A + x
-
sub
default DenseMatrix sub(double x, DenseMatrix c)
Element-wise addition C = A - x
-
sub
default DenseMatrix sub(double x)
In place element-wise subtraction A = A - x
-
mul
default DenseMatrix mul(double x, DenseMatrix c)
Element-wise addition C = A * x
-
mul
default DenseMatrix mul(double x)
In place element-wise multiplication A = A * x
-
div
default DenseMatrix div(double x, DenseMatrix c)
Element-wise addition C = A / x
-
div
default DenseMatrix div(double x)
In place element-wise division A = A / x
-
replaceNaN
default DenseMatrix replaceNaN(double x)
Replaces NaN's with given value.
-
sum
default double sum()
Returns the sum of all elements in the matrix.- Returns:
- the sum of all elements.
-
array
default double[][] array()
Return the two-dimensional array of matrix.- Returns:
- the two-dimensional array of matrix.
-
-