39static inline double fast_fma(
40 const double x,
const double y,
const double z)
noexcept
42#if defined(FP_FAST_FMA)
43 return std::fma(
x,
y, z);
47#pragma STDC FP_CONTRACT ON
54enum class Kind :
int { First = 1, Second = 2 };
61template <
typename T, Kind KIND>
62class ChebychevIterator {
70 constexpr ChebychevIterator() =
default;
72 ChebychevIterator(
const ChebychevIterator &) =
default;
74 ChebychevIterator(ChebychevIterator &&) =
default;
76 constexpr ChebychevIterator(
const T &
x)
77 : _curr(static_cast<int>(KIND) *
x), _twox(2 *
x)
81 ChebychevIterator &
operator=(
const ChebychevIterator &) =
default;
83 ChebychevIterator &
operator=(ChebychevIterator &&) =
default;
86 constexpr inline T operator*() const noexcept {
return _last; }
88 constexpr inline T lookahead() const noexcept {
return _curr; }
90 inline ChebychevIterator &operator++() noexcept
93 T newval = _twox*_curr -_last;
99 inline ChebychevIterator operator++(
int)
noexcept
101 ChebychevIterator retVal(*
this);
120 _x(
"x",
"Dependent", this,
x),
121 _coefList(
"coefficients",
"List of coefficients",this),
124 for (
const auto coef : coefList) {
127 ") ERROR: coefficient " << coef->GetName() <<
128 " is not of type RooAbsReal" << std::endl ;
129 throw std::invalid_argument(
"Wrong input arguments for RooChebychev");
139 _x(
"x", this, other._x),
140 _coefList(
"coefList",this,other._coefList),
141 _refRangeName(other._refRangeName)
169 using size_type =
typename RooListProxy::Storage_t::size_type;
173 ChebychevIterator<double, Kind::First> chit(
x);
175 for (size_type i = 0; iend != i; ++i, ++chit) {
189void compute(
size_t batchSize,
double xmax,
double xmin,
190 double * __restrict
output,
191 const double * __restrict
const xData,
194 constexpr size_t block = 128;
195 const size_t nCoef = _coefList.
size();
198 for (
size_t i=0; i<batchSize; i+=
block) {
199 size_t stop = (i+
block >= batchSize) ? batchSize-i :
block;
203 for (
size_t j=0; j<stop; j++) {
204 prev[j][0] =
output[i+j] = 1.0;
208 for (
size_t k=0; k<nCoef; k++) {
209 const double coef =
static_cast<const RooAbsReal &
>(_coefList[k]).getVal();
210 for (
size_t j=0; j<stop; j++) {
211 output[i+j] += prev[j][1]*coef;
214 const double next = 2*X[j]*prev[j][1] -prev[j][0];
215 prev[j][0] = prev[j][1];
230 batchSize = xData.size();
249 assert(1 == code); (
void)code;
272 using size_type =
typename RooListProxy::Storage_t::size_type;
281 ChebychevIterator<double, Kind::First> bit(
b), ait(
a);
284 for (size_type i = 1; iend != i; ++i) {
287 const double term2 = (*bit - *ait) / nminus1;
288 ++bit, ++ait, ++nminus1;
289 const double term1 = (bit.lookahead() - ait.lookahead()) / (nminus1 + 1.);
290 const double intTn = 0.5 * (term1 - term2);
Binding & operator=(OUT(*fun)(void))
typedef void((*Func_t)())
TTime operator*(const TTime &t1, const TTime &t2)
RooSpan< double > makeWritableBatchUnInit(std::size_t begin, std::size_t batchSize)
Make a batch and return a span pointing to the pdf-local memory.
Storage_t::size_type size() const
RooAbsReal is the common abstract base class for objects that represent a real value and implements f...
Bool_t matchArgs(const RooArgSet &allDeps, RooArgSet &numDeps, const RooArgProxy &a) const
Utility function for use in getAnalyticalIntegral().
Double_t getVal(const RooArgSet *normalisationSet=nullptr) const
Evaluate object.
BatchHelpers::BatchData _batchData
RooArgList is a container object that can hold multiple RooAbsArg objects.
RooArgSet is a container object that can hold multiple RooAbsArg objects.
Chebychev polynomial p.d.f.
RooSpan< double > evaluateBatch(std::size_t begin, std::size_t batchSize) const
Evaluate function for a batch of input data points.
virtual void selectNormalizationRange(const char *rangeName=0, Bool_t force=kFALSE)
Interface function to force use of a given normalization range to interpret function value.
Int_t getAnalyticalIntegral(RooArgSet &allVars, RooArgSet &analVars, const char *rangeName=0) const
Interface function getAnalyticalIntergral advertises the analytical integrals that are supported.
Double_t evaluate() const
Evaluate this PDF / function / constant. Needs to be overridden by all derived classes.
Double_t evalAnaInt(const Double_t a, const Double_t b) const
Double_t analyticalIntegral(Int_t code, const char *rangeName=0) const
Implements the actual analytical integral(s) advertised by getAnalyticalIntegral.
RooListProxy is the concrete proxy for RooArgList objects.
virtual Bool_t add(const RooAbsArg &var, Bool_t silent=kFALSE)
Reimplementation of standard RooArgList::add()
const TNamed * constPtr(const char *stringPtr)
Return a unique TNamed pointer for given C++ string.
static RooNameReg & instance()
Return reference to singleton instance.
A simple container to hold a batch of data values.
Double_t min(const char *rname=0) const
Query lower limit of range. This requires the payload to be RooAbsRealLValue or derived.
RooSpan< const double > getValBatch(std::size_t begin, std::size_t batchSize) const
Double_t max(const char *rname=0) const
Query upper limit of range. This requires the payload to be RooAbsRealLValue or derived.
The TNamed class is the base class for all named ROOT classes.
virtual const char * GetName() const
Returns name of object.
static long int sum(long int i)
static void output(int code)