Potatoasad / KerrQuasinormalModes.jl

A Package to Compute mode functions for Kerr Black Hole Quasinormal modes, as well as their frequencies, seperation constants and more. Additionally provides an interface for cheap differentiation of such modes.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Using generated functions for computing the spin weighted spheroidal harmonics

Potatoasad opened this issue · comments

At the moment there is this large and clanky method for precomputing the factorial expressions inside the SpinWeightedSphericalHarmonic functions.

I used Mathematica to precompute expressions for spin weighted spherical harmonics:
s = -2 to +2 , l = 0 to 20 , m = all

They are all saved in a csv, and then a huge ~500 expression if-else statement is constructed.

This goes into the body of the SpinWeightedSphericalHarmonicCalculation function.

I want to look into the possibility of having a @generated function unroll all the loops and pre-compute the relevant binomial expressions at compile time.

So we will have some expression like:

@generated function::SpinWeightedSpheroidal{s,l,m})()
    # function body that generates the needed expression
end

This would imply that we would make SpinWeightedSpheroidal a parametric type with s,l,m as parameters as well.

Why is this needed?

Derivatives of a Spin Weighted Spheroidal Harmonic ψₛ our expansion can be written as a sum over ψₛ₊₁ and ψₛ₋₁ , and so if we only pre-compute uptil s=2, and take it's first derivative or second derivative (which we often may have to do), we would be using unoptimized code which will spend more time computing binomial expressions of s,l and m than anything else.