Expose more testing functions via cython api.

This commit is contained in:
Marek Nečada 2021-12-21 12:31:32 +02:00
parent fed391b20c
commit 2c12d28c70
2 changed files with 27 additions and 4 deletions

View File

@ -696,7 +696,7 @@ cdef class ScatteringSystem:
self.s, iri, 0) self.s, iri, 0)
return target_np return target_np
def pack_matrix(self, fullmatrix, iri): def pack_matrix(self, fullmatrix, iri, version='normal'):
"""Converts (projects) a matrix into an irrep subspace. """Converts (projects) a matrix into an irrep subspace.
Parameters Parameters
@ -728,10 +728,14 @@ cdef class ScatteringSystem:
cdef np.ndarray[np.complex_t, ndim=2] target_np = np.empty( cdef np.ndarray[np.complex_t, ndim=2] target_np = np.empty(
(rlen, rlen), dtype=complex, order='C') (rlen, rlen), dtype=complex, order='C')
cdef cdouble[:,::1] target_view = target_np cdef cdouble[:,::1] target_view = target_np
qpms_scatsys_irrep_pack_matrix(&target_view[0][0], &fullmatrix_view[0][0], if version == 'stupid':
qpms_scatsys_irrep_pack_matrix_stupid(&target_view[0][0], &fullmatrix_view[0][0],
self.s, iri)
else:
qpms_scatsys_irrep_pack_matrix(&target_view[0][0], &fullmatrix_view[0][0],
self.s, iri) self.s, iri)
return target_np return target_np
def unpack_matrix(self, packedmatrix, iri): def unpack_matrix(self, packedmatrix, iri, version='normal'):
"""Unpacks an "irrep-packed" excitation coefficient vector to full coordinates. """Unpacks an "irrep-packed" excitation coefficient vector to full coordinates.
Parameters Parameters
@ -764,7 +768,11 @@ cdef class ScatteringSystem:
cdef np.ndarray[np.complex_t, ndim=2] target_np = np.empty( cdef np.ndarray[np.complex_t, ndim=2] target_np = np.empty(
(flen, flen), dtype=complex, order='C') (flen, flen), dtype=complex, order='C')
cdef cdouble[:,::1] target_view = target_np cdef cdouble[:,::1] target_view = target_np
qpms_scatsys_irrep_unpack_matrix(&target_view[0][0], &packedmatrix_view[0][0], if version == 'stupid':
qpms_scatsys_irrep_unpack_matrix_stupid(&target_view[0][0], &packedmatrix_view[0][0],
self.s, iri, 0)
else:
qpms_scatsys_irrep_unpack_matrix(&target_view[0][0], &packedmatrix_view[0][0],
self.s, iri, 0) self.s, iri, 0)
return target_np return target_np
@ -816,6 +824,16 @@ cdef class ScatteringSystem:
qpms_scatsys_periodic_build_translation_matrix_full(&target_view[0][0], self.s, wavenumber, &blochvector_c, eta) qpms_scatsys_periodic_build_translation_matrix_full(&target_view[0][0], self.s, wavenumber, &blochvector_c, eta)
return target return target
def irrep_transform_matrix(self, qpms_iri_t iri):
self.check_s()
cdef size_t rlen = self.saecv_sizes[iri]
cdef size_t fullen = self.fecv_size
cdef np.ndarray[np.complex_t, ndim=2] target = np.empty(
(rlen, fullen), dtype=complex, order='C')
cdef cdouble[:,::1] target_view = target
qpms_scatsys_irrep_transform_matrix(&target_view[0][0], self.s, iri)
return target
def translation_matrix_packed(self, cdouble wavenumber, qpms_iri_t iri, J = QPMS_HANKEL_PLUS): def translation_matrix_packed(self, cdouble wavenumber, qpms_iri_t iri, J = QPMS_HANKEL_PLUS):
self.check_s() self.check_s()
cdef size_t rlen = self.saecv_sizes[iri] cdef size_t rlen = self.saecv_sizes[iri]

View File

@ -645,6 +645,11 @@ cdef extern from "scatsystem.h":
cdouble omega, const qpms_tolerance_spec_t *tol) cdouble omega, const qpms_tolerance_spec_t *tol)
qpms_scatsys_at_omega_t *qpms_scatsys_at_omega(const qpms_scatsys_t *ss, cdouble omega) qpms_scatsys_at_omega_t *qpms_scatsys_at_omega(const qpms_scatsys_t *ss, cdouble omega)
void qpms_scatsys_at_omega_free(qpms_scatsys_at_omega_t *ssw) void qpms_scatsys_at_omega_free(qpms_scatsys_at_omega_t *ssw)
cdouble *qpms_scatsys_irrep_transform_matrix(cdouble *target, const qpms_scatsys_t *ss, qpms_iri_t iri)
cdouble *qpms_scatsys_irrep_pack_matrix_stupid(cdouble *target_packed,
const cdouble *orig_full, const qpms_scatsys_t *ss, qpms_iri_t iri)
cdouble *qpms_scatsys_irrep_unpack_matrix_stupid(cdouble *target_full,
const cdouble *orig_packed, const qpms_scatsys_t *ss, qpms_iri_t iri, bint add)
cdouble *qpms_scatsys_irrep_pack_matrix(cdouble *target_packed, cdouble *qpms_scatsys_irrep_pack_matrix(cdouble *target_packed,
const cdouble *orig_full, const qpms_scatsys_t *ss, qpms_iri_t iri) const cdouble *orig_full, const qpms_scatsys_t *ss, qpms_iri_t iri)
cdouble *qpms_scatsys_irrep_unpack_matrix(cdouble *target_full, cdouble *qpms_scatsys_irrep_unpack_matrix(cdouble *target_full,