Skip to content

Commit

Permalink
fix naming
Browse files Browse the repository at this point in the history
  • Loading branch information
varunagrawal committed Jan 2, 2025
1 parent 795780d commit ebd523e
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions gtsam/discrete/DiscreteFactorGraph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -112,24 +112,23 @@ namespace gtsam {
// }

/**
* @brief Multiply all the `factors` and normalize the
* product to prevent underflow.
* @brief Multiply all the `factors`.
*
* @param factors The factors to multiply as a DiscreteFactorGraph.
* @return DecisionTreeFactor
*/
static DecisionTreeFactor ProductAndNormalize(
static DecisionTreeFactor DiscreteProduct(
const DiscreteFactorGraph& factors) {
// PRODUCT: multiply all factors
gttic(product);
DecisionTreeFactor product = factors.product();
gttoc(product);

// Max over all the potentials by pretending all keys are frontal:
auto normalizer = product.max(product.size());
auto denominator = product.max(product.size());

// Normalize the product factor to prevent underflow.
product = product / (*normalizer);
product = product / (*denominator);

return product;
}
Expand All @@ -139,7 +138,7 @@ namespace gtsam {
std::pair<DiscreteConditional::shared_ptr, DiscreteFactor::shared_ptr> //
EliminateForMPE(const DiscreteFactorGraph& factors,
const Ordering& frontalKeys) {
DecisionTreeFactor product = ProductAndNormalize(factors);
DecisionTreeFactor product = DiscreteProduct(factors);

// max out frontals, this is the factor on the separator
gttic(max);
Expand Down Expand Up @@ -217,7 +216,7 @@ namespace gtsam {
std::pair<DiscreteConditional::shared_ptr, DiscreteFactor::shared_ptr> //
EliminateDiscrete(const DiscreteFactorGraph& factors,
const Ordering& frontalKeys) {
DecisionTreeFactor product = ProductAndNormalize(factors);
DecisionTreeFactor product = DiscreteProduct(factors);

// sum out frontals, this is the factor on the separator
gttic(sum);
Expand Down

0 comments on commit ebd523e

Please sign in to comment.