XLPack 7.0
XLPack Numerical Library (Excel VBA) Reference Manual
Loading...
Searching...
No Matches

◆ Dormlq()

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

Multiplies matrix by Q of LQ factorization

Purpose
This routine overwrites the general real m x n matrix C with
Side = "L" Side = "R"
Trans = "N": Q * C C * Q
Trans = "T": Q^T * C C * Q^T
where Q is a real orthogonal matrix defined as the product of k elementary reflectors
Q = H(k) . . . H(2) H(1)
as returned by Dgelqf. 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^T from the right.
[in]Trans= "N": No transpose, apply Q.
= "T": Transpose, apply Q^T.
[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 >= K, LA2 >= M (Side = "L") or N (Side = "R"))
The i-th row must contain the vector which defines the elementary reflector H(i), for i = 1, 2, ..., K, as returned by Dgelqf in the first K rows 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 Dgelqf.
[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^T*C or C*Q^T 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 <> "T" 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 LQ factorization of the matrix A, and compute L*Q, where
( 2.20 -0.11 -0.32 )
A = ( -0.11 2.93 0.81 )
( -0.32 0.81 2.37 )
Sub Ex_Dormlq()
Const M = 3, N = 3, K = N
Dim A(M - 1, N - 1) As Double, Tau(N - 1) As Double, Info As Long
Dim L(M - 1, N - 1) As Double, I As Long, J As Long
A(0, 0) = 0.2: A(0, 1) = -0.11: A(0, 2) = -0.93
A(1, 0) = -0.32: A(1, 1) = 0.81: A(1, 2) = 0.37
A(2, 0) = -0.8: A(2, 1) = -0.92: A(2, 2) = -0.29
'-- Compute LQ factorization of A
Call Dgelqf(M, N, A(), Tau(), Info)
For I = 0 To M - 1
For J = 0 To I
L(I, J) = A(I, J)
Next
Next
Debug.Print "L ="
Debug.Print L(0, 0), L(0, 1), L(0, 2)
Debug.Print L(1, 0), L(1, 1), L(1, 2)
Debug.Print L(2, 0), L(2, 1), L(2, 2)
Debug.Print "Info =", Info
'-- Compute L*Q
Call Dormlq("R", "N", M, N, K, A(), Tau(), L(), Info)
Debug.Print "L*Q ="
Debug.Print L(0, 0), L(0, 1), L(0, 2)
Debug.Print L(1, 0), L(1, 1), L(1, 2)
Debug.Print L(2, 0), L(2, 1), L(2, 2)
Debug.Print "Info =", Info
End Sub
Sub Dgelqf(M As Long, N As Long, A() As Double, Tau() As Double, Info As Long)
LQ factorization
Sub Dormlq(Side As String, Trans As String, M As Long, N As Long, K As Long, A() As Double, Tau() As Double, C() As Double, Info As Long)
Multiplies matrix by Q of LQ factorization
Example Results
L =
-0.957601169589929 0 0
0.51921406926948 -0.791085804620857 0
-0.220237826244838 0.609478035393939 -1.07262846515618
Info = 0
L*Q =
0.2 -0.11 -0.93
-0.32 0.81 0.37
-0.8 -0.92 -0.29
Info = 0