Public Types | Protected Types | Protected Attributes | List of all members
gtsam::VariableIndex Class Reference

#include <VariableIndex.h>

Public Types

typedef KeyMap::const_iterator const_iterator
 
typedef FactorIndices::const_iterator Factor_const_iterator
 
typedef FactorIndices::iterator Factor_iterator
 
typedef KeyMap::const_iterator iterator
 
typedef std::shared_ptr< VariableIndexshared_ptr
 
typedef KeyMap::value_type value_type
 

Protected Types

typedef FastMap< Key, FactorIndicesKeyMap
 

Protected Attributes

KeyMap index_
 
size_t nEntries_
 
size_t nFactors_
 

Standard Constructors

 VariableIndex ()
 Default constructor, creates an empty VariableIndex. More...
 
template<class FG >
 VariableIndex (const FG &factorGraph)
 

Standard Interface

size_t size () const
 The number of variable entries. This is equal to the number of unique variable Keys. More...
 
size_t nFactors () const
 The number of factors in the original factor graph. More...
 
size_t nEntries () const
 The number of nonzero blocks, i.e. the number of variable-factor entries. More...
 
const FactorIndicesoperator[] (Key variable) const
 Access a list of factors by variable. More...
 
bool empty (Key variable) const
 Return true if no factors associated with a variable. More...
 

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
 

Advanced Interface

template<class FG >
void augment (const FG &factors, const FactorIndices *newFactorIndices=nullptr)
 
template<class FG >
void augment (const FG &factor, const FactorIndices &newFactorIndices)
 
void augmentExistingFactor (const FactorIndex factorIndex, const KeySet &newKeys)
 
template<typename ITERATOR , class FG >
void remove (ITERATOR firstFactor, ITERATOR lastFactor, const FG &factors)
 
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. More...
 
const_iterator end () const
 Iterator to the first variable entry. More...
 
const_iterator find (Key key) const
 Find the iterator for the requested variable entry. More...
 
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 FactorIndicesinternalAt (Key variable) const
 Internal version of 'at' that asserts existence. More...
 
FactorIndicesinternalAt (Key variable)
 Internal version of 'at' that asserts existence. More...
 

Detailed Description

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.

Definition at line 41 of file VariableIndex.h.

Member Typedef Documentation

◆ const_iterator

typedef KeyMap::const_iterator gtsam::VariableIndex::const_iterator

Definition at line 54 of file VariableIndex.h.

◆ Factor_const_iterator

typedef FactorIndices::const_iterator gtsam::VariableIndex::Factor_const_iterator

Definition at line 45 of file VariableIndex.h.

◆ Factor_iterator

typedef FactorIndices::iterator gtsam::VariableIndex::Factor_iterator

Definition at line 44 of file VariableIndex.h.

◆ iterator

typedef KeyMap::const_iterator gtsam::VariableIndex::iterator

Definition at line 55 of file VariableIndex.h.

◆ KeyMap

Definition at line 48 of file VariableIndex.h.

◆ shared_ptr

Definition at line 43 of file VariableIndex.h.

◆ value_type

typedef KeyMap::value_type gtsam::VariableIndex::value_type

Definition at line 56 of file VariableIndex.h.

Constructor & Destructor Documentation

◆ VariableIndex() [1/2]

gtsam::VariableIndex::VariableIndex ( )
inline

Default constructor, creates an empty VariableIndex.

Definition at line 62 of file VariableIndex.h.

◆ VariableIndex() [2/2]

template<class FG >
gtsam::VariableIndex::VariableIndex ( const FG &  factorGraph)
inlineexplicit

Create a VariableIndex that computes and stores the block column structure of a factor graph.

Definition at line 69 of file VariableIndex.h.

Member Function Documentation

◆ augment() [1/2]

template<class FG >
void gtsam::VariableIndex::augment ( const FG &  factors,
const FactorIndices newFactorIndices = nullptr 
)

Augment the variable index with new factors. This can be used when solving problems incrementally.

Definition at line 27 of file VariableIndex-inl.h.

◆ augment() [2/2]

template<class FG >
void gtsam::VariableIndex::augment ( const FG &  factor,
const FactorIndices newFactorIndices 
)
inline

An overload of augment() that takes a single factor. and l-value reference to FactorIndeces.

Definition at line 134 of file VariableIndex.h.

◆ augmentExistingFactor()

void gtsam::VariableIndex::augmentExistingFactor ( const FactorIndex  factorIndex,
const KeySet newKeys 
)

Augment the variable index after an existing factor now affects to more variable Keys. This can be used when solving problems incrementally, with smart factors or in general with factors with a dynamic number of Keys.

