lml-main
Version:
This is now a mono repository published into many standalone packages.
45 lines (28 loc) • 652 B
Markdown
<!-- Note: This file is automatically generated from source code comments. Changes made in this file will be overridden. -->
Calculate the trace of a matrix: the sum of the elements on the main
diagonal of a square matrix.
```js
math.trace(x)
```
Parameter | Type | Description
--------- | ---- | -----------
`x` | Array &
Type | Description
---- | -----------
number | The trace of `x`
```js
math.trace([[1, 2], [3, 4]]); // returns 5
var A = [
[],
[-1, 2, 3],
[]
]
math.trace(A); // returns 6
```
[](diag.md)