indexing_mod.cpp
Go to the documentation of this file.
00001 // Copyright Jim Bosch & Ankit Daftery 2010-2012.
00002 // Distributed under the Boost Software License, Version 1.0.
00003 //    (See accompanying file LICENSE_1_0.txt or copy at
00004 //          http://www.boost.org/LICENSE_1_0.txt)
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 }


boost_numpy
Author(s): Jim Bosch, Ankit Daftery
autogenerated on Fri Aug 28 2015 10:10:40