From 3b7996cd14db4a07251a881123ae119d85889046 Mon Sep 17 00:00:00 2001 From: Jishnu Bhattacharya Date: Fri, 9 Jun 2023 21:01:23 +0530 Subject: [PATCH] Fix pochhammer for a vector of n --- Project.toml | 2 +- src/specialfunctions.jl | 2 +- test/specialfunctionstests.jl | 2 ++ 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/Project.toml b/Project.toml index 1611c1f7..678e3dd7 100644 --- a/Project.toml +++ b/Project.toml @@ -1,6 +1,6 @@ name = "FastTransforms" uuid = "057dd010-8810-581a-b7be-e3fc3b93f78c" -version = "0.16.2" +version = "0.16.3" [deps] AbstractFFTs = "621f4979-c628-5d54-868e-fcf4e3e8185c" diff --git a/src/specialfunctions.jl b/src/specialfunctions.jl index b5915ab7..b1f48cbb 100644 --- a/src/specialfunctions.jl +++ b/src/specialfunctions.jl @@ -48,7 +48,7 @@ end pochhammer(x::Number,n::Number) = isinteger(n) ? pochhammer(x,Int(n)) : ogamma(x)/ogamma(x+n) function pochhammer(x::Number,n::UnitRange{T}) where T<:Real - ret = Vector{promote_type(typeof(x),T)}(length(n)) + ret = Vector{promote_type(typeof(x),T)}(undef,length(n)) ret[1] = pochhammer(x,first(n)) for i=2:length(n) ret[i] = (x+n[i]-1)*ret[i-1] diff --git a/test/specialfunctionstests.jl b/test/specialfunctionstests.jl index 85a2e1f9..fca98b31 100644 --- a/test/specialfunctionstests.jl +++ b/test/specialfunctionstests.jl @@ -18,6 +18,8 @@ import FastTransforms: chebyshevmoments1, chebyshevmoments2, chebyshevjacobimome @test pochhammer(1.1,2.2) ≈ gamma(3.3)/gamma(1.1) @test pochhammer(-2,1) == pochhammer(-2,1.0) == pochhammer(-2.0,1) == -2 + @test pochhammer(2,0:5) == [pochhammer(2,i) for i in 0:5] + n = 0:1000 λ = 0.125 @test norm(Cnλ.(n, λ) ./ Cnλ.(n, big(λ)) .- 1, Inf) < 3eps()