Differentiate the two usage of Index types
Submitted by Gael Guennebaud @ggael
Assigned to Nobody
Link to original bugzilla bug (#572)
Version: 3.3 (current stable)
Description
Currently, the Index type appear in different contexts:
1 - For classic dense expression, Index refers to the integer type used for storing and returning sizes, for coefficient indexes, etc. In this context it is always equal to DenseIndex (=ptrdiff_t).
2 - For PermutationMatrix, Transpositions and Sparse expression, it is used for the same purpose as above, but it also corresponds to the value type used to store all the indices. It defined through a template parameter and most of the time it is equal to 'int' for compactness purpose.
This results in a lot of conflicting conversions from 64 bits integers to 32 bits ints, and so a huge amount of legitimate warnings when such warnings are detected.
In my opinion, in the 2nd case all the sizes, coefficient indexes, loop counters, etc. should keep using the globally defined DenseIndex type (poorly named), and the templated Index type should only be used for the internal storage and for method that explicitly and directly returns such indices. Concretely, this would means that PermutationMatrix::rows() would always return a DenseIndex, PermutationMatrix::operator()(i) would always take a DenseIndex, but it would return the Index type defined from its template parameter.
The problem is that would slightly change the API since some method would now take/return long int instead of int. On the other