Package no.uib.cipr.matrix.sparse
Class CG
- java.lang.Object
-
- no.uib.cipr.matrix.sparse.AbstractIterativeSolver
-
- no.uib.cipr.matrix.sparse.CG
-
- All Implemented Interfaces:
IterativeSolver
public class CG extends AbstractIterativeSolver
Conjugate Gradients solver. CG solves the symmetric positive definite linear systemAx=b
using the Conjugate Gradient method.
-
-
Field Summary
-
Fields inherited from class no.uib.cipr.matrix.sparse.AbstractIterativeSolver
iter, M
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Vector
solve(Matrix A, Vector b, Vector x)
Solves the given problem, writing result into the vector.-
Methods inherited from class no.uib.cipr.matrix.sparse.AbstractIterativeSolver
checkSizes, getIterationMonitor, getPreconditioner, setIterationMonitor, setPreconditioner
-
-
-
-
Constructor Detail
-
CG
public CG(Vector template)
Constructor for CG. Uses the given vector as template for creating scratch vectors. Typically, the solution or the right hand side vector can be passed, and the template is not modified- Parameters:
template
- Vector to use as template for the work vectors needed in the solution process
-
-
Method Detail
-
solve
public Vector solve(Matrix A, Vector b, Vector x) throws IterativeSolverNotConvergedException
Description copied from interface:IterativeSolver
Solves the given problem, writing result into the vector.- Parameters:
A
- Matrix of the problemb
- Right hand sidex
- Solution is stored here. Also used as initial guess- Returns:
- The solution vector x
- Throws:
IterativeSolverNotConvergedException
-
-