|
|
◆ Zgeqp3()
| Sub Zgeqp3 |
( |
M As |
Long, |
|
|
N As |
Long, |
|
|
A() As |
Complex, |
|
|
Jpvt() As |
Long, |
|
|
Tau() As |
Complex, |
|
|
Info As |
Long |
|
) |
| |
QR factorization of a complex matrix with pivoting
- Purpose
- This routine computes a QR factorization with column pivoting of a matrix A: using Level 3 BLAS.
- Parameters
-
| [in] | M | Number of rows of the matrix A. (M >= 0) (If M = 0, returns without computation) |
| [in] | N | Number of columns of the 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 upper triangle of the array contains the min(M, N) x N upper trapezoidal matrix R; the elements below the diagonal, together with the array Tau(), represent the unitary matrix Q as a product of min(M, N) elementary reflectors. |
| [in,out] | Jpvt() | Array Jpvt(LJpvt - 1) (LJpvt >= N)
[in] If Jpvt(j-1) <> 0, the j-th column of A is permuted to the front of A*P (a leading column); if Jpvt(j-1) = 0, the j-th column of A is a free column.
[out] If Jpvt(j-1) = k, then the j-th column of A*P was the the k-th column of A. |
| [out] | Tau() | Array Tau(LTau - 1) (LTau >= min(M, N))
The scalar factors of the elementary reflectors. |
| [out] | Info | = 0: Successful exit.
= -1: The argument M had an illegal value. (M < 0)
= -2: The argument N had an illegal value. (N < 0)
= -3: The argument A() is invalid.
= -4: The argument Jpvt() is invalid.
= -5: The argument Tau() is invalid. |
- Reference
- LAPACK
- Example Program
- Compute QR factorization of the 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_Zgeqp3()
Const M = 3, N = 3, K = N
Dim A(M - 1, N - 1) As Complex, Jpvt(N - 1) As Long, Tau(N - 1) As Complex
Dim Info As Long, I 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)
For I = 0 To N - 1
Jpvt(I) = 1
Next
Call Zgeqp3(M, N, A(), Jpvt(), Tau(), Info)
Debug.Print "R ="
Debug.Print "Jpvt =", Jpvt(0), Jpvt(1), Jpvt(2)
Debug.Print "Info =", Info
Call Zungqr(M, N, K, A(), Tau(), Info)
Debug.Print "Q ="
Debug.Print "Info =", Info
End Sub
Function Cmplx(R As Double, Optional I As Double=0) As Complex Building complex number
Function Cimag(A As Complex) As Double Imaginary part of complex number
Function Creal(A As Complex) As Double Real part of complex number
Sub Zgeqp3(M As Long, N As Long, A() As Complex, Jpvt() As Long, Tau() As Complex, Info As Long) QR factorization of a complex matrix with pivoting
Sub Zungqr(M As Long, N As Long, K As Long, A() As Complex, Tau() As Complex, Info As Long) Generates matrix Q of QR factorization of a complex matrix
- Example Results
R =
-1.54618886297891 0 0.455571771900423 0.580588841049134
0.105614523497074 -0.57774313435356
1.14235325460067 0 -0.16000635361559 -0.558214300362838
1.30543219081149 0
Jpvt = 1 2 3
Info = 0
Q =
-0.129350304344243 7.11426673893335E-02 -0.726366393673366 -0.242754372725663
0.517401217376971 0.595011399983517 -0.157793930669391 0.252577062211036
-0.459193580422062 -0.381583397815516 -0.142116660471961 0.551879456556921
0.614237041991267 -0.119926029506194
5.77211185374505E-02 0.535006158572045
0.105825585638305 0.554588344523916
Info = 0
|