-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
std.math.complex: Added a missing complex function. #21998
base: master
Are you sure you want to change the base?
Conversation
lib/std/math/complex.zig
Outdated
@@ -115,6 +115,11 @@ pub fn Complex(comptime T: type) type { | |||
pub fn magnitude(self: Self) T { | |||
return @sqrt(self.re * self.re + self.im * self.im); | |||
} | |||
|
|||
/// Returns the quared magnitude of a complex number. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A typo: quared
should be squared
|
It incorrect usage of terminology (and therefore confusing) to call the magnitude the square root of the magnitude. Unity is just wrong. c++'s |
You're right. This is the magnitude of a complex number: And to get rid of the root you square it. That is called "magnitude squared": See University of Houston (https://www.math.uh.edu/~dblecher/4389complex_numbers.pdf) |
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.