-
-
Notifications
You must be signed in to change notification settings - Fork 10.9k
Add numpy.phase in addition to numpy.angle #3621
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
Comments
A shorter implementation would be I'm dubious that such a tiny function is worth including...
|
@njsmith Some folks use that as the |
I don't have a strong opinion either way, just raising the issue. Having a what the heck does our sign function do for complex numbers? Is this like (numpy.linalg.slogdet is one function that uses the abs(z) == 1 definition On Thu, Aug 15, 2013 at 2:38 PM, Charles Harris notifications@github.comwrote:
|
Yep, that is what it does ;) I don't know that we can just change it, OTOH, I doubt many use the current form for complex. |
Yeah, if my guess is right and no-one uses that, then no-one will complain On Thu, Aug 15, 2013 at 9:48 PM, Charles Harris notifications@github.comwrote:
|
Numpy's complex sign function is -1 for changing this. |
Huh, that is interesting! Thanks. It does look like every software package I can find uses the z/|z|
|
Yes, numpy seems to be pretty much alone in defining sign for complex-valued numbers like this. (Ok, not alone if you count mathematical literature.) However, because the behavior is still sort of sensible, I'd be somewhat wary of changing it, as it is not clear that it won't break things. The documentation should be changed to mention the exact definition used in any case, though. |
How about adding a sgn function? Documentation of |
Side note: an argument against calling such a function |
On a similar note, an implementation of |
Second the idea of extending |
I'm closing this in favour of #13179 (mostly since the title no longer reflects the discussion, and because I think the request makes more sense as part of a larger effort to make working with complex numbers a little easier). |
I wanted to suggest adding a function which directly gives the phase of a complex valued number instead of the angle:
This is a simple enhancement, which I think would make numpy more consistent and offer the benefit of simply being faster in large loops, rather than going the
ang = numpy.angle(z); phase = numpy.cos(ang) + 1j * numpy.sin(ang)
route (ornumpy.cos(1j * ang)
, for what it's worth).The text was updated successfully, but these errors were encountered: