numpy  2.0.0
src/multiarray/mapping.h
Go to the documentation of this file.
00001 #ifndef _NPY_ARRAYMAPPING_H_
00002 #define _NPY_ARRAYMAPPING_H_
00003 
00004 extern NPY_NO_EXPORT PyMappingMethods array_as_mapping;
00005 
00006 
00007 /*
00008  * Struct into which indices are parsed.
00009  * I.e. integer ones should only be parsed once, slices and arrays
00010  * need to be validated later and for the ellipsis we need to find how
00011  * many slices it represents.
00012  */
00013 typedef struct {
00014     /*
00015      * Object of index: slice, array, or NULL. Owns a reference.
00016      */
00017     PyObject *object;
00018     /*
00019      * Value of an integer index, number of slices an Ellipsis is worth,
00020      * -1 if input was an integer array and the original size of the
00021      * boolean array if it is a converted boolean array.
00022      */
00023     npy_intp value;
00024     /* kind of index, see constants in mapping.c */
00025     int type;
00026 } npy_index_info;
00027 
00028 
00029 NPY_NO_EXPORT Py_ssize_t
00030 array_length(PyArrayObject *self);
00031 
00032 NPY_NO_EXPORT PyObject *
00033 array_item_asarray(PyArrayObject *self, npy_intp i);
00034 
00035 NPY_NO_EXPORT PyObject *
00036 array_item_asscalar(PyArrayObject *self, npy_intp i);
00037 
00038 NPY_NO_EXPORT PyObject *
00039 array_item(PyArrayObject *self, Py_ssize_t i);
00040 
00041 NPY_NO_EXPORT PyObject *
00042 array_subscript_asarray(PyArrayObject *self, PyObject *op);
00043 
00044 NPY_NO_EXPORT PyObject *
00045 array_subscript(PyArrayObject *self, PyObject *op);
00046 
00047 NPY_NO_EXPORT int
00048 array_assign_item(PyArrayObject *self, Py_ssize_t i, PyObject *v);
00049 
00050 /*
00051  * Prototypes for Mapping calls --- not part of the C-API
00052  * because only useful as part of a getitem call.
00053  */
00054 NPY_NO_EXPORT void
00055 PyArray_MapIterReset(PyArrayMapIterObject *mit);
00056 
00057 NPY_NO_EXPORT void
00058 PyArray_MapIterNext(PyArrayMapIterObject *mit);
00059 
00060 NPY_NO_EXPORT int
00061 PyArray_MapIterCheckIndices(PyArrayMapIterObject *mit);
00062 
00063 NPY_NO_EXPORT void
00064 PyArray_MapIterSwapAxes(PyArrayMapIterObject *mit, PyArrayObject **ret, int getmap);
00065 
00066 NPY_NO_EXPORT PyObject*
00067 PyArray_MapIterNew(npy_index_info *indices , int index_num, int index_type,
00068                    int ndim, int fancy_ndim,
00069                    PyArrayObject *arr, PyArrayObject *subspace,
00070                    npy_uint32 subspace_iter_flags, npy_uint32 subspace_flags,
00071                    npy_uint32 extra_op_flags, PyArrayObject *extra_op,
00072                    PyArray_Descr *extra_op_dtype);
00073 #endif