ftz 0.0.1
Fast, reproducible floating-point arithmetic
Loading...
Searching...
No Matches
exp_coefficients.h
1#pragma once
2// SPDX-FileCopyrightText: 2026 Edward Kmett <ekmett@gmail.com>
3// SPDX-License-Identifier: BSD-2-Clause OR Apache-2.0
4
5// Coefficient words shared by the C++ and HLSL fused Horner stages.
6// Degrees 1..5 are constant-one relative fits; degree 6 is the constant-one
7// absolute fit with linear term one. Degree 7 retains the original graph.
8// See tests/exp_fit for the fitting scripts and accuracy limitations.
9namespace ftz { namespace detail { namespace math {
10 template <unsigned int Degree> struct exp_coefficients;
11 template <> struct exp_coefficients<1> {
12 static const unsigned int leading = 0x3f76382au;
13 static const unsigned int next = 0x3f800000u;
14 static const unsigned int c5 = 0x00000000u;
15 static const unsigned int c4 = 0x00000000u;
16 static const unsigned int c3 = 0x00000000u;
17 static const unsigned int c2 = 0x00000000u;
18 static const unsigned int c1 = 0x3f76382au;
19 static const unsigned int c0 = 0x3f800000u;
20 };
21 template <> struct exp_coefficients<2> {
22 static const unsigned int leading = 0x3eff9d09u;
23 static const unsigned int next = 0x3f81cf0bu;
24 static const unsigned int c5 = 0x00000000u;
25 static const unsigned int c4 = 0x00000000u;
26 static const unsigned int c3 = 0x00000000u;
27 static const unsigned int c2 = 0x3eff9d09u;
28 static const unsigned int c1 = 0x3f81cf0bu;
29 static const unsigned int c0 = 0x3f800000u;
30 };
31 template <> struct exp_coefficients<3> {
32 static const unsigned int leading = 0x3e2924d1u;
33 static const unsigned int next = 0x3f010eb2u;
34 static const unsigned int c5 = 0x00000000u;
35 static const unsigned int c4 = 0x00000000u;
36 static const unsigned int c3 = 0x3e2924d1u;
37 static const unsigned int c2 = 0x3f010eb2u;
38 static const unsigned int c1 = 0x3f80066bu;
39 static const unsigned int c0 = 0x3f800000u;
40 };
41 template <> struct exp_coefficients<4> {
42 static const unsigned int leading = 0x3d2a0993u;
43 static const unsigned int next = 0x3e2be74cu;
44 static const unsigned int c5 = 0x00000000u;
45 static const unsigned int c4 = 0x3d2a0993u;
46 static const unsigned int c3 = 0x3e2be74cu;
47 static const unsigned int c2 = 0x3f0001fbu;
48 static const unsigned int c1 = 0x3f7ffdd4u;
49 static const unsigned int c0 = 0x3f800000u;
50 };
51 template <> struct exp_coefficients<5> {
52 static const unsigned int leading = 0x3c07cfd2u;
53 static const unsigned int next = 0x3d2b9d0eu;
54 static const unsigned int c5 = 0x3c07cfd2u;
55 static const unsigned int c4 = 0x3d2b9d0eu;
56 static const unsigned int c3 = 0x3e2aad40u;
57 static const unsigned int c2 = 0x3efffee3u;
58 static const unsigned int c1 = 0x3f7ffffbu;
59 static const unsigned int c0 = 0x3f800000u;
60 };
61 template <> struct exp_coefficients<6> {
62 static const unsigned int leading = 0x3ab6aafau;
63 static const unsigned int next = 0x3c091f16u;
64 static const unsigned int c5 = 0x3c091f16u;
65 static const unsigned int c4 = 0x3d2aaa70u;
66 static const unsigned int c3 = 0x3e2aaa45u;
67 static const unsigned int c2 = 0x3f000000u;
68 static const unsigned int c1 = 0x3f800000u;
69 static const unsigned int c0 = 0x3f800000u;
70 };
71 template <> struct exp_coefficients<7> {
72 static const unsigned int leading = 0x3950eb8au;
73 static const unsigned int next = 0x3ab6d3abu;
74 static const unsigned int c5 = 0x3c08882eu;
75 static const unsigned int c4 = 0x3d2aaa32u;
76 static const unsigned int c3 = 0x3e2aaaabu;
77 static const unsigned int c2 = 0x3f000000u;
78 static const unsigned int c1 = 0x3f800000u;
79 static const unsigned int c0 = 0x3f800000u;
80 };
81}}}