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

◆ Dgelqf()

Sub Dgelqf ( M As  Long,
N As  Long,
A() As  Double,
Tau() As  Double,
Info As  Long 
)

LQ factorization

Purpose
This routine computes a LQ factorization of a real m x n matrix A.
A = L * Q
Parameters
[in]MNumber of rows of the matrix A. (M >= 0) (If M = 0, returns without computation)
[in]NNumber 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 elements on and below the diagonal of the array contains the M x min(M, N) lower trapezoidal matrix L (L is lower triangular if M <= N); the elements above the diagonal, with the array Tau(), represent the orthogonal matrix Q as a product of elementary reflectors (see Further Details).
[out]Tau()Array Tau(LTau - 1) (LTau >= min(M, N))
The scalar factors of the elementary reflectors (see Further Details).
[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 Tau() is invalid.
Further Details
The matrix Q is represented as a product of elementary reflectors
Q = H(k) . . . H(2) H(1), where k = min(M, N).
Each H(i) has the form
H(i) = I - tau * v * v^T
where tau is a real scalar, and v is a real vector with v(1 to i-1) = 0 and v(i) = 1; v(i+1 to N) is stored on exit in A(i-1, i to N-1), and tau in Tau(i-1).
Reference
LAPACK
Example Program
Compute QR factorization of the matrix A, where
( 2.20 -0.11 -0.32 )
A = ( -0.11 2.93 0.81 )
( -0.32 0.81 2.37 )
Sub Ex_Dgelqf()
Const M = 3, N = 3, K = N
Dim A(M - 1, N - 1) As Double, Tau(N - 1) As Double, Info 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)
Debug.Print "L ="
Debug.Print A(0, 0)
Debug.Print A(1, 0), A(1, 1)
Debug.Print A(2, 0), A(2, 1), A(2, 2)
Debug.Print "Info =", Info
'-- Compute Q
Call Dorglq(M, N, K, A(), Tau(), Info)
Debug.Print "Q ="
Debug.Print A(0, 0), A(0, 1), A(0, 2)
Debug.Print A(1, 0), A(1, 1), A(1, 2)
Debug.Print A(2, 0), A(2, 1), A(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 Dorglq(M As Long, N As Long, K As Long, A() As Double, Tau() As Double, Info As Long)
Generates matrix Q of LQ factorization
Example Results
L =
-0.957601169589929
0.51921406926948 -0.791085804620857
-0.220237826244838 0.609478035393939 -1.07262846515618
Info = 0
Q =
-0.208855216922558 0.114870369307407 0.971176758689895
0.267429186186539 -0.948516183365263 0.169701739147835
0.940670573973608 0.295164103761576 0.167382863850482
Info = 0