|
◆ Zgesvdq()
Sub Zgesvdq |
( |
Joba As |
String, |
|
|
Jobp As |
String, |
|
|
Jobr As |
String, |
|
|
Jobu As |
String, |
|
|
Jobv As |
String, |
|
|
M As |
Long, |
|
|
N As |
Long, |
|
|
A() As |
Complex, |
|
|
S() As |
Double, |
|
|
U() As |
Complex, |
|
|
V() As |
Complex, |
|
|
Numrank As |
Long, |
|
|
Info As |
Long, |
|
|
Optional Cond As |
Double |
|
) |
| |
Singular value decomposition (SVD) of a complex matrix (Preconditioned QR method)
- Purpose
- This routine computes the singular value decomposition (SVD) of a complex M x N matrix A, where M >= N. The SVD of A is written as
[++] [xx] [x0] [xx]
A = U * SIGMA * V^H, [++] = [xx] * [ox] * [xx]
[++] [xx]
where SIGMA is an N x N diagonal matrix, U is an M x N orthonormal matrix, and V is an N x N unitary matrix. The diagonal elements of SIGMA are the singular values of A. The columns of U and V are the left and the right singular vectors of A, respectively.
- Parameters
-
[in] | Joba | Specifies the level of accuracy in the computed SVD.
= "A": The requested accuracy corresponds to having the backward error bounded by || delta A ||_F <= f(M, N) * EPS * || A ||_F, where EPS = Dlamch("E"). This authorises this routine to truncate the computed triangular factor in a rank revealing QR factorization whenever the truncated part is below the threshold of the order of EPS * ||A||_F. This is aggressive truncation level.
= "M": Similarly as with "A", but the truncation is more gentle: it is allowed only when there is a drop on the diagonal of the triangular factor in the QR factorization. This is medium truncation level.
= "H": High accuracy requested. No numerical rank determination based on the rank revealing QR factorization is attempted.
= "E": Same as "H", and in addition the condition number of column scaled A is estimated and returned in Cond. N^(-1/4)*Cond <= ||pinv(A_scaled)||_2 <= N^(1/4)*Cond. |
[in] | Jobp | = "P": The rows of A are ordered in decreasing order with respect to ||A(i,:)||_infinity. This enhances numerical accuracy at the cost of extra data movement. Recommended for numerical robustness.
= "N": No row pivoting. |
[in] | Jobr | = "T": After the initial pivoted QR factorization, Zgesvd is applied to the transposed R^H of the computed triangular factor R. This involves some extra data movement (matrix transpositions). Useful for experiments, research and development.
= "N": The triangular factor R is given as input to Zgesvd. This may be preferred as it involves less data movement. |
[in] | Jobu | = "A": All M left singular vectors are computed and returned in the array U(). See the description of U().
= "S" or "U": min(M, N) (= N) left singular vectors are computed and returned in the array U(). See the description of U().
= "R": Numerical rank Numrank is determined and only Numrank left singular vectors are computed and returned in the array U().
= "N": The left singular vectors are not computed.
Note - Jobu = "F" is not supported. |
[in] | Jobv | = "A" or "V": All N right singular vectors are computed and returned in the array V().
= "R": Numerical rank Numrank is determined and only Numrank right singular vectors are computed and returned in the array V(). This option is allowed only if Jobu = "R" or Jobu = "N". Otherwise it is illegal.
= "N": The right singular vectors are not computed. |
[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. (M >= N >= 0) (If N = 0, returns without computation) |
[in,out] | A() | Array A(LA1 - 1, LA2 - 1) (LA1 >= M, LA2 >= N)
[in] The input matrix A.
[out] If Jobu <> "N" or Jobv <> "N", the lower triangle of A() contains the Householder vectors as stored by Zgeqp3. If Jobu = "F", these Householder vectors together with work[0:N-1] can be used to restore the Q factors from the initial pivoted QR factorization of A. See the description of U(). |
[out] | S() | Array S(LS - 1) (LS >= N)
The singular values of A, ordered so that S(i) >= S(i+1). |
[out] | U() | Array U(LU1 - 1, LU2 - 1) (LU1 >= M if Jobu = "A", "S", "U" or "R") (LU2 >= M if Jobu = "A", LU2 >= N if Jobu = "S", "U" or "R")
Jobu = "A": U() contains the M left singular vectors.
Jobu = "S", "U" or "R": U() contains the leading N or the leading Numrank left singular vectors.
Jobu = "N": U() is not referenced. |
[out] | V() | Array V(LV1 - 1, LV2 - 1) (LV1 >= N if Jobv = "A", "V" or "R", or Joba = "E") (LV2 >= N if Jobv = "A", "V" or "R", or Joba = "E")
Jobv = "A" or "V": V() contains the N x N unitary matrix V^H.
Jobv = "R": V() contains the first Numrank rows of V^H (the right singular vectors, stored rowwise, of the Numrank largest singular values).
Jobv = "N" and Joba = "E": V() is used as a workspace.
Jobv = "N" and Joba <> "E": V() is not referenced. |
[out] | Numrank | The numerical rank first determined after the rank revealing QR factorization, following the strategy specified by the value of Joba. if Jobv = "R" and Jobu = "R", only Numrank leading singular values and vectors are then requested in the call of Zgesvd. The final value of Numrank might be further reduced if some singular values are computed as zeros. |
[out] | Info | = 0: Successful exit
= -1: The argument Joba had an illegal value (Joba <> "A", "M", "H" nor "E")
= -2: The argument Jobp had an illegal value (Jobp <> "P" nor "N")
= -3: The argument Jobr had an illegal value (Jobr <> "T" nor "N")
= -4: The argument Jobu had an illegal value (Jobu <> "A", "S", "R" nor "N")
= -5: The argument Jobv had an illegal value (Jobv <> "A", "V", "R" nor "N")
= -6: The argument M had an illegal value (M < 0)
= -7: The argument N had an illegal value (N < 0 or N > M)
= -8: The argument A() is invalid.
= -9: The argument S() is invalid.
= -10: The argument U() is invalid.
= -11: The argument V() is invalid.
> 0: Zbdsqr did not converge. Info specifies how many superdiagonals of an intermediate bidiagonal form B (computed in Zgesvd) did not converge to zero. |
[out] | Cond | (Optional)
The estimated condition number of column scaled A is returned if Joba = "E". |
- 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_Zgesvdq()
Const M = 3, N = 3
Dim A(M - 1, N - 1) As Complex, V(N - 1, N - 1) As Complex, U(M - 1, N - 1) As Complex
Dim S(N - 1) As Double, Numrank As Long, 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 Zgesvdq("A", "P", "N", "S", "A", M, N, A(), S(), U(), V(), Numrank, 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(V(0, 0)), Cimag(V(0, 0)), Creal(V(0, 1)), Cimag(V(0, 1))
Debug.Print Creal(V(1, 0)), Cimag(V(1, 0)), Creal(V(1, 1)), Cimag(V(1, 1))
Debug.Print Creal(V(2, 0)), Cimag(V(2, 0)), Creal(V(2, 1)), Cimag(V(2, 1))
Debug.Print Creal(V(0, 2)), Cimag(V(0, 2))
Debug.Print Creal(V(1, 2)), Cimag(V(1, 2))
Debug.Print Creal(V(2, 2)), Cimag(V(2, 2))
Debug.Print "Numrank =", Numrank, "Info =", Info
End Sub
- Example Results
Singular values = 2.07084030821889 1.23513084760163 0.901483337149816
U =
0.322093837376809 -0.402732043434635 9.95958553097357E-02 0.309610800223195
-0.255722271568769 -0.689932737910445 -0.631621088952191 0.037032935734802
0.438560869464762 -1.80488745428177E-02 -7.00863751874239E-02 0.699280401316292
-0.71181974068539 0.348707521966053
9.32902099996814E-02 -0.222663951646943
0.551156386049191 9.82856061041462E-02
V^H =
0.603023132575377 0 -0.36655126147564 -0.394522570687146
0.66381846531382 -0 0.134961467338043 -0.149629139353428
0.44238913491109 -0 0.297134277147366 0.762299060909463
-0.16075433957414 0.566138903287951
0.366911928609536 -0.61977189734833
-0.331437452593181 0.15827959884907
Numrank = 3 Info = 0
|