]> sourceware.org Git - glibc.git/commitdiff
replace tgammaf by the CORE-MATH implementation master
authorPaul Zimmermann <Paul.Zimmermann@inria.fr>
Tue, 8 Oct 2024 09:28:04 +0000 (11:28 +0200)
committerPaul Zimmermann <Paul.Zimmermann@inria.fr>
Fri, 11 Oct 2024 09:12:32 +0000 (11:12 +0200)
The CORE-MATH implementation is correctly rounded (for any rounding mode).
This can be checked by exhaustive tests in a few minutes since there are
less than 2^32 values to check against for example GNU MPFR.
This patch also adds some bench values for tgammaf.

Tested on x86_64 and x86 (cfarm26).

With the initial GNU libc code it gave on an Intel(R) Core(TM) i7-8700:

      "tgammaf": {
       "": {
        "duration": 3.50188e+09,
        "iterations": 2e+07,
        "max": 602.891,
        "min": 65.1415,
        "mean": 175.094
       }
      }

With the new code:

      "tgammaf": {
       "": {
        "duration": 3.30825e+09,
        "iterations": 5e+07,
        "max": 211.592,
        "min": 32.0325,
        "mean": 66.1649
       }
      }

With the initial GNU libc code it gave on cfarm26 (i686):

  "tgammaf": {
   "": {
    "duration": 3.70505e+09,
    "iterations": 6e+06,
    "max": 2420.23,
    "min": 243.154,
    "mean": 617.509
   }
  }

With the new code:

  "tgammaf": {
   "": {
    "duration": 3.24497e+09,
    "iterations": 1.8e+07,
    "max": 1238.15,
    "min": 101.155,
    "mean": 180.276
   }
  }

