gtsam  4.0.0
gtsam
GaussianFactor.h
Go to the documentation of this file.
1 /* ----------------------------------------------------------------------------
2 
3  * GTSAM Copyright 2010, 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 
19 // \callgraph
20 
21 #pragma once
22 
23 #include <gtsam/inference/Factor.h>
24 #include <gtsam/base/Matrix.h>
25 #include <gtsam/base/Testable.h>
26 
27 namespace gtsam {
28 
29  // Forward declarations
30  class VectorValues;
31  class Scatter;
32  class SymmetricBlockMatrix;
33 
38  class GTSAM_EXPORT GaussianFactor : public Factor
39  {
40  public:
41  typedef GaussianFactor This;
42  typedef boost::shared_ptr<This> shared_ptr;
43  typedef Factor Base;
44 
47 
50  template<typename CONTAINER>
51  GaussianFactor(const CONTAINER& keys) : Base(keys) {}
52 
54  virtual ~GaussianFactor() {}
55 
56  // Implementing Testable interface
57  virtual void print(const std::string& s = "",
58  const KeyFormatter& formatter = DefaultKeyFormatter) const = 0;
59 
61  virtual bool equals(const GaussianFactor& lf, double tol = 1e-9) const = 0;
62 
64  virtual double error(const VectorValues& c) const = 0;
67  virtual DenseIndex getDim(const_iterator variable) const = 0;
68 
76  virtual Matrix augmentedJacobian() const = 0;
77 
85  virtual std::pair<Matrix,Vector> jacobian() const = 0;
86 
95  virtual Matrix augmentedInformation() const = 0;
96 
100  virtual Matrix information() const = 0;
101 
103  virtual VectorValues hessianDiagonal() const = 0;
104 
106  virtual void hessianDiagonal(double* d) const = 0;
107 
109  virtual std::map<Key,Matrix> hessianBlockDiagonal() const = 0;
110 
112  virtual GaussianFactor::shared_ptr clone() const = 0;
113 
115  virtual bool empty() const = 0;
116 
122  virtual GaussianFactor::shared_ptr negate() const = 0;
123 
129  virtual void updateHessian(const KeyVector& keys,
130  SymmetricBlockMatrix* info) const = 0;
131 
133  virtual void multiplyHessianAdd(double alpha, const VectorValues& x, VectorValues& y) const = 0;
134 
136  virtual VectorValues gradientAtZero() const = 0;
137 
139  virtual void gradientAtZero(double* d) const = 0;
140 
142  virtual Vector gradient(Key key, const VectorValues& x) const = 0;
143 
144  // Determine position of a given key
145  template <typename CONTAINER>
146  static DenseIndex Slot(const CONTAINER& keys, Key key) {
147  return std::find(keys.begin(), keys.end(), key) - keys.begin();
148  }
149 
150  private:
152  friend class boost::serialization::access;
153  template<class ARCHIVE>
154  void serialize(ARCHIVE & ar, const unsigned int /*version*/) {
155  ar & BOOST_SERIALIZATION_BASE_OBJECT_NVP(Base);
156  }
157 
158  }; // GaussianFactor
159 
161 template<>
162 struct traits<GaussianFactor> : public Testable<GaussianFactor> {
163 };
164 
165 } // \ namespace gtsam
GaussianFactor(const CONTAINER &keys)
Construct from container of keys.
Definition: GaussianFactor.h:51
This is the base class for all factor types.
Definition: Factor.h:54
ptrdiff_t DenseIndex
The index type for Eigen objects.
Definition: types.h:63
void print(const Matrix &A, const string &s, ostream &stream)
print without optional string, must specify cout yourself
Definition: Matrix.cpp:141
std::uint64_t Key
Integer nonlinear key type.
Definition: types.h:57
Template to create a binary predicate.
Definition: Testable.h:110
A helper that implements the traits interface for GTSAM types.
Definition: Testable.h:150
An abstract virtual base class for JacobianFactor and HessianFactor.
Definition: GaussianFactor.h:38
virtual ~GaussianFactor()
Destructor.
Definition: GaussianFactor.h:54
boost::function< std::string(Key)> KeyFormatter
Typedef for a function to format a key, i.e. to convert it to a string.
Definition: Key.h:33
This class represents a collection of vector-valued variables associated each with a unique integer i...
Definition: VectorValues.h:73
FastVector< Key > KeyVector
Define collection type once and for all - also used in wrappers.
Definition: Key.h:56
A manifold defines a space in which there is a notion of a linear tangent space that can be centered ...
Definition: concepts.h:30
The base class for all factors.
Definition: SymmetricBlockMatrix.h:51
Global functions in a separate testing namespace.
Definition: chartTesting.h:28
Concept check for values that can be used in unit tests.
iterator begin()
Iterator over variables.
Definition: VectorValues.h:214
typedef and functions to augment Eigen's MatrixXd
GaussianFactor This
This class.
Definition: GaussianFactor.h:41
Factor Base
Our base class.
Definition: GaussianFactor.h:43
GaussianFactor()
Default constructor creates empty factor.
Definition: GaussianFactor.h:46
boost::shared_ptr< This > shared_ptr
shared_ptr to this class
Definition: GaussianFactor.h:42