[Numpy-svn] r5027 - trunk/numpy/core/src
numpy-svn at scipy.org
numpy-svn at scipy.org
Sun Apr 13 02:05:30 EDT 2008
Author: charris
Date: 2008-04-13 01:05:28 -0500 (Sun, 13 Apr 2008)
New Revision: 5027
Modified:
trunk/numpy/core/src/arraytypes.inc.src
Log:
Reindent. Needs style cleanup too.
Small cleanup of MyPyFloat_AsDouble.
Modified: trunk/numpy/core/src/arraytypes.inc.src
===================================================================
--- trunk/numpy/core/src/arraytypes.inc.src 2008-04-12 23:18:27 UTC (rev 5026)
+++ trunk/numpy/core/src/arraytypes.inc.src 2008-04-13 06:05:28 UTC (rev 5027)
@@ -3,102 +3,102 @@
static longlong
-MyPyLong_AsLongLong(PyObject *vv)
+MyPyLong_AsLongLong(PyObject *obj)
{
- longlong ret;
+ longlong ret;
- if (!PyLong_Check(vv)) {
- PyObject *mylong;
- mylong = PyNumber_Long(vv);
- if (mylong == NULL) {
- return (longlong) -1;
- }
- vv = mylong;
+ if (!PyLong_Check(obj)) {
+ PyObject *mylong;
+ mylong = PyNumber_Long(obj);
+ if (mylong == NULL) {
+ return (longlong) -1;
}
- else {
- Py_INCREF(vv);
- }
+ obj = mylong;
+ }
+ else {
+ Py_INCREF(obj);
+ }
- ret = PyLong_AsLongLong(vv);
- Py_DECREF(vv);
- return ret;
+ ret = PyLong_AsLongLong(obj);
+ Py_DECREF(obj);
+ return ret;
}
static ulong
-MyPyLong_AsUnsignedLong(PyObject *vv)
+MyPyLong_AsUnsignedLong(PyObject *obj)
{
- ulong ret;
+ ulong ret;
- if (!PyLong_Check(vv)) {
- PyObject *mylong;
- mylong = PyNumber_Long(vv);
- if (mylong == NULL) {
- return (ulong) -1;
- }
- vv = mylong;
+ if (!PyLong_Check(obj)) {
+ PyObject *mylong;
+ mylong = PyNumber_Long(obj);
+ if (mylong == NULL) {
+ return (ulong) -1;
}
- else {
- Py_INCREF(vv);
- }
+ obj = mylong;
+ }
+ else {
+ Py_INCREF(obj);
+ }
- ret = PyLong_AsUnsignedLong(vv);
- if (PyErr_Occurred()) {
- PyErr_Clear();
- ret = (ulong) PyLong_AsLong(vv);
- }
- Py_DECREF(vv);
- return ret;
+ ret = PyLong_AsUnsignedLong(obj);
+ if (PyErr_Occurred()) {
+ PyErr_Clear();
+ ret = (ulong) PyLong_AsLong(obj);
+ }
+ Py_DECREF(obj);
+ return ret;
}
static ulonglong
-MyPyLong_AsUnsignedLongLong(PyObject *vv)
+MyPyLong_AsUnsignedLongLong(PyObject *obj)
{
- ulonglong ret;
+ ulonglong ret;
- if (!PyLong_Check(vv)) {
- PyObject *mylong;
- mylong = PyNumber_Long(vv);
- if (mylong == NULL) {
- return (ulonglong) -1;
- }
- vv = mylong;
+ if (!PyLong_Check(obj)) {
+ PyObject *mylong;
+ mylong = PyNumber_Long(obj);
+ if (mylong == NULL) {
+ return (ulonglong) -1;
}
- else {
- Py_INCREF(vv);
- }
+ obj = mylong;
+ }
+ else {
+ Py_INCREF(obj);
+ }
- ret = PyLong_AsUnsignedLongLong(vv);
- if (PyErr_Occurred()) {
- PyErr_Clear();
- ret = (ulonglong) PyLong_AsLongLong(vv);
- }
- Py_DECREF(vv);
- return ret;
+ ret = PyLong_AsUnsignedLongLong(obj);
+ if (PyErr_Occurred()) {
+ PyErr_Clear();
+ ret = (ulonglong) PyLong_AsLongLong(obj);
+ }
+ Py_DECREF(obj);
+ return ret;
}
static double
_getNAN(void) {
#ifdef NAN
- return NAN;
+ return NAN;
#else
- static double nan=0;
+ static double nan=0;
- if (nan == 0) {
- double mul = 1e100;
- double tmp = 0.0;
- double pinf=0;
- pinf = mul;
- for (;;) {
- pinf *= mul;
- if (pinf == tmp) break;
- tmp = pinf;
- }
- nan = pinf / pinf;
+ if (nan == 0) {
+ double mul = 1e100;
+ double tmp = 0.0;
+ double pinf=0;
+ pinf = mul;
+ for (;;) {
+ pinf *= mul;
+ if (pinf == tmp) break;
+ tmp = pinf;
}
- return nan;
+ nan = pinf / pinf;
+ }
+ return nan;
#endif
}
@@ -106,21 +106,20 @@
static double
MyPyFloat_AsDouble(PyObject *obj)
{
- PyObject *tmp;
- double d;
- if (PyString_Check(obj)) {
- tmp = PyFloat_FromString(obj, 0);
- if (tmp) {
- d = PyFloat_AsDouble(tmp);
- Py_DECREF(tmp);
- return d;
- }
- else {
- return _getNAN();
- }
+ if (PyString_Check(obj)) {
+ PyObject *tmp = PyFloat_FromString(obj, 0);
+ if (tmp) {
+ double d = PyFloat_AsDouble(tmp);
+ Py_DECREF(tmp);
+ return d;
}
- if (obj == Py_None) return _getNAN();
- return PyFloat_AsDouble(obj);
+ else {
+ return _getNAN();
+ }
+ }
+ if (obj == Py_None)
+ return _getNAN();
+ return PyFloat_AsDouble(obj);
}
@@ -138,46 +137,46 @@
static PyObject *
@TYP at _getitem(char *ip, PyArrayObject *ap) {
- @typ@ t1;
+ @typ@ t1;
- if ((ap==NULL) || PyArray_ISBEHAVED_RO(ap)) {
- t1 = *((@typ@ *)ip);
- return @func1@((@typ1@)t1);
- }
- else {
- ap->descr->f->copyswap(&t1, ip, !PyArray_ISNOTSWAPPED(ap),
- ap);
- return @func1@((@typ1@)t1);
- }
+ if ((ap==NULL) || PyArray_ISBEHAVED_RO(ap)) {
+ t1 = *((@typ@ *)ip);
+ return @func1@((@typ1@)t1);
+ }
+ else {
+ ap->descr->f->copyswap(&t1, ip, !PyArray_ISNOTSWAPPED(ap),
+ ap);
+ return @func1@((@typ1@)t1);
+ }
}
static int
@TYP at _setitem(PyObject *op, char *ov, PyArrayObject *ap) {
- @typ@ temp; /* ensures alignment */
+ @typ@ temp; /* ensures alignment */
- if (PyArray_IsScalar(op, @kind@)) {
- temp = ((Py at kind@ScalarObject *)op)->obval;
+ if (PyArray_IsScalar(op, @kind@)) {
+ temp = ((Py at kind@ScalarObject *)op)->obval;
+ }
+ else {
+ temp = (@typ@)@func2@(op);
+ }
+ if (PyErr_Occurred()) {
+ if (PySequence_Check(op)) {
+ PyErr_Clear();
+ PyErr_SetString(PyExc_ValueError, "setting an array" \
+ " element with a sequence.");
}
- else {
- temp = (@typ@)@func2@(op);
- }
- if (PyErr_Occurred()) {
- if (PySequence_Check(op)) {
- PyErr_Clear();
- PyErr_SetString(PyExc_ValueError, "setting an array" \
- " element with a sequence.");
- }
- return -1;
- }
- if (ap == NULL || PyArray_ISBEHAVED(ap))
- *((@typ@ *)ov)=temp;
- else {
- ap->descr->f->copyswap(ov, &temp, !PyArray_ISNOTSWAPPED(ap),
- ap);
- }
+ return -1;
+ }
+ if (ap == NULL || PyArray_ISBEHAVED(ap))
+ *((@typ@ *)ov)=temp;
+ else {
+ ap->descr->f->copyswap(ov, &temp, !PyArray_ISNOTSWAPPED(ap),
+ ap);
+ }
- return 0;
+ return 0;
}
/**end repeat**/
@@ -191,19 +190,19 @@
static PyObject *
@TYP at _getitem(char *ip, PyArrayObject *ap) {
- @typ@ t1, t2;
+ @typ@ t1, t2;
- if ((ap==NULL) || PyArray_ISBEHAVED_RO(ap)) {
- return PyComplex_FromDoubles((double)((@typ@ *)ip)[0],
- (double)((@typ@ *)ip)[1]);
- }
- else {
- int size = sizeof(@typ@);
- Bool swap = !PyArray_ISNOTSWAPPED(ap);
- copy_and_swap(&t1, ip, size, 1, 0, swap);
- copy_and_swap(&t2, ip+size, size, 1, 0, swap);
- return PyComplex_FromDoubles((double)t1, (double)t2);
- }
+ if ((ap==NULL) || PyArray_ISBEHAVED_RO(ap)) {
+ return PyComplex_FromDoubles((double)((@typ@ *)ip)[0],
+ (double)((@typ@ *)ip)[1]);
+ }
+ else {
+ int size = sizeof(@typ@);
+ Bool swap = !PyArray_ISNOTSWAPPED(ap);
+ copy_and_swap(&t1, ip, size, 1, 0, swap);
+ copy_and_swap(&t2, ip+size, size, 1, 0, swap);
+ return PyComplex_FromDoubles((double)t1, (double)t2);
+ }
}
/**end repeat**/
@@ -216,75 +215,75 @@
static int
@TYP at _setitem(PyObject *op, char *ov, PyArrayObject *ap)
{
- Py_complex oop;
- PyObject *op2;
- c at typ@ temp;
- int rsize;
+ Py_complex oop;
+ PyObject *op2;
+ c at typ@ temp;
+ int rsize;
- if (!(PyArray_IsScalar(op, @kind@))) {
- if (PyArray_Check(op) && (PyArray_NDIM(op)==0)) {
- op2 = ((PyArrayObject *)op)->descr->f->getitem \
- (((PyArrayObject *)op)->data,
- (PyArrayObject *)op);
- }
- else {
- op2 = op; Py_INCREF(op);
- }
- if (op2 == Py_None) {
- oop.real = oop.imag = _getNAN();
- }
- else {
- oop = PyComplex_AsCComplex (op2);
- }
- Py_DECREF(op2);
- if (PyErr_Occurred()) return -1;
- temp.real = (@typ@) oop.real;
- temp.imag = (@typ@) oop.imag;
+ if (!(PyArray_IsScalar(op, @kind@))) {
+ if (PyArray_Check(op) && (PyArray_NDIM(op)==0)) {
+ op2 = ((PyArrayObject *)op)->descr->f->getitem \
+ (((PyArrayObject *)op)->data,
+ (PyArrayObject *)op);
}
else {
- temp = ((Py at kind@ScalarObject *)op)->obval;
+ op2 = op; Py_INCREF(op);
}
+ if (op2 == Py_None) {
+ oop.real = oop.imag = _getNAN();
+ }
+ else {
+ oop = PyComplex_AsCComplex (op2);
+ }
+ Py_DECREF(op2);
+ if (PyErr_Occurred()) return -1;
+ temp.real = (@typ@) oop.real;
+ temp.imag = (@typ@) oop.imag;
+ }
+ else {
+ temp = ((Py at kind@ScalarObject *)op)->obval;
+ }
- memcpy(ov, &temp, ap->descr->elsize);
- if (!PyArray_ISNOTSWAPPED(ap))
- byte_swap_vector(ov, 2, sizeof(@typ@));
+ memcpy(ov, &temp, ap->descr->elsize);
+ if (!PyArray_ISNOTSWAPPED(ap))
+ byte_swap_vector(ov, 2, sizeof(@typ@));
- rsize = sizeof(@typ@);
- copy_and_swap(ov, &temp, rsize, 2, rsize, !PyArray_ISNOTSWAPPED(ap));
- return 0;
+ rsize = sizeof(@typ@);
+ copy_and_swap(ov, &temp, rsize, 2, rsize, !PyArray_ISNOTSWAPPED(ap));
+ return 0;
}
/**end repeat**/
static PyObject *
LONGDOUBLE_getitem(char *ip, PyArrayObject *ap)
{
- return PyArray_Scalar(ip, ap->descr, NULL);
+ return PyArray_Scalar(ip, ap->descr, NULL);
}
static int
LONGDOUBLE_setitem(PyObject *op, char *ov, PyArrayObject *ap) {
- longdouble temp; /* ensures alignment */
+ longdouble temp; /* ensures alignment */
- if (PyArray_IsScalar(op, LongDouble)) {
- temp = ((PyLongDoubleScalarObject *)op)->obval;
- }
- else {
- temp = (longdouble) MyPyFloat_AsDouble(op);
- }
- if (PyErr_Occurred()) return -1;
- if (ap == NULL || PyArray_ISBEHAVED(ap))
- *((longdouble *)ov)=temp;
- else {
- copy_and_swap(ov, &temp, ap->descr->elsize, 1, 0,
- !PyArray_ISNOTSWAPPED(ap));
- }
- return 0;
+ if (PyArray_IsScalar(op, LongDouble)) {
+ temp = ((PyLongDoubleScalarObject *)op)->obval;
+ }
+ else {
+ temp = (longdouble) MyPyFloat_AsDouble(op);
+ }
+ if (PyErr_Occurred()) return -1;
+ if (ap == NULL || PyArray_ISBEHAVED(ap))
+ *((longdouble *)ov)=temp;
+ else {
+ copy_and_swap(ov, &temp, ap->descr->elsize, 1, 0,
+ !PyArray_ISNOTSWAPPED(ap));
+ }
+ return 0;
}
static PyObject *
CLONGDOUBLE_getitem(char *ip, PyArrayObject *ap)
{
- return PyArray_Scalar(ip, ap->descr, NULL);
+ return PyArray_Scalar(ip, ap->descr, NULL);
}
@@ -292,102 +291,102 @@
static PyObject *
UNICODE_getitem(char *ip, PyArrayObject *ap)
{
- PyObject *obj;
- int mysize;
- PyArray_UCS4 *dptr;
- char *buffer;
- int alloc=0;
+ PyObject *obj;
+ int mysize;
+ PyArray_UCS4 *dptr;
+ char *buffer;
+ int alloc=0;
- mysize = ap->descr->elsize >> 2;
- dptr = (PyArray_UCS4 *)ip + mysize-1;
- while(mysize > 0 && *dptr-- == 0) mysize--;
- if (!PyArray_ISBEHAVED(ap)) {
- buffer = _pya_malloc(mysize << 2);
- if (buffer == NULL)
- return PyErr_NoMemory();
- alloc = 1;
- memcpy(buffer, ip, mysize << 2);
- if (!PyArray_ISNOTSWAPPED(ap)) {
- byte_swap_vector(buffer, mysize, 4);
- }
+ mysize = ap->descr->elsize >> 2;
+ dptr = (PyArray_UCS4 *)ip + mysize-1;
+ while(mysize > 0 && *dptr-- == 0) mysize--;
+ if (!PyArray_ISBEHAVED(ap)) {
+ buffer = _pya_malloc(mysize << 2);
+ if (buffer == NULL)
+ return PyErr_NoMemory();
+ alloc = 1;
+ memcpy(buffer, ip, mysize << 2);
+ if (!PyArray_ISNOTSWAPPED(ap)) {
+ byte_swap_vector(buffer, mysize, 4);
}
- else buffer = ip;
+ }
+ else buffer = ip;
#ifdef Py_UNICODE_WIDE
- obj = PyUnicode_FromUnicode((const Py_UNICODE *)buffer, mysize);
+ obj = PyUnicode_FromUnicode((const Py_UNICODE *)buffer, mysize);
#else
- /* create new empty unicode object of length mysize*2 */
- obj = MyPyUnicode_New(mysize*2);
- if (obj == NULL) {if (alloc) _pya_free(buffer); return obj;}
- mysize = PyUCS2Buffer_FromUCS4(((PyUnicodeObject *)obj)->str,
- (PyArray_UCS4 *)buffer, mysize);
- /* reset length of unicode object to ucs2size */
- if (MyPyUnicode_Resize((PyUnicodeObject *)obj, mysize) < 0) {
- if (alloc) _pya_free(buffer);
- Py_DECREF(obj);
- return NULL;
- }
-#endif
+ /* create new empty unicode object of length mysize*2 */
+ obj = MyPyUnicode_New(mysize*2);
+ if (obj == NULL) {if (alloc) _pya_free(buffer); return obj;}
+ mysize = PyUCS2Buffer_FromUCS4(((PyUnicodeObject *)obj)->str,
+ (PyArray_UCS4 *)buffer, mysize);
+ /* reset length of unicode object to ucs2size */
+ if (MyPyUnicode_Resize((PyUnicodeObject *)obj, mysize) < 0) {
if (alloc) _pya_free(buffer);
+ Py_DECREF(obj);
+ return NULL;
+ }
+#endif
+ if (alloc) _pya_free(buffer);
- return obj;
+ return obj;
}
static int
UNICODE_setitem(PyObject *op, char *ov, PyArrayObject *ap)
{
- PyObject *temp;
- Py_UNICODE *ptr;
- int datalen;
+ PyObject *temp;
+ Py_UNICODE *ptr;
+ int datalen;
#ifndef Py_UNICODE_WIDE
- char *buffer;
+ char *buffer;
#endif
- if (!PyString_Check(op) && !PyUnicode_Check(op) &&
+ if (!PyString_Check(op) && !PyUnicode_Check(op) &&
PySequence_Check(op) && PySequence_Size(op) > 0) {
- PyErr_SetString(PyExc_ValueError,
- "setting an array element with a sequence");
- return -1;
- }
- /* Sequence_Size might have returned an error */
- if (PyErr_Occurred()) PyErr_Clear();
- if ((temp=PyObject_Unicode(op)) == NULL) return -1;
- ptr = PyUnicode_AS_UNICODE(temp);
- if ((ptr == NULL) || (PyErr_Occurred())) {
- Py_DECREF(temp);
- return -1;
- }
- datalen = PyUnicode_GET_DATA_SIZE(temp);
+ PyErr_SetString(PyExc_ValueError,
+ "setting an array element with a sequence");
+ return -1;
+ }
+ /* Sequence_Size might have returned an error */
+ if (PyErr_Occurred()) PyErr_Clear();
+ if ((temp=PyObject_Unicode(op)) == NULL) return -1;
+ ptr = PyUnicode_AS_UNICODE(temp);
+ if ((ptr == NULL) || (PyErr_Occurred())) {
+ Py_DECREF(temp);
+ return -1;
+ }
+ datalen = PyUnicode_GET_DATA_SIZE(temp);
#ifdef Py_UNICODE_WIDE
- memcpy(ov, ptr, MIN(ap->descr->elsize, datalen));
+ memcpy(ov, ptr, MIN(ap->descr->elsize, datalen));
#else
- if (!PyArray_ISALIGNED(ap)) {
- buffer = _pya_malloc(ap->descr->elsize);
- if (buffer == NULL) {
- Py_DECREF(temp);
- PyErr_NoMemory();
- return -1;
- }
+ if (!PyArray_ISALIGNED(ap)) {
+ buffer = _pya_malloc(ap->descr->elsize);
+ if (buffer == NULL) {
+ Py_DECREF(temp);
+ PyErr_NoMemory();
+ return -1;
}
- else buffer = ov;
- datalen = PyUCS2Buffer_AsUCS4(ptr, (PyArray_UCS4 *)buffer,
- datalen >> 1,
- ap->descr->elsize >> 2);
- datalen <<= 2;
- if (!PyArray_ISALIGNED(ap)) {
- memcpy(ov, buffer, datalen);
- _pya_free(buffer);
- }
+ }
+ else buffer = ov;
+ datalen = PyUCS2Buffer_AsUCS4(ptr, (PyArray_UCS4 *)buffer,
+ datalen >> 1,
+ ap->descr->elsize >> 2);
+ datalen <<= 2;
+ if (!PyArray_ISALIGNED(ap)) {
+ memcpy(ov, buffer, datalen);
+ _pya_free(buffer);
+ }
#endif
- /* Fill in the rest of the space with 0 */
- if (ap->descr->elsize > datalen) {
- memset(ov + datalen, 0, (ap->descr->elsize - datalen));
- }
+ /* Fill in the rest of the space with 0 */
+ if (ap->descr->elsize > datalen) {
+ memset(ov + datalen, 0, (ap->descr->elsize - datalen));
+ }
- if (!PyArray_ISNOTSWAPPED(ap))
- byte_swap_vector(ov, ap->descr->elsize >> 2, 4);
- Py_DECREF(temp);
- return 0;
+ if (!PyArray_ISNOTSWAPPED(ap))
+ byte_swap_vector(ov, ap->descr->elsize >> 2, 4);
+ Py_DECREF(temp);
+ return 0;
}
/* STRING -- can handle both NULL-terminated and not NULL-terminated cases
@@ -396,45 +395,45 @@
static PyObject *
STRING_getitem(char *ip, PyArrayObject *ap)
{
- /* Will eliminate NULLs at the end */
- char *ptr;
- int size = ap->descr->elsize;
+ /* Will eliminate NULLs at the end */
+ char *ptr;
+ int size = ap->descr->elsize;
- ptr = ip + size-1;
- while (*ptr-- == '\0' && size > 0) size--;
- return PyString_FromStringAndSize(ip,size);
+ ptr = ip + size-1;
+ while (*ptr-- == '\0' && size > 0) size--;
+ return PyString_FromStringAndSize(ip,size);
}
static int
STRING_setitem(PyObject *op, char *ov, PyArrayObject *ap)
{
- char *ptr;
- Py_ssize_t len;
- PyObject *temp=NULL;
+ char *ptr;
+ Py_ssize_t len;
+ PyObject *temp=NULL;
- if (!PyString_Check(op) && !PyUnicode_Check(op) &&
+ if (!PyString_Check(op) && !PyUnicode_Check(op) &&
PySequence_Check(op) && PySequence_Size(op) > 0) {
- PyErr_SetString(PyExc_ValueError,
- "setting an array element with a sequence");
- return -1;
- }
- /* Sequence_Size might have returned an error */
- if (PyErr_Occurred()) PyErr_Clear();
- if ((temp = PyObject_Str(op)) == NULL) return -1;
+ PyErr_SetString(PyExc_ValueError,
+ "setting an array element with a sequence");
+ return -1;
+ }
+ /* Sequence_Size might have returned an error */
+ if (PyErr_Occurred()) PyErr_Clear();
+ if ((temp = PyObject_Str(op)) == NULL) return -1;
- if (PyString_AsStringAndSize(temp, &ptr, &len) == -1) {
- Py_DECREF(temp);
- return -1;
- }
- memcpy(ov, ptr, MIN(ap->descr->elsize,len));
- /* If string lenth is smaller than room in array
- Then fill the rest of the element size
- with NULL */
- if (ap->descr->elsize > len) {
- memset(ov + len, 0, (ap->descr->elsize - len));
- }
+ if (PyString_AsStringAndSize(temp, &ptr, &len) == -1) {
Py_DECREF(temp);
- return 0;
+ return -1;
+ }
+ memcpy(ov, ptr, MIN(ap->descr->elsize,len));
+ /* If string lenth is smaller than room in array
+ Then fill the rest of the element size
+ with NULL */
+ if (ap->descr->elsize > len) {
+ memset(ov + len, 0, (ap->descr->elsize - len));
+ }
+ Py_DECREF(temp);
+ return 0;
}
/* OBJECT */
@@ -442,38 +441,38 @@
static PyObject *
OBJECT_getitem(char *ip, PyArrayObject *ap)
{
- if (*(PyObject **)ip == NULL) {
- Py_INCREF(Py_None);
- return Py_None;
- }
- if (!ap || PyArray_ISALIGNED(ap)) {
- Py_INCREF(*(PyObject **)ip);
- return *(PyObject **)ip;
- }
- else {
- PyObject **obj;
- obj = (PyObject **)ip;
- Py_INCREF(*obj);
- return *obj;
- }
+ if (*(PyObject **)ip == NULL) {
+ Py_INCREF(Py_None);
+ return Py_None;
+ }
+ if (!ap || PyArray_ISALIGNED(ap)) {
+ Py_INCREF(*(PyObject **)ip);
+ return *(PyObject **)ip;
+ }
+ else {
+ PyObject **obj;
+ obj = (PyObject **)ip;
+ Py_INCREF(*obj);
+ return *obj;
+ }
}
static int
OBJECT_setitem(PyObject *op, char *ov, PyArrayObject *ap)
{
- Py_INCREF(op);
- if (!ap || PyArray_ISALIGNED(ap)) {
- Py_XDECREF(*(PyObject **)ov);
- *(PyObject **)ov = op;
- }
- else {
- PyObject **obj;
- obj = (PyObject **)ov;
- Py_XDECREF(*obj);
- memcpy(ov, &op, sizeof(PyObject *));
- }
- return PyErr_Occurred() ? -1:0;
+ Py_INCREF(op);
+ if (!ap || PyArray_ISALIGNED(ap)) {
+ Py_XDECREF(*(PyObject **)ov);
+ *(PyObject **)ov = op;
+ }
+ else {
+ PyObject **obj;
+ obj = (PyObject **)ov;
+ Py_XDECREF(*obj);
+ memcpy(ov, &op, sizeof(PyObject *));
+ }
+ return PyErr_Occurred() ? -1:0;
}
/* VOID */
@@ -481,98 +480,98 @@
static PyObject *
VOID_getitem(char *ip, PyArrayObject *ap)
{
- PyObject *u=NULL;
- PyArray_Descr* descr;
- int itemsize;
+ PyObject *u=NULL;
+ PyArray_Descr* descr;
+ int itemsize;
- descr = ap->descr;
- if (descr->names) {
- PyObject *key;
- PyObject *names;
- int i, n;
- PyObject *ret;
- PyObject *tup, *title;
- PyArray_Descr *new;
- int offset;
- int savedflags;
+ descr = ap->descr;
+ if (descr->names) {
+ PyObject *key;
+ PyObject *names;
+ int i, n;
+ PyObject *ret;
+ PyObject *tup, *title;
+ PyArray_Descr *new;
+ int offset;
+ int savedflags;
- /* get the names from the fields dictionary*/
- names = descr->names;
- if (!names) goto finish;
- n = PyTuple_GET_SIZE(names);
- ret = PyTuple_New(n);
- savedflags = ap->flags;
- for (i=0; i<n; i++) {
- key = PyTuple_GET_ITEM(names, i);
- tup = PyDict_GetItem(descr->fields, key);
- if (!PyArg_ParseTuple(tup, "Oi|O", &new, &offset,
- &title)) {
- Py_DECREF(ret);
- ap->descr = descr;
- return NULL;
- }
- ap->descr = new;
- /* update alignment based on offset */
- if ((new->alignment > 1) && \
- ((((intp)(ip+offset)) % new->alignment) != 0))
- ap->flags &= ~ALIGNED;
- else
- ap->flags |= ALIGNED;
-
- PyTuple_SET_ITEM(ret, i, \
- new->f->getitem(ip+offset, ap));
- ap->flags = savedflags;
- }
+ /* get the names from the fields dictionary*/
+ names = descr->names;
+ if (!names) goto finish;
+ n = PyTuple_GET_SIZE(names);
+ ret = PyTuple_New(n);
+ savedflags = ap->flags;
+ for (i=0; i<n; i++) {
+ key = PyTuple_GET_ITEM(names, i);
+ tup = PyDict_GetItem(descr->fields, key);
+ if (!PyArg_ParseTuple(tup, "Oi|O", &new, &offset,
+ &title)) {
+ Py_DECREF(ret);
ap->descr = descr;
- return ret;
+ return NULL;
+ }
+ ap->descr = new;
+ /* update alignment based on offset */
+ if ((new->alignment > 1) && \
+ ((((intp)(ip+offset)) % new->alignment) != 0))
+ ap->flags &= ~ALIGNED;
+ else
+ ap->flags |= ALIGNED;
+
+ PyTuple_SET_ITEM(ret, i, \
+ new->f->getitem(ip+offset, ap));
+ ap->flags = savedflags;
}
+ ap->descr = descr;
+ return ret;
+ }
- if (descr->subarray) {
- /* return an array of the basic type */
- PyArray_Dims shape={NULL,-1};
- PyObject *ret;
- if (!(PyArray_IntpConverter(descr->subarray->shape,
- &shape))) {
- PyDimMem_FREE(shape.ptr);
- PyErr_SetString(PyExc_ValueError,
- "invalid shape in fixed-type tuple.");
- return NULL;
- }
- Py_INCREF(descr->subarray->base);
- ret = PyArray_NewFromDescr(&PyArray_Type,
- descr->subarray->base,
- shape.len, shape.ptr,
- NULL, ip, ap->flags, NULL);
- PyDimMem_FREE(shape.ptr);
- if (!ret) return NULL;
- PyArray_BASE(ret) = (PyObject *)ap;
- Py_INCREF(ap);
- PyArray_UpdateFlags((PyArrayObject *)ret, UPDATE_ALL);
- return ret;
+ if (descr->subarray) {
+ /* return an array of the basic type */
+ PyArray_Dims shape={NULL,-1};
+ PyObject *ret;
+ if (!(PyArray_IntpConverter(descr->subarray->shape,
+ &shape))) {
+ PyDimMem_FREE(shape.ptr);
+ PyErr_SetString(PyExc_ValueError,
+ "invalid shape in fixed-type tuple.");
+ return NULL;
}
+ Py_INCREF(descr->subarray->base);
+ ret = PyArray_NewFromDescr(&PyArray_Type,
+ descr->subarray->base,
+ shape.len, shape.ptr,
+ NULL, ip, ap->flags, NULL);
+ PyDimMem_FREE(shape.ptr);
+ if (!ret) return NULL;
+ PyArray_BASE(ret) = (PyObject *)ap;
+ Py_INCREF(ap);
+ PyArray_UpdateFlags((PyArrayObject *)ret, UPDATE_ALL);
+ return ret;
+ }
- finish:
- if (PyDataType_FLAGCHK(descr, NPY_ITEM_HASOBJECT) ||
+finish:
+ if (PyDataType_FLAGCHK(descr, NPY_ITEM_HASOBJECT) ||
PyDataType_FLAGCHK(descr, NPY_ITEM_IS_POINTER)) {
- PyErr_SetString(PyExc_ValueError,
- "tried to get void-array with object"
- " members as buffer.");
- return NULL;
- }
+ PyErr_SetString(PyExc_ValueError,
+ "tried to get void-array with object"
+ " members as buffer.");
+ return NULL;
+ }
- itemsize=ap->descr->elsize;
- if (PyArray_ISWRITEABLE(ap))
- u = PyBuffer_FromReadWriteMemory(ip, itemsize);
- else
- u = PyBuffer_FromMemory(ip, itemsize);
- if (u==NULL) goto fail;
+ itemsize=ap->descr->elsize;
+ if (PyArray_ISWRITEABLE(ap))
+ u = PyBuffer_FromReadWriteMemory(ip, itemsize);
+ else
+ u = PyBuffer_FromMemory(ip, itemsize);
+ if (u==NULL) goto fail;
- /* default is to return buffer object pointing to current item */
- /* a view of it */
- return u;
+ /* default is to return buffer object pointing to current item */
+ /* a view of it */
+ return u;
- fail:
- return NULL;
+fail:
+ return NULL;
}
@@ -582,103 +581,103 @@
static int
VOID_setitem(PyObject *op, char *ip, PyArrayObject *ap)
{
- PyArray_Descr* descr;
- int itemsize=ap->descr->elsize;
- int res;
+ PyArray_Descr* descr;
+ int itemsize=ap->descr->elsize;
+ int res;
- descr = ap->descr;
- if (descr->names && PyTuple_Check(op)) {
- PyObject *key;
- PyObject *names;
- int i, n;
- PyObject *tup, *title;
- PyArray_Descr *new;
- int offset;
- int savedflags;
- res = -1;
- /* get the names from the fields dictionary*/
- names = descr->names;
- n = PyTuple_GET_SIZE(names);
- if (PyTuple_GET_SIZE(op) != n) {
- PyErr_SetString(PyExc_ValueError,
- "size of tuple must match "\
- "number of fields.");
- return -1;
- }
- savedflags = ap->flags;
- for (i=0; i<n; i++) {
- key = PyTuple_GET_ITEM(names, i);
- tup = PyDict_GetItem(descr->fields, key);
- if (!PyArg_ParseTuple(tup, "Oi|O", &new, &offset,
- &title)) {
- ap->descr = descr;
- return -1;
- }
- ap->descr = new;
- /* remember to update alignment flags */
- if ((new->alignment > 1) && \
- ((((intp)(ip+offset)) % new->alignment) != 0))
- ap->flags &= ~ALIGNED;
- else
- ap->flags |= ALIGNED;
-
- res = new->f->setitem(PyTuple_GET_ITEM(op, i),
- ip+offset, ap);
- ap->flags = savedflags;
- if (res < 0) break;
- }
+ descr = ap->descr;
+ if (descr->names && PyTuple_Check(op)) {
+ PyObject *key;
+ PyObject *names;
+ int i, n;
+ PyObject *tup, *title;
+ PyArray_Descr *new;
+ int offset;
+ int savedflags;
+ res = -1;
+ /* get the names from the fields dictionary*/
+ names = descr->names;
+ n = PyTuple_GET_SIZE(names);
+ if (PyTuple_GET_SIZE(op) != n) {
+ PyErr_SetString(PyExc_ValueError,
+ "size of tuple must match "\
+ "number of fields.");
+ return -1;
+ }
+ savedflags = ap->flags;
+ for (i=0; i<n; i++) {
+ key = PyTuple_GET_ITEM(names, i);
+ tup = PyDict_GetItem(descr->fields, key);
+ if (!PyArg_ParseTuple(tup, "Oi|O", &new, &offset,
+ &title)) {
ap->descr = descr;
- return res;
+ return -1;
+ }
+ ap->descr = new;
+ /* remember to update alignment flags */
+ if ((new->alignment > 1) && \
+ ((((intp)(ip+offset)) % new->alignment) != 0))
+ ap->flags &= ~ALIGNED;
+ else
+ ap->flags |= ALIGNED;
+
+ res = new->f->setitem(PyTuple_GET_ITEM(op, i),
+ ip+offset, ap);
+ ap->flags = savedflags;
+ if (res < 0) break;
}
+ ap->descr = descr;
+ return res;
+ }
- if (descr->subarray) {
- /* copy into an array of the same basic type */
- PyArray_Dims shape={NULL,-1};
- PyObject *ret;
- if (!(PyArray_IntpConverter(descr->subarray->shape,
- &shape))) {
- PyDimMem_FREE(shape.ptr);
- PyErr_SetString(PyExc_ValueError,
- "invalid shape in fixed-type tuple.");
- return -1;
- }
- Py_INCREF(descr->subarray->base);
- ret = PyArray_NewFromDescr(&PyArray_Type,
- descr->subarray->base,
- shape.len, shape.ptr,
- NULL, ip, ap->flags, NULL);
- PyDimMem_FREE(shape.ptr);
- if (!ret) return -1;
- PyArray_BASE(ret) = (PyObject *)ap;
- Py_INCREF(ap);
- PyArray_UpdateFlags((PyArrayObject *)ret, UPDATE_ALL);
- res = PyArray_CopyObject((PyArrayObject *)ret, op);
- Py_DECREF(ret);
- return res;
+ if (descr->subarray) {
+ /* copy into an array of the same basic type */
+ PyArray_Dims shape={NULL,-1};
+ PyObject *ret;
+ if (!(PyArray_IntpConverter(descr->subarray->shape,
+ &shape))) {
+ PyDimMem_FREE(shape.ptr);
+ PyErr_SetString(PyExc_ValueError,
+ "invalid shape in fixed-type tuple.");
+ return -1;
}
+ Py_INCREF(descr->subarray->base);
+ ret = PyArray_NewFromDescr(&PyArray_Type,
+ descr->subarray->base,
+ shape.len, shape.ptr,
+ NULL, ip, ap->flags, NULL);
+ PyDimMem_FREE(shape.ptr);
+ if (!ret) return -1;
+ PyArray_BASE(ret) = (PyObject *)ap;
+ Py_INCREF(ap);
+ PyArray_UpdateFlags((PyArrayObject *)ret, UPDATE_ALL);
+ res = PyArray_CopyObject((PyArrayObject *)ret, op);
+ Py_DECREF(ret);
+ return res;
+ }
- /* Default is to use buffer interface to set item */
- {
- const void *buffer;
- Py_ssize_t buflen;
- if (PyDataType_FLAGCHK(descr, NPY_ITEM_HASOBJECT) ||
- PyDataType_FLAGCHK(descr, NPY_ITEM_IS_POINTER)) {
- PyErr_SetString(PyExc_ValueError,
- "tried to set void-array with object"
- " members using buffer.");
- return -1;
- }
- res = PyObject_AsReadBuffer(op, &buffer, &buflen);
- if (res == -1) goto fail;
- memcpy(ip, buffer, NPY_MIN(buflen, itemsize));
- if (itemsize > buflen) {
- memset(ip+buflen, 0, (itemsize-buflen));
- }
+ /* Default is to use buffer interface to set item */
+ {
+ const void *buffer;
+ Py_ssize_t buflen;
+ if (PyDataType_FLAGCHK(descr, NPY_ITEM_HASOBJECT) ||
+ PyDataType_FLAGCHK(descr, NPY_ITEM_IS_POINTER)) {
+ PyErr_SetString(PyExc_ValueError,
+ "tried to set void-array with object"
+ " members using buffer.");
+ return -1;
}
- return 0;
+ res = PyObject_AsReadBuffer(op, &buffer, &buflen);
+ if (res == -1) goto fail;
+ memcpy(ip, buffer, NPY_MIN(buflen, itemsize));
+ if (itemsize > buflen) {
+ memset(ip+buflen, 0, (itemsize-buflen));
+ }
+ }
+ return 0;
- fail:
- return -1;
+fail:
+ return -1;
}
@@ -698,10 +697,10 @@
@from at _to_@to@(register @fromtyp@ *ip, register @totyp@ *op, register intp n,
PyArrayObject *aip, PyArrayObject *aop)
{
- while (n--) {
- *op++ = (@totyp@)*ip;
- @incr@;
- }
+ while (n--) {
+ *op++ = (@totyp@)*ip;
+ @incr@;
+ }
}
/**end repeat**/
@@ -713,9 +712,9 @@
@from at _to_BOOL(register @fromtyp@ *ip, register Bool *op, register intp n,
PyArrayObject *aip, PyArrayObject *aop)
{
- while (n--) {
- *op++ = (Bool)(*ip++ != FALSE);
- }
+ while (n--) {
+ *op++ = (Bool)(*ip++ != FALSE);
+ }
}
/**end repeat**/
@@ -727,10 +726,10 @@
@from at _to_BOOL(register @fromtyp@ *ip, register Bool *op, register intp n,
PyArrayObject *aip, PyArrayObject *aop)
{
- while (n--) {
- *op = (Bool)(((*ip).real != FALSE) || ((*ip).imag != FALSE));
- op++; ip++;
- }
+ while (n--) {
+ *op = (Bool)(((*ip).real != FALSE) || ((*ip).imag != FALSE));
+ op++; ip++;
+ }
}
/**end repeat**/
@@ -742,9 +741,9 @@
BOOL_to_ at to@(register Bool *ip, register @totyp@ *op, register intp n,
PyArrayObject *aip, PyArrayObject *aop)
{
- while (n--) {
- *op++ = (@totyp@)(*ip++ != FALSE);
- }
+ while (n--) {
+ *op++ = (@totyp@)(*ip++ != FALSE);
+ }
}
/**end repeat**/
@@ -759,10 +758,10 @@
@from at _to_@to@(register @fromtyp@ *ip, register @totyp@ *op, register intp n,
PyArrayObject *aip, PyArrayObject *aop)
{
- while (n--) {
- *op++ = (@totyp@)*ip++;
- *op++ = 0.0;
- }
+ while (n--) {
+ *op++ = (@totyp@)*ip++;
+ *op++ = 0.0;
+ }
}
/**end repeat**/
@@ -778,10 +777,10 @@
@from at _to_@to@(register @fromtyp@ *ip, register @totyp@ *op, register intp n,
PyArrayObject *aip, PyArrayObject *aop)
{
- n <<= 1;
- while (n--) {
- *op++ = (@totyp@)*ip++;
- }
+ n <<= 1;
+ while (n--) {
+ *op++ = (@totyp@)*ip++;
+ }
}
/**end repeat**/
@@ -796,12 +795,12 @@
@from at _to_OBJECT(@fromtyp@ *ip, PyObject **op, intp n, PyArrayObject *aip,
PyArrayObject *aop)
{
- register intp i;
- int skip=@skip@;
- for(i=0;i<n;i++,ip+=skip,op++) {
- Py_XDECREF(*op);
- *op = @from at _getitem((char *)ip, aip);
- }
+ register intp i;
+ int skip=@skip@;
+ for(i=0;i<n;i++,ip+=skip,op++) {
+ Py_XDECREF(*op);
+ *op = @from at _getitem((char *)ip, aip);
+ }
}
/**end repeat**/
@@ -815,16 +814,16 @@
OBJECT_to_ at to@(PyObject **ip, @totyp@ *op, intp n, PyArrayObject *aip,
PyArrayObject *aop)
{
- register intp i;
- int skip=@skip@;
- for(i=0;i<n;i++,ip++,op+=skip) {
- if (*ip == NULL) {
- @to at _setitem(Py_False, (char *)op, aop);
- }
- else {
- @to at _setitem(*ip, (char *)op, aop);
- }
+ register intp i;
+ int skip=@skip@;
+ for(i=0;i<n;i++,ip++,op+=skip) {
+ if (*ip == NULL) {
+ @to at _setitem(Py_False, (char *)op, aop);
}
+ else {
+ @to at _setitem(*ip, (char *)op, aop);
+ }
+ }
}
/**end repeat**/
@@ -843,27 +842,27 @@
@from at _to_@to@(@fromtyp@ *ip, @totyp@ *op, intp n, PyArrayObject *aip,
PyArrayObject *aop)
{
- register intp i;
- PyObject *temp=NULL;
- int skip=aip->descr->elsize;
- int oskip=@oskip@;
- for(i=0; i<n; i++, ip+=skip, op+=oskip) {
- temp = @from at _getitem((char *)ip, aip);
- if (temp==NULL) return;
- /* convert from Python object to needed one */
- if (@convert@) {
- PyObject *new, *args;
- /* call out to the Python builtin given by convstr */
- args = Py_BuildValue("(N)", temp);
- new = Py at convstr@_Type.tp_new(&Py at convstr@_Type, args, NULL);
- Py_DECREF(args);
- temp = new;
- if (temp==NULL) return;
- }
-
- @to at _setitem(temp,(char *)op, aop);
- Py_DECREF(temp);
+ register intp i;
+ PyObject *temp=NULL;
+ int skip=aip->descr->elsize;
+ int oskip=@oskip@;
+ for(i=0; i<n; i++, ip+=skip, op+=oskip) {
+ temp = @from at _getitem((char *)ip, aip);
+ if (temp==NULL) return;
+ /* convert from Python object to needed one */
+ if (@convert@) {
+ PyObject *new, *args;
+ /* call out to the Python builtin given by convstr */
+ args = Py_BuildValue("(N)", temp);
+ new = Py at convstr@_Type.tp_new(&Py at convstr@_Type, args, NULL);
+ Py_DECREF(args);
+ temp = new;
+ if (temp==NULL) return;
}
+
+ @to at _setitem(temp,(char *)op, aop);
+ Py_DECREF(temp);
+ }
}
/**end repeat**/
@@ -880,19 +879,19 @@
@from at _to_@to@(@fromtyp@ *ip, @totyp@ *op, intp n, PyArrayObject *aip,
PyArrayObject *aop)
{
- register intp i;
- PyObject *temp=NULL;
- int skip=1;
- int oskip=aop->descr->elsize;
- for(i=0; i<n; i++, ip+=skip, op+=oskip) {
- temp = @from at _getitem((char *)ip, aip);
- if (temp==NULL) {
- Py_INCREF(Py_False);
- temp = Py_False;
- }
- @to at _setitem(temp,(char *)op, aop);
- Py_DECREF(temp);
+ register intp i;
+ PyObject *temp=NULL;
+ int skip=1;
+ int oskip=aop->descr->elsize;
+ for(i=0; i<n; i++, ip+=skip, op+=oskip) {
+ temp = @from at _getitem((char *)ip, aip);
+ if (temp==NULL) {
+ Py_INCREF(Py_False);
+ temp = Py_False;
}
+ @to at _setitem(temp,(char *)op, aop);
+ Py_DECREF(temp);
+ }
}
/**end repeat**/
@@ -913,7 +912,7 @@
static int
@fname at _scan (FILE *fp, @type@ *ip, void *ignore, PyArray_Descr *ignore2)
{
- return fscanf(fp, "%"@format@, ip);
+ return fscanf(fp, "%"@format@, ip);
}
/**end repeat**/
@@ -927,22 +926,22 @@
static int
@fname at _scan (FILE *fp, @type@ *ip, void *ignore, PyArray_Descr *ignore2)
{
- @btype@ temp;
- int num;
- num = fscanf(fp, "%"@format@, &temp);
- *ip = (@type@) temp;
- return num;
+ @btype@ temp;
+ int num;
+ num = fscanf(fp, "%"@format@, &temp);
+ *ip = (@type@) temp;
+ return num;
}
/**end repeat**/
static int
BOOL_scan (FILE *fp, Bool *ip, void *ignore, PyArray_Descr *ignore2)
{
- int temp;
- int num;
- num = fscanf(fp, "%d", &temp);
- *ip = (Bool) (temp != 0);
- return num;
+ int temp;
+ int num;
+ num = fscanf(fp, "%d", &temp);
+ *ip = (Bool) (temp != 0);
+ return num;
}
/**begin repeat
@@ -962,11 +961,11 @@
static int
@fname at _fromstr(char *str, @type@ *ip, char **endptr, PyArray_Descr *ignore)
{
- @btype@ result;
+ @btype@ result;
- result = PyOS_strto at func@(str, endptr, 10);
- *ip = (@type@) result;
- return 0;
+ result = PyOS_strto at func@(str, endptr, 10);
+ *ip = (@type@) result;
+ return 0;
}
/**end repeat**/
@@ -978,11 +977,11 @@
static int
@fname at _fromstr(char *str, @type@ *ip, char **endptr, PyArray_Descr *ignore)
{
- double result;
+ double result;
- result = PyOS_ascii_strtod(str, endptr);
- *ip = (@type@) result;
- return 0;
+ result = PyOS_ascii_strtod(str, endptr);
+ *ip = (@type@) result;
+ return 0;
}
#else
#define @fname at _fromstr NULL
@@ -1010,79 +1009,79 @@
@fname at _copyswapn (void *dst, intp dstride, void *src, intp sstride,
intp n, int swap, void *arr)
{
- if (src != NULL) {
- if (sstride == sizeof(@type@) && dstride == sizeof(@type@)) {
- memcpy(dst, src, n*sizeof(@type@));
- }
- else {
- _unaligned_strided_byte_copy(dst, dstride, src, sstride,
- n, sizeof(@type@));
- }
+ if (src != NULL) {
+ if (sstride == sizeof(@type@) && dstride == sizeof(@type@)) {
+ memcpy(dst, src, n*sizeof(@type@));
}
- if (swap) {
- _strided_byte_swap(dst, dstride, n, sizeof(@type@));
+ else {
+ _unaligned_strided_byte_copy(dst, dstride, src, sstride,
+ n, sizeof(@type@));
}
+ }
+ if (swap) {
+ _strided_byte_swap(dst, dstride, n, sizeof(@type@));
+ }
}
static void
@fname at _copyswap (void *dst, void *src, int swap, void *arr)
{
- if (src != NULL) /* copy first if needed */
- memcpy(dst, src, sizeof(@type@));
+ if (src != NULL) /* copy first if needed */
+ memcpy(dst, src, sizeof(@type@));
- if (swap) {
- register char *a, *b, c;
- a = (char *)dst;
+ if (swap) {
+ register char *a, *b, c;
+ a = (char *)dst;
#if SIZEOF_ at fsize@ == 2
- b = a + 1;
- c = *a; *a++ = *b; *b = c;
+ b = a + 1;
+ c = *a; *a++ = *b; *b = c;
#elif SIZEOF_ at fsize@ == 4
- b = a + 3;
- c = *a; *a++ = *b; *b-- = c;
- c = *a; *a++ = *b; *b = c;
+ b = a + 3;
+ c = *a; *a++ = *b; *b-- = c;
+ c = *a; *a++ = *b; *b = c;
#elif SIZEOF_ at fsize@ == 8
- b = a + 7;
- c = *a; *a++ = *b; *b-- = c;
- c = *a; *a++ = *b; *b-- = c;
- c = *a; *a++ = *b; *b-- = c;
- c = *a; *a++ = *b; *b = c;
+ b = a + 7;
+ c = *a; *a++ = *b; *b-- = c;
+ c = *a; *a++ = *b; *b-- = c;
+ c = *a; *a++ = *b; *b-- = c;
+ c = *a; *a++ = *b; *b = c;
#elif SIZEOF_ at fsize@ == 10
- b = a + 9;
- c = *a; *a++ = *b; *b-- = c;
- c = *a; *a++ = *b; *b-- = c;
- c = *a; *a++ = *b; *b-- = c;
- c = *a; *a++ = *b; *b-- = c;
- c = *a; *a++ = *b; *b = c;
+ b = a + 9;
+ c = *a; *a++ = *b; *b-- = c;
+ c = *a; *a++ = *b; *b-- = c;
+ c = *a; *a++ = *b; *b-- = c;
+ c = *a; *a++ = *b; *b-- = c;
+ c = *a; *a++ = *b; *b = c;
#elif SIZEOF_ at fsize@ == 12
- b = a + 11;
- c = *a; *a++ = *b; *b-- = c;
- c = *a; *a++ = *b; *b-- = c;
- c = *a; *a++ = *b; *b-- = c;
- c = *a; *a++ = *b; *b-- = c;
- c = *a; *a++ = *b; *b-- = c;
- c = *a; *a++ = *b; *b = c;
+ b = a + 11;
+ c = *a; *a++ = *b; *b-- = c;
+ c = *a; *a++ = *b; *b-- = c;
+ c = *a; *a++ = *b; *b-- = c;
+ c = *a; *a++ = *b; *b-- = c;
+ c = *a; *a++ = *b; *b-- = c;
+ c = *a; *a++ = *b; *b = c;
#elif SIZEOF_ at fsize@ == 16
- b = a + 15;
- c = *a; *a++ = *b; *b-- = c;
- c = *a; *a++ = *b; *b-- = c;
- c = *a; *a++ = *b; *b-- = c;
- c = *a; *a++ = *b; *b-- = c;
- c = *a; *a++ = *b; *b-- = c;
- c = *a; *a++ = *b; *b-- = c;
- c = *a; *a++ = *b; *b-- = c;
- c = *a; *a++ = *b; *b = c;
+ b = a + 15;
+ c = *a; *a++ = *b; *b-- = c;
+ c = *a; *a++ = *b; *b-- = c;
+ c = *a; *a++ = *b; *b-- = c;
+ c = *a; *a++ = *b; *b-- = c;
+ c = *a; *a++ = *b; *b-- = c;
+ c = *a; *a++ = *b; *b-- = c;
+ c = *a; *a++ = *b; *b-- = c;
+ c = *a; *a++ = *b; *b = c;
#else
- {
- register int i, nn;
- b = a + (SIZEOF_ at fsize@-1);
- nn = SIZEOF_ at fsize@ / 2;
- for (i=0; i<nn; i++) {
- c=*a; *a++ = *b; *b-- = c;
- }
- }
-#endif
+ {
+ register int i, nn;
+ b = a + (SIZEOF_ at fsize@-1);
+ nn = SIZEOF_ at fsize@ / 2;
+ for (i=0; i<nn; i++) {
+ c=*a; *a++ = *b; *b-- = c;
+ }
}
+#endif
+ }
}
@@ -1097,24 +1096,24 @@
@fname at _copyswapn (void *dst, intp dstride, void *src, intp sstride, intp n,
int swap, void *arr)
{
- if (src != NULL) {
- if (sstride == sizeof(@type@) && dstride == sizeof(@type@)) {
- memcpy(dst, src, n*sizeof(@type@));
- }
- else {
- _unaligned_strided_byte_copy(dst, dstride, src, sstride,
- n, sizeof(@type@));
- }
+ if (src != NULL) {
+ if (sstride == sizeof(@type@) && dstride == sizeof(@type@)) {
+ memcpy(dst, src, n*sizeof(@type@));
}
- /* ignore swap */
+ else {
+ _unaligned_strided_byte_copy(dst, dstride, src, sstride,
+ n, sizeof(@type@));
+ }
+ }
+ /* ignore swap */
}
static void
@fname at _copyswap (void *dst, void *src, int swap, void *arr)
{
- if (src != NULL) /* copy first if needed */
- memcpy(dst, src, sizeof(@type@));
- /* ignore swap */
+ if (src != NULL) /* copy first if needed */
+ memcpy(dst, src, sizeof(@type@));
+ /* ignore swap */
}
/**end repeat**/
@@ -1132,120 +1131,120 @@
int swap, void *arr)
{
- if (src != NULL) { /* copy first if needed */
- if (sstride == sizeof(@type@) && dstride == sizeof(@type@)) {
- memcpy(dst, src, n*sizeof(@type@));
- }
- else {
- _unaligned_strided_byte_copy(dst, dstride, src,
- sstride, n,
- sizeof(@type@));
- }
+ if (src != NULL) { /* copy first if needed */
+ if (sstride == sizeof(@type@) && dstride == sizeof(@type@)) {
+ memcpy(dst, src, n*sizeof(@type@));
}
-
- if (swap) {
- _strided_byte_swap(dst, dstride, n, SIZEOF_ at fsize@);
- _strided_byte_swap(((char *)dst + SIZEOF_ at fsize@), dstride,
- n, SIZEOF_ at fsize@);
+ else {
+ _unaligned_strided_byte_copy(dst, dstride, src,
+ sstride, n,
+ sizeof(@type@));
}
+ }
+
+ if (swap) {
+ _strided_byte_swap(dst, dstride, n, SIZEOF_ at fsize@);
+ _strided_byte_swap(((char *)dst + SIZEOF_ at fsize@), dstride,
+ n, SIZEOF_ at fsize@);
+ }
}
static void
@fname at _copyswap (void *dst, void *src, int swap, void *arr)
{
- if (src != NULL) /* copy first if needed */
- memcpy(dst, src, sizeof(@type@));
+ if (src != NULL) /* copy first if needed */
+ memcpy(dst, src, sizeof(@type@));
- if (swap) {
- register char *a, *b, c;
- a = (char *)dst;
+ if (swap) {
+ register char *a, *b, c;
+ a = (char *)dst;
#if SIZEOF_ at fsize@ == 4
- b = a + 3;
- c = *a; *a++ = *b; *b-- = c;
- c = *a; *a++ = *b; *b = c;
- a += 2;
- b = a + 3;
- c = *a; *a++ = *b; *b-- = c;
- c = *a; *a++ = *b; *b = c;
+ b = a + 3;
+ c = *a; *a++ = *b; *b-- = c;
+ c = *a; *a++ = *b; *b = c;
+ a += 2;
+ b = a + 3;
+ c = *a; *a++ = *b; *b-- = c;
+ c = *a; *a++ = *b; *b = c;
#elif SIZEOF_ at fsize@ == 8
- b = a + 7;
- c = *a; *a++ = *b; *b-- = c;
- c = *a; *a++ = *b; *b-- = c;
- c = *a; *a++ = *b; *b-- = c;
- c = *a; *a++ = *b; *b = c;
- a += 4;
- b = a + 7;
- c = *a; *a++ = *b; *b-- = c;
- c = *a; *a++ = *b; *b-- = c;
- c = *a; *a++ = *b; *b-- = c;
- c = *a; *a++ = *b; *b = c;
+ b = a + 7;
+ c = *a; *a++ = *b; *b-- = c;
+ c = *a; *a++ = *b; *b-- = c;
+ c = *a; *a++ = *b; *b-- = c;
+ c = *a; *a++ = *b; *b = c;
+ a += 4;
+ b = a + 7;
+ c = *a; *a++ = *b; *b-- = c;
+ c = *a; *a++ = *b; *b-- = c;
+ c = *a; *a++ = *b; *b-- = c;
+ c = *a; *a++ = *b; *b = c;
#elif SIZEOF_ at fsize@ == 10
- b = a + 9;
- c = *a; *a++ = *b; *b-- = c;
- c = *a; *a++ = *b; *b-- = c;
- c = *a; *a++ = *b; *b-- = c;
- c = *a; *a++ = *b; *b-- = c;
- c = *a; *a++ = *b; *b = c;
- a += 5;
- b = a + 9;
- c = *a; *a++ = *b; *b-- = c;
- c = *a; *a++ = *b; *b-- = c;
- c = *a; *a++ = *b; *b-- = c;
- c = *a; *a++ = *b; *b-- = c;
- c = *a; *a++ = *b; *b = c;
+ b = a + 9;
+ c = *a; *a++ = *b; *b-- = c;
+ c = *a; *a++ = *b; *b-- = c;
+ c = *a; *a++ = *b; *b-- = c;
+ c = *a; *a++ = *b; *b-- = c;
+ c = *a; *a++ = *b; *b = c;
+ a += 5;
+ b = a + 9;
+ c = *a; *a++ = *b; *b-- = c;
+ c = *a; *a++ = *b; *b-- = c;
+ c = *a; *a++ = *b; *b-- = c;
+ c = *a; *a++ = *b; *b-- = c;
+ c = *a; *a++ = *b; *b = c;
#elif SIZEOF_ at fsize@ == 12
- b = a + 11;
- c = *a; *a++ = *b; *b-- = c;
- c = *a; *a++ = *b; *b-- = c;
- c = *a; *a++ = *b; *b-- = c;
- c = *a; *a++ = *b; *b-- = c;
- c = *a; *a++ = *b; *b-- = c;
- c = *a; *a++ = *b; *b = c;
- a += 6;
- b = a + 11;
- c = *a; *a++ = *b; *b-- = c;
- c = *a; *a++ = *b; *b-- = c;
- c = *a; *a++ = *b; *b-- = c;
- c = *a; *a++ = *b; *b-- = c;
- c = *a; *a++ = *b; *b-- = c;
- c = *a; *a++ = *b; *b = c;
+ b = a + 11;
+ c = *a; *a++ = *b; *b-- = c;
+ c = *a; *a++ = *b; *b-- = c;
+ c = *a; *a++ = *b; *b-- = c;
+ c = *a; *a++ = *b; *b-- = c;
+ c = *a; *a++ = *b; *b-- = c;
+ c = *a; *a++ = *b; *b = c;
+ a += 6;
+ b = a + 11;
+ c = *a; *a++ = *b; *b-- = c;
+ c = *a; *a++ = *b; *b-- = c;
+ c = *a; *a++ = *b; *b-- = c;
+ c = *a; *a++ = *b; *b-- = c;
+ c = *a; *a++ = *b; *b-- = c;
+ c = *a; *a++ = *b; *b = c;
#elif SIZEOF_ at fsize@ == 16
- b = a + 15;
- c = *a; *a++ = *b; *b-- = c;
- c = *a; *a++ = *b; *b-- = c;
- c = *a; *a++ = *b; *b-- = c;
- c = *a; *a++ = *b; *b-- = c;
- c = *a; *a++ = *b; *b-- = c;
- c = *a; *a++ = *b; *b-- = c;
- c = *a; *a++ = *b; *b-- = c;
- c = *a; *a++ = *b; *b = c;
- a += 8;
- b = a + 15;
- c = *a; *a++ = *b; *b-- = c;
- c = *a; *a++ = *b; *b-- = c;
- c = *a; *a++ = *b; *b-- = c;
- c = *a; *a++ = *b; *b-- = c;
- c = *a; *a++ = *b; *b-- = c;
- c = *a; *a++ = *b; *b-- = c;
- c = *a; *a++ = *b; *b-- = c;
- c = *a; *a++ = *b; *b = c;
+ b = a + 15;
+ c = *a; *a++ = *b; *b-- = c;
+ c = *a; *a++ = *b; *b-- = c;
+ c = *a; *a++ = *b; *b-- = c;
+ c = *a; *a++ = *b; *b-- = c;
+ c = *a; *a++ = *b; *b-- = c;
+ c = *a; *a++ = *b; *b-- = c;
+ c = *a; *a++ = *b; *b-- = c;
+ c = *a; *a++ = *b; *b = c;
+ a += 8;
+ b = a + 15;
+ c = *a; *a++ = *b; *b-- = c;
+ c = *a; *a++ = *b; *b-- = c;
+ c = *a; *a++ = *b; *b-- = c;
+ c = *a; *a++ = *b; *b-- = c;
+ c = *a; *a++ = *b; *b-- = c;
+ c = *a; *a++ = *b; *b-- = c;
+ c = *a; *a++ = *b; *b-- = c;
+ c = *a; *a++ = *b; *b = c;
#else
- {
- register int i, nn;
- b = a + (SIZEOF_ at fsize@-1);
- nn = SIZEOF_ at fsize@ / 2;
- for (i=0; i<nn; i++) {
- c=*a; *a++ = *b; *b-- = c;
- }
- a += nn / 2;
- b = a + (SIZEOF_ at fsize@-1);
- nn = SIZEOF_ at fsize@ / 2;
- for (i=0; i<nn; i++) {
- c=*a; *a++ = *b; *b-- = c;
- }
- }
-#endif
+ {
+ register int i, nn;
+ b = a + (SIZEOF_ at fsize@-1);
+ nn = SIZEOF_ at fsize@ / 2;
+ for (i=0; i<nn; i++) {
+ c=*a; *a++ = *b; *b-- = c;
+ }
+ a += nn / 2;
+ b = a + (SIZEOF_ at fsize@-1);
+ nn = SIZEOF_ at fsize@ / 2;
+ for (i=0; i<nn; i++) {
+ c=*a; *a++ = *b; *b-- = c;
+ }
}
+#endif
+ }
}
/**end repeat**/
@@ -1255,53 +1254,53 @@
OBJECT_copyswapn (PyObject **dst, intp dstride, PyObject **src, intp sstride,
register intp n, int swap, void *arr)
{
- register intp i;
- if (src != NULL) {
- dstride /= sizeof(PyObject **);
- sstride /= sizeof(PyObject **);
- if (__ALIGNED(dst,sizeof(PyObject **)) && __ALIGNED(src, sizeof(PyObject **))) {
- for (i=0; i<n; i++) {
- Py_XINCREF(*src);
- Py_XDECREF(*dst);
- *dst = *src;
- dst += dstride;
- src += sstride;
- }
- }
- else {
- PyObject **dp, **sp;
- for (i=0; i<n; i++) {
- dp = dst;
- sp = src;
- Py_XINCREF(*sp);
- Py_XDECREF(*dp);
- memcpy(dst, src, sizeof(PyObject *));
- dst += dstride;
- src += sstride;
- }
- }
+ register intp i;
+ if (src != NULL) {
+ dstride /= sizeof(PyObject **);
+ sstride /= sizeof(PyObject **);
+ if (__ALIGNED(dst,sizeof(PyObject **)) && __ALIGNED(src, sizeof(PyObject **))) {
+ for (i=0; i<n; i++) {
+ Py_XINCREF(*src);
+ Py_XDECREF(*dst);
+ *dst = *src;
+ dst += dstride;
+ src += sstride;
+ }
}
- /* ignore swap */
- return;
+ else {
+ PyObject **dp, **sp;
+ for (i=0; i<n; i++) {
+ dp = dst;
+ sp = src;
+ Py_XINCREF(*sp);
+ Py_XDECREF(*dp);
+ memcpy(dst, src, sizeof(PyObject *));
+ dst += dstride;
+ src += sstride;
+ }
+ }
+ }
+ /* ignore swap */
+ return;
}
static void
OBJECT_copyswap(PyObject **dst, PyObject **src, int swap, void *arr)
{
- if (src != NULL) {
- if (__ALIGNED(dst,sizeof(PyObject **)) && __ALIGNED(src,sizeof(PyObject **))) {
- Py_XINCREF(*src);
- Py_XDECREF(*dst);
- *dst = *src;
- }
- else {
- PyObject **dp=dst, **sp=src;
- Py_XINCREF(*sp);
- Py_XDECREF(*dp);
- memcpy(dst, src, sizeof(PyObject *));
- }
+ if (src != NULL) {
+ if (__ALIGNED(dst,sizeof(PyObject **)) && __ALIGNED(src,sizeof(PyObject **))) {
+ Py_XINCREF(*src);
+ Py_XDECREF(*dst);
+ *dst = *src;
}
+ else {
+ PyObject **dp=dst, **sp=src;
+ Py_XINCREF(*sp);
+ Py_XDECREF(*dp);
+ memcpy(dst, src, sizeof(PyObject *));
+ }
+ }
}
/* ignore swap */
@@ -1309,16 +1308,16 @@
STRING_copyswapn (char *dst, intp dstride, char *src, intp sstride,
intp n, int swap, PyArrayObject *arr)
{
- if (src != NULL && arr != NULL) {
- int itemsize = arr->descr->elsize;
- if (dstride == itemsize && sstride == itemsize) {
- memcpy(dst, src, itemsize * n);
- }
- else {
- _unaligned_strided_byte_copy(dst, dstride, src, sstride, n, itemsize);
- }
+ if (src != NULL && arr != NULL) {
+ int itemsize = arr->descr->elsize;
+ if (dstride == itemsize && sstride == itemsize) {
+ memcpy(dst, src, itemsize * n);
}
- return;
+ else {
+ _unaligned_strided_byte_copy(dst, dstride, src, sstride, n, itemsize);
+ }
+ }
+ return;
}
/* */
@@ -1326,95 +1325,95 @@
VOID_copyswapn (char *dst, intp dstride, char *src, intp sstride,
intp n, int swap, PyArrayObject *arr)
{
- if (arr == NULL) return;
- if (PyArray_HASFIELDS(arr)) {
- PyObject *key, *value, *title=NULL;
- PyArray_Descr *new, *descr;
- int offset;
- Py_ssize_t pos=0;
- descr = arr->descr;
- while (PyDict_Next(descr->fields, &pos, &key, &value)) {
- if (!PyArg_ParseTuple(value, "Oi|O", &new, &offset,
- &title)) {
- arr->descr=descr;return;
- }
- arr->descr = new;
- new->f->copyswapn(dst+offset, dstride,
- (src != NULL ? src+offset : NULL),
- sstride, n, swap, arr);
- }
- arr->descr = descr;
- return;
+ if (arr == NULL) return;
+ if (PyArray_HASFIELDS(arr)) {
+ PyObject *key, *value, *title=NULL;
+ PyArray_Descr *new, *descr;
+ int offset;
+ Py_ssize_t pos=0;
+ descr = arr->descr;
+ while (PyDict_Next(descr->fields, &pos, &key, &value)) {
+ if (!PyArg_ParseTuple(value, "Oi|O", &new, &offset,
+ &title)) {
+ arr->descr=descr;return;
+ }
+ arr->descr = new;
+ new->f->copyswapn(dst+offset, dstride,
+ (src != NULL ? src+offset : NULL),
+ sstride, n, swap, arr);
}
- if (swap && arr->descr->subarray != NULL) {
- PyArray_Descr *descr, *new;
- npy_intp num;
- npy_intp i;
- int subitemsize;
- char *dstptr, *srcptr;
- descr = arr->descr;
- new = descr->subarray->base;
- arr->descr = new;
- dstptr = dst;
- srcptr = src;
- subitemsize = new->elsize;
- num = descr->elsize / subitemsize;
- for (i=0; i<n; i++) {
- new->f->copyswapn(dstptr, subitemsize, srcptr,
- subitemsize, num, swap, arr);
- dstptr += dstride;
- if (srcptr) srcptr += sstride;
- }
- arr->descr = descr;
- return;
+ arr->descr = descr;
+ return;
+ }
+ if (swap && arr->descr->subarray != NULL) {
+ PyArray_Descr *descr, *new;
+ npy_intp num;
+ npy_intp i;
+ int subitemsize;
+ char *dstptr, *srcptr;
+ descr = arr->descr;
+ new = descr->subarray->base;
+ arr->descr = new;
+ dstptr = dst;
+ srcptr = src;
+ subitemsize = new->elsize;
+ num = descr->elsize / subitemsize;
+ for (i=0; i<n; i++) {
+ new->f->copyswapn(dstptr, subitemsize, srcptr,
+ subitemsize, num, swap, arr);
+ dstptr += dstride;
+ if (srcptr) srcptr += sstride;
}
- if (src != NULL) {
- memcpy(dst, src, arr->descr->elsize * n);
- }
+ arr->descr = descr;
return;
+ }
+ if (src != NULL) {
+ memcpy(dst, src, arr->descr->elsize * n);
+ }
+ return;
}
static void
VOID_copyswap (char *dst, char *src, int swap, PyArrayObject *arr)
{
- if (arr==NULL) return;
- if (PyArray_HASFIELDS(arr)) {
- PyObject *key, *value, *title=NULL;
- PyArray_Descr *new, *descr;
- int offset;
- Py_ssize_t pos=0;
- descr = arr->descr; /* Save it */
- while (PyDict_Next(descr->fields, &pos, &key, &value)) {
- if (!PyArg_ParseTuple(value, "Oi|O", &new, &offset,
- &title)) {
- arr->descr=descr;return;
- }
- arr->descr = new;
- new->f->copyswap(dst+offset,
- (src != NULL ? src+offset : NULL),
- swap, arr);
- }
- arr->descr = descr;
- return;
+ if (arr==NULL) return;
+ if (PyArray_HASFIELDS(arr)) {
+ PyObject *key, *value, *title=NULL;
+ PyArray_Descr *new, *descr;
+ int offset;
+ Py_ssize_t pos=0;
+ descr = arr->descr; /* Save it */
+ while (PyDict_Next(descr->fields, &pos, &key, &value)) {
+ if (!PyArg_ParseTuple(value, "Oi|O", &new, &offset,
+ &title)) {
+ arr->descr=descr;return;
+ }
+ arr->descr = new;
+ new->f->copyswap(dst+offset,
+ (src != NULL ? src+offset : NULL),
+ swap, arr);
}
- if (swap && arr->descr->subarray != NULL) {
- PyArray_Descr *descr, *new;
- npy_intp num;
- int itemsize;
- descr = arr->descr;
- new = descr->subarray->base;
- arr->descr = new;
- itemsize = new->elsize;
- num = descr->elsize / itemsize;
- new->f->copyswapn(dst, itemsize, src,
- itemsize, num, swap, arr);
- arr->descr = descr;
- return;
- }
- if (src != NULL) {
- memcpy(dst, src, arr->descr->elsize);
- }
+ arr->descr = descr;
return;
+ }
+ if (swap && arr->descr->subarray != NULL) {
+ PyArray_Descr *descr, *new;
+ npy_intp num;
+ int itemsize;
+ descr = arr->descr;
+ new = descr->subarray->base;
+ arr->descr = new;
+ itemsize = new->elsize;
+ num = descr->elsize / itemsize;
+ new->f->copyswapn(dst, itemsize, src,
+ itemsize, num, swap, arr);
+ arr->descr = descr;
+ return;
+ }
+ if (src != NULL) {
+ memcpy(dst, src, arr->descr->elsize);
+ }
+ return;
}
@@ -1422,59 +1421,59 @@
UNICODE_copyswapn (char *dst, intp dstride, char *src, intp sstride,
intp n, int swap, PyArrayObject *arr)
{
- int itemsize;
- if (arr==NULL) return;
- itemsize = arr->descr->elsize;
- if (src != NULL) {
- if (dstride == itemsize && sstride == itemsize)
- memcpy(dst, src, n * itemsize);
- else
- _unaligned_strided_byte_copy(dst, dstride, src,
- sstride, n, itemsize);
- }
+ int itemsize;
+ if (arr==NULL) return;
+ itemsize = arr->descr->elsize;
+ if (src != NULL) {
+ if (dstride == itemsize && sstride == itemsize)
+ memcpy(dst, src, n * itemsize);
+ else
+ _unaligned_strided_byte_copy(dst, dstride, src,
+ sstride, n, itemsize);
+ }
- n *= itemsize;
- if (swap) {
- register char *a, *b, c;
- n >>= 2; /* n is the number of unicode characters to swap */
- for (a = (char *)dst; n>0; n--) {
- b = a + 3;
- c=*a; *a++ = *b; *b-- = c;
- c=*a; *a++ = *b; *b-- = c;
- a += 2;
- }
+ n *= itemsize;
+ if (swap) {
+ register char *a, *b, c;
+ n >>= 2; /* n is the number of unicode characters to swap */
+ for (a = (char *)dst; n>0; n--) {
+ b = a + 3;
+ c=*a; *a++ = *b; *b-- = c;
+ c=*a; *a++ = *b; *b-- = c;
+ a += 2;
}
+ }
}
static void
STRING_copyswap (char *dst, char *src, int swap, PyArrayObject *arr)
{
- if (src != NULL && arr != NULL) {
- memcpy(dst, src, arr->descr->elsize);
- }
+ if (src != NULL && arr != NULL) {
+ memcpy(dst, src, arr->descr->elsize);
+ }
}
static void
UNICODE_copyswap (char *dst, char *src, int swap, PyArrayObject *arr)
{
- int itemsize;
- if (arr == NULL) return;
- itemsize = arr->descr->elsize;
- if (src != NULL) {
- memcpy(dst, src, itemsize);
- }
+ int itemsize;
+ if (arr == NULL) return;
+ itemsize = arr->descr->elsize;
+ if (src != NULL) {
+ memcpy(dst, src, itemsize);
+ }
- if (swap) {
- register char *a, *b, c;
- itemsize >>= 2;
- for (a = (char *)dst; itemsize>0; itemsize--) {
- b = a + 3;
- c=*a; *a++ = *b; *b-- = c;
- c=*a; *a++ = *b; *b-- = c;
- a += 2;
- }
+ if (swap) {
+ register char *a, *b, c;
+ itemsize >>= 2;
+ for (a = (char *)dst; itemsize>0; itemsize--) {
+ b = a + 3;
+ c=*a; *a++ = *b; *b-- = c;
+ c=*a; *a++ = *b; *b-- = c;
+ a += 2;
}
+ }
}
@@ -1487,15 +1486,15 @@
static Bool
@fname at _nonzero (@type@ *ip, PyArrayObject *ap)
{
- @type@ t1;
- if (ap==NULL || PyArray_ISBEHAVED_RO(ap))
- return (Bool) (*ip != 0);
- else {
- /* don't worry about swap, since we are just testing
- whether or not equal to 0 */
- memcpy(&t1, ip, sizeof(@type@));
- return (Bool) (t1 != 0);
- }
+ @type@ t1;
+ if (ap==NULL || PyArray_ISBEHAVED_RO(ap))
+ return (Bool) (*ip != 0);
+ else {
+ /* don't worry about swap, since we are just testing
+ whether or not equal to 0 */
+ memcpy(&t1, ip, sizeof(@type@));
+ return (Bool) (t1 != 0);
+ }
}
/**end repeat**/
@@ -1506,15 +1505,15 @@
static Bool
@fname at _nonzero (@type@ *ip, PyArrayObject *ap)
{
- @type@ t1;
- if (ap==NULL || PyArray_ISBEHAVED_RO(ap))
- return (Bool) ((ip->real != 0) || (ip->imag != 0));
- else {
- /* don't worry about swap, since we are just testing
- whether or not equal to 0 */
- memcpy(&t1, ip, sizeof(@type@));
- return (Bool) ((t1.real != 0) || (t1.imag != 0));
- }
+ @type@ t1;
+ if (ap==NULL || PyArray_ISBEHAVED_RO(ap))
+ return (Bool) ((ip->real != 0) || (ip->imag != 0));
+ else {
+ /* don't worry about swap, since we are just testing
+ whether or not equal to 0 */
+ memcpy(&t1, ip, sizeof(@type@));
+ return (Bool) ((t1.real != 0) || (t1.imag != 0));
+ }
}
/**end repeat**/
@@ -1525,33 +1524,33 @@
static Bool
Py_STRING_ISSPACE(char ch)
{
- char white[] = WHITESPACE;
- int j;
- Bool space=FALSE;
- for (j=0; j<WHITELEN; j++) {
- if (ch == white[j]) {
- space=TRUE;
- break;
- }
+ char white[] = WHITESPACE;
+ int j;
+ Bool space=FALSE;
+ for (j=0; j<WHITELEN; j++) {
+ if (ch == white[j]) {
+ space=TRUE;
+ break;
}
- return space;
+ }
+ return space;
}
static Bool
STRING_nonzero (char *ip, PyArrayObject *ap)
{
- int len = ap->descr->elsize;
- int i;
- Bool nonz = FALSE;
+ int len = ap->descr->elsize;
+ int i;
+ Bool nonz = FALSE;
- for (i=0; i<len; i++) {
- if (!Py_STRING_ISSPACE(*ip)) {
- nonz = TRUE;
- break;
- }
- ip++;
+ for (i=0; i<len; i++) {
+ if (!Py_STRING_ISSPACE(*ip)) {
+ nonz = TRUE;
+ break;
}
- return nonz;
+ ip++;
+ }
+ return nonz;
}
#ifdef Py_UNICODE_WIDE
@@ -1563,48 +1562,48 @@
static Bool
UNICODE_nonzero (PyArray_UCS4 *ip, PyArrayObject *ap)
{
- int len = ap->descr->elsize >> 2;
- int i;
- Bool nonz = FALSE;
- char *buffer=NULL;
+ int len = ap->descr->elsize >> 2;
+ int i;
+ Bool nonz = FALSE;
+ char *buffer=NULL;
- if ((!PyArray_ISNOTSWAPPED(ap)) || \
+ if ((!PyArray_ISNOTSWAPPED(ap)) || \
(!PyArray_ISALIGNED(ap))) {
- buffer = _pya_malloc(ap->descr->elsize);
- if (buffer == NULL) {
- return nonz;
- }
- memcpy(buffer, ip, ap->descr->elsize);
- if (!PyArray_ISNOTSWAPPED(ap)) {
- byte_swap_vector(buffer, len, 4);
- }
- ip = (PyArray_UCS4 *)buffer;
+ buffer = _pya_malloc(ap->descr->elsize);
+ if (buffer == NULL) {
+ return nonz;
}
+ memcpy(buffer, ip, ap->descr->elsize);
+ if (!PyArray_ISNOTSWAPPED(ap)) {
+ byte_swap_vector(buffer, len, 4);
+ }
+ ip = (PyArray_UCS4 *)buffer;
+ }
- for (i=0; i<len; i++) {
- if (!PyArray_UCS4_ISSPACE(*ip)) {
- nonz = TRUE;
- break;
- }
- ip++;
+ for (i=0; i<len; i++) {
+ if (!PyArray_UCS4_ISSPACE(*ip)) {
+ nonz = TRUE;
+ break;
}
- _pya_free(buffer);
- return nonz;
+ ip++;
+ }
+ _pya_free(buffer);
+ return nonz;
}
static Bool
OBJECT_nonzero (PyObject **ip, PyArrayObject *ap)
{
- if (*ip == NULL) return FALSE;
- if (PyArray_ISALIGNED(ap)) {
- return (Bool) PyObject_IsTrue(*ip);
- }
- else {
- PyObject **obj;
- obj = ip;
- return (Bool) PyObject_IsTrue(*obj);
- }
+ if (*ip == NULL) return FALSE;
+ if (PyArray_ISALIGNED(ap)) {
+ return (Bool) PyObject_IsTrue(*ip);
+ }
+ else {
+ PyObject **obj;
+ obj = ip;
+ return (Bool) PyObject_IsTrue(*obj);
+ }
}
/* if we have fields, then nonzero only if all sub-fields are nonzero.
@@ -1612,44 +1611,44 @@
static Bool
VOID_nonzero (char *ip, PyArrayObject *ap)
{
- int i;
- int len;
- Bool nonz = FALSE;
+ int i;
+ int len;
+ Bool nonz = FALSE;
- if (PyArray_HASFIELDS(ap)) {
- PyArray_Descr *descr, *new;
- PyObject *key, *value, *title;
- int savedflags, offset;
- Py_ssize_t pos=0;
- descr = ap->descr;
- savedflags = ap->flags;
- while (PyDict_Next(descr->fields, &pos, &key, &value)) {
- if (!PyArg_ParseTuple(value, "Oi|O", &new, &offset,
- &title)) {PyErr_Clear(); continue;}
- ap->descr = new;
- ap->flags = savedflags;
- if ((new->alignment > 1) && !__ALIGNED(ip+offset, new->alignment))
- ap->flags &= ~ALIGNED;
- else
- ap->flags |= ALIGNED;
- if (new->f->nonzero(ip+offset, ap)) {
- nonz=TRUE;
- break;
- }
- }
- ap->descr = descr;
- ap->flags = savedflags;
- return nonz;
+ if (PyArray_HASFIELDS(ap)) {
+ PyArray_Descr *descr, *new;
+ PyObject *key, *value, *title;
+ int savedflags, offset;
+ Py_ssize_t pos=0;
+ descr = ap->descr;
+ savedflags = ap->flags;
+ while (PyDict_Next(descr->fields, &pos, &key, &value)) {
+ if (!PyArg_ParseTuple(value, "Oi|O", &new, &offset,
+ &title)) {PyErr_Clear(); continue;}
+ ap->descr = new;
+ ap->flags = savedflags;
+ if ((new->alignment > 1) && !__ALIGNED(ip+offset, new->alignment))
+ ap->flags &= ~ALIGNED;
+ else
+ ap->flags |= ALIGNED;
+ if (new->f->nonzero(ip+offset, ap)) {
+ nonz=TRUE;
+ break;
+ }
}
- len = ap->descr->elsize;
- for (i=0; i<len; i++) {
- if (*ip != '\0') {
- nonz = TRUE;
- break;
- }
- ip++;
- }
+ ap->descr = descr;
+ ap->flags = savedflags;
return nonz;
+ }
+ len = ap->descr->elsize;
+ for (i=0; i<len; i++) {
+ if (*ip != '\0') {
+ nonz = TRUE;
+ break;
+ }
+ ip++;
+ }
+ return nonz;
}
#undef __ALIGNED
@@ -1660,7 +1659,7 @@
static int
BOOL_compare(Bool *ip1, Bool *ip2, PyArrayObject *ap)
{
- return (*ip1 ? (*ip2 ? 0 : 1) : (*ip2 ? -1 : 0));
+ return (*ip1 ? (*ip2 ? 0 : 1) : (*ip2 ? -1 : 0));
}
/**begin repeat
@@ -1671,7 +1670,7 @@
static int
@fname at _compare (@type@ *ip1, @type@ *ip2, PyArrayObject *ap)
{
- return *ip1 < *ip2 ? -1 : *ip1 == *ip2 ? 0 : 1;
+ return *ip1 < *ip2 ? -1 : *ip1 == *ip2 ? 0 : 1;
}
/**end repeat**/
@@ -1685,24 +1684,24 @@
static int
@fname at _compare (@type@ *ip1, @type@ *ip2, PyArrayObject *ap)
{
- if (*ip1 == *ip2) {
- return ip1[1]<ip2[1] ? -1 : (ip1[1] == ip2[1] ? 0 : 1);
- }
- else {
- return *ip1 < *ip2 ? -1 : 1;
- }
+ if (*ip1 == *ip2) {
+ return ip1[1]<ip2[1] ? -1 : (ip1[1] == ip2[1] ? 0 : 1);
+ }
+ else {
+ return *ip1 < *ip2 ? -1 : 1;
+ }
}
/**end repeat**/
static int
OBJECT_compare(PyObject **ip1, PyObject **ip2, PyArrayObject *ap)
{
- if ((*ip1 == NULL) || (*ip2 == NULL)) {
- if (ip1 == ip2) return 1;
- if (ip1 == NULL) return -1;
- return 1;
- }
- return PyObject_Compare(*ip1, *ip2);
+ if ((*ip1 == NULL) || (*ip2 == NULL)) {
+ if (ip1 == ip2) return 1;
+ if (ip1 == NULL) return -1;
+ return 1;
+ }
+ return PyObject_Compare(*ip1, *ip2);
}
static int
@@ -1726,19 +1725,19 @@
UNICODE_compare(register PyArray_UCS4 *ip1, register PyArray_UCS4 *ip2,
PyArrayObject *ap)
{
- register int itemsize=ap->descr->elsize;
- register PyArray_UCS4 c1, c2;
+ register int itemsize=ap->descr->elsize;
+ register PyArray_UCS4 c1, c2;
- if (itemsize < 0) return 0;
+ if (itemsize < 0) return 0;
- while(itemsize-- > 0) {
- c1 = *ip1++;
- c2 = *ip2++;
+ while(itemsize-- > 0) {
+ c1 = *ip1++;
+ c2 = *ip2++;
- if (c1 != c2)
- return (c1 < c2) ? -1 : 1;
- }
- return 0;
+ if (c1 != c2)
+ return (c1 < c2) ? -1 : 1;
+ }
+ return 0;
}
/* If fields are defined, then compare on first field and if equal
@@ -1751,63 +1750,63 @@
static int
VOID_compare(char *ip1, char *ip2, PyArrayObject *ap)
{
- PyArray_Descr *descr, *new;
- PyObject *names, *key;
- PyObject *tup, *title;
- char *nip1, *nip2;
- int i, offset, res=0;
+ PyArray_Descr *descr, *new;
+ PyObject *names, *key;
+ PyObject *tup, *title;
+ char *nip1, *nip2;
+ int i, offset, res=0;
- if (!PyArray_HASFIELDS(ap))
- return STRING_compare(ip1, ip2, ap);
+ if (!PyArray_HASFIELDS(ap))
+ return STRING_compare(ip1, ip2, ap);
- descr = ap->descr;
- /* Compare on the first-field. If equal, then
- compare on the second-field, etc.
- */
- names = descr->names;
- for (i=0; i<PyTuple_GET_SIZE(names); i++) {
- key = PyTuple_GET_ITEM(names, i);
- tup = PyDict_GetItem(descr->fields, key);
- if (!PyArg_ParseTuple(tup, "Oi|O", &new, &offset,
- &title)) {
- goto finish;
+ descr = ap->descr;
+ /* Compare on the first-field. If equal, then
+ compare on the second-field, etc.
+ */
+ names = descr->names;
+ for (i=0; i<PyTuple_GET_SIZE(names); i++) {
+ key = PyTuple_GET_ITEM(names, i);
+ tup = PyDict_GetItem(descr->fields, key);
+ if (!PyArg_ParseTuple(tup, "Oi|O", &new, &offset,
+ &title)) {
+ goto finish;
+ }
+ ap->descr = new;
+ nip1 = ip1+offset;
+ nip2 = ip2+offset;
+ if (new->alignment > 1) {
+ if (((intp)(nip1) % new->alignment) != 0) {
+ /* create buffer and copy */
+ nip1 = _pya_malloc(new->elsize);
+ if (nip1 == NULL) goto finish;
+ memcpy(nip1, ip1+offset, new->elsize);
+ }
+ if (((intp)(nip2) % new->alignment) != 0) {
+ /* copy data to a buffer */
+ nip2 = _pya_malloc(new->elsize);
+ if (nip2 == NULL) {
+ if (nip1 != ip1+offset)
+ _pya_free(nip1);
+ goto finish;
}
- ap->descr = new;
- nip1 = ip1+offset;
- nip2 = ip2+offset;
- if (new->alignment > 1) {
- if (((intp)(nip1) % new->alignment) != 0) {
- /* create buffer and copy */
- nip1 = _pya_malloc(new->elsize);
- if (nip1 == NULL) goto finish;
- memcpy(nip1, ip1+offset, new->elsize);
- }
- if (((intp)(nip2) % new->alignment) != 0) {
- /* copy data to a buffer */
- nip2 = _pya_malloc(new->elsize);
- if (nip2 == NULL) {
- if (nip1 != ip1+offset)
- _pya_free(nip1);
- goto finish;
- }
- memcpy(nip2, ip2+offset, new->elsize);
- }
- }
- res = new->f->compare(nip1, nip2, ap);
- if (new->alignment > 1) {
- if (nip1 != ip1+offset) {
- _pya_free(nip1);
- }
- if (nip2 != ip2+offset) {
- _pya_free(nip2);
- }
- }
- if (res != 0) break;
+ memcpy(nip2, ip2+offset, new->elsize);
+ }
}
+ res = new->f->compare(nip1, nip2, ap);
+ if (new->alignment > 1) {
+ if (nip1 != ip1+offset) {
+ _pya_free(nip1);
+ }
+ if (nip2 != ip2+offset) {
+ _pya_free(nip2);
+ }
+ }
+ if (res != 0) break;
+ }
- finish:
- ap->descr = descr;
- return res;
+finish:
+ ap->descr = descr;
+ return res;
}
/****************** argfunc **********************************/
@@ -1822,17 +1821,17 @@
static int
@fname at _argmax(@type@ *ip, intp n, intp *max_ind, PyArrayObject *aip)
{
- register intp i;
- @type@ mp=*ip;
- *max_ind=0;
- for (i=1; i<n; i++) {
- @incr@;
- if (*ip > mp) {
- mp = *ip;
- *max_ind = i;
- }
+ register intp i;
+ @type@ mp=*ip;
+ *max_ind=0;
+ for (i=1; i<n; i++) {
+ @incr@;
+ if (*ip > mp) {
+ mp = *ip;
+ *max_ind = i;
}
- return 0;
+ }
+ return 0;
}
/**end repeat**/
@@ -1840,21 +1839,21 @@
static int
OBJECT_argmax(PyObject **ip, intp n, intp *max_ind, PyArrayObject *aip)
{
- register intp i;
- PyObject *mp=ip[0]; *max_ind=0;
- i = 1;
- while(i<n && mp==NULL) {
- mp=ip[i];
- i++;
+ register intp i;
+ PyObject *mp=ip[0]; *max_ind=0;
+ i = 1;
+ while(i<n && mp==NULL) {
+ mp=ip[i];
+ i++;
+ }
+ for(; i<n; i++) {
+ ip++;
+ if (*ip != NULL && PyObject_Compare(*ip,mp) > 0) {
+ mp = *ip;
+ *max_ind=i;
}
- for(; i<n; i++) {
- ip++;
- if (*ip != NULL && PyObject_Compare(*ip,mp) > 0) {
- mp = *ip;
- *max_ind=i;
- }
- }
- return 0;
+ }
+ return 0;
}
/**begin repeat
@@ -1866,22 +1865,22 @@
static int
@fname at _argmax(@type@ *ip, intp n, intp *max_ind, PyArrayObject *aip)
{
- register intp i;
- int elsize = aip->descr->elsize;
- @type@ *mp = (@type@ *)_pya_malloc(elsize);
+ register intp i;
+ int elsize = aip->descr->elsize;
+ @type@ *mp = (@type@ *)_pya_malloc(elsize);
- if (mp==NULL) return 0;
- memcpy(mp, ip, elsize);
- *max_ind = 0;
- for(i=1; i<n; i++) {
- ip += elsize;
- if (@fname at _compare(ip,mp,aip) > 0) {
- memcpy(mp, ip, elsize);
- *max_ind=i;
- }
+ if (mp==NULL) return 0;
+ memcpy(mp, ip, elsize);
+ *max_ind = 0;
+ for(i=1; i<n; i++) {
+ ip += elsize;
+ if (@fname at _compare(ip,mp,aip) > 0) {
+ memcpy(mp, ip, elsize);
+ *max_ind=i;
}
- _pya_free(mp);
- return 0;
+ }
+ _pya_free(mp);
+ return 0;
}
/**end repeat**/
@@ -1892,15 +1891,15 @@
BOOL_dot(char *ip1, intp is1, char *ip2, intp is2, char *op, intp n,
void *ignore)
{
- register Bool tmp=FALSE;
- register intp i;
- for(i=0;i<n;i++,ip1+=is1,ip2+=is2) {
- if ((*((Bool *)ip1) != 0) && (*((Bool *)ip2) != 0)) {
- tmp = TRUE;
- break;
- }
+ register Bool tmp=FALSE;
+ register intp i;
+ for(i=0;i<n;i++,ip1+=is1,ip2+=is2) {
+ if ((*((Bool *)ip1) != 0) && (*((Bool *)ip2) != 0)) {
+ tmp = TRUE;
+ break;
}
- *((Bool *)op) = tmp;
+ }
+ *((Bool *)op) = tmp;
}
/**begin repeat
@@ -1912,13 +1911,13 @@
@name at _dot(char *ip1, intp is1, char *ip2, intp is2, char *op, intp n,
void *ignore)
{
- register @out@ tmp=(@out@)0;
- register intp i;
- for(i=0;i<n;i++,ip1+=is1,ip2+=is2) {
- tmp += (@out@)(*((@type@ *)ip1)) * \
- (@out@)(*((@type@ *)ip2));
- }
- *((@type@ *)op) = (@type@) tmp;
+ register @out@ tmp=(@out@)0;
+ register intp i;
+ for(i=0;i<n;i++,ip1+=is1,ip2+=is2) {
+ tmp += (@out@)(*((@type@ *)ip1)) * \
+ (@out@)(*((@type@ *)ip2));
+ }
+ *((@type@ *)op) = (@type@) tmp;
}
/**end repeat**/
@@ -1930,15 +1929,15 @@
static void @name at _dot(char *ip1, intp is1, char *ip2, intp is2,
char *op, intp n, void *ignore)
{
- @type@ tmpr=(@type@)0.0, tmpi=(@type@)0.0;
- intp i;
- for(i=0;i<n;i++,ip1+=is1,ip2+=is2) {
- tmpr += ((@type@ *)ip1)[0] * ((@type@ *)ip2)[0]
- - ((@type@ *)ip1)[1] * ((@type@ *)ip2)[1];
- tmpi += ((@type@ *)ip1)[1] * ((@type@ *)ip2)[0]
- + ((@type@ *)ip1)[0] * ((@type@ *)ip2)[1];
- }
- ((@type@ *)op)[0] = tmpr; ((@type@ *)op)[1] = tmpi;
+ @type@ tmpr=(@type@)0.0, tmpi=(@type@)0.0;
+ intp i;
+ for(i=0;i<n;i++,ip1+=is1,ip2+=is2) {
+ tmpr += ((@type@ *)ip1)[0] * ((@type@ *)ip2)[0]
+ - ((@type@ *)ip1)[1] * ((@type@ *)ip2)[1];
+ tmpi += ((@type@ *)ip1)[1] * ((@type@ *)ip2)[0]
+ + ((@type@ *)ip1)[0] * ((@type@ *)ip2)[1];
+ }
+ ((@type@ *)op)[0] = tmpr; ((@type@ *)op)[1] = tmpi;
}
/**end repeat**/
@@ -1947,33 +1946,33 @@
OBJECT_dot(char *ip1, intp is1, char *ip2, intp is2, char *op, intp n,
void *ignore)
{
- intp i;
- PyObject *tmp1, *tmp2, *tmp=NULL;
- PyObject **tmp3;
- for(i=0;i<n;i++,ip1+=is1,ip2+=is2) {
- if ((*((PyObject **)ip1) == NULL) || (*((PyObject **)ip2) == NULL)) {
- tmp1 = Py_False;
- Py_INCREF(Py_False);
- }
- else {
- tmp1 = PyNumber_Multiply(*((PyObject **)ip1),
- *((PyObject **)ip2));
- if (!tmp1) { Py_XDECREF(tmp); return;}
- }
- if (i == 0) {
- tmp = tmp1;
- } else {
- tmp2 = PyNumber_Add(tmp, tmp1);
- Py_XDECREF(tmp);
- Py_XDECREF(tmp1);
- if (!tmp2) return;
- tmp = tmp2;
- }
+ intp i;
+ PyObject *tmp1, *tmp2, *tmp=NULL;
+ PyObject **tmp3;
+ for(i=0;i<n;i++,ip1+=is1,ip2+=is2) {
+ if ((*((PyObject **)ip1) == NULL) || (*((PyObject **)ip2) == NULL)) {
+ tmp1 = Py_False;
+ Py_INCREF(Py_False);
}
- tmp3 = (PyObject**) op;
- tmp2 = *tmp3;
- *((PyObject **)op) = tmp;
- Py_XDECREF(tmp2);
+ else {
+ tmp1 = PyNumber_Multiply(*((PyObject **)ip1),
+ *((PyObject **)ip2));
+ if (!tmp1) { Py_XDECREF(tmp); return;}
+ }
+ if (i == 0) {
+ tmp = tmp1;
+ } else {
+ tmp2 = PyNumber_Add(tmp, tmp1);
+ Py_XDECREF(tmp);
+ Py_XDECREF(tmp1);
+ if (!tmp2) return;
+ tmp = tmp2;
+ }
+ }
+ tmp3 = (PyObject**) op;
+ tmp2 = *tmp3;
+ *((PyObject **)op) = tmp;
+ Py_XDECREF(tmp2);
}
#define BOOL_fill NULL
@@ -1982,25 +1981,25 @@
static void
OBJECT_fill(PyObject **buffer, intp length, void *ignored)
{
- intp i;
- PyObject *start = buffer[0];
- PyObject *delta = buffer[1];
- delta = PyNumber_Subtract(delta, start);
- if (!delta) return;
+ intp i;
+ PyObject *start = buffer[0];
+ PyObject *delta = buffer[1];
+ delta = PyNumber_Subtract(delta, start);
+ if (!delta) return;
+ start = PyNumber_Add(start, delta);
+ if (!start) goto finish;
+ buffer += 2;
+
+ for (i=2; i<length; i++, buffer++) {
start = PyNumber_Add(start, delta);
if (!start) goto finish;
- buffer += 2;
+ Py_XDECREF(*buffer);
+ *buffer = start;
+ }
- for (i=2; i<length; i++, buffer++) {
- start = PyNumber_Add(start, delta);
- if (!start) goto finish;
- Py_XDECREF(*buffer);
- *buffer = start;
- }
-
- finish:
- Py_DECREF(delta);
- return;
+finish:
+ Py_DECREF(delta);
+ return;
}
/**begin repeat
@@ -2010,13 +2009,13 @@
static void
@NAME at _fill(@typ@ *buffer, intp length, void *ignored)
{
- register intp i;
- @typ@ start = buffer[0];
- @typ@ delta = buffer[1];
- delta -= start;
- for (i=2; i<length; ++i) {
- buffer[i] = start + i*delta;
- }
+ register intp i;
+ @typ@ start = buffer[0];
+ @typ@ delta = buffer[1];
+ delta -= start;
+ for (i=2; i<length; ++i) {
+ buffer[i] = start + i*delta;
+ }
}
/**end repeat**/
@@ -2027,21 +2026,21 @@
static void
@NAME at _fill(@typ@ *buffer, intp length, void *ignored)
{
- register intp i;
- @typ@ start;
- @typ@ delta;
+ register intp i;
+ @typ@ start;
+ @typ@ delta;
- start.real = buffer->real;
- start.imag = buffer->imag;
- delta.real = buffer[1].real;
- delta.imag = buffer[1].imag;
- delta.real -= start.real;
- delta.imag -= start.imag;
- buffer += 2;
- for (i=2; i<length; i++, buffer++) {
- buffer->real = start.real + i*delta.real;
- buffer->imag = start.imag + i*delta.imag;
- }
+ start.real = buffer->real;
+ start.imag = buffer->imag;
+ delta.real = buffer[1].real;
+ delta.imag = buffer[1].imag;
+ delta.real -= start.real;
+ delta.imag -= start.imag;
+ buffer += 2;
+ for (i=2; i<length; i++, buffer++) {
+ buffer->real = start.real + i*delta.real;
+ buffer->imag = start.imag + i*delta.imag;
+ }
}
/**end repeat**/
@@ -2050,13 +2049,13 @@
static void
OBJECT_fillwithscalar(PyObject **buffer, intp length, PyObject **value, void *ignored)
{
- intp i;
- PyObject *val = *value;
- for (i=0; i<length; i++) {
- Py_XDECREF(buffer[i]);
- Py_XINCREF(val);
- buffer[i] = val;
- }
+ intp i;
+ PyObject *val = *value;
+ for (i=0; i<length; i++) {
+ Py_XDECREF(buffer[i]);
+ Py_XINCREF(val);
+ buffer[i] = val;
+ }
}
/**begin repeat
#NAME=BOOL,BYTE,UBYTE#
@@ -2065,7 +2064,7 @@
static void
@NAME at _fillwithscalar(@typ@ *buffer, intp length, @typ@ *value, void *ignored)
{
- memset(buffer, *value, length);
+ memset(buffer, *value, length);
}
/**end repeat**/
@@ -2076,11 +2075,11 @@
static void
@NAME at _fillwithscalar(@typ@ *buffer, intp length, @typ@ *value, void *ignored)
{
- register intp i;
- @typ@ val = *value;
- for (i=0; i<length; ++i) {
- buffer[i] = val;
- }
+ register intp i;
+ @typ@ val = *value;
+ for (i=0; i<length; ++i) {
+ buffer[i] = val;
+ }
}
/**end repeat**/
@@ -2098,41 +2097,41 @@
static void
@name at _fastclip(@type@ *in, intp ni, @type@ *min, @type@ *max, @type@ *out)
{
- register npy_intp i;
- @type@ max_val=0, min_val=0;
+ register npy_intp i;
+ @type@ max_val=0, min_val=0;
- if (max != NULL)
- max_val = *max;
- if (min != NULL)
- min_val = *min;
+ if (max != NULL)
+ max_val = *max;
+ if (min != NULL)
+ min_val = *min;
- if (max == NULL) {
- for (i = 0; i < ni; i++) {
- if (in[i] < min_val) {
- out[i] = min_val;
- }
- }
- return;
- }
-
- if (min == NULL) {
- for (i = 0; i < ni; i++) {
- if (in[i] > max_val) {
- out[i] = max_val;
- }
- }
- return;
- }
-
+ if (max == NULL) {
for (i = 0; i < ni; i++) {
- if (in[i] < min_val) {
- out[i] = min_val;
- } else if (in[i] > max_val) {
- out[i] = max_val;
- }
+ if (in[i] < min_val) {
+ out[i] = min_val;
+ }
}
+ return;
+ }
+ if (min == NULL) {
+ for (i = 0; i < ni; i++) {
+ if (in[i] > max_val) {
+ out[i] = max_val;
+ }
+ }
return;
+ }
+
+ for (i = 0; i < ni; i++) {
+ if (in[i] < min_val) {
+ out[i] = min_val;
+ } else if (in[i] > max_val) {
+ out[i] = max_val;
+ }
+ }
+
+ return;
}
/**end repeat**/
@@ -2143,43 +2142,43 @@
static void
@name at _fastclip(@type@ *in, intp ni, @type@ *min, @type@ *max, @type@ *out)
{
- register npy_intp i;
- @type@ max_val, min_val;
-
- min_val = *min;
- max_val = *max;
+ register npy_intp i;
+ @type@ max_val, min_val;
- if (max != NULL)
- max_val = *max;
- if (min != NULL)
- min_val = *min;
+ min_val = *min;
+ max_val = *max;
- if (max == NULL) {
- for (i = 0; i < ni; i++) {
- if (PyArray_CLT(in[i],min_val)) {
- out[i] = min_val;
- }
- }
- return;
- }
+ if (max != NULL)
+ max_val = *max;
+ if (min != NULL)
+ min_val = *min;
- if (min == NULL) {
- for (i = 0; i < ni; i++) {
- if (PyArray_CGT(in[i], max_val)) {
- out[i] = max_val;
- }
- }
- return;
- }
+ if (max == NULL) {
+ for (i = 0; i < ni; i++) {
+ if (PyArray_CLT(in[i],min_val)) {
+ out[i] = min_val;
+ }
+ }
+ return;
+ }
+ if (min == NULL) {
for (i = 0; i < ni; i++) {
- if (PyArray_CLT(in[i], min_val)) {
- out[i] = min_val;
- } else if (PyArray_CGT(in[i], max_val)) {
- out[i] = max_val;
- }
+ if (PyArray_CGT(in[i], max_val)) {
+ out[i] = max_val;
+ }
}
return;
+ }
+
+ for (i = 0; i < ni; i++) {
+ if (PyArray_CLT(in[i], min_val)) {
+ out[i] = min_val;
+ } else if (PyArray_CGT(in[i], max_val)) {
+ out[i] = max_val;
+ }
+ }
+ return;
}
/**end repeat**/
@@ -2197,25 +2196,25 @@
static void
@name at _fastputmask(@type@ *in, Bool *mask, intp ni, @type@ *vals, intp nv)
{
- register npy_intp i;
- @type@ s_val;
+ register npy_intp i;
+ @type@ s_val;
- if (nv == 1) {
- s_val = *vals;
- for (i = 0; i < ni; i++) {
- if (mask[i]) {
- in[i] = s_val;
- }
- }
+ if (nv == 1) {
+ s_val = *vals;
+ for (i = 0; i < ni; i++) {
+ if (mask[i]) {
+ in[i] = s_val;
+ }
}
- else {
- for (i = 0; i < ni; i++) {
- if (mask[i]) {
- in[i] = vals[i%nv];
- }
- }
+ }
+ else {
+ for (i = 0; i < ni; i++) {
+ if (mask[i]) {
+ in[i] = vals[i%nv];
+ }
}
- return;
+ }
+ return;
}
/**end repeat**/
@@ -2241,67 +2240,67 @@
*/
static PyArray_ArrFuncs _Py at NAME@_ArrFuncs = {
- {
- (PyArray_VectorUnaryFunc*)@from at _to_BOOL,
- (PyArray_VectorUnaryFunc*)@from at _to_BYTE,
- (PyArray_VectorUnaryFunc*)@from at _to_UBYTE,
- (PyArray_VectorUnaryFunc*)@from at _to_SHORT,
- (PyArray_VectorUnaryFunc*)@from at _to_USHORT,
- (PyArray_VectorUnaryFunc*)@from at _to_INT,
- (PyArray_VectorUnaryFunc*)@from at _to_UINT,
- (PyArray_VectorUnaryFunc*)@from at _to_LONG,
- (PyArray_VectorUnaryFunc*)@from at _to_ULONG,
- (PyArray_VectorUnaryFunc*)@from at _to_LONGLONG,
- (PyArray_VectorUnaryFunc*)@from at _to_ULONGLONG,
- (PyArray_VectorUnaryFunc*)@from at _to_FLOAT,
- (PyArray_VectorUnaryFunc*)@from at _to_DOUBLE,
- (PyArray_VectorUnaryFunc*)@from at _to_LONGDOUBLE,
- (PyArray_VectorUnaryFunc*)@from at _to_CFLOAT,
- (PyArray_VectorUnaryFunc*)@from at _to_CDOUBLE,
- (PyArray_VectorUnaryFunc*)@from at _to_CLONGDOUBLE,
- (PyArray_VectorUnaryFunc*)@from at _to_OBJECT,
- (PyArray_VectorUnaryFunc*)@from at _to_STRING,
- (PyArray_VectorUnaryFunc*)@from at _to_UNICODE,
- (PyArray_VectorUnaryFunc*)@from at _to_VOID
- },
- (PyArray_GetItemFunc*)@from at _getitem,
- (PyArray_SetItemFunc*)@from at _setitem,
- (PyArray_CopySwapNFunc*)@from at _copyswapn,
- (PyArray_CopySwapFunc*)@from at _copyswap,
- (PyArray_CompareFunc*)@from at _compare,
- (PyArray_ArgFunc*)@from at _argmax,
- (PyArray_DotFunc*)NULL,
- (PyArray_ScanFunc*)@from at _scan,
- (PyArray_FromStrFunc*)@from at _fromstr,
- (PyArray_NonzeroFunc*)@from at _nonzero,
- (PyArray_FillFunc*)NULL,
- (PyArray_FillWithScalarFunc*)NULL,
- {
- NULL, NULL, NULL
- },
- {
- NULL, NULL, NULL
- },
- NULL,
- (PyArray_ScalarKindFunc*)NULL,
- NULL,
- NULL,
- (PyArray_FastClipFunc *)NULL,
- (PyArray_FastPutmaskFunc *)NULL
+ {
+ (PyArray_VectorUnaryFunc*)@from at _to_BOOL,
+ (PyArray_VectorUnaryFunc*)@from at _to_BYTE,
+ (PyArray_VectorUnaryFunc*)@from at _to_UBYTE,
+ (PyArray_VectorUnaryFunc*)@from at _to_SHORT,
+ (PyArray_VectorUnaryFunc*)@from at _to_USHORT,
+ (PyArray_VectorUnaryFunc*)@from at _to_INT,
+ (PyArray_VectorUnaryFunc*)@from at _to_UINT,
+ (PyArray_VectorUnaryFunc*)@from at _to_LONG,
+ (PyArray_VectorUnaryFunc*)@from at _to_ULONG,
+ (PyArray_VectorUnaryFunc*)@from at _to_LONGLONG,
+ (PyArray_VectorUnaryFunc*)@from at _to_ULONGLONG,
+ (PyArray_VectorUnaryFunc*)@from at _to_FLOAT,
+ (PyArray_VectorUnaryFunc*)@from at _to_DOUBLE,
+ (PyArray_VectorUnaryFunc*)@from at _to_LONGDOUBLE,
+ (PyArray_VectorUnaryFunc*)@from at _to_CFLOAT,
+ (PyArray_VectorUnaryFunc*)@from at _to_CDOUBLE,
+ (PyArray_VectorUnaryFunc*)@from at _to_CLONGDOUBLE,
+ (PyArray_VectorUnaryFunc*)@from at _to_OBJECT,
+ (PyArray_VectorUnaryFunc*)@from at _to_STRING,
+ (PyArray_VectorUnaryFunc*)@from at _to_UNICODE,
+ (PyArray_VectorUnaryFunc*)@from at _to_VOID
+ },
+ (PyArray_GetItemFunc*)@from at _getitem,
+ (PyArray_SetItemFunc*)@from at _setitem,
+ (PyArray_CopySwapNFunc*)@from at _copyswapn,
+ (PyArray_CopySwapFunc*)@from at _copyswap,
+ (PyArray_CompareFunc*)@from at _compare,
+ (PyArray_ArgFunc*)@from at _argmax,
+ (PyArray_DotFunc*)NULL,
+ (PyArray_ScanFunc*)@from at _scan,
+ (PyArray_FromStrFunc*)@from at _fromstr,
+ (PyArray_NonzeroFunc*)@from at _nonzero,
+ (PyArray_FillFunc*)NULL,
+ (PyArray_FillWithScalarFunc*)NULL,
+ {
+ NULL, NULL, NULL
+ },
+ {
+ NULL, NULL, NULL
+ },
+ NULL,
+ (PyArray_ScalarKindFunc*)NULL,
+ NULL,
+ NULL,
+ (PyArray_FastClipFunc *)NULL,
+ (PyArray_FastPutmaskFunc *)NULL
};
static PyArray_Descr @from at _Descr = {
- PyObject_HEAD_INIT(&PyArrayDescr_Type)
+ PyObject_HEAD_INIT(&PyArrayDescr_Type)
&Py at NAME@ArrType_Type,
- PyArray_ at from@LTR,
- PyArray_ at from@LTR,
- '@endian@', 0,
- PyArray_ at from@, 0,
- _ALIGN(@align@),
- NULL,
- NULL,
- NULL,
- &_Py at NAME@_ArrFuncs,
+ PyArray_ at from@LTR,
+ PyArray_ at from@LTR,
+ '@endian@', 0,
+ PyArray_ at from@, 0,
+ _ALIGN(@align@),
+ NULL,
+ NULL,
+ NULL,
+ &_Py at NAME@_ArrFuncs,
};
/**end repeat**/
@@ -2319,68 +2318,68 @@
*/
static PyArray_ArrFuncs _Py at NAME@_ArrFuncs = {
- {
- (PyArray_VectorUnaryFunc*)@from at _to_BOOL,
- (PyArray_VectorUnaryFunc*)@from at _to_BYTE,
- (PyArray_VectorUnaryFunc*)@from at _to_UBYTE,
- (PyArray_VectorUnaryFunc*)@from at _to_SHORT,
- (PyArray_VectorUnaryFunc*)@from at _to_USHORT,
- (PyArray_VectorUnaryFunc*)@from at _to_INT,
- (PyArray_VectorUnaryFunc*)@from at _to_UINT,
- (PyArray_VectorUnaryFunc*)@from at _to_LONG,
- (PyArray_VectorUnaryFunc*)@from at _to_ULONG,
- (PyArray_VectorUnaryFunc*)@from at _to_LONGLONG,
- (PyArray_VectorUnaryFunc*)@from at _to_ULONGLONG,
- (PyArray_VectorUnaryFunc*)@from at _to_FLOAT,
- (PyArray_VectorUnaryFunc*)@from at _to_DOUBLE,
- (PyArray_VectorUnaryFunc*)@from at _to_LONGDOUBLE,
- (PyArray_VectorUnaryFunc*)@from at _to_CFLOAT,
- (PyArray_VectorUnaryFunc*)@from at _to_CDOUBLE,
- (PyArray_VectorUnaryFunc*)@from at _to_CLONGDOUBLE,
- (PyArray_VectorUnaryFunc*)@from at _to_OBJECT,
- (PyArray_VectorUnaryFunc*)@from at _to_STRING,
- (PyArray_VectorUnaryFunc*)@from at _to_UNICODE,
- (PyArray_VectorUnaryFunc*)@from at _to_VOID
- },
- (PyArray_GetItemFunc*)@from at _getitem,
- (PyArray_SetItemFunc*)@from at _setitem,
- (PyArray_CopySwapNFunc*)@from at _copyswapn,
- (PyArray_CopySwapFunc*)@from at _copyswap,
- (PyArray_CompareFunc*)@from at _compare,
- (PyArray_ArgFunc*)@from at _argmax,
- (PyArray_DotFunc*)@from at _dot,
- (PyArray_ScanFunc*)@from at _scan,
- (PyArray_FromStrFunc*)@from at _fromstr,
- (PyArray_NonzeroFunc*)@from at _nonzero,
- (PyArray_FillFunc*)@from at _fill,
- (PyArray_FillWithScalarFunc*)@from at _fillwithscalar,
- {
- NULL, NULL, NULL
- },
- {
- NULL, NULL, NULL
- },
- NULL,
- (PyArray_ScalarKindFunc*)NULL,
- NULL,
- NULL,
- (PyArray_FastClipFunc*)@from at _fastclip,
- (PyArray_FastPutmaskFunc*)@from at _fastputmask
+ {
+ (PyArray_VectorUnaryFunc*)@from at _to_BOOL,
+ (PyArray_VectorUnaryFunc*)@from at _to_BYTE,
+ (PyArray_VectorUnaryFunc*)@from at _to_UBYTE,
+ (PyArray_VectorUnaryFunc*)@from at _to_SHORT,
+ (PyArray_VectorUnaryFunc*)@from at _to_USHORT,
+ (PyArray_VectorUnaryFunc*)@from at _to_INT,
+ (PyArray_VectorUnaryFunc*)@from at _to_UINT,
+ (PyArray_VectorUnaryFunc*)@from at _to_LONG,
+ (PyArray_VectorUnaryFunc*)@from at _to_ULONG,
+ (PyArray_VectorUnaryFunc*)@from at _to_LONGLONG,
+ (PyArray_VectorUnaryFunc*)@from at _to_ULONGLONG,
+ (PyArray_VectorUnaryFunc*)@from at _to_FLOAT,
+ (PyArray_VectorUnaryFunc*)@from at _to_DOUBLE,
+ (PyArray_VectorUnaryFunc*)@from at _to_LONGDOUBLE,
+ (PyArray_VectorUnaryFunc*)@from at _to_CFLOAT,
+ (PyArray_VectorUnaryFunc*)@from at _to_CDOUBLE,
+ (PyArray_VectorUnaryFunc*)@from at _to_CLONGDOUBLE,
+ (PyArray_VectorUnaryFunc*)@from at _to_OBJECT,
+ (PyArray_VectorUnaryFunc*)@from at _to_STRING,
+ (PyArray_VectorUnaryFunc*)@from at _to_UNICODE,
+ (PyArray_VectorUnaryFunc*)@from at _to_VOID
+ },
+ (PyArray_GetItemFunc*)@from at _getitem,
+ (PyArray_SetItemFunc*)@from at _setitem,
+ (PyArray_CopySwapNFunc*)@from at _copyswapn,
+ (PyArray_CopySwapFunc*)@from at _copyswap,
+ (PyArray_CompareFunc*)@from at _compare,
+ (PyArray_ArgFunc*)@from at _argmax,
+ (PyArray_DotFunc*)@from at _dot,
+ (PyArray_ScanFunc*)@from at _scan,
+ (PyArray_FromStrFunc*)@from at _fromstr,
+ (PyArray_NonzeroFunc*)@from at _nonzero,
+ (PyArray_FillFunc*)@from at _fill,
+ (PyArray_FillWithScalarFunc*)@from at _fillwithscalar,
+ {
+ NULL, NULL, NULL
+ },
+ {
+ NULL, NULL, NULL
+ },
+ NULL,
+ (PyArray_ScalarKindFunc*)NULL,
+ NULL,
+ NULL,
+ (PyArray_FastClipFunc*)@from at _fastclip,
+ (PyArray_FastPutmaskFunc*)@from at _fastputmask
};
static PyArray_Descr @from at _Descr = {
- PyObject_HEAD_INIT(&PyArrayDescr_Type)
+ PyObject_HEAD_INIT(&PyArrayDescr_Type)
&Py at NAME@ArrType_Type,
- PyArray_ at kind@LTR,
- PyArray_ at from@LTR,
- '@endian@', @isobject@,
- PyArray_ at from@,
- @num@*sizeof(@fromtyp@),
- _ALIGN(@fromtyp@),
- NULL,
- NULL,
- NULL,
- &_Py at NAME@_ArrFuncs,
+ PyArray_ at kind@LTR,
+ PyArray_ at from@LTR,
+ '@endian@', @isobject@,
+ PyArray_ at from@,
+ @num@*sizeof(@fromtyp@),
+ _ALIGN(@fromtyp@),
+ NULL,
+ NULL,
+ NULL,
+ &_Py at NAME@_ArrFuncs,
};
/**end repeat**/
@@ -2389,27 +2388,27 @@
static char _letter_to_num[_MAX_LETTER];
static PyArray_Descr *_builtin_descrs[] = {
- &BOOL_Descr,
- &BYTE_Descr,
- &UBYTE_Descr,
- &SHORT_Descr,
- &USHORT_Descr,
- &INT_Descr,
- &UINT_Descr,
- &LONG_Descr,
- &ULONG_Descr,
- &LONGLONG_Descr,
- &ULONGLONG_Descr,
- &FLOAT_Descr,
- &DOUBLE_Descr,
- &LONGDOUBLE_Descr,
- &CFLOAT_Descr,
- &CDOUBLE_Descr,
- &CLONGDOUBLE_Descr,
- &OBJECT_Descr,
- &STRING_Descr,
- &UNICODE_Descr,
- &VOID_Descr,
+ &BOOL_Descr,
+ &BYTE_Descr,
+ &UBYTE_Descr,
+ &SHORT_Descr,
+ &USHORT_Descr,
+ &INT_Descr,
+ &UINT_Descr,
+ &LONG_Descr,
+ &ULONG_Descr,
+ &LONGLONG_Descr,
+ &ULONGLONG_Descr,
+ &FLOAT_Descr,
+ &DOUBLE_Descr,
+ &LONGDOUBLE_Descr,
+ &CFLOAT_Descr,
+ &CDOUBLE_Descr,
+ &CLONGDOUBLE_Descr,
+ &OBJECT_Descr,
+ &STRING_Descr,
+ &UNICODE_Descr,
+ &VOID_Descr,
};
/*OBJECT_API
@@ -2418,72 +2417,72 @@
static PyArray_Descr *
PyArray_DescrFromType(int type)
{
- PyArray_Descr *ret=NULL;
+ PyArray_Descr *ret=NULL;
- if (type < PyArray_NTYPES) {
- ret = _builtin_descrs[type];
- }
- else if (type == PyArray_NOTYPE) {
- /* This needs to not raise an error so
- that PyArray_DescrFromType(PyArray_NOTYPE)
- works for backwards-compatible C-API
- */
- return NULL;
- }
- else if ((type == PyArray_CHAR) || \
- (type == PyArray_CHARLTR)) {
- ret = PyArray_DescrNew(_builtin_descrs[PyArray_STRING]);
- ret->elsize = 1;
- ret->type = PyArray_CHARLTR;
- return ret;
- }
- else if PyTypeNum_ISUSERDEF(type) {
- ret = userdescrs[type-PyArray_USERDEF];
- }
- else {
- int num=PyArray_NTYPES;
- if (type < _MAX_LETTER)
- num = (int) _letter_to_num[type];
- if (num >= PyArray_NTYPES)
- ret = NULL;
- else
- ret = _builtin_descrs[num];
- }
- if (ret==NULL) {
- PyErr_SetString(PyExc_ValueError,
- "Invalid data-type for array");
- }
- else Py_INCREF(ret);
+ if (type < PyArray_NTYPES) {
+ ret = _builtin_descrs[type];
+ }
+ else if (type == PyArray_NOTYPE) {
+ /* This needs to not raise an error so
+ that PyArray_DescrFromType(PyArray_NOTYPE)
+ works for backwards-compatible C-API
+ */
+ return NULL;
+ }
+ else if ((type == PyArray_CHAR) || \
+ (type == PyArray_CHARLTR)) {
+ ret = PyArray_DescrNew(_builtin_descrs[PyArray_STRING]);
+ ret->elsize = 1;
+ ret->type = PyArray_CHARLTR;
return ret;
+ }
+ else if PyTypeNum_ISUSERDEF(type) {
+ ret = userdescrs[type-PyArray_USERDEF];
+ }
+ else {
+ int num=PyArray_NTYPES;
+ if (type < _MAX_LETTER)
+ num = (int) _letter_to_num[type];
+ if (num >= PyArray_NTYPES)
+ ret = NULL;
+ else
+ ret = _builtin_descrs[num];
+ }
+ if (ret==NULL) {
+ PyErr_SetString(PyExc_ValueError,
+ "Invalid data-type for array");
+ }
+ else Py_INCREF(ret);
+ return ret;
}
static int
set_typeinfo(PyObject *dict)
{
- PyObject *infodict, *s;
- int i;
+ PyObject *infodict, *s;
+ int i;
- for (i=0; i<_MAX_LETTER; i++) {
- _letter_to_num[i] = PyArray_NTYPES;
- }
+ for (i=0; i<_MAX_LETTER; i++) {
+ _letter_to_num[i] = PyArray_NTYPES;
+ }
/**begin repeat
#name=BOOL,BYTE,UBYTE,SHORT,USHORT,INT,UINT,INTP,UINTP,LONG,ULONG,LONGLONG,ULONGLONG,FLOAT,DOUBLE,LONGDOUBLE,CFLOAT,CDOUBLE,CLONGDOUBLE,OBJECT,STRING,UNICODE,VOID#
*/
- _letter_to_num[PyArray_ at name@LTR] = PyArray_ at name@;
+ _letter_to_num[PyArray_ at name@LTR] = PyArray_ at name@;
/**end repeat**/
- _letter_to_num[PyArray_STRINGLTR2] = PyArray_STRING;
+ _letter_to_num[PyArray_STRINGLTR2] = PyArray_STRING;
/**begin repeat
#name=BOOL,BYTE,UBYTE,SHORT,USHORT,INT,UINT,LONG,ULONG,LONGLONG,ULONGLONG,FLOAT,DOUBLE,LONGDOUBLE,CFLOAT,CDOUBLE,CLONGDOUBLE,OBJECT,STRING,UNICODE,VOID#
*/
- @name at _Descr.fields = Py_None;
+ @name at _Descr.fields = Py_None;
/**end repeat**/
- /* Set a dictionary with type information */
- infodict = PyDict_New();
- if (infodict == NULL) return -1;
+ /* Set a dictionary with type information */
+ infodict = PyDict_New();
+ if (infodict == NULL) return -1;
#define BITSOF_INTP CHAR_BIT*SIZEOF_PY_INTPTR_T
#define BITSOF_BYTE CHAR_BIT
@@ -2499,15 +2498,15 @@
#cx=i*6,N,N,N,l,N,N,N#
#cn=i*7,N,i,l,i,N,i#
*/
- PyDict_SetItemString(infodict, "@name@",
- s=Py_BuildValue("ciii at cx@@cn at O",
- PyArray_ at name@LTR,
- PyArray_ at name@,
- BITSOF_ at uname@,
- _ALIGN(@type@),
- @max@, @min@,
- (PyObject *)&Py at Name@ArrType_Type));
- Py_DECREF(s);
+ PyDict_SetItemString(infodict, "@name@",
+ s=Py_BuildValue("ciii at cx@@cn at O",
+ PyArray_ at name@LTR,
+ PyArray_ at name@,
+ BITSOF_ at uname@,
+ _ALIGN(@type@),
+ @max@, @min@,
+ (PyObject *)&Py at Name@ArrType_Type));
+ Py_DECREF(s);
/**end repeat**/
#define BITSOF_CFLOAT 2*BITSOF_FLOAT
@@ -2520,51 +2519,51 @@
#name=FLOAT, DOUBLE, LONGDOUBLE, CFLOAT, CDOUBLE, CLONGDOUBLE#
#Name=Float,Double,LongDouble,CFloat,CDouble,CLongDouble#
*/
- PyDict_SetItemString(infodict, "@name@",
- s=Py_BuildValue("ciiiO", PyArray_ at name@LTR,
- PyArray_ at name@, BITSOF_ at name@,
- _ALIGN(@type@),
- (PyObject *)\
- &Py at Name@ArrType_Type));
- Py_DECREF(s);
-/**end repeat**/
+ PyDict_SetItemString(infodict, "@name@",
+ s=Py_BuildValue("ciiiO", PyArray_ at name@LTR,
+ PyArray_ at name@, BITSOF_ at name@,
+ _ALIGN(@type@),
+ (PyObject *)\
+ &Py at Name@ArrType_Type));
+ Py_DECREF(s);
+ /**end repeat**/
- PyDict_SetItemString(infodict, "OBJECT",
- s=Py_BuildValue("ciiiO", PyArray_OBJECTLTR,
- PyArray_OBJECT,
- sizeof(PyObject *)*CHAR_BIT,
- _ALIGN(PyObject *),
- (PyObject *)\
- &PyObjectArrType_Type));
- Py_DECREF(s);
- PyDict_SetItemString(infodict, "STRING",
- s=Py_BuildValue("ciiiO", PyArray_STRINGLTR,
- PyArray_STRING, 0,
- _ALIGN(char),
- (PyObject *)\
- &PyStringArrType_Type));
- Py_DECREF(s);
- PyDict_SetItemString(infodict, "UNICODE",
- s=Py_BuildValue("ciiiO", PyArray_UNICODELTR,
- PyArray_UNICODE, 0,
- _ALIGN(PyArray_UCS4),
- (PyObject *)\
- &PyUnicodeArrType_Type));
- Py_DECREF(s);
- PyDict_SetItemString(infodict, "VOID",
- s=Py_BuildValue("ciiiO", PyArray_VOIDLTR,
- PyArray_VOID, 0,
- _ALIGN(char),
- (PyObject *)\
- &PyVoidArrType_Type));
- Py_DECREF(s);
+ PyDict_SetItemString(infodict, "OBJECT",
+ s=Py_BuildValue("ciiiO", PyArray_OBJECTLTR,
+ PyArray_OBJECT,
+ sizeof(PyObject *)*CHAR_BIT,
+ _ALIGN(PyObject *),
+ (PyObject *)\
+ &PyObjectArrType_Type));
+ Py_DECREF(s);
+ PyDict_SetItemString(infodict, "STRING",
+ s=Py_BuildValue("ciiiO", PyArray_STRINGLTR,
+ PyArray_STRING, 0,
+ _ALIGN(char),
+ (PyObject *)\
+ &PyStringArrType_Type));
+ Py_DECREF(s);
+ PyDict_SetItemString(infodict, "UNICODE",
+ s=Py_BuildValue("ciiiO", PyArray_UNICODELTR,
+ PyArray_UNICODE, 0,
+ _ALIGN(PyArray_UCS4),
+ (PyObject *)\
+ &PyUnicodeArrType_Type));
+ Py_DECREF(s);
+ PyDict_SetItemString(infodict, "VOID",
+ s=Py_BuildValue("ciiiO", PyArray_VOIDLTR,
+ PyArray_VOID, 0,
+ _ALIGN(char),
+ (PyObject *)\
+ &PyVoidArrType_Type));
+ Py_DECREF(s);
#define SETTYPE(name) \
- Py_INCREF(&Py##name##ArrType_Type); \
- PyDict_SetItemString(infodict, #name, \
- (PyObject *)&Py##name##ArrType_Type);
+ Py_INCREF(&Py##name##ArrType_Type); \
+ PyDict_SetItemString(infodict, #name, \
+ (PyObject *)&Py##name##ArrType_Type);
- SETTYPE(Generic)
+ SETTYPE(Generic)
SETTYPE(Number)
SETTYPE(Integer)
SETTYPE(Inexact)
@@ -2578,8 +2577,8 @@
#undef SETTYPE
PyDict_SetItemString(dict, "typeinfo", infodict);
- Py_DECREF(infodict);
- return 0;
+ Py_DECREF(infodict);
+ return 0;
}
#undef _MAX_LETTER
More information about the Numpy-svn
mailing list