-
Notifications
You must be signed in to change notification settings - Fork 1.6k
<complex>: Replace handwritten transcendental functions
#5956
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Stephan T. Lavavej (StephanTLavavej)
wants to merge
18
commits into
microsoft:main
from
StephanTLavavej:math-blaster
Closed
Changes from all commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
aba61fe
Fuse xfcosh.cpp into xcosh.cpp.
StephanTLavavej 85ca579
Fuse xfsinh.cpp into xsinh.cpp.
StephanTLavavej 273a6e3
`_CSTD _Cosh(_Left, _Right)` => `_STD cosh(_Left) * _Right`
StephanTLavavej e1a89bd
`_CSTD _Sinh(_Left, _Right)` => `_STD sinh(_Left) * _Right`
StephanTLavavej 92fc841
Remove non-dllexported `_Xbig`, `_FXbig`.
StephanTLavavej 239063b
Remove non-dllexported _Feraise() and its macros.
StephanTLavavej 7a1618e
Remove now-unused DSIGN, FSIGN macros.
StephanTLavavej 50dd871
Fuse xfdtest.cpp into xdtest.cpp.
StephanTLavavej 2d929dc
Preserve `_Dtest`, `_LDtest`, `_FDtest` for bincompat.
StephanTLavavej b1c90af
Implement `_Dtest` with `fpclassify`.
StephanTLavavej 7d68c05
Fuse xfexp.cpp into xexp.cpp.
StephanTLavavej d3fdf99
Preserve `_Exp`, `_FExp`, `_LExp` for bincompat.
StephanTLavavej ba064e5
Remove non-dllexported `_FDnorm`, `_FDscale`, `_Xfe_overflow`, `_Xfe_…
StephanTLavavej 9588388
Delete xmath.hpp, replace with `<cmath>`.
StephanTLavavej f97b4ad
Delete internal but user-visible `<ymath.h>`, fuse remnants into `<co…
StephanTLavavej 2ef76e0
Restore special case for zero to the `_Exp` codepaths. Enable passing…
StephanTLavavej 858b3b3
Overhaul GH_001059_hyperbolic_truncation to expect more accurate resu…
StephanTLavavej 3a6a997
x86 actually behaves correctly.
StephanTLavavej File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,43 +1,23 @@ | ||
| // Copyright (c) Microsoft Corporation. | ||
| // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
|
|
||
| #include "xmath.hpp" | ||
| #include <cmath> | ||
|
|
||
| _EXTERN_C_UNLESS_PURE | ||
|
|
||
| _CRTIMP2_PURE double __CLRCALL_PURE_OR_CDECL _Cosh(double x, double y) noexcept { // compute y * cosh(x), |y| <= 1 | ||
| switch (_Dtest(&x)) { // test for special codes | ||
| case _NANCODE: | ||
| case _INFCODE: | ||
| return x; | ||
| case 0: | ||
| return y; | ||
| default: // finite | ||
| if (y == 0.0) { | ||
| return y; | ||
| } | ||
|
|
||
| if (x < 0.0) { | ||
| x = -x; | ||
| } | ||
|
|
||
| if (x < _Xbig) { // worth adding in exp(-x) | ||
| _Exp(&x, 1.0, -1); | ||
| return y * (x + 0.25 / x); | ||
| } | ||
| switch (_Exp(&x, y, -1)) { // report over/underflow | ||
| case 0: | ||
| _Feraise(_FE_UNDERFLOW); | ||
| break; | ||
| case _INFCODE: | ||
| _Feraise(_FE_OVERFLOW); | ||
| } | ||
| return x; | ||
| } | ||
| // TRANSITION, ABI: preserved for binary compatibility | ||
| _CRTIMP2_PURE double __CLRCALL_PURE_OR_CDECL _Cosh(double x, double y) noexcept { | ||
| return _STD cosh(x) * y; | ||
| } | ||
|
|
||
| // TRANSITION, ABI: preserved for binary compatibility | ||
| _CRTIMP2_PURE long double __CLRCALL_PURE_OR_CDECL _LCosh(long double x, long double y) noexcept { | ||
| return _Cosh(static_cast<double>(x), static_cast<double>(y)); | ||
| return _STD cosh(x) * y; | ||
| } | ||
|
|
||
| // TRANSITION, ABI: preserved for binary compatibility | ||
| _CRTIMP2_PURE float __CLRCALL_PURE_OR_CDECL _FCosh(float x, float y) noexcept { | ||
| return _STD cosh(x) * y; | ||
| } | ||
|
|
||
| _END_EXTERN_C_UNLESS_PURE |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,27 +1,23 @@ | ||
| // Copyright (c) Microsoft Corporation. | ||
| // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
|
|
||
| // _Dtest function -- IEEE 754 version | ||
|
|
||
| #include "xmath.hpp" | ||
| #include <cmath> | ||
|
|
||
| _EXTERN_C_UNLESS_PURE | ||
|
|
||
| _CRTIMP2_PURE short __CLRCALL_PURE_OR_CDECL _Dtest(double* px) noexcept { // categorize *px | ||
| const auto ps = reinterpret_cast<_Dval*>(px); | ||
| // TRANSITION, ABI: preserved for binary compatibility | ||
| _CRTIMP2_PURE short __CLRCALL_PURE_OR_CDECL _Dtest(double* px) noexcept { | ||
| return static_cast<short>(_STD fpclassify(*px)); | ||
| } | ||
|
|
||
| if ((ps->_Sh[_D0] & _DMASK) == _DMAX << _DOFF) { | ||
| return (ps->_Sh[_D0] & _DFRAC) != 0 || ps->_Sh[_D1] != 0 || ps->_Sh[_D2] != 0 || ps->_Sh[_D3] != 0 ? _NANCODE | ||
| : _INFCODE; | ||
| } else if ((ps->_Sh[_D0] & ~_DSIGN) != 0 || ps->_Sh[_D1] != 0 || ps->_Sh[_D2] != 0 || ps->_Sh[_D3] != 0) { | ||
| return (ps->_Sh[_D0] & _DMASK) == 0 ? _DENORM : _FINITE; | ||
| } else { | ||
| return 0; | ||
| } | ||
| // TRANSITION, ABI: preserved for binary compatibility | ||
| _CRTIMP2_PURE short __CLRCALL_PURE_OR_CDECL _LDtest(long double* px) noexcept { | ||
| return static_cast<short>(_STD fpclassify(*px)); | ||
| } | ||
|
|
||
| _CRTIMP2_PURE short __CLRCALL_PURE_OR_CDECL _LDtest(long double* px) noexcept { // categorize *px -- 64-bit | ||
| return _Dtest(reinterpret_cast<double*>(px)); | ||
| // TRANSITION, ABI: preserved for binary compatibility | ||
| _CRTIMP2_PURE short __CLRCALL_PURE_OR_CDECL _FDtest(float* px) noexcept { | ||
| return static_cast<short>(_STD fpclassify(*px)); | ||
| } | ||
|
|
||
| _END_EXTERN_C_UNLESS_PURE |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.