DiscreteBayesNet.cpp
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 
22 
23 #include <boost/make_shared.hpp>
24 #include <boost/range/adaptor/reversed.hpp>
25 
26 namespace gtsam {
27 
28  // Instantiate base class
29  template class FactorGraph<DiscreteConditional>;
30 
31  /* ************************************************************************* */
32  bool DiscreteBayesNet::equals(const This& bn, double tol) const
33  {
34  return Base::equals(bn, tol);
35  }
36 
37  /* ************************************************************************* */
38 // void DiscreteBayesNet::add_front(const Signature& s) {
39 // push_front(boost::make_shared<DiscreteConditional>(s));
40 // }
41 
42  /* ************************************************************************* */
44  push_back(boost::make_shared<DiscreteConditional>(s));
45  }
46 
47  /* ************************************************************************* */
49  // evaluate all conditionals and multiply
50  double result = 1.0;
51  for(DiscreteConditional::shared_ptr conditional: *this)
52  result *= (*conditional)(values);
53  return result;
54  }
55 
56  /* ************************************************************************* */
58  // solve each node in turn in topological sort order (parents first)
60  for (auto conditional: boost::adaptors::reverse(*this))
61  conditional->solveInPlace(*result);
62  return result;
63  }
64 
65  /* ************************************************************************* */
67  // sample each node in turn in topological sort order (parents first)
69  for (auto conditional: boost::adaptors::reverse(*this))
70  conditional->sampleInPlace(*result);
71  return result;
72  }
73 
74 /* ************************************************************************* */
75 } // namespace
DiscreteFactor::sharedValues sample() const
bool equals(const This &bn, double tol=1e-9) const
leaf::MyValues values
void add(const Signature &s)
IsDerived< DERIVEDFACTOR > push_back(boost::shared_ptr< DERIVEDFACTOR > factor)
Add a factor directly using a shared_ptr.
Definition: FactorGraph.h:166
bool equals(const This &fg, double tol=1e-9) const
Values result
RealScalar s
boost::shared_ptr< This > shared_ptr
shared_ptr to this class
traits
Definition: chartTesting.h:28
void reverse(const MatrixType &m)
boost::shared_ptr< Values > sharedValues
DiscreteFactor::sharedValues optimize() const
const G double tol
Definition: Group.h:83
double evaluate(const DiscreteConditional::Values &values) const


gtsam
Author(s):
autogenerated on Sat May 8 2021 02:41:59