Namespaces | Macros | Functions
ufunc.hpp File Reference
#include "eigenpy/register.hpp"
Include dependency graph for ufunc.hpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Namespaces

 eigenpy
 
 eigenpy::internal
 

Macros

#define EIGENPY_NPY_CONST_UFUNC_ARG
 
#define EIGENPY_REGISTER_BINARY_OPERATOR(name, op)
 
#define EIGENPY_REGISTER_BINARY_UFUNC(name, code, T1, T2, R)
 
#define EIGENPY_REGISTER_UNARY_OPERATOR(name, op)
 
#define EIGENPY_REGISTER_UNARY_UFUNC(name, code, T, R)
 

Functions

template<typename Scalar >
void eigenpy::registerCommonUfunc ()
 

Macro Definition Documentation

#define EIGENPY_NPY_CONST_UFUNC_ARG

Definition at line 18 of file ufunc.hpp.

#define EIGENPY_REGISTER_BINARY_OPERATOR (   name,
  op 
)
Value:
template<typename T1, typename T2, typename R> \
void binary_op_##name(char** args, EIGENPY_NPY_CONST_UFUNC_ARG npy_intp * dimensions, EIGENPY_NPY_CONST_UFUNC_ARG npy_intp * steps, void * /*data*/) \
{ \
npy_intp is0 = steps[0], is1 = steps[1], \
os = steps[2], n = *dimensions; \
char * i0 = args[0], *i1 = args[1], *o = args[2]; \
int k; \
for (k = 0; k < n; k++) \
{ \
T1 & x = *static_cast<T1*>(static_cast<void*>(i0)); \
T2 & y = *static_cast<T2*>(static_cast<void*>(i1)); \
R & res = *static_cast<R*>(static_cast<void*>(o)); \
res = x op y; \
i0 += is0; i1 += is1; o += os; \
} \
} \
\
template<typename T> \
void binary_op_##name(char** args, EIGENPY_NPY_CONST_UFUNC_ARG npy_intp * dimensions, EIGENPY_NPY_CONST_UFUNC_ARG npy_intp * steps, void * data) \
{ \
binary_op_##name<T,T,T>(args,dimensions,steps,data); \
}
data
Definition: setup.in.py:38
#define EIGENPY_NPY_CONST_UFUNC_ARG
Definition: ufunc.hpp:18

Definition at line 21 of file ufunc.hpp.

#define EIGENPY_REGISTER_BINARY_UFUNC (   name,
  code,
  T1,
  T2,
 
)
Value:
{ \
PyUFuncObject* ufunc = \
(PyUFuncObject*)PyObject_GetAttrString(numpy, #name); \
int _types[3] = { Register::getTypeCode<T1>(), Register::getTypeCode<T2>(), Register::getTypeCode<R>()}; \
if (!ufunc) { \
/*goto fail; \*/ \
} \
if (sizeof(_types)/sizeof(int)!=ufunc->nargs) { \
PyErr_Format(PyExc_AssertionError, \
"ufunc %s takes %d arguments, our loop takes %lu", \
#name, ufunc->nargs, (unsigned long) \
(sizeof(_types)/sizeof(int))); \
Py_DECREF(ufunc); \
} \
if (PyUFunc_RegisterLoopForType((PyUFuncObject*)ufunc, code, \
internal::binary_op_##name<T1,T2,R>, _types, 0) < 0) { \
/*Py_DECREF(ufunc);*/ \
/*goto fail; \*/ \
} \
Py_DECREF(ufunc); \
}

Definition at line 83 of file ufunc.hpp.

#define EIGENPY_REGISTER_UNARY_OPERATOR (   name,
  op 
)
Value:
template<typename T, typename R> \
void unary_op_##name(char** args, EIGENPY_NPY_CONST_UFUNC_ARG npy_intp * dimensions, EIGENPY_NPY_CONST_UFUNC_ARG npy_intp * steps, void * /*data*/) \
{ \
npy_intp is = steps[0], \
os = steps[1], n = *dimensions; \
char * i = args[0], *o = args[1]; \
int k; \
for (k = 0; k < n; k++) \
{ \
T & x = *static_cast<T*>(static_cast<void*>(i)); \
R & res = *static_cast<R*>(static_cast<void*>(o)); \
res = op x; \
i += is; o += os; \
} \
} \
\
template<typename T> \
void unary_op_##name(char** args, EIGENPY_NPY_CONST_UFUNC_ARG npy_intp * dimensions, EIGENPY_NPY_CONST_UFUNC_ARG npy_intp * steps, void * data) \
{ \
unary_op_##name<T,T>(args,dimensions,steps,data); \
}
data
Definition: setup.in.py:38
#define EIGENPY_NPY_CONST_UFUNC_ARG
Definition: ufunc.hpp:18

Definition at line 56 of file ufunc.hpp.

#define EIGENPY_REGISTER_UNARY_UFUNC (   name,
  code,
  T,
 
)
Value:
{ \
PyUFuncObject* ufunc = \
(PyUFuncObject*)PyObject_GetAttrString(numpy, #name); \
int _types[2] = { Register::getTypeCode<T>(), Register::getTypeCode<R>()}; \
if (!ufunc) { \
/*goto fail; \*/ \
} \
if (sizeof(_types)/sizeof(int)!=ufunc->nargs) { \
PyErr_Format(PyExc_AssertionError, \
"ufunc %s takes %d arguments, our loop takes %lu", \
#name, ufunc->nargs, (unsigned long) \
(sizeof(_types)/sizeof(int))); \
Py_DECREF(ufunc); \
} \
if (PyUFunc_RegisterLoopForType((PyUFuncObject*)ufunc, code, \
internal::unary_op_##name<T,R>, _types, 0) < 0) { \
/*Py_DECREF(ufunc);*/ \
/*goto fail; \*/ \
} \
Py_DECREF(ufunc); \
}

Definition at line 105 of file ufunc.hpp.



eigenpy
Author(s): Justin Carpentier, Nicolas Mansard
autogenerated on Sat Apr 17 2021 02:37:59