Go to the documentation of this file.
32 #ifdef GTSAM_ENABLE_BOOST_SERIALIZATION
33 #include <boost/serialization/nvp.hpp>
34 #include <boost/serialization/vector.hpp>
38 #include <type_traits>
47 template <
class CLIQUE>
57 template <
class FACTOR>
61 typedef std::shared_ptr<FACTOR>
69 typedef std::shared_ptr<This>
73 template <
typename DERIVEDFACTOR>
74 using IsDerived =
typename std::enable_if<
106 template <
typename ITERATOR>
112 template <
class CONTAINER>
131 template <
class DERIVEDFACTOR,
typename = IsDerived<DERIVEDFACTOR>>
132 FactorGraph(std::initializer_list<std::shared_ptr<DERIVEDFACTOR>> sharedFactors)
146 template <
class DERIVEDFACTOR>
148 factors_.push_back(std::shared_ptr<FACTOR>(factor));
152 template <
class DERIVEDFACTOR,
class... Args>
154 factors_.push_back(std::allocate_shared<DERIVEDFACTOR>(
156 std::forward<Args>(
args)...));
163 template <
class DERIVEDFACTOR>
165 factors_.push_back(std::allocate_shared<DERIVEDFACTOR>(
170 template <
class DERIVEDFACTOR>
176 template <
class DERIVEDFACTOR>
189 template <
class DERIVEDFACTOR>
191 std::shared_ptr<DERIVEDFACTOR> factor) {
204 template <
typename ITERATOR>
206 ITERATOR lastFactor) {
211 template <
typename ITERATOR>
213 ITERATOR lastFactor) {
214 for (ITERATOR
f = firstFactor;
f != lastFactor; ++
f)
push_back(*
f);
225 template <
typename CONTAINER>
227 push_back(container.begin(), container.end());
231 template <
typename CONTAINER>
233 push_back(container.begin(), container.end());
240 template <
class FACTOR_OR_CONTAINER>
241 void add(
const FACTOR_OR_CONTAINER& factorOrContainer) {
249 template <
class FACTOR_OR_CONTAINER>
264 template <
class CLIQUE>
265 typename std::enable_if<
275 template <
typename CONTAINER,
typename = HasDerivedElementType<CONTAINER>>
277 bool useEmptySlots =
false);
284 virtual void print(
const std::string&
s =
"FactorGraph",
317 template <
typename F>
318 std::shared_ptr<F>
at(
size_t i) {
319 return std::dynamic_pointer_cast<F>(
factors_.at(
i));
323 template <
typename F>
324 const std::shared_ptr<F>
at(
size_t i)
const {
325 return std::dynamic_pointer_cast<F>(
factors_.at(
i));
389 void dot(std::ostream&
os,
420 inline bool exists(
size_t idx)
const {
return idx <
size() &&
at(idx); }
423 #ifdef GTSAM_ENABLE_BOOST_SERIALIZATION
425 friend class boost::serialization::access;
426 template <
class ARCHIVE>
427 void serialize(ARCHIVE& ar,
const unsigned int ) {
428 ar& BOOST_SERIALIZATION_NVP(
factors_);
FactorIndices add_factors(const CONTAINER &factors, bool useEmptySlots=false)
FastVector< sharedFactor >::const_iterator const_iterator
FACTOR FactorType
factor type
FastVector< sharedFactor > factors_
A thin wrapper around std::vector that uses a custom allocator.
Array< double, 1, 3 > e(1./3., 0.5, 2.)
double error(const HybridValues &values) const
Concept check for values that can be used in unit tests.
void addFactorsToGraph(FactorGraph< FactorType > *graph) const
IsDerived< DERIVEDFACTOR > push_back(const DERIVEDFACTOR &factor)
std::vector< T, typename internal::FastDefaultVectorAllocator< T >::type > FastVector
virtual void print(const std::string &s="FactorGraph", const KeyFormatter &formatter=DefaultKeyFormatter) const
Print out graph to std::cout, with optional key formatter.
const GaussianFactorGraph factors
std::shared_ptr< F > at(size_t i)
KeyVector keyVector() const
const KeyFormatter & formatter
This & operator+=(const FACTOR_OR_CONTAINER &factorOrContainer)
void saveGraph(const std::string &filename, const KeyFormatter &keyFormatter=DefaultKeyFormatter, const DotWriter &writer=DotWriter()) const
output to file with graphviz format.
bool isEqual(const FactorGraph &other) const
Check exact equality of the factor pointers. Useful for derived ==.
typename std::enable_if< std::is_base_of< FactorType, typename T::value_type >::value >::type HasDerivedValueType
Check if T has a value_type derived from FactorType.
std::shared_ptr< This > shared_ptr
Shared pointer for this class.
HasDerivedValueType< ITERATOR > push_back(ITERATOR firstFactor, ITERATOR lastFactor)
Push back many factors with an iterator (factors are copied)
ofstream os("timeSchurFactors.csv")
static const symbolic::SymbolExpr< internal::symbolic_last_tag > last
FastVector< Key > KeyVector
Define collection type once and for all - also used in wrappers.
FactorGraph(std::initializer_list< std::shared_ptr< DERIVEDFACTOR >> sharedFactors)
KeyFormatter DefaultKeyFormatter
Assign default key formatter.
iterator erase(iterator item)
const sharedFactor at(size_t i) const
virtual void resize(size_t size)
sharedFactor front() const
STL compatible allocator to use with types requiring a non standrad alignment.
typename std::enable_if< std::is_base_of< FactorType, DERIVEDFACTOR >::value >::type IsDerived
Check if a DERIVEDFACTOR is in fact derived from FactorType.
HasDerivedElementType< ITERATOR > push_back(ITERATOR firstFactor, ITERATOR lastFactor)
std::function< std::string(Key)> KeyFormatter
Typedef for a function to format a key, i.e. to convert it to a string.
void replace(size_t index, sharedFactor factor)
std::enable_if< std::is_base_of< FactorType, DERIVEDFACTOR >::value, This >::type & operator+=(std::shared_ptr< DERIVEDFACTOR > factor)
Append factor to factor graph.
bool equals(const This &fg, double tol=1e-9) const
Check equality up to tolerance.
FactorGraph(const CONTAINER &factors)
FastVector< sharedFactor >::iterator iterator
FactorGraph(ITERATOR firstFactor, ITERATOR lastFactor)
Point2(* f)(const Point3 &, OptionalJacobian< 2, 3 >)
sharedFactor back() const
sharedFactor & at(size_t i)
iterator erase(iterator first, iterator last)
typename std::enable_if< std::is_base_of< FactorType, typename T::value_type::element_type >::value >::type HasDerivedElementType
Check if T has a pointer type derived from FactorType.
FactorGraph< FACTOR > This
Typedef for this class.
std::enable_if< std::is_base_of< This, typename CLIQUE::FactorGraphType >::value >::type push_back(const BayesTree< CLIQUE > &bayesTree)
IsDerived< DERIVEDFACTOR > push_back(std::shared_ptr< DERIVEDFACTOR > factor)
Add a factor directly using a shared_ptr.
sharedFactor & operator[](size_t i)
void dot(std::ostream &os, const KeyFormatter &keyFormatter=DefaultKeyFormatter, const DotWriter &writer=DotWriter()) const
Output to graphviz format, stream version.
const_iterator end() const
#define GTSAM_CONCEPT_TESTABLE_TYPE(T)
const_iterator begin() const
HasDerivedElementType< CONTAINER > push_back(const CONTAINER &container)
const std::shared_ptr< F > at(size_t i) const
Const version of templated at method.
void reserve(size_t size)
bool exists(size_t idx) const
virtual ~FactorGraph()=default
IsDerived< DERIVEDFACTOR > add(std::shared_ptr< DERIVEDFACTOR > factor)
add is a synonym for push_back.
std::shared_ptr< FACTOR > sharedFactor
Shared pointer to a factor.
const sharedFactor operator[](size_t i) const
DotWriter is a helper class for writing graphviz .dot files.
HasDerivedValueType< CONTAINER > push_back(const CONTAINER &container)
Push back non-pointer objects in a container (factors are copied).
IsDerived< DERIVEDFACTOR > emplace_shared(Args &&... args)
Emplace a shared pointer to factor of given type.
void add(const FACTOR_OR_CONTAINER &factorOrContainer)
FastVector< FactorIndex > FactorIndices
Define collection types:
std::enable_if< std::is_base_of< FactorType, DERIVEDFACTOR >::value, This >::type & operator,(std::shared_ptr< DERIVEDFACTOR > factor)
Overload comma operator to allow for append chaining.
gtsam
Author(s):
autogenerated on Sat Nov 16 2024 04:02:17