[eigen] Instability in LLT and LDLT methods. |
[ Thread Index |
Date Index
| More lists.tuxfamily.org/eigen Archives
]
- To: eigen <eigen@xxxxxxxxxxxxxxxxxxx>
- Subject: [eigen] Instability in LLT and LDLT methods.
- From: Keir Mierle <mierle@xxxxxxxxx>
- Date: Tue, 27 Jan 2009 10:35:48 -0800
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:date:message-id:subject :from:to:content-type; bh=EZideoue3itfHbphzQBYOSaDhU0jwaOOovV6rt946/4=; b=DDEBPlqK9lQHp/Ht7ZuifMVM7WYKGQLqIzDjEI+V7mC//VibUrVJnhhQrozsDM48Ga DlYBB4xtNevFxLiXhSDcg32KxfM61jQldvArmqj+Lp6rDQIgX/O+QCtvbrqP93Zov/Uf fb4mvUElyUtIHVAiRyJKJW2PMLKJJjmIkxWr4=
- Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:date:message-id:subject:from:to:content-type; b=jUFfYlz6wXUCEyv87gEtDDaxVVS5qgZa+poIL2td4FbiWPz9/w35qXMVDdUk7c2vWJ nqeas/16OnsEBsaOJt1YgHxZA4+ICypChy7iM8dGhrtiMJ67AtQt15WAN00CbZSsKBza qtG+dXwSYF6XnsnHvSzCQ+k0dN7nV3iFFEa/U=
Here is a testcase that fails with LLT and LDLT but works fine with
all of LU, SVD, and QR solving. Depends on my previous patch for QR
solver (or comment out the qr().solve line).
Keir
#include <Eigen/Core>
#include <Eigen/Cholesky>
#include <Eigen/LU>
#include <Eigen/QR>
#include <Eigen/SVD>
using namespace Eigen;
using namespace std;
template<typename Decomposition, typename TMat, typename TVec>
void Solve(const Decomposition &decomposition, const TMat A, const TVec &b) {
TVec x;
if (decomposition.solve(b, &x)) {
cout << "Solved.\n";
cout << "x = " << x.transpose() << endl;
cout << "||Ax - b|| = " << (A*x - b).norm() << endl;
} else {
cout << "Failed to solve.\n";
}
cout << "\n";
}
int main() {
Matrix<double, 3, 3> A;
Matrix<double, 3, 1> b;
A << 7.685e-06, 0, -2.316e-09,
0, 7.686e-06, -3.276e-09,
-2.316e-09, -3.276e-09, 2.892e-06;
b << 1.855e-09, 2.623e-09, -2.689e-12;
cout << "A = \n" << A << endl;
cout << "b = " << b.transpose() << endl;
cout << "\n";
cout << "ldlt: "; Solve(A.ldlt(), A, b);
cout << "llt: "; Solve(A.llt(), A, b);
cout << "lu: "; Solve(A.lu(), A, b);
cout << "svd: "; Solve(A.svd(), A, b);
cout << "qr: "; Solve(A.qr(), A, b);
}