VariableIndex can augment an existing factor

release/4.3a0
Jose Luis Blanco Claraco 2019-05-26 09:59:00 +02:00
parent 17edca2426
commit a6901cdfcf
2 changed files with 20 additions and 0 deletions

View File

@ -55,4 +55,17 @@ void VariableIndex::outputMetisFormat(ostream& os) const {
os << flush;
}
/* ************************************************************************* */
void VariableIndex::augmentExistingFactor(const FactorIndex factorIndex, const KeySet & newKeys)
{
gttic(VariableIndex_augmentExistingFactor);
for(const Key key: newKeys) {
index_[key].push_back(factorIndex);
++nEntries_;
}
gttoc(VariableIndex_augmentExistingFactor);
}
}

View File

@ -125,6 +125,13 @@ public:
template<class FG>
void augment(const FG& factors, boost::optional<const FactorIndices&> newFactorIndices = boost::none);
/**
* 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.
*/
void augmentExistingFactor(const FactorIndex factorIndex, const KeySet & newKeys);
/**
* 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