|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectprea.data.structure.DenseMatrix
public class DenseMatrix
This class implements dense matrix. Note that we use UJMP package (http://www.ujmp.org) to implement this class.
Field Summary | |
---|---|
private int |
M
The number of rows. |
private org.ujmp.core.Matrix |
map
The UJMP matrix to store data. |
private int |
N
The number of columns. |
Constructor Summary | |
---|---|
DenseMatrix(int m,
int n)
Construct an empty dense matrix, with a given size. |
|
DenseMatrix(org.ujmp.core.Matrix m)
Construct an empty dense matrix, with data copied from UJMP matrix. |
Method Summary | |
---|---|
DenseMatrix |
add(double alpha)
Scalar addition. |
double |
average()
Average of every element. |
DenseMatrix |
cholesky()
Calculate Cholesky decomposition of the matrix. |
DenseMatrix |
covariance()
Generate a covariance matrix of the current matrix. |
DenseVector |
diagonal()
Return items in the diagonal in vector form. |
DenseMatrix |
exp(double alpha)
Exponential of a given constant. |
DenseVector |
getCol(int index)
Return a copy of a given column. |
DenseVector |
getColRef(int index)
Return a reference of a given column. |
org.ujmp.core.Matrix |
getMatrix()
Get an UJMP matrix. |
DenseVector |
getRow(int index)
Return a copy of a given row. |
DenseVector |
getRowRef(int index)
Return a reference of a given row. |
double |
getValue(int i,
int j)
Retrieve a stored value from the given index. |
DenseMatrix |
inverse()
Calculate inverse matrix. |
int |
itemCount()
Actual number of items in the matrix. |
int[] |
length()
Capacity of this matrix. |
static DenseMatrix |
makeIdentity(int n)
Generate an identity matrix with the given size. |
DenseMatrix |
partInverse(int[] indexList)
Inverse of matrix only with indices in indexList. |
DenseMatrix |
partMinus(DenseMatrix B,
int[] indexList)
Matrix subtraction (A = A - B) only with indices in indexList. |
DenseMatrix |
partPlus(DenseMatrix B,
int[] indexList)
Matrix summation (A = A + B) only with indices in indexList. |
DenseMatrix |
partScale(double alpha,
int[] indexList)
Scalar Multiplication only with indices in indexList. |
DenseVector |
partTimes(DenseVector x,
int[] indexList)
Matrix-vector product (b = Ax) only with indices in indexList. |
DenseMatrix |
plus(DenseMatrix B)
Matrix-matrix sum (C = A + B) |
DenseMatrix |
scale(double alpha)
Scalar multiplication (aX). |
void |
selfAdd(double alpha)
Scalar addition on the matrix itself. |
void |
selfScale(double alpha)
Scalar multiplication (aX) on the matrix itself. |
void |
setValue(int i,
int j,
double value)
Set a new value at the given index. |
double |
stdev()
Standard Deviation of every element. |
double |
sum()
Sum of every element. |
DenseMatrix |
times(DenseMatrix B)
Matrix-matrix product (C = AB) |
DenseVector |
times(DenseVector x)
Matrix-vector product (b = Ax) |
DenseMatrix |
toDenseSubset(int[] indexList)
Condense the matrix only with given indices. |
DenseMatrix |
toDenseSubset(int[] rowList,
int[] colList)
Condense the matrix only with given indices, both rows and columns separately. |
SparseMatrix |
toSparseMatrix()
Convert the matrix into sparse matrix. |
java.lang.String |
toString()
Convert the matrix to a printable string. |
DenseMatrix |
transpose()
The transpose of the matrix. |
double |
variance()
Variance of every element. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
private int M
private int N
private org.ujmp.core.Matrix map
Constructor Detail |
---|
public DenseMatrix(int m, int n)
m
- The number of rows.n
- The number of columns.public DenseMatrix(org.ujmp.core.Matrix m)
m
- An UJMP matrix.Method Detail |
---|
public org.ujmp.core.Matrix getMatrix()
public void setValue(int i, int j, double value)
i
- The row index to store new value.j
- The column index to store new value.value
- The value to store.public double getValue(int i, int j)
i
- The row index to retrieve.j
- The column index to retrieve.
public DenseVector getRowRef(int index)
index
- The row index to retrieve.
public DenseVector getRow(int index)
index
- The row index to retrieve.
public DenseVector getColRef(int index)
index
- The column index to retrieve.
public DenseVector getCol(int index)
index
- The column index to retrieve.
public SparseMatrix toSparseMatrix()
public DenseMatrix toDenseSubset(int[] indexList)
indexList
- The list of indices.
public DenseMatrix toDenseSubset(int[] rowList, int[] colList)
rowList
- The list of row indices.colList
- The list of column indices.
public int[] length()
public int itemCount()
public DenseVector diagonal()
public double sum()
public double average()
public double variance()
public double stdev()
public DenseMatrix scale(double alpha)
alpha
- The scalar value to be multiplied to this matrix.
public void selfScale(double alpha)
alpha
- The scalar value to be multiplied to this matrix.public DenseMatrix add(double alpha)
alpha
- The scalar value to be added to this matrix.
public void selfAdd(double alpha)
alpha
- The scalar value to be added to this matrix.public DenseMatrix exp(double alpha)
alpha
- The exponent.
public DenseMatrix transpose()
public DenseVector times(DenseVector x)
x
- The vector to be multiplied to this matrix.
java.lang.RuntimeException
- when dimensions disagreepublic DenseMatrix times(DenseMatrix B)
B
- The matrix to be multiplied to this matrix.
java.lang.RuntimeException
- when dimensions disagreepublic DenseMatrix plus(DenseMatrix B)
B
- The matrix to be added to this matrix.
java.lang.RuntimeException
- when dimensions disagreepublic static DenseMatrix makeIdentity(int n)
n
- The size of requested identity matrix.
public DenseMatrix inverse()
java.lang.RuntimeException
- when dimensions disagree.public DenseMatrix cholesky()
java.lang.RuntimeException
- when matrix is not square.public DenseMatrix covariance()
public DenseMatrix partScale(double alpha, int[] indexList)
alpha
- The scalar to be multiplied to this matrix.indexList
- The list of indices to be applied summation.
public DenseMatrix partPlus(DenseMatrix B, int[] indexList)
B
- The matrix to be added to this matrix.indexList
- The list of indices to be applied summation.
java.lang.RuntimeException
- when dimensions disagree.public DenseMatrix partMinus(DenseMatrix B, int[] indexList)
B
- The matrix to be subtracted from this matrix.indexList
- The list of indices to be applied subtraction.
java.lang.RuntimeException
- when dimensions disagree.public DenseVector partTimes(DenseVector x, int[] indexList)
x
- The vector to be multiplied to this matrix.indexList
- The list of indices to be applied multiplication.
public DenseMatrix partInverse(int[] indexList)
indexList
- The list of indices to be applied multiplication.
java.lang.RuntimeException
- when dimensions disagree.public java.lang.String toString()
toString
in class java.lang.Object
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |