diff --git a/Number_types/include/CGAL/Interval_nt.h b/Number_types/include/CGAL/Interval_nt.h index 131d47da86e..e0c09d1f3e1 100644 --- a/Number_types/include/CGAL/Interval_nt.h +++ b/Number_types/include/CGAL/Interval_nt.h @@ -52,6 +52,7 @@ #include #include #include +#include namespace CGAL { @@ -1274,6 +1275,46 @@ namespace Eigen { template struct significant_decimals_impl > : significant_decimals_impl::value_type> { }; + + // Without this, when computing some decompositions for a matrix of + // intervals, Eigen looks for the largest element in a column (for + // instance). There may easily be 2 equal, slightly imprecise numbers that + // could equally well be used as pivots, but Eigen ends up spuriously + // throwing in the comparison between them. So we provide a different + // strategy for picking the pivot. + template struct scalar_score_coeff_op; + template struct scalar_score_coeff_op > { + // If all coeffs can be 0, it is essential to designate as the best one + // that can be non-zero and has a non-zero score, if there is one. + struct result_type : boost::totally_ordered1 { + CGAL::Interval_nt i; + result_type():i(){} + result_type(CGAL::Interval_nt j):i(j){} + friend bool operator<(result_type x, result_type y){ + if(x.i.inf()==0){ + if(y.i.inf()==0)return x.i.sup() const&x)const{return abs(x);} + }; } }