diff options
Diffstat (limited to 'numpy/numarray/numpy_numarray')
-rw-r--r-- | numpy/numarray/numpy_numarray/arraybase.h | 61 | ||||
-rw-r--r-- | numpy/numarray/numpy_numarray/cfunc.h | 78 | ||||
-rw-r--r-- | numpy/numarray/numpy_numarray/ieeespecial.h | 124 | ||||
-rw-r--r-- | numpy/numarray/numpy_numarray/libnumarray.h | 611 | ||||
-rw-r--r-- | numpy/numarray/numpy_numarray/numcomplex.h | 252 | ||||
-rw-r--r-- | numpy/numarray/numpy_numarray/nummacro.h | 449 |
6 files changed, 0 insertions, 1575 deletions
diff --git a/numpy/numarray/numpy_numarray/arraybase.h b/numpy/numarray/numpy_numarray/arraybase.h deleted file mode 100644 index 6461d80fc..000000000 --- a/numpy/numarray/numpy_numarray/arraybase.h +++ /dev/null @@ -1,61 +0,0 @@ -#if !defined(__arraybase_h) -#define _arraybase_h 1 - -#define SZ_BUF 79 -#define MAXDIM MAX_DIMS -#define MAXARGS 18 - -#define maybelong intp - -typedef enum -{ - tAny=-1, - tBool=PyArray_BOOL, - tInt8=PyArray_INT8, - tUInt8=PyArray_UINT8, - tInt16=PyArray_INT16, - tUInt16=PyArray_UINT16, - tInt32=PyArray_INT32, - tUInt32=PyArray_UINT32, - tInt64=PyArray_INT64, - tUInt64=PyArray_UINT64, - tFloat32=PyArray_FLOAT32, - tFloat64=PyArray_FLOAT64, - tComplex32=PyArray_COMPLEX64, - tComplex64=PyArray_COMPLEX128, - tObject=PyArray_OBJECT, /* placeholder... does nothing */ - tMaxType=PyArray_NTYPES, - tDefault = tFloat64, -#if BITSOF_LONG == 64 - tLong = tInt64, -#else - tLong = tInt32, -#endif -} NumarrayType; - -#define nNumarrayType PyArray_NTYPES - -#define HAS_UINT64 1 - -typedef enum -{ - NUM_LITTLE_ENDIAN=0, - NUM_BIG_ENDIAN = 1 -} NumarrayByteOrder; - -#define Complex64 Complex64_ -typedef struct { Float32 r, i; } Complex32; -typedef struct { Float64 r, i; } Complex64; - -#define WRITABLE WRITEABLE -#define CHECKOVERFLOW 0x800 -#define UPDATEDICT 0x1000 -#define FORTRAN_CONTIGUOUS FORTRAN -#define IS_CARRAY (CONTIGUOUS | ALIGNED) - -#define PyArray(m) ((PyArrayObject *)(m)) -#define PyArray_ISFORTRAN_CONTIGUOUS(m) (((PyArray(m))->flags & FORTRAN_CONTIGUOUS) != 0) -#define PyArray_ISWRITABLE PyArray_ISWRITEABLE - - -#endif diff --git a/numpy/numarray/numpy_numarray/cfunc.h b/numpy/numarray/numpy_numarray/cfunc.h deleted file mode 100644 index b581be08f..000000000 --- a/numpy/numarray/numpy_numarray/cfunc.h +++ /dev/null @@ -1,78 +0,0 @@ -#if !defined(__cfunc__) -#define __cfunc__ 1 - -typedef PyObject *(*CFUNCasPyValue)(void *); -typedef int (*UFUNC)(long, long, long, void **, long*); -/* typedef void (*CFUNC_2ARG)(long, void *, void *); */ -/* typedef void (*CFUNC_3ARG)(long, void *, void *, void *); */ -typedef int (*CFUNCfromPyValue)(PyObject *, void *); -typedef int (*CFUNC_STRIDE_CONV_FUNC)(long, long, maybelong *, - void *, long, maybelong*, void *, long, maybelong *); - -typedef int (*CFUNC_STRIDED_FUNC)(PyObject *, long, PyArrayObject **, - char **data); - -#define MAXARRAYS 16 - -typedef enum { - CFUNC_UFUNC, - CFUNC_STRIDING, - CFUNC_NSTRIDING, - CFUNC_AS_PY_VALUE, - CFUNC_FROM_PY_VALUE -} eCfuncType; - -typedef struct { - char *name; - void *fptr; /* Pointer to "un-wrapped" c function */ - eCfuncType type; /* UFUNC, STRIDING, AsPyValue, FromPyValue */ - Bool chkself; /* CFUNC does own alignment/bounds checking */ - Bool align; /* CFUNC requires aligned buffer pointers */ - Int8 wantIn, wantOut; /* required input/output arg counts. */ - Int8 sizes[MAXARRAYS]; /* array of align/itemsizes. */ - Int8 iters[MAXARRAYS]; /* array of element counts. 0 --> niter. */ -} CfuncDescriptor; - -typedef struct { - PyObject_HEAD - CfuncDescriptor descr; -} CfuncObject; - -#define SELF_CHECKED_CFUNC_DESCR(name, type) \ - static CfuncDescriptor name##_descr = { #name, (void *) name, type, 1 } - -#define CHECK_ALIGN 1 - -#define CFUNC_DESCR(name, type, align, iargs, oargs, s1, s2, s3, i1, i2, i3) \ - static CfuncDescriptor name##_descr = \ - { #name, (void *)name, type, 0, align, iargs, oargs, {s1, s2, s3}, {i1, i2, i3} } - -#define UFUNC_DESCR1(name, s1) \ - CFUNC_DESCR(name, CFUNC_UFUNC, CHECK_ALIGN, 0, 1, s1, 0, 0, 0, 0, 0) - -#define UFUNC_DESCR2(name, s1, s2) \ - CFUNC_DESCR(name, CFUNC_UFUNC, CHECK_ALIGN, 1, 1, s1, s2, 0, 0, 0, 0) - -#define UFUNC_DESCR3(name, s1, s2, s3) \ - CFUNC_DESCR(name, CFUNC_UFUNC, CHECK_ALIGN, 2, 1, s1, s2, s3, 0, 0, 0) - -#define UFUNC_DESCR3sv(name, s1, s2, s3) \ - CFUNC_DESCR(name, CFUNC_UFUNC, CHECK_ALIGN, 2, 1, s1, s2, s3, 1, 0, 0) - -#define UFUNC_DESCR3vs(name, s1, s2, s3) \ - CFUNC_DESCR(name, CFUNC_UFUNC, CHECK_ALIGN, 2, 1, s1, s2, s3, 0, 1, 0) - -#define STRIDING_DESCR2(name, align, s1, s2) \ - CFUNC_DESCR(name, CFUNC_STRIDING, align, 1, 1, s1, s2, 0, 0, 0, 0) - -#define NSTRIDING_DESCR1(name) \ - CFUNC_DESCR(name, CFUNC_NSTRIDING, 0, 0, 1, 0, 0, 0, 0, 0, 0) - -#define NSTRIDING_DESCR2(name) \ - CFUNC_DESCR(name, CFUNC_NSTRIDING, 0, 1, 1, 0, 0, 0, 0, 0, 0) - -#define NSTRIDING_DESCR3(name) \ - CFUNC_DESCR(name, CFUNC_NSTRIDING, 0, 2, 1, 0, 0, 0, 0, 0, 0) - -#endif - diff --git a/numpy/numarray/numpy_numarray/ieeespecial.h b/numpy/numarray/numpy_numarray/ieeespecial.h deleted file mode 100644 index 0f3fff2a9..000000000 --- a/numpy/numarray/numpy_numarray/ieeespecial.h +++ /dev/null @@ -1,124 +0,0 @@ -/* 32-bit special value ranges */ - -#if defined(_MSC_VER) -#define MKINT(x) (x##UL) -#define MKINT64(x) (x##Ui64) -#define BIT(x) (1Ui64 << (x)) -#else -#define MKINT(x) (x##U) -#define MKINT64(x) (x##ULL) -#define BIT(x) (1ULL << (x)) -#endif - - -#define NEG_QUIET_NAN_MIN32 MKINT(0xFFC00001) -#define NEG_QUIET_NAN_MAX32 MKINT(0xFFFFFFFF) - -#define INDETERMINATE_MIN32 MKINT(0xFFC00000) -#define INDETERMINATE_MAX32 MKINT(0xFFC00000) - -#define NEG_SIGNAL_NAN_MIN32 MKINT(0xFF800001) -#define NEG_SIGNAL_NAN_MAX32 MKINT(0xFFBFFFFF) - -#define NEG_INFINITY_MIN32 MKINT(0xFF800000) - -#define NEG_NORMALIZED_MIN32 MKINT(0x80800000) -#define NEG_NORMALIZED_MAX32 MKINT(0xFF7FFFFF) - -#define NEG_DENORMALIZED_MIN32 MKINT(0x80000001) -#define NEG_DENORMALIZED_MAX32 MKINT(0x807FFFFF) - -#define NEG_ZERO_MIN32 MKINT(0x80000000) -#define NEG_ZERO_MAX32 MKINT(0x80000000) - -#define POS_ZERO_MIN32 MKINT(0x00000000) -#define POS_ZERO_MAX32 MKINT(0x00000000) - -#define POS_DENORMALIZED_MIN32 MKINT(0x00000001) -#define POS_DENORMALIZED_MAX32 MKINT(0x007FFFFF) - -#define POS_NORMALIZED_MIN32 MKINT(0x00800000) -#define POS_NORMALIZED_MAX32 MKINT(0x7F7FFFFF) - -#define POS_INFINITY_MIN32 MKINT(0x7F800000) -#define POS_INFINITY_MAX32 MKINT(0x7F800000) - -#define POS_SIGNAL_NAN_MIN32 MKINT(0x7F800001) -#define POS_SIGNAL_NAN_MAX32 MKINT(0x7FBFFFFF) - -#define POS_QUIET_NAN_MIN32 MKINT(0x7FC00000) -#define POS_QUIET_NAN_MAX32 MKINT(0x7FFFFFFF) - -/* 64-bit special value ranges */ - -#define NEG_QUIET_NAN_MIN64 MKINT64(0xFFF8000000000001) -#define NEG_QUIET_NAN_MAX64 MKINT64(0xFFFFFFFFFFFFFFFF) - -#define INDETERMINATE_MIN64 MKINT64(0xFFF8000000000000) -#define INDETERMINATE_MAX64 MKINT64(0xFFF8000000000000) - -#define NEG_SIGNAL_NAN_MIN64 MKINT64(0xFFF7FFFFFFFFFFFF) -#define NEG_SIGNAL_NAN_MAX64 MKINT64(0xFFF0000000000001) - -#define NEG_INFINITY_MIN64 MKINT64(0xFFF0000000000000) - -#define NEG_NORMALIZED_MIN64 MKINT64(0xFFEFFFFFFFFFFFFF) -#define NEG_NORMALIZED_MAX64 MKINT64(0x8010000000000000) - -#define NEG_DENORMALIZED_MIN64 MKINT64(0x800FFFFFFFFFFFFF) -#define NEG_DENORMALIZED_MAX64 MKINT64(0x8000000000000001) - -#define NEG_ZERO_MIN64 MKINT64(0x8000000000000000) -#define NEG_ZERO_MAX64 MKINT64(0x8000000000000000) - -#define POS_ZERO_MIN64 MKINT64(0x0000000000000000) -#define POS_ZERO_MAX64 MKINT64(0x0000000000000000) - -#define POS_DENORMALIZED_MIN64 MKINT64(0x0000000000000001) -#define POS_DENORMALIZED_MAX64 MKINT64(0x000FFFFFFFFFFFFF) - -#define POS_NORMALIZED_MIN64 MKINT64(0x0010000000000000) -#define POS_NORMALIZED_MAX64 MKINT64(0x7FEFFFFFFFFFFFFF) - -#define POS_INFINITY_MIN64 MKINT64(0x7FF0000000000000) -#define POS_INFINITY_MAX64 MKINT64(0x7FF0000000000000) - -#define POS_SIGNAL_NAN_MIN64 MKINT64(0x7FF0000000000001) -#define POS_SIGNAL_NAN_MAX64 MKINT64(0x7FF7FFFFFFFFFFFF) - -#define POS_QUIET_NAN_MIN64 MKINT64(0x7FF8000000000000) -#define POS_QUIET_NAN_MAX64 MKINT64(0x7FFFFFFFFFFFFFFF) - -typedef enum -{ - POS_QNAN_BIT, - NEG_QNAN_BIT, - POS_SNAN_BIT, - NEG_SNAN_BIT, - POS_INF_BIT, - NEG_INF_BIT, - POS_DEN_BIT, - NEG_DEN_BIT, - POS_NOR_BIT, - NEG_NOR_BIT, - POS_ZERO_BIT, - NEG_ZERO_BIT, - INDETERM_BIT, - BUG_BIT -} ieee_selects; - -#define MSK_POS_QNAN BIT(POS_QNAN_BIT) -#define MSK_POS_SNAN BIT(POS_SNAN_BIT) -#define MSK_POS_INF BIT(POS_INF_BIT) -#define MSK_POS_DEN BIT(POS_DEN_BIT) -#define MSK_POS_NOR BIT(POS_NOR_BIT) -#define MSK_POS_ZERO BIT(POS_ZERO_BIT) -#define MSK_NEG_QNAN BIT(NEG_QNAN_BIT) -#define MSK_NEG_SNAN BIT(NEG_SNAN_BIT) -#define MSK_NEG_INF BIT(NEG_INF_BIT) -#define MSK_NEG_DEN BIT(NEG_DEN_BIT) -#define MSK_NEG_NOR BIT(NEG_NOR_BIT) -#define MSK_NEG_ZERO BIT(NEG_ZERO_BIT) -#define MSK_INDETERM BIT(INDETERM_BIT) -#define MSK_BUG BIT(BUG_BIT) - diff --git a/numpy/numarray/numpy_numarray/libnumarray.h b/numpy/numarray/numpy_numarray/libnumarray.h deleted file mode 100644 index 3d838c061..000000000 --- a/numpy/numarray/numpy_numarray/libnumarray.h +++ /dev/null @@ -1,611 +0,0 @@ -/* Compatibility with numarray. Do not use in new code. - */ - -#ifndef NUMPY_LIBNUMARRAY_H -#define NUMPY_LIBNUMARRAY_H - -#include "numpy/arrayobject.h" -#include "arraybase.h" -#include "nummacro.h" -#include "numcomplex.h" -#include "ieeespecial.h" -#include "cfunc.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/* Header file for libnumarray */ - -#if !defined(_libnumarray_MODULE) - -/* -Extensions constructed from seperate compilation units can access the -C-API defined here by defining "libnumarray_UNIQUE_SYMBOL" to a global -name unique to the extension. Doing this circumvents the requirement -to import libnumarray into each compilation unit, but is nevertheless -mildly discouraged as "outside the Python norm" and potentially -leading to problems. Looking around at "existing Python art", most -extension modules are monolithic C files, and likely for good reason. -*/ - -/* C API address pointer */ -#if defined(NO_IMPORT) || defined(NO_IMPORT_ARRAY) -extern void **libnumarray_API; -#else -#if defined(libnumarray_UNIQUE_SYMBOL) -void **libnumarray_API; -#else -static void **libnumarray_API; -#endif -#endif - -#define _import_libnumarray() \ - { \ - PyObject *module = PyImport_ImportModule("numpy.numarray._capi"); \ - if (module != NULL) { \ - PyObject *module_dict = PyModule_GetDict(module); \ - PyObject *c_api_object = \ - PyDict_GetItemString(module_dict, "_C_API"); \ - if (c_api_object && PyCObject_Check(c_api_object)) { \ - libnumarray_API = (void **)PyCObject_AsVoidPtr(c_api_object); \ - } else { \ - PyErr_Format(PyExc_ImportError, \ - "Can't get API for module 'numpy.numarray._capi'"); \ - } \ - } \ - } - -#define import_libnumarray() _import_libnumarray(); if (PyErr_Occurred()) { PyErr_Print(); Py_FatalError("numpy.numarray._capi failed to import... exiting.\n"); } - -#endif - - -#define libnumarray_FatalApiError (Py_FatalError("Call to API function without first calling import_libnumarray() in " __FILE__), NULL) - - -/* Macros defining components of function prototypes */ - -#ifdef _libnumarray_MODULE - /* This section is used when compiling libnumarray */ - -static PyObject *_Error; - -static PyObject* getBuffer (PyObject*o); - -static int isBuffer (PyObject*o); - -static int getWriteBufferDataPtr (PyObject*o,void**p); - -static int isBufferWriteable (PyObject*o); - -static int getReadBufferDataPtr (PyObject*o,void**p); - -static int getBufferSize (PyObject*o); - -static double num_log (double x); - -static double num_log10 (double x); - -static double num_pow (double x, double y); - -static double num_acosh (double x); - -static double num_asinh (double x); - -static double num_atanh (double x); - -static double num_round (double x); - -static int int_dividebyzero_error (long value, long unused); - -static int int_overflow_error (Float64 value); - -static int umult64_overflow (UInt64 a, UInt64 b); - -static int smult64_overflow (Int64 a0, Int64 b0); - -static void NA_Done (void); - -static PyArrayObject* NA_NewAll (int ndim, maybelong* shape, NumarrayType type, void* buffer, maybelong byteoffset, maybelong bytestride, int byteorder, int aligned, int writeable); - -static PyArrayObject* NA_NewAllStrides (int ndim, maybelong* shape, maybelong* strides, NumarrayType type, void* buffer, maybelong byteoffset, int byteorder, int aligned, int writeable); - -static PyArrayObject* NA_New (void* buffer, NumarrayType type, int ndim,...); - -static PyArrayObject* NA_Empty (int ndim, maybelong* shape, NumarrayType type); - -static PyArrayObject* NA_NewArray (void* buffer, NumarrayType type, int ndim, ...); - -static PyArrayObject* NA_vNewArray (void* buffer, NumarrayType type, int ndim, maybelong *shape); - -static PyObject* NA_ReturnOutput (PyObject*,PyArrayObject*); - -static long NA_getBufferPtrAndSize (PyObject*,int,void**); - -static int NA_checkIo (char*,int,int,int,int); - -static int NA_checkOneCBuffer (char*,long,void*,long,size_t); - -static int NA_checkNCBuffers (char*,int,long,void**,long*,Int8*,Int8*); - -static int NA_checkOneStriding (char*,long,maybelong*,long,maybelong*,long,long,int); - -static PyObject* NA_new_cfunc (CfuncDescriptor*); - -static int NA_add_cfunc (PyObject*,char*,CfuncDescriptor*); - -static PyArrayObject* NA_InputArray (PyObject*,NumarrayType,int); - -static PyArrayObject* NA_OutputArray (PyObject*,NumarrayType,int); - -static PyArrayObject* NA_IoArray (PyObject*,NumarrayType,int); - -static PyArrayObject* NA_OptionalOutputArray (PyObject*,NumarrayType,int,PyArrayObject*); - -static long NA_get_offset (PyArrayObject*,int,...); - -static Float64 NA_get_Float64 (PyArrayObject*,long); - -static void NA_set_Float64 (PyArrayObject*,long,Float64); - -static Complex64 NA_get_Complex64 (PyArrayObject*,long); - -static void NA_set_Complex64 (PyArrayObject*,long,Complex64); - -static Int64 NA_get_Int64 (PyArrayObject*,long); - -static void NA_set_Int64 (PyArrayObject*,long,Int64); - -static Float64 NA_get1_Float64 (PyArrayObject*,long); - -static Float64 NA_get2_Float64 (PyArrayObject*,long,long); - -static Float64 NA_get3_Float64 (PyArrayObject*,long,long,long); - -static void NA_set1_Float64 (PyArrayObject*,long,Float64); - -static void NA_set2_Float64 (PyArrayObject*,long,long,Float64); - -static void NA_set3_Float64 (PyArrayObject*,long,long,long,Float64); - -static Complex64 NA_get1_Complex64 (PyArrayObject*,long); - -static Complex64 NA_get2_Complex64 (PyArrayObject*,long,long); - -static Complex64 NA_get3_Complex64 (PyArrayObject*,long,long,long); - -static void NA_set1_Complex64 (PyArrayObject*,long,Complex64); - -static void NA_set2_Complex64 (PyArrayObject*,long,long,Complex64); - -static void NA_set3_Complex64 (PyArrayObject*,long,long,long,Complex64); - -static Int64 NA_get1_Int64 (PyArrayObject*,long); - -static Int64 NA_get2_Int64 (PyArrayObject*,long,long); - -static Int64 NA_get3_Int64 (PyArrayObject*,long,long,long); - -static void NA_set1_Int64 (PyArrayObject*,long,Int64); - -static void NA_set2_Int64 (PyArrayObject*,long,long,Int64); - -static void NA_set3_Int64 (PyArrayObject*,long,long,long,Int64); - -static int NA_get1D_Float64 (PyArrayObject*,long,int,Float64*); - -static int NA_set1D_Float64 (PyArrayObject*,long,int,Float64*); - -static int NA_get1D_Int64 (PyArrayObject*,long,int,Int64*); - -static int NA_set1D_Int64 (PyArrayObject*,long,int,Int64*); - -static int NA_get1D_Complex64 (PyArrayObject*,long,int,Complex64*); - -static int NA_set1D_Complex64 (PyArrayObject*,long,int,Complex64*); - -static int NA_ShapeEqual (PyArrayObject*,PyArrayObject*); - -static int NA_ShapeLessThan (PyArrayObject*,PyArrayObject*); - -static int NA_ByteOrder (void); - -static Bool NA_IeeeSpecial32 (Float32*,Int32*); - -static Bool NA_IeeeSpecial64 (Float64*,Int32*); - -static PyArrayObject* NA_updateDataPtr (PyArrayObject*); - -static char* NA_typeNoToName (int); - -static int NA_nameToTypeNo (char*); - -static PyObject* NA_typeNoToTypeObject (int); - -static PyObject* NA_intTupleFromMaybeLongs (int,maybelong*); - -static long NA_maybeLongsFromIntTuple (int,maybelong*,PyObject*); - -static int NA_intTupleProduct (PyObject *obj, long *product); - -static long NA_isIntegerSequence (PyObject*); - -static PyObject* NA_setArrayFromSequence (PyArrayObject*,PyObject*); - -static int NA_maxType (PyObject*); - -static int NA_isPythonScalar (PyObject *obj); - -static PyObject* NA_getPythonScalar (PyArrayObject*,long); - -static int NA_setFromPythonScalar (PyArrayObject*,long,PyObject*); - -static int NA_NDArrayCheck (PyObject*); - -static int NA_NumArrayCheck (PyObject*); - -static int NA_ComplexArrayCheck (PyObject*); - -static unsigned long NA_elements (PyArrayObject*); - -static int NA_typeObjectToTypeNo (PyObject*); - -static int NA_copyArray (PyArrayObject* to, const PyArrayObject* from); - -static PyArrayObject* NA_copy (PyArrayObject*); - -static PyObject* NA_getType (PyObject *typeobj_or_name); - -static PyObject * NA_callCUFuncCore (PyObject *cfunc, long niter, long ninargs, long noutargs, PyObject **BufferObj, long *offset); - -static PyObject * NA_callStrideConvCFuncCore (PyObject *cfunc, int nshape, maybelong *shape, PyObject *inbuffObj, long inboffset, int nstrides0, maybelong *inbstrides, PyObject *outbuffObj, long outboffset, int nstrides1, maybelong *outbstrides, long nbytes); - -static void NA_stridesFromShape (int nshape, maybelong *shape, maybelong bytestride, maybelong *strides); - -static int NA_OperatorCheck (PyObject *obj); - -static int NA_ConverterCheck (PyObject *obj); - -static int NA_UfuncCheck (PyObject *obj); - -static int NA_CfuncCheck (PyObject *obj); - -static int NA_getByteOffset (PyArrayObject *array, int nindices, maybelong *indices, long *offset); - -static int NA_swapAxes (PyArrayObject *array, int x, int y); - -static PyObject * NA_initModuleGlobal (char *module, char *global); - -static NumarrayType NA_NumarrayType (PyObject *seq); - -static PyArrayObject * NA_NewAllFromBuffer (int ndim, maybelong *shape, NumarrayType type, PyObject *bufferObject, maybelong byteoffset, maybelong bytestride, int byteorder, int aligned, int writeable); - -static Float64 * NA_alloc1D_Float64 (PyArrayObject *a, long offset, int cnt); - -static Int64 * NA_alloc1D_Int64 (PyArrayObject *a, long offset, int cnt); - -static void NA_updateAlignment (PyArrayObject *self); - -static void NA_updateContiguous (PyArrayObject *self); - -static void NA_updateStatus (PyArrayObject *self); - -static int NA_NumArrayCheckExact (PyObject *op); - -static int NA_NDArrayCheckExact (PyObject *op); - -static int NA_OperatorCheckExact (PyObject *op); - -static int NA_ConverterCheckExact (PyObject *op); - -static int NA_UfuncCheckExact (PyObject *op); - -static int NA_CfuncCheckExact (PyObject *op); - -static char * NA_getArrayData (PyArrayObject *ap); - -static void NA_updateByteswap (PyArrayObject *ap); - -static PyArray_Descr * NA_DescrFromType (int type); - -static PyObject * NA_Cast (PyArrayObject *a, int type); - -static int NA_checkFPErrors (void); - -static void NA_clearFPErrors (void); - -static int NA_checkAndReportFPErrors (char *name); - -static Bool NA_IeeeMask32 (Float32,Int32); - -static Bool NA_IeeeMask64 (Float64,Int32); - -static int _NA_callStridingHelper (PyObject *aux, long dim, long nnumarray, PyArrayObject *numarray[], char *data[], CFUNC_STRIDED_FUNC f); - -static PyArrayObject * NA_FromDimsStridesDescrAndData (int nd, maybelong *dims, maybelong *strides, PyArray_Descr *descr, char *data); - -static PyArrayObject * NA_FromDimsTypeAndData (int nd, maybelong *dims, int type, char *data); - -static PyArrayObject * NA_FromDimsStridesTypeAndData (int nd, maybelong *dims, maybelong *strides, int type, char *data); - -static int NA_scipy_typestr (NumarrayType t, int byteorder, char *typestr); - -static PyArrayObject * NA_FromArrayStruct (PyObject *a); - - -#else - /* This section is used in modules that use libnumarray */ - -#define getBuffer (libnumarray_API ? (*(PyObject* (*) (PyObject*o) ) libnumarray_API[ 0 ]) : (*(PyObject* (*) (PyObject*o) ) libnumarray_FatalApiError)) - -#define isBuffer (libnumarray_API ? (*(int (*) (PyObject*o) ) libnumarray_API[ 1 ]) : (*(int (*) (PyObject*o) ) libnumarray_FatalApiError)) - -#define getWriteBufferDataPtr (libnumarray_API ? (*(int (*) (PyObject*o,void**p) ) libnumarray_API[ 2 ]) : (*(int (*) (PyObject*o,void**p) ) libnumarray_FatalApiError)) - -#define isBufferWriteable (libnumarray_API ? (*(int (*) (PyObject*o) ) libnumarray_API[ 3 ]) : (*(int (*) (PyObject*o) ) libnumarray_FatalApiError)) - -#define getReadBufferDataPtr (libnumarray_API ? (*(int (*) (PyObject*o,void**p) ) libnumarray_API[ 4 ]) : (*(int (*) (PyObject*o,void**p) ) libnumarray_FatalApiError)) - -#define getBufferSize (libnumarray_API ? (*(int (*) (PyObject*o) ) libnumarray_API[ 5 ]) : (*(int (*) (PyObject*o) ) libnumarray_FatalApiError)) - -#define num_log (libnumarray_API ? (*(double (*) (double x) ) libnumarray_API[ 6 ]) : (*(double (*) (double x) ) libnumarray_FatalApiError)) - -#define num_log10 (libnumarray_API ? (*(double (*) (double x) ) libnumarray_API[ 7 ]) : (*(double (*) (double x) ) libnumarray_FatalApiError)) - -#define num_pow (libnumarray_API ? (*(double (*) (double x, double y) ) libnumarray_API[ 8 ]) : (*(double (*) (double x, double y) ) libnumarray_FatalApiError)) - -#define num_acosh (libnumarray_API ? (*(double (*) (double x) ) libnumarray_API[ 9 ]) : (*(double (*) (double x) ) libnumarray_FatalApiError)) - -#define num_asinh (libnumarray_API ? (*(double (*) (double x) ) libnumarray_API[ 10 ]) : (*(double (*) (double x) ) libnumarray_FatalApiError)) - -#define num_atanh (libnumarray_API ? (*(double (*) (double x) ) libnumarray_API[ 11 ]) : (*(double (*) (double x) ) libnumarray_FatalApiError)) - -#define num_round (libnumarray_API ? (*(double (*) (double x) ) libnumarray_API[ 12 ]) : (*(double (*) (double x) ) libnumarray_FatalApiError)) - -#define int_dividebyzero_error (libnumarray_API ? (*(int (*) (long value, long unused) ) libnumarray_API[ 13 ]) : (*(int (*) (long value, long unused) ) libnumarray_FatalApiError)) - -#define int_overflow_error (libnumarray_API ? (*(int (*) (Float64 value) ) libnumarray_API[ 14 ]) : (*(int (*) (Float64 value) ) libnumarray_FatalApiError)) - -#define umult64_overflow (libnumarray_API ? (*(int (*) (UInt64 a, UInt64 b) ) libnumarray_API[ 15 ]) : (*(int (*) (UInt64 a, UInt64 b) ) libnumarray_FatalApiError)) - -#define smult64_overflow (libnumarray_API ? (*(int (*) (Int64 a0, Int64 b0) ) libnumarray_API[ 16 ]) : (*(int (*) (Int64 a0, Int64 b0) ) libnumarray_FatalApiError)) - -#define NA_Done (libnumarray_API ? (*(void (*) (void) ) libnumarray_API[ 17 ]) : (*(void (*) (void) ) libnumarray_FatalApiError)) - -#define NA_NewAll (libnumarray_API ? (*(PyArrayObject* (*) (int ndim, maybelong* shape, NumarrayType type, void* buffer, maybelong byteoffset, maybelong bytestride, int byteorder, int aligned, int writeable) ) libnumarray_API[ 18 ]) : (*(PyArrayObject* (*) (int ndim, maybelong* shape, NumarrayType type, void* buffer, maybelong byteoffset, maybelong bytestride, int byteorder, int aligned, int writeable) ) libnumarray_FatalApiError)) - -#define NA_NewAllStrides (libnumarray_API ? (*(PyArrayObject* (*) (int ndim, maybelong* shape, maybelong* strides, NumarrayType type, void* buffer, maybelong byteoffset, int byteorder, int aligned, int writeable) ) libnumarray_API[ 19 ]) : (*(PyArrayObject* (*) (int ndim, maybelong* shape, maybelong* strides, NumarrayType type, void* buffer, maybelong byteoffset, int byteorder, int aligned, int writeable) ) libnumarray_FatalApiError)) - -#define NA_New (libnumarray_API ? (*(PyArrayObject* (*) (void* buffer, NumarrayType type, int ndim,...) ) libnumarray_API[ 20 ]) : (*(PyArrayObject* (*) (void* buffer, NumarrayType type, int ndim,...) ) libnumarray_FatalApiError)) - -#define NA_Empty (libnumarray_API ? (*(PyArrayObject* (*) (int ndim, maybelong* shape, NumarrayType type) ) libnumarray_API[ 21 ]) : (*(PyArrayObject* (*) (int ndim, maybelong* shape, NumarrayType type) ) libnumarray_FatalApiError)) - -#define NA_NewArray (libnumarray_API ? (*(PyArrayObject* (*) (void* buffer, NumarrayType type, int ndim, ...) ) libnumarray_API[ 22 ]) : (*(PyArrayObject* (*) (void* buffer, NumarrayType type, int ndim, ...) ) libnumarray_FatalApiError)) - -#define NA_vNewArray (libnumarray_API ? (*(PyArrayObject* (*) (void* buffer, NumarrayType type, int ndim, maybelong *shape) ) libnumarray_API[ 23 ]) : (*(PyArrayObject* (*) (void* buffer, NumarrayType type, int ndim, maybelong *shape) ) libnumarray_FatalApiError)) - -#define NA_ReturnOutput (libnumarray_API ? (*(PyObject* (*) (PyObject*,PyArrayObject*) ) libnumarray_API[ 24 ]) : (*(PyObject* (*) (PyObject*,PyArrayObject*) ) libnumarray_FatalApiError)) - -#define NA_getBufferPtrAndSize (libnumarray_API ? (*(long (*) (PyObject*,int,void**) ) libnumarray_API[ 25 ]) : (*(long (*) (PyObject*,int,void**) ) libnumarray_FatalApiError)) - -#define NA_checkIo (libnumarray_API ? (*(int (*) (char*,int,int,int,int) ) libnumarray_API[ 26 ]) : (*(int (*) (char*,int,int,int,int) ) libnumarray_FatalApiError)) - -#define NA_checkOneCBuffer (libnumarray_API ? (*(int (*) (char*,long,void*,long,size_t) ) libnumarray_API[ 27 ]) : (*(int (*) (char*,long,void*,long,size_t) ) libnumarray_FatalApiError)) - -#define NA_checkNCBuffers (libnumarray_API ? (*(int (*) (char*,int,long,void**,long*,Int8*,Int8*) ) libnumarray_API[ 28 ]) : (*(int (*) (char*,int,long,void**,long*,Int8*,Int8*) ) libnumarray_FatalApiError)) - -#define NA_checkOneStriding (libnumarray_API ? (*(int (*) (char*,long,maybelong*,long,maybelong*,long,long,int) ) libnumarray_API[ 29 ]) : (*(int (*) (char*,long,maybelong*,long,maybelong*,long,long,int) ) libnumarray_FatalApiError)) - -#define NA_new_cfunc (libnumarray_API ? (*(PyObject* (*) (CfuncDescriptor*) ) libnumarray_API[ 30 ]) : (*(PyObject* (*) (CfuncDescriptor*) ) libnumarray_FatalApiError)) - -#define NA_add_cfunc (libnumarray_API ? (*(int (*) (PyObject*,char*,CfuncDescriptor*) ) libnumarray_API[ 31 ]) : (*(int (*) (PyObject*,char*,CfuncDescriptor*) ) libnumarray_FatalApiError)) - -#define NA_InputArray (libnumarray_API ? (*(PyArrayObject* (*) (PyObject*,NumarrayType,int) ) libnumarray_API[ 32 ]) : (*(PyArrayObject* (*) (PyObject*,NumarrayType,int) ) libnumarray_FatalApiError)) - -#define NA_OutputArray (libnumarray_API ? (*(PyArrayObject* (*) (PyObject*,NumarrayType,int) ) libnumarray_API[ 33 ]) : (*(PyArrayObject* (*) (PyObject*,NumarrayType,int) ) libnumarray_FatalApiError)) - -#define NA_IoArray (libnumarray_API ? (*(PyArrayObject* (*) (PyObject*,NumarrayType,int) ) libnumarray_API[ 34 ]) : (*(PyArrayObject* (*) (PyObject*,NumarrayType,int) ) libnumarray_FatalApiError)) - -#define NA_OptionalOutputArray (libnumarray_API ? (*(PyArrayObject* (*) (PyObject*,NumarrayType,int,PyArrayObject*) ) libnumarray_API[ 35 ]) : (*(PyArrayObject* (*) (PyObject*,NumarrayType,int,PyArrayObject*) ) libnumarray_FatalApiError)) - -#define NA_get_offset (libnumarray_API ? (*(long (*) (PyArrayObject*,int,...) ) libnumarray_API[ 36 ]) : (*(long (*) (PyArrayObject*,int,...) ) libnumarray_FatalApiError)) - -#define NA_get_Float64 (libnumarray_API ? (*(Float64 (*) (PyArrayObject*,long) ) libnumarray_API[ 37 ]) : (*(Float64 (*) (PyArrayObject*,long) ) libnumarray_FatalApiError)) - -#define NA_set_Float64 (libnumarray_API ? (*(void (*) (PyArrayObject*,long,Float64) ) libnumarray_API[ 38 ]) : (*(void (*) (PyArrayObject*,long,Float64) ) libnumarray_FatalApiError)) - -#define NA_get_Complex64 (libnumarray_API ? (*(Complex64 (*) (PyArrayObject*,long) ) libnumarray_API[ 39 ]) : (*(Complex64 (*) (PyArrayObject*,long) ) libnumarray_FatalApiError)) - -#define NA_set_Complex64 (libnumarray_API ? (*(void (*) (PyArrayObject*,long,Complex64) ) libnumarray_API[ 40 ]) : (*(void (*) (PyArrayObject*,long,Complex64) ) libnumarray_FatalApiError)) - -#define NA_get_Int64 (libnumarray_API ? (*(Int64 (*) (PyArrayObject*,long) ) libnumarray_API[ 41 ]) : (*(Int64 (*) (PyArrayObject*,long) ) libnumarray_FatalApiError)) - -#define NA_set_Int64 (libnumarray_API ? (*(void (*) (PyArrayObject*,long,Int64) ) libnumarray_API[ 42 ]) : (*(void (*) (PyArrayObject*,long,Int64) ) libnumarray_FatalApiError)) - -#define NA_get1_Float64 (libnumarray_API ? (*(Float64 (*) (PyArrayObject*,long) ) libnumarray_API[ 43 ]) : (*(Float64 (*) (PyArrayObject*,long) ) libnumarray_FatalApiError)) - -#define NA_get2_Float64 (libnumarray_API ? (*(Float64 (*) (PyArrayObject*,long,long) ) libnumarray_API[ 44 ]) : (*(Float64 (*) (PyArrayObject*,long,long) ) libnumarray_FatalApiError)) - -#define NA_get3_Float64 (libnumarray_API ? (*(Float64 (*) (PyArrayObject*,long,long,long) ) libnumarray_API[ 45 ]) : (*(Float64 (*) (PyArrayObject*,long,long,long) ) libnumarray_FatalApiError)) - -#define NA_set1_Float64 (libnumarray_API ? (*(void (*) (PyArrayObject*,long,Float64) ) libnumarray_API[ 46 ]) : (*(void (*) (PyArrayObject*,long,Float64) ) libnumarray_FatalApiError)) - -#define NA_set2_Float64 (libnumarray_API ? (*(void (*) (PyArrayObject*,long,long,Float64) ) libnumarray_API[ 47 ]) : (*(void (*) (PyArrayObject*,long,long,Float64) ) libnumarray_FatalApiError)) - -#define NA_set3_Float64 (libnumarray_API ? (*(void (*) (PyArrayObject*,long,long,long,Float64) ) libnumarray_API[ 48 ]) : (*(void (*) (PyArrayObject*,long,long,long,Float64) ) libnumarray_FatalApiError)) - -#define NA_get1_Complex64 (libnumarray_API ? (*(Complex64 (*) (PyArrayObject*,long) ) libnumarray_API[ 49 ]) : (*(Complex64 (*) (PyArrayObject*,long) ) libnumarray_FatalApiError)) - -#define NA_get2_Complex64 (libnumarray_API ? (*(Complex64 (*) (PyArrayObject*,long,long) ) libnumarray_API[ 50 ]) : (*(Complex64 (*) (PyArrayObject*,long,long) ) libnumarray_FatalApiError)) - -#define NA_get3_Complex64 (libnumarray_API ? (*(Complex64 (*) (PyArrayObject*,long,long,long) ) libnumarray_API[ 51 ]) : (*(Complex64 (*) (PyArrayObject*,long,long,long) ) libnumarray_FatalApiError)) - -#define NA_set1_Complex64 (libnumarray_API ? (*(void (*) (PyArrayObject*,long,Complex64) ) libnumarray_API[ 52 ]) : (*(void (*) (PyArrayObject*,long,Complex64) ) libnumarray_FatalApiError)) - -#define NA_set2_Complex64 (libnumarray_API ? (*(void (*) (PyArrayObject*,long,long,Complex64) ) libnumarray_API[ 53 ]) : (*(void (*) (PyArrayObject*,long,long,Complex64) ) libnumarray_FatalApiError)) - -#define NA_set3_Complex64 (libnumarray_API ? (*(void (*) (PyArrayObject*,long,long,long,Complex64) ) libnumarray_API[ 54 ]) : (*(void (*) (PyArrayObject*,long,long,long,Complex64) ) libnumarray_FatalApiError)) - -#define NA_get1_Int64 (libnumarray_API ? (*(Int64 (*) (PyArrayObject*,long) ) libnumarray_API[ 55 ]) : (*(Int64 (*) (PyArrayObject*,long) ) libnumarray_FatalApiError)) - -#define NA_get2_Int64 (libnumarray_API ? (*(Int64 (*) (PyArrayObject*,long,long) ) libnumarray_API[ 56 ]) : (*(Int64 (*) (PyArrayObject*,long,long) ) libnumarray_FatalApiError)) - -#define NA_get3_Int64 (libnumarray_API ? (*(Int64 (*) (PyArrayObject*,long,long,long) ) libnumarray_API[ 57 ]) : (*(Int64 (*) (PyArrayObject*,long,long,long) ) libnumarray_FatalApiError)) - -#define NA_set1_Int64 (libnumarray_API ? (*(void (*) (PyArrayObject*,long,Int64) ) libnumarray_API[ 58 ]) : (*(void (*) (PyArrayObject*,long,Int64) ) libnumarray_FatalApiError)) - -#define NA_set2_Int64 (libnumarray_API ? (*(void (*) (PyArrayObject*,long,long,Int64) ) libnumarray_API[ 59 ]) : (*(void (*) (PyArrayObject*,long,long,Int64) ) libnumarray_FatalApiError)) - -#define NA_set3_Int64 (libnumarray_API ? (*(void (*) (PyArrayObject*,long,long,long,Int64) ) libnumarray_API[ 60 ]) : (*(void (*) (PyArrayObject*,long,long,long,Int64) ) libnumarray_FatalApiError)) - -#define NA_get1D_Float64 (libnumarray_API ? (*(int (*) (PyArrayObject*,long,int,Float64*) ) libnumarray_API[ 61 ]) : (*(int (*) (PyArrayObject*,long,int,Float64*) ) libnumarray_FatalApiError)) - -#define NA_set1D_Float64 (libnumarray_API ? (*(int (*) (PyArrayObject*,long,int,Float64*) ) libnumarray_API[ 62 ]) : (*(int (*) (PyArrayObject*,long,int,Float64*) ) libnumarray_FatalApiError)) - -#define NA_get1D_Int64 (libnumarray_API ? (*(int (*) (PyArrayObject*,long,int,Int64*) ) libnumarray_API[ 63 ]) : (*(int (*) (PyArrayObject*,long,int,Int64*) ) libnumarray_FatalApiError)) - -#define NA_set1D_Int64 (libnumarray_API ? (*(int (*) (PyArrayObject*,long,int,Int64*) ) libnumarray_API[ 64 ]) : (*(int (*) (PyArrayObject*,long,int,Int64*) ) libnumarray_FatalApiError)) - -#define NA_get1D_Complex64 (libnumarray_API ? (*(int (*) (PyArrayObject*,long,int,Complex64*) ) libnumarray_API[ 65 ]) : (*(int (*) (PyArrayObject*,long,int,Complex64*) ) libnumarray_FatalApiError)) - -#define NA_set1D_Complex64 (libnumarray_API ? (*(int (*) (PyArrayObject*,long,int,Complex64*) ) libnumarray_API[ 66 ]) : (*(int (*) (PyArrayObject*,long,int,Complex64*) ) libnumarray_FatalApiError)) - -#define NA_ShapeEqual (libnumarray_API ? (*(int (*) (PyArrayObject*,PyArrayObject*) ) libnumarray_API[ 67 ]) : (*(int (*) (PyArrayObject*,PyArrayObject*) ) libnumarray_FatalApiError)) - -#define NA_ShapeLessThan (libnumarray_API ? (*(int (*) (PyArrayObject*,PyArrayObject*) ) libnumarray_API[ 68 ]) : (*(int (*) (PyArrayObject*,PyArrayObject*) ) libnumarray_FatalApiError)) - -#define NA_ByteOrder (libnumarray_API ? (*(int (*) (void) ) libnumarray_API[ 69 ]) : (*(int (*) (void) ) libnumarray_FatalApiError)) - -#define NA_IeeeSpecial32 (libnumarray_API ? (*(Bool (*) (Float32*,Int32*) ) libnumarray_API[ 70 ]) : (*(Bool (*) (Float32*,Int32*) ) libnumarray_FatalApiError)) - -#define NA_IeeeSpecial64 (libnumarray_API ? (*(Bool (*) (Float64*,Int32*) ) libnumarray_API[ 71 ]) : (*(Bool (*) (Float64*,Int32*) ) libnumarray_FatalApiError)) - -#define NA_updateDataPtr (libnumarray_API ? (*(PyArrayObject* (*) (PyArrayObject*) ) libnumarray_API[ 72 ]) : (*(PyArrayObject* (*) (PyArrayObject*) ) libnumarray_FatalApiError)) - -#define NA_typeNoToName (libnumarray_API ? (*(char* (*) (int) ) libnumarray_API[ 73 ]) : (*(char* (*) (int) ) libnumarray_FatalApiError)) - -#define NA_nameToTypeNo (libnumarray_API ? (*(int (*) (char*) ) libnumarray_API[ 74 ]) : (*(int (*) (char*) ) libnumarray_FatalApiError)) - -#define NA_typeNoToTypeObject (libnumarray_API ? (*(PyObject* (*) (int) ) libnumarray_API[ 75 ]) : (*(PyObject* (*) (int) ) libnumarray_FatalApiError)) - -#define NA_intTupleFromMaybeLongs (libnumarray_API ? (*(PyObject* (*) (int,maybelong*) ) libnumarray_API[ 76 ]) : (*(PyObject* (*) (int,maybelong*) ) libnumarray_FatalApiError)) - -#define NA_maybeLongsFromIntTuple (libnumarray_API ? (*(long (*) (int,maybelong*,PyObject*) ) libnumarray_API[ 77 ]) : (*(long (*) (int,maybelong*,PyObject*) ) libnumarray_FatalApiError)) - -#define NA_intTupleProduct (libnumarray_API ? (*(int (*) (PyObject *obj, long *product) ) libnumarray_API[ 78 ]) : (*(int (*) (PyObject *obj, long *product) ) libnumarray_FatalApiError)) - -#define NA_isIntegerSequence (libnumarray_API ? (*(long (*) (PyObject*) ) libnumarray_API[ 79 ]) : (*(long (*) (PyObject*) ) libnumarray_FatalApiError)) - -#define NA_setArrayFromSequence (libnumarray_API ? (*(PyObject* (*) (PyArrayObject*,PyObject*) ) libnumarray_API[ 80 ]) : (*(PyObject* (*) (PyArrayObject*,PyObject*) ) libnumarray_FatalApiError)) - -#define NA_maxType (libnumarray_API ? (*(int (*) (PyObject*) ) libnumarray_API[ 81 ]) : (*(int (*) (PyObject*) ) libnumarray_FatalApiError)) - -#define NA_isPythonScalar (libnumarray_API ? (*(int (*) (PyObject *obj) ) libnumarray_API[ 82 ]) : (*(int (*) (PyObject *obj) ) libnumarray_FatalApiError)) - -#define NA_getPythonScalar (libnumarray_API ? (*(PyObject* (*) (PyArrayObject*,long) ) libnumarray_API[ 83 ]) : (*(PyObject* (*) (PyArrayObject*,long) ) libnumarray_FatalApiError)) - -#define NA_setFromPythonScalar (libnumarray_API ? (*(int (*) (PyArrayObject*,long,PyObject*) ) libnumarray_API[ 84 ]) : (*(int (*) (PyArrayObject*,long,PyObject*) ) libnumarray_FatalApiError)) - -#define NA_NDArrayCheck (libnumarray_API ? (*(int (*) (PyObject*) ) libnumarray_API[ 85 ]) : (*(int (*) (PyObject*) ) libnumarray_FatalApiError)) - -#define NA_NumArrayCheck (libnumarray_API ? (*(int (*) (PyObject*) ) libnumarray_API[ 86 ]) : (*(int (*) (PyObject*) ) libnumarray_FatalApiError)) - -#define NA_ComplexArrayCheck (libnumarray_API ? (*(int (*) (PyObject*) ) libnumarray_API[ 87 ]) : (*(int (*) (PyObject*) ) libnumarray_FatalApiError)) - -#define NA_elements (libnumarray_API ? (*(unsigned long (*) (PyArrayObject*) ) libnumarray_API[ 88 ]) : (*(unsigned long (*) (PyArrayObject*) ) libnumarray_FatalApiError)) - -#define NA_typeObjectToTypeNo (libnumarray_API ? (*(int (*) (PyObject*) ) libnumarray_API[ 89 ]) : (*(int (*) (PyObject*) ) libnumarray_FatalApiError)) - -#define NA_copyArray (libnumarray_API ? (*(int (*) (PyArrayObject* to, const PyArrayObject* from) ) libnumarray_API[ 90 ]) : (*(int (*) (PyArrayObject* to, const PyArrayObject* from) ) libnumarray_FatalApiError)) - -#define NA_copy (libnumarray_API ? (*(PyArrayObject* (*) (PyArrayObject*) ) libnumarray_API[ 91 ]) : (*(PyArrayObject* (*) (PyArrayObject*) ) libnumarray_FatalApiError)) - -#define NA_getType (libnumarray_API ? (*(PyObject* (*) (PyObject *typeobj_or_name) ) libnumarray_API[ 92 ]) : (*(PyObject* (*) (PyObject *typeobj_or_name) ) libnumarray_FatalApiError)) - -#define NA_callCUFuncCore (libnumarray_API ? (*(PyObject * (*) (PyObject *cfunc, long niter, long ninargs, long noutargs, PyObject **BufferObj, long *offset) ) libnumarray_API[ 93 ]) : (*(PyObject * (*) (PyObject *cfunc, long niter, long ninargs, long noutargs, PyObject **BufferObj, long *offset) ) libnumarray_FatalApiError)) - -#define NA_callStrideConvCFuncCore (libnumarray_API ? (*(PyObject * (*) (PyObject *cfunc, int nshape, maybelong *shape, PyObject *inbuffObj, long inboffset, int nstrides0, maybelong *inbstrides, PyObject *outbuffObj, long outboffset, int nstrides1, maybelong *outbstrides, long nbytes) ) libnumarray_API[ 94 ]) : (*(PyObject * (*) (PyObject *cfunc, int nshape, maybelong *shape, PyObject *inbuffObj, long inboffset, int nstrides0, maybelong *inbstrides, PyObject *outbuffObj, long outboffset, int nstrides1, maybelong *outbstrides, long nbytes) ) libnumarray_FatalApiError)) - -#define NA_stridesFromShape (libnumarray_API ? (*(void (*) (int nshape, maybelong *shape, maybelong bytestride, maybelong *strides) ) libnumarray_API[ 95 ]) : (*(void (*) (int nshape, maybelong *shape, maybelong bytestride, maybelong *strides) ) libnumarray_FatalApiError)) - -#define NA_OperatorCheck (libnumarray_API ? (*(int (*) (PyObject *obj) ) libnumarray_API[ 96 ]) : (*(int (*) (PyObject *obj) ) libnumarray_FatalApiError)) - -#define NA_ConverterCheck (libnumarray_API ? (*(int (*) (PyObject *obj) ) libnumarray_API[ 97 ]) : (*(int (*) (PyObject *obj) ) libnumarray_FatalApiError)) - -#define NA_UfuncCheck (libnumarray_API ? (*(int (*) (PyObject *obj) ) libnumarray_API[ 98 ]) : (*(int (*) (PyObject *obj) ) libnumarray_FatalApiError)) - -#define NA_CfuncCheck (libnumarray_API ? (*(int (*) (PyObject *obj) ) libnumarray_API[ 99 ]) : (*(int (*) (PyObject *obj) ) libnumarray_FatalApiError)) - -#define NA_getByteOffset (libnumarray_API ? (*(int (*) (PyArrayObject *array, int nindices, maybelong *indices, long *offset) ) libnumarray_API[ 100 ]) : (*(int (*) (PyArrayObject *array, int nindices, maybelong *indices, long *offset) ) libnumarray_FatalApiError)) - -#define NA_swapAxes (libnumarray_API ? (*(int (*) (PyArrayObject *array, int x, int y) ) libnumarray_API[ 101 ]) : (*(int (*) (PyArrayObject *array, int x, int y) ) libnumarray_FatalApiError)) - -#define NA_initModuleGlobal (libnumarray_API ? (*(PyObject * (*) (char *module, char *global) ) libnumarray_API[ 102 ]) : (*(PyObject * (*) (char *module, char *global) ) libnumarray_FatalApiError)) - -#define NA_NumarrayType (libnumarray_API ? (*(NumarrayType (*) (PyObject *seq) ) libnumarray_API[ 103 ]) : (*(NumarrayType (*) (PyObject *seq) ) libnumarray_FatalApiError)) - -#define NA_NewAllFromBuffer (libnumarray_API ? (*(PyArrayObject * (*) (int ndim, maybelong *shape, NumarrayType type, PyObject *bufferObject, maybelong byteoffset, maybelong bytestride, int byteorder, int aligned, int writeable) ) libnumarray_API[ 104 ]) : (*(PyArrayObject * (*) (int ndim, maybelong *shape, NumarrayType type, PyObject *bufferObject, maybelong byteoffset, maybelong bytestride, int byteorder, int aligned, int writeable) ) libnumarray_FatalApiError)) - -#define NA_alloc1D_Float64 (libnumarray_API ? (*(Float64 * (*) (PyArrayObject *a, long offset, int cnt) ) libnumarray_API[ 105 ]) : (*(Float64 * (*) (PyArrayObject *a, long offset, int cnt) ) libnumarray_FatalApiError)) - -#define NA_alloc1D_Int64 (libnumarray_API ? (*(Int64 * (*) (PyArrayObject *a, long offset, int cnt) ) libnumarray_API[ 106 ]) : (*(Int64 * (*) (PyArrayObject *a, long offset, int cnt) ) libnumarray_FatalApiError)) - -#define NA_updateAlignment (libnumarray_API ? (*(void (*) (PyArrayObject *self) ) libnumarray_API[ 107 ]) : (*(void (*) (PyArrayObject *self) ) libnumarray_FatalApiError)) - -#define NA_updateContiguous (libnumarray_API ? (*(void (*) (PyArrayObject *self) ) libnumarray_API[ 108 ]) : (*(void (*) (PyArrayObject *self) ) libnumarray_FatalApiError)) - -#define NA_updateStatus (libnumarray_API ? (*(void (*) (PyArrayObject *self) ) libnumarray_API[ 109 ]) : (*(void (*) (PyArrayObject *self) ) libnumarray_FatalApiError)) - -#define NA_NumArrayCheckExact (libnumarray_API ? (*(int (*) (PyObject *op) ) libnumarray_API[ 110 ]) : (*(int (*) (PyObject *op) ) libnumarray_FatalApiError)) - -#define NA_NDArrayCheckExact (libnumarray_API ? (*(int (*) (PyObject *op) ) libnumarray_API[ 111 ]) : (*(int (*) (PyObject *op) ) libnumarray_FatalApiError)) - -#define NA_OperatorCheckExact (libnumarray_API ? (*(int (*) (PyObject *op) ) libnumarray_API[ 112 ]) : (*(int (*) (PyObject *op) ) libnumarray_FatalApiError)) - -#define NA_ConverterCheckExact (libnumarray_API ? (*(int (*) (PyObject *op) ) libnumarray_API[ 113 ]) : (*(int (*) (PyObject *op) ) libnumarray_FatalApiError)) - -#define NA_UfuncCheckExact (libnumarray_API ? (*(int (*) (PyObject *op) ) libnumarray_API[ 114 ]) : (*(int (*) (PyObject *op) ) libnumarray_FatalApiError)) - -#define NA_CfuncCheckExact (libnumarray_API ? (*(int (*) (PyObject *op) ) libnumarray_API[ 115 ]) : (*(int (*) (PyObject *op) ) libnumarray_FatalApiError)) - -#define NA_getArrayData (libnumarray_API ? (*(char * (*) (PyArrayObject *ap) ) libnumarray_API[ 116 ]) : (*(char * (*) (PyArrayObject *ap) ) libnumarray_FatalApiError)) - -#define NA_updateByteswap (libnumarray_API ? (*(void (*) (PyArrayObject *ap) ) libnumarray_API[ 117 ]) : (*(void (*) (PyArrayObject *ap) ) libnumarray_FatalApiError)) - -#define NA_DescrFromType (libnumarray_API ? (*(PyArray_Descr * (*) (int type) ) libnumarray_API[ 118 ]) : (*(PyArray_Descr * (*) (int type) ) libnumarray_FatalApiError)) - -#define NA_Cast (libnumarray_API ? (*(PyObject * (*) (PyArrayObject *a, int type) ) libnumarray_API[ 119 ]) : (*(PyObject * (*) (PyArrayObject *a, int type) ) libnumarray_FatalApiError)) - -#define NA_checkFPErrors (libnumarray_API ? (*(int (*) (void) ) libnumarray_API[ 120 ]) : (*(int (*) (void) ) libnumarray_FatalApiError)) - -#define NA_clearFPErrors (libnumarray_API ? (*(void (*) (void) ) libnumarray_API[ 121 ]) : (*(void (*) (void) ) libnumarray_FatalApiError)) - -#define NA_checkAndReportFPErrors (libnumarray_API ? (*(int (*) (char *name) ) libnumarray_API[ 122 ]) : (*(int (*) (char *name) ) libnumarray_FatalApiError)) - -#define NA_IeeeMask32 (libnumarray_API ? (*(Bool (*) (Float32,Int32) ) libnumarray_API[ 123 ]) : (*(Bool (*) (Float32,Int32) ) libnumarray_FatalApiError)) - -#define NA_IeeeMask64 (libnumarray_API ? (*(Bool (*) (Float64,Int32) ) libnumarray_API[ 124 ]) : (*(Bool (*) (Float64,Int32) ) libnumarray_FatalApiError)) - -#define _NA_callStridingHelper (libnumarray_API ? (*(int (*) (PyObject *aux, long dim, long nnumarray, PyArrayObject *numarray[], char *data[], CFUNC_STRIDED_FUNC f) ) libnumarray_API[ 125 ]) : (*(int (*) (PyObject *aux, long dim, long nnumarray, PyArrayObject *numarray[], char *data[], CFUNC_STRIDED_FUNC f) ) libnumarray_FatalApiError)) - -#define NA_FromDimsStridesDescrAndData (libnumarray_API ? (*(PyArrayObject * (*) (int nd, maybelong *dims, maybelong *strides, PyArray_Descr *descr, char *data) ) libnumarray_API[ 126 ]) : (*(PyArrayObject * (*) (int nd, maybelong *dims, maybelong *strides, PyArray_Descr *descr, char *data) ) libnumarray_FatalApiError)) - -#define NA_FromDimsTypeAndData (libnumarray_API ? (*(PyArrayObject * (*) (int nd, maybelong *dims, int type, char *data) ) libnumarray_API[ 127 ]) : (*(PyArrayObject * (*) (int nd, maybelong *dims, int type, char *data) ) libnumarray_FatalApiError)) - -#define NA_FromDimsStridesTypeAndData (libnumarray_API ? (*(PyArrayObject * (*) (int nd, maybelong *dims, maybelong *strides, int type, char *data) ) libnumarray_API[ 128 ]) : (*(PyArrayObject * (*) (int nd, maybelong *dims, maybelong *strides, int type, char *data) ) libnumarray_FatalApiError)) - -#define NA_scipy_typestr (libnumarray_API ? (*(int (*) (NumarrayType t, int byteorder, char *typestr) ) libnumarray_API[ 129 ]) : (*(int (*) (NumarrayType t, int byteorder, char *typestr) ) libnumarray_FatalApiError)) - -#define NA_FromArrayStruct (libnumarray_API ? (*(PyArrayObject * (*) (PyObject *a) ) libnumarray_API[ 130 ]) : (*(PyArrayObject * (*) (PyObject *a) ) libnumarray_FatalApiError)) - -#endif - - /* Total number of C API pointers */ -#define libnumarray_API_pointers 131 - -#ifdef __cplusplus -} -#endif - -#endif /* NUMPY_LIBNUMARRAY_H */ diff --git a/numpy/numarray/numpy_numarray/numcomplex.h b/numpy/numarray/numpy_numarray/numcomplex.h deleted file mode 100644 index 9ed4198c7..000000000 --- a/numpy/numarray/numpy_numarray/numcomplex.h +++ /dev/null @@ -1,252 +0,0 @@ -/* See numarray.h for Complex32, Complex64: - -typedef struct { Float32 r, i; } Complex32; -typedef struct { Float64 r, i; } Complex64; - -*/ -typedef struct { Float32 a, theta; } PolarComplex32; -typedef struct { Float64 a, theta; } PolarComplex64; - -#define NUM_SQ(x) ((x)*(x)) - -#define NUM_CABSSQ(p) (NUM_SQ((p).r) + NUM_SQ((p).i)) - -#define NUM_CABS(p) sqrt(NUM_CABSSQ(p)) - -#define NUM_C_TO_P(c, p) (p).a = NUM_CABS(c); \ - (p).theta = atan2((c).i, (c).r); - -#define NUM_P_TO_C(p, c) (c).r = (p).a*cos((p).theta); \ - (c).i = (p).a*sin((p).theta); - -#define NUM_CASS(p, q) (q).r = (p).r, (q).i = (p).i - -#define NUM_CADD(p, q, s) (s).r = (p).r + (q).r, \ - (s).i = (p).i + (q).i - -#define NUM_CSUB(p, q, s) (s).r = (p).r - (q).r, \ - (s).i = (p).i - (q).i - -#define NUM_CMUL(p, q, s) \ - { Float64 rp = (p).r; \ - Float64 rq = (q).r; \ - (s).r = rp*rq - (p).i*(q).i; \ - (s).i = rp*(q).i + rq*(p).i; \ - } - -#define NUM_CDIV(p, q, s) \ - { \ - Float64 rp = (p).r; \ - Float64 ip = (p).i; \ - Float64 rq = (q).r; \ - if ((q).i != 0) { \ - Float64 temp = NUM_CABSSQ(q); \ - (s).r = (rp*rq+(p).i*(q).i)/temp; \ - (s).i = (rq*(p).i-(q).i*rp)/temp; \ - } else { \ - (s).r = rp/rq; \ - (s).i = ip/rq; \ - } \ - } - -#define NUM_CREM(p, q, s) \ - { Complex64 r; \ - NUM_CDIV(p, q, r); \ - r.r = floor(r.r); \ - r.i = 0; \ - NUM_CMUL(r, q, r); \ - NUM_CSUB(p, r, s); \ - } - -#define NUM_CMINUS(p, s) (s).r = -(p).r; (s).i = -(p).i; -#define NUM_CNEG NUM_CMINUS - -#define NUM_CEQ(p, q) (((p).r == (q).r) && ((p).i == (q).i)) -#define NUM_CNE(p, q) (((p).r != (q).r) || ((p).i != (q).i)) -#define NUM_CLT(p, q) ((p).r < (q).r) -#define NUM_CGT(p, q) ((p).r > (q).r) -#define NUM_CLE(p, q) ((p).r <= (q).r) -#define NUM_CGE(p, q) ((p).r >= (q).r) - -/* e**z = e**x * (cos(y)+ i*sin(y)) where z = x + i*y - so e**z = e**x * cos(y) + i * e**x * sin(y) -*/ -#define NUM_CEXP(p, s) \ - { Float64 ex = exp((p).r); \ - (s).r = ex * cos((p).i); \ - (s).i = ex * sin((p).i); \ - } - -/* e**w = z; w = u + i*v; z = r * e**(i*theta); - -e**u * e**(i*v) = r * e**(i*theta); - -log(z) = w; log(z) = log(r) + i*theta; - */ -#define NUM_CLOG(p, s) \ - { PolarComplex64 temp; NUM_C_TO_P(p, temp); \ - (s).r = num_log(temp.a); \ - (s).i = temp.theta; \ - } - -#define NUM_LOG10_E 0.43429448190325182 - -#define NUM_CLOG10(p, s) \ - { NUM_CLOG(p, s); \ - (s).r *= NUM_LOG10_E; \ - (s).i *= NUM_LOG10_E; \ - } - -/* s = p ** q */ -#define NUM_CPOW(p, q, s) { if (NUM_CABSSQ(p) == 0) { \ - if ((q).r == 0 && (q).i == 0) { \ - (s).r = (s).i = 1; \ - } else { \ - (s).r = (s).i = 0; \ - } \ - } else { \ - NUM_CLOG(p, s); \ - NUM_CMUL(s, q, s); \ - NUM_CEXP(s, s); \ - } \ - } - -#define NUM_CSQRT(p, s) { Complex64 temp; temp.r = 0.5; temp.i=0; \ - NUM_CPOW(p, temp, s); \ - } - -#define NUM_CSQR(p, s) { Complex64 temp; temp.r = 2.0; temp.i=0; \ - NUM_CPOW(p, temp, s); \ - } - -#define NUM_CSIN(p, s) { Float64 sp = sin((p).r); \ - Float64 cp = cos((p).r); \ - (s).r = cosh((p).i) * sp; \ - (s).i = sinh((p).i) * cp; \ - } - -#define NUM_CCOS(p, s) { Float64 sp = sin((p).r); \ - Float64 cp = cos((p).r); \ - (s).r = cosh((p).i) * cp; \ - (s).i = -sinh((p).i) * sp; \ - } - -#define NUM_CTAN(p, s) { Complex64 ss, cs; \ - NUM_CSIN(p, ss); \ - NUM_CCOS(p, cs); \ - NUM_CDIV(ss, cs, s); \ - } - -#define NUM_CSINH(p, s) { Float64 sp = sin((p).i); \ - Float64 cp = cos((p).i); \ - (s).r = sinh((p).r) * cp; \ - (s).i = cosh((p).r) * sp; \ - } - -#define NUM_CCOSH(p, s) { Float64 sp = sin((p).i); \ - Float64 cp = cos((p).i); \ - (s).r = cosh((p).r) * cp; \ - (s).i = sinh((p).r) * sp; \ - } - -#define NUM_CTANH(p, s) { Complex64 ss, cs; \ - NUM_CSINH(p, ss); \ - NUM_CCOSH(p, cs); \ - NUM_CDIV(ss, cs, s); \ - } - -#define NUM_CRPOW(p, v, s) { Complex64 cr; cr.r = v; cr.i = 0; \ - NUM_CPOW(p,cr,s); \ - } - -#define NUM_CRMUL(p, v, s) (s).r = (p).r * v; (s).i = (p).i * v; - -#define NUM_CIMUL(p, s) { Float64 temp = (s).r; \ - (s).r = -(p).i; (s).i = temp; \ - } - -/* asin(z) = -i * log(i*z + (1 - z**2)**0.5) */ -#define NUM_CASIN(p, s) { Complex64 p1; NUM_CASS(p, p1); \ - NUM_CIMUL(p, p1); \ - NUM_CMUL(p, p, s); \ - NUM_CNEG(s, s); \ - (s).r += 1; \ - NUM_CRPOW(s, 0.5, s); \ - NUM_CADD(p1, s, s); \ - NUM_CLOG(s, s); \ - NUM_CIMUL(s, s); \ - NUM_CNEG(s, s); \ - } - -/* acos(z) = -i * log(z + i*(1 - z**2)**0.5) */ -#define NUM_CACOS(p, s) { Complex64 p1; NUM_CASS(p, p1); \ - NUM_CMUL(p, p, s); \ - NUM_CNEG(s, s); \ - (s).r += 1; \ - NUM_CRPOW(s, 0.5, s); \ - NUM_CIMUL(s, s); \ - NUM_CADD(p1, s, s); \ - NUM_CLOG(s, s); \ - NUM_CIMUL(s, s); \ - NUM_CNEG(s, s); \ - } - -/* atan(z) = i/2 * log( (i+z) / (i - z) ) */ -#define NUM_CATAN(p, s) { Complex64 p1, p2; \ - NUM_CASS(p, p1); NUM_CNEG(p, p2); \ - p1.i += 1; \ - p2.i += 1; \ - NUM_CDIV(p1, p2, s); \ - NUM_CLOG(s, s); \ - NUM_CIMUL(s, s); \ - NUM_CRMUL(s, 0.5, s); \ - } - -/* asinh(z) = log( z + (z**2 + 1)**0.5 ) */ -#define NUM_CASINH(p, s) { Complex64 p1; NUM_CASS(p, p1); \ - NUM_CMUL(p, p, s); \ - (s).r += 1; \ - NUM_CRPOW(s, 0.5, s); \ - NUM_CADD(p1, s, s); \ - NUM_CLOG(s, s); \ - } - -/* acosh(z) = log( z + (z**2 - 1)**0.5 ) */ -#define NUM_CACOSH(p, s) { Complex64 p1; NUM_CASS(p, p1); \ - NUM_CMUL(p, p, s); \ - (s).r -= 1; \ - NUM_CRPOW(s, 0.5, s); \ - NUM_CADD(p1, s, s); \ - NUM_CLOG(s, s); \ - } - -/* atanh(z) = 1/2 * log( (1+z)/(1-z) ) */ -#define NUM_CATANH(p, s) { Complex64 p1, p2; \ - NUM_CASS(p, p1); NUM_CNEG(p, p2); \ - p1.r += 1; \ - p2.r += 1; \ - NUM_CDIV(p1, p2, s); \ - NUM_CLOG(s, s); \ - NUM_CRMUL(s, 0.5, s); \ - } - - -#define NUM_CMIN(p, q) (NUM_CLE(p, q) ? p : q) -#define NUM_CMAX(p, q) (NUM_CGE(p, q) ? p : q) - -#define NUM_CNZ(p) (((p).r != 0) || ((p).i != 0)) -#define NUM_CLAND(p, q) (NUM_CNZ(p) & NUM_CNZ(q)) -#define NUM_CLOR(p, q) (NUM_CNZ(p) | NUM_CNZ(q)) -#define NUM_CLXOR(p, q) (NUM_CNZ(p) ^ NUM_CNZ(q)) -#define NUM_CLNOT(p) (!NUM_CNZ(p)) - -#define NUM_CFLOOR(p, s) (s).r = floor((p).r); (s).i = floor((p).i); -#define NUM_CCEIL(p, s) (s).r = ceil((p).r); (s).i = ceil((p).i); - -#define NUM_CFABS(p, s) (s).r = fabs((p).r); (s).i = fabs((p).i); -#define NUM_CROUND(p, s) (s).r = num_round((p).r); (s).i = num_round((p).i); -#define NUM_CHYPOT(p, q, s) { Complex64 t; \ - NUM_CSQR(p, s); NUM_CSQR(q, t); \ - NUM_CADD(s, t, s); \ - NUM_CSQRT(s, s); \ - } diff --git a/numpy/numarray/numpy_numarray/nummacro.h b/numpy/numarray/numpy_numarray/nummacro.h deleted file mode 100644 index 7bcc250a9..000000000 --- a/numpy/numarray/numpy_numarray/nummacro.h +++ /dev/null @@ -1,449 +0,0 @@ -/* Primarily for compatibility with numarray C-API */ - -#if !defined(_ndarraymacro) -#define _ndarraymacro - -/* The structs defined here are private implementation details of numarray -which are subject to change w/o notice. -*/ - -#define PY_BOOL_CHAR "b" -#define PY_INT8_CHAR "b" -#define PY_INT16_CHAR "h" -#define PY_INT32_CHAR "i" -#define PY_FLOAT32_CHAR "f" -#define PY_FLOAT64_CHAR "d" -#define PY_UINT8_CHAR "h" -#define PY_UINT16_CHAR "i" -#define PY_UINT32_CHAR "i" /* Unless longer int available */ -#define PY_COMPLEX64_CHAR "D" -#define PY_COMPLEX128_CHAR "D" - -#define PY_LONG_CHAR "l" -#define PY_LONG_LONG_CHAR "L" - -#define pyFPE_DIVIDE_BY_ZERO 1 -#define pyFPE_OVERFLOW 2 -#define pyFPE_UNDERFLOW 4 -#define pyFPE_INVALID 8 - -#define isNonZERO(x) (x != 0) /* to convert values to boolean 1's or 0's */ - -typedef enum -{ - NUM_CONTIGUOUS=1, - NUM_NOTSWAPPED=2, - NUM_ALIGNED=4, - NUM_WRITABLE=8, - NUM_COPY=16, - - NUM_C_ARRAY = (NUM_CONTIGUOUS | NUM_ALIGNED | NUM_NOTSWAPPED), - NUM_UNCONVERTED = 0 -} NumRequirements; - -#define UNCONVERTED 0 -#define C_ARRAY (NUM_CONTIGUOUS | NUM_NOTSWAPPED | NUM_ALIGNED) - -#define MUST_BE_COMPUTED 2 - -#define NUM_FLOORDIVIDE(a,b,out) (out) = floor((a)/(b)) - -#define NA_Begin() Py_Initialize(); import_libnumarray(); -#define NA_End() NA_Done(); Py_Finalize(); - -#define NA_OFFSETDATA(num) ((void *) PyArray_DATA(num)) - -/* unaligned NA_COPY functions */ -#define NA_COPY1(i, o) (*(o) = *(i)) -#define NA_COPY2(i, o) NA_COPY1(i, o), NA_COPY1(i+1, o+1) -#define NA_COPY4(i, o) NA_COPY2(i, o), NA_COPY2(i+2, o+2) -#define NA_COPY8(i, o) NA_COPY4(i, o), NA_COPY4(i+4, o+4) -#define NA_COPY16(i, o) NA_COPY8(i, o), NA_COPY8(i+8, o+8) - -/* byteswapping macros: these fail if i==o */ -#define NA_SWAP1(i, o) NA_COPY1(i, o) -#define NA_SWAP2(i, o) NA_SWAP1(i, o+1), NA_SWAP1(i+1, o) -#define NA_SWAP4(i, o) NA_SWAP2(i, o+2), NA_SWAP2(i+2, o) -#define NA_SWAP8(i, o) NA_SWAP4(i, o+4), NA_SWAP4(i+4, o) -#define NA_SWAP16(i, o) NA_SWAP8(i, o+8), NA_SWAP8(i+8, o) - -/* complex byteswaps must swap each part (real, imag) independently */ -#define NA_COMPLEX_SWAP8(i, o) NA_SWAP4(i, o), NA_SWAP4(i+4, o+4) -#define NA_COMPLEX_SWAP16(i, o) NA_SWAP8(i, o), NA_SWAP8(i+8, o+8) - -/* byteswapping macros: these work even if i == o */ -#define NA_TSWAP1(i, o, t) NA_COPY1(i, t), NA_SWAP1(t, o) -#define NA_TSWAP2(i, o, t) NA_COPY2(i, t), NA_SWAP2(t, o) -#define NA_TSWAP4(i, o, t) NA_COPY4(i, t), NA_SWAP4(t, o) -#define NA_TSWAP8(i, o, t) NA_COPY8(i, t), NA_SWAP8(t, o) - -/* fast copy functions for %N aligned i and o */ -#define NA_ACOPY1(i, o) (((Int8 *)o)[0] = ((Int8 *)i)[0]) -#define NA_ACOPY2(i, o) (((Int16 *)o)[0] = ((Int16 *)i)[0]) -#define NA_ACOPY4(i, o) (((Int32 *)o)[0] = ((Int32 *)i)[0]) -#define NA_ACOPY8(i, o) (((Float64 *)o)[0] = ((Float64 *)i)[0]) -#define NA_ACOPY16(i, o) (((Complex64 *)o)[0] = ((Complex64 *)i)[0]) - -/* from here down, type("ai") is NDInfo* */ - -#define NA_PTR(ai) ((char *) NA_OFFSETDATA((ai))) -#define NA_PTR1(ai, i) (NA_PTR(ai) + \ - (i)*(ai)->strides[0]) -#define NA_PTR2(ai, i, j) (NA_PTR(ai) + \ - (i)*(ai)->strides[0] + \ - (j)*(ai)->strides[1]) -#define NA_PTR3(ai, i, j, k) (NA_PTR(ai) + \ - (i)*(ai)->strides[0] + \ - (j)*(ai)->strides[1] + \ - (k)*(ai)->strides[2]) - -#define NA_SET_TEMP(ai, type, v) (((type *) &__temp__)[0] = v) - -#define NA_SWAPComplex64 NA_COMPLEX_SWAP16 -#define NA_SWAPComplex64_ NA_COMPLEX_SWAP16 -#define NA_SWAPComplex32 NA_COMPLEX_SWAP8 -#define NA_SWAPFloat64 NA_SWAP8 -#define NA_SWAPFloat32 NA_SWAP4 -#define NA_SWAPInt64 NA_SWAP8 -#define NA_SWAPUInt64 NA_SWAP8 -#define NA_SWAPInt32 NA_SWAP4 -#define NA_SWAPUInt32 NA_SWAP4 -#define NA_SWAPInt16 NA_SWAP2 -#define NA_SWAPUInt16 NA_SWAP2 -#define NA_SWAPInt8 NA_SWAP1 -#define NA_SWAPUInt8 NA_SWAP1 -#define NA_SWAPBool NA_SWAP1 - -#define NA_COPYComplex64 NA_COPY16 -#define NA_COPYComplex64_ NA_COPY16 -#define NA_COPYComplex32 NA_COPY8 -#define NA_COPYFloat64 NA_COPY8 -#define NA_COPYFloat32 NA_COPY4 -#define NA_COPYInt64 NA_COPY8 -#define NA_COPYUInt64 NA_COPY8 -#define NA_COPYInt32 NA_COPY4 -#define NA_COPYUInt32 NA_COPY4 -#define NA_COPYInt16 NA_COPY2 -#define NA_COPYUInt16 NA_COPY2 -#define NA_COPYInt8 NA_COPY1 -#define NA_COPYUInt8 NA_COPY1 -#define NA_COPYBool NA_COPY1 - -#ifdef __cplusplus -extern "C" { -#endif - -#define _makeGetPb(type) \ -static type _NA_GETPb_##type(char *ptr) \ -{ \ - type temp; \ - NA_SWAP##type(ptr, (char *)&temp); \ - return temp; \ -} - -#define _makeGetPa(type) \ -static type _NA_GETPa_##type(char *ptr) \ -{ \ - type temp; \ - NA_COPY##type(ptr, (char *)&temp); \ - return temp; \ -} - -_makeGetPb(Complex64_) -_makeGetPb(Complex32) -_makeGetPb(Float64) -_makeGetPb(Float32) -_makeGetPb(Int64) -_makeGetPb(UInt64) -_makeGetPb(Int32) -_makeGetPb(UInt32) -_makeGetPb(Int16) -_makeGetPb(UInt16) -_makeGetPb(Int8) -_makeGetPb(UInt8) -_makeGetPb(Bool) - -_makeGetPa(Complex64_) -_makeGetPa(Complex32) -_makeGetPa(Float64) -_makeGetPa(Float32) -_makeGetPa(Int64) -_makeGetPa(UInt64) -_makeGetPa(Int32) -_makeGetPa(UInt32) -_makeGetPa(Int16) -_makeGetPa(UInt16) -_makeGetPa(Int8) -_makeGetPa(UInt8) -_makeGetPa(Bool) - -#undef _makeGetPb -#undef _makeGetPa - -#define _makeSetPb(type) \ -static void _NA_SETPb_##type(char *ptr, type v) \ -{ \ - NA_SWAP##type(((char *)&v), ptr); \ - return; \ -} - -#define _makeSetPa(type) \ -static void _NA_SETPa_##type(char *ptr, type v) \ -{ \ - NA_COPY##type(((char *)&v), ptr); \ - return; \ -} - -_makeSetPb(Complex64_) -_makeSetPb(Complex32) -_makeSetPb(Float64) -_makeSetPb(Float32) -_makeSetPb(Int64) -_makeSetPb(UInt64) -_makeSetPb(Int32) -_makeSetPb(UInt32) -_makeSetPb(Int16) -_makeSetPb(UInt16) -_makeSetPb(Int8) -_makeSetPb(UInt8) -_makeSetPb(Bool) - -_makeSetPa(Complex64_) -_makeSetPa(Complex32) -_makeSetPa(Float64) -_makeSetPa(Float32) -_makeSetPa(Int64) -_makeSetPa(UInt64) -_makeSetPa(Int32) -_makeSetPa(UInt32) -_makeSetPa(Int16) -_makeSetPa(UInt16) -_makeSetPa(Int8) -_makeSetPa(UInt8) -_makeSetPa(Bool) - -#undef _makeSetPb -#undef _makeSetPa - -#ifdef __cplusplus - } -#endif - -/* ========================== ptr get/set ================================ */ - -/* byteswapping */ -#define NA_GETPb(ai, type, ptr) _NA_GETPb_##type(ptr) - -/* aligning */ -#define NA_GETPa(ai, type, ptr) _NA_GETPa_##type(ptr) - -/* fast (aligned, !byteswapped) */ -#define NA_GETPf(ai, type, ptr) (*((type *) (ptr))) - -#define NA_GETP(ai, type, ptr) \ - (PyArray_ISCARRAY(ai) ? NA_GETPf(ai, type, ptr) \ - : (PyArray_ISBYTESWAPPED(ai) ? \ - NA_GETPb(ai, type, ptr) \ - : NA_GETPa(ai, type, ptr))) - -/* NOTE: NA_SET* macros cannot be used as values. */ - -/* byteswapping */ -#define NA_SETPb(ai, type, ptr, v) _NA_SETPb_##type(ptr, v) - -/* aligning */ -#define NA_SETPa(ai, type, ptr, v) _NA_SETPa_##type(ptr, v) - -/* fast (aligned, !byteswapped) */ -#define NA_SETPf(ai, type, ptr, v) ((*((type *) ptr)) = (v)) - -#define NA_SETP(ai, type, ptr, v) \ - if (PyArray_ISCARRAY(ai)) { \ - NA_SETPf((ai), type, (ptr), (v)); \ - } else if (PyArray_ISBYTESWAPPED(ai)) { \ - NA_SETPb((ai), type, (ptr), (v)); \ - } else \ - NA_SETPa((ai), type, (ptr), (v)) - -/* ========================== 1 index get/set ============================ */ - -/* byteswapping */ -#define NA_GET1b(ai, type, i) NA_GETPb(ai, type, NA_PTR1(ai, i)) -/* aligning */ -#define NA_GET1a(ai, type, i) NA_GETPa(ai, type, NA_PTR1(ai, i)) -/* fast (aligned, !byteswapped) */ -#define NA_GET1f(ai, type, i) NA_GETPf(ai, type, NA_PTR1(ai, i)) -/* testing */ -#define NA_GET1(ai, type, i) NA_GETP(ai, type, NA_PTR1(ai, i)) - -/* byteswapping */ -#define NA_SET1b(ai, type, i, v) NA_SETPb(ai, type, NA_PTR1(ai, i), v) -/* aligning */ -#define NA_SET1a(ai, type, i, v) NA_SETPa(ai, type, NA_PTR1(ai, i), v) -/* fast (aligned, !byteswapped) */ -#define NA_SET1f(ai, type, i, v) NA_SETPf(ai, type, NA_PTR1(ai, i), v) -/* testing */ -#define NA_SET1(ai, type, i, v) NA_SETP(ai, type, NA_PTR1(ai, i), v) - -/* ========================== 2 index get/set ============================= */ - -/* byteswapping */ -#define NA_GET2b(ai, type, i, j) NA_GETPb(ai, type, NA_PTR2(ai, i, j)) -/* aligning */ -#define NA_GET2a(ai, type, i, j) NA_GETPa(ai, type, NA_PTR2(ai, i, j)) -/* fast (aligned, !byteswapped) */ -#define NA_GET2f(ai, type, i, j) NA_GETPf(ai, type, NA_PTR2(ai, i, j)) -/* testing */ -#define NA_GET2(ai, type, i, j) NA_GETP(ai, type, NA_PTR2(ai, i, j)) - -/* byteswapping */ -#define NA_SET2b(ai, type, i, j, v) NA_SETPb(ai, type, NA_PTR2(ai, i, j), v) -/* aligning */ -#define NA_SET2a(ai, type, i, j, v) NA_SETPa(ai, type, NA_PTR2(ai, i, j), v) -/* fast (aligned, !byteswapped) */ -#define NA_SET2f(ai, type, i, j, v) NA_SETPf(ai, type, NA_PTR2(ai, i, j), v) - -#define NA_SET2(ai, type, i, j, v) NA_SETP(ai, type, NA_PTR2(ai, i, j), v) - -/* ========================== 3 index get/set ============================= */ - -/* byteswapping */ -#define NA_GET3b(ai, type, i, j, k) NA_GETPb(ai, type, NA_PTR3(ai, i, j, k)) -/* aligning */ -#define NA_GET3a(ai, type, i, j, k) NA_GETPa(ai, type, NA_PTR3(ai, i, j, k)) -/* fast (aligned, !byteswapped) */ -#define NA_GET3f(ai, type, i, j, k) NA_GETPf(ai, type, NA_PTR3(ai, i, j, k)) -/* testing */ -#define NA_GET3(ai, type, i, j, k) NA_GETP(ai, type, NA_PTR3(ai, i, j, k)) - -/* byteswapping */ -#define NA_SET3b(ai, type, i, j, k, v) \ - NA_SETPb(ai, type, NA_PTR3(ai, i, j, k), v) -/* aligning */ -#define NA_SET3a(ai, type, i, j, k, v) \ - NA_SETPa(ai, type, NA_PTR3(ai, i, j, k), v) -/* fast (aligned, !byteswapped) */ -#define NA_SET3f(ai, type, i, j, k, v) \ - NA_SETPf(ai, type, NA_PTR3(ai, i, j, k), v) -#define NA_SET3(ai, type, i, j, k, v) \ - NA_SETP(ai, type, NA_PTR3(ai, i, j, k), v) - -/* ========================== 1D get/set ================================== */ - -#define NA_GET1Db(ai, type, base, cnt, out) \ - { int i, stride = ai->strides[ai->nd-1]; \ - for(i=0; i<cnt; i++) { \ - out[i] = NA_GETPb(ai, type, base); \ - base += stride; \ - } \ - } - -#define NA_GET1Da(ai, type, base, cnt, out) \ - { int i, stride = ai->strides[ai->nd-1]; \ - for(i=0; i<cnt; i++) { \ - out[i] = NA_GETPa(ai, type, base); \ - base += stride; \ - } \ - } - -#define NA_GET1Df(ai, type, base, cnt, out) \ - { int i, stride = ai->strides[ai->nd-1]; \ - for(i=0; i<cnt; i++) { \ - out[i] = NA_GETPf(ai, type, base); \ - base += stride; \ - } \ - } - -#define NA_GET1D(ai, type, base, cnt, out) \ - if (PyArray_ISCARRAY(ai)) { \ - NA_GET1Df(ai, type, base, cnt, out); \ - } else if (PyArray_ISBYTESWAPPED(ai)) { \ - NA_GET1Db(ai, type, base, cnt, out); \ - } else { \ - NA_GET1Da(ai, type, base, cnt, out); \ - } - -#define NA_SET1Db(ai, type, base, cnt, in) \ - { int i, stride = ai->strides[ai->nd-1]; \ - for(i=0; i<cnt; i++) { \ - NA_SETPb(ai, type, base, in[i]); \ - base += stride; \ - } \ - } - -#define NA_SET1Da(ai, type, base, cnt, in) \ - { int i, stride = ai->strides[ai->nd-1]; \ - for(i=0; i<cnt; i++) { \ - NA_SETPa(ai, type, base, in[i]); \ - base += stride; \ - } \ - } - -#define NA_SET1Df(ai, type, base, cnt, in) \ - { int i, stride = ai->strides[ai->nd-1]; \ - for(i=0; i<cnt; i++) { \ - NA_SETPf(ai, type, base, in[i]); \ - base += stride; \ - } \ - } - -#define NA_SET1D(ai, type, base, cnt, out) \ - if (PyArray_ISCARRAY(ai)) { \ - NA_SET1Df(ai, type, base, cnt, out); \ - } else if (PyArray_ISBYTESWAPPED(ai)) { \ - NA_SET1Db(ai, type, base, cnt, out); \ - } else { \ - NA_SET1Da(ai, type, base, cnt, out); \ - } - -/* ========================== utilities ================================== */ - -#if !defined(MIN) -#define MIN(x,y) (((x)<=(y)) ? (x) : (y)) -#endif - -#if !defined(MAX) -#define MAX(x,y) (((x)>=(y)) ? (x) : (y)) -#endif - -#if !defined(ABS) -#define ABS(x) (((x) >= 0) ? (x) : -(x)) -#endif - -#define ELEM(x) (sizeof(x)/sizeof(x[0])) - -#define BOOLEAN_BITWISE_NOT(x) ((x) ^ 1) - -#define NA_NBYTES(a) (a->descr->elsize * NA_elements(a)) - -#if defined(NA_SMP) -#define BEGIN_THREADS Py_BEGIN_ALLOW_THREADS -#define END_THREADS Py_END_ALLOW_THREADS -#else -#define BEGIN_THREADS -#define END_THREADS -#endif - -#if !defined(NA_isnan) - -#define U32(u) (* (Int32 *) &(u) ) -#define U64(u) (* (Int64 *) &(u) ) - -#define NA_isnan32(u) \ - ( (( U32(u) & 0x7f800000) == 0x7f800000) && ((U32(u) & 0x007fffff) != 0)) ? 1:0 - -#if !defined(_MSC_VER) -#define NA_isnan64(u) \ - ( (( U64(u) & 0x7ff0000000000000LL) == 0x7ff0000000000000LL) && ((U64(u) & 0x000fffffffffffffLL) != 0)) ? 1:0 -#else -#define NA_isnan64(u) \ - ( (( U64(u) & 0x7ff0000000000000i64) == 0x7ff0000000000000i64) && ((U64(u) & 0x000fffffffffffffi64) != 0)) ? 1:0 -#endif - -#define NA_isnanC32(u) (NA_isnan32(((Complex32 *)&(u))->r) || NA_isnan32(((Complex32 *)&(u))->i)) -#define NA_isnanC64(u) (NA_isnan64(((Complex64 *)&(u))->r) || NA_isnan64(((Complex64 *)&(u))->i)) - -#endif /* NA_isnan */ - - -#endif /* _ndarraymacro */ |