From 2894c957b1942d355b4c014b0a176ae6d592d078 Mon Sep 17 00:00:00 2001 From: Varun Agrawal Date: Wed, 1 Jan 2025 19:15:49 -0500 Subject: [PATCH] clarify TableProduct function --- gtsam/hybrid/HybridGaussianFactorGraph.cpp | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/gtsam/hybrid/HybridGaussianFactorGraph.cpp b/gtsam/hybrid/HybridGaussianFactorGraph.cpp index 7cc890dc0..25047bfad 100644 --- a/gtsam/hybrid/HybridGaussianFactorGraph.cpp +++ b/gtsam/hybrid/HybridGaussianFactorGraph.cpp @@ -256,13 +256,12 @@ static TableFactor::shared_ptr DiscreteFactorFromErrors( } /** - * @brief Multiply all the `factors` and normalize the - * product to prevent underflow. + * @brief Multiply all the `factors` using the machinery of the TableFactor. * * @param factors The factors to multiply as a DiscreteFactorGraph. * @return TableFactor */ -static TableFactor ProductAndNormalize(const DiscreteFactorGraph &factors) { +static TableFactor TableProduct(const DiscreteFactorGraph &factors) { // PRODUCT: multiply all factors #if GTSAM_HYBRID_TIMING gttic_(DiscreteProduct); @@ -282,14 +281,13 @@ static TableFactor ProductAndNormalize(const DiscreteFactorGraph &factors) { gttoc_(DiscreteProduct); #endif - // Max over all the potentials by pretending all keys are frontal: - auto normalizer = product.max(product.size()); - #if GTSAM_HYBRID_TIMING gttic_(DiscreteNormalize); #endif + // Max over all the potentials by pretending all keys are frontal: + auto denominator = product.max(product.size()); // Normalize the product factor to prevent underflow. - product = product / (*normalizer); + product = product / (*denominator); #if GTSAM_HYBRID_TIMING gttoc_(DiscreteNormalize); #endif @@ -352,7 +350,7 @@ discreteElimination(const HybridGaussianFactorGraph &factors, // so we can use the TableFactor for efficiency. if (separator.size() == 0) { // Get product factor - TableFactor product = ProductAndNormalize(dfg); + TableFactor product = TableProduct(dfg); #if GTSAM_HYBRID_TIMING gttic_(EliminateDiscreteFormDiscreteConditional);