This may sound like a bit of a rhetorical question, but I ask it here for two reasons:
- It took me a while to figure out what C++ std::norm() was doing differently from Matlab/Octave, so others may stumble upon it here.
- I find it odd to define the
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 (can't post the link due to 1-link limit).