From 3fb6f39b30021b5a5e4d2f551998bf14ab6f52cf Mon Sep 17 00:00:00 2001 From: Varun Agrawal Date: Mon, 6 Jan 2025 23:13:06 -0500 Subject: [PATCH] override operator/ in TableDistribution --- gtsam/discrete/TableDistribution.cpp | 6 ++++++ gtsam/discrete/TableDistribution.h | 4 ++++ 2 files changed, 10 insertions(+) diff --git a/gtsam/discrete/TableDistribution.cpp b/gtsam/discrete/TableDistribution.cpp index 3c0605f27..621e6e394 100644 --- a/gtsam/discrete/TableDistribution.cpp +++ b/gtsam/discrete/TableDistribution.cpp @@ -111,6 +111,12 @@ DiscreteFactor::shared_ptr TableDistribution::max(const Ordering& keys) const { return table_.max(keys); } +/* ****************************************************************************/ +DiscreteFactor::shared_ptr TableDistribution::operator/( + const DiscreteFactor::shared_ptr& f) const { + return table_ / f; +} + /* ************************************************************************ */ DiscreteValues TableDistribution::argmax() const { uint64_t maxIdx = 0; diff --git a/gtsam/discrete/TableDistribution.h b/gtsam/discrete/TableDistribution.h index 1c393bb1a..da349efe1 100644 --- a/gtsam/discrete/TableDistribution.h +++ b/gtsam/discrete/TableDistribution.h @@ -123,6 +123,10 @@ class GTSAM_EXPORT TableDistribution : public DiscreteConditional { /// Create new factor by maximizing over all values with the same separator. DiscreteFactor::shared_ptr max(const Ordering& keys) const override; + /// divide by DiscreteFactor::shared_ptr f (safely) + DiscreteFactor::shared_ptr operator/( + const DiscreteFactor::shared_ptr& f) const override; + /** * @brief Return assignment that maximizes value. *