From b325150b3751b7f5c43b0268f76be8e60f10fe38 Mon Sep 17 00:00:00 2001 From: Varun Agrawal Date: Sun, 8 Dec 2024 16:18:42 -0500 Subject: [PATCH] revert DiscreteFactorGraph::product --- gtsam/discrete/DiscreteFactorGraph.cpp | 13 ++++--------- gtsam/discrete/DiscreteFactorGraph.h | 2 +- 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/gtsam/discrete/DiscreteFactorGraph.cpp b/gtsam/discrete/DiscreteFactorGraph.cpp index fa9d9bdc7..9e64b0f6d 100644 --- a/gtsam/discrete/DiscreteFactorGraph.cpp +++ b/gtsam/discrete/DiscreteFactorGraph.cpp @@ -64,15 +64,10 @@ namespace gtsam { } /* ************************************************************************* */ - DiscreteFactor::shared_ptr DiscreteFactorGraph::product() const { - sharedFactor result = this->at(0); - for (size_t i = 1; i < this->size(); ++i) { - const sharedFactor factor = this->at(i); - if (factor) { - // Predicated on the fact that all discrete factors are of a single type - // so there is no type-conversion happening which can be expensive. - result = result->operator*(factor); - } + DecisionTreeFactor DiscreteFactorGraph::product() const { + DecisionTreeFactor result; + for (const sharedFactor& factor : *this) { + if (factor) result = result * (*factor); } return result; } diff --git a/gtsam/discrete/DiscreteFactorGraph.h b/gtsam/discrete/DiscreteFactorGraph.h index a5324811c..43c48c2d0 100644 --- a/gtsam/discrete/DiscreteFactorGraph.h +++ b/gtsam/discrete/DiscreteFactorGraph.h @@ -147,7 +147,7 @@ class GTSAM_EXPORT DiscreteFactorGraph DiscreteKeys discreteKeys() const; /** return product of all factors as a single factor */ - DiscreteFactor::shared_ptr product() const; + DecisionTreeFactor product() const; /** * Evaluates the factor graph given values, returns the joint probability of