39 std::array<double, 3>
const roots =
40 boost::math::tools::cubic_roots<double>(
a_,
b_,
c_,
d_);
42 std::vector<double> adjusted_roots;
43 adjusted_roots.reserve(3);
45 double last_valid = std::numeric_limits<double>::quiet_NaN();
47 for (
auto root : roots)
51 if (!std::isnan(last_valid))
53 adjusted_roots.push_back(last_valid);
59 adjusted_roots.push_back(root);
64 ranges::sort(adjusted_roots);
65 return adjusted_roots;