Skip to content

Commit 1146ac5

Browse files
committed
add rand! for non containers
1 parent 3b1baa1 commit 1146ac5

1 file changed

Lines changed: 9 additions & 0 deletions

File tree

src/RandomExtensions.jl

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,15 @@ val_gentype(X) = gentype(X)
3333
val_gentype(::Type{X}) where {X} = X
3434

3535

36+
## rand! for non-containers
37+
38+
rand!(y, X) = rand!(GLOBAL_RNG, y, X)
39+
rand!(y, ::Type{X}) where {X} = rand!(GLOBAL_RNG, y, X)
40+
41+
rand!(rng::AbstractRNG, y, X) = rand!(rng, y, Sampler(rng, X, Val(1)))
42+
rand!(rng::AbstractRNG, y, ::Type{X}) where {X} = rand!(rng, y, Sampler(rng, X, Val(1)))
43+
44+
3645
## includes
3746

3847
include("distributions.jl")

0 commit comments

Comments
 (0)