-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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>
: Skip reset in normal_distribution::operator()
with custom params
#4618
<random>
: Skip reset in normal_distribution::operator()
with custom params
#4618
Conversation
…arams `normal_distribution` works by computing a pair of coefficients that are multiplied with the stddev to compute how far (and in which direction) the result is from the mean. These coefficients are not reliant on the actual stddev (or mean), so there is no reason to avoid reusing one computed during last invocation, even if it was with different params. AFAIK usage of this overload is rare (personally I think this overload should've never been standardized), the old code still needlessly penalized it, in the worst case halving the performance.
I am not sure whether this needs a test, and where to add it. The organization of tests seems to be oriented around papers/github issues, but this has none... I guess I could use the github PR number instead, now that it is open. |
Sounds good to me. An alternative could be squeezing into an existing test, but I don't see a suitable |
<random>
: Skip reset in normal_distribution::operator()
with custom params
tests/std/tests/GH_004618_normal_distribution_avoids_resets/test.cpp
Outdated
Show resolved
Hide resolved
tests/std/tests/GH_004618_normal_distribution_avoids_resets/test.cpp
Outdated
Show resolved
Hide resolved
tests/std/tests/GH_004618_normal_distribution_avoids_resets/test.cpp
Outdated
Show resolved
Hide resolved
tests/std/tests/GH_004618_mixed_operator_usage_keeps_statistical_properties/test.cpp
Outdated
Show resolved
Hide resolved
tests/std/tests/GH_004618_mixed_operator_usage_keeps_statistical_properties/test.cpp
Outdated
Show resolved
Hide resolved
tests/std/tests/GH_004618_mixed_operator_usage_keeps_statistical_properties/test.cpp
Outdated
Show resolved
Hide resolved
tests/std/tests/GH_004618_mixed_operator_usage_keeps_statistical_properties/test.cpp
Outdated
Show resolved
Hide resolved
tests/std/tests/GH_004618_mixed_operator_usage_keeps_statistical_properties/test.cpp
Outdated
Show resolved
Hide resolved
This is awesome, thank you! 😻 I pushed a conflict-free merge with |
I'm mirroring this to the MSVC-internal repo - please notify me if any further changes are pushed. |
Thanks again for improving performance and simplifying code! 🚀 ✨ 😻 |
normal_distribution
works by computing a pair of coefficients that are multiplied with the stddev to compute how far (and in which direction) the result is from the mean. These coefficients are not reliant on the actual stddev (or mean), so there is no reason to avoid reusing one computed during last invocation, even if it was with different params.AFAIK usage of this overload is rare (personally I think this overload should've never been standardized), the old code still needlessly penalized it, in the worst case halving the performance.