mirror of
https://github.com/boostorg/python.git
synced 2026-01-20 16:52:15 +00:00
23 lines
760 B
C++
23 lines
760 B
C++
#include <boost/numpy.hpp>
|
|
#include <boost/python/slice.hpp>
|
|
|
|
namespace p = boost::python;
|
|
namespace np = boost::numpy;
|
|
|
|
p::object single(np::ndarray ndarr, int i) { return ndarr[i];}
|
|
p::object slice(np::ndarray ndarr, p::slice sl) { return ndarr[sl];}
|
|
p::object indexarray(np::ndarray ndarr, np::ndarray d1) { return ndarr[d1];}
|
|
//p::object indexarray_2d(np::ndarray ndarr, np::ndarray d1,np::ndarray d2) { return ndarr[d1,d2];}
|
|
//p::object indexslice(np::ndarray ndarr, np::ndarray d1, p::slice sl) { return ndarr[d1][sl];}
|
|
|
|
BOOST_PYTHON_MODULE(indexing_mod)
|
|
{
|
|
np::initialize();
|
|
p::def("single", single);
|
|
p::def("slice", slice);
|
|
p::def("indexarray", indexarray);
|
|
// p::def("indexarray", indexarray_2d);
|
|
// p::def("indexslice", indexslice);
|
|
|
|
}
|