SVDCOMP Function
Computes the singular value decomposition (SVD), A = USVT, of a real or complex rectangular matrix A. An estimate of the rank of A also can be computed.
Usage
result = SVDCOMP(a)
Input Parameters
a—Two-dimensional matrix containing the coefficient matrix. Element A (i, j) contains the jth coefficient of the ith equation.
Returned Value
result—One-dimensional array containing ordered singular values of A.
Input Keywords
Double—If present and nonzero, double precision is used.
Tol_Rank—Specifies a named variable containing the tolerance used to determine when a singular value is negligible and replaced by the value zero. If Tol_Rank > 0, then a singular value si,i is considered negligible if si,i ≤ Tol_Rank. If Tol_Rank < 0, then a singular value si,i is considered negligible if si,i ≤ Tol_Rank * ||A||infinity.
In this case, |Tol_Rank| should be an estimate of relative error or uncertainty in the data.
Output Keywords
Rank—Specifies a named variable into which an estimate of the rank of A is stored.
U—Specifies a named variable into which the left-singular vectors of A are stored.
V—Specifies a named variable into which the right-singular vectors of A are stored.
Inverse—Specifies a named variable into which the generalized inverse of the matrix A is stored.
Discussion
Function SVDCOMP computes the singular value decomposition of a real or complex matrix A. It reduces the matrix A to a bidiagonal matrix B by pre- and post-multiplying Householder transformations. Then, singular value decomposition of B is computed using the implicit-shifted QR algorithm. An estimate of the rank of the matrix A is obtained by finding the smallest integer k such that sk,k ≤ Tol_Rank or sk,k ≤ Tol_Rank * ||A||infinity.
Since si + 1, i + 1 ≤ s i,i, it follows that all the s i,i satisfy the same inequality for i = k, ..., min(m, n) – 2. The rank is set to the value k. If A = USVT, its generalized inverse is A+ = VS+UT. Here, S+ = diag (s–10,0,..., s–1i,i, 0, ..., 0). Only singular values that are not negligible are reciprocated. If Inverse is specified, the function first computes the singular value decomposition of the matrix A. The generalized inverse is then computed. The SVDCOMP function fails if the QR algorithm does not converge after 30 iterations.
Example 1
This example computes the singular values of a 6-by-4 real matrix.
; Define the matrix.
RM, a, 6, 4
row 0: 1 2 1 4
row 1: 3 2 1 3
row 2: 4 3 1 4
row 3: 2 1 3 1
row 4: 1 5 2 2
row 5: 1 2 2 3
; Call SVDCOMP and output the results.
singvals = SVDCOMP(a)
PM, singvals
; PV-WAVE prints the following:
; 11.4850
; 3.26975
; 2.65336
; 2.08873
Example 2
This example computes the singular value decomposition of the 6-by-4 real matrix A. Matrices U and V are returned using keywords U and V.
; Define the matrix.
RM, a, 6, 4
row 0: 1 2 1 4
row 1: 3 2 1 3
row 2: 4 3 1 4
row 3: 2 1 3 1
row 4: 1 5 2 2
row 5: 1 2 2 3
; Call SVDCOMP with keywords U and V and output the results.
singvals = SVDCOMP(a, U = u, V = v)
PM, singvals, Title = 'Singular values', Format = '(f12.6)'
; PV-WAVE prints the following:
; Singular values
; 11.485018
; 3.269752
; 2.653356
; 2.088730
PM, u, Title = 'Left singular vectors, U', Format = '(4f12.6)'
; PV-WAVE prints the following:
; Left singular vectors, U
; -0.380476 0.119671 0.439083 -0.565399
; -0.403754 0.345111 -0.056576 0.214776
; -0.545120 0.429265 0.051392 0.432144
; -0.264784 -0.068320 -0.883861 -0.215254
; -0.446310 -0.816828 0.141900 0.321270
; -0.354629 -0.102147 -0.004318 -0.545800
PM, v, Title = 'Right singular vectors, V', Format = '(4f12.6)'
; PV-WAVE prints the following:
; Right singular vectors, V
; -0.444294 0.555531 -0.435379 0.551754
; -0.558067 -0.654299 0.277457 0.428336
; -0.324386 -0.351361 -0.732099 -0.485129
; -0.621239 0.373931 0.444402 -0.526066
Warning Errors
MATH_SLOWCONVERGENT_MATRIX—Convergence cannot be reached after 30 iterations.