Michele De Stefano's C++ Utilities
Main Page
Modules
Namespaces
Classes
Files
Examples
File List
File Members
traits.hpp
Go to the documentation of this file.
1
// mds_utils/python/numpy/traits.hpp
2
//
3
// Copyright (c) 2014 - Michele De Stefano (micdestefano@users.sourceforge.net)
4
//
5
// Distributed under the MIT License (See accompanying file LICENSE)
6
7
#ifndef MDS_UTILS_PYTHON_NUMPY_TRAITS_HPP_INCLUDED
8
#define MDS_UTILS_PYTHON_NUMPY_TRAITS_HPP_INCLUDED
9
10
#include <numpy/arrayobject.h>
11
#include <boost/preprocessor/seq/for_each.hpp>
12
#include <boost/preprocessor/tuple/elem.hpp>
13
#include <complex>
14
31
namespace
mds_utils
{
32
namespace
python {
33
namespace
numpy {
47
template
<
class
T>
48
struct
numpy_dtype_traits
;
49
51
52
#define SEQ_TYPE_NPYDTYPE_TYPENUM_TUPLES \
53
((bool,npy_bool,NPY_BOOL))((char,npy_byte,NPY_BYTE)) \
54
((short,npy_short,NPY_SHORT))((int,npy_int,NPY_INT)) \
55
((long,npy_long,NPY_LONG))((long long,npy_longlong,NPY_LONGLONG)) \
56
((unsigned char,npy_ubyte,NPY_UBYTE)) \
57
((unsigned short,npy_short,NPY_USHORT)) \
58
((unsigned int,npy_uint,NPY_UINT)) \
59
((unsigned long,npy_ulong,NPY_ULONG))\
60
((unsigned long long,npy_ulonglong,NPY_ULONGLONG)) \
61
((float,npy_float,NPY_FLOAT))((double,npy_double,NPY_DOUBLE)) \
62
((long double,npy_longdouble,NPY_LONGDOUBLE)) \
63
((std::complex<float>,npy_cfloat,NPY_CFLOAT)) \
64
((std::complex<double>,npy_cdouble,NPY_CDOUBLE)) \
65
((std::complex<long double>,npy_clongdouble,NPY_CLONGDOUBLE))
66
67
#define numpy_dtype_traits_DEFSPEC_GEN(r,data,elem) \
68
template<> \
69
struct numpy_dtype_traits< BOOST_PP_TUPLE_ELEM(3,0,elem) > { \
70
typedef BOOST_PP_TUPLE_ELEM(3,1,elem) type; \
71
static const int typenum = BOOST_PP_TUPLE_ELEM(3,2,elem); \
72
};
73
74
BOOST_PP_SEQ_FOR_EACH(numpy_dtype_traits_DEFSPEC_GEN,~,SEQ_TYPE_NPYDTYPE_TYPENUM_TUPLES)
75
76
78
}
// namespace numpy
79
}
// namespace python
80
}
// namespace mds_utils
81
82
83
#endif
/* MDS_UTILS_PYTHON_NUMPY_TRAITS_HPP_INCLUDED */
mds_utils
Main namespace of all Michele De Stefano's C++ utilities.
Definition:
endian.hpp:30
mds_utils::python::numpy::numpy_dtype_traits
Provides traits for a specific C/C++ datatype.
Definition:
traits.hpp:48
include
mds_utils
python
numpy
traits.hpp
Generated by
1.8.11