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 Creal(A(0, 0)), Cimag(A(0, 0)), Creal(A(0, 1)), Cimag(A(0, 1))
Debug.Print Creal(A(0, 2)), Cimag(A(0, 2))
Debug.Print Creal(A(1, 1)), Cimag(A(1, 1)), Creal(A(1, 2)), Cimag(A(1, 2))
Debug.Print Creal(A(2, 2)), Cimag(A(2, 2))
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 Creal(A(0, 0)), Cimag(A(0, 0)), Creal(A(0, 1)), Cimag(A(0, 1))
Debug.Print Creal(A(1, 0)), Cimag(A(1, 0)), Creal(A(1, 1)), Cimag(A(1, 1))
Debug.Print Creal(A(2, 0)), Cimag(A(2, 0)), Creal(A(2, 1)), Cimag(A(2, 1))
Debug.Print Creal(A(0, 2)), Cimag(A(0, 2))
Debug.Print Creal(A(1, 2)), Cimag(A(1, 2))
Debug.Print Creal(A(2, 2)), Cimag(A(2, 2))
Debug.Print "Info =", Info
End Sub