trace

Return the trace of matrix A, i.e., the sum of the diagonal elements

Information

This information is part of the Modelica Standard Library maintained by the Modelica Association.

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

Syntax

result = trace(A)

Inputs (1)

A

Type: Real[:,size(A, 1)]

Description: Square matrix A

Outputs (1)

result

Type: Real

Description: Trace of A