differintC 0.0.1__cp313-cp313-win_amd64.whl → 0.0.2__cp313-cp313-win_amd64.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.
differintC/__init__.py ADDED
@@ -0,0 +1,80 @@
1
+ import os
2
+ import sys
3
+ import ctypes
4
+ from pathlib import Path
5
+ import importlib.resources
6
+ import warnings
7
+
8
+
9
+ def _load_dll():
10
+ if sys.platform != "win32":
11
+ return
12
+
13
+ # Get package directory
14
+ package_dir = Path(__file__).parent
15
+
16
+ # 1. Try package directory (where __init__.py is)
17
+ dll_path = package_dir / "libfftw3-3.dll"
18
+ if dll_path.exists():
19
+ os.add_dll_directory(str(package_dir))
20
+ print(f"Loaded FFTW DLL from package directory: {dll_path}")
21
+ return
22
+
23
+ # 2. Try site-packages root directory
24
+ site_packages_dll = package_dir.parent / "libfftw3-3.dll"
25
+ if site_packages_dll.exists():
26
+ os.add_dll_directory(str(site_packages_dll.parent))
27
+ print(f"Loaded FFTW DLL from site-packages root: {site_packages_dll}")
28
+ return
29
+
30
+ # 3. Try using importlib.resources
31
+ try:
32
+ with importlib.resources.path("differintC", "libfftw3-3.dll") as dll_path:
33
+ if dll_path.exists():
34
+ os.add_dll_directory(str(dll_path.parent))
35
+ print(f"Loaded FFTW DLL via importlib: {dll_path}")
36
+ return
37
+ except Exception as e:
38
+ warnings.warn(f"importlib.resources failed: {e}")
39
+
40
+ # 4. Try Windows system directory
41
+ system_dll = Path("C:/Windows/System32") / "libfftw3-3.dll"
42
+ if system_dll.exists():
43
+ os.add_dll_directory(str(system_dll.parent))
44
+ print(f"Loaded FFTW DLL from system directory: {system_dll}")
45
+ return
46
+
47
+ # 5. Try loading directly (if in PATH)
48
+ try:
49
+ ctypes.CDLL("libfftw3-3.dll")
50
+ print("Loaded FFTW DLL directly from PATH")
51
+ return
52
+ except OSError:
53
+ pass
54
+
55
+ # If all else fails
56
+ raise RuntimeError(
57
+ "FFTW DLL not found! Checked locations:\n"
58
+ + f"1. Package directory: {package_dir}/libfftw3-3.dll\n"
59
+ + f"2. Site-packages root: {package_dir.parent}/libfftw3-3.dll\n"
60
+ + f"3. System directory: C:/Windows/System32/libfftw3-3.dll"
61
+ )
62
+
63
+
64
+ # Load DLL before importing C++ module
65
+ try:
66
+ _load_dll()
67
+ except RuntimeError as e:
68
+ print(f"FFTW DLL loading failed: {e}")
69
+ # Try to proceed anyway - might be available in PATH
70
+ try:
71
+ ctypes.CDLL("libfftw3-3.dll")
72
+ print("Successfully loaded FFTW DLL after initial failure")
73
+ except OSError:
74
+ raise
75
+
76
+ # Import the C++ extension
77
+ from differintC import * # Directly import from site-packages
78
+
79
+ # Add version attribute
80
+ __version__ = "0.0.2"
Binary file
Binary file
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: differintC
3
- Version: 0.0.1
3
+ Version: 0.0.2
4
4
  Summary: Fast C++ implementation of fractional calculus operators via pybind11
5
5
  Author: Parsa Roshanak
6
6
  License: MIT
