dpnp.real

dpnp.real(x, out=None, order='K')

Computes real part of each element x_i for input array x.

For full documentation refer to numpy.real.

Parameters:
  • x ({dpnp.ndarray, usm_ndarray}) -- Input array, expected to have numeric data type.

  • out ({None, dpnp.ndarray, usm_ndarray}, optional) -- Output array to populate. Array must have the correct shape and the expected data type. Default: None.

  • order ({"C", "F", "A", "K"}, optional) -- Memory layout of the newly output array, if parameter out is None. Default: "K".

Returns:

out -- An array containing the element-wise real component of input. If the input is a real-valued data type, the returned array has the same data type. If the input is a complex floating-point data type, the returned array has a floating-point data type with the same floating-point precision as complex input.

Return type:

dpnp.ndarray

See also

dpnp.real_if_close

Return the real part of the input is complex with all imaginary parts close to zero.

dpnp.imag

Return the imaginary part of the complex argument.

dpnp.angle

Return the angle of the complex argument.

Examples

>>> import dpnp as np
>>> 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(np.array(1 + 1j))
array(1.)