Go to the documentation of this file.00001
00002
00003
00004
00005
00006 #include <boost/numpy.hpp>
00007 #include <boost/python/slice.hpp>
00008
00009 namespace p = boost::python;
00010 namespace np = boost::numpy;
00011
00012 p::object single(np::ndarray ndarr, int i) { return ndarr[i];}
00013 p::object slice(np::ndarray ndarr, p::slice sl) { return ndarr[sl];}
00014 p::object indexarray(np::ndarray ndarr, np::ndarray d1) { return ndarr[d1];}
00015 p::object indexarray_2d(np::ndarray ndarr, np::ndarray d1,np::ndarray d2) { return ndarr[p::make_tuple(d1,d2)];}
00016 p::object indexslice(np::ndarray ndarr, np::ndarray d1, p::slice sl) { return ndarr[p::make_tuple(d1, sl)];}
00017
00018 BOOST_PYTHON_MODULE(indexing_mod)
00019 {
00020 np::initialize();
00021 p::def("single", single);
00022 p::def("slice", slice);
00023 p::def("indexarray", indexarray);
00024 p::def("indexarray", indexarray_2d);
00025 p::def("indexslice", indexslice);
00026
00027 }