summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTravis Oliphant <oliphant@enthought.com>2006-01-02 03:50:42 +0000
committerTravis Oliphant <oliphant@enthought.com>2006-01-02 03:50:42 +0000
commitb5ba0003def4cfa43b29d29df8f085d09609707b (patch)
tree1707278791b3131c8ac7a3bfbc7bc42114b9faab
parent912b8ef191e420c9b5f7bce9f52b6fa815bdae54 (diff)
downloadnumpy-b5ba0003def4cfa43b29d29df8f085d09609707b.tar.gz
Added UIntXX inplace of UintXX. Added Bool type
-rw-r--r--scipy/base/numerictypes.py5
-rw-r--r--scipy/base/oldnumeric.py3
-rw-r--r--scipy/base/src/_sortmodule.c.src22
3 files changed, 21 insertions, 9 deletions
diff --git a/scipy/base/numerictypes.py b/scipy/base/numerictypes.py
index 839ce66e7..d70b29290 100644
--- a/scipy/base/numerictypes.py
+++ b/scipy/base/numerictypes.py
@@ -161,7 +161,10 @@ def _add_types():
if base != '':
allTypes["%s%d" % (base, bit)] = typeobj
typeDict["%s%d" % (base, bit)] = typeobj
- typeDict["%s%d" % (base.capitalize(), bit)] = typeobj
+ if base[:2] == 'ui':
+ typeDict['U%s%d' % (base[1:].capitalize(), bit)] = typeobj
+ else:
+ typeDict["%s%d" % (base.capitalize(), bit)] = typeobj
if char != '':
typeDict[char] = typeobj
diff --git a/scipy/base/oldnumeric.py b/scipy/base/oldnumeric.py
index 521cbd6eb..9cf87218e 100644
--- a/scipy/base/oldnumeric.py
+++ b/scipy/base/oldnumeric.py
@@ -3,7 +3,7 @@
__all__ = ['asarray', 'array', 'concatenate',
'NewAxis',
'UFuncType', 'UfuncType', 'ArrayType', 'arraytype',
- 'LittleEndian',
+ 'LittleEndian', 'Bool',
'Character', 'UnsignedInt8', 'UnsignedInt16', 'UnsignedInt',
'UInt8','UInt16','UInt32',
# UnsignedInt64 and Unsigned128 added below if possible
@@ -89,6 +89,7 @@ except AttributeError:
else:
__all__ += ['Int128']
+Bool = _dt_(bool)
Int0 = _dt_(int)
Int = _dt_(int)
Float0 = _dt_(float)
diff --git a/scipy/base/src/_sortmodule.c.src b/scipy/base/src/_sortmodule.c.src
index ccf7a0f84..47c7520c1 100644
--- a/scipy/base/src/_sortmodule.c.src
+++ b/scipy/base/src/_sortmodule.c.src
@@ -6,6 +6,9 @@
with a few modifications (complex comparisons compare the imaginary
part if the real parts are equal, for example), and the names
are changed.
+
+ The original sorting code is due to Charles R. Harris who wrote
+ it for numarray.
*/
/* Quick sort is usually the fastest, but the worst case scenario can
@@ -15,12 +18,17 @@
The merge sort is *stable*, meaning that equal components
are unmoved from their entry versions, so it can be used to
implement lexigraphic sorting on multiple keys.
+
+ The heap sort is included for completeness.
*/
#include "Python.h"
#include "scipy/arrayobject.h"
+#define PYA_QS_STACK 100
+#define SMALL_QUICKSORT 15
+#define SMALL_MERGESORT 20
#define STDC_LT(a,b) ((a) < (b))
#define STDC_LE(a,b) ((a) <= (b))
#define STDC_EQ(a,b) ((a) == (b))
@@ -41,10 +49,10 @@ static int
@type@ *pl = start;
@type@ *pr = start + num - 1;
@type@ vp, SWAP_temp;
- @type@ *stack[100], **sptr = stack, *pm, *pi, *pj, *pt;
+ @type@ *stack[PYA_QS_STACK], **sptr = stack, *pm, *pi, *pj, *pt;
for(;;) {
- while ((pr - pl) > 15) {
+ while ((pr - pl) > SMALL_QUICKSORT) {
/* quicksort partition */
pm = pl + ((pr - pl) >> 1);
if (@lessthan@(*pm,*pl)) SWAP(*pm,*pl);
@@ -93,13 +101,13 @@ static int
{
@type@ vp;
intp *pl, *pr, SWAP_temp;
- intp *stack[100], **sptr=stack, *pm, *pi, *pj, *pt, vi;
+ intp *stack[PYA_QS_STACK], **sptr=stack, *pm, *pi, *pj, *pt, vi;
pl = tosort;
pr = tosort + num - 1;
for(;;) {
- while ((pr - pl) > 15) {
+ while ((pr - pl) > SMALL_QUICKSORT) {
/* quicksort partition */
pm = pl + ((pr - pl) >> 1);
if (@lessthan@(v[*pm],v[*pl])) SWAP(*pm,*pl);
@@ -237,7 +245,7 @@ static void
{
@type@ vp, *pi, *pj, *pk, *pm;
- if (pr - pl > 20) {
+ if (pr - pl > SMALL_MERGESORT) {
/* merge sort */
pm = pl + ((pr - pl + 1)>>1);
@TYPE@_mergesort0(pl,pm-1,pw);
@@ -294,7 +302,7 @@ static void
@type@ vp;
intp vi, *pi, *pj, *pk, *pm;
- if (pr - pl > 20) {
+ if (pr - pl > SMALL_MERGESORT) {
/* merge sort */
pm = pl + ((pr - pl + 1)>>1);
@TYPE@_amergesort0(pl,pm-1,v,pw);
@@ -371,7 +379,7 @@ static void
@type@ vp;
intp vi, *pi, *pj, *pk, *pm;
- if (pr - pl > 20) {
+ if (pr - pl > SMALL_MERGESORT) {
/* merge sort */
pm = pl + ((pr - pl + 1)>>1);
@TYPE@_amergesort0(pl,pm-1,v,pw,elsize);