Namespaces | Macros | Functions
ufunc.hpp File Reference
#include "eigenpy/register.hpp"
#include "eigenpy/user-type.hpp"
#include "eigenpy/utils/python-compat.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 T >
void eigenpy::internal::gufunc_matrix_multiply (char **args, npy_intp EIGENPY_NPY_CONST_UFUNC_ARG *dimensions, npy_intp EIGENPY_NPY_CONST_UFUNC_ARG *steps, void *NPY_UNUSED(func))
 
template<typename T >
void eigenpy::internal::matrix_multiply (char **args, npy_intp const *dimensions, npy_intp const *steps)
 
template<typename Scalar >
void eigenpy::registerCommonUfunc ()
 

Macro Definition Documentation

◆ EIGENPY_NPY_CONST_UFUNC_ARG

#define EIGENPY_NPY_CONST_UFUNC_ARG

Definition at line 20 of file ufunc.hpp.

◆ EIGENPY_REGISTER_BINARY_OPERATOR

#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); \
}

Definition at line 92 of file ufunc.hpp.

◆ EIGENPY_REGISTER_BINARY_UFUNC

#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 157 of file ufunc.hpp.

◆ EIGENPY_REGISTER_UNARY_OPERATOR

#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); \
}

Definition at line 129 of file ufunc.hpp.

◆ EIGENPY_REGISTER_UNARY_UFUNC

#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 182 of file ufunc.hpp.

test_user_struct.y
y
Definition: test_user_struct.py:5
setup.data
data
Definition: setup.in.py:48
test_geometry.R
R
Definition: test_geometry.py:81
test_geometry.res
res
Definition: test_geometry.py:88
test_user_struct.x
x
Definition: test_user_struct.py:4
setup.name
name
Definition: setup.in.py:179
EIGENPY_NPY_CONST_UFUNC_ARG
#define EIGENPY_NPY_CONST_UFUNC_ARG
Definition: ufunc.hpp:20


eigenpy
Author(s): Justin Carpentier, Nicolas Mansard
autogenerated on Sat Nov 2 2024 02:14:45