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>: Fix mersenne_twister_engine special case behavior #1631

Merged
merged 8 commits into from
Jun 29, 2021

Conversation

statementreply
Copy link
Contributor

@statementreply statementreply commented Feb 8, 2021

  • Fixes mersenne_twister_engine random number generation when m = n or n = 1. [rand.eng.mers]/1:

    [...] all subscripts applied to X are to be taken modulo n.

  • Fixes mersenne_twister_engine seeding when input is degenerate.
  • Also removes the trailing space of text output.

@statementreply statementreply requested a review from a team as a code owner February 8, 2021 06:13
Copy link
Contributor

@miscco miscco left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not really that deep into mersenne twister so some superficial comments that made me scratch my head

stl/inc/random Outdated Show resolved Hide resolved
stl/inc/random Outdated Show resolved Hide resolved
@StephanTLavavej StephanTLavavej added the bug Something isn't working label Feb 8, 2021
Revert some const-folded values to their original expressions, so they
look similar to other code paths.

Reduce scope of `_Ix`.

Mark `_Tmp` as const.
stl/inc/random Outdated Show resolved Hide resolved
stl/inc/random Outdated Show resolved Hide resolved
stl/inc/random Show resolved Hide resolved
stl/inc/random Show resolved Hide resolved
@CaseyCarter CaseyCarter removed their assignment Jun 23, 2021
@StephanTLavavej StephanTLavavej self-assigned this Jun 24, 2021
@StephanTLavavej StephanTLavavej merged commit 6780481 into microsoft:main Jun 29, 2021
@StephanTLavavej
Copy link
Member

Thanks for fixing these 3 bugs - clearly chosen because 3 is both a Mersenne prime exponent and a Mersenne prime itself! 😹

@statementreply statementreply deleted the fix-mersenne-twister branch August 28, 2021 06:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants
  翻译: