![]() |
LINE Solver (C++)
Templated C++ port of the LINE queueing solver
|
The fdlibm elementary functions Java specifies, reproduced, for the code paths whose whole purpose is to land on the same bits as a Java reference. More...
#include <cmath>#include <cstdint>#include <cstring>#include <limits>Go to the source code of this file.
Namespaces | |
| namespace | line |
The fdlibm elementary functions Java specifies, reproduced, for the code paths whose whole purpose is to land on the same bits as a Java reference.
WHY THIS FILE EXISTS: libm IS NOT A FIXED FUNCTION. std::log1p is allowed a 1-ulp error and glibc changed which representative it returns between 2.35 and 2.39 (Ubuntu 22.04 vs 24.04). Measured over 200k draws, log1p and expm1 differ between those two while log, exp, pow, sqrt, lgamma and tgamma agree. In ordinary numerics a last-bit difference is noise, but a SEEDED discrete-event simulation is a chaotic map of its variates: one ulp on one interarrival reorders the event queue and the whole sample path parts company. That is not hypothetical – the same common/ldes binary, the same model.json and the same -s 100000 --seed 23000 gave QLen 98.565592 on a glibc-2.35 host and 98.562490 under the containerized MATLAB's glibc 2.39, against an ABSOLUTE 1e-3 gate on the recorded baseline.
WHY fdlibm IS THE RIGHT TARGET AND NOT MERELY A STABLE ONE. StrictMath IS fdlibm by specification, and Math.log1p was measured to agree with it on every one of 400k draws. Hashing raw bit patterns so the comparison is language-neutral, this implementation is bit-identical to both:
C, host glibc 2.35 16873585727775930126 C, container glibc 2.39 14249616856320735164 C, this file 12005405864943986042 Java Math.log1p 12005405864943986042 Java StrictMath.log1p 12005405864943986042
So routing the SSJ variate layer here does two things at once: it makes the engine reproduce itself on any glibc, and it moves it ONTO the Java engine's arithmetic rather than beside it. Only the seeded sample-path code should call these – the analytical APIs are free to use libm, where a last bit does not cascade.
Source: Sun's fdlibm s_log1p.c, the algorithm StrictMath.log1p is defined to use. Transcribed with its constants and branch structure intact.
Definition in file fdlibm.h.