g2o
Toggle main menu visibility
Loading...
Searching...
No Matches
g2o
solvers
pcg
linear_solver_pcg.h
Go to the documentation of this file.
1
// g2o - General Graph Optimization
2
// Copyright (C) 2011 R. Kuemmerle, G. Grisetti, W. Burgard
3
// All rights reserved.
4
//
5
// Redistribution and use in source and binary forms, with or without
6
// modification, are permitted provided that the following conditions are
7
// met:
8
//
9
// * Redistributions of source code must retain the above copyright notice,
10
// this list of conditions and the following disclaimer.
11
// * Redistributions in binary form must reproduce the above copyright
12
// notice, this list of conditions and the following disclaimer in the
13
// documentation and/or other materials provided with the distribution.
14
//
15
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
16
// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
17
// TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
18
// PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
19
// HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
20
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
21
// TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
22
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
23
// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
24
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26
27
#ifndef G2O_LINEAR_SOLVER_PCG_H
28
#define G2O_LINEAR_SOLVER_PCG_H
29
30
#include <Eigen/Core>
31
#include <utility>
32
#include <vector>
33
34
#include "
g2o/core/batch_stats.h
"
35
#include "
g2o/core/linear_solver.h
"
36
37
namespace
g2o
{
38
42
template
<
typename
MatrixType>
43
class
LinearSolverPCG
:
public
LinearSolver
<MatrixType> {
44
public
:
45
LinearSolverPCG
() :
LinearSolver
<MatrixType>() {
46
_tolerance
=
cst
(1e-6);
47
_absoluteTolerance
=
true
;
48
_residual
= -1.0;
49
_maxIter
= -1;
50
}
51
52
virtual
~LinearSolverPCG
() {}
53
54
virtual
bool
init
() {
55
_residual
= -1.0;
56
_indices
.clear();
57
_sparseMat
.clear();
58
return
true
;
59
}
60
61
bool
solve
(
const
SparseBlockMatrix<MatrixType>
& A,
double
* x,
double
* b);
62
64
double
tolerance
()
const
{
return
_tolerance
; }
65
void
setTolerance
(
double
tolerance
) {
_tolerance
=
tolerance
; }
66
67
int
maxIterations
()
const
{
return
_maxIter
; }
68
void
setMaxIterations
(
int
maxIter) {
_maxIter
= maxIter; }
69
70
bool
absoluteTolerance
()
const
{
return
_absoluteTolerance
; }
71
void
setAbsoluteTolerance
(
bool
absoluteTolerance
) {
72
_absoluteTolerance
=
absoluteTolerance
;
73
}
74
75
protected
:
76
using
MatrixVector
= std::vector<MatrixType>;
77
using
MatrixPtrVector
= std::vector<const MatrixType*>;
78
79
double
_tolerance
;
80
double
_residual
;
81
bool
_absoluteTolerance
;
82
int
_maxIter
;
83
84
MatrixPtrVector
_diag
;
85
MatrixVector
_J
;
86
87
std::vector<std::pair<int, int> >
_indices
;
88
MatrixPtrVector
_sparseMat
;
89
90
void
multDiag
(
const
std::vector<int>& colBlockIndices,
MatrixVector
& A,
91
const
VectorX
& src,
VectorX
& dest);
92
void
multDiag
(
const
std::vector<int>& colBlockIndices,
MatrixPtrVector
& A,
93
const
VectorX
& src,
VectorX
& dest);
94
void
mult
(
const
std::vector<int>& colBlockIndices,
const
VectorX
& src,
95
VectorX
& dest);
96
};
97
98
#include "
linear_solver_pcg.hpp
"
99
100
}
// namespace g2o
101
102
#endif
batch_stats.h
g2o::LinearSolverPCG::_sparseMat
MatrixPtrVector _sparseMat
Definition
linear_solver_pcg.h:88
g2o::LinearSolverPCG::tolerance
double tolerance() const
return the tolerance for terminating PCG before convergence
Definition
linear_solver_pcg.h:64
g2o::LinearSolverPCG::mult
void mult(const std::vector< int > &colBlockIndices, const VectorX &src, VectorX &dest)
Definition
linear_solver_pcg.h:186
g2o::LinearSolverPCG::_maxIter
int _maxIter
Definition
linear_solver_pcg.h:82
g2o::LinearSolverPCG::absoluteTolerance
bool absoluteTolerance() const
Definition
linear_solver_pcg.h:70
g2o::LinearSolverPCG::_indices
std::vector< std::pair< int, int > > _indices
Definition
linear_solver_pcg.h:87
g2o::LinearSolverPCG::_residual
double _residual
Definition
linear_solver_pcg.h:80
g2o::LinearSolverPCG::MatrixVector
std::vector< MatrixType > MatrixVector
Definition
linear_solver_pcg.h:76
g2o::LinearSolverPCG::_tolerance
double _tolerance
Definition
linear_solver_pcg.h:79
g2o::LinearSolverPCG::MatrixPtrVector
std::vector< const MatrixType * > MatrixPtrVector
Definition
linear_solver_pcg.h:77
g2o::LinearSolverPCG::solve
bool solve(const SparseBlockMatrix< MatrixType > &A, double *x, double *b)
Definition
linear_solver_pcg.h:88
g2o::LinearSolverPCG::LinearSolverPCG
LinearSolverPCG()
Definition
linear_solver_pcg.h:45
g2o::LinearSolverPCG::maxIterations
int maxIterations() const
Definition
linear_solver_pcg.h:67
g2o::LinearSolverPCG::init
virtual bool init()
Definition
linear_solver_pcg.h:54
g2o::LinearSolverPCG::setAbsoluteTolerance
void setAbsoluteTolerance(bool absoluteTolerance)
Definition
linear_solver_pcg.h:71
g2o::LinearSolverPCG::setMaxIterations
void setMaxIterations(int maxIter)
Definition
linear_solver_pcg.h:68
g2o::LinearSolverPCG::_diag
MatrixPtrVector _diag
Definition
linear_solver_pcg.h:84
g2o::LinearSolverPCG::setTolerance
void setTolerance(double tolerance)
Definition
linear_solver_pcg.h:65
g2o::LinearSolverPCG::_absoluteTolerance
bool _absoluteTolerance
Definition
linear_solver_pcg.h:81
g2o::LinearSolverPCG::~LinearSolverPCG
virtual ~LinearSolverPCG()
Definition
linear_solver_pcg.h:52
g2o::LinearSolverPCG::_J
MatrixVector _J
Definition
linear_solver_pcg.h:85
g2o::LinearSolverPCG::multDiag
void multDiag(const std::vector< int > &colBlockIndices, MatrixVector &A, const VectorX &src, VectorX &dest)
Definition
linear_solver_pcg.h:164
g2o::LinearSolver::LinearSolver
LinearSolver()
Definition
linear_solver.h:49
g2o::SparseBlockMatrix
Sparse matrix which uses blocks.
Definition
sparse_block_matrix.h:64
linear_solver.h
linear_solver_pcg.hpp
g2o
Definition
dl_wrapper.cpp:55
g2o::VectorX
VectorN< Eigen::Dynamic > VectorX
Definition
eigen_types.h:55
g2o::cst
constexpr double cst(long double v)
Definition
misc.h:60
Generated on
for g2o by
1.17.0