From 7561da4df2df5740a808d0e6ea4e957eb65cb4f2 Mon Sep 17 00:00:00 2001 From: Varun Agrawal Date: Mon, 6 Jan 2025 13:35:45 -0500 Subject: [PATCH] move operator/ to Constraint.h --- gtsam_unstable/discrete/AllDiff.cpp | 6 ------ gtsam_unstable/discrete/Constraint.h | 6 ++++++ gtsam_unstable/discrete/Domain.cpp | 6 ------ gtsam_unstable/discrete/SingleValue.cpp | 6 ------ 4 files changed, 6 insertions(+), 18 deletions(-) diff --git a/gtsam_unstable/discrete/AllDiff.cpp b/gtsam_unstable/discrete/AllDiff.cpp index 01f50fa3d..585ca8103 100644 --- a/gtsam_unstable/discrete/AllDiff.cpp +++ b/gtsam_unstable/discrete/AllDiff.cpp @@ -56,12 +56,6 @@ DecisionTreeFactor AllDiff::operator*(const DecisionTreeFactor& f) const { return toDecisionTreeFactor() * f; } -/* ************************************************************************* */ -DiscreteFactor::shared_ptr AllDiff::operator/( - const DiscreteFactor::shared_ptr& df) const { - return this->toDecisionTreeFactor() / df; -} - /* ************************************************************************* */ bool AllDiff::ensureArcConsistency(Key j, Domains* domains) const { Domain& Dj = domains->at(j); diff --git a/gtsam_unstable/discrete/Constraint.h b/gtsam_unstable/discrete/Constraint.h index 71ed7647a..2d98ab40b 100644 --- a/gtsam_unstable/discrete/Constraint.h +++ b/gtsam_unstable/discrete/Constraint.h @@ -86,6 +86,12 @@ class GTSAM_UNSTABLE_EXPORT Constraint : public DiscreteFactor { this->operator*(df->toDecisionTreeFactor())); } + /// divide by DiscreteFactor::shared_ptr f (safely) + DiscreteFactor::shared_ptr operator/( + const DiscreteFactor::shared_ptr& df) const override { + return this->toDecisionTreeFactor() / df; + } + /// @} /// @name Wrapper support /// @{ diff --git a/gtsam_unstable/discrete/Domain.cpp b/gtsam_unstable/discrete/Domain.cpp index cecb7cc1a..74f621dc7 100644 --- a/gtsam_unstable/discrete/Domain.cpp +++ b/gtsam_unstable/discrete/Domain.cpp @@ -49,12 +49,6 @@ DecisionTreeFactor Domain::operator*(const DecisionTreeFactor& f) const { return toDecisionTreeFactor() * f; } -/* ************************************************************************* */ -DiscreteFactor::shared_ptr Domain::operator/( - const DiscreteFactor::shared_ptr& df) const { - return this->toDecisionTreeFactor() / df; -} - /* ************************************************************************* */ bool Domain::ensureArcConsistency(Key j, Domains* domains) const { if (j != key()) throw invalid_argument("Domain check on wrong domain"); diff --git a/gtsam_unstable/discrete/SingleValue.cpp b/gtsam_unstable/discrete/SingleValue.cpp index 09a8314df..220bc9c06 100644 --- a/gtsam_unstable/discrete/SingleValue.cpp +++ b/gtsam_unstable/discrete/SingleValue.cpp @@ -41,12 +41,6 @@ DecisionTreeFactor SingleValue::operator*(const DecisionTreeFactor& f) const { return toDecisionTreeFactor() * f; } -/* ************************************************************************* */ -DiscreteFactor::shared_ptr SingleValue::operator/( - const DiscreteFactor::shared_ptr& df) const { - return this->toDecisionTreeFactor() / df; -} - /* ************************************************************************* */ bool SingleValue::ensureArcConsistency(Key j, Domains* domains) const { if (j != keys_[0])