SymbolicFactor.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 
20 #include <gtsam/inference/Factor.h>
21 #include <gtsam/inference/Key.h>
22 #include <gtsam/base/Testable.h>
23 
24 #include <boost/shared_ptr.hpp>
25 #include <boost/assign/list_of.hpp>
26 #include <boost/make_shared.hpp>
27 
28 #include <utility>
29 
30 namespace gtsam {
31 
32  // Forward declarations
33  class SymbolicConditional;
34  class Ordering;
35 
39  class GTSAM_EXPORT SymbolicFactor : public Factor {
40 
41  public:
42 
44  typedef Factor Base;
46 
48  typedef boost::shared_ptr<This> shared_ptr;
49 
52 
55 
57  explicit SymbolicFactor(Key j) :
58  Base(boost::assign::cref_list_of<1>(j)) {}
59 
62  Base(boost::assign::cref_list_of<2>(j1)(j2)) {}
63 
65  SymbolicFactor(Key j1, Key j2, Key j3) :
66  Base(boost::assign::cref_list_of<3>(j1)(j2)(j3)) {}
67 
69  SymbolicFactor(Key j1, Key j2, Key j3, Key j4) :
70  Base(boost::assign::cref_list_of<4>(j1)(j2)(j3)(j4)) {}
71 
73  SymbolicFactor(Key j1, Key j2, Key j3, Key j4, Key j5) :
74  Base(boost::assign::cref_list_of<5>(j1)(j2)(j3)(j4)(j5)) {}
75 
77  SymbolicFactor(Key j1, Key j2, Key j3, Key j4, Key j5, Key j6) :
78  Base(boost::assign::cref_list_of<6>(j1)(j2)(j3)(j4)(j5)(j6)) {}
79 
81  explicit SymbolicFactor(const Factor& factor) : Base(factor.keys()) {}
82 
83  virtual ~SymbolicFactor() {}
84 
86  SymbolicFactor::shared_ptr clone() const { return boost::make_shared<This>(*this); }
87 
89 
92 
93  bool equals(const This& other, double tol = 1e-9) const;
94 
96  void print(
97  const std::string& s = "SymbolicFactor",
98  const KeyFormatter& formatter = DefaultKeyFormatter) const override {
100  }
101 
103  void printKeys(
104  const std::string& s = "SymbolicFactor",
105  const KeyFormatter& formatter = DefaultKeyFormatter) const override {
106  Base::printKeys(s, formatter);
107  }
108 
110 
113  public:
115  template<typename KEYITERATOR>
116  static SymbolicFactor FromIterators(KEYITERATOR beginKey, KEYITERATOR endKey) {
117  return SymbolicFactor(Base::FromIterators(beginKey, endKey));
118  }
119 
121  template<typename KEYITERATOR>
122  static SymbolicFactor::shared_ptr FromIteratorsShared(KEYITERATOR beginKey, KEYITERATOR endKey) {
123  SymbolicFactor::shared_ptr result = boost::make_shared<SymbolicFactor>();
124  result->keys_.assign(beginKey, endKey);
125  return result;
126  }
127 
130  template<class CONTAINER>
131  static SymbolicFactor FromKeys(const CONTAINER& keys) {
132  return SymbolicFactor(Base::FromKeys(keys));
133  }
134 
137  template<class CONTAINER>
138  static SymbolicFactor::shared_ptr FromKeysShared(const CONTAINER& keys) {
139  return FromIteratorsShared(keys.begin(), keys.end());
140  }
141 
143 
146 
148  bool empty() const { return keys_.empty(); }
149 
152  std::pair<boost::shared_ptr<SymbolicConditional>, boost::shared_ptr<SymbolicFactor> >
153  eliminate(const Ordering& keys) const;
154 
156 
157  private:
159  friend class boost::serialization::access;
160  template<class ARCHIVE>
161  void serialize(ARCHIVE & ar, const unsigned int /*version*/) {
162  ar & BOOST_SERIALIZATION_BASE_OBJECT_NVP(Base);
163  }
164  }; // IndexFactor
165 
166  // Forward declarations
167  class SymbolicFactorGraph;
168  class Ordering;
169 
174  GTSAM_EXPORT std::pair<boost::shared_ptr<SymbolicConditional>, boost::shared_ptr<SymbolicFactor> >
176 
178  template<>
179  struct traits<SymbolicFactor> : public Testable<SymbolicFactor> {
180  };
181 
182 } //\ namespace gtsam
183 
void print(const Matrix &A, const string &s, ostream &stream)
Definition: Matrix.cpp:155
void printKeys(const std::string &s="SymbolicFactor", const KeyFormatter &formatter=DefaultKeyFormatter) const override
print only keys
SymbolicFactor(Key j1, Key j2, Key j3, Key j4)
Concept check for values that can be used in unit tests.
SymbolicConditional ConditionalType
static SymbolicFactor::shared_ptr FromKeysShared(const CONTAINER &keys)
GaussianFactorGraph factors(list_of(factor1)(factor2)(factor3))
SymbolicFactor(Key j1, Key j2, Key j3)
void print(const std::string &s="SymbolicFactor", const KeyFormatter &formatter=DefaultKeyFormatter) const override
print
static const KeyFormatter DefaultKeyFormatter
Definition: Key.h:43
SymbolicFactor(Key j1, Key j2)
static SymbolicFactor::shared_ptr FromIteratorsShared(KEYITERATOR beginKey, KEYITERATOR endKey)
const KeyFormatter & formatter
void serialize(ARCHIVE &ar, const unsigned int)
SymbolicFactor This
Values result
SymbolicFactor(const Factor &factor)
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
boost::shared_ptr< This > shared_ptr
Array< double, 1, 3 > e(1./3., 0.5, 2.)
RealScalar s
traits
Definition: chartTesting.h:28
SymbolicFactor(Key j1, Key j2, Key j3, Key j4, Key j5, Key j6)
static SymbolicFactor FromKeys(const CONTAINER &keys)
SymbolicFactor::shared_ptr clone() const
Copy this object as its actual derived type.
const G double tol
Definition: Group.h:83
static SymbolicFactor FromIterators(KEYITERATOR beginKey, KEYITERATOR endKey)
const KeyVector keys
std::pair< boost::shared_ptr< SymbolicConditional >, boost::shared_ptr< SymbolicFactor > > EliminateSymbolic(const SymbolicFactorGraph &factors, const Ordering &keys)
std::uint64_t Key
Integer nonlinear key type.
Definition: types.h:61
std::ptrdiff_t j
SymbolicFactor(Key j1, Key j2, Key j3, Key j4, Key j5)
The base class for all factors.


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