GaussianBayesNet.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 
26 #include <gtsam/global_includes.h>
27 
28 #include <utility>
29 namespace gtsam {
30 
35  class GTSAM_EXPORT GaussianBayesNet: public BayesNet<GaussianConditional>
36  {
37  public:
38 
42  typedef std::shared_ptr<This> shared_ptr;
43  typedef std::shared_ptr<ConditionalType> sharedConditional;
44 
47 
50 
52  template <typename ITERATOR>
53  GaussianBayesNet(ITERATOR firstConditional, ITERATOR lastConditional)
54  : Base(firstConditional, lastConditional) {}
55 
57  template <class CONTAINER>
58  explicit GaussianBayesNet(const CONTAINER& conditionals) {
59  push_back(conditionals);
60  }
61 
64  template <class DERIVEDCONDITIONAL>
66  : Base(graph) {}
67 
72  template <class DERIVEDCONDITIONAL>
74  std::initializer_list<std::shared_ptr<DERIVEDCONDITIONAL> > conditionals)
75  : Base(conditionals) {}
76 
78 
81 
83  bool equals(const This& bn, double tol = 1e-9) const;
84 
86  friend bool operator==(const GaussianBayesNet& lhs,
87  const GaussianBayesNet& rhs) {
88  return lhs.isEqual(rhs);
89  }
90 
92  void print(
93  const std::string& s = "",
94  const KeyFormatter& formatter = DefaultKeyFormatter) const override {
96  }
97 
99 
102 
104  double error(const VectorValues& x) const;
105 
107  double logProbability(const VectorValues& x) const;
108 
114  double evaluate(const VectorValues& x) const;
115 
117  double operator()(const VectorValues& x) const {
118  return evaluate(x);
119  }
120 
123  VectorValues optimize() const;
124 
126  VectorValues optimize(const VectorValues& given) const;
127 
134  VectorValues sample(std::mt19937_64* rng) const;
135 
143  VectorValues sample(const VectorValues& given, std::mt19937_64* rng) const;
144 
146  VectorValues sample() const;
147 
149  VectorValues sample(const VectorValues& given) const;
150 
157  Ordering ordering() const;
158 
160 
163 
169  std::pair<Matrix, Vector> matrix(const Ordering& ordering) const;
170 
176  std::pair<Matrix, Vector> matrix() const;
177 
203  VectorValues optimizeGradientSearch() const;
204 
210  VectorValues gradient(const VectorValues& x0) const;
211 
218  VectorValues gradientAtZero() const;
219 
227  double determinant() const;
228 
235  double logDeterminant() const;
236 
243  double negLogConstant() const;
244 
249  VectorValues backSubstitute(const VectorValues& gx) const;
250 
257  VectorValues backSubstituteTranspose(const VectorValues& gx) const;
258 
262 
263  using Base::evaluate; // Expose evaluate(const HybridValues&) method..
264  using Base::logProbability; // Expose logProbability(const HybridValues&) method..
265  using Base::error; // Expose error(const HybridValues&) method..
266 
268 
269  private:
270 #ifdef GTSAM_ENABLE_BOOST_SERIALIZATION
271 
272  friend class boost::serialization::access;
273  template<class ARCHIVE>
274  void serialize(ARCHIVE & ar, const unsigned int /*version*/) {
275  ar & BOOST_SERIALIZATION_BASE_OBJECT_NVP(Base);
276  }
277 #endif
278  };
279 
281  template<>
282  struct traits<GaussianBayesNet> : public Testable<GaussianBayesNet> {
283  };
284 
285 } //\ namespace gtsam
Eigen::internal::print
EIGEN_STRONG_INLINE Packet4f print(const Packet4f &a)
Definition: NEON/PacketMath.h:3115
rng
static std::mt19937 rng
Definition: timeFactorOverhead.cpp:31
GaussianConditional.h
Conditional Gaussian Base class.
gtsam::GaussianBayesNet::Base
BayesNet< GaussianConditional > Base
Definition: GaussianBayesNet.h:39
global_includes.h
Included from all GTSAM files.
gtsam::BayesNet
Definition: BayesNet.h:35
s
RealScalar s
Definition: level1_cplx_impl.h:126
e
Array< double, 1, 3 > e(1./3., 0.5, 2.)
gtsam::GaussianBayesNet::GaussianBayesNet
GaussianBayesNet(ITERATOR firstConditional, ITERATOR lastConditional)
Definition: GaussianBayesNet.h:53
gtsam::GaussianBayesNet::GaussianBayesNet
GaussianBayesNet(const CONTAINER &conditionals)
Definition: GaussianBayesNet.h:58
gtsam::optimize
Point3 optimize(const NonlinearFactorGraph &graph, const Values &values, Key landmarkKey)
Definition: triangulation.cpp:177
x
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
Definition: gnuplot_common_settings.hh:12
gtsam::GaussianBayesNet::sharedConditional
std::shared_ptr< ConditionalType > sharedConditional
Definition: GaussianBayesNet.h:43
gtsam::GaussianBayesNet::This
GaussianBayesNet This
Definition: GaussianBayesNet.h:40
formatter
const KeyFormatter & formatter
Definition: treeTraversal-inst.h:204
gtsam::FactorGraph::isEqual
bool isEqual(const FactorGraph &other) const
Check exact equality of the factor pointers. Useful for derived ==.
Definition: FactorGraph.h:95
gtsam::GaussianBayesNet::GaussianBayesNet
GaussianBayesNet()
Definition: GaussianBayesNet.h:49
equal_constants::conditionals
const std::vector< GaussianConditional::shared_ptr > conditionals
Definition: testHybridGaussianConditional.cpp:53
determinant
void determinant(const MatrixType &m)
Definition: determinant.cpp:14
gtsam::DefaultKeyFormatter
KeyFormatter DefaultKeyFormatter
Assign default key formatter.
Definition: Key.cpp:30
gtsam::FactorGraph
Definition: BayesTree.h:34
gtsam::VectorValues
Definition: VectorValues.h:74
gtsam::KeyFormatter
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
gtsam::GaussianBayesNet::GaussianBayesNet
GaussianBayesNet(std::initializer_list< std::shared_ptr< DERIVEDCONDITIONAL > > conditionals)
Definition: GaussianBayesNet.h:73
gtsam::internal::logDeterminant
double logDeterminant(const typename BAYESTREE::sharedClique &clique)
Definition: GaussianBayesTree-inl.h:42
gtsam::GaussianConditional
Definition: GaussianConditional.h:40
x0
static Symbol x0('x', 0)
BayesNet.h
Bayes network.
gtsam::GaussianBayesNet::ConditionalType
GaussianConditional ConditionalType
Definition: GaussianBayesNet.h:41
ordering
static enum @1096 ordering
gtsam::equals
Definition: Testable.h:112
matrix
Map< Matrix< T, Dynamic, Dynamic, ColMajor >, 0, OuterStride<> > matrix(T *data, int rows, int cols, int stride)
Definition: gtsam/3rdparty/Eigen/blas/common.h:110
gtsam::GaussianBayesNet::GaussianBayesNet
GaussianBayesNet(const FactorGraph< DERIVEDCONDITIONAL > &graph)
Definition: GaussianBayesNet.h:65
gtsam::GaussianBayesNet::operator()
double operator()(const VectorValues &x) const
Evaluate probability density, sugar.
Definition: GaussianBayesNet.h:117
gtsam
traits
Definition: SFMdata.h:40
gtsam::Testable
Definition: Testable.h:152
error
static double error
Definition: testRot3.cpp:37
gtsam::traits
Definition: Group.h:36
FactorGraph.h
Factor Graph Base Class.
This
#define This
Definition: ActiveSetSolver-inl.h:27
gtsam::tol
const G double tol
Definition: Group.h:79
gtsam::GaussianBayesNet::print
void print(const std::string &s="", const KeyFormatter &formatter=DefaultKeyFormatter) const override
print graph
Definition: GaussianBayesNet.h:92
Base
Definition: test_virtual_functions.cpp:156
graph
NonlinearFactorGraph graph
Definition: doc/Code/OdometryExample.cpp:2
gtsam::Ordering
Definition: inference/Ordering.h:33
gtsam::GaussianBayesNet::shared_ptr
std::shared_ptr< This > shared_ptr
Definition: GaussianBayesNet.h:42
gtsam::GaussianBayesNet::operator==
friend bool operator==(const GaussianBayesNet &lhs, const GaussianBayesNet &rhs)
Check exact equality.
Definition: GaussianBayesNet.h:86
gtsam::GaussianBayesNet
Definition: GaussianBayesNet.h:35


gtsam
Author(s):
autogenerated on Sat Nov 16 2024 04:02:19