On Wed, 4 Oct 2006, Nevine Jacob wrote:
Dear Sir,I am an amateur with LAPACK and I am confused about using the
CLAPACK functions DGEQRF and DORGQR. Assuming I have a (10 x 2) matrix
as the input matrix, how would I call the above functions?
From my
understanding, the input matrix should be converted to a 1D matrix in a
column-major arrangement. So the input matrix (say A) becomes a (1 x 20)
matrix.
That's it A is a 1D array and you fill it in column major format. That is
to say in your case:
A[00] = a_{01,01}; A[01] = a_{02,01}; ... A[09] = a_{10,01}
A[10] = a_{01,02}; A[11] = a_{02,02}; ... A[19] = a_{10,02}
M = 10 (number of rows)
yes
N = 2 (number of columns)
yes
LDA = ?
in the previous case LDA = M.
(Leading Dimension of A. How do I calculate this?)
TAU = (1 x MIN(M,N))
yes
arrayWORK = ? (If I choose LWORK = -1, what should be the size of
WORK?)
LWORK = ? (How do I choose this value? Is it intuitive?)
(1) you allocate WORK of size 1;
(2) you set LWORK=-1;
(3) you call DGEQRF with the same calling sequence as you will do, the
fact that LWORK=-1 is interpreted by the LAPACK routine as a workspace
size query, the routine will return you the optimal workspace (optimal in
term of performance)
(4) lwork = (int) work[0]; /* you read the optimal value return by the
return.
(5) free(work);
(6) allocate work of size lwork
then you're good LWORK and WORK are ok you can do your regular LAPACK
call. (actually should be exactly the same line as in (3))
INFO (just declared, not defined)
sure you need to declare it. no need to define it. LAPACK will not read
this value anyway and will overwrite it. You might want to check the value
in output.
These calculations give me the desired value of R (from A) but how do I
calculate Q?
If you want Q from the output of the DGEQRF, this is not trivial to do on
its own. There is a routine specially devoted to this. The name is DORGQR
as you mentionned in your subject.
Julien
|