rcond not correct for rank deficient matrix
Summary
I am using Eigen::FullPivLU with Eigen::Matrix<double, 7, 7>. I found that the rcond function of FullPivLU returns a non-zero value even if the input matrix is rank deficient. Maybe I have misunderstood something, but it seems to me that this is bug.
Best regards, Morten Åkerblad
Environment
- Operating System : Window
- Architecture : x64
- Eigen Version : 3.4.0
- Compiler Version : Visual Studio Version 17.11.6
- Compile Flags : -O3 -march=native
- Vector Extension : SSE/AVX/NEON ...
Minimal Example
using Matrix7x7 = Eigen::Matrix<double, 7, 7>;
using Vector7 = Eigen::Matrix<double, 7, 1>;
void test_rcond(Matrix7x7& A)
{
Eigen::FullPivLU<Matrix7x7> lu_factorization(A);
if (lu_factorization.rank() < 7)
{
double rcond = lu_factorization.rcond();
assert(rcond == 0.0);
}
}
Steps to reproduce
Here is a dump of the matrix A:
0.0000000000000000
0.0000000000000000
1.0000000000000000
0.0000000000000000
0.34149999916553497
0.0000000000000000
0.79877008515664061
0.0000000000000000
1.0000000000000000
0.0000000000000000
0.29200000315904617
0.0000000000000000
-0.37149999849498272
-0.16425902650844920
0.0000000000000000
0.0000000000000000
1.0000000000000000
0.0000000000000000
0.34149999916553497
0.0000000000000000
0.79877008515664061
0.0000000000000000
1.0000000000000000
0.0000000000000000
0.040500000119209290
0.0000000000000000
-0.30099999904632568
-0.081170580429391403
1.0000000000000000
0.0000000000000000
0.0000000000000000
0.0000000000000000
0.0000000000000000
0.0000000000000000
-0.0000000000000000
0.0000000000000000
0.70710689672598170
0.70710666564709435
0.027000000700354562
0.025455838867477515
-0.025455847186317101
-0.0068972271572272821
1.0000000000000000
0.0000000000000000
0.0000000000000000
0.0000000000000000
0.0000000000000000
0.0000000000000000
-0.0000000000000000
It has rank 5, but rcond returns 0.054420254040403307, which seems like a bug to me.
Here is another example where rank = 6 and rcond = 0.041005432281770185
-0.18993746291019808
0.0000000000000000
0.0000000000000000
1.0000000000000000
0.0000000000000000
0.35004772836926978
0.0000000000000000
0.78634840828157904
0.0000000000000000
1.0000000000000000
0.0000000000000000
0.0071360472582042700
0.0000000000000000
-0.30954772825006049
-0.098431819579263849
1.0000000000000000
0.0000000000000000
0.0000000000000000
0.0000000000000000
0.033363952861005020
0.0000000000000000
0.0031123239693799164
0.0000000000000000
1.0000000000000000
0.0000000000000000
-0.0063639521606504434
0.0000000000000000
-0.044547727654014047
-0.011272635679894241
0.70710689672598170
0.0000000000000000
-0.70710666564709435
0.0000000000000000
0.0000000000000000
0.0000000000000000
8.4516301250972170e-18
What is the current bug behavior?
What is the expected correct behavior?
Relevant logs
Warning Messages
Benchmark scripts and results
Anything else that might help
-
Have a plan to fix this issue.
Edited by Antonio Sánchez