diff --git a/qpms/cybspec.pyx b/qpms/cybspec.pyx index 45cf286..7cbbc67 100644 --- a/qpms/cybspec.pyx +++ b/qpms/cybspec.pyx @@ -1,4 +1,5 @@ import numpy as np +cimport numpy as np import enum from .cycommon import get_mn_y, tlm2uvswfi __VSWF_norm_dict = { @@ -140,6 +141,11 @@ cdef class BaseSpec: return self.__ilist[key] def __repr__(self): + cdef qpms_l_t lMax_candidate + lMax_candidate = qpms_nelem2lMax(len(self.__ilist) // 2) + if lMax_candidate >= 0: + if np.array_equal(self.__ilist, BaseSpec(lMax=lMax_candidate).ilist): + return 'BaseSpec(lMax=%d)' % lMax_candidate return 'BaseSpec([' + ','.join('%d' % i for i in self.__ilist) + '])' property ilist: diff --git a/qpms/indexing.h b/qpms/indexing.h index e8ef012..11ac48e 100644 --- a/qpms/indexing.h +++ b/qpms/indexing.h @@ -63,6 +63,15 @@ static inline qpms_y_t qpms_lMax2nelem(qpms_l_t lmax){ return lmax * ((qpms_y_t)lmax + 2); } +/// Inverse of qpms_lMax2nelem(); returns -1 if there is no exact match. +static inline qpms_l_t qpms_nelem2lMax(qpms_y_t nelem) { + qpms_l_t l = qpms_y2n(nelem); + if (l == -qpms_yn2m(nelem, l)) + return l - 1; + else + return -1; +} + // Scalar versions: they have a place for the 0, 0 term in the beginning /// Mapping from multipole degree, order to flat index (degree ≥ 0)