Class ForwardSolver<T extends MatrixMixin<T,?,U,?>,U extends VectorMixin<U,T,?,?>,V>

java.lang.Object
org.flag4j.linalg.solvers.exact.triangular.ForwardSolver<T,U,V>
Type Parameters:
T - Type of coefficient matrix.
U - Vector type equivalent to the coefficient matrix.
V - Type of the internal storage datastructures in the matrix and vector.
All Implemented Interfaces:
LinearMatrixSolver<T,U>, LinearSolver<T>
Direct Known Subclasses:
ComplexForwardSolver, RealForwardSolver

public abstract class ForwardSolver<T extends MatrixMixin<T,?,U,?>,U extends VectorMixin<U,T,?,?>,V> extends Object implements LinearMatrixSolver<T,U>
This solver solves linear systems 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.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected final boolean
    Flag indicating if an explicit check should be made that the coefficient matrix is lower triangular.
    protected final boolean
    Flag indicating if lower-triangular matrices passed to this solver will be unit lower-triangular (true) or simply lower-triangular (false).
    protected static final double
    Threshold for determining if a determinant is to be considered zero when checking if the coefficient matrix is full rank.
    protected V
    Temporary storage for columns of the solution matrix.
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    protected
    ForwardSolver(boolean isUnit, boolean enforceLower)
    Creates a solver for solving a lower-triangular system.
  • Method Summary

    Modifier and Type
    Method
    Description
    protected void
    checkParams(T coeff, int constantRows)
    Ensures passed parameters are valid for the back solver.
    protected void
    checkSingular(double detAbs, int numRows, int numCols)
    Checks if the coefficient matrix is singular based on the computed determinant.
    abstract T
    Solves a linear system LX = P for X where L is a lower triangular matrix and P is a permutation matrix.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface org.flag4j.linalg.solvers.LinearMatrixSolver

    solve, solve
  • Field Details

    • RANK_CONDITION

      protected static final double RANK_CONDITION
      Threshold for determining if a determinant is to be considered zero when checking if the coefficient matrix is full rank.
    • isUnit

      protected final boolean isUnit
      Flag indicating if lower-triangular matrices passed to this solver will be unit lower-triangular (true) or simply lower-triangular (false).
    • enforceLower

      protected final boolean enforceLower
      Flag indicating if an explicit check should be made that the coefficient matrix is lower triangular. If false, the matrix will simply be assumed to be lower triangular.
    • xCol

      protected V xCol
      Temporary storage for columns of the solution matrix. This can be used to improve cache performance when columns need to be traveled.
  • Constructor Details

    • ForwardSolver

      protected ForwardSolver(boolean isUnit, boolean enforceLower)
      Creates a solver for solving a lower-triangular system.
      Parameters:
      isUnit - Flag indicating if coefficient matrices passed will be unit lower-triangular or simply lower-triangular in general.
      enforceLower - Flag indicating if an explicit check should be made that the coefficient matrix is lower triangular.
  • Method Details

    • solve

      public abstract T solve(T L, PermutationMatrix P)
      Solves a linear system LX = P for X where L is a lower triangular matrix and P is a permutation matrix.
      Parameters:
      L - Lower triangular coefficient matrix.
      P - Constant permutation matrix.
      Returns:
      The solution of X for the linear system LX = P.
    • checkParams

      protected void checkParams(T coeff, int constantRows)
      Ensures passed parameters are valid for the back solver.
      Parameters:
      coeff - Coefficient matrix in the linear system.
      constantRows - Number of rows in the constant vector or matrix.
      Throws:
      IllegalArgumentException - If coeff is not square, coeff.numRows()!=constantRows, or if enforceTriU is true and coeff is not upper triangular.
    • checkSingular

      protected void checkSingular(double detAbs, int numRows, int numCols)
      Checks if the coefficient matrix is singular based on the computed determinant.
      Parameters:
      detAbs - Absolute value of computed determinant.
      numRows - Number of rows in the coefficient matrix.
      numCols - Number of columns in the coefficient matrix.