mindspore.ops.hypot

View Source On Gitee
mindspore.ops.hypot(input, other)[source]

Computes hypotenuse of input tensors element-wise as legs of a right triangle. The shape of two inputs should be broadcastable, and data type of them should be one of: float32, float64

\[out_i = \sqrt{input_i^2 + other_i^2}\]
Parameters
  • input (Tensor) – The first input tensor.

  • other (Tensor) – The second input tensor.

Returns

Tensor, the shape is the same as the one after broadcasting, and the data type is one with higher precision in the two inputs.

Raises
  • TypeError – If data type input or other is not float32 or float64.

  • ValueError – If shape of two inputs are not broadcastable.

Supported Platforms:

Ascend GPU CPU

Examples

>>> import numpy as np
>>> from mindspore import Tensor, ops
>>> input = Tensor(np.array([3., 5., 7.]))
>>> other = Tensor(np.array([4., 12., 24.]))
>>> y = ops.hypot(input, other)
>>> print(y)
[ 5. 13. 25.]