becheran / fast-hilbert

Fast Hilbert space-filling curve transformation using a LUT
MIT License
41 stars 3 forks source link

Generalise functions for other uints #3

Closed DoubleHyphen closed 3 years ago

DoubleHyphen commented 3 years ago

OK, so this was way more difficult than I thought, and the code's become a bit uglier as a result. Nonetheless, the functions now ought to function not just for u32s as before but also for u8s, u16s and u64s.

Admittedly, I'd like it to be refactored at some point so the code can become cleaner. For now, however, this ought to suffice. In the meantime I'll try to think if there are other optimisations we can perform.

Oh, and also: Seeing as the LUTs for each function were only being used within that one function, I took the liberty of moving them inside those functions.

becheran commented 3 years ago

Looks great again! I will have a look soon. Very handy

becheran commented 3 years ago

I did checkout the code and get it running adding the num_traits dependency. Sad that something like num_traits is not part of rust std.

I now observe a further performance gain dropping from 600 ms to about 180 ms so this is now more in the performance range that you experienced. But were does this 3 times speedup come from? Looking at the code I don't really get it?