函数 zeros #
创建一个由零填充的矩阵。创建的矩阵可以有一个或多个维度。
Syntax #
math.zeros(m)
math.zeros(m, format)
math.zeros(m, n)
math.zeros(m, n, format)
math.zeros([m, n])
math.zeros([m, n], format)
Parameters #
| Parameter | Type | Description |
|---|---|---|
size |
…(number | BigNumber) | Array | 矩阵每个维度的尺寸 |
format |
string | 矩阵存储格式 |
Returns #
| Type | Description |
|---|---|
| Array | Matrix | 一个由零填充的矩阵 |
Throws #
Type | Description —- | ———–
Examples #
math.zeros() // returns []
math.zeros(3) // returns [0, 0, 0]
math.zeros(3, 2) // returns [[0, 0], [0, 0], [0, 0]]
math.zeros(3, 'dense') // returns [0, 0, 0]
const A = [[1, 2, 3], [4, 5, 6]]
math.zeros(math.size(A)) // returns [[0, 0, 0], [0, 0, 0]]