Skip to content

Commit 3fa9da9

Browse files
authored
Merge pull request #2087 from borglab/new-docs-inference
New docs: inference
2 parents 1e72ff0 + 6ea62e1 commit 3fa9da9

23 files changed

+4540
-14
lines changed

gtsam/inference/VariableIndex.cpp

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,24 @@ namespace gtsam {
2323

2424
using namespace std;
2525

26+
const FactorIndices& VariableIndex::operator[](Key variable) const {
27+
return index_.find(variable)->second;
28+
}
29+
30+
const FactorIndices& VariableIndex::at(Key variable) const {
31+
KeyMap::const_iterator item = index_.find(variable);
32+
if(item == index_.end())
33+
throw std::invalid_argument("Requested non-existent variable '" +
34+
DefaultKeyFormatter(variable) +
35+
"' from VariableIndex");
36+
else
37+
return item->second;
38+
}
39+
40+
bool VariableIndex::empty(Key variable) const {
41+
return (*this)[variable].empty();
42+
}
43+
2644
/* ************************************************************************* */
2745
bool VariableIndex::equals(const VariableIndex& other, double tol) const {
2846
return this->nEntries_ == other.nEntries_ && this->nFactors_ == other.nFactors_

gtsam/inference/VariableIndex.h

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -83,21 +83,13 @@ class GTSAM_EXPORT VariableIndex {
8383
/// The number of nonzero blocks, i.e. the number of variable-factor entries
8484
size_t nEntries() const { return nEntries_; }
8585

86+
/// Access a list of factors by variable without checking for existence
87+
const FactorIndices& operator[](Key variable) const;
8688
/// Access a list of factors by variable
87-
const FactorIndices& operator[](Key variable) const {
88-
KeyMap::const_iterator item = index_.find(variable);
89-
if(item == index_.end())
90-
throw std::invalid_argument("Requested non-existent variable '" +
91-
DefaultKeyFormatter(variable) +
92-
"' from VariableIndex");
93-
else
94-
return item->second;
95-
}
89+
const FactorIndices& at(Key variable) const;
9690

9791
/// Return true if no factors associated with a variable
98-
bool empty(Key variable) const {
99-
return (*this)[variable].empty();
100-
}
92+
bool empty(Key variable) const;
10193

10294
/// @}
10395
/// @name Testable

0 commit comments

Comments
 (0)