You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
104: Adapted complex exp() function so that it can handle inf and nan arguments as well r=cuviper a=JorisDeRidder
### Why this PR?
The current version of the complex exp() function is not able to handle arguments that contain +/- inf or NaN in their real or imaginary part. This impacts other complex functions that use the exp() function.
For example, for the most widely used implementation of the complex Faddeeva function `w()`, the current `exp()` implementation leads to `w(1e160 - 1e159*i) = NaN + NaN *i` , while the correct value is `-5.586035480670854e-162 + 5.5860354806708545e-161 * i`. The underlying reason is that the current `exp()` implementation erroneously returns `exp(-inf + inf *i) = NaN + Nan *i` instead of the correct `0 + 0*i`.
Cf also issue #103.
### Contents of this PR
- I propose a modified complex exp() function that does deal with inf and nan. The added logic was strongly inspired by the one implemented in the `<complex>` C++ header that comes with clang++.
- I added extra unit tests. The relevant values were taken from [this page](https://en.cppreference.com/w/cpp/numeric/complex/exp).
- For the unit tests I also implemented `close_naninf()` and `close_naninf_to_tol()` as the existing functions `close()` and `close_to_tol()` are not able to deal with inf and nan.
Co-authored-by: Joris De Ridder <joris.deridder@kuleuven.be>
Co-authored-by: Joris De Ridder <5747893+JorisDeRidder@users.noreply.github.com>
0 commit comments