Skip to content

Add numpy.phase in addition to numpy.angle #3621

@SuperFluffy

Description

@SuperFluffy

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).

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions