diff --git a/gtsam/discrete/DiscreteConditional.cpp b/gtsam/discrete/DiscreteConditional.cpp index 1a345afac..e433243e1 100644 --- a/gtsam/discrete/DiscreteConditional.cpp +++ b/gtsam/discrete/DiscreteConditional.cpp @@ -479,10 +479,9 @@ double DiscreteConditional::evaluate(const HybridValues& x) const { } /* ************************************************************************* */ -DiscreteConditional::shared_ptr DiscreteConditional::max( +DiscreteFactor::shared_ptr DiscreteConditional::max( const Ordering& keys) const { - auto m = *BaseFactor::max(keys); - return std::make_shared(m.discreteKeys().size(), m); + return BaseFactor::max(keys); } /* ************************************************************************* */ diff --git a/gtsam/discrete/DiscreteConditional.h b/gtsam/discrete/DiscreteConditional.h index 35dc346d1..c92a69050 100644 --- a/gtsam/discrete/DiscreteConditional.h +++ b/gtsam/discrete/DiscreteConditional.h @@ -215,13 +215,13 @@ class GTSAM_EXPORT DiscreteConditional size_t argmax(const DiscreteValues& parentsValues = DiscreteValues()) const; /** - * @brief Create new conditional by maximizing over all + * @brief Create new factor by maximizing over all * values with the same separator. * * @param keys The keys to sum over. - * @return DiscreteConditional::shared_ptr + * @return DiscreteFactor::shared_ptr */ - virtual DiscreteConditional::shared_ptr max(const Ordering& keys) const; + virtual DiscreteFactor::shared_ptr max(const Ordering& keys) const; /// @} /// @name Advanced Interface diff --git a/gtsam/discrete/TableDistribution.cpp b/gtsam/discrete/TableDistribution.cpp index 2e476b0ee..241320649 100644 --- a/gtsam/discrete/TableDistribution.cpp +++ b/gtsam/discrete/TableDistribution.cpp @@ -114,11 +114,8 @@ bool TableDistribution::equals(const DiscreteFactor& other, double tol) const { } /* ****************************************************************************/ -DiscreteConditional::shared_ptr TableDistribution::max( - const Ordering& keys) const { - auto m = *table_.max(keys); - - return std::make_shared(m); +DiscreteFactor::shared_ptr TableDistribution::max(const Ordering& keys) const { + return table_.max(keys); } /* ************************************************************************ */ diff --git a/gtsam/discrete/TableDistribution.h b/gtsam/discrete/TableDistribution.h index 9cbca0d26..5b36105a1 100644 --- a/gtsam/discrete/TableDistribution.h +++ b/gtsam/discrete/TableDistribution.h @@ -132,14 +132,13 @@ class GTSAM_EXPORT TableDistribution : public DiscreteConditional { } /** - * @brief Create new conditional by maximizing over all + * @brief Create new factor by maximizing over all * values with the same separator. * * @param keys The keys to sum over. - * @return DiscreteConditional::shared_ptr + * @return DiscreteFactor::shared_ptr */ - virtual DiscreteConditional::shared_ptr max( - const Ordering& keys) const override; + virtual DiscreteFactor::shared_ptr max(const Ordering& keys) const override; /** * @brief Return assignment that maximizes value.