A collection of methods to compute overlap integrals for modal scattering matrices. Essentially this involves solving the following integral

\[K_{abnm} = \iint^{\infty}_{-\infty} U_{nm}(x,y,q_i) M(x,y) U^*_{ab}(x,y,q_o) \, dy \, dx \]

\(U_nm\) is the initial modes in the basis \(q_i\) we are converting from and \(U_ab\) are the target modes in a basis \(q_o\) we are projecting into.


Should explore if decomposing compute_map_knm_matrix_riemann_optimised into real and imaginary integrals might be faster. In cases where q_in == q_out then integrals are real, apart from the map component which can be complex.

Explore use of zgemm3m which is 25% faster than zgemm

Probably look into using CUDA if necessary for more speed.


composite_newton_cotes_weights(N, order)

Constructs the weights for a composite Newton-Cotes rule for integration along 1-dimensional line with equally spaced steps.


Calculates a mode scattering matrix using a Riemann sum.

map_coupling_matrix_riemann(double complex[, ...)

outer_conj_product(double complex[, , ...)

Computes U * U^C and returns the output into the result array.

outer_conj_product_2(double complex[, , ...)

Computes U1 * U2**C and returns the output into the result array.