summaryrefslogtreecommitdiff
path: root/numpy
diff options
context:
space:
mode:
authorCharles Harris <charlesr.harris@gmail.com>2011-06-05 23:03:17 -0600
committerCharles Harris <charlesr.harris@gmail.com>2011-06-16 20:15:00 -0600
commit60054e398e52c690a3769dea9a25883bf4cae9f4 (patch)
tree7c7d5ff58b1a396f402dbe1e65ba93a8d65f134b /numpy
parentf4ba3edfe94b7990a79bff03a73369b584e9a72e (diff)
downloadnumpy-60054e398e52c690a3769dea9a25883bf4cae9f4.tar.gz
ENH: Move comparison functions into an include file.
Make include file for the future sorting library. Use prefixed numpy types.
Diffstat (limited to 'numpy')
-rw-r--r--numpy/core/include/numpy/npy_sort.h128
-rw-r--r--numpy/core/setup.py1
-rw-r--r--numpy/core/src/sorting/npy_sort_common.h306
-rw-r--r--numpy/core/src/sorting/sortmodule.c.src200
4 files changed, 444 insertions, 191 deletions
diff --git a/numpy/core/include/numpy/npy_sort.h b/numpy/core/include/numpy/npy_sort.h
new file mode 100644
index 000000000..c31155705
--- /dev/null
+++ b/numpy/core/include/numpy/npy_sort.h
@@ -0,0 +1,128 @@
+#ifndef __NPY_SORT_H__
+#define __NPY_SORT_H__
+
+/* Python include is for future object sorts */
+#include <Python.h>
+#include <numpy/npy_common.h>
+
+
+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);
+void BOOL_amergesort0(npy_intp *pl, npy_intp *pr, npy_bool *v, npy_intp *pw);
+int BOOL_amergesort(npy_bool *v, npy_intp *tosort, 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);
+void BYTE_amergesort0(npy_intp *pl, npy_intp *pr, npy_byte *v, npy_intp *pw);
+int BYTE_amergesort(npy_byte *v, npy_intp *tosort, 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);
+void UBYTE_amergesort0(npy_intp *pl, npy_intp *pr, npy_ubyte *v, npy_intp *pw);
+int UBYTE_amergesort(npy_ubyte *v, npy_intp *tosort, 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);
+void SHORT_amergesort0(npy_intp *pl, npy_intp *pr, npy_short *v, npy_intp *pw);
+int SHORT_amergesort(npy_short *v, npy_intp *tosort, 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);
+void USHORT_amergesort0(npy_intp *pl, npy_intp *pr, npy_ushort *v, npy_intp *pw);
+int USHORT_amergesort(npy_ushort *v, npy_intp *tosort, 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);
+void INT_amergesort0(npy_intp *pl, npy_intp *pr, npy_int *v, npy_intp *pw);
+int INT_amergesort(npy_int *v, npy_intp *tosort, 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);
+void UINT_amergesort0(npy_intp *pl, npy_intp *pr, npy_uint *v, npy_intp *pw);
+int UINT_amergesort(npy_uint *v, npy_intp *tosort, 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);
+void LONG_amergesort0(npy_intp *pl, npy_intp *pr, npy_long *v, npy_intp *pw);
+int LONG_amergesort(npy_long *v, npy_intp *tosort, 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);
+void ULONG_amergesort0(npy_intp *pl, npy_intp *pr, npy_ulong *v, npy_intp *pw);
+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);
+void LONGLONG_amergesort0(npy_intp *pl, npy_intp *pr, npy_longlong *v, npy_intp *pw);
+int LONGLONG_amergesort(npy_longlong *v, npy_intp *tosort, 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);
+void ULONGLONG_amergesort0(npy_intp *pl, npy_intp *pr, npy_ulonglong *v, npy_intp *pw);
+int ULONGLONG_amergesort(npy_ulonglong *v, npy_intp *tosort, 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);
+void HALF_amergesort0(npy_intp *pl, npy_intp *pr, npy_ushort *v, npy_intp *pw);
+int HALF_amergesort(npy_ushort *v, npy_intp *tosort, 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);
+void FLOAT_amergesort0(npy_intp *pl, npy_intp *pr, npy_float *v, npy_intp *pw);
+int FLOAT_amergesort(npy_float *v, npy_intp *tosort, 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);
+void DOUBLE_amergesort0(npy_intp *pl, npy_intp *pr, npy_double *v, npy_intp *pw);
+int DOUBLE_amergesort(npy_double *v, npy_intp *tosort, 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);
+void LONGDOUBLE_amergesort0(npy_intp *pl, npy_intp *pr, npy_longdouble *v, npy_intp *pw);
+int LONGDOUBLE_amergesort(npy_longdouble *v, npy_intp *tosort, 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);
+void CFLOAT_amergesort0(npy_intp *pl, npy_intp *pr, npy_cfloat *v, npy_intp *pw);
+int CFLOAT_amergesort(npy_cfloat *v, npy_intp *tosort, 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);
+void CDOUBLE_amergesort0(npy_intp *pl, npy_intp *pr, npy_cdouble *v, npy_intp *pw);
+int CDOUBLE_amergesort(npy_cdouble *v, npy_intp *tosort, 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);
+void CLONGDOUBLE_amergesort0(npy_intp *pl, npy_intp *pr, npy_clongdouble *v, npy_intp *pw);
+int CLONGDOUBLE_amergesort(npy_clongdouble *v, npy_intp *tosort, npy_intp num, void *NOT_USED);
+
+
+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);
+void STRING_amergesort0(npy_intp *pl, npy_intp *pr, char *v, npy_intp *pw, int len);
+int STRING_amergesort(char *v, npy_intp *tosort, npy_intp num, 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);
+void UNICODE_amergesort0(npy_intp *pl, npy_intp *pr, npy_ucs4 *v, npy_intp *pw, int len);
+int UNICODE_amergesort(npy_ucs4 *v, npy_intp *tosort, npy_intp num, PyArrayObject *arr);
+
+#endif
diff --git a/numpy/core/setup.py b/numpy/core/setup.py
index f53186b42..ab4f913c0 100644
--- a/numpy/core/setup.py
+++ b/numpy/core/setup.py
@@ -653,6 +653,7 @@ def configuration(parent_package='',top_path=None):
config.add_include_dirs(join('src', 'npymath'))
config.add_include_dirs(join('src', 'multiarray'))
config.add_include_dirs(join('src', 'umath'))
+ config.add_include_dirs(join('src', 'sorting'))
config.numpy_include_dirs.extend(config.paths('include'))
diff --git a/numpy/core/src/sorting/npy_sort_common.h b/numpy/core/src/sorting/npy_sort_common.h
new file mode 100644
index 000000000..d4b3a0b3e
--- /dev/null
+++ b/numpy/core/src/sorting/npy_sort_common.h
@@ -0,0 +1,306 @@
+#ifndef __NPY_SORT_COMMON_H__
+#define __NPY_SORT_COMMON_H__
+
+
+#include "Python.h"
+#include "numpy/npy_common.h"
+#include "numpy/npy_math.h"
+#include "numpy/halffloat.h"
+#include "npy_config.h"
+
+
+/*
+ *****************************************************************************
+ ** SWAP MACROS **
+ *****************************************************************************
+ */
+
+#define BOOL_SWAP(a,b) {npy_bool tmp = (b); (b)=(a); (a) = tmp;}
+#define BYTE_SWAP(a,b) {npy_byte tmp = (b); (b)=(a); (a) = tmp;}
+#define UBYTE_SWAP(a,b) {npy_ubyte tmp = (b); (b)=(a); (a) = tmp;}
+#define SHORT_SWAP(a,b) {npy_short tmp = (b); (b)=(a); (a) = tmp;}
+#define USHORT_SWAP(a,b) {npy_ushort tmp = (b); (b)=(a); (a) = tmp;}
+#define INT_SWAP(a,b) {npy_int tmp = (b); (b)=(a); (a) = tmp;}
+#define UINT_SWAP(a,b) {npy_uint tmp = (b); (b)=(a); (a) = tmp;}
+#define LONG_SWAP(a,b) {npy_long tmp = (b); (b)=(a); (a) = tmp;}
+#define ULONG_SWAP(a,b) {npy_ulong tmp = (b); (b)=(a); (a) = tmp;}
+#define LONGLONG_SWAP(a,b) {npy_longlong tmp = (b); (b)=(a); (a) = tmp;}
+#define ULONGLONG_SWAP(a,b) {npy_ulonglong tmp = (b); (b)=(a); (a) = tmp;}
+#define HALF_SWAP(a,b) {npy_half tmp = (b); (b)=(a); (a) = tmp;}
+#define FLOAT_SWAP(a,b) {npy_float tmp = (b); (b)=(a); (a) = tmp;}
+#define DOUBLE_SWAP(a,b) {npy_double tmp = (b); (b)=(a); (a) = tmp;}
+#define LONGDOUBLE_SWAP(a,b) {npy_longdouble tmp = (b); (b)=(a); (a) = tmp;}
+#define CFLOAT_SWAP(a,b) {npy_cfloat tmp = (b); (b)=(a); (a) = tmp;}
+#define CDOUBLE_SWAP(a,b) {npy_cdouble tmp = (b); (b)=(a); (a) = tmp;}
+#define CLONGDOUBLE_SWAP(a,b) {npy_clongdouble tmp = (b); (b)=(a); (a) = tmp;}
+#define INTP_SWAP(a,b) {npy_intp tmp = (b); (b)=(a); (a) = tmp;}
+
+/*
+ *****************************************************************************
+ ** COMPARISON FUNCTIONS **
+ *****************************************************************************
+ */
+
+NPY_INLINE static int
+BOOL_LT(npy_bool a, npy_bool b)
+{
+ return a < b;
+}
+
+
+NPY_INLINE static int
+BYTE_LT(npy_byte a, npy_byte b)
+{
+ return a < b;
+}
+
+
+NPY_INLINE static int
+UBYTE_LT(npy_ubyte a, npy_ubyte b)
+{
+ return a < b;
+}
+
+
+NPY_INLINE static int
+SHORT_LT(npy_short a, npy_short b)
+{
+ return a < b;
+}
+
+
+NPY_INLINE static int
+USHORT_LT(npy_ushort a, npy_ushort b)
+{
+ return a < b;
+}
+
+
+NPY_INLINE static int
+INT_LT(npy_int a, npy_int b)
+{
+ return a < b;
+}
+
+
+NPY_INLINE static int
+UINT_LT(npy_uint a, npy_uint b)
+{
+ return a < b;
+}
+
+
+NPY_INLINE static int
+LONG_LT(npy_long a, npy_long b)
+{
+ return a < b;
+}
+
+
+NPY_INLINE static int
+ULONG_LT(npy_ulong a, npy_ulong b)
+{
+ return a < b;
+}
+
+
+NPY_INLINE static int
+LONGLONG_LT(npy_longlong a, npy_longlong b)
+{
+ return a < b;
+}
+
+
+NPY_INLINE static int
+ULONGLONG_LT(npy_ulonglong a, npy_ulonglong b)
+{
+ return a < b;
+}
+
+
+NPY_INLINE static int
+FLOAT_LT(npy_float a, npy_float b)
+{
+ return a < b || (b != b && a == a);
+}
+
+
+NPY_INLINE static int
+DOUBLE_LT(npy_double a, npy_double b)
+{
+ return a < b || (b != b && a == a);
+}
+
+
+NPY_INLINE static int
+LONGDOUBLE_LT(npy_longdouble a, npy_longdouble b)
+{
+ return a < b || (b != b && a == a);
+}
+
+
+NPY_INLINE static int
+HALF_LT(npy_half a, npy_half b)
+{
+ int ret;
+
+ if (npy_half_isnan(b)) {
+ ret = !npy_half_isnan(a);
+ } else {
+ ret = !npy_half_isnan(a) && npy_half_lt_nonan(a, b);
+ }
+
+ return ret;
+}
+
+/*
+ * For inline functions SUN recommends not using a return in the then part
+ * of an if statement. It's a SUN compiler thing, so assign the return value
+ * to a variable instead.
+ */
+NPY_INLINE static int
+CFLOAT_LT(npy_cfloat a, npy_cfloat b)
+{
+ int ret;
+
+ if (a.real < b.real) {
+ ret = a.imag == a.imag || b.imag != b.imag;
+ }
+ else if (a.real > b.real) {
+ ret = b.imag != b.imag && a.imag == a.imag;
+ }
+ else if (a.real == b.real || (a.real != a.real && b.real != b.real)) {
+ ret = a.imag < b.imag || (b.imag != b.imag && a.imag == a.imag);
+ }
+ else {
+ ret = b.real != b.real;
+ }
+
+ return ret;
+}
+
+
+NPY_INLINE static int
+CDOUBLE_LT(npy_cdouble a, npy_cdouble b)
+{
+ int ret;
+
+ if (a.real < b.real) {
+ ret = a.imag == a.imag || b.imag != b.imag;
+ }
+ else if (a.real > b.real) {
+ ret = b.imag != b.imag && a.imag == a.imag;
+ }
+ else if (a.real == b.real || (a.real != a.real && b.real != b.real)) {
+ ret = a.imag < b.imag || (b.imag != b.imag && a.imag == a.imag);
+ }
+ else {
+ ret = b.real != b.real;
+ }
+
+ return ret;
+}
+
+
+NPY_INLINE static int
+CLONGDOUBLE_LT(npy_clongdouble a, npy_clongdouble b)
+{
+ int ret;
+
+ if (a.real < b.real) {
+ ret = a.imag == a.imag || b.imag != b.imag;
+ }
+ else if (a.real > b.real) {
+ ret = b.imag != b.imag && a.imag == a.imag;
+ }
+ else if (a.real == b.real || (a.real != a.real && b.real != b.real)) {
+ ret = a.imag < b.imag || (b.imag != b.imag && a.imag == a.imag);
+ }
+ else {
+ ret = b.real != b.real;
+ }
+
+ return ret;
+}
+
+
+/* The PyObject functions are stubs for later use */
+NPY_INLINE static int
+PyObject_LT(PyObject *pa, PyObject *pb)
+{
+ return 0;
+}
+
+
+NPY_INLINE static void
+STRING_COPY(char *s1, char *s2, size_t len)
+{
+ memcpy(s1, s2, len);
+}
+
+
+NPY_INLINE static void
+STRING_SWAP(char *s1, char *s2, size_t len)
+{
+ while(len--) {
+ const char t = *s1;
+ *s1++ = *s2;
+ *s2++ = t;
+ }
+}
+
+
+NPY_INLINE static int
+STRING_LT(char *s1, char *s2, size_t len)
+{
+ const unsigned char *c1 = (unsigned char *)s1;
+ const unsigned char *c2 = (unsigned char *)s2;
+ size_t i;
+ int ret = 0;
+
+ for (i = 0; i < len; ++i) {
+ if (c1[i] != c2[i]) {
+ ret = c1[i] < c2[i];
+ break;
+ }
+ }
+ return ret;
+}
+
+
+NPY_INLINE static void
+UNICODE_COPY(npy_ucs4 *s1, npy_ucs4 *s2, size_t len)
+{
+ while(len--) {
+ *s1++ = *s2++;
+ }
+}
+
+
+NPY_INLINE static void
+UNICODE_SWAP(npy_ucs4 *s1, npy_ucs4 *s2, size_t len)
+{
+ while(len--) {
+ const npy_ucs4 t = *s1;
+ *s1++ = *s2;
+ *s2++ = t;
+ }
+}
+
+
+NPY_INLINE static int
+UNICODE_LT(npy_ucs4 *s1, npy_ucs4 *s2, size_t len)
+{
+ size_t i;
+ int ret = 0;
+
+ for (i = 0; i < len; ++i) {
+ if (s1[i] != s2[i]) {
+ ret = s1[i] < s2[i];
+ break;
+ }
+ }
+ return ret;
+}
+
+#endif
diff --git a/numpy/core/src/sorting/sortmodule.c.src b/numpy/core/src/sorting/sortmodule.c.src
index 527d0c402..f242b3393 100644
--- a/numpy/core/src/sorting/sortmodule.c.src
+++ b/numpy/core/src/sorting/sortmodule.c.src
@@ -26,13 +26,7 @@
* The heap sort is included for completeness.
*/
-
-#include "Python.h"
-#include "numpy/noprefix.h"
-#include "numpy/npy_math.h"
-#include "numpy/halffloat.h"
-
-#include "npy_config.h"
+#include "npy_sort_common.h"
#define NOT_USED NPY_UNUSED(unused)
#define PYA_QS_STACK 100
@@ -40,186 +34,6 @@
#define SMALL_MERGESORT 20
#define SMALL_STRING 16
-/*
- *****************************************************************************
- ** SWAP MACROS **
- *****************************************************************************
- */
-
-/**begin repeat
- *
- * #TYPE = BOOL, BYTE, UBYTE, SHORT, USHORT, INT, UINT, LONG, ULONG,
- * LONGLONG, ULONGLONG, HALF, FLOAT, DOUBLE, LONGDOUBLE, CFLOAT,
- * CDOUBLE,CLONGDOUBLE, INTP#
- * #type = 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_intp#
- */
-#define @TYPE@_SWAP(a,b) {@type@ tmp = (b); (b)=(a); (a) = tmp;}
-
-/**end repeat**/
-
-/*
- *****************************************************************************
- ** COMPARISON FUNCTIONS **
- *****************************************************************************
- */
-
-/**begin repeat
- *
- * #TYPE = BOOL, BYTE, UBYTE, SHORT, USHORT, INT, UINT, LONG, ULONG,
- * LONGLONG, ULONGLONG#
- * #type = Bool, byte, ubyte, short, ushort, int, uint, long, ulong,
- * longlong, ulonglong#
- */
-NPY_INLINE static int
-@TYPE@_LT(@type@ a, @type@ b)
-{
- return a < b;
-}
-/**end repeat**/
-
-
-/**begin repeat
- *
- * #TYPE = FLOAT, DOUBLE, LONGDOUBLE#
- * #type = float, double, longdouble#
- */
-NPY_INLINE static int
-@TYPE@_LT(@type@ a, @type@ b)
-{
- return a < b || (b != b && a == a);
-}
-/**end repeat**/
-
-NPY_INLINE static int
-HALF_LT(npy_half a, npy_half b)
-{
- int ret;
-
- if (npy_half_isnan(b)) {
- ret = !npy_half_isnan(a);
- } else {
- ret = !npy_half_isnan(a) && npy_half_lt_nonan(a, b);
- }
-
- return ret;
-}
-
-/*
- * For inline functions SUN recommends not using a return in the then part
- * of an if statement. It's a SUN compiler thing, so assign the return value
- * to a variable instead.
- */
-
-/**begin repeat
- *
- * #TYPE = CFLOAT, CDOUBLE, CLONGDOUBLE#
- * #type = cfloat, cdouble, clongdouble#
- */
-NPY_INLINE static int
-@TYPE@_LT(@type@ a, @type@ b)
-{
- int ret;
-
- if (a.real < b.real) {
- ret = a.imag == a.imag || b.imag != b.imag;
- }
- else if (a.real > b.real) {
- ret = b.imag != b.imag && a.imag == a.imag;
- }
- else if (a.real == b.real || (a.real != a.real && b.real != b.real)) {
- ret = a.imag < b.imag || (b.imag != b.imag && a.imag == a.imag);
- }
- else {
- ret = b.real != b.real;
- }
-
- return ret;
-}
-/**end repeat**/
-
-
-/* The PyObject functions are stubs for later use */
-NPY_INLINE static int
-PyObject_LT(PyObject *pa, PyObject *pb)
-{
- return 0;
-}
-
-
-NPY_INLINE static void
-STRING_COPY(char *s1, char *s2, size_t len)
-{
- memcpy(s1, s2, len);
-}
-
-
-NPY_INLINE static void
-STRING_SWAP(char *s1, char *s2, size_t len)
-{
- while(len--) {
- const char t = *s1;
- *s1++ = *s2;
- *s2++ = t;
- }
-}
-
-
-NPY_INLINE static int
-STRING_LT(char *s1, char *s2, size_t len)
-{
- const unsigned char *c1 = (unsigned char *)s1;
- const unsigned char *c2 = (unsigned char *)s2;
- size_t i;
- int ret = 0;
-
- for (i = 0; i < len; ++i) {
- if (c1[i] != c2[i]) {
- ret = c1[i] < c2[i];
- break;
- }
- }
- return ret;
-}
-
-
-NPY_INLINE static void
-UNICODE_COPY(npy_ucs4 *s1, npy_ucs4 *s2, size_t len)
-{
- while(len--) {
- *s1++ = *s2++;
- }
-}
-
-
-NPY_INLINE static void
-UNICODE_SWAP(npy_ucs4 *s1, npy_ucs4 *s2, size_t len)
-{
- while(len--) {
- const npy_ucs4 t = *s1;
- *s1++ = *s2;
- *s2++ = t;
- }
-}
-
-
-NPY_INLINE static int
-UNICODE_LT(npy_ucs4 *s1, npy_ucs4 *s2, size_t len)
-{
- size_t i;
- int ret = 0;
-
- for (i = 0; i < len; ++i) {
- if (s1[i] != s2[i]) {
- ret = s1[i] < s2[i];
- break;
- }
- }
- return ret;
-}
-
/*
*****************************************************************************
@@ -233,9 +47,10 @@ UNICODE_LT(npy_ucs4 *s1, npy_ucs4 *s2, size_t len)
* #TYPE = BOOL, BYTE, UBYTE, SHORT, USHORT, INT, UINT, LONG, ULONG,
* LONGLONG, ULONGLONG, HALF, FLOAT, DOUBLE, LONGDOUBLE,
* CFLOAT, CDOUBLE, CLONGDOUBLE#
- * #type = Bool, byte, ubyte, short, ushort, int, uint, long, ulong,
- * longlong, ulonglong, ushort, float, double, longdouble,
- * cfloat, cdouble, 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#
*/
@@ -598,7 +413,7 @@ static int
/**begin repeat
*
* #TYPE = STRING, UNICODE#
- * #type = char, PyArray_UCS4#
+ * #type = char, npy_ucs4#
*/
static void
@@ -971,6 +786,9 @@ static int
}
/**end repeat**/
+/* just for the module bit */
+#include "numpy/noprefix.h"
+
static void
add_sortfuncs(void)
{