mirror of
https://github.com/josdejong/mathjs.git
synced 2026-01-25 15:07:57 +00:00
63 lines
1.6 KiB
Markdown
63 lines
1.6 KiB
Markdown
---
|
|
layout: default
|
|
---
|
|
|
|
<!-- Note: This file is automatically generated from source code comments. Changes made in this file will be overridden. -->
|
|
|
|
<h1 id="function-zeros">Function zeros <a href="#function-zeros" title="Permalink">#</a></h1>
|
|
|
|
Create a matrix filled with zeros. The created matrix can have one or
|
|
multiple dimensions.
|
|
|
|
|
|
<h2 id="syntax">Syntax <a href="#syntax" title="Permalink">#</a></h2>
|
|
|
|
```js
|
|
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)
|
|
```
|
|
|
|
<h3 id="parameters">Parameters <a href="#parameters" title="Permalink">#</a></h3>
|
|
|
|
Parameter | Type | Description
|
|
--------- | ---- | -----------
|
|
`size` | ...(number | BigNumber) | Array | The size of each dimension of the matrix
|
|
`format` | string | The Matrix storage format
|
|
|
|
<h3 id="returns">Returns <a href="#returns" title="Permalink">#</a></h3>
|
|
|
|
Type | Description
|
|
---- | -----------
|
|
Array | Matrix | A matrix filled with zeros
|
|
|
|
|
|
<h3 id="throws">Throws <a href="#throws" title="Permalink">#</a></h3>
|
|
|
|
Type | Description
|
|
---- | -----------
|
|
|
|
|
|
<h2 id="examples">Examples <a href="#examples" title="Permalink">#</a></h2>
|
|
|
|
```js
|
|
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]]
|
|
```
|
|
|
|
|
|
<h2 id="see-also">See also <a href="#see-also" title="Permalink">#</a></h2>
|
|
|
|
[ones](ones.html),
|
|
[identity](identity.html),
|
|
[size](size.html),
|
|
[range](range.html)
|