numpy.hpp 1.3 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
{
Justin Carpentier's avatar
Justin Carpentier committed
38
  EIGENPY_DLLEXPORT PyObject*  call_PyArray_SimpleNew(int nd, npy_intp * shape, NPY_TYPES np_type);
Justin Carpentier's avatar
Justin Carpentier committed
39

Justin Carpentier's avatar
Justin Carpentier committed
40
  EIGENPY_DLLEXPORT PyObject* call_PyArray_New(int nd, npy_intp * shape, NPY_TYPES np_type, void * data_ptr, int options);
Justin Carpentier's avatar
Justin Carpentier committed
41
42
43
44
45
46
47
48
49

  EIGENPY_DLLEXPORT int call_PyArray_ObjectType(PyObject *, int);
}
#else
  #define call_PyArray_SimpleNew PyArray_SimpleNew
  #define call_PyArray_New(nd,shape,np_type,data_ptr,options) \
    PyArray_New(&PyArray_Type,nd,shape,np_type,NULL,data_ptr,0,options,NULL)
#endif

50
#endif // ifndef __eigenpy_numpy_hpp__