numpy.cpp
Go to the documentation of this file.
1 /*
2  * Copyright 2020-2022 INRIA
3  */
4 
5 #include "eigenpy/numpy.hpp"
6 
7 namespace eigenpy {
8 void import_numpy() {
9  if (_import_array() < 0) {
10  PyErr_Print();
11  PyErr_SetString(PyExc_ImportError,
12  "numpy.core.multiarray failed to import");
13  }
14 }
15 
16 int PyArray_TypeNum(PyTypeObject* type) {
17  return PyArray_TypeNumFromName(const_cast<char*>(type->tp_name));
18 }
19 
20 #if defined _WIN32 || defined __CYGWIN__
21 
22 bool call_PyArray_Check(PyObject* py_obj) { return PyArray_Check(py_obj); }
23 
24 PyObject* call_PyArray_SimpleNew(int nd, npy_intp* shape, int np_type) {
25  return PyArray_SimpleNew(nd, shape, np_type);
26 }
27 
28 PyObject* call_PyArray_New(PyTypeObject* py_type_ptr, int nd, npy_intp* shape,
29  int np_type, void* data_ptr, int options) {
30  return PyArray_New(py_type_ptr, nd, shape, np_type, NULL, data_ptr, 0,
31  options, NULL);
32 }
33 
34 PyObject* call_PyArray_New(PyTypeObject* py_type_ptr, int nd, npy_intp* shape,
35  int np_type, npy_intp* strides, void* data_ptr,
36  int options) {
37  return PyArray_New(py_type_ptr, nd, shape, np_type, strides, data_ptr, 0,
38  options, NULL);
39 }
40 
41 int call_PyArray_ObjectType(PyObject* obj, int val) {
42  return PyArray_ObjectType(obj, val);
43 }
44 
45 PyTypeObject* getPyArrayType() { return &PyArray_Type; }
46 
47 PyArray_Descr* call_PyArray_DescrFromType(int typenum) {
48  return PyArray_DescrFromType(typenum);
49 }
50 
51 void call_PyArray_InitArrFuncs(PyArray_ArrFuncs* funcs) {
52  PyArray_InitArrFuncs(funcs);
53 }
54 
55 int call_PyArray_RegisterDataType(PyArray_Descr* dtype) {
56  return PyArray_RegisterDataType(dtype);
57 }
58 
59 PyArray_Descr* call_PyArray_MinScalarType(PyArrayObject* arr) {
60  return PyArray_MinScalarType(arr);
61 }
62 
63 int call_PyArray_RegisterCanCast(PyArray_Descr* descr, int totype,
64  NPY_SCALARKIND scalar) {
65  return PyArray_RegisterCanCast(descr, totype, scalar);
66 }
67 
68 int call_PyArray_RegisterCastFunc(PyArray_Descr* descr, int totype,
69  PyArray_VectorUnaryFunc* castfunc) {
70  return PyArray_RegisterCastFunc(descr, totype, castfunc);
71 }
72 
73 #endif
74 } // namespace eigenpy
bool call_PyArray_Check(PyObject *py_obj)
Definition: numpy.hpp:136
void EIGENPY_DLLAPI import_numpy()
Definition: numpy.cpp:8
PyObject * call_PyArray_SimpleNew(int nd, npy_intp *shape, int np_type)
Definition: numpy.hpp:140
PyObject * call_PyArray_New(PyTypeObject *py_type_ptr, int nd, npy_intp *shape, int np_type, void *data_ptr, int options)
Definition: numpy.hpp:144
int call_PyArray_RegisterCastFunc(PyArray_Descr *descr, int totype, PyArray_VectorUnaryFunc *castfunc)
Definition: numpy.hpp:186
int call_PyArray_RegisterCanCast(PyArray_Descr *descr, int totype, NPY_SCALARKIND scalar)
Definition: numpy.hpp:181
PyArray_Descr * call_PyArray_MinScalarType(PyArrayObject *arr)
Definition: numpy.hpp:177
int call_PyArray_ObjectType(PyObject *obj, int val)
Definition: numpy.hpp:159
int call_PyArray_RegisterDataType(PyArray_Descr *dtype)
Definition: numpy.hpp:173
PyTypeObject * getPyArrayType()
Definition: numpy.hpp:163
PyArray_Descr * call_PyArray_DescrFromType(int typenum)
Definition: numpy.hpp:165
void call_PyArray_InitArrFuncs(PyArray_ArrFuncs *funcs)
Definition: numpy.hpp:169
int EIGENPY_DLLAPI PyArray_TypeNum(PyTypeObject *type)
Definition: numpy.cpp:16


eigenpy
Author(s): Justin Carpentier, Nicolas Mansard
autogenerated on Fri Jun 2 2023 02:10:26