Convenience function to create the 'usual' bspecs.

Former-commit-id: ce4e1cbab81ef251ad44cb58d765b6b19a0179aa
This commit is contained in:
Marek Nečada 2019-03-09 00:33:19 +00:00
parent 4dfb358de6
commit fb706b07ae
2 changed files with 19 additions and 0 deletions

View File

@ -69,6 +69,22 @@ qpms_vswf_set_spec_t *qpms_vswf_set_spec_copy(const qpms_vswf_set_spec_t *or){
return c; 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) { void qpms_vswf_set_spec_free(qpms_vswf_set_spec_t *s) {
if(s) free(s->ilist); if(s) free(s->ilist);
free(s); free(s);

View File

@ -27,6 +27,9 @@ bool qpms_vswf_set_spec_isidentical(const qpms_vswf_set_spec_t *a,
const qpms_vswf_set_spec_t *b); const qpms_vswf_set_spec_t *b);
/// Copies an instance of qpms_vswf_set_spec_t /// 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); 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. /// Finds the position of a given index in the bspec's ilist.
/** If not found, returns -1. */ /** If not found, returns -1. */