Registered Member
|
After looking at the member list for
ColPivHouseholderQR(<MatrixXd>) qr(A); given at http://eigen.tuxfamily.org/dox/classEig ... mbers.html and various other Eigen documentation, and after also looking at some past posts, I found two things that are unclear: 1) Seems the intended ways to access Q and R are: Q = qr.householderQ(); R_notquite = qr.matrixQR(); Am I correct? What is unclear is the following: notice above I called it R_notquite, because my results indicate it's not quite R, because I find it's not upper diagonal, --- here's an actual 2x3 example result returned by qr.matrixQR() --- notice in the bottom row that its first column is far from 0: -2.23 -2.23 -2.23 0.618 -1.8e-16 -1.8e-16 Having said this, I did find that both diagonal and above-the-diagonal in an R_notquite are basically the same as R's (when I compute R with Matlab's [Q,R,P]=qr(A), to compare). Is this lack of appearance of zeros below the diagonal the intended behavior or a bug? To obtain R, s it a sufficient workaround for the user to make it upper diagonal by simply setting its below-the-diagonal elements to 0 (given that its diagonal and above-the-diagonal appear to be the same as the expected R's, as mentioned above)? I wonder if it might be related to this ColPivHouseholderQR bug: http://eigen.tuxfamily.org/bz/show_bug.cgi?id=295 2) It is unclear how to use the above qr variable to access the permutation matrix P (where AP=QR). As a matter of fact, I'm more interested in the vector version of P, just like returned by Matlab's [Q,R,P]=qr(A,0) (where the 0 tells Matlab to return P vector rather than P matrix). Of course, to determine the linearly independent columns of A via the "QR with column pivoting" approach (which, in Eigen, is ColPivHouseholderQR), the P is necessary. In Matlab I believe the lin indep cols are given by A(:,P(1:r)) where r is the number of pivot columns (available in Eigen as qr.nonzeroPivots()). I'm trying to determine the lin indep cols in Eigen using this same sort of approach (by using QR, without having to row-reduction to echelon form). Thanks in advance for any clarification! |
Registered Member
|
Hmm, the documentation of that class can be improved.
1) The matrix returned by qr.matrixQR() contains both Q and R, as the name suggests. The upper triangular part (including the diagonal) contains the matrix R, while the strictly lower triangular part encodes the matrix Q. In your 2x3 example, the first entry of the second row comes from Q and the other entries form R. If you want only R, you can write R = qr.matrixQR().triangularPart<Upper>() . 2) The permutations can be accessed via the undocumented function qr.colsPermutation() . |
Registered users: Bing [Bot], Google [Bot], Yahoo [Bot]