|
gtsam
4.0.0
gtsam
|
The VariableIndex class computes and stores the block column structure of a factor graph.
The factor graph stores a collection of factors, each of which involves a set of variables. In contrast, the VariableIndex is built from a factor graph prior to elimination, and stores the list of factors that involve each variable. This information is stored as a deque of lists of factor indices.
Standard Constructors | |
| VariableIndex () | |
| Default constructor, creates an empty VariableIndex. | |
| template<class FG > | |
| VariableIndex (const FG &factorGraph) | |
| Create a VariableIndex that computes and stores the block column structure of a factor graph. | |
Standard Interface | |
| size_t | size () const |
| The number of variable entries. More... | |
| size_t | nFactors () const |
| The number of factors in the original factor graph. | |
| size_t | nEntries () const |
| The number of nonzero blocks, i.e. More... | |
| const Factors & | operator[] (Key variable) const |
| Access a list of factors by variable. | |
Testable | |
| bool | equals (const VariableIndex &other, double tol=0.0) const |
| Test for equality (for unit tests and debug assertions). More... | |
| void | print (const std::string &str="VariableIndex: ", const KeyFormatter &keyFormatter=DefaultKeyFormatter) const |
| Print the variable index (for unit tests and debugging). More... | |
| void | outputMetisFormat (std::ostream &os) const |
| Output dual hypergraph to Metis file format for use with hmetis In the dual graph, variables are hyperedges, factors are nodes. | |
Advanced Interface | |
| template<class FG > | |
| void | augment (const FG &factors, boost::optional< const FastVector< size_t > & > newFactorIndices=boost::none) |
| Augment the variable index with new factors. More... | |
| template<typename ITERATOR , class FG > | |
| void | remove (ITERATOR firstFactor, ITERATOR lastFactor, const FG &factors) |
| Remove entries corresponding to the specified factors. More... | |
| template<typename ITERATOR > | |
| void | removeUnusedVariables (ITERATOR firstKey, ITERATOR lastKey) |
| Remove unused empty variables (in debug mode verifies they are empty). More... | |
| const_iterator | begin () const |
| Iterator to the first variable entry. | |
| const_iterator | end () const |
| Iterator to the first variable entry. | |
| const_iterator | find (Key key) const |
| Find the iterator for the requested variable entry. | |
| Factor_iterator | factorsBegin (Key variable) |
| Factor_iterator | factorsEnd (Key variable) |
| Factor_const_iterator | factorsBegin (Key variable) const |
| Factor_const_iterator | factorsEnd (Key variable) const |
| const Factors & | internalAt (Key variable) const |
| Internal version of 'at' that asserts existence. | |
| Factors & | internalAt (Key variable) |
| Internal version of 'at' that asserts existence. | |
Public Types | |
| typedef boost::shared_ptr< VariableIndex > | shared_ptr |
| typedef FastVector< size_t > | Factors |
| typedef Factors::iterator | Factor_iterator |
| typedef Factors::const_iterator | Factor_const_iterator |
| typedef KeyMap::const_iterator | const_iterator |
| typedef KeyMap::const_iterator | iterator |
| typedef KeyMap::value_type | value_type |
Protected Types | |
| typedef FastMap< Key, Factors > | KeyMap |
Protected Attributes | |
| KeyMap | index_ |
| size_t | nFactors_ |
| size_t | nEntries_ |
| void gtsam::VariableIndex::augment | ( | const FG & | factors, |
| boost::optional< const FastVector< size_t > & > | newFactorIndices = boost::none |
||
| ) |
Augment the variable index with new factors.
This can be used when solving problems incrementally.
| bool gtsam::VariableIndex::equals | ( | const VariableIndex & | other, |
| double | tol = 0.0 |
||
| ) | const |
Test for equality (for unit tests and debug assertions).
|
inline |
The number of nonzero blocks, i.e.
the number of variable-factor entries
| void gtsam::VariableIndex::print | ( | const std::string & | str = "VariableIndex: ", |
| const KeyFormatter & | keyFormatter = DefaultKeyFormatter |
||
| ) | const |
Print the variable index (for unit tests and debugging).
| void gtsam::VariableIndex::remove | ( | ITERATOR | firstFactor, |
| ITERATOR | lastFactor, | ||
| const FG & | factors | ||
| ) |
Remove entries corresponding to the specified factors.
NOTE: We intentionally do not decrement nFactors_ because the factor indices need to remain consistent. Removing factors from a factor graph does not shift the indices of other factors. Also, we keep nFactors_ one greater than the highest-numbered factor referenced in a VariableIndex.
| indices | The indices of the factors to remove, which must match factors |
| factors | The factors being removed, which must symbolically correspond exactly to the factors with the specified indices that were added. |
| void gtsam::VariableIndex::removeUnusedVariables | ( | ITERATOR | firstKey, |
| ITERATOR | lastKey | ||
| ) |
Remove unused empty variables (in debug mode verifies they are empty).
|
inline |
The number of variable entries.
This is one greater than the variable with the highest index.