Skip to content

Commit 6e72ef6

Browse files
committed
remove gamma calls
1 parent a2ff7b8 commit 6e72ef6

File tree

3 files changed

+13
-5
lines changed

3 files changed

+13
-5
lines changed

src/airy.jl

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -387,7 +387,7 @@ function airy_large_arg_a(x::ComplexOrReal{T}) where T
387387
xsqr = sqrt(x)
388388

389389
out = zero(S)
390-
t = gamma(one(T) / 6) * gamma(T(5) / 6) / 4
390+
t = GAMMA_ONE_SIXTH(T) * GAMMA_FIVE_SIXTHS(T) / 4
391391
a = 4*xsqr*x
392392
for i in 0:MaxIter
393393
out += t
@@ -403,7 +403,7 @@ function airy_large_arg_b(x::ComplexOrReal{T}) where T
403403
xsqr = sqrt(x)
404404

405405
out = zero(S)
406-
t = gamma(one(T) / 6) * gamma(T(5) / 6) / 4
406+
t = GAMMA_ONE_SIXTH(T) * GAMMA_FIVE_SIXTHS(T) / 4
407407
a = 4*xsqr*x
408408
for i in 0:MaxIter
409409
out += t
@@ -419,7 +419,9 @@ function airy_large_arg_c(x::ComplexOrReal{T}) where T
419419
xsqr = sqrt(x)
420420

421421
out = zero(S)
422-
t = gamma(-one(T) / 6) * gamma(T(7) / 6) / 4
422+
# use identities of gamma to relate to defined constants
423+
# t = gamma(-one(T) / 6) * gamma(T(7) / 6) / 4
424+
t = -GAMMA_FIVE_SIXTHS(T) * GAMMA_ONE_SIXTH(T) / 4
423425
a = 4*xsqr*x
424426
for i in 0:MaxIter
425427
out += t
@@ -435,7 +437,9 @@ function airy_large_arg_d(x::ComplexOrReal{T}) where T
435437
xsqr = sqrt(x)
436438

437439
out = zero(S)
438-
t = gamma(-one(T) / 6) * gamma(T(7) / 6) / 4
440+
# use identities of gamma to relate to defined constants
441+
# t = gamma(-one(T) / 6) * gamma(T(7) / 6) / 4
442+
t = -GAMMA_FIVE_SIXTHS(T) * GAMMA_ONE_SIXTH(T) / 4
439443
a = 4*xsqr*x
440444
for i in 0:MaxIter
441445
out += t

src/gamma.jl

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,4 +66,3 @@ function small_gamma(x)
6666
q = evalpoly(x, Q)
6767
return z * p / q
6868
end
69-

src/math_constants.jl

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,5 +25,10 @@ const SQPIO2(::Type{Float32}) = 1.25331413731550025f0
2525

2626
const GAMMA_TWO_THIRDS(::Type{Float64}) = 1.3541179394264005
2727
const GAMMA_ONE_THIRD(::Type{Float64}) = 2.6789385347077475
28+
const GAMMA_ONE_SIXTH(::Type{Float64}) = 5.566316001780235
29+
const GAMMA_FIVE_SIXTHS(::Type{Float64}) = 1.128787029908126
30+
2831
const GAMMA_TWO_THIRDS(::Type{Float32}) = 1.3541179394264005f0
2932
const GAMMA_ONE_THIRD(::Type{Float32}) = 2.6789385347077475f0
33+
const GAMMA_ONE_SIXTH(::Type{Float32}) = 5.566316001780235f0
34+
const GAMMA_FIVE_SIXTHS(::Type{Float32}) = 1.128787029908126f0

0 commit comments

Comments
 (0)