函数 max #
计算矩阵或值列表的最大值。对于多维数组,将计算展平数组的最大值。当提供了 dim 时,将计算所选维度的最大值。参数 dim 是从零开始的。
Syntax #
math.max(a, b, c, ...)
math.max(A)
math.max(A, dimension)
Parameters #
| Parameter | Type | Description |
|---|---|---|
args |
… * | 单个矩阵或多个标量值 |
Returns #
| Type | Description |
|---|---|
| * | 最大值 |
Throws #
Type | Description —- | ———–
Examples #
math.max(2, 1, 4, 3) // returns 4
math.max([2, 1, 4, 3]) // returns 4
// maximum over a specified dimension (zero-based)
math.max([[2, 5], [4, 3], [1, 7]], 0) // returns [4, 7]
math.max([[2, 5], [4, 3], [1, 7]], 1) // returns [5, 4, 7]
math.max(2.7, 7.1, -4.5, 2.0, 4.1) // returns 7.1
math.min(2.7, 7.1, -4.5, 2.0, 4.1) // returns -4.5