28 boost::optional<const FactorIndices&> newFactorIndices) {
29 gttic(VariableIndex_augment);
32 for (
size_t i = 0;
i < factors.size(); ++
i) {
34 const size_t globalI =
35 newFactorIndices ? (*newFactorIndices)[
i] :
nFactors_;
36 for(
const Key key: *factors[i]) {
43 if (newFactorIndices) {
53 template<
typename ITERATOR,
class FG>
56 gttic(VariableIndex_remove);
62 ITERATOR factorIndex = firstFactor;
64 for (; factorIndex != lastFactor; ++factorIndex, ++
i) {
65 if (i >= factors.size())
66 throw std::invalid_argument(
67 "Internal error, requested inconsistent number of factor indices and factors in VariableIndex::remove");
69 for(
Key j: *factors[i]) {
71 auto entry = std::find(factorEntries.begin(),
72 factorEntries.end(), *factorIndex);
73 if (entry == factorEntries.end())
74 throw std::invalid_argument(
75 "Internal error, indices and factors passed into VariableIndex::remove are not consistent with the existing variable index");
76 factorEntries.erase(entry);
84 template<
typename ITERATOR>
86 for (ITERATOR
key = firstKey;
key != lastKey; ++
key) {
87 KeyMap::iterator entry =
index_.find(*
key);
88 if (!entry->second.empty())
89 throw std::invalid_argument(
90 "Asking to remove variables from the variable index that are not unused");
void augment(const FG &factors, boost::optional< const FactorIndices & > newFactorIndices=boost::none)
FastVector< FactorIndex > FactorIndices
Define collection types:
GaussianFactorGraph factors(list_of(factor1)(factor2)(factor3))
const FactorIndices & internalAt(Key variable) const
Internal version of 'at' that asserts existence.
void remove(ITERATOR firstFactor, ITERATOR lastFactor, const FG &factors)
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.