|
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<UpperTriangularMatrix>
com.numericalmethod.suanshu.matrix.doubles.matrixtype.dense.triangle.UpperTriangularMatrix
public class UpperTriangularMatrix
This class implements upper triangular matrix, which has 0 entries whenever row index > column index.
This implementation saves about half of the data cost (except for the diagonal)
when compared to the implementation of DenseMatrix.
Users may use this class instead of DenseMatrix
when they know that the matrix is upper triangular.
Upper triangular matrices are always square.
| Constructor Summary | |
|---|---|
UpperTriangularMatrix(double[][] data)
Construct an upper triangular matrix from a 2D double[][] array. |
|
UpperTriangularMatrix(int dim)
Construct an upper triangular matrix of dimension dim * dim. |
|
UpperTriangularMatrix(Matrix U)
Copy constructor performing a deep copy of a matrix. |
|
UpperTriangularMatrix(UpperTriangularMatrix U)
Copy constructor performing a deep copy. |
|
| Method Summary | |
|---|---|
UpperTriangularMatrix |
add(UpperTriangularMatrix that)
|
UpperTriangularMatrix |
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. |
UpperTriangularMatrix |
minus(UpperTriangularMatrix that)
|
UpperTriangularMatrix |
multiply(UpperTriangularMatrix that)
|
UpperTriangularMatrix |
ONE()
Get an identity matrix that has the same dimension as this matrix. |
UpperTriangularMatrix |
scaled(double scalar)
scalar * this |
LowerTriangularMatrix |
t()
t(A) |
DenseMatrix |
toDense()
Densify a matrix, i.e., convert a matrix implementation to a standard dense matrix, DenseMatrix. |
UpperTriangularMatrix |
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 UpperTriangularMatrix(int dim)
dim * dim.
Space for the matrix data is not yet allocated.
dim - dimension; for a square matrix, it is the number of rows or columnspublic UpperTriangularMatrix(double[][] data)
data - the 2D array input
java.lang.IllegalArgumentException - if data is not upper triangularpublic UpperTriangularMatrix(Matrix U)
U - a matrix
java.lang.IllegalArgumentException - when A is not square, or when A is not upper triangularpublic UpperTriangularMatrix(UpperTriangularMatrix U)
U - an UpperTriangularMatrix| Method Detail |
|---|
public UpperTriangularMatrix 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<UpperTriangularMatrix>row - the row index
A[row, ]public DenseVector getColumn(int col)
MatrixAccessor
getColumn in interface MatrixAccessorgetColumn in class MatrixMathImpl<UpperTriangularMatrix>col - the column index
A[, col]public UpperTriangularMatrix add(UpperTriangularMatrix that)
public UpperTriangularMatrix minus(UpperTriangularMatrix that)
public UpperTriangularMatrix multiply(UpperTriangularMatrix that)
public UpperTriangularMatrix ZERO()
AbelianGroupa in the group,
the equation 0 + a = a + 0 = a holds.
ZERO in interface AbelianGroup<Matrix>ZERO in interface MatrixRing0public UpperTriangularMatrix 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 LowerTriangularMatrix t()
t(A)
t in interface MatrixRingt in class MatrixMathImpl<UpperTriangularMatrix>public UpperTriangularMatrix scaled(double scalar)
Matrixscalar * this
scaled in interface Matrixscaled in class MatrixMathImpl<UpperTriangularMatrix>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 | |||||||