diff options
-rw-r--r-- | numpy/core/include/numpy/npy_common.h | 5 | ||||
-rw-r--r-- | numpy/core/include/numpy/npy_sort.h | 288 | ||||
-rw-r--r-- | numpy/core/src/npysort/sort.c.src | 68 | ||||
-rw-r--r-- | numpy/core/src/npysort/sortmodule.c.src | 20 |
4 files changed, 195 insertions, 186 deletions
diff --git a/numpy/core/include/numpy/npy_common.h b/numpy/core/include/numpy/npy_common.h index 0c92fb494..6ca83cc29 100644 --- a/numpy/core/include/numpy/npy_common.h +++ b/numpy/core/include/numpy/npy_common.h @@ -178,11 +178,12 @@ typedef unsigned int npy_uint; typedef unsigned long npy_ulong; /* These are for completeness */ -typedef float npy_float; -typedef double npy_double; +typedef char npy_char; typedef short npy_short; typedef int npy_int; typedef long npy_long; +typedef float npy_float; +typedef double npy_double; /* * Disabling C99 complex usage: a lot of C code in numpy/scipy rely on being diff --git a/numpy/core/include/numpy/npy_sort.h b/numpy/core/include/numpy/npy_sort.h index 60f2b047a..0c0b77bcf 100644 --- a/numpy/core/include/numpy/npy_sort.h +++ b/numpy/core/include/numpy/npy_sort.h @@ -7,163 +7,163 @@ #include <numpy/ndarraytypes.h> -int BOOL_quicksort(npy_bool *start, npy_intp num, void *NOT_USED); -int BOOL_heapsort(npy_bool *start, npy_intp n, void *NOT_USED); -int BOOL_mergesort(npy_bool *start, npy_intp num, void *NOT_USED); -int BOOL_aquicksort(npy_bool *v, npy_intp* tosort, npy_intp num, void *NOT_USED); -int BOOL_aheapsort(npy_bool *v, npy_intp *tosort, npy_intp n, void *NOT_USED); -int BOOL_amergesort(npy_bool *v, npy_intp *tosort, npy_intp num, void *NOT_USED); +int quicksort_npy_bool(npy_bool *vec, npy_intp cnt, void *null); +int heapsort_npy_bool(npy_bool *vec, npy_intp cnt, void *null); +int mergesort_npy_bool(npy_bool *vec, npy_intp cnt, void *null); +int aquicksort_npy_bool(npy_bool *vec, npy_intp *ind, npy_intp cnt, void *null); +int aheapsort_npy_bool(npy_bool *vec, npy_intp *ind, npy_intp cnt, void *null); +int amergesort_npy_bool(npy_bool *vec, npy_intp *ind, npy_intp cnt, void *null); -int BYTE_quicksort(npy_byte *start, npy_intp num, void *NOT_USED); -int BYTE_heapsort(npy_byte *start, npy_intp n, void *NOT_USED); -int BYTE_mergesort(npy_byte *start, npy_intp num, void *NOT_USED); -int BYTE_aquicksort(npy_byte *v, npy_intp* tosort, npy_intp num, void *NOT_USED); -int BYTE_aheapsort(npy_byte *v, npy_intp *tosort, npy_intp n, void *NOT_USED); -int BYTE_amergesort(npy_byte *v, npy_intp *tosort, npy_intp num, void *NOT_USED); - - -int UBYTE_quicksort(npy_ubyte *start, npy_intp num, void *NOT_USED); -int UBYTE_heapsort(npy_ubyte *start, npy_intp n, void *NOT_USED); -int UBYTE_mergesort(npy_ubyte *start, npy_intp num, void *NOT_USED); -int UBYTE_aquicksort(npy_ubyte *v, npy_intp* tosort, npy_intp num, void *NOT_USED); -int UBYTE_aheapsort(npy_ubyte *v, npy_intp *tosort, npy_intp n, void *NOT_USED); -int UBYTE_amergesort(npy_ubyte *v, npy_intp *tosort, npy_intp num, void *NOT_USED); +int quicksort_npy_byte(npy_byte *vec, npy_intp cnt, void *null); +int heapsort_npy_byte(npy_byte *vec, npy_intp cnt, void *null); +int mergesort_npy_byte(npy_byte *vec, npy_intp cnt, void *null); +int aquicksort_npy_byte(npy_byte *vec, npy_intp *ind, npy_intp cnt, void *null); +int aheapsort_npy_byte(npy_byte *vec, npy_intp *ind, npy_intp cnt, void *null); +int amergesort_npy_byte(npy_byte *vec, npy_intp *ind, npy_intp cnt, void *null); + + +int quicksort_npy_ubyte(npy_ubyte *vec, npy_intp cnt, void *null); +int heapsort_npy_ubyte(npy_ubyte *vec, npy_intp cnt, void *null); +int mergesort_npy_ubyte(npy_ubyte *vec, npy_intp cnt, void *null); +int aquicksort_npy_ubyte(npy_ubyte *vec, npy_intp *ind, npy_intp cnt, void *null); +int aheapsort_npy_ubyte(npy_ubyte *vec, npy_intp *ind, npy_intp cnt, void *null); +int amergesort_npy_ubyte(npy_ubyte *vec, npy_intp *ind, npy_intp cnt, void *null); -int SHORT_quicksort(npy_short *start, npy_intp num, void *NOT_USED); -int SHORT_heapsort(npy_short *start, npy_intp n, void *NOT_USED); -int SHORT_mergesort(npy_short *start, npy_intp num, void *NOT_USED); -int SHORT_aquicksort(npy_short *v, npy_intp* tosort, npy_intp num, void *NOT_USED); -int SHORT_aheapsort(npy_short *v, npy_intp *tosort, npy_intp n, void *NOT_USED); -int SHORT_amergesort(npy_short *v, npy_intp *tosort, npy_intp num, void *NOT_USED); - - -int USHORT_quicksort(npy_ushort *start, npy_intp num, void *NOT_USED); -int USHORT_heapsort(npy_ushort *start, npy_intp n, void *NOT_USED); -int USHORT_mergesort(npy_ushort *start, npy_intp num, void *NOT_USED); -int USHORT_aquicksort(npy_ushort *v, npy_intp* tosort, npy_intp num, void *NOT_USED); -int USHORT_aheapsort(npy_ushort *v, npy_intp *tosort, npy_intp n, void *NOT_USED); -int USHORT_amergesort(npy_ushort *v, npy_intp *tosort, npy_intp num, void *NOT_USED); +int quicksort_npy_short(npy_short *vec, npy_intp cnt, void *null); +int heapsort_npy_short(npy_short *vec, npy_intp cnt, void *null); +int mergesort_npy_short(npy_short *vec, npy_intp cnt, void *null); +int aquicksort_npy_short(npy_short *vec, npy_intp *ind, npy_intp cnt, void *null); +int aheapsort_npy_short(npy_short *vec, npy_intp *ind, npy_intp cnt, void *null); +int amergesort_npy_short(npy_short *vec, npy_intp *ind, npy_intp cnt, void *null); + + +int quicksort_npy_ushort(npy_ushort *vec, npy_intp cnt, void *null); +int heapsort_npy_ushort(npy_ushort *vec, npy_intp cnt, void *null); +int mergesort_npy_ushort(npy_ushort *vec, npy_intp cnt, void *null); +int aquicksort_npy_ushort(npy_ushort *vec, npy_intp *ind, npy_intp cnt, void *null); +int aheapsort_npy_ushort(npy_ushort *vec, npy_intp *ind, npy_intp cnt, void *null); +int amergesort_npy_ushort(npy_ushort *vec, npy_intp *ind, npy_intp cnt, void *null); -int INT_quicksort(npy_int *start, npy_intp num, void *NOT_USED); -int INT_heapsort(npy_int *start, npy_intp n, void *NOT_USED); -int INT_mergesort(npy_int *start, npy_intp num, void *NOT_USED); -int INT_aquicksort(npy_int *v, npy_intp* tosort, npy_intp num, void *NOT_USED); -int INT_aheapsort(npy_int *v, npy_intp *tosort, npy_intp n, void *NOT_USED); -int INT_amergesort(npy_int *v, npy_intp *tosort, npy_intp num, void *NOT_USED); - - -int UINT_quicksort(npy_uint *start, npy_intp num, void *NOT_USED); -int UINT_heapsort(npy_uint *start, npy_intp n, void *NOT_USED); -int UINT_mergesort(npy_uint *start, npy_intp num, void *NOT_USED); -int UINT_aquicksort(npy_uint *v, npy_intp* tosort, npy_intp num, void *NOT_USED); -int UINT_aheapsort(npy_uint *v, npy_intp *tosort, npy_intp n, void *NOT_USED); -int UINT_amergesort(npy_uint *v, npy_intp *tosort, npy_intp num, void *NOT_USED); - - -int LONG_quicksort(npy_long *start, npy_intp num, void *NOT_USED); -int LONG_heapsort(npy_long *start, npy_intp n, void *NOT_USED); -int LONG_mergesort(npy_long *start, npy_intp num, void *NOT_USED); -int LONG_aquicksort(npy_long *v, npy_intp* tosort, npy_intp num, void *NOT_USED); -int LONG_aheapsort(npy_long *v, npy_intp *tosort, npy_intp n, void *NOT_USED); -int LONG_amergesort(npy_long *v, npy_intp *tosort, npy_intp num, void *NOT_USED); - - -int ULONG_quicksort(npy_ulong *start, npy_intp num, void *NOT_USED); -int ULONG_heapsort(npy_ulong *start, npy_intp n, void *NOT_USED); -int ULONG_mergesort(npy_ulong *start, npy_intp num, void *NOT_USED); -int ULONG_aquicksort(npy_ulong *v, npy_intp* tosort, npy_intp num, void *NOT_USED); -int ULONG_aheapsort(npy_ulong *v, npy_intp *tosort, npy_intp n, void *NOT_USED); -int ULONG_amergesort(npy_ulong *v, npy_intp *tosort, npy_intp num, void *NOT_USED); - - -int LONGLONG_aquicksort(npy_longlong *v, npy_intp* tosort, npy_intp num, void *NOT_USED); -int LONGLONG_aheapsort(npy_longlong *v, npy_intp *tosort, npy_intp n, void *NOT_USED); -int LONGLONG_amergesort(npy_longlong *v, npy_intp *tosort, npy_intp num, void *NOT_USED); -int LONGLONG_quicksort(npy_longlong *start, npy_intp num, void *NOT_USED); -int LONGLONG_heapsort(npy_longlong *start, npy_intp n, void *NOT_USED); -int LONGLONG_mergesort(npy_longlong *start, npy_intp num, void *NOT_USED); - - -int ULONGLONG_quicksort(npy_ulonglong *start, npy_intp num, void *NOT_USED); -int ULONGLONG_heapsort(npy_ulonglong *start, npy_intp n, void *NOT_USED); -int ULONGLONG_mergesort(npy_ulonglong *start, npy_intp num, void *NOT_USED); -int ULONGLONG_aquicksort(npy_ulonglong *v, npy_intp* tosort, npy_intp num, void *NOT_USED); -int ULONGLONG_aheapsort(npy_ulonglong *v, npy_intp *tosort, npy_intp n, void *NOT_USED); -int ULONGLONG_amergesort(npy_ulonglong *v, npy_intp *tosort, npy_intp num, void *NOT_USED); - - -int HALF_quicksort(npy_ushort *start, npy_intp num, void *NOT_USED); -int HALF_heapsort(npy_ushort *start, npy_intp n, void *NOT_USED); -int HALF_mergesort(npy_ushort *start, npy_intp num, void *NOT_USED); -int HALF_aquicksort(npy_ushort *v, npy_intp* tosort, npy_intp num, void *NOT_USED); -int HALF_aheapsort(npy_ushort *v, npy_intp *tosort, npy_intp n, void *NOT_USED); -int HALF_amergesort(npy_ushort *v, npy_intp *tosort, npy_intp num, void *NOT_USED); - - -int FLOAT_quicksort(npy_float *start, npy_intp num, void *NOT_USED); -int FLOAT_heapsort(npy_float *start, npy_intp n, void *NOT_USED); -int FLOAT_mergesort(npy_float *start, npy_intp num, void *NOT_USED); -int FLOAT_aquicksort(npy_float *v, npy_intp* tosort, npy_intp num, void *NOT_USED); -int FLOAT_aheapsort(npy_float *v, npy_intp *tosort, npy_intp n, void *NOT_USED); -int FLOAT_amergesort(npy_float *v, npy_intp *tosort, npy_intp num, void *NOT_USED); +int quicksort_npy_int(npy_int *vec, npy_intp cnt, void *null); +int heapsort_npy_int(npy_int *vec, npy_intp cnt, void *null); +int mergesort_npy_int(npy_int *vec, npy_intp cnt, void *null); +int aquicksort_npy_int(npy_int *vec, npy_intp *ind, npy_intp cnt, void *null); +int aheapsort_npy_int(npy_int *vec, npy_intp *ind, npy_intp cnt, void *null); +int amergesort_npy_int(npy_int *vec, npy_intp *ind, npy_intp cnt, void *null); + + +int quicksort_npy_uint(npy_uint *vec, npy_intp cnt, void *null); +int heapsort_npy_uint(npy_uint *vec, npy_intp cnt, void *null); +int mergesort_npy_uint(npy_uint *vec, npy_intp cnt, void *null); +int aquicksort_npy_uint(npy_uint *vec, npy_intp *ind, npy_intp cnt, void *null); +int aheapsort_npy_uint(npy_uint *vec, npy_intp *ind, npy_intp cnt, void *null); +int amergesort_npy_uint(npy_uint *vec, npy_intp *ind, npy_intp cnt, void *null); + + +int quicksort_npy_long(npy_long *vec, npy_intp cnt, void *null); +int heapsort_npy_long(npy_long *vec, npy_intp cnt, void *null); +int mergesort_npy_long(npy_long *vec, npy_intp cnt, void *null); +int aquicksort_npy_long(npy_long *vec, npy_intp *ind, npy_intp cnt, void *null); +int aheapsort_npy_long(npy_long *vec, npy_intp *ind, npy_intp cnt, void *null); +int amergesort_npy_long(npy_long *vec, npy_intp *ind, npy_intp cnt, void *null); + + +int quicksort_npy_ulong(npy_ulong *vec, npy_intp cnt, void *null); +int heapsort_npy_ulong(npy_ulong *vec, npy_intp cnt, void *null); +int mergesort_npy_ulong(npy_ulong *vec, npy_intp cnt, void *null); +int aquicksort_npy_ulong(npy_ulong *vec, npy_intp *ind, npy_intp cnt, void *null); +int aheapsort_npy_ulong(npy_ulong *vec, npy_intp *ind, npy_intp cnt, void *null); +int amergesort_npy_ulong(npy_ulong *vec, npy_intp *ind, npy_intp cnt, void *null); + + +int quicksort_npy_longlong(npy_longlong *vec, npy_intp cnt, void *null); +int heapsort_npy_longlong(npy_longlong *vec, npy_intp cnt, void *null); +int mergesort_npy_longlong(npy_longlong *vec, npy_intp cnt, void *null); +int aquicksort_npy_longlong(npy_longlong *vec, npy_intp *ind, npy_intp cnt, void *null); +int aheapsort_npy_longlong(npy_longlong *vec, npy_intp *ind, npy_intp cnt, void *null); +int amergesort_npy_longlong(npy_longlong *vec, npy_intp *ind, npy_intp cnt, void *null); + + +int quicksort_npy_ulonglong(npy_ulonglong *vec, npy_intp cnt, void *null); +int heapsort_npy_ulonglong(npy_ulonglong *vec, npy_intp cnt, void *null); +int mergesort_npy_ulonglong(npy_ulonglong *vec, npy_intp cnt, void *null); +int aquicksort_npy_ulonglong(npy_ulonglong *vec, npy_intp *ind, npy_intp cnt, void *null); +int aheapsort_npy_ulonglong(npy_ulonglong *vec, npy_intp *ind, npy_intp cnt, void *null); +int amergesort_npy_ulonglong(npy_ulonglong *vec, npy_intp *ind, npy_intp cnt, void *null); + + +int quicksort_npy_half(npy_ushort *vec, npy_intp cnt, void *null); +int heapsort_npy_half(npy_ushort *vec, npy_intp cnt, void *null); +int mergesort_npy_half(npy_ushort *vec, npy_intp cnt, void *null); +int aquicksort_npy_half(npy_ushort *vec, npy_intp *ind, npy_intp cnt, void *null); +int aheapsort_npy_half(npy_ushort *vec, npy_intp *ind, npy_intp cnt, void *null); +int amergesort_npy_half(npy_ushort *vec, npy_intp *ind, npy_intp cnt, void *null); + + +int quicksort_npy_float(npy_float *vec, npy_intp cnt, void *null); +int heapsort_npy_float(npy_float *vec, npy_intp cnt, void *null); +int mergesort_npy_float(npy_float *vec, npy_intp cnt, void *null); +int aquicksort_npy_float(npy_float *vec, npy_intp *ind, npy_intp cnt, void *null); +int aheapsort_npy_float(npy_float *vec, npy_intp *ind, npy_intp cnt, void *null); +int amergesort_npy_float(npy_float *vec, npy_intp *ind, npy_intp cnt, void *null); -int DOUBLE_quicksort(npy_double *start, npy_intp num, void *NOT_USED); -int DOUBLE_heapsort(npy_double *start, npy_intp n, void *NOT_USED); -int DOUBLE_mergesort(npy_double *start, npy_intp num, void *NOT_USED); -int DOUBLE_aquicksort(npy_double *v, npy_intp* tosort, npy_intp num, void *NOT_USED); -int DOUBLE_aheapsort(npy_double *v, npy_intp *tosort, npy_intp n, void *NOT_USED); -int DOUBLE_amergesort(npy_double *v, npy_intp *tosort, npy_intp num, void *NOT_USED); - - -int LONGDOUBLE_quicksort(npy_longdouble *start, npy_intp num, void *NOT_USED); -int LONGDOUBLE_heapsort(npy_longdouble *start, npy_intp n, void *NOT_USED); -int LONGDOUBLE_mergesort(npy_longdouble *start, npy_intp num, void *NOT_USED); -int LONGDOUBLE_aquicksort(npy_longdouble *v, npy_intp* tosort, npy_intp num, void *NOT_USED); -int LONGDOUBLE_aheapsort(npy_longdouble *v, npy_intp *tosort, npy_intp n, void *NOT_USED); -int LONGDOUBLE_amergesort(npy_longdouble *v, npy_intp *tosort, npy_intp num, void *NOT_USED); +int quicksort_npy_double(npy_double *vec, npy_intp cnt, void *null); +int heapsort_npy_double(npy_double *vec, npy_intp cnt, void *null); +int mergesort_npy_double(npy_double *vec, npy_intp cnt, void *null); +int aquicksort_npy_double(npy_double *vec, npy_intp *ind, npy_intp cnt, void *null); +int aheapsort_npy_double(npy_double *vec, npy_intp *ind, npy_intp cnt, void *null); +int amergesort_npy_double(npy_double *vec, npy_intp *ind, npy_intp cnt, void *null); + + +int quicksort_npy_longdouble(npy_longdouble *vec, npy_intp cnt, void *null); +int heapsort_npy_longdouble(npy_longdouble *vec, npy_intp cnt, void *null); +int mergesort_npy_longdouble(npy_longdouble *vec, npy_intp cnt, void *null); +int aquicksort_npy_longdouble(npy_longdouble *vec, npy_intp *ind, npy_intp cnt, void *null); +int aheapsort_npy_longdouble(npy_longdouble *vec, npy_intp *ind, npy_intp cnt, void *null); +int amergesort_npy_longdouble(npy_longdouble *vec, npy_intp *ind, npy_intp cnt, void *null); -int CFLOAT_quicksort(npy_cfloat *start, npy_intp num, void *NOT_USED); -int CFLOAT_heapsort(npy_cfloat *start, npy_intp n, void *NOT_USED); -int CFLOAT_mergesort(npy_cfloat *start, npy_intp num, void *NOT_USED); -int CFLOAT_aquicksort(npy_cfloat *v, npy_intp* tosort, npy_intp num, void *NOT_USED); -int CFLOAT_aheapsort(npy_cfloat *v, npy_intp *tosort, npy_intp n, void *NOT_USED); -int CFLOAT_amergesort(npy_cfloat *v, npy_intp *tosort, npy_intp num, void *NOT_USED); - - -int CDOUBLE_quicksort(npy_cdouble *start, npy_intp num, void *NOT_USED); -int CDOUBLE_heapsort(npy_cdouble *start, npy_intp n, void *NOT_USED); -int CDOUBLE_mergesort(npy_cdouble *start, npy_intp num, void *NOT_USED); -int CDOUBLE_aquicksort(npy_cdouble *v, npy_intp* tosort, npy_intp num, void *NOT_USED); -int CDOUBLE_aheapsort(npy_cdouble *v, npy_intp *tosort, npy_intp n, void *NOT_USED); -int CDOUBLE_amergesort(npy_cdouble *v, npy_intp *tosort, npy_intp num, void *NOT_USED); +int quicksort_npy_cfloat(npy_cfloat *vec, npy_intp cnt, void *null); +int heapsort_npy_cfloat(npy_cfloat *vec, npy_intp cnt, void *null); +int mergesort_npy_cfloat(npy_cfloat *vec, npy_intp cnt, void *null); +int aquicksort_npy_cfloat(npy_cfloat *vec, npy_intp *ind, npy_intp cnt, void *null); +int aheapsort_npy_cfloat(npy_cfloat *vec, npy_intp *ind, npy_intp cnt, void *null); +int amergesort_npy_cfloat(npy_cfloat *vec, npy_intp *ind, npy_intp cnt, void *null); + + +int quicksort_npy_cdouble(npy_cdouble *vec, npy_intp cnt, void *null); +int heapsort_npy_cdouble(npy_cdouble *vec, npy_intp cnt, void *null); +int mergesort_npy_cdouble(npy_cdouble *vec, npy_intp cnt, void *null); +int aquicksort_npy_cdouble(npy_cdouble *vec, npy_intp *ind, npy_intp cnt, void *null); +int aheapsort_npy_cdouble(npy_cdouble *vec, npy_intp *ind, npy_intp cnt, void *null); +int amergesort_npy_cdouble(npy_cdouble *vec, npy_intp *ind, npy_intp cnt, void *null); -int CLONGDOUBLE_quicksort(npy_clongdouble *start, npy_intp num, void *NOT_USED); -int CLONGDOUBLE_heapsort(npy_clongdouble *start, npy_intp n, void *NOT_USED); -int CLONGDOUBLE_mergesort(npy_clongdouble *start, npy_intp num, void *NOT_USED); -int CLONGDOUBLE_aquicksort(npy_clongdouble *v, npy_intp* tosort, npy_intp num, void *NOT_USED); -int CLONGDOUBLE_aheapsort(npy_clongdouble *v, npy_intp *tosort, npy_intp n, void *NOT_USED); -int CLONGDOUBLE_amergesort(npy_clongdouble *v, npy_intp *tosort, npy_intp num, void *NOT_USED); - - -int STRING_mergesort(char *start, npy_intp num, PyArrayObject *arr); -int STRING_quicksort(char *start, npy_intp num, PyArrayObject *arr); -int STRING_heapsort(char *start, npy_intp n, PyArrayObject *arr); -int STRING_aheapsort(char *v, npy_intp *tosort, npy_intp n, PyArrayObject *arr); -int STRING_aquicksort(char *v, npy_intp* tosort, npy_intp num, PyArrayObject *arr); -int STRING_amergesort(char *v, npy_intp *tosort, npy_intp num, PyArrayObject *arr); +int quicksort_npy_clongdouble(npy_clongdouble *vec, npy_intp cnt, void *null); +int heapsort_npy_clongdouble(npy_clongdouble *vec, npy_intp cnt, void *null); +int mergesort_npy_clongdouble(npy_clongdouble *vec, npy_intp cnt, void *null); +int aquicksort_npy_clongdouble(npy_clongdouble *vec, npy_intp *ind, npy_intp cnt, void *null); +int aheapsort_npy_clongdouble(npy_clongdouble *vec, npy_intp *ind, npy_intp cnt, void *null); +int amergesort_npy_clongdouble(npy_clongdouble *vec, npy_intp *ind, npy_intp cnt, void *null); + + +int quicksort_npy_string(npy_char *vec, npy_intp cnt, PyArrayObject *arr); +int heapsort_npy_string(npy_char *vec, npy_intp cnt, PyArrayObject *arr); +int mergesort_npy_string(npy_char *vec, npy_intp cnt, PyArrayObject *arr); +int aquicksort_npy_string(npy_char *vec, npy_intp *ind, npy_intp cnt, PyArrayObject *arr); +int aheapsort_npy_string(npy_char *vec, npy_intp *ind, npy_intp cnt, PyArrayObject *arr); +int amergesort_npy_string(npy_char *vec, npy_intp *ind, npy_intp cnt, PyArrayObject *arr); -int UNICODE_mergesort(npy_ucs4 *start, npy_intp num, PyArrayObject *arr); -int UNICODE_quicksort(npy_ucs4 *start, npy_intp num, PyArrayObject *arr); -int UNICODE_heapsort(npy_ucs4 *start, npy_intp n, PyArrayObject *arr); -int UNICODE_aheapsort(npy_ucs4 *v, npy_intp *tosort, npy_intp n, PyArrayObject *arr); -int UNICODE_aquicksort(npy_ucs4 *v, npy_intp* tosort, npy_intp num, PyArrayObject *arr); -int UNICODE_amergesort(npy_ucs4 *v, npy_intp *tosort, npy_intp num, PyArrayObject *arr); +int quicksort_npy_unicode(npy_ucs4 *vec, npy_intp cnt, PyArrayObject *arr); +int heapsort_npy_unicode(npy_ucs4 *vec, npy_intp cnt, PyArrayObject *arr); +int mergesort_npy_unicode(npy_ucs4 *vec, npy_intp cnt, PyArrayObject *arr); +int aquicksort_npy_unicode(npy_ucs4 *vec, npy_intp *ind, npy_intp cnt, PyArrayObject *arr); +int aheapsort_npy_unicode(npy_ucs4 *vec, npy_intp *ind, npy_intp cnt, PyArrayObject *arr); +int amergesort_npy_unicode(npy_ucs4 *vec, npy_intp *ind, npy_intp cnt, PyArrayObject *arr); #endif diff --git a/numpy/core/src/npysort/sort.c.src b/numpy/core/src/npysort/sort.c.src index 90a44a3cd..3e2f320d4 100644 --- a/numpy/core/src/npysort/sort.c.src +++ b/numpy/core/src/npysort/sort.c.src @@ -49,15 +49,18 @@ * #TYPE = BOOL, BYTE, UBYTE, SHORT, USHORT, INT, UINT, LONG, ULONG, * LONGLONG, ULONGLONG, HALF, FLOAT, DOUBLE, LONGDOUBLE, * CFLOAT, CDOUBLE, CLONGDOUBLE# + * #suff = npy_bool, npy_byte, npy_ubyte, npy_short, npy_ushort, npy_int, + * npy_uint, npy_long, npy_ulong, npy_longlong, npy_ulonglong, + * npy_half, npy_float, npy_double, npy_longdouble, npy_cfloat, + * npy_cdouble, npy_clongdouble# * #type = npy_bool, npy_byte, npy_ubyte, npy_short, npy_ushort, npy_int, * npy_uint, npy_long, npy_ulong, npy_longlong, npy_ulonglong, * npy_ushort, npy_float, npy_double, npy_longdouble, npy_cfloat, * npy_cdouble, npy_clongdouble# */ - int -@TYPE@_quicksort(@type@ *start, npy_intp num, void *NOT_USED) +quicksort_@suff@(@type@ *start, npy_intp num, void *NOT_USED) { @type@ *pl = start; @type@ *pr = start + num - 1; @@ -119,7 +122,7 @@ int } int -@TYPE@_aquicksort(@type@ *v, npy_intp* tosort, npy_intp num, void *NOT_USED) +aquicksort_@suff@(@type@ *v, npy_intp* tosort, npy_intp num, void *NOT_USED) { @type@ vp; npy_intp *pl, *pr; @@ -185,7 +188,7 @@ int int -@TYPE@_heapsort(@type@ *start, npy_intp n, void *NOT_USED) +heapsort_@suff@(@type@ *start, npy_intp n, void *NOT_USED) { @type@ tmp, *a; npy_intp i,j,l; @@ -235,7 +238,7 @@ int } int -@TYPE@_aheapsort(@type@ *v, npy_intp *tosort, npy_intp n, void *NOT_USED) +aheapsort_@suff@(@type@ *v, npy_intp *tosort, npy_intp n, void *NOT_USED) { npy_intp *a, i,j,l, tmp; /* The arrays need to be offset by one for heapsort indexing */ @@ -283,22 +286,22 @@ int } static void -@TYPE@_mergesort0(@type@ *pl, @type@ *pr, @type@ *pw) +mergesort0_@suff@(@type@ *pl, @type@ *pr, @type@ *pw) { @type@ vp, *pi, *pj, *pk, *pm; if (pr - pl > SMALL_MERGESORT) { /* merge sort */ pm = pl + ((pr - pl) >> 1); - @TYPE@_mergesort0(pl, pm, pw); - @TYPE@_mergesort0(pm, pr, pw); + mergesort0_@suff@(pl, pm, pw); + mergesort0_@suff@(pm, pr, pw); for (pi = pw, pj = pl; pj < pm;) { *pi++ = *pj++; } pj = pw; pk = pl; while (pj < pi && pm < pr) { - if (@TYPE@_LT(*pm,*pj)) { + if (@TYPE@_LT(*pm, *pj)) { *pk = *pm++; } else { @@ -325,7 +328,7 @@ static void } int -@TYPE@_mergesort(@type@ *start, npy_intp num, void *NOT_USED) +mergesort_@suff@(@type@ *start, npy_intp num, void *NOT_USED) { @type@ *pl, *pr, *pw; @@ -336,14 +339,14 @@ int PyErr_NoMemory(); return -1; } - @TYPE@_mergesort0(pl, pr, pw); + mergesort0_@suff@(pl, pr, pw); PyDataMem_FREE(pw); return 0; } static void -@TYPE@_amergesort0(npy_intp *pl, npy_intp *pr, @type@ *v, npy_intp *pw) +amergesort0_@suff@(npy_intp *pl, npy_intp *pr, @type@ *v, npy_intp *pw) { @type@ vp; npy_intp vi, *pi, *pj, *pk, *pm; @@ -351,13 +354,13 @@ static void if (pr - pl > SMALL_MERGESORT) { /* merge sort */ pm = pl + ((pr - pl + 1)>>1); - @TYPE@_amergesort0(pl,pm-1,v,pw); - @TYPE@_amergesort0(pm,pr,v,pw); + amergesort0_@suff@(pl, pm-1, v, pw); + amergesort0_@suff@(pm, pr, v, pw); for (pi = pw, pj = pl; pj < pm; ++pi, ++pj) { *pi = *pj; } for (pk = pw, pm = pl; pk < pi && pj <= pr; ++pm) { - if (@TYPE@_LT(v[*pj],v[*pk])) { + if (@TYPE@_LT(v[*pj], v[*pk])) { *pm = *pj; ++pj; } @@ -384,7 +387,7 @@ static void } int -@TYPE@_amergesort(@type@ *v, npy_intp *tosort, npy_intp num, void *NOT_USED) +amergesort_@suff@(@type@ *v, npy_intp *tosort, npy_intp num, void *NOT_USED) { npy_intp *pl, *pr, *pw; @@ -396,7 +399,7 @@ int return -1; } - @TYPE@_amergesort0(pl, pr, v, pw); + amergesort0_@suff@(pl, pr, v, pw); PyDimMem_FREE(pw); return 0; @@ -415,19 +418,20 @@ int /**begin repeat * * #TYPE = STRING, UNICODE# - * #type = char, npy_ucs4# + * #suff = npy_string, npy_unicode# + * #type = npy_char, npy_ucs4# */ static void -@TYPE@_mergesort0(@type@ *pl, @type@ *pr, @type@ *pw, @type@ *vp, size_t len) +mergesort0_@suff@(@type@ *pl, @type@ *pr, @type@ *pw, @type@ *vp, size_t len) { @type@ *pi, *pj, *pk, *pm; if ((size_t)(pr - pl) > SMALL_MERGESORT*len) { /* merge sort */ pm = pl + (((pr - pl)/len) >> 1)*len; - @TYPE@_mergesort0(pl, pm, pw, vp, len); - @TYPE@_mergesort0(pm, pr, pw, vp, len); + mergesort0_@suff@(pl, pm, pw, vp, len); + mergesort0_@suff@(pm, pr, pw, vp, len); @TYPE@_COPY(pw, pl, pm - pl); pi = pw + (pm - pl); pj = pw; @@ -462,7 +466,7 @@ static void } int -@TYPE@_mergesort(@type@ *start, npy_intp num, PyArrayObject *arr) +mergesort_@suff@(@type@ *start, npy_intp num, PyArrayObject *arr) { const size_t elsize = arr->descr->elsize; const size_t len = elsize / sizeof(@type@); @@ -483,7 +487,7 @@ int err = -1; goto fail_1; } - @TYPE@_mergesort0(pl, pr, pw, vp, len); + mergesort0_@suff@(pl, pr, pw, vp, len); PyDataMem_FREE(vp); fail_1: @@ -493,7 +497,7 @@ fail_0: } int -@TYPE@_quicksort(@type@ *start, npy_intp num, PyArrayObject *arr) +quicksort_@suff@(@type@ *start, npy_intp num, PyArrayObject *arr) { const size_t len = arr->descr->elsize/sizeof(@type@); @type@ *vp = malloc(arr->descr->elsize); @@ -560,7 +564,7 @@ int int -@TYPE@_heapsort(@type@ *start, npy_intp n, PyArrayObject *arr) +heapsort_@suff@(@type@ *start, npy_intp n, PyArrayObject *arr) { size_t len = arr->descr->elsize/sizeof(@type@); @type@ *tmp = malloc(arr->descr->elsize); @@ -609,7 +613,7 @@ int int -@TYPE@_aheapsort(@type@ *v, npy_intp *tosort, npy_intp n, PyArrayObject *arr) +aheapsort_@suff@(@type@ *v, npy_intp *tosort, npy_intp n, PyArrayObject *arr) { size_t len = arr->descr->elsize/sizeof(@type@); npy_intp *a, i,j,l, tmp; @@ -658,7 +662,7 @@ int int -@TYPE@_aquicksort(@type@ *v, npy_intp* tosort, npy_intp num, PyArrayObject *arr) +aquicksort_@suff@(@type@ *v, npy_intp* tosort, npy_intp num, PyArrayObject *arr) { size_t len = arr->descr->elsize/sizeof(@type@); @type@ *vp; @@ -725,7 +729,7 @@ int static void -@TYPE@_amergesort0(npy_intp *pl, npy_intp *pr, @type@ *v, npy_intp *pw, int len) +amergesort0_@suff@(npy_intp *pl, npy_intp *pr, @type@ *v, npy_intp *pw, int len) { @type@ *vp; npy_intp vi, *pi, *pj, *pk, *pm; @@ -733,8 +737,8 @@ static void if (pr - pl > SMALL_MERGESORT) { /* merge sort */ pm = pl + ((pr - pl) >> 1); - @TYPE@_amergesort0(pl,pm,v,pw,len); - @TYPE@_amergesort0(pm,pr,v,pw,len); + amergesort0_@suff@(pl, pm, v, pw, len); + amergesort0_@suff@(pm, pr, v, pw, len); for (pi = pw, pj = pl; pj < pm;) { *pi++ = *pj++; } @@ -768,7 +772,7 @@ static void int -@TYPE@_amergesort(@type@ *v, npy_intp *tosort, npy_intp num, PyArrayObject *arr) +amergesort_@suff@(@type@ *v, npy_intp *tosort, npy_intp num, PyArrayObject *arr) { const size_t elsize = arr->descr->elsize; const size_t len = elsize / sizeof(@type@); @@ -781,7 +785,7 @@ int PyErr_NoMemory(); return -1; } - @TYPE@_amergesort0(pl, pr, v, pw, len); + amergesort0_@suff@(pl, pr, v, pw, len); PyDimMem_FREE(pw); return 0; diff --git a/numpy/core/src/npysort/sortmodule.c.src b/numpy/core/src/npysort/sortmodule.c.src index 9aabc1100..6f59b0cf9 100644 --- a/numpy/core/src/npysort/sortmodule.c.src +++ b/numpy/core/src/npysort/sortmodule.c.src @@ -40,20 +40,24 @@ add_sortfuncs(void) * #TYPE = BOOL, BYTE, UBYTE, SHORT, USHORT, INT, UINT, LONG, ULONG, * LONGLONG, ULONGLONG, HALF, FLOAT, DOUBLE, LONGDOUBLE, * CFLOAT, CDOUBLE, CLONGDOUBLE, STRING, UNICODE# + * #suff = npy_bool, npy_byte, npy_ubyte, npy_short, npy_ushort, npy_int, + * npy_uint, npy_long, npy_ulong, npy_longlong, npy_ulonglong, + * npy_half, npy_float, npy_double, npy_longdouble, npy_cfloat, + * npy_cdouble, npy_clongdouble, npy_string, npy_unicode# */ descr = PyArray_DescrFromType(PyArray_@TYPE@); descr->f->sort[PyArray_QUICKSORT] = - (PyArray_SortFunc *)@TYPE@_quicksort; - descr->f->argsort[PyArray_QUICKSORT] = - (PyArray_ArgSortFunc *)@TYPE@_aquicksort; + (PyArray_SortFunc *)quicksort_@suff@; descr->f->sort[PyArray_HEAPSORT] = - (PyArray_SortFunc *)@TYPE@_heapsort; - descr->f->argsort[PyArray_HEAPSORT] = - (PyArray_ArgSortFunc *)@TYPE@_aheapsort; + (PyArray_SortFunc *)heapsort_@suff@; descr->f->sort[PyArray_MERGESORT] = - (PyArray_SortFunc *)@TYPE@_mergesort; + (PyArray_SortFunc *)mergesort_@suff@; + descr->f->argsort[PyArray_QUICKSORT] = + (PyArray_ArgSortFunc *)aquicksort_@suff@; + descr->f->argsort[PyArray_HEAPSORT] = + (PyArray_ArgSortFunc *)aheapsort_@suff@; descr->f->argsort[PyArray_MERGESORT] = - (PyArray_ArgSortFunc *)@TYPE@_amergesort; + (PyArray_ArgSortFunc *)amergesort_@suff@; /**end repeat**/ } |