return all keys (slow)
parent
e26ab012de
commit
896d006ddf
|
|
@ -77,14 +77,26 @@ namespace gtsam {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ************************************************************************* */
|
/* ************************************************************************* */
|
||||||
template<class FACTOR>
|
template<class FACTOR>
|
||||||
size_t FactorGraph<FACTOR>::nrFactors() const {
|
size_t FactorGraph<FACTOR>::nrFactors() const {
|
||||||
size_t size_ = 0;
|
size_t size_ = 0;
|
||||||
for (const_iterator factor = factors_.begin(); factor != factors_.end(); factor++)
|
BOOST_FOREACH(const sharedFactor& factor, factors_)
|
||||||
if (*factor != NULL) size_++;
|
if (factor) size_++;
|
||||||
return size_;
|
return size_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* ************************************************************************* */
|
||||||
|
template<class FACTOR>
|
||||||
|
std::set<typename FACTOR::KeyType> FactorGraph<FACTOR>::keys() const {
|
||||||
|
std::set<KeyType> allKeys;
|
||||||
|
BOOST_FOREACH(const sharedFactor& factor, factors_)
|
||||||
|
if (factor) {
|
||||||
|
BOOST_FOREACH(Index j, factor->keys())
|
||||||
|
allKeys.insert(j);
|
||||||
|
}
|
||||||
|
return allKeys;
|
||||||
|
}
|
||||||
|
|
||||||
/* ************************************************************************* */
|
/* ************************************************************************* */
|
||||||
template<class FACTOR>
|
template<class FACTOR>
|
||||||
|
|
|
||||||
|
|
@ -27,6 +27,7 @@
|
||||||
|
|
||||||
#include <boost/serialization/nvp.hpp>
|
#include <boost/serialization/nvp.hpp>
|
||||||
#include <boost/function.hpp>
|
#include <boost/function.hpp>
|
||||||
|
#include <set>
|
||||||
|
|
||||||
namespace gtsam {
|
namespace gtsam {
|
||||||
|
|
||||||
|
|
@ -44,7 +45,7 @@ template<class CONDITIONAL, class CLIQUE> class BayesTree;
|
||||||
public:
|
public:
|
||||||
|
|
||||||
typedef FACTOR FactorType; ///< factor type
|
typedef FACTOR FactorType; ///< factor type
|
||||||
typedef typename FACTOR::KeyType KeyType; ///< type of Keys we use to index factors with
|
typedef typename FACTOR::KeyType KeyType; ///< type of Keys we use to index variables with
|
||||||
typedef boost::shared_ptr<FACTOR> sharedFactor; ///< Shared pointer to a factor
|
typedef boost::shared_ptr<FACTOR> sharedFactor; ///< Shared pointer to a factor
|
||||||
typedef boost::shared_ptr<typename FACTOR::ConditionalType> sharedConditional; ///< Shared pointer to a conditional
|
typedef boost::shared_ptr<typename FACTOR::ConditionalType> sharedConditional; ///< Shared pointer to a conditional
|
||||||
|
|
||||||
|
|
@ -208,6 +209,9 @@ template<class CONDITIONAL, class CLIQUE> class BayesTree;
|
||||||
/** return the number valid factors */
|
/** return the number valid factors */
|
||||||
size_t nrFactors() const;
|
size_t nrFactors() const;
|
||||||
|
|
||||||
|
/** Potentially very slow function to return all keys involved */
|
||||||
|
std::set<KeyType> keys() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
/** Serialization function */
|
/** Serialization function */
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue