.Modelica.Math.Matrices.trace

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

Interface

function trace
  extends Modelica.Icons.Function;
  input Real A[:, size(A, 1)] "Square matrix A";
  output Real result "Trace of A";
end trace;

Revisions


Generated at 2020-06-05T21:39:08Z by OpenModelica 1.16.0~dev-442-g2e5bc9f