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

java.lang.Object
org.flag4j.linalg.solvers.exact.triangular.BackSolver<T,U,V>
Type Parameters:
T - Type of matrix to decompose.
U - Vector type equivalent of matrix.
V - Type of internal storage for the matrix and vector.
All Implemented Interfaces:
LinearMatrixSolver<T,U>, LinearSolver<T>
Direct Known Subclasses:
ComplexBackSolver, RealBackSolver

public abstract class BackSolver<T extends MatrixMixin<T,?,U,?>,U extends VectorMixin<U,T,?,?>,V> extends Object implements LinearMatrixSolver<T,U>
Base class for solvers which solve a linear system of equations \( Ux = b \) or \( UX = B \) where \( U \) is an upper triangular matrix. This system is solved in an exact sense.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected boolean
    Flag indicating if an explicit check should be made that the matrix is singular (or near singular).
    protected final boolean
    Flag indicating if determinant should be computed.
    protected U
    For storing vector results.
    protected T
    For storing matrix results.
    protected V
    For temporary storage of matrix columns to help improve cache performance.
  • Constructor Summary

    Constructors
    Constructor
    Description
    BackSolver(boolean enforceTriU)
    Creates a solver for solving linear systems for upper triangular coefficient matrices.
  • Method Summary

    Modifier and Type
    Method
    Description
    protected void
    checkParams(T coeff, Shape constantShape)
    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.
    protected BackSolver<T,U,V>
    setCheckSingular(boolean checkSingular)
    Sets a flag indicating if an explicit check should be made that the coefficient matrix is singular.

    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

    • X

      protected T extends MatrixMixin<T,?,U,?> X
      For storing matrix results.
    • x

      protected U extends VectorMixin<U,T,?,?> x
      For storing vector results.
    • xCol

      protected V xCol
      For temporary storage of matrix columns to help improve cache performance.
    • enforceTriU

      protected final boolean enforceTriU
      Flag indicating if determinant should be computed.
    • checkSingular

      protected boolean checkSingular
      Flag indicating if an explicit check should be made that the matrix is singular (or near singular).
      • If true, an explicit singularity check will be made.
      • If false, no check will be made.
  • Constructor Details

    • BackSolver

      public BackSolver(boolean enforceTriU)
      Creates a solver for solving linear systems for upper triangular coefficient matrices.
      Parameters:
      enforceTriU - Flag indicating if an explicit check should be made that the coefficient matrix is upper triangular.
  • Method Details

    • setCheckSingular

      protected BackSolver<T,U,V> setCheckSingular(boolean checkSingular)
      Sets a flag indicating if an explicit check should be made that the coefficient matrix is singular.
      Parameters:
      checkSingular - Flag indicating if an explicit check should be made that the matrix is singular (or near singular).
      • If true, an explicit singularity check will be made.
      • If false, no check will be made.
      Returns:
      A reference to this back solver instance.
    • checkParams

      protected void checkParams(T coeff, Shape constantShape)
      Ensures passed parameters are valid for the back solver.
      Parameters:
      coeff - Coefficient matrix in the linear system.
      constantRows - Shape of 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.