functionsingularValues

Return singular values and left and right singular vectors

Extends from Modelica.Icons.Function (Icon for functions).

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

Inputs

TypeNameDefaultDescription
Real[:,:]AMatrix

Outputs

TypeNameDefaultDescription
Real[min(size(A, 1), size(A, 2))]sigmaSingular values
Real[size(A, 1),size(A, 1)]Uidentity(size(A, 1))Left orthogonal matrix
Real[size(A, 2),size(A, 2)]VTidentity(size(A, 2))Transposed right orthogonal matrix