JuliaMath / SpecialFunctions.jl

Special mathematical functions in Julia

Home Page:https://specialfunctions.juliamath.org/stable/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

gamma_inc doesn't handle NaNs

andreasnoack opened this issue · comments

They currently cause infinite loops. E.g.

gamma_inc(NaN, 0.3)

hangs in

while true
l += 1.0
c *= -x/l
t = c/(a + l)
sm += t
if abs(t) <= tol
break
end
end
. I think that Morris' old fortran code just didn't handle NaNs at all. Should we just propagate the NaNs or should we throw in the same way as we do for other illegal input such as in
if a < 0.0 || x < 0.0
throw(DomainError((a, x, ind), "`a` and `x` must be greater than 0 ---- Domain : (0, Inf)"))
elseif a == 0.0 && x == 0.0
throw(DomainError((a, x, ind), "`a` and `x` must be greater than 0 ---- Domain : (0, Inf)"))