函数 hypot #

计算具有值的列表的斜边。斜边定义为

hypot(a, b, c, ...) = sqrt(a^2 + b^2 + c^2 + ...)

对于矩阵输入,将计算矩阵中所有值的斜边。

Syntax #

math.hypot(a, b, ...)
math.hypot([a, b, c, ...])

Parameters #

Parameter Type Description
args … number | BigNumber | Array | Matrix 具有数值、数组或矩阵的列表。矩阵和数组输入会被展平,并为整个矩阵返回一个数字。

Returns #

Type Description
number | BigNumber 返回输入值的斜边。

Throws #

Type | Description —- | ———–

Examples #

math.hypot(3, 4)      // 5
math.hypot(3, 4, 5)   // 7.0710678118654755
math.hypot([3, 4, 5]) // 7.0710678118654755
math.hypot(-2)        // 2

另请参阅 #

abs, norm

Fork me on GitHub