gtsam 4.2.0
gtsam
Loading...
Searching...
No Matches
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
24#include <gtsam/base/Matrix.h>
25#include <gtsam/base/Testable.h>
26
27namespace 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:
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
59 void print(
60 const std::string& s = "",
61 const KeyFormatter& formatter = DefaultKeyFormatter) const override = 0;
62
64 virtual bool equals(const GaussianFactor& lf, double tol = 1e-9) const = 0;
65
73 virtual double error(const VectorValues& c) const;
74
79 double error(const HybridValues& c) const override;
80
82 virtual DenseIndex getDim(const_iterator variable) const = 0;
83
91 virtual Matrix augmentedJacobian() const = 0;
92
100 virtual std::pair<Matrix,Vector> jacobian() const = 0;
101
110 virtual Matrix augmentedInformation() const = 0;
111
115 virtual Matrix information() const = 0;
116
118 VectorValues hessianDiagonal() const;
119
121 virtual void hessianDiagonalAdd(VectorValues& d) const = 0;
122
124 virtual void hessianDiagonal(double* d) const = 0;
125
127 virtual std::map<Key,Matrix> hessianBlockDiagonal() const = 0;
128
131
138
144 virtual void updateHessian(const KeyVector& keys,
145 SymmetricBlockMatrix* info) const = 0;
146
148 virtual void multiplyHessianAdd(double alpha, const VectorValues& x, VectorValues& y) const = 0;
149
151 virtual VectorValues gradientAtZero() const = 0;
152
154 virtual void gradientAtZero(double* d) const = 0;
155
157 virtual Vector gradient(Key key, const VectorValues& x) const = 0;
158
159 // Determine position of a given key
160 template <typename CONTAINER>
161 static DenseIndex Slot(const CONTAINER& keys, Key key) {
162 return std::find(keys.begin(), keys.end(), key) - keys.begin();
163 }
164
165 private:
167 friend class boost::serialization::access;
168 template<class ARCHIVE>
169 void serialize(ARCHIVE & ar, const unsigned int /*version*/) {
170 ar & BOOST_SERIALIZATION_BASE_OBJECT_NVP(Base);
171 }
172
173 }; // GaussianFactor
174
176template<>
177struct traits<GaussianFactor> : public Testable<GaussianFactor> {
178};
179
180} // \ namespace gtsam
Concept check for values that can be used in unit tests.
typedef and functions to augment Eigen's MatrixXd
The base class for all factors.
Global functions in a separate testing namespace.
Definition chartTesting.h:28
FastVector< Key > KeyVector
Define collection type once and for all - also used in wrappers.
Definition Key.h:86
ptrdiff_t DenseIndex
The index type for Eigen objects.
Definition types.h:106
std::uint64_t Key
Integer nonlinear key type.
Definition types.h:100
std::function< std::string(Key)> KeyFormatter
Typedef for a function to format a key, i.e. to convert it to a string.
Definition Key.h:35
A manifold defines a space in which there is a notion of a linear tangent space that can be centered ...
Definition concepts.h:30
This class stores a dense matrix and allows it to be accessed as a collection of blocks.
Definition SymmetricBlockMatrix.h:52
A helper that implements the traits interface for GTSAM types.
Definition Testable.h:151
HybridValues represents a collection of DiscreteValues and VectorValues.
Definition HybridValues.h:38
Definition Factor.h:68
KeyVector::const_iterator const_iterator
Const iterator over keys.
Definition Factor.h:80
An abstract virtual base class for JacobianFactor and HessianFactor.
Definition GaussianFactor.h:39
virtual DenseIndex getDim(const_iterator variable) const =0
Return the dimension of the variable pointed to by the given key iterator.
virtual std::map< Key, Matrix > hessianBlockDiagonal() const =0
Return the block diagonal of the Hessian for this factor.
boost::shared_ptr< This > shared_ptr
shared_ptr to this class
Definition GaussianFactor.h:42
virtual std::pair< Matrix, Vector > jacobian() const =0
Return the dense Jacobian and right-hand-side , with the noise models baked into A and b.
virtual Vector gradient(Key key, const VectorValues &x) const =0
Gradient wrt a key at any values.
virtual GaussianFactor::shared_ptr clone() const =0
Clone a factor (make a deep copy)
virtual Matrix information() const =0
Return the non-augmented information matrix represented by this GaussianFactor.
Factor Base
Our base class.
Definition GaussianFactor.h:43
virtual ~GaussianFactor()
Destructor.
Definition GaussianFactor.h:54
virtual VectorValues gradientAtZero() const =0
A'*b for Jacobian, eta for Hessian.
GaussianFactor(const CONTAINER &keys)
Construct from container of keys.
Definition GaussianFactor.h:51
virtual void multiplyHessianAdd(double alpha, const VectorValues &x, VectorValues &y) const =0
y += alpha * A'*A*x
virtual bool equals(const GaussianFactor &lf, double tol=1e-9) const =0
Equals for testable.
virtual Matrix augmentedInformation() const =0
Return the augmented information matrix represented by this GaussianFactor.
virtual Matrix augmentedJacobian() const =0
Return a dense Jacobian matrix, augmented with b with the noise models baked into A and b.
GaussianFactor()
Default constructor creates empty factor.
Definition GaussianFactor.h:46
virtual GaussianFactor::shared_ptr negate() const =0
Construct the corresponding anti-factor to negate information stored stored in this factor.
virtual void hessianDiagonal(double *d) const =0
Raw memory access version of hessianDiagonal.
GaussianFactor This
This class.
Definition GaussianFactor.h:41
virtual void updateHessian(const KeyVector &keys, SymmetricBlockMatrix *info) const =0
Update an information matrix by adding the information corresponding to this factor (used internally ...
void print(const std::string &s="", const KeyFormatter &formatter=DefaultKeyFormatter) const override=0
print
virtual void hessianDiagonalAdd(VectorValues &d) const =0
Add the current diagonal to a VectorValues instance.
virtual void gradientAtZero(double *d) const =0
Raw memory access version of gradientAtZero.
VectorValues represents a collection of vector-valued variables associated each with a unique integer...
Definition VectorValues.h:74
The Factor::error simply extracts the.