mirror of
https://github.com/josdejong/mathjs.git
synced 2026-01-25 15:07:57 +00:00
60 lines
1.4 KiB
Markdown
60 lines
1.4 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-sum">Function sum <a href="#function-sum" title="Permalink">#</a></h1>
|
|
|
|
Compute the sum of a matrix or a list with values.
|
|
In case of a multidimensional array or matrix, the sum of all
|
|
elements will be calculated.
|
|
|
|
|
|
<h2 id="syntax">Syntax <a href="#syntax" title="Permalink">#</a></h2>
|
|
|
|
```js
|
|
math.sum(a, b, c, ...)
|
|
math.sum(A)
|
|
math.sum(A, dimension)
|
|
```
|
|
|
|
<h3 id="parameters">Parameters <a href="#parameters" title="Permalink">#</a></h3>
|
|
|
|
Parameter | Type | Description
|
|
--------- | ---- | -----------
|
|
`args` | ... * | A single matrix or multiple scalar values
|
|
|
|
<h3 id="returns">Returns <a href="#returns" title="Permalink">#</a></h3>
|
|
|
|
Type | Description
|
|
---- | -----------
|
|
* | The sum of all values
|
|
|
|
|
|
<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.sum(2, 1, 4, 3) // returns 10
|
|
math.sum([2, 1, 4, 3]) // returns 10
|
|
math.sum([[2, 5], [4, 3], [1, 7]]) // returns 22
|
|
```
|
|
|
|
|
|
<h2 id="see-also">See also <a href="#see-also" title="Permalink">#</a></h2>
|
|
|
|
[mean](mean.html),
|
|
[median](median.html),
|
|
[min](min.html),
|
|
[max](max.html),
|
|
[prod](prod.html),
|
|
[std](std.html),
|
|
[variance](variance.html),
|
|
[cumsum](cumsum.html)
|