Re: [eigen] potential bug?

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


2010/8/3 Hauke Heibel <hauke.heibel@xxxxxxxxxxxxxx>:
> Hi,
>
> this code here produces a norm of around 2. Is that a bug or is it me?
>
> - Hauke
>
> #include <Eigen/Eigen>
>
> #include <iostream>
>
> using namespace Eigen;
>
> void main()
> {
>  typedef Matrix4d MatrixType;
>  MatrixType m = MatrixType::Random();
>
>  ColPivHouseholderQR<MatrixType> qr(m);
>
>  MatrixType R = qr.matrixQR().triangularView<Upper>();
>  MatrixType Q = qr.householderQ();
>
>  std::cout << qr.rank() << std::endl;
>  std::cout << (Q*R - m).norm() << std::endl;

ColPivHouseholderQR is... pivoting :-)

So you need to apply the permutation if you want to reconstruct the
original matrix.

See the unit-test:
  MatrixType r = qr.matrixQR().template triangularView<Upper>();
  MatrixType c = q * r * qr.colsPermutation().inverse();
  VERIFY_IS_APPROX(m1, c);

Benoit


> }
>
>
>



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