Equivalent of j in NumPy

In Python, 1j or 0+1j is a literal of complex type. You can broadcast that into an array using expressions, for example

In [17]: 1j * np.arange(5)
Out[17]: array([ 0.+0.j,  0.+1.j,  0.+2.j,  0.+3.j,  0.+4.j])

Create an array from literals:

In [18]: np.array([1j])
Out[18]: array([ 0.+1.j])

Note that what Michael9 posted creates a complex, not a complex array:

In [21]: np.complex(0,1)
Out[21]: 1j
In [22]: type(_)
Out[22]: complex

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)