Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 0 additions & 40 deletions math/mathcore/inc/Math/CladDerivator.h
Original file line number Diff line number Diff line change
Expand Up @@ -151,46 +151,6 @@ ValueAndPushforward<T, T> Log2_pushforward(T x, T d_x)
return {::TMath::Log2(x), (1.0 / (x * ::TMath::Log(2.0))) * d_x};
}

template <typename T>
ValueAndPushforward<T, T> 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 <typename T, typename U>
void Max_pullback(T a, T b, U p, clad::array_ref<T> d_a, clad::array_ref<T> d_b)
{
if (a >= b)
*d_a += p;
else
*d_b += p;
}

template <typename T>
ValueAndPushforward<T, T> 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 <typename T, typename U>
void Min_pullback(T a, T b, U p, clad::array_ref<T> d_a, clad::array_ref<T> d_b)
{
if (a <= b)
*d_a += p;
else
*d_b += p;
}

template <typename T>
ValueAndPushforward<T, T> Power_pushforward(T x, T y, T d_x, T d_y)
{
Expand Down
6 changes: 6 additions & 0 deletions roofit/roofitcore/inc/RooGlobalFunc.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<RooAbsReal> const &absReal, std::string const &name)
{
return writeCodegenDebugMacro(*absReal, name);
}

} // Experimental

std::string getBatchCompute();
Expand Down
6 changes: 6 additions & 0 deletions roofit/roofitcore/src/RooEvaluatorWrapper.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 2 additions & 0 deletions roofit/roofitcore/src/RooEvaluatorWrapper.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@ class RooEvaluatorWrapper final : public RooAbsReal {

void setUseGeneratedFunctionCode(bool);

void writeDebugMacro(std::string const &) const;

protected:
double evaluate() const override;

Expand Down
9 changes: 9 additions & 0 deletions roofit/roofitcore/src/RooGlobalFunc.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@
#include <RooRealConstant.h>
#include <RooRealVar.h>

#include "RooEvaluatorWrapper.h"

#include <TH1.h>
#include <TInterpreter.h>

Expand Down Expand Up @@ -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<RooEvaluatorWrapper const *>(&absReal)) {
wrapper->writeDebugMacro(name);
}
}

} // namespace Experimental

// RooAbsReal::plotOn arguments
Expand Down
Loading