dpnp.abs

dpnp.abs(x, out=None, where=True, order='K', dtype=None, subok=True, **kwargs)

Calculate the absolute value element-wise.

For full documentation refer to numpy.absolute.

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

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

  • 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 absolute values. For complex input, the absolute value is its magnitude. If x has a real-valued data type, the returned array has the same data type as x. If x has a complex floating-point data type, the returned array has a real-valued floating-point data type whose precision matches the precision of x.

Return type:

dpnp.ndarray

Limitations

Parameters where and subok are supported with their default values. Keyword argument kwargs is currently unsupported. Otherwise NotImplementedError exception will be raised.

See also

dpnp.fabs

Calculate the absolute value element-wise excluding complex types.

Notes

dpnp.abs is a shorthand for this function.

Examples

>>> import dpnp as np
>>> a = np.array([-1.2, 1.2])
>>> np.absolute(a)
array([1.2, 1.2])
>>> a = np.array(1.2 + 1j)
>>> np.absolute(a)
array(1.5620499351813308)