Added exists() to FactorGraph to allow for checking whether a factor exists at a given index. Necessary for matlab interface.

release/4.3a0
Alex Cunningham 2013-06-06 18:07:55 +00:00
parent 43a0367a66
commit ee21ef61a6
2 changed files with 7 additions and 1 deletions

View File

@ -895,6 +895,7 @@ class SymbolicFactorGraph {
void print(string s) const;
bool equals(const gtsam::SymbolicFactorGraph& rhs, double tol) const;
size_t size() const;
bool exists(size_t i) const;
// Standard interface
// FIXME: Must wrap FastSet<Index> for this to work
@ -1282,6 +1283,7 @@ class GaussianFactorGraph {
bool equals(const gtsam::GaussianFactorGraph& lfgraph, double tol) const;
size_t size() const;
gtsam::GaussianFactor* at(size_t idx) const;
bool exists(size_t idx) const;
// Inference
pair<gtsam::GaussianConditional*, gtsam::GaussianFactorGraph> eliminateFrontals(size_t nFrontals) const;
@ -1508,7 +1510,8 @@ class NonlinearFactorGraph {
bool empty() const;
void remove(size_t i);
size_t nrFactors() const;
gtsam::NonlinearFactor* at(size_t i) const;
gtsam::NonlinearFactor* at(size_t idx) const;
bool exists(size_t idx) const;
void push_back(const gtsam::NonlinearFactorGraph& factors);
// NonlinearFactorGraph

View File

@ -165,6 +165,9 @@ class VariableIndex;
const sharedFactor operator[](size_t i) const { return at(i); }
sharedFactor& operator[](size_t i) { return at(i); }
/** Checks whether a valid factor exists at the given index */
inline bool exists(size_t i) const { return i<factors_.size() && factors_[i]; }
/** STL begin, so we can use BOOST_FOREACH */
const_iterator begin() const { return factors_.begin();}