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

Function npy_amergesort

numpy/core/src/npysort/mergesort.cpp:459–482  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

457}
458
459NPY_NO_EXPORT int
460npy_amergesort(void *v, npy_intp *tosort, npy_intp num, void *varr)
461{
462 PyArrayObject *arr = (PyArrayObject *)varr;
463 npy_intp elsize = PyArray_ITEMSIZE(arr);
464 PyArray_CompareFunc *cmp = PyArray_DESCR(arr)->f->compare;
465 npy_intp *pl, *pr, *pw;
466
467 /* Items that have zero size don't make sense to sort */
468 if (elsize == 0) {
469 return 0;
470 }
471
472 pl = tosort;
473 pr = pl + num;
474 pw = (npy_intp *)malloc((num >> 1) * sizeof(npy_intp));
475 if (pw == NULL) {
476 return -NPY_ENOMEM;
477 }
478 npy_amergesort0(pl, pr, (char *)v, pw, elsize, cmp, arr);
479 free(pw);
480
481 return 0;
482}
483
484/***************************************
485 * C > C++ dispatch

Callers

nothing calls this directly

Calls 3

PyArray_ITEMSIZEFunction · 0.85
PyArray_DESCRFunction · 0.85
npy_amergesort0Function · 0.85

Tested by

no test coverage detected