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

TypeNameDefaultDescription
Real[:,size(A, 1)]ASquare matrix A

Outputs

TypeNameDefaultDescription
RealresultTrace of A

Revisions

  • 2010/05/31 by Marcus Baur, DLR-RM