This forum has been archived. All content is frozen. Please use KDE Discuss instead.

QR decomposition: Extracting out the Q and R matrices

Tags: None
(comma "," separated)
marvisiyer
Registered Member
Posts
21
Karma
0
How to extract the Q & R matrices for the QR decomposition in Eigen?
jitseniesen
Registered Member
Posts
204
Karma
2
marvisiyer wrote:How to extract the Q & R matrices for the QR decomposition in Eigen?

Which QR decomposition are you using? For instance, for ColPivHouseholderQR, looking in the documentation at http://eigen.tuxfamily.org/dox-devel/cl ... derQR.html I can see a method .householderQ() for extracting the Q matrix and .matrixR() for extracting the R matrix.
marvisiyer
Registered Member
Posts
21
Karma
0
jitseniesen wrote:
marvisiyer wrote:How to extract the Q & R matrices for the QR decomposition in Eigen?

Which QR decomposition are you using? For instance, for ColPivHouseholderQR, looking in the documentation at http://eigen.tuxfamily.org/dox-devel/cl ... derQR.html I can see a method .householderQ() for extracting the Q matrix and .matrixR() for extracting the R matrix.


Thanks. I was using looking at FullPivHouseholderQR(http://eigen.tuxfamily.org/dox-devel/cl ... derQR.html) and HouseholderQR(http://eigen.tuxfamily.org/dox-devel/cl ... derQR.html) and these didn't have the method matrixR(). Thanks again.
User avatar
ggael
Moderator
Posts
3447
Karma
19
OS
but they have a matrixQR() from which you can get the R matrix as the upper triangular part:
Code: Select all
qr.matrixQR().triangularView<Upper>()
marvisiyer
Registered Member
Posts
21
Karma
0
ggael wrote:but they have a matrixQR() from which you can get the R matrix as the upper triangular part:
Code: Select all
qr.matrixQR().triangularView<Upper>()


Thanks. But looks like all the three methods return a full QR. My matrix is a very thin matrix and I definitely do not want to do full QR. How should I proceed to get a reduced QR factorization?
User avatar
ggael
Moderator
Posts
3447
Karma
19
OS
they do a reduced QR by default.
jitseniesen
Registered Member
Posts
204
Karma
2
There is a thread about the thin QR at viewtopic.php?f=74&t=91271 . The code at the end of that thread may be useful for you.
marvisiyer
Registered Member
Posts
21
Karma
0
ggael wrote:they do a reduced QR by default.


The question is precisely how to do that? Given a thin matrix A, how to get its thin QR and store the Q and R factors?
subhadeepk
Registered Member
Posts
3
Karma
0
marvisiyer wrote:
ggael wrote:but they have a matrixQR() from which you can get the R matrix as the upper triangular part:
Code: Select all
qr.matrixQR().triangularView<Upper>()


Thanks. But looks like all the three methods return a full QR. My matrix is a very thin matrix and I definitely do not want to do full QR. How should I proceed to get a reduced QR factorization?


I am getting an error Upper was not declared in this scope. Any hints, sorry for being noob.


I have included hearder files Eigen/Dense , Eigen/QR

Edited:

Found the bug, forgot to write in using namespace Eigen;


Bookmarks



Who is online

Registered users: Bing [Bot], Google [Bot], Yahoo [Bot]