Skip to content

Commit

Permalink
Remove custom jinc and replace it with SpecialFunctions.jinc (#77)
Browse files Browse the repository at this point in the history
* Remove custom jinc and replace it with SpecialFunctions.jinc

* Remove jinc file

* Revert "Remove jinc file"

This reverts commit 322429d.

* Revert "Remove custom jinc and replace it with SpecialFunctions.jinc"

This reverts commit f3b0e0f.

* Revert to old convention but call SpecialFunctions

* Update comment

---------

Co-authored-by: Jeff Fessler <[email protected]>
  • Loading branch information
roflmaostc and JeffFessler authored Feb 3, 2023
1 parent 2399ad5 commit 3ce70f6
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions src/jinc.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ jinc.jl

export jinc

using SpecialFunctions: besselj1
import SpecialFunctions


"""
Expand All @@ -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

0 comments on commit 3ce70f6

Please sign in to comment.