Skip to content

Commit

Permalink
widen integer type to Int64 for loop indices
Browse files Browse the repository at this point in the history
in order to include enough terms in the series
  • Loading branch information
Expander committed Nov 25, 2023
1 parent 61d4732 commit c8fb8a7
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions src/Li.jl
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ function li_series_unity_pos(n::Integer, z::ComplexOrReal{T}) where T

l2 = l*l

for j in (n + 3):2:typemax(n)
for j in (n + 3):2:typemax(promote_type(typeof(n), Int64))
p *= l2/((j - 1)*j)
old_sum = sum
sum += zeta(n - j, T)*p
Expand Down Expand Up @@ -279,7 +279,7 @@ function li_series_unity_neg(n::Integer, z::Complex{T})::Complex{T} where T
sum += zeta(n, T)
end

for k in kmin:2:typemax(n)
for k in kmin:2:typemax(promote_type(typeof(n), Int64))
term = zeta(n - k, T)*inv_fac(k, T)*lk
!isfinite(term) && break
sum_old = sum
Expand All @@ -299,7 +299,7 @@ function li_series_taylor(n::Integer, z::ComplexOrReal)
sum = z
zn = z*z

for k in 2:typemax(n)
for k in 2:typemax(promote_type(typeof(n), Int64))
term = zn/oftype(real(z), k)^n
!isfinite(term) && break
old_sum = sum
Expand Down
4 changes: 2 additions & 2 deletions test/Li.jl
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ end
setprecision(BigFloat, MAX_BINARY_DIGITS) do
for T in (Float16, Float32, Float64, BigFloat)
ep = ni.eps*eps(T)/eps(Float64)
for TN in (Int16, Int32, Int64, Int128)
for TN in (Int8, Int16, Int32, Int64, Int128)
(n > typemax(TN) || n < typemin(TN)) && continue
test_function_on_data(z -> PolyLog.reli(TN(n), z), map(T, real_data), ep, ep)
end
Expand All @@ -48,7 +48,7 @@ end
for T in (Float32, Float64, BigFloat)
T == BigFloat && (n < 0 || n > 2) && continue # tests take too long
ep = ni.eps*eps(T)/eps(Float64)
for TN in (Int16, Int32, Int64, Int128)
for TN in (Int8, Int16, Int32, Int64, Int128)
(n > typemax(TN) || n < typemin(TN)) && continue
test_function_on_data(z -> PolyLog.li(TN(n), z), map(Complex{T}, complex_data), ep, ep)
end
Expand Down

0 comments on commit c8fb8a7

Please sign in to comment.