MCPcopy Create free account
hub / github.com/numpy/numpy / trivial_at_loop

Function trivial_at_loop

numpy/core/src/umath/ufunc_object.c:5933–5991  ·  view source on GitHub ↗

* Use an indexed loop to do the work * Returns 0 if successful */

Source from the content-addressed store, hash-verified

5931 * Returns 0 if successful
5932 */
5933static int
5934trivial_at_loop(PyArrayMethodObject *ufuncimpl, NPY_ARRAYMETHOD_FLAGS flags,
5935 PyArrayMapIterObject *iter,
5936 PyArrayObject *op1_array, PyArrayObject *op2_array,
5937 PyArrayMethod_Context *context)
5938{
5939 int buffersize=0, errormask = 0;
5940 int res;
5941 char *args[3];
5942 npy_intp steps[4];
5943 args[0] = (char *) iter->baseoffset;
5944 steps[0] = iter->fancy_strides[0];
5945 if (ufuncimpl->nin == 1) {
5946 args[2] = NULL;
5947 steps[2] = 0;
5948 } else {
5949 args[2] = (char *)PyArray_DATA(op2_array);
5950 if (PyArray_NDIM(op2_array) == 0
5951 || PyArray_DIM(op2_array, 0) <= 1) {
5952 steps[2] = 0;
5953 } else {
5954 steps[2] = PyArray_STRIDE(op2_array, 0);
5955 }
5956 }
5957
5958 if (!(flags & NPY_METH_NO_FLOATINGPOINT_ERRORS)) {
5959 npy_clear_floatstatus_barrier((char *)context);
5960 }
5961
5962 do {
5963 npy_intp *inner_size = NpyIter_GetInnerLoopSizePtr(iter->outer);
5964 npy_intp * indxP = (npy_intp *)iter->outer_ptrs[0];
5965 args[1] = (char *)indxP;
5966 steps[1] = iter->outer_strides[0];
5967 /*
5968 * The value of iter->fancy_dims[0] is added to negative indexes
5969 * inside the inner loop
5970 */
5971 steps[3] = iter->fancy_dims[0];
5972
5973 res = ufuncimpl->contiguous_indexed_loop(
5974 context, args, inner_size, steps, NULL);
5975
5976 if (args[2] != NULL) {
5977 args[2] += (*inner_size) * steps[2];
5978 }
5979 } while (res == 0 && iter->outer_next(iter->outer));
5980
5981 if (res == 0 && !(flags & NPY_METH_NO_FLOATINGPOINT_ERRORS)) {
5982 const char * ufunc_name =
5983 ufunc_get_name_cstr((PyUFuncObject *)context->caller);
5984 if (_get_bufsize_errmask(NULL, ufunc_name,
5985 &buffersize, &errormask) < 0) {
5986 return -1;
5987 }
5988 res = _check_ufunc_fperr(errormask, NULL, ufunc_name);
5989 }
5990 return res;

Callers 1

ufunc_atFunction · 0.85

Calls 9

PyArray_DATAFunction · 0.85
PyArray_NDIMFunction · 0.85
PyArray_DIMFunction · 0.85
PyArray_STRIDEFunction · 0.85
ufunc_get_name_cstrFunction · 0.85
_get_bufsize_errmaskFunction · 0.85
_check_ufunc_fperrFunction · 0.85

Tested by

no test coverage detected