.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 2024-04-28T18:16:21Z by OpenModelicaOpenModelica 1.22.3 using GenerateDoc.mos