.Modelica.Math.Matrices.singularValues

Information

Syntax

         sigma = Matrices.singularValues(A);
(sigma, U, VT) = Matrices.singularValues(A);

Description

This function computes the singular values and optionally the singular vectors of matrix A. Basically the singular value decomposition of A is computed, i.e.,

A = U Σ VT
  = U*Sigma*VT

where U and V are orthogonal matrices (UUT=I, VVT=I). Σ = [diagonal(σi), zeros(n,m-n)], if n=size(A,1) ≤ m=size(A,2)) or [diagonal(σi); zeros(n-m,m)], if n > m=size(A,2)). Σ has the same size as matrix A with nonnegative diagonal elements in decreasing order and with all other elements zero (σ1 is the largest element). The function returns the singular values σi in vector sigma and the orthogonal matrices in matrices U and VT.

Example

A = [1, 2,  3,  4;
     3, 4,  5, -2;
    -1, 2, -3,  5];
(sigma, U, VT) = singularValues(A);
results in:
   sigma = {8.33, 6.94, 2.31};
i.e.
   Sigma = [8.33,    0,    0, 0;
               0, 6.94,    0, 0;
               0,    0, 2.31, 0]

See also

Matrices.eigenValues

Interface

function singularValues
  extends Modelica.Icons.Function;
  input Real A[:, :] "Matrix";
  output Real sigma[min(size(A, 1), size(A, 2))] "Singular values";
  output Real U[size(A, 1), size(A, 1)] = identity(size(A, 1)) "Left orthogonal matrix";
  output Real VT[size(A, 2), size(A, 2)] = identity(size(A, 2)) "Transposed right orthogonal matrix";
end singularValues;

Generated at 2024-12-26T19:25:54Z by OpenModelicaOpenModelica 1.24.3 using GenerateDoc.mos