dpnp.reduce_hypot

dpnp.reduce_hypot(x, /, *, axis=None, dtype=None, keepdims=False, out=None)[source]

Calculates the square root of the sum of squares of elements in the input array.

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

  • axis ({None, int or tuple of ints}, optional) -- Axis or axes along which values must be computed. If a tuple of unique integers, values are computed over multiple axes. If None, the result is computed over the entire array. Default: None.

  • dtype ({None, dtype}, optional) --

    Data type of the returned array. If None, the default data type is inferred from the "kind" of the input array data type.

    • If x has a real-valued floating-point data type, the returned array will have the same data type as x.

    • If x has a boolean or integral data type, the returned array will have the default floating point data type for the device where input array x is allocated.

    • If x has a complex-valued floating-point data type, an error is raised.

    If the data type (either specified or resolved) differs from the data type of x, the input array elements are cast to the specified data type before computing the result. Default: None.

  • keepdims ({None, bool}, optional) -- If True, the reduced axes (dimensions) are included in the result as singleton dimensions, so that the returned array remains compatible with the input arrays according to Array Broadcasting rules. Otherwise, if False, the reduced axes are not included in the returned array. Default: False.

  • out ({None, dpnp.ndarray, usm_ndarray}, optional) -- The array into which the result is written. The data type of out must match the expected shape and the expected data type of the result or (if provided) dtype. If None then a new array is returned. Default: None.

Returns:

out -- An array containing the results. If the result was computed over the entire array, a zero-dimensional array is returned. The returned array has the data type as described in the dtype parameter description above.

Return type:

dpnp.ndarray

Note

This function is equivalent of numpy.hypot.reduce.

See also

dpnp.hypot

Given the "legs" of a right triangle, return its hypotenuse.

Examples

>>> import dpnp as np
>>> a = np.ones(10)
>>> np.reduce_hypot(a)
array(3.16227766)
>>> np.sqrt(np.sum(np.square(a)))
array(3.16227766)