Skip to content

Commit

Permalink
add few comments
Browse files Browse the repository at this point in the history
  • Loading branch information
rfourquet committed Nov 19, 2017
1 parent 4d770b3 commit 3050f01
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 1 deletion.
2 changes: 1 addition & 1 deletion base/random/RNGs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

## RandomDevice

# SamplerTypes(Union{X,Y,...}) = Union{SamplerType{X},SamplerType{Y},...}
# SamplerTypes(Union{X,Y,...}) == Union{SamplerType{X},SamplerType{Y},...}
SamplerTypes(U::Union) = Union{map(T->SamplerType{T}, Base.uniontypes(U))...}
const SamplerBoolBitInteger = SamplerTypes(Union{Bool, Base.BitInteger})

Expand Down
11 changes: 11 additions & 0 deletions base/random/generation.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,17 @@

# Uniform random generation

# This file contains the creation of Sampler objects and the associated generation of
# random values from them. More specifically, given the specification S of a set
# of values to pick from (e.g. 1:10, or "a string"), we define
#
# 1) Sampler(rng, S, ::Repetition) -> sampler
# 2) rand(rng, sampler) -> random value
#
# Note that the 1) is automated when when the sampler is not intended to carry information,
# i.e. the default fall-backs SamplerType and SamplerTrivial are used.


## from types: rand(::Type, [dims...])

### random floats
Expand Down
4 changes: 4 additions & 0 deletions base/random/random.jl
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,10 @@ Base.getindex(st::SamplerSimple) = st.self

### machinery for generation with Sampler

# This describes how to generate random scalars or arrays, by generating a Sampler
# and calling rand on it (which should be defined in "generation.jl").
# NOTE: this section could be moved into a separate file when more containers are supported.

#### scalars

rand(rng::AbstractRNG, X) = rand(rng, Sampler(rng, X, Val(1)))
Expand Down

0 comments on commit 3050f01

Please sign in to comment.