|
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.diagonal.TridiagonalMatrix
public class TridiagonalMatrix
This class represents a matrix with non-zero entries only on the super, main and sub diagonals.
| Constructor Summary | |
|---|---|
TridiagonalMatrix(double[][] data)
Construct a tridiagonal matrix from a 2D double[][] array. |
|
TridiagonalMatrix(int dim)
Construct a tridiagonal matrix of dimension dim * dim. |
|
TridiagonalMatrix(TridiagonalMatrix that)
Copy constructor performing a deep copy. |
|
| Method Summary | |
|---|---|
TridiagonalMatrix |
add(TridiagonalMatrix that)
|
TridiagonalMatrix |
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 |
diagonal()
Get a copy of the diagonal of the matrix. |
boolean |
equals(java.lang.Object obj)
Check if two matrices (of different implementations) are equal. |
DenseVector |
getColumn(int col)
Get a specified column as a vector. |
DenseVector |
getRow(int row)
Get a specified row as a vector. |
int |
hashCode()
|
TridiagonalMatrix |
minus(TridiagonalMatrix that)
|
TridiagonalMatrix |
ONE()
Get an identity matrix that has the same dimension as this matrix. |
TridiagonalMatrix |
scaled(double scalar)
scalar * this |
DenseVector |
subDiagonal()
Get a copy of the sub-diagonal of the matrix. |
DenseVector |
superDiagonal()
Get a copy of the super-diagonal of the matrix. |
TridiagonalMatrix |
t()
t(this)
Compute the transpose of this matrix. |
DenseMatrix |
toDense()
Densify a matrix, i.e., convert a matrix implementation to a standard dense matrix, DenseMatrix. |
java.lang.String |
toString()
|
TridiagonalMatrix |
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.MatrixStorageImpl |
|---|
get, getMatrixData, 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 |
| Methods inherited from class java.lang.Object |
|---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
public TridiagonalMatrix(int dim)
dim * dim.
dim - dimension of the matrixpublic TridiagonalMatrix(double[][] data)
For example,
new double[][]{
{2, 5, 8, 11},
{1, 4, 7, 10, 13},
{3, 6, 9, 12}
}
is
| 1 2 0 0 0 |
| 3 4 5 0 0 |
| 0 6 7 8 0 |
| 0 0 9 10 11 |
| 0 0 0 12 13 |
We allow 'null' input when a diagonal is 0s.
For example,
new double[][]{
{2, 5, 8, 11},
{1, 4, 7, 10, 13},
null
}
is
| 1 2 0 0 0 |
| 0 4 5 0 0 |
| 0 0 7 8 0 |
| 0 0 0 10 11 |
| 0 0 0 0 13 |
The following is not allowed because the dimension cannot be determined.
new double[][]{
null,
null,
null
}
data - the 2D array inputpublic TridiagonalMatrix(TridiagonalMatrix that)
that - a TridiagonalMatrix| Method Detail |
|---|
public TridiagonalMatrix deepCopy()
Matrixthis by the copy
constructor of the class, or just this if the instance itself is
immutable.
Override the return type.
Matrix instancepublic TridiagonalMatrix add(TridiagonalMatrix that)
public TridiagonalMatrix minus(TridiagonalMatrix that)
public TridiagonalMatrix ZERO()
AbelianGroupa in the group,
the equation 0 + a = a + 0 = a holds.
0public TridiagonalMatrix ONE()
MatrixRingFor a non-square matrix, it zeros out the rows (columns) with index > nCols (nRows).
public TridiagonalMatrix t()
MatrixRingt(this)
Compute the transpose of this matrix. The original matrix does not change. The returned value is independent and can be modified anyhow.
This is the involution on the matrix ring.
t in interface MatrixRingt in class MatrixMathImpl<TridiagonalMatrix>public TridiagonalMatrix scaled(double scalar)
Matrixscalar * this
scaled in interface Matrixscaled in class MatrixMathImpl<TridiagonalMatrix>scalar - a double
scalar * thispublic 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 diagonal()
public DenseVector superDiagonal()
public DenseVector subDiagonal()
public DenseVector getRow(int row)
MatrixAccessor
getRow in interface MatrixAccessorgetRow in class MatrixMathImpl<T extends com.numericalmethod.suanshu.matrix.doubles.matrixtype.dense.diagonal.DiagonalDataMatrix>row - the row index
A[row, ]public DenseVector getColumn(int col)
MatrixAccessor
getColumn in interface MatrixAccessorgetColumn in class MatrixMathImpl<T extends com.numericalmethod.suanshu.matrix.doubles.matrixtype.dense.diagonal.DiagonalDataMatrix>col - the column index
A[, col]public java.lang.String toString()
toString in class MatrixMathImpl<T extends com.numericalmethod.suanshu.matrix.doubles.matrixtype.dense.diagonal.DiagonalDataMatrix>public boolean equals(java.lang.Object obj)
MatrixStorageImpl
equals in class MatrixStorageImpl<T extends com.numericalmethod.suanshu.matrix.doubles.matrixtype.dense.diagonal.DiagonalDataMatrix>true iff two matrices have the same values, entry-by-entrypublic int hashCode()
hashCode in class MatrixStorageImpl<T extends com.numericalmethod.suanshu.matrix.doubles.matrixtype.dense.diagonal.DiagonalDataMatrix>
|
SuanShu, a Java numerical and statistical library | |||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||