Simple Example
In this example (as in the One-Shot Example) we will check the band limit of a jinc function: \(f(r) = \frac{J_1(r)}{r}\). The (0 order) Hankel transform of this should be the top hat function.
Here we create a HankelTransform object and use its qdht method.
In this simple case, the simpler, single shot functions used in the One-Shot Example may be simpler to use. It should be noted, however, that they are not well suited for multiple transforms on the same grid and the approach taken here is recommended.
Here is the source code:
mod helper; use amos_bessel_rs::bessel_j; use hankrs::HankelTransform; use ndarray::Axis; use crate::helper::plot_1d; fn main() -> Result<(), Box<dyn std::error::Error>> { // Create a HankelTransform object which holds the grid for r and kr points. let transformer = HankelTransform::new(0, 100.0, 1024).unwrap(); let radius = transformer.radius(); // Note that although the calculation fails at r = 0, transformer.radius() does not include r=0. let f = radius.mapv(|rad| bessel_j(1.0, rad).unwrap() / rad); plot_1d( "simple_example_f.png", &radius, &f, "Jinc Function", "Radius /m", "Amplitude", 0.0..100.0, -0.2..0.6, )?; // Now take the Hankel transform using transformer.qdht let ht = transformer.qdht(&f, Axis(0)); // As expected, this is a top-hat function bandlimited to k<1, except for numerical error. plot_1d( "simple_example_ht.png", &transformer.kr(), &ht, "Hankel Transform", "Radial wavevector /m^-1", "Amplitude", 0.0..5.0, -0.2..1.2, )?; Ok(()) }
Original Function:

Hankel Transform (QDHT):
