Skip to content

Commit

Permalink
Merge pull request #13 from GregPlowman/master
Browse files Browse the repository at this point in the history
pointer_to_array deprecated to unsafe_wrap
  • Loading branch information
andreasnoack authored Jun 29, 2018
2 parents bf085aa + 5dbadd5 commit b1e2429
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/RNGTest.jl
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ module RNGTest
end
cache = Vector{T}(cache_size)
fillcache(WrappedRNG{T, RNG}(rng, cache, fillarray,
pointer_to_array(convert(Ptr{UInt32}, pointer(cache)), sizeof(cache)÷sizeof(UInt32)),
unsafe_wrap(Array, convert(Ptr{UInt32}, pointer(cache)), sizeof(cache)÷sizeof(UInt32)),
0)) # 0 is a dummy value, which will be set correctly by fillcache
end

Expand Down Expand Up @@ -105,7 +105,7 @@ module RNGTest

# RNGGenerator struct
mutable struct Unif01
ptr::Ptr{Array{Int32}}
ptr::Ptr{Void}
gentype::Type
name::String
function Unif01(f::Function, genname)
Expand All @@ -120,14 +120,14 @@ module RNGTest
return b
end

function Unif01{T<:AbstractFloat}(g::WrappedRNG{T}, genname)
function Unif01(g::WrappedRNG{T}, genname) where {T<:AbstractFloat}
# we assume that g being created out of an AbstractRNG, it produces Floats in the interval [0,1)
@eval f() = ($g)() :: Float64
cf = cfunction(f, Float64, ())
return new(ccall((:unif01_CreateExternGen01, libtestu01), Ptr{Void}, (Ptr{UInt8}, Ptr{Void}), genname, cf), Float64)
end

function Unif01{T<:Integer}(g::WrappedRNG{T}, genname)
function Unif01(g::WrappedRNG{T}, genname) where {T<:Integer}
@assert Cuint === UInt32
@eval f() = ($g)() :: UInt32
cf = cfunction(f, UInt32, ())
Expand Down
3 changes: 3 additions & 0 deletions test/tests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -50,3 +50,6 @@ print("Test: ")
print("RandomWalk: ")
@test all(hcat(RNGTest.swalk_RandomWalk1(f, 1, 1000000, 0, 30, 150, 150)...) .> pval)
println("OK")

rng = RNGTest.wrap(MersenneTwister(0), UInt32)
RNGTest.smallcrushTestU01(rng)

0 comments on commit b1e2429

Please sign in to comment.