|
SuanShu, a Java numerical and statistical library | |||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||
java.lang.Objectcom.numericalmethod.suanshu.matrix.doubles.matrixtype.MatrixMathImpl<T>
com.numericalmethod.suanshu.matrix.doubles.matrixtype.MatrixStorageImpl<T>
com.numericalmethod.suanshu.matrix.doubles.matrixtype.dense.triangle.TriangularMatrix<LowerTriangularMatrix>
com.numericalmethod.suanshu.matrix.doubles.matrixtype.dense.triangle.LowerTriangularMatrix
public class LowerTriangularMatrix
This class implements the lower triangular matrix, which has 0 entries whenever column index > row index.
This implementation saves about half of the data cost (except for the diagonal)
when compared to the DenseMatrix implementation.
Users may use this class instead of DenseMatrix
when they know that the matrix is lower triangular.
Lower triangular matrices are always square.
| Constructor Summary | |
|---|---|
LowerTriangularMatrix(double[][] data)
Construct a lower triangular matrix from a 2D double[][] array. |
|
LowerTriangularMatrix(int dim)
Construct a lower triangular matrix of dimension dim * dim. |
|
LowerTriangularMatrix(LowerTriangularMatrix L)
Copy constructor performing a deep copy. |
|
LowerTriangularMatrix(Matrix A)
Construct a lower triangular matrix from a matrix. |
|
| Method Summary | |
|---|---|
LowerTriangularMatrix |
add(LowerTriangularMatrix that)
this + that
Add with a LowerTriangularMatrix. |
LowerTriangularMatrix |
deepCopy()
The implementation can return an instance created from this by the copy
constructor of the class, or just this if the instance itself is
immutable. |
DenseVector |
getColumn(int col)
Get a specified column as a vector. |
DenseVector |
getRow(int row)
Get a specified row as a vector. |
LowerTriangularMatrix |
minus(LowerTriangularMatrix that)
this - that
Subtract a LowerTriangularMatrix. |
LowerTriangularMatrix |
multiply(LowerTriangularMatrix that)
this %*% that
Multiply by a LowerTriangularMatrix. |
LowerTriangularMatrix |
ONE()
Get an identity matrix that has the same dimension as this matrix. |
LowerTriangularMatrix |
scaled(double scalar)
scalar * this |
UpperTriangularMatrix |
t()
t(A) |
DenseMatrix |
toDense()
Densify a matrix, i.e., convert a matrix implementation to a standard dense matrix, DenseMatrix. |
LowerTriangularMatrix |
ZERO()
The additive element 0 in the group, such that for all elements a in the group,
the equation 0 + a = a + 0 = a holds. |
| Methods inherited from class com.numericalmethod.suanshu.matrix.doubles.matrixtype.dense.triangle.TriangularMatrix |
|---|
dim, getMatrixData |
| Methods inherited from class com.numericalmethod.suanshu.matrix.doubles.matrixtype.MatrixStorageImpl |
|---|
equals, get, hashCode, set, setMatrixData |
| Methods inherited from class com.numericalmethod.suanshu.matrix.doubles.matrixtype.MatrixMathImpl |
|---|
add, call, getSample, minus, multiply, multiply, nCols, nRows, opposite, setColumn, setColumn, setRow, setRow, toString |
| Methods inherited from class java.lang.Object |
|---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
public LowerTriangularMatrix(int dim)
dim * dim.
dim - dimension; for a square matrix, it is the number of rows or columnspublic LowerTriangularMatrix(double[][] data)
data - the 2D array input
java.lang.IllegalArgumentException - when the input data is not a lower triangular matrixpublic LowerTriangularMatrix(Matrix A)
A - a matrix
java.lang.IllegalArgumentException - when A is not squarepublic LowerTriangularMatrix(LowerTriangularMatrix L)
L - the LowerTriangularMatrix to be copied| Method Detail |
|---|
public LowerTriangularMatrix deepCopy()
Matrixthis by the copy
constructor of the class, or just this if the instance itself is
immutable.
Override the return type.
deepCopy in interface DeepCopyabledeepCopy in interface MatrixMatrix instancepublic DenseMatrix toDense()
DensifiableDenseMatrix.
This is equivalent to
new DenseMatrix(Matrix A)
Individual matrix implementation may optimize the conversion
by taking advantage of having access to the class' private members.
In other words, toDense() is in general more efficient than explicit copy construction.
As an example, for some long matrix computations, we may not be sure about the return type. We can always cast it to the standard matrix. That is,
DenseMatrix A = B.multiply(C).add(D).minus(E).toDense();
This statement always works regardless of the types of B, C, D, and E.
toDense in interface DensifiableDenseMatrixpublic DenseVector getRow(int row)
MatrixAccessor
getRow in interface MatrixAccessorgetRow in class MatrixMathImpl<LowerTriangularMatrix>row - the row index
A[row, ]public DenseVector getColumn(int col)
MatrixAccessor
getColumn in interface MatrixAccessorgetColumn in class MatrixMathImpl<LowerTriangularMatrix>col - the column index
A[, col]public LowerTriangularMatrix add(LowerTriangularMatrix that)
this + that
Add with a LowerTriangularMatrix.
that - another matrix
this and thatpublic LowerTriangularMatrix minus(LowerTriangularMatrix that)
this - that
Subtract a LowerTriangularMatrix.
that - another matrix
this and thatpublic LowerTriangularMatrix multiply(LowerTriangularMatrix that)
this %*% that
Multiply by a LowerTriangularMatrix.
that - another matrix
this and thatpublic LowerTriangularMatrix ZERO()
AbelianGroupa in the group,
the equation 0 + a = a + 0 = a holds.
ZERO in interface AbelianGroup<Matrix>ZERO in interface MatrixRing0public LowerTriangularMatrix ONE()
MatrixRingFor a non-square matrix, it zeros out the rows (columns) with index > nCols (nRows).
ONE in interface Monoid<Matrix>ONE in interface MatrixRingpublic UpperTriangularMatrix t()
t(A)
t in interface MatrixRingt in class MatrixMathImpl<LowerTriangularMatrix>thispublic LowerTriangularMatrix scaled(double scalar)
Matrixscalar * this
scaled in interface Matrixscaled in class MatrixMathImpl<LowerTriangularMatrix>scalar - a double
scalar * this
|
SuanShu, a Java numerical and statistical library | |||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||