Re: [eigen] Floating point as index type

[ Thread Index | Date Index | More Archives ]


If we wanted to ensure not to break existing code here, we'd need to explicitly allow everything which can be converted to Eigen::Index (aka std::ptrdiff_t). But on the one hand, that would be complicated (due to the new Indexing feature), and on the other hand, I agree that this might rather hide existing bugs. (Like accessing Vector[(double(N)/n)*n] may or may not round down)

As a workaround you could write yourself a DenseBase plugin which adds `operator()(double, double)`, etc:

But as also suggested by Rasmus, you should really just explicitly cast your floats/doubles to Eigen::Index (perhaps after rounding instead of truncating -- depending on your use-case). This will not add any overhead, as this was happening implicitly before -- only some syntactic noise which actually is good, since you are misusing types here.


On 25/11/2019 23.16, Gael Guennebaud wrote:

yes we are aware of that. We could explicitly accept float and double as
"valid_index_type", but I think this would just keep silent some latent
bugs. I've just added note there:


On Mon, Nov 25, 2019 at 7:57 PM Janos Meny <janos.meny@xxxxxxxxxxxxxx>

Hey everyone,

I noticed that in the development branch the following code will no longer

Aside from the fact that I think this is a bug, this would break a lot of
code I think.

Best regards


 Dr.-Ing. Christoph Hertzberg

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

 Postadresse der Hauptgeschäftsstelle Standort Bremen:
 Robotics Innovation Center
 Robert-Hooke-Straße 1
 28359 Bremen, Germany

 Tel.:     +49 421 178 45-4021
 Zentrale: +49 421 178 45-0
 E-Mail:   christoph.hertzberg@xxxxxxx

 Weitere Informationen:
  Deutsches Forschungszentrum für Künstliche Intelligenz GmbH
  Trippstadter Straße 122, D-67663 Kaiserslautern, Germany

  Prof. Dr. Antonio Krüger (Vorsitzender)
  Dr. Walter Olthoff

  Vorsitzender des Aufsichtsrats:
  Dr. Gabriël Clemens
  Amtsgericht Kaiserslautern, HRB 2313

Mail converted by MHonArc 2.6.19+