zeros.md (1122B)
1 <!-- Note: This file is automatically generated from source code comments. Changes made in this file will be overridden. --> 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 ### Throws 35 36 Type | Description 37 ---- | ----------- 38 39 40 ## Examples 41 42 ```js 43 math.zeros(3) // returns [0, 0, 0] 44 math.zeros(3, 2) // returns [[0, 0], [0, 0], [0, 0]] 45 math.zeros(3, 'dense') // returns [0, 0, 0] 46 47 const A = [[1, 2, 3], [4, 5, 6]] 48 math.zeros(math.size(A)) // returns [[0, 0, 0], [0, 0, 0]] 49 ``` 50 51 52 ## See also 53 54 [ones](ones.md), 55 [identity](identity.md), 56 [size](size.md), 57 [range](range.md)