From c754f9bfdcb6c213003a511924a5c4df69f5b91c Mon Sep 17 00:00:00 2001 From: Varun Agrawal Date: Mon, 6 Jan 2025 18:47:44 -0500 Subject: [PATCH] add comments --- gtsam/discrete/DecisionTreeFactor.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/gtsam/discrete/DecisionTreeFactor.cpp b/gtsam/discrete/DecisionTreeFactor.cpp index 2f2c039a4..6e25c6452 100644 --- a/gtsam/discrete/DecisionTreeFactor.cpp +++ b/gtsam/discrete/DecisionTreeFactor.cpp @@ -81,12 +81,18 @@ namespace gtsam { DiscreteFactor::shared_ptr DecisionTreeFactor::operator/( const DiscreteFactor::shared_ptr& f) const { if (auto tf = std::dynamic_pointer_cast(f)) { + // Check if `f` is a TableFactor. If yes, then + // convert `this` to a TableFactor which is cheaper. return std::make_shared(tf->operator/(TableFactor(*this))); + } else if (auto dtf = std::dynamic_pointer_cast(f)) { + // If `f` is a DecisionTreeFactor, divide normally. return std::make_shared(this->operator/(*dtf)); + } else { + // Else, convert `f` to a DecisionTreeFactor so we can divide return std::make_shared( - this->operator/(this->toDecisionTreeFactor())); + this->operator/(f->toDecisionTreeFactor())); } }