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:
LinearSolver<Matrix,
Vector>
This solver solves linear systems of equations where the coefficient matrix in an
upper triangular
real dense matrix
and the constant vector is a real dense vector or matrix. That is, solves a linear system of equations U*x=b
or
U*X=B
where U
is an upper triangular matrix.-
Field Summary
Modifier and TypeFieldDescriptionprotected double
For computing determinant of coefficient matrix during solve.Fields inherited from class org.flag4j.linalg.solvers.exact.triangular.BackSolver
enforceTriU, RANK_CONDITION, x, X, xCol
-
Constructor Summary
ConstructorDescriptionCreates 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 TypeMethodDescriptiondouble
getDet()
Gets the determinant computed during the last solve.Solves the linear system of equations given byU*X=B
where the coefficient matrixU
is anupper triangular
matrix.Solves the linear system of equations given byU*x=b
where the coefficient matrixU
is anupper triangular
matrix.Solves the linear system of equations given byU*X=I
where the coefficient matrixU
is anupper triangular
matrix andI
is theidentity
matrix of appropriate size.solveLower
(Matrix U, Matrix L) Solves a special case of the linear systemU*X=L
forX
where the coefficient matrixU
is anupper triangular
matrix and the constant matrixL
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. Note, by default no check will * be made to ensure the coefficient matrix is upper triangular. If you would like to enforce this, see *RealBackSolver(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
-
getDet
public double getDet()Gets the determinant computed during the last solve. -
solve
Solves the linear system of equations given byU*x=b
where the coefficient matrixU
is anupper triangular
matrix.- Parameters:
U
- Upper triangular coefficient matrix in the linear system. IfenforceTriU
was set tofalse
when this solver instance was created andU
is 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 systemA*x=b
. - Throws:
SingularMatrixException
- If the matrixU
is singular (i.e. has a zero on the principle diagonal).
-
solve
Solves the linear system of equations given byU*X=B
where the coefficient matrixU
is anupper triangular
matrix.- Parameters:
U
- Upper triangular coefficient matrix in the linear system. IfenforceTriU
was set tofalse
when this solver instance was created andU
is 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 systemU*X=B
. - Throws:
SingularMatrixException
- If the matrixU
is singular (i.e. has a zero on the principle diagonal).
-
solveIdentity
Solves the linear system of equations given byU*X=I
where the coefficient matrixU
is anupper triangular
matrix andI
is theidentity
matrix of appropriate size. This essentially inverts the upper triangular matrix sinceU*U
-1=I
.- Parameters:
U
- Upper triangular coefficient matrix in the linear system. IfenforceTriU
was set tofalse
when this solver instance was created andU
is not actually upper triangular, it will be treated as if it were.- Returns:
- The solution to
X
in the linear systemU*X=B
. - Throws:
SingularMatrixException
- If the matrixU
is singular (i.e. has a zero on the principle diagonal).
-
solveLower
Solves a special case of the linear systemU*X=L
forX
where the coefficient matrixU
is anupper triangular
matrix and the constant matrixL
islower triangular
.- Parameters:
U
- Upper triangular coefficient matrix in the linear system. IfenforceTriU
was set tofalse
when this solver instance was created andU
is not actually upper triangular, it will be treated as if it were.L
- Lower triangular constant matrix. This is not explicit checked. IfL
is 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
U*X=L
for the matrixX
.
-