From 52c8034d41e8703ad149ee161c9d93ded4df5f0c Mon Sep 17 00:00:00 2001 From: Varun Agrawal Date: Mon, 9 Dec 2024 16:16:18 -0500 Subject: [PATCH] add division by DiscreteFactor in TableFactor --- gtsam/discrete/TableFactor.h | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/gtsam/discrete/TableFactor.h b/gtsam/discrete/TableFactor.h index 002c276ca..64e98c6a1 100644 --- a/gtsam/discrete/TableFactor.h +++ b/gtsam/discrete/TableFactor.h @@ -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(f)) { + return apply(*tf, safe_div); + } else if (auto dtf = std::dynamic_pointer_cast(f)) { + return apply(TableFactor(f->discreteKeys(), *dtf), safe_div); + } + } + /// Convert into a decisiontree DecisionTreeFactor toDecisionTreeFactor() const override;