forked from pybind/python_example
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
38 lines (29 loc) · 742 Bytes
/
main.cpp
File metadata and controls
38 lines (29 loc) · 742 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#include <pybind11/pybind11.h>
#include <pybind11/numpy.h>
#include "cga.h"
namespace py = pybind11;
py::array basic_op(py::array xs, py::array ys){
/* A basic operation */
CGA a = CGA::from_np_array(xs);
CGA b = CGA::from_np_array(ys);
CGA res = ((a|b)*b);
CGA res2 = res*res;
return res2.to_np_array();
}
PYBIND11_MODULE(cga_cpp, m) {
m.doc() = R"pbdoc(
Pybind11 example plugin
-----------------------
.. currentmodule:: cga_cpp
.. autosummary::
:toctree: _generate
add
subtract
)pbdoc";
m.def("basic_op", &basic_op);
#ifdef VERSION_INFO
m.attr("__version__") = VERSION_INFO;
#else
m.attr("__version__") = "dev";
#endif
}