Class ThomasAlgorithm


  • public final class ThomasAlgorithm
    extends Object
    Thomas algorithm is an efficient algorithm to solve a linear tridiagonal matrix equation. The complexity of the Thomas algorithm is \(O(N)\), where N is the number of unknowns.

    A tridiagonal system for N unknowns can be written as \[ a_i x_{i-1} + b_i x_i + c_i x_{i+1} = d_i, \] where a1 = 0 and cn = 0. \[ \begin{bmatrix} {b_1} & {c_1} & { } & { } & { 0 } \\ {a_2} & {b_2} & {c_2} & { } & { } \\ { } & {a_3} & {b_3} & \ddots & { } \\ { } & { } & \ddots & \ddots & {c_{n-1}} \\ { 0 } & { } & { } & {a_n} & {b_n} \\ \end{bmatrix} \begin{bmatrix} {x_1} \\ {x_2} \\ {x_3} \\ \vdots \\ {x_n} \\ \end{bmatrix} = \begin{bmatrix} {d_1} \\ {d_2} \\ {d_3} \\ \vdots \\ {d_n} \\ \end{bmatrix} . \]

    See Also:
    Wikipedia: Thomas algorithm
    • Constructor Detail

      • ThomasAlgorithm

        public ThomasAlgorithm()
    • Method Detail

      • solve

        public Vector solve​(TridiagonalMatrix A,
                            Vector d)
        Solves a tridiagonal matrix equation.
        Parameters:
        A - the left hand side coefficient matrix
        d - the right hand side vector
        Returns:
        the solution vector
        Throws:
        ArithmeticException - when the diagonal contains zeros