numpy.real
-
numpy.real(val)
[source] -
Return the real part of the complex argument.
- Parameters
-
-
valarray_like
-
Input array.
-
- Returns
-
-
outndarray or scalar
-
The real component of the complex argument. If
val
is real, the type ofval
is used for the output. Ifval
has complex elements, the returned type is float.
-
See also
Examples
>>> a = np.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 = np.array([9, 8, 7]) >>> a array([9.+2.j, 8.+4.j, 7.+6.j]) >>> np.real(1 + 1j) 1.0
© 2005–2020 NumPy Developers
Licensed under the 3-clause BSD License.
https://numpy.org/doc/1.18/reference/generated/numpy.real.html