Package org.flag4j.arrays.sparse
Class SymmTriDiagonal
java.lang.Object
org.flag4j.arrays.sparse.SymmTriDiagonal
- All Implemented Interfaces:
Serializable
A real symmetric tri-diagonal matrix. Note, this class simply stores the values of the symmetric tri-diagonal matrix and has limited support for operations with such a matrix.
A matrix is symmetric tri-diagonal if it is symmetric and all values below the first sub-diagonal and above the first super-diagonal are zero.
For example, the following matrix is in symmetric tri-diagonal form where each X
may hold a different value (provided
the matrix is symmetric):
[[ X X 0 0 0 ] [ X X X 0 0 ] [ 0 X X X 0 ] [ 0 0 X X X ] [ 0 0 0 X X ]]
- See Also:
-
Field Summary
Modifier and TypeFieldDescription(package private) final double[]
Stores the diagonal entries of this symmetric tri-diagonal matrix.(package private) final double[]
Stores the first sub/super diagonal entries of this symmetric tri-diagonal matrix.(package private) final int
The size (i.e. -
Constructor Summary
ConstructorDescriptionSymmTriDiagonal
(double[] diag, double[] offDiag) Constructs a symmetric tri-diagonal matrix with the provided diagonal and off-diagonal entries. -
Method Summary
Modifier and TypeMethodDescriptionboolean
Checks if an object is equal to this symmetric tri-diagonal matrix.double
get
(int rowIdx, int colIdx) Gets the entry within this symmetric tri-diagonal matrix at the specified indices.int
hashCode()
Creates a hash code for this symmetric tri-diagonal matrix.shape()
Gets the shape of this symmetric tri-diagonal matrix.toDense()
Converts this symmetric tri-diagonal matrix to an equivalent dense matrix.
-
Field Details
-
diag
final double[] diagStores the diagonal entries of this symmetric tri-diagonal matrix. -
offDiag
final double[] offDiagStores the first sub/super diagonal entries of this symmetric tri-diagonal matrix. -
size
final int sizeThe size (i.e. number of rows and columns) of this symmetric tri-diagonal matrix.
-
-
Constructor Details
-
SymmTriDiagonal
public SymmTriDiagonal(double[] diag, double[] offDiag) Constructs a symmetric tri-diagonal matrix with the provided diagonal and off-diagonal entries.- Parameters:
diag
- Diagonal entries of the symmetric tri-diagonal matrix.offDiag
- Sub/super diagonal entries of the symmetric tri-diagonal matrix.
-
-
Method Details
-
get
public double get(int rowIdx, int colIdx) Gets the entry within this symmetric tri-diagonal matrix at the specified indices.- Parameters:
rowIdx
- Row index of entry to get.colIdx
- Column index of entry to get.- Returns:
- The entry of this symmetric tri-diagonal matrix at the specified indices.
- Throws:
IndexOutOfBoundsException
- If either index is out of bounds for this matrix.
-
toDense
Converts this symmetric tri-diagonal matrix to an equivalent dense matrix.- Returns:
- A dense matrix equivalent to this symmetric tri-diagonal matrix.
-
equals
Checks if an object is equal to this symmetric tri-diagonal matrix. An object is considered equal to this matrix if it is an instance ofSymmTriDiagonal
and all diagonal and off diagonal entries are equal.- Overrides:
equals
in classObject
- Parameters:
object
- Object to compare to this symmetric tri-diagonal matrix.- Returns:
- True if
b
is an instance ofSymmTriDiagonal
and all diagonal and off diagonal entries are equal to the corresponding values in this symmetric tri-diagonal matrix.
-
hashCode
-
shape
Gets the shape of this symmetric tri-diagonal matrix.- Returns:
- The shape of this symmetric tri-diagonal matrix.
-