Signed-off-by: Alexei Sibidanov <sibid@uvic.ca>
Signed-off-by: Paul Zimmermann <Paul.Zimmermann@inria.fr>
Changes in v2:
    - include <math.h> (fix the linknamespace failures)
    - restored original benchtests/strcoll-inputs/filelist#en_US.UTF-8 file
    - restored original wrapper code (math/w_tgammaf_compat.c),
      except for the dealing with the sign
    - removed the tgammaf/float entries in all libm-test-ulps files
    - address other comments from Joseph Myers
      (https://sourceware.org/pipermail/libc-alpha/2024-July/158736.html)

Changes in v3:
    - pass NULL argument for signgam from w_tgammaf_compat.c
    - use of math_narrow_eval
    - added more comments

Changes in v4:
    - initialize local_signgam to 0 in math/w_tgamma_template.c
    - replace sysdeps/ieee754/dbl-64/gamma_productf.c by dummy file

Changes in v5:
    - do not mention local_signgam any more in math/w_tgammaf_compat.c
    - initialize local_signgam to 1 instead of 0 in w_tgamma_template.c
      and added comment

Changes in v6:
    - pass NULL as 2nd argument of __ieee754_gammaf_r in
      w_tgammaf_compat.c, and check for NULL in e_gammaf_r.c

Changes in v7:
    - added Signed-off-by line for Alexei Sibidanov (author of the code)

Changes in v8:
    - added Signed-off-by line for Paul Zimmermann (submitted of the patch)

Changes in v9:
    - address comments from review by Adhemerval Zanella
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
33 files changed:
SHARED-FILES
benchtests/Makefile
benchtests/tgammaf-inputs [new file with mode: 0644]
math/w_tgammaf_compat.c
sysdeps/aarch64/libm-test-ulps
sysdeps/alpha/fpu/libm-test-ulps
sysdeps/arc/fpu/libm-test-ulps
sysdeps/arc/nofpu/libm-test-ulps
sysdeps/arm/libm-test-ulps
sysdeps/csky/fpu/libm-test-ulps
sysdeps/csky/nofpu/libm-test-ulps
sysdeps/hppa/fpu/libm-test-ulps
sysdeps/i386/fpu/libm-test-ulps
sysdeps/i386/i686/fpu/multiarch/libm-test-ulps
sysdeps/ieee754/dbl-64/gamma_productf.c
sysdeps/ieee754/flt-32/e_gammaf_r.c
sysdeps/loongarch/lp64/libm-test-ulps
sysdeps/m68k/coldfire/fpu/libm-test-ulps
sysdeps/m68k/m680x0/fpu/libm-test-ulps
sysdeps/microblaze/libm-test-ulps
sysdeps/mips/mips32/libm-test-ulps
sysdeps/mips/mips64/libm-test-ulps
sysdeps/nios2/libm-test-ulps
sysdeps/or1k/fpu/libm-test-ulps
sysdeps/or1k/nofpu/libm-test-ulps
sysdeps/powerpc/fpu/libm-test-ulps
sysdeps/powerpc/nofpu/libm-test-ulps
sysdeps/riscv/nofpu/libm-test-ulps
sysdeps/riscv/rvd/libm-test-ulps
sysdeps/s390/fpu/libm-test-ulps
sysdeps/sh/libm-test-ulps
sysdeps/sparc/fpu/libm-test-ulps
sysdeps/x86_64/fpu/libm-test-ulps

index d84e8e9697285610f03267e4199aba4435c6c586..2aefac8a9562ec0597e53e21ce4c48f220e19d95 100644 (file)
@@ -219,3 +219,15 @@ tzdata:
   timezone/leapseconds
   # This is yearistype.sh in the parent project
   timezone/yearistype
+
+# The following files are shared with the CORE-MATH project
+sysdeps/ieee754/flt-32/e_gammaf_r.c
+  (file src/binary32/tgamma/tgammaf.c in CORE-MATH)
+  Instructions to merge new versions:
+  - change the function name from cr_tgammaf to __ieee754_gammaf_r
+  - add "int *signgamp" as 2nd argument and add at the beginning:
+    if (signgamp != NULL) *signgamp = 1;
+  - remove the errno stuff (this is done by the wrapper)
+  - replace 0x1p127f * 0x1p127f by math_narrow_eval (x * 0x1p127f)
+  - replace 0x1p-127f * sgn[k&1] by math_narrow_eval (0x1p-127f * sgn[k&1])
+  - add libm_alias_finite (__ieee754_gammaf_r, __gammaf_r) at the end
index d228e9e68af3d73129591f3d875d6be545182eac..79d802aaf07268cf68e6a06e6bb1eb831f04fc67 100644 (file)
@@ -94,6 +94,7 @@ bench-math := \
   tan \
   tanh \
   tgamma \
+  tgammaf \
   trunc \
   truncf \
   y0 \
diff --git a/benchtests/tgammaf-inputs b/benchtests/tgammaf-inputs
new file mode 100644 (file)
index 0000000..b2baf5c
--- /dev/null
@@ -0,0 +1,1006 @@
+## includes: math.h
+## args: float
+## ret: float
+
+# Random inputs in [-a,a=0x1.18522ep+5)
+# where a is the smallest number such that tgammaf rounds to +Inf (to nearest)
+0x1.714acp+2
+0x1.0f4884p+4
+-0x1.16b54p+1
+0x1.238ef4p+4
+0x1.4896ap+4
+-0x1.714e7p+2
+0x1.c254cp+4
+0x1.c76928p+3
+0x1.0b82acp+5
+-0x1.a4d6dp+2
+0x1.16f3ap+2
+0x1.43a5bp+2
+-0x1.da2ef8p+4
+0x1.f7c01p+2
+0x1.f5b698p+4
+-0x1.3dcbccp+3
+0x1.34238p+3
+-0x1.0b6364p+5
+-0x1.1c820cp+4
+-0x1.bcdeccp+4
+0x1.481cdp+3
+0x1.83fbf8p+4
+0x1.18504cp+5
+-0x1.b65098p+4
+0x1.5aa868p+4
+-0x1.8f06ap+3
+-0x1.a8d468p+2
+0x1.11a554p+5
+0x1.b47368p+4
+0x1.df0d08p+4
+-0x1.f80fcap+4
+0x1.c9cda4p+4
+0x1.785454p+4
+-0x1.af1b08p+2
+-0x1.0f6e86p+5
+0x1.869148p+3
+0x1.054cp+1
+0x1.f545dp+4
+-0x1.20e18p+1
+0x1.ec8cd8p+4
+-0x1.047434p+5
+-0x1.059518p+5
+0x1.6c32bp+2
+0x1.e72af8p+4
+-0x1.8e6d38p+4
+-0x1.5173ep+2
+0x1.0df39p+5
+-0x1.98be5p+4
+0x1.d16e8p-1
+-0x1.8d11ap+2
+-0x1.10bc48p+5
+0x1.99a9bp+3
+0x1.ea951p+2
+-0x1.38a44p+3
+-0x1.e303f2p+4
+0x1.3efc18p+3
+-0x1.d4510cp+3
+0x1.10a078p+3
+0x1.75f644p+4
+-0x1.b0b2c2p+4
+-0x1.dc58ep+1
+0x1.be8c2p+2
+-0x1.ad4244p+4
+0x1.4bdd88p+3
+0x1.7e3b98p+3
+-0x1.47af9p+2
+-0x1.26b82p+2
+-0x1.d8bd38p+4
+0x1.348244p+4
+0x1.5b6f4p+0
+-0x1.0f1764p+5
+-0x1.eea53p+2
+0x1.17cdbp+4
+-0x1.c0d6fp+1
+0x1.5d8fbcp+4
+-0x1.46e70cp+4
+0x1.a7379p+2
+-0x1.c537b8p+2
+0x1.65fdfp+2
+-0x1.573a14p+4
+-0x1.f6d328p+2
+0x1.3fa52p+3
+-0x1.9e64d4p+3
+-0x1.d1f208p+4
+0x1.daff8p+1
+-0x1.f85f48p+3
+-0x1.aa2b78p+4
+-0x1.1d6d14p+3
+0x1.06be64p+5
+-0x1.00671cp+4
+0x1.eeb7p-2
+0x1.10efdp+2
+0x1.de3fc8p+4
+-0x1.1da752p+4
+0x1.76392p+4
+-0x1.acd59p+4
+0x1.3db448p+3
+-0x1.2ef648p+4
+-0x1.30f1e8p+4
+-0x1.d3de8ep+4
+-0x1.e9566p+3
+-0x1.9ea03cp+3
+-0x1.f0158p-1
+-0x1.ff9bbp+1
+-0x1.3a3454p+3
+-0x1.87b4e4p+3
+0x1.3ea26p+1
+0x1.638248p+4
+-0x1.125e42p+4
+0x1.cc892cp+4
+0x1.b01cap+4
+0x1.d24a08p+3
+0x1.a2a1e8p+4
+0x1.15e17p+5
+0x1.10825p+5
+0x1.daad88p+4
+-0x1.21f976p+4
+-0x1.031fbcp+4
+-0x1.17fd7ep+5
+0x1.126018p+4
+-0x1.e621bp+4
+0x1.c4cf78p+3
+0x1.53dcd4p+4
+-0x1.8b519cp+4
+-0x1.69dacp+0
+0x1.4172ep+2
+0x1.160e68p+4
+0x1.a7da7p+4
+-0x1.decd6cp+4
+0x1.4b2bap+3
+0x1.806868p+3
+0x1.427174p+4
+-0x1.f04p-2
+0x1.0c93d8p+4
+0x1.093c6p+2
+-0x1.082e6ep+5
+-0x1.181a92p+5
+-0x1.19dfbp+2
+-0x1.98fef8p+2
+0x1.a77e94p+4
+0x1.1ad3cp+0
+-0x1.39c9bcp+3
+-0x1.ea251cp+4
+0x1.dec54p+2
+0x1.cc7e1cp+4
+0x1.6d9f1p+2
+-0x1.fe9198p+2
+-0x1.026232p+4
+0x1.08ad5p+5
+-0x1.43db28p+4
+-0x1.c4139ap+4
+0x1.bd6538p+4
+-0x1.a1ca9p+3
+-0x1.100adap+4
+0x1.1642p+5
+0x1.5a583p+3
+-0x1.902c5ap+4
+0x1.12f3ap+3
+0x1.0762a4p+5
+0x1.dea9e8p+4
+0x1.73af2p+4
+-0x1.51b6p+2
+0x1.e5fdf8p+3
+-0x1.2cdf44p+3
+-0x1.15518ep+5
+0x1.8481cp+1
+0x1.14c8ap+5
+-0x1.e34466p+4
+-0x1.2e8a6ep+4
+-0x1.edbcap+2
+-0x1.a34a2p+3
+0x1.62ba48p+4
+-0x1.48a09cp+3
+0x1.365f9p+2
+-0x1.e31778p+3
+0x1.373324p+4
+0x1.2a03p+2
+-0x1.4304dcp+4
+0x1.abb9dcp+4
+0x1.0dc9ap+5
+-0x1.b292f4p+4
+0x1.c72028p+3
+-0x1.78e0a4p+4
+-0x1.25c21cp+4
+0x1.155e5p+2
+-0x1.edba2p+3
+-0x1.dc87a6p+4
+0x1.44f16p+3
+-0x1.35781p+3
+0x1.b1acfp+4
+-0x1.c4c57p+3
+-0x1.c6ca42p+4
+-0x1.619604p+3
+-0x1.1f1f2p+2
+0x1.1ed8p+0
+0x1.76619cp+4
+-0x1.382454p+3
+-0x1.5270ep+1
+-0x1.16be2p+1
+0x1.4062fp+2
+-0x1.9fd7a8p+2
+-0x1.e1d9d8p+4
+0x1.ad37d8p+3
+-0x1.c78fecp+4
+-0x1.fbc6bp+2
+-0x1.e4c7dcp+3
+0x1.e5efp+2
+-0x1.28d7c8p+4
+0x1.72d978p+3
+0x1.37137cp+4
+-0x1.53ec9cp+3
+0x1.66a2bp+3
+0x1.9a4ep-3
+0x1.1140e4p+4
+0x1.16ed74p+5
+0x1.a82d78p+3
+0x1.975b0cp+4
+0x1.ca4ebp+3
+-0x1.589c6ap+4
+0x1.8ef3cp+2
+0x1.e2b6p+2
+-0x1.6b87f8p+2
+0x1.24f1e8p+4
+0x1.3a7a8p+4
+-0x1.f984f2p+4
+-0x1.a401p-1
+0x1.956ec8p+4
+-0x1.db5688p+4
+0x1.36f2ap+3
+-0x1.d1107p+3
+-0x1.b25828p+2
+-0x1.ffd308p+4
+0x1.3ec6c4p+4
+-0x1.721c04p+4
+0x1.d9e568p+4
+0x1.a293a8p+3
+0x1.10c4d8p+5
+0x1.cbe78p+0
+0x1.1052c8p+3
+0x1.32e02p+1
+0x1.be4b2p+4
+0x1.b1e164p+4
+-0x1.4dedb8p+4
+-0x1.52518cp+3
+-0x1.ddb38p-1
+-0x1.42cd08p+4
+0x1.2154d4p+4
+-0x1.067cc8p+4
+-0x1.767908p+4
+-0x1.3a2d44p+4
+-0x1.705b12p+4
+-0x1.de6e8p+0
+0x1.626488p+4
+-0x1.69fe64p+4
+-0x1.9f53eep+4
+-0x1.d6668p+0
+0x1.40e7c8p+4
+0x1.0f18bp+2
+0x1.7d9204p+4
+-0x1.40e0c2p+4
+0x1.3ca2p-1
+0x1.d0cf4p+4
+-0x1.9af13p+1
+0x1.49159p+3
+0x1.0e886cp+4
+-0x1.387932p+4
+-0x1.76d0b2p+4
+0x1.e3a888p+4
+0x1.95945p+3
+-0x1.f11fccp+3
+-0x1.f94b88p+3
+-0x1.5c3164p+4
+0x1.7042fp+4
+0x1.7b4304p+4
+0x1.193fcp+0
+-0x1.a69a94p+3
+0x1.fca03p+2
+0x1.a8b48p+1
+-0x1.4b058cp+3
+0x1.f889cp+4
+0x1.216c5cp+4
+0x1.4abf8p+3
+-0x1.903e98p+3
+0x1.002418p+5
+-0x1.81bd24p+4
+0x1.bcd70cp+4
+-0x1.27c00ap+4
+0x1.82ff1p+2
+0x1.a61df8p+3
+0x1.cc60d8p+3
+-0x1.36d58p+4
+0x1.35c0e4p+4
+-0x1.0cca7ap+5
+-0x1.f7191p+1
+0x1.064398p+5
+0x1.326608p+3
+0x1.6e83ep+3
+0x1.f9d508p+4
+0x1.aef608p+4
+-0x1.78885cp+4
+0x1.2a9f6p+4
+-0x1.3852c4p+4
+0x1.f53fe8p+4
+0x1.54b6cp+0
+-0x1.07f15cp+5
+-0x1.6d6c6cp+4
+0x1.836434p+4
+-0x1.f2d5b8p+2
+0x1.28f9c8p+3
+0x1.7e7d6cp+4
+-0x1.dcc444p+4
+0x1.aba548p+4
+0x1.c8b9f4p+4
+0x1.3b2d8p+3
+0x1.f0f87p+4
+0x1.526da8p+4
+-0x1.387fb8p+4
+-0x1.4167fp+4
+-0x1.570d18p+3
+0x1.aaedb8p+3
+-0x1.b53824p+3
+0x1.4a0e1cp+4
+0x1.021604p+4
+-0x1.21900cp+4
+-0x1.84c488p+3
+-0x1.03b874p+3
+0x1.5bcc5cp+4
+-0x1.9fb5c8p+3
+-0x1.842c52p+4
+-0x1.3deae4p+3
+-0x1.9ae034p+4
+-0x1.10fa9cp+5
+-0x1.b95bdcp+4
+-0x1.62e5bap+4
+0x1.e0e8fp+4
+-0x1.96a54cp+4
+0x1.c61774p+4
+-0x1.90c15p+4
+-0x1.5de06ap+4
+-0x1.08898ep+5
+0x1.644f1p+4
+0x1.caf23p+2
+0x1.3b8f6p+3
+-0x1.c806aap+4
+0x1.c6ebe4p+4
+-0x1.49fcd4p+3
+-0x1.787318p+4
+0x1.164038p+3
+-0x1.05b048p+2
+-0x1.dbe2f8p+2
+-0x1.7f48bp+2
+0x1.70e1ecp+4
+0x1.330974p+4
+-0x1.dd4fdp+3
+0x1.460e1p+3
+-0x1.2d880cp+3
+-0x1.9575f2p+4
+-0x1.0acce4p+5
+0x1.048768p+4
+-0x1.03fd18p+3
+0x1.05b15p+5
+0x1.54f76p+1
+0x1.f6f6e8p+4
+0x1.b3677p+4
+0x1.c01f3p+2
+-0x1.e32a14p+4
+-0x1.c72a8p+0
+-0x1.ebac5ap+4
+0x1.d83bp-1
+-0x1.4926e8p+4
+-0x1.797964p+4
+-0x1.49e964p+3
+-0x1.841d6cp+4
+-0x1.25273cp+3
+-0x1.07b102p+4
+-0x1.14b7acp+5
+-0x1.b5e63ap+4
+0x1.b52cacp+4
+0x1.f47f3p+2
+-0x1.6f3afcp+4
+-0x1.13717cp+3
+-0x1.1b037cp+4
+0x1.5da03p+4
+0x1.ec788p+4
+0x1.139c4cp+4
+-0x1.7418a6p+4
+0x1.03917cp+5
+-0x1.95383p+4
+0x1.03f114p+5
+-0x1.57e28ep+4
+0x1.caf3a4p+4
+-0x1.2cbb8p-1
+0x1.245f6p+3
+-0x1.2f17dp+3
+-0x1.86afacp+4
+0x1.2aaac8p+4
+-0x1.0a568p+0
+0x1.a7e7b4p+4
+0x1.c330b8p+3
+0x1.0faeap+1
+-0x1.2d39p+2
+-0x1.4ddb52p+4
+-0x1.f0c194p+4
+-0x1.3381cp+2
+0x1.12218p+5
+0x1.4804bp+2
+-0x1.df3382p+4
+-0x1.163aap+1
+0x1.8d269cp+4
+0x1.b46b3p+4
+-0x1.476e0cp+3
+-0x1.449c18p+3
+0x1.1a06p-1
+-0x1.2dba34p+4
+-0x1.2bc334p+4
+0x1.bba7b4p+4
+-0x1.c0eb2ep+4
+0x1.c2fa38p+4
+0x1.0f8538p+5
+0x1.fc3df8p+4
+0x1.537f8cp+4
+-0x1.a8d7ccp+4
+0x1.96023p+2
+0x1.3b2d2p+1
+-0x1.7b62c6p+4
+-0x1.5185ap+1
+-0x1.f7a8p-1
+-0x1.0c922p+3
+-0x1.df916p+4
+0x1.f3911p+3
+-0x1.5d9218p+3
+0x1.e0c878p+4
+-0x1.bd25bp+1
+0x1.66c448p+3
+-0x1.811accp+3
+-0x1.010c9cp+4
+0x1.f2a9f8p+4
+-0x1.1002dcp+4
+-0x1.274c8ep+4
+-0x1.2a902p+4
+0x1.74b20cp+4
+0x1.ff9988p+4
+-0x1.08647p+4
+-0x1.6557ecp+3
+0x1.cc62p+0
+-0x1.01b0c6p+5
+-0x1.75cep+4
+0x1.56d63cp+4
+-0x1.f86a7p+2
+0x1.4c874p+4
+0x1.37df0cp+4
+-0x1.265c3cp+3
+-0x1.0c48cp+5
+-0x1.e459d8p+3
+-0x1.8bca4p+3
+0x1.14706p+3
+-0x1.c99d3p+2
+-0x1.0fb52ap+4
+-0x1.071aecp+5
+-0x1.8975d8p+2
+-0x1.128304p+3
+-0x1.e3ff3p+1
+-0x1.152db8p+2
+-0x1.16b954p+5
+-0x1.15e6cep+5
+0x1.21b8d8p+4
+-0x1.1a98a8p+2
+0x1.059a88p+5
+0x1.2e2f4cp+4
+0x1.9f7c4p+3
+0x1.67382p+1
+0x1.2551dp+4
+0x1.b0fd4p+2
+0x1.583a68p+3
+0x1.30a698p+3
+-0x1.f8fe88p+2
+0x1.96d6f4p+4
+-0x1.0d8a96p+5
+-0x1.74878p-1
+0x1.10f1ep+1
+0x1.300af8p+4
+0x1.26de1cp+4
+0x1.ac842p+2
+0x1.74276p+4
+-0x1.d4723ep+4
+0x1.7222f8p+4
+-0x1.12400cp+5
+-0x1.6626e8p+3
+-0x1.a6c344p+3
+-0x1.3f75ep+2
+0x1.968ac4p+4
+-0x1.e132ecp+3
+0x1.308c5cp+4
+0x1.32232p+1
+-0x1.101cap+5
+-0x1.0adf06p+5
+-0x1.9d61p+3
+0x1.0937dp+5
+0x1.b44f3cp+4
+-0x1.c78ap+0
+-0x1.829a6p+4
+0x1.7ecb88p+3
+0x1.44aa6p+4
+-0x1.f017dap+4
+-0x1.a4603p+3
+-0x1.6fc0c8p+3
+0x1.ec29cp+4
+-0x1.ff5bdcp+4
+0x1.d5782p+4
+-0x1.2f712ap+4
+-0x1.552f48p+2
+0x1.a127bp+4
+-0x1.3a8cdcp+3
+-0x1.7a1228p+3
+0x1.8b913p+2
+0x1.db95fp+3
+0x1.7a43p+3
+-0x1.539778p+4
+-0x1.a4d114p+4
+-0x1.c4127p+4
+0x1.75c1p+4
+-0x1.f3b83p+2
+-0x1.2d3ffep+4
+0x1.73c72p+2
+0x1.b9044p+0
+0x1.e7383p+4
+-0x1.f12826p+4
+-0x1.ace2ap+1
+0x1.fb643p+4
+-0x1.d6d9a8p+2
+0x1.5da19p+4
+-0x1.1f967p+3
+-0x1.9ac65ep+4
+-0x1.03408cp+3
+-0x1.014488p+5
+-0x1.3ce4d8p+4
+-0x1.99e4a8p+4
+0x1.e51898p+4
+0x1.8df99p+2
+0x1.9240dp+4
+0x1.94107p+3
+-0x1.e7551p+3
+0x1.f8568p+4
+-0x1.57339cp+4
+0x1.d9ef98p+4
+0x1.ea652p+4
+-0x1.185138p+4
+-0x1.37b20cp+3
+0x1.6e3ea8p+4
+-0x1.08b312p+4
+-0x1.f85fep+4
+-0x1.50c0dcp+4
+-0x1.daf28p+0
+0x1.1dd7b8p+4
+0x1.7179e8p+4
+-0x1.489db4p+4
+-0x1.5b705cp+3
+0x1.c989d4p+4
+-0x1.d0da4p+0
+0x1.67d708p+3
+-0x1.a4d0f8p+3
+-0x1.22519cp+4
+0x1.0e6b54p+4
+0x1.17e9bp+5
+0x1.68d95cp+4
+-0x1.ec6d2cp+4
+-0x1.38ffccp+4
+-0x1.23bf1ep+4
+0x1.a0e2p+2
+0x1.24094p+3
+-0x1.90f946p+4
+-0x1.4f2b2p+4
+0x1.93398p+0
+0x1.3d7fdp+4
+0x1.3741fp+4
+-0x1.a88074p+3
+-0x1.103f16p+5
+0x1.53c554p+4
+0x1.e8e9p+1
+-0x1.0e4e4cp+4
+-0x1.e2389ep+4
+-0x1.ad61p+3
+-0x1.c30eecp+3
+-0x1.67abb8p+2
+-0x1.c4fffcp+3
+-0x1.5dd3ap+1
+-0x1.6eb4a8p+2
+0x1.63f0bp+3
+-0x1.073cd8p+5
+0x1.bb22e8p+4
+-0x1.a8ce5p+2
+-0x1.51153cp+3
+-0x1.56371p+3
+0x1.f1fb4p+0
+0x1.498f8p+3
+0x1.332da8p+3
+0x1.080834p+5
+-0x1.32da04p+3
+0x1.650174p+4
+-0x1.59f60cp+4
+-0x1.4e8858p+2
+0x1.84688p+0
+0x1.3629fp+2
+0x1.0ba29p+5
+-0x1.0ae52p+2
+-0x1.4f44ap+1
+0x1.9ae28p+0
+0x1.2baf1p+2
+0x1.0c802p+2
+-0x1.c67dd8p+2
+-0x1.de957p+1
+0x1.48b72p+1
+-0x1.4c0c68p+4
+0x1.46a744p+4
+-0x1.39d01cp+3
+0x1.53d76p+3
+0x1.1668a4p+5
+0x1.f4433p+4
+0x1.e4b0fp+2
+-0x1.7c4cf8p+4
+0x1.0d5e8p+4
+-0x1.880078p+4
+0x1.53c5ep+4
+0x1.904728p+3
+0x1.0d36f8p+5
+0x1.f6183p+4
+0x1.08f43cp+4
+0x1.77e2c8p+4
+-0x1.cb5924p+4
+0x1.486de8p+4
+0x1.060a78p+3
+0x1.0c8e4cp+5
+0x1.fb2dcp+3
+0x1.39f22p+4
+-0x1.0111a6p+5
+0x1.8b0198p+3
+-0x1.c08372p+4
+-0x1.e9686p+4
+-0x1.2f4aa4p+3
+0x1.ad5be4p+4
+-0x1.518fccp+3
+-0x1.c858d4p+3
+-0x1.5f7f7cp+3
+-0x1.556ffep+4
+-0x1.2215a4p+3
+-0x1.50b018p+4
+0x1.f249ap+2
+0x1.12e38p+5
+-0x1.b1dc0cp+4
+-0x1.a102dcp+3
+0x1.80dbc4p+4
+-0x1.684cbcp+3
+0x1.ed581p+2
+-0x1.dca674p+3
+0x1.973504p+4
+-0x1.f820f8p+4
+-0x1.81a7p+1
+-0x1.0c8b6p+5
+0x1.d1e7b8p+4
+0x1.3709dcp+4
+-0x1.48f4ap+3
+-0x1.07881p+5
+0x1.45905p+2
+-0x1.0c0d02p+5
+-0x1.067a0cp+3
+0x1.9dd588p+4
+0x1.ba0ed8p+4
+0x1.f44628p+4
+0x1.cabed4p+4
+-0x1.e23812p+4
+-0x1.0a744ep+5
+0x1.db644p+0
+0x1.51211p+4
+0x1.a63694p+4
+0x1.246b2cp+4
+-0x1.756b7p+4
+-0x1.ff7878p+4
+-0x1.f10044p+4
+-0x1.cda77p+1
+-0x1.1961a2p+4
+0x1.d4abbp+2
+-0x1.03ed76p+4
+0x1.079cfcp+4
+-0x1.7365f4p+3
+-0x1.2dd44p+0
+-0x1.b47a6p+1
+0x1.9784d4p+4
+-0x1.f35baep+4
+-0x1.bb35acp+4
+0x1.b9d88p+1
+0x1.14f6a4p+5
+-0x1.7c5ecp+0
+0x1.05bd1cp+5
+-0x1.a19a52p+4
+-0x1.148c8p+3
+-0x1.771ce2p+4
+-0x1.072ffap+5
+0x1.c4178cp+4
+0x1.8bad68p+4
+0x1.b47704p+4
+0x1.0e2438p+4
+-0x1.fc9778p+4
+0x1.5ec7ap+2
+0x1.43912p+2
+0x1.46345p+3
+0x1.6cd29p+4
+0x1.0144cp+2
+-0x1.1e9854p+3
+-0x1.3756bap+4
+-0x1.0b664ap+4
+-0x1.9aep-3
+0x1.68f64p+3
+0x1.3aa67p+3
+-0x1.07615ap+5
+-0x1.f0c314p+4
+0x1.b0bdf4p+4
+-0x1.54f9aep+4
+0x1.9c367p+4
+-0x1.14b3ecp+4
+0x1.791af8p+4
+0x1.a81588p+3
+0x1.3b838p+4
+0x1.e13758p+4
+0x1.56c47p+2
+0x1.8f7e7cp+4
+0x1.5262e8p+4
+-0x1.896a58p+2
+0x1.f37f48p+4
+0x1.fbaadp+4
+0x1.4d2cfp+2
+0x1.6c67ap+2
+0x1.9b882p+3
+0x1.5b66fp+2
+-0x1.9d42dp+1
+-0x1.05346cp+4
+0x1.0ab82p+1
+0x1.9e15b8p+3
+-0x1.d98274p+3
+0x1.0a78b8p+3
+-0x1.2f3774p+4
+0x1.a9b88p+0
+-0x1.f47fecp+4
+-0x1.558a24p+4
+0x1.46c308p+3
+-0x1.bf564cp+4
+0x1.b638c8p+4
+0x1.42b98p+0
+-0x1.97a6a4p+4
+-0x1.4220ecp+4
+0x1.6845ap+3
+-0x1.fb5ddp+4
+0x1.eb47fp+2
+-0x1.067b58p+3
+0x1.167014p+5
+0x1.e7924p+4
+-0x1.5f6cp-3
+0x1.30a098p+3
+0x1.05834cp+5
+-0x1.da437cp+3
+0x1.3e04b8p+4
+-0x1.9ef4ecp+3
+0x1.51ce1p+3
+-0x1.112634p+5
+0x1.77c6ep+4
+-0x1.d37be8p+3
+-0x1.7e568p+0
+-0x1.c5a644p+4
+-0x1.6e036p+1
+-0x1.1786d4p+3
+-0x1.8580e8p+2
+0x1.c466cp+0
+0x1.0ba94p+3
+0x1.86773p+2
+0x1.803bep+4
+-0x1.ae82f8p+2
+-0x1.862498p+2
+0x1.3da6p+0
+0x1.a865d8p+3
+-0x1.ce0fb8p+2
+-0x1.846eep+4
+-0x1.d932p+3
+-0x1.547b34p+4
+0x1.7a1cbp+3
+0x1.248f58p+3
+-0x1.352bcp+4
+-0x1.8b421cp+4
+0x1.fd815p+2
+0x1.22a41p+3
+-0x1.0ac0eap+4
+-0x1.45f61p+4
+0x1.36d9bp+4
+-0x1.9cd784p+3
+-0x1.5fb918p+2
+-0x1.810298p+3
+0x1.e7b198p+3
+-0x1.ff5fc4p+4
+0x1.92637p+3
+0x1.82252p+2
+-0x1.aa8ebap+4
+-0x1.dc9b4ep+4
+0x1.ae464p+4
+0x1.d58b9p+3
+0x1.879fep+4
+0x1.afb52cp+4
+-0x1.9eda98p+4
+0x1.f3939p+4
+-0x1.e927e8p+3
+-0x1.582306p+4
+0x1.10753cp+5
+-0x1.80fd7cp+4
+0x1.9b3cbp+2
+0x1.67267p+4
+-0x1.51e6e8p+4
+-0x1.6250c8p+2
+-0x1.1550c4p+4
+0x1.2d6838p+3
+0x1.099948p+4
+-0x1.2eaf5p+4
+0x1.dca0cp+0
+-0x1.7374p-4
+-0x1.c2053ep+4
+0x1.9e5f04p+4
+-0x1.07dbf6p+5
+-0x1.23ba88p+4
+0x1.0956a4p+4
+-0x1.b798ap+1
+0x1.f7143p+2
+0x1.b56028p+3
+-0x1.151df6p+5
+-0x1.301754p+4
+-0x1.05d158p+5
+0x1.08eb28p+5
+-0x1.5c5d5p+4
+-0x1.9cffd2p+4
+-0x1.285654p+4
+0x1.e001e8p+3
+0x1.04076p+2
+0x1.0c6a04p+4
+0x1.7bb8p-2
+-0x1.0f0518p+5
+-0x1.3567a8p+2
+-0x1.1ebdp-1
+-0x1.8ef22p+3
+-0x1.0a1d5ap+5
+0x1.8a9edp+3
+0x1.00c0e4p+5
+-0x1.32c98p-1
+-0x1.e081c8p+3
+-0x1.226ea4p+4
+0x1.bf0b7p+4
+0x1.c4d04p+0
+0x1.f48ddp+2
+-0x1.f9f398p+2
+-0x1.24d42p+2
+0x1.0c776p+4
+0x1.8a98ep+3
+-0x1.86d128p+4
+-0x1.dda632p+4
+0x1.b3ad38p+4
+0x1.0dac4p+3
+0x1.9fc00cp+4
+-0x1.93bfccp+4
+-0x1.6e659p+2
+-0x1.60dap-1
+-0x1.50fd46p+4
+0x1.1d5078p+4
+0x1.b69efp+3
+0x1.e31d3p+3
+-0x1.0541cp+5
+0x1.3a1648p+3
+0x1.a0c63p+3
+0x1.ea3ff8p+4
+0x1.58ea1cp+4
+0x1.a5509cp+4
+-0x1.30dc1p+3
+-0x1.6a0c2ep+4
+0x1.017178p+3
+0x1.3f598p+0
+0x1.33b4e8p+4
+-0x1.74f184p+4
+0x1.05baep+2
+0x1.b8792p+1
+0x1.638c68p+4
+0x1.94a15cp+4
+-0x1.43fc96p+4
+-0x1.21606cp+3
+0x1.9b3a58p+3
+0x1.e4a05p+4
+0x1.bfa8d8p+4
+-0x1.9076acp+4
+-0x1.967568p+4
+0x1.ac7a58p+3
+0x1.51c12p+2
+0x1.769c4p+1
+-0x1.a53708p+4
+-0x1.fcd6dp+1
+0x1.9b57p+2
+-0x1.f69b8p+0
+-0x1.b953p+2
+0x1.0ec4fcp+5
+-0x1.cf1dcp+0
+0x1.8084b8p+4
+0x1.62db78p+3
+-0x1.485c98p+2
+-0x1.576414p+4
+-0x1.fcc948p+3
+0x1.9d863p+3
+-0x1.08b39ep+5
+0x1.795ep-3
+0x1.99e26p+2
+0x1.fb6d6p+4
+-0x1.55d16p+1
+0x1.41071p+3
+0x1.549abcp+4
+0x1.4e88p-3
+0x1.10bfcp+2
+0x1.97b3cp+3
+-0x1.4580cp+3
+-0x1.df2fp+0
+-0x1.09a2dcp+5
+-0x1.7e1124p+3
+-0x1.14f35ep+5
+0x1.2956cp+4
+0x1.c7b8e8p+4
+-0x1.ebba08p+3
+-0x1.fdfd3p+3
+0x1.46906p+1
+0x1.c1318p+0
+0x1.79f444p+4
+0x1.6012bcp+4
+0x1.fd49ap+2
+-0x1.11612cp+4
+0x1.ea3cdp+4
+-0x1.a053ccp+4
+-0x1.995764p+3
+0x1.bec2e8p+4
+-0x1.7aa898p+2
+0x1.6b6edp+2
+0x1.9b6774p+4
+0x1.e85738p+3
+0x1.974ad4p+4
+-0x1.554564p+4
+-0x1.383ap+3
+-0x1.7576dcp+4
+-0x1.7e8308p+4
+-0x1.786086p+4
+-0x1.31641p+2
+-0x1.591184p+4
+0x1.1ef65p+4
+-0x1.39bc08p+2
+-0x1.1672b4p+4
+-0x1.4aa7f4p+4
+0x1.201d4p+1
+-0x1.afecp-3
+-0x1.163698p+3
+-0x1.7660cp+2
+-0x1.c7fb44p+4
+-0x1.8e0cbp+3
+-0x1.d2a9p-2
+0x1.d0d51p+4
+0x1.d1ea38p+4
+0x1.9741bp+3
+0x1.d90b08p+3
+0x1.6608f8p+4
+-0x1.019936p+5
+-0x1.bd980ep+4
+0x1.c8ad9p+2
+-0x1.a33178p+2
+-0x1.957c74p+4
+0x1.1adc7p+4
+-0x1.329bcp+2
+0x1.4df538p+3
+0x1.ce0544p+4
+0x1.09ab3p+5
+-0x1.937bp+4
+0x1.029744p+5
+0x1.f899f8p+4
+0x1.8140e8p+4
+0x1.e035p+2
+0x1.1418a4p+5
+0x1.183664p+5
+0x1.9ac948p+4
+0x1.7be72p+3
+0x1.3145d8p+4
+0x1.a88598p+3
+-0x1.15d71p+5
+-0x1.cfe5dp+3
+-0x1.3259b4p+3
+0x1.eb17fp+4
+-0x1.c4d158p+3
+-0x1.a0004cp+4
+0x1.b62a1p+3
+-0x1.320a1cp+4
+0x1.99bd1cp+4
+0x1.36e0ap+4
+-0x1.da762p+1
+0x1.91eep+2
+0x1.18d928p+3
+0x1.956c5cp+4
+0x1.4226e8p+4
index 34e0e096e00d0757d817f0b1fc5cb16fd2185d85..addbdb1109457452336d18a62b6267315428716a 100644 (file)
@@ -14,6 +14,7 @@
 
 #include <errno.h>
 #include <math.h>
+#include <stddef.h>
 #include <math_private.h>
 #include <math-svid-compat.h>
 #include <libm-alias-float.h>
@@ -22,8 +23,7 @@
 float
 __tgammaf(float x)
 {
-       int local_signgam;
-       float y = __ieee754_gammaf_r(x,&local_signgam);
+       float y = __ieee754_gammaf_r(x, NULL);
 
        if(__glibc_unlikely (!isfinite (y) || y == 0)
           && (isfinite (x) || (isinf (x) && x < 0.0))
@@ -41,7 +41,7 @@ __tgammaf(float x)
            /* tgammaf overflow */
            return __kernel_standard_f(x, x, 140);
        }
-       return local_signgam < 0 ? - y : y;
+       return y;
 }
 libm_alias_float (__tgamma, tgamma)
 #endif
index 846fb2c29e97b8e0f69fc1c26b22f08449cfce40..8c333fcd293e8ec2f70c789d9bf977a5599c5916 100644 (file)
@@ -1653,22 +1653,18 @@ ldouble: 3
 
 Function: "tgamma":
 double: 9
-float: 8
 ldouble: 4
 
 Function: "tgamma_downward":
 double: 9
-float: 7
 ldouble: 5
 
 Function: "tgamma_towardzero":
 double: 9
-float: 7
 ldouble: 5
 
 Function: "tgamma_upward":
 double: 9
-float: 8
 ldouble: 4
 
 Function: "y0":
index e28c2af6839b5600a3fc258bab431557b49a3a9d..5c6175406bae7ef92e115b90aead9e7ba7ed3c13 100644 (file)
@@ -1410,22 +1410,18 @@ ldouble: 3
 
 Function: "tgamma":
 double: 9
-float: 8
 ldouble: 4
 
 Function: "tgamma_downward":
 double: 9
-float: 7
 ldouble: 5
 
 Function: "tgamma_towardzero":
 double: 9
-float: 7
 ldouble: 5
 
 Function: "tgamma_upward":
 double: 9
-float: 8
 ldouble: 4
 
 Function: "y0":
index 7e2c2dff13e5a14d183e3c2ff3407d719e63e946..d1665b9b72aa2b011cbfbaef44a43e6384e29377 100644 (file)
@@ -1157,19 +1157,15 @@ float: 3
 
 Function: "tgamma":
 double: 9
-float: 9
 
 Function: "tgamma_downward":
 double: 9
-float: 9
 
 Function: "tgamma_towardzero":
 double: 9
-float: 8
 
 Function: "tgamma_upward":
 double: 9
-float: 9
 
 Function: "y0":
 double: 3
index d9d6c76c3ed1c106b62df3655f5bd61d63d09582..e768024eb502b6b865f5c70da822219fcfb66630 100644 (file)
@@ -279,7 +279,6 @@ float: 2
 
 Function: "tgamma":
 double: 9
-float: 8
 
 Function: "y0":
 double: 3
index 100e9d19567feebd1f0babdac19cb316a6db18c6..21fe98a7bd6529d0784a65efd79ee7b2e38ca1e4 100644 (file)
@@ -1152,19 +1152,15 @@ float: 3
 
 Function: "tgamma":
 double: 9
-float: 8
 
 Function: "tgamma_downward":
 double: 9
-float: 7
 
 Function: "tgamma_towardzero":
 double: 9
-float: 7
 
 Function: "tgamma_upward":
 double: 9
-float: 8
 
 Function: "y0":
 double: 3
index fc634f89cae94c8db7f103b05ca9d9eebb8095e0..151df00638f86337bebcb5fdc60dc7675834704d 100644 (file)
@@ -1061,19 +1061,15 @@ float: 3
 
 Function: "tgamma":
 double: 9
-float: 8
 
 Function: "tgamma_downward":
 double: 8
-float: 7
 
 Function: "tgamma_towardzero":
 double: 9
-float: 7
 
 Function: "tgamma_upward":
 double: 9
-float: 8
 
 Function: "y0":
 double: 3
index a1e28c8ee01a3439c1c3d8f03f92cd4c8d99cf98..48697a7b09870690eed2925094639607ce7915be 100644 (file)
@@ -1092,19 +1092,15 @@ float: 3
 
 Function: "tgamma":
 double: 9
-float: 8
 
 Function: "tgamma_downward":
 double: 5
-float: 5
 
 Function: "tgamma_towardzero":
 double: 5
-float: 4
 
 Function: "tgamma_upward":
 double: 4
-float: 4
 
 Function: "y0":
 double: 3
index 4f0709c817f42e074afc85e227f6899d73aa339d..57c1155e8be6dc4ecf912727c53d3210e8c40097 100644 (file)
@@ -1181,20 +1181,16 @@ float: 3
 
 Function: "tgamma":
 double: 9
-float: 8
 ldouble: 1
 
 Function: "tgamma_downward":
 double: 9
-float: 7
 
 Function: "tgamma_towardzero":
 double: 9
-float: 7
 
 Function: "tgamma_upward":
 double: 9
-float: 8
 
 Function: "y0":
 double: 3
index 9e462447526de78b7f516b111b9d45e8542f5524..d13b05a220a8641fac1f995a4b6e86bbedd80581 100644 (file)
@@ -1699,25 +1699,21 @@ ldouble: 4
 
 Function: "tgamma":
 double: 9
-float: 8
 float128: 4
 ldouble: 5
 
 Function: "tgamma_downward":
 double: 9
-float: 7
 float128: 5
 ldouble: 6
 
 Function: "tgamma_towardzero":
 double: 9
-float: 7
 float128: 5
 ldouble: 6
 
 Function: "tgamma_upward":
 double: 9
-float: 8
 float128: 4
 ldouble: 5
 
index 5c41bf36dc396f6ddbd86899274ff4c6d5d9d364..0a813aa8dd79840fbffbce4155bc0de0451bf4a5 100644 (file)
@@ -1701,25 +1701,21 @@ ldouble: 4
 
 Function: "tgamma":
 double: 9
-float: 8
 float128: 4
 ldouble: 5
 
 Function: "tgamma_downward":
 double: 9
-float: 7
 float128: 5
 ldouble: 6
 
 Function: "tgamma_towardzero":
 double: 9
-float: 7
 float128: 5
 ldouble: 6
 
 Function: "tgamma_upward":
 double: 8
-float: 8
 float128: 4
 ldouble: 5
 
index f3596eeae4ffdc73436333e769bf90abf91bd02f..1cc8931700702e65d29a6e2af287175d23c6b182 100644 (file)
@@ -1,44 +1 @@
-/* Compute a product of X, X+1, ..., with an error estimate.
-   Copyright (C) 2013-2024 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, see
-   <https://www.gnu.org/licenses/>.  */
-
-#include <math.h>
-#include <math-narrow-eval.h>
-#include <math_private.h>
-#include <float.h>
-
-/* Compute the product of X + X_EPS, X + X_EPS + 1, ..., X + X_EPS + N
-   - 1, in the form R * (1 + *EPS) where the return value R is an
-   approximation to the product and *EPS is set to indicate the
-   approximate error in the return value.  X is such that all the
-   values X + 1, ..., X + N - 1 are exactly representable, and X_EPS /
-   X is small enough that factors quadratic in it can be
-   neglected.  */
-
-float
-__gamma_productf (float x, float x_eps, int n, float *eps)
-{
-  double x_full = (double) x + (double) x_eps;
-  double ret = x_full;
-  for (int i = 1; i < n; i++)
-    ret *= x_full + i;
-
-  float fret = math_narrow_eval ((float) ret);
-  *eps = (ret - fret) / fret;
-
-  return fret;
-}
+/* Not needed.  */
index a9730d61c1944a7bef481b846e2b632092229e80..90ed3b4890b821a3be205acbf4cf5926595d67e0 100644 (file)
-/* Implementation of gamma function according to ISO C.
-   Copyright (C) 1997-2024 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
+/* Implementation of the gamma function for binary32.
 
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
+Copyright (c) 2023-2024 Alexei Sibidanov.
 
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
+The original version of this file was copied from the CORE-MATH
+project (file src/binary32/tgamma/tgammaf.c, revision a48e352).
 
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, see
-   <https://www.gnu.org/licenses/>.  */
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
 
-#include <math.h>
-#include <math-narrow-eval.h>
-#include <math_private.h>
-#include <fenv_private.h>
-#include <math-underflow.h>
-#include <float.h>
-#include <libm-alias-finite.h>
-
-/* Coefficients B_2k / 2k(2k-1) of x^-(2k-1) inside exp in Stirling's
-   approximation to gamma function.  */
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
 
-static const float gamma_coeff[] =
-  {
-    0x1.555556p-4f,
-    -0xb.60b61p-12f,
-    0x3.403404p-12f,
-  };
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
+ */
 
-#define NCOEFF (sizeof (gamma_coeff) / sizeof (gamma_coeff[0]))
+/* Changes with respect to the original CORE-MATH code:
+   - removed the dealing with errno
+     (this is done in the wrapper math/w_tgammaf_compat.c)
+   - usage of math_narrow_eval to deal with underflow/overflow
+   - deal with signgamp
+ */
 
-/* Return gamma (X), for positive X less than 42, in the form R *
-   2^(*EXP2_ADJ), where R is the return value and *EXP2_ADJ is set to
-   avoid overflow or underflow in intermediate calculations.  */
+#include <math.h>
+#include <float.h>
+#include <stdint.h>
+#include <stddef.h>
+#include <libm-alias-finite.h>
+#include <math-narrow-eval.h>
 
-static float
-gammaf_positive (float x, int *exp2_adj)
-{
-  int local_signgam;
-  if (x < 0.5f)
-    {
-      *exp2_adj = 0;
-      return __ieee754_expf (__ieee754_lgammaf_r (x + 1, &local_signgam)) / x;
-    }
-  else if (x <= 1.5f)
-    {
-      *exp2_adj = 0;
-      return __ieee754_expf (__ieee754_lgammaf_r (x, &local_signgam));
-    }
-  else if (x < 2.5f)
-    {
-      *exp2_adj = 0;
-      float x_adj = x - 1;
-      return (__ieee754_expf (__ieee754_lgammaf_r (x_adj, &local_signgam))
-             * x_adj);
-    }
-  else
-    {
-      float eps = 0;
-      float x_eps = 0;
-      float x_adj = x;
-      float prod = 1;
-      if (x < 4.0f)
-       {
-         /* Adjust into the range for applying Stirling's
-            approximation.  */
-         float n = ceilf (4.0f - x);
-         x_adj = math_narrow_eval (x + n);
-         x_eps = (x - (x_adj - n));
-         prod = __gamma_productf (x_adj - n, x_eps, n, &eps);
-       }
-      /* The result is now gamma (X_ADJ + X_EPS) / (PROD * (1 + EPS)).
-        Compute gamma (X_ADJ + X_EPS) using Stirling's approximation,
-        starting by computing pow (X_ADJ, X_ADJ) with a power of 2
-        factored out.  */
-      float exp_adj = -eps;
-      float x_adj_int = roundf (x_adj);
-      float x_adj_frac = x_adj - x_adj_int;
-      int x_adj_log2;
-      float x_adj_mant = __frexpf (x_adj, &x_adj_log2);
-      if (x_adj_mant < M_SQRT1_2f)
-       {
-         x_adj_log2--;
-         x_adj_mant *= 2.0f;
-       }
-      *exp2_adj = x_adj_log2 * (int) x_adj_int;
-      float ret = (__ieee754_powf (x_adj_mant, x_adj)
-                  * __ieee754_exp2f (x_adj_log2 * x_adj_frac)
-                  * __ieee754_expf (-x_adj)
-                  * sqrtf (2 * M_PIf / x_adj)
-                  / prod);
-      exp_adj += x_eps * __ieee754_logf (x_adj);
-      float bsum = gamma_coeff[NCOEFF - 1];
-      float x_adj2 = x_adj * x_adj;
-      for (size_t i = 1; i <= NCOEFF - 1; i++)
-       bsum = bsum / x_adj2 + gamma_coeff[NCOEFF - 1 - i];
-      exp_adj += bsum / x_adj;
-      return ret + ret * __expm1f (exp_adj);
-    }
-}
+typedef union {float f; uint32_t u;} b32u32_u;
+typedef union {double f; uint64_t u;} b64u64_u;
 
 float
 __ieee754_gammaf_r (float x, int *signgamp)
 {
-  int32_t hx;
-  float ret;
+  /* The wrapper in math/w_tgamma_template.c expects *signgamp to be set to a
+     non-negative value if the returned value is gamma(x), and to a negative
+     value if it is -gamma(x).
+     Since the code here directly computes gamma(x), we set it to 1.
+  */
+  if (signgamp != NULL)
+    *signgamp = 1;
 
-  GET_FLOAT_WORD (hx, x);
+  /* List of exceptional cases. Each entry contains the 32-bit encoding u of x,
+     a binary32 approximation f of gamma(x), and a correction term df.  */
+  static const struct {uint32_t u; float f, df;} tb[] = {
+    {0x27de86a9u, 0x1.268266p+47f, 0x1p22f},      // x = 0x1.bd0d52p-48
+    {0x27e05475u, 0x1.242422p+47f, 0x1p22f},      // x = 0x1.c0a8eap-48
+    {0xb63befb3u, -0x1.5cb6e4p+18f, 0x1p-7f},     // x = -0x1.77df66p-19
+    {0x3c7bb570u, 0x1.021d9p+6f, 0x1p-19f},       // x = 0x1.f76aep-7
+    {0x41e886d1u, 0x1.33136ap+98f, 0x1p73f},      // x = 0x1.d10da2p+4
+    {0xc067d177u, 0x1.f6850cp-3f, 0x1p-28f},      // x = -0x1.cfa2eep+1
+    {0xbd99da31u, -0x1.befe66p+3, -0x1p-22f},     // x = -0x1.33b462p-4
+    {0xbf54c45au, -0x1.a6b4ecp+2, +0x1p-23f},     // x = -0x1.a988b4p-1
+    {0x41ee77feu, 0x1.d3631cp+101, -0x1p-76f},    // x = 0x1.dceffcp+4
+    {0x3f843a64u, 0x1.f6c638p-1, 0x1p-26f},       // x = 0x1.0874c8p+0
+  };
 
-  if (__glibc_unlikely ((hx & 0x7fffffff) == 0))
-    {
-      /* Return value for x == 0 is Inf with divide by zero exception.  */
-      *signgamp = 0;
-      return 1.0 / x;
+  b32u32_u t = {.f = x};
+  uint32_t ax = t.u<<1;
+  if(__builtin_expect(ax>=(0xffu<<24), 0)){ /* x=NaN or +/-Inf */
+    if(ax==(0xffu<<24)){ /* x=+/-Inf */
+      if(t.u>>31){ /* x=-Inf */
+        return x / x; /* will raise the "Invalid operation" exception */
+      }
+      return x; /* x=+Inf */
     }
-  if (__builtin_expect (hx < 0, 0)
-      && (uint32_t) hx < 0xff800000 && rintf (x) == x)
-    {
-      /* Return value for integer x < 0 is NaN with invalid exception.  */
-      *signgamp = 0;
-      return (x - x) / (x - x);
+    return x + x; /* x=NaN, where x+x ensures the "Invalid operation"
+                     exception is set if x is sNaN */
+  }
+  double z = x;
+  if(__builtin_expect(ax<0x6d000000u, 0)){ /* |x| < 0x1p-18 */
+    volatile double d = (0x1.fa658c23b1578p-1 - 0x1.d0a118f324b63p-1*z)*z - 0x1.2788cfc6fb619p-1;
+    double f = 1.0/z + d;
+    float r = f;
+    b64u64_u rt = {.f = f};
+    if(((rt.u+2)&0xfffffff) < 4){
+      for(unsigned i=0;i<sizeof(tb)/sizeof(tb[0]);i++)
+       if(t.u==tb[i].u) return tb[i].f + tb[i].df;
     }
-  if (__glibc_unlikely (hx == 0xff800000))
-    {
-      /* x == -Inf.  According to ISO this is NaN.  */
-      *signgamp = 0;
-      return x - x;
+    return r;
+  }
+  float fx = __builtin_floorf(x);
+  if(__builtin_expect(x >= 0x1.18522p+5f, 0)){
+    /* Overflow case. The original CORE-MATH code returns 0x1p127f * 0x1p127f,
+       but apparently some compilers replace this by +Inf.  */
+    return math_narrow_eval (x * 0x1p127f);
+  }
+  /* compute k only after the overflow check, otherwise the case to integer
+     might overflow */
+  int k = fx;
+  if(__builtin_expect(fx==x, 0)){ /* x is integer */
+    if(x == 0.0f){
+      return 1.0f/x;
     }
-  if (__glibc_unlikely ((hx & 0x7f800000) == 0x7f800000))
-    {
-      /* Positive infinity (return positive infinity) or NaN (return
-        NaN).  */
-      *signgamp = 0;
-      return x + x;
+    if(x < 0.0f){
+      return 0.0f / 0.0f; /* should raise the "Invalid operation" exception */
     }
+    double t0 = 1, x0 = 1;
+    for(int i=1; i<k; i++, x0 += 1.0) t0 *= x0;
+    return t0;
+  }
+  if(__builtin_expect(x<-42.0f, 0)){ /* negative non-integer */
+    /* For x < -42, x non-integer, |gamma(x)| < 2^-151.  */
+    static const float sgn[2] = {0x1p-127f, -0x1p-127f};
+    /* Underflows always happens */
+    return math_narrow_eval (0x1p-127f * sgn[k&1]);
+  }
+  /* The array c[] stores a degree-15 polynomial approximation for gamma(x).  */
+  static const double c[] =
+    {0x1.c9a76be577123p+0, 0x1.8f2754ddcf90dp+0, 0x1.0d1191949419bp+0, 0x1.e1f42cf0ae4a1p-2,
+     0x1.82b358a3ab638p-3, 0x1.e1f2b30cd907bp-5, 0x1.240f6d4071bd8p-6, 0x1.1522c9f3cd012p-8,
+     0x1.1fd0051a0525bp-10, 0x1.9808a8b96c37ep-13, 0x1.b3f78e01152b5p-15, 0x1.49c85a7e1fd04p-18,
+     0x1.471ca49184475p-19, -0x1.368f0b7ed9e36p-23, 0x1.882222f9049efp-23, -0x1.a69ed2042842cp-25};
 
-  if (x >= 36.0f)
-    {
-      /* Overflow.  */
-      *signgamp = 0;
-      ret = math_narrow_eval (FLT_MAX * FLT_MAX);
-      return ret;
-    }
-  else
-    {
-      SET_RESTORE_ROUNDF (FE_TONEAREST);
-      if (x > 0.0f)
-       {
-         *signgamp = 0;
-         int exp2_adj;
-         float tret = gammaf_positive (x, &exp2_adj);
-         ret = __scalbnf (tret, exp2_adj);
-       }
-      else if (x >= -FLT_EPSILON / 4.0f)
-       {
-         *signgamp = 0;
-         ret = 1.0f / x;
-       }
-      else
-       {
-         float tx = truncf (x);
-         *signgamp = (tx == 2.0f * truncf (tx / 2.0f)) ? -1 : 1;
-         if (x <= -42.0f)
-           /* Underflow.  */
-           ret = FLT_MIN * FLT_MIN;
-         else
-           {
-             float frac = tx - x;
-             if (frac > 0.5f)
-               frac = 1.0f - frac;
-             float sinpix = (frac <= 0.25f
-                             ? __sinf (M_PIf * frac)
-                             : __cosf (M_PIf * (0.5f - frac)));
-             int exp2_adj;
-             float tret = M_PIf / (-x * sinpix
-                                   * gammaf_positive (-x, &exp2_adj));
-             ret = __scalbnf (tret, -exp2_adj);
-             math_check_force_underflow_nonneg (ret);
-           }
-       }
-      ret = math_narrow_eval (ret);
-    }
-  if (isinf (ret) && x != 0)
-    {
-      if (*signgamp < 0)
-       {
-         ret = math_narrow_eval (-copysignf (FLT_MAX, ret) * FLT_MAX);
-         ret = -ret;
-       }
-      else
-       ret = math_narrow_eval (copysignf (FLT_MAX, ret) * FLT_MAX);
-      return ret;
-    }
-  else if (ret == 0)
-    {
-      if (*signgamp < 0)
-       {
-         ret = math_narrow_eval (-copysignf (FLT_MIN, ret) * FLT_MIN);
-         ret = -ret;
-       }
-      else
-       ret = math_narrow_eval (copysignf (FLT_MIN, ret) * FLT_MIN);
-      return ret;
+  double m = z - 0x1.7p+1, i = __builtin_roundeven(m), step = __builtin_copysign(1.0,i);
+  double d = m - i, d2 = d*d, d4 = d2*d2, d8 = d4*d4;
+  double f = (c[0] + d*c[1]) + d2*(c[2] + d*c[3]) + d4*((c[4] + d*c[5]) + d2*(c[6] + d*c[7]))
+    + d8*((c[8] + d*c[9]) + d2*(c[10] + d*c[11]) + d4*((c[12] + d*c[13]) + d2*(c[14] + d*c[15])));
+  int jm = __builtin_fabs(i);
+  double w = 1;
+  if(jm){
+    z -= 0.5 + step*0.5;
+    w = z;
+    for(int j=jm-1; j; j--) {z -= step; w *= z;}
+  }
+  if(i<=-0.5) w = 1/w;
+  f *= w;
+  b64u64_u rt = {.f = f};
+  float r = f;
+  /* Deal with exceptional cases.  */
+  if(__builtin_expect(((rt.u+2)&0xfffffff) < 8, 0)){
+    for(unsigned j=0;j<sizeof(tb)/sizeof(tb[0]);j++) {
+      if(t.u==tb[j].u) return tb[j].f + tb[j].df;
     }
-  else
-    return ret;
+  }
+  return r;
 }
 libm_alias_finite (__ieee754_gammaf_r, __gammaf_r)
index 833dca40e46f8f3b6e88bbb411344700df2650e1..75e21ee2a8fcbf3dd6284c781476a1a84aae9646 100644 (file)
@@ -1432,22 +1432,18 @@ ldouble: 3
 
 Function: "tgamma":
 double: 9
-float: 8
 ldouble: 4
 
 Function: "tgamma_downward":
 double: 9
-float: 7
 ldouble: 5
 
 Function: "tgamma_towardzero":
 double: 9
-float: 7
 ldouble: 5
 
 Function: "tgamma_upward":
 double: 9
-float: 8
 ldouble: 4
 
 Function: "y0":
index 1b25a70e3ffe6298ee393ddc20e4bd320d2f207e..ae054987190ebdbf8cac42eb911f8a4ac46a2b46 100644 (file)
@@ -146,7 +146,6 @@ double: 1
 
 Function: "tgamma":
 double: 1
-float: 1
 
 Function: "y0":
 double: 2
index 6eacfb6b6f72b2293fe20e3bcf4481479ce2633b..73e98eb479ae6e1a90960756d2cd2c1f6b1db2ba 100644 (file)
@@ -1208,22 +1208,18 @@ float: 1
 
 Function: "tgamma":
 double: 3
-float: 9
 ldouble: 9
 
 Function: "tgamma_downward":
 double: 3
-float: 9
 ldouble: 9
 
 Function: "tgamma_towardzero":
 double: 3
-float: 9
 ldouble: 9
 
 Function: "tgamma_upward":
 double: 2
-float: 9
 ldouble: 9
 
 Function: "y0":
index d3666eb7d4d04923a07f6fdf90346cf9564efbb1..98ea940cccb2c38347a26ca4f1c90e45f9da8e0a 100644 (file)
@@ -257,7 +257,6 @@ float: 2
 
 Function: "tgamma":
 double: 5
-float: 4
 
 Function: "y0":
 double: 2
index d95230724b699575674566d46cb90fc8995c613c..cc1600c2ab69e6d9a44829713d26bab07600eace 100644 (file)
@@ -1156,19 +1156,15 @@ float: 3
 
 Function: "tgamma":
 double: 9
-float: 8
 
 Function: "tgamma_downward":
 double: 9
-float: 7
 
 Function: "tgamma_towardzero":
 double: 9
-float: 7
 
 Function: "tgamma_upward":
 double: 9
-float: 8
 
 Function: "y0":
 double: 3
index ce33d9b4b367f7399600511c565d5cf7a0d071af..88dbb20401857d72ab9804f866cd711f0c417aec 100644 (file)
@@ -1444,22 +1444,18 @@ ldouble: 3
 
 Function: "tgamma":
 double: 9
-float: 8
 ldouble: 4
 
 Function: "tgamma_downward":
 double: 9
-float: 7
 ldouble: 5
 
 Function: "tgamma_towardzero":
 double: 9
-float: 7
 ldouble: 5
 
 Function: "tgamma_upward":
 double: 9
-float: 8
 ldouble: 4
 
 Function: "y0":
index c8d1a722f7d6a21c87dce9975ed50ce9822812b8..df6e932cb60a64ae4edfcff8522f2f36a26f2e8f 100644 (file)
@@ -266,7 +266,6 @@ float: 2
 
 Function: "tgamma":
 double: 9
-float: 8
 
 Function: "y0":
 double: 3
index 59b9f072f5d6af3e1e04492b7ffdbe01c2df5c27..4ccb13629848070cdae56067a592701bc1c8e54a 100644 (file)
@@ -1066,19 +1066,15 @@ float: 3
 
 Function: "tgamma":
 double: 9
-float: 8
 
 Function: "tgamma_downward":
 double: 9
-float: 9
 
 Function: "tgamma_towardzero":
 double: 9
-float: 8
 
 Function: "tgamma_upward":
 double: 9
-float: 8
 
 Function: "y0":
 double: 3
index 726855faaad6f790568d81bc304c414723f7ed63..7087cf9addff5322b1ece00d4703eef8113f7ded 100644 (file)
@@ -1064,19 +1064,15 @@ float: 3
 
 Function: "tgamma":
 double: 9
-float: 8
 
 Function: "tgamma_downward":
 double: 9
-float: 9
 
 Function: "tgamma_towardzero":
 double: 9
-float: 8
 
 Function: "tgamma_upward":
 double: 9
-float: 8
 
 Function: "y0":
 double: 3
index 2b5d2b940d472ed686f978b48cc506ebb41d6eef..dcefbcefcfaeda01755ebcfc5722e87b06293f69 100644 (file)
@@ -1828,25 +1828,21 @@ ldouble: 6
 
 Function: "tgamma":
 double: 9
-float: 8
 float128: 4
 ldouble: 5
 
 Function: "tgamma_downward":
 double: 9
-float: 7
 float128: 5
 ldouble: 6
 
 Function: "tgamma_towardzero":
 double: 9
-float: 7
 float128: 5
 ldouble: 5
 
 Function: "tgamma_upward":
 double: 9
-float: 8
 float128: 4
 ldouble: 5
 
index d56327ac33243c1adc1afcb35b9e2c432afd9e9c..14be978dc3906d68a8b70ccf28dad4328b2718ad 100644 (file)
@@ -1560,22 +1560,18 @@ ldouble: 6
 
 Function: "tgamma":
 double: 9
-float: 8
 ldouble: 5
 
 Function: "tgamma_downward":
 double: 9
-float: 7
 ldouble: 5
 
 Function: "tgamma_towardzero":
 double: 9
-float: 7
 ldouble: 5
 
 Function: "tgamma_upward":
 double: 9
-float: 8
 ldouble: 4
 
 Function: "y0":
index 9ad64d1d8595d8e303f4768083583acb6fb13596..4adad138b05639534dff0740bfa0b1f6e0cb1379 100644 (file)
@@ -1361,22 +1361,18 @@ ldouble: 3
 
 Function: "tgamma":
 double: 9
-float: 8
 ldouble: 4
 
 Function: "tgamma_downward":
 double: 5
-float: 5
 ldouble: 5
 
 Function: "tgamma_towardzero":
 double: 5
-float: 4
 ldouble: 5
 
 Function: "tgamma_upward":
 double: 4
-float: 4
 ldouble: 4
 
 Function: "y0":
index 233186f29a6738b24369765cfc5547923e40c534..07a8794e48d5099648c829ee98670d8e407b2bfc 100644 (file)
@@ -1431,22 +1431,18 @@ ldouble: 3
 
 Function: "tgamma":
 double: 9
-float: 8
 ldouble: 4
 
 Function: "tgamma_downward":
 double: 9
-float: 7
 ldouble: 5
 
 Function: "tgamma_towardzero":
 double: 9
-float: 7
 ldouble: 5
 
 Function: "tgamma_upward":
 double: 8
-float: 8
 ldouble: 4
 
 Function: "y0":
index e10b5c69ae20682c3e746a9e7c43b53dcbbbf890..6e4084ae3719a8d2a8890e64820759f966f9da5c 100644 (file)
@@ -1429,22 +1429,18 @@ ldouble: 3
 
 Function: "tgamma":
 double: 9
-float: 8
 ldouble: 4
 
 Function: "tgamma_downward":
 double: 9
-float: 7
 ldouble: 5
 
 Function: "tgamma_towardzero":
 double: 9
-float: 7
 ldouble: 5
 
 Function: "tgamma_upward":
 double: 9
-float: 8
 ldouble: 4
 
 Function: "y0":
index 3c84259941789fd98eddfa3eaab7cc3f510261b4..36f21ed395921d473187e630c41b205ed864004b 100644 (file)
@@ -532,11 +532,9 @@ float: 2
 
 Function: "tgamma":
 double: 9
-float: 8
 
 Function: "tgamma_towardzero":
 double: 9
-float: 7
 
 Function: "y0":
 double: 3
index 1bb8b7c5f490706c65d51b853b283b5f6a298955..ccb6c794e7a44d8cc6043de3173c06fbb18b3712 100644 (file)
@@ -1444,22 +1444,18 @@ ldouble: 3
 
 Function: "tgamma":
 double: 9
-float: 8
 ldouble: 4
 
 Function: "tgamma_downward":
 double: 9
-float: 7
 ldouble: 5
 
 Function: "tgamma_towardzero":
 double: 9
-float: 7
 ldouble: 5
 
 Function: "tgamma_upward":
 double: 9
-float: 8
 ldouble: 4
 
 Function: "y0":
index c2e36dcbdf36b8b6caeaefd79b488f15c94f8d5c..80d0125642bb7fe782cc7fecc7bf08a0a44017c0 100644 (file)
@@ -2263,25 +2263,21 @@ double: 1
 
 Function: "tgamma":
 double: 9
-float: 8
 float128: 4
 ldouble: 5
 
 Function: "tgamma_downward":
 double: 9
-float: 7
 float128: 5
 ldouble: 6
 
 Function: "tgamma_towardzero":
 double: 9
-float: 7
 float128: 5
 ldouble: 6
 
 Function: "tgamma_upward":
 double: 9
-float: 8
 float128: 4
 ldouble: 5
 
This page took 0.107362 seconds and 5 git commands to generate.