[Numpy-discussion] Assigning complex value to real array

Andrew P. Mullhaupt doc@zen-pharaohs....
Thu Oct 7 17:02:43 CDT 2010


  On 10/7/2010 3:45 PM, josef.pktd@gmail.com wrote:
> what's your namespace?from scipy import log
>>>> log(int(-2))
> (0.69314718055994529+3.1415926535897931j)

This should explain:

andrew@flyer:~$ python
Enthought Python Distribution -- http://www.enthought.com
Version: 6.2-2 (64-bit)

Python 2.6.5 |EPD 6.2-2 (64-bit)| (r265:79063, Mar 22 2010, 17:32:05)
[GCC 4.1.2 20080704 (Red Hat 4.1.2-44)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
 >>> from numpy import *
 >>> log(int(-2))
nan
 >>> from scipy import *
 >>> log(int(-2))
(0.69314718055994529+3.1415926535897931j)
 >>> R = ones(2)
 >>> R[0] = R[0] * 1j
 >>> R
array([ 0.,  1.])
 >>> R = ones(2, 'complex')
 >>> R[0] = R[0] * 1j
 >>> R
array([ 0.+1.j,  1.+0.j])


Best Regards,
Andrew Mullhaupt



More information about the NumPy-Discussion mailing list