diff --git a/include/teqp/algorithms/rootfinding.hpp b/include/teqp/algorithms/rootfinding.hpp index 4f2e7921a5bf68bdd4bcc060ac6a0a7b83dd3044..e9e54f02979be3f1dfc25289d3ef5a70d2a8d4cf 100644 --- a/include/teqp/algorithms/rootfinding.hpp +++ b/include/teqp/algorithms/rootfinding.hpp @@ -18,6 +18,9 @@ auto NewtonRaphson(Callable f, const Inputs& args, double tol) { Eigen::ArrayXd v = J.colPivHouseholderQr().solve(-r0.matrix()); x += v; auto err = r0.matrix().norm(); + if (!std::isfinite(err)){ + throw std::invalid_argument("err is now NaN"); + } if (err < tol) { break; }