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

◆ Zunmqr()

Sub Zunmqr ( Side As  String,
Trans As  String,
M As  Long,
N As  Long,
K As  Long,
A() As  Complex,
Tau() As  Complex,
C() As  Complex,
Info As  Long 
)

Multiplies matrix by Q of QR factorization of a complex matrix

Purpose
This routine overwrites the general complex m x n matrix C with
Side = "L" Side = "R"
Trans = "N": Q * C C * Q
Trans = "C": Q^H * C C * Q^H
where Q is a complex unitary matrix defined as the product of k elementary reflectors
Q = H(1) H(2) . . . H(k)
as returned by Zgeqrf. Q is of order m if Side = "L" and of order n if Side = "R".
Parameters
[in]Side= "L": Apply Q or Q^T from the left.
= "R": Apply Q or Q^H from the right.
[in]Trans= "N": No transpose, apply Q.
= "C": Conjugate transpose, apply Q^H.
[in]MNumber of rows of the matrix C. (M >= 0) (If M = 0, returns without computation)
[in]NNumber of columns of the matrix C. (N >= 0) (If N = 0, returns without computation)
[in]KNumber of elementary reflectors whose product defines the matrix Q. (M => K >= 0 if Side = "L", N >= K >= 0 if Side = "R") (If K = 0, returns without computation)
[in]A()Array A(LA1 - 1, LA2 - 1) (LA1 >= M (Side = "L") or N (Side = "R"), LA2 >= K)
The i-th column must contain the vector which defines the elementary reflector H(i), for i = 1, 2, ..., K, as returned by Zgeqrf in the first K columns of its array argument A().
[in]Tau()Array Tau(LTau - 1) (LTau >= K)
The scalar factors of the elementary reflectors H(i) as returned by Zgeqrf.
[in,out]C()Array C(LC1 - 1, LC2 - 1) (LC1 >= M, LC2 >= N)
[in] M x N matrix C.
[out] C() is overwritten by Q*C or Q^H*C or C*Q^H or C*Q.
[out]Info= 0: Successful exit.
= -1: The argument Side had an illegal value. (Side <> "L" nor "R")
= -2: The argument Trans had an illegal value. (Trans <> "C" nor "N")
= -3: The argument M had an illegal value. (M < 0)
= -4: The argument N had an illegal value. (N < 0)
= -5: The argument K had an illegal value. (K < 0, or K > M (Side = "L") or N (Side = "R"))
= -6: The argument A() is invalid.
= -7: The argument Tau() is invalid.
= -8: The argument C() is invalid.
Reference
LAPACK
Example Program
Compute QR factorization of the matrix A, and compute Q*R, 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_Zunmqr()
Const M = 3, N = 3, K = N
Dim A(M - 1, N - 1) As Complex, Tau(N - 1) As Complex, Info As Long
Dim R(M - 1, N - 1) As Complex, I As Long, J 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 Zgeqrf(M, N, A(), Tau(), Info)
For I = 0 To M - 1
For J = I To N - 1
R(I, J) = A(I, J)
Next
Next
Debug.Print "R ="
Debug.Print Creal(R(0, 0)), Cimag(R(0, 0)), Creal(R(0, 1)), Cimag(R(0, 1))
Debug.Print Creal(R(0, 2)), Cimag(R(0, 2))
Debug.Print Creal(R(1, 1)), Cimag(R(1, 1)), Creal(R(1, 2)), Cimag(R(1, 2))
Debug.Print Creal(R(2, 2)), Cimag(R(2, 2))
Debug.Print "Info =", Info
Call Zunmqr("L", "N", M, N, K, A(), Tau(), R(), Info)
Debug.Print "Q*R ="
Debug.Print Creal(R(0, 0)), Cimag(R(0, 0)), Creal(R(0, 1)), Cimag(R(0, 1)), Creal(R(0, 2)), Cimag(R(0, 2))
Debug.Print Creal(R(1, 0)), Cimag(R(1, 0)), Creal(R(1, 1)), Cimag(R(1, 1)), Creal(R(1, 2)), Cimag(R(1, 2))
Debug.Print Creal(R(2, 0)), Cimag(R(2, 0)), Creal(R(2, 1)), Cimag(R(2, 1)), Creal(R(2, 2)), Cimag(R(2, 2))
Debug.Print "Info =", Info
End Sub
Example Results
R =
-1.54618886297891 0 0.455571771900423 0.580588841049134
0.105614523497074 -0.57774313435356
1.14235325460067 0 -0.16000635361559 -0.558214300362838
1.30543219081149 0
Info = 0
Q*R =
0.2 -0.11 -0.93 -0.32 0.81 0.37
-0.8 -0.92 -0.29 0.86 0.64 0.51
0.71 0.59 -0.15 0.19 0.2 0.94
Info = 0