mirror-llvm-project/libc/config
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
..
baremetal [libc][math] Implement half precision lgamma function (#192834) 2026-07-19 04:29:50 +03:00
darwin [libc][math] Implement half precision lgamma function (#192834) 2026-07-19 04:29:50 +03:00
freebsd/x86_64 [libc][math][c++23] Add expbf16 math function (#161919) 2026-06-27 16:55:55 +05:30
gpu [libc][math] Implement half precision lgamma function (#192834) 2026-07-19 04:29:50 +03:00
linux [libc][math] Implement half precision lgamma function (#192834) 2026-07-19 04:29:50 +03:00
uefi [libc][NFC] Add stdint.h proxy header to fix dependency issue with <stdint.h> includes. (#150303) 2025-07-23 20:19:52 -04:00
windows [libc][math][c++23] Add expbf16 math function (#161919) 2026-06-27 16:55:55 +05:30
app.h [libc][uefi] add crt1 (#132150) 2025-05-09 09:02:33 -07:00
CMakeLists.txt [libc][NFC] Add stdint.h proxy header to fix dependency issue with <stdint.h> includes. (#150303) 2025-07-23 20:19:52 -04:00
config.json [libc][math] Adding LIBC_MATH_ASSUME_ROUND_NEAREST_ONLY option (#201154) 2026-06-11 13:42:28 -04:00