STK++ 0.9.13
|
The conjugate gradient method is an algorithm for the numerical solution of particular systems of linear equations, namely those whose matrix is symmetric and positive-definite. More...
#include <STK_CG.h>
Public Types | |
typedef ColVector::Type | Type |
Public Member Functions | |
CG () | |
Default Constructor. | |
CG (MultFunctor const &mult, ColVector const &b, InitFunctor *const &p_init=0, Type eps=Arithmetic< Type >::epsilon()) | |
Constructor. | |
CG (CG const &cg) | |
Copy constructor. | |
~CG () | |
destructor | |
CG * | clone () const |
clone pattern | |
ColVector const & | x () const |
Real const & | x (int const &i) const |
int const & | iter () const |
int const & | nbStart () const |
ColVector const & | r () const |
void | setEps (Type const &eps) |
Set the tolerance. | |
void | setB (ColVector const &b) |
Set the constant vector. | |
void | setMultFunctor (MultFunctor const &mult) |
Set functor computing Ax. | |
void | setInitFunctor (InitFunctor *const &p_init) |
Set functor computing x at initialization. | |
int | run () |
String const & | error () const |
get the last error message. | |
Protected Member Functions | |
int | cg () |
Protected Attributes | |
String | msg_error_ |
String with the last error message. | |
Private Attributes | |
ColVector | x_ |
solution of the system | |
ColVector | r_ |
residuals of the system | |
Type | eps_ |
tolerance | |
int | iter_ |
number of iterations | |
int | nbStart_ |
number of restart_ | |
MultFunctor const * | p_mult_ |
pointer on the functor performing Ax | |
InitFunctor const * | p_init_ |
pointer on the functor initializing x | |
ColVector const * | p_b_ |
constant pointer on the second member of the system | |
The conjugate gradient method is an algorithm for the numerical solution of particular systems of linear equations, namely those whose matrix is symmetric and positive-definite.
The conjugate gradient method is an iterative method, so it can be applied to sparse systems that are too large to be handled by direct methods such as the Cholesky decomposition.
The algorithm is detailed below for solving
The result is
MultFunctor | A functor computing the result of Ax. |
InitFunctor | A functor computing the initial value x. |
ColVector | The type of the containers for the vectors. |
typedef ColVector::Type STK::CG< MultFunctor, ColVector, InitFunctor >::Type |
|
inline |
Default Constructor.
Definition at line 91 of file STK_CG.h.
Referenced by STK::CG< MultFunctor, ColVector, InitFunctor >::clone().
|
inline |
Constructor.
mult | functor which compute Ax with A a matrix and x a vector |
b | from Ax=b |
p_init | functor which initialize x |
eps | tolerance |
Definition at line 98 of file STK_CG.h.
|
inline |
Copy constructor.
The constructor to copy.
cg | the conjugate gradient to copy |
|
inline |
|
inlineprotected |
Definition at line 156 of file STK_CG.h.
References STK::CG< MultFunctor, ColVector, InitFunctor >::eps_, STK::CG< MultFunctor, ColVector, InitFunctor >::iter_, STK::CG< MultFunctor, ColVector, InitFunctor >::nbStart(), STK::CG< MultFunctor, ColVector, InitFunctor >::p_b_, STK::CG< MultFunctor, ColVector, InitFunctor >::p_init_, STK::CG< MultFunctor, ColVector, InitFunctor >::p_mult_, STK::CG< MultFunctor, ColVector, InitFunctor >::r_, and STK::CG< MultFunctor, ColVector, InitFunctor >::x_.
Referenced by STK::CG< MultFunctor, ColVector, InitFunctor >::run().
|
inline |
clone pattern
Definition at line 123 of file STK_CG.h.
References STK::CG< MultFunctor, ColVector, InitFunctor >::CG().
|
inline |
get the last error message.
Definition at line 150 of file STK_CG.h.
References STK::CG< MultFunctor, ColVector, InitFunctor >::msg_error_.
|
inline |
Definition at line 130 of file STK_CG.h.
References STK::CG< MultFunctor, ColVector, InitFunctor >::iter_.
|
inline |
Definition at line 132 of file STK_CG.h.
References STK::CG< MultFunctor, ColVector, InitFunctor >::nbStart_.
Referenced by STK::CG< MultFunctor, ColVector, InitFunctor >::cg().
|
inline |
Definition at line 134 of file STK_CG.h.
References STK::CG< MultFunctor, ColVector, InitFunctor >::r_.
|
inline |
Definition at line 146 of file STK_CG.h.
References STK::CG< MultFunctor, ColVector, InitFunctor >::cg().
|
inline |
Set the constant vector.
Definition at line 138 of file STK_CG.h.
References STK::CG< MultFunctor, ColVector, InitFunctor >::p_b_.
|
inline |
Set the tolerance.
Definition at line 136 of file STK_CG.h.
References STK::CG< MultFunctor, ColVector, InitFunctor >::eps_.
|
inline |
Set functor computing x at initialization.
Definition at line 142 of file STK_CG.h.
References STK::CG< MultFunctor, ColVector, InitFunctor >::p_init_.
|
inline |
Set functor computing Ax.
Definition at line 140 of file STK_CG.h.
References STK::mult(), and STK::CG< MultFunctor, ColVector, InitFunctor >::p_mult_.
|
inline |
Definition at line 126 of file STK_CG.h.
References STK::CG< MultFunctor, ColVector, InitFunctor >::x_.
|
inline |
Definition at line 128 of file STK_CG.h.
References STK::CG< MultFunctor, ColVector, InitFunctor >::x_.
|
private |
tolerance
Definition at line 209 of file STK_CG.h.
Referenced by STK::CG< MultFunctor, ColVector, InitFunctor >::cg(), and STK::CG< MultFunctor, ColVector, InitFunctor >::setEps().
|
private |
number of iterations
Definition at line 211 of file STK_CG.h.
Referenced by STK::CG< MultFunctor, ColVector, InitFunctor >::cg(), and STK::CG< MultFunctor, ColVector, InitFunctor >::iter().
|
protected |
String with the last error message.
Definition at line 154 of file STK_CG.h.
Referenced by STK::CG< MultFunctor, ColVector, InitFunctor >::error().
|
private |
number of restart_
Definition at line 213 of file STK_CG.h.
Referenced by STK::CG< MultFunctor, ColVector, InitFunctor >::nbStart().
|
private |
constant pointer on the second member of the system
Definition at line 219 of file STK_CG.h.
Referenced by STK::CG< MultFunctor, ColVector, InitFunctor >::cg(), and STK::CG< MultFunctor, ColVector, InitFunctor >::setB().
|
private |
pointer on the functor initializing x
Definition at line 217 of file STK_CG.h.
Referenced by STK::CG< MultFunctor, ColVector, InitFunctor >::cg(), and STK::CG< MultFunctor, ColVector, InitFunctor >::setInitFunctor().
|
private |
pointer on the functor performing Ax
Definition at line 215 of file STK_CG.h.
Referenced by STK::CG< MultFunctor, ColVector, InitFunctor >::cg(), and STK::CG< MultFunctor, ColVector, InitFunctor >::setMultFunctor().
|
private |
residuals of the system
Definition at line 207 of file STK_CG.h.
Referenced by STK::CG< MultFunctor, ColVector, InitFunctor >::cg(), and STK::CG< MultFunctor, ColVector, InitFunctor >::r().
|
private |
solution of the system
Definition at line 205 of file STK_CG.h.
Referenced by STK::CG< MultFunctor, ColVector, InitFunctor >::cg(), STK::CG< MultFunctor, ColVector, InitFunctor >::x(), and STK::CG< MultFunctor, ColVector, InitFunctor >::x().