EigenRand icon indicating copy to clipboard operation
EigenRand copied to clipboard

Integral types

Open kc9jud opened this issue 1 year ago • 3 comments

Is there a reason why Discrete.h uses std::is_same rather than std::is_integral here? https://github.com/bab2min/EigenRand/blob/f3190cd7f85c5878c949625cb2811262ff050d66/EigenRand/Dists/Discrete.h#L217 If this is instead std::is_integral<_Scalar>::value, then the discrete generators can also be used for int64_t, uint32_t, etc.

kc9jud avatar Oct 14 '24 19:10 kc9jud

Would this line: https://github.com/bab2min/EigenRand/blob/f3190cd7f85c5878c949625cb2811262ff050d66/EigenRand/Dists/Discrete.h#L268 need to change to if (bitcnt + bitsize < CHAR_BIT*sizeof(_Scalar))?

kc9jud avatar Oct 14 '24 19:10 kc9jud

As I look further, it seems like there are a decent number of places where other types/constants need to become sizeof-dependent. Is this of interest?

kc9jud avatar Oct 14 '24 19:10 kc9jud

Hi @kc9jud , thank you for your interest in this repository. It is because Discrete generators use some specialized routine for int32_t SIMD. At the time of first implementation, only int32_t was considered, so additional implementations were required to make it work for other integral types. I will add support for other integral types in future updates.

bab2min avatar Oct 20 '24 17:10 bab2min