|
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.BidiagonalMatrix
public class BidiagonalMatrix
This class represents a matrix with non-zero entries only on the main, and either the super-diagonal or sub-diagonal.
| Nested Class Summary | |
|---|---|
static class |
BidiagonalMatrix.Type
the types of bidiagonal matrices available |
| Constructor Summary | |
|---|---|
BidiagonalMatrix(BidiagonalMatrix that)
Copy constructor. |
|
BidiagonalMatrix(double[][] data)
Construct a bidiagonal matrix from a 2D double[][] array. |
|
BidiagonalMatrix(int dim,
BidiagonalMatrix.Type type)
Construct a bidiagonal matrix of dimension dim * dim. |
|
| Method Summary | |
|---|---|
BidiagonalMatrix |
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()
|
boolean |
isUnreduced(double epsilon)
A bidiagonal matrix is unreduced iff it has no 0 on both the super and main diagonals. |
Matrix |
multiply(Matrix that)
this %*% that |
BidiagonalMatrix |
ONE()
Get an identity matrix that has the same dimension as this matrix. |
BidiagonalMatrix |
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. |
BidiagonalMatrix |
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()
|
BidiagonalMatrix.Type |
type()
Get the type of the bidiagonal matrix. |
BidiagonalMatrix |
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, 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 BidiagonalMatrix(double[][] data)
There are two rows. The longer row is the main diagonal and has one more element. If the first row is shorter, it is an upper bidiagonal matrix. If the second row is shorter, it is a lower bidiagonal matrix.
For example,
new double[][]{
{2, 5, 8, 11},
{1, 4, 7, 10, 13}
}
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 |
We allow 'null' input when a diagonal is 0s, except for the main diagonal.
For example,
new double[][]{
{1, 4, 7, 10, 13},
null
}
is
| 1 0 0 0 0 |
| 0 4 0 0 0 |
| 0 0 7 0 0 |
| 0 0 0 10 0 |
| 0 0 0 0 13 |
The following is not allowed because the dimension cannot be determined.
new double[][]{
null,
null
}
We will treat a diagonal matrix as an upper bidiagonal matrix in this class.
data - the 2D array input
public BidiagonalMatrix(int dim,
BidiagonalMatrix.Type type)
dim * dim.
dim - dimension of the matrixtype - the type of bidiagonal matrix to createpublic BidiagonalMatrix(BidiagonalMatrix that)
that - a BidiagonalMatrix| Method Detail |
|---|
public BidiagonalMatrix deepCopy()
Matrixthis by the copy
constructor of the class, or just this if the instance itself is
immutable.
Override the return type.
Matrix instancepublic BidiagonalMatrix.Type type()
public BidiagonalMatrix 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<BidiagonalMatrix>public Matrix multiply(Matrix that)
MatrixRingthis %*% that
multiply in interface Monoid<Matrix>multiply in interface MatrixRingmultiply in class MatrixMathImpl<BidiagonalMatrix>that - another matrix
this and thatpublic BidiagonalMatrix scaled(double scalar)
Matrixscalar * this
scaled in interface Matrixscaled in class MatrixMathImpl<BidiagonalMatrix>scalar - a double
scalar * thispublic BidiagonalMatrix ZERO()
AbelianGroupa in the group,
the equation 0 + a = a + 0 = a holds.
0public BidiagonalMatrix ONE()
MatrixRingFor a non-square matrix, it zeros out the rows (columns) with index > nCols (nRows).
public boolean isUnreduced(double epsilon)
epsilon - a precision parameter: when a number |x| ≤ ε, it is considered 0
true iff this is unreducedpublic 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 | |||||||