Re: [eigen] Specializing max_coeff_visitor for some number types

[ Thread Index | Date Index | More lists.tuxfamily.org/eigen Archives ]


On Mon, 28 Apr 2014, Marc Glisse wrote:

here is a simpler alternative, where I only replace abs() by a score function, so the change looks really minor.

I tested the following in CGAL and it worked just as well as the previous version:

I changed the CGAL testcase because it is important that only 0 have a score of 0 (the interval [0,1] should have a non-zero score). It is not optimal (I would like [0,1]>[0,0] but [1,2]<[1,1]) but good enough (some day I'll experiment with the policies discussed with Christoph Hertzberg). Note that this doesn't affect the patch to Eigen, which is giving me a simple hook to score and compare coefficients any way I want.


  template<bool b> struct scalar_score_coeff_op<CGAL::Interval_nt<b> > {
    // If all coeffs can be 0, it is important to designate as the max one
    // that can be non-zero and has a non-zero score, if there is one.
    struct result_type : boost::totally_ordered1<result_type> {
      CGAL::Interval_nt<b> i;
      result_type():i(){}
      result_type(CGAL::Interval_nt<b> j):i(j){}
      friend bool operator<(result_type x, result_type y){
        if (x.i.inf() != y.i.inf())
          return x.i.inf() < y.i.inf();
        else
          return x.i.sup() < y.i.sup();
      }
      friend bool operator==(result_type x, result_type y){
        // Throw if we don't know if the max coeff is 0
        return x.i == y.i;
      }
    };
    result_type operator()(CGAL::Interval_nt<b> const&x)const{ return abs(x); }
  };



Would opening a PR in bugzilla help move things forward? Or would it bury it even deeper? I am not familiar with this project so I don't know the proper procedure...

--
Marc Glisse



Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/