diff options
| author | lntue <lntue@google.com> | 2025-10-21 13:33:09 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-10-21 13:33:09 -0400 |
| commit | 513f9c50e74e55b7f8dedf65105bdc1083d4f83d (patch) | |
| tree | 0eecbc7ef1a4e0ef56dc2364980df46290f6e11b /lldb/packages/Python/lldbsuite/test/gdbclientutils.py | |
| parent | 4a1ea3e4a973b1b742ce578661017a3f3eb6acfe (diff) | |
| download | llvm-513f9c50e74e55b7f8dedf65105bdc1083d4f83d.zip llvm-513f9c50e74e55b7f8dedf65105bdc1083d4f83d.tar.gz llvm-513f9c50e74e55b7f8dedf65105bdc1083d4f83d.tar.bz2 | |
[libc][math] Add float-only implementation for sinf / cosf. (#161680)
Based on the double precision's sin/cos fast path algorithm:
Step 1: Perform range reduction `y = x mod pi/8` with target errors <
2^-54.
This is because the worst case mod pi/8 for single precision is ~2^-31,
so to have up to 1 ULP errors from
the range reduction, the targeted errors should `be 2^(-31 - 23) =
2^-54`.
Step 2: Polynomial approximation
We use degree-5 and degree-4 polynomials to approximate sin and cos of
the reduced angle respectively.
Step 3: Combine the results using trig identities
```math
\begin{align*}
\sin(x) &= \sin(y) \cdot \cos(k \cdot \frac{\pi}{8}) + \cos(y) \cdot \sin(k \cdot \frac{\pi}{8}) \\
\cos(x) &= \cos(y) \cdot \cos(k \cdot \frac{\pi}{8}) - \sin(y) \cdot \sin(k \cdot \frac{\pi}{8})
\end{align*}
```
Overall errors: <= 3 ULPs for default rounding modes (tested
exhaustively).
Current limitation: large range reduction requires FMA instructions for
binary32. This restriction will be removed in the followup PR.
---------
Co-authored-by: Petr Hosek <phosek@google.com>
Diffstat (limited to 'lldb/packages/Python/lldbsuite/test/gdbclientutils.py')
0 files changed, 0 insertions, 0 deletions
