flopscope.numpy.real
fnp.real(val)[flopscope source][numpy source]
Return the real part of the complex argument.
Adapted from NumPy docs np.real
Cost
Flopscope Context
Return real part of complex array.
Parameters
- val:array_like
Input array.
Returns
- out:ndarray or scalar
The real component of the complex argument. If
valis real, the type ofvalis used for the output. Ifvalhas complex elements, the returned type is float.
See also
Examples
>>> import flopscope.numpy as fnp
>>> a = flops.array([1+2j, 3+4j, 5+6j])
>>> a.real
array([1., 3., 5.])
>>> a.real = 9
>>> a
array([9.+2.j, 9.+4.j, 9.+6.j])
>>> a.real = flops.array([9, 8, 7])
>>> a
array([9.+2.j, 8.+4.j, 7.+6.j])
>>> flops.real(1 + 1j)
1.0