## Getting Q and R out of HouseHolderQR (eigen 3.0.4)

BenBenBen
Registered Member
Posts
2
Karma
0

### Getting Q and R out of HouseHolderQR (eigen 3.0.4)

Mon Jan 16, 2012 5:58 pm
Hello,

First of all, thank you for the amazing work you've done with eigen. This library is a pleasure to use, with a great API.
However, I'm a bit confused by the documentation of HouseHolderQR, and haven't found a solution in this forum.

I'm looking to get the Q and R matrix of a QR decomposition of a matrix using HouseHolderQR. The documentation indicates that the method matrixQR() yields "a reference to the matrix where the Householder QR decomposition is stored in a LAPACK-compatible way."

What is the easiest way to get Q and R ? Is there a way to get these matrices using eigen, or do I have to look at the way lapack stores this matrix and retrieve it "by hand" ? If this is the case, should this function be added to the existing implementation ? It would prevent errors related to row-wise vs column-wise storage, etc...
I do need Q and R because I'm dealing with an algorithm that uses these matrices as a basis for other things, so my goal is not simply to solve a linear system.

Thank you for the help, and congratulation for your work ! I'm really looking forward eigen 3.1 with MKL integration.

Benoit
BenBenBen
Registered Member
Posts
2
Karma
0

### Re: Getting Q and R out of HouseHolderQR (eigen 3.0.4)

Tue Jan 17, 2012 10:11 am
I am replying to myself, because the answer might be of some use for other people.

By looking at the implementation of HouseHolderQR, there is a member function householderQ() that does not have any comments even though it is public. I believe this is the reason why it doesn't appear in the documentation http://eigen.tuxfamily.org/dox/classEigen_1_1HouseholderQR.html.

So, to get the Q Matrix, one just has to convert m.householderQ() into a MatrixXd for instance, and then the R matrix is the upper triangular matrix of matrixQR().

Should these indications be added to the documentation ? Shouldn't householderQ() be documented ?
jitseniesen
Registered Member
Posts
185
Karma
2

### Re: Getting Q and R out of HouseHolderQR (eigen 3.0.4)

Tue Jan 17, 2012 10:19 am
Yes, to both question. It seems that the documentation of the HouseHolderQR class can be greatly improved. A patch would be very welcome.

## Who is online

Registered users: alake, Baidu [Spider], Bing [Bot], boudewijn, brandy_000, bshah, cristian.onet, Exabot [Bot], garthecho, Google [Bot], GreatEmerald, Horus, ken300, koriun, Majestic-12 [Bot], mgraesslin, parzt, peje, Tuukka, vomus, Yahoo [Bot]