functiontrace
Return the trace of matrix A, i.e., the sum of the diagonal elements
Extends from Modelica.Icons.Function (Icon for functions).
Information
Syntax
r = Matrices.trace(A);
Description
This function computes the trace, i.e., the sum of the elements in the diagonal of matrix A.
Example
A = [1, 3;
2, 1];
r = trace(A);
results in:
r = 2.0
Inputs
| Type | Name | Default | Description |
|---|---|---|---|
| Real[:,size(A, 1)] | A | Square matrix A |
Outputs
| Type | Name | Default | Description |
|---|---|---|---|
| Real | result | Trace of A |
Revisions
- 2010/05/31 by Marcus Baur, DLR-RM