-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #97 from yha/hypergeom-nan-checks
Test hypergeometric arguments for NaN values
- Loading branch information
Showing
2 changed files
with
16 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -231,6 +231,9 @@ end | |
#(c) 2013 Jiahao Chen <[email protected]> | ||
export hypergeom, hypergeom_e | ||
|
||
# NaN values not handled correctly by GSL, see GSL.jl issue #96 | ||
@inline _hypergeom_any_nan(a,b,x) = any(isnan,a) || any(isnan,b) || isnan(x) | ||
|
||
""" | ||
hypergeom(a, b, x::Float64) -> Float64 | ||
|
@@ -243,6 +246,7 @@ and length-0 `a` and/or `b` may be input as simply `[]`. | |
Supported values of ``(p, q)`` are ``(0, 0)``, ``(0, 1)``, ``(1, 1)``, ``(2, 0)`` and ``(2, 1)``. | ||
""" | ||
function hypergeom(a, b, x) | ||
_hypergeom_any_nan(a,b,x) && return NaN | ||
n = length(a), length(b) | ||
if n == (0, 0) | ||
exp(x) | ||
|
@@ -271,6 +275,7 @@ and length-0 `a` and/or `b` may be input as simply `[]`. | |
Supported values of ``(p, q)`` are ``(0, 0)``, ``(0, 1)``, ``(1, 1)``, ``(2, 0)`` and ``(2, 1)``. | ||
""" | ||
function hypergeom_e(a, b, x) | ||
_hypergeom_any_nan(a,b,x) && return gsl_sf_result(NaN, NaN) | ||
n = length(a), length(b) | ||
if n == (0, 0) | ||
sf_exp_err_e(x,0.0) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters