[eigen] [patch] LDLt decomposition with rank-deficient matrices |
[ Thread Index |
Date Index
| More lists.tuxfamily.org/eigen Archives
]
- To: eigen@xxxxxxxxxxxxxxxxxxx
- Subject: [eigen] [patch] LDLt decomposition with rank-deficient matrices
- From: Ben Goodrich <bgokgm@xxxxxxxxxxxxxx>
- Date: Mon, 22 Feb 2010 20:52:03 -0500
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=gamma; h=domainkey-signature:mime-version:received:date:message-id:subject :from:to:content-type; bh=5MLjnmkkoqLS01dhqbATzoPmx4NUkC4P4hPyJCj9tbk=; b=E8JDuaxvMUMl+rgnvQ9XIMAZk/7Op0HMJxwOR4cfWwirbELCZ7LYd7ryYjptVAQS30 yDtdMibkgkpcitB0A3l9D/KpofCqweu4cmqfNcTYNTEayn+yWN6frYdOJSbtlwx2XFA1 Abwdhx1M9wfrzPHlAQt/i8Ino6Q0DTJn/ntQE=
- Domainkey-signature: a=rsa-sha1; c=nofws; d=googlemail.com; s=gamma; h=mime-version:date:message-id:subject:from:to:content-type; b=BbWUmnO0C1IzjvTwPQ19wBz/kLmR2P0eYF7K0K/BiSrlDBOK/9l9X6t/1Z8nl/BE3W 5tZKkRC6AjlsPvTfNKZgEZ6AsGf3QSPEoZop0u2ZlSWjo+lw9rOniGiRe3H8n6qGXDRa rqr33s6wyeMbzMYhS6xE/RhZwNFWnJ4ZF0nTA=
Hi,
Thank you for creating eigen. It is great.
I mentioned a bug about ldlt() with rank-deficient matrices and gave a
test case here:
http://forum.kde.org/viewtopic.php?f=74&t=85449&sid=43724496b3e1705a95b41fa17c0f95eb&start=10
I believe the problem is that when ldlt() decides to abort due to a
diagonal entry of D being too close to zero, it does not change the
remaining diagonal entries to be 0.0 . As a result, when the original
matrix has a nullity of 2 or more, multiplying the factors together
does not result in the original matrix.
The attached patch fixes this issue for me in the test case by zeroing
out the relevant diagonal entries. It applies to the development
branch. I will reply to this message with a patch and a question about
the stable branch.
Thank you,
Ben
# HG changeset patch
# User Ben Goodrich <bgokGM@xxxxxxxxx>
# Date 1266888211 18000
# Node ID 1c47a9153fef51ef667f90910de4cb86474d8fdc
# Parent a4b00df290033caece6c90dfdd9c214d5bc20e51
set some diagonal elements of D as 0.0 if matrix is rank-deficient
diff -r a4b00df29003 -r 1c47a9153fef Eigen/src/Cholesky/LDLT.h
--- a/Eigen/src/Cholesky/LDLT.h Mon Feb 22 15:39:17 2010 +0100
+++ b/Eigen/src/Cholesky/LDLT.h Mon Feb 22 20:23:31 2010 -0500
@@ -214,7 +214,10 @@
// Finish early if the matrix is not full rank.
if(biggest_in_corner < cutoff)
{
- for(int i = j; i < size; i++) m_transpositions.coeffRef(i) = i;
+ for(int i = j; i < size; i++) {
+ m_transpositions.coeffRef(i) = i;
+ m_matrix.coeffRef(i,i) = 0.0;
+ }
break;
}
@@ -238,7 +241,10 @@
// Finish early if the matrix is not full rank.
if(ei_abs(Djj) < cutoff)
{
- for(int i = j; i < size; i++) m_transpositions.coeffRef(i) = i;
+ for(int i = j; i < size; i++) {
+ m_transpositions.coeffRef(i) = i;
+ m_matrix.coeffRef(i,i) = 0.0;
+ }
break;
}