File tree Expand file tree Collapse file tree 3 files changed +51
-0
lines changed Expand file tree Collapse file tree 3 files changed +51
-0
lines changed Original file line number Diff line number Diff line change @@ -218,6 +218,11 @@ DEVICE double GammaP (double n, double x)
218
218
{ /* --- regularized Gamma function P */
219
219
if ((n <= 0 ) || (x < 0 )) return NPY_NAN ; /* check the function arguments */
220
220
if (x <= 0 ) return 0 ; /* treat x = 0 as a special case */
221
+ if (isinf (n )) {
222
+ if (isinf (x )) return NPY_NAN ;
223
+ return 0 ;
224
+ }
225
+ if (isinf (x )) return 1 ;
221
226
if (x < n + 1 ) return _series (n , x ) * exp (n * log (x ) - x - logGamma (n ));
222
227
return 1 - _cfrac (n , x ) * exp (n * log (x ) - x - logGamma (n ));
223
228
} /* GammaP() */
@@ -228,6 +233,11 @@ DEVICE double GammaQ (double n, double x)
228
233
{ /* --- regularized Gamma function Q */
229
234
if ((n <= 0 ) || (x < 0 )) return NPY_NAN ; /* check the function arguments */
230
235
if (x <= 0 ) return 1 ; /* treat x = 0 as a special case */
236
+ if (isinf (n )) {
237
+ if (isinf (x )) return NPY_NAN ;
238
+ return 1 ;
239
+ }
240
+ if (isinf (x )) return 0 ;
231
241
if (x < n + 1 ) return 1 - _series (n , x ) * exp (n * log (x ) - x - logGamma (n ));
232
242
return _cfrac (n , x ) * exp (n * log (x ) - x - logGamma (n ));
233
243
} /* GammaQ() */
Original file line number Diff line number Diff line change @@ -631,6 +631,13 @@ def __eq__(self, other):
631
631
def __hash__ (self ):
632
632
return hash (type (self ))
633
633
634
+ def c_code_cache_version (self ):
635
+ v = super ().c_code_cache_version ()
636
+ if v :
637
+ return (2 , * v )
638
+ else :
639
+ return v
640
+
634
641
635
642
chi2sf = Chi2SF (upgrade_to_float64 , name = "chi2sf" )
636
643
@@ -677,6 +684,13 @@ def __eq__(self, other):
677
684
def __hash__ (self ):
678
685
return hash (type (self ))
679
686
687
+ def c_code_cache_version (self ):
688
+ v = super ().c_code_cache_version ()
689
+ if v :
690
+ return (2 , * v )
691
+ else :
692
+ return v
693
+
680
694
681
695
gammainc = GammaInc (upgrade_to_float , name = "gammainc" )
682
696
@@ -723,6 +737,13 @@ def __eq__(self, other):
723
737
def __hash__ (self ):
724
738
return hash (type (self ))
725
739
740
+ def c_code_cache_version (self ):
741
+ v = super ().c_code_cache_version ()
742
+ if v :
743
+ return (2 , * v )
744
+ else :
745
+ return v
746
+
726
747
727
748
gammaincc = GammaIncC (upgrade_to_float , name = "gammaincc" )
728
749
Original file line number Diff line number Diff line change @@ -41,6 +41,16 @@ def test_gammainc_nan_c():
41
41
assert np .isnan (test_func (- 1 , - 1 ))
42
42
43
43
44
+ def test_gammainc_inf_c ():
45
+ x1 = pt .dscalar ()
46
+ x2 = pt .dscalar ()
47
+ y = gammainc (x1 , x2 )
48
+ test_func = make_function (CLinker ().accept (FunctionGraph ([x1 , x2 ], [y ])))
49
+ assert np .isclose (test_func (np .inf , 1 ), sp .gammainc (np .inf , 1 ))
50
+ assert np .isclose (test_func (1 , np .inf ), sp .gammainc (1 , np .inf ))
51
+ assert np .isnan (test_func (np .inf , np .inf ))
52
+
53
+
44
54
def test_gammaincc_python ():
45
55
x1 = pt .dscalar ()
46
56
x2 = pt .dscalar ()
@@ -59,6 +69,16 @@ def test_gammaincc_nan_c():
59
69
assert np .isnan (test_func (- 1 , - 1 ))
60
70
61
71
72
+ def test_gammaincc_inf_c ():
73
+ x1 = pt .dscalar ()
74
+ x2 = pt .dscalar ()
75
+ y = gammaincc (x1 , x2 )
76
+ test_func = make_function (CLinker ().accept (FunctionGraph ([x1 , x2 ], [y ])))
77
+ assert np .isclose (test_func (np .inf , 1 ), sp .gammaincc (np .inf , 1 ))
78
+ assert np .isclose (test_func (1 , np .inf ), sp .gammaincc (1 , np .inf ))
79
+ assert np .isnan (test_func (np .inf , np .inf ))
80
+
81
+
62
82
def test_gammal_nan_c ():
63
83
x1 = pt .dscalar ()
64
84
x2 = pt .dscalar ()
You can’t perform that action at this time.
0 commit comments