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

allocate distinct seed arrays for RNGs in randjump #21868

Merged
merged 1 commit into from
May 16, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
allocate distinct seed arrays for RNGs in randjump
  • Loading branch information
rfourquet committed May 16, 2017
commit 598f5850b6b567d8f010a3f35a9f4c9cd2257bfc
2 changes: 1 addition & 1 deletion base/random.jl
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ function randjump(mt::MersenneTwister, jumps::Integer, jumppoly::AbstractString)
push!(mts, mt)
for i in 1:jumps-1
cmt = mts[end]
push!(mts, MersenneTwister(cmt.seed, dSFMT.dsfmt_jump(cmt.state, jumppoly)))
push!(mts, MersenneTwister(copy(cmt.seed), dSFMT.dsfmt_jump(cmt.state, jumppoly)))
end
return mts
end
Expand Down
6 changes: 6 additions & 0 deletions test/random.jl
Original file line number Diff line number Diff line change
Expand Up @@ -475,6 +475,12 @@ end
let seed = rand(UInt32, 10)
r = MersenneTwister(seed)
@test r.seed == seed && r.seed !== seed
# RNGs do not share their seed in randjump
let rs = randjump(r, 2)
@test rs[1].seed !== rs[2].seed
srand(rs[2])
@test seed == rs[1].seed != rs[2].seed
end
resize!(seed, 4)
@test r.seed != seed
end
Expand Down