add comments

release/4.3a0
Varun Agrawal 2025-01-06 18:47:44 -05:00
parent f8dedb5035
commit c754f9bfdc
1 changed files with 7 additions and 1 deletions

View File

@ -81,12 +81,18 @@ namespace gtsam {
DiscreteFactor::shared_ptr DecisionTreeFactor::operator/( DiscreteFactor::shared_ptr DecisionTreeFactor::operator/(
const DiscreteFactor::shared_ptr& f) const { const DiscreteFactor::shared_ptr& f) const {
if (auto tf = std::dynamic_pointer_cast<TableFactor>(f)) { if (auto tf = std::dynamic_pointer_cast<TableFactor>(f)) {
// Check if `f` is a TableFactor. If yes, then
// convert `this` to a TableFactor which is cheaper.
return std::make_shared<TableFactor>(tf->operator/(TableFactor(*this))); return std::make_shared<TableFactor>(tf->operator/(TableFactor(*this)));
} else if (auto dtf = std::dynamic_pointer_cast<DecisionTreeFactor>(f)) { } else if (auto dtf = std::dynamic_pointer_cast<DecisionTreeFactor>(f)) {
// If `f` is a DecisionTreeFactor, divide normally.
return std::make_shared<DecisionTreeFactor>(this->operator/(*dtf)); return std::make_shared<DecisionTreeFactor>(this->operator/(*dtf));
} else { } else {
// Else, convert `f` to a DecisionTreeFactor so we can divide
return std::make_shared<DecisionTreeFactor>( return std::make_shared<DecisionTreeFactor>(
this->operator/(this->toDecisionTreeFactor())); this->operator/(f->toDecisionTreeFactor()));
} }
} }