Skip to content

Commit b16387f

Browse files
authored
Don't convert BigFloats to Float64 (#120)
Fix #119.
1 parent e33062f commit b16387f

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

src/erf.jl

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,9 @@ for f in (:erf, :erfc, :erfcx, :erfi, :Dawson)
2424
@eval begin
2525
($fname)(z::Complex{Float64}) = Complex{Float64}(ccall(($(string("Faddeeva_",f)),openspecfun), Complex{Float64}, (Complex{Float64}, Float64), z, zero(Float64)))
2626
($fname)(z::Complex{Float32}) = Complex{Float32}(ccall(($(string("Faddeeva_",f)),openspecfun), Complex{Float64}, (Complex{Float64}, Float64), Complex{Float64}(z), Float64(eps(Float32))))
27-
($fname)(z::Complex) = ($fname)(Complex{Float64}(z))
27+
28+
($fname)(z::Complex) = ($fname)(float(z))
29+
($fname)(z::Complex{<:AbstractFloat}) = throw(MethodError($fname,(z,)))
2830
end
2931
end
3032

@@ -33,7 +35,9 @@ for f in (:erfcx, :erfi, :Dawson)
3335
@eval begin
3436
($fname)(x::Float64) = ccall(($(string("Faddeeva_",f,"_re")),openspecfun), Float64, (Float64,), x)
3537
($fname)(x::Float32) = Float32(ccall(($(string("Faddeeva_",f,"_re")),openspecfun), Float64, (Float64,), Float64(x)))
36-
($fname)(x::Integer) = ($fname)(float(x))
38+
39+
($fname)(x::Real) = ($fname)(float(x))
40+
($fname)(x::AbstractFloat) = throw(MethodError($fname,(x,)))
3741
end
3842
end
3943

test/runtests.jl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,9 @@ relerrc(z, x) = max(relerr(real(z),real(x)), relerr(imag(z),imag(x)))
6262
@test SF.erfcx(1.8) SF.erfcx(big(1.8)) rtol=4*eps()
6363
@test SF.erfcx(1.8e8) SF.erfcx(big(1.8e8)) rtol=4*eps()
6464
@test SF.erfcx(1.8e88) SF.erfcx(big(1.8e88)) rtol=4*eps()
65+
66+
@test_throws MethodError erf(big(1.0)*im)
67+
@test_throws MethodError erfi(big(1.0))
6568
end
6669

6770
@testset "sine and cosine integrals" begin

0 commit comments

Comments
 (0)