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>
25 #include <gtsam/dllexport.h>
26 
27 #include <boost/shared_ptr.hpp>
28 
29 #include <map>
30 
31 namespace 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) {}
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 
69 
70  public:
71 
73 
80  SubgraphPreconditioner(const sharedFG& Ab2, const sharedBayesNet& Rc1, const sharedValues& xbar,
82 
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
void print(const Matrix &A, const string &s, ostream &stream)
Definition: Matrix.cpp:155
const sharedErrors b2bar() const
vector of errors
Scalar * y
boost::shared_ptr< const VectorValues > sharedValues
boost::shared_ptr< const GaussianBayesNet > sharedBayesNet
SubgraphPreconditionerParameters(const SubgraphBuilderParameters &p=SubgraphBuilderParameters())
Point2 operator*(double s, const Point2 &p)
multiply with scalar
Definition: Point2.h:45
static VectorValues Zero(const VectorValues &other)
else if n * info
Factor Graph Values.
SubgraphPreconditionerParameters parameters_
Eigen::VectorXd Vector
Definition: Vector.h:38
const sharedBayesNet & Rc1() const
RealScalar alpha
sharedErrors b2bar_
A2*xbar - b2.
Array< double, 1, 3 > e(1./3., 0.5, 2.)
RealScalar s
boost::shared_ptr< SubgraphPreconditionerParameters > shared_ptr
boost::shared_ptr< const GaussianFactorGraph > sharedFG
Vector operator^(const Matrix &A, const Vector &v)
Definition: Matrix.cpp:130
Some support classes for iterative solvers.
cout<< "The eigenvalues of A are:"<< endl<< ces.eigenvalues()<< endl;cout<< "The matrix of eigenvectors, V, is:"<< endl<< ces.eigenvectors()<< endl<< endl;complex< float > lambda
boost::shared_ptr< SubgraphPreconditioner > shared_ptr
traits
Definition: chartTesting.h:28
float * p
boost::shared_ptr< const Errors > sharedErrors
static double error
Definition: testRot3.cpp:39
const sharedFG & Ab2() const
set noclip points set clip one set noclip two set bar set border lt lw set xdata set ydata set zdata set x2data set y2data set boxwidth set dummy x


gtsam
Author(s):
autogenerated on Sat May 8 2021 02:44:50