nlcpy.imag

nlcpy.imag(val)

Returns the imaginary part of the complex argument.

Parameters
valarray_like

Input arrays or scalars.

Returns
outndarray

The imaginary component of the complex argument. If val is real, the type of val is used for the output. If val has complex elements, the returned type is float. If val is a scalar, this function returns the result as a 0-dimention array.

参考

real

Returns the real part of the complex argument.

angle

Returns the angle of the complex argument.

Examples

>>> import nlcpy as vp
>>> a = vp.array([1+2j, 3+4j, 5+6j])
>>> a.imag
array([2., 4., 6.])
>>> a.imag = vp.array([8, 10, 12])
>>> a
array([1. +8.j, 3.+10.j, 5.+12.j])
>>> vp.imag(1 + 1j)
array(1.)