H
highegg
hello,
the C++ standard defines std::norm (const std::complex<T>& x) to
return "the squared magnitude of x".
Earlier in the same section, std::abs is defined as returning "the
magnitude of x".
This wording is a little unfortunate, as it may suggest that the
std::norm(x) should be equal to std::abs(x) squared.
To my disappointment, this is what current GCC does, referring to the
standard as a reasoning.
I think that the intent of std::norm was clearly to provide a
convenient way to efficiently calculate squared magnitude *without*
the need to calculate a square root (and then square back). Hence, GCC
has turned a potentially useful function into a useless one.
What do you think? Did the author misinterpret the standard, or did he
take it too literally?
Is it GCC or the standard that should be fixed? Perhaps there could be
a clarification in the standard?
regards
Jaroslav Hajek
the C++ standard defines std::norm (const std::complex<T>& x) to
return "the squared magnitude of x".
Earlier in the same section, std::abs is defined as returning "the
magnitude of x".
This wording is a little unfortunate, as it may suggest that the
std::norm(x) should be equal to std::abs(x) squared.
To my disappointment, this is what current GCC does, referring to the
standard as a reasoning.
I think that the intent of std::norm was clearly to provide a
convenient way to efficiently calculate squared magnitude *without*
the need to calculate a square root (and then square back). Hence, GCC
has turned a potentially useful function into a useless one.
What do you think? Did the author misinterpret the standard, or did he
take it too literally?
Is it GCC or the standard that should be fixed? Perhaps there could be
a clarification in the standard?
regards
Jaroslav Hajek