28 gttic(VariableIndex_augment);
31 for (
size_t i = 0;
i < factors.size(); ++
i) {
33 const size_t globalI =
34 newFactorIndices ? (*newFactorIndices)[
i] :
nFactors_;
35 for(
const Key key: *factors[i]) {
42 if (newFactorIndices) {
52 template<
typename ITERATOR,
class FG>
55 gttic(VariableIndex_remove);
61 ITERATOR factorIndex = firstFactor;
63 for (; factorIndex != lastFactor; ++factorIndex, ++
i) {
64 if (i >= factors.size())
65 throw std::invalid_argument(
66 "Internal error, requested inconsistent number of factor indices and factors in VariableIndex::remove");
68 for(
Key j: *factors[i]) {
70 auto entry = std::find(factorEntries.begin(),
71 factorEntries.end(), *factorIndex);
72 if (entry == factorEntries.end())
73 throw std::invalid_argument(
74 "Internal error, indices and factors passed into VariableIndex::remove are not consistent with the existing variable index");
75 factorEntries.erase(entry);
83 template<
typename ITERATOR>
85 for (ITERATOR
key = firstKey;
key != lastKey; ++
key) {
86 KeyMap::iterator entry =
index_.find(*
key);
87 if (!entry->second.empty())
88 throw std::invalid_argument(
89 "Asking to remove variables from the variable index that are not unused");
const gtsam::Symbol key('X', 0)
const GaussianFactorGraph factors
void augment(const FG &factors, const FactorIndices *newFactorIndices=nullptr)
FastVector< FactorIndex > FactorIndices
Define collection types:
void remove(ITERATOR firstFactor, ITERATOR lastFactor, const FG &factors)
const FactorIndices & internalAt(Key variable) const
Internal version of 'at' that asserts existence.
void removeUnusedVariables(ITERATOR firstKey, ITERATOR lastKey)
Remove unused empty variables (in debug mode verifies they are empty).
std::uint64_t Key
Integer nonlinear key type.