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

Function npyiter_undo_iter_axis_perm

numpy/core/src/multiarray/nditer_impl.h:335–352  ·  view source on GitHub ↗

* Undo the axis permutation of the iterator. When the operand has fewer * dimensions then the iterator, this can return negative values for * inserted (broadcast) dimensions. * * @param axis Axis for which to undo the iterator axis permutation. * @param ndim If `op_axes` is being used, this is the iterator dimension, * otherwise this is the operand dimension. * @param perm The i

Source from the content-addressed store, hash-verified

333 * `op_axes` this indexes into `op_axes` (unpermuted iterator axis)
334 */
335static inline int
336npyiter_undo_iter_axis_perm(
337 int axis, int ndim, const npy_int8 *perm, npy_bool *axis_flipped)
338{
339 npy_int8 p = perm[axis];
340 /* The iterator treats axis reversed, thus adjust by ndim */
341 npy_bool flipped = p < 0;
342 if (axis_flipped != NULL) {
343 *axis_flipped = flipped;
344 }
345 if (flipped) {
346 axis = ndim + p;
347 }
348 else {
349 axis = ndim - p - 1;
350 }
351 return axis;
352}
353
354NPY_NO_EXPORT void
355npyiter_coalesce_axes(NpyIter *iter);

Callers 4

npyiter_replace_axisdataFunction · 0.85
npyiter_new_temp_arrayFunction · 0.85
NpyIter_GetShapeFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected