hankrs - Quasi-Discrete Hankel Transforms for Rust
Edward Rogers
hankrs is a Rust implementation of the quasi-discrete Hankel transform as developed by Manuel Guizar-Sicairos and Julio C. Guitierrez-Vega:
"Computation of quasi-discrete Hankel transforms of the integer order for propagating optical wave fields" Manuel Guizar-Sicairos and Julio C. Guitierrez-Vega J. Opt. Soc. Am. A 21 (1) 53-58 (2004)
It was designed for use primarily in cases where a discrete Hankel transform is required, similar to the FFT for a Fourier transform. It operates on functions stored in ndarray arrays.
I have used this code extensively (originally in Python) for beam-propagation-method calculations of radially-symmetric beams. In the radially symmetric case, the 2D FFT over x and y that would be used in a non-symmetric system is replaced by a 1D QDHT over r, making the computational load much lighter and allowing bigger simulations.
hankrs is a Rust port of my Python library, PyHank (which itself was inspired by Adam Wyatt's Matlab version). It aims to simplify the interface and utilizes the ndarray crate for array operations.
It provides both a simple single-shot interface (one_shot module), and a more advanced approach (via the HankelTransform struct) that speeds up computation significantly if making multiple transforms on the same grid.
Contributions and comments are welcome using Github at: https://github.com/etfrogers/hankrs
Installation
You can add hankrs to your Rust project via cargo:
For development and running the tests, just use standard Cargo commands:
Note for Linux/Windows Developers: When compiling tests or benchmarks, this crate links against the system's OpenBLAS library for acceleration. You must install the OpenBLAS development headers (e.g., sudo apt-get install libopenblas-dev on Ubuntu) prior to running cargo test, otherwise the build will fail to link.
Bugs & Contribution
Please use Github to report bugs, feature requests and submit your code: https://github.com/etfrogers/hankrs
Documentation
The API documentation for hankrs can be found at docs.rs, or you can build it locally with:
Comprehensive examples and mathematical background are provided in the online hankrs book.
Usage
Please refer to the online examples for extensive walkthroughs and mathematical comparisons. You can also view the tests (e.g. tests/test_transformer.rs and tests/test_one_shot.rs) for usage examples.