Class TridiagonalMatrix

  • All Implemented Interfaces:
    Matrix

    public class TridiagonalMatrix
    extends Object
    implements Matrix
    Class representing a tridiagonal matrix. $$ \begin{align*} \begin{pmatrix} a_1 & b_1 & 0 & \cdots & 0 & 0 & 0 \\ c_1 & a_2 & b_2 & \cdots & 0 & 0 & 0 \\ 0 & & \ddots & & \vdots & \vdots & \vdots \\ 0 & 0 & 0 & & c_{n-2} & a_{n-1} & b_{n-1} \\ 0 & 0 & 0 & \cdots & 0 & c_{n-1} & a_n \end{pmatrix} \end{align*} $$
    • Constructor Detail

      • TridiagonalMatrix

        public TridiagonalMatrix​(double[] a,
                                 double[] b,
                                 double[] c)
        Parameters:
        a - An array containing the diagonal values of the matrix, not null
        b - An array containing the upper sub-diagonal values of the matrix, not null. Its length must be one less than the length of the diagonal array
        c - An array containing the lower sub-diagonal values of the matrix, not null. Its length must be one less than the length of the diagonal array
    • Method Detail

      • getDiagonalData

        public double[] getDiagonalData()
        Direct access to Diagonal Data.
        Returns:
        An array of the values of the diagonal
      • getDiagonal

        public double[] getDiagonal()
        Returns:
        An array of the values of the diagonal
      • getUpperSubDiagonalData

        public double[] getUpperSubDiagonalData()
        Direct access to upper sub-Diagonal Data.
        Returns:
        An array of the values of the upper sub-diagonal
      • getUpperSubDiagonal

        public double[] getUpperSubDiagonal()
        Returns:
        An array of the values of the upper sub-diagonal
      • getLowerSubDiagonalData

        public double[] getLowerSubDiagonalData()
        Direct access to lower sub-Diagonal Data.
        Returns:
        An array of the values of the lower sub-diagonal
      • getLowerSubDiagonal

        public double[] getLowerSubDiagonal()
        Returns:
        An array of the values of the lower sub-diagonal
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object
      • dimensions

        public int dimensions()
        Description copied from interface: Matrix
        Gets the number of dimensions of the matrix.

        Each matrix type has a fixed number of dimensions, returned by this method.

        Specified by:
        dimensions in interface Matrix
        Returns:
        the dimensions of the matrix
      • size

        public int size()
        Description copied from interface: Matrix
        Gets the size of the matrix.

        This is the total number of elements in the matrix.

        Specified by:
        size in interface Matrix
        Returns:
        the size of the matrix
      • getEntry

        public double getEntry​(int... index)
        Gets the entry for the indices.
        Parameters:
        index - the indices
        Returns:
        the entry