Re: [eigen] Scalar vs. int / double in SelfAdjointEigenSolver.h

[ Thread Index | Date Index | More Archives ]

On 2016-08-11 08:40, Pavel Holoborodko wrote:
*...which may not the case for user defined type.*

 From my experience of creating custom scalar type (mpreal) -
I can say that keeping code without explicit conversions to Scalar is very

I generally agree on that -- and this is also true for AutoDiff-types. However we traditionally did convert all POD scalars to "Scalar" before using it, in order to be compatible with custom scalars which do not support operators with mixed types. I guess an optimal solution could be add a templated convert method, into NumTraits<Scalar> like:

template<class Scalar>
struct NumTraits {
  // other NumTraits stuff ...
  template<class X>
  static Scalar convert(const X& x) { return Scalar(x); }

which, if Scalar supports operations with PODs, can be specialized to:
  template<class X>
  static const X& convert(const X& x) { return x; }

Unfortunately, this would require massive refactoring. Maybe we just add the Scalar() conversion for now, and consider changing this for 3.3.x or 3.4?


 Dipl. Inf., Dipl. Math. Christoph Hertzberg

 Universität Bremen
 FB 3 - Mathematik und Informatik
 AG Robotik
 Robert-Hooke-Straße 1
 28359 Bremen, Germany

 Zentrale: +49 421 178 45-6611

 Besuchsadresse der Nebengeschäftsstelle:
 Robert-Hooke-Straße 5
 28359 Bremen, Germany

 Tel.:    +49 421 178 45-4021
 Empfang: +49 421 178 45-6600
 Fax:     +49 421 178 45-4150
 E-Mail:  chtz@xxxxxxxxxxxxxxxxxxxxxxxx

 Weitere Informationen:

Mail converted by MHonArc 2.6.19+