00001
00002
00003 #define PY_SSIZE_T_CLEAN
00004 #include "Python.h"
00005 #ifndef Py_PYTHON_H
00006 #error Python headers needed to compile C extensions, please install development version of Python.
00007 #elif PY_VERSION_HEX < 0x02060000 || (0x03000000 <= PY_VERSION_HEX && PY_VERSION_HEX < 0x03020000)
00008 #error Cython requires Python 2.6+ or Python 3.2+.
00009 #else
00010 #define CYTHON_ABI "0_25_2"
00011 #include <stddef.h>
00012 #ifndef offsetof
00013 #define offsetof(type, member) ( (size_t) & ((type*)0) -> member )
00014 #endif
00015 #if !defined(WIN32) && !defined(MS_WINDOWS)
00016 #ifndef __stdcall
00017 #define __stdcall
00018 #endif
00019 #ifndef __cdecl
00020 #define __cdecl
00021 #endif
00022 #ifndef __fastcall
00023 #define __fastcall
00024 #endif
00025 #endif
00026 #ifndef DL_IMPORT
00027 #define DL_IMPORT(t) t
00028 #endif
00029 #ifndef DL_EXPORT
00030 #define DL_EXPORT(t) t
00031 #endif
00032 #ifndef HAVE_LONG_LONG
00033 #if PY_VERSION_HEX >= 0x03030000 || (PY_MAJOR_VERSION == 2 && PY_VERSION_HEX >= 0x02070000)
00034 #define HAVE_LONG_LONG
00035 #endif
00036 #endif
00037 #ifndef PY_LONG_LONG
00038 #define PY_LONG_LONG LONG_LONG
00039 #endif
00040 #ifndef Py_HUGE_VAL
00041 #define Py_HUGE_VAL HUGE_VAL
00042 #endif
00043 #ifdef PYPY_VERSION
00044 #define CYTHON_COMPILING_IN_PYPY 1
00045 #define CYTHON_COMPILING_IN_PYSTON 0
00046 #define CYTHON_COMPILING_IN_CPYTHON 0
00047 #undef CYTHON_USE_TYPE_SLOTS
00048 #define CYTHON_USE_TYPE_SLOTS 0
00049 #undef CYTHON_USE_ASYNC_SLOTS
00050 #define CYTHON_USE_ASYNC_SLOTS 0
00051 #undef CYTHON_USE_PYLIST_INTERNALS
00052 #define CYTHON_USE_PYLIST_INTERNALS 0
00053 #undef CYTHON_USE_UNICODE_INTERNALS
00054 #define CYTHON_USE_UNICODE_INTERNALS 0
00055 #undef CYTHON_USE_UNICODE_WRITER
00056 #define CYTHON_USE_UNICODE_WRITER 0
00057 #undef CYTHON_USE_PYLONG_INTERNALS
00058 #define CYTHON_USE_PYLONG_INTERNALS 0
00059 #undef CYTHON_AVOID_BORROWED_REFS
00060 #define CYTHON_AVOID_BORROWED_REFS 1
00061 #undef CYTHON_ASSUME_SAFE_MACROS
00062 #define CYTHON_ASSUME_SAFE_MACROS 0
00063 #undef CYTHON_UNPACK_METHODS
00064 #define CYTHON_UNPACK_METHODS 0
00065 #undef CYTHON_FAST_THREAD_STATE
00066 #define CYTHON_FAST_THREAD_STATE 0
00067 #undef CYTHON_FAST_PYCALL
00068 #define CYTHON_FAST_PYCALL 0
00069 #elif defined(PYSTON_VERSION)
00070 #define CYTHON_COMPILING_IN_PYPY 0
00071 #define CYTHON_COMPILING_IN_PYSTON 1
00072 #define CYTHON_COMPILING_IN_CPYTHON 0
00073 #ifndef CYTHON_USE_TYPE_SLOTS
00074 #define CYTHON_USE_TYPE_SLOTS 1
00075 #endif
00076 #undef CYTHON_USE_ASYNC_SLOTS
00077 #define CYTHON_USE_ASYNC_SLOTS 0
00078 #undef CYTHON_USE_PYLIST_INTERNALS
00079 #define CYTHON_USE_PYLIST_INTERNALS 0
00080 #ifndef CYTHON_USE_UNICODE_INTERNALS
00081 #define CYTHON_USE_UNICODE_INTERNALS 1
00082 #endif
00083 #undef CYTHON_USE_UNICODE_WRITER
00084 #define CYTHON_USE_UNICODE_WRITER 0
00085 #undef CYTHON_USE_PYLONG_INTERNALS
00086 #define CYTHON_USE_PYLONG_INTERNALS 0
00087 #ifndef CYTHON_AVOID_BORROWED_REFS
00088 #define CYTHON_AVOID_BORROWED_REFS 0
00089 #endif
00090 #ifndef CYTHON_ASSUME_SAFE_MACROS
00091 #define CYTHON_ASSUME_SAFE_MACROS 1
00092 #endif
00093 #ifndef CYTHON_UNPACK_METHODS
00094 #define CYTHON_UNPACK_METHODS 1
00095 #endif
00096 #undef CYTHON_FAST_THREAD_STATE
00097 #define CYTHON_FAST_THREAD_STATE 0
00098 #undef CYTHON_FAST_PYCALL
00099 #define CYTHON_FAST_PYCALL 0
00100 #else
00101 #define CYTHON_COMPILING_IN_PYPY 0
00102 #define CYTHON_COMPILING_IN_PYSTON 0
00103 #define CYTHON_COMPILING_IN_CPYTHON 1
00104 #ifndef CYTHON_USE_TYPE_SLOTS
00105 #define CYTHON_USE_TYPE_SLOTS 1
00106 #endif
00107 #if PY_MAJOR_VERSION < 3
00108 #undef CYTHON_USE_ASYNC_SLOTS
00109 #define CYTHON_USE_ASYNC_SLOTS 0
00110 #elif !defined(CYTHON_USE_ASYNC_SLOTS)
00111 #define CYTHON_USE_ASYNC_SLOTS 1
00112 #endif
00113 #if PY_VERSION_HEX < 0x02070000
00114 #undef CYTHON_USE_PYLONG_INTERNALS
00115 #define CYTHON_USE_PYLONG_INTERNALS 0
00116 #elif !defined(CYTHON_USE_PYLONG_INTERNALS)
00117 #define CYTHON_USE_PYLONG_INTERNALS 1
00118 #endif
00119 #ifndef CYTHON_USE_PYLIST_INTERNALS
00120 #define CYTHON_USE_PYLIST_INTERNALS 1
00121 #endif
00122 #ifndef CYTHON_USE_UNICODE_INTERNALS
00123 #define CYTHON_USE_UNICODE_INTERNALS 1
00124 #endif
00125 #if PY_VERSION_HEX < 0x030300F0
00126 #undef CYTHON_USE_UNICODE_WRITER
00127 #define CYTHON_USE_UNICODE_WRITER 0
00128 #elif !defined(CYTHON_USE_UNICODE_WRITER)
00129 #define CYTHON_USE_UNICODE_WRITER 1
00130 #endif
00131 #ifndef CYTHON_AVOID_BORROWED_REFS
00132 #define CYTHON_AVOID_BORROWED_REFS 0
00133 #endif
00134 #ifndef CYTHON_ASSUME_SAFE_MACROS
00135 #define CYTHON_ASSUME_SAFE_MACROS 1
00136 #endif
00137 #ifndef CYTHON_UNPACK_METHODS
00138 #define CYTHON_UNPACK_METHODS 1
00139 #endif
00140 #ifndef CYTHON_FAST_THREAD_STATE
00141 #define CYTHON_FAST_THREAD_STATE 1
00142 #endif
00143 #ifndef CYTHON_FAST_PYCALL
00144 #define CYTHON_FAST_PYCALL 1
00145 #endif
00146 #endif
00147 #if !defined(CYTHON_FAST_PYCCALL)
00148 #define CYTHON_FAST_PYCCALL (CYTHON_FAST_PYCALL && PY_VERSION_HEX >= 0x030600B1)
00149 #endif
00150 #if CYTHON_USE_PYLONG_INTERNALS
00151 #include "longintrepr.h"
00152 #undef SHIFT
00153 #undef BASE
00154 #undef MASK
00155 #endif
00156 #if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX < 0x02070600 && !defined(Py_OptimizeFlag)
00157 #define Py_OptimizeFlag 0
00158 #endif
00159 #define __PYX_BUILD_PY_SSIZE_T "n"
00160 #define CYTHON_FORMAT_SSIZE_T "z"
00161 #if PY_MAJOR_VERSION < 3
00162 #define __Pyx_BUILTIN_MODULE_NAME "__builtin__"
00163 #define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)\
00164 PyCode_New(a+k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)
00165 #define __Pyx_DefaultClassType PyClass_Type
00166 #else
00167 #define __Pyx_BUILTIN_MODULE_NAME "builtins"
00168 #define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)\
00169 PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)
00170 #define __Pyx_DefaultClassType PyType_Type
00171 #endif
00172 #ifndef Py_TPFLAGS_CHECKTYPES
00173 #define Py_TPFLAGS_CHECKTYPES 0
00174 #endif
00175 #ifndef Py_TPFLAGS_HAVE_INDEX
00176 #define Py_TPFLAGS_HAVE_INDEX 0
00177 #endif
00178 #ifndef Py_TPFLAGS_HAVE_NEWBUFFER
00179 #define Py_TPFLAGS_HAVE_NEWBUFFER 0
00180 #endif
00181 #ifndef Py_TPFLAGS_HAVE_FINALIZE
00182 #define Py_TPFLAGS_HAVE_FINALIZE 0
00183 #endif
00184 #ifndef METH_FASTCALL
00185 #define METH_FASTCALL 0x80
00186 typedef PyObject *(*__Pyx_PyCFunctionFast) (PyObject *self, PyObject **args,
00187 Py_ssize_t nargs, PyObject *kwnames);
00188 #else
00189 #define __Pyx_PyCFunctionFast _PyCFunctionFast
00190 #endif
00191 #if CYTHON_FAST_PYCCALL
00192 #define __Pyx_PyFastCFunction_Check(func)\
00193 ((PyCFunction_Check(func) && (METH_FASTCALL == (PyCFunction_GET_FLAGS(func) & ~(METH_CLASS | METH_STATIC | METH_COEXIST)))))
00194 #else
00195 #define __Pyx_PyFastCFunction_Check(func) 0
00196 #endif
00197 #if PY_VERSION_HEX > 0x03030000 && defined(PyUnicode_KIND)
00198 #define CYTHON_PEP393_ENABLED 1
00199 #define __Pyx_PyUnicode_READY(op) (likely(PyUnicode_IS_READY(op)) ?\
00200 0 : _PyUnicode_Ready((PyObject *)(op)))
00201 #define __Pyx_PyUnicode_GET_LENGTH(u) PyUnicode_GET_LENGTH(u)
00202 #define __Pyx_PyUnicode_READ_CHAR(u, i) PyUnicode_READ_CHAR(u, i)
00203 #define __Pyx_PyUnicode_MAX_CHAR_VALUE(u) PyUnicode_MAX_CHAR_VALUE(u)
00204 #define __Pyx_PyUnicode_KIND(u) PyUnicode_KIND(u)
00205 #define __Pyx_PyUnicode_DATA(u) PyUnicode_DATA(u)
00206 #define __Pyx_PyUnicode_READ(k, d, i) PyUnicode_READ(k, d, i)
00207 #define __Pyx_PyUnicode_WRITE(k, d, i, ch) PyUnicode_WRITE(k, d, i, ch)
00208 #define __Pyx_PyUnicode_IS_TRUE(u) (0 != (likely(PyUnicode_IS_READY(u)) ? PyUnicode_GET_LENGTH(u) : PyUnicode_GET_SIZE(u)))
00209 #else
00210 #define CYTHON_PEP393_ENABLED 0
00211 #define PyUnicode_1BYTE_KIND 1
00212 #define PyUnicode_2BYTE_KIND 2
00213 #define PyUnicode_4BYTE_KIND 4
00214 #define __Pyx_PyUnicode_READY(op) (0)
00215 #define __Pyx_PyUnicode_GET_LENGTH(u) PyUnicode_GET_SIZE(u)
00216 #define __Pyx_PyUnicode_READ_CHAR(u, i) ((Py_UCS4)(PyUnicode_AS_UNICODE(u)[i]))
00217 #define __Pyx_PyUnicode_MAX_CHAR_VALUE(u) ((sizeof(Py_UNICODE) == 2) ? 65535 : 1114111)
00218 #define __Pyx_PyUnicode_KIND(u) (sizeof(Py_UNICODE))
00219 #define __Pyx_PyUnicode_DATA(u) ((void*)PyUnicode_AS_UNICODE(u))
00220 #define __Pyx_PyUnicode_READ(k, d, i) ((void)(k), (Py_UCS4)(((Py_UNICODE*)d)[i]))
00221 #define __Pyx_PyUnicode_WRITE(k, d, i, ch) (((void)(k)), ((Py_UNICODE*)d)[i] = ch)
00222 #define __Pyx_PyUnicode_IS_TRUE(u) (0 != PyUnicode_GET_SIZE(u))
00223 #endif
00224 #if CYTHON_COMPILING_IN_PYPY
00225 #define __Pyx_PyUnicode_Concat(a, b) PyNumber_Add(a, b)
00226 #define __Pyx_PyUnicode_ConcatSafe(a, b) PyNumber_Add(a, b)
00227 #else
00228 #define __Pyx_PyUnicode_Concat(a, b) PyUnicode_Concat(a, b)
00229 #define __Pyx_PyUnicode_ConcatSafe(a, b) ((unlikely((a) == Py_None) || unlikely((b) == Py_None)) ?\
00230 PyNumber_Add(a, b) : __Pyx_PyUnicode_Concat(a, b))
00231 #endif
00232 #if CYTHON_COMPILING_IN_PYPY && !defined(PyUnicode_Contains)
00233 #define PyUnicode_Contains(u, s) PySequence_Contains(u, s)
00234 #endif
00235 #if CYTHON_COMPILING_IN_PYPY && !defined(PyByteArray_Check)
00236 #define PyByteArray_Check(obj) PyObject_TypeCheck(obj, &PyByteArray_Type)
00237 #endif
00238 #if CYTHON_COMPILING_IN_PYPY && !defined(PyObject_Format)
00239 #define PyObject_Format(obj, fmt) PyObject_CallMethod(obj, "__format__", "O", fmt)
00240 #endif
00241 #if CYTHON_COMPILING_IN_PYPY && !defined(PyObject_Malloc)
00242 #define PyObject_Malloc(s) PyMem_Malloc(s)
00243 #define PyObject_Free(p) PyMem_Free(p)
00244 #define PyObject_Realloc(p) PyMem_Realloc(p)
00245 #endif
00246 #if CYTHON_COMPILING_IN_PYSTON
00247 #define __Pyx_PyCode_HasFreeVars(co) PyCode_HasFreeVars(co)
00248 #define __Pyx_PyFrame_SetLineNumber(frame, lineno) PyFrame_SetLineNumber(frame, lineno)
00249 #else
00250 #define __Pyx_PyCode_HasFreeVars(co) (PyCode_GetNumFree(co) > 0)
00251 #define __Pyx_PyFrame_SetLineNumber(frame, lineno) (frame)->f_lineno = (lineno)
00252 #endif
00253 #define __Pyx_PyString_FormatSafe(a, b) ((unlikely((a) == Py_None)) ? PyNumber_Remainder(a, b) : __Pyx_PyString_Format(a, b))
00254 #define __Pyx_PyUnicode_FormatSafe(a, b) ((unlikely((a) == Py_None)) ? PyNumber_Remainder(a, b) : PyUnicode_Format(a, b))
00255 #if PY_MAJOR_VERSION >= 3
00256 #define __Pyx_PyString_Format(a, b) PyUnicode_Format(a, b)
00257 #else
00258 #define __Pyx_PyString_Format(a, b) PyString_Format(a, b)
00259 #endif
00260 #if PY_MAJOR_VERSION < 3 && !defined(PyObject_ASCII)
00261 #define PyObject_ASCII(o) PyObject_Repr(o)
00262 #endif
00263 #if PY_MAJOR_VERSION >= 3
00264 #define PyBaseString_Type PyUnicode_Type
00265 #define PyStringObject PyUnicodeObject
00266 #define PyString_Type PyUnicode_Type
00267 #define PyString_Check PyUnicode_Check
00268 #define PyString_CheckExact PyUnicode_CheckExact
00269 #endif
00270 #if PY_MAJOR_VERSION >= 3
00271 #define __Pyx_PyBaseString_Check(obj) PyUnicode_Check(obj)
00272 #define __Pyx_PyBaseString_CheckExact(obj) PyUnicode_CheckExact(obj)
00273 #else
00274 #define __Pyx_PyBaseString_Check(obj) (PyString_Check(obj) || PyUnicode_Check(obj))
00275 #define __Pyx_PyBaseString_CheckExact(obj) (PyString_CheckExact(obj) || PyUnicode_CheckExact(obj))
00276 #endif
00277 #ifndef PySet_CheckExact
00278 #define PySet_CheckExact(obj) (Py_TYPE(obj) == &PySet_Type)
00279 #endif
00280 #define __Pyx_TypeCheck(obj, type) PyObject_TypeCheck(obj, (PyTypeObject *)type)
00281 #define __Pyx_PyException_Check(obj) __Pyx_TypeCheck(obj, PyExc_Exception)
00282 #if PY_MAJOR_VERSION >= 3
00283 #define PyIntObject PyLongObject
00284 #define PyInt_Type PyLong_Type
00285 #define PyInt_Check(op) PyLong_Check(op)
00286 #define PyInt_CheckExact(op) PyLong_CheckExact(op)
00287 #define PyInt_FromString PyLong_FromString
00288 #define PyInt_FromUnicode PyLong_FromUnicode
00289 #define PyInt_FromLong PyLong_FromLong
00290 #define PyInt_FromSize_t PyLong_FromSize_t
00291 #define PyInt_FromSsize_t PyLong_FromSsize_t
00292 #define PyInt_AsLong PyLong_AsLong
00293 #define PyInt_AS_LONG PyLong_AS_LONG
00294 #define PyInt_AsSsize_t PyLong_AsSsize_t
00295 #define PyInt_AsUnsignedLongMask PyLong_AsUnsignedLongMask
00296 #define PyInt_AsUnsignedLongLongMask PyLong_AsUnsignedLongLongMask
00297 #define PyNumber_Int PyNumber_Long
00298 #endif
00299 #if PY_MAJOR_VERSION >= 3
00300 #define PyBoolObject PyLongObject
00301 #endif
00302 #if PY_MAJOR_VERSION >= 3 && CYTHON_COMPILING_IN_PYPY
00303 #ifndef PyUnicode_InternFromString
00304 #define PyUnicode_InternFromString(s) PyUnicode_FromString(s)
00305 #endif
00306 #endif
00307 #if PY_VERSION_HEX < 0x030200A4
00308 typedef long Py_hash_t;
00309 #define __Pyx_PyInt_FromHash_t PyInt_FromLong
00310 #define __Pyx_PyInt_AsHash_t PyInt_AsLong
00311 #else
00312 #define __Pyx_PyInt_FromHash_t PyInt_FromSsize_t
00313 #define __Pyx_PyInt_AsHash_t PyInt_AsSsize_t
00314 #endif
00315 #if PY_MAJOR_VERSION >= 3
00316 #define __Pyx_PyMethod_New(func, self, klass) ((self) ? PyMethod_New(func, self) : PyInstanceMethod_New(func))
00317 #else
00318 #define __Pyx_PyMethod_New(func, self, klass) PyMethod_New(func, self, klass)
00319 #endif
00320 #if CYTHON_USE_ASYNC_SLOTS
00321 #if PY_VERSION_HEX >= 0x030500B1
00322 #define __Pyx_PyAsyncMethodsStruct PyAsyncMethods
00323 #define __Pyx_PyType_AsAsync(obj) (Py_TYPE(obj)->tp_as_async)
00324 #else
00325 typedef struct {
00326 unaryfunc am_await;
00327 unaryfunc am_aiter;
00328 unaryfunc am_anext;
00329 } __Pyx_PyAsyncMethodsStruct;
00330 #define __Pyx_PyType_AsAsync(obj) ((__Pyx_PyAsyncMethodsStruct*) (Py_TYPE(obj)->tp_reserved))
00331 #endif
00332 #else
00333 #define __Pyx_PyType_AsAsync(obj) NULL
00334 #endif
00335 #ifndef CYTHON_RESTRICT
00336 #if defined(__GNUC__)
00337 #define CYTHON_RESTRICT __restrict__
00338 #elif defined(_MSC_VER) && _MSC_VER >= 1400
00339 #define CYTHON_RESTRICT __restrict
00340 #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
00341 #define CYTHON_RESTRICT restrict
00342 #else
00343 #define CYTHON_RESTRICT
00344 #endif
00345 #endif
00346 #ifndef CYTHON_UNUSED
00347 # if defined(__GNUC__)
00348 # if !(defined(__cplusplus)) || (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4))
00349 # define CYTHON_UNUSED __attribute__ ((__unused__))
00350 # else
00351 # define CYTHON_UNUSED
00352 # endif
00353 # elif defined(__ICC) || (defined(__INTEL_COMPILER) && !defined(_MSC_VER))
00354 # define CYTHON_UNUSED __attribute__ ((__unused__))
00355 # else
00356 # define CYTHON_UNUSED
00357 # endif
00358 #endif
00359 #ifndef CYTHON_MAYBE_UNUSED_VAR
00360 # if defined(__cplusplus)
00361 template<class T> void CYTHON_MAYBE_UNUSED_VAR( const T& ) { }
00362 # else
00363 # define CYTHON_MAYBE_UNUSED_VAR(x) (void)(x)
00364 # endif
00365 #endif
00366 #ifndef CYTHON_NCP_UNUSED
00367 # if CYTHON_COMPILING_IN_CPYTHON
00368 # define CYTHON_NCP_UNUSED
00369 # else
00370 # define CYTHON_NCP_UNUSED CYTHON_UNUSED
00371 # endif
00372 #endif
00373 #define __Pyx_void_to_None(void_result) ((void)(void_result), Py_INCREF(Py_None), Py_None)
00374
00375 #ifndef CYTHON_INLINE
00376 #if defined(__clang__)
00377 #define CYTHON_INLINE __inline__ __attribute__ ((__unused__))
00378 #elif defined(__GNUC__)
00379 #define CYTHON_INLINE __inline__
00380 #elif defined(_MSC_VER)
00381 #define CYTHON_INLINE __inline
00382 #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
00383 #define CYTHON_INLINE inline
00384 #else
00385 #define CYTHON_INLINE
00386 #endif
00387 #endif
00388
00389 #if defined(WIN32) || defined(MS_WINDOWS)
00390 #define _USE_MATH_DEFINES
00391 #endif
00392 #include <math.h>
00393 #ifdef NAN
00394 #define __PYX_NAN() ((float) NAN)
00395 #else
00396 static CYTHON_INLINE float __PYX_NAN() {
00397 float value;
00398 memset(&value, 0xFF, sizeof(value));
00399 return value;
00400 }
00401 #endif
00402 #if defined(__CYGWIN__) && defined(_LDBL_EQ_DBL)
00403 #define __Pyx_truncl trunc
00404 #else
00405 #define __Pyx_truncl truncl
00406 #endif
00407
00408
00409 #define __PYX_ERR(f_index, lineno, Ln_error) \
00410 { \
00411 __pyx_filename = __pyx_f[f_index]; __pyx_lineno = lineno; __pyx_clineno = __LINE__; goto Ln_error; \
00412 }
00413
00414 #if PY_MAJOR_VERSION >= 3
00415 #define __Pyx_PyNumber_Divide(x,y) PyNumber_TrueDivide(x,y)
00416 #define __Pyx_PyNumber_InPlaceDivide(x,y) PyNumber_InPlaceTrueDivide(x,y)
00417 #else
00418 #define __Pyx_PyNumber_Divide(x,y) PyNumber_Divide(x,y)
00419 #define __Pyx_PyNumber_InPlaceDivide(x,y) PyNumber_InPlaceDivide(x,y)
00420 #endif
00421
00422 #ifndef __PYX_EXTERN_C
00423 #ifdef __cplusplus
00424 #define __PYX_EXTERN_C extern "C"
00425 #else
00426 #define __PYX_EXTERN_C extern
00427 #endif
00428 #endif
00429
00430 #define __PYX_HAVE__cpu_nms
00431 #define __PYX_HAVE_API__cpu_nms
00432 #include <string.h>
00433 #include <stdio.h>
00434 #include <stdlib.h>
00435 #include "numpy/arrayobject.h"
00436 #include "numpy/ufuncobject.h"
00437 #ifdef _OPENMP
00438 #include <omp.h>
00439 #endif
00440
00441 #ifdef PYREX_WITHOUT_ASSERTIONS
00442 #define CYTHON_WITHOUT_ASSERTIONS
00443 #endif
00444
00445 typedef struct {PyObject **p; const char *s; const Py_ssize_t n; const char* encoding;
00446 const char is_unicode; const char is_str; const char intern; } __Pyx_StringTabEntry;
00447
00448 #define __PYX_DEFAULT_STRING_ENCODING_IS_ASCII 0
00449 #define __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT 0
00450 #define __PYX_DEFAULT_STRING_ENCODING ""
00451 #define __Pyx_PyObject_FromString __Pyx_PyBytes_FromString
00452 #define __Pyx_PyObject_FromStringAndSize __Pyx_PyBytes_FromStringAndSize
00453 #define __Pyx_uchar_cast(c) ((unsigned char)c)
00454 #define __Pyx_long_cast(x) ((long)x)
00455 #define __Pyx_fits_Py_ssize_t(v, type, is_signed) (\
00456 (sizeof(type) < sizeof(Py_ssize_t)) ||\
00457 (sizeof(type) > sizeof(Py_ssize_t) &&\
00458 likely(v < (type)PY_SSIZE_T_MAX ||\
00459 v == (type)PY_SSIZE_T_MAX) &&\
00460 (!is_signed || likely(v > (type)PY_SSIZE_T_MIN ||\
00461 v == (type)PY_SSIZE_T_MIN))) ||\
00462 (sizeof(type) == sizeof(Py_ssize_t) &&\
00463 (is_signed || likely(v < (type)PY_SSIZE_T_MAX ||\
00464 v == (type)PY_SSIZE_T_MAX))) )
00465 #if defined (__cplusplus) && __cplusplus >= 201103L
00466 #include <cstdlib>
00467 #define __Pyx_sst_abs(value) std::abs(value)
00468 #elif SIZEOF_INT >= SIZEOF_SIZE_T
00469 #define __Pyx_sst_abs(value) abs(value)
00470 #elif SIZEOF_LONG >= SIZEOF_SIZE_T
00471 #define __Pyx_sst_abs(value) labs(value)
00472 #elif defined (_MSC_VER) && defined (_M_X64)
00473 #define __Pyx_sst_abs(value) _abs64(value)
00474 #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
00475 #define __Pyx_sst_abs(value) llabs(value)
00476 #elif defined (__GNUC__)
00477 #define __Pyx_sst_abs(value) __builtin_llabs(value)
00478 #else
00479 #define __Pyx_sst_abs(value) ((value<0) ? -value : value)
00480 #endif
00481 static CYTHON_INLINE char* __Pyx_PyObject_AsString(PyObject*);
00482 static CYTHON_INLINE char* __Pyx_PyObject_AsStringAndSize(PyObject*, Py_ssize_t* length);
00483 #define __Pyx_PyByteArray_FromString(s) PyByteArray_FromStringAndSize((const char*)s, strlen((const char*)s))
00484 #define __Pyx_PyByteArray_FromStringAndSize(s, l) PyByteArray_FromStringAndSize((const char*)s, l)
00485 #define __Pyx_PyBytes_FromString PyBytes_FromString
00486 #define __Pyx_PyBytes_FromStringAndSize PyBytes_FromStringAndSize
00487 static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(const char*);
00488 #if PY_MAJOR_VERSION < 3
00489 #define __Pyx_PyStr_FromString __Pyx_PyBytes_FromString
00490 #define __Pyx_PyStr_FromStringAndSize __Pyx_PyBytes_FromStringAndSize
00491 #else
00492 #define __Pyx_PyStr_FromString __Pyx_PyUnicode_FromString
00493 #define __Pyx_PyStr_FromStringAndSize __Pyx_PyUnicode_FromStringAndSize
00494 #endif
00495 #define __Pyx_PyObject_AsSString(s) ((signed char*) __Pyx_PyObject_AsString(s))
00496 #define __Pyx_PyObject_AsUString(s) ((unsigned char*) __Pyx_PyObject_AsString(s))
00497 #define __Pyx_PyObject_FromCString(s) __Pyx_PyObject_FromString((const char*)s)
00498 #define __Pyx_PyBytes_FromCString(s) __Pyx_PyBytes_FromString((const char*)s)
00499 #define __Pyx_PyByteArray_FromCString(s) __Pyx_PyByteArray_FromString((const char*)s)
00500 #define __Pyx_PyStr_FromCString(s) __Pyx_PyStr_FromString((const char*)s)
00501 #define __Pyx_PyUnicode_FromCString(s) __Pyx_PyUnicode_FromString((const char*)s)
00502 #if PY_MAJOR_VERSION < 3
00503 static CYTHON_INLINE size_t __Pyx_Py_UNICODE_strlen(const Py_UNICODE *u)
00504 {
00505 const Py_UNICODE *u_end = u;
00506 while (*u_end++) ;
00507 return (size_t)(u_end - u - 1);
00508 }
00509 #else
00510 #define __Pyx_Py_UNICODE_strlen Py_UNICODE_strlen
00511 #endif
00512 #define __Pyx_PyUnicode_FromUnicode(u) PyUnicode_FromUnicode(u, __Pyx_Py_UNICODE_strlen(u))
00513 #define __Pyx_PyUnicode_FromUnicodeAndLength PyUnicode_FromUnicode
00514 #define __Pyx_PyUnicode_AsUnicode PyUnicode_AsUnicode
00515 #define __Pyx_NewRef(obj) (Py_INCREF(obj), obj)
00516 #define __Pyx_Owned_Py_None(b) __Pyx_NewRef(Py_None)
00517 #define __Pyx_PyBool_FromLong(b) ((b) ? __Pyx_NewRef(Py_True) : __Pyx_NewRef(Py_False))
00518 static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject*);
00519 static CYTHON_INLINE PyObject* __Pyx_PyNumber_IntOrLong(PyObject* x);
00520 static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject*);
00521 static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t);
00522 #if CYTHON_ASSUME_SAFE_MACROS
00523 #define __pyx_PyFloat_AsDouble(x) (PyFloat_CheckExact(x) ? PyFloat_AS_DOUBLE(x) : PyFloat_AsDouble(x))
00524 #else
00525 #define __pyx_PyFloat_AsDouble(x) PyFloat_AsDouble(x)
00526 #endif
00527 #define __pyx_PyFloat_AsFloat(x) ((float) __pyx_PyFloat_AsDouble(x))
00528 #if PY_MAJOR_VERSION >= 3
00529 #define __Pyx_PyNumber_Int(x) (PyLong_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Long(x))
00530 #else
00531 #define __Pyx_PyNumber_Int(x) (PyInt_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Int(x))
00532 #endif
00533 #define __Pyx_PyNumber_Float(x) (PyFloat_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Float(x))
00534 #if PY_MAJOR_VERSION < 3 && __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
00535 static int __Pyx_sys_getdefaultencoding_not_ascii;
00536 static int __Pyx_init_sys_getdefaultencoding_params(void) {
00537 PyObject* sys;
00538 PyObject* default_encoding = NULL;
00539 PyObject* ascii_chars_u = NULL;
00540 PyObject* ascii_chars_b = NULL;
00541 const char* default_encoding_c;
00542 sys = PyImport_ImportModule("sys");
00543 if (!sys) goto bad;
00544 default_encoding = PyObject_CallMethod(sys, (char*) "getdefaultencoding", NULL);
00545 Py_DECREF(sys);
00546 if (!default_encoding) goto bad;
00547 default_encoding_c = PyBytes_AsString(default_encoding);
00548 if (!default_encoding_c) goto bad;
00549 if (strcmp(default_encoding_c, "ascii") == 0) {
00550 __Pyx_sys_getdefaultencoding_not_ascii = 0;
00551 } else {
00552 char ascii_chars[128];
00553 int c;
00554 for (c = 0; c < 128; c++) {
00555 ascii_chars[c] = c;
00556 }
00557 __Pyx_sys_getdefaultencoding_not_ascii = 1;
00558 ascii_chars_u = PyUnicode_DecodeASCII(ascii_chars, 128, NULL);
00559 if (!ascii_chars_u) goto bad;
00560 ascii_chars_b = PyUnicode_AsEncodedString(ascii_chars_u, default_encoding_c, NULL);
00561 if (!ascii_chars_b || !PyBytes_Check(ascii_chars_b) || memcmp(ascii_chars, PyBytes_AS_STRING(ascii_chars_b), 128) != 0) {
00562 PyErr_Format(
00563 PyExc_ValueError,
00564 "This module compiled with c_string_encoding=ascii, but default encoding '%.200s' is not a superset of ascii.",
00565 default_encoding_c);
00566 goto bad;
00567 }
00568 Py_DECREF(ascii_chars_u);
00569 Py_DECREF(ascii_chars_b);
00570 }
00571 Py_DECREF(default_encoding);
00572 return 0;
00573 bad:
00574 Py_XDECREF(default_encoding);
00575 Py_XDECREF(ascii_chars_u);
00576 Py_XDECREF(ascii_chars_b);
00577 return -1;
00578 }
00579 #endif
00580 #if __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT && PY_MAJOR_VERSION >= 3
00581 #define __Pyx_PyUnicode_FromStringAndSize(c_str, size) PyUnicode_DecodeUTF8(c_str, size, NULL)
00582 #else
00583 #define __Pyx_PyUnicode_FromStringAndSize(c_str, size) PyUnicode_Decode(c_str, size, __PYX_DEFAULT_STRING_ENCODING, NULL)
00584 #if __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT
00585 static char* __PYX_DEFAULT_STRING_ENCODING;
00586 static int __Pyx_init_sys_getdefaultencoding_params(void) {
00587 PyObject* sys;
00588 PyObject* default_encoding = NULL;
00589 char* default_encoding_c;
00590 sys = PyImport_ImportModule("sys");
00591 if (!sys) goto bad;
00592 default_encoding = PyObject_CallMethod(sys, (char*) (const char*) "getdefaultencoding", NULL);
00593 Py_DECREF(sys);
00594 if (!default_encoding) goto bad;
00595 default_encoding_c = PyBytes_AsString(default_encoding);
00596 if (!default_encoding_c) goto bad;
00597 __PYX_DEFAULT_STRING_ENCODING = (char*) malloc(strlen(default_encoding_c));
00598 if (!__PYX_DEFAULT_STRING_ENCODING) goto bad;
00599 strcpy(__PYX_DEFAULT_STRING_ENCODING, default_encoding_c);
00600 Py_DECREF(default_encoding);
00601 return 0;
00602 bad:
00603 Py_XDECREF(default_encoding);
00604 return -1;
00605 }
00606 #endif
00607 #endif
00608
00609
00610
00611 #if defined(__GNUC__) && (__GNUC__ > 2 || (__GNUC__ == 2 && (__GNUC_MINOR__ > 95)))
00612 #define likely(x) __builtin_expect(!!(x), 1)
00613 #define unlikely(x) __builtin_expect(!!(x), 0)
00614 #else
00615 #define likely(x) (x)
00616 #define unlikely(x) (x)
00617 #endif
00618
00619 static PyObject *__pyx_m;
00620 static PyObject *__pyx_d;
00621 static PyObject *__pyx_b;
00622 static PyObject *__pyx_empty_tuple;
00623 static PyObject *__pyx_empty_bytes;
00624 static PyObject *__pyx_empty_unicode;
00625 static int __pyx_lineno;
00626 static int __pyx_clineno = 0;
00627 static const char * __pyx_cfilenm= __FILE__;
00628 static const char *__pyx_filename;
00629
00630
00631 #if !defined(CYTHON_CCOMPLEX)
00632 #if defined(__cplusplus)
00633 #define CYTHON_CCOMPLEX 1
00634 #elif defined(_Complex_I)
00635 #define CYTHON_CCOMPLEX 1
00636 #else
00637 #define CYTHON_CCOMPLEX 0
00638 #endif
00639 #endif
00640 #if CYTHON_CCOMPLEX
00641 #ifdef __cplusplus
00642 #include <complex>
00643 #else
00644 #include <complex.h>
00645 #endif
00646 #endif
00647 #if CYTHON_CCOMPLEX && !defined(__cplusplus) && defined(__sun__) && defined(__GNUC__)
00648 #undef _Complex_I
00649 #define _Complex_I 1.0fj
00650 #endif
00651
00652
00653 static const char *__pyx_f[] = {
00654 "cpu_nms.pyx",
00655 "__init__.pxd",
00656 "type.pxd",
00657 };
00658
00659 #define IS_UNSIGNED(type) (((type) -1) > 0)
00660 struct __Pyx_StructField_;
00661 #define __PYX_BUF_FLAGS_PACKED_STRUCT (1 << 0)
00662 typedef struct {
00663 const char* name;
00664 struct __Pyx_StructField_* fields;
00665 size_t size;
00666 size_t arraysize[8];
00667 int ndim;
00668 char typegroup;
00669 char is_unsigned;
00670 int flags;
00671 } __Pyx_TypeInfo;
00672 typedef struct __Pyx_StructField_ {
00673 __Pyx_TypeInfo* type;
00674 const char* name;
00675 size_t offset;
00676 } __Pyx_StructField;
00677 typedef struct {
00678 __Pyx_StructField* field;
00679 size_t parent_offset;
00680 } __Pyx_BufFmt_StackElem;
00681 typedef struct {
00682 __Pyx_StructField root;
00683 __Pyx_BufFmt_StackElem* head;
00684 size_t fmt_offset;
00685 size_t new_count, enc_count;
00686 size_t struct_alignment;
00687 int is_complex;
00688 char enc_type;
00689 char new_packmode;
00690 char enc_packmode;
00691 char is_valid_array;
00692 } __Pyx_BufFmt_Context;
00693
00694
00695
00696
00697
00698
00699
00700
00701
00702 typedef npy_int8 __pyx_t_5numpy_int8_t;
00703
00704
00705
00706
00707
00708
00709
00710
00711 typedef npy_int16 __pyx_t_5numpy_int16_t;
00712
00713
00714
00715
00716
00717
00718
00719
00720 typedef npy_int32 __pyx_t_5numpy_int32_t;
00721
00722
00723
00724
00725
00726
00727
00728
00729 typedef npy_int64 __pyx_t_5numpy_int64_t;
00730
00731
00732
00733
00734
00735
00736
00737
00738 typedef npy_uint8 __pyx_t_5numpy_uint8_t;
00739
00740
00741
00742
00743
00744
00745
00746
00747 typedef npy_uint16 __pyx_t_5numpy_uint16_t;
00748
00749
00750
00751
00752
00753
00754
00755
00756 typedef npy_uint32 __pyx_t_5numpy_uint32_t;
00757
00758
00759
00760
00761
00762
00763
00764
00765 typedef npy_uint64 __pyx_t_5numpy_uint64_t;
00766
00767
00768
00769
00770
00771
00772
00773
00774 typedef npy_float32 __pyx_t_5numpy_float32_t;
00775
00776
00777
00778
00779
00780
00781
00782
00783 typedef npy_float64 __pyx_t_5numpy_float64_t;
00784
00785
00786
00787
00788
00789
00790
00791
00792 typedef npy_long __pyx_t_5numpy_int_t;
00793
00794
00795
00796
00797
00798
00799
00800
00801 typedef npy_longlong __pyx_t_5numpy_long_t;
00802
00803
00804
00805
00806
00807
00808
00809
00810 typedef npy_longlong __pyx_t_5numpy_longlong_t;
00811
00812
00813
00814
00815
00816
00817
00818
00819 typedef npy_ulong __pyx_t_5numpy_uint_t;
00820
00821
00822
00823
00824
00825
00826
00827
00828 typedef npy_ulonglong __pyx_t_5numpy_ulong_t;
00829
00830
00831
00832
00833
00834
00835
00836
00837 typedef npy_ulonglong __pyx_t_5numpy_ulonglong_t;
00838
00839
00840
00841
00842
00843
00844
00845
00846 typedef npy_intp __pyx_t_5numpy_intp_t;
00847
00848
00849
00850
00851
00852
00853
00854
00855 typedef npy_uintp __pyx_t_5numpy_uintp_t;
00856
00857
00858
00859
00860
00861
00862
00863
00864 typedef npy_double __pyx_t_5numpy_float_t;
00865
00866
00867
00868
00869
00870
00871
00872
00873 typedef npy_double __pyx_t_5numpy_double_t;
00874
00875
00876
00877
00878
00879
00880
00881
00882 typedef npy_longdouble __pyx_t_5numpy_longdouble_t;
00883
00884 #if CYTHON_CCOMPLEX
00885 #ifdef __cplusplus
00886 typedef ::std::complex< float > __pyx_t_float_complex;
00887 #else
00888 typedef float _Complex __pyx_t_float_complex;
00889 #endif
00890 #else
00891 typedef struct { float real, imag; } __pyx_t_float_complex;
00892 #endif
00893 static CYTHON_INLINE __pyx_t_float_complex __pyx_t_float_complex_from_parts(float, float);
00894
00895
00896 #if CYTHON_CCOMPLEX
00897 #ifdef __cplusplus
00898 typedef ::std::complex< double > __pyx_t_double_complex;
00899 #else
00900 typedef double _Complex __pyx_t_double_complex;
00901 #endif
00902 #else
00903 typedef struct { double real, imag; } __pyx_t_double_complex;
00904 #endif
00905 static CYTHON_INLINE __pyx_t_double_complex __pyx_t_double_complex_from_parts(double, double);
00906
00907
00908
00909
00910
00911
00912
00913
00914
00915
00916
00917 typedef npy_cfloat __pyx_t_5numpy_cfloat_t;
00918
00919
00920
00921
00922
00923
00924
00925
00926 typedef npy_cdouble __pyx_t_5numpy_cdouble_t;
00927
00928
00929
00930
00931
00932
00933
00934
00935 typedef npy_clongdouble __pyx_t_5numpy_clongdouble_t;
00936
00937
00938
00939
00940
00941
00942
00943
00944 typedef npy_cdouble __pyx_t_5numpy_complex_t;
00945
00946
00947
00948 #ifndef CYTHON_REFNANNY
00949 #define CYTHON_REFNANNY 0
00950 #endif
00951 #if CYTHON_REFNANNY
00952 typedef struct {
00953 void (*INCREF)(void*, PyObject*, int);
00954 void (*DECREF)(void*, PyObject*, int);
00955 void (*GOTREF)(void*, PyObject*, int);
00956 void (*GIVEREF)(void*, PyObject*, int);
00957 void* (*SetupContext)(const char*, int, const char*);
00958 void (*FinishContext)(void**);
00959 } __Pyx_RefNannyAPIStruct;
00960 static __Pyx_RefNannyAPIStruct *__Pyx_RefNanny = NULL;
00961 static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname);
00962 #define __Pyx_RefNannyDeclarations void *__pyx_refnanny = NULL;
00963 #ifdef WITH_THREAD
00964 #define __Pyx_RefNannySetupContext(name, acquire_gil)\
00965 if (acquire_gil) {\
00966 PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure();\
00967 __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__);\
00968 PyGILState_Release(__pyx_gilstate_save);\
00969 } else {\
00970 __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__);\
00971 }
00972 #else
00973 #define __Pyx_RefNannySetupContext(name, acquire_gil)\
00974 __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__)
00975 #endif
00976 #define __Pyx_RefNannyFinishContext()\
00977 __Pyx_RefNanny->FinishContext(&__pyx_refnanny)
00978 #define __Pyx_INCREF(r) __Pyx_RefNanny->INCREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
00979 #define __Pyx_DECREF(r) __Pyx_RefNanny->DECREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
00980 #define __Pyx_GOTREF(r) __Pyx_RefNanny->GOTREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
00981 #define __Pyx_GIVEREF(r) __Pyx_RefNanny->GIVEREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
00982 #define __Pyx_XINCREF(r) do { if((r) != NULL) {__Pyx_INCREF(r); }} while(0)
00983 #define __Pyx_XDECREF(r) do { if((r) != NULL) {__Pyx_DECREF(r); }} while(0)
00984 #define __Pyx_XGOTREF(r) do { if((r) != NULL) {__Pyx_GOTREF(r); }} while(0)
00985 #define __Pyx_XGIVEREF(r) do { if((r) != NULL) {__Pyx_GIVEREF(r);}} while(0)
00986 #else
00987 #define __Pyx_RefNannyDeclarations
00988 #define __Pyx_RefNannySetupContext(name, acquire_gil)
00989 #define __Pyx_RefNannyFinishContext()
00990 #define __Pyx_INCREF(r) Py_INCREF(r)
00991 #define __Pyx_DECREF(r) Py_DECREF(r)
00992 #define __Pyx_GOTREF(r)
00993 #define __Pyx_GIVEREF(r)
00994 #define __Pyx_XINCREF(r) Py_XINCREF(r)
00995 #define __Pyx_XDECREF(r) Py_XDECREF(r)
00996 #define __Pyx_XGOTREF(r)
00997 #define __Pyx_XGIVEREF(r)
00998 #endif
00999 #define __Pyx_XDECREF_SET(r, v) do {\
01000 PyObject *tmp = (PyObject *) r;\
01001 r = v; __Pyx_XDECREF(tmp);\
01002 } while (0)
01003 #define __Pyx_DECREF_SET(r, v) do {\
01004 PyObject *tmp = (PyObject *) r;\
01005 r = v; __Pyx_DECREF(tmp);\
01006 } while (0)
01007 #define __Pyx_CLEAR(r) do { PyObject* tmp = ((PyObject*)(r)); r = NULL; __Pyx_DECREF(tmp);} while(0)
01008 #define __Pyx_XCLEAR(r) do { if((r) != NULL) {PyObject* tmp = ((PyObject*)(r)); r = NULL; __Pyx_DECREF(tmp);}} while(0)
01009
01010
01011 #if CYTHON_USE_TYPE_SLOTS
01012 static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStr(PyObject* obj, PyObject* attr_name) {
01013 PyTypeObject* tp = Py_TYPE(obj);
01014 if (likely(tp->tp_getattro))
01015 return tp->tp_getattro(obj, attr_name);
01016 #if PY_MAJOR_VERSION < 3
01017 if (likely(tp->tp_getattr))
01018 return tp->tp_getattr(obj, PyString_AS_STRING(attr_name));
01019 #endif
01020 return PyObject_GetAttr(obj, attr_name);
01021 }
01022 #else
01023 #define __Pyx_PyObject_GetAttrStr(o,n) PyObject_GetAttr(o,n)
01024 #endif
01025
01026
01027 static PyObject *__Pyx_GetBuiltinName(PyObject *name);
01028
01029
01030 static void __Pyx_RaiseArgtupleInvalid(const char* func_name, int exact,
01031 Py_ssize_t num_min, Py_ssize_t num_max, Py_ssize_t num_found);
01032
01033
01034 static void __Pyx_RaiseDoubleKeywordsError(const char* func_name, PyObject* kw_name);
01035
01036
01037 static int __Pyx_ParseOptionalKeywords(PyObject *kwds, PyObject **argnames[],\
01038 PyObject *kwds2, PyObject *values[], Py_ssize_t num_pos_args,\
01039 const char* function_name);
01040
01041
01042 static CYTHON_INLINE int __Pyx_ArgTypeTest(PyObject *obj, PyTypeObject *type, int none_allowed,
01043 const char *name, int exact);
01044
01045
01046 static CYTHON_INLINE int __Pyx_GetBufferAndValidate(Py_buffer* buf, PyObject* obj,
01047 __Pyx_TypeInfo* dtype, int flags, int nd, int cast, __Pyx_BufFmt_StackElem* stack);
01048 static CYTHON_INLINE void __Pyx_SafeReleaseBuffer(Py_buffer* info);
01049 static const char* __Pyx_BufFmt_CheckString(__Pyx_BufFmt_Context* ctx, const char* ts);
01050 static void __Pyx_BufFmt_Init(__Pyx_BufFmt_Context* ctx,
01051 __Pyx_BufFmt_StackElem* stack,
01052 __Pyx_TypeInfo* type);
01053
01054
01055 static CYTHON_INLINE int __Pyx_TypeTest(PyObject *obj, PyTypeObject *type);
01056
01057
01058 #if !CYTHON_COMPILING_IN_PYPY
01059 static PyObject* __Pyx_PyInt_AddObjC(PyObject *op1, PyObject *op2, long intval, int inplace);
01060 #else
01061 #define __Pyx_PyInt_AddObjC(op1, op2, intval, inplace)\
01062 (inplace ? PyNumber_InPlaceAdd(op1, op2) : PyNumber_Add(op1, op2))
01063 #endif
01064
01065
01066 #if CYTHON_FAST_PYCCALL
01067 static CYTHON_INLINE PyObject *__Pyx_PyCFunction_FastCall(PyObject *func, PyObject **args, Py_ssize_t nargs);
01068 #else
01069 #define __Pyx_PyCFunction_FastCall(func, args, nargs) (assert(0), NULL)
01070 #endif
01071
01072
01073 #if CYTHON_FAST_PYCALL
01074 #define __Pyx_PyFunction_FastCall(func, args, nargs)\
01075 __Pyx_PyFunction_FastCallDict((func), (args), (nargs), NULL)
01076 #if 1 || PY_VERSION_HEX < 0x030600B1
01077 static PyObject *__Pyx_PyFunction_FastCallDict(PyObject *func, PyObject **args, int nargs, PyObject *kwargs);
01078 #else
01079 #define __Pyx_PyFunction_FastCallDict(func, args, nargs, kwargs) _PyFunction_FastCallDict(func, args, nargs, kwargs)
01080 #endif
01081 #endif
01082
01083
01084 #if CYTHON_COMPILING_IN_CPYTHON
01085 static CYTHON_INLINE PyObject* __Pyx_PyObject_Call(PyObject *func, PyObject *arg, PyObject *kw);
01086 #else
01087 #define __Pyx_PyObject_Call(func, arg, kw) PyObject_Call(func, arg, kw)
01088 #endif
01089
01090
01091 #if CYTHON_COMPILING_IN_CPYTHON
01092 static CYTHON_INLINE PyObject* __Pyx_PyObject_CallMethO(PyObject *func, PyObject *arg);
01093 #endif
01094
01095
01096 static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg);
01097
01098
01099 #if CYTHON_COMPILING_IN_CPYTHON
01100 static CYTHON_INLINE PyObject* __Pyx_PyObject_CallNoArg(PyObject *func);
01101 #else
01102 #define __Pyx_PyObject_CallNoArg(func) __Pyx_PyObject_Call(func, __pyx_empty_tuple, NULL)
01103 #endif
01104
01105
01106 static CYTHON_INLINE PyObject *__Pyx_GetModuleGlobalName(PyObject *name);
01107
01108
01109 static void __Pyx_RaiseBufferIndexError(int axis);
01110
01111 #define __Pyx_BufPtrStrided1d(type, buf, i0, s0) (type)((char*)buf + i0 * s0)
01112
01113 #if CYTHON_USE_PYLIST_INTERNALS && CYTHON_ASSUME_SAFE_MACROS
01114 static CYTHON_INLINE int __Pyx_PyList_Append(PyObject* list, PyObject* x) {
01115 PyListObject* L = (PyListObject*) list;
01116 Py_ssize_t len = Py_SIZE(list);
01117 if (likely(L->allocated > len) & likely(len > (L->allocated >> 1))) {
01118 Py_INCREF(x);
01119 PyList_SET_ITEM(list, len, x);
01120 Py_SIZE(list) = len+1;
01121 return 0;
01122 }
01123 return PyList_Append(list, x);
01124 }
01125 #else
01126 #define __Pyx_PyList_Append(L,x) PyList_Append(L,x)
01127 #endif
01128
01129
01130 #if CYTHON_FAST_THREAD_STATE
01131 #define __Pyx_PyThreadState_declare PyThreadState *__pyx_tstate;
01132 #define __Pyx_PyThreadState_assign __pyx_tstate = PyThreadState_GET();
01133 #else
01134 #define __Pyx_PyThreadState_declare
01135 #define __Pyx_PyThreadState_assign
01136 #endif
01137
01138
01139 #if CYTHON_FAST_THREAD_STATE
01140 #define __Pyx_ErrRestoreWithState(type, value, tb) __Pyx_ErrRestoreInState(PyThreadState_GET(), type, value, tb)
01141 #define __Pyx_ErrFetchWithState(type, value, tb) __Pyx_ErrFetchInState(PyThreadState_GET(), type, value, tb)
01142 #define __Pyx_ErrRestore(type, value, tb) __Pyx_ErrRestoreInState(__pyx_tstate, type, value, tb)
01143 #define __Pyx_ErrFetch(type, value, tb) __Pyx_ErrFetchInState(__pyx_tstate, type, value, tb)
01144 static CYTHON_INLINE void __Pyx_ErrRestoreInState(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb);
01145 static CYTHON_INLINE void __Pyx_ErrFetchInState(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb);
01146 #else
01147 #define __Pyx_ErrRestoreWithState(type, value, tb) PyErr_Restore(type, value, tb)
01148 #define __Pyx_ErrFetchWithState(type, value, tb) PyErr_Fetch(type, value, tb)
01149 #define __Pyx_ErrRestore(type, value, tb) PyErr_Restore(type, value, tb)
01150 #define __Pyx_ErrFetch(type, value, tb) PyErr_Fetch(type, value, tb)
01151 #endif
01152
01153
01154 static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause);
01155
01156
01157 #if PY_MAJOR_VERSION >= 3 && !CYTHON_COMPILING_IN_PYPY
01158 static PyObject *__Pyx_PyDict_GetItem(PyObject *d, PyObject* key) {
01159 PyObject *value;
01160 value = PyDict_GetItemWithError(d, key);
01161 if (unlikely(!value)) {
01162 if (!PyErr_Occurred()) {
01163 PyObject* args = PyTuple_Pack(1, key);
01164 if (likely(args))
01165 PyErr_SetObject(PyExc_KeyError, args);
01166 Py_XDECREF(args);
01167 }
01168 return NULL;
01169 }
01170 Py_INCREF(value);
01171 return value;
01172 }
01173 #else
01174 #define __Pyx_PyDict_GetItem(d, key) PyObject_GetItem(d, key)
01175 #endif
01176
01177
01178 static CYTHON_INLINE void __Pyx_RaiseTooManyValuesError(Py_ssize_t expected);
01179
01180
01181 static CYTHON_INLINE void __Pyx_RaiseNeedMoreValuesError(Py_ssize_t index);
01182
01183
01184 static CYTHON_INLINE void __Pyx_RaiseNoneNotIterableError(void);
01185
01186
01187 #if CYTHON_FAST_THREAD_STATE
01188 #define __Pyx_ExceptionSave(type, value, tb) __Pyx__ExceptionSave(__pyx_tstate, type, value, tb)
01189 static CYTHON_INLINE void __Pyx__ExceptionSave(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb);
01190 #define __Pyx_ExceptionReset(type, value, tb) __Pyx__ExceptionReset(__pyx_tstate, type, value, tb)
01191 static CYTHON_INLINE void __Pyx__ExceptionReset(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb);
01192 #else
01193 #define __Pyx_ExceptionSave(type, value, tb) PyErr_GetExcInfo(type, value, tb)
01194 #define __Pyx_ExceptionReset(type, value, tb) PyErr_SetExcInfo(type, value, tb)
01195 #endif
01196
01197
01198 #if CYTHON_FAST_THREAD_STATE
01199 #define __Pyx_PyErr_ExceptionMatches(err) __Pyx_PyErr_ExceptionMatchesInState(__pyx_tstate, err)
01200 static CYTHON_INLINE int __Pyx_PyErr_ExceptionMatchesInState(PyThreadState* tstate, PyObject* err);
01201 #else
01202 #define __Pyx_PyErr_ExceptionMatches(err) PyErr_ExceptionMatches(err)
01203 #endif
01204
01205
01206 #if CYTHON_FAST_THREAD_STATE
01207 #define __Pyx_GetException(type, value, tb) __Pyx__GetException(__pyx_tstate, type, value, tb)
01208 static int __Pyx__GetException(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb);
01209 #else
01210 static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb);
01211 #endif
01212
01213
01214 static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, int level);
01215
01216
01217 typedef struct {
01218 PyCodeObject* code_object;
01219 int code_line;
01220 } __Pyx_CodeObjectCacheEntry;
01221 struct __Pyx_CodeObjectCache {
01222 int count;
01223 int max_count;
01224 __Pyx_CodeObjectCacheEntry* entries;
01225 };
01226 static struct __Pyx_CodeObjectCache __pyx_code_cache = {0,0,NULL};
01227 static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line);
01228 static PyCodeObject *__pyx_find_code_object(int code_line);
01229 static void __pyx_insert_code_object(int code_line, PyCodeObject* code_object);
01230
01231
01232 static void __Pyx_AddTraceback(const char *funcname, int c_line,
01233 int py_line, const char *filename);
01234
01235
01236 typedef struct {
01237 Py_ssize_t shape, strides, suboffsets;
01238 } __Pyx_Buf_DimInfo;
01239 typedef struct {
01240 size_t refcount;
01241 Py_buffer pybuffer;
01242 } __Pyx_Buffer;
01243 typedef struct {
01244 __Pyx_Buffer *rcbuffer;
01245 char *data;
01246 __Pyx_Buf_DimInfo diminfo[8];
01247 } __Pyx_LocalBuf_ND;
01248
01249 #if PY_MAJOR_VERSION < 3
01250 static int __Pyx_GetBuffer(PyObject *obj, Py_buffer *view, int flags);
01251 static void __Pyx_ReleaseBuffer(Py_buffer *view);
01252 #else
01253 #define __Pyx_GetBuffer PyObject_GetBuffer
01254 #define __Pyx_ReleaseBuffer PyBuffer_Release
01255 #endif
01256
01257
01258
01259 static Py_ssize_t __Pyx_zeros[] = {0, 0, 0, 0, 0, 0, 0, 0};
01260 static Py_ssize_t __Pyx_minusones[] = {-1, -1, -1, -1, -1, -1, -1, -1};
01261
01262
01263 static CYTHON_INLINE PyObject* __Pyx_PyInt_From_int(int value);
01264
01265
01266 static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value);
01267
01268
01269 #if CYTHON_CCOMPLEX
01270 #ifdef __cplusplus
01271 #define __Pyx_CREAL(z) ((z).real())
01272 #define __Pyx_CIMAG(z) ((z).imag())
01273 #else
01274 #define __Pyx_CREAL(z) (__real__(z))
01275 #define __Pyx_CIMAG(z) (__imag__(z))
01276 #endif
01277 #else
01278 #define __Pyx_CREAL(z) ((z).real)
01279 #define __Pyx_CIMAG(z) ((z).imag)
01280 #endif
01281 #if defined(__cplusplus) && CYTHON_CCOMPLEX\
01282 && (defined(_WIN32) || defined(__clang__) || (defined(__GNUC__) && (__GNUC__ >= 5 || __GNUC__ == 4 && __GNUC_MINOR__ >= 4 )) || __cplusplus >= 201103)
01283 #define __Pyx_SET_CREAL(z,x) ((z).real(x))
01284 #define __Pyx_SET_CIMAG(z,y) ((z).imag(y))
01285 #else
01286 #define __Pyx_SET_CREAL(z,x) __Pyx_CREAL(z) = (x)
01287 #define __Pyx_SET_CIMAG(z,y) __Pyx_CIMAG(z) = (y)
01288 #endif
01289
01290
01291 #if CYTHON_CCOMPLEX
01292 #define __Pyx_c_eq_float(a, b) ((a)==(b))
01293 #define __Pyx_c_sum_float(a, b) ((a)+(b))
01294 #define __Pyx_c_diff_float(a, b) ((a)-(b))
01295 #define __Pyx_c_prod_float(a, b) ((a)*(b))
01296 #define __Pyx_c_quot_float(a, b) ((a)/(b))
01297 #define __Pyx_c_neg_float(a) (-(a))
01298 #ifdef __cplusplus
01299 #define __Pyx_c_is_zero_float(z) ((z)==(float)0)
01300 #define __Pyx_c_conj_float(z) (::std::conj(z))
01301 #if 1
01302 #define __Pyx_c_abs_float(z) (::std::abs(z))
01303 #define __Pyx_c_pow_float(a, b) (::std::pow(a, b))
01304 #endif
01305 #else
01306 #define __Pyx_c_is_zero_float(z) ((z)==0)
01307 #define __Pyx_c_conj_float(z) (conjf(z))
01308 #if 1
01309 #define __Pyx_c_abs_float(z) (cabsf(z))
01310 #define __Pyx_c_pow_float(a, b) (cpowf(a, b))
01311 #endif
01312 #endif
01313 #else
01314 static CYTHON_INLINE int __Pyx_c_eq_float(__pyx_t_float_complex, __pyx_t_float_complex);
01315 static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_sum_float(__pyx_t_float_complex, __pyx_t_float_complex);
01316 static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_diff_float(__pyx_t_float_complex, __pyx_t_float_complex);
01317 static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_prod_float(__pyx_t_float_complex, __pyx_t_float_complex);
01318 static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_quot_float(__pyx_t_float_complex, __pyx_t_float_complex);
01319 static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_neg_float(__pyx_t_float_complex);
01320 static CYTHON_INLINE int __Pyx_c_is_zero_float(__pyx_t_float_complex);
01321 static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_conj_float(__pyx_t_float_complex);
01322 #if 1
01323 static CYTHON_INLINE float __Pyx_c_abs_float(__pyx_t_float_complex);
01324 static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_pow_float(__pyx_t_float_complex, __pyx_t_float_complex);
01325 #endif
01326 #endif
01327
01328
01329 #if CYTHON_CCOMPLEX
01330 #define __Pyx_c_eq_double(a, b) ((a)==(b))
01331 #define __Pyx_c_sum_double(a, b) ((a)+(b))
01332 #define __Pyx_c_diff_double(a, b) ((a)-(b))
01333 #define __Pyx_c_prod_double(a, b) ((a)*(b))
01334 #define __Pyx_c_quot_double(a, b) ((a)/(b))
01335 #define __Pyx_c_neg_double(a) (-(a))
01336 #ifdef __cplusplus
01337 #define __Pyx_c_is_zero_double(z) ((z)==(double)0)
01338 #define __Pyx_c_conj_double(z) (::std::conj(z))
01339 #if 1
01340 #define __Pyx_c_abs_double(z) (::std::abs(z))
01341 #define __Pyx_c_pow_double(a, b) (::std::pow(a, b))
01342 #endif
01343 #else
01344 #define __Pyx_c_is_zero_double(z) ((z)==0)
01345 #define __Pyx_c_conj_double(z) (conj(z))
01346 #if 1
01347 #define __Pyx_c_abs_double(z) (cabs(z))
01348 #define __Pyx_c_pow_double(a, b) (cpow(a, b))
01349 #endif
01350 #endif
01351 #else
01352 static CYTHON_INLINE int __Pyx_c_eq_double(__pyx_t_double_complex, __pyx_t_double_complex);
01353 static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_sum_double(__pyx_t_double_complex, __pyx_t_double_complex);
01354 static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_diff_double(__pyx_t_double_complex, __pyx_t_double_complex);
01355 static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_prod_double(__pyx_t_double_complex, __pyx_t_double_complex);
01356 static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_quot_double(__pyx_t_double_complex, __pyx_t_double_complex);
01357 static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_neg_double(__pyx_t_double_complex);
01358 static CYTHON_INLINE int __Pyx_c_is_zero_double(__pyx_t_double_complex);
01359 static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_conj_double(__pyx_t_double_complex);
01360 #if 1
01361 static CYTHON_INLINE double __Pyx_c_abs_double(__pyx_t_double_complex);
01362 static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_pow_double(__pyx_t_double_complex, __pyx_t_double_complex);
01363 #endif
01364 #endif
01365
01366
01367 static CYTHON_INLINE PyObject* __Pyx_PyInt_From_enum__NPY_TYPES(enum NPY_TYPES value);
01368
01369
01370 static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *);
01371
01372
01373 static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *);
01374
01375
01376 static int __Pyx_check_binary_version(void);
01377
01378
01379 #if !defined(__Pyx_PyIdentifier_FromString)
01380 #if PY_MAJOR_VERSION < 3
01381 #define __Pyx_PyIdentifier_FromString(s) PyString_FromString(s)
01382 #else
01383 #define __Pyx_PyIdentifier_FromString(s) PyUnicode_FromString(s)
01384 #endif
01385 #endif
01386
01387
01388 static PyObject *__Pyx_ImportModule(const char *name);
01389
01390
01391 static PyTypeObject *__Pyx_ImportType(const char *module_name, const char *class_name, size_t size, int strict);
01392
01393
01394 static int __Pyx_InitStrings(__Pyx_StringTabEntry *t);
01395
01396
01397
01398
01399
01400
01401
01402
01403
01404
01405
01406 static PyTypeObject *__pyx_ptype_7cpython_4type_type = 0;
01407
01408
01409
01410
01411
01412
01413
01414
01415
01416
01417
01418
01419 static PyTypeObject *__pyx_ptype_5numpy_dtype = 0;
01420 static PyTypeObject *__pyx_ptype_5numpy_flatiter = 0;
01421 static PyTypeObject *__pyx_ptype_5numpy_broadcast = 0;
01422 static PyTypeObject *__pyx_ptype_5numpy_ndarray = 0;
01423 static PyTypeObject *__pyx_ptype_5numpy_ufunc = 0;
01424 static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *, char *, char *, int *);
01425
01426
01427 static CYTHON_INLINE __pyx_t_5numpy_float32_t __pyx_f_7cpu_nms_max(__pyx_t_5numpy_float32_t, __pyx_t_5numpy_float32_t);
01428 static CYTHON_INLINE __pyx_t_5numpy_float32_t __pyx_f_7cpu_nms_min(__pyx_t_5numpy_float32_t, __pyx_t_5numpy_float32_t);
01429 static __Pyx_TypeInfo __Pyx_TypeInfo_nn___pyx_t_5numpy_float32_t = { "float32_t", NULL, sizeof(__pyx_t_5numpy_float32_t), { 0 }, 0, 'R', 0, 0 };
01430 static __Pyx_TypeInfo __Pyx_TypeInfo_nn___pyx_t_5numpy_int_t = { "int_t", NULL, sizeof(__pyx_t_5numpy_int_t), { 0 }, 0, IS_UNSIGNED(__pyx_t_5numpy_int_t) ? 'U' : 'I', IS_UNSIGNED(__pyx_t_5numpy_int_t), 0 };
01431 #define __Pyx_MODULE_NAME "cpu_nms"
01432 int __pyx_module_is_main_cpu_nms = 0;
01433
01434
01435 static PyObject *__pyx_builtin_range;
01436 static PyObject *__pyx_builtin_ValueError;
01437 static PyObject *__pyx_builtin_RuntimeError;
01438 static PyObject *__pyx_builtin_ImportError;
01439 static const char __pyx_k_h[] = "h";
01440 static const char __pyx_k_i[] = "i";
01441 static const char __pyx_k_j[] = "_j";
01442 static const char __pyx_k_w[] = "w";
01443 static const char __pyx_k_np[] = "np";
01444 static const char __pyx_k_x1[] = "x1";
01445 static const char __pyx_k_x2[] = "x2";
01446 static const char __pyx_k_y1[] = "y1";
01447 static const char __pyx_k_y2[] = "y2";
01448 static const char __pyx_k_i_2[] = "_i";
01449 static const char __pyx_k_int[] = "int";
01450 static const char __pyx_k_ix1[] = "ix1";
01451 static const char __pyx_k_ix2[] = "ix2";
01452 static const char __pyx_k_iy1[] = "iy1";
01453 static const char __pyx_k_iy2[] = "iy2";
01454 static const char __pyx_k_j_2[] = "j";
01455 static const char __pyx_k_ovr[] = "ovr";
01456 static const char __pyx_k_xx1[] = "xx1";
01457 static const char __pyx_k_xx2[] = "xx2";
01458 static const char __pyx_k_yy1[] = "yy1";
01459 static const char __pyx_k_yy2[] = "yy2";
01460 static const char __pyx_k_dets[] = "dets";
01461 static const char __pyx_k_keep[] = "keep";
01462 static const char __pyx_k_main[] = "__main__";
01463 static const char __pyx_k_test[] = "__test__";
01464 static const char __pyx_k_areas[] = "areas";
01465 static const char __pyx_k_dtype[] = "dtype";
01466 static const char __pyx_k_iarea[] = "iarea";
01467 static const char __pyx_k_inter[] = "inter";
01468 static const char __pyx_k_ndets[] = "ndets";
01469 static const char __pyx_k_numpy[] = "numpy";
01470 static const char __pyx_k_order[] = "order";
01471 static const char __pyx_k_range[] = "range";
01472 static const char __pyx_k_zeros[] = "zeros";
01473 static const char __pyx_k_astype[] = "astype";
01474 static const char __pyx_k_import[] = "__import__";
01475 static const char __pyx_k_scores[] = "scores";
01476 static const char __pyx_k_thresh[] = "thresh";
01477 static const char __pyx_k_argsort[] = "argsort";
01478 static const char __pyx_k_cpu_nms[] = "cpu_nms";
01479 static const char __pyx_k_ValueError[] = "ValueError";
01480 static const char __pyx_k_suppressed[] = "suppressed";
01481 static const char __pyx_k_ImportError[] = "ImportError";
01482 static const char __pyx_k_RuntimeError[] = "RuntimeError";
01483 static const char __pyx_k_ndarray_is_not_C_contiguous[] = "ndarray is not C contiguous";
01484 static const char __pyx_k_home_andrewsilva_Deformable_Con[] = "/home/andrewsilva/Deformable_ConvNets/Deformable-ConvNets/lib/nms/cpu_nms.pyx";
01485 static const char __pyx_k_numpy_core_multiarray_failed_to[] = "numpy.core.multiarray failed to import";
01486 static const char __pyx_k_unknown_dtype_code_in_numpy_pxd[] = "unknown dtype code in numpy.pxd (%d)";
01487 static const char __pyx_k_Format_string_allocated_too_shor[] = "Format string allocated too short, see comment in numpy.pxd";
01488 static const char __pyx_k_Non_native_byte_order_not_suppor[] = "Non-native byte order not supported";
01489 static const char __pyx_k_ndarray_is_not_Fortran_contiguou[] = "ndarray is not Fortran contiguous";
01490 static const char __pyx_k_numpy_core_umath_failed_to_impor[] = "numpy.core.umath failed to import";
01491 static const char __pyx_k_Format_string_allocated_too_shor_2[] = "Format string allocated too short.";
01492 static PyObject *__pyx_kp_u_Format_string_allocated_too_shor;
01493 static PyObject *__pyx_kp_u_Format_string_allocated_too_shor_2;
01494 static PyObject *__pyx_n_s_ImportError;
01495 static PyObject *__pyx_kp_u_Non_native_byte_order_not_suppor;
01496 static PyObject *__pyx_n_s_RuntimeError;
01497 static PyObject *__pyx_n_s_ValueError;
01498 static PyObject *__pyx_n_s_areas;
01499 static PyObject *__pyx_n_s_argsort;
01500 static PyObject *__pyx_n_s_astype;
01501 static PyObject *__pyx_n_s_cpu_nms;
01502 static PyObject *__pyx_n_s_dets;
01503 static PyObject *__pyx_n_s_dtype;
01504 static PyObject *__pyx_n_s_h;
01505 static PyObject *__pyx_kp_s_home_andrewsilva_Deformable_Con;
01506 static PyObject *__pyx_n_s_i;
01507 static PyObject *__pyx_n_s_i_2;
01508 static PyObject *__pyx_n_s_iarea;
01509 static PyObject *__pyx_n_s_import;
01510 static PyObject *__pyx_n_s_int;
01511 static PyObject *__pyx_n_s_inter;
01512 static PyObject *__pyx_n_s_ix1;
01513 static PyObject *__pyx_n_s_ix2;
01514 static PyObject *__pyx_n_s_iy1;
01515 static PyObject *__pyx_n_s_iy2;
01516 static PyObject *__pyx_n_s_j;
01517 static PyObject *__pyx_n_s_j_2;
01518 static PyObject *__pyx_n_s_keep;
01519 static PyObject *__pyx_n_s_main;
01520 static PyObject *__pyx_kp_u_ndarray_is_not_C_contiguous;
01521 static PyObject *__pyx_kp_u_ndarray_is_not_Fortran_contiguou;
01522 static PyObject *__pyx_n_s_ndets;
01523 static PyObject *__pyx_n_s_np;
01524 static PyObject *__pyx_n_s_numpy;
01525 static PyObject *__pyx_kp_s_numpy_core_multiarray_failed_to;
01526 static PyObject *__pyx_kp_s_numpy_core_umath_failed_to_impor;
01527 static PyObject *__pyx_n_s_order;
01528 static PyObject *__pyx_n_s_ovr;
01529 static PyObject *__pyx_n_s_range;
01530 static PyObject *__pyx_n_s_scores;
01531 static PyObject *__pyx_n_s_suppressed;
01532 static PyObject *__pyx_n_s_test;
01533 static PyObject *__pyx_n_s_thresh;
01534 static PyObject *__pyx_kp_u_unknown_dtype_code_in_numpy_pxd;
01535 static PyObject *__pyx_n_s_w;
01536 static PyObject *__pyx_n_s_x1;
01537 static PyObject *__pyx_n_s_x2;
01538 static PyObject *__pyx_n_s_xx1;
01539 static PyObject *__pyx_n_s_xx2;
01540 static PyObject *__pyx_n_s_y1;
01541 static PyObject *__pyx_n_s_y2;
01542 static PyObject *__pyx_n_s_yy1;
01543 static PyObject *__pyx_n_s_yy2;
01544 static PyObject *__pyx_n_s_zeros;
01545 static PyObject *__pyx_pf_7cpu_nms_cpu_nms(CYTHON_UNUSED PyObject *__pyx_self, PyArrayObject *__pyx_v_dets, PyObject *__pyx_v_thresh);
01546 static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, Py_buffer *__pyx_v_info, int __pyx_v_flags);
01547 static void __pyx_pf_5numpy_7ndarray_2__releasebuffer__(PyArrayObject *__pyx_v_self, Py_buffer *__pyx_v_info);
01548 static PyObject *__pyx_int_0;
01549 static PyObject *__pyx_int_1;
01550 static PyObject *__pyx_int_2;
01551 static PyObject *__pyx_int_3;
01552 static PyObject *__pyx_int_4;
01553 static PyObject *__pyx_int_neg_1;
01554 static PyObject *__pyx_slice_;
01555 static PyObject *__pyx_slice__3;
01556 static PyObject *__pyx_slice__5;
01557 static PyObject *__pyx_slice__7;
01558 static PyObject *__pyx_slice__9;
01559 static PyObject *__pyx_tuple__2;
01560 static PyObject *__pyx_tuple__4;
01561 static PyObject *__pyx_tuple__6;
01562 static PyObject *__pyx_tuple__8;
01563 static PyObject *__pyx_slice__11;
01564 static PyObject *__pyx_tuple__10;
01565 static PyObject *__pyx_tuple__12;
01566 static PyObject *__pyx_tuple__13;
01567 static PyObject *__pyx_tuple__14;
01568 static PyObject *__pyx_tuple__15;
01569 static PyObject *__pyx_tuple__16;
01570 static PyObject *__pyx_tuple__17;
01571 static PyObject *__pyx_tuple__18;
01572 static PyObject *__pyx_tuple__19;
01573 static PyObject *__pyx_tuple__20;
01574 static PyObject *__pyx_tuple__21;
01575 static PyObject *__pyx_tuple__22;
01576 static PyObject *__pyx_codeobj__23;
01577
01578
01579
01580
01581
01582
01583
01584
01585
01586 static CYTHON_INLINE __pyx_t_5numpy_float32_t __pyx_f_7cpu_nms_max(__pyx_t_5numpy_float32_t __pyx_v_a, __pyx_t_5numpy_float32_t __pyx_v_b) {
01587 __pyx_t_5numpy_float32_t __pyx_r;
01588 __Pyx_RefNannyDeclarations
01589 __pyx_t_5numpy_float32_t __pyx_t_1;
01590 __Pyx_RefNannySetupContext("max", 0);
01591
01592
01593
01594
01595
01596
01597
01598
01599 if (((__pyx_v_a >= __pyx_v_b) != 0)) {
01600 __pyx_t_1 = __pyx_v_a;
01601 } else {
01602 __pyx_t_1 = __pyx_v_b;
01603 }
01604 __pyx_r = __pyx_t_1;
01605 goto __pyx_L0;
01606
01607
01608
01609
01610
01611
01612
01613
01614
01615
01616 __pyx_L0:;
01617 __Pyx_RefNannyFinishContext();
01618 return __pyx_r;
01619 }
01620
01621
01622
01623
01624
01625
01626
01627
01628
01629 static CYTHON_INLINE __pyx_t_5numpy_float32_t __pyx_f_7cpu_nms_min(__pyx_t_5numpy_float32_t __pyx_v_a, __pyx_t_5numpy_float32_t __pyx_v_b) {
01630 __pyx_t_5numpy_float32_t __pyx_r;
01631 __Pyx_RefNannyDeclarations
01632 __pyx_t_5numpy_float32_t __pyx_t_1;
01633 __Pyx_RefNannySetupContext("min", 0);
01634
01635
01636
01637
01638
01639
01640
01641
01642 if (((__pyx_v_a <= __pyx_v_b) != 0)) {
01643 __pyx_t_1 = __pyx_v_a;
01644 } else {
01645 __pyx_t_1 = __pyx_v_b;
01646 }
01647 __pyx_r = __pyx_t_1;
01648 goto __pyx_L0;
01649
01650
01651
01652
01653
01654
01655
01656
01657
01658
01659 __pyx_L0:;
01660 __Pyx_RefNannyFinishContext();
01661 return __pyx_r;
01662 }
01663
01664
01665
01666
01667
01668
01669
01670
01671
01672
01673 static PyObject *__pyx_pw_7cpu_nms_1cpu_nms(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds);
01674 static PyMethodDef __pyx_mdef_7cpu_nms_1cpu_nms = {"cpu_nms", (PyCFunction)__pyx_pw_7cpu_nms_1cpu_nms, METH_VARARGS|METH_KEYWORDS, 0};
01675 static PyObject *__pyx_pw_7cpu_nms_1cpu_nms(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
01676 PyArrayObject *__pyx_v_dets = 0;
01677 PyObject *__pyx_v_thresh = 0;
01678 PyObject *__pyx_r = 0;
01679 __Pyx_RefNannyDeclarations
01680 __Pyx_RefNannySetupContext("cpu_nms (wrapper)", 0);
01681 {
01682 static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_dets,&__pyx_n_s_thresh,0};
01683 PyObject* values[2] = {0,0};
01684 if (unlikely(__pyx_kwds)) {
01685 Py_ssize_t kw_args;
01686 const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
01687 switch (pos_args) {
01688 case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
01689 case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
01690 case 0: break;
01691 default: goto __pyx_L5_argtuple_error;
01692 }
01693 kw_args = PyDict_Size(__pyx_kwds);
01694 switch (pos_args) {
01695 case 0:
01696 if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_dets)) != 0)) kw_args--;
01697 else goto __pyx_L5_argtuple_error;
01698 case 1:
01699 if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_thresh)) != 0)) kw_args--;
01700 else {
01701 __Pyx_RaiseArgtupleInvalid("cpu_nms", 1, 2, 2, 1); __PYX_ERR(0, 17, __pyx_L3_error)
01702 }
01703 }
01704 if (unlikely(kw_args > 0)) {
01705 if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "cpu_nms") < 0)) __PYX_ERR(0, 17, __pyx_L3_error)
01706 }
01707 } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
01708 goto __pyx_L5_argtuple_error;
01709 } else {
01710 values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
01711 values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
01712 }
01713 __pyx_v_dets = ((PyArrayObject *)values[0]);
01714 __pyx_v_thresh = ((PyObject*)values[1]);
01715 }
01716 goto __pyx_L4_argument_unpacking_done;
01717 __pyx_L5_argtuple_error:;
01718 __Pyx_RaiseArgtupleInvalid("cpu_nms", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 17, __pyx_L3_error)
01719 __pyx_L3_error:;
01720 __Pyx_AddTraceback("cpu_nms.cpu_nms", __pyx_clineno, __pyx_lineno, __pyx_filename);
01721 __Pyx_RefNannyFinishContext();
01722 return NULL;
01723 __pyx_L4_argument_unpacking_done:;
01724 if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_dets), __pyx_ptype_5numpy_ndarray, 1, "dets", 0))) __PYX_ERR(0, 17, __pyx_L1_error)
01725 if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_thresh), (&PyFloat_Type), 1, "thresh", 1))) __PYX_ERR(0, 17, __pyx_L1_error)
01726 __pyx_r = __pyx_pf_7cpu_nms_cpu_nms(__pyx_self, __pyx_v_dets, __pyx_v_thresh);
01727
01728
01729 goto __pyx_L0;
01730 __pyx_L1_error:;
01731 __pyx_r = NULL;
01732 __pyx_L0:;
01733 __Pyx_RefNannyFinishContext();
01734 return __pyx_r;
01735 }
01736
01737 static PyObject *__pyx_pf_7cpu_nms_cpu_nms(CYTHON_UNUSED PyObject *__pyx_self, PyArrayObject *__pyx_v_dets, PyObject *__pyx_v_thresh) {
01738 PyArrayObject *__pyx_v_x1 = 0;
01739 PyArrayObject *__pyx_v_y1 = 0;
01740 PyArrayObject *__pyx_v_x2 = 0;
01741 PyArrayObject *__pyx_v_y2 = 0;
01742 PyArrayObject *__pyx_v_scores = 0;
01743 PyArrayObject *__pyx_v_areas = 0;
01744 PyArrayObject *__pyx_v_order = 0;
01745 int __pyx_v_ndets;
01746 PyArrayObject *__pyx_v_suppressed = 0;
01747 int __pyx_v__i;
01748 int __pyx_v__j;
01749 int __pyx_v_i;
01750 int __pyx_v_j;
01751 __pyx_t_5numpy_float32_t __pyx_v_ix1;
01752 __pyx_t_5numpy_float32_t __pyx_v_iy1;
01753 __pyx_t_5numpy_float32_t __pyx_v_ix2;
01754 __pyx_t_5numpy_float32_t __pyx_v_iy2;
01755 __pyx_t_5numpy_float32_t __pyx_v_iarea;
01756 __pyx_t_5numpy_float32_t __pyx_v_xx1;
01757 __pyx_t_5numpy_float32_t __pyx_v_yy1;
01758 __pyx_t_5numpy_float32_t __pyx_v_xx2;
01759 __pyx_t_5numpy_float32_t __pyx_v_yy2;
01760 __pyx_t_5numpy_float32_t __pyx_v_w;
01761 __pyx_t_5numpy_float32_t __pyx_v_h;
01762 __pyx_t_5numpy_float32_t __pyx_v_inter;
01763 __pyx_t_5numpy_float32_t __pyx_v_ovr;
01764 PyObject *__pyx_v_keep = NULL;
01765 __Pyx_LocalBuf_ND __pyx_pybuffernd_areas;
01766 __Pyx_Buffer __pyx_pybuffer_areas;
01767 __Pyx_LocalBuf_ND __pyx_pybuffernd_dets;
01768 __Pyx_Buffer __pyx_pybuffer_dets;
01769 __Pyx_LocalBuf_ND __pyx_pybuffernd_order;
01770 __Pyx_Buffer __pyx_pybuffer_order;
01771 __Pyx_LocalBuf_ND __pyx_pybuffernd_scores;
01772 __Pyx_Buffer __pyx_pybuffer_scores;
01773 __Pyx_LocalBuf_ND __pyx_pybuffernd_suppressed;
01774 __Pyx_Buffer __pyx_pybuffer_suppressed;
01775 __Pyx_LocalBuf_ND __pyx_pybuffernd_x1;
01776 __Pyx_Buffer __pyx_pybuffer_x1;
01777 __Pyx_LocalBuf_ND __pyx_pybuffernd_x2;
01778 __Pyx_Buffer __pyx_pybuffer_x2;
01779 __Pyx_LocalBuf_ND __pyx_pybuffernd_y1;
01780 __Pyx_Buffer __pyx_pybuffer_y1;
01781 __Pyx_LocalBuf_ND __pyx_pybuffernd_y2;
01782 __Pyx_Buffer __pyx_pybuffer_y2;
01783 PyObject *__pyx_r = NULL;
01784 __Pyx_RefNannyDeclarations
01785 PyObject *__pyx_t_1 = NULL;
01786 PyArrayObject *__pyx_t_2 = NULL;
01787 PyArrayObject *__pyx_t_3 = NULL;
01788 PyArrayObject *__pyx_t_4 = NULL;
01789 PyArrayObject *__pyx_t_5 = NULL;
01790 PyArrayObject *__pyx_t_6 = NULL;
01791 PyObject *__pyx_t_7 = NULL;
01792 PyObject *__pyx_t_8 = NULL;
01793 PyArrayObject *__pyx_t_9 = NULL;
01794 PyArrayObject *__pyx_t_10 = NULL;
01795 PyObject *__pyx_t_11 = NULL;
01796 PyObject *__pyx_t_12 = NULL;
01797 PyArrayObject *__pyx_t_13 = NULL;
01798 int __pyx_t_14;
01799 int __pyx_t_15;
01800 Py_ssize_t __pyx_t_16;
01801 int __pyx_t_17;
01802 Py_ssize_t __pyx_t_18;
01803 int __pyx_t_19;
01804 int __pyx_t_20;
01805 Py_ssize_t __pyx_t_21;
01806 Py_ssize_t __pyx_t_22;
01807 Py_ssize_t __pyx_t_23;
01808 Py_ssize_t __pyx_t_24;
01809 Py_ssize_t __pyx_t_25;
01810 int __pyx_t_26;
01811 Py_ssize_t __pyx_t_27;
01812 int __pyx_t_28;
01813 Py_ssize_t __pyx_t_29;
01814 Py_ssize_t __pyx_t_30;
01815 Py_ssize_t __pyx_t_31;
01816 Py_ssize_t __pyx_t_32;
01817 Py_ssize_t __pyx_t_33;
01818 Py_ssize_t __pyx_t_34;
01819 __pyx_t_5numpy_float32_t __pyx_t_35;
01820 Py_ssize_t __pyx_t_36;
01821 __Pyx_RefNannySetupContext("cpu_nms", 0);
01822 __pyx_pybuffer_x1.pybuffer.buf = NULL;
01823 __pyx_pybuffer_x1.refcount = 0;
01824 __pyx_pybuffernd_x1.data = NULL;
01825 __pyx_pybuffernd_x1.rcbuffer = &__pyx_pybuffer_x1;
01826 __pyx_pybuffer_y1.pybuffer.buf = NULL;
01827 __pyx_pybuffer_y1.refcount = 0;
01828 __pyx_pybuffernd_y1.data = NULL;
01829 __pyx_pybuffernd_y1.rcbuffer = &__pyx_pybuffer_y1;
01830 __pyx_pybuffer_x2.pybuffer.buf = NULL;
01831 __pyx_pybuffer_x2.refcount = 0;
01832 __pyx_pybuffernd_x2.data = NULL;
01833 __pyx_pybuffernd_x2.rcbuffer = &__pyx_pybuffer_x2;
01834 __pyx_pybuffer_y2.pybuffer.buf = NULL;
01835 __pyx_pybuffer_y2.refcount = 0;
01836 __pyx_pybuffernd_y2.data = NULL;
01837 __pyx_pybuffernd_y2.rcbuffer = &__pyx_pybuffer_y2;
01838 __pyx_pybuffer_scores.pybuffer.buf = NULL;
01839 __pyx_pybuffer_scores.refcount = 0;
01840 __pyx_pybuffernd_scores.data = NULL;
01841 __pyx_pybuffernd_scores.rcbuffer = &__pyx_pybuffer_scores;
01842 __pyx_pybuffer_areas.pybuffer.buf = NULL;
01843 __pyx_pybuffer_areas.refcount = 0;
01844 __pyx_pybuffernd_areas.data = NULL;
01845 __pyx_pybuffernd_areas.rcbuffer = &__pyx_pybuffer_areas;
01846 __pyx_pybuffer_order.pybuffer.buf = NULL;
01847 __pyx_pybuffer_order.refcount = 0;
01848 __pyx_pybuffernd_order.data = NULL;
01849 __pyx_pybuffernd_order.rcbuffer = &__pyx_pybuffer_order;
01850 __pyx_pybuffer_suppressed.pybuffer.buf = NULL;
01851 __pyx_pybuffer_suppressed.refcount = 0;
01852 __pyx_pybuffernd_suppressed.data = NULL;
01853 __pyx_pybuffernd_suppressed.rcbuffer = &__pyx_pybuffer_suppressed;
01854 __pyx_pybuffer_dets.pybuffer.buf = NULL;
01855 __pyx_pybuffer_dets.refcount = 0;
01856 __pyx_pybuffernd_dets.data = NULL;
01857 __pyx_pybuffernd_dets.rcbuffer = &__pyx_pybuffer_dets;
01858 {
01859 __Pyx_BufFmt_StackElem __pyx_stack[1];
01860 if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_dets.rcbuffer->pybuffer, (PyObject*)__pyx_v_dets, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float32_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) __PYX_ERR(0, 17, __pyx_L1_error)
01861 }
01862 __pyx_pybuffernd_dets.diminfo[0].strides = __pyx_pybuffernd_dets.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_dets.diminfo[0].shape = __pyx_pybuffernd_dets.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_dets.diminfo[1].strides = __pyx_pybuffernd_dets.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_dets.diminfo[1].shape = __pyx_pybuffernd_dets.rcbuffer->pybuffer.shape[1];
01863
01864
01865
01866
01867
01868
01869
01870
01871 __pyx_t_1 = PyObject_GetItem(((PyObject *)__pyx_v_dets), __pyx_tuple__2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 18, __pyx_L1_error)
01872 __Pyx_GOTREF(__pyx_t_1);
01873 if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 18, __pyx_L1_error)
01874 __pyx_t_2 = ((PyArrayObject *)__pyx_t_1);
01875 {
01876 __Pyx_BufFmt_StackElem __pyx_stack[1];
01877 if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_x1.rcbuffer->pybuffer, (PyObject*)__pyx_t_2, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float32_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {
01878 __pyx_v_x1 = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_pybuffernd_x1.rcbuffer->pybuffer.buf = NULL;
01879 __PYX_ERR(0, 18, __pyx_L1_error)
01880 } else {__pyx_pybuffernd_x1.diminfo[0].strides = __pyx_pybuffernd_x1.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_x1.diminfo[0].shape = __pyx_pybuffernd_x1.rcbuffer->pybuffer.shape[0];
01881 }
01882 }
01883 __pyx_t_2 = 0;
01884 __pyx_v_x1 = ((PyArrayObject *)__pyx_t_1);
01885 __pyx_t_1 = 0;
01886
01887
01888
01889
01890
01891
01892
01893
01894 __pyx_t_1 = PyObject_GetItem(((PyObject *)__pyx_v_dets), __pyx_tuple__4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 19, __pyx_L1_error)
01895 __Pyx_GOTREF(__pyx_t_1);
01896 if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 19, __pyx_L1_error)
01897 __pyx_t_3 = ((PyArrayObject *)__pyx_t_1);
01898 {
01899 __Pyx_BufFmt_StackElem __pyx_stack[1];
01900 if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_y1.rcbuffer->pybuffer, (PyObject*)__pyx_t_3, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float32_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {
01901 __pyx_v_y1 = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_pybuffernd_y1.rcbuffer->pybuffer.buf = NULL;
01902 __PYX_ERR(0, 19, __pyx_L1_error)
01903 } else {__pyx_pybuffernd_y1.diminfo[0].strides = __pyx_pybuffernd_y1.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_y1.diminfo[0].shape = __pyx_pybuffernd_y1.rcbuffer->pybuffer.shape[0];
01904 }
01905 }
01906 __pyx_t_3 = 0;
01907 __pyx_v_y1 = ((PyArrayObject *)__pyx_t_1);
01908 __pyx_t_1 = 0;
01909
01910
01911
01912
01913
01914
01915
01916
01917 __pyx_t_1 = PyObject_GetItem(((PyObject *)__pyx_v_dets), __pyx_tuple__6); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 20, __pyx_L1_error)
01918 __Pyx_GOTREF(__pyx_t_1);
01919 if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 20, __pyx_L1_error)
01920 __pyx_t_4 = ((PyArrayObject *)__pyx_t_1);
01921 {
01922 __Pyx_BufFmt_StackElem __pyx_stack[1];
01923 if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_x2.rcbuffer->pybuffer, (PyObject*)__pyx_t_4, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float32_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {
01924 __pyx_v_x2 = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_pybuffernd_x2.rcbuffer->pybuffer.buf = NULL;
01925 __PYX_ERR(0, 20, __pyx_L1_error)
01926 } else {__pyx_pybuffernd_x2.diminfo[0].strides = __pyx_pybuffernd_x2.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_x2.diminfo[0].shape = __pyx_pybuffernd_x2.rcbuffer->pybuffer.shape[0];
01927 }
01928 }
01929 __pyx_t_4 = 0;
01930 __pyx_v_x2 = ((PyArrayObject *)__pyx_t_1);
01931 __pyx_t_1 = 0;
01932
01933
01934
01935
01936
01937
01938
01939
01940 __pyx_t_1 = PyObject_GetItem(((PyObject *)__pyx_v_dets), __pyx_tuple__8); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 21, __pyx_L1_error)
01941 __Pyx_GOTREF(__pyx_t_1);
01942 if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 21, __pyx_L1_error)
01943 __pyx_t_5 = ((PyArrayObject *)__pyx_t_1);
01944 {
01945 __Pyx_BufFmt_StackElem __pyx_stack[1];
01946 if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_y2.rcbuffer->pybuffer, (PyObject*)__pyx_t_5, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float32_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {
01947 __pyx_v_y2 = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_pybuffernd_y2.rcbuffer->pybuffer.buf = NULL;
01948 __PYX_ERR(0, 21, __pyx_L1_error)
01949 } else {__pyx_pybuffernd_y2.diminfo[0].strides = __pyx_pybuffernd_y2.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_y2.diminfo[0].shape = __pyx_pybuffernd_y2.rcbuffer->pybuffer.shape[0];
01950 }
01951 }
01952 __pyx_t_5 = 0;
01953 __pyx_v_y2 = ((PyArrayObject *)__pyx_t_1);
01954 __pyx_t_1 = 0;
01955
01956
01957
01958
01959
01960
01961
01962
01963 __pyx_t_1 = PyObject_GetItem(((PyObject *)__pyx_v_dets), __pyx_tuple__10); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 22, __pyx_L1_error)
01964 __Pyx_GOTREF(__pyx_t_1);
01965 if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 22, __pyx_L1_error)
01966 __pyx_t_6 = ((PyArrayObject *)__pyx_t_1);
01967 {
01968 __Pyx_BufFmt_StackElem __pyx_stack[1];
01969 if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_scores.rcbuffer->pybuffer, (PyObject*)__pyx_t_6, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float32_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {
01970 __pyx_v_scores = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_pybuffernd_scores.rcbuffer->pybuffer.buf = NULL;
01971 __PYX_ERR(0, 22, __pyx_L1_error)
01972 } else {__pyx_pybuffernd_scores.diminfo[0].strides = __pyx_pybuffernd_scores.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_scores.diminfo[0].shape = __pyx_pybuffernd_scores.rcbuffer->pybuffer.shape[0];
01973 }
01974 }
01975 __pyx_t_6 = 0;
01976 __pyx_v_scores = ((PyArrayObject *)__pyx_t_1);
01977 __pyx_t_1 = 0;
01978
01979
01980
01981
01982
01983
01984
01985
01986 __pyx_t_1 = PyNumber_Subtract(((PyObject *)__pyx_v_x2), ((PyObject *)__pyx_v_x1)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 24, __pyx_L1_error)
01987 __Pyx_GOTREF(__pyx_t_1);
01988 __pyx_t_7 = __Pyx_PyInt_AddObjC(__pyx_t_1, __pyx_int_1, 1, 0); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 24, __pyx_L1_error)
01989 __Pyx_GOTREF(__pyx_t_7);
01990 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
01991 __pyx_t_1 = PyNumber_Subtract(((PyObject *)__pyx_v_y2), ((PyObject *)__pyx_v_y1)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 24, __pyx_L1_error)
01992 __Pyx_GOTREF(__pyx_t_1);
01993 __pyx_t_8 = __Pyx_PyInt_AddObjC(__pyx_t_1, __pyx_int_1, 1, 0); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 24, __pyx_L1_error)
01994 __Pyx_GOTREF(__pyx_t_8);
01995 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
01996 __pyx_t_1 = PyNumber_Multiply(__pyx_t_7, __pyx_t_8); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 24, __pyx_L1_error)
01997 __Pyx_GOTREF(__pyx_t_1);
01998 __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
01999 __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
02000 if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 24, __pyx_L1_error)
02001 __pyx_t_9 = ((PyArrayObject *)__pyx_t_1);
02002 {
02003 __Pyx_BufFmt_StackElem __pyx_stack[1];
02004 if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_areas.rcbuffer->pybuffer, (PyObject*)__pyx_t_9, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float32_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {
02005 __pyx_v_areas = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_pybuffernd_areas.rcbuffer->pybuffer.buf = NULL;
02006 __PYX_ERR(0, 24, __pyx_L1_error)
02007 } else {__pyx_pybuffernd_areas.diminfo[0].strides = __pyx_pybuffernd_areas.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_areas.diminfo[0].shape = __pyx_pybuffernd_areas.rcbuffer->pybuffer.shape[0];
02008 }
02009 }
02010 __pyx_t_9 = 0;
02011 __pyx_v_areas = ((PyArrayObject *)__pyx_t_1);
02012 __pyx_t_1 = 0;
02013
02014
02015
02016
02017
02018
02019
02020
02021 __pyx_t_8 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_scores), __pyx_n_s_argsort); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 25, __pyx_L1_error)
02022 __Pyx_GOTREF(__pyx_t_8);
02023 __pyx_t_7 = NULL;
02024 if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_8))) {
02025 __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_8);
02026 if (likely(__pyx_t_7)) {
02027 PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_8);
02028 __Pyx_INCREF(__pyx_t_7);
02029 __Pyx_INCREF(function);
02030 __Pyx_DECREF_SET(__pyx_t_8, function);
02031 }
02032 }
02033 if (__pyx_t_7) {
02034 __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_8, __pyx_t_7); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 25, __pyx_L1_error)
02035 __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
02036 } else {
02037 __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_8); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 25, __pyx_L1_error)
02038 }
02039 __Pyx_GOTREF(__pyx_t_1);
02040 __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
02041 __pyx_t_8 = PyObject_GetItem(__pyx_t_1, __pyx_slice__11); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 25, __pyx_L1_error)
02042 __Pyx_GOTREF(__pyx_t_8);
02043 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
02044 __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_8, __pyx_n_s_astype); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 25, __pyx_L1_error)
02045 __Pyx_GOTREF(__pyx_t_1);
02046 __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
02047 __pyx_t_8 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_tuple__12, NULL); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 25, __pyx_L1_error)
02048 __Pyx_GOTREF(__pyx_t_8);
02049 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
02050 if (!(likely(((__pyx_t_8) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_8, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 25, __pyx_L1_error)
02051 __pyx_t_10 = ((PyArrayObject *)__pyx_t_8);
02052 {
02053 __Pyx_BufFmt_StackElem __pyx_stack[1];
02054 if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_order.rcbuffer->pybuffer, (PyObject*)__pyx_t_10, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {
02055 __pyx_v_order = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_pybuffernd_order.rcbuffer->pybuffer.buf = NULL;
02056 __PYX_ERR(0, 25, __pyx_L1_error)
02057 } else {__pyx_pybuffernd_order.diminfo[0].strides = __pyx_pybuffernd_order.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_order.diminfo[0].shape = __pyx_pybuffernd_order.rcbuffer->pybuffer.shape[0];
02058 }
02059 }
02060 __pyx_t_10 = 0;
02061 __pyx_v_order = ((PyArrayObject *)__pyx_t_8);
02062 __pyx_t_8 = 0;
02063
02064
02065
02066
02067
02068
02069
02070
02071 __pyx_v_ndets = (__pyx_v_dets->dimensions[0]);
02072
02073
02074
02075
02076
02077
02078
02079
02080 __pyx_t_8 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 29, __pyx_L1_error)
02081 __Pyx_GOTREF(__pyx_t_8);
02082 __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_8, __pyx_n_s_zeros); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 29, __pyx_L1_error)
02083 __Pyx_GOTREF(__pyx_t_1);
02084 __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
02085 __pyx_t_8 = __Pyx_PyInt_From_int(__pyx_v_ndets); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 29, __pyx_L1_error)
02086 __Pyx_GOTREF(__pyx_t_8);
02087 __pyx_t_7 = PyTuple_New(1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 29, __pyx_L1_error)
02088 __Pyx_GOTREF(__pyx_t_7);
02089 __Pyx_GIVEREF(__pyx_t_8);
02090 PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_8);
02091 __pyx_t_8 = 0;
02092 __pyx_t_8 = PyDict_New(); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 29, __pyx_L1_error)
02093 __Pyx_GOTREF(__pyx_t_8);
02094 __pyx_t_11 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 29, __pyx_L1_error)
02095 __Pyx_GOTREF(__pyx_t_11);
02096 __pyx_t_12 = __Pyx_PyObject_GetAttrStr(__pyx_t_11, __pyx_n_s_int); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 29, __pyx_L1_error)
02097 __Pyx_GOTREF(__pyx_t_12);
02098 __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
02099 if (PyDict_SetItem(__pyx_t_8, __pyx_n_s_dtype, __pyx_t_12) < 0) __PYX_ERR(0, 29, __pyx_L1_error)
02100 __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
02101 __pyx_t_12 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_7, __pyx_t_8); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 29, __pyx_L1_error)
02102 __Pyx_GOTREF(__pyx_t_12);
02103 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
02104 __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
02105 __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
02106 if (!(likely(((__pyx_t_12) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_12, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 29, __pyx_L1_error)
02107 __pyx_t_13 = ((PyArrayObject *)__pyx_t_12);
02108 {
02109 __Pyx_BufFmt_StackElem __pyx_stack[1];
02110 if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_suppressed.rcbuffer->pybuffer, (PyObject*)__pyx_t_13, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int_t, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 1, 0, __pyx_stack) == -1)) {
02111 __pyx_v_suppressed = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_pybuffernd_suppressed.rcbuffer->pybuffer.buf = NULL;
02112 __PYX_ERR(0, 28, __pyx_L1_error)
02113 } else {__pyx_pybuffernd_suppressed.diminfo[0].strides = __pyx_pybuffernd_suppressed.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_suppressed.diminfo[0].shape = __pyx_pybuffernd_suppressed.rcbuffer->pybuffer.shape[0];
02114 }
02115 }
02116 __pyx_t_13 = 0;
02117 __pyx_v_suppressed = ((PyArrayObject *)__pyx_t_12);
02118 __pyx_t_12 = 0;
02119
02120
02121
02122
02123
02124
02125
02126
02127 __pyx_t_12 = PyList_New(0); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 42, __pyx_L1_error)
02128 __Pyx_GOTREF(__pyx_t_12);
02129 __pyx_v_keep = ((PyObject*)__pyx_t_12);
02130 __pyx_t_12 = 0;
02131
02132
02133
02134
02135
02136
02137
02138
02139 __pyx_t_14 = __pyx_v_ndets;
02140 for (__pyx_t_15 = 0; __pyx_t_15 < __pyx_t_14; __pyx_t_15+=1) {
02141 __pyx_v__i = __pyx_t_15;
02142
02143
02144
02145
02146
02147
02148
02149
02150 __pyx_t_16 = __pyx_v__i;
02151 __pyx_t_17 = -1;
02152 if (__pyx_t_16 < 0) {
02153 __pyx_t_16 += __pyx_pybuffernd_order.diminfo[0].shape;
02154 if (unlikely(__pyx_t_16 < 0)) __pyx_t_17 = 0;
02155 } else if (unlikely(__pyx_t_16 >= __pyx_pybuffernd_order.diminfo[0].shape)) __pyx_t_17 = 0;
02156 if (unlikely(__pyx_t_17 != -1)) {
02157 __Pyx_RaiseBufferIndexError(__pyx_t_17);
02158 __PYX_ERR(0, 44, __pyx_L1_error)
02159 }
02160 __pyx_v_i = (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_int_t *, __pyx_pybuffernd_order.rcbuffer->pybuffer.buf, __pyx_t_16, __pyx_pybuffernd_order.diminfo[0].strides));
02161
02162
02163
02164
02165
02166
02167
02168
02169 __pyx_t_18 = __pyx_v_i;
02170 __pyx_t_17 = -1;
02171 if (__pyx_t_18 < 0) {
02172 __pyx_t_18 += __pyx_pybuffernd_suppressed.diminfo[0].shape;
02173 if (unlikely(__pyx_t_18 < 0)) __pyx_t_17 = 0;
02174 } else if (unlikely(__pyx_t_18 >= __pyx_pybuffernd_suppressed.diminfo[0].shape)) __pyx_t_17 = 0;
02175 if (unlikely(__pyx_t_17 != -1)) {
02176 __Pyx_RaiseBufferIndexError(__pyx_t_17);
02177 __PYX_ERR(0, 45, __pyx_L1_error)
02178 }
02179 __pyx_t_19 = (((*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_int_t *, __pyx_pybuffernd_suppressed.rcbuffer->pybuffer.buf, __pyx_t_18, __pyx_pybuffernd_suppressed.diminfo[0].strides)) == 1) != 0);
02180 if (__pyx_t_19) {
02181
02182
02183
02184
02185
02186
02187
02188
02189 goto __pyx_L3_continue;
02190
02191
02192
02193
02194
02195
02196
02197
02198 }
02199
02200
02201
02202
02203
02204
02205
02206
02207 __pyx_t_12 = __Pyx_PyInt_From_int(__pyx_v_i); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 47, __pyx_L1_error)
02208 __Pyx_GOTREF(__pyx_t_12);
02209 __pyx_t_20 = __Pyx_PyList_Append(__pyx_v_keep, __pyx_t_12); if (unlikely(__pyx_t_20 == -1)) __PYX_ERR(0, 47, __pyx_L1_error)
02210 __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
02211
02212
02213
02214
02215
02216
02217
02218
02219 __pyx_t_21 = __pyx_v_i;
02220 __pyx_t_17 = -1;
02221 if (__pyx_t_21 < 0) {
02222 __pyx_t_21 += __pyx_pybuffernd_x1.diminfo[0].shape;
02223 if (unlikely(__pyx_t_21 < 0)) __pyx_t_17 = 0;
02224 } else if (unlikely(__pyx_t_21 >= __pyx_pybuffernd_x1.diminfo[0].shape)) __pyx_t_17 = 0;
02225 if (unlikely(__pyx_t_17 != -1)) {
02226 __Pyx_RaiseBufferIndexError(__pyx_t_17);
02227 __PYX_ERR(0, 48, __pyx_L1_error)
02228 }
02229 __pyx_v_ix1 = (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float32_t *, __pyx_pybuffernd_x1.rcbuffer->pybuffer.buf, __pyx_t_21, __pyx_pybuffernd_x1.diminfo[0].strides));
02230
02231
02232
02233
02234
02235
02236
02237
02238 __pyx_t_22 = __pyx_v_i;
02239 __pyx_t_17 = -1;
02240 if (__pyx_t_22 < 0) {
02241 __pyx_t_22 += __pyx_pybuffernd_y1.diminfo[0].shape;
02242 if (unlikely(__pyx_t_22 < 0)) __pyx_t_17 = 0;
02243 } else if (unlikely(__pyx_t_22 >= __pyx_pybuffernd_y1.diminfo[0].shape)) __pyx_t_17 = 0;
02244 if (unlikely(__pyx_t_17 != -1)) {
02245 __Pyx_RaiseBufferIndexError(__pyx_t_17);
02246 __PYX_ERR(0, 49, __pyx_L1_error)
02247 }
02248 __pyx_v_iy1 = (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float32_t *, __pyx_pybuffernd_y1.rcbuffer->pybuffer.buf, __pyx_t_22, __pyx_pybuffernd_y1.diminfo[0].strides));
02249
02250
02251
02252
02253
02254
02255
02256
02257 __pyx_t_23 = __pyx_v_i;
02258 __pyx_t_17 = -1;
02259 if (__pyx_t_23 < 0) {
02260 __pyx_t_23 += __pyx_pybuffernd_x2.diminfo[0].shape;
02261 if (unlikely(__pyx_t_23 < 0)) __pyx_t_17 = 0;
02262 } else if (unlikely(__pyx_t_23 >= __pyx_pybuffernd_x2.diminfo[0].shape)) __pyx_t_17 = 0;
02263 if (unlikely(__pyx_t_17 != -1)) {
02264 __Pyx_RaiseBufferIndexError(__pyx_t_17);
02265 __PYX_ERR(0, 50, __pyx_L1_error)
02266 }
02267 __pyx_v_ix2 = (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float32_t *, __pyx_pybuffernd_x2.rcbuffer->pybuffer.buf, __pyx_t_23, __pyx_pybuffernd_x2.diminfo[0].strides));
02268
02269
02270
02271
02272
02273
02274
02275
02276 __pyx_t_24 = __pyx_v_i;
02277 __pyx_t_17 = -1;
02278 if (__pyx_t_24 < 0) {
02279 __pyx_t_24 += __pyx_pybuffernd_y2.diminfo[0].shape;
02280 if (unlikely(__pyx_t_24 < 0)) __pyx_t_17 = 0;
02281 } else if (unlikely(__pyx_t_24 >= __pyx_pybuffernd_y2.diminfo[0].shape)) __pyx_t_17 = 0;
02282 if (unlikely(__pyx_t_17 != -1)) {
02283 __Pyx_RaiseBufferIndexError(__pyx_t_17);
02284 __PYX_ERR(0, 51, __pyx_L1_error)
02285 }
02286 __pyx_v_iy2 = (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float32_t *, __pyx_pybuffernd_y2.rcbuffer->pybuffer.buf, __pyx_t_24, __pyx_pybuffernd_y2.diminfo[0].strides));
02287
02288
02289
02290
02291
02292
02293
02294
02295 __pyx_t_25 = __pyx_v_i;
02296 __pyx_t_17 = -1;
02297 if (__pyx_t_25 < 0) {
02298 __pyx_t_25 += __pyx_pybuffernd_areas.diminfo[0].shape;
02299 if (unlikely(__pyx_t_25 < 0)) __pyx_t_17 = 0;
02300 } else if (unlikely(__pyx_t_25 >= __pyx_pybuffernd_areas.diminfo[0].shape)) __pyx_t_17 = 0;
02301 if (unlikely(__pyx_t_17 != -1)) {
02302 __Pyx_RaiseBufferIndexError(__pyx_t_17);
02303 __PYX_ERR(0, 52, __pyx_L1_error)
02304 }
02305 __pyx_v_iarea = (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float32_t *, __pyx_pybuffernd_areas.rcbuffer->pybuffer.buf, __pyx_t_25, __pyx_pybuffernd_areas.diminfo[0].strides));
02306
02307
02308
02309
02310
02311
02312
02313
02314 __pyx_t_17 = __pyx_v_ndets;
02315 for (__pyx_t_26 = (__pyx_v__i + 1); __pyx_t_26 < __pyx_t_17; __pyx_t_26+=1) {
02316 __pyx_v__j = __pyx_t_26;
02317
02318
02319
02320
02321
02322
02323
02324
02325 __pyx_t_27 = __pyx_v__j;
02326 __pyx_t_28 = -1;
02327 if (__pyx_t_27 < 0) {
02328 __pyx_t_27 += __pyx_pybuffernd_order.diminfo[0].shape;
02329 if (unlikely(__pyx_t_27 < 0)) __pyx_t_28 = 0;
02330 } else if (unlikely(__pyx_t_27 >= __pyx_pybuffernd_order.diminfo[0].shape)) __pyx_t_28 = 0;
02331 if (unlikely(__pyx_t_28 != -1)) {
02332 __Pyx_RaiseBufferIndexError(__pyx_t_28);
02333 __PYX_ERR(0, 54, __pyx_L1_error)
02334 }
02335 __pyx_v_j = (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_int_t *, __pyx_pybuffernd_order.rcbuffer->pybuffer.buf, __pyx_t_27, __pyx_pybuffernd_order.diminfo[0].strides));
02336
02337
02338
02339
02340
02341
02342
02343
02344 __pyx_t_29 = __pyx_v_j;
02345 __pyx_t_28 = -1;
02346 if (__pyx_t_29 < 0) {
02347 __pyx_t_29 += __pyx_pybuffernd_suppressed.diminfo[0].shape;
02348 if (unlikely(__pyx_t_29 < 0)) __pyx_t_28 = 0;
02349 } else if (unlikely(__pyx_t_29 >= __pyx_pybuffernd_suppressed.diminfo[0].shape)) __pyx_t_28 = 0;
02350 if (unlikely(__pyx_t_28 != -1)) {
02351 __Pyx_RaiseBufferIndexError(__pyx_t_28);
02352 __PYX_ERR(0, 55, __pyx_L1_error)
02353 }
02354 __pyx_t_19 = (((*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_int_t *, __pyx_pybuffernd_suppressed.rcbuffer->pybuffer.buf, __pyx_t_29, __pyx_pybuffernd_suppressed.diminfo[0].strides)) == 1) != 0);
02355 if (__pyx_t_19) {
02356
02357
02358
02359
02360
02361
02362
02363
02364 goto __pyx_L6_continue;
02365
02366
02367
02368
02369
02370
02371
02372
02373 }
02374
02375
02376
02377
02378
02379
02380
02381
02382 __pyx_t_30 = __pyx_v_j;
02383 __pyx_t_28 = -1;
02384 if (__pyx_t_30 < 0) {
02385 __pyx_t_30 += __pyx_pybuffernd_x1.diminfo[0].shape;
02386 if (unlikely(__pyx_t_30 < 0)) __pyx_t_28 = 0;
02387 } else if (unlikely(__pyx_t_30 >= __pyx_pybuffernd_x1.diminfo[0].shape)) __pyx_t_28 = 0;
02388 if (unlikely(__pyx_t_28 != -1)) {
02389 __Pyx_RaiseBufferIndexError(__pyx_t_28);
02390 __PYX_ERR(0, 57, __pyx_L1_error)
02391 }
02392 __pyx_v_xx1 = __pyx_f_7cpu_nms_max(__pyx_v_ix1, (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float32_t *, __pyx_pybuffernd_x1.rcbuffer->pybuffer.buf, __pyx_t_30, __pyx_pybuffernd_x1.diminfo[0].strides)));
02393
02394
02395
02396
02397
02398
02399
02400
02401 __pyx_t_31 = __pyx_v_j;
02402 __pyx_t_28 = -1;
02403 if (__pyx_t_31 < 0) {
02404 __pyx_t_31 += __pyx_pybuffernd_y1.diminfo[0].shape;
02405 if (unlikely(__pyx_t_31 < 0)) __pyx_t_28 = 0;
02406 } else if (unlikely(__pyx_t_31 >= __pyx_pybuffernd_y1.diminfo[0].shape)) __pyx_t_28 = 0;
02407 if (unlikely(__pyx_t_28 != -1)) {
02408 __Pyx_RaiseBufferIndexError(__pyx_t_28);
02409 __PYX_ERR(0, 58, __pyx_L1_error)
02410 }
02411 __pyx_v_yy1 = __pyx_f_7cpu_nms_max(__pyx_v_iy1, (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float32_t *, __pyx_pybuffernd_y1.rcbuffer->pybuffer.buf, __pyx_t_31, __pyx_pybuffernd_y1.diminfo[0].strides)));
02412
02413
02414
02415
02416
02417
02418
02419
02420 __pyx_t_32 = __pyx_v_j;
02421 __pyx_t_28 = -1;
02422 if (__pyx_t_32 < 0) {
02423 __pyx_t_32 += __pyx_pybuffernd_x2.diminfo[0].shape;
02424 if (unlikely(__pyx_t_32 < 0)) __pyx_t_28 = 0;
02425 } else if (unlikely(__pyx_t_32 >= __pyx_pybuffernd_x2.diminfo[0].shape)) __pyx_t_28 = 0;
02426 if (unlikely(__pyx_t_28 != -1)) {
02427 __Pyx_RaiseBufferIndexError(__pyx_t_28);
02428 __PYX_ERR(0, 59, __pyx_L1_error)
02429 }
02430 __pyx_v_xx2 = __pyx_f_7cpu_nms_min(__pyx_v_ix2, (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float32_t *, __pyx_pybuffernd_x2.rcbuffer->pybuffer.buf, __pyx_t_32, __pyx_pybuffernd_x2.diminfo[0].strides)));
02431
02432
02433
02434
02435
02436
02437
02438
02439 __pyx_t_33 = __pyx_v_j;
02440 __pyx_t_28 = -1;
02441 if (__pyx_t_33 < 0) {
02442 __pyx_t_33 += __pyx_pybuffernd_y2.diminfo[0].shape;
02443 if (unlikely(__pyx_t_33 < 0)) __pyx_t_28 = 0;
02444 } else if (unlikely(__pyx_t_33 >= __pyx_pybuffernd_y2.diminfo[0].shape)) __pyx_t_28 = 0;
02445 if (unlikely(__pyx_t_28 != -1)) {
02446 __Pyx_RaiseBufferIndexError(__pyx_t_28);
02447 __PYX_ERR(0, 60, __pyx_L1_error)
02448 }
02449 __pyx_v_yy2 = __pyx_f_7cpu_nms_min(__pyx_v_iy2, (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float32_t *, __pyx_pybuffernd_y2.rcbuffer->pybuffer.buf, __pyx_t_33, __pyx_pybuffernd_y2.diminfo[0].strides)));
02450
02451
02452
02453
02454
02455
02456
02457
02458 __pyx_v_w = __pyx_f_7cpu_nms_max(0.0, ((__pyx_v_xx2 - __pyx_v_xx1) + 1.0));
02459
02460
02461
02462
02463
02464
02465
02466
02467 __pyx_v_h = __pyx_f_7cpu_nms_max(0.0, ((__pyx_v_yy2 - __pyx_v_yy1) + 1.0));
02468
02469
02470
02471
02472
02473
02474
02475
02476 __pyx_v_inter = (__pyx_v_w * __pyx_v_h);
02477
02478
02479
02480
02481
02482
02483
02484
02485 __pyx_t_34 = __pyx_v_j;
02486 __pyx_t_28 = -1;
02487 if (__pyx_t_34 < 0) {
02488 __pyx_t_34 += __pyx_pybuffernd_areas.diminfo[0].shape;
02489 if (unlikely(__pyx_t_34 < 0)) __pyx_t_28 = 0;
02490 } else if (unlikely(__pyx_t_34 >= __pyx_pybuffernd_areas.diminfo[0].shape)) __pyx_t_28 = 0;
02491 if (unlikely(__pyx_t_28 != -1)) {
02492 __Pyx_RaiseBufferIndexError(__pyx_t_28);
02493 __PYX_ERR(0, 64, __pyx_L1_error)
02494 }
02495 __pyx_t_35 = ((__pyx_v_iarea + (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float32_t *, __pyx_pybuffernd_areas.rcbuffer->pybuffer.buf, __pyx_t_34, __pyx_pybuffernd_areas.diminfo[0].strides))) - __pyx_v_inter);
02496 if (unlikely(__pyx_t_35 == 0)) {
02497 PyErr_SetString(PyExc_ZeroDivisionError, "float division");
02498 __PYX_ERR(0, 64, __pyx_L1_error)
02499 }
02500 __pyx_v_ovr = (__pyx_v_inter / __pyx_t_35);
02501
02502
02503
02504
02505
02506
02507
02508
02509 __pyx_t_12 = PyFloat_FromDouble(__pyx_v_ovr); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 65, __pyx_L1_error)
02510 __Pyx_GOTREF(__pyx_t_12);
02511 __pyx_t_8 = PyObject_RichCompare(__pyx_t_12, __pyx_v_thresh, Py_GE); __Pyx_XGOTREF(__pyx_t_8); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 65, __pyx_L1_error)
02512 __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
02513 __pyx_t_19 = __Pyx_PyObject_IsTrue(__pyx_t_8); if (unlikely(__pyx_t_19 < 0)) __PYX_ERR(0, 65, __pyx_L1_error)
02514 __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
02515 if (__pyx_t_19) {
02516
02517
02518
02519
02520
02521
02522
02523
02524 __pyx_t_36 = __pyx_v_j;
02525 __pyx_t_28 = -1;
02526 if (__pyx_t_36 < 0) {
02527 __pyx_t_36 += __pyx_pybuffernd_suppressed.diminfo[0].shape;
02528 if (unlikely(__pyx_t_36 < 0)) __pyx_t_28 = 0;
02529 } else if (unlikely(__pyx_t_36 >= __pyx_pybuffernd_suppressed.diminfo[0].shape)) __pyx_t_28 = 0;
02530 if (unlikely(__pyx_t_28 != -1)) {
02531 __Pyx_RaiseBufferIndexError(__pyx_t_28);
02532 __PYX_ERR(0, 66, __pyx_L1_error)
02533 }
02534 *__Pyx_BufPtrStrided1d(__pyx_t_5numpy_int_t *, __pyx_pybuffernd_suppressed.rcbuffer->pybuffer.buf, __pyx_t_36, __pyx_pybuffernd_suppressed.diminfo[0].strides) = 1;
02535
02536
02537
02538
02539
02540
02541
02542
02543 }
02544 __pyx_L6_continue:;
02545 }
02546 __pyx_L3_continue:;
02547 }
02548
02549
02550
02551
02552
02553
02554 __Pyx_XDECREF(__pyx_r);
02555 __Pyx_INCREF(__pyx_v_keep);
02556 __pyx_r = __pyx_v_keep;
02557 goto __pyx_L0;
02558
02559
02560
02561
02562
02563
02564
02565
02566
02567
02568 __pyx_L1_error:;
02569 __Pyx_XDECREF(__pyx_t_1);
02570 __Pyx_XDECREF(__pyx_t_7);
02571 __Pyx_XDECREF(__pyx_t_8);
02572 __Pyx_XDECREF(__pyx_t_11);
02573 __Pyx_XDECREF(__pyx_t_12);
02574 { PyObject *__pyx_type, *__pyx_value, *__pyx_tb;
02575 __Pyx_PyThreadState_declare
02576 __Pyx_PyThreadState_assign
02577 __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb);
02578 __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_areas.rcbuffer->pybuffer);
02579 __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_dets.rcbuffer->pybuffer);
02580 __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_order.rcbuffer->pybuffer);
02581 __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_scores.rcbuffer->pybuffer);
02582 __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_suppressed.rcbuffer->pybuffer);
02583 __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_x1.rcbuffer->pybuffer);
02584 __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_x2.rcbuffer->pybuffer);
02585 __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_y1.rcbuffer->pybuffer);
02586 __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_y2.rcbuffer->pybuffer);
02587 __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}
02588 __Pyx_AddTraceback("cpu_nms.cpu_nms", __pyx_clineno, __pyx_lineno, __pyx_filename);
02589 __pyx_r = NULL;
02590 goto __pyx_L2;
02591 __pyx_L0:;
02592 __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_areas.rcbuffer->pybuffer);
02593 __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_dets.rcbuffer->pybuffer);
02594 __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_order.rcbuffer->pybuffer);
02595 __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_scores.rcbuffer->pybuffer);
02596 __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_suppressed.rcbuffer->pybuffer);
02597 __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_x1.rcbuffer->pybuffer);
02598 __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_x2.rcbuffer->pybuffer);
02599 __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_y1.rcbuffer->pybuffer);
02600 __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_y2.rcbuffer->pybuffer);
02601 __pyx_L2:;
02602 __Pyx_XDECREF((PyObject *)__pyx_v_x1);
02603 __Pyx_XDECREF((PyObject *)__pyx_v_y1);
02604 __Pyx_XDECREF((PyObject *)__pyx_v_x2);
02605 __Pyx_XDECREF((PyObject *)__pyx_v_y2);
02606 __Pyx_XDECREF((PyObject *)__pyx_v_scores);
02607 __Pyx_XDECREF((PyObject *)__pyx_v_areas);
02608 __Pyx_XDECREF((PyObject *)__pyx_v_order);
02609 __Pyx_XDECREF((PyObject *)__pyx_v_suppressed);
02610 __Pyx_XDECREF(__pyx_v_keep);
02611 __Pyx_XGIVEREF(__pyx_r);
02612 __Pyx_RefNannyFinishContext();
02613 return __pyx_r;
02614 }
02615
02616
02617
02618
02619
02620
02621
02622
02623
02624
02625 static CYTHON_UNUSED int __pyx_pw_5numpy_7ndarray_1__getbuffer__(PyObject *__pyx_v_self, Py_buffer *__pyx_v_info, int __pyx_v_flags);
02626 static CYTHON_UNUSED int __pyx_pw_5numpy_7ndarray_1__getbuffer__(PyObject *__pyx_v_self, Py_buffer *__pyx_v_info, int __pyx_v_flags) {
02627 int __pyx_r;
02628 __Pyx_RefNannyDeclarations
02629 __Pyx_RefNannySetupContext("__getbuffer__ (wrapper)", 0);
02630 __pyx_r = __pyx_pf_5numpy_7ndarray___getbuffer__(((PyArrayObject *)__pyx_v_self), ((Py_buffer *)__pyx_v_info), ((int)__pyx_v_flags));
02631
02632
02633 __Pyx_RefNannyFinishContext();
02634 return __pyx_r;
02635 }
02636
02637 static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, Py_buffer *__pyx_v_info, int __pyx_v_flags) {
02638 int __pyx_v_copy_shape;
02639 int __pyx_v_i;
02640 int __pyx_v_ndim;
02641 int __pyx_v_endian_detector;
02642 int __pyx_v_little_endian;
02643 int __pyx_v_t;
02644 char *__pyx_v_f;
02645 PyArray_Descr *__pyx_v_descr = 0;
02646 int __pyx_v_offset;
02647 int __pyx_v_hasfields;
02648 int __pyx_r;
02649 __Pyx_RefNannyDeclarations
02650 int __pyx_t_1;
02651 int __pyx_t_2;
02652 PyObject *__pyx_t_3 = NULL;
02653 int __pyx_t_4;
02654 int __pyx_t_5;
02655 PyObject *__pyx_t_6 = NULL;
02656 char *__pyx_t_7;
02657 __Pyx_RefNannySetupContext("__getbuffer__", 0);
02658 if (__pyx_v_info != NULL) {
02659 __pyx_v_info->obj = Py_None; __Pyx_INCREF(Py_None);
02660 __Pyx_GIVEREF(__pyx_v_info->obj);
02661 }
02662
02663
02664
02665
02666
02667
02668
02669
02670 __pyx_t_1 = ((__pyx_v_info == NULL) != 0);
02671 if (__pyx_t_1) {
02672 __pyx_r = 0;
02673 goto __pyx_L0;
02674 }
02675
02676
02677
02678
02679
02680
02681
02682
02683 __pyx_v_endian_detector = 1;
02684
02685
02686
02687
02688
02689
02690
02691
02692 __pyx_v_little_endian = ((((char *)(&__pyx_v_endian_detector))[0]) != 0);
02693
02694
02695
02696
02697
02698
02699
02700
02701 __pyx_v_ndim = PyArray_NDIM(__pyx_v_self);
02702
02703
02704
02705
02706
02707
02708
02709
02710 __pyx_t_1 = (((sizeof(npy_intp)) != (sizeof(Py_ssize_t))) != 0);
02711 if (__pyx_t_1) {
02712
02713
02714
02715
02716
02717
02718
02719
02720 __pyx_v_copy_shape = 1;
02721
02722
02723
02724
02725
02726
02727
02728
02729 goto __pyx_L4;
02730 }
02731
02732
02733
02734
02735
02736
02737
02738
02739 {
02740 __pyx_v_copy_shape = 0;
02741 }
02742 __pyx_L4:;
02743
02744
02745
02746
02747
02748
02749
02750
02751 __pyx_t_2 = (((__pyx_v_flags & PyBUF_C_CONTIGUOUS) == PyBUF_C_CONTIGUOUS) != 0);
02752 if (__pyx_t_2) {
02753 } else {
02754 __pyx_t_1 = __pyx_t_2;
02755 goto __pyx_L6_bool_binop_done;
02756 }
02757
02758
02759
02760
02761
02762
02763
02764
02765 __pyx_t_2 = ((!(PyArray_CHKFLAGS(__pyx_v_self, NPY_C_CONTIGUOUS) != 0)) != 0);
02766 __pyx_t_1 = __pyx_t_2;
02767 __pyx_L6_bool_binop_done:;
02768
02769
02770
02771
02772
02773
02774
02775
02776 if (__pyx_t_1) {
02777
02778
02779
02780
02781
02782
02783
02784
02785 __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__13, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 218, __pyx_L1_error)
02786 __Pyx_GOTREF(__pyx_t_3);
02787 __Pyx_Raise(__pyx_t_3, 0, 0, 0);
02788 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
02789 __PYX_ERR(1, 218, __pyx_L1_error)
02790
02791
02792
02793
02794
02795
02796
02797
02798 }
02799
02800
02801
02802
02803
02804
02805
02806
02807 __pyx_t_2 = (((__pyx_v_flags & PyBUF_F_CONTIGUOUS) == PyBUF_F_CONTIGUOUS) != 0);
02808 if (__pyx_t_2) {
02809 } else {
02810 __pyx_t_1 = __pyx_t_2;
02811 goto __pyx_L9_bool_binop_done;
02812 }
02813
02814
02815
02816
02817
02818
02819
02820
02821 __pyx_t_2 = ((!(PyArray_CHKFLAGS(__pyx_v_self, NPY_F_CONTIGUOUS) != 0)) != 0);
02822 __pyx_t_1 = __pyx_t_2;
02823 __pyx_L9_bool_binop_done:;
02824
02825
02826
02827
02828
02829
02830
02831
02832 if (__pyx_t_1) {
02833
02834
02835
02836
02837
02838
02839
02840
02841 __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__14, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 222, __pyx_L1_error)
02842 __Pyx_GOTREF(__pyx_t_3);
02843 __Pyx_Raise(__pyx_t_3, 0, 0, 0);
02844 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
02845 __PYX_ERR(1, 222, __pyx_L1_error)
02846
02847
02848
02849
02850
02851
02852
02853
02854 }
02855
02856
02857
02858
02859
02860
02861
02862
02863 __pyx_v_info->buf = PyArray_DATA(__pyx_v_self);
02864
02865
02866
02867
02868
02869
02870
02871
02872 __pyx_v_info->ndim = __pyx_v_ndim;
02873
02874
02875
02876
02877
02878
02879
02880
02881 __pyx_t_1 = (__pyx_v_copy_shape != 0);
02882 if (__pyx_t_1) {
02883
02884
02885
02886
02887
02888
02889
02890
02891 __pyx_v_info->strides = ((Py_ssize_t *)malloc((((sizeof(Py_ssize_t)) * ((size_t)__pyx_v_ndim)) * 2)));
02892
02893
02894
02895
02896
02897
02898
02899
02900 __pyx_v_info->shape = (__pyx_v_info->strides + __pyx_v_ndim);
02901
02902
02903
02904
02905
02906
02907
02908
02909 __pyx_t_4 = __pyx_v_ndim;
02910 for (__pyx_t_5 = 0; __pyx_t_5 < __pyx_t_4; __pyx_t_5+=1) {
02911 __pyx_v_i = __pyx_t_5;
02912
02913
02914
02915
02916
02917
02918
02919
02920 (__pyx_v_info->strides[__pyx_v_i]) = (PyArray_STRIDES(__pyx_v_self)[__pyx_v_i]);
02921
02922
02923
02924
02925
02926
02927
02928
02929 (__pyx_v_info->shape[__pyx_v_i]) = (PyArray_DIMS(__pyx_v_self)[__pyx_v_i]);
02930 }
02931
02932
02933
02934
02935
02936
02937
02938
02939 goto __pyx_L11;
02940 }
02941
02942
02943
02944
02945
02946
02947
02948
02949 {
02950 __pyx_v_info->strides = ((Py_ssize_t *)PyArray_STRIDES(__pyx_v_self));
02951
02952
02953
02954
02955
02956
02957
02958
02959 __pyx_v_info->shape = ((Py_ssize_t *)PyArray_DIMS(__pyx_v_self));
02960 }
02961 __pyx_L11:;
02962
02963
02964
02965
02966
02967
02968
02969
02970 __pyx_v_info->suboffsets = NULL;
02971
02972
02973
02974
02975
02976
02977
02978
02979 __pyx_v_info->itemsize = PyArray_ITEMSIZE(__pyx_v_self);
02980
02981
02982
02983
02984
02985
02986
02987
02988 __pyx_v_info->readonly = (!(PyArray_ISWRITEABLE(__pyx_v_self) != 0));
02989
02990
02991
02992
02993
02994
02995
02996
02997 __pyx_v_f = NULL;
02998
02999
03000
03001
03002
03003
03004
03005
03006 __pyx_t_3 = ((PyObject *)__pyx_v_self->descr);
03007 __Pyx_INCREF(__pyx_t_3);
03008 __pyx_v_descr = ((PyArray_Descr *)__pyx_t_3);
03009 __pyx_t_3 = 0;
03010
03011
03012
03013
03014
03015
03016
03017
03018 __pyx_v_hasfields = PyDataType_HASFIELDS(__pyx_v_descr);
03019
03020
03021
03022
03023
03024
03025
03026
03027 __pyx_t_2 = ((!(__pyx_v_hasfields != 0)) != 0);
03028 if (__pyx_t_2) {
03029 } else {
03030 __pyx_t_1 = __pyx_t_2;
03031 goto __pyx_L15_bool_binop_done;
03032 }
03033 __pyx_t_2 = ((!(__pyx_v_copy_shape != 0)) != 0);
03034 __pyx_t_1 = __pyx_t_2;
03035 __pyx_L15_bool_binop_done:;
03036 if (__pyx_t_1) {
03037
03038
03039
03040
03041
03042
03043
03044
03045 __Pyx_INCREF(Py_None);
03046 __Pyx_GIVEREF(Py_None);
03047 __Pyx_GOTREF(__pyx_v_info->obj);
03048 __Pyx_DECREF(__pyx_v_info->obj);
03049 __pyx_v_info->obj = Py_None;
03050
03051
03052
03053
03054
03055
03056
03057
03058 goto __pyx_L14;
03059 }
03060
03061
03062
03063
03064
03065
03066
03067
03068 {
03069 __Pyx_INCREF(((PyObject *)__pyx_v_self));
03070 __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
03071 __Pyx_GOTREF(__pyx_v_info->obj);
03072 __Pyx_DECREF(__pyx_v_info->obj);
03073 __pyx_v_info->obj = ((PyObject *)__pyx_v_self);
03074 }
03075 __pyx_L14:;
03076
03077
03078
03079
03080
03081
03082
03083
03084 __pyx_t_1 = ((!(__pyx_v_hasfields != 0)) != 0);
03085 if (__pyx_t_1) {
03086
03087
03088
03089
03090
03091
03092
03093
03094 __pyx_t_4 = __pyx_v_descr->type_num;
03095 __pyx_v_t = __pyx_t_4;
03096
03097
03098
03099
03100
03101
03102
03103
03104 __pyx_t_2 = ((__pyx_v_descr->byteorder == '>') != 0);
03105 if (!__pyx_t_2) {
03106 goto __pyx_L20_next_or;
03107 } else {
03108 }
03109 __pyx_t_2 = (__pyx_v_little_endian != 0);
03110 if (!__pyx_t_2) {
03111 } else {
03112 __pyx_t_1 = __pyx_t_2;
03113 goto __pyx_L19_bool_binop_done;
03114 }
03115 __pyx_L20_next_or:;
03116
03117
03118
03119
03120
03121
03122
03123
03124 __pyx_t_2 = ((__pyx_v_descr->byteorder == '<') != 0);
03125 if (__pyx_t_2) {
03126 } else {
03127 __pyx_t_1 = __pyx_t_2;
03128 goto __pyx_L19_bool_binop_done;
03129 }
03130 __pyx_t_2 = ((!(__pyx_v_little_endian != 0)) != 0);
03131 __pyx_t_1 = __pyx_t_2;
03132 __pyx_L19_bool_binop_done:;
03133
03134
03135
03136
03137
03138
03139
03140
03141 if (__pyx_t_1) {
03142
03143
03144
03145
03146
03147
03148
03149
03150 __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__15, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 259, __pyx_L1_error)
03151 __Pyx_GOTREF(__pyx_t_3);
03152 __Pyx_Raise(__pyx_t_3, 0, 0, 0);
03153 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
03154 __PYX_ERR(1, 259, __pyx_L1_error)
03155
03156
03157
03158
03159
03160
03161
03162
03163 }
03164
03165
03166
03167
03168
03169
03170
03171
03172 switch (__pyx_v_t) {
03173 case NPY_BYTE:
03174 __pyx_v_f = ((char *)"b");
03175 break;
03176
03177
03178
03179
03180
03181
03182
03183
03184 case NPY_UBYTE:
03185 __pyx_v_f = ((char *)"B");
03186 break;
03187
03188
03189
03190
03191
03192
03193
03194
03195 case NPY_SHORT:
03196 __pyx_v_f = ((char *)"h");
03197 break;
03198
03199
03200
03201
03202
03203
03204
03205
03206 case NPY_USHORT:
03207 __pyx_v_f = ((char *)"H");
03208 break;
03209
03210
03211
03212
03213
03214
03215
03216
03217 case NPY_INT:
03218 __pyx_v_f = ((char *)"i");
03219 break;
03220
03221
03222
03223
03224
03225
03226
03227
03228 case NPY_UINT:
03229 __pyx_v_f = ((char *)"I");
03230 break;
03231
03232
03233
03234
03235
03236
03237
03238
03239 case NPY_LONG:
03240 __pyx_v_f = ((char *)"l");
03241 break;
03242
03243
03244
03245
03246
03247
03248
03249
03250 case NPY_ULONG:
03251 __pyx_v_f = ((char *)"L");
03252 break;
03253
03254
03255
03256
03257
03258
03259
03260
03261 case NPY_LONGLONG:
03262 __pyx_v_f = ((char *)"q");
03263 break;
03264
03265
03266
03267
03268
03269
03270
03271
03272 case NPY_ULONGLONG:
03273 __pyx_v_f = ((char *)"Q");
03274 break;
03275
03276
03277
03278
03279
03280
03281
03282
03283 case NPY_FLOAT:
03284 __pyx_v_f = ((char *)"f");
03285 break;
03286
03287
03288
03289
03290
03291
03292
03293
03294 case NPY_DOUBLE:
03295 __pyx_v_f = ((char *)"d");
03296 break;
03297
03298
03299
03300
03301
03302
03303
03304
03305 case NPY_LONGDOUBLE:
03306 __pyx_v_f = ((char *)"g");
03307 break;
03308
03309
03310
03311
03312
03313
03314
03315
03316 case NPY_CFLOAT:
03317 __pyx_v_f = ((char *)"Zf");
03318 break;
03319
03320
03321
03322
03323
03324
03325
03326
03327 case NPY_CDOUBLE:
03328 __pyx_v_f = ((char *)"Zd");
03329 break;
03330
03331
03332
03333
03334
03335
03336
03337
03338 case NPY_CLONGDOUBLE:
03339 __pyx_v_f = ((char *)"Zg");
03340 break;
03341
03342
03343
03344
03345
03346
03347
03348
03349 case NPY_OBJECT:
03350 __pyx_v_f = ((char *)"O");
03351 break;
03352 default:
03353
03354
03355
03356
03357
03358
03359
03360
03361 __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_t); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 278, __pyx_L1_error)
03362 __Pyx_GOTREF(__pyx_t_3);
03363 __pyx_t_6 = PyUnicode_Format(__pyx_kp_u_unknown_dtype_code_in_numpy_pxd, __pyx_t_3); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 278, __pyx_L1_error)
03364 __Pyx_GOTREF(__pyx_t_6);
03365 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
03366 __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 278, __pyx_L1_error)
03367 __Pyx_GOTREF(__pyx_t_3);
03368 __Pyx_GIVEREF(__pyx_t_6);
03369 PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_6);
03370 __pyx_t_6 = 0;
03371 __pyx_t_6 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_t_3, NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 278, __pyx_L1_error)
03372 __Pyx_GOTREF(__pyx_t_6);
03373 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
03374 __Pyx_Raise(__pyx_t_6, 0, 0, 0);
03375 __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
03376 __PYX_ERR(1, 278, __pyx_L1_error)
03377 break;
03378 }
03379
03380
03381
03382
03383
03384
03385
03386
03387 __pyx_v_info->format = __pyx_v_f;
03388
03389
03390
03391
03392
03393
03394
03395
03396 __pyx_r = 0;
03397 goto __pyx_L0;
03398
03399
03400
03401
03402
03403
03404
03405
03406 }
03407
03408
03409
03410
03411
03412
03413
03414
03415 {
03416 __pyx_v_info->format = ((char *)malloc(0xFF));
03417
03418
03419
03420
03421
03422
03423
03424
03425 (__pyx_v_info->format[0]) = '^';
03426
03427
03428
03429
03430
03431
03432
03433
03434 __pyx_v_offset = 0;
03435
03436
03437
03438
03439
03440
03441
03442
03443 __pyx_t_7 = __pyx_f_5numpy__util_dtypestring(__pyx_v_descr, (__pyx_v_info->format + 1), (__pyx_v_info->format + 0xFF), (&__pyx_v_offset)); if (unlikely(__pyx_t_7 == NULL)) __PYX_ERR(1, 285, __pyx_L1_error)
03444 __pyx_v_f = __pyx_t_7;
03445
03446
03447
03448
03449
03450
03451
03452
03453 (__pyx_v_f[0]) = '\x00';
03454 }
03455
03456
03457
03458
03459
03460
03461
03462
03463
03464
03465 __pyx_r = 0;
03466 goto __pyx_L0;
03467 __pyx_L1_error:;
03468 __Pyx_XDECREF(__pyx_t_3);
03469 __Pyx_XDECREF(__pyx_t_6);
03470 __Pyx_AddTraceback("numpy.ndarray.__getbuffer__", __pyx_clineno, __pyx_lineno, __pyx_filename);
03471 __pyx_r = -1;
03472 if (__pyx_v_info != NULL && __pyx_v_info->obj != NULL) {
03473 __Pyx_GOTREF(__pyx_v_info->obj);
03474 __Pyx_DECREF(__pyx_v_info->obj); __pyx_v_info->obj = NULL;
03475 }
03476 goto __pyx_L2;
03477 __pyx_L0:;
03478 if (__pyx_v_info != NULL && __pyx_v_info->obj == Py_None) {
03479 __Pyx_GOTREF(Py_None);
03480 __Pyx_DECREF(Py_None); __pyx_v_info->obj = NULL;
03481 }
03482 __pyx_L2:;
03483 __Pyx_XDECREF((PyObject *)__pyx_v_descr);
03484 __Pyx_RefNannyFinishContext();
03485 return __pyx_r;
03486 }
03487
03488
03489
03490
03491
03492
03493
03494
03495
03496
03497 static CYTHON_UNUSED void __pyx_pw_5numpy_7ndarray_3__releasebuffer__(PyObject *__pyx_v_self, Py_buffer *__pyx_v_info);
03498 static CYTHON_UNUSED void __pyx_pw_5numpy_7ndarray_3__releasebuffer__(PyObject *__pyx_v_self, Py_buffer *__pyx_v_info) {
03499 __Pyx_RefNannyDeclarations
03500 __Pyx_RefNannySetupContext("__releasebuffer__ (wrapper)", 0);
03501 __pyx_pf_5numpy_7ndarray_2__releasebuffer__(((PyArrayObject *)__pyx_v_self), ((Py_buffer *)__pyx_v_info));
03502
03503
03504 __Pyx_RefNannyFinishContext();
03505 }
03506
03507 static void __pyx_pf_5numpy_7ndarray_2__releasebuffer__(PyArrayObject *__pyx_v_self, Py_buffer *__pyx_v_info) {
03508 __Pyx_RefNannyDeclarations
03509 int __pyx_t_1;
03510 __Pyx_RefNannySetupContext("__releasebuffer__", 0);
03511
03512
03513
03514
03515
03516
03517
03518
03519 __pyx_t_1 = (PyArray_HASFIELDS(__pyx_v_self) != 0);
03520 if (__pyx_t_1) {
03521
03522
03523
03524
03525
03526
03527
03528
03529 free(__pyx_v_info->format);
03530
03531
03532
03533
03534
03535
03536
03537
03538 }
03539
03540
03541
03542
03543
03544
03545
03546
03547 __pyx_t_1 = (((sizeof(npy_intp)) != (sizeof(Py_ssize_t))) != 0);
03548 if (__pyx_t_1) {
03549
03550
03551
03552
03553
03554
03555
03556
03557 free(__pyx_v_info->strides);
03558
03559
03560
03561
03562
03563
03564
03565
03566 }
03567
03568
03569
03570
03571
03572
03573
03574
03575
03576
03577 __Pyx_RefNannyFinishContext();
03578 }
03579
03580
03581
03582
03583
03584
03585
03586
03587
03588 static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew1(PyObject *__pyx_v_a) {
03589 PyObject *__pyx_r = NULL;
03590 __Pyx_RefNannyDeclarations
03591 PyObject *__pyx_t_1 = NULL;
03592 __Pyx_RefNannySetupContext("PyArray_MultiIterNew1", 0);
03593
03594
03595
03596
03597
03598
03599
03600
03601 __Pyx_XDECREF(__pyx_r);
03602 __pyx_t_1 = PyArray_MultiIterNew(1, ((void *)__pyx_v_a)); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 771, __pyx_L1_error)
03603 __Pyx_GOTREF(__pyx_t_1);
03604 __pyx_r = __pyx_t_1;
03605 __pyx_t_1 = 0;
03606 goto __pyx_L0;
03607
03608
03609
03610
03611
03612
03613
03614
03615
03616
03617 __pyx_L1_error:;
03618 __Pyx_XDECREF(__pyx_t_1);
03619 __Pyx_AddTraceback("numpy.PyArray_MultiIterNew1", __pyx_clineno, __pyx_lineno, __pyx_filename);
03620 __pyx_r = 0;
03621 __pyx_L0:;
03622 __Pyx_XGIVEREF(__pyx_r);
03623 __Pyx_RefNannyFinishContext();
03624 return __pyx_r;
03625 }
03626
03627
03628
03629
03630
03631
03632
03633
03634
03635 static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew2(PyObject *__pyx_v_a, PyObject *__pyx_v_b) {
03636 PyObject *__pyx_r = NULL;
03637 __Pyx_RefNannyDeclarations
03638 PyObject *__pyx_t_1 = NULL;
03639 __Pyx_RefNannySetupContext("PyArray_MultiIterNew2", 0);
03640
03641
03642
03643
03644
03645
03646
03647
03648 __Pyx_XDECREF(__pyx_r);
03649 __pyx_t_1 = PyArray_MultiIterNew(2, ((void *)__pyx_v_a), ((void *)__pyx_v_b)); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 774, __pyx_L1_error)
03650 __Pyx_GOTREF(__pyx_t_1);
03651 __pyx_r = __pyx_t_1;
03652 __pyx_t_1 = 0;
03653 goto __pyx_L0;
03654
03655
03656
03657
03658
03659
03660
03661
03662
03663
03664 __pyx_L1_error:;
03665 __Pyx_XDECREF(__pyx_t_1);
03666 __Pyx_AddTraceback("numpy.PyArray_MultiIterNew2", __pyx_clineno, __pyx_lineno, __pyx_filename);
03667 __pyx_r = 0;
03668 __pyx_L0:;
03669 __Pyx_XGIVEREF(__pyx_r);
03670 __Pyx_RefNannyFinishContext();
03671 return __pyx_r;
03672 }
03673
03674
03675
03676
03677
03678
03679
03680
03681
03682 static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew3(PyObject *__pyx_v_a, PyObject *__pyx_v_b, PyObject *__pyx_v_c) {
03683 PyObject *__pyx_r = NULL;
03684 __Pyx_RefNannyDeclarations
03685 PyObject *__pyx_t_1 = NULL;
03686 __Pyx_RefNannySetupContext("PyArray_MultiIterNew3", 0);
03687
03688
03689
03690
03691
03692
03693
03694
03695 __Pyx_XDECREF(__pyx_r);
03696 __pyx_t_1 = PyArray_MultiIterNew(3, ((void *)__pyx_v_a), ((void *)__pyx_v_b), ((void *)__pyx_v_c)); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 777, __pyx_L1_error)
03697 __Pyx_GOTREF(__pyx_t_1);
03698 __pyx_r = __pyx_t_1;
03699 __pyx_t_1 = 0;
03700 goto __pyx_L0;
03701
03702
03703
03704
03705
03706
03707
03708
03709
03710
03711 __pyx_L1_error:;
03712 __Pyx_XDECREF(__pyx_t_1);
03713 __Pyx_AddTraceback("numpy.PyArray_MultiIterNew3", __pyx_clineno, __pyx_lineno, __pyx_filename);
03714 __pyx_r = 0;
03715 __pyx_L0:;
03716 __Pyx_XGIVEREF(__pyx_r);
03717 __Pyx_RefNannyFinishContext();
03718 return __pyx_r;
03719 }
03720
03721
03722
03723
03724
03725
03726
03727
03728
03729 static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew4(PyObject *__pyx_v_a, PyObject *__pyx_v_b, PyObject *__pyx_v_c, PyObject *__pyx_v_d) {
03730 PyObject *__pyx_r = NULL;
03731 __Pyx_RefNannyDeclarations
03732 PyObject *__pyx_t_1 = NULL;
03733 __Pyx_RefNannySetupContext("PyArray_MultiIterNew4", 0);
03734
03735
03736
03737
03738
03739
03740
03741
03742 __Pyx_XDECREF(__pyx_r);
03743 __pyx_t_1 = PyArray_MultiIterNew(4, ((void *)__pyx_v_a), ((void *)__pyx_v_b), ((void *)__pyx_v_c), ((void *)__pyx_v_d)); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 780, __pyx_L1_error)
03744 __Pyx_GOTREF(__pyx_t_1);
03745 __pyx_r = __pyx_t_1;
03746 __pyx_t_1 = 0;
03747 goto __pyx_L0;
03748
03749
03750
03751
03752
03753
03754
03755
03756
03757
03758 __pyx_L1_error:;
03759 __Pyx_XDECREF(__pyx_t_1);
03760 __Pyx_AddTraceback("numpy.PyArray_MultiIterNew4", __pyx_clineno, __pyx_lineno, __pyx_filename);
03761 __pyx_r = 0;
03762 __pyx_L0:;
03763 __Pyx_XGIVEREF(__pyx_r);
03764 __Pyx_RefNannyFinishContext();
03765 return __pyx_r;
03766 }
03767
03768
03769
03770
03771
03772
03773
03774
03775
03776 static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew5(PyObject *__pyx_v_a, PyObject *__pyx_v_b, PyObject *__pyx_v_c, PyObject *__pyx_v_d, PyObject *__pyx_v_e) {
03777 PyObject *__pyx_r = NULL;
03778 __Pyx_RefNannyDeclarations
03779 PyObject *__pyx_t_1 = NULL;
03780 __Pyx_RefNannySetupContext("PyArray_MultiIterNew5", 0);
03781
03782
03783
03784
03785
03786
03787
03788
03789 __Pyx_XDECREF(__pyx_r);
03790 __pyx_t_1 = PyArray_MultiIterNew(5, ((void *)__pyx_v_a), ((void *)__pyx_v_b), ((void *)__pyx_v_c), ((void *)__pyx_v_d), ((void *)__pyx_v_e)); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 783, __pyx_L1_error)
03791 __Pyx_GOTREF(__pyx_t_1);
03792 __pyx_r = __pyx_t_1;
03793 __pyx_t_1 = 0;
03794 goto __pyx_L0;
03795
03796
03797
03798
03799
03800
03801
03802
03803
03804
03805 __pyx_L1_error:;
03806 __Pyx_XDECREF(__pyx_t_1);
03807 __Pyx_AddTraceback("numpy.PyArray_MultiIterNew5", __pyx_clineno, __pyx_lineno, __pyx_filename);
03808 __pyx_r = 0;
03809 __pyx_L0:;
03810 __Pyx_XGIVEREF(__pyx_r);
03811 __Pyx_RefNannyFinishContext();
03812 return __pyx_r;
03813 }
03814
03815
03816
03817
03818
03819
03820
03821
03822
03823 static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx_v_descr, char *__pyx_v_f, char *__pyx_v_end, int *__pyx_v_offset) {
03824 PyArray_Descr *__pyx_v_child = 0;
03825 int __pyx_v_endian_detector;
03826 int __pyx_v_little_endian;
03827 PyObject *__pyx_v_fields = 0;
03828 PyObject *__pyx_v_childname = NULL;
03829 PyObject *__pyx_v_new_offset = NULL;
03830 PyObject *__pyx_v_t = NULL;
03831 char *__pyx_r;
03832 __Pyx_RefNannyDeclarations
03833 PyObject *__pyx_t_1 = NULL;
03834 Py_ssize_t __pyx_t_2;
03835 PyObject *__pyx_t_3 = NULL;
03836 PyObject *__pyx_t_4 = NULL;
03837 int __pyx_t_5;
03838 int __pyx_t_6;
03839 int __pyx_t_7;
03840 long __pyx_t_8;
03841 char *__pyx_t_9;
03842 __Pyx_RefNannySetupContext("_util_dtypestring", 0);
03843
03844
03845
03846
03847
03848
03849
03850
03851 __pyx_v_endian_detector = 1;
03852
03853
03854
03855
03856
03857
03858
03859
03860 __pyx_v_little_endian = ((((char *)(&__pyx_v_endian_detector))[0]) != 0);
03861
03862
03863
03864
03865
03866
03867
03868
03869 if (unlikely(__pyx_v_descr->names == Py_None)) {
03870 PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable");
03871 __PYX_ERR(1, 794, __pyx_L1_error)
03872 }
03873 __pyx_t_1 = __pyx_v_descr->names; __Pyx_INCREF(__pyx_t_1); __pyx_t_2 = 0;
03874 for (;;) {
03875 if (__pyx_t_2 >= PyTuple_GET_SIZE(__pyx_t_1)) break;
03876 #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
03877 __pyx_t_3 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_3); __pyx_t_2++; if (unlikely(0 < 0)) __PYX_ERR(1, 794, __pyx_L1_error)
03878 #else
03879 __pyx_t_3 = PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 794, __pyx_L1_error)
03880 __Pyx_GOTREF(__pyx_t_3);
03881 #endif
03882 __Pyx_XDECREF_SET(__pyx_v_childname, __pyx_t_3);
03883 __pyx_t_3 = 0;
03884
03885
03886
03887
03888
03889
03890
03891
03892 if (unlikely(__pyx_v_descr->fields == Py_None)) {
03893 PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
03894 __PYX_ERR(1, 795, __pyx_L1_error)
03895 }
03896 __pyx_t_3 = __Pyx_PyDict_GetItem(__pyx_v_descr->fields, __pyx_v_childname); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 795, __pyx_L1_error)
03897 __Pyx_GOTREF(__pyx_t_3);
03898 if (!(likely(PyTuple_CheckExact(__pyx_t_3))||((__pyx_t_3) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_t_3)->tp_name), 0))) __PYX_ERR(1, 795, __pyx_L1_error)
03899 __Pyx_XDECREF_SET(__pyx_v_fields, ((PyObject*)__pyx_t_3));
03900 __pyx_t_3 = 0;
03901
03902
03903
03904
03905
03906
03907
03908
03909 if (likely(__pyx_v_fields != Py_None)) {
03910 PyObject* sequence = __pyx_v_fields;
03911 #if !CYTHON_COMPILING_IN_PYPY
03912 Py_ssize_t size = Py_SIZE(sequence);
03913 #else
03914 Py_ssize_t size = PySequence_Size(sequence);
03915 #endif
03916 if (unlikely(size != 2)) {
03917 if (size > 2) __Pyx_RaiseTooManyValuesError(2);
03918 else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
03919 __PYX_ERR(1, 796, __pyx_L1_error)
03920 }
03921 #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
03922 __pyx_t_3 = PyTuple_GET_ITEM(sequence, 0);
03923 __pyx_t_4 = PyTuple_GET_ITEM(sequence, 1);
03924 __Pyx_INCREF(__pyx_t_3);
03925 __Pyx_INCREF(__pyx_t_4);
03926 #else
03927 __pyx_t_3 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 796, __pyx_L1_error)
03928 __Pyx_GOTREF(__pyx_t_3);
03929 __pyx_t_4 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 796, __pyx_L1_error)
03930 __Pyx_GOTREF(__pyx_t_4);
03931 #endif
03932 } else {
03933 __Pyx_RaiseNoneNotIterableError(); __PYX_ERR(1, 796, __pyx_L1_error)
03934 }
03935 if (!(likely(((__pyx_t_3) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_3, __pyx_ptype_5numpy_dtype))))) __PYX_ERR(1, 796, __pyx_L1_error)
03936 __Pyx_XDECREF_SET(__pyx_v_child, ((PyArray_Descr *)__pyx_t_3));
03937 __pyx_t_3 = 0;
03938 __Pyx_XDECREF_SET(__pyx_v_new_offset, __pyx_t_4);
03939 __pyx_t_4 = 0;
03940
03941
03942
03943
03944
03945
03946
03947
03948 __pyx_t_4 = __Pyx_PyInt_From_int((__pyx_v_offset[0])); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 798, __pyx_L1_error)
03949 __Pyx_GOTREF(__pyx_t_4);
03950 __pyx_t_3 = PyNumber_Subtract(__pyx_v_new_offset, __pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 798, __pyx_L1_error)
03951 __Pyx_GOTREF(__pyx_t_3);
03952 __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
03953 __pyx_t_5 = __Pyx_PyInt_As_int(__pyx_t_3); if (unlikely((__pyx_t_5 == (int)-1) && PyErr_Occurred())) __PYX_ERR(1, 798, __pyx_L1_error)
03954 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
03955 __pyx_t_6 = ((((__pyx_v_end - __pyx_v_f) - ((int)__pyx_t_5)) < 15) != 0);
03956 if (__pyx_t_6) {
03957
03958
03959
03960
03961
03962
03963
03964
03965 __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_RuntimeError, __pyx_tuple__16, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 799, __pyx_L1_error)
03966 __Pyx_GOTREF(__pyx_t_3);
03967 __Pyx_Raise(__pyx_t_3, 0, 0, 0);
03968 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
03969 __PYX_ERR(1, 799, __pyx_L1_error)
03970
03971
03972
03973
03974
03975
03976
03977
03978 }
03979
03980
03981
03982
03983
03984
03985
03986
03987 __pyx_t_7 = ((__pyx_v_child->byteorder == '>') != 0);
03988 if (!__pyx_t_7) {
03989 goto __pyx_L8_next_or;
03990 } else {
03991 }
03992 __pyx_t_7 = (__pyx_v_little_endian != 0);
03993 if (!__pyx_t_7) {
03994 } else {
03995 __pyx_t_6 = __pyx_t_7;
03996 goto __pyx_L7_bool_binop_done;
03997 }
03998 __pyx_L8_next_or:;
03999
04000
04001
04002
04003
04004
04005
04006
04007 __pyx_t_7 = ((__pyx_v_child->byteorder == '<') != 0);
04008 if (__pyx_t_7) {
04009 } else {
04010 __pyx_t_6 = __pyx_t_7;
04011 goto __pyx_L7_bool_binop_done;
04012 }
04013 __pyx_t_7 = ((!(__pyx_v_little_endian != 0)) != 0);
04014 __pyx_t_6 = __pyx_t_7;
04015 __pyx_L7_bool_binop_done:;
04016
04017
04018
04019
04020
04021
04022
04023
04024 if (__pyx_t_6) {
04025
04026
04027
04028
04029
04030
04031
04032
04033 __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__17, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 803, __pyx_L1_error)
04034 __Pyx_GOTREF(__pyx_t_3);
04035 __Pyx_Raise(__pyx_t_3, 0, 0, 0);
04036 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
04037 __PYX_ERR(1, 803, __pyx_L1_error)
04038
04039
04040
04041
04042
04043
04044
04045
04046 }
04047
04048
04049
04050
04051
04052
04053
04054
04055 while (1) {
04056 __pyx_t_3 = __Pyx_PyInt_From_int((__pyx_v_offset[0])); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 813, __pyx_L1_error)
04057 __Pyx_GOTREF(__pyx_t_3);
04058 __pyx_t_4 = PyObject_RichCompare(__pyx_t_3, __pyx_v_new_offset, Py_LT); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 813, __pyx_L1_error)
04059 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
04060 __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(1, 813, __pyx_L1_error)
04061 __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
04062 if (!__pyx_t_6) break;
04063
04064
04065
04066
04067
04068
04069
04070
04071 (__pyx_v_f[0]) = 0x78;
04072
04073
04074
04075
04076
04077
04078
04079
04080 __pyx_v_f = (__pyx_v_f + 1);
04081
04082
04083
04084
04085
04086
04087
04088
04089 __pyx_t_8 = 0;
04090 (__pyx_v_offset[__pyx_t_8]) = ((__pyx_v_offset[__pyx_t_8]) + 1);
04091 }
04092
04093
04094
04095
04096
04097
04098
04099
04100 __pyx_t_8 = 0;
04101 (__pyx_v_offset[__pyx_t_8]) = ((__pyx_v_offset[__pyx_t_8]) + __pyx_v_child->elsize);
04102
04103
04104
04105
04106
04107
04108
04109
04110 __pyx_t_6 = ((!(PyDataType_HASFIELDS(__pyx_v_child) != 0)) != 0);
04111 if (__pyx_t_6) {
04112
04113
04114
04115
04116
04117
04118
04119
04120 __pyx_t_4 = __Pyx_PyInt_From_int(__pyx_v_child->type_num); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 821, __pyx_L1_error)
04121 __Pyx_GOTREF(__pyx_t_4);
04122 __Pyx_XDECREF_SET(__pyx_v_t, __pyx_t_4);
04123 __pyx_t_4 = 0;
04124
04125
04126
04127
04128
04129
04130
04131
04132 __pyx_t_6 = (((__pyx_v_end - __pyx_v_f) < 5) != 0);
04133 if (__pyx_t_6) {
04134
04135
04136
04137
04138
04139
04140
04141
04142 __pyx_t_4 = __Pyx_PyObject_Call(__pyx_builtin_RuntimeError, __pyx_tuple__18, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 823, __pyx_L1_error)
04143 __Pyx_GOTREF(__pyx_t_4);
04144 __Pyx_Raise(__pyx_t_4, 0, 0, 0);
04145 __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
04146 __PYX_ERR(1, 823, __pyx_L1_error)
04147
04148
04149
04150
04151
04152
04153
04154
04155 }
04156
04157
04158
04159
04160
04161
04162
04163
04164 __pyx_t_4 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_BYTE); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 826, __pyx_L1_error)
04165 __Pyx_GOTREF(__pyx_t_4);
04166 __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_4, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 826, __pyx_L1_error)
04167 __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
04168 __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(1, 826, __pyx_L1_error)
04169 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
04170 if (__pyx_t_6) {
04171 (__pyx_v_f[0]) = 98;
04172 goto __pyx_L15;
04173 }
04174
04175
04176
04177
04178
04179
04180
04181
04182 __pyx_t_3 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_UBYTE); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 827, __pyx_L1_error)
04183 __Pyx_GOTREF(__pyx_t_3);
04184 __pyx_t_4 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 827, __pyx_L1_error)
04185 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
04186 __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(1, 827, __pyx_L1_error)
04187 __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
04188 if (__pyx_t_6) {
04189 (__pyx_v_f[0]) = 66;
04190 goto __pyx_L15;
04191 }
04192
04193
04194
04195
04196
04197
04198
04199
04200 __pyx_t_4 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_SHORT); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 828, __pyx_L1_error)
04201 __Pyx_GOTREF(__pyx_t_4);
04202 __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_4, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 828, __pyx_L1_error)
04203 __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
04204 __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(1, 828, __pyx_L1_error)
04205 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
04206 if (__pyx_t_6) {
04207 (__pyx_v_f[0]) = 0x68;
04208 goto __pyx_L15;
04209 }
04210
04211
04212
04213
04214
04215
04216
04217
04218 __pyx_t_3 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_USHORT); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 829, __pyx_L1_error)
04219 __Pyx_GOTREF(__pyx_t_3);
04220 __pyx_t_4 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 829, __pyx_L1_error)
04221 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
04222 __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(1, 829, __pyx_L1_error)
04223 __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
04224 if (__pyx_t_6) {
04225 (__pyx_v_f[0]) = 72;
04226 goto __pyx_L15;
04227 }
04228
04229
04230
04231
04232
04233
04234
04235
04236 __pyx_t_4 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_INT); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 830, __pyx_L1_error)
04237 __Pyx_GOTREF(__pyx_t_4);
04238 __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_4, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 830, __pyx_L1_error)
04239 __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
04240 __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(1, 830, __pyx_L1_error)
04241 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
04242 if (__pyx_t_6) {
04243 (__pyx_v_f[0]) = 0x69;
04244 goto __pyx_L15;
04245 }
04246
04247
04248
04249
04250
04251
04252
04253
04254 __pyx_t_3 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_UINT); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 831, __pyx_L1_error)
04255 __Pyx_GOTREF(__pyx_t_3);
04256 __pyx_t_4 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 831, __pyx_L1_error)
04257 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
04258 __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(1, 831, __pyx_L1_error)
04259 __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
04260 if (__pyx_t_6) {
04261 (__pyx_v_f[0]) = 73;
04262 goto __pyx_L15;
04263 }
04264
04265
04266
04267
04268
04269
04270
04271
04272 __pyx_t_4 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_LONG); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 832, __pyx_L1_error)
04273 __Pyx_GOTREF(__pyx_t_4);
04274 __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_4, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 832, __pyx_L1_error)
04275 __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
04276 __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(1, 832, __pyx_L1_error)
04277 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
04278 if (__pyx_t_6) {
04279 (__pyx_v_f[0]) = 0x6C;
04280 goto __pyx_L15;
04281 }
04282
04283
04284
04285
04286
04287
04288
04289
04290 __pyx_t_3 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_ULONG); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 833, __pyx_L1_error)
04291 __Pyx_GOTREF(__pyx_t_3);
04292 __pyx_t_4 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 833, __pyx_L1_error)
04293 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
04294 __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(1, 833, __pyx_L1_error)
04295 __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
04296 if (__pyx_t_6) {
04297 (__pyx_v_f[0]) = 76;
04298 goto __pyx_L15;
04299 }
04300
04301
04302
04303
04304
04305
04306
04307
04308 __pyx_t_4 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_LONGLONG); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 834, __pyx_L1_error)
04309 __Pyx_GOTREF(__pyx_t_4);
04310 __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_4, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 834, __pyx_L1_error)
04311 __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
04312 __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(1, 834, __pyx_L1_error)
04313 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
04314 if (__pyx_t_6) {
04315 (__pyx_v_f[0]) = 0x71;
04316 goto __pyx_L15;
04317 }
04318
04319
04320
04321
04322
04323
04324
04325
04326 __pyx_t_3 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_ULONGLONG); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 835, __pyx_L1_error)
04327 __Pyx_GOTREF(__pyx_t_3);
04328 __pyx_t_4 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 835, __pyx_L1_error)
04329 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
04330 __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(1, 835, __pyx_L1_error)
04331 __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
04332 if (__pyx_t_6) {
04333 (__pyx_v_f[0]) = 81;
04334 goto __pyx_L15;
04335 }
04336
04337
04338
04339
04340
04341
04342
04343
04344 __pyx_t_4 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_FLOAT); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 836, __pyx_L1_error)
04345 __Pyx_GOTREF(__pyx_t_4);
04346 __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_4, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 836, __pyx_L1_error)
04347 __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
04348 __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(1, 836, __pyx_L1_error)
04349 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
04350 if (__pyx_t_6) {
04351 (__pyx_v_f[0]) = 0x66;
04352 goto __pyx_L15;
04353 }
04354
04355
04356
04357
04358
04359
04360
04361
04362 __pyx_t_3 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_DOUBLE); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 837, __pyx_L1_error)
04363 __Pyx_GOTREF(__pyx_t_3);
04364 __pyx_t_4 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 837, __pyx_L1_error)
04365 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
04366 __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(1, 837, __pyx_L1_error)
04367 __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
04368 if (__pyx_t_6) {
04369 (__pyx_v_f[0]) = 0x64;
04370 goto __pyx_L15;
04371 }
04372
04373
04374
04375
04376
04377
04378
04379
04380 __pyx_t_4 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_LONGDOUBLE); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 838, __pyx_L1_error)
04381 __Pyx_GOTREF(__pyx_t_4);
04382 __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_4, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 838, __pyx_L1_error)
04383 __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
04384 __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(1, 838, __pyx_L1_error)
04385 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
04386 if (__pyx_t_6) {
04387 (__pyx_v_f[0]) = 0x67;
04388 goto __pyx_L15;
04389 }
04390
04391
04392
04393
04394
04395
04396
04397
04398 __pyx_t_3 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_CFLOAT); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 839, __pyx_L1_error)
04399 __Pyx_GOTREF(__pyx_t_3);
04400 __pyx_t_4 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 839, __pyx_L1_error)
04401 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
04402 __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(1, 839, __pyx_L1_error)
04403 __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
04404 if (__pyx_t_6) {
04405 (__pyx_v_f[0]) = 90;
04406 (__pyx_v_f[1]) = 0x66;
04407 __pyx_v_f = (__pyx_v_f + 1);
04408 goto __pyx_L15;
04409 }
04410
04411
04412
04413
04414
04415
04416
04417
04418 __pyx_t_4 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_CDOUBLE); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 840, __pyx_L1_error)
04419 __Pyx_GOTREF(__pyx_t_4);
04420 __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_4, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 840, __pyx_L1_error)
04421 __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
04422 __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(1, 840, __pyx_L1_error)
04423 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
04424 if (__pyx_t_6) {
04425 (__pyx_v_f[0]) = 90;
04426 (__pyx_v_f[1]) = 0x64;
04427 __pyx_v_f = (__pyx_v_f + 1);
04428 goto __pyx_L15;
04429 }
04430
04431
04432
04433
04434
04435
04436
04437
04438 __pyx_t_3 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_CLONGDOUBLE); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 841, __pyx_L1_error)
04439 __Pyx_GOTREF(__pyx_t_3);
04440 __pyx_t_4 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 841, __pyx_L1_error)
04441 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
04442 __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(1, 841, __pyx_L1_error)
04443 __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
04444 if (__pyx_t_6) {
04445 (__pyx_v_f[0]) = 90;
04446 (__pyx_v_f[1]) = 0x67;
04447 __pyx_v_f = (__pyx_v_f + 1);
04448 goto __pyx_L15;
04449 }
04450
04451
04452
04453
04454
04455
04456
04457
04458 __pyx_t_4 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_OBJECT); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 842, __pyx_L1_error)
04459 __Pyx_GOTREF(__pyx_t_4);
04460 __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_4, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 842, __pyx_L1_error)
04461 __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
04462 __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(1, 842, __pyx_L1_error)
04463 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
04464 if (__pyx_t_6) {
04465 (__pyx_v_f[0]) = 79;
04466 goto __pyx_L15;
04467 }
04468
04469
04470
04471
04472
04473
04474
04475
04476 {
04477 __pyx_t_3 = PyUnicode_Format(__pyx_kp_u_unknown_dtype_code_in_numpy_pxd, __pyx_v_t); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 844, __pyx_L1_error)
04478 __Pyx_GOTREF(__pyx_t_3);
04479 __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 844, __pyx_L1_error)
04480 __Pyx_GOTREF(__pyx_t_4);
04481 __Pyx_GIVEREF(__pyx_t_3);
04482 PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_3);
04483 __pyx_t_3 = 0;
04484 __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_t_4, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 844, __pyx_L1_error)
04485 __Pyx_GOTREF(__pyx_t_3);
04486 __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
04487 __Pyx_Raise(__pyx_t_3, 0, 0, 0);
04488 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
04489 __PYX_ERR(1, 844, __pyx_L1_error)
04490 }
04491 __pyx_L15:;
04492
04493
04494
04495
04496
04497
04498
04499
04500 __pyx_v_f = (__pyx_v_f + 1);
04501
04502
04503
04504
04505
04506
04507
04508
04509 goto __pyx_L13;
04510 }
04511
04512
04513
04514
04515
04516
04517
04518
04519 {
04520 __pyx_t_9 = __pyx_f_5numpy__util_dtypestring(__pyx_v_child, __pyx_v_f, __pyx_v_end, __pyx_v_offset); if (unlikely(__pyx_t_9 == NULL)) __PYX_ERR(1, 849, __pyx_L1_error)
04521 __pyx_v_f = __pyx_t_9;
04522 }
04523 __pyx_L13:;
04524
04525
04526
04527
04528
04529
04530
04531
04532 }
04533 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
04534
04535
04536
04537
04538
04539
04540
04541
04542 __pyx_r = __pyx_v_f;
04543 goto __pyx_L0;
04544
04545
04546
04547
04548
04549
04550
04551
04552
04553
04554 __pyx_L1_error:;
04555 __Pyx_XDECREF(__pyx_t_1);
04556 __Pyx_XDECREF(__pyx_t_3);
04557 __Pyx_XDECREF(__pyx_t_4);
04558 __Pyx_AddTraceback("numpy._util_dtypestring", __pyx_clineno, __pyx_lineno, __pyx_filename);
04559 __pyx_r = NULL;
04560 __pyx_L0:;
04561 __Pyx_XDECREF((PyObject *)__pyx_v_child);
04562 __Pyx_XDECREF(__pyx_v_fields);
04563 __Pyx_XDECREF(__pyx_v_childname);
04564 __Pyx_XDECREF(__pyx_v_new_offset);
04565 __Pyx_XDECREF(__pyx_v_t);
04566 __Pyx_RefNannyFinishContext();
04567 return __pyx_r;
04568 }
04569
04570
04571
04572
04573
04574
04575
04576
04577
04578 static CYTHON_INLINE void __pyx_f_5numpy_set_array_base(PyArrayObject *__pyx_v_arr, PyObject *__pyx_v_base) {
04579 PyObject *__pyx_v_baseptr;
04580 __Pyx_RefNannyDeclarations
04581 int __pyx_t_1;
04582 int __pyx_t_2;
04583 __Pyx_RefNannySetupContext("set_array_base", 0);
04584
04585
04586
04587
04588
04589
04590
04591
04592 __pyx_t_1 = (__pyx_v_base == Py_None);
04593 __pyx_t_2 = (__pyx_t_1 != 0);
04594 if (__pyx_t_2) {
04595
04596
04597
04598
04599
04600
04601
04602
04603 __pyx_v_baseptr = NULL;
04604
04605
04606
04607
04608
04609
04610
04611
04612 goto __pyx_L3;
04613 }
04614
04615
04616
04617
04618
04619
04620
04621
04622 {
04623 Py_INCREF(__pyx_v_base);
04624
04625
04626
04627
04628
04629
04630
04631
04632 __pyx_v_baseptr = ((PyObject *)__pyx_v_base);
04633 }
04634 __pyx_L3:;
04635
04636
04637
04638
04639
04640
04641
04642
04643 Py_XDECREF(__pyx_v_arr->base);
04644
04645
04646
04647
04648
04649
04650
04651
04652 __pyx_v_arr->base = __pyx_v_baseptr;
04653
04654
04655
04656
04657
04658
04659
04660
04661
04662
04663 __Pyx_RefNannyFinishContext();
04664 }
04665
04666
04667
04668
04669
04670
04671
04672
04673
04674 static CYTHON_INLINE PyObject *__pyx_f_5numpy_get_array_base(PyArrayObject *__pyx_v_arr) {
04675 PyObject *__pyx_r = NULL;
04676 __Pyx_RefNannyDeclarations
04677 int __pyx_t_1;
04678 __Pyx_RefNannySetupContext("get_array_base", 0);
04679
04680
04681
04682
04683
04684
04685
04686
04687 __pyx_t_1 = ((__pyx_v_arr->base == NULL) != 0);
04688 if (__pyx_t_1) {
04689
04690
04691
04692
04693
04694
04695
04696
04697 __Pyx_XDECREF(__pyx_r);
04698 __Pyx_INCREF(Py_None);
04699 __pyx_r = Py_None;
04700 goto __pyx_L0;
04701
04702
04703
04704
04705
04706
04707
04708
04709 }
04710
04711
04712
04713
04714
04715
04716
04717
04718 {
04719 __Pyx_XDECREF(__pyx_r);
04720 __Pyx_INCREF(((PyObject *)__pyx_v_arr->base));
04721 __pyx_r = ((PyObject *)__pyx_v_arr->base);
04722 goto __pyx_L0;
04723 }
04724
04725
04726
04727
04728
04729
04730
04731
04732
04733
04734 __pyx_L0:;
04735 __Pyx_XGIVEREF(__pyx_r);
04736 __Pyx_RefNannyFinishContext();
04737 return __pyx_r;
04738 }
04739
04740
04741
04742
04743
04744
04745
04746
04747
04748 static CYTHON_INLINE int __pyx_f_5numpy_import_array(void) {
04749 int __pyx_r;
04750 __Pyx_RefNannyDeclarations
04751 PyObject *__pyx_t_1 = NULL;
04752 PyObject *__pyx_t_2 = NULL;
04753 PyObject *__pyx_t_3 = NULL;
04754 int __pyx_t_4;
04755 PyObject *__pyx_t_5 = NULL;
04756 PyObject *__pyx_t_6 = NULL;
04757 PyObject *__pyx_t_7 = NULL;
04758 PyObject *__pyx_t_8 = NULL;
04759 __Pyx_RefNannySetupContext("import_array", 0);
04760
04761
04762
04763
04764
04765
04766
04767
04768 {
04769 __Pyx_PyThreadState_declare
04770 __Pyx_PyThreadState_assign
04771 __Pyx_ExceptionSave(&__pyx_t_1, &__pyx_t_2, &__pyx_t_3);
04772 __Pyx_XGOTREF(__pyx_t_1);
04773 __Pyx_XGOTREF(__pyx_t_2);
04774 __Pyx_XGOTREF(__pyx_t_3);
04775 {
04776
04777
04778
04779
04780
04781
04782
04783
04784 __pyx_t_4 = _import_array(); if (unlikely(__pyx_t_4 == -1)) __PYX_ERR(1, 987, __pyx_L3_error)
04785
04786
04787
04788
04789
04790
04791
04792
04793 }
04794 __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
04795 __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
04796 __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
04797 goto __pyx_L10_try_end;
04798 __pyx_L3_error:;
04799 __Pyx_PyThreadState_assign
04800
04801
04802
04803
04804
04805
04806
04807
04808 __pyx_t_4 = __Pyx_PyErr_ExceptionMatches(((PyObject *)(&((PyTypeObject*)PyExc_Exception)[0])));
04809 if (__pyx_t_4) {
04810 __Pyx_AddTraceback("numpy.import_array", __pyx_clineno, __pyx_lineno, __pyx_filename);
04811 if (__Pyx_GetException(&__pyx_t_5, &__pyx_t_6, &__pyx_t_7) < 0) __PYX_ERR(1, 988, __pyx_L5_except_error)
04812 __Pyx_GOTREF(__pyx_t_5);
04813 __Pyx_GOTREF(__pyx_t_6);
04814 __Pyx_GOTREF(__pyx_t_7);
04815
04816
04817
04818
04819
04820
04821
04822
04823 __pyx_t_8 = __Pyx_PyObject_Call(__pyx_builtin_ImportError, __pyx_tuple__19, NULL); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 989, __pyx_L5_except_error)
04824 __Pyx_GOTREF(__pyx_t_8);
04825 __Pyx_Raise(__pyx_t_8, 0, 0, 0);
04826 __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
04827 __PYX_ERR(1, 989, __pyx_L5_except_error)
04828 }
04829 goto __pyx_L5_except_error;
04830 __pyx_L5_except_error:;
04831
04832
04833
04834
04835
04836
04837
04838
04839 __Pyx_PyThreadState_assign
04840 __Pyx_XGIVEREF(__pyx_t_1);
04841 __Pyx_XGIVEREF(__pyx_t_2);
04842 __Pyx_XGIVEREF(__pyx_t_3);
04843 __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3);
04844 goto __pyx_L1_error;
04845 __pyx_L10_try_end:;
04846 }
04847
04848
04849
04850
04851
04852
04853
04854
04855
04856
04857 __pyx_r = 0;
04858 goto __pyx_L0;
04859 __pyx_L1_error:;
04860 __Pyx_XDECREF(__pyx_t_5);
04861 __Pyx_XDECREF(__pyx_t_6);
04862 __Pyx_XDECREF(__pyx_t_7);
04863 __Pyx_XDECREF(__pyx_t_8);
04864 __Pyx_AddTraceback("numpy.import_array", __pyx_clineno, __pyx_lineno, __pyx_filename);
04865 __pyx_r = -1;
04866 __pyx_L0:;
04867 __Pyx_RefNannyFinishContext();
04868 return __pyx_r;
04869 }
04870
04871
04872
04873
04874
04875
04876
04877
04878
04879 static CYTHON_INLINE int __pyx_f_5numpy_import_umath(void) {
04880 int __pyx_r;
04881 __Pyx_RefNannyDeclarations
04882 PyObject *__pyx_t_1 = NULL;
04883 PyObject *__pyx_t_2 = NULL;
04884 PyObject *__pyx_t_3 = NULL;
04885 int __pyx_t_4;
04886 PyObject *__pyx_t_5 = NULL;
04887 PyObject *__pyx_t_6 = NULL;
04888 PyObject *__pyx_t_7 = NULL;
04889 PyObject *__pyx_t_8 = NULL;
04890 __Pyx_RefNannySetupContext("import_umath", 0);
04891
04892
04893
04894
04895
04896
04897
04898
04899 {
04900 __Pyx_PyThreadState_declare
04901 __Pyx_PyThreadState_assign
04902 __Pyx_ExceptionSave(&__pyx_t_1, &__pyx_t_2, &__pyx_t_3);
04903 __Pyx_XGOTREF(__pyx_t_1);
04904 __Pyx_XGOTREF(__pyx_t_2);
04905 __Pyx_XGOTREF(__pyx_t_3);
04906 {
04907
04908
04909
04910
04911
04912
04913
04914
04915 __pyx_t_4 = _import_umath(); if (unlikely(__pyx_t_4 == -1)) __PYX_ERR(1, 993, __pyx_L3_error)
04916
04917
04918
04919
04920
04921
04922
04923
04924 }
04925 __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
04926 __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
04927 __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
04928 goto __pyx_L10_try_end;
04929 __pyx_L3_error:;
04930 __Pyx_PyThreadState_assign
04931
04932
04933
04934
04935
04936
04937
04938
04939 __pyx_t_4 = __Pyx_PyErr_ExceptionMatches(((PyObject *)(&((PyTypeObject*)PyExc_Exception)[0])));
04940 if (__pyx_t_4) {
04941 __Pyx_AddTraceback("numpy.import_umath", __pyx_clineno, __pyx_lineno, __pyx_filename);
04942 if (__Pyx_GetException(&__pyx_t_5, &__pyx_t_6, &__pyx_t_7) < 0) __PYX_ERR(1, 994, __pyx_L5_except_error)
04943 __Pyx_GOTREF(__pyx_t_5);
04944 __Pyx_GOTREF(__pyx_t_6);
04945 __Pyx_GOTREF(__pyx_t_7);
04946
04947
04948
04949
04950
04951
04952
04953
04954 __pyx_t_8 = __Pyx_PyObject_Call(__pyx_builtin_ImportError, __pyx_tuple__20, NULL); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 995, __pyx_L5_except_error)
04955 __Pyx_GOTREF(__pyx_t_8);
04956 __Pyx_Raise(__pyx_t_8, 0, 0, 0);
04957 __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
04958 __PYX_ERR(1, 995, __pyx_L5_except_error)
04959 }
04960 goto __pyx_L5_except_error;
04961 __pyx_L5_except_error:;
04962
04963
04964
04965
04966
04967
04968
04969
04970 __Pyx_PyThreadState_assign
04971 __Pyx_XGIVEREF(__pyx_t_1);
04972 __Pyx_XGIVEREF(__pyx_t_2);
04973 __Pyx_XGIVEREF(__pyx_t_3);
04974 __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3);
04975 goto __pyx_L1_error;
04976 __pyx_L10_try_end:;
04977 }
04978
04979
04980
04981
04982
04983
04984
04985
04986
04987
04988 __pyx_r = 0;
04989 goto __pyx_L0;
04990 __pyx_L1_error:;
04991 __Pyx_XDECREF(__pyx_t_5);
04992 __Pyx_XDECREF(__pyx_t_6);
04993 __Pyx_XDECREF(__pyx_t_7);
04994 __Pyx_XDECREF(__pyx_t_8);
04995 __Pyx_AddTraceback("numpy.import_umath", __pyx_clineno, __pyx_lineno, __pyx_filename);
04996 __pyx_r = -1;
04997 __pyx_L0:;
04998 __Pyx_RefNannyFinishContext();
04999 return __pyx_r;
05000 }
05001
05002
05003
05004
05005
05006
05007
05008
05009
05010 static CYTHON_INLINE int __pyx_f_5numpy_import_ufunc(void) {
05011 int __pyx_r;
05012 __Pyx_RefNannyDeclarations
05013 PyObject *__pyx_t_1 = NULL;
05014 PyObject *__pyx_t_2 = NULL;
05015 PyObject *__pyx_t_3 = NULL;
05016 int __pyx_t_4;
05017 PyObject *__pyx_t_5 = NULL;
05018 PyObject *__pyx_t_6 = NULL;
05019 PyObject *__pyx_t_7 = NULL;
05020 PyObject *__pyx_t_8 = NULL;
05021 __Pyx_RefNannySetupContext("import_ufunc", 0);
05022
05023
05024
05025
05026
05027
05028
05029
05030 {
05031 __Pyx_PyThreadState_declare
05032 __Pyx_PyThreadState_assign
05033 __Pyx_ExceptionSave(&__pyx_t_1, &__pyx_t_2, &__pyx_t_3);
05034 __Pyx_XGOTREF(__pyx_t_1);
05035 __Pyx_XGOTREF(__pyx_t_2);
05036 __Pyx_XGOTREF(__pyx_t_3);
05037 {
05038
05039
05040
05041
05042
05043
05044
05045
05046 __pyx_t_4 = _import_umath(); if (unlikely(__pyx_t_4 == -1)) __PYX_ERR(1, 999, __pyx_L3_error)
05047
05048
05049
05050
05051
05052
05053
05054
05055 }
05056 __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
05057 __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
05058 __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
05059 goto __pyx_L10_try_end;
05060 __pyx_L3_error:;
05061 __Pyx_PyThreadState_assign
05062
05063
05064
05065
05066
05067
05068
05069 __pyx_t_4 = __Pyx_PyErr_ExceptionMatches(((PyObject *)(&((PyTypeObject*)PyExc_Exception)[0])));
05070 if (__pyx_t_4) {
05071 __Pyx_AddTraceback("numpy.import_ufunc", __pyx_clineno, __pyx_lineno, __pyx_filename);
05072 if (__Pyx_GetException(&__pyx_t_5, &__pyx_t_6, &__pyx_t_7) < 0) __PYX_ERR(1, 1000, __pyx_L5_except_error)
05073 __Pyx_GOTREF(__pyx_t_5);
05074 __Pyx_GOTREF(__pyx_t_6);
05075 __Pyx_GOTREF(__pyx_t_7);
05076
05077
05078
05079
05080
05081
05082 __pyx_t_8 = __Pyx_PyObject_Call(__pyx_builtin_ImportError, __pyx_tuple__21, NULL); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 1001, __pyx_L5_except_error)
05083 __Pyx_GOTREF(__pyx_t_8);
05084 __Pyx_Raise(__pyx_t_8, 0, 0, 0);
05085 __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
05086 __PYX_ERR(1, 1001, __pyx_L5_except_error)
05087 }
05088 goto __pyx_L5_except_error;
05089 __pyx_L5_except_error:;
05090
05091
05092
05093
05094
05095
05096
05097
05098 __Pyx_PyThreadState_assign
05099 __Pyx_XGIVEREF(__pyx_t_1);
05100 __Pyx_XGIVEREF(__pyx_t_2);
05101 __Pyx_XGIVEREF(__pyx_t_3);
05102 __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3);
05103 goto __pyx_L1_error;
05104 __pyx_L10_try_end:;
05105 }
05106
05107
05108
05109
05110
05111
05112
05113
05114
05115
05116 __pyx_r = 0;
05117 goto __pyx_L0;
05118 __pyx_L1_error:;
05119 __Pyx_XDECREF(__pyx_t_5);
05120 __Pyx_XDECREF(__pyx_t_6);
05121 __Pyx_XDECREF(__pyx_t_7);
05122 __Pyx_XDECREF(__pyx_t_8);
05123 __Pyx_AddTraceback("numpy.import_ufunc", __pyx_clineno, __pyx_lineno, __pyx_filename);
05124 __pyx_r = -1;
05125 __pyx_L0:;
05126 __Pyx_RefNannyFinishContext();
05127 return __pyx_r;
05128 }
05129
05130 static PyMethodDef __pyx_methods[] = {
05131 {0, 0, 0, 0}
05132 };
05133
05134 #if PY_MAJOR_VERSION >= 3
05135 static struct PyModuleDef __pyx_moduledef = {
05136 #if PY_VERSION_HEX < 0x03020000
05137 { PyObject_HEAD_INIT(NULL) NULL, 0, NULL },
05138 #else
05139 PyModuleDef_HEAD_INIT,
05140 #endif
05141 "cpu_nms",
05142 0,
05143 -1,
05144 __pyx_methods ,
05145 NULL,
05146 NULL,
05147 NULL,
05148 NULL
05149 };
05150 #endif
05151
05152 static __Pyx_StringTabEntry __pyx_string_tab[] = {
05153 {&__pyx_kp_u_Format_string_allocated_too_shor, __pyx_k_Format_string_allocated_too_shor, sizeof(__pyx_k_Format_string_allocated_too_shor), 0, 1, 0, 0},
05154 {&__pyx_kp_u_Format_string_allocated_too_shor_2, __pyx_k_Format_string_allocated_too_shor_2, sizeof(__pyx_k_Format_string_allocated_too_shor_2), 0, 1, 0, 0},
05155 {&__pyx_n_s_ImportError, __pyx_k_ImportError, sizeof(__pyx_k_ImportError), 0, 0, 1, 1},
05156 {&__pyx_kp_u_Non_native_byte_order_not_suppor, __pyx_k_Non_native_byte_order_not_suppor, sizeof(__pyx_k_Non_native_byte_order_not_suppor), 0, 1, 0, 0},
05157 {&__pyx_n_s_RuntimeError, __pyx_k_RuntimeError, sizeof(__pyx_k_RuntimeError), 0, 0, 1, 1},
05158 {&__pyx_n_s_ValueError, __pyx_k_ValueError, sizeof(__pyx_k_ValueError), 0, 0, 1, 1},
05159 {&__pyx_n_s_areas, __pyx_k_areas, sizeof(__pyx_k_areas), 0, 0, 1, 1},
05160 {&__pyx_n_s_argsort, __pyx_k_argsort, sizeof(__pyx_k_argsort), 0, 0, 1, 1},
05161 {&__pyx_n_s_astype, __pyx_k_astype, sizeof(__pyx_k_astype), 0, 0, 1, 1},
05162 {&__pyx_n_s_cpu_nms, __pyx_k_cpu_nms, sizeof(__pyx_k_cpu_nms), 0, 0, 1, 1},
05163 {&__pyx_n_s_dets, __pyx_k_dets, sizeof(__pyx_k_dets), 0, 0, 1, 1},
05164 {&__pyx_n_s_dtype, __pyx_k_dtype, sizeof(__pyx_k_dtype), 0, 0, 1, 1},
05165 {&__pyx_n_s_h, __pyx_k_h, sizeof(__pyx_k_h), 0, 0, 1, 1},
05166 {&__pyx_kp_s_home_andrewsilva_Deformable_Con, __pyx_k_home_andrewsilva_Deformable_Con, sizeof(__pyx_k_home_andrewsilva_Deformable_Con), 0, 0, 1, 0},
05167 {&__pyx_n_s_i, __pyx_k_i, sizeof(__pyx_k_i), 0, 0, 1, 1},
05168 {&__pyx_n_s_i_2, __pyx_k_i_2, sizeof(__pyx_k_i_2), 0, 0, 1, 1},
05169 {&__pyx_n_s_iarea, __pyx_k_iarea, sizeof(__pyx_k_iarea), 0, 0, 1, 1},
05170 {&__pyx_n_s_import, __pyx_k_import, sizeof(__pyx_k_import), 0, 0, 1, 1},
05171 {&__pyx_n_s_int, __pyx_k_int, sizeof(__pyx_k_int), 0, 0, 1, 1},
05172 {&__pyx_n_s_inter, __pyx_k_inter, sizeof(__pyx_k_inter), 0, 0, 1, 1},
05173 {&__pyx_n_s_ix1, __pyx_k_ix1, sizeof(__pyx_k_ix1), 0, 0, 1, 1},
05174 {&__pyx_n_s_ix2, __pyx_k_ix2, sizeof(__pyx_k_ix2), 0, 0, 1, 1},
05175 {&__pyx_n_s_iy1, __pyx_k_iy1, sizeof(__pyx_k_iy1), 0, 0, 1, 1},
05176 {&__pyx_n_s_iy2, __pyx_k_iy2, sizeof(__pyx_k_iy2), 0, 0, 1, 1},
05177 {&__pyx_n_s_j, __pyx_k_j, sizeof(__pyx_k_j), 0, 0, 1, 1},
05178 {&__pyx_n_s_j_2, __pyx_k_j_2, sizeof(__pyx_k_j_2), 0, 0, 1, 1},
05179 {&__pyx_n_s_keep, __pyx_k_keep, sizeof(__pyx_k_keep), 0, 0, 1, 1},
05180 {&__pyx_n_s_main, __pyx_k_main, sizeof(__pyx_k_main), 0, 0, 1, 1},
05181 {&__pyx_kp_u_ndarray_is_not_C_contiguous, __pyx_k_ndarray_is_not_C_contiguous, sizeof(__pyx_k_ndarray_is_not_C_contiguous), 0, 1, 0, 0},
05182 {&__pyx_kp_u_ndarray_is_not_Fortran_contiguou, __pyx_k_ndarray_is_not_Fortran_contiguou, sizeof(__pyx_k_ndarray_is_not_Fortran_contiguou), 0, 1, 0, 0},
05183 {&__pyx_n_s_ndets, __pyx_k_ndets, sizeof(__pyx_k_ndets), 0, 0, 1, 1},
05184 {&__pyx_n_s_np, __pyx_k_np, sizeof(__pyx_k_np), 0, 0, 1, 1},
05185 {&__pyx_n_s_numpy, __pyx_k_numpy, sizeof(__pyx_k_numpy), 0, 0, 1, 1},
05186 {&__pyx_kp_s_numpy_core_multiarray_failed_to, __pyx_k_numpy_core_multiarray_failed_to, sizeof(__pyx_k_numpy_core_multiarray_failed_to), 0, 0, 1, 0},
05187 {&__pyx_kp_s_numpy_core_umath_failed_to_impor, __pyx_k_numpy_core_umath_failed_to_impor, sizeof(__pyx_k_numpy_core_umath_failed_to_impor), 0, 0, 1, 0},
05188 {&__pyx_n_s_order, __pyx_k_order, sizeof(__pyx_k_order), 0, 0, 1, 1},
05189 {&__pyx_n_s_ovr, __pyx_k_ovr, sizeof(__pyx_k_ovr), 0, 0, 1, 1},
05190 {&__pyx_n_s_range, __pyx_k_range, sizeof(__pyx_k_range), 0, 0, 1, 1},
05191 {&__pyx_n_s_scores, __pyx_k_scores, sizeof(__pyx_k_scores), 0, 0, 1, 1},
05192 {&__pyx_n_s_suppressed, __pyx_k_suppressed, sizeof(__pyx_k_suppressed), 0, 0, 1, 1},
05193 {&__pyx_n_s_test, __pyx_k_test, sizeof(__pyx_k_test), 0, 0, 1, 1},
05194 {&__pyx_n_s_thresh, __pyx_k_thresh, sizeof(__pyx_k_thresh), 0, 0, 1, 1},
05195 {&__pyx_kp_u_unknown_dtype_code_in_numpy_pxd, __pyx_k_unknown_dtype_code_in_numpy_pxd, sizeof(__pyx_k_unknown_dtype_code_in_numpy_pxd), 0, 1, 0, 0},
05196 {&__pyx_n_s_w, __pyx_k_w, sizeof(__pyx_k_w), 0, 0, 1, 1},
05197 {&__pyx_n_s_x1, __pyx_k_x1, sizeof(__pyx_k_x1), 0, 0, 1, 1},
05198 {&__pyx_n_s_x2, __pyx_k_x2, sizeof(__pyx_k_x2), 0, 0, 1, 1},
05199 {&__pyx_n_s_xx1, __pyx_k_xx1, sizeof(__pyx_k_xx1), 0, 0, 1, 1},
05200 {&__pyx_n_s_xx2, __pyx_k_xx2, sizeof(__pyx_k_xx2), 0, 0, 1, 1},
05201 {&__pyx_n_s_y1, __pyx_k_y1, sizeof(__pyx_k_y1), 0, 0, 1, 1},
05202 {&__pyx_n_s_y2, __pyx_k_y2, sizeof(__pyx_k_y2), 0, 0, 1, 1},
05203 {&__pyx_n_s_yy1, __pyx_k_yy1, sizeof(__pyx_k_yy1), 0, 0, 1, 1},
05204 {&__pyx_n_s_yy2, __pyx_k_yy2, sizeof(__pyx_k_yy2), 0, 0, 1, 1},
05205 {&__pyx_n_s_zeros, __pyx_k_zeros, sizeof(__pyx_k_zeros), 0, 0, 1, 1},
05206 {0, 0, 0, 0, 0, 0, 0}
05207 };
05208 static int __Pyx_InitCachedBuiltins(void) {
05209 __pyx_builtin_range = __Pyx_GetBuiltinName(__pyx_n_s_range); if (!__pyx_builtin_range) __PYX_ERR(0, 43, __pyx_L1_error)
05210 __pyx_builtin_ValueError = __Pyx_GetBuiltinName(__pyx_n_s_ValueError); if (!__pyx_builtin_ValueError) __PYX_ERR(1, 218, __pyx_L1_error)
05211 __pyx_builtin_RuntimeError = __Pyx_GetBuiltinName(__pyx_n_s_RuntimeError); if (!__pyx_builtin_RuntimeError) __PYX_ERR(1, 799, __pyx_L1_error)
05212 __pyx_builtin_ImportError = __Pyx_GetBuiltinName(__pyx_n_s_ImportError); if (!__pyx_builtin_ImportError) __PYX_ERR(1, 989, __pyx_L1_error)
05213 return 0;
05214 __pyx_L1_error:;
05215 return -1;
05216 }
05217
05218 static int __Pyx_InitCachedConstants(void) {
05219 __Pyx_RefNannyDeclarations
05220 __Pyx_RefNannySetupContext("__Pyx_InitCachedConstants", 0);
05221
05222
05223
05224
05225
05226
05227
05228
05229 __pyx_slice_ = PySlice_New(Py_None, Py_None, Py_None); if (unlikely(!__pyx_slice_)) __PYX_ERR(0, 18, __pyx_L1_error)
05230 __Pyx_GOTREF(__pyx_slice_);
05231 __Pyx_GIVEREF(__pyx_slice_);
05232 __pyx_tuple__2 = PyTuple_Pack(2, __pyx_slice_, __pyx_int_0); if (unlikely(!__pyx_tuple__2)) __PYX_ERR(0, 18, __pyx_L1_error)
05233 __Pyx_GOTREF(__pyx_tuple__2);
05234 __Pyx_GIVEREF(__pyx_tuple__2);
05235
05236
05237
05238
05239
05240
05241
05242
05243 __pyx_slice__3 = PySlice_New(Py_None, Py_None, Py_None); if (unlikely(!__pyx_slice__3)) __PYX_ERR(0, 19, __pyx_L1_error)
05244 __Pyx_GOTREF(__pyx_slice__3);
05245 __Pyx_GIVEREF(__pyx_slice__3);
05246 __pyx_tuple__4 = PyTuple_Pack(2, __pyx_slice__3, __pyx_int_1); if (unlikely(!__pyx_tuple__4)) __PYX_ERR(0, 19, __pyx_L1_error)
05247 __Pyx_GOTREF(__pyx_tuple__4);
05248 __Pyx_GIVEREF(__pyx_tuple__4);
05249
05250
05251
05252
05253
05254
05255
05256
05257 __pyx_slice__5 = PySlice_New(Py_None, Py_None, Py_None); if (unlikely(!__pyx_slice__5)) __PYX_ERR(0, 20, __pyx_L1_error)
05258 __Pyx_GOTREF(__pyx_slice__5);
05259 __Pyx_GIVEREF(__pyx_slice__5);
05260 __pyx_tuple__6 = PyTuple_Pack(2, __pyx_slice__5, __pyx_int_2); if (unlikely(!__pyx_tuple__6)) __PYX_ERR(0, 20, __pyx_L1_error)
05261 __Pyx_GOTREF(__pyx_tuple__6);
05262 __Pyx_GIVEREF(__pyx_tuple__6);
05263
05264
05265
05266
05267
05268
05269
05270
05271 __pyx_slice__7 = PySlice_New(Py_None, Py_None, Py_None); if (unlikely(!__pyx_slice__7)) __PYX_ERR(0, 21, __pyx_L1_error)
05272 __Pyx_GOTREF(__pyx_slice__7);
05273 __Pyx_GIVEREF(__pyx_slice__7);
05274 __pyx_tuple__8 = PyTuple_Pack(2, __pyx_slice__7, __pyx_int_3); if (unlikely(!__pyx_tuple__8)) __PYX_ERR(0, 21, __pyx_L1_error)
05275 __Pyx_GOTREF(__pyx_tuple__8);
05276 __Pyx_GIVEREF(__pyx_tuple__8);
05277
05278
05279
05280
05281
05282
05283
05284
05285 __pyx_slice__9 = PySlice_New(Py_None, Py_None, Py_None); if (unlikely(!__pyx_slice__9)) __PYX_ERR(0, 22, __pyx_L1_error)
05286 __Pyx_GOTREF(__pyx_slice__9);
05287 __Pyx_GIVEREF(__pyx_slice__9);
05288 __pyx_tuple__10 = PyTuple_Pack(2, __pyx_slice__9, __pyx_int_4); if (unlikely(!__pyx_tuple__10)) __PYX_ERR(0, 22, __pyx_L1_error)
05289 __Pyx_GOTREF(__pyx_tuple__10);
05290 __Pyx_GIVEREF(__pyx_tuple__10);
05291
05292
05293
05294
05295
05296
05297
05298
05299 __pyx_slice__11 = PySlice_New(Py_None, Py_None, __pyx_int_neg_1); if (unlikely(!__pyx_slice__11)) __PYX_ERR(0, 25, __pyx_L1_error)
05300 __Pyx_GOTREF(__pyx_slice__11);
05301 __Pyx_GIVEREF(__pyx_slice__11);
05302 __pyx_tuple__12 = PyTuple_Pack(1, __pyx_n_s_i); if (unlikely(!__pyx_tuple__12)) __PYX_ERR(0, 25, __pyx_L1_error)
05303 __Pyx_GOTREF(__pyx_tuple__12);
05304 __Pyx_GIVEREF(__pyx_tuple__12);
05305
05306
05307
05308
05309
05310
05311
05312
05313 __pyx_tuple__13 = PyTuple_Pack(1, __pyx_kp_u_ndarray_is_not_C_contiguous); if (unlikely(!__pyx_tuple__13)) __PYX_ERR(1, 218, __pyx_L1_error)
05314 __Pyx_GOTREF(__pyx_tuple__13);
05315 __Pyx_GIVEREF(__pyx_tuple__13);
05316
05317
05318
05319
05320
05321
05322
05323
05324 __pyx_tuple__14 = PyTuple_Pack(1, __pyx_kp_u_ndarray_is_not_Fortran_contiguou); if (unlikely(!__pyx_tuple__14)) __PYX_ERR(1, 222, __pyx_L1_error)
05325 __Pyx_GOTREF(__pyx_tuple__14);
05326 __Pyx_GIVEREF(__pyx_tuple__14);
05327
05328
05329
05330
05331
05332
05333
05334
05335 __pyx_tuple__15 = PyTuple_Pack(1, __pyx_kp_u_Non_native_byte_order_not_suppor); if (unlikely(!__pyx_tuple__15)) __PYX_ERR(1, 259, __pyx_L1_error)
05336 __Pyx_GOTREF(__pyx_tuple__15);
05337 __Pyx_GIVEREF(__pyx_tuple__15);
05338
05339
05340
05341
05342
05343
05344
05345
05346 __pyx_tuple__16 = PyTuple_Pack(1, __pyx_kp_u_Format_string_allocated_too_shor); if (unlikely(!__pyx_tuple__16)) __PYX_ERR(1, 799, __pyx_L1_error)
05347 __Pyx_GOTREF(__pyx_tuple__16);
05348 __Pyx_GIVEREF(__pyx_tuple__16);
05349
05350
05351
05352
05353
05354
05355
05356
05357 __pyx_tuple__17 = PyTuple_Pack(1, __pyx_kp_u_Non_native_byte_order_not_suppor); if (unlikely(!__pyx_tuple__17)) __PYX_ERR(1, 803, __pyx_L1_error)
05358 __Pyx_GOTREF(__pyx_tuple__17);
05359 __Pyx_GIVEREF(__pyx_tuple__17);
05360
05361
05362
05363
05364
05365
05366
05367
05368 __pyx_tuple__18 = PyTuple_Pack(1, __pyx_kp_u_Format_string_allocated_too_shor_2); if (unlikely(!__pyx_tuple__18)) __PYX_ERR(1, 823, __pyx_L1_error)
05369 __Pyx_GOTREF(__pyx_tuple__18);
05370 __Pyx_GIVEREF(__pyx_tuple__18);
05371
05372
05373
05374
05375
05376
05377
05378
05379 __pyx_tuple__19 = PyTuple_Pack(1, __pyx_kp_s_numpy_core_multiarray_failed_to); if (unlikely(!__pyx_tuple__19)) __PYX_ERR(1, 989, __pyx_L1_error)
05380 __Pyx_GOTREF(__pyx_tuple__19);
05381 __Pyx_GIVEREF(__pyx_tuple__19);
05382
05383
05384
05385
05386
05387
05388
05389
05390 __pyx_tuple__20 = PyTuple_Pack(1, __pyx_kp_s_numpy_core_umath_failed_to_impor); if (unlikely(!__pyx_tuple__20)) __PYX_ERR(1, 995, __pyx_L1_error)
05391 __Pyx_GOTREF(__pyx_tuple__20);
05392 __Pyx_GIVEREF(__pyx_tuple__20);
05393
05394
05395
05396
05397
05398
05399 __pyx_tuple__21 = PyTuple_Pack(1, __pyx_kp_s_numpy_core_umath_failed_to_impor); if (unlikely(!__pyx_tuple__21)) __PYX_ERR(1, 1001, __pyx_L1_error)
05400 __Pyx_GOTREF(__pyx_tuple__21);
05401 __Pyx_GIVEREF(__pyx_tuple__21);
05402
05403
05404
05405
05406
05407
05408
05409
05410 __pyx_tuple__22 = PyTuple_Pack(29, __pyx_n_s_dets, __pyx_n_s_thresh, __pyx_n_s_x1, __pyx_n_s_y1, __pyx_n_s_x2, __pyx_n_s_y2, __pyx_n_s_scores, __pyx_n_s_areas, __pyx_n_s_order, __pyx_n_s_ndets, __pyx_n_s_suppressed, __pyx_n_s_i_2, __pyx_n_s_j, __pyx_n_s_i, __pyx_n_s_j_2, __pyx_n_s_ix1, __pyx_n_s_iy1, __pyx_n_s_ix2, __pyx_n_s_iy2, __pyx_n_s_iarea, __pyx_n_s_xx1, __pyx_n_s_yy1, __pyx_n_s_xx2, __pyx_n_s_yy2, __pyx_n_s_w, __pyx_n_s_h, __pyx_n_s_inter, __pyx_n_s_ovr, __pyx_n_s_keep); if (unlikely(!__pyx_tuple__22)) __PYX_ERR(0, 17, __pyx_L1_error)
05411 __Pyx_GOTREF(__pyx_tuple__22);
05412 __Pyx_GIVEREF(__pyx_tuple__22);
05413 __pyx_codeobj__23 = (PyObject*)__Pyx_PyCode_New(2, 0, 29, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__22, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_home_andrewsilva_Deformable_Con, __pyx_n_s_cpu_nms, 17, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__23)) __PYX_ERR(0, 17, __pyx_L1_error)
05414 __Pyx_RefNannyFinishContext();
05415 return 0;
05416 __pyx_L1_error:;
05417 __Pyx_RefNannyFinishContext();
05418 return -1;
05419 }
05420
05421 static int __Pyx_InitGlobals(void) {
05422 if (__Pyx_InitStrings(__pyx_string_tab) < 0) __PYX_ERR(0, 1, __pyx_L1_error);
05423 __pyx_int_0 = PyInt_FromLong(0); if (unlikely(!__pyx_int_0)) __PYX_ERR(0, 1, __pyx_L1_error)
05424 __pyx_int_1 = PyInt_FromLong(1); if (unlikely(!__pyx_int_1)) __PYX_ERR(0, 1, __pyx_L1_error)
05425 __pyx_int_2 = PyInt_FromLong(2); if (unlikely(!__pyx_int_2)) __PYX_ERR(0, 1, __pyx_L1_error)
05426 __pyx_int_3 = PyInt_FromLong(3); if (unlikely(!__pyx_int_3)) __PYX_ERR(0, 1, __pyx_L1_error)
05427 __pyx_int_4 = PyInt_FromLong(4); if (unlikely(!__pyx_int_4)) __PYX_ERR(0, 1, __pyx_L1_error)
05428 __pyx_int_neg_1 = PyInt_FromLong(-1); if (unlikely(!__pyx_int_neg_1)) __PYX_ERR(0, 1, __pyx_L1_error)
05429 return 0;
05430 __pyx_L1_error:;
05431 return -1;
05432 }
05433
05434 #if PY_MAJOR_VERSION < 3
05435 PyMODINIT_FUNC initcpu_nms(void);
05436 PyMODINIT_FUNC initcpu_nms(void)
05437 #else
05438 PyMODINIT_FUNC PyInit_cpu_nms(void);
05439 PyMODINIT_FUNC PyInit_cpu_nms(void)
05440 #endif
05441 {
05442 PyObject *__pyx_t_1 = NULL;
05443 __Pyx_RefNannyDeclarations
05444 #if CYTHON_REFNANNY
05445 __Pyx_RefNanny = __Pyx_RefNannyImportAPI("refnanny");
05446 if (!__Pyx_RefNanny) {
05447 PyErr_Clear();
05448 __Pyx_RefNanny = __Pyx_RefNannyImportAPI("Cython.Runtime.refnanny");
05449 if (!__Pyx_RefNanny)
05450 Py_FatalError("failed to import 'refnanny' module");
05451 }
05452 #endif
05453 __Pyx_RefNannySetupContext("PyMODINIT_FUNC PyInit_cpu_nms(void)", 0);
05454 if (__Pyx_check_binary_version() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
05455 __pyx_empty_tuple = PyTuple_New(0); if (unlikely(!__pyx_empty_tuple)) __PYX_ERR(0, 1, __pyx_L1_error)
05456 __pyx_empty_bytes = PyBytes_FromStringAndSize("", 0); if (unlikely(!__pyx_empty_bytes)) __PYX_ERR(0, 1, __pyx_L1_error)
05457 __pyx_empty_unicode = PyUnicode_FromStringAndSize("", 0); if (unlikely(!__pyx_empty_unicode)) __PYX_ERR(0, 1, __pyx_L1_error)
05458 #ifdef __Pyx_CyFunction_USED
05459 if (__pyx_CyFunction_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
05460 #endif
05461 #ifdef __Pyx_FusedFunction_USED
05462 if (__pyx_FusedFunction_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
05463 #endif
05464 #ifdef __Pyx_Coroutine_USED
05465 if (__pyx_Coroutine_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
05466 #endif
05467 #ifdef __Pyx_Generator_USED
05468 if (__pyx_Generator_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
05469 #endif
05470 #ifdef __Pyx_StopAsyncIteration_USED
05471 if (__pyx_StopAsyncIteration_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
05472 #endif
05473
05474
05475 #if defined(__PYX_FORCE_INIT_THREADS) && __PYX_FORCE_INIT_THREADS
05476 #ifdef WITH_THREAD
05477 PyEval_InitThreads();
05478 #endif
05479 #endif
05480
05481 #if PY_MAJOR_VERSION < 3
05482 __pyx_m = Py_InitModule4("cpu_nms", __pyx_methods, 0, 0, PYTHON_API_VERSION); Py_XINCREF(__pyx_m);
05483 #else
05484 __pyx_m = PyModule_Create(&__pyx_moduledef);
05485 #endif
05486 if (unlikely(!__pyx_m)) __PYX_ERR(0, 1, __pyx_L1_error)
05487 __pyx_d = PyModule_GetDict(__pyx_m); if (unlikely(!__pyx_d)) __PYX_ERR(0, 1, __pyx_L1_error)
05488 Py_INCREF(__pyx_d);
05489 __pyx_b = PyImport_AddModule(__Pyx_BUILTIN_MODULE_NAME); if (unlikely(!__pyx_b)) __PYX_ERR(0, 1, __pyx_L1_error)
05490 #if CYTHON_COMPILING_IN_PYPY
05491 Py_INCREF(__pyx_b);
05492 #endif
05493 if (PyObject_SetAttrString(__pyx_m, "__builtins__", __pyx_b) < 0) __PYX_ERR(0, 1, __pyx_L1_error);
05494
05495 if (__Pyx_InitGlobals() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
05496 #if PY_MAJOR_VERSION < 3 && (__PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT)
05497 if (__Pyx_init_sys_getdefaultencoding_params() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
05498 #endif
05499 if (__pyx_module_is_main_cpu_nms) {
05500 if (PyObject_SetAttrString(__pyx_m, "__name__", __pyx_n_s_main) < 0) __PYX_ERR(0, 1, __pyx_L1_error)
05501 }
05502 #if PY_MAJOR_VERSION >= 3
05503 {
05504 PyObject *modules = PyImport_GetModuleDict(); if (unlikely(!modules)) __PYX_ERR(0, 1, __pyx_L1_error)
05505 if (!PyDict_GetItemString(modules, "cpu_nms")) {
05506 if (unlikely(PyDict_SetItemString(modules, "cpu_nms", __pyx_m) < 0)) __PYX_ERR(0, 1, __pyx_L1_error)
05507 }
05508 }
05509 #endif
05510
05511 if (__Pyx_InitCachedBuiltins() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
05512
05513 if (__Pyx_InitCachedConstants() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
05514
05515
05516
05517
05518
05519 __pyx_ptype_7cpython_4type_type = __Pyx_ImportType(__Pyx_BUILTIN_MODULE_NAME, "type",
05520 #if CYTHON_COMPILING_IN_PYPY
05521 sizeof(PyTypeObject),
05522 #else
05523 sizeof(PyHeapTypeObject),
05524 #endif
05525 0); if (unlikely(!__pyx_ptype_7cpython_4type_type)) __PYX_ERR(2, 9, __pyx_L1_error)
05526 __pyx_ptype_5numpy_dtype = __Pyx_ImportType("numpy", "dtype", sizeof(PyArray_Descr), 0); if (unlikely(!__pyx_ptype_5numpy_dtype)) __PYX_ERR(1, 155, __pyx_L1_error)
05527 __pyx_ptype_5numpy_flatiter = __Pyx_ImportType("numpy", "flatiter", sizeof(PyArrayIterObject), 0); if (unlikely(!__pyx_ptype_5numpy_flatiter)) __PYX_ERR(1, 168, __pyx_L1_error)
05528 __pyx_ptype_5numpy_broadcast = __Pyx_ImportType("numpy", "broadcast", sizeof(PyArrayMultiIterObject), 0); if (unlikely(!__pyx_ptype_5numpy_broadcast)) __PYX_ERR(1, 172, __pyx_L1_error)
05529 __pyx_ptype_5numpy_ndarray = __Pyx_ImportType("numpy", "ndarray", sizeof(PyArrayObject), 0); if (unlikely(!__pyx_ptype_5numpy_ndarray)) __PYX_ERR(1, 181, __pyx_L1_error)
05530 __pyx_ptype_5numpy_ufunc = __Pyx_ImportType("numpy", "ufunc", sizeof(PyUFuncObject), 0); if (unlikely(!__pyx_ptype_5numpy_ufunc)) __PYX_ERR(1, 861, __pyx_L1_error)
05531
05532
05533
05534 #if defined(__Pyx_Generator_USED) || defined(__Pyx_Coroutine_USED)
05535 if (__Pyx_patch_abc() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
05536 #endif
05537
05538
05539
05540
05541
05542
05543
05544
05545 __pyx_t_1 = __Pyx_Import(__pyx_n_s_numpy, 0, -1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 8, __pyx_L1_error)
05546 __Pyx_GOTREF(__pyx_t_1);
05547 if (PyDict_SetItem(__pyx_d, __pyx_n_s_np, __pyx_t_1) < 0) __PYX_ERR(0, 8, __pyx_L1_error)
05548 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
05549
05550
05551
05552
05553
05554
05555
05556
05557 __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_7cpu_nms_1cpu_nms, NULL, __pyx_n_s_cpu_nms); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 17, __pyx_L1_error)
05558 __Pyx_GOTREF(__pyx_t_1);
05559 if (PyDict_SetItem(__pyx_d, __pyx_n_s_cpu_nms, __pyx_t_1) < 0) __PYX_ERR(0, 17, __pyx_L1_error)
05560 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
05561
05562
05563
05564
05565
05566
05567 __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1, __pyx_L1_error)
05568 __Pyx_GOTREF(__pyx_t_1);
05569 if (PyDict_SetItem(__pyx_d, __pyx_n_s_test, __pyx_t_1) < 0) __PYX_ERR(0, 1, __pyx_L1_error)
05570 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
05571
05572
05573
05574
05575
05576
05577
05578
05579
05580
05581
05582 goto __pyx_L0;
05583 __pyx_L1_error:;
05584 __Pyx_XDECREF(__pyx_t_1);
05585 if (__pyx_m) {
05586 if (__pyx_d) {
05587 __Pyx_AddTraceback("init cpu_nms", __pyx_clineno, __pyx_lineno, __pyx_filename);
05588 }
05589 Py_DECREF(__pyx_m); __pyx_m = 0;
05590 } else if (!PyErr_Occurred()) {
05591 PyErr_SetString(PyExc_ImportError, "init cpu_nms");
05592 }
05593 __pyx_L0:;
05594 __Pyx_RefNannyFinishContext();
05595 #if PY_MAJOR_VERSION < 3
05596 return;
05597 #else
05598 return __pyx_m;
05599 #endif
05600 }
05601
05602
05603
05604 #if CYTHON_REFNANNY
05605 static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname) {
05606 PyObject *m = NULL, *p = NULL;
05607 void *r = NULL;
05608 m = PyImport_ImportModule((char *)modname);
05609 if (!m) goto end;
05610 p = PyObject_GetAttrString(m, (char *)"RefNannyAPI");
05611 if (!p) goto end;
05612 r = PyLong_AsVoidPtr(p);
05613 end:
05614 Py_XDECREF(p);
05615 Py_XDECREF(m);
05616 return (__Pyx_RefNannyAPIStruct *)r;
05617 }
05618 #endif
05619
05620
05621 static PyObject *__Pyx_GetBuiltinName(PyObject *name) {
05622 PyObject* result = __Pyx_PyObject_GetAttrStr(__pyx_b, name);
05623 if (unlikely(!result)) {
05624 PyErr_Format(PyExc_NameError,
05625 #if PY_MAJOR_VERSION >= 3
05626 "name '%U' is not defined", name);
05627 #else
05628 "name '%.200s' is not defined", PyString_AS_STRING(name));
05629 #endif
05630 }
05631 return result;
05632 }
05633
05634
05635 static void __Pyx_RaiseArgtupleInvalid(
05636 const char* func_name,
05637 int exact,
05638 Py_ssize_t num_min,
05639 Py_ssize_t num_max,
05640 Py_ssize_t num_found)
05641 {
05642 Py_ssize_t num_expected;
05643 const char *more_or_less;
05644 if (num_found < num_min) {
05645 num_expected = num_min;
05646 more_or_less = "at least";
05647 } else {
05648 num_expected = num_max;
05649 more_or_less = "at most";
05650 }
05651 if (exact) {
05652 more_or_less = "exactly";
05653 }
05654 PyErr_Format(PyExc_TypeError,
05655 "%.200s() takes %.8s %" CYTHON_FORMAT_SSIZE_T "d positional argument%.1s (%" CYTHON_FORMAT_SSIZE_T "d given)",
05656 func_name, more_or_less, num_expected,
05657 (num_expected == 1) ? "" : "s", num_found);
05658 }
05659
05660
05661 static void __Pyx_RaiseDoubleKeywordsError(
05662 const char* func_name,
05663 PyObject* kw_name)
05664 {
05665 PyErr_Format(PyExc_TypeError,
05666 #if PY_MAJOR_VERSION >= 3
05667 "%s() got multiple values for keyword argument '%U'", func_name, kw_name);
05668 #else
05669 "%s() got multiple values for keyword argument '%s'", func_name,
05670 PyString_AsString(kw_name));
05671 #endif
05672 }
05673
05674
05675 static int __Pyx_ParseOptionalKeywords(
05676 PyObject *kwds,
05677 PyObject **argnames[],
05678 PyObject *kwds2,
05679 PyObject *values[],
05680 Py_ssize_t num_pos_args,
05681 const char* function_name)
05682 {
05683 PyObject *key = 0, *value = 0;
05684 Py_ssize_t pos = 0;
05685 PyObject*** name;
05686 PyObject*** first_kw_arg = argnames + num_pos_args;
05687 while (PyDict_Next(kwds, &pos, &key, &value)) {
05688 name = first_kw_arg;
05689 while (*name && (**name != key)) name++;
05690 if (*name) {
05691 values[name-argnames] = value;
05692 continue;
05693 }
05694 name = first_kw_arg;
05695 #if PY_MAJOR_VERSION < 3
05696 if (likely(PyString_CheckExact(key)) || likely(PyString_Check(key))) {
05697 while (*name) {
05698 if ((CYTHON_COMPILING_IN_PYPY || PyString_GET_SIZE(**name) == PyString_GET_SIZE(key))
05699 && _PyString_Eq(**name, key)) {
05700 values[name-argnames] = value;
05701 break;
05702 }
05703 name++;
05704 }
05705 if (*name) continue;
05706 else {
05707 PyObject*** argname = argnames;
05708 while (argname != first_kw_arg) {
05709 if ((**argname == key) || (
05710 (CYTHON_COMPILING_IN_PYPY || PyString_GET_SIZE(**argname) == PyString_GET_SIZE(key))
05711 && _PyString_Eq(**argname, key))) {
05712 goto arg_passed_twice;
05713 }
05714 argname++;
05715 }
05716 }
05717 } else
05718 #endif
05719 if (likely(PyUnicode_Check(key))) {
05720 while (*name) {
05721 int cmp = (**name == key) ? 0 :
05722 #if !CYTHON_COMPILING_IN_PYPY && PY_MAJOR_VERSION >= 3
05723 (PyUnicode_GET_SIZE(**name) != PyUnicode_GET_SIZE(key)) ? 1 :
05724 #endif
05725 PyUnicode_Compare(**name, key);
05726 if (cmp < 0 && unlikely(PyErr_Occurred())) goto bad;
05727 if (cmp == 0) {
05728 values[name-argnames] = value;
05729 break;
05730 }
05731 name++;
05732 }
05733 if (*name) continue;
05734 else {
05735 PyObject*** argname = argnames;
05736 while (argname != first_kw_arg) {
05737 int cmp = (**argname == key) ? 0 :
05738 #if !CYTHON_COMPILING_IN_PYPY && PY_MAJOR_VERSION >= 3
05739 (PyUnicode_GET_SIZE(**argname) != PyUnicode_GET_SIZE(key)) ? 1 :
05740 #endif
05741 PyUnicode_Compare(**argname, key);
05742 if (cmp < 0 && unlikely(PyErr_Occurred())) goto bad;
05743 if (cmp == 0) goto arg_passed_twice;
05744 argname++;
05745 }
05746 }
05747 } else
05748 goto invalid_keyword_type;
05749 if (kwds2) {
05750 if (unlikely(PyDict_SetItem(kwds2, key, value))) goto bad;
05751 } else {
05752 goto invalid_keyword;
05753 }
05754 }
05755 return 0;
05756 arg_passed_twice:
05757 __Pyx_RaiseDoubleKeywordsError(function_name, key);
05758 goto bad;
05759 invalid_keyword_type:
05760 PyErr_Format(PyExc_TypeError,
05761 "%.200s() keywords must be strings", function_name);
05762 goto bad;
05763 invalid_keyword:
05764 PyErr_Format(PyExc_TypeError,
05765 #if PY_MAJOR_VERSION < 3
05766 "%.200s() got an unexpected keyword argument '%.200s'",
05767 function_name, PyString_AsString(key));
05768 #else
05769 "%s() got an unexpected keyword argument '%U'",
05770 function_name, key);
05771 #endif
05772 bad:
05773 return -1;
05774 }
05775
05776
05777 static void __Pyx_RaiseArgumentTypeInvalid(const char* name, PyObject *obj, PyTypeObject *type) {
05778 PyErr_Format(PyExc_TypeError,
05779 "Argument '%.200s' has incorrect type (expected %.200s, got %.200s)",
05780 name, type->tp_name, Py_TYPE(obj)->tp_name);
05781 }
05782 static CYTHON_INLINE int __Pyx_ArgTypeTest(PyObject *obj, PyTypeObject *type, int none_allowed,
05783 const char *name, int exact)
05784 {
05785 if (unlikely(!type)) {
05786 PyErr_SetString(PyExc_SystemError, "Missing type object");
05787 return 0;
05788 }
05789 if (none_allowed && obj == Py_None) return 1;
05790 else if (exact) {
05791 if (likely(Py_TYPE(obj) == type)) return 1;
05792 #if PY_MAJOR_VERSION == 2
05793 else if ((type == &PyBaseString_Type) && likely(__Pyx_PyBaseString_CheckExact(obj))) return 1;
05794 #endif
05795 }
05796 else {
05797 if (likely(PyObject_TypeCheck(obj, type))) return 1;
05798 }
05799 __Pyx_RaiseArgumentTypeInvalid(name, obj, type);
05800 return 0;
05801 }
05802
05803
05804 static CYTHON_INLINE int __Pyx_IsLittleEndian(void) {
05805 unsigned int n = 1;
05806 return *(unsigned char*)(&n) != 0;
05807 }
05808 static void __Pyx_BufFmt_Init(__Pyx_BufFmt_Context* ctx,
05809 __Pyx_BufFmt_StackElem* stack,
05810 __Pyx_TypeInfo* type) {
05811 stack[0].field = &ctx->root;
05812 stack[0].parent_offset = 0;
05813 ctx->root.type = type;
05814 ctx->root.name = "buffer dtype";
05815 ctx->root.offset = 0;
05816 ctx->head = stack;
05817 ctx->head->field = &ctx->root;
05818 ctx->fmt_offset = 0;
05819 ctx->head->parent_offset = 0;
05820 ctx->new_packmode = '@';
05821 ctx->enc_packmode = '@';
05822 ctx->new_count = 1;
05823 ctx->enc_count = 0;
05824 ctx->enc_type = 0;
05825 ctx->is_complex = 0;
05826 ctx->is_valid_array = 0;
05827 ctx->struct_alignment = 0;
05828 while (type->typegroup == 'S') {
05829 ++ctx->head;
05830 ctx->head->field = type->fields;
05831 ctx->head->parent_offset = 0;
05832 type = type->fields->type;
05833 }
05834 }
05835 static int __Pyx_BufFmt_ParseNumber(const char** ts) {
05836 int count;
05837 const char* t = *ts;
05838 if (*t < '0' || *t > '9') {
05839 return -1;
05840 } else {
05841 count = *t++ - '0';
05842 while (*t >= '0' && *t < '9') {
05843 count *= 10;
05844 count += *t++ - '0';
05845 }
05846 }
05847 *ts = t;
05848 return count;
05849 }
05850 static int __Pyx_BufFmt_ExpectNumber(const char **ts) {
05851 int number = __Pyx_BufFmt_ParseNumber(ts);
05852 if (number == -1)
05853 PyErr_Format(PyExc_ValueError,\
05854 "Does not understand character buffer dtype format string ('%c')", **ts);
05855 return number;
05856 }
05857 static void __Pyx_BufFmt_RaiseUnexpectedChar(char ch) {
05858 PyErr_Format(PyExc_ValueError,
05859 "Unexpected format string character: '%c'", ch);
05860 }
05861 static const char* __Pyx_BufFmt_DescribeTypeChar(char ch, int is_complex) {
05862 switch (ch) {
05863 case 'c': return "'char'";
05864 case 'b': return "'signed char'";
05865 case 'B': return "'unsigned char'";
05866 case 'h': return "'short'";
05867 case 'H': return "'unsigned short'";
05868 case 'i': return "'int'";
05869 case 'I': return "'unsigned int'";
05870 case 'l': return "'long'";
05871 case 'L': return "'unsigned long'";
05872 case 'q': return "'long long'";
05873 case 'Q': return "'unsigned long long'";
05874 case 'f': return (is_complex ? "'complex float'" : "'float'");
05875 case 'd': return (is_complex ? "'complex double'" : "'double'");
05876 case 'g': return (is_complex ? "'complex long double'" : "'long double'");
05877 case 'T': return "a struct";
05878 case 'O': return "Python object";
05879 case 'P': return "a pointer";
05880 case 's': case 'p': return "a string";
05881 case 0: return "end";
05882 default: return "unparseable format string";
05883 }
05884 }
05885 static size_t __Pyx_BufFmt_TypeCharToStandardSize(char ch, int is_complex) {
05886 switch (ch) {
05887 case '?': case 'c': case 'b': case 'B': case 's': case 'p': return 1;
05888 case 'h': case 'H': return 2;
05889 case 'i': case 'I': case 'l': case 'L': return 4;
05890 case 'q': case 'Q': return 8;
05891 case 'f': return (is_complex ? 8 : 4);
05892 case 'd': return (is_complex ? 16 : 8);
05893 case 'g': {
05894 PyErr_SetString(PyExc_ValueError, "Python does not define a standard format string size for long double ('g')..");
05895 return 0;
05896 }
05897 case 'O': case 'P': return sizeof(void*);
05898 default:
05899 __Pyx_BufFmt_RaiseUnexpectedChar(ch);
05900 return 0;
05901 }
05902 }
05903 static size_t __Pyx_BufFmt_TypeCharToNativeSize(char ch, int is_complex) {
05904 switch (ch) {
05905 case 'c': case 'b': case 'B': case 's': case 'p': return 1;
05906 case 'h': case 'H': return sizeof(short);
05907 case 'i': case 'I': return sizeof(int);
05908 case 'l': case 'L': return sizeof(long);
05909 #ifdef HAVE_LONG_LONG
05910 case 'q': case 'Q': return sizeof(PY_LONG_LONG);
05911 #endif
05912 case 'f': return sizeof(float) * (is_complex ? 2 : 1);
05913 case 'd': return sizeof(double) * (is_complex ? 2 : 1);
05914 case 'g': return sizeof(long double) * (is_complex ? 2 : 1);
05915 case 'O': case 'P': return sizeof(void*);
05916 default: {
05917 __Pyx_BufFmt_RaiseUnexpectedChar(ch);
05918 return 0;
05919 }
05920 }
05921 }
05922 typedef struct { char c; short x; } __Pyx_st_short;
05923 typedef struct { char c; int x; } __Pyx_st_int;
05924 typedef struct { char c; long x; } __Pyx_st_long;
05925 typedef struct { char c; float x; } __Pyx_st_float;
05926 typedef struct { char c; double x; } __Pyx_st_double;
05927 typedef struct { char c; long double x; } __Pyx_st_longdouble;
05928 typedef struct { char c; void *x; } __Pyx_st_void_p;
05929 #ifdef HAVE_LONG_LONG
05930 typedef struct { char c; PY_LONG_LONG x; } __Pyx_st_longlong;
05931 #endif
05932 static size_t __Pyx_BufFmt_TypeCharToAlignment(char ch, CYTHON_UNUSED int is_complex) {
05933 switch (ch) {
05934 case '?': case 'c': case 'b': case 'B': case 's': case 'p': return 1;
05935 case 'h': case 'H': return sizeof(__Pyx_st_short) - sizeof(short);
05936 case 'i': case 'I': return sizeof(__Pyx_st_int) - sizeof(int);
05937 case 'l': case 'L': return sizeof(__Pyx_st_long) - sizeof(long);
05938 #ifdef HAVE_LONG_LONG
05939 case 'q': case 'Q': return sizeof(__Pyx_st_longlong) - sizeof(PY_LONG_LONG);
05940 #endif
05941 case 'f': return sizeof(__Pyx_st_float) - sizeof(float);
05942 case 'd': return sizeof(__Pyx_st_double) - sizeof(double);
05943 case 'g': return sizeof(__Pyx_st_longdouble) - sizeof(long double);
05944 case 'P': case 'O': return sizeof(__Pyx_st_void_p) - sizeof(void*);
05945 default:
05946 __Pyx_BufFmt_RaiseUnexpectedChar(ch);
05947 return 0;
05948 }
05949 }
05950
05951
05952
05953
05954 typedef struct { short x; char c; } __Pyx_pad_short;
05955 typedef struct { int x; char c; } __Pyx_pad_int;
05956 typedef struct { long x; char c; } __Pyx_pad_long;
05957 typedef struct { float x; char c; } __Pyx_pad_float;
05958 typedef struct { double x; char c; } __Pyx_pad_double;
05959 typedef struct { long double x; char c; } __Pyx_pad_longdouble;
05960 typedef struct { void *x; char c; } __Pyx_pad_void_p;
05961 #ifdef HAVE_LONG_LONG
05962 typedef struct { PY_LONG_LONG x; char c; } __Pyx_pad_longlong;
05963 #endif
05964 static size_t __Pyx_BufFmt_TypeCharToPadding(char ch, CYTHON_UNUSED int is_complex) {
05965 switch (ch) {
05966 case '?': case 'c': case 'b': case 'B': case 's': case 'p': return 1;
05967 case 'h': case 'H': return sizeof(__Pyx_pad_short) - sizeof(short);
05968 case 'i': case 'I': return sizeof(__Pyx_pad_int) - sizeof(int);
05969 case 'l': case 'L': return sizeof(__Pyx_pad_long) - sizeof(long);
05970 #ifdef HAVE_LONG_LONG
05971 case 'q': case 'Q': return sizeof(__Pyx_pad_longlong) - sizeof(PY_LONG_LONG);
05972 #endif
05973 case 'f': return sizeof(__Pyx_pad_float) - sizeof(float);
05974 case 'd': return sizeof(__Pyx_pad_double) - sizeof(double);
05975 case 'g': return sizeof(__Pyx_pad_longdouble) - sizeof(long double);
05976 case 'P': case 'O': return sizeof(__Pyx_pad_void_p) - sizeof(void*);
05977 default:
05978 __Pyx_BufFmt_RaiseUnexpectedChar(ch);
05979 return 0;
05980 }
05981 }
05982 static char __Pyx_BufFmt_TypeCharToGroup(char ch, int is_complex) {
05983 switch (ch) {
05984 case 'c':
05985 return 'H';
05986 case 'b': case 'h': case 'i':
05987 case 'l': case 'q': case 's': case 'p':
05988 return 'I';
05989 case 'B': case 'H': case 'I': case 'L': case 'Q':
05990 return 'U';
05991 case 'f': case 'd': case 'g':
05992 return (is_complex ? 'C' : 'R');
05993 case 'O':
05994 return 'O';
05995 case 'P':
05996 return 'P';
05997 default: {
05998 __Pyx_BufFmt_RaiseUnexpectedChar(ch);
05999 return 0;
06000 }
06001 }
06002 }
06003 static void __Pyx_BufFmt_RaiseExpected(__Pyx_BufFmt_Context* ctx) {
06004 if (ctx->head == NULL || ctx->head->field == &ctx->root) {
06005 const char* expected;
06006 const char* quote;
06007 if (ctx->head == NULL) {
06008 expected = "end";
06009 quote = "";
06010 } else {
06011 expected = ctx->head->field->type->name;
06012 quote = "'";
06013 }
06014 PyErr_Format(PyExc_ValueError,
06015 "Buffer dtype mismatch, expected %s%s%s but got %s",
06016 quote, expected, quote,
06017 __Pyx_BufFmt_DescribeTypeChar(ctx->enc_type, ctx->is_complex));
06018 } else {
06019 __Pyx_StructField* field = ctx->head->field;
06020 __Pyx_StructField* parent = (ctx->head - 1)->field;
06021 PyErr_Format(PyExc_ValueError,
06022 "Buffer dtype mismatch, expected '%s' but got %s in '%s.%s'",
06023 field->type->name, __Pyx_BufFmt_DescribeTypeChar(ctx->enc_type, ctx->is_complex),
06024 parent->type->name, field->name);
06025 }
06026 }
06027 static int __Pyx_BufFmt_ProcessTypeChunk(__Pyx_BufFmt_Context* ctx) {
06028 char group;
06029 size_t size, offset, arraysize = 1;
06030 if (ctx->enc_type == 0) return 0;
06031 if (ctx->head->field->type->arraysize[0]) {
06032 int i, ndim = 0;
06033 if (ctx->enc_type == 's' || ctx->enc_type == 'p') {
06034 ctx->is_valid_array = ctx->head->field->type->ndim == 1;
06035 ndim = 1;
06036 if (ctx->enc_count != ctx->head->field->type->arraysize[0]) {
06037 PyErr_Format(PyExc_ValueError,
06038 "Expected a dimension of size %zu, got %zu",
06039 ctx->head->field->type->arraysize[0], ctx->enc_count);
06040 return -1;
06041 }
06042 }
06043 if (!ctx->is_valid_array) {
06044 PyErr_Format(PyExc_ValueError, "Expected %d dimensions, got %d",
06045 ctx->head->field->type->ndim, ndim);
06046 return -1;
06047 }
06048 for (i = 0; i < ctx->head->field->type->ndim; i++) {
06049 arraysize *= ctx->head->field->type->arraysize[i];
06050 }
06051 ctx->is_valid_array = 0;
06052 ctx->enc_count = 1;
06053 }
06054 group = __Pyx_BufFmt_TypeCharToGroup(ctx->enc_type, ctx->is_complex);
06055 do {
06056 __Pyx_StructField* field = ctx->head->field;
06057 __Pyx_TypeInfo* type = field->type;
06058 if (ctx->enc_packmode == '@' || ctx->enc_packmode == '^') {
06059 size = __Pyx_BufFmt_TypeCharToNativeSize(ctx->enc_type, ctx->is_complex);
06060 } else {
06061 size = __Pyx_BufFmt_TypeCharToStandardSize(ctx->enc_type, ctx->is_complex);
06062 }
06063 if (ctx->enc_packmode == '@') {
06064 size_t align_at = __Pyx_BufFmt_TypeCharToAlignment(ctx->enc_type, ctx->is_complex);
06065 size_t align_mod_offset;
06066 if (align_at == 0) return -1;
06067 align_mod_offset = ctx->fmt_offset % align_at;
06068 if (align_mod_offset > 0) ctx->fmt_offset += align_at - align_mod_offset;
06069 if (ctx->struct_alignment == 0)
06070 ctx->struct_alignment = __Pyx_BufFmt_TypeCharToPadding(ctx->enc_type,
06071 ctx->is_complex);
06072 }
06073 if (type->size != size || type->typegroup != group) {
06074 if (type->typegroup == 'C' && type->fields != NULL) {
06075 size_t parent_offset = ctx->head->parent_offset + field->offset;
06076 ++ctx->head;
06077 ctx->head->field = type->fields;
06078 ctx->head->parent_offset = parent_offset;
06079 continue;
06080 }
06081 if ((type->typegroup == 'H' || group == 'H') && type->size == size) {
06082 } else {
06083 __Pyx_BufFmt_RaiseExpected(ctx);
06084 return -1;
06085 }
06086 }
06087 offset = ctx->head->parent_offset + field->offset;
06088 if (ctx->fmt_offset != offset) {
06089 PyErr_Format(PyExc_ValueError,
06090 "Buffer dtype mismatch; next field is at offset %" CYTHON_FORMAT_SSIZE_T "d but %" CYTHON_FORMAT_SSIZE_T "d expected",
06091 (Py_ssize_t)ctx->fmt_offset, (Py_ssize_t)offset);
06092 return -1;
06093 }
06094 ctx->fmt_offset += size;
06095 if (arraysize)
06096 ctx->fmt_offset += (arraysize - 1) * size;
06097 --ctx->enc_count;
06098 while (1) {
06099 if (field == &ctx->root) {
06100 ctx->head = NULL;
06101 if (ctx->enc_count != 0) {
06102 __Pyx_BufFmt_RaiseExpected(ctx);
06103 return -1;
06104 }
06105 break;
06106 }
06107 ctx->head->field = ++field;
06108 if (field->type == NULL) {
06109 --ctx->head;
06110 field = ctx->head->field;
06111 continue;
06112 } else if (field->type->typegroup == 'S') {
06113 size_t parent_offset = ctx->head->parent_offset + field->offset;
06114 if (field->type->fields->type == NULL) continue;
06115 field = field->type->fields;
06116 ++ctx->head;
06117 ctx->head->field = field;
06118 ctx->head->parent_offset = parent_offset;
06119 break;
06120 } else {
06121 break;
06122 }
06123 }
06124 } while (ctx->enc_count);
06125 ctx->enc_type = 0;
06126 ctx->is_complex = 0;
06127 return 0;
06128 }
06129 static CYTHON_INLINE PyObject *
06130 __pyx_buffmt_parse_array(__Pyx_BufFmt_Context* ctx, const char** tsp)
06131 {
06132 const char *ts = *tsp;
06133 int i = 0, number;
06134 int ndim = ctx->head->field->type->ndim;
06135 ;
06136 ++ts;
06137 if (ctx->new_count != 1) {
06138 PyErr_SetString(PyExc_ValueError,
06139 "Cannot handle repeated arrays in format string");
06140 return NULL;
06141 }
06142 if (__Pyx_BufFmt_ProcessTypeChunk(ctx) == -1) return NULL;
06143 while (*ts && *ts != ')') {
06144 switch (*ts) {
06145 case ' ': case '\f': case '\r': case '\n': case '\t': case '\v': continue;
06146 default: break;
06147 }
06148 number = __Pyx_BufFmt_ExpectNumber(&ts);
06149 if (number == -1) return NULL;
06150 if (i < ndim && (size_t) number != ctx->head->field->type->arraysize[i])
06151 return PyErr_Format(PyExc_ValueError,
06152 "Expected a dimension of size %zu, got %d",
06153 ctx->head->field->type->arraysize[i], number);
06154 if (*ts != ',' && *ts != ')')
06155 return PyErr_Format(PyExc_ValueError,
06156 "Expected a comma in format string, got '%c'", *ts);
06157 if (*ts == ',') ts++;
06158 i++;
06159 }
06160 if (i != ndim)
06161 return PyErr_Format(PyExc_ValueError, "Expected %d dimension(s), got %d",
06162 ctx->head->field->type->ndim, i);
06163 if (!*ts) {
06164 PyErr_SetString(PyExc_ValueError,
06165 "Unexpected end of format string, expected ')'");
06166 return NULL;
06167 }
06168 ctx->is_valid_array = 1;
06169 ctx->new_count = 1;
06170 *tsp = ++ts;
06171 return Py_None;
06172 }
06173 static const char* __Pyx_BufFmt_CheckString(__Pyx_BufFmt_Context* ctx, const char* ts) {
06174 int got_Z = 0;
06175 while (1) {
06176 switch(*ts) {
06177 case 0:
06178 if (ctx->enc_type != 0 && ctx->head == NULL) {
06179 __Pyx_BufFmt_RaiseExpected(ctx);
06180 return NULL;
06181 }
06182 if (__Pyx_BufFmt_ProcessTypeChunk(ctx) == -1) return NULL;
06183 if (ctx->head != NULL) {
06184 __Pyx_BufFmt_RaiseExpected(ctx);
06185 return NULL;
06186 }
06187 return ts;
06188 case ' ':
06189 case '\r':
06190 case '\n':
06191 ++ts;
06192 break;
06193 case '<':
06194 if (!__Pyx_IsLittleEndian()) {
06195 PyErr_SetString(PyExc_ValueError, "Little-endian buffer not supported on big-endian compiler");
06196 return NULL;
06197 }
06198 ctx->new_packmode = '=';
06199 ++ts;
06200 break;
06201 case '>':
06202 case '!':
06203 if (__Pyx_IsLittleEndian()) {
06204 PyErr_SetString(PyExc_ValueError, "Big-endian buffer not supported on little-endian compiler");
06205 return NULL;
06206 }
06207 ctx->new_packmode = '=';
06208 ++ts;
06209 break;
06210 case '=':
06211 case '@':
06212 case '^':
06213 ctx->new_packmode = *ts++;
06214 break;
06215 case 'T':
06216 {
06217 const char* ts_after_sub;
06218 size_t i, struct_count = ctx->new_count;
06219 size_t struct_alignment = ctx->struct_alignment;
06220 ctx->new_count = 1;
06221 ++ts;
06222 if (*ts != '{') {
06223 PyErr_SetString(PyExc_ValueError, "Buffer acquisition: Expected '{' after 'T'");
06224 return NULL;
06225 }
06226 if (__Pyx_BufFmt_ProcessTypeChunk(ctx) == -1) return NULL;
06227 ctx->enc_type = 0;
06228 ctx->enc_count = 0;
06229 ctx->struct_alignment = 0;
06230 ++ts;
06231 ts_after_sub = ts;
06232 for (i = 0; i != struct_count; ++i) {
06233 ts_after_sub = __Pyx_BufFmt_CheckString(ctx, ts);
06234 if (!ts_after_sub) return NULL;
06235 }
06236 ts = ts_after_sub;
06237 if (struct_alignment) ctx->struct_alignment = struct_alignment;
06238 }
06239 break;
06240 case '}':
06241 {
06242 size_t alignment = ctx->struct_alignment;
06243 ++ts;
06244 if (__Pyx_BufFmt_ProcessTypeChunk(ctx) == -1) return NULL;
06245 ctx->enc_type = 0;
06246 if (alignment && ctx->fmt_offset % alignment) {
06247 ctx->fmt_offset += alignment - (ctx->fmt_offset % alignment);
06248 }
06249 }
06250 return ts;
06251 case 'x':
06252 if (__Pyx_BufFmt_ProcessTypeChunk(ctx) == -1) return NULL;
06253 ctx->fmt_offset += ctx->new_count;
06254 ctx->new_count = 1;
06255 ctx->enc_count = 0;
06256 ctx->enc_type = 0;
06257 ctx->enc_packmode = ctx->new_packmode;
06258 ++ts;
06259 break;
06260 case 'Z':
06261 got_Z = 1;
06262 ++ts;
06263 if (*ts != 'f' && *ts != 'd' && *ts != 'g') {
06264 __Pyx_BufFmt_RaiseUnexpectedChar('Z');
06265 return NULL;
06266 }
06267 case 'c': case 'b': case 'B': case 'h': case 'H': case 'i': case 'I':
06268 case 'l': case 'L': case 'q': case 'Q':
06269 case 'f': case 'd': case 'g':
06270 case 'O': case 'p':
06271 if (ctx->enc_type == *ts && got_Z == ctx->is_complex &&
06272 ctx->enc_packmode == ctx->new_packmode) {
06273 ctx->enc_count += ctx->new_count;
06274 ctx->new_count = 1;
06275 got_Z = 0;
06276 ++ts;
06277 break;
06278 }
06279 case 's':
06280 if (__Pyx_BufFmt_ProcessTypeChunk(ctx) == -1) return NULL;
06281 ctx->enc_count = ctx->new_count;
06282 ctx->enc_packmode = ctx->new_packmode;
06283 ctx->enc_type = *ts;
06284 ctx->is_complex = got_Z;
06285 ++ts;
06286 ctx->new_count = 1;
06287 got_Z = 0;
06288 break;
06289 case ':':
06290 ++ts;
06291 while(*ts != ':') ++ts;
06292 ++ts;
06293 break;
06294 case '(':
06295 if (!__pyx_buffmt_parse_array(ctx, &ts)) return NULL;
06296 break;
06297 default:
06298 {
06299 int number = __Pyx_BufFmt_ExpectNumber(&ts);
06300 if (number == -1) return NULL;
06301 ctx->new_count = (size_t)number;
06302 }
06303 }
06304 }
06305 }
06306 static CYTHON_INLINE void __Pyx_ZeroBuffer(Py_buffer* buf) {
06307 buf->buf = NULL;
06308 buf->obj = NULL;
06309 buf->strides = __Pyx_zeros;
06310 buf->shape = __Pyx_zeros;
06311 buf->suboffsets = __Pyx_minusones;
06312 }
06313 static CYTHON_INLINE int __Pyx_GetBufferAndValidate(
06314 Py_buffer* buf, PyObject* obj, __Pyx_TypeInfo* dtype, int flags,
06315 int nd, int cast, __Pyx_BufFmt_StackElem* stack)
06316 {
06317 if (obj == Py_None || obj == NULL) {
06318 __Pyx_ZeroBuffer(buf);
06319 return 0;
06320 }
06321 buf->buf = NULL;
06322 if (__Pyx_GetBuffer(obj, buf, flags) == -1) goto fail;
06323 if (buf->ndim != nd) {
06324 PyErr_Format(PyExc_ValueError,
06325 "Buffer has wrong number of dimensions (expected %d, got %d)",
06326 nd, buf->ndim);
06327 goto fail;
06328 }
06329 if (!cast) {
06330 __Pyx_BufFmt_Context ctx;
06331 __Pyx_BufFmt_Init(&ctx, stack, dtype);
06332 if (!__Pyx_BufFmt_CheckString(&ctx, buf->format)) goto fail;
06333 }
06334 if ((unsigned)buf->itemsize != dtype->size) {
06335 PyErr_Format(PyExc_ValueError,
06336 "Item size of buffer (%" CYTHON_FORMAT_SSIZE_T "d byte%s) does not match size of '%s' (%" CYTHON_FORMAT_SSIZE_T "d byte%s)",
06337 buf->itemsize, (buf->itemsize > 1) ? "s" : "",
06338 dtype->name, (Py_ssize_t)dtype->size, (dtype->size > 1) ? "s" : "");
06339 goto fail;
06340 }
06341 if (buf->suboffsets == NULL) buf->suboffsets = __Pyx_minusones;
06342 return 0;
06343 fail:;
06344 __Pyx_ZeroBuffer(buf);
06345 return -1;
06346 }
06347 static CYTHON_INLINE void __Pyx_SafeReleaseBuffer(Py_buffer* info) {
06348 if (info->buf == NULL) return;
06349 if (info->suboffsets == __Pyx_minusones) info->suboffsets = NULL;
06350 __Pyx_ReleaseBuffer(info);
06351 }
06352
06353
06354 static CYTHON_INLINE int __Pyx_TypeTest(PyObject *obj, PyTypeObject *type) {
06355 if (unlikely(!type)) {
06356 PyErr_SetString(PyExc_SystemError, "Missing type object");
06357 return 0;
06358 }
06359 if (likely(PyObject_TypeCheck(obj, type)))
06360 return 1;
06361 PyErr_Format(PyExc_TypeError, "Cannot convert %.200s to %.200s",
06362 Py_TYPE(obj)->tp_name, type->tp_name);
06363 return 0;
06364 }
06365
06366
06367 #if !CYTHON_COMPILING_IN_PYPY
06368 static PyObject* __Pyx_PyInt_AddObjC(PyObject *op1, PyObject *op2, CYTHON_UNUSED long intval, CYTHON_UNUSED int inplace) {
06369 #if PY_MAJOR_VERSION < 3
06370 if (likely(PyInt_CheckExact(op1))) {
06371 const long b = intval;
06372 long x;
06373 long a = PyInt_AS_LONG(op1);
06374 x = (long)((unsigned long)a + b);
06375 if (likely((x^a) >= 0 || (x^b) >= 0))
06376 return PyInt_FromLong(x);
06377 return PyLong_Type.tp_as_number->nb_add(op1, op2);
06378 }
06379 #endif
06380 #if CYTHON_USE_PYLONG_INTERNALS
06381 if (likely(PyLong_CheckExact(op1))) {
06382 const long b = intval;
06383 long a, x;
06384 #ifdef HAVE_LONG_LONG
06385 const PY_LONG_LONG llb = intval;
06386 PY_LONG_LONG lla, llx;
06387 #endif
06388 const digit* digits = ((PyLongObject*)op1)->ob_digit;
06389 const Py_ssize_t size = Py_SIZE(op1);
06390 if (likely(__Pyx_sst_abs(size) <= 1)) {
06391 a = likely(size) ? digits[0] : 0;
06392 if (size == -1) a = -a;
06393 } else {
06394 switch (size) {
06395 case -2:
06396 if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
06397 a = -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
06398 break;
06399 #ifdef HAVE_LONG_LONG
06400 } else if (8 * sizeof(PY_LONG_LONG) - 1 > 2 * PyLong_SHIFT) {
06401 lla = -(PY_LONG_LONG) (((((unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
06402 goto long_long;
06403 #endif
06404 }
06405 case 2:
06406 if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
06407 a = (long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
06408 break;
06409 #ifdef HAVE_LONG_LONG
06410 } else if (8 * sizeof(PY_LONG_LONG) - 1 > 2 * PyLong_SHIFT) {
06411 lla = (PY_LONG_LONG) (((((unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
06412 goto long_long;
06413 #endif
06414 }
06415 case -3:
06416 if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
06417 a = -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
06418 break;
06419 #ifdef HAVE_LONG_LONG
06420 } else if (8 * sizeof(PY_LONG_LONG) - 1 > 3 * PyLong_SHIFT) {
06421 lla = -(PY_LONG_LONG) (((((((unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
06422 goto long_long;
06423 #endif
06424 }
06425 case 3:
06426 if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
06427 a = (long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
06428 break;
06429 #ifdef HAVE_LONG_LONG
06430 } else if (8 * sizeof(PY_LONG_LONG) - 1 > 3 * PyLong_SHIFT) {
06431 lla = (PY_LONG_LONG) (((((((unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
06432 goto long_long;
06433 #endif
06434 }
06435 case -4:
06436 if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) {
06437 a = -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
06438 break;
06439 #ifdef HAVE_LONG_LONG
06440 } else if (8 * sizeof(PY_LONG_LONG) - 1 > 4 * PyLong_SHIFT) {
06441 lla = -(PY_LONG_LONG) (((((((((unsigned PY_LONG_LONG)digits[3]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
06442 goto long_long;
06443 #endif
06444 }
06445 case 4:
06446 if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) {
06447 a = (long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
06448 break;
06449 #ifdef HAVE_LONG_LONG
06450 } else if (8 * sizeof(PY_LONG_LONG) - 1 > 4 * PyLong_SHIFT) {
06451 lla = (PY_LONG_LONG) (((((((((unsigned PY_LONG_LONG)digits[3]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
06452 goto long_long;
06453 #endif
06454 }
06455 default: return PyLong_Type.tp_as_number->nb_add(op1, op2);
06456 }
06457 }
06458 x = a + b;
06459 return PyLong_FromLong(x);
06460 #ifdef HAVE_LONG_LONG
06461 long_long:
06462 llx = lla + llb;
06463 return PyLong_FromLongLong(llx);
06464 #endif
06465
06466
06467 }
06468 #endif
06469 if (PyFloat_CheckExact(op1)) {
06470 const long b = intval;
06471 double a = PyFloat_AS_DOUBLE(op1);
06472 double result;
06473 PyFPE_START_PROTECT("add", return NULL)
06474 result = ((double)a) + (double)b;
06475 PyFPE_END_PROTECT(result)
06476 return PyFloat_FromDouble(result);
06477 }
06478 return (inplace ? PyNumber_InPlaceAdd : PyNumber_Add)(op1, op2);
06479 }
06480 #endif
06481
06482
06483 #if CYTHON_FAST_PYCCALL
06484 static CYTHON_INLINE PyObject * __Pyx_PyCFunction_FastCall(PyObject *func_obj, PyObject **args, Py_ssize_t nargs) {
06485 PyCFunctionObject *func = (PyCFunctionObject*)func_obj;
06486 PyCFunction meth = PyCFunction_GET_FUNCTION(func);
06487 PyObject *self = PyCFunction_GET_SELF(func);
06488 assert(PyCFunction_Check(func));
06489 assert(METH_FASTCALL == (PyCFunction_GET_FLAGS(func) & ~(METH_CLASS | METH_STATIC | METH_COEXIST)));
06490 assert(nargs >= 0);
06491 assert(nargs == 0 || args != NULL);
06492
06493
06494
06495 assert(!PyErr_Occurred());
06496 return (*((__Pyx_PyCFunctionFast)meth)) (self, args, nargs, NULL);
06497 }
06498 #endif // CYTHON_FAST_PYCCALL
06499
06500
06501 #if CYTHON_FAST_PYCALL
06502 #include "frameobject.h"
06503 static PyObject* __Pyx_PyFunction_FastCallNoKw(PyCodeObject *co, PyObject **args, Py_ssize_t na,
06504 PyObject *globals) {
06505 PyFrameObject *f;
06506 PyThreadState *tstate = PyThreadState_GET();
06507 PyObject **fastlocals;
06508 Py_ssize_t i;
06509 PyObject *result;
06510 assert(globals != NULL);
06511
06512
06513
06514
06515 assert(tstate != NULL);
06516 f = PyFrame_New(tstate, co, globals, NULL);
06517 if (f == NULL) {
06518 return NULL;
06519 }
06520 fastlocals = f->f_localsplus;
06521 for (i = 0; i < na; i++) {
06522 Py_INCREF(*args);
06523 fastlocals[i] = *args++;
06524 }
06525 result = PyEval_EvalFrameEx(f,0);
06526 ++tstate->recursion_depth;
06527 Py_DECREF(f);
06528 --tstate->recursion_depth;
06529 return result;
06530 }
06531 #if 1 || PY_VERSION_HEX < 0x030600B1
06532 static PyObject *__Pyx_PyFunction_FastCallDict(PyObject *func, PyObject **args, int nargs, PyObject *kwargs) {
06533 PyCodeObject *co = (PyCodeObject *)PyFunction_GET_CODE(func);
06534 PyObject *globals = PyFunction_GET_GLOBALS(func);
06535 PyObject *argdefs = PyFunction_GET_DEFAULTS(func);
06536 PyObject *closure;
06537 #if PY_MAJOR_VERSION >= 3
06538 PyObject *kwdefs;
06539 #endif
06540 PyObject *kwtuple, **k;
06541 PyObject **d;
06542 Py_ssize_t nd;
06543 Py_ssize_t nk;
06544 PyObject *result;
06545 assert(kwargs == NULL || PyDict_Check(kwargs));
06546 nk = kwargs ? PyDict_Size(kwargs) : 0;
06547 if (Py_EnterRecursiveCall((char*)" while calling a Python object")) {
06548 return NULL;
06549 }
06550 if (
06551 #if PY_MAJOR_VERSION >= 3
06552 co->co_kwonlyargcount == 0 &&
06553 #endif
06554 likely(kwargs == NULL || nk == 0) &&
06555 co->co_flags == (CO_OPTIMIZED | CO_NEWLOCALS | CO_NOFREE)) {
06556 if (argdefs == NULL && co->co_argcount == nargs) {
06557 result = __Pyx_PyFunction_FastCallNoKw(co, args, nargs, globals);
06558 goto done;
06559 }
06560 else if (nargs == 0 && argdefs != NULL
06561 && co->co_argcount == Py_SIZE(argdefs)) {
06562
06563
06564 args = &PyTuple_GET_ITEM(argdefs, 0);
06565 result =__Pyx_PyFunction_FastCallNoKw(co, args, Py_SIZE(argdefs), globals);
06566 goto done;
06567 }
06568 }
06569 if (kwargs != NULL) {
06570 Py_ssize_t pos, i;
06571 kwtuple = PyTuple_New(2 * nk);
06572 if (kwtuple == NULL) {
06573 result = NULL;
06574 goto done;
06575 }
06576 k = &PyTuple_GET_ITEM(kwtuple, 0);
06577 pos = i = 0;
06578 while (PyDict_Next(kwargs, &pos, &k[i], &k[i+1])) {
06579 Py_INCREF(k[i]);
06580 Py_INCREF(k[i+1]);
06581 i += 2;
06582 }
06583 nk = i / 2;
06584 }
06585 else {
06586 kwtuple = NULL;
06587 k = NULL;
06588 }
06589 closure = PyFunction_GET_CLOSURE(func);
06590 #if PY_MAJOR_VERSION >= 3
06591 kwdefs = PyFunction_GET_KW_DEFAULTS(func);
06592 #endif
06593 if (argdefs != NULL) {
06594 d = &PyTuple_GET_ITEM(argdefs, 0);
06595 nd = Py_SIZE(argdefs);
06596 }
06597 else {
06598 d = NULL;
06599 nd = 0;
06600 }
06601 #if PY_MAJOR_VERSION >= 3
06602 result = PyEval_EvalCodeEx((PyObject*)co, globals, (PyObject *)NULL,
06603 args, nargs,
06604 k, (int)nk,
06605 d, (int)nd, kwdefs, closure);
06606 #else
06607 result = PyEval_EvalCodeEx(co, globals, (PyObject *)NULL,
06608 args, nargs,
06609 k, (int)nk,
06610 d, (int)nd, closure);
06611 #endif
06612 Py_XDECREF(kwtuple);
06613 done:
06614 Py_LeaveRecursiveCall();
06615 return result;
06616 }
06617 #endif // CPython < 3.6
06618 #endif // CYTHON_FAST_PYCALL
06619
06620
06621 #if CYTHON_COMPILING_IN_CPYTHON
06622 static CYTHON_INLINE PyObject* __Pyx_PyObject_Call(PyObject *func, PyObject *arg, PyObject *kw) {
06623 PyObject *result;
06624 ternaryfunc call = func->ob_type->tp_call;
06625 if (unlikely(!call))
06626 return PyObject_Call(func, arg, kw);
06627 if (unlikely(Py_EnterRecursiveCall((char*)" while calling a Python object")))
06628 return NULL;
06629 result = (*call)(func, arg, kw);
06630 Py_LeaveRecursiveCall();
06631 if (unlikely(!result) && unlikely(!PyErr_Occurred())) {
06632 PyErr_SetString(
06633 PyExc_SystemError,
06634 "NULL result without error in PyObject_Call");
06635 }
06636 return result;
06637 }
06638 #endif
06639
06640
06641 #if CYTHON_COMPILING_IN_CPYTHON
06642 static CYTHON_INLINE PyObject* __Pyx_PyObject_CallMethO(PyObject *func, PyObject *arg) {
06643 PyObject *self, *result;
06644 PyCFunction cfunc;
06645 cfunc = PyCFunction_GET_FUNCTION(func);
06646 self = PyCFunction_GET_SELF(func);
06647 if (unlikely(Py_EnterRecursiveCall((char*)" while calling a Python object")))
06648 return NULL;
06649 result = cfunc(self, arg);
06650 Py_LeaveRecursiveCall();
06651 if (unlikely(!result) && unlikely(!PyErr_Occurred())) {
06652 PyErr_SetString(
06653 PyExc_SystemError,
06654 "NULL result without error in PyObject_Call");
06655 }
06656 return result;
06657 }
06658 #endif
06659
06660
06661 #if CYTHON_COMPILING_IN_CPYTHON
06662 static PyObject* __Pyx__PyObject_CallOneArg(PyObject *func, PyObject *arg) {
06663 PyObject *result;
06664 PyObject *args = PyTuple_New(1);
06665 if (unlikely(!args)) return NULL;
06666 Py_INCREF(arg);
06667 PyTuple_SET_ITEM(args, 0, arg);
06668 result = __Pyx_PyObject_Call(func, args, NULL);
06669 Py_DECREF(args);
06670 return result;
06671 }
06672 static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg) {
06673 #if CYTHON_FAST_PYCALL
06674 if (PyFunction_Check(func)) {
06675 return __Pyx_PyFunction_FastCall(func, &arg, 1);
06676 }
06677 #endif
06678 #ifdef __Pyx_CyFunction_USED
06679 if (likely(PyCFunction_Check(func) || PyObject_TypeCheck(func, __pyx_CyFunctionType))) {
06680 #else
06681 if (likely(PyCFunction_Check(func))) {
06682 #endif
06683 if (likely(PyCFunction_GET_FLAGS(func) & METH_O)) {
06684 return __Pyx_PyObject_CallMethO(func, arg);
06685 #if CYTHON_FAST_PYCCALL
06686 } else if (PyCFunction_GET_FLAGS(func) & METH_FASTCALL) {
06687 return __Pyx_PyCFunction_FastCall(func, &arg, 1);
06688 #endif
06689 }
06690 }
06691 return __Pyx__PyObject_CallOneArg(func, arg);
06692 }
06693 #else
06694 static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg) {
06695 PyObject *result;
06696 PyObject *args = PyTuple_Pack(1, arg);
06697 if (unlikely(!args)) return NULL;
06698 result = __Pyx_PyObject_Call(func, args, NULL);
06699 Py_DECREF(args);
06700 return result;
06701 }
06702 #endif
06703
06704
06705 #if CYTHON_COMPILING_IN_CPYTHON
06706 static CYTHON_INLINE PyObject* __Pyx_PyObject_CallNoArg(PyObject *func) {
06707 #if CYTHON_FAST_PYCALL
06708 if (PyFunction_Check(func)) {
06709 return __Pyx_PyFunction_FastCall(func, NULL, 0);
06710 }
06711 #endif
06712 #ifdef __Pyx_CyFunction_USED
06713 if (likely(PyCFunction_Check(func) || PyObject_TypeCheck(func, __pyx_CyFunctionType))) {
06714 #else
06715 if (likely(PyCFunction_Check(func))) {
06716 #endif
06717 if (likely(PyCFunction_GET_FLAGS(func) & METH_NOARGS)) {
06718 return __Pyx_PyObject_CallMethO(func, NULL);
06719 }
06720 }
06721 return __Pyx_PyObject_Call(func, __pyx_empty_tuple, NULL);
06722 }
06723 #endif
06724
06725
06726 static CYTHON_INLINE PyObject *__Pyx_GetModuleGlobalName(PyObject *name) {
06727 PyObject *result;
06728 #if !CYTHON_AVOID_BORROWED_REFS
06729 result = PyDict_GetItem(__pyx_d, name);
06730 if (likely(result)) {
06731 Py_INCREF(result);
06732 } else {
06733 #else
06734 result = PyObject_GetItem(__pyx_d, name);
06735 if (!result) {
06736 PyErr_Clear();
06737 #endif
06738 result = __Pyx_GetBuiltinName(name);
06739 }
06740 return result;
06741 }
06742
06743
06744 static void __Pyx_RaiseBufferIndexError(int axis) {
06745 PyErr_Format(PyExc_IndexError,
06746 "Out of bounds on buffer access (axis %d)", axis);
06747 }
06748
06749
06750 #if CYTHON_FAST_THREAD_STATE
06751 static CYTHON_INLINE void __Pyx_ErrRestoreInState(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb) {
06752 PyObject *tmp_type, *tmp_value, *tmp_tb;
06753 tmp_type = tstate->curexc_type;
06754 tmp_value = tstate->curexc_value;
06755 tmp_tb = tstate->curexc_traceback;
06756 tstate->curexc_type = type;
06757 tstate->curexc_value = value;
06758 tstate->curexc_traceback = tb;
06759 Py_XDECREF(tmp_type);
06760 Py_XDECREF(tmp_value);
06761 Py_XDECREF(tmp_tb);
06762 }
06763 static CYTHON_INLINE void __Pyx_ErrFetchInState(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) {
06764 *type = tstate->curexc_type;
06765 *value = tstate->curexc_value;
06766 *tb = tstate->curexc_traceback;
06767 tstate->curexc_type = 0;
06768 tstate->curexc_value = 0;
06769 tstate->curexc_traceback = 0;
06770 }
06771 #endif
06772
06773
06774 #if PY_MAJOR_VERSION < 3
06775 static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb,
06776 CYTHON_UNUSED PyObject *cause) {
06777 __Pyx_PyThreadState_declare
06778 Py_XINCREF(type);
06779 if (!value || value == Py_None)
06780 value = NULL;
06781 else
06782 Py_INCREF(value);
06783 if (!tb || tb == Py_None)
06784 tb = NULL;
06785 else {
06786 Py_INCREF(tb);
06787 if (!PyTraceBack_Check(tb)) {
06788 PyErr_SetString(PyExc_TypeError,
06789 "raise: arg 3 must be a traceback or None");
06790 goto raise_error;
06791 }
06792 }
06793 if (PyType_Check(type)) {
06794 #if CYTHON_COMPILING_IN_PYPY
06795 if (!value) {
06796 Py_INCREF(Py_None);
06797 value = Py_None;
06798 }
06799 #endif
06800 PyErr_NormalizeException(&type, &value, &tb);
06801 } else {
06802 if (value) {
06803 PyErr_SetString(PyExc_TypeError,
06804 "instance exception may not have a separate value");
06805 goto raise_error;
06806 }
06807 value = type;
06808 type = (PyObject*) Py_TYPE(type);
06809 Py_INCREF(type);
06810 if (!PyType_IsSubtype((PyTypeObject *)type, (PyTypeObject *)PyExc_BaseException)) {
06811 PyErr_SetString(PyExc_TypeError,
06812 "raise: exception class must be a subclass of BaseException");
06813 goto raise_error;
06814 }
06815 }
06816 __Pyx_PyThreadState_assign
06817 __Pyx_ErrRestore(type, value, tb);
06818 return;
06819 raise_error:
06820 Py_XDECREF(value);
06821 Py_XDECREF(type);
06822 Py_XDECREF(tb);
06823 return;
06824 }
06825 #else
06826 static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause) {
06827 PyObject* owned_instance = NULL;
06828 if (tb == Py_None) {
06829 tb = 0;
06830 } else if (tb && !PyTraceBack_Check(tb)) {
06831 PyErr_SetString(PyExc_TypeError,
06832 "raise: arg 3 must be a traceback or None");
06833 goto bad;
06834 }
06835 if (value == Py_None)
06836 value = 0;
06837 if (PyExceptionInstance_Check(type)) {
06838 if (value) {
06839 PyErr_SetString(PyExc_TypeError,
06840 "instance exception may not have a separate value");
06841 goto bad;
06842 }
06843 value = type;
06844 type = (PyObject*) Py_TYPE(value);
06845 } else if (PyExceptionClass_Check(type)) {
06846 PyObject *instance_class = NULL;
06847 if (value && PyExceptionInstance_Check(value)) {
06848 instance_class = (PyObject*) Py_TYPE(value);
06849 if (instance_class != type) {
06850 int is_subclass = PyObject_IsSubclass(instance_class, type);
06851 if (!is_subclass) {
06852 instance_class = NULL;
06853 } else if (unlikely(is_subclass == -1)) {
06854 goto bad;
06855 } else {
06856 type = instance_class;
06857 }
06858 }
06859 }
06860 if (!instance_class) {
06861 PyObject *args;
06862 if (!value)
06863 args = PyTuple_New(0);
06864 else if (PyTuple_Check(value)) {
06865 Py_INCREF(value);
06866 args = value;
06867 } else
06868 args = PyTuple_Pack(1, value);
06869 if (!args)
06870 goto bad;
06871 owned_instance = PyObject_Call(type, args, NULL);
06872 Py_DECREF(args);
06873 if (!owned_instance)
06874 goto bad;
06875 value = owned_instance;
06876 if (!PyExceptionInstance_Check(value)) {
06877 PyErr_Format(PyExc_TypeError,
06878 "calling %R should have returned an instance of "
06879 "BaseException, not %R",
06880 type, Py_TYPE(value));
06881 goto bad;
06882 }
06883 }
06884 } else {
06885 PyErr_SetString(PyExc_TypeError,
06886 "raise: exception class must be a subclass of BaseException");
06887 goto bad;
06888 }
06889 #if PY_VERSION_HEX >= 0x03030000
06890 if (cause) {
06891 #else
06892 if (cause && cause != Py_None) {
06893 #endif
06894 PyObject *fixed_cause;
06895 if (cause == Py_None) {
06896 fixed_cause = NULL;
06897 } else if (PyExceptionClass_Check(cause)) {
06898 fixed_cause = PyObject_CallObject(cause, NULL);
06899 if (fixed_cause == NULL)
06900 goto bad;
06901 } else if (PyExceptionInstance_Check(cause)) {
06902 fixed_cause = cause;
06903 Py_INCREF(fixed_cause);
06904 } else {
06905 PyErr_SetString(PyExc_TypeError,
06906 "exception causes must derive from "
06907 "BaseException");
06908 goto bad;
06909 }
06910 PyException_SetCause(value, fixed_cause);
06911 }
06912 PyErr_SetObject(type, value);
06913 if (tb) {
06914 #if CYTHON_COMPILING_IN_PYPY
06915 PyObject *tmp_type, *tmp_value, *tmp_tb;
06916 PyErr_Fetch(&tmp_type, &tmp_value, &tmp_tb);
06917 Py_INCREF(tb);
06918 PyErr_Restore(tmp_type, tmp_value, tb);
06919 Py_XDECREF(tmp_tb);
06920 #else
06921 PyThreadState *tstate = PyThreadState_GET();
06922 PyObject* tmp_tb = tstate->curexc_traceback;
06923 if (tb != tmp_tb) {
06924 Py_INCREF(tb);
06925 tstate->curexc_traceback = tb;
06926 Py_XDECREF(tmp_tb);
06927 }
06928 #endif
06929 }
06930 bad:
06931 Py_XDECREF(owned_instance);
06932 return;
06933 }
06934 #endif
06935
06936
06937 static CYTHON_INLINE void __Pyx_RaiseTooManyValuesError(Py_ssize_t expected) {
06938 PyErr_Format(PyExc_ValueError,
06939 "too many values to unpack (expected %" CYTHON_FORMAT_SSIZE_T "d)", expected);
06940 }
06941
06942
06943 static CYTHON_INLINE void __Pyx_RaiseNeedMoreValuesError(Py_ssize_t index) {
06944 PyErr_Format(PyExc_ValueError,
06945 "need more than %" CYTHON_FORMAT_SSIZE_T "d value%.1s to unpack",
06946 index, (index == 1) ? "" : "s");
06947 }
06948
06949
06950 static CYTHON_INLINE void __Pyx_RaiseNoneNotIterableError(void) {
06951 PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable");
06952 }
06953
06954
06955 #if CYTHON_FAST_THREAD_STATE
06956 static CYTHON_INLINE void __Pyx__ExceptionSave(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) {
06957 *type = tstate->exc_type;
06958 *value = tstate->exc_value;
06959 *tb = tstate->exc_traceback;
06960 Py_XINCREF(*type);
06961 Py_XINCREF(*value);
06962 Py_XINCREF(*tb);
06963 }
06964 static CYTHON_INLINE void __Pyx__ExceptionReset(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb) {
06965 PyObject *tmp_type, *tmp_value, *tmp_tb;
06966 tmp_type = tstate->exc_type;
06967 tmp_value = tstate->exc_value;
06968 tmp_tb = tstate->exc_traceback;
06969 tstate->exc_type = type;
06970 tstate->exc_value = value;
06971 tstate->exc_traceback = tb;
06972 Py_XDECREF(tmp_type);
06973 Py_XDECREF(tmp_value);
06974 Py_XDECREF(tmp_tb);
06975 }
06976 #endif
06977
06978
06979 #if CYTHON_FAST_THREAD_STATE
06980 static CYTHON_INLINE int __Pyx_PyErr_ExceptionMatchesInState(PyThreadState* tstate, PyObject* err) {
06981 PyObject *exc_type = tstate->curexc_type;
06982 if (exc_type == err) return 1;
06983 if (unlikely(!exc_type)) return 0;
06984 return PyErr_GivenExceptionMatches(exc_type, err);
06985 }
06986 #endif
06987
06988
06989 #if CYTHON_FAST_THREAD_STATE
06990 static int __Pyx__GetException(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) {
06991 #else
06992 static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb) {
06993 #endif
06994 PyObject *local_type, *local_value, *local_tb;
06995 #if CYTHON_FAST_THREAD_STATE
06996 PyObject *tmp_type, *tmp_value, *tmp_tb;
06997 local_type = tstate->curexc_type;
06998 local_value = tstate->curexc_value;
06999 local_tb = tstate->curexc_traceback;
07000 tstate->curexc_type = 0;
07001 tstate->curexc_value = 0;
07002 tstate->curexc_traceback = 0;
07003 #else
07004 PyErr_Fetch(&local_type, &local_value, &local_tb);
07005 #endif
07006 PyErr_NormalizeException(&local_type, &local_value, &local_tb);
07007 #if CYTHON_FAST_THREAD_STATE
07008 if (unlikely(tstate->curexc_type))
07009 #else
07010 if (unlikely(PyErr_Occurred()))
07011 #endif
07012 goto bad;
07013 #if PY_MAJOR_VERSION >= 3
07014 if (local_tb) {
07015 if (unlikely(PyException_SetTraceback(local_value, local_tb) < 0))
07016 goto bad;
07017 }
07018 #endif
07019 Py_XINCREF(local_tb);
07020 Py_XINCREF(local_type);
07021 Py_XINCREF(local_value);
07022 *type = local_type;
07023 *value = local_value;
07024 *tb = local_tb;
07025 #if CYTHON_FAST_THREAD_STATE
07026 tmp_type = tstate->exc_type;
07027 tmp_value = tstate->exc_value;
07028 tmp_tb = tstate->exc_traceback;
07029 tstate->exc_type = local_type;
07030 tstate->exc_value = local_value;
07031 tstate->exc_traceback = local_tb;
07032 Py_XDECREF(tmp_type);
07033 Py_XDECREF(tmp_value);
07034 Py_XDECREF(tmp_tb);
07035 #else
07036 PyErr_SetExcInfo(local_type, local_value, local_tb);
07037 #endif
07038 return 0;
07039 bad:
07040 *type = 0;
07041 *value = 0;
07042 *tb = 0;
07043 Py_XDECREF(local_type);
07044 Py_XDECREF(local_value);
07045 Py_XDECREF(local_tb);
07046 return -1;
07047 }
07048
07049
07050 static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, int level) {
07051 PyObject *empty_list = 0;
07052 PyObject *module = 0;
07053 PyObject *global_dict = 0;
07054 PyObject *empty_dict = 0;
07055 PyObject *list;
07056 #if PY_VERSION_HEX < 0x03030000
07057 PyObject *py_import;
07058 py_import = __Pyx_PyObject_GetAttrStr(__pyx_b, __pyx_n_s_import);
07059 if (!py_import)
07060 goto bad;
07061 #endif
07062 if (from_list)
07063 list = from_list;
07064 else {
07065 empty_list = PyList_New(0);
07066 if (!empty_list)
07067 goto bad;
07068 list = empty_list;
07069 }
07070 global_dict = PyModule_GetDict(__pyx_m);
07071 if (!global_dict)
07072 goto bad;
07073 empty_dict = PyDict_New();
07074 if (!empty_dict)
07075 goto bad;
07076 {
07077 #if PY_MAJOR_VERSION >= 3
07078 if (level == -1) {
07079 if (strchr(__Pyx_MODULE_NAME, '.')) {
07080 #if PY_VERSION_HEX < 0x03030000
07081 PyObject *py_level = PyInt_FromLong(1);
07082 if (!py_level)
07083 goto bad;
07084 module = PyObject_CallFunctionObjArgs(py_import,
07085 name, global_dict, empty_dict, list, py_level, NULL);
07086 Py_DECREF(py_level);
07087 #else
07088 module = PyImport_ImportModuleLevelObject(
07089 name, global_dict, empty_dict, list, 1);
07090 #endif
07091 if (!module) {
07092 if (!PyErr_ExceptionMatches(PyExc_ImportError))
07093 goto bad;
07094 PyErr_Clear();
07095 }
07096 }
07097 level = 0;
07098 }
07099 #endif
07100 if (!module) {
07101 #if PY_VERSION_HEX < 0x03030000
07102 PyObject *py_level = PyInt_FromLong(level);
07103 if (!py_level)
07104 goto bad;
07105 module = PyObject_CallFunctionObjArgs(py_import,
07106 name, global_dict, empty_dict, list, py_level, NULL);
07107 Py_DECREF(py_level);
07108 #else
07109 module = PyImport_ImportModuleLevelObject(
07110 name, global_dict, empty_dict, list, level);
07111 #endif
07112 }
07113 }
07114 bad:
07115 #if PY_VERSION_HEX < 0x03030000
07116 Py_XDECREF(py_import);
07117 #endif
07118 Py_XDECREF(empty_list);
07119 Py_XDECREF(empty_dict);
07120 return module;
07121 }
07122
07123
07124 static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line) {
07125 int start = 0, mid = 0, end = count - 1;
07126 if (end >= 0 && code_line > entries[end].code_line) {
07127 return count;
07128 }
07129 while (start < end) {
07130 mid = start + (end - start) / 2;
07131 if (code_line < entries[mid].code_line) {
07132 end = mid;
07133 } else if (code_line > entries[mid].code_line) {
07134 start = mid + 1;
07135 } else {
07136 return mid;
07137 }
07138 }
07139 if (code_line <= entries[mid].code_line) {
07140 return mid;
07141 } else {
07142 return mid + 1;
07143 }
07144 }
07145 static PyCodeObject *__pyx_find_code_object(int code_line) {
07146 PyCodeObject* code_object;
07147 int pos;
07148 if (unlikely(!code_line) || unlikely(!__pyx_code_cache.entries)) {
07149 return NULL;
07150 }
07151 pos = __pyx_bisect_code_objects(__pyx_code_cache.entries, __pyx_code_cache.count, code_line);
07152 if (unlikely(pos >= __pyx_code_cache.count) || unlikely(__pyx_code_cache.entries[pos].code_line != code_line)) {
07153 return NULL;
07154 }
07155 code_object = __pyx_code_cache.entries[pos].code_object;
07156 Py_INCREF(code_object);
07157 return code_object;
07158 }
07159 static void __pyx_insert_code_object(int code_line, PyCodeObject* code_object) {
07160 int pos, i;
07161 __Pyx_CodeObjectCacheEntry* entries = __pyx_code_cache.entries;
07162 if (unlikely(!code_line)) {
07163 return;
07164 }
07165 if (unlikely(!entries)) {
07166 entries = (__Pyx_CodeObjectCacheEntry*)PyMem_Malloc(64*sizeof(__Pyx_CodeObjectCacheEntry));
07167 if (likely(entries)) {
07168 __pyx_code_cache.entries = entries;
07169 __pyx_code_cache.max_count = 64;
07170 __pyx_code_cache.count = 1;
07171 entries[0].code_line = code_line;
07172 entries[0].code_object = code_object;
07173 Py_INCREF(code_object);
07174 }
07175 return;
07176 }
07177 pos = __pyx_bisect_code_objects(__pyx_code_cache.entries, __pyx_code_cache.count, code_line);
07178 if ((pos < __pyx_code_cache.count) && unlikely(__pyx_code_cache.entries[pos].code_line == code_line)) {
07179 PyCodeObject* tmp = entries[pos].code_object;
07180 entries[pos].code_object = code_object;
07181 Py_DECREF(tmp);
07182 return;
07183 }
07184 if (__pyx_code_cache.count == __pyx_code_cache.max_count) {
07185 int new_max = __pyx_code_cache.max_count + 64;
07186 entries = (__Pyx_CodeObjectCacheEntry*)PyMem_Realloc(
07187 __pyx_code_cache.entries, (size_t)new_max*sizeof(__Pyx_CodeObjectCacheEntry));
07188 if (unlikely(!entries)) {
07189 return;
07190 }
07191 __pyx_code_cache.entries = entries;
07192 __pyx_code_cache.max_count = new_max;
07193 }
07194 for (i=__pyx_code_cache.count; i>pos; i--) {
07195 entries[i] = entries[i-1];
07196 }
07197 entries[pos].code_line = code_line;
07198 entries[pos].code_object = code_object;
07199 __pyx_code_cache.count++;
07200 Py_INCREF(code_object);
07201 }
07202
07203
07204 #include "compile.h"
07205 #include "frameobject.h"
07206 #include "traceback.h"
07207 static PyCodeObject* __Pyx_CreateCodeObjectForTraceback(
07208 const char *funcname, int c_line,
07209 int py_line, const char *filename) {
07210 PyCodeObject *py_code = 0;
07211 PyObject *py_srcfile = 0;
07212 PyObject *py_funcname = 0;
07213 #if PY_MAJOR_VERSION < 3
07214 py_srcfile = PyString_FromString(filename);
07215 #else
07216 py_srcfile = PyUnicode_FromString(filename);
07217 #endif
07218 if (!py_srcfile) goto bad;
07219 if (c_line) {
07220 #if PY_MAJOR_VERSION < 3
07221 py_funcname = PyString_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, c_line);
07222 #else
07223 py_funcname = PyUnicode_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, c_line);
07224 #endif
07225 }
07226 else {
07227 #if PY_MAJOR_VERSION < 3
07228 py_funcname = PyString_FromString(funcname);
07229 #else
07230 py_funcname = PyUnicode_FromString(funcname);
07231 #endif
07232 }
07233 if (!py_funcname) goto bad;
07234 py_code = __Pyx_PyCode_New(
07235 0,
07236 0,
07237 0,
07238 0,
07239 0,
07240 __pyx_empty_bytes,
07241 __pyx_empty_tuple,
07242 __pyx_empty_tuple,
07243 __pyx_empty_tuple,
07244 __pyx_empty_tuple,
07245 __pyx_empty_tuple,
07246 py_srcfile,
07247 py_funcname,
07248 py_line,
07249 __pyx_empty_bytes
07250 );
07251 Py_DECREF(py_srcfile);
07252 Py_DECREF(py_funcname);
07253 return py_code;
07254 bad:
07255 Py_XDECREF(py_srcfile);
07256 Py_XDECREF(py_funcname);
07257 return NULL;
07258 }
07259 static void __Pyx_AddTraceback(const char *funcname, int c_line,
07260 int py_line, const char *filename) {
07261 PyCodeObject *py_code = 0;
07262 PyFrameObject *py_frame = 0;
07263 py_code = __pyx_find_code_object(c_line ? c_line : py_line);
07264 if (!py_code) {
07265 py_code = __Pyx_CreateCodeObjectForTraceback(
07266 funcname, c_line, py_line, filename);
07267 if (!py_code) goto bad;
07268 __pyx_insert_code_object(c_line ? c_line : py_line, py_code);
07269 }
07270 py_frame = PyFrame_New(
07271 PyThreadState_GET(),
07272 py_code,
07273 __pyx_d,
07274 0
07275 );
07276 if (!py_frame) goto bad;
07277 __Pyx_PyFrame_SetLineNumber(py_frame, py_line);
07278 PyTraceBack_Here(py_frame);
07279 bad:
07280 Py_XDECREF(py_code);
07281 Py_XDECREF(py_frame);
07282 }
07283
07284 #if PY_MAJOR_VERSION < 3
07285 static int __Pyx_GetBuffer(PyObject *obj, Py_buffer *view, int flags) {
07286 if (PyObject_CheckBuffer(obj)) return PyObject_GetBuffer(obj, view, flags);
07287 if (PyObject_TypeCheck(obj, __pyx_ptype_5numpy_ndarray)) return __pyx_pw_5numpy_7ndarray_1__getbuffer__(obj, view, flags);
07288 PyErr_Format(PyExc_TypeError, "'%.200s' does not have the buffer interface", Py_TYPE(obj)->tp_name);
07289 return -1;
07290 }
07291 static void __Pyx_ReleaseBuffer(Py_buffer *view) {
07292 PyObject *obj = view->obj;
07293 if (!obj) return;
07294 if (PyObject_CheckBuffer(obj)) {
07295 PyBuffer_Release(view);
07296 return;
07297 }
07298 if (PyObject_TypeCheck(obj, __pyx_ptype_5numpy_ndarray)) { __pyx_pw_5numpy_7ndarray_3__releasebuffer__(obj, view); return; }
07299 Py_DECREF(obj);
07300 view->obj = NULL;
07301 }
07302 #endif
07303
07304
07305
07306 static CYTHON_INLINE PyObject* __Pyx_PyInt_From_int(int value) {
07307 const int neg_one = (int) -1, const_zero = (int) 0;
07308 const int is_unsigned = neg_one > const_zero;
07309 if (is_unsigned) {
07310 if (sizeof(int) < sizeof(long)) {
07311 return PyInt_FromLong((long) value);
07312 } else if (sizeof(int) <= sizeof(unsigned long)) {
07313 return PyLong_FromUnsignedLong((unsigned long) value);
07314 #ifdef HAVE_LONG_LONG
07315 } else if (sizeof(int) <= sizeof(unsigned PY_LONG_LONG)) {
07316 return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value);
07317 #endif
07318 }
07319 } else {
07320 if (sizeof(int) <= sizeof(long)) {
07321 return PyInt_FromLong((long) value);
07322 #ifdef HAVE_LONG_LONG
07323 } else if (sizeof(int) <= sizeof(PY_LONG_LONG)) {
07324 return PyLong_FromLongLong((PY_LONG_LONG) value);
07325 #endif
07326 }
07327 }
07328 {
07329 int one = 1; int little = (int)*(unsigned char *)&one;
07330 unsigned char *bytes = (unsigned char *)&value;
07331 return _PyLong_FromByteArray(bytes, sizeof(int),
07332 little, !is_unsigned);
07333 }
07334 }
07335
07336
07337 #define __PYX_VERIFY_RETURN_INT(target_type, func_type, func_value)\
07338 __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, 0)
07339 #define __PYX_VERIFY_RETURN_INT_EXC(target_type, func_type, func_value)\
07340 __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, 1)
07341 #define __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, exc)\
07342 {\
07343 func_type value = func_value;\
07344 if (sizeof(target_type) < sizeof(func_type)) {\
07345 if (unlikely(value != (func_type) (target_type) value)) {\
07346 func_type zero = 0;\
07347 if (exc && unlikely(value == (func_type)-1 && PyErr_Occurred()))\
07348 return (target_type) -1;\
07349 if (is_unsigned && unlikely(value < zero))\
07350 goto raise_neg_overflow;\
07351 else\
07352 goto raise_overflow;\
07353 }\
07354 }\
07355 return (target_type) value;\
07356 }
07357
07358
07359 static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value) {
07360 const long neg_one = (long) -1, const_zero = (long) 0;
07361 const int is_unsigned = neg_one > const_zero;
07362 if (is_unsigned) {
07363 if (sizeof(long) < sizeof(long)) {
07364 return PyInt_FromLong((long) value);
07365 } else if (sizeof(long) <= sizeof(unsigned long)) {
07366 return PyLong_FromUnsignedLong((unsigned long) value);
07367 #ifdef HAVE_LONG_LONG
07368 } else if (sizeof(long) <= sizeof(unsigned PY_LONG_LONG)) {
07369 return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value);
07370 #endif
07371 }
07372 } else {
07373 if (sizeof(long) <= sizeof(long)) {
07374 return PyInt_FromLong((long) value);
07375 #ifdef HAVE_LONG_LONG
07376 } else if (sizeof(long) <= sizeof(PY_LONG_LONG)) {
07377 return PyLong_FromLongLong((PY_LONG_LONG) value);
07378 #endif
07379 }
07380 }
07381 {
07382 int one = 1; int little = (int)*(unsigned char *)&one;
07383 unsigned char *bytes = (unsigned char *)&value;
07384 return _PyLong_FromByteArray(bytes, sizeof(long),
07385 little, !is_unsigned);
07386 }
07387 }
07388
07389
07390 #if CYTHON_CCOMPLEX
07391 #ifdef __cplusplus
07392 static CYTHON_INLINE __pyx_t_float_complex __pyx_t_float_complex_from_parts(float x, float y) {
07393 return ::std::complex< float >(x, y);
07394 }
07395 #else
07396 static CYTHON_INLINE __pyx_t_float_complex __pyx_t_float_complex_from_parts(float x, float y) {
07397 return x + y*(__pyx_t_float_complex)_Complex_I;
07398 }
07399 #endif
07400 #else
07401 static CYTHON_INLINE __pyx_t_float_complex __pyx_t_float_complex_from_parts(float x, float y) {
07402 __pyx_t_float_complex z;
07403 z.real = x;
07404 z.imag = y;
07405 return z;
07406 }
07407 #endif
07408
07409
07410 #if CYTHON_CCOMPLEX
07411 #else
07412 static CYTHON_INLINE int __Pyx_c_eq_float(__pyx_t_float_complex a, __pyx_t_float_complex b) {
07413 return (a.real == b.real) && (a.imag == b.imag);
07414 }
07415 static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_sum_float(__pyx_t_float_complex a, __pyx_t_float_complex b) {
07416 __pyx_t_float_complex z;
07417 z.real = a.real + b.real;
07418 z.imag = a.imag + b.imag;
07419 return z;
07420 }
07421 static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_diff_float(__pyx_t_float_complex a, __pyx_t_float_complex b) {
07422 __pyx_t_float_complex z;
07423 z.real = a.real - b.real;
07424 z.imag = a.imag - b.imag;
07425 return z;
07426 }
07427 static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_prod_float(__pyx_t_float_complex a, __pyx_t_float_complex b) {
07428 __pyx_t_float_complex z;
07429 z.real = a.real * b.real - a.imag * b.imag;
07430 z.imag = a.real * b.imag + a.imag * b.real;
07431 return z;
07432 }
07433 #if 1
07434 static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_quot_float(__pyx_t_float_complex a, __pyx_t_float_complex b) {
07435 if (b.imag == 0) {
07436 return __pyx_t_float_complex_from_parts(a.real / b.real, a.imag / b.real);
07437 } else if (fabsf(b.real) >= fabsf(b.imag)) {
07438 if (b.real == 0 && b.imag == 0) {
07439 return __pyx_t_float_complex_from_parts(a.real / b.real, a.imag / b.imag);
07440 } else {
07441 float r = b.imag / b.real;
07442 float s = 1.0 / (b.real + b.imag * r);
07443 return __pyx_t_float_complex_from_parts(
07444 (a.real + a.imag * r) * s, (a.imag - a.real * r) * s);
07445 }
07446 } else {
07447 float r = b.real / b.imag;
07448 float s = 1.0 / (b.imag + b.real * r);
07449 return __pyx_t_float_complex_from_parts(
07450 (a.real * r + a.imag) * s, (a.imag * r - a.real) * s);
07451 }
07452 }
07453 #else
07454 static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_quot_float(__pyx_t_float_complex a, __pyx_t_float_complex b) {
07455 if (b.imag == 0) {
07456 return __pyx_t_float_complex_from_parts(a.real / b.real, a.imag / b.real);
07457 } else {
07458 float denom = b.real * b.real + b.imag * b.imag;
07459 return __pyx_t_float_complex_from_parts(
07460 (a.real * b.real + a.imag * b.imag) / denom,
07461 (a.imag * b.real - a.real * b.imag) / denom);
07462 }
07463 }
07464 #endif
07465 static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_neg_float(__pyx_t_float_complex a) {
07466 __pyx_t_float_complex z;
07467 z.real = -a.real;
07468 z.imag = -a.imag;
07469 return z;
07470 }
07471 static CYTHON_INLINE int __Pyx_c_is_zero_float(__pyx_t_float_complex a) {
07472 return (a.real == 0) && (a.imag == 0);
07473 }
07474 static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_conj_float(__pyx_t_float_complex a) {
07475 __pyx_t_float_complex z;
07476 z.real = a.real;
07477 z.imag = -a.imag;
07478 return z;
07479 }
07480 #if 1
07481 static CYTHON_INLINE float __Pyx_c_abs_float(__pyx_t_float_complex z) {
07482 #if !defined(HAVE_HYPOT) || defined(_MSC_VER)
07483 return sqrtf(z.real*z.real + z.imag*z.imag);
07484 #else
07485 return hypotf(z.real, z.imag);
07486 #endif
07487 }
07488 static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_pow_float(__pyx_t_float_complex a, __pyx_t_float_complex b) {
07489 __pyx_t_float_complex z;
07490 float r, lnr, theta, z_r, z_theta;
07491 if (b.imag == 0 && b.real == (int)b.real) {
07492 if (b.real < 0) {
07493 float denom = a.real * a.real + a.imag * a.imag;
07494 a.real = a.real / denom;
07495 a.imag = -a.imag / denom;
07496 b.real = -b.real;
07497 }
07498 switch ((int)b.real) {
07499 case 0:
07500 z.real = 1;
07501 z.imag = 0;
07502 return z;
07503 case 1:
07504 return a;
07505 case 2:
07506 z = __Pyx_c_prod_float(a, a);
07507 return __Pyx_c_prod_float(a, a);
07508 case 3:
07509 z = __Pyx_c_prod_float(a, a);
07510 return __Pyx_c_prod_float(z, a);
07511 case 4:
07512 z = __Pyx_c_prod_float(a, a);
07513 return __Pyx_c_prod_float(z, z);
07514 }
07515 }
07516 if (a.imag == 0) {
07517 if (a.real == 0) {
07518 return a;
07519 } else if (b.imag == 0) {
07520 z.real = powf(a.real, b.real);
07521 z.imag = 0;
07522 return z;
07523 } else if (a.real > 0) {
07524 r = a.real;
07525 theta = 0;
07526 } else {
07527 r = -a.real;
07528 theta = atan2f(0, -1);
07529 }
07530 } else {
07531 r = __Pyx_c_abs_float(a);
07532 theta = atan2f(a.imag, a.real);
07533 }
07534 lnr = logf(r);
07535 z_r = expf(lnr * b.real - theta * b.imag);
07536 z_theta = theta * b.real + lnr * b.imag;
07537 z.real = z_r * cosf(z_theta);
07538 z.imag = z_r * sinf(z_theta);
07539 return z;
07540 }
07541 #endif
07542 #endif
07543
07544
07545 #if CYTHON_CCOMPLEX
07546 #ifdef __cplusplus
07547 static CYTHON_INLINE __pyx_t_double_complex __pyx_t_double_complex_from_parts(double x, double y) {
07548 return ::std::complex< double >(x, y);
07549 }
07550 #else
07551 static CYTHON_INLINE __pyx_t_double_complex __pyx_t_double_complex_from_parts(double x, double y) {
07552 return x + y*(__pyx_t_double_complex)_Complex_I;
07553 }
07554 #endif
07555 #else
07556 static CYTHON_INLINE __pyx_t_double_complex __pyx_t_double_complex_from_parts(double x, double y) {
07557 __pyx_t_double_complex z;
07558 z.real = x;
07559 z.imag = y;
07560 return z;
07561 }
07562 #endif
07563
07564
07565 #if CYTHON_CCOMPLEX
07566 #else
07567 static CYTHON_INLINE int __Pyx_c_eq_double(__pyx_t_double_complex a, __pyx_t_double_complex b) {
07568 return (a.real == b.real) && (a.imag == b.imag);
07569 }
07570 static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_sum_double(__pyx_t_double_complex a, __pyx_t_double_complex b) {
07571 __pyx_t_double_complex z;
07572 z.real = a.real + b.real;
07573 z.imag = a.imag + b.imag;
07574 return z;
07575 }
07576 static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_diff_double(__pyx_t_double_complex a, __pyx_t_double_complex b) {
07577 __pyx_t_double_complex z;
07578 z.real = a.real - b.real;
07579 z.imag = a.imag - b.imag;
07580 return z;
07581 }
07582 static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_prod_double(__pyx_t_double_complex a, __pyx_t_double_complex b) {
07583 __pyx_t_double_complex z;
07584 z.real = a.real * b.real - a.imag * b.imag;
07585 z.imag = a.real * b.imag + a.imag * b.real;
07586 return z;
07587 }
07588 #if 1
07589 static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_quot_double(__pyx_t_double_complex a, __pyx_t_double_complex b) {
07590 if (b.imag == 0) {
07591 return __pyx_t_double_complex_from_parts(a.real / b.real, a.imag / b.real);
07592 } else if (fabs(b.real) >= fabs(b.imag)) {
07593 if (b.real == 0 && b.imag == 0) {
07594 return __pyx_t_double_complex_from_parts(a.real / b.real, a.imag / b.imag);
07595 } else {
07596 double r = b.imag / b.real;
07597 double s = 1.0 / (b.real + b.imag * r);
07598 return __pyx_t_double_complex_from_parts(
07599 (a.real + a.imag * r) * s, (a.imag - a.real * r) * s);
07600 }
07601 } else {
07602 double r = b.real / b.imag;
07603 double s = 1.0 / (b.imag + b.real * r);
07604 return __pyx_t_double_complex_from_parts(
07605 (a.real * r + a.imag) * s, (a.imag * r - a.real) * s);
07606 }
07607 }
07608 #else
07609 static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_quot_double(__pyx_t_double_complex a, __pyx_t_double_complex b) {
07610 if (b.imag == 0) {
07611 return __pyx_t_double_complex_from_parts(a.real / b.real, a.imag / b.real);
07612 } else {
07613 double denom = b.real * b.real + b.imag * b.imag;
07614 return __pyx_t_double_complex_from_parts(
07615 (a.real * b.real + a.imag * b.imag) / denom,
07616 (a.imag * b.real - a.real * b.imag) / denom);
07617 }
07618 }
07619 #endif
07620 static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_neg_double(__pyx_t_double_complex a) {
07621 __pyx_t_double_complex z;
07622 z.real = -a.real;
07623 z.imag = -a.imag;
07624 return z;
07625 }
07626 static CYTHON_INLINE int __Pyx_c_is_zero_double(__pyx_t_double_complex a) {
07627 return (a.real == 0) && (a.imag == 0);
07628 }
07629 static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_conj_double(__pyx_t_double_complex a) {
07630 __pyx_t_double_complex z;
07631 z.real = a.real;
07632 z.imag = -a.imag;
07633 return z;
07634 }
07635 #if 1
07636 static CYTHON_INLINE double __Pyx_c_abs_double(__pyx_t_double_complex z) {
07637 #if !defined(HAVE_HYPOT) || defined(_MSC_VER)
07638 return sqrt(z.real*z.real + z.imag*z.imag);
07639 #else
07640 return hypot(z.real, z.imag);
07641 #endif
07642 }
07643 static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_pow_double(__pyx_t_double_complex a, __pyx_t_double_complex b) {
07644 __pyx_t_double_complex z;
07645 double r, lnr, theta, z_r, z_theta;
07646 if (b.imag == 0 && b.real == (int)b.real) {
07647 if (b.real < 0) {
07648 double denom = a.real * a.real + a.imag * a.imag;
07649 a.real = a.real / denom;
07650 a.imag = -a.imag / denom;
07651 b.real = -b.real;
07652 }
07653 switch ((int)b.real) {
07654 case 0:
07655 z.real = 1;
07656 z.imag = 0;
07657 return z;
07658 case 1:
07659 return a;
07660 case 2:
07661 z = __Pyx_c_prod_double(a, a);
07662 return __Pyx_c_prod_double(a, a);
07663 case 3:
07664 z = __Pyx_c_prod_double(a, a);
07665 return __Pyx_c_prod_double(z, a);
07666 case 4:
07667 z = __Pyx_c_prod_double(a, a);
07668 return __Pyx_c_prod_double(z, z);
07669 }
07670 }
07671 if (a.imag == 0) {
07672 if (a.real == 0) {
07673 return a;
07674 } else if (b.imag == 0) {
07675 z.real = pow(a.real, b.real);
07676 z.imag = 0;
07677 return z;
07678 } else if (a.real > 0) {
07679 r = a.real;
07680 theta = 0;
07681 } else {
07682 r = -a.real;
07683 theta = atan2(0, -1);
07684 }
07685 } else {
07686 r = __Pyx_c_abs_double(a);
07687 theta = atan2(a.imag, a.real);
07688 }
07689 lnr = log(r);
07690 z_r = exp(lnr * b.real - theta * b.imag);
07691 z_theta = theta * b.real + lnr * b.imag;
07692 z.real = z_r * cos(z_theta);
07693 z.imag = z_r * sin(z_theta);
07694 return z;
07695 }
07696 #endif
07697 #endif
07698
07699
07700 static CYTHON_INLINE PyObject* __Pyx_PyInt_From_enum__NPY_TYPES(enum NPY_TYPES value) {
07701 const enum NPY_TYPES neg_one = (enum NPY_TYPES) -1, const_zero = (enum NPY_TYPES) 0;
07702 const int is_unsigned = neg_one > const_zero;
07703 if (is_unsigned) {
07704 if (sizeof(enum NPY_TYPES) < sizeof(long)) {
07705 return PyInt_FromLong((long) value);
07706 } else if (sizeof(enum NPY_TYPES) <= sizeof(unsigned long)) {
07707 return PyLong_FromUnsignedLong((unsigned long) value);
07708 #ifdef HAVE_LONG_LONG
07709 } else if (sizeof(enum NPY_TYPES) <= sizeof(unsigned PY_LONG_LONG)) {
07710 return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value);
07711 #endif
07712 }
07713 } else {
07714 if (sizeof(enum NPY_TYPES) <= sizeof(long)) {
07715 return PyInt_FromLong((long) value);
07716 #ifdef HAVE_LONG_LONG
07717 } else if (sizeof(enum NPY_TYPES) <= sizeof(PY_LONG_LONG)) {
07718 return PyLong_FromLongLong((PY_LONG_LONG) value);
07719 #endif
07720 }
07721 }
07722 {
07723 int one = 1; int little = (int)*(unsigned char *)&one;
07724 unsigned char *bytes = (unsigned char *)&value;
07725 return _PyLong_FromByteArray(bytes, sizeof(enum NPY_TYPES),
07726 little, !is_unsigned);
07727 }
07728 }
07729
07730
07731 static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *x) {
07732 const int neg_one = (int) -1, const_zero = (int) 0;
07733 const int is_unsigned = neg_one > const_zero;
07734 #if PY_MAJOR_VERSION < 3
07735 if (likely(PyInt_Check(x))) {
07736 if (sizeof(int) < sizeof(long)) {
07737 __PYX_VERIFY_RETURN_INT(int, long, PyInt_AS_LONG(x))
07738 } else {
07739 long val = PyInt_AS_LONG(x);
07740 if (is_unsigned && unlikely(val < 0)) {
07741 goto raise_neg_overflow;
07742 }
07743 return (int) val;
07744 }
07745 } else
07746 #endif
07747 if (likely(PyLong_Check(x))) {
07748 if (is_unsigned) {
07749 #if CYTHON_USE_PYLONG_INTERNALS
07750 const digit* digits = ((PyLongObject*)x)->ob_digit;
07751 switch (Py_SIZE(x)) {
07752 case 0: return (int) 0;
07753 case 1: __PYX_VERIFY_RETURN_INT(int, digit, digits[0])
07754 case 2:
07755 if (8 * sizeof(int) > 1 * PyLong_SHIFT) {
07756 if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
07757 __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
07758 } else if (8 * sizeof(int) >= 2 * PyLong_SHIFT) {
07759 return (int) (((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0]));
07760 }
07761 }
07762 break;
07763 case 3:
07764 if (8 * sizeof(int) > 2 * PyLong_SHIFT) {
07765 if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
07766 __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
07767 } else if (8 * sizeof(int) >= 3 * PyLong_SHIFT) {
07768 return (int) (((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]));
07769 }
07770 }
07771 break;
07772 case 4:
07773 if (8 * sizeof(int) > 3 * PyLong_SHIFT) {
07774 if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
07775 __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
07776 } else if (8 * sizeof(int) >= 4 * PyLong_SHIFT) {
07777 return (int) (((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]));
07778 }
07779 }
07780 break;
07781 }
07782 #endif
07783 #if CYTHON_COMPILING_IN_CPYTHON
07784 if (unlikely(Py_SIZE(x) < 0)) {
07785 goto raise_neg_overflow;
07786 }
07787 #else
07788 {
07789 int result = PyObject_RichCompareBool(x, Py_False, Py_LT);
07790 if (unlikely(result < 0))
07791 return (int) -1;
07792 if (unlikely(result == 1))
07793 goto raise_neg_overflow;
07794 }
07795 #endif
07796 if (sizeof(int) <= sizeof(unsigned long)) {
07797 __PYX_VERIFY_RETURN_INT_EXC(int, unsigned long, PyLong_AsUnsignedLong(x))
07798 #ifdef HAVE_LONG_LONG
07799 } else if (sizeof(int) <= sizeof(unsigned PY_LONG_LONG)) {
07800 __PYX_VERIFY_RETURN_INT_EXC(int, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x))
07801 #endif
07802 }
07803 } else {
07804 #if CYTHON_USE_PYLONG_INTERNALS
07805 const digit* digits = ((PyLongObject*)x)->ob_digit;
07806 switch (Py_SIZE(x)) {
07807 case 0: return (int) 0;
07808 case -1: __PYX_VERIFY_RETURN_INT(int, sdigit, (sdigit) (-(sdigit)digits[0]))
07809 case 1: __PYX_VERIFY_RETURN_INT(int, digit, +digits[0])
07810 case -2:
07811 if (8 * sizeof(int) - 1 > 1 * PyLong_SHIFT) {
07812 if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
07813 __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
07814 } else if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) {
07815 return (int) (((int)-1)*(((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
07816 }
07817 }
07818 break;
07819 case 2:
07820 if (8 * sizeof(int) > 1 * PyLong_SHIFT) {
07821 if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
07822 __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
07823 } else if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) {
07824 return (int) ((((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
07825 }
07826 }
07827 break;
07828 case -3:
07829 if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) {
07830 if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
07831 __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
07832 } else if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) {
07833 return (int) (((int)-1)*(((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
07834 }
07835 }
07836 break;
07837 case 3:
07838 if (8 * sizeof(int) > 2 * PyLong_SHIFT) {
07839 if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
07840 __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
07841 } else if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) {
07842 return (int) ((((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
07843 }
07844 }
07845 break;
07846 case -4:
07847 if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) {
07848 if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
07849 __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
07850 } else if (8 * sizeof(int) - 1 > 4 * PyLong_SHIFT) {
07851 return (int) (((int)-1)*(((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
07852 }
07853 }
07854 break;
07855 case 4:
07856 if (8 * sizeof(int) > 3 * PyLong_SHIFT) {
07857 if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
07858 __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
07859 } else if (8 * sizeof(int) - 1 > 4 * PyLong_SHIFT) {
07860 return (int) ((((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
07861 }
07862 }
07863 break;
07864 }
07865 #endif
07866 if (sizeof(int) <= sizeof(long)) {
07867 __PYX_VERIFY_RETURN_INT_EXC(int, long, PyLong_AsLong(x))
07868 #ifdef HAVE_LONG_LONG
07869 } else if (sizeof(int) <= sizeof(PY_LONG_LONG)) {
07870 __PYX_VERIFY_RETURN_INT_EXC(int, PY_LONG_LONG, PyLong_AsLongLong(x))
07871 #endif
07872 }
07873 }
07874 {
07875 #if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray)
07876 PyErr_SetString(PyExc_RuntimeError,
07877 "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers");
07878 #else
07879 int val;
07880 PyObject *v = __Pyx_PyNumber_IntOrLong(x);
07881 #if PY_MAJOR_VERSION < 3
07882 if (likely(v) && !PyLong_Check(v)) {
07883 PyObject *tmp = v;
07884 v = PyNumber_Long(tmp);
07885 Py_DECREF(tmp);
07886 }
07887 #endif
07888 if (likely(v)) {
07889 int one = 1; int is_little = (int)*(unsigned char *)&one;
07890 unsigned char *bytes = (unsigned char *)&val;
07891 int ret = _PyLong_AsByteArray((PyLongObject *)v,
07892 bytes, sizeof(val),
07893 is_little, !is_unsigned);
07894 Py_DECREF(v);
07895 if (likely(!ret))
07896 return val;
07897 }
07898 #endif
07899 return (int) -1;
07900 }
07901 } else {
07902 int val;
07903 PyObject *tmp = __Pyx_PyNumber_IntOrLong(x);
07904 if (!tmp) return (int) -1;
07905 val = __Pyx_PyInt_As_int(tmp);
07906 Py_DECREF(tmp);
07907 return val;
07908 }
07909 raise_overflow:
07910 PyErr_SetString(PyExc_OverflowError,
07911 "value too large to convert to int");
07912 return (int) -1;
07913 raise_neg_overflow:
07914 PyErr_SetString(PyExc_OverflowError,
07915 "can't convert negative value to int");
07916 return (int) -1;
07917 }
07918
07919
07920 static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *x) {
07921 const long neg_one = (long) -1, const_zero = (long) 0;
07922 const int is_unsigned = neg_one > const_zero;
07923 #if PY_MAJOR_VERSION < 3
07924 if (likely(PyInt_Check(x))) {
07925 if (sizeof(long) < sizeof(long)) {
07926 __PYX_VERIFY_RETURN_INT(long, long, PyInt_AS_LONG(x))
07927 } else {
07928 long val = PyInt_AS_LONG(x);
07929 if (is_unsigned && unlikely(val < 0)) {
07930 goto raise_neg_overflow;
07931 }
07932 return (long) val;
07933 }
07934 } else
07935 #endif
07936 if (likely(PyLong_Check(x))) {
07937 if (is_unsigned) {
07938 #if CYTHON_USE_PYLONG_INTERNALS
07939 const digit* digits = ((PyLongObject*)x)->ob_digit;
07940 switch (Py_SIZE(x)) {
07941 case 0: return (long) 0;
07942 case 1: __PYX_VERIFY_RETURN_INT(long, digit, digits[0])
07943 case 2:
07944 if (8 * sizeof(long) > 1 * PyLong_SHIFT) {
07945 if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
07946 __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
07947 } else if (8 * sizeof(long) >= 2 * PyLong_SHIFT) {
07948 return (long) (((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0]));
07949 }
07950 }
07951 break;
07952 case 3:
07953 if (8 * sizeof(long) > 2 * PyLong_SHIFT) {
07954 if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
07955 __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
07956 } else if (8 * sizeof(long) >= 3 * PyLong_SHIFT) {
07957 return (long) (((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]));
07958 }
07959 }
07960 break;
07961 case 4:
07962 if (8 * sizeof(long) > 3 * PyLong_SHIFT) {
07963 if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
07964 __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
07965 } else if (8 * sizeof(long) >= 4 * PyLong_SHIFT) {
07966 return (long) (((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]));
07967 }
07968 }
07969 break;
07970 }
07971 #endif
07972 #if CYTHON_COMPILING_IN_CPYTHON
07973 if (unlikely(Py_SIZE(x) < 0)) {
07974 goto raise_neg_overflow;
07975 }
07976 #else
07977 {
07978 int result = PyObject_RichCompareBool(x, Py_False, Py_LT);
07979 if (unlikely(result < 0))
07980 return (long) -1;
07981 if (unlikely(result == 1))
07982 goto raise_neg_overflow;
07983 }
07984 #endif
07985 if (sizeof(long) <= sizeof(unsigned long)) {
07986 __PYX_VERIFY_RETURN_INT_EXC(long, unsigned long, PyLong_AsUnsignedLong(x))
07987 #ifdef HAVE_LONG_LONG
07988 } else if (sizeof(long) <= sizeof(unsigned PY_LONG_LONG)) {
07989 __PYX_VERIFY_RETURN_INT_EXC(long, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x))
07990 #endif
07991 }
07992 } else {
07993 #if CYTHON_USE_PYLONG_INTERNALS
07994 const digit* digits = ((PyLongObject*)x)->ob_digit;
07995 switch (Py_SIZE(x)) {
07996 case 0: return (long) 0;
07997 case -1: __PYX_VERIFY_RETURN_INT(long, sdigit, (sdigit) (-(sdigit)digits[0]))
07998 case 1: __PYX_VERIFY_RETURN_INT(long, digit, +digits[0])
07999 case -2:
08000 if (8 * sizeof(long) - 1 > 1 * PyLong_SHIFT) {
08001 if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
08002 __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
08003 } else if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
08004 return (long) (((long)-1)*(((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
08005 }
08006 }
08007 break;
08008 case 2:
08009 if (8 * sizeof(long) > 1 * PyLong_SHIFT) {
08010 if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
08011 __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
08012 } else if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
08013 return (long) ((((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
08014 }
08015 }
08016 break;
08017 case -3:
08018 if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
08019 if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
08020 __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
08021 } else if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
08022 return (long) (((long)-1)*(((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
08023 }
08024 }
08025 break;
08026 case 3:
08027 if (8 * sizeof(long) > 2 * PyLong_SHIFT) {
08028 if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
08029 __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
08030 } else if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
08031 return (long) ((((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
08032 }
08033 }
08034 break;
08035 case -4:
08036 if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
08037 if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
08038 __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
08039 } else if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) {
08040 return (long) (((long)-1)*(((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
08041 }
08042 }
08043 break;
08044 case 4:
08045 if (8 * sizeof(long) > 3 * PyLong_SHIFT) {
08046 if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
08047 __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
08048 } else if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) {
08049 return (long) ((((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
08050 }
08051 }
08052 break;
08053 }
08054 #endif
08055 if (sizeof(long) <= sizeof(long)) {
08056 __PYX_VERIFY_RETURN_INT_EXC(long, long, PyLong_AsLong(x))
08057 #ifdef HAVE_LONG_LONG
08058 } else if (sizeof(long) <= sizeof(PY_LONG_LONG)) {
08059 __PYX_VERIFY_RETURN_INT_EXC(long, PY_LONG_LONG, PyLong_AsLongLong(x))
08060 #endif
08061 }
08062 }
08063 {
08064 #if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray)
08065 PyErr_SetString(PyExc_RuntimeError,
08066 "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers");
08067 #else
08068 long val;
08069 PyObject *v = __Pyx_PyNumber_IntOrLong(x);
08070 #if PY_MAJOR_VERSION < 3
08071 if (likely(v) && !PyLong_Check(v)) {
08072 PyObject *tmp = v;
08073 v = PyNumber_Long(tmp);
08074 Py_DECREF(tmp);
08075 }
08076 #endif
08077 if (likely(v)) {
08078 int one = 1; int is_little = (int)*(unsigned char *)&one;
08079 unsigned char *bytes = (unsigned char *)&val;
08080 int ret = _PyLong_AsByteArray((PyLongObject *)v,
08081 bytes, sizeof(val),
08082 is_little, !is_unsigned);
08083 Py_DECREF(v);
08084 if (likely(!ret))
08085 return val;
08086 }
08087 #endif
08088 return (long) -1;
08089 }
08090 } else {
08091 long val;
08092 PyObject *tmp = __Pyx_PyNumber_IntOrLong(x);
08093 if (!tmp) return (long) -1;
08094 val = __Pyx_PyInt_As_long(tmp);
08095 Py_DECREF(tmp);
08096 return val;
08097 }
08098 raise_overflow:
08099 PyErr_SetString(PyExc_OverflowError,
08100 "value too large to convert to long");
08101 return (long) -1;
08102 raise_neg_overflow:
08103 PyErr_SetString(PyExc_OverflowError,
08104 "can't convert negative value to long");
08105 return (long) -1;
08106 }
08107
08108
08109 static int __Pyx_check_binary_version(void) {
08110 char ctversion[4], rtversion[4];
08111 PyOS_snprintf(ctversion, 4, "%d.%d", PY_MAJOR_VERSION, PY_MINOR_VERSION);
08112 PyOS_snprintf(rtversion, 4, "%s", Py_GetVersion());
08113 if (ctversion[0] != rtversion[0] || ctversion[2] != rtversion[2]) {
08114 char message[200];
08115 PyOS_snprintf(message, sizeof(message),
08116 "compiletime version %s of module '%.100s' "
08117 "does not match runtime version %s",
08118 ctversion, __Pyx_MODULE_NAME, rtversion);
08119 return PyErr_WarnEx(NULL, message, 1);
08120 }
08121 return 0;
08122 }
08123
08124
08125 #ifndef __PYX_HAVE_RT_ImportModule
08126 #define __PYX_HAVE_RT_ImportModule
08127 static PyObject *__Pyx_ImportModule(const char *name) {
08128 PyObject *py_name = 0;
08129 PyObject *py_module = 0;
08130 py_name = __Pyx_PyIdentifier_FromString(name);
08131 if (!py_name)
08132 goto bad;
08133 py_module = PyImport_Import(py_name);
08134 Py_DECREF(py_name);
08135 return py_module;
08136 bad:
08137 Py_XDECREF(py_name);
08138 return 0;
08139 }
08140 #endif
08141
08142
08143 #ifndef __PYX_HAVE_RT_ImportType
08144 #define __PYX_HAVE_RT_ImportType
08145 static PyTypeObject *__Pyx_ImportType(const char *module_name, const char *class_name,
08146 size_t size, int strict)
08147 {
08148 PyObject *py_module = 0;
08149 PyObject *result = 0;
08150 PyObject *py_name = 0;
08151 char warning[200];
08152 Py_ssize_t basicsize;
08153 #ifdef Py_LIMITED_API
08154 PyObject *py_basicsize;
08155 #endif
08156 py_module = __Pyx_ImportModule(module_name);
08157 if (!py_module)
08158 goto bad;
08159 py_name = __Pyx_PyIdentifier_FromString(class_name);
08160 if (!py_name)
08161 goto bad;
08162 result = PyObject_GetAttr(py_module, py_name);
08163 Py_DECREF(py_name);
08164 py_name = 0;
08165 Py_DECREF(py_module);
08166 py_module = 0;
08167 if (!result)
08168 goto bad;
08169 if (!PyType_Check(result)) {
08170 PyErr_Format(PyExc_TypeError,
08171 "%.200s.%.200s is not a type object",
08172 module_name, class_name);
08173 goto bad;
08174 }
08175 #ifndef Py_LIMITED_API
08176 basicsize = ((PyTypeObject *)result)->tp_basicsize;
08177 #else
08178 py_basicsize = PyObject_GetAttrString(result, "__basicsize__");
08179 if (!py_basicsize)
08180 goto bad;
08181 basicsize = PyLong_AsSsize_t(py_basicsize);
08182 Py_DECREF(py_basicsize);
08183 py_basicsize = 0;
08184 if (basicsize == (Py_ssize_t)-1 && PyErr_Occurred())
08185 goto bad;
08186 #endif
08187 if (!strict && (size_t)basicsize > size) {
08188 PyOS_snprintf(warning, sizeof(warning),
08189 "%s.%s size changed, may indicate binary incompatibility. Expected %zd, got %zd",
08190 module_name, class_name, basicsize, size);
08191 if (PyErr_WarnEx(NULL, warning, 0) < 0) goto bad;
08192 }
08193 else if ((size_t)basicsize != size) {
08194 PyErr_Format(PyExc_ValueError,
08195 "%.200s.%.200s has the wrong size, try recompiling. Expected %zd, got %zd",
08196 module_name, class_name, basicsize, size);
08197 goto bad;
08198 }
08199 return (PyTypeObject *)result;
08200 bad:
08201 Py_XDECREF(py_module);
08202 Py_XDECREF(result);
08203 return NULL;
08204 }
08205 #endif
08206
08207
08208 static int __Pyx_InitStrings(__Pyx_StringTabEntry *t) {
08209 while (t->p) {
08210 #if PY_MAJOR_VERSION < 3
08211 if (t->is_unicode) {
08212 *t->p = PyUnicode_DecodeUTF8(t->s, t->n - 1, NULL);
08213 } else if (t->intern) {
08214 *t->p = PyString_InternFromString(t->s);
08215 } else {
08216 *t->p = PyString_FromStringAndSize(t->s, t->n - 1);
08217 }
08218 #else
08219 if (t->is_unicode | t->is_str) {
08220 if (t->intern) {
08221 *t->p = PyUnicode_InternFromString(t->s);
08222 } else if (t->encoding) {
08223 *t->p = PyUnicode_Decode(t->s, t->n - 1, t->encoding, NULL);
08224 } else {
08225 *t->p = PyUnicode_FromStringAndSize(t->s, t->n - 1);
08226 }
08227 } else {
08228 *t->p = PyBytes_FromStringAndSize(t->s, t->n - 1);
08229 }
08230 #endif
08231 if (!*t->p)
08232 return -1;
08233 ++t;
08234 }
08235 return 0;
08236 }
08237
08238 static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(const char* c_str) {
08239 return __Pyx_PyUnicode_FromStringAndSize(c_str, (Py_ssize_t)strlen(c_str));
08240 }
08241 static CYTHON_INLINE char* __Pyx_PyObject_AsString(PyObject* o) {
08242 Py_ssize_t ignore;
08243 return __Pyx_PyObject_AsStringAndSize(o, &ignore);
08244 }
08245 static CYTHON_INLINE char* __Pyx_PyObject_AsStringAndSize(PyObject* o, Py_ssize_t *length) {
08246 #if CYTHON_COMPILING_IN_CPYTHON && (__PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT)
08247 if (
08248 #if PY_MAJOR_VERSION < 3 && __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
08249 __Pyx_sys_getdefaultencoding_not_ascii &&
08250 #endif
08251 PyUnicode_Check(o)) {
08252 #if PY_VERSION_HEX < 0x03030000
08253 char* defenc_c;
08254 PyObject* defenc = _PyUnicode_AsDefaultEncodedString(o, NULL);
08255 if (!defenc) return NULL;
08256 defenc_c = PyBytes_AS_STRING(defenc);
08257 #if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
08258 {
08259 char* end = defenc_c + PyBytes_GET_SIZE(defenc);
08260 char* c;
08261 for (c = defenc_c; c < end; c++) {
08262 if ((unsigned char) (*c) >= 128) {
08263 PyUnicode_AsASCIIString(o);
08264 return NULL;
08265 }
08266 }
08267 }
08268 #endif
08269 *length = PyBytes_GET_SIZE(defenc);
08270 return defenc_c;
08271 #else
08272 if (__Pyx_PyUnicode_READY(o) == -1) return NULL;
08273 #if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
08274 if (PyUnicode_IS_ASCII(o)) {
08275 *length = PyUnicode_GET_LENGTH(o);
08276 return PyUnicode_AsUTF8(o);
08277 } else {
08278 PyUnicode_AsASCIIString(o);
08279 return NULL;
08280 }
08281 #else
08282 return PyUnicode_AsUTF8AndSize(o, length);
08283 #endif
08284 #endif
08285 } else
08286 #endif
08287 #if (!CYTHON_COMPILING_IN_PYPY) || (defined(PyByteArray_AS_STRING) && defined(PyByteArray_GET_SIZE))
08288 if (PyByteArray_Check(o)) {
08289 *length = PyByteArray_GET_SIZE(o);
08290 return PyByteArray_AS_STRING(o);
08291 } else
08292 #endif
08293 {
08294 char* result;
08295 int r = PyBytes_AsStringAndSize(o, &result, length);
08296 if (unlikely(r < 0)) {
08297 return NULL;
08298 } else {
08299 return result;
08300 }
08301 }
08302 }
08303 static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject* x) {
08304 int is_true = x == Py_True;
08305 if (is_true | (x == Py_False) | (x == Py_None)) return is_true;
08306 else return PyObject_IsTrue(x);
08307 }
08308 static CYTHON_INLINE PyObject* __Pyx_PyNumber_IntOrLong(PyObject* x) {
08309 #if CYTHON_USE_TYPE_SLOTS
08310 PyNumberMethods *m;
08311 #endif
08312 const char *name = NULL;
08313 PyObject *res = NULL;
08314 #if PY_MAJOR_VERSION < 3
08315 if (PyInt_Check(x) || PyLong_Check(x))
08316 #else
08317 if (PyLong_Check(x))
08318 #endif
08319 return __Pyx_NewRef(x);
08320 #if CYTHON_USE_TYPE_SLOTS
08321 m = Py_TYPE(x)->tp_as_number;
08322 #if PY_MAJOR_VERSION < 3
08323 if (m && m->nb_int) {
08324 name = "int";
08325 res = PyNumber_Int(x);
08326 }
08327 else if (m && m->nb_long) {
08328 name = "long";
08329 res = PyNumber_Long(x);
08330 }
08331 #else
08332 if (m && m->nb_int) {
08333 name = "int";
08334 res = PyNumber_Long(x);
08335 }
08336 #endif
08337 #else
08338 res = PyNumber_Int(x);
08339 #endif
08340 if (res) {
08341 #if PY_MAJOR_VERSION < 3
08342 if (!PyInt_Check(res) && !PyLong_Check(res)) {
08343 #else
08344 if (!PyLong_Check(res)) {
08345 #endif
08346 PyErr_Format(PyExc_TypeError,
08347 "__%.4s__ returned non-%.4s (type %.200s)",
08348 name, name, Py_TYPE(res)->tp_name);
08349 Py_DECREF(res);
08350 return NULL;
08351 }
08352 }
08353 else if (!PyErr_Occurred()) {
08354 PyErr_SetString(PyExc_TypeError,
08355 "an integer is required");
08356 }
08357 return res;
08358 }
08359 static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject* b) {
08360 Py_ssize_t ival;
08361 PyObject *x;
08362 #if PY_MAJOR_VERSION < 3
08363 if (likely(PyInt_CheckExact(b))) {
08364 if (sizeof(Py_ssize_t) >= sizeof(long))
08365 return PyInt_AS_LONG(b);
08366 else
08367 return PyInt_AsSsize_t(x);
08368 }
08369 #endif
08370 if (likely(PyLong_CheckExact(b))) {
08371 #if CYTHON_USE_PYLONG_INTERNALS
08372 const digit* digits = ((PyLongObject*)b)->ob_digit;
08373 const Py_ssize_t size = Py_SIZE(b);
08374 if (likely(__Pyx_sst_abs(size) <= 1)) {
08375 ival = likely(size) ? digits[0] : 0;
08376 if (size == -1) ival = -ival;
08377 return ival;
08378 } else {
08379 switch (size) {
08380 case 2:
08381 if (8 * sizeof(Py_ssize_t) > 2 * PyLong_SHIFT) {
08382 return (Py_ssize_t) (((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
08383 }
08384 break;
08385 case -2:
08386 if (8 * sizeof(Py_ssize_t) > 2 * PyLong_SHIFT) {
08387 return -(Py_ssize_t) (((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
08388 }
08389 break;
08390 case 3:
08391 if (8 * sizeof(Py_ssize_t) > 3 * PyLong_SHIFT) {
08392 return (Py_ssize_t) (((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
08393 }
08394 break;
08395 case -3:
08396 if (8 * sizeof(Py_ssize_t) > 3 * PyLong_SHIFT) {
08397 return -(Py_ssize_t) (((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
08398 }
08399 break;
08400 case 4:
08401 if (8 * sizeof(Py_ssize_t) > 4 * PyLong_SHIFT) {
08402 return (Py_ssize_t) (((((((((size_t)digits[3]) << PyLong_SHIFT) | (size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
08403 }
08404 break;
08405 case -4:
08406 if (8 * sizeof(Py_ssize_t) > 4 * PyLong_SHIFT) {
08407 return -(Py_ssize_t) (((((((((size_t)digits[3]) << PyLong_SHIFT) | (size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
08408 }
08409 break;
08410 }
08411 }
08412 #endif
08413 return PyLong_AsSsize_t(b);
08414 }
08415 x = PyNumber_Index(b);
08416 if (!x) return -1;
08417 ival = PyInt_AsSsize_t(x);
08418 Py_DECREF(x);
08419 return ival;
08420 }
08421 static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t ival) {
08422 return PyInt_FromSize_t(ival);
08423 }
08424
08425
08426 #endif