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