normalize no longer takes explicit sum, so that it normalizes correctly

release/4.3a0
Varun Agrawal 2024-10-09 18:34:56 -04:00
parent c26b272d80
commit acda56d67b
2 changed files with 2 additions and 5 deletions

View File

@ -234,12 +234,9 @@ namespace gtsam {
* @brief Helper method to perform normalization such that all leaves in the
* tree sum to 1
*
* @param sum
* @return AlgebraicDecisionTree
*/
AlgebraicDecisionTree normalize(double sum) const {
return this->apply([&sum](const double& x) { return x / sum; });
}
AlgebraicDecisionTree normalize() const { return (*this) / this->sum(); }
/// Find the minimum values amongst all leaves
double min() const {

View File

@ -562,7 +562,7 @@ TEST(ADT, Sum) {
TEST(ADT, Normalize) {
ADT a = exampleADT();
double sum = a.sum();
auto actual = a.normalize(sum);
auto actual = a.normalize();
DiscreteKey A(0, 2), B(1, 3), C(2, 2);
DiscreteKeys keys = DiscreteKeys{A, B, C};