dpnp.absolute
- dpnp.absolute(x, out=None, order='K', dtype=None, casting='same_kind', **kwargs)
Calculates the absolute value for each element x_i of input array x.
For full documentation refer to
numpy.absolute
.- Parameters:
x ({dpnp.ndarray, usm_ndarray}) -- Input arrays, 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.
order ({None, "C", "F", "A", "K"}, optional) -- Memory layout of the newly output array, Cannot be provided together with out. Default:
"K"
.dtype ({None, dtype}, optional) -- If provided, the destination array will have this dtype. Cannot be provided together with out. Default:
None
.casting ({"no", "equiv", "safe", "same_kind", "unsafe"}, optional) -- Controls what kind of data casting may occur. Cannot be provided together with out. Default:
"safe"
.
- 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
Keyword arguments where and subok are supported with their default values. Other keyword arguments 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)