gtsam  3.2.1
gtsam
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Conditional-inst.h
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 #pragma once
20 
21 #include <boost/foreach.hpp>
22 #include <iostream>
23 
25 
26 namespace gtsam {
27 
28  /* ************************************************************************* */
29  template<class FACTOR, class DERIVEDFACTOR>
30  void Conditional<FACTOR,DERIVEDFACTOR>::print(const std::string& s, const KeyFormatter& formatter) const {
31  std::cout << s << " P(";
32  BOOST_FOREACH(Key key, frontals())
33  std::cout << " " << formatter(key);
34  if (nrParents() > 0)
35  std::cout << " |";
36  BOOST_FOREACH(Key parent, parents())
37  std::cout << " " << formatter(parent);
38  std::cout << ")" << std::endl;
39  }
40 
41  /* ************************************************************************* */
42  template<class FACTOR, class DERIVEDFACTOR>
43  bool Conditional<FACTOR,DERIVEDFACTOR>::equals(const This& c, double tol) const
44  {
45  return nrFrontals_ == c.nrFrontals_;
46  }
47 
48 }
TODO: Update comments.
Definition: Conditional.h:40
void print(const std::string &s="Conditional", const KeyFormatter &formatter=DefaultKeyFormatter) const
print with optional formatter
Definition: Conditional-inst.h:30
Base class for conditional densities.
bool equals(const This &c, double tol=1e-9) const
check equality
Definition: Conditional-inst.h:43
size_t Key
Integer nonlinear key type.
Definition: types.h:59
boost::function< std::string(Key)> KeyFormatter
Typedef for a function to format a key, i.e. to convert it to a string.
Definition: types.h:62
size_t nrFrontals_
The first nrFrontal variables are frontal and the rest are parents.
Definition: Conditional.h:44