diff --git a/math/mathcore/inc/Math/CladDerivator.h b/math/mathcore/inc/Math/CladDerivator.h index bb5ea2d7f36dc..e91795532a393 100644 --- a/math/mathcore/inc/Math/CladDerivator.h +++ b/math/mathcore/inc/Math/CladDerivator.h @@ -151,46 +151,6 @@ ValueAndPushforward Log2_pushforward(T x, T d_x) return {::TMath::Log2(x), (1.0 / (x * ::TMath::Log(2.0))) * d_x}; } -template -ValueAndPushforward Max_pushforward(T x, T y, T d_x, T d_y) -{ - T derivative = 0; - if (x >= y) - derivative = d_x; - else - derivative = d_y; - return {::TMath::Max(x, y), derivative}; -} - -template -void Max_pullback(T a, T b, U p, clad::array_ref d_a, clad::array_ref d_b) -{ - if (a >= b) - *d_a += p; - else - *d_b += p; -} - -template -ValueAndPushforward Min_pushforward(T x, T y, T d_x, T d_y) -{ - T derivative = 0; - if (x <= y) - derivative = d_x; - else - derivative = d_y; - return {::TMath::Min(x, y), derivative}; -} - -template -void Min_pullback(T a, T b, U p, clad::array_ref d_a, clad::array_ref d_b) -{ - if (a <= b) - *d_a += p; - else - *d_b += p; -} - template ValueAndPushforward Power_pushforward(T x, T y, T d_x, T d_y) { diff --git a/roofit/roofitcore/inc/RooGlobalFunc.h b/roofit/roofitcore/inc/RooGlobalFunc.h index 94a48f0fa7925..75f7dda24932c 100644 --- a/roofit/roofitcore/inc/RooGlobalFunc.h +++ b/roofit/roofitcore/inc/RooGlobalFunc.h @@ -80,6 +80,12 @@ namespace Experimental { RooCmdArg ParallelGradientOptions(bool enable=true, int orderStrategy=0, int chainFactor=1) ; RooCmdArg ParallelDescentOptions(bool enable=false, int splitStrategy=0, int numSplits=4) ; +void writeCodegenDebugMacro(RooAbsReal const &absReal, std::string const &name); +inline void writeCodegenDebugMacro(std::unique_ptr const &absReal, std::string const &name) +{ + return writeCodegenDebugMacro(*absReal, name); +} + } // Experimental std::string getBatchCompute(); diff --git a/roofit/roofitcore/src/RooEvaluatorWrapper.cxx b/roofit/roofitcore/src/RooEvaluatorWrapper.cxx index a7245872b6083..e975a3002dd50 100644 --- a/roofit/roofitcore/src/RooEvaluatorWrapper.cxx +++ b/roofit/roofitcore/src/RooEvaluatorWrapper.cxx @@ -513,4 +513,10 @@ bool RooEvaluatorWrapper::hasGradient() const return _funcWrapper->hasGradient(); } +void RooEvaluatorWrapper::writeDebugMacro(std::string const &filename) const +{ + if (_funcWrapper) + return _funcWrapper->writeDebugMacro(filename); +} + /// \endcond diff --git a/roofit/roofitcore/src/RooEvaluatorWrapper.h b/roofit/roofitcore/src/RooEvaluatorWrapper.h index b217f91317f40..02c447002cf8e 100644 --- a/roofit/roofitcore/src/RooEvaluatorWrapper.h +++ b/roofit/roofitcore/src/RooEvaluatorWrapper.h @@ -72,6 +72,8 @@ class RooEvaluatorWrapper final : public RooAbsReal { void setUseGeneratedFunctionCode(bool); + void writeDebugMacro(std::string const &) const; + protected: double evaluate() const override; diff --git a/roofit/roofitcore/src/RooGlobalFunc.cxx b/roofit/roofitcore/src/RooGlobalFunc.cxx index 656b640e47f53..b2a3a7274ed38 100644 --- a/roofit/roofitcore/src/RooGlobalFunc.cxx +++ b/roofit/roofitcore/src/RooGlobalFunc.cxx @@ -32,6 +32,8 @@ #include #include +#include "RooEvaluatorWrapper.h" + #include #include @@ -129,6 +131,13 @@ RooCmdArg ParallelDescentOptions(bool enable, int splitStrategy, int numSplits) return RooCmdArg("ParallelDescentOptions", enable, numSplits, splitStrategy, 0, nullptr, nullptr, nullptr, nullptr); } +void writeCodegenDebugMacro(RooAbsReal const &absReal, std::string const &name) +{ + if (auto *wrapper = dynamic_cast(&absReal)) { + wrapper->writeDebugMacro(name); + } +} + } // namespace Experimental // RooAbsReal::plotOn arguments