The SVDC procedure computes the Singular Value Decomposition (SVD) of a square ( n x n ) or non-square ( n x m ) array as the product of orthogonal and diagonal arrays. SVD is a very powerful tool for the solution of linear systems, and is often used when a solution cannot be determined by other numerical algorithms.
The SVD of an ( m x n ) non-square array A is computed as the product of an ( m x n ) column orthogonal array U , an ( n x n ) diagonal array SV , composed of the singular values, and the transpose of an ( n x n ) orthogonal array V: A = U SV V T
SVDC is based on the routine
svdcmp
described in section 2.6 of
Numerical Recipes in C: The Art of Scientific Computing
(Second Edition), published by Cambridge University Press, and is used by permission.
To find the singular values of an array A:
A = [[1.0, 2.0, -1.0, 2.5], $ ; Define the array A.
SVDC, A, W, U, V ; Compute the Singular Value Decomposition.
PRINT, W ; Print the singular values.
8.81973 2.65502 4.30598 6.84484
To verify the decomposition, use the relationship A = U ## SV ## TRANSPOSE(V), where SV is a diagonal array created from the output vector W.
FOR K = 0, 3 DO sv(K,K) = W[K]
result = U ## sv ## TRANSPOSE(V)
1.00000 2.00000 -1.00000 2.50000
1.50000 3.30000 -0.500001 2.00000
3.10000 0.700000 2.20000 0.00000
2.23517e-08 0.300000 -2.00000 5.30000
2.10000 0.999999 4.30000 2.20000