Cython performance tweaks
Hey, this is a cool project :)
I was looking through your Cython code, there's a couple of minor mistakes that are probably hurting the performance.
The math.acos(qz/qrr)
is doing a check for 0 in Python, you'll likely want to put a @cython.cdivision
decorator.
Secondly, your array qfactor
(and similar) can be declared as cdef double[::1] qfactor
which is telling cython that the memory is C-contiguous. This makes slicing it inside the inner loop faster.
If you do cython -a sfactor.pyx
it produces an annotated html that shows the C code that will get compiled which is handy for seeing this stuff.