add division by DiscreteFactor in TableFactor

release/4.3a0
Varun Agrawal 2024-12-09 16:16:18 -05:00
parent e46cd54993
commit 52c8034d41
1 changed files with 9 additions and 0 deletions

View File

@ -171,6 +171,15 @@ class GTSAM_EXPORT TableFactor : public DiscreteFactor {
return apply(f, safe_div);
}
/// divide by DiscreteFactor::shared_ptr f (safely)
TableFactor operator/(const DiscreteFactor::shared_ptr& f) const {
if (auto tf = std::dynamic_pointer_cast<TableFactor>(f)) {
return apply(*tf, safe_div);
} else if (auto dtf = std::dynamic_pointer_cast<DecisionTreeFactor>(f)) {
return apply(TableFactor(f->discreteKeys(), *dtf), safe_div);
}
}
/// Convert into a decisiontree
DecisionTreeFactor toDecisionTreeFactor() const override;