Class RealForwardSolver

java.lang.Object
org.flag4j.linalg.solvers.exact.triangular.ForwardSolver<Matrix,Vector,double[]>
org.flag4j.linalg.solvers.exact.triangular.RealForwardSolver
All Implemented Interfaces:
LinearMatrixSolver<Matrix,Vector>, LinearSolver<Matrix>

public class RealForwardSolver extends ForwardSolver<Matrix,Vector,double[]>
This solver solves a real linear system of equations where the coefficient matrix is lower triangular. That is, solves the systems \( Lx = b \) or \( LX = B \) where \( L \) is a lower triangular matrix. This is accomplished using a simple forward substitution.
See Also:
  • Field Summary

    Fields inherited from class org.flag4j.linalg.solvers.exact.triangular.ForwardSolver

    enforceLower, isUnit, RANK_CONDITION, xCol
  • Constructor Summary

    Constructors
    Constructor
    Description
    Creates a solver to solve a linear system where the coefficient matrix is lower triangular.
    RealForwardSolver(boolean isUnit)
    Creates a solver to solve a linear system where the coefficient matrix is lower triangular or unit lower triangular.
    RealForwardSolver(boolean isUnit, boolean enforceLower)
    Creates a solver to solve a linear system where the coefficient matrix is lower triangular or unit lower triangular.
  • Method Summary

    Modifier and Type
    Method
    Description
    double
    Gets the determinant computed during the last solve.
    Performs forward substitution for a unit lower triangular matrix \( L \) and a matrix \( B \).
    Performs forward substitution for a unit lower triangular matrix \( L \) and a vector \( b \).
    Solves a linear system \( LX = P \) for \( X \) where \( L \) is a lower triangular matrix and \( P \) is a permutation matrix.
    Performs forward substitution for a unit lower triangular matrix \( L \) and the identity matrix.

    Methods inherited from class org.flag4j.linalg.solvers.exact.triangular.ForwardSolver

    checkParams, checkSingular

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • RealForwardSolver

      public RealForwardSolver()
      Creates a solver to solve a linear system where the coefficient matrix is lower triangular.
    • RealForwardSolver

      public RealForwardSolver(boolean isUnit)
      Creates a solver to solve a linear system where the coefficient matrix is lower triangular or unit lower triangular.
      Parameters:
      isUnit - Flag which indicates if the coefficient matrix is unit lower triangular or not.
      • If true, the coefficient matrix is expected to be unit lower triangular.
      • If false, the coefficient matrix is expected to be lower triangular but not necessarily unit lower.
    • RealForwardSolver

      public RealForwardSolver(boolean isUnit, boolean enforceLower)
      Creates a solver to solve a linear system where the coefficient matrix is lower triangular or unit lower triangular.
      Parameters:
      isUnit - Flag which indicates if the coefficient matrix is unit lower triangular or not.
      • If true, the coefficient matrix is expected to be unit lower triangular.
      • If false, the coefficient matrix is expected to be lower triangular but not necessarily unit lower.
      enforceLower - Flag indicating if an explicit check should be made that the coefficient matrix is lower triangular.
  • Method Details

    • getDet

      public double getDet()
      Gets the determinant computed during the last solve.
    • solve

      public Vector solve(Matrix L, Vector b)
      Performs forward substitution for a unit lower triangular matrix \( L \) and a vector \( b \). That is, solves the linear system \( Lx = b \) for \( x \) where \( L \) is lower triangular.
      Parameters:
      L - Lower triangular coefficient matrix \( L \). L is assumed to be lower triangular and only entries at and below the principle diagonal will be accessed.
      b - Constant vector \( b \).
      Returns:
      The result of solving the linear system \( Lx = b \) where \( L \) is a lower triangular.
      Throws:
      SingularMatrixException - If L is singular (i.e. has at least one zero on the principle diagonal).
    • solve

      public Matrix solve(Matrix L, Matrix B)
      Performs forward substitution for a unit lower triangular matrix \( L \) and a matrix \( B \). That is, solves the linear system \( LX = B \) for \( X \) where \( L \) is lower triangular.
      Parameters:
      L - Lower triangular coefficient matrix \( L \). L is assumed to be lower triangular and only entries at and below the principle diagonal will be accessed.
      B - The constant matrix in the linear system.
      b - Constant matrix \( B \).
      Returns:
      The result of solving the linear system \( LX = B \) where \( L \) is a lower triangular.
      Throws:
      SingularMatrixException - If L is singular (i.e. has at least one zero on the principle diagonal).
    • solve

      public Matrix solve(Matrix L, PermutationMatrix P)
      Solves a linear system \( LX = P \) for \( X \) where \( L \) is a lower triangular matrix and \( P \) is a permutation matrix.
      Specified by:
      solve in class ForwardSolver<Matrix,Vector,double[]>
      Parameters:
      L - Lower triangular coefficient matrix \( L \).
      P - Constant permutation matrix \( P \).
      Returns:
      The solution to \( X \) in the linear system \( LX = P \).
    • solveIdentity

      public Matrix solveIdentity(Matrix L)
      Performs forward substitution for a unit lower triangular matrix \( L \) and the identity matrix. That is, solves the linear system \( LX = I \) where \( L \) is a lower triangular matrix and \( I \) is the appropriately sized identity matrix.
      Parameters:
      L - Lower triangular coefficient matrix, \( L \). If L is not lower triangular, it will be treated as if it were and only data in the lower triangular portion will be accessed.
      Returns:
      The result of solving the linear system \( LX = B \) where \( L \) is a lower triangular matrix.
      Throws:
      SingularMatrixException - If the matrix lower triangular L is singular (i.e. has at least one zero on the principle diagonal).