g2o
Public Member Functions | Protected Types | Protected Member Functions | Protected Attributes | List of all members
g2o::LinearSolverPCG< MatrixType > Class Template Reference

linear solver using PCG, pre-conditioner is block Jacobi More...

#include <linear_solver_pcg.h>

Inheritance diagram for g2o::LinearSolverPCG< MatrixType >:
Inheritance graph
[legend]
Collaboration diagram for g2o::LinearSolverPCG< MatrixType >:
Collaboration graph
[legend]

Public Member Functions

 LinearSolverPCG ()
 
virtual ~LinearSolverPCG ()
 
virtual bool init ()
 
bool solve (const SparseBlockMatrix< MatrixType > &A, double *x, double *b)
 
double tolerance () const
 return the tolerance for terminating PCG before convergence More...
 
void setTolerance (double tolerance)
 
int maxIterations () const
 
void setMaxIterations (int maxIter)
 
bool absoluteTolerance () const
 
void setAbsoluteTolerance (bool absoluteTolerance)
 
bool verbose () const
 
void setVerbose (bool verbose)
 
- Public Member Functions inherited from g2o::LinearSolver< MatrixType >
 LinearSolver ()
 
virtual ~LinearSolver ()
 
virtual bool solveBlocks (double **&blocks, const SparseBlockMatrix< MatrixType > &A)
 
virtual bool solvePattern (SparseBlockMatrix< MatrixXD > &spinv, const std::vector< std::pair< int, int > > &blockIndices, const SparseBlockMatrix< MatrixType > &A)
 
virtual bool writeDebug () const
 write a debug dump of the system matrix if it is not PSD in solve More...
 
virtual void setWriteDebug (bool)
 

Protected Types

typedef std::vector< MatrixType, Eigen::aligned_allocator< MatrixType > > MatrixVector
 
typedef std::vector< const MatrixType * > MatrixPtrVector
 

Protected Member Functions

void multDiag (const std::vector< int > &colBlockIndices, MatrixVector &A, const VectorXD &src, VectorXD &dest)
 
void multDiag (const std::vector< int > &colBlockIndices, MatrixPtrVector &A, const VectorXD &src, VectorXD &dest)
 
void mult (const std::vector< int > &colBlockIndices, const VectorXD &src, VectorXD &dest)
 

Protected Attributes

double _tolerance
 
double _residual
 
bool _absoluteTolerance
 
bool _verbose
 
int _maxIter
 
MatrixPtrVector _diag
 
MatrixVector _J
 
std::vector< std::pair< int, int > > _indices
 
MatrixPtrVector _sparseMat
 

Detailed Description

template<typename MatrixType>
class g2o::LinearSolverPCG< MatrixType >

linear solver using PCG, pre-conditioner is block Jacobi

Definition at line 47 of file linear_solver_pcg.h.

Member Typedef Documentation

template<typename MatrixType>
typedef std::vector< const MatrixType* > g2o::LinearSolverPCG< MatrixType >::MatrixPtrVector
protected

Definition at line 89 of file linear_solver_pcg.h.

template<typename MatrixType>
typedef std::vector< MatrixType, Eigen::aligned_allocator<MatrixType> > g2o::LinearSolverPCG< MatrixType >::MatrixVector
protected

Definition at line 88 of file linear_solver_pcg.h.

Constructor & Destructor Documentation

template<typename MatrixType>
g2o::LinearSolverPCG< MatrixType >::LinearSolverPCG ( )
inline

Definition at line 50 of file linear_solver_pcg.h.

References g2o::LinearSolverPCG< MatrixType >::_tolerance, and g2o::LinearSolverPCG< MatrixType >::_verbose.

50  :
51  LinearSolver<MatrixType>()
52  {
53  _tolerance = 1e-6;
54  _verbose = false;
55  _absoluteTolerance = true;
56  _residual = -1.0;
57  _maxIter = -1;
58  }
template<typename MatrixType>
virtual g2o::LinearSolverPCG< MatrixType >::~LinearSolverPCG ( )
inlinevirtual

Definition at line 60 of file linear_solver_pcg.h.

61  {
62  }

Member Function Documentation

template<typename MatrixType>
bool g2o::LinearSolverPCG< MatrixType >::absoluteTolerance ( ) const
inline
template<typename MatrixType>
virtual bool g2o::LinearSolverPCG< MatrixType >::init ( )
inlinevirtual

init for operating on matrices with a different non-zero pattern like before

Implements g2o::LinearSolver< MatrixType >.

Definition at line 64 of file linear_solver_pcg.h.

References g2o::LinearSolverPCG< MatrixType >::_residual.

65  {
66  _residual = -1.0;
67  _indices.clear();
68  _sparseMat.clear();
69  return true;
70  }
std::vector< std::pair< int, int > > _indices
MatrixPtrVector _sparseMat
template<typename MatrixType>
int g2o::LinearSolverPCG< MatrixType >::maxIterations ( ) const
inline

Definition at line 78 of file linear_solver_pcg.h.

References g2o::LinearSolverPCG< MatrixType >::_maxIter.

78 { return _maxIter;}
template<typename MatrixType >
void LinearSolverPCG::mult ( const std::vector< int > &  colBlockIndices,
const VectorXD src,
VectorXD dest 
)
protected

Definition at line 180 of file linear_solver_pcg.h.

template<typename MatrixType >
void LinearSolverPCG::multDiag ( const std::vector< int > &  colBlockIndices,
MatrixVector A,
const VectorXD src,
VectorXD dest 
)
protected

Definition at line 160 of file linear_solver_pcg.h.

