-
-
Notifications
You must be signed in to change notification settings - Fork 12.2k
Add numpy.phase in addition to numpy.angle #3621
Copy link
Copy link
Closed
Description
I wanted to suggest adding a function which directly gives the phase of a complex valued number instead of the angle:
def phase(z): # Calculates the phase of a complex number
r = numpy.absolute(z)
return (z.real/r + 1j * z.imag/r)
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 (or numpy.cos(1j * ang), for what it's worth).
Reactions are currently unavailable