Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

<random>: Optimize P0952R2 generate_canonical when R is a power of 2 #4750

Closed
StephanTLavavej opened this issue Jun 26, 2024 · 0 comments · Fixed by #4850
Closed

<random>: Optimize P0952R2 generate_canonical when R is a power of 2 #4750

StephanTLavavej opened this issue Jun 26, 2024 · 0 comments · Fixed by #4850
Labels
fixed Something works now, yay! performance Must go faster

Comments

@StephanTLavavej
Copy link
Member

While reviewing @MattStephanson's implementation of #4169 / WG21-P0952R2, @statementreply noted in #4740 (comment) :

_Sx doesn't need to be wider than _Result_uint_type when _Rx is a power of 2, as is noted in https://eel.is/c++draft/rand.util.canonical#7 . The $i$-th random value could be shifted by $i \log_2 R - \log_2 x$ bits instead (the 0th random value is shifted right).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
fixed Something works now, yay! performance Must go faster
Projects
None yet
1 participant