template<typename MatrixType >
void LinearSolverPCG::multDiag ( const std::vector< int > &  colBlockIndices,
MatrixPtrVector A,
const VectorXD src,
VectorXD dest 
)
protected

Definition at line 170 of file linear_solver_pcg.h.

template<typename MatrixType>
void g2o::LinearSolverPCG< MatrixType >::setAbsoluteTolerance ( bool  absoluteTolerance)
inline
template<typename MatrixType>
void g2o::LinearSolverPCG< MatrixType >::setMaxIterations ( int  maxIter)
inline

Definition at line 79 of file linear_solver_pcg.h.

References g2o::LinearSolverPCG< MatrixType >::_maxIter.

79 { _maxIter = maxIter;}
template<typename MatrixType>
void g2o::LinearSolverPCG< MatrixType >::setTolerance ( double  tolerance)
inline

Definition at line 76 of file linear_solver_pcg.h.

References g2o::LinearSolverPCG< MatrixType >::_tolerance, and g2o::LinearSolverPCG< MatrixType >::tolerance().

double tolerance() const
return the tolerance for terminating PCG before convergence
template<typename MatrixType>
void g2o::LinearSolverPCG< MatrixType >::setVerbose ( bool  verbose)
inline
template<typename MatrixType >
bool LinearSolverPCG::solve ( const SparseBlockMatrix< MatrixType > &  A,
double *  x,
double *  b 
)
virtual

Assumes that A is the same matrix for several calls. Among other assumptions, the non-zero pattern does not change! If the matrix changes call init() before. solve system Ax = b, x and b have to allocated beforehand!!

Implements g2o::LinearSolver< MatrixType >.

Definition at line 81 of file linear_solver_pcg.h.

References g2o::LinearSolverPCG< MatrixType >::_absoluteTolerance.

81  { return _absoluteTolerance;}
83 
84  bool verbose() const { return _verbose;}
85  void setVerbose(bool verbose) { _verbose = verbose;}
86 
87  protected:
88  typedef std::vector< MatrixType, Eigen::aligned_allocator<MatrixType> > MatrixVector;
89  typedef std::vector< const MatrixType* > MatrixPtrVector;
90 
91  double _tolerance;
92  double _residual;
93  bool _absoluteTolerance;
94  bool _verbose;
95  int _maxIter;
96 
99 
100  std::vector<std::pair<int, int> > _indices;
102 
103  void multDiag(const std::vector<int>& colBlockIndices, MatrixVector& A, const VectorXD& src, VectorXD& dest);
104  void multDiag(const std::vector<int>& colBlockIndices, MatrixPtrVector& A, const VectorXD& src, VectorXD& dest);
105  void mult(const std::vector<int>& colBlockIndices, const VectorXD& src, VectorXD& dest);
106  };
107 
108 #include "linear_solver_pcg.hpp"
109 
110 }// end namespace
111 
112 #endif
113 
MatrixPtrVector _diag
void multDiag(const std::vector< int > &colBlockIndices, MatrixVector &A, const VectorXD &src, VectorXD &dest)
std::vector< MatrixType, Eigen::aligned_allocator< MatrixType > > MatrixVector
void mult(const std::vector< int > &colBlockIndices, const VectorXD &src, VectorXD &dest)
bool absoluteTolerance() const
std::vector< const MatrixType * > MatrixPtrVector
void setAbsoluteTolerance(bool absoluteTolerance)
std::vector< std::pair< int, int > > _indices
void setVerbose(bool verbose)
Eigen::Matrix< double, Eigen::Dynamic, 1, Eigen::ColMajor > VectorXD
Definition: eigen_types.h:48
MatrixPtrVector _sparseMat
template<typename MatrixType>
double g2o::LinearSolverPCG< MatrixType >::tolerance ( ) const
inline

return the tolerance for terminating PCG before convergence

Definition at line 75 of file linear_solver_pcg.h.

References g2o::LinearSolverPCG< MatrixType >::_tolerance.

Referenced by g2o::LinearSolverPCG< MatrixType >::setTolerance().

75 { return _tolerance;}
template<typename MatrixType>
bool g2o::LinearSolverPCG< MatrixType >::verbose ( ) const
inline

Member Data Documentation

template<typename MatrixType>
bool g2o::LinearSolverPCG< MatrixType >::_absoluteTolerance
protected
template<typename MatrixType>
MatrixPtrVector g2o::LinearSolverPCG< MatrixType >::_diag
protected

Definition at line 97 of file linear_solver_pcg.h.

template<typename MatrixType>
std::vector<std::pair<int, int> > g2o::LinearSolverPCG< MatrixType >::_indices
protected

Definition at line 100 of file linear_solver_pcg.h.

template<typename MatrixType>
MatrixVector g2o::LinearSolverPCG< MatrixType >::_J
protected

Definition at line 98 of file linear_solver_pcg.h.

template<typename MatrixType>
int g2o::LinearSolverPCG< MatrixType >::_maxIter
protected
template<typename MatrixType>
double g2o::LinearSolverPCG< MatrixType >::_residual
protected

Definition at line 92 of file linear_solver_pcg.h.

Referenced by g2o::LinearSolverPCG< MatrixType >::init().

template<typename MatrixType>
MatrixPtrVector g2o::LinearSolverPCG< MatrixType >::_sparseMat
protected

Definition at line 101 of file linear_solver_pcg.h.

template<typename MatrixType>
double g2o::LinearSolverPCG< MatrixType >::_tolerance
protected
template<typename MatrixType>
bool g2o::LinearSolverPCG< MatrixType >::_verbose
protected

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