Package org.apache.commons.math3.linear
Class PreconditionedIterativeLinearSolver
java.lang.Object
org.apache.commons.math3.linear.IterativeLinearSolver
org.apache.commons.math3.linear.PreconditionedIterativeLinearSolver
- Direct Known Subclasses:
ConjugateGradient,SymmLQ
This abstract class defines preconditioned iterative solvers. When A is ill-conditioned, instead of solving system A · x = b directly, it is preferable to solve either
Concrete implementations of this abstract class must be provided with the
preconditioner M, as a RealLinearOperator.
- Since:
- 3.0
-
Constructor Summary
ConstructorsConstructorDescriptionPreconditionedIterativeLinearSolver(int maxIterations) Creates a new instance of this class, with default iteration manager.Creates a new instance of this class, with custom iteration manager. -
Method Summary
Modifier and TypeMethodDescriptionprotected static voidPerforms all dimension checks on the parameters ofsolveandsolveInPlace, and throws an exception if one of the checks fails.Returns an estimate of the solution to the linear system A · x = b.solve(RealLinearOperator a, RealLinearOperator m, RealVector b, RealVector x0) Returns an estimate of the solution to the linear system A · x = b.Returns an estimate of the solution to the linear system A · x = b.solve(RealLinearOperator a, RealVector b, RealVector x0) Returns an estimate of the solution to the linear system A · x = b.abstract RealVectorsolveInPlace(RealLinearOperator a, RealLinearOperator m, RealVector b, RealVector x0) Returns an estimate of the solution to the linear system A · x = b.solveInPlace(RealLinearOperator a, RealVector b, RealVector x0) Returns an estimate of the solution to the linear system A · x = b.Methods inherited from class org.apache.commons.math3.linear.IterativeLinearSolver
checkParameters, getIterationManager
-
Constructor Details
-
PreconditionedIterativeLinearSolver
public PreconditionedIterativeLinearSolver(int maxIterations) Creates a new instance of this class, with default iteration manager.- Parameters:
maxIterations- the maximum number of iterations
-
PreconditionedIterativeLinearSolver
Creates a new instance of this class, with custom iteration manager.- Parameters:
manager- the custom iteration manager- Throws:
NullArgumentException- ifmanagerisnull
-
-
Method Details
-
solve
public RealVector solve(RealLinearOperator a, RealLinearOperator m, RealVector b, RealVector x0) throws NullArgumentException, NonSquareOperatorException, DimensionMismatchException, MaxCountExceededException Returns an estimate of the solution to the linear system A · x = b.- Parameters:
a- the linear operator A of the systemm- the preconditioner, M (can benull)b- the right-hand side vectorx0- the initial guess of the solution- Returns:
- a new vector containing the solution
- Throws:
NullArgumentException- if one of the parameters isnullNonSquareOperatorException- ifaormis not squareDimensionMismatchException- ifm,borx0have dimensions inconsistent withaMaxCountExceededException- at exhaustion of the iteration count, unless a customcallbackhas been set at construction of theIterationManager
-
solve
public RealVector solve(RealLinearOperator a, RealVector b) throws NullArgumentException, NonSquareOperatorException, DimensionMismatchException, MaxCountExceededException Returns an estimate of the solution to the linear system A · x = b.- Overrides:
solvein classIterativeLinearSolver- Parameters:
a- the linear operator A of the systemb- the right-hand side vector- Returns:
- a new vector containing the solution
- Throws:
NullArgumentException- if one of the parameters isnullNonSquareOperatorException- ifais not squareDimensionMismatchException- ifbhas dimensions inconsistent withaMaxCountExceededException- at exhaustion of the iteration count, unless a customcallbackhas been set at construction of theIterationManager
-
solve
public RealVector solve(RealLinearOperator a, RealVector b, RealVector x0) throws NullArgumentException, NonSquareOperatorException, DimensionMismatchException, MaxCountExceededException Returns an estimate of the solution to the linear system A · x = b.- Overrides:
solvein classIterativeLinearSolver- Parameters:
a- the linear operator A of the systemb- the right-hand side vectorx0- the initial guess of the solution- Returns:
- a new vector containing the solution
- Throws:
NullArgumentException- if one of the parameters isnullNonSquareOperatorException- ifais not squareDimensionMismatchException- ifborx0have dimensions inconsistent withaMaxCountExceededException- at exhaustion of the iteration count, unless a customcallbackhas been set at construction of theIterationManager
-
checkParameters
protected static void checkParameters(RealLinearOperator a, RealLinearOperator m, RealVector b, RealVector x0) throws NullArgumentException, NonSquareOperatorException, DimensionMismatchException Performs all dimension checks on the parameters ofsolveandsolveInPlace, and throws an exception if one of the checks fails.- Parameters:
a- the linear operator A of the systemm- the preconditioner, M (can benull)b- the right-hand side vectorx0- the initial guess of the solution- Throws:
NullArgumentException- if one of the parameters isnullNonSquareOperatorException- ifaormis not squareDimensionMismatchException- ifm,borx0have dimensions inconsistent witha
-
solve
public RealVector solve(RealLinearOperator a, RealLinearOperator m, RealVector b) throws NullArgumentException, NonSquareOperatorException, DimensionMismatchException, MaxCountExceededException Returns an estimate of the solution to the linear system A · x = b.- Parameters:
a- the linear operator A of the systemm- the preconditioner, M (can benull)b- the right-hand side vector- Returns:
- a new vector containing the solution
- Throws:
NullArgumentException- if one of the parameters isnullNonSquareOperatorException- ifaormis not squareDimensionMismatchException- ifmorbhave dimensions inconsistent withaMaxCountExceededException- at exhaustion of the iteration count, unless a customcallbackhas been set at construction of theIterationManager
-
solveInPlace
public abstract RealVector solveInPlace(RealLinearOperator a, RealLinearOperator m, RealVector b, RealVector x0) throws NullArgumentException, NonSquareOperatorException, DimensionMismatchException, MaxCountExceededException Returns an estimate of the solution to the linear system A · x = b. The solution is computed in-place (initial guess is modified).- Parameters:
a- the linear operator A of the systemm- the preconditioner, M (can benull)b- the right-hand side vectorx0- the initial guess of the solution- Returns:
- a reference to
x0(shallow copy) updated with the solution - Throws:
NullArgumentException- if one of the parameters isnullNonSquareOperatorException- ifaormis not squareDimensionMismatchException- ifm,borx0have dimensions inconsistent withaMaxCountExceededException- at exhaustion of the iteration count, unless a customcallbackhas been set at construction of theIterationManager
-
solveInPlace
public RealVector solveInPlace(RealLinearOperator a, RealVector b, RealVector x0) throws NullArgumentException, NonSquareOperatorException, DimensionMismatchException, MaxCountExceededException Returns an estimate of the solution to the linear system A · x = b. The solution is computed in-place (initial guess is modified).- Specified by:
solveInPlacein classIterativeLinearSolver- Parameters:
a- the linear operator A of the systemb- the right-hand side vectorx0- initial guess of the solution- Returns:
- a reference to
x0(shallow copy) updated with the solution - Throws:
NullArgumentException- if one of the parameters isnullNonSquareOperatorException- ifais not squareDimensionMismatchException- ifborx0have dimensions inconsistent withaMaxCountExceededException- at exhaustion of the iteration count, unless a customcallbackhas been set at construction of theIterationManager
-