numpy.hpp 1.41 KB
Newer Older
1
2
3
4
5
6
7
/*
 * Copyright 2020 INRIA
 */

#ifndef __eigenpy_numpy_hpp__
#define __eigenpy_numpy_hpp__

Justin Carpentier's avatar
Justin Carpentier committed
8
#include <boost/python.hpp>
9
10
#include "eigenpy/config.hpp"

11
12
13
14
15
16
17
18
19
20
21
#ifndef PY_ARRAY_UNIQUE_SYMBOL
  #define PY_ARRAY_UNIQUE_SYMBOL EIGENPY_ARRAY_API
#endif

#include <numpy/numpyconfig.h>
#ifdef NPY_1_8_API_VERSION
  #define NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION
#endif

#include <numpy/noprefix.h>

Justin Carpentier's avatar
Justin Carpentier committed
22
23
24
25
26
27
28
#if defined _WIN32 || defined __CYGWIN__
  #define EIGENPY_GET_PY_ARRAY_TYPE(array) \
    call_PyArray_ObjectType(reinterpret_cast<PyObject *>(array), 0)
#else
  #define EIGENPY_GET_PY_ARRAY_TYPE(array) \
    PyArray_ObjectType(reinterpret_cast<PyObject *>(array), 0)
#endif
29

30
31
namespace eigenpy
{
32
  void EIGENPY_DLLEXPORT import_numpy();
33
34
}

Justin Carpentier's avatar
Justin Carpentier committed
35
36
37
#if defined _WIN32 || defined __CYGWIN__
namespace eigenpy
{
38
  EIGENPY_DLLEXPORT PyObject* call_PyArray_SimpleNew(int nd, npy_intp * shape, int np_type);
Justin Carpentier's avatar
Justin Carpentier committed
39

40
  EIGENPY_DLLEXPORT PyObject* call_PyArray_New(PyTypeObject * py_type_ptr, int nd, npy_intp * shape, int np_type, void * data_ptr, int options);
Justin Carpentier's avatar
Justin Carpentier committed
41
42

  EIGENPY_DLLEXPORT int call_PyArray_ObjectType(PyObject *, int);
43
44

  EIGENPY_DLLEXPORT PyTypeObject getPyArrayType();
Justin Carpentier's avatar
Justin Carpentier committed
45
46
47
}
#else
  #define call_PyArray_SimpleNew PyArray_SimpleNew
48
49
  #define call_PyArray_New(py_type_ptr,nd,shape,np_type,data_ptr,options) \
    PyArray_New(py_type_ptr,nd,shape,np_type,NULL,data_ptr,0,options,NULL)
50
  #define getPyArrayType() PyArray_Type
Justin Carpentier's avatar
Justin Carpentier committed
51
52
#endif

53
#endif // ifndef __eigenpy_numpy_hpp__