Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions src/Li2.jl
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,8 @@ li2(z::Real) = li2(Complex(z))

_li2(z::ComplexF16) = oftype(z, _li2(ComplexF32(z)))

function _li2(z::Complex{T})::Complex{T} where T
# overload for complex types for which li2_approx uses pre-computed Bernoulli numbers
function _li2(z::Complex{T})::Complex{T} where {T<:Union{Float32, Float64}}
rz, iz = reim(z)

if iszero(iz)
Expand Down Expand Up @@ -270,7 +271,8 @@ function _li2(z::Complex{T})::Complex{T} where T
end
end

function _li2(z::Complex{BigFloat})::Complex{BigFloat}
# overload for generic complex types
function _li2(z::Complex{T})::Complex{T} where T
rz, iz = reim(z)

if iszero(iz)
Expand Down
14 changes: 14 additions & 0 deletions test/Dual.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
if isdefined(Base, :get_extension)
import ForwardDiff

function li_dual(n::Integer, z::Complex)
z_dual = complex(ForwardDiff.Dual(real(z)), ForwardDiff.Dual(imag(z)))
PolyLog.li(n, z_dual)
end


@testset "Dual" begin
z = 0.5 + 0.8im
@test li_dual(2, z) ≈ PolyLog.li(2, z) rtol=1e-15
end
end
1 change: 1 addition & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ include("TestPrecision.jl")
include("DataReader.jl")
include("DataTester.jl")
include("Digamma.jl")
include("Dual.jl")
include("Eta.jl")
include("Factorial.jl")
include("Harmonic.jl")
Expand Down
Loading