max returns DiscreteFactor

release/4.3a0
Varun Agrawal 2025-01-04 16:12:09 -05:00
parent 2410d4f442
commit 5e4cf89ba9
4 changed files with 10 additions and 15 deletions

View File

@ -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<DiscreteConditional>(m.discreteKeys().size(), m);
return BaseFactor::max(keys);
}
/* ************************************************************************* */

View File

@ -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

View File

@ -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<TableDistribution>(m);
DiscreteFactor::shared_ptr TableDistribution::max(const Ordering& keys) const {
return table_.max(keys);
}
/* ************************************************************************ */

View File

@ -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.