diff --git a/qpms/vswf.c b/qpms/vswf.c index 862b756..10af7ff 100644 --- a/qpms/vswf.c +++ b/qpms/vswf.c @@ -69,6 +69,22 @@ qpms_vswf_set_spec_t *qpms_vswf_set_spec_copy(const qpms_vswf_set_spec_t *or){ return c; } +qpms_vswf_set_spec_t *qpms_vswf_set_spec_from_lMax(qpms_l_t lMax, + qpms_normalisation_t norm) { + qpms_vswf_set_spec_t *c = malloc(sizeof(qpms_vswf_set_spec_t)); + if (!c) abort(); // return NULL + c->n = c->capacity = 2 * qpms_lMax2nelem(lMax); + c->ilist = malloc(sizeof(qpms_uvswfi_t) * c->capacity); + size_t i = 0; + for (int it = 0; it < 2; ++it) + for (qpms_l_t n = 1; n <= lMax; ++n) + for (qpms_m_t m = -n; m <= n; ++m) + c->ilist[i++] = + qpms_tmn2uvswfi(it ? QPMS_VSWF_MAGNETIC : QPMS_VSWF_ELECTRIC, m, n); + c->norm = norm; + return c; +} + void qpms_vswf_set_spec_free(qpms_vswf_set_spec_t *s) { if(s) free(s->ilist); free(s); diff --git a/qpms/vswf.h b/qpms/vswf.h index 065a735..d33b4d2 100644 --- a/qpms/vswf.h +++ b/qpms/vswf.h @@ -27,6 +27,9 @@ bool qpms_vswf_set_spec_isidentical(const qpms_vswf_set_spec_t *a, const qpms_vswf_set_spec_t *b); /// Copies an instance of qpms_vswf_set_spec_t qpms_vswf_set_spec_t *qpms_vswf_set_spec_copy(const qpms_vswf_set_spec_t *orig); +/// Creates an instance of qpms_vswf_set_spec_t in the 'traditional' layout. +qpms_vswf_set_spec_t *qpms_vswf_set_spec_from_lMax(qpms_l_t lMax, + qpms_normalisation_t norm); /// Finds the position of a given index in the bspec's ilist. /** If not found, returns -1. */