mirror-llvm-project/libc/utils
Anonmiraj f05a649741
[libc][math] Implement half precision lgamma function (#192834)
The implementation uses three distinct paths based on $|x|$:

- Small ($|x| < 0.66$): Fits a degree-12 Chebyshev for $h(t) =
\frac{\text{lgamma}(t) + \log(t)}{t}$, recovering $\text{lgamma}(t) = t
\cdot h - \log(t)$.

- Medium ($|x| \in [0.66, 3.37]$): Fits a degree-20 Chebyshev for $g(t)
= \frac{\text{lgamma}(t)}{(t-1)(t-2)}$
- Stirling ($|x| > 3.37$): Uses $(x-0.5) \cdot \log(x) - x +
\frac{\log(2\pi)}{2}$ plus 1/2/4/8-term Bernoulli corrections by
sub-range.


Special cases: NaN, +/-Inf -> +Inf, +/-0 pole, negative integer pole,
lgamma(1) = lgamma(2) = 0 exactly, overflow for large positive x.

Exhaustive tests pass in all 4 rounding modes.

-- CORE-MATH reciprocal throughput --
Ntrial = 20 ; Min = 391.348 + 77.447 clc/call; Median-Min = 68.093
clc/call; Max = 540.055 clc/call;
-- System LIBC reciprocal throughput --
Ntrial = 20 ; Min = 377.829 + 81.686 clc/call; Median-Min = 64.851
clc/call; Max = 532.888 clc/call;
2026-07-19 04:29:50 +03:00
..
buildbot [libc] Remove unused AOR_v20.02 directory (#185951) 2026-03-12 10:14:04 -04:00
docgen [libc][docs] Dynamically generate time.h documentation (#210197) 2026-07-17 08:14:57 +01:00
hdrgen [libc] Add public_includes stanza to hdrgen and use it in socket headers (#205543) 2026-06-29 08:13:17 +02:00
libctest Reland: [lit] Move maxIndividualTestTime from global to test suite config (#199996) 2026-05-27 20:19:29 +00:00
mathtools
MPCWrapper [libc][complex] Enable cabs and cabsf in libc (#206677) 2026-07-06 10:55:08 +08:00
MPFRWrapper [libc][math] Implement half precision lgamma function (#192834) 2026-07-19 04:29:50 +03:00
wctype_utils [libc][wctype] Move classification lookup tables to a cpp file (#174993) 2026-02-05 17:58:50 +01:00
CMakeLists.txt