This may sound like a bit of a rhetorical question, but I ask it here for two reasons:
norm()
function as being something different (though closely related) to what is generally considered to be the norm (or L2-norm, or Euclidean norm, etc., etc.)Specifically the C++ standard library defines norm()
for complex numbers to be the square of the modulus (or absolute value), where the modulus is sqrt(a^2 + b^2) when the complex number is in the form a + i*b.
This goes against my understanding of the norm, which when specified as the Euclidean norm (which corresponds to the modulus used here), is the square root of the sum of squares. I'll reference Mathworld's definition of the complex modulus.
Is this something others have run into? I found it as a result of porting some signal processing code from Octave to C++, and the only other place I found reference to this difference was on the GCC mailing list.
The C++ usage of the word "norm" is rather confusing, since most people have only ever come across norms in the context of vector spaces. If you view the complex numbers as a vector space over the reals, this is definitely not a norm. In fairness to C++, the std::norm( ) function does compute the so-called Field Norm from the complex numbers to the reals.
Fortunately, there is the std::abs( ) function, which does what you want.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With