rename normalization to normalizer

release/4.3a0
Varun Agrawal 2024-12-25 13:13:21 -05:00
parent a2f917aa09
commit 748db19795
2 changed files with 8 additions and 9 deletions

View File

@ -126,10 +126,10 @@ namespace gtsam {
gttoc(product); gttoc(product);
// Max over all the potentials by pretending all keys are frontal: // Max over all the potentials by pretending all keys are frontal:
auto normalization = product.max(product.size()); auto normalizer = product.max(product.size());
// Normalize the product factor to prevent underflow. // Normalize the product factor to prevent underflow.
product = product / (*normalization); product = product / (*normalizer);
return product; return product;
} }
@ -207,8 +207,7 @@ namespace gtsam {
return dag.argmax(); return dag.argmax();
} }
DiscreteValues DiscreteFactorGraph::optimize( DiscreteValues DiscreteFactorGraph::optimize(const Ordering& ordering) const {
const Ordering& ordering) const {
gttic(DiscreteFactorGraph_optimize); gttic(DiscreteFactorGraph_optimize);
DiscreteLookupDAG dag = maxProduct(ordering); DiscreteLookupDAG dag = maxProduct(ordering);
return dag.argmax(); return dag.argmax();

View File

@ -117,9 +117,9 @@ TEST(DiscreteFactorGraph, test) {
*std::dynamic_pointer_cast<DecisionTreeFactor>(newFactorPtr); *std::dynamic_pointer_cast<DecisionTreeFactor>(newFactorPtr);
// Normalize newFactor by max for comparison with expected // Normalize newFactor by max for comparison with expected
auto normalization = newFactor.max(newFactor.size()); auto normalizer = newFactor.max(newFactor.size());
newFactor = newFactor / *normalization; newFactor = newFactor / *normalizer;
// Check Conditional // Check Conditional
CHECK(conditional); CHECK(conditional);
@ -131,9 +131,9 @@ TEST(DiscreteFactorGraph, test) {
CHECK(&newFactor); CHECK(&newFactor);
DecisionTreeFactor expectedFactor(B & A, "10 6 6 10"); DecisionTreeFactor expectedFactor(B & A, "10 6 6 10");
// Normalize by max. // Normalize by max.
normalization = expectedFactor.max(expectedFactor.size()); normalizer = expectedFactor.max(expectedFactor.size());
// Ensure normalization is correct. // Ensure normalizer is correct.
expectedFactor = expectedFactor / *normalization; expectedFactor = expectedFactor / *normalizer;
EXPECT(assert_equal(expectedFactor, newFactor)); EXPECT(assert_equal(expectedFactor, newFactor));
// Test using elimination tree // Test using elimination tree