Class RealBackSolver
java.lang.Object
org.flag4j.linalg.solvers.exact.triangular.BackSolver<Matrix,Vector,double[]>
org.flag4j.linalg.solvers.exact.triangular.RealBackSolver
- All Implemented Interfaces:
LinearMatrixSolver<Matrix,,Vector> LinearSolver<Matrix>
This solver solves linear systems of the form \( Ux = b \) or
\( UX = B \) where \( U \) is an
upper triangular matrix. This system is solved in an exact sense.
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected doubleFor computing determinant of coefficient matrix during solve.Fields inherited from class org.flag4j.linalg.solvers.exact.triangular.BackSolver
checkSingular, enforceTriU, x, X, xCol -
Constructor Summary
ConstructorsConstructorDescriptionCreates a solver for solving linear systems for upper triangular coefficient matrices.RealBackSolver(boolean enforceTriU) Creates a solver for solving linear systems for upper triangular coefficient matrices. -
Method Summary
Modifier and TypeMethodDescriptiondoublegetDet()Gets the determinant computed during the last solve.setCheckSingular(boolean checkSingular) Sets a flag indicating if an explicit check should be made that the coefficient matrix is singular.Solves the linear system of equations given by \( UX = B \) where the coefficient matrix \( U \) is anupper triangularmatrix.Solves the linear system of equations given by \( Ux = b \) where the coefficient matrix \( U \) is anupper triangularmatrix.Solves the linear system of equations given by \( UX = I \) where the coefficient matrix \( U \) is anupper triangularmatrix and I is theidentitymatrix of appropriate size.solveLower(Matrix U, Matrix L) Solves a special case of the linear system \( UX = L \) for \( X \) where the coefficient matrix \( U \) is anupper triangularmatrix and the constant matrix \( L \) islower triangular.Methods inherited from class org.flag4j.linalg.solvers.exact.triangular.BackSolver
checkParams, checkSingular
-
Field Details
-
det
protected double detFor computing determinant of coefficient matrix during solve.
-
-
Constructor Details
-
RealBackSolver
public RealBackSolver()Creates a solver for solving linear systems for upper triangular coefficient matrices. By default, an explicit check will be made that the coefficient matrix is upper triangular. To toggle this, useRealBackSolver(boolean). -
RealBackSolver
public RealBackSolver(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
Sets a flag indicating if an explicit check should be made that the coefficient matrix is singular.- Overrides:
setCheckSingularin classBackSolver<Matrix,Vector, double[]> - 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.
- If
- Returns:
- A reference to this back solver instance.
-
getDet
public double getDet()Gets the determinant computed during the last solve. -
solve
Solves the linear system of equations given by \( Ux = b \) where the coefficient matrix \( U \) is anupper triangularmatrix.- Parameters:
U- Upper triangular coefficient matrix in the linear system. IfenforceTriUwas set tofalsewhen this solver instance was created andUis not actually upper triangular, it will be treated as if it were.b- Vector of constants in the linear system.- Returns:
- The solution to x in the linear system \( Ux = b \).
- Throws:
SingularMatrixException- If the matrixUis singular (i.e. has a zero on the principle diagonal).
-
solve
Solves the linear system of equations given by \( UX = B \) where the coefficient matrix \( U \) is anupper triangularmatrix.- Parameters:
U- Upper triangular coefficient matrix in the linear system. IfenforceTriUwas set tofalsewhen this solver instance was created andUis not actually upper triangular, it will be treated as if it were.B- Matrix of constants in the linear system.- Returns:
- The solution to X in the linear system \( UX = B \).
- Throws:
SingularMatrixException- If the matrixUis singular (i.e. has a zero on the principle diagonal).
-
solveIdentity
Solves the linear system of equations given by \( UX = I \) where the coefficient matrix \( U \) is anupper triangularmatrix and I is theidentitymatrix of appropriate size. This essentially inverts the upper triangular matrix since \( UU^{-1} = I \).- Parameters:
U- Upper triangular coefficient matrix in the linear system. IfenforceTriUwas set tofalsewhen this solver instance was created andUis not actually upper triangular, it will be treated as if it were.- Returns:
- The solution to X in the linear system \( UX = B \).
- Throws:
SingularMatrixException- If the matrixUis singular (i.e. has a zero on the principle diagonal).
-
solveLower
Solves a special case of the linear system \( UX = L \) for \( X \) where the coefficient matrix \( U \) is anupper triangularmatrix and the constant matrix \( L \) islower triangular.- Parameters:
U- Upper triangular coefficient matrix in the linear system. IfenforceTriUwas set tofalsewhen this solver instance was created andUis not actually upper triangular, it will be treated as if it were.L- Lower triangular constant matrix. This is not explicit checked. IfLis not lower triangular, values above the principle diagonal will be ignored and the result will still be correctly computed.- Returns:
- The result of solving the linear system \( UX = L \) for the matrix \( X \).
-