forked from harperj/KDTSpecializer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_cpp_file.cpp
45 lines (37 loc) · 915 Bytes
/
test_cpp_file.cpp
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
39
40
41
42
43
44
45
#include <boost/python.hpp>
#include "/home/harper/Documents/Work/SEJITS/pyCombBLAS/trunk/kdt/pyCombBLAS/pyOperations.h"
#include <stdint.h>
#include "test_cpp_file.h"
using namespace boost::python;
namespace op
{
template <typename T>
struct my_op_s : public ConcreteUnaryFunction<T>
{
T operator()(const T& x) const
{
return (x < 0) ? -static_cast<doubleint>(x) : x;
}
};
UnaryFunction my_op()
{
return UnaryFunction(new my_op_s<doubleint>());
}
}
/*
PyObject* my_op_py(object x)
{
//float val = extract<float>(x.attr("__float__"));
double f = extract<double>(x);
if(f < 0) f = -f;
PyObject* ret = PyFloat_FromDouble(f);
return ret;
}
BOOST_PYTHON_MODULE(module)
{
//class_<op::UnaryFunction>("UnaryFunction", init<op::ConcreteUnaryFunction<doubleint>*>());
//def("my_op", &op::my_op);
//def("apply_my_op", &apply_my_op);
def("my_op_py", &my_op_py);
}
*/