public class TridiagonalMatrix extends Object
Constructor and Description |
---|
TridiagonalMatrix(double[][] data)
Constructs a tri-diagonal matrix from a 3-row 2D
double[][] array such that:
the first row is the super diagonal with (dim - 1) entries;
the second row is the main diagonal with dim entries;
the third row is the sub diagonal with (dim - 1) entries.
For example,
|
TridiagonalMatrix(int dim)
Constructs a 0 tri-diagonal matrix of dimension dim * dim.
|
TridiagonalMatrix(Matrix A)
Casts a matrix to tridiagonal by copying the 3 diagonals (ignoring all other entries).
|
TridiagonalMatrix(TridiagonalMatrix that)
Copy constructor performing a deep copy.
|
Modifier and Type | Method and Description |
---|---|
Matrix |
add(Matrix that)
this + that
|
TridiagonalMatrix |
deepCopy()
The implementation returns an instance created from
this by the copy
constructor of the class, or just this if the instance itself is
immutable. |
boolean |
equals(Object obj) |
double |
get(int i,
int j)
Get the matrix entry at [i,j].
|
Vector |
getColumn(int j)
Get the specified column in the matrix as a vector.
|
DenseVector |
getDiagonal()
Gets the main diagonal of the matrix.
|
Vector |
getRow(int i)
Get the specified row in the matrix as a vector.
|
DenseVector |
getSubDiagonal()
Gets the sub-diagonal of the matrix.
|
DenseVector |
getSuperDiagonal()
Gets the super-diagonal of the matrix.
|
int |
hashCode() |
Matrix |
minus(Matrix that)
this - that
|
Matrix |
multiply(Matrix that)
this * that
|
Vector |
multiply(Vector v)
Right multiply this matrix, A, by a vector.
|
int |
nCols()
Gets the number of columns.
|
int |
nRows()
Gets the number of rows.
|
TridiagonalMatrix |
ONE()
Get an identity matrix that has the same dimension as this matrix.
|
TridiagonalMatrix |
opposite()
For each a in G, there exists an element b in G such that
a + b = b + a = 0.
|
TridiagonalMatrix |
scaled(double scalar)
Scale this matrix, A, by a constant.
|
void |
set(int i,
int j,
double value)
Set the matrix entry at [i,j] to a value.
|
TridiagonalMatrix |
t()
Get the transpose of this matrix.
|
DenseMatrix |
toDense()
Densify a matrix, i.e., convert a matrix implementation to the standard dense matrix,
DenseMatrix . |
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.
|
public TridiagonalMatrix(int dim)
dim
- the dimension of the matrixpublic TridiagonalMatrix(double[][] data)
double[][]
array such that:
gives \[ \begin{bmatrix} 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 \end{bmatrix} \] We allownew double[][]{ {2, 5, 8, 11}, {1, 4, 7, 10, 13}, {3, 6, 9, 12} }
null
input when a diagonal is 0s.
For example,
gives \[ \begin{bmatrix} 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 \end{bmatrix} \] The following is not allowed because the dimension cannot be determined.new double[][]{ {2, 5, 8, 11}, {1, 4, 7, 10, 13}, null }
new double[][]{ null, null, null }
data
- the 2D array inputpublic TridiagonalMatrix(Matrix A)
A
- the matrixpublic TridiagonalMatrix(TridiagonalMatrix that)
that
- a tri-diagonal matrixpublic TridiagonalMatrix deepCopy()
DeepCopyable
this
by the copy
constructor of the class, or just this
if the instance itself is
immutable.public Matrix add(Matrix that)
MatrixRing
add
in interface MatrixRing
add
in interface AbelianGroup<Matrix>
that
- a matrixthis
and that
public Matrix minus(Matrix that)
MatrixRing
minus
in interface MatrixRing
minus
in interface AbelianGroup<Matrix>
that
- a matrixthis
and that
public TridiagonalMatrix scaled(double scalar)
Matrix
scalar
- a doublepublic TridiagonalMatrix opposite()
AbelianGroup
this.add(this.opposite()) == this.ZERO
public TridiagonalMatrix t()
MatrixRing
public TridiagonalMatrix ZERO()
AbelianGroup
public TridiagonalMatrix ONE()
MatrixRing
public DenseMatrix toDense()
Densifiable
DenseMatrix
.toDense
in interface Densifiable
DenseMatrix
public DenseVector getDiagonal()
public DenseVector getSuperDiagonal()
public DenseVector getSubDiagonal()
public int nRows()
Table
public int nCols()
Table
public void set(int i, int j, double value) throws MatrixAccessException
MatrixAccess
set
in interface MatrixAccess
i
- the row indexj
- the column indexvalue
- the value to set A[i,j] toMatrixAccessException
- if i or j is out of rangepublic double get(int i, int j) throws MatrixAccessException
MatrixAccess
get
in interface MatrixAccess
i
- the row indexj
- the column indexMatrixAccessException
- if i or j is out of rangepublic Vector getRow(int i)
Matrix
public Vector getColumn(int j)
Matrix
public Matrix multiply(Matrix that)
MatrixRing
multiply
in interface MatrixRing
multiply
in interface Monoid<Matrix>
that
- a matrixthis
and that
public Vector multiply(Vector v)
Matrix
Copyright © 2010-2020 NM FinTech Ltd.. All Rights Reserved.