From 3ce70f63fc1d1d9b9d2d149e65d8ed8c32fbe693 Mon Sep 17 00:00:00 2001 From: "Felix Wechsler (he/him)" Date: Fri, 3 Feb 2023 16:51:24 +0100 Subject: [PATCH] Remove custom jinc and replace it with SpecialFunctions.jinc (#77) * Remove custom jinc and replace it with SpecialFunctions.jinc * Remove jinc file * Revert "Remove jinc file" This reverts commit 322429dc7f52e05a4318b7f777280e5d14bdbc7c. * Revert "Remove custom jinc and replace it with SpecialFunctions.jinc" This reverts commit f3b0e0f1e946fbb179510007f70deff013fcbc35. * Revert to old convention but call SpecialFunctions * Update comment --------- Co-authored-by: Jeff Fessler --- src/jinc.jl | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/jinc.jl b/src/jinc.jl index d0cf6ea..f90c5d8 100644 --- a/src/jinc.jl +++ b/src/jinc.jl @@ -4,7 +4,7 @@ jinc.jl export jinc -using SpecialFunctions: besselj1 +import SpecialFunctions """ @@ -15,11 +15,10 @@ where `J1` is a Bessel function of the first kind. The argument `x` must be unitless. -Return type is `promote_type(typeof(x), Float32)`. +!!! note + `SpecialFunctions.jinc(0) = 1` whereas the convention here is `jinc(0) = π / 4` + which corresponds to the area of a disk of unit diameter. """ function jinc(x::X) where {X <: Real} - T = promote_type(X, Float32) - if (x == 0) return convert(T, π/4) end - y = abs(x) - convert(T, besselj1(π*y) / (2*y)) + X(π) / 4 * SpecialFunctions.jinc(x) end