@@ -308,7 +308,7 @@ let a = [rand(RandomDevice(), UInt128) for i=1:10]
308
308
end
309
309
310
310
# test all rand APIs
311
- for rng in ([], [MersenneTwister (0 )], [RandomDevice ()])
311
+ for rng in ([], [MersenneTwister (0 )], [RandomDevice ()], [ Xoshiro ()] )
312
312
ftypes = [Float16, Float32, Float64]
313
313
cftypes = [ComplexF16, ComplexF32, ComplexF64, ftypes... ]
314
314
types = [Bool, Char, BigFloat, Base. BitInteger_types... , ftypes... ]
@@ -433,7 +433,7 @@ function hist(X, n)
433
433
end
434
434
435
435
# test uniform distribution of floats
436
- for rng in [MersenneTwister (), RandomDevice ()],
436
+ for rng in [MersenneTwister (), RandomDevice (), Xoshiro () ],
437
437
T in [Float16, Float32, Float64, BigFloat],
438
438
prec in (T == BigFloat ? [3 , 53 , 64 , 100 , 256 , 1000 ] : [256 ])
439
439
setprecision (BigFloat, prec) do
454
454
# but also for 3 linear combinations of positions (for the array version)
455
455
lcs = unique! .([rand (1 : n, 2 ), rand (1 : n, 3 ), rand (1 : n, 5 )])
456
456
aslcs = zeros (Int, 3 )
457
- for rng = (MersenneTwister (), RandomDevice ())
457
+ for rng = (MersenneTwister (), RandomDevice (), Xoshiro () )
458
458
for scalar = [false , true ]
459
459
fill! (a, 0 )
460
460
fill! (as, 0 )
478
478
end
479
479
end
480
480
481
- # test reproducility of methods
482
- let mta = MersenneTwister (42 ), mtb = MersenneTwister (42 )
481
+ @testset " reproducility of methods for $RNG " for RNG = (MersenneTwister,Xoshiro)
482
+ mta, mtb = RNG (42 ), RNG (42 )
483
483
484
484
@test rand (mta) == rand (mtb)
485
485
@test rand (mta,10 ) == rand (mtb,10 )
664
664
# this shouldn't crash (#22403)
665
665
@test_throws ArgumentError rand! (Union{UInt,Int}[1 , 2 , 3 ])
666
666
667
- @testset " $RNG () & Random.seed!(rng::$RNG ) initializes randomly" for RNG in (MersenneTwister, RandomDevice)
667
+ @testset " $RNG () & Random.seed!(rng::$RNG ) initializes randomly" for RNG in (MersenneTwister, RandomDevice, Xoshiro )
668
668
m = RNG ()
669
669
a = rand (m, Int)
670
670
m = RNG ()
@@ -685,11 +685,17 @@ end
685
685
@test rand (m, Int) ∉ (a, b, c, d)
686
686
end
687
687
688
- @testset " MersenneTwister($seed ) & Random.seed!(m::MersenneTwister, $seed ) produce the same stream" for seed in [0 : 5 ; 10000 : 10005 ]
689
- m = MersenneTwister (seed)
690
- a = [rand (m) for _= 1 : 100 ]
691
- Random. seed! (m, seed)
692
- @test a == [rand (m) for _= 1 : 100 ]
688
+ @testset " $RNG (seed) & Random.seed!(m::$RNG , seed) produce the same stream" for RNG= (MersenneTwister,Xoshiro)
689
+ seeds = Any[0 , 1 , 2 , 10000 , 10001 , rand (UInt32, 8 ), rand (UInt128, 3 )... ]
690
+ if RNG == Xoshiro
691
+ push! (seeds, rand (UInt64, rand (1 : 4 )), Tuple (rand (UInt64, 4 )))
692
+ end
693
+ for seed= seeds
694
+ m = RNG (seed)
695
+ a = [rand (m) for _= 1 : 100 ]
696
+ Random. seed! (m, seed)
697
+ @test a == [rand (m) for _= 1 : 100 ]
698
+ end
693
699
end
694
700
695
701
struct RandomStruct23964 end
@@ -698,7 +704,7 @@ struct RandomStruct23964 end
698
704
@test_throws ArgumentError rand (RandomStruct23964 ())
699
705
end
700
706
701
- @testset " rand(::$(typeof (RNG)) , ::UnitRange{$T }" for RNG ∈ (MersenneTwister (rand (UInt128)), RandomDevice ()),
707
+ @testset " rand(::$(typeof (RNG)) , ::UnitRange{$T }" for RNG ∈ (MersenneTwister (rand (UInt128)), RandomDevice (), Xoshiro () ),
702
708
T ∈ (Int8, Int16, Int32, UInt32, Int64, Int128, UInt128)
703
709
for S in (SamplerRangeInt, SamplerRangeFast, SamplerRangeNDL)
704
710
S == SamplerRangeNDL && sizeof (T) > 8 && continue
0 commit comments