jax.numpy.hypot#
- jax.numpy.hypot(x1, x2, /)[源代码]#
- 返回直角三角形给定两条直角边的元素级斜边。 - JAX 实现 - numpy.hypot。- 参数:
- x1 (ArrayLike) – 标量或数组。指定直角三角形的一条直角边。不支持 - complex数据类型。
- x2 (ArrayLike) – 标量或数组。指定直角三角形的另一条直角边。不支持 - complex数据类型。- x1和- x2必须具有相同的形状或兼容的广播。
 
- 返回:
- 一个包含直角三角形给定直角边 - x1和- x2的斜边的数组,提升到非精确数据类型。
- 返回类型:
 - 注意 - jnp.hypot是比计算- jnp.sqrt(x1 ** 2 + x2 **2)更数值稳定的方法。- 示例 - >>> jnp.hypot(3, 4) Array(5., dtype=float32, weak_type=True) >>> x1 = jnp.array([[3, -2, 5], ... [9, 1, -4]]) >>> x2 = jnp.array([-5, 6, 8]) >>> with jnp.printoptions(precision=3, suppress=True): ... jnp.hypot(x1, x2) Array([[ 5.831, 6.325, 9.434], [10.296, 6.083, 8.944]], dtype=float32) 
