Closed MothNik closed 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.
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.
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 wherescipy.special.logsumexp
andscipy.special.gammaln
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 oflogsumexp
,For the second one, the
float64
-argument support ofgammaln
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 iswhich should pose no problem for a Numba-compatible implementation as well.