Definition at line 59 of file VariableIndex.cpp.

◆ begin()

const_iterator gtsam::VariableIndex::begin ( ) const
inline

Iterator to the first variable entry.

Definition at line 163 of file VariableIndex.h.

◆ empty()

bool gtsam::VariableIndex::empty ( Key  variable) const
inline

Return true if no factors associated with a variable.

Definition at line 96 of file VariableIndex.h.

◆ end()

const_iterator gtsam::VariableIndex::end ( ) const
inline

Iterator to the first variable entry.

Definition at line 166 of file VariableIndex.h.

◆ equals()

bool gtsam::VariableIndex::equals ( const VariableIndex other,
double  tol = 0.0 
) const

Test for equality (for unit tests and debug assertions).

Definition at line 27 of file VariableIndex.cpp.

◆ factorsBegin() [1/2]

Factor_iterator gtsam::VariableIndex::factorsBegin ( Key  variable)
inlineprotected

Definition at line 172 of file VariableIndex.h.

◆ factorsBegin() [2/2]

Factor_const_iterator gtsam::VariableIndex::factorsBegin ( Key  variable) const
inlineprotected

Definition at line 175 of file VariableIndex.h.

◆ factorsEnd() [1/2]

Factor_iterator gtsam::VariableIndex::factorsEnd ( Key  variable)
inlineprotected

Definition at line 173 of file VariableIndex.h.

◆ factorsEnd() [2/2]

Factor_const_iterator gtsam::VariableIndex::factorsEnd ( Key  variable) const
inlineprotected

Definition at line 176 of file VariableIndex.h.

◆ find()

const_iterator gtsam::VariableIndex::find ( Key  key) const
inline

Find the iterator for the requested variable entry.

Definition at line 169 of file VariableIndex.h.

◆ internalAt() [1/2]

const FactorIndices& gtsam::VariableIndex::internalAt ( Key  variable) const
inlineprotected

Internal version of 'at' that asserts existence.

Definition at line 179 of file VariableIndex.h.

◆ internalAt() [2/2]

FactorIndices& gtsam::VariableIndex::internalAt ( Key  variable)
inlineprotected

Internal version of 'at' that asserts existence.

Definition at line 186 of file VariableIndex.h.

◆ nEntries()

size_t gtsam::VariableIndex::nEntries ( ) const
inline

The number of nonzero blocks, i.e. the number of variable-factor entries.

Definition at line 84 of file VariableIndex.h.

◆ nFactors()

size_t gtsam::VariableIndex::nFactors ( ) const
inline

The number of factors in the original factor graph.

Definition at line 81 of file VariableIndex.h.

◆ operator[]()

const FactorIndices& gtsam::VariableIndex::operator[] ( Key  variable) const
inline

Access a list of factors by variable.

Definition at line 87 of file VariableIndex.h.

◆ outputMetisFormat()

void gtsam::VariableIndex::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.

Definition at line 46 of file VariableIndex.cpp.

◆ print()

void gtsam::VariableIndex::print ( const std::string &  str = "VariableIndex: ",
const KeyFormatter keyFormatter = DefaultKeyFormatter 
) const

Print the variable index (for unit tests and debugging).

Definition at line 33 of file VariableIndex.cpp.

◆ remove()

template<typename ITERATOR , class FG >
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.

Parameters
indicesThe indices of the factors to remove, which must match factors
factorsThe factors being removed, which must symbolically correspond exactly to the factors with the specified indices that were added.

Definition at line 53 of file VariableIndex-inl.h.

◆ removeUnusedVariables()

template<typename ITERATOR >
void gtsam::VariableIndex::removeUnusedVariables ( ITERATOR  firstKey,
ITERATOR  lastKey 
)

Remove unused empty variables (in debug mode verifies they are empty).

Definition at line 84 of file VariableIndex-inl.h.

◆ size()

size_t gtsam::VariableIndex::size ( ) const
inline

The number of variable entries. This is equal to the number of unique variable Keys.

Definition at line 78 of file VariableIndex.h.

Member Data Documentation

◆ index_

KeyMap gtsam::VariableIndex::index_
protected

Definition at line 49 of file VariableIndex.h.

◆ nEntries_

size_t gtsam::VariableIndex::nEntries_
protected

Definition at line 51 of file VariableIndex.h.

◆ nFactors_

size_t gtsam::VariableIndex::nFactors_
protected

Definition at line 50 of file VariableIndex.h.


The documentation for this class was generated from the following files:


gtsam
Author(s):
autogenerated on Tue Jul 4 2023 02:47:15