Skip to content

Commit b174fcf

Browse files
authored
Doublefloats and hypergeometric functions (#92)
* doublefloats and lower incomplete gamma function * conversion of doublefloats to arbfloat and arbreal
1 parent 87864dd commit b174fcf

File tree

5 files changed

+68
-8
lines changed

5 files changed

+68
-8
lines changed

Project.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ Readables = "0d4725de-cd7c-5e44-8a85-a48caeef9fa5"
1717
GMP_jll = "781609d7-10c4-51f6-84f2-b8444358ff6d"
1818
MPFR_jll = "3a97d323-0669-5f0c-9066-3539efd106a3"
1919
FLINT_jll = "e134572f-a0d5-539d-bddf-3cad8db41a82"
20+
DoubleFloats = "497a8b3b-efae-58df-a0af-a86822472b78"
2021

2122
[compat]
2223
FLINT_jll = "301.300 - 304.700"

src/ArbNumerics.jl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ export ArbNumber,
6262
hypergeometric_0F1, hypergeometric_1F1, hypergeometric_2F1,
6363
regular_hypergeometric_0F1, regular_hypergeometric_1F1, regular_hypergeometric_2F1,
6464
F₀₁, F₁₁, F₂₁, regularF₀₁, regularF₁₁, regularF₂₁,
65+
hypergeometric_U, hypergeometric_gamma_lower, regular_hypergeometric_gamma_lower, further_regular_hypergeometric_gamma_lower,
6566
elliptic_k, elliptic_e, elliptic_pi, elliptic_f,
6667
elliptic_k2, elliptic_e2, elliptic_pi2, elliptic_f2, # modulus^2
6768
elliptic_rf, elliptic_rg, elliptic_rj,
@@ -127,6 +128,8 @@ import SpecialFunctions: gamma, lgamma, lfact, digamma, invdigamma, polygamma, t
127128
besselj, besselj0, besselj1, bessely, bessely0, bessely1, besseli, besselk,
128129
eta, zeta
129130

131+
import DoubleFloats: DoubleFloat
132+
130133
using FLINT_jll
131134

132135
macro libarb(function_name)

src/float/hypergeometric.jl

Lines changed: 59 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -169,25 +169,76 @@ function regular_hypergeometric_2F1(a::ArbReal{P}, b::ArbReal{P}, c::ArbReal{P},
169169
return result
170170
end
171171

172+
"""
173+
hypergeometric_gamma_lower(s, z)
174+
175+
lower incomplete gamma function, ``small_gamma(s, z) = (z^s / s) * ₁F₁(s, s+1, -z)``
176+
"""
177+
function hypergeometric_gamma_lower(s::ArbReal{P}, z::ArbReal{P}) where {P}
178+
result = ArbReal{P}()
179+
regularized = Cint(0)
180+
ccall(@libarb(arb_hypgeom_gamma_lower), Cvoid, (Ref{ArbReal}, Ref{ArbReal}, Ref{ArbReal}, Cint, Clong),
181+
result, s, z, regularized, P)
182+
return result
183+
end
184+
185+
"""
186+
regular_hypergeometric_gamma_lower(s, z)
187+
188+
regularized lower incomplete gamma function, ``P(s, z) = small_gamma(s, z) / gamma(s)``
189+
"""
190+
function regular_hypergeometric_gamma_lower(s::ArbReal{P}, z::ArbReal{P}) where {P}
191+
result = ArbReal{P}()
192+
regularized = Cint(1)
193+
ccall(@libarb(arb_hypgeom_gamma_lower), Cvoid, (Ref{ArbReal}, Ref{ArbReal}, Ref{ArbReal}, Cint, Clong),
194+
result, s, z, regularized, P)
195+
return result
196+
end
197+
198+
"""
199+
further_regular_hypergeometric_gamma_lower(s, z)
200+
201+
'further' regularized lower incomplete gamma function, ``small_gamma_star(s, z) = z^-s * P(s, z)``
202+
"""
203+
function further_regular_hypergeometric_gamma_lower(s::ArbReal{P}, z::ArbReal{P}) where {P}
204+
result = ArbReal{P}()
205+
regularized = Cint(2)
206+
ccall(@libarb(arb_hypgeom_gamma_lower), Cvoid, (Ref{ArbReal}, Ref{ArbReal}, Ref{ArbReal}, Cint, Clong),
207+
result, s, z, regularized, P)
208+
return result
209+
end
210+
211+
212+
213+
172214
# ArbFloat
173215

174216
hypergeometric_0F1(a::ArbFloat{P}, z::ArbFloat{P}) where {P} =
175-
ArbFloat{P}(hypgeom0f1(ArbReal{P}(a), ArbReal{P}(z)))
217+
ArbFloat{P}(hypergeometric_0F1(ArbReal{P}(a), ArbReal{P}(z)))
176218

177219
hypergeometric_0F1_regularized(a::ArbFloat{P}, z::ArbFloat{P}) where {P} =
178-
ArbFloat{P}(hypgeom0f1reg(ArbReal{P}(a), ArbReal{P}(z)))
220+
ArbFloat{P}(hypergeometric_0F1_regularized(ArbReal{P}(a), ArbReal{P}(z)))
179221

180-
hypergeometric_U(a::ArbFloat{P}, z::ArbFloat{P}) where {P} =
181-
ArbFloat{P}(hypgeomu(ArbReal{P}(a), ArbReal{P}(z)))
222+
hypergeometric_U(a::ArbFloat{P}, b::ArbFloat{P}, z::ArbFloat{P}) where {P} =
223+
ArbFloat{P}(hypergeometric_U(ArbReal{P}(a), ArbReal{P}(b), ArbReal{P}(z)))
182224

183225
hypergeometric_1F1(a::ArbFloat{P}, b::ArbFloat{P}, z::ArbFloat{P}) where {P} =
184-
ArbFloat{P}(hypgeom1f1(ArbReal{P}(a), ArbReal{P}(b), ArbReal{P}(z)))
226+
ArbFloat{P}(hypergeometric_1F1(ArbReal{P}(a), ArbReal{P}(b), ArbReal{P}(z)))
185227

186228
hypergeometric_1F1_regularized(a::ArbFloat{P}, b::ArbFloat{P}, z::ArbFloat{P}) where {P} =
187-
ArbFloat{P}(hypgeom1f1reg(ArbReal{P}(a), ArbReal{P}(b), ArbReal{P}(z)))
229+
ArbFloat{P}(hypergeometric_1F1_regularized(ArbReal{P}(a), ArbReal{P}(b), ArbReal{P}(z)))
188230

189231
hypergeometric_1F2(a::ArbFloat{P}, b::ArbFloat{P}, c::ArbFloat{P}, z::ArbFloat{P}) where {P} =
190-
ArbFloat{P}(hypgeom1f2(ArbReal{P}(a), ArbReal{P}(b), ArbReal{P}(c), ArbReal{P}(z)))
232+
ArbFloat{P}(hypergeometric_1F2(ArbReal{P}(a), ArbReal{P}(b), ArbReal{P}(c), ArbReal{P}(z)))
191233

192234
hypergeometric_1F2_regularized(a::ArbFloat{P}, b::ArbFloat{P}, c::ArbFloat{P}, z::ArbFloat{P}) where {P} =
193-
ArbFloat{P}(hypgeom1f2reg(ArbReal{P}(a), ArbReal{P}(b), ArbReal{P}(c), ArbReal{P}(z)))
235+
ArbFloat{P}(hypergeometric_1F2_regularized(ArbReal{P}(a), ArbReal{P}(b), ArbReal{P}(c), ArbReal{P}(z)))
236+
237+
hypergeometric_gamma_lower(s::ArbFloat{P}, z::ArbFloat{P}) where {P} =
238+
ArbFloat{P}(hypergeometric_gamma_lower(ArbReal{P}(s), ArbReal{P}(z)))
239+
240+
regular_hypergeometric_gamma_lower(s::ArbFloat{P}, z::ArbFloat{P}) where {P} =
241+
ArbFloat{P}(hypergeometric_gamma_lower(ArbReal{P}(s), ArbReal{P}(z)))
242+
243+
further_regular_hypergeometric_gamma_lower(s::ArbFloat{P}, z::ArbFloat{P}) where {P} =
244+
ArbFloat{P}(further_hypergeometric_gamma_lower(ArbReal{P}(s), ArbReal{P}(z)))

src/libarb/ArbFloat.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,8 @@ end
107107

108108
ArbFloat{P}(x::T) where {P,T<:Integer} = ArbFloat{P}(BigFloat(x, precision=P + 2))
109109

110+
ArbFloat{P}(x::DoubleFloat{T}) where {P,T<:IEEEFloat} = ArbFloat{P}(x.hi) + ArbFloat{P}(x.lo)
111+
110112
function ArbFloat{P}(x::Base.IEEEFloat) where {P}
111113
z = ArbFloat{P}()
112114
ccall(@libarb(arf_set_d), Cvoid, (Ref{ArbFloat}, Cdouble), z, x)

src/libarb/ArbReal.jl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,9 @@ function ArbReal{P}(x::USlong) where {P}
6060
end
6161
ArbReal{P}(x::T) where {P, T<:Integer} = ArbReal{P}(BigFloat(x, precision=P + 2))
6262

63+
ArbReal{P}(x::DoubleFloat{T}) where {P,T<:IEEEFloat} = ArbReal{P}(x.hi) + ArbReal{P}(x.lo)
64+
65+
6366
function ArbReal{P}(x::Base.IEEEFloat) where {P}
6467
z = ArbReal{P}()
6568
ccall(@libarb(arb_set_d), Cvoid, (Ref{ArbReal}, Cdouble), z, x)

0 commit comments

Comments
 (0)