Bug in complex::norm

nbecker@fred.net nbecker@fred.net
Tue Aug 21 10:46:00 GMT 2001


I just updated to gcc-3.0.1 and found a problem with the
implementation of complex::norm.

It seems that norm is now defined in terms of abs!  This is not
efficient and is wrong for non-float types.

The definition of norm should be

template<typename T>
inline T norm (const complex<T>& z) {
        return real (z) * real (z) + imag (z) * imag (z)
}



More information about the Libstdc++ mailing list