I wrote an optimization routine, and the tolerance disminishes at each iteration. Comparison is performed at each iteration with a threshold tolerance, 1e-10. I computed a log for the successive iterations, and observe that at some point, tolerance decreases a lot from one iteration to the next, and from 0.000573789 becomes -1.#IND (NaN, right?). And threshold is not detected. Iterations go further althought tolerance threshold has been met.
Should I compare current tolerance both with 1e-10 and with NaN? Where could the problem come from? All the things are double.
Thanks and regards.
You shouldn’t have a NaN in the first place. Enable signals for NaN, run in the debugger, and repair your code.
You might find this article useful.