Skip to content

Commit 94714f6

Browse files
authored
expint: add another condition for gamma CF use (#275)
* Add another condition for gamma CF * Test
1 parent 48f22a7 commit 94714f6

File tree

2 files changed

+10
-7
lines changed

2 files changed

+10
-7
lines changed

src/expint.jl

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -249,14 +249,15 @@ end
249249
# En_cf_nogamma and En_cf_gamma
250250
# returns (evaluated result, # iterations used, whether En_cf_gamma was chosen)
251251
function En_cf::Number, z::Number, niter::Int=1000)
252-
gammapart, cfpart, iters = En_cf_gamma(ν, z, niter)
253-
gammaabs, cfabs = abs(gammapart), abs(cfpart)
254-
if gammaabs != Inf && gammaabs > 1.0 && gammaabs > cfabs
255-
# significant gamma part, use this
256-
return gammapart + cfpart, iters, true
257-
else
258-
return En_cf_nogamma(ν, z, niter)..., false
252+
if real(1-ν) > 0
253+
gammapart, cfpart, iters = En_cf_gamma(ν, z, niter)
254+
gammaabs, cfabs = abs(gammapart), abs(cfpart)
255+
if gammaabs != Inf && gammaabs > 1.0 && gammaabs > cfabs
256+
# significant gamma part, use this
257+
return gammapart + cfpart, iters, true
258+
end
259259
end
260+
return En_cf_nogamma(ν, z, niter)..., false
260261
end
261262

262263
# Compute expint(ν, z₀+Δ) given start = expint(ν, z₀), as described by [Amos 1980].

test/expint.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,8 @@ using Base.MathConstants
7575
@test expint(-2, 3.3) isa Real
7676
@test expint(-2, -3.3) -4.745485121488663825992363318400378114254141655964565963
7777
@test expint(-2, -3.3) isa Real
78+
@test expint(2.2, 3.3) 0.0071305694486185747267607978483436184475047798769491326205
79+
@test expint(1.2, 3.3) 0.0085837830493629441737850749465161073231031009810293477318
7880

7981
@test expint(-2.1+3im, 4.2 +0im) 0.003387565626497080536855067510744646235748203589175196673362104 - 0.003355838600814825542988272289126728631565803782052141768321840im
8082
@test expint(-4.3, -10+0.0im) -1505.2167858114105916067190408869152177781925766866637213104 + 0.00015439438628349460776476190593323691084185406009267711345841im

0 commit comments

Comments
 (0)