numpy 2.0.0
|
#include "nditer_impl.h"
#define NPY_ITERATOR_IMPLEMENTATION_CODE |
NPY_NO_EXPORT int npyiter_allocate_buffers | ( | NpyIter * | iter, |
char ** | errmsg | ||
) |
Referenced by NpyIter_EnableExternalLoop().
static npy_intp npyiter_checkreducesize | ( | NpyIter * | iter, |
npy_intp | count, | ||
npy_intp * | reduce_innersize, | ||
npy_intp * | reduce_outerdim | ||
) | [static] |
NPY_NO_EXPORT void npyiter_coalesce_axes | ( | NpyIter * | iter | ) |
References NAD_INDEX, NAD_SHAPE, NAD_STRIDES, NBF_REDUCE_OUTERSIZE, NBF_SIZE, NPY_IT_DBG_PRINT1, NPY_IT_DBG_PRINT2, NPY_OP_ITFLAG_WRITEMASKED, and PyArray_TransferMaskedStridedToNDim().
NPY_NO_EXPORT void npyiter_copy_from_buffers | ( | NpyIter * | iter | ) |
Referenced by NpyIter_EnableExternalLoop(), and NpyIter_GotoIndex().
NPY_NO_EXPORT void npyiter_copy_to_buffers | ( | NpyIter * | iter, |
char ** | prev_dataptrs | ||
) |
References _PyArray_Descr::elsize, and NPY_IT_DBG_PRINT1.
Referenced by NpyIter_EnableExternalLoop(), NpyIter_GotoIndex(), and NpyIter_New().
NPY_NO_EXPORT int NpyIter_CreateCompatibleStrides | ( | NpyIter * | iter, |
npy_intp | itemsize, | ||
npy_intp * | outstrides | ||
) |
output array created using the NPY_ITER_ALLOCATE flag, where NULL was passed for op_axes. This is for data packed contiguously, but not necessarily in C or Fortran order. This should be used together with NpyIter_GetShape and NpyIter_GetNDim.
A use case for this function is to match the shape and layout of the iterator and tack on one or more dimensions. For example, in order to generate a vector per input value for a numerical gradient, you pass in ndim*itemsize for itemsize, then add another dimension to the end with size ndim and stride itemsize. To do the Hessian matrix, you do the same thing but add two dimensions, or take advantage of the symmetry and pack it into 1 dimension with a particular encoding.
This function may only be called if the iterator is tracking a multi-index and if NPY_ITER_DONT_NEGATE_STRIDES was used to prevent an axis from being iterated in reverse order.
If an array is created with this method, simply adding 'itemsize' for each iteration will traverse the new array matching the iterator.
Returns NPY_SUCCEED or NPY_FAIL.
NPY_NO_EXPORT void NpyIter_DebugPrint | ( | NpyIter * | iter | ) |
NPY_NO_EXPORT int NpyIter_EnableExternalLoop | ( | NpyIter * | iter | ) |
References NBF_BUFITEREND, NBF_SIZE, NIT_BUFFERDATA, NIT_ITEREND, NIT_ITERINDEX, NIT_ITERSTART, NIT_ITFLAGS, NIT_NOP, NPY_FAIL, NPY_ITFLAG_DELAYBUF, NPY_SUCCEED, npyiter_allocate_buffers(), npyiter_copy_from_buffers(), npyiter_copy_to_buffers(), and npyiter_goto_iterindex().
If the iterator is tracking a multi-index, gets the strides for the axis specified, otherwise gets the strides for the iteration axis as Fortran order (fastest-changing axis first).
Returns NULL if an error occurs.
References NIT_BASEOFFSETS.
References NBF_PTRS, and NIT_BUFFERDATA.
NPY_NO_EXPORT char** NpyIter_GetDataPtrArray | ( | NpyIter * | iter | ) |
References NIT_NOP, NIT_OPITFLAGS, and NPY_OP_ITFLAG_WRITE.
Referenced by apply_business_day_count(), and business_day_offset().
NPY_NO_EXPORT PyArray_Descr** NpyIter_GetDescrArray | ( | NpyIter * | iter | ) |
References NAD_SHAPE, NBF_SIZE, NIT_AXISDATA, NIT_BUFFERDATA, NIT_ITFLAGS, and NIT_NOP.
NPY_NO_EXPORT char** NpyIter_GetInitialDataPtrArray | ( | NpyIter * | iter | ) |
directly into the arrays (never pointing to a buffer), for starting unbuffered iteration. This always returns the addresses for the iterator position as reset to iterator index 0.
These pointers are different from the pointers accepted by NpyIter_ResetBasePointers, because the direction along some axes may have been reversed, requiring base offsets.
This function may be safely called without holding the Python GIL.
change during iteration receive the value NPY_MAX_INTP. Once the iterator is ready to iterate, call this to get the strides which will always be fixed in the inner loop, then choose optimized inner loop functions which take advantage of those fixed strides.
This function may be safely called without holding the Python GIL.
Referenced by apply_business_day_count(), and business_day_offset().
Referenced by apply_business_day_count(), and business_day_offset().
References NIT_ITFLAGS.
References NPY_FAIL.
Referenced by apply_business_day_count(), and business_day_offset().
NPY_NO_EXPORT PyArrayObject* NpyIter_GetIterView | ( | NpyIter * | iter, |
npy_intp | i | ||
) |
Referenced by npyiter_remove_axis().
NPY_NO_EXPORT int NpyIter_GetNDim | ( | NpyIter * | iter | ) |
NPY_NO_EXPORT int NpyIter_GetNOp | ( | NpyIter * | iter | ) |
Referenced by npyiter_iterrange_set(), and npyiter_remove_axis().
NPY_NO_EXPORT PyArrayObject** NpyIter_GetOperandArray | ( | NpyIter * | iter | ) |
Referenced by apply_business_day_count(), and business_day_offset().
NPY_NO_EXPORT void NpyIter_GetReadFlags | ( | NpyIter * | iter, |
char * | outreadflags | ||
) |
otherwise gets the shape of the iteration as Fortran-order (fastest-changing index first).
The reason Fortran-order is returned when a multi-index is not enabled is that this is providing a direct view into how the iterator traverses the n-dimensional space. The iterator organizes its memory from fastest index to slowest index, and when a multi-index is enabled, it uses a permutation to recover the original order.
Returns NPY_SUCCEED or NPY_FAIL.
References NIT_NOP, and NIT_OPERANDS.
NPY_NO_EXPORT void NpyIter_GetWriteFlags | ( | NpyIter * | iter, |
char * | outwriteflags | ||
) |
Referenced by NpyIter_EnableExternalLoop(), NpyIter_GotoIndex(), and NpyIter_New().
to the specified index.
Returns NPY_SUCCEED on success, NPY_FAIL on failure.
References NBF_BUFITEREND, NBF_PTRS, NBF_SIZE, NBF_STRIDES, NIT_BUFFERDATA, NIT_ITERINDEX, NPY_ITFLAG_REDUCE, npyiter_copy_from_buffers(), npyiter_copy_to_buffers(), and npyiter_goto_iterindex().
which matches the iteration order of the iterator.
Returns NPY_SUCCEED on success, NPY_FAIL on failure.
correct number of entries for 'ndim'. It is only valid when NPY_ITER_MULTI_INDEX was passed to the constructor. This operation fails if the multi-index is out of bounds.
Returns NPY_SUCCEED on success, NPY_FAIL on failure.
References NPY_FAIL.
References NIT_ITEREND, and NIT_ITERSTART.
Referenced by npyiter_iterrange_set().
References NIT_ITFLAGS, NIT_NDIM, and NIT_NOP.
Referenced by npyiter_index_set().
NPY_NO_EXPORT int NpyIter_RemoveAxis | ( | NpyIter * | iter, |
int | axis | ||
) |
was set for iterator creation, and does not work if buffering is enabled. This function also resets the iterator to its initial state.
Returns NPY_SUCCEED or NPY_FAIL.
NPY_NO_EXPORT int NpyIter_RemoveMultiIndex | ( | NpyIter * | iter | ) |
References NAD_SHAPE.
NPY_NO_EXPORT int NpyIter_Reset | ( | NpyIter * | iter, |
char ** | errmsg | ||
) |
NPY_NO_EXPORT int NpyIter_ResetBasePointers | ( | NpyIter * | iter, |
char ** | baseptrs, | ||
char ** | errmsg | ||
) |
NPY_NO_EXPORT int NpyIter_ResetToIterIndexRange | ( | NpyIter * | iter, |
npy_intp | istart, | ||
npy_intp | iend, | ||
char ** | errmsg | ||
) |