8#ifndef ROOFIT_ROOFITCORE_INC_ROONANPACKER_H_
9#define ROOFIT_ROOFITCORE_INC_ROONANPACKER_H_
36 static constexpr uint64_t
magicTag = 0x321ab00000000;
52 _payload = std::numeric_limits<double>::quiet_NaN();
64 double sum = std::accumulate(begin, end, 0.f, [](
float acc,
double val) {
102 std::memcpy(&tmp, &val,
sizeof(uint64_t));
110 double result = std::numeric_limits<double>::quiet_NaN();
112 std::memcpy(&tmp, &result,
sizeof(uint64_t));
114 std::memcpy(&tmp, &payload,
sizeof(
float));
115 std::memcpy(&result, &tmp,
sizeof(uint64_t));
124 std::memcpy(&tmp, &val,
sizeof(
float));
130 static bool haveWarned =
false;
132 Warning(
"RooNaNPacker",
"Fast recovery from undefined function values only implemented for little-endian machines."
133 " 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.
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.
float getPayload() const
Retrieve packed float.
static bool isNaNWithPayload(double val)
Test if val has a float packed into its mantissa.
static double packFloatIntoNaN(float payload)
Pack float into mantissa of a NaN.
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)