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:
LinearSolver<Matrix,
Vector>
This solver solves linear systems of equations where the coefficient matrix in a lower triangular real dense matrix
and the constant vector is a real dense vector.
-
Field Summary
Modifier and TypeFieldDescriptionprivate double
For computing determinant of lower triangular matrix during solve.Fields inherited from class org.flag4j.linalg.solvers.exact.triangular.ForwardSolver
enforceLower, isUnit, RANK_CONDITION, x, X, xCol
-
Constructor Summary
ConstructorDescriptionCreates 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 TypeMethodDescriptiondouble
getDet()
Gets the determinant computed during the last solve.Performs forward substitution for a unit lower triangular matrixL
and a matrixB
.Performs forward substitution for a unit lower triangular matrixL
and a vectorb
.Performs forward substitution for a unit lower triangular matrixL
and the identity matrix.private Matrix
solveLower
(Matrix L, Matrix B) Solves a linear system where the coefficient matrix is lower triangular.private Vector
solveLower
(Matrix L, Vector b) Solves a linear system where the coefficient matrix is lower triangular.private Matrix
Solves a linear systemL*X=I
where the coefficient matrixL
is lower triangular and the constant matrixI
is the appropriately sized identity matrix.private Matrix
solveUnitLower
(Matrix L, Matrix B) Solves a linear system where the coefficient matrix is unit lower triangular.private Vector
solveUnitLower
(Matrix L, Vector b) Solves a linear system where the coefficient matrix is unit lower triangular.private Matrix
Solves a linear system where the coefficient matrix is unit lower triangular and the constant matrix is the identity matrix.Methods inherited from class org.flag4j.linalg.solvers.exact.triangular.ForwardSolver
checkParams, checkSingular
-
Field Details
-
det
private double detFor computing determinant of lower triangular matrix during solve.
-
-
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 true, the coefficient matrix is expected to be lower triangular.
-
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 true, the coefficient matrix is expected to be lower triangular.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
Performs forward substitution for a unit lower triangular matrixL
and a vectorb
. That is, solves the linear systemL*x=b
whereL
is a lower triangular matrix.- Parameters:
L
- Lower triangular coefficient matrix. IfL
is not lower triangular, it will be treated as if it were.b
- Constant vector.- Returns:
- The result of solving the linear system
L*x=b
whereL
is a lower triangular matrix. - Throws:
SingularMatrixException
- If
-
solve
Performs forward substitution for a unit lower triangular matrixL
and a matrixB
. That is, solves the linear systemL*X=B
whereL
is a lower triangular matrix.- Parameters:
L
- Lower triangular coefficient matrix. IfL
is not lower triangular, it will be treated as if it were.B
- Constant Matrix.- Returns:
- The result of solving the linear system
L*X=B
whereL
is a lower triangular matrix. - Throws:
SingularMatrixException
- If the matrix lower triangularL
is singular (i.e. has a zero on * the principle diagonal).
-
solveIdentity
Performs forward substitution for a unit lower triangular matrixL
and the identity matrix. That is, solves the linear systemL*X=I
whereL
is a lower triangular matrix andI
is the appropriately sized identity matrix.- Parameters:
L
- Lower triangular coefficient matrix. IfL
is not lower triangular, it will be treated as if it were.- Returns:
- The result of solving the linear system
L*X=B
whereL
is a lower triangular matrix. - Throws:
SingularMatrixException
- If the matrix lower triangularL
is singular (i.e. has a zero on the principle diagonal).
-
solveUnitLower
-
solveLower
Solves a linear system where the coefficient matrix is lower triangular.- Parameters:
L
- Unit lower triangular matrix.b
- Vector of constants in the linear system.- Returns:
- The solution of
x
for the linear systemL*x=b
. - Throws:
SingularMatrixException
- If the lower triangular matrixL
is singular (i.e. has a zero on the principle diagonal).
-
solveUnitLower
-
solveLower
Solves a linear system where the coefficient matrix is lower triangular.- Parameters:
L
- Unit lower triangular matrix.B
- Matrix of constants in the linear system.- Returns:
- The solution of
X
for the linear systemL*X=b
. - Throws:
SingularMatrixException
- If the lower triangular matrixL
is singular (i.e. has a zero on the principle diagonal).
-
solveUnitLowerIdentity
-
solveLowerIdentity
Solves a linear systemL*X=I
where the coefficient matrixL
is lower triangular and the constant matrixI
is the appropriately sized identity matrix.- Parameters:
L
- Unit lower triangular matrix (Note, this is not checked). IfL
is not lower triangular, it will be treated as if it were. No error will be thrown.- Returns:
- The solution of
X
for the linear systemL*X=I
. - Throws:
SingularMatrixException
- If the lower triangular matrixL
is singular (i.e. has a zero on the principle diagonal).
-