mirror of
https://github.com/josdejong/mathjs.git
synced 2026-02-01 16:07:46 +00:00
Added missing docs on trace
This commit is contained in:
parent
beb4e2e536
commit
c389ad336e
45
docs/reference/functions/trace.md
Normal file
45
docs/reference/functions/trace.md
Normal file
@ -0,0 +1,45 @@
|
||||
# Function trace
|
||||
|
||||
Calculate the trace of a matrix: the sum of the elements on the main
|
||||
diagonal of a square matrix.
|
||||
|
||||
|
||||
## Syntax
|
||||
|
||||
```js
|
||||
math.trace(x)
|
||||
```
|
||||
|
||||
### Parameters
|
||||
|
||||
Parameter | Type | Description
|
||||
--------- | ---- | -----------
|
||||
`x` | Array | Matrix | A matrix
|
||||
|
||||
### Returns
|
||||
|
||||
Type | Description
|
||||
---- | -----------
|
||||
Number | The trace of `x`
|
||||
|
||||
|
||||
## Examples
|
||||
|
||||
```js
|
||||
math.trace([[1, 2], [3, 4]]); // returns 5
|
||||
|
||||
var A = [
|
||||
[1, 2, 3],
|
||||
[-1, 2, 3],
|
||||
[2, 0, 3]
|
||||
]
|
||||
math.trace(A); // returns 6
|
||||
```
|
||||
|
||||
|
||||
## See also
|
||||
|
||||
[diag](diag.md)
|
||||
|
||||
|
||||
<!-- Note: This file is automatically generated from source code comments. Changes made in this file will be overridden. -->
|
||||
Loading…
x
Reference in New Issue
Block a user