Two-sided Jacobi algorithm for Singular Value Decomposition (SVD)
A = U D VT ,
where matrix D is diagonal with non-negative elements and matrices U and V are orghogonal. The diagonal elements of matrix D can always be chosen non-negative by multiplying the relevant columns of matrix U with (-1).SVD can be used to solve a number of problems in linear algebra.
A → JT A J
where J ≐ J(θ,p,q) is the Jacobi matrix (where the angle θ is chosen to eliminate the off-diagonal elements Apq=Aqp) to all upper off-diagonal matrix elements in cyclic sweeps until the matrix becomes diagonal.
The two-sided Jacobi SVD algorithm for general real square matrices is the same as the Jacobi eigenvalue algorithm, except that the elementary transformation is slightly different,
A → JT GT A J ,
where
tan(θ) = (Apq - Aqp)/(Aqq + App)
(check that this is correct).The matrices U and V are updated after each transformation as
Of course you should not actually multiply Jacobi matrices—which costs O(n³) operations—but rather perform updates which only cost O(n) operations.