Search code examples
c++eigenqr-decomposition

Thin QR decomposition in c++


Is there an easy to use c++ library for "thin" QR decomposition of a rectangular matrix?
Eigen seems to only support full Q matrices. I can take a full Q and discard some columns, but would it be more efficient to not compute them to begin with?


Solution

  • Newmat does exactly what you want.

    To decompose A into QR, you can do:

    Matrix Q = A;
    UpperTriangularMatrix R;
    QRZ(Q, R)
    

    If A is a 3x5 matrix, R will be 3x3 and Q will be 3x5 as well.