CCCoreLib 31 May 2022
CloudCompare Core algorithms
Public Member Functions | Protected Attributes | List of all members
CCCoreLib::ConjugateGradient< N, Scalar > Class Template Reference

A class to perform a conjugate gradient optimization. More...

#include <ConjugateGradient.h>

Inheritance diagram for CCCoreLib::ConjugateGradient< N, Scalar >:
Inheritance graph
[legend]
Collaboration diagram for CCCoreLib::ConjugateGradient< N, Scalar >:
Collaboration graph
[legend]

Public Member Functions

 ConjugateGradient ()
 Default constructor.
 
virtual ~ConjugateGradient ()=default
 Default destructor.
 
SquareMatrixTpl< Scalar > & A ()
 Returns A matrix.
 
Scalar * b ()
 Returns b vector.
 
void initConjugateGradient (const Scalar *X0)
 Initializes the conjugate gradient. More...
 
Scalar iterConjugateGradient (Scalar *Xn)
 Iterates the conjugate gradient. More...
 

Protected Attributes

Scalar cg_Gn [N]
 Residuals vector.
 
Scalar cg_Hn [N]
 'Hn' vector More...
 
Scalar cg_u [N]
 'u' vector More...
 
Scalar cg_b [N]
 'b' vector More...
 
SquareMatrixTpl< Scalar > cg_A
 'A' matrix More...
 

Detailed Description

template<int N, class Scalar>
class CCCoreLib::ConjugateGradient< N, Scalar >

A class to perform a conjugate gradient optimization.

Inspired from the "Numerical Recipes". Template parameter 'N' is the dimension of the linear system. Lets "A*Xn=b" be the system to optimize (at iteration n). First the user must init the A matrix (N*N) and b vector (N*1). Then the solver is initialized with X0 (see initConjugateGradient). And the conjugate gradient is iterated with iterConjugateGradient.

Member Function Documentation

◆ initConjugateGradient()

template<int N, class Scalar >
void CCCoreLib::ConjugateGradient< N, Scalar >::initConjugateGradient ( const Scalar *  X0)
inline

Initializes the conjugate gradient.

Parameters
X0the initial state (size N)

◆ iterConjugateGradient()

template<int N, class Scalar >
Scalar CCCoreLib::ConjugateGradient< N, Scalar >::iterConjugateGradient ( Scalar *  Xn)
inline

Iterates the conjugate gradient.

Xn will be automatically updated to Xn+1 on output.

Parameters
Xnthe current estimation of Xn (size N)
Returns
mean square error

Member Data Documentation

◆ cg_A

template<int N, class Scalar >
SquareMatrixTpl<Scalar> CCCoreLib::ConjugateGradient< N, Scalar >::cg_A
protected

'A' matrix

Equation solved: "A.X=b"

◆ cg_b

template<int N, class Scalar >
Scalar CCCoreLib::ConjugateGradient< N, Scalar >::cg_b[N]
protected

'b' vector

Equation solved: "A.X=b"

◆ cg_Hn

template<int N, class Scalar >
Scalar CCCoreLib::ConjugateGradient< N, Scalar >::cg_Hn[N]
protected

'Hn' vector

Intermediary computation result

◆ cg_u

template<int N, class Scalar >
Scalar CCCoreLib::ConjugateGradient< N, Scalar >::cg_u[N]
protected

'u' vector

Intermediary computation result


The documentation for this class was generated from the following file: