Skip to content

Commit

Permalink
type-stabilize reli(n,x)
Browse files Browse the repository at this point in the history
  • Loading branch information
Expander committed Oct 5, 2023
1 parent 551d5c7 commit d4e7aa6
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/Eta.jl
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ const MINUS_ETA_NEG = (
)

# returns Li(n,-1) = (2^(1 - n) - 1)*zeta(n)
function neg_eta(n::Integer, T)
function neg_eta(n::Integer, ::Type{T})::T where T
if issimplefloat(T)
convert(T, neg_eta_f46(n))
else
Expand Down
4 changes: 2 additions & 2 deletions src/Factorial.jl
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ const INVERSE_FACTORIALS = (
)

# returns n! for n >= 0
function fac(n::Integer, T)
function fac(n::Integer, ::Type{T})::T where T
if issimplefloat(T)
convert(T, fac_f64(n))
else
Expand All @@ -148,7 +148,7 @@ function fac_big(n::Integer)::BigFloat
end

# returns 1/n! for n >= 0
function inv_fac(n::Integer, T)
function inv_fac(n::Integer, ::Type{T})::T where T
if issimplefloat(T)
convert(T, inv_fac_f64(n))
else
Expand Down
2 changes: 1 addition & 1 deletion src/Harmonic.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# returns n-th harmonic number, n > 0
function harmonic(n::Integer, T)
function harmonic(n::Integer, ::Type{T})::T where T
if issimplefloat(T)
convert(T, harmonic_f64(n))
else
Expand Down
6 changes: 4 additions & 2 deletions src/Li.jl
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ _reli(n::Integer, x::Float16) = oftype(x, _reli(n, Float32(x)))

_reli(n::Integer, x::Float32) = oftype(x, _reli(n, Float64(x)))

function _reli(n::Integer, x::Real)::Real
function _reli(n::Integer, x::Real)
isnan(x) && return oftype(x, NaN)
isinf(x) && return oftype(x, -Inf)
x == zero(x) && return zero(x)
Expand Down Expand Up @@ -157,7 +157,9 @@ function _li(n::Integer, z::ComplexF64)::ComplexF64
end

# returns -(-1)^n of type T
oddsgn(n, T) = isodd(n) ? one(T) : -one(T)
function oddsgn(n, ::Type{T})::T where T
isodd(n) ? one(T) : -one(T)
end

# returns r.h.s. of inversion formula for complex z:
#
Expand Down
2 changes: 1 addition & 1 deletion src/Zeta.jl
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ const ZETA_NEG = (
)

# Riemann zeta function for integer arguments
function zeta(n::Integer, T)
function zeta(n::Integer, ::Type{T})::T where T
if issimplefloat(T)
convert(T, zeta_f64(n))
else
Expand Down

0 comments on commit d4e7aa6

Please sign in to comment.