From f751a5bfcf085f429cf48ce51f854587d1b28cad Mon Sep 17 00:00:00 2001 From: Varun Agrawal Date: Thu, 6 Jul 2023 16:37:22 -0400 Subject: [PATCH] overload apply method in DecisionTreeFactor --- gtsam/discrete/DecisionTreeFactor.cpp | 8 ++++++++ gtsam/discrete/DecisionTreeFactor.h | 7 +++++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/gtsam/discrete/DecisionTreeFactor.cpp b/gtsam/discrete/DecisionTreeFactor.cpp index ff18268b1..56f1659dc 100644 --- a/gtsam/discrete/DecisionTreeFactor.cpp +++ b/gtsam/discrete/DecisionTreeFactor.cpp @@ -101,6 +101,14 @@ namespace gtsam { return DecisionTreeFactor(keys, result); } + /* ************************************************************************ */ + DecisionTreeFactor DecisionTreeFactor::apply(ADT::UnaryAssignment op) const { + // apply operand + ADT result = ADT::apply(op); + // Make a new factor + return DecisionTreeFactor(discreteKeys(), result); + } + /* ************************************************************************ */ DecisionTreeFactor::shared_ptr DecisionTreeFactor::combine( size_t nrFrontals, ADT::Binary op) const { diff --git a/gtsam/discrete/DecisionTreeFactor.h b/gtsam/discrete/DecisionTreeFactor.h index e90a2f96f..e92c82b77 100644 --- a/gtsam/discrete/DecisionTreeFactor.h +++ b/gtsam/discrete/DecisionTreeFactor.h @@ -147,8 +147,11 @@ namespace gtsam { /// @name Advanced Interface /// @{ - /// Inherit all the `apply` methods from AlgebraicDecisionTree - using ADT::apply; + /** + * Apply unary operator (*this) "op" f + * @param op a unary operator that operates on AlgebraicDecisionTree + */ + DecisionTreeFactor apply(ADT::UnaryAssignment op) const; /** * Apply binary operator (*this) "op" f