1 |
|
2 |
|
3 | # Function zeros
|
4 |
|
5 | Create a matrix filled with zeros. The created matrix can have one or
|
6 | multiple dimensions.
|
7 |
|
8 |
|
9 | ## Syntax
|
10 |
|
11 | ```js
|
12 | math.zeros(m)
|
13 | math.zeros(m, format)
|
14 | math.zeros(m, n)
|
15 | math.zeros(m, n, format)
|
16 | math.zeros([m, n])
|
17 | math.zeros([m, n], format)
|
18 | ```
|
19 |
|
20 | ### Parameters
|
21 |
|
22 | Parameter | Type | Description
|
23 | --------- | ---- | -----------
|
24 | `size` | ...number | Array | The size of each dimension of the matrix
|
25 | `format` | string | The Matrix storage format
|
26 |
|
27 | ### Returns
|
28 |
|
29 | Type | Description
|
30 | ---- | -----------
|
31 | Array | Matrix | A matrix filled with zeros
|
32 |
|
33 |
|
34 | ## Examples
|
35 |
|
36 | ```js
|
37 | math.zeros(3) // returns [0, 0, 0]
|
38 | math.zeros(3, 2) // returns [[0, 0], [0, 0], [0, 0]]
|
39 | math.zeros(3, 'dense') // returns [0, 0, 0]
|
40 |
|
41 | const A = [[1, 2, 3], [4, 5, 6]]
|
42 | math.zeros(math.size(A)) // returns [[0, 0, 0], [0, 0, 0]]
|
43 | ```
|
44 |
|
45 |
|
46 | ## See also
|
47 |
|
48 | [ones](ones.md),
|
49 | [identity](identity.md),
|
50 | [size](size.md),
|
51 | [range](range.md)
|