Public Member Functions | Protected Member Functions | Protected Attributes | List of all members

Implements a conjugate gradient method as sparse linear algebra solver. More...

#include <conjugate_gradient_method.hpp>

Inheritance diagram for ConjugateGradientMethod:
Inheritance graph
[legend]

Public Member Functions

virtual SparseSolverclone () 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 SparseSolveroperator= (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
 

Detailed Description

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.

Author
Boris Houska, Hans Joachim Ferreau

Definition at line 57 of file conjugate_gradient_method.hpp.

Constructor & Destructor Documentation

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.

ConjugateGradientMethod::~ConjugateGradientMethod ( )
virtual

Destructor.

Definition at line 126 of file conjugate_gradient_method.cpp.

Member Function Documentation

virtual returnValue ConjugateGradientMethod::applyInversePreconditioner ( double *  x_)
protectedpure virtual

Applies the inverse of the preconditioner to the vector x (only internal use)

Implemented in SymmetricConjugateGradientMethod, and NormalConjugateGradientMethod.

virtual returnValue ConjugateGradientMethod::applyPreconditioner ( double *  b)
protectedpure virtual

Applies the preconditioner to the vector b (only internal use)

Implemented in SymmetricConjugateGradientMethod, and NormalConjugateGradientMethod.

virtual SparseSolver* ConjugateGradientMethod::clone ( ) const
pure virtual

Clone operator (deep copy).

Implements SparseSolver.

Implemented in SymmetricConjugateGradientMethod, and NormalConjugateGradientMethod.

virtual returnValue ConjugateGradientMethod::computePreconditioner ( double *  A_)
protectedpure virtual

Computes the preconditioner and Applies it to the input matrix.

Implemented in SymmetricConjugateGradientMethod, and NormalConjugateGradientMethod.

returnValue ConjugateGradientMethod::getX ( double *  x_)
virtual

Returns the solution of the equation A*x = b if solved.

Returns
SUCCESSFUL_RETURN

Implements SparseSolver.

Definition at line 329 of file conjugate_gradient_method.cpp.

virtual void ConjugateGradientMethod::multiply ( double *  xx,
double *  result 
)
protectedpure virtual

Evaluates the matrix-vector product result = A*xx efficiently. (only internal use)

Implemented in SymmetricConjugateGradientMethod, and NormalConjugateGradientMethod.

double ConjugateGradientMethod::scalarProduct ( double *  aa,
double *  bb 
)
protected

Returns the scalar product of aa and bb. (only internal use)

Definition at line 355 of file conjugate_gradient_method.cpp.

returnValue ConjugateGradientMethod::setDimension ( const int &  n)
virtual

Defines the dimension n of A R^{n n}

Returns
SUCCESSFUL_RETURN

Implements SparseSolver.

Definition at line 252 of file conjugate_gradient_method.cpp.

virtual returnValue ConjugateGradientMethod::setIndices ( const int *  rowIdx_,
const int *  colIdx_ 
)
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.

returnValue ConjugateGradientMethod::setMatrix ( double *  A_)
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.

returnValue ConjugateGradientMethod::setNumberOfEntries ( const int &  nDense_)
virtual

Defines the number of non-zero elements in the
matrix A

Returns
SUCCESSFUL_RETURN

Implements SparseSolver.

Definition at line 300 of file conjugate_gradient_method.cpp.

returnValue ConjugateGradientMethod::setPrintLevel ( PrintLevel  printLevel_)
virtual

Sets the print level.

Returns
SUCCESSFUL_RETURN

Implements SparseSolver.

Definition at line 342 of file conjugate_gradient_method.cpp.

returnValue ConjugateGradientMethod::setTolerance ( double  TOL_)
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.

Returns
SUCCESSFUL_RETURN

Implements SparseSolver.

Definition at line 335 of file conjugate_gradient_method.cpp.

returnValue ConjugateGradientMethod::solve ( double *  b)
virtual

Solves the system A*x = b for the specified data.

Returns
SUCCESSFUL_RETURN
RET_LINEAR_SYSTEM_NUMERICALLY_SINGULAR

Implements SparseSolver.

Definition at line 149 of file conjugate_gradient_method.cpp.

Member Data Documentation

double* ConjugateGradientMethod::A
protected

Definition at line 183 of file conjugate_gradient_method.hpp.

double* ConjugateGradientMethod::condScale
protected

Definition at line 193 of file conjugate_gradient_method.hpp.

int ConjugateGradientMethod::dim
protected

Definition at line 178 of file conjugate_gradient_method.hpp.

int ConjugateGradientMethod::nDense
protected

Definition at line 179 of file conjugate_gradient_method.hpp.

double* ConjugateGradientMethod::norm2
protected

Definition at line 189 of file conjugate_gradient_method.hpp.

double** ConjugateGradientMethod::p
protected

Definition at line 190 of file conjugate_gradient_method.hpp.

int ConjugateGradientMethod::pCounter
protected

Definition at line 192 of file conjugate_gradient_method.hpp.

PrintLevel ConjugateGradientMethod::printLevel
protected

Definition at line 197 of file conjugate_gradient_method.hpp.

double* ConjugateGradientMethod::r
protected

Definition at line 191 of file conjugate_gradient_method.hpp.

double ConjugateGradientMethod::TOL
protected

Definition at line 196 of file conjugate_gradient_method.hpp.

double* ConjugateGradientMethod::x
protected

Definition at line 184 of file conjugate_gradient_method.hpp.


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


acado
Author(s): Milan Vukov, Rien Quirynen
autogenerated on Mon Jun 10 2019 12:35:22