Class RealExactSolver

java.lang.Object
org.flag4j.linalg.solvers.exact.ExactSolver<Matrix,Vector>
org.flag4j.linalg.solvers.exact.RealExactSolver
Type Parameters:
T - The type of the coefficient matrix in the linear system.
U - The type of vector in the linear system.
All Implemented Interfaces:
LinearMatrixSolver<Matrix,Vector>, LinearSolver<Matrix>

public class RealExactSolver extends ExactSolver<Matrix,Vector>

Solves a well determined system of equations \( Ax = b \) or \( AX = B \) in an exact sense by using a LU decomposition where \( A \), \( B \), and \( X \) are matrices, and \( x \) and \( b \) are vectors.

If the system is not well determined, i.e. \( A \) is not square or not full rank, then use a least-squares solver.

Usage:

A single system may be solved by calling either ExactSolver.solve(MatrixMixin, VectorMixin) or ExactSolver.solve(MatrixMixin, VectorMixin).

Instances of this solver may also be used to efficiently solve many systems of the form \( Ax = b \) or \( AX = B \) for the same coefficient matrix \( A \) but numerous constant vectors/matrices \( b \) or \( B \). To do this, the workflow would be as follows:

  1. Create an instance of RealExactSolver.
  2. Call decompse(A) once on the coefficient matrix \( A \).
  3. Call solve(b) or solve(B) as many times as needed to solve each system for with the various \( b \) vectors and/or \( B \) matrices.
Note: Any call made to one of the following methods after a call to decompse(A) will override the coefficient matrix set that call:

Specialized solvers are provided for inversion using ExactSolver.solveIdentity(MatrixMixin). This should be preferred over calling on of the other solve methods and providing an identity matrix explicitly.

  • Constructor Details

    • RealExactSolver

      public RealExactSolver()
      Constructs an exact LU solver where the coefficient matrix is real dense.
  • Method Details

    • permuteRows

      protected Vector permuteRows(Vector b)
      Permute the rows of a vector using the row permutation matrix from the LU decomposition.
      Specified by:
      permuteRows in class ExactSolver<Matrix,Vector>
      Parameters:
      b - Vector to permute the rows of.
      Returns:
      A vector which is the result of applying the row permutation from the LU decomposition to the vector b.
    • permuteRows

      protected Matrix permuteRows(Matrix B)
      Permute the rows of a matrix using the row permutation matrix from the LU decomposition.
      Specified by:
      permuteRows in class ExactSolver<Matrix,Vector>
      Parameters:
      B - matrix to permute the rows of.
      Returns:
      A matrix which is the result of applying the row permutation from the LU decomposition to the matrix B.