diff options
author | Travis Oliphant <oliphant@enthought.com> | 2006-03-01 06:10:17 +0000 |
---|---|---|
committer | Travis Oliphant <oliphant@enthought.com> | 2006-03-01 06:10:17 +0000 |
commit | 3f8c2dea68dd5d8b437a02f002836f09644e5c3f (patch) | |
tree | b77d3891d3073ef84d214d11f17f605633e16c3e /numpy | |
parent | 5f9949015822c662a8a5bd145f2aab08c2b3dfb2 (diff) | |
download | numpy-3f8c2dea68dd5d8b437a02f002836f09644e5c3f.tar.gz |
Swap order of fill-function arguments and make ones use fill now.
Diffstat (limited to 'numpy')
-rw-r--r-- | numpy/core/include/numpy/arrayobject.h | 2 | ||||
-rw-r--r-- | numpy/core/numeric.py | 10 | ||||
-rw-r--r-- | numpy/core/src/arrayobject.c | 2 | ||||
-rw-r--r-- | numpy/core/src/arraytypes.inc.src | 6 |
4 files changed, 10 insertions, 10 deletions
diff --git a/numpy/core/include/numpy/arrayobject.h b/numpy/core/include/numpy/arrayobject.h index 0ded2eb26..ed76acb87 100644 --- a/numpy/core/include/numpy/arrayobject.h +++ b/numpy/core/include/numpy/arrayobject.h @@ -811,7 +811,7 @@ typedef int (PyArray_FillFunc)(void *, intp, void *); typedef int (PyArray_SortFunc)(void *, intp, void *); typedef int (PyArray_ArgSortFunc)(void *, intp *, intp, void *); -typedef int (PyArray_FillWithScalarFunc)(void *, intp, intp, void *); +typedef int (PyArray_FillWithScalarFunc)(void *, intp, void *, void *); typedef struct { intp *ptr; diff --git a/numpy/core/numeric.py b/numpy/core/numeric.py index 1da30e68f..d4359a540 100644 --- a/numpy/core/numeric.py +++ b/numpy/core/numeric.py @@ -340,11 +340,11 @@ def ones(shape, dtype=int_, fortran=False): """ones(shape, dtype=int_) returns an array of the given dimensions which is initialized to all ones. """ - # This appears to be slower... - #a = empty(shape, dtype, fortran) - #a.fill(1) - a = zeros(shape, dtype, fortran) - a+=1 + a = empty(shape, dtype, fortran) + a.fill(1) + # Above is faster now after addition of fast loops. + #a = zeros(shape, dtype, fortran) + #a+=1 return a def identity(n,dtype=int_): diff --git a/numpy/core/src/arrayobject.c b/numpy/core/src/arrayobject.c index cd83f31e1..fe53283a5 100644 --- a/numpy/core/src/arrayobject.c +++ b/numpy/core/src/arrayobject.c @@ -4112,7 +4112,7 @@ PyArray_FillWithScalar(PyArrayObject *arr, PyObject *obj) arr->descr->f->fillwithscalar; if (fillwithscalar && PyArray_ISALIGNED(arr)) { copyswap(fromptr, NULL, swap, itemsize); - fillwithscalar(toptr, size, itemsize, fromptr); + fillwithscalar(toptr, size, fromptr, arr); } else { while (size--) { diff --git a/numpy/core/src/arraytypes.inc.src b/numpy/core/src/arraytypes.inc.src index 2c570b946..4bd24904a 100644 --- a/numpy/core/src/arraytypes.inc.src +++ b/numpy/core/src/arraytypes.inc.src @@ -1715,7 +1715,7 @@ static void /* this requires buffer to be filled with objects or NULL */ static void -OBJECT_fillwithscalar(PyObject **buffer, intp length, intp ignored, PyObject **value) +OBJECT_fillwithscalar(PyObject **buffer, intp length, PyObject **value, void *ignored) { intp i; PyObject *val = *value; @@ -1730,7 +1730,7 @@ OBJECT_fillwithscalar(PyObject **buffer, intp length, intp ignored, PyObject **v #typ=Bool,byte,ubyte# */ static void -@NAME@_fillwithscalar(@typ@ *buffer, intp length, intp ignored, @typ@ *value) +@NAME@_fillwithscalar(@typ@ *buffer, intp length, @typ@ *value, void *ignored) { memset(buffer, *value, length); } @@ -1741,7 +1741,7 @@ static void #typ=short,ushort,int,uint,long,ulong,longlong,ulonglong,float,double,longdouble,cfloat,cdouble,clongdouble# */ static void -@NAME@_fillwithscalar(@typ@ *buffer, intp length, intp ignored, @typ@ *value) +@NAME@_fillwithscalar(@typ@ *buffer, intp length, @typ@ *value, void *ignored) { register intp i; @typ@ val = *value; |