1
$\begingroup$

I'd like to do a $A=QR$ decomposition of a matrix $A$, with $m\times n$. I use dgeqrf_ (or dgeqp3_) to proceed to the first part of the decomposition. Then, I can easily compute the matrix $R$ by taking the upper diagonal part of the output matrix.

If $A$ is such that $m > n$, the Lapack subroutine dorgqr_ create the correct $Q$ matrix.

But if $A$ is such that $m < n$, the same subroutine gives me an error :

** On entry to DORGQR parameter number  2 had an illegal value

I guess it's because $m<n$... should I use another routine for this case?

$\endgroup$
3
$\begingroup$

You seem to be confusing the input arguments for dorgqr. The second argument is the width of the orthogonal/unitary matrix which you would like to generate as the product of the Householder reflectors generated by dgeqrf or dgeqp3. While both of these routines support the $m \le n$ case, you should recognize that, when $m \le n$, the QR decomposition implies a $Q$ which is $m \times m$ and an $R$ which is $m \times n$, and $Q$ is implicitly defined as the product of the $m$ Householder transformations implied by each of the first $m$ columns of the output of dgeqrf/dgeqp3.

You should thus have the first, second, and third argument of dorgqr each equal to $m$. My guess is that you used the width of $A$, $n$, for the second argument, which would be illegal.

$\endgroup$
  • 1
    $\begingroup$ thx, good guess, it is exactly the mistake i made... $\endgroup$ – PinkFloyd Jul 5 '13 at 10:30
2
$\begingroup$

Usually people use the QR decomposition for tall/skinny matrices, as Jan pointed out. For short/fat matrices, the LQ decomposition is more appropriate. It is basically a QR on the transpose of the matrix, and you use routine dgelqf.

If you state what you intend to do with the factorization, we might be able to point out better and more specific solutions.

$\endgroup$
  • $\begingroup$ I have deleted my post... $\endgroup$ – Jan Jul 5 '13 at 5:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.