|
TDLS 0.2.0
Tiny Device-callable Linear Solvers
|
Exact floating-point value admissible as a template argument. More...
Go to the source code of this file.
Classes | |
| struct | tdls::StructuralReal< T > |
| Floating-point value stored as an odd integer mantissa and a power-of-two exponent, admissible as a template argument on every compiler supporting class-type non-type template parameters. More... | |
Exact floating-point value admissible as a template argument.
The solver configurations travel as class-type non-type template parameters, which C++20 restricts to structural types: every member must itself be structural. Floating-point members only became structural with P1907R1, a late C++20 addition whose support lags behind the rest of the standard (GCC 11, MSVC 19.29, and the EDG frontend of nvcc only from CUDA 13.0). Integer members, on the other hand, are accepted by every compiler implementing class-type template parameters at all (GCC 10, Clang 12, MSVC 19.28, nvcc 12.0).
StructuralReal therefore stores a floating-point value as an odd integer mantissa and a power-of-two exponent, m * 2^e. Every finite float or double value is represented exactly (53 significant bits fit the 63 of a signed 64-bit mantissa), and so is a long double value within those 63 bits, which every double literal is: a configuration threshold round-trips bit for bit and the solvers see exactly the value written by the caller. The representation is canonical (odd mantissa, zero as (0, 0)), so two configurations built from equal values name the same solver instantiation, as they would with plain floating-point members. Both directions are constant-evaluated: the solvers read the thresholds into static constexpr scalars at instantiation and no code of this header reaches a kernel.