Skip to content

Commit

Permalink
fix besselk f16
Browse files Browse the repository at this point in the history
  • Loading branch information
heltonmc committed Aug 11, 2022
1 parent c095ae2 commit df2db0c
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/besselk.jl
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,11 @@ end
Scaled modified Bessel function of the second kind of order nu, ``K_{nu}(x)*e^{x}``.
"""
function besselkx(nu, x::T) where T <: Union{Float32, Float64}
besselkx(nu::Real, x::Real) = _besselkx(nu, float(x))

_besselkx(nu, x::Float16) = Float16(_besselkx(nu, Float32(x)))

function _besselkx(nu, x::T) where T <: Union{Float32, Float64}
# dispatch to avoid uniform expansion when nu = 0
iszero(nu) && return besselk0x(x)

Expand Down
1 change: 1 addition & 0 deletions test/besseli_test.jl
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ t = [besseli(m, x) for m in m, x in x]
t = [besselix(m, x) for m in m, x in x]
@test t[10] isa Float64
@test t [SpecialFunctions.besselix(m, x) for m in m, x in x]
@test besselix(10, Float16(1.0)) isa Float16

## Tests for besselk

Expand Down
1 change: 1 addition & 0 deletions test/besselk_test.jl
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ end

# test Float16
@test besselk(10, Float16(1.0)) isa Float16
@test besselkx(10, Float16(1.0)) isa Float16

# test Inf
@test iszero(besselk(2, Inf))
Expand Down

0 comments on commit df2db0c

Please sign in to comment.