gtsam 4.1.1
gtsam
SubgraphPreconditioner.h
Go to the documentation of this file.
1/* ----------------------------------------------------------------------------
2
3 * GTSAM Copyright 2010-2019, Georgia Tech Research Corporation,
4 * Atlanta, Georgia 30332-0415
5 * All Rights Reserved
6 * Authors: Frank Dellaert, et al. (see THANKS for the full author list)
7
8 * See LICENSE for the license information
9
10 * -------------------------------------------------------------------------- */
11
18#pragma once
19
21#include <gtsam/linear/Errors.h>
23#include <gtsam/linear/Preconditioner.h>
25#include <gtsam/dllexport.h>
26
27#include <boost/shared_ptr.hpp>
28
29#include <map>
30
31namespace gtsam {
32
33 // Forward declarations
34 class GaussianBayesNet;
35 class GaussianFactorGraph;
36 class VectorValues;
37
39 typedef boost::shared_ptr<SubgraphPreconditionerParameters> shared_ptr;
41 : builderParams(p) {}
42 SubgraphBuilderParameters builderParams;
43 };
44
52 class GTSAM_EXPORT SubgraphPreconditioner : public Preconditioner {
53
54 public:
55 typedef boost::shared_ptr<SubgraphPreconditioner> shared_ptr;
56 typedef boost::shared_ptr<const GaussianBayesNet> sharedBayesNet;
57 typedef boost::shared_ptr<const GaussianFactorGraph> sharedFG;
58 typedef boost::shared_ptr<const VectorValues> sharedValues;
59 typedef boost::shared_ptr<const Errors> sharedErrors;
60
61 private:
62 sharedFG Ab2_;
63 sharedBayesNet Rc1_;
64 sharedValues xbar_;
65 sharedErrors b2bar_;
66
67 KeyInfo keyInfo_;
69
70 public:
71
73
80 SubgraphPreconditioner(const sharedFG& Ab2, const sharedBayesNet& Rc1, const sharedValues& xbar,
82
83 ~SubgraphPreconditioner() override {}
84
86 void print(const std::string& s = "SubgraphPreconditioner") const;
87
89 const sharedFG& Ab2() const { return Ab2_; }
90
92 const sharedBayesNet& Rc1() const { return Rc1_; }
93
95 const sharedErrors b2bar() const { return b2bar_; }
96
102 /* x = xbar + inv(R1)*y */
103 VectorValues x(const VectorValues& y) const;
104
105 /* A zero VectorValues with the structure of xbar */
106 VectorValues zero() const {
107 assert(xbar_);
108 return VectorValues::Zero(*xbar_);
109 }
110
116 void transposeMultiplyAdd2(double alpha, Errors::const_iterator begin,
117 Errors::const_iterator end, VectorValues& y) const;
118
119 /* error, given y */
120 double error(const VectorValues& y) const;
121
123 VectorValues gradient(const VectorValues& y) const;
124
126 Errors operator*(const VectorValues& y) const;
127
129 void multiplyInPlace(const VectorValues& y, Errors& e) const;
130
132 VectorValues operator^(const Errors& e) const;
133
138 void transposeMultiplyAdd(double alpha, const Errors& e, VectorValues& y) const;
139
140 /*****************************************************************************/
141 /* implement virtual functions of Preconditioner */
142
144 void solve(const Vector& y, Vector &x) const override;
145
147 void transposeSolve(const Vector& y, Vector& x) const override;
148
150 void build(
151 const GaussianFactorGraph &gfg,
152 const KeyInfo &info,
153 const std::map<Key,Vector> &lambda
154 ) override;
155 /*****************************************************************************/
156 };
157
158} // namespace gtsam
vector of errors
Some support classes for iterative solvers.
Factor Graph Values.
Global functions in a separate testing namespace.
Definition: chartTesting.h:28
Vector operator^(const Matrix &A, const Vector &v)
overload ^ for trans(A)*v We transpose the vectors for speed.
Definition: Matrix.cpp:130
void print(const Matrix &A, const string &s, ostream &stream)
print without optional string, must specify cout yourself
Definition: Matrix.cpp:155
Point2 operator*(double s, const Point2 &p)
multiply with scalar
Definition: Point2.h:47
Handy data structure for iterative solvers.
Definition: IterativeSolver.h:126
Definition: Preconditioner.h:24
Definition: Preconditioner.h:64
Definition: SubgraphBuilder.h:96
Definition: SubgraphPreconditioner.h:38
Subgraph conditioner class, as explained in the RSS 2010 submission.
Definition: SubgraphPreconditioner.h:52
const sharedBayesNet & Rc1() const
Access Rc1.
Definition: SubgraphPreconditioner.h:92
const sharedErrors b2bar() const
Access b2bar.
Definition: SubgraphPreconditioner.h:95
const sharedFG & Ab2() const
Access Ab2.
Definition: SubgraphPreconditioner.h:89
This class represents a collection of vector-valued variables associated each with a unique integer i...
Definition: VectorValues.h:74
static VectorValues Zero(const VectorValues &other)
Create a VectorValues with the same structure as other, but filled with zeros.
Definition: VectorValues.cpp:78