summaryrefslogtreecommitdiff
path: root/bindings/galearn_pdm.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'bindings/galearn_pdm.cpp')
-rw-r--r--bindings/galearn_pdm.cpp29
1 files changed, 29 insertions, 0 deletions
diff --git a/bindings/galearn_pdm.cpp b/bindings/galearn_pdm.cpp
new file mode 100644
index 0000000..9274a01
--- /dev/null
+++ b/bindings/galearn_pdm.cpp
@@ -0,0 +1,29 @@
+#include <pybind11/pybind11.h>
+#include <pybind11/numpy.h>
+
+namespace py = pybind11;
+
+void process(py::array_t<uint8_t> arr1, py::array_t<int16_t> arr2) {
+ // Check shapes or sizes if needed
+ auto buf1 = arr1.request();
+ auto buf2 = arr2.request();
+
+ if (buf1.ndim != 1 || buf2.ndim != 1) {
+ throw std::runtime_error("Only 1D arrays supported");
+ }
+
+ if (buf1.size < buf2.size) {
+ throw std::runtime_error("Input 1 must be same or larger than input 2");
+ }
+
+ // Example: access data
+ uint8_t* in = static_cast<uint8_t*>(buf1.ptr);
+ int16_t* out = static_cast<int16_t*>(buf2.ptr);
+ for (int i=0; i<buf2.size; i++) {
+ out[i] = in[i] + 1;
+ }
+}
+
+PYBIND11_MODULE(galearn_pdm, m) {
+ m.def("process", &process, "Process two numpy arrays (uint8 and int16)");
+}