trouble with complex numbers
Piet van Oostrum
piet at cs.uu.nl
Wed Aug 5 08:34:31 EDT 2009
>>>>> Christian Heimes <lists at cheimes.de> (CH) wrote:
>CH> You can write your own phase() function. This function is mostly correct
>CH> unless either the real and/or the imag part is NaN or INF.
>CH> from math import atan2
>CH> def phase(z):
>CH> z += 1j # convert int, long, float to complex
That should be z += 0j
>CH> return atan2(z.imag, z.real)
--
Piet van Oostrum <piet at cs.uu.nl>
URL: http://pietvanoostrum.com [PGP 8DAE142BE17999C4]
Private email: piet at vanoostrum.org
More information about the Python-list
mailing list