Skip to content

Commit

Permalink
use zeta from mpfr
Browse files Browse the repository at this point in the history
  • Loading branch information
Expander committed Sep 28, 2023
1 parent 0fcc4da commit 2faed3e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 16 deletions.
6 changes: 5 additions & 1 deletion src/Eta.jl
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ function neg_eta(n::Integer, T=Float64)
if T == Float64
neg_eta_f46(n)
else
(exp2(1 - n) - one(T))*zeta(n, T)
neg_eta_big(n)
end
end

Expand All @@ -88,3 +88,7 @@ function neg_eta_f46(n::Integer)::Float64
-1.0
end
end

function neg_eta_big(n::Integer)::BigFloat
(exp2(1 - n) - one(T))*zeta(n, T)
end
19 changes: 4 additions & 15 deletions src/Zeta.jl
Original file line number Diff line number Diff line change
Expand Up @@ -92,19 +92,8 @@ function zeta_f64(n::Integer)::Float64
end

function zeta_big(n::Integer)::BigFloat
if n < 0
throw(DomainError(n, "zeta(n, T=$(T)) not implemented for n < 0"))
elseif n == 0
BigFloat("-0.5")
elseif n == 1
BigFloat("Inf")
else
sum = one(T)
for i in 2:typemax(n)
old_sum = sum
sum += (-1)^(i+1)*convert(T, i)^(-n)
sum == old_sum && break
end
sum/(one(T) - exp2(1 - n))
end
x = BigFloat(n)
z = BigFloat()
ccall((:mpfr_zeta, :libmpfr), Int32, (Ref{BigFloat}, Ref{BigFloat}, Int32), z, x, ROUNDING_MODE[])
return z
end

0 comments on commit 2faed3e

Please sign in to comment.