.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-11-23T19:25:52Z by OpenModelicaOpenModelica 1.24.2 using GenerateDoc.mos