From 160306cf8edcded7c40dfe87e79ba5190c352723 Mon Sep 17 00:00:00 2001 From: Chris Geoga <{ID}+{username}@users.noreply.github.com> Date: Sat, 8 Aug 2020 14:11:49 -0400 Subject: [PATCH 1/4] Change fallback unsafe_gamma for x::Real to x<:AbstractFloat. Add fallback for generic argument to default gamma function. --- src/specialfunctions.jl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/specialfunctions.jl b/src/specialfunctions.jl index c9aa02e..40b7984 100644 --- a/src/specialfunctions.jl +++ b/src/specialfunctions.jl @@ -141,7 +141,7 @@ const libm = Base.libm_name unsafe_gamma(x::Float64) = ccall((:tgamma, libm), Float64, (Float64, ), x) unsafe_gamma(x::Float32) = ccall((:tgammaf, libm), Float32, (Float32, ), x) -unsafe_gamma(x::Real) = unsafe_gamma(float(x)) +unsafe_gamma(x::T) where{T<:AbstractFloat} = unsafe_gamma(float(x)) function unsafe_gamma(x::BigFloat) z = BigFloat() ccall((:mpfr_gamma, :libmpfr), Int32, (Ref{BigFloat}, Ref{BigFloat}, Int32), z, x, Base.MPFR.ROUNDING_MODE[]) @@ -149,7 +149,7 @@ function unsafe_gamma(x::BigFloat) end unsafe_gamma(z::Complex) = gamma(z) unsafe_gamma(z::Dual) = (r = realpart(z);w = unsafe_gamma(r); dual(w, w*digamma(r)*dualpart(z))) - +unsafe_gamma(z) = gamma(z) """ @lanczosratio(z, ϵ, c₀, c...) From dcbbca71ec56789809c50f9487f65a85a15d1b6f Mon Sep 17 00:00:00 2001 From: Chris Geoga <{ID}+{username}@users.noreply.github.com> Date: Sat, 8 Aug 2020 22:06:11 -0400 Subject: [PATCH 2/4] Remove unnecessary float conversion. --- src/specialfunctions.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/specialfunctions.jl b/src/specialfunctions.jl index 40b7984..32bf62d 100644 --- a/src/specialfunctions.jl +++ b/src/specialfunctions.jl @@ -141,7 +141,7 @@ const libm = Base.libm_name unsafe_gamma(x::Float64) = ccall((:tgamma, libm), Float64, (Float64, ), x) unsafe_gamma(x::Float32) = ccall((:tgammaf, libm), Float32, (Float32, ), x) -unsafe_gamma(x::T) where{T<:AbstractFloat} = unsafe_gamma(float(x)) +unsafe_gamma(x::T) where{T<:AbstractFloat} = unsafe_gamma(x) function unsafe_gamma(x::BigFloat) z = BigFloat() ccall((:mpfr_gamma, :libmpfr), Int32, (Ref{BigFloat}, Ref{BigFloat}, Int32), z, x, Base.MPFR.ROUNDING_MODE[]) From 4dae254c41f55cd444855a38acfcbcc04e270982 Mon Sep 17 00:00:00 2001 From: Chris Geoga <{ID}+{username}@users.noreply.github.com> Date: Sun, 9 Aug 2020 10:37:47 -0400 Subject: [PATCH 3/4] Final cleanup to unsafe_gamma. Bump version. --- Project.toml | 2 +- src/specialfunctions.jl | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/Project.toml b/Project.toml index 3556fb3..818efad 100644 --- a/Project.toml +++ b/Project.toml @@ -1,6 +1,6 @@ name = "HypergeometricFunctions" uuid = "34004b35-14d8-5ef3-9330-4cdb6864b03a" -version = "0.3.1" +version = "0.3.2" [deps] DualNumbers = "fa6b7ba4-c1ee-5f82-b5fc-ecf0adba8f74" diff --git a/src/specialfunctions.jl b/src/specialfunctions.jl index 32bf62d..17433c6 100644 --- a/src/specialfunctions.jl +++ b/src/specialfunctions.jl @@ -141,13 +141,12 @@ const libm = Base.libm_name unsafe_gamma(x::Float64) = ccall((:tgamma, libm), Float64, (Float64, ), x) unsafe_gamma(x::Float32) = ccall((:tgammaf, libm), Float32, (Float32, ), x) -unsafe_gamma(x::T) where{T<:AbstractFloat} = unsafe_gamma(x) +#unsafe_gamma(x::T) where{T<:AbstractFloat} = unsafe_gamma(x) function unsafe_gamma(x::BigFloat) z = BigFloat() ccall((:mpfr_gamma, :libmpfr), Int32, (Ref{BigFloat}, Ref{BigFloat}, Int32), z, x, Base.MPFR.ROUNDING_MODE[]) return z end -unsafe_gamma(z::Complex) = gamma(z) unsafe_gamma(z::Dual) = (r = realpart(z);w = unsafe_gamma(r); dual(w, w*digamma(r)*dualpart(z))) unsafe_gamma(z) = gamma(z) """ From 94561710fa7417bdf6e9be24b1e4fa40c04e69ad Mon Sep 17 00:00:00 2001 From: Chris Geoga <{ID}+{username}@users.noreply.github.com> Date: Sun, 9 Aug 2020 10:57:37 -0400 Subject: [PATCH 4/4] Remove commented line. Sorry for hasty push earlier. --- src/specialfunctions.jl | 1 - 1 file changed, 1 deletion(-) diff --git a/src/specialfunctions.jl b/src/specialfunctions.jl index 17433c6..b94f083 100644 --- a/src/specialfunctions.jl +++ b/src/specialfunctions.jl @@ -141,7 +141,6 @@ const libm = Base.libm_name unsafe_gamma(x::Float64) = ccall((:tgamma, libm), Float64, (Float64, ), x) unsafe_gamma(x::Float32) = ccall((:tgammaf, libm), Float32, (Float32, ), x) -#unsafe_gamma(x::T) where{T<:AbstractFloat} = unsafe_gamma(x) function unsafe_gamma(x::BigFloat) z = BigFloat() ccall((:mpfr_gamma, :libmpfr), Int32, (Ref{BigFloat}, Ref{BigFloat}, Int32), z, x, Base.MPFR.ROUNDING_MODE[])