Tony Finch
d20ea4a703
Make isc_random_uniform() nearly divisionless
...
It used to require two 32-bit integer divisions to get a random number
less than some limit. Now we use Daniel Lemire's "nearly-divisionless"
algorithm for unbiased bounded random numbers, which requires one
64-bit integer multiply in the usual case, and one 32-bit integer
division in rare slow cases. Even the slow cases are faster than
before; there are also fewer branches.
I think this algorithm is exceptionally beautiful. It also has more
clever tricks than lines of code, so I have done my best to explain
how it works.
2022-04-22 16:40:37 +01:00
..
2022-01-11 09:05:02 +01:00
2022-01-11 09:05:02 +01:00
2022-04-01 23:45:23 +02:00
2022-03-25 08:33:43 +01:00
2022-01-11 09:05:02 +01:00
2022-01-11 09:05:02 +01:00
2022-03-25 08:33:43 +01:00
2022-01-11 09:05:02 +01:00
2022-01-11 09:05:02 +01:00
2022-01-11 09:05:02 +01:00
2022-01-11 09:05:02 +01:00
2022-01-11 09:05:02 +01:00
2022-01-11 09:05:02 +01:00
2022-01-11 09:05:02 +01:00
2022-01-11 09:05:02 +01:00
2022-01-11 09:05:02 +01:00
2022-01-11 09:05:02 +01:00
2022-01-11 09:05:02 +01:00
2022-01-11 09:05:02 +01:00
2022-01-11 09:05:02 +01:00
2022-01-11 09:05:02 +01:00
2022-01-11 09:05:02 +01:00
2022-03-25 08:33:43 +01:00
2022-04-19 14:25:23 +02:00
2022-01-11 09:05:02 +01:00
2022-01-11 09:05:02 +01:00
2022-01-11 09:05:02 +01:00
2022-01-11 09:05:02 +01:00
2022-01-11 09:05:02 +01:00
2022-01-11 09:05:02 +01:00
2022-04-01 23:04:24 +02:00
2022-03-08 11:19:34 +01:00
2022-01-11 09:05:02 +01:00
2022-01-11 09:05:02 +01:00
2022-03-28 15:02:18 -07:00
2022-01-11 09:05:02 +01:00
2022-01-11 09:05:02 +01:00
2022-01-11 09:05:02 +01:00
2022-01-11 09:05:02 +01:00
2022-01-11 09:05:02 +01:00
2022-03-04 13:49:51 +01:00
2022-01-11 09:05:02 +01:00
2022-01-11 09:05:02 +01:00
2022-01-11 09:05:02 +01:00
2022-01-11 09:05:02 +01:00
2022-01-11 09:05:02 +01:00
2022-01-11 09:05:02 +01:00
2022-01-11 09:05:02 +01:00
2022-01-11 09:05:02 +01:00
2022-01-11 09:05:02 +01:00
2022-01-27 15:48:50 -08:00
2022-01-11 09:05:02 +01:00
2022-04-19 11:08:13 +02:00
2022-01-11 09:05:02 +01:00
2022-01-11 09:05:02 +01:00
2022-01-11 09:05:02 +01:00
2022-01-11 09:05:02 +01:00
2022-01-27 13:02:23 +01:00
2022-01-11 09:05:02 +01:00
2022-01-11 09:05:02 +01:00
2022-01-11 09:05:02 +01:00
2022-01-11 09:05:02 +01:00
2022-01-11 09:05:02 +01:00
2022-04-22 16:40:37 +01:00
2022-03-14 13:00:05 -07:00
2022-01-11 09:05:02 +01:00
2022-01-11 09:05:02 +01:00
2022-01-11 09:05:02 +01:00
2022-01-11 09:05:02 +01:00
2022-03-28 15:32:30 +03:00
2022-01-11 09:05:02 +01:00
2022-01-11 09:05:02 +01:00
2022-01-11 09:05:02 +01:00
2022-01-11 09:05:02 +01:00
2022-01-27 15:48:50 -08:00
2022-01-11 09:05:02 +01:00
2022-01-11 09:05:02 +01:00
2022-03-08 23:55:10 +01:00
2022-01-11 09:05:02 +01:00
2022-01-11 09:05:02 +01:00
2022-01-11 09:05:02 +01:00
2022-01-11 09:05:02 +01:00
2022-01-11 09:05:02 +01:00
2022-01-11 09:05:02 +01:00
2022-04-19 14:25:23 +02:00
2022-02-09 17:22:06 +01:00
2022-03-14 13:00:05 -07:00
2022-04-02 01:23:15 +02:00
2022-04-06 18:45:57 +03:00
2022-01-11 09:05:02 +01:00
2022-03-14 13:00:05 -07:00
2022-01-11 09:05:02 +01:00
2022-01-11 09:05:02 +01:00
2022-04-04 21:20:05 +02:00