diff --git a/qpms/scatsys_translation_booster.c b/qpms/scatsys_translation_booster.c new file mode 100644 index 0000000..5a49429 --- /dev/null +++ b/qpms/scatsys_translation_booster.c @@ -0,0 +1,38 @@ +#include "scatsystem.h" + +#define SQ(x) ((x)*(x)) + +typedef size_t ppid_t; +typedef size_t uoppid_t; + +// Unordered pair ID. TODO get rid of redundancies +static inline uoppid_t uopairid(qpms_ss_pi_t pn_total, qpms_ss_pi_t p1, qpms_ss_pi_t p2) { + return pn_total * p1 + p2; +} + +// Unordered pair ID count. TODO get rid of redundancies. +static inline uoppid_t uopairarr_len(qpms_ss_pi_t pn_total) { + return SQ(pn_total); +} + +// Ordered pair ID. +static inline uoppid_t pairid(qpms_ss_pi_t pn_total, qpms_ss_pi_t p1, qpms_ss_pi_t p2) { + return pn_total * p1 + p2; +} + +// Ordered pair ID count. +static inline uoppid_t pairarr_len(qpms_ss_pi_t pn_total) { + return SQ(pn_total); +} + +typedef struct qpms_scatsys_translation_booster { + double *r; // Unique distances array, indices are ppid_t + ppid_t *r_map; // FIXME +} qpms_scatsys_translation_booster_t; + +struct qpms_scatsys_translation_booster *qpms_scatsys_translation_booster_create( + const qpms_scatsys_ss *ss) { + const qpms_ss_pi_t np = ss->p_count; + TODO; +} + diff --git a/qpms/scatsystem.c b/qpms/scatsystem.c index c3bb86c..4a9a326 100644 --- a/qpms/scatsystem.c +++ b/qpms/scatsystem.c @@ -143,7 +143,6 @@ static void add_orbit_type(qpms_scatsys_t *ss, const qpms_ss_orbit_type_t *ot_cu ss->orbit_type_count++; } - // Almost 200 lines. This whole thing deserves a rewrite! qpms_scatsys_at_omega_t *qpms_scatsys_apply_symmetry(const qpms_scatsys_t *orig, const qpms_finite_group_t *sym, complex double omega, diff --git a/qpms/scatsystem.h b/qpms/scatsystem.h index 5c74c1f..5023fc2 100644 --- a/qpms/scatsystem.h +++ b/qpms/scatsystem.h @@ -133,7 +133,7 @@ typedef struct qpms_ss_derived_tmatrix_t { struct qpms_trans_calculator; -struct qpms_epsmu_generator_t; +struct qpms_scatsys_translation_booster; typedef struct qpms_scatsys_t { struct qpms_epsmu_generator_t medium; ///< Optical properties of the background medium. @@ -188,6 +188,9 @@ typedef struct qpms_scatsys_t { char *otspace_end; double lenscale; // radius of the array, used as a relative tolerance measure struct qpms_trans_calculator *c; + // Internal metadata for faster translation matrix evaluation + struct qpms_scatsys_translation_booster *tbooster; + } qpms_scatsys_t; /// Retrieve the bspec of \a tmi'th element of \a ss->tm.