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
FieldsModifier and TypeFieldDescriptionprotected final booleanFlag indicating if an explicit check should be made that the coefficient matrix is lower triangular.protected final booleanFlag indicating if lower-triangular matrices passed to this solver will be unit lower-triangular (true) or simply lower-triangular (false).protected static final doubleThreshold for determining if a determinant is to be considered zero when checking if the coefficient matrix is full rank.protected VTemporary storage for columns of the solution matrix. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedForwardSolver(boolean isUnit, boolean enforceLower) Creates a solver for solving a lower-triangular system. -
Method Summary
Modifier and TypeMethodDescriptionprotected voidcheckParams(T coeff, int constantRows) Ensures passed parameters are valid for the back solver.protected voidcheckSingular(double detAbs, int numRows, int numCols) Checks if the coefficient matrix is singular based on the computed determinant.abstract Tsolve(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.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.flag4j.linalg.solvers.LinearMatrixSolver
solve, solve
-
Field Details
-
RANK_CONDITION
protected static final double RANK_CONDITIONThreshold for determining if a determinant is to be considered zero when checking if the coefficient matrix is full rank. -
isUnit
protected final boolean isUnitFlag indicating if lower-triangular matrices passed to this solver will be unit lower-triangular (true) or simply lower-triangular (false). -
enforceLower
protected final boolean enforceLowerFlag 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
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
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
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 ifenforceTriUis true andcoeffis 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.
-