Stuck in loop for a certain input when using mpreal support
Submitted by Joel Dahne
Assigned to Nobody
Link to original bugzilla bug (#1695)
Version: 3.3 (current stable)
Description
Created attachment 934
File containing program and input data to reproduce the problem
The BDCSVD function for computing singular value the decomposition of a matrix gets stuck in a loop when using mpreal for a certain input.
To reproduce this compile the attached program, on my system this is done with
g++ -Wall -I/usr/include/eigen3/ eigen_svd_bug.cpp -o eigen_svd_bug -lmpfr
and then run it with the input from the attached text file
./eigen_svd_bug < bug-matrix-mpfr
It then gets stuck in an loop and does not return. It seems to be very sensitive to the input data, for example just changing the precision to 63 (or 65) bits instead of 64 makes it return.
I have been trying to identify the problem and it seems to be the final while loop in the function computeSingVals that gets stuck
while (rightShifted - leftShifted > Literal(2) * NumTraits<RealScalar>::epsilon() * numext::maxi<RealScalar>(abs(leftShifted), abs(rightShifted)))
{
...
}
I think the problem could be related to the fact that mpreal (mpfr) has a much wider exponent then normal double precision floating points and the worst case scenario for this loop is thus much worse for mpreal than for double. However I'm not sure this is the case and I'll try to look into it a bit more, getting back if I find anything.
Attachment 934, "File containing program and input data to reproduce the problem":
reproduce.tar