return DiscreteValues directly

release/4.3a0
Varun Agrawal 2025-01-04 17:10:43 -05:00
parent aba691d3d6
commit 69b5e7d527
3 changed files with 4 additions and 5 deletions

View File

@ -119,7 +119,7 @@ DiscreteFactor::shared_ptr TableDistribution::max(const Ordering& keys) const {
} }
/* ************************************************************************ */ /* ************************************************************************ */
uint64_t TableDistribution::argmax() const { DiscreteValues TableDistribution::argmax() const {
uint64_t maxIdx = 0; uint64_t maxIdx = 0;
double maxValue = 0.0; double maxValue = 0.0;
@ -132,7 +132,7 @@ uint64_t TableDistribution::argmax() const {
} }
} }
return maxIdx; return table_.findAssignments(maxIdx);
} }
/* ****************************************************************************/ /* ****************************************************************************/

View File

@ -145,7 +145,7 @@ class GTSAM_EXPORT TableDistribution : public DiscreteConditional {
* *
* @return maximizing assignment for the variables. * @return maximizing assignment for the variables.
*/ */
uint64_t argmax() const; DiscreteValues argmax() const;
/// @} /// @}
/// @name Advanced Interface /// @name Advanced Interface

View File

@ -47,8 +47,7 @@ DiscreteValues HybridBayesTree::discreteMaxProduct(
const DiscreteFactorGraph& dfg) const { const DiscreteFactorGraph& dfg) const {
TableFactor product = TableProduct(dfg); TableFactor product = TableProduct(dfg);
uint64_t maxIdx = TableDistribution(product).argmax(); DiscreteValues assignment = TableDistribution(product).argmax();
DiscreteValues assignment = product.findAssignments(maxIdx);
return assignment; return assignment;
} }