]>
git.proxmox.com Git - ceph.git/blob - 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)
7 #define BOOST_PYTHON_NUMPY_INTERNAL
8 #include <boost/python/numpy/internal.hpp>
9 #include <boost/python/numpy/ufunc.hpp>
11 namespace boost
{ namespace python
{
14 NUMPY_OBJECT_MANAGER_TRAITS_IMPL(PyArrayMultiIter_Type
, numpy::multi_iter
)
15 } // namespace boost::python::converter
20 multi_iter
make_multi_iter(object
const & a1
)
22 return multi_iter(python::detail::new_reference(PyArray_MultiIterNew(1, a1
.ptr())));
25 multi_iter
make_multi_iter(object
const & a1
, object
const & a2
)
27 return multi_iter(python::detail::new_reference(PyArray_MultiIterNew(2, a1
.ptr(), a2
.ptr())));
30 multi_iter
make_multi_iter(object
const & a1
, object
const & a2
, object
const & a3
)
32 return multi_iter(python::detail::new_reference(PyArray_MultiIterNew(3, a1
.ptr(), a2
.ptr(), a3
.ptr())));
35 void multi_iter::next()
37 PyArray_MultiIter_NEXT(ptr());
40 bool multi_iter::not_done() const
42 return PyArray_MultiIter_NOTDONE(ptr());
45 char * multi_iter::get_data(int i
) const
47 return reinterpret_cast<char*>(PyArray_MultiIter_DATA(ptr(), i
));
50 int multi_iter::get_nd() const
52 return reinterpret_cast<PyArrayMultiIterObject
*>(ptr())->nd
;
55 Py_intptr_t
const * multi_iter::get_shape() const
57 return reinterpret_cast<PyArrayMultiIterObject
*>(ptr())->dimensions
;
60 Py_intptr_t
multi_iter::shape(int n
) const
62 return reinterpret_cast<PyArrayMultiIterObject
*>(ptr())->dimensions
[n
];
65 }}} // namespace boost::python::numpy