26 #include <boost/bind.hpp> 37 template <
class FACTOR>
40 std::cout << (s.empty() ?
"" : s +
" ") << std::endl;
41 std::cout <<
"size: " <<
size() << std::endl;
42 for (
size_t i = 0;
i < factors_.size();
i++) {
44 ss <<
"factor " <<
i <<
": ";
45 if (factors_[i]) factors_[
i]->print(ss.str(),
formatter);
50 template <
class FACTOR>
53 if (factors_.size() != fg.
size())
return false;
56 for (
size_t i = 0;
i < factors_.size();
i++) {
58 if (f1 ==
nullptr && f2 ==
nullptr)
continue;
59 if (f1 ==
nullptr || f2 ==
nullptr)
return false;
60 if (!f1->equals(*f2, tol))
return false;
66 template <
class FACTOR>
75 template <
class FACTOR>
79 if (factor) keys.insert(factor->begin(), factor->end());
85 template <
class FACTOR>
88 keys.reserve(2 *
size());
90 if (factor) keys.insert(keys.end(), factor->begin(), factor->end());
91 std::sort(keys.begin(), keys.end());
92 auto last = std::unique(keys.begin(), keys.end());
93 keys.erase(last, keys.end());
98 template <
class FACTOR>
99 template <
typename CONTAINER,
typename>
101 bool useEmptySlots) {
102 const size_t num_factors = factors.size();
106 for (
size_t j = 0;
j < num_factors; ++
j) {
120 newFactorIndices[
j] =
i;
124 for (
size_t i = 0;
i < num_factors; ++
i) newFactorIndices[
i] =
i +
size();
127 return newFactorIndices;
constexpr int last(int, int result)
FastVector< FactorIndex > FactorIndices
Define collection types:
FactorIndices add_factors(const CONTAINER &factors, bool useEmptySlots=false)
GaussianFactorGraph factors(list_of(factor1)(factor2)(factor3))
double f2(const Vector2 &x)
const KeyFormatter & formatter
bool equals(const This &fg, double tol=1e-9) const
FastVector< Key > KeyVector
Define collection type once and for all - also used in wrappers.
boost::shared_ptr< FACTOR > sharedFactor
Shared pointer to a factor.
std::function< std::string(Key)> KeyFormatter
Typedef for a function to format a key, i.e. to convert it to a string.
static std::stringstream ss
virtual void print(const std::string &s="FactorGraph", const KeyFormatter &formatter=DefaultKeyFormatter) const
print out graph
Point2 f1(const Point3 &p, OptionalJacobian< 2, 3 > H)
KeyVector keyVector() const
FastVector< sharedFactor > factors_