24#include <boost/serialization/nvp.hpp>
25#include <boost/shared_ptr.hpp>
61 typedef boost::shared_ptr<Factor> shared_ptr;
83 template<
typename CONTAINER>
84 explicit Factor(
const CONTAINER& keys) : keys_(keys.begin(), keys.end()) {}
88 template<
typename ITERATOR>
89 Factor(ITERATOR first, ITERATOR last) : keys_(first, last) {}
93 template<
typename CONTAINER>
95 return Factor(keys.begin(), keys.end()); }
99 template<
typename ITERATOR>
101 return Factor(first, last); }
136 size_t size()
const {
return keys_.size(); }
145 const std::string& s =
"Factor",
146 const KeyFormatter& formatter = DefaultKeyFormatter)
const;
149 virtual void printKeys(
150 const std::string& s =
"Factor",
151 const KeyFormatter& formatter = DefaultKeyFormatter)
const;
155 bool equals(
const This& other,
double tol = 1e-9)
const;
174 friend class boost::serialization::access;
175 template<
class Archive>
176 void serialize(Archive & ar,
const unsigned int ) {
177 ar & BOOST_SERIALIZATION_NVP(keys_);
A thin wrapper around std::vector that uses a custom allocator.
Typedefs for easier changing of types.
Global functions in a separate testing namespace.
Definition: chartTesting.h:28
FastVector< Key > KeyVector
Define collection type once and for all - also used in wrappers.
Definition: Key.h:86
std::string serialize(const T &input)
serializes to a string
Definition: serialization.h:112
void print(const Matrix &A, const string &s, ostream &stream)
print without optional string, must specify cout yourself
Definition: Matrix.cpp:155
FastVector< FactorIndex > FactorIndices
Define collection types:
Definition: Factor.h:33
std::uint64_t Key
Integer nonlinear key type.
Definition: types.h:69
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
Template to create a binary predicate.
Definition: Testable.h:111
This is the base class for all factor types.
Definition: Factor.h:56
const KeyVector & keys() const
Access the factor's involved variable keys.
Definition: Factor.h:125
KeyVector keys_
The keys involved in this factor.
Definition: Factor.h:73
const_iterator find(Key key) const
find
Definition: Factor.h:122
const_iterator begin() const
Iterator at beginning of involved variable keys.
Definition: Factor.h:128
Factor()
Default constructor for I/O.
Definition: Factor.h:79
iterator end()
Iterator at end of involved variable keys.
Definition: Factor.h:170
KeyVector & keys()
Definition: Factor.h:164
static Factor FromIterators(ITERATOR first, ITERATOR last)
Construct factor from iterator keys.
Definition: Factor.h:100
static Factor FromKeys(const CONTAINER &keys)
Construct factor from container of keys.
Definition: Factor.h:94
iterator begin()
Iterator at beginning of involved variable keys.
Definition: Factor.h:167
virtual ~Factor()=default
Default destructor.
Factor(ITERATOR first, ITERATOR last)
Construct factor from iterator keys.
Definition: Factor.h:89
KeyVector::const_iterator const_iterator
Const iterator over keys.
Definition: Factor.h:68
const_iterator end() const
Iterator at end of involved variable keys.
Definition: Factor.h:131
Factor(const CONTAINER &keys)
Construct factor from container of keys.
Definition: Factor.h:84
KeyVector::iterator iterator
Iterator over keys.
Definition: Factor.h:65
Key back() const
Last key.
Definition: Factor.h:119
Key front() const
First key.
Definition: Factor.h:116
size_t size() const
Definition: Factor.h:136