gtsam  4.0.0
gtsam
GaussianConditional.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 
18 // \callgraph
19 
20 #pragma once
21 
22 #include <boost/utility.hpp>
23 
24 #include <gtsam/global_includes.h>
28 
29 namespace gtsam {
30 
36  class GTSAM_EXPORT GaussianConditional :
37  public JacobianFactor,
38  public Conditional<JacobianFactor, GaussianConditional>
39  {
40  public:
42  typedef boost::shared_ptr<This> shared_ptr;
45 
48 
50  GaussianConditional(Key key, const Vector& d, const Matrix& R,
51  const SharedDiagonal& sigmas = SharedDiagonal());
52 
54  GaussianConditional(Key key, const Vector& d, const Matrix& R,
55  Key name1, const Matrix& S, const SharedDiagonal& sigmas = SharedDiagonal());
56 
58  GaussianConditional(Key key, const Vector& d, const Matrix& R,
59  Key name1, const Matrix& S, Key name2, const Matrix& T,
60  const SharedDiagonal& sigmas = SharedDiagonal());
61 
65  template<typename TERMS>
66  GaussianConditional(const TERMS& terms,
67  size_t nrFrontals, const Vector& d,
68  const SharedDiagonal& sigmas = SharedDiagonal());
69 
74  template<typename KEYS>
76  const KEYS& keys, size_t nrFrontals, const VerticalBlockMatrix& augmentedMatrix,
77  const SharedDiagonal& sigmas = SharedDiagonal());
78 
86  template<typename ITERATOR>
87  static shared_ptr Combine(ITERATOR firstConditional, ITERATOR lastConditional);
88 
90  void print(const std::string& = "GaussianConditional",
91  const KeyFormatter& formatter = DefaultKeyFormatter) const;
92 
94  bool equals(const GaussianFactor&cg, double tol = 1e-9) const;
95 
97  constABlock get_R() const { return Ab_.range(0, nrFrontals()); }
98 
100  constABlock get_S() const { return Ab_.range(nrFrontals(), size()); }
101 
103  constABlock get_S(const_iterator variable) const { return BaseFactor::getA(variable); }
104 
106  const constBVector get_d() const { return BaseFactor::getb(); }
107 
121  VectorValues solve(const VectorValues& parents) const;
122 
123  VectorValues solveOtherRHS(const VectorValues& parents, const VectorValues& rhs) const;
124 
126  void solveTransposeInPlace(VectorValues& gy) const;
127 
130  void scaleFrontalsBySigma(VectorValues& gy) const;
131 // __declspec(deprecated) void scaleFrontalsBySigma(VectorValues& gy) const; // FIXME: depreciated flag doesn't appear to exist?
132 
133  private:
134 
136  friend class boost::serialization::access;
137  template<class Archive>
138  void serialize(Archive & ar, const unsigned int /*version*/) {
139  ar & BOOST_SERIALIZATION_BASE_OBJECT_NVP(BaseFactor);
140  ar & BOOST_SERIALIZATION_BASE_OBJECT_NVP(BaseConditional);
141  }
142  }; // GaussianConditional
143 
145 template<>
146 struct traits<GaussianConditional> : public Testable<GaussianConditional> {};
147 
148 } // \ namespace gtsam
149 
151 
void print(const Matrix &A, const string &s, ostream &stream)
print without optional string, must specify cout yourself
Definition: Matrix.cpp:140
A conditional Gaussian functions as the node in a Bayes network It has a set of parents y...
Definition: GaussianConditional.h:36
Base class for conditional densities.
Included from all GTSAM files.
Definition: VerticalBlockMatrix.h:41
An abstract virtual base class for JacobianFactor and HessianFactor.
Definition: GaussianFactor.h:38
A helper that implements the traits interface for GTSAM types.
Definition: Testable.h:150
TODO: Update comments.
Definition: Conditional.h:40
Template to create a binary predicate.
Definition: Testable.h:110
JacobianFactor BaseFactor
Typedef to our factor base class.
Definition: GaussianConditional.h:43
constABlock get_S() const
Get a view of the parent blocks.
Definition: GaussianConditional.h:100
Conditional< BaseFactor, This > BaseConditional
Typedef to our conditional base class.
Definition: GaussianConditional.h:44
boost::shared_ptr< This > shared_ptr
shared_ptr to this class
Definition: GaussianConditional.h:42
This class represents a collection of vector-valued variables associated each with a unique integer i...
Definition: VectorValues.h:90
FastVector< Key >::const_iterator const_iterator
Const iterator over keys.
Definition: Factor.h:64
A manifold defines a space in which there is a notion of a linear tangent space that can be centered ...
Definition: concepts.h:30
constABlock get_S(const_iterator variable) const
Get a view of the S matrix for the variable pointed to by the given key iterator. ...
Definition: GaussianConditional.h:103
Factor Graph Values.
constABlock get_R() const
Return a view of the upper-triangular R block of the conditional.
Definition: GaussianConditional.h:97
GaussianConditional()
default constructor needed for serialization
Definition: GaussianConditional.h:47
GaussianConditional This
Typedef to this class.
Definition: GaussianConditional.h:41
A Gaussian factor in the squared-error form.
Definition: JacobianFactor.h:87
const constBVector get_d() const
Get a view of the r.h.s.
Definition: GaussianConditional.h:106
std::uint64_t Key
Integer nonlinear key type.
Definition: types.h:57
Global functions in a separate testing namespace.
Definition: chartTesting.h:28
Conditional Gaussian Base class.
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