/** * @file Factor-inl.h * @brief * @author Richard Roberts * @created Sep 1, 2010 */ #pragma once #include #include #include #include #include #include namespace gtsam { ///* ************************************************************************* */ //template //Factor::Factor(const boost::shared_ptr& c) { // keys_.resize(c->parents().size()+1); // keys_[0] = c->key(); // size_t j = 1; // BOOST_FOREACH(const Index parent, c->parents()) { // keys_[j++] = parent; // } // checkSorted(); //} /* ************************************************************************* */ template Factor::Factor(KeyIterator beginKey, KeyIterator endKey) : keys_(beginKey, endKey) { assertInvariants(); } /* ************************************************************************* */ template Factor::shared_ptr Factor::Combine(const FactorGraphType& factorGraph, const VariableIndex& variableIndex, const std::vector& factors, const std::vector& variables, const std::vector >& variablePositions) { return shared_ptr(new Factor(variables.begin(), variables.end())); } /* ************************************************************************* */ template Factor::shared_ptr Factor::Combine(const FactorGraph& factors, const std::map, std::less, MapAllocator>& variableSlots) { typedef const std::map, std::less, MapAllocator> VariableSlots; typedef typeof(boost::lambda::bind(&VariableSlots::value_type::first, boost::lambda::_1)) FirstGetter; typedef boost::transform_iterator< FirstGetter, typename VariableSlots::const_iterator, Index, Index> IndexIterator; FirstGetter firstGetter(boost::lambda::bind(&VariableSlots::value_type::first, boost::lambda::_1)); IndexIterator keysBegin(variableSlots.begin(), firstGetter); IndexIterator keysEnd(variableSlots.end(), firstGetter); return shared_ptr(new Factor(keysBegin, keysEnd)); } }