5 #ifndef __eigenpy_numpy_hpp__
6 #define __eigenpy_numpy_hpp__
10 #ifndef PY_ARRAY_UNIQUE_SYMBOL
11 #define PY_ARRAY_UNIQUE_SYMBOL EIGENPY_ARRAY_API
14 #include <numpy/numpyconfig.h>
15 #ifdef NPY_1_8_API_VERSION
16 #define NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION
23 #if NPY_ABI_VERSION < 0x02000000
24 #define PyArray_DescrProto PyArray_Descr
27 #include <numpy/ndarrayobject.h>
28 #include <numpy/ufuncobject.h>
30 #if NPY_ABI_VERSION < 0x02000000
39 #if PY_VERSION_HEX < 0x030900A4 && !defined(Py_SET_TYPE)
43 #define Py_SET_TYPE(o, type) _Py_SET_TYPE((PyObject*)(o), type)
46 #if defined _WIN32 || defined __CYGWIN__
47 #define EIGENPY_GET_PY_ARRAY_TYPE(array) \
48 call_PyArray_MinScalarType(array)->type_num
50 #define EIGENPY_GET_PY_ARRAY_TYPE(array) PyArray_MinScalarType(array)->type_num
58 template <
typename Scalar>
101 #if defined _WIN32 || defined __CYGWIN__
104 struct NumpyEquivalentType<long> {
108 struct NumpyEquivalentType<unsigned long> {
125 #if defined __APPLE__
128 struct NumpyEquivalentType<long> {
132 struct NumpyEquivalentType<unsigned long> {
140 #if defined __linux__
143 struct NumpyEquivalentType<long long> {
147 struct NumpyEquivalentType<unsigned long long> {
179 template <
typename Scalar>
188 #if defined _WIN32 || defined __CYGWIN__
194 EIGENPY_DLLAPI PyObject*
call_PyArray_New(PyTypeObject* py_type_ptr,
int nd,
195 npy_intp* shape,
int np_type,
196 void* data_ptr,
int options);
198 EIGENPY_DLLAPI PyObject*
call_PyArray_New(PyTypeObject* py_type_ptr,
int nd,
199 npy_intp* shape,
int np_type,
200 npy_intp* strides,
void* data_ptr,
215 NPY_SCALARKIND scalar);
220 PyArray_Descr* descr,
int totype, PyArray_VectorUnaryFunc* castfunc);
223 return PyArray_Check(py_obj);
227 return PyArray_SimpleNew(nd, shape, np_type);
231 npy_intp* shape,
int np_type,
void* data_ptr,
233 return PyArray_New(py_type_ptr, nd, shape, np_type, NULL, data_ptr, 0,
238 npy_intp* shape,
int np_type,
239 npy_intp* strides,
void* data_ptr,
241 return PyArray_New(py_type_ptr, nd, shape, np_type, strides, data_ptr, 0,
246 return PyArray_ObjectType(obj, val);
252 return PyArray_DescrFromType(typenum);
256 PyArray_InitArrFuncs(funcs);
260 return PyArray_RegisterDataType(dtype);
264 return PyArray_MinScalarType(arr);
268 NPY_SCALARKIND scalar) {
269 return PyArray_RegisterCanCast(descr, totype, scalar);
273 PyArray_VectorUnaryFunc* castfunc) {
274 return PyArray_RegisterCastFunc(descr, totype, castfunc);
279 #endif // ifndef __eigenpy_numpy_hpp__