-
-
Notifications
You must be signed in to change notification settings - Fork 5.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
MersenneTwister: implement generation of jump-ahead polynomials #16906
Conversation
22f74b8
to
7cbeb70
Compare
base/dSFMT.jl
Outdated
end | ||
|
||
"Cached jump polynomials for `MersenneTwister`." | ||
# hack: contains Poly19937 at key -1 (as it can not be initialized at compile time) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
need to double check this, but having the comment between the docstring and the const might mean the docstring is not associated with the const?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just checked and it works! but I'll move anyway the comment after the definition.
You can make randjump(rng, 10) # ten jumps with default steps
randjump(rng, steps=10) # one jump with 10 steps
randjump(rng, 10, steps=10) # ten jumps with 10 steps each It's the same thing for |
7cbeb70
to
20aeb42
Compare
base/random.jl
Outdated
randjump(r::MersenneTwister, jumps, jumppoly::AbstractString) -> Vector{MersenneTwister} | ||
|
||
Similar to `randjump(r, jumps, steps)` where the number of steps is determined | ||
by a jump polynomial `jumppoly` in ``GF(2)[X]`` encoded as an hexadecimal string. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe explain in words what GF(2)[X]
means?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated.
20aeb42
to
768b4d1
Compare
a573099
to
426ad10
Compare
I think I agree with your proposed API for |
426ad10
to
801dfc4
Compare
This is freshly rebased. Barring objections, I will just merge this: this adds only a little bit of code, and adds the missing half of the |
This completes PR #12498, which provided the jump-ahead functionality, by allowing to specify an arbitrary number of steps instead of the hard-coded 10^20. This code may very well be better-suited for a package, but it's so tiny (roughly the same size as the original code from #12498) that I thought I could push it here as well.
This is WIP as I'm considering evolving the
randjump
API, e.g. deprecating the methodrandjump(rng::MersenneTwister, jumps, jumppoly::AbstractString)
. Also I think I would like to haverandjump(rng, steps)
(andrandjump!(rng, steps)
) but this is incompatible withrandjump(rng, jumps)
.