dtype_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/cstdint.hpp>
00008 
00009 namespace p = boost::python;
00010 namespace np = boost::numpy;
00011 
00012 template <typename T>
00013 np::dtype accept(T) {
00014   return np::dtype::get_builtin<T>();
00015 }
00016 
00017 BOOST_PYTHON_MODULE(dtype_mod) 
00018 {
00019   np::initialize();
00020   // wrap dtype equivalence test, since it isn't available in Python API.
00021   p::def("equivalent", np::equivalent);
00022   // integers, by number of bits
00023   p::def("accept_int8", accept<boost::int8_t>);
00024   p::def("accept_uint8", accept<boost::uint8_t>);
00025   p::def("accept_int16", accept<boost::int16_t>);
00026   p::def("accept_uint16", accept<boost::uint16_t>);
00027   p::def("accept_int32", accept<boost::int32_t>);
00028   p::def("accept_uint32", accept<boost::uint32_t>);
00029   p::def("accept_int64", accept<boost::int64_t>);
00030   p::def("accept_uint64", accept<boost::uint64_t>);
00031   // integers, by C name according to NumPy
00032   p::def("accept_bool_", accept<bool>);
00033   p::def("accept_byte", accept<signed char>);
00034   p::def("accept_ubyte", accept<unsigned char>);
00035   p::def("accept_short", accept<short>);
00036   p::def("accept_ushort", accept<unsigned short>);
00037   p::def("accept_intc", accept<int>);
00038   p::def("accept_uintc", accept<unsigned int>);
00039   // floats and complex
00040   p::def("accept_float32", accept<float>);
00041   p::def("accept_complex64", accept< std::complex<float> >);
00042   p::def("accept_float64", accept<double>);
00043   p::def("accept_complex128", accept< std::complex<double> >);
00044   if (sizeof(long double) > sizeof(double)) {
00045       p::def("accept_longdouble", accept<long double>);
00046       p::def("accept_clongdouble", accept< std::complex<long double> >);
00047   }
00048 }


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