Python Numpy - Complex Numbers - Is there a function for Polar to Rectangular conversion? -


is there built-in numpy function convert complex number in polar form, magnitude , angle (degrees) 1 in real , imaginary components?

clearly write own seems type of thing there optimised version included in module?

more specifically, have array of magnitudes , array of angles:

>>> array([1, 1, 1, 1, 1]) >>> b array([120, 121, 120, 120, 121]) 

and is:

>>> c [(-0.5+0.8660254038j),(-0.515038074+0.8571673007j),(-0.5+0.8660254038j),(-0.5+0.8660254038j),(-0.515038074+0.8571673007j)] 

there isn't function want, there angle, hardest part. so, example, 1 define 2 functions:

def p2r(radii, angles):     return radii * exp(1j*angles)  def r2p(x):     return abs(x), angle(x) 

these functions using radians input , output, , degrees, 1 need conversion radians in both functions.

in numpy reference there's section on handling complex numbers, , function you're looking listed (so since they're not there, don't think exist within numpy).


Comments

Popular posts from this blog

java - Jmockit String final length method mocking Issue -

asp.net - Razor Page Hosted on IIS 6 Fails Every Morning -

c++ - wxwidget compiling on windows command prompt -