Open chrboesch opened 1 week ago
sqrtmag
sounds like "square root of magnitude". I suggest to rename the function to sqrmag
(remove the t
), for reference in Unity it's called sqrMagnitude
@Atomk from wikipedia:
(...) This allows to define the absolute value (or modulus or magnitude) of z to be the square root
$$ |z|=\sqrt{x^2+y^2} $$
It incorrect usage of terminology (and therefore confusing) to call the magnitude the square root of the magnitude. Unity is just wrong. c++'s std::complex
has the correct definition.
It incorrect usage of terminology (and therefore confusing) to call the magnitude the square root of the magnitude.
You're right. This is the magnitude of a complex number: $$|z| = \sqrt{a^2 + b^2}$$
And to get rid of the root you square it. That is called "magnitude squared": $|z|^2 = a^2 + b^2$.
See University of Houston (https://www.math.uh.edu/~dblecher/4389complex_numbers.pdf) That is exactly what this function does. You square the magnitude. That's why 'sqrmag' fits well for this function, in my view.
A required function in signal processing which, if you don't know exactly what it does, is reproduced as it is in the test. This then leads to inaccuracies, which is not necessary or should not be the case.