pylibsparseir 0.7.4__cp312-cp312-macosx_15_0_arm64.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- pylibsparseir/__init__.py +31 -0
- pylibsparseir/clean_build_artifacts.py +71 -0
- pylibsparseir/constants.py +39 -0
- pylibsparseir/core.py +641 -0
- pylibsparseir/ctypes_autogen.py +117 -0
- pylibsparseir/ctypes_wrapper.py +44 -0
- pylibsparseir/libsparse_ir_capi.dylib +0 -0
- pylibsparseir/sparseir.h +1874 -0
- pylibsparseir-0.7.4.dist-info/METADATA +209 -0
- pylibsparseir-0.7.4.dist-info/RECORD +12 -0
- pylibsparseir-0.7.4.dist-info/WHEEL +6 -0
- pylibsparseir-0.7.4.dist-info/licenses/LICENSE +21 -0
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Auto-generated ctypes bindings from C-API header.
|
|
3
|
+
DO NOT EDIT THIS FILE MANUALLY.
|
|
4
|
+
Generated by tools/gen_ctypes.py
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
import ctypes
|
|
8
|
+
from ctypes import (
|
|
9
|
+
c_int, c_double, c_int64, c_size_t, c_bool,
|
|
10
|
+
POINTER, c_char_p, Structure,
|
|
11
|
+
)
|
|
12
|
+
|
|
13
|
+
from .ctypes_wrapper import (
|
|
14
|
+
spir_kernel, spir_funcs, spir_basis,
|
|
15
|
+
spir_sampling, spir_sve_result,
|
|
16
|
+
)
|
|
17
|
+
|
|
18
|
+
# Custom complex type (matches core.py definition)
|
|
19
|
+
class c_double_complex(Structure):
|
|
20
|
+
"""Complex number as ctypes Structure."""
|
|
21
|
+
_fields_ = [("real", ctypes.c_double), ("imag", ctypes.c_double)]
|
|
22
|
+
|
|
23
|
+
@property
|
|
24
|
+
def value(self):
|
|
25
|
+
return self.real + 1j * self.imag
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
# Function prototypes: {name: (restype, [argtypes])}
|
|
29
|
+
FUNCTIONS = {
|
|
30
|
+
'spir_basis_clone': ('POINTER(struct spir_basis)', ['POINTER(struct spir_basis)']),
|
|
31
|
+
'spir_basis_get_default_matsus': ('c_int', ['POINTER(struct spir_basis)', '_Bool', 'POINTER(c_int64)']),
|
|
32
|
+
'spir_basis_get_default_matsus_ext': ('c_int', ['POINTER(struct spir_basis)', '_Bool', '_Bool', 'c_int', 'POINTER(c_int64)', 'POINTER(c_int)']),
|
|
33
|
+
'spir_basis_get_default_taus': ('c_int', ['POINTER(struct spir_basis)', 'POINTER(c_double)']),
|
|
34
|
+
'spir_basis_get_default_taus_ext': ('c_int', ['POINTER(struct spir_basis)', 'c_int', 'POINTER(c_double)', 'POINTER(c_int)']),
|
|
35
|
+
'spir_basis_get_default_ws': ('c_int', ['POINTER(struct spir_basis)', 'POINTER(c_double)']),
|
|
36
|
+
'spir_basis_get_n_default_matsus': ('c_int', ['POINTER(struct spir_basis)', '_Bool', 'POINTER(c_int)']),
|
|
37
|
+
'spir_basis_get_n_default_matsus_ext': ('c_int', ['POINTER(struct spir_basis)', '_Bool', '_Bool', 'c_int', 'POINTER(c_int)']),
|
|
38
|
+
'spir_basis_get_n_default_taus': ('c_int', ['POINTER(struct spir_basis)', 'POINTER(c_int)']),
|
|
39
|
+
'spir_basis_get_n_default_ws': ('c_int', ['POINTER(struct spir_basis)', 'POINTER(c_int)']),
|
|
40
|
+
'spir_basis_get_singular_values': ('c_int', ['POINTER(struct spir_basis)', 'POINTER(c_double)']),
|
|
41
|
+
'spir_basis_get_size': ('c_int', ['POINTER(struct spir_basis)', 'POINTER(c_int)']),
|
|
42
|
+
'spir_basis_get_stats': ('c_int', ['POINTER(struct spir_basis)', 'POINTER(c_int)']),
|
|
43
|
+
'spir_basis_get_svals': ('c_int', ['POINTER(struct spir_basis)', 'POINTER(c_double)']),
|
|
44
|
+
'spir_basis_get_u': ('POINTER(struct spir_funcs)', ['POINTER(struct spir_basis)', 'POINTER(c_int)']),
|
|
45
|
+
'spir_basis_get_uhat': ('POINTER(struct spir_funcs)', ['POINTER(struct spir_basis)', 'POINTER(c_int)']),
|
|
46
|
+
'spir_basis_get_uhat_full': ('POINTER(struct spir_funcs)', ['POINTER(struct spir_basis)', 'POINTER(c_int)']),
|
|
47
|
+
'spir_basis_get_v': ('POINTER(struct spir_funcs)', ['POINTER(struct spir_basis)', 'POINTER(c_int)']),
|
|
48
|
+
'spir_basis_is_assigned': ('c_int', ['POINTER(struct spir_basis)']),
|
|
49
|
+
'spir_basis_new': ('POINTER(struct spir_basis)', ['c_int', 'c_double', 'c_double', 'c_double', 'POINTER(struct spir_kernel)', 'POINTER(struct spir_sve_result)', 'c_int', 'POINTER(c_int)']),
|
|
50
|
+
'spir_basis_new_from_sve_and_regularizer': ('POINTER(struct spir_basis)', ['c_int', 'c_double', 'c_double', 'c_double', 'c_double', 'c_int', 'c_double', 'POINTER(struct spir_sve_result)', 'POINTER(struct spir_funcs)', 'c_int', 'POINTER(c_int)']),
|
|
51
|
+
'spir_basis_release': ('None', ['POINTER(struct spir_basis)']),
|
|
52
|
+
'spir_choose_working_type': ('c_int', ['c_double']),
|
|
53
|
+
'spir_dlr2ir_dd': ('c_int', ['POINTER(struct spir_basis)', 'POINTER(struct spir_gemm_backend)', 'c_int', 'c_int', 'POINTER(c_int)', 'c_int', 'POINTER(c_double)', 'POINTER(c_double)']),
|
|
54
|
+
'spir_dlr2ir_zz': ('c_int', ['POINTER(struct spir_basis)', 'POINTER(struct spir_gemm_backend)', 'c_int', 'c_int', 'POINTER(c_int)', 'c_int', 'POINTER(struct Complex64)', 'POINTER(struct Complex64)']),
|
|
55
|
+
'spir_dlr_get_npoles': ('c_int', ['POINTER(struct spir_basis)', 'POINTER(c_int)']),
|
|
56
|
+
'spir_dlr_get_poles': ('c_int', ['POINTER(struct spir_basis)', 'POINTER(c_double)']),
|
|
57
|
+
'spir_dlr_new': ('POINTER(struct spir_basis)', ['POINTER(struct spir_basis)', 'POINTER(c_int)']),
|
|
58
|
+
'spir_dlr_new_with_poles': ('POINTER(struct spir_basis)', ['POINTER(struct spir_basis)', 'c_int', 'POINTER(c_double)', 'POINTER(c_int)']),
|
|
59
|
+
'spir_funcs_batch_eval': ('c_int', ['POINTER(struct spir_funcs)', 'c_int', 'c_int', 'POINTER(c_double)', 'POINTER(c_double)']),
|
|
60
|
+
'spir_funcs_batch_eval_matsu': ('c_int', ['POINTER(struct spir_funcs)', 'c_int', 'c_int', 'POINTER(c_int64)', 'POINTER(struct Complex64)']),
|
|
61
|
+
'spir_funcs_clone': ('POINTER(struct spir_funcs)', ['POINTER(struct spir_funcs)']),
|
|
62
|
+
'spir_funcs_eval': ('c_int', ['POINTER(struct spir_funcs)', 'c_double', 'POINTER(c_double)']),
|
|
63
|
+
'spir_funcs_eval_matsu': ('c_int', ['POINTER(struct spir_funcs)', 'c_int64', 'POINTER(struct Complex64)']),
|
|
64
|
+
'spir_funcs_from_piecewise_legendre': ('POINTER(struct spir_funcs)', ['POINTER(c_double)', 'c_int', 'POINTER(c_double)', 'c_int', 'c_int', 'POINTER(c_int)']),
|
|
65
|
+
'spir_funcs_get_knots': ('c_int', ['POINTER(struct spir_funcs)', 'POINTER(c_double)']),
|
|
66
|
+
'spir_funcs_get_n_knots': ('c_int', ['POINTER(struct spir_funcs)', 'POINTER(c_int)']),
|
|
67
|
+
'spir_funcs_get_size': ('c_int', ['POINTER(struct spir_funcs)', 'POINTER(c_int)']),
|
|
68
|
+
'spir_funcs_get_slice': ('POINTER(struct spir_funcs)', ['POINTER(struct spir_funcs)', 'c_int', 'POINTER(c_int)', 'POINTER(c_int)']),
|
|
69
|
+
'spir_funcs_is_assigned': ('c_int', ['POINTER(struct spir_funcs)']),
|
|
70
|
+
'spir_funcs_release': ('None', ['POINTER(struct spir_funcs)']),
|
|
71
|
+
'spir_gauss_legendre_rule_piecewise_ddouble': ('c_int', ['c_int', 'POINTER(c_double)', 'c_int', 'POINTER(c_double)', 'POINTER(c_double)', 'POINTER(c_double)', 'POINTER(c_double)', 'POINTER(c_int)']),
|
|
72
|
+
'spir_gauss_legendre_rule_piecewise_double': ('c_int', ['c_int', 'POINTER(c_double)', 'c_int', 'POINTER(c_double)', 'POINTER(c_double)', 'POINTER(c_int)']),
|
|
73
|
+
'spir_gemm_backend_new_from_fblas_ilp64': ('POINTER(struct spir_gemm_backend)', ['POINTER(None)', 'POINTER(None)']),
|
|
74
|
+
'spir_gemm_backend_new_from_fblas_lp64': ('POINTER(struct spir_gemm_backend)', ['POINTER(None)', 'POINTER(None)']),
|
|
75
|
+
'spir_gemm_backend_release': ('None', ['POINTER(struct spir_gemm_backend)']),
|
|
76
|
+
'spir_ir2dlr_dd': ('c_int', ['POINTER(struct spir_basis)', 'POINTER(struct spir_gemm_backend)', 'c_int', 'c_int', 'POINTER(c_int)', 'c_int', 'POINTER(c_double)', 'POINTER(c_double)']),
|
|
77
|
+
'spir_ir2dlr_zz': ('c_int', ['POINTER(struct spir_basis)', 'POINTER(struct spir_gemm_backend)', 'c_int', 'c_int', 'POINTER(c_int)', 'c_int', 'POINTER(struct Complex64)', 'POINTER(struct Complex64)']),
|
|
78
|
+
'spir_kernel_clone': ('POINTER(struct spir_kernel)', ['POINTER(struct spir_kernel)']),
|
|
79
|
+
'spir_kernel_compute': ('c_int', ['POINTER(struct spir_kernel)', 'c_double', 'c_double', 'POINTER(c_double)']),
|
|
80
|
+
'spir_kernel_get_domain': ('c_int', ['POINTER(struct spir_kernel)', 'POINTER(c_double)', 'POINTER(c_double)', 'POINTER(c_double)', 'POINTER(c_double)']),
|
|
81
|
+
'spir_kernel_get_lambda': ('c_int', ['POINTER(struct spir_kernel)', 'POINTER(c_double)']),
|
|
82
|
+
'spir_kernel_get_sve_hints_ngauss': ('c_int', ['POINTER(struct spir_kernel)', 'c_double', 'POINTER(c_int)']),
|
|
83
|
+
'spir_kernel_get_sve_hints_nsvals': ('c_int', ['POINTER(struct spir_kernel)', 'c_double', 'POINTER(c_int)']),
|
|
84
|
+
'spir_kernel_get_sve_hints_segments_x': ('c_int', ['POINTER(struct spir_kernel)', 'c_double', 'POINTER(c_double)', 'POINTER(c_int)']),
|
|
85
|
+
'spir_kernel_get_sve_hints_segments_y': ('c_int', ['POINTER(struct spir_kernel)', 'c_double', 'POINTER(c_double)', 'POINTER(c_int)']),
|
|
86
|
+
'spir_kernel_is_assigned': ('c_int', ['POINTER(struct spir_kernel)']),
|
|
87
|
+
'spir_kernel_release': ('None', ['POINTER(struct spir_kernel)']),
|
|
88
|
+
'spir_logistic_kernel_new': ('POINTER(struct spir_kernel)', ['c_double', 'POINTER(c_int)']),
|
|
89
|
+
'spir_matsu_sampling_new': ('POINTER(struct spir_sampling)', ['POINTER(struct spir_basis)', '_Bool', 'c_int', 'POINTER(c_int64)', 'POINTER(c_int)']),
|
|
90
|
+
'spir_matsu_sampling_new_with_matrix': ('POINTER(struct spir_sampling)', ['c_int', 'c_int', 'c_int', '_Bool', 'c_int', 'POINTER(c_int64)', 'POINTER(struct Complex64)', 'POINTER(c_int)']),
|
|
91
|
+
'spir_reg_bose_kernel_new': ('POINTER(struct spir_kernel)', ['c_double', 'POINTER(c_int)']),
|
|
92
|
+
'spir_sampling_clone': ('POINTER(struct spir_sampling)', ['POINTER(struct spir_sampling)']),
|
|
93
|
+
'spir_sampling_eval_dd': ('c_int', ['POINTER(struct spir_sampling)', 'POINTER(struct spir_gemm_backend)', 'c_int', 'c_int', 'POINTER(c_int)', 'c_int', 'POINTER(c_double)', 'POINTER(c_double)']),
|
|
94
|
+
'spir_sampling_eval_dz': ('c_int', ['POINTER(struct spir_sampling)', 'POINTER(struct spir_gemm_backend)', 'c_int', 'c_int', 'POINTER(c_int)', 'c_int', 'POINTER(c_double)', 'POINTER(struct Complex64)']),
|
|
95
|
+
'spir_sampling_eval_zz': ('c_int', ['POINTER(struct spir_sampling)', 'POINTER(struct spir_gemm_backend)', 'c_int', 'c_int', 'POINTER(c_int)', 'c_int', 'POINTER(struct Complex64)', 'POINTER(struct Complex64)']),
|
|
96
|
+
'spir_sampling_fit_dd': ('c_int', ['POINTER(struct spir_sampling)', 'POINTER(struct spir_gemm_backend)', 'c_int', 'c_int', 'POINTER(c_int)', 'c_int', 'POINTER(c_double)', 'POINTER(c_double)']),
|
|
97
|
+
'spir_sampling_fit_zd': ('c_int', ['POINTER(struct spir_sampling)', 'POINTER(struct spir_gemm_backend)', 'c_int', 'c_int', 'POINTER(c_int)', 'c_int', 'POINTER(struct Complex64)', 'POINTER(c_double)']),
|
|
98
|
+
'spir_sampling_fit_zz': ('c_int', ['POINTER(struct spir_sampling)', 'POINTER(struct spir_gemm_backend)', 'c_int', 'c_int', 'POINTER(c_int)', 'c_int', 'POINTER(struct Complex64)', 'POINTER(struct Complex64)']),
|
|
99
|
+
'spir_sampling_get_cond_num': ('c_int', ['POINTER(struct spir_sampling)', 'POINTER(c_double)']),
|
|
100
|
+
'spir_sampling_get_matsus': ('c_int', ['POINTER(struct spir_sampling)', 'POINTER(c_int64)']),
|
|
101
|
+
'spir_sampling_get_npoints': ('c_int', ['POINTER(struct spir_sampling)', 'POINTER(c_int)']),
|
|
102
|
+
'spir_sampling_get_taus': ('c_int', ['POINTER(struct spir_sampling)', 'POINTER(c_double)']),
|
|
103
|
+
'spir_sampling_is_assigned': ('c_int', ['POINTER(struct spir_sampling)']),
|
|
104
|
+
'spir_sampling_release': ('None', ['POINTER(struct spir_sampling)']),
|
|
105
|
+
'spir_sve_result_clone': ('POINTER(struct spir_sve_result)', ['POINTER(struct spir_sve_result)']),
|
|
106
|
+
'spir_sve_result_from_matrix': ('POINTER(struct spir_sve_result)', ['POINTER(c_double)', 'POINTER(c_double)', 'c_int', 'c_int', 'c_int', 'POINTER(c_double)', 'c_int', 'POINTER(c_double)', 'c_int', 'c_int', 'c_double', 'POINTER(c_int)']),
|
|
107
|
+
'spir_sve_result_from_matrix_centrosymmetric': ('POINTER(struct spir_sve_result)', ['POINTER(c_double)', 'POINTER(c_double)', 'POINTER(c_double)', 'POINTER(c_double)', 'c_int', 'c_int', 'c_int', 'POINTER(c_double)', 'c_int', 'POINTER(c_double)', 'c_int', 'c_int', 'c_double', 'POINTER(c_int)']),
|
|
108
|
+
'spir_sve_result_get_size': ('c_int', ['POINTER(struct spir_sve_result)', 'POINTER(c_int)']),
|
|
109
|
+
'spir_sve_result_get_svals': ('c_int', ['POINTER(struct spir_sve_result)', 'POINTER(c_double)']),
|
|
110
|
+
'spir_sve_result_is_assigned': ('c_int', ['POINTER(struct spir_sve_result)']),
|
|
111
|
+
'spir_sve_result_new': ('POINTER(struct spir_sve_result)', ['POINTER(struct spir_kernel)', 'c_double', 'c_int', 'c_int', 'c_int', 'POINTER(c_int)']),
|
|
112
|
+
'spir_sve_result_release': ('None', ['POINTER(struct spir_sve_result)']),
|
|
113
|
+
'spir_sve_result_truncate': ('POINTER(struct spir_sve_result)', ['POINTER(struct spir_sve_result)', 'c_double', 'c_int', 'POINTER(c_int)']),
|
|
114
|
+
'spir_tau_sampling_new': ('POINTER(struct spir_sampling)', ['POINTER(struct spir_basis)', 'c_int', 'POINTER(c_double)', 'POINTER(c_int)']),
|
|
115
|
+
'spir_tau_sampling_new_with_matrix': ('POINTER(struct spir_sampling)', ['c_int', 'c_int', 'c_int', 'c_int', 'POINTER(c_double)', 'POINTER(c_double)', 'POINTER(c_int)']),
|
|
116
|
+
'spir_uhat_get_default_matsus': ('c_int', ['POINTER(struct spir_funcs)', 'c_int', '_Bool', '_Bool', 'POINTER(c_int64)', 'POINTER(c_int)']),
|
|
117
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Type definitions for the SparseIR C API.
|
|
3
|
+
"""
|
|
4
|
+
|
|
5
|
+
from ctypes import *
|
|
6
|
+
import numpy as np
|
|
7
|
+
|
|
8
|
+
# Define complex type
|
|
9
|
+
c_complex = c_double * 2
|
|
10
|
+
|
|
11
|
+
# Opaque types
|
|
12
|
+
class _spir_kernel(Structure):
|
|
13
|
+
_fields_ = []
|
|
14
|
+
|
|
15
|
+
class _spir_funcs(Structure):
|
|
16
|
+
_fields_ = []
|
|
17
|
+
|
|
18
|
+
class _spir_basis(Structure):
|
|
19
|
+
_fields_ = []
|
|
20
|
+
|
|
21
|
+
class _spir_sampling(Structure):
|
|
22
|
+
_fields_ = []
|
|
23
|
+
|
|
24
|
+
class _spir_sve_result(Structure):
|
|
25
|
+
_fields_ = []
|
|
26
|
+
|
|
27
|
+
class _spir_gemm_backend(Structure):
|
|
28
|
+
_fields_ = []
|
|
29
|
+
|
|
30
|
+
# Type aliases
|
|
31
|
+
spir_kernel = POINTER(_spir_kernel)
|
|
32
|
+
spir_funcs = POINTER(_spir_funcs)
|
|
33
|
+
spir_basis = POINTER(_spir_basis)
|
|
34
|
+
spir_sampling = POINTER(_spir_sampling)
|
|
35
|
+
spir_sve_result = POINTER(_spir_sve_result)
|
|
36
|
+
spir_gemm_backend = POINTER(_spir_gemm_backend)
|
|
37
|
+
|
|
38
|
+
# Additional ctypes definitions
|
|
39
|
+
c_int64 = c_longlong
|
|
40
|
+
|
|
41
|
+
# NumPy dtype mappings
|
|
42
|
+
COMPLEX_DTYPE = np.dtype(np.complex128)
|
|
43
|
+
DOUBLE_DTYPE = np.dtype(np.float64)
|
|
44
|
+
INT64_DTYPE = np.dtype(np.int64)
|
|
Binary file
|