XLPack 6.1
Excel VBA Numerical Library Reference Manual
Loading...
Searching...
No Matches

◆ Zgesdd()

Sub Zgesdd ( Jobz As  String,
M As  Long,
N As  Long,
A() As  Complex,
S() As  Double,
U() As  Complex,
Vt() As  Complex,
Info As  Long 
)

(Divide and conquer driver) Singular value decomposition (SVD) of a complex matrix

Purpose
This routine computes the singular value decomposition (SVD) of a complex M x N matrix A, optionally computing the left and/or right singular vectors. If singular vectors are desired, it uses a divide-and-conquer algorithm.

The SVD is written
A = U * SIGMA * V^H
where SIGMA is an M x N matrix which is zero except for its min(M, N) diagonal elements, U is an M x M unitary matrix, and V is an N x N unitary matrix. The diagonal elements of SIGMA are the singular values of A. They are real and non-negative, and are returned in descending order. The first min(M, N) columns of U and V are the left and right singular vectors of A.

Note that the routine returns V^H, not V.
Parameters
[in]JobzSpecifies options for computing all or part of the matrix U and V^H:
= "A": All M columns of U and all N rows of V^H are returned in the array U() and Vt().
= "S": The first min(M, N) columns of U and the first min(M, N) rows of V^H are returned in the array U() and Vt().
= "O": If M >= N, the first N columns of U are overwritten on the array A() and all rows of V^H are returned in the array Vt(). Otherwise, all columns of U are returned in the array U() and the first M rows of V^H are overwritten in the array A().
= "N": No columns of U or rows of V^H are computed.
[in]MNumber of rows of the input matrix A. (M >= 0) (If M = 0, returns without computation)
[in]NNumber of columns of the input matrix A. (N >= 0) (If N = 0, returns without computation)
[in,out]A()Array A(LA1 - 1, LA2 - 1) (LA1 >= M, LA2 >= N)
[in] M x N matrix A.
[out] Jobz = "O": A() is overwritten with the first N columns of U (the left singular vectors, stored columnwise) if M >= n. A() is overwritten with the first M rows of V^H (the right singular vectors, stored rowwise) otherwise.
  Jobz != "O": The contents of A() are destroyed.
[out]S()Array S(LS - 1) (LS >= min(M, N))
The singular values of A, sorted so that S(i) >= S(i+1).
[out]U()Array U(LU1 - 1, LU2 - 1) (LU1 >= M if Jobz = "S" or "A", or, Jobz = "O" and M < N) (LU2 >= M if Jobz = "A", or, Jobz = "O" and M < N, LU2 >= min(M, N) if Jobz = "S")
Jobz = "A" or Jobz = "O" and M < N: U() contains the M x M unitary matrix U.
Jobz = "S": U() contains the first min(M, N) columns of U (the left singular vectors, stored columnwise).
Jobz = "O" and M >= N or Jobz = "N": U() is not referenced.

Array Vt(LVt1 - 1, LVt2 - 1) (LVt1 >= N if Jobz = "A", or, Jobz = "O" and M >= N, LVt1 >= min(M, N) if Jobz = "S") (LVt2 >= N if Jobz = "S" or "A", or, Jobz = "O" and M >= N)
Jobz = "A" or Jobz = "O" and M >= N: Vt() contains the N x N unitary matrix V^H.
Jobz = "S": Vt() contains the first min(M, N) rows of V^H (the right singular vectors, stored rowwise).
Jobz = "O" and M < N or Jobz = "N": Vt() is not referenced.

Parameters
[out]Info= 0: Successful exit
= -1: The argument Jobz had an illegal value (Jobz != "A", "S", "O" nor "N")
= -2: The argument M had an illegal value (M < 0)
= -3: The argument N had an illegal value (N < 0)
= -4: The argument A() is invalid.
= -5: The argument S() is invalid.
= -6: The argument U() is invalid.
= -7: The argument Vt() is invalid.
> 0: Dbdsdc did not converge. Updating process of divide and conquer failed.
Reference
LAPACK
Example Program
Compute singular values and left and right singular vectors of matrix A, where
( 0.20-0.11i -0.93-0.32i 0.81+0.37i )
A = ( -0.80-0.92i -0.29+0.86i 0.64+0.51i )
( 0.71+0.59i -0.15+0.19i 0.20+0.94i )
Sub Ex_Zgesdd()
Const M = 3, N = 3
Dim A(M - 1, N - 1) As Complex, U(M - 1, N - 1) As Complex, Vt(N - 1, N - 1) As Complex
Dim S(N - 1) As Double, Info As Long
A(0, 0) = Cmplx(0.2, -0.11): A(0, 1) = Cmplx(-0.93, -0.32): A(0, 2) = Cmplx(0.81, 0.37)
A(1, 0) = Cmplx(-0.8, -0.92): A(1, 1) = Cmplx(-0.29, 0.86): A(1, 2) = Cmplx(0.64, 0.51)
A(2, 0) = Cmplx(0.71, 0.59): A(2, 1) = Cmplx(-0.15, 0.19): A(2, 2) = Cmplx(0.2, 0.94)
Call Zgesdd("S", M, N, A(), S(), U(), Vt(), Info)
Debug.Print "Singular values =", S(0), S(1), S(2)
Debug.Print "U ="
Debug.Print Creal(U(0, 0)), Cimag(U(0, 0)), Creal(U(0, 1)), Cimag(U(0, 1))
Debug.Print Creal(U(1, 0)), Cimag(U(1, 0)), Creal(U(1, 1)), Cimag(U(1, 1))
Debug.Print Creal(U(2, 0)), Cimag(U(2, 0)), Creal(U(2, 1)), Cimag(U(2, 1))
Debug.Print Creal(U(0, 2)), Cimag(U(0, 2))
Debug.Print Creal(U(1, 2)), Cimag(U(1, 2))
Debug.Print Creal(U(2, 2)), Cimag(U(2, 2))
Debug.Print "V^H ="
Debug.Print Creal(Vt(0, 0)), Cimag(Vt(0, 0)), Creal(Vt(0, 1)), Cimag(Vt(0, 1))
Debug.Print Creal(Vt(1, 0)), Cimag(Vt(1, 0)), Creal(Vt(1, 1)), Cimag(Vt(1, 1))
Debug.Print Creal(Vt(2, 0)), Cimag(Vt(2, 0)), Creal(Vt(2, 1)), Cimag(Vt(2, 1))
Debug.Print Creal(Vt(0, 2)), Cimag(Vt(0, 2))
Debug.Print Creal(Vt(1, 2)), Cimag(Vt(1, 2))
Debug.Print Creal(Vt(2, 2)), Cimag(Vt(2, 2))
Debug.Print "Info =", Info
End Sub
Example Results
Singular values = 2.07084030821889 1.23513084760163 0.901483337149816
U =
-0.322093837376809 0.402732043434636 9.95958553097357E-02 0.309610800223195
0.25572227156877 0.689932737910445 -0.631621088952191 3.70329357348019E-02
-0.438560869464762 1.80488745428176E-02 -7.00863751874234E-02 0.699280401316292
0.711819740685389 -0.348707521966052
-9.32902099996817E-02 0.222663951646943
-0.55115638604919 -0.098285606104146
V^H =
-0.603023132575377 0 0.366551261475641 0.394522570687146
0.663818465313821 0 0.134961467338043 -0.149629139353428
-0.44238913491109 0 -0.297134277147366 -0.762299060909463
0.16075433957414 -0.566138903287951
0.366911928609536 -0.61977189734833
0.331437452593181 -0.15827959884907
Info = 0