Showing results for 
Search instead for 
Did you mean: 

DORGQR First dimension of matrix A.

Hi All.
I have multiple regression model X * B = Y + e, where X - Txm, B - mxn, Y and e - Txn and I want to get residuals "e", without actualy calculation B. So I want to use QR decomposition of matrix X, and do it as following: e = Y - Q *(Q'*Y); So I want to use DORGQR twice. Assume, we use all elementary reflectors, and Q is Txm matrix.
Everything ok with the first call, I get Q'Y which is mxn matrix. But there is a problem with second call, in accordance with the article:
I don't have any way to specify the number of rows in matrix Q. In section "Fortran 95 Interface Notes" (it's not very clear for me, why here) I see the note:
Holds the matrix A of size (r,k).
r = m if side = 'L'.
r = n if side = 'R'
So I just want to multiply Q (Txm) and Q'R (mxn), but routine automatically assumes that Q is mxk which is definitely not what I want. May be somebody can give me a hint? What I'm doing wrong? Extraction Q matrix explicitly doesn't seem to be a good solution for me, I want to reduce memory usage.
0 Kudos
1 Reply
Black Belt

I do not understand why you want to form Q explicitly at the same time that you are trying to avoid forming B in full.

Let B = [b1 b2 b3 ... ], Y = [y1 y2 y3 ...], e = [e1 e2 e3 ... ]

where b1, b2, b3... are individual columns of B or, at your choosing, groups of columns that you are willing to process together.

You call DGEQRF once to perfom the QR decomposition of X, with Q stored implicitly in the result.

You then call DORMQR to solve for b1, which you then use to compute e1 = X b1 - y1, and similarly for e2, e3, ... For this to work, you need to save a copy of X before the call to DGEQRF, which overwrites X. Or, it may be just as easy to regenerate the necessary portions of X.

Would this approach satisfy your needs?

Minor note: you have inconsistent signs for the error matrix e in your post.