Skip to content

Commit

Permalink
Add polygamma function (#60)
Browse files Browse the repository at this point in the history
* Fix parameter bug in polylog

* Reorder function definitions for consistency

* Add polygamma

* Adjust parameter naming convention

* Export polygamma
  • Loading branch information
alexfreudenberg committed Jul 23, 2023
1 parent 2cd87dd commit 3ae7f58
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 36 deletions.
2 changes: 1 addition & 1 deletion src/ArbNumerics.jl
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ export ArbNumber,
elliptic_rf, elliptic_rg, elliptic_rj,
weierstrass_p, weierstrass_p_prime, weierstrass_p_jet, weierstrass_invariants, weierstrass_roots, weierstrass_p_series, weierstrass_inv_p, weierstrass_zeta, weierstrass_sigma,
zeta, eta, xi, # Reimann
lambertw, polylog,
lambertw, polylog, polygamma,
π, ℯ, γ, φ, catalan,

# fft
Expand Down
94 changes: 59 additions & 35 deletions src/float/otherspecial.jl
Original file line number Diff line number Diff line change
Expand Up @@ -86,43 +86,8 @@ for (A,F) in ((:agm, :arb_agm), )
end
end

function polylog(s::ArbComplex{P}, z::ArbComplex{P}, prec::Int=P) where {P}
w = ArbComplex{P}()
ccall(@libarb(acb_polylog), Cvoid, (Ref{ArbComplex}, Ref{ArbComplex}, Ref{ArbComplex}, Cint), w, s, z, P)
return w
end

function polylog(s::ArbReal{P}, z::ArbReal{P}, prec::Int=P) where {P}
sc = ArbComplex(s)
zc = ArbComplex(z)
wc = polylog(sc, zc, prec)
return wc
end

function polylog(s::ArbFloat{P}, z::ArbFloat{P}, prec::Int=P) where {P}
sc = ArbComplex(s)
zc = ArbComplex(z)
wc = polylog(sc, zc, prec)
return wc
end

function polylog(s::Int, z::ArbComplex{P}, prec::Int=P) where {P}
w = ArbComplex{P}()
ccall(@libarb(acb_polylog_si), Cvoid, (Ref{ArbComplex}, Cint, Ref{ArbComplex}, Cint), w, s, z, P)
return w
end

function polylog(s::Int, z::ArbReal{P}, prec::Int=P) where {P}
zc = ArbComplex(z)
wc = polylog(s, zc, prec)
return wc
end

function polylog(s::Int, z::ArbFloat{P}, prec::Int=P) where {P}
zc = ArbComplex(z)
wc = polylog(s, zc, prec)
return wc
end

#=
for (A,F) in ((:ellipticp, :acb_elliptic_p), (:ellipticpi, :acb_elliptic_pi),
Expand Down Expand Up @@ -213,6 +178,65 @@ function agm(x::ArbFloat{P}, y::ArbFloat{P}) where {P}
end


function polylog(s::ArbComplex{P}, z::ArbComplex{P}, prec::Int=P) where {P}
w = ArbComplex{P}()
ccall(@libarb(acb_polylog), Cvoid, (Ref{ArbComplex}, Ref{ArbComplex}, Ref{ArbComplex}, Cint), w, s, z, prec)
return w
end

function polylog(s::ArbReal{P}, z::ArbReal{P}, prec::Int=P) where {P}
sc = ArbComplex(s)
zc = ArbComplex(z)
wc = polylog(sc, zc, prec)
return wc
end

function polylog(s::ArbFloat{P}, z::ArbFloat{P}, prec::Int=P) where {P}
sc = ArbComplex(s)
zc = ArbComplex(z)
wc = polylog(sc, zc, prec)
return wc
end

function polylog(s::Int, z::ArbComplex{P}, prec::Int=P) where {P}
w = ArbComplex{P}()
ccall(@libarb(acb_polylog_si), Cvoid, (Ref{ArbComplex}, Cint, Ref{ArbComplex}, Cint), w, s, z, prec)
return w
end

function polylog(s::Int, z::ArbReal{P}, prec::Int=P) where {P}
zc = ArbComplex(z)
wc = polylog(s, zc, prec)
return wc
end

function polylog(s::Int, z::ArbFloat{P}, prec::Int=P) where {P}
zc = ArbComplex(z)
wc = polylog(s, zc, prec)
return wc
end

function polygamma(s::ArbComplex{P}, z::ArbComplex{P}, prec::Int=P) where {P}
res = ArbComplex{P}()
ccall(@libarb(acb_polygamma), Cvoid, (Ref{ArbComplex}, Ref{ArbComplex}, Ref{ArbComplex}, Cint), res, s, z, prec)
return res
end

function polygamma(s::ArbReal{P}, z::ArbReal{P}, prec::Int=P) where {P}
sc = ArbComplex(s)
zc = ArbComplex(z)
res = polygamma(sc, zc, prec)
return res
end

function polygamma(s::ArbFloat{P}, z::ArbFloat{P}, prec::Int=P) where {P}
sc = ArbComplex(s)
zc = ArbComplex(z)
res = polygamma(sc, zc, prec)
return res
end


#=
function erfcx(z::ArbComplex{P}) where {P}
hiprec = round(Int, P*1.25)
Expand Down

0 comments on commit 3ae7f58

Please sign in to comment.