The IMSL_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.
This routine requires an IDL Advanced Math and Stats license. For more information, contact your sales or technical support representative.
The IMSL_SVDCOMP function 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, it computes singular value decomposition of B 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–1 0,0,..., s–1 i,i, 0, ..., 0). Only singular values that are not negligible are reciprocated. If the keyword INVERSE is specified, the function first computes the singular value decomposition of the matrix A, then computes the generalized inverse. The IMSL_SVDCOMP function fails if the QR algorithm does not converge after 30 iterations.
Examples
Example 1
This example computes the singular values of a 6-by-4 real 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
singvals = IMSL_SVDCOMP(a)
PM, singvals
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.
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
singvals = IMSL_SVDCOMP(a, U = u, V = v)
PM, singvals, Title = 'Singular values', Format = '(f12.6)'
Singular values
11.485018
3.269752
2.653356
2.088730
PM, u, Title = 'Left singular vectors, U', Format = '(4f12.6)'
Left singular vectors, U
-0.3804755863D, -0.1196709926D, -0.4390828244D, 0.5653995859D
-0.4037537132D, -0.3451108371D, 0.0565761853D, -0.2147755765D
-0.5451204862D, -0.4292648935D, -0.0513926928D, -0.4321441628D
-0.2647842940D, 0.0683195253D, 0.8838608674D, 0.2152536982D
-0.4463101123D, 0.8168276233D, -0.1418996751D, -0.3212695843D
-0.3546286566D, 0.1021473992D, 0.0043184440D, 0.5458002219D
PM, v, Title = 'Right singular vectors, V', Format = '(4f12.6)'
Right singular vectors, V
-0.4442941288D, -0.5555312578D, 0.4353789667D, -0.5517543874D
-0.5580672382D, 0.6542987401D, -0.2774569005D, -0.4283360652D
-0.3243861032D, 0.3513606456D, 0.7320995334D, 0.4851284633D
-0.6212385538D, -0.3739303104D, -0.4444019542D, 0.5260662366
Errors
Warning Errors
MATH_SLOWCONVERGENT_MATRIX: Convergence cannot be reached after 30 iterations.
Syntax
Result = IMSL_SVDCOMP(A [, /DOUBLE] [, INVERSE=variable] [, RANK=variable] [, TOL_RANK=variable] [, U=variable] [, V=variable])
Return Value
One-dimensional array containing ordered singular values of A.
Arguments
A
Two-dimensional matrix containing the coefficient matrix. Element A (i, j) contains the j-th coefficient of the i-th equation.
Keywords
DOUBLE (optional)
If present and nonzero, double precision is used.
INVERSE (optional)
Named variable into which the generalized inverse of the matrix A is stored.
RANK (optional)
Named variable into which an estimate of the rank of A is stored.
TOL_RANK (optional)
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.
U (optional)
Named variable into which the left-singular vectors of A are stored.
V (optional)
Named variable into which the right-singular vectors of A are stored.
Version History
See Also
IMSL_CHNNDFAC, IMSL_CHNNDSOL, IMSL_LINLSQ, IMSL_QRFAC