Fix missing import in finiterectlat-scatter.py
[qpms.git] / qpms / cyewaldtest.pyx
blobc88215bc638ce19181c82c96ae9fce6c9a72e20a
1 from .qpms_cdefs cimport *
2 from libc.stdlib cimport malloc, free, calloc
3 import numpy as np
5 cdef extern from "ewald.h":
6 void ewald3_2_sigma_long_Delta(cdouble *target, double *err, int maxn, cdouble x, int xbranch, cdouble z)
7 void ewald3_2_sigma_long_Delta_series(cdouble *target, double *err, int maxn, cdouble x, int xbranch, cdouble z)
8 void ewald3_2_sigma_long_Delta_recurrent(cdouble *target, double *err, int maxn, cdouble x, int xbranch, cdouble z, bint bigimz)
9 int complex_gamma_inc_e(double a, cdouble x, int xbranch, qpms_csf_result *result)
11 def e32_Delta(int maxn, cdouble x, cdouble z, int xbranch = 0, get_err=True, method='auto'):
12 cdef np.ndarray[double, ndim=1] err_np
13 cdef double[::1] err_view
14 cdef np.ndarray[np.complex_t, ndim=1] target_np = np.empty((maxn+1,), dtype=complex, order='C')
15 cdef cdouble[::1] target_view = target_np
16 if get_err:
17 err_np = np.empty((maxn+1,), order='C')
18 err_view = err_np
19 if method == 'recurrent':
20 ewald3_2_sigma_long_Delta_recurrent(&target_view[0], &err_view[0] if get_err else NULL, maxn, x, xbranch, z, False)
21 if method == 'recurrent_bigimz':
22 ewald3_2_sigma_long_Delta_recurrent(&target_view[0], &err_view[0] if get_err else NULL, maxn, x, xbranch, z, True)
23 elif method == 'series':
24 ewald3_2_sigma_long_Delta_series(&target_view[0], &err_view[0] if get_err else NULL, maxn, x, xbranch, z)
25 else:
26 ewald3_2_sigma_long_Delta(&target_view[0], &err_view[0] if get_err else NULL, maxn, x, xbranch, z)
27 if get_err:
28 return target_np, err_np
29 else:
30 return target_np
32 def gamma_inc(double a, cdouble x, int xbranch=0):
33 cdef qpms_csf_result res
34 complex_gamma_inc_e(a, x, xbranch, &res)
35 return res.val