numpy 2.0.0
include/numpy/ufuncobject.h File Reference
#include <numpy/npy_math.h>
#include "arrayobject.h"
#include "__ufunc_api.h"

Go to the source code of this file.

Data Structures

struct  _tagPyUFuncObject
struct  PyUFunc_PyFuncData
struct  _loop1d_info

Defines

#define UFUNC_ERR_IGNORE   0
#define UFUNC_ERR_WARN   1
#define UFUNC_ERR_RAISE   2
#define UFUNC_ERR_CALL   3
#define UFUNC_ERR_PRINT   4
#define UFUNC_ERR_LOG   5
#define UFUNC_MASK_DIVIDEBYZERO   0x07
#define UFUNC_MASK_OVERFLOW   0x3f
#define UFUNC_MASK_UNDERFLOW   0x1ff
#define UFUNC_MASK_INVALID   0xfff
#define UFUNC_SHIFT_DIVIDEBYZERO   0
#define UFUNC_SHIFT_OVERFLOW   3
#define UFUNC_SHIFT_UNDERFLOW   6
#define UFUNC_SHIFT_INVALID   9
#define UFUNC_FPE_DIVIDEBYZERO   1
#define UFUNC_FPE_OVERFLOW   2
#define UFUNC_FPE_UNDERFLOW   4
#define UFUNC_FPE_INVALID   8
#define UFUNC_ERR_DEFAULT   0
#define UFUNC_OBJ_ISOBJECT   1
#define UFUNC_OBJ_NEEDS_API   2
#define UFUNC_ERR_DEFAULT2
#define NPY_LOOP_BEGIN_THREADS
#define NPY_LOOP_END_THREADS
#define PyUFunc_One   1
#define PyUFunc_Zero   0
#define PyUFunc_None   -1
#define UFUNC_REDUCE   0
#define UFUNC_ACCUMULATE   1
#define UFUNC_REDUCEAT   2
#define UFUNC_OUTER   3
#define UFUNC_PYVALS_NAME   "UFUNC_PYVALS"
#define UFUNC_CHECK_ERROR(arg)
#define NO_FLOATING_POINT_SUPPORT
#define UFUNC_CHECK_STATUS(ret)
#define generate_divbyzero_error()   npy_set_floatstatus_divbyzero()
#define generate_overflow_error()   npy_set_floatstatus_overflow()
#define UFUNC_NOFPE

Typedefs

typedef void(* PyUFuncGenericFunction )(char **args, npy_intp *dimensions, npy_intp *steps, void *innerloopdata)
typedef void(* PyUFuncGenericMaskedFunction )(char **args, npy_intp *dimensions, npy_intp *steps, NpyAuxData *innerloopdata)
typedef int( PyUFunc_TypeResolutionFunc )(struct _tagPyUFuncObject *ufunc, NPY_CASTING casting, PyArrayObject **operands, PyObject *type_tup, PyArray_Descr **out_dtypes, PyUFuncGenericFunction *out_innerloop, void **out_innerloopdata)
typedef int( PyUFunc_TypeResolutionMaskedFunc )(struct _tagPyUFuncObject *ufunc, NPY_CASTING casting, PyArrayObject **operands, PyObject *type_tup, PyArray_Descr **out_dtypes, PyUFuncGenericMaskedFunction *out_innerloop, NpyAuxData **out_innerloopdata)
typedef struct _tagPyUFuncObject PyUFuncObject
typedef struct _loop1d_info PyUFunc_Loop1d

Define Documentation

#define generate_divbyzero_error ( )    npy_set_floatstatus_divbyzero()
THESE MACROS ARE DEPRECATED. Use npy_set_floatstatus_* in the npymath library.
#define generate_overflow_error ( )    npy_set_floatstatus_overflow()
#define NO_FLOATING_POINT_SUPPORT
This code checks the IEEE status flags in a platform-dependent way
Adapted from Numarray
OSF/Alpha (Tru64) ---------------------------------------------
#define NPY_LOOP_BEGIN_THREADS
#define NPY_LOOP_END_THREADS
#define PyUFunc_None   -1

Referenced by ufunc_frompyfunc().

#define PyUFunc_One   1
#define PyUFunc_Zero   0
#define UFUNC_ACCUMULATE   1
#define UFUNC_CHECK_ERROR (   arg)
Value:
do {if ((((arg)->obj & UFUNC_OBJ_NEEDS_API) && PyErr_Occurred()) ||                         \
            ((arg)->errormask &&                                        \
             PyUFunc_checkfperr((arg)->errormask,                       \
                                (arg)->errobj,                          \
                                &(arg)->first)))                        \
                goto fail;} while (0)
