sharp_legendre_table: Import Legendre table generating code from libpsht

Includes a Python wrapper. The code is tested and compared with SciPy
results through the Python tests.
This commit is contained in:
Dag Sverre Seljebotn 2017-05-18 22:41:19 +02:00
parent 0787838ab3
commit a93db0b1aa
9 changed files with 1616 additions and 5 deletions

View file

@ -1,8 +1,9 @@
import numpy as np
cimport cython
__all__ = ['legendre_transform', 'legendre_roots', 'sht', 'synthesis', 'adjoint_synthesis',
'analysis', 'adjoint_analysis', 'healpix_grid', 'triangular_order', 'rectangular_order',
'packed_real_order']
'packed_real_order', 'normalized_associated_legendre_table']
def legendre_transform(x, bl, out=None):
@ -254,3 +255,17 @@ cdef class packed_real_order(alm_info):
ms=NULL if ms is None else &ms[0],
alm_info=&self.ainfo)
#
#
#
@cython.boundscheck(False)
def normalized_associated_legendre_table(int lmax, int m, theta):
cdef double[::1] theta_ = np.ascontiguousarray(theta, dtype=np.double)
out = np.zeros((theta_.shape[0], lmax - m + 1), np.double)
cdef double[:, ::1] out_ = out
if lmax < m:
raise ValueError("lmax < m")
with nogil:
sharp_normalized_associated_legendre_table(m, lmax, theta_.shape[0], &theta_[0], lmax - m + 1, &out_[0,0])
return out