numpy  2.0.0
src/umath/umathmodule.c File Reference
#include "Python.h"
#include "npy_config.h"
#include "numpy/arrayobject.h"
#include "numpy/ufuncobject.h"
#include "numpy/npy_3kcompat.h"
#include "abstract.h"
#include "numpy/npy_math.h"
#include "funcs.inc"
#include "loops.h"
#include "ufunc_object.h"
#include "ufunc_type_resolution.h"
#include "__umath_generated.c"
#include "__ufunc_api.c"
#include <stdio.h>

Defines

#define _UMATHMODULE
#define NPY_NO_DEPRECATED_API   NPY_API_VERSION
#define PY_ARRAY_UNIQUE_SYMBOL   _npy_umathmodule_ARRAY_API
#define RETVAL
#define ADDCONST(str)   PyModule_AddIntConstant(m, #str, UFUNC_##str)
#define ADDSCONST(str)   PyModule_AddStringConstant(m, "UFUNC_" #str, UFUNC_##str)

Functions

NPY_NO_EXPORT int initscalarmath (PyObject *)
static int object_ufunc_type_resolver (PyUFuncObject *ufunc, NPY_CASTING casting, PyArrayObject **operands, PyObject *type_tup, PyArray_Descr **out_dtypes)
static int object_ufunc_loop_selector (PyUFuncObject *ufunc, PyArray_Descr **NPY_UNUSED(dtypes), PyUFuncGenericFunction *out_innerloop, void **out_innerloopdata, int *out_needs_api)
static PyObject * ufunc_frompyfunc (PyObject *NPY_UNUSED(dummy), PyObject *args, PyObject *NPY_UNUSED(kwds))
static PyObject * add_newdoc_ufunc (PyObject *NPY_UNUSED(dummy), PyObject *args)
static int intern_strings (void)
PyMODINIT_FUNC initumath (void)

Variables

static PyUFuncGenericFunction pyfunc_functions [] = {PyUFunc_On_Om}
NPY_VISIBILITY_HIDDEN PyObject * npy_um_str_out = NULL
NPY_VISIBILITY_HIDDEN PyObject * npy_um_str_subok = NULL
NPY_VISIBILITY_HIDDEN PyObject * npy_um_str_array_prepare = NULL
NPY_VISIBILITY_HIDDEN PyObject * npy_um_str_array_wrap = NULL
NPY_VISIBILITY_HIDDEN PyObject * npy_um_str_array_finalize = NULL
NPY_VISIBILITY_HIDDEN PyObject * npy_um_str_ufunc = NULL
NPY_VISIBILITY_HIDDEN PyObject * npy_um_str_pyvals_name = NULL
static struct PyMethodDef methods []

Define Documentation

#define _UMATHMODULE
vim:syntax=c

* INCLUDES **

_UMATHMODULE IS needed in __ufunc_api.h, included from numpy/ufuncobject.h. This is a mess and it would be nice to fix it. It has nothing to do with __ufunc_api.c
#define ADDCONST (   str)    PyModule_AddIntConstant(m, #str, UFUNC_##str)
#define ADDSCONST (   str)    PyModule_AddStringConstant(m, "UFUNC_" #str, UFUNC_##str)
#define NPY_NO_DEPRECATED_API   NPY_API_VERSION
#define PY_ARRAY_UNIQUE_SYMBOL   _npy_umathmodule_ARRAY_API
#define RETVAL

Function Documentation

static PyObject* add_newdoc_ufunc ( PyObject *  NPY_UNUSEDdummy,
PyObject *  args 
) [static]
docstring in numpy.add_newdocs.py
This introduces a memory leak, as the memory allocated for the doc will not be freed even if the ufunc itself is deleted. In practice this should not be a problem since the user would have to repeatedly create, document, and throw away ufuncs.

Referenced by intern_strings().

NPY_NO_EXPORT int initscalarmath ( PyObject *  )

* INCLUDE GENERATED CODE **

PyMODINIT_FUNC initumath ( void  )
Create the module and add the functions
Import the array
Initialize the types
Add some symbolic constants to the module
Load the ufunc operators into the array module's namespace
Setup the array object's numerical structures with appropriate
ufuncs in d
Check for errors
static int intern_strings ( void  ) [static]
intern some strings used in ufuncs

References add_newdoc_ufunc(), methods, ufunc_frompyfunc(), ufunc_geterr(), and ufunc_seterr().

static int object_ufunc_loop_selector ( PyUFuncObject ufunc,
PyArray_Descr **  NPY_UNUSEDdtypes,
PyUFuncGenericFunction out_innerloop,
void **  out_innerloopdata,
int *  out_needs_api 
) [static]
static int object_ufunc_type_resolver ( PyUFuncObject ufunc,
NPY_CASTING  casting,
PyArrayObject **  operands,
PyObject *  type_tup,
PyArray_Descr **  out_dtypes 
) [static]
static PyObject* ufunc_frompyfunc ( PyObject *  NPY_UNUSEDdummy,
PyObject *  args,
PyObject *  NPY_UNUSEDkwds 
) [static]
Keywords are ignored for now
generalized ufunc
self->ptr holds a pointer for enough memory for self->data[0] (fdata) self->data self->name self->types
To be safest, all of these need their memory aligned on void * pointers Therefore, we may need to allocate extra space.
Do a better job someday

References PyUFunc_PyFuncData::callable, fname, PyUFunc_PyFuncData::nin, PyUFunc_PyFuncData::nout, NPY_MAXARGS, NPY_OBJECT, object_ufunc_loop_selector(), object_ufunc_type_resolver(), PyArray_malloc, pyfunc_functions, PyUFunc_None, and PyUFunc_Type.

Referenced by intern_strings().


Variable Documentation

struct PyMethodDef methods[] [static]
Initial value:
 {
    {"frompyfunc",
        (PyCFunction) ufunc_frompyfunc,
        METH_VARARGS | METH_KEYWORDS, NULL},
    {"seterrobj",
        (PyCFunction) ufunc_seterr,
        METH_VARARGS, NULL},
    {"geterrobj",
        (PyCFunction) ufunc_geterr,
        METH_VARARGS, NULL},
    {"_add_newdoc_ufunc", (PyCFunction)add_newdoc_ufunc,
        METH_VARARGS, NULL},
    {NULL, NULL, 0, NULL}                
}
Setup the umath module
Remove for time being, it is declared in __ufunc_api.h
static PyTypeObject PyUFunc_Type;

Referenced by intern_strings().

NPY_VISIBILITY_HIDDEN PyObject* npy_um_str_array_finalize = NULL
NPY_VISIBILITY_HIDDEN PyObject* npy_um_str_array_prepare = NULL
NPY_VISIBILITY_HIDDEN PyObject* npy_um_str_array_wrap = NULL
NPY_VISIBILITY_HIDDEN PyObject* npy_um_str_out = NULL

* SETUP UFUNCS **

NPY_VISIBILITY_HIDDEN PyObject* npy_um_str_pyvals_name = NULL
NPY_VISIBILITY_HIDDEN PyObject* npy_um_str_subok = NULL
NPY_VISIBILITY_HIDDEN PyObject* npy_um_str_ufunc = NULL