From 64aa0520edd7cb7b7bb58e976bc77516d3312321 Mon Sep 17 00:00:00 2001 From: Varun Agrawal Date: Thu, 30 Jan 2025 21:52:49 -0500 Subject: [PATCH] implement DiscreteFactor methods in Constraint --- gtsam_unstable/discrete/Constraint.h | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/gtsam_unstable/discrete/Constraint.h b/gtsam_unstable/discrete/Constraint.h index 328fabbea..637cf404e 100644 --- a/gtsam_unstable/discrete/Constraint.h +++ b/gtsam_unstable/discrete/Constraint.h @@ -87,6 +87,16 @@ class GTSAM_UNSTABLE_EXPORT Constraint : public DiscreteFactor { this->operator*(df->toDecisionTreeFactor())); } + /// Multiply by a scalar + virtual DiscreteFactor::shared_ptr operator*(double s) const override { + return this->toDecisionTreeFactor() * s; + } + + /// Multiply by a DecisionTreeFactor and return a DecisionTreeFactor + DecisionTreeFactor operator*(const DecisionTreeFactor& dtf) const override { + return this->toDecisionTreeFactor() * dtf; + } + /// divide by DiscreteFactor::shared_ptr f (safely) DiscreteFactor::shared_ptr operator/( const DiscreteFactor::shared_ptr& df) const override { @@ -104,6 +114,9 @@ class GTSAM_UNSTABLE_EXPORT Constraint : public DiscreteFactor { return toDecisionTreeFactor().sum(keys); } + /// Find the max value + double max() const override { return toDecisionTreeFactor().max(); } + DiscreteFactor::shared_ptr max(size_t nrFrontals) const override { return toDecisionTreeFactor().max(nrFrontals); }