]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/python/src/numpy/ufunc.cpp
add subtree-ish sources for 12.0.3
[ceph.git] / ceph / src / boost / libs / python / src / numpy / ufunc.cpp
1 // Copyright Jim Bosch 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)
6
7 #define BOOST_PYTHON_NUMPY_INTERNAL
8 #include <boost/python/numpy/internal.hpp>
9 #include <boost/python/numpy/ufunc.hpp>
10
11 namespace boost { namespace python {
12 namespace converter
13 {
14 NUMPY_OBJECT_MANAGER_TRAITS_IMPL(PyArrayMultiIter_Type, numpy::multi_iter)
15 } // namespace boost::python::converter
16
17 namespace numpy
18 {
19
20 multi_iter make_multi_iter(object const & a1)
21 {
22 return multi_iter(python::detail::new_reference(PyArray_MultiIterNew(1, a1.ptr())));
23 }
24
25 multi_iter make_multi_iter(object const & a1, object const & a2)
26 {
27 return multi_iter(python::detail::new_reference(PyArray_MultiIterNew(2, a1.ptr(), a2.ptr())));
28 }
29
30 multi_iter make_multi_iter(object const & a1, object const & a2, object const & a3)
31 {
32 return multi_iter(python::detail::new_reference(PyArray_MultiIterNew(3, a1.ptr(), a2.ptr(), a3.ptr())));
33 }
34
35 void multi_iter::next()
36 {
37 PyArray_MultiIter_NEXT(ptr());
38 }
39
40 bool multi_iter::not_done() const
41 {
42 return PyArray_MultiIter_NOTDONE(ptr());
43 }
44
45 char * multi_iter::get_data(int i) const
46 {
47 return reinterpret_cast<char*>(PyArray_MultiIter_DATA(ptr(), i));
48 }
49
50 int multi_iter::get_nd() const
51 {
52 return reinterpret_cast<PyArrayMultiIterObject*>(ptr())->nd;
53 }
54
55 Py_intptr_t const * multi_iter::get_shape() const
56 {
57 return reinterpret_cast<PyArrayMultiIterObject*>(ptr())->dimensions;
58 }
59
60 Py_intptr_t multi_iter::shape(int n) const
61 {
62 return reinterpret_cast<PyArrayMultiIterObject*>(ptr())->dimensions[n];
63 }
64
65 }}} // namespace boost::python::numpy