Skip to content

Commit a3bfb4c

Browse files
committed
Fix NaN propagation for x and check domain when x<0.
1 parent 1b21871 commit a3bfb4c

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

src/modifiedsphericalbessel.jl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,11 @@ Computes `k_{ν}(x)`, the modified second-kind spherical Bessel function, and of
77
sphericalbesselk(nu, x) = _sphericalbesselk(nu, float(x))
88

99
function _sphericalbesselk(nu, x::T) where T
10+
isnan(x) && return NaN
1011
if isinteger(nu) && nu < 41.5
12+
if x < zero(x)
13+
return throw(DomainError(x, "Complex result returned for real arguments. Complex arguments are currently not supported"))
14+
end
1115
# using ifelse here to hopefully cut out a branch on nu < 0 or not. The
1216
# symmetry here is that
1317
# k_{-n} = (...)*K_{-n + 1/2}

0 commit comments

Comments
 (0)