Skip to content

Commit

Permalink
[RF] No need to build wrapper around Clad derivatives anymore
Browse files Browse the repository at this point in the history
Using the `clad::array_ref` type is not necessary anymore, so we can
save some code.
  • Loading branch information
guitargeek committed Jul 9, 2024
1 parent b848606 commit e42b5a6
Showing 1 changed file with 1 addition and 12 deletions.
13 changes: 1 addition & 12 deletions roofit/roofitcore/src/RooFuncWrapper.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,6 @@ void RooFuncWrapper::createGradient()
{
std::string gradName = _funcName + "_grad_0";
std::string requestName = _funcName + "_req";
std::string wrapperName = _funcName + "_derivativeWrapper";

// Calculate gradient
declareToInterpreter("#include <Math/CladDerivator.h>\n");
Expand All @@ -164,17 +163,7 @@ void RooFuncWrapper::createGradient()
throw std::runtime_error(errorMsg.str().c_str());
}

// Build a wrapper over the derivative to hide clad specific types such as 'array_ref'.
// disable clang-format for making the following code unreadable.
// clang-format off
std::stringstream dWrapperStrm;
dWrapperStrm << "void " << wrapperName << "(double* params, double const* obs, double const* xlArr, double* out) {\n"
" clad::array_ref<double> cladOut(out, " << _params.size() << ");\n"
" " << gradName << "(params, obs, xlArr, cladOut);\n"
"}";
// clang-format on
declareToInterpreter(dWrapperStrm.str());
_grad = reinterpret_cast<Grad>(gInterpreter->ProcessLine((wrapperName + ";").c_str()));
_grad = reinterpret_cast<Grad>(gInterpreter->ProcessLine((gradName + ";").c_str()));
_hasGradient = true;
}

Expand Down

0 comments on commit e42b5a6

Please sign in to comment.