aboutsummaryrefslogtreecommitdiff
path: root/math/sincosf.c
AgeCommit message (Collapse)Author
2022-02-10Update lincense to MIT OR Apache-2.0 WITH LLVM-exceptionSzabolcs Nagy
The outgoing license was MIT only. The new dual license allows using the code under Apache-2.0 WITH LLVM-exception license too.
2021-12-21math: fix constant in sinf and cosfSzabolcs Nagy
gcc-12 -frounding-math started using runtime rounding mode for converting double constants to float, so abstop12(pio4) is no longer a compile time constant (this is required by iso c). Use float pio4f instead to make the generated code the same as before and avoid regressions on gcc-12.
2021-02-17Update copyright yearsSzabolcs Nagy
Scripted copyright year updates based on git committer date.
2019-07-18Remove math/single and rem_pio2Szabolcs Nagy
math/single contained code for systems without double precision fpu and rem_pio2 is not used currently and likely will be designed differently when double precision trigonometric functions are added.
2018-11-22Relicence the project under the MIT LicenseSzabolcs Nagy
2018-08-08Improve sincosf commentsWilco Dijkstra
Improve comments. Use TOINT_INTRINSICS rather than HAVE_FAST_ROUND.
2018-07-04Fix namespace issues in sincosfWilco Dijkstra
Use const sincos_t for clarity instead of making the typedef const. Use __inv_pi4 and __sincosf_table to avoid namespace issues with static linking.
2018-06-29Fix GNU style issuesSzabolcs Nagy
Whitespace changes only.
2018-05-16Improve performance of sinf/cosf/sincosfWilco Dijkstra
This patch is a complete rewrite of sinf, cosf and sincosf. The new version is significantly faster, as well as simple and accurate. The worst-case ULP is 0.56072, maximum relative error is 0.5303p-23 over all 4 billion inputs. In non-nearest rounding modes the error is 1ULP. The algorithm uses 3 main cases: small inputs which don't need argument reduction, small inputs which need a simple range reduction and large inputs requiring complex range reduction. The code uses approximate integer comparisons to quickly decide between these cases - on some targets this may be slow, so this can be configured to use floating point comparisons. The small range reducer uses a single reduction step to handle values up to 120.0. It is fastest on targets which support inlined round instructions. The large range reducer uses integer arithmetic for simplicity. It does a 32x96 bit multiply to compute a 64-bit modulo result. This is more than accurate enough to handle the worst-case cancellation for values close to an integer multiple of PI/4. It could be further optimized, however it is already much faster than necessary.