I am a beginner LAPACK user.
I am playing with QL factorization.
I'd have problem to obtain the full Q matrix through the ORGQL subroutine.
Specifically, given an m-by-n matrix A, I would like to build the "full" m-by-m matrix Q such that A=QL, for any value of m and n (i.e., both when m >= n or n < m).
To date, when m > n, I was able to successfully obtain only the "reduced" m-by-n matrix Q, which corresponds to the n trailing columns of the "full" Q matrix.
Is there a way in LAPACK to obtain the "full" Q matrix?
Or simply I compute the "reduced" Q and set the m-n heading columns to zero (when m>n)?
As a test case, I'm using the following 6-by-4 input matrix A:
- Code: Select all
[ -0.57 -1.28 -0.39 0.25;
-1.93 1.08 -0.31 -2.14;
2.30 0.24 0.40 -0.35;
-1.93 0.64 -0.66 0.08;
0.15 0.30 0.15 -2.13;
-0.02 1.03 -1.43 0.50 ]
I perform the following steps:
1. Call DGEQLF with LWORK=-1 (in order to get the optimal workspace size)
DGEQLF(6, 4, A, 6, TAU, WORK, -1, INFO)
2. Then I call DGEQLF again but this time with workspace properly resized (LWORK=INFO):
DGEQLF(6, 4, A, 6, TAU, WORK, LWORK, INFO)
After this call I get the following result:
- Code: Select all
A = [ -1.942940 1.506660 0.933778 -0.096466;
0.899115 1.403620 -1.277710 0.825749;
2.894850 0.455552 -1.038550 0.135052;
0.504110 1.581270 1.283920 -0.030869;
1.921280 -1.053210 1.692760 0.821891;
0.872950 -0.901803 -0.213936 3.091590 ]
TAU = [ 0.35820;
0.36713;
0.32095;
0.83827 ]
3. Then I call DORGQL in order to obtain the matrix Q (as before I call it two times, where the first one is for getting the optimal workspace size). Here is the problem
3.a. If I call: DORGQL(6, 4, min(6,4), A, 6, TAU, WORK, LWORK, INFO)
I get the trailing 4 columns of Q matrix
- Code: Select all
Q = [ 0.0833107 -0.9100041 -0.2201730 0.0808647;
-0.2971665 0.1079856 -0.2706159 -0.6922014;
0.6403848 0.2350681 0.2219915 -0.1132102;
-0.4461129 0.1619876 -0.3866238 0.0258767;
0.2937612 -0.2021707 0.0015402 -0.6889674;
0.4575411 0.1945615 -0.8243342 0.1617290 ]
4.a While if I call: DORGQL(6, 6, min(6,4), A, 6, TAU, WORK, LWORK, INFO)
I get a totally wrong matrix.
If I compute the Q matrix manually (i.e., by computing H(i), such that Q=H(4)*H(3)*H(2)*H(1)) I get:
- Code: Select all
Q = [ -0.1280591 -0.3058246 0.0833107 -0.9100041 -0.2201730 0.0808647;
-0.5697119 -0.1519170 -0.2971665 0.1079856 -0.2706159 -0.6922014;
-0.0751564 -0.6833014 0.6403848 0.2350681 0.2219915 -0.1132102;
0.5633922 -0.5542341 -0.4461129 0.1619876 -0.3866238 0.0258767;
0.5762694 0.2570164 0.2937612 -0.2021707 0.0015402 -0.6889674;
-0.0621795 0.2079659 0.4575411 0.1945615 -0.8243342 0.1617290 ]
which successfully satisfies A=QL.
Thank you very much for helping me!!
Best,
-- Marco

