SVD

Purpose:

Calculates the singular value decomposition of a matrix.

Syntax:

(u, w, v) = SVD(a, mode)

a

-

A square or rectangular matrix.

mode

-

Optional. An integer, the form of the output matrices:

0:

Compact form.

1:

Standard form (default).

"econ":

Economy form.

Alternate Syntax:

 

SVD(a, mode)

a

-

A square or rectangular matrix.

mode

-

Optional. An integer, the type of matrix to return:

00:

W, Singular values as a column (default).

01:

V, Right singular value matrix.

10:

U, Left singular value matrix.

11:

Combined U W V matrix.

Returns:

(u, w, v) = SVD(a) returns u, w and v as three separate matrices such that u *^ w *^ v' == a.

 

SVD(a) returns a series containing the singular values of a.

Example:

W1: {{1, 2},

     {3, 4}, 

     {5, 6}, 

     {7, 8}} 

 

(u, w, v) = svd(w1)

 

u == {{-0.1525, -0.8226, -0.3945, -0.3800},

      {-0.3499, -0.4214,  0.2428,  0.8007}, 

      {-0.5474, -0.0201,  0.6979, -0.4614}, 

      {-0.7448,  0.3812, -0.5462,  0.0407}} 

 

w == {{14.2691, 0.0000},

      { 0.0000, 0.6268}, 

      { 0.0000, 0.0000}, 

      { 0.0000, 0.0000}} 

 

v == {{-0.6414, -0.7672},

      {-0.7672, -0.6414}} 

 

u *^ w *^ v' == {{1, 2},

                 {3, 4}, 

                 {5, 6}, 

                 {7, 8}} 

 

Computes the singular decomposition in standard form.

Example:

W1: {{1, 2},

     {3, 4}, 

     {5, 6}, 

     {7, 8}} 

 

(u, w, v) = svd(w1, 0)

 

u == {{-0.1525, -0.8226},

      {-0.3499, -0.4214}, 

      {-0.5474, -0.0201}, 

      {-0.7448, 0.3812}} 

 

w == {{14.2691, 0.0000},

      { 0.0000, 0.6268}} 

 

v == {{-0.6414, -0.7672},

      {-0.7672, -0.6414}} 

 

u *^ w *^ v' == {{1, 2},

                 {3, 4}, 

                 {5, 6}, 

                 {7, 8}} 

 

Computes the singular decomposition in compact form.

Example:

W1: {{1, 2},

     {3, 4}, 

     {5, 6}, 

     {7, 8}} 

 

W2: svd(w1)

 

W2 == {14.2691, 0.6268} 

 

W2 contains the singular values of W1 as a single column series. The singular values are ranked from largest to smallest.

Remarks:

Singular value decomposition decomposes the matrix A into three matrix components, U, W and V such that:

 

image\svddiv28.gif

 

where U is an orthonormal matrix that contains the left singular values, W is a diagonal matrix representing the weighting factor or singular values and V is a orthonormal matrix that contains the right singular values.

 

image\svddiv29.gif

 

For a complex matrix:

 

image\svddiv30.gif

 

where H is the conjugate transpose operator.

 

With this decomposition, the inverse of a real matrix can be calculated as:

 

image\svddiv32.gif

 

where wj  (the singular values) are the diagonal values of matrix W.

 

For a complex matrix:

 

image\svddiv33.gif

 

For input matrix A of size MxN, matrix U is size MxM, W is size MxN and V is size NxN:

 

(u, w, v) = svd(a, 0)

 

returns the components in compact form. If M > N, U is size MxN, W is size NxN and V is size NxN. If M <= N,  the compact form is identical to the standard form

 

(u, w, v) = svd(a, "econ")

 

returns the components in economy form. If M < N, U is size MxM, W is size MxM and V is size NxM. If M >= N, the economy form is identical to the compact form.

 

See SVDDIV and LINFIT for examples of using SVD to compute a least squares fit of arbitrary basis functions to a series.

 

SVD is based on a FORTRAN routine named SSVDC written by G. W. Stewart, Argonne National Laboratory.

 

See DADiSP/MatrixXL to significantly optimize SVD.

See Also:

*^ (Matrix Multiply)

\^ (Matrix Solve)

COND

DADiSP/MatrixXL

DIAGONAL

HESS

INVERSE

LINFIT

LU

NORM

NULL

ORTH

PINV

QR

RANK

SVDDIV

TRANSPOSE

References:

[1]

Press, Flannery, Teukolsky, Vetterling

 

Numerical Recipes in C

 

Cambridge Press, 1988

 

pp. 407-552

 

Note: For reference only, the implementation employed by SVD is more accurate than the algorithm presented in [1].