Cython-wrap additional translations.h functions.

Former-commit-id: 4b1ad54f40167f66b6788cb2976ca854b7971a5e
This commit is contained in:
Marek Nečada 2019-07-22 10:08:09 +03:00
parent 29a521db81
commit d01ab445fe
3 changed files with 57 additions and 0 deletions

View File

@ -24,6 +24,8 @@ TODO list before public release
* As a description of a T-matrix / particle metadata. * As a description of a T-matrix / particle metadata.
- Nice CLI for all general enough utilities. - Nice CLI for all general enough utilities.
- Remove legacy code. - Remove legacy code.
- Split qpms_c.pyx.
- Reduce compiler warnings.
- Prefix all identifiers. Maybe think about a different prefix than qpms? - Prefix all identifiers. Maybe think about a different prefix than qpms?
- Consistent indentation and style overall. - Consistent indentation and style overall.
- Rewrite the parallelized translation matrix, mode problem matrix generators - Rewrite the parallelized translation matrix, mode problem matrix generators

View File

@ -671,6 +671,46 @@ cdef class trans_calculator:
) )
return a, b return a, b
def get_trans_array_bspec_sph(self, BaseSpec destspec, BaseSpec srcspec,
double k, kdlj, qpms_bessel_t J = QPMS_HANKEL_PLUS):
if kdlj.shape != (3,):
raise ValueError("Array of shape (3,) with spherical coordinates of the translation expected")
cdef size_t destn = len(destspec)
cdef size_t srcn = len(srcspec)
cdef np.ndarray[np.complex_t, ndim=2] target = np.empty(
(destn, srcn), dtype=complex, order='C')
cdef cdouble[:,::1] target_view = target
cdef sph_t kdlj_sph
kdlj_sph.r = kdlj[0]
kdlj_sph.theta = kdlj[1]
kdlj_sph.phi = kdlj[2]
qpms_trans_calculator_get_trans_array(self.c, &target_view[0][0],
destspec.rawpointer(), srcn, srcspec.rawpointer(), 1,
kdlj_sph, False, J)
return target
def get_trans_array_bspec_c3pos(self, BaseSpec destspec, BaseSpec srcspec,
double k, destpos, srcpos, qpms_bessel_t J = QPMS_HANKEL_PLUS):
if destpos.shape != (3,) or srcpos.shape != (3,):
raise ValueError("Array of shape (3,) with cartesian coordinates of the particle position expected")
cdef size_t destn = len(destspec)
cdef size_t srcn = len(srcspec)
cdef np.ndarray[np.complex_t, ndim=2] target = np.empty(
(destn, srcn), dtype=complex, order='C')
cdef cdouble[:,::1] target_view = target
cdef cart3_t srcp, destp
srcp.x = srcpos[0]
srcp.y = srcpos[1]
srcp.z = srcpos[2]
destp.x = destpos[0]
destp.y = destpos[1]
destp.z = destpos[2]
qpms_trans_calculator_get_trans_array_lc3p(self.c, &target_view[0][0],
destspec.rawpointer(), srcn, srcspec.rawpointer(), 1, k,
destp, srcp, J)
return target
# TODO make possible to access the attributes (to show normalization etc) # TODO make possible to access the attributes (to show normalization etc)

View File

@ -269,6 +269,21 @@ cdef extern from "translations.h":
char *phi_data, np.npy_intp *phi_shape, np.npy_intp *phi_strides, char *phi_data, np.npy_intp *phi_shape, np.npy_intp *phi_strides,
char *r_ge_d_data, np.npy_intp *phi_shape, np.npy_intp *phi_strides) nogil char *r_ge_d_data, np.npy_intp *phi_shape, np.npy_intp *phi_strides) nogil
int qpms_trans_calculator_get_trans_array(const qpms_trans_calculator *c,
cdouble *target,
const qpms_vswf_set_spec_t *destspec, size_t deststride,
const qpms_vswf_set_spec_t *srcspec, size_t srcstride,
sph_t kdlj, bint r_ge_d, qpms_bessel_t J);
int qpms_trans_calculator_get_trans_array_lc3p(
const qpms_trans_calculator *c,
cdouble *target,
const qpms_vswf_set_spec_t *destspec, size_t deststride,
const qpms_vswf_set_spec_t *srcspec, size_t srcstride,
double k, cart3_t destpos, cart3_t srcpos,
qpms_bessel_t J
);
cdef extern from "gsl/gsl_interp.h": cdef extern from "gsl/gsl_interp.h":
struct gsl_interp_type: struct gsl_interp_type:
pass pass