Class SymmTriDiag

java.lang.Object
org.flag4j.arrays.sparse.SymmTriDiag
All Implemented Interfaces:
Serializable

public class SymmTriDiag extends Object implements 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

    Constructors
    Constructor
    Description
    SymmTriDiag(double[] diag, double[] offDiag)
    Constructs a symmetric tri-diagonal matrix with the provided diagonal and off-diagonal data.
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    equals(Object object)
    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.
    Gets the shape of this symmetric tri-diagonal matrix.
    int
    Creates a hash code for this symmetric tri-diagonal matrix.
    Converts this symmetric tri-diagonal matrix to an equivalent dense matrix.

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
  • 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

      public Shape 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

      public 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

      public boolean equals(Object object)
      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 of SymmTriDiag and all diagonal and off diagonal data are equal.
      Overrides:
      equals in class Object
      Parameters:
      object - Object to compare to this symmetric tri-diagonal matrix.
      Returns:
      True if b is an instance of SymmTriDiag and all diagonal and off diagonal data are equal to the corresponding values in this symmetric tri-diagonal matrix.
    • hashCode

      public int hashCode()
      Creates a hash code for this symmetric tri-diagonal matrix.
      Overrides:
      hashCode in class Object
      Returns:
      An integer hash code for this symmetric tri-diagonal matrix.