|
1 | | -VERSION < v"0.7.0-beta2.199" && __precompile__() |
2 | | - |
3 | 1 | module Sobol |
4 | | -using Compat, Compat.Random |
5 | | -export SobolSeq, ScaledSobolSeq, next!, next |
6 | | -@static if isdefined(Base, :next) |
7 | | - import Base: next |
8 | | -end |
| 2 | +using Random |
| 3 | +export SobolSeq, ScaledSobolSeq, next! |
9 | 4 |
|
10 | 5 | include("soboldata.jl") #loads `sobol_a` and `sobol_minit` |
11 | 6 |
|
@@ -81,8 +76,6 @@ function next!(s::SobolSeq, x::AbstractVector{<:AbstractFloat}) |
81 | 76 | end |
82 | 77 | next!(s::SobolSeq) = next!(s, Array{Float64,1}(undef, ndims(s))) |
83 | 78 |
|
84 | | -@deprecate next(s::AbstractSobolSeq) next!(s) |
85 | | - |
86 | 79 | # if we know in advance how many points (n) we want to compute, then |
87 | 80 | # adopt the suggestion of the Joe and Kuo paper, which in turn |
88 | 81 | # is taken from Acworth et al (1998), of skipping a number of |
|
105 | 98 | # Technically, the Sobol sequence ends after 2^32-1 points, but it |
106 | 99 | # falls back on pseudorandom numbers after this. In practice, one is |
107 | 100 | # unlikely to reach that point. |
108 | | -@static if isdefined(Base, :iterate) |
109 | | - Base.iterate(s::AbstractSobolSeq, state=nothing) = (next!(s), state) |
110 | | -else |
111 | | - Base.start(s::AbstractSobolSeq) = nothing |
112 | | - Base.next(s::AbstractSobolSeq, state) = (next!(s), state) |
113 | | - Base.done(s::AbstractSobolSeq, state) = false |
114 | | -end |
| 101 | +Base.iterate(s::AbstractSobolSeq, state=nothing) = (next!(s), state) |
115 | 102 | Base.eltype(::Type{<:AbstractSobolSeq}) = Vector{Float64} |
116 | | -Compat.IteratorSize(::Type{<:AbstractSobolSeq}) = Base.IsInfinite() |
117 | | -Compat.IteratorEltype(::Type{<:AbstractSobolSeq}) = Base.HasEltype() |
| 103 | +Base.IteratorSize(::Type{<:AbstractSobolSeq}) = Base.IsInfinite() |
| 104 | +Base.IteratorEltype(::Type{<:AbstractSobolSeq}) = Base.HasEltype() |
118 | 105 |
|
119 | 106 | # Convenience wrapper for scaled Sobol sequences |
120 | 107 |
|
@@ -144,7 +131,6 @@ next!(s::SobolSeq{N}, lb::AbstractVector, ub::AbstractVector) where {N} = next!( |
144 | 131 |
|
145 | 132 | next!(s::ScaledSobolSeq, x::AbstractVector{<:AbstractFloat}) = next!(s.s, x, s.lb, s.ub) |
146 | 133 | next!(s::ScaledSobolSeq) = next!(s.s, Array{Float64,1}(undef, ndims(s)), s.lb, s.ub) |
147 | | -next(s::ScaledSobolSeq) = next!(s, Vector{Float64}(undef, ndims(s))) |
148 | 134 |
|
149 | 135 | Base.skip(s::ScaledSobolSeq, n) = skip(s.s, n) |
150 | 136 |
|
|
0 commit comments