1 /* Generated by Cython 0.29.23 */
2 
3 /* BEGIN: Cython Metadata
4 {
5     "distutils": {
6         "depends": [
7             "/tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/core/include/numpy/arrayobject.h",
8             "/tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/core/include/numpy/ufuncobject.h"
9         ],
10         "extra_compile_args": [
11             "-w",
12             "-O3",
13             "-funroll-loops"
14         ],
15         "include_dirs": [
16             "/tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/core/include"
17         ],
18         "language": "c++",
19         "name": "qutip.control.cy_grape",
20         "sources": [
21             "qutip/control/cy_grape.pyx"
22         ]
23     },
24     "module_name": "qutip.control.cy_grape"
25 }
26 END: Cython Metadata */
27 
28 #ifndef PY_SSIZE_T_CLEAN
29 #define PY_SSIZE_T_CLEAN
30 #endif /* PY_SSIZE_T_CLEAN */
31 #include "Python.h"
32 #ifndef Py_PYTHON_H
33     #error Python headers needed to compile C extensions, please install development version of Python.
34 #elif PY_VERSION_HEX < 0x02060000 || (0x03000000 <= PY_VERSION_HEX && PY_VERSION_HEX < 0x03030000)
35     #error Cython requires Python 2.6+ or Python 3.3+.
36 #else
37 #define CYTHON_ABI "0_29_23"
38 #define CYTHON_HEX_VERSION 0x001D17F0
39 #define CYTHON_FUTURE_DIVISION 1
40 #include <stddef.h>
41 #ifndef offsetof
42   #define offsetof(type, member) ( (size_t) & ((type*)0) -> member )
43 #endif
44 #if !defined(WIN32) && !defined(MS_WINDOWS)
45   #ifndef __stdcall
46     #define __stdcall
47   #endif
48   #ifndef __cdecl
49     #define __cdecl
50   #endif
51   #ifndef __fastcall
52     #define __fastcall
53   #endif
54 #endif
55 #ifndef DL_IMPORT
56   #define DL_IMPORT(t) t
57 #endif
58 #ifndef DL_EXPORT
59   #define DL_EXPORT(t) t
60 #endif
61 #define __PYX_COMMA ,
62 #ifndef HAVE_LONG_LONG
63   #if PY_VERSION_HEX >= 0x02070000
64     #define HAVE_LONG_LONG
65   #endif
66 #endif
67 #ifndef PY_LONG_LONG
68   #define PY_LONG_LONG LONG_LONG
69 #endif
70 #ifndef Py_HUGE_VAL
71   #define Py_HUGE_VAL HUGE_VAL
72 #endif
73 #ifdef PYPY_VERSION
74   #define CYTHON_COMPILING_IN_PYPY 1
75   #define CYTHON_COMPILING_IN_PYSTON 0
76   #define CYTHON_COMPILING_IN_CPYTHON 0
77   #undef CYTHON_USE_TYPE_SLOTS
78   #define CYTHON_USE_TYPE_SLOTS 0
79   #undef CYTHON_USE_PYTYPE_LOOKUP
80   #define CYTHON_USE_PYTYPE_LOOKUP 0
81   #if PY_VERSION_HEX < 0x03050000
82     #undef CYTHON_USE_ASYNC_SLOTS
83     #define CYTHON_USE_ASYNC_SLOTS 0
84   #elif !defined(CYTHON_USE_ASYNC_SLOTS)
85     #define CYTHON_USE_ASYNC_SLOTS 1
86   #endif
87   #undef CYTHON_USE_PYLIST_INTERNALS
88   #define CYTHON_USE_PYLIST_INTERNALS 0
89   #undef CYTHON_USE_UNICODE_INTERNALS
90   #define CYTHON_USE_UNICODE_INTERNALS 0
91   #undef CYTHON_USE_UNICODE_WRITER
92   #define CYTHON_USE_UNICODE_WRITER 0
93   #undef CYTHON_USE_PYLONG_INTERNALS
94   #define CYTHON_USE_PYLONG_INTERNALS 0
95   #undef CYTHON_AVOID_BORROWED_REFS
96   #define CYTHON_AVOID_BORROWED_REFS 1
97   #undef CYTHON_ASSUME_SAFE_MACROS
98   #define CYTHON_ASSUME_SAFE_MACROS 0
99   #undef CYTHON_UNPACK_METHODS
100   #define CYTHON_UNPACK_METHODS 0
101   #undef CYTHON_FAST_THREAD_STATE
102   #define CYTHON_FAST_THREAD_STATE 0
103   #undef CYTHON_FAST_PYCALL
104   #define CYTHON_FAST_PYCALL 0
105   #undef CYTHON_PEP489_MULTI_PHASE_INIT
106   #define CYTHON_PEP489_MULTI_PHASE_INIT 0
107   #undef CYTHON_USE_TP_FINALIZE
108   #define CYTHON_USE_TP_FINALIZE 0
109   #undef CYTHON_USE_DICT_VERSIONS
110   #define CYTHON_USE_DICT_VERSIONS 0
111   #undef CYTHON_USE_EXC_INFO_STACK
112   #define CYTHON_USE_EXC_INFO_STACK 0
113 #elif defined(PYSTON_VERSION)
114   #define CYTHON_COMPILING_IN_PYPY 0
115   #define CYTHON_COMPILING_IN_PYSTON 1
116   #define CYTHON_COMPILING_IN_CPYTHON 0
117   #ifndef CYTHON_USE_TYPE_SLOTS
118     #define CYTHON_USE_TYPE_SLOTS 1
119   #endif
120   #undef CYTHON_USE_PYTYPE_LOOKUP
121   #define CYTHON_USE_PYTYPE_LOOKUP 0
122   #undef CYTHON_USE_ASYNC_SLOTS
123   #define CYTHON_USE_ASYNC_SLOTS 0
124   #undef CYTHON_USE_PYLIST_INTERNALS
125   #define CYTHON_USE_PYLIST_INTERNALS 0
126   #ifndef CYTHON_USE_UNICODE_INTERNALS
127     #define CYTHON_USE_UNICODE_INTERNALS 1
128   #endif
129   #undef CYTHON_USE_UNICODE_WRITER
130   #define CYTHON_USE_UNICODE_WRITER 0
131   #undef CYTHON_USE_PYLONG_INTERNALS
132   #define CYTHON_USE_PYLONG_INTERNALS 0
133   #ifndef CYTHON_AVOID_BORROWED_REFS
134     #define CYTHON_AVOID_BORROWED_REFS 0
135   #endif
136   #ifndef CYTHON_ASSUME_SAFE_MACROS
137     #define CYTHON_ASSUME_SAFE_MACROS 1
138   #endif
139   #ifndef CYTHON_UNPACK_METHODS
140     #define CYTHON_UNPACK_METHODS 1
141   #endif
142   #undef CYTHON_FAST_THREAD_STATE
143   #define CYTHON_FAST_THREAD_STATE 0
144   #undef CYTHON_FAST_PYCALL
145   #define CYTHON_FAST_PYCALL 0
146   #undef CYTHON_PEP489_MULTI_PHASE_INIT
147   #define CYTHON_PEP489_MULTI_PHASE_INIT 0
148   #undef CYTHON_USE_TP_FINALIZE
149   #define CYTHON_USE_TP_FINALIZE 0
150   #undef CYTHON_USE_DICT_VERSIONS
151   #define CYTHON_USE_DICT_VERSIONS 0
152   #undef CYTHON_USE_EXC_INFO_STACK
153   #define CYTHON_USE_EXC_INFO_STACK 0
154 #else
155   #define CYTHON_COMPILING_IN_PYPY 0
156   #define CYTHON_COMPILING_IN_PYSTON 0
157   #define CYTHON_COMPILING_IN_CPYTHON 1
158   #ifndef CYTHON_USE_TYPE_SLOTS
159     #define CYTHON_USE_TYPE_SLOTS 1
160   #endif
161   #if PY_VERSION_HEX < 0x02070000
162     #undef CYTHON_USE_PYTYPE_LOOKUP
163     #define CYTHON_USE_PYTYPE_LOOKUP 0
164   #elif !defined(CYTHON_USE_PYTYPE_LOOKUP)
165     #define CYTHON_USE_PYTYPE_LOOKUP 1
166   #endif
167   #if PY_MAJOR_VERSION < 3
168     #undef CYTHON_USE_ASYNC_SLOTS
169     #define CYTHON_USE_ASYNC_SLOTS 0
170   #elif !defined(CYTHON_USE_ASYNC_SLOTS)
171     #define CYTHON_USE_ASYNC_SLOTS 1
172   #endif
173   #if PY_VERSION_HEX < 0x02070000
174     #undef CYTHON_USE_PYLONG_INTERNALS
175     #define CYTHON_USE_PYLONG_INTERNALS 0
176   #elif !defined(CYTHON_USE_PYLONG_INTERNALS)
177     #define CYTHON_USE_PYLONG_INTERNALS 1
178   #endif
179   #ifndef CYTHON_USE_PYLIST_INTERNALS
180     #define CYTHON_USE_PYLIST_INTERNALS 1
181   #endif
182   #ifndef CYTHON_USE_UNICODE_INTERNALS
183     #define CYTHON_USE_UNICODE_INTERNALS 1
184   #endif
185   #if PY_VERSION_HEX < 0x030300F0
186     #undef CYTHON_USE_UNICODE_WRITER
187     #define CYTHON_USE_UNICODE_WRITER 0
188   #elif !defined(CYTHON_USE_UNICODE_WRITER)
189     #define CYTHON_USE_UNICODE_WRITER 1
190   #endif
191   #ifndef CYTHON_AVOID_BORROWED_REFS
192     #define CYTHON_AVOID_BORROWED_REFS 0
193   #endif
194   #ifndef CYTHON_ASSUME_SAFE_MACROS
195     #define CYTHON_ASSUME_SAFE_MACROS 1
196   #endif
197   #ifndef CYTHON_UNPACK_METHODS
198     #define CYTHON_UNPACK_METHODS 1
199   #endif
200   #ifndef CYTHON_FAST_THREAD_STATE
201     #define CYTHON_FAST_THREAD_STATE 1
202   #endif
203   #ifndef CYTHON_FAST_PYCALL
204     #define CYTHON_FAST_PYCALL 1
205   #endif
206   #ifndef CYTHON_PEP489_MULTI_PHASE_INIT
207     #define CYTHON_PEP489_MULTI_PHASE_INIT (PY_VERSION_HEX >= 0x03050000)
208   #endif
209   #ifndef CYTHON_USE_TP_FINALIZE
210     #define CYTHON_USE_TP_FINALIZE (PY_VERSION_HEX >= 0x030400a1)
211   #endif
212   #ifndef CYTHON_USE_DICT_VERSIONS
213     #define CYTHON_USE_DICT_VERSIONS (PY_VERSION_HEX >= 0x030600B1)
214   #endif
215   #ifndef CYTHON_USE_EXC_INFO_STACK
216     #define CYTHON_USE_EXC_INFO_STACK (PY_VERSION_HEX >= 0x030700A3)
217   #endif
218 #endif
219 #if !defined(CYTHON_FAST_PYCCALL)
220 #define CYTHON_FAST_PYCCALL  (CYTHON_FAST_PYCALL && PY_VERSION_HEX >= 0x030600B1)
221 #endif
222 #if CYTHON_USE_PYLONG_INTERNALS
223   #include "longintrepr.h"
224   #undef SHIFT
225   #undef BASE
226   #undef MASK
227   #ifdef SIZEOF_VOID_P
228     enum { __pyx_check_sizeof_voidp = 1 / (int)(SIZEOF_VOID_P == sizeof(void*)) };
229   #endif
230 #endif
231 #ifndef __has_attribute
232   #define __has_attribute(x) 0
233 #endif
234 #ifndef __has_cpp_attribute
235   #define __has_cpp_attribute(x) 0
236 #endif
237 #ifndef CYTHON_RESTRICT
238   #if defined(__GNUC__)
239     #define CYTHON_RESTRICT __restrict__
240   #elif defined(_MSC_VER) && _MSC_VER >= 1400
241     #define CYTHON_RESTRICT __restrict
242   #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
243     #define CYTHON_RESTRICT restrict
244   #else
245     #define CYTHON_RESTRICT
246   #endif
247 #endif
248 #ifndef CYTHON_UNUSED
249 # if defined(__GNUC__)
250 #   if !(defined(__cplusplus)) || (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4))
251 #     define CYTHON_UNUSED __attribute__ ((__unused__))
252 #   else
253 #     define CYTHON_UNUSED
254 #   endif
255 # elif defined(__ICC) || (defined(__INTEL_COMPILER) && !defined(_MSC_VER))
256 #   define CYTHON_UNUSED __attribute__ ((__unused__))
257 # else
258 #   define CYTHON_UNUSED
259 # endif
260 #endif
261 #ifndef CYTHON_MAYBE_UNUSED_VAR
262 #  if defined(__cplusplus)
CYTHON_MAYBE_UNUSED_VAR(const T &)263      template<class T> void CYTHON_MAYBE_UNUSED_VAR( const T& ) { }
264 #  else
265 #    define CYTHON_MAYBE_UNUSED_VAR(x) (void)(x)
266 #  endif
267 #endif
268 #ifndef CYTHON_NCP_UNUSED
269 # if CYTHON_COMPILING_IN_CPYTHON
270 #  define CYTHON_NCP_UNUSED
271 # else
272 #  define CYTHON_NCP_UNUSED CYTHON_UNUSED
273 # endif
274 #endif
275 #define __Pyx_void_to_None(void_result) ((void)(void_result), Py_INCREF(Py_None), Py_None)
276 #ifdef _MSC_VER
277     #ifndef _MSC_STDINT_H_
278         #if _MSC_VER < 1300
279            typedef unsigned char     uint8_t;
280            typedef unsigned int      uint32_t;
281         #else
282            typedef unsigned __int8   uint8_t;
283            typedef unsigned __int32  uint32_t;
284         #endif
285     #endif
286 #else
287    #include <stdint.h>
288 #endif
289 #ifndef CYTHON_FALLTHROUGH
290   #if defined(__cplusplus) && __cplusplus >= 201103L
291     #if __has_cpp_attribute(fallthrough)
292       #define CYTHON_FALLTHROUGH [[fallthrough]]
293     #elif __has_cpp_attribute(clang::fallthrough)
294       #define CYTHON_FALLTHROUGH [[clang::fallthrough]]
295     #elif __has_cpp_attribute(gnu::fallthrough)
296       #define CYTHON_FALLTHROUGH [[gnu::fallthrough]]
297     #endif
298   #endif
299   #ifndef CYTHON_FALLTHROUGH
300     #if __has_attribute(fallthrough)
301       #define CYTHON_FALLTHROUGH __attribute__((fallthrough))
302     #else
303       #define CYTHON_FALLTHROUGH
304     #endif
305   #endif
306   #if defined(__clang__ ) && defined(__apple_build_version__)
307     #if __apple_build_version__ < 7000000
308       #undef  CYTHON_FALLTHROUGH
309       #define CYTHON_FALLTHROUGH
310     #endif
311   #endif
312 #endif
313 
314 #ifndef __cplusplus
315   #error "Cython files generated with the C++ option must be compiled with a C++ compiler."
316 #endif
317 #ifndef CYTHON_INLINE
318   #if defined(__clang__)
319     #define CYTHON_INLINE __inline__ __attribute__ ((__unused__))
320   #else
321     #define CYTHON_INLINE inline
322   #endif
323 #endif
324 template<typename T>
__Pyx_call_destructor(T & x)325 void __Pyx_call_destructor(T& x) {
326     x.~T();
327 }
328 template<typename T>
329 class __Pyx_FakeReference {
330   public:
__Pyx_FakeReference()331     __Pyx_FakeReference() : ptr(NULL) { }
__Pyx_FakeReference(const T & ref)332     __Pyx_FakeReference(const T& ref) : ptr(const_cast<T*>(&ref)) { }
operator ->()333     T *operator->() { return ptr; }
operator &()334     T *operator&() { return ptr; }
operator T&()335     operator T&() { return *ptr; }
operator ==(U other)336     template<typename U> bool operator ==(U other) { return *ptr == other; }
operator !=(U other)337     template<typename U> bool operator !=(U other) { return *ptr != other; }
338   private:
339     T *ptr;
340 };
341 
342 #if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX < 0x02070600 && !defined(Py_OptimizeFlag)
343   #define Py_OptimizeFlag 0
344 #endif
345 #define __PYX_BUILD_PY_SSIZE_T "n"
346 #define CYTHON_FORMAT_SSIZE_T "z"
347 #if PY_MAJOR_VERSION < 3
348   #define __Pyx_BUILTIN_MODULE_NAME "__builtin__"
349   #define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)\
350           PyCode_New(a+k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)
351   #define __Pyx_DefaultClassType PyClass_Type
352 #else
353   #define __Pyx_BUILTIN_MODULE_NAME "builtins"
354 #if PY_VERSION_HEX >= 0x030800A4 && PY_VERSION_HEX < 0x030800B2
355   #define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)\
356           PyCode_New(a, 0, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)
357 #else
358   #define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)\
359           PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)
360 #endif
361   #define __Pyx_DefaultClassType PyType_Type
362 #endif
363 #ifndef Py_TPFLAGS_CHECKTYPES
364   #define Py_TPFLAGS_CHECKTYPES 0
365 #endif
366 #ifndef Py_TPFLAGS_HAVE_INDEX
367   #define Py_TPFLAGS_HAVE_INDEX 0
368 #endif
369 #ifndef Py_TPFLAGS_HAVE_NEWBUFFER
370   #define Py_TPFLAGS_HAVE_NEWBUFFER 0
371 #endif
372 #ifndef Py_TPFLAGS_HAVE_FINALIZE
373   #define Py_TPFLAGS_HAVE_FINALIZE 0
374 #endif
375 #ifndef METH_STACKLESS
376   #define METH_STACKLESS 0
377 #endif
378 #if PY_VERSION_HEX <= 0x030700A3 || !defined(METH_FASTCALL)
379   #ifndef METH_FASTCALL
380      #define METH_FASTCALL 0x80
381   #endif
382   typedef PyObject *(*__Pyx_PyCFunctionFast) (PyObject *self, PyObject *const *args, Py_ssize_t nargs);
383   typedef PyObject *(*__Pyx_PyCFunctionFastWithKeywords) (PyObject *self, PyObject *const *args,
384                                                           Py_ssize_t nargs, PyObject *kwnames);
385 #else
386   #define __Pyx_PyCFunctionFast _PyCFunctionFast
387   #define __Pyx_PyCFunctionFastWithKeywords _PyCFunctionFastWithKeywords
388 #endif
389 #if CYTHON_FAST_PYCCALL
390 #define __Pyx_PyFastCFunction_Check(func)\
391     ((PyCFunction_Check(func) && (METH_FASTCALL == (PyCFunction_GET_FLAGS(func) & ~(METH_CLASS | METH_STATIC | METH_COEXIST | METH_KEYWORDS | METH_STACKLESS)))))
392 #else
393 #define __Pyx_PyFastCFunction_Check(func) 0
394 #endif
395 #if CYTHON_COMPILING_IN_PYPY && !defined(PyObject_Malloc)
396   #define PyObject_Malloc(s)   PyMem_Malloc(s)
397   #define PyObject_Free(p)     PyMem_Free(p)
398   #define PyObject_Realloc(p)  PyMem_Realloc(p)
399 #endif
400 #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX < 0x030400A1
401   #define PyMem_RawMalloc(n)           PyMem_Malloc(n)
402   #define PyMem_RawRealloc(p, n)       PyMem_Realloc(p, n)
403   #define PyMem_RawFree(p)             PyMem_Free(p)
404 #endif
405 #if CYTHON_COMPILING_IN_PYSTON
406   #define __Pyx_PyCode_HasFreeVars(co)  PyCode_HasFreeVars(co)
407   #define __Pyx_PyFrame_SetLineNumber(frame, lineno) PyFrame_SetLineNumber(frame, lineno)
408 #else
409   #define __Pyx_PyCode_HasFreeVars(co)  (PyCode_GetNumFree(co) > 0)
410   #define __Pyx_PyFrame_SetLineNumber(frame, lineno)  (frame)->f_lineno = (lineno)
411 #endif
412 #if !CYTHON_FAST_THREAD_STATE || PY_VERSION_HEX < 0x02070000
413   #define __Pyx_PyThreadState_Current PyThreadState_GET()
414 #elif PY_VERSION_HEX >= 0x03060000
415   #define __Pyx_PyThreadState_Current _PyThreadState_UncheckedGet()
416 #elif PY_VERSION_HEX >= 0x03000000
417   #define __Pyx_PyThreadState_Current PyThreadState_GET()
418 #else
419   #define __Pyx_PyThreadState_Current _PyThreadState_Current
420 #endif
421 #if PY_VERSION_HEX < 0x030700A2 && !defined(PyThread_tss_create) && !defined(Py_tss_NEEDS_INIT)
422 #include "pythread.h"
423 #define Py_tss_NEEDS_INIT 0
424 typedef int Py_tss_t;
PyThread_tss_create(Py_tss_t * key)425 static CYTHON_INLINE int PyThread_tss_create(Py_tss_t *key) {
426   *key = PyThread_create_key();
427   return 0;
428 }
PyThread_tss_alloc(void)429 static CYTHON_INLINE Py_tss_t * PyThread_tss_alloc(void) {
430   Py_tss_t *key = (Py_tss_t *)PyObject_Malloc(sizeof(Py_tss_t));
431   *key = Py_tss_NEEDS_INIT;
432   return key;
433 }
PyThread_tss_free(Py_tss_t * key)434 static CYTHON_INLINE void PyThread_tss_free(Py_tss_t *key) {
435   PyObject_Free(key);
436 }
PyThread_tss_is_created(Py_tss_t * key)437 static CYTHON_INLINE int PyThread_tss_is_created(Py_tss_t *key) {
438   return *key != Py_tss_NEEDS_INIT;
439 }
PyThread_tss_delete(Py_tss_t * key)440 static CYTHON_INLINE void PyThread_tss_delete(Py_tss_t *key) {
441   PyThread_delete_key(*key);
442   *key = Py_tss_NEEDS_INIT;
443 }
PyThread_tss_set(Py_tss_t * key,void * value)444 static CYTHON_INLINE int PyThread_tss_set(Py_tss_t *key, void *value) {
445   return PyThread_set_key_value(*key, value);
446 }
PyThread_tss_get(Py_tss_t * key)447 static CYTHON_INLINE void * PyThread_tss_get(Py_tss_t *key) {
448   return PyThread_get_key_value(*key);
449 }
450 #endif
451 #if CYTHON_COMPILING_IN_CPYTHON || defined(_PyDict_NewPresized)
452 #define __Pyx_PyDict_NewPresized(n)  ((n <= 8) ? PyDict_New() : _PyDict_NewPresized(n))
453 #else
454 #define __Pyx_PyDict_NewPresized(n)  PyDict_New()
455 #endif
456 #if PY_MAJOR_VERSION >= 3 || CYTHON_FUTURE_DIVISION
457   #define __Pyx_PyNumber_Divide(x,y)         PyNumber_TrueDivide(x,y)
458   #define __Pyx_PyNumber_InPlaceDivide(x,y)  PyNumber_InPlaceTrueDivide(x,y)
459 #else
460   #define __Pyx_PyNumber_Divide(x,y)         PyNumber_Divide(x,y)
461   #define __Pyx_PyNumber_InPlaceDivide(x,y)  PyNumber_InPlaceDivide(x,y)
462 #endif
463 #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030500A1 && CYTHON_USE_UNICODE_INTERNALS
464 #define __Pyx_PyDict_GetItemStr(dict, name)  _PyDict_GetItem_KnownHash(dict, name, ((PyASCIIObject *) name)->hash)
465 #else
466 #define __Pyx_PyDict_GetItemStr(dict, name)  PyDict_GetItem(dict, name)
467 #endif
468 #if PY_VERSION_HEX > 0x03030000 && defined(PyUnicode_KIND)
469   #define CYTHON_PEP393_ENABLED 1
470   #define __Pyx_PyUnicode_READY(op)       (likely(PyUnicode_IS_READY(op)) ?\
471                                               0 : _PyUnicode_Ready((PyObject *)(op)))
472   #define __Pyx_PyUnicode_GET_LENGTH(u)   PyUnicode_GET_LENGTH(u)
473   #define __Pyx_PyUnicode_READ_CHAR(u, i) PyUnicode_READ_CHAR(u, i)
474   #define __Pyx_PyUnicode_MAX_CHAR_VALUE(u)   PyUnicode_MAX_CHAR_VALUE(u)
475   #define __Pyx_PyUnicode_KIND(u)         PyUnicode_KIND(u)
476   #define __Pyx_PyUnicode_DATA(u)         PyUnicode_DATA(u)
477   #define __Pyx_PyUnicode_READ(k, d, i)   PyUnicode_READ(k, d, i)
478   #define __Pyx_PyUnicode_WRITE(k, d, i, ch)  PyUnicode_WRITE(k, d, i, ch)
479   #if defined(PyUnicode_IS_READY) && defined(PyUnicode_GET_SIZE)
480   #define __Pyx_PyUnicode_IS_TRUE(u)      (0 != (likely(PyUnicode_IS_READY(u)) ? PyUnicode_GET_LENGTH(u) : PyUnicode_GET_SIZE(u)))
481   #else
482   #define __Pyx_PyUnicode_IS_TRUE(u)      (0 != PyUnicode_GET_LENGTH(u))
483   #endif
484 #else
485   #define CYTHON_PEP393_ENABLED 0
486   #define PyUnicode_1BYTE_KIND  1
487   #define PyUnicode_2BYTE_KIND  2
488   #define PyUnicode_4BYTE_KIND  4
489   #define __Pyx_PyUnicode_READY(op)       (0)
490   #define __Pyx_PyUnicode_GET_LENGTH(u)   PyUnicode_GET_SIZE(u)
491   #define __Pyx_PyUnicode_READ_CHAR(u, i) ((Py_UCS4)(PyUnicode_AS_UNICODE(u)[i]))
492   #define __Pyx_PyUnicode_MAX_CHAR_VALUE(u)   ((sizeof(Py_UNICODE) == 2) ? 65535 : 1114111)
493   #define __Pyx_PyUnicode_KIND(u)         (sizeof(Py_UNICODE))
494   #define __Pyx_PyUnicode_DATA(u)         ((void*)PyUnicode_AS_UNICODE(u))
495   #define __Pyx_PyUnicode_READ(k, d, i)   ((void)(k), (Py_UCS4)(((Py_UNICODE*)d)[i]))
496   #define __Pyx_PyUnicode_WRITE(k, d, i, ch)  (((void)(k)), ((Py_UNICODE*)d)[i] = ch)
497   #define __Pyx_PyUnicode_IS_TRUE(u)      (0 != PyUnicode_GET_SIZE(u))
498 #endif
499 #if CYTHON_COMPILING_IN_PYPY
500   #define __Pyx_PyUnicode_Concat(a, b)      PyNumber_Add(a, b)
501   #define __Pyx_PyUnicode_ConcatSafe(a, b)  PyNumber_Add(a, b)
502 #else
503   #define __Pyx_PyUnicode_Concat(a, b)      PyUnicode_Concat(a, b)
504   #define __Pyx_PyUnicode_ConcatSafe(a, b)  ((unlikely((a) == Py_None) || unlikely((b) == Py_None)) ?\
505       PyNumber_Add(a, b) : __Pyx_PyUnicode_Concat(a, b))
506 #endif
507 #if CYTHON_COMPILING_IN_PYPY && !defined(PyUnicode_Contains)
508   #define PyUnicode_Contains(u, s)  PySequence_Contains(u, s)
509 #endif
510 #if CYTHON_COMPILING_IN_PYPY && !defined(PyByteArray_Check)
511   #define PyByteArray_Check(obj)  PyObject_TypeCheck(obj, &PyByteArray_Type)
512 #endif
513 #if CYTHON_COMPILING_IN_PYPY && !defined(PyObject_Format)
514   #define PyObject_Format(obj, fmt)  PyObject_CallMethod(obj, "__format__", "O", fmt)
515 #endif
516 #define __Pyx_PyString_FormatSafe(a, b)   ((unlikely((a) == Py_None || (PyString_Check(b) && !PyString_CheckExact(b)))) ? PyNumber_Remainder(a, b) : __Pyx_PyString_Format(a, b))
517 #define __Pyx_PyUnicode_FormatSafe(a, b)  ((unlikely((a) == Py_None || (PyUnicode_Check(b) && !PyUnicode_CheckExact(b)))) ? PyNumber_Remainder(a, b) : PyUnicode_Format(a, b))
518 #if PY_MAJOR_VERSION >= 3
519   #define __Pyx_PyString_Format(a, b)  PyUnicode_Format(a, b)
520 #else
521   #define __Pyx_PyString_Format(a, b)  PyString_Format(a, b)
522 #endif
523 #if PY_MAJOR_VERSION < 3 && !defined(PyObject_ASCII)
524   #define PyObject_ASCII(o)            PyObject_Repr(o)
525 #endif
526 #if PY_MAJOR_VERSION >= 3
527   #define PyBaseString_Type            PyUnicode_Type
528   #define PyStringObject               PyUnicodeObject
529   #define PyString_Type                PyUnicode_Type
530   #define PyString_Check               PyUnicode_Check
531   #define PyString_CheckExact          PyUnicode_CheckExact
532 #ifndef PyObject_Unicode
533   #define PyObject_Unicode             PyObject_Str
534 #endif
535 #endif
536 #if PY_MAJOR_VERSION >= 3
537   #define __Pyx_PyBaseString_Check(obj) PyUnicode_Check(obj)
538   #define __Pyx_PyBaseString_CheckExact(obj) PyUnicode_CheckExact(obj)
539 #else
540   #define __Pyx_PyBaseString_Check(obj) (PyString_Check(obj) || PyUnicode_Check(obj))
541   #define __Pyx_PyBaseString_CheckExact(obj) (PyString_CheckExact(obj) || PyUnicode_CheckExact(obj))
542 #endif
543 #ifndef PySet_CheckExact
544   #define PySet_CheckExact(obj)        (Py_TYPE(obj) == &PySet_Type)
545 #endif
546 #if PY_VERSION_HEX >= 0x030900A4
547   #define __Pyx_SET_REFCNT(obj, refcnt) Py_SET_REFCNT(obj, refcnt)
548   #define __Pyx_SET_SIZE(obj, size) Py_SET_SIZE(obj, size)
549 #else
550   #define __Pyx_SET_REFCNT(obj, refcnt) Py_REFCNT(obj) = (refcnt)
551   #define __Pyx_SET_SIZE(obj, size) Py_SIZE(obj) = (size)
552 #endif
553 #if CYTHON_ASSUME_SAFE_MACROS
554   #define __Pyx_PySequence_SIZE(seq)  Py_SIZE(seq)
555 #else
556   #define __Pyx_PySequence_SIZE(seq)  PySequence_Size(seq)
557 #endif
558 #if PY_MAJOR_VERSION >= 3
559   #define PyIntObject                  PyLongObject
560   #define PyInt_Type                   PyLong_Type
561   #define PyInt_Check(op)              PyLong_Check(op)
562   #define PyInt_CheckExact(op)         PyLong_CheckExact(op)
563   #define PyInt_FromString             PyLong_FromString
564   #define PyInt_FromUnicode            PyLong_FromUnicode
565   #define PyInt_FromLong               PyLong_FromLong
566   #define PyInt_FromSize_t             PyLong_FromSize_t
567   #define PyInt_FromSsize_t            PyLong_FromSsize_t
568   #define PyInt_AsLong                 PyLong_AsLong
569   #define PyInt_AS_LONG                PyLong_AS_LONG
570   #define PyInt_AsSsize_t              PyLong_AsSsize_t
571   #define PyInt_AsUnsignedLongMask     PyLong_AsUnsignedLongMask
572   #define PyInt_AsUnsignedLongLongMask PyLong_AsUnsignedLongLongMask
573   #define PyNumber_Int                 PyNumber_Long
574 #endif
575 #if PY_MAJOR_VERSION >= 3
576   #define PyBoolObject                 PyLongObject
577 #endif
578 #if PY_MAJOR_VERSION >= 3 && CYTHON_COMPILING_IN_PYPY
579   #ifndef PyUnicode_InternFromString
580     #define PyUnicode_InternFromString(s) PyUnicode_FromString(s)
581   #endif
582 #endif
583 #if PY_VERSION_HEX < 0x030200A4
584   typedef long Py_hash_t;
585   #define __Pyx_PyInt_FromHash_t PyInt_FromLong
586   #define __Pyx_PyInt_AsHash_t   PyInt_AsLong
587 #else
588   #define __Pyx_PyInt_FromHash_t PyInt_FromSsize_t
589   #define __Pyx_PyInt_AsHash_t   PyInt_AsSsize_t
590 #endif
591 #if PY_MAJOR_VERSION >= 3
592   #define __Pyx_PyMethod_New(func, self, klass) ((self) ? ((void)(klass), PyMethod_New(func, self)) : __Pyx_NewRef(func))
593 #else
594   #define __Pyx_PyMethod_New(func, self, klass) PyMethod_New(func, self, klass)
595 #endif
596 #if CYTHON_USE_ASYNC_SLOTS
597   #if PY_VERSION_HEX >= 0x030500B1
598     #define __Pyx_PyAsyncMethodsStruct PyAsyncMethods
599     #define __Pyx_PyType_AsAsync(obj) (Py_TYPE(obj)->tp_as_async)
600   #else
601     #define __Pyx_PyType_AsAsync(obj) ((__Pyx_PyAsyncMethodsStruct*) (Py_TYPE(obj)->tp_reserved))
602   #endif
603 #else
604   #define __Pyx_PyType_AsAsync(obj) NULL
605 #endif
606 #ifndef __Pyx_PyAsyncMethodsStruct
607     typedef struct {
608         unaryfunc am_await;
609         unaryfunc am_aiter;
610         unaryfunc am_anext;
611     } __Pyx_PyAsyncMethodsStruct;
612 #endif
613 
614 #if defined(WIN32) || defined(MS_WINDOWS)
615   #define _USE_MATH_DEFINES
616 #endif
617 #include <math.h>
618 #ifdef NAN
619 #define __PYX_NAN() ((float) NAN)
620 #else
__PYX_NAN()621 static CYTHON_INLINE float __PYX_NAN() {
622   float value;
623   memset(&value, 0xFF, sizeof(value));
624   return value;
625 }
626 #endif
627 #if defined(__CYGWIN__) && defined(_LDBL_EQ_DBL)
628 #define __Pyx_truncl trunc
629 #else
630 #define __Pyx_truncl truncl
631 #endif
632 
633 #define __PYX_MARK_ERR_POS(f_index, lineno) \
634     { __pyx_filename = __pyx_f[f_index]; (void)__pyx_filename; __pyx_lineno = lineno; (void)__pyx_lineno; __pyx_clineno = __LINE__; (void)__pyx_clineno; }
635 #define __PYX_ERR(f_index, lineno, Ln_error) \
636     { __PYX_MARK_ERR_POS(f_index, lineno) goto Ln_error; }
637 
638 #ifndef __PYX_EXTERN_C
639   #ifdef __cplusplus
640     #define __PYX_EXTERN_C extern "C"
641   #else
642     #define __PYX_EXTERN_C extern
643   #endif
644 #endif
645 
646 #define __PYX_HAVE__qutip__control__cy_grape
647 #define __PYX_HAVE_API__qutip__control__cy_grape
648 /* Early includes */
649 #include <string.h>
650 #include <stdio.h>
651 #include "numpy/arrayobject.h"
652 #include "numpy/ufuncobject.h"
653 
654     /* NumPy API declarations from "numpy/__init__.pxd" */
655 
656 #include <math.h>
657 #ifdef _OPENMP
658 #include <omp.h>
659 #endif /* _OPENMP */
660 
661 #if defined(PYREX_WITHOUT_ASSERTIONS) && !defined(CYTHON_WITHOUT_ASSERTIONS)
662 #define CYTHON_WITHOUT_ASSERTIONS
663 #endif
664 
665 typedef struct {PyObject **p; const char *s; const Py_ssize_t n; const char* encoding;
666                 const char is_unicode; const char is_str; const char intern; } __Pyx_StringTabEntry;
667 
668 #define __PYX_DEFAULT_STRING_ENCODING_IS_ASCII 0
669 #define __PYX_DEFAULT_STRING_ENCODING_IS_UTF8 0
670 #define __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT (PY_MAJOR_VERSION >= 3 && __PYX_DEFAULT_STRING_ENCODING_IS_UTF8)
671 #define __PYX_DEFAULT_STRING_ENCODING ""
672 #define __Pyx_PyObject_FromString __Pyx_PyBytes_FromString
673 #define __Pyx_PyObject_FromStringAndSize __Pyx_PyBytes_FromStringAndSize
674 #define __Pyx_uchar_cast(c) ((unsigned char)c)
675 #define __Pyx_long_cast(x) ((long)x)
676 #define __Pyx_fits_Py_ssize_t(v, type, is_signed)  (\
677     (sizeof(type) < sizeof(Py_ssize_t))  ||\
678     (sizeof(type) > sizeof(Py_ssize_t) &&\
679           likely(v < (type)PY_SSIZE_T_MAX ||\
680                  v == (type)PY_SSIZE_T_MAX)  &&\
681           (!is_signed || likely(v > (type)PY_SSIZE_T_MIN ||\
682                                 v == (type)PY_SSIZE_T_MIN)))  ||\
683     (sizeof(type) == sizeof(Py_ssize_t) &&\
684           (is_signed || likely(v < (type)PY_SSIZE_T_MAX ||\
685                                v == (type)PY_SSIZE_T_MAX)))  )
__Pyx_is_valid_index(Py_ssize_t i,Py_ssize_t limit)686 static CYTHON_INLINE int __Pyx_is_valid_index(Py_ssize_t i, Py_ssize_t limit) {
687     return (size_t) i < (size_t) limit;
688 }
689 #if defined (__cplusplus) && __cplusplus >= 201103L
690     #include <cstdlib>
691     #define __Pyx_sst_abs(value) std::abs(value)
692 #elif SIZEOF_INT >= SIZEOF_SIZE_T
693     #define __Pyx_sst_abs(value) abs(value)
694 #elif SIZEOF_LONG >= SIZEOF_SIZE_T
695     #define __Pyx_sst_abs(value) labs(value)
696 #elif defined (_MSC_VER)
697     #define __Pyx_sst_abs(value) ((Py_ssize_t)_abs64(value))
698 #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
699     #define __Pyx_sst_abs(value) llabs(value)
700 #elif defined (__GNUC__)
701     #define __Pyx_sst_abs(value) __builtin_llabs(value)
702 #else
703     #define __Pyx_sst_abs(value) ((value<0) ? -value : value)
704 #endif
705 static CYTHON_INLINE const char* __Pyx_PyObject_AsString(PyObject*);
706 static CYTHON_INLINE const char* __Pyx_PyObject_AsStringAndSize(PyObject*, Py_ssize_t* length);
707 #define __Pyx_PyByteArray_FromString(s) PyByteArray_FromStringAndSize((const char*)s, strlen((const char*)s))
708 #define __Pyx_PyByteArray_FromStringAndSize(s, l) PyByteArray_FromStringAndSize((const char*)s, l)
709 #define __Pyx_PyBytes_FromString        PyBytes_FromString
710 #define __Pyx_PyBytes_FromStringAndSize PyBytes_FromStringAndSize
711 static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(const char*);
712 #if PY_MAJOR_VERSION < 3
713     #define __Pyx_PyStr_FromString        __Pyx_PyBytes_FromString
714     #define __Pyx_PyStr_FromStringAndSize __Pyx_PyBytes_FromStringAndSize
715 #else
716     #define __Pyx_PyStr_FromString        __Pyx_PyUnicode_FromString
717     #define __Pyx_PyStr_FromStringAndSize __Pyx_PyUnicode_FromStringAndSize
718 #endif
719 #define __Pyx_PyBytes_AsWritableString(s)     ((char*) PyBytes_AS_STRING(s))
720 #define __Pyx_PyBytes_AsWritableSString(s)    ((signed char*) PyBytes_AS_STRING(s))
721 #define __Pyx_PyBytes_AsWritableUString(s)    ((unsigned char*) PyBytes_AS_STRING(s))
722 #define __Pyx_PyBytes_AsString(s)     ((const char*) PyBytes_AS_STRING(s))
723 #define __Pyx_PyBytes_AsSString(s)    ((const signed char*) PyBytes_AS_STRING(s))
724 #define __Pyx_PyBytes_AsUString(s)    ((const unsigned char*) PyBytes_AS_STRING(s))
725 #define __Pyx_PyObject_AsWritableString(s)    ((char*) __Pyx_PyObject_AsString(s))
726 #define __Pyx_PyObject_AsWritableSString(s)    ((signed char*) __Pyx_PyObject_AsString(s))
727 #define __Pyx_PyObject_AsWritableUString(s)    ((unsigned char*) __Pyx_PyObject_AsString(s))
728 #define __Pyx_PyObject_AsSString(s)    ((const signed char*) __Pyx_PyObject_AsString(s))
729 #define __Pyx_PyObject_AsUString(s)    ((const unsigned char*) __Pyx_PyObject_AsString(s))
730 #define __Pyx_PyObject_FromCString(s)  __Pyx_PyObject_FromString((const char*)s)
731 #define __Pyx_PyBytes_FromCString(s)   __Pyx_PyBytes_FromString((const char*)s)
732 #define __Pyx_PyByteArray_FromCString(s)   __Pyx_PyByteArray_FromString((const char*)s)
733 #define __Pyx_PyStr_FromCString(s)     __Pyx_PyStr_FromString((const char*)s)
734 #define __Pyx_PyUnicode_FromCString(s) __Pyx_PyUnicode_FromString((const char*)s)
__Pyx_Py_UNICODE_strlen(const Py_UNICODE * u)735 static CYTHON_INLINE size_t __Pyx_Py_UNICODE_strlen(const Py_UNICODE *u) {
736     const Py_UNICODE *u_end = u;
737     while (*u_end++) ;
738     return (size_t)(u_end - u - 1);
739 }
740 #define __Pyx_PyUnicode_FromUnicode(u)       PyUnicode_FromUnicode(u, __Pyx_Py_UNICODE_strlen(u))
741 #define __Pyx_PyUnicode_FromUnicodeAndLength PyUnicode_FromUnicode
742 #define __Pyx_PyUnicode_AsUnicode            PyUnicode_AsUnicode
743 #define __Pyx_NewRef(obj) (Py_INCREF(obj), obj)
744 #define __Pyx_Owned_Py_None(b) __Pyx_NewRef(Py_None)
745 static CYTHON_INLINE PyObject * __Pyx_PyBool_FromLong(long b);
746 static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject*);
747 static CYTHON_INLINE int __Pyx_PyObject_IsTrueAndDecref(PyObject*);
748 static CYTHON_INLINE PyObject* __Pyx_PyNumber_IntOrLong(PyObject* x);
749 #define __Pyx_PySequence_Tuple(obj)\
750     (likely(PyTuple_CheckExact(obj)) ? __Pyx_NewRef(obj) : PySequence_Tuple(obj))
751 static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject*);
752 static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t);
753 #if CYTHON_ASSUME_SAFE_MACROS
754 #define __pyx_PyFloat_AsDouble(x) (PyFloat_CheckExact(x) ? PyFloat_AS_DOUBLE(x) : PyFloat_AsDouble(x))
755 #else
756 #define __pyx_PyFloat_AsDouble(x) PyFloat_AsDouble(x)
757 #endif
758 #define __pyx_PyFloat_AsFloat(x) ((float) __pyx_PyFloat_AsDouble(x))
759 #if PY_MAJOR_VERSION >= 3
760 #define __Pyx_PyNumber_Int(x) (PyLong_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Long(x))
761 #else
762 #define __Pyx_PyNumber_Int(x) (PyInt_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Int(x))
763 #endif
764 #define __Pyx_PyNumber_Float(x) (PyFloat_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Float(x))
765 #if PY_MAJOR_VERSION < 3 && __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
766 static int __Pyx_sys_getdefaultencoding_not_ascii;
__Pyx_init_sys_getdefaultencoding_params(void)767 static int __Pyx_init_sys_getdefaultencoding_params(void) {
768     PyObject* sys;
769     PyObject* default_encoding = NULL;
770     PyObject* ascii_chars_u = NULL;
771     PyObject* ascii_chars_b = NULL;
772     const char* default_encoding_c;
773     sys = PyImport_ImportModule("sys");
774     if (!sys) goto bad;
775     default_encoding = PyObject_CallMethod(sys, (char*) "getdefaultencoding", NULL);
776     Py_DECREF(sys);
777     if (!default_encoding) goto bad;
778     default_encoding_c = PyBytes_AsString(default_encoding);
779     if (!default_encoding_c) goto bad;
780     if (strcmp(default_encoding_c, "ascii") == 0) {
781         __Pyx_sys_getdefaultencoding_not_ascii = 0;
782     } else {
783         char ascii_chars[128];
784         int c;
785         for (c = 0; c < 128; c++) {
786             ascii_chars[c] = c;
787         }
788         __Pyx_sys_getdefaultencoding_not_ascii = 1;
789         ascii_chars_u = PyUnicode_DecodeASCII(ascii_chars, 128, NULL);
790         if (!ascii_chars_u) goto bad;
791         ascii_chars_b = PyUnicode_AsEncodedString(ascii_chars_u, default_encoding_c, NULL);
792         if (!ascii_chars_b || !PyBytes_Check(ascii_chars_b) || memcmp(ascii_chars, PyBytes_AS_STRING(ascii_chars_b), 128) != 0) {
793             PyErr_Format(
794                 PyExc_ValueError,
795                 "This module compiled with c_string_encoding=ascii, but default encoding '%.200s' is not a superset of ascii.",
796                 default_encoding_c);
797             goto bad;
798         }
799         Py_DECREF(ascii_chars_u);
800         Py_DECREF(ascii_chars_b);
801     }
802     Py_DECREF(default_encoding);
803     return 0;
804 bad:
805     Py_XDECREF(default_encoding);
806     Py_XDECREF(ascii_chars_u);
807     Py_XDECREF(ascii_chars_b);
808     return -1;
809 }
810 #endif
811 #if __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT && PY_MAJOR_VERSION >= 3
812 #define __Pyx_PyUnicode_FromStringAndSize(c_str, size) PyUnicode_DecodeUTF8(c_str, size, NULL)
813 #else
814 #define __Pyx_PyUnicode_FromStringAndSize(c_str, size) PyUnicode_Decode(c_str, size, __PYX_DEFAULT_STRING_ENCODING, NULL)
815 #if __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT
816 static char* __PYX_DEFAULT_STRING_ENCODING;
__Pyx_init_sys_getdefaultencoding_params(void)817 static int __Pyx_init_sys_getdefaultencoding_params(void) {
818     PyObject* sys;
819     PyObject* default_encoding = NULL;
820     char* default_encoding_c;
821     sys = PyImport_ImportModule("sys");
822     if (!sys) goto bad;
823     default_encoding = PyObject_CallMethod(sys, (char*) (const char*) "getdefaultencoding", NULL);
824     Py_DECREF(sys);
825     if (!default_encoding) goto bad;
826     default_encoding_c = PyBytes_AsString(default_encoding);
827     if (!default_encoding_c) goto bad;
828     __PYX_DEFAULT_STRING_ENCODING = (char*) malloc(strlen(default_encoding_c) + 1);
829     if (!__PYX_DEFAULT_STRING_ENCODING) goto bad;
830     strcpy(__PYX_DEFAULT_STRING_ENCODING, default_encoding_c);
831     Py_DECREF(default_encoding);
832     return 0;
833 bad:
834     Py_XDECREF(default_encoding);
835     return -1;
836 }
837 #endif
838 #endif
839 
840 
841 /* Test for GCC > 2.95 */
842 #if defined(__GNUC__)     && (__GNUC__ > 2 || (__GNUC__ == 2 && (__GNUC_MINOR__ > 95)))
843   #define likely(x)   __builtin_expect(!!(x), 1)
844   #define unlikely(x) __builtin_expect(!!(x), 0)
845 #else /* !__GNUC__ or GCC < 2.95 */
846   #define likely(x)   (x)
847   #define unlikely(x) (x)
848 #endif /* __GNUC__ */
__Pyx_pretend_to_initialize(void * ptr)849 static CYTHON_INLINE void __Pyx_pretend_to_initialize(void* ptr) { (void)ptr; }
850 
851 static PyObject *__pyx_m = NULL;
852 static PyObject *__pyx_d;
853 static PyObject *__pyx_b;
854 static PyObject *__pyx_cython_runtime = NULL;
855 static PyObject *__pyx_empty_tuple;
856 static PyObject *__pyx_empty_bytes;
857 static PyObject *__pyx_empty_unicode;
858 static int __pyx_lineno;
859 static int __pyx_clineno = 0;
860 static const char * __pyx_cfilenm= __FILE__;
861 static const char *__pyx_filename;
862 
863 /* Header.proto */
864 #if !defined(CYTHON_CCOMPLEX)
865   #if defined(__cplusplus)
866     #define CYTHON_CCOMPLEX 1
867   #elif defined(_Complex_I)
868     #define CYTHON_CCOMPLEX 1
869   #else
870     #define CYTHON_CCOMPLEX 0
871   #endif
872 #endif
873 #if CYTHON_CCOMPLEX
874   #ifdef __cplusplus
875     #include <complex>
876   #else
877     #include <complex.h>
878   #endif
879 #endif
880 #if CYTHON_CCOMPLEX && !defined(__cplusplus) && defined(__sun__) && defined(__GNUC__)
881   #undef _Complex_I
882   #define _Complex_I 1.0fj
883 #endif
884 
885 
886 static const char *__pyx_f[] = {
887   "qutip/control/cy_grape.pyx",
888   "__init__.pxd",
889   "type.pxd",
890 };
891 /* BufferFormatStructs.proto */
892 #define IS_UNSIGNED(type) (((type) -1) > 0)
893 struct __Pyx_StructField_;
894 #define __PYX_BUF_FLAGS_PACKED_STRUCT (1 << 0)
895 typedef struct {
896   const char* name;
897   struct __Pyx_StructField_* fields;
898   size_t size;
899   size_t arraysize[8];
900   int ndim;
901   char typegroup;
902   char is_unsigned;
903   int flags;
904 } __Pyx_TypeInfo;
905 typedef struct __Pyx_StructField_ {
906   __Pyx_TypeInfo* type;
907   const char* name;
908   size_t offset;
909 } __Pyx_StructField;
910 typedef struct {
911   __Pyx_StructField* field;
912   size_t parent_offset;
913 } __Pyx_BufFmt_StackElem;
914 typedef struct {
915   __Pyx_StructField root;
916   __Pyx_BufFmt_StackElem* head;
917   size_t fmt_offset;
918   size_t new_count, enc_count;
919   size_t struct_alignment;
920   int is_complex;
921   char enc_type;
922   char new_packmode;
923   char enc_packmode;
924   char is_valid_array;
925 } __Pyx_BufFmt_Context;
926 
927 
928 /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":689
929  * # in Cython to enable them only on the right systems.
930  *
931  * ctypedef npy_int8       int8_t             # <<<<<<<<<<<<<<
932  * ctypedef npy_int16      int16_t
933  * ctypedef npy_int32      int32_t
934  */
935 typedef npy_int8 __pyx_t_5numpy_int8_t;
936 
937 /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":690
938  *
939  * ctypedef npy_int8       int8_t
940  * ctypedef npy_int16      int16_t             # <<<<<<<<<<<<<<
941  * ctypedef npy_int32      int32_t
942  * ctypedef npy_int64      int64_t
943  */
944 typedef npy_int16 __pyx_t_5numpy_int16_t;
945 
946 /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":691
947  * ctypedef npy_int8       int8_t
948  * ctypedef npy_int16      int16_t
949  * ctypedef npy_int32      int32_t             # <<<<<<<<<<<<<<
950  * ctypedef npy_int64      int64_t
951  * #ctypedef npy_int96      int96_t
952  */
953 typedef npy_int32 __pyx_t_5numpy_int32_t;
954 
955 /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":692
956  * ctypedef npy_int16      int16_t
957  * ctypedef npy_int32      int32_t
958  * ctypedef npy_int64      int64_t             # <<<<<<<<<<<<<<
959  * #ctypedef npy_int96      int96_t
960  * #ctypedef npy_int128     int128_t
961  */
962 typedef npy_int64 __pyx_t_5numpy_int64_t;
963 
964 /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":696
965  * #ctypedef npy_int128     int128_t
966  *
967  * ctypedef npy_uint8      uint8_t             # <<<<<<<<<<<<<<
968  * ctypedef npy_uint16     uint16_t
969  * ctypedef npy_uint32     uint32_t
970  */
971 typedef npy_uint8 __pyx_t_5numpy_uint8_t;
972 
973 /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":697
974  *
975  * ctypedef npy_uint8      uint8_t
976  * ctypedef npy_uint16     uint16_t             # <<<<<<<<<<<<<<
977  * ctypedef npy_uint32     uint32_t
978  * ctypedef npy_uint64     uint64_t
979  */
980 typedef npy_uint16 __pyx_t_5numpy_uint16_t;
981 
982 /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":698
983  * ctypedef npy_uint8      uint8_t
984  * ctypedef npy_uint16     uint16_t
985  * ctypedef npy_uint32     uint32_t             # <<<<<<<<<<<<<<
986  * ctypedef npy_uint64     uint64_t
987  * #ctypedef npy_uint96     uint96_t
988  */
989 typedef npy_uint32 __pyx_t_5numpy_uint32_t;
990 
991 /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":699
992  * ctypedef npy_uint16     uint16_t
993  * ctypedef npy_uint32     uint32_t
994  * ctypedef npy_uint64     uint64_t             # <<<<<<<<<<<<<<
995  * #ctypedef npy_uint96     uint96_t
996  * #ctypedef npy_uint128    uint128_t
997  */
998 typedef npy_uint64 __pyx_t_5numpy_uint64_t;
999 
1000 /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":703
1001  * #ctypedef npy_uint128    uint128_t
1002  *
1003  * ctypedef npy_float32    float32_t             # <<<<<<<<<<<<<<
1004  * ctypedef npy_float64    float64_t
1005  * #ctypedef npy_float80    float80_t
1006  */
1007 typedef npy_float32 __pyx_t_5numpy_float32_t;
1008 
1009 /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":704
1010  *
1011  * ctypedef npy_float32    float32_t
1012  * ctypedef npy_float64    float64_t             # <<<<<<<<<<<<<<
1013  * #ctypedef npy_float80    float80_t
1014  * #ctypedef npy_float128   float128_t
1015  */
1016 typedef npy_float64 __pyx_t_5numpy_float64_t;
1017 
1018 /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":713
1019  * # The int types are mapped a bit surprising --
1020  * # numpy.int corresponds to 'l' and numpy.long to 'q'
1021  * ctypedef npy_long       int_t             # <<<<<<<<<<<<<<
1022  * ctypedef npy_longlong   long_t
1023  * ctypedef npy_longlong   longlong_t
1024  */
1025 typedef npy_long __pyx_t_5numpy_int_t;
1026 
1027 /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":714
1028  * # numpy.int corresponds to 'l' and numpy.long to 'q'
1029  * ctypedef npy_long       int_t
1030  * ctypedef npy_longlong   long_t             # <<<<<<<<<<<<<<
1031  * ctypedef npy_longlong   longlong_t
1032  *
1033  */
1034 typedef npy_longlong __pyx_t_5numpy_long_t;
1035 
1036 /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":715
1037  * ctypedef npy_long       int_t
1038  * ctypedef npy_longlong   long_t
1039  * ctypedef npy_longlong   longlong_t             # <<<<<<<<<<<<<<
1040  *
1041  * ctypedef npy_ulong      uint_t
1042  */
1043 typedef npy_longlong __pyx_t_5numpy_longlong_t;
1044 
1045 /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":717
1046  * ctypedef npy_longlong   longlong_t
1047  *
1048  * ctypedef npy_ulong      uint_t             # <<<<<<<<<<<<<<
1049  * ctypedef npy_ulonglong  ulong_t
1050  * ctypedef npy_ulonglong  ulonglong_t
1051  */
1052 typedef npy_ulong __pyx_t_5numpy_uint_t;
1053 
1054 /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":718
1055  *
1056  * ctypedef npy_ulong      uint_t
1057  * ctypedef npy_ulonglong  ulong_t             # <<<<<<<<<<<<<<
1058  * ctypedef npy_ulonglong  ulonglong_t
1059  *
1060  */
1061 typedef npy_ulonglong __pyx_t_5numpy_ulong_t;
1062 
1063 /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":719
1064  * ctypedef npy_ulong      uint_t
1065  * ctypedef npy_ulonglong  ulong_t
1066  * ctypedef npy_ulonglong  ulonglong_t             # <<<<<<<<<<<<<<
1067  *
1068  * ctypedef npy_intp       intp_t
1069  */
1070 typedef npy_ulonglong __pyx_t_5numpy_ulonglong_t;
1071 
1072 /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":721
1073  * ctypedef npy_ulonglong  ulonglong_t
1074  *
1075  * ctypedef npy_intp       intp_t             # <<<<<<<<<<<<<<
1076  * ctypedef npy_uintp      uintp_t
1077  *
1078  */
1079 typedef npy_intp __pyx_t_5numpy_intp_t;
1080 
1081 /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":722
1082  *
1083  * ctypedef npy_intp       intp_t
1084  * ctypedef npy_uintp      uintp_t             # <<<<<<<<<<<<<<
1085  *
1086  * ctypedef npy_double     float_t
1087  */
1088 typedef npy_uintp __pyx_t_5numpy_uintp_t;
1089 
1090 /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":724
1091  * ctypedef npy_uintp      uintp_t
1092  *
1093  * ctypedef npy_double     float_t             # <<<<<<<<<<<<<<
1094  * ctypedef npy_double     double_t
1095  * ctypedef npy_longdouble longdouble_t
1096  */
1097 typedef npy_double __pyx_t_5numpy_float_t;
1098 
1099 /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":725
1100  *
1101  * ctypedef npy_double     float_t
1102  * ctypedef npy_double     double_t             # <<<<<<<<<<<<<<
1103  * ctypedef npy_longdouble longdouble_t
1104  *
1105  */
1106 typedef npy_double __pyx_t_5numpy_double_t;
1107 
1108 /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":726
1109  * ctypedef npy_double     float_t
1110  * ctypedef npy_double     double_t
1111  * ctypedef npy_longdouble longdouble_t             # <<<<<<<<<<<<<<
1112  *
1113  * ctypedef npy_cfloat      cfloat_t
1114  */
1115 typedef npy_longdouble __pyx_t_5numpy_longdouble_t;
1116 
1117 /* "qutip/control/cy_grape.pyx":40
1118  *
1119  * DTYPE = np.float64
1120  * ctypedef np.float64_t DTYPE_t             # <<<<<<<<<<<<<<
1121  *
1122  * ITYPE = np.int32
1123  */
1124 typedef __pyx_t_5numpy_float64_t __pyx_t_5qutip_7control_8cy_grape_DTYPE_t;
1125 
1126 /* "qutip/control/cy_grape.pyx":43
1127  *
1128  * ITYPE = np.int32
1129  * ctypedef np.int32_t ITYPE_t             # <<<<<<<<<<<<<<
1130  *
1131  * CTYPE = np.complex128
1132  */
1133 typedef __pyx_t_5numpy_int32_t __pyx_t_5qutip_7control_8cy_grape_ITYPE_t;
1134 
1135 /* "qutip/control/cy_grape.pyx":49
1136  *
1137  * CTYPE = np.int64
1138  * ctypedef np.int64_t LTYPE_t             # <<<<<<<<<<<<<<
1139  *
1140  * @cython.boundscheck(False)
1141  */
1142 typedef __pyx_t_5numpy_int64_t __pyx_t_5qutip_7control_8cy_grape_LTYPE_t;
1143 /* Declarations.proto */
1144 #if CYTHON_CCOMPLEX
1145   #ifdef __cplusplus
1146     typedef ::std::complex< double > __pyx_t_double_complex;
1147   #else
1148     typedef double _Complex __pyx_t_double_complex;
1149   #endif
1150 #else
1151     typedef struct { double real, imag; } __pyx_t_double_complex;
1152 #endif
1153 static CYTHON_INLINE __pyx_t_double_complex __pyx_t_double_complex_from_parts(double, double);
1154 
1155 /* Declarations.proto */
1156 #if CYTHON_CCOMPLEX
1157   #ifdef __cplusplus
1158     typedef ::std::complex< float > __pyx_t_float_complex;
1159   #else
1160     typedef float _Complex __pyx_t_float_complex;
1161   #endif
1162 #else
1163     typedef struct { float real, imag; } __pyx_t_float_complex;
1164 #endif
1165 static CYTHON_INLINE __pyx_t_float_complex __pyx_t_float_complex_from_parts(float, float);
1166 
1167 
1168 /*--- Type declarations ---*/
1169 
1170 /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":728
1171  * ctypedef npy_longdouble longdouble_t
1172  *
1173  * ctypedef npy_cfloat      cfloat_t             # <<<<<<<<<<<<<<
1174  * ctypedef npy_cdouble     cdouble_t
1175  * ctypedef npy_clongdouble clongdouble_t
1176  */
1177 typedef npy_cfloat __pyx_t_5numpy_cfloat_t;
1178 
1179 /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":729
1180  *
1181  * ctypedef npy_cfloat      cfloat_t
1182  * ctypedef npy_cdouble     cdouble_t             # <<<<<<<<<<<<<<
1183  * ctypedef npy_clongdouble clongdouble_t
1184  *
1185  */
1186 typedef npy_cdouble __pyx_t_5numpy_cdouble_t;
1187 
1188 /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":730
1189  * ctypedef npy_cfloat      cfloat_t
1190  * ctypedef npy_cdouble     cdouble_t
1191  * ctypedef npy_clongdouble clongdouble_t             # <<<<<<<<<<<<<<
1192  *
1193  * ctypedef npy_cdouble     complex_t
1194  */
1195 typedef npy_clongdouble __pyx_t_5numpy_clongdouble_t;
1196 
1197 /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":732
1198  * ctypedef npy_clongdouble clongdouble_t
1199  *
1200  * ctypedef npy_cdouble     complex_t             # <<<<<<<<<<<<<<
1201  *
1202  * cdef inline object PyArray_MultiIterNew1(a):
1203  */
1204 typedef npy_cdouble __pyx_t_5numpy_complex_t;
1205 
1206 /* --- Runtime support code (head) --- */
1207 /* Refnanny.proto */
1208 #ifndef CYTHON_REFNANNY
1209   #define CYTHON_REFNANNY 0
1210 #endif
1211 #if CYTHON_REFNANNY
1212   typedef struct {
1213     void (*INCREF)(void*, PyObject*, int);
1214     void (*DECREF)(void*, PyObject*, int);
1215     void (*GOTREF)(void*, PyObject*, int);
1216     void (*GIVEREF)(void*, PyObject*, int);
1217     void* (*SetupContext)(const char*, int, const char*);
1218     void (*FinishContext)(void**);
1219   } __Pyx_RefNannyAPIStruct;
1220   static __Pyx_RefNannyAPIStruct *__Pyx_RefNanny = NULL;
1221   static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname);
1222   #define __Pyx_RefNannyDeclarations void *__pyx_refnanny = NULL;
1223 #ifdef WITH_THREAD
1224   #define __Pyx_RefNannySetupContext(name, acquire_gil)\
1225           if (acquire_gil) {\
1226               PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure();\
1227               __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__);\
1228               PyGILState_Release(__pyx_gilstate_save);\
1229           } else {\
1230               __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__);\
1231           }
1232 #else
1233   #define __Pyx_RefNannySetupContext(name, acquire_gil)\
1234           __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__)
1235 #endif
1236   #define __Pyx_RefNannyFinishContext()\
1237           __Pyx_RefNanny->FinishContext(&__pyx_refnanny)
1238   #define __Pyx_INCREF(r)  __Pyx_RefNanny->INCREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
1239   #define __Pyx_DECREF(r)  __Pyx_RefNanny->DECREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
1240   #define __Pyx_GOTREF(r)  __Pyx_RefNanny->GOTREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
1241   #define __Pyx_GIVEREF(r) __Pyx_RefNanny->GIVEREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
1242   #define __Pyx_XINCREF(r)  do { if((r) != NULL) {__Pyx_INCREF(r); }} while(0)
1243   #define __Pyx_XDECREF(r)  do { if((r) != NULL) {__Pyx_DECREF(r); }} while(0)
1244   #define __Pyx_XGOTREF(r)  do { if((r) != NULL) {__Pyx_GOTREF(r); }} while(0)
1245   #define __Pyx_XGIVEREF(r) do { if((r) != NULL) {__Pyx_GIVEREF(r);}} while(0)
1246 #else
1247   #define __Pyx_RefNannyDeclarations
1248   #define __Pyx_RefNannySetupContext(name, acquire_gil)
1249   #define __Pyx_RefNannyFinishContext()
1250   #define __Pyx_INCREF(r) Py_INCREF(r)
1251   #define __Pyx_DECREF(r) Py_DECREF(r)
1252   #define __Pyx_GOTREF(r)
1253   #define __Pyx_GIVEREF(r)
1254   #define __Pyx_XINCREF(r) Py_XINCREF(r)
1255   #define __Pyx_XDECREF(r) Py_XDECREF(r)
1256   #define __Pyx_XGOTREF(r)
1257   #define __Pyx_XGIVEREF(r)
1258 #endif
1259 #define __Pyx_XDECREF_SET(r, v) do {\
1260         PyObject *tmp = (PyObject *) r;\
1261         r = v; __Pyx_XDECREF(tmp);\
1262     } while (0)
1263 #define __Pyx_DECREF_SET(r, v) do {\
1264         PyObject *tmp = (PyObject *) r;\
1265         r = v; __Pyx_DECREF(tmp);\
1266     } while (0)
1267 #define __Pyx_CLEAR(r)    do { PyObject* tmp = ((PyObject*)(r)); r = NULL; __Pyx_DECREF(tmp);} while(0)
1268 #define __Pyx_XCLEAR(r)   do { if((r) != NULL) {PyObject* tmp = ((PyObject*)(r)); r = NULL; __Pyx_DECREF(tmp);}} while(0)
1269 
1270 /* PyObjectGetAttrStr.proto */
1271 #if CYTHON_USE_TYPE_SLOTS
1272 static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStr(PyObject* obj, PyObject* attr_name);
1273 #else
1274 #define __Pyx_PyObject_GetAttrStr(o,n) PyObject_GetAttr(o,n)
1275 #endif
1276 
1277 /* GetBuiltinName.proto */
1278 static PyObject *__Pyx_GetBuiltinName(PyObject *name);
1279 
1280 /* PyFunctionFastCall.proto */
1281 #if CYTHON_FAST_PYCALL
1282 #define __Pyx_PyFunction_FastCall(func, args, nargs)\
1283     __Pyx_PyFunction_FastCallDict((func), (args), (nargs), NULL)
1284 #if 1 || PY_VERSION_HEX < 0x030600B1
1285 static PyObject *__Pyx_PyFunction_FastCallDict(PyObject *func, PyObject **args, Py_ssize_t nargs, PyObject *kwargs);
1286 #else
1287 #define __Pyx_PyFunction_FastCallDict(func, args, nargs, kwargs) _PyFunction_FastCallDict(func, args, nargs, kwargs)
1288 #endif
1289 #define __Pyx_BUILD_ASSERT_EXPR(cond)\
1290     (sizeof(char [1 - 2*!(cond)]) - 1)
1291 #ifndef Py_MEMBER_SIZE
1292 #define Py_MEMBER_SIZE(type, member) sizeof(((type *)0)->member)
1293 #endif
1294   static size_t __pyx_pyframe_localsplus_offset = 0;
1295   #include "frameobject.h"
1296   #define __Pxy_PyFrame_Initialize_Offsets()\
1297     ((void)__Pyx_BUILD_ASSERT_EXPR(sizeof(PyFrameObject) == offsetof(PyFrameObject, f_localsplus) + Py_MEMBER_SIZE(PyFrameObject, f_localsplus)),\
1298      (void)(__pyx_pyframe_localsplus_offset = ((size_t)PyFrame_Type.tp_basicsize) - Py_MEMBER_SIZE(PyFrameObject, f_localsplus)))
1299   #define __Pyx_PyFrame_GetLocalsplus(frame)\
1300     (assert(__pyx_pyframe_localsplus_offset), (PyObject **)(((char *)(frame)) + __pyx_pyframe_localsplus_offset))
1301 #endif
1302 
1303 /* PyObjectCall.proto */
1304 #if CYTHON_COMPILING_IN_CPYTHON
1305 static CYTHON_INLINE PyObject* __Pyx_PyObject_Call(PyObject *func, PyObject *arg, PyObject *kw);
1306 #else
1307 #define __Pyx_PyObject_Call(func, arg, kw) PyObject_Call(func, arg, kw)
1308 #endif
1309 
1310 /* PyObjectCallMethO.proto */
1311 #if CYTHON_COMPILING_IN_CPYTHON
1312 static CYTHON_INLINE PyObject* __Pyx_PyObject_CallMethO(PyObject *func, PyObject *arg);
1313 #endif
1314 
1315 /* PyObjectCallNoArg.proto */
1316 #if CYTHON_COMPILING_IN_CPYTHON
1317 static CYTHON_INLINE PyObject* __Pyx_PyObject_CallNoArg(PyObject *func);
1318 #else
1319 #define __Pyx_PyObject_CallNoArg(func) __Pyx_PyObject_Call(func, __pyx_empty_tuple, NULL)
1320 #endif
1321 
1322 /* PyCFunctionFastCall.proto */
1323 #if CYTHON_FAST_PYCCALL
1324 static CYTHON_INLINE PyObject *__Pyx_PyCFunction_FastCall(PyObject *func, PyObject **args, Py_ssize_t nargs);
1325 #else
1326 #define __Pyx_PyCFunction_FastCall(func, args, nargs)  (assert(0), NULL)
1327 #endif
1328 
1329 /* PyObjectCallOneArg.proto */
1330 static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg);
1331 
1332 /* ExtTypeTest.proto */
1333 static CYTHON_INLINE int __Pyx_TypeTest(PyObject *obj, PyTypeObject *type);
1334 
1335 /* IsLittleEndian.proto */
1336 static CYTHON_INLINE int __Pyx_Is_Little_Endian(void);
1337 
1338 /* BufferFormatCheck.proto */
1339 static const char* __Pyx_BufFmt_CheckString(__Pyx_BufFmt_Context* ctx, const char* ts);
1340 static void __Pyx_BufFmt_Init(__Pyx_BufFmt_Context* ctx,
1341                               __Pyx_BufFmt_StackElem* stack,
1342                               __Pyx_TypeInfo* type);
1343 
1344 /* BufferGetAndValidate.proto */
1345 #define __Pyx_GetBufferAndValidate(buf, obj, dtype, flags, nd, cast, stack)\
1346     ((obj == Py_None || obj == NULL) ?\
1347     (__Pyx_ZeroBuffer(buf), 0) :\
1348     __Pyx__GetBufferAndValidate(buf, obj, dtype, flags, nd, cast, stack))
1349 static int  __Pyx__GetBufferAndValidate(Py_buffer* buf, PyObject* obj,
1350     __Pyx_TypeInfo* dtype, int flags, int nd, int cast, __Pyx_BufFmt_StackElem* stack);
1351 static void __Pyx_ZeroBuffer(Py_buffer* buf);
1352 static CYTHON_INLINE void __Pyx_SafeReleaseBuffer(Py_buffer* info);
1353 static Py_ssize_t __Pyx_minusones[] = { -1, -1, -1, -1, -1, -1, -1, -1 };
1354 static Py_ssize_t __Pyx_zeros[] = { 0, 0, 0, 0, 0, 0, 0, 0 };
1355 
1356 #define __Pyx_BufPtrCContig1d(type, buf, i0, s0) ((type)buf + i0)
1357 /* GetItemInt.proto */
1358 #define __Pyx_GetItemInt(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck)\
1359     (__Pyx_fits_Py_ssize_t(i, type, is_signed) ?\
1360     __Pyx_GetItemInt_Fast(o, (Py_ssize_t)i, is_list, wraparound, boundscheck) :\
1361     (is_list ? (PyErr_SetString(PyExc_IndexError, "list index out of range"), (PyObject*)NULL) :\
1362                __Pyx_GetItemInt_Generic(o, to_py_func(i))))
1363 #define __Pyx_GetItemInt_List(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck)\
1364     (__Pyx_fits_Py_ssize_t(i, type, is_signed) ?\
1365     __Pyx_GetItemInt_List_Fast(o, (Py_ssize_t)i, wraparound, boundscheck) :\
1366     (PyErr_SetString(PyExc_IndexError, "list index out of range"), (PyObject*)NULL))
1367 static CYTHON_INLINE PyObject *__Pyx_GetItemInt_List_Fast(PyObject *o, Py_ssize_t i,
1368                                                               int wraparound, int boundscheck);
1369 #define __Pyx_GetItemInt_Tuple(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck)\
1370     (__Pyx_fits_Py_ssize_t(i, type, is_signed) ?\
1371     __Pyx_GetItemInt_Tuple_Fast(o, (Py_ssize_t)i, wraparound, boundscheck) :\
1372     (PyErr_SetString(PyExc_IndexError, "tuple index out of range"), (PyObject*)NULL))
1373 static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Tuple_Fast(PyObject *o, Py_ssize_t i,
1374                                                               int wraparound, int boundscheck);
1375 static PyObject *__Pyx_GetItemInt_Generic(PyObject *o, PyObject* j);
1376 static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Fast(PyObject *o, Py_ssize_t i,
1377                                                      int is_list, int wraparound, int boundscheck);
1378 
1379 /* PyThreadStateGet.proto */
1380 #if CYTHON_FAST_THREAD_STATE
1381 #define __Pyx_PyThreadState_declare  PyThreadState *__pyx_tstate;
1382 #define __Pyx_PyThreadState_assign  __pyx_tstate = __Pyx_PyThreadState_Current;
1383 #define __Pyx_PyErr_Occurred()  __pyx_tstate->curexc_type
1384 #else
1385 #define __Pyx_PyThreadState_declare
1386 #define __Pyx_PyThreadState_assign
1387 #define __Pyx_PyErr_Occurred()  PyErr_Occurred()
1388 #endif
1389 
1390 /* PyErrFetchRestore.proto */
1391 #if CYTHON_FAST_THREAD_STATE
1392 #define __Pyx_PyErr_Clear() __Pyx_ErrRestore(NULL, NULL, NULL)
1393 #define __Pyx_ErrRestoreWithState(type, value, tb)  __Pyx_ErrRestoreInState(PyThreadState_GET(), type, value, tb)
1394 #define __Pyx_ErrFetchWithState(type, value, tb)    __Pyx_ErrFetchInState(PyThreadState_GET(), type, value, tb)
1395 #define __Pyx_ErrRestore(type, value, tb)  __Pyx_ErrRestoreInState(__pyx_tstate, type, value, tb)
1396 #define __Pyx_ErrFetch(type, value, tb)    __Pyx_ErrFetchInState(__pyx_tstate, type, value, tb)
1397 static CYTHON_INLINE void __Pyx_ErrRestoreInState(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb);
1398 static CYTHON_INLINE void __Pyx_ErrFetchInState(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb);
1399 #if CYTHON_COMPILING_IN_CPYTHON
1400 #define __Pyx_PyErr_SetNone(exc) (Py_INCREF(exc), __Pyx_ErrRestore((exc), NULL, NULL))
1401 #else
1402 #define __Pyx_PyErr_SetNone(exc) PyErr_SetNone(exc)
1403 #endif
1404 #else
1405 #define __Pyx_PyErr_Clear() PyErr_Clear()
1406 #define __Pyx_PyErr_SetNone(exc) PyErr_SetNone(exc)
1407 #define __Pyx_ErrRestoreWithState(type, value, tb)  PyErr_Restore(type, value, tb)
1408 #define __Pyx_ErrFetchWithState(type, value, tb)  PyErr_Fetch(type, value, tb)
1409 #define __Pyx_ErrRestoreInState(tstate, type, value, tb)  PyErr_Restore(type, value, tb)
1410 #define __Pyx_ErrFetchInState(tstate, type, value, tb)  PyErr_Fetch(type, value, tb)
1411 #define __Pyx_ErrRestore(type, value, tb)  PyErr_Restore(type, value, tb)
1412 #define __Pyx_ErrFetch(type, value, tb)  PyErr_Fetch(type, value, tb)
1413 #endif
1414 
1415 /* WriteUnraisableException.proto */
1416 static void __Pyx_WriteUnraisable(const char *name, int clineno,
1417                                   int lineno, const char *filename,
1418                                   int full_traceback, int nogil);
1419 
1420 /* RaiseArgTupleInvalid.proto */
1421 static void __Pyx_RaiseArgtupleInvalid(const char* func_name, int exact,
1422     Py_ssize_t num_min, Py_ssize_t num_max, Py_ssize_t num_found);
1423 
1424 /* RaiseDoubleKeywords.proto */
1425 static void __Pyx_RaiseDoubleKeywordsError(const char* func_name, PyObject* kw_name);
1426 
1427 /* ParseKeywords.proto */
1428 static int __Pyx_ParseOptionalKeywords(PyObject *kwds, PyObject **argnames[],\
1429     PyObject *kwds2, PyObject *values[], Py_ssize_t num_pos_args,\
1430     const char* function_name);
1431 
1432 /* ObjectGetItem.proto */
1433 #if CYTHON_USE_TYPE_SLOTS
1434 static CYTHON_INLINE PyObject *__Pyx_PyObject_GetItem(PyObject *obj, PyObject* key);
1435 #else
1436 #define __Pyx_PyObject_GetItem(obj, key)  PyObject_GetItem(obj, key)
1437 #endif
1438 
1439 #define __Pyx_BufPtrCContig3d(type, buf, i0, s0, i1, s1, i2, s2) ((type)((char*)buf + i0 * s0 + i1 * s1) + i2)
1440 /* ArgTypeTest.proto */
1441 #define __Pyx_ArgTypeTest(obj, type, none_allowed, name, exact)\
1442     ((likely((Py_TYPE(obj) == type) | (none_allowed && (obj == Py_None)))) ? 1 :\
1443         __Pyx__ArgTypeTest(obj, type, name, exact))
1444 static int __Pyx__ArgTypeTest(PyObject *obj, PyTypeObject *type, const char *name, int exact);
1445 
1446 /* GetTopmostException.proto */
1447 #if CYTHON_USE_EXC_INFO_STACK
1448 static _PyErr_StackItem * __Pyx_PyErr_GetTopmostException(PyThreadState *tstate);
1449 #endif
1450 
1451 /* SaveResetException.proto */
1452 #if CYTHON_FAST_THREAD_STATE
1453 #define __Pyx_ExceptionSave(type, value, tb)  __Pyx__ExceptionSave(__pyx_tstate, type, value, tb)
1454 static CYTHON_INLINE void __Pyx__ExceptionSave(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb);
1455 #define __Pyx_ExceptionReset(type, value, tb)  __Pyx__ExceptionReset(__pyx_tstate, type, value, tb)
1456 static CYTHON_INLINE void __Pyx__ExceptionReset(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb);
1457 #else
1458 #define __Pyx_ExceptionSave(type, value, tb)   PyErr_GetExcInfo(type, value, tb)
1459 #define __Pyx_ExceptionReset(type, value, tb)  PyErr_SetExcInfo(type, value, tb)
1460 #endif
1461 
1462 /* PyErrExceptionMatches.proto */
1463 #if CYTHON_FAST_THREAD_STATE
1464 #define __Pyx_PyErr_ExceptionMatches(err) __Pyx_PyErr_ExceptionMatchesInState(__pyx_tstate, err)
1465 static CYTHON_INLINE int __Pyx_PyErr_ExceptionMatchesInState(PyThreadState* tstate, PyObject* err);
1466 #else
1467 #define __Pyx_PyErr_ExceptionMatches(err)  PyErr_ExceptionMatches(err)
1468 #endif
1469 
1470 /* GetException.proto */
1471 #if CYTHON_FAST_THREAD_STATE
1472 #define __Pyx_GetException(type, value, tb)  __Pyx__GetException(__pyx_tstate, type, value, tb)
1473 static int __Pyx__GetException(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb);
1474 #else
1475 static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb);
1476 #endif
1477 
1478 /* RaiseException.proto */
1479 static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause);
1480 
1481 /* TypeImport.proto */
1482 #ifndef __PYX_HAVE_RT_ImportType_proto
1483 #define __PYX_HAVE_RT_ImportType_proto
1484 enum __Pyx_ImportType_CheckSize {
1485    __Pyx_ImportType_CheckSize_Error = 0,
1486    __Pyx_ImportType_CheckSize_Warn = 1,
1487    __Pyx_ImportType_CheckSize_Ignore = 2
1488 };
1489 static PyTypeObject *__Pyx_ImportType(PyObject* module, const char *module_name, const char *class_name, size_t size, enum __Pyx_ImportType_CheckSize check_size);
1490 #endif
1491 
1492 /* Import.proto */
1493 static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, int level);
1494 
1495 /* PyDictVersioning.proto */
1496 #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_TYPE_SLOTS
1497 #define __PYX_DICT_VERSION_INIT  ((PY_UINT64_T) -1)
1498 #define __PYX_GET_DICT_VERSION(dict)  (((PyDictObject*)(dict))->ma_version_tag)
1499 #define __PYX_UPDATE_DICT_CACHE(dict, value, cache_var, version_var)\
1500     (version_var) = __PYX_GET_DICT_VERSION(dict);\
1501     (cache_var) = (value);
1502 #define __PYX_PY_DICT_LOOKUP_IF_MODIFIED(VAR, DICT, LOOKUP) {\
1503     static PY_UINT64_T __pyx_dict_version = 0;\
1504     static PyObject *__pyx_dict_cached_value = NULL;\
1505     if (likely(__PYX_GET_DICT_VERSION(DICT) == __pyx_dict_version)) {\
1506         (VAR) = __pyx_dict_cached_value;\
1507     } else {\
1508         (VAR) = __pyx_dict_cached_value = (LOOKUP);\
1509         __pyx_dict_version = __PYX_GET_DICT_VERSION(DICT);\
1510     }\
1511 }
1512 static CYTHON_INLINE PY_UINT64_T __Pyx_get_tp_dict_version(PyObject *obj);
1513 static CYTHON_INLINE PY_UINT64_T __Pyx_get_object_dict_version(PyObject *obj);
1514 static CYTHON_INLINE int __Pyx_object_dict_version_matches(PyObject* obj, PY_UINT64_T tp_dict_version, PY_UINT64_T obj_dict_version);
1515 #else
1516 #define __PYX_GET_DICT_VERSION(dict)  (0)
1517 #define __PYX_UPDATE_DICT_CACHE(dict, value, cache_var, version_var)
1518 #define __PYX_PY_DICT_LOOKUP_IF_MODIFIED(VAR, DICT, LOOKUP)  (VAR) = (LOOKUP);
1519 #endif
1520 
1521 /* GetModuleGlobalName.proto */
1522 #if CYTHON_USE_DICT_VERSIONS
1523 #define __Pyx_GetModuleGlobalName(var, name)  {\
1524     static PY_UINT64_T __pyx_dict_version = 0;\
1525     static PyObject *__pyx_dict_cached_value = NULL;\
1526     (var) = (likely(__pyx_dict_version == __PYX_GET_DICT_VERSION(__pyx_d))) ?\
1527         (likely(__pyx_dict_cached_value) ? __Pyx_NewRef(__pyx_dict_cached_value) : __Pyx_GetBuiltinName(name)) :\
1528         __Pyx__GetModuleGlobalName(name, &__pyx_dict_version, &__pyx_dict_cached_value);\
1529 }
1530 #define __Pyx_GetModuleGlobalNameUncached(var, name)  {\
1531     PY_UINT64_T __pyx_dict_version;\
1532     PyObject *__pyx_dict_cached_value;\
1533     (var) = __Pyx__GetModuleGlobalName(name, &__pyx_dict_version, &__pyx_dict_cached_value);\
1534 }
1535 static PyObject *__Pyx__GetModuleGlobalName(PyObject *name, PY_UINT64_T *dict_version, PyObject **dict_cached_value);
1536 #else
1537 #define __Pyx_GetModuleGlobalName(var, name)  (var) = __Pyx__GetModuleGlobalName(name)
1538 #define __Pyx_GetModuleGlobalNameUncached(var, name)  (var) = __Pyx__GetModuleGlobalName(name)
1539 static CYTHON_INLINE PyObject *__Pyx__GetModuleGlobalName(PyObject *name);
1540 #endif
1541 
1542 /* CLineInTraceback.proto */
1543 #ifdef CYTHON_CLINE_IN_TRACEBACK
1544 #define __Pyx_CLineForTraceback(tstate, c_line)  (((CYTHON_CLINE_IN_TRACEBACK)) ? c_line : 0)
1545 #else
1546 static int __Pyx_CLineForTraceback(PyThreadState *tstate, int c_line);
1547 #endif
1548 
1549 /* CodeObjectCache.proto */
1550 typedef struct {
1551     PyCodeObject* code_object;
1552     int code_line;
1553 } __Pyx_CodeObjectCacheEntry;
1554 struct __Pyx_CodeObjectCache {
1555     int count;
1556     int max_count;
1557     __Pyx_CodeObjectCacheEntry* entries;
1558 };
1559 static struct __Pyx_CodeObjectCache __pyx_code_cache = {0,0,NULL};
1560 static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line);
1561 static PyCodeObject *__pyx_find_code_object(int code_line);
1562 static void __pyx_insert_code_object(int code_line, PyCodeObject* code_object);
1563 
1564 /* AddTraceback.proto */
1565 static void __Pyx_AddTraceback(const char *funcname, int c_line,
1566                                int py_line, const char *filename);
1567 
1568 /* BufferStructDeclare.proto */
1569 typedef struct {
1570   Py_ssize_t shape, strides, suboffsets;
1571 } __Pyx_Buf_DimInfo;
1572 typedef struct {
1573   size_t refcount;
1574   Py_buffer pybuffer;
1575 } __Pyx_Buffer;
1576 typedef struct {
1577   __Pyx_Buffer *rcbuffer;
1578   char *data;
1579   __Pyx_Buf_DimInfo diminfo[8];
1580 } __Pyx_LocalBuf_ND;
1581 
1582 #if PY_MAJOR_VERSION < 3
1583     static int __Pyx_GetBuffer(PyObject *obj, Py_buffer *view, int flags);
1584     static void __Pyx_ReleaseBuffer(Py_buffer *view);
1585 #else
1586     #define __Pyx_GetBuffer PyObject_GetBuffer
1587     #define __Pyx_ReleaseBuffer PyBuffer_Release
1588 #endif
1589 
1590 
1591 /* GCCDiagnostics.proto */
1592 #if defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6))
1593 #define __Pyx_HAS_GCC_DIAGNOSTIC
1594 #endif
1595 
1596 /* RealImag.proto */
1597 #if CYTHON_CCOMPLEX
1598   #ifdef __cplusplus
1599     #define __Pyx_CREAL(z) ((z).real())
1600     #define __Pyx_CIMAG(z) ((z).imag())
1601   #else
1602     #define __Pyx_CREAL(z) (__real__(z))
1603     #define __Pyx_CIMAG(z) (__imag__(z))
1604   #endif
1605 #else
1606     #define __Pyx_CREAL(z) ((z).real)
1607     #define __Pyx_CIMAG(z) ((z).imag)
1608 #endif
1609 #if defined(__cplusplus) && CYTHON_CCOMPLEX\
1610         && (defined(_WIN32) || defined(__clang__) || (defined(__GNUC__) && (__GNUC__ >= 5 || __GNUC__ == 4 && __GNUC_MINOR__ >= 4 )) || __cplusplus >= 201103)
1611     #define __Pyx_SET_CREAL(z,x) ((z).real(x))
1612     #define __Pyx_SET_CIMAG(z,y) ((z).imag(y))
1613 #else
1614     #define __Pyx_SET_CREAL(z,x) __Pyx_CREAL(z) = (x)
1615     #define __Pyx_SET_CIMAG(z,y) __Pyx_CIMAG(z) = (y)
1616 #endif
1617 
1618 /* Arithmetic.proto */
1619 #if CYTHON_CCOMPLEX
1620     #define __Pyx_c_eq_double(a, b)   ((a)==(b))
1621     #define __Pyx_c_sum_double(a, b)  ((a)+(b))
1622     #define __Pyx_c_diff_double(a, b) ((a)-(b))
1623     #define __Pyx_c_prod_double(a, b) ((a)*(b))
1624     #define __Pyx_c_quot_double(a, b) ((a)/(b))
1625     #define __Pyx_c_neg_double(a)     (-(a))
1626   #ifdef __cplusplus
1627     #define __Pyx_c_is_zero_double(z) ((z)==(double)0)
1628     #define __Pyx_c_conj_double(z)    (::std::conj(z))
1629     #if 1
1630         #define __Pyx_c_abs_double(z)     (::std::abs(z))
1631         #define __Pyx_c_pow_double(a, b)  (::std::pow(a, b))
1632     #endif
1633   #else
1634     #define __Pyx_c_is_zero_double(z) ((z)==0)
1635     #define __Pyx_c_conj_double(z)    (conj(z))
1636     #if 1
1637         #define __Pyx_c_abs_double(z)     (cabs(z))
1638         #define __Pyx_c_pow_double(a, b)  (cpow(a, b))
1639     #endif
1640  #endif
1641 #else
1642     static CYTHON_INLINE int __Pyx_c_eq_double(__pyx_t_double_complex, __pyx_t_double_complex);
1643     static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_sum_double(__pyx_t_double_complex, __pyx_t_double_complex);
1644     static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_diff_double(__pyx_t_double_complex, __pyx_t_double_complex);
1645     static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_prod_double(__pyx_t_double_complex, __pyx_t_double_complex);
1646     static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_quot_double(__pyx_t_double_complex, __pyx_t_double_complex);
1647     static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_neg_double(__pyx_t_double_complex);
1648     static CYTHON_INLINE int __Pyx_c_is_zero_double(__pyx_t_double_complex);
1649     static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_conj_double(__pyx_t_double_complex);
1650     #if 1
1651         static CYTHON_INLINE double __Pyx_c_abs_double(__pyx_t_double_complex);
1652         static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_pow_double(__pyx_t_double_complex, __pyx_t_double_complex);
1653     #endif
1654 #endif
1655 
1656 /* ToPy.proto */
1657 #define __pyx_PyComplex_FromComplex(z)\
1658         PyComplex_FromDoubles((double)__Pyx_CREAL(z),\
1659                               (double)__Pyx_CIMAG(z))
1660 
1661 /* FromPy.proto */
1662 static __pyx_t_double_complex __Pyx_PyComplex_As___pyx_t_double_complex(PyObject*);
1663 
1664 /* Arithmetic.proto */
1665 #if CYTHON_CCOMPLEX
1666     #define __Pyx_c_eq_float(a, b)   ((a)==(b))
1667     #define __Pyx_c_sum_float(a, b)  ((a)+(b))
1668     #define __Pyx_c_diff_float(a, b) ((a)-(b))
1669     #define __Pyx_c_prod_float(a, b) ((a)*(b))
1670     #define __Pyx_c_quot_float(a, b) ((a)/(b))
1671     #define __Pyx_c_neg_float(a)     (-(a))
1672   #ifdef __cplusplus
1673     #define __Pyx_c_is_zero_float(z) ((z)==(float)0)
1674     #define __Pyx_c_conj_float(z)    (::std::conj(z))
1675     #if 1
1676         #define __Pyx_c_abs_float(z)     (::std::abs(z))
1677         #define __Pyx_c_pow_float(a, b)  (::std::pow(a, b))
1678     #endif
1679   #else
1680     #define __Pyx_c_is_zero_float(z) ((z)==0)
1681     #define __Pyx_c_conj_float(z)    (conjf(z))
1682     #if 1
1683         #define __Pyx_c_abs_float(z)     (cabsf(z))
1684         #define __Pyx_c_pow_float(a, b)  (cpowf(a, b))
1685     #endif
1686  #endif
1687 #else
1688     static CYTHON_INLINE int __Pyx_c_eq_float(__pyx_t_float_complex, __pyx_t_float_complex);
1689     static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_sum_float(__pyx_t_float_complex, __pyx_t_float_complex);
1690     static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_diff_float(__pyx_t_float_complex, __pyx_t_float_complex);
1691     static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_prod_float(__pyx_t_float_complex, __pyx_t_float_complex);
1692     static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_quot_float(__pyx_t_float_complex, __pyx_t_float_complex);
1693     static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_neg_float(__pyx_t_float_complex);
1694     static CYTHON_INLINE int __Pyx_c_is_zero_float(__pyx_t_float_complex);
1695     static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_conj_float(__pyx_t_float_complex);
1696     #if 1
1697         static CYTHON_INLINE float __Pyx_c_abs_float(__pyx_t_float_complex);
1698         static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_pow_float(__pyx_t_float_complex, __pyx_t_float_complex);
1699     #endif
1700 #endif
1701 
1702 /* CIntFromPy.proto */
1703 static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *);
1704 
1705 /* CIntToPy.proto */
1706 static CYTHON_INLINE PyObject* __Pyx_PyInt_From_int(int value);
1707 
1708 /* CIntToPy.proto */
1709 static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value);
1710 
1711 /* CIntFromPy.proto */
1712 static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *);
1713 
1714 /* FastTypeChecks.proto */
1715 #if CYTHON_COMPILING_IN_CPYTHON
1716 #define __Pyx_TypeCheck(obj, type) __Pyx_IsSubtype(Py_TYPE(obj), (PyTypeObject *)type)
1717 static CYTHON_INLINE int __Pyx_IsSubtype(PyTypeObject *a, PyTypeObject *b);
1718 static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches(PyObject *err, PyObject *type);
1719 static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches2(PyObject *err, PyObject *type1, PyObject *type2);
1720 #else
1721 #define __Pyx_TypeCheck(obj, type) PyObject_TypeCheck(obj, (PyTypeObject *)type)
1722 #define __Pyx_PyErr_GivenExceptionMatches(err, type) PyErr_GivenExceptionMatches(err, type)
1723 #define __Pyx_PyErr_GivenExceptionMatches2(err, type1, type2) (PyErr_GivenExceptionMatches(err, type1) || PyErr_GivenExceptionMatches(err, type2))
1724 #endif
1725 #define __Pyx_PyException_Check(obj) __Pyx_TypeCheck(obj, PyExc_Exception)
1726 
1727 /* CheckBinaryVersion.proto */
1728 static int __Pyx_check_binary_version(void);
1729 
1730 /* InitStrings.proto */
1731 static int __Pyx_InitStrings(__Pyx_StringTabEntry *t);
1732 
1733 
1734 /* Module declarations from 'cpython.buffer' */
1735 
1736 /* Module declarations from 'libc.string' */
1737 
1738 /* Module declarations from 'libc.stdio' */
1739 
1740 /* Module declarations from '__builtin__' */
1741 
1742 /* Module declarations from 'cpython.type' */
1743 static PyTypeObject *__pyx_ptype_7cpython_4type_type = 0;
1744 
1745 /* Module declarations from 'cpython' */
1746 
1747 /* Module declarations from 'cpython.object' */
1748 
1749 /* Module declarations from 'cpython.ref' */
1750 
1751 /* Module declarations from 'cpython.mem' */
1752 
1753 /* Module declarations from 'numpy' */
1754 
1755 /* Module declarations from 'numpy' */
1756 static PyTypeObject *__pyx_ptype_5numpy_dtype = 0;
1757 static PyTypeObject *__pyx_ptype_5numpy_flatiter = 0;
1758 static PyTypeObject *__pyx_ptype_5numpy_broadcast = 0;
1759 static PyTypeObject *__pyx_ptype_5numpy_ndarray = 0;
1760 static PyTypeObject *__pyx_ptype_5numpy_ufunc = 0;
1761 
1762 /* Module declarations from 'cython' */
1763 
1764 /* Module declarations from 'libc.math' */
1765 
1766 /* Module declarations from 'libc' */
1767 
1768 /* Module declarations from 'qutip.control.cy_grape' */
1769 static __pyx_t_double_complex __pyx_f_5qutip_7control_8cy_grape_cy_overlap(PyObject *, PyObject *, int __pyx_skip_dispatch); /*proto*/
1770 static PyObject *__pyx_f_5qutip_7control_8cy_grape_cy_grape_inner(PyObject *, PyArrayObject *, int, int, int, PyObject *, PyObject *, PyObject *, float, float, float, float, int, int, float, float, int __pyx_skip_dispatch); /*proto*/
1771 static __Pyx_TypeInfo __Pyx_TypeInfo___pyx_t_double_complex = { "double complex", NULL, sizeof(__pyx_t_double_complex), { 0 }, 0, 'C', 0, 0 };
1772 static __Pyx_TypeInfo __Pyx_TypeInfo_nn___pyx_t_5qutip_7control_8cy_grape_ITYPE_t = { "ITYPE_t", NULL, sizeof(__pyx_t_5qutip_7control_8cy_grape_ITYPE_t), { 0 }, 0, IS_UNSIGNED(__pyx_t_5qutip_7control_8cy_grape_ITYPE_t) ? 'U' : 'I', IS_UNSIGNED(__pyx_t_5qutip_7control_8cy_grape_ITYPE_t), 0 };
1773 static __Pyx_TypeInfo __Pyx_TypeInfo_nn___pyx_t_5qutip_7control_8cy_grape_DTYPE_t = { "DTYPE_t", NULL, sizeof(__pyx_t_5qutip_7control_8cy_grape_DTYPE_t), { 0 }, 0, 'R', 0, 0 };
1774 #define __Pyx_MODULE_NAME "qutip.control.cy_grape"
1775 extern int __pyx_module_is_main_qutip__control__cy_grape;
1776 int __pyx_module_is_main_qutip__control__cy_grape = 0;
1777 
1778 /* Implementation of 'qutip.control.cy_grape' */
1779 static PyObject *__pyx_builtin_range;
1780 static PyObject *__pyx_builtin_ImportError;
1781 static const char __pyx_k_J[] = "J";
1782 static const char __pyx_k_M[] = "M";
1783 static const char __pyx_k_T[] = "T";
1784 static const char __pyx_k_U[] = "U";
1785 static const char __pyx_k_r[] = "r";
1786 static const char __pyx_k_u[] = "u";
1787 static const char __pyx_k_dt[] = "dt";
1788 static const char __pyx_k_np[] = "np";
1789 static const char __pyx_k_eps[] = "eps";
1790 static const char __pyx_k_op1[] = "op1";
1791 static const char __pyx_k_op2[] = "op2";
1792 static const char __pyx_k_beta[] = "beta";
1793 static const char __pyx_k_conj[] = "conj";
1794 static const char __pyx_k_data[] = "data";
1795 static const char __pyx_k_main[] = "__main__";
1796 static const char __pyx_k_name[] = "__name__";
1797 static const char __pyx_k_real[] = "real";
1798 static const char __pyx_k_test[] = "__test__";
1799 static const char __pyx_k_CTYPE[] = "CTYPE";
1800 static const char __pyx_k_DTYPE[] = "DTYPE";
1801 static const char __pyx_k_H_ops[] = "H_ops";
1802 static const char __pyx_k_ITYPE[] = "ITYPE";
1803 static const char __pyx_k_alpha[] = "alpha";
1804 static const char __pyx_k_int32[] = "int32";
1805 static const char __pyx_k_int64[] = "int64";
1806 static const char __pyx_k_numpy[] = "numpy";
1807 static const char __pyx_k_range[] = "range";
1808 static const char __pyx_k_shape[] = "shape";
1809 static const char __pyx_k_tocsr[] = "tocsr";
1810 static const char __pyx_k_u_max[] = "u_max";
1811 static const char __pyx_k_u_min[] = "u_min";
1812 static const char __pyx_k_import[] = "__import__";
1813 static const char __pyx_k_indptr[] = "indptr";
1814 static const char __pyx_k_float64[] = "float64";
1815 static const char __pyx_k_indices[] = "indices";
1816 static const char __pyx_k_U_b_list[] = "U_b_list";
1817 static const char __pyx_k_U_f_list[] = "U_f_list";
1818 static const char __pyx_k_complex128[] = "complex128";
1819 static const char __pyx_k_ImportError[] = "ImportError";
1820 static const char __pyx_k_use_u_limits[] = "use_u_limits";
1821 static const char __pyx_k_phase_sensitive[] = "phase_sensitive";
1822 static const char __pyx_k_cline_in_traceback[] = "cline_in_traceback";
1823 static const char __pyx_k_numpy_core_multiarray_failed_to[] = "numpy.core.multiarray failed to import";
1824 static const char __pyx_k_numpy_core_umath_failed_to_impor[] = "numpy.core.umath failed to import";
1825 static PyObject *__pyx_n_s_CTYPE;
1826 static PyObject *__pyx_n_s_DTYPE;
1827 static PyObject *__pyx_n_s_H_ops;
1828 static PyObject *__pyx_n_s_ITYPE;
1829 static PyObject *__pyx_n_s_ImportError;
1830 static PyObject *__pyx_n_s_J;
1831 static PyObject *__pyx_n_s_M;
1832 static PyObject *__pyx_n_s_T;
1833 static PyObject *__pyx_n_s_U;
1834 static PyObject *__pyx_n_s_U_b_list;
1835 static PyObject *__pyx_n_s_U_f_list;
1836 static PyObject *__pyx_n_s_alpha;
1837 static PyObject *__pyx_n_s_beta;
1838 static PyObject *__pyx_n_s_cline_in_traceback;
1839 static PyObject *__pyx_n_s_complex128;
1840 static PyObject *__pyx_n_s_conj;
1841 static PyObject *__pyx_n_s_data;
1842 static PyObject *__pyx_n_s_dt;
1843 static PyObject *__pyx_n_s_eps;
1844 static PyObject *__pyx_n_s_float64;
1845 static PyObject *__pyx_n_s_import;
1846 static PyObject *__pyx_n_s_indices;
1847 static PyObject *__pyx_n_s_indptr;
1848 static PyObject *__pyx_n_s_int32;
1849 static PyObject *__pyx_n_s_int64;
1850 static PyObject *__pyx_n_s_main;
1851 static PyObject *__pyx_n_s_name;
1852 static PyObject *__pyx_n_s_np;
1853 static PyObject *__pyx_n_s_numpy;
1854 static PyObject *__pyx_kp_u_numpy_core_multiarray_failed_to;
1855 static PyObject *__pyx_kp_u_numpy_core_umath_failed_to_impor;
1856 static PyObject *__pyx_n_s_op1;
1857 static PyObject *__pyx_n_s_op2;
1858 static PyObject *__pyx_n_s_phase_sensitive;
1859 static PyObject *__pyx_n_s_r;
1860 static PyObject *__pyx_n_s_range;
1861 static PyObject *__pyx_n_s_real;
1862 static PyObject *__pyx_n_s_shape;
1863 static PyObject *__pyx_n_s_test;
1864 static PyObject *__pyx_n_s_tocsr;
1865 static PyObject *__pyx_n_s_u;
1866 static PyObject *__pyx_n_s_u_max;
1867 static PyObject *__pyx_n_s_u_min;
1868 static PyObject *__pyx_n_s_use_u_limits;
1869 static PyObject *__pyx_pf_5qutip_7control_8cy_grape_cy_overlap(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_op1, PyObject *__pyx_v_op2); /* proto */
1870 static PyObject *__pyx_pf_5qutip_7control_8cy_grape_2cy_grape_inner(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_U, PyArrayObject *__pyx_v_u, int __pyx_v_r, int __pyx_v_J, int __pyx_v_M, PyObject *__pyx_v_U_b_list, PyObject *__pyx_v_U_f_list, PyObject *__pyx_v_H_ops, float __pyx_v_dt, float __pyx_v_eps, float __pyx_v_alpha, float __pyx_v_beta, int __pyx_v_phase_sensitive, int __pyx_v_use_u_limits, float __pyx_v_u_min, float __pyx_v_u_max); /* proto */
1871 static PyObject *__pyx_int_2;
1872 static PyObject *__pyx_tuple_;
1873 static PyObject *__pyx_tuple__2;
1874 /* Late includes */
1875 
1876 /* "qutip/control/cy_grape.pyx":53
1877  * @cython.boundscheck(False)
1878  * @cython.wraparound(False)
1879  * cpdef CTYPE_t cy_overlap(object op1, object op2):             # <<<<<<<<<<<<<<
1880  *
1881  *     cdef Py_ssize_t row
1882  */
1883 
1884 static PyObject *__pyx_pw_5qutip_7control_8cy_grape_1cy_overlap(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
__pyx_f_5qutip_7control_8cy_grape_cy_overlap(PyObject * __pyx_v_op1,PyObject * __pyx_v_op2,CYTHON_UNUSED int __pyx_skip_dispatch)1885 static __pyx_t_double_complex __pyx_f_5qutip_7control_8cy_grape_cy_overlap(PyObject *__pyx_v_op1, PyObject *__pyx_v_op2, CYTHON_UNUSED int __pyx_skip_dispatch) {
1886   Py_ssize_t __pyx_v_row;
1887   __pyx_t_double_complex __pyx_v_tr;
1888   int __pyx_v_col1;
1889   int __pyx_v_row1_idx_start;
1890   int __pyx_v_row1_idx_end;
1891   PyArrayObject *__pyx_v_data1 = 0;
1892   PyArrayObject *__pyx_v_idx1 = 0;
1893   PyArrayObject *__pyx_v_ptr1 = 0;
1894   int __pyx_v_col2;
1895   int __pyx_v_row2_idx_start;
1896   int __pyx_v_row2_idx_end;
1897   PyArrayObject *__pyx_v_data2 = 0;
1898   PyArrayObject *__pyx_v_idx2 = 0;
1899   PyArrayObject *__pyx_v_ptr2 = 0;
1900   int __pyx_v_num_rows;
1901   int __pyx_v_row1_idx;
1902   int __pyx_v_row2_idx;
1903   __Pyx_LocalBuf_ND __pyx_pybuffernd_data1;
1904   __Pyx_Buffer __pyx_pybuffer_data1;
1905   __Pyx_LocalBuf_ND __pyx_pybuffernd_data2;
1906   __Pyx_Buffer __pyx_pybuffer_data2;
1907   __Pyx_LocalBuf_ND __pyx_pybuffernd_idx1;
1908   __Pyx_Buffer __pyx_pybuffer_idx1;
1909   __Pyx_LocalBuf_ND __pyx_pybuffernd_idx2;
1910   __Pyx_Buffer __pyx_pybuffer_idx2;
1911   __Pyx_LocalBuf_ND __pyx_pybuffernd_ptr1;
1912   __Pyx_Buffer __pyx_pybuffer_ptr1;
1913   __Pyx_LocalBuf_ND __pyx_pybuffernd_ptr2;
1914   __Pyx_Buffer __pyx_pybuffer_ptr2;
1915   __pyx_t_double_complex __pyx_r;
1916   __Pyx_RefNannyDeclarations
1917   PyObject *__pyx_t_1 = NULL;
1918   PyObject *__pyx_t_2 = NULL;
1919   PyObject *__pyx_t_3 = NULL;
1920   PyArrayObject *__pyx_t_4 = NULL;
1921   PyArrayObject *__pyx_t_5 = NULL;
1922   PyArrayObject *__pyx_t_6 = NULL;
1923   PyArrayObject *__pyx_t_7 = NULL;
1924   PyArrayObject *__pyx_t_8 = NULL;
1925   PyArrayObject *__pyx_t_9 = NULL;
1926   int __pyx_t_10;
1927   int __pyx_t_11;
1928   Py_ssize_t __pyx_t_12;
1929   Py_ssize_t __pyx_t_13;
1930   int __pyx_t_14;
1931   int __pyx_t_15;
1932   int __pyx_t_16;
1933   Py_ssize_t __pyx_t_17;
1934   __pyx_t_double_complex __pyx_t_18;
1935   int __pyx_lineno = 0;
1936   const char *__pyx_filename = NULL;
1937   int __pyx_clineno = 0;
1938   __Pyx_RefNannySetupContext("cy_overlap", 0);
1939   __Pyx_INCREF(__pyx_v_op1);
1940   __pyx_pybuffer_data1.pybuffer.buf = NULL;
1941   __pyx_pybuffer_data1.refcount = 0;
1942   __pyx_pybuffernd_data1.data = NULL;
1943   __pyx_pybuffernd_data1.rcbuffer = &__pyx_pybuffer_data1;
1944   __pyx_pybuffer_idx1.pybuffer.buf = NULL;
1945   __pyx_pybuffer_idx1.refcount = 0;
1946   __pyx_pybuffernd_idx1.data = NULL;
1947   __pyx_pybuffernd_idx1.rcbuffer = &__pyx_pybuffer_idx1;
1948   __pyx_pybuffer_ptr1.pybuffer.buf = NULL;
1949   __pyx_pybuffer_ptr1.refcount = 0;
1950   __pyx_pybuffernd_ptr1.data = NULL;
1951   __pyx_pybuffernd_ptr1.rcbuffer = &__pyx_pybuffer_ptr1;
1952   __pyx_pybuffer_data2.pybuffer.buf = NULL;
1953   __pyx_pybuffer_data2.refcount = 0;
1954   __pyx_pybuffernd_data2.data = NULL;
1955   __pyx_pybuffernd_data2.rcbuffer = &__pyx_pybuffer_data2;
1956   __pyx_pybuffer_idx2.pybuffer.buf = NULL;
1957   __pyx_pybuffer_idx2.refcount = 0;
1958   __pyx_pybuffernd_idx2.data = NULL;
1959   __pyx_pybuffernd_idx2.rcbuffer = &__pyx_pybuffer_idx2;
1960   __pyx_pybuffer_ptr2.pybuffer.buf = NULL;
1961   __pyx_pybuffer_ptr2.refcount = 0;
1962   __pyx_pybuffernd_ptr2.data = NULL;
1963   __pyx_pybuffernd_ptr2.rcbuffer = &__pyx_pybuffer_ptr2;
1964 
1965   /* "qutip/control/cy_grape.pyx":56
1966  *
1967  *     cdef Py_ssize_t row
1968  *     cdef CTYPE_t tr = 0.0             # <<<<<<<<<<<<<<
1969  *
1970  *     op1 = op1.T.tocsr()
1971  */
1972   __pyx_v_tr = __pyx_t_double_complex_from_parts(0.0, 0);
1973 
1974   /* "qutip/control/cy_grape.pyx":58
1975  *     cdef CTYPE_t tr = 0.0
1976  *
1977  *     op1 = op1.T.tocsr()             # <<<<<<<<<<<<<<
1978  *
1979  *     cdef int col1, row1_idx_start, row1_idx_end
1980  */
1981   __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_op1, __pyx_n_s_T); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 58, __pyx_L1_error)
1982   __Pyx_GOTREF(__pyx_t_2);
1983   __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_tocsr); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 58, __pyx_L1_error)
1984   __Pyx_GOTREF(__pyx_t_3);
1985   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
1986   __pyx_t_2 = NULL;
1987   if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) {
1988     __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3);
1989     if (likely(__pyx_t_2)) {
1990       PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
1991       __Pyx_INCREF(__pyx_t_2);
1992       __Pyx_INCREF(function);
1993       __Pyx_DECREF_SET(__pyx_t_3, function);
1994     }
1995   }
1996   __pyx_t_1 = (__pyx_t_2) ? __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_2) : __Pyx_PyObject_CallNoArg(__pyx_t_3);
1997   __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
1998   if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 58, __pyx_L1_error)
1999   __Pyx_GOTREF(__pyx_t_1);
2000   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
2001   __Pyx_DECREF_SET(__pyx_v_op1, __pyx_t_1);
2002   __pyx_t_1 = 0;
2003 
2004   /* "qutip/control/cy_grape.pyx":61
2005  *
2006  *     cdef int col1, row1_idx_start, row1_idx_end
2007  *     cdef np.ndarray[CTYPE_t, ndim=1, mode="c"] data1 = op1.data.conj()             # <<<<<<<<<<<<<<
2008  *     cdef np.ndarray[ITYPE_t, ndim=1, mode="c"] idx1 = op1.indices
2009  *     cdef np.ndarray[ITYPE_t, ndim=1, mode="c"] ptr1 = op1.indptr
2010  */
2011   __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_op1, __pyx_n_s_data); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 61, __pyx_L1_error)
2012   __Pyx_GOTREF(__pyx_t_3);
2013   __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_conj); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 61, __pyx_L1_error)
2014   __Pyx_GOTREF(__pyx_t_2);
2015   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
2016   __pyx_t_3 = NULL;
2017   if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
2018     __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
2019     if (likely(__pyx_t_3)) {
2020       PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
2021       __Pyx_INCREF(__pyx_t_3);
2022       __Pyx_INCREF(function);
2023       __Pyx_DECREF_SET(__pyx_t_2, function);
2024     }
2025   }
2026   __pyx_t_1 = (__pyx_t_3) ? __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3) : __Pyx_PyObject_CallNoArg(__pyx_t_2);
2027   __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
2028   if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 61, __pyx_L1_error)
2029   __Pyx_GOTREF(__pyx_t_1);
2030   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
2031   if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 61, __pyx_L1_error)
2032   __pyx_t_4 = ((PyArrayObject *)__pyx_t_1);
2033   {
2034     __Pyx_BufFmt_StackElem __pyx_stack[1];
2035     if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_data1.rcbuffer->pybuffer, (PyObject*)__pyx_t_4, &__Pyx_TypeInfo___pyx_t_double_complex, PyBUF_FORMAT| PyBUF_C_CONTIGUOUS, 1, 0, __pyx_stack) == -1)) {
2036       __pyx_v_data1 = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_pybuffernd_data1.rcbuffer->pybuffer.buf = NULL;
2037       __PYX_ERR(0, 61, __pyx_L1_error)
2038     } else {__pyx_pybuffernd_data1.diminfo[0].strides = __pyx_pybuffernd_data1.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_data1.diminfo[0].shape = __pyx_pybuffernd_data1.rcbuffer->pybuffer.shape[0];
2039     }
2040   }
2041   __pyx_t_4 = 0;
2042   __pyx_v_data1 = ((PyArrayObject *)__pyx_t_1);
2043   __pyx_t_1 = 0;
2044 
2045   /* "qutip/control/cy_grape.pyx":62
2046  *     cdef int col1, row1_idx_start, row1_idx_end
2047  *     cdef np.ndarray[CTYPE_t, ndim=1, mode="c"] data1 = op1.data.conj()
2048  *     cdef np.ndarray[ITYPE_t, ndim=1, mode="c"] idx1 = op1.indices             # <<<<<<<<<<<<<<
2049  *     cdef np.ndarray[ITYPE_t, ndim=1, mode="c"] ptr1 = op1.indptr
2050  *
2051  */
2052   __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_op1, __pyx_n_s_indices); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 62, __pyx_L1_error)
2053   __Pyx_GOTREF(__pyx_t_1);
2054   if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 62, __pyx_L1_error)
2055   __pyx_t_5 = ((PyArrayObject *)__pyx_t_1);
2056   {
2057     __Pyx_BufFmt_StackElem __pyx_stack[1];
2058     if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_idx1.rcbuffer->pybuffer, (PyObject*)__pyx_t_5, &__Pyx_TypeInfo_nn___pyx_t_5qutip_7control_8cy_grape_ITYPE_t, PyBUF_FORMAT| PyBUF_C_CONTIGUOUS, 1, 0, __pyx_stack) == -1)) {
2059       __pyx_v_idx1 = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_pybuffernd_idx1.rcbuffer->pybuffer.buf = NULL;
2060       __PYX_ERR(0, 62, __pyx_L1_error)
2061     } else {__pyx_pybuffernd_idx1.diminfo[0].strides = __pyx_pybuffernd_idx1.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_idx1.diminfo[0].shape = __pyx_pybuffernd_idx1.rcbuffer->pybuffer.shape[0];
2062     }
2063   }
2064   __pyx_t_5 = 0;
2065   __pyx_v_idx1 = ((PyArrayObject *)__pyx_t_1);
2066   __pyx_t_1 = 0;
2067 
2068   /* "qutip/control/cy_grape.pyx":63
2069  *     cdef np.ndarray[CTYPE_t, ndim=1, mode="c"] data1 = op1.data.conj()
2070  *     cdef np.ndarray[ITYPE_t, ndim=1, mode="c"] idx1 = op1.indices
2071  *     cdef np.ndarray[ITYPE_t, ndim=1, mode="c"] ptr1 = op1.indptr             # <<<<<<<<<<<<<<
2072  *
2073  *     cdef int col2, row2_idx_start, row2_idx_end
2074  */
2075   __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_op1, __pyx_n_s_indptr); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 63, __pyx_L1_error)
2076   __Pyx_GOTREF(__pyx_t_1);
2077   if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 63, __pyx_L1_error)
2078   __pyx_t_6 = ((PyArrayObject *)__pyx_t_1);
2079   {
2080     __Pyx_BufFmt_StackElem __pyx_stack[1];
2081     if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_ptr1.rcbuffer->pybuffer, (PyObject*)__pyx_t_6, &__Pyx_TypeInfo_nn___pyx_t_5qutip_7control_8cy_grape_ITYPE_t, PyBUF_FORMAT| PyBUF_C_CONTIGUOUS, 1, 0, __pyx_stack) == -1)) {
2082       __pyx_v_ptr1 = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_pybuffernd_ptr1.rcbuffer->pybuffer.buf = NULL;
2083       __PYX_ERR(0, 63, __pyx_L1_error)
2084     } else {__pyx_pybuffernd_ptr1.diminfo[0].strides = __pyx_pybuffernd_ptr1.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_ptr1.diminfo[0].shape = __pyx_pybuffernd_ptr1.rcbuffer->pybuffer.shape[0];
2085     }
2086   }
2087   __pyx_t_6 = 0;
2088   __pyx_v_ptr1 = ((PyArrayObject *)__pyx_t_1);
2089   __pyx_t_1 = 0;
2090 
2091   /* "qutip/control/cy_grape.pyx":66
2092  *
2093  *     cdef int col2, row2_idx_start, row2_idx_end
2094  *     cdef np.ndarray[CTYPE_t, ndim=1, mode="c"] data2 = op2.data             # <<<<<<<<<<<<<<
2095  *     cdef np.ndarray[ITYPE_t, ndim=1, mode="c"] idx2 = op2.indices
2096  *     cdef np.ndarray[ITYPE_t, ndim=1, mode="c"] ptr2 = op2.indptr
2097  */
2098   __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_op2, __pyx_n_s_data); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 66, __pyx_L1_error)
2099   __Pyx_GOTREF(__pyx_t_1);
2100   if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 66, __pyx_L1_error)
2101   __pyx_t_7 = ((PyArrayObject *)__pyx_t_1);
2102   {
2103     __Pyx_BufFmt_StackElem __pyx_stack[1];
2104     if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_data2.rcbuffer->pybuffer, (PyObject*)__pyx_t_7, &__Pyx_TypeInfo___pyx_t_double_complex, PyBUF_FORMAT| PyBUF_C_CONTIGUOUS, 1, 0, __pyx_stack) == -1)) {
2105       __pyx_v_data2 = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_pybuffernd_data2.rcbuffer->pybuffer.buf = NULL;
2106       __PYX_ERR(0, 66, __pyx_L1_error)
2107     } else {__pyx_pybuffernd_data2.diminfo[0].strides = __pyx_pybuffernd_data2.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_data2.diminfo[0].shape = __pyx_pybuffernd_data2.rcbuffer->pybuffer.shape[0];
2108     }
2109   }
2110   __pyx_t_7 = 0;
2111   __pyx_v_data2 = ((PyArrayObject *)__pyx_t_1);
2112   __pyx_t_1 = 0;
2113 
2114   /* "qutip/control/cy_grape.pyx":67
2115  *     cdef int col2, row2_idx_start, row2_idx_end
2116  *     cdef np.ndarray[CTYPE_t, ndim=1, mode="c"] data2 = op2.data
2117  *     cdef np.ndarray[ITYPE_t, ndim=1, mode="c"] idx2 = op2.indices             # <<<<<<<<<<<<<<
2118  *     cdef np.ndarray[ITYPE_t, ndim=1, mode="c"] ptr2 = op2.indptr
2119  *
2120  */
2121   __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_op2, __pyx_n_s_indices); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 67, __pyx_L1_error)
2122   __Pyx_GOTREF(__pyx_t_1);
2123   if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 67, __pyx_L1_error)
2124   __pyx_t_8 = ((PyArrayObject *)__pyx_t_1);
2125   {
2126     __Pyx_BufFmt_StackElem __pyx_stack[1];
2127     if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_idx2.rcbuffer->pybuffer, (PyObject*)__pyx_t_8, &__Pyx_TypeInfo_nn___pyx_t_5qutip_7control_8cy_grape_ITYPE_t, PyBUF_FORMAT| PyBUF_C_CONTIGUOUS, 1, 0, __pyx_stack) == -1)) {
2128       __pyx_v_idx2 = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_pybuffernd_idx2.rcbuffer->pybuffer.buf = NULL;
2129       __PYX_ERR(0, 67, __pyx_L1_error)
2130     } else {__pyx_pybuffernd_idx2.diminfo[0].strides = __pyx_pybuffernd_idx2.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_idx2.diminfo[0].shape = __pyx_pybuffernd_idx2.rcbuffer->pybuffer.shape[0];
2131     }
2132   }
2133   __pyx_t_8 = 0;
2134   __pyx_v_idx2 = ((PyArrayObject *)__pyx_t_1);
2135   __pyx_t_1 = 0;
2136 
2137   /* "qutip/control/cy_grape.pyx":68
2138  *     cdef np.ndarray[CTYPE_t, ndim=1, mode="c"] data2 = op2.data
2139  *     cdef np.ndarray[ITYPE_t, ndim=1, mode="c"] idx2 = op2.indices
2140  *     cdef np.ndarray[ITYPE_t, ndim=1, mode="c"] ptr2 = op2.indptr             # <<<<<<<<<<<<<<
2141  *
2142  *     cdef int num_rows = ptr1.shape[0]-1
2143  */
2144   __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_op2, __pyx_n_s_indptr); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 68, __pyx_L1_error)
2145   __Pyx_GOTREF(__pyx_t_1);
2146   if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 68, __pyx_L1_error)
2147   __pyx_t_9 = ((PyArrayObject *)__pyx_t_1);
2148   {
2149     __Pyx_BufFmt_StackElem __pyx_stack[1];
2150     if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_ptr2.rcbuffer->pybuffer, (PyObject*)__pyx_t_9, &__Pyx_TypeInfo_nn___pyx_t_5qutip_7control_8cy_grape_ITYPE_t, PyBUF_FORMAT| PyBUF_C_CONTIGUOUS, 1, 0, __pyx_stack) == -1)) {
2151       __pyx_v_ptr2 = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_pybuffernd_ptr2.rcbuffer->pybuffer.buf = NULL;
2152       __PYX_ERR(0, 68, __pyx_L1_error)
2153     } else {__pyx_pybuffernd_ptr2.diminfo[0].strides = __pyx_pybuffernd_ptr2.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_ptr2.diminfo[0].shape = __pyx_pybuffernd_ptr2.rcbuffer->pybuffer.shape[0];
2154     }
2155   }
2156   __pyx_t_9 = 0;
2157   __pyx_v_ptr2 = ((PyArrayObject *)__pyx_t_1);
2158   __pyx_t_1 = 0;
2159 
2160   /* "qutip/control/cy_grape.pyx":70
2161  *     cdef np.ndarray[ITYPE_t, ndim=1, mode="c"] ptr2 = op2.indptr
2162  *
2163  *     cdef int num_rows = ptr1.shape[0]-1             # <<<<<<<<<<<<<<
2164  *
2165  *     for row in range(num_rows):
2166  */
2167   __pyx_v_num_rows = ((__pyx_v_ptr1->dimensions[0]) - 1);
2168 
2169   /* "qutip/control/cy_grape.pyx":72
2170  *     cdef int num_rows = ptr1.shape[0]-1
2171  *
2172  *     for row in range(num_rows):             # <<<<<<<<<<<<<<
2173  *
2174  *         row1_idx_start = ptr1[row]
2175  */
2176   __pyx_t_10 = __pyx_v_num_rows;
2177   __pyx_t_11 = __pyx_t_10;
2178   for (__pyx_t_12 = 0; __pyx_t_12 < __pyx_t_11; __pyx_t_12+=1) {
2179     __pyx_v_row = __pyx_t_12;
2180 
2181     /* "qutip/control/cy_grape.pyx":74
2182  *     for row in range(num_rows):
2183  *
2184  *         row1_idx_start = ptr1[row]             # <<<<<<<<<<<<<<
2185  *         row1_idx_end = ptr1[row + 1]
2186  *         for row1_idx from row1_idx_start <= row1_idx < row1_idx_end:
2187  */
2188     __pyx_t_13 = __pyx_v_row;
2189     __pyx_v_row1_idx_start = (*__Pyx_BufPtrCContig1d(__pyx_t_5qutip_7control_8cy_grape_ITYPE_t *, __pyx_pybuffernd_ptr1.rcbuffer->pybuffer.buf, __pyx_t_13, __pyx_pybuffernd_ptr1.diminfo[0].strides));
2190 
2191     /* "qutip/control/cy_grape.pyx":75
2192  *
2193  *         row1_idx_start = ptr1[row]
2194  *         row1_idx_end = ptr1[row + 1]             # <<<<<<<<<<<<<<
2195  *         for row1_idx from row1_idx_start <= row1_idx < row1_idx_end:
2196  *             col1 = idx1[row1_idx]
2197  */
2198     __pyx_t_13 = (__pyx_v_row + 1);
2199     __pyx_v_row1_idx_end = (*__Pyx_BufPtrCContig1d(__pyx_t_5qutip_7control_8cy_grape_ITYPE_t *, __pyx_pybuffernd_ptr1.rcbuffer->pybuffer.buf, __pyx_t_13, __pyx_pybuffernd_ptr1.diminfo[0].strides));
2200 
2201     /* "qutip/control/cy_grape.pyx":76
2202  *         row1_idx_start = ptr1[row]
2203  *         row1_idx_end = ptr1[row + 1]
2204  *         for row1_idx from row1_idx_start <= row1_idx < row1_idx_end:             # <<<<<<<<<<<<<<
2205  *             col1 = idx1[row1_idx]
2206  *
2207  */
2208     __pyx_t_14 = __pyx_v_row1_idx_end;
2209     for (__pyx_v_row1_idx = __pyx_v_row1_idx_start; __pyx_v_row1_idx < __pyx_t_14; __pyx_v_row1_idx++) {
2210 
2211       /* "qutip/control/cy_grape.pyx":77
2212  *         row1_idx_end = ptr1[row + 1]
2213  *         for row1_idx from row1_idx_start <= row1_idx < row1_idx_end:
2214  *             col1 = idx1[row1_idx]             # <<<<<<<<<<<<<<
2215  *
2216  *             row2_idx_start = ptr2[col1]
2217  */
2218       __pyx_t_13 = __pyx_v_row1_idx;
2219       __pyx_v_col1 = (*__Pyx_BufPtrCContig1d(__pyx_t_5qutip_7control_8cy_grape_ITYPE_t *, __pyx_pybuffernd_idx1.rcbuffer->pybuffer.buf, __pyx_t_13, __pyx_pybuffernd_idx1.diminfo[0].strides));
2220 
2221       /* "qutip/control/cy_grape.pyx":79
2222  *             col1 = idx1[row1_idx]
2223  *
2224  *             row2_idx_start = ptr2[col1]             # <<<<<<<<<<<<<<
2225  *             row2_idx_end = ptr2[col1 + 1]
2226  *             for row2_idx from row2_idx_start <= row2_idx < row2_idx_end:
2227  */
2228       __pyx_t_13 = __pyx_v_col1;
2229       __pyx_v_row2_idx_start = (*__Pyx_BufPtrCContig1d(__pyx_t_5qutip_7control_8cy_grape_ITYPE_t *, __pyx_pybuffernd_ptr2.rcbuffer->pybuffer.buf, __pyx_t_13, __pyx_pybuffernd_ptr2.diminfo[0].strides));
2230 
2231       /* "qutip/control/cy_grape.pyx":80
2232  *
2233  *             row2_idx_start = ptr2[col1]
2234  *             row2_idx_end = ptr2[col1 + 1]             # <<<<<<<<<<<<<<
2235  *             for row2_idx from row2_idx_start <= row2_idx < row2_idx_end:
2236  *                 col2 = idx2[row2_idx]
2237  */
2238       __pyx_t_13 = (__pyx_v_col1 + 1);
2239       __pyx_v_row2_idx_end = (*__Pyx_BufPtrCContig1d(__pyx_t_5qutip_7control_8cy_grape_ITYPE_t *, __pyx_pybuffernd_ptr2.rcbuffer->pybuffer.buf, __pyx_t_13, __pyx_pybuffernd_ptr2.diminfo[0].strides));
2240 
2241       /* "qutip/control/cy_grape.pyx":81
2242  *             row2_idx_start = ptr2[col1]
2243  *             row2_idx_end = ptr2[col1 + 1]
2244  *             for row2_idx from row2_idx_start <= row2_idx < row2_idx_end:             # <<<<<<<<<<<<<<
2245  *                 col2 = idx2[row2_idx]
2246  *
2247  */
2248       __pyx_t_15 = __pyx_v_row2_idx_end;
2249       for (__pyx_v_row2_idx = __pyx_v_row2_idx_start; __pyx_v_row2_idx < __pyx_t_15; __pyx_v_row2_idx++) {
2250 
2251         /* "qutip/control/cy_grape.pyx":82
2252  *             row2_idx_end = ptr2[col1 + 1]
2253  *             for row2_idx from row2_idx_start <= row2_idx < row2_idx_end:
2254  *                 col2 = idx2[row2_idx]             # <<<<<<<<<<<<<<
2255  *
2256  *                 if col2 == row:
2257  */
2258         __pyx_t_13 = __pyx_v_row2_idx;
2259         __pyx_v_col2 = (*__Pyx_BufPtrCContig1d(__pyx_t_5qutip_7control_8cy_grape_ITYPE_t *, __pyx_pybuffernd_idx2.rcbuffer->pybuffer.buf, __pyx_t_13, __pyx_pybuffernd_idx2.diminfo[0].strides));
2260 
2261         /* "qutip/control/cy_grape.pyx":84
2262  *                 col2 = idx2[row2_idx]
2263  *
2264  *                 if col2 == row:             # <<<<<<<<<<<<<<
2265  *                     tr += data1[row1_idx] * data2[row2_idx]
2266  *
2267  */
2268         __pyx_t_16 = ((__pyx_v_col2 == __pyx_v_row) != 0);
2269         if (__pyx_t_16) {
2270 
2271           /* "qutip/control/cy_grape.pyx":85
2272  *
2273  *                 if col2 == row:
2274  *                     tr += data1[row1_idx] * data2[row2_idx]             # <<<<<<<<<<<<<<
2275  *
2276  *     return tr / op1.shape[0]
2277  */
2278           __pyx_t_13 = __pyx_v_row1_idx;
2279           __pyx_t_17 = __pyx_v_row2_idx;
2280           __pyx_v_tr = __Pyx_c_sum_double(__pyx_v_tr, __Pyx_c_prod_double((*__Pyx_BufPtrCContig1d(__pyx_t_double_complex *, __pyx_pybuffernd_data1.rcbuffer->pybuffer.buf, __pyx_t_13, __pyx_pybuffernd_data1.diminfo[0].strides)), (*__Pyx_BufPtrCContig1d(__pyx_t_double_complex *, __pyx_pybuffernd_data2.rcbuffer->pybuffer.buf, __pyx_t_17, __pyx_pybuffernd_data2.diminfo[0].strides))));
2281 
2282           /* "qutip/control/cy_grape.pyx":84
2283  *                 col2 = idx2[row2_idx]
2284  *
2285  *                 if col2 == row:             # <<<<<<<<<<<<<<
2286  *                     tr += data1[row1_idx] * data2[row2_idx]
2287  *
2288  */
2289         }
2290       }
2291     }
2292   }
2293 
2294   /* "qutip/control/cy_grape.pyx":87
2295  *                     tr += data1[row1_idx] * data2[row2_idx]
2296  *
2297  *     return tr / op1.shape[0]             # <<<<<<<<<<<<<<
2298  *
2299  *
2300  */
2301   __pyx_t_1 = __pyx_PyComplex_FromComplex(__pyx_v_tr); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 87, __pyx_L1_error)
2302   __Pyx_GOTREF(__pyx_t_1);
2303   __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_op1, __pyx_n_s_shape); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 87, __pyx_L1_error)
2304   __Pyx_GOTREF(__pyx_t_2);
2305   __pyx_t_3 = __Pyx_GetItemInt(__pyx_t_2, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 87, __pyx_L1_error)
2306   __Pyx_GOTREF(__pyx_t_3);
2307   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
2308   __pyx_t_2 = __Pyx_PyNumber_Divide(__pyx_t_1, __pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 87, __pyx_L1_error)
2309   __Pyx_GOTREF(__pyx_t_2);
2310   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
2311   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
2312   __pyx_t_18 = __Pyx_PyComplex_As___pyx_t_double_complex(__pyx_t_2); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 87, __pyx_L1_error)
2313   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
2314   __pyx_r = __pyx_t_18;
2315   goto __pyx_L0;
2316 
2317   /* "qutip/control/cy_grape.pyx":53
2318  * @cython.boundscheck(False)
2319  * @cython.wraparound(False)
2320  * cpdef CTYPE_t cy_overlap(object op1, object op2):             # <<<<<<<<<<<<<<
2321  *
2322  *     cdef Py_ssize_t row
2323  */
2324 
2325   /* function exit code */
2326   __pyx_L1_error:;
2327   __Pyx_XDECREF(__pyx_t_1);
2328   __Pyx_XDECREF(__pyx_t_2);
2329   __Pyx_XDECREF(__pyx_t_3);
2330   { PyObject *__pyx_type, *__pyx_value, *__pyx_tb;
2331     __Pyx_PyThreadState_declare
2332     __Pyx_PyThreadState_assign
2333     __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb);
2334     __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_data1.rcbuffer->pybuffer);
2335     __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_data2.rcbuffer->pybuffer);
2336     __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_idx1.rcbuffer->pybuffer);
2337     __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_idx2.rcbuffer->pybuffer);
2338     __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_ptr1.rcbuffer->pybuffer);
2339     __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_ptr2.rcbuffer->pybuffer);
2340   __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}
2341   __Pyx_WriteUnraisable("qutip.control.cy_grape.cy_overlap", __pyx_clineno, __pyx_lineno, __pyx_filename, 1, 0);
2342   __pyx_r = __pyx_t_double_complex_from_parts(0, 0);
2343   goto __pyx_L2;
2344   __pyx_L0:;
2345   __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_data1.rcbuffer->pybuffer);
2346   __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_data2.rcbuffer->pybuffer);
2347   __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_idx1.rcbuffer->pybuffer);
2348   __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_idx2.rcbuffer->pybuffer);
2349   __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_ptr1.rcbuffer->pybuffer);
2350   __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_ptr2.rcbuffer->pybuffer);
2351   __pyx_L2:;
2352   __Pyx_XDECREF((PyObject *)__pyx_v_data1);
2353   __Pyx_XDECREF((PyObject *)__pyx_v_idx1);
2354   __Pyx_XDECREF((PyObject *)__pyx_v_ptr1);
2355   __Pyx_XDECREF((PyObject *)__pyx_v_data2);
2356   __Pyx_XDECREF((PyObject *)__pyx_v_idx2);
2357   __Pyx_XDECREF((PyObject *)__pyx_v_ptr2);
2358   __Pyx_XDECREF(__pyx_v_op1);
2359   __Pyx_RefNannyFinishContext();
2360   return __pyx_r;
2361 }
2362 
2363 /* Python wrapper */
2364 static PyObject *__pyx_pw_5qutip_7control_8cy_grape_1cy_overlap(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
__pyx_pw_5qutip_7control_8cy_grape_1cy_overlap(PyObject * __pyx_self,PyObject * __pyx_args,PyObject * __pyx_kwds)2365 static PyObject *__pyx_pw_5qutip_7control_8cy_grape_1cy_overlap(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
2366   PyObject *__pyx_v_op1 = 0;
2367   PyObject *__pyx_v_op2 = 0;
2368   int __pyx_lineno = 0;
2369   const char *__pyx_filename = NULL;
2370   int __pyx_clineno = 0;
2371   PyObject *__pyx_r = 0;
2372   __Pyx_RefNannyDeclarations
2373   __Pyx_RefNannySetupContext("cy_overlap (wrapper)", 0);
2374   {
2375     static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_op1,&__pyx_n_s_op2,0};
2376     PyObject* values[2] = {0,0};
2377     if (unlikely(__pyx_kwds)) {
2378       Py_ssize_t kw_args;
2379       const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
2380       switch (pos_args) {
2381         case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
2382         CYTHON_FALLTHROUGH;
2383         case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
2384         CYTHON_FALLTHROUGH;
2385         case  0: break;
2386         default: goto __pyx_L5_argtuple_error;
2387       }
2388       kw_args = PyDict_Size(__pyx_kwds);
2389       switch (pos_args) {
2390         case  0:
2391         if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_op1)) != 0)) kw_args--;
2392         else goto __pyx_L5_argtuple_error;
2393         CYTHON_FALLTHROUGH;
2394         case  1:
2395         if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_op2)) != 0)) kw_args--;
2396         else {
2397           __Pyx_RaiseArgtupleInvalid("cy_overlap", 1, 2, 2, 1); __PYX_ERR(0, 53, __pyx_L3_error)
2398         }
2399       }
2400       if (unlikely(kw_args > 0)) {
2401         if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "cy_overlap") < 0)) __PYX_ERR(0, 53, __pyx_L3_error)
2402       }
2403     } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
2404       goto __pyx_L5_argtuple_error;
2405     } else {
2406       values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
2407       values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
2408     }
2409     __pyx_v_op1 = values[0];
2410     __pyx_v_op2 = values[1];
2411   }
2412   goto __pyx_L4_argument_unpacking_done;
2413   __pyx_L5_argtuple_error:;
2414   __Pyx_RaiseArgtupleInvalid("cy_overlap", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 53, __pyx_L3_error)
2415   __pyx_L3_error:;
2416   __Pyx_AddTraceback("qutip.control.cy_grape.cy_overlap", __pyx_clineno, __pyx_lineno, __pyx_filename);
2417   __Pyx_RefNannyFinishContext();
2418   return NULL;
2419   __pyx_L4_argument_unpacking_done:;
2420   __pyx_r = __pyx_pf_5qutip_7control_8cy_grape_cy_overlap(__pyx_self, __pyx_v_op1, __pyx_v_op2);
2421 
2422   /* function exit code */
2423   __Pyx_RefNannyFinishContext();
2424   return __pyx_r;
2425 }
2426 
__pyx_pf_5qutip_7control_8cy_grape_cy_overlap(CYTHON_UNUSED PyObject * __pyx_self,PyObject * __pyx_v_op1,PyObject * __pyx_v_op2)2427 static PyObject *__pyx_pf_5qutip_7control_8cy_grape_cy_overlap(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_op1, PyObject *__pyx_v_op2) {
2428   PyObject *__pyx_r = NULL;
2429   __Pyx_RefNannyDeclarations
2430   __pyx_t_double_complex __pyx_t_1;
2431   PyObject *__pyx_t_2 = NULL;
2432   int __pyx_lineno = 0;
2433   const char *__pyx_filename = NULL;
2434   int __pyx_clineno = 0;
2435   __Pyx_RefNannySetupContext("cy_overlap", 0);
2436   __Pyx_XDECREF(__pyx_r);
2437   __pyx_t_1 = __pyx_f_5qutip_7control_8cy_grape_cy_overlap(__pyx_v_op1, __pyx_v_op2, 0);
2438   __pyx_t_2 = __pyx_PyComplex_FromComplex(__pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 53, __pyx_L1_error)
2439   __Pyx_GOTREF(__pyx_t_2);
2440   __pyx_r = __pyx_t_2;
2441   __pyx_t_2 = 0;
2442   goto __pyx_L0;
2443 
2444   /* function exit code */
2445   __pyx_L1_error:;
2446   __Pyx_XDECREF(__pyx_t_2);
2447   __Pyx_AddTraceback("qutip.control.cy_grape.cy_overlap", __pyx_clineno, __pyx_lineno, __pyx_filename);
2448   __pyx_r = NULL;
2449   __pyx_L0:;
2450   __Pyx_XGIVEREF(__pyx_r);
2451   __Pyx_RefNannyFinishContext();
2452   return __pyx_r;
2453 }
2454 
2455 /* "qutip/control/cy_grape.pyx":92
2456  * @cython.boundscheck(False)
2457  * @cython.wraparound(False)
2458  * cpdef cy_grape_inner(U, np.ndarray[DTYPE_t, ndim=3, mode="c"] u,             # <<<<<<<<<<<<<<
2459  *                      int r, int J, int M, U_b_list, U_f_list, H_ops,
2460  *                      float dt, float eps, float alpha, float beta,
2461  */
2462 
2463 static PyObject *__pyx_pw_5qutip_7control_8cy_grape_3cy_grape_inner(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
__pyx_f_5qutip_7control_8cy_grape_cy_grape_inner(PyObject * __pyx_v_U,PyArrayObject * __pyx_v_u,int __pyx_v_r,int __pyx_v_J,int __pyx_v_M,PyObject * __pyx_v_U_b_list,PyObject * __pyx_v_U_f_list,PyObject * __pyx_v_H_ops,float __pyx_v_dt,float __pyx_v_eps,float __pyx_v_alpha,float __pyx_v_beta,int __pyx_v_phase_sensitive,int __pyx_v_use_u_limits,float __pyx_v_u_min,float __pyx_v_u_max,CYTHON_UNUSED int __pyx_skip_dispatch)2464 static PyObject *__pyx_f_5qutip_7control_8cy_grape_cy_grape_inner(PyObject *__pyx_v_U, PyArrayObject *__pyx_v_u, int __pyx_v_r, int __pyx_v_J, int __pyx_v_M, PyObject *__pyx_v_U_b_list, PyObject *__pyx_v_U_f_list, PyObject *__pyx_v_H_ops, float __pyx_v_dt, float __pyx_v_eps, float __pyx_v_alpha, float __pyx_v_beta, int __pyx_v_phase_sensitive, int __pyx_v_use_u_limits, float __pyx_v_u_min, float __pyx_v_u_max, CYTHON_UNUSED int __pyx_skip_dispatch) {
2465   int __pyx_v_j;
2466   PyObject *__pyx_v_m = NULL;
2467   PyObject *__pyx_v_P = NULL;
2468   PyObject *__pyx_v_Q = NULL;
2469   PyObject *__pyx_v_du = NULL;
2470   __Pyx_LocalBuf_ND __pyx_pybuffernd_u;
2471   __Pyx_Buffer __pyx_pybuffer_u;
2472   PyObject *__pyx_r = NULL;
2473   __Pyx_RefNannyDeclarations
2474   PyObject *__pyx_t_1 = NULL;
2475   PyObject *__pyx_t_2 = NULL;
2476   Py_ssize_t __pyx_t_3;
2477   PyObject *(*__pyx_t_4)(PyObject *);
2478   PyObject *__pyx_t_5 = NULL;
2479   int __pyx_t_6;
2480   int __pyx_t_7;
2481   int __pyx_t_8;
2482   __pyx_t_double_complex __pyx_t_9;
2483   PyObject *__pyx_t_10 = NULL;
2484   int __pyx_t_11;
2485   PyObject *__pyx_t_12 = NULL;
2486   Py_ssize_t __pyx_t_13;
2487   Py_ssize_t __pyx_t_14;
2488   Py_ssize_t __pyx_t_15;
2489   Py_ssize_t __pyx_t_16;
2490   Py_ssize_t __pyx_t_17;
2491   Py_ssize_t __pyx_t_18;
2492   int __pyx_lineno = 0;
2493   const char *__pyx_filename = NULL;
2494   int __pyx_clineno = 0;
2495   __Pyx_RefNannySetupContext("cy_grape_inner", 0);
2496   __pyx_pybuffer_u.pybuffer.buf = NULL;
2497   __pyx_pybuffer_u.refcount = 0;
2498   __pyx_pybuffernd_u.data = NULL;
2499   __pyx_pybuffernd_u.rcbuffer = &__pyx_pybuffer_u;
2500   {
2501     __Pyx_BufFmt_StackElem __pyx_stack[1];
2502     if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_u.rcbuffer->pybuffer, (PyObject*)__pyx_v_u, &__Pyx_TypeInfo_nn___pyx_t_5qutip_7control_8cy_grape_DTYPE_t, PyBUF_FORMAT| PyBUF_C_CONTIGUOUS| PyBUF_WRITABLE, 3, 0, __pyx_stack) == -1)) __PYX_ERR(0, 92, __pyx_L1_error)
2503   }
2504   __pyx_pybuffernd_u.diminfo[0].strides = __pyx_pybuffernd_u.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_u.diminfo[0].shape = __pyx_pybuffernd_u.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_u.diminfo[1].strides = __pyx_pybuffernd_u.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_u.diminfo[1].shape = __pyx_pybuffernd_u.rcbuffer->pybuffer.shape[1]; __pyx_pybuffernd_u.diminfo[2].strides = __pyx_pybuffernd_u.rcbuffer->pybuffer.strides[2]; __pyx_pybuffernd_u.diminfo[2].shape = __pyx_pybuffernd_u.rcbuffer->pybuffer.shape[2];
2505 
2506   /* "qutip/control/cy_grape.pyx":100
2507  *     cdef int j, k
2508  *
2509  *     for m in range(M-1):             # <<<<<<<<<<<<<<
2510  *         P = U_b_list[m] * U
2511  *         for j in range(J):
2512  */
2513   __pyx_t_1 = __Pyx_PyInt_From_long((__pyx_v_M - 1)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 100, __pyx_L1_error)
2514   __Pyx_GOTREF(__pyx_t_1);
2515   __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_builtin_range, __pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 100, __pyx_L1_error)
2516   __Pyx_GOTREF(__pyx_t_2);
2517   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
2518   if (likely(PyList_CheckExact(__pyx_t_2)) || PyTuple_CheckExact(__pyx_t_2)) {
2519     __pyx_t_1 = __pyx_t_2; __Pyx_INCREF(__pyx_t_1); __pyx_t_3 = 0;
2520     __pyx_t_4 = NULL;
2521   } else {
2522     __pyx_t_3 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 100, __pyx_L1_error)
2523     __Pyx_GOTREF(__pyx_t_1);
2524     __pyx_t_4 = Py_TYPE(__pyx_t_1)->tp_iternext; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 100, __pyx_L1_error)
2525   }
2526   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
2527   for (;;) {
2528     if (likely(!__pyx_t_4)) {
2529       if (likely(PyList_CheckExact(__pyx_t_1))) {
2530         if (__pyx_t_3 >= PyList_GET_SIZE(__pyx_t_1)) break;
2531         #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
2532         __pyx_t_2 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_3); __Pyx_INCREF(__pyx_t_2); __pyx_t_3++; if (unlikely(0 < 0)) __PYX_ERR(0, 100, __pyx_L1_error)
2533         #else
2534         __pyx_t_2 = PySequence_ITEM(__pyx_t_1, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 100, __pyx_L1_error)
2535         __Pyx_GOTREF(__pyx_t_2);
2536         #endif
2537       } else {
2538         if (__pyx_t_3 >= PyTuple_GET_SIZE(__pyx_t_1)) break;
2539         #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
2540         __pyx_t_2 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_3); __Pyx_INCREF(__pyx_t_2); __pyx_t_3++; if (unlikely(0 < 0)) __PYX_ERR(0, 100, __pyx_L1_error)
2541         #else
2542         __pyx_t_2 = PySequence_ITEM(__pyx_t_1, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 100, __pyx_L1_error)
2543         __Pyx_GOTREF(__pyx_t_2);
2544         #endif
2545       }
2546     } else {
2547       __pyx_t_2 = __pyx_t_4(__pyx_t_1);
2548       if (unlikely(!__pyx_t_2)) {
2549         PyObject* exc_type = PyErr_Occurred();
2550         if (exc_type) {
2551           if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
2552           else __PYX_ERR(0, 100, __pyx_L1_error)
2553         }
2554         break;
2555       }
2556       __Pyx_GOTREF(__pyx_t_2);
2557     }
2558     __Pyx_XDECREF_SET(__pyx_v_m, __pyx_t_2);
2559     __pyx_t_2 = 0;
2560 
2561     /* "qutip/control/cy_grape.pyx":101
2562  *
2563  *     for m in range(M-1):
2564  *         P = U_b_list[m] * U             # <<<<<<<<<<<<<<
2565  *         for j in range(J):
2566  *             Q = 1j * dt * H_ops[j] * U_f_list[m]
2567  */
2568     __pyx_t_2 = __Pyx_PyObject_GetItem(__pyx_v_U_b_list, __pyx_v_m); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 101, __pyx_L1_error)
2569     __Pyx_GOTREF(__pyx_t_2);
2570     __pyx_t_5 = PyNumber_Multiply(__pyx_t_2, __pyx_v_U); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 101, __pyx_L1_error)
2571     __Pyx_GOTREF(__pyx_t_5);
2572     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
2573     __Pyx_XDECREF_SET(__pyx_v_P, __pyx_t_5);
2574     __pyx_t_5 = 0;
2575 
2576     /* "qutip/control/cy_grape.pyx":102
2577  *     for m in range(M-1):
2578  *         P = U_b_list[m] * U
2579  *         for j in range(J):             # <<<<<<<<<<<<<<
2580  *             Q = 1j * dt * H_ops[j] * U_f_list[m]
2581  *
2582  */
2583     __pyx_t_6 = __pyx_v_J;
2584     __pyx_t_7 = __pyx_t_6;
2585     for (__pyx_t_8 = 0; __pyx_t_8 < __pyx_t_7; __pyx_t_8+=1) {
2586       __pyx_v_j = __pyx_t_8;
2587 
2588       /* "qutip/control/cy_grape.pyx":103
2589  *         P = U_b_list[m] * U
2590  *         for j in range(J):
2591  *             Q = 1j * dt * H_ops[j] * U_f_list[m]             # <<<<<<<<<<<<<<
2592  *
2593  *             if phase_sensitive:
2594  */
2595       __pyx_t_9 = __Pyx_c_prod_double(__pyx_t_double_complex_from_parts(0, 1.0), __pyx_t_double_complex_from_parts(__pyx_v_dt, 0));
2596       __pyx_t_5 = __pyx_PyComplex_FromComplex(__pyx_t_9); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 103, __pyx_L1_error)
2597       __Pyx_GOTREF(__pyx_t_5);
2598       __pyx_t_2 = __Pyx_GetItemInt(__pyx_v_H_ops, __pyx_v_j, int, 1, __Pyx_PyInt_From_int, 0, 0, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 103, __pyx_L1_error)
2599       __Pyx_GOTREF(__pyx_t_2);
2600       __pyx_t_10 = PyNumber_Multiply(__pyx_t_5, __pyx_t_2); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 103, __pyx_L1_error)
2601       __Pyx_GOTREF(__pyx_t_10);
2602       __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
2603       __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
2604       __pyx_t_2 = __Pyx_PyObject_GetItem(__pyx_v_U_f_list, __pyx_v_m); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 103, __pyx_L1_error)
2605       __Pyx_GOTREF(__pyx_t_2);
2606       __pyx_t_5 = PyNumber_Multiply(__pyx_t_10, __pyx_t_2); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 103, __pyx_L1_error)
2607       __Pyx_GOTREF(__pyx_t_5);
2608       __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
2609       __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
2610       __Pyx_XDECREF_SET(__pyx_v_Q, __pyx_t_5);
2611       __pyx_t_5 = 0;
2612 
2613       /* "qutip/control/cy_grape.pyx":105
2614  *             Q = 1j * dt * H_ops[j] * U_f_list[m]
2615  *
2616  *             if phase_sensitive:             # <<<<<<<<<<<<<<
2617  *                 du = - cy_overlap(P, Q)
2618  *             else:
2619  */
2620       __pyx_t_11 = (__pyx_v_phase_sensitive != 0);
2621       if (__pyx_t_11) {
2622 
2623         /* "qutip/control/cy_grape.pyx":106
2624  *
2625  *             if phase_sensitive:
2626  *                 du = - cy_overlap(P, Q)             # <<<<<<<<<<<<<<
2627  *             else:
2628  *                 du = - 2 * cy_overlap(P, Q) * cy_overlap(U_f_list[m], P)
2629  */
2630         __pyx_t_9 = __Pyx_c_neg_double(__pyx_f_5qutip_7control_8cy_grape_cy_overlap(__pyx_v_P, __pyx_v_Q, 0));
2631         __pyx_t_5 = __pyx_PyComplex_FromComplex(__pyx_t_9); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 106, __pyx_L1_error)
2632         __Pyx_GOTREF(__pyx_t_5);
2633         __Pyx_XDECREF_SET(__pyx_v_du, __pyx_t_5);
2634         __pyx_t_5 = 0;
2635 
2636         /* "qutip/control/cy_grape.pyx":105
2637  *             Q = 1j * dt * H_ops[j] * U_f_list[m]
2638  *
2639  *             if phase_sensitive:             # <<<<<<<<<<<<<<
2640  *                 du = - cy_overlap(P, Q)
2641  *             else:
2642  */
2643         goto __pyx_L7;
2644       }
2645 
2646       /* "qutip/control/cy_grape.pyx":108
2647  *                 du = - cy_overlap(P, Q)
2648  *             else:
2649  *                 du = - 2 * cy_overlap(P, Q) * cy_overlap(U_f_list[m], P)             # <<<<<<<<<<<<<<
2650  *
2651  *             if alpha > 0.0:
2652  */
2653       /*else*/ {
2654         __pyx_t_5 = __Pyx_PyObject_GetItem(__pyx_v_U_f_list, __pyx_v_m); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 108, __pyx_L1_error)
2655         __Pyx_GOTREF(__pyx_t_5);
2656         __pyx_t_9 = __Pyx_c_prod_double(__Pyx_c_prod_double(__pyx_t_double_complex_from_parts(-2L, 0), __pyx_f_5qutip_7control_8cy_grape_cy_overlap(__pyx_v_P, __pyx_v_Q, 0)), __pyx_f_5qutip_7control_8cy_grape_cy_overlap(__pyx_t_5, __pyx_v_P, 0));
2657         __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
2658         __pyx_t_5 = __pyx_PyComplex_FromComplex(__pyx_t_9); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 108, __pyx_L1_error)
2659         __Pyx_GOTREF(__pyx_t_5);
2660         __Pyx_XDECREF_SET(__pyx_v_du, __pyx_t_5);
2661         __pyx_t_5 = 0;
2662       }
2663       __pyx_L7:;
2664 
2665       /* "qutip/control/cy_grape.pyx":110
2666  *                 du = - 2 * cy_overlap(P, Q) * cy_overlap(U_f_list[m], P)
2667  *
2668  *             if alpha > 0.0:             # <<<<<<<<<<<<<<
2669  *                 # penalty term for high power control signals u
2670  *                 du += -2 * alpha * u[r, j, m] * dt
2671  */
2672       __pyx_t_11 = ((__pyx_v_alpha > 0.0) != 0);
2673       if (__pyx_t_11) {
2674 
2675         /* "qutip/control/cy_grape.pyx":112
2676  *             if alpha > 0.0:
2677  *                 # penalty term for high power control signals u
2678  *                 du += -2 * alpha * u[r, j, m] * dt             # <<<<<<<<<<<<<<
2679  *
2680  *             if beta:
2681  */
2682         __pyx_t_5 = PyFloat_FromDouble((-2.0 * __pyx_v_alpha)); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 112, __pyx_L1_error)
2683         __Pyx_GOTREF(__pyx_t_5);
2684         __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_r); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 112, __pyx_L1_error)
2685         __Pyx_GOTREF(__pyx_t_2);
2686         __pyx_t_10 = __Pyx_PyInt_From_int(__pyx_v_j); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 112, __pyx_L1_error)
2687         __Pyx_GOTREF(__pyx_t_10);
2688         __pyx_t_12 = PyTuple_New(3); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 112, __pyx_L1_error)
2689         __Pyx_GOTREF(__pyx_t_12);
2690         __Pyx_GIVEREF(__pyx_t_2);
2691         PyTuple_SET_ITEM(__pyx_t_12, 0, __pyx_t_2);
2692         __Pyx_GIVEREF(__pyx_t_10);
2693         PyTuple_SET_ITEM(__pyx_t_12, 1, __pyx_t_10);
2694         __Pyx_INCREF(__pyx_v_m);
2695         __Pyx_GIVEREF(__pyx_v_m);
2696         PyTuple_SET_ITEM(__pyx_t_12, 2, __pyx_v_m);
2697         __pyx_t_2 = 0;
2698         __pyx_t_10 = 0;
2699         __pyx_t_10 = __Pyx_PyObject_GetItem(((PyObject *)__pyx_v_u), __pyx_t_12); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 112, __pyx_L1_error)
2700         __Pyx_GOTREF(__pyx_t_10);
2701         __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
2702         __pyx_t_12 = PyNumber_Multiply(__pyx_t_5, __pyx_t_10); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 112, __pyx_L1_error)
2703         __Pyx_GOTREF(__pyx_t_12);
2704         __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
2705         __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
2706         __pyx_t_10 = PyFloat_FromDouble(__pyx_v_dt); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 112, __pyx_L1_error)
2707         __Pyx_GOTREF(__pyx_t_10);
2708         __pyx_t_5 = PyNumber_Multiply(__pyx_t_12, __pyx_t_10); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 112, __pyx_L1_error)
2709         __Pyx_GOTREF(__pyx_t_5);
2710         __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
2711         __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
2712         __pyx_t_10 = PyNumber_InPlaceAdd(__pyx_v_du, __pyx_t_5); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 112, __pyx_L1_error)
2713         __Pyx_GOTREF(__pyx_t_10);
2714         __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
2715         __Pyx_DECREF_SET(__pyx_v_du, __pyx_t_10);
2716         __pyx_t_10 = 0;
2717 
2718         /* "qutip/control/cy_grape.pyx":110
2719  *                 du = - 2 * cy_overlap(P, Q) * cy_overlap(U_f_list[m], P)
2720  *
2721  *             if alpha > 0.0:             # <<<<<<<<<<<<<<
2722  *                 # penalty term for high power control signals u
2723  *                 du += -2 * alpha * u[r, j, m] * dt
2724  */
2725       }
2726 
2727       /* "qutip/control/cy_grape.pyx":114
2728  *                 du += -2 * alpha * u[r, j, m] * dt
2729  *
2730  *             if beta:             # <<<<<<<<<<<<<<
2731  *                 # penalty term for late control signals u
2732  *                 du += -2 * beta * m ** 2 * u[r, j, m] * dt
2733  */
2734       __pyx_t_11 = (__pyx_v_beta != 0);
2735       if (__pyx_t_11) {
2736 
2737         /* "qutip/control/cy_grape.pyx":116
2738  *             if beta:
2739  *                 # penalty term for late control signals u
2740  *                 du += -2 * beta * m ** 2 * u[r, j, m] * dt             # <<<<<<<<<<<<<<
2741  *
2742  *             u[r + 1, j, m] = u[r, j, m] + eps * du.real
2743  */
2744         __pyx_t_10 = PyFloat_FromDouble((-2.0 * __pyx_v_beta)); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 116, __pyx_L1_error)
2745         __Pyx_GOTREF(__pyx_t_10);
2746         __pyx_t_5 = PyNumber_Power(__pyx_v_m, __pyx_int_2, Py_None); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 116, __pyx_L1_error)
2747         __Pyx_GOTREF(__pyx_t_5);
2748         __pyx_t_12 = PyNumber_Multiply(__pyx_t_10, __pyx_t_5); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 116, __pyx_L1_error)
2749         __Pyx_GOTREF(__pyx_t_12);
2750         __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
2751         __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
2752         __pyx_t_5 = __Pyx_PyInt_From_int(__pyx_v_r); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 116, __pyx_L1_error)
2753         __Pyx_GOTREF(__pyx_t_5);
2754         __pyx_t_10 = __Pyx_PyInt_From_int(__pyx_v_j); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 116, __pyx_L1_error)
2755         __Pyx_GOTREF(__pyx_t_10);
2756         __pyx_t_2 = PyTuple_New(3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 116, __pyx_L1_error)
2757         __Pyx_GOTREF(__pyx_t_2);
2758         __Pyx_GIVEREF(__pyx_t_5);
2759         PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_5);
2760         __Pyx_GIVEREF(__pyx_t_10);
2761         PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_t_10);
2762         __Pyx_INCREF(__pyx_v_m);
2763         __Pyx_GIVEREF(__pyx_v_m);
2764         PyTuple_SET_ITEM(__pyx_t_2, 2, __pyx_v_m);
2765         __pyx_t_5 = 0;
2766         __pyx_t_10 = 0;
2767         __pyx_t_10 = __Pyx_PyObject_GetItem(((PyObject *)__pyx_v_u), __pyx_t_2); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 116, __pyx_L1_error)
2768         __Pyx_GOTREF(__pyx_t_10);
2769         __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
2770         __pyx_t_2 = PyNumber_Multiply(__pyx_t_12, __pyx_t_10); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 116, __pyx_L1_error)
2771         __Pyx_GOTREF(__pyx_t_2);
2772         __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
2773         __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
2774         __pyx_t_10 = PyFloat_FromDouble(__pyx_v_dt); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 116, __pyx_L1_error)
2775         __Pyx_GOTREF(__pyx_t_10);
2776         __pyx_t_12 = PyNumber_Multiply(__pyx_t_2, __pyx_t_10); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 116, __pyx_L1_error)
2777         __Pyx_GOTREF(__pyx_t_12);
2778         __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
2779         __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
2780         __pyx_t_10 = PyNumber_InPlaceAdd(__pyx_v_du, __pyx_t_12); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 116, __pyx_L1_error)
2781         __Pyx_GOTREF(__pyx_t_10);
2782         __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
2783         __Pyx_DECREF_SET(__pyx_v_du, __pyx_t_10);
2784         __pyx_t_10 = 0;
2785 
2786         /* "qutip/control/cy_grape.pyx":114
2787  *                 du += -2 * alpha * u[r, j, m] * dt
2788  *
2789  *             if beta:             # <<<<<<<<<<<<<<
2790  *                 # penalty term for late control signals u
2791  *                 du += -2 * beta * m ** 2 * u[r, j, m] * dt
2792  */
2793       }
2794 
2795       /* "qutip/control/cy_grape.pyx":118
2796  *                 du += -2 * beta * m ** 2 * u[r, j, m] * dt
2797  *
2798  *             u[r + 1, j, m] = u[r, j, m] + eps * du.real             # <<<<<<<<<<<<<<
2799  *
2800  *             if use_u_limits:
2801  */
2802       __pyx_t_10 = __Pyx_PyInt_From_int(__pyx_v_r); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 118, __pyx_L1_error)
2803       __Pyx_GOTREF(__pyx_t_10);
2804       __pyx_t_12 = __Pyx_PyInt_From_int(__pyx_v_j); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 118, __pyx_L1_error)
2805       __Pyx_GOTREF(__pyx_t_12);
2806       __pyx_t_2 = PyTuple_New(3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 118, __pyx_L1_error)
2807       __Pyx_GOTREF(__pyx_t_2);
2808       __Pyx_GIVEREF(__pyx_t_10);
2809       PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_10);
2810       __Pyx_GIVEREF(__pyx_t_12);
2811       PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_t_12);
2812       __Pyx_INCREF(__pyx_v_m);
2813       __Pyx_GIVEREF(__pyx_v_m);
2814       PyTuple_SET_ITEM(__pyx_t_2, 2, __pyx_v_m);
2815       __pyx_t_10 = 0;
2816       __pyx_t_12 = 0;
2817       __pyx_t_12 = __Pyx_PyObject_GetItem(((PyObject *)__pyx_v_u), __pyx_t_2); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 118, __pyx_L1_error)
2818       __Pyx_GOTREF(__pyx_t_12);
2819       __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
2820       __pyx_t_2 = PyFloat_FromDouble(__pyx_v_eps); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 118, __pyx_L1_error)
2821       __Pyx_GOTREF(__pyx_t_2);
2822       __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_v_du, __pyx_n_s_real); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 118, __pyx_L1_error)
2823       __Pyx_GOTREF(__pyx_t_10);
2824       __pyx_t_5 = PyNumber_Multiply(__pyx_t_2, __pyx_t_10); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 118, __pyx_L1_error)
2825       __Pyx_GOTREF(__pyx_t_5);
2826       __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
2827       __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
2828       __pyx_t_10 = PyNumber_Add(__pyx_t_12, __pyx_t_5); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 118, __pyx_L1_error)
2829       __Pyx_GOTREF(__pyx_t_10);
2830       __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
2831       __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
2832       __pyx_t_5 = __Pyx_PyInt_From_long((__pyx_v_r + 1)); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 118, __pyx_L1_error)
2833       __Pyx_GOTREF(__pyx_t_5);
2834       __pyx_t_12 = __Pyx_PyInt_From_int(__pyx_v_j); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 118, __pyx_L1_error)
2835       __Pyx_GOTREF(__pyx_t_12);
2836       __pyx_t_2 = PyTuple_New(3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 118, __pyx_L1_error)
2837       __Pyx_GOTREF(__pyx_t_2);
2838       __Pyx_GIVEREF(__pyx_t_5);
2839       PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_5);
2840       __Pyx_GIVEREF(__pyx_t_12);
2841       PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_t_12);
2842       __Pyx_INCREF(__pyx_v_m);
2843       __Pyx_GIVEREF(__pyx_v_m);
2844       PyTuple_SET_ITEM(__pyx_t_2, 2, __pyx_v_m);
2845       __pyx_t_5 = 0;
2846       __pyx_t_12 = 0;
2847       if (unlikely(PyObject_SetItem(((PyObject *)__pyx_v_u), __pyx_t_2, __pyx_t_10) < 0)) __PYX_ERR(0, 118, __pyx_L1_error)
2848       __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
2849       __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
2850 
2851       /* "qutip/control/cy_grape.pyx":120
2852  *             u[r + 1, j, m] = u[r, j, m] + eps * du.real
2853  *
2854  *             if use_u_limits:             # <<<<<<<<<<<<<<
2855  *                 if u[r + 1, j, m] < u_min:
2856  *                     u[r + 1, j, m] = u_min
2857  */
2858       __pyx_t_11 = (__pyx_v_use_u_limits != 0);
2859       if (__pyx_t_11) {
2860 
2861         /* "qutip/control/cy_grape.pyx":121
2862  *
2863  *             if use_u_limits:
2864  *                 if u[r + 1, j, m] < u_min:             # <<<<<<<<<<<<<<
2865  *                     u[r + 1, j, m] = u_min
2866  *                 elif u[r + 1, j, m] > u_max:
2867  */
2868         __pyx_t_10 = __Pyx_PyInt_From_long((__pyx_v_r + 1)); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 121, __pyx_L1_error)
2869         __Pyx_GOTREF(__pyx_t_10);
2870         __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_j); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 121, __pyx_L1_error)
2871         __Pyx_GOTREF(__pyx_t_2);
2872         __pyx_t_12 = PyTuple_New(3); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 121, __pyx_L1_error)
2873         __Pyx_GOTREF(__pyx_t_12);
2874         __Pyx_GIVEREF(__pyx_t_10);
2875         PyTuple_SET_ITEM(__pyx_t_12, 0, __pyx_t_10);
2876         __Pyx_GIVEREF(__pyx_t_2);
2877         PyTuple_SET_ITEM(__pyx_t_12, 1, __pyx_t_2);
2878         __Pyx_INCREF(__pyx_v_m);
2879         __Pyx_GIVEREF(__pyx_v_m);
2880         PyTuple_SET_ITEM(__pyx_t_12, 2, __pyx_v_m);
2881         __pyx_t_10 = 0;
2882         __pyx_t_2 = 0;
2883         __pyx_t_2 = __Pyx_PyObject_GetItem(((PyObject *)__pyx_v_u), __pyx_t_12); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 121, __pyx_L1_error)
2884         __Pyx_GOTREF(__pyx_t_2);
2885         __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
2886         __pyx_t_12 = PyFloat_FromDouble(__pyx_v_u_min); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 121, __pyx_L1_error)
2887         __Pyx_GOTREF(__pyx_t_12);
2888         __pyx_t_10 = PyObject_RichCompare(__pyx_t_2, __pyx_t_12, Py_LT); __Pyx_XGOTREF(__pyx_t_10); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 121, __pyx_L1_error)
2889         __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
2890         __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
2891         __pyx_t_11 = __Pyx_PyObject_IsTrue(__pyx_t_10); if (unlikely(__pyx_t_11 < 0)) __PYX_ERR(0, 121, __pyx_L1_error)
2892         __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
2893         if (__pyx_t_11) {
2894 
2895           /* "qutip/control/cy_grape.pyx":122
2896  *             if use_u_limits:
2897  *                 if u[r + 1, j, m] < u_min:
2898  *                     u[r + 1, j, m] = u_min             # <<<<<<<<<<<<<<
2899  *                 elif u[r + 1, j, m] > u_max:
2900  *                     u[r + 1, j, m] = u_max
2901  */
2902           __pyx_t_10 = PyFloat_FromDouble(__pyx_v_u_min); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 122, __pyx_L1_error)
2903           __Pyx_GOTREF(__pyx_t_10);
2904           __pyx_t_12 = __Pyx_PyInt_From_long((__pyx_v_r + 1)); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 122, __pyx_L1_error)
2905           __Pyx_GOTREF(__pyx_t_12);
2906           __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_j); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 122, __pyx_L1_error)
2907           __Pyx_GOTREF(__pyx_t_2);
2908           __pyx_t_5 = PyTuple_New(3); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 122, __pyx_L1_error)
2909           __Pyx_GOTREF(__pyx_t_5);
2910           __Pyx_GIVEREF(__pyx_t_12);
2911           PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_12);
2912           __Pyx_GIVEREF(__pyx_t_2);
2913           PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_t_2);
2914           __Pyx_INCREF(__pyx_v_m);
2915           __Pyx_GIVEREF(__pyx_v_m);
2916           PyTuple_SET_ITEM(__pyx_t_5, 2, __pyx_v_m);
2917           __pyx_t_12 = 0;
2918           __pyx_t_2 = 0;
2919           if (unlikely(PyObject_SetItem(((PyObject *)__pyx_v_u), __pyx_t_5, __pyx_t_10) < 0)) __PYX_ERR(0, 122, __pyx_L1_error)
2920           __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
2921           __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
2922 
2923           /* "qutip/control/cy_grape.pyx":121
2924  *
2925  *             if use_u_limits:
2926  *                 if u[r + 1, j, m] < u_min:             # <<<<<<<<<<<<<<
2927  *                     u[r + 1, j, m] = u_min
2928  *                 elif u[r + 1, j, m] > u_max:
2929  */
2930           goto __pyx_L11;
2931         }
2932 
2933         /* "qutip/control/cy_grape.pyx":123
2934  *                 if u[r + 1, j, m] < u_min:
2935  *                     u[r + 1, j, m] = u_min
2936  *                 elif u[r + 1, j, m] > u_max:             # <<<<<<<<<<<<<<
2937  *                     u[r + 1, j, m] = u_max
2938  *
2939  */
2940         __pyx_t_10 = __Pyx_PyInt_From_long((__pyx_v_r + 1)); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 123, __pyx_L1_error)
2941         __Pyx_GOTREF(__pyx_t_10);
2942         __pyx_t_5 = __Pyx_PyInt_From_int(__pyx_v_j); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 123, __pyx_L1_error)
2943         __Pyx_GOTREF(__pyx_t_5);
2944         __pyx_t_2 = PyTuple_New(3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 123, __pyx_L1_error)
2945         __Pyx_GOTREF(__pyx_t_2);
2946         __Pyx_GIVEREF(__pyx_t_10);
2947         PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_10);
2948         __Pyx_GIVEREF(__pyx_t_5);
2949         PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_t_5);
2950         __Pyx_INCREF(__pyx_v_m);
2951         __Pyx_GIVEREF(__pyx_v_m);
2952         PyTuple_SET_ITEM(__pyx_t_2, 2, __pyx_v_m);
2953         __pyx_t_10 = 0;
2954         __pyx_t_5 = 0;
2955         __pyx_t_5 = __Pyx_PyObject_GetItem(((PyObject *)__pyx_v_u), __pyx_t_2); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 123, __pyx_L1_error)
2956         __Pyx_GOTREF(__pyx_t_5);
2957         __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
2958         __pyx_t_2 = PyFloat_FromDouble(__pyx_v_u_max); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 123, __pyx_L1_error)
2959         __Pyx_GOTREF(__pyx_t_2);
2960         __pyx_t_10 = PyObject_RichCompare(__pyx_t_5, __pyx_t_2, Py_GT); __Pyx_XGOTREF(__pyx_t_10); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 123, __pyx_L1_error)
2961         __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
2962         __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
2963         __pyx_t_11 = __Pyx_PyObject_IsTrue(__pyx_t_10); if (unlikely(__pyx_t_11 < 0)) __PYX_ERR(0, 123, __pyx_L1_error)
2964         __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
2965         if (__pyx_t_11) {
2966 
2967           /* "qutip/control/cy_grape.pyx":124
2968  *                     u[r + 1, j, m] = u_min
2969  *                 elif u[r + 1, j, m] > u_max:
2970  *                     u[r + 1, j, m] = u_max             # <<<<<<<<<<<<<<
2971  *
2972  *     for j in range(J):
2973  */
2974           __pyx_t_10 = PyFloat_FromDouble(__pyx_v_u_max); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 124, __pyx_L1_error)
2975           __Pyx_GOTREF(__pyx_t_10);
2976           __pyx_t_2 = __Pyx_PyInt_From_long((__pyx_v_r + 1)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 124, __pyx_L1_error)
2977           __Pyx_GOTREF(__pyx_t_2);
2978           __pyx_t_5 = __Pyx_PyInt_From_int(__pyx_v_j); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 124, __pyx_L1_error)
2979           __Pyx_GOTREF(__pyx_t_5);
2980           __pyx_t_12 = PyTuple_New(3); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 124, __pyx_L1_error)
2981           __Pyx_GOTREF(__pyx_t_12);
2982           __Pyx_GIVEREF(__pyx_t_2);
2983           PyTuple_SET_ITEM(__pyx_t_12, 0, __pyx_t_2);
2984           __Pyx_GIVEREF(__pyx_t_5);
2985           PyTuple_SET_ITEM(__pyx_t_12, 1, __pyx_t_5);
2986           __Pyx_INCREF(__pyx_v_m);
2987           __Pyx_GIVEREF(__pyx_v_m);
2988           PyTuple_SET_ITEM(__pyx_t_12, 2, __pyx_v_m);
2989           __pyx_t_2 = 0;
2990           __pyx_t_5 = 0;
2991           if (unlikely(PyObject_SetItem(((PyObject *)__pyx_v_u), __pyx_t_12, __pyx_t_10) < 0)) __PYX_ERR(0, 124, __pyx_L1_error)
2992           __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
2993           __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
2994 
2995           /* "qutip/control/cy_grape.pyx":123
2996  *                 if u[r + 1, j, m] < u_min:
2997  *                     u[r + 1, j, m] = u_min
2998  *                 elif u[r + 1, j, m] > u_max:             # <<<<<<<<<<<<<<
2999  *                     u[r + 1, j, m] = u_max
3000  *
3001  */
3002         }
3003         __pyx_L11:;
3004 
3005         /* "qutip/control/cy_grape.pyx":120
3006  *             u[r + 1, j, m] = u[r, j, m] + eps * du.real
3007  *
3008  *             if use_u_limits:             # <<<<<<<<<<<<<<
3009  *                 if u[r + 1, j, m] < u_min:
3010  *                     u[r + 1, j, m] = u_min
3011  */
3012       }
3013     }
3014 
3015     /* "qutip/control/cy_grape.pyx":100
3016  *     cdef int j, k
3017  *
3018  *     for m in range(M-1):             # <<<<<<<<<<<<<<
3019  *         P = U_b_list[m] * U
3020  *         for j in range(J):
3021  */
3022   }
3023   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
3024 
3025   /* "qutip/control/cy_grape.pyx":126
3026  *                     u[r + 1, j, m] = u_max
3027  *
3028  *     for j in range(J):             # <<<<<<<<<<<<<<
3029  *         u[r + 1, j, M-1] = u[r + 1, j, M-2]
3030  */
3031   __pyx_t_6 = __pyx_v_J;
3032   __pyx_t_7 = __pyx_t_6;
3033   for (__pyx_t_8 = 0; __pyx_t_8 < __pyx_t_7; __pyx_t_8+=1) {
3034     __pyx_v_j = __pyx_t_8;
3035 
3036     /* "qutip/control/cy_grape.pyx":127
3037  *
3038  *     for j in range(J):
3039  *         u[r + 1, j, M-1] = u[r + 1, j, M-2]             # <<<<<<<<<<<<<<
3040  */
3041     __pyx_t_13 = (__pyx_v_r + 1);
3042     __pyx_t_14 = __pyx_v_j;
3043     __pyx_t_15 = (__pyx_v_M - 2);
3044     __pyx_t_16 = (__pyx_v_r + 1);
3045     __pyx_t_17 = __pyx_v_j;
3046     __pyx_t_18 = (__pyx_v_M - 1);
3047     *__Pyx_BufPtrCContig3d(__pyx_t_5qutip_7control_8cy_grape_DTYPE_t *, __pyx_pybuffernd_u.rcbuffer->pybuffer.buf, __pyx_t_16, __pyx_pybuffernd_u.diminfo[0].strides, __pyx_t_17, __pyx_pybuffernd_u.diminfo[1].strides, __pyx_t_18, __pyx_pybuffernd_u.diminfo[2].strides) = (*__Pyx_BufPtrCContig3d(__pyx_t_5qutip_7control_8cy_grape_DTYPE_t *, __pyx_pybuffernd_u.rcbuffer->pybuffer.buf, __pyx_t_13, __pyx_pybuffernd_u.diminfo[0].strides, __pyx_t_14, __pyx_pybuffernd_u.diminfo[1].strides, __pyx_t_15, __pyx_pybuffernd_u.diminfo[2].strides));
3048   }
3049 
3050   /* "qutip/control/cy_grape.pyx":92
3051  * @cython.boundscheck(False)
3052  * @cython.wraparound(False)
3053  * cpdef cy_grape_inner(U, np.ndarray[DTYPE_t, ndim=3, mode="c"] u,             # <<<<<<<<<<<<<<
3054  *                      int r, int J, int M, U_b_list, U_f_list, H_ops,
3055  *                      float dt, float eps, float alpha, float beta,
3056  */
3057 
3058   /* function exit code */
3059   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
3060   goto __pyx_L0;
3061   __pyx_L1_error:;
3062   __Pyx_XDECREF(__pyx_t_1);
3063   __Pyx_XDECREF(__pyx_t_2);
3064   __Pyx_XDECREF(__pyx_t_5);
3065   __Pyx_XDECREF(__pyx_t_10);
3066   __Pyx_XDECREF(__pyx_t_12);
3067   { PyObject *__pyx_type, *__pyx_value, *__pyx_tb;
3068     __Pyx_PyThreadState_declare
3069     __Pyx_PyThreadState_assign
3070     __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb);
3071     __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_u.rcbuffer->pybuffer);
3072   __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}
3073   __Pyx_AddTraceback("qutip.control.cy_grape.cy_grape_inner", __pyx_clineno, __pyx_lineno, __pyx_filename);
3074   __pyx_r = 0;
3075   goto __pyx_L2;
3076   __pyx_L0:;
3077   __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_u.rcbuffer->pybuffer);
3078   __pyx_L2:;
3079   __Pyx_XDECREF(__pyx_v_m);
3080   __Pyx_XDECREF(__pyx_v_P);
3081   __Pyx_XDECREF(__pyx_v_Q);
3082   __Pyx_XDECREF(__pyx_v_du);
3083   __Pyx_XGIVEREF(__pyx_r);
3084   __Pyx_RefNannyFinishContext();
3085   return __pyx_r;
3086 }
3087 
3088 /* Python wrapper */
3089 static PyObject *__pyx_pw_5qutip_7control_8cy_grape_3cy_grape_inner(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
__pyx_pw_5qutip_7control_8cy_grape_3cy_grape_inner(PyObject * __pyx_self,PyObject * __pyx_args,PyObject * __pyx_kwds)3090 static PyObject *__pyx_pw_5qutip_7control_8cy_grape_3cy_grape_inner(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
3091   PyObject *__pyx_v_U = 0;
3092   PyArrayObject *__pyx_v_u = 0;
3093   int __pyx_v_r;
3094   int __pyx_v_J;
3095   int __pyx_v_M;
3096   PyObject *__pyx_v_U_b_list = 0;
3097   PyObject *__pyx_v_U_f_list = 0;
3098   PyObject *__pyx_v_H_ops = 0;
3099   float __pyx_v_dt;
3100   float __pyx_v_eps;
3101   float __pyx_v_alpha;
3102   float __pyx_v_beta;
3103   int __pyx_v_phase_sensitive;
3104   int __pyx_v_use_u_limits;
3105   float __pyx_v_u_min;
3106   float __pyx_v_u_max;
3107   int __pyx_lineno = 0;
3108   const char *__pyx_filename = NULL;
3109   int __pyx_clineno = 0;
3110   PyObject *__pyx_r = 0;
3111   __Pyx_RefNannyDeclarations
3112   __Pyx_RefNannySetupContext("cy_grape_inner (wrapper)", 0);
3113   {
3114     static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_U,&__pyx_n_s_u,&__pyx_n_s_r,&__pyx_n_s_J,&__pyx_n_s_M,&__pyx_n_s_U_b_list,&__pyx_n_s_U_f_list,&__pyx_n_s_H_ops,&__pyx_n_s_dt,&__pyx_n_s_eps,&__pyx_n_s_alpha,&__pyx_n_s_beta,&__pyx_n_s_phase_sensitive,&__pyx_n_s_use_u_limits,&__pyx_n_s_u_min,&__pyx_n_s_u_max,0};
3115     PyObject* values[16] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
3116     if (unlikely(__pyx_kwds)) {
3117       Py_ssize_t kw_args;
3118       const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
3119       switch (pos_args) {
3120         case 16: values[15] = PyTuple_GET_ITEM(__pyx_args, 15);
3121         CYTHON_FALLTHROUGH;
3122         case 15: values[14] = PyTuple_GET_ITEM(__pyx_args, 14);
3123         CYTHON_FALLTHROUGH;
3124         case 14: values[13] = PyTuple_GET_ITEM(__pyx_args, 13);
3125         CYTHON_FALLTHROUGH;
3126         case 13: values[12] = PyTuple_GET_ITEM(__pyx_args, 12);
3127         CYTHON_FALLTHROUGH;
3128         case 12: values[11] = PyTuple_GET_ITEM(__pyx_args, 11);
3129         CYTHON_FALLTHROUGH;
3130         case 11: values[10] = PyTuple_GET_ITEM(__pyx_args, 10);
3131         CYTHON_FALLTHROUGH;
3132         case 10: values[9] = PyTuple_GET_ITEM(__pyx_args, 9);
3133         CYTHON_FALLTHROUGH;
3134         case  9: values[8] = PyTuple_GET_ITEM(__pyx_args, 8);
3135         CYTHON_FALLTHROUGH;
3136         case  8: values[7] = PyTuple_GET_ITEM(__pyx_args, 7);
3137         CYTHON_FALLTHROUGH;
3138         case  7: values[6] = PyTuple_GET_ITEM(__pyx_args, 6);
3139         CYTHON_FALLTHROUGH;
3140         case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
3141         CYTHON_FALLTHROUGH;
3142         case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
3143         CYTHON_FALLTHROUGH;
3144         case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
3145         CYTHON_FALLTHROUGH;
3146         case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
3147         CYTHON_FALLTHROUGH;
3148         case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
3149         CYTHON_FALLTHROUGH;
3150         case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
3151         CYTHON_FALLTHROUGH;
3152         case  0: break;
3153         default: goto __pyx_L5_argtuple_error;
3154       }
3155       kw_args = PyDict_Size(__pyx_kwds);
3156       switch (pos_args) {
3157         case  0:
3158         if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_U)) != 0)) kw_args--;
3159         else goto __pyx_L5_argtuple_error;
3160         CYTHON_FALLTHROUGH;
3161         case  1:
3162         if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_u)) != 0)) kw_args--;
3163         else {
3164           __Pyx_RaiseArgtupleInvalid("cy_grape_inner", 1, 16, 16, 1); __PYX_ERR(0, 92, __pyx_L3_error)
3165         }
3166         CYTHON_FALLTHROUGH;
3167         case  2:
3168         if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_r)) != 0)) kw_args--;
3169         else {
3170           __Pyx_RaiseArgtupleInvalid("cy_grape_inner", 1, 16, 16, 2); __PYX_ERR(0, 92, __pyx_L3_error)
3171         }
3172         CYTHON_FALLTHROUGH;
3173         case  3:
3174         if (likely((values[3] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_J)) != 0)) kw_args--;
3175         else {
3176           __Pyx_RaiseArgtupleInvalid("cy_grape_inner", 1, 16, 16, 3); __PYX_ERR(0, 92, __pyx_L3_error)
3177         }
3178         CYTHON_FALLTHROUGH;
3179         case  4:
3180         if (likely((values[4] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_M)) != 0)) kw_args--;
3181         else {
3182           __Pyx_RaiseArgtupleInvalid("cy_grape_inner", 1, 16, 16, 4); __PYX_ERR(0, 92, __pyx_L3_error)
3183         }
3184         CYTHON_FALLTHROUGH;
3185         case  5:
3186         if (likely((values[5] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_U_b_list)) != 0)) kw_args--;
3187         else {
3188           __Pyx_RaiseArgtupleInvalid("cy_grape_inner", 1, 16, 16, 5); __PYX_ERR(0, 92, __pyx_L3_error)
3189         }
3190         CYTHON_FALLTHROUGH;
3191         case  6:
3192         if (likely((values[6] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_U_f_list)) != 0)) kw_args--;
3193         else {
3194           __Pyx_RaiseArgtupleInvalid("cy_grape_inner", 1, 16, 16, 6); __PYX_ERR(0, 92, __pyx_L3_error)
3195         }
3196         CYTHON_FALLTHROUGH;
3197         case  7:
3198         if (likely((values[7] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_H_ops)) != 0)) kw_args--;
3199         else {
3200           __Pyx_RaiseArgtupleInvalid("cy_grape_inner", 1, 16, 16, 7); __PYX_ERR(0, 92, __pyx_L3_error)
3201         }
3202         CYTHON_FALLTHROUGH;
3203         case  8:
3204         if (likely((values[8] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_dt)) != 0)) kw_args--;
3205         else {
3206           __Pyx_RaiseArgtupleInvalid("cy_grape_inner", 1, 16, 16, 8); __PYX_ERR(0, 92, __pyx_L3_error)
3207         }
3208         CYTHON_FALLTHROUGH;
3209         case  9:
3210         if (likely((values[9] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_eps)) != 0)) kw_args--;
3211         else {
3212           __Pyx_RaiseArgtupleInvalid("cy_grape_inner", 1, 16, 16, 9); __PYX_ERR(0, 92, __pyx_L3_error)
3213         }
3214         CYTHON_FALLTHROUGH;
3215         case 10:
3216         if (likely((values[10] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_alpha)) != 0)) kw_args--;
3217         else {
3218           __Pyx_RaiseArgtupleInvalid("cy_grape_inner", 1, 16, 16, 10); __PYX_ERR(0, 92, __pyx_L3_error)
3219         }
3220         CYTHON_FALLTHROUGH;
3221         case 11:
3222         if (likely((values[11] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_beta)) != 0)) kw_args--;
3223         else {
3224           __Pyx_RaiseArgtupleInvalid("cy_grape_inner", 1, 16, 16, 11); __PYX_ERR(0, 92, __pyx_L3_error)
3225         }
3226         CYTHON_FALLTHROUGH;
3227         case 12:
3228         if (likely((values[12] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_phase_sensitive)) != 0)) kw_args--;
3229         else {
3230           __Pyx_RaiseArgtupleInvalid("cy_grape_inner", 1, 16, 16, 12); __PYX_ERR(0, 92, __pyx_L3_error)
3231         }
3232         CYTHON_FALLTHROUGH;
3233         case 13:
3234         if (likely((values[13] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_use_u_limits)) != 0)) kw_args--;
3235         else {
3236           __Pyx_RaiseArgtupleInvalid("cy_grape_inner", 1, 16, 16, 13); __PYX_ERR(0, 92, __pyx_L3_error)
3237         }
3238         CYTHON_FALLTHROUGH;
3239         case 14:
3240         if (likely((values[14] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_u_min)) != 0)) kw_args--;
3241         else {
3242           __Pyx_RaiseArgtupleInvalid("cy_grape_inner", 1, 16, 16, 14); __PYX_ERR(0, 92, __pyx_L3_error)
3243         }
3244         CYTHON_FALLTHROUGH;
3245         case 15:
3246         if (likely((values[15] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_u_max)) != 0)) kw_args--;
3247         else {
3248           __Pyx_RaiseArgtupleInvalid("cy_grape_inner", 1, 16, 16, 15); __PYX_ERR(0, 92, __pyx_L3_error)
3249         }
3250       }
3251       if (unlikely(kw_args > 0)) {
3252         if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "cy_grape_inner") < 0)) __PYX_ERR(0, 92, __pyx_L3_error)
3253       }
3254     } else if (PyTuple_GET_SIZE(__pyx_args) != 16) {
3255       goto __pyx_L5_argtuple_error;
3256     } else {
3257       values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
3258       values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
3259       values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
3260       values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
3261       values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
3262       values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
3263       values[6] = PyTuple_GET_ITEM(__pyx_args, 6);
3264       values[7] = PyTuple_GET_ITEM(__pyx_args, 7);
3265       values[8] = PyTuple_GET_ITEM(__pyx_args, 8);
3266       values[9] = PyTuple_GET_ITEM(__pyx_args, 9);
3267       values[10] = PyTuple_GET_ITEM(__pyx_args, 10);
3268       values[11] = PyTuple_GET_ITEM(__pyx_args, 11);
3269       values[12] = PyTuple_GET_ITEM(__pyx_args, 12);
3270       values[13] = PyTuple_GET_ITEM(__pyx_args, 13);
3271       values[14] = PyTuple_GET_ITEM(__pyx_args, 14);
3272       values[15] = PyTuple_GET_ITEM(__pyx_args, 15);
3273     }
3274     __pyx_v_U = values[0];
3275     __pyx_v_u = ((PyArrayObject *)values[1]);
3276     __pyx_v_r = __Pyx_PyInt_As_int(values[2]); if (unlikely((__pyx_v_r == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 93, __pyx_L3_error)
3277     __pyx_v_J = __Pyx_PyInt_As_int(values[3]); if (unlikely((__pyx_v_J == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 93, __pyx_L3_error)
3278     __pyx_v_M = __Pyx_PyInt_As_int(values[4]); if (unlikely((__pyx_v_M == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 93, __pyx_L3_error)
3279     __pyx_v_U_b_list = values[5];
3280     __pyx_v_U_f_list = values[6];
3281     __pyx_v_H_ops = values[7];
3282     __pyx_v_dt = __pyx_PyFloat_AsFloat(values[8]); if (unlikely((__pyx_v_dt == (float)-1) && PyErr_Occurred())) __PYX_ERR(0, 94, __pyx_L3_error)
3283     __pyx_v_eps = __pyx_PyFloat_AsFloat(values[9]); if (unlikely((__pyx_v_eps == (float)-1) && PyErr_Occurred())) __PYX_ERR(0, 94, __pyx_L3_error)
3284     __pyx_v_alpha = __pyx_PyFloat_AsFloat(values[10]); if (unlikely((__pyx_v_alpha == (float)-1) && PyErr_Occurred())) __PYX_ERR(0, 94, __pyx_L3_error)
3285     __pyx_v_beta = __pyx_PyFloat_AsFloat(values[11]); if (unlikely((__pyx_v_beta == (float)-1) && PyErr_Occurred())) __PYX_ERR(0, 94, __pyx_L3_error)
3286     __pyx_v_phase_sensitive = __Pyx_PyInt_As_int(values[12]); if (unlikely((__pyx_v_phase_sensitive == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 95, __pyx_L3_error)
3287     __pyx_v_use_u_limits = __Pyx_PyInt_As_int(values[13]); if (unlikely((__pyx_v_use_u_limits == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 96, __pyx_L3_error)
3288     __pyx_v_u_min = __pyx_PyFloat_AsFloat(values[14]); if (unlikely((__pyx_v_u_min == (float)-1) && PyErr_Occurred())) __PYX_ERR(0, 96, __pyx_L3_error)
3289     __pyx_v_u_max = __pyx_PyFloat_AsFloat(values[15]); if (unlikely((__pyx_v_u_max == (float)-1) && PyErr_Occurred())) __PYX_ERR(0, 96, __pyx_L3_error)
3290   }
3291   goto __pyx_L4_argument_unpacking_done;
3292   __pyx_L5_argtuple_error:;
3293   __Pyx_RaiseArgtupleInvalid("cy_grape_inner", 1, 16, 16, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 92, __pyx_L3_error)
3294   __pyx_L3_error:;
3295   __Pyx_AddTraceback("qutip.control.cy_grape.cy_grape_inner", __pyx_clineno, __pyx_lineno, __pyx_filename);
3296   __Pyx_RefNannyFinishContext();
3297   return NULL;
3298   __pyx_L4_argument_unpacking_done:;
3299   if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_u), __pyx_ptype_5numpy_ndarray, 1, "u", 0))) __PYX_ERR(0, 92, __pyx_L1_error)
3300   __pyx_r = __pyx_pf_5qutip_7control_8cy_grape_2cy_grape_inner(__pyx_self, __pyx_v_U, __pyx_v_u, __pyx_v_r, __pyx_v_J, __pyx_v_M, __pyx_v_U_b_list, __pyx_v_U_f_list, __pyx_v_H_ops, __pyx_v_dt, __pyx_v_eps, __pyx_v_alpha, __pyx_v_beta, __pyx_v_phase_sensitive, __pyx_v_use_u_limits, __pyx_v_u_min, __pyx_v_u_max);
3301 
3302   /* function exit code */
3303   goto __pyx_L0;
3304   __pyx_L1_error:;
3305   __pyx_r = NULL;
3306   __pyx_L0:;
3307   __Pyx_RefNannyFinishContext();
3308   return __pyx_r;
3309 }
3310 
__pyx_pf_5qutip_7control_8cy_grape_2cy_grape_inner(CYTHON_UNUSED PyObject * __pyx_self,PyObject * __pyx_v_U,PyArrayObject * __pyx_v_u,int __pyx_v_r,int __pyx_v_J,int __pyx_v_M,PyObject * __pyx_v_U_b_list,PyObject * __pyx_v_U_f_list,PyObject * __pyx_v_H_ops,float __pyx_v_dt,float __pyx_v_eps,float __pyx_v_alpha,float __pyx_v_beta,int __pyx_v_phase_sensitive,int __pyx_v_use_u_limits,float __pyx_v_u_min,float __pyx_v_u_max)3311 static PyObject *__pyx_pf_5qutip_7control_8cy_grape_2cy_grape_inner(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_U, PyArrayObject *__pyx_v_u, int __pyx_v_r, int __pyx_v_J, int __pyx_v_M, PyObject *__pyx_v_U_b_list, PyObject *__pyx_v_U_f_list, PyObject *__pyx_v_H_ops, float __pyx_v_dt, float __pyx_v_eps, float __pyx_v_alpha, float __pyx_v_beta, int __pyx_v_phase_sensitive, int __pyx_v_use_u_limits, float __pyx_v_u_min, float __pyx_v_u_max) {
3312   __Pyx_LocalBuf_ND __pyx_pybuffernd_u;
3313   __Pyx_Buffer __pyx_pybuffer_u;
3314   PyObject *__pyx_r = NULL;
3315   __Pyx_RefNannyDeclarations
3316   PyObject *__pyx_t_1 = NULL;
3317   int __pyx_lineno = 0;
3318   const char *__pyx_filename = NULL;
3319   int __pyx_clineno = 0;
3320   __Pyx_RefNannySetupContext("cy_grape_inner", 0);
3321   __pyx_pybuffer_u.pybuffer.buf = NULL;
3322   __pyx_pybuffer_u.refcount = 0;
3323   __pyx_pybuffernd_u.data = NULL;
3324   __pyx_pybuffernd_u.rcbuffer = &__pyx_pybuffer_u;
3325   {
3326     __Pyx_BufFmt_StackElem __pyx_stack[1];
3327     if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_u.rcbuffer->pybuffer, (PyObject*)__pyx_v_u, &__Pyx_TypeInfo_nn___pyx_t_5qutip_7control_8cy_grape_DTYPE_t, PyBUF_FORMAT| PyBUF_C_CONTIGUOUS, 3, 0, __pyx_stack) == -1)) __PYX_ERR(0, 92, __pyx_L1_error)
3328   }
3329   __pyx_pybuffernd_u.diminfo[0].strides = __pyx_pybuffernd_u.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_u.diminfo[0].shape = __pyx_pybuffernd_u.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_u.diminfo[1].strides = __pyx_pybuffernd_u.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_u.diminfo[1].shape = __pyx_pybuffernd_u.rcbuffer->pybuffer.shape[1]; __pyx_pybuffernd_u.diminfo[2].strides = __pyx_pybuffernd_u.rcbuffer->pybuffer.strides[2]; __pyx_pybuffernd_u.diminfo[2].shape = __pyx_pybuffernd_u.rcbuffer->pybuffer.shape[2];
3330   __Pyx_XDECREF(__pyx_r);
3331   __pyx_t_1 = __pyx_f_5qutip_7control_8cy_grape_cy_grape_inner(__pyx_v_U, __pyx_v_u, __pyx_v_r, __pyx_v_J, __pyx_v_M, __pyx_v_U_b_list, __pyx_v_U_f_list, __pyx_v_H_ops, __pyx_v_dt, __pyx_v_eps, __pyx_v_alpha, __pyx_v_beta, __pyx_v_phase_sensitive, __pyx_v_use_u_limits, __pyx_v_u_min, __pyx_v_u_max, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 92, __pyx_L1_error)
3332   __Pyx_GOTREF(__pyx_t_1);
3333   __pyx_r = __pyx_t_1;
3334   __pyx_t_1 = 0;
3335   goto __pyx_L0;
3336 
3337   /* function exit code */
3338   __pyx_L1_error:;
3339   __Pyx_XDECREF(__pyx_t_1);
3340   { PyObject *__pyx_type, *__pyx_value, *__pyx_tb;
3341     __Pyx_PyThreadState_declare
3342     __Pyx_PyThreadState_assign
3343     __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb);
3344     __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_u.rcbuffer->pybuffer);
3345   __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}
3346   __Pyx_AddTraceback("qutip.control.cy_grape.cy_grape_inner", __pyx_clineno, __pyx_lineno, __pyx_filename);
3347   __pyx_r = NULL;
3348   goto __pyx_L2;
3349   __pyx_L0:;
3350   __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_u.rcbuffer->pybuffer);
3351   __pyx_L2:;
3352   __Pyx_XGIVEREF(__pyx_r);
3353   __Pyx_RefNannyFinishContext();
3354   return __pyx_r;
3355 }
3356 
3357 /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":734
3358  * ctypedef npy_cdouble     complex_t
3359  *
3360  * cdef inline object PyArray_MultiIterNew1(a):             # <<<<<<<<<<<<<<
3361  *     return PyArray_MultiIterNew(1, <void*>a)
3362  *
3363  */
3364 
__pyx_f_5numpy_PyArray_MultiIterNew1(PyObject * __pyx_v_a)3365 static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew1(PyObject *__pyx_v_a) {
3366   PyObject *__pyx_r = NULL;
3367   __Pyx_RefNannyDeclarations
3368   PyObject *__pyx_t_1 = NULL;
3369   int __pyx_lineno = 0;
3370   const char *__pyx_filename = NULL;
3371   int __pyx_clineno = 0;
3372   __Pyx_RefNannySetupContext("PyArray_MultiIterNew1", 0);
3373 
3374   /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":735
3375  *
3376  * cdef inline object PyArray_MultiIterNew1(a):
3377  *     return PyArray_MultiIterNew(1, <void*>a)             # <<<<<<<<<<<<<<
3378  *
3379  * cdef inline object PyArray_MultiIterNew2(a, b):
3380  */
3381   __Pyx_XDECREF(__pyx_r);
3382   __pyx_t_1 = PyArray_MultiIterNew(1, ((void *)__pyx_v_a)); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 735, __pyx_L1_error)
3383   __Pyx_GOTREF(__pyx_t_1);
3384   __pyx_r = __pyx_t_1;
3385   __pyx_t_1 = 0;
3386   goto __pyx_L0;
3387 
3388   /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":734
3389  * ctypedef npy_cdouble     complex_t
3390  *
3391  * cdef inline object PyArray_MultiIterNew1(a):             # <<<<<<<<<<<<<<
3392  *     return PyArray_MultiIterNew(1, <void*>a)
3393  *
3394  */
3395 
3396   /* function exit code */
3397   __pyx_L1_error:;
3398   __Pyx_XDECREF(__pyx_t_1);
3399   __Pyx_AddTraceback("numpy.PyArray_MultiIterNew1", __pyx_clineno, __pyx_lineno, __pyx_filename);
3400   __pyx_r = 0;
3401   __pyx_L0:;
3402   __Pyx_XGIVEREF(__pyx_r);
3403   __Pyx_RefNannyFinishContext();
3404   return __pyx_r;
3405 }
3406 
3407 /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":737
3408  *     return PyArray_MultiIterNew(1, <void*>a)
3409  *
3410  * cdef inline object PyArray_MultiIterNew2(a, b):             # <<<<<<<<<<<<<<
3411  *     return PyArray_MultiIterNew(2, <void*>a, <void*>b)
3412  *
3413  */
3414 
__pyx_f_5numpy_PyArray_MultiIterNew2(PyObject * __pyx_v_a,PyObject * __pyx_v_b)3415 static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew2(PyObject *__pyx_v_a, PyObject *__pyx_v_b) {
3416   PyObject *__pyx_r = NULL;
3417   __Pyx_RefNannyDeclarations
3418   PyObject *__pyx_t_1 = NULL;
3419   int __pyx_lineno = 0;
3420   const char *__pyx_filename = NULL;
3421   int __pyx_clineno = 0;
3422   __Pyx_RefNannySetupContext("PyArray_MultiIterNew2", 0);
3423 
3424   /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":738
3425  *
3426  * cdef inline object PyArray_MultiIterNew2(a, b):
3427  *     return PyArray_MultiIterNew(2, <void*>a, <void*>b)             # <<<<<<<<<<<<<<
3428  *
3429  * cdef inline object PyArray_MultiIterNew3(a, b, c):
3430  */
3431   __Pyx_XDECREF(__pyx_r);
3432   __pyx_t_1 = PyArray_MultiIterNew(2, ((void *)__pyx_v_a), ((void *)__pyx_v_b)); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 738, __pyx_L1_error)
3433   __Pyx_GOTREF(__pyx_t_1);
3434   __pyx_r = __pyx_t_1;
3435   __pyx_t_1 = 0;
3436   goto __pyx_L0;
3437 
3438   /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":737
3439  *     return PyArray_MultiIterNew(1, <void*>a)
3440  *
3441  * cdef inline object PyArray_MultiIterNew2(a, b):             # <<<<<<<<<<<<<<
3442  *     return PyArray_MultiIterNew(2, <void*>a, <void*>b)
3443  *
3444  */
3445 
3446   /* function exit code */
3447   __pyx_L1_error:;
3448   __Pyx_XDECREF(__pyx_t_1);
3449   __Pyx_AddTraceback("numpy.PyArray_MultiIterNew2", __pyx_clineno, __pyx_lineno, __pyx_filename);
3450   __pyx_r = 0;
3451   __pyx_L0:;
3452   __Pyx_XGIVEREF(__pyx_r);
3453   __Pyx_RefNannyFinishContext();
3454   return __pyx_r;
3455 }
3456 
3457 /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":740
3458  *     return PyArray_MultiIterNew(2, <void*>a, <void*>b)
3459  *
3460  * cdef inline object PyArray_MultiIterNew3(a, b, c):             # <<<<<<<<<<<<<<
3461  *     return PyArray_MultiIterNew(3, <void*>a, <void*>b, <void*> c)
3462  *
3463  */
3464 
__pyx_f_5numpy_PyArray_MultiIterNew3(PyObject * __pyx_v_a,PyObject * __pyx_v_b,PyObject * __pyx_v_c)3465 static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew3(PyObject *__pyx_v_a, PyObject *__pyx_v_b, PyObject *__pyx_v_c) {
3466   PyObject *__pyx_r = NULL;
3467   __Pyx_RefNannyDeclarations
3468   PyObject *__pyx_t_1 = NULL;
3469   int __pyx_lineno = 0;
3470   const char *__pyx_filename = NULL;
3471   int __pyx_clineno = 0;
3472   __Pyx_RefNannySetupContext("PyArray_MultiIterNew3", 0);
3473 
3474   /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":741
3475  *
3476  * cdef inline object PyArray_MultiIterNew3(a, b, c):
3477  *     return PyArray_MultiIterNew(3, <void*>a, <void*>b, <void*> c)             # <<<<<<<<<<<<<<
3478  *
3479  * cdef inline object PyArray_MultiIterNew4(a, b, c, d):
3480  */
3481   __Pyx_XDECREF(__pyx_r);
3482   __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, 741, __pyx_L1_error)
3483   __Pyx_GOTREF(__pyx_t_1);
3484   __pyx_r = __pyx_t_1;
3485   __pyx_t_1 = 0;
3486   goto __pyx_L0;
3487 
3488   /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":740
3489  *     return PyArray_MultiIterNew(2, <void*>a, <void*>b)
3490  *
3491  * cdef inline object PyArray_MultiIterNew3(a, b, c):             # <<<<<<<<<<<<<<
3492  *     return PyArray_MultiIterNew(3, <void*>a, <void*>b, <void*> c)
3493  *
3494  */
3495 
3496   /* function exit code */
3497   __pyx_L1_error:;
3498   __Pyx_XDECREF(__pyx_t_1);
3499   __Pyx_AddTraceback("numpy.PyArray_MultiIterNew3", __pyx_clineno, __pyx_lineno, __pyx_filename);
3500   __pyx_r = 0;
3501   __pyx_L0:;
3502   __Pyx_XGIVEREF(__pyx_r);
3503   __Pyx_RefNannyFinishContext();
3504   return __pyx_r;
3505 }
3506 
3507 /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":743
3508  *     return PyArray_MultiIterNew(3, <void*>a, <void*>b, <void*> c)
3509  *
3510  * cdef inline object PyArray_MultiIterNew4(a, b, c, d):             # <<<<<<<<<<<<<<
3511  *     return PyArray_MultiIterNew(4, <void*>a, <void*>b, <void*>c, <void*> d)
3512  *
3513  */
3514 
__pyx_f_5numpy_PyArray_MultiIterNew4(PyObject * __pyx_v_a,PyObject * __pyx_v_b,PyObject * __pyx_v_c,PyObject * __pyx_v_d)3515 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) {
3516   PyObject *__pyx_r = NULL;
3517   __Pyx_RefNannyDeclarations
3518   PyObject *__pyx_t_1 = NULL;
3519   int __pyx_lineno = 0;
3520   const char *__pyx_filename = NULL;
3521   int __pyx_clineno = 0;
3522   __Pyx_RefNannySetupContext("PyArray_MultiIterNew4", 0);
3523 
3524   /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":744
3525  *
3526  * cdef inline object PyArray_MultiIterNew4(a, b, c, d):
3527  *     return PyArray_MultiIterNew(4, <void*>a, <void*>b, <void*>c, <void*> d)             # <<<<<<<<<<<<<<
3528  *
3529  * cdef inline object PyArray_MultiIterNew5(a, b, c, d, e):
3530  */
3531   __Pyx_XDECREF(__pyx_r);
3532   __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, 744, __pyx_L1_error)
3533   __Pyx_GOTREF(__pyx_t_1);
3534   __pyx_r = __pyx_t_1;
3535   __pyx_t_1 = 0;
3536   goto __pyx_L0;
3537 
3538   /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":743
3539  *     return PyArray_MultiIterNew(3, <void*>a, <void*>b, <void*> c)
3540  *
3541  * cdef inline object PyArray_MultiIterNew4(a, b, c, d):             # <<<<<<<<<<<<<<
3542  *     return PyArray_MultiIterNew(4, <void*>a, <void*>b, <void*>c, <void*> d)
3543  *
3544  */
3545 
3546   /* function exit code */
3547   __pyx_L1_error:;
3548   __Pyx_XDECREF(__pyx_t_1);
3549   __Pyx_AddTraceback("numpy.PyArray_MultiIterNew4", __pyx_clineno, __pyx_lineno, __pyx_filename);
3550   __pyx_r = 0;
3551   __pyx_L0:;
3552   __Pyx_XGIVEREF(__pyx_r);
3553   __Pyx_RefNannyFinishContext();
3554   return __pyx_r;
3555 }
3556 
3557 /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":746
3558  *     return PyArray_MultiIterNew(4, <void*>a, <void*>b, <void*>c, <void*> d)
3559  *
3560  * cdef inline object PyArray_MultiIterNew5(a, b, c, d, e):             # <<<<<<<<<<<<<<
3561  *     return PyArray_MultiIterNew(5, <void*>a, <void*>b, <void*>c, <void*> d, <void*> e)
3562  *
3563  */
3564 
__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)3565 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) {
3566   PyObject *__pyx_r = NULL;
3567   __Pyx_RefNannyDeclarations
3568   PyObject *__pyx_t_1 = NULL;
3569   int __pyx_lineno = 0;
3570   const char *__pyx_filename = NULL;
3571   int __pyx_clineno = 0;
3572   __Pyx_RefNannySetupContext("PyArray_MultiIterNew5", 0);
3573 
3574   /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":747
3575  *
3576  * cdef inline object PyArray_MultiIterNew5(a, b, c, d, e):
3577  *     return PyArray_MultiIterNew(5, <void*>a, <void*>b, <void*>c, <void*> d, <void*> e)             # <<<<<<<<<<<<<<
3578  *
3579  * cdef inline tuple PyDataType_SHAPE(dtype d):
3580  */
3581   __Pyx_XDECREF(__pyx_r);
3582   __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, 747, __pyx_L1_error)
3583   __Pyx_GOTREF(__pyx_t_1);
3584   __pyx_r = __pyx_t_1;
3585   __pyx_t_1 = 0;
3586   goto __pyx_L0;
3587 
3588   /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":746
3589  *     return PyArray_MultiIterNew(4, <void*>a, <void*>b, <void*>c, <void*> d)
3590  *
3591  * cdef inline object PyArray_MultiIterNew5(a, b, c, d, e):             # <<<<<<<<<<<<<<
3592  *     return PyArray_MultiIterNew(5, <void*>a, <void*>b, <void*>c, <void*> d, <void*> e)
3593  *
3594  */
3595 
3596   /* function exit code */
3597   __pyx_L1_error:;
3598   __Pyx_XDECREF(__pyx_t_1);
3599   __Pyx_AddTraceback("numpy.PyArray_MultiIterNew5", __pyx_clineno, __pyx_lineno, __pyx_filename);
3600   __pyx_r = 0;
3601   __pyx_L0:;
3602   __Pyx_XGIVEREF(__pyx_r);
3603   __Pyx_RefNannyFinishContext();
3604   return __pyx_r;
3605 }
3606 
3607 /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":749
3608  *     return PyArray_MultiIterNew(5, <void*>a, <void*>b, <void*>c, <void*> d, <void*> e)
3609  *
3610  * cdef inline tuple PyDataType_SHAPE(dtype d):             # <<<<<<<<<<<<<<
3611  *     if PyDataType_HASSUBARRAY(d):
3612  *         return <tuple>d.subarray.shape
3613  */
3614 
__pyx_f_5numpy_PyDataType_SHAPE(PyArray_Descr * __pyx_v_d)3615 static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyDataType_SHAPE(PyArray_Descr *__pyx_v_d) {
3616   PyObject *__pyx_r = NULL;
3617   __Pyx_RefNannyDeclarations
3618   int __pyx_t_1;
3619   __Pyx_RefNannySetupContext("PyDataType_SHAPE", 0);
3620 
3621   /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":750
3622  *
3623  * cdef inline tuple PyDataType_SHAPE(dtype d):
3624  *     if PyDataType_HASSUBARRAY(d):             # <<<<<<<<<<<<<<
3625  *         return <tuple>d.subarray.shape
3626  *     else:
3627  */
3628   __pyx_t_1 = (PyDataType_HASSUBARRAY(__pyx_v_d) != 0);
3629   if (__pyx_t_1) {
3630 
3631     /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":751
3632  * cdef inline tuple PyDataType_SHAPE(dtype d):
3633  *     if PyDataType_HASSUBARRAY(d):
3634  *         return <tuple>d.subarray.shape             # <<<<<<<<<<<<<<
3635  *     else:
3636  *         return ()
3637  */
3638     __Pyx_XDECREF(__pyx_r);
3639     __Pyx_INCREF(((PyObject*)__pyx_v_d->subarray->shape));
3640     __pyx_r = ((PyObject*)__pyx_v_d->subarray->shape);
3641     goto __pyx_L0;
3642 
3643     /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":750
3644  *
3645  * cdef inline tuple PyDataType_SHAPE(dtype d):
3646  *     if PyDataType_HASSUBARRAY(d):             # <<<<<<<<<<<<<<
3647  *         return <tuple>d.subarray.shape
3648  *     else:
3649  */
3650   }
3651 
3652   /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":753
3653  *         return <tuple>d.subarray.shape
3654  *     else:
3655  *         return ()             # <<<<<<<<<<<<<<
3656  *
3657  *
3658  */
3659   /*else*/ {
3660     __Pyx_XDECREF(__pyx_r);
3661     __Pyx_INCREF(__pyx_empty_tuple);
3662     __pyx_r = __pyx_empty_tuple;
3663     goto __pyx_L0;
3664   }
3665 
3666   /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":749
3667  *     return PyArray_MultiIterNew(5, <void*>a, <void*>b, <void*>c, <void*> d, <void*> e)
3668  *
3669  * cdef inline tuple PyDataType_SHAPE(dtype d):             # <<<<<<<<<<<<<<
3670  *     if PyDataType_HASSUBARRAY(d):
3671  *         return <tuple>d.subarray.shape
3672  */
3673 
3674   /* function exit code */
3675   __pyx_L0:;
3676   __Pyx_XGIVEREF(__pyx_r);
3677   __Pyx_RefNannyFinishContext();
3678   return __pyx_r;
3679 }
3680 
3681 /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":868
3682  *     int _import_umath() except -1
3683  *
3684  * cdef inline void set_array_base(ndarray arr, object base):             # <<<<<<<<<<<<<<
3685  *     Py_INCREF(base) # important to do this before stealing the reference below!
3686  *     PyArray_SetBaseObject(arr, base)
3687  */
3688 
__pyx_f_5numpy_set_array_base(PyArrayObject * __pyx_v_arr,PyObject * __pyx_v_base)3689 static CYTHON_INLINE void __pyx_f_5numpy_set_array_base(PyArrayObject *__pyx_v_arr, PyObject *__pyx_v_base) {
3690   __Pyx_RefNannyDeclarations
3691   __Pyx_RefNannySetupContext("set_array_base", 0);
3692 
3693   /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":869
3694  *
3695  * cdef inline void set_array_base(ndarray arr, object base):
3696  *     Py_INCREF(base) # important to do this before stealing the reference below!             # <<<<<<<<<<<<<<
3697  *     PyArray_SetBaseObject(arr, base)
3698  *
3699  */
3700   Py_INCREF(__pyx_v_base);
3701 
3702   /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":870
3703  * cdef inline void set_array_base(ndarray arr, object base):
3704  *     Py_INCREF(base) # important to do this before stealing the reference below!
3705  *     PyArray_SetBaseObject(arr, base)             # <<<<<<<<<<<<<<
3706  *
3707  * cdef inline object get_array_base(ndarray arr):
3708  */
3709   (void)(PyArray_SetBaseObject(__pyx_v_arr, __pyx_v_base));
3710 
3711   /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":868
3712  *     int _import_umath() except -1
3713  *
3714  * cdef inline void set_array_base(ndarray arr, object base):             # <<<<<<<<<<<<<<
3715  *     Py_INCREF(base) # important to do this before stealing the reference below!
3716  *     PyArray_SetBaseObject(arr, base)
3717  */
3718 
3719   /* function exit code */
3720   __Pyx_RefNannyFinishContext();
3721 }
3722 
3723 /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":872
3724  *     PyArray_SetBaseObject(arr, base)
3725  *
3726  * cdef inline object get_array_base(ndarray arr):             # <<<<<<<<<<<<<<
3727  *     base = PyArray_BASE(arr)
3728  *     if base is NULL:
3729  */
3730 
__pyx_f_5numpy_get_array_base(PyArrayObject * __pyx_v_arr)3731 static CYTHON_INLINE PyObject *__pyx_f_5numpy_get_array_base(PyArrayObject *__pyx_v_arr) {
3732   PyObject *__pyx_v_base;
3733   PyObject *__pyx_r = NULL;
3734   __Pyx_RefNannyDeclarations
3735   int __pyx_t_1;
3736   __Pyx_RefNannySetupContext("get_array_base", 0);
3737 
3738   /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":873
3739  *
3740  * cdef inline object get_array_base(ndarray arr):
3741  *     base = PyArray_BASE(arr)             # <<<<<<<<<<<<<<
3742  *     if base is NULL:
3743  *         return None
3744  */
3745   __pyx_v_base = PyArray_BASE(__pyx_v_arr);
3746 
3747   /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":874
3748  * cdef inline object get_array_base(ndarray arr):
3749  *     base = PyArray_BASE(arr)
3750  *     if base is NULL:             # <<<<<<<<<<<<<<
3751  *         return None
3752  *     return <object>base
3753  */
3754   __pyx_t_1 = ((__pyx_v_base == NULL) != 0);
3755   if (__pyx_t_1) {
3756 
3757     /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":875
3758  *     base = PyArray_BASE(arr)
3759  *     if base is NULL:
3760  *         return None             # <<<<<<<<<<<<<<
3761  *     return <object>base
3762  *
3763  */
3764     __Pyx_XDECREF(__pyx_r);
3765     __pyx_r = Py_None; __Pyx_INCREF(Py_None);
3766     goto __pyx_L0;
3767 
3768     /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":874
3769  * cdef inline object get_array_base(ndarray arr):
3770  *     base = PyArray_BASE(arr)
3771  *     if base is NULL:             # <<<<<<<<<<<<<<
3772  *         return None
3773  *     return <object>base
3774  */
3775   }
3776 
3777   /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":876
3778  *     if base is NULL:
3779  *         return None
3780  *     return <object>base             # <<<<<<<<<<<<<<
3781  *
3782  * # Versions of the import_* functions which are more suitable for
3783  */
3784   __Pyx_XDECREF(__pyx_r);
3785   __Pyx_INCREF(((PyObject *)__pyx_v_base));
3786   __pyx_r = ((PyObject *)__pyx_v_base);
3787   goto __pyx_L0;
3788 
3789   /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":872
3790  *     PyArray_SetBaseObject(arr, base)
3791  *
3792  * cdef inline object get_array_base(ndarray arr):             # <<<<<<<<<<<<<<
3793  *     base = PyArray_BASE(arr)
3794  *     if base is NULL:
3795  */
3796 
3797   /* function exit code */
3798   __pyx_L0:;
3799   __Pyx_XGIVEREF(__pyx_r);
3800   __Pyx_RefNannyFinishContext();
3801   return __pyx_r;
3802 }
3803 
3804 /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":880
3805  * # Versions of the import_* functions which are more suitable for
3806  * # Cython code.
3807  * cdef inline int import_array() except -1:             # <<<<<<<<<<<<<<
3808  *     try:
3809  *         __pyx_import_array()
3810  */
3811 
__pyx_f_5numpy_import_array(void)3812 static CYTHON_INLINE int __pyx_f_5numpy_import_array(void) {
3813   int __pyx_r;
3814   __Pyx_RefNannyDeclarations
3815   PyObject *__pyx_t_1 = NULL;
3816   PyObject *__pyx_t_2 = NULL;
3817   PyObject *__pyx_t_3 = NULL;
3818   int __pyx_t_4;
3819   PyObject *__pyx_t_5 = NULL;
3820   PyObject *__pyx_t_6 = NULL;
3821   PyObject *__pyx_t_7 = NULL;
3822   PyObject *__pyx_t_8 = NULL;
3823   int __pyx_lineno = 0;
3824   const char *__pyx_filename = NULL;
3825   int __pyx_clineno = 0;
3826   __Pyx_RefNannySetupContext("import_array", 0);
3827 
3828   /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":881
3829  * # Cython code.
3830  * cdef inline int import_array() except -1:
3831  *     try:             # <<<<<<<<<<<<<<
3832  *         __pyx_import_array()
3833  *     except Exception:
3834  */
3835   {
3836     __Pyx_PyThreadState_declare
3837     __Pyx_PyThreadState_assign
3838     __Pyx_ExceptionSave(&__pyx_t_1, &__pyx_t_2, &__pyx_t_3);
3839     __Pyx_XGOTREF(__pyx_t_1);
3840     __Pyx_XGOTREF(__pyx_t_2);
3841     __Pyx_XGOTREF(__pyx_t_3);
3842     /*try:*/ {
3843 
3844       /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":882
3845  * cdef inline int import_array() except -1:
3846  *     try:
3847  *         __pyx_import_array()             # <<<<<<<<<<<<<<
3848  *     except Exception:
3849  *         raise ImportError("numpy.core.multiarray failed to import")
3850  */
3851       __pyx_t_4 = _import_array(); if (unlikely(__pyx_t_4 == ((int)-1))) __PYX_ERR(1, 882, __pyx_L3_error)
3852 
3853       /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":881
3854  * # Cython code.
3855  * cdef inline int import_array() except -1:
3856  *     try:             # <<<<<<<<<<<<<<
3857  *         __pyx_import_array()
3858  *     except Exception:
3859  */
3860     }
3861     __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
3862     __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
3863     __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
3864     goto __pyx_L8_try_end;
3865     __pyx_L3_error:;
3866 
3867     /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":883
3868  *     try:
3869  *         __pyx_import_array()
3870  *     except Exception:             # <<<<<<<<<<<<<<
3871  *         raise ImportError("numpy.core.multiarray failed to import")
3872  *
3873  */
3874     __pyx_t_4 = __Pyx_PyErr_ExceptionMatches(((PyObject *)(&((PyTypeObject*)PyExc_Exception)[0])));
3875     if (__pyx_t_4) {
3876       __Pyx_AddTraceback("numpy.import_array", __pyx_clineno, __pyx_lineno, __pyx_filename);
3877       if (__Pyx_GetException(&__pyx_t_5, &__pyx_t_6, &__pyx_t_7) < 0) __PYX_ERR(1, 883, __pyx_L5_except_error)
3878       __Pyx_GOTREF(__pyx_t_5);
3879       __Pyx_GOTREF(__pyx_t_6);
3880       __Pyx_GOTREF(__pyx_t_7);
3881 
3882       /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":884
3883  *         __pyx_import_array()
3884  *     except Exception:
3885  *         raise ImportError("numpy.core.multiarray failed to import")             # <<<<<<<<<<<<<<
3886  *
3887  * cdef inline int import_umath() except -1:
3888  */
3889       __pyx_t_8 = __Pyx_PyObject_Call(__pyx_builtin_ImportError, __pyx_tuple_, NULL); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 884, __pyx_L5_except_error)
3890       __Pyx_GOTREF(__pyx_t_8);
3891       __Pyx_Raise(__pyx_t_8, 0, 0, 0);
3892       __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
3893       __PYX_ERR(1, 884, __pyx_L5_except_error)
3894     }
3895     goto __pyx_L5_except_error;
3896     __pyx_L5_except_error:;
3897 
3898     /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":881
3899  * # Cython code.
3900  * cdef inline int import_array() except -1:
3901  *     try:             # <<<<<<<<<<<<<<
3902  *         __pyx_import_array()
3903  *     except Exception:
3904  */
3905     __Pyx_XGIVEREF(__pyx_t_1);
3906     __Pyx_XGIVEREF(__pyx_t_2);
3907     __Pyx_XGIVEREF(__pyx_t_3);
3908     __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3);
3909     goto __pyx_L1_error;
3910     __pyx_L8_try_end:;
3911   }
3912 
3913   /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":880
3914  * # Versions of the import_* functions which are more suitable for
3915  * # Cython code.
3916  * cdef inline int import_array() except -1:             # <<<<<<<<<<<<<<
3917  *     try:
3918  *         __pyx_import_array()
3919  */
3920 
3921   /* function exit code */
3922   __pyx_r = 0;
3923   goto __pyx_L0;
3924   __pyx_L1_error:;
3925   __Pyx_XDECREF(__pyx_t_5);
3926   __Pyx_XDECREF(__pyx_t_6);
3927   __Pyx_XDECREF(__pyx_t_7);
3928   __Pyx_XDECREF(__pyx_t_8);
3929   __Pyx_AddTraceback("numpy.import_array", __pyx_clineno, __pyx_lineno, __pyx_filename);
3930   __pyx_r = -1;
3931   __pyx_L0:;
3932   __Pyx_RefNannyFinishContext();
3933   return __pyx_r;
3934 }
3935 
3936 /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":886
3937  *         raise ImportError("numpy.core.multiarray failed to import")
3938  *
3939  * cdef inline int import_umath() except -1:             # <<<<<<<<<<<<<<
3940  *     try:
3941  *         _import_umath()
3942  */
3943 
__pyx_f_5numpy_import_umath(void)3944 static CYTHON_INLINE int __pyx_f_5numpy_import_umath(void) {
3945   int __pyx_r;
3946   __Pyx_RefNannyDeclarations
3947   PyObject *__pyx_t_1 = NULL;
3948   PyObject *__pyx_t_2 = NULL;
3949   PyObject *__pyx_t_3 = NULL;
3950   int __pyx_t_4;
3951   PyObject *__pyx_t_5 = NULL;
3952   PyObject *__pyx_t_6 = NULL;
3953   PyObject *__pyx_t_7 = NULL;
3954   PyObject *__pyx_t_8 = NULL;
3955   int __pyx_lineno = 0;
3956   const char *__pyx_filename = NULL;
3957   int __pyx_clineno = 0;
3958   __Pyx_RefNannySetupContext("import_umath", 0);
3959 
3960   /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":887
3961  *
3962  * cdef inline int import_umath() except -1:
3963  *     try:             # <<<<<<<<<<<<<<
3964  *         _import_umath()
3965  *     except Exception:
3966  */
3967   {
3968     __Pyx_PyThreadState_declare
3969     __Pyx_PyThreadState_assign
3970     __Pyx_ExceptionSave(&__pyx_t_1, &__pyx_t_2, &__pyx_t_3);
3971     __Pyx_XGOTREF(__pyx_t_1);
3972     __Pyx_XGOTREF(__pyx_t_2);
3973     __Pyx_XGOTREF(__pyx_t_3);
3974     /*try:*/ {
3975 
3976       /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":888
3977  * cdef inline int import_umath() except -1:
3978  *     try:
3979  *         _import_umath()             # <<<<<<<<<<<<<<
3980  *     except Exception:
3981  *         raise ImportError("numpy.core.umath failed to import")
3982  */
3983       __pyx_t_4 = _import_umath(); if (unlikely(__pyx_t_4 == ((int)-1))) __PYX_ERR(1, 888, __pyx_L3_error)
3984 
3985       /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":887
3986  *
3987  * cdef inline int import_umath() except -1:
3988  *     try:             # <<<<<<<<<<<<<<
3989  *         _import_umath()
3990  *     except Exception:
3991  */
3992     }
3993     __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
3994     __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
3995     __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
3996     goto __pyx_L8_try_end;
3997     __pyx_L3_error:;
3998 
3999     /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":889
4000  *     try:
4001  *         _import_umath()
4002  *     except Exception:             # <<<<<<<<<<<<<<
4003  *         raise ImportError("numpy.core.umath failed to import")
4004  *
4005  */
4006     __pyx_t_4 = __Pyx_PyErr_ExceptionMatches(((PyObject *)(&((PyTypeObject*)PyExc_Exception)[0])));
4007     if (__pyx_t_4) {
4008       __Pyx_AddTraceback("numpy.import_umath", __pyx_clineno, __pyx_lineno, __pyx_filename);
4009       if (__Pyx_GetException(&__pyx_t_5, &__pyx_t_6, &__pyx_t_7) < 0) __PYX_ERR(1, 889, __pyx_L5_except_error)
4010       __Pyx_GOTREF(__pyx_t_5);
4011       __Pyx_GOTREF(__pyx_t_6);
4012       __Pyx_GOTREF(__pyx_t_7);
4013 
4014       /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":890
4015  *         _import_umath()
4016  *     except Exception:
4017  *         raise ImportError("numpy.core.umath failed to import")             # <<<<<<<<<<<<<<
4018  *
4019  * cdef inline int import_ufunc() except -1:
4020  */
4021       __pyx_t_8 = __Pyx_PyObject_Call(__pyx_builtin_ImportError, __pyx_tuple__2, NULL); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 890, __pyx_L5_except_error)
4022       __Pyx_GOTREF(__pyx_t_8);
4023       __Pyx_Raise(__pyx_t_8, 0, 0, 0);
4024       __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
4025       __PYX_ERR(1, 890, __pyx_L5_except_error)
4026     }
4027     goto __pyx_L5_except_error;
4028     __pyx_L5_except_error:;
4029 
4030     /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":887
4031  *
4032  * cdef inline int import_umath() except -1:
4033  *     try:             # <<<<<<<<<<<<<<
4034  *         _import_umath()
4035  *     except Exception:
4036  */
4037     __Pyx_XGIVEREF(__pyx_t_1);
4038     __Pyx_XGIVEREF(__pyx_t_2);
4039     __Pyx_XGIVEREF(__pyx_t_3);
4040     __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3);
4041     goto __pyx_L1_error;
4042     __pyx_L8_try_end:;
4043   }
4044 
4045   /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":886
4046  *         raise ImportError("numpy.core.multiarray failed to import")
4047  *
4048  * cdef inline int import_umath() except -1:             # <<<<<<<<<<<<<<
4049  *     try:
4050  *         _import_umath()
4051  */
4052 
4053   /* function exit code */
4054   __pyx_r = 0;
4055   goto __pyx_L0;
4056   __pyx_L1_error:;
4057   __Pyx_XDECREF(__pyx_t_5);
4058   __Pyx_XDECREF(__pyx_t_6);
4059   __Pyx_XDECREF(__pyx_t_7);
4060   __Pyx_XDECREF(__pyx_t_8);
4061   __Pyx_AddTraceback("numpy.import_umath", __pyx_clineno, __pyx_lineno, __pyx_filename);
4062   __pyx_r = -1;
4063   __pyx_L0:;
4064   __Pyx_RefNannyFinishContext();
4065   return __pyx_r;
4066 }
4067 
4068 /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":892
4069  *         raise ImportError("numpy.core.umath failed to import")
4070  *
4071  * cdef inline int import_ufunc() except -1:             # <<<<<<<<<<<<<<
4072  *     try:
4073  *         _import_umath()
4074  */
4075 
__pyx_f_5numpy_import_ufunc(void)4076 static CYTHON_INLINE int __pyx_f_5numpy_import_ufunc(void) {
4077   int __pyx_r;
4078   __Pyx_RefNannyDeclarations
4079   PyObject *__pyx_t_1 = NULL;
4080   PyObject *__pyx_t_2 = NULL;
4081   PyObject *__pyx_t_3 = NULL;
4082   int __pyx_t_4;
4083   PyObject *__pyx_t_5 = NULL;
4084   PyObject *__pyx_t_6 = NULL;
4085   PyObject *__pyx_t_7 = NULL;
4086   PyObject *__pyx_t_8 = NULL;
4087   int __pyx_lineno = 0;
4088   const char *__pyx_filename = NULL;
4089   int __pyx_clineno = 0;
4090   __Pyx_RefNannySetupContext("import_ufunc", 0);
4091 
4092   /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":893
4093  *
4094  * cdef inline int import_ufunc() except -1:
4095  *     try:             # <<<<<<<<<<<<<<
4096  *         _import_umath()
4097  *     except Exception:
4098  */
4099   {
4100     __Pyx_PyThreadState_declare
4101     __Pyx_PyThreadState_assign
4102     __Pyx_ExceptionSave(&__pyx_t_1, &__pyx_t_2, &__pyx_t_3);
4103     __Pyx_XGOTREF(__pyx_t_1);
4104     __Pyx_XGOTREF(__pyx_t_2);
4105     __Pyx_XGOTREF(__pyx_t_3);
4106     /*try:*/ {
4107 
4108       /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":894
4109  * cdef inline int import_ufunc() except -1:
4110  *     try:
4111  *         _import_umath()             # <<<<<<<<<<<<<<
4112  *     except Exception:
4113  *         raise ImportError("numpy.core.umath failed to import")
4114  */
4115       __pyx_t_4 = _import_umath(); if (unlikely(__pyx_t_4 == ((int)-1))) __PYX_ERR(1, 894, __pyx_L3_error)
4116 
4117       /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":893
4118  *
4119  * cdef inline int import_ufunc() except -1:
4120  *     try:             # <<<<<<<<<<<<<<
4121  *         _import_umath()
4122  *     except Exception:
4123  */
4124     }
4125     __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
4126     __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
4127     __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
4128     goto __pyx_L8_try_end;
4129     __pyx_L3_error:;
4130 
4131     /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":895
4132  *     try:
4133  *         _import_umath()
4134  *     except Exception:             # <<<<<<<<<<<<<<
4135  *         raise ImportError("numpy.core.umath failed to import")
4136  *
4137  */
4138     __pyx_t_4 = __Pyx_PyErr_ExceptionMatches(((PyObject *)(&((PyTypeObject*)PyExc_Exception)[0])));
4139     if (__pyx_t_4) {
4140       __Pyx_AddTraceback("numpy.import_ufunc", __pyx_clineno, __pyx_lineno, __pyx_filename);
4141       if (__Pyx_GetException(&__pyx_t_5, &__pyx_t_6, &__pyx_t_7) < 0) __PYX_ERR(1, 895, __pyx_L5_except_error)
4142       __Pyx_GOTREF(__pyx_t_5);
4143       __Pyx_GOTREF(__pyx_t_6);
4144       __Pyx_GOTREF(__pyx_t_7);
4145 
4146       /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":896
4147  *         _import_umath()
4148  *     except Exception:
4149  *         raise ImportError("numpy.core.umath failed to import")             # <<<<<<<<<<<<<<
4150  *
4151  * cdef extern from *:
4152  */
4153       __pyx_t_8 = __Pyx_PyObject_Call(__pyx_builtin_ImportError, __pyx_tuple__2, NULL); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 896, __pyx_L5_except_error)
4154       __Pyx_GOTREF(__pyx_t_8);
4155       __Pyx_Raise(__pyx_t_8, 0, 0, 0);
4156       __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
4157       __PYX_ERR(1, 896, __pyx_L5_except_error)
4158     }
4159     goto __pyx_L5_except_error;
4160     __pyx_L5_except_error:;
4161 
4162     /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":893
4163  *
4164  * cdef inline int import_ufunc() except -1:
4165  *     try:             # <<<<<<<<<<<<<<
4166  *         _import_umath()
4167  *     except Exception:
4168  */
4169     __Pyx_XGIVEREF(__pyx_t_1);
4170     __Pyx_XGIVEREF(__pyx_t_2);
4171     __Pyx_XGIVEREF(__pyx_t_3);
4172     __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3);
4173     goto __pyx_L1_error;
4174     __pyx_L8_try_end:;
4175   }
4176 
4177   /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":892
4178  *         raise ImportError("numpy.core.umath failed to import")
4179  *
4180  * cdef inline int import_ufunc() except -1:             # <<<<<<<<<<<<<<
4181  *     try:
4182  *         _import_umath()
4183  */
4184 
4185   /* function exit code */
4186   __pyx_r = 0;
4187   goto __pyx_L0;
4188   __pyx_L1_error:;
4189   __Pyx_XDECREF(__pyx_t_5);
4190   __Pyx_XDECREF(__pyx_t_6);
4191   __Pyx_XDECREF(__pyx_t_7);
4192   __Pyx_XDECREF(__pyx_t_8);
4193   __Pyx_AddTraceback("numpy.import_ufunc", __pyx_clineno, __pyx_lineno, __pyx_filename);
4194   __pyx_r = -1;
4195   __pyx_L0:;
4196   __Pyx_RefNannyFinishContext();
4197   return __pyx_r;
4198 }
4199 
4200 static PyMethodDef __pyx_methods[] = {
4201   {"cy_overlap", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_5qutip_7control_8cy_grape_1cy_overlap, METH_VARARGS|METH_KEYWORDS, 0},
4202   {"cy_grape_inner", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_5qutip_7control_8cy_grape_3cy_grape_inner, METH_VARARGS|METH_KEYWORDS, 0},
4203   {0, 0, 0, 0}
4204 };
4205 
4206 #if PY_MAJOR_VERSION >= 3
4207 #if CYTHON_PEP489_MULTI_PHASE_INIT
4208 static PyObject* __pyx_pymod_create(PyObject *spec, PyModuleDef *def); /*proto*/
4209 static int __pyx_pymod_exec_cy_grape(PyObject* module); /*proto*/
4210 static PyModuleDef_Slot __pyx_moduledef_slots[] = {
4211   {Py_mod_create, (void*)__pyx_pymod_create},
4212   {Py_mod_exec, (void*)__pyx_pymod_exec_cy_grape},
4213   {0, NULL}
4214 };
4215 #endif
4216 
4217 static struct PyModuleDef __pyx_moduledef = {
4218     PyModuleDef_HEAD_INIT,
4219     "cy_grape",
4220     0, /* m_doc */
4221   #if CYTHON_PEP489_MULTI_PHASE_INIT
4222     0, /* m_size */
4223   #else
4224     -1, /* m_size */
4225   #endif
4226     __pyx_methods /* m_methods */,
4227   #if CYTHON_PEP489_MULTI_PHASE_INIT
4228     __pyx_moduledef_slots, /* m_slots */
4229   #else
4230     NULL, /* m_reload */
4231   #endif
4232     NULL, /* m_traverse */
4233     NULL, /* m_clear */
4234     NULL /* m_free */
4235 };
4236 #endif
4237 #ifndef CYTHON_SMALL_CODE
4238 #if defined(__clang__)
4239     #define CYTHON_SMALL_CODE
4240 #elif defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3))
4241     #define CYTHON_SMALL_CODE __attribute__((cold))
4242 #else
4243     #define CYTHON_SMALL_CODE
4244 #endif
4245 #endif
4246 
4247 static __Pyx_StringTabEntry __pyx_string_tab[] = {
4248   {&__pyx_n_s_CTYPE, __pyx_k_CTYPE, sizeof(__pyx_k_CTYPE), 0, 0, 1, 1},
4249   {&__pyx_n_s_DTYPE, __pyx_k_DTYPE, sizeof(__pyx_k_DTYPE), 0, 0, 1, 1},
4250   {&__pyx_n_s_H_ops, __pyx_k_H_ops, sizeof(__pyx_k_H_ops), 0, 0, 1, 1},
4251   {&__pyx_n_s_ITYPE, __pyx_k_ITYPE, sizeof(__pyx_k_ITYPE), 0, 0, 1, 1},
4252   {&__pyx_n_s_ImportError, __pyx_k_ImportError, sizeof(__pyx_k_ImportError), 0, 0, 1, 1},
4253   {&__pyx_n_s_J, __pyx_k_J, sizeof(__pyx_k_J), 0, 0, 1, 1},
4254   {&__pyx_n_s_M, __pyx_k_M, sizeof(__pyx_k_M), 0, 0, 1, 1},
4255   {&__pyx_n_s_T, __pyx_k_T, sizeof(__pyx_k_T), 0, 0, 1, 1},
4256   {&__pyx_n_s_U, __pyx_k_U, sizeof(__pyx_k_U), 0, 0, 1, 1},
4257   {&__pyx_n_s_U_b_list, __pyx_k_U_b_list, sizeof(__pyx_k_U_b_list), 0, 0, 1, 1},
4258   {&__pyx_n_s_U_f_list, __pyx_k_U_f_list, sizeof(__pyx_k_U_f_list), 0, 0, 1, 1},
4259   {&__pyx_n_s_alpha, __pyx_k_alpha, sizeof(__pyx_k_alpha), 0, 0, 1, 1},
4260   {&__pyx_n_s_beta, __pyx_k_beta, sizeof(__pyx_k_beta), 0, 0, 1, 1},
4261   {&__pyx_n_s_cline_in_traceback, __pyx_k_cline_in_traceback, sizeof(__pyx_k_cline_in_traceback), 0, 0, 1, 1},
4262   {&__pyx_n_s_complex128, __pyx_k_complex128, sizeof(__pyx_k_complex128), 0, 0, 1, 1},
4263   {&__pyx_n_s_conj, __pyx_k_conj, sizeof(__pyx_k_conj), 0, 0, 1, 1},
4264   {&__pyx_n_s_data, __pyx_k_data, sizeof(__pyx_k_data), 0, 0, 1, 1},
4265   {&__pyx_n_s_dt, __pyx_k_dt, sizeof(__pyx_k_dt), 0, 0, 1, 1},
4266   {&__pyx_n_s_eps, __pyx_k_eps, sizeof(__pyx_k_eps), 0, 0, 1, 1},
4267   {&__pyx_n_s_float64, __pyx_k_float64, sizeof(__pyx_k_float64), 0, 0, 1, 1},
4268   {&__pyx_n_s_import, __pyx_k_import, sizeof(__pyx_k_import), 0, 0, 1, 1},
4269   {&__pyx_n_s_indices, __pyx_k_indices, sizeof(__pyx_k_indices), 0, 0, 1, 1},
4270   {&__pyx_n_s_indptr, __pyx_k_indptr, sizeof(__pyx_k_indptr), 0, 0, 1, 1},
4271   {&__pyx_n_s_int32, __pyx_k_int32, sizeof(__pyx_k_int32), 0, 0, 1, 1},
4272   {&__pyx_n_s_int64, __pyx_k_int64, sizeof(__pyx_k_int64), 0, 0, 1, 1},
4273   {&__pyx_n_s_main, __pyx_k_main, sizeof(__pyx_k_main), 0, 0, 1, 1},
4274   {&__pyx_n_s_name, __pyx_k_name, sizeof(__pyx_k_name), 0, 0, 1, 1},
4275   {&__pyx_n_s_np, __pyx_k_np, sizeof(__pyx_k_np), 0, 0, 1, 1},
4276   {&__pyx_n_s_numpy, __pyx_k_numpy, sizeof(__pyx_k_numpy), 0, 0, 1, 1},
4277   {&__pyx_kp_u_numpy_core_multiarray_failed_to, __pyx_k_numpy_core_multiarray_failed_to, sizeof(__pyx_k_numpy_core_multiarray_failed_to), 0, 1, 0, 0},
4278   {&__pyx_kp_u_numpy_core_umath_failed_to_impor, __pyx_k_numpy_core_umath_failed_to_impor, sizeof(__pyx_k_numpy_core_umath_failed_to_impor), 0, 1, 0, 0},
4279   {&__pyx_n_s_op1, __pyx_k_op1, sizeof(__pyx_k_op1), 0, 0, 1, 1},
4280   {&__pyx_n_s_op2, __pyx_k_op2, sizeof(__pyx_k_op2), 0, 0, 1, 1},
4281   {&__pyx_n_s_phase_sensitive, __pyx_k_phase_sensitive, sizeof(__pyx_k_phase_sensitive), 0, 0, 1, 1},
4282   {&__pyx_n_s_r, __pyx_k_r, sizeof(__pyx_k_r), 0, 0, 1, 1},
4283   {&__pyx_n_s_range, __pyx_k_range, sizeof(__pyx_k_range), 0, 0, 1, 1},
4284   {&__pyx_n_s_real, __pyx_k_real, sizeof(__pyx_k_real), 0, 0, 1, 1},
4285   {&__pyx_n_s_shape, __pyx_k_shape, sizeof(__pyx_k_shape), 0, 0, 1, 1},
4286   {&__pyx_n_s_test, __pyx_k_test, sizeof(__pyx_k_test), 0, 0, 1, 1},
4287   {&__pyx_n_s_tocsr, __pyx_k_tocsr, sizeof(__pyx_k_tocsr), 0, 0, 1, 1},
4288   {&__pyx_n_s_u, __pyx_k_u, sizeof(__pyx_k_u), 0, 0, 1, 1},
4289   {&__pyx_n_s_u_max, __pyx_k_u_max, sizeof(__pyx_k_u_max), 0, 0, 1, 1},
4290   {&__pyx_n_s_u_min, __pyx_k_u_min, sizeof(__pyx_k_u_min), 0, 0, 1, 1},
4291   {&__pyx_n_s_use_u_limits, __pyx_k_use_u_limits, sizeof(__pyx_k_use_u_limits), 0, 0, 1, 1},
4292   {0, 0, 0, 0, 0, 0, 0}
4293 };
__Pyx_InitCachedBuiltins(void)4294 static CYTHON_SMALL_CODE int __Pyx_InitCachedBuiltins(void) {
4295   __pyx_builtin_range = __Pyx_GetBuiltinName(__pyx_n_s_range); if (!__pyx_builtin_range) __PYX_ERR(0, 72, __pyx_L1_error)
4296   __pyx_builtin_ImportError = __Pyx_GetBuiltinName(__pyx_n_s_ImportError); if (!__pyx_builtin_ImportError) __PYX_ERR(1, 884, __pyx_L1_error)
4297   return 0;
4298   __pyx_L1_error:;
4299   return -1;
4300 }
4301 
__Pyx_InitCachedConstants(void)4302 static CYTHON_SMALL_CODE int __Pyx_InitCachedConstants(void) {
4303   __Pyx_RefNannyDeclarations
4304   __Pyx_RefNannySetupContext("__Pyx_InitCachedConstants", 0);
4305 
4306   /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":884
4307  *         __pyx_import_array()
4308  *     except Exception:
4309  *         raise ImportError("numpy.core.multiarray failed to import")             # <<<<<<<<<<<<<<
4310  *
4311  * cdef inline int import_umath() except -1:
4312  */
4313   __pyx_tuple_ = PyTuple_Pack(1, __pyx_kp_u_numpy_core_multiarray_failed_to); if (unlikely(!__pyx_tuple_)) __PYX_ERR(1, 884, __pyx_L1_error)
4314   __Pyx_GOTREF(__pyx_tuple_);
4315   __Pyx_GIVEREF(__pyx_tuple_);
4316 
4317   /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":890
4318  *         _import_umath()
4319  *     except Exception:
4320  *         raise ImportError("numpy.core.umath failed to import")             # <<<<<<<<<<<<<<
4321  *
4322  * cdef inline int import_ufunc() except -1:
4323  */
4324   __pyx_tuple__2 = PyTuple_Pack(1, __pyx_kp_u_numpy_core_umath_failed_to_impor); if (unlikely(!__pyx_tuple__2)) __PYX_ERR(1, 890, __pyx_L1_error)
4325   __Pyx_GOTREF(__pyx_tuple__2);
4326   __Pyx_GIVEREF(__pyx_tuple__2);
4327   __Pyx_RefNannyFinishContext();
4328   return 0;
4329   __pyx_L1_error:;
4330   __Pyx_RefNannyFinishContext();
4331   return -1;
4332 }
4333 
__Pyx_InitGlobals(void)4334 static CYTHON_SMALL_CODE int __Pyx_InitGlobals(void) {
4335   if (__Pyx_InitStrings(__pyx_string_tab) < 0) __PYX_ERR(0, 1, __pyx_L1_error);
4336   __pyx_int_2 = PyInt_FromLong(2); if (unlikely(!__pyx_int_2)) __PYX_ERR(0, 1, __pyx_L1_error)
4337   return 0;
4338   __pyx_L1_error:;
4339   return -1;
4340 }
4341 
4342 static CYTHON_SMALL_CODE int __Pyx_modinit_global_init_code(void); /*proto*/
4343 static CYTHON_SMALL_CODE int __Pyx_modinit_variable_export_code(void); /*proto*/
4344 static CYTHON_SMALL_CODE int __Pyx_modinit_function_export_code(void); /*proto*/
4345 static CYTHON_SMALL_CODE int __Pyx_modinit_type_init_code(void); /*proto*/
4346 static CYTHON_SMALL_CODE int __Pyx_modinit_type_import_code(void); /*proto*/
4347 static CYTHON_SMALL_CODE int __Pyx_modinit_variable_import_code(void); /*proto*/
4348 static CYTHON_SMALL_CODE int __Pyx_modinit_function_import_code(void); /*proto*/
4349 
__Pyx_modinit_global_init_code(void)4350 static int __Pyx_modinit_global_init_code(void) {
4351   __Pyx_RefNannyDeclarations
4352   __Pyx_RefNannySetupContext("__Pyx_modinit_global_init_code", 0);
4353   /*--- Global init code ---*/
4354   __Pyx_RefNannyFinishContext();
4355   return 0;
4356 }
4357 
__Pyx_modinit_variable_export_code(void)4358 static int __Pyx_modinit_variable_export_code(void) {
4359   __Pyx_RefNannyDeclarations
4360   __Pyx_RefNannySetupContext("__Pyx_modinit_variable_export_code", 0);
4361   /*--- Variable export code ---*/
4362   __Pyx_RefNannyFinishContext();
4363   return 0;
4364 }
4365 
__Pyx_modinit_function_export_code(void)4366 static int __Pyx_modinit_function_export_code(void) {
4367   __Pyx_RefNannyDeclarations
4368   __Pyx_RefNannySetupContext("__Pyx_modinit_function_export_code", 0);
4369   /*--- Function export code ---*/
4370   __Pyx_RefNannyFinishContext();
4371   return 0;
4372 }
4373 
__Pyx_modinit_type_init_code(void)4374 static int __Pyx_modinit_type_init_code(void) {
4375   __Pyx_RefNannyDeclarations
4376   __Pyx_RefNannySetupContext("__Pyx_modinit_type_init_code", 0);
4377   /*--- Type init code ---*/
4378   __Pyx_RefNannyFinishContext();
4379   return 0;
4380 }
4381 
__Pyx_modinit_type_import_code(void)4382 static int __Pyx_modinit_type_import_code(void) {
4383   __Pyx_RefNannyDeclarations
4384   PyObject *__pyx_t_1 = NULL;
4385   int __pyx_lineno = 0;
4386   const char *__pyx_filename = NULL;
4387   int __pyx_clineno = 0;
4388   __Pyx_RefNannySetupContext("__Pyx_modinit_type_import_code", 0);
4389   /*--- Type import code ---*/
4390   __pyx_t_1 = PyImport_ImportModule(__Pyx_BUILTIN_MODULE_NAME); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 9, __pyx_L1_error)
4391   __Pyx_GOTREF(__pyx_t_1);
4392   __pyx_ptype_7cpython_4type_type = __Pyx_ImportType(__pyx_t_1, __Pyx_BUILTIN_MODULE_NAME, "type",
4393   #if defined(PYPY_VERSION_NUM) && PYPY_VERSION_NUM < 0x050B0000
4394   sizeof(PyTypeObject),
4395   #else
4396   sizeof(PyHeapTypeObject),
4397   #endif
4398   __Pyx_ImportType_CheckSize_Warn);
4399    if (!__pyx_ptype_7cpython_4type_type) __PYX_ERR(2, 9, __pyx_L1_error)
4400   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
4401   __pyx_t_1 = PyImport_ImportModule("numpy"); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 199, __pyx_L1_error)
4402   __Pyx_GOTREF(__pyx_t_1);
4403   __pyx_ptype_5numpy_dtype = __Pyx_ImportType(__pyx_t_1, "numpy", "dtype", sizeof(PyArray_Descr), __Pyx_ImportType_CheckSize_Ignore);
4404    if (!__pyx_ptype_5numpy_dtype) __PYX_ERR(1, 199, __pyx_L1_error)
4405   __pyx_ptype_5numpy_flatiter = __Pyx_ImportType(__pyx_t_1, "numpy", "flatiter", sizeof(PyArrayIterObject), __Pyx_ImportType_CheckSize_Ignore);
4406    if (!__pyx_ptype_5numpy_flatiter) __PYX_ERR(1, 222, __pyx_L1_error)
4407   __pyx_ptype_5numpy_broadcast = __Pyx_ImportType(__pyx_t_1, "numpy", "broadcast", sizeof(PyArrayMultiIterObject), __Pyx_ImportType_CheckSize_Ignore);
4408    if (!__pyx_ptype_5numpy_broadcast) __PYX_ERR(1, 226, __pyx_L1_error)
4409   __pyx_ptype_5numpy_ndarray = __Pyx_ImportType(__pyx_t_1, "numpy", "ndarray", sizeof(PyArrayObject), __Pyx_ImportType_CheckSize_Ignore);
4410    if (!__pyx_ptype_5numpy_ndarray) __PYX_ERR(1, 238, __pyx_L1_error)
4411   __pyx_ptype_5numpy_ufunc = __Pyx_ImportType(__pyx_t_1, "numpy", "ufunc", sizeof(PyUFuncObject), __Pyx_ImportType_CheckSize_Ignore);
4412    if (!__pyx_ptype_5numpy_ufunc) __PYX_ERR(1, 764, __pyx_L1_error)
4413   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
4414   __Pyx_RefNannyFinishContext();
4415   return 0;
4416   __pyx_L1_error:;
4417   __Pyx_XDECREF(__pyx_t_1);
4418   __Pyx_RefNannyFinishContext();
4419   return -1;
4420 }
4421 
__Pyx_modinit_variable_import_code(void)4422 static int __Pyx_modinit_variable_import_code(void) {
4423   __Pyx_RefNannyDeclarations
4424   __Pyx_RefNannySetupContext("__Pyx_modinit_variable_import_code", 0);
4425   /*--- Variable import code ---*/
4426   __Pyx_RefNannyFinishContext();
4427   return 0;
4428 }
4429 
__Pyx_modinit_function_import_code(void)4430 static int __Pyx_modinit_function_import_code(void) {
4431   __Pyx_RefNannyDeclarations
4432   __Pyx_RefNannySetupContext("__Pyx_modinit_function_import_code", 0);
4433   /*--- Function import code ---*/
4434   __Pyx_RefNannyFinishContext();
4435   return 0;
4436 }
4437 
4438 
4439 #ifndef CYTHON_NO_PYINIT_EXPORT
4440 #define __Pyx_PyMODINIT_FUNC PyMODINIT_FUNC
4441 #elif PY_MAJOR_VERSION < 3
4442 #ifdef __cplusplus
4443 #define __Pyx_PyMODINIT_FUNC extern "C" void
4444 #else
4445 #define __Pyx_PyMODINIT_FUNC void
4446 #endif
4447 #else
4448 #ifdef __cplusplus
4449 #define __Pyx_PyMODINIT_FUNC extern "C" PyObject *
4450 #else
4451 #define __Pyx_PyMODINIT_FUNC PyObject *
4452 #endif
4453 #endif
4454 
4455 
4456 #if PY_MAJOR_VERSION < 3
4457 __Pyx_PyMODINIT_FUNC initcy_grape(void) CYTHON_SMALL_CODE; /*proto*/
initcy_grape(void)4458 __Pyx_PyMODINIT_FUNC initcy_grape(void)
4459 #else
4460 __Pyx_PyMODINIT_FUNC PyInit_cy_grape(void) CYTHON_SMALL_CODE; /*proto*/
4461 __Pyx_PyMODINIT_FUNC PyInit_cy_grape(void)
4462 #if CYTHON_PEP489_MULTI_PHASE_INIT
4463 {
4464   return PyModuleDef_Init(&__pyx_moduledef);
4465 }
4466 static CYTHON_SMALL_CODE int __Pyx_check_single_interpreter(void) {
4467     #if PY_VERSION_HEX >= 0x030700A1
4468     static PY_INT64_T main_interpreter_id = -1;
4469     PY_INT64_T current_id = PyInterpreterState_GetID(PyThreadState_Get()->interp);
4470     if (main_interpreter_id == -1) {
4471         main_interpreter_id = current_id;
4472         return (unlikely(current_id == -1)) ? -1 : 0;
4473     } else if (unlikely(main_interpreter_id != current_id))
4474     #else
4475     static PyInterpreterState *main_interpreter = NULL;
4476     PyInterpreterState *current_interpreter = PyThreadState_Get()->interp;
4477     if (!main_interpreter) {
4478         main_interpreter = current_interpreter;
4479     } else if (unlikely(main_interpreter != current_interpreter))
4480     #endif
4481     {
4482         PyErr_SetString(
4483             PyExc_ImportError,
4484             "Interpreter change detected - this module can only be loaded into one interpreter per process.");
4485         return -1;
4486     }
4487     return 0;
4488 }
4489 static CYTHON_SMALL_CODE int __Pyx_copy_spec_to_module(PyObject *spec, PyObject *moddict, const char* from_name, const char* to_name, int allow_none) {
4490     PyObject *value = PyObject_GetAttrString(spec, from_name);
4491     int result = 0;
4492     if (likely(value)) {
4493         if (allow_none || value != Py_None) {
4494             result = PyDict_SetItemString(moddict, to_name, value);
4495         }
4496         Py_DECREF(value);
4497     } else if (PyErr_ExceptionMatches(PyExc_AttributeError)) {
4498         PyErr_Clear();
4499     } else {
4500         result = -1;
4501     }
4502     return result;
4503 }
4504 static CYTHON_SMALL_CODE PyObject* __pyx_pymod_create(PyObject *spec, CYTHON_UNUSED PyModuleDef *def) {
4505     PyObject *module = NULL, *moddict, *modname;
4506     if (__Pyx_check_single_interpreter())
4507         return NULL;
4508     if (__pyx_m)
4509         return __Pyx_NewRef(__pyx_m);
4510     modname = PyObject_GetAttrString(spec, "name");
4511     if (unlikely(!modname)) goto bad;
4512     module = PyModule_NewObject(modname);
4513     Py_DECREF(modname);
4514     if (unlikely(!module)) goto bad;
4515     moddict = PyModule_GetDict(module);
4516     if (unlikely(!moddict)) goto bad;
4517     if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "loader", "__loader__", 1) < 0)) goto bad;
4518     if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "origin", "__file__", 1) < 0)) goto bad;
4519     if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "parent", "__package__", 1) < 0)) goto bad;
4520     if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "submodule_search_locations", "__path__", 0) < 0)) goto bad;
4521     return module;
4522 bad:
4523     Py_XDECREF(module);
4524     return NULL;
4525 }
4526 
4527 
4528 static CYTHON_SMALL_CODE int __pyx_pymod_exec_cy_grape(PyObject *__pyx_pyinit_module)
4529 #endif
4530 #endif
4531 {
4532   PyObject *__pyx_t_1 = NULL;
4533   PyObject *__pyx_t_2 = NULL;
4534   int __pyx_lineno = 0;
4535   const char *__pyx_filename = NULL;
4536   int __pyx_clineno = 0;
4537   __Pyx_RefNannyDeclarations
4538   #if CYTHON_PEP489_MULTI_PHASE_INIT
4539   if (__pyx_m) {
4540     if (__pyx_m == __pyx_pyinit_module) return 0;
4541     PyErr_SetString(PyExc_RuntimeError, "Module 'cy_grape' has already been imported. Re-initialisation is not supported.");
4542     return -1;
4543   }
4544   #elif PY_MAJOR_VERSION >= 3
4545   if (__pyx_m) return __Pyx_NewRef(__pyx_m);
4546   #endif
4547   #if CYTHON_REFNANNY
4548 __Pyx_RefNanny = __Pyx_RefNannyImportAPI("refnanny");
4549 if (!__Pyx_RefNanny) {
4550   PyErr_Clear();
4551   __Pyx_RefNanny = __Pyx_RefNannyImportAPI("Cython.Runtime.refnanny");
4552   if (!__Pyx_RefNanny)
4553       Py_FatalError("failed to import 'refnanny' module");
4554 }
4555 #endif
4556   __Pyx_RefNannySetupContext("__Pyx_PyMODINIT_FUNC PyInit_cy_grape(void)", 0);
4557   if (__Pyx_check_binary_version() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
4558   #ifdef __Pxy_PyFrame_Initialize_Offsets
4559   __Pxy_PyFrame_Initialize_Offsets();
4560   #endif
4561   __pyx_empty_tuple = PyTuple_New(0); if (unlikely(!__pyx_empty_tuple)) __PYX_ERR(0, 1, __pyx_L1_error)
4562   __pyx_empty_bytes = PyBytes_FromStringAndSize("", 0); if (unlikely(!__pyx_empty_bytes)) __PYX_ERR(0, 1, __pyx_L1_error)
4563   __pyx_empty_unicode = PyUnicode_FromStringAndSize("", 0); if (unlikely(!__pyx_empty_unicode)) __PYX_ERR(0, 1, __pyx_L1_error)
4564   #ifdef __Pyx_CyFunction_USED
4565   if (__pyx_CyFunction_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
4566   #endif
4567   #ifdef __Pyx_FusedFunction_USED
4568   if (__pyx_FusedFunction_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
4569   #endif
4570   #ifdef __Pyx_Coroutine_USED
4571   if (__pyx_Coroutine_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
4572   #endif
4573   #ifdef __Pyx_Generator_USED
4574   if (__pyx_Generator_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
4575   #endif
4576   #ifdef __Pyx_AsyncGen_USED
4577   if (__pyx_AsyncGen_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
4578   #endif
4579   #ifdef __Pyx_StopAsyncIteration_USED
4580   if (__pyx_StopAsyncIteration_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
4581   #endif
4582   /*--- Library function declarations ---*/
4583   /*--- Threads initialization code ---*/
4584   #if defined(__PYX_FORCE_INIT_THREADS) && __PYX_FORCE_INIT_THREADS
4585   #ifdef WITH_THREAD /* Python build with threading support? */
4586   PyEval_InitThreads();
4587   #endif
4588   #endif
4589   /*--- Module creation code ---*/
4590   #if CYTHON_PEP489_MULTI_PHASE_INIT
4591   __pyx_m = __pyx_pyinit_module;
4592   Py_INCREF(__pyx_m);
4593   #else
4594   #if PY_MAJOR_VERSION < 3
4595   __pyx_m = Py_InitModule4("cy_grape", __pyx_methods, 0, 0, PYTHON_API_VERSION); Py_XINCREF(__pyx_m);
4596   #else
4597   __pyx_m = PyModule_Create(&__pyx_moduledef);
4598   #endif
4599   if (unlikely(!__pyx_m)) __PYX_ERR(0, 1, __pyx_L1_error)
4600   #endif
4601   __pyx_d = PyModule_GetDict(__pyx_m); if (unlikely(!__pyx_d)) __PYX_ERR(0, 1, __pyx_L1_error)
4602   Py_INCREF(__pyx_d);
4603   __pyx_b = PyImport_AddModule(__Pyx_BUILTIN_MODULE_NAME); if (unlikely(!__pyx_b)) __PYX_ERR(0, 1, __pyx_L1_error)
4604   Py_INCREF(__pyx_b);
4605   __pyx_cython_runtime = PyImport_AddModule((char *) "cython_runtime"); if (unlikely(!__pyx_cython_runtime)) __PYX_ERR(0, 1, __pyx_L1_error)
4606   Py_INCREF(__pyx_cython_runtime);
4607   if (PyObject_SetAttrString(__pyx_m, "__builtins__", __pyx_b) < 0) __PYX_ERR(0, 1, __pyx_L1_error);
4608   /*--- Initialize various global constants etc. ---*/
4609   if (__Pyx_InitGlobals() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
4610   #if PY_MAJOR_VERSION < 3 && (__PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT)
4611   if (__Pyx_init_sys_getdefaultencoding_params() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
4612   #endif
4613   if (__pyx_module_is_main_qutip__control__cy_grape) {
4614     if (PyObject_SetAttr(__pyx_m, __pyx_n_s_name, __pyx_n_s_main) < 0) __PYX_ERR(0, 1, __pyx_L1_error)
4615   }
4616   #if PY_MAJOR_VERSION >= 3
4617   {
4618     PyObject *modules = PyImport_GetModuleDict(); if (unlikely(!modules)) __PYX_ERR(0, 1, __pyx_L1_error)
4619     if (!PyDict_GetItemString(modules, "qutip.control.cy_grape")) {
4620       if (unlikely(PyDict_SetItemString(modules, "qutip.control.cy_grape", __pyx_m) < 0)) __PYX_ERR(0, 1, __pyx_L1_error)
4621     }
4622   }
4623   #endif
4624   /*--- Builtin init code ---*/
4625   if (__Pyx_InitCachedBuiltins() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
4626   /*--- Constants init code ---*/
4627   if (__Pyx_InitCachedConstants() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
4628   /*--- Global type/function init code ---*/
4629   (void)__Pyx_modinit_global_init_code();
4630   (void)__Pyx_modinit_variable_export_code();
4631   (void)__Pyx_modinit_function_export_code();
4632   (void)__Pyx_modinit_type_init_code();
4633   if (unlikely(__Pyx_modinit_type_import_code() < 0)) __PYX_ERR(0, 1, __pyx_L1_error)
4634   (void)__Pyx_modinit_variable_import_code();
4635   (void)__Pyx_modinit_function_import_code();
4636   /*--- Execution code ---*/
4637   #if defined(__Pyx_Generator_USED) || defined(__Pyx_Coroutine_USED)
4638   if (__Pyx_patch_abc() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
4639   #endif
4640 
4641   /* "qutip/control/cy_grape.pyx":34
4642  * #    OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
4643  * ###############################################################################
4644  * import numpy as np             # <<<<<<<<<<<<<<
4645  * cimport numpy as np
4646  * cimport cython
4647  */
4648   __pyx_t_1 = __Pyx_Import(__pyx_n_s_numpy, 0, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 34, __pyx_L1_error)
4649   __Pyx_GOTREF(__pyx_t_1);
4650   if (PyDict_SetItem(__pyx_d, __pyx_n_s_np, __pyx_t_1) < 0) __PYX_ERR(0, 34, __pyx_L1_error)
4651   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
4652 
4653   /* "qutip/control/cy_grape.pyx":39
4654  * cimport libc.math
4655  *
4656  * DTYPE = np.float64             # <<<<<<<<<<<<<<
4657  * ctypedef np.float64_t DTYPE_t
4658  *
4659  */
4660   __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_np); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 39, __pyx_L1_error)
4661   __Pyx_GOTREF(__pyx_t_1);
4662   __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_float64); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 39, __pyx_L1_error)
4663   __Pyx_GOTREF(__pyx_t_2);
4664   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
4665   if (PyDict_SetItem(__pyx_d, __pyx_n_s_DTYPE, __pyx_t_2) < 0) __PYX_ERR(0, 39, __pyx_L1_error)
4666   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
4667 
4668   /* "qutip/control/cy_grape.pyx":42
4669  * ctypedef np.float64_t DTYPE_t
4670  *
4671  * ITYPE = np.int32             # <<<<<<<<<<<<<<
4672  * ctypedef np.int32_t ITYPE_t
4673  *
4674  */
4675   __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_np); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 42, __pyx_L1_error)
4676   __Pyx_GOTREF(__pyx_t_2);
4677   __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_int32); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 42, __pyx_L1_error)
4678   __Pyx_GOTREF(__pyx_t_1);
4679   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
4680   if (PyDict_SetItem(__pyx_d, __pyx_n_s_ITYPE, __pyx_t_1) < 0) __PYX_ERR(0, 42, __pyx_L1_error)
4681   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
4682 
4683   /* "qutip/control/cy_grape.pyx":45
4684  * ctypedef np.int32_t ITYPE_t
4685  *
4686  * CTYPE = np.complex128             # <<<<<<<<<<<<<<
4687  * ctypedef np.complex128_t CTYPE_t
4688  *
4689  */
4690   __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_np); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 45, __pyx_L1_error)
4691   __Pyx_GOTREF(__pyx_t_1);
4692   __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_complex128); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 45, __pyx_L1_error)
4693   __Pyx_GOTREF(__pyx_t_2);
4694   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
4695   if (PyDict_SetItem(__pyx_d, __pyx_n_s_CTYPE, __pyx_t_2) < 0) __PYX_ERR(0, 45, __pyx_L1_error)
4696   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
4697 
4698   /* "qutip/control/cy_grape.pyx":48
4699  * ctypedef np.complex128_t CTYPE_t
4700  *
4701  * CTYPE = np.int64             # <<<<<<<<<<<<<<
4702  * ctypedef np.int64_t LTYPE_t
4703  *
4704  */
4705   __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_np); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 48, __pyx_L1_error)
4706   __Pyx_GOTREF(__pyx_t_2);
4707   __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_int64); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 48, __pyx_L1_error)
4708   __Pyx_GOTREF(__pyx_t_1);
4709   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
4710   if (PyDict_SetItem(__pyx_d, __pyx_n_s_CTYPE, __pyx_t_1) < 0) __PYX_ERR(0, 48, __pyx_L1_error)
4711   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
4712 
4713   /* "qutip/control/cy_grape.pyx":1
4714  * #cython: language_level=3             # <<<<<<<<<<<<<<
4715  * # This file is part of QuTiP: Quantum Toolbox in Python.
4716  * #
4717  */
4718   __pyx_t_1 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1, __pyx_L1_error)
4719   __Pyx_GOTREF(__pyx_t_1);
4720   if (PyDict_SetItem(__pyx_d, __pyx_n_s_test, __pyx_t_1) < 0) __PYX_ERR(0, 1, __pyx_L1_error)
4721   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
4722 
4723   /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":892
4724  *         raise ImportError("numpy.core.umath failed to import")
4725  *
4726  * cdef inline int import_ufunc() except -1:             # <<<<<<<<<<<<<<
4727  *     try:
4728  *         _import_umath()
4729  */
4730 
4731   /*--- Wrapped vars code ---*/
4732 
4733   goto __pyx_L0;
4734   __pyx_L1_error:;
4735   __Pyx_XDECREF(__pyx_t_1);
4736   __Pyx_XDECREF(__pyx_t_2);
4737   if (__pyx_m) {
4738     if (__pyx_d) {
4739       __Pyx_AddTraceback("init qutip.control.cy_grape", __pyx_clineno, __pyx_lineno, __pyx_filename);
4740     }
4741     Py_CLEAR(__pyx_m);
4742   } else if (!PyErr_Occurred()) {
4743     PyErr_SetString(PyExc_ImportError, "init qutip.control.cy_grape");
4744   }
4745   __pyx_L0:;
4746   __Pyx_RefNannyFinishContext();
4747   #if CYTHON_PEP489_MULTI_PHASE_INIT
4748   return (__pyx_m != NULL) ? 0 : -1;
4749   #elif PY_MAJOR_VERSION >= 3
4750   return __pyx_m;
4751   #else
4752   return;
4753   #endif
4754 }
4755 
4756 /* --- Runtime support code --- */
4757 /* Refnanny */
4758 #if CYTHON_REFNANNY
__Pyx_RefNannyImportAPI(const char * modname)4759 static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname) {
4760     PyObject *m = NULL, *p = NULL;
4761     void *r = NULL;
4762     m = PyImport_ImportModule(modname);
4763     if (!m) goto end;
4764     p = PyObject_GetAttrString(m, "RefNannyAPI");
4765     if (!p) goto end;
4766     r = PyLong_AsVoidPtr(p);
4767 end:
4768     Py_XDECREF(p);
4769     Py_XDECREF(m);
4770     return (__Pyx_RefNannyAPIStruct *)r;
4771 }
4772 #endif
4773 
4774 /* PyObjectGetAttrStr */
4775 #if CYTHON_USE_TYPE_SLOTS
__Pyx_PyObject_GetAttrStr(PyObject * obj,PyObject * attr_name)4776 static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStr(PyObject* obj, PyObject* attr_name) {
4777     PyTypeObject* tp = Py_TYPE(obj);
4778     if (likely(tp->tp_getattro))
4779         return tp->tp_getattro(obj, attr_name);
4780 #if PY_MAJOR_VERSION < 3
4781     if (likely(tp->tp_getattr))
4782         return tp->tp_getattr(obj, PyString_AS_STRING(attr_name));
4783 #endif
4784     return PyObject_GetAttr(obj, attr_name);
4785 }
4786 #endif
4787 
4788 /* GetBuiltinName */
__Pyx_GetBuiltinName(PyObject * name)4789 static PyObject *__Pyx_GetBuiltinName(PyObject *name) {
4790     PyObject* result = __Pyx_PyObject_GetAttrStr(__pyx_b, name);
4791     if (unlikely(!result)) {
4792         PyErr_Format(PyExc_NameError,
4793 #if PY_MAJOR_VERSION >= 3
4794             "name '%U' is not defined", name);
4795 #else
4796             "name '%.200s' is not defined", PyString_AS_STRING(name));
4797 #endif
4798     }
4799     return result;
4800 }
4801 
4802 /* PyFunctionFastCall */
4803 #if CYTHON_FAST_PYCALL
__Pyx_PyFunction_FastCallNoKw(PyCodeObject * co,PyObject ** args,Py_ssize_t na,PyObject * globals)4804 static PyObject* __Pyx_PyFunction_FastCallNoKw(PyCodeObject *co, PyObject **args, Py_ssize_t na,
4805                                                PyObject *globals) {
4806     PyFrameObject *f;
4807     PyThreadState *tstate = __Pyx_PyThreadState_Current;
4808     PyObject **fastlocals;
4809     Py_ssize_t i;
4810     PyObject *result;
4811     assert(globals != NULL);
4812     /* XXX Perhaps we should create a specialized
4813        PyFrame_New() that doesn't take locals, but does
4814        take builtins without sanity checking them.
4815        */
4816     assert(tstate != NULL);
4817     f = PyFrame_New(tstate, co, globals, NULL);
4818     if (f == NULL) {
4819         return NULL;
4820     }
4821     fastlocals = __Pyx_PyFrame_GetLocalsplus(f);
4822     for (i = 0; i < na; i++) {
4823         Py_INCREF(*args);
4824         fastlocals[i] = *args++;
4825     }
4826     result = PyEval_EvalFrameEx(f,0);
4827     ++tstate->recursion_depth;
4828     Py_DECREF(f);
4829     --tstate->recursion_depth;
4830     return result;
4831 }
4832 #if 1 || PY_VERSION_HEX < 0x030600B1
__Pyx_PyFunction_FastCallDict(PyObject * func,PyObject ** args,Py_ssize_t nargs,PyObject * kwargs)4833 static PyObject *__Pyx_PyFunction_FastCallDict(PyObject *func, PyObject **args, Py_ssize_t nargs, PyObject *kwargs) {
4834     PyCodeObject *co = (PyCodeObject *)PyFunction_GET_CODE(func);
4835     PyObject *globals = PyFunction_GET_GLOBALS(func);
4836     PyObject *argdefs = PyFunction_GET_DEFAULTS(func);
4837     PyObject *closure;
4838 #if PY_MAJOR_VERSION >= 3
4839     PyObject *kwdefs;
4840 #endif
4841     PyObject *kwtuple, **k;
4842     PyObject **d;
4843     Py_ssize_t nd;
4844     Py_ssize_t nk;
4845     PyObject *result;
4846     assert(kwargs == NULL || PyDict_Check(kwargs));
4847     nk = kwargs ? PyDict_Size(kwargs) : 0;
4848     if (Py_EnterRecursiveCall((char*)" while calling a Python object")) {
4849         return NULL;
4850     }
4851     if (
4852 #if PY_MAJOR_VERSION >= 3
4853             co->co_kwonlyargcount == 0 &&
4854 #endif
4855             likely(kwargs == NULL || nk == 0) &&
4856             co->co_flags == (CO_OPTIMIZED | CO_NEWLOCALS | CO_NOFREE)) {
4857         if (argdefs == NULL && co->co_argcount == nargs) {
4858             result = __Pyx_PyFunction_FastCallNoKw(co, args, nargs, globals);
4859             goto done;
4860         }
4861         else if (nargs == 0 && argdefs != NULL
4862                  && co->co_argcount == Py_SIZE(argdefs)) {
4863             /* function called with no arguments, but all parameters have
4864                a default value: use default values as arguments .*/
4865             args = &PyTuple_GET_ITEM(argdefs, 0);
4866             result =__Pyx_PyFunction_FastCallNoKw(co, args, Py_SIZE(argdefs), globals);
4867             goto done;
4868         }
4869     }
4870     if (kwargs != NULL) {
4871         Py_ssize_t pos, i;
4872         kwtuple = PyTuple_New(2 * nk);
4873         if (kwtuple == NULL) {
4874             result = NULL;
4875             goto done;
4876         }
4877         k = &PyTuple_GET_ITEM(kwtuple, 0);
4878         pos = i = 0;
4879         while (PyDict_Next(kwargs, &pos, &k[i], &k[i+1])) {
4880             Py_INCREF(k[i]);
4881             Py_INCREF(k[i+1]);
4882             i += 2;
4883         }
4884         nk = i / 2;
4885     }
4886     else {
4887         kwtuple = NULL;
4888         k = NULL;
4889     }
4890     closure = PyFunction_GET_CLOSURE(func);
4891 #if PY_MAJOR_VERSION >= 3
4892     kwdefs = PyFunction_GET_KW_DEFAULTS(func);
4893 #endif
4894     if (argdefs != NULL) {
4895         d = &PyTuple_GET_ITEM(argdefs, 0);
4896         nd = Py_SIZE(argdefs);
4897     }
4898     else {
4899         d = NULL;
4900         nd = 0;
4901     }
4902 #if PY_MAJOR_VERSION >= 3
4903     result = PyEval_EvalCodeEx((PyObject*)co, globals, (PyObject *)NULL,
4904                                args, (int)nargs,
4905                                k, (int)nk,
4906                                d, (int)nd, kwdefs, closure);
4907 #else
4908     result = PyEval_EvalCodeEx(co, globals, (PyObject *)NULL,
4909                                args, (int)nargs,
4910                                k, (int)nk,
4911                                d, (int)nd, closure);
4912 #endif
4913     Py_XDECREF(kwtuple);
4914 done:
4915     Py_LeaveRecursiveCall();
4916     return result;
4917 }
4918 #endif
4919 #endif
4920 
4921 /* PyObjectCall */
4922 #if CYTHON_COMPILING_IN_CPYTHON
__Pyx_PyObject_Call(PyObject * func,PyObject * arg,PyObject * kw)4923 static CYTHON_INLINE PyObject* __Pyx_PyObject_Call(PyObject *func, PyObject *arg, PyObject *kw) {
4924     PyObject *result;
4925     ternaryfunc call = func->ob_type->tp_call;
4926     if (unlikely(!call))
4927         return PyObject_Call(func, arg, kw);
4928     if (unlikely(Py_EnterRecursiveCall((char*)" while calling a Python object")))
4929         return NULL;
4930     result = (*call)(func, arg, kw);
4931     Py_LeaveRecursiveCall();
4932     if (unlikely(!result) && unlikely(!PyErr_Occurred())) {
4933         PyErr_SetString(
4934             PyExc_SystemError,
4935             "NULL result without error in PyObject_Call");
4936     }
4937     return result;
4938 }
4939 #endif
4940 
4941 /* PyObjectCallMethO */
4942 #if CYTHON_COMPILING_IN_CPYTHON
__Pyx_PyObject_CallMethO(PyObject * func,PyObject * arg)4943 static CYTHON_INLINE PyObject* __Pyx_PyObject_CallMethO(PyObject *func, PyObject *arg) {
4944     PyObject *self, *result;
4945     PyCFunction cfunc;
4946     cfunc = PyCFunction_GET_FUNCTION(func);
4947     self = PyCFunction_GET_SELF(func);
4948     if (unlikely(Py_EnterRecursiveCall((char*)" while calling a Python object")))
4949         return NULL;
4950     result = cfunc(self, arg);
4951     Py_LeaveRecursiveCall();
4952     if (unlikely(!result) && unlikely(!PyErr_Occurred())) {
4953         PyErr_SetString(
4954             PyExc_SystemError,
4955             "NULL result without error in PyObject_Call");
4956     }
4957     return result;
4958 }
4959 #endif
4960 
4961 /* PyObjectCallNoArg */
4962 #if CYTHON_COMPILING_IN_CPYTHON
__Pyx_PyObject_CallNoArg(PyObject * func)4963 static CYTHON_INLINE PyObject* __Pyx_PyObject_CallNoArg(PyObject *func) {
4964 #if CYTHON_FAST_PYCALL
4965     if (PyFunction_Check(func)) {
4966         return __Pyx_PyFunction_FastCall(func, NULL, 0);
4967     }
4968 #endif
4969 #ifdef __Pyx_CyFunction_USED
4970     if (likely(PyCFunction_Check(func) || __Pyx_CyFunction_Check(func)))
4971 #else
4972     if (likely(PyCFunction_Check(func)))
4973 #endif
4974     {
4975         if (likely(PyCFunction_GET_FLAGS(func) & METH_NOARGS)) {
4976             return __Pyx_PyObject_CallMethO(func, NULL);
4977         }
4978     }
4979     return __Pyx_PyObject_Call(func, __pyx_empty_tuple, NULL);
4980 }
4981 #endif
4982 
4983 /* PyCFunctionFastCall */
4984 #if CYTHON_FAST_PYCCALL
__Pyx_PyCFunction_FastCall(PyObject * func_obj,PyObject ** args,Py_ssize_t nargs)4985 static CYTHON_INLINE PyObject * __Pyx_PyCFunction_FastCall(PyObject *func_obj, PyObject **args, Py_ssize_t nargs) {
4986     PyCFunctionObject *func = (PyCFunctionObject*)func_obj;
4987     PyCFunction meth = PyCFunction_GET_FUNCTION(func);
4988     PyObject *self = PyCFunction_GET_SELF(func);
4989     int flags = PyCFunction_GET_FLAGS(func);
4990     assert(PyCFunction_Check(func));
4991     assert(METH_FASTCALL == (flags & ~(METH_CLASS | METH_STATIC | METH_COEXIST | METH_KEYWORDS | METH_STACKLESS)));
4992     assert(nargs >= 0);
4993     assert(nargs == 0 || args != NULL);
4994     /* _PyCFunction_FastCallDict() must not be called with an exception set,
4995        because it may clear it (directly or indirectly) and so the
4996        caller loses its exception */
4997     assert(!PyErr_Occurred());
4998     if ((PY_VERSION_HEX < 0x030700A0) || unlikely(flags & METH_KEYWORDS)) {
4999         return (*((__Pyx_PyCFunctionFastWithKeywords)(void*)meth)) (self, args, nargs, NULL);
5000     } else {
5001         return (*((__Pyx_PyCFunctionFast)(void*)meth)) (self, args, nargs);
5002     }
5003 }
5004 #endif
5005 
5006 /* PyObjectCallOneArg */
5007 #if CYTHON_COMPILING_IN_CPYTHON
__Pyx__PyObject_CallOneArg(PyObject * func,PyObject * arg)5008 static PyObject* __Pyx__PyObject_CallOneArg(PyObject *func, PyObject *arg) {
5009     PyObject *result;
5010     PyObject *args = PyTuple_New(1);
5011     if (unlikely(!args)) return NULL;
5012     Py_INCREF(arg);
5013     PyTuple_SET_ITEM(args, 0, arg);
5014     result = __Pyx_PyObject_Call(func, args, NULL);
5015     Py_DECREF(args);
5016     return result;
5017 }
__Pyx_PyObject_CallOneArg(PyObject * func,PyObject * arg)5018 static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg) {
5019 #if CYTHON_FAST_PYCALL
5020     if (PyFunction_Check(func)) {
5021         return __Pyx_PyFunction_FastCall(func, &arg, 1);
5022     }
5023 #endif
5024     if (likely(PyCFunction_Check(func))) {
5025         if (likely(PyCFunction_GET_FLAGS(func) & METH_O)) {
5026             return __Pyx_PyObject_CallMethO(func, arg);
5027 #if CYTHON_FAST_PYCCALL
5028         } else if (__Pyx_PyFastCFunction_Check(func)) {
5029             return __Pyx_PyCFunction_FastCall(func, &arg, 1);
5030 #endif
5031         }
5032     }
5033     return __Pyx__PyObject_CallOneArg(func, arg);
5034 }
5035 #else
__Pyx_PyObject_CallOneArg(PyObject * func,PyObject * arg)5036 static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg) {
5037     PyObject *result;
5038     PyObject *args = PyTuple_Pack(1, arg);
5039     if (unlikely(!args)) return NULL;
5040     result = __Pyx_PyObject_Call(func, args, NULL);
5041     Py_DECREF(args);
5042     return result;
5043 }
5044 #endif
5045 
5046 /* ExtTypeTest */
__Pyx_TypeTest(PyObject * obj,PyTypeObject * type)5047 static CYTHON_INLINE int __Pyx_TypeTest(PyObject *obj, PyTypeObject *type) {
5048     if (unlikely(!type)) {
5049         PyErr_SetString(PyExc_SystemError, "Missing type object");
5050         return 0;
5051     }
5052     if (likely(__Pyx_TypeCheck(obj, type)))
5053         return 1;
5054     PyErr_Format(PyExc_TypeError, "Cannot convert %.200s to %.200s",
5055                  Py_TYPE(obj)->tp_name, type->tp_name);
5056     return 0;
5057 }
5058 
5059 /* IsLittleEndian */
__Pyx_Is_Little_Endian(void)5060 static CYTHON_INLINE int __Pyx_Is_Little_Endian(void)
5061 {
5062   union {
5063     uint32_t u32;
5064     uint8_t u8[4];
5065   } S;
5066   S.u32 = 0x01020304;
5067   return S.u8[0] == 4;
5068 }
5069 
5070 /* BufferFormatCheck */
__Pyx_BufFmt_Init(__Pyx_BufFmt_Context * ctx,__Pyx_BufFmt_StackElem * stack,__Pyx_TypeInfo * type)5071 static void __Pyx_BufFmt_Init(__Pyx_BufFmt_Context* ctx,
5072                               __Pyx_BufFmt_StackElem* stack,
5073                               __Pyx_TypeInfo* type) {
5074   stack[0].field = &ctx->root;
5075   stack[0].parent_offset = 0;
5076   ctx->root.type = type;
5077   ctx->root.name = "buffer dtype";
5078   ctx->root.offset = 0;
5079   ctx->head = stack;
5080   ctx->head->field = &ctx->root;
5081   ctx->fmt_offset = 0;
5082   ctx->head->parent_offset = 0;
5083   ctx->new_packmode = '@';
5084   ctx->enc_packmode = '@';
5085   ctx->new_count = 1;
5086   ctx->enc_count = 0;
5087   ctx->enc_type = 0;
5088   ctx->is_complex = 0;
5089   ctx->is_valid_array = 0;
5090   ctx->struct_alignment = 0;
5091   while (type->typegroup == 'S') {
5092     ++ctx->head;
5093     ctx->head->field = type->fields;
5094     ctx->head->parent_offset = 0;
5095     type = type->fields->type;
5096   }
5097 }
__Pyx_BufFmt_ParseNumber(const char ** ts)5098 static int __Pyx_BufFmt_ParseNumber(const char** ts) {
5099     int count;
5100     const char* t = *ts;
5101     if (*t < '0' || *t > '9') {
5102       return -1;
5103     } else {
5104         count = *t++ - '0';
5105         while (*t >= '0' && *t <= '9') {
5106             count *= 10;
5107             count += *t++ - '0';
5108         }
5109     }
5110     *ts = t;
5111     return count;
5112 }
__Pyx_BufFmt_ExpectNumber(const char ** ts)5113 static int __Pyx_BufFmt_ExpectNumber(const char **ts) {
5114     int number = __Pyx_BufFmt_ParseNumber(ts);
5115     if (number == -1)
5116         PyErr_Format(PyExc_ValueError,\
5117                      "Does not understand character buffer dtype format string ('%c')", **ts);
5118     return number;
5119 }
__Pyx_BufFmt_RaiseUnexpectedChar(char ch)5120 static void __Pyx_BufFmt_RaiseUnexpectedChar(char ch) {
5121   PyErr_Format(PyExc_ValueError,
5122                "Unexpected format string character: '%c'", ch);
5123 }
__Pyx_BufFmt_DescribeTypeChar(char ch,int is_complex)5124 static const char* __Pyx_BufFmt_DescribeTypeChar(char ch, int is_complex) {
5125   switch (ch) {
5126     case '?': return "'bool'";
5127     case 'c': return "'char'";
5128     case 'b': return "'signed char'";
5129     case 'B': return "'unsigned char'";
5130     case 'h': return "'short'";
5131     case 'H': return "'unsigned short'";
5132     case 'i': return "'int'";
5133     case 'I': return "'unsigned int'";
5134     case 'l': return "'long'";
5135     case 'L': return "'unsigned long'";
5136     case 'q': return "'long long'";
5137     case 'Q': return "'unsigned long long'";
5138     case 'f': return (is_complex ? "'complex float'" : "'float'");
5139     case 'd': return (is_complex ? "'complex double'" : "'double'");
5140     case 'g': return (is_complex ? "'complex long double'" : "'long double'");
5141     case 'T': return "a struct";
5142     case 'O': return "Python object";
5143     case 'P': return "a pointer";
5144     case 's': case 'p': return "a string";
5145     case 0: return "end";
5146     default: return "unparseable format string";
5147   }
5148 }
__Pyx_BufFmt_TypeCharToStandardSize(char ch,int is_complex)5149 static size_t __Pyx_BufFmt_TypeCharToStandardSize(char ch, int is_complex) {
5150   switch (ch) {
5151     case '?': case 'c': case 'b': case 'B': case 's': case 'p': return 1;
5152     case 'h': case 'H': return 2;
5153     case 'i': case 'I': case 'l': case 'L': return 4;
5154     case 'q': case 'Q': return 8;
5155     case 'f': return (is_complex ? 8 : 4);
5156     case 'd': return (is_complex ? 16 : 8);
5157     case 'g': {
5158       PyErr_SetString(PyExc_ValueError, "Python does not define a standard format string size for long double ('g')..");
5159       return 0;
5160     }
5161     case 'O': case 'P': return sizeof(void*);
5162     default:
5163       __Pyx_BufFmt_RaiseUnexpectedChar(ch);
5164       return 0;
5165     }
5166 }
__Pyx_BufFmt_TypeCharToNativeSize(char ch,int is_complex)5167 static size_t __Pyx_BufFmt_TypeCharToNativeSize(char ch, int is_complex) {
5168   switch (ch) {
5169     case '?': case 'c': case 'b': case 'B': case 's': case 'p': return 1;
5170     case 'h': case 'H': return sizeof(short);
5171     case 'i': case 'I': return sizeof(int);
5172     case 'l': case 'L': return sizeof(long);
5173     #ifdef HAVE_LONG_LONG
5174     case 'q': case 'Q': return sizeof(PY_LONG_LONG);
5175     #endif
5176     case 'f': return sizeof(float) * (is_complex ? 2 : 1);
5177     case 'd': return sizeof(double) * (is_complex ? 2 : 1);
5178     case 'g': return sizeof(long double) * (is_complex ? 2 : 1);
5179     case 'O': case 'P': return sizeof(void*);
5180     default: {
5181       __Pyx_BufFmt_RaiseUnexpectedChar(ch);
5182       return 0;
5183     }
5184   }
5185 }
5186 typedef struct { char c; short x; } __Pyx_st_short;
5187 typedef struct { char c; int x; } __Pyx_st_int;
5188 typedef struct { char c; long x; } __Pyx_st_long;
5189 typedef struct { char c; float x; } __Pyx_st_float;
5190 typedef struct { char c; double x; } __Pyx_st_double;
5191 typedef struct { char c; long double x; } __Pyx_st_longdouble;
5192 typedef struct { char c; void *x; } __Pyx_st_void_p;
5193 #ifdef HAVE_LONG_LONG
5194 typedef struct { char c; PY_LONG_LONG x; } __Pyx_st_longlong;
5195 #endif
__Pyx_BufFmt_TypeCharToAlignment(char ch,CYTHON_UNUSED int is_complex)5196 static size_t __Pyx_BufFmt_TypeCharToAlignment(char ch, CYTHON_UNUSED int is_complex) {
5197   switch (ch) {
5198     case '?': case 'c': case 'b': case 'B': case 's': case 'p': return 1;
5199     case 'h': case 'H': return sizeof(__Pyx_st_short) - sizeof(short);
5200     case 'i': case 'I': return sizeof(__Pyx_st_int) - sizeof(int);
5201     case 'l': case 'L': return sizeof(__Pyx_st_long) - sizeof(long);
5202 #ifdef HAVE_LONG_LONG
5203     case 'q': case 'Q': return sizeof(__Pyx_st_longlong) - sizeof(PY_LONG_LONG);
5204 #endif
5205     case 'f': return sizeof(__Pyx_st_float) - sizeof(float);
5206     case 'd': return sizeof(__Pyx_st_double) - sizeof(double);
5207     case 'g': return sizeof(__Pyx_st_longdouble) - sizeof(long double);
5208     case 'P': case 'O': return sizeof(__Pyx_st_void_p) - sizeof(void*);
5209     default:
5210       __Pyx_BufFmt_RaiseUnexpectedChar(ch);
5211       return 0;
5212     }
5213 }
5214 /* These are for computing the padding at the end of the struct to align
5215    on the first member of the struct. This will probably the same as above,
5216    but we don't have any guarantees.
5217  */
5218 typedef struct { short x; char c; } __Pyx_pad_short;
5219 typedef struct { int x; char c; } __Pyx_pad_int;
5220 typedef struct { long x; char c; } __Pyx_pad_long;
5221 typedef struct { float x; char c; } __Pyx_pad_float;
5222 typedef struct { double x; char c; } __Pyx_pad_double;
5223 typedef struct { long double x; char c; } __Pyx_pad_longdouble;
5224 typedef struct { void *x; char c; } __Pyx_pad_void_p;
5225 #ifdef HAVE_LONG_LONG
5226 typedef struct { PY_LONG_LONG x; char c; } __Pyx_pad_longlong;
5227 #endif
__Pyx_BufFmt_TypeCharToPadding(char ch,CYTHON_UNUSED int is_complex)5228 static size_t __Pyx_BufFmt_TypeCharToPadding(char ch, CYTHON_UNUSED int is_complex) {
5229   switch (ch) {
5230     case '?': case 'c': case 'b': case 'B': case 's': case 'p': return 1;
5231     case 'h': case 'H': return sizeof(__Pyx_pad_short) - sizeof(short);
5232     case 'i': case 'I': return sizeof(__Pyx_pad_int) - sizeof(int);
5233     case 'l': case 'L': return sizeof(__Pyx_pad_long) - sizeof(long);
5234 #ifdef HAVE_LONG_LONG
5235     case 'q': case 'Q': return sizeof(__Pyx_pad_longlong) - sizeof(PY_LONG_LONG);
5236 #endif
5237     case 'f': return sizeof(__Pyx_pad_float) - sizeof(float);
5238     case 'd': return sizeof(__Pyx_pad_double) - sizeof(double);
5239     case 'g': return sizeof(__Pyx_pad_longdouble) - sizeof(long double);
5240     case 'P': case 'O': return sizeof(__Pyx_pad_void_p) - sizeof(void*);
5241     default:
5242       __Pyx_BufFmt_RaiseUnexpectedChar(ch);
5243       return 0;
5244     }
5245 }
__Pyx_BufFmt_TypeCharToGroup(char ch,int is_complex)5246 static char __Pyx_BufFmt_TypeCharToGroup(char ch, int is_complex) {
5247   switch (ch) {
5248     case 'c':
5249         return 'H';
5250     case 'b': case 'h': case 'i':
5251     case 'l': case 'q': case 's': case 'p':
5252         return 'I';
5253     case '?': case 'B': case 'H': case 'I': case 'L': case 'Q':
5254         return 'U';
5255     case 'f': case 'd': case 'g':
5256         return (is_complex ? 'C' : 'R');
5257     case 'O':
5258         return 'O';
5259     case 'P':
5260         return 'P';
5261     default: {
5262       __Pyx_BufFmt_RaiseUnexpectedChar(ch);
5263       return 0;
5264     }
5265   }
5266 }
__Pyx_BufFmt_RaiseExpected(__Pyx_BufFmt_Context * ctx)5267 static void __Pyx_BufFmt_RaiseExpected(__Pyx_BufFmt_Context* ctx) {
5268   if (ctx->head == NULL || ctx->head->field == &ctx->root) {
5269     const char* expected;
5270     const char* quote;
5271     if (ctx->head == NULL) {
5272       expected = "end";
5273       quote = "";
5274     } else {
5275       expected = ctx->head->field->type->name;
5276       quote = "'";
5277     }
5278     PyErr_Format(PyExc_ValueError,
5279                  "Buffer dtype mismatch, expected %s%s%s but got %s",
5280                  quote, expected, quote,
5281                  __Pyx_BufFmt_DescribeTypeChar(ctx->enc_type, ctx->is_complex));
5282   } else {
5283     __Pyx_StructField* field = ctx->head->field;
5284     __Pyx_StructField* parent = (ctx->head - 1)->field;
5285     PyErr_Format(PyExc_ValueError,
5286                  "Buffer dtype mismatch, expected '%s' but got %s in '%s.%s'",
5287                  field->type->name, __Pyx_BufFmt_DescribeTypeChar(ctx->enc_type, ctx->is_complex),
5288                  parent->type->name, field->name);
5289   }
5290 }
__Pyx_BufFmt_ProcessTypeChunk(__Pyx_BufFmt_Context * ctx)5291 static int __Pyx_BufFmt_ProcessTypeChunk(__Pyx_BufFmt_Context* ctx) {
5292   char group;
5293   size_t size, offset, arraysize = 1;
5294   if (ctx->enc_type == 0) return 0;
5295   if (ctx->head->field->type->arraysize[0]) {
5296     int i, ndim = 0;
5297     if (ctx->enc_type == 's' || ctx->enc_type == 'p') {
5298         ctx->is_valid_array = ctx->head->field->type->ndim == 1;
5299         ndim = 1;
5300         if (ctx->enc_count != ctx->head->field->type->arraysize[0]) {
5301             PyErr_Format(PyExc_ValueError,
5302                          "Expected a dimension of size %zu, got %zu",
5303                          ctx->head->field->type->arraysize[0], ctx->enc_count);
5304             return -1;
5305         }
5306     }
5307     if (!ctx->is_valid_array) {
5308       PyErr_Format(PyExc_ValueError, "Expected %d dimensions, got %d",
5309                    ctx->head->field->type->ndim, ndim);
5310       return -1;
5311     }
5312     for (i = 0; i < ctx->head->field->type->ndim; i++) {
5313       arraysize *= ctx->head->field->type->arraysize[i];
5314     }
5315     ctx->is_valid_array = 0;
5316     ctx->enc_count = 1;
5317   }
5318   group = __Pyx_BufFmt_TypeCharToGroup(ctx->enc_type, ctx->is_complex);
5319   do {
5320     __Pyx_StructField* field = ctx->head->field;
5321     __Pyx_TypeInfo* type = field->type;
5322     if (ctx->enc_packmode == '@' || ctx->enc_packmode == '^') {
5323       size = __Pyx_BufFmt_TypeCharToNativeSize(ctx->enc_type, ctx->is_complex);
5324     } else {
5325       size = __Pyx_BufFmt_TypeCharToStandardSize(ctx->enc_type, ctx->is_complex);
5326     }
5327     if (ctx->enc_packmode == '@') {
5328       size_t align_at = __Pyx_BufFmt_TypeCharToAlignment(ctx->enc_type, ctx->is_complex);
5329       size_t align_mod_offset;
5330       if (align_at == 0) return -1;
5331       align_mod_offset = ctx->fmt_offset % align_at;
5332       if (align_mod_offset > 0) ctx->fmt_offset += align_at - align_mod_offset;
5333       if (ctx->struct_alignment == 0)
5334           ctx->struct_alignment = __Pyx_BufFmt_TypeCharToPadding(ctx->enc_type,
5335                                                                  ctx->is_complex);
5336     }
5337     if (type->size != size || type->typegroup != group) {
5338       if (type->typegroup == 'C' && type->fields != NULL) {
5339         size_t parent_offset = ctx->head->parent_offset + field->offset;
5340         ++ctx->head;
5341         ctx->head->field = type->fields;
5342         ctx->head->parent_offset = parent_offset;
5343         continue;
5344       }
5345       if ((type->typegroup == 'H' || group == 'H') && type->size == size) {
5346       } else {
5347           __Pyx_BufFmt_RaiseExpected(ctx);
5348           return -1;
5349       }
5350     }
5351     offset = ctx->head->parent_offset + field->offset;
5352     if (ctx->fmt_offset != offset) {
5353       PyErr_Format(PyExc_ValueError,
5354                    "Buffer dtype mismatch; next field is at offset %" CYTHON_FORMAT_SSIZE_T "d but %" CYTHON_FORMAT_SSIZE_T "d expected",
5355                    (Py_ssize_t)ctx->fmt_offset, (Py_ssize_t)offset);
5356       return -1;
5357     }
5358     ctx->fmt_offset += size;
5359     if (arraysize)
5360       ctx->fmt_offset += (arraysize - 1) * size;
5361     --ctx->enc_count;
5362     while (1) {
5363       if (field == &ctx->root) {
5364         ctx->head = NULL;
5365         if (ctx->enc_count != 0) {
5366           __Pyx_BufFmt_RaiseExpected(ctx);
5367           return -1;
5368         }
5369         break;
5370       }
5371       ctx->head->field = ++field;
5372       if (field->type == NULL) {
5373         --ctx->head;
5374         field = ctx->head->field;
5375         continue;
5376       } else if (field->type->typegroup == 'S') {
5377         size_t parent_offset = ctx->head->parent_offset + field->offset;
5378         if (field->type->fields->type == NULL) continue;
5379         field = field->type->fields;
5380         ++ctx->head;
5381         ctx->head->field = field;
5382         ctx->head->parent_offset = parent_offset;
5383         break;
5384       } else {
5385         break;
5386       }
5387     }
5388   } while (ctx->enc_count);
5389   ctx->enc_type = 0;
5390   ctx->is_complex = 0;
5391   return 0;
5392 }
5393 static PyObject *
__pyx_buffmt_parse_array(__Pyx_BufFmt_Context * ctx,const char ** tsp)5394 __pyx_buffmt_parse_array(__Pyx_BufFmt_Context* ctx, const char** tsp)
5395 {
5396     const char *ts = *tsp;
5397     int i = 0, number, ndim;
5398     ++ts;
5399     if (ctx->new_count != 1) {
5400         PyErr_SetString(PyExc_ValueError,
5401                         "Cannot handle repeated arrays in format string");
5402         return NULL;
5403     }
5404     if (__Pyx_BufFmt_ProcessTypeChunk(ctx) == -1) return NULL;
5405     ndim = ctx->head->field->type->ndim;
5406     while (*ts && *ts != ')') {
5407         switch (*ts) {
5408             case ' ': case '\f': case '\r': case '\n': case '\t': case '\v':  continue;
5409             default:  break;
5410         }
5411         number = __Pyx_BufFmt_ExpectNumber(&ts);
5412         if (number == -1) return NULL;
5413         if (i < ndim && (size_t) number != ctx->head->field->type->arraysize[i])
5414             return PyErr_Format(PyExc_ValueError,
5415                         "Expected a dimension of size %zu, got %d",
5416                         ctx->head->field->type->arraysize[i], number);
5417         if (*ts != ',' && *ts != ')')
5418             return PyErr_Format(PyExc_ValueError,
5419                                 "Expected a comma in format string, got '%c'", *ts);
5420         if (*ts == ',') ts++;
5421         i++;
5422     }
5423     if (i != ndim)
5424         return PyErr_Format(PyExc_ValueError, "Expected %d dimension(s), got %d",
5425                             ctx->head->field->type->ndim, i);
5426     if (!*ts) {
5427         PyErr_SetString(PyExc_ValueError,
5428                         "Unexpected end of format string, expected ')'");
5429         return NULL;
5430     }
5431     ctx->is_valid_array = 1;
5432     ctx->new_count = 1;
5433     *tsp = ++ts;
5434     return Py_None;
5435 }
__Pyx_BufFmt_CheckString(__Pyx_BufFmt_Context * ctx,const char * ts)5436 static const char* __Pyx_BufFmt_CheckString(__Pyx_BufFmt_Context* ctx, const char* ts) {
5437   int got_Z = 0;
5438   while (1) {
5439     switch(*ts) {
5440       case 0:
5441         if (ctx->enc_type != 0 && ctx->head == NULL) {
5442           __Pyx_BufFmt_RaiseExpected(ctx);
5443           return NULL;
5444         }
5445         if (__Pyx_BufFmt_ProcessTypeChunk(ctx) == -1) return NULL;
5446         if (ctx->head != NULL) {
5447           __Pyx_BufFmt_RaiseExpected(ctx);
5448           return NULL;
5449         }
5450         return ts;
5451       case ' ':
5452       case '\r':
5453       case '\n':
5454         ++ts;
5455         break;
5456       case '<':
5457         if (!__Pyx_Is_Little_Endian()) {
5458           PyErr_SetString(PyExc_ValueError, "Little-endian buffer not supported on big-endian compiler");
5459           return NULL;
5460         }
5461         ctx->new_packmode = '=';
5462         ++ts;
5463         break;
5464       case '>':
5465       case '!':
5466         if (__Pyx_Is_Little_Endian()) {
5467           PyErr_SetString(PyExc_ValueError, "Big-endian buffer not supported on little-endian compiler");
5468           return NULL;
5469         }
5470         ctx->new_packmode = '=';
5471         ++ts;
5472         break;
5473       case '=':
5474       case '@':
5475       case '^':
5476         ctx->new_packmode = *ts++;
5477         break;
5478       case 'T':
5479         {
5480           const char* ts_after_sub;
5481           size_t i, struct_count = ctx->new_count;
5482           size_t struct_alignment = ctx->struct_alignment;
5483           ctx->new_count = 1;
5484           ++ts;
5485           if (*ts != '{') {
5486             PyErr_SetString(PyExc_ValueError, "Buffer acquisition: Expected '{' after 'T'");
5487             return NULL;
5488           }
5489           if (__Pyx_BufFmt_ProcessTypeChunk(ctx) == -1) return NULL;
5490           ctx->enc_type = 0;
5491           ctx->enc_count = 0;
5492           ctx->struct_alignment = 0;
5493           ++ts;
5494           ts_after_sub = ts;
5495           for (i = 0; i != struct_count; ++i) {
5496             ts_after_sub = __Pyx_BufFmt_CheckString(ctx, ts);
5497             if (!ts_after_sub) return NULL;
5498           }
5499           ts = ts_after_sub;
5500           if (struct_alignment) ctx->struct_alignment = struct_alignment;
5501         }
5502         break;
5503       case '}':
5504         {
5505           size_t alignment = ctx->struct_alignment;
5506           ++ts;
5507           if (__Pyx_BufFmt_ProcessTypeChunk(ctx) == -1) return NULL;
5508           ctx->enc_type = 0;
5509           if (alignment && ctx->fmt_offset % alignment) {
5510             ctx->fmt_offset += alignment - (ctx->fmt_offset % alignment);
5511           }
5512         }
5513         return ts;
5514       case 'x':
5515         if (__Pyx_BufFmt_ProcessTypeChunk(ctx) == -1) return NULL;
5516         ctx->fmt_offset += ctx->new_count;
5517         ctx->new_count = 1;
5518         ctx->enc_count = 0;
5519         ctx->enc_type = 0;
5520         ctx->enc_packmode = ctx->new_packmode;
5521         ++ts;
5522         break;
5523       case 'Z':
5524         got_Z = 1;
5525         ++ts;
5526         if (*ts != 'f' && *ts != 'd' && *ts != 'g') {
5527           __Pyx_BufFmt_RaiseUnexpectedChar('Z');
5528           return NULL;
5529         }
5530         CYTHON_FALLTHROUGH;
5531       case '?': case 'c': case 'b': case 'B': case 'h': case 'H': case 'i': case 'I':
5532       case 'l': case 'L': case 'q': case 'Q':
5533       case 'f': case 'd': case 'g':
5534       case 'O': case 'p':
5535         if ((ctx->enc_type == *ts) && (got_Z == ctx->is_complex) &&
5536             (ctx->enc_packmode == ctx->new_packmode) && (!ctx->is_valid_array)) {
5537           ctx->enc_count += ctx->new_count;
5538           ctx->new_count = 1;
5539           got_Z = 0;
5540           ++ts;
5541           break;
5542         }
5543         CYTHON_FALLTHROUGH;
5544       case 's':
5545         if (__Pyx_BufFmt_ProcessTypeChunk(ctx) == -1) return NULL;
5546         ctx->enc_count = ctx->new_count;
5547         ctx->enc_packmode = ctx->new_packmode;
5548         ctx->enc_type = *ts;
5549         ctx->is_complex = got_Z;
5550         ++ts;
5551         ctx->new_count = 1;
5552         got_Z = 0;
5553         break;
5554       case ':':
5555         ++ts;
5556         while(*ts != ':') ++ts;
5557         ++ts;
5558         break;
5559       case '(':
5560         if (!__pyx_buffmt_parse_array(ctx, &ts)) return NULL;
5561         break;
5562       default:
5563         {
5564           int number = __Pyx_BufFmt_ExpectNumber(&ts);
5565           if (number == -1) return NULL;
5566           ctx->new_count = (size_t)number;
5567         }
5568     }
5569   }
5570 }
5571 
5572 /* BufferGetAndValidate */
__Pyx_SafeReleaseBuffer(Py_buffer * info)5573   static CYTHON_INLINE void __Pyx_SafeReleaseBuffer(Py_buffer* info) {
5574   if (unlikely(info->buf == NULL)) return;
5575   if (info->suboffsets == __Pyx_minusones) info->suboffsets = NULL;
5576   __Pyx_ReleaseBuffer(info);
5577 }
__Pyx_ZeroBuffer(Py_buffer * buf)5578 static void __Pyx_ZeroBuffer(Py_buffer* buf) {
5579   buf->buf = NULL;
5580   buf->obj = NULL;
5581   buf->strides = __Pyx_zeros;
5582   buf->shape = __Pyx_zeros;
5583   buf->suboffsets = __Pyx_minusones;
5584 }
__Pyx__GetBufferAndValidate(Py_buffer * buf,PyObject * obj,__Pyx_TypeInfo * dtype,int flags,int nd,int cast,__Pyx_BufFmt_StackElem * stack)5585 static int __Pyx__GetBufferAndValidate(
5586         Py_buffer* buf, PyObject* obj,  __Pyx_TypeInfo* dtype, int flags,
5587         int nd, int cast, __Pyx_BufFmt_StackElem* stack)
5588 {
5589   buf->buf = NULL;
5590   if (unlikely(__Pyx_GetBuffer(obj, buf, flags) == -1)) {
5591     __Pyx_ZeroBuffer(buf);
5592     return -1;
5593   }
5594   if (unlikely(buf->ndim != nd)) {
5595     PyErr_Format(PyExc_ValueError,
5596                  "Buffer has wrong number of dimensions (expected %d, got %d)",
5597                  nd, buf->ndim);
5598     goto fail;
5599   }
5600   if (!cast) {
5601     __Pyx_BufFmt_Context ctx;
5602     __Pyx_BufFmt_Init(&ctx, stack, dtype);
5603     if (!__Pyx_BufFmt_CheckString(&ctx, buf->format)) goto fail;
5604   }
5605   if (unlikely((size_t)buf->itemsize != dtype->size)) {
5606     PyErr_Format(PyExc_ValueError,
5607       "Item size of buffer (%" CYTHON_FORMAT_SSIZE_T "d byte%s) does not match size of '%s' (%" CYTHON_FORMAT_SSIZE_T "d byte%s)",
5608       buf->itemsize, (buf->itemsize > 1) ? "s" : "",
5609       dtype->name, (Py_ssize_t)dtype->size, (dtype->size > 1) ? "s" : "");
5610     goto fail;
5611   }
5612   if (buf->suboffsets == NULL) buf->suboffsets = __Pyx_minusones;
5613   return 0;
5614 fail:;
5615   __Pyx_SafeReleaseBuffer(buf);
5616   return -1;
5617 }
5618 
5619 /* GetItemInt */
__Pyx_GetItemInt_Generic(PyObject * o,PyObject * j)5620   static PyObject *__Pyx_GetItemInt_Generic(PyObject *o, PyObject* j) {
5621     PyObject *r;
5622     if (!j) return NULL;
5623     r = PyObject_GetItem(o, j);
5624     Py_DECREF(j);
5625     return r;
5626 }
__Pyx_GetItemInt_List_Fast(PyObject * o,Py_ssize_t i,CYTHON_NCP_UNUSED int wraparound,CYTHON_NCP_UNUSED int boundscheck)5627 static CYTHON_INLINE PyObject *__Pyx_GetItemInt_List_Fast(PyObject *o, Py_ssize_t i,
5628                                                               CYTHON_NCP_UNUSED int wraparound,
5629                                                               CYTHON_NCP_UNUSED int boundscheck) {
5630 #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
5631     Py_ssize_t wrapped_i = i;
5632     if (wraparound & unlikely(i < 0)) {
5633         wrapped_i += PyList_GET_SIZE(o);
5634     }
5635     if ((!boundscheck) || likely(__Pyx_is_valid_index(wrapped_i, PyList_GET_SIZE(o)))) {
5636         PyObject *r = PyList_GET_ITEM(o, wrapped_i);
5637         Py_INCREF(r);
5638         return r;
5639     }
5640     return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i));
5641 #else
5642     return PySequence_GetItem(o, i);
5643 #endif
5644 }
__Pyx_GetItemInt_Tuple_Fast(PyObject * o,Py_ssize_t i,CYTHON_NCP_UNUSED int wraparound,CYTHON_NCP_UNUSED int boundscheck)5645 static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Tuple_Fast(PyObject *o, Py_ssize_t i,
5646                                                               CYTHON_NCP_UNUSED int wraparound,
5647                                                               CYTHON_NCP_UNUSED int boundscheck) {
5648 #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
5649     Py_ssize_t wrapped_i = i;
5650     if (wraparound & unlikely(i < 0)) {
5651         wrapped_i += PyTuple_GET_SIZE(o);
5652     }
5653     if ((!boundscheck) || likely(__Pyx_is_valid_index(wrapped_i, PyTuple_GET_SIZE(o)))) {
5654         PyObject *r = PyTuple_GET_ITEM(o, wrapped_i);
5655         Py_INCREF(r);
5656         return r;
5657     }
5658     return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i));
5659 #else
5660     return PySequence_GetItem(o, i);
5661 #endif
5662 }
__Pyx_GetItemInt_Fast(PyObject * o,Py_ssize_t i,int is_list,CYTHON_NCP_UNUSED int wraparound,CYTHON_NCP_UNUSED int boundscheck)5663 static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Fast(PyObject *o, Py_ssize_t i, int is_list,
5664                                                      CYTHON_NCP_UNUSED int wraparound,
5665                                                      CYTHON_NCP_UNUSED int boundscheck) {
5666 #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS && CYTHON_USE_TYPE_SLOTS
5667     if (is_list || PyList_CheckExact(o)) {
5668         Py_ssize_t n = ((!wraparound) | likely(i >= 0)) ? i : i + PyList_GET_SIZE(o);
5669         if ((!boundscheck) || (likely(__Pyx_is_valid_index(n, PyList_GET_SIZE(o))))) {
5670             PyObject *r = PyList_GET_ITEM(o, n);
5671             Py_INCREF(r);
5672             return r;
5673         }
5674     }
5675     else if (PyTuple_CheckExact(o)) {
5676         Py_ssize_t n = ((!wraparound) | likely(i >= 0)) ? i : i + PyTuple_GET_SIZE(o);
5677         if ((!boundscheck) || likely(__Pyx_is_valid_index(n, PyTuple_GET_SIZE(o)))) {
5678             PyObject *r = PyTuple_GET_ITEM(o, n);
5679             Py_INCREF(r);
5680             return r;
5681         }
5682     } else {
5683         PySequenceMethods *m = Py_TYPE(o)->tp_as_sequence;
5684         if (likely(m && m->sq_item)) {
5685             if (wraparound && unlikely(i < 0) && likely(m->sq_length)) {
5686                 Py_ssize_t l = m->sq_length(o);
5687                 if (likely(l >= 0)) {
5688                     i += l;
5689                 } else {
5690                     if (!PyErr_ExceptionMatches(PyExc_OverflowError))
5691                         return NULL;
5692                     PyErr_Clear();
5693                 }
5694             }
5695             return m->sq_item(o, i);
5696         }
5697     }
5698 #else
5699     if (is_list || PySequence_Check(o)) {
5700         return PySequence_GetItem(o, i);
5701     }
5702 #endif
5703     return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i));
5704 }
5705 
5706 /* PyErrFetchRestore */
5707   #if CYTHON_FAST_THREAD_STATE
__Pyx_ErrRestoreInState(PyThreadState * tstate,PyObject * type,PyObject * value,PyObject * tb)5708 static CYTHON_INLINE void __Pyx_ErrRestoreInState(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb) {
5709     PyObject *tmp_type, *tmp_value, *tmp_tb;
5710     tmp_type = tstate->curexc_type;
5711     tmp_value = tstate->curexc_value;
5712     tmp_tb = tstate->curexc_traceback;
5713     tstate->curexc_type = type;
5714     tstate->curexc_value = value;
5715     tstate->curexc_traceback = tb;
5716     Py_XDECREF(tmp_type);
5717     Py_XDECREF(tmp_value);
5718     Py_XDECREF(tmp_tb);
5719 }
__Pyx_ErrFetchInState(PyThreadState * tstate,PyObject ** type,PyObject ** value,PyObject ** tb)5720 static CYTHON_INLINE void __Pyx_ErrFetchInState(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) {
5721     *type = tstate->curexc_type;
5722     *value = tstate->curexc_value;
5723     *tb = tstate->curexc_traceback;
5724     tstate->curexc_type = 0;
5725     tstate->curexc_value = 0;
5726     tstate->curexc_traceback = 0;
5727 }
5728 #endif
5729 
5730 /* WriteUnraisableException */
__Pyx_WriteUnraisable(const char * name,CYTHON_UNUSED int clineno,CYTHON_UNUSED int lineno,CYTHON_UNUSED const char * filename,int full_traceback,CYTHON_UNUSED int nogil)5731   static void __Pyx_WriteUnraisable(const char *name, CYTHON_UNUSED int clineno,
5732                                   CYTHON_UNUSED int lineno, CYTHON_UNUSED const char *filename,
5733                                   int full_traceback, CYTHON_UNUSED int nogil) {
5734     PyObject *old_exc, *old_val, *old_tb;
5735     PyObject *ctx;
5736     __Pyx_PyThreadState_declare
5737 #ifdef WITH_THREAD
5738     PyGILState_STATE state;
5739     if (nogil)
5740         state = PyGILState_Ensure();
5741 #ifdef _MSC_VER
5742     else state = (PyGILState_STATE)-1;
5743 #endif
5744 #endif
5745     __Pyx_PyThreadState_assign
5746     __Pyx_ErrFetch(&old_exc, &old_val, &old_tb);
5747     if (full_traceback) {
5748         Py_XINCREF(old_exc);
5749         Py_XINCREF(old_val);
5750         Py_XINCREF(old_tb);
5751         __Pyx_ErrRestore(old_exc, old_val, old_tb);
5752         PyErr_PrintEx(1);
5753     }
5754     #if PY_MAJOR_VERSION < 3
5755     ctx = PyString_FromString(name);
5756     #else
5757     ctx = PyUnicode_FromString(name);
5758     #endif
5759     __Pyx_ErrRestore(old_exc, old_val, old_tb);
5760     if (!ctx) {
5761         PyErr_WriteUnraisable(Py_None);
5762     } else {
5763         PyErr_WriteUnraisable(ctx);
5764         Py_DECREF(ctx);
5765     }
5766 #ifdef WITH_THREAD
5767     if (nogil)
5768         PyGILState_Release(state);
5769 #endif
5770 }
5771 
5772 /* RaiseArgTupleInvalid */
__Pyx_RaiseArgtupleInvalid(const char * func_name,int exact,Py_ssize_t num_min,Py_ssize_t num_max,Py_ssize_t num_found)5773   static void __Pyx_RaiseArgtupleInvalid(
5774     const char* func_name,
5775     int exact,
5776     Py_ssize_t num_min,
5777     Py_ssize_t num_max,
5778     Py_ssize_t num_found)
5779 {
5780     Py_ssize_t num_expected;
5781     const char *more_or_less;
5782     if (num_found < num_min) {
5783         num_expected = num_min;
5784         more_or_less = "at least";
5785     } else {
5786         num_expected = num_max;
5787         more_or_less = "at most";
5788     }
5789     if (exact) {
5790         more_or_less = "exactly";
5791     }
5792     PyErr_Format(PyExc_TypeError,
5793                  "%.200s() takes %.8s %" CYTHON_FORMAT_SSIZE_T "d positional argument%.1s (%" CYTHON_FORMAT_SSIZE_T "d given)",
5794                  func_name, more_or_less, num_expected,
5795                  (num_expected == 1) ? "" : "s", num_found);
5796 }
5797 
5798 /* RaiseDoubleKeywords */
__Pyx_RaiseDoubleKeywordsError(const char * func_name,PyObject * kw_name)5799   static void __Pyx_RaiseDoubleKeywordsError(
5800     const char* func_name,
5801     PyObject* kw_name)
5802 {
5803     PyErr_Format(PyExc_TypeError,
5804         #if PY_MAJOR_VERSION >= 3
5805         "%s() got multiple values for keyword argument '%U'", func_name, kw_name);
5806         #else
5807         "%s() got multiple values for keyword argument '%s'", func_name,
5808         PyString_AsString(kw_name));
5809         #endif
5810 }
5811 
5812 /* ParseKeywords */
__Pyx_ParseOptionalKeywords(PyObject * kwds,PyObject ** argnames[],PyObject * kwds2,PyObject * values[],Py_ssize_t num_pos_args,const char * function_name)5813   static int __Pyx_ParseOptionalKeywords(
5814     PyObject *kwds,
5815     PyObject **argnames[],
5816     PyObject *kwds2,
5817     PyObject *values[],
5818     Py_ssize_t num_pos_args,
5819     const char* function_name)
5820 {
5821     PyObject *key = 0, *value = 0;
5822     Py_ssize_t pos = 0;
5823     PyObject*** name;
5824     PyObject*** first_kw_arg = argnames + num_pos_args;
5825     while (PyDict_Next(kwds, &pos, &key, &value)) {
5826         name = first_kw_arg;
5827         while (*name && (**name != key)) name++;
5828         if (*name) {
5829             values[name-argnames] = value;
5830             continue;
5831         }
5832         name = first_kw_arg;
5833         #if PY_MAJOR_VERSION < 3
5834         if (likely(PyString_Check(key))) {
5835             while (*name) {
5836                 if ((CYTHON_COMPILING_IN_PYPY || PyString_GET_SIZE(**name) == PyString_GET_SIZE(key))
5837                         && _PyString_Eq(**name, key)) {
5838                     values[name-argnames] = value;
5839                     break;
5840                 }
5841                 name++;
5842             }
5843             if (*name) continue;
5844             else {
5845                 PyObject*** argname = argnames;
5846                 while (argname != first_kw_arg) {
5847                     if ((**argname == key) || (
5848                             (CYTHON_COMPILING_IN_PYPY || PyString_GET_SIZE(**argname) == PyString_GET_SIZE(key))
5849                              && _PyString_Eq(**argname, key))) {
5850                         goto arg_passed_twice;
5851                     }
5852                     argname++;
5853                 }
5854             }
5855         } else
5856         #endif
5857         if (likely(PyUnicode_Check(key))) {
5858             while (*name) {
5859                 int cmp = (**name == key) ? 0 :
5860                 #if !CYTHON_COMPILING_IN_PYPY && PY_MAJOR_VERSION >= 3
5861                     (__Pyx_PyUnicode_GET_LENGTH(**name) != __Pyx_PyUnicode_GET_LENGTH(key)) ? 1 :
5862                 #endif
5863                     PyUnicode_Compare(**name, key);
5864                 if (cmp < 0 && unlikely(PyErr_Occurred())) goto bad;
5865                 if (cmp == 0) {
5866                     values[name-argnames] = value;
5867                     break;
5868                 }
5869                 name++;
5870             }
5871             if (*name) continue;
5872             else {
5873                 PyObject*** argname = argnames;
5874                 while (argname != first_kw_arg) {
5875                     int cmp = (**argname == key) ? 0 :
5876                     #if !CYTHON_COMPILING_IN_PYPY && PY_MAJOR_VERSION >= 3
5877                         (__Pyx_PyUnicode_GET_LENGTH(**argname) != __Pyx_PyUnicode_GET_LENGTH(key)) ? 1 :
5878                     #endif
5879                         PyUnicode_Compare(**argname, key);
5880                     if (cmp < 0 && unlikely(PyErr_Occurred())) goto bad;
5881                     if (cmp == 0) goto arg_passed_twice;
5882                     argname++;
5883                 }
5884             }
5885         } else
5886             goto invalid_keyword_type;
5887         if (kwds2) {
5888             if (unlikely(PyDict_SetItem(kwds2, key, value))) goto bad;
5889         } else {
5890             goto invalid_keyword;
5891         }
5892     }
5893     return 0;
5894 arg_passed_twice:
5895     __Pyx_RaiseDoubleKeywordsError(function_name, key);
5896     goto bad;
5897 invalid_keyword_type:
5898     PyErr_Format(PyExc_TypeError,
5899         "%.200s() keywords must be strings", function_name);
5900     goto bad;
5901 invalid_keyword:
5902     PyErr_Format(PyExc_TypeError,
5903     #if PY_MAJOR_VERSION < 3
5904         "%.200s() got an unexpected keyword argument '%.200s'",
5905         function_name, PyString_AsString(key));
5906     #else
5907         "%s() got an unexpected keyword argument '%U'",
5908         function_name, key);
5909     #endif
5910 bad:
5911     return -1;
5912 }
5913 
5914 /* ObjectGetItem */
5915   #if CYTHON_USE_TYPE_SLOTS
__Pyx_PyObject_GetIndex(PyObject * obj,PyObject * index)5916 static PyObject *__Pyx_PyObject_GetIndex(PyObject *obj, PyObject* index) {
5917     PyObject *runerr;
5918     Py_ssize_t key_value;
5919     PySequenceMethods *m = Py_TYPE(obj)->tp_as_sequence;
5920     if (unlikely(!(m && m->sq_item))) {
5921         PyErr_Format(PyExc_TypeError, "'%.200s' object is not subscriptable", Py_TYPE(obj)->tp_name);
5922         return NULL;
5923     }
5924     key_value = __Pyx_PyIndex_AsSsize_t(index);
5925     if (likely(key_value != -1 || !(runerr = PyErr_Occurred()))) {
5926         return __Pyx_GetItemInt_Fast(obj, key_value, 0, 1, 1);
5927     }
5928     if (PyErr_GivenExceptionMatches(runerr, PyExc_OverflowError)) {
5929         PyErr_Clear();
5930         PyErr_Format(PyExc_IndexError, "cannot fit '%.200s' into an index-sized integer", Py_TYPE(index)->tp_name);
5931     }
5932     return NULL;
5933 }
__Pyx_PyObject_GetItem(PyObject * obj,PyObject * key)5934 static PyObject *__Pyx_PyObject_GetItem(PyObject *obj, PyObject* key) {
5935     PyMappingMethods *m = Py_TYPE(obj)->tp_as_mapping;
5936     if (likely(m && m->mp_subscript)) {
5937         return m->mp_subscript(obj, key);
5938     }
5939     return __Pyx_PyObject_GetIndex(obj, key);
5940 }
5941 #endif
5942 
5943 /* ArgTypeTest */
__Pyx__ArgTypeTest(PyObject * obj,PyTypeObject * type,const char * name,int exact)5944   static int __Pyx__ArgTypeTest(PyObject *obj, PyTypeObject *type, const char *name, int exact)
5945 {
5946     if (unlikely(!type)) {
5947         PyErr_SetString(PyExc_SystemError, "Missing type object");
5948         return 0;
5949     }
5950     else if (exact) {
5951         #if PY_MAJOR_VERSION == 2
5952         if ((type == &PyBaseString_Type) && likely(__Pyx_PyBaseString_CheckExact(obj))) return 1;
5953         #endif
5954     }
5955     else {
5956         if (likely(__Pyx_TypeCheck(obj, type))) return 1;
5957     }
5958     PyErr_Format(PyExc_TypeError,
5959         "Argument '%.200s' has incorrect type (expected %.200s, got %.200s)",
5960         name, type->tp_name, Py_TYPE(obj)->tp_name);
5961     return 0;
5962 }
5963 
5964 /* GetTopmostException */
5965   #if CYTHON_USE_EXC_INFO_STACK
5966 static _PyErr_StackItem *
__Pyx_PyErr_GetTopmostException(PyThreadState * tstate)5967 __Pyx_PyErr_GetTopmostException(PyThreadState *tstate)
5968 {
5969     _PyErr_StackItem *exc_info = tstate->exc_info;
5970     while ((exc_info->exc_type == NULL || exc_info->exc_type == Py_None) &&
5971            exc_info->previous_item != NULL)
5972     {
5973         exc_info = exc_info->previous_item;
5974     }
5975     return exc_info;
5976 }
5977 #endif
5978 
5979 /* SaveResetException */
5980   #if CYTHON_FAST_THREAD_STATE
__Pyx__ExceptionSave(PyThreadState * tstate,PyObject ** type,PyObject ** value,PyObject ** tb)5981 static CYTHON_INLINE void __Pyx__ExceptionSave(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) {
5982     #if CYTHON_USE_EXC_INFO_STACK
5983     _PyErr_StackItem *exc_info = __Pyx_PyErr_GetTopmostException(tstate);
5984     *type = exc_info->exc_type;
5985     *value = exc_info->exc_value;
5986     *tb = exc_info->exc_traceback;
5987     #else
5988     *type = tstate->exc_type;
5989     *value = tstate->exc_value;
5990     *tb = tstate->exc_traceback;
5991     #endif
5992     Py_XINCREF(*type);
5993     Py_XINCREF(*value);
5994     Py_XINCREF(*tb);
5995 }
__Pyx__ExceptionReset(PyThreadState * tstate,PyObject * type,PyObject * value,PyObject * tb)5996 static CYTHON_INLINE void __Pyx__ExceptionReset(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb) {
5997     PyObject *tmp_type, *tmp_value, *tmp_tb;
5998     #if CYTHON_USE_EXC_INFO_STACK
5999     _PyErr_StackItem *exc_info = tstate->exc_info;
6000     tmp_type = exc_info->exc_type;
6001     tmp_value = exc_info->exc_value;
6002     tmp_tb = exc_info->exc_traceback;
6003     exc_info->exc_type = type;
6004     exc_info->exc_value = value;
6005     exc_info->exc_traceback = tb;
6006     #else
6007     tmp_type = tstate->exc_type;
6008     tmp_value = tstate->exc_value;
6009     tmp_tb = tstate->exc_traceback;
6010     tstate->exc_type = type;
6011     tstate->exc_value = value;
6012     tstate->exc_traceback = tb;
6013     #endif
6014     Py_XDECREF(tmp_type);
6015     Py_XDECREF(tmp_value);
6016     Py_XDECREF(tmp_tb);
6017 }
6018 #endif
6019 
6020 /* PyErrExceptionMatches */
6021   #if CYTHON_FAST_THREAD_STATE
__Pyx_PyErr_ExceptionMatchesTuple(PyObject * exc_type,PyObject * tuple)6022 static int __Pyx_PyErr_ExceptionMatchesTuple(PyObject *exc_type, PyObject *tuple) {
6023     Py_ssize_t i, n;
6024     n = PyTuple_GET_SIZE(tuple);
6025 #if PY_MAJOR_VERSION >= 3
6026     for (i=0; i<n; i++) {
6027         if (exc_type == PyTuple_GET_ITEM(tuple, i)) return 1;
6028     }
6029 #endif
6030     for (i=0; i<n; i++) {
6031         if (__Pyx_PyErr_GivenExceptionMatches(exc_type, PyTuple_GET_ITEM(tuple, i))) return 1;
6032     }
6033     return 0;
6034 }
__Pyx_PyErr_ExceptionMatchesInState(PyThreadState * tstate,PyObject * err)6035 static CYTHON_INLINE int __Pyx_PyErr_ExceptionMatchesInState(PyThreadState* tstate, PyObject* err) {
6036     PyObject *exc_type = tstate->curexc_type;
6037     if (exc_type == err) return 1;
6038     if (unlikely(!exc_type)) return 0;
6039     if (unlikely(PyTuple_Check(err)))
6040         return __Pyx_PyErr_ExceptionMatchesTuple(exc_type, err);
6041     return __Pyx_PyErr_GivenExceptionMatches(exc_type, err);
6042 }
6043 #endif
6044 
6045 /* GetException */
6046   #if CYTHON_FAST_THREAD_STATE
__Pyx__GetException(PyThreadState * tstate,PyObject ** type,PyObject ** value,PyObject ** tb)6047 static int __Pyx__GetException(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb)
6048 #else
6049 static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb)
6050 #endif
6051 {
6052     PyObject *local_type, *local_value, *local_tb;
6053 #if CYTHON_FAST_THREAD_STATE
6054     PyObject *tmp_type, *tmp_value, *tmp_tb;
6055     local_type = tstate->curexc_type;
6056     local_value = tstate->curexc_value;
6057     local_tb = tstate->curexc_traceback;
6058     tstate->curexc_type = 0;
6059     tstate->curexc_value = 0;
6060     tstate->curexc_traceback = 0;
6061 #else
6062     PyErr_Fetch(&local_type, &local_value, &local_tb);
6063 #endif
6064     PyErr_NormalizeException(&local_type, &local_value, &local_tb);
6065 #if CYTHON_FAST_THREAD_STATE
6066     if (unlikely(tstate->curexc_type))
6067 #else
6068     if (unlikely(PyErr_Occurred()))
6069 #endif
6070         goto bad;
6071     #if PY_MAJOR_VERSION >= 3
6072     if (local_tb) {
6073         if (unlikely(PyException_SetTraceback(local_value, local_tb) < 0))
6074             goto bad;
6075     }
6076     #endif
6077     Py_XINCREF(local_tb);
6078     Py_XINCREF(local_type);
6079     Py_XINCREF(local_value);
6080     *type = local_type;
6081     *value = local_value;
6082     *tb = local_tb;
6083 #if CYTHON_FAST_THREAD_STATE
6084     #if CYTHON_USE_EXC_INFO_STACK
6085     {
6086         _PyErr_StackItem *exc_info = tstate->exc_info;
6087         tmp_type = exc_info->exc_type;
6088         tmp_value = exc_info->exc_value;
6089         tmp_tb = exc_info->exc_traceback;
6090         exc_info->exc_type = local_type;
6091         exc_info->exc_value = local_value;
6092         exc_info->exc_traceback = local_tb;
6093     }
6094     #else
6095     tmp_type = tstate->exc_type;
6096     tmp_value = tstate->exc_value;
6097     tmp_tb = tstate->exc_traceback;
6098     tstate->exc_type = local_type;
6099     tstate->exc_value = local_value;
6100     tstate->exc_traceback = local_tb;
6101     #endif
6102     Py_XDECREF(tmp_type);
6103     Py_XDECREF(tmp_value);
6104     Py_XDECREF(tmp_tb);
6105 #else
6106     PyErr_SetExcInfo(local_type, local_value, local_tb);
6107 #endif
6108     return 0;
6109 bad:
6110     *type = 0;
6111     *value = 0;
6112     *tb = 0;
6113     Py_XDECREF(local_type);
6114     Py_XDECREF(local_value);
6115     Py_XDECREF(local_tb);
6116     return -1;
6117 }
6118 
6119 /* RaiseException */
6120   #if PY_MAJOR_VERSION < 3
__Pyx_Raise(PyObject * type,PyObject * value,PyObject * tb,CYTHON_UNUSED PyObject * cause)6121 static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb,
6122                         CYTHON_UNUSED PyObject *cause) {
6123     __Pyx_PyThreadState_declare
6124     Py_XINCREF(type);
6125     if (!value || value == Py_None)
6126         value = NULL;
6127     else
6128         Py_INCREF(value);
6129     if (!tb || tb == Py_None)
6130         tb = NULL;
6131     else {
6132         Py_INCREF(tb);
6133         if (!PyTraceBack_Check(tb)) {
6134             PyErr_SetString(PyExc_TypeError,
6135                 "raise: arg 3 must be a traceback or None");
6136             goto raise_error;
6137         }
6138     }
6139     if (PyType_Check(type)) {
6140 #if CYTHON_COMPILING_IN_PYPY
6141         if (!value) {
6142             Py_INCREF(Py_None);
6143             value = Py_None;
6144         }
6145 #endif
6146         PyErr_NormalizeException(&type, &value, &tb);
6147     } else {
6148         if (value) {
6149             PyErr_SetString(PyExc_TypeError,
6150                 "instance exception may not have a separate value");
6151             goto raise_error;
6152         }
6153         value = type;
6154         type = (PyObject*) Py_TYPE(type);
6155         Py_INCREF(type);
6156         if (!PyType_IsSubtype((PyTypeObject *)type, (PyTypeObject *)PyExc_BaseException)) {
6157             PyErr_SetString(PyExc_TypeError,
6158                 "raise: exception class must be a subclass of BaseException");
6159             goto raise_error;
6160         }
6161     }
6162     __Pyx_PyThreadState_assign
6163     __Pyx_ErrRestore(type, value, tb);
6164     return;
6165 raise_error:
6166     Py_XDECREF(value);
6167     Py_XDECREF(type);
6168     Py_XDECREF(tb);
6169     return;
6170 }
6171 #else
__Pyx_Raise(PyObject * type,PyObject * value,PyObject * tb,PyObject * cause)6172 static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause) {
6173     PyObject* owned_instance = NULL;
6174     if (tb == Py_None) {
6175         tb = 0;
6176     } else if (tb && !PyTraceBack_Check(tb)) {
6177         PyErr_SetString(PyExc_TypeError,
6178             "raise: arg 3 must be a traceback or None");
6179         goto bad;
6180     }
6181     if (value == Py_None)
6182         value = 0;
6183     if (PyExceptionInstance_Check(type)) {
6184         if (value) {
6185             PyErr_SetString(PyExc_TypeError,
6186                 "instance exception may not have a separate value");
6187             goto bad;
6188         }
6189         value = type;
6190         type = (PyObject*) Py_TYPE(value);
6191     } else if (PyExceptionClass_Check(type)) {
6192         PyObject *instance_class = NULL;
6193         if (value && PyExceptionInstance_Check(value)) {
6194             instance_class = (PyObject*) Py_TYPE(value);
6195             if (instance_class != type) {
6196                 int is_subclass = PyObject_IsSubclass(instance_class, type);
6197                 if (!is_subclass) {
6198                     instance_class = NULL;
6199                 } else if (unlikely(is_subclass == -1)) {
6200                     goto bad;
6201                 } else {
6202                     type = instance_class;
6203                 }
6204             }
6205         }
6206         if (!instance_class) {
6207             PyObject *args;
6208             if (!value)
6209                 args = PyTuple_New(0);
6210             else if (PyTuple_Check(value)) {
6211                 Py_INCREF(value);
6212                 args = value;
6213             } else
6214                 args = PyTuple_Pack(1, value);
6215             if (!args)
6216                 goto bad;
6217             owned_instance = PyObject_Call(type, args, NULL);
6218             Py_DECREF(args);
6219             if (!owned_instance)
6220                 goto bad;
6221             value = owned_instance;
6222             if (!PyExceptionInstance_Check(value)) {
6223                 PyErr_Format(PyExc_TypeError,
6224                              "calling %R should have returned an instance of "
6225                              "BaseException, not %R",
6226                              type, Py_TYPE(value));
6227                 goto bad;
6228             }
6229         }
6230     } else {
6231         PyErr_SetString(PyExc_TypeError,
6232             "raise: exception class must be a subclass of BaseException");
6233         goto bad;
6234     }
6235     if (cause) {
6236         PyObject *fixed_cause;
6237         if (cause == Py_None) {
6238             fixed_cause = NULL;
6239         } else if (PyExceptionClass_Check(cause)) {
6240             fixed_cause = PyObject_CallObject(cause, NULL);
6241             if (fixed_cause == NULL)
6242                 goto bad;
6243         } else if (PyExceptionInstance_Check(cause)) {
6244             fixed_cause = cause;
6245             Py_INCREF(fixed_cause);
6246         } else {
6247             PyErr_SetString(PyExc_TypeError,
6248                             "exception causes must derive from "
6249                             "BaseException");
6250             goto bad;
6251         }
6252         PyException_SetCause(value, fixed_cause);
6253     }
6254     PyErr_SetObject(type, value);
6255     if (tb) {
6256 #if CYTHON_COMPILING_IN_PYPY
6257         PyObject *tmp_type, *tmp_value, *tmp_tb;
6258         PyErr_Fetch(&tmp_type, &tmp_value, &tmp_tb);
6259         Py_INCREF(tb);
6260         PyErr_Restore(tmp_type, tmp_value, tb);
6261         Py_XDECREF(tmp_tb);
6262 #else
6263         PyThreadState *tstate = __Pyx_PyThreadState_Current;
6264         PyObject* tmp_tb = tstate->curexc_traceback;
6265         if (tb != tmp_tb) {
6266             Py_INCREF(tb);
6267             tstate->curexc_traceback = tb;
6268             Py_XDECREF(tmp_tb);
6269         }
6270 #endif
6271     }
6272 bad:
6273     Py_XDECREF(owned_instance);
6274     return;
6275 }
6276 #endif
6277 
6278 /* TypeImport */
6279   #ifndef __PYX_HAVE_RT_ImportType
6280 #define __PYX_HAVE_RT_ImportType
__Pyx_ImportType(PyObject * module,const char * module_name,const char * class_name,size_t size,enum __Pyx_ImportType_CheckSize check_size)6281 static PyTypeObject *__Pyx_ImportType(PyObject *module, const char *module_name, const char *class_name,
6282     size_t size, enum __Pyx_ImportType_CheckSize check_size)
6283 {
6284     PyObject *result = 0;
6285     char warning[200];
6286     Py_ssize_t basicsize;
6287 #ifdef Py_LIMITED_API
6288     PyObject *py_basicsize;
6289 #endif
6290     result = PyObject_GetAttrString(module, class_name);
6291     if (!result)
6292         goto bad;
6293     if (!PyType_Check(result)) {
6294         PyErr_Format(PyExc_TypeError,
6295             "%.200s.%.200s is not a type object",
6296             module_name, class_name);
6297         goto bad;
6298     }
6299 #ifndef Py_LIMITED_API
6300     basicsize = ((PyTypeObject *)result)->tp_basicsize;
6301 #else
6302     py_basicsize = PyObject_GetAttrString(result, "__basicsize__");
6303     if (!py_basicsize)
6304         goto bad;
6305     basicsize = PyLong_AsSsize_t(py_basicsize);
6306     Py_DECREF(py_basicsize);
6307     py_basicsize = 0;
6308     if (basicsize == (Py_ssize_t)-1 && PyErr_Occurred())
6309         goto bad;
6310 #endif
6311     if ((size_t)basicsize < size) {
6312         PyErr_Format(PyExc_ValueError,
6313             "%.200s.%.200s size changed, may indicate binary incompatibility. "
6314             "Expected %zd from C header, got %zd from PyObject",
6315             module_name, class_name, size, basicsize);
6316         goto bad;
6317     }
6318     if (check_size == __Pyx_ImportType_CheckSize_Error && (size_t)basicsize != size) {
6319         PyErr_Format(PyExc_ValueError,
6320             "%.200s.%.200s size changed, may indicate binary incompatibility. "
6321             "Expected %zd from C header, got %zd from PyObject",
6322             module_name, class_name, size, basicsize);
6323         goto bad;
6324     }
6325     else if (check_size == __Pyx_ImportType_CheckSize_Warn && (size_t)basicsize > size) {
6326         PyOS_snprintf(warning, sizeof(warning),
6327             "%s.%s size changed, may indicate binary incompatibility. "
6328             "Expected %zd from C header, got %zd from PyObject",
6329             module_name, class_name, size, basicsize);
6330         if (PyErr_WarnEx(NULL, warning, 0) < 0) goto bad;
6331     }
6332     return (PyTypeObject *)result;
6333 bad:
6334     Py_XDECREF(result);
6335     return NULL;
6336 }
6337 #endif
6338 
6339 /* Import */
__Pyx_Import(PyObject * name,PyObject * from_list,int level)6340   static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, int level) {
6341     PyObject *empty_list = 0;
6342     PyObject *module = 0;
6343     PyObject *global_dict = 0;
6344     PyObject *empty_dict = 0;
6345     PyObject *list;
6346     #if PY_MAJOR_VERSION < 3
6347     PyObject *py_import;
6348     py_import = __Pyx_PyObject_GetAttrStr(__pyx_b, __pyx_n_s_import);
6349     if (!py_import)
6350         goto bad;
6351     #endif
6352     if (from_list)
6353         list = from_list;
6354     else {
6355         empty_list = PyList_New(0);
6356         if (!empty_list)
6357             goto bad;
6358         list = empty_list;
6359     }
6360     global_dict = PyModule_GetDict(__pyx_m);
6361     if (!global_dict)
6362         goto bad;
6363     empty_dict = PyDict_New();
6364     if (!empty_dict)
6365         goto bad;
6366     {
6367         #if PY_MAJOR_VERSION >= 3
6368         if (level == -1) {
6369             if ((1) && (strchr(__Pyx_MODULE_NAME, '.'))) {
6370                 module = PyImport_ImportModuleLevelObject(
6371                     name, global_dict, empty_dict, list, 1);
6372                 if (!module) {
6373                     if (!PyErr_ExceptionMatches(PyExc_ImportError))
6374                         goto bad;
6375                     PyErr_Clear();
6376                 }
6377             }
6378             level = 0;
6379         }
6380         #endif
6381         if (!module) {
6382             #if PY_MAJOR_VERSION < 3
6383             PyObject *py_level = PyInt_FromLong(level);
6384             if (!py_level)
6385                 goto bad;
6386             module = PyObject_CallFunctionObjArgs(py_import,
6387                 name, global_dict, empty_dict, list, py_level, (PyObject *)NULL);
6388             Py_DECREF(py_level);
6389             #else
6390             module = PyImport_ImportModuleLevelObject(
6391                 name, global_dict, empty_dict, list, level);
6392             #endif
6393         }
6394     }
6395 bad:
6396     #if PY_MAJOR_VERSION < 3
6397     Py_XDECREF(py_import);
6398     #endif
6399     Py_XDECREF(empty_list);
6400     Py_XDECREF(empty_dict);
6401     return module;
6402 }
6403 
6404 /* PyDictVersioning */
6405   #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_TYPE_SLOTS
__Pyx_get_tp_dict_version(PyObject * obj)6406 static CYTHON_INLINE PY_UINT64_T __Pyx_get_tp_dict_version(PyObject *obj) {
6407     PyObject *dict = Py_TYPE(obj)->tp_dict;
6408     return likely(dict) ? __PYX_GET_DICT_VERSION(dict) : 0;
6409 }
__Pyx_get_object_dict_version(PyObject * obj)6410 static CYTHON_INLINE PY_UINT64_T __Pyx_get_object_dict_version(PyObject *obj) {
6411     PyObject **dictptr = NULL;
6412     Py_ssize_t offset = Py_TYPE(obj)->tp_dictoffset;
6413     if (offset) {
6414 #if CYTHON_COMPILING_IN_CPYTHON
6415         dictptr = (likely(offset > 0)) ? (PyObject **) ((char *)obj + offset) : _PyObject_GetDictPtr(obj);
6416 #else
6417         dictptr = _PyObject_GetDictPtr(obj);
6418 #endif
6419     }
6420     return (dictptr && *dictptr) ? __PYX_GET_DICT_VERSION(*dictptr) : 0;
6421 }
__Pyx_object_dict_version_matches(PyObject * obj,PY_UINT64_T tp_dict_version,PY_UINT64_T obj_dict_version)6422 static CYTHON_INLINE int __Pyx_object_dict_version_matches(PyObject* obj, PY_UINT64_T tp_dict_version, PY_UINT64_T obj_dict_version) {
6423     PyObject *dict = Py_TYPE(obj)->tp_dict;
6424     if (unlikely(!dict) || unlikely(tp_dict_version != __PYX_GET_DICT_VERSION(dict)))
6425         return 0;
6426     return obj_dict_version == __Pyx_get_object_dict_version(obj);
6427 }
6428 #endif
6429 
6430 /* GetModuleGlobalName */
6431   #if CYTHON_USE_DICT_VERSIONS
__Pyx__GetModuleGlobalName(PyObject * name,PY_UINT64_T * dict_version,PyObject ** dict_cached_value)6432 static PyObject *__Pyx__GetModuleGlobalName(PyObject *name, PY_UINT64_T *dict_version, PyObject **dict_cached_value)
6433 #else
6434 static CYTHON_INLINE PyObject *__Pyx__GetModuleGlobalName(PyObject *name)
6435 #endif
6436 {
6437     PyObject *result;
6438 #if !CYTHON_AVOID_BORROWED_REFS
6439 #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030500A1
6440     result = _PyDict_GetItem_KnownHash(__pyx_d, name, ((PyASCIIObject *) name)->hash);
6441     __PYX_UPDATE_DICT_CACHE(__pyx_d, result, *dict_cached_value, *dict_version)
6442     if (likely(result)) {
6443         return __Pyx_NewRef(result);
6444     } else if (unlikely(PyErr_Occurred())) {
6445         return NULL;
6446     }
6447 #else
6448     result = PyDict_GetItem(__pyx_d, name);
6449     __PYX_UPDATE_DICT_CACHE(__pyx_d, result, *dict_cached_value, *dict_version)
6450     if (likely(result)) {
6451         return __Pyx_NewRef(result);
6452     }
6453 #endif
6454 #else
6455     result = PyObject_GetItem(__pyx_d, name);
6456     __PYX_UPDATE_DICT_CACHE(__pyx_d, result, *dict_cached_value, *dict_version)
6457     if (likely(result)) {
6458         return __Pyx_NewRef(result);
6459     }
6460     PyErr_Clear();
6461 #endif
6462     return __Pyx_GetBuiltinName(name);
6463 }
6464 
6465 /* CLineInTraceback */
6466   #ifndef CYTHON_CLINE_IN_TRACEBACK
__Pyx_CLineForTraceback(CYTHON_NCP_UNUSED PyThreadState * tstate,int c_line)6467 static int __Pyx_CLineForTraceback(CYTHON_NCP_UNUSED PyThreadState *tstate, int c_line) {
6468     PyObject *use_cline;
6469     PyObject *ptype, *pvalue, *ptraceback;
6470 #if CYTHON_COMPILING_IN_CPYTHON
6471     PyObject **cython_runtime_dict;
6472 #endif
6473     if (unlikely(!__pyx_cython_runtime)) {
6474         return c_line;
6475     }
6476     __Pyx_ErrFetchInState(tstate, &ptype, &pvalue, &ptraceback);
6477 #if CYTHON_COMPILING_IN_CPYTHON
6478     cython_runtime_dict = _PyObject_GetDictPtr(__pyx_cython_runtime);
6479     if (likely(cython_runtime_dict)) {
6480         __PYX_PY_DICT_LOOKUP_IF_MODIFIED(
6481             use_cline, *cython_runtime_dict,
6482             __Pyx_PyDict_GetItemStr(*cython_runtime_dict, __pyx_n_s_cline_in_traceback))
6483     } else
6484 #endif
6485     {
6486       PyObject *use_cline_obj = __Pyx_PyObject_GetAttrStr(__pyx_cython_runtime, __pyx_n_s_cline_in_traceback);
6487       if (use_cline_obj) {
6488         use_cline = PyObject_Not(use_cline_obj) ? Py_False : Py_True;
6489         Py_DECREF(use_cline_obj);
6490       } else {
6491         PyErr_Clear();
6492         use_cline = NULL;
6493       }
6494     }
6495     if (!use_cline) {
6496         c_line = 0;
6497         PyObject_SetAttr(__pyx_cython_runtime, __pyx_n_s_cline_in_traceback, Py_False);
6498     }
6499     else if (use_cline == Py_False || (use_cline != Py_True && PyObject_Not(use_cline) != 0)) {
6500         c_line = 0;
6501     }
6502     __Pyx_ErrRestoreInState(tstate, ptype, pvalue, ptraceback);
6503     return c_line;
6504 }
6505 #endif
6506 
6507 /* CodeObjectCache */
__pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry * entries,int count,int code_line)6508   static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line) {
6509     int start = 0, mid = 0, end = count - 1;
6510     if (end >= 0 && code_line > entries[end].code_line) {
6511         return count;
6512     }
6513     while (start < end) {
6514         mid = start + (end - start) / 2;
6515         if (code_line < entries[mid].code_line) {
6516             end = mid;
6517         } else if (code_line > entries[mid].code_line) {
6518              start = mid + 1;
6519         } else {
6520             return mid;
6521         }
6522     }
6523     if (code_line <= entries[mid].code_line) {
6524         return mid;
6525     } else {
6526         return mid + 1;
6527     }
6528 }
__pyx_find_code_object(int code_line)6529 static PyCodeObject *__pyx_find_code_object(int code_line) {
6530     PyCodeObject* code_object;
6531     int pos;
6532     if (unlikely(!code_line) || unlikely(!__pyx_code_cache.entries)) {
6533         return NULL;
6534     }
6535     pos = __pyx_bisect_code_objects(__pyx_code_cache.entries, __pyx_code_cache.count, code_line);
6536     if (unlikely(pos >= __pyx_code_cache.count) || unlikely(__pyx_code_cache.entries[pos].code_line != code_line)) {
6537         return NULL;
6538     }
6539     code_object = __pyx_code_cache.entries[pos].code_object;
6540     Py_INCREF(code_object);
6541     return code_object;
6542 }
__pyx_insert_code_object(int code_line,PyCodeObject * code_object)6543 static void __pyx_insert_code_object(int code_line, PyCodeObject* code_object) {
6544     int pos, i;
6545     __Pyx_CodeObjectCacheEntry* entries = __pyx_code_cache.entries;
6546     if (unlikely(!code_line)) {
6547         return;
6548     }
6549     if (unlikely(!entries)) {
6550         entries = (__Pyx_CodeObjectCacheEntry*)PyMem_Malloc(64*sizeof(__Pyx_CodeObjectCacheEntry));
6551         if (likely(entries)) {
6552             __pyx_code_cache.entries = entries;
6553             __pyx_code_cache.max_count = 64;
6554             __pyx_code_cache.count = 1;
6555             entries[0].code_line = code_line;
6556             entries[0].code_object = code_object;
6557             Py_INCREF(code_object);
6558         }
6559         return;
6560     }
6561     pos = __pyx_bisect_code_objects(__pyx_code_cache.entries, __pyx_code_cache.count, code_line);
6562     if ((pos < __pyx_code_cache.count) && unlikely(__pyx_code_cache.entries[pos].code_line == code_line)) {
6563         PyCodeObject* tmp = entries[pos].code_object;
6564         entries[pos].code_object = code_object;
6565         Py_DECREF(tmp);
6566         return;
6567     }
6568     if (__pyx_code_cache.count == __pyx_code_cache.max_count) {
6569         int new_max = __pyx_code_cache.max_count + 64;
6570         entries = (__Pyx_CodeObjectCacheEntry*)PyMem_Realloc(
6571             __pyx_code_cache.entries, ((size_t)new_max) * sizeof(__Pyx_CodeObjectCacheEntry));
6572         if (unlikely(!entries)) {
6573             return;
6574         }
6575         __pyx_code_cache.entries = entries;
6576         __pyx_code_cache.max_count = new_max;
6577     }
6578     for (i=__pyx_code_cache.count; i>pos; i--) {
6579         entries[i] = entries[i-1];
6580     }
6581     entries[pos].code_line = code_line;
6582     entries[pos].code_object = code_object;
6583     __pyx_code_cache.count++;
6584     Py_INCREF(code_object);
6585 }
6586 
6587 /* AddTraceback */
6588   #include "compile.h"
6589 #include "frameobject.h"
6590 #include "traceback.h"
__Pyx_CreateCodeObjectForTraceback(const char * funcname,int c_line,int py_line,const char * filename)6591 static PyCodeObject* __Pyx_CreateCodeObjectForTraceback(
6592             const char *funcname, int c_line,
6593             int py_line, const char *filename) {
6594     PyCodeObject *py_code = 0;
6595     PyObject *py_srcfile = 0;
6596     PyObject *py_funcname = 0;
6597     #if PY_MAJOR_VERSION < 3
6598     py_srcfile = PyString_FromString(filename);
6599     #else
6600     py_srcfile = PyUnicode_FromString(filename);
6601     #endif
6602     if (!py_srcfile) goto bad;
6603     if (c_line) {
6604         #if PY_MAJOR_VERSION < 3
6605         py_funcname = PyString_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, c_line);
6606         #else
6607         py_funcname = PyUnicode_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, c_line);
6608         #endif
6609     }
6610     else {
6611         #if PY_MAJOR_VERSION < 3
6612         py_funcname = PyString_FromString(funcname);
6613         #else
6614         py_funcname = PyUnicode_FromString(funcname);
6615         #endif
6616     }
6617     if (!py_funcname) goto bad;
6618     py_code = __Pyx_PyCode_New(
6619         0,
6620         0,
6621         0,
6622         0,
6623         0,
6624         __pyx_empty_bytes, /*PyObject *code,*/
6625         __pyx_empty_tuple, /*PyObject *consts,*/
6626         __pyx_empty_tuple, /*PyObject *names,*/
6627         __pyx_empty_tuple, /*PyObject *varnames,*/
6628         __pyx_empty_tuple, /*PyObject *freevars,*/
6629         __pyx_empty_tuple, /*PyObject *cellvars,*/
6630         py_srcfile,   /*PyObject *filename,*/
6631         py_funcname,  /*PyObject *name,*/
6632         py_line,
6633         __pyx_empty_bytes  /*PyObject *lnotab*/
6634     );
6635     Py_DECREF(py_srcfile);
6636     Py_DECREF(py_funcname);
6637     return py_code;
6638 bad:
6639     Py_XDECREF(py_srcfile);
6640     Py_XDECREF(py_funcname);
6641     return NULL;
6642 }
__Pyx_AddTraceback(const char * funcname,int c_line,int py_line,const char * filename)6643 static void __Pyx_AddTraceback(const char *funcname, int c_line,
6644                                int py_line, const char *filename) {
6645     PyCodeObject *py_code = 0;
6646     PyFrameObject *py_frame = 0;
6647     PyThreadState *tstate = __Pyx_PyThreadState_Current;
6648     if (c_line) {
6649         c_line = __Pyx_CLineForTraceback(tstate, c_line);
6650     }
6651     py_code = __pyx_find_code_object(c_line ? -c_line : py_line);
6652     if (!py_code) {
6653         py_code = __Pyx_CreateCodeObjectForTraceback(
6654             funcname, c_line, py_line, filename);
6655         if (!py_code) goto bad;
6656         __pyx_insert_code_object(c_line ? -c_line : py_line, py_code);
6657     }
6658     py_frame = PyFrame_New(
6659         tstate,            /*PyThreadState *tstate,*/
6660         py_code,           /*PyCodeObject *code,*/
6661         __pyx_d,    /*PyObject *globals,*/
6662         0                  /*PyObject *locals*/
6663     );
6664     if (!py_frame) goto bad;
6665     __Pyx_PyFrame_SetLineNumber(py_frame, py_line);
6666     PyTraceBack_Here(py_frame);
6667 bad:
6668     Py_XDECREF(py_code);
6669     Py_XDECREF(py_frame);
6670 }
6671 
6672 #if PY_MAJOR_VERSION < 3
__Pyx_GetBuffer(PyObject * obj,Py_buffer * view,int flags)6673 static int __Pyx_GetBuffer(PyObject *obj, Py_buffer *view, int flags) {
6674     if (PyObject_CheckBuffer(obj)) return PyObject_GetBuffer(obj, view, flags);
6675     PyErr_Format(PyExc_TypeError, "'%.200s' does not have the buffer interface", Py_TYPE(obj)->tp_name);
6676     return -1;
6677 }
__Pyx_ReleaseBuffer(Py_buffer * view)6678 static void __Pyx_ReleaseBuffer(Py_buffer *view) {
6679     PyObject *obj = view->obj;
6680     if (!obj) return;
6681     if (PyObject_CheckBuffer(obj)) {
6682         PyBuffer_Release(view);
6683         return;
6684     }
6685     if ((0)) {}
6686     view->obj = NULL;
6687     Py_DECREF(obj);
6688 }
6689 #endif
6690 
6691 
6692   /* CIntFromPyVerify */
6693   #define __PYX_VERIFY_RETURN_INT(target_type, func_type, func_value)\
6694     __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, 0)
6695 #define __PYX_VERIFY_RETURN_INT_EXC(target_type, func_type, func_value)\
6696     __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, 1)
6697 #define __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, exc)\
6698     {\
6699         func_type value = func_value;\
6700         if (sizeof(target_type) < sizeof(func_type)) {\
6701             if (unlikely(value != (func_type) (target_type) value)) {\
6702                 func_type zero = 0;\
6703                 if (exc && unlikely(value == (func_type)-1 && PyErr_Occurred()))\
6704                     return (target_type) -1;\
6705                 if (is_unsigned && unlikely(value < zero))\
6706                     goto raise_neg_overflow;\
6707                 else\
6708                     goto raise_overflow;\
6709             }\
6710         }\
6711         return (target_type) value;\
6712     }
6713 
6714 /* Declarations */
6715   #if CYTHON_CCOMPLEX
6716   #ifdef __cplusplus
__pyx_t_double_complex_from_parts(double x,double y)6717     static CYTHON_INLINE __pyx_t_double_complex __pyx_t_double_complex_from_parts(double x, double y) {
6718       return ::std::complex< double >(x, y);
6719     }
6720   #else
__pyx_t_double_complex_from_parts(double x,double y)6721     static CYTHON_INLINE __pyx_t_double_complex __pyx_t_double_complex_from_parts(double x, double y) {
6722       return x + y*(__pyx_t_double_complex)_Complex_I;
6723     }
6724   #endif
6725 #else
__pyx_t_double_complex_from_parts(double x,double y)6726     static CYTHON_INLINE __pyx_t_double_complex __pyx_t_double_complex_from_parts(double x, double y) {
6727       __pyx_t_double_complex z;
6728       z.real = x;
6729       z.imag = y;
6730       return z;
6731     }
6732 #endif
6733 
6734 /* Arithmetic */
6735   #if CYTHON_CCOMPLEX
6736 #else
__Pyx_c_eq_double(__pyx_t_double_complex a,__pyx_t_double_complex b)6737     static CYTHON_INLINE int __Pyx_c_eq_double(__pyx_t_double_complex a, __pyx_t_double_complex b) {
6738        return (a.real == b.real) && (a.imag == b.imag);
6739     }
__Pyx_c_sum_double(__pyx_t_double_complex a,__pyx_t_double_complex b)6740     static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_sum_double(__pyx_t_double_complex a, __pyx_t_double_complex b) {
6741         __pyx_t_double_complex z;
6742         z.real = a.real + b.real;
6743         z.imag = a.imag + b.imag;
6744         return z;
6745     }
__Pyx_c_diff_double(__pyx_t_double_complex a,__pyx_t_double_complex b)6746     static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_diff_double(__pyx_t_double_complex a, __pyx_t_double_complex b) {
6747         __pyx_t_double_complex z;
6748         z.real = a.real - b.real;
6749         z.imag = a.imag - b.imag;
6750         return z;
6751     }
__Pyx_c_prod_double(__pyx_t_double_complex a,__pyx_t_double_complex b)6752     static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_prod_double(__pyx_t_double_complex a, __pyx_t_double_complex b) {
6753         __pyx_t_double_complex z;
6754         z.real = a.real * b.real - a.imag * b.imag;
6755         z.imag = a.real * b.imag + a.imag * b.real;
6756         return z;
6757     }
6758     #if 1
__Pyx_c_quot_double(__pyx_t_double_complex a,__pyx_t_double_complex b)6759     static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_quot_double(__pyx_t_double_complex a, __pyx_t_double_complex b) {
6760         if (b.imag == 0) {
6761             return __pyx_t_double_complex_from_parts(a.real / b.real, a.imag / b.real);
6762         } else if (fabs(b.real) >= fabs(b.imag)) {
6763             if (b.real == 0 && b.imag == 0) {
6764                 return __pyx_t_double_complex_from_parts(a.real / b.real, a.imag / b.imag);
6765             } else {
6766                 double r = b.imag / b.real;
6767                 double s = (double)(1.0) / (b.real + b.imag * r);
6768                 return __pyx_t_double_complex_from_parts(
6769                     (a.real + a.imag * r) * s, (a.imag - a.real * r) * s);
6770             }
6771         } else {
6772             double r = b.real / b.imag;
6773             double s = (double)(1.0) / (b.imag + b.real * r);
6774             return __pyx_t_double_complex_from_parts(
6775                 (a.real * r + a.imag) * s, (a.imag * r - a.real) * s);
6776         }
6777     }
6778     #else
__Pyx_c_quot_double(__pyx_t_double_complex a,__pyx_t_double_complex b)6779     static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_quot_double(__pyx_t_double_complex a, __pyx_t_double_complex b) {
6780         if (b.imag == 0) {
6781             return __pyx_t_double_complex_from_parts(a.real / b.real, a.imag / b.real);
6782         } else {
6783             double denom = b.real * b.real + b.imag * b.imag;
6784             return __pyx_t_double_complex_from_parts(
6785                 (a.real * b.real + a.imag * b.imag) / denom,
6786                 (a.imag * b.real - a.real * b.imag) / denom);
6787         }
6788     }
6789     #endif
__Pyx_c_neg_double(__pyx_t_double_complex a)6790     static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_neg_double(__pyx_t_double_complex a) {
6791         __pyx_t_double_complex z;
6792         z.real = -a.real;
6793         z.imag = -a.imag;
6794         return z;
6795     }
__Pyx_c_is_zero_double(__pyx_t_double_complex a)6796     static CYTHON_INLINE int __Pyx_c_is_zero_double(__pyx_t_double_complex a) {
6797        return (a.real == 0) && (a.imag == 0);
6798     }
__Pyx_c_conj_double(__pyx_t_double_complex a)6799     static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_conj_double(__pyx_t_double_complex a) {
6800         __pyx_t_double_complex z;
6801         z.real =  a.real;
6802         z.imag = -a.imag;
6803         return z;
6804     }
6805     #if 1
__Pyx_c_abs_double(__pyx_t_double_complex z)6806         static CYTHON_INLINE double __Pyx_c_abs_double(__pyx_t_double_complex z) {
6807           #if !defined(HAVE_HYPOT) || defined(_MSC_VER)
6808             return sqrt(z.real*z.real + z.imag*z.imag);
6809           #else
6810             return hypot(z.real, z.imag);
6811           #endif
6812         }
__Pyx_c_pow_double(__pyx_t_double_complex a,__pyx_t_double_complex b)6813         static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_pow_double(__pyx_t_double_complex a, __pyx_t_double_complex b) {
6814             __pyx_t_double_complex z;
6815             double r, lnr, theta, z_r, z_theta;
6816             if (b.imag == 0 && b.real == (int)b.real) {
6817                 if (b.real < 0) {
6818                     double denom = a.real * a.real + a.imag * a.imag;
6819                     a.real = a.real / denom;
6820                     a.imag = -a.imag / denom;
6821                     b.real = -b.real;
6822                 }
6823                 switch ((int)b.real) {
6824                     case 0:
6825                         z.real = 1;
6826                         z.imag = 0;
6827                         return z;
6828                     case 1:
6829                         return a;
6830                     case 2:
6831                         return __Pyx_c_prod_double(a, a);
6832                     case 3:
6833                         z = __Pyx_c_prod_double(a, a);
6834                         return __Pyx_c_prod_double(z, a);
6835                     case 4:
6836                         z = __Pyx_c_prod_double(a, a);
6837                         return __Pyx_c_prod_double(z, z);
6838                 }
6839             }
6840             if (a.imag == 0) {
6841                 if (a.real == 0) {
6842                     return a;
6843                 } else if (b.imag == 0) {
6844                     z.real = pow(a.real, b.real);
6845                     z.imag = 0;
6846                     return z;
6847                 } else if (a.real > 0) {
6848                     r = a.real;
6849                     theta = 0;
6850                 } else {
6851                     r = -a.real;
6852                     theta = atan2(0.0, -1.0);
6853                 }
6854             } else {
6855                 r = __Pyx_c_abs_double(a);
6856                 theta = atan2(a.imag, a.real);
6857             }
6858             lnr = log(r);
6859             z_r = exp(lnr * b.real - theta * b.imag);
6860             z_theta = theta * b.real + lnr * b.imag;
6861             z.real = z_r * cos(z_theta);
6862             z.imag = z_r * sin(z_theta);
6863             return z;
6864         }
6865     #endif
6866 #endif
6867 
6868 /* FromPy */
__Pyx_PyComplex_As___pyx_t_double_complex(PyObject * o)6869   static __pyx_t_double_complex __Pyx_PyComplex_As___pyx_t_double_complex(PyObject* o) {
6870     Py_complex cval;
6871 #if !CYTHON_COMPILING_IN_PYPY
6872     if (PyComplex_CheckExact(o))
6873         cval = ((PyComplexObject *)o)->cval;
6874     else
6875 #endif
6876         cval = PyComplex_AsCComplex(o);
6877     return __pyx_t_double_complex_from_parts(
6878                (double)cval.real,
6879                (double)cval.imag);
6880 }
6881 
6882 /* Declarations */
6883   #if CYTHON_CCOMPLEX
6884   #ifdef __cplusplus
__pyx_t_float_complex_from_parts(float x,float y)6885     static CYTHON_INLINE __pyx_t_float_complex __pyx_t_float_complex_from_parts(float x, float y) {
6886       return ::std::complex< float >(x, y);
6887     }
6888   #else
__pyx_t_float_complex_from_parts(float x,float y)6889     static CYTHON_INLINE __pyx_t_float_complex __pyx_t_float_complex_from_parts(float x, float y) {
6890       return x + y*(__pyx_t_float_complex)_Complex_I;
6891     }
6892   #endif
6893 #else
__pyx_t_float_complex_from_parts(float x,float y)6894     static CYTHON_INLINE __pyx_t_float_complex __pyx_t_float_complex_from_parts(float x, float y) {
6895       __pyx_t_float_complex z;
6896       z.real = x;
6897       z.imag = y;
6898       return z;
6899     }
6900 #endif
6901 
6902 /* Arithmetic */
6903   #if CYTHON_CCOMPLEX
6904 #else
__Pyx_c_eq_float(__pyx_t_float_complex a,__pyx_t_float_complex b)6905     static CYTHON_INLINE int __Pyx_c_eq_float(__pyx_t_float_complex a, __pyx_t_float_complex b) {
6906        return (a.real == b.real) && (a.imag == b.imag);
6907     }
__Pyx_c_sum_float(__pyx_t_float_complex a,__pyx_t_float_complex b)6908     static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_sum_float(__pyx_t_float_complex a, __pyx_t_float_complex b) {
6909         __pyx_t_float_complex z;
6910         z.real = a.real + b.real;
6911         z.imag = a.imag + b.imag;
6912         return z;
6913     }
__Pyx_c_diff_float(__pyx_t_float_complex a,__pyx_t_float_complex b)6914     static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_diff_float(__pyx_t_float_complex a, __pyx_t_float_complex b) {
6915         __pyx_t_float_complex z;
6916         z.real = a.real - b.real;
6917         z.imag = a.imag - b.imag;
6918         return z;
6919     }
__Pyx_c_prod_float(__pyx_t_float_complex a,__pyx_t_float_complex b)6920     static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_prod_float(__pyx_t_float_complex a, __pyx_t_float_complex b) {
6921         __pyx_t_float_complex z;
6922         z.real = a.real * b.real - a.imag * b.imag;
6923         z.imag = a.real * b.imag + a.imag * b.real;
6924         return z;
6925     }
6926     #if 1
__Pyx_c_quot_float(__pyx_t_float_complex a,__pyx_t_float_complex b)6927     static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_quot_float(__pyx_t_float_complex a, __pyx_t_float_complex b) {
6928         if (b.imag == 0) {
6929             return __pyx_t_float_complex_from_parts(a.real / b.real, a.imag / b.real);
6930         } else if (fabsf(b.real) >= fabsf(b.imag)) {
6931             if (b.real == 0 && b.imag == 0) {
6932                 return __pyx_t_float_complex_from_parts(a.real / b.real, a.imag / b.imag);
6933             } else {
6934                 float r = b.imag / b.real;
6935                 float s = (float)(1.0) / (b.real + b.imag * r);
6936                 return __pyx_t_float_complex_from_parts(
6937                     (a.real + a.imag * r) * s, (a.imag - a.real * r) * s);
6938             }
6939         } else {
6940             float r = b.real / b.imag;
6941             float s = (float)(1.0) / (b.imag + b.real * r);
6942             return __pyx_t_float_complex_from_parts(
6943                 (a.real * r + a.imag) * s, (a.imag * r - a.real) * s);
6944         }
6945     }
6946     #else
__Pyx_c_quot_float(__pyx_t_float_complex a,__pyx_t_float_complex b)6947     static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_quot_float(__pyx_t_float_complex a, __pyx_t_float_complex b) {
6948         if (b.imag == 0) {
6949             return __pyx_t_float_complex_from_parts(a.real / b.real, a.imag / b.real);
6950         } else {
6951             float denom = b.real * b.real + b.imag * b.imag;
6952             return __pyx_t_float_complex_from_parts(
6953                 (a.real * b.real + a.imag * b.imag) / denom,
6954                 (a.imag * b.real - a.real * b.imag) / denom);
6955         }
6956     }
6957     #endif
__Pyx_c_neg_float(__pyx_t_float_complex a)6958     static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_neg_float(__pyx_t_float_complex a) {
6959         __pyx_t_float_complex z;
6960         z.real = -a.real;
6961         z.imag = -a.imag;
6962         return z;
6963     }
__Pyx_c_is_zero_float(__pyx_t_float_complex a)6964     static CYTHON_INLINE int __Pyx_c_is_zero_float(__pyx_t_float_complex a) {
6965        return (a.real == 0) && (a.imag == 0);
6966     }
__Pyx_c_conj_float(__pyx_t_float_complex a)6967     static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_conj_float(__pyx_t_float_complex a) {
6968         __pyx_t_float_complex z;
6969         z.real =  a.real;
6970         z.imag = -a.imag;
6971         return z;
6972     }
6973     #if 1
__Pyx_c_abs_float(__pyx_t_float_complex z)6974         static CYTHON_INLINE float __Pyx_c_abs_float(__pyx_t_float_complex z) {
6975           #if !defined(HAVE_HYPOT) || defined(_MSC_VER)
6976             return sqrtf(z.real*z.real + z.imag*z.imag);
6977           #else
6978             return hypotf(z.real, z.imag);
6979           #endif
6980         }
__Pyx_c_pow_float(__pyx_t_float_complex a,__pyx_t_float_complex b)6981         static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_pow_float(__pyx_t_float_complex a, __pyx_t_float_complex b) {
6982             __pyx_t_float_complex z;
6983             float r, lnr, theta, z_r, z_theta;
6984             if (b.imag == 0 && b.real == (int)b.real) {
6985                 if (b.real < 0) {
6986                     float denom = a.real * a.real + a.imag * a.imag;
6987                     a.real = a.real / denom;
6988                     a.imag = -a.imag / denom;
6989                     b.real = -b.real;
6990                 }
6991                 switch ((int)b.real) {
6992                     case 0:
6993                         z.real = 1;
6994                         z.imag = 0;
6995                         return z;
6996                     case 1:
6997                         return a;
6998                     case 2:
6999                         return __Pyx_c_prod_float(a, a);
7000                     case 3:
7001                         z = __Pyx_c_prod_float(a, a);
7002                         return __Pyx_c_prod_float(z, a);
7003                     case 4:
7004                         z = __Pyx_c_prod_float(a, a);
7005                         return __Pyx_c_prod_float(z, z);
7006                 }
7007             }
7008             if (a.imag == 0) {
7009                 if (a.real == 0) {
7010                     return a;
7011                 } else if (b.imag == 0) {
7012                     z.real = powf(a.real, b.real);
7013                     z.imag = 0;
7014                     return z;
7015                 } else if (a.real > 0) {
7016                     r = a.real;
7017                     theta = 0;
7018                 } else {
7019                     r = -a.real;
7020                     theta = atan2f(0.0, -1.0);
7021                 }
7022             } else {
7023                 r = __Pyx_c_abs_float(a);
7024                 theta = atan2f(a.imag, a.real);
7025             }
7026             lnr = logf(r);
7027             z_r = expf(lnr * b.real - theta * b.imag);
7028             z_theta = theta * b.real + lnr * b.imag;
7029             z.real = z_r * cosf(z_theta);
7030             z.imag = z_r * sinf(z_theta);
7031             return z;
7032         }
7033     #endif
7034 #endif
7035 
7036 /* CIntFromPy */
__Pyx_PyInt_As_int(PyObject * x)7037   static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *x) {
7038 #ifdef __Pyx_HAS_GCC_DIAGNOSTIC
7039 #pragma GCC diagnostic push
7040 #pragma GCC diagnostic ignored "-Wconversion"
7041 #endif
7042     const int neg_one = (int) -1, const_zero = (int) 0;
7043 #ifdef __Pyx_HAS_GCC_DIAGNOSTIC
7044 #pragma GCC diagnostic pop
7045 #endif
7046     const int is_unsigned = neg_one > const_zero;
7047 #if PY_MAJOR_VERSION < 3
7048     if (likely(PyInt_Check(x))) {
7049         if (sizeof(int) < sizeof(long)) {
7050             __PYX_VERIFY_RETURN_INT(int, long, PyInt_AS_LONG(x))
7051         } else {
7052             long val = PyInt_AS_LONG(x);
7053             if (is_unsigned && unlikely(val < 0)) {
7054                 goto raise_neg_overflow;
7055             }
7056             return (int) val;
7057         }
7058     } else
7059 #endif
7060     if (likely(PyLong_Check(x))) {
7061         if (is_unsigned) {
7062 #if CYTHON_USE_PYLONG_INTERNALS
7063             const digit* digits = ((PyLongObject*)x)->ob_digit;
7064             switch (Py_SIZE(x)) {
7065                 case  0: return (int) 0;
7066                 case  1: __PYX_VERIFY_RETURN_INT(int, digit, digits[0])
7067                 case 2:
7068                     if (8 * sizeof(int) > 1 * PyLong_SHIFT) {
7069                         if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
7070                             __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
7071                         } else if (8 * sizeof(int) >= 2 * PyLong_SHIFT) {
7072                             return (int) (((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0]));
7073                         }
7074                     }
7075                     break;
7076                 case 3:
7077                     if (8 * sizeof(int) > 2 * PyLong_SHIFT) {
7078                         if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
7079                             __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
7080                         } else if (8 * sizeof(int) >= 3 * PyLong_SHIFT) {
7081                             return (int) (((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]));
7082                         }
7083                     }
7084                     break;
7085                 case 4:
7086                     if (8 * sizeof(int) > 3 * PyLong_SHIFT) {
7087                         if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
7088                             __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])))
7089                         } else if (8 * sizeof(int) >= 4 * PyLong_SHIFT) {
7090                             return (int) (((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]));
7091                         }
7092                     }
7093                     break;
7094             }
7095 #endif
7096 #if CYTHON_COMPILING_IN_CPYTHON
7097             if (unlikely(Py_SIZE(x) < 0)) {
7098                 goto raise_neg_overflow;
7099             }
7100 #else
7101             {
7102                 int result = PyObject_RichCompareBool(x, Py_False, Py_LT);
7103                 if (unlikely(result < 0))
7104                     return (int) -1;
7105                 if (unlikely(result == 1))
7106                     goto raise_neg_overflow;
7107             }
7108 #endif
7109             if (sizeof(int) <= sizeof(unsigned long)) {
7110                 __PYX_VERIFY_RETURN_INT_EXC(int, unsigned long, PyLong_AsUnsignedLong(x))
7111 #ifdef HAVE_LONG_LONG
7112             } else if (sizeof(int) <= sizeof(unsigned PY_LONG_LONG)) {
7113                 __PYX_VERIFY_RETURN_INT_EXC(int, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x))
7114 #endif
7115             }
7116         } else {
7117 #if CYTHON_USE_PYLONG_INTERNALS
7118             const digit* digits = ((PyLongObject*)x)->ob_digit;
7119             switch (Py_SIZE(x)) {
7120                 case  0: return (int) 0;
7121                 case -1: __PYX_VERIFY_RETURN_INT(int, sdigit, (sdigit) (-(sdigit)digits[0]))
7122                 case  1: __PYX_VERIFY_RETURN_INT(int,  digit, +digits[0])
7123                 case -2:
7124                     if (8 * sizeof(int) - 1 > 1 * PyLong_SHIFT) {
7125                         if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
7126                             __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
7127                         } else if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) {
7128                             return (int) (((int)-1)*(((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
7129                         }
7130                     }
7131                     break;
7132                 case 2:
7133                     if (8 * sizeof(int) > 1 * PyLong_SHIFT) {
7134                         if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
7135                             __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
7136                         } else if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) {
7137                             return (int) ((((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
7138                         }
7139                     }
7140                     break;
7141                 case -3:
7142                     if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) {
7143                         if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
7144                             __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
7145                         } else if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) {
7146                             return (int) (((int)-1)*(((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
7147                         }
7148                     }
7149                     break;
7150                 case 3:
7151                     if (8 * sizeof(int) > 2 * PyLong_SHIFT) {
7152                         if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
7153                             __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
7154                         } else if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) {
7155                             return (int) ((((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
7156                         }
7157                     }
7158                     break;
7159                 case -4:
7160                     if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) {
7161                         if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
7162                             __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])))
7163                         } else if (8 * sizeof(int) - 1 > 4 * PyLong_SHIFT) {
7164                             return (int) (((int)-1)*(((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
7165                         }
7166                     }
7167                     break;
7168                 case 4:
7169                     if (8 * sizeof(int) > 3 * PyLong_SHIFT) {
7170                         if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
7171                             __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])))
7172                         } else if (8 * sizeof(int) - 1 > 4 * PyLong_SHIFT) {
7173                             return (int) ((((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
7174                         }
7175                     }
7176                     break;
7177             }
7178 #endif
7179             if (sizeof(int) <= sizeof(long)) {
7180                 __PYX_VERIFY_RETURN_INT_EXC(int, long, PyLong_AsLong(x))
7181 #ifdef HAVE_LONG_LONG
7182             } else if (sizeof(int) <= sizeof(PY_LONG_LONG)) {
7183                 __PYX_VERIFY_RETURN_INT_EXC(int, PY_LONG_LONG, PyLong_AsLongLong(x))
7184 #endif
7185             }
7186         }
7187         {
7188 #if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray)
7189             PyErr_SetString(PyExc_RuntimeError,
7190                             "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers");
7191 #else
7192             int val;
7193             PyObject *v = __Pyx_PyNumber_IntOrLong(x);
7194  #if PY_MAJOR_VERSION < 3
7195             if (likely(v) && !PyLong_Check(v)) {
7196                 PyObject *tmp = v;
7197                 v = PyNumber_Long(tmp);
7198                 Py_DECREF(tmp);
7199             }
7200  #endif
7201             if (likely(v)) {
7202                 int one = 1; int is_little = (int)*(unsigned char *)&one;
7203                 unsigned char *bytes = (unsigned char *)&val;
7204                 int ret = _PyLong_AsByteArray((PyLongObject *)v,
7205                                               bytes, sizeof(val),
7206                                               is_little, !is_unsigned);
7207                 Py_DECREF(v);
7208                 if (likely(!ret))
7209                     return val;
7210             }
7211 #endif
7212             return (int) -1;
7213         }
7214     } else {
7215         int val;
7216         PyObject *tmp = __Pyx_PyNumber_IntOrLong(x);
7217         if (!tmp) return (int) -1;
7218         val = __Pyx_PyInt_As_int(tmp);
7219         Py_DECREF(tmp);
7220         return val;
7221     }
7222 raise_overflow:
7223     PyErr_SetString(PyExc_OverflowError,
7224         "value too large to convert to int");
7225     return (int) -1;
7226 raise_neg_overflow:
7227     PyErr_SetString(PyExc_OverflowError,
7228         "can't convert negative value to int");
7229     return (int) -1;
7230 }
7231 
7232 /* CIntToPy */
__Pyx_PyInt_From_int(int value)7233   static CYTHON_INLINE PyObject* __Pyx_PyInt_From_int(int value) {
7234 #ifdef __Pyx_HAS_GCC_DIAGNOSTIC
7235 #pragma GCC diagnostic push
7236 #pragma GCC diagnostic ignored "-Wconversion"
7237 #endif
7238     const int neg_one = (int) -1, const_zero = (int) 0;
7239 #ifdef __Pyx_HAS_GCC_DIAGNOSTIC
7240 #pragma GCC diagnostic pop
7241 #endif
7242     const int is_unsigned = neg_one > const_zero;
7243     if (is_unsigned) {
7244         if (sizeof(int) < sizeof(long)) {
7245             return PyInt_FromLong((long) value);
7246         } else if (sizeof(int) <= sizeof(unsigned long)) {
7247             return PyLong_FromUnsignedLong((unsigned long) value);
7248 #ifdef HAVE_LONG_LONG
7249         } else if (sizeof(int) <= sizeof(unsigned PY_LONG_LONG)) {
7250             return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value);
7251 #endif
7252         }
7253     } else {
7254         if (sizeof(int) <= sizeof(long)) {
7255             return PyInt_FromLong((long) value);
7256 #ifdef HAVE_LONG_LONG
7257         } else if (sizeof(int) <= sizeof(PY_LONG_LONG)) {
7258             return PyLong_FromLongLong((PY_LONG_LONG) value);
7259 #endif
7260         }
7261     }
7262     {
7263         int one = 1; int little = (int)*(unsigned char *)&one;
7264         unsigned char *bytes = (unsigned char *)&value;
7265         return _PyLong_FromByteArray(bytes, sizeof(int),
7266                                      little, !is_unsigned);
7267     }
7268 }
7269 
7270 /* CIntToPy */
__Pyx_PyInt_From_long(long value)7271   static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value) {
7272 #ifdef __Pyx_HAS_GCC_DIAGNOSTIC
7273 #pragma GCC diagnostic push
7274 #pragma GCC diagnostic ignored "-Wconversion"
7275 #endif
7276     const long neg_one = (long) -1, const_zero = (long) 0;
7277 #ifdef __Pyx_HAS_GCC_DIAGNOSTIC
7278 #pragma GCC diagnostic pop
7279 #endif
7280     const int is_unsigned = neg_one > const_zero;
7281     if (is_unsigned) {
7282         if (sizeof(long) < sizeof(long)) {
7283             return PyInt_FromLong((long) value);
7284         } else if (sizeof(long) <= sizeof(unsigned long)) {
7285             return PyLong_FromUnsignedLong((unsigned long) value);
7286 #ifdef HAVE_LONG_LONG
7287         } else if (sizeof(long) <= sizeof(unsigned PY_LONG_LONG)) {
7288             return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value);
7289 #endif
7290         }
7291     } else {
7292         if (sizeof(long) <= sizeof(long)) {
7293             return PyInt_FromLong((long) value);
7294 #ifdef HAVE_LONG_LONG
7295         } else if (sizeof(long) <= sizeof(PY_LONG_LONG)) {
7296             return PyLong_FromLongLong((PY_LONG_LONG) value);
7297 #endif
7298         }
7299     }
7300     {
7301         int one = 1; int little = (int)*(unsigned char *)&one;
7302         unsigned char *bytes = (unsigned char *)&value;
7303         return _PyLong_FromByteArray(bytes, sizeof(long),
7304                                      little, !is_unsigned);
7305     }
7306 }
7307 
7308 /* CIntFromPy */
__Pyx_PyInt_As_long(PyObject * x)7309   static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *x) {
7310 #ifdef __Pyx_HAS_GCC_DIAGNOSTIC
7311 #pragma GCC diagnostic push
7312 #pragma GCC diagnostic ignored "-Wconversion"
7313 #endif
7314     const long neg_one = (long) -1, const_zero = (long) 0;
7315 #ifdef __Pyx_HAS_GCC_DIAGNOSTIC
7316 #pragma GCC diagnostic pop
7317 #endif
7318     const int is_unsigned = neg_one > const_zero;
7319 #if PY_MAJOR_VERSION < 3
7320     if (likely(PyInt_Check(x))) {
7321         if (sizeof(long) < sizeof(long)) {
7322             __PYX_VERIFY_RETURN_INT(long, long, PyInt_AS_LONG(x))
7323         } else {
7324             long val = PyInt_AS_LONG(x);
7325             if (is_unsigned && unlikely(val < 0)) {
7326                 goto raise_neg_overflow;
7327             }
7328             return (long) val;
7329         }
7330     } else
7331 #endif
7332     if (likely(PyLong_Check(x))) {
7333         if (is_unsigned) {
7334 #if CYTHON_USE_PYLONG_INTERNALS
7335             const digit* digits = ((PyLongObject*)x)->ob_digit;
7336             switch (Py_SIZE(x)) {
7337                 case  0: return (long) 0;
7338                 case  1: __PYX_VERIFY_RETURN_INT(long, digit, digits[0])
7339                 case 2:
7340                     if (8 * sizeof(long) > 1 * PyLong_SHIFT) {
7341                         if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
7342                             __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
7343                         } else if (8 * sizeof(long) >= 2 * PyLong_SHIFT) {
7344                             return (long) (((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0]));
7345                         }
7346                     }
7347                     break;
7348                 case 3:
7349                     if (8 * sizeof(long) > 2 * PyLong_SHIFT) {
7350                         if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
7351                             __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
7352                         } else if (8 * sizeof(long) >= 3 * PyLong_SHIFT) {
7353                             return (long) (((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]));
7354                         }
7355                     }
7356                     break;
7357                 case 4:
7358                     if (8 * sizeof(long) > 3 * PyLong_SHIFT) {
7359                         if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
7360                             __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])))
7361                         } else if (8 * sizeof(long) >= 4 * PyLong_SHIFT) {
7362                             return (long) (((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]));
7363                         }
7364                     }
7365                     break;
7366             }
7367 #endif
7368 #if CYTHON_COMPILING_IN_CPYTHON
7369             if (unlikely(Py_SIZE(x) < 0)) {
7370                 goto raise_neg_overflow;
7371             }
7372 #else
7373             {
7374                 int result = PyObject_RichCompareBool(x, Py_False, Py_LT);
7375                 if (unlikely(result < 0))
7376                     return (long) -1;
7377                 if (unlikely(result == 1))
7378                     goto raise_neg_overflow;
7379             }
7380 #endif
7381             if (sizeof(long) <= sizeof(unsigned long)) {
7382                 __PYX_VERIFY_RETURN_INT_EXC(long, unsigned long, PyLong_AsUnsignedLong(x))
7383 #ifdef HAVE_LONG_LONG
7384             } else if (sizeof(long) <= sizeof(unsigned PY_LONG_LONG)) {
7385                 __PYX_VERIFY_RETURN_INT_EXC(long, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x))
7386 #endif
7387             }
7388         } else {
7389 #if CYTHON_USE_PYLONG_INTERNALS
7390             const digit* digits = ((PyLongObject*)x)->ob_digit;
7391             switch (Py_SIZE(x)) {
7392                 case  0: return (long) 0;
7393                 case -1: __PYX_VERIFY_RETURN_INT(long, sdigit, (sdigit) (-(sdigit)digits[0]))
7394                 case  1: __PYX_VERIFY_RETURN_INT(long,  digit, +digits[0])
7395                 case -2:
7396                     if (8 * sizeof(long) - 1 > 1 * PyLong_SHIFT) {
7397                         if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
7398                             __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
7399                         } else if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
7400                             return (long) (((long)-1)*(((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
7401                         }
7402                     }
7403                     break;
7404                 case 2:
7405                     if (8 * sizeof(long) > 1 * PyLong_SHIFT) {
7406                         if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
7407                             __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
7408                         } else if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
7409                             return (long) ((((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
7410                         }
7411                     }
7412                     break;
7413                 case -3:
7414                     if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
7415                         if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
7416                             __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
7417                         } else if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
7418                             return (long) (((long)-1)*(((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
7419                         }
7420                     }
7421                     break;
7422                 case 3:
7423                     if (8 * sizeof(long) > 2 * PyLong_SHIFT) {
7424                         if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
7425                             __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
7426                         } else if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
7427                             return (long) ((((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
7428                         }
7429                     }
7430                     break;
7431                 case -4:
7432                     if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
7433                         if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
7434                             __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])))
7435                         } else if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) {
7436                             return (long) (((long)-1)*(((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
7437                         }
7438                     }
7439                     break;
7440                 case 4:
7441                     if (8 * sizeof(long) > 3 * PyLong_SHIFT) {
7442                         if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
7443                             __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])))
7444                         } else if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) {
7445                             return (long) ((((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
7446                         }
7447                     }
7448                     break;
7449             }
7450 #endif
7451             if (sizeof(long) <= sizeof(long)) {
7452                 __PYX_VERIFY_RETURN_INT_EXC(long, long, PyLong_AsLong(x))
7453 #ifdef HAVE_LONG_LONG
7454             } else if (sizeof(long) <= sizeof(PY_LONG_LONG)) {
7455                 __PYX_VERIFY_RETURN_INT_EXC(long, PY_LONG_LONG, PyLong_AsLongLong(x))
7456 #endif
7457             }
7458         }
7459         {
7460 #if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray)
7461             PyErr_SetString(PyExc_RuntimeError,
7462                             "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers");
7463 #else
7464             long val;
7465             PyObject *v = __Pyx_PyNumber_IntOrLong(x);
7466  #if PY_MAJOR_VERSION < 3
7467             if (likely(v) && !PyLong_Check(v)) {
7468                 PyObject *tmp = v;
7469                 v = PyNumber_Long(tmp);
7470                 Py_DECREF(tmp);
7471             }
7472  #endif
7473             if (likely(v)) {
7474                 int one = 1; int is_little = (int)*(unsigned char *)&one;
7475                 unsigned char *bytes = (unsigned char *)&val;
7476                 int ret = _PyLong_AsByteArray((PyLongObject *)v,
7477                                               bytes, sizeof(val),
7478                                               is_little, !is_unsigned);
7479                 Py_DECREF(v);
7480                 if (likely(!ret))
7481                     return val;
7482             }
7483 #endif
7484             return (long) -1;
7485         }
7486     } else {
7487         long val;
7488         PyObject *tmp = __Pyx_PyNumber_IntOrLong(x);
7489         if (!tmp) return (long) -1;
7490         val = __Pyx_PyInt_As_long(tmp);
7491         Py_DECREF(tmp);
7492         return val;
7493     }
7494 raise_overflow:
7495     PyErr_SetString(PyExc_OverflowError,
7496         "value too large to convert to long");
7497     return (long) -1;
7498 raise_neg_overflow:
7499     PyErr_SetString(PyExc_OverflowError,
7500         "can't convert negative value to long");
7501     return (long) -1;
7502 }
7503 
7504 /* FastTypeChecks */
7505   #if CYTHON_COMPILING_IN_CPYTHON
__Pyx_InBases(PyTypeObject * a,PyTypeObject * b)7506 static int __Pyx_InBases(PyTypeObject *a, PyTypeObject *b) {
7507     while (a) {
7508         a = a->tp_base;
7509         if (a == b)
7510             return 1;
7511     }
7512     return b == &PyBaseObject_Type;
7513 }
__Pyx_IsSubtype(PyTypeObject * a,PyTypeObject * b)7514 static CYTHON_INLINE int __Pyx_IsSubtype(PyTypeObject *a, PyTypeObject *b) {
7515     PyObject *mro;
7516     if (a == b) return 1;
7517     mro = a->tp_mro;
7518     if (likely(mro)) {
7519         Py_ssize_t i, n;
7520         n = PyTuple_GET_SIZE(mro);
7521         for (i = 0; i < n; i++) {
7522             if (PyTuple_GET_ITEM(mro, i) == (PyObject *)b)
7523                 return 1;
7524         }
7525         return 0;
7526     }
7527     return __Pyx_InBases(a, b);
7528 }
7529 #if PY_MAJOR_VERSION == 2
__Pyx_inner_PyErr_GivenExceptionMatches2(PyObject * err,PyObject * exc_type1,PyObject * exc_type2)7530 static int __Pyx_inner_PyErr_GivenExceptionMatches2(PyObject *err, PyObject* exc_type1, PyObject* exc_type2) {
7531     PyObject *exception, *value, *tb;
7532     int res;
7533     __Pyx_PyThreadState_declare
7534     __Pyx_PyThreadState_assign
7535     __Pyx_ErrFetch(&exception, &value, &tb);
7536     res = exc_type1 ? PyObject_IsSubclass(err, exc_type1) : 0;
7537     if (unlikely(res == -1)) {
7538         PyErr_WriteUnraisable(err);
7539         res = 0;
7540     }
7541     if (!res) {
7542         res = PyObject_IsSubclass(err, exc_type2);
7543         if (unlikely(res == -1)) {
7544             PyErr_WriteUnraisable(err);
7545             res = 0;
7546         }
7547     }
7548     __Pyx_ErrRestore(exception, value, tb);
7549     return res;
7550 }
7551 #else
__Pyx_inner_PyErr_GivenExceptionMatches2(PyObject * err,PyObject * exc_type1,PyObject * exc_type2)7552 static CYTHON_INLINE int __Pyx_inner_PyErr_GivenExceptionMatches2(PyObject *err, PyObject* exc_type1, PyObject *exc_type2) {
7553     int res = exc_type1 ? __Pyx_IsSubtype((PyTypeObject*)err, (PyTypeObject*)exc_type1) : 0;
7554     if (!res) {
7555         res = __Pyx_IsSubtype((PyTypeObject*)err, (PyTypeObject*)exc_type2);
7556     }
7557     return res;
7558 }
7559 #endif
__Pyx_PyErr_GivenExceptionMatchesTuple(PyObject * exc_type,PyObject * tuple)7560 static int __Pyx_PyErr_GivenExceptionMatchesTuple(PyObject *exc_type, PyObject *tuple) {
7561     Py_ssize_t i, n;
7562     assert(PyExceptionClass_Check(exc_type));
7563     n = PyTuple_GET_SIZE(tuple);
7564 #if PY_MAJOR_VERSION >= 3
7565     for (i=0; i<n; i++) {
7566         if (exc_type == PyTuple_GET_ITEM(tuple, i)) return 1;
7567     }
7568 #endif
7569     for (i=0; i<n; i++) {
7570         PyObject *t = PyTuple_GET_ITEM(tuple, i);
7571         #if PY_MAJOR_VERSION < 3
7572         if (likely(exc_type == t)) return 1;
7573         #endif
7574         if (likely(PyExceptionClass_Check(t))) {
7575             if (__Pyx_inner_PyErr_GivenExceptionMatches2(exc_type, NULL, t)) return 1;
7576         } else {
7577         }
7578     }
7579     return 0;
7580 }
__Pyx_PyErr_GivenExceptionMatches(PyObject * err,PyObject * exc_type)7581 static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches(PyObject *err, PyObject* exc_type) {
7582     if (likely(err == exc_type)) return 1;
7583     if (likely(PyExceptionClass_Check(err))) {
7584         if (likely(PyExceptionClass_Check(exc_type))) {
7585             return __Pyx_inner_PyErr_GivenExceptionMatches2(err, NULL, exc_type);
7586         } else if (likely(PyTuple_Check(exc_type))) {
7587             return __Pyx_PyErr_GivenExceptionMatchesTuple(err, exc_type);
7588         } else {
7589         }
7590     }
7591     return PyErr_GivenExceptionMatches(err, exc_type);
7592 }
__Pyx_PyErr_GivenExceptionMatches2(PyObject * err,PyObject * exc_type1,PyObject * exc_type2)7593 static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches2(PyObject *err, PyObject *exc_type1, PyObject *exc_type2) {
7594     assert(PyExceptionClass_Check(exc_type1));
7595     assert(PyExceptionClass_Check(exc_type2));
7596     if (likely(err == exc_type1 || err == exc_type2)) return 1;
7597     if (likely(PyExceptionClass_Check(err))) {
7598         return __Pyx_inner_PyErr_GivenExceptionMatches2(err, exc_type1, exc_type2);
7599     }
7600     return (PyErr_GivenExceptionMatches(err, exc_type1) || PyErr_GivenExceptionMatches(err, exc_type2));
7601 }
7602 #endif
7603 
7604 /* CheckBinaryVersion */
__Pyx_check_binary_version(void)7605   static int __Pyx_check_binary_version(void) {
7606     char ctversion[4], rtversion[4];
7607     PyOS_snprintf(ctversion, 4, "%d.%d", PY_MAJOR_VERSION, PY_MINOR_VERSION);
7608     PyOS_snprintf(rtversion, 4, "%s", Py_GetVersion());
7609     if (ctversion[0] != rtversion[0] || ctversion[2] != rtversion[2]) {
7610         char message[200];
7611         PyOS_snprintf(message, sizeof(message),
7612                       "compiletime version %s of module '%.100s' "
7613                       "does not match runtime version %s",
7614                       ctversion, __Pyx_MODULE_NAME, rtversion);
7615         return PyErr_WarnEx(NULL, message, 1);
7616     }
7617     return 0;
7618 }
7619 
7620 /* InitStrings */
__Pyx_InitStrings(__Pyx_StringTabEntry * t)7621   static int __Pyx_InitStrings(__Pyx_StringTabEntry *t) {
7622     while (t->p) {
7623         #if PY_MAJOR_VERSION < 3
7624         if (t->is_unicode) {
7625             *t->p = PyUnicode_DecodeUTF8(t->s, t->n - 1, NULL);
7626         } else if (t->intern) {
7627             *t->p = PyString_InternFromString(t->s);
7628         } else {
7629             *t->p = PyString_FromStringAndSize(t->s, t->n - 1);
7630         }
7631         #else
7632         if (t->is_unicode | t->is_str) {
7633             if (t->intern) {
7634                 *t->p = PyUnicode_InternFromString(t->s);
7635             } else if (t->encoding) {
7636                 *t->p = PyUnicode_Decode(t->s, t->n - 1, t->encoding, NULL);
7637             } else {
7638                 *t->p = PyUnicode_FromStringAndSize(t->s, t->n - 1);
7639             }
7640         } else {
7641             *t->p = PyBytes_FromStringAndSize(t->s, t->n - 1);
7642         }
7643         #endif
7644         if (!*t->p)
7645             return -1;
7646         if (PyObject_Hash(*t->p) == -1)
7647             return -1;
7648         ++t;
7649     }
7650     return 0;
7651 }
7652 
__Pyx_PyUnicode_FromString(const char * c_str)7653 static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(const char* c_str) {
7654     return __Pyx_PyUnicode_FromStringAndSize(c_str, (Py_ssize_t)strlen(c_str));
7655 }
__Pyx_PyObject_AsString(PyObject * o)7656 static CYTHON_INLINE const char* __Pyx_PyObject_AsString(PyObject* o) {
7657     Py_ssize_t ignore;
7658     return __Pyx_PyObject_AsStringAndSize(o, &ignore);
7659 }
7660 #if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT
7661 #if !CYTHON_PEP393_ENABLED
__Pyx_PyUnicode_AsStringAndSize(PyObject * o,Py_ssize_t * length)7662 static const char* __Pyx_PyUnicode_AsStringAndSize(PyObject* o, Py_ssize_t *length) {
7663     char* defenc_c;
7664     PyObject* defenc = _PyUnicode_AsDefaultEncodedString(o, NULL);
7665     if (!defenc) return NULL;
7666     defenc_c = PyBytes_AS_STRING(defenc);
7667 #if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
7668     {
7669         char* end = defenc_c + PyBytes_GET_SIZE(defenc);
7670         char* c;
7671         for (c = defenc_c; c < end; c++) {
7672             if ((unsigned char) (*c) >= 128) {
7673                 PyUnicode_AsASCIIString(o);
7674                 return NULL;
7675             }
7676         }
7677     }
7678 #endif
7679     *length = PyBytes_GET_SIZE(defenc);
7680     return defenc_c;
7681 }
7682 #else
__Pyx_PyUnicode_AsStringAndSize(PyObject * o,Py_ssize_t * length)7683 static CYTHON_INLINE const char* __Pyx_PyUnicode_AsStringAndSize(PyObject* o, Py_ssize_t *length) {
7684     if (unlikely(__Pyx_PyUnicode_READY(o) == -1)) return NULL;
7685 #if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
7686     if (likely(PyUnicode_IS_ASCII(o))) {
7687         *length = PyUnicode_GET_LENGTH(o);
7688         return PyUnicode_AsUTF8(o);
7689     } else {
7690         PyUnicode_AsASCIIString(o);
7691         return NULL;
7692     }
7693 #else
7694     return PyUnicode_AsUTF8AndSize(o, length);
7695 #endif
7696 }
7697 #endif
7698 #endif
__Pyx_PyObject_AsStringAndSize(PyObject * o,Py_ssize_t * length)7699 static CYTHON_INLINE const char* __Pyx_PyObject_AsStringAndSize(PyObject* o, Py_ssize_t *length) {
7700 #if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT
7701     if (
7702 #if PY_MAJOR_VERSION < 3 && __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
7703             __Pyx_sys_getdefaultencoding_not_ascii &&
7704 #endif
7705             PyUnicode_Check(o)) {
7706         return __Pyx_PyUnicode_AsStringAndSize(o, length);
7707     } else
7708 #endif
7709 #if (!CYTHON_COMPILING_IN_PYPY) || (defined(PyByteArray_AS_STRING) && defined(PyByteArray_GET_SIZE))
7710     if (PyByteArray_Check(o)) {
7711         *length = PyByteArray_GET_SIZE(o);
7712         return PyByteArray_AS_STRING(o);
7713     } else
7714 #endif
7715     {
7716         char* result;
7717         int r = PyBytes_AsStringAndSize(o, &result, length);
7718         if (unlikely(r < 0)) {
7719             return NULL;
7720         } else {
7721             return result;
7722         }
7723     }
7724 }
__Pyx_PyObject_IsTrue(PyObject * x)7725 static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject* x) {
7726    int is_true = x == Py_True;
7727    if (is_true | (x == Py_False) | (x == Py_None)) return is_true;
7728    else return PyObject_IsTrue(x);
7729 }
__Pyx_PyObject_IsTrueAndDecref(PyObject * x)7730 static CYTHON_INLINE int __Pyx_PyObject_IsTrueAndDecref(PyObject* x) {
7731     int retval;
7732     if (unlikely(!x)) return -1;
7733     retval = __Pyx_PyObject_IsTrue(x);
7734     Py_DECREF(x);
7735     return retval;
7736 }
__Pyx_PyNumber_IntOrLongWrongResultType(PyObject * result,const char * type_name)7737 static PyObject* __Pyx_PyNumber_IntOrLongWrongResultType(PyObject* result, const char* type_name) {
7738 #if PY_MAJOR_VERSION >= 3
7739     if (PyLong_Check(result)) {
7740         if (PyErr_WarnFormat(PyExc_DeprecationWarning, 1,
7741                 "__int__ returned non-int (type %.200s).  "
7742                 "The ability to return an instance of a strict subclass of int "
7743                 "is deprecated, and may be removed in a future version of Python.",
7744                 Py_TYPE(result)->tp_name)) {
7745             Py_DECREF(result);
7746             return NULL;
7747         }
7748         return result;
7749     }
7750 #endif
7751     PyErr_Format(PyExc_TypeError,
7752                  "__%.4s__ returned non-%.4s (type %.200s)",
7753                  type_name, type_name, Py_TYPE(result)->tp_name);
7754     Py_DECREF(result);
7755     return NULL;
7756 }
__Pyx_PyNumber_IntOrLong(PyObject * x)7757 static CYTHON_INLINE PyObject* __Pyx_PyNumber_IntOrLong(PyObject* x) {
7758 #if CYTHON_USE_TYPE_SLOTS
7759   PyNumberMethods *m;
7760 #endif
7761   const char *name = NULL;
7762   PyObject *res = NULL;
7763 #if PY_MAJOR_VERSION < 3
7764   if (likely(PyInt_Check(x) || PyLong_Check(x)))
7765 #else
7766   if (likely(PyLong_Check(x)))
7767 #endif
7768     return __Pyx_NewRef(x);
7769 #if CYTHON_USE_TYPE_SLOTS
7770   m = Py_TYPE(x)->tp_as_number;
7771   #if PY_MAJOR_VERSION < 3
7772   if (m && m->nb_int) {
7773     name = "int";
7774     res = m->nb_int(x);
7775   }
7776   else if (m && m->nb_long) {
7777     name = "long";
7778     res = m->nb_long(x);
7779   }
7780   #else
7781   if (likely(m && m->nb_int)) {
7782     name = "int";
7783     res = m->nb_int(x);
7784   }
7785   #endif
7786 #else
7787   if (!PyBytes_CheckExact(x) && !PyUnicode_CheckExact(x)) {
7788     res = PyNumber_Int(x);
7789   }
7790 #endif
7791   if (likely(res)) {
7792 #if PY_MAJOR_VERSION < 3
7793     if (unlikely(!PyInt_Check(res) && !PyLong_Check(res))) {
7794 #else
7795     if (unlikely(!PyLong_CheckExact(res))) {
7796 #endif
7797         return __Pyx_PyNumber_IntOrLongWrongResultType(res, name);
7798     }
7799   }
7800   else if (!PyErr_Occurred()) {
7801     PyErr_SetString(PyExc_TypeError,
7802                     "an integer is required");
7803   }
7804   return res;
7805 }
7806 static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject* b) {
7807   Py_ssize_t ival;
7808   PyObject *x;
7809 #if PY_MAJOR_VERSION < 3
7810   if (likely(PyInt_CheckExact(b))) {
7811     if (sizeof(Py_ssize_t) >= sizeof(long))
7812         return PyInt_AS_LONG(b);
7813     else
7814         return PyInt_AsSsize_t(b);
7815   }
7816 #endif
7817   if (likely(PyLong_CheckExact(b))) {
7818     #if CYTHON_USE_PYLONG_INTERNALS
7819     const digit* digits = ((PyLongObject*)b)->ob_digit;
7820     const Py_ssize_t size = Py_SIZE(b);
7821     if (likely(__Pyx_sst_abs(size) <= 1)) {
7822         ival = likely(size) ? digits[0] : 0;
7823         if (size == -1) ival = -ival;
7824         return ival;
7825     } else {
7826       switch (size) {
7827          case 2:
7828            if (8 * sizeof(Py_ssize_t) > 2 * PyLong_SHIFT) {
7829              return (Py_ssize_t) (((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
7830            }
7831            break;
7832          case -2:
7833            if (8 * sizeof(Py_ssize_t) > 2 * PyLong_SHIFT) {
7834              return -(Py_ssize_t) (((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
7835            }
7836            break;
7837          case 3:
7838            if (8 * sizeof(Py_ssize_t) > 3 * PyLong_SHIFT) {
7839              return (Py_ssize_t) (((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
7840            }
7841            break;
7842          case -3:
7843            if (8 * sizeof(Py_ssize_t) > 3 * PyLong_SHIFT) {
7844              return -(Py_ssize_t) (((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
7845            }
7846            break;
7847          case 4:
7848            if (8 * sizeof(Py_ssize_t) > 4 * PyLong_SHIFT) {
7849              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]));
7850            }
7851            break;
7852          case -4:
7853            if (8 * sizeof(Py_ssize_t) > 4 * PyLong_SHIFT) {
7854              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]));
7855            }
7856            break;
7857       }
7858     }
7859     #endif
7860     return PyLong_AsSsize_t(b);
7861   }
7862   x = PyNumber_Index(b);
7863   if (!x) return -1;
7864   ival = PyInt_AsSsize_t(x);
7865   Py_DECREF(x);
7866   return ival;
7867 }
7868 static CYTHON_INLINE PyObject * __Pyx_PyBool_FromLong(long b) {
7869   return b ? __Pyx_NewRef(Py_True) : __Pyx_NewRef(Py_False);
7870 }
7871 static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t ival) {
7872     return PyInt_FromSize_t(ival);
7873 }
7874 
7875 
7876 #endif /* Py_PYTHON_H */
7877