|
◆ Zgesvdx()
Sub Zgesvdx |
( |
Jobu As |
String, |
|
|
Jobvt As |
String, |
|
|
Range As |
String, |
|
|
M As |
Long, |
|
|
N As |
Long, |
|
|
A() As |
Complex, |
|
|
Vl As |
Double, |
|
|
Vu As |
Double, |
|
|
Il As |
Long, |
|
|
Iu As |
Long, |
|
|
Ns As |
Long, |
|
|
S() As |
Double, |
|
|
U() As |
Complex, |
|
|
Vt() As |
Complex, |
|
|
Info As |
Long |
|
) |
| |
(Expert 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. The SVD is written 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.
Zgesvdx uses an eigenvalue problem for obtaining the SVD, which allows for the computation of a subset of singular values and vectors.
Note that the routine returns V^H, not V.
- Parameters
-
[in] | Jobu | Specifies options for computing all or part of the matrix U:
= "V": The first min(M, N) columns of U (the left singular vectors) or as specified by range are returned in the array U().
= "N": No columns of U (no left singular vectors) are computed. |
[in] | Jobvt | Specifies options for computing all or part of the matrix V^H:
= "V": The first min(M, N) rows of V^H (the right singular vectors) or as specificed by range are returned in the array Vt().
= "N": No rows of V^H (no right singular vectors) are computed. |
[in] | Range | = "A": All singular values will be found.
= "V": All singular values in the half-open interval (Vl, Vu] will be found.
= "I": The Il-th through Iu-th singular values will be found. |
[in] | M | Number of rows of the input matrix A. (M >= 0) (If M = 0, returns without computation) |
[in] | N | Number 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] The contents of A() are destroyed. |
[in] | Vl | Range = "V": The lower bound of the interval to be searched for singular values. (Vu > Vl)
Range = "A" or "I": Not referenced. |
[in] | Vu | Range = "V": The upper bound of the interval to be searched for singular values. (Vu > Vl)
Range = "A" or "I": Not referenced. |
[in] | Il | Range = "I": The index of the smallest singular value to be returned. (1 <= Il <= Iu <= min(M, N), if min(M, N) > 0)
Range = "A" or "V": Not referenced. |
[in] | Iu | Range = "I": The index of the largest singular value to be returned. (1 <= Il <= Iu <= min(M, N), if min(M, N) > 0)
Range = "A" or "V": Not referenced. |
[out] | Ns | The total number of singular values found. (0 <= Ns <= min(M, N))
Range = "A": Ns = min(M, N).
Range = "I": Ns = Iu - Il + 1. |
[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, LU2 >= NS)
Jobu = "V": U() contains columns of U (the left singular vectors, stored columnwise) as specified by Range.
Jobu = "N": U() is not referenced.
Note: The user must ensure that LU2 >= NS. If Range = "V", the exact value of NS is not known in advance and an upper bound must be used. |
[out] | Vt() | Array Vt(LVt1 - 1, LVt2 - 1) (LVt1 >= NS, LVt2 >= N)
Jobvt = "V": Vt() contains the rows of V^H (the right singular vectors, stored rowwise) as specified by Range.
Jobvt = "N": Vt() is not referenced.
Note: The user must ensure that LVt1 >= NS. If Range = "V", the exact value of NS is not known in advance and an upper bound must be used. |
[out] | Info | = 0: Successful exit.
= -1: The argument Jobu had an illegal value. (Jobu <> "A", "S", "O" nor "N")
= -2: The argument Jobvt had an illegal value. (Jobvt <> "A", "S", "O" nor "N")
= -3: The argument Range had an illegal value. (Range <> "A", "V" nor "I")
= -4: The argument M had an illegal value. (M < 0)
= -5: The argument N had an illegal value. (N < 0)
= -6: The argument A() is invalid.
= -7: The argument Vl had an illegal value. (Vl < 0)
= -8: The argument Vu had an illegal value. (Vu < vl)
= -9: The argument Il had an illegal value. (Il < 1 or Il > max(1, min(M, N)))
= -10: The argument Iu had an illegal value. (Iu < min(min(M, N), Il) or Iu > min(M, N))
= -12: The argument S() is invalid.
= -13: The argument U() is invalid.
= -14: The argument Vt() is invalid.
= i > 0: i eigenvectors failed to converge in Dbdsvdx/Dstevx.
= 2*N+1: An internal error occurred in Dbdsvx. |
- 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_Zgesvdx()
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
Dim Vl As Double, Vu As Double, Il As Long, Iu As Long, Ns 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 Zgesvdx("V", "V", "A", M, N, A(), Vl, Vu, Il, Iu, Ns, 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 "Ns =", Ns, "Info =", Info
End Sub
- Example Results
Singular values = 2.07084030821889 1.23513084760163 0.901483337149816
U =
-0.322093837376809 0.402732043434636 9.95958553097354E-02 0.309610800223195
0.25572227156877 0.689932737910445 -0.63162108895219 3.70329357348017E-02
-0.438560869464762 1.80488745428176E-02 -7.00863751874233E-02 0.699280401316292
0.711819740685389 -0.348707521966052
-9.32902099996817E-02 0.222663951646943
-0.551156386049191 -9.82856061041459E-02
V^H =
-0.603023132575377 0 0.36655126147564 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.158279598849071
Ns = 3 Info = 0
|