1
|
|
#ifndef __NPY_SORT_H__
|
2
|
|
#define __NPY_SORT_H__
|
3
|
|
|
4
|
|
/* Python include is for future object sorts */
|
5
|
|
#include <Python.h>
|
6
|
|
#include <numpy/npy_common.h>
|
7
|
|
#include <numpy/ndarraytypes.h>
|
8
|
|
|
9
|
|
#define NPY_ENOMEM 1
|
10
|
|
#define NPY_ECOMP 2
|
11
|
|
|
12
|
|
static NPY_INLINE int npy_get_msb(npy_uintp unum)
|
13
|
|
{
|
14
|
1
|
int depth_limit = 0;
|
15
|
1
|
while (unum >>= 1) {
|
16
|
1
|
depth_limit++;
|
17
|
|
}
|
18
|
|
return depth_limit;
|
19
|
|
}
|
20
|
|
|
21
|
|
|
22
|
|
/*
|
23
|
|
*****************************************************************************
|
24
|
|
** NUMERIC SORTS **
|
25
|
|
*****************************************************************************
|
26
|
|
*/
|
27
|
|
|
28
|
|
|
29
|
|
/**begin repeat
|
30
|
|
*
|
31
|
|
* #suff = bool, byte, ubyte, short, ushort, int, uint, long, ulong,
|
32
|
|
* longlong, ulonglong, half, float, double, longdouble,
|
33
|
|
* cfloat, cdouble, clongdouble, datetime, timedelta#
|
34
|
|
*/
|
35
|
|
|
36
|
|
NPY_NO_EXPORT int quicksort_@suff@(void *vec, npy_intp cnt, void *null);
|
37
|
|
NPY_NO_EXPORT int heapsort_@suff@(void *vec, npy_intp cnt, void *null);
|
38
|
|
NPY_NO_EXPORT int mergesort_@suff@(void *vec, npy_intp cnt, void *null);
|
39
|
|
NPY_NO_EXPORT int timsort_@suff@(void *vec, npy_intp cnt, void *null);
|
40
|
|
NPY_NO_EXPORT int aquicksort_@suff@(void *vec, npy_intp *ind, npy_intp cnt, void *null);
|
41
|
|
NPY_NO_EXPORT int aheapsort_@suff@(void *vec, npy_intp *ind, npy_intp cnt, void *null);
|
42
|
|
NPY_NO_EXPORT int amergesort_@suff@(void *vec, npy_intp *ind, npy_intp cnt, void *null);
|
43
|
|
NPY_NO_EXPORT int atimsort_@suff@(void *vec, npy_intp *ind, npy_intp cnt, void *null);
|
44
|
|
|
45
|
|
/**end repeat**/
|
46
|
|
|
47
|
|
/**begin repeat
|
48
|
|
*
|
49
|
|
* #suff = bool, byte, ubyte, short, ushort, int, uint, long, ulong,
|
50
|
|
* longlong, ulonglong#
|
51
|
|
*/
|
52
|
|
|
53
|
|
NPY_NO_EXPORT int radixsort_@suff@(void *vec, npy_intp cnt, void *null);
|
54
|
|
NPY_NO_EXPORT int aradixsort_@suff@(void *vec, npy_intp *ind, npy_intp cnt, void *null);
|
55
|
|
|
56
|
|
/**end repeat**/
|
57
|
|
|
58
|
|
|
59
|
|
|
60
|
|
/*
|
61
|
|
*****************************************************************************
|
62
|
|
** STRING SORTS **
|
63
|
|
*****************************************************************************
|
64
|
|
*/
|
65
|
|
|
66
|
|
|
67
|
|
/**begin repeat
|
68
|
|
*
|
69
|
|
* #suff = string, unicode#
|
70
|
|
*/
|
71
|
|
|
72
|
|
NPY_NO_EXPORT int quicksort_@suff@(void *vec, npy_intp cnt, void *arr);
|
73
|
|
NPY_NO_EXPORT int heapsort_@suff@(void *vec, npy_intp cnt, void *arr);
|
74
|
|
NPY_NO_EXPORT int mergesort_@suff@(void *vec, npy_intp cnt, void *arr);
|
75
|
|
NPY_NO_EXPORT int timsort_@suff@(void *vec, npy_intp cnt, void *arr);
|
76
|
|
NPY_NO_EXPORT int aquicksort_@suff@(void *vec, npy_intp *ind, npy_intp cnt, void *arr);
|
77
|
|
NPY_NO_EXPORT int aheapsort_@suff@(void *vec, npy_intp *ind, npy_intp cnt, void *arr);
|
78
|
|
NPY_NO_EXPORT int amergesort_@suff@(void *vec, npy_intp *ind, npy_intp cnt, void *arr);
|
79
|
|
NPY_NO_EXPORT int atimsort_@suff@(void *vec, npy_intp *ind, npy_intp cnt, void *arr);
|
80
|
|
|
81
|
|
/**end repeat**/
|
82
|
|
|
83
|
|
|
84
|
|
/*
|
85
|
|
*****************************************************************************
|
86
|
|
** GENERIC SORT **
|
87
|
|
*****************************************************************************
|
88
|
|
*/
|
89
|
|
|
90
|
|
|
91
|
|
NPY_NO_EXPORT int npy_quicksort(void *vec, npy_intp cnt, void *arr);
|
92
|
|
NPY_NO_EXPORT int npy_heapsort(void *vec, npy_intp cnt, void *arr);
|
93
|
|
NPY_NO_EXPORT int npy_mergesort(void *vec, npy_intp cnt, void *arr);
|
94
|
|
NPY_NO_EXPORT int npy_timsort(void *vec, npy_intp cnt, void *arr);
|
95
|
|
NPY_NO_EXPORT int npy_aquicksort(void *vec, npy_intp *ind, npy_intp cnt, void *arr);
|
96
|
|
NPY_NO_EXPORT int npy_aheapsort(void *vec, npy_intp *ind, npy_intp cnt, void *arr);
|
97
|
|
NPY_NO_EXPORT int npy_amergesort(void *vec, npy_intp *ind, npy_intp cnt, void *arr);
|
98
|
|
NPY_NO_EXPORT int npy_atimsort(void *vec, npy_intp *ind, npy_intp cnt, void *arr);
|
99
|
|
|
100
|
|
#endif
|