diff --git a/qpms/groups.h b/qpms/groups.h index 34f2c44..6b05332 100644 --- a/qpms/groups.h +++ b/qpms/groups.h @@ -25,6 +25,7 @@ #define QPMS_GROUPS_H #include "qpms_types.h" +#include /// To be used only in qpms_finite_group_t struct qpms_finite_group_irrep_t { diff --git a/qpms/normalisation.h b/qpms/normalisation.h index c7ee22b..5ab7099 100644 --- a/qpms/normalisation.h +++ b/qpms/normalisation.h @@ -207,4 +207,77 @@ static inline complex double qpms_spharm_azimuthal_part_derivative_div_m(qpms_no QPMS_WTF; } } + +#if 0 // legacy code moved from qpms_types.h. TODO cleanup +/// Returns the normalisation convention code without the Condon-Shortley phase. +static inline int qpms_normalisation_t_normonly(qpms_normalisation_t norm) { + return norm & (~QPMS_NORMALISATION_T_CSBIT); +} + +/* Normalisation of the spherical waves is now scattered in at least three different files: + * here, we have the norm in terms of radiated power of outgoing wave. + * In file legendre.c, function qpms_pitau_get determines the norm used in the vswf.c + * spherical vector wave norms. The "dual" waves in vswf.c use the ..._abssquare function below. + * In file translations.c, the normalisations are again set by hand using the normfac and lognormfac + * functions. + */ +#include +#include +// relative to QPMS_NORMALISATION_KRISTENSSON_CS, i.e. +// P_l^m[normtype] = P_l^m[Kristensson] +static inline double qpms_normalisation_t_factor(qpms_normalisation_t norm, qpms_l_t l, qpms_m_t m) { + int csphase = qpms_normalisation_t_csphase(norm); + norm = qpms_normalisation_t_normonly(norm); + double factor; + switch (norm) { + case QPMS_NORMALISATION_KRISTENSSON: + factor = 1.; + break; + case QPMS_NORMALISATION_TAYLOR: + factor = sqrt(l*(l+1)); + break; + case QPMS_NORMALISATION_NONE: + factor = sqrt(l*(l+1) * 4 * M_PI / (2*l+1) * exp(lgamma(l+m+1)-lgamma(l-m+1))); + break; +#ifdef USE_XU_ANTINORMALISATION // broken probably in legendre.c + case QPMS_NORMALISATION_XU: + factor = sqrt(4 * M_PI) / (2*l+1) * exp(lgamma(l+m+1)-lgamma(l-m+1)); + break; +#endif + default: + assert(0); + } + factor *= (m%2)?(-csphase):1; + return factor; +} + + +// TODO move elsewhere +static inline double qpms_normalisation_t_factor_abssquare(qpms_normalisation_t norm, qpms_l_t l, qpms_m_t m) { + norm = qpms_normalisation_t_normonly(norm); + switch (norm) { + case QPMS_NORMALISATION_KRISTENSSON: + return 1.; + break; + case QPMS_NORMALISATION_TAYLOR: + return l*(l+1); + break; + case QPMS_NORMALISATION_NONE: + return l*(l+1) * 4 * M_PI / (2*l+1) * exp(lgamma(l+m+1)-lgamma(l-m+1)); + break; +#ifdef USE_XU_ANTINORMALISATION // broken probably in legendre.c + case QPMS_NORMALISATION_XU: + { + double fac = sqrt(4 * M_PI) / (2*l+1) * exp(lgamma(l+m+1)-lgamma(l-m+1)); + return fac * fac; + } + break; +#endif + default: + assert(0); + return NAN; + } +} +#endif + #endif //NORMALISATION_H diff --git a/qpms/qpms_types.h b/qpms/qpms_types.h index 0bf4263..e72ef0f 100644 --- a/qpms/qpms_types.h +++ b/qpms/qpms_types.h @@ -166,80 +166,6 @@ static inline int qpms_normalisation_t_csphase(qpms_normalisation_t norm) { return (norm & QPMS_NORMALISATION_CSPHASE)? -1 : 1; } -#if 0 -/// Returns the normalisation convention code without the Condon-Shortley phase. -static inline int qpms_normalisation_t_normonly(qpms_normalisation_t norm) { - return norm & (~QPMS_NORMALISATION_T_CSBIT); -} - -// TODO move the inlines elsewhere -/* Normalisation of the spherical waves is now scattered in at least three different files: - * here, we have the norm in terms of radiated power of outgoing wave. - * In file legendre.c, function qpms_pitau_get determines the norm used in the vswf.c - * spherical vector wave norms. The "dual" waves in vswf.c use the ..._abssquare function below. - * In file translations.c, the normalisations are again set by hand using the normfac and lognormfac - * functions. - */ -#include -#include -// relative to QPMS_NORMALISATION_KRISTENSSON_CS, i.e. -// P_l^m[normtype] = P_l^m[Kristensson] -static inline double qpms_normalisation_t_factor(qpms_normalisation_t norm, qpms_l_t l, qpms_m_t m) { - int csphase = qpms_normalisation_t_csphase(norm); - norm = qpms_normalisation_t_normonly(norm); - double factor; - switch (norm) { - case QPMS_NORMALISATION_KRISTENSSON: - factor = 1.; - break; - case QPMS_NORMALISATION_TAYLOR: - factor = sqrt(l*(l+1)); - break; - case QPMS_NORMALISATION_NONE: - factor = sqrt(l*(l+1) * 4 * M_PI / (2*l+1) * exp(lgamma(l+m+1)-lgamma(l-m+1))); - break; -#ifdef USE_XU_ANTINORMALISATION // broken probably in legendre.c - case QPMS_NORMALISATION_XU: - factor = sqrt(4 * M_PI) / (2*l+1) * exp(lgamma(l+m+1)-lgamma(l-m+1)); - break; -#endif - default: - assert(0); - } - factor *= (m%2)?(-csphase):1; - return factor; -} - - -// TODO move elsewhere -static inline double qpms_normalisation_t_factor_abssquare(qpms_normalisation_t norm, qpms_l_t l, qpms_m_t m) { - norm = qpms_normalisation_t_normonly(norm); - switch (norm) { - case QPMS_NORMALISATION_KRISTENSSON: - return 1.; - break; - case QPMS_NORMALISATION_TAYLOR: - return l*(l+1); - break; - case QPMS_NORMALISATION_NONE: - return l*(l+1) * 4 * M_PI / (2*l+1) * exp(lgamma(l+m+1)-lgamma(l-m+1)); - break; -#ifdef USE_XU_ANTINORMALISATION // broken probably in legendre.c - case QPMS_NORMALISATION_XU: - { - double fac = sqrt(4 * M_PI) / (2*l+1) * exp(lgamma(l+m+1)-lgamma(l-m+1)); - return fac * fac; - } - break; -#endif - default: - assert(0); - return NAN; - } -} -#endif - - /// Bessel function kinds. typedef enum { QPMS_BESSEL_REGULAR = 1, ///< regular (spherical) Bessel function \a j (Bessel function of the first kind)