]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/python/test/numpy/ufunc.cpp
1 // Copyright Jim Bosch & Ankit Daftery 2010-2012.
2 // Copyright Stefan Seefeld 2016.
3 // Distributed under the Boost Software License, Version 1.0.
4 // (See accompanying file LICENSE_1_0.txt or copy at
5 // http://www.boost.org/LICENSE_1_0.txt)
7 #include <boost/python/numpy.hpp>
9 namespace p
= boost::python
;
10 namespace np
= boost::python::numpy
;
14 typedef double argument_type
;
15 typedef double result_type
;
17 double operator()(double r
) const { return r
* 2;}
22 typedef double first_argument_type
;
23 typedef double second_argument_type
;
24 typedef double result_type
;
26 double operator()(double a
, double b
) const { return a
* 2 + b
* 3;}
29 BOOST_PYTHON_MODULE(ufunc_ext
)
32 p::class_
<UnaryCallable
>("UnaryCallable")
33 .def("__call__", np::unary_ufunc
<UnaryCallable
>::make());
34 p::class_
< BinaryCallable
>("BinaryCallable")
35 .def("__call__", np::binary_ufunc
<BinaryCallable
>::make());