diff --git a/src/math/gen/functions.h b/src/math/gen/functions.h index bdf0be8..596c21b 100644 --- a/src/math/gen/functions.h +++ b/src/math/gen/functions.h @@ -91,8 +91,8 @@ T(nearbyintl, l_l) T(nextafter, dd_d) T(nextafterf, ff_f) T(nextafterl, ll_l) -T(nexttoward, ll_d) -T(nexttowardf, ll_f) +T(nexttoward, dl_d) +T(nexttowardf, fl_f) T(nexttowardl, ll_l) T(pow, dd_d) T(powf, ff_f) diff --git a/src/math/gen/gensanity.sh b/src/math/gen/gensanity.sh index 3577059..949c4b6 100755 --- a/src/math/gen/gensanity.sh +++ b/src/math/gen/gensanity.sh @@ -31,7 +31,7 @@ EOF -0.67876370263940246316802166606111153 7 EOF ;; - dd_*|ff_*|ll_*) ./gen $N >$D/$N.h <$D/$N.h < +#include +#include "util.h" + +static struct ll_l t[] = { +#if LDBL_MANT_DIG == 53 +DHEADERS +#elif LDBL_MANT_DIG == 64 +HEADERS +#endif +}; + +int main(void) +{ + #pragma STDC FENV_ACCESS ON + long double y; + float d; + int e, i, err = 0; + struct ll_l *p; + + for (i = 0; i < sizeof t/sizeof *t; i++) { + p = t + i; + + if (p->r < 0) + continue; + fesetround(p->r); + feclearexcept(FE_ALL_EXCEPT); + y = ___(p->x, p->x2); + e = fetestexcept(INEXACT|INVALID|DIVBYZERO|UNDERFLOW|OVERFLOW); + + if (!checkexcept(e, p->e, p->r)) { + printf("%s:%d: bad fp exception: %s ___(%La,%La)=%La, want %s", + p->file, p->line, rstr(p->r), p->x, p->x2, p->y, estr(p->e)); + printf(" got %s\n", estr(e)); + err++; + } + d = ulperrl(y, p->y, p->dy); + if (!checkulp(d, p->r)) { + printf("%s:%d: %s ___(%La,%La) want %La got %La ulperr %.3f = %a + %a\n", + p->file, p->line, rstr(p->r), p->x, p->x2, p->y, y, d, d-p->dy, p->dy); + err++; + } + } + return !!err; +} diff --git a/src/math/gen/template/fl_f.c b/src/math/gen/template/fl_f.c new file mode 100644 index 0000000..962cce4 --- /dev/null +++ b/src/math/gen/template/fl_f.c @@ -0,0 +1,45 @@ +#include +#include +#include "util.h" + +static struct ll_l t[] = { +#if LDBL_MANT_DIG == 53 +DHEADERS +#elif LDBL_MANT_DIG == 64 +HEADERS +#endif +}; + +int main(void) +{ + #pragma STDC FENV_ACCESS ON + long double y; + float d; + int e, i, err = 0; + struct ll_l *p; + + for (i = 0; i < sizeof t/sizeof *t; i++) { + p = t + i; + + if (p->r < 0) + continue; + fesetround(p->r); + feclearexcept(FE_ALL_EXCEPT); + y = ___(p->x, p->x2); + e = fetestexcept(INEXACT|INVALID|DIVBYZERO|UNDERFLOW|OVERFLOW); + + if (!checkexcept(e, p->e, p->r)) { + printf("%s:%d: bad fp exception: %s ___(%La,%La)=%La, want %s", + p->file, p->line, rstr(p->r), p->x, p->x2, p->y, estr(p->e)); + printf(" got %s\n", estr(e)); + err++; + } + d = ulperrl(y, p->y, p->dy); + if (!checkulp(d, p->r)) { + printf("%s:%d: %s ___(%La,%La) want %La got %La ulperr %.3f = %a + %a\n", + p->file, p->line, rstr(p->r), p->x, p->x2, p->y, y, d, d-p->dy, p->dy); + err++; + } + } + return !!err; +} diff --git a/src/math/gen/template/ll_d.c b/src/math/gen/template/ll_d.c deleted file mode 100644 index 962cce4..0000000 --- a/src/math/gen/template/ll_d.c +++ /dev/null @@ -1,45 +0,0 @@ -#include -#include -#include "util.h" - -static struct ll_l t[] = { -#if LDBL_MANT_DIG == 53 -DHEADERS -#elif LDBL_MANT_DIG == 64 -HEADERS -#endif -}; - -int main(void) -{ - #pragma STDC FENV_ACCESS ON - long double y; - float d; - int e, i, err = 0; - struct ll_l *p; - - for (i = 0; i < sizeof t/sizeof *t; i++) { - p = t + i; - - if (p->r < 0) - continue; - fesetround(p->r); - feclearexcept(FE_ALL_EXCEPT); - y = ___(p->x, p->x2); - e = fetestexcept(INEXACT|INVALID|DIVBYZERO|UNDERFLOW|OVERFLOW); - - if (!checkexcept(e, p->e, p->r)) { - printf("%s:%d: bad fp exception: %s ___(%La,%La)=%La, want %s", - p->file, p->line, rstr(p->r), p->x, p->x2, p->y, estr(p->e)); - printf(" got %s\n", estr(e)); - err++; - } - d = ulperrl(y, p->y, p->dy); - if (!checkulp(d, p->r)) { - printf("%s:%d: %s ___(%La,%La) want %La got %La ulperr %.3f = %a + %a\n", - p->file, p->line, rstr(p->r), p->x, p->x2, p->y, y, d, d-p->dy, p->dy); - err++; - } - } - return !!err; -} diff --git a/src/math/gen/template/ll_f.c b/src/math/gen/template/ll_f.c deleted file mode 100644 index 962cce4..0000000 --- a/src/math/gen/template/ll_f.c +++ /dev/null @@ -1,45 +0,0 @@ -#include -#include -#include "util.h" - -static struct ll_l t[] = { -#if LDBL_MANT_DIG == 53 -DHEADERS -#elif LDBL_MANT_DIG == 64 -HEADERS -#endif -}; - -int main(void) -{ - #pragma STDC FENV_ACCESS ON - long double y; - float d; - int e, i, err = 0; - struct ll_l *p; - - for (i = 0; i < sizeof t/sizeof *t; i++) { - p = t + i; - - if (p->r < 0) - continue; - fesetround(p->r); - feclearexcept(FE_ALL_EXCEPT); - y = ___(p->x, p->x2); - e = fetestexcept(INEXACT|INVALID|DIVBYZERO|UNDERFLOW|OVERFLOW); - - if (!checkexcept(e, p->e, p->r)) { - printf("%s:%d: bad fp exception: %s ___(%La,%La)=%La, want %s", - p->file, p->line, rstr(p->r), p->x, p->x2, p->y, estr(p->e)); - printf(" got %s\n", estr(e)); - err++; - } - d = ulperrl(y, p->y, p->dy); - if (!checkulp(d, p->r)) { - printf("%s:%d: %s ___(%La,%La) want %La got %La ulperr %.3f = %a + %a\n", - p->file, p->line, rstr(p->r), p->x, p->x2, p->y, y, d, d-p->dy, p->dy); - err++; - } - } - return !!err; -} diff --git a/src/math/sanity/nexttoward.h b/src/math/sanity/nexttoward.h index 8cf5f43..277be41 100644 --- a/src/math/sanity/nexttoward.h +++ b/src/math/sanity/nexttoward.h @@ -1,10 +1,10 @@ -T(RN, -0x1.02239f3c6a8f13dep+3L, 0x1.22484b9ef31efd4p+2L, -0x1.02239f3c6a8fp+3, 0x0p+0, INEXACT) -T(RN, 0x1.161868e18bc67782p+2L, -0x1.1c6a6cdce75e83acp+3L, 0x1.161868e18bc66p+2, 0x0p+0, INEXACT) -T(RN, -0x1.0c34b3e01e6e682cp+3L, -0x1.61bde29e83f6cb16p+1L, -0x1.0c34b3e01e6e6p+3, 0x0p+0, INEXACT) -T(RN, -0x1.a206f0a19dcc3948p+2L, 0x1.24527f7b576abb6p+2L, -0x1.a206f0a19dcc3p+2, 0x0p+0, INEXACT) -T(RN, 0x1.288bbb0d6a1e5bdap+3L, 0x1.33edd910a3c00b7p+2L, 0x1.288bbb0d6a1e5p+3, 0x0p+0, INEXACT) -T(RN, -0x1.9ccd8be03f4949a2p+2L, 0x1.52fb12ef638a1222p-1L, -0x1.9ccd8be03f494p+2, 0x0p+0, INEXACT) -T(RN, 0x1.f6f80ed2eab43b22p+2L, 0x1.ab3ff8575b21cf92p-5L, 0x1.f6f80ed2eab43p+2, 0x0p+0, INEXACT) -T(RN, -0x1.95882b433fad2dd4p-1L, 0x1.eb4a2e7ce06930dap+2L, -0x1.95882b433fad2p-1, 0x0p+0, INEXACT) -T(RN, 0x1.3b3d617ae3c4a65p-1L, 0x1.01860611d75e1052p+1L, 0x1.3b3d617ae3c4bp-1, 0x0p+0, INEXACT) -T(RN, -0x1.1e159e36313ee67cp-1L, 0x1.081bd34224212bp-5L, -0x1.1e159e36313edp-1, 0x0p+0, INEXACT) +T(RN, -0x1.02239f3c6a8f1p+3, 0x1.22484b9ef31efd4p+2L, -0x1.02239f3c6a8fp+3, 0x0p+0, 0) +T(RN, 0x1.161868e18bc67p+2, -0x1.1c6a6cdce75e83acp+3L, 0x1.161868e18bc66p+2, 0x0p+0, 0) +T(RN, -0x1.0c34b3e01e6e7p+3, -0x1.61bde29e83f6cb16p+1L, -0x1.0c34b3e01e6e6p+3, 0x0p+0, 0) +T(RN, -0x1.a206f0a19dcc4p+2, 0x1.24527f7b576abb6p+2L, -0x1.a206f0a19dcc3p+2, 0x0p+0, 0) +T(RN, 0x1.288bbb0d6a1e6p+3, 0x1.33edd910a3c00b7p+2L, 0x1.288bbb0d6a1e5p+3, 0x0p+0, 0) +T(RN, -0x1.9ccd8be03f495p+2, 0x1.52fb12ef638a1222p-1L, -0x1.9ccd8be03f494p+2, 0x0p+0, 0) +T(RN, 0x1.f6f80ed2eab44p+2, 0x1.ab3ff8575b21cf92p-5L, 0x1.f6f80ed2eab43p+2, 0x0p+0, 0) +T(RN, -0x1.95882b433fad3p-1, 0x1.eb4a2e7ce06930dap+2L, -0x1.95882b433fad2p-1, 0x0p+0, 0) +T(RN, 0x1.3b3d617ae3c4ap-1, 0x1.01860611d75e1052p+1L, 0x1.3b3d617ae3c4bp-1, 0x0p+0, 0) +T(RN, -0x1.1e159e36313eep-1, 0x1.081bd34224212bp-5L, -0x1.1e159e36313edp-1, 0x0p+0, 0) diff --git a/src/math/sanity/nexttowardf.h b/src/math/sanity/nexttowardf.h index a403d33..c6d2d51 100644 --- a/src/math/sanity/nexttowardf.h +++ b/src/math/sanity/nexttowardf.h @@ -1,10 +1,10 @@ -T(RN, -0x1.02239f3c6a8f13dep+3L, 0x1.22484b9ef31efd4p+2L, -0x1.02239ep+3, 0x0p+0, INEXACT) -T(RN, 0x1.161868e18bc67782p+2L, -0x1.1c6a6cdce75e83acp+3L, 0x1.161866p+2, 0x0p+0, INEXACT) -T(RN, -0x1.0c34b3e01e6e682cp+3L, -0x1.61bde29e83f6cb16p+1L, -0x1.0c34b2p+3, 0x0p+0, INEXACT) -T(RN, -0x1.a206f0a19dcc3948p+2L, 0x1.24527f7b576abb6p+2L, -0x1.a206eep+2, 0x0p+0, INEXACT) -T(RN, 0x1.288bbb0d6a1e5bdap+3L, 0x1.33edd910a3c00b7p+2L, 0x1.288bbap+3, 0x0p+0, INEXACT) -T(RN, -0x1.9ccd8be03f4949a2p+2L, 0x1.52fb12ef638a1222p-1L, -0x1.9ccd8ap+2, 0x0p+0, INEXACT) -T(RN, 0x1.f6f80ed2eab43b22p+2L, 0x1.ab3ff8575b21cf92p-5L, 0x1.f6f80cp+2, 0x0p+0, INEXACT) -T(RN, -0x1.95882b433fad2dd4p-1L, 0x1.eb4a2e7ce06930dap+2L, -0x1.95882ap-1, 0x0p+0, INEXACT) -T(RN, 0x1.3b3d617ae3c4a65p-1L, 0x1.01860611d75e1052p+1L, 0x1.3b3d64p-1, 0x0p+0, INEXACT) -T(RN, -0x1.1e159e36313ee67cp-1L, 0x1.081bd34224212bp-5L, -0x1.1e159cp-1, 0x0p+0, INEXACT) +T(RN, -0x1.0223ap+3, 0x1.22484b9ef31efd4p+2L, -0x1.02239ep+3, 0x0p+0, 0) +T(RN, 0x1.161868p+2, -0x1.1c6a6cdce75e83acp+3L, 0x1.161866p+2, 0x0p+0, 0) +T(RN, -0x1.0c34b4p+3, -0x1.61bde29e83f6cb16p+1L, -0x1.0c34b2p+3, 0x0p+0, 0) +T(RN, -0x1.a206fp+2, 0x1.24527f7b576abb6p+2L, -0x1.a206eep+2, 0x0p+0, 0) +T(RN, 0x1.288bbcp+3, 0x1.33edd910a3c00b7p+2L, 0x1.288bbap+3, 0x0p+0, 0) +T(RN, -0x1.9ccd8cp+2, 0x1.52fb12ef638a1222p-1L, -0x1.9ccd8ap+2, 0x0p+0, 0) +T(RN, 0x1.f6f80ep+2, 0x1.ab3ff8575b21cf92p-5L, 0x1.f6f80cp+2, 0x0p+0, 0) +T(RN, -0x1.95882cp-1, 0x1.eb4a2e7ce06930dap+2L, -0x1.95882ap-1, 0x0p+0, 0) +T(RN, 0x1.3b3d62p-1, 0x1.01860611d75e1052p+1L, 0x1.3b3d64p-1, 0x0p+0, 0) +T(RN, -0x1.1e159ep-1, 0x1.081bd34224212bp-5L, -0x1.1e159cp-1, 0x0p+0, 0)