Skip to content

Commit c1f7012

Browse files
authored
Merge branch 'master' into dw/notimplemented
2 parents d059919 + feccbf4 commit c1f7012

File tree

9 files changed

+515
-396
lines changed

9 files changed

+515
-396
lines changed

Project.toml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
11
name = "SpecialFunctions"
22
uuid = "276daf66-3868-5448-9aa4-cd146d93841b"
3-
version = "1.3.1"
3+
version = "1.4.0"
44

55
[deps]
66
ChainRulesCore = "d360d2e6-b24c-11e9-a2a3-2a2ae2dbcce4"
7+
LogExpFunctions = "2ab3a3ac-af41-5b50-aa03-7779005ae688"
78
OpenSpecFun_jll = "efe28fd5-8261-553b-a9e1-b2916fc3738e"
89

910
[compat]
1011
ChainRulesCore = "0.9.40"
1112
ChainRulesTestUtils = "0.6.8"
13+
LogExpFunctions = "0.2"
1214
OpenSpecFun_jll = "0.5"
1315
julia = "1.3"
1416

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ Most of these functions were formerly part of Base in early versions of Julia.
77
CI (Linux, macOS, FreeBSD, Windows):
88
[![Travis](https://travis-ci.org/JuliaMath/SpecialFunctions.jl.svg?branch=master)](https://travis-ci.org/JuliaMath/SpecialFunctions.jl)
99
[![CI](https://github.com/JuliaMath/SpecialFunctions.jl/workflows/CI/badge.svg)](https://github.com/JuliaMath/SpecialFunctions.jl/actions?query=workflow%3ACI)
10-
[![Coveralls](https://coveralls.io/repos/github/JuliaMath/SpecialFunctions.jl/badge.svg?branch=master)](https://coveralls.io/github/JuliaMath/SpecialFunctions.jl?branch=master)
10+
[![codecov](https://codecov.io/gh/JuliaMath/SpecialFunctions.jl/branch/master/graph/badge.svg?token=qIKzX2I5ZK)](https://codecov.io/gh/JuliaMath/SpecialFunctions.jl)
1111

1212
Documentation:
1313
[![Documentation](https://img.shields.io/badge/docs-stable-blue.svg)](https://JuliaMath.github.io/SpecialFunctions.jl/stable)

src/SpecialFunctions.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
module SpecialFunctions
22

33
import ChainRulesCore
4+
import LogExpFunctions
45

56
using OpenSpecFun_jll
67

src/beta_inc.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -109,9 +109,9 @@ function beta_integrand(a::Float64,b::Float64,x::Float64,y::Float64,mu::Float64=
109109
lambda = a - (a+b)*x
110110
end
111111
e = -lambda/a
112-
u = abs(e) > 0.6 ? u = e - log(x/x0) : - log1pmx(e)
112+
u = abs(e) > 0.6 ? e - log(x/x0) : - LogExpFunctions.log1pmx(e)
113113
e = lambda/b
114-
v = abs(e) > 0.6 ? e - log(y/y0) : - log1pmx(e)
114+
v = abs(e) > 0.6 ? e - log(y/y0) : - LogExpFunctions.log1pmx(e)
115115
z = esum(mu, -(a*u + b*v))
116116
return (1.0/sqrt(2*pi))*sqrt(b*x0)*z*exp(-stirling_corr(a,b))
117117
elseif x > 0.375
@@ -271,7 +271,7 @@ function beta_inc_asymptotic_symmetric(a::Float64, b::Float64, lambda::Float64,
271271
r1 = (b-a)/b
272272
w0 = 1.0/sqrt(a*(1.0+h))
273273
end
274-
f = -a*log1pmx(-(lambda/a)) - b*log1pmx((lambda/b))
274+
f = -a*LogExpFunctions.log1pmx(-(lambda/a)) - b*LogExpFunctions.log1pmx(lambda/b)
275275
t = exp(-f)
276276
if t == 0.0
277277
return ans

src/expint.jl

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -214,17 +214,19 @@ function En_cf_gamma(ν::Number, z::Number, n::Int=1000)
214214
ϵ = 10*eps(real(B))
215215
scale = sqrt(floatmax(real(A)))
216216

217-
iters = 1
218-
j = 1
219-
for i = 2:n
217+
iters = 0
218+
for i = 1:n
220219
iters += 1
221220

222-
term = iseven(i) ? -(i÷2 - 1 - ν)*z : z*(i÷2)
223-
A, Aprev = (i - ν)*A + term * Aprev, A
224-
B, Bprev = (i - ν)*B + term * Bprev, B
221+
a = iseven(i) ? (i÷2)*z : -((i + 1)÷2 - ν)*z
222+
b = (i + 1 - ν)
223+
224+
A, Aprev = b*A + a*Aprev, A
225+
B, Bprev = b*B + a*Bprev, B
225226

226-
conv = abs(Aprev*B - A*Bprev) < ϵ*abs(B*Bprev)
227-
conv && break
227+
if abs(Aprev*B - A*Bprev) < ϵ*abs(Aprev*B)
228+
break
229+
end
228230

229231
if max(abs(real(A)), abs(imag(A))) > scale
230232
A /= scale
@@ -436,6 +438,7 @@ function _expint(ν::Number, z::Number, niter::Int=1000, ::Val{expscaled}=Val{fa
436438
else
437439
g, cf, _ = zero(z), En_cf_nogamma(ν, z, niter)...
438440
end
441+
439442
g != 0 && (g *= gmult)
440443
cf = expscaled ? cf : En_safeexpmult(-z, cf)
441444
return g + cf

0 commit comments

Comments
 (0)