Class SymmTriDiag
java.lang.Object
org.flag4j.arrays.sparse.SymmTriDiag
- All Implemented Interfaces:
Serializable
A real symmetric tri-diagonal matrix. This class stores the non-zero values of the symmetric tri-diagonal matrix and has limited support for ops 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:
-
Constructor Summary
ConstructorsConstructorDescriptionSymmTriDiag
(double[] diag, double[] offDiag) Constructs a symmetric tri-diagonal matrix with the provided diagonal and off-diagonal data. -
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.getShape()
Gets the shape of this symmetric tri-diagonal matrix.int
hashCode()
Creates a hash code for this symmetric tri-diagonal matrix.toDense()
Converts this symmetric tri-diagonal matrix to an equivalent dense matrix.
-
Constructor Details
-
SymmTriDiag
public SymmTriDiag(double[] diag, double[] offDiag) Constructs a symmetric tri-diagonal matrix with the provided diagonal and off-diagonal data.- Parameters:
diag
- Diagonal data of the symmetric tri-diagonal matrix.offDiag
- Sub/super diagonal data of the symmetric tri-diagonal matrix.
-
-
Method Details
-
getShape
Gets the shape of this symmetric tri-diagonal matrix.- Returns:
- The shape of this symmetric tri-diagonal matrix.
-
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 ofSymmTriDiag
and all diagonal and off diagonal data are equal.- Overrides:
equals
in classObject
- Parameters:
object
- Object to compare to this symmetric tri-diagonal matrix.- Returns:
- True if
b
is an instance ofSymmTriDiag
and all diagonal and off diagonal data are equal to the corresponding values in this symmetric tri-diagonal matrix.
-
hashCode
-