.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 S VT
  = U*Sigma*VT

where U and V are orthogonal matrices (UUT=I, VVT=I). S = [diagonal(si), zeros(n,m-n)], if n=size(A,1) ≤ m=size(A,2)) or [diagonal(si); zeros(n-m,m)], if n > m=size(A,2)). S has the same size as matrix A with nonnegative diagonal elements in decreasing order and with all other elements zero (s1 is the largest element). The function returns the singular values si 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 2020-06-05T07:38:22Z by OpenModelica 1.16.0~dev-420-gc007a39