[eigen] Custom Scalar in QR

[ Thread Index | Date Index | More lists.tuxfamily.org/eigen Archives ]


I have noticed strange behavior when HousholderQR (default branch) is used with mpfr::mpreal.

Accuracy is lost when QR is applied to rectangular matrix, m < n.

        //typedef double RealScalar;
        typedef mpfr::mpreal RealScalar;

        typedef Eigen::Matrix< RealScalar, Dynamic, Dynamic> RealMatrix;

        int m = 2, n = 4;
        RealMatrix a(m,n);
        RealMatrix r, q;

        srand(0);
        a.setRandom();

        HouseholderQR<RealMatrix> qr(a);

        r = qr.matrixQR().triangularView<Upper>();
        q = qr.householderQ();

        RealScalar e = (a-q*r).norm();
        
        std::cout <<"A-Q*R = "<< e << std::endl; // should be of machine epsilon scale

Output for "double" (correct):

   A-Q*R = 2.88444e-016

Output for "mpreal" (accuracy is lost):

   A-Q*R = 1.40222

This affects "default" branch. Branch 3.2 (with all recent updates) produces correct result.
Similar situation happens with dense LU.

Decided to report issue in the mail-list since it is appeared very recently and probably can be fixed quickly while it is "hot".

Would appreciate any ideas/advice what (recent) changes might cause the issue.

Thanks in advance,
Pavel.


Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/