@@ -0,0 +1,7 @@
1
+ differintC/__init__.py,sha256=3S0KJat-cNbhGuzPDJ--skatjDg05e8FyX8MwURX-_U,2521
2
+ differintC/libfftw3-3.dll,sha256=ABqDXS8lrAZhWA1n21YiFXwoSBwGp_PvRa2TmDm_VKE,2712765
3
+ differintC/libfftw3-3.lib,sha256=O1n7vwNRUjJuvlQ91RWn7xDXMD8PYDM0dHXXETX_ruo,241990
4
+ differintc-0.0.2.dist-info/METADATA,sha256=cZMvoN1HL9Gwg0-YLTIieH_vuNj64rW8Xy7ftu69Cwg,3285
5
+ differintc-0.0.2.dist-info/WHEEL,sha256=_PdgJ-W7uMAsWwnGnEdiicDU_PKcobRdffEM23gmN6g,106
6
+ differintc-0.0.2.dist-info/licenses/LICENSE,sha256=jqB4xKqXwsqHxw3nhNfX51kOCtYhxNDQFqCIl5Qj8h4,1091
7
+ differintc-0.0.2.dist-info/RECORD,,
@@ -1,6 +0,0 @@
1
- python/CMakeLists.txt,sha256=YH4PMGwp8NqUb5ZsKmOjtoRmwdjqAr9T8bcRf59sJcE,401
2
- python/module.cpp,sha256=2ptoCWNYUXnhYlJfxMm_q6NM66goo1lB9WV6mbysTF0,5663
3
- differintc-0.0.1.dist-info/METADATA,sha256=TPcJPxQPP4AAdefMQfHPLoj-i-IjFkDpx0ixQbe0rh8,3285
4
- differintc-0.0.1.dist-info/WHEEL,sha256=_PdgJ-W7uMAsWwnGnEdiicDU_PKcobRdffEM23gmN6g,106
5
- differintc-0.0.1.dist-info/licenses/LICENSE,sha256=jqB4xKqXwsqHxw3nhNfX51kOCtYhxNDQFqCIl5Qj8h4,1091
6
- differintc-0.0.1.dist-info/RECORD,,
python/CMakeLists.txt DELETED
@@ -1,17 +0,0 @@
1
- pybind11_add_module(differintC module.cpp ../src/differint.cpp)
2
-
3
- target_include_directories(differintC
4
- PRIVATE ${CMAKE_SOURCE_DIR}/include
5
- )
6
-
7
- target_link_libraries(differintC
8
- PRIVATE differint_core
9
- )
10
-
11
- set_target_properties(differintC PROPERTIES
12
- PREFIX ""
13
- SUFFIX ".pyd"
14
- )
15
-
16
- install(TARGETS differintC
17
- LIBRARY DESTINATION ${CMAKE_INSTALL_PREFIX}/Lib/site-packages)
python/module.cpp DELETED
@@ -1,110 +0,0 @@
1
- #include <pybind11/stl.h>
2
- #include <pybind11/pybind11.h>
3
- #include <pybind11/numpy.h>
4
- #include <vector>
5
- #include <stdexcept>
6
-
7
- namespace py = pybind11;
8
-
9
- namespace differint {
10
- std::vector<double> RL(double, const std::vector<double>&, double, double, size_t);
11
- double RLpoint(double, const std::vector<double>&, double, double, size_t);
12
- std::vector<double> GL(double, const std::vector<double>&, double, double, size_t);
13
- double GLpoint(double, const std::vector<double>&, double, double, size_t);
14
- }
15
- using namespace differint;
16
-
17
-
18
-
19
- // Helper to sample a Python callable into a std::vector<double>
20
- template <typename Func>
21
- std::vector<double> call_and_sample(Func&& f, double a, double b, size_t n) {
22
- std::vector<double> vals(n);
23
- double step = (b - a) / (n - 1);
24
- for (size_t i = 0; i < n; ++i)
25
- vals[i] = f(a + step * i);
26
- return vals;
27
- }
28
-
29
- // Overload 1: Input is a NumPy array or list (accept py::array_t<double>)
30
- std::vector<double> prepare_fvals(py::array_t<double> arr, size_t expected_size) {
31
- if (arr.size() != expected_size)
32
- throw std::runtime_error("Input array length must equal num_points");
33
- // Copy data from NumPy array (you could do zero-copy with caution, but copying is safer here)
34
- std::vector<double> v(arr.size());
35
- std::memcpy(v.data(), arr.data(), sizeof(double) * arr.size());
36
- return v;
37
- }
38
-
39
- // Overload 2: Input is a Python callable (py::function)
40
- std::vector<double> prepare_fvals(py::function func, double a, double b, size_t n) {
41
- return call_and_sample([&func](double x) {
42
- return func(x).cast<double>();
43
- }, a, b, n);
44
- }
45
-
46
-
47
-
48
-
49
-
50
- PYBIND11_MODULE(differintC, m) {
51
- m.doc() = "Fast fractional calculus operators in C++ with Python bindings";
52
-
53
- // RL (whole array)
54
- m.def("RL", [](double alpha, py::object f, double domain_start, double domain_end, size_t num_points) {
55
- // Dispatch based on type
56
- if (py::isinstance<py::array>(f)) {
57
- return RL(alpha, prepare_fvals(f.cast<py::array_t<double>>(), num_points), domain_start, domain_end, num_points);
58
- } else if (py::isinstance<py::function>(f)) {
59
- return RL(alpha, prepare_fvals(f.cast<py::function>(), domain_start, domain_end, num_points), domain_start, domain_end, num_points);
60
- } else if (py::isinstance<py::list>(f)) {
61
- // treat list as array
62
- return RL(alpha, prepare_fvals(f.cast<py::array_t<double>>(), num_points), domain_start, domain_end, num_points);
63
- } else {
64
- throw std::runtime_error("Unsupported input type for function f");
65
- }
66
- }, py::arg("alpha"), py::arg("f"), py::arg("domain_start") = 0.0, py::arg("domain_end") = 1.0, py::arg("num_points") = 100);
67
-
68
- // RLpoint (single point)
69
- m.def("RLpoint", [](double alpha, py::object f, double domain_start, double domain_end, size_t num_points) {
70
- if (py::isinstance<py::array>(f)) {
71
- return RLpoint(alpha, prepare_fvals(f.cast<py::array_t<double>>(), num_points), domain_start, domain_end, num_points);
72
- } else if (py::isinstance<py::function>(f)) {
73
- return RLpoint(alpha, prepare_fvals(f.cast<py::function>(), domain_start, domain_end, num_points), domain_start, domain_end, num_points);
74
- } else if (py::isinstance<py::list>(f)) {
75
- return RLpoint(alpha, prepare_fvals(f.cast<py::array_t<double>>(), num_points), domain_start, domain_end, num_points);
76
- } else {
77
- throw std::runtime_error("Unsupported input type for function f");
78
- }
79
- }, py::arg("alpha"), py::arg("f"), py::arg("domain_start") = 0.0, py::arg("domain_end") = 1.0, py::arg("num_points") = 100);
80
-
81
-
82
-
83
- m.def("GL", [](double alpha, py::object f, double domain_start, double domain_end, size_t num_points) {
84
- // Dispatch based on type
85
- if (py::isinstance<py::array>(f)) {
86
- return GL(alpha, prepare_fvals(f.cast<py::array_t<double>>(), num_points), domain_start, domain_end, num_points);
87
- } else if (py::isinstance<py::function>(f)) {
88
- return GL(alpha, prepare_fvals(f.cast<py::function>(), domain_start, domain_end, num_points), domain_start, domain_end, num_points);
89
- } else if (py::isinstance<py::list>(f)) {
90
- // treat list as array
91
- return GL(alpha, prepare_fvals(f.cast<py::array_t<double>>(), num_points), domain_start, domain_end, num_points);
92
- } else {
93
- throw std::runtime_error("Unsupported input type for function f");
94
- }
95
- }, py::arg("alpha"), py::arg("f"), py::arg("domain_start") = 0.0, py::arg("domain_end") = 1.0, py::arg("num_points") = 100);
96
-
97
- // GLpoint (single point)
98
- m.def("GLpoint", [](double alpha, py::object f, double domain_start, double domain_end, size_t num_points) {
99
- if (py::isinstance<py::array>(f)) {
100
- return GLpoint(alpha, prepare_fvals(f.cast<py::array_t<double>>(), num_points), domain_start, domain_end, num_points);
101
- } else if (py::isinstance<py::function>(f)) {
102
- return GLpoint(alpha, prepare_fvals(f.cast<py::function>(), domain_start, domain_end, num_points), domain_start, domain_end, num_points);
103
- } else if (py::isinstance<py::list>(f)) {
104
- return GLpoint(alpha, prepare_fvals(f.cast<py::array_t<double>>(), num_points), domain_start, domain_end, num_points);
105
- } else {
106
- throw std::runtime_error("Unsupported input type for function f");
107
- }
108
- }, py::arg("alpha"), py::arg("f"), py::arg("domain_start") = 0.0, py::arg("domain_end") = 1.0, py::arg("num_points") = 100);
109
-
110
- }