diff --git a/qpms/qpms_error.h b/qpms/qpms_error.h index b1ea0f7..33597ab 100644 --- a/qpms/qpms_error.h +++ b/qpms/qpms_error.h @@ -27,4 +27,6 @@ void qpms_pr_debug_at_flf(const char *filename, unsigned int linenum, #define QPMS_ENSURE_SUCCESS(x) {if(x) QPMS_WTF;} +#define QPMS_ENSURE(x, msg, ...) {if(!(x)) qpms_pr_error_at_flf(__FILE__,__LINE__,__func__,msg, ##__VA_ARGS__); } + #endif diff --git a/qpms/scatsystem.c b/qpms/scatsystem.c index 27a1ad2..062fba4 100644 --- a/qpms/scatsystem.c +++ b/qpms/scatsystem.c @@ -467,16 +467,18 @@ qpms_scatsys_t *qpms_scatsys_apply_symmetry(const qpms_scatsys_t *orig, const qp break; } if (j == ss->tm_count) { // duplicity not found, copy the t-matrix - ss->tm[i] = qpms_tmatrix_copy(orig->tm[i]); + ss->tm[j] = qpms_tmatrix_copy(orig->tm[i]); + ss->max_bspecn = MAX(ss->tm[j]->spec->n, ss->max_bspecn); + lMax = MAX(lMax, ss->tm[j]->spec->lMax); ++(ss->tm_count); } tm_dupl_remap[i] = j; - ss->max_bspecn = MAX(ss->tm[i]->spec->n, ss->max_bspecn); if (normalisation == QPMS_NORMALISATION_UNDEF) normalisation = ss->tm[i]->spec->norm; // We expect all bspec norms to be the same. - else assert(normalisation == ss->tm[i]->spec->norm); - lMax = MAX(lMax, ss->tm[i]->spec->lMax); + else QPMS_ENSURE(normalisation == ss->tm[j]->spec->norm, + "Normalisation convention must be the same for all T-matrices." + " %d != %d\n", normalisation, ss->tm[j]->spec->norm); } // Copy particles, remapping the t-matrix indices