13#ifndef ROOFIT_BATCHCOMPUTE_ROONANPACKER_H
14#define ROOFIT_BATCHCOMPUTE_ROONANPACKER_H
43 static constexpr uint64_t
magicTag = 0x321ab00000000;
58 _payload = std::numeric_limits<double>::quiet_NaN();
69 double sum = std::accumulate(begin, end, 0.f, [](
float acc,
double val) {
return acc +=
unpackNaN(val); });
102 std::memcpy(&tmp, &val,
sizeof(uint64_t));
111 double result = std::numeric_limits<double>::quiet_NaN();
113 std::memcpy(&tmp, &
result,
sizeof(uint64_t));
115 std::memcpy(&tmp, &payload,
sizeof(
float));
116 std::memcpy(&
result, &tmp,
sizeof(uint64_t));
126 std::memcpy(&tmp, &val,
sizeof(
float));
133 static bool haveWarned =
false;
136 "Fast recovery from undefined function values only implemented for little-endian machines."
137 " If necessary, request an extension of functionality on https://root.cern");
void Warning(const char *location, const char *msgfmt,...)
Use this function in warning situations.
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t result
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void value
Little struct that can pack a float into the unused bits of the mantissa of a NaN double.
static constexpr uint64_t magicTag
bool isNaNWithPayload() const
Test if this struct has a float packed into its mantissa.
__roodevice__ static __roohost__ double packFloatIntoNaN(float payload)
Pack float into mantissa of a NaN.
float getPayload() const
Retrieve packed float.
static bool isNaNWithPayload(double val)
Test if val has a float packed into its mantissa.
static constexpr uint64_t magicTagMask
void setPayload(float payload)
Pack float into mantissa of NaN.
RooNaNPacker(float value)
Create NaN with a packed floating point number.
double getNaNWithPayload() const
Retrieve a NaN with the current float payload packed into the mantissa.
RooNaNPacker & operator*=(float val)
Multiply the packed float.
static double accumulatePayloads(It_t begin, It_t end)
Unpack floats from NaNs, and sum the packed values.
static float unpackNaN(double val)
If val is NaN and a this NaN has been tagged as containing a payload, unpack the float from the manti...
void accumulate(double val)
Accumulate a packed float from another NaN into this.
RooNaNPacker & operator+=(float val)
Add to the packed float.
static void warn()
Warn that packing only works on little-endian machines.
static uint64_t sum(uint64_t i)