From 626ffd77cd454467dc170f1546e20ed6b11427bd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Ne=C4=8Dada?= Date: Fri, 22 May 2020 15:44:20 +0300 Subject: [PATCH] Wrappers for testing z != 0 lattice sum related special functions. Former-commit-id: a6be46f81850b1c01c72ea96c141c92a98f6ace8 --- qpms/cyewaldtest.pyx | 24 ++++++++++++++++++++++++ setup.py | 6 +++++- 2 files changed, 29 insertions(+), 1 deletion(-) create mode 100644 qpms/cyewaldtest.pyx diff --git a/qpms/cyewaldtest.pyx b/qpms/cyewaldtest.pyx new file mode 100644 index 0000000..cf93b14 --- /dev/null +++ b/qpms/cyewaldtest.pyx @@ -0,0 +1,24 @@ +from .qpms_cdefs cimport * +from libc.stdlib cimport malloc, free, calloc +import numpy as np + +cdef extern from "ewald.h": + void ewald3_2_sigma_long_Delta(qpms_csf_result *target, int maxn, cdouble x, cdouble z) + int complex_gamma_inc_e(double a, cdouble x, int m, qpms_csf_result *result) + +def e32_Delta(int maxn, cdouble x, cdouble z): + cdef qpms_csf_result *target = malloc((maxn+1)*sizeof(qpms_csf_result)) + cdef np.ndarray[cdouble, ndim=1] target_np = np.empty((maxn+1,), dtype=complex, order='C') + ewald3_2_sigma_long_Delta(target, maxn, x, z) + cdef int i + for i in range(maxn+1): + target_np[i] = target[i].val + free(target) + return target_np + +def gamma_inc(double a, cdouble x, int m=0): + cdef qpms_csf_result res + complex_gamma_inc_e(a, x, m, &res) + return res.val + + diff --git a/setup.py b/setup.py index 4ae09d2..13ee224 100755 --- a/setup.py +++ b/setup.py @@ -121,6 +121,10 @@ cyquaternions = Extension('qpms.cyquaternions', #extra_link_args=['amos/libamos.a', 'qpms/libqpms.a'], libraries=['qpms', 'gsl', 'lapacke', 'blas', 'gslcblas', 'pthread',] ) +cyewaldtest = Extension('qpms.cyewaldtest', + sources = ['qpms/cyewaldtest.pyx'], + libraries=['qpms', 'gsl', 'lapacke', 'blas', 'gslcblas', 'pthread',] + ) qpms_c = Extension('qpms.qpms_c', sources = [ @@ -144,7 +148,7 @@ setup(name='qpms', #'quaternion','spherical_functions', 'scipy>=0.18.0', 'sympy>=1.2'], #dependency_links=['https://github.com/moble/quaternion/archive/v2.0.tar.gz','https://github.com/moble/spherical_functions/archive/master.zip'], - ext_modules=cythonize([qpms_c, cywaves, cytranslations, cytmatrices, cycommon, cyquaternions, cybspec, cymaterials], include_path=['qpms', 'amos'], gdb_debug=True), + ext_modules=cythonize([qpms_c, cywaves, cytranslations, cytmatrices, cycommon, cyquaternions, cybspec, cymaterials, cyewaldtest], include_path=['qpms', 'amos'], gdb_debug=True), cmdclass = {'build_ext': build_ext}, zip_safe=False )