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

Function PyArray_CreateSortedStridePerm

numpy/core/src/multiarray/shape.c:773–788  ·  view source on GitHub ↗

NUMPY_API * * This function populates the first ndim elements * of strideperm with sorted descending by their absolute values. * For example, the stride array (4, -2, 12) becomes * [(2, 12), (0, 4), (1, -2)]. */

Source from the content-addressed store, hash-verified

771 * [(2, 12), (0, 4), (1, -2)].
772 */
773NPY_NO_EXPORT void
774PyArray_CreateSortedStridePerm(int ndim, npy_intp const *strides,
775 npy_stride_sort_item *out_strideperm)
776{
777 int i;
778
779 /* Set up the strideperm values */
780 for (i = 0; i < ndim; ++i) {
781 out_strideperm[i].perm = i;
782 out_strideperm[i].stride = strides[i];
783 }
784
785 /* Sort them */
786 qsort(out_strideperm, ndim, sizeof(npy_stride_sort_item),
787 &_npy_stride_sort_item_comparator);
788}
789
790static inline npy_intp
791s_intp_abs(npy_intp x)

Callers 6

PyArray_RavelFunction · 0.85
PyArray_MapIterNewFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected