On 24/10/2024 20.03, Paul Caprioli via Std-Proposals wrote:
> My colleagues and I are looking into the accuracy of complex mathematical operations/functions with different compilers/libraries.
> The first version of our paper is available at: https://inria.hal.science/hal-04714173
>
> In the Numerics [complex.transcendentals] section of the C++ standard, some functions (e.g., acos) have a remark, "Behaves the same as the C function cacos.
> See also: ISO/IEC 9899:2018." Others (e.g., log) have a note, "The semantics of this function are intended to be the same in C++ as they are for clog in C."
> Others (e.g., cos) have neither.
>
> Are these differences intentional and meaningful? I would appreciate any pointers or help in learning more.
These words probably haven't been touched for three decades.
Some of them, yes.
cos(const complex<T>&) was present in C++98, and there was no ccos in ISO C at the time, so nothing that it could refer to. ccos was added to C99.
acos(const complex<T>&) was not present in C++98, it was added in C++11. By that time, C had standardized cacos, so acos(complex<T>) could refer to cacos. It looks like when the new complex functions were added to C++11, somebody took the opportunity to add references to the corresponding functions in C99.
log(const complex<T>&) was in C++98, but like the cos/ccos case above, it couldn't refer to clog because that wasn't in C. The note about the semantics being intended to be the same as C was added by the defect report
https://cplusplus.github.io/LWG/issue2597 which also removed a contradictory requirement. So that was clarifying a specific property that had been previously specified differently. That's why it's not in the same form as the cross-references for the "new" functions added in C++11.
So the differences are because the wording was added and/or changed at different times, by different people. I don't think that is intended to convey any different meaning though. As Jens said, those functions should all be consistent with the corresponding ones in C.
My guess is that we want "the same" behavior as in C for all of those functions
(e.g. regarding branch cuts), and the differences in note phrasing are accidental.
I would guess that all C++ implementations defer to the corresponding C functions
for those trigonometrics.
Quote from the paper, section 3:
"The following table shows the results for the complex bivariate operations in single precision."
What are the "results"? It would be good to repeat what the numbers mean.
Jens
--
Std-Proposals mailing list
Std-Proposals@lists.isocpp.org
https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals