SymbolicConditional.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 #pragma once
19 
22 #include <gtsam/base/Testable.h>
23 #include <gtsam/base/types.h>
24 
25 namespace gtsam {
26 
36  class GTSAM_EXPORT SymbolicConditional :
37  public SymbolicFactor,
38  public Conditional<SymbolicFactor, SymbolicConditional> {
39 
40  public:
44  typedef boost::shared_ptr<This> shared_ptr;
47 
50 
53 
55  SymbolicConditional(Key j) : BaseFactor(j), BaseConditional(1) {}
56 
58  SymbolicConditional(Key j, Key parent) : BaseFactor(j, parent), BaseConditional(1) {}
59 
61  SymbolicConditional(Key j, Key parent1, Key parent2) : BaseFactor(j, parent1, parent2), BaseConditional(1) {}
62 
64  SymbolicConditional(Key j, Key parent1, Key parent2, Key parent3) : BaseFactor(j, parent1, parent2, parent3), BaseConditional(1) {}
65 
67  template<typename ITERATOR>
68  static SymbolicConditional FromIterators(ITERATOR firstKey, ITERATOR lastKey, size_t nrFrontals)
69  {
71  (BaseFactor&)result = BaseFactor::FromIterators(firstKey, lastKey);
72  result.nrFrontals_ = nrFrontals;
73  return result;
74  }
75 
77  template<typename ITERATOR>
78  static SymbolicConditional::shared_ptr FromIteratorsShared(ITERATOR firstKey, ITERATOR lastKey, size_t nrFrontals)
79  {
80  SymbolicConditional::shared_ptr result = boost::make_shared<SymbolicConditional>();
81  result->keys_.assign(firstKey, lastKey);
82  result->nrFrontals_ = nrFrontals;
83  return result;
84  }
85 
87  template<class CONTAINER>
88  static SymbolicConditional FromKeys(const CONTAINER& keys, size_t nrFrontals) {
89  return FromIterators(keys.begin(), keys.end(), nrFrontals);
90  }
91 
93  template<class CONTAINER>
94  static SymbolicConditional::shared_ptr FromKeysShared(const CONTAINER& keys, size_t nrFrontals) {
95  return FromIteratorsShared(keys.begin(), keys.end(), nrFrontals);
96  }
97 
98  ~SymbolicConditional() override {}
99 
101  SymbolicFactor::shared_ptr clone() const { return boost::make_shared<This>(*this); }
102 
104 
106 
108  void print(
109  const std::string& str = "",
110  const KeyFormatter& keyFormatter = DefaultKeyFormatter) const override;
111 
113  bool equals(const This& c, double tol = 1e-9) const;
114 
116 
117  private:
119  friend class boost::serialization::access;
120  template<class Archive>
121  void serialize(Archive & ar, const unsigned int /*version*/) {
122  ar & BOOST_SERIALIZATION_BASE_OBJECT_NVP(BaseFactor);
123  ar & BOOST_SERIALIZATION_BASE_OBJECT_NVP(BaseConditional);
124  }
125  };
126 
128 template<>
129 struct traits<SymbolicConditional> : public Testable<SymbolicConditional> {
130 };
131 
132 } //\ namespace gtsam
void print(const Matrix &A, const string &s, ostream &stream)
Definition: Matrix.cpp:155
Base class for conditional densities.
Typedefs for easier changing of types.
static SymbolicConditional::shared_ptr FromIteratorsShared(ITERATOR firstKey, ITERATOR lastKey, size_t nrFrontals)
Concept check for values that can be used in unit tests.
Scalar Scalar * c
Definition: benchVecAdd.cpp:17
SymbolicConditional(Key j, Key parent1, Key parent2, Key parent3)
static SymbolicConditional::shared_ptr FromKeysShared(const CONTAINER &keys, size_t nrFrontals)
static SymbolicConditional FromKeys(const CONTAINER &keys, size_t nrFrontals)
static const KeyFormatter DefaultKeyFormatter
Definition: Key.h:43
static SymbolicConditional FromIterators(ITERATOR firstKey, ITERATOR lastKey, size_t nrFrontals)
SymbolicFactor BaseFactor
Typedef to this class.
boost::shared_ptr< This > shared_ptr
Typedef to the conditional base class.
SymbolicConditional(Key j, Key parent)
Values result
SymbolicConditional(Key j, Key parent1, Key parent2)
Definition: pytypes.h:928
Conditional< BaseFactor, This > BaseConditional
Typedef to the factor base class.
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
BaseFactor::const_iterator const_iterator
iterator to keys
KeyVector::iterator iterator
Iterator over keys.
Definition: Factor.h:64
BaseFactor::iterator iterator
Boost shared_ptr to this class.
boost::shared_ptr< This > shared_ptr
Array< double, 1, 3 > e(1./3., 0.5, 2.)
SymbolicFactor::shared_ptr clone() const
Copy this object as its actual derived type.
traits
Definition: chartTesting.h:28
void serialize(Archive &ar, const unsigned int)
const G double tol
Definition: Group.h:83
KeyVector::const_iterator const_iterator
Const iterator over keys.
Definition: Factor.h:67
const KeyVector keys
std::uint64_t Key
Integer nonlinear key type.
Definition: types.h:61
std::ptrdiff_t j


gtsam
Author(s):
autogenerated on Sat May 8 2021 02:45:07