Re: [eigen] potential bug? |
[ Thread Index |
Date Index
| More lists.tuxfamily.org/eigen Archives
]
- To: eigen@xxxxxxxxxxxxxxxxxxx
- Subject: Re: [eigen] potential bug?
- From: Benoit Jacob <jacob.benoit.1@xxxxxxxxx>
- Date: Tue, 3 Aug 2010 14:50:05 -0400
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:received:in-reply-to :references:date:message-id:subject:from:to:content-type :content-transfer-encoding; bh=W4faNloZ2d5ejhZIXx+ydMTZjXtV6XwSkEaXLP6Zmn8=; b=Uqu1rpOS+sZaQFIVmsXgFQhmS+aTFArWo0jzV3oRmdiDCHpyiGQVTWNBpqbIaQVQKT JK4scDeudSTLsyqWVSB00Ac9ClwWbC14ifQuo8kqhh5eMwWfR4Req7MQ2E+SxTF2Toxd t/4nymucv1f9RvPJ6wxlSqRdIVZn8ijhRBwQk=
- Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type:content-transfer-encoding; b=DL5jPtr9ogCsQLTrOFcUWqOTWxz8cg/j1AqKVCiB7p3cXdB7lqHKFsemvtrJt4KCn/ H0UHW7OsUwH21f1NT6I6MCkZoPPVbkJEiluj0FMPZnYhUYpb/3whxtDDwDdLPoeQ/IGc AiLnjtDcWMwzyIJsfM3Jc40KH+mglkqINrqG8=
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
> }
>
>
>