mindspore.numpy.hypot
- mindspore.numpy.hypot(x1, x2, dtype=None)[源代码]
Given the “legs” of a right triangle, returns its hypotenuse.
Equivalent to
sqrt(x1**2 + x2**2)
, element-wise. If x1 or x2 is scalar_like (i.e., unambiguously cast-able to a scalar type), it is broadcast for use with each element of the other argument. (See Examples)说明
Numpy arguments out, where, casting, order, subok, signature, and extobj are not supported. On GPU, the supported dtypes are np.float16 and np.float32. On CPU, the supported dtypes are np.float16, np.float32, and np.float64.
- 参数
x1 (Tensor) – Leg of the triangle(s).
x2 (Tensor) – Leg of the triangle(s). If
x1.shape != x2.shape
, they must be broadcastable to a common shape (which becomes the shape of the output).dtype (
mindspore.dtype
, optional) – Defaults to None. Overrides the dtype of the output Tensor.
- 返回
Tensor or scalar, the hypotenuse of the triangle(s). This is a scalar if both x1 and x2 are scalars.
- Supported Platforms:
Ascend
GPU
CPU
样例
>>> import mindspore.numpy as np >>> output = np.hypot(3*np.ones((3, 3)), 4*np.ones((3, 3))) >>> print(output) [[5. 5. 5.] [5. 5. 5.] [5. 5. 5.]] >>> output = np.hypot(3*np.ones((3, 3)), np.array([4.0])) >>> print(output) [[5. 5. 5.] [5. 5. 5.] [5. 5. 5.]]