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

Is HouseholderQR suitable for economy QR?

Tags: None
(comma "," separated)
matriza
Registered Member
Posts
17
Karma
0
To do economy QR of a matrix Y I'm currently using
Code: Select all
ColPivHouseholderQR<MatrixXd> qr(Y);
MatrixXd Z = qr.matrixQ();
MatrixXd Q = Z.leftCols(Y.cols());

to get economy QR, but this is quite slow for large matrices. Would HouseholderQR be suitable?

As an aside, why can't I subset a matrix and reassign to itself, like
Code: Select all
MatrixXd Q = qr.matrixQ();
Q = Q.leftCols(Y.cols());

this gives me segfaults and valgrind complains about it too.

Thanks.

Edit: also, is there a better way of computing economy QR for large matrices? I've got matrices of 100K by 20, and 100K x 100K takes too much RAM.
User avatar
ggael
Moderator
Posts
3447
Karma
19
OS
internally, both HouseholderQR and the column pivoting variant does "economy QR" since the orthogonal factor Q is stored as householder reflectors. What is missing though is an easy way to evaluate the Householder sequence returned by householderQ() or matrixQ() which is an alias to a thin dense matrix. Currently, the best is:

MatrixXd thinQ = MatrixXd::Identity(Y.rows()m Y.cols());
thinQ = qr.householderQ() * thinQ;

Regarding your second question:

Q = Q.leftCols(Y.cols());

is not valid because of "aliasing" issue. Q is first resized and reallocated, and then the copy takes place, but that's too late !

You can use Q.conservativeResize(NoChange,Y.cols());


Bookmarks



Who is online

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