-
Notifications
You must be signed in to change notification settings - Fork 11.6k
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
Complex arithmetic bug: creal(0+I*Inf) -> NaN #59681
Comments
@llvm/issue-subscribers-clang-frontend |
From C2x Annex G.3p1: "A complex or imaginary value with at least one infinite part is regarded as an infinity (even if its other part is a quiet NaN). A complex or imaginary value is a finite number if each of its parts is a finite number (neither infinite nor NaN). A complex or imaginary value is a zero if each of its parts is a zero." So I believe |
You are refering to https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3054.pdf, right? Sect G3, which you quoted in full length, says that a+I*inf is to be regarded as infinity. This is important for function like The addition operator is treated in Sect G5.2, which however only states the obvious, and does not explicitly refer to infinities. For our purpose most helpful is Sect G6, which specifies some function values for infinite arguments. Specfically, G6.1.1 says about the complex arccos function: "cacos(x + i∞) returns π2 − i∞, for finite x." From this it is absolutely clear that complex numbers with one finite and one infinite component should be supported as such. |
Correct
I may not be understanding the summary of the issue then. I was under the impression that I might be getting thrown off by having no idea what type
I think I agree, but given my confidence level, I'm going to CC @jcranmer-intel for a second opinion that this issue should be confirmed. |
Say, |
libcerf-2.4, released 2aug23: - CMake: runtime destination corrected (bin, not lib) - CMake: removed option PORTABLE and compiler flag -march (unavailable on some architectures) libcerf-2.3, released 10jan23: - Fix compiler flags; use -O3 for Release - Introduce CERF_COMPILE_OPTIONS to let users overwrite the hard-coded compile options - Under gcc, use -march=native - PACKAGE MAINTAINERS: use -DPORTABLE=ON to override this !! - Add test coverage for erfcx, dawson, im_w_of_x (against nearby complex and status quo) - Avoid some divisions in function voigt (suggested by Alexander Kleinsorge) - Accelerate lookup in erfcx, im_w_of_x (avoid long switch, contributed by Alexander Kleinsorge) - Work around clang bug llvm/llvm-project#59681 (0+I*Inf->NaN) libcerf-2.2, released 7nov22: - No longer raise underflow error in w_of_z for large real arg (contributed by Ethan Merritt) - In test suite, confound zero with values close to underflow - Remove some invisible files that had slipped in accidentally (noticed by Christoph Junghans) - Windows binary now built with Visual Studio 17 2022 libcerf-2.1, released 8apr22: - Provide cerfConfig.cmake (contributed by Lori A. Burns and Christoph Junghans) - libcerf.pc: Remove hard-coded lib/ - Version number incremented to overcome upstream problems with withdrawn release 2.0 libcerf-1.17, released 29jun21: - Correct pkgconfig installation directory (use GNU install dirs, install to LIBDIR/pkgconfig) libcerf-1.16, released 23jun21: - voigt_hwhm: replaced Newton's method (which failed for rare parameter combinations) by Illinois regula falsi (contributed by Ethan A Merritt) - Some internal cleanup, especially of include directives libcerf-1.15, released 10jun21: - Use assertion in voigt_hwhm to check for impossible situations (to avoid fprintf and exit, as suggested by Ethan A Merritt) - Added widthtest, which tests voigt_hwhm for numerous ratios gamma/sigma - libcerf.pc.in: correct prefix (as suggested by Alexander Grund) - CMake install - make full use of CMAKE_INSTALL_<dir> variables - DESTINATION now given by LIBDIR from GNUInstallDirs - Support CPack for all platforms libcerf-1.14, released 19oct20: - Simplified test code - Homepage moved to https://jugit.fz-juelich.de/mlz/libcerf, 17mar19
In C99, there is no constructor for complex numbers. We need to write z = a + I*b. When b is Inf, then z becomes NaN. In numeric code, however, it may make perfect sense to rely on Re(z) = a.
This problem is known at since 12 years [1]. Other compilers (gcc, MSVC) do it right.
[1] https://www.mail-archive.com/freebsd-toolchain@freebsd.org/msg00000.html
The text was updated successfully, but these errors were encountered: