Skip to content

Commit

Permalink
Fix some 0.7 deprecations
Browse files Browse the repository at this point in the history
  • Loading branch information
ararslan committed Dec 15, 2017
1 parent 9151a95 commit 9b84b16
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 53 deletions.
56 changes: 28 additions & 28 deletions src/bessel.jl
Expand Up @@ -26,7 +26,7 @@ function Base.showerror(io::IO, ex::AmosException)
end

## Airy functions
function _airy(z::Complex128, id::Int32, kode::Int32)
function _airy(z::Complex{Float64}, id::Int32, kode::Int32)
ai1, ai2 = Ref{Float64}(), Ref{Float64}()
ae1, ae2 = Ref{Int32}(), Ref{Int32}()

Expand All @@ -43,7 +43,7 @@ function _airy(z::Complex128, id::Int32, kode::Int32)
end
end

function _biry(z::Complex128, id::Int32, kode::Int32)
function _biry(z::Complex{Float64}, id::Int32, kode::Int32)
ai1, ai2 = Ref{Float64}(), Ref{Float64}()
ae1 = Ref{Int32}()

Expand All @@ -67,31 +67,31 @@ end
Airy function of the first kind ``\\operatorname{Ai}(x)``.
"""
function airyai end
airyai(z::Complex128) = _airy(z, Int32(0), Int32(1))
airyai(z::Complex{Float64}) = _airy(z, Int32(0), Int32(1))

"""
airyaiprime(x)
Derivative of the Airy function of the first kind ``\\operatorname{Ai}'(x)``.
"""
function airyaiprime end
airyaiprime(z::Complex128) = _airy(z, Int32(1), Int32(1))
airyaiprime(z::Complex{Float64}) = _airy(z, Int32(1), Int32(1))

"""
airybi(x)
Airy function of the second kind ``\\operatorname{Bi}(x)``.
"""
function airybi end
airybi(z::Complex128) = _biry(z, Int32(0), Int32(1))
airybi(z::Complex{Float64}) = _biry(z, Int32(0), Int32(1))

"""
airybiprime(x)
Derivative of the Airy function of the second kind ``\\operatorname{Bi}'(x)``.
"""
function airybiprime end
airybiprime(z::Complex128) = _biry(z, Int32(1), Int32(1))
airybiprime(z::Complex{Float64}) = _biry(z, Int32(1), Int32(1))

"""
airyaix(x)
Expand All @@ -100,7 +100,7 @@ Scaled Airy function of the first kind ``\\operatorname{Ai}(x) e^{\\frac{2}{3} x
\\sqrt{x}}``. Throws `DomainError` for negative `Real` arguments.
"""
function airyaix end
airyaix(z::Complex128) = _airy(z, Int32(0), Int32(2))
airyaix(z::Complex{Float64}) = _airy(z, Int32(0), Int32(2))

"""
airyaiprimex(x)
Expand All @@ -109,30 +109,30 @@ Scaled derivative of the Airy function of the first kind ``\\operatorname{Ai}'(x
e^{\\frac{2}{3} x \\sqrt{x}}``. Throws `DomainError` for negative `Real` arguments.
"""
function airyaiprimex end
airyaiprimex(z::Complex128) = _airy(z, Int32(1), Int32(2))
airyaiprimex(z::Complex{Float64}) = _airy(z, Int32(1), Int32(2))

"""
airybix(x)
Scaled Airy function of the second kind ``\\operatorname{Bi}(x) e^{- \\left| \\operatorname{Re} \\left( \\frac{2}{3} x \\sqrt{x} \\right) \\right|}``.
"""
function airybix end
airybix(z::Complex128) = _biry(z, Int32(0), Int32(2))
airybix(z::Complex{Float64}) = _biry(z, Int32(0), Int32(2))

"""
airybiprimex(x)
Scaled derivative of the Airy function of the second kind ``\\operatorname{Bi}'(x) e^{- \\left| \\operatorname{Re} \\left( \\frac{2}{3} x \\sqrt{x} \\right) \\right|}``.
"""
function airybiprimex end
airybiprimex(z::Complex128) = _biry(z, Int32(1), Int32(2))
airybiprimex(z::Complex{Float64}) = _biry(z, Int32(1), Int32(2))

for afn in (:airyai, :airyaiprime, :airybi, :airybiprime,
:airyaix, :airyaiprimex, :airybix, :airybiprimex)
@eval begin
$afn(z::Complex) = $afn(float(z))
$afn(z::Complex{<:AbstractFloat}) = throw(MethodError($afn,(z,)))
$afn(z::Complex64) = Complex64($afn(Complex128(z)))
$afn(z::Complex{Float32}) = Complex{Float32}($afn(Complex{Float64}(z)))
end
if afn in (:airyaix, :airyaiprimex)
@eval $afn(x::Real) = x < 0 ? throw(DomainError(x, "`x` must be nonnegative.")) : real($afn(complex(float(x))))
Expand Down Expand Up @@ -172,7 +172,7 @@ for jy in ("j","y"), nu in (0,1)
end


function _besselh(nu::Float64, k::Int32, z::Complex128, kode::Int32)
function _besselh(nu::Float64, k::Int32, z::Complex{Float64}, kode::Int32)
ai1, ai2 = Ref{Float64}(), Ref{Float64}()
ae1, ae2 = Ref{Int32}(), Ref{Int32}()

Expand All @@ -189,7 +189,7 @@ function _besselh(nu::Float64, k::Int32, z::Complex128, kode::Int32)
end
end

function _besseli(nu::Float64, z::Complex128, kode::Int32)
function _besseli(nu::Float64, z::Complex{Float64}, kode::Int32)
ai1, ai2 = Ref{Float64}(), Ref{Float64}()
ae1, ae2 = Ref{Int32}(), Ref{Int32}()

Expand All @@ -206,7 +206,7 @@ function _besseli(nu::Float64, z::Complex128, kode::Int32)
end
end

function _besselj(nu::Float64, z::Complex128, kode::Int32)
function _besselj(nu::Float64, z::Complex{Float64}, kode::Int32)
ai1, ai2 = Ref{Float64}(), Ref{Float64}()
ae1, ae2 = Ref{Int32}(), Ref{Int32}()

Expand All @@ -223,7 +223,7 @@ function _besselj(nu::Float64, z::Complex128, kode::Int32)
end
end

function _besselk(nu::Float64, z::Complex128, kode::Int32)
function _besselk(nu::Float64, z::Complex{Float64}, kode::Int32)
ai1, ai2 = Ref{Float64}(), Ref{Float64}()
ae1, ae2 = Ref{Int32}(), Ref{Int32}()

Expand All @@ -240,7 +240,7 @@ function _besselk(nu::Float64, z::Complex128, kode::Int32)
end
end

function _bessely(nu::Float64, z::Complex128, kode::Int32)
function _bessely(nu::Float64, z::Complex{Float64}, kode::Int32)
ai1, ai2 = Ref{Float64}(), Ref{Float64}()
ae1, ae2 = Ref{Int32}(), Ref{Int32}()
wrk1, wrk2 = Ref{Float64}(), Ref{Float64}()
Expand Down Expand Up @@ -268,7 +268,7 @@ selecting [`hankelh1`](@ref) or [`hankelh2`](@ref), respectively.
"""
function besselh end

function besselh(nu::Float64, k::Integer, z::Complex128)
function besselh(nu::Float64, k::Integer, z::Complex{Float64})
if nu < 0
s = (k == 1) ? 1 : -1
return _besselh(-nu,Int32(k),z,Int32(1)) * complex(cospi(nu),-s*sinpi(nu))
Expand All @@ -291,15 +291,15 @@ exponential factor (analytically), so it avoids these problems.
"""
function besselhx end

function besselhx(nu::Float64, k::Integer, z::Complex128)
function besselhx(nu::Float64, k::Integer, z::Complex{Float64})
if nu < 0
s = (k == 1) ? 1 : -1
return _besselh(-nu,Int32(k),z,Int32(2)) * complex(cospi(nu),-s*sinpi(nu))
end
return _besselh(nu,Int32(k),z,Int32(2))
end

function besseli(nu::Float64, z::Complex128)
function besseli(nu::Float64, z::Complex{Float64})
if nu < 0
if isinteger(nu)
return _besseli(-nu,z,Int32(1))
Expand All @@ -311,7 +311,7 @@ function besseli(nu::Float64, z::Complex128)
end
end

function besselix(nu::Float64, z::Complex128)
function besselix(nu::Float64, z::Complex{Float64})
if nu < 0
if isinteger(nu)
return _besseli(-nu,z,Int32(2))
Expand All @@ -323,7 +323,7 @@ function besselix(nu::Float64, z::Complex128)
end
end

function besselj(nu::Float64, z::Complex128)
function besselj(nu::Float64, z::Complex{Float64})
if nu < 0
if isinteger(nu)
return _besselj(-nu,z,Int32(1))*cospi(nu)
Expand All @@ -339,7 +339,7 @@ besselj(nu::Cint, x::Float64) = ccall((:jn, libm), Float64, (Cint, Float64), nu,
besselj(nu::Cint, x::Float32) = ccall((:jnf, libm), Float32, (Cint, Float32), nu, x)


function besseljx(nu::Float64, z::Complex128)
function besseljx(nu::Float64, z::Complex{Float64})
if nu < 0
if isinteger(nu)
return _besselj(-nu,z,Int32(2))*cospi(nu)
Expand All @@ -351,9 +351,9 @@ function besseljx(nu::Float64, z::Complex128)
end
end

besselk(nu::Float64, z::Complex128) = _besselk(abs(nu), z, Int32(1))
besselk(nu::Float64, z::Complex{Float64}) = _besselk(abs(nu), z, Int32(1))

besselkx(nu::Float64, z::Complex128) = _besselk(abs(nu), z, Int32(2))
besselkx(nu::Float64, z::Complex{Float64}) = _besselk(abs(nu), z, Int32(2))

function bessely(nu::Cint, x::Float64)
if x < 0
Expand All @@ -368,15 +368,15 @@ function bessely(nu::Cint, x::Float32)
ccall((:ynf, libm), Float32, (Cint, Float32), nu, x)
end

function bessely(nu::Float64, z::Complex128)
function bessely(nu::Float64, z::Complex{Float64})
if nu < 0
return _bessely(-nu,z,Int32(1))*cospi(nu) - _besselj(-nu,z,Int32(1))*sinpi(nu)
else
return _bessely(nu,z,Int32(1))
end
end

function besselyx(nu::Float64, z::Complex128)
function besselyx(nu::Float64, z::Complex{Float64})
if nu < 0
return _bessely(-nu,z,Int32(2))*cospi(nu) - _besselj(-nu,z,Int32(2))*sinpi(nu)
else
Expand Down Expand Up @@ -500,7 +500,7 @@ for f in ("i", "ix", "j", "jx", "k", "kx", "y", "yx")
$bfn(Tf(nu), Complex{Tf}(z))
end
$bfn(k::T, z::Complex{T}) where {T<:AbstractFloat} = throw(MethodError($bfn,(k,z)))
$bfn(nu::Float32, x::Complex64) = Complex64($bfn(Float64(nu), Complex128(x)))
$bfn(nu::Float32, x::Complex{Float32}) = Complex{Float32}($bfn(Float64(nu), Complex{Float64}(x)))
end
end

Expand All @@ -517,7 +517,7 @@ for bfn in (:besselh, :besselhx)
end

$bfn(nu::T, k::Integer, z::Complex{T}) where {T<:AbstractFloat} = throw(MethodError($bfn,(nu,k,z)))
$bfn(nu::Float32, k::Integer, x::Complex64) = Complex64($bfn(Float64(nu), k, Complex128(x)))
$bfn(nu::Float32, k::Integer, x::Complex{Float32}) = Complex{Float32}($bfn(Float64(nu), k, Complex{Float64}(x)))
end
end

Expand Down
8 changes: 4 additions & 4 deletions src/deprecated.jl
Expand Up @@ -4,7 +4,7 @@
@deprecate airyx(z::Number) airyaix(z)
@deprecate airyprime(z::Number) airyaiprime(z)

function _airy(k::Integer, z::Complex128)
function _airy(k::Integer, z::Complex{Float64})
Base.depwarn("`airy(k,x)` is deprecated, use `airyai(x)`, `airyaiprime(x)`, `airybi(x)` or `airybiprime(x)` instead.",:airy)
id = Int32(k==1 || k==3)
if k == 0 || k == 1
Expand All @@ -15,7 +15,7 @@ function _airy(k::Integer, z::Complex128)
throw(DomainError(k, "`k` must be between 0 and 3."))
end
end
function _airyx(k::Integer, z::Complex128)
function _airyx(k::Integer, z::Complex{Float64})
Base.depwarn("`airyx(k,x)` is deprecated, use `airyaix(x)`, `airyaiprimex(x)`, `airybix(x)` or `airybiprimex(x)` instead.",:airyx)
id = Int32(k==1 || k==3)
if k == 0 || k == 1
Expand All @@ -31,7 +31,7 @@ for afn in (:airy,:airyx)
_afn = Symbol("_"*string(afn))
suf = string(afn)[5:end]
@eval begin
function $afn(k::Integer, z::Complex128)
function $afn(k::Integer, z::Complex{Float64})
afn = $(QuoteNode(afn))
suf = $(QuoteNode(suf))
Base.depwarn("`$afn(k,x)` is deprecated, use `airyai$suf(x)`, `airyaiprime$suf(x)`, `airybi$suf(x)` or `airybiprime$suf(x)` instead.",$(QuoteNode(afn)))
Expand All @@ -40,7 +40,7 @@ for afn in (:airy,:airyx)

$afn(k::Integer, z::Complex) = $afn(k, float(z))
$afn(k::Integer, z::Complex{<:AbstractFloat}) = throw(MethodError($afn,(k,z)))
$afn(k::Integer, z::Complex64) = Complex64($afn(k, Complex128(z)))
$afn(k::Integer, z::Complex{Float32}) = Complex{Float32}($afn(k, Complex{Float64}(z)))
$afn(k::Integer, x::Real) = $afn(k, float(x))
$afn(k::Integer, x::AbstractFloat) = real($afn(k, complex(x)))
end
Expand Down
8 changes: 4 additions & 4 deletions src/erf.jl
Expand Up @@ -9,7 +9,7 @@ for f in (:erf, :erfc)
($f)(x::Float32) = ccall(($(string(f,"f")),libm), Float32, (Float32,), x)
($f)(x::Real) = ($f)(float(x))
($f)(a::Float16) = Float16($f(Float32(a)))
($f)(a::Complex32) = Complex32($f(Complex64(a)))
($f)(a::Complex{Float16}) = Complex{Float16}($f(Complex{Float32}(a)))
function ($f)(x::BigFloat)
z = BigFloat()
ccall(($(string(:mpfr_,f)), :libmpfr), Int32, (Ref{BigFloat}, Ref{BigFloat}, Int32), z, x, ROUNDING_MODE[])
Expand All @@ -22,9 +22,9 @@ end
for f in (:erf, :erfc, :erfcx, :erfi, :Dawson)
fname = (f === :Dawson) ? :dawson : f
@eval begin
($fname)(z::Complex128) = Complex128(ccall(($(string("Faddeeva_",f)),openspecfun), Complex{Float64}, (Complex{Float64}, Float64), z, zero(Float64)))
($fname)(z::Complex64) = Complex64(ccall(($(string("Faddeeva_",f)),openspecfun), Complex{Float64}, (Complex{Float64}, Float64), Complex128(z), Float64(eps(Float32))))
($fname)(z::Complex) = ($fname)(Complex128(z))
($fname)(z::Complex{Float64}) = Complex{Float64}(ccall(($(string("Faddeeva_",f)),openspecfun), Complex{Float64}, (Complex{Float64}, Float64), z, zero(Float64)))
($fname)(z::Complex{Float32}) = Complex{Float32}(ccall(($(string("Faddeeva_",f)),openspecfun), Complex{Float64}, (Complex{Float64}, Float64), Complex{Float64}(z), Float64(eps(Float32))))
($fname)(z::Complex) = ($fname)(Complex{Float64}(z))
end
end

Expand Down
6 changes: 3 additions & 3 deletions src/gamma.jl
Expand Up @@ -100,13 +100,13 @@ function cotderiv_q(m::Int)
q₋ = cotderiv_q(m-1)
d = length(q₋) - 1 # degree of q₋
if isodd(m-1)
q = Array{Float64}(length(q₋))
q = Vector{Float64}(uninitialized, length(q₋))
q[end] = d * q₋[end] * 2/m
for i = 1:length(q)-1
q[i] = ((i-1)*q₋[i] + i*q₋[i+1]) * 2/m
end
else # iseven(m-1)
q = Array{Float64}(length(q₋) + 1)
q = Vector{Float64}(uninitialized, length(q₋) + 1)
q[1] = q₋[1] / m
q[end] = (1 + 2d) * q₋[end] / m
for i = 2:length(q)-1
Expand Down Expand Up @@ -486,7 +486,7 @@ end


for T in (Float16, Float32, Float64)
@eval f64(x::Complex{$T}) = Complex128(x)
@eval f64(x::Complex{$T}) = Complex{Float64}(x)
@eval f64(x::$T) = Float64(x)
end

Expand Down

0 comments on commit 9b84b16

Please sign in to comment.