Skip to content

Commit 5866fe5

Browse files
authored
Fix integer evaluation (#29)
* Fix integer arguments * Update Project.toml
1 parent f4461b4 commit 5866fe5

File tree

3 files changed

+14
-10
lines changed

3 files changed

+14
-10
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name = "HypergeometricFunctions"
22
uuid = "34004b35-14d8-5ef3-9330-4cdb6864b03a"
3-
version = "0.3.2"
3+
version = "0.3.3"
44

55
[deps]
66
DualNumbers = "fa6b7ba4-c1ee-5f82-b5fc-ecf0adba8f74"

src/specialfunctions.jl

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -347,7 +347,7 @@ end
347347

348348

349349
function _₂F₁maclaurin(a::Number, b::Number, c::Number, z::Number)
350-
T = promote_type(typeof(a), typeof(b), typeof(c), typeof(z))
350+
T = float(promote_type(typeof(a), typeof(b), typeof(c), typeof(z)))
351351
S₀, S₁, j = one(T), one(T)+a*b*z/c, 1
352352
while errcheck(S₀, S₁, 10eps(real(T))) || j 1
353353
rⱼ = (a+j)/(j+1)*(b+j)/(c+j)
@@ -358,7 +358,7 @@ function _₂F₁maclaurin(a::Number, b::Number, c::Number, z::Number)
358358
end
359359

360360
function _₂F₁maclaurinalt(a::Number, b::Number, c::Number, z::Number)
361-
T = promote_type(typeof(a), typeof(b), typeof(c), typeof(z))
361+
T = float(promote_type(typeof(a), typeof(b), typeof(c), typeof(z)))
362362
C, S, j = one(T), one(T), 0
363363
while abs(C) > 10abs(S)*eps(real(T)) || j 1
364364
C *= (a+j)/(j+1)*(b+j)/(c+j)*z
@@ -369,7 +369,7 @@ function _₂F₁maclaurinalt(a::Number, b::Number, c::Number, z::Number)
369369
end
370370

371371
function _₂F₁continuation(s::Number, t::Number, c::Number, z₀::Number, z::Number)
372-
T = promote_type(typeof(s), typeof(t), typeof(c), typeof(z₀), typeof(z))
372+
T = float(promote_type(typeof(s), typeof(t), typeof(c), typeof(z₀), typeof(z)))
373373
izz₀, d0, d1 = inv(z-z₀), one(T), s/(2s-t+one(T))*((s+1)*(1-2z₀)+(t+1)*z₀-c)
374374
S₀, S₁, izz₀j, j = one(T), one(T)+d1*izz₀, izz₀, 2
375375
while errcheck(S₀, S₁, 10eps(real(T))) || j 2
@@ -381,7 +381,7 @@ function _₂F₁continuation(s::Number, t::Number, c::Number, z₀::Number, z::
381381
end
382382

383383
function _₂F₁continuationalt(a::Number, c::Number, z₀::Number, z::Number)
384-
T = promote_type(typeof(a), typeof(c), typeof(z₀), typeof(z))
384+
T = float(promote_type(typeof(a), typeof(c), typeof(z₀), typeof(z)))
385385
izz₀ = inv(z-z₀)
386386
e0, e1 = one(T), (a+one(T))*(one(T)-2z₀)+(2a+one(T))*z₀-c
387387
f0, f1 = zero(T), one(T)-2z₀
@@ -402,7 +402,7 @@ function _₂F₁continuationalt(a::Number, c::Number, z₀::Number, z::Number)
402402
end
403403

404404
function _₂F₁logsum(a::Number, b::Number, z::Number, w::Number, s::Int)
405-
T = promote_type(typeof(a), typeof(b), typeof(z), typeof(w))
405+
T = float(promote_type(typeof(a), typeof(b), typeof(z), typeof(w)))
406406
cⱼ = 2digamma(one(T))-digamma(a)-digamma(b)+s*log1p(-z)
407407
C, S, j = one(T), cⱼ, 0
408408
while abs(C) > 10abs(S)*eps(real(T)) || j 1
@@ -415,7 +415,7 @@ function _₂F₁logsum(a::Number, b::Number, z::Number, w::Number, s::Int)
415415
end
416416

417417
function _₂F₁logsumalt(a::Number, b::Number, z::Number, w::Number)
418-
T = promote_type(typeof(a), typeof(b), typeof(z), typeof(w))
418+
T = float(promote_type(typeof(a), typeof(b), typeof(z), typeof(w)))
419419
d, cⱼ = one(T)-b, 2digamma(one(T))-digamma(a)-digamma(b)-log(-w)
420420
C, S, j = one(T), cⱼ, 0
421421
while abs(C) > 10abs(S)*eps(real(T)) || j 1
@@ -428,7 +428,7 @@ function _₂F₁logsumalt(a::Number, b::Number, z::Number, w::Number)
428428
end
429429

430430
function _₂F₁taylor(a::Number, b::Number, c::Number, z::Number)
431-
T = promote_type(typeof(a), typeof(b), typeof(c), typeof(z))
431+
T = float(promote_type(typeof(a), typeof(b), typeof(c), typeof(z)))
432432
z₀ = abs(z) < 1 ? ρϵ*sign(z) : sign(z)/ρϵ
433433
q₀, q₁ = _₂F₁(a, b, c, z₀), a*b/c*_₂F₁(a+1, b+1, c+1, z₀)
434434
S₀, zz₀ = q₀, z-z₀
@@ -443,7 +443,7 @@ function _₂F₁taylor(a::Number, b::Number, c::Number, z::Number)
443443
end
444444

445445
function _₃F₂maclaurin(a₁, a₂, a₃, b₁, b₂, z)
446-
T = promote_type(typeof(a₁), typeof(a₂), typeof(a₃), typeof(b₁), typeof(b₂), typeof(z))
446+
T = float(promote_type(typeof(a₁), typeof(a₂), typeof(a₃), typeof(b₁), typeof(b₂), typeof(z)))
447447
S₀, S₁, j = one(T), one(T)+(a₁*a₂*a₃*z)/(b₁*b₂), 1
448448
while errcheck(S₀, S₁, 10eps(real(T))) || j 1
449449
rⱼ = ((a₁+j)*(a₂+j)*(a₃+j))/((b₁+j)*(b₂+j)*(j+1))
@@ -454,7 +454,7 @@ function _₃F₂maclaurin(a₁, a₂, a₃, b₁, b₂, z)
454454
end
455455

456456
function pFqmaclaurin(a::AbstractVector{S}, b::AbstractVector{U}, z::V) where {S, U, V}
457-
T = promote_type(S, U, V)
457+
T = float(promote_type(S, U, V))
458458
S₀, S₁, j = one(T), one(T)+prod(a)*z/prod(b), 1
459459
while errcheck(S₀, S₁, 10eps(real(T))) || j 1
460460
rⱼ = inv(j+one(T))

test/runtests.jl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -424,4 +424,8 @@ end
424424
@test pFqweniger(S[α, β], S[γ], z) CS(pFq(T[α, β], T[γ], CT(z))) atol=atol rtol=rtol
425425
end
426426
end
427+
428+
@testset "Integer arguments" begin
429+
@test _₂F₁(1, 0, 3, -1) _₂F₁(1.0, 0, 3, -1) 1.0
430+
end
427431
end

0 commit comments

Comments
 (0)