MothNik / robust_fourier

Noise- and Outlier-Robust Fourier Transform with Hermite Functions with NumPy and Numba
MIT License
1 stars 0 forks source link

[ENHANCEMENT] Make Hermite polynomials and functions logic Numba `jit`-able #2

Closed MothNik closed 4 months ago

MothNik commented 4 months ago

Right now, the recursive implementation of the Hermite polynomials relies on a Python for-loop and is thus probably not as efficient as possible. Since the Hermite functions rely on the Hermite polynomials, they will also benefit from such an enhancement.

The only 2 parts of the implementations that are not jit-able right out of the box are the points where

are called.

However, the first should be pretty straightforward (if complex dtypes are left aside for now) by re-implementing the logic according to the source of logsumexp,

For the second one, the float64-argument support of gammaln is not required in the contexts encountered here because only the factorials of integer orders are evaluated. For those, the natural logarithm of their factorial is

LogIntegerFactorial

which should pose no problem for a Numba-compatible implementation as well.

MothNik commented 4 months ago

Marked this as rendered irrelevant after looking at this publication. Changing to Numba is not the best way to go in the current state of the algorithm because the recursive algorithm itself is the problem and can apparently be significantly improved with respect to speed.

I will still merge the branch for this issue, but immediately start working on implementing the algorithm from the publication.

MothNik commented 4 months ago

Sorry, my mistake. The recursion is still required. All good 😅 However, the overflow/underflow situation can probably be avoided a bit more efficiently by using the logarithms in a smarter fashion, so I will focus on that for now.