From 2b85cfedd4845e3a4329b9cf6dc0a5acb84fc499 Mon Sep 17 00:00:00 2001 From: Varun Agrawal Date: Sat, 22 Jul 2023 00:50:33 -0400 Subject: [PATCH] DecisionTreeFactor apply methods --- gtsam/discrete/DecisionTreeFactor.cpp | 16 ++++++++++++++++ gtsam/discrete/DecisionTreeFactor.h | 14 ++++++++++++-- 2 files changed, 28 insertions(+), 2 deletions(-) diff --git a/gtsam/discrete/DecisionTreeFactor.cpp b/gtsam/discrete/DecisionTreeFactor.cpp index ff18268b1..4aa5e5759 100644 --- a/gtsam/discrete/DecisionTreeFactor.cpp +++ b/gtsam/discrete/DecisionTreeFactor.cpp @@ -82,6 +82,22 @@ namespace gtsam { ADT::print("", formatter); } + /* ************************************************************************ */ + DecisionTreeFactor DecisionTreeFactor::apply(ADT::Unary op) const { + // apply operand + ADT result = ADT::apply(op); + // Make a new factor + return DecisionTreeFactor(discreteKeys(), result); + } + + /* ************************************************************************ */ + DecisionTreeFactor DecisionTreeFactor::apply(ADT::UnaryAssignment op) const { + // apply operand + ADT result = ADT::apply(op); + // Make a new factor + return DecisionTreeFactor(discreteKeys(), result); + } + /* ************************************************************************ */ DecisionTreeFactor DecisionTreeFactor::apply(const DecisionTreeFactor& f, ADT::Binary op) const { diff --git a/gtsam/discrete/DecisionTreeFactor.h b/gtsam/discrete/DecisionTreeFactor.h index e90a2f96f..77da93c5f 100644 --- a/gtsam/discrete/DecisionTreeFactor.h +++ b/gtsam/discrete/DecisionTreeFactor.h @@ -147,8 +147,18 @@ 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::Unary op) const; + + /** + * Apply unary operator (*this) "op" f + * @param op a unary operator that operates on AlgebraicDecisionTree. Takes + * both the assignment and the value. + */ + DecisionTreeFactor apply(ADT::UnaryAssignment op) const; /** * Apply binary operator (*this) "op" f