Skip to content

Commit

Permalink
compute correct subset of keys for division
Browse files Browse the repository at this point in the history
  • Loading branch information
varunagrawal committed Jan 3, 2025
1 parent cb9cec3 commit c6c451b
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion gtsam/discrete/DecisionTreeFactor.h
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,15 @@ namespace gtsam {

/// divide by factor f (safely)
DecisionTreeFactor operator/(const DecisionTreeFactor& f) const {
return apply(f, safe_div);
KeyVector diff;
std::set_difference(this->keys().begin(), this->keys().end(),
f.keys().begin(), f.keys().end(),
std::back_inserter(diff));
DiscreteKeys keys;
for (Key key : diff) {
keys.push_back({key, this->cardinality(key)});
}
return DecisionTreeFactor(keys, apply(f, safe_div));
}

/// Convert into a decision tree
Expand Down

0 comments on commit c6c451b

Please sign in to comment.