public class CGSolver extends java.lang.Object implements IterativeSolver
IterativeSolver.ToleranceType
Modifier and Type | Field and Description |
---|---|
boolean |
debug |
Constructor and Description |
---|
CGSolver() |
Modifier and Type | Method and Description |
---|---|
int |
getMaxIterations() |
int |
getNumIterations()
Returns the number of iterations associated with the last call to
solve . |
double |
getRelativeResidual()
Returns the relative residual ||A x - b||/||b|| at the end of the last
call to
solve . |
double |
getTolerance() |
IterativeSolver.ToleranceType |
getToleranceType() |
boolean |
isCompatible(int matrixType) |
void |
setMaxIterations(int max) |
void |
setTolerance(double tol) |
void |
setToleranceType(IterativeSolver.ToleranceType type) |
boolean |
solve(VectorNd x,
LinearTransformNd A,
VectorNd b)
Solves a linear system A x = b using the conjugate gradient method.
|
boolean |
solve(VectorNd x,
LinearTransformNd A,
VectorNd b,
double tol,
int maxIter)
Solves a linear system A x = b using the conjugate gradient method.
|
boolean |
solve(VectorNd x,
LinearTransformNd A,
VectorNd b,
double tol,
int maxIter,
LinearTransformNd P)
Solves a linear system A x = b using the conjugate gradient method with a
preconditioner.
|
boolean |
solveTransformed(VectorNd x,
SparseMatrixNd A,
VectorNd b,
double tol,
int maxIter,
IncompleteCholeskyDecomposition icd) |
public double getTolerance()
getTolerance
in interface IterativeSolver
public void setTolerance(double tol)
setTolerance
in interface IterativeSolver
public IterativeSolver.ToleranceType getToleranceType()
getToleranceType
in interface IterativeSolver
public void setToleranceType(IterativeSolver.ToleranceType type)
setToleranceType
in interface IterativeSolver
public int getMaxIterations()
getMaxIterations
in interface IterativeSolver
public void setMaxIterations(int max)
setMaxIterations
in interface IterativeSolver
public boolean solve(VectorNd x, LinearTransformNd A, VectorNd b)
LinearTransformNd
. The method
will iterate while relative residual ||A x - b||/||b|| is greater than a
supplied tolerance and the number of iterations is less than a specified
maximum.solve
in interface IterativeSolver
x
- result vector, as well as initial guess of the solutionA
- linear transform for the system to be solvedb
- input vectorpublic boolean solve(VectorNd x, LinearTransformNd A, VectorNd b, double tol, int maxIter)
LinearTransformNd
. The method
will iterate while relative residual ||A x - b||/||b|| is greater than a
supplied tolerance and the number of iterations is less than a specified
maximum.x
- result vector, as well as initial guess of the solutionA
- linear transform for the system to be solvedb
- input vectortol
- solution tolerancemaxIter
- maximum number of iferationspublic boolean solve(VectorNd x, LinearTransformNd A, VectorNd b, double tol, int maxIter, LinearTransformNd P)
LinearTransformNd
. The mul
method of the preconditioner
should implement the transformation y = inv(M) x, where M is a a
preconditioning matrix that approximates A. The method will iterate while
relative residual ||A x - b||/||b|| is greater than a supplied tolerance
and the number of iterations is less than a specified maximum.x
- result vector, as well as initial guess of the solutionA
- linear transform for the system to be solvedb
- input vectortol
- solution tolerancemaxIter
- maximum number of iferationsP
- preconditioner (optional, may be specified as null)public int getNumIterations()
solve
.getNumIterations
in interface IterativeSolver
public double getRelativeResidual()
solve
.getRelativeResidual
in interface IterativeSolver
public boolean isCompatible(int matrixType)
isCompatible
in interface IterativeSolver
public boolean solveTransformed(VectorNd x, SparseMatrixNd A, VectorNd b, double tol, int maxIter, IncompleteCholeskyDecomposition icd)