Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/VML.jl
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ function vml_check_error()
vml_error = ccall((:_vmlClearErrStatus, lib), Cint, ())
if vml_error != 0
if vml_error == 1
error(DomainError())
throw(DomainError())
elseif vml_error == 2 || vml_error == 3 || vml_error == 4
# Singularity, overflow, or underflow
# I don't think Base throws on these
Expand Down
8 changes: 4 additions & 4 deletions test/common.jl
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,8 @@ const base_binary_complex = (
)

function randindomain{T<:Real}(t::Type{T}, n, domain)
d1 = oftype(t, domain[1])
d2 = oftype(t, domain[2])
d1 = convert(t, domain[1])
d2 = convert(t, domain[2])
ddiff = d2 - d1
@assert isfinite(ddiff)
v = rand(t, n)
Expand All @@ -79,8 +79,8 @@ function randindomain{T<:Real}(t::Type{T}, n, domain)
end

function randindomain{T<:Complex}(t::Type{T}, n, domain)
d1 = oftype(t, domain[1])
d2 = oftype(t, domain[2])
d1 = convert(t, domain[1])
d2 = convert(t, domain[2])
ddiff = d2 - d1
@assert isfinite(ddiff)
v = rand(t, 2*n)
Expand Down
16 changes: 16 additions & 0 deletions test/complex.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# First generate some random data and test functions in Base on it
const NVALS = 1000
input = Dict(t=>[[(randindomain(t, NVALS, domain),) for (fn, domain) in base_unary_complex];
[(randindomain(t, NVALS, domain1), randindomain(t, NVALS, domain2))
for (fn, domain1, domain2) in base_binary_complex];
(randindomain(t, NVALS, (0, 100)), randindomain(t, 1, (-2, 10))[1])]
for t in (Complex64, Complex128))
fns = [[x[1] for x in base_unary_complex]; [x[1] for x in base_binary_complex]; .^]
output = Dict(t=>[fns[i](input[t][i]...) for i = 1:length(fns)] for t in (Complex64, Complex128))

# Now test the same data with VML
using VML
for t in (Complex64, Complex128), i = 1:length(fns)
fn = fns[i]
Base.Test.test_approx_eq(output[t][i], fn(input[t][i]...), "Base $t $fn", "VML $t $fn")
end
25 changes: 25 additions & 0 deletions test/real.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# First generate some random data and test functions in Base on it
const NVALS = 1000
input = Dict(t=>[[(randindomain(t, NVALS, domain),) for (fn, domain) in base_unary_real];
[(randindomain(t, NVALS, domain1), randindomain(t, NVALS, domain2))
for (fn, domain1, domain2) in base_binary_real];
(randindomain(t, NVALS, (0, 100)), randindomain(t, 1, (-5, 20))[1])]
for t in (Float32, Float64))
fns = [[x[1] for x in base_unary_real]; [x[1] for x in base_binary_real]; .^]
output = Dict(t=>[fns[i](input[t][i]...) for i = 1:length(fns)] for t in (Float32, Float64))

# Now test the same data with VML
using VML
for t in (Float32, Float64), i = 1:length(fns)
fn = fns[i]
Base.Test.test_approx_eq(output[t][i], fn(input[t][i]...), "Base $t $fn", "VML $t $fn")
end

# Verify that we still throw DomainErrors
Base.Test.@test_throws DomainError sqrt([-1.0])

# Setting accuracy
vml_set_accuracy(VML_LA)
@assert vml_get_accuracy() == VML_LA
vml_set_accuracy(VML_EP)
@assert vml_get_accuracy() == VML_EP
4 changes: 3 additions & 1 deletion test/runtests.jl
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
include("common.jl")
include("common.jl")
include("real.jl")
include("complex.jl")