Implements a conjugate gradient method as sparse linear algebra solver. More...
#include <conjugate_gradient_method.hpp>
Public Member Functions | |
virtual SparseSolver * | clone () const =0 |
ConjugateGradientMethod () | |
ConjugateGradientMethod (const ConjugateGradientMethod &arg) | |
virtual returnValue | getX (double *x_) |
virtual returnValue | setDimension (const int &n) |
virtual returnValue | setIndices (const int *rowIdx_, const int *colIdx_)=0 |
virtual returnValue | setMatrix (double *A_) |
virtual returnValue | setNumberOfEntries (const int &nDense_) |
virtual returnValue | setPrintLevel (PrintLevel printLevel_) |
virtual returnValue | setTolerance (double TOL_) |
virtual returnValue | solve (double *b) |
virtual | ~ConjugateGradientMethod () |
Public Member Functions inherited from SparseSolver | |
virtual returnValue | factorize ()=0 |
virtual int_t | getNegativeEigenvalues () |
virtual int_t | getRank () |
virtual returnValue | getZeroPivots (int_t *&zeroPivots) |
virtual SparseSolver & | operator= (const SparseSolver &rhs) |
virtual returnValue | reset () |
virtual returnValue | setMatrixData (int_t dim, int_t numNonzeros, const int_t *const airn, const int_t *const acjn, const real_t *const avals)=0 |
virtual returnValue | solve (int_t dim, const real_t *const rhs, real_t *const sol)=0 |
virtual returnValue | solveTranspose (double *b) |
SparseSolver () | |
SparseSolver (const SparseSolver &rhs) | |
SparseSolver () | |
virtual | ~SparseSolver () |
virtual | ~SparseSolver () |
Protected Member Functions | |
virtual returnValue | applyInversePreconditioner (double *x_)=0 |
virtual returnValue | applyPreconditioner (double *b)=0 |
virtual returnValue | computePreconditioner (double *A_)=0 |
virtual void | multiply (double *xx, double *result)=0 |
double | scalarProduct (double *aa, double *bb) |
Protected Member Functions inherited from SparseSolver | |
returnValue | clear () |
returnValue | copy (const SparseSolver &rhs) |
Protected Attributes | |
double * | A |
double * | condScale |
int | dim |
int | nDense |
double * | norm2 |
double ** | p |
int | pCounter |
PrintLevel | printLevel |
double * | r |
double | TOL |
double * | x |
Implements a conjugate gradient method as sparse linear algebra solver.
The class ConjugateGradientMethod implements a special sparse
linear algebra solver. After the application of an preconditioner
an iterative conjugate basis of the sparse data matrix A is
computed. The algotithm stops if the required tolerance is achieved.
Definition at line 57 of file conjugate_gradient_method.hpp.
BEGIN_NAMESPACE_ACADO ConjugateGradientMethod::ConjugateGradientMethod | ( | ) |
Default constructor.
Definition at line 48 of file conjugate_gradient_method.cpp.
ConjugateGradientMethod::ConjugateGradientMethod | ( | const ConjugateGradientMethod & | arg | ) |
Copy constructor (deep copy).
Definition at line 64 of file conjugate_gradient_method.cpp.
|
virtual |
Destructor.
Definition at line 126 of file conjugate_gradient_method.cpp.
|
protectedpure virtual |
Applies the inverse of the preconditioner to the vector x (only internal use)
Implemented in SymmetricConjugateGradientMethod, and NormalConjugateGradientMethod.
|
protectedpure virtual |
Applies the preconditioner to the vector b (only internal use)
Implemented in SymmetricConjugateGradientMethod, and NormalConjugateGradientMethod.
|
pure virtual |
Clone operator (deep copy).
Implements SparseSolver.
Implemented in SymmetricConjugateGradientMethod, and NormalConjugateGradientMethod.
|
protectedpure virtual |
Computes the preconditioner and Applies it to the input matrix.
Implemented in SymmetricConjugateGradientMethod, and NormalConjugateGradientMethod.
|
virtual |
Returns the solution of the equation A*x = b if solved.
Implements SparseSolver.
Definition at line 329 of file conjugate_gradient_method.cpp.
|
protectedpure virtual |
Evaluates the matrix-vector product result = A*xx efficiently. (only internal use)
Implemented in SymmetricConjugateGradientMethod, and NormalConjugateGradientMethod.
|
protected |
Returns the scalar product of aa and bb. (only internal use)
Definition at line 355 of file conjugate_gradient_method.cpp.
|
virtual |
Defines the dimension n of A R^{n n}
Implements SparseSolver.
Definition at line 252 of file conjugate_gradient_method.cpp.
|
pure virtual |
Sets an index list containing the positions of the
non-zero elements in the matrix A.
Implements SparseSolver.
Implemented in SymmetricConjugateGradientMethod, and NormalConjugateGradientMethod.
|
virtual |
Sets the non-zero elements of the matrix A. The double* A
is assumed to contain nDense entries corresponding to
non-zero elements of A.
Implements SparseSolver.
Definition at line 315 of file conjugate_gradient_method.cpp.
|
virtual |
Defines the number of non-zero elements in the
matrix A
Implements SparseSolver.
Definition at line 300 of file conjugate_gradient_method.cpp.
|
virtual |
Sets the print level.
Implements SparseSolver.
Definition at line 342 of file conjugate_gradient_method.cpp.
|
virtual |
Sets the required tolerance (accuracy) for the solution of
the linear equation. For large tolerances an iterative
algorithm might converge earlier.
Requires || A*x - b || <= TOL
The norm || . || is possibly scaled by a preconditioner.
Implements SparseSolver.
Definition at line 335 of file conjugate_gradient_method.cpp.
|
virtual |
Solves the system A*x = b for the specified data.
Implements SparseSolver.
Definition at line 149 of file conjugate_gradient_method.cpp.
|
protected |
Definition at line 183 of file conjugate_gradient_method.hpp.
|
protected |
Definition at line 193 of file conjugate_gradient_method.hpp.
|
protected |
Definition at line 178 of file conjugate_gradient_method.hpp.
|
protected |
Definition at line 179 of file conjugate_gradient_method.hpp.
|
protected |
Definition at line 189 of file conjugate_gradient_method.hpp.
|
protected |
Definition at line 190 of file conjugate_gradient_method.hpp.
|
protected |
Definition at line 192 of file conjugate_gradient_method.hpp.
|
protected |
Definition at line 197 of file conjugate_gradient_method.hpp.
|
protected |
Definition at line 191 of file conjugate_gradient_method.hpp.
|
protected |
Definition at line 196 of file conjugate_gradient_method.hpp.
|
protected |
Definition at line 184 of file conjugate_gradient_method.hpp.