diff --git a/gtsam/discrete/AlgebraicDecisionTree.h b/gtsam/discrete/AlgebraicDecisionTree.h index f47e01668..acdbf63a3 100644 --- a/gtsam/discrete/AlgebraicDecisionTree.h +++ b/gtsam/discrete/AlgebraicDecisionTree.h @@ -141,10 +141,10 @@ namespace gtsam { /// Equality method customized to node type `double`. bool equals(const AlgebraicDecisionTree& other, double tol = 1e-9) const { // lambda for comparison of two doubles upto some tolerance. - auto comparator = [](double a, double b, double tol) { + auto compare = [tol](double a, double b) { return std::abs(a - b) < tol; }; - return this->root_->equals(*other.root_, tol, comparator); + return this->root_->equals(*other.root_, tol, compare); } }; // AlgebraicDecisionTree diff --git a/gtsam/discrete/DecisionTree-inl.h b/gtsam/discrete/DecisionTree-inl.h index fb6c78148..209c2ad80 100644 --- a/gtsam/discrete/DecisionTree-inl.h +++ b/gtsam/discrete/DecisionTree-inl.h @@ -77,10 +77,10 @@ namespace gtsam { /** equality up to tolerance */ bool equals(const Node& q, double tol, - const ComparatorFunc& comparator) const override { + const CompareFunc& compare) const override { const Leaf* other = dynamic_cast(&q); if (!other) return false; - return comparator(this->constant_, other->constant_, tol); + return compare(this->constant_, other->constant_); } /** print */ @@ -282,14 +282,14 @@ namespace gtsam { /** equality up to tolerance */ bool equals(const Node& q, double tol, - const ComparatorFunc& comparator) const override { + const CompareFunc& compare) const override { const Choice* other = dynamic_cast(&q); if (!other) return false; if (this->label_ != other->label_) return false; if (branches_.size() != other->branches_.size()) return false; // we don't care about shared pointers being equal here for (size_t i = 0; i < branches_.size(); i++) - if (!(branches_[i]->equals(*(other->branches_[i]), tol, comparator))) + if (!(branches_[i]->equals(*(other->branches_[i]), tol, compare))) return false; return true; } @@ -649,8 +649,8 @@ namespace gtsam { /*********************************************************************************/ template bool DecisionTree::equals(const DecisionTree& other, double tol, - const ComparatorFunc& comparator) const { - return root_->equals(*other.root_, tol, comparator); + const CompareFunc& compare) const { + return root_->equals(*other.root_, tol, compare); } template diff --git a/gtsam/discrete/DecisionTree.h b/gtsam/discrete/DecisionTree.h index 8e6c0e4d7..26817bf79 100644 --- a/gtsam/discrete/DecisionTree.h +++ b/gtsam/discrete/DecisionTree.h @@ -47,14 +47,14 @@ namespace gtsam { } /// Default method for comparison of two objects of type Y. - static bool DefaultComparator(const Y& a, const Y& b, double tol) { + static bool DefaultCompare(const Y& a, const Y& b) { return a == b; } public: using FormatterFunc = std::function; - using ComparatorFunc = std::function; + using CompareFunc = std::function; /** Handy typedefs for unary and binary function types */ typedef std::function Unary; @@ -102,7 +102,7 @@ namespace gtsam { virtual bool sameLeaf(const Node& q) const = 0; virtual bool equals( const Node& other, double tol = 1e-9, - const ComparatorFunc& comparator = &DefaultComparator) const = 0; + const CompareFunc& compare = &DefaultCompare) const = 0; virtual const Y& operator()(const Assignment& x) const = 0; virtual Ptr apply(const Unary& op) const = 0; virtual Ptr apply_f_op_g(const Node&, const Binary&) const = 0; @@ -188,7 +188,7 @@ namespace gtsam { // Testable bool equals(const DecisionTree& other, double tol = 1e-9, - const ComparatorFunc& comparator = &DefaultComparator) const; + const CompareFunc& compare = &DefaultCompare) const; /// @} /// @name Standard Interface