#define UFUNC_CHECK_STATUS (   ret)
Value:
{ \
    ret = 0; \
  }
#define UFUNC_ERR_CALL   3
#define UFUNC_ERR_DEFAULT   0
Error mode that avoids look-up (no checking)
#define UFUNC_ERR_DEFAULT2
#define UFUNC_ERR_IGNORE   0
#define UFUNC_ERR_LOG   5
#define UFUNC_ERR_PRINT   4
#define UFUNC_ERR_RAISE   2
#define UFUNC_ERR_WARN   1
#define UFUNC_FPE_DIVIDEBYZERO   1
platform-dependent code translates floating point
status to an integer sum of these values
#define UFUNC_FPE_INVALID   8
#define UFUNC_FPE_OVERFLOW   2
#define UFUNC_FPE_UNDERFLOW   4
#define UFUNC_MASK_DIVIDEBYZERO   0x07
Python side integer mask
#define UFUNC_MASK_INVALID   0xfff
#define UFUNC_MASK_OVERFLOW   0x3f
#define UFUNC_MASK_UNDERFLOW   0x1ff
#define UFUNC_NOFPE
Make sure it gets defined if it isn't already
!Py_UFUNCOBJECT_H
#define UFUNC_OBJ_ISOBJECT   1
#define UFUNC_OBJ_NEEDS_API   2
#define UFUNC_OUTER   3
#define UFUNC_PYVALS_NAME   "UFUNC_PYVALS"

Referenced by _extract_pyvals().

#define UFUNC_REDUCE   0
#define UFUNC_REDUCEAT   2
#define UFUNC_SHIFT_DIVIDEBYZERO   0
#define UFUNC_SHIFT_INVALID   9
#define UFUNC_SHIFT_OVERFLOW   3
#define UFUNC_SHIFT_UNDERFLOW   6

Typedef Documentation

typedef struct _loop1d_info PyUFunc_Loop1d
A linked-list of function information for
user-defined 1-d loops.
typedef int( PyUFunc_TypeResolutionFunc)(struct _tagPyUFuncObject *ufunc, NPY_CASTING casting, PyArrayObject **operands, PyObject *type_tup, PyArray_Descr **out_dtypes, PyUFuncGenericFunction *out_innerloop, void **out_innerloopdata)
Given the operands for calling a ufunc, should determine the calculation input and output data types and return an inner loop function. This function should validate that the casting rule is being followed, and fail if it is not.
For backwards compatibility, the regular type resolution function does not support auxiliary data with object semantics. The type resolution call which returns a masked generic function returns a standard NpyAuxData object, for which the NPY_AUXDATA_FREE and NPY_AUXDATA_CLONE macros work.
ufunc: The ufunc object. casting: The 'casting' parameter provided to the ufunc. operands: An array of length (ufunc->nin + ufunc->nout),

System Message: ERROR/3 (<string>, line 15) Unexpected indentation.

<blockquote> with the output parameters possibly NULL.</blockquote>

System Message: WARNING/2 (<string>, line 16) Block quote ends without a blank line; unexpected unindent.
type_tup: Either NULL, or the type_tup passed to the ufunc. out_dtypes: An array which should be populated with new

System Message: ERROR/3 (<string>, line 18) Unexpected indentation.

<blockquote> references to (ufunc->nin + ufunc->nout) new dtypes, one for each input and output. These dtypes should all be in native-endian format.</blockquote>

System Message: WARNING/2 (<string>, line 21) Block quote ends without a blank line; unexpected unindent.
out_innerloop: Should be populated with the correct ufunc inner
loop for the given type.
out_innerloopdata: Should be populated with the void* data to
be passed into the out_innerloop function.
Should return 0 on success, -1 on failure (with exception set), or -2 if Py_NotImplemented should be returned.
typedef int( PyUFunc_TypeResolutionMaskedFunc)(struct _tagPyUFuncObject *ufunc, NPY_CASTING casting, PyArrayObject **operands, PyObject *type_tup, PyArray_Descr **out_dtypes, PyUFuncGenericMaskedFunction *out_innerloop, NpyAuxData **out_innerloopdata)
typedef void(* PyUFuncGenericFunction)(char **args, npy_intp *dimensions, npy_intp *steps, void *innerloopdata)
The most generic inner loop for a standard element-wise ufunc
typedef void(* PyUFuncGenericMaskedFunction)(char **args, npy_intp *dimensions, npy_intp *steps, NpyAuxData *innerloopdata)
The most generic inner loop for a masked standard element-wise ufunc. The mask data and step is at args[narg] and steps[narg], after all the operands.