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.cy.brtools",
20         "sources": [
21             "qutip/cy/brtools.pyx"
22         ]
23     },
24     "module_name": "qutip.cy.brtools"
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__cy__brtools
647 #define __PYX_HAVE_API__qutip__cy__brtools
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 #include <float.h>
658 #include "ios"
659 #include "new"
660 #include "stdexcept"
661 #include "typeinfo"
662 #include <vector>
663 #include <algorithm>
664 #include <complex>
665 #include "pythread.h"
666 #include <stdlib.h>
667 #include "pystate.h"
668 #ifdef _OPENMP
669 #include <omp.h>
670 #endif /* _OPENMP */
671 
672 #if defined(PYREX_WITHOUT_ASSERTIONS) && !defined(CYTHON_WITHOUT_ASSERTIONS)
673 #define CYTHON_WITHOUT_ASSERTIONS
674 #endif
675 
676 typedef struct {PyObject **p; const char *s; const Py_ssize_t n; const char* encoding;
677                 const char is_unicode; const char is_str; const char intern; } __Pyx_StringTabEntry;
678 
679 #define __PYX_DEFAULT_STRING_ENCODING_IS_ASCII 0
680 #define __PYX_DEFAULT_STRING_ENCODING_IS_UTF8 0
681 #define __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT (PY_MAJOR_VERSION >= 3 && __PYX_DEFAULT_STRING_ENCODING_IS_UTF8)
682 #define __PYX_DEFAULT_STRING_ENCODING ""
683 #define __Pyx_PyObject_FromString __Pyx_PyBytes_FromString
684 #define __Pyx_PyObject_FromStringAndSize __Pyx_PyBytes_FromStringAndSize
685 #define __Pyx_uchar_cast(c) ((unsigned char)c)
686 #define __Pyx_long_cast(x) ((long)x)
687 #define __Pyx_fits_Py_ssize_t(v, type, is_signed)  (\
688     (sizeof(type) < sizeof(Py_ssize_t))  ||\
689     (sizeof(type) > sizeof(Py_ssize_t) &&\
690           likely(v < (type)PY_SSIZE_T_MAX ||\
691                  v == (type)PY_SSIZE_T_MAX)  &&\
692           (!is_signed || likely(v > (type)PY_SSIZE_T_MIN ||\
693                                 v == (type)PY_SSIZE_T_MIN)))  ||\
694     (sizeof(type) == sizeof(Py_ssize_t) &&\
695           (is_signed || likely(v < (type)PY_SSIZE_T_MAX ||\
696                                v == (type)PY_SSIZE_T_MAX)))  )
__Pyx_is_valid_index(Py_ssize_t i,Py_ssize_t limit)697 static CYTHON_INLINE int __Pyx_is_valid_index(Py_ssize_t i, Py_ssize_t limit) {
698     return (size_t) i < (size_t) limit;
699 }
700 #if defined (__cplusplus) && __cplusplus >= 201103L
701     #include <cstdlib>
702     #define __Pyx_sst_abs(value) std::abs(value)
703 #elif SIZEOF_INT >= SIZEOF_SIZE_T
704     #define __Pyx_sst_abs(value) abs(value)
705 #elif SIZEOF_LONG >= SIZEOF_SIZE_T
706     #define __Pyx_sst_abs(value) labs(value)
707 #elif defined (_MSC_VER)
708     #define __Pyx_sst_abs(value) ((Py_ssize_t)_abs64(value))
709 #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
710     #define __Pyx_sst_abs(value) llabs(value)
711 #elif defined (__GNUC__)
712     #define __Pyx_sst_abs(value) __builtin_llabs(value)
713 #else
714     #define __Pyx_sst_abs(value) ((value<0) ? -value : value)
715 #endif
716 static CYTHON_INLINE const char* __Pyx_PyObject_AsString(PyObject*);
717 static CYTHON_INLINE const char* __Pyx_PyObject_AsStringAndSize(PyObject*, Py_ssize_t* length);
718 #define __Pyx_PyByteArray_FromString(s) PyByteArray_FromStringAndSize((const char*)s, strlen((const char*)s))
719 #define __Pyx_PyByteArray_FromStringAndSize(s, l) PyByteArray_FromStringAndSize((const char*)s, l)
720 #define __Pyx_PyBytes_FromString        PyBytes_FromString
721 #define __Pyx_PyBytes_FromStringAndSize PyBytes_FromStringAndSize
722 static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(const char*);
723 #if PY_MAJOR_VERSION < 3
724     #define __Pyx_PyStr_FromString        __Pyx_PyBytes_FromString
725     #define __Pyx_PyStr_FromStringAndSize __Pyx_PyBytes_FromStringAndSize
726 #else
727     #define __Pyx_PyStr_FromString        __Pyx_PyUnicode_FromString
728     #define __Pyx_PyStr_FromStringAndSize __Pyx_PyUnicode_FromStringAndSize
729 #endif
730 #define __Pyx_PyBytes_AsWritableString(s)     ((char*) PyBytes_AS_STRING(s))
731 #define __Pyx_PyBytes_AsWritableSString(s)    ((signed char*) PyBytes_AS_STRING(s))
732 #define __Pyx_PyBytes_AsWritableUString(s)    ((unsigned char*) PyBytes_AS_STRING(s))
733 #define __Pyx_PyBytes_AsString(s)     ((const char*) PyBytes_AS_STRING(s))
734 #define __Pyx_PyBytes_AsSString(s)    ((const signed char*) PyBytes_AS_STRING(s))
735 #define __Pyx_PyBytes_AsUString(s)    ((const unsigned char*) PyBytes_AS_STRING(s))
736 #define __Pyx_PyObject_AsWritableString(s)    ((char*) __Pyx_PyObject_AsString(s))
737 #define __Pyx_PyObject_AsWritableSString(s)    ((signed char*) __Pyx_PyObject_AsString(s))
738 #define __Pyx_PyObject_AsWritableUString(s)    ((unsigned char*) __Pyx_PyObject_AsString(s))
739 #define __Pyx_PyObject_AsSString(s)    ((const signed char*) __Pyx_PyObject_AsString(s))
740 #define __Pyx_PyObject_AsUString(s)    ((const unsigned char*) __Pyx_PyObject_AsString(s))
741 #define __Pyx_PyObject_FromCString(s)  __Pyx_PyObject_FromString((const char*)s)
742 #define __Pyx_PyBytes_FromCString(s)   __Pyx_PyBytes_FromString((const char*)s)
743 #define __Pyx_PyByteArray_FromCString(s)   __Pyx_PyByteArray_FromString((const char*)s)
744 #define __Pyx_PyStr_FromCString(s)     __Pyx_PyStr_FromString((const char*)s)
745 #define __Pyx_PyUnicode_FromCString(s) __Pyx_PyUnicode_FromString((const char*)s)
__Pyx_Py_UNICODE_strlen(const Py_UNICODE * u)746 static CYTHON_INLINE size_t __Pyx_Py_UNICODE_strlen(const Py_UNICODE *u) {
747     const Py_UNICODE *u_end = u;
748     while (*u_end++) ;
749     return (size_t)(u_end - u - 1);
750 }
751 #define __Pyx_PyUnicode_FromUnicode(u)       PyUnicode_FromUnicode(u, __Pyx_Py_UNICODE_strlen(u))
752 #define __Pyx_PyUnicode_FromUnicodeAndLength PyUnicode_FromUnicode
753 #define __Pyx_PyUnicode_AsUnicode            PyUnicode_AsUnicode
754 #define __Pyx_NewRef(obj) (Py_INCREF(obj), obj)
755 #define __Pyx_Owned_Py_None(b) __Pyx_NewRef(Py_None)
756 static CYTHON_INLINE PyObject * __Pyx_PyBool_FromLong(long b);
757 static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject*);
758 static CYTHON_INLINE int __Pyx_PyObject_IsTrueAndDecref(PyObject*);
759 static CYTHON_INLINE PyObject* __Pyx_PyNumber_IntOrLong(PyObject* x);
760 #define __Pyx_PySequence_Tuple(obj)\
761     (likely(PyTuple_CheckExact(obj)) ? __Pyx_NewRef(obj) : PySequence_Tuple(obj))
762 static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject*);
763 static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t);
764 #if CYTHON_ASSUME_SAFE_MACROS
765 #define __pyx_PyFloat_AsDouble(x) (PyFloat_CheckExact(x) ? PyFloat_AS_DOUBLE(x) : PyFloat_AsDouble(x))
766 #else
767 #define __pyx_PyFloat_AsDouble(x) PyFloat_AsDouble(x)
768 #endif
769 #define __pyx_PyFloat_AsFloat(x) ((float) __pyx_PyFloat_AsDouble(x))
770 #if PY_MAJOR_VERSION >= 3
771 #define __Pyx_PyNumber_Int(x) (PyLong_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Long(x))
772 #else
773 #define __Pyx_PyNumber_Int(x) (PyInt_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Int(x))
774 #endif
775 #define __Pyx_PyNumber_Float(x) (PyFloat_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Float(x))
776 #if PY_MAJOR_VERSION < 3 && __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
777 static int __Pyx_sys_getdefaultencoding_not_ascii;
__Pyx_init_sys_getdefaultencoding_params(void)778 static int __Pyx_init_sys_getdefaultencoding_params(void) {
779     PyObject* sys;
780     PyObject* default_encoding = NULL;
781     PyObject* ascii_chars_u = NULL;
782     PyObject* ascii_chars_b = NULL;
783     const char* default_encoding_c;
784     sys = PyImport_ImportModule("sys");
785     if (!sys) goto bad;
786     default_encoding = PyObject_CallMethod(sys, (char*) "getdefaultencoding", NULL);
787     Py_DECREF(sys);
788     if (!default_encoding) goto bad;
789     default_encoding_c = PyBytes_AsString(default_encoding);
790     if (!default_encoding_c) goto bad;
791     if (strcmp(default_encoding_c, "ascii") == 0) {
792         __Pyx_sys_getdefaultencoding_not_ascii = 0;
793     } else {
794         char ascii_chars[128];
795         int c;
796         for (c = 0; c < 128; c++) {
797             ascii_chars[c] = c;
798         }
799         __Pyx_sys_getdefaultencoding_not_ascii = 1;
800         ascii_chars_u = PyUnicode_DecodeASCII(ascii_chars, 128, NULL);
801         if (!ascii_chars_u) goto bad;
802         ascii_chars_b = PyUnicode_AsEncodedString(ascii_chars_u, default_encoding_c, NULL);
803         if (!ascii_chars_b || !PyBytes_Check(ascii_chars_b) || memcmp(ascii_chars, PyBytes_AS_STRING(ascii_chars_b), 128) != 0) {
804             PyErr_Format(
805                 PyExc_ValueError,
806                 "This module compiled with c_string_encoding=ascii, but default encoding '%.200s' is not a superset of ascii.",
807                 default_encoding_c);
808             goto bad;
809         }
810         Py_DECREF(ascii_chars_u);
811         Py_DECREF(ascii_chars_b);
812     }
813     Py_DECREF(default_encoding);
814     return 0;
815 bad:
816     Py_XDECREF(default_encoding);
817     Py_XDECREF(ascii_chars_u);
818     Py_XDECREF(ascii_chars_b);
819     return -1;
820 }
821 #endif
822 #if __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT && PY_MAJOR_VERSION >= 3
823 #define __Pyx_PyUnicode_FromStringAndSize(c_str, size) PyUnicode_DecodeUTF8(c_str, size, NULL)
824 #else
825 #define __Pyx_PyUnicode_FromStringAndSize(c_str, size) PyUnicode_Decode(c_str, size, __PYX_DEFAULT_STRING_ENCODING, NULL)
826 #if __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT
827 static char* __PYX_DEFAULT_STRING_ENCODING;
__Pyx_init_sys_getdefaultencoding_params(void)828 static int __Pyx_init_sys_getdefaultencoding_params(void) {
829     PyObject* sys;
830     PyObject* default_encoding = NULL;
831     char* default_encoding_c;
832     sys = PyImport_ImportModule("sys");
833     if (!sys) goto bad;
834     default_encoding = PyObject_CallMethod(sys, (char*) (const char*) "getdefaultencoding", NULL);
835     Py_DECREF(sys);
836     if (!default_encoding) goto bad;
837     default_encoding_c = PyBytes_AsString(default_encoding);
838     if (!default_encoding_c) goto bad;
839     __PYX_DEFAULT_STRING_ENCODING = (char*) malloc(strlen(default_encoding_c) + 1);
840     if (!__PYX_DEFAULT_STRING_ENCODING) goto bad;
841     strcpy(__PYX_DEFAULT_STRING_ENCODING, default_encoding_c);
842     Py_DECREF(default_encoding);
843     return 0;
844 bad:
845     Py_XDECREF(default_encoding);
846     return -1;
847 }
848 #endif
849 #endif
850 
851 
852 /* Test for GCC > 2.95 */
853 #if defined(__GNUC__)     && (__GNUC__ > 2 || (__GNUC__ == 2 && (__GNUC_MINOR__ > 95)))
854   #define likely(x)   __builtin_expect(!!(x), 1)
855   #define unlikely(x) __builtin_expect(!!(x), 0)
856 #else /* !__GNUC__ or GCC < 2.95 */
857   #define likely(x)   (x)
858   #define unlikely(x) (x)
859 #endif /* __GNUC__ */
__Pyx_pretend_to_initialize(void * ptr)860 static CYTHON_INLINE void __Pyx_pretend_to_initialize(void* ptr) { (void)ptr; }
861 
862 static PyObject *__pyx_m = NULL;
863 static PyObject *__pyx_d;
864 static PyObject *__pyx_b;
865 static PyObject *__pyx_cython_runtime = NULL;
866 static PyObject *__pyx_empty_tuple;
867 static PyObject *__pyx_empty_bytes;
868 static PyObject *__pyx_empty_unicode;
869 static int __pyx_lineno;
870 static int __pyx_clineno = 0;
871 static const char * __pyx_cfilenm= __FILE__;
872 static const char *__pyx_filename;
873 
874 /* Header.proto */
875 #if !defined(CYTHON_CCOMPLEX)
876   #if defined(__cplusplus)
877     #define CYTHON_CCOMPLEX 1
878   #elif defined(_Complex_I)
879     #define CYTHON_CCOMPLEX 1
880   #else
881     #define CYTHON_CCOMPLEX 0
882   #endif
883 #endif
884 #if CYTHON_CCOMPLEX
885   #ifdef __cplusplus
886     #include <complex>
887   #else
888     #include <complex.h>
889   #endif
890 #endif
891 #if CYTHON_CCOMPLEX && !defined(__cplusplus) && defined(__sun__) && defined(__GNUC__)
892   #undef _Complex_I
893   #define _Complex_I 1.0fj
894 #endif
895 
896 
897 static const char *__pyx_f[] = {
898   "qutip/cy/sparse_routines.pxi",
899   "qutip/cy/brtools.pyx",
900   "__init__.pxd",
901   "stringsource",
902   "type.pxd",
903 };
904 /* BufferFormatStructs.proto */
905 #define IS_UNSIGNED(type) (((type) -1) > 0)
906 struct __Pyx_StructField_;
907 #define __PYX_BUF_FLAGS_PACKED_STRUCT (1 << 0)
908 typedef struct {
909   const char* name;
910   struct __Pyx_StructField_* fields;
911   size_t size;
912   size_t arraysize[8];
913   int ndim;
914   char typegroup;
915   char is_unsigned;
916   int flags;
917 } __Pyx_TypeInfo;
918 typedef struct __Pyx_StructField_ {
919   __Pyx_TypeInfo* type;
920   const char* name;
921   size_t offset;
922 } __Pyx_StructField;
923 typedef struct {
924   __Pyx_StructField* field;
925   size_t parent_offset;
926 } __Pyx_BufFmt_StackElem;
927 typedef struct {
928   __Pyx_StructField root;
929   __Pyx_BufFmt_StackElem* head;
930   size_t fmt_offset;
931   size_t new_count, enc_count;
932   size_t struct_alignment;
933   int is_complex;
934   char enc_type;
935   char new_packmode;
936   char enc_packmode;
937   char is_valid_array;
938 } __Pyx_BufFmt_Context;
939 
940 /* MemviewSliceStruct.proto */
941 struct __pyx_memoryview_obj;
942 typedef struct {
943   struct __pyx_memoryview_obj *memview;
944   char *data;
945   Py_ssize_t shape[8];
946   Py_ssize_t strides[8];
947   Py_ssize_t suboffsets[8];
948 } __Pyx_memviewslice;
949 #define __Pyx_MemoryView_Len(m)  (m.shape[0])
950 
951 /* Atomics.proto */
952 #include <pythread.h>
953 #ifndef CYTHON_ATOMICS
954     #define CYTHON_ATOMICS 1
955 #endif
956 #define __pyx_atomic_int_type int
957 #if CYTHON_ATOMICS && __GNUC__ >= 4 && (__GNUC_MINOR__ > 1 ||\
958                     (__GNUC_MINOR__ == 1 && __GNUC_PATCHLEVEL >= 2)) &&\
959                     !defined(__i386__)
960     #define __pyx_atomic_incr_aligned(value, lock) __sync_fetch_and_add(value, 1)
961     #define __pyx_atomic_decr_aligned(value, lock) __sync_fetch_and_sub(value, 1)
962     #ifdef __PYX_DEBUG_ATOMICS
963         #warning "Using GNU atomics"
964     #endif
965 #elif CYTHON_ATOMICS && defined(_MSC_VER) && 0
966     #include <Windows.h>
967     #undef __pyx_atomic_int_type
968     #define __pyx_atomic_int_type LONG
969     #define __pyx_atomic_incr_aligned(value, lock) InterlockedIncrement(value)
970     #define __pyx_atomic_decr_aligned(value, lock) InterlockedDecrement(value)
971     #ifdef __PYX_DEBUG_ATOMICS
972         #pragma message ("Using MSVC atomics")
973     #endif
974 #elif CYTHON_ATOMICS && (defined(__ICC) || defined(__INTEL_COMPILER)) && 0
975     #define __pyx_atomic_incr_aligned(value, lock) _InterlockedIncrement(value)
976     #define __pyx_atomic_decr_aligned(value, lock) _InterlockedDecrement(value)
977     #ifdef __PYX_DEBUG_ATOMICS
978         #warning "Using Intel atomics"
979     #endif
980 #else
981     #undef CYTHON_ATOMICS
982     #define CYTHON_ATOMICS 0
983     #ifdef __PYX_DEBUG_ATOMICS
984         #warning "Not using atomics"
985     #endif
986 #endif
987 typedef volatile __pyx_atomic_int_type __pyx_atomic_int;
988 #if CYTHON_ATOMICS
989     #define __pyx_add_acquisition_count(memview)\
990              __pyx_atomic_incr_aligned(__pyx_get_slice_count_pointer(memview), memview->lock)
991     #define __pyx_sub_acquisition_count(memview)\
992             __pyx_atomic_decr_aligned(__pyx_get_slice_count_pointer(memview), memview->lock)
993 #else
994     #define __pyx_add_acquisition_count(memview)\
995             __pyx_add_acquisition_count_locked(__pyx_get_slice_count_pointer(memview), memview->lock)
996     #define __pyx_sub_acquisition_count(memview)\
997             __pyx_sub_acquisition_count_locked(__pyx_get_slice_count_pointer(memview), memview->lock)
998 #endif
999 
1000 /* ForceInitThreads.proto */
1001 #ifndef __PYX_FORCE_INIT_THREADS
1002   #define __PYX_FORCE_INIT_THREADS 0
1003 #endif
1004 
1005 /* NoFastGil.proto */
1006 #define __Pyx_PyGILState_Ensure PyGILState_Ensure
1007 #define __Pyx_PyGILState_Release PyGILState_Release
1008 #define __Pyx_FastGIL_Remember()
1009 #define __Pyx_FastGIL_Forget()
1010 #define __Pyx_FastGilFuncInit()
1011 
1012 
1013 /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":689
1014  * # in Cython to enable them only on the right systems.
1015  *
1016  * ctypedef npy_int8       int8_t             # <<<<<<<<<<<<<<
1017  * ctypedef npy_int16      int16_t
1018  * ctypedef npy_int32      int32_t
1019  */
1020 typedef npy_int8 __pyx_t_5numpy_int8_t;
1021 
1022 /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":690
1023  *
1024  * ctypedef npy_int8       int8_t
1025  * ctypedef npy_int16      int16_t             # <<<<<<<<<<<<<<
1026  * ctypedef npy_int32      int32_t
1027  * ctypedef npy_int64      int64_t
1028  */
1029 typedef npy_int16 __pyx_t_5numpy_int16_t;
1030 
1031 /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":691
1032  * ctypedef npy_int8       int8_t
1033  * ctypedef npy_int16      int16_t
1034  * ctypedef npy_int32      int32_t             # <<<<<<<<<<<<<<
1035  * ctypedef npy_int64      int64_t
1036  * #ctypedef npy_int96      int96_t
1037  */
1038 typedef npy_int32 __pyx_t_5numpy_int32_t;
1039 
1040 /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":692
1041  * ctypedef npy_int16      int16_t
1042  * ctypedef npy_int32      int32_t
1043  * ctypedef npy_int64      int64_t             # <<<<<<<<<<<<<<
1044  * #ctypedef npy_int96      int96_t
1045  * #ctypedef npy_int128     int128_t
1046  */
1047 typedef npy_int64 __pyx_t_5numpy_int64_t;
1048 
1049 /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":696
1050  * #ctypedef npy_int128     int128_t
1051  *
1052  * ctypedef npy_uint8      uint8_t             # <<<<<<<<<<<<<<
1053  * ctypedef npy_uint16     uint16_t
1054  * ctypedef npy_uint32     uint32_t
1055  */
1056 typedef npy_uint8 __pyx_t_5numpy_uint8_t;
1057 
1058 /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":697
1059  *
1060  * ctypedef npy_uint8      uint8_t
1061  * ctypedef npy_uint16     uint16_t             # <<<<<<<<<<<<<<
1062  * ctypedef npy_uint32     uint32_t
1063  * ctypedef npy_uint64     uint64_t
1064  */
1065 typedef npy_uint16 __pyx_t_5numpy_uint16_t;
1066 
1067 /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":698
1068  * ctypedef npy_uint8      uint8_t
1069  * ctypedef npy_uint16     uint16_t
1070  * ctypedef npy_uint32     uint32_t             # <<<<<<<<<<<<<<
1071  * ctypedef npy_uint64     uint64_t
1072  * #ctypedef npy_uint96     uint96_t
1073  */
1074 typedef npy_uint32 __pyx_t_5numpy_uint32_t;
1075 
1076 /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":699
1077  * ctypedef npy_uint16     uint16_t
1078  * ctypedef npy_uint32     uint32_t
1079  * ctypedef npy_uint64     uint64_t             # <<<<<<<<<<<<<<
1080  * #ctypedef npy_uint96     uint96_t
1081  * #ctypedef npy_uint128    uint128_t
1082  */
1083 typedef npy_uint64 __pyx_t_5numpy_uint64_t;
1084 
1085 /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":703
1086  * #ctypedef npy_uint128    uint128_t
1087  *
1088  * ctypedef npy_float32    float32_t             # <<<<<<<<<<<<<<
1089  * ctypedef npy_float64    float64_t
1090  * #ctypedef npy_float80    float80_t
1091  */
1092 typedef npy_float32 __pyx_t_5numpy_float32_t;
1093 
1094 /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":704
1095  *
1096  * ctypedef npy_float32    float32_t
1097  * ctypedef npy_float64    float64_t             # <<<<<<<<<<<<<<
1098  * #ctypedef npy_float80    float80_t
1099  * #ctypedef npy_float128   float128_t
1100  */
1101 typedef npy_float64 __pyx_t_5numpy_float64_t;
1102 
1103 /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":713
1104  * # The int types are mapped a bit surprising --
1105  * # numpy.int corresponds to 'l' and numpy.long to 'q'
1106  * ctypedef npy_long       int_t             # <<<<<<<<<<<<<<
1107  * ctypedef npy_longlong   long_t
1108  * ctypedef npy_longlong   longlong_t
1109  */
1110 typedef npy_long __pyx_t_5numpy_int_t;
1111 
1112 /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":714
1113  * # numpy.int corresponds to 'l' and numpy.long to 'q'
1114  * ctypedef npy_long       int_t
1115  * ctypedef npy_longlong   long_t             # <<<<<<<<<<<<<<
1116  * ctypedef npy_longlong   longlong_t
1117  *
1118  */
1119 typedef npy_longlong __pyx_t_5numpy_long_t;
1120 
1121 /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":715
1122  * ctypedef npy_long       int_t
1123  * ctypedef npy_longlong   long_t
1124  * ctypedef npy_longlong   longlong_t             # <<<<<<<<<<<<<<
1125  *
1126  * ctypedef npy_ulong      uint_t
1127  */
1128 typedef npy_longlong __pyx_t_5numpy_longlong_t;
1129 
1130 /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":717
1131  * ctypedef npy_longlong   longlong_t
1132  *
1133  * ctypedef npy_ulong      uint_t             # <<<<<<<<<<<<<<
1134  * ctypedef npy_ulonglong  ulong_t
1135  * ctypedef npy_ulonglong  ulonglong_t
1136  */
1137 typedef npy_ulong __pyx_t_5numpy_uint_t;
1138 
1139 /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":718
1140  *
1141  * ctypedef npy_ulong      uint_t
1142  * ctypedef npy_ulonglong  ulong_t             # <<<<<<<<<<<<<<
1143  * ctypedef npy_ulonglong  ulonglong_t
1144  *
1145  */
1146 typedef npy_ulonglong __pyx_t_5numpy_ulong_t;
1147 
1148 /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":719
1149  * ctypedef npy_ulong      uint_t
1150  * ctypedef npy_ulonglong  ulong_t
1151  * ctypedef npy_ulonglong  ulonglong_t             # <<<<<<<<<<<<<<
1152  *
1153  * ctypedef npy_intp       intp_t
1154  */
1155 typedef npy_ulonglong __pyx_t_5numpy_ulonglong_t;
1156 
1157 /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":721
1158  * ctypedef npy_ulonglong  ulonglong_t
1159  *
1160  * ctypedef npy_intp       intp_t             # <<<<<<<<<<<<<<
1161  * ctypedef npy_uintp      uintp_t
1162  *
1163  */
1164 typedef npy_intp __pyx_t_5numpy_intp_t;
1165 
1166 /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":722
1167  *
1168  * ctypedef npy_intp       intp_t
1169  * ctypedef npy_uintp      uintp_t             # <<<<<<<<<<<<<<
1170  *
1171  * ctypedef npy_double     float_t
1172  */
1173 typedef npy_uintp __pyx_t_5numpy_uintp_t;
1174 
1175 /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":724
1176  * ctypedef npy_uintp      uintp_t
1177  *
1178  * ctypedef npy_double     float_t             # <<<<<<<<<<<<<<
1179  * ctypedef npy_double     double_t
1180  * ctypedef npy_longdouble longdouble_t
1181  */
1182 typedef npy_double __pyx_t_5numpy_float_t;
1183 
1184 /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":725
1185  *
1186  * ctypedef npy_double     float_t
1187  * ctypedef npy_double     double_t             # <<<<<<<<<<<<<<
1188  * ctypedef npy_longdouble longdouble_t
1189  *
1190  */
1191 typedef npy_double __pyx_t_5numpy_double_t;
1192 
1193 /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":726
1194  * ctypedef npy_double     float_t
1195  * ctypedef npy_double     double_t
1196  * ctypedef npy_longdouble longdouble_t             # <<<<<<<<<<<<<<
1197  *
1198  * ctypedef npy_cfloat      cfloat_t
1199  */
1200 typedef npy_longdouble __pyx_t_5numpy_longdouble_t;
1201 
1202 /* "scipy/linalg/cython_lapack.pxd":15
1203  * # The original libraries should be linked directly.
1204  *
1205  * ctypedef float s             # <<<<<<<<<<<<<<
1206  * ctypedef double d
1207  * ctypedef float complex c
1208  */
1209 typedef float __pyx_t_5scipy_6linalg_13cython_lapack_s;
1210 
1211 /* "scipy/linalg/cython_lapack.pxd":16
1212  *
1213  * ctypedef float s
1214  * ctypedef double d             # <<<<<<<<<<<<<<
1215  * ctypedef float complex c
1216  * ctypedef double complex z
1217  */
1218 typedef double __pyx_t_5scipy_6linalg_13cython_lapack_d;
1219 
1220 /* "scipy/linalg/cython_blas.pxd":15
1221  * # The original libraries should be linked directly.
1222  *
1223  * ctypedef float s             # <<<<<<<<<<<<<<
1224  * ctypedef double d
1225  * ctypedef float complex c
1226  */
1227 typedef float __pyx_t_5scipy_6linalg_11cython_blas_s;
1228 
1229 /* "scipy/linalg/cython_blas.pxd":16
1230  *
1231  * ctypedef float s
1232  * ctypedef double d             # <<<<<<<<<<<<<<
1233  * ctypedef float complex c
1234  * ctypedef double complex z
1235  */
1236 typedef double __pyx_t_5scipy_6linalg_11cython_blas_d;
1237 
1238 /* "qutip/cy/parameters.pxi":5
1239  *
1240  * DTYPE = np.float64
1241  * ctypedef cnp.float64_t DTYPE_t             # <<<<<<<<<<<<<<
1242  *
1243  * ITYPE = np.int32
1244  */
1245 typedef __pyx_t_5numpy_float64_t __pyx_t_5qutip_2cy_10spmatfuncs_DTYPE_t;
1246 
1247 /* "qutip/cy/parameters.pxi":8
1248  *
1249  * ITYPE = np.int32
1250  * ctypedef cnp.int32_t ITYPE_t             # <<<<<<<<<<<<<<
1251  *
1252  * CTYPE = np.complex128
1253  */
1254 typedef __pyx_t_5numpy_int32_t __pyx_t_5qutip_2cy_10spmatfuncs_ITYPE_t;
1255 
1256 /* "qutip/cy/parameters.pxi":14
1257  *
1258  * CTYPE = np.int64
1259  * ctypedef cnp.int64_t LTYPE_t             # <<<<<<<<<<<<<<
1260  */
1261 typedef __pyx_t_5numpy_int64_t __pyx_t_5qutip_2cy_10spmatfuncs_LTYPE_t;
1262 /* Declarations.proto */
1263 #if CYTHON_CCOMPLEX
1264   #ifdef __cplusplus
1265     typedef ::std::complex< double > __pyx_t_double_complex;
1266   #else
1267     typedef double _Complex __pyx_t_double_complex;
1268   #endif
1269 #else
1270     typedef struct { double real, imag; } __pyx_t_double_complex;
1271 #endif
1272 static CYTHON_INLINE __pyx_t_double_complex __pyx_t_double_complex_from_parts(double, double);
1273 
1274 /* Declarations.proto */
1275 #if CYTHON_CCOMPLEX
1276   #ifdef __cplusplus
1277     typedef ::std::complex< float > __pyx_t_float_complex;
1278   #else
1279     typedef float _Complex __pyx_t_float_complex;
1280   #endif
1281 #else
1282     typedef struct { float real, imag; } __pyx_t_float_complex;
1283 #endif
1284 static CYTHON_INLINE __pyx_t_float_complex __pyx_t_float_complex_from_parts(float, float);
1285 
1286 
1287 /*--- Type declarations ---*/
1288 struct __pyx_array_obj;
1289 struct __pyx_MemviewEnum_obj;
1290 struct __pyx_memoryview_obj;
1291 struct __pyx_memoryviewslice_obj;
1292 
1293 /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":728
1294  * ctypedef npy_longdouble longdouble_t
1295  *
1296  * ctypedef npy_cfloat      cfloat_t             # <<<<<<<<<<<<<<
1297  * ctypedef npy_cdouble     cdouble_t
1298  * ctypedef npy_clongdouble clongdouble_t
1299  */
1300 typedef npy_cfloat __pyx_t_5numpy_cfloat_t;
1301 
1302 /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":729
1303  *
1304  * ctypedef npy_cfloat      cfloat_t
1305  * ctypedef npy_cdouble     cdouble_t             # <<<<<<<<<<<<<<
1306  * ctypedef npy_clongdouble clongdouble_t
1307  *
1308  */
1309 typedef npy_cdouble __pyx_t_5numpy_cdouble_t;
1310 
1311 /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":730
1312  * ctypedef npy_cfloat      cfloat_t
1313  * ctypedef npy_cdouble     cdouble_t
1314  * ctypedef npy_clongdouble clongdouble_t             # <<<<<<<<<<<<<<
1315  *
1316  * ctypedef npy_cdouble     complex_t
1317  */
1318 typedef npy_clongdouble __pyx_t_5numpy_clongdouble_t;
1319 
1320 /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":732
1321  * ctypedef npy_clongdouble clongdouble_t
1322  *
1323  * ctypedef npy_cdouble     complex_t             # <<<<<<<<<<<<<<
1324  *
1325  * cdef inline object PyArray_MultiIterNew1(a):
1326  */
1327 typedef npy_cdouble __pyx_t_5numpy_complex_t;
1328 
1329 /* "scipy/linalg/cython_lapack.pxd":22
1330  * # Function pointer type declarations for
1331  * # gees and gges families of functions.
1332  * ctypedef bint cselect1(c*)             # <<<<<<<<<<<<<<
1333  * ctypedef bint cselect2(c*, c*)
1334  * ctypedef bint dselect2(d*, d*)
1335  */
1336 typedef int __pyx_t_5scipy_6linalg_13cython_lapack_cselect1(__pyx_t_float_complex *);
1337 
1338 /* "scipy/linalg/cython_lapack.pxd":23
1339  * # gees and gges families of functions.
1340  * ctypedef bint cselect1(c*)
1341  * ctypedef bint cselect2(c*, c*)             # <<<<<<<<<<<<<<
1342  * ctypedef bint dselect2(d*, d*)
1343  * ctypedef bint dselect3(d*, d*, d*)
1344  */
1345 typedef int __pyx_t_5scipy_6linalg_13cython_lapack_cselect2(__pyx_t_float_complex *, __pyx_t_float_complex *);
1346 
1347 /* "scipy/linalg/cython_lapack.pxd":24
1348  * ctypedef bint cselect1(c*)
1349  * ctypedef bint cselect2(c*, c*)
1350  * ctypedef bint dselect2(d*, d*)             # <<<<<<<<<<<<<<
1351  * ctypedef bint dselect3(d*, d*, d*)
1352  * ctypedef bint sselect2(s*, s*)
1353  */
1354 typedef int __pyx_t_5scipy_6linalg_13cython_lapack_dselect2(__pyx_t_5scipy_6linalg_13cython_lapack_d *, __pyx_t_5scipy_6linalg_13cython_lapack_d *);
1355 
1356 /* "scipy/linalg/cython_lapack.pxd":25
1357  * ctypedef bint cselect2(c*, c*)
1358  * ctypedef bint dselect2(d*, d*)
1359  * ctypedef bint dselect3(d*, d*, d*)             # <<<<<<<<<<<<<<
1360  * ctypedef bint sselect2(s*, s*)
1361  * ctypedef bint sselect3(s*, s*, s*)
1362  */
1363 typedef int __pyx_t_5scipy_6linalg_13cython_lapack_dselect3(__pyx_t_5scipy_6linalg_13cython_lapack_d *, __pyx_t_5scipy_6linalg_13cython_lapack_d *, __pyx_t_5scipy_6linalg_13cython_lapack_d *);
1364 
1365 /* "scipy/linalg/cython_lapack.pxd":26
1366  * ctypedef bint dselect2(d*, d*)
1367  * ctypedef bint dselect3(d*, d*, d*)
1368  * ctypedef bint sselect2(s*, s*)             # <<<<<<<<<<<<<<
1369  * ctypedef bint sselect3(s*, s*, s*)
1370  * ctypedef bint zselect1(z*)
1371  */
1372 typedef int __pyx_t_5scipy_6linalg_13cython_lapack_sselect2(__pyx_t_5scipy_6linalg_13cython_lapack_s *, __pyx_t_5scipy_6linalg_13cython_lapack_s *);
1373 
1374 /* "scipy/linalg/cython_lapack.pxd":27
1375  * ctypedef bint dselect3(d*, d*, d*)
1376  * ctypedef bint sselect2(s*, s*)
1377  * ctypedef bint sselect3(s*, s*, s*)             # <<<<<<<<<<<<<<
1378  * ctypedef bint zselect1(z*)
1379  * ctypedef bint zselect2(z*, z*)
1380  */
1381 typedef int __pyx_t_5scipy_6linalg_13cython_lapack_sselect3(__pyx_t_5scipy_6linalg_13cython_lapack_s *, __pyx_t_5scipy_6linalg_13cython_lapack_s *, __pyx_t_5scipy_6linalg_13cython_lapack_s *);
1382 
1383 /* "scipy/linalg/cython_lapack.pxd":28
1384  * ctypedef bint sselect2(s*, s*)
1385  * ctypedef bint sselect3(s*, s*, s*)
1386  * ctypedef bint zselect1(z*)             # <<<<<<<<<<<<<<
1387  * ctypedef bint zselect2(z*, z*)
1388  *
1389  */
1390 typedef int __pyx_t_5scipy_6linalg_13cython_lapack_zselect1(__pyx_t_double_complex *);
1391 
1392 /* "scipy/linalg/cython_lapack.pxd":29
1393  * ctypedef bint sselect3(s*, s*, s*)
1394  * ctypedef bint zselect1(z*)
1395  * ctypedef bint zselect2(z*, z*)             # <<<<<<<<<<<<<<
1396  *
1397  * cdef void cbbcsd(char *jobu1, char *jobu2, char *jobv1t, char *jobv2t, char *trans, int *m, int *p, int *q, s *theta, s *phi, c *u1, int *ldu1, c *u2, int *ldu2, c *v1t, int *ldv1t, c *v2t, int *ldv2t, s *b11d, s *b11e, s *b12d, s *b12e, s *b21d, s *b21e, s *b22d, s *b22e, s *rwork, int *lrwork, int *info) nogil
1398  */
1399 typedef int __pyx_t_5scipy_6linalg_13cython_lapack_zselect2(__pyx_t_double_complex *, __pyx_t_double_complex *);
1400 struct __pyx_t_5qutip_2cy_14sparse_structs__csr_mat;
1401 struct __pyx_t_5qutip_2cy_14sparse_structs__coo_mat;
1402 
1403 /* "qutip/cy/sparse_structs.pxd":35
1404  * ###############################################################################
1405  *
1406  * cdef struct _csr_mat:             # <<<<<<<<<<<<<<
1407  *     double complex * data
1408  *     int * indices
1409  */
1410 struct __pyx_t_5qutip_2cy_14sparse_structs__csr_mat {
1411   __pyx_t_double_complex *data;
1412   int *indices;
1413   int *indptr;
1414   int nnz;
1415   int nrows;
1416   int ncols;
1417   int is_set;
1418   int max_length;
1419   int numpy_lock;
1420 };
1421 
1422 /* "qutip/cy/sparse_structs.pxd":46
1423  *     int numpy_lock
1424  *
1425  * cdef struct _coo_mat:             # <<<<<<<<<<<<<<
1426  *     double complex * data
1427  *     int * rows
1428  */
1429 struct __pyx_t_5qutip_2cy_14sparse_structs__coo_mat {
1430   __pyx_t_double_complex *data;
1431   int *rows;
1432   int *cols;
1433   int nnz;
1434   int nrows;
1435   int ncols;
1436   int is_set;
1437   int max_length;
1438   int numpy_lock;
1439 };
1440 
1441 /* "qutip/cy/sparse_structs.pxd":57
1442  *     int numpy_lock
1443  *
1444  * ctypedef _csr_mat CSR_Matrix             # <<<<<<<<<<<<<<
1445  * ctypedef _coo_mat COO_Matrix
1446  */
1447 typedef struct __pyx_t_5qutip_2cy_14sparse_structs__csr_mat __pyx_t_5qutip_2cy_14sparse_structs_CSR_Matrix;
1448 
1449 /* "qutip/cy/sparse_structs.pxd":58
1450  *
1451  * ctypedef _csr_mat CSR_Matrix
1452  * ctypedef _coo_mat COO_Matrix             # <<<<<<<<<<<<<<
1453  */
1454 typedef struct __pyx_t_5qutip_2cy_14sparse_structs__coo_mat __pyx_t_5qutip_2cy_14sparse_structs_COO_Matrix;
1455 struct __pyx_t_5qutip_2cy_7brtools__data_ind_pair;
1456 struct __pyx_opt_args_5qutip_2cy_7brtools_raise_error_CSR;
1457 struct __pyx_opt_args_5qutip_2cy_7brtools_raise_error_COO;
1458 struct __pyx_opt_args_5qutip_2cy_7brtools_init_CSR;
1459 struct __pyx_opt_args_5qutip_2cy_7brtools_init_COO;
1460 struct __pyx_opt_args_5qutip_2cy_7brtools_expand_CSR;
1461 struct __pyx_opt_args_5qutip_2cy_7brtools_ZGEMM;
1462 struct __pyx_opt_args_5qutip_2cy_7brtools_ZGEMV;
1463 
1464 /* "qutip/cy/brtools.pxd":38
1465  *
1466  * #Spectral function with signature (w,t)
1467  * ctypedef complex (*spec_func)(double, double)             # <<<<<<<<<<<<<<
1468  *
1469  * cdef complex[::1,:] farray_alloc(int nrows)
1470  */
1471 typedef __pyx_t_double_complex (*__pyx_t_5qutip_2cy_7brtools_spec_func)(double, double);
1472 
1473 /* "qutip/cy/sparse_routines.pxi":54
1474  *
1475  * #Struct used for CSR indices sorting
1476  * cdef struct _data_ind_pair:             # <<<<<<<<<<<<<<
1477  *     double complex data
1478  *     int ind
1479  */
1480 struct __pyx_t_5qutip_2cy_7brtools__data_ind_pair {
1481   __pyx_t_double_complex data;
1482   int ind;
1483 };
1484 
1485 /* "qutip/cy/sparse_routines.pxi":58
1486  *     int ind
1487  *
1488  * ctypedef _data_ind_pair data_ind_pair             # <<<<<<<<<<<<<<
1489  * ctypedef int (*cfptr)(data_ind_pair, data_ind_pair)
1490  *
1491  */
1492 typedef struct __pyx_t_5qutip_2cy_7brtools__data_ind_pair __pyx_t_5qutip_2cy_7brtools_data_ind_pair;
1493 
1494 /* "qutip/cy/sparse_routines.pxi":59
1495  *
1496  * ctypedef _data_ind_pair data_ind_pair
1497  * ctypedef int (*cfptr)(data_ind_pair, data_ind_pair)             # <<<<<<<<<<<<<<
1498  *
1499  *
1500  */
1501 typedef int (*__pyx_t_5qutip_2cy_7brtools_cfptr)(__pyx_t_5qutip_2cy_7brtools_data_ind_pair, __pyx_t_5qutip_2cy_7brtools_data_ind_pair);
1502 
1503 /* "qutip/cy/sparse_routines.pxi":62
1504  *
1505  *
1506  * cdef void raise_error_CSR(int E, CSR_Matrix * C = NULL):             # <<<<<<<<<<<<<<
1507  *     if not C.numpy_lock and C != NULL:
1508  *         free_CSR(C)
1509  */
1510 struct __pyx_opt_args_5qutip_2cy_7brtools_raise_error_CSR {
1511   int __pyx_n;
1512   __pyx_t_5qutip_2cy_14sparse_structs_CSR_Matrix *C;
1513 };
1514 
1515 /* "qutip/cy/sparse_routines.pxi":83
1516  *
1517  *
1518  * cdef void raise_error_COO(int E, COO_Matrix * C = NULL):             # <<<<<<<<<<<<<<
1519  *     if not C.numpy_lock and C != NULL:
1520  *         free_COO(C)
1521  */
1522 struct __pyx_opt_args_5qutip_2cy_7brtools_raise_error_COO {
1523   int __pyx_n;
1524   __pyx_t_5qutip_2cy_14sparse_structs_COO_Matrix *C;
1525 };
1526 
1527 /* "qutip/cy/sparse_routines.pxi":113
1528  * @cython.boundscheck(False)
1529  * @cython.wraparound(False)
1530  * cdef void init_CSR(CSR_Matrix * mat, int nnz, int nrows, int ncols = 0,             # <<<<<<<<<<<<<<
1531  *                 int max_length = 0, int init_zeros = 1):
1532  *     """
1533  */
1534 struct __pyx_opt_args_5qutip_2cy_7brtools_init_CSR {
1535   int __pyx_n;
1536   int ncols;
1537   int max_length;
1538   int init_zeros;
1539 };
1540 
1541 /* "qutip/cy/sparse_routines.pxi":184
1542  * @cython.boundscheck(False)
1543  * @cython.wraparound(False)
1544  * cdef void init_COO(COO_Matrix * mat, int nnz, int nrows, int ncols = 0,             # <<<<<<<<<<<<<<
1545  *                 int max_length = 0, int init_zeros = 1):
1546  *     """
1547  */
1548 struct __pyx_opt_args_5qutip_2cy_7brtools_init_COO {
1549   int __pyx_n;
1550   int ncols;
1551   int max_length;
1552   int init_zeros;
1553 };
1554 
1555 /* "qutip/cy/sparse_routines.pxi":286
1556  * @cython.boundscheck(False)
1557  * @cython.wraparound(False)
1558  * cdef void expand_CSR(CSR_Matrix * mat, int init_zeros=0):             # <<<<<<<<<<<<<<
1559  *     """
1560  *     Expands the length of CSR data and indices arrays to accomodate
1561  */
1562 struct __pyx_opt_args_5qutip_2cy_7brtools_expand_CSR {
1563   int __pyx_n;
1564   int init_zeros;
1565 };
1566 
1567 /* "qutip/cy/brtools.pyx":309
1568  * @cython.boundscheck(False)
1569  * @cython.wraparound(False)
1570  * cdef double complex * ZGEMM(double complex * A, double complex * B,             # <<<<<<<<<<<<<<
1571  *          int Arows, int Acols, int Brows, int Bcols,
1572  *          int transA = 0, int transB = 0,
1573  */
1574 struct __pyx_opt_args_5qutip_2cy_7brtools_ZGEMM {
1575   int __pyx_n;
1576   int transA;
1577   int transB;
1578   __pyx_t_double_complex alpha;
1579   __pyx_t_double_complex beta;
1580 };
1581 
1582 /* "qutip/cy/brtools.pyx":337
1583  * @cython.boundscheck(False)
1584  * @cython.wraparound(False)
1585  * cdef void ZGEMV(double complex * A, double complex * vec,             # <<<<<<<<<<<<<<
1586  *                         double complex * out,
1587  *                        int Arows, int Acols, int transA = 0,
1588  */
1589 struct __pyx_opt_args_5qutip_2cy_7brtools_ZGEMV {
1590   int __pyx_n;
1591   int transA;
1592   __pyx_t_double_complex alpha;
1593   __pyx_t_double_complex beta;
1594 };
1595 
1596 /* "View.MemoryView":105
1597  *
1598  * @cname("__pyx_array")
1599  * cdef class array:             # <<<<<<<<<<<<<<
1600  *
1601  *     cdef:
1602  */
1603 struct __pyx_array_obj {
1604   PyObject_HEAD
1605   struct __pyx_vtabstruct_array *__pyx_vtab;
1606   char *data;
1607   Py_ssize_t len;
1608   char *format;
1609   int ndim;
1610   Py_ssize_t *_shape;
1611   Py_ssize_t *_strides;
1612   Py_ssize_t itemsize;
1613   PyObject *mode;
1614   PyObject *_format;
1615   void (*callback_free_data)(void *);
1616   int free_data;
1617   int dtype_is_object;
1618 };
1619 
1620 
1621 /* "View.MemoryView":279
1622  *
1623  * @cname('__pyx_MemviewEnum')
1624  * cdef class Enum(object):             # <<<<<<<<<<<<<<
1625  *     cdef object name
1626  *     def __init__(self, name):
1627  */
1628 struct __pyx_MemviewEnum_obj {
1629   PyObject_HEAD
1630   PyObject *name;
1631 };
1632 
1633 
1634 /* "View.MemoryView":330
1635  *
1636  * @cname('__pyx_memoryview')
1637  * cdef class memoryview(object):             # <<<<<<<<<<<<<<
1638  *
1639  *     cdef object obj
1640  */
1641 struct __pyx_memoryview_obj {
1642   PyObject_HEAD
1643   struct __pyx_vtabstruct_memoryview *__pyx_vtab;
1644   PyObject *obj;
1645   PyObject *_size;
1646   PyObject *_array_interface;
1647   PyThread_type_lock lock;
1648   __pyx_atomic_int acquisition_count[2];
1649   __pyx_atomic_int *acquisition_count_aligned_p;
1650   Py_buffer view;
1651   int flags;
1652   int dtype_is_object;
1653   __Pyx_TypeInfo *typeinfo;
1654 };
1655 
1656 
1657 /* "View.MemoryView":965
1658  *
1659  * @cname('__pyx_memoryviewslice')
1660  * cdef class _memoryviewslice(memoryview):             # <<<<<<<<<<<<<<
1661  *     "Internal class for passing memoryview slices to Python"
1662  *
1663  */
1664 struct __pyx_memoryviewslice_obj {
1665   struct __pyx_memoryview_obj __pyx_base;
1666   __Pyx_memviewslice from_slice;
1667   PyObject *from_object;
1668   PyObject *(*to_object_func)(char *);
1669   int (*to_dtype_func)(char *, PyObject *);
1670 };
1671 
1672 
1673 
1674 /* "View.MemoryView":105
1675  *
1676  * @cname("__pyx_array")
1677  * cdef class array:             # <<<<<<<<<<<<<<
1678  *
1679  *     cdef:
1680  */
1681 
1682 struct __pyx_vtabstruct_array {
1683   PyObject *(*get_memview)(struct __pyx_array_obj *);
1684 };
1685 static struct __pyx_vtabstruct_array *__pyx_vtabptr_array;
1686 
1687 
1688 /* "View.MemoryView":330
1689  *
1690  * @cname('__pyx_memoryview')
1691  * cdef class memoryview(object):             # <<<<<<<<<<<<<<
1692  *
1693  *     cdef object obj
1694  */
1695 
1696 struct __pyx_vtabstruct_memoryview {
1697   char *(*get_item_pointer)(struct __pyx_memoryview_obj *, PyObject *);
1698   PyObject *(*is_slice)(struct __pyx_memoryview_obj *, PyObject *);
1699   PyObject *(*setitem_slice_assignment)(struct __pyx_memoryview_obj *, PyObject *, PyObject *);
1700   PyObject *(*setitem_slice_assign_scalar)(struct __pyx_memoryview_obj *, struct __pyx_memoryview_obj *, PyObject *);
1701   PyObject *(*setitem_indexed)(struct __pyx_memoryview_obj *, PyObject *, PyObject *);
1702   PyObject *(*convert_item_to_object)(struct __pyx_memoryview_obj *, char *);
1703   PyObject *(*assign_item_from_object)(struct __pyx_memoryview_obj *, char *, PyObject *);
1704 };
1705 static struct __pyx_vtabstruct_memoryview *__pyx_vtabptr_memoryview;
1706 
1707 
1708 /* "View.MemoryView":965
1709  *
1710  * @cname('__pyx_memoryviewslice')
1711  * cdef class _memoryviewslice(memoryview):             # <<<<<<<<<<<<<<
1712  *     "Internal class for passing memoryview slices to Python"
1713  *
1714  */
1715 
1716 struct __pyx_vtabstruct__memoryviewslice {
1717   struct __pyx_vtabstruct_memoryview __pyx_base;
1718 };
1719 static struct __pyx_vtabstruct__memoryviewslice *__pyx_vtabptr__memoryviewslice;
1720 
1721 /* --- Runtime support code (head) --- */
1722 /* Refnanny.proto */
1723 #ifndef CYTHON_REFNANNY
1724   #define CYTHON_REFNANNY 0
1725 #endif
1726 #if CYTHON_REFNANNY
1727   typedef struct {
1728     void (*INCREF)(void*, PyObject*, int);
1729     void (*DECREF)(void*, PyObject*, int);
1730     void (*GOTREF)(void*, PyObject*, int);
1731     void (*GIVEREF)(void*, PyObject*, int);
1732     void* (*SetupContext)(const char*, int, const char*);
1733     void (*FinishContext)(void**);
1734   } __Pyx_RefNannyAPIStruct;
1735   static __Pyx_RefNannyAPIStruct *__Pyx_RefNanny = NULL;
1736   static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname);
1737   #define __Pyx_RefNannyDeclarations void *__pyx_refnanny = NULL;
1738 #ifdef WITH_THREAD
1739   #define __Pyx_RefNannySetupContext(name, acquire_gil)\
1740           if (acquire_gil) {\
1741               PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure();\
1742               __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__);\
1743               PyGILState_Release(__pyx_gilstate_save);\
1744           } else {\
1745               __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__);\
1746           }
1747 #else
1748   #define __Pyx_RefNannySetupContext(name, acquire_gil)\
1749           __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__)
1750 #endif
1751   #define __Pyx_RefNannyFinishContext()\
1752           __Pyx_RefNanny->FinishContext(&__pyx_refnanny)
1753   #define __Pyx_INCREF(r)  __Pyx_RefNanny->INCREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
1754   #define __Pyx_DECREF(r)  __Pyx_RefNanny->DECREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
1755   #define __Pyx_GOTREF(r)  __Pyx_RefNanny->GOTREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
1756   #define __Pyx_GIVEREF(r) __Pyx_RefNanny->GIVEREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
1757   #define __Pyx_XINCREF(r)  do { if((r) != NULL) {__Pyx_INCREF(r); }} while(0)
1758   #define __Pyx_XDECREF(r)  do { if((r) != NULL) {__Pyx_DECREF(r); }} while(0)
1759   #define __Pyx_XGOTREF(r)  do { if((r) != NULL) {__Pyx_GOTREF(r); }} while(0)
1760   #define __Pyx_XGIVEREF(r) do { if((r) != NULL) {__Pyx_GIVEREF(r);}} while(0)
1761 #else
1762   #define __Pyx_RefNannyDeclarations
1763   #define __Pyx_RefNannySetupContext(name, acquire_gil)
1764   #define __Pyx_RefNannyFinishContext()
1765   #define __Pyx_INCREF(r) Py_INCREF(r)
1766   #define __Pyx_DECREF(r) Py_DECREF(r)
1767   #define __Pyx_GOTREF(r)
1768   #define __Pyx_GIVEREF(r)
1769   #define __Pyx_XINCREF(r) Py_XINCREF(r)
1770   #define __Pyx_XDECREF(r) Py_XDECREF(r)
1771   #define __Pyx_XGOTREF(r)
1772   #define __Pyx_XGIVEREF(r)
1773 #endif
1774 #define __Pyx_XDECREF_SET(r, v) do {\
1775         PyObject *tmp = (PyObject *) r;\
1776         r = v; __Pyx_XDECREF(tmp);\
1777     } while (0)
1778 #define __Pyx_DECREF_SET(r, v) do {\
1779         PyObject *tmp = (PyObject *) r;\
1780         r = v; __Pyx_DECREF(tmp);\
1781     } while (0)
1782 #define __Pyx_CLEAR(r)    do { PyObject* tmp = ((PyObject*)(r)); r = NULL; __Pyx_DECREF(tmp);} while(0)
1783 #define __Pyx_XCLEAR(r)   do { if((r) != NULL) {PyObject* tmp = ((PyObject*)(r)); r = NULL; __Pyx_DECREF(tmp);}} while(0)
1784 
1785 /* PyObjectGetAttrStr.proto */
1786 #if CYTHON_USE_TYPE_SLOTS
1787 static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStr(PyObject* obj, PyObject* attr_name);
1788 #else
1789 #define __Pyx_PyObject_GetAttrStr(o,n) PyObject_GetAttr(o,n)
1790 #endif
1791 
1792 /* GetBuiltinName.proto */
1793 static PyObject *__Pyx_GetBuiltinName(PyObject *name);
1794 
1795 /* PyObjectCall.proto */
1796 #if CYTHON_COMPILING_IN_CPYTHON
1797 static CYTHON_INLINE PyObject* __Pyx_PyObject_Call(PyObject *func, PyObject *arg, PyObject *kw);
1798 #else
1799 #define __Pyx_PyObject_Call(func, arg, kw) PyObject_Call(func, arg, kw)
1800 #endif
1801 
1802 /* PyThreadStateGet.proto */
1803 #if CYTHON_FAST_THREAD_STATE
1804 #define __Pyx_PyThreadState_declare  PyThreadState *__pyx_tstate;
1805 #define __Pyx_PyThreadState_assign  __pyx_tstate = __Pyx_PyThreadState_Current;
1806 #define __Pyx_PyErr_Occurred()  __pyx_tstate->curexc_type
1807 #else
1808 #define __Pyx_PyThreadState_declare
1809 #define __Pyx_PyThreadState_assign
1810 #define __Pyx_PyErr_Occurred()  PyErr_Occurred()
1811 #endif
1812 
1813 /* PyErrFetchRestore.proto */
1814 #if CYTHON_FAST_THREAD_STATE
1815 #define __Pyx_PyErr_Clear() __Pyx_ErrRestore(NULL, NULL, NULL)
1816 #define __Pyx_ErrRestoreWithState(type, value, tb)  __Pyx_ErrRestoreInState(PyThreadState_GET(), type, value, tb)
1817 #define __Pyx_ErrFetchWithState(type, value, tb)    __Pyx_ErrFetchInState(PyThreadState_GET(), type, value, tb)
1818 #define __Pyx_ErrRestore(type, value, tb)  __Pyx_ErrRestoreInState(__pyx_tstate, type, value, tb)
1819 #define __Pyx_ErrFetch(type, value, tb)    __Pyx_ErrFetchInState(__pyx_tstate, type, value, tb)
1820 static CYTHON_INLINE void __Pyx_ErrRestoreInState(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb);
1821 static CYTHON_INLINE void __Pyx_ErrFetchInState(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb);
1822 #if CYTHON_COMPILING_IN_CPYTHON
1823 #define __Pyx_PyErr_SetNone(exc) (Py_INCREF(exc), __Pyx_ErrRestore((exc), NULL, NULL))
1824 #else
1825 #define __Pyx_PyErr_SetNone(exc) PyErr_SetNone(exc)
1826 #endif
1827 #else
1828 #define __Pyx_PyErr_Clear() PyErr_Clear()
1829 #define __Pyx_PyErr_SetNone(exc) PyErr_SetNone(exc)
1830 #define __Pyx_ErrRestoreWithState(type, value, tb)  PyErr_Restore(type, value, tb)
1831 #define __Pyx_ErrFetchWithState(type, value, tb)  PyErr_Fetch(type, value, tb)
1832 #define __Pyx_ErrRestoreInState(tstate, type, value, tb)  PyErr_Restore(type, value, tb)
1833 #define __Pyx_ErrFetchInState(tstate, type, value, tb)  PyErr_Fetch(type, value, tb)
1834 #define __Pyx_ErrRestore(type, value, tb)  PyErr_Restore(type, value, tb)
1835 #define __Pyx_ErrFetch(type, value, tb)  PyErr_Fetch(type, value, tb)
1836 #endif
1837 
1838 /* RaiseException.proto */
1839 static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause);
1840 
1841 /* WriteUnraisableException.proto */
1842 static void __Pyx_WriteUnraisable(const char *name, int clineno,
1843                                   int lineno, const char *filename,
1844                                   int full_traceback, int nogil);
1845 
1846 /* ExtTypeTest.proto */
1847 static CYTHON_INLINE int __Pyx_TypeTest(PyObject *obj, PyTypeObject *type);
1848 
1849 /* IsLittleEndian.proto */
1850 static CYTHON_INLINE int __Pyx_Is_Little_Endian(void);
1851 
1852 /* BufferFormatCheck.proto */
1853 static const char* __Pyx_BufFmt_CheckString(__Pyx_BufFmt_Context* ctx, const char* ts);
1854 static void __Pyx_BufFmt_Init(__Pyx_BufFmt_Context* ctx,
1855                               __Pyx_BufFmt_StackElem* stack,
1856                               __Pyx_TypeInfo* type);
1857 
1858 /* BufferGetAndValidate.proto */
1859 #define __Pyx_GetBufferAndValidate(buf, obj, dtype, flags, nd, cast, stack)\
1860     ((obj == Py_None || obj == NULL) ?\
1861     (__Pyx_ZeroBuffer(buf), 0) :\
1862     __Pyx__GetBufferAndValidate(buf, obj, dtype, flags, nd, cast, stack))
1863 static int  __Pyx__GetBufferAndValidate(Py_buffer* buf, PyObject* obj,
1864     __Pyx_TypeInfo* dtype, int flags, int nd, int cast, __Pyx_BufFmt_StackElem* stack);
1865 static void __Pyx_ZeroBuffer(Py_buffer* buf);
1866 static CYTHON_INLINE void __Pyx_SafeReleaseBuffer(Py_buffer* info);
1867 static Py_ssize_t __Pyx_minusones[] = { -1, -1, -1, -1, -1, -1, -1, -1 };
1868 static Py_ssize_t __Pyx_zeros[] = { 0, 0, 0, 0, 0, 0, 0, 0 };
1869 
1870 /* BufferFallbackError.proto */
1871 static void __Pyx_RaiseBufferFallbackError(void);
1872 
1873 /* PyDictVersioning.proto */
1874 #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_TYPE_SLOTS
1875 #define __PYX_DICT_VERSION_INIT  ((PY_UINT64_T) -1)
1876 #define __PYX_GET_DICT_VERSION(dict)  (((PyDictObject*)(dict))->ma_version_tag)
1877 #define __PYX_UPDATE_DICT_CACHE(dict, value, cache_var, version_var)\
1878     (version_var) = __PYX_GET_DICT_VERSION(dict);\
1879     (cache_var) = (value);
1880 #define __PYX_PY_DICT_LOOKUP_IF_MODIFIED(VAR, DICT, LOOKUP) {\
1881     static PY_UINT64_T __pyx_dict_version = 0;\
1882     static PyObject *__pyx_dict_cached_value = NULL;\
1883     if (likely(__PYX_GET_DICT_VERSION(DICT) == __pyx_dict_version)) {\
1884         (VAR) = __pyx_dict_cached_value;\
1885     } else {\
1886         (VAR) = __pyx_dict_cached_value = (LOOKUP);\
1887         __pyx_dict_version = __PYX_GET_DICT_VERSION(DICT);\
1888     }\
1889 }
1890 static CYTHON_INLINE PY_UINT64_T __Pyx_get_tp_dict_version(PyObject *obj);
1891 static CYTHON_INLINE PY_UINT64_T __Pyx_get_object_dict_version(PyObject *obj);
1892 static CYTHON_INLINE int __Pyx_object_dict_version_matches(PyObject* obj, PY_UINT64_T tp_dict_version, PY_UINT64_T obj_dict_version);
1893 #else
1894 #define __PYX_GET_DICT_VERSION(dict)  (0)
1895 #define __PYX_UPDATE_DICT_CACHE(dict, value, cache_var, version_var)
1896 #define __PYX_PY_DICT_LOOKUP_IF_MODIFIED(VAR, DICT, LOOKUP)  (VAR) = (LOOKUP);
1897 #endif
1898 
1899 /* GetModuleGlobalName.proto */
1900 #if CYTHON_USE_DICT_VERSIONS
1901 #define __Pyx_GetModuleGlobalName(var, name)  {\
1902     static PY_UINT64_T __pyx_dict_version = 0;\
1903     static PyObject *__pyx_dict_cached_value = NULL;\
1904     (var) = (likely(__pyx_dict_version == __PYX_GET_DICT_VERSION(__pyx_d))) ?\
1905         (likely(__pyx_dict_cached_value) ? __Pyx_NewRef(__pyx_dict_cached_value) : __Pyx_GetBuiltinName(name)) :\
1906         __Pyx__GetModuleGlobalName(name, &__pyx_dict_version, &__pyx_dict_cached_value);\
1907 }
1908 #define __Pyx_GetModuleGlobalNameUncached(var, name)  {\
1909     PY_UINT64_T __pyx_dict_version;\
1910     PyObject *__pyx_dict_cached_value;\
1911     (var) = __Pyx__GetModuleGlobalName(name, &__pyx_dict_version, &__pyx_dict_cached_value);\
1912 }
1913 static PyObject *__Pyx__GetModuleGlobalName(PyObject *name, PY_UINT64_T *dict_version, PyObject **dict_cached_value);
1914 #else
1915 #define __Pyx_GetModuleGlobalName(var, name)  (var) = __Pyx__GetModuleGlobalName(name)
1916 #define __Pyx_GetModuleGlobalNameUncached(var, name)  (var) = __Pyx__GetModuleGlobalName(name)
1917 static CYTHON_INLINE PyObject *__Pyx__GetModuleGlobalName(PyObject *name);
1918 #endif
1919 
1920 /* GetItemInt.proto */
1921 #define __Pyx_GetItemInt(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck)\
1922     (__Pyx_fits_Py_ssize_t(i, type, is_signed) ?\
1923     __Pyx_GetItemInt_Fast(o, (Py_ssize_t)i, is_list, wraparound, boundscheck) :\
1924     (is_list ? (PyErr_SetString(PyExc_IndexError, "list index out of range"), (PyObject*)NULL) :\
1925                __Pyx_GetItemInt_Generic(o, to_py_func(i))))
1926 #define __Pyx_GetItemInt_List(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck)\
1927     (__Pyx_fits_Py_ssize_t(i, type, is_signed) ?\
1928     __Pyx_GetItemInt_List_Fast(o, (Py_ssize_t)i, wraparound, boundscheck) :\
1929     (PyErr_SetString(PyExc_IndexError, "list index out of range"), (PyObject*)NULL))
1930 static CYTHON_INLINE PyObject *__Pyx_GetItemInt_List_Fast(PyObject *o, Py_ssize_t i,
1931                                                               int wraparound, int boundscheck);
1932 #define __Pyx_GetItemInt_Tuple(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck)\
1933     (__Pyx_fits_Py_ssize_t(i, type, is_signed) ?\
1934     __Pyx_GetItemInt_Tuple_Fast(o, (Py_ssize_t)i, wraparound, boundscheck) :\
1935     (PyErr_SetString(PyExc_IndexError, "tuple index out of range"), (PyObject*)NULL))
1936 static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Tuple_Fast(PyObject *o, Py_ssize_t i,
1937                                                               int wraparound, int boundscheck);
1938 static PyObject *__Pyx_GetItemInt_Generic(PyObject *o, PyObject* j);
1939 static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Fast(PyObject *o, Py_ssize_t i,
1940                                                      int is_list, int wraparound, int boundscheck);
1941 
1942 /* MemviewSliceInit.proto */
1943 #define __Pyx_BUF_MAX_NDIMS %(BUF_MAX_NDIMS)d
1944 #define __Pyx_MEMVIEW_DIRECT   1
1945 #define __Pyx_MEMVIEW_PTR      2
1946 #define __Pyx_MEMVIEW_FULL     4
1947 #define __Pyx_MEMVIEW_CONTIG   8
1948 #define __Pyx_MEMVIEW_STRIDED  16
1949 #define __Pyx_MEMVIEW_FOLLOW   32
1950 #define __Pyx_IS_C_CONTIG 1
1951 #define __Pyx_IS_F_CONTIG 2
1952 static int __Pyx_init_memviewslice(
1953                 struct __pyx_memoryview_obj *memview,
1954                 int ndim,
1955                 __Pyx_memviewslice *memviewslice,
1956                 int memview_is_new_reference);
1957 static CYTHON_INLINE int __pyx_add_acquisition_count_locked(
1958     __pyx_atomic_int *acquisition_count, PyThread_type_lock lock);
1959 static CYTHON_INLINE int __pyx_sub_acquisition_count_locked(
1960     __pyx_atomic_int *acquisition_count, PyThread_type_lock lock);
1961 #define __pyx_get_slice_count_pointer(memview) (memview->acquisition_count_aligned_p)
1962 #define __pyx_get_slice_count(memview) (*__pyx_get_slice_count_pointer(memview))
1963 #define __PYX_INC_MEMVIEW(slice, have_gil) __Pyx_INC_MEMVIEW(slice, have_gil, __LINE__)
1964 #define __PYX_XDEC_MEMVIEW(slice, have_gil) __Pyx_XDEC_MEMVIEW(slice, have_gil, __LINE__)
1965 static CYTHON_INLINE void __Pyx_INC_MEMVIEW(__Pyx_memviewslice *, int, int);
1966 static CYTHON_INLINE void __Pyx_XDEC_MEMVIEW(__Pyx_memviewslice *, int, int);
1967 
1968 /* RaiseArgTupleInvalid.proto */
1969 static void __Pyx_RaiseArgtupleInvalid(const char* func_name, int exact,
1970     Py_ssize_t num_min, Py_ssize_t num_max, Py_ssize_t num_found);
1971 
1972 /* RaiseDoubleKeywords.proto */
1973 static void __Pyx_RaiseDoubleKeywordsError(const char* func_name, PyObject* kw_name);
1974 
1975 /* ParseKeywords.proto */
1976 static int __Pyx_ParseOptionalKeywords(PyObject *kwds, PyObject **argnames[],\
1977     PyObject *kwds2, PyObject *values[], Py_ssize_t num_pos_args,\
1978     const char* function_name);
1979 
1980 /* None.proto */
1981 static CYTHON_INLINE void __Pyx_RaiseUnboundLocalError(const char *varname);
1982 
1983 /* PyCFunctionFastCall.proto */
1984 #if CYTHON_FAST_PYCCALL
1985 static CYTHON_INLINE PyObject *__Pyx_PyCFunction_FastCall(PyObject *func, PyObject **args, Py_ssize_t nargs);
1986 #else
1987 #define __Pyx_PyCFunction_FastCall(func, args, nargs)  (assert(0), NULL)
1988 #endif
1989 
1990 /* PyFunctionFastCall.proto */
1991 #if CYTHON_FAST_PYCALL
1992 #define __Pyx_PyFunction_FastCall(func, args, nargs)\
1993     __Pyx_PyFunction_FastCallDict((func), (args), (nargs), NULL)
1994 #if 1 || PY_VERSION_HEX < 0x030600B1
1995 static PyObject *__Pyx_PyFunction_FastCallDict(PyObject *func, PyObject **args, Py_ssize_t nargs, PyObject *kwargs);
1996 #else
1997 #define __Pyx_PyFunction_FastCallDict(func, args, nargs, kwargs) _PyFunction_FastCallDict(func, args, nargs, kwargs)
1998 #endif
1999 #define __Pyx_BUILD_ASSERT_EXPR(cond)\
2000     (sizeof(char [1 - 2*!(cond)]) - 1)
2001 #ifndef Py_MEMBER_SIZE
2002 #define Py_MEMBER_SIZE(type, member) sizeof(((type *)0)->member)
2003 #endif
2004   static size_t __pyx_pyframe_localsplus_offset = 0;
2005   #include "frameobject.h"
2006   #define __Pxy_PyFrame_Initialize_Offsets()\
2007     ((void)__Pyx_BUILD_ASSERT_EXPR(sizeof(PyFrameObject) == offsetof(PyFrameObject, f_localsplus) + Py_MEMBER_SIZE(PyFrameObject, f_localsplus)),\
2008      (void)(__pyx_pyframe_localsplus_offset = ((size_t)PyFrame_Type.tp_basicsize) - Py_MEMBER_SIZE(PyFrameObject, f_localsplus)))
2009   #define __Pyx_PyFrame_GetLocalsplus(frame)\
2010     (assert(__pyx_pyframe_localsplus_offset), (PyObject **)(((char *)(frame)) + __pyx_pyframe_localsplus_offset))
2011 #endif
2012 
2013 /* PyObjectCallMethO.proto */
2014 #if CYTHON_COMPILING_IN_CPYTHON
2015 static CYTHON_INLINE PyObject* __Pyx_PyObject_CallMethO(PyObject *func, PyObject *arg);
2016 #endif
2017 
2018 /* PyObjectCallOneArg.proto */
2019 static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg);
2020 
2021 /* PyObjectCall2Args.proto */
2022 static CYTHON_UNUSED PyObject* __Pyx_PyObject_Call2Args(PyObject* function, PyObject* arg1, PyObject* arg2);
2023 
2024 #define __Pyx_BufPtrCContig1d(type, buf, i0, s0) ((type)buf + i0)
2025 /* ObjectGetItem.proto */
2026 #if CYTHON_USE_TYPE_SLOTS
2027 static CYTHON_INLINE PyObject *__Pyx_PyObject_GetItem(PyObject *obj, PyObject* key);
2028 #else
2029 #define __Pyx_PyObject_GetItem(obj, key)  PyObject_GetItem(obj, key)
2030 #endif
2031 
2032 /* GetTopmostException.proto */
2033 #if CYTHON_USE_EXC_INFO_STACK
2034 static _PyErr_StackItem * __Pyx_PyErr_GetTopmostException(PyThreadState *tstate);
2035 #endif
2036 
2037 /* SaveResetException.proto */
2038 #if CYTHON_FAST_THREAD_STATE
2039 #define __Pyx_ExceptionSave(type, value, tb)  __Pyx__ExceptionSave(__pyx_tstate, type, value, tb)
2040 static CYTHON_INLINE void __Pyx__ExceptionSave(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb);
2041 #define __Pyx_ExceptionReset(type, value, tb)  __Pyx__ExceptionReset(__pyx_tstate, type, value, tb)
2042 static CYTHON_INLINE void __Pyx__ExceptionReset(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb);
2043 #else
2044 #define __Pyx_ExceptionSave(type, value, tb)   PyErr_GetExcInfo(type, value, tb)
2045 #define __Pyx_ExceptionReset(type, value, tb)  PyErr_SetExcInfo(type, value, tb)
2046 #endif
2047 
2048 /* PyErrExceptionMatches.proto */
2049 #if CYTHON_FAST_THREAD_STATE
2050 #define __Pyx_PyErr_ExceptionMatches(err) __Pyx_PyErr_ExceptionMatchesInState(__pyx_tstate, err)
2051 static CYTHON_INLINE int __Pyx_PyErr_ExceptionMatchesInState(PyThreadState* tstate, PyObject* err);
2052 #else
2053 #define __Pyx_PyErr_ExceptionMatches(err)  PyErr_ExceptionMatches(err)
2054 #endif
2055 
2056 /* GetException.proto */
2057 #if CYTHON_FAST_THREAD_STATE
2058 #define __Pyx_GetException(type, value, tb)  __Pyx__GetException(__pyx_tstate, type, value, tb)
2059 static int __Pyx__GetException(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb);
2060 #else
2061 static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb);
2062 #endif
2063 
2064 /* ArgTypeTest.proto */
2065 #define __Pyx_ArgTypeTest(obj, type, none_allowed, name, exact)\
2066     ((likely((Py_TYPE(obj) == type) | (none_allowed && (obj == Py_None)))) ? 1 :\
2067         __Pyx__ArgTypeTest(obj, type, name, exact))
2068 static int __Pyx__ArgTypeTest(PyObject *obj, PyTypeObject *type, const char *name, int exact);
2069 
2070 /* IncludeStringH.proto */
2071 #include <string.h>
2072 
2073 /* BytesEquals.proto */
2074 static CYTHON_INLINE int __Pyx_PyBytes_Equals(PyObject* s1, PyObject* s2, int equals);
2075 
2076 /* UnicodeEquals.proto */
2077 static CYTHON_INLINE int __Pyx_PyUnicode_Equals(PyObject* s1, PyObject* s2, int equals);
2078 
2079 /* StrEquals.proto */
2080 #if PY_MAJOR_VERSION >= 3
2081 #define __Pyx_PyString_Equals __Pyx_PyUnicode_Equals
2082 #else
2083 #define __Pyx_PyString_Equals __Pyx_PyBytes_Equals
2084 #endif
2085 
2086 /* None.proto */
2087 static CYTHON_INLINE Py_ssize_t __Pyx_div_Py_ssize_t(Py_ssize_t, Py_ssize_t);
2088 
2089 /* UnaryNegOverflows.proto */
2090 #define UNARY_NEG_WOULD_OVERFLOW(x)\
2091         (((x) < 0) & ((unsigned long)(x) == 0-(unsigned long)(x)))
2092 
2093 static CYTHON_UNUSED int __pyx_array_getbuffer(PyObject *__pyx_v_self, Py_buffer *__pyx_v_info, int __pyx_v_flags); /*proto*/
2094 static PyObject *__pyx_array_get_memview(struct __pyx_array_obj *); /*proto*/
2095 /* GetAttr.proto */
2096 static CYTHON_INLINE PyObject *__Pyx_GetAttr(PyObject *, PyObject *);
2097 
2098 /* decode_c_string_utf16.proto */
__Pyx_PyUnicode_DecodeUTF16(const char * s,Py_ssize_t size,const char * errors)2099 static CYTHON_INLINE PyObject *__Pyx_PyUnicode_DecodeUTF16(const char *s, Py_ssize_t size, const char *errors) {
2100     int byteorder = 0;
2101     return PyUnicode_DecodeUTF16(s, size, errors, &byteorder);
2102 }
__Pyx_PyUnicode_DecodeUTF16LE(const char * s,Py_ssize_t size,const char * errors)2103 static CYTHON_INLINE PyObject *__Pyx_PyUnicode_DecodeUTF16LE(const char *s, Py_ssize_t size, const char *errors) {
2104     int byteorder = -1;
2105     return PyUnicode_DecodeUTF16(s, size, errors, &byteorder);
2106 }
__Pyx_PyUnicode_DecodeUTF16BE(const char * s,Py_ssize_t size,const char * errors)2107 static CYTHON_INLINE PyObject *__Pyx_PyUnicode_DecodeUTF16BE(const char *s, Py_ssize_t size, const char *errors) {
2108     int byteorder = 1;
2109     return PyUnicode_DecodeUTF16(s, size, errors, &byteorder);
2110 }
2111 
2112 /* decode_c_string.proto */
2113 static CYTHON_INLINE PyObject* __Pyx_decode_c_string(
2114          const char* cstring, Py_ssize_t start, Py_ssize_t stop,
2115          const char* encoding, const char* errors,
2116          PyObject* (*decode_func)(const char *s, Py_ssize_t size, const char *errors));
2117 
2118 /* GetAttr3.proto */
2119 static CYTHON_INLINE PyObject *__Pyx_GetAttr3(PyObject *, PyObject *, PyObject *);
2120 
2121 /* RaiseTooManyValuesToUnpack.proto */
2122 static CYTHON_INLINE void __Pyx_RaiseTooManyValuesError(Py_ssize_t expected);
2123 
2124 /* RaiseNeedMoreValuesToUnpack.proto */
2125 static CYTHON_INLINE void __Pyx_RaiseNeedMoreValuesError(Py_ssize_t index);
2126 
2127 /* RaiseNoneIterError.proto */
2128 static CYTHON_INLINE void __Pyx_RaiseNoneNotIterableError(void);
2129 
2130 /* SwapException.proto */
2131 #if CYTHON_FAST_THREAD_STATE
2132 #define __Pyx_ExceptionSwap(type, value, tb)  __Pyx__ExceptionSwap(__pyx_tstate, type, value, tb)
2133 static CYTHON_INLINE void __Pyx__ExceptionSwap(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb);
2134 #else
2135 static CYTHON_INLINE void __Pyx_ExceptionSwap(PyObject **type, PyObject **value, PyObject **tb);
2136 #endif
2137 
2138 /* Import.proto */
2139 static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, int level);
2140 
2141 /* FastTypeChecks.proto */
2142 #if CYTHON_COMPILING_IN_CPYTHON
2143 #define __Pyx_TypeCheck(obj, type) __Pyx_IsSubtype(Py_TYPE(obj), (PyTypeObject *)type)
2144 static CYTHON_INLINE int __Pyx_IsSubtype(PyTypeObject *a, PyTypeObject *b);
2145 static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches(PyObject *err, PyObject *type);
2146 static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches2(PyObject *err, PyObject *type1, PyObject *type2);
2147 #else
2148 #define __Pyx_TypeCheck(obj, type) PyObject_TypeCheck(obj, (PyTypeObject *)type)
2149 #define __Pyx_PyErr_GivenExceptionMatches(err, type) PyErr_GivenExceptionMatches(err, type)
2150 #define __Pyx_PyErr_GivenExceptionMatches2(err, type1, type2) (PyErr_GivenExceptionMatches(err, type1) || PyErr_GivenExceptionMatches(err, type2))
2151 #endif
2152 #define __Pyx_PyException_Check(obj) __Pyx_TypeCheck(obj, PyExc_Exception)
2153 
2154 static CYTHON_UNUSED int __pyx_memoryview_getbuffer(PyObject *__pyx_v_self, Py_buffer *__pyx_v_info, int __pyx_v_flags); /*proto*/
2155 /* ListCompAppend.proto */
2156 #if CYTHON_USE_PYLIST_INTERNALS && CYTHON_ASSUME_SAFE_MACROS
__Pyx_ListComp_Append(PyObject * list,PyObject * x)2157 static CYTHON_INLINE int __Pyx_ListComp_Append(PyObject* list, PyObject* x) {
2158     PyListObject* L = (PyListObject*) list;
2159     Py_ssize_t len = Py_SIZE(list);
2160     if (likely(L->allocated > len)) {
2161         Py_INCREF(x);
2162         PyList_SET_ITEM(list, len, x);
2163         __Pyx_SET_SIZE(list, len + 1);
2164         return 0;
2165     }
2166     return PyList_Append(list, x);
2167 }
2168 #else
2169 #define __Pyx_ListComp_Append(L,x) PyList_Append(L,x)
2170 #endif
2171 
2172 /* PyIntBinop.proto */
2173 #if !CYTHON_COMPILING_IN_PYPY
2174 static PyObject* __Pyx_PyInt_AddObjC(PyObject *op1, PyObject *op2, long intval, int inplace, int zerodivision_check);
2175 #else
2176 #define __Pyx_PyInt_AddObjC(op1, op2, intval, inplace, zerodivision_check)\
2177     (inplace ? PyNumber_InPlaceAdd(op1, op2) : PyNumber_Add(op1, op2))
2178 #endif
2179 
2180 /* ListExtend.proto */
__Pyx_PyList_Extend(PyObject * L,PyObject * v)2181 static CYTHON_INLINE int __Pyx_PyList_Extend(PyObject* L, PyObject* v) {
2182 #if CYTHON_COMPILING_IN_CPYTHON
2183     PyObject* none = _PyList_Extend((PyListObject*)L, v);
2184     if (unlikely(!none))
2185         return -1;
2186     Py_DECREF(none);
2187     return 0;
2188 #else
2189     return PyList_SetSlice(L, PY_SSIZE_T_MAX, PY_SSIZE_T_MAX, v);
2190 #endif
2191 }
2192 
2193 /* ListAppend.proto */
2194 #if CYTHON_USE_PYLIST_INTERNALS && CYTHON_ASSUME_SAFE_MACROS
__Pyx_PyList_Append(PyObject * list,PyObject * x)2195 static CYTHON_INLINE int __Pyx_PyList_Append(PyObject* list, PyObject* x) {
2196     PyListObject* L = (PyListObject*) list;
2197     Py_ssize_t len = Py_SIZE(list);
2198     if (likely(L->allocated > len) & likely(len > (L->allocated >> 1))) {
2199         Py_INCREF(x);
2200         PyList_SET_ITEM(list, len, x);
2201         __Pyx_SET_SIZE(list, len + 1);
2202         return 0;
2203     }
2204     return PyList_Append(list, x);
2205 }
2206 #else
2207 #define __Pyx_PyList_Append(L,x) PyList_Append(L,x)
2208 #endif
2209 
2210 /* None.proto */
2211 static CYTHON_INLINE long __Pyx_div_long(long, long);
2212 
2213 /* ImportFrom.proto */
2214 static PyObject* __Pyx_ImportFrom(PyObject* module, PyObject* name);
2215 
2216 /* HasAttr.proto */
2217 static CYTHON_INLINE int __Pyx_HasAttr(PyObject *, PyObject *);
2218 
2219 /* StringJoin.proto */
2220 #if PY_MAJOR_VERSION < 3
2221 #define __Pyx_PyString_Join __Pyx_PyBytes_Join
2222 #define __Pyx_PyBaseString_Join(s, v) (PyUnicode_CheckExact(s) ? PyUnicode_Join(s, v) : __Pyx_PyBytes_Join(s, v))
2223 #else
2224 #define __Pyx_PyString_Join PyUnicode_Join
2225 #define __Pyx_PyBaseString_Join PyUnicode_Join
2226 #endif
2227 #if CYTHON_COMPILING_IN_CPYTHON
2228     #if PY_MAJOR_VERSION < 3
2229     #define __Pyx_PyBytes_Join _PyString_Join
2230     #else
2231     #define __Pyx_PyBytes_Join _PyBytes_Join
2232     #endif
2233 #else
2234 static CYTHON_INLINE PyObject* __Pyx_PyBytes_Join(PyObject* sep, PyObject* values);
2235 #endif
2236 
2237 /* PyObject_Unicode.proto */
2238 #if PY_MAJOR_VERSION >= 3
2239 #define __Pyx_PyObject_Unicode(obj)\
2240     (likely(PyUnicode_CheckExact(obj)) ? __Pyx_NewRef(obj) : PyObject_Str(obj))
2241 #else
2242 #define __Pyx_PyObject_Unicode(obj)\
2243     (likely(PyUnicode_CheckExact(obj)) ? __Pyx_NewRef(obj) : PyObject_Unicode(obj))
2244 #endif
2245 
2246 /* PyObject_GenericGetAttrNoDict.proto */
2247 #if CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP && PY_VERSION_HEX < 0x03070000
2248 static CYTHON_INLINE PyObject* __Pyx_PyObject_GenericGetAttrNoDict(PyObject* obj, PyObject* attr_name);
2249 #else
2250 #define __Pyx_PyObject_GenericGetAttrNoDict PyObject_GenericGetAttr
2251 #endif
2252 
2253 /* PyObject_GenericGetAttr.proto */
2254 #if CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP && PY_VERSION_HEX < 0x03070000
2255 static PyObject* __Pyx_PyObject_GenericGetAttr(PyObject* obj, PyObject* attr_name);
2256 #else
2257 #define __Pyx_PyObject_GenericGetAttr PyObject_GenericGetAttr
2258 #endif
2259 
2260 /* SetVTable.proto */
2261 static int __Pyx_SetVtable(PyObject *dict, void *vtable);
2262 
2263 /* PyObjectGetAttrStrNoError.proto */
2264 static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStrNoError(PyObject* obj, PyObject* attr_name);
2265 
2266 /* SetupReduce.proto */
2267 static int __Pyx_setup_reduce(PyObject* type_obj);
2268 
2269 /* TypeImport.proto */
2270 #ifndef __PYX_HAVE_RT_ImportType_proto
2271 #define __PYX_HAVE_RT_ImportType_proto
2272 enum __Pyx_ImportType_CheckSize {
2273    __Pyx_ImportType_CheckSize_Error = 0,
2274    __Pyx_ImportType_CheckSize_Warn = 1,
2275    __Pyx_ImportType_CheckSize_Ignore = 2
2276 };
2277 static PyTypeObject *__Pyx_ImportType(PyObject* module, const char *module_name, const char *class_name, size_t size, enum __Pyx_ImportType_CheckSize check_size);
2278 #endif
2279 
2280 /* CLineInTraceback.proto */
2281 #ifdef CYTHON_CLINE_IN_TRACEBACK
2282 #define __Pyx_CLineForTraceback(tstate, c_line)  (((CYTHON_CLINE_IN_TRACEBACK)) ? c_line : 0)
2283 #else
2284 static int __Pyx_CLineForTraceback(PyThreadState *tstate, int c_line);
2285 #endif
2286 
2287 /* CodeObjectCache.proto */
2288 typedef struct {
2289     PyCodeObject* code_object;
2290     int code_line;
2291 } __Pyx_CodeObjectCacheEntry;
2292 struct __Pyx_CodeObjectCache {
2293     int count;
2294     int max_count;
2295     __Pyx_CodeObjectCacheEntry* entries;
2296 };
2297 static struct __Pyx_CodeObjectCache __pyx_code_cache = {0,0,NULL};
2298 static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line);
2299 static PyCodeObject *__pyx_find_code_object(int code_line);
2300 static void __pyx_insert_code_object(int code_line, PyCodeObject* code_object);
2301 
2302 /* AddTraceback.proto */
2303 static void __Pyx_AddTraceback(const char *funcname, int c_line,
2304                                int py_line, const char *filename);
2305 
2306 /* RealImag.proto */
2307 #if CYTHON_CCOMPLEX
2308   #ifdef __cplusplus
2309     #define __Pyx_CREAL(z) ((z).real())
2310     #define __Pyx_CIMAG(z) ((z).imag())
2311   #else
2312     #define __Pyx_CREAL(z) (__real__(z))
2313     #define __Pyx_CIMAG(z) (__imag__(z))
2314   #endif
2315 #else
2316     #define __Pyx_CREAL(z) ((z).real)
2317     #define __Pyx_CIMAG(z) ((z).imag)
2318 #endif
2319 #if defined(__cplusplus) && CYTHON_CCOMPLEX\
2320         && (defined(_WIN32) || defined(__clang__) || (defined(__GNUC__) && (__GNUC__ >= 5 || __GNUC__ == 4 && __GNUC_MINOR__ >= 4 )) || __cplusplus >= 201103)
2321     #define __Pyx_SET_CREAL(z,x) ((z).real(x))
2322     #define __Pyx_SET_CIMAG(z,y) ((z).imag(y))
2323 #else
2324     #define __Pyx_SET_CREAL(z,x) __Pyx_CREAL(z) = (x)
2325     #define __Pyx_SET_CIMAG(z,y) __Pyx_CIMAG(z) = (y)
2326 #endif
2327 
2328 /* Arithmetic.proto */
2329 #if CYTHON_CCOMPLEX
2330     #define __Pyx_c_eq_double(a, b)   ((a)==(b))
2331     #define __Pyx_c_sum_double(a, b)  ((a)+(b))
2332     #define __Pyx_c_diff_double(a, b) ((a)-(b))
2333     #define __Pyx_c_prod_double(a, b) ((a)*(b))
2334     #define __Pyx_c_quot_double(a, b) ((a)/(b))
2335     #define __Pyx_c_neg_double(a)     (-(a))
2336   #ifdef __cplusplus
2337     #define __Pyx_c_is_zero_double(z) ((z)==(double)0)
2338     #define __Pyx_c_conj_double(z)    (::std::conj(z))
2339     #if 1
2340         #define __Pyx_c_abs_double(z)     (::std::abs(z))
2341         #define __Pyx_c_pow_double(a, b)  (::std::pow(a, b))
2342     #endif
2343   #else
2344     #define __Pyx_c_is_zero_double(z) ((z)==0)
2345     #define __Pyx_c_conj_double(z)    (conj(z))
2346     #if 1
2347         #define __Pyx_c_abs_double(z)     (cabs(z))
2348         #define __Pyx_c_pow_double(a, b)  (cpow(a, b))
2349     #endif
2350  #endif
2351 #else
2352     static CYTHON_INLINE int __Pyx_c_eq_double(__pyx_t_double_complex, __pyx_t_double_complex);
2353     static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_sum_double(__pyx_t_double_complex, __pyx_t_double_complex);
2354     static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_diff_double(__pyx_t_double_complex, __pyx_t_double_complex);
2355     static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_prod_double(__pyx_t_double_complex, __pyx_t_double_complex);
2356     static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_quot_double(__pyx_t_double_complex, __pyx_t_double_complex);
2357     static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_neg_double(__pyx_t_double_complex);
2358     static CYTHON_INLINE int __Pyx_c_is_zero_double(__pyx_t_double_complex);
2359     static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_conj_double(__pyx_t_double_complex);
2360     #if 1
2361         static CYTHON_INLINE double __Pyx_c_abs_double(__pyx_t_double_complex);
2362         static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_pow_double(__pyx_t_double_complex, __pyx_t_double_complex);
2363     #endif
2364 #endif
2365 
2366 #if PY_MAJOR_VERSION < 3
2367     static int __Pyx_GetBuffer(PyObject *obj, Py_buffer *view, int flags);
2368     static void __Pyx_ReleaseBuffer(Py_buffer *view);
2369 #else
2370     #define __Pyx_GetBuffer PyObject_GetBuffer
2371     #define __Pyx_ReleaseBuffer PyBuffer_Release
2372 #endif
2373 
2374 
2375 /* BufferStructDeclare.proto */
2376 typedef struct {
2377   Py_ssize_t shape, strides, suboffsets;
2378 } __Pyx_Buf_DimInfo;
2379 typedef struct {
2380   size_t refcount;
2381   Py_buffer pybuffer;
2382 } __Pyx_Buffer;
2383 typedef struct {
2384   __Pyx_Buffer *rcbuffer;
2385   char *data;
2386   __Pyx_Buf_DimInfo diminfo[8];
2387 } __Pyx_LocalBuf_ND;
2388 
2389 /* MemviewSliceIsContig.proto */
2390 static int __pyx_memviewslice_is_contig(const __Pyx_memviewslice mvs, char order, int ndim);
2391 
2392 /* OverlappingSlices.proto */
2393 static int __pyx_slices_overlap(__Pyx_memviewslice *slice1,
2394                                 __Pyx_memviewslice *slice2,
2395                                 int ndim, size_t itemsize);
2396 
2397 /* Capsule.proto */
2398 static CYTHON_INLINE PyObject *__pyx_capsule_create(void *p, const char *sig);
2399 
2400 /* GCCDiagnostics.proto */
2401 #if defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6))
2402 #define __Pyx_HAS_GCC_DIAGNOSTIC
2403 #endif
2404 
2405 /* TypeInfoCompare.proto */
2406 static int __pyx_typeinfo_cmp(__Pyx_TypeInfo *a, __Pyx_TypeInfo *b);
2407 
2408 /* MemviewSliceValidateAndInit.proto */
2409 static int __Pyx_ValidateAndInit_memviewslice(
2410                 int *axes_specs,
2411                 int c_or_f_flag,
2412                 int buf_flags,
2413                 int ndim,
2414                 __Pyx_TypeInfo *dtype,
2415                 __Pyx_BufFmt_StackElem stack[],
2416                 __Pyx_memviewslice *memviewslice,
2417                 PyObject *original_obj);
2418 
2419 /* ObjectToMemviewSlice.proto */
2420 static CYTHON_INLINE __Pyx_memviewslice __Pyx_PyObject_to_MemoryviewSlice_dcd____pyx_t_double_complex(PyObject *, int writable_flag);
2421 
2422 /* FromPy.proto */
2423 static __pyx_t_double_complex __Pyx_PyComplex_As___pyx_t_double_complex(PyObject*);
2424 
2425 /* ObjectToMemviewSlice.proto */
2426 static CYTHON_INLINE __Pyx_memviewslice __Pyx_PyObject_to_MemoryviewSlice_dc_double(PyObject *, int writable_flag);
2427 
2428 /* CppExceptionConversion.proto */
2429 #ifndef __Pyx_CppExn2PyErr
2430 #include <new>
2431 #include <typeinfo>
2432 #include <stdexcept>
2433 #include <ios>
__Pyx_CppExn2PyErr()2434 static void __Pyx_CppExn2PyErr() {
2435   try {
2436     if (PyErr_Occurred())
2437       ; // let the latest Python exn pass through and ignore the current one
2438     else
2439       throw;
2440   } catch (const std::bad_alloc& exn) {
2441     PyErr_SetString(PyExc_MemoryError, exn.what());
2442   } catch (const std::bad_cast& exn) {
2443     PyErr_SetString(PyExc_TypeError, exn.what());
2444   } catch (const std::bad_typeid& exn) {
2445     PyErr_SetString(PyExc_TypeError, exn.what());
2446   } catch (const std::domain_error& exn) {
2447     PyErr_SetString(PyExc_ValueError, exn.what());
2448   } catch (const std::invalid_argument& exn) {
2449     PyErr_SetString(PyExc_ValueError, exn.what());
2450   } catch (const std::ios_base::failure& exn) {
2451     PyErr_SetString(PyExc_IOError, exn.what());
2452   } catch (const std::out_of_range& exn) {
2453     PyErr_SetString(PyExc_IndexError, exn.what());
2454   } catch (const std::overflow_error& exn) {
2455     PyErr_SetString(PyExc_OverflowError, exn.what());
2456   } catch (const std::range_error& exn) {
2457     PyErr_SetString(PyExc_ArithmeticError, exn.what());
2458   } catch (const std::underflow_error& exn) {
2459     PyErr_SetString(PyExc_ArithmeticError, exn.what());
2460   } catch (const std::exception& exn) {
2461     PyErr_SetString(PyExc_RuntimeError, exn.what());
2462   }
2463   catch (...)
2464   {
2465     PyErr_SetString(PyExc_RuntimeError, "Unknown exception");
2466   }
2467 }
2468 #endif
2469 
2470 /* None.proto */
2471 static CYTHON_INLINE Py_ssize_t __Pyx_pow_Py_ssize_t(Py_ssize_t, Py_ssize_t);
2472 
2473 /* MemviewDtypeToObject.proto */
2474 static CYTHON_INLINE PyObject *__pyx_memview_get_double(const char *itemp);
2475 static CYTHON_INLINE int __pyx_memview_set_double(const char *itemp, PyObject *obj);
2476 
2477 /* None.proto */
2478 static CYTHON_INLINE long __Pyx_pow_long(long, long);
2479 
2480 /* Arithmetic.proto */
2481 #if CYTHON_CCOMPLEX
2482     #define __Pyx_c_eq_float(a, b)   ((a)==(b))
2483     #define __Pyx_c_sum_float(a, b)  ((a)+(b))
2484     #define __Pyx_c_diff_float(a, b) ((a)-(b))
2485     #define __Pyx_c_prod_float(a, b) ((a)*(b))
2486     #define __Pyx_c_quot_float(a, b) ((a)/(b))
2487     #define __Pyx_c_neg_float(a)     (-(a))
2488   #ifdef __cplusplus
2489     #define __Pyx_c_is_zero_float(z) ((z)==(float)0)
2490     #define __Pyx_c_conj_float(z)    (::std::conj(z))
2491     #if 1
2492         #define __Pyx_c_abs_float(z)     (::std::abs(z))
2493         #define __Pyx_c_pow_float(a, b)  (::std::pow(a, b))
2494     #endif
2495   #else
2496     #define __Pyx_c_is_zero_float(z) ((z)==0)
2497     #define __Pyx_c_conj_float(z)    (conjf(z))
2498     #if 1
2499         #define __Pyx_c_abs_float(z)     (cabsf(z))
2500         #define __Pyx_c_pow_float(a, b)  (cpowf(a, b))
2501     #endif
2502  #endif
2503 #else
2504     static CYTHON_INLINE int __Pyx_c_eq_float(__pyx_t_float_complex, __pyx_t_float_complex);
2505     static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_sum_float(__pyx_t_float_complex, __pyx_t_float_complex);
2506     static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_diff_float(__pyx_t_float_complex, __pyx_t_float_complex);
2507     static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_prod_float(__pyx_t_float_complex, __pyx_t_float_complex);
2508     static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_quot_float(__pyx_t_float_complex, __pyx_t_float_complex);
2509     static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_neg_float(__pyx_t_float_complex);
2510     static CYTHON_INLINE int __Pyx_c_is_zero_float(__pyx_t_float_complex);
2511     static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_conj_float(__pyx_t_float_complex);
2512     #if 1
2513         static CYTHON_INLINE float __Pyx_c_abs_float(__pyx_t_float_complex);
2514         static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_pow_float(__pyx_t_float_complex, __pyx_t_float_complex);
2515     #endif
2516 #endif
2517 
2518 /* MemviewSliceCopyTemplate.proto */
2519 static __Pyx_memviewslice
2520 __pyx_memoryview_copy_new_contig(const __Pyx_memviewslice *from_mvs,
2521                                  const char *mode, int ndim,
2522                                  size_t sizeof_dtype, int contig_flag,
2523                                  int dtype_is_object);
2524 
2525 /* CIntFromPy.proto */
2526 static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *);
2527 
2528 /* TypeInfoToFormat.proto */
2529 struct __pyx_typeinfo_string {
2530     char string[3];
2531 };
2532 static struct __pyx_typeinfo_string __Pyx_TypeInfoToFormat(__Pyx_TypeInfo *type);
2533 
2534 /* CIntFromPy.proto */
2535 static CYTHON_INLINE unsigned int __Pyx_PyInt_As_unsigned_int(PyObject *);
2536 
2537 /* CIntToPy.proto */
2538 static CYTHON_INLINE PyObject* __Pyx_PyInt_From_int(int value);
2539 
2540 /* CIntFromPy.proto */
2541 static CYTHON_INLINE size_t __Pyx_PyInt_As_size_t(PyObject *);
2542 
2543 /* CIntToPy.proto */
2544 static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value);
2545 
2546 /* CIntToPy.proto */
2547 static CYTHON_INLINE PyObject* __Pyx_PyInt_From_unsigned_int(unsigned int value);
2548 
2549 /* CIntFromPy.proto */
2550 static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *);
2551 
2552 /* CIntFromPy.proto */
2553 static CYTHON_INLINE char __Pyx_PyInt_As_char(PyObject *);
2554 
2555 /* ObjectToMemviewSlice.proto */
2556 static CYTHON_INLINE __Pyx_memviewslice __Pyx_PyObject_to_MemoryviewSlice_dc___pyx_t_double_complex(PyObject *, int writable_flag);
2557 
2558 /* ObjectToMemviewSlice.proto */
2559 static CYTHON_INLINE __Pyx_memviewslice __Pyx_PyObject_to_MemoryviewSlice_dc_int(PyObject *, int writable_flag);
2560 
2561 /* ObjectToMemviewSlice.proto */
2562 static CYTHON_INLINE __Pyx_memviewslice __Pyx_PyObject_to_MemoryviewSlice_d_dc___pyx_t_double_complex(PyObject *, int writable_flag);
2563 
2564 /* ObjectToMemviewSlice.proto */
2565 static CYTHON_INLINE __Pyx_memviewslice __Pyx_PyObject_to_MemoryviewSlice_ds_long(PyObject *, int writable_flag);
2566 
2567 /* CheckBinaryVersion.proto */
2568 static int __Pyx_check_binary_version(void);
2569 
2570 /* FunctionExport.proto */
2571 static int __Pyx_ExportFunction(const char *name, void (*f)(void), const char *sig);
2572 
2573 /* FunctionImport.proto */
2574 static int __Pyx_ImportFunction(PyObject *module, const char *funcname, void (**f)(void), const char *sig);
2575 
2576 /* InitStrings.proto */
2577 static int __Pyx_InitStrings(__Pyx_StringTabEntry *t);
2578 
2579 static PyObject *__pyx_array_get_memview(struct __pyx_array_obj *__pyx_v_self); /* proto*/
2580 static char *__pyx_memoryview_get_item_pointer(struct __pyx_memoryview_obj *__pyx_v_self, PyObject *__pyx_v_index); /* proto*/
2581 static PyObject *__pyx_memoryview_is_slice(struct __pyx_memoryview_obj *__pyx_v_self, PyObject *__pyx_v_obj); /* proto*/
2582 static PyObject *__pyx_memoryview_setitem_slice_assignment(struct __pyx_memoryview_obj *__pyx_v_self, PyObject *__pyx_v_dst, PyObject *__pyx_v_src); /* proto*/
2583 static PyObject *__pyx_memoryview_setitem_slice_assign_scalar(struct __pyx_memoryview_obj *__pyx_v_self, struct __pyx_memoryview_obj *__pyx_v_dst, PyObject *__pyx_v_value); /* proto*/
2584 static PyObject *__pyx_memoryview_setitem_indexed(struct __pyx_memoryview_obj *__pyx_v_self, PyObject *__pyx_v_index, PyObject *__pyx_v_value); /* proto*/
2585 static PyObject *__pyx_memoryview_convert_item_to_object(struct __pyx_memoryview_obj *__pyx_v_self, char *__pyx_v_itemp); /* proto*/
2586 static PyObject *__pyx_memoryview_assign_item_from_object(struct __pyx_memoryview_obj *__pyx_v_self, char *__pyx_v_itemp, PyObject *__pyx_v_value); /* proto*/
2587 static PyObject *__pyx_memoryviewslice_convert_item_to_object(struct __pyx_memoryviewslice_obj *__pyx_v_self, char *__pyx_v_itemp); /* proto*/
2588 static PyObject *__pyx_memoryviewslice_assign_item_from_object(struct __pyx_memoryviewslice_obj *__pyx_v_self, char *__pyx_v_itemp, PyObject *__pyx_v_value); /* proto*/
2589 
2590 /* Module declarations from 'cpython.buffer' */
2591 
2592 /* Module declarations from 'libc.string' */
2593 
2594 /* Module declarations from 'libc.stdio' */
2595 
2596 /* Module declarations from '__builtin__' */
2597 
2598 /* Module declarations from 'cpython.type' */
2599 static PyTypeObject *__pyx_ptype_7cpython_4type_type = 0;
2600 
2601 /* Module declarations from 'cpython' */
2602 
2603 /* Module declarations from 'cpython.object' */
2604 
2605 /* Module declarations from 'cpython.ref' */
2606 
2607 /* Module declarations from 'cpython.mem' */
2608 
2609 /* Module declarations from 'numpy' */
2610 
2611 /* Module declarations from 'numpy' */
2612 static PyTypeObject *__pyx_ptype_5numpy_dtype = 0;
2613 static PyTypeObject *__pyx_ptype_5numpy_flatiter = 0;
2614 static PyTypeObject *__pyx_ptype_5numpy_broadcast = 0;
2615 static PyTypeObject *__pyx_ptype_5numpy_ndarray = 0;
2616 static PyTypeObject *__pyx_ptype_5numpy_ufunc = 0;
2617 static CYTHON_INLINE int __pyx_f_5numpy_import_array(void); /*proto*/
2618 
2619 /* Module declarations from 'scipy.linalg.cython_lapack' */
2620 static void (*__pyx_f_5scipy_6linalg_13cython_lapack_zgeev)(char *, char *, int *, __pyx_t_double_complex *, int *, __pyx_t_double_complex *, __pyx_t_double_complex *, int *, __pyx_t_double_complex *, int *, __pyx_t_double_complex *, int *, __pyx_t_5scipy_6linalg_13cython_lapack_d *, int *); /*proto*/
2621 static void (*__pyx_f_5scipy_6linalg_13cython_lapack_zheevr)(char *, char *, char *, int *, __pyx_t_double_complex *, int *, __pyx_t_5scipy_6linalg_13cython_lapack_d *, __pyx_t_5scipy_6linalg_13cython_lapack_d *, int *, int *, __pyx_t_5scipy_6linalg_13cython_lapack_d *, int *, __pyx_t_5scipy_6linalg_13cython_lapack_d *, __pyx_t_double_complex *, int *, int *, __pyx_t_double_complex *, int *, __pyx_t_5scipy_6linalg_13cython_lapack_d *, int *, int *, int *, int *); /*proto*/
2622 
2623 /* Module declarations from 'scipy.linalg.cython_blas' */
2624 static void (*__pyx_f_5scipy_6linalg_11cython_blas_zaxpy)(int *, __pyx_t_double_complex *, __pyx_t_double_complex *, int *, __pyx_t_double_complex *, int *); /*proto*/
2625 static void (*__pyx_f_5scipy_6linalg_11cython_blas_zgemm)(char *, char *, int *, int *, int *, __pyx_t_double_complex *, __pyx_t_double_complex *, int *, __pyx_t_double_complex *, int *, __pyx_t_double_complex *, __pyx_t_double_complex *, int *); /*proto*/
2626 static void (*__pyx_f_5scipy_6linalg_11cython_blas_zgemv)(char *, int *, int *, __pyx_t_double_complex *, __pyx_t_double_complex *, int *, __pyx_t_double_complex *, int *, __pyx_t_double_complex *, __pyx_t_double_complex *, int *); /*proto*/
2627 
2628 /* Module declarations from 'qutip.cy.sparse_structs' */
2629 
2630 /* Module declarations from 'qutip.cy.spmath' */
2631 static int (*__pyx_f_5qutip_2cy_6spmath__safe_multiply)(int, int); /*proto*/
2632 static void (*__pyx_f_5qutip_2cy_6spmath__zcsr_add)(__pyx_t_5qutip_2cy_14sparse_structs_CSR_Matrix *, __pyx_t_5qutip_2cy_14sparse_structs_CSR_Matrix *, __pyx_t_5qutip_2cy_14sparse_structs_CSR_Matrix *, __pyx_t_double_complex); /*proto*/
2633 static void (*__pyx_f_5qutip_2cy_6spmath__zcsr_mult)(__pyx_t_5qutip_2cy_14sparse_structs_CSR_Matrix *, __pyx_t_5qutip_2cy_14sparse_structs_CSR_Matrix *, __pyx_t_5qutip_2cy_14sparse_structs_CSR_Matrix *); /*proto*/
2634 static void (*__pyx_f_5qutip_2cy_6spmath__zcsr_kron)(__pyx_t_5qutip_2cy_14sparse_structs_CSR_Matrix *, __pyx_t_5qutip_2cy_14sparse_structs_CSR_Matrix *, __pyx_t_5qutip_2cy_14sparse_structs_CSR_Matrix *); /*proto*/
2635 static void (*__pyx_f_5qutip_2cy_6spmath__zcsr_kron_core)(__pyx_t_double_complex *, int *, int *, __pyx_t_double_complex *, int *, int *, __pyx_t_5qutip_2cy_14sparse_structs_CSR_Matrix *, int, int, int); /*proto*/
2636 static void (*__pyx_f_5qutip_2cy_6spmath__zcsr_transpose)(__pyx_t_5qutip_2cy_14sparse_structs_CSR_Matrix *, __pyx_t_5qutip_2cy_14sparse_structs_CSR_Matrix *); /*proto*/
2637 static void (*__pyx_f_5qutip_2cy_6spmath__zcsr_adjoint)(__pyx_t_5qutip_2cy_14sparse_structs_CSR_Matrix *, __pyx_t_5qutip_2cy_14sparse_structs_CSR_Matrix *); /*proto*/
2638 
2639 /* Module declarations from 'qutip.cy.spconvert' */
2640 static void (*__pyx_f_5qutip_2cy_9spconvert_fdense2D_to_CSR)(__Pyx_memviewslice, __pyx_t_5qutip_2cy_14sparse_structs_CSR_Matrix *, unsigned int, unsigned int); /*proto*/
2641 
2642 /* Module declarations from 'cython.view' */
2643 static struct __pyx_array_obj *__pyx_array_new(PyObject *, Py_ssize_t, char *, char *, char *); /*proto*/
2644 
2645 /* Module declarations from 'cython' */
2646 
2647 /* Module declarations from 'libcpp' */
2648 
2649 /* Module declarations from 'qutip.cy.spmatfuncs' */
2650 static void (*__pyx_f_5qutip_2cy_10spmatfuncs_spmvpy)(__pyx_t_double_complex *, int *, int *, __pyx_t_double_complex *, __pyx_t_double_complex, __pyx_t_double_complex *, unsigned int); /*proto*/
2651 
2652 /* Module declarations from 'libc.math' */
2653 
2654 /* Module declarations from 'libc.float' */
2655 
2656 /* Module declarations from 'libcpp.vector' */
2657 
2658 /* Module declarations from 'libcpp.algorithm' */
2659 
2660 /* Module declarations from 'qutip.cy.brtools' */
2661 static PyTypeObject *__pyx_array_type = 0;
2662 static PyTypeObject *__pyx_MemviewEnum_type = 0;
2663 static PyTypeObject *__pyx_memoryview_type = 0;
2664 static PyTypeObject *__pyx_memoryviewslice_type = 0;
2665 static int __pyx_v_5qutip_2cy_7brtools_use_zgeev;
2666 static PyObject *generic = 0;
2667 static PyObject *strided = 0;
2668 static PyObject *indirect = 0;
2669 static PyObject *contiguous = 0;
2670 static PyObject *indirect_contiguous = 0;
2671 static int __pyx_memoryview_thread_locks_used;
2672 static PyThread_type_lock __pyx_memoryview_thread_locks[8];
2673 static void __pyx_f_5qutip_2cy_7brtools_dense_add_mult(__Pyx_memviewslice, __Pyx_memviewslice, __pyx_t_double_complex, int __pyx_skip_dispatch); /*proto*/
2674 static __Pyx_memviewslice __pyx_f_5qutip_2cy_7brtools_dense_to_eigbasis(__Pyx_memviewslice, __Pyx_memviewslice, unsigned int, double); /*proto*/
2675 static CYTHON_INLINE void __pyx_f_5qutip_2cy_7brtools_vec2mat_index(int, int, int *); /*proto*/
2676 static void __pyx_f_5qutip_2cy_7brtools_raise_error_CSR(int, struct __pyx_opt_args_5qutip_2cy_7brtools_raise_error_CSR *__pyx_optional_args); /*proto*/
2677 static void __pyx_f_5qutip_2cy_7brtools_raise_error_COO(int, struct __pyx_opt_args_5qutip_2cy_7brtools_raise_error_COO *__pyx_optional_args); /*proto*/
2678 static CYTHON_INLINE int __pyx_f_5qutip_2cy_7brtools_int_min(int, int); /*proto*/
2679 static void __pyx_f_5qutip_2cy_7brtools_init_CSR(__pyx_t_5qutip_2cy_14sparse_structs_CSR_Matrix *, int, int, struct __pyx_opt_args_5qutip_2cy_7brtools_init_CSR *__pyx_optional_args); /*proto*/
2680 static void __pyx_f_5qutip_2cy_7brtools_init_COO(__pyx_t_5qutip_2cy_14sparse_structs_COO_Matrix *, int, int, struct __pyx_opt_args_5qutip_2cy_7brtools_init_COO *__pyx_optional_args); /*proto*/
2681 static void __pyx_f_5qutip_2cy_7brtools_free_CSR(__pyx_t_5qutip_2cy_14sparse_structs_CSR_Matrix *); /*proto*/
2682 static void __pyx_f_5qutip_2cy_7brtools_free_COO(__pyx_t_5qutip_2cy_14sparse_structs_COO_Matrix *); /*proto*/
2683 static PyObject *__pyx_f_5qutip_2cy_7brtools_CSR_to_scipy(__pyx_t_5qutip_2cy_14sparse_structs_CSR_Matrix *); /*proto*/
2684 static void __pyx_f_5qutip_2cy_7brtools_COO_to_CSR(__pyx_t_5qutip_2cy_14sparse_structs_CSR_Matrix *, __pyx_t_5qutip_2cy_14sparse_structs_COO_Matrix *); /*proto*/
2685 static int __pyx_f_5qutip_2cy_7brtools_ind_sort(__pyx_t_5qutip_2cy_7brtools_data_ind_pair, __pyx_t_5qutip_2cy_7brtools_data_ind_pair); /*proto*/
2686 static void __pyx_f_5qutip_2cy_7brtools_sort_indices(__pyx_t_5qutip_2cy_14sparse_structs_CSR_Matrix *); /*proto*/
2687 static void __pyx_f_5qutip_2cy_7brtools_identity_CSR(__pyx_t_5qutip_2cy_14sparse_structs_CSR_Matrix *, unsigned int); /*proto*/
2688 static void __pyx_f_5qutip_2cy_7brtools_ZGEEV(__Pyx_memviewslice, double *, __Pyx_memviewslice, int); /*proto*/
2689 static __pyx_t_double_complex *__pyx_f_5qutip_2cy_7brtools_ZGEMM(__pyx_t_double_complex *, __pyx_t_double_complex *, int, int, int, int, struct __pyx_opt_args_5qutip_2cy_7brtools_ZGEMM *__pyx_optional_args); /*proto*/
2690 static PyObject *__pyx_f_5qutip_2cy_7brtools_cop_super_term(__Pyx_memviewslice, __Pyx_memviewslice, __pyx_t_double_complex, unsigned int, double, int __pyx_skip_dispatch); /*proto*/
2691 static struct __pyx_array_obj *__pyx_array_new(PyObject *, Py_ssize_t, char *, char *, char *); /*proto*/
2692 static void *__pyx_align_pointer(void *, size_t); /*proto*/
2693 static PyObject *__pyx_memoryview_new(PyObject *, int, int, __Pyx_TypeInfo *); /*proto*/
2694 static CYTHON_INLINE int __pyx_memoryview_check(PyObject *); /*proto*/
2695 static PyObject *_unellipsify(PyObject *, int); /*proto*/
2696 static PyObject *assert_direct_dimensions(Py_ssize_t *, int); /*proto*/
2697 static struct __pyx_memoryview_obj *__pyx_memview_slice(struct __pyx_memoryview_obj *, PyObject *); /*proto*/
2698 static int __pyx_memoryview_slice_memviewslice(__Pyx_memviewslice *, Py_ssize_t, Py_ssize_t, Py_ssize_t, int, int, int *, Py_ssize_t, Py_ssize_t, Py_ssize_t, int, int, int, int); /*proto*/
2699 static char *__pyx_pybuffer_index(Py_buffer *, char *, Py_ssize_t, Py_ssize_t); /*proto*/
2700 static int __pyx_memslice_transpose(__Pyx_memviewslice *); /*proto*/
2701 static PyObject *__pyx_memoryview_fromslice(__Pyx_memviewslice, int, PyObject *(*)(char *), int (*)(char *, PyObject *), int); /*proto*/
2702 static __Pyx_memviewslice *__pyx_memoryview_get_slice_from_memoryview(struct __pyx_memoryview_obj *, __Pyx_memviewslice *); /*proto*/
2703 static void __pyx_memoryview_slice_copy(struct __pyx_memoryview_obj *, __Pyx_memviewslice *); /*proto*/
2704 static PyObject *__pyx_memoryview_copy_object(struct __pyx_memoryview_obj *); /*proto*/
2705 static PyObject *__pyx_memoryview_copy_object_from_slice(struct __pyx_memoryview_obj *, __Pyx_memviewslice *); /*proto*/
2706 static Py_ssize_t abs_py_ssize_t(Py_ssize_t); /*proto*/
2707 static char __pyx_get_best_slice_order(__Pyx_memviewslice *, int); /*proto*/
2708 static void _copy_strided_to_strided(char *, Py_ssize_t *, char *, Py_ssize_t *, Py_ssize_t *, Py_ssize_t *, int, size_t); /*proto*/
2709 static void copy_strided_to_strided(__Pyx_memviewslice *, __Pyx_memviewslice *, int, size_t); /*proto*/
2710 static Py_ssize_t __pyx_memoryview_slice_get_size(__Pyx_memviewslice *, int); /*proto*/
2711 static Py_ssize_t __pyx_fill_contig_strides_array(Py_ssize_t *, Py_ssize_t *, Py_ssize_t, int, char); /*proto*/
2712 static void *__pyx_memoryview_copy_data_to_temp(__Pyx_memviewslice *, __Pyx_memviewslice *, char, int); /*proto*/
2713 static int __pyx_memoryview_err_extents(int, Py_ssize_t, Py_ssize_t); /*proto*/
2714 static int __pyx_memoryview_err_dim(PyObject *, char *, int); /*proto*/
2715 static int __pyx_memoryview_err(PyObject *, char *); /*proto*/
2716 static int __pyx_memoryview_copy_contents(__Pyx_memviewslice, __Pyx_memviewslice, int, int, int); /*proto*/
2717 static void __pyx_memoryview_broadcast_leading(__Pyx_memviewslice *, int, int); /*proto*/
2718 static void __pyx_memoryview_refcount_copying(__Pyx_memviewslice *, int, int, int); /*proto*/
2719 static void __pyx_memoryview_refcount_objects_in_slice_with_gil(char *, Py_ssize_t *, Py_ssize_t *, int, int); /*proto*/
2720 static void __pyx_memoryview_refcount_objects_in_slice(char *, Py_ssize_t *, Py_ssize_t *, int, int); /*proto*/
2721 static void __pyx_memoryview_slice_assign_scalar(__Pyx_memviewslice *, int, size_t, void *, int); /*proto*/
2722 static void __pyx_memoryview__slice_assign_scalar(char *, Py_ssize_t *, Py_ssize_t *, int, size_t, void *); /*proto*/
2723 static PyObject *__pyx_unpickle_Enum__set_state(struct __pyx_MemviewEnum_obj *, PyObject *); /*proto*/
2724 static PyObject *__pyx_format_from_typeinfo(__Pyx_TypeInfo *); /*proto*/
2725 static __Pyx_TypeInfo __Pyx_TypeInfo___pyx_t_double_complex = { "double complex", NULL, sizeof(__pyx_t_double_complex), { 0 }, 0, 'C', 0, 0 };
2726 static __Pyx_TypeInfo __Pyx_TypeInfo_int = { "int", NULL, sizeof(int), { 0 }, 0, IS_UNSIGNED(int) ? 'U' : 'I', IS_UNSIGNED(int), 0 };
2727 static __Pyx_TypeInfo __Pyx_TypeInfo_double = { "double", NULL, sizeof(double), { 0 }, 0, 'R', 0, 0 };
2728 static __Pyx_TypeInfo __Pyx_TypeInfo_long = { "long", NULL, sizeof(long), { 0 }, 0, IS_UNSIGNED(long) ? 'U' : 'I', IS_UNSIGNED(long), 0 };
2729 #define __Pyx_MODULE_NAME "qutip.cy.brtools"
2730 extern int __pyx_module_is_main_qutip__cy__brtools;
2731 int __pyx_module_is_main_qutip__cy__brtools = 0;
2732 
2733 /* Implementation of 'qutip.cy.brtools' */
2734 static PyObject *__pyx_builtin_MemoryError;
2735 static PyObject *__pyx_builtin_range;
2736 static PyObject *__pyx_builtin_ImportError;
2737 static PyObject *__pyx_builtin_ValueError;
2738 static PyObject *__pyx_builtin_enumerate;
2739 static PyObject *__pyx_builtin_TypeError;
2740 static PyObject *__pyx_builtin_Ellipsis;
2741 static PyObject *__pyx_builtin_id;
2742 static PyObject *__pyx_builtin_IndexError;
2743 static const char __pyx_k_A[] = "A";
2744 static const char __pyx_k_B[] = "B";
2745 static const char __pyx_k_O[] = "O";
2746 static const char __pyx_k_T[] = "T{";
2747   static const char __pyx_k_c[] = "c";
2748   static const char __pyx_k_s[] = "(%s)";
2749   static const char __pyx_k_id[] = "id";
2750   static const char __pyx_k_ii[] = "ii";
2751   static const char __pyx_k_jj[] = "jj";
2752   static const char __pyx_k_np[] = "np";
2753   static const char __pyx_k__39[] = "^";
2754   static const char __pyx_k__40[] = "";
2755   static const char __pyx_k__41[] = ":";
2756 static const char __pyx_k__42[] = "}";
2757 static const char __pyx_k__43[] = ",";
2758 static const char __pyx_k_ans[] = "ans";
2759 static const char __pyx_k_col[] = "col";
2760 static const char __pyx_k_cop[] = "cop";
2761 static const char __pyx_k_idx[] = "idx";
2762 static const char __pyx_k_ind[] = "ind";
2763 static const char __pyx_k_new[] = "__new__";
2764 static const char __pyx_k_nnz[] = "nnz";
2765 static const char __pyx_k_obj[] = "obj";
2766 static const char __pyx_k_ptr[] = "ptr";
2767 static const char __pyx_k_row[] = "row";
2768 static const char __pyx_k_atol[] = "atol";
2769 static const char __pyx_k_base[] = "base";
2770 static const char __pyx_k_data[] = "data";
2771 static const char __pyx_k_dict[] = "__dict__";
2772 static const char __pyx_k_join[] = "join";
2773 static const char __pyx_k_main[] = "__main__";
2774 static const char __pyx_k_mode[] = "mode";
2775 static const char __pyx_k_name[] = "name";
2776 static const char __pyx_k_ndim[] = "ndim";
2777 static const char __pyx_k_pack[] = "pack";
2778 static const char __pyx_k_size[] = "size";
2779 static const char __pyx_k_step[] = "step";
2780 static const char __pyx_k_stop[] = "stop";
2781 static const char __pyx_k_test[] = "__test__";
2782 static const char __pyx_k_val1[] = "val1";
2783 static const char __pyx_k_val2[] = "val2";
2784 static const char __pyx_k_ASCII[] = "ASCII";
2785 static const char __pyx_k_alpha[] = "alpha";
2786 static const char __pyx_k_array[] = "array";
2787 static const char __pyx_k_class[] = "__class__";
2788 static const char __pyx_k_diags[] = "diags";
2789 static const char __pyx_k_dtype[] = "dtype";
2790 static const char __pyx_k_empty[] = "empty";
2791 static const char __pyx_k_error[] = "error";
2792 static const char __pyx_k_evecs[] = "evecs";
2793 static const char __pyx_k_flags[] = "flags";
2794 static const char __pyx_k_int32[] = "int32";
2795 static const char __pyx_k_nrows[] = "nrows";
2796 static const char __pyx_k_numpy[] = "numpy";
2797 static const char __pyx_k_range[] = "range";
2798 static const char __pyx_k_shape[] = "shape";
2799 static const char __pyx_k_start[] = "start";
2800 static const char __pyx_k_encode[] = "encode";
2801 static const char __pyx_k_format[] = "format";
2802 static const char __pyx_k_import[] = "__import__";
2803 static const char __pyx_k_indptr[] = "indptr";
2804 static const char __pyx_k_name_2[] = "__name__";
2805 static const char __pyx_k_pickle[] = "pickle";
2806 static const char __pyx_k_reduce[] = "__reduce__";
2807 static const char __pyx_k_struct[] = "struct";
2808 static const char __pyx_k_unpack[] = "unpack";
2809 static const char __pyx_k_update[] = "update";
2810 static const char __pyx_k_argsort[] = "argsort";
2811 static const char __pyx_k_fortran[] = "fortran";
2812 static const char __pyx_k_indices[] = "indices";
2813 static const char __pyx_k_memview[] = "memview";
2814 static const char __pyx_k_Ellipsis[] = "Ellipsis";
2815 static const char __pyx_k_getstate[] = "__getstate__";
2816 static const char __pyx_k_itemsize[] = "itemsize";
2817 static const char __pyx_k_pyx_type[] = "__pyx_type";
2818 static const char __pyx_k_setstate[] = "__setstate__";
2819 static const char __pyx_k_TypeError[] = "TypeError";
2820 static const char __pyx_k_enumerate[] = "enumerate";
2821 static const char __pyx_k_pyx_state[] = "__pyx_state";
2822 static const char __pyx_k_reduce_ex[] = "__reduce_ex__";
2823 static const char __pyx_k_IndexError[] = "IndexError";
2824 static const char __pyx_k_ValueError[] = "ValueError";
2825 static const char __pyx_k_coo_matrix[] = "coo_matrix";
2826 static const char __pyx_k_pyx_result[] = "__pyx_result";
2827 static const char __pyx_k_pyx_vtable[] = "__pyx_vtable__";
2828 static const char __pyx_k_ImportError[] = "ImportError";
2829 static const char __pyx_k_MemoryError[] = "MemoryError";
2830 static const char __pyx_k_PickleError[] = "PickleError";
2831 static const char __pyx_k_eigh_unsafe[] = "eigh_unsafe";
2832 static const char __pyx_k_pyx_checksum[] = "__pyx_checksum";
2833 static const char __pyx_k_scipy_sparse[] = "scipy.sparse";
2834 static const char __pyx_k_stringsource[] = "stringsource";
2835 static const char __pyx_k_pyx_getbuffer[] = "__pyx_getbuffer";
2836 static const char __pyx_k_reduce_cython[] = "__reduce_cython__";
2837 static const char __pyx_k_qutip_settings[] = "qutip.settings";
2838 static const char __pyx_k_View_MemoryView[] = "View.MemoryView";
2839 static const char __pyx_k_allocate_buffer[] = "allocate_buffer";
2840 static const char __pyx_k_dtype_is_object[] = "dtype_is_object";
2841 static const char __pyx_k_fast_csr_matrix[] = "fast_csr_matrix";
2842 static const char __pyx_k_pyx_PickleError[] = "__pyx_PickleError";
2843 static const char __pyx_k_setstate_cython[] = "__setstate_cython__";
2844 static const char __pyx_k_qutip_cy_brtools[] = "qutip.cy.brtools";
2845 static const char __pyx_k_qutip_fastsparse[] = "qutip.fastsparse";
2846 static const char __pyx_k_pyx_unpickle_Enum[] = "__pyx_unpickle_Enum";
2847 static const char __pyx_k_cline_in_traceback[] = "cline_in_traceback";
2848 static const char __pyx_k_liou_from_diag_ham[] = "liou_from_diag_ham";
2849 static const char __pyx_k_strided_and_direct[] = "<strided and direct>";
2850 static const char __pyx_k_Error_in_Cython_code[] = "Error in Cython code.";
2851 static const char __pyx_k_Error_in_parameter_s[] = "Error in parameter : %s";
2852 static const char __pyx_k_Invalid_transA_value[] = "Invalid transA value.";
2853 static const char __pyx_k_Invalid_transB_value[] = "Invalid transB value.";
2854 static const char __pyx_k_qutip_cy_brtools_pyx[] = "qutip/cy/brtools.pyx";
2855 static const char __pyx_k_strided_and_indirect[] = "<strided and indirect>";
2856 static const char __pyx_k_contiguous_and_direct[] = "<contiguous and direct>";
2857 static const char __pyx_k_MemoryView_of_r_object[] = "<MemoryView of %r object>";
2858 static const char __pyx_k_MemoryView_of_r_at_0x_x[] = "<MemoryView of %r at 0x%x>";
2859 static const char __pyx_k_contiguous_and_indirect[] = "<contiguous and indirect>";
2860 static const char __pyx_k_Cannot_index_with_type_s[] = "Cannot index with type '%s'";
2861 static const char __pyx_k_Could_not_allocate_memory[] = "Could not allocate memory.";
2862 static const char __pyx_k_Invalid_shape_in_axis_d_d[] = "Invalid shape in axis %d: %d.";
2863 static const char __pyx_k_itemsize_0_for_cython_array[] = "itemsize <= 0 for cython.array";
2864 static const char __pyx_k_Algorithm_failed_to_converge[] = "Algorithm failed to converge";
2865 static const char __pyx_k_COO_Matrix_cannot_be_expanded[] = "COO_Matrix cannot be expanded.";
2866 static const char __pyx_k_COO_Matrix_is_not_initialized[] = "COO_Matrix is not initialized.";
2867 static const char __pyx_k_CSR_Matrix_cannot_be_expanded[] = "CSR_Matrix cannot be expanded.";
2868 static const char __pyx_k_CSR_Matrix_is_not_initialized[] = "CSR_Matrix is not initialized.";
2869 static const char __pyx_k_unable_to_allocate_array_data[] = "unable to allocate array data.";
2870 static const char __pyx_k_NumPy_already_has_lock_on_data[] = "NumPy already has lock on data.";
2871 static const char __pyx_k_strided_and_direct_or_indirect[] = "<strided and direct or indirect>";
2872 static const char __pyx_k_numpy_core_multiarray_failed_to[] = "numpy.core.multiarray failed to import";
2873 static const char __pyx_k_Buffer_view_does_not_expose_stri[] = "Buffer view does not expose strides";
2874 static const char __pyx_k_Can_only_create_a_buffer_that_is[] = "Can only create a buffer that is contiguous in memory.";
2875 static const char __pyx_k_Cannot_assign_to_read_only_memor[] = "Cannot assign to read-only memoryview";
2876 static const char __pyx_k_Cannot_create_writable_memory_vi[] = "Cannot create writable memory view from read-only memoryview";
2877 static const char __pyx_k_Cannot_expand_data_structures_pa[] = "Cannot expand data structures past max_length.";
2878 static const char __pyx_k_Data_length_cannot_be_larger_tha[] = "Data length cannot be larger than max_length";
2879 static const char __pyx_k_Empty_shape_tuple_for_cython_arr[] = "Empty shape tuple for cython.array";
2880 static const char __pyx_k_Error_manipulating_COO_Matrix_st[] = "Error manipulating COO_Matrix structure.";
2881 static const char __pyx_k_Error_manipulating_CSR_Matrix_st[] = "Error manipulating CSR_Matrix structure.";
2882 static const char __pyx_k_Incompatible_checksums_s_vs_0xb0[] = "Incompatible checksums (%s vs 0xb068931 = (name))";
2883 static const char __pyx_k_Indirect_dimensions_not_supporte[] = "Indirect dimensions not supported";
2884 static const char __pyx_k_Invalid_mode_expected_c_or_fortr[] = "Invalid mode, expected 'c' or 'fortran', got %s";
2885 static const char __pyx_k_Out_of_bounds_on_buffer_access_a[] = "Out of bounds on buffer access (axis %d)";
2886 static const char __pyx_k_Unable_to_convert_item_to_object[] = "Unable to convert item to object";
2887 static const char __pyx_k_got_differing_extents_in_dimensi[] = "got differing extents in dimension %d (got %d and %d)";
2888 static const char __pyx_k_no_default___reduce___due_to_non[] = "no default __reduce__ due to non-trivial __cinit__";
2889 static const char __pyx_k_numpy_core_umath_failed_to_impor[] = "numpy.core.umath failed to import";
2890 static const char __pyx_k_unable_to_allocate_shape_and_str[] = "unable to allocate shape and strides.";
2891 static PyObject *__pyx_n_s_A;
2892 static PyObject *__pyx_n_s_ASCII;
2893 static PyObject *__pyx_kp_u_Algorithm_failed_to_converge;
2894 static PyObject *__pyx_n_s_B;
2895 static PyObject *__pyx_kp_s_Buffer_view_does_not_expose_stri;
2896 static PyObject *__pyx_kp_u_COO_Matrix_cannot_be_expanded;
2897 static PyObject *__pyx_kp_u_COO_Matrix_is_not_initialized;
2898 static PyObject *__pyx_kp_u_CSR_Matrix_cannot_be_expanded;
2899 static PyObject *__pyx_kp_u_CSR_Matrix_is_not_initialized;
2900 static PyObject *__pyx_kp_s_Can_only_create_a_buffer_that_is;
2901 static PyObject *__pyx_kp_s_Cannot_assign_to_read_only_memor;
2902 static PyObject *__pyx_kp_s_Cannot_create_writable_memory_vi;
2903 static PyObject *__pyx_kp_u_Cannot_expand_data_structures_pa;
2904 static PyObject *__pyx_kp_s_Cannot_index_with_type_s;
2905 static PyObject *__pyx_kp_u_Could_not_allocate_memory;
2906 static PyObject *__pyx_kp_u_Data_length_cannot_be_larger_tha;
2907 static PyObject *__pyx_n_s_Ellipsis;
2908 static PyObject *__pyx_kp_s_Empty_shape_tuple_for_cython_arr;
2909 static PyObject *__pyx_kp_u_Error_in_Cython_code;
2910 static PyObject *__pyx_kp_u_Error_in_parameter_s;
2911 static PyObject *__pyx_kp_u_Error_manipulating_COO_Matrix_st;
2912 static PyObject *__pyx_kp_u_Error_manipulating_CSR_Matrix_st;
2913 static PyObject *__pyx_n_s_ImportError;
2914 static PyObject *__pyx_kp_s_Incompatible_checksums_s_vs_0xb0;
2915 static PyObject *__pyx_n_s_IndexError;
2916 static PyObject *__pyx_kp_s_Indirect_dimensions_not_supporte;
2917 static PyObject *__pyx_kp_s_Invalid_mode_expected_c_or_fortr;
2918 static PyObject *__pyx_kp_s_Invalid_shape_in_axis_d_d;
2919 static PyObject *__pyx_kp_u_Invalid_transA_value;
2920 static PyObject *__pyx_kp_u_Invalid_transB_value;
2921 static PyObject *__pyx_n_s_MemoryError;
2922 static PyObject *__pyx_kp_s_MemoryView_of_r_at_0x_x;
2923 static PyObject *__pyx_kp_s_MemoryView_of_r_object;
2924 static PyObject *__pyx_kp_u_NumPy_already_has_lock_on_data;
2925 static PyObject *__pyx_n_b_O;
2926 static PyObject *__pyx_kp_s_Out_of_bounds_on_buffer_access_a;
2927 static PyObject *__pyx_n_s_PickleError;
2928 static PyObject *__pyx_kp_b_T;
2929 static PyObject *__pyx_n_s_TypeError;
2930 static PyObject *__pyx_kp_s_Unable_to_convert_item_to_object;
2931 static PyObject *__pyx_n_s_ValueError;
2932 static PyObject *__pyx_n_s_View_MemoryView;
2933 static PyObject *__pyx_kp_b__39;
2934 static PyObject *__pyx_kp_b__40;
2935 static PyObject *__pyx_kp_b__41;
2936 static PyObject *__pyx_kp_b__42;
2937 static PyObject *__pyx_kp_u__43;
2938 static PyObject *__pyx_n_s_allocate_buffer;
2939 static PyObject *__pyx_n_s_alpha;
2940 static PyObject *__pyx_n_s_ans;
2941 static PyObject *__pyx_n_s_argsort;
2942 static PyObject *__pyx_n_s_array;
2943 static PyObject *__pyx_n_s_atol;
2944 static PyObject *__pyx_n_s_base;
2945 static PyObject *__pyx_n_s_c;
2946 static PyObject *__pyx_n_u_c;
2947 static PyObject *__pyx_n_s_class;
2948 static PyObject *__pyx_n_s_cline_in_traceback;
2949 static PyObject *__pyx_n_s_col;
2950 static PyObject *__pyx_kp_s_contiguous_and_direct;
2951 static PyObject *__pyx_kp_s_contiguous_and_indirect;
2952 static PyObject *__pyx_n_s_coo_matrix;
2953 static PyObject *__pyx_n_s_cop;
2954 static PyObject *__pyx_n_s_data;
2955 static PyObject *__pyx_n_s_diags;
2956 static PyObject *__pyx_n_s_dict;
2957 static PyObject *__pyx_n_s_dtype;
2958 static PyObject *__pyx_n_s_dtype_is_object;
2959 static PyObject *__pyx_n_s_eigh_unsafe;
2960 static PyObject *__pyx_n_s_empty;
2961 static PyObject *__pyx_n_s_encode;
2962 static PyObject *__pyx_n_s_enumerate;
2963 static PyObject *__pyx_n_s_error;
2964 static PyObject *__pyx_n_s_evecs;
2965 static PyObject *__pyx_n_s_fast_csr_matrix;
2966 static PyObject *__pyx_n_s_flags;
2967 static PyObject *__pyx_n_s_format;
2968 static PyObject *__pyx_n_s_fortran;
2969 static PyObject *__pyx_n_u_fortran;
2970 static PyObject *__pyx_n_s_getstate;
2971 static PyObject *__pyx_kp_s_got_differing_extents_in_dimensi;
2972 static PyObject *__pyx_n_s_id;
2973 static PyObject *__pyx_n_s_idx;
2974 static PyObject *__pyx_n_s_ii;
2975 static PyObject *__pyx_n_s_import;
2976 static PyObject *__pyx_n_s_ind;
2977 static PyObject *__pyx_n_s_indices;
2978 static PyObject *__pyx_n_s_indptr;
2979 static PyObject *__pyx_n_s_int32;
2980 static PyObject *__pyx_n_s_itemsize;
2981 static PyObject *__pyx_kp_s_itemsize_0_for_cython_array;
2982 static PyObject *__pyx_n_s_jj;
2983 static PyObject *__pyx_n_s_join;
2984 static PyObject *__pyx_n_s_liou_from_diag_ham;
2985 static PyObject *__pyx_n_s_main;
2986 static PyObject *__pyx_n_s_memview;
2987 static PyObject *__pyx_n_s_mode;
2988 static PyObject *__pyx_n_s_name;
2989 static PyObject *__pyx_n_s_name_2;
2990 static PyObject *__pyx_n_s_ndim;
2991 static PyObject *__pyx_n_s_new;
2992 static PyObject *__pyx_n_s_nnz;
2993 static PyObject *__pyx_kp_s_no_default___reduce___due_to_non;
2994 static PyObject *__pyx_n_s_np;
2995 static PyObject *__pyx_n_s_nrows;
2996 static PyObject *__pyx_n_s_numpy;
2997 static PyObject *__pyx_kp_u_numpy_core_multiarray_failed_to;
2998 static PyObject *__pyx_kp_u_numpy_core_umath_failed_to_impor;
2999 static PyObject *__pyx_n_s_obj;
3000 static PyObject *__pyx_n_s_pack;
3001 static PyObject *__pyx_n_s_pickle;
3002 static PyObject *__pyx_n_s_ptr;
3003 static PyObject *__pyx_n_s_pyx_PickleError;
3004 static PyObject *__pyx_n_s_pyx_checksum;
3005 static PyObject *__pyx_n_s_pyx_getbuffer;
3006 static PyObject *__pyx_n_s_pyx_result;
3007 static PyObject *__pyx_n_s_pyx_state;
3008 static PyObject *__pyx_n_s_pyx_type;
3009 static PyObject *__pyx_n_s_pyx_unpickle_Enum;
3010 static PyObject *__pyx_n_s_pyx_vtable;
3011 static PyObject *__pyx_n_s_qutip_cy_brtools;
3012 static PyObject *__pyx_kp_s_qutip_cy_brtools_pyx;
3013 static PyObject *__pyx_n_s_qutip_fastsparse;
3014 static PyObject *__pyx_n_s_qutip_settings;
3015 static PyObject *__pyx_n_s_range;
3016 static PyObject *__pyx_n_s_reduce;
3017 static PyObject *__pyx_n_s_reduce_cython;
3018 static PyObject *__pyx_n_s_reduce_ex;
3019 static PyObject *__pyx_n_s_row;
3020 static PyObject *__pyx_kp_u_s;
3021 static PyObject *__pyx_n_s_scipy_sparse;
3022 static PyObject *__pyx_n_s_setstate;
3023 static PyObject *__pyx_n_s_setstate_cython;
3024 static PyObject *__pyx_n_s_shape;
3025 static PyObject *__pyx_n_s_size;
3026 static PyObject *__pyx_n_s_start;
3027 static PyObject *__pyx_n_s_step;
3028 static PyObject *__pyx_n_s_stop;
3029 static PyObject *__pyx_kp_s_strided_and_direct;
3030 static PyObject *__pyx_kp_s_strided_and_direct_or_indirect;
3031 static PyObject *__pyx_kp_s_strided_and_indirect;
3032 static PyObject *__pyx_kp_s_stringsource;
3033 static PyObject *__pyx_n_s_struct;
3034 static PyObject *__pyx_n_s_test;
3035 static PyObject *__pyx_kp_s_unable_to_allocate_array_data;
3036 static PyObject *__pyx_kp_s_unable_to_allocate_shape_and_str;
3037 static PyObject *__pyx_n_s_unpack;
3038 static PyObject *__pyx_n_s_update;
3039 static PyObject *__pyx_n_s_val1;
3040 static PyObject *__pyx_n_s_val2;
3041 static PyObject *__pyx_pf_5qutip_2cy_7brtools_dense_add_mult(CYTHON_UNUSED PyObject *__pyx_self, __Pyx_memviewslice __pyx_v_A, __Pyx_memviewslice __pyx_v_B, __pyx_t_double_complex __pyx_v_alpha); /* proto */
3042 static PyObject *__pyx_pf_5qutip_2cy_7brtools_2liou_from_diag_ham(CYTHON_UNUSED PyObject *__pyx_self, __Pyx_memviewslice __pyx_v_diags); /* proto */
3043 static PyObject *__pyx_pf_5qutip_2cy_7brtools_4cop_super_term(CYTHON_UNUSED PyObject *__pyx_self, __Pyx_memviewslice __pyx_v_cop, __Pyx_memviewslice __pyx_v_evecs, __pyx_t_double_complex __pyx_v_alpha, unsigned int __pyx_v_nrows, double __pyx_v_atol); /* proto */
3044 static int __pyx_array___pyx_pf_15View_dot_MemoryView_5array___cinit__(struct __pyx_array_obj *__pyx_v_self, PyObject *__pyx_v_shape, Py_ssize_t __pyx_v_itemsize, PyObject *__pyx_v_format, PyObject *__pyx_v_mode, int __pyx_v_allocate_buffer); /* proto */
3045 static int __pyx_array___pyx_pf_15View_dot_MemoryView_5array_2__getbuffer__(struct __pyx_array_obj *__pyx_v_self, Py_buffer *__pyx_v_info, int __pyx_v_flags); /* proto */
3046 static void __pyx_array___pyx_pf_15View_dot_MemoryView_5array_4__dealloc__(struct __pyx_array_obj *__pyx_v_self); /* proto */
3047 static PyObject *__pyx_pf_15View_dot_MemoryView_5array_7memview___get__(struct __pyx_array_obj *__pyx_v_self); /* proto */
3048 static Py_ssize_t __pyx_array___pyx_pf_15View_dot_MemoryView_5array_6__len__(struct __pyx_array_obj *__pyx_v_self); /* proto */
3049 static PyObject *__pyx_array___pyx_pf_15View_dot_MemoryView_5array_8__getattr__(struct __pyx_array_obj *__pyx_v_self, PyObject *__pyx_v_attr); /* proto */
3050 static PyObject *__pyx_array___pyx_pf_15View_dot_MemoryView_5array_10__getitem__(struct __pyx_array_obj *__pyx_v_self, PyObject *__pyx_v_item); /* proto */
3051 static int __pyx_array___pyx_pf_15View_dot_MemoryView_5array_12__setitem__(struct __pyx_array_obj *__pyx_v_self, PyObject *__pyx_v_item, PyObject *__pyx_v_value); /* proto */
3052 static PyObject *__pyx_pf___pyx_array___reduce_cython__(CYTHON_UNUSED struct __pyx_array_obj *__pyx_v_self); /* proto */
3053 static PyObject *__pyx_pf___pyx_array_2__setstate_cython__(CYTHON_UNUSED struct __pyx_array_obj *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v___pyx_state); /* proto */
3054 static int __pyx_MemviewEnum___pyx_pf_15View_dot_MemoryView_4Enum___init__(struct __pyx_MemviewEnum_obj *__pyx_v_self, PyObject *__pyx_v_name); /* proto */
3055 static PyObject *__pyx_MemviewEnum___pyx_pf_15View_dot_MemoryView_4Enum_2__repr__(struct __pyx_MemviewEnum_obj *__pyx_v_self); /* proto */
3056 static PyObject *__pyx_pf___pyx_MemviewEnum___reduce_cython__(struct __pyx_MemviewEnum_obj *__pyx_v_self); /* proto */
3057 static PyObject *__pyx_pf___pyx_MemviewEnum_2__setstate_cython__(struct __pyx_MemviewEnum_obj *__pyx_v_self, PyObject *__pyx_v___pyx_state); /* proto */
3058 static int __pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview___cinit__(struct __pyx_memoryview_obj *__pyx_v_self, PyObject *__pyx_v_obj, int __pyx_v_flags, int __pyx_v_dtype_is_object); /* proto */
3059 static void __pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_2__dealloc__(struct __pyx_memoryview_obj *__pyx_v_self); /* proto */
3060 static PyObject *__pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_4__getitem__(struct __pyx_memoryview_obj *__pyx_v_self, PyObject *__pyx_v_index); /* proto */
3061 static int __pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_6__setitem__(struct __pyx_memoryview_obj *__pyx_v_self, PyObject *__pyx_v_index, PyObject *__pyx_v_value); /* proto */
3062 static int __pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_8__getbuffer__(struct __pyx_memoryview_obj *__pyx_v_self, Py_buffer *__pyx_v_info, int __pyx_v_flags); /* proto */
3063 static PyObject *__pyx_pf_15View_dot_MemoryView_10memoryview_1T___get__(struct __pyx_memoryview_obj *__pyx_v_self); /* proto */
3064 static PyObject *__pyx_pf_15View_dot_MemoryView_10memoryview_4base___get__(struct __pyx_memoryview_obj *__pyx_v_self); /* proto */
3065 static PyObject *__pyx_pf_15View_dot_MemoryView_10memoryview_5shape___get__(struct __pyx_memoryview_obj *__pyx_v_self); /* proto */
3066 static PyObject *__pyx_pf_15View_dot_MemoryView_10memoryview_7strides___get__(struct __pyx_memoryview_obj *__pyx_v_self); /* proto */
3067 static PyObject *__pyx_pf_15View_dot_MemoryView_10memoryview_10suboffsets___get__(struct __pyx_memoryview_obj *__pyx_v_self); /* proto */
3068 static PyObject *__pyx_pf_15View_dot_MemoryView_10memoryview_4ndim___get__(struct __pyx_memoryview_obj *__pyx_v_self); /* proto */
3069 static PyObject *__pyx_pf_15View_dot_MemoryView_10memoryview_8itemsize___get__(struct __pyx_memoryview_obj *__pyx_v_self); /* proto */
3070 static PyObject *__pyx_pf_15View_dot_MemoryView_10memoryview_6nbytes___get__(struct __pyx_memoryview_obj *__pyx_v_self); /* proto */
3071 static PyObject *__pyx_pf_15View_dot_MemoryView_10memoryview_4size___get__(struct __pyx_memoryview_obj *__pyx_v_self); /* proto */
3072 static Py_ssize_t __pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_10__len__(struct __pyx_memoryview_obj *__pyx_v_self); /* proto */
3073 static PyObject *__pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_12__repr__(struct __pyx_memoryview_obj *__pyx_v_self); /* proto */
3074 static PyObject *__pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_14__str__(struct __pyx_memoryview_obj *__pyx_v_self); /* proto */
3075 static PyObject *__pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_16is_c_contig(struct __pyx_memoryview_obj *__pyx_v_self); /* proto */
3076 static PyObject *__pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_18is_f_contig(struct __pyx_memoryview_obj *__pyx_v_self); /* proto */
3077 static PyObject *__pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_20copy(struct __pyx_memoryview_obj *__pyx_v_self); /* proto */
3078 static PyObject *__pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_22copy_fortran(struct __pyx_memoryview_obj *__pyx_v_self); /* proto */
3079 static PyObject *__pyx_pf___pyx_memoryview___reduce_cython__(CYTHON_UNUSED struct __pyx_memoryview_obj *__pyx_v_self); /* proto */
3080 static PyObject *__pyx_pf___pyx_memoryview_2__setstate_cython__(CYTHON_UNUSED struct __pyx_memoryview_obj *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v___pyx_state); /* proto */
3081 static void __pyx_memoryviewslice___pyx_pf_15View_dot_MemoryView_16_memoryviewslice___dealloc__(struct __pyx_memoryviewslice_obj *__pyx_v_self); /* proto */
3082 static PyObject *__pyx_pf_15View_dot_MemoryView_16_memoryviewslice_4base___get__(struct __pyx_memoryviewslice_obj *__pyx_v_self); /* proto */
3083 static PyObject *__pyx_pf___pyx_memoryviewslice___reduce_cython__(CYTHON_UNUSED struct __pyx_memoryviewslice_obj *__pyx_v_self); /* proto */
3084 static PyObject *__pyx_pf___pyx_memoryviewslice_2__setstate_cython__(CYTHON_UNUSED struct __pyx_memoryviewslice_obj *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v___pyx_state); /* proto */
3085 static PyObject *__pyx_pf_15View_dot_MemoryView___pyx_unpickle_Enum(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v___pyx_type, long __pyx_v___pyx_checksum, PyObject *__pyx_v___pyx_state); /* proto */
3086 static PyObject *__pyx_tp_new_array(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
3087 static PyObject *__pyx_tp_new_Enum(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
3088 static PyObject *__pyx_tp_new_memoryview(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
3089 static PyObject *__pyx_tp_new__memoryviewslice(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
3090 static PyObject *__pyx_int_0;
3091 static PyObject *__pyx_int_1;
3092 static PyObject *__pyx_int_184977713;
3093 static PyObject *__pyx_int_neg_1;
3094 static __pyx_t_double_complex __pyx_k__13;
3095 static __pyx_t_double_complex __pyx_k__14;
3096 static __pyx_t_double_complex __pyx_k__17;
3097 static __pyx_t_double_complex __pyx_k__18;
3098 static PyObject *__pyx_tuple_;
3099 static PyObject *__pyx_tuple__2;
3100 static PyObject *__pyx_tuple__3;
3101 static PyObject *__pyx_tuple__4;
3102 static PyObject *__pyx_tuple__5;
3103 static PyObject *__pyx_tuple__6;
3104 static PyObject *__pyx_tuple__7;
3105 static PyObject *__pyx_tuple__8;
3106 static PyObject *__pyx_tuple__9;
3107 static PyObject *__pyx_slice__35;
3108 static PyObject *__pyx_tuple__10;
3109 static PyObject *__pyx_tuple__11;
3110 static PyObject *__pyx_tuple__12;
3111 static PyObject *__pyx_tuple__15;
3112 static PyObject *__pyx_tuple__16;
3113 static PyObject *__pyx_tuple__19;
3114 static PyObject *__pyx_tuple__20;
3115 static PyObject *__pyx_tuple__21;
3116 static PyObject *__pyx_tuple__22;
3117 static PyObject *__pyx_tuple__23;
3118 static PyObject *__pyx_tuple__24;
3119 static PyObject *__pyx_tuple__25;
3120 static PyObject *__pyx_tuple__26;
3121 static PyObject *__pyx_tuple__27;
3122 static PyObject *__pyx_tuple__28;
3123 static PyObject *__pyx_tuple__29;
3124 static PyObject *__pyx_tuple__30;
3125 static PyObject *__pyx_tuple__31;
3126 static PyObject *__pyx_tuple__32;
3127 static PyObject *__pyx_tuple__33;
3128 static PyObject *__pyx_tuple__34;
3129 static PyObject *__pyx_tuple__36;
3130 static PyObject *__pyx_tuple__37;
3131 static PyObject *__pyx_tuple__38;
3132 static PyObject *__pyx_tuple__44;
3133 static PyObject *__pyx_tuple__46;
3134 static PyObject *__pyx_tuple__47;
3135 static PyObject *__pyx_tuple__48;
3136 static PyObject *__pyx_tuple__49;
3137 static PyObject *__pyx_tuple__50;
3138 static PyObject *__pyx_tuple__51;
3139 static PyObject *__pyx_codeobj__45;
3140 static PyObject *__pyx_codeobj__52;
3141 /* Late includes */
3142 
3143 /* "qutip/cy/sparse_routines.pxi":62
3144  *
3145  *
3146  * cdef void raise_error_CSR(int E, CSR_Matrix * C = NULL):             # <<<<<<<<<<<<<<
3147  *     if not C.numpy_lock and C != NULL:
3148  *         free_CSR(C)
3149  */
3150 
__pyx_f_5qutip_2cy_7brtools_raise_error_CSR(int __pyx_v_E,struct __pyx_opt_args_5qutip_2cy_7brtools_raise_error_CSR * __pyx_optional_args)3151 static void __pyx_f_5qutip_2cy_7brtools_raise_error_CSR(int __pyx_v_E, struct __pyx_opt_args_5qutip_2cy_7brtools_raise_error_CSR *__pyx_optional_args) {
3152   __pyx_t_5qutip_2cy_14sparse_structs_CSR_Matrix *__pyx_v_C = ((__pyx_t_5qutip_2cy_14sparse_structs_CSR_Matrix *)NULL);
3153   __Pyx_RefNannyDeclarations
3154   int __pyx_t_1;
3155   int __pyx_t_2;
3156   PyObject *__pyx_t_3 = NULL;
3157   int __pyx_lineno = 0;
3158   const char *__pyx_filename = NULL;
3159   int __pyx_clineno = 0;
3160   __Pyx_RefNannySetupContext("raise_error_CSR", 0);
3161   if (__pyx_optional_args) {
3162     if (__pyx_optional_args->__pyx_n > 0) {
3163       __pyx_v_C = __pyx_optional_args->C;
3164     }
3165   }
3166 
3167   /* "qutip/cy/sparse_routines.pxi":63
3168  *
3169  * cdef void raise_error_CSR(int E, CSR_Matrix * C = NULL):
3170  *     if not C.numpy_lock and C != NULL:             # <<<<<<<<<<<<<<
3171  *         free_CSR(C)
3172  *     if E == -1:
3173  */
3174   __pyx_t_2 = ((!(__pyx_v_C->numpy_lock != 0)) != 0);
3175   if (__pyx_t_2) {
3176   } else {
3177     __pyx_t_1 = __pyx_t_2;
3178     goto __pyx_L4_bool_binop_done;
3179   }
3180   __pyx_t_2 = ((__pyx_v_C != NULL) != 0);
3181   __pyx_t_1 = __pyx_t_2;
3182   __pyx_L4_bool_binop_done:;
3183   if (__pyx_t_1) {
3184 
3185     /* "qutip/cy/sparse_routines.pxi":64
3186  * cdef void raise_error_CSR(int E, CSR_Matrix * C = NULL):
3187  *     if not C.numpy_lock and C != NULL:
3188  *         free_CSR(C)             # <<<<<<<<<<<<<<
3189  *     if E == -1:
3190  *         raise MemoryError('Could not allocate memory.')
3191  */
3192     __pyx_f_5qutip_2cy_7brtools_free_CSR(__pyx_v_C);
3193 
3194     /* "qutip/cy/sparse_routines.pxi":63
3195  *
3196  * cdef void raise_error_CSR(int E, CSR_Matrix * C = NULL):
3197  *     if not C.numpy_lock and C != NULL:             # <<<<<<<<<<<<<<
3198  *         free_CSR(C)
3199  *     if E == -1:
3200  */
3201   }
3202 
3203   /* "qutip/cy/sparse_routines.pxi":65
3204  *     if not C.numpy_lock and C != NULL:
3205  *         free_CSR(C)
3206  *     if E == -1:             # <<<<<<<<<<<<<<
3207  *         raise MemoryError('Could not allocate memory.')
3208  *     elif E == -2:
3209  */
3210   switch (__pyx_v_E) {
3211     case -1L:
3212 
3213     /* "qutip/cy/sparse_routines.pxi":66
3214  *         free_CSR(C)
3215  *     if E == -1:
3216  *         raise MemoryError('Could not allocate memory.')             # <<<<<<<<<<<<<<
3217  *     elif E == -2:
3218  *         raise Exception('Error manipulating CSR_Matrix structure.')
3219  */
3220     __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_MemoryError, __pyx_tuple_, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 66, __pyx_L1_error)
3221     __Pyx_GOTREF(__pyx_t_3);
3222     __Pyx_Raise(__pyx_t_3, 0, 0, 0);
3223     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
3224     __PYX_ERR(0, 66, __pyx_L1_error)
3225 
3226     /* "qutip/cy/sparse_routines.pxi":65
3227  *     if not C.numpy_lock and C != NULL:
3228  *         free_CSR(C)
3229  *     if E == -1:             # <<<<<<<<<<<<<<
3230  *         raise MemoryError('Could not allocate memory.')
3231  *     elif E == -2:
3232  */
3233     break;
3234     case -2L:
3235 
3236     /* "qutip/cy/sparse_routines.pxi":68
3237  *         raise MemoryError('Could not allocate memory.')
3238  *     elif E == -2:
3239  *         raise Exception('Error manipulating CSR_Matrix structure.')             # <<<<<<<<<<<<<<
3240  *     elif E == -3:
3241  *         raise Exception('CSR_Matrix is not initialized.')
3242  */
3243     __pyx_t_3 = __Pyx_PyObject_Call(((PyObject *)(&((PyTypeObject*)PyExc_Exception)[0])), __pyx_tuple__2, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 68, __pyx_L1_error)
3244     __Pyx_GOTREF(__pyx_t_3);
3245     __Pyx_Raise(__pyx_t_3, 0, 0, 0);
3246     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
3247     __PYX_ERR(0, 68, __pyx_L1_error)
3248 
3249     /* "qutip/cy/sparse_routines.pxi":67
3250  *     if E == -1:
3251  *         raise MemoryError('Could not allocate memory.')
3252  *     elif E == -2:             # <<<<<<<<<<<<<<
3253  *         raise Exception('Error manipulating CSR_Matrix structure.')
3254  *     elif E == -3:
3255  */
3256     break;
3257     case -3L:
3258 
3259     /* "qutip/cy/sparse_routines.pxi":70
3260  *         raise Exception('Error manipulating CSR_Matrix structure.')
3261  *     elif E == -3:
3262  *         raise Exception('CSR_Matrix is not initialized.')             # <<<<<<<<<<<<<<
3263  *     elif E == -4:
3264  *         raise Exception('NumPy already has lock on data.')
3265  */
3266     __pyx_t_3 = __Pyx_PyObject_Call(((PyObject *)(&((PyTypeObject*)PyExc_Exception)[0])), __pyx_tuple__3, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 70, __pyx_L1_error)
3267     __Pyx_GOTREF(__pyx_t_3);
3268     __Pyx_Raise(__pyx_t_3, 0, 0, 0);
3269     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
3270     __PYX_ERR(0, 70, __pyx_L1_error)
3271 
3272     /* "qutip/cy/sparse_routines.pxi":69
3273  *     elif E == -2:
3274  *         raise Exception('Error manipulating CSR_Matrix structure.')
3275  *     elif E == -3:             # <<<<<<<<<<<<<<
3276  *         raise Exception('CSR_Matrix is not initialized.')
3277  *     elif E == -4:
3278  */
3279     break;
3280     case -4L:
3281 
3282     /* "qutip/cy/sparse_routines.pxi":72
3283  *         raise Exception('CSR_Matrix is not initialized.')
3284  *     elif E == -4:
3285  *         raise Exception('NumPy already has lock on data.')             # <<<<<<<<<<<<<<
3286  *     elif E == -5:
3287  *         raise Exception('Cannot expand data structures past max_length.')
3288  */
3289     __pyx_t_3 = __Pyx_PyObject_Call(((PyObject *)(&((PyTypeObject*)PyExc_Exception)[0])), __pyx_tuple__4, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 72, __pyx_L1_error)
3290     __Pyx_GOTREF(__pyx_t_3);
3291     __Pyx_Raise(__pyx_t_3, 0, 0, 0);
3292     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
3293     __PYX_ERR(0, 72, __pyx_L1_error)
3294 
3295     /* "qutip/cy/sparse_routines.pxi":71
3296  *     elif E == -3:
3297  *         raise Exception('CSR_Matrix is not initialized.')
3298  *     elif E == -4:             # <<<<<<<<<<<<<<
3299  *         raise Exception('NumPy already has lock on data.')
3300  *     elif E == -5:
3301  */
3302     break;
3303     case -5L:
3304 
3305     /* "qutip/cy/sparse_routines.pxi":74
3306  *         raise Exception('NumPy already has lock on data.')
3307  *     elif E == -5:
3308  *         raise Exception('Cannot expand data structures past max_length.')             # <<<<<<<<<<<<<<
3309  *     elif E == -6:
3310  *         raise Exception('CSR_Matrix cannot be expanded.')
3311  */
3312     __pyx_t_3 = __Pyx_PyObject_Call(((PyObject *)(&((PyTypeObject*)PyExc_Exception)[0])), __pyx_tuple__5, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 74, __pyx_L1_error)
3313     __Pyx_GOTREF(__pyx_t_3);
3314     __Pyx_Raise(__pyx_t_3, 0, 0, 0);
3315     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
3316     __PYX_ERR(0, 74, __pyx_L1_error)
3317 
3318     /* "qutip/cy/sparse_routines.pxi":73
3319  *     elif E == -4:
3320  *         raise Exception('NumPy already has lock on data.')
3321  *     elif E == -5:             # <<<<<<<<<<<<<<
3322  *         raise Exception('Cannot expand data structures past max_length.')
3323  *     elif E == -6:
3324  */
3325     break;
3326     case -6L:
3327 
3328     /* "qutip/cy/sparse_routines.pxi":76
3329  *         raise Exception('Cannot expand data structures past max_length.')
3330  *     elif E == -6:
3331  *         raise Exception('CSR_Matrix cannot be expanded.')             # <<<<<<<<<<<<<<
3332  *     elif E == -7:
3333  *         raise Exception('Data length cannot be larger than max_length')
3334  */
3335     __pyx_t_3 = __Pyx_PyObject_Call(((PyObject *)(&((PyTypeObject*)PyExc_Exception)[0])), __pyx_tuple__6, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 76, __pyx_L1_error)
3336     __Pyx_GOTREF(__pyx_t_3);
3337     __Pyx_Raise(__pyx_t_3, 0, 0, 0);
3338     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
3339     __PYX_ERR(0, 76, __pyx_L1_error)
3340 
3341     /* "qutip/cy/sparse_routines.pxi":75
3342  *     elif E == -5:
3343  *         raise Exception('Cannot expand data structures past max_length.')
3344  *     elif E == -6:             # <<<<<<<<<<<<<<
3345  *         raise Exception('CSR_Matrix cannot be expanded.')
3346  *     elif E == -7:
3347  */
3348     break;
3349     case -7L:
3350 
3351     /* "qutip/cy/sparse_routines.pxi":78
3352  *         raise Exception('CSR_Matrix cannot be expanded.')
3353  *     elif E == -7:
3354  *         raise Exception('Data length cannot be larger than max_length')             # <<<<<<<<<<<<<<
3355  *     else:
3356  *         raise Exception('Error in Cython code.')
3357  */
3358     __pyx_t_3 = __Pyx_PyObject_Call(((PyObject *)(&((PyTypeObject*)PyExc_Exception)[0])), __pyx_tuple__7, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 78, __pyx_L1_error)
3359     __Pyx_GOTREF(__pyx_t_3);
3360     __Pyx_Raise(__pyx_t_3, 0, 0, 0);
3361     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
3362     __PYX_ERR(0, 78, __pyx_L1_error)
3363 
3364     /* "qutip/cy/sparse_routines.pxi":77
3365  *     elif E == -6:
3366  *         raise Exception('CSR_Matrix cannot be expanded.')
3367  *     elif E == -7:             # <<<<<<<<<<<<<<
3368  *         raise Exception('Data length cannot be larger than max_length')
3369  *     else:
3370  */
3371     break;
3372     default:
3373 
3374     /* "qutip/cy/sparse_routines.pxi":80
3375  *         raise Exception('Data length cannot be larger than max_length')
3376  *     else:
3377  *         raise Exception('Error in Cython code.')             # <<<<<<<<<<<<<<
3378  *
3379  *
3380  */
3381     __pyx_t_3 = __Pyx_PyObject_Call(((PyObject *)(&((PyTypeObject*)PyExc_Exception)[0])), __pyx_tuple__8, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 80, __pyx_L1_error)
3382     __Pyx_GOTREF(__pyx_t_3);
3383     __Pyx_Raise(__pyx_t_3, 0, 0, 0);
3384     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
3385     __PYX_ERR(0, 80, __pyx_L1_error)
3386     break;
3387   }
3388 
3389   /* "qutip/cy/sparse_routines.pxi":62
3390  *
3391  *
3392  * cdef void raise_error_CSR(int E, CSR_Matrix * C = NULL):             # <<<<<<<<<<<<<<
3393  *     if not C.numpy_lock and C != NULL:
3394  *         free_CSR(C)
3395  */
3396 
3397   /* function exit code */
3398   __pyx_L1_error:;
3399   __Pyx_XDECREF(__pyx_t_3);
3400   __Pyx_WriteUnraisable("qutip.cy.brtools.raise_error_CSR", __pyx_clineno, __pyx_lineno, __pyx_filename, 1, 0);
3401   __Pyx_RefNannyFinishContext();
3402 }
3403 
3404 /* "qutip/cy/sparse_routines.pxi":83
3405  *
3406  *
3407  * cdef void raise_error_COO(int E, COO_Matrix * C = NULL):             # <<<<<<<<<<<<<<
3408  *     if not C.numpy_lock and C != NULL:
3409  *         free_COO(C)
3410  */
3411 
__pyx_f_5qutip_2cy_7brtools_raise_error_COO(int __pyx_v_E,struct __pyx_opt_args_5qutip_2cy_7brtools_raise_error_COO * __pyx_optional_args)3412 static void __pyx_f_5qutip_2cy_7brtools_raise_error_COO(int __pyx_v_E, struct __pyx_opt_args_5qutip_2cy_7brtools_raise_error_COO *__pyx_optional_args) {
3413   __pyx_t_5qutip_2cy_14sparse_structs_COO_Matrix *__pyx_v_C = ((__pyx_t_5qutip_2cy_14sparse_structs_COO_Matrix *)NULL);
3414   __Pyx_RefNannyDeclarations
3415   int __pyx_t_1;
3416   int __pyx_t_2;
3417   PyObject *__pyx_t_3 = NULL;
3418   int __pyx_lineno = 0;
3419   const char *__pyx_filename = NULL;
3420   int __pyx_clineno = 0;
3421   __Pyx_RefNannySetupContext("raise_error_COO", 0);
3422   if (__pyx_optional_args) {
3423     if (__pyx_optional_args->__pyx_n > 0) {
3424       __pyx_v_C = __pyx_optional_args->C;
3425     }
3426   }
3427 
3428   /* "qutip/cy/sparse_routines.pxi":84
3429  *
3430  * cdef void raise_error_COO(int E, COO_Matrix * C = NULL):
3431  *     if not C.numpy_lock and C != NULL:             # <<<<<<<<<<<<<<
3432  *         free_COO(C)
3433  *     if E == -1:
3434  */
3435   __pyx_t_2 = ((!(__pyx_v_C->numpy_lock != 0)) != 0);
3436   if (__pyx_t_2) {
3437   } else {
3438     __pyx_t_1 = __pyx_t_2;
3439     goto __pyx_L4_bool_binop_done;
3440   }
3441   __pyx_t_2 = ((__pyx_v_C != NULL) != 0);
3442   __pyx_t_1 = __pyx_t_2;
3443   __pyx_L4_bool_binop_done:;
3444   if (__pyx_t_1) {
3445 
3446     /* "qutip/cy/sparse_routines.pxi":85
3447  * cdef void raise_error_COO(int E, COO_Matrix * C = NULL):
3448  *     if not C.numpy_lock and C != NULL:
3449  *         free_COO(C)             # <<<<<<<<<<<<<<
3450  *     if E == -1:
3451  *         raise MemoryError('Could not allocate memory.')
3452  */
3453     __pyx_f_5qutip_2cy_7brtools_free_COO(__pyx_v_C);
3454 
3455     /* "qutip/cy/sparse_routines.pxi":84
3456  *
3457  * cdef void raise_error_COO(int E, COO_Matrix * C = NULL):
3458  *     if not C.numpy_lock and C != NULL:             # <<<<<<<<<<<<<<
3459  *         free_COO(C)
3460  *     if E == -1:
3461  */
3462   }
3463 
3464   /* "qutip/cy/sparse_routines.pxi":86
3465  *     if not C.numpy_lock and C != NULL:
3466  *         free_COO(C)
3467  *     if E == -1:             # <<<<<<<<<<<<<<
3468  *         raise MemoryError('Could not allocate memory.')
3469  *     elif E == -2:
3470  */
3471   switch (__pyx_v_E) {
3472     case -1L:
3473 
3474     /* "qutip/cy/sparse_routines.pxi":87
3475  *         free_COO(C)
3476  *     if E == -1:
3477  *         raise MemoryError('Could not allocate memory.')             # <<<<<<<<<<<<<<
3478  *     elif E == -2:
3479  *         raise Exception('Error manipulating COO_Matrix structure.')
3480  */
3481     __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_MemoryError, __pyx_tuple_, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 87, __pyx_L1_error)
3482     __Pyx_GOTREF(__pyx_t_3);
3483     __Pyx_Raise(__pyx_t_3, 0, 0, 0);
3484     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
3485     __PYX_ERR(0, 87, __pyx_L1_error)
3486 
3487     /* "qutip/cy/sparse_routines.pxi":86
3488  *     if not C.numpy_lock and C != NULL:
3489  *         free_COO(C)
3490  *     if E == -1:             # <<<<<<<<<<<<<<
3491  *         raise MemoryError('Could not allocate memory.')
3492  *     elif E == -2:
3493  */
3494     break;
3495     case -2L:
3496 
3497     /* "qutip/cy/sparse_routines.pxi":89
3498  *         raise MemoryError('Could not allocate memory.')
3499  *     elif E == -2:
3500  *         raise Exception('Error manipulating COO_Matrix structure.')             # <<<<<<<<<<<<<<
3501  *     elif E == -3:
3502  *         raise Exception('COO_Matrix is not initialized.')
3503  */
3504     __pyx_t_3 = __Pyx_PyObject_Call(((PyObject *)(&((PyTypeObject*)PyExc_Exception)[0])), __pyx_tuple__9, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 89, __pyx_L1_error)
3505     __Pyx_GOTREF(__pyx_t_3);
3506     __Pyx_Raise(__pyx_t_3, 0, 0, 0);
3507     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
3508     __PYX_ERR(0, 89, __pyx_L1_error)
3509 
3510     /* "qutip/cy/sparse_routines.pxi":88
3511  *     if E == -1:
3512  *         raise MemoryError('Could not allocate memory.')
3513  *     elif E == -2:             # <<<<<<<<<<<<<<
3514  *         raise Exception('Error manipulating COO_Matrix structure.')
3515  *     elif E == -3:
3516  */
3517     break;
3518     case -3L:
3519 
3520     /* "qutip/cy/sparse_routines.pxi":91
3521  *         raise Exception('Error manipulating COO_Matrix structure.')
3522  *     elif E == -3:
3523  *         raise Exception('COO_Matrix is not initialized.')             # <<<<<<<<<<<<<<
3524  *     elif E == -4:
3525  *         raise Exception('NumPy already has lock on data.')
3526  */
3527     __pyx_t_3 = __Pyx_PyObject_Call(((PyObject *)(&((PyTypeObject*)PyExc_Exception)[0])), __pyx_tuple__10, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 91, __pyx_L1_error)
3528     __Pyx_GOTREF(__pyx_t_3);
3529     __Pyx_Raise(__pyx_t_3, 0, 0, 0);
3530     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
3531     __PYX_ERR(0, 91, __pyx_L1_error)
3532 
3533     /* "qutip/cy/sparse_routines.pxi":90
3534  *     elif E == -2:
3535  *         raise Exception('Error manipulating COO_Matrix structure.')
3536  *     elif E == -3:             # <<<<<<<<<<<<<<
3537  *         raise Exception('COO_Matrix is not initialized.')
3538  *     elif E == -4:
3539  */
3540     break;
3541     case -4L:
3542 
3543     /* "qutip/cy/sparse_routines.pxi":93
3544  *         raise Exception('COO_Matrix is not initialized.')
3545  *     elif E == -4:
3546  *         raise Exception('NumPy already has lock on data.')             # <<<<<<<<<<<<<<
3547  *     elif E == -5:
3548  *         raise Exception('Cannot expand data structures past max_length.')
3549  */
3550     __pyx_t_3 = __Pyx_PyObject_Call(((PyObject *)(&((PyTypeObject*)PyExc_Exception)[0])), __pyx_tuple__4, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 93, __pyx_L1_error)
3551     __Pyx_GOTREF(__pyx_t_3);
3552     __Pyx_Raise(__pyx_t_3, 0, 0, 0);
3553     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
3554     __PYX_ERR(0, 93, __pyx_L1_error)
3555 
3556     /* "qutip/cy/sparse_routines.pxi":92
3557  *     elif E == -3:
3558  *         raise Exception('COO_Matrix is not initialized.')
3559  *     elif E == -4:             # <<<<<<<<<<<<<<
3560  *         raise Exception('NumPy already has lock on data.')
3561  *     elif E == -5:
3562  */
3563     break;
3564     case -5L:
3565 
3566     /* "qutip/cy/sparse_routines.pxi":95
3567  *         raise Exception('NumPy already has lock on data.')
3568  *     elif E == -5:
3569  *         raise Exception('Cannot expand data structures past max_length.')             # <<<<<<<<<<<<<<
3570  *     elif E == -6:
3571  *         raise Exception('COO_Matrix cannot be expanded.')
3572  */
3573     __pyx_t_3 = __Pyx_PyObject_Call(((PyObject *)(&((PyTypeObject*)PyExc_Exception)[0])), __pyx_tuple__5, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 95, __pyx_L1_error)
3574     __Pyx_GOTREF(__pyx_t_3);
3575     __Pyx_Raise(__pyx_t_3, 0, 0, 0);
3576     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
3577     __PYX_ERR(0, 95, __pyx_L1_error)
3578 
3579     /* "qutip/cy/sparse_routines.pxi":94
3580  *     elif E == -4:
3581  *         raise Exception('NumPy already has lock on data.')
3582  *     elif E == -5:             # <<<<<<<<<<<<<<
3583  *         raise Exception('Cannot expand data structures past max_length.')
3584  *     elif E == -6:
3585  */
3586     break;
3587     case -6L:
3588 
3589     /* "qutip/cy/sparse_routines.pxi":97
3590  *         raise Exception('Cannot expand data structures past max_length.')
3591  *     elif E == -6:
3592  *         raise Exception('COO_Matrix cannot be expanded.')             # <<<<<<<<<<<<<<
3593  *     elif E == -7:
3594  *         raise Exception('Data length cannot be larger than max_length')
3595  */
3596     __pyx_t_3 = __Pyx_PyObject_Call(((PyObject *)(&((PyTypeObject*)PyExc_Exception)[0])), __pyx_tuple__11, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 97, __pyx_L1_error)
3597     __Pyx_GOTREF(__pyx_t_3);
3598     __Pyx_Raise(__pyx_t_3, 0, 0, 0);
3599     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
3600     __PYX_ERR(0, 97, __pyx_L1_error)
3601 
3602     /* "qutip/cy/sparse_routines.pxi":96
3603  *     elif E == -5:
3604  *         raise Exception('Cannot expand data structures past max_length.')
3605  *     elif E == -6:             # <<<<<<<<<<<<<<
3606  *         raise Exception('COO_Matrix cannot be expanded.')
3607  *     elif E == -7:
3608  */
3609     break;
3610     case -7L:
3611 
3612     /* "qutip/cy/sparse_routines.pxi":99
3613  *         raise Exception('COO_Matrix cannot be expanded.')
3614  *     elif E == -7:
3615  *         raise Exception('Data length cannot be larger than max_length')             # <<<<<<<<<<<<<<
3616  *     else:
3617  *         raise Exception('Error in Cython code.')
3618  */
3619     __pyx_t_3 = __Pyx_PyObject_Call(((PyObject *)(&((PyTypeObject*)PyExc_Exception)[0])), __pyx_tuple__7, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 99, __pyx_L1_error)
3620     __Pyx_GOTREF(__pyx_t_3);
3621     __Pyx_Raise(__pyx_t_3, 0, 0, 0);
3622     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
3623     __PYX_ERR(0, 99, __pyx_L1_error)
3624 
3625     /* "qutip/cy/sparse_routines.pxi":98
3626  *     elif E == -6:
3627  *         raise Exception('COO_Matrix cannot be expanded.')
3628  *     elif E == -7:             # <<<<<<<<<<<<<<
3629  *         raise Exception('Data length cannot be larger than max_length')
3630  *     else:
3631  */
3632     break;
3633     default:
3634 
3635     /* "qutip/cy/sparse_routines.pxi":101
3636  *         raise Exception('Data length cannot be larger than max_length')
3637  *     else:
3638  *         raise Exception('Error in Cython code.')             # <<<<<<<<<<<<<<
3639  *
3640  *
3641  */
3642     __pyx_t_3 = __Pyx_PyObject_Call(((PyObject *)(&((PyTypeObject*)PyExc_Exception)[0])), __pyx_tuple__8, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 101, __pyx_L1_error)
3643     __Pyx_GOTREF(__pyx_t_3);
3644     __Pyx_Raise(__pyx_t_3, 0, 0, 0);
3645     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
3646     __PYX_ERR(0, 101, __pyx_L1_error)
3647     break;
3648   }
3649 
3650   /* "qutip/cy/sparse_routines.pxi":83
3651  *
3652  *
3653  * cdef void raise_error_COO(int E, COO_Matrix * C = NULL):             # <<<<<<<<<<<<<<
3654  *     if not C.numpy_lock and C != NULL:
3655  *         free_COO(C)
3656  */
3657 
3658   /* function exit code */
3659   __pyx_L1_error:;
3660   __Pyx_XDECREF(__pyx_t_3);
3661   __Pyx_WriteUnraisable("qutip.cy.brtools.raise_error_COO", __pyx_clineno, __pyx_lineno, __pyx_filename, 1, 0);
3662   __Pyx_RefNannyFinishContext();
3663 }
3664 
3665 /* "qutip/cy/sparse_routines.pxi":104
3666  *
3667  *
3668  * cdef inline int int_min(int a, int b) nogil:             # <<<<<<<<<<<<<<
3669  *     return b if b < a else a
3670  *
3671  */
3672 
__pyx_f_5qutip_2cy_7brtools_int_min(int __pyx_v_a,int __pyx_v_b)3673 static CYTHON_INLINE int __pyx_f_5qutip_2cy_7brtools_int_min(int __pyx_v_a, int __pyx_v_b) {
3674   int __pyx_r;
3675   int __pyx_t_1;
3676 
3677   /* "qutip/cy/sparse_routines.pxi":105
3678  *
3679  * cdef inline int int_min(int a, int b) nogil:
3680  *     return b if b < a else a             # <<<<<<<<<<<<<<
3681  *
3682  * cdef inline int int_max(int a, int b) nogil:
3683  */
3684   if (((__pyx_v_b < __pyx_v_a) != 0)) {
3685     __pyx_t_1 = __pyx_v_b;
3686   } else {
3687     __pyx_t_1 = __pyx_v_a;
3688   }
3689   __pyx_r = __pyx_t_1;
3690   goto __pyx_L0;
3691 
3692   /* "qutip/cy/sparse_routines.pxi":104
3693  *
3694  *
3695  * cdef inline int int_min(int a, int b) nogil:             # <<<<<<<<<<<<<<
3696  *     return b if b < a else a
3697  *
3698  */
3699 
3700   /* function exit code */
3701   __pyx_L0:;
3702   return __pyx_r;
3703 }
3704 
3705 /* "qutip/cy/sparse_routines.pxi":107
3706  *     return b if b < a else a
3707  *
3708  * cdef inline int int_max(int a, int b) nogil:             # <<<<<<<<<<<<<<
3709  *     return a if a > b else b
3710  *
3711  */
3712 
__pyx_f_5qutip_2cy_7brtools_int_max(int __pyx_v_a,int __pyx_v_b)3713 static CYTHON_INLINE int __pyx_f_5qutip_2cy_7brtools_int_max(int __pyx_v_a, int __pyx_v_b) {
3714   int __pyx_r;
3715   int __pyx_t_1;
3716 
3717   /* "qutip/cy/sparse_routines.pxi":108
3718  *
3719  * cdef inline int int_max(int a, int b) nogil:
3720  *     return a if a > b else b             # <<<<<<<<<<<<<<
3721  *
3722  *
3723  */
3724   if (((__pyx_v_a > __pyx_v_b) != 0)) {
3725     __pyx_t_1 = __pyx_v_a;
3726   } else {
3727     __pyx_t_1 = __pyx_v_b;
3728   }
3729   __pyx_r = __pyx_t_1;
3730   goto __pyx_L0;
3731 
3732   /* "qutip/cy/sparse_routines.pxi":107
3733  *     return b if b < a else a
3734  *
3735  * cdef inline int int_max(int a, int b) nogil:             # <<<<<<<<<<<<<<
3736  *     return a if a > b else b
3737  *
3738  */
3739 
3740   /* function exit code */
3741   __pyx_L0:;
3742   return __pyx_r;
3743 }
3744 
3745 /* "qutip/cy/sparse_routines.pxi":113
3746  * @cython.boundscheck(False)
3747  * @cython.wraparound(False)
3748  * cdef void init_CSR(CSR_Matrix * mat, int nnz, int nrows, int ncols = 0,             # <<<<<<<<<<<<<<
3749  *                 int max_length = 0, int init_zeros = 1):
3750  *     """
3751  */
3752 
__pyx_f_5qutip_2cy_7brtools_init_CSR(__pyx_t_5qutip_2cy_14sparse_structs_CSR_Matrix * __pyx_v_mat,int __pyx_v_nnz,int __pyx_v_nrows,struct __pyx_opt_args_5qutip_2cy_7brtools_init_CSR * __pyx_optional_args)3753 static void __pyx_f_5qutip_2cy_7brtools_init_CSR(__pyx_t_5qutip_2cy_14sparse_structs_CSR_Matrix *__pyx_v_mat, int __pyx_v_nnz, int __pyx_v_nrows, struct __pyx_opt_args_5qutip_2cy_7brtools_init_CSR *__pyx_optional_args) {
3754   int __pyx_v_ncols = ((int)0);
3755   int __pyx_v_max_length = ((int)0);
3756   int __pyx_v_init_zeros = ((int)1);
3757   __Pyx_RefNannyDeclarations
3758   int __pyx_t_1;
3759   struct __pyx_opt_args_5qutip_2cy_7brtools_raise_error_CSR __pyx_t_2;
3760   __Pyx_RefNannySetupContext("init_CSR", 0);
3761   if (__pyx_optional_args) {
3762     if (__pyx_optional_args->__pyx_n > 0) {
3763       __pyx_v_ncols = __pyx_optional_args->ncols;
3764       if (__pyx_optional_args->__pyx_n > 1) {
3765         __pyx_v_max_length = __pyx_optional_args->max_length;
3766         if (__pyx_optional_args->__pyx_n > 2) {
3767           __pyx_v_init_zeros = __pyx_optional_args->init_zeros;
3768         }
3769       }
3770     }
3771   }
3772 
3773   /* "qutip/cy/sparse_routines.pxi":134
3774  *         Default value of zero indicates no resizing.
3775  *     """
3776  *     if max_length == 0:             # <<<<<<<<<<<<<<
3777  *         max_length = nnz
3778  *     if nnz > max_length:
3779  */
3780   __pyx_t_1 = ((__pyx_v_max_length == 0) != 0);
3781   if (__pyx_t_1) {
3782 
3783     /* "qutip/cy/sparse_routines.pxi":135
3784  *     """
3785  *     if max_length == 0:
3786  *         max_length = nnz             # <<<<<<<<<<<<<<
3787  *     if nnz > max_length:
3788  *         raise_error_CSR(-7, mat)
3789  */
3790     __pyx_v_max_length = __pyx_v_nnz;
3791 
3792     /* "qutip/cy/sparse_routines.pxi":134
3793  *         Default value of zero indicates no resizing.
3794  *     """
3795  *     if max_length == 0:             # <<<<<<<<<<<<<<
3796  *         max_length = nnz
3797  *     if nnz > max_length:
3798  */
3799   }
3800 
3801   /* "qutip/cy/sparse_routines.pxi":136
3802  *     if max_length == 0:
3803  *         max_length = nnz
3804  *     if nnz > max_length:             # <<<<<<<<<<<<<<
3805  *         raise_error_CSR(-7, mat)
3806  *     if init_zeros:
3807  */
3808   __pyx_t_1 = ((__pyx_v_nnz > __pyx_v_max_length) != 0);
3809   if (__pyx_t_1) {
3810 
3811     /* "qutip/cy/sparse_routines.pxi":137
3812  *         max_length = nnz
3813  *     if nnz > max_length:
3814  *         raise_error_CSR(-7, mat)             # <<<<<<<<<<<<<<
3815  *     if init_zeros:
3816  *         mat.data = <double complex *>PyDataMem_NEW_ZEROED(nnz, sizeof(double complex))
3817  */
3818     __pyx_t_2.__pyx_n = 1;
3819     __pyx_t_2.C = __pyx_v_mat;
3820     __pyx_f_5qutip_2cy_7brtools_raise_error_CSR(-7, &__pyx_t_2);
3821 
3822     /* "qutip/cy/sparse_routines.pxi":136
3823  *     if max_length == 0:
3824  *         max_length = nnz
3825  *     if nnz > max_length:             # <<<<<<<<<<<<<<
3826  *         raise_error_CSR(-7, mat)
3827  *     if init_zeros:
3828  */
3829   }
3830 
3831   /* "qutip/cy/sparse_routines.pxi":138
3832  *     if nnz > max_length:
3833  *         raise_error_CSR(-7, mat)
3834  *     if init_zeros:             # <<<<<<<<<<<<<<
3835  *         mat.data = <double complex *>PyDataMem_NEW_ZEROED(nnz, sizeof(double complex))
3836  *     else:
3837  */
3838   __pyx_t_1 = (__pyx_v_init_zeros != 0);
3839   if (__pyx_t_1) {
3840 
3841     /* "qutip/cy/sparse_routines.pxi":139
3842  *         raise_error_CSR(-7, mat)
3843  *     if init_zeros:
3844  *         mat.data = <double complex *>PyDataMem_NEW_ZEROED(nnz, sizeof(double complex))             # <<<<<<<<<<<<<<
3845  *     else:
3846  *         mat.data = <double complex *>PyDataMem_NEW(nnz * sizeof(double complex))
3847  */
3848     __pyx_v_mat->data = ((__pyx_t_double_complex *)PyDataMem_NEW_ZEROED(__pyx_v_nnz, (sizeof(__pyx_t_double_complex))));
3849 
3850     /* "qutip/cy/sparse_routines.pxi":138
3851  *     if nnz > max_length:
3852  *         raise_error_CSR(-7, mat)
3853  *     if init_zeros:             # <<<<<<<<<<<<<<
3854  *         mat.data = <double complex *>PyDataMem_NEW_ZEROED(nnz, sizeof(double complex))
3855  *     else:
3856  */
3857     goto __pyx_L5;
3858   }
3859 
3860   /* "qutip/cy/sparse_routines.pxi":141
3861  *         mat.data = <double complex *>PyDataMem_NEW_ZEROED(nnz, sizeof(double complex))
3862  *     else:
3863  *         mat.data = <double complex *>PyDataMem_NEW(nnz * sizeof(double complex))             # <<<<<<<<<<<<<<
3864  *     if mat.data == NULL:
3865  *         raise_error_CSR(-1, mat)
3866  */
3867   /*else*/ {
3868     __pyx_v_mat->data = ((__pyx_t_double_complex *)PyDataMem_NEW((__pyx_v_nnz * (sizeof(__pyx_t_double_complex)))));
3869   }
3870   __pyx_L5:;
3871 
3872   /* "qutip/cy/sparse_routines.pxi":142
3873  *     else:
3874  *         mat.data = <double complex *>PyDataMem_NEW(nnz * sizeof(double complex))
3875  *     if mat.data == NULL:             # <<<<<<<<<<<<<<
3876  *         raise_error_CSR(-1, mat)
3877  *     if init_zeros:
3878  */
3879   __pyx_t_1 = ((__pyx_v_mat->data == NULL) != 0);
3880   if (__pyx_t_1) {
3881 
3882     /* "qutip/cy/sparse_routines.pxi":143
3883  *         mat.data = <double complex *>PyDataMem_NEW(nnz * sizeof(double complex))
3884  *     if mat.data == NULL:
3885  *         raise_error_CSR(-1, mat)             # <<<<<<<<<<<<<<
3886  *     if init_zeros:
3887  *         mat.indices = <int *>PyDataMem_NEW_ZEROED(nnz, sizeof(int))
3888  */
3889     __pyx_t_2.__pyx_n = 1;
3890     __pyx_t_2.C = __pyx_v_mat;
3891     __pyx_f_5qutip_2cy_7brtools_raise_error_CSR(-1, &__pyx_t_2);
3892 
3893     /* "qutip/cy/sparse_routines.pxi":142
3894  *     else:
3895  *         mat.data = <double complex *>PyDataMem_NEW(nnz * sizeof(double complex))
3896  *     if mat.data == NULL:             # <<<<<<<<<<<<<<
3897  *         raise_error_CSR(-1, mat)
3898  *     if init_zeros:
3899  */
3900   }
3901 
3902   /* "qutip/cy/sparse_routines.pxi":144
3903  *     if mat.data == NULL:
3904  *         raise_error_CSR(-1, mat)
3905  *     if init_zeros:             # <<<<<<<<<<<<<<
3906  *         mat.indices = <int *>PyDataMem_NEW_ZEROED(nnz, sizeof(int))
3907  *         mat.indptr = <int *>PyDataMem_NEW_ZEROED((nrows+1), sizeof(int))
3908  */
3909   __pyx_t_1 = (__pyx_v_init_zeros != 0);
3910   if (__pyx_t_1) {
3911 
3912     /* "qutip/cy/sparse_routines.pxi":145
3913  *         raise_error_CSR(-1, mat)
3914  *     if init_zeros:
3915  *         mat.indices = <int *>PyDataMem_NEW_ZEROED(nnz, sizeof(int))             # <<<<<<<<<<<<<<
3916  *         mat.indptr = <int *>PyDataMem_NEW_ZEROED((nrows+1), sizeof(int))
3917  *     else:
3918  */
3919     __pyx_v_mat->indices = ((int *)PyDataMem_NEW_ZEROED(__pyx_v_nnz, (sizeof(int))));
3920 
3921     /* "qutip/cy/sparse_routines.pxi":146
3922  *     if init_zeros:
3923  *         mat.indices = <int *>PyDataMem_NEW_ZEROED(nnz, sizeof(int))
3924  *         mat.indptr = <int *>PyDataMem_NEW_ZEROED((nrows+1), sizeof(int))             # <<<<<<<<<<<<<<
3925  *     else:
3926  *         mat.indices = <int *>PyDataMem_NEW(nnz * sizeof(int))
3927  */
3928     __pyx_v_mat->indptr = ((int *)PyDataMem_NEW_ZEROED((__pyx_v_nrows + 1), (sizeof(int))));
3929 
3930     /* "qutip/cy/sparse_routines.pxi":144
3931  *     if mat.data == NULL:
3932  *         raise_error_CSR(-1, mat)
3933  *     if init_zeros:             # <<<<<<<<<<<<<<
3934  *         mat.indices = <int *>PyDataMem_NEW_ZEROED(nnz, sizeof(int))
3935  *         mat.indptr = <int *>PyDataMem_NEW_ZEROED((nrows+1), sizeof(int))
3936  */
3937     goto __pyx_L7;
3938   }
3939 
3940   /* "qutip/cy/sparse_routines.pxi":148
3941  *         mat.indptr = <int *>PyDataMem_NEW_ZEROED((nrows+1), sizeof(int))
3942  *     else:
3943  *         mat.indices = <int *>PyDataMem_NEW(nnz * sizeof(int))             # <<<<<<<<<<<<<<
3944  *         mat.indptr = <int *>PyDataMem_NEW((nrows+1) * sizeof(int))
3945  *     mat.nnz = nnz
3946  */
3947   /*else*/ {
3948     __pyx_v_mat->indices = ((int *)PyDataMem_NEW((__pyx_v_nnz * (sizeof(int)))));
3949 
3950     /* "qutip/cy/sparse_routines.pxi":149
3951  *     else:
3952  *         mat.indices = <int *>PyDataMem_NEW(nnz * sizeof(int))
3953  *         mat.indptr = <int *>PyDataMem_NEW((nrows+1) * sizeof(int))             # <<<<<<<<<<<<<<
3954  *     mat.nnz = nnz
3955  *     mat.nrows = nrows
3956  */
3957     __pyx_v_mat->indptr = ((int *)PyDataMem_NEW(((__pyx_v_nrows + 1) * (sizeof(int)))));
3958   }
3959   __pyx_L7:;
3960 
3961   /* "qutip/cy/sparse_routines.pxi":150
3962  *         mat.indices = <int *>PyDataMem_NEW(nnz * sizeof(int))
3963  *         mat.indptr = <int *>PyDataMem_NEW((nrows+1) * sizeof(int))
3964  *     mat.nnz = nnz             # <<<<<<<<<<<<<<
3965  *     mat.nrows = nrows
3966  *     if ncols == 0:
3967  */
3968   __pyx_v_mat->nnz = __pyx_v_nnz;
3969 
3970   /* "qutip/cy/sparse_routines.pxi":151
3971  *         mat.indptr = <int *>PyDataMem_NEW((nrows+1) * sizeof(int))
3972  *     mat.nnz = nnz
3973  *     mat.nrows = nrows             # <<<<<<<<<<<<<<
3974  *     if ncols == 0:
3975  *         mat.ncols = nrows
3976  */
3977   __pyx_v_mat->nrows = __pyx_v_nrows;
3978 
3979   /* "qutip/cy/sparse_routines.pxi":152
3980  *     mat.nnz = nnz
3981  *     mat.nrows = nrows
3982  *     if ncols == 0:             # <<<<<<<<<<<<<<
3983  *         mat.ncols = nrows
3984  *     else:
3985  */
3986   __pyx_t_1 = ((__pyx_v_ncols == 0) != 0);
3987   if (__pyx_t_1) {
3988 
3989     /* "qutip/cy/sparse_routines.pxi":153
3990  *     mat.nrows = nrows
3991  *     if ncols == 0:
3992  *         mat.ncols = nrows             # <<<<<<<<<<<<<<
3993  *     else:
3994  *         mat.ncols = ncols
3995  */
3996     __pyx_v_mat->ncols = __pyx_v_nrows;
3997 
3998     /* "qutip/cy/sparse_routines.pxi":152
3999  *     mat.nnz = nnz
4000  *     mat.nrows = nrows
4001  *     if ncols == 0:             # <<<<<<<<<<<<<<
4002  *         mat.ncols = nrows
4003  *     else:
4004  */
4005     goto __pyx_L8;
4006   }
4007 
4008   /* "qutip/cy/sparse_routines.pxi":155
4009  *         mat.ncols = nrows
4010  *     else:
4011  *         mat.ncols = ncols             # <<<<<<<<<<<<<<
4012  *     mat.is_set = 1
4013  *     mat.max_length = max_length
4014  */
4015   /*else*/ {
4016     __pyx_v_mat->ncols = __pyx_v_ncols;
4017   }
4018   __pyx_L8:;
4019 
4020   /* "qutip/cy/sparse_routines.pxi":156
4021  *     else:
4022  *         mat.ncols = ncols
4023  *     mat.is_set = 1             # <<<<<<<<<<<<<<
4024  *     mat.max_length = max_length
4025  *     mat.numpy_lock = 0
4026  */
4027   __pyx_v_mat->is_set = 1;
4028 
4029   /* "qutip/cy/sparse_routines.pxi":157
4030  *         mat.ncols = ncols
4031  *     mat.is_set = 1
4032  *     mat.max_length = max_length             # <<<<<<<<<<<<<<
4033  *     mat.numpy_lock = 0
4034  *
4035  */
4036   __pyx_v_mat->max_length = __pyx_v_max_length;
4037 
4038   /* "qutip/cy/sparse_routines.pxi":158
4039  *     mat.is_set = 1
4040  *     mat.max_length = max_length
4041  *     mat.numpy_lock = 0             # <<<<<<<<<<<<<<
4042  *
4043  *
4044  */
4045   __pyx_v_mat->numpy_lock = 0;
4046 
4047   /* "qutip/cy/sparse_routines.pxi":113
4048  * @cython.boundscheck(False)
4049  * @cython.wraparound(False)
4050  * cdef void init_CSR(CSR_Matrix * mat, int nnz, int nrows, int ncols = 0,             # <<<<<<<<<<<<<<
4051  *                 int max_length = 0, int init_zeros = 1):
4052  *     """
4053  */
4054 
4055   /* function exit code */
4056   __Pyx_RefNannyFinishContext();
4057 }
4058 
4059 /* "qutip/cy/sparse_routines.pxi":163
4060  * @cython.boundscheck(False)
4061  * @cython.wraparound(False)
4062  * cdef void copy_CSR(CSR_Matrix * out, CSR_Matrix * mat):             # <<<<<<<<<<<<<<
4063  *     """
4064  *     Copy a CSR_Matrix.
4065  */
4066 
__pyx_f_5qutip_2cy_7brtools_copy_CSR(__pyx_t_5qutip_2cy_14sparse_structs_CSR_Matrix * __pyx_v_out,__pyx_t_5qutip_2cy_14sparse_structs_CSR_Matrix * __pyx_v_mat)4067 static void __pyx_f_5qutip_2cy_7brtools_copy_CSR(__pyx_t_5qutip_2cy_14sparse_structs_CSR_Matrix *__pyx_v_out, __pyx_t_5qutip_2cy_14sparse_structs_CSR_Matrix *__pyx_v_mat) {
4068   size_t __pyx_v_kk;
4069   __Pyx_RefNannyDeclarations
4070   int __pyx_t_1;
4071   struct __pyx_opt_args_5qutip_2cy_7brtools_init_CSR __pyx_t_2;
4072   int __pyx_t_3;
4073   int __pyx_t_4;
4074   size_t __pyx_t_5;
4075   long __pyx_t_6;
4076   long __pyx_t_7;
4077   __Pyx_RefNannySetupContext("copy_CSR", 0);
4078 
4079   /* "qutip/cy/sparse_routines.pxi":168
4080  *     """
4081  *     cdef size_t kk
4082  *     if not mat.is_set:             # <<<<<<<<<<<<<<
4083  *         raise_error_CSR(-3)
4084  *     elif out.is_set:
4085  */
4086   __pyx_t_1 = ((!(__pyx_v_mat->is_set != 0)) != 0);
4087   if (__pyx_t_1) {
4088 
4089     /* "qutip/cy/sparse_routines.pxi":169
4090  *     cdef size_t kk
4091  *     if not mat.is_set:
4092  *         raise_error_CSR(-3)             # <<<<<<<<<<<<<<
4093  *     elif out.is_set:
4094  *         raise_error_CSR(-2)
4095  */
4096     __pyx_f_5qutip_2cy_7brtools_raise_error_CSR(-3, NULL);
4097 
4098     /* "qutip/cy/sparse_routines.pxi":168
4099  *     """
4100  *     cdef size_t kk
4101  *     if not mat.is_set:             # <<<<<<<<<<<<<<
4102  *         raise_error_CSR(-3)
4103  *     elif out.is_set:
4104  */
4105     goto __pyx_L3;
4106   }
4107 
4108   /* "qutip/cy/sparse_routines.pxi":170
4109  *     if not mat.is_set:
4110  *         raise_error_CSR(-3)
4111  *     elif out.is_set:             # <<<<<<<<<<<<<<
4112  *         raise_error_CSR(-2)
4113  *     init_CSR(out, mat.nnz, mat.nrows, mat.nrows, mat.max_length)
4114  */
4115   __pyx_t_1 = (__pyx_v_out->is_set != 0);
4116   if (__pyx_t_1) {
4117 
4118     /* "qutip/cy/sparse_routines.pxi":171
4119  *         raise_error_CSR(-3)
4120  *     elif out.is_set:
4121  *         raise_error_CSR(-2)             # <<<<<<<<<<<<<<
4122  *     init_CSR(out, mat.nnz, mat.nrows, mat.nrows, mat.max_length)
4123  *     # We cannot use memcpy here since there are issues with
4124  */
4125     __pyx_f_5qutip_2cy_7brtools_raise_error_CSR(-2, NULL);
4126 
4127     /* "qutip/cy/sparse_routines.pxi":170
4128  *     if not mat.is_set:
4129  *         raise_error_CSR(-3)
4130  *     elif out.is_set:             # <<<<<<<<<<<<<<
4131  *         raise_error_CSR(-2)
4132  *     init_CSR(out, mat.nnz, mat.nrows, mat.nrows, mat.max_length)
4133  */
4134   }
4135   __pyx_L3:;
4136 
4137   /* "qutip/cy/sparse_routines.pxi":172
4138  *     elif out.is_set:
4139  *         raise_error_CSR(-2)
4140  *     init_CSR(out, mat.nnz, mat.nrows, mat.nrows, mat.max_length)             # <<<<<<<<<<<<<<
4141  *     # We cannot use memcpy here since there are issues with
4142  *     # doing so on Win with the GCC compiler
4143  */
4144   __pyx_t_2.__pyx_n = 2;
4145   __pyx_t_2.ncols = __pyx_v_mat->nrows;
4146   __pyx_t_2.max_length = __pyx_v_mat->max_length;
4147   __pyx_f_5qutip_2cy_7brtools_init_CSR(__pyx_v_out, __pyx_v_mat->nnz, __pyx_v_mat->nrows, &__pyx_t_2);
4148 
4149   /* "qutip/cy/sparse_routines.pxi":175
4150  *     # We cannot use memcpy here since there are issues with
4151  *     # doing so on Win with the GCC compiler
4152  *     for kk in range(mat.nnz):             # <<<<<<<<<<<<<<
4153  *         out.data[kk] = mat.data[kk]
4154  *         out.indices[kk] = mat.indices[kk]
4155  */
4156   __pyx_t_3 = __pyx_v_mat->nnz;
4157   __pyx_t_4 = __pyx_t_3;
4158   for (__pyx_t_5 = 0; __pyx_t_5 < __pyx_t_4; __pyx_t_5+=1) {
4159     __pyx_v_kk = __pyx_t_5;
4160 
4161     /* "qutip/cy/sparse_routines.pxi":176
4162  *     # doing so on Win with the GCC compiler
4163  *     for kk in range(mat.nnz):
4164  *         out.data[kk] = mat.data[kk]             # <<<<<<<<<<<<<<
4165  *         out.indices[kk] = mat.indices[kk]
4166  *     for kk in range(mat.nrows+1):
4167  */
4168     (__pyx_v_out->data[__pyx_v_kk]) = (__pyx_v_mat->data[__pyx_v_kk]);
4169 
4170     /* "qutip/cy/sparse_routines.pxi":177
4171  *     for kk in range(mat.nnz):
4172  *         out.data[kk] = mat.data[kk]
4173  *         out.indices[kk] = mat.indices[kk]             # <<<<<<<<<<<<<<
4174  *     for kk in range(mat.nrows+1):
4175  *         out.indptr[kk] = mat.indptr[kk]
4176  */
4177     (__pyx_v_out->indices[__pyx_v_kk]) = (__pyx_v_mat->indices[__pyx_v_kk]);
4178   }
4179 
4180   /* "qutip/cy/sparse_routines.pxi":178
4181  *         out.data[kk] = mat.data[kk]
4182  *         out.indices[kk] = mat.indices[kk]
4183  *     for kk in range(mat.nrows+1):             # <<<<<<<<<<<<<<
4184  *         out.indptr[kk] = mat.indptr[kk]
4185  *
4186  */
4187   __pyx_t_6 = (__pyx_v_mat->nrows + 1);
4188   __pyx_t_7 = __pyx_t_6;
4189   for (__pyx_t_5 = 0; __pyx_t_5 < __pyx_t_7; __pyx_t_5+=1) {
4190     __pyx_v_kk = __pyx_t_5;
4191 
4192     /* "qutip/cy/sparse_routines.pxi":179
4193  *         out.indices[kk] = mat.indices[kk]
4194  *     for kk in range(mat.nrows+1):
4195  *         out.indptr[kk] = mat.indptr[kk]             # <<<<<<<<<<<<<<
4196  *
4197  *
4198  */
4199     (__pyx_v_out->indptr[__pyx_v_kk]) = (__pyx_v_mat->indptr[__pyx_v_kk]);
4200   }
4201 
4202   /* "qutip/cy/sparse_routines.pxi":163
4203  * @cython.boundscheck(False)
4204  * @cython.wraparound(False)
4205  * cdef void copy_CSR(CSR_Matrix * out, CSR_Matrix * mat):             # <<<<<<<<<<<<<<
4206  *     """
4207  *     Copy a CSR_Matrix.
4208  */
4209 
4210   /* function exit code */
4211   __Pyx_RefNannyFinishContext();
4212 }
4213 
4214 /* "qutip/cy/sparse_routines.pxi":184
4215  * @cython.boundscheck(False)
4216  * @cython.wraparound(False)
4217  * cdef void init_COO(COO_Matrix * mat, int nnz, int nrows, int ncols = 0,             # <<<<<<<<<<<<<<
4218  *                 int max_length = 0, int init_zeros = 1):
4219  *     """
4220  */
4221 
__pyx_f_5qutip_2cy_7brtools_init_COO(__pyx_t_5qutip_2cy_14sparse_structs_COO_Matrix * __pyx_v_mat,int __pyx_v_nnz,int __pyx_v_nrows,struct __pyx_opt_args_5qutip_2cy_7brtools_init_COO * __pyx_optional_args)4222 static void __pyx_f_5qutip_2cy_7brtools_init_COO(__pyx_t_5qutip_2cy_14sparse_structs_COO_Matrix *__pyx_v_mat, int __pyx_v_nnz, int __pyx_v_nrows, struct __pyx_opt_args_5qutip_2cy_7brtools_init_COO *__pyx_optional_args) {
4223   int __pyx_v_ncols = ((int)0);
4224   int __pyx_v_max_length = ((int)0);
4225   int __pyx_v_init_zeros = ((int)1);
4226   __Pyx_RefNannyDeclarations
4227   int __pyx_t_1;
4228   struct __pyx_opt_args_5qutip_2cy_7brtools_raise_error_COO __pyx_t_2;
4229   __Pyx_RefNannySetupContext("init_COO", 0);
4230   if (__pyx_optional_args) {
4231     if (__pyx_optional_args->__pyx_n > 0) {
4232       __pyx_v_ncols = __pyx_optional_args->ncols;
4233       if (__pyx_optional_args->__pyx_n > 1) {
4234         __pyx_v_max_length = __pyx_optional_args->max_length;
4235         if (__pyx_optional_args->__pyx_n > 2) {
4236           __pyx_v_init_zeros = __pyx_optional_args->init_zeros;
4237         }
4238       }
4239     }
4240   }
4241 
4242   /* "qutip/cy/sparse_routines.pxi":204
4243  *         Default value of zero indicates no resizing.
4244  *     """
4245  *     if max_length == 0:             # <<<<<<<<<<<<<<
4246  *         max_length = nnz
4247  *     if nnz > max_length:
4248  */
4249   __pyx_t_1 = ((__pyx_v_max_length == 0) != 0);
4250   if (__pyx_t_1) {
4251 
4252     /* "qutip/cy/sparse_routines.pxi":205
4253  *     """
4254  *     if max_length == 0:
4255  *         max_length = nnz             # <<<<<<<<<<<<<<
4256  *     if nnz > max_length:
4257  *         raise_error_COO(-7, mat)
4258  */
4259     __pyx_v_max_length = __pyx_v_nnz;
4260 
4261     /* "qutip/cy/sparse_routines.pxi":204
4262  *         Default value of zero indicates no resizing.
4263  *     """
4264  *     if max_length == 0:             # <<<<<<<<<<<<<<
4265  *         max_length = nnz
4266  *     if nnz > max_length:
4267  */
4268   }
4269 
4270   /* "qutip/cy/sparse_routines.pxi":206
4271  *     if max_length == 0:
4272  *         max_length = nnz
4273  *     if nnz > max_length:             # <<<<<<<<<<<<<<
4274  *         raise_error_COO(-7, mat)
4275  *     if init_zeros:
4276  */
4277   __pyx_t_1 = ((__pyx_v_nnz > __pyx_v_max_length) != 0);
4278   if (__pyx_t_1) {
4279 
4280     /* "qutip/cy/sparse_routines.pxi":207
4281  *         max_length = nnz
4282  *     if nnz > max_length:
4283  *         raise_error_COO(-7, mat)             # <<<<<<<<<<<<<<
4284  *     if init_zeros:
4285  *         mat.data = <double complex *>PyDataMem_NEW_ZEROED(nnz, sizeof(double complex))
4286  */
4287     __pyx_t_2.__pyx_n = 1;
4288     __pyx_t_2.C = __pyx_v_mat;
4289     __pyx_f_5qutip_2cy_7brtools_raise_error_COO(-7, &__pyx_t_2);
4290 
4291     /* "qutip/cy/sparse_routines.pxi":206
4292  *     if max_length == 0:
4293  *         max_length = nnz
4294  *     if nnz > max_length:             # <<<<<<<<<<<<<<
4295  *         raise_error_COO(-7, mat)
4296  *     if init_zeros:
4297  */
4298   }
4299 
4300   /* "qutip/cy/sparse_routines.pxi":208
4301  *     if nnz > max_length:
4302  *         raise_error_COO(-7, mat)
4303  *     if init_zeros:             # <<<<<<<<<<<<<<
4304  *         mat.data = <double complex *>PyDataMem_NEW_ZEROED(nnz, sizeof(double complex))
4305  *     else:
4306  */
4307   __pyx_t_1 = (__pyx_v_init_zeros != 0);
4308   if (__pyx_t_1) {
4309 
4310     /* "qutip/cy/sparse_routines.pxi":209
4311  *         raise_error_COO(-7, mat)
4312  *     if init_zeros:
4313  *         mat.data = <double complex *>PyDataMem_NEW_ZEROED(nnz, sizeof(double complex))             # <<<<<<<<<<<<<<
4314  *     else:
4315  *         mat.data = <double complex *>PyDataMem_NEW(nnz * sizeof(double complex))
4316  */
4317     __pyx_v_mat->data = ((__pyx_t_double_complex *)PyDataMem_NEW_ZEROED(__pyx_v_nnz, (sizeof(__pyx_t_double_complex))));
4318 
4319     /* "qutip/cy/sparse_routines.pxi":208
4320  *     if nnz > max_length:
4321  *         raise_error_COO(-7, mat)
4322  *     if init_zeros:             # <<<<<<<<<<<<<<
4323  *         mat.data = <double complex *>PyDataMem_NEW_ZEROED(nnz, sizeof(double complex))
4324  *     else:
4325  */
4326     goto __pyx_L5;
4327   }
4328 
4329   /* "qutip/cy/sparse_routines.pxi":211
4330  *         mat.data = <double complex *>PyDataMem_NEW_ZEROED(nnz, sizeof(double complex))
4331  *     else:
4332  *         mat.data = <double complex *>PyDataMem_NEW(nnz * sizeof(double complex))             # <<<<<<<<<<<<<<
4333  *     if mat.data == NULL:
4334  *         raise_error_COO(-1, mat)
4335  */
4336   /*else*/ {
4337     __pyx_v_mat->data = ((__pyx_t_double_complex *)PyDataMem_NEW((__pyx_v_nnz * (sizeof(__pyx_t_double_complex)))));
4338   }
4339   __pyx_L5:;
4340 
4341   /* "qutip/cy/sparse_routines.pxi":212
4342  *     else:
4343  *         mat.data = <double complex *>PyDataMem_NEW(nnz * sizeof(double complex))
4344  *     if mat.data == NULL:             # <<<<<<<<<<<<<<
4345  *         raise_error_COO(-1, mat)
4346  *     if init_zeros:
4347  */
4348   __pyx_t_1 = ((__pyx_v_mat->data == NULL) != 0);
4349   if (__pyx_t_1) {
4350 
4351     /* "qutip/cy/sparse_routines.pxi":213
4352  *         mat.data = <double complex *>PyDataMem_NEW(nnz * sizeof(double complex))
4353  *     if mat.data == NULL:
4354  *         raise_error_COO(-1, mat)             # <<<<<<<<<<<<<<
4355  *     if init_zeros:
4356  *         mat.rows = <int *>PyDataMem_NEW_ZEROED(nnz, sizeof(int))
4357  */
4358     __pyx_t_2.__pyx_n = 1;
4359     __pyx_t_2.C = __pyx_v_mat;
4360     __pyx_f_5qutip_2cy_7brtools_raise_error_COO(-1, &__pyx_t_2);
4361 
4362     /* "qutip/cy/sparse_routines.pxi":212
4363  *     else:
4364  *         mat.data = <double complex *>PyDataMem_NEW(nnz * sizeof(double complex))
4365  *     if mat.data == NULL:             # <<<<<<<<<<<<<<
4366  *         raise_error_COO(-1, mat)
4367  *     if init_zeros:
4368  */
4369   }
4370 
4371   /* "qutip/cy/sparse_routines.pxi":214
4372  *     if mat.data == NULL:
4373  *         raise_error_COO(-1, mat)
4374  *     if init_zeros:             # <<<<<<<<<<<<<<
4375  *         mat.rows = <int *>PyDataMem_NEW_ZEROED(nnz, sizeof(int))
4376  *         mat.cols = <int *>PyDataMem_NEW_ZEROED(nnz, sizeof(int))
4377  */
4378   __pyx_t_1 = (__pyx_v_init_zeros != 0);
4379   if (__pyx_t_1) {
4380 
4381     /* "qutip/cy/sparse_routines.pxi":215
4382  *         raise_error_COO(-1, mat)
4383  *     if init_zeros:
4384  *         mat.rows = <int *>PyDataMem_NEW_ZEROED(nnz, sizeof(int))             # <<<<<<<<<<<<<<
4385  *         mat.cols = <int *>PyDataMem_NEW_ZEROED(nnz, sizeof(int))
4386  *     else:
4387  */
4388     __pyx_v_mat->rows = ((int *)PyDataMem_NEW_ZEROED(__pyx_v_nnz, (sizeof(int))));
4389 
4390     /* "qutip/cy/sparse_routines.pxi":216
4391  *     if init_zeros:
4392  *         mat.rows = <int *>PyDataMem_NEW_ZEROED(nnz, sizeof(int))
4393  *         mat.cols = <int *>PyDataMem_NEW_ZEROED(nnz, sizeof(int))             # <<<<<<<<<<<<<<
4394  *     else:
4395  *         mat.rows = <int *>PyDataMem_NEW(nnz * sizeof(int))
4396  */
4397     __pyx_v_mat->cols = ((int *)PyDataMem_NEW_ZEROED(__pyx_v_nnz, (sizeof(int))));
4398 
4399     /* "qutip/cy/sparse_routines.pxi":214
4400  *     if mat.data == NULL:
4401  *         raise_error_COO(-1, mat)
4402  *     if init_zeros:             # <<<<<<<<<<<<<<
4403  *         mat.rows = <int *>PyDataMem_NEW_ZEROED(nnz, sizeof(int))
4404  *         mat.cols = <int *>PyDataMem_NEW_ZEROED(nnz, sizeof(int))
4405  */
4406     goto __pyx_L7;
4407   }
4408 
4409   /* "qutip/cy/sparse_routines.pxi":218
4410  *         mat.cols = <int *>PyDataMem_NEW_ZEROED(nnz, sizeof(int))
4411  *     else:
4412  *         mat.rows = <int *>PyDataMem_NEW(nnz * sizeof(int))             # <<<<<<<<<<<<<<
4413  *         mat.cols = <int *>PyDataMem_NEW(nnz * sizeof(int))
4414  *     mat.nnz = nnz
4415  */
4416   /*else*/ {
4417     __pyx_v_mat->rows = ((int *)PyDataMem_NEW((__pyx_v_nnz * (sizeof(int)))));
4418 
4419     /* "qutip/cy/sparse_routines.pxi":219
4420  *     else:
4421  *         mat.rows = <int *>PyDataMem_NEW(nnz * sizeof(int))
4422  *         mat.cols = <int *>PyDataMem_NEW(nnz * sizeof(int))             # <<<<<<<<<<<<<<
4423  *     mat.nnz = nnz
4424  *     mat.nrows = nrows
4425  */
4426     __pyx_v_mat->cols = ((int *)PyDataMem_NEW((__pyx_v_nnz * (sizeof(int)))));
4427   }
4428   __pyx_L7:;
4429 
4430   /* "qutip/cy/sparse_routines.pxi":220
4431  *         mat.rows = <int *>PyDataMem_NEW(nnz * sizeof(int))
4432  *         mat.cols = <int *>PyDataMem_NEW(nnz * sizeof(int))
4433  *     mat.nnz = nnz             # <<<<<<<<<<<<<<
4434  *     mat.nrows = nrows
4435  *     if ncols == 0:
4436  */
4437   __pyx_v_mat->nnz = __pyx_v_nnz;
4438 
4439   /* "qutip/cy/sparse_routines.pxi":221
4440  *         mat.cols = <int *>PyDataMem_NEW(nnz * sizeof(int))
4441  *     mat.nnz = nnz
4442  *     mat.nrows = nrows             # <<<<<<<<<<<<<<
4443  *     if ncols == 0:
4444  *         mat.ncols = nrows
4445  */
4446   __pyx_v_mat->nrows = __pyx_v_nrows;
4447 
4448   /* "qutip/cy/sparse_routines.pxi":222
4449  *     mat.nnz = nnz
4450  *     mat.nrows = nrows
4451  *     if ncols == 0:             # <<<<<<<<<<<<<<
4452  *         mat.ncols = nrows
4453  *     else:
4454  */
4455   __pyx_t_1 = ((__pyx_v_ncols == 0) != 0);
4456   if (__pyx_t_1) {
4457 
4458     /* "qutip/cy/sparse_routines.pxi":223
4459  *     mat.nrows = nrows
4460  *     if ncols == 0:
4461  *         mat.ncols = nrows             # <<<<<<<<<<<<<<
4462  *     else:
4463  *         mat.ncols = ncols
4464  */
4465     __pyx_v_mat->ncols = __pyx_v_nrows;
4466 
4467     /* "qutip/cy/sparse_routines.pxi":222
4468  *     mat.nnz = nnz
4469  *     mat.nrows = nrows
4470  *     if ncols == 0:             # <<<<<<<<<<<<<<
4471  *         mat.ncols = nrows
4472  *     else:
4473  */
4474     goto __pyx_L8;
4475   }
4476 
4477   /* "qutip/cy/sparse_routines.pxi":225
4478  *         mat.ncols = nrows
4479  *     else:
4480  *         mat.ncols = ncols             # <<<<<<<<<<<<<<
4481  *     mat.is_set = 1
4482  *     mat.max_length = max_length
4483  */
4484   /*else*/ {
4485     __pyx_v_mat->ncols = __pyx_v_ncols;
4486   }
4487   __pyx_L8:;
4488 
4489   /* "qutip/cy/sparse_routines.pxi":226
4490  *     else:
4491  *         mat.ncols = ncols
4492  *     mat.is_set = 1             # <<<<<<<<<<<<<<
4493  *     mat.max_length = max_length
4494  *     mat.numpy_lock = 0
4495  */
4496   __pyx_v_mat->is_set = 1;
4497 
4498   /* "qutip/cy/sparse_routines.pxi":227
4499  *         mat.ncols = ncols
4500  *     mat.is_set = 1
4501  *     mat.max_length = max_length             # <<<<<<<<<<<<<<
4502  *     mat.numpy_lock = 0
4503  *
4504  */
4505   __pyx_v_mat->max_length = __pyx_v_max_length;
4506 
4507   /* "qutip/cy/sparse_routines.pxi":228
4508  *     mat.is_set = 1
4509  *     mat.max_length = max_length
4510  *     mat.numpy_lock = 0             # <<<<<<<<<<<<<<
4511  *
4512  * @cython.boundscheck(False)
4513  */
4514   __pyx_v_mat->numpy_lock = 0;
4515 
4516   /* "qutip/cy/sparse_routines.pxi":184
4517  * @cython.boundscheck(False)
4518  * @cython.wraparound(False)
4519  * cdef void init_COO(COO_Matrix * mat, int nnz, int nrows, int ncols = 0,             # <<<<<<<<<<<<<<
4520  *                 int max_length = 0, int init_zeros = 1):
4521  *     """
4522  */
4523 
4524   /* function exit code */
4525   __Pyx_RefNannyFinishContext();
4526 }
4527 
4528 /* "qutip/cy/sparse_routines.pxi":232
4529  * @cython.boundscheck(False)
4530  * @cython.wraparound(False)
4531  * cdef void free_CSR(CSR_Matrix * mat):             # <<<<<<<<<<<<<<
4532  *     """
4533  *     Manually free CSR_Matrix data structures if
4534  */
4535 
__pyx_f_5qutip_2cy_7brtools_free_CSR(__pyx_t_5qutip_2cy_14sparse_structs_CSR_Matrix * __pyx_v_mat)4536 static void __pyx_f_5qutip_2cy_7brtools_free_CSR(__pyx_t_5qutip_2cy_14sparse_structs_CSR_Matrix *__pyx_v_mat) {
4537   __Pyx_RefNannyDeclarations
4538   int __pyx_t_1;
4539   int __pyx_t_2;
4540   __Pyx_RefNannySetupContext("free_CSR", 0);
4541 
4542   /* "qutip/cy/sparse_routines.pxi":237
4543  *     data is not locked by NumPy.
4544  *     """
4545  *     if not mat.numpy_lock and mat.is_set:             # <<<<<<<<<<<<<<
4546  *         if mat.data != NULL:
4547  *             PyDataMem_FREE(mat.data)
4548  */
4549   __pyx_t_2 = ((!(__pyx_v_mat->numpy_lock != 0)) != 0);
4550   if (__pyx_t_2) {
4551   } else {
4552     __pyx_t_1 = __pyx_t_2;
4553     goto __pyx_L4_bool_binop_done;
4554   }
4555   __pyx_t_2 = (__pyx_v_mat->is_set != 0);
4556   __pyx_t_1 = __pyx_t_2;
4557   __pyx_L4_bool_binop_done:;
4558   if (__pyx_t_1) {
4559 
4560     /* "qutip/cy/sparse_routines.pxi":238
4561  *     """
4562  *     if not mat.numpy_lock and mat.is_set:
4563  *         if mat.data != NULL:             # <<<<<<<<<<<<<<
4564  *             PyDataMem_FREE(mat.data)
4565  *         if mat.indices != NULL:
4566  */
4567     __pyx_t_1 = ((__pyx_v_mat->data != NULL) != 0);
4568     if (__pyx_t_1) {
4569 
4570       /* "qutip/cy/sparse_routines.pxi":239
4571  *     if not mat.numpy_lock and mat.is_set:
4572  *         if mat.data != NULL:
4573  *             PyDataMem_FREE(mat.data)             # <<<<<<<<<<<<<<
4574  *         if mat.indices != NULL:
4575  *             PyDataMem_FREE(mat.indices)
4576  */
4577       PyDataMem_FREE(__pyx_v_mat->data);
4578 
4579       /* "qutip/cy/sparse_routines.pxi":238
4580  *     """
4581  *     if not mat.numpy_lock and mat.is_set:
4582  *         if mat.data != NULL:             # <<<<<<<<<<<<<<
4583  *             PyDataMem_FREE(mat.data)
4584  *         if mat.indices != NULL:
4585  */
4586     }
4587 
4588     /* "qutip/cy/sparse_routines.pxi":240
4589  *         if mat.data != NULL:
4590  *             PyDataMem_FREE(mat.data)
4591  *         if mat.indices != NULL:             # <<<<<<<<<<<<<<
4592  *             PyDataMem_FREE(mat.indices)
4593  *         if mat.indptr != NULL:
4594  */
4595     __pyx_t_1 = ((__pyx_v_mat->indices != NULL) != 0);
4596     if (__pyx_t_1) {
4597 
4598       /* "qutip/cy/sparse_routines.pxi":241
4599  *             PyDataMem_FREE(mat.data)
4600  *         if mat.indices != NULL:
4601  *             PyDataMem_FREE(mat.indices)             # <<<<<<<<<<<<<<
4602  *         if mat.indptr != NULL:
4603  *             PyDataMem_FREE(mat.indptr)
4604  */
4605       PyDataMem_FREE(__pyx_v_mat->indices);
4606 
4607       /* "qutip/cy/sparse_routines.pxi":240
4608  *         if mat.data != NULL:
4609  *             PyDataMem_FREE(mat.data)
4610  *         if mat.indices != NULL:             # <<<<<<<<<<<<<<
4611  *             PyDataMem_FREE(mat.indices)
4612  *         if mat.indptr != NULL:
4613  */
4614     }
4615 
4616     /* "qutip/cy/sparse_routines.pxi":242
4617  *         if mat.indices != NULL:
4618  *             PyDataMem_FREE(mat.indices)
4619  *         if mat.indptr != NULL:             # <<<<<<<<<<<<<<
4620  *             PyDataMem_FREE(mat.indptr)
4621  *         mat.is_set = 0
4622  */
4623     __pyx_t_1 = ((__pyx_v_mat->indptr != NULL) != 0);
4624     if (__pyx_t_1) {
4625 
4626       /* "qutip/cy/sparse_routines.pxi":243
4627  *             PyDataMem_FREE(mat.indices)
4628  *         if mat.indptr != NULL:
4629  *             PyDataMem_FREE(mat.indptr)             # <<<<<<<<<<<<<<
4630  *         mat.is_set = 0
4631  *     else:
4632  */
4633       PyDataMem_FREE(__pyx_v_mat->indptr);
4634 
4635       /* "qutip/cy/sparse_routines.pxi":242
4636  *         if mat.indices != NULL:
4637  *             PyDataMem_FREE(mat.indices)
4638  *         if mat.indptr != NULL:             # <<<<<<<<<<<<<<
4639  *             PyDataMem_FREE(mat.indptr)
4640  *         mat.is_set = 0
4641  */
4642     }
4643 
4644     /* "qutip/cy/sparse_routines.pxi":244
4645  *         if mat.indptr != NULL:
4646  *             PyDataMem_FREE(mat.indptr)
4647  *         mat.is_set = 0             # <<<<<<<<<<<<<<
4648  *     else:
4649  *         raise_error_CSR(-2)
4650  */
4651     __pyx_v_mat->is_set = 0;
4652 
4653     /* "qutip/cy/sparse_routines.pxi":237
4654  *     data is not locked by NumPy.
4655  *     """
4656  *     if not mat.numpy_lock and mat.is_set:             # <<<<<<<<<<<<<<
4657  *         if mat.data != NULL:
4658  *             PyDataMem_FREE(mat.data)
4659  */
4660     goto __pyx_L3;
4661   }
4662 
4663   /* "qutip/cy/sparse_routines.pxi":246
4664  *         mat.is_set = 0
4665  *     else:
4666  *         raise_error_CSR(-2)             # <<<<<<<<<<<<<<
4667  *
4668  * @cython.boundscheck(False)
4669  */
4670   /*else*/ {
4671     __pyx_f_5qutip_2cy_7brtools_raise_error_CSR(-2, NULL);
4672   }
4673   __pyx_L3:;
4674 
4675   /* "qutip/cy/sparse_routines.pxi":232
4676  * @cython.boundscheck(False)
4677  * @cython.wraparound(False)
4678  * cdef void free_CSR(CSR_Matrix * mat):             # <<<<<<<<<<<<<<
4679  *     """
4680  *     Manually free CSR_Matrix data structures if
4681  */
4682 
4683   /* function exit code */
4684   __Pyx_RefNannyFinishContext();
4685 }
4686 
4687 /* "qutip/cy/sparse_routines.pxi":250
4688  * @cython.boundscheck(False)
4689  * @cython.wraparound(False)
4690  * cdef void free_COO(COO_Matrix * mat):             # <<<<<<<<<<<<<<
4691  *     """
4692  *     Manually free COO_Matrix data structures if
4693  */
4694 
__pyx_f_5qutip_2cy_7brtools_free_COO(__pyx_t_5qutip_2cy_14sparse_structs_COO_Matrix * __pyx_v_mat)4695 static void __pyx_f_5qutip_2cy_7brtools_free_COO(__pyx_t_5qutip_2cy_14sparse_structs_COO_Matrix *__pyx_v_mat) {
4696   __Pyx_RefNannyDeclarations
4697   int __pyx_t_1;
4698   int __pyx_t_2;
4699   __Pyx_RefNannySetupContext("free_COO", 0);
4700 
4701   /* "qutip/cy/sparse_routines.pxi":255
4702  *     data is not locked by NumPy.
4703  *     """
4704  *     if not mat.numpy_lock and mat.is_set:             # <<<<<<<<<<<<<<
4705  *         if mat.data != NULL:
4706  *             PyDataMem_FREE(mat.data)
4707  */
4708   __pyx_t_2 = ((!(__pyx_v_mat->numpy_lock != 0)) != 0);
4709   if (__pyx_t_2) {
4710   } else {
4711     __pyx_t_1 = __pyx_t_2;
4712     goto __pyx_L4_bool_binop_done;
4713   }
4714   __pyx_t_2 = (__pyx_v_mat->is_set != 0);
4715   __pyx_t_1 = __pyx_t_2;
4716   __pyx_L4_bool_binop_done:;
4717   if (__pyx_t_1) {
4718 
4719     /* "qutip/cy/sparse_routines.pxi":256
4720  *     """
4721  *     if not mat.numpy_lock and mat.is_set:
4722  *         if mat.data != NULL:             # <<<<<<<<<<<<<<
4723  *             PyDataMem_FREE(mat.data)
4724  *         if mat.rows != NULL:
4725  */
4726     __pyx_t_1 = ((__pyx_v_mat->data != NULL) != 0);
4727     if (__pyx_t_1) {
4728 
4729       /* "qutip/cy/sparse_routines.pxi":257
4730  *     if not mat.numpy_lock and mat.is_set:
4731  *         if mat.data != NULL:
4732  *             PyDataMem_FREE(mat.data)             # <<<<<<<<<<<<<<
4733  *         if mat.rows != NULL:
4734  *             PyDataMem_FREE(mat.rows)
4735  */
4736       PyDataMem_FREE(__pyx_v_mat->data);
4737 
4738       /* "qutip/cy/sparse_routines.pxi":256
4739  *     """
4740  *     if not mat.numpy_lock and mat.is_set:
4741  *         if mat.data != NULL:             # <<<<<<<<<<<<<<
4742  *             PyDataMem_FREE(mat.data)
4743  *         if mat.rows != NULL:
4744  */
4745     }
4746 
4747     /* "qutip/cy/sparse_routines.pxi":258
4748  *         if mat.data != NULL:
4749  *             PyDataMem_FREE(mat.data)
4750  *         if mat.rows != NULL:             # <<<<<<<<<<<<<<
4751  *             PyDataMem_FREE(mat.rows)
4752  *         if mat.cols != NULL:
4753  */
4754     __pyx_t_1 = ((__pyx_v_mat->rows != NULL) != 0);
4755     if (__pyx_t_1) {
4756 
4757       /* "qutip/cy/sparse_routines.pxi":259
4758  *             PyDataMem_FREE(mat.data)
4759  *         if mat.rows != NULL:
4760  *             PyDataMem_FREE(mat.rows)             # <<<<<<<<<<<<<<
4761  *         if mat.cols != NULL:
4762  *             PyDataMem_FREE(mat.cols)
4763  */
4764       PyDataMem_FREE(__pyx_v_mat->rows);
4765 
4766       /* "qutip/cy/sparse_routines.pxi":258
4767  *         if mat.data != NULL:
4768  *             PyDataMem_FREE(mat.data)
4769  *         if mat.rows != NULL:             # <<<<<<<<<<<<<<
4770  *             PyDataMem_FREE(mat.rows)
4771  *         if mat.cols != NULL:
4772  */
4773     }
4774 
4775     /* "qutip/cy/sparse_routines.pxi":260
4776  *         if mat.rows != NULL:
4777  *             PyDataMem_FREE(mat.rows)
4778  *         if mat.cols != NULL:             # <<<<<<<<<<<<<<
4779  *             PyDataMem_FREE(mat.cols)
4780  *         mat.is_set = 0
4781  */
4782     __pyx_t_1 = ((__pyx_v_mat->cols != NULL) != 0);
4783     if (__pyx_t_1) {
4784 
4785       /* "qutip/cy/sparse_routines.pxi":261
4786  *             PyDataMem_FREE(mat.rows)
4787  *         if mat.cols != NULL:
4788  *             PyDataMem_FREE(mat.cols)             # <<<<<<<<<<<<<<
4789  *         mat.is_set = 0
4790  *     else:
4791  */
4792       PyDataMem_FREE(__pyx_v_mat->cols);
4793 
4794       /* "qutip/cy/sparse_routines.pxi":260
4795  *         if mat.rows != NULL:
4796  *             PyDataMem_FREE(mat.rows)
4797  *         if mat.cols != NULL:             # <<<<<<<<<<<<<<
4798  *             PyDataMem_FREE(mat.cols)
4799  *         mat.is_set = 0
4800  */
4801     }
4802 
4803     /* "qutip/cy/sparse_routines.pxi":262
4804  *         if mat.cols != NULL:
4805  *             PyDataMem_FREE(mat.cols)
4806  *         mat.is_set = 0             # <<<<<<<<<<<<<<
4807  *     else:
4808  *         raise_error_COO(-2)
4809  */
4810     __pyx_v_mat->is_set = 0;
4811 
4812     /* "qutip/cy/sparse_routines.pxi":255
4813  *     data is not locked by NumPy.
4814  *     """
4815  *     if not mat.numpy_lock and mat.is_set:             # <<<<<<<<<<<<<<
4816  *         if mat.data != NULL:
4817  *             PyDataMem_FREE(mat.data)
4818  */
4819     goto __pyx_L3;
4820   }
4821 
4822   /* "qutip/cy/sparse_routines.pxi":264
4823  *         mat.is_set = 0
4824  *     else:
4825  *         raise_error_COO(-2)             # <<<<<<<<<<<<<<
4826  *
4827  *
4828  */
4829   /*else*/ {
4830     __pyx_f_5qutip_2cy_7brtools_raise_error_COO(-2, NULL);
4831   }
4832   __pyx_L3:;
4833 
4834   /* "qutip/cy/sparse_routines.pxi":250
4835  * @cython.boundscheck(False)
4836  * @cython.wraparound(False)
4837  * cdef void free_COO(COO_Matrix * mat):             # <<<<<<<<<<<<<<
4838  *     """
4839  *     Manually free COO_Matrix data structures if
4840  */
4841 
4842   /* function exit code */
4843   __Pyx_RefNannyFinishContext();
4844 }
4845 
4846 /* "qutip/cy/sparse_routines.pxi":269
4847  * @cython.boundscheck(False)
4848  * @cython.wraparound(False)
4849  * cdef void shorten_CSR(CSR_Matrix * mat, int N):             # <<<<<<<<<<<<<<
4850  *     """
4851  *     Shortends the length of CSR data and indices arrays.
4852  */
4853 
__pyx_f_5qutip_2cy_7brtools_shorten_CSR(__pyx_t_5qutip_2cy_14sparse_structs_CSR_Matrix * __pyx_v_mat,int __pyx_v_N)4854 static void __pyx_f_5qutip_2cy_7brtools_shorten_CSR(__pyx_t_5qutip_2cy_14sparse_structs_CSR_Matrix *__pyx_v_mat, int __pyx_v_N) {
4855   __Pyx_RefNannyDeclarations
4856   int __pyx_t_1;
4857   int __pyx_t_2;
4858   struct __pyx_opt_args_5qutip_2cy_7brtools_raise_error_CSR __pyx_t_3;
4859   __Pyx_RefNannySetupContext("shorten_CSR", 0);
4860 
4861   /* "qutip/cy/sparse_routines.pxi":273
4862  *     Shortends the length of CSR data and indices arrays.
4863  *     """
4864  *     if (not mat.numpy_lock) and mat.is_set:             # <<<<<<<<<<<<<<
4865  *         mat.data = <double complex *>PyDataMem_RENEW(mat.data, N * sizeof(double complex))
4866  *         mat.indices = <int *>PyDataMem_RENEW(mat.indices, N * sizeof(int))
4867  */
4868   __pyx_t_2 = ((!(__pyx_v_mat->numpy_lock != 0)) != 0);
4869   if (__pyx_t_2) {
4870   } else {
4871     __pyx_t_1 = __pyx_t_2;
4872     goto __pyx_L4_bool_binop_done;
4873   }
4874   __pyx_t_2 = (__pyx_v_mat->is_set != 0);
4875   __pyx_t_1 = __pyx_t_2;
4876   __pyx_L4_bool_binop_done:;
4877   if (__pyx_t_1) {
4878 
4879     /* "qutip/cy/sparse_routines.pxi":274
4880  *     """
4881  *     if (not mat.numpy_lock) and mat.is_set:
4882  *         mat.data = <double complex *>PyDataMem_RENEW(mat.data, N * sizeof(double complex))             # <<<<<<<<<<<<<<
4883  *         mat.indices = <int *>PyDataMem_RENEW(mat.indices, N * sizeof(int))
4884  *         mat.nnz = N
4885  */
4886     __pyx_v_mat->data = ((__pyx_t_double_complex *)PyDataMem_RENEW(__pyx_v_mat->data, (__pyx_v_N * (sizeof(__pyx_t_double_complex)))));
4887 
4888     /* "qutip/cy/sparse_routines.pxi":275
4889  *     if (not mat.numpy_lock) and mat.is_set:
4890  *         mat.data = <double complex *>PyDataMem_RENEW(mat.data, N * sizeof(double complex))
4891  *         mat.indices = <int *>PyDataMem_RENEW(mat.indices, N * sizeof(int))             # <<<<<<<<<<<<<<
4892  *         mat.nnz = N
4893  *     else:
4894  */
4895     __pyx_v_mat->indices = ((int *)PyDataMem_RENEW(__pyx_v_mat->indices, (__pyx_v_N * (sizeof(int)))));
4896 
4897     /* "qutip/cy/sparse_routines.pxi":276
4898  *         mat.data = <double complex *>PyDataMem_RENEW(mat.data, N * sizeof(double complex))
4899  *         mat.indices = <int *>PyDataMem_RENEW(mat.indices, N * sizeof(int))
4900  *         mat.nnz = N             # <<<<<<<<<<<<<<
4901  *     else:
4902  *         if mat.numpy_lock:
4903  */
4904     __pyx_v_mat->nnz = __pyx_v_N;
4905 
4906     /* "qutip/cy/sparse_routines.pxi":273
4907  *     Shortends the length of CSR data and indices arrays.
4908  *     """
4909  *     if (not mat.numpy_lock) and mat.is_set:             # <<<<<<<<<<<<<<
4910  *         mat.data = <double complex *>PyDataMem_RENEW(mat.data, N * sizeof(double complex))
4911  *         mat.indices = <int *>PyDataMem_RENEW(mat.indices, N * sizeof(int))
4912  */
4913     goto __pyx_L3;
4914   }
4915 
4916   /* "qutip/cy/sparse_routines.pxi":278
4917  *         mat.nnz = N
4918  *     else:
4919  *         if mat.numpy_lock:             # <<<<<<<<<<<<<<
4920  *             raise_error_CSR(-4, mat)
4921  *         elif not mat.is_set:
4922  */
4923   /*else*/ {
4924     __pyx_t_1 = (__pyx_v_mat->numpy_lock != 0);
4925     if (__pyx_t_1) {
4926 
4927       /* "qutip/cy/sparse_routines.pxi":279
4928  *     else:
4929  *         if mat.numpy_lock:
4930  *             raise_error_CSR(-4, mat)             # <<<<<<<<<<<<<<
4931  *         elif not mat.is_set:
4932  *             raise_error_CSR(-3, mat)
4933  */
4934       __pyx_t_3.__pyx_n = 1;
4935       __pyx_t_3.C = __pyx_v_mat;
4936       __pyx_f_5qutip_2cy_7brtools_raise_error_CSR(-4, &__pyx_t_3);
4937 
4938       /* "qutip/cy/sparse_routines.pxi":278
4939  *         mat.nnz = N
4940  *     else:
4941  *         if mat.numpy_lock:             # <<<<<<<<<<<<<<
4942  *             raise_error_CSR(-4, mat)
4943  *         elif not mat.is_set:
4944  */
4945       goto __pyx_L6;
4946     }
4947 
4948     /* "qutip/cy/sparse_routines.pxi":280
4949  *         if mat.numpy_lock:
4950  *             raise_error_CSR(-4, mat)
4951  *         elif not mat.is_set:             # <<<<<<<<<<<<<<
4952  *             raise_error_CSR(-3, mat)
4953  *
4954  */
4955     __pyx_t_1 = ((!(__pyx_v_mat->is_set != 0)) != 0);
4956     if (__pyx_t_1) {
4957 
4958       /* "qutip/cy/sparse_routines.pxi":281
4959  *             raise_error_CSR(-4, mat)
4960  *         elif not mat.is_set:
4961  *             raise_error_CSR(-3, mat)             # <<<<<<<<<<<<<<
4962  *
4963  *
4964  */
4965       __pyx_t_3.__pyx_n = 1;
4966       __pyx_t_3.C = __pyx_v_mat;
4967       __pyx_f_5qutip_2cy_7brtools_raise_error_CSR(-3, &__pyx_t_3);
4968 
4969       /* "qutip/cy/sparse_routines.pxi":280
4970  *         if mat.numpy_lock:
4971  *             raise_error_CSR(-4, mat)
4972  *         elif not mat.is_set:             # <<<<<<<<<<<<<<
4973  *             raise_error_CSR(-3, mat)
4974  *
4975  */
4976     }
4977     __pyx_L6:;
4978   }
4979   __pyx_L3:;
4980 
4981   /* "qutip/cy/sparse_routines.pxi":269
4982  * @cython.boundscheck(False)
4983  * @cython.wraparound(False)
4984  * cdef void shorten_CSR(CSR_Matrix * mat, int N):             # <<<<<<<<<<<<<<
4985  *     """
4986  *     Shortends the length of CSR data and indices arrays.
4987  */
4988 
4989   /* function exit code */
4990   __Pyx_RefNannyFinishContext();
4991 }
4992 
4993 /* "qutip/cy/sparse_routines.pxi":286
4994  * @cython.boundscheck(False)
4995  * @cython.wraparound(False)
4996  * cdef void expand_CSR(CSR_Matrix * mat, int init_zeros=0):             # <<<<<<<<<<<<<<
4997  *     """
4998  *     Expands the length of CSR data and indices arrays to accomodate
4999  */
5000 
__pyx_f_5qutip_2cy_7brtools_expand_CSR(__pyx_t_5qutip_2cy_14sparse_structs_CSR_Matrix * __pyx_v_mat,struct __pyx_opt_args_5qutip_2cy_7brtools_expand_CSR * __pyx_optional_args)5001 static void __pyx_f_5qutip_2cy_7brtools_expand_CSR(__pyx_t_5qutip_2cy_14sparse_structs_CSR_Matrix *__pyx_v_mat, struct __pyx_opt_args_5qutip_2cy_7brtools_expand_CSR *__pyx_optional_args) {
5002   int __pyx_v_init_zeros = ((int)0);
5003   size_t __pyx_v_ii;
5004   int __pyx_v_new_size;
5005   __pyx_t_double_complex *__pyx_v_new_data;
5006   int *__pyx_v_new_ind;
5007   __Pyx_RefNannyDeclarations
5008   int __pyx_t_1;
5009   struct __pyx_opt_args_5qutip_2cy_7brtools_raise_error_CSR __pyx_t_2;
5010   int __pyx_t_3;
5011   int __pyx_t_4;
5012   int __pyx_t_5;
5013   size_t __pyx_t_6;
5014   __Pyx_RefNannySetupContext("expand_CSR", 0);
5015   if (__pyx_optional_args) {
5016     if (__pyx_optional_args->__pyx_n > 0) {
5017       __pyx_v_init_zeros = __pyx_optional_args->init_zeros;
5018     }
5019   }
5020 
5021   /* "qutip/cy/sparse_routines.pxi":293
5022  *     cdef size_t ii
5023  *     cdef int new_size
5024  *     if mat.nnz == mat.max_length:             # <<<<<<<<<<<<<<
5025  *         raise_error_CSR(-5, mat) #Cannot expand data past max_length.
5026  *     elif (not mat.numpy_lock) and mat.is_set:
5027  */
5028   __pyx_t_1 = ((__pyx_v_mat->nnz == __pyx_v_mat->max_length) != 0);
5029   if (__pyx_t_1) {
5030 
5031     /* "qutip/cy/sparse_routines.pxi":294
5032  *     cdef int new_size
5033  *     if mat.nnz == mat.max_length:
5034  *         raise_error_CSR(-5, mat) #Cannot expand data past max_length.             # <<<<<<<<<<<<<<
5035  *     elif (not mat.numpy_lock) and mat.is_set:
5036  *         new_size = int_min(2*mat.nnz, mat.max_length)
5037  */
5038     __pyx_t_2.__pyx_n = 1;
5039     __pyx_t_2.C = __pyx_v_mat;
5040     __pyx_f_5qutip_2cy_7brtools_raise_error_CSR(-5, &__pyx_t_2);
5041 
5042     /* "qutip/cy/sparse_routines.pxi":293
5043  *     cdef size_t ii
5044  *     cdef int new_size
5045  *     if mat.nnz == mat.max_length:             # <<<<<<<<<<<<<<
5046  *         raise_error_CSR(-5, mat) #Cannot expand data past max_length.
5047  *     elif (not mat.numpy_lock) and mat.is_set:
5048  */
5049     goto __pyx_L3;
5050   }
5051 
5052   /* "qutip/cy/sparse_routines.pxi":295
5053  *     if mat.nnz == mat.max_length:
5054  *         raise_error_CSR(-5, mat) #Cannot expand data past max_length.
5055  *     elif (not mat.numpy_lock) and mat.is_set:             # <<<<<<<<<<<<<<
5056  *         new_size = int_min(2*mat.nnz, mat.max_length)
5057  *         new_data = <double complex *>PyDataMem_RENEW(mat.data, new_size * sizeof(double complex))
5058  */
5059   __pyx_t_3 = ((!(__pyx_v_mat->numpy_lock != 0)) != 0);
5060   if (__pyx_t_3) {
5061   } else {
5062     __pyx_t_1 = __pyx_t_3;
5063     goto __pyx_L4_bool_binop_done;
5064   }
5065   __pyx_t_3 = (__pyx_v_mat->is_set != 0);
5066   __pyx_t_1 = __pyx_t_3;
5067   __pyx_L4_bool_binop_done:;
5068   if (__pyx_t_1) {
5069 
5070     /* "qutip/cy/sparse_routines.pxi":296
5071  *         raise_error_CSR(-5, mat) #Cannot expand data past max_length.
5072  *     elif (not mat.numpy_lock) and mat.is_set:
5073  *         new_size = int_min(2*mat.nnz, mat.max_length)             # <<<<<<<<<<<<<<
5074  *         new_data = <double complex *>PyDataMem_RENEW(mat.data, new_size * sizeof(double complex))
5075  *         if new_data == NULL:
5076  */
5077     __pyx_v_new_size = __pyx_f_5qutip_2cy_7brtools_int_min((2 * __pyx_v_mat->nnz), __pyx_v_mat->max_length);
5078 
5079     /* "qutip/cy/sparse_routines.pxi":297
5080  *     elif (not mat.numpy_lock) and mat.is_set:
5081  *         new_size = int_min(2*mat.nnz, mat.max_length)
5082  *         new_data = <double complex *>PyDataMem_RENEW(mat.data, new_size * sizeof(double complex))             # <<<<<<<<<<<<<<
5083  *         if new_data == NULL:
5084  *             raise_error_CSR(-1, mat)
5085  */
5086     __pyx_v_new_data = ((__pyx_t_double_complex *)PyDataMem_RENEW(__pyx_v_mat->data, (__pyx_v_new_size * (sizeof(__pyx_t_double_complex)))));
5087 
5088     /* "qutip/cy/sparse_routines.pxi":298
5089  *         new_size = int_min(2*mat.nnz, mat.max_length)
5090  *         new_data = <double complex *>PyDataMem_RENEW(mat.data, new_size * sizeof(double complex))
5091  *         if new_data == NULL:             # <<<<<<<<<<<<<<
5092  *             raise_error_CSR(-1, mat)
5093  *         else:
5094  */
5095     __pyx_t_1 = ((__pyx_v_new_data == NULL) != 0);
5096     if (__pyx_t_1) {
5097 
5098       /* "qutip/cy/sparse_routines.pxi":299
5099  *         new_data = <double complex *>PyDataMem_RENEW(mat.data, new_size * sizeof(double complex))
5100  *         if new_data == NULL:
5101  *             raise_error_CSR(-1, mat)             # <<<<<<<<<<<<<<
5102  *         else:
5103  *             mat.data = new_data
5104  */
5105       __pyx_t_2.__pyx_n = 1;
5106       __pyx_t_2.C = __pyx_v_mat;
5107       __pyx_f_5qutip_2cy_7brtools_raise_error_CSR(-1, &__pyx_t_2);
5108 
5109       /* "qutip/cy/sparse_routines.pxi":298
5110  *         new_size = int_min(2*mat.nnz, mat.max_length)
5111  *         new_data = <double complex *>PyDataMem_RENEW(mat.data, new_size * sizeof(double complex))
5112  *         if new_data == NULL:             # <<<<<<<<<<<<<<
5113  *             raise_error_CSR(-1, mat)
5114  *         else:
5115  */
5116       goto __pyx_L6;
5117     }
5118 
5119     /* "qutip/cy/sparse_routines.pxi":301
5120  *             raise_error_CSR(-1, mat)
5121  *         else:
5122  *             mat.data = new_data             # <<<<<<<<<<<<<<
5123  *             if init_zeros == 1:
5124  *                 for ii in range(mat.nnz, new_size):
5125  */
5126     /*else*/ {
5127       __pyx_v_mat->data = __pyx_v_new_data;
5128 
5129       /* "qutip/cy/sparse_routines.pxi":302
5130  *         else:
5131  *             mat.data = new_data
5132  *             if init_zeros == 1:             # <<<<<<<<<<<<<<
5133  *                 for ii in range(mat.nnz, new_size):
5134  *                     mat.data[ii] = 0
5135  */
5136       __pyx_t_1 = ((__pyx_v_init_zeros == 1) != 0);
5137       if (__pyx_t_1) {
5138 
5139         /* "qutip/cy/sparse_routines.pxi":303
5140  *             mat.data = new_data
5141  *             if init_zeros == 1:
5142  *                 for ii in range(mat.nnz, new_size):             # <<<<<<<<<<<<<<
5143  *                     mat.data[ii] = 0
5144  *
5145  */
5146         __pyx_t_4 = __pyx_v_new_size;
5147         __pyx_t_5 = __pyx_t_4;
5148         for (__pyx_t_6 = __pyx_v_mat->nnz; __pyx_t_6 < __pyx_t_5; __pyx_t_6+=1) {
5149           __pyx_v_ii = __pyx_t_6;
5150 
5151           /* "qutip/cy/sparse_routines.pxi":304
5152  *             if init_zeros == 1:
5153  *                 for ii in range(mat.nnz, new_size):
5154  *                     mat.data[ii] = 0             # <<<<<<<<<<<<<<
5155  *
5156  *         new_ind = <int *>PyDataMem_RENEW(mat.indices, new_size * sizeof(int))
5157  */
5158           (__pyx_v_mat->data[__pyx_v_ii]) = __pyx_t_double_complex_from_parts(0, 0);
5159         }
5160 
5161         /* "qutip/cy/sparse_routines.pxi":302
5162  *         else:
5163  *             mat.data = new_data
5164  *             if init_zeros == 1:             # <<<<<<<<<<<<<<
5165  *                 for ii in range(mat.nnz, new_size):
5166  *                     mat.data[ii] = 0
5167  */
5168       }
5169     }
5170     __pyx_L6:;
5171 
5172     /* "qutip/cy/sparse_routines.pxi":306
5173  *                     mat.data[ii] = 0
5174  *
5175  *         new_ind = <int *>PyDataMem_RENEW(mat.indices, new_size * sizeof(int))             # <<<<<<<<<<<<<<
5176  *         mat.indices = new_ind
5177  *         if init_zeros == 1:
5178  */
5179     __pyx_v_new_ind = ((int *)PyDataMem_RENEW(__pyx_v_mat->indices, (__pyx_v_new_size * (sizeof(int)))));
5180 
5181     /* "qutip/cy/sparse_routines.pxi":307
5182  *
5183  *         new_ind = <int *>PyDataMem_RENEW(mat.indices, new_size * sizeof(int))
5184  *         mat.indices = new_ind             # <<<<<<<<<<<<<<
5185  *         if init_zeros == 1:
5186  *             for ii in range(mat.nnz, new_size):
5187  */
5188     __pyx_v_mat->indices = __pyx_v_new_ind;
5189 
5190     /* "qutip/cy/sparse_routines.pxi":308
5191  *         new_ind = <int *>PyDataMem_RENEW(mat.indices, new_size * sizeof(int))
5192  *         mat.indices = new_ind
5193  *         if init_zeros == 1:             # <<<<<<<<<<<<<<
5194  *             for ii in range(mat.nnz, new_size):
5195  *                 mat.indices[ii] = 0
5196  */
5197     __pyx_t_1 = ((__pyx_v_init_zeros == 1) != 0);
5198     if (__pyx_t_1) {
5199 
5200       /* "qutip/cy/sparse_routines.pxi":309
5201  *         mat.indices = new_ind
5202  *         if init_zeros == 1:
5203  *             for ii in range(mat.nnz, new_size):             # <<<<<<<<<<<<<<
5204  *                 mat.indices[ii] = 0
5205  *         mat.nnz = new_size
5206  */
5207       __pyx_t_4 = __pyx_v_new_size;
5208       __pyx_t_5 = __pyx_t_4;
5209       for (__pyx_t_6 = __pyx_v_mat->nnz; __pyx_t_6 < __pyx_t_5; __pyx_t_6+=1) {
5210         __pyx_v_ii = __pyx_t_6;
5211 
5212         /* "qutip/cy/sparse_routines.pxi":310
5213  *         if init_zeros == 1:
5214  *             for ii in range(mat.nnz, new_size):
5215  *                 mat.indices[ii] = 0             # <<<<<<<<<<<<<<
5216  *         mat.nnz = new_size
5217  *     else:
5218  */
5219         (__pyx_v_mat->indices[__pyx_v_ii]) = 0;
5220       }
5221 
5222       /* "qutip/cy/sparse_routines.pxi":308
5223  *         new_ind = <int *>PyDataMem_RENEW(mat.indices, new_size * sizeof(int))
5224  *         mat.indices = new_ind
5225  *         if init_zeros == 1:             # <<<<<<<<<<<<<<
5226  *             for ii in range(mat.nnz, new_size):
5227  *                 mat.indices[ii] = 0
5228  */
5229     }
5230 
5231     /* "qutip/cy/sparse_routines.pxi":311
5232  *             for ii in range(mat.nnz, new_size):
5233  *                 mat.indices[ii] = 0
5234  *         mat.nnz = new_size             # <<<<<<<<<<<<<<
5235  *     else:
5236  *         if mat.numpy_lock:
5237  */
5238     __pyx_v_mat->nnz = __pyx_v_new_size;
5239 
5240     /* "qutip/cy/sparse_routines.pxi":295
5241  *     if mat.nnz == mat.max_length:
5242  *         raise_error_CSR(-5, mat) #Cannot expand data past max_length.
5243  *     elif (not mat.numpy_lock) and mat.is_set:             # <<<<<<<<<<<<<<
5244  *         new_size = int_min(2*mat.nnz, mat.max_length)
5245  *         new_data = <double complex *>PyDataMem_RENEW(mat.data, new_size * sizeof(double complex))
5246  */
5247     goto __pyx_L3;
5248   }
5249 
5250   /* "qutip/cy/sparse_routines.pxi":313
5251  *         mat.nnz = new_size
5252  *     else:
5253  *         if mat.numpy_lock:             # <<<<<<<<<<<<<<
5254  *             raise_error_CSR(-4, mat)
5255  *         elif not mat.is_set:
5256  */
5257   /*else*/ {
5258     __pyx_t_1 = (__pyx_v_mat->numpy_lock != 0);
5259     if (__pyx_t_1) {
5260 
5261       /* "qutip/cy/sparse_routines.pxi":314
5262  *     else:
5263  *         if mat.numpy_lock:
5264  *             raise_error_CSR(-4, mat)             # <<<<<<<<<<<<<<
5265  *         elif not mat.is_set:
5266  *             raise_error_CSR(-3, mat)
5267  */
5268       __pyx_t_2.__pyx_n = 1;
5269       __pyx_t_2.C = __pyx_v_mat;
5270       __pyx_f_5qutip_2cy_7brtools_raise_error_CSR(-4, &__pyx_t_2);
5271 
5272       /* "qutip/cy/sparse_routines.pxi":313
5273  *         mat.nnz = new_size
5274  *     else:
5275  *         if mat.numpy_lock:             # <<<<<<<<<<<<<<
5276  *             raise_error_CSR(-4, mat)
5277  *         elif not mat.is_set:
5278  */
5279       goto __pyx_L13;
5280     }
5281 
5282     /* "qutip/cy/sparse_routines.pxi":315
5283  *         if mat.numpy_lock:
5284  *             raise_error_CSR(-4, mat)
5285  *         elif not mat.is_set:             # <<<<<<<<<<<<<<
5286  *             raise_error_CSR(-3, mat)
5287  *
5288  */
5289     __pyx_t_1 = ((!(__pyx_v_mat->is_set != 0)) != 0);
5290     if (__pyx_t_1) {
5291 
5292       /* "qutip/cy/sparse_routines.pxi":316
5293  *             raise_error_CSR(-4, mat)
5294  *         elif not mat.is_set:
5295  *             raise_error_CSR(-3, mat)             # <<<<<<<<<<<<<<
5296  *
5297  *
5298  */
5299       __pyx_t_2.__pyx_n = 1;
5300       __pyx_t_2.C = __pyx_v_mat;
5301       __pyx_f_5qutip_2cy_7brtools_raise_error_CSR(-3, &__pyx_t_2);
5302 
5303       /* "qutip/cy/sparse_routines.pxi":315
5304  *         if mat.numpy_lock:
5305  *             raise_error_CSR(-4, mat)
5306  *         elif not mat.is_set:             # <<<<<<<<<<<<<<
5307  *             raise_error_CSR(-3, mat)
5308  *
5309  */
5310     }
5311     __pyx_L13:;
5312   }
5313   __pyx_L3:;
5314 
5315   /* "qutip/cy/sparse_routines.pxi":286
5316  * @cython.boundscheck(False)
5317  * @cython.wraparound(False)
5318  * cdef void expand_CSR(CSR_Matrix * mat, int init_zeros=0):             # <<<<<<<<<<<<<<
5319  *     """
5320  *     Expands the length of CSR data and indices arrays to accomodate
5321  */
5322 
5323   /* function exit code */
5324   __Pyx_RefNannyFinishContext();
5325 }
5326 
5327 /* "qutip/cy/sparse_routines.pxi":321
5328  * @cython.boundscheck(False)
5329  * @cython.wraparound(False)
5330  * cdef object CSR_to_scipy(CSR_Matrix * mat):             # <<<<<<<<<<<<<<
5331  *     """
5332  *     Converts a CSR_Matrix struct to a SciPy csr_matrix class object.
5333  */
5334 
__pyx_f_5qutip_2cy_7brtools_CSR_to_scipy(__pyx_t_5qutip_2cy_14sparse_structs_CSR_Matrix * __pyx_v_mat)5335 static PyObject *__pyx_f_5qutip_2cy_7brtools_CSR_to_scipy(__pyx_t_5qutip_2cy_14sparse_structs_CSR_Matrix *__pyx_v_mat) {
5336   npy_intp __pyx_v_dat_len;
5337   npy_intp __pyx_v_ptr_len;
5338   PyArrayObject *__pyx_v__data = 0;
5339   PyArrayObject *__pyx_v__ind = 0;
5340   PyArrayObject *__pyx_v__ptr = 0;
5341   __Pyx_LocalBuf_ND __pyx_pybuffernd__data;
5342   __Pyx_Buffer __pyx_pybuffer__data;
5343   __Pyx_LocalBuf_ND __pyx_pybuffernd__ind;
5344   __Pyx_Buffer __pyx_pybuffer__ind;
5345   __Pyx_LocalBuf_ND __pyx_pybuffernd__ptr;
5346   __Pyx_Buffer __pyx_pybuffer__ptr;
5347   PyObject *__pyx_r = NULL;
5348   __Pyx_RefNannyDeclarations
5349   int __pyx_t_1;
5350   int __pyx_t_2;
5351   int __pyx_t_3;
5352   PyObject *__pyx_t_4 = NULL;
5353   PyArrayObject *__pyx_t_5 = NULL;
5354   PyObject *__pyx_t_6 = NULL;
5355   PyObject *__pyx_t_7 = NULL;
5356   PyObject *__pyx_t_8 = NULL;
5357   PyArrayObject *__pyx_t_9 = NULL;
5358   PyObject *__pyx_t_10 = NULL;
5359   PyObject *__pyx_t_11 = NULL;
5360   PyObject *__pyx_t_12 = NULL;
5361   PyObject *__pyx_t_13 = NULL;
5362   PyObject *__pyx_t_14 = NULL;
5363   int __pyx_lineno = 0;
5364   const char *__pyx_filename = NULL;
5365   int __pyx_clineno = 0;
5366   __Pyx_RefNannySetupContext("CSR_to_scipy", 0);
5367   __pyx_pybuffer__data.pybuffer.buf = NULL;
5368   __pyx_pybuffer__data.refcount = 0;
5369   __pyx_pybuffernd__data.data = NULL;
5370   __pyx_pybuffernd__data.rcbuffer = &__pyx_pybuffer__data;
5371   __pyx_pybuffer__ind.pybuffer.buf = NULL;
5372   __pyx_pybuffer__ind.refcount = 0;
5373   __pyx_pybuffernd__ind.data = NULL;
5374   __pyx_pybuffernd__ind.rcbuffer = &__pyx_pybuffer__ind;
5375   __pyx_pybuffer__ptr.pybuffer.buf = NULL;
5376   __pyx_pybuffer__ptr.refcount = 0;
5377   __pyx_pybuffernd__ptr.data = NULL;
5378   __pyx_pybuffernd__ptr.rcbuffer = &__pyx_pybuffer__ptr;
5379 
5380   /* "qutip/cy/sparse_routines.pxi":336
5381  *     cdef np.ndarray[complex, ndim=1] _data
5382  *     cdef np.ndarray[int, ndim=1] _ind, _ptr
5383  *     if (not mat.numpy_lock) and mat.is_set:             # <<<<<<<<<<<<<<
5384  *         dat_len = mat.nnz
5385  *         ptr_len = mat.nrows+1
5386  */
5387   __pyx_t_2 = ((!(__pyx_v_mat->numpy_lock != 0)) != 0);
5388   if (__pyx_t_2) {
5389   } else {
5390     __pyx_t_1 = __pyx_t_2;
5391     goto __pyx_L4_bool_binop_done;
5392   }
5393   __pyx_t_2 = (__pyx_v_mat->is_set != 0);
5394   __pyx_t_1 = __pyx_t_2;
5395   __pyx_L4_bool_binop_done:;
5396   if (__pyx_t_1) {
5397 
5398     /* "qutip/cy/sparse_routines.pxi":337
5399  *     cdef np.ndarray[int, ndim=1] _ind, _ptr
5400  *     if (not mat.numpy_lock) and mat.is_set:
5401  *         dat_len = mat.nnz             # <<<<<<<<<<<<<<
5402  *         ptr_len = mat.nrows+1
5403  *         _data = np.PyArray_SimpleNewFromData(1, &dat_len, np.NPY_COMPLEX128, mat.data)
5404  */
5405     __pyx_t_3 = __pyx_v_mat->nnz;
5406     __pyx_v_dat_len = __pyx_t_3;
5407 
5408     /* "qutip/cy/sparse_routines.pxi":338
5409  *     if (not mat.numpy_lock) and mat.is_set:
5410  *         dat_len = mat.nnz
5411  *         ptr_len = mat.nrows+1             # <<<<<<<<<<<<<<
5412  *         _data = np.PyArray_SimpleNewFromData(1, &dat_len, np.NPY_COMPLEX128, mat.data)
5413  *         PyArray_ENABLEFLAGS(_data, np.NPY_ARRAY_OWNDATA)
5414  */
5415     __pyx_v_ptr_len = (__pyx_v_mat->nrows + 1);
5416 
5417     /* "qutip/cy/sparse_routines.pxi":339
5418  *         dat_len = mat.nnz
5419  *         ptr_len = mat.nrows+1
5420  *         _data = np.PyArray_SimpleNewFromData(1, &dat_len, np.NPY_COMPLEX128, mat.data)             # <<<<<<<<<<<<<<
5421  *         PyArray_ENABLEFLAGS(_data, np.NPY_ARRAY_OWNDATA)
5422  *
5423  */
5424     __pyx_t_4 = PyArray_SimpleNewFromData(1, (&__pyx_v_dat_len), NPY_COMPLEX128, __pyx_v_mat->data); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 339, __pyx_L1_error)
5425     __Pyx_GOTREF(__pyx_t_4);
5426     if (!(likely(((__pyx_t_4) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_4, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 339, __pyx_L1_error)
5427     __pyx_t_5 = ((PyArrayObject *)__pyx_t_4);
5428     {
5429       __Pyx_BufFmt_StackElem __pyx_stack[1];
5430       __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd__data.rcbuffer->pybuffer);
5431       __pyx_t_3 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd__data.rcbuffer->pybuffer, (PyObject*)__pyx_t_5, &__Pyx_TypeInfo___pyx_t_double_complex, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack);
5432       if (unlikely(__pyx_t_3 < 0)) {
5433         PyErr_Fetch(&__pyx_t_6, &__pyx_t_7, &__pyx_t_8);
5434         if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd__data.rcbuffer->pybuffer, (PyObject*)__pyx_v__data, &__Pyx_TypeInfo___pyx_t_double_complex, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {
5435           Py_XDECREF(__pyx_t_6); Py_XDECREF(__pyx_t_7); Py_XDECREF(__pyx_t_8);
5436           __Pyx_RaiseBufferFallbackError();
5437         } else {
5438           PyErr_Restore(__pyx_t_6, __pyx_t_7, __pyx_t_8);
5439         }
5440         __pyx_t_6 = __pyx_t_7 = __pyx_t_8 = 0;
5441       }
5442       __pyx_pybuffernd__data.diminfo[0].strides = __pyx_pybuffernd__data.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd__data.diminfo[0].shape = __pyx_pybuffernd__data.rcbuffer->pybuffer.shape[0];
5443       if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(0, 339, __pyx_L1_error)
5444     }
5445     __pyx_t_5 = 0;
5446     __pyx_v__data = ((PyArrayObject *)__pyx_t_4);
5447     __pyx_t_4 = 0;
5448 
5449     /* "qutip/cy/sparse_routines.pxi":340
5450  *         ptr_len = mat.nrows+1
5451  *         _data = np.PyArray_SimpleNewFromData(1, &dat_len, np.NPY_COMPLEX128, mat.data)
5452  *         PyArray_ENABLEFLAGS(_data, np.NPY_ARRAY_OWNDATA)             # <<<<<<<<<<<<<<
5453  *
5454  *         _ind = np.PyArray_SimpleNewFromData(1, &dat_len, np.NPY_INT32, mat.indices)
5455  */
5456     PyArray_ENABLEFLAGS(((PyArrayObject *)__pyx_v__data), NPY_ARRAY_OWNDATA);
5457 
5458     /* "qutip/cy/sparse_routines.pxi":342
5459  *         PyArray_ENABLEFLAGS(_data, np.NPY_ARRAY_OWNDATA)
5460  *
5461  *         _ind = np.PyArray_SimpleNewFromData(1, &dat_len, np.NPY_INT32, mat.indices)             # <<<<<<<<<<<<<<
5462  *         PyArray_ENABLEFLAGS(_ind, np.NPY_ARRAY_OWNDATA)
5463  *
5464  */
5465     __pyx_t_4 = PyArray_SimpleNewFromData(1, (&__pyx_v_dat_len), NPY_INT32, __pyx_v_mat->indices); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 342, __pyx_L1_error)
5466     __Pyx_GOTREF(__pyx_t_4);
5467     if (!(likely(((__pyx_t_4) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_4, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 342, __pyx_L1_error)
5468     __pyx_t_9 = ((PyArrayObject *)__pyx_t_4);
5469     {
5470       __Pyx_BufFmt_StackElem __pyx_stack[1];
5471       __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd__ind.rcbuffer->pybuffer);
5472       __pyx_t_3 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd__ind.rcbuffer->pybuffer, (PyObject*)__pyx_t_9, &__Pyx_TypeInfo_int, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack);
5473       if (unlikely(__pyx_t_3 < 0)) {
5474         PyErr_Fetch(&__pyx_t_8, &__pyx_t_7, &__pyx_t_6);
5475         if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd__ind.rcbuffer->pybuffer, (PyObject*)__pyx_v__ind, &__Pyx_TypeInfo_int, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {
5476           Py_XDECREF(__pyx_t_8); Py_XDECREF(__pyx_t_7); Py_XDECREF(__pyx_t_6);
5477           __Pyx_RaiseBufferFallbackError();
5478         } else {
5479           PyErr_Restore(__pyx_t_8, __pyx_t_7, __pyx_t_6);
5480         }
5481         __pyx_t_8 = __pyx_t_7 = __pyx_t_6 = 0;
5482       }
5483       __pyx_pybuffernd__ind.diminfo[0].strides = __pyx_pybuffernd__ind.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd__ind.diminfo[0].shape = __pyx_pybuffernd__ind.rcbuffer->pybuffer.shape[0];
5484       if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(0, 342, __pyx_L1_error)
5485     }
5486     __pyx_t_9 = 0;
5487     __pyx_v__ind = ((PyArrayObject *)__pyx_t_4);
5488     __pyx_t_4 = 0;
5489 
5490     /* "qutip/cy/sparse_routines.pxi":343
5491  *
5492  *         _ind = np.PyArray_SimpleNewFromData(1, &dat_len, np.NPY_INT32, mat.indices)
5493  *         PyArray_ENABLEFLAGS(_ind, np.NPY_ARRAY_OWNDATA)             # <<<<<<<<<<<<<<
5494  *
5495  *         _ptr = np.PyArray_SimpleNewFromData(1, &ptr_len, np.NPY_INT32, mat.indptr)
5496  */
5497     PyArray_ENABLEFLAGS(((PyArrayObject *)__pyx_v__ind), NPY_ARRAY_OWNDATA);
5498 
5499     /* "qutip/cy/sparse_routines.pxi":345
5500  *         PyArray_ENABLEFLAGS(_ind, np.NPY_ARRAY_OWNDATA)
5501  *
5502  *         _ptr = np.PyArray_SimpleNewFromData(1, &ptr_len, np.NPY_INT32, mat.indptr)             # <<<<<<<<<<<<<<
5503  *         PyArray_ENABLEFLAGS(_ptr, np.NPY_ARRAY_OWNDATA)
5504  *         mat.numpy_lock = 1
5505  */
5506     __pyx_t_4 = PyArray_SimpleNewFromData(1, (&__pyx_v_ptr_len), NPY_INT32, __pyx_v_mat->indptr); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 345, __pyx_L1_error)
5507     __Pyx_GOTREF(__pyx_t_4);
5508     if (!(likely(((__pyx_t_4) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_4, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 345, __pyx_L1_error)
5509     __pyx_t_9 = ((PyArrayObject *)__pyx_t_4);
5510     {
5511       __Pyx_BufFmt_StackElem __pyx_stack[1];
5512       __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd__ptr.rcbuffer->pybuffer);
5513       __pyx_t_3 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd__ptr.rcbuffer->pybuffer, (PyObject*)__pyx_t_9, &__Pyx_TypeInfo_int, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack);
5514       if (unlikely(__pyx_t_3 < 0)) {
5515         PyErr_Fetch(&__pyx_t_6, &__pyx_t_7, &__pyx_t_8);
5516         if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd__ptr.rcbuffer->pybuffer, (PyObject*)__pyx_v__ptr, &__Pyx_TypeInfo_int, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {
5517           Py_XDECREF(__pyx_t_6); Py_XDECREF(__pyx_t_7); Py_XDECREF(__pyx_t_8);
5518           __Pyx_RaiseBufferFallbackError();
5519         } else {
5520           PyErr_Restore(__pyx_t_6, __pyx_t_7, __pyx_t_8);
5521         }
5522         __pyx_t_6 = __pyx_t_7 = __pyx_t_8 = 0;
5523       }
5524       __pyx_pybuffernd__ptr.diminfo[0].strides = __pyx_pybuffernd__ptr.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd__ptr.diminfo[0].shape = __pyx_pybuffernd__ptr.rcbuffer->pybuffer.shape[0];
5525       if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(0, 345, __pyx_L1_error)
5526     }
5527     __pyx_t_9 = 0;
5528     __pyx_v__ptr = ((PyArrayObject *)__pyx_t_4);
5529     __pyx_t_4 = 0;
5530 
5531     /* "qutip/cy/sparse_routines.pxi":346
5532  *
5533  *         _ptr = np.PyArray_SimpleNewFromData(1, &ptr_len, np.NPY_INT32, mat.indptr)
5534  *         PyArray_ENABLEFLAGS(_ptr, np.NPY_ARRAY_OWNDATA)             # <<<<<<<<<<<<<<
5535  *         mat.numpy_lock = 1
5536  *         return fast_csr_matrix((_data, _ind, _ptr), shape=(mat.nrows,mat.ncols))
5537  */
5538     PyArray_ENABLEFLAGS(((PyArrayObject *)__pyx_v__ptr), NPY_ARRAY_OWNDATA);
5539 
5540     /* "qutip/cy/sparse_routines.pxi":347
5541  *         _ptr = np.PyArray_SimpleNewFromData(1, &ptr_len, np.NPY_INT32, mat.indptr)
5542  *         PyArray_ENABLEFLAGS(_ptr, np.NPY_ARRAY_OWNDATA)
5543  *         mat.numpy_lock = 1             # <<<<<<<<<<<<<<
5544  *         return fast_csr_matrix((_data, _ind, _ptr), shape=(mat.nrows,mat.ncols))
5545  *     else:
5546  */
5547     __pyx_v_mat->numpy_lock = 1;
5548 
5549     /* "qutip/cy/sparse_routines.pxi":348
5550  *         PyArray_ENABLEFLAGS(_ptr, np.NPY_ARRAY_OWNDATA)
5551  *         mat.numpy_lock = 1
5552  *         return fast_csr_matrix((_data, _ind, _ptr), shape=(mat.nrows,mat.ncols))             # <<<<<<<<<<<<<<
5553  *     else:
5554  *         if mat.numpy_lock:
5555  */
5556     __Pyx_XDECREF(__pyx_r);
5557     __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_fast_csr_matrix); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 348, __pyx_L1_error)
5558     __Pyx_GOTREF(__pyx_t_4);
5559     __pyx_t_10 = PyTuple_New(3); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 348, __pyx_L1_error)
5560     __Pyx_GOTREF(__pyx_t_10);
5561     __Pyx_INCREF(((PyObject *)__pyx_v__data));
5562     __Pyx_GIVEREF(((PyObject *)__pyx_v__data));
5563     PyTuple_SET_ITEM(__pyx_t_10, 0, ((PyObject *)__pyx_v__data));
5564     __Pyx_INCREF(((PyObject *)__pyx_v__ind));
5565     __Pyx_GIVEREF(((PyObject *)__pyx_v__ind));
5566     PyTuple_SET_ITEM(__pyx_t_10, 1, ((PyObject *)__pyx_v__ind));
5567     __Pyx_INCREF(((PyObject *)__pyx_v__ptr));
5568     __Pyx_GIVEREF(((PyObject *)__pyx_v__ptr));
5569     PyTuple_SET_ITEM(__pyx_t_10, 2, ((PyObject *)__pyx_v__ptr));
5570     __pyx_t_11 = PyTuple_New(1); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 348, __pyx_L1_error)
5571     __Pyx_GOTREF(__pyx_t_11);
5572     __Pyx_GIVEREF(__pyx_t_10);
5573     PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_t_10);
5574     __pyx_t_10 = 0;
5575     __pyx_t_10 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 348, __pyx_L1_error)
5576     __Pyx_GOTREF(__pyx_t_10);
5577     __pyx_t_12 = __Pyx_PyInt_From_int(__pyx_v_mat->nrows); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 348, __pyx_L1_error)
5578     __Pyx_GOTREF(__pyx_t_12);
5579     __pyx_t_13 = __Pyx_PyInt_From_int(__pyx_v_mat->ncols); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 348, __pyx_L1_error)
5580     __Pyx_GOTREF(__pyx_t_13);
5581     __pyx_t_14 = PyTuple_New(2); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 348, __pyx_L1_error)
5582     __Pyx_GOTREF(__pyx_t_14);
5583     __Pyx_GIVEREF(__pyx_t_12);
5584     PyTuple_SET_ITEM(__pyx_t_14, 0, __pyx_t_12);
5585     __Pyx_GIVEREF(__pyx_t_13);
5586     PyTuple_SET_ITEM(__pyx_t_14, 1, __pyx_t_13);
5587     __pyx_t_12 = 0;
5588     __pyx_t_13 = 0;
5589     if (PyDict_SetItem(__pyx_t_10, __pyx_n_s_shape, __pyx_t_14) < 0) __PYX_ERR(0, 348, __pyx_L1_error)
5590     __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
5591     __pyx_t_14 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_11, __pyx_t_10); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 348, __pyx_L1_error)
5592     __Pyx_GOTREF(__pyx_t_14);
5593     __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
5594     __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
5595     __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
5596     __pyx_r = __pyx_t_14;
5597     __pyx_t_14 = 0;
5598     goto __pyx_L0;
5599 
5600     /* "qutip/cy/sparse_routines.pxi":336
5601  *     cdef np.ndarray[complex, ndim=1] _data
5602  *     cdef np.ndarray[int, ndim=1] _ind, _ptr
5603  *     if (not mat.numpy_lock) and mat.is_set:             # <<<<<<<<<<<<<<
5604  *         dat_len = mat.nnz
5605  *         ptr_len = mat.nrows+1
5606  */
5607   }
5608 
5609   /* "qutip/cy/sparse_routines.pxi":350
5610  *         return fast_csr_matrix((_data, _ind, _ptr), shape=(mat.nrows,mat.ncols))
5611  *     else:
5612  *         if mat.numpy_lock:             # <<<<<<<<<<<<<<
5613  *             raise_error_CSR(-4)
5614  *         elif not mat.is_set:
5615  */
5616   /*else*/ {
5617     __pyx_t_1 = (__pyx_v_mat->numpy_lock != 0);
5618     if (__pyx_t_1) {
5619 
5620       /* "qutip/cy/sparse_routines.pxi":351
5621  *     else:
5622  *         if mat.numpy_lock:
5623  *             raise_error_CSR(-4)             # <<<<<<<<<<<<<<
5624  *         elif not mat.is_set:
5625  *             raise_error_CSR(-3)
5626  */
5627       __pyx_f_5qutip_2cy_7brtools_raise_error_CSR(-4, NULL);
5628 
5629       /* "qutip/cy/sparse_routines.pxi":350
5630  *         return fast_csr_matrix((_data, _ind, _ptr), shape=(mat.nrows,mat.ncols))
5631  *     else:
5632  *         if mat.numpy_lock:             # <<<<<<<<<<<<<<
5633  *             raise_error_CSR(-4)
5634  *         elif not mat.is_set:
5635  */
5636       goto __pyx_L6;
5637     }
5638 
5639     /* "qutip/cy/sparse_routines.pxi":352
5640  *         if mat.numpy_lock:
5641  *             raise_error_CSR(-4)
5642  *         elif not mat.is_set:             # <<<<<<<<<<<<<<
5643  *             raise_error_CSR(-3)
5644  *
5645  */
5646     __pyx_t_1 = ((!(__pyx_v_mat->is_set != 0)) != 0);
5647     if (__pyx_t_1) {
5648 
5649       /* "qutip/cy/sparse_routines.pxi":353
5650  *             raise_error_CSR(-4)
5651  *         elif not mat.is_set:
5652  *             raise_error_CSR(-3)             # <<<<<<<<<<<<<<
5653  *
5654  *
5655  */
5656       __pyx_f_5qutip_2cy_7brtools_raise_error_CSR(-3, NULL);
5657 
5658       /* "qutip/cy/sparse_routines.pxi":352
5659  *         if mat.numpy_lock:
5660  *             raise_error_CSR(-4)
5661  *         elif not mat.is_set:             # <<<<<<<<<<<<<<
5662  *             raise_error_CSR(-3)
5663  *
5664  */
5665     }
5666     __pyx_L6:;
5667   }
5668 
5669   /* "qutip/cy/sparse_routines.pxi":321
5670  * @cython.boundscheck(False)
5671  * @cython.wraparound(False)
5672  * cdef object CSR_to_scipy(CSR_Matrix * mat):             # <<<<<<<<<<<<<<
5673  *     """
5674  *     Converts a CSR_Matrix struct to a SciPy csr_matrix class object.
5675  */
5676 
5677   /* function exit code */
5678   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
5679   goto __pyx_L0;
5680   __pyx_L1_error:;
5681   __Pyx_XDECREF(__pyx_t_4);
5682   __Pyx_XDECREF(__pyx_t_10);
5683   __Pyx_XDECREF(__pyx_t_11);
5684   __Pyx_XDECREF(__pyx_t_12);
5685   __Pyx_XDECREF(__pyx_t_13);
5686   __Pyx_XDECREF(__pyx_t_14);
5687   { PyObject *__pyx_type, *__pyx_value, *__pyx_tb;
5688     __Pyx_PyThreadState_declare
5689     __Pyx_PyThreadState_assign
5690     __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb);
5691     __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd__data.rcbuffer->pybuffer);
5692     __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd__ind.rcbuffer->pybuffer);
5693     __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd__ptr.rcbuffer->pybuffer);
5694   __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}
5695   __Pyx_AddTraceback("qutip.cy.brtools.CSR_to_scipy", __pyx_clineno, __pyx_lineno, __pyx_filename);
5696   __pyx_r = 0;
5697   goto __pyx_L2;
5698   __pyx_L0:;
5699   __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd__data.rcbuffer->pybuffer);
5700   __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd__ind.rcbuffer->pybuffer);
5701   __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd__ptr.rcbuffer->pybuffer);
5702   __pyx_L2:;
5703   __Pyx_XDECREF((PyObject *)__pyx_v__data);
5704   __Pyx_XDECREF((PyObject *)__pyx_v__ind);
5705   __Pyx_XDECREF((PyObject *)__pyx_v__ptr);
5706   __Pyx_XGIVEREF(__pyx_r);
5707   __Pyx_RefNannyFinishContext();
5708   return __pyx_r;
5709 }
5710 
5711 /* "qutip/cy/sparse_routines.pxi":358
5712  * @cython.boundscheck(False)
5713  * @cython.wraparound(False)
5714  * cdef object COO_to_scipy(COO_Matrix * mat):             # <<<<<<<<<<<<<<
5715  *     """
5716  *     Converts a COO_Matrix struct to a SciPy coo_matrix class object.
5717  */
5718 
__pyx_f_5qutip_2cy_7brtools_COO_to_scipy(__pyx_t_5qutip_2cy_14sparse_structs_COO_Matrix * __pyx_v_mat)5719 static PyObject *__pyx_f_5qutip_2cy_7brtools_COO_to_scipy(__pyx_t_5qutip_2cy_14sparse_structs_COO_Matrix *__pyx_v_mat) {
5720   npy_intp __pyx_v_dat_len;
5721   PyArrayObject *__pyx_v__data = 0;
5722   PyArrayObject *__pyx_v__row = 0;
5723   PyArrayObject *__pyx_v__col = 0;
5724   __Pyx_LocalBuf_ND __pyx_pybuffernd__col;
5725   __Pyx_Buffer __pyx_pybuffer__col;
5726   __Pyx_LocalBuf_ND __pyx_pybuffernd__data;
5727   __Pyx_Buffer __pyx_pybuffer__data;
5728   __Pyx_LocalBuf_ND __pyx_pybuffernd__row;
5729   __Pyx_Buffer __pyx_pybuffer__row;
5730   PyObject *__pyx_r = NULL;
5731   __Pyx_RefNannyDeclarations
5732   int __pyx_t_1;
5733   int __pyx_t_2;
5734   int __pyx_t_3;
5735   PyObject *__pyx_t_4 = NULL;
5736   PyArrayObject *__pyx_t_5 = NULL;
5737   PyObject *__pyx_t_6 = NULL;
5738   PyObject *__pyx_t_7 = NULL;
5739   PyObject *__pyx_t_8 = NULL;
5740   PyArrayObject *__pyx_t_9 = NULL;
5741   PyObject *__pyx_t_10 = NULL;
5742   PyObject *__pyx_t_11 = NULL;
5743   PyObject *__pyx_t_12 = NULL;
5744   PyObject *__pyx_t_13 = NULL;
5745   PyObject *__pyx_t_14 = NULL;
5746   int __pyx_lineno = 0;
5747   const char *__pyx_filename = NULL;
5748   int __pyx_clineno = 0;
5749   __Pyx_RefNannySetupContext("COO_to_scipy", 0);
5750   __pyx_pybuffer__data.pybuffer.buf = NULL;
5751   __pyx_pybuffer__data.refcount = 0;
5752   __pyx_pybuffernd__data.data = NULL;
5753   __pyx_pybuffernd__data.rcbuffer = &__pyx_pybuffer__data;
5754   __pyx_pybuffer__row.pybuffer.buf = NULL;
5755   __pyx_pybuffer__row.refcount = 0;
5756   __pyx_pybuffernd__row.data = NULL;
5757   __pyx_pybuffernd__row.rcbuffer = &__pyx_pybuffer__row;
5758   __pyx_pybuffer__col.pybuffer.buf = NULL;
5759   __pyx_pybuffer__col.refcount = 0;
5760   __pyx_pybuffernd__col.data = NULL;
5761   __pyx_pybuffernd__col.rcbuffer = &__pyx_pybuffer__col;
5762 
5763   /* "qutip/cy/sparse_routines.pxi":373
5764  *     cdef np.ndarray[complex, ndim=1] _data
5765  *     cdef np.ndarray[int, ndim=1] _row, _col
5766  *     if (not mat.numpy_lock) and mat.is_set:             # <<<<<<<<<<<<<<
5767  *         dat_len = mat.nnz
5768  *         _data = np.PyArray_SimpleNewFromData(1, &dat_len, np.NPY_COMPLEX128, mat.data)
5769  */
5770   __pyx_t_2 = ((!(__pyx_v_mat->numpy_lock != 0)) != 0);
5771   if (__pyx_t_2) {
5772   } else {
5773     __pyx_t_1 = __pyx_t_2;
5774     goto __pyx_L4_bool_binop_done;
5775   }
5776   __pyx_t_2 = (__pyx_v_mat->is_set != 0);
5777   __pyx_t_1 = __pyx_t_2;
5778   __pyx_L4_bool_binop_done:;
5779   if (__pyx_t_1) {
5780 
5781     /* "qutip/cy/sparse_routines.pxi":374
5782  *     cdef np.ndarray[int, ndim=1] _row, _col
5783  *     if (not mat.numpy_lock) and mat.is_set:
5784  *         dat_len = mat.nnz             # <<<<<<<<<<<<<<
5785  *         _data = np.PyArray_SimpleNewFromData(1, &dat_len, np.NPY_COMPLEX128, mat.data)
5786  *         PyArray_ENABLEFLAGS(_data, np.NPY_ARRAY_OWNDATA)
5787  */
5788     __pyx_t_3 = __pyx_v_mat->nnz;
5789     __pyx_v_dat_len = __pyx_t_3;
5790 
5791     /* "qutip/cy/sparse_routines.pxi":375
5792  *     if (not mat.numpy_lock) and mat.is_set:
5793  *         dat_len = mat.nnz
5794  *         _data = np.PyArray_SimpleNewFromData(1, &dat_len, np.NPY_COMPLEX128, mat.data)             # <<<<<<<<<<<<<<
5795  *         PyArray_ENABLEFLAGS(_data, np.NPY_ARRAY_OWNDATA)
5796  *
5797  */
5798     __pyx_t_4 = PyArray_SimpleNewFromData(1, (&__pyx_v_dat_len), NPY_COMPLEX128, __pyx_v_mat->data); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 375, __pyx_L1_error)
5799     __Pyx_GOTREF(__pyx_t_4);
5800     if (!(likely(((__pyx_t_4) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_4, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 375, __pyx_L1_error)
5801     __pyx_t_5 = ((PyArrayObject *)__pyx_t_4);
5802     {
5803       __Pyx_BufFmt_StackElem __pyx_stack[1];
5804       __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd__data.rcbuffer->pybuffer);
5805       __pyx_t_3 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd__data.rcbuffer->pybuffer, (PyObject*)__pyx_t_5, &__Pyx_TypeInfo___pyx_t_double_complex, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack);
5806       if (unlikely(__pyx_t_3 < 0)) {
5807         PyErr_Fetch(&__pyx_t_6, &__pyx_t_7, &__pyx_t_8);
5808         if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd__data.rcbuffer->pybuffer, (PyObject*)__pyx_v__data, &__Pyx_TypeInfo___pyx_t_double_complex, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {
5809           Py_XDECREF(__pyx_t_6); Py_XDECREF(__pyx_t_7); Py_XDECREF(__pyx_t_8);
5810           __Pyx_RaiseBufferFallbackError();
5811         } else {
5812           PyErr_Restore(__pyx_t_6, __pyx_t_7, __pyx_t_8);
5813         }
5814         __pyx_t_6 = __pyx_t_7 = __pyx_t_8 = 0;
5815       }
5816       __pyx_pybuffernd__data.diminfo[0].strides = __pyx_pybuffernd__data.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd__data.diminfo[0].shape = __pyx_pybuffernd__data.rcbuffer->pybuffer.shape[0];
5817       if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(0, 375, __pyx_L1_error)
5818     }
5819     __pyx_t_5 = 0;
5820     __pyx_v__data = ((PyArrayObject *)__pyx_t_4);
5821     __pyx_t_4 = 0;
5822 
5823     /* "qutip/cy/sparse_routines.pxi":376
5824  *         dat_len = mat.nnz
5825  *         _data = np.PyArray_SimpleNewFromData(1, &dat_len, np.NPY_COMPLEX128, mat.data)
5826  *         PyArray_ENABLEFLAGS(_data, np.NPY_ARRAY_OWNDATA)             # <<<<<<<<<<<<<<
5827  *
5828  *         _row = np.PyArray_SimpleNewFromData(1, &dat_len, np.NPY_INT32, mat.rows)
5829  */
5830     PyArray_ENABLEFLAGS(((PyArrayObject *)__pyx_v__data), NPY_ARRAY_OWNDATA);
5831 
5832     /* "qutip/cy/sparse_routines.pxi":378
5833  *         PyArray_ENABLEFLAGS(_data, np.NPY_ARRAY_OWNDATA)
5834  *
5835  *         _row = np.PyArray_SimpleNewFromData(1, &dat_len, np.NPY_INT32, mat.rows)             # <<<<<<<<<<<<<<
5836  *         PyArray_ENABLEFLAGS(_row, np.NPY_ARRAY_OWNDATA)
5837  *
5838  */
5839     __pyx_t_4 = PyArray_SimpleNewFromData(1, (&__pyx_v_dat_len), NPY_INT32, __pyx_v_mat->rows); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 378, __pyx_L1_error)
5840     __Pyx_GOTREF(__pyx_t_4);
5841     if (!(likely(((__pyx_t_4) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_4, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 378, __pyx_L1_error)
5842     __pyx_t_9 = ((PyArrayObject *)__pyx_t_4);
5843     {
5844       __Pyx_BufFmt_StackElem __pyx_stack[1];
5845       __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd__row.rcbuffer->pybuffer);
5846       __pyx_t_3 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd__row.rcbuffer->pybuffer, (PyObject*)__pyx_t_9, &__Pyx_TypeInfo_int, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack);
5847       if (unlikely(__pyx_t_3 < 0)) {
5848         PyErr_Fetch(&__pyx_t_8, &__pyx_t_7, &__pyx_t_6);
5849         if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd__row.rcbuffer->pybuffer, (PyObject*)__pyx_v__row, &__Pyx_TypeInfo_int, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {
5850           Py_XDECREF(__pyx_t_8); Py_XDECREF(__pyx_t_7); Py_XDECREF(__pyx_t_6);
5851           __Pyx_RaiseBufferFallbackError();
5852         } else {
5853           PyErr_Restore(__pyx_t_8, __pyx_t_7, __pyx_t_6);
5854         }
5855         __pyx_t_8 = __pyx_t_7 = __pyx_t_6 = 0;
5856       }
5857       __pyx_pybuffernd__row.diminfo[0].strides = __pyx_pybuffernd__row.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd__row.diminfo[0].shape = __pyx_pybuffernd__row.rcbuffer->pybuffer.shape[0];
5858       if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(0, 378, __pyx_L1_error)
5859     }
5860     __pyx_t_9 = 0;
5861     __pyx_v__row = ((PyArrayObject *)__pyx_t_4);
5862     __pyx_t_4 = 0;
5863 
5864     /* "qutip/cy/sparse_routines.pxi":379
5865  *
5866  *         _row = np.PyArray_SimpleNewFromData(1, &dat_len, np.NPY_INT32, mat.rows)
5867  *         PyArray_ENABLEFLAGS(_row, np.NPY_ARRAY_OWNDATA)             # <<<<<<<<<<<<<<
5868  *
5869  *         _col = np.PyArray_SimpleNewFromData(1, &dat_len, np.NPY_INT32, mat.cols)
5870  */
5871     PyArray_ENABLEFLAGS(((PyArrayObject *)__pyx_v__row), NPY_ARRAY_OWNDATA);
5872 
5873     /* "qutip/cy/sparse_routines.pxi":381
5874  *         PyArray_ENABLEFLAGS(_row, np.NPY_ARRAY_OWNDATA)
5875  *
5876  *         _col = np.PyArray_SimpleNewFromData(1, &dat_len, np.NPY_INT32, mat.cols)             # <<<<<<<<<<<<<<
5877  *         PyArray_ENABLEFLAGS(_col, np.NPY_ARRAY_OWNDATA)
5878  *         mat.numpy_lock = 1
5879  */
5880     __pyx_t_4 = PyArray_SimpleNewFromData(1, (&__pyx_v_dat_len), NPY_INT32, __pyx_v_mat->cols); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 381, __pyx_L1_error)
5881     __Pyx_GOTREF(__pyx_t_4);
5882     if (!(likely(((__pyx_t_4) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_4, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 381, __pyx_L1_error)
5883     __pyx_t_9 = ((PyArrayObject *)__pyx_t_4);
5884     {
5885       __Pyx_BufFmt_StackElem __pyx_stack[1];
5886       __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd__col.rcbuffer->pybuffer);
5887       __pyx_t_3 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd__col.rcbuffer->pybuffer, (PyObject*)__pyx_t_9, &__Pyx_TypeInfo_int, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack);
5888       if (unlikely(__pyx_t_3 < 0)) {
5889         PyErr_Fetch(&__pyx_t_6, &__pyx_t_7, &__pyx_t_8);
5890         if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd__col.rcbuffer->pybuffer, (PyObject*)__pyx_v__col, &__Pyx_TypeInfo_int, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {
5891           Py_XDECREF(__pyx_t_6); Py_XDECREF(__pyx_t_7); Py_XDECREF(__pyx_t_8);
5892           __Pyx_RaiseBufferFallbackError();
5893         } else {
5894           PyErr_Restore(__pyx_t_6, __pyx_t_7, __pyx_t_8);
5895         }
5896         __pyx_t_6 = __pyx_t_7 = __pyx_t_8 = 0;
5897       }
5898       __pyx_pybuffernd__col.diminfo[0].strides = __pyx_pybuffernd__col.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd__col.diminfo[0].shape = __pyx_pybuffernd__col.rcbuffer->pybuffer.shape[0];
5899       if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(0, 381, __pyx_L1_error)
5900     }
5901     __pyx_t_9 = 0;
5902     __pyx_v__col = ((PyArrayObject *)__pyx_t_4);
5903     __pyx_t_4 = 0;
5904 
5905     /* "qutip/cy/sparse_routines.pxi":382
5906  *
5907  *         _col = np.PyArray_SimpleNewFromData(1, &dat_len, np.NPY_INT32, mat.cols)
5908  *         PyArray_ENABLEFLAGS(_col, np.NPY_ARRAY_OWNDATA)             # <<<<<<<<<<<<<<
5909  *         mat.numpy_lock = 1
5910  *         return coo_matrix((_data, (_row, _col)), shape=(mat.nrows,mat.ncols))
5911  */
5912     PyArray_ENABLEFLAGS(((PyArrayObject *)__pyx_v__col), NPY_ARRAY_OWNDATA);
5913 
5914     /* "qutip/cy/sparse_routines.pxi":383
5915  *         _col = np.PyArray_SimpleNewFromData(1, &dat_len, np.NPY_INT32, mat.cols)
5916  *         PyArray_ENABLEFLAGS(_col, np.NPY_ARRAY_OWNDATA)
5917  *         mat.numpy_lock = 1             # <<<<<<<<<<<<<<
5918  *         return coo_matrix((_data, (_row, _col)), shape=(mat.nrows,mat.ncols))
5919  *     else:
5920  */
5921     __pyx_v_mat->numpy_lock = 1;
5922 
5923     /* "qutip/cy/sparse_routines.pxi":384
5924  *         PyArray_ENABLEFLAGS(_col, np.NPY_ARRAY_OWNDATA)
5925  *         mat.numpy_lock = 1
5926  *         return coo_matrix((_data, (_row, _col)), shape=(mat.nrows,mat.ncols))             # <<<<<<<<<<<<<<
5927  *     else:
5928  *         if mat.numpy_lock:
5929  */
5930     __Pyx_XDECREF(__pyx_r);
5931     __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_coo_matrix); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 384, __pyx_L1_error)
5932     __Pyx_GOTREF(__pyx_t_4);
5933     __pyx_t_10 = PyTuple_New(2); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 384, __pyx_L1_error)
5934     __Pyx_GOTREF(__pyx_t_10);
5935     __Pyx_INCREF(((PyObject *)__pyx_v__row));
5936     __Pyx_GIVEREF(((PyObject *)__pyx_v__row));
5937     PyTuple_SET_ITEM(__pyx_t_10, 0, ((PyObject *)__pyx_v__row));
5938     __Pyx_INCREF(((PyObject *)__pyx_v__col));
5939     __Pyx_GIVEREF(((PyObject *)__pyx_v__col));
5940     PyTuple_SET_ITEM(__pyx_t_10, 1, ((PyObject *)__pyx_v__col));
5941     __pyx_t_11 = PyTuple_New(2); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 384, __pyx_L1_error)
5942     __Pyx_GOTREF(__pyx_t_11);
5943     __Pyx_INCREF(((PyObject *)__pyx_v__data));
5944     __Pyx_GIVEREF(((PyObject *)__pyx_v__data));
5945     PyTuple_SET_ITEM(__pyx_t_11, 0, ((PyObject *)__pyx_v__data));
5946     __Pyx_GIVEREF(__pyx_t_10);
5947     PyTuple_SET_ITEM(__pyx_t_11, 1, __pyx_t_10);
5948     __pyx_t_10 = 0;
5949     __pyx_t_10 = PyTuple_New(1); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 384, __pyx_L1_error)
5950     __Pyx_GOTREF(__pyx_t_10);
5951     __Pyx_GIVEREF(__pyx_t_11);
5952     PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_11);
5953     __pyx_t_11 = 0;
5954     __pyx_t_11 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 384, __pyx_L1_error)
5955     __Pyx_GOTREF(__pyx_t_11);
5956     __pyx_t_12 = __Pyx_PyInt_From_int(__pyx_v_mat->nrows); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 384, __pyx_L1_error)
5957     __Pyx_GOTREF(__pyx_t_12);
5958     __pyx_t_13 = __Pyx_PyInt_From_int(__pyx_v_mat->ncols); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 384, __pyx_L1_error)
5959     __Pyx_GOTREF(__pyx_t_13);
5960     __pyx_t_14 = PyTuple_New(2); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 384, __pyx_L1_error)
5961     __Pyx_GOTREF(__pyx_t_14);
5962     __Pyx_GIVEREF(__pyx_t_12);
5963     PyTuple_SET_ITEM(__pyx_t_14, 0, __pyx_t_12);
5964     __Pyx_GIVEREF(__pyx_t_13);
5965     PyTuple_SET_ITEM(__pyx_t_14, 1, __pyx_t_13);
5966     __pyx_t_12 = 0;
5967     __pyx_t_13 = 0;
5968     if (PyDict_SetItem(__pyx_t_11, __pyx_n_s_shape, __pyx_t_14) < 0) __PYX_ERR(0, 384, __pyx_L1_error)
5969     __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
5970     __pyx_t_14 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_10, __pyx_t_11); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 384, __pyx_L1_error)
5971     __Pyx_GOTREF(__pyx_t_14);
5972     __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
5973     __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
5974     __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
5975     __pyx_r = __pyx_t_14;
5976     __pyx_t_14 = 0;
5977     goto __pyx_L0;
5978 
5979     /* "qutip/cy/sparse_routines.pxi":373
5980  *     cdef np.ndarray[complex, ndim=1] _data
5981  *     cdef np.ndarray[int, ndim=1] _row, _col
5982  *     if (not mat.numpy_lock) and mat.is_set:             # <<<<<<<<<<<<<<
5983  *         dat_len = mat.nnz
5984  *         _data = np.PyArray_SimpleNewFromData(1, &dat_len, np.NPY_COMPLEX128, mat.data)
5985  */
5986   }
5987 
5988   /* "qutip/cy/sparse_routines.pxi":386
5989  *         return coo_matrix((_data, (_row, _col)), shape=(mat.nrows,mat.ncols))
5990  *     else:
5991  *         if mat.numpy_lock:             # <<<<<<<<<<<<<<
5992  *             raise_error_COO(-4)
5993  *         elif not mat.is_set:
5994  */
5995   /*else*/ {
5996     __pyx_t_1 = (__pyx_v_mat->numpy_lock != 0);
5997     if (__pyx_t_1) {
5998 
5999       /* "qutip/cy/sparse_routines.pxi":387
6000  *     else:
6001  *         if mat.numpy_lock:
6002  *             raise_error_COO(-4)             # <<<<<<<<<<<<<<
6003  *         elif not mat.is_set:
6004  *             raise_error_COO(-3)
6005  */
6006       __pyx_f_5qutip_2cy_7brtools_raise_error_COO(-4, NULL);
6007 
6008       /* "qutip/cy/sparse_routines.pxi":386
6009  *         return coo_matrix((_data, (_row, _col)), shape=(mat.nrows,mat.ncols))
6010  *     else:
6011  *         if mat.numpy_lock:             # <<<<<<<<<<<<<<
6012  *             raise_error_COO(-4)
6013  *         elif not mat.is_set:
6014  */
6015       goto __pyx_L6;
6016     }
6017 
6018     /* "qutip/cy/sparse_routines.pxi":388
6019  *         if mat.numpy_lock:
6020  *             raise_error_COO(-4)
6021  *         elif not mat.is_set:             # <<<<<<<<<<<<<<
6022  *             raise_error_COO(-3)
6023  *
6024  */
6025     __pyx_t_1 = ((!(__pyx_v_mat->is_set != 0)) != 0);
6026     if (__pyx_t_1) {
6027 
6028       /* "qutip/cy/sparse_routines.pxi":389
6029  *             raise_error_COO(-4)
6030  *         elif not mat.is_set:
6031  *             raise_error_COO(-3)             # <<<<<<<<<<<<<<
6032  *
6033  *
6034  */
6035       __pyx_f_5qutip_2cy_7brtools_raise_error_COO(-3, NULL);
6036 
6037       /* "qutip/cy/sparse_routines.pxi":388
6038  *         if mat.numpy_lock:
6039  *             raise_error_COO(-4)
6040  *         elif not mat.is_set:             # <<<<<<<<<<<<<<
6041  *             raise_error_COO(-3)
6042  *
6043  */
6044     }
6045     __pyx_L6:;
6046   }
6047 
6048   /* "qutip/cy/sparse_routines.pxi":358
6049  * @cython.boundscheck(False)
6050  * @cython.wraparound(False)
6051  * cdef object COO_to_scipy(COO_Matrix * mat):             # <<<<<<<<<<<<<<
6052  *     """
6053  *     Converts a COO_Matrix struct to a SciPy coo_matrix class object.
6054  */
6055 
6056   /* function exit code */
6057   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
6058   goto __pyx_L0;
6059   __pyx_L1_error:;
6060   __Pyx_XDECREF(__pyx_t_4);
6061   __Pyx_XDECREF(__pyx_t_10);
6062   __Pyx_XDECREF(__pyx_t_11);
6063   __Pyx_XDECREF(__pyx_t_12);
6064   __Pyx_XDECREF(__pyx_t_13);
6065   __Pyx_XDECREF(__pyx_t_14);
6066   { PyObject *__pyx_type, *__pyx_value, *__pyx_tb;
6067     __Pyx_PyThreadState_declare
6068     __Pyx_PyThreadState_assign
6069     __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb);
6070     __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd__col.rcbuffer->pybuffer);
6071     __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd__data.rcbuffer->pybuffer);
6072     __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd__row.rcbuffer->pybuffer);
6073   __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}
6074   __Pyx_AddTraceback("qutip.cy.brtools.COO_to_scipy", __pyx_clineno, __pyx_lineno, __pyx_filename);
6075   __pyx_r = 0;
6076   goto __pyx_L2;
6077   __pyx_L0:;
6078   __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd__col.rcbuffer->pybuffer);
6079   __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd__data.rcbuffer->pybuffer);
6080   __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd__row.rcbuffer->pybuffer);
6081   __pyx_L2:;
6082   __Pyx_XDECREF((PyObject *)__pyx_v__data);
6083   __Pyx_XDECREF((PyObject *)__pyx_v__row);
6084   __Pyx_XDECREF((PyObject *)__pyx_v__col);
6085   __Pyx_XGIVEREF(__pyx_r);
6086   __Pyx_RefNannyFinishContext();
6087   return __pyx_r;
6088 }
6089 
6090 /* "qutip/cy/sparse_routines.pxi":395
6091  * @cython.boundscheck(False)
6092  * @cython.wraparound(False)
6093  * cdef void COO_to_CSR(CSR_Matrix * out, COO_Matrix * mat):             # <<<<<<<<<<<<<<
6094  *     """
6095  *     Conversion from COO to CSR. Not in place,
6096  */
6097 
__pyx_f_5qutip_2cy_7brtools_COO_to_CSR(__pyx_t_5qutip_2cy_14sparse_structs_CSR_Matrix * __pyx_v_out,__pyx_t_5qutip_2cy_14sparse_structs_COO_Matrix * __pyx_v_mat)6098 static void __pyx_f_5qutip_2cy_7brtools_COO_to_CSR(__pyx_t_5qutip_2cy_14sparse_structs_CSR_Matrix *__pyx_v_out, __pyx_t_5qutip_2cy_14sparse_structs_COO_Matrix *__pyx_v_mat) {
6099   int __pyx_v_i;
6100   int __pyx_v_j;
6101   int __pyx_v_iad;
6102   int __pyx_v_j0;
6103   __pyx_t_double_complex __pyx_v_val;
6104   size_t __pyx_v_kk;
6105   __Pyx_RefNannyDeclarations
6106   struct __pyx_opt_args_5qutip_2cy_7brtools_init_CSR __pyx_t_1;
6107   int __pyx_t_2;
6108   int __pyx_t_3;
6109   size_t __pyx_t_4;
6110   __Pyx_RefNannySetupContext("COO_to_CSR", 0);
6111 
6112   /* "qutip/cy/sparse_routines.pxi":403
6113  *     cdef double complex val
6114  *     cdef size_t kk
6115  *     init_CSR(out, mat.nnz, mat.nrows, mat.ncols, max_length=0, init_zeros=1)             # <<<<<<<<<<<<<<
6116  *     # Determine row lengths
6117  *     for kk in range(mat.nnz):
6118  */
6119   __pyx_t_1.__pyx_n = 3;
6120   __pyx_t_1.ncols = __pyx_v_mat->ncols;
6121   __pyx_t_1.max_length = 0;
6122   __pyx_t_1.init_zeros = 1;
6123   __pyx_f_5qutip_2cy_7brtools_init_CSR(__pyx_v_out, __pyx_v_mat->nnz, __pyx_v_mat->nrows, &__pyx_t_1);
6124 
6125   /* "qutip/cy/sparse_routines.pxi":405
6126  *     init_CSR(out, mat.nnz, mat.nrows, mat.ncols, max_length=0, init_zeros=1)
6127  *     # Determine row lengths
6128  *     for kk in range(mat.nnz):             # <<<<<<<<<<<<<<
6129  *         out.indptr[mat.rows[kk]] = out.indptr[mat.rows[kk]] + 1
6130  *     # Starting position of rows
6131  */
6132   __pyx_t_2 = __pyx_v_mat->nnz;
6133   __pyx_t_3 = __pyx_t_2;
6134   for (__pyx_t_4 = 0; __pyx_t_4 < __pyx_t_3; __pyx_t_4+=1) {
6135     __pyx_v_kk = __pyx_t_4;
6136 
6137     /* "qutip/cy/sparse_routines.pxi":406
6138  *     # Determine row lengths
6139  *     for kk in range(mat.nnz):
6140  *         out.indptr[mat.rows[kk]] = out.indptr[mat.rows[kk]] + 1             # <<<<<<<<<<<<<<
6141  *     # Starting position of rows
6142  *     j = 0
6143  */
6144     (__pyx_v_out->indptr[(__pyx_v_mat->rows[__pyx_v_kk])]) = ((__pyx_v_out->indptr[(__pyx_v_mat->rows[__pyx_v_kk])]) + 1);
6145   }
6146 
6147   /* "qutip/cy/sparse_routines.pxi":408
6148  *         out.indptr[mat.rows[kk]] = out.indptr[mat.rows[kk]] + 1
6149  *     # Starting position of rows
6150  *     j = 0             # <<<<<<<<<<<<<<
6151  *     for kk in range(mat.nrows):
6152  *         j0 = out.indptr[kk]
6153  */
6154   __pyx_v_j = 0;
6155 
6156   /* "qutip/cy/sparse_routines.pxi":409
6157  *     # Starting position of rows
6158  *     j = 0
6159  *     for kk in range(mat.nrows):             # <<<<<<<<<<<<<<
6160  *         j0 = out.indptr[kk]
6161  *         out.indptr[kk] = j
6162  */
6163   __pyx_t_2 = __pyx_v_mat->nrows;
6164   __pyx_t_3 = __pyx_t_2;
6165   for (__pyx_t_4 = 0; __pyx_t_4 < __pyx_t_3; __pyx_t_4+=1) {
6166     __pyx_v_kk = __pyx_t_4;
6167 
6168     /* "qutip/cy/sparse_routines.pxi":410
6169  *     j = 0
6170  *     for kk in range(mat.nrows):
6171  *         j0 = out.indptr[kk]             # <<<<<<<<<<<<<<
6172  *         out.indptr[kk] = j
6173  *         j += j0
6174  */
6175     __pyx_v_j0 = (__pyx_v_out->indptr[__pyx_v_kk]);
6176 
6177     /* "qutip/cy/sparse_routines.pxi":411
6178  *     for kk in range(mat.nrows):
6179  *         j0 = out.indptr[kk]
6180  *         out.indptr[kk] = j             # <<<<<<<<<<<<<<
6181  *         j += j0
6182  *     #Do the data
6183  */
6184     (__pyx_v_out->indptr[__pyx_v_kk]) = __pyx_v_j;
6185 
6186     /* "qutip/cy/sparse_routines.pxi":412
6187  *         j0 = out.indptr[kk]
6188  *         out.indptr[kk] = j
6189  *         j += j0             # <<<<<<<<<<<<<<
6190  *     #Do the data
6191  *     for kk in range(mat.nnz):
6192  */
6193     __pyx_v_j = (__pyx_v_j + __pyx_v_j0);
6194   }
6195 
6196   /* "qutip/cy/sparse_routines.pxi":414
6197  *         j += j0
6198  *     #Do the data
6199  *     for kk in range(mat.nnz):             # <<<<<<<<<<<<<<
6200  *         i = mat.rows[kk]
6201  *         j = mat.cols[kk]
6202  */
6203   __pyx_t_2 = __pyx_v_mat->nnz;
6204   __pyx_t_3 = __pyx_t_2;
6205   for (__pyx_t_4 = 0; __pyx_t_4 < __pyx_t_3; __pyx_t_4+=1) {
6206     __pyx_v_kk = __pyx_t_4;
6207 
6208     /* "qutip/cy/sparse_routines.pxi":415
6209  *     #Do the data
6210  *     for kk in range(mat.nnz):
6211  *         i = mat.rows[kk]             # <<<<<<<<<<<<<<
6212  *         j = mat.cols[kk]
6213  *         val = mat.data[kk]
6214  */
6215     __pyx_v_i = (__pyx_v_mat->rows[__pyx_v_kk]);
6216 
6217     /* "qutip/cy/sparse_routines.pxi":416
6218  *     for kk in range(mat.nnz):
6219  *         i = mat.rows[kk]
6220  *         j = mat.cols[kk]             # <<<<<<<<<<<<<<
6221  *         val = mat.data[kk]
6222  *         iad = out.indptr[i]
6223  */
6224     __pyx_v_j = (__pyx_v_mat->cols[__pyx_v_kk]);
6225 
6226     /* "qutip/cy/sparse_routines.pxi":417
6227  *         i = mat.rows[kk]
6228  *         j = mat.cols[kk]
6229  *         val = mat.data[kk]             # <<<<<<<<<<<<<<
6230  *         iad = out.indptr[i]
6231  *         out.data[iad] = val
6232  */
6233     __pyx_v_val = (__pyx_v_mat->data[__pyx_v_kk]);
6234 
6235     /* "qutip/cy/sparse_routines.pxi":418
6236  *         j = mat.cols[kk]
6237  *         val = mat.data[kk]
6238  *         iad = out.indptr[i]             # <<<<<<<<<<<<<<
6239  *         out.data[iad] = val
6240  *         out.indices[iad] = j
6241  */
6242     __pyx_v_iad = (__pyx_v_out->indptr[__pyx_v_i]);
6243 
6244     /* "qutip/cy/sparse_routines.pxi":419
6245  *         val = mat.data[kk]
6246  *         iad = out.indptr[i]
6247  *         out.data[iad] = val             # <<<<<<<<<<<<<<
6248  *         out.indices[iad] = j
6249  *         out.indptr[i] = iad+1
6250  */
6251     (__pyx_v_out->data[__pyx_v_iad]) = __pyx_v_val;
6252 
6253     /* "qutip/cy/sparse_routines.pxi":420
6254  *         iad = out.indptr[i]
6255  *         out.data[iad] = val
6256  *         out.indices[iad] = j             # <<<<<<<<<<<<<<
6257  *         out.indptr[i] = iad+1
6258  *     # Shift back
6259  */
6260     (__pyx_v_out->indices[__pyx_v_iad]) = __pyx_v_j;
6261 
6262     /* "qutip/cy/sparse_routines.pxi":421
6263  *         out.data[iad] = val
6264  *         out.indices[iad] = j
6265  *         out.indptr[i] = iad+1             # <<<<<<<<<<<<<<
6266  *     # Shift back
6267  *     for kk in range(mat.nrows,0,-1):
6268  */
6269     (__pyx_v_out->indptr[__pyx_v_i]) = (__pyx_v_iad + 1);
6270   }
6271 
6272   /* "qutip/cy/sparse_routines.pxi":423
6273  *         out.indptr[i] = iad+1
6274  *     # Shift back
6275  *     for kk in range(mat.nrows,0,-1):             # <<<<<<<<<<<<<<
6276  *         out.indptr[kk] = out.indptr[kk-1]
6277  *     out.indptr[0] = 0
6278  */
6279   for (__pyx_t_4 = __pyx_v_mat->nrows + 1; __pyx_t_4 > 0 + 1; ) { __pyx_t_4-=1;
6280     __pyx_v_kk = __pyx_t_4;
6281 
6282     /* "qutip/cy/sparse_routines.pxi":424
6283  *     # Shift back
6284  *     for kk in range(mat.nrows,0,-1):
6285  *         out.indptr[kk] = out.indptr[kk-1]             # <<<<<<<<<<<<<<
6286  *     out.indptr[0] = 0
6287  *
6288  */
6289     (__pyx_v_out->indptr[__pyx_v_kk]) = (__pyx_v_out->indptr[(__pyx_v_kk - 1)]);
6290   }
6291 
6292   /* "qutip/cy/sparse_routines.pxi":425
6293  *     for kk in range(mat.nrows,0,-1):
6294  *         out.indptr[kk] = out.indptr[kk-1]
6295  *     out.indptr[0] = 0             # <<<<<<<<<<<<<<
6296  *
6297  *
6298  */
6299   (__pyx_v_out->indptr[0]) = 0;
6300 
6301   /* "qutip/cy/sparse_routines.pxi":395
6302  * @cython.boundscheck(False)
6303  * @cython.wraparound(False)
6304  * cdef void COO_to_CSR(CSR_Matrix * out, COO_Matrix * mat):             # <<<<<<<<<<<<<<
6305  *     """
6306  *     Conversion from COO to CSR. Not in place,
6307  */
6308 
6309   /* function exit code */
6310   __Pyx_RefNannyFinishContext();
6311 }
6312 
6313 /* "qutip/cy/sparse_routines.pxi":430
6314  * @cython.boundscheck(False)
6315  * @cython.wraparound(False)
6316  * cdef void CSR_to_COO(COO_Matrix * out, CSR_Matrix * mat):             # <<<<<<<<<<<<<<
6317  *     """
6318  *     Converts a CSR_Matrix to a COO_Matrix.
6319  */
6320 
__pyx_f_5qutip_2cy_7brtools_CSR_to_COO(__pyx_t_5qutip_2cy_14sparse_structs_COO_Matrix * __pyx_v_out,__pyx_t_5qutip_2cy_14sparse_structs_CSR_Matrix * __pyx_v_mat)6321 static void __pyx_f_5qutip_2cy_7brtools_CSR_to_COO(__pyx_t_5qutip_2cy_14sparse_structs_COO_Matrix *__pyx_v_out, __pyx_t_5qutip_2cy_14sparse_structs_CSR_Matrix *__pyx_v_mat) {
6322   int __pyx_v_k1;
6323   int __pyx_v_k2;
6324   size_t __pyx_v_jj;
6325   size_t __pyx_v_kk;
6326   __Pyx_RefNannyDeclarations
6327   struct __pyx_opt_args_5qutip_2cy_7brtools_init_COO __pyx_t_1;
6328   int __pyx_t_2;
6329   int __pyx_t_3;
6330   size_t __pyx_t_4;
6331   size_t __pyx_t_5;
6332   __Pyx_RefNannySetupContext("CSR_to_COO", 0);
6333 
6334   /* "qutip/cy/sparse_routines.pxi":436
6335  *     cdef int k1, k2
6336  *     cdef size_t jj, kk
6337  *     init_COO(out, mat.nnz, mat.nrows, mat.ncols)             # <<<<<<<<<<<<<<
6338  *     for kk in range(mat.nnz):
6339  *         out.data[kk] = mat.data[kk]
6340  */
6341   __pyx_t_1.__pyx_n = 1;
6342   __pyx_t_1.ncols = __pyx_v_mat->ncols;
6343   __pyx_f_5qutip_2cy_7brtools_init_COO(__pyx_v_out, __pyx_v_mat->nnz, __pyx_v_mat->nrows, &__pyx_t_1);
6344 
6345   /* "qutip/cy/sparse_routines.pxi":437
6346  *     cdef size_t jj, kk
6347  *     init_COO(out, mat.nnz, mat.nrows, mat.ncols)
6348  *     for kk in range(mat.nnz):             # <<<<<<<<<<<<<<
6349  *         out.data[kk] = mat.data[kk]
6350  *         out.cols[kk] = mat.indices[kk]
6351  */
6352   __pyx_t_2 = __pyx_v_mat->nnz;
6353   __pyx_t_3 = __pyx_t_2;
6354   for (__pyx_t_4 = 0; __pyx_t_4 < __pyx_t_3; __pyx_t_4+=1) {
6355     __pyx_v_kk = __pyx_t_4;
6356 
6357     /* "qutip/cy/sparse_routines.pxi":438
6358  *     init_COO(out, mat.nnz, mat.nrows, mat.ncols)
6359  *     for kk in range(mat.nnz):
6360  *         out.data[kk] = mat.data[kk]             # <<<<<<<<<<<<<<
6361  *         out.cols[kk] = mat.indices[kk]
6362  *     for kk in range(mat.nrows-1,0,-1):
6363  */
6364     (__pyx_v_out->data[__pyx_v_kk]) = (__pyx_v_mat->data[__pyx_v_kk]);
6365 
6366     /* "qutip/cy/sparse_routines.pxi":439
6367  *     for kk in range(mat.nnz):
6368  *         out.data[kk] = mat.data[kk]
6369  *         out.cols[kk] = mat.indices[kk]             # <<<<<<<<<<<<<<
6370  *     for kk in range(mat.nrows-1,0,-1):
6371  *         k1 = mat.indptr[kk+1]
6372  */
6373     (__pyx_v_out->cols[__pyx_v_kk]) = (__pyx_v_mat->indices[__pyx_v_kk]);
6374   }
6375 
6376   /* "qutip/cy/sparse_routines.pxi":440
6377  *         out.data[kk] = mat.data[kk]
6378  *         out.cols[kk] = mat.indices[kk]
6379  *     for kk in range(mat.nrows-1,0,-1):             # <<<<<<<<<<<<<<
6380  *         k1 = mat.indptr[kk+1]
6381  *         k2 = mat.indptr[kk]
6382  */
6383   for (__pyx_t_4 = (__pyx_v_mat->nrows - 1) + 1; __pyx_t_4 > 0 + 1; ) { __pyx_t_4-=1;
6384     __pyx_v_kk = __pyx_t_4;
6385 
6386     /* "qutip/cy/sparse_routines.pxi":441
6387  *         out.cols[kk] = mat.indices[kk]
6388  *     for kk in range(mat.nrows-1,0,-1):
6389  *         k1 = mat.indptr[kk+1]             # <<<<<<<<<<<<<<
6390  *         k2 = mat.indptr[kk]
6391  *         for jj in range(k2, k1):
6392  */
6393     __pyx_v_k1 = (__pyx_v_mat->indptr[(__pyx_v_kk + 1)]);
6394 
6395     /* "qutip/cy/sparse_routines.pxi":442
6396  *     for kk in range(mat.nrows-1,0,-1):
6397  *         k1 = mat.indptr[kk+1]
6398  *         k2 = mat.indptr[kk]             # <<<<<<<<<<<<<<
6399  *         for jj in range(k2, k1):
6400  *             out.rows[jj] = kk
6401  */
6402     __pyx_v_k2 = (__pyx_v_mat->indptr[__pyx_v_kk]);
6403 
6404     /* "qutip/cy/sparse_routines.pxi":443
6405  *         k1 = mat.indptr[kk+1]
6406  *         k2 = mat.indptr[kk]
6407  *         for jj in range(k2, k1):             # <<<<<<<<<<<<<<
6408  *             out.rows[jj] = kk
6409  *
6410  */
6411     __pyx_t_2 = __pyx_v_k1;
6412     __pyx_t_3 = __pyx_t_2;
6413     for (__pyx_t_5 = __pyx_v_k2; __pyx_t_5 < __pyx_t_3; __pyx_t_5+=1) {
6414       __pyx_v_jj = __pyx_t_5;
6415 
6416       /* "qutip/cy/sparse_routines.pxi":444
6417  *         k2 = mat.indptr[kk]
6418  *         for jj in range(k2, k1):
6419  *             out.rows[jj] = kk             # <<<<<<<<<<<<<<
6420  *
6421  *
6422  */
6423       (__pyx_v_out->rows[__pyx_v_jj]) = __pyx_v_kk;
6424     }
6425   }
6426 
6427   /* "qutip/cy/sparse_routines.pxi":430
6428  * @cython.boundscheck(False)
6429  * @cython.wraparound(False)
6430  * cdef void CSR_to_COO(COO_Matrix * out, CSR_Matrix * mat):             # <<<<<<<<<<<<<<
6431  *     """
6432  *     Converts a CSR_Matrix to a COO_Matrix.
6433  */
6434 
6435   /* function exit code */
6436   __Pyx_RefNannyFinishContext();
6437 }
6438 
6439 /* "qutip/cy/sparse_routines.pxi":450
6440  * @cython.boundscheck(False)
6441  * @cython.wraparound(False)
6442  * cdef void COO_to_CSR_inplace(CSR_Matrix * out, COO_Matrix * mat):             # <<<<<<<<<<<<<<
6443  *     """
6444  *     In place conversion from COO to CSR. In place, but not sorted.
6445  */
6446 
__pyx_f_5qutip_2cy_7brtools_COO_to_CSR_inplace(__pyx_t_5qutip_2cy_14sparse_structs_CSR_Matrix * __pyx_v_out,__pyx_t_5qutip_2cy_14sparse_structs_COO_Matrix * __pyx_v_mat)6447 static void __pyx_f_5qutip_2cy_7brtools_COO_to_CSR_inplace(__pyx_t_5qutip_2cy_14sparse_structs_CSR_Matrix *__pyx_v_out, __pyx_t_5qutip_2cy_14sparse_structs_COO_Matrix *__pyx_v_mat) {
6448   size_t __pyx_v_kk;
6449   int __pyx_v_i;
6450   int __pyx_v_j;
6451   int __pyx_v_init;
6452   int __pyx_v_inext;
6453   int __pyx_v_jnext;
6454   int __pyx_v_ipos;
6455   int *__pyx_v__tmp_rows;
6456   __pyx_t_double_complex __pyx_v_val;
6457   __pyx_t_double_complex __pyx_v_val_next;
6458   int *__pyx_v_work;
6459   __Pyx_RefNannyDeclarations
6460   int __pyx_t_1;
6461   int __pyx_t_2;
6462   size_t __pyx_t_3;
6463   long __pyx_t_4;
6464   size_t __pyx_t_5;
6465   int __pyx_t_6;
6466   __pyx_t_double_complex *__pyx_t_7;
6467   int *__pyx_t_8;
6468   __Pyx_RefNannySetupContext("COO_to_CSR_inplace", 0);
6469 
6470   /* "qutip/cy/sparse_routines.pxi":460
6471  *     cdef int * _tmp_rows
6472  *     cdef complex val, val_next
6473  *     cdef int * work = <int *>PyDataMem_NEW_ZEROED(mat.nrows+1, sizeof(int))             # <<<<<<<<<<<<<<
6474  *     # Determine output indptr array
6475  *     for kk in range(mat.nnz):
6476  */
6477   __pyx_v_work = ((int *)PyDataMem_NEW_ZEROED((__pyx_v_mat->nrows + 1), (sizeof(int))));
6478 
6479   /* "qutip/cy/sparse_routines.pxi":462
6480  *     cdef int * work = <int *>PyDataMem_NEW_ZEROED(mat.nrows+1, sizeof(int))
6481  *     # Determine output indptr array
6482  *     for kk in range(mat.nnz):             # <<<<<<<<<<<<<<
6483  *         i = mat.rows[kk]
6484  *         work[i+1] += 1
6485  */
6486   __pyx_t_1 = __pyx_v_mat->nnz;
6487   __pyx_t_2 = __pyx_t_1;
6488   for (__pyx_t_3 = 0; __pyx_t_3 < __pyx_t_2; __pyx_t_3+=1) {
6489     __pyx_v_kk = __pyx_t_3;
6490 
6491     /* "qutip/cy/sparse_routines.pxi":463
6492  *     # Determine output indptr array
6493  *     for kk in range(mat.nnz):
6494  *         i = mat.rows[kk]             # <<<<<<<<<<<<<<
6495  *         work[i+1] += 1
6496  *     work[0] = 0
6497  */
6498     __pyx_v_i = (__pyx_v_mat->rows[__pyx_v_kk]);
6499 
6500     /* "qutip/cy/sparse_routines.pxi":464
6501  *     for kk in range(mat.nnz):
6502  *         i = mat.rows[kk]
6503  *         work[i+1] += 1             # <<<<<<<<<<<<<<
6504  *     work[0] = 0
6505  *     for kk in range(mat.nrows):
6506  */
6507     __pyx_t_4 = (__pyx_v_i + 1);
6508     (__pyx_v_work[__pyx_t_4]) = ((__pyx_v_work[__pyx_t_4]) + 1);
6509   }
6510 
6511   /* "qutip/cy/sparse_routines.pxi":465
6512  *         i = mat.rows[kk]
6513  *         work[i+1] += 1
6514  *     work[0] = 0             # <<<<<<<<<<<<<<
6515  *     for kk in range(mat.nrows):
6516  *         work[kk+1] += work[kk]
6517  */
6518   (__pyx_v_work[0]) = 0;
6519 
6520   /* "qutip/cy/sparse_routines.pxi":466
6521  *         work[i+1] += 1
6522  *     work[0] = 0
6523  *     for kk in range(mat.nrows):             # <<<<<<<<<<<<<<
6524  *         work[kk+1] += work[kk]
6525  *
6526  */
6527   __pyx_t_1 = __pyx_v_mat->nrows;
6528   __pyx_t_2 = __pyx_t_1;
6529   for (__pyx_t_3 = 0; __pyx_t_3 < __pyx_t_2; __pyx_t_3+=1) {
6530     __pyx_v_kk = __pyx_t_3;
6531 
6532     /* "qutip/cy/sparse_routines.pxi":467
6533  *     work[0] = 0
6534  *     for kk in range(mat.nrows):
6535  *         work[kk+1] += work[kk]             # <<<<<<<<<<<<<<
6536  *
6537  *     if mat.nnz < (mat.nrows+1):
6538  */
6539     __pyx_t_5 = (__pyx_v_kk + 1);
6540     (__pyx_v_work[__pyx_t_5]) = ((__pyx_v_work[__pyx_t_5]) + (__pyx_v_work[__pyx_v_kk]));
6541   }
6542 
6543   /* "qutip/cy/sparse_routines.pxi":469
6544  *         work[kk+1] += work[kk]
6545  *
6546  *     if mat.nnz < (mat.nrows+1):             # <<<<<<<<<<<<<<
6547  *         _tmp_rows = <int *>PyDataMem_RENEW(mat.rows, (mat.nrows+1) * sizeof(int))
6548  *         mat.rows = _tmp_rows
6549  */
6550   __pyx_t_6 = ((__pyx_v_mat->nnz < (__pyx_v_mat->nrows + 1)) != 0);
6551   if (__pyx_t_6) {
6552 
6553     /* "qutip/cy/sparse_routines.pxi":470
6554  *
6555  *     if mat.nnz < (mat.nrows+1):
6556  *         _tmp_rows = <int *>PyDataMem_RENEW(mat.rows, (mat.nrows+1) * sizeof(int))             # <<<<<<<<<<<<<<
6557  *         mat.rows = _tmp_rows
6558  *     init = 0
6559  */
6560     __pyx_v__tmp_rows = ((int *)PyDataMem_RENEW(__pyx_v_mat->rows, ((__pyx_v_mat->nrows + 1) * (sizeof(int)))));
6561 
6562     /* "qutip/cy/sparse_routines.pxi":471
6563  *     if mat.nnz < (mat.nrows+1):
6564  *         _tmp_rows = <int *>PyDataMem_RENEW(mat.rows, (mat.nrows+1) * sizeof(int))
6565  *         mat.rows = _tmp_rows             # <<<<<<<<<<<<<<
6566  *     init = 0
6567  *     while init < mat.nnz:
6568  */
6569     __pyx_v_mat->rows = __pyx_v__tmp_rows;
6570 
6571     /* "qutip/cy/sparse_routines.pxi":469
6572  *         work[kk+1] += work[kk]
6573  *
6574  *     if mat.nnz < (mat.nrows+1):             # <<<<<<<<<<<<<<
6575  *         _tmp_rows = <int *>PyDataMem_RENEW(mat.rows, (mat.nrows+1) * sizeof(int))
6576  *         mat.rows = _tmp_rows
6577  */
6578   }
6579 
6580   /* "qutip/cy/sparse_routines.pxi":472
6581  *         _tmp_rows = <int *>PyDataMem_RENEW(mat.rows, (mat.nrows+1) * sizeof(int))
6582  *         mat.rows = _tmp_rows
6583  *     init = 0             # <<<<<<<<<<<<<<
6584  *     while init < mat.nnz:
6585  *         while (mat.rows[init] < 0):
6586  */
6587   __pyx_v_init = 0;
6588 
6589   /* "qutip/cy/sparse_routines.pxi":473
6590  *         mat.rows = _tmp_rows
6591  *     init = 0
6592  *     while init < mat.nnz:             # <<<<<<<<<<<<<<
6593  *         while (mat.rows[init] < 0):
6594  *             init += 1
6595  */
6596   while (1) {
6597     __pyx_t_6 = ((__pyx_v_init < __pyx_v_mat->nnz) != 0);
6598     if (!__pyx_t_6) break;
6599 
6600     /* "qutip/cy/sparse_routines.pxi":474
6601  *     init = 0
6602  *     while init < mat.nnz:
6603  *         while (mat.rows[init] < 0):             # <<<<<<<<<<<<<<
6604  *             init += 1
6605  *         val = mat.data[init]
6606  */
6607     while (1) {
6608       __pyx_t_6 = (((__pyx_v_mat->rows[__pyx_v_init]) < 0) != 0);
6609       if (!__pyx_t_6) break;
6610 
6611       /* "qutip/cy/sparse_routines.pxi":475
6612  *     while init < mat.nnz:
6613  *         while (mat.rows[init] < 0):
6614  *             init += 1             # <<<<<<<<<<<<<<
6615  *         val = mat.data[init]
6616  *         i = mat.rows[init]
6617  */
6618       __pyx_v_init = (__pyx_v_init + 1);
6619     }
6620 
6621     /* "qutip/cy/sparse_routines.pxi":476
6622  *         while (mat.rows[init] < 0):
6623  *             init += 1
6624  *         val = mat.data[init]             # <<<<<<<<<<<<<<
6625  *         i = mat.rows[init]
6626  *         j = mat.cols[init]
6627  */
6628     __pyx_v_val = (__pyx_v_mat->data[__pyx_v_init]);
6629 
6630     /* "qutip/cy/sparse_routines.pxi":477
6631  *             init += 1
6632  *         val = mat.data[init]
6633  *         i = mat.rows[init]             # <<<<<<<<<<<<<<
6634  *         j = mat.cols[init]
6635  *         mat.rows[init] = -1
6636  */
6637     __pyx_v_i = (__pyx_v_mat->rows[__pyx_v_init]);
6638 
6639     /* "qutip/cy/sparse_routines.pxi":478
6640  *         val = mat.data[init]
6641  *         i = mat.rows[init]
6642  *         j = mat.cols[init]             # <<<<<<<<<<<<<<
6643  *         mat.rows[init] = -1
6644  *         while 1:
6645  */
6646     __pyx_v_j = (__pyx_v_mat->cols[__pyx_v_init]);
6647 
6648     /* "qutip/cy/sparse_routines.pxi":479
6649  *         i = mat.rows[init]
6650  *         j = mat.cols[init]
6651  *         mat.rows[init] = -1             # <<<<<<<<<<<<<<
6652  *         while 1:
6653  *             ipos = work[i]
6654  */
6655     (__pyx_v_mat->rows[__pyx_v_init]) = -1;
6656 
6657     /* "qutip/cy/sparse_routines.pxi":480
6658  *         j = mat.cols[init]
6659  *         mat.rows[init] = -1
6660  *         while 1:             # <<<<<<<<<<<<<<
6661  *             ipos = work[i]
6662  *             val_next = mat.data[ipos]
6663  */
6664     while (1) {
6665 
6666       /* "qutip/cy/sparse_routines.pxi":481
6667  *         mat.rows[init] = -1
6668  *         while 1:
6669  *             ipos = work[i]             # <<<<<<<<<<<<<<
6670  *             val_next = mat.data[ipos]
6671  *             inext = mat.rows[ipos]
6672  */
6673       __pyx_v_ipos = (__pyx_v_work[__pyx_v_i]);
6674 
6675       /* "qutip/cy/sparse_routines.pxi":482
6676  *         while 1:
6677  *             ipos = work[i]
6678  *             val_next = mat.data[ipos]             # <<<<<<<<<<<<<<
6679  *             inext = mat.rows[ipos]
6680  *             jnext = mat.cols[ipos]
6681  */
6682       __pyx_v_val_next = (__pyx_v_mat->data[__pyx_v_ipos]);
6683 
6684       /* "qutip/cy/sparse_routines.pxi":483
6685  *             ipos = work[i]
6686  *             val_next = mat.data[ipos]
6687  *             inext = mat.rows[ipos]             # <<<<<<<<<<<<<<
6688  *             jnext = mat.cols[ipos]
6689  *
6690  */
6691       __pyx_v_inext = (__pyx_v_mat->rows[__pyx_v_ipos]);
6692 
6693       /* "qutip/cy/sparse_routines.pxi":484
6694  *             val_next = mat.data[ipos]
6695  *             inext = mat.rows[ipos]
6696  *             jnext = mat.cols[ipos]             # <<<<<<<<<<<<<<
6697  *
6698  *             mat.data[ipos] = val
6699  */
6700       __pyx_v_jnext = (__pyx_v_mat->cols[__pyx_v_ipos]);
6701 
6702       /* "qutip/cy/sparse_routines.pxi":486
6703  *             jnext = mat.cols[ipos]
6704  *
6705  *             mat.data[ipos] = val             # <<<<<<<<<<<<<<
6706  *             mat.cols[ipos] = j
6707  *             mat.rows[ipos] = -1
6708  */
6709       (__pyx_v_mat->data[__pyx_v_ipos]) = __pyx_v_val;
6710 
6711       /* "qutip/cy/sparse_routines.pxi":487
6712  *
6713  *             mat.data[ipos] = val
6714  *             mat.cols[ipos] = j             # <<<<<<<<<<<<<<
6715  *             mat.rows[ipos] = -1
6716  *             work[i] += 1
6717  */
6718       (__pyx_v_mat->cols[__pyx_v_ipos]) = __pyx_v_j;
6719 
6720       /* "qutip/cy/sparse_routines.pxi":488
6721  *             mat.data[ipos] = val
6722  *             mat.cols[ipos] = j
6723  *             mat.rows[ipos] = -1             # <<<<<<<<<<<<<<
6724  *             work[i] += 1
6725  *             if inext < 0:
6726  */
6727       (__pyx_v_mat->rows[__pyx_v_ipos]) = -1;
6728 
6729       /* "qutip/cy/sparse_routines.pxi":489
6730  *             mat.cols[ipos] = j
6731  *             mat.rows[ipos] = -1
6732  *             work[i] += 1             # <<<<<<<<<<<<<<
6733  *             if inext < 0:
6734  *                 break
6735  */
6736       __pyx_t_1 = __pyx_v_i;
6737       (__pyx_v_work[__pyx_t_1]) = ((__pyx_v_work[__pyx_t_1]) + 1);
6738 
6739       /* "qutip/cy/sparse_routines.pxi":490
6740  *             mat.rows[ipos] = -1
6741  *             work[i] += 1
6742  *             if inext < 0:             # <<<<<<<<<<<<<<
6743  *                 break
6744  *             val = val_next
6745  */
6746       __pyx_t_6 = ((__pyx_v_inext < 0) != 0);
6747       if (__pyx_t_6) {
6748 
6749         /* "qutip/cy/sparse_routines.pxi":491
6750  *             work[i] += 1
6751  *             if inext < 0:
6752  *                 break             # <<<<<<<<<<<<<<
6753  *             val = val_next
6754  *             i = inext
6755  */
6756         goto __pyx_L13_break;
6757 
6758         /* "qutip/cy/sparse_routines.pxi":490
6759  *             mat.rows[ipos] = -1
6760  *             work[i] += 1
6761  *             if inext < 0:             # <<<<<<<<<<<<<<
6762  *                 break
6763  *             val = val_next
6764  */
6765       }
6766 
6767       /* "qutip/cy/sparse_routines.pxi":492
6768  *             if inext < 0:
6769  *                 break
6770  *             val = val_next             # <<<<<<<<<<<<<<
6771  *             i = inext
6772  *             j = jnext
6773  */
6774       __pyx_v_val = __pyx_v_val_next;
6775 
6776       /* "qutip/cy/sparse_routines.pxi":493
6777  *                 break
6778  *             val = val_next
6779  *             i = inext             # <<<<<<<<<<<<<<
6780  *             j = jnext
6781  *         init += 1
6782  */
6783       __pyx_v_i = __pyx_v_inext;
6784 
6785       /* "qutip/cy/sparse_routines.pxi":494
6786  *             val = val_next
6787  *             i = inext
6788  *             j = jnext             # <<<<<<<<<<<<<<
6789  *         init += 1
6790  *
6791  */
6792       __pyx_v_j = __pyx_v_jnext;
6793     }
6794     __pyx_L13_break:;
6795 
6796     /* "qutip/cy/sparse_routines.pxi":495
6797  *             i = inext
6798  *             j = jnext
6799  *         init += 1             # <<<<<<<<<<<<<<
6800  *
6801  *     for kk in range(mat.nrows):
6802  */
6803     __pyx_v_init = (__pyx_v_init + 1);
6804   }
6805 
6806   /* "qutip/cy/sparse_routines.pxi":497
6807  *         init += 1
6808  *
6809  *     for kk in range(mat.nrows):             # <<<<<<<<<<<<<<
6810  *         mat.rows[kk+1] = work[kk]
6811  *     mat.rows[0] = 0
6812  */
6813   __pyx_t_1 = __pyx_v_mat->nrows;
6814   __pyx_t_2 = __pyx_t_1;
6815   for (__pyx_t_3 = 0; __pyx_t_3 < __pyx_t_2; __pyx_t_3+=1) {
6816     __pyx_v_kk = __pyx_t_3;
6817 
6818     /* "qutip/cy/sparse_routines.pxi":498
6819  *
6820  *     for kk in range(mat.nrows):
6821  *         mat.rows[kk+1] = work[kk]             # <<<<<<<<<<<<<<
6822  *     mat.rows[0] = 0
6823  *
6824  */
6825     (__pyx_v_mat->rows[(__pyx_v_kk + 1)]) = (__pyx_v_work[__pyx_v_kk]);
6826   }
6827 
6828   /* "qutip/cy/sparse_routines.pxi":499
6829  *     for kk in range(mat.nrows):
6830  *         mat.rows[kk+1] = work[kk]
6831  *     mat.rows[0] = 0             # <<<<<<<<<<<<<<
6832  *
6833  *     if mat.nnz > (mat.nrows+1):
6834  */
6835   (__pyx_v_mat->rows[0]) = 0;
6836 
6837   /* "qutip/cy/sparse_routines.pxi":501
6838  *     mat.rows[0] = 0
6839  *
6840  *     if mat.nnz > (mat.nrows+1):             # <<<<<<<<<<<<<<
6841  *         _tmp_rows = <int *>PyDataMem_RENEW(mat.rows, (mat.nrows+1) * sizeof(int))
6842  *         mat.rows = _tmp_rows
6843  */
6844   __pyx_t_6 = ((__pyx_v_mat->nnz > (__pyx_v_mat->nrows + 1)) != 0);
6845   if (__pyx_t_6) {
6846 
6847     /* "qutip/cy/sparse_routines.pxi":502
6848  *
6849  *     if mat.nnz > (mat.nrows+1):
6850  *         _tmp_rows = <int *>PyDataMem_RENEW(mat.rows, (mat.nrows+1) * sizeof(int))             # <<<<<<<<<<<<<<
6851  *         mat.rows = _tmp_rows
6852  *     #Free working array
6853  */
6854     __pyx_v__tmp_rows = ((int *)PyDataMem_RENEW(__pyx_v_mat->rows, ((__pyx_v_mat->nrows + 1) * (sizeof(int)))));
6855 
6856     /* "qutip/cy/sparse_routines.pxi":503
6857  *     if mat.nnz > (mat.nrows+1):
6858  *         _tmp_rows = <int *>PyDataMem_RENEW(mat.rows, (mat.nrows+1) * sizeof(int))
6859  *         mat.rows = _tmp_rows             # <<<<<<<<<<<<<<
6860  *     #Free working array
6861  *     PyDataMem_FREE(work)
6862  */
6863     __pyx_v_mat->rows = __pyx_v__tmp_rows;
6864 
6865     /* "qutip/cy/sparse_routines.pxi":501
6866  *     mat.rows[0] = 0
6867  *
6868  *     if mat.nnz > (mat.nrows+1):             # <<<<<<<<<<<<<<
6869  *         _tmp_rows = <int *>PyDataMem_RENEW(mat.rows, (mat.nrows+1) * sizeof(int))
6870  *         mat.rows = _tmp_rows
6871  */
6872   }
6873 
6874   /* "qutip/cy/sparse_routines.pxi":505
6875  *         mat.rows = _tmp_rows
6876  *     #Free working array
6877  *     PyDataMem_FREE(work)             # <<<<<<<<<<<<<<
6878  *     #Set CSR pointers to original COO data.
6879  *     out.data = mat.data
6880  */
6881   PyDataMem_FREE(__pyx_v_work);
6882 
6883   /* "qutip/cy/sparse_routines.pxi":507
6884  *     PyDataMem_FREE(work)
6885  *     #Set CSR pointers to original COO data.
6886  *     out.data = mat.data             # <<<<<<<<<<<<<<
6887  *     out.indices = mat.cols
6888  *     out.indptr = mat.rows
6889  */
6890   __pyx_t_7 = __pyx_v_mat->data;
6891   __pyx_v_out->data = __pyx_t_7;
6892 
6893   /* "qutip/cy/sparse_routines.pxi":508
6894  *     #Set CSR pointers to original COO data.
6895  *     out.data = mat.data
6896  *     out.indices = mat.cols             # <<<<<<<<<<<<<<
6897  *     out.indptr = mat.rows
6898  *     out.nrows = mat.nrows
6899  */
6900   __pyx_t_8 = __pyx_v_mat->cols;
6901   __pyx_v_out->indices = __pyx_t_8;
6902 
6903   /* "qutip/cy/sparse_routines.pxi":509
6904  *     out.data = mat.data
6905  *     out.indices = mat.cols
6906  *     out.indptr = mat.rows             # <<<<<<<<<<<<<<
6907  *     out.nrows = mat.nrows
6908  *     out.ncols = mat.ncols
6909  */
6910   __pyx_t_8 = __pyx_v_mat->rows;
6911   __pyx_v_out->indptr = __pyx_t_8;
6912 
6913   /* "qutip/cy/sparse_routines.pxi":510
6914  *     out.indices = mat.cols
6915  *     out.indptr = mat.rows
6916  *     out.nrows = mat.nrows             # <<<<<<<<<<<<<<
6917  *     out.ncols = mat.ncols
6918  *     out.nnz = mat.nnz
6919  */
6920   __pyx_t_1 = __pyx_v_mat->nrows;
6921   __pyx_v_out->nrows = __pyx_t_1;
6922 
6923   /* "qutip/cy/sparse_routines.pxi":511
6924  *     out.indptr = mat.rows
6925  *     out.nrows = mat.nrows
6926  *     out.ncols = mat.ncols             # <<<<<<<<<<<<<<
6927  *     out.nnz = mat.nnz
6928  *     out.max_length = mat.nnz
6929  */
6930   __pyx_t_1 = __pyx_v_mat->ncols;
6931   __pyx_v_out->ncols = __pyx_t_1;
6932 
6933   /* "qutip/cy/sparse_routines.pxi":512
6934  *     out.nrows = mat.nrows
6935  *     out.ncols = mat.ncols
6936  *     out.nnz = mat.nnz             # <<<<<<<<<<<<<<
6937  *     out.max_length = mat.nnz
6938  *     out.is_set = 1
6939  */
6940   __pyx_t_1 = __pyx_v_mat->nnz;
6941   __pyx_v_out->nnz = __pyx_t_1;
6942 
6943   /* "qutip/cy/sparse_routines.pxi":513
6944  *     out.ncols = mat.ncols
6945  *     out.nnz = mat.nnz
6946  *     out.max_length = mat.nnz             # <<<<<<<<<<<<<<
6947  *     out.is_set = 1
6948  *     out.numpy_lock = 0
6949  */
6950   __pyx_t_1 = __pyx_v_mat->nnz;
6951   __pyx_v_out->max_length = __pyx_t_1;
6952 
6953   /* "qutip/cy/sparse_routines.pxi":514
6954  *     out.nnz = mat.nnz
6955  *     out.max_length = mat.nnz
6956  *     out.is_set = 1             # <<<<<<<<<<<<<<
6957  *     out.numpy_lock = 0
6958  *
6959  */
6960   __pyx_v_out->is_set = 1;
6961 
6962   /* "qutip/cy/sparse_routines.pxi":515
6963  *     out.max_length = mat.nnz
6964  *     out.is_set = 1
6965  *     out.numpy_lock = 0             # <<<<<<<<<<<<<<
6966  *
6967  *
6968  */
6969   __pyx_v_out->numpy_lock = 0;
6970 
6971   /* "qutip/cy/sparse_routines.pxi":450
6972  * @cython.boundscheck(False)
6973  * @cython.wraparound(False)
6974  * cdef void COO_to_CSR_inplace(CSR_Matrix * out, COO_Matrix * mat):             # <<<<<<<<<<<<<<
6975  *     """
6976  *     In place conversion from COO to CSR. In place, but not sorted.
6977  */
6978 
6979   /* function exit code */
6980   __Pyx_RefNannyFinishContext();
6981 }
6982 
6983 /* "qutip/cy/sparse_routines.pxi":520
6984  * @cython.boundscheck(False)
6985  * @cython.wraparound(False)
6986  * cdef int ind_sort(data_ind_pair x, data_ind_pair y):             # <<<<<<<<<<<<<<
6987  *     return x.ind < y.ind
6988  *
6989  */
6990 
__pyx_f_5qutip_2cy_7brtools_ind_sort(__pyx_t_5qutip_2cy_7brtools_data_ind_pair __pyx_v_x,__pyx_t_5qutip_2cy_7brtools_data_ind_pair __pyx_v_y)6991 static int __pyx_f_5qutip_2cy_7brtools_ind_sort(__pyx_t_5qutip_2cy_7brtools_data_ind_pair __pyx_v_x, __pyx_t_5qutip_2cy_7brtools_data_ind_pair __pyx_v_y) {
6992   int __pyx_r;
6993   __Pyx_RefNannyDeclarations
6994   __Pyx_RefNannySetupContext("ind_sort", 0);
6995 
6996   /* "qutip/cy/sparse_routines.pxi":521
6997  * @cython.wraparound(False)
6998  * cdef int ind_sort(data_ind_pair x, data_ind_pair y):
6999  *     return x.ind < y.ind             # <<<<<<<<<<<<<<
7000  *
7001  *
7002  */
7003   __pyx_r = (__pyx_v_x.ind < __pyx_v_y.ind);
7004   goto __pyx_L0;
7005 
7006   /* "qutip/cy/sparse_routines.pxi":520
7007  * @cython.boundscheck(False)
7008  * @cython.wraparound(False)
7009  * cdef int ind_sort(data_ind_pair x, data_ind_pair y):             # <<<<<<<<<<<<<<
7010  *     return x.ind < y.ind
7011  *
7012  */
7013 
7014   /* function exit code */
7015   __pyx_L0:;
7016   __Pyx_RefNannyFinishContext();
7017   return __pyx_r;
7018 }
7019 
7020 /* "qutip/cy/sparse_routines.pxi":526
7021  * @cython.boundscheck(False)
7022  * @cython.wraparound(False)
7023  * cdef void sort_indices(CSR_Matrix * mat):             # <<<<<<<<<<<<<<
7024  *     """
7025  *     Sorts the indices of a CSR_Matrix inplace.
7026  */
7027 
__pyx_f_5qutip_2cy_7brtools_sort_indices(__pyx_t_5qutip_2cy_14sparse_structs_CSR_Matrix * __pyx_v_mat)7028 static void __pyx_f_5qutip_2cy_7brtools_sort_indices(__pyx_t_5qutip_2cy_14sparse_structs_CSR_Matrix *__pyx_v_mat) {
7029   size_t __pyx_v_ii;
7030   size_t __pyx_v_jj;
7031   std::vector<__pyx_t_5qutip_2cy_7brtools_data_ind_pair>  __pyx_v_pairs;
7032   __pyx_t_5qutip_2cy_7brtools_cfptr __pyx_v_cfptr_;
7033   int __pyx_v_row_start;
7034   int __pyx_v_row_end;
7035   int __pyx_v_length;
7036   __Pyx_RefNannyDeclarations
7037   int __pyx_t_1;
7038   int __pyx_t_2;
7039   size_t __pyx_t_3;
7040   int __pyx_t_4;
7041   int __pyx_t_5;
7042   size_t __pyx_t_6;
7043   __pyx_t_double_complex __pyx_t_7;
7044   int __pyx_t_8;
7045   int __pyx_lineno = 0;
7046   const char *__pyx_filename = NULL;
7047   int __pyx_clineno = 0;
7048   __Pyx_RefNannySetupContext("sort_indices", 0);
7049 
7050   /* "qutip/cy/sparse_routines.pxi":532
7051  *     cdef size_t ii, jj
7052  *     cdef vector[data_ind_pair] pairs
7053  *     cdef cfptr cfptr_ = &ind_sort             # <<<<<<<<<<<<<<
7054  *     cdef int row_start, row_end, length
7055  *
7056  */
7057   __pyx_v_cfptr_ = (&__pyx_f_5qutip_2cy_7brtools_ind_sort);
7058 
7059   /* "qutip/cy/sparse_routines.pxi":535
7060  *     cdef int row_start, row_end, length
7061  *
7062  *     for ii in range(mat.nrows):             # <<<<<<<<<<<<<<
7063  *         row_start = mat.indptr[ii]
7064  *         row_end = mat.indptr[ii+1]
7065  */
7066   __pyx_t_1 = __pyx_v_mat->nrows;
7067   __pyx_t_2 = __pyx_t_1;
7068   for (__pyx_t_3 = 0; __pyx_t_3 < __pyx_t_2; __pyx_t_3+=1) {
7069     __pyx_v_ii = __pyx_t_3;
7070 
7071     /* "qutip/cy/sparse_routines.pxi":536
7072  *
7073  *     for ii in range(mat.nrows):
7074  *         row_start = mat.indptr[ii]             # <<<<<<<<<<<<<<
7075  *         row_end = mat.indptr[ii+1]
7076  *         length = row_end - row_start
7077  */
7078     __pyx_v_row_start = (__pyx_v_mat->indptr[__pyx_v_ii]);
7079 
7080     /* "qutip/cy/sparse_routines.pxi":537
7081  *     for ii in range(mat.nrows):
7082  *         row_start = mat.indptr[ii]
7083  *         row_end = mat.indptr[ii+1]             # <<<<<<<<<<<<<<
7084  *         length = row_end - row_start
7085  *         pairs.resize(length)
7086  */
7087     __pyx_v_row_end = (__pyx_v_mat->indptr[(__pyx_v_ii + 1)]);
7088 
7089     /* "qutip/cy/sparse_routines.pxi":538
7090  *         row_start = mat.indptr[ii]
7091  *         row_end = mat.indptr[ii+1]
7092  *         length = row_end - row_start             # <<<<<<<<<<<<<<
7093  *         pairs.resize(length)
7094  *
7095  */
7096     __pyx_v_length = (__pyx_v_row_end - __pyx_v_row_start);
7097 
7098     /* "qutip/cy/sparse_routines.pxi":539
7099  *         row_end = mat.indptr[ii+1]
7100  *         length = row_end - row_start
7101  *         pairs.resize(length)             # <<<<<<<<<<<<<<
7102  *
7103  *         for jj in range(length):
7104  */
7105     try {
7106       __pyx_v_pairs.resize(__pyx_v_length);
7107     } catch(...) {
7108       __Pyx_CppExn2PyErr();
7109       __PYX_ERR(0, 539, __pyx_L1_error)
7110     }
7111 
7112     /* "qutip/cy/sparse_routines.pxi":541
7113  *         pairs.resize(length)
7114  *
7115  *         for jj in range(length):             # <<<<<<<<<<<<<<
7116  *             pairs[jj].data = mat.data[row_start+jj]
7117  *             pairs[jj].ind = mat.indices[row_start+jj]
7118  */
7119     __pyx_t_4 = __pyx_v_length;
7120     __pyx_t_5 = __pyx_t_4;
7121     for (__pyx_t_6 = 0; __pyx_t_6 < __pyx_t_5; __pyx_t_6+=1) {
7122       __pyx_v_jj = __pyx_t_6;
7123 
7124       /* "qutip/cy/sparse_routines.pxi":542
7125  *
7126  *         for jj in range(length):
7127  *             pairs[jj].data = mat.data[row_start+jj]             # <<<<<<<<<<<<<<
7128  *             pairs[jj].ind = mat.indices[row_start+jj]
7129  *
7130  */
7131       (__pyx_v_pairs[__pyx_v_jj]).data = (__pyx_v_mat->data[(__pyx_v_row_start + __pyx_v_jj)]);
7132 
7133       /* "qutip/cy/sparse_routines.pxi":543
7134  *         for jj in range(length):
7135  *             pairs[jj].data = mat.data[row_start+jj]
7136  *             pairs[jj].ind = mat.indices[row_start+jj]             # <<<<<<<<<<<<<<
7137  *
7138  *         sort(pairs.begin(),pairs.end(),cfptr_)
7139  */
7140       (__pyx_v_pairs[__pyx_v_jj]).ind = (__pyx_v_mat->indices[(__pyx_v_row_start + __pyx_v_jj)]);
7141     }
7142 
7143     /* "qutip/cy/sparse_routines.pxi":545
7144  *             pairs[jj].ind = mat.indices[row_start+jj]
7145  *
7146  *         sort(pairs.begin(),pairs.end(),cfptr_)             # <<<<<<<<<<<<<<
7147  *
7148  *         for jj in range(length):
7149  */
7150     std::sort<std::vector<__pyx_t_5qutip_2cy_7brtools_data_ind_pair> ::iterator,__pyx_t_5qutip_2cy_7brtools_cfptr>(__pyx_v_pairs.begin(), __pyx_v_pairs.end(), __pyx_v_cfptr_);
7151 
7152     /* "qutip/cy/sparse_routines.pxi":547
7153  *         sort(pairs.begin(),pairs.end(),cfptr_)
7154  *
7155  *         for jj in range(length):             # <<<<<<<<<<<<<<
7156  *             mat.data[row_start+jj] = pairs[jj].data
7157  *             mat.indices[row_start+jj] = pairs[jj].ind
7158  */
7159     __pyx_t_4 = __pyx_v_length;
7160     __pyx_t_5 = __pyx_t_4;
7161     for (__pyx_t_6 = 0; __pyx_t_6 < __pyx_t_5; __pyx_t_6+=1) {
7162       __pyx_v_jj = __pyx_t_6;
7163 
7164       /* "qutip/cy/sparse_routines.pxi":548
7165  *
7166  *         for jj in range(length):
7167  *             mat.data[row_start+jj] = pairs[jj].data             # <<<<<<<<<<<<<<
7168  *             mat.indices[row_start+jj] = pairs[jj].ind
7169  *
7170  */
7171       __pyx_t_7 = (__pyx_v_pairs[__pyx_v_jj]).data;
7172       (__pyx_v_mat->data[(__pyx_v_row_start + __pyx_v_jj)]) = __pyx_t_7;
7173 
7174       /* "qutip/cy/sparse_routines.pxi":549
7175  *         for jj in range(length):
7176  *             mat.data[row_start+jj] = pairs[jj].data
7177  *             mat.indices[row_start+jj] = pairs[jj].ind             # <<<<<<<<<<<<<<
7178  *
7179  *
7180  */
7181       __pyx_t_8 = (__pyx_v_pairs[__pyx_v_jj]).ind;
7182       (__pyx_v_mat->indices[(__pyx_v_row_start + __pyx_v_jj)]) = __pyx_t_8;
7183     }
7184   }
7185 
7186   /* "qutip/cy/sparse_routines.pxi":526
7187  * @cython.boundscheck(False)
7188  * @cython.wraparound(False)
7189  * cdef void sort_indices(CSR_Matrix * mat):             # <<<<<<<<<<<<<<
7190  *     """
7191  *     Sorts the indices of a CSR_Matrix inplace.
7192  */
7193 
7194   /* function exit code */
7195   goto __pyx_L0;
7196   __pyx_L1_error:;
7197   __Pyx_WriteUnraisable("qutip.cy.brtools.sort_indices", __pyx_clineno, __pyx_lineno, __pyx_filename, 1, 0);
7198   __pyx_L0:;
7199   __Pyx_RefNannyFinishContext();
7200 }
7201 
7202 /* "qutip/cy/sparse_routines.pxi":555
7203  * @cython.boundscheck(False)
7204  * @cython.wraparound(False)
7205  * cdef CSR_Matrix CSR_from_scipy(object A):             # <<<<<<<<<<<<<<
7206  *     """
7207  *     Converts a SciPy CSR sparse matrix to a
7208  */
7209 
__pyx_f_5qutip_2cy_7brtools_CSR_from_scipy(PyObject * __pyx_v_A)7210 static __pyx_t_5qutip_2cy_14sparse_structs_CSR_Matrix __pyx_f_5qutip_2cy_7brtools_CSR_from_scipy(PyObject *__pyx_v_A) {
7211   __Pyx_memviewslice __pyx_v_data = { 0, 0, { 0 }, { 0 }, { 0 } };
7212   __Pyx_memviewslice __pyx_v_ind = { 0, 0, { 0 }, { 0 }, { 0 } };
7213   __Pyx_memviewslice __pyx_v_ptr = { 0, 0, { 0 }, { 0 }, { 0 } };
7214   int __pyx_v_nrows;
7215   int __pyx_v_ncols;
7216   int __pyx_v_nnz;
7217   __pyx_t_5qutip_2cy_14sparse_structs_CSR_Matrix __pyx_v_mat;
7218   __pyx_t_5qutip_2cy_14sparse_structs_CSR_Matrix __pyx_r;
7219   __Pyx_RefNannyDeclarations
7220   PyObject *__pyx_t_1 = NULL;
7221   __Pyx_memviewslice __pyx_t_2 = { 0, 0, { 0 }, { 0 }, { 0 } };
7222   __Pyx_memviewslice __pyx_t_3 = { 0, 0, { 0 }, { 0 }, { 0 } };
7223   PyObject *__pyx_t_4 = NULL;
7224   int __pyx_t_5;
7225   Py_ssize_t __pyx_t_6;
7226   int __pyx_lineno = 0;
7227   const char *__pyx_filename = NULL;
7228   int __pyx_clineno = 0;
7229   __Pyx_RefNannySetupContext("CSR_from_scipy", 0);
7230 
7231   /* "qutip/cy/sparse_routines.pxi":560
7232  *     CSR_Matrix struct.
7233  *     """
7234  *     cdef complex[::1] data = A.data             # <<<<<<<<<<<<<<
7235  *     cdef int[::1] ind = A.indices
7236  *     cdef int[::1] ptr = A.indptr
7237  */
7238   __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_A, __pyx_n_s_data); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 560, __pyx_L1_error)
7239   __Pyx_GOTREF(__pyx_t_1);
7240   __pyx_t_2 = __Pyx_PyObject_to_MemoryviewSlice_dc___pyx_t_double_complex(__pyx_t_1, PyBUF_WRITABLE); if (unlikely(!__pyx_t_2.memview)) __PYX_ERR(0, 560, __pyx_L1_error)
7241   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
7242   __pyx_v_data = __pyx_t_2;
7243   __pyx_t_2.memview = NULL;
7244   __pyx_t_2.data = NULL;
7245 
7246   /* "qutip/cy/sparse_routines.pxi":561
7247  *     """
7248  *     cdef complex[::1] data = A.data
7249  *     cdef int[::1] ind = A.indices             # <<<<<<<<<<<<<<
7250  *     cdef int[::1] ptr = A.indptr
7251  *     cdef int nrows = A.shape[0]
7252  */
7253   __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_A, __pyx_n_s_indices); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 561, __pyx_L1_error)
7254   __Pyx_GOTREF(__pyx_t_1);
7255   __pyx_t_3 = __Pyx_PyObject_to_MemoryviewSlice_dc_int(__pyx_t_1, PyBUF_WRITABLE); if (unlikely(!__pyx_t_3.memview)) __PYX_ERR(0, 561, __pyx_L1_error)
7256   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
7257   __pyx_v_ind = __pyx_t_3;
7258   __pyx_t_3.memview = NULL;
7259   __pyx_t_3.data = NULL;
7260 
7261   /* "qutip/cy/sparse_routines.pxi":562
7262  *     cdef complex[::1] data = A.data
7263  *     cdef int[::1] ind = A.indices
7264  *     cdef int[::1] ptr = A.indptr             # <<<<<<<<<<<<<<
7265  *     cdef int nrows = A.shape[0]
7266  *     cdef int ncols = A.shape[1]
7267  */
7268   __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_A, __pyx_n_s_indptr); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 562, __pyx_L1_error)
7269   __Pyx_GOTREF(__pyx_t_1);
7270   __pyx_t_3 = __Pyx_PyObject_to_MemoryviewSlice_dc_int(__pyx_t_1, PyBUF_WRITABLE); if (unlikely(!__pyx_t_3.memview)) __PYX_ERR(0, 562, __pyx_L1_error)
7271   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
7272   __pyx_v_ptr = __pyx_t_3;
7273   __pyx_t_3.memview = NULL;
7274   __pyx_t_3.data = NULL;
7275 
7276   /* "qutip/cy/sparse_routines.pxi":563
7277  *     cdef int[::1] ind = A.indices
7278  *     cdef int[::1] ptr = A.indptr
7279  *     cdef int nrows = A.shape[0]             # <<<<<<<<<<<<<<
7280  *     cdef int ncols = A.shape[1]
7281  *     cdef int nnz = ptr[nrows]
7282  */
7283   __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_A, __pyx_n_s_shape); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 563, __pyx_L1_error)
7284   __Pyx_GOTREF(__pyx_t_1);
7285   __pyx_t_4 = __Pyx_GetItemInt(__pyx_t_1, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 563, __pyx_L1_error)
7286   __Pyx_GOTREF(__pyx_t_4);
7287   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
7288   __pyx_t_5 = __Pyx_PyInt_As_int(__pyx_t_4); if (unlikely((__pyx_t_5 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 563, __pyx_L1_error)
7289   __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
7290   __pyx_v_nrows = __pyx_t_5;
7291 
7292   /* "qutip/cy/sparse_routines.pxi":564
7293  *     cdef int[::1] ptr = A.indptr
7294  *     cdef int nrows = A.shape[0]
7295  *     cdef int ncols = A.shape[1]             # <<<<<<<<<<<<<<
7296  *     cdef int nnz = ptr[nrows]
7297  *
7298  */
7299   __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_A, __pyx_n_s_shape); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 564, __pyx_L1_error)
7300   __Pyx_GOTREF(__pyx_t_4);
7301   __pyx_t_1 = __Pyx_GetItemInt(__pyx_t_4, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 564, __pyx_L1_error)
7302   __Pyx_GOTREF(__pyx_t_1);
7303   __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
7304   __pyx_t_5 = __Pyx_PyInt_As_int(__pyx_t_1); if (unlikely((__pyx_t_5 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 564, __pyx_L1_error)
7305   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
7306   __pyx_v_ncols = __pyx_t_5;
7307 
7308   /* "qutip/cy/sparse_routines.pxi":565
7309  *     cdef int nrows = A.shape[0]
7310  *     cdef int ncols = A.shape[1]
7311  *     cdef int nnz = ptr[nrows]             # <<<<<<<<<<<<<<
7312  *
7313  *     cdef CSR_Matrix mat
7314  */
7315   __pyx_t_6 = __pyx_v_nrows;
7316   __pyx_v_nnz = (*((int *) ( /* dim=0 */ ((char *) (((int *) __pyx_v_ptr.data) + __pyx_t_6)) )));
7317 
7318   /* "qutip/cy/sparse_routines.pxi":569
7319  *     cdef CSR_Matrix mat
7320  *
7321  *     mat.data = &data[0]             # <<<<<<<<<<<<<<
7322  *     mat.indices = &ind[0]
7323  *     mat.indptr = &ptr[0]
7324  */
7325   __pyx_t_6 = 0;
7326   __pyx_v_mat.data = (&(*((__pyx_t_double_complex *) ( /* dim=0 */ ((char *) (((__pyx_t_double_complex *) __pyx_v_data.data) + __pyx_t_6)) ))));
7327 
7328   /* "qutip/cy/sparse_routines.pxi":570
7329  *
7330  *     mat.data = &data[0]
7331  *     mat.indices = &ind[0]             # <<<<<<<<<<<<<<
7332  *     mat.indptr = &ptr[0]
7333  *     mat.nrows = nrows
7334  */
7335   __pyx_t_6 = 0;
7336   __pyx_v_mat.indices = (&(*((int *) ( /* dim=0 */ ((char *) (((int *) __pyx_v_ind.data) + __pyx_t_6)) ))));
7337 
7338   /* "qutip/cy/sparse_routines.pxi":571
7339  *     mat.data = &data[0]
7340  *     mat.indices = &ind[0]
7341  *     mat.indptr = &ptr[0]             # <<<<<<<<<<<<<<
7342  *     mat.nrows = nrows
7343  *     mat.ncols = ncols
7344  */
7345   __pyx_t_6 = 0;
7346   __pyx_v_mat.indptr = (&(*((int *) ( /* dim=0 */ ((char *) (((int *) __pyx_v_ptr.data) + __pyx_t_6)) ))));
7347 
7348   /* "qutip/cy/sparse_routines.pxi":572
7349  *     mat.indices = &ind[0]
7350  *     mat.indptr = &ptr[0]
7351  *     mat.nrows = nrows             # <<<<<<<<<<<<<<
7352  *     mat.ncols = ncols
7353  *     mat.nnz = nnz
7354  */
7355   __pyx_v_mat.nrows = __pyx_v_nrows;
7356 
7357   /* "qutip/cy/sparse_routines.pxi":573
7358  *     mat.indptr = &ptr[0]
7359  *     mat.nrows = nrows
7360  *     mat.ncols = ncols             # <<<<<<<<<<<<<<
7361  *     mat.nnz = nnz
7362  *     mat.max_length = nnz
7363  */
7364   __pyx_v_mat.ncols = __pyx_v_ncols;
7365 
7366   /* "qutip/cy/sparse_routines.pxi":574
7367  *     mat.nrows = nrows
7368  *     mat.ncols = ncols
7369  *     mat.nnz = nnz             # <<<<<<<<<<<<<<
7370  *     mat.max_length = nnz
7371  *     mat.is_set = 1
7372  */
7373   __pyx_v_mat.nnz = __pyx_v_nnz;
7374 
7375   /* "qutip/cy/sparse_routines.pxi":575
7376  *     mat.ncols = ncols
7377  *     mat.nnz = nnz
7378  *     mat.max_length = nnz             # <<<<<<<<<<<<<<
7379  *     mat.is_set = 1
7380  *     mat.numpy_lock = 1
7381  */
7382   __pyx_v_mat.max_length = __pyx_v_nnz;
7383 
7384   /* "qutip/cy/sparse_routines.pxi":576
7385  *     mat.nnz = nnz
7386  *     mat.max_length = nnz
7387  *     mat.is_set = 1             # <<<<<<<<<<<<<<
7388  *     mat.numpy_lock = 1
7389  *
7390  */
7391   __pyx_v_mat.is_set = 1;
7392 
7393   /* "qutip/cy/sparse_routines.pxi":577
7394  *     mat.max_length = nnz
7395  *     mat.is_set = 1
7396  *     mat.numpy_lock = 1             # <<<<<<<<<<<<<<
7397  *
7398  *     return mat
7399  */
7400   __pyx_v_mat.numpy_lock = 1;
7401 
7402   /* "qutip/cy/sparse_routines.pxi":579
7403  *     mat.numpy_lock = 1
7404  *
7405  *     return mat             # <<<<<<<<<<<<<<
7406  *
7407  *
7408  */
7409   __pyx_r = __pyx_v_mat;
7410   goto __pyx_L0;
7411 
7412   /* "qutip/cy/sparse_routines.pxi":555
7413  * @cython.boundscheck(False)
7414  * @cython.wraparound(False)
7415  * cdef CSR_Matrix CSR_from_scipy(object A):             # <<<<<<<<<<<<<<
7416  *     """
7417  *     Converts a SciPy CSR sparse matrix to a
7418  */
7419 
7420   /* function exit code */
7421   __pyx_L1_error:;
7422   __Pyx_XDECREF(__pyx_t_1);
7423   __PYX_XDEC_MEMVIEW(&__pyx_t_2, 1);
7424   __PYX_XDEC_MEMVIEW(&__pyx_t_3, 1);
7425   __Pyx_XDECREF(__pyx_t_4);
7426   __Pyx_WriteUnraisable("qutip.cy.brtools.CSR_from_scipy", __pyx_clineno, __pyx_lineno, __pyx_filename, 1, 0);
7427   __Pyx_pretend_to_initialize(&__pyx_r);
7428   __pyx_L0:;
7429   __PYX_XDEC_MEMVIEW(&__pyx_v_data, 1);
7430   __PYX_XDEC_MEMVIEW(&__pyx_v_ind, 1);
7431   __PYX_XDEC_MEMVIEW(&__pyx_v_ptr, 1);
7432   __Pyx_RefNannyFinishContext();
7433   return __pyx_r;
7434 }
7435 
7436 /* "qutip/cy/sparse_routines.pxi":584
7437  * @cython.boundscheck(False)
7438  * @cython.wraparound(False)
7439  * cdef void CSR_from_scipy_inplace(object A, CSR_Matrix* mat):             # <<<<<<<<<<<<<<
7440  *     """
7441  *     Converts a SciPy CSR sparse matrix to a
7442  */
7443 
__pyx_f_5qutip_2cy_7brtools_CSR_from_scipy_inplace(PyObject * __pyx_v_A,__pyx_t_5qutip_2cy_14sparse_structs_CSR_Matrix * __pyx_v_mat)7444 static void __pyx_f_5qutip_2cy_7brtools_CSR_from_scipy_inplace(PyObject *__pyx_v_A, __pyx_t_5qutip_2cy_14sparse_structs_CSR_Matrix *__pyx_v_mat) {
7445   __Pyx_memviewslice __pyx_v_data = { 0, 0, { 0 }, { 0 }, { 0 } };
7446   __Pyx_memviewslice __pyx_v_ind = { 0, 0, { 0 }, { 0 }, { 0 } };
7447   __Pyx_memviewslice __pyx_v_ptr = { 0, 0, { 0 }, { 0 }, { 0 } };
7448   int __pyx_v_nrows;
7449   int __pyx_v_ncols;
7450   int __pyx_v_nnz;
7451   __Pyx_RefNannyDeclarations
7452   PyObject *__pyx_t_1 = NULL;
7453   __Pyx_memviewslice __pyx_t_2 = { 0, 0, { 0 }, { 0 }, { 0 } };
7454   __Pyx_memviewslice __pyx_t_3 = { 0, 0, { 0 }, { 0 }, { 0 } };
7455   PyObject *__pyx_t_4 = NULL;
7456   int __pyx_t_5;
7457   Py_ssize_t __pyx_t_6;
7458   int __pyx_lineno = 0;
7459   const char *__pyx_filename = NULL;
7460   int __pyx_clineno = 0;
7461   __Pyx_RefNannySetupContext("CSR_from_scipy_inplace", 0);
7462 
7463   /* "qutip/cy/sparse_routines.pxi":589
7464  *     CSR_Matrix struct.
7465  *     """
7466  *     cdef complex[::1] data = A.data             # <<<<<<<<<<<<<<
7467  *     cdef int[::1] ind = A.indices
7468  *     cdef int[::1] ptr = A.indptr
7469  */
7470   __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_A, __pyx_n_s_data); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 589, __pyx_L1_error)
7471   __Pyx_GOTREF(__pyx_t_1);
7472   __pyx_t_2 = __Pyx_PyObject_to_MemoryviewSlice_dc___pyx_t_double_complex(__pyx_t_1, PyBUF_WRITABLE); if (unlikely(!__pyx_t_2.memview)) __PYX_ERR(0, 589, __pyx_L1_error)
7473   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
7474   __pyx_v_data = __pyx_t_2;
7475   __pyx_t_2.memview = NULL;
7476   __pyx_t_2.data = NULL;
7477 
7478   /* "qutip/cy/sparse_routines.pxi":590
7479  *     """
7480  *     cdef complex[::1] data = A.data
7481  *     cdef int[::1] ind = A.indices             # <<<<<<<<<<<<<<
7482  *     cdef int[::1] ptr = A.indptr
7483  *     cdef int nrows = A.shape[0]
7484  */
7485   __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_A, __pyx_n_s_indices); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 590, __pyx_L1_error)
7486   __Pyx_GOTREF(__pyx_t_1);
7487   __pyx_t_3 = __Pyx_PyObject_to_MemoryviewSlice_dc_int(__pyx_t_1, PyBUF_WRITABLE); if (unlikely(!__pyx_t_3.memview)) __PYX_ERR(0, 590, __pyx_L1_error)
7488   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
7489   __pyx_v_ind = __pyx_t_3;
7490   __pyx_t_3.memview = NULL;
7491   __pyx_t_3.data = NULL;
7492 
7493   /* "qutip/cy/sparse_routines.pxi":591
7494  *     cdef complex[::1] data = A.data
7495  *     cdef int[::1] ind = A.indices
7496  *     cdef int[::1] ptr = A.indptr             # <<<<<<<<<<<<<<
7497  *     cdef int nrows = A.shape[0]
7498  *     cdef int ncols = A.shape[1]
7499  */
7500   __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_A, __pyx_n_s_indptr); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 591, __pyx_L1_error)
7501   __Pyx_GOTREF(__pyx_t_1);
7502   __pyx_t_3 = __Pyx_PyObject_to_MemoryviewSlice_dc_int(__pyx_t_1, PyBUF_WRITABLE); if (unlikely(!__pyx_t_3.memview)) __PYX_ERR(0, 591, __pyx_L1_error)
7503   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
7504   __pyx_v_ptr = __pyx_t_3;
7505   __pyx_t_3.memview = NULL;
7506   __pyx_t_3.data = NULL;
7507 
7508   /* "qutip/cy/sparse_routines.pxi":592
7509  *     cdef int[::1] ind = A.indices
7510  *     cdef int[::1] ptr = A.indptr
7511  *     cdef int nrows = A.shape[0]             # <<<<<<<<<<<<<<
7512  *     cdef int ncols = A.shape[1]
7513  *     cdef int nnz = ptr[nrows]
7514  */
7515   __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_A, __pyx_n_s_shape); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 592, __pyx_L1_error)
7516   __Pyx_GOTREF(__pyx_t_1);
7517   __pyx_t_4 = __Pyx_GetItemInt(__pyx_t_1, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 592, __pyx_L1_error)
7518   __Pyx_GOTREF(__pyx_t_4);
7519   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
7520   __pyx_t_5 = __Pyx_PyInt_As_int(__pyx_t_4); if (unlikely((__pyx_t_5 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 592, __pyx_L1_error)
7521   __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
7522   __pyx_v_nrows = __pyx_t_5;
7523 
7524   /* "qutip/cy/sparse_routines.pxi":593
7525  *     cdef int[::1] ptr = A.indptr
7526  *     cdef int nrows = A.shape[0]
7527  *     cdef int ncols = A.shape[1]             # <<<<<<<<<<<<<<
7528  *     cdef int nnz = ptr[nrows]
7529  *
7530  */
7531   __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_A, __pyx_n_s_shape); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 593, __pyx_L1_error)
7532   __Pyx_GOTREF(__pyx_t_4);
7533   __pyx_t_1 = __Pyx_GetItemInt(__pyx_t_4, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 593, __pyx_L1_error)
7534   __Pyx_GOTREF(__pyx_t_1);
7535   __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
7536   __pyx_t_5 = __Pyx_PyInt_As_int(__pyx_t_1); if (unlikely((__pyx_t_5 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 593, __pyx_L1_error)
7537   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
7538   __pyx_v_ncols = __pyx_t_5;
7539 
7540   /* "qutip/cy/sparse_routines.pxi":594
7541  *     cdef int nrows = A.shape[0]
7542  *     cdef int ncols = A.shape[1]
7543  *     cdef int nnz = ptr[nrows]             # <<<<<<<<<<<<<<
7544  *
7545  *     mat.data = &data[0]
7546  */
7547   __pyx_t_6 = __pyx_v_nrows;
7548   __pyx_v_nnz = (*((int *) ( /* dim=0 */ ((char *) (((int *) __pyx_v_ptr.data) + __pyx_t_6)) )));
7549 
7550   /* "qutip/cy/sparse_routines.pxi":596
7551  *     cdef int nnz = ptr[nrows]
7552  *
7553  *     mat.data = &data[0]             # <<<<<<<<<<<<<<
7554  *     mat.indices = &ind[0]
7555  *     mat.indptr = &ptr[0]
7556  */
7557   __pyx_t_6 = 0;
7558   __pyx_v_mat->data = (&(*((__pyx_t_double_complex *) ( /* dim=0 */ ((char *) (((__pyx_t_double_complex *) __pyx_v_data.data) + __pyx_t_6)) ))));
7559 
7560   /* "qutip/cy/sparse_routines.pxi":597
7561  *
7562  *     mat.data = &data[0]
7563  *     mat.indices = &ind[0]             # <<<<<<<<<<<<<<
7564  *     mat.indptr = &ptr[0]
7565  *     mat.nrows = nrows
7566  */
7567   __pyx_t_6 = 0;
7568   __pyx_v_mat->indices = (&(*((int *) ( /* dim=0 */ ((char *) (((int *) __pyx_v_ind.data) + __pyx_t_6)) ))));
7569 
7570   /* "qutip/cy/sparse_routines.pxi":598
7571  *     mat.data = &data[0]
7572  *     mat.indices = &ind[0]
7573  *     mat.indptr = &ptr[0]             # <<<<<<<<<<<<<<
7574  *     mat.nrows = nrows
7575  *     mat.ncols = ncols
7576  */
7577   __pyx_t_6 = 0;
7578   __pyx_v_mat->indptr = (&(*((int *) ( /* dim=0 */ ((char *) (((int *) __pyx_v_ptr.data) + __pyx_t_6)) ))));
7579 
7580   /* "qutip/cy/sparse_routines.pxi":599
7581  *     mat.indices = &ind[0]
7582  *     mat.indptr = &ptr[0]
7583  *     mat.nrows = nrows             # <<<<<<<<<<<<<<
7584  *     mat.ncols = ncols
7585  *     mat.nnz = nnz
7586  */
7587   __pyx_v_mat->nrows = __pyx_v_nrows;
7588 
7589   /* "qutip/cy/sparse_routines.pxi":600
7590  *     mat.indptr = &ptr[0]
7591  *     mat.nrows = nrows
7592  *     mat.ncols = ncols             # <<<<<<<<<<<<<<
7593  *     mat.nnz = nnz
7594  *     mat.max_length = nnz
7595  */
7596   __pyx_v_mat->ncols = __pyx_v_ncols;
7597 
7598   /* "qutip/cy/sparse_routines.pxi":601
7599  *     mat.nrows = nrows
7600  *     mat.ncols = ncols
7601  *     mat.nnz = nnz             # <<<<<<<<<<<<<<
7602  *     mat.max_length = nnz
7603  *     mat.is_set = 1
7604  */
7605   __pyx_v_mat->nnz = __pyx_v_nnz;
7606 
7607   /* "qutip/cy/sparse_routines.pxi":602
7608  *     mat.ncols = ncols
7609  *     mat.nnz = nnz
7610  *     mat.max_length = nnz             # <<<<<<<<<<<<<<
7611  *     mat.is_set = 1
7612  *     mat.numpy_lock = 1
7613  */
7614   __pyx_v_mat->max_length = __pyx_v_nnz;
7615 
7616   /* "qutip/cy/sparse_routines.pxi":603
7617  *     mat.nnz = nnz
7618  *     mat.max_length = nnz
7619  *     mat.is_set = 1             # <<<<<<<<<<<<<<
7620  *     mat.numpy_lock = 1
7621  *
7622  */
7623   __pyx_v_mat->is_set = 1;
7624 
7625   /* "qutip/cy/sparse_routines.pxi":604
7626  *     mat.max_length = nnz
7627  *     mat.is_set = 1
7628  *     mat.numpy_lock = 1             # <<<<<<<<<<<<<<
7629  *
7630  *
7631  */
7632   __pyx_v_mat->numpy_lock = 1;
7633 
7634   /* "qutip/cy/sparse_routines.pxi":584
7635  * @cython.boundscheck(False)
7636  * @cython.wraparound(False)
7637  * cdef void CSR_from_scipy_inplace(object A, CSR_Matrix* mat):             # <<<<<<<<<<<<<<
7638  *     """
7639  *     Converts a SciPy CSR sparse matrix to a
7640  */
7641 
7642   /* function exit code */
7643   goto __pyx_L0;
7644   __pyx_L1_error:;
7645   __Pyx_XDECREF(__pyx_t_1);
7646   __PYX_XDEC_MEMVIEW(&__pyx_t_2, 1);
7647   __PYX_XDEC_MEMVIEW(&__pyx_t_3, 1);
7648   __Pyx_XDECREF(__pyx_t_4);
7649   __Pyx_WriteUnraisable("qutip.cy.brtools.CSR_from_scipy_inplace", __pyx_clineno, __pyx_lineno, __pyx_filename, 1, 0);
7650   __pyx_L0:;
7651   __PYX_XDEC_MEMVIEW(&__pyx_v_data, 1);
7652   __PYX_XDEC_MEMVIEW(&__pyx_v_ind, 1);
7653   __PYX_XDEC_MEMVIEW(&__pyx_v_ptr, 1);
7654   __Pyx_RefNannyFinishContext();
7655 }
7656 
7657 /* "qutip/cy/sparse_routines.pxi":609
7658  * @cython.boundscheck(False)
7659  * @cython.wraparound(False)
7660  * cdef COO_Matrix COO_from_scipy(object A):             # <<<<<<<<<<<<<<
7661  *     """
7662  *     Converts a SciPy COO sparse matrix to a
7663  */
7664 
__pyx_f_5qutip_2cy_7brtools_COO_from_scipy(PyObject * __pyx_v_A)7665 static __pyx_t_5qutip_2cy_14sparse_structs_COO_Matrix __pyx_f_5qutip_2cy_7brtools_COO_from_scipy(PyObject *__pyx_v_A) {
7666   __Pyx_memviewslice __pyx_v_data = { 0, 0, { 0 }, { 0 }, { 0 } };
7667   __Pyx_memviewslice __pyx_v_rows = { 0, 0, { 0 }, { 0 }, { 0 } };
7668   __Pyx_memviewslice __pyx_v_cols = { 0, 0, { 0 }, { 0 }, { 0 } };
7669   int __pyx_v_nrows;
7670   int __pyx_v_ncols;
7671   int __pyx_v_nnz;
7672   __pyx_t_5qutip_2cy_14sparse_structs_COO_Matrix __pyx_v_mat;
7673   __pyx_t_5qutip_2cy_14sparse_structs_COO_Matrix __pyx_r;
7674   __Pyx_RefNannyDeclarations
7675   PyObject *__pyx_t_1 = NULL;
7676   __Pyx_memviewslice __pyx_t_2 = { 0, 0, { 0 }, { 0 }, { 0 } };
7677   __Pyx_memviewslice __pyx_t_3 = { 0, 0, { 0 }, { 0 }, { 0 } };
7678   PyObject *__pyx_t_4 = NULL;
7679   int __pyx_t_5;
7680   Py_ssize_t __pyx_t_6;
7681   int __pyx_lineno = 0;
7682   const char *__pyx_filename = NULL;
7683   int __pyx_clineno = 0;
7684   __Pyx_RefNannySetupContext("COO_from_scipy", 0);
7685 
7686   /* "qutip/cy/sparse_routines.pxi":614
7687  *     COO_Matrix struct.
7688  *     """
7689  *     cdef complex[::1] data = A.data             # <<<<<<<<<<<<<<
7690  *     cdef int[::1] rows = A.row
7691  *     cdef int[::1] cols = A.col
7692  */
7693   __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_A, __pyx_n_s_data); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 614, __pyx_L1_error)
7694   __Pyx_GOTREF(__pyx_t_1);
7695   __pyx_t_2 = __Pyx_PyObject_to_MemoryviewSlice_dc___pyx_t_double_complex(__pyx_t_1, PyBUF_WRITABLE); if (unlikely(!__pyx_t_2.memview)) __PYX_ERR(0, 614, __pyx_L1_error)
7696   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
7697   __pyx_v_data = __pyx_t_2;
7698   __pyx_t_2.memview = NULL;
7699   __pyx_t_2.data = NULL;
7700 
7701   /* "qutip/cy/sparse_routines.pxi":615
7702  *     """
7703  *     cdef complex[::1] data = A.data
7704  *     cdef int[::1] rows = A.row             # <<<<<<<<<<<<<<
7705  *     cdef int[::1] cols = A.col
7706  *     cdef int nrows = A.shape[0]
7707  */
7708   __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_A, __pyx_n_s_row); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 615, __pyx_L1_error)
7709   __Pyx_GOTREF(__pyx_t_1);
7710   __pyx_t_3 = __Pyx_PyObject_to_MemoryviewSlice_dc_int(__pyx_t_1, PyBUF_WRITABLE); if (unlikely(!__pyx_t_3.memview)) __PYX_ERR(0, 615, __pyx_L1_error)
7711   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
7712   __pyx_v_rows = __pyx_t_3;
7713   __pyx_t_3.memview = NULL;
7714   __pyx_t_3.data = NULL;
7715 
7716   /* "qutip/cy/sparse_routines.pxi":616
7717  *     cdef complex[::1] data = A.data
7718  *     cdef int[::1] rows = A.row
7719  *     cdef int[::1] cols = A.col             # <<<<<<<<<<<<<<
7720  *     cdef int nrows = A.shape[0]
7721  *     cdef int ncols = A.shape[1]
7722  */
7723   __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_A, __pyx_n_s_col); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 616, __pyx_L1_error)
7724   __Pyx_GOTREF(__pyx_t_1);
7725   __pyx_t_3 = __Pyx_PyObject_to_MemoryviewSlice_dc_int(__pyx_t_1, PyBUF_WRITABLE); if (unlikely(!__pyx_t_3.memview)) __PYX_ERR(0, 616, __pyx_L1_error)
7726   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
7727   __pyx_v_cols = __pyx_t_3;
7728   __pyx_t_3.memview = NULL;
7729   __pyx_t_3.data = NULL;
7730 
7731   /* "qutip/cy/sparse_routines.pxi":617
7732  *     cdef int[::1] rows = A.row
7733  *     cdef int[::1] cols = A.col
7734  *     cdef int nrows = A.shape[0]             # <<<<<<<<<<<<<<
7735  *     cdef int ncols = A.shape[1]
7736  *     cdef int nnz = data.shape[0]
7737  */
7738   __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_A, __pyx_n_s_shape); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 617, __pyx_L1_error)
7739   __Pyx_GOTREF(__pyx_t_1);
7740   __pyx_t_4 = __Pyx_GetItemInt(__pyx_t_1, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 617, __pyx_L1_error)
7741   __Pyx_GOTREF(__pyx_t_4);
7742   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
7743   __pyx_t_5 = __Pyx_PyInt_As_int(__pyx_t_4); if (unlikely((__pyx_t_5 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 617, __pyx_L1_error)
7744   __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
7745   __pyx_v_nrows = __pyx_t_5;
7746 
7747   /* "qutip/cy/sparse_routines.pxi":618
7748  *     cdef int[::1] cols = A.col
7749  *     cdef int nrows = A.shape[0]
7750  *     cdef int ncols = A.shape[1]             # <<<<<<<<<<<<<<
7751  *     cdef int nnz = data.shape[0]
7752  *
7753  */
7754   __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_A, __pyx_n_s_shape); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 618, __pyx_L1_error)
7755   __Pyx_GOTREF(__pyx_t_4);
7756   __pyx_t_1 = __Pyx_GetItemInt(__pyx_t_4, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 618, __pyx_L1_error)
7757   __Pyx_GOTREF(__pyx_t_1);
7758   __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
7759   __pyx_t_5 = __Pyx_PyInt_As_int(__pyx_t_1); if (unlikely((__pyx_t_5 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 618, __pyx_L1_error)
7760   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
7761   __pyx_v_ncols = __pyx_t_5;
7762 
7763   /* "qutip/cy/sparse_routines.pxi":619
7764  *     cdef int nrows = A.shape[0]
7765  *     cdef int ncols = A.shape[1]
7766  *     cdef int nnz = data.shape[0]             # <<<<<<<<<<<<<<
7767  *
7768  *     cdef COO_Matrix mat
7769  */
7770   __pyx_v_nnz = (__pyx_v_data.shape[0]);
7771 
7772   /* "qutip/cy/sparse_routines.pxi":622
7773  *
7774  *     cdef COO_Matrix mat
7775  *     mat.data = &data[0]             # <<<<<<<<<<<<<<
7776  *     mat.rows = &rows[0]
7777  *     mat.cols = &cols[0]
7778  */
7779   __pyx_t_6 = 0;
7780   __pyx_v_mat.data = (&(*((__pyx_t_double_complex *) ( /* dim=0 */ ((char *) (((__pyx_t_double_complex *) __pyx_v_data.data) + __pyx_t_6)) ))));
7781 
7782   /* "qutip/cy/sparse_routines.pxi":623
7783  *     cdef COO_Matrix mat
7784  *     mat.data = &data[0]
7785  *     mat.rows = &rows[0]             # <<<<<<<<<<<<<<
7786  *     mat.cols = &cols[0]
7787  *     mat.nrows = nrows
7788  */
7789   __pyx_t_6 = 0;
7790   __pyx_v_mat.rows = (&(*((int *) ( /* dim=0 */ ((char *) (((int *) __pyx_v_rows.data) + __pyx_t_6)) ))));
7791 
7792   /* "qutip/cy/sparse_routines.pxi":624
7793  *     mat.data = &data[0]
7794  *     mat.rows = &rows[0]
7795  *     mat.cols = &cols[0]             # <<<<<<<<<<<<<<
7796  *     mat.nrows = nrows
7797  *     mat.ncols = ncols
7798  */
7799   __pyx_t_6 = 0;
7800   __pyx_v_mat.cols = (&(*((int *) ( /* dim=0 */ ((char *) (((int *) __pyx_v_cols.data) + __pyx_t_6)) ))));
7801 
7802   /* "qutip/cy/sparse_routines.pxi":625
7803  *     mat.rows = &rows[0]
7804  *     mat.cols = &cols[0]
7805  *     mat.nrows = nrows             # <<<<<<<<<<<<<<
7806  *     mat.ncols = ncols
7807  *     mat.nnz = nnz
7808  */
7809   __pyx_v_mat.nrows = __pyx_v_nrows;
7810 
7811   /* "qutip/cy/sparse_routines.pxi":626
7812  *     mat.cols = &cols[0]
7813  *     mat.nrows = nrows
7814  *     mat.ncols = ncols             # <<<<<<<<<<<<<<
7815  *     mat.nnz = nnz
7816  *     mat.max_length = nnz
7817  */
7818   __pyx_v_mat.ncols = __pyx_v_ncols;
7819 
7820   /* "qutip/cy/sparse_routines.pxi":627
7821  *     mat.nrows = nrows
7822  *     mat.ncols = ncols
7823  *     mat.nnz = nnz             # <<<<<<<<<<<<<<
7824  *     mat.max_length = nnz
7825  *     mat.is_set = 1
7826  */
7827   __pyx_v_mat.nnz = __pyx_v_nnz;
7828 
7829   /* "qutip/cy/sparse_routines.pxi":628
7830  *     mat.ncols = ncols
7831  *     mat.nnz = nnz
7832  *     mat.max_length = nnz             # <<<<<<<<<<<<<<
7833  *     mat.is_set = 1
7834  *     mat.numpy_lock = 1
7835  */
7836   __pyx_v_mat.max_length = __pyx_v_nnz;
7837 
7838   /* "qutip/cy/sparse_routines.pxi":629
7839  *     mat.nnz = nnz
7840  *     mat.max_length = nnz
7841  *     mat.is_set = 1             # <<<<<<<<<<<<<<
7842  *     mat.numpy_lock = 1
7843  *
7844  */
7845   __pyx_v_mat.is_set = 1;
7846 
7847   /* "qutip/cy/sparse_routines.pxi":630
7848  *     mat.max_length = nnz
7849  *     mat.is_set = 1
7850  *     mat.numpy_lock = 1             # <<<<<<<<<<<<<<
7851  *
7852  *     return mat
7853  */
7854   __pyx_v_mat.numpy_lock = 1;
7855 
7856   /* "qutip/cy/sparse_routines.pxi":632
7857  *     mat.numpy_lock = 1
7858  *
7859  *     return mat             # <<<<<<<<<<<<<<
7860  *
7861  *
7862  */
7863   __pyx_r = __pyx_v_mat;
7864   goto __pyx_L0;
7865 
7866   /* "qutip/cy/sparse_routines.pxi":609
7867  * @cython.boundscheck(False)
7868  * @cython.wraparound(False)
7869  * cdef COO_Matrix COO_from_scipy(object A):             # <<<<<<<<<<<<<<
7870  *     """
7871  *     Converts a SciPy COO sparse matrix to a
7872  */
7873 
7874   /* function exit code */
7875   __pyx_L1_error:;
7876   __Pyx_XDECREF(__pyx_t_1);
7877   __PYX_XDEC_MEMVIEW(&__pyx_t_2, 1);
7878   __PYX_XDEC_MEMVIEW(&__pyx_t_3, 1);
7879   __Pyx_XDECREF(__pyx_t_4);
7880   __Pyx_WriteUnraisable("qutip.cy.brtools.COO_from_scipy", __pyx_clineno, __pyx_lineno, __pyx_filename, 1, 0);
7881   __Pyx_pretend_to_initialize(&__pyx_r);
7882   __pyx_L0:;
7883   __PYX_XDEC_MEMVIEW(&__pyx_v_data, 1);
7884   __PYX_XDEC_MEMVIEW(&__pyx_v_rows, 1);
7885   __PYX_XDEC_MEMVIEW(&__pyx_v_cols, 1);
7886   __Pyx_RefNannyFinishContext();
7887   return __pyx_r;
7888 }
7889 
7890 /* "qutip/cy/sparse_routines.pxi":637
7891  * @cython.boundscheck(False)
7892  * @cython.wraparound(False)
7893  * cdef void identity_CSR(CSR_Matrix * mat, unsigned int nrows):             # <<<<<<<<<<<<<<
7894  *     cdef size_t kk
7895  *     init_CSR(mat, nrows, nrows, nrows, 0, 0)
7896  */
7897 
__pyx_f_5qutip_2cy_7brtools_identity_CSR(__pyx_t_5qutip_2cy_14sparse_structs_CSR_Matrix * __pyx_v_mat,unsigned int __pyx_v_nrows)7898 static void __pyx_f_5qutip_2cy_7brtools_identity_CSR(__pyx_t_5qutip_2cy_14sparse_structs_CSR_Matrix *__pyx_v_mat, unsigned int __pyx_v_nrows) {
7899   size_t __pyx_v_kk;
7900   __Pyx_RefNannyDeclarations
7901   struct __pyx_opt_args_5qutip_2cy_7brtools_init_CSR __pyx_t_1;
7902   unsigned int __pyx_t_2;
7903   unsigned int __pyx_t_3;
7904   size_t __pyx_t_4;
7905   __Pyx_RefNannySetupContext("identity_CSR", 0);
7906 
7907   /* "qutip/cy/sparse_routines.pxi":639
7908  * cdef void identity_CSR(CSR_Matrix * mat, unsigned int nrows):
7909  *     cdef size_t kk
7910  *     init_CSR(mat, nrows, nrows, nrows, 0, 0)             # <<<<<<<<<<<<<<
7911  *     for kk in range(nrows):
7912  *         mat.data[kk] = 1
7913  */
7914   __pyx_t_1.__pyx_n = 3;
7915   __pyx_t_1.ncols = __pyx_v_nrows;
7916   __pyx_t_1.max_length = 0;
7917   __pyx_t_1.init_zeros = 0;
7918   __pyx_f_5qutip_2cy_7brtools_init_CSR(__pyx_v_mat, __pyx_v_nrows, __pyx_v_nrows, &__pyx_t_1);
7919 
7920   /* "qutip/cy/sparse_routines.pxi":640
7921  *     cdef size_t kk
7922  *     init_CSR(mat, nrows, nrows, nrows, 0, 0)
7923  *     for kk in range(nrows):             # <<<<<<<<<<<<<<
7924  *         mat.data[kk] = 1
7925  *         mat.indices[kk] = kk
7926  */
7927   __pyx_t_2 = __pyx_v_nrows;
7928   __pyx_t_3 = __pyx_t_2;
7929   for (__pyx_t_4 = 0; __pyx_t_4 < __pyx_t_3; __pyx_t_4+=1) {
7930     __pyx_v_kk = __pyx_t_4;
7931 
7932     /* "qutip/cy/sparse_routines.pxi":641
7933  *     init_CSR(mat, nrows, nrows, nrows, 0, 0)
7934  *     for kk in range(nrows):
7935  *         mat.data[kk] = 1             # <<<<<<<<<<<<<<
7936  *         mat.indices[kk] = kk
7937  *         mat.indptr[kk] = kk
7938  */
7939     (__pyx_v_mat->data[__pyx_v_kk]) = __pyx_t_double_complex_from_parts(1, 0);
7940 
7941     /* "qutip/cy/sparse_routines.pxi":642
7942  *     for kk in range(nrows):
7943  *         mat.data[kk] = 1
7944  *         mat.indices[kk] = kk             # <<<<<<<<<<<<<<
7945  *         mat.indptr[kk] = kk
7946  *     mat.indptr[nrows] = nrows
7947  */
7948     (__pyx_v_mat->indices[__pyx_v_kk]) = __pyx_v_kk;
7949 
7950     /* "qutip/cy/sparse_routines.pxi":643
7951  *         mat.data[kk] = 1
7952  *         mat.indices[kk] = kk
7953  *         mat.indptr[kk] = kk             # <<<<<<<<<<<<<<
7954  *     mat.indptr[nrows] = nrows
7955  */
7956     (__pyx_v_mat->indptr[__pyx_v_kk]) = __pyx_v_kk;
7957   }
7958 
7959   /* "qutip/cy/sparse_routines.pxi":644
7960  *         mat.indices[kk] = kk
7961  *         mat.indptr[kk] = kk
7962  *     mat.indptr[nrows] = nrows             # <<<<<<<<<<<<<<
7963  */
7964   (__pyx_v_mat->indptr[__pyx_v_nrows]) = __pyx_v_nrows;
7965 
7966   /* "qutip/cy/sparse_routines.pxi":637
7967  * @cython.boundscheck(False)
7968  * @cython.wraparound(False)
7969  * cdef void identity_CSR(CSR_Matrix * mat, unsigned int nrows):             # <<<<<<<<<<<<<<
7970  *     cdef size_t kk
7971  *     init_CSR(mat, nrows, nrows, nrows, 0, 0)
7972  */
7973 
7974   /* function exit code */
7975   __Pyx_RefNannyFinishContext();
7976 }
7977 
7978 /* "qutip/cy/brtools.pyx":64
7979  * @cython.boundscheck(False)
7980  * @cython.wraparound(False)
7981  * cdef complex[::1,:] farray_alloc(int nrows):             # <<<<<<<<<<<<<<
7982  *     """
7983  *     Allocate a complex zero array in fortran-order for a
7984  */
7985 
__pyx_f_5qutip_2cy_7brtools_farray_alloc(int __pyx_v_nrows)7986 static __Pyx_memviewslice __pyx_f_5qutip_2cy_7brtools_farray_alloc(int __pyx_v_nrows) {
7987   __pyx_t_double_complex *__pyx_v_temp;
7988   __Pyx_memviewslice __pyx_v_cview = { 0, 0, { 0 }, { 0 }, { 0 } };
7989   __Pyx_memviewslice __pyx_v_fview = { 0, 0, { 0 }, { 0 }, { 0 } };
7990   __Pyx_memviewslice __pyx_r = { 0, 0, { 0 }, { 0 }, { 0 } };
7991   __Pyx_RefNannyDeclarations
7992   struct __pyx_array_obj *__pyx_t_1 = NULL;
7993   PyObject *__pyx_t_2 = NULL;
7994   PyObject *__pyx_t_3 = NULL;
7995   __Pyx_memviewslice __pyx_t_4 = { 0, 0, { 0 }, { 0 }, { 0 } };
7996   __Pyx_memviewslice __pyx_t_5 = { 0, 0, { 0 }, { 0 }, { 0 } };
7997   int __pyx_lineno = 0;
7998   const char *__pyx_filename = NULL;
7999   int __pyx_clineno = 0;
8000   __Pyx_RefNannySetupContext("farray_alloc", 0);
8001 
8002   /* "qutip/cy/brtools.pyx":79
8003  *         A zeroed memoryview in fortran-order.
8004  *     """
8005  *     cdef double complex * temp = <double complex *>PyDataMem_NEW_ZEROED(nrows*nrows,sizeof(complex))             # <<<<<<<<<<<<<<
8006  *     cdef complex[:,::1] cview = <double complex[:nrows, :nrows]> temp
8007  *     cdef complex[::1,:] fview = cview.T
8008  */
8009   __pyx_v_temp = ((__pyx_t_double_complex *)PyDataMem_NEW_ZEROED((__pyx_v_nrows * __pyx_v_nrows), (sizeof(__pyx_t_double_complex))));
8010 
8011   /* "qutip/cy/brtools.pyx":80
8012  *     """
8013  *     cdef double complex * temp = <double complex *>PyDataMem_NEW_ZEROED(nrows*nrows,sizeof(complex))
8014  *     cdef complex[:,::1] cview = <double complex[:nrows, :nrows]> temp             # <<<<<<<<<<<<<<
8015  *     cdef complex[::1,:] fview = cview.T
8016  *     return fview
8017  */
8018   if (!__pyx_v_temp) {
8019     PyErr_SetString(PyExc_ValueError,"Cannot create cython.array from NULL pointer");
8020     __PYX_ERR(1, 80, __pyx_L1_error)
8021   }
8022   __pyx_t_3 = __pyx_format_from_typeinfo(&__Pyx_TypeInfo___pyx_t_double_complex); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 80, __pyx_L1_error)
8023   __Pyx_GOTREF(__pyx_t_3);
8024   __pyx_t_2 = Py_BuildValue((char*) "("  __PYX_BUILD_PY_SSIZE_T  __PYX_BUILD_PY_SSIZE_T  ")", ((Py_ssize_t)__pyx_v_nrows), ((Py_ssize_t)__pyx_v_nrows)); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 80, __pyx_L1_error)
8025   __Pyx_GOTREF(__pyx_t_2);
8026   __pyx_t_1 = __pyx_array_new(__pyx_t_2, sizeof(__pyx_t_double_complex), PyBytes_AS_STRING(__pyx_t_3), (char *) "c", (char *) __pyx_v_temp);
8027   if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 80, __pyx_L1_error)
8028   __Pyx_GOTREF(__pyx_t_1);
8029   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
8030   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
8031   __pyx_t_4 = __Pyx_PyObject_to_MemoryviewSlice_d_dc___pyx_t_double_complex(((PyObject *)__pyx_t_1), PyBUF_WRITABLE); if (unlikely(!__pyx_t_4.memview)) __PYX_ERR(1, 80, __pyx_L1_error)
8032   __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
8033   __pyx_v_cview = __pyx_t_4;
8034   __pyx_t_4.memview = NULL;
8035   __pyx_t_4.data = NULL;
8036 
8037   /* "qutip/cy/brtools.pyx":81
8038  *     cdef double complex * temp = <double complex *>PyDataMem_NEW_ZEROED(nrows*nrows,sizeof(complex))
8039  *     cdef complex[:,::1] cview = <double complex[:nrows, :nrows]> temp
8040  *     cdef complex[::1,:] fview = cview.T             # <<<<<<<<<<<<<<
8041  *     return fview
8042  *
8043  */
8044   __pyx_t_5 = __pyx_v_cview;
8045   __PYX_INC_MEMVIEW(&__pyx_t_5, 1);
8046   if (unlikely(__pyx_memslice_transpose(&__pyx_t_5) == 0)) __PYX_ERR(1, 81, __pyx_L1_error)
8047   __pyx_v_fview = __pyx_t_5;
8048   __pyx_t_5.memview = NULL;
8049   __pyx_t_5.data = NULL;
8050 
8051   /* "qutip/cy/brtools.pyx":82
8052  *     cdef complex[:,::1] cview = <double complex[:nrows, :nrows]> temp
8053  *     cdef complex[::1,:] fview = cview.T
8054  *     return fview             # <<<<<<<<<<<<<<
8055  *
8056  *
8057  */
8058   __PYX_INC_MEMVIEW(&__pyx_v_fview, 0);
8059   __pyx_r = __pyx_v_fview;
8060   goto __pyx_L0;
8061 
8062   /* "qutip/cy/brtools.pyx":64
8063  * @cython.boundscheck(False)
8064  * @cython.wraparound(False)
8065  * cdef complex[::1,:] farray_alloc(int nrows):             # <<<<<<<<<<<<<<
8066  *     """
8067  *     Allocate a complex zero array in fortran-order for a
8068  */
8069 
8070   /* function exit code */
8071   __pyx_L1_error:;
8072   __Pyx_XDECREF(((PyObject *)__pyx_t_1));
8073   __Pyx_XDECREF(__pyx_t_2);
8074   __Pyx_XDECREF(__pyx_t_3);
8075   __PYX_XDEC_MEMVIEW(&__pyx_t_4, 1);
8076   __PYX_XDEC_MEMVIEW(&__pyx_t_5, 1);
8077   __pyx_r.data = NULL;
8078   __pyx_r.memview = NULL;
8079   __Pyx_AddTraceback("qutip.cy.brtools.farray_alloc", __pyx_clineno, __pyx_lineno, __pyx_filename);
8080   goto __pyx_L2;
8081   __pyx_L0:;
8082   if (unlikely(!__pyx_r.memview)) {
8083     PyErr_SetString(PyExc_TypeError, "Memoryview return value is not initialized");
8084   }
8085   __pyx_L2:;
8086   __PYX_XDEC_MEMVIEW(&__pyx_v_cview, 1);
8087   __PYX_XDEC_MEMVIEW(&__pyx_v_fview, 1);
8088   __Pyx_RefNannyFinishContext();
8089   return __pyx_r;
8090 }
8091 
8092 /* "qutip/cy/brtools.pyx":87
8093  * @cython.boundscheck(False)
8094  * @cython.wraparound(False)
8095  * cpdef void dense_add_mult(complex[::1,:] A,             # <<<<<<<<<<<<<<
8096  *                   complex[::1,:] B,
8097  *                   double complex alpha) nogil:
8098  */
8099 
8100 static PyObject *__pyx_pw_5qutip_2cy_7brtools_1dense_add_mult(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
__pyx_f_5qutip_2cy_7brtools_dense_add_mult(__Pyx_memviewslice __pyx_v_A,__Pyx_memviewslice __pyx_v_B,__pyx_t_double_complex __pyx_v_alpha,CYTHON_UNUSED int __pyx_skip_dispatch)8101 static void __pyx_f_5qutip_2cy_7brtools_dense_add_mult(__Pyx_memviewslice __pyx_v_A, __Pyx_memviewslice __pyx_v_B, __pyx_t_double_complex __pyx_v_alpha, CYTHON_UNUSED int __pyx_skip_dispatch) {
8102   int __pyx_v_nrows2;
8103   int __pyx_v_inc;
8104   Py_ssize_t __pyx_t_1;
8105   Py_ssize_t __pyx_t_2;
8106   Py_ssize_t __pyx_t_3;
8107   Py_ssize_t __pyx_t_4;
8108 
8109   /* "qutip/cy/brtools.pyx":105
8110  *
8111  *     """
8112  *     cdef int nrows2 = A.shape[0]**2             # <<<<<<<<<<<<<<
8113  *     cdef int inc = 1
8114  *     zaxpy(&nrows2, &alpha, &B[0,0], &inc, &A[0,0], &inc)
8115  */
8116   __pyx_v_nrows2 = __Pyx_pow_Py_ssize_t((__pyx_v_A.shape[0]), 2);
8117 
8118   /* "qutip/cy/brtools.pyx":106
8119  *     """
8120  *     cdef int nrows2 = A.shape[0]**2
8121  *     cdef int inc = 1             # <<<<<<<<<<<<<<
8122  *     zaxpy(&nrows2, &alpha, &B[0,0], &inc, &A[0,0], &inc)
8123  *
8124  */
8125   __pyx_v_inc = 1;
8126 
8127   /* "qutip/cy/brtools.pyx":107
8128  *     cdef int nrows2 = A.shape[0]**2
8129  *     cdef int inc = 1
8130  *     zaxpy(&nrows2, &alpha, &B[0,0], &inc, &A[0,0], &inc)             # <<<<<<<<<<<<<<
8131  *
8132  *
8133  */
8134   __pyx_t_1 = 0;
8135   __pyx_t_2 = 0;
8136   __pyx_t_3 = 0;
8137   __pyx_t_4 = 0;
8138   __pyx_f_5scipy_6linalg_11cython_blas_zaxpy((&__pyx_v_nrows2), (&__pyx_v_alpha), (&(*((__pyx_t_double_complex *) ( /* dim=1 */ (( /* dim=0 */ ((char *) (((__pyx_t_double_complex *) __pyx_v_B.data) + __pyx_t_1)) ) + __pyx_t_2 * __pyx_v_B.strides[1]) )))), (&__pyx_v_inc), (&(*((__pyx_t_double_complex *) ( /* dim=1 */ (( /* dim=0 */ ((char *) (((__pyx_t_double_complex *) __pyx_v_A.data) + __pyx_t_3)) ) + __pyx_t_4 * __pyx_v_A.strides[1]) )))), (&__pyx_v_inc));
8139 
8140   /* "qutip/cy/brtools.pyx":87
8141  * @cython.boundscheck(False)
8142  * @cython.wraparound(False)
8143  * cpdef void dense_add_mult(complex[::1,:] A,             # <<<<<<<<<<<<<<
8144  *                   complex[::1,:] B,
8145  *                   double complex alpha) nogil:
8146  */
8147 
8148   /* function exit code */
8149 }
8150 
8151 /* Python wrapper */
8152 static PyObject *__pyx_pw_5qutip_2cy_7brtools_1dense_add_mult(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
8153 static char __pyx_doc_5qutip_2cy_7brtools_dense_add_mult[] = "\n    Performs the dense matrix multiplication A = A + (alpha*B)\n    where A and B are complex 2D square matrices,\n    and alpha is a complex coefficient.\n\n    Parameters\n    ----------\n    A : ndarray\n        Complex matrix in f-order that is to be overwritten\n    B : ndarray\n        Complex matrix in f-order.\n    alpha : complex\n        Coefficient in front of B.\n\n    ";
__pyx_pw_5qutip_2cy_7brtools_1dense_add_mult(PyObject * __pyx_self,PyObject * __pyx_args,PyObject * __pyx_kwds)8154 static PyObject *__pyx_pw_5qutip_2cy_7brtools_1dense_add_mult(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
8155   __Pyx_memviewslice __pyx_v_A = { 0, 0, { 0 }, { 0 }, { 0 } };
8156   __Pyx_memviewslice __pyx_v_B = { 0, 0, { 0 }, { 0 }, { 0 } };
8157   __pyx_t_double_complex __pyx_v_alpha;
8158   int __pyx_lineno = 0;
8159   const char *__pyx_filename = NULL;
8160   int __pyx_clineno = 0;
8161   PyObject *__pyx_r = 0;
8162   __Pyx_RefNannyDeclarations
8163   __Pyx_RefNannySetupContext("dense_add_mult (wrapper)", 0);
8164   {
8165     static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_A,&__pyx_n_s_B,&__pyx_n_s_alpha,0};
8166     PyObject* values[3] = {0,0,0};
8167     if (unlikely(__pyx_kwds)) {
8168       Py_ssize_t kw_args;
8169       const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
8170       switch (pos_args) {
8171         case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
8172         CYTHON_FALLTHROUGH;
8173         case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
8174         CYTHON_FALLTHROUGH;
8175         case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
8176         CYTHON_FALLTHROUGH;
8177         case  0: break;
8178         default: goto __pyx_L5_argtuple_error;
8179       }
8180       kw_args = PyDict_Size(__pyx_kwds);
8181       switch (pos_args) {
8182         case  0:
8183         if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_A)) != 0)) kw_args--;
8184         else goto __pyx_L5_argtuple_error;
8185         CYTHON_FALLTHROUGH;
8186         case  1:
8187         if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_B)) != 0)) kw_args--;
8188         else {
8189           __Pyx_RaiseArgtupleInvalid("dense_add_mult", 1, 3, 3, 1); __PYX_ERR(1, 87, __pyx_L3_error)
8190         }
8191         CYTHON_FALLTHROUGH;
8192         case  2:
8193         if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_alpha)) != 0)) kw_args--;
8194         else {
8195           __Pyx_RaiseArgtupleInvalid("dense_add_mult", 1, 3, 3, 2); __PYX_ERR(1, 87, __pyx_L3_error)
8196         }
8197       }
8198       if (unlikely(kw_args > 0)) {
8199         if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "dense_add_mult") < 0)) __PYX_ERR(1, 87, __pyx_L3_error)
8200       }
8201     } else if (PyTuple_GET_SIZE(__pyx_args) != 3) {
8202       goto __pyx_L5_argtuple_error;
8203     } else {
8204       values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
8205       values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
8206       values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
8207     }
8208     __pyx_v_A = __Pyx_PyObject_to_MemoryviewSlice_dcd____pyx_t_double_complex(values[0], PyBUF_WRITABLE); if (unlikely(!__pyx_v_A.memview)) __PYX_ERR(1, 87, __pyx_L3_error)
8209     __pyx_v_B = __Pyx_PyObject_to_MemoryviewSlice_dcd____pyx_t_double_complex(values[1], PyBUF_WRITABLE); if (unlikely(!__pyx_v_B.memview)) __PYX_ERR(1, 88, __pyx_L3_error)
8210     __pyx_v_alpha = __Pyx_PyComplex_As___pyx_t_double_complex(values[2]); if (unlikely(PyErr_Occurred())) __PYX_ERR(1, 89, __pyx_L3_error)
8211   }
8212   goto __pyx_L4_argument_unpacking_done;
8213   __pyx_L5_argtuple_error:;
8214   __Pyx_RaiseArgtupleInvalid("dense_add_mult", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(1, 87, __pyx_L3_error)
8215   __pyx_L3_error:;
8216   __Pyx_AddTraceback("qutip.cy.brtools.dense_add_mult", __pyx_clineno, __pyx_lineno, __pyx_filename);
8217   __Pyx_RefNannyFinishContext();
8218   return NULL;
8219   __pyx_L4_argument_unpacking_done:;
8220   __pyx_r = __pyx_pf_5qutip_2cy_7brtools_dense_add_mult(__pyx_self, __pyx_v_A, __pyx_v_B, __pyx_v_alpha);
8221 
8222   /* function exit code */
8223   __Pyx_RefNannyFinishContext();
8224   return __pyx_r;
8225 }
8226 
__pyx_pf_5qutip_2cy_7brtools_dense_add_mult(CYTHON_UNUSED PyObject * __pyx_self,__Pyx_memviewslice __pyx_v_A,__Pyx_memviewslice __pyx_v_B,__pyx_t_double_complex __pyx_v_alpha)8227 static PyObject *__pyx_pf_5qutip_2cy_7brtools_dense_add_mult(CYTHON_UNUSED PyObject *__pyx_self, __Pyx_memviewslice __pyx_v_A, __Pyx_memviewslice __pyx_v_B, __pyx_t_double_complex __pyx_v_alpha) {
8228   PyObject *__pyx_r = NULL;
8229   __Pyx_RefNannyDeclarations
8230   PyObject *__pyx_t_1 = NULL;
8231   int __pyx_lineno = 0;
8232   const char *__pyx_filename = NULL;
8233   int __pyx_clineno = 0;
8234   __Pyx_RefNannySetupContext("dense_add_mult", 0);
8235   __Pyx_XDECREF(__pyx_r);
8236   if (unlikely(!__pyx_v_A.memview)) { __Pyx_RaiseUnboundLocalError("A"); __PYX_ERR(1, 87, __pyx_L1_error) }
8237   if (unlikely(!__pyx_v_B.memview)) { __Pyx_RaiseUnboundLocalError("B"); __PYX_ERR(1, 87, __pyx_L1_error) }
8238   __pyx_t_1 = __Pyx_void_to_None(__pyx_f_5qutip_2cy_7brtools_dense_add_mult(__pyx_v_A, __pyx_v_B, __pyx_v_alpha, 0)); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 87, __pyx_L1_error)
8239   __Pyx_GOTREF(__pyx_t_1);
8240   __pyx_r = __pyx_t_1;
8241   __pyx_t_1 = 0;
8242   goto __pyx_L0;
8243 
8244   /* function exit code */
8245   __pyx_L1_error:;
8246   __Pyx_XDECREF(__pyx_t_1);
8247   __Pyx_AddTraceback("qutip.cy.brtools.dense_add_mult", __pyx_clineno, __pyx_lineno, __pyx_filename);
8248   __pyx_r = NULL;
8249   __pyx_L0:;
8250   __PYX_XDEC_MEMVIEW(&__pyx_v_A, 1);
8251   __PYX_XDEC_MEMVIEW(&__pyx_v_B, 1);
8252   __Pyx_XGIVEREF(__pyx_r);
8253   __Pyx_RefNannyFinishContext();
8254   return __pyx_r;
8255 }
8256 
8257 /* "qutip/cy/brtools.pyx":112
8258  * @cython.boundscheck(False)
8259  * @cython.wraparound(False)
8260  * cdef void ZHEEVR(complex[::1,:] H, double * eigvals,             # <<<<<<<<<<<<<<
8261  *                     complex[::1,:] Z, int nrows):
8262  *     """
8263  */
8264 
__pyx_f_5qutip_2cy_7brtools_ZHEEVR(__Pyx_memviewslice __pyx_v_H,double * __pyx_v_eigvals,__Pyx_memviewslice __pyx_v_Z,int __pyx_v_nrows)8265 static void __pyx_f_5qutip_2cy_7brtools_ZHEEVR(__Pyx_memviewslice __pyx_v_H, double *__pyx_v_eigvals, __Pyx_memviewslice __pyx_v_Z, int __pyx_v_nrows) {
8266   char __pyx_v_jobz;
8267   char __pyx_v_rnge;
8268   char __pyx_v_uplo;
8269   double __pyx_v_vl;
8270   double __pyx_v_vu;
8271   double __pyx_v_abstol;
8272   int __pyx_v_il;
8273   int __pyx_v_iu;
8274   int __pyx_v_lwork;
8275   int __pyx_v_lrwork;
8276   int __pyx_v_liwork;
8277   int __pyx_v_info;
8278   int __pyx_v_M;
8279   int *__pyx_v_isuppz;
8280   __pyx_t_double_complex *__pyx_v_work;
8281   double *__pyx_v_rwork;
8282   int *__pyx_v_iwork;
8283   __Pyx_RefNannyDeclarations
8284   int __pyx_t_1;
8285   Py_ssize_t __pyx_t_2;
8286   Py_ssize_t __pyx_t_3;
8287   Py_ssize_t __pyx_t_4;
8288   Py_ssize_t __pyx_t_5;
8289   int __pyx_t_6;
8290   PyObject *__pyx_t_7 = NULL;
8291   PyObject *__pyx_t_8 = NULL;
8292   int __pyx_lineno = 0;
8293   const char *__pyx_filename = NULL;
8294   int __pyx_clineno = 0;
8295   __Pyx_RefNannySetupContext("ZHEEVR", 0);
8296 
8297   /* "qutip/cy/brtools.pyx":129
8298  *         Number of rows in matrix.
8299  *     """
8300  *     if use_zgeev:             # <<<<<<<<<<<<<<
8301  *         ZGEEV(H, eigvals, Z, nrows)
8302  *         return
8303  */
8304   __pyx_t_1 = (__pyx_v_5qutip_2cy_7brtools_use_zgeev != 0);
8305   if (__pyx_t_1) {
8306 
8307     /* "qutip/cy/brtools.pyx":130
8308  *     """
8309  *     if use_zgeev:
8310  *         ZGEEV(H, eigvals, Z, nrows)             # <<<<<<<<<<<<<<
8311  *         return
8312  *     cdef char jobz = b'V'
8313  */
8314     __pyx_f_5qutip_2cy_7brtools_ZGEEV(__pyx_v_H, __pyx_v_eigvals, __pyx_v_Z, __pyx_v_nrows);
8315 
8316     /* "qutip/cy/brtools.pyx":131
8317  *     if use_zgeev:
8318  *         ZGEEV(H, eigvals, Z, nrows)
8319  *         return             # <<<<<<<<<<<<<<
8320  *     cdef char jobz = b'V'
8321  *     cdef char rnge = b'A'
8322  */
8323     goto __pyx_L0;
8324 
8325     /* "qutip/cy/brtools.pyx":129
8326  *         Number of rows in matrix.
8327  *     """
8328  *     if use_zgeev:             # <<<<<<<<<<<<<<
8329  *         ZGEEV(H, eigvals, Z, nrows)
8330  *         return
8331  */
8332   }
8333 
8334   /* "qutip/cy/brtools.pyx":132
8335  *         ZGEEV(H, eigvals, Z, nrows)
8336  *         return
8337  *     cdef char jobz = b'V'             # <<<<<<<<<<<<<<
8338  *     cdef char rnge = b'A'
8339  *     cdef char uplo = b'L'
8340  */
8341   __pyx_v_jobz = 'V';
8342 
8343   /* "qutip/cy/brtools.pyx":133
8344  *         return
8345  *     cdef char jobz = b'V'
8346  *     cdef char rnge = b'A'             # <<<<<<<<<<<<<<
8347  *     cdef char uplo = b'L'
8348  *     cdef double vl=1, vu=1, abstol=0
8349  */
8350   __pyx_v_rnge = 'A';
8351 
8352   /* "qutip/cy/brtools.pyx":134
8353  *     cdef char jobz = b'V'
8354  *     cdef char rnge = b'A'
8355  *     cdef char uplo = b'L'             # <<<<<<<<<<<<<<
8356  *     cdef double vl=1, vu=1, abstol=0
8357  *     cdef int il=1, iu=1
8358  */
8359   __pyx_v_uplo = 'L';
8360 
8361   /* "qutip/cy/brtools.pyx":135
8362  *     cdef char rnge = b'A'
8363  *     cdef char uplo = b'L'
8364  *     cdef double vl=1, vu=1, abstol=0             # <<<<<<<<<<<<<<
8365  *     cdef int il=1, iu=1
8366  *     cdef int lwork = 18 * nrows
8367  */
8368   __pyx_v_vl = 1.0;
8369   __pyx_v_vu = 1.0;
8370   __pyx_v_abstol = 0.0;
8371 
8372   /* "qutip/cy/brtools.pyx":136
8373  *     cdef char uplo = b'L'
8374  *     cdef double vl=1, vu=1, abstol=0
8375  *     cdef int il=1, iu=1             # <<<<<<<<<<<<<<
8376  *     cdef int lwork = 18 * nrows
8377  *     cdef int lrwork = 24*nrows, liwork = 10*nrows
8378  */
8379   __pyx_v_il = 1;
8380   __pyx_v_iu = 1;
8381 
8382   /* "qutip/cy/brtools.pyx":137
8383  *     cdef double vl=1, vu=1, abstol=0
8384  *     cdef int il=1, iu=1
8385  *     cdef int lwork = 18 * nrows             # <<<<<<<<<<<<<<
8386  *     cdef int lrwork = 24*nrows, liwork = 10*nrows
8387  *     cdef int info=0, M=0
8388  */
8389   __pyx_v_lwork = (18 * __pyx_v_nrows);
8390 
8391   /* "qutip/cy/brtools.pyx":138
8392  *     cdef int il=1, iu=1
8393  *     cdef int lwork = 18 * nrows
8394  *     cdef int lrwork = 24*nrows, liwork = 10*nrows             # <<<<<<<<<<<<<<
8395  *     cdef int info=0, M=0
8396  *     #These nee to be freed at end
8397  */
8398   __pyx_v_lrwork = (24 * __pyx_v_nrows);
8399   __pyx_v_liwork = (10 * __pyx_v_nrows);
8400 
8401   /* "qutip/cy/brtools.pyx":139
8402  *     cdef int lwork = 18 * nrows
8403  *     cdef int lrwork = 24*nrows, liwork = 10*nrows
8404  *     cdef int info=0, M=0             # <<<<<<<<<<<<<<
8405  *     #These nee to be freed at end
8406  *     cdef int * isuppz = <int *>PyDataMem_NEW((2*nrows) * sizeof(int))
8407  */
8408   __pyx_v_info = 0;
8409   __pyx_v_M = 0;
8410 
8411   /* "qutip/cy/brtools.pyx":141
8412  *     cdef int info=0, M=0
8413  *     #These nee to be freed at end
8414  *     cdef int * isuppz = <int *>PyDataMem_NEW((2*nrows) * sizeof(int))             # <<<<<<<<<<<<<<
8415  *     cdef complex * work = <complex *>PyDataMem_NEW(lwork * sizeof(complex))
8416  *     cdef double * rwork = <double *>PyDataMem_NEW((24*nrows) * sizeof(double))
8417  */
8418   __pyx_v_isuppz = ((int *)PyDataMem_NEW(((2 * __pyx_v_nrows) * (sizeof(int)))));
8419 
8420   /* "qutip/cy/brtools.pyx":142
8421  *     #These nee to be freed at end
8422  *     cdef int * isuppz = <int *>PyDataMem_NEW((2*nrows) * sizeof(int))
8423  *     cdef complex * work = <complex *>PyDataMem_NEW(lwork * sizeof(complex))             # <<<<<<<<<<<<<<
8424  *     cdef double * rwork = <double *>PyDataMem_NEW((24*nrows) * sizeof(double))
8425  *     cdef int * iwork = <int *>PyDataMem_NEW((10*nrows) * sizeof(int))
8426  */
8427   __pyx_v_work = ((__pyx_t_double_complex *)PyDataMem_NEW((__pyx_v_lwork * (sizeof(__pyx_t_double_complex)))));
8428 
8429   /* "qutip/cy/brtools.pyx":143
8430  *     cdef int * isuppz = <int *>PyDataMem_NEW((2*nrows) * sizeof(int))
8431  *     cdef complex * work = <complex *>PyDataMem_NEW(lwork * sizeof(complex))
8432  *     cdef double * rwork = <double *>PyDataMem_NEW((24*nrows) * sizeof(double))             # <<<<<<<<<<<<<<
8433  *     cdef int * iwork = <int *>PyDataMem_NEW((10*nrows) * sizeof(int))
8434  *
8435  */
8436   __pyx_v_rwork = ((double *)PyDataMem_NEW(((24 * __pyx_v_nrows) * (sizeof(double)))));
8437 
8438   /* "qutip/cy/brtools.pyx":144
8439  *     cdef complex * work = <complex *>PyDataMem_NEW(lwork * sizeof(complex))
8440  *     cdef double * rwork = <double *>PyDataMem_NEW((24*nrows) * sizeof(double))
8441  *     cdef int * iwork = <int *>PyDataMem_NEW((10*nrows) * sizeof(int))             # <<<<<<<<<<<<<<
8442  *
8443  *     zheevr(&jobz, &rnge, &uplo, &nrows, &H[0,0], &nrows, &vl, &vu, &il, &iu, &abstol,
8444  */
8445   __pyx_v_iwork = ((int *)PyDataMem_NEW(((10 * __pyx_v_nrows) * (sizeof(int)))));
8446 
8447   /* "qutip/cy/brtools.pyx":146
8448  *     cdef int * iwork = <int *>PyDataMem_NEW((10*nrows) * sizeof(int))
8449  *
8450  *     zheevr(&jobz, &rnge, &uplo, &nrows, &H[0,0], &nrows, &vl, &vu, &il, &iu, &abstol,             # <<<<<<<<<<<<<<
8451  *            &M, eigvals, &Z[0,0], &nrows, isuppz, work, &lwork,
8452  *           rwork, &lrwork, iwork, &liwork, &info)
8453  */
8454   __pyx_t_2 = 0;
8455   __pyx_t_3 = 0;
8456 
8457   /* "qutip/cy/brtools.pyx":147
8458  *
8459  *     zheevr(&jobz, &rnge, &uplo, &nrows, &H[0,0], &nrows, &vl, &vu, &il, &iu, &abstol,
8460  *            &M, eigvals, &Z[0,0], &nrows, isuppz, work, &lwork,             # <<<<<<<<<<<<<<
8461  *           rwork, &lrwork, iwork, &liwork, &info)
8462  *     PyDataMem_FREE(work)
8463  */
8464   __pyx_t_4 = 0;
8465   __pyx_t_5 = 0;
8466 
8467   /* "qutip/cy/brtools.pyx":146
8468  *     cdef int * iwork = <int *>PyDataMem_NEW((10*nrows) * sizeof(int))
8469  *
8470  *     zheevr(&jobz, &rnge, &uplo, &nrows, &H[0,0], &nrows, &vl, &vu, &il, &iu, &abstol,             # <<<<<<<<<<<<<<
8471  *            &M, eigvals, &Z[0,0], &nrows, isuppz, work, &lwork,
8472  *           rwork, &lrwork, iwork, &liwork, &info)
8473  */
8474   __pyx_f_5scipy_6linalg_13cython_lapack_zheevr((&__pyx_v_jobz), (&__pyx_v_rnge), (&__pyx_v_uplo), (&__pyx_v_nrows), (&(*((__pyx_t_double_complex *) ( /* dim=1 */ (( /* dim=0 */ ((char *) (((__pyx_t_double_complex *) __pyx_v_H.data) + __pyx_t_2)) ) + __pyx_t_3 * __pyx_v_H.strides[1]) )))), (&__pyx_v_nrows), (&__pyx_v_vl), (&__pyx_v_vu), (&__pyx_v_il), (&__pyx_v_iu), (&__pyx_v_abstol), (&__pyx_v_M), __pyx_v_eigvals, (&(*((__pyx_t_double_complex *) ( /* dim=1 */ (( /* dim=0 */ ((char *) (((__pyx_t_double_complex *) __pyx_v_Z.data) + __pyx_t_4)) ) + __pyx_t_5 * __pyx_v_Z.strides[1]) )))), (&__pyx_v_nrows), __pyx_v_isuppz, __pyx_v_work, (&__pyx_v_lwork), __pyx_v_rwork, (&__pyx_v_lrwork), __pyx_v_iwork, (&__pyx_v_liwork), (&__pyx_v_info));
8475 
8476   /* "qutip/cy/brtools.pyx":149
8477  *            &M, eigvals, &Z[0,0], &nrows, isuppz, work, &lwork,
8478  *           rwork, &lrwork, iwork, &liwork, &info)
8479  *     PyDataMem_FREE(work)             # <<<<<<<<<<<<<<
8480  *     PyDataMem_FREE(rwork)
8481  *     PyDataMem_FREE(isuppz)
8482  */
8483   PyDataMem_FREE(__pyx_v_work);
8484 
8485   /* "qutip/cy/brtools.pyx":150
8486  *           rwork, &lrwork, iwork, &liwork, &info)
8487  *     PyDataMem_FREE(work)
8488  *     PyDataMem_FREE(rwork)             # <<<<<<<<<<<<<<
8489  *     PyDataMem_FREE(isuppz)
8490  *     PyDataMem_FREE(iwork)
8491  */
8492   PyDataMem_FREE(__pyx_v_rwork);
8493 
8494   /* "qutip/cy/brtools.pyx":151
8495  *     PyDataMem_FREE(work)
8496  *     PyDataMem_FREE(rwork)
8497  *     PyDataMem_FREE(isuppz)             # <<<<<<<<<<<<<<
8498  *     PyDataMem_FREE(iwork)
8499  *     if info != 0:
8500  */
8501   PyDataMem_FREE(__pyx_v_isuppz);
8502 
8503   /* "qutip/cy/brtools.pyx":152
8504  *     PyDataMem_FREE(rwork)
8505  *     PyDataMem_FREE(isuppz)
8506  *     PyDataMem_FREE(iwork)             # <<<<<<<<<<<<<<
8507  *     if info != 0:
8508  *         if info < 0:
8509  */
8510   PyDataMem_FREE(__pyx_v_iwork);
8511 
8512   /* "qutip/cy/brtools.pyx":153
8513  *     PyDataMem_FREE(isuppz)
8514  *     PyDataMem_FREE(iwork)
8515  *     if info != 0:             # <<<<<<<<<<<<<<
8516  *         if info < 0:
8517  *             raise Exception("Error in parameter : %s" & abs(info))
8518  */
8519   __pyx_t_1 = ((__pyx_v_info != 0) != 0);
8520   if (__pyx_t_1) {
8521 
8522     /* "qutip/cy/brtools.pyx":154
8523  *     PyDataMem_FREE(iwork)
8524  *     if info != 0:
8525  *         if info < 0:             # <<<<<<<<<<<<<<
8526  *             raise Exception("Error in parameter : %s" & abs(info))
8527  *         else:
8528  */
8529     __pyx_t_1 = ((__pyx_v_info < 0) != 0);
8530     if (unlikely(__pyx_t_1)) {
8531 
8532       /* "qutip/cy/brtools.pyx":155
8533  *     if info != 0:
8534  *         if info < 0:
8535  *             raise Exception("Error in parameter : %s" & abs(info))             # <<<<<<<<<<<<<<
8536  *         else:
8537  *             raise Exception("Algorithm failed to converge")
8538  */
8539       __pyx_t_6 = abs(__pyx_v_info); if (unlikely(__pyx_t_6 == ((int)-1))) __PYX_ERR(1, 155, __pyx_L1_error)
8540       __pyx_t_7 = __Pyx_PyInt_From_int(__pyx_t_6); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 155, __pyx_L1_error)
8541       __Pyx_GOTREF(__pyx_t_7);
8542       __pyx_t_8 = PyNumber_And(__pyx_kp_u_Error_in_parameter_s, __pyx_t_7); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 155, __pyx_L1_error)
8543       __Pyx_GOTREF(__pyx_t_8);
8544       __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
8545       __pyx_t_7 = __Pyx_PyObject_CallOneArg(((PyObject *)(&((PyTypeObject*)PyExc_Exception)[0])), __pyx_t_8); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 155, __pyx_L1_error)
8546       __Pyx_GOTREF(__pyx_t_7);
8547       __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
8548       __Pyx_Raise(__pyx_t_7, 0, 0, 0);
8549       __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
8550       __PYX_ERR(1, 155, __pyx_L1_error)
8551 
8552       /* "qutip/cy/brtools.pyx":154
8553  *     PyDataMem_FREE(iwork)
8554  *     if info != 0:
8555  *         if info < 0:             # <<<<<<<<<<<<<<
8556  *             raise Exception("Error in parameter : %s" & abs(info))
8557  *         else:
8558  */
8559     }
8560 
8561     /* "qutip/cy/brtools.pyx":157
8562  *             raise Exception("Error in parameter : %s" & abs(info))
8563  *         else:
8564  *             raise Exception("Algorithm failed to converge")             # <<<<<<<<<<<<<<
8565  *
8566  *
8567  */
8568     /*else*/ {
8569       __pyx_t_7 = __Pyx_PyObject_Call(((PyObject *)(&((PyTypeObject*)PyExc_Exception)[0])), __pyx_tuple__12, NULL); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 157, __pyx_L1_error)
8570       __Pyx_GOTREF(__pyx_t_7);
8571       __Pyx_Raise(__pyx_t_7, 0, 0, 0);
8572       __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
8573       __PYX_ERR(1, 157, __pyx_L1_error)
8574     }
8575 
8576     /* "qutip/cy/brtools.pyx":153
8577  *     PyDataMem_FREE(isuppz)
8578  *     PyDataMem_FREE(iwork)
8579  *     if info != 0:             # <<<<<<<<<<<<<<
8580  *         if info < 0:
8581  *             raise Exception("Error in parameter : %s" & abs(info))
8582  */
8583   }
8584 
8585   /* "qutip/cy/brtools.pyx":112
8586  * @cython.boundscheck(False)
8587  * @cython.wraparound(False)
8588  * cdef void ZHEEVR(complex[::1,:] H, double * eigvals,             # <<<<<<<<<<<<<<
8589  *                     complex[::1,:] Z, int nrows):
8590  *     """
8591  */
8592 
8593   /* function exit code */
8594   goto __pyx_L0;
8595   __pyx_L1_error:;
8596   __Pyx_XDECREF(__pyx_t_7);
8597   __Pyx_XDECREF(__pyx_t_8);
8598   __Pyx_WriteUnraisable("qutip.cy.brtools.ZHEEVR", __pyx_clineno, __pyx_lineno, __pyx_filename, 1, 0);
8599   __pyx_L0:;
8600   __Pyx_RefNannyFinishContext();
8601 }
8602 
8603 /* "qutip/cy/brtools.pyx":162
8604  * @cython.boundscheck(False)
8605  * @cython.wraparound(False)
8606  * cdef void ZGEEV(complex[::1,:] H, double * eigvals,             # <<<<<<<<<<<<<<
8607  *                 complex[::1,:] Z, int nrows):
8608  *     """
8609  */
8610 
__pyx_f_5qutip_2cy_7brtools_ZGEEV(__Pyx_memviewslice __pyx_v_H,double * __pyx_v_eigvals,__Pyx_memviewslice __pyx_v_Z,int __pyx_v_nrows)8611 static void __pyx_f_5qutip_2cy_7brtools_ZGEEV(__Pyx_memviewslice __pyx_v_H, double *__pyx_v_eigvals, __Pyx_memviewslice __pyx_v_Z, int __pyx_v_nrows) {
8612   char __pyx_v_jobvl;
8613   char __pyx_v_jobvr;
8614   int __pyx_v_i;
8615   int __pyx_v_j;
8616   int __pyx_v_k;
8617   int __pyx_v_lwork;
8618   int __pyx_v_same_eigv;
8619   __pyx_t_double_complex __pyx_v_dot;
8620   __pyx_t_double_complex __pyx_v_wkopt;
8621   int __pyx_v_info;
8622   __pyx_t_double_complex *__pyx_v_work;
8623   __pyx_t_double_complex *__pyx_v_eival;
8624   __pyx_t_double_complex *__pyx_v_vl;
8625   __pyx_t_double_complex *__pyx_v_vr;
8626   double *__pyx_v_rwork;
8627   __Pyx_memviewslice __pyx_v_idx = { 0, 0, { 0 }, { 0 }, { 0 } };
8628   __Pyx_RefNannyDeclarations
8629   Py_ssize_t __pyx_t_1;
8630   Py_ssize_t __pyx_t_2;
8631   int __pyx_t_3;
8632   int __pyx_t_4;
8633   int __pyx_t_5;
8634   PyObject *__pyx_t_6 = NULL;
8635   PyObject *__pyx_t_7 = NULL;
8636   PyObject *__pyx_t_8 = NULL;
8637   PyObject *__pyx_t_9 = NULL;
8638   PyObject *__pyx_t_10 = NULL;
8639   struct __pyx_array_obj *__pyx_t_11 = NULL;
8640   PyObject *__pyx_t_12 = NULL;
8641   __Pyx_memviewslice __pyx_t_13 = { 0, 0, { 0 }, { 0 }, { 0 } };
8642   int __pyx_t_14;
8643   int __pyx_t_15;
8644   int __pyx_t_16;
8645   Py_ssize_t __pyx_t_17;
8646   int __pyx_t_18;
8647   int __pyx_t_19;
8648   int __pyx_t_20;
8649   int __pyx_t_21;
8650   Py_ssize_t __pyx_t_22;
8651   int __pyx_lineno = 0;
8652   const char *__pyx_filename = NULL;
8653   int __pyx_clineno = 0;
8654   __Pyx_RefNannySetupContext("ZGEEV", 0);
8655 
8656   /* "qutip/cy/brtools.pyx":179
8657  *         Number of rows in matrix.
8658  *     """
8659  *     cdef char jobvl = b'N'             # <<<<<<<<<<<<<<
8660  *     cdef char jobvr = b'V'
8661  *     cdef int i, j, k, lwork = -1
8662  */
8663   __pyx_v_jobvl = 'N';
8664 
8665   /* "qutip/cy/brtools.pyx":180
8666  *     """
8667  *     cdef char jobvl = b'N'
8668  *     cdef char jobvr = b'V'             # <<<<<<<<<<<<<<
8669  *     cdef int i, j, k, lwork = -1
8670  *     cdef int same_eigv = 0
8671  */
8672   __pyx_v_jobvr = 'V';
8673 
8674   /* "qutip/cy/brtools.pyx":181
8675  *     cdef char jobvl = b'N'
8676  *     cdef char jobvr = b'V'
8677  *     cdef int i, j, k, lwork = -1             # <<<<<<<<<<<<<<
8678  *     cdef int same_eigv = 0
8679  *     cdef complex dot
8680  */
8681   __pyx_v_lwork = -1;
8682 
8683   /* "qutip/cy/brtools.pyx":182
8684  *     cdef char jobvr = b'V'
8685  *     cdef int i, j, k, lwork = -1
8686  *     cdef int same_eigv = 0             # <<<<<<<<<<<<<<
8687  *     cdef complex dot
8688  *     cdef complex wkopt
8689  */
8690   __pyx_v_same_eigv = 0;
8691 
8692   /* "qutip/cy/brtools.pyx":185
8693  *     cdef complex dot
8694  *     cdef complex wkopt
8695  *     cdef int info=0             # <<<<<<<<<<<<<<
8696  *     cdef complex * work
8697  *
8698  */
8699   __pyx_v_info = 0;
8700 
8701   /* "qutip/cy/brtools.pyx":189
8702  *
8703  *     #These need to be freed at end
8704  *     cdef complex * eival = <complex *>PyDataMem_NEW(nrows * sizeof(complex))             # <<<<<<<<<<<<<<
8705  *     cdef complex * vl = <complex *>PyDataMem_NEW(nrows * nrows *
8706  *                                                  sizeof(complex))
8707  */
8708   __pyx_v_eival = ((__pyx_t_double_complex *)PyDataMem_NEW((__pyx_v_nrows * (sizeof(__pyx_t_double_complex)))));
8709 
8710   /* "qutip/cy/brtools.pyx":190
8711  *     #These need to be freed at end
8712  *     cdef complex * eival = <complex *>PyDataMem_NEW(nrows * sizeof(complex))
8713  *     cdef complex * vl = <complex *>PyDataMem_NEW(nrows * nrows *             # <<<<<<<<<<<<<<
8714  *                                                  sizeof(complex))
8715  *     cdef complex * vr = <complex *>PyDataMem_NEW(nrows * nrows *
8716  */
8717   __pyx_v_vl = ((__pyx_t_double_complex *)PyDataMem_NEW(((__pyx_v_nrows * __pyx_v_nrows) * (sizeof(__pyx_t_double_complex)))));
8718 
8719   /* "qutip/cy/brtools.pyx":192
8720  *     cdef complex * vl = <complex *>PyDataMem_NEW(nrows * nrows *
8721  *                                                  sizeof(complex))
8722  *     cdef complex * vr = <complex *>PyDataMem_NEW(nrows * nrows *             # <<<<<<<<<<<<<<
8723  *                                                  sizeof(complex))
8724  *     cdef double * rwork = <double *>PyDataMem_NEW((2*nrows) * sizeof(double))
8725  */
8726   __pyx_v_vr = ((__pyx_t_double_complex *)PyDataMem_NEW(((__pyx_v_nrows * __pyx_v_nrows) * (sizeof(__pyx_t_double_complex)))));
8727 
8728   /* "qutip/cy/brtools.pyx":194
8729  *     cdef complex * vr = <complex *>PyDataMem_NEW(nrows * nrows *
8730  *                                                  sizeof(complex))
8731  *     cdef double * rwork = <double *>PyDataMem_NEW((2*nrows) * sizeof(double))             # <<<<<<<<<<<<<<
8732  *
8733  *     # First call to get lwork
8734  */
8735   __pyx_v_rwork = ((double *)PyDataMem_NEW(((2 * __pyx_v_nrows) * (sizeof(double)))));
8736 
8737   /* "qutip/cy/brtools.pyx":197
8738  *
8739  *     # First call to get lwork
8740  *     zgeev(&jobvl, &jobvr, &nrows, &H[0,0], &nrows,             # <<<<<<<<<<<<<<
8741  *           eival, vl, &nrows, vr, &nrows,
8742  *           &wkopt, &lwork, rwork, &info)
8743  */
8744   __pyx_t_1 = 0;
8745   __pyx_t_2 = 0;
8746 
8747   /* "qutip/cy/brtools.pyx":199
8748  *     zgeev(&jobvl, &jobvr, &nrows, &H[0,0], &nrows,
8749  *           eival, vl, &nrows, vr, &nrows,
8750  *           &wkopt, &lwork, rwork, &info)             # <<<<<<<<<<<<<<
8751  *     lwork = int(real(wkopt))
8752  *     work = <complex *>PyDataMem_NEW(lwork * sizeof(complex))
8753  */
8754   __pyx_f_5scipy_6linalg_13cython_lapack_zgeev((&__pyx_v_jobvl), (&__pyx_v_jobvr), (&__pyx_v_nrows), (&(*((__pyx_t_double_complex *) ( /* dim=1 */ (( /* dim=0 */ ((char *) (((__pyx_t_double_complex *) __pyx_v_H.data) + __pyx_t_1)) ) + __pyx_t_2 * __pyx_v_H.strides[1]) )))), (&__pyx_v_nrows), __pyx_v_eival, __pyx_v_vl, (&__pyx_v_nrows), __pyx_v_vr, (&__pyx_v_nrows), (&__pyx_v_wkopt), (&__pyx_v_lwork), __pyx_v_rwork, (&__pyx_v_info));
8755 
8756   /* "qutip/cy/brtools.pyx":200
8757  *           eival, vl, &nrows, vr, &nrows,
8758  *           &wkopt, &lwork, rwork, &info)
8759  *     lwork = int(real(wkopt))             # <<<<<<<<<<<<<<
8760  *     work = <complex *>PyDataMem_NEW(lwork * sizeof(complex))
8761  *     # Solving
8762  */
8763   __pyx_v_lwork = ((int)std::real(__pyx_v_wkopt));
8764 
8765   /* "qutip/cy/brtools.pyx":201
8766  *           &wkopt, &lwork, rwork, &info)
8767  *     lwork = int(real(wkopt))
8768  *     work = <complex *>PyDataMem_NEW(lwork * sizeof(complex))             # <<<<<<<<<<<<<<
8769  *     # Solving
8770  *     zgeev(&jobvl, &jobvr, &nrows, &H[0,0], &nrows,
8771  */
8772   __pyx_v_work = ((__pyx_t_double_complex *)PyDataMem_NEW((__pyx_v_lwork * (sizeof(__pyx_t_double_complex)))));
8773 
8774   /* "qutip/cy/brtools.pyx":203
8775  *     work = <complex *>PyDataMem_NEW(lwork * sizeof(complex))
8776  *     # Solving
8777  *     zgeev(&jobvl, &jobvr, &nrows, &H[0,0], &nrows,             # <<<<<<<<<<<<<<
8778  *           eival, vl, &nrows, vr, &nrows, #&Z[0,0],
8779  *           work, &lwork, rwork, &info)
8780  */
8781   __pyx_t_2 = 0;
8782   __pyx_t_1 = 0;
8783 
8784   /* "qutip/cy/brtools.pyx":205
8785  *     zgeev(&jobvl, &jobvr, &nrows, &H[0,0], &nrows,
8786  *           eival, vl, &nrows, vr, &nrows, #&Z[0,0],
8787  *           work, &lwork, rwork, &info)             # <<<<<<<<<<<<<<
8788  *     for i in range(nrows):
8789  *         eigvals[i] = real(eival[i])
8790  */
8791   __pyx_f_5scipy_6linalg_13cython_lapack_zgeev((&__pyx_v_jobvl), (&__pyx_v_jobvr), (&__pyx_v_nrows), (&(*((__pyx_t_double_complex *) ( /* dim=1 */ (( /* dim=0 */ ((char *) (((__pyx_t_double_complex *) __pyx_v_H.data) + __pyx_t_2)) ) + __pyx_t_1 * __pyx_v_H.strides[1]) )))), (&__pyx_v_nrows), __pyx_v_eival, __pyx_v_vl, (&__pyx_v_nrows), __pyx_v_vr, (&__pyx_v_nrows), __pyx_v_work, (&__pyx_v_lwork), __pyx_v_rwork, (&__pyx_v_info));
8792 
8793   /* "qutip/cy/brtools.pyx":206
8794  *           eival, vl, &nrows, vr, &nrows, #&Z[0,0],
8795  *           work, &lwork, rwork, &info)
8796  *     for i in range(nrows):             # <<<<<<<<<<<<<<
8797  *         eigvals[i] = real(eival[i])
8798  *     # After using lapack, numpy...
8799  */
8800   __pyx_t_3 = __pyx_v_nrows;
8801   __pyx_t_4 = __pyx_t_3;
8802   for (__pyx_t_5 = 0; __pyx_t_5 < __pyx_t_4; __pyx_t_5+=1) {
8803     __pyx_v_i = __pyx_t_5;
8804 
8805     /* "qutip/cy/brtools.pyx":207
8806  *           work, &lwork, rwork, &info)
8807  *     for i in range(nrows):
8808  *         eigvals[i] = real(eival[i])             # <<<<<<<<<<<<<<
8809  *     # After using lapack, numpy...
8810  *     # lapack does not seems to have sorting function
8811  */
8812     (__pyx_v_eigvals[__pyx_v_i]) = std::real((__pyx_v_eival[__pyx_v_i]));
8813   }
8814 
8815   /* "qutip/cy/brtools.pyx":211
8816  *     # lapack does not seems to have sorting function
8817  *     # zheevr sort but not zgeev
8818  *     cdef long[:] idx = np.argsort(np.array(<double[:nrows]> eigvals))             # <<<<<<<<<<<<<<
8819  *     for i in range(nrows):
8820  *         eigvals[i] = real(eival[idx[i]])
8821  */
8822   __Pyx_GetModuleGlobalName(__pyx_t_7, __pyx_n_s_np); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 211, __pyx_L1_error)
8823   __Pyx_GOTREF(__pyx_t_7);
8824   __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_n_s_argsort); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 211, __pyx_L1_error)
8825   __Pyx_GOTREF(__pyx_t_8);
8826   __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
8827   __Pyx_GetModuleGlobalName(__pyx_t_9, __pyx_n_s_np); if (unlikely(!__pyx_t_9)) __PYX_ERR(1, 211, __pyx_L1_error)
8828   __Pyx_GOTREF(__pyx_t_9);
8829   __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_t_9, __pyx_n_s_array); if (unlikely(!__pyx_t_10)) __PYX_ERR(1, 211, __pyx_L1_error)
8830   __Pyx_GOTREF(__pyx_t_10);
8831   __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
8832   if (!__pyx_v_eigvals) {
8833     PyErr_SetString(PyExc_ValueError,"Cannot create cython.array from NULL pointer");
8834     __PYX_ERR(1, 211, __pyx_L1_error)
8835   }
8836   __pyx_t_12 = __pyx_format_from_typeinfo(&__Pyx_TypeInfo_double); if (unlikely(!__pyx_t_12)) __PYX_ERR(1, 211, __pyx_L1_error)
8837   __Pyx_GOTREF(__pyx_t_12);
8838   __pyx_t_9 = Py_BuildValue((char*) "("  __PYX_BUILD_PY_SSIZE_T  ")", ((Py_ssize_t)__pyx_v_nrows)); if (unlikely(!__pyx_t_9)) __PYX_ERR(1, 211, __pyx_L1_error)
8839   __Pyx_GOTREF(__pyx_t_9);
8840   __pyx_t_11 = __pyx_array_new(__pyx_t_9, sizeof(double), PyBytes_AS_STRING(__pyx_t_12), (char *) "c", (char *) __pyx_v_eigvals);
8841   if (unlikely(!__pyx_t_11)) __PYX_ERR(1, 211, __pyx_L1_error)
8842   __Pyx_GOTREF(__pyx_t_11);
8843   __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
8844   __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
8845   __pyx_t_12 = NULL;
8846   if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_10))) {
8847     __pyx_t_12 = PyMethod_GET_SELF(__pyx_t_10);
8848     if (likely(__pyx_t_12)) {
8849       PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_10);
8850       __Pyx_INCREF(__pyx_t_12);
8851       __Pyx_INCREF(function);
8852       __Pyx_DECREF_SET(__pyx_t_10, function);
8853     }
8854   }
8855   __pyx_t_7 = (__pyx_t_12) ? __Pyx_PyObject_Call2Args(__pyx_t_10, __pyx_t_12, ((PyObject *)__pyx_t_11)) : __Pyx_PyObject_CallOneArg(__pyx_t_10, ((PyObject *)__pyx_t_11));
8856   __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
8857   __Pyx_DECREF(((PyObject *)__pyx_t_11)); __pyx_t_11 = 0;
8858   if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 211, __pyx_L1_error)
8859   __Pyx_GOTREF(__pyx_t_7);
8860   __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
8861   __pyx_t_10 = NULL;
8862   if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_8))) {
8863     __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_8);
8864     if (likely(__pyx_t_10)) {
8865       PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_8);
8866       __Pyx_INCREF(__pyx_t_10);
8867       __Pyx_INCREF(function);
8868       __Pyx_DECREF_SET(__pyx_t_8, function);
8869     }
8870   }
8871   __pyx_t_6 = (__pyx_t_10) ? __Pyx_PyObject_Call2Args(__pyx_t_8, __pyx_t_10, __pyx_t_7) : __Pyx_PyObject_CallOneArg(__pyx_t_8, __pyx_t_7);
8872   __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
8873   __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
8874   if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 211, __pyx_L1_error)
8875   __Pyx_GOTREF(__pyx_t_6);
8876   __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
8877   __pyx_t_13 = __Pyx_PyObject_to_MemoryviewSlice_ds_long(__pyx_t_6, PyBUF_WRITABLE); if (unlikely(!__pyx_t_13.memview)) __PYX_ERR(1, 211, __pyx_L1_error)
8878   __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
8879   __pyx_v_idx = __pyx_t_13;
8880   __pyx_t_13.memview = NULL;
8881   __pyx_t_13.data = NULL;
8882 
8883   /* "qutip/cy/brtools.pyx":212
8884  *     # zheevr sort but not zgeev
8885  *     cdef long[:] idx = np.argsort(np.array(<double[:nrows]> eigvals))
8886  *     for i in range(nrows):             # <<<<<<<<<<<<<<
8887  *         eigvals[i] = real(eival[idx[i]])
8888  *         for j in range(nrows):
8889  */
8890   __pyx_t_3 = __pyx_v_nrows;
8891   __pyx_t_4 = __pyx_t_3;
8892   for (__pyx_t_5 = 0; __pyx_t_5 < __pyx_t_4; __pyx_t_5+=1) {
8893     __pyx_v_i = __pyx_t_5;
8894 
8895     /* "qutip/cy/brtools.pyx":213
8896  *     cdef long[:] idx = np.argsort(np.array(<double[:nrows]> eigvals))
8897  *     for i in range(nrows):
8898  *         eigvals[i] = real(eival[idx[i]])             # <<<<<<<<<<<<<<
8899  *         for j in range(nrows):
8900  *             Z[j,i] = vr[j + idx[i]*nrows]
8901  */
8902     __pyx_t_1 = __pyx_v_i;
8903     (__pyx_v_eigvals[__pyx_v_i]) = std::real((__pyx_v_eival[(*((long *) ( /* dim=0 */ (__pyx_v_idx.data + __pyx_t_1 * __pyx_v_idx.strides[0]) )))]));
8904 
8905     /* "qutip/cy/brtools.pyx":214
8906  *     for i in range(nrows):
8907  *         eigvals[i] = real(eival[idx[i]])
8908  *         for j in range(nrows):             # <<<<<<<<<<<<<<
8909  *             Z[j,i] = vr[j + idx[i]*nrows]
8910  *
8911  */
8912     __pyx_t_14 = __pyx_v_nrows;
8913     __pyx_t_15 = __pyx_t_14;
8914     for (__pyx_t_16 = 0; __pyx_t_16 < __pyx_t_15; __pyx_t_16+=1) {
8915       __pyx_v_j = __pyx_t_16;
8916 
8917       /* "qutip/cy/brtools.pyx":215
8918  *         eigvals[i] = real(eival[idx[i]])
8919  *         for j in range(nrows):
8920  *             Z[j,i] = vr[j + idx[i]*nrows]             # <<<<<<<<<<<<<<
8921  *
8922  *     for i in range(1, nrows):
8923  */
8924       __pyx_t_1 = __pyx_v_i;
8925       __pyx_t_2 = __pyx_v_j;
8926       __pyx_t_17 = __pyx_v_i;
8927       *((__pyx_t_double_complex *) ( /* dim=1 */ (( /* dim=0 */ ((char *) (((__pyx_t_double_complex *) __pyx_v_Z.data) + __pyx_t_2)) ) + __pyx_t_17 * __pyx_v_Z.strides[1]) )) = (__pyx_v_vr[(__pyx_v_j + ((*((long *) ( /* dim=0 */ (__pyx_v_idx.data + __pyx_t_1 * __pyx_v_idx.strides[0]) ))) * __pyx_v_nrows))]);
8928     }
8929   }
8930 
8931   /* "qutip/cy/brtools.pyx":217
8932  *             Z[j,i] = vr[j + idx[i]*nrows]
8933  *
8934  *     for i in range(1, nrows):             # <<<<<<<<<<<<<<
8935  *         if cabs(eigvals[i] - eigvals[i-1]) < 1e-12:
8936  *             same_eigv += 1
8937  */
8938   __pyx_t_3 = __pyx_v_nrows;
8939   __pyx_t_4 = __pyx_t_3;
8940   for (__pyx_t_5 = 1; __pyx_t_5 < __pyx_t_4; __pyx_t_5+=1) {
8941     __pyx_v_i = __pyx_t_5;
8942 
8943     /* "qutip/cy/brtools.pyx":218
8944  *
8945  *     for i in range(1, nrows):
8946  *         if cabs(eigvals[i] - eigvals[i-1]) < 1e-12:             # <<<<<<<<<<<<<<
8947  *             same_eigv += 1
8948  *             for j in range(same_eigv):
8949  */
8950     __pyx_t_18 = ((abs(__pyx_t_double_complex_from_parts(((__pyx_v_eigvals[__pyx_v_i]) - (__pyx_v_eigvals[(__pyx_v_i - 1)])), 0)) < 1e-12) != 0);
8951     if (__pyx_t_18) {
8952 
8953       /* "qutip/cy/brtools.pyx":219
8954  *     for i in range(1, nrows):
8955  *         if cabs(eigvals[i] - eigvals[i-1]) < 1e-12:
8956  *             same_eigv += 1             # <<<<<<<<<<<<<<
8957  *             for j in range(same_eigv):
8958  *                 dot = 0.
8959  */
8960       __pyx_v_same_eigv = (__pyx_v_same_eigv + 1);
8961 
8962       /* "qutip/cy/brtools.pyx":220
8963  *         if cabs(eigvals[i] - eigvals[i-1]) < 1e-12:
8964  *             same_eigv += 1
8965  *             for j in range(same_eigv):             # <<<<<<<<<<<<<<
8966  *                 dot = 0.
8967  *                 for k in range(nrows):
8968  */
8969       __pyx_t_14 = __pyx_v_same_eigv;
8970       __pyx_t_15 = __pyx_t_14;
8971       for (__pyx_t_16 = 0; __pyx_t_16 < __pyx_t_15; __pyx_t_16+=1) {
8972         __pyx_v_j = __pyx_t_16;
8973 
8974         /* "qutip/cy/brtools.pyx":221
8975  *             same_eigv += 1
8976  *             for j in range(same_eigv):
8977  *                 dot = 0.             # <<<<<<<<<<<<<<
8978  *                 for k in range(nrows):
8979  *                     dot += conj(Z[k,i-j-1]) * Z[k,i]
8980  */
8981         __pyx_v_dot = __pyx_t_double_complex_from_parts(0., 0);
8982 
8983         /* "qutip/cy/brtools.pyx":222
8984  *             for j in range(same_eigv):
8985  *                 dot = 0.
8986  *                 for k in range(nrows):             # <<<<<<<<<<<<<<
8987  *                     dot += conj(Z[k,i-j-1]) * Z[k,i]
8988  *                 for k in range(nrows):
8989  */
8990         __pyx_t_19 = __pyx_v_nrows;
8991         __pyx_t_20 = __pyx_t_19;
8992         for (__pyx_t_21 = 0; __pyx_t_21 < __pyx_t_20; __pyx_t_21+=1) {
8993           __pyx_v_k = __pyx_t_21;
8994 
8995           /* "qutip/cy/brtools.pyx":223
8996  *                 dot = 0.
8997  *                 for k in range(nrows):
8998  *                     dot += conj(Z[k,i-j-1]) * Z[k,i]             # <<<<<<<<<<<<<<
8999  *                 for k in range(nrows):
9000  *                     Z[k,i] -= Z[k,i-j-1] * dot
9001  */
9002           __pyx_t_1 = __pyx_v_k;
9003           __pyx_t_17 = ((__pyx_v_i - __pyx_v_j) - 1);
9004           __pyx_t_2 = __pyx_v_k;
9005           __pyx_t_22 = __pyx_v_i;
9006           __pyx_v_dot = __Pyx_c_sum_double(__pyx_v_dot, __Pyx_c_prod_double(std::conj((*((__pyx_t_double_complex *) ( /* dim=1 */ (( /* dim=0 */ ((char *) (((__pyx_t_double_complex *) __pyx_v_Z.data) + __pyx_t_1)) ) + __pyx_t_17 * __pyx_v_Z.strides[1]) )))), (*((__pyx_t_double_complex *) ( /* dim=1 */ (( /* dim=0 */ ((char *) (((__pyx_t_double_complex *) __pyx_v_Z.data) + __pyx_t_2)) ) + __pyx_t_22 * __pyx_v_Z.strides[1]) )))));
9007         }
9008 
9009         /* "qutip/cy/brtools.pyx":224
9010  *                 for k in range(nrows):
9011  *                     dot += conj(Z[k,i-j-1]) * Z[k,i]
9012  *                 for k in range(nrows):             # <<<<<<<<<<<<<<
9013  *                     Z[k,i] -= Z[k,i-j-1] * dot
9014  *                 dot = 0.
9015  */
9016         __pyx_t_19 = __pyx_v_nrows;
9017         __pyx_t_20 = __pyx_t_19;
9018         for (__pyx_t_21 = 0; __pyx_t_21 < __pyx_t_20; __pyx_t_21+=1) {
9019           __pyx_v_k = __pyx_t_21;
9020 
9021           /* "qutip/cy/brtools.pyx":225
9022  *                     dot += conj(Z[k,i-j-1]) * Z[k,i]
9023  *                 for k in range(nrows):
9024  *                     Z[k,i] -= Z[k,i-j-1] * dot             # <<<<<<<<<<<<<<
9025  *                 dot = 0.
9026  *                 for k in range(nrows):
9027  */
9028           __pyx_t_22 = __pyx_v_k;
9029           __pyx_t_2 = ((__pyx_v_i - __pyx_v_j) - 1);
9030           __pyx_t_17 = __pyx_v_k;
9031           __pyx_t_1 = __pyx_v_i;
9032           *((__pyx_t_double_complex *) ( /* dim=1 */ (( /* dim=0 */ ((char *) (((__pyx_t_double_complex *) __pyx_v_Z.data) + __pyx_t_17)) ) + __pyx_t_1 * __pyx_v_Z.strides[1]) )) -= __Pyx_c_prod_double((*((__pyx_t_double_complex *) ( /* dim=1 */ (( /* dim=0 */ ((char *) (((__pyx_t_double_complex *) __pyx_v_Z.data) + __pyx_t_22)) ) + __pyx_t_2 * __pyx_v_Z.strides[1]) ))), __pyx_v_dot);
9033         }
9034 
9035         /* "qutip/cy/brtools.pyx":226
9036  *                 for k in range(nrows):
9037  *                     Z[k,i] -= Z[k,i-j-1] * dot
9038  *                 dot = 0.             # <<<<<<<<<<<<<<
9039  *                 for k in range(nrows):
9040  *                     dot += conj(Z[k,i]) * Z[k,i]
9041  */
9042         __pyx_v_dot = __pyx_t_double_complex_from_parts(0., 0);
9043 
9044         /* "qutip/cy/brtools.pyx":227
9045  *                     Z[k,i] -= Z[k,i-j-1] * dot
9046  *                 dot = 0.
9047  *                 for k in range(nrows):             # <<<<<<<<<<<<<<
9048  *                     dot += conj(Z[k,i]) * Z[k,i]
9049  *                 dot = sqrt(dot)
9050  */
9051         __pyx_t_19 = __pyx_v_nrows;
9052         __pyx_t_20 = __pyx_t_19;
9053         for (__pyx_t_21 = 0; __pyx_t_21 < __pyx_t_20; __pyx_t_21+=1) {
9054           __pyx_v_k = __pyx_t_21;
9055 
9056           /* "qutip/cy/brtools.pyx":228
9057  *                 dot = 0.
9058  *                 for k in range(nrows):
9059  *                     dot += conj(Z[k,i]) * Z[k,i]             # <<<<<<<<<<<<<<
9060  *                 dot = sqrt(dot)
9061  *                 for k in range(nrows):
9062  */
9063           __pyx_t_2 = __pyx_v_k;
9064           __pyx_t_22 = __pyx_v_i;
9065           __pyx_t_1 = __pyx_v_k;
9066           __pyx_t_17 = __pyx_v_i;
9067           __pyx_v_dot = __Pyx_c_sum_double(__pyx_v_dot, __Pyx_c_prod_double(std::conj((*((__pyx_t_double_complex *) ( /* dim=1 */ (( /* dim=0 */ ((char *) (((__pyx_t_double_complex *) __pyx_v_Z.data) + __pyx_t_2)) ) + __pyx_t_22 * __pyx_v_Z.strides[1]) )))), (*((__pyx_t_double_complex *) ( /* dim=1 */ (( /* dim=0 */ ((char *) (((__pyx_t_double_complex *) __pyx_v_Z.data) + __pyx_t_1)) ) + __pyx_t_17 * __pyx_v_Z.strides[1]) )))));
9068         }
9069 
9070         /* "qutip/cy/brtools.pyx":229
9071  *                 for k in range(nrows):
9072  *                     dot += conj(Z[k,i]) * Z[k,i]
9073  *                 dot = sqrt(dot)             # <<<<<<<<<<<<<<
9074  *                 for k in range(nrows):
9075  *                     Z[k,i] /= dot
9076  */
9077         __pyx_v_dot = std::sqrt(__pyx_v_dot);
9078 
9079         /* "qutip/cy/brtools.pyx":230
9080  *                     dot += conj(Z[k,i]) * Z[k,i]
9081  *                 dot = sqrt(dot)
9082  *                 for k in range(nrows):             # <<<<<<<<<<<<<<
9083  *                     Z[k,i] /= dot
9084  *         else:
9085  */
9086         __pyx_t_19 = __pyx_v_nrows;
9087         __pyx_t_20 = __pyx_t_19;
9088         for (__pyx_t_21 = 0; __pyx_t_21 < __pyx_t_20; __pyx_t_21+=1) {
9089           __pyx_v_k = __pyx_t_21;
9090 
9091           /* "qutip/cy/brtools.pyx":231
9092  *                 dot = sqrt(dot)
9093  *                 for k in range(nrows):
9094  *                     Z[k,i] /= dot             # <<<<<<<<<<<<<<
9095  *         else:
9096  *             same_eigv = 0
9097  */
9098           __pyx_t_17 = __pyx_v_k;
9099           __pyx_t_1 = __pyx_v_i;
9100           *((__pyx_t_double_complex *) ( /* dim=1 */ (( /* dim=0 */ ((char *) (((__pyx_t_double_complex *) __pyx_v_Z.data) + __pyx_t_17)) ) + __pyx_t_1 * __pyx_v_Z.strides[1]) )) /= __pyx_v_dot;
9101         }
9102       }
9103 
9104       /* "qutip/cy/brtools.pyx":218
9105  *
9106  *     for i in range(1, nrows):
9107  *         if cabs(eigvals[i] - eigvals[i-1]) < 1e-12:             # <<<<<<<<<<<<<<
9108  *             same_eigv += 1
9109  *             for j in range(same_eigv):
9110  */
9111       goto __pyx_L11;
9112     }
9113 
9114     /* "qutip/cy/brtools.pyx":233
9115  *                     Z[k,i] /= dot
9116  *         else:
9117  *             same_eigv = 0             # <<<<<<<<<<<<<<
9118  *
9119  *     PyDataMem_FREE(work)
9120  */
9121     /*else*/ {
9122       __pyx_v_same_eigv = 0;
9123     }
9124     __pyx_L11:;
9125   }
9126 
9127   /* "qutip/cy/brtools.pyx":235
9128  *             same_eigv = 0
9129  *
9130  *     PyDataMem_FREE(work)             # <<<<<<<<<<<<<<
9131  *     PyDataMem_FREE(rwork)
9132  *     PyDataMem_FREE(vl)
9133  */
9134   PyDataMem_FREE(__pyx_v_work);
9135 
9136   /* "qutip/cy/brtools.pyx":236
9137  *
9138  *     PyDataMem_FREE(work)
9139  *     PyDataMem_FREE(rwork)             # <<<<<<<<<<<<<<
9140  *     PyDataMem_FREE(vl)
9141  *     PyDataMem_FREE(vr)
9142  */
9143   PyDataMem_FREE(__pyx_v_rwork);
9144 
9145   /* "qutip/cy/brtools.pyx":237
9146  *     PyDataMem_FREE(work)
9147  *     PyDataMem_FREE(rwork)
9148  *     PyDataMem_FREE(vl)             # <<<<<<<<<<<<<<
9149  *     PyDataMem_FREE(vr)
9150  *     PyDataMem_FREE(eival)
9151  */
9152   PyDataMem_FREE(__pyx_v_vl);
9153 
9154   /* "qutip/cy/brtools.pyx":238
9155  *     PyDataMem_FREE(rwork)
9156  *     PyDataMem_FREE(vl)
9157  *     PyDataMem_FREE(vr)             # <<<<<<<<<<<<<<
9158  *     PyDataMem_FREE(eival)
9159  *     if info != 0:
9160  */
9161   PyDataMem_FREE(__pyx_v_vr);
9162 
9163   /* "qutip/cy/brtools.pyx":239
9164  *     PyDataMem_FREE(vl)
9165  *     PyDataMem_FREE(vr)
9166  *     PyDataMem_FREE(eival)             # <<<<<<<<<<<<<<
9167  *     if info != 0:
9168  *         if info < 0:
9169  */
9170   PyDataMem_FREE(__pyx_v_eival);
9171 
9172   /* "qutip/cy/brtools.pyx":240
9173  *     PyDataMem_FREE(vr)
9174  *     PyDataMem_FREE(eival)
9175  *     if info != 0:             # <<<<<<<<<<<<<<
9176  *         if info < 0:
9177  *             raise Exception("Error in parameter : %s" & abs(info))
9178  */
9179   __pyx_t_18 = ((__pyx_v_info != 0) != 0);
9180   if (__pyx_t_18) {
9181 
9182     /* "qutip/cy/brtools.pyx":241
9183  *     PyDataMem_FREE(eival)
9184  *     if info != 0:
9185  *         if info < 0:             # <<<<<<<<<<<<<<
9186  *             raise Exception("Error in parameter : %s" & abs(info))
9187  *         else:
9188  */
9189     __pyx_t_18 = ((__pyx_v_info < 0) != 0);
9190     if (unlikely(__pyx_t_18)) {
9191 
9192       /* "qutip/cy/brtools.pyx":242
9193  *     if info != 0:
9194  *         if info < 0:
9195  *             raise Exception("Error in parameter : %s" & abs(info))             # <<<<<<<<<<<<<<
9196  *         else:
9197  *             raise Exception("Algorithm failed to converge")
9198  */
9199       __pyx_t_3 = abs(__pyx_v_info); if (unlikely(__pyx_t_3 == ((int)-1))) __PYX_ERR(1, 242, __pyx_L1_error)
9200       __pyx_t_6 = __Pyx_PyInt_From_int(__pyx_t_3); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 242, __pyx_L1_error)
9201       __Pyx_GOTREF(__pyx_t_6);
9202       __pyx_t_8 = PyNumber_And(__pyx_kp_u_Error_in_parameter_s, __pyx_t_6); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 242, __pyx_L1_error)
9203       __Pyx_GOTREF(__pyx_t_8);
9204       __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
9205       __pyx_t_6 = __Pyx_PyObject_CallOneArg(((PyObject *)(&((PyTypeObject*)PyExc_Exception)[0])), __pyx_t_8); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 242, __pyx_L1_error)
9206       __Pyx_GOTREF(__pyx_t_6);
9207       __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
9208       __Pyx_Raise(__pyx_t_6, 0, 0, 0);
9209       __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
9210       __PYX_ERR(1, 242, __pyx_L1_error)
9211 
9212       /* "qutip/cy/brtools.pyx":241
9213  *     PyDataMem_FREE(eival)
9214  *     if info != 0:
9215  *         if info < 0:             # <<<<<<<<<<<<<<
9216  *             raise Exception("Error in parameter : %s" & abs(info))
9217  *         else:
9218  */
9219     }
9220 
9221     /* "qutip/cy/brtools.pyx":244
9222  *             raise Exception("Error in parameter : %s" & abs(info))
9223  *         else:
9224  *             raise Exception("Algorithm failed to converge")             # <<<<<<<<<<<<<<
9225  *
9226  *
9227  */
9228     /*else*/ {
9229       __pyx_t_6 = __Pyx_PyObject_Call(((PyObject *)(&((PyTypeObject*)PyExc_Exception)[0])), __pyx_tuple__12, NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 244, __pyx_L1_error)
9230       __Pyx_GOTREF(__pyx_t_6);
9231       __Pyx_Raise(__pyx_t_6, 0, 0, 0);
9232       __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
9233       __PYX_ERR(1, 244, __pyx_L1_error)
9234     }
9235 
9236     /* "qutip/cy/brtools.pyx":240
9237  *     PyDataMem_FREE(vr)
9238  *     PyDataMem_FREE(eival)
9239  *     if info != 0:             # <<<<<<<<<<<<<<
9240  *         if info < 0:
9241  *             raise Exception("Error in parameter : %s" & abs(info))
9242  */
9243   }
9244 
9245   /* "qutip/cy/brtools.pyx":162
9246  * @cython.boundscheck(False)
9247  * @cython.wraparound(False)
9248  * cdef void ZGEEV(complex[::1,:] H, double * eigvals,             # <<<<<<<<<<<<<<
9249  *                 complex[::1,:] Z, int nrows):
9250  *     """
9251  */
9252 
9253   /* function exit code */
9254   goto __pyx_L0;
9255   __pyx_L1_error:;
9256   __Pyx_XDECREF(__pyx_t_6);
9257   __Pyx_XDECREF(__pyx_t_7);
9258   __Pyx_XDECREF(__pyx_t_8);
9259   __Pyx_XDECREF(__pyx_t_9);
9260   __Pyx_XDECREF(__pyx_t_10);
9261   __Pyx_XDECREF(((PyObject *)__pyx_t_11));
9262   __Pyx_XDECREF(__pyx_t_12);
9263   __PYX_XDEC_MEMVIEW(&__pyx_t_13, 1);
9264   __Pyx_WriteUnraisable("qutip.cy.brtools.ZGEEV", __pyx_clineno, __pyx_lineno, __pyx_filename, 1, 0);
9265   __pyx_L0:;
9266   __PYX_XDEC_MEMVIEW(&__pyx_v_idx, 1);
9267   __Pyx_RefNannyFinishContext();
9268 }
9269 
9270 /* "qutip/cy/brtools.pyx":249
9271  * @cython.boundscheck(False)
9272  * @cython.wraparound(False)
9273  * def liou_from_diag_ham(double[::1] diags):             # <<<<<<<<<<<<<<
9274  *     cdef unsigned int nrows = diags.shape[0]
9275  *     cdef np.ndarray[complex, ndim=1, mode='c'] data = np.empty(nrows**2, dtype=complex)
9276  */
9277 
9278 /* Python wrapper */
9279 static PyObject *__pyx_pw_5qutip_2cy_7brtools_3liou_from_diag_ham(PyObject *__pyx_self, PyObject *__pyx_arg_diags); /*proto*/
9280 static PyMethodDef __pyx_mdef_5qutip_2cy_7brtools_3liou_from_diag_ham = {"liou_from_diag_ham", (PyCFunction)__pyx_pw_5qutip_2cy_7brtools_3liou_from_diag_ham, METH_O, 0};
__pyx_pw_5qutip_2cy_7brtools_3liou_from_diag_ham(PyObject * __pyx_self,PyObject * __pyx_arg_diags)9281 static PyObject *__pyx_pw_5qutip_2cy_7brtools_3liou_from_diag_ham(PyObject *__pyx_self, PyObject *__pyx_arg_diags) {
9282   __Pyx_memviewslice __pyx_v_diags = { 0, 0, { 0 }, { 0 }, { 0 } };
9283   int __pyx_lineno = 0;
9284   const char *__pyx_filename = NULL;
9285   int __pyx_clineno = 0;
9286   PyObject *__pyx_r = 0;
9287   __Pyx_RefNannyDeclarations
9288   __Pyx_RefNannySetupContext("liou_from_diag_ham (wrapper)", 0);
9289   assert(__pyx_arg_diags); {
9290     __pyx_v_diags = __Pyx_PyObject_to_MemoryviewSlice_dc_double(__pyx_arg_diags, PyBUF_WRITABLE); if (unlikely(!__pyx_v_diags.memview)) __PYX_ERR(1, 249, __pyx_L3_error)
9291   }
9292   goto __pyx_L4_argument_unpacking_done;
9293   __pyx_L3_error:;
9294   __Pyx_AddTraceback("qutip.cy.brtools.liou_from_diag_ham", __pyx_clineno, __pyx_lineno, __pyx_filename);
9295   __Pyx_RefNannyFinishContext();
9296   return NULL;
9297   __pyx_L4_argument_unpacking_done:;
9298   __pyx_r = __pyx_pf_5qutip_2cy_7brtools_2liou_from_diag_ham(__pyx_self, __pyx_v_diags);
9299 
9300   /* function exit code */
9301   __Pyx_RefNannyFinishContext();
9302   return __pyx_r;
9303 }
9304 
__pyx_pf_5qutip_2cy_7brtools_2liou_from_diag_ham(CYTHON_UNUSED PyObject * __pyx_self,__Pyx_memviewslice __pyx_v_diags)9305 static PyObject *__pyx_pf_5qutip_2cy_7brtools_2liou_from_diag_ham(CYTHON_UNUSED PyObject *__pyx_self, __Pyx_memviewslice __pyx_v_diags) {
9306   unsigned int __pyx_v_nrows;
9307   PyArrayObject *__pyx_v_data = 0;
9308   PyArrayObject *__pyx_v_ind = 0;
9309   PyArrayObject *__pyx_v_ptr = 0;
9310   unsigned int __pyx_v_idx;
9311   unsigned int __pyx_v_nnz;
9312   size_t __pyx_v_ii;
9313   size_t __pyx_v_jj;
9314   __pyx_t_double_complex __pyx_v_val1;
9315   __pyx_t_double_complex __pyx_v_val2;
9316   __pyx_t_double_complex __pyx_v_ans;
9317   __Pyx_LocalBuf_ND __pyx_pybuffernd_data;
9318   __Pyx_Buffer __pyx_pybuffer_data;
9319   __Pyx_LocalBuf_ND __pyx_pybuffernd_ind;
9320   __Pyx_Buffer __pyx_pybuffer_ind;
9321   __Pyx_LocalBuf_ND __pyx_pybuffernd_ptr;
9322   __Pyx_Buffer __pyx_pybuffer_ptr;
9323   PyObject *__pyx_r = NULL;
9324   __Pyx_RefNannyDeclarations
9325   PyObject *__pyx_t_1 = NULL;
9326   PyObject *__pyx_t_2 = NULL;
9327   PyObject *__pyx_t_3 = NULL;
9328   PyObject *__pyx_t_4 = NULL;
9329   PyArrayObject *__pyx_t_5 = NULL;
9330   PyObject *__pyx_t_6 = NULL;
9331   PyArrayObject *__pyx_t_7 = NULL;
9332   PyArrayObject *__pyx_t_8 = NULL;
9333   Py_ssize_t __pyx_t_9;
9334   unsigned int __pyx_t_10;
9335   unsigned int __pyx_t_11;
9336   size_t __pyx_t_12;
9337   size_t __pyx_t_13;
9338   unsigned int __pyx_t_14;
9339   unsigned int __pyx_t_15;
9340   size_t __pyx_t_16;
9341   int __pyx_t_17;
9342   PyObject *__pyx_t_18 = NULL;
9343   int __pyx_lineno = 0;
9344   const char *__pyx_filename = NULL;
9345   int __pyx_clineno = 0;
9346   __Pyx_RefNannySetupContext("liou_from_diag_ham", 0);
9347   __pyx_pybuffer_data.pybuffer.buf = NULL;
9348   __pyx_pybuffer_data.refcount = 0;
9349   __pyx_pybuffernd_data.data = NULL;
9350   __pyx_pybuffernd_data.rcbuffer = &__pyx_pybuffer_data;
9351   __pyx_pybuffer_ind.pybuffer.buf = NULL;
9352   __pyx_pybuffer_ind.refcount = 0;
9353   __pyx_pybuffernd_ind.data = NULL;
9354   __pyx_pybuffernd_ind.rcbuffer = &__pyx_pybuffer_ind;
9355   __pyx_pybuffer_ptr.pybuffer.buf = NULL;
9356   __pyx_pybuffer_ptr.refcount = 0;
9357   __pyx_pybuffernd_ptr.data = NULL;
9358   __pyx_pybuffernd_ptr.rcbuffer = &__pyx_pybuffer_ptr;
9359 
9360   /* "qutip/cy/brtools.pyx":250
9361  * @cython.wraparound(False)
9362  * def liou_from_diag_ham(double[::1] diags):
9363  *     cdef unsigned int nrows = diags.shape[0]             # <<<<<<<<<<<<<<
9364  *     cdef np.ndarray[complex, ndim=1, mode='c'] data = np.empty(nrows**2, dtype=complex)
9365  *     cdef np.ndarray[int, ndim=1, mode='c'] ind = np.empty(nrows**2, dtype=np.int32)
9366  */
9367   __pyx_v_nrows = (__pyx_v_diags.shape[0]);
9368 
9369   /* "qutip/cy/brtools.pyx":251
9370  * def liou_from_diag_ham(double[::1] diags):
9371  *     cdef unsigned int nrows = diags.shape[0]
9372  *     cdef np.ndarray[complex, ndim=1, mode='c'] data = np.empty(nrows**2, dtype=complex)             # <<<<<<<<<<<<<<
9373  *     cdef np.ndarray[int, ndim=1, mode='c'] ind = np.empty(nrows**2, dtype=np.int32)
9374  *     cdef np.ndarray[int, ndim=1, mode='c'] ptr = np.empty(nrows**2+1, dtype=np.int32)
9375  */
9376   __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_np); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 251, __pyx_L1_error)
9377   __Pyx_GOTREF(__pyx_t_1);
9378   __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_empty); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 251, __pyx_L1_error)
9379   __Pyx_GOTREF(__pyx_t_2);
9380   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
9381   __pyx_t_1 = __Pyx_PyInt_From_long(__Pyx_pow_long(((long)__pyx_v_nrows), 2)); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 251, __pyx_L1_error)
9382   __Pyx_GOTREF(__pyx_t_1);
9383   __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 251, __pyx_L1_error)
9384   __Pyx_GOTREF(__pyx_t_3);
9385   __Pyx_GIVEREF(__pyx_t_1);
9386   PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_1);
9387   __pyx_t_1 = 0;
9388   __pyx_t_1 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 251, __pyx_L1_error)
9389   __Pyx_GOTREF(__pyx_t_1);
9390   if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_dtype, ((PyObject *)(&PyComplex_Type))) < 0) __PYX_ERR(1, 251, __pyx_L1_error)
9391   __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_3, __pyx_t_1); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 251, __pyx_L1_error)
9392   __Pyx_GOTREF(__pyx_t_4);
9393   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
9394   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
9395   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
9396   if (!(likely(((__pyx_t_4) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_4, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(1, 251, __pyx_L1_error)
9397   __pyx_t_5 = ((PyArrayObject *)__pyx_t_4);
9398   {
9399     __Pyx_BufFmt_StackElem __pyx_stack[1];
9400     if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_data.rcbuffer->pybuffer, (PyObject*)__pyx_t_5, &__Pyx_TypeInfo___pyx_t_double_complex, PyBUF_FORMAT| PyBUF_C_CONTIGUOUS| PyBUF_WRITABLE, 1, 0, __pyx_stack) == -1)) {
9401       __pyx_v_data = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_pybuffernd_data.rcbuffer->pybuffer.buf = NULL;
9402       __PYX_ERR(1, 251, __pyx_L1_error)
9403     } else {__pyx_pybuffernd_data.diminfo[0].strides = __pyx_pybuffernd_data.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_data.diminfo[0].shape = __pyx_pybuffernd_data.rcbuffer->pybuffer.shape[0];
9404     }
9405   }
9406   __pyx_t_5 = 0;
9407   __pyx_v_data = ((PyArrayObject *)__pyx_t_4);
9408   __pyx_t_4 = 0;
9409 
9410   /* "qutip/cy/brtools.pyx":252
9411  *     cdef unsigned int nrows = diags.shape[0]
9412  *     cdef np.ndarray[complex, ndim=1, mode='c'] data = np.empty(nrows**2, dtype=complex)
9413  *     cdef np.ndarray[int, ndim=1, mode='c'] ind = np.empty(nrows**2, dtype=np.int32)             # <<<<<<<<<<<<<<
9414  *     cdef np.ndarray[int, ndim=1, mode='c'] ptr = np.empty(nrows**2+1, dtype=np.int32)
9415  *     cdef unsigned int idx, nnz = 0
9416  */
9417   __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_np); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 252, __pyx_L1_error)
9418   __Pyx_GOTREF(__pyx_t_4);
9419   __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_empty); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 252, __pyx_L1_error)
9420   __Pyx_GOTREF(__pyx_t_1);
9421   __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
9422   __pyx_t_4 = __Pyx_PyInt_From_long(__Pyx_pow_long(((long)__pyx_v_nrows), 2)); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 252, __pyx_L1_error)
9423   __Pyx_GOTREF(__pyx_t_4);
9424   __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 252, __pyx_L1_error)
9425   __Pyx_GOTREF(__pyx_t_3);
9426   __Pyx_GIVEREF(__pyx_t_4);
9427   PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_4);
9428   __pyx_t_4 = 0;
9429   __pyx_t_4 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 252, __pyx_L1_error)
9430   __Pyx_GOTREF(__pyx_t_4);
9431   __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_np); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 252, __pyx_L1_error)
9432   __Pyx_GOTREF(__pyx_t_2);
9433   __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_int32); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 252, __pyx_L1_error)
9434   __Pyx_GOTREF(__pyx_t_6);
9435   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
9436   if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_dtype, __pyx_t_6) < 0) __PYX_ERR(1, 252, __pyx_L1_error)
9437   __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
9438   __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 252, __pyx_L1_error)
9439   __Pyx_GOTREF(__pyx_t_6);
9440   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
9441   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
9442   __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
9443   if (!(likely(((__pyx_t_6) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_6, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(1, 252, __pyx_L1_error)
9444   __pyx_t_7 = ((PyArrayObject *)__pyx_t_6);
9445   {
9446     __Pyx_BufFmt_StackElem __pyx_stack[1];
9447     if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_ind.rcbuffer->pybuffer, (PyObject*)__pyx_t_7, &__Pyx_TypeInfo_int, PyBUF_FORMAT| PyBUF_C_CONTIGUOUS| PyBUF_WRITABLE, 1, 0, __pyx_stack) == -1)) {
9448       __pyx_v_ind = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_pybuffernd_ind.rcbuffer->pybuffer.buf = NULL;
9449       __PYX_ERR(1, 252, __pyx_L1_error)
9450     } else {__pyx_pybuffernd_ind.diminfo[0].strides = __pyx_pybuffernd_ind.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_ind.diminfo[0].shape = __pyx_pybuffernd_ind.rcbuffer->pybuffer.shape[0];
9451     }
9452   }
9453   __pyx_t_7 = 0;
9454   __pyx_v_ind = ((PyArrayObject *)__pyx_t_6);
9455   __pyx_t_6 = 0;
9456 
9457   /* "qutip/cy/brtools.pyx":253
9458  *     cdef np.ndarray[complex, ndim=1, mode='c'] data = np.empty(nrows**2, dtype=complex)
9459  *     cdef np.ndarray[int, ndim=1, mode='c'] ind = np.empty(nrows**2, dtype=np.int32)
9460  *     cdef np.ndarray[int, ndim=1, mode='c'] ptr = np.empty(nrows**2+1, dtype=np.int32)             # <<<<<<<<<<<<<<
9461  *     cdef unsigned int idx, nnz = 0
9462  *     cdef size_t ii, jj
9463  */
9464   __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_n_s_np); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 253, __pyx_L1_error)
9465   __Pyx_GOTREF(__pyx_t_6);
9466   __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_empty); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 253, __pyx_L1_error)
9467   __Pyx_GOTREF(__pyx_t_4);
9468   __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
9469   __pyx_t_6 = __Pyx_PyInt_From_long((__Pyx_pow_long(((long)__pyx_v_nrows), 2) + 1)); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 253, __pyx_L1_error)
9470   __Pyx_GOTREF(__pyx_t_6);
9471   __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 253, __pyx_L1_error)
9472   __Pyx_GOTREF(__pyx_t_3);
9473   __Pyx_GIVEREF(__pyx_t_6);
9474   PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_6);
9475   __pyx_t_6 = 0;
9476   __pyx_t_6 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 253, __pyx_L1_error)
9477   __Pyx_GOTREF(__pyx_t_6);
9478   __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_np); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 253, __pyx_L1_error)
9479   __Pyx_GOTREF(__pyx_t_1);
9480   __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_int32); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 253, __pyx_L1_error)
9481   __Pyx_GOTREF(__pyx_t_2);
9482   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
9483   if (PyDict_SetItem(__pyx_t_6, __pyx_n_s_dtype, __pyx_t_2) < 0) __PYX_ERR(1, 253, __pyx_L1_error)
9484   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
9485   __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_3, __pyx_t_6); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 253, __pyx_L1_error)
9486   __Pyx_GOTREF(__pyx_t_2);
9487   __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
9488   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
9489   __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
9490   if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(1, 253, __pyx_L1_error)
9491   __pyx_t_8 = ((PyArrayObject *)__pyx_t_2);
9492   {
9493     __Pyx_BufFmt_StackElem __pyx_stack[1];
9494     if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_ptr.rcbuffer->pybuffer, (PyObject*)__pyx_t_8, &__Pyx_TypeInfo_int, PyBUF_FORMAT| PyBUF_C_CONTIGUOUS| PyBUF_WRITABLE, 1, 0, __pyx_stack) == -1)) {
9495       __pyx_v_ptr = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_pybuffernd_ptr.rcbuffer->pybuffer.buf = NULL;
9496       __PYX_ERR(1, 253, __pyx_L1_error)
9497     } else {__pyx_pybuffernd_ptr.diminfo[0].strides = __pyx_pybuffernd_ptr.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_ptr.diminfo[0].shape = __pyx_pybuffernd_ptr.rcbuffer->pybuffer.shape[0];
9498     }
9499   }
9500   __pyx_t_8 = 0;
9501   __pyx_v_ptr = ((PyArrayObject *)__pyx_t_2);
9502   __pyx_t_2 = 0;
9503 
9504   /* "qutip/cy/brtools.pyx":254
9505  *     cdef np.ndarray[int, ndim=1, mode='c'] ind = np.empty(nrows**2, dtype=np.int32)
9506  *     cdef np.ndarray[int, ndim=1, mode='c'] ptr = np.empty(nrows**2+1, dtype=np.int32)
9507  *     cdef unsigned int idx, nnz = 0             # <<<<<<<<<<<<<<
9508  *     cdef size_t ii, jj
9509  *     cdef double complex val1, val2, ans
9510  */
9511   __pyx_v_nnz = 0;
9512 
9513   /* "qutip/cy/brtools.pyx":258
9514  *     cdef double complex val1, val2, ans
9515  *
9516  *     ptr[0] = 0             # <<<<<<<<<<<<<<
9517  *     for ii in range(nrows):
9518  *         val1 = 1j*diags[ii]
9519  */
9520   __pyx_t_9 = 0;
9521   *__Pyx_BufPtrCContig1d(int *, __pyx_pybuffernd_ptr.rcbuffer->pybuffer.buf, __pyx_t_9, __pyx_pybuffernd_ptr.diminfo[0].strides) = 0;
9522 
9523   /* "qutip/cy/brtools.pyx":259
9524  *
9525  *     ptr[0] = 0
9526  *     for ii in range(nrows):             # <<<<<<<<<<<<<<
9527  *         val1 = 1j*diags[ii]
9528  *         idx = nrows*ii+1 #Here the +1 is to set the next ptr
9529  */
9530   __pyx_t_10 = __pyx_v_nrows;
9531   __pyx_t_11 = __pyx_t_10;
9532   for (__pyx_t_12 = 0; __pyx_t_12 < __pyx_t_11; __pyx_t_12+=1) {
9533     __pyx_v_ii = __pyx_t_12;
9534 
9535     /* "qutip/cy/brtools.pyx":260
9536  *     ptr[0] = 0
9537  *     for ii in range(nrows):
9538  *         val1 = 1j*diags[ii]             # <<<<<<<<<<<<<<
9539  *         idx = nrows*ii+1 #Here the +1 is to set the next ptr
9540  *         for jj in range(nrows):
9541  */
9542     __pyx_t_13 = __pyx_v_ii;
9543     __pyx_v_val1 = __Pyx_c_prod_double(__pyx_t_double_complex_from_parts(0, 1.0), __pyx_t_double_complex_from_parts((*((double *) ( /* dim=0 */ ((char *) (((double *) __pyx_v_diags.data) + __pyx_t_13)) ))), 0));
9544 
9545     /* "qutip/cy/brtools.pyx":261
9546  *     for ii in range(nrows):
9547  *         val1 = 1j*diags[ii]
9548  *         idx = nrows*ii+1 #Here the +1 is to set the next ptr             # <<<<<<<<<<<<<<
9549  *         for jj in range(nrows):
9550  *             val2 = -1j*diags[jj]
9551  */
9552     __pyx_v_idx = ((__pyx_v_nrows * __pyx_v_ii) + 1);
9553 
9554     /* "qutip/cy/brtools.pyx":262
9555  *         val1 = 1j*diags[ii]
9556  *         idx = nrows*ii+1 #Here the +1 is to set the next ptr
9557  *         for jj in range(nrows):             # <<<<<<<<<<<<<<
9558  *             val2 = -1j*diags[jj]
9559  *             ans = val1 + val2
9560  */
9561     __pyx_t_14 = __pyx_v_nrows;
9562     __pyx_t_15 = __pyx_t_14;
9563     for (__pyx_t_13 = 0; __pyx_t_13 < __pyx_t_15; __pyx_t_13+=1) {
9564       __pyx_v_jj = __pyx_t_13;
9565 
9566       /* "qutip/cy/brtools.pyx":263
9567  *         idx = nrows*ii+1 #Here the +1 is to set the next ptr
9568  *         for jj in range(nrows):
9569  *             val2 = -1j*diags[jj]             # <<<<<<<<<<<<<<
9570  *             ans = val1 + val2
9571  *             if ans != 0:
9572  */
9573       __pyx_t_16 = __pyx_v_jj;
9574       __pyx_v_val2 = __Pyx_c_prod_double(__Pyx_c_neg_double(__pyx_t_double_complex_from_parts(0, 1.0)), __pyx_t_double_complex_from_parts((*((double *) ( /* dim=0 */ ((char *) (((double *) __pyx_v_diags.data) + __pyx_t_16)) ))), 0));
9575 
9576       /* "qutip/cy/brtools.pyx":264
9577  *         for jj in range(nrows):
9578  *             val2 = -1j*diags[jj]
9579  *             ans = val1 + val2             # <<<<<<<<<<<<<<
9580  *             if ans != 0:
9581  *                 data[nnz] = ans
9582  */
9583       __pyx_v_ans = __Pyx_c_sum_double(__pyx_v_val1, __pyx_v_val2);
9584 
9585       /* "qutip/cy/brtools.pyx":265
9586  *             val2 = -1j*diags[jj]
9587  *             ans = val1 + val2
9588  *             if ans != 0:             # <<<<<<<<<<<<<<
9589  *                 data[nnz] = ans
9590  *                 ind[nnz] = nrows*ii+jj
9591  */
9592       __pyx_t_17 = ((!__Pyx_c_eq_double(__pyx_v_ans, __pyx_t_double_complex_from_parts(0, 0))) != 0);
9593       if (__pyx_t_17) {
9594 
9595         /* "qutip/cy/brtools.pyx":266
9596  *             ans = val1 + val2
9597  *             if ans != 0:
9598  *                 data[nnz] = ans             # <<<<<<<<<<<<<<
9599  *                 ind[nnz] = nrows*ii+jj
9600  *                 ptr[idx+jj] = nnz+1
9601  */
9602         __pyx_t_16 = __pyx_v_nnz;
9603         *__Pyx_BufPtrCContig1d(__pyx_t_double_complex *, __pyx_pybuffernd_data.rcbuffer->pybuffer.buf, __pyx_t_16, __pyx_pybuffernd_data.diminfo[0].strides) = __pyx_v_ans;
9604 
9605         /* "qutip/cy/brtools.pyx":267
9606  *             if ans != 0:
9607  *                 data[nnz] = ans
9608  *                 ind[nnz] = nrows*ii+jj             # <<<<<<<<<<<<<<
9609  *                 ptr[idx+jj] = nnz+1
9610  *                 nnz += 1
9611  */
9612         __pyx_t_16 = __pyx_v_nnz;
9613         *__Pyx_BufPtrCContig1d(int *, __pyx_pybuffernd_ind.rcbuffer->pybuffer.buf, __pyx_t_16, __pyx_pybuffernd_ind.diminfo[0].strides) = ((__pyx_v_nrows * __pyx_v_ii) + __pyx_v_jj);
9614 
9615         /* "qutip/cy/brtools.pyx":268
9616  *                 data[nnz] = ans
9617  *                 ind[nnz] = nrows*ii+jj
9618  *                 ptr[idx+jj] = nnz+1             # <<<<<<<<<<<<<<
9619  *                 nnz += 1
9620  *             else:
9621  */
9622         __pyx_t_16 = (__pyx_v_idx + __pyx_v_jj);
9623         *__Pyx_BufPtrCContig1d(int *, __pyx_pybuffernd_ptr.rcbuffer->pybuffer.buf, __pyx_t_16, __pyx_pybuffernd_ptr.diminfo[0].strides) = (__pyx_v_nnz + 1);
9624 
9625         /* "qutip/cy/brtools.pyx":269
9626  *                 ind[nnz] = nrows*ii+jj
9627  *                 ptr[idx+jj] = nnz+1
9628  *                 nnz += 1             # <<<<<<<<<<<<<<
9629  *             else:
9630  *                 ptr[idx+jj] = nnz
9631  */
9632         __pyx_v_nnz = (__pyx_v_nnz + 1);
9633 
9634         /* "qutip/cy/brtools.pyx":265
9635  *             val2 = -1j*diags[jj]
9636  *             ans = val1 + val2
9637  *             if ans != 0:             # <<<<<<<<<<<<<<
9638  *                 data[nnz] = ans
9639  *                 ind[nnz] = nrows*ii+jj
9640  */
9641         goto __pyx_L7;
9642       }
9643 
9644       /* "qutip/cy/brtools.pyx":271
9645  *                 nnz += 1
9646  *             else:
9647  *                 ptr[idx+jj] = nnz             # <<<<<<<<<<<<<<
9648  *     return fast_csr_matrix((data[:nnz],ind[:nnz],ptr), shape=(nrows**2,nrows**2))
9649  *
9650  */
9651       /*else*/ {
9652         __pyx_t_16 = (__pyx_v_idx + __pyx_v_jj);
9653         *__Pyx_BufPtrCContig1d(int *, __pyx_pybuffernd_ptr.rcbuffer->pybuffer.buf, __pyx_t_16, __pyx_pybuffernd_ptr.diminfo[0].strides) = __pyx_v_nnz;
9654       }
9655       __pyx_L7:;
9656     }
9657   }
9658 
9659   /* "qutip/cy/brtools.pyx":272
9660  *             else:
9661  *                 ptr[idx+jj] = nnz
9662  *     return fast_csr_matrix((data[:nnz],ind[:nnz],ptr), shape=(nrows**2,nrows**2))             # <<<<<<<<<<<<<<
9663  *
9664  *
9665  */
9666   __Pyx_XDECREF(__pyx_r);
9667   __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_fast_csr_matrix); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 272, __pyx_L1_error)
9668   __Pyx_GOTREF(__pyx_t_2);
9669   __pyx_t_6 = __Pyx_PyInt_From_unsigned_int(__pyx_v_nnz); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 272, __pyx_L1_error)
9670   __Pyx_GOTREF(__pyx_t_6);
9671   __pyx_t_3 = PySlice_New(Py_None, __pyx_t_6, Py_None); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 272, __pyx_L1_error)
9672   __Pyx_GOTREF(__pyx_t_3);
9673   __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
9674   __pyx_t_6 = __Pyx_PyObject_GetItem(((PyObject *)__pyx_v_data), __pyx_t_3); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 272, __pyx_L1_error)
9675   __Pyx_GOTREF(__pyx_t_6);
9676   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
9677   __pyx_t_3 = __Pyx_PyInt_From_unsigned_int(__pyx_v_nnz); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 272, __pyx_L1_error)
9678   __Pyx_GOTREF(__pyx_t_3);
9679   __pyx_t_4 = PySlice_New(Py_None, __pyx_t_3, Py_None); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 272, __pyx_L1_error)
9680   __Pyx_GOTREF(__pyx_t_4);
9681   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
9682   __pyx_t_3 = __Pyx_PyObject_GetItem(((PyObject *)__pyx_v_ind), __pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 272, __pyx_L1_error)
9683   __Pyx_GOTREF(__pyx_t_3);
9684   __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
9685   __pyx_t_4 = PyTuple_New(3); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 272, __pyx_L1_error)
9686   __Pyx_GOTREF(__pyx_t_4);
9687   __Pyx_GIVEREF(__pyx_t_6);
9688   PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_6);
9689   __Pyx_GIVEREF(__pyx_t_3);
9690   PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_3);
9691   __Pyx_INCREF(((PyObject *)__pyx_v_ptr));
9692   __Pyx_GIVEREF(((PyObject *)__pyx_v_ptr));
9693   PyTuple_SET_ITEM(__pyx_t_4, 2, ((PyObject *)__pyx_v_ptr));
9694   __pyx_t_6 = 0;
9695   __pyx_t_3 = 0;
9696   __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 272, __pyx_L1_error)
9697   __Pyx_GOTREF(__pyx_t_3);
9698   __Pyx_GIVEREF(__pyx_t_4);
9699   PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_4);
9700   __pyx_t_4 = 0;
9701   __pyx_t_4 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 272, __pyx_L1_error)
9702   __Pyx_GOTREF(__pyx_t_4);
9703   __pyx_t_6 = __Pyx_PyInt_From_long(__Pyx_pow_long(((long)__pyx_v_nrows), 2)); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 272, __pyx_L1_error)
9704   __Pyx_GOTREF(__pyx_t_6);
9705   __pyx_t_1 = __Pyx_PyInt_From_long(__Pyx_pow_long(((long)__pyx_v_nrows), 2)); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 272, __pyx_L1_error)
9706   __Pyx_GOTREF(__pyx_t_1);
9707   __pyx_t_18 = PyTuple_New(2); if (unlikely(!__pyx_t_18)) __PYX_ERR(1, 272, __pyx_L1_error)
9708   __Pyx_GOTREF(__pyx_t_18);
9709   __Pyx_GIVEREF(__pyx_t_6);
9710   PyTuple_SET_ITEM(__pyx_t_18, 0, __pyx_t_6);
9711   __Pyx_GIVEREF(__pyx_t_1);
9712   PyTuple_SET_ITEM(__pyx_t_18, 1, __pyx_t_1);
9713   __pyx_t_6 = 0;
9714   __pyx_t_1 = 0;
9715   if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_shape, __pyx_t_18) < 0) __PYX_ERR(1, 272, __pyx_L1_error)
9716   __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
9717   __pyx_t_18 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_18)) __PYX_ERR(1, 272, __pyx_L1_error)
9718   __Pyx_GOTREF(__pyx_t_18);
9719   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
9720   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
9721   __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
9722   __pyx_r = __pyx_t_18;
9723   __pyx_t_18 = 0;
9724   goto __pyx_L0;
9725 
9726   /* "qutip/cy/brtools.pyx":249
9727  * @cython.boundscheck(False)
9728  * @cython.wraparound(False)
9729  * def liou_from_diag_ham(double[::1] diags):             # <<<<<<<<<<<<<<
9730  *     cdef unsigned int nrows = diags.shape[0]
9731  *     cdef np.ndarray[complex, ndim=1, mode='c'] data = np.empty(nrows**2, dtype=complex)
9732  */
9733 
9734   /* function exit code */
9735   __pyx_L1_error:;
9736   __Pyx_XDECREF(__pyx_t_1);
9737   __Pyx_XDECREF(__pyx_t_2);
9738   __Pyx_XDECREF(__pyx_t_3);
9739   __Pyx_XDECREF(__pyx_t_4);
9740   __Pyx_XDECREF(__pyx_t_6);
9741   __Pyx_XDECREF(__pyx_t_18);
9742   { PyObject *__pyx_type, *__pyx_value, *__pyx_tb;
9743     __Pyx_PyThreadState_declare
9744     __Pyx_PyThreadState_assign
9745     __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb);
9746     __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_data.rcbuffer->pybuffer);
9747     __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_ind.rcbuffer->pybuffer);
9748     __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_ptr.rcbuffer->pybuffer);
9749   __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}
9750   __Pyx_AddTraceback("qutip.cy.brtools.liou_from_diag_ham", __pyx_clineno, __pyx_lineno, __pyx_filename);
9751   __pyx_r = NULL;
9752   goto __pyx_L2;
9753   __pyx_L0:;
9754   __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_data.rcbuffer->pybuffer);
9755   __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_ind.rcbuffer->pybuffer);
9756   __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_ptr.rcbuffer->pybuffer);
9757   __pyx_L2:;
9758   __PYX_XDEC_MEMVIEW(&__pyx_v_diags, 1);
9759   __Pyx_XDECREF((PyObject *)__pyx_v_data);
9760   __Pyx_XDECREF((PyObject *)__pyx_v_ind);
9761   __Pyx_XDECREF((PyObject *)__pyx_v_ptr);
9762   __Pyx_XGIVEREF(__pyx_r);
9763   __Pyx_RefNannyFinishContext();
9764   return __pyx_r;
9765 }
9766 
9767 /* "qutip/cy/brtools.pyx":278
9768  * @cython.boundscheck(False)
9769  * @cython.wraparound(False)
9770  * cdef void diag_liou_mult(double * diags, double complex * vec,             # <<<<<<<<<<<<<<
9771  *                         double complex * out, unsigned int nrows) nogil:
9772  *     """
9773  */
9774 
__pyx_f_5qutip_2cy_7brtools_diag_liou_mult(double * __pyx_v_diags,__pyx_t_double_complex * __pyx_v_vec,__pyx_t_double_complex * __pyx_v_out,unsigned int __pyx_v_nrows)9775 static void __pyx_f_5qutip_2cy_7brtools_diag_liou_mult(double *__pyx_v_diags, __pyx_t_double_complex *__pyx_v_vec, __pyx_t_double_complex *__pyx_v_out, unsigned int __pyx_v_nrows) {
9776   unsigned int __pyx_v_nnz;
9777   size_t __pyx_v_ii;
9778   size_t __pyx_v_jj;
9779   __pyx_t_double_complex __pyx_v_val;
9780   __pyx_t_double_complex __pyx_v_ans;
9781   unsigned int __pyx_t_1;
9782   unsigned int __pyx_t_2;
9783   size_t __pyx_t_3;
9784   unsigned int __pyx_t_4;
9785   unsigned int __pyx_t_5;
9786   size_t __pyx_t_6;
9787   unsigned int __pyx_t_7;
9788 
9789   /* "qutip/cy/brtools.pyx":295
9790  *         Dimension of Hamiltonian.
9791  *     """
9792  *     cdef unsigned int nnz = 0             # <<<<<<<<<<<<<<
9793  *     cdef size_t ii, jj
9794  *     cdef double complex val, ans
9795  */
9796   __pyx_v_nnz = 0;
9797 
9798   /* "qutip/cy/brtools.pyx":299
9799  *     cdef double complex val, ans
9800  *
9801  *     for ii in range(nrows):             # <<<<<<<<<<<<<<
9802  *         val = 1j*diags[ii]
9803  *         for jj in range(nrows):
9804  */
9805   __pyx_t_1 = __pyx_v_nrows;
9806   __pyx_t_2 = __pyx_t_1;
9807   for (__pyx_t_3 = 0; __pyx_t_3 < __pyx_t_2; __pyx_t_3+=1) {
9808     __pyx_v_ii = __pyx_t_3;
9809 
9810     /* "qutip/cy/brtools.pyx":300
9811  *
9812  *     for ii in range(nrows):
9813  *         val = 1j*diags[ii]             # <<<<<<<<<<<<<<
9814  *         for jj in range(nrows):
9815  *             ans = val - 1j*diags[jj]
9816  */
9817     __pyx_v_val = __Pyx_c_prod_double(__pyx_t_double_complex_from_parts(0, 1.0), __pyx_t_double_complex_from_parts((__pyx_v_diags[__pyx_v_ii]), 0));
9818 
9819     /* "qutip/cy/brtools.pyx":301
9820  *     for ii in range(nrows):
9821  *         val = 1j*diags[ii]
9822  *         for jj in range(nrows):             # <<<<<<<<<<<<<<
9823  *             ans = val - 1j*diags[jj]
9824  *             out[nnz] += ans*vec[nnz]
9825  */
9826     __pyx_t_4 = __pyx_v_nrows;
9827     __pyx_t_5 = __pyx_t_4;
9828     for (__pyx_t_6 = 0; __pyx_t_6 < __pyx_t_5; __pyx_t_6+=1) {
9829       __pyx_v_jj = __pyx_t_6;
9830 
9831       /* "qutip/cy/brtools.pyx":302
9832  *         val = 1j*diags[ii]
9833  *         for jj in range(nrows):
9834  *             ans = val - 1j*diags[jj]             # <<<<<<<<<<<<<<
9835  *             out[nnz] += ans*vec[nnz]
9836  *             nnz += 1
9837  */
9838       __pyx_v_ans = __Pyx_c_diff_double(__pyx_v_val, __Pyx_c_prod_double(__pyx_t_double_complex_from_parts(0, 1.0), __pyx_t_double_complex_from_parts((__pyx_v_diags[__pyx_v_jj]), 0)));
9839 
9840       /* "qutip/cy/brtools.pyx":303
9841  *         for jj in range(nrows):
9842  *             ans = val - 1j*diags[jj]
9843  *             out[nnz] += ans*vec[nnz]             # <<<<<<<<<<<<<<
9844  *             nnz += 1
9845  *
9846  */
9847       __pyx_t_7 = __pyx_v_nnz;
9848       (__pyx_v_out[__pyx_t_7]) = __Pyx_c_sum_double((__pyx_v_out[__pyx_t_7]), __Pyx_c_prod_double(__pyx_v_ans, (__pyx_v_vec[__pyx_v_nnz])));
9849 
9850       /* "qutip/cy/brtools.pyx":304
9851  *             ans = val - 1j*diags[jj]
9852  *             out[nnz] += ans*vec[nnz]
9853  *             nnz += 1             # <<<<<<<<<<<<<<
9854  *
9855  *
9856  */
9857       __pyx_v_nnz = (__pyx_v_nnz + 1);
9858     }
9859   }
9860 
9861   /* "qutip/cy/brtools.pyx":278
9862  * @cython.boundscheck(False)
9863  * @cython.wraparound(False)
9864  * cdef void diag_liou_mult(double * diags, double complex * vec,             # <<<<<<<<<<<<<<
9865  *                         double complex * out, unsigned int nrows) nogil:
9866  *     """
9867  */
9868 
9869   /* function exit code */
9870 }
9871 
9872 /* "qutip/cy/brtools.pyx":309
9873  * @cython.boundscheck(False)
9874  * @cython.wraparound(False)
9875  * cdef double complex * ZGEMM(double complex * A, double complex * B,             # <<<<<<<<<<<<<<
9876  *          int Arows, int Acols, int Brows, int Bcols,
9877  *          int transA = 0, int transB = 0,
9878  */
9879 
__pyx_f_5qutip_2cy_7brtools_ZGEMM(__pyx_t_double_complex * __pyx_v_A,__pyx_t_double_complex * __pyx_v_B,int __pyx_v_Arows,int __pyx_v_Acols,int __pyx_v_Brows,int __pyx_v_Bcols,struct __pyx_opt_args_5qutip_2cy_7brtools_ZGEMM * __pyx_optional_args)9880 static __pyx_t_double_complex *__pyx_f_5qutip_2cy_7brtools_ZGEMM(__pyx_t_double_complex *__pyx_v_A, __pyx_t_double_complex *__pyx_v_B, int __pyx_v_Arows, int __pyx_v_Acols, int __pyx_v_Brows, int __pyx_v_Bcols, struct __pyx_opt_args_5qutip_2cy_7brtools_ZGEMM *__pyx_optional_args) {
9881   int __pyx_v_transA = ((int)0);
9882   int __pyx_v_transB = ((int)0);
9883   __pyx_t_double_complex __pyx_v_alpha = __pyx_k__13;
9884   __pyx_t_double_complex __pyx_v_beta = __pyx_k__14;
9885   __pyx_t_double_complex *__pyx_v_C;
9886   char __pyx_v_tA;
9887   char __pyx_v_tB;
9888   __pyx_t_double_complex *__pyx_r;
9889   __Pyx_RefNannyDeclarations
9890   PyObject *__pyx_t_1 = NULL;
9891   int __pyx_lineno = 0;
9892   const char *__pyx_filename = NULL;
9893   int __pyx_clineno = 0;
9894   __Pyx_RefNannySetupContext("ZGEMM", 0);
9895   if (__pyx_optional_args) {
9896     if (__pyx_optional_args->__pyx_n > 0) {
9897       __pyx_v_transA = __pyx_optional_args->transA;
9898       if (__pyx_optional_args->__pyx_n > 1) {
9899         __pyx_v_transB = __pyx_optional_args->transB;
9900         if (__pyx_optional_args->__pyx_n > 2) {
9901           __pyx_v_alpha = __pyx_optional_args->alpha;
9902           if (__pyx_optional_args->__pyx_n > 3) {
9903             __pyx_v_beta = __pyx_optional_args->beta;
9904           }
9905         }
9906       }
9907     }
9908   }
9909 
9910   /* "qutip/cy/brtools.pyx":313
9911  *          int transA = 0, int transB = 0,
9912  *          double complex alpha = 1, double complex beta = 0):
9913  *     cdef double complex * C = <double complex *>PyDataMem_NEW((Acols*Brows)*sizeof(double complex))             # <<<<<<<<<<<<<<
9914  *     cdef char tA, tB
9915  *     if transA == 0:
9916  */
9917   __pyx_v_C = ((__pyx_t_double_complex *)PyDataMem_NEW(((__pyx_v_Acols * __pyx_v_Brows) * (sizeof(__pyx_t_double_complex)))));
9918 
9919   /* "qutip/cy/brtools.pyx":315
9920  *     cdef double complex * C = <double complex *>PyDataMem_NEW((Acols*Brows)*sizeof(double complex))
9921  *     cdef char tA, tB
9922  *     if transA == 0:             # <<<<<<<<<<<<<<
9923  *         tA = b'N'
9924  *     elif transA == 1:
9925  */
9926   switch (__pyx_v_transA) {
9927     case 0:
9928 
9929     /* "qutip/cy/brtools.pyx":316
9930  *     cdef char tA, tB
9931  *     if transA == 0:
9932  *         tA = b'N'             # <<<<<<<<<<<<<<
9933  *     elif transA == 1:
9934  *         tA = b'T'
9935  */
9936     __pyx_v_tA = 'N';
9937 
9938     /* "qutip/cy/brtools.pyx":315
9939  *     cdef double complex * C = <double complex *>PyDataMem_NEW((Acols*Brows)*sizeof(double complex))
9940  *     cdef char tA, tB
9941  *     if transA == 0:             # <<<<<<<<<<<<<<
9942  *         tA = b'N'
9943  *     elif transA == 1:
9944  */
9945     break;
9946     case 1:
9947 
9948     /* "qutip/cy/brtools.pyx":318
9949  *         tA = b'N'
9950  *     elif transA == 1:
9951  *         tA = b'T'             # <<<<<<<<<<<<<<
9952  *     elif transA == 2:
9953  *         tA = b'C'
9954  */
9955     __pyx_v_tA = 'T';
9956 
9957     /* "qutip/cy/brtools.pyx":317
9958  *     if transA == 0:
9959  *         tA = b'N'
9960  *     elif transA == 1:             # <<<<<<<<<<<<<<
9961  *         tA = b'T'
9962  *     elif transA == 2:
9963  */
9964     break;
9965     case 2:
9966 
9967     /* "qutip/cy/brtools.pyx":320
9968  *         tA = b'T'
9969  *     elif transA == 2:
9970  *         tA = b'C'             # <<<<<<<<<<<<<<
9971  *     else:
9972  *         raise Exception('Invalid transA value.')
9973  */
9974     __pyx_v_tA = 'C';
9975 
9976     /* "qutip/cy/brtools.pyx":319
9977  *     elif transA == 1:
9978  *         tA = b'T'
9979  *     elif transA == 2:             # <<<<<<<<<<<<<<
9980  *         tA = b'C'
9981  *     else:
9982  */
9983     break;
9984     default:
9985 
9986     /* "qutip/cy/brtools.pyx":322
9987  *         tA = b'C'
9988  *     else:
9989  *         raise Exception('Invalid transA value.')             # <<<<<<<<<<<<<<
9990  *     if transB == 0:
9991  *         tB = b'N'
9992  */
9993     __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)(&((PyTypeObject*)PyExc_Exception)[0])), __pyx_tuple__15, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 322, __pyx_L1_error)
9994     __Pyx_GOTREF(__pyx_t_1);
9995     __Pyx_Raise(__pyx_t_1, 0, 0, 0);
9996     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
9997     __PYX_ERR(1, 322, __pyx_L1_error)
9998     break;
9999   }
10000 
10001   /* "qutip/cy/brtools.pyx":323
10002  *     else:
10003  *         raise Exception('Invalid transA value.')
10004  *     if transB == 0:             # <<<<<<<<<<<<<<
10005  *         tB = b'N'
10006  *     elif transB == 1:
10007  */
10008   switch (__pyx_v_transB) {
10009     case 0:
10010 
10011     /* "qutip/cy/brtools.pyx":324
10012  *         raise Exception('Invalid transA value.')
10013  *     if transB == 0:
10014  *         tB = b'N'             # <<<<<<<<<<<<<<
10015  *     elif transB == 1:
10016  *         tB = b'T'
10017  */
10018     __pyx_v_tB = 'N';
10019 
10020     /* "qutip/cy/brtools.pyx":323
10021  *     else:
10022  *         raise Exception('Invalid transA value.')
10023  *     if transB == 0:             # <<<<<<<<<<<<<<
10024  *         tB = b'N'
10025  *     elif transB == 1:
10026  */
10027     break;
10028     case 1:
10029 
10030     /* "qutip/cy/brtools.pyx":326
10031  *         tB = b'N'
10032  *     elif transB == 1:
10033  *         tB = b'T'             # <<<<<<<<<<<<<<
10034  *     elif transB == 2:
10035  *         tB = b'C'
10036  */
10037     __pyx_v_tB = 'T';
10038 
10039     /* "qutip/cy/brtools.pyx":325
10040  *     if transB == 0:
10041  *         tB = b'N'
10042  *     elif transB == 1:             # <<<<<<<<<<<<<<
10043  *         tB = b'T'
10044  *     elif transB == 2:
10045  */
10046     break;
10047     case 2:
10048 
10049     /* "qutip/cy/brtools.pyx":328
10050  *         tB = b'T'
10051  *     elif transB == 2:
10052  *         tB = b'C'             # <<<<<<<<<<<<<<
10053  *     else:
10054  *         raise Exception('Invalid transB value.')
10055  */
10056     __pyx_v_tB = 'C';
10057 
10058     /* "qutip/cy/brtools.pyx":327
10059  *     elif transB == 1:
10060  *         tB = b'T'
10061  *     elif transB == 2:             # <<<<<<<<<<<<<<
10062  *         tB = b'C'
10063  *     else:
10064  */
10065     break;
10066     default:
10067 
10068     /* "qutip/cy/brtools.pyx":330
10069  *         tB = b'C'
10070  *     else:
10071  *         raise Exception('Invalid transB value.')             # <<<<<<<<<<<<<<
10072  *
10073  *     zgemm(&tA, &tB, &Arows, &Bcols, &Brows, &alpha, A, &Arows, B, &Brows, &beta, C, &Arows)
10074  */
10075     __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)(&((PyTypeObject*)PyExc_Exception)[0])), __pyx_tuple__16, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 330, __pyx_L1_error)
10076     __Pyx_GOTREF(__pyx_t_1);
10077     __Pyx_Raise(__pyx_t_1, 0, 0, 0);
10078     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
10079     __PYX_ERR(1, 330, __pyx_L1_error)
10080     break;
10081   }
10082 
10083   /* "qutip/cy/brtools.pyx":332
10084  *         raise Exception('Invalid transB value.')
10085  *
10086  *     zgemm(&tA, &tB, &Arows, &Bcols, &Brows, &alpha, A, &Arows, B, &Brows, &beta, C, &Arows)             # <<<<<<<<<<<<<<
10087  *     return C
10088  *
10089  */
10090   __pyx_f_5scipy_6linalg_11cython_blas_zgemm((&__pyx_v_tA), (&__pyx_v_tB), (&__pyx_v_Arows), (&__pyx_v_Bcols), (&__pyx_v_Brows), (&__pyx_v_alpha), __pyx_v_A, (&__pyx_v_Arows), __pyx_v_B, (&__pyx_v_Brows), (&__pyx_v_beta), __pyx_v_C, (&__pyx_v_Arows));
10091 
10092   /* "qutip/cy/brtools.pyx":333
10093  *
10094  *     zgemm(&tA, &tB, &Arows, &Bcols, &Brows, &alpha, A, &Arows, B, &Brows, &beta, C, &Arows)
10095  *     return C             # <<<<<<<<<<<<<<
10096  *
10097  * @cython.boundscheck(False)
10098  */
10099   __pyx_r = __pyx_v_C;
10100   goto __pyx_L0;
10101 
10102   /* "qutip/cy/brtools.pyx":309
10103  * @cython.boundscheck(False)
10104  * @cython.wraparound(False)
10105  * cdef double complex * ZGEMM(double complex * A, double complex * B,             # <<<<<<<<<<<<<<
10106  *          int Arows, int Acols, int Brows, int Bcols,
10107  *          int transA = 0, int transB = 0,
10108  */
10109 
10110   /* function exit code */
10111   __pyx_L1_error:;
10112   __Pyx_XDECREF(__pyx_t_1);
10113   __Pyx_WriteUnraisable("qutip.cy.brtools.ZGEMM", __pyx_clineno, __pyx_lineno, __pyx_filename, 1, 0);
10114   __pyx_r = 0;
10115   __pyx_L0:;
10116   __Pyx_RefNannyFinishContext();
10117   return __pyx_r;
10118 }
10119 
10120 /* "qutip/cy/brtools.pyx":337
10121  * @cython.boundscheck(False)
10122  * @cython.wraparound(False)
10123  * cdef void ZGEMV(double complex * A, double complex * vec,             # <<<<<<<<<<<<<<
10124  *                         double complex * out,
10125  *                        int Arows, int Acols, int transA = 0,
10126  */
10127 
__pyx_f_5qutip_2cy_7brtools_ZGEMV(__pyx_t_double_complex * __pyx_v_A,__pyx_t_double_complex * __pyx_v_vec,__pyx_t_double_complex * __pyx_v_out,int __pyx_v_Arows,int __pyx_v_Acols,struct __pyx_opt_args_5qutip_2cy_7brtools_ZGEMV * __pyx_optional_args)10128 static void __pyx_f_5qutip_2cy_7brtools_ZGEMV(__pyx_t_double_complex *__pyx_v_A, __pyx_t_double_complex *__pyx_v_vec, __pyx_t_double_complex *__pyx_v_out, int __pyx_v_Arows, int __pyx_v_Acols, struct __pyx_opt_args_5qutip_2cy_7brtools_ZGEMV *__pyx_optional_args) {
10129   int __pyx_v_transA = ((int)0);
10130   __pyx_t_double_complex __pyx_v_alpha = __pyx_k__17;
10131   __pyx_t_double_complex __pyx_v_beta = __pyx_k__18;
10132   char __pyx_v_tA;
10133   int __pyx_v_idx;
10134   int __pyx_v_idy;
10135   __Pyx_RefNannyDeclarations
10136   PyObject *__pyx_t_1 = NULL;
10137   int __pyx_lineno = 0;
10138   const char *__pyx_filename = NULL;
10139   int __pyx_clineno = 0;
10140   __Pyx_RefNannySetupContext("ZGEMV", 0);
10141   if (__pyx_optional_args) {
10142     if (__pyx_optional_args->__pyx_n > 0) {
10143       __pyx_v_transA = __pyx_optional_args->transA;
10144       if (__pyx_optional_args->__pyx_n > 1) {
10145         __pyx_v_alpha = __pyx_optional_args->alpha;
10146         if (__pyx_optional_args->__pyx_n > 2) {
10147           __pyx_v_beta = __pyx_optional_args->beta;
10148         }
10149       }
10150     }
10151   }
10152 
10153   /* "qutip/cy/brtools.pyx":342
10154  *                        double complex alpha=1, double complex beta=1):
10155  *     cdef char tA
10156  *     cdef int idx = 1, idy = 1             # <<<<<<<<<<<<<<
10157  *     if transA == 0:
10158  *         tA = b'N'
10159  */
10160   __pyx_v_idx = 1;
10161   __pyx_v_idy = 1;
10162 
10163   /* "qutip/cy/brtools.pyx":343
10164  *     cdef char tA
10165  *     cdef int idx = 1, idy = 1
10166  *     if transA == 0:             # <<<<<<<<<<<<<<
10167  *         tA = b'N'
10168  *     elif transA == 1:
10169  */
10170   switch (__pyx_v_transA) {
10171     case 0:
10172 
10173     /* "qutip/cy/brtools.pyx":344
10174  *     cdef int idx = 1, idy = 1
10175  *     if transA == 0:
10176  *         tA = b'N'             # <<<<<<<<<<<<<<
10177  *     elif transA == 1:
10178  *         tA = b'T'
10179  */
10180     __pyx_v_tA = 'N';
10181 
10182     /* "qutip/cy/brtools.pyx":343
10183  *     cdef char tA
10184  *     cdef int idx = 1, idy = 1
10185  *     if transA == 0:             # <<<<<<<<<<<<<<
10186  *         tA = b'N'
10187  *     elif transA == 1:
10188  */
10189     break;
10190     case 1:
10191 
10192     /* "qutip/cy/brtools.pyx":346
10193  *         tA = b'N'
10194  *     elif transA == 1:
10195  *         tA = b'T'             # <<<<<<<<<<<<<<
10196  *     elif transA == 2:
10197  *         tA = b'C'
10198  */
10199     __pyx_v_tA = 'T';
10200 
10201     /* "qutip/cy/brtools.pyx":345
10202  *     if transA == 0:
10203  *         tA = b'N'
10204  *     elif transA == 1:             # <<<<<<<<<<<<<<
10205  *         tA = b'T'
10206  *     elif transA == 2:
10207  */
10208     break;
10209     case 2:
10210 
10211     /* "qutip/cy/brtools.pyx":348
10212  *         tA = b'T'
10213  *     elif transA == 2:
10214  *         tA = b'C'             # <<<<<<<<<<<<<<
10215  *     else:
10216  *         raise Exception('Invalid transA value.')
10217  */
10218     __pyx_v_tA = 'C';
10219 
10220     /* "qutip/cy/brtools.pyx":347
10221  *     elif transA == 1:
10222  *         tA = b'T'
10223  *     elif transA == 2:             # <<<<<<<<<<<<<<
10224  *         tA = b'C'
10225  *     else:
10226  */
10227     break;
10228     default:
10229 
10230     /* "qutip/cy/brtools.pyx":350
10231  *         tA = b'C'
10232  *     else:
10233  *         raise Exception('Invalid transA value.')             # <<<<<<<<<<<<<<
10234  *     zgemv(&tA, &Arows, &Acols, &alpha, A, &Arows, vec, &idx, &beta, out, &idy)
10235  *
10236  */
10237     __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)(&((PyTypeObject*)PyExc_Exception)[0])), __pyx_tuple__15, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 350, __pyx_L1_error)
10238     __Pyx_GOTREF(__pyx_t_1);
10239     __Pyx_Raise(__pyx_t_1, 0, 0, 0);
10240     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
10241     __PYX_ERR(1, 350, __pyx_L1_error)
10242     break;
10243   }
10244 
10245   /* "qutip/cy/brtools.pyx":351
10246  *     else:
10247  *         raise Exception('Invalid transA value.')
10248  *     zgemv(&tA, &Arows, &Acols, &alpha, A, &Arows, vec, &idx, &beta, out, &idy)             # <<<<<<<<<<<<<<
10249  *
10250  *
10251  */
10252   __pyx_f_5scipy_6linalg_11cython_blas_zgemv((&__pyx_v_tA), (&__pyx_v_Arows), (&__pyx_v_Acols), (&__pyx_v_alpha), __pyx_v_A, (&__pyx_v_Arows), __pyx_v_vec, (&__pyx_v_idx), (&__pyx_v_beta), __pyx_v_out, (&__pyx_v_idy));
10253 
10254   /* "qutip/cy/brtools.pyx":337
10255  * @cython.boundscheck(False)
10256  * @cython.wraparound(False)
10257  * cdef void ZGEMV(double complex * A, double complex * vec,             # <<<<<<<<<<<<<<
10258  *                         double complex * out,
10259  *                        int Arows, int Acols, int transA = 0,
10260  */
10261 
10262   /* function exit code */
10263   goto __pyx_L0;
10264   __pyx_L1_error:;
10265   __Pyx_XDECREF(__pyx_t_1);
10266   __Pyx_WriteUnraisable("qutip.cy.brtools.ZGEMV", __pyx_clineno, __pyx_lineno, __pyx_filename, 1, 0);
10267   __pyx_L0:;
10268   __Pyx_RefNannyFinishContext();
10269 }
10270 
10271 /* "qutip/cy/brtools.pyx":357
10272  * @cython.boundscheck(False)
10273  * @cython.wraparound(False)
10274  * cdef complex[::1,:] dense_to_eigbasis(complex[::1,:] A, complex[::1,:] evecs,             # <<<<<<<<<<<<<<
10275  *                                     unsigned int nrows,
10276  *                                     double atol):
10277  */
10278 
__pyx_f_5qutip_2cy_7brtools_dense_to_eigbasis(__Pyx_memviewslice __pyx_v_A,__Pyx_memviewslice __pyx_v_evecs,unsigned int __pyx_v_nrows,double __pyx_v_atol)10279 static __Pyx_memviewslice __pyx_f_5qutip_2cy_7brtools_dense_to_eigbasis(__Pyx_memviewslice __pyx_v_A, __Pyx_memviewslice __pyx_v_evecs, unsigned int __pyx_v_nrows, double __pyx_v_atol) {
10280   int __pyx_v_kk;
10281   __pyx_t_double_complex *__pyx_v_temp1;
10282   __pyx_t_double_complex *__pyx_v_eig_mat;
10283   __Pyx_memviewslice __pyx_v_out = { 0, 0, { 0 }, { 0 }, { 0 } };
10284   __Pyx_memviewslice __pyx_v_out_f = { 0, 0, { 0 }, { 0 }, { 0 } };
10285   __Pyx_memviewslice __pyx_r = { 0, 0, { 0 }, { 0 }, { 0 } };
10286   __Pyx_RefNannyDeclarations
10287   Py_ssize_t __pyx_t_1;
10288   Py_ssize_t __pyx_t_2;
10289   Py_ssize_t __pyx_t_3;
10290   Py_ssize_t __pyx_t_4;
10291   __pyx_t_double_complex *__pyx_t_5;
10292   struct __pyx_opt_args_5qutip_2cy_7brtools_ZGEMM __pyx_t_6;
10293   long __pyx_t_7;
10294   long __pyx_t_8;
10295   int __pyx_t_9;
10296   int __pyx_t_10;
10297   struct __pyx_array_obj *__pyx_t_11 = NULL;
10298   PyObject *__pyx_t_12 = NULL;
10299   PyObject *__pyx_t_13 = NULL;
10300   __Pyx_memviewslice __pyx_t_14 = { 0, 0, { 0 }, { 0 }, { 0 } };
10301   __Pyx_memviewslice __pyx_t_15 = { 0, 0, { 0 }, { 0 }, { 0 } };
10302   int __pyx_lineno = 0;
10303   const char *__pyx_filename = NULL;
10304   int __pyx_clineno = 0;
10305   __Pyx_RefNannySetupContext("dense_to_eigbasis", 0);
10306 
10307   /* "qutip/cy/brtools.pyx":361
10308  *                                     double atol):
10309  *     cdef int kk
10310  *     cdef double complex * temp1 = ZGEMM(&A[0,0], &evecs[0,0],             # <<<<<<<<<<<<<<
10311  *                                        nrows, nrows, nrows, nrows, 0, 0)
10312  *     cdef double complex * eig_mat = ZGEMM(&evecs[0,0], temp1,
10313  */
10314   __pyx_t_1 = 0;
10315   __pyx_t_2 = 0;
10316   __pyx_t_3 = 0;
10317   __pyx_t_4 = 0;
10318 
10319   /* "qutip/cy/brtools.pyx":362
10320  *     cdef int kk
10321  *     cdef double complex * temp1 = ZGEMM(&A[0,0], &evecs[0,0],
10322  *                                        nrows, nrows, nrows, nrows, 0, 0)             # <<<<<<<<<<<<<<
10323  *     cdef double complex * eig_mat = ZGEMM(&evecs[0,0], temp1,
10324  *                                        nrows, nrows, nrows, nrows, 2, 0)
10325  */
10326   __pyx_t_6.__pyx_n = 2;
10327   __pyx_t_6.transA = 0;
10328   __pyx_t_6.transB = 0;
10329   __pyx_t_5 = __pyx_f_5qutip_2cy_7brtools_ZGEMM((&(*((__pyx_t_double_complex *) ( /* dim=1 */ (( /* dim=0 */ ((char *) (((__pyx_t_double_complex *) __pyx_v_A.data) + __pyx_t_1)) ) + __pyx_t_2 * __pyx_v_A.strides[1]) )))), (&(*((__pyx_t_double_complex *) ( /* dim=1 */ (( /* dim=0 */ ((char *) (((__pyx_t_double_complex *) __pyx_v_evecs.data) + __pyx_t_3)) ) + __pyx_t_4 * __pyx_v_evecs.strides[1]) )))), __pyx_v_nrows, __pyx_v_nrows, __pyx_v_nrows, __pyx_v_nrows, &__pyx_t_6);
10330   __pyx_v_temp1 = __pyx_t_5;
10331 
10332   /* "qutip/cy/brtools.pyx":363
10333  *     cdef double complex * temp1 = ZGEMM(&A[0,0], &evecs[0,0],
10334  *                                        nrows, nrows, nrows, nrows, 0, 0)
10335  *     cdef double complex * eig_mat = ZGEMM(&evecs[0,0], temp1,             # <<<<<<<<<<<<<<
10336  *                                        nrows, nrows, nrows, nrows, 2, 0)
10337  *     PyDataMem_FREE(temp1)
10338  */
10339   __pyx_t_4 = 0;
10340   __pyx_t_3 = 0;
10341 
10342   /* "qutip/cy/brtools.pyx":364
10343  *                                        nrows, nrows, nrows, nrows, 0, 0)
10344  *     cdef double complex * eig_mat = ZGEMM(&evecs[0,0], temp1,
10345  *                                        nrows, nrows, nrows, nrows, 2, 0)             # <<<<<<<<<<<<<<
10346  *     PyDataMem_FREE(temp1)
10347  *     #Get view on ouput
10348  */
10349   __pyx_t_6.__pyx_n = 2;
10350   __pyx_t_6.transA = 2;
10351   __pyx_t_6.transB = 0;
10352   __pyx_t_5 = __pyx_f_5qutip_2cy_7brtools_ZGEMM((&(*((__pyx_t_double_complex *) ( /* dim=1 */ (( /* dim=0 */ ((char *) (((__pyx_t_double_complex *) __pyx_v_evecs.data) + __pyx_t_4)) ) + __pyx_t_3 * __pyx_v_evecs.strides[1]) )))), __pyx_v_temp1, __pyx_v_nrows, __pyx_v_nrows, __pyx_v_nrows, __pyx_v_nrows, &__pyx_t_6);
10353   __pyx_v_eig_mat = __pyx_t_5;
10354 
10355   /* "qutip/cy/brtools.pyx":365
10356  *     cdef double complex * eig_mat = ZGEMM(&evecs[0,0], temp1,
10357  *                                        nrows, nrows, nrows, nrows, 2, 0)
10358  *     PyDataMem_FREE(temp1)             # <<<<<<<<<<<<<<
10359  *     #Get view on ouput
10360  *     # Find all small elements and set to zero
10361  */
10362   PyDataMem_FREE(__pyx_v_temp1);
10363 
10364   /* "qutip/cy/brtools.pyx":368
10365  *     #Get view on ouput
10366  *     # Find all small elements and set to zero
10367  *     for kk in range(nrows**2):             # <<<<<<<<<<<<<<
10368  *         if cabs(eig_mat[kk]) < atol:
10369  *             eig_mat[kk] = 0
10370  */
10371   __pyx_t_7 = __Pyx_pow_long(((long)__pyx_v_nrows), 2);
10372   __pyx_t_8 = __pyx_t_7;
10373   for (__pyx_t_9 = 0; __pyx_t_9 < __pyx_t_8; __pyx_t_9+=1) {
10374     __pyx_v_kk = __pyx_t_9;
10375 
10376     /* "qutip/cy/brtools.pyx":369
10377  *     # Find all small elements and set to zero
10378  *     for kk in range(nrows**2):
10379  *         if cabs(eig_mat[kk]) < atol:             # <<<<<<<<<<<<<<
10380  *             eig_mat[kk] = 0
10381  *     cdef complex[:,::1] out = <complex[:nrows, :nrows]> eig_mat
10382  */
10383     __pyx_t_10 = ((abs((__pyx_v_eig_mat[__pyx_v_kk])) < __pyx_v_atol) != 0);
10384     if (__pyx_t_10) {
10385 
10386       /* "qutip/cy/brtools.pyx":370
10387  *     for kk in range(nrows**2):
10388  *         if cabs(eig_mat[kk]) < atol:
10389  *             eig_mat[kk] = 0             # <<<<<<<<<<<<<<
10390  *     cdef complex[:,::1] out = <complex[:nrows, :nrows]> eig_mat
10391  *     #This just gets the correct f-ordered view on the data
10392  */
10393       (__pyx_v_eig_mat[__pyx_v_kk]) = __pyx_t_double_complex_from_parts(0, 0);
10394 
10395       /* "qutip/cy/brtools.pyx":369
10396  *     # Find all small elements and set to zero
10397  *     for kk in range(nrows**2):
10398  *         if cabs(eig_mat[kk]) < atol:             # <<<<<<<<<<<<<<
10399  *             eig_mat[kk] = 0
10400  *     cdef complex[:,::1] out = <complex[:nrows, :nrows]> eig_mat
10401  */
10402     }
10403   }
10404 
10405   /* "qutip/cy/brtools.pyx":371
10406  *         if cabs(eig_mat[kk]) < atol:
10407  *             eig_mat[kk] = 0
10408  *     cdef complex[:,::1] out = <complex[:nrows, :nrows]> eig_mat             # <<<<<<<<<<<<<<
10409  *     #This just gets the correct f-ordered view on the data
10410  *     cdef complex[::1,:] out_f = out.T
10411  */
10412   if (!__pyx_v_eig_mat) {
10413     PyErr_SetString(PyExc_ValueError,"Cannot create cython.array from NULL pointer");
10414     __PYX_ERR(1, 371, __pyx_L1_error)
10415   }
10416   __pyx_t_13 = __pyx_format_from_typeinfo(&__Pyx_TypeInfo___pyx_t_double_complex); if (unlikely(!__pyx_t_13)) __PYX_ERR(1, 371, __pyx_L1_error)
10417   __Pyx_GOTREF(__pyx_t_13);
10418   __pyx_t_12 = Py_BuildValue((char*) "("  __PYX_BUILD_PY_SSIZE_T  __PYX_BUILD_PY_SSIZE_T  ")", ((Py_ssize_t)__pyx_v_nrows), ((Py_ssize_t)__pyx_v_nrows)); if (unlikely(!__pyx_t_12)) __PYX_ERR(1, 371, __pyx_L1_error)
10419   __Pyx_GOTREF(__pyx_t_12);
10420   __pyx_t_11 = __pyx_array_new(__pyx_t_12, sizeof(__pyx_t_double_complex), PyBytes_AS_STRING(__pyx_t_13), (char *) "c", (char *) __pyx_v_eig_mat);
10421   if (unlikely(!__pyx_t_11)) __PYX_ERR(1, 371, __pyx_L1_error)
10422   __Pyx_GOTREF(__pyx_t_11);
10423   __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
10424   __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
10425   __pyx_t_14 = __Pyx_PyObject_to_MemoryviewSlice_d_dc___pyx_t_double_complex(((PyObject *)__pyx_t_11), PyBUF_WRITABLE); if (unlikely(!__pyx_t_14.memview)) __PYX_ERR(1, 371, __pyx_L1_error)
10426   __Pyx_DECREF(((PyObject *)__pyx_t_11)); __pyx_t_11 = 0;
10427   __pyx_v_out = __pyx_t_14;
10428   __pyx_t_14.memview = NULL;
10429   __pyx_t_14.data = NULL;
10430 
10431   /* "qutip/cy/brtools.pyx":373
10432  *     cdef complex[:,::1] out = <complex[:nrows, :nrows]> eig_mat
10433  *     #This just gets the correct f-ordered view on the data
10434  *     cdef complex[::1,:] out_f = out.T             # <<<<<<<<<<<<<<
10435  *     return out_f
10436  *
10437  */
10438   __pyx_t_15 = __pyx_v_out;
10439   __PYX_INC_MEMVIEW(&__pyx_t_15, 1);
10440   if (unlikely(__pyx_memslice_transpose(&__pyx_t_15) == 0)) __PYX_ERR(1, 373, __pyx_L1_error)
10441   __pyx_v_out_f = __pyx_t_15;
10442   __pyx_t_15.memview = NULL;
10443   __pyx_t_15.data = NULL;
10444 
10445   /* "qutip/cy/brtools.pyx":374
10446  *     #This just gets the correct f-ordered view on the data
10447  *     cdef complex[::1,:] out_f = out.T
10448  *     return out_f             # <<<<<<<<<<<<<<
10449  *
10450  *
10451  */
10452   __PYX_INC_MEMVIEW(&__pyx_v_out_f, 0);
10453   __pyx_r = __pyx_v_out_f;
10454   goto __pyx_L0;
10455 
10456   /* "qutip/cy/brtools.pyx":357
10457  * @cython.boundscheck(False)
10458  * @cython.wraparound(False)
10459  * cdef complex[::1,:] dense_to_eigbasis(complex[::1,:] A, complex[::1,:] evecs,             # <<<<<<<<<<<<<<
10460  *                                     unsigned int nrows,
10461  *                                     double atol):
10462  */
10463 
10464   /* function exit code */
10465   __pyx_L1_error:;
10466   __Pyx_XDECREF(((PyObject *)__pyx_t_11));
10467   __Pyx_XDECREF(__pyx_t_12);
10468   __Pyx_XDECREF(__pyx_t_13);
10469   __PYX_XDEC_MEMVIEW(&__pyx_t_14, 1);
10470   __PYX_XDEC_MEMVIEW(&__pyx_t_15, 1);
10471   __pyx_r.data = NULL;
10472   __pyx_r.memview = NULL;
10473   __Pyx_AddTraceback("qutip.cy.brtools.dense_to_eigbasis", __pyx_clineno, __pyx_lineno, __pyx_filename);
10474   goto __pyx_L2;
10475   __pyx_L0:;
10476   if (unlikely(!__pyx_r.memview)) {
10477     PyErr_SetString(PyExc_TypeError, "Memoryview return value is not initialized");
10478   }
10479   __pyx_L2:;
10480   __PYX_XDEC_MEMVIEW(&__pyx_v_out, 1);
10481   __PYX_XDEC_MEMVIEW(&__pyx_v_out_f, 1);
10482   __Pyx_RefNannyFinishContext();
10483   return __pyx_r;
10484 }
10485 
10486 /* "qutip/cy/brtools.pyx":379
10487  * @cython.boundscheck(False)
10488  * @cython.wraparound(False)
10489  * cdef double complex * vec_to_eigbasis(complex[::1] vec, complex[::1,:] evecs,             # <<<<<<<<<<<<<<
10490  *                                     unsigned int nrows):
10491  *
10492  */
10493 
__pyx_f_5qutip_2cy_7brtools_vec_to_eigbasis(__Pyx_memviewslice __pyx_v_vec,__Pyx_memviewslice __pyx_v_evecs,unsigned int __pyx_v_nrows)10494 static __pyx_t_double_complex *__pyx_f_5qutip_2cy_7brtools_vec_to_eigbasis(__Pyx_memviewslice __pyx_v_vec, __Pyx_memviewslice __pyx_v_evecs, unsigned int __pyx_v_nrows) {
10495   __pyx_t_double_complex *__pyx_v_temp1;
10496   __pyx_t_double_complex *__pyx_v_eig_vec;
10497   __pyx_t_double_complex *__pyx_r;
10498   __Pyx_RefNannyDeclarations
10499   Py_ssize_t __pyx_t_1;
10500   Py_ssize_t __pyx_t_2;
10501   Py_ssize_t __pyx_t_3;
10502   __pyx_t_double_complex *__pyx_t_4;
10503   struct __pyx_opt_args_5qutip_2cy_7brtools_ZGEMM __pyx_t_5;
10504   __Pyx_RefNannySetupContext("vec_to_eigbasis", 0);
10505 
10506   /* "qutip/cy/brtools.pyx":383
10507  *
10508  *     cdef size_t ii, jj
10509  *     cdef double complex * temp1 = ZGEMM(&vec[0], &evecs[0,0],             # <<<<<<<<<<<<<<
10510  *                                        nrows, nrows, nrows, nrows, 0, 0)
10511  *     cdef double complex * eig_vec = ZGEMM(&evecs[0,0], temp1,
10512  */
10513   __pyx_t_1 = 0;
10514   __pyx_t_2 = 0;
10515   __pyx_t_3 = 0;
10516 
10517   /* "qutip/cy/brtools.pyx":384
10518  *     cdef size_t ii, jj
10519  *     cdef double complex * temp1 = ZGEMM(&vec[0], &evecs[0,0],
10520  *                                        nrows, nrows, nrows, nrows, 0, 0)             # <<<<<<<<<<<<<<
10521  *     cdef double complex * eig_vec = ZGEMM(&evecs[0,0], temp1,
10522  *                                        nrows, nrows, nrows, nrows, 2, 0)
10523  */
10524   __pyx_t_5.__pyx_n = 2;
10525   __pyx_t_5.transA = 0;
10526   __pyx_t_5.transB = 0;
10527   __pyx_t_4 = __pyx_f_5qutip_2cy_7brtools_ZGEMM((&(*((__pyx_t_double_complex *) ( /* dim=0 */ ((char *) (((__pyx_t_double_complex *) __pyx_v_vec.data) + __pyx_t_1)) )))), (&(*((__pyx_t_double_complex *) ( /* dim=1 */ (( /* dim=0 */ ((char *) (((__pyx_t_double_complex *) __pyx_v_evecs.data) + __pyx_t_2)) ) + __pyx_t_3 * __pyx_v_evecs.strides[1]) )))), __pyx_v_nrows, __pyx_v_nrows, __pyx_v_nrows, __pyx_v_nrows, &__pyx_t_5);
10528   __pyx_v_temp1 = __pyx_t_4;
10529 
10530   /* "qutip/cy/brtools.pyx":385
10531  *     cdef double complex * temp1 = ZGEMM(&vec[0], &evecs[0,0],
10532  *                                        nrows, nrows, nrows, nrows, 0, 0)
10533  *     cdef double complex * eig_vec = ZGEMM(&evecs[0,0], temp1,             # <<<<<<<<<<<<<<
10534  *                                        nrows, nrows, nrows, nrows, 2, 0)
10535  *     PyDataMem_FREE(temp1)
10536  */
10537   __pyx_t_3 = 0;
10538   __pyx_t_2 = 0;
10539 
10540   /* "qutip/cy/brtools.pyx":386
10541  *                                        nrows, nrows, nrows, nrows, 0, 0)
10542  *     cdef double complex * eig_vec = ZGEMM(&evecs[0,0], temp1,
10543  *                                        nrows, nrows, nrows, nrows, 2, 0)             # <<<<<<<<<<<<<<
10544  *     PyDataMem_FREE(temp1)
10545  *     return eig_vec
10546  */
10547   __pyx_t_5.__pyx_n = 2;
10548   __pyx_t_5.transA = 2;
10549   __pyx_t_5.transB = 0;
10550   __pyx_t_4 = __pyx_f_5qutip_2cy_7brtools_ZGEMM((&(*((__pyx_t_double_complex *) ( /* dim=1 */ (( /* dim=0 */ ((char *) (((__pyx_t_double_complex *) __pyx_v_evecs.data) + __pyx_t_3)) ) + __pyx_t_2 * __pyx_v_evecs.strides[1]) )))), __pyx_v_temp1, __pyx_v_nrows, __pyx_v_nrows, __pyx_v_nrows, __pyx_v_nrows, &__pyx_t_5);
10551   __pyx_v_eig_vec = __pyx_t_4;
10552 
10553   /* "qutip/cy/brtools.pyx":387
10554  *     cdef double complex * eig_vec = ZGEMM(&evecs[0,0], temp1,
10555  *                                        nrows, nrows, nrows, nrows, 2, 0)
10556  *     PyDataMem_FREE(temp1)             # <<<<<<<<<<<<<<
10557  *     return eig_vec
10558  *
10559  */
10560   PyDataMem_FREE(__pyx_v_temp1);
10561 
10562   /* "qutip/cy/brtools.pyx":388
10563  *                                        nrows, nrows, nrows, nrows, 2, 0)
10564  *     PyDataMem_FREE(temp1)
10565  *     return eig_vec             # <<<<<<<<<<<<<<
10566  *
10567  *
10568  */
10569   __pyx_r = __pyx_v_eig_vec;
10570   goto __pyx_L0;
10571 
10572   /* "qutip/cy/brtools.pyx":379
10573  * @cython.boundscheck(False)
10574  * @cython.wraparound(False)
10575  * cdef double complex * vec_to_eigbasis(complex[::1] vec, complex[::1,:] evecs,             # <<<<<<<<<<<<<<
10576  *                                     unsigned int nrows):
10577  *
10578  */
10579 
10580   /* function exit code */
10581   __pyx_L0:;
10582   __Pyx_RefNannyFinishContext();
10583   return __pyx_r;
10584 }
10585 
10586 /* "qutip/cy/brtools.pyx":393
10587  * @cython.boundscheck(False)
10588  * @cython.wraparound(False)
10589  * cdef np.ndarray[complex, ndim=1, mode='c'] vec_to_fockbasis(double complex * eig_vec,             # <<<<<<<<<<<<<<
10590  *                                                 complex[::1,:] evecs,
10591  *                                                 unsigned int nrows):
10592  */
10593 
__pyx_f_5qutip_2cy_7brtools_vec_to_fockbasis(__pyx_t_double_complex * __pyx_v_eig_vec,__Pyx_memviewslice __pyx_v_evecs,unsigned int __pyx_v_nrows)10594 static PyArrayObject *__pyx_f_5qutip_2cy_7brtools_vec_to_fockbasis(__pyx_t_double_complex *__pyx_v_eig_vec, __Pyx_memviewslice __pyx_v_evecs, unsigned int __pyx_v_nrows) {
10595   npy_intp __pyx_v_nrows2;
10596   __pyx_t_double_complex *__pyx_v_temp1;
10597   __pyx_t_double_complex *__pyx_v_fock_vec;
10598   PyArrayObject *__pyx_v_out = 0;
10599   __Pyx_LocalBuf_ND __pyx_pybuffernd_out;
10600   __Pyx_Buffer __pyx_pybuffer_out;
10601   PyArrayObject *__pyx_r = NULL;
10602   __Pyx_RefNannyDeclarations
10603   Py_ssize_t __pyx_t_1;
10604   Py_ssize_t __pyx_t_2;
10605   __pyx_t_double_complex *__pyx_t_3;
10606   struct __pyx_opt_args_5qutip_2cy_7brtools_ZGEMM __pyx_t_4;
10607   PyObject *__pyx_t_5 = NULL;
10608   PyArrayObject *__pyx_t_6 = NULL;
10609   int __pyx_lineno = 0;
10610   const char *__pyx_filename = NULL;
10611   int __pyx_clineno = 0;
10612   __Pyx_RefNannySetupContext("vec_to_fockbasis", 0);
10613   __pyx_pybuffer_out.pybuffer.buf = NULL;
10614   __pyx_pybuffer_out.refcount = 0;
10615   __pyx_pybuffernd_out.data = NULL;
10616   __pyx_pybuffernd_out.rcbuffer = &__pyx_pybuffer_out;
10617 
10618   /* "qutip/cy/brtools.pyx":398
10619  *
10620  *     cdef size_t ii, jj
10621  *     cdef np.npy_intp nrows2 = nrows**2             # <<<<<<<<<<<<<<
10622  *     cdef double complex * temp1 = ZGEMM(&eig_vec[0], &evecs[0,0],
10623  *                                        nrows, nrows, nrows, nrows, 0, 2)
10624  */
10625   __pyx_v_nrows2 = __Pyx_pow_long(((long)__pyx_v_nrows), 2);
10626 
10627   /* "qutip/cy/brtools.pyx":399
10628  *     cdef size_t ii, jj
10629  *     cdef np.npy_intp nrows2 = nrows**2
10630  *     cdef double complex * temp1 = ZGEMM(&eig_vec[0], &evecs[0,0],             # <<<<<<<<<<<<<<
10631  *                                        nrows, nrows, nrows, nrows, 0, 2)
10632  *     cdef double complex * fock_vec = ZGEMM(&evecs[0,0], temp1,
10633  */
10634   __pyx_t_1 = 0;
10635   __pyx_t_2 = 0;
10636 
10637   /* "qutip/cy/brtools.pyx":400
10638  *     cdef np.npy_intp nrows2 = nrows**2
10639  *     cdef double complex * temp1 = ZGEMM(&eig_vec[0], &evecs[0,0],
10640  *                                        nrows, nrows, nrows, nrows, 0, 2)             # <<<<<<<<<<<<<<
10641  *     cdef double complex * fock_vec = ZGEMM(&evecs[0,0], temp1,
10642  *                                        nrows, nrows, nrows, nrows, 0, 0)
10643  */
10644   __pyx_t_4.__pyx_n = 2;
10645   __pyx_t_4.transA = 0;
10646   __pyx_t_4.transB = 2;
10647   __pyx_t_3 = __pyx_f_5qutip_2cy_7brtools_ZGEMM((&(__pyx_v_eig_vec[0])), (&(*((__pyx_t_double_complex *) ( /* dim=1 */ (( /* dim=0 */ ((char *) (((__pyx_t_double_complex *) __pyx_v_evecs.data) + __pyx_t_1)) ) + __pyx_t_2 * __pyx_v_evecs.strides[1]) )))), __pyx_v_nrows, __pyx_v_nrows, __pyx_v_nrows, __pyx_v_nrows, &__pyx_t_4);
10648   __pyx_v_temp1 = __pyx_t_3;
10649 
10650   /* "qutip/cy/brtools.pyx":401
10651  *     cdef double complex * temp1 = ZGEMM(&eig_vec[0], &evecs[0,0],
10652  *                                        nrows, nrows, nrows, nrows, 0, 2)
10653  *     cdef double complex * fock_vec = ZGEMM(&evecs[0,0], temp1,             # <<<<<<<<<<<<<<
10654  *                                        nrows, nrows, nrows, nrows, 0, 0)
10655  *     PyDataMem_FREE(temp1)
10656  */
10657   __pyx_t_2 = 0;
10658   __pyx_t_1 = 0;
10659 
10660   /* "qutip/cy/brtools.pyx":402
10661  *                                        nrows, nrows, nrows, nrows, 0, 2)
10662  *     cdef double complex * fock_vec = ZGEMM(&evecs[0,0], temp1,
10663  *                                        nrows, nrows, nrows, nrows, 0, 0)             # <<<<<<<<<<<<<<
10664  *     PyDataMem_FREE(temp1)
10665  *     cdef np.ndarray[complex, ndim=1, mode='c'] out = \
10666  */
10667   __pyx_t_4.__pyx_n = 2;
10668   __pyx_t_4.transA = 0;
10669   __pyx_t_4.transB = 0;
10670   __pyx_t_3 = __pyx_f_5qutip_2cy_7brtools_ZGEMM((&(*((__pyx_t_double_complex *) ( /* dim=1 */ (( /* dim=0 */ ((char *) (((__pyx_t_double_complex *) __pyx_v_evecs.data) + __pyx_t_2)) ) + __pyx_t_1 * __pyx_v_evecs.strides[1]) )))), __pyx_v_temp1, __pyx_v_nrows, __pyx_v_nrows, __pyx_v_nrows, __pyx_v_nrows, &__pyx_t_4);
10671   __pyx_v_fock_vec = __pyx_t_3;
10672 
10673   /* "qutip/cy/brtools.pyx":403
10674  *     cdef double complex * fock_vec = ZGEMM(&evecs[0,0], temp1,
10675  *                                        nrows, nrows, nrows, nrows, 0, 0)
10676  *     PyDataMem_FREE(temp1)             # <<<<<<<<<<<<<<
10677  *     cdef np.ndarray[complex, ndim=1, mode='c'] out = \
10678  *                 np.PyArray_SimpleNewFromData(1, &nrows2, np.NPY_COMPLEX128, fock_vec)
10679  */
10680   PyDataMem_FREE(__pyx_v_temp1);
10681 
10682   /* "qutip/cy/brtools.pyx":405
10683  *     PyDataMem_FREE(temp1)
10684  *     cdef np.ndarray[complex, ndim=1, mode='c'] out = \
10685  *                 np.PyArray_SimpleNewFromData(1, &nrows2, np.NPY_COMPLEX128, fock_vec)             # <<<<<<<<<<<<<<
10686  *     PyArray_ENABLEFLAGS(out, np.NPY_ARRAY_OWNDATA)
10687  *     return out
10688  */
10689   __pyx_t_5 = PyArray_SimpleNewFromData(1, (&__pyx_v_nrows2), NPY_COMPLEX128, __pyx_v_fock_vec); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 405, __pyx_L1_error)
10690   __Pyx_GOTREF(__pyx_t_5);
10691   if (!(likely(((__pyx_t_5) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_5, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(1, 405, __pyx_L1_error)
10692   __pyx_t_6 = ((PyArrayObject *)__pyx_t_5);
10693   {
10694     __Pyx_BufFmt_StackElem __pyx_stack[1];
10695     if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_out.rcbuffer->pybuffer, (PyObject*)__pyx_t_6, &__Pyx_TypeInfo___pyx_t_double_complex, PyBUF_FORMAT| PyBUF_C_CONTIGUOUS, 1, 0, __pyx_stack) == -1)) {
10696       __pyx_v_out = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_pybuffernd_out.rcbuffer->pybuffer.buf = NULL;
10697       __PYX_ERR(1, 404, __pyx_L1_error)
10698     } else {__pyx_pybuffernd_out.diminfo[0].strides = __pyx_pybuffernd_out.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_out.diminfo[0].shape = __pyx_pybuffernd_out.rcbuffer->pybuffer.shape[0];
10699     }
10700   }
10701   __pyx_t_6 = 0;
10702   __pyx_v_out = ((PyArrayObject *)__pyx_t_5);
10703   __pyx_t_5 = 0;
10704 
10705   /* "qutip/cy/brtools.pyx":406
10706  *     cdef np.ndarray[complex, ndim=1, mode='c'] out = \
10707  *                 np.PyArray_SimpleNewFromData(1, &nrows2, np.NPY_COMPLEX128, fock_vec)
10708  *     PyArray_ENABLEFLAGS(out, np.NPY_ARRAY_OWNDATA)             # <<<<<<<<<<<<<<
10709  *     return out
10710  *
10711  */
10712   PyArray_ENABLEFLAGS(((PyArrayObject *)__pyx_v_out), NPY_ARRAY_OWNDATA);
10713 
10714   /* "qutip/cy/brtools.pyx":407
10715  *                 np.PyArray_SimpleNewFromData(1, &nrows2, np.NPY_COMPLEX128, fock_vec)
10716  *     PyArray_ENABLEFLAGS(out, np.NPY_ARRAY_OWNDATA)
10717  *     return out             # <<<<<<<<<<<<<<
10718  *
10719  *
10720  */
10721   __Pyx_XDECREF(((PyObject *)__pyx_r));
10722   __Pyx_INCREF(((PyObject *)__pyx_v_out));
10723   __pyx_r = ((PyArrayObject *)__pyx_v_out);
10724   goto __pyx_L0;
10725 
10726   /* "qutip/cy/brtools.pyx":393
10727  * @cython.boundscheck(False)
10728  * @cython.wraparound(False)
10729  * cdef np.ndarray[complex, ndim=1, mode='c'] vec_to_fockbasis(double complex * eig_vec,             # <<<<<<<<<<<<<<
10730  *                                                 complex[::1,:] evecs,
10731  *                                                 unsigned int nrows):
10732  */
10733 
10734   /* function exit code */
10735   __pyx_L1_error:;
10736   __Pyx_XDECREF(__pyx_t_5);
10737   { PyObject *__pyx_type, *__pyx_value, *__pyx_tb;
10738     __Pyx_PyThreadState_declare
10739     __Pyx_PyThreadState_assign
10740     __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb);
10741     __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_out.rcbuffer->pybuffer);
10742   __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}
10743   __Pyx_AddTraceback("qutip.cy.brtools.vec_to_fockbasis", __pyx_clineno, __pyx_lineno, __pyx_filename);
10744   __pyx_r = 0;
10745   goto __pyx_L2;
10746   __pyx_L0:;
10747   __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_out.rcbuffer->pybuffer);
10748   __pyx_L2:;
10749   __Pyx_XDECREF((PyObject *)__pyx_v_out);
10750   __Pyx_XGIVEREF((PyObject *)__pyx_r);
10751   __Pyx_RefNannyFinishContext();
10752   return __pyx_r;
10753 }
10754 
10755 /* "qutip/cy/brtools.pyx":413
10756  * @cython.boundscheck(False)
10757  * @cython.wraparound(False)
10758  * cpdef cop_super_term(complex[::1,:] cop, complex[::1,:] evecs,             # <<<<<<<<<<<<<<
10759  *                      double complex alpha, unsigned int nrows,
10760  *                      double atol):
10761  */
10762 
10763 static PyObject *__pyx_pw_5qutip_2cy_7brtools_5cop_super_term(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
__pyx_f_5qutip_2cy_7brtools_cop_super_term(__Pyx_memviewslice __pyx_v_cop,__Pyx_memviewslice __pyx_v_evecs,__pyx_t_double_complex __pyx_v_alpha,unsigned int __pyx_v_nrows,double __pyx_v_atol,CYTHON_UNUSED int __pyx_skip_dispatch)10764 static PyObject *__pyx_f_5qutip_2cy_7brtools_cop_super_term(__Pyx_memviewslice __pyx_v_cop, __Pyx_memviewslice __pyx_v_evecs, __pyx_t_double_complex __pyx_v_alpha, unsigned int __pyx_v_nrows, double __pyx_v_atol, CYTHON_UNUSED int __pyx_skip_dispatch) {
10765   size_t __pyx_v_kk;
10766   __pyx_t_5qutip_2cy_14sparse_structs_CSR_Matrix __pyx_v_mat1;
10767   __pyx_t_5qutip_2cy_14sparse_structs_CSR_Matrix __pyx_v_mat2;
10768   __pyx_t_5qutip_2cy_14sparse_structs_CSR_Matrix __pyx_v_mat3;
10769   __pyx_t_5qutip_2cy_14sparse_structs_CSR_Matrix __pyx_v_mat4;
10770   __pyx_t_5qutip_2cy_14sparse_structs_CSR_Matrix __pyx_v_mat5;
10771   __Pyx_memviewslice __pyx_v_cop_eig = { 0, 0, { 0 }, { 0 }, { 0 } };
10772   __pyx_t_double_complex *__pyx_v_conj_data;
10773   PyObject *__pyx_r = NULL;
10774   __Pyx_RefNannyDeclarations
10775   __Pyx_memviewslice __pyx_t_1 = { 0, 0, { 0 }, { 0 }, { 0 } };
10776   int __pyx_t_2;
10777   int __pyx_t_3;
10778   size_t __pyx_t_4;
10779   size_t __pyx_t_5;
10780   Py_ssize_t __pyx_t_6;
10781   Py_ssize_t __pyx_t_7;
10782   int __pyx_t_8;
10783   struct __pyx_opt_args_5qutip_2cy_7brtools_init_CSR __pyx_t_9;
10784   PyObject *__pyx_t_10 = NULL;
10785   int __pyx_lineno = 0;
10786   const char *__pyx_filename = NULL;
10787   int __pyx_clineno = 0;
10788   __Pyx_RefNannySetupContext("cop_super_term", 0);
10789 
10790   /* "qutip/cy/brtools.pyx":419
10791  *     cdef CSR_Matrix mat1, mat2, mat3, mat4, mat5
10792  *
10793  *     cdef complex[::1,:] cop_eig = dense_to_eigbasis(cop, evecs, nrows, atol)             # <<<<<<<<<<<<<<
10794  *
10795  *     fdense2D_to_CSR(cop_eig, &mat1, nrows, nrows)
10796  */
10797   __pyx_t_1 = __pyx_f_5qutip_2cy_7brtools_dense_to_eigbasis(__pyx_v_cop, __pyx_v_evecs, __pyx_v_nrows, __pyx_v_atol); if (unlikely(!__pyx_t_1.memview)) __PYX_ERR(1, 419, __pyx_L1_error)
10798   __pyx_v_cop_eig = __pyx_t_1;
10799   __pyx_t_1.memview = NULL;
10800   __pyx_t_1.data = NULL;
10801 
10802   /* "qutip/cy/brtools.pyx":421
10803  *     cdef complex[::1,:] cop_eig = dense_to_eigbasis(cop, evecs, nrows, atol)
10804  *
10805  *     fdense2D_to_CSR(cop_eig, &mat1, nrows, nrows)             # <<<<<<<<<<<<<<
10806  *     #Multiply by alpha for time-dependence
10807  *     for kk in range(mat1.nnz):
10808  */
10809   __pyx_f_5qutip_2cy_9spconvert_fdense2D_to_CSR(__pyx_v_cop_eig, (&__pyx_v_mat1), __pyx_v_nrows, __pyx_v_nrows);
10810 
10811   /* "qutip/cy/brtools.pyx":423
10812  *     fdense2D_to_CSR(cop_eig, &mat1, nrows, nrows)
10813  *     #Multiply by alpha for time-dependence
10814  *     for kk in range(mat1.nnz):             # <<<<<<<<<<<<<<
10815  *         mat1.data[kk] *= alpha
10816  *
10817  */
10818   __pyx_t_2 = __pyx_v_mat1.nnz;
10819   __pyx_t_3 = __pyx_t_2;
10820   for (__pyx_t_4 = 0; __pyx_t_4 < __pyx_t_3; __pyx_t_4+=1) {
10821     __pyx_v_kk = __pyx_t_4;
10822 
10823     /* "qutip/cy/brtools.pyx":424
10824  *     #Multiply by alpha for time-dependence
10825  *     for kk in range(mat1.nnz):
10826  *         mat1.data[kk] *= alpha             # <<<<<<<<<<<<<<
10827  *
10828  *     #Free data associated with cop_eig as it is no longer needed.
10829  */
10830     __pyx_t_5 = __pyx_v_kk;
10831     (__pyx_v_mat1.data[__pyx_t_5]) = __Pyx_c_prod_double((__pyx_v_mat1.data[__pyx_t_5]), __pyx_v_alpha);
10832   }
10833 
10834   /* "qutip/cy/brtools.pyx":427
10835  *
10836  *     #Free data associated with cop_eig as it is no longer needed.
10837  *     PyDataMem_FREE(&cop_eig[0,0])             # <<<<<<<<<<<<<<
10838  *
10839  *     #create temp array of conj data for cop_eig_sparse
10840  */
10841   __pyx_t_6 = 0;
10842   __pyx_t_7 = 0;
10843   PyDataMem_FREE((&(*((__pyx_t_double_complex *) ( /* dim=1 */ (( /* dim=0 */ ((char *) (((__pyx_t_double_complex *) __pyx_v_cop_eig.data) + __pyx_t_6)) ) + __pyx_t_7 * __pyx_v_cop_eig.strides[1]) )))));
10844 
10845   /* "qutip/cy/brtools.pyx":430
10846  *
10847  *     #create temp array of conj data for cop_eig_sparse
10848  *     cdef complex * conj_data = <complex *>PyDataMem_NEW(mat1.nnz * sizeof(complex))             # <<<<<<<<<<<<<<
10849  *     for kk in range(mat1.nnz):
10850  *         conj_data[kk] = conj(mat1.data[kk])
10851  */
10852   __pyx_v_conj_data = ((__pyx_t_double_complex *)PyDataMem_NEW((__pyx_v_mat1.nnz * (sizeof(__pyx_t_double_complex)))));
10853 
10854   /* "qutip/cy/brtools.pyx":431
10855  *     #create temp array of conj data for cop_eig_sparse
10856  *     cdef complex * conj_data = <complex *>PyDataMem_NEW(mat1.nnz * sizeof(complex))
10857  *     for kk in range(mat1.nnz):             # <<<<<<<<<<<<<<
10858  *         conj_data[kk] = conj(mat1.data[kk])
10859  *
10860  */
10861   __pyx_t_2 = __pyx_v_mat1.nnz;
10862   __pyx_t_3 = __pyx_t_2;
10863   for (__pyx_t_4 = 0; __pyx_t_4 < __pyx_t_3; __pyx_t_4+=1) {
10864     __pyx_v_kk = __pyx_t_4;
10865 
10866     /* "qutip/cy/brtools.pyx":432
10867  *     cdef complex * conj_data = <complex *>PyDataMem_NEW(mat1.nnz * sizeof(complex))
10868  *     for kk in range(mat1.nnz):
10869  *         conj_data[kk] = conj(mat1.data[kk])             # <<<<<<<<<<<<<<
10870  *
10871  *
10872  */
10873     (__pyx_v_conj_data[__pyx_v_kk]) = std::conj((__pyx_v_mat1.data[__pyx_v_kk]));
10874   }
10875 
10876   /* "qutip/cy/brtools.pyx":437
10877  *     #mat2 holds data for kron(cop.dag(), c)
10878  *     init_CSR(&mat2,
10879  *              _safe_multiply(mat1.nnz, mat1.nnz),             # <<<<<<<<<<<<<<
10880  *              _safe_multiply(mat1.nrows, mat1.nrows),
10881  *              _safe_multiply(mat1.ncols, mat1.ncols))
10882  */
10883   __pyx_t_2 = __pyx_f_5qutip_2cy_6spmath__safe_multiply(__pyx_v_mat1.nnz, __pyx_v_mat1.nnz); if (unlikely(__pyx_t_2 == ((int)-1) && PyErr_Occurred())) __PYX_ERR(1, 437, __pyx_L1_error)
10884 
10885   /* "qutip/cy/brtools.pyx":438
10886  *     init_CSR(&mat2,
10887  *              _safe_multiply(mat1.nnz, mat1.nnz),
10888  *              _safe_multiply(mat1.nrows, mat1.nrows),             # <<<<<<<<<<<<<<
10889  *              _safe_multiply(mat1.ncols, mat1.ncols))
10890  *     _zcsr_kron_core(conj_data, mat1.indices, mat1.indptr,
10891  */
10892   __pyx_t_3 = __pyx_f_5qutip_2cy_6spmath__safe_multiply(__pyx_v_mat1.nrows, __pyx_v_mat1.nrows); if (unlikely(__pyx_t_3 == ((int)-1) && PyErr_Occurred())) __PYX_ERR(1, 438, __pyx_L1_error)
10893 
10894   /* "qutip/cy/brtools.pyx":439
10895  *              _safe_multiply(mat1.nnz, mat1.nnz),
10896  *              _safe_multiply(mat1.nrows, mat1.nrows),
10897  *              _safe_multiply(mat1.ncols, mat1.ncols))             # <<<<<<<<<<<<<<
10898  *     _zcsr_kron_core(conj_data, mat1.indices, mat1.indptr,
10899  *                    mat1.data, mat1.indices, mat1.indptr,
10900  */
10901   __pyx_t_8 = __pyx_f_5qutip_2cy_6spmath__safe_multiply(__pyx_v_mat1.ncols, __pyx_v_mat1.ncols); if (unlikely(__pyx_t_8 == ((int)-1) && PyErr_Occurred())) __PYX_ERR(1, 439, __pyx_L1_error)
10902 
10903   /* "qutip/cy/brtools.pyx":436
10904  *
10905  *     #mat2 holds data for kron(cop.dag(), c)
10906  *     init_CSR(&mat2,             # <<<<<<<<<<<<<<
10907  *              _safe_multiply(mat1.nnz, mat1.nnz),
10908  *              _safe_multiply(mat1.nrows, mat1.nrows),
10909  */
10910   __pyx_t_9.__pyx_n = 1;
10911   __pyx_t_9.ncols = __pyx_t_8;
10912   __pyx_f_5qutip_2cy_7brtools_init_CSR((&__pyx_v_mat2), __pyx_t_2, __pyx_t_3, &__pyx_t_9);
10913 
10914   /* "qutip/cy/brtools.pyx":440
10915  *              _safe_multiply(mat1.nrows, mat1.nrows),
10916  *              _safe_multiply(mat1.ncols, mat1.ncols))
10917  *     _zcsr_kron_core(conj_data, mat1.indices, mat1.indptr,             # <<<<<<<<<<<<<<
10918  *                    mat1.data, mat1.indices, mat1.indptr,
10919  *                    &mat2,
10920  */
10921   __pyx_f_5qutip_2cy_6spmath__zcsr_kron_core(__pyx_v_conj_data, __pyx_v_mat1.indices, __pyx_v_mat1.indptr, __pyx_v_mat1.data, __pyx_v_mat1.indices, __pyx_v_mat1.indptr, (&__pyx_v_mat2), __pyx_v_mat1.nrows, __pyx_v_mat1.nrows, __pyx_v_mat1.ncols);
10922 
10923   /* "qutip/cy/brtools.pyx":446
10924  *
10925  *     #Free temp conj_data array
10926  *     PyDataMem_FREE(conj_data)             # <<<<<<<<<<<<<<
10927  *     #Create identity in mat3
10928  *     identity_CSR(&mat3, nrows)
10929  */
10930   PyDataMem_FREE(__pyx_v_conj_data);
10931 
10932   /* "qutip/cy/brtools.pyx":448
10933  *     PyDataMem_FREE(conj_data)
10934  *     #Create identity in mat3
10935  *     identity_CSR(&mat3, nrows)             # <<<<<<<<<<<<<<
10936  *     #Take adjoint cop.H -> mat4
10937  *     _zcsr_adjoint(&mat1, &mat4)
10938  */
10939   __pyx_f_5qutip_2cy_7brtools_identity_CSR((&__pyx_v_mat3), __pyx_v_nrows);
10940 
10941   /* "qutip/cy/brtools.pyx":450
10942  *     identity_CSR(&mat3, nrows)
10943  *     #Take adjoint cop.H -> mat4
10944  *     _zcsr_adjoint(&mat1, &mat4)             # <<<<<<<<<<<<<<
10945  *     #multiply cop.dag() * c -> mat5
10946  *     _zcsr_mult(&mat4, &mat1, &mat5)
10947  */
10948   __pyx_f_5qutip_2cy_6spmath__zcsr_adjoint((&__pyx_v_mat1), (&__pyx_v_mat4));
10949 
10950   /* "qutip/cy/brtools.pyx":452
10951  *     _zcsr_adjoint(&mat1, &mat4)
10952  *     #multiply cop.dag() * c -> mat5
10953  *     _zcsr_mult(&mat4, &mat1, &mat5)             # <<<<<<<<<<<<<<
10954  *     #Free mat1 and mat 4 as we will reuse
10955  *     free_CSR(&mat1)
10956  */
10957   __pyx_f_5qutip_2cy_6spmath__zcsr_mult((&__pyx_v_mat4), (&__pyx_v_mat1), (&__pyx_v_mat5));
10958 
10959   /* "qutip/cy/brtools.pyx":454
10960  *     _zcsr_mult(&mat4, &mat1, &mat5)
10961  *     #Free mat1 and mat 4 as we will reuse
10962  *     free_CSR(&mat1)             # <<<<<<<<<<<<<<
10963  *     free_CSR(&mat4)
10964  *     # kron(eye, cdc) -> mat1
10965  */
10966   __pyx_f_5qutip_2cy_7brtools_free_CSR((&__pyx_v_mat1));
10967 
10968   /* "qutip/cy/brtools.pyx":455
10969  *     #Free mat1 and mat 4 as we will reuse
10970  *     free_CSR(&mat1)
10971  *     free_CSR(&mat4)             # <<<<<<<<<<<<<<
10972  *     # kron(eye, cdc) -> mat1
10973  *     _zcsr_kron(&mat3, &mat5, &mat1)
10974  */
10975   __pyx_f_5qutip_2cy_7brtools_free_CSR((&__pyx_v_mat4));
10976 
10977   /* "qutip/cy/brtools.pyx":457
10978  *     free_CSR(&mat4)
10979  *     # kron(eye, cdc) -> mat1
10980  *     _zcsr_kron(&mat3, &mat5, &mat1)             # <<<<<<<<<<<<<<
10981  *     # Add data from mat2 - 0.5 * cop_sparse -> mat4
10982  *     _zcsr_add(&mat2, &mat1, &mat4, -0.5)
10983  */
10984   __pyx_f_5qutip_2cy_6spmath__zcsr_kron((&__pyx_v_mat3), (&__pyx_v_mat5), (&__pyx_v_mat1)); if (unlikely(PyErr_Occurred())) __PYX_ERR(1, 457, __pyx_L1_error)
10985 
10986   /* "qutip/cy/brtools.pyx":459
10987  *     _zcsr_kron(&mat3, &mat5, &mat1)
10988  *     # Add data from mat2 - 0.5 * cop_sparse -> mat4
10989  *     _zcsr_add(&mat2, &mat1, &mat4, -0.5)             # <<<<<<<<<<<<<<
10990  *     #Free mat1 and mat2 now
10991  *     free_CSR(&mat1)
10992  */
10993   __pyx_f_5qutip_2cy_6spmath__zcsr_add((&__pyx_v_mat2), (&__pyx_v_mat1), (&__pyx_v_mat4), __pyx_t_double_complex_from_parts(-0.5, 0));
10994 
10995   /* "qutip/cy/brtools.pyx":461
10996  *     _zcsr_add(&mat2, &mat1, &mat4, -0.5)
10997  *     #Free mat1 and mat2 now
10998  *     free_CSR(&mat1)             # <<<<<<<<<<<<<<
10999  *     free_CSR(&mat2)
11000  *     #Take traspose of cdc -> mat1
11001  */
11002   __pyx_f_5qutip_2cy_7brtools_free_CSR((&__pyx_v_mat1));
11003 
11004   /* "qutip/cy/brtools.pyx":462
11005  *     #Free mat1 and mat2 now
11006  *     free_CSR(&mat1)
11007  *     free_CSR(&mat2)             # <<<<<<<<<<<<<<
11008  *     #Take traspose of cdc -> mat1
11009  *     _zcsr_transpose(&mat5, &mat1)
11010  */
11011   __pyx_f_5qutip_2cy_7brtools_free_CSR((&__pyx_v_mat2));
11012 
11013   /* "qutip/cy/brtools.pyx":464
11014  *     free_CSR(&mat2)
11015  *     #Take traspose of cdc -> mat1
11016  *     _zcsr_transpose(&mat5, &mat1)             # <<<<<<<<<<<<<<
11017  *     free_CSR(&mat5)
11018  *     # kron(cdct, eye) -> mat2
11019  */
11020   __pyx_f_5qutip_2cy_6spmath__zcsr_transpose((&__pyx_v_mat5), (&__pyx_v_mat1));
11021 
11022   /* "qutip/cy/brtools.pyx":465
11023  *     #Take traspose of cdc -> mat1
11024  *     _zcsr_transpose(&mat5, &mat1)
11025  *     free_CSR(&mat5)             # <<<<<<<<<<<<<<
11026  *     # kron(cdct, eye) -> mat2
11027  *     _zcsr_kron(&mat1, &mat3, &mat2)
11028  */
11029   __pyx_f_5qutip_2cy_7brtools_free_CSR((&__pyx_v_mat5));
11030 
11031   /* "qutip/cy/brtools.pyx":467
11032  *     free_CSR(&mat5)
11033  *     # kron(cdct, eye) -> mat2
11034  *     _zcsr_kron(&mat1, &mat3, &mat2)             # <<<<<<<<<<<<<<
11035  *     free_CSR(&mat3)
11036  *     # Add data from mat4 - 0.5 * mat2 -> mat1
11037  */
11038   __pyx_f_5qutip_2cy_6spmath__zcsr_kron((&__pyx_v_mat1), (&__pyx_v_mat3), (&__pyx_v_mat2)); if (unlikely(PyErr_Occurred())) __PYX_ERR(1, 467, __pyx_L1_error)
11039 
11040   /* "qutip/cy/brtools.pyx":468
11041  *     # kron(cdct, eye) -> mat2
11042  *     _zcsr_kron(&mat1, &mat3, &mat2)
11043  *     free_CSR(&mat3)             # <<<<<<<<<<<<<<
11044  *     # Add data from mat4 - 0.5 * mat2 -> mat1
11045  *     _zcsr_add(&mat4, &mat2, &mat1, -0.5)
11046  */
11047   __pyx_f_5qutip_2cy_7brtools_free_CSR((&__pyx_v_mat3));
11048 
11049   /* "qutip/cy/brtools.pyx":470
11050  *     free_CSR(&mat3)
11051  *     # Add data from mat4 - 0.5 * mat2 -> mat1
11052  *     _zcsr_add(&mat4, &mat2, &mat1, -0.5)             # <<<<<<<<<<<<<<
11053  *     free_CSR(&mat4)
11054  *     free_CSR(&mat2)
11055  */
11056   __pyx_f_5qutip_2cy_6spmath__zcsr_add((&__pyx_v_mat4), (&__pyx_v_mat2), (&__pyx_v_mat1), __pyx_t_double_complex_from_parts(-0.5, 0));
11057 
11058   /* "qutip/cy/brtools.pyx":471
11059  *     # Add data from mat4 - 0.5 * mat2 -> mat1
11060  *     _zcsr_add(&mat4, &mat2, &mat1, -0.5)
11061  *     free_CSR(&mat4)             # <<<<<<<<<<<<<<
11062  *     free_CSR(&mat2)
11063  *     return CSR_to_scipy(&mat1)
11064  */
11065   __pyx_f_5qutip_2cy_7brtools_free_CSR((&__pyx_v_mat4));
11066 
11067   /* "qutip/cy/brtools.pyx":472
11068  *     _zcsr_add(&mat4, &mat2, &mat1, -0.5)
11069  *     free_CSR(&mat4)
11070  *     free_CSR(&mat2)             # <<<<<<<<<<<<<<
11071  *     return CSR_to_scipy(&mat1)
11072  *
11073  */
11074   __pyx_f_5qutip_2cy_7brtools_free_CSR((&__pyx_v_mat2));
11075 
11076   /* "qutip/cy/brtools.pyx":473
11077  *     free_CSR(&mat4)
11078  *     free_CSR(&mat2)
11079  *     return CSR_to_scipy(&mat1)             # <<<<<<<<<<<<<<
11080  *
11081  *
11082  */
11083   __Pyx_XDECREF(__pyx_r);
11084   __pyx_t_10 = __pyx_f_5qutip_2cy_7brtools_CSR_to_scipy((&__pyx_v_mat1)); if (unlikely(!__pyx_t_10)) __PYX_ERR(1, 473, __pyx_L1_error)
11085   __Pyx_GOTREF(__pyx_t_10);
11086   __pyx_r = __pyx_t_10;
11087   __pyx_t_10 = 0;
11088   goto __pyx_L0;
11089 
11090   /* "qutip/cy/brtools.pyx":413
11091  * @cython.boundscheck(False)
11092  * @cython.wraparound(False)
11093  * cpdef cop_super_term(complex[::1,:] cop, complex[::1,:] evecs,             # <<<<<<<<<<<<<<
11094  *                      double complex alpha, unsigned int nrows,
11095  *                      double atol):
11096  */
11097 
11098   /* function exit code */
11099   __pyx_L1_error:;
11100   __PYX_XDEC_MEMVIEW(&__pyx_t_1, 1);
11101   __Pyx_XDECREF(__pyx_t_10);
11102   __Pyx_AddTraceback("qutip.cy.brtools.cop_super_term", __pyx_clineno, __pyx_lineno, __pyx_filename);
11103   __pyx_r = 0;
11104   __pyx_L0:;
11105   __PYX_XDEC_MEMVIEW(&__pyx_v_cop_eig, 1);
11106   __Pyx_XGIVEREF(__pyx_r);
11107   __Pyx_RefNannyFinishContext();
11108   return __pyx_r;
11109 }
11110 
11111 /* Python wrapper */
11112 static PyObject *__pyx_pw_5qutip_2cy_7brtools_5cop_super_term(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
__pyx_pw_5qutip_2cy_7brtools_5cop_super_term(PyObject * __pyx_self,PyObject * __pyx_args,PyObject * __pyx_kwds)11113 static PyObject *__pyx_pw_5qutip_2cy_7brtools_5cop_super_term(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
11114   __Pyx_memviewslice __pyx_v_cop = { 0, 0, { 0 }, { 0 }, { 0 } };
11115   __Pyx_memviewslice __pyx_v_evecs = { 0, 0, { 0 }, { 0 }, { 0 } };
11116   __pyx_t_double_complex __pyx_v_alpha;
11117   unsigned int __pyx_v_nrows;
11118   double __pyx_v_atol;
11119   int __pyx_lineno = 0;
11120   const char *__pyx_filename = NULL;
11121   int __pyx_clineno = 0;
11122   PyObject *__pyx_r = 0;
11123   __Pyx_RefNannyDeclarations
11124   __Pyx_RefNannySetupContext("cop_super_term (wrapper)", 0);
11125   {
11126     static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_cop,&__pyx_n_s_evecs,&__pyx_n_s_alpha,&__pyx_n_s_nrows,&__pyx_n_s_atol,0};
11127     PyObject* values[5] = {0,0,0,0,0};
11128     if (unlikely(__pyx_kwds)) {
11129       Py_ssize_t kw_args;
11130       const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
11131       switch (pos_args) {
11132         case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
11133         CYTHON_FALLTHROUGH;
11134         case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
11135         CYTHON_FALLTHROUGH;
11136         case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
11137         CYTHON_FALLTHROUGH;
11138         case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
11139         CYTHON_FALLTHROUGH;
11140         case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
11141         CYTHON_FALLTHROUGH;
11142         case  0: break;
11143         default: goto __pyx_L5_argtuple_error;
11144       }
11145       kw_args = PyDict_Size(__pyx_kwds);
11146       switch (pos_args) {
11147         case  0:
11148         if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_cop)) != 0)) kw_args--;
11149         else goto __pyx_L5_argtuple_error;
11150         CYTHON_FALLTHROUGH;
11151         case  1:
11152         if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_evecs)) != 0)) kw_args--;
11153         else {
11154           __Pyx_RaiseArgtupleInvalid("cop_super_term", 1, 5, 5, 1); __PYX_ERR(1, 413, __pyx_L3_error)
11155         }
11156         CYTHON_FALLTHROUGH;
11157         case  2:
11158         if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_alpha)) != 0)) kw_args--;
11159         else {
11160           __Pyx_RaiseArgtupleInvalid("cop_super_term", 1, 5, 5, 2); __PYX_ERR(1, 413, __pyx_L3_error)
11161         }
11162         CYTHON_FALLTHROUGH;
11163         case  3:
11164         if (likely((values[3] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_nrows)) != 0)) kw_args--;
11165         else {
11166           __Pyx_RaiseArgtupleInvalid("cop_super_term", 1, 5, 5, 3); __PYX_ERR(1, 413, __pyx_L3_error)
11167         }
11168         CYTHON_FALLTHROUGH;
11169         case  4:
11170         if (likely((values[4] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_atol)) != 0)) kw_args--;
11171         else {
11172           __Pyx_RaiseArgtupleInvalid("cop_super_term", 1, 5, 5, 4); __PYX_ERR(1, 413, __pyx_L3_error)
11173         }
11174       }
11175       if (unlikely(kw_args > 0)) {
11176         if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "cop_super_term") < 0)) __PYX_ERR(1, 413, __pyx_L3_error)
11177       }
11178     } else if (PyTuple_GET_SIZE(__pyx_args) != 5) {
11179       goto __pyx_L5_argtuple_error;
11180     } else {
11181       values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
11182       values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
11183       values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
11184       values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
11185       values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
11186     }
11187     __pyx_v_cop = __Pyx_PyObject_to_MemoryviewSlice_dcd____pyx_t_double_complex(values[0], PyBUF_WRITABLE); if (unlikely(!__pyx_v_cop.memview)) __PYX_ERR(1, 413, __pyx_L3_error)
11188     __pyx_v_evecs = __Pyx_PyObject_to_MemoryviewSlice_dcd____pyx_t_double_complex(values[1], PyBUF_WRITABLE); if (unlikely(!__pyx_v_evecs.memview)) __PYX_ERR(1, 413, __pyx_L3_error)
11189     __pyx_v_alpha = __Pyx_PyComplex_As___pyx_t_double_complex(values[2]); if (unlikely(PyErr_Occurred())) __PYX_ERR(1, 414, __pyx_L3_error)
11190     __pyx_v_nrows = __Pyx_PyInt_As_unsigned_int(values[3]); if (unlikely((__pyx_v_nrows == (unsigned int)-1) && PyErr_Occurred())) __PYX_ERR(1, 414, __pyx_L3_error)
11191     __pyx_v_atol = __pyx_PyFloat_AsDouble(values[4]); if (unlikely((__pyx_v_atol == (double)-1) && PyErr_Occurred())) __PYX_ERR(1, 415, __pyx_L3_error)
11192   }
11193   goto __pyx_L4_argument_unpacking_done;
11194   __pyx_L5_argtuple_error:;
11195   __Pyx_RaiseArgtupleInvalid("cop_super_term", 1, 5, 5, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(1, 413, __pyx_L3_error)
11196   __pyx_L3_error:;
11197   __Pyx_AddTraceback("qutip.cy.brtools.cop_super_term", __pyx_clineno, __pyx_lineno, __pyx_filename);
11198   __Pyx_RefNannyFinishContext();
11199   return NULL;
11200   __pyx_L4_argument_unpacking_done:;
11201   __pyx_r = __pyx_pf_5qutip_2cy_7brtools_4cop_super_term(__pyx_self, __pyx_v_cop, __pyx_v_evecs, __pyx_v_alpha, __pyx_v_nrows, __pyx_v_atol);
11202 
11203   /* function exit code */
11204   __Pyx_RefNannyFinishContext();
11205   return __pyx_r;
11206 }
11207 
__pyx_pf_5qutip_2cy_7brtools_4cop_super_term(CYTHON_UNUSED PyObject * __pyx_self,__Pyx_memviewslice __pyx_v_cop,__Pyx_memviewslice __pyx_v_evecs,__pyx_t_double_complex __pyx_v_alpha,unsigned int __pyx_v_nrows,double __pyx_v_atol)11208 static PyObject *__pyx_pf_5qutip_2cy_7brtools_4cop_super_term(CYTHON_UNUSED PyObject *__pyx_self, __Pyx_memviewslice __pyx_v_cop, __Pyx_memviewslice __pyx_v_evecs, __pyx_t_double_complex __pyx_v_alpha, unsigned int __pyx_v_nrows, double __pyx_v_atol) {
11209   PyObject *__pyx_r = NULL;
11210   __Pyx_RefNannyDeclarations
11211   PyObject *__pyx_t_1 = NULL;
11212   int __pyx_lineno = 0;
11213   const char *__pyx_filename = NULL;
11214   int __pyx_clineno = 0;
11215   __Pyx_RefNannySetupContext("cop_super_term", 0);
11216   __Pyx_XDECREF(__pyx_r);
11217   if (unlikely(!__pyx_v_cop.memview)) { __Pyx_RaiseUnboundLocalError("cop"); __PYX_ERR(1, 413, __pyx_L1_error) }
11218   if (unlikely(!__pyx_v_evecs.memview)) { __Pyx_RaiseUnboundLocalError("evecs"); __PYX_ERR(1, 413, __pyx_L1_error) }
11219   __pyx_t_1 = __pyx_f_5qutip_2cy_7brtools_cop_super_term(__pyx_v_cop, __pyx_v_evecs, __pyx_v_alpha, __pyx_v_nrows, __pyx_v_atol, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 413, __pyx_L1_error)
11220   __Pyx_GOTREF(__pyx_t_1);
11221   __pyx_r = __pyx_t_1;
11222   __pyx_t_1 = 0;
11223   goto __pyx_L0;
11224 
11225   /* function exit code */
11226   __pyx_L1_error:;
11227   __Pyx_XDECREF(__pyx_t_1);
11228   __Pyx_AddTraceback("qutip.cy.brtools.cop_super_term", __pyx_clineno, __pyx_lineno, __pyx_filename);
11229   __pyx_r = NULL;
11230   __pyx_L0:;
11231   __PYX_XDEC_MEMVIEW(&__pyx_v_cop, 1);
11232   __PYX_XDEC_MEMVIEW(&__pyx_v_evecs, 1);
11233   __Pyx_XGIVEREF(__pyx_r);
11234   __Pyx_RefNannyFinishContext();
11235   return __pyx_r;
11236 }
11237 
11238 /* "qutip/cy/brtools.pyx":479
11239  * @cython.boundscheck(False)
11240  * @cython.wraparound(False)
11241  * cdef void cop_super_mult(complex[::1,:] cop, complex[::1,:] evecs,             # <<<<<<<<<<<<<<
11242  *                      double complex * vec,
11243  *                      double complex alpha,
11244  */
11245 
__pyx_f_5qutip_2cy_7brtools_cop_super_mult(__Pyx_memviewslice __pyx_v_cop,__Pyx_memviewslice __pyx_v_evecs,__pyx_t_double_complex * __pyx_v_vec,__pyx_t_double_complex __pyx_v_alpha,__pyx_t_double_complex * __pyx_v_out,unsigned int __pyx_v_nrows,double __pyx_v_atol)11246 static void __pyx_f_5qutip_2cy_7brtools_cop_super_mult(__Pyx_memviewslice __pyx_v_cop, __Pyx_memviewslice __pyx_v_evecs, __pyx_t_double_complex *__pyx_v_vec, __pyx_t_double_complex __pyx_v_alpha, __pyx_t_double_complex *__pyx_v_out, unsigned int __pyx_v_nrows, double __pyx_v_atol) {
11247   size_t __pyx_v_kk;
11248   __pyx_t_5qutip_2cy_14sparse_structs_CSR_Matrix __pyx_v_mat1;
11249   __pyx_t_5qutip_2cy_14sparse_structs_CSR_Matrix __pyx_v_mat2;
11250   __pyx_t_5qutip_2cy_14sparse_structs_CSR_Matrix __pyx_v_mat3;
11251   __pyx_t_5qutip_2cy_14sparse_structs_CSR_Matrix __pyx_v_mat4;
11252   __Pyx_memviewslice __pyx_v_cop_eig = { 0, 0, { 0 }, { 0 }, { 0 } };
11253   __pyx_t_double_complex *__pyx_v_conj_data;
11254   __Pyx_RefNannyDeclarations
11255   __Pyx_memviewslice __pyx_t_1 = { 0, 0, { 0 }, { 0 }, { 0 } };
11256   int __pyx_t_2;
11257   int __pyx_t_3;
11258   size_t __pyx_t_4;
11259   size_t __pyx_t_5;
11260   Py_ssize_t __pyx_t_6;
11261   Py_ssize_t __pyx_t_7;
11262   int __pyx_t_8;
11263   struct __pyx_opt_args_5qutip_2cy_7brtools_init_CSR __pyx_t_9;
11264   int __pyx_lineno = 0;
11265   const char *__pyx_filename = NULL;
11266   int __pyx_clineno = 0;
11267   __Pyx_RefNannySetupContext("cop_super_mult", 0);
11268 
11269   /* "qutip/cy/brtools.pyx":488
11270  *     cdef CSR_Matrix mat1, mat2, mat3, mat4
11271  *
11272  *     cdef complex[::1,:] cop_eig = dense_to_eigbasis(cop, evecs, nrows, atol)             # <<<<<<<<<<<<<<
11273  *
11274  *     #Mat1 holds cop_eig in CSR format
11275  */
11276   __pyx_t_1 = __pyx_f_5qutip_2cy_7brtools_dense_to_eigbasis(__pyx_v_cop, __pyx_v_evecs, __pyx_v_nrows, __pyx_v_atol); if (unlikely(!__pyx_t_1.memview)) __PYX_ERR(1, 488, __pyx_L1_error)
11277   __pyx_v_cop_eig = __pyx_t_1;
11278   __pyx_t_1.memview = NULL;
11279   __pyx_t_1.data = NULL;
11280 
11281   /* "qutip/cy/brtools.pyx":491
11282  *
11283  *     #Mat1 holds cop_eig in CSR format
11284  *     fdense2D_to_CSR(cop_eig, &mat1, nrows, nrows)             # <<<<<<<<<<<<<<
11285  *
11286  *     #Multiply by alpha for time-dependence
11287  */
11288   __pyx_f_5qutip_2cy_9spconvert_fdense2D_to_CSR(__pyx_v_cop_eig, (&__pyx_v_mat1), __pyx_v_nrows, __pyx_v_nrows);
11289 
11290   /* "qutip/cy/brtools.pyx":494
11291  *
11292  *     #Multiply by alpha for time-dependence
11293  *     for kk in range(mat1.nnz):             # <<<<<<<<<<<<<<
11294  *         mat1.data[kk] *= alpha
11295  *
11296  */
11297   __pyx_t_2 = __pyx_v_mat1.nnz;
11298   __pyx_t_3 = __pyx_t_2;
11299   for (__pyx_t_4 = 0; __pyx_t_4 < __pyx_t_3; __pyx_t_4+=1) {
11300     __pyx_v_kk = __pyx_t_4;
11301 
11302     /* "qutip/cy/brtools.pyx":495
11303  *     #Multiply by alpha for time-dependence
11304  *     for kk in range(mat1.nnz):
11305  *         mat1.data[kk] *= alpha             # <<<<<<<<<<<<<<
11306  *
11307  *     #Free data associated with cop_eig as it is no longer needed.
11308  */
11309     __pyx_t_5 = __pyx_v_kk;
11310     (__pyx_v_mat1.data[__pyx_t_5]) = __Pyx_c_prod_double((__pyx_v_mat1.data[__pyx_t_5]), __pyx_v_alpha);
11311   }
11312 
11313   /* "qutip/cy/brtools.pyx":498
11314  *
11315  *     #Free data associated with cop_eig as it is no longer needed.
11316  *     PyDataMem_FREE(&cop_eig[0,0])             # <<<<<<<<<<<<<<
11317  *
11318  *     #create temp array of conj data for cop_eig_sparse
11319  */
11320   __pyx_t_6 = 0;
11321   __pyx_t_7 = 0;
11322   PyDataMem_FREE((&(*((__pyx_t_double_complex *) ( /* dim=1 */ (( /* dim=0 */ ((char *) (((__pyx_t_double_complex *) __pyx_v_cop_eig.data) + __pyx_t_6)) ) + __pyx_t_7 * __pyx_v_cop_eig.strides[1]) )))));
11323 
11324   /* "qutip/cy/brtools.pyx":501
11325  *
11326  *     #create temp array of conj data for cop_eig_sparse
11327  *     cdef complex * conj_data = <complex *>PyDataMem_NEW(mat1.nnz * sizeof(complex))             # <<<<<<<<<<<<<<
11328  *     for kk in range(mat1.nnz):
11329  *         conj_data[kk] = conj(mat1.data[kk])
11330  */
11331   __pyx_v_conj_data = ((__pyx_t_double_complex *)PyDataMem_NEW((__pyx_v_mat1.nnz * (sizeof(__pyx_t_double_complex)))));
11332 
11333   /* "qutip/cy/brtools.pyx":502
11334  *     #create temp array of conj data for cop_eig_sparse
11335  *     cdef complex * conj_data = <complex *>PyDataMem_NEW(mat1.nnz * sizeof(complex))
11336  *     for kk in range(mat1.nnz):             # <<<<<<<<<<<<<<
11337  *         conj_data[kk] = conj(mat1.data[kk])
11338  *
11339  */
11340   __pyx_t_2 = __pyx_v_mat1.nnz;
11341   __pyx_t_3 = __pyx_t_2;
11342   for (__pyx_t_4 = 0; __pyx_t_4 < __pyx_t_3; __pyx_t_4+=1) {
11343     __pyx_v_kk = __pyx_t_4;
11344 
11345     /* "qutip/cy/brtools.pyx":503
11346  *     cdef complex * conj_data = <complex *>PyDataMem_NEW(mat1.nnz * sizeof(complex))
11347  *     for kk in range(mat1.nnz):
11348  *         conj_data[kk] = conj(mat1.data[kk])             # <<<<<<<<<<<<<<
11349  *
11350  *     #mat2 holds data for kron(cop.dag(), c)
11351  */
11352     (__pyx_v_conj_data[__pyx_v_kk]) = std::conj((__pyx_v_mat1.data[__pyx_v_kk]));
11353   }
11354 
11355   /* "qutip/cy/brtools.pyx":508
11356  *     init_CSR(
11357  *         &mat2,
11358  *         _safe_multiply(mat1.nnz, mat1.nnz),             # <<<<<<<<<<<<<<
11359  *         _safe_multiply(mat1.nrows, mat1.nrows),
11360  *         _safe_multiply(mat1.ncols, mat1.ncols),
11361  */
11362   __pyx_t_2 = __pyx_f_5qutip_2cy_6spmath__safe_multiply(__pyx_v_mat1.nnz, __pyx_v_mat1.nnz); if (unlikely(__pyx_t_2 == ((int)-1) && PyErr_Occurred())) __PYX_ERR(1, 508, __pyx_L1_error)
11363 
11364   /* "qutip/cy/brtools.pyx":509
11365  *         &mat2,
11366  *         _safe_multiply(mat1.nnz, mat1.nnz),
11367  *         _safe_multiply(mat1.nrows, mat1.nrows),             # <<<<<<<<<<<<<<
11368  *         _safe_multiply(mat1.ncols, mat1.ncols),
11369  *     )
11370  */
11371   __pyx_t_3 = __pyx_f_5qutip_2cy_6spmath__safe_multiply(__pyx_v_mat1.nrows, __pyx_v_mat1.nrows); if (unlikely(__pyx_t_3 == ((int)-1) && PyErr_Occurred())) __PYX_ERR(1, 509, __pyx_L1_error)
11372 
11373   /* "qutip/cy/brtools.pyx":510
11374  *         _safe_multiply(mat1.nnz, mat1.nnz),
11375  *         _safe_multiply(mat1.nrows, mat1.nrows),
11376  *         _safe_multiply(mat1.ncols, mat1.ncols),             # <<<<<<<<<<<<<<
11377  *     )
11378  *     _zcsr_kron_core(conj_data, mat1.indices, mat1.indptr,
11379  */
11380   __pyx_t_8 = __pyx_f_5qutip_2cy_6spmath__safe_multiply(__pyx_v_mat1.ncols, __pyx_v_mat1.ncols); if (unlikely(__pyx_t_8 == ((int)-1) && PyErr_Occurred())) __PYX_ERR(1, 510, __pyx_L1_error)
11381 
11382   /* "qutip/cy/brtools.pyx":506
11383  *
11384  *     #mat2 holds data for kron(cop.dag(), c)
11385  *     init_CSR(             # <<<<<<<<<<<<<<
11386  *         &mat2,
11387  *         _safe_multiply(mat1.nnz, mat1.nnz),
11388  */
11389   __pyx_t_9.__pyx_n = 1;
11390   __pyx_t_9.ncols = __pyx_t_8;
11391   __pyx_f_5qutip_2cy_7brtools_init_CSR((&__pyx_v_mat2), __pyx_t_2, __pyx_t_3, &__pyx_t_9);
11392 
11393   /* "qutip/cy/brtools.pyx":512
11394  *         _safe_multiply(mat1.ncols, mat1.ncols),
11395  *     )
11396  *     _zcsr_kron_core(conj_data, mat1.indices, mat1.indptr,             # <<<<<<<<<<<<<<
11397  *                    mat1.data, mat1.indices, mat1.indptr,
11398  *                    &mat2,
11399  */
11400   __pyx_f_5qutip_2cy_6spmath__zcsr_kron_core(__pyx_v_conj_data, __pyx_v_mat1.indices, __pyx_v_mat1.indptr, __pyx_v_mat1.data, __pyx_v_mat1.indices, __pyx_v_mat1.indptr, (&__pyx_v_mat2), __pyx_v_mat1.nrows, __pyx_v_mat1.nrows, __pyx_v_mat1.ncols);
11401 
11402   /* "qutip/cy/brtools.pyx":518
11403  *
11404  *     #Do spmv with kron(cop.dag(), c)
11405  *     spmvpy(mat2.data,mat2.indices,mat2.indptr,             # <<<<<<<<<<<<<<
11406  *         &vec[0], 1, out, nrows**2)
11407  *
11408  */
11409   __pyx_f_5qutip_2cy_10spmatfuncs_spmvpy(__pyx_v_mat2.data, __pyx_v_mat2.indices, __pyx_v_mat2.indptr, (&(__pyx_v_vec[0])), __pyx_t_double_complex_from_parts(1, 0), __pyx_v_out, __Pyx_pow_long(((long)__pyx_v_nrows), 2));
11410 
11411   /* "qutip/cy/brtools.pyx":522
11412  *
11413  *     #Free temp conj_data array
11414  *     PyDataMem_FREE(conj_data)             # <<<<<<<<<<<<<<
11415  *     #Free mat2
11416  *     free_CSR(&mat2)
11417  */
11418   PyDataMem_FREE(__pyx_v_conj_data);
11419 
11420   /* "qutip/cy/brtools.pyx":524
11421  *     PyDataMem_FREE(conj_data)
11422  *     #Free mat2
11423  *     free_CSR(&mat2)             # <<<<<<<<<<<<<<
11424  *
11425  *     #Create identity in mat3
11426  */
11427   __pyx_f_5qutip_2cy_7brtools_free_CSR((&__pyx_v_mat2));
11428 
11429   /* "qutip/cy/brtools.pyx":527
11430  *
11431  *     #Create identity in mat3
11432  *     identity_CSR(&mat3, nrows)             # <<<<<<<<<<<<<<
11433  *
11434  *     #Take adjoint of cop (mat1) -> mat2
11435  */
11436   __pyx_f_5qutip_2cy_7brtools_identity_CSR((&__pyx_v_mat3), __pyx_v_nrows);
11437 
11438   /* "qutip/cy/brtools.pyx":530
11439  *
11440  *     #Take adjoint of cop (mat1) -> mat2
11441  *     _zcsr_adjoint(&mat1, &mat2)             # <<<<<<<<<<<<<<
11442  *
11443  *     #multiply cop.dag() * c (cdc) -> mat4
11444  */
11445   __pyx_f_5qutip_2cy_6spmath__zcsr_adjoint((&__pyx_v_mat1), (&__pyx_v_mat2));
11446 
11447   /* "qutip/cy/brtools.pyx":533
11448  *
11449  *     #multiply cop.dag() * c (cdc) -> mat4
11450  *     _zcsr_mult(&mat2, &mat1, &mat4)             # <<<<<<<<<<<<<<
11451  *
11452  *     #Free mat1 and mat2
11453  */
11454   __pyx_f_5qutip_2cy_6spmath__zcsr_mult((&__pyx_v_mat2), (&__pyx_v_mat1), (&__pyx_v_mat4));
11455 
11456   /* "qutip/cy/brtools.pyx":536
11457  *
11458  *     #Free mat1 and mat2
11459  *     free_CSR(&mat1)             # <<<<<<<<<<<<<<
11460  *     free_CSR(&mat2)
11461  *
11462  */
11463   __pyx_f_5qutip_2cy_7brtools_free_CSR((&__pyx_v_mat1));
11464 
11465   /* "qutip/cy/brtools.pyx":537
11466  *     #Free mat1 and mat2
11467  *     free_CSR(&mat1)
11468  *     free_CSR(&mat2)             # <<<<<<<<<<<<<<
11469  *
11470  *     # kron(eye, cdc) -> mat1
11471  */
11472   __pyx_f_5qutip_2cy_7brtools_free_CSR((&__pyx_v_mat2));
11473 
11474   /* "qutip/cy/brtools.pyx":540
11475  *
11476  *     # kron(eye, cdc) -> mat1
11477  *     _zcsr_kron(&mat3, &mat4, &mat1)             # <<<<<<<<<<<<<<
11478  *
11479  *     #Do spmv with -0.5*kron(eye, cdc)
11480  */
11481   __pyx_f_5qutip_2cy_6spmath__zcsr_kron((&__pyx_v_mat3), (&__pyx_v_mat4), (&__pyx_v_mat1)); if (unlikely(PyErr_Occurred())) __PYX_ERR(1, 540, __pyx_L1_error)
11482 
11483   /* "qutip/cy/brtools.pyx":543
11484  *
11485  *     #Do spmv with -0.5*kron(eye, cdc)
11486  *     spmvpy(mat1.data,mat1.indices,mat1.indptr,             # <<<<<<<<<<<<<<
11487  *         vec, -0.5, &out[0], nrows**2)
11488  *
11489  */
11490   __pyx_f_5qutip_2cy_10spmatfuncs_spmvpy(__pyx_v_mat1.data, __pyx_v_mat1.indices, __pyx_v_mat1.indptr, __pyx_v_vec, __pyx_t_double_complex_from_parts(-0.5, 0), (&(__pyx_v_out[0])), __Pyx_pow_long(((long)__pyx_v_nrows), 2));
11491 
11492   /* "qutip/cy/brtools.pyx":547
11493  *
11494  *     #Free mat1 (mat1 and mat2 are currently free)
11495  *     free_CSR(&mat1)             # <<<<<<<<<<<<<<
11496  *
11497  *     #Take traspose of cdc (mat4) -> mat1
11498  */
11499   __pyx_f_5qutip_2cy_7brtools_free_CSR((&__pyx_v_mat1));
11500 
11501   /* "qutip/cy/brtools.pyx":550
11502  *
11503  *     #Take traspose of cdc (mat4) -> mat1
11504  *     _zcsr_transpose(&mat4, &mat1)             # <<<<<<<<<<<<<<
11505  *
11506  *     #Free mat4 (mat2 and mat4 currently free)
11507  */
11508   __pyx_f_5qutip_2cy_6spmath__zcsr_transpose((&__pyx_v_mat4), (&__pyx_v_mat1));
11509 
11510   /* "qutip/cy/brtools.pyx":553
11511  *
11512  *     #Free mat4 (mat2 and mat4 currently free)
11513  *     free_CSR(&mat4)             # <<<<<<<<<<<<<<
11514  *
11515  *     # kron(cdct, eye) -> mat2
11516  */
11517   __pyx_f_5qutip_2cy_7brtools_free_CSR((&__pyx_v_mat4));
11518 
11519   /* "qutip/cy/brtools.pyx":556
11520  *
11521  *     # kron(cdct, eye) -> mat2
11522  *     _zcsr_kron(&mat1, &mat3, &mat2)             # <<<<<<<<<<<<<<
11523  *
11524  *     #Do spmv with -0.5*kron(cdct, eye)
11525  */
11526   __pyx_f_5qutip_2cy_6spmath__zcsr_kron((&__pyx_v_mat1), (&__pyx_v_mat3), (&__pyx_v_mat2)); if (unlikely(PyErr_Occurred())) __PYX_ERR(1, 556, __pyx_L1_error)
11527 
11528   /* "qutip/cy/brtools.pyx":559
11529  *
11530  *     #Do spmv with -0.5*kron(cdct, eye)
11531  *     spmvpy(mat2.data,mat2.indices,mat2.indptr,             # <<<<<<<<<<<<<<
11532  *         vec, -0.5, &out[0], nrows**2)
11533  *
11534  */
11535   __pyx_f_5qutip_2cy_10spmatfuncs_spmvpy(__pyx_v_mat2.data, __pyx_v_mat2.indices, __pyx_v_mat2.indptr, __pyx_v_vec, __pyx_t_double_complex_from_parts(-0.5, 0), (&(__pyx_v_out[0])), __Pyx_pow_long(((long)__pyx_v_nrows), 2));
11536 
11537   /* "qutip/cy/brtools.pyx":563
11538  *
11539  *     #Free mat1, mat2, and mat3
11540  *     free_CSR(&mat1)             # <<<<<<<<<<<<<<
11541  *     free_CSR(&mat2)
11542  *     free_CSR(&mat3)
11543  */
11544   __pyx_f_5qutip_2cy_7brtools_free_CSR((&__pyx_v_mat1));
11545 
11546   /* "qutip/cy/brtools.pyx":564
11547  *     #Free mat1, mat2, and mat3
11548  *     free_CSR(&mat1)
11549  *     free_CSR(&mat2)             # <<<<<<<<<<<<<<
11550  *     free_CSR(&mat3)
11551  *
11552  */
11553   __pyx_f_5qutip_2cy_7brtools_free_CSR((&__pyx_v_mat2));
11554 
11555   /* "qutip/cy/brtools.pyx":565
11556  *     free_CSR(&mat1)
11557  *     free_CSR(&mat2)
11558  *     free_CSR(&mat3)             # <<<<<<<<<<<<<<
11559  *
11560  *
11561  */
11562   __pyx_f_5qutip_2cy_7brtools_free_CSR((&__pyx_v_mat3));
11563 
11564   /* "qutip/cy/brtools.pyx":479
11565  * @cython.boundscheck(False)
11566  * @cython.wraparound(False)
11567  * cdef void cop_super_mult(complex[::1,:] cop, complex[::1,:] evecs,             # <<<<<<<<<<<<<<
11568  *                      double complex * vec,
11569  *                      double complex alpha,
11570  */
11571 
11572   /* function exit code */
11573   goto __pyx_L0;
11574   __pyx_L1_error:;
11575   __PYX_XDEC_MEMVIEW(&__pyx_t_1, 1);
11576   __Pyx_AddTraceback("qutip.cy.brtools.cop_super_mult", __pyx_clineno, __pyx_lineno, __pyx_filename);
11577   __pyx_L0:;
11578   __PYX_XDEC_MEMVIEW(&__pyx_v_cop_eig, 1);
11579   __Pyx_RefNannyFinishContext();
11580 }
11581 
11582 /* "qutip/cy/brtools.pyx":572
11583  * @cython.wraparound(False)
11584  * @cython.cdivision(True)
11585  * cdef inline void vec2mat_index(int nrows, int index, int[2] out) nogil:             # <<<<<<<<<<<<<<
11586  *     out[1] = index // nrows
11587  *     out[0] = index - nrows * out[1]
11588  */
11589 
__pyx_f_5qutip_2cy_7brtools_vec2mat_index(int __pyx_v_nrows,int __pyx_v_index,int * __pyx_v_out)11590 static CYTHON_INLINE void __pyx_f_5qutip_2cy_7brtools_vec2mat_index(int __pyx_v_nrows, int __pyx_v_index, int *__pyx_v_out) {
11591 
11592   /* "qutip/cy/brtools.pyx":573
11593  * @cython.cdivision(True)
11594  * cdef inline void vec2mat_index(int nrows, int index, int[2] out) nogil:
11595  *     out[1] = index // nrows             # <<<<<<<<<<<<<<
11596  *     out[0] = index - nrows * out[1]
11597  *
11598  */
11599   (__pyx_v_out[1]) = (__pyx_v_index / __pyx_v_nrows);
11600 
11601   /* "qutip/cy/brtools.pyx":574
11602  * cdef inline void vec2mat_index(int nrows, int index, int[2] out) nogil:
11603  *     out[1] = index // nrows
11604  *     out[0] = index - nrows * out[1]             # <<<<<<<<<<<<<<
11605  *
11606  *
11607  */
11608   (__pyx_v_out[0]) = (__pyx_v_index - (__pyx_v_nrows * (__pyx_v_out[1])));
11609 
11610   /* "qutip/cy/brtools.pyx":572
11611  * @cython.wraparound(False)
11612  * @cython.cdivision(True)
11613  * cdef inline void vec2mat_index(int nrows, int index, int[2] out) nogil:             # <<<<<<<<<<<<<<
11614  *     out[1] = index // nrows
11615  *     out[0] = index - nrows * out[1]
11616  */
11617 
11618   /* function exit code */
11619 }
11620 
11621 /* "qutip/cy/brtools.pyx":580
11622  * @cython.boundscheck(False)
11623  * @cython.wraparound(False)
11624  * cdef double skew_and_dwmin(double * evals, double[:,::1] skew,             # <<<<<<<<<<<<<<
11625  *                                 unsigned int nrows) nogil:
11626  *     cdef double diff
11627  */
11628 
__pyx_f_5qutip_2cy_7brtools_skew_and_dwmin(double * __pyx_v_evals,__Pyx_memviewslice __pyx_v_skew,unsigned int __pyx_v_nrows)11629 static double __pyx_f_5qutip_2cy_7brtools_skew_and_dwmin(double *__pyx_v_evals, __Pyx_memviewslice __pyx_v_skew, unsigned int __pyx_v_nrows) {
11630   double __pyx_v_diff;
11631   double __pyx_v_dw_min;
11632   size_t __pyx_v_ii;
11633   size_t __pyx_v_jj;
11634   double __pyx_r;
11635   unsigned int __pyx_t_1;
11636   unsigned int __pyx_t_2;
11637   size_t __pyx_t_3;
11638   unsigned int __pyx_t_4;
11639   unsigned int __pyx_t_5;
11640   size_t __pyx_t_6;
11641   size_t __pyx_t_7;
11642   size_t __pyx_t_8;
11643   int __pyx_t_9;
11644 
11645   /* "qutip/cy/brtools.pyx":583
11646  *                                 unsigned int nrows) nogil:
11647  *     cdef double diff
11648  *     dw_min = DBL_MAX             # <<<<<<<<<<<<<<
11649  *     cdef size_t ii, jj
11650  *     for ii in range(nrows):
11651  */
11652   __pyx_v_dw_min = DBL_MAX;
11653 
11654   /* "qutip/cy/brtools.pyx":585
11655  *     dw_min = DBL_MAX
11656  *     cdef size_t ii, jj
11657  *     for ii in range(nrows):             # <<<<<<<<<<<<<<
11658  *         for jj in range(nrows):
11659  *             diff = evals[ii] - evals[jj]
11660  */
11661   __pyx_t_1 = __pyx_v_nrows;
11662   __pyx_t_2 = __pyx_t_1;
11663   for (__pyx_t_3 = 0; __pyx_t_3 < __pyx_t_2; __pyx_t_3+=1) {
11664     __pyx_v_ii = __pyx_t_3;
11665 
11666     /* "qutip/cy/brtools.pyx":586
11667  *     cdef size_t ii, jj
11668  *     for ii in range(nrows):
11669  *         for jj in range(nrows):             # <<<<<<<<<<<<<<
11670  *             diff = evals[ii] - evals[jj]
11671  *             skew[ii,jj] = diff
11672  */
11673     __pyx_t_4 = __pyx_v_nrows;
11674     __pyx_t_5 = __pyx_t_4;
11675     for (__pyx_t_6 = 0; __pyx_t_6 < __pyx_t_5; __pyx_t_6+=1) {
11676       __pyx_v_jj = __pyx_t_6;
11677 
11678       /* "qutip/cy/brtools.pyx":587
11679  *     for ii in range(nrows):
11680  *         for jj in range(nrows):
11681  *             diff = evals[ii] - evals[jj]             # <<<<<<<<<<<<<<
11682  *             skew[ii,jj] = diff
11683  *             if diff != 0:
11684  */
11685       __pyx_v_diff = ((__pyx_v_evals[__pyx_v_ii]) - (__pyx_v_evals[__pyx_v_jj]));
11686 
11687       /* "qutip/cy/brtools.pyx":588
11688  *         for jj in range(nrows):
11689  *             diff = evals[ii] - evals[jj]
11690  *             skew[ii,jj] = diff             # <<<<<<<<<<<<<<
11691  *             if diff != 0:
11692  *                 dw_min = fmin(fabs(diff), dw_min)
11693  */
11694       __pyx_t_7 = __pyx_v_ii;
11695       __pyx_t_8 = __pyx_v_jj;
11696       *((double *) ( /* dim=1 */ ((char *) (((double *) ( /* dim=0 */ (__pyx_v_skew.data + __pyx_t_7 * __pyx_v_skew.strides[0]) )) + __pyx_t_8)) )) = __pyx_v_diff;
11697 
11698       /* "qutip/cy/brtools.pyx":589
11699  *             diff = evals[ii] - evals[jj]
11700  *             skew[ii,jj] = diff
11701  *             if diff != 0:             # <<<<<<<<<<<<<<
11702  *                 dw_min = fmin(fabs(diff), dw_min)
11703  *     return dw_min
11704  */
11705       __pyx_t_9 = ((__pyx_v_diff != 0.0) != 0);
11706       if (__pyx_t_9) {
11707 
11708         /* "qutip/cy/brtools.pyx":590
11709  *             skew[ii,jj] = diff
11710  *             if diff != 0:
11711  *                 dw_min = fmin(fabs(diff), dw_min)             # <<<<<<<<<<<<<<
11712  *     return dw_min
11713  *
11714  */
11715         __pyx_v_dw_min = fmin(fabs(__pyx_v_diff), __pyx_v_dw_min);
11716 
11717         /* "qutip/cy/brtools.pyx":589
11718  *             diff = evals[ii] - evals[jj]
11719  *             skew[ii,jj] = diff
11720  *             if diff != 0:             # <<<<<<<<<<<<<<
11721  *                 dw_min = fmin(fabs(diff), dw_min)
11722  *     return dw_min
11723  */
11724       }
11725     }
11726   }
11727 
11728   /* "qutip/cy/brtools.pyx":591
11729  *             if diff != 0:
11730  *                 dw_min = fmin(fabs(diff), dw_min)
11731  *     return dw_min             # <<<<<<<<<<<<<<
11732  *
11733  *
11734  */
11735   __pyx_r = __pyx_v_dw_min;
11736   goto __pyx_L0;
11737 
11738   /* "qutip/cy/brtools.pyx":580
11739  * @cython.boundscheck(False)
11740  * @cython.wraparound(False)
11741  * cdef double skew_and_dwmin(double * evals, double[:,::1] skew,             # <<<<<<<<<<<<<<
11742  *                                 unsigned int nrows) nogil:
11743  *     cdef double diff
11744  */
11745 
11746   /* function exit code */
11747   __pyx_L0:;
11748   return __pyx_r;
11749 }
11750 
11751 /* "qutip/cy/brtools.pyx":596
11752  * @cython.boundscheck(False)
11753  * @cython.wraparound(False)
11754  * cdef void br_term_mult(double t, complex[::1,:] A, complex[::1,:] evecs,             # <<<<<<<<<<<<<<
11755  *                 double[:,::1] skew, double dw_min, spec_func spectral,
11756  *                 double complex * vec, double complex * out,
11757  */
11758 
__pyx_f_5qutip_2cy_7brtools_br_term_mult(double __pyx_v_t,__Pyx_memviewslice __pyx_v_A,__Pyx_memviewslice __pyx_v_evecs,__Pyx_memviewslice __pyx_v_skew,double __pyx_v_dw_min,__pyx_t_5qutip_2cy_7brtools_spec_func __pyx_v_spectral,__pyx_t_double_complex * __pyx_v_vec,__pyx_t_double_complex * __pyx_v_out,unsigned int __pyx_v_nrows,int __pyx_v_use_secular,double __pyx_v_sec_cutoff,double __pyx_v_atol)11759 static void __pyx_f_5qutip_2cy_7brtools_br_term_mult(double __pyx_v_t, __Pyx_memviewslice __pyx_v_A, __Pyx_memviewslice __pyx_v_evecs, __Pyx_memviewslice __pyx_v_skew, double __pyx_v_dw_min, __pyx_t_5qutip_2cy_7brtools_spec_func __pyx_v_spectral, __pyx_t_double_complex *__pyx_v_vec, __pyx_t_double_complex *__pyx_v_out, unsigned int __pyx_v_nrows, int __pyx_v_use_secular, double __pyx_v_sec_cutoff, double __pyx_v_atol) {
11760   size_t __pyx_v_kk;
11761   size_t __pyx_v_I;
11762   size_t __pyx_v_J;
11763   int __pyx_v_ab[2];
11764   int __pyx_v_cd[2];
11765   __Pyx_memviewslice __pyx_v_A_eig = { 0, 0, { 0 }, { 0 }, { 0 } };
11766   __pyx_t_double_complex __pyx_v_elem;
11767   __pyx_t_double_complex __pyx_v_ac_elem;
11768   __pyx_t_double_complex __pyx_v_bd_elem;
11769   std::vector<int>  __pyx_v_coo_rows;
11770   std::vector<int>  __pyx_v_coo_cols;
11771   std::vector<__pyx_t_double_complex>  __pyx_v_coo_data;
11772   unsigned int __pyx_v_nnz;
11773   __pyx_t_5qutip_2cy_14sparse_structs_COO_Matrix __pyx_v_coo;
11774   __pyx_t_5qutip_2cy_14sparse_structs_CSR_Matrix __pyx_v_csr;
11775   __Pyx_RefNannyDeclarations
11776   __Pyx_memviewslice __pyx_t_1 = { 0, 0, { 0 }, { 0 }, { 0 } };
11777   long __pyx_t_2;
11778   long __pyx_t_3;
11779   size_t __pyx_t_4;
11780   long __pyx_t_5;
11781   long __pyx_t_6;
11782   size_t __pyx_t_7;
11783   int __pyx_t_8;
11784   int __pyx_t_9;
11785   Py_ssize_t __pyx_t_10;
11786   Py_ssize_t __pyx_t_11;
11787   Py_ssize_t __pyx_t_12;
11788   Py_ssize_t __pyx_t_13;
11789   unsigned int __pyx_t_14;
11790   unsigned int __pyx_t_15;
11791   size_t __pyx_t_16;
11792   size_t __pyx_t_17;
11793   size_t __pyx_t_18;
11794   size_t __pyx_t_19;
11795   int __pyx_lineno = 0;
11796   const char *__pyx_filename = NULL;
11797   int __pyx_clineno = 0;
11798   __Pyx_RefNannySetupContext("br_term_mult", 0);
11799 
11800   /* "qutip/cy/brtools.pyx":605
11801  *     cdef size_t I, J # vector index variables
11802  *     cdef int[2] ab, cd #matrix indexing variables
11803  *     cdef complex[::1,:] A_eig = dense_to_eigbasis(A, evecs, nrows, atol)             # <<<<<<<<<<<<<<
11804  *     cdef complex elem, ac_elem, bd_elem
11805  *     cdef vector[int] coo_rows, coo_cols
11806  */
11807   __pyx_t_1 = __pyx_f_5qutip_2cy_7brtools_dense_to_eigbasis(__pyx_v_A, __pyx_v_evecs, __pyx_v_nrows, __pyx_v_atol); if (unlikely(!__pyx_t_1.memview)) __PYX_ERR(1, 605, __pyx_L1_error)
11808   __pyx_v_A_eig = __pyx_t_1;
11809   __pyx_t_1.memview = NULL;
11810   __pyx_t_1.data = NULL;
11811 
11812   /* "qutip/cy/brtools.pyx":614
11813  *     cdef complex[:,::1] non_sec_mat
11814  *
11815  *     for I in range(nrows**2):             # <<<<<<<<<<<<<<
11816  *         vec2mat_index(nrows, I, ab)
11817  *         for J in range(nrows**2):
11818  */
11819   __pyx_t_2 = __Pyx_pow_long(((long)__pyx_v_nrows), 2);
11820   __pyx_t_3 = __pyx_t_2;
11821   for (__pyx_t_4 = 0; __pyx_t_4 < __pyx_t_3; __pyx_t_4+=1) {
11822     __pyx_v_I = __pyx_t_4;
11823 
11824     /* "qutip/cy/brtools.pyx":615
11825  *
11826  *     for I in range(nrows**2):
11827  *         vec2mat_index(nrows, I, ab)             # <<<<<<<<<<<<<<
11828  *         for J in range(nrows**2):
11829  *             vec2mat_index(nrows, J, cd)
11830  */
11831     __pyx_f_5qutip_2cy_7brtools_vec2mat_index(__pyx_v_nrows, __pyx_v_I, __pyx_v_ab);
11832 
11833     /* "qutip/cy/brtools.pyx":616
11834  *     for I in range(nrows**2):
11835  *         vec2mat_index(nrows, I, ab)
11836  *         for J in range(nrows**2):             # <<<<<<<<<<<<<<
11837  *             vec2mat_index(nrows, J, cd)
11838  *
11839  */
11840     __pyx_t_5 = __Pyx_pow_long(((long)__pyx_v_nrows), 2);
11841     __pyx_t_6 = __pyx_t_5;
11842     for (__pyx_t_7 = 0; __pyx_t_7 < __pyx_t_6; __pyx_t_7+=1) {
11843       __pyx_v_J = __pyx_t_7;
11844 
11845       /* "qutip/cy/brtools.pyx":617
11846  *         vec2mat_index(nrows, I, ab)
11847  *         for J in range(nrows**2):
11848  *             vec2mat_index(nrows, J, cd)             # <<<<<<<<<<<<<<
11849  *
11850  *             if (not use_secular) or (fabs(skew[ab[0],ab[1]]-skew[cd[0],cd[1]]) < (dw_min * sec_cutoff)):
11851  */
11852       __pyx_f_5qutip_2cy_7brtools_vec2mat_index(__pyx_v_nrows, __pyx_v_J, __pyx_v_cd);
11853 
11854       /* "qutip/cy/brtools.pyx":619
11855  *             vec2mat_index(nrows, J, cd)
11856  *
11857  *             if (not use_secular) or (fabs(skew[ab[0],ab[1]]-skew[cd[0],cd[1]]) < (dw_min * sec_cutoff)):             # <<<<<<<<<<<<<<
11858  *                 elem = (A_eig[ab[0],cd[0]]*A_eig[cd[1],ab[1]]) * 0.5
11859  *                 elem *= (spectral(skew[cd[0],ab[0]],t)+spectral(skew[cd[1],ab[1]],t))
11860  */
11861       __pyx_t_9 = ((!(__pyx_v_use_secular != 0)) != 0);
11862       if (!__pyx_t_9) {
11863       } else {
11864         __pyx_t_8 = __pyx_t_9;
11865         goto __pyx_L8_bool_binop_done;
11866       }
11867       __pyx_t_10 = (__pyx_v_ab[0]);
11868       __pyx_t_11 = (__pyx_v_ab[1]);
11869       __pyx_t_12 = (__pyx_v_cd[0]);
11870       __pyx_t_13 = (__pyx_v_cd[1]);
11871       __pyx_t_9 = ((fabs(((*((double *) ( /* dim=1 */ ((char *) (((double *) ( /* dim=0 */ (__pyx_v_skew.data + __pyx_t_10 * __pyx_v_skew.strides[0]) )) + __pyx_t_11)) ))) - (*((double *) ( /* dim=1 */ ((char *) (((double *) ( /* dim=0 */ (__pyx_v_skew.data + __pyx_t_12 * __pyx_v_skew.strides[0]) )) + __pyx_t_13)) ))))) < (__pyx_v_dw_min * __pyx_v_sec_cutoff)) != 0);
11872       __pyx_t_8 = __pyx_t_9;
11873       __pyx_L8_bool_binop_done:;
11874       if (__pyx_t_8) {
11875 
11876         /* "qutip/cy/brtools.pyx":620
11877  *
11878  *             if (not use_secular) or (fabs(skew[ab[0],ab[1]]-skew[cd[0],cd[1]]) < (dw_min * sec_cutoff)):
11879  *                 elem = (A_eig[ab[0],cd[0]]*A_eig[cd[1],ab[1]]) * 0.5             # <<<<<<<<<<<<<<
11880  *                 elem *= (spectral(skew[cd[0],ab[0]],t)+spectral(skew[cd[1],ab[1]],t))
11881  *
11882  */
11883         __pyx_t_13 = (__pyx_v_ab[0]);
11884         __pyx_t_12 = (__pyx_v_cd[0]);
11885         __pyx_t_11 = (__pyx_v_cd[1]);
11886         __pyx_t_10 = (__pyx_v_ab[1]);
11887         __pyx_v_elem = __Pyx_c_prod_double(__Pyx_c_prod_double((*((__pyx_t_double_complex *) ( /* dim=1 */ (( /* dim=0 */ ((char *) (((__pyx_t_double_complex *) __pyx_v_A_eig.data) + __pyx_t_13)) ) + __pyx_t_12 * __pyx_v_A_eig.strides[1]) ))), (*((__pyx_t_double_complex *) ( /* dim=1 */ (( /* dim=0 */ ((char *) (((__pyx_t_double_complex *) __pyx_v_A_eig.data) + __pyx_t_11)) ) + __pyx_t_10 * __pyx_v_A_eig.strides[1]) )))), __pyx_t_double_complex_from_parts(0.5, 0));
11888 
11889         /* "qutip/cy/brtools.pyx":621
11890  *             if (not use_secular) or (fabs(skew[ab[0],ab[1]]-skew[cd[0],cd[1]]) < (dw_min * sec_cutoff)):
11891  *                 elem = (A_eig[ab[0],cd[0]]*A_eig[cd[1],ab[1]]) * 0.5
11892  *                 elem *= (spectral(skew[cd[0],ab[0]],t)+spectral(skew[cd[1],ab[1]],t))             # <<<<<<<<<<<<<<
11893  *
11894  *                 if (ab[0]==cd[0]):
11895  */
11896         __pyx_t_10 = (__pyx_v_cd[0]);
11897         __pyx_t_11 = (__pyx_v_ab[0]);
11898         __pyx_t_12 = (__pyx_v_cd[1]);
11899         __pyx_t_13 = (__pyx_v_ab[1]);
11900         __pyx_v_elem = __Pyx_c_prod_double(__pyx_v_elem, __Pyx_c_sum_double(__pyx_v_spectral((*((double *) ( /* dim=1 */ ((char *) (((double *) ( /* dim=0 */ (__pyx_v_skew.data + __pyx_t_10 * __pyx_v_skew.strides[0]) )) + __pyx_t_11)) ))), __pyx_v_t), __pyx_v_spectral((*((double *) ( /* dim=1 */ ((char *) (((double *) ( /* dim=0 */ (__pyx_v_skew.data + __pyx_t_12 * __pyx_v_skew.strides[0]) )) + __pyx_t_13)) ))), __pyx_v_t)));
11901 
11902         /* "qutip/cy/brtools.pyx":623
11903  *                 elem *= (spectral(skew[cd[0],ab[0]],t)+spectral(skew[cd[1],ab[1]],t))
11904  *
11905  *                 if (ab[0]==cd[0]):             # <<<<<<<<<<<<<<
11906  *                     ac_elem = 0
11907  *                     for kk in range(nrows):
11908  */
11909         __pyx_t_8 = (((__pyx_v_ab[0]) == (__pyx_v_cd[0])) != 0);
11910         if (__pyx_t_8) {
11911 
11912           /* "qutip/cy/brtools.pyx":624
11913  *
11914  *                 if (ab[0]==cd[0]):
11915  *                     ac_elem = 0             # <<<<<<<<<<<<<<
11916  *                     for kk in range(nrows):
11917  *                         ac_elem += A_eig[cd[1],kk]*A_eig[kk,ab[1]] * spectral(skew[cd[1],kk],t)
11918  */
11919           __pyx_v_ac_elem = __pyx_t_double_complex_from_parts(0, 0);
11920 
11921           /* "qutip/cy/brtools.pyx":625
11922  *                 if (ab[0]==cd[0]):
11923  *                     ac_elem = 0
11924  *                     for kk in range(nrows):             # <<<<<<<<<<<<<<
11925  *                         ac_elem += A_eig[cd[1],kk]*A_eig[kk,ab[1]] * spectral(skew[cd[1],kk],t)
11926  *                     elem -= 0.5*ac_elem
11927  */
11928           __pyx_t_14 = __pyx_v_nrows;
11929           __pyx_t_15 = __pyx_t_14;
11930           for (__pyx_t_16 = 0; __pyx_t_16 < __pyx_t_15; __pyx_t_16+=1) {
11931             __pyx_v_kk = __pyx_t_16;
11932 
11933             /* "qutip/cy/brtools.pyx":626
11934  *                     ac_elem = 0
11935  *                     for kk in range(nrows):
11936  *                         ac_elem += A_eig[cd[1],kk]*A_eig[kk,ab[1]] * spectral(skew[cd[1],kk],t)             # <<<<<<<<<<<<<<
11937  *                     elem -= 0.5*ac_elem
11938  *
11939  */
11940             __pyx_t_13 = (__pyx_v_cd[1]);
11941             __pyx_t_17 = __pyx_v_kk;
11942             __pyx_t_18 = __pyx_v_kk;
11943             __pyx_t_12 = (__pyx_v_ab[1]);
11944             __pyx_t_11 = (__pyx_v_cd[1]);
11945             __pyx_t_19 = __pyx_v_kk;
11946             __pyx_v_ac_elem = __Pyx_c_sum_double(__pyx_v_ac_elem, __Pyx_c_prod_double(__Pyx_c_prod_double((*((__pyx_t_double_complex *) ( /* dim=1 */ (( /* dim=0 */ ((char *) (((__pyx_t_double_complex *) __pyx_v_A_eig.data) + __pyx_t_13)) ) + __pyx_t_17 * __pyx_v_A_eig.strides[1]) ))), (*((__pyx_t_double_complex *) ( /* dim=1 */ (( /* dim=0 */ ((char *) (((__pyx_t_double_complex *) __pyx_v_A_eig.data) + __pyx_t_18)) ) + __pyx_t_12 * __pyx_v_A_eig.strides[1]) )))), __pyx_v_spectral((*((double *) ( /* dim=1 */ ((char *) (((double *) ( /* dim=0 */ (__pyx_v_skew.data + __pyx_t_11 * __pyx_v_skew.strides[0]) )) + __pyx_t_19)) ))), __pyx_v_t)));
11947           }
11948 
11949           /* "qutip/cy/brtools.pyx":627
11950  *                     for kk in range(nrows):
11951  *                         ac_elem += A_eig[cd[1],kk]*A_eig[kk,ab[1]] * spectral(skew[cd[1],kk],t)
11952  *                     elem -= 0.5*ac_elem             # <<<<<<<<<<<<<<
11953  *
11954  *                 if (ab[1]==cd[1]):
11955  */
11956           __pyx_v_elem = __Pyx_c_diff_double(__pyx_v_elem, __Pyx_c_prod_double(__pyx_t_double_complex_from_parts(0.5, 0), __pyx_v_ac_elem));
11957 
11958           /* "qutip/cy/brtools.pyx":623
11959  *                 elem *= (spectral(skew[cd[0],ab[0]],t)+spectral(skew[cd[1],ab[1]],t))
11960  *
11961  *                 if (ab[0]==cd[0]):             # <<<<<<<<<<<<<<
11962  *                     ac_elem = 0
11963  *                     for kk in range(nrows):
11964  */
11965         }
11966 
11967         /* "qutip/cy/brtools.pyx":629
11968  *                     elem -= 0.5*ac_elem
11969  *
11970  *                 if (ab[1]==cd[1]):             # <<<<<<<<<<<<<<
11971  *                     bd_elem = 0
11972  *                     for kk in range(nrows):
11973  */
11974         __pyx_t_8 = (((__pyx_v_ab[1]) == (__pyx_v_cd[1])) != 0);
11975         if (__pyx_t_8) {
11976 
11977           /* "qutip/cy/brtools.pyx":630
11978  *
11979  *                 if (ab[1]==cd[1]):
11980  *                     bd_elem = 0             # <<<<<<<<<<<<<<
11981  *                     for kk in range(nrows):
11982  *                         bd_elem += A_eig[ab[0],kk]*A_eig[kk,cd[0]] * spectral(skew[cd[0],kk],t)
11983  */
11984           __pyx_v_bd_elem = __pyx_t_double_complex_from_parts(0, 0);
11985 
11986           /* "qutip/cy/brtools.pyx":631
11987  *                 if (ab[1]==cd[1]):
11988  *                     bd_elem = 0
11989  *                     for kk in range(nrows):             # <<<<<<<<<<<<<<
11990  *                         bd_elem += A_eig[ab[0],kk]*A_eig[kk,cd[0]] * spectral(skew[cd[0],kk],t)
11991  *                     elem -= 0.5*bd_elem
11992  */
11993           __pyx_t_14 = __pyx_v_nrows;
11994           __pyx_t_15 = __pyx_t_14;
11995           for (__pyx_t_16 = 0; __pyx_t_16 < __pyx_t_15; __pyx_t_16+=1) {
11996             __pyx_v_kk = __pyx_t_16;
11997 
11998             /* "qutip/cy/brtools.pyx":632
11999  *                     bd_elem = 0
12000  *                     for kk in range(nrows):
12001  *                         bd_elem += A_eig[ab[0],kk]*A_eig[kk,cd[0]] * spectral(skew[cd[0],kk],t)             # <<<<<<<<<<<<<<
12002  *                     elem -= 0.5*bd_elem
12003  *
12004  */
12005             __pyx_t_11 = (__pyx_v_ab[0]);
12006             __pyx_t_19 = __pyx_v_kk;
12007             __pyx_t_18 = __pyx_v_kk;
12008             __pyx_t_12 = (__pyx_v_cd[0]);
12009             __pyx_t_13 = (__pyx_v_cd[0]);
12010             __pyx_t_17 = __pyx_v_kk;
12011             __pyx_v_bd_elem = __Pyx_c_sum_double(__pyx_v_bd_elem, __Pyx_c_prod_double(__Pyx_c_prod_double((*((__pyx_t_double_complex *) ( /* dim=1 */ (( /* dim=0 */ ((char *) (((__pyx_t_double_complex *) __pyx_v_A_eig.data) + __pyx_t_11)) ) + __pyx_t_19 * __pyx_v_A_eig.strides[1]) ))), (*((__pyx_t_double_complex *) ( /* dim=1 */ (( /* dim=0 */ ((char *) (((__pyx_t_double_complex *) __pyx_v_A_eig.data) + __pyx_t_18)) ) + __pyx_t_12 * __pyx_v_A_eig.strides[1]) )))), __pyx_v_spectral((*((double *) ( /* dim=1 */ ((char *) (((double *) ( /* dim=0 */ (__pyx_v_skew.data + __pyx_t_13 * __pyx_v_skew.strides[0]) )) + __pyx_t_17)) ))), __pyx_v_t)));
12012           }
12013 
12014           /* "qutip/cy/brtools.pyx":633
12015  *                     for kk in range(nrows):
12016  *                         bd_elem += A_eig[ab[0],kk]*A_eig[kk,cd[0]] * spectral(skew[cd[0],kk],t)
12017  *                     elem -= 0.5*bd_elem             # <<<<<<<<<<<<<<
12018  *
12019  *                 if (elem != 0):
12020  */
12021           __pyx_v_elem = __Pyx_c_diff_double(__pyx_v_elem, __Pyx_c_prod_double(__pyx_t_double_complex_from_parts(0.5, 0), __pyx_v_bd_elem));
12022 
12023           /* "qutip/cy/brtools.pyx":629
12024  *                     elem -= 0.5*ac_elem
12025  *
12026  *                 if (ab[1]==cd[1]):             # <<<<<<<<<<<<<<
12027  *                     bd_elem = 0
12028  *                     for kk in range(nrows):
12029  */
12030         }
12031 
12032         /* "qutip/cy/brtools.pyx":635
12033  *                     elem -= 0.5*bd_elem
12034  *
12035  *                 if (elem != 0):             # <<<<<<<<<<<<<<
12036  *                     coo_rows.push_back(I)
12037  *                     coo_cols.push_back(J)
12038  */
12039         __pyx_t_8 = ((!__Pyx_c_eq_double(__pyx_v_elem, __pyx_t_double_complex_from_parts(0, 0))) != 0);
12040         if (__pyx_t_8) {
12041 
12042           /* "qutip/cy/brtools.pyx":636
12043  *
12044  *                 if (elem != 0):
12045  *                     coo_rows.push_back(I)             # <<<<<<<<<<<<<<
12046  *                     coo_cols.push_back(J)
12047  *                     coo_data.push_back(elem)
12048  */
12049           try {
12050             __pyx_v_coo_rows.push_back(__pyx_v_I);
12051           } catch(...) {
12052             __Pyx_CppExn2PyErr();
12053             __PYX_ERR(1, 636, __pyx_L1_error)
12054           }
12055 
12056           /* "qutip/cy/brtools.pyx":637
12057  *                 if (elem != 0):
12058  *                     coo_rows.push_back(I)
12059  *                     coo_cols.push_back(J)             # <<<<<<<<<<<<<<
12060  *                     coo_data.push_back(elem)
12061  *
12062  */
12063           try {
12064             __pyx_v_coo_cols.push_back(__pyx_v_J);
12065           } catch(...) {
12066             __Pyx_CppExn2PyErr();
12067             __PYX_ERR(1, 637, __pyx_L1_error)
12068           }
12069 
12070           /* "qutip/cy/brtools.pyx":638
12071  *                     coo_rows.push_back(I)
12072  *                     coo_cols.push_back(J)
12073  *                     coo_data.push_back(elem)             # <<<<<<<<<<<<<<
12074  *
12075  *     PyDataMem_FREE(&A_eig[0,0])
12076  */
12077           try {
12078             __pyx_v_coo_data.push_back(__pyx_v_elem);
12079           } catch(...) {
12080             __Pyx_CppExn2PyErr();
12081             __PYX_ERR(1, 638, __pyx_L1_error)
12082           }
12083 
12084           /* "qutip/cy/brtools.pyx":635
12085  *                     elem -= 0.5*bd_elem
12086  *
12087  *                 if (elem != 0):             # <<<<<<<<<<<<<<
12088  *                     coo_rows.push_back(I)
12089  *                     coo_cols.push_back(J)
12090  */
12091         }
12092 
12093         /* "qutip/cy/brtools.pyx":619
12094  *             vec2mat_index(nrows, J, cd)
12095  *
12096  *             if (not use_secular) or (fabs(skew[ab[0],ab[1]]-skew[cd[0],cd[1]]) < (dw_min * sec_cutoff)):             # <<<<<<<<<<<<<<
12097  *                 elem = (A_eig[ab[0],cd[0]]*A_eig[cd[1],ab[1]]) * 0.5
12098  *                 elem *= (spectral(skew[cd[0],ab[0]],t)+spectral(skew[cd[1],ab[1]],t))
12099  */
12100       }
12101     }
12102   }
12103 
12104   /* "qutip/cy/brtools.pyx":640
12105  *                     coo_data.push_back(elem)
12106  *
12107  *     PyDataMem_FREE(&A_eig[0,0])             # <<<<<<<<<<<<<<
12108  *
12109  *     #Number of elements in BR tensor
12110  */
12111   __pyx_t_13 = 0;
12112   __pyx_t_12 = 0;
12113   PyDataMem_FREE((&(*((__pyx_t_double_complex *) ( /* dim=1 */ (( /* dim=0 */ ((char *) (((__pyx_t_double_complex *) __pyx_v_A_eig.data) + __pyx_t_13)) ) + __pyx_t_12 * __pyx_v_A_eig.strides[1]) )))));
12114 
12115   /* "qutip/cy/brtools.pyx":643
12116  *
12117  *     #Number of elements in BR tensor
12118  *     nnz = coo_rows.size()             # <<<<<<<<<<<<<<
12119  *     coo.nnz = nnz
12120  *     coo.rows = coo_rows.data()
12121  */
12122   __pyx_v_nnz = __pyx_v_coo_rows.size();
12123 
12124   /* "qutip/cy/brtools.pyx":644
12125  *     #Number of elements in BR tensor
12126  *     nnz = coo_rows.size()
12127  *     coo.nnz = nnz             # <<<<<<<<<<<<<<
12128  *     coo.rows = coo_rows.data()
12129  *     coo.cols = coo_cols.data()
12130  */
12131   __pyx_v_coo.nnz = __pyx_v_nnz;
12132 
12133   /* "qutip/cy/brtools.pyx":645
12134  *     nnz = coo_rows.size()
12135  *     coo.nnz = nnz
12136  *     coo.rows = coo_rows.data()             # <<<<<<<<<<<<<<
12137  *     coo.cols = coo_cols.data()
12138  *     coo.data = coo_data.data()
12139  */
12140   __pyx_v_coo.rows = __pyx_v_coo_rows.data();
12141 
12142   /* "qutip/cy/brtools.pyx":646
12143  *     coo.nnz = nnz
12144  *     coo.rows = coo_rows.data()
12145  *     coo.cols = coo_cols.data()             # <<<<<<<<<<<<<<
12146  *     coo.data = coo_data.data()
12147  *     coo.nrows = nrows**2
12148  */
12149   __pyx_v_coo.cols = __pyx_v_coo_cols.data();
12150 
12151   /* "qutip/cy/brtools.pyx":647
12152  *     coo.rows = coo_rows.data()
12153  *     coo.cols = coo_cols.data()
12154  *     coo.data = coo_data.data()             # <<<<<<<<<<<<<<
12155  *     coo.nrows = nrows**2
12156  *     coo.ncols = nrows**2
12157  */
12158   __pyx_v_coo.data = __pyx_v_coo_data.data();
12159 
12160   /* "qutip/cy/brtools.pyx":648
12161  *     coo.cols = coo_cols.data()
12162  *     coo.data = coo_data.data()
12163  *     coo.nrows = nrows**2             # <<<<<<<<<<<<<<
12164  *     coo.ncols = nrows**2
12165  *     coo.is_set = 1
12166  */
12167   __pyx_v_coo.nrows = __Pyx_pow_long(((long)__pyx_v_nrows), 2);
12168 
12169   /* "qutip/cy/brtools.pyx":649
12170  *     coo.data = coo_data.data()
12171  *     coo.nrows = nrows**2
12172  *     coo.ncols = nrows**2             # <<<<<<<<<<<<<<
12173  *     coo.is_set = 1
12174  *     coo.max_length = nnz
12175  */
12176   __pyx_v_coo.ncols = __Pyx_pow_long(((long)__pyx_v_nrows), 2);
12177 
12178   /* "qutip/cy/brtools.pyx":650
12179  *     coo.nrows = nrows**2
12180  *     coo.ncols = nrows**2
12181  *     coo.is_set = 1             # <<<<<<<<<<<<<<
12182  *     coo.max_length = nnz
12183  *     COO_to_CSR(&csr, &coo)
12184  */
12185   __pyx_v_coo.is_set = 1;
12186 
12187   /* "qutip/cy/brtools.pyx":651
12188  *     coo.ncols = nrows**2
12189  *     coo.is_set = 1
12190  *     coo.max_length = nnz             # <<<<<<<<<<<<<<
12191  *     COO_to_CSR(&csr, &coo)
12192  *     spmvpy(csr.data, csr.indices, csr.indptr, vec, 1, out, nrows**2)
12193  */
12194   __pyx_v_coo.max_length = __pyx_v_nnz;
12195 
12196   /* "qutip/cy/brtools.pyx":652
12197  *     coo.is_set = 1
12198  *     coo.max_length = nnz
12199  *     COO_to_CSR(&csr, &coo)             # <<<<<<<<<<<<<<
12200  *     spmvpy(csr.data, csr.indices, csr.indptr, vec, 1, out, nrows**2)
12201  *     free_CSR(&csr)
12202  */
12203   __pyx_f_5qutip_2cy_7brtools_COO_to_CSR((&__pyx_v_csr), (&__pyx_v_coo));
12204 
12205   /* "qutip/cy/brtools.pyx":653
12206  *     coo.max_length = nnz
12207  *     COO_to_CSR(&csr, &coo)
12208  *     spmvpy(csr.data, csr.indices, csr.indptr, vec, 1, out, nrows**2)             # <<<<<<<<<<<<<<
12209  *     free_CSR(&csr)
12210  *
12211  */
12212   __pyx_f_5qutip_2cy_10spmatfuncs_spmvpy(__pyx_v_csr.data, __pyx_v_csr.indices, __pyx_v_csr.indptr, __pyx_v_vec, __pyx_t_double_complex_from_parts(1, 0), __pyx_v_out, __Pyx_pow_long(((long)__pyx_v_nrows), 2));
12213 
12214   /* "qutip/cy/brtools.pyx":654
12215  *     COO_to_CSR(&csr, &coo)
12216  *     spmvpy(csr.data, csr.indices, csr.indptr, vec, 1, out, nrows**2)
12217  *     free_CSR(&csr)             # <<<<<<<<<<<<<<
12218  *
12219  *
12220  */
12221   __pyx_f_5qutip_2cy_7brtools_free_CSR((&__pyx_v_csr));
12222 
12223   /* "qutip/cy/brtools.pyx":596
12224  * @cython.boundscheck(False)
12225  * @cython.wraparound(False)
12226  * cdef void br_term_mult(double t, complex[::1,:] A, complex[::1,:] evecs,             # <<<<<<<<<<<<<<
12227  *                 double[:,::1] skew, double dw_min, spec_func spectral,
12228  *                 double complex * vec, double complex * out,
12229  */
12230 
12231   /* function exit code */
12232   goto __pyx_L0;
12233   __pyx_L1_error:;
12234   __PYX_XDEC_MEMVIEW(&__pyx_t_1, 1);
12235   __Pyx_WriteUnraisable("qutip.cy.brtools.br_term_mult", __pyx_clineno, __pyx_lineno, __pyx_filename, 1, 0);
12236   __pyx_L0:;
12237   __PYX_XDEC_MEMVIEW(&__pyx_v_A_eig, 1);
12238   __Pyx_RefNannyFinishContext();
12239 }
12240 
12241 /* "qutip/cy/brtools.pyx":659
12242  * @cython.boundscheck(False)
12243  * @cython.wraparound(False)
12244  * cdef void sparse_ZHEEVR(complex[::1,:] H, double * eigvals,             # <<<<<<<<<<<<<<
12245  *                     CSR_Matrix * evecs, int nrows, double atol):
12246  *     """
12247  */
12248 
__pyx_f_5qutip_2cy_7brtools_sparse_ZHEEVR(__Pyx_memviewslice __pyx_v_H,double * __pyx_v_eigvals,__pyx_t_5qutip_2cy_14sparse_structs_CSR_Matrix * __pyx_v_evecs,int __pyx_v_nrows,double __pyx_v_atol)12249 static void __pyx_f_5qutip_2cy_7brtools_sparse_ZHEEVR(__Pyx_memviewslice __pyx_v_H, double *__pyx_v_eigvals, __pyx_t_5qutip_2cy_14sparse_structs_CSR_Matrix *__pyx_v_evecs, int __pyx_v_nrows, double __pyx_v_atol) {
12250   size_t __pyx_v_jj;
12251   size_t __pyx_v_ii;
12252   char __pyx_v_jobz;
12253   char __pyx_v_rnge;
12254   char __pyx_v_uplo;
12255   double __pyx_v_vl;
12256   double __pyx_v_vu;
12257   double __pyx_v_abstol;
12258   int __pyx_v_il;
12259   int __pyx_v_iu;
12260   int __pyx_v_lwork;
12261   int __pyx_v_lrwork;
12262   int __pyx_v_liwork;
12263   int __pyx_v_info;
12264   int __pyx_v_M;
12265   int *__pyx_v_isuppz;
12266   __pyx_t_double_complex *__pyx_v_work;
12267   double *__pyx_v_rwork;
12268   int *__pyx_v_iwork;
12269   __Pyx_memviewslice __pyx_v_cZ = { 0, 0, { 0 }, { 0 }, { 0 } };
12270   __Pyx_memviewslice __pyx_v_Z = { 0, 0, { 0 }, { 0 }, { 0 } };
12271   __Pyx_RefNannyDeclarations
12272   __pyx_t_double_complex *__pyx_t_1;
12273   struct __pyx_array_obj *__pyx_t_2 = NULL;
12274   PyObject *__pyx_t_3 = NULL;
12275   PyObject *__pyx_t_4 = NULL;
12276   __Pyx_memviewslice __pyx_t_5 = { 0, 0, { 0 }, { 0 }, { 0 } };
12277   __Pyx_memviewslice __pyx_t_6 = { 0, 0, { 0 }, { 0 }, { 0 } };
12278   Py_ssize_t __pyx_t_7;
12279   Py_ssize_t __pyx_t_8;
12280   Py_ssize_t __pyx_t_9;
12281   Py_ssize_t __pyx_t_10;
12282   int __pyx_t_11;
12283   int __pyx_t_12;
12284   int __pyx_t_13;
12285   size_t __pyx_t_14;
12286   int __pyx_t_15;
12287   int __pyx_t_16;
12288   size_t __pyx_t_17;
12289   size_t __pyx_t_18;
12290   size_t __pyx_t_19;
12291   int __pyx_lineno = 0;
12292   const char *__pyx_filename = NULL;
12293   int __pyx_clineno = 0;
12294   __Pyx_RefNannySetupContext("sparse_ZHEEVR", 0);
12295 
12296   /* "qutip/cy/brtools.pyx":677
12297  *     """
12298  *     cdef size_t jj, ii
12299  *     cdef char jobz = b'V'             # <<<<<<<<<<<<<<
12300  *     cdef char rnge = b'A'
12301  *     cdef char uplo = b'L'
12302  */
12303   __pyx_v_jobz = 'V';
12304 
12305   /* "qutip/cy/brtools.pyx":678
12306  *     cdef size_t jj, ii
12307  *     cdef char jobz = b'V'
12308  *     cdef char rnge = b'A'             # <<<<<<<<<<<<<<
12309  *     cdef char uplo = b'L'
12310  *     cdef double vl=1, vu=1, abstol=0
12311  */
12312   __pyx_v_rnge = 'A';
12313 
12314   /* "qutip/cy/brtools.pyx":679
12315  *     cdef char jobz = b'V'
12316  *     cdef char rnge = b'A'
12317  *     cdef char uplo = b'L'             # <<<<<<<<<<<<<<
12318  *     cdef double vl=1, vu=1, abstol=0
12319  *     cdef int il=1, iu=1
12320  */
12321   __pyx_v_uplo = 'L';
12322 
12323   /* "qutip/cy/brtools.pyx":680
12324  *     cdef char rnge = b'A'
12325  *     cdef char uplo = b'L'
12326  *     cdef double vl=1, vu=1, abstol=0             # <<<<<<<<<<<<<<
12327  *     cdef int il=1, iu=1
12328  *     cdef int lwork = 18 * nrows
12329  */
12330   __pyx_v_vl = 1.0;
12331   __pyx_v_vu = 1.0;
12332   __pyx_v_abstol = 0.0;
12333 
12334   /* "qutip/cy/brtools.pyx":681
12335  *     cdef char uplo = b'L'
12336  *     cdef double vl=1, vu=1, abstol=0
12337  *     cdef int il=1, iu=1             # <<<<<<<<<<<<<<
12338  *     cdef int lwork = 18 * nrows
12339  *     cdef int lrwork = 24*nrows, liwork = 10*nrows
12340  */
12341   __pyx_v_il = 1;
12342   __pyx_v_iu = 1;
12343 
12344   /* "qutip/cy/brtools.pyx":682
12345  *     cdef double vl=1, vu=1, abstol=0
12346  *     cdef int il=1, iu=1
12347  *     cdef int lwork = 18 * nrows             # <<<<<<<<<<<<<<
12348  *     cdef int lrwork = 24*nrows, liwork = 10*nrows
12349  *     cdef int info=0, M=0
12350  */
12351   __pyx_v_lwork = (18 * __pyx_v_nrows);
12352 
12353   /* "qutip/cy/brtools.pyx":683
12354  *     cdef int il=1, iu=1
12355  *     cdef int lwork = 18 * nrows
12356  *     cdef int lrwork = 24*nrows, liwork = 10*nrows             # <<<<<<<<<<<<<<
12357  *     cdef int info=0, M=0
12358  *     #These nee to be freed at end
12359  */
12360   __pyx_v_lrwork = (24 * __pyx_v_nrows);
12361   __pyx_v_liwork = (10 * __pyx_v_nrows);
12362 
12363   /* "qutip/cy/brtools.pyx":684
12364  *     cdef int lwork = 18 * nrows
12365  *     cdef int lrwork = 24*nrows, liwork = 10*nrows
12366  *     cdef int info=0, M=0             # <<<<<<<<<<<<<<
12367  *     #These nee to be freed at end
12368  *     cdef int * isuppz = <int *>PyDataMem_NEW((2*nrows) * sizeof(int))
12369  */
12370   __pyx_v_info = 0;
12371   __pyx_v_M = 0;
12372 
12373   /* "qutip/cy/brtools.pyx":686
12374  *     cdef int info=0, M=0
12375  *     #These nee to be freed at end
12376  *     cdef int * isuppz = <int *>PyDataMem_NEW((2*nrows) * sizeof(int))             # <<<<<<<<<<<<<<
12377  *     cdef complex * work = <complex *>PyDataMem_NEW(lwork * sizeof(complex))
12378  *     cdef double * rwork = <double *>PyDataMem_NEW((24*nrows) * sizeof(double))
12379  */
12380   __pyx_v_isuppz = ((int *)PyDataMem_NEW(((2 * __pyx_v_nrows) * (sizeof(int)))));
12381 
12382   /* "qutip/cy/brtools.pyx":687
12383  *     #These nee to be freed at end
12384  *     cdef int * isuppz = <int *>PyDataMem_NEW((2*nrows) * sizeof(int))
12385  *     cdef complex * work = <complex *>PyDataMem_NEW(lwork * sizeof(complex))             # <<<<<<<<<<<<<<
12386  *     cdef double * rwork = <double *>PyDataMem_NEW((24*nrows) * sizeof(double))
12387  *     cdef int * iwork = <int *>PyDataMem_NEW((10*nrows) * sizeof(int))
12388  */
12389   __pyx_v_work = ((__pyx_t_double_complex *)PyDataMem_NEW((__pyx_v_lwork * (sizeof(__pyx_t_double_complex)))));
12390 
12391   /* "qutip/cy/brtools.pyx":688
12392  *     cdef int * isuppz = <int *>PyDataMem_NEW((2*nrows) * sizeof(int))
12393  *     cdef complex * work = <complex *>PyDataMem_NEW(lwork * sizeof(complex))
12394  *     cdef double * rwork = <double *>PyDataMem_NEW((24*nrows) * sizeof(double))             # <<<<<<<<<<<<<<
12395  *     cdef int * iwork = <int *>PyDataMem_NEW((10*nrows) * sizeof(int))
12396  *     cdef complex[:,::1] cZ = <complex[:nrows, :nrows]><complex *>PyDataMem_NEW(nrows**2 * sizeof(complex))
12397  */
12398   __pyx_v_rwork = ((double *)PyDataMem_NEW(((24 * __pyx_v_nrows) * (sizeof(double)))));
12399 
12400   /* "qutip/cy/brtools.pyx":689
12401  *     cdef complex * work = <complex *>PyDataMem_NEW(lwork * sizeof(complex))
12402  *     cdef double * rwork = <double *>PyDataMem_NEW((24*nrows) * sizeof(double))
12403  *     cdef int * iwork = <int *>PyDataMem_NEW((10*nrows) * sizeof(int))             # <<<<<<<<<<<<<<
12404  *     cdef complex[:,::1] cZ = <complex[:nrows, :nrows]><complex *>PyDataMem_NEW(nrows**2 * sizeof(complex))
12405  *     cdef complex[::1,:] Z = cZ.T
12406  */
12407   __pyx_v_iwork = ((int *)PyDataMem_NEW(((10 * __pyx_v_nrows) * (sizeof(int)))));
12408 
12409   /* "qutip/cy/brtools.pyx":690
12410  *     cdef double * rwork = <double *>PyDataMem_NEW((24*nrows) * sizeof(double))
12411  *     cdef int * iwork = <int *>PyDataMem_NEW((10*nrows) * sizeof(int))
12412  *     cdef complex[:,::1] cZ = <complex[:nrows, :nrows]><complex *>PyDataMem_NEW(nrows**2 * sizeof(complex))             # <<<<<<<<<<<<<<
12413  *     cdef complex[::1,:] Z = cZ.T
12414  *
12415  */
12416   __pyx_t_1 = ((__pyx_t_double_complex *)PyDataMem_NEW((__Pyx_pow_long(((long)__pyx_v_nrows), 2) * (sizeof(__pyx_t_double_complex)))));
12417   if (!__pyx_t_1) {
12418     PyErr_SetString(PyExc_ValueError,"Cannot create cython.array from NULL pointer");
12419     __PYX_ERR(1, 690, __pyx_L1_error)
12420   }
12421   __pyx_t_4 = __pyx_format_from_typeinfo(&__Pyx_TypeInfo___pyx_t_double_complex); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 690, __pyx_L1_error)
12422   __Pyx_GOTREF(__pyx_t_4);
12423   __pyx_t_3 = Py_BuildValue((char*) "("  __PYX_BUILD_PY_SSIZE_T  __PYX_BUILD_PY_SSIZE_T  ")", ((Py_ssize_t)__pyx_v_nrows), ((Py_ssize_t)__pyx_v_nrows)); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 690, __pyx_L1_error)
12424   __Pyx_GOTREF(__pyx_t_3);
12425   __pyx_t_2 = __pyx_array_new(__pyx_t_3, sizeof(__pyx_t_double_complex), PyBytes_AS_STRING(__pyx_t_4), (char *) "c", (char *) __pyx_t_1);
12426   if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 690, __pyx_L1_error)
12427   __Pyx_GOTREF(__pyx_t_2);
12428   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
12429   __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
12430   __pyx_t_5 = __Pyx_PyObject_to_MemoryviewSlice_d_dc___pyx_t_double_complex(((PyObject *)__pyx_t_2), PyBUF_WRITABLE); if (unlikely(!__pyx_t_5.memview)) __PYX_ERR(1, 690, __pyx_L1_error)
12431   __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
12432   __pyx_v_cZ = __pyx_t_5;
12433   __pyx_t_5.memview = NULL;
12434   __pyx_t_5.data = NULL;
12435 
12436   /* "qutip/cy/brtools.pyx":691
12437  *     cdef int * iwork = <int *>PyDataMem_NEW((10*nrows) * sizeof(int))
12438  *     cdef complex[:,::1] cZ = <complex[:nrows, :nrows]><complex *>PyDataMem_NEW(nrows**2 * sizeof(complex))
12439  *     cdef complex[::1,:] Z = cZ.T             # <<<<<<<<<<<<<<
12440  *
12441  *     zheevr(&jobz, &rnge, &uplo, &nrows, &H[0,0], &nrows, &vl, &vu, &il, &iu, &abstol,
12442  */
12443   __pyx_t_6 = __pyx_v_cZ;
12444   __PYX_INC_MEMVIEW(&__pyx_t_6, 1);
12445   if (unlikely(__pyx_memslice_transpose(&__pyx_t_6) == 0)) __PYX_ERR(1, 691, __pyx_L1_error)
12446   __pyx_v_Z = __pyx_t_6;
12447   __pyx_t_6.memview = NULL;
12448   __pyx_t_6.data = NULL;
12449 
12450   /* "qutip/cy/brtools.pyx":693
12451  *     cdef complex[::1,:] Z = cZ.T
12452  *
12453  *     zheevr(&jobz, &rnge, &uplo, &nrows, &H[0,0], &nrows, &vl, &vu, &il, &iu, &abstol,             # <<<<<<<<<<<<<<
12454  *            &M, eigvals, &Z[0,0], &nrows, isuppz, work, &lwork,
12455  *           rwork, &lrwork, iwork, &liwork, &info)
12456  */
12457   __pyx_t_7 = 0;
12458   __pyx_t_8 = 0;
12459 
12460   /* "qutip/cy/brtools.pyx":694
12461  *
12462  *     zheevr(&jobz, &rnge, &uplo, &nrows, &H[0,0], &nrows, &vl, &vu, &il, &iu, &abstol,
12463  *            &M, eigvals, &Z[0,0], &nrows, isuppz, work, &lwork,             # <<<<<<<<<<<<<<
12464  *           rwork, &lrwork, iwork, &liwork, &info)
12465  *     PyDataMem_FREE(work)
12466  */
12467   __pyx_t_9 = 0;
12468   __pyx_t_10 = 0;
12469 
12470   /* "qutip/cy/brtools.pyx":693
12471  *     cdef complex[::1,:] Z = cZ.T
12472  *
12473  *     zheevr(&jobz, &rnge, &uplo, &nrows, &H[0,0], &nrows, &vl, &vu, &il, &iu, &abstol,             # <<<<<<<<<<<<<<
12474  *            &M, eigvals, &Z[0,0], &nrows, isuppz, work, &lwork,
12475  *           rwork, &lrwork, iwork, &liwork, &info)
12476  */
12477   __pyx_f_5scipy_6linalg_13cython_lapack_zheevr((&__pyx_v_jobz), (&__pyx_v_rnge), (&__pyx_v_uplo), (&__pyx_v_nrows), (&(*((__pyx_t_double_complex *) ( /* dim=1 */ (( /* dim=0 */ ((char *) (((__pyx_t_double_complex *) __pyx_v_H.data) + __pyx_t_7)) ) + __pyx_t_8 * __pyx_v_H.strides[1]) )))), (&__pyx_v_nrows), (&__pyx_v_vl), (&__pyx_v_vu), (&__pyx_v_il), (&__pyx_v_iu), (&__pyx_v_abstol), (&__pyx_v_M), __pyx_v_eigvals, (&(*((__pyx_t_double_complex *) ( /* dim=1 */ (( /* dim=0 */ ((char *) (((__pyx_t_double_complex *) __pyx_v_Z.data) + __pyx_t_9)) ) + __pyx_t_10 * __pyx_v_Z.strides[1]) )))), (&__pyx_v_nrows), __pyx_v_isuppz, __pyx_v_work, (&__pyx_v_lwork), __pyx_v_rwork, (&__pyx_v_lrwork), __pyx_v_iwork, (&__pyx_v_liwork), (&__pyx_v_info));
12478 
12479   /* "qutip/cy/brtools.pyx":696
12480  *            &M, eigvals, &Z[0,0], &nrows, isuppz, work, &lwork,
12481  *           rwork, &lrwork, iwork, &liwork, &info)
12482  *     PyDataMem_FREE(work)             # <<<<<<<<<<<<<<
12483  *     PyDataMem_FREE(rwork)
12484  *     PyDataMem_FREE(isuppz)
12485  */
12486   PyDataMem_FREE(__pyx_v_work);
12487 
12488   /* "qutip/cy/brtools.pyx":697
12489  *           rwork, &lrwork, iwork, &liwork, &info)
12490  *     PyDataMem_FREE(work)
12491  *     PyDataMem_FREE(rwork)             # <<<<<<<<<<<<<<
12492  *     PyDataMem_FREE(isuppz)
12493  *     PyDataMem_FREE(iwork)
12494  */
12495   PyDataMem_FREE(__pyx_v_rwork);
12496 
12497   /* "qutip/cy/brtools.pyx":698
12498  *     PyDataMem_FREE(work)
12499  *     PyDataMem_FREE(rwork)
12500  *     PyDataMem_FREE(isuppz)             # <<<<<<<<<<<<<<
12501  *     PyDataMem_FREE(iwork)
12502  *     if info != 0:
12503  */
12504   PyDataMem_FREE(__pyx_v_isuppz);
12505 
12506   /* "qutip/cy/brtools.pyx":699
12507  *     PyDataMem_FREE(rwork)
12508  *     PyDataMem_FREE(isuppz)
12509  *     PyDataMem_FREE(iwork)             # <<<<<<<<<<<<<<
12510  *     if info != 0:
12511  *         if info < 0:
12512  */
12513   PyDataMem_FREE(__pyx_v_iwork);
12514 
12515   /* "qutip/cy/brtools.pyx":700
12516  *     PyDataMem_FREE(isuppz)
12517  *     PyDataMem_FREE(iwork)
12518  *     if info != 0:             # <<<<<<<<<<<<<<
12519  *         if info < 0:
12520  *             raise Exception("Error in parameter : %s" & abs(info))
12521  */
12522   __pyx_t_11 = ((__pyx_v_info != 0) != 0);
12523   if (__pyx_t_11) {
12524 
12525     /* "qutip/cy/brtools.pyx":701
12526  *     PyDataMem_FREE(iwork)
12527  *     if info != 0:
12528  *         if info < 0:             # <<<<<<<<<<<<<<
12529  *             raise Exception("Error in parameter : %s" & abs(info))
12530  *         else:
12531  */
12532     __pyx_t_11 = ((__pyx_v_info < 0) != 0);
12533     if (unlikely(__pyx_t_11)) {
12534 
12535       /* "qutip/cy/brtools.pyx":702
12536  *     if info != 0:
12537  *         if info < 0:
12538  *             raise Exception("Error in parameter : %s" & abs(info))             # <<<<<<<<<<<<<<
12539  *         else:
12540  *             raise Exception("Algorithm failed to converge")
12541  */
12542       __pyx_t_12 = abs(__pyx_v_info); if (unlikely(__pyx_t_12 == ((int)-1))) __PYX_ERR(1, 702, __pyx_L1_error)
12543       __pyx_t_4 = __Pyx_PyInt_From_int(__pyx_t_12); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 702, __pyx_L1_error)
12544       __Pyx_GOTREF(__pyx_t_4);
12545       __pyx_t_3 = PyNumber_And(__pyx_kp_u_Error_in_parameter_s, __pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 702, __pyx_L1_error)
12546       __Pyx_GOTREF(__pyx_t_3);
12547       __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
12548       __pyx_t_4 = __Pyx_PyObject_CallOneArg(((PyObject *)(&((PyTypeObject*)PyExc_Exception)[0])), __pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 702, __pyx_L1_error)
12549       __Pyx_GOTREF(__pyx_t_4);
12550       __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
12551       __Pyx_Raise(__pyx_t_4, 0, 0, 0);
12552       __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
12553       __PYX_ERR(1, 702, __pyx_L1_error)
12554 
12555       /* "qutip/cy/brtools.pyx":701
12556  *     PyDataMem_FREE(iwork)
12557  *     if info != 0:
12558  *         if info < 0:             # <<<<<<<<<<<<<<
12559  *             raise Exception("Error in parameter : %s" & abs(info))
12560  *         else:
12561  */
12562     }
12563 
12564     /* "qutip/cy/brtools.pyx":704
12565  *             raise Exception("Error in parameter : %s" & abs(info))
12566  *         else:
12567  *             raise Exception("Algorithm failed to converge")             # <<<<<<<<<<<<<<
12568  *     for jj in range(nrows):
12569  *         for ii in range(nrows):
12570  */
12571     /*else*/ {
12572       __pyx_t_4 = __Pyx_PyObject_Call(((PyObject *)(&((PyTypeObject*)PyExc_Exception)[0])), __pyx_tuple__12, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 704, __pyx_L1_error)
12573       __Pyx_GOTREF(__pyx_t_4);
12574       __Pyx_Raise(__pyx_t_4, 0, 0, 0);
12575       __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
12576       __PYX_ERR(1, 704, __pyx_L1_error)
12577     }
12578 
12579     /* "qutip/cy/brtools.pyx":700
12580  *     PyDataMem_FREE(isuppz)
12581  *     PyDataMem_FREE(iwork)
12582  *     if info != 0:             # <<<<<<<<<<<<<<
12583  *         if info < 0:
12584  *             raise Exception("Error in parameter : %s" & abs(info))
12585  */
12586   }
12587 
12588   /* "qutip/cy/brtools.pyx":705
12589  *         else:
12590  *             raise Exception("Algorithm failed to converge")
12591  *     for jj in range(nrows):             # <<<<<<<<<<<<<<
12592  *         for ii in range(nrows):
12593  *             if cabs(Z[ii,jj]) < atol:
12594  */
12595   __pyx_t_12 = __pyx_v_nrows;
12596   __pyx_t_13 = __pyx_t_12;
12597   for (__pyx_t_14 = 0; __pyx_t_14 < __pyx_t_13; __pyx_t_14+=1) {
12598     __pyx_v_jj = __pyx_t_14;
12599 
12600     /* "qutip/cy/brtools.pyx":706
12601  *             raise Exception("Algorithm failed to converge")
12602  *     for jj in range(nrows):
12603  *         for ii in range(nrows):             # <<<<<<<<<<<<<<
12604  *             if cabs(Z[ii,jj]) < atol:
12605  *                 Z[ii,jj] = 0
12606  */
12607     __pyx_t_15 = __pyx_v_nrows;
12608     __pyx_t_16 = __pyx_t_15;
12609     for (__pyx_t_17 = 0; __pyx_t_17 < __pyx_t_16; __pyx_t_17+=1) {
12610       __pyx_v_ii = __pyx_t_17;
12611 
12612       /* "qutip/cy/brtools.pyx":707
12613  *     for jj in range(nrows):
12614  *         for ii in range(nrows):
12615  *             if cabs(Z[ii,jj]) < atol:             # <<<<<<<<<<<<<<
12616  *                 Z[ii,jj] = 0
12617  *     fdense2D_to_CSR(Z, evecs, nrows, nrows)
12618  */
12619       __pyx_t_18 = __pyx_v_ii;
12620       __pyx_t_19 = __pyx_v_jj;
12621       __pyx_t_11 = ((abs((*((__pyx_t_double_complex *) ( /* dim=1 */ (( /* dim=0 */ ((char *) (((__pyx_t_double_complex *) __pyx_v_Z.data) + __pyx_t_18)) ) + __pyx_t_19 * __pyx_v_Z.strides[1]) )))) < __pyx_v_atol) != 0);
12622       if (__pyx_t_11) {
12623 
12624         /* "qutip/cy/brtools.pyx":708
12625  *         for ii in range(nrows):
12626  *             if cabs(Z[ii,jj]) < atol:
12627  *                 Z[ii,jj] = 0             # <<<<<<<<<<<<<<
12628  *     fdense2D_to_CSR(Z, evecs, nrows, nrows)
12629  *     PyDataMem_FREE(&Z[0,0])
12630  */
12631         __pyx_t_19 = __pyx_v_ii;
12632         __pyx_t_18 = __pyx_v_jj;
12633         *((__pyx_t_double_complex *) ( /* dim=1 */ (( /* dim=0 */ ((char *) (((__pyx_t_double_complex *) __pyx_v_Z.data) + __pyx_t_19)) ) + __pyx_t_18 * __pyx_v_Z.strides[1]) )) = __pyx_t_double_complex_from_parts(0, 0);
12634 
12635         /* "qutip/cy/brtools.pyx":707
12636  *     for jj in range(nrows):
12637  *         for ii in range(nrows):
12638  *             if cabs(Z[ii,jj]) < atol:             # <<<<<<<<<<<<<<
12639  *                 Z[ii,jj] = 0
12640  *     fdense2D_to_CSR(Z, evecs, nrows, nrows)
12641  */
12642       }
12643     }
12644   }
12645 
12646   /* "qutip/cy/brtools.pyx":709
12647  *             if cabs(Z[ii,jj]) < atol:
12648  *                 Z[ii,jj] = 0
12649  *     fdense2D_to_CSR(Z, evecs, nrows, nrows)             # <<<<<<<<<<<<<<
12650  *     PyDataMem_FREE(&Z[0,0])
12651  *
12652  */
12653   __pyx_f_5qutip_2cy_9spconvert_fdense2D_to_CSR(__pyx_v_Z, __pyx_v_evecs, __pyx_v_nrows, __pyx_v_nrows);
12654 
12655   /* "qutip/cy/brtools.pyx":710
12656  *                 Z[ii,jj] = 0
12657  *     fdense2D_to_CSR(Z, evecs, nrows, nrows)
12658  *     PyDataMem_FREE(&Z[0,0])             # <<<<<<<<<<<<<<
12659  *
12660  *
12661  */
12662   __pyx_t_10 = 0;
12663   __pyx_t_9 = 0;
12664   PyDataMem_FREE((&(*((__pyx_t_double_complex *) ( /* dim=1 */ (( /* dim=0 */ ((char *) (((__pyx_t_double_complex *) __pyx_v_Z.data) + __pyx_t_10)) ) + __pyx_t_9 * __pyx_v_Z.strides[1]) )))));
12665 
12666   /* "qutip/cy/brtools.pyx":659
12667  * @cython.boundscheck(False)
12668  * @cython.wraparound(False)
12669  * cdef void sparse_ZHEEVR(complex[::1,:] H, double * eigvals,             # <<<<<<<<<<<<<<
12670  *                     CSR_Matrix * evecs, int nrows, double atol):
12671  *     """
12672  */
12673 
12674   /* function exit code */
12675   goto __pyx_L0;
12676   __pyx_L1_error:;
12677   __Pyx_XDECREF(((PyObject *)__pyx_t_2));
12678   __Pyx_XDECREF(__pyx_t_3);
12679   __Pyx_XDECREF(__pyx_t_4);
12680   __PYX_XDEC_MEMVIEW(&__pyx_t_5, 1);
12681   __PYX_XDEC_MEMVIEW(&__pyx_t_6, 1);
12682   __Pyx_WriteUnraisable("qutip.cy.brtools.sparse_ZHEEVR", __pyx_clineno, __pyx_lineno, __pyx_filename, 1, 0);
12683   __pyx_L0:;
12684   __PYX_XDEC_MEMVIEW(&__pyx_v_cZ, 1);
12685   __PYX_XDEC_MEMVIEW(&__pyx_v_Z, 1);
12686   __Pyx_RefNannyFinishContext();
12687 }
12688 
12689 /* "qutip/cy/brtools.pyx":715
12690  * @cython.boundscheck(False)
12691  * @cython.wraparound(False)
12692  * cdef CSR_Matrix sparse_to_eigbasis(complex[::1] Adata, int[::1] Aind, int[::1] Aptr,             # <<<<<<<<<<<<<<
12693  *                                 CSR_Matrix * evecs, unsigned int nrows):
12694  *     cdef CSR_Matrix A, B, C, A_eig
12695  */
12696 
__pyx_f_5qutip_2cy_7brtools_sparse_to_eigbasis(__Pyx_memviewslice __pyx_v_Adata,__Pyx_memviewslice __pyx_v_Aind,__Pyx_memviewslice __pyx_v_Aptr,__pyx_t_5qutip_2cy_14sparse_structs_CSR_Matrix * __pyx_v_evecs,unsigned int __pyx_v_nrows)12697 static __pyx_t_5qutip_2cy_14sparse_structs_CSR_Matrix __pyx_f_5qutip_2cy_7brtools_sparse_to_eigbasis(__Pyx_memviewslice __pyx_v_Adata, __Pyx_memviewslice __pyx_v_Aind, __Pyx_memviewslice __pyx_v_Aptr, __pyx_t_5qutip_2cy_14sparse_structs_CSR_Matrix *__pyx_v_evecs, unsigned int __pyx_v_nrows) {
12698   __pyx_t_5qutip_2cy_14sparse_structs_CSR_Matrix __pyx_v_A;
12699   __pyx_t_5qutip_2cy_14sparse_structs_CSR_Matrix __pyx_v_B;
12700   __pyx_t_5qutip_2cy_14sparse_structs_CSR_Matrix __pyx_v_C;
12701   __pyx_t_5qutip_2cy_14sparse_structs_CSR_Matrix __pyx_v_A_eig;
12702   __pyx_t_5qutip_2cy_14sparse_structs_CSR_Matrix __pyx_r;
12703   __Pyx_RefNannyDeclarations
12704   Py_ssize_t __pyx_t_1;
12705   int __pyx_t_2;
12706   __Pyx_RefNannySetupContext("sparse_to_eigbasis", 0);
12707 
12708   /* "qutip/cy/brtools.pyx":718
12709  *                                 CSR_Matrix * evecs, unsigned int nrows):
12710  *     cdef CSR_Matrix A, B, C, A_eig
12711  *     A.data = &Adata[0]             # <<<<<<<<<<<<<<
12712  *     A.indices = &Aind[0]
12713  *     A.indptr = &Aptr[0]
12714  */
12715   __pyx_t_1 = 0;
12716   __pyx_v_A.data = (&(*((__pyx_t_double_complex *) ( /* dim=0 */ ((char *) (((__pyx_t_double_complex *) __pyx_v_Adata.data) + __pyx_t_1)) ))));
12717 
12718   /* "qutip/cy/brtools.pyx":719
12719  *     cdef CSR_Matrix A, B, C, A_eig
12720  *     A.data = &Adata[0]
12721  *     A.indices = &Aind[0]             # <<<<<<<<<<<<<<
12722  *     A.indptr = &Aptr[0]
12723  *     A.nnz = A.indptr[nrows]
12724  */
12725   __pyx_t_1 = 0;
12726   __pyx_v_A.indices = (&(*((int *) ( /* dim=0 */ ((char *) (((int *) __pyx_v_Aind.data) + __pyx_t_1)) ))));
12727 
12728   /* "qutip/cy/brtools.pyx":720
12729  *     A.data = &Adata[0]
12730  *     A.indices = &Aind[0]
12731  *     A.indptr = &Aptr[0]             # <<<<<<<<<<<<<<
12732  *     A.nnz = A.indptr[nrows]
12733  *     A.nrows = nrows
12734  */
12735   __pyx_t_1 = 0;
12736   __pyx_v_A.indptr = (&(*((int *) ( /* dim=0 */ ((char *) (((int *) __pyx_v_Aptr.data) + __pyx_t_1)) ))));
12737 
12738   /* "qutip/cy/brtools.pyx":721
12739  *     A.indices = &Aind[0]
12740  *     A.indptr = &Aptr[0]
12741  *     A.nnz = A.indptr[nrows]             # <<<<<<<<<<<<<<
12742  *     A.nrows = nrows
12743  *     A.ncols = nrows
12744  */
12745   __pyx_v_A.nnz = (__pyx_v_A.indptr[__pyx_v_nrows]);
12746 
12747   /* "qutip/cy/brtools.pyx":722
12748  *     A.indptr = &Aptr[0]
12749  *     A.nnz = A.indptr[nrows]
12750  *     A.nrows = nrows             # <<<<<<<<<<<<<<
12751  *     A.ncols = nrows
12752  *     A.max_length = A.nnz
12753  */
12754   __pyx_v_A.nrows = __pyx_v_nrows;
12755 
12756   /* "qutip/cy/brtools.pyx":723
12757  *     A.nnz = A.indptr[nrows]
12758  *     A.nrows = nrows
12759  *     A.ncols = nrows             # <<<<<<<<<<<<<<
12760  *     A.max_length = A.nnz
12761  *     A.numpy_lock = 1
12762  */
12763   __pyx_v_A.ncols = __pyx_v_nrows;
12764 
12765   /* "qutip/cy/brtools.pyx":724
12766  *     A.nrows = nrows
12767  *     A.ncols = nrows
12768  *     A.max_length = A.nnz             # <<<<<<<<<<<<<<
12769  *     A.numpy_lock = 1
12770  *     A.is_set = 1
12771  */
12772   __pyx_t_2 = __pyx_v_A.nnz;
12773   __pyx_v_A.max_length = __pyx_t_2;
12774 
12775   /* "qutip/cy/brtools.pyx":725
12776  *     A.ncols = nrows
12777  *     A.max_length = A.nnz
12778  *     A.numpy_lock = 1             # <<<<<<<<<<<<<<
12779  *     A.is_set = 1
12780  *
12781  */
12782   __pyx_v_A.numpy_lock = 1;
12783 
12784   /* "qutip/cy/brtools.pyx":726
12785  *     A.max_length = A.nnz
12786  *     A.numpy_lock = 1
12787  *     A.is_set = 1             # <<<<<<<<<<<<<<
12788  *
12789  *     _zcsr_mult(&A, evecs, &B)
12790  */
12791   __pyx_v_A.is_set = 1;
12792 
12793   /* "qutip/cy/brtools.pyx":728
12794  *     A.is_set = 1
12795  *
12796  *     _zcsr_mult(&A, evecs, &B)             # <<<<<<<<<<<<<<
12797  *     _zcsr_adjoint(evecs, &C)
12798  *     _zcsr_mult(&C, &B, &A_eig)
12799  */
12800   __pyx_f_5qutip_2cy_6spmath__zcsr_mult((&__pyx_v_A), __pyx_v_evecs, (&__pyx_v_B));
12801 
12802   /* "qutip/cy/brtools.pyx":729
12803  *
12804  *     _zcsr_mult(&A, evecs, &B)
12805  *     _zcsr_adjoint(evecs, &C)             # <<<<<<<<<<<<<<
12806  *     _zcsr_mult(&C, &B, &A_eig)
12807  *     sort_indices(&A_eig)
12808  */
12809   __pyx_f_5qutip_2cy_6spmath__zcsr_adjoint(__pyx_v_evecs, (&__pyx_v_C));
12810 
12811   /* "qutip/cy/brtools.pyx":730
12812  *     _zcsr_mult(&A, evecs, &B)
12813  *     _zcsr_adjoint(evecs, &C)
12814  *     _zcsr_mult(&C, &B, &A_eig)             # <<<<<<<<<<<<<<
12815  *     sort_indices(&A_eig)
12816  *     free_CSR(&B)
12817  */
12818   __pyx_f_5qutip_2cy_6spmath__zcsr_mult((&__pyx_v_C), (&__pyx_v_B), (&__pyx_v_A_eig));
12819 
12820   /* "qutip/cy/brtools.pyx":731
12821  *     _zcsr_adjoint(evecs, &C)
12822  *     _zcsr_mult(&C, &B, &A_eig)
12823  *     sort_indices(&A_eig)             # <<<<<<<<<<<<<<
12824  *     free_CSR(&B)
12825  *     free_CSR(&C)
12826  */
12827   __pyx_f_5qutip_2cy_7brtools_sort_indices((&__pyx_v_A_eig));
12828 
12829   /* "qutip/cy/brtools.pyx":732
12830  *     _zcsr_mult(&C, &B, &A_eig)
12831  *     sort_indices(&A_eig)
12832  *     free_CSR(&B)             # <<<<<<<<<<<<<<
12833  *     free_CSR(&C)
12834  *     return A_eig
12835  */
12836   __pyx_f_5qutip_2cy_7brtools_free_CSR((&__pyx_v_B));
12837 
12838   /* "qutip/cy/brtools.pyx":733
12839  *     sort_indices(&A_eig)
12840  *     free_CSR(&B)
12841  *     free_CSR(&C)             # <<<<<<<<<<<<<<
12842  *     return A_eig
12843  */
12844   __pyx_f_5qutip_2cy_7brtools_free_CSR((&__pyx_v_C));
12845 
12846   /* "qutip/cy/brtools.pyx":734
12847  *     free_CSR(&B)
12848  *     free_CSR(&C)
12849  *     return A_eig             # <<<<<<<<<<<<<<
12850  */
12851   __pyx_r = __pyx_v_A_eig;
12852   goto __pyx_L0;
12853 
12854   /* "qutip/cy/brtools.pyx":715
12855  * @cython.boundscheck(False)
12856  * @cython.wraparound(False)
12857  * cdef CSR_Matrix sparse_to_eigbasis(complex[::1] Adata, int[::1] Aind, int[::1] Aptr,             # <<<<<<<<<<<<<<
12858  *                                 CSR_Matrix * evecs, unsigned int nrows):
12859  *     cdef CSR_Matrix A, B, C, A_eig
12860  */
12861 
12862   /* function exit code */
12863   __pyx_L0:;
12864   __Pyx_RefNannyFinishContext();
12865   return __pyx_r;
12866 }
12867 
12868 /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":734
12869  * ctypedef npy_cdouble     complex_t
12870  *
12871  * cdef inline object PyArray_MultiIterNew1(a):             # <<<<<<<<<<<<<<
12872  *     return PyArray_MultiIterNew(1, <void*>a)
12873  *
12874  */
12875 
__pyx_f_5numpy_PyArray_MultiIterNew1(PyObject * __pyx_v_a)12876 static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew1(PyObject *__pyx_v_a) {
12877   PyObject *__pyx_r = NULL;
12878   __Pyx_RefNannyDeclarations
12879   PyObject *__pyx_t_1 = NULL;
12880   int __pyx_lineno = 0;
12881   const char *__pyx_filename = NULL;
12882   int __pyx_clineno = 0;
12883   __Pyx_RefNannySetupContext("PyArray_MultiIterNew1", 0);
12884 
12885   /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":735
12886  *
12887  * cdef inline object PyArray_MultiIterNew1(a):
12888  *     return PyArray_MultiIterNew(1, <void*>a)             # <<<<<<<<<<<<<<
12889  *
12890  * cdef inline object PyArray_MultiIterNew2(a, b):
12891  */
12892   __Pyx_XDECREF(__pyx_r);
12893   __pyx_t_1 = PyArray_MultiIterNew(1, ((void *)__pyx_v_a)); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 735, __pyx_L1_error)
12894   __Pyx_GOTREF(__pyx_t_1);
12895   __pyx_r = __pyx_t_1;
12896   __pyx_t_1 = 0;
12897   goto __pyx_L0;
12898 
12899   /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":734
12900  * ctypedef npy_cdouble     complex_t
12901  *
12902  * cdef inline object PyArray_MultiIterNew1(a):             # <<<<<<<<<<<<<<
12903  *     return PyArray_MultiIterNew(1, <void*>a)
12904  *
12905  */
12906 
12907   /* function exit code */
12908   __pyx_L1_error:;
12909   __Pyx_XDECREF(__pyx_t_1);
12910   __Pyx_AddTraceback("numpy.PyArray_MultiIterNew1", __pyx_clineno, __pyx_lineno, __pyx_filename);
12911   __pyx_r = 0;
12912   __pyx_L0:;
12913   __Pyx_XGIVEREF(__pyx_r);
12914   __Pyx_RefNannyFinishContext();
12915   return __pyx_r;
12916 }
12917 
12918 /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":737
12919  *     return PyArray_MultiIterNew(1, <void*>a)
12920  *
12921  * cdef inline object PyArray_MultiIterNew2(a, b):             # <<<<<<<<<<<<<<
12922  *     return PyArray_MultiIterNew(2, <void*>a, <void*>b)
12923  *
12924  */
12925 
__pyx_f_5numpy_PyArray_MultiIterNew2(PyObject * __pyx_v_a,PyObject * __pyx_v_b)12926 static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew2(PyObject *__pyx_v_a, PyObject *__pyx_v_b) {
12927   PyObject *__pyx_r = NULL;
12928   __Pyx_RefNannyDeclarations
12929   PyObject *__pyx_t_1 = NULL;
12930   int __pyx_lineno = 0;
12931   const char *__pyx_filename = NULL;
12932   int __pyx_clineno = 0;
12933   __Pyx_RefNannySetupContext("PyArray_MultiIterNew2", 0);
12934 
12935   /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":738
12936  *
12937  * cdef inline object PyArray_MultiIterNew2(a, b):
12938  *     return PyArray_MultiIterNew(2, <void*>a, <void*>b)             # <<<<<<<<<<<<<<
12939  *
12940  * cdef inline object PyArray_MultiIterNew3(a, b, c):
12941  */
12942   __Pyx_XDECREF(__pyx_r);
12943   __pyx_t_1 = PyArray_MultiIterNew(2, ((void *)__pyx_v_a), ((void *)__pyx_v_b)); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 738, __pyx_L1_error)
12944   __Pyx_GOTREF(__pyx_t_1);
12945   __pyx_r = __pyx_t_1;
12946   __pyx_t_1 = 0;
12947   goto __pyx_L0;
12948 
12949   /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":737
12950  *     return PyArray_MultiIterNew(1, <void*>a)
12951  *
12952  * cdef inline object PyArray_MultiIterNew2(a, b):             # <<<<<<<<<<<<<<
12953  *     return PyArray_MultiIterNew(2, <void*>a, <void*>b)
12954  *
12955  */
12956 
12957   /* function exit code */
12958   __pyx_L1_error:;
12959   __Pyx_XDECREF(__pyx_t_1);
12960   __Pyx_AddTraceback("numpy.PyArray_MultiIterNew2", __pyx_clineno, __pyx_lineno, __pyx_filename);
12961   __pyx_r = 0;
12962   __pyx_L0:;
12963   __Pyx_XGIVEREF(__pyx_r);
12964   __Pyx_RefNannyFinishContext();
12965   return __pyx_r;
12966 }
12967 
12968 /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":740
12969  *     return PyArray_MultiIterNew(2, <void*>a, <void*>b)
12970  *
12971  * cdef inline object PyArray_MultiIterNew3(a, b, c):             # <<<<<<<<<<<<<<
12972  *     return PyArray_MultiIterNew(3, <void*>a, <void*>b, <void*> c)
12973  *
12974  */
12975 
__pyx_f_5numpy_PyArray_MultiIterNew3(PyObject * __pyx_v_a,PyObject * __pyx_v_b,PyObject * __pyx_v_c)12976 static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew3(PyObject *__pyx_v_a, PyObject *__pyx_v_b, PyObject *__pyx_v_c) {
12977   PyObject *__pyx_r = NULL;
12978   __Pyx_RefNannyDeclarations
12979   PyObject *__pyx_t_1 = NULL;
12980   int __pyx_lineno = 0;
12981   const char *__pyx_filename = NULL;
12982   int __pyx_clineno = 0;
12983   __Pyx_RefNannySetupContext("PyArray_MultiIterNew3", 0);
12984 
12985   /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":741
12986  *
12987  * cdef inline object PyArray_MultiIterNew3(a, b, c):
12988  *     return PyArray_MultiIterNew(3, <void*>a, <void*>b, <void*> c)             # <<<<<<<<<<<<<<
12989  *
12990  * cdef inline object PyArray_MultiIterNew4(a, b, c, d):
12991  */
12992   __Pyx_XDECREF(__pyx_r);
12993   __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(2, 741, __pyx_L1_error)
12994   __Pyx_GOTREF(__pyx_t_1);
12995   __pyx_r = __pyx_t_1;
12996   __pyx_t_1 = 0;
12997   goto __pyx_L0;
12998 
12999   /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":740
13000  *     return PyArray_MultiIterNew(2, <void*>a, <void*>b)
13001  *
13002  * cdef inline object PyArray_MultiIterNew3(a, b, c):             # <<<<<<<<<<<<<<
13003  *     return PyArray_MultiIterNew(3, <void*>a, <void*>b, <void*> c)
13004  *
13005  */
13006 
13007   /* function exit code */
13008   __pyx_L1_error:;
13009   __Pyx_XDECREF(__pyx_t_1);
13010   __Pyx_AddTraceback("numpy.PyArray_MultiIterNew3", __pyx_clineno, __pyx_lineno, __pyx_filename);
13011   __pyx_r = 0;
13012   __pyx_L0:;
13013   __Pyx_XGIVEREF(__pyx_r);
13014   __Pyx_RefNannyFinishContext();
13015   return __pyx_r;
13016 }
13017 
13018 /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":743
13019  *     return PyArray_MultiIterNew(3, <void*>a, <void*>b, <void*> c)
13020  *
13021  * cdef inline object PyArray_MultiIterNew4(a, b, c, d):             # <<<<<<<<<<<<<<
13022  *     return PyArray_MultiIterNew(4, <void*>a, <void*>b, <void*>c, <void*> d)
13023  *
13024  */
13025 
__pyx_f_5numpy_PyArray_MultiIterNew4(PyObject * __pyx_v_a,PyObject * __pyx_v_b,PyObject * __pyx_v_c,PyObject * __pyx_v_d)13026 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) {
13027   PyObject *__pyx_r = NULL;
13028   __Pyx_RefNannyDeclarations
13029   PyObject *__pyx_t_1 = NULL;
13030   int __pyx_lineno = 0;
13031   const char *__pyx_filename = NULL;
13032   int __pyx_clineno = 0;
13033   __Pyx_RefNannySetupContext("PyArray_MultiIterNew4", 0);
13034 
13035   /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":744
13036  *
13037  * cdef inline object PyArray_MultiIterNew4(a, b, c, d):
13038  *     return PyArray_MultiIterNew(4, <void*>a, <void*>b, <void*>c, <void*> d)             # <<<<<<<<<<<<<<
13039  *
13040  * cdef inline object PyArray_MultiIterNew5(a, b, c, d, e):
13041  */
13042   __Pyx_XDECREF(__pyx_r);
13043   __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(2, 744, __pyx_L1_error)
13044   __Pyx_GOTREF(__pyx_t_1);
13045   __pyx_r = __pyx_t_1;
13046   __pyx_t_1 = 0;
13047   goto __pyx_L0;
13048 
13049   /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":743
13050  *     return PyArray_MultiIterNew(3, <void*>a, <void*>b, <void*> c)
13051  *
13052  * cdef inline object PyArray_MultiIterNew4(a, b, c, d):             # <<<<<<<<<<<<<<
13053  *     return PyArray_MultiIterNew(4, <void*>a, <void*>b, <void*>c, <void*> d)
13054  *
13055  */
13056 
13057   /* function exit code */
13058   __pyx_L1_error:;
13059   __Pyx_XDECREF(__pyx_t_1);
13060   __Pyx_AddTraceback("numpy.PyArray_MultiIterNew4", __pyx_clineno, __pyx_lineno, __pyx_filename);
13061   __pyx_r = 0;
13062   __pyx_L0:;
13063   __Pyx_XGIVEREF(__pyx_r);
13064   __Pyx_RefNannyFinishContext();
13065   return __pyx_r;
13066 }
13067 
13068 /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":746
13069  *     return PyArray_MultiIterNew(4, <void*>a, <void*>b, <void*>c, <void*> d)
13070  *
13071  * cdef inline object PyArray_MultiIterNew5(a, b, c, d, e):             # <<<<<<<<<<<<<<
13072  *     return PyArray_MultiIterNew(5, <void*>a, <void*>b, <void*>c, <void*> d, <void*> e)
13073  *
13074  */
13075 
__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)13076 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) {
13077   PyObject *__pyx_r = NULL;
13078   __Pyx_RefNannyDeclarations
13079   PyObject *__pyx_t_1 = NULL;
13080   int __pyx_lineno = 0;
13081   const char *__pyx_filename = NULL;
13082   int __pyx_clineno = 0;
13083   __Pyx_RefNannySetupContext("PyArray_MultiIterNew5", 0);
13084 
13085   /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":747
13086  *
13087  * cdef inline object PyArray_MultiIterNew5(a, b, c, d, e):
13088  *     return PyArray_MultiIterNew(5, <void*>a, <void*>b, <void*>c, <void*> d, <void*> e)             # <<<<<<<<<<<<<<
13089  *
13090  * cdef inline tuple PyDataType_SHAPE(dtype d):
13091  */
13092   __Pyx_XDECREF(__pyx_r);
13093   __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(2, 747, __pyx_L1_error)
13094   __Pyx_GOTREF(__pyx_t_1);
13095   __pyx_r = __pyx_t_1;
13096   __pyx_t_1 = 0;
13097   goto __pyx_L0;
13098 
13099   /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":746
13100  *     return PyArray_MultiIterNew(4, <void*>a, <void*>b, <void*>c, <void*> d)
13101  *
13102  * cdef inline object PyArray_MultiIterNew5(a, b, c, d, e):             # <<<<<<<<<<<<<<
13103  *     return PyArray_MultiIterNew(5, <void*>a, <void*>b, <void*>c, <void*> d, <void*> e)
13104  *
13105  */
13106 
13107   /* function exit code */
13108   __pyx_L1_error:;
13109   __Pyx_XDECREF(__pyx_t_1);
13110   __Pyx_AddTraceback("numpy.PyArray_MultiIterNew5", __pyx_clineno, __pyx_lineno, __pyx_filename);
13111   __pyx_r = 0;
13112   __pyx_L0:;
13113   __Pyx_XGIVEREF(__pyx_r);
13114   __Pyx_RefNannyFinishContext();
13115   return __pyx_r;
13116 }
13117 
13118 /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":749
13119  *     return PyArray_MultiIterNew(5, <void*>a, <void*>b, <void*>c, <void*> d, <void*> e)
13120  *
13121  * cdef inline tuple PyDataType_SHAPE(dtype d):             # <<<<<<<<<<<<<<
13122  *     if PyDataType_HASSUBARRAY(d):
13123  *         return <tuple>d.subarray.shape
13124  */
13125 
__pyx_f_5numpy_PyDataType_SHAPE(PyArray_Descr * __pyx_v_d)13126 static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyDataType_SHAPE(PyArray_Descr *__pyx_v_d) {
13127   PyObject *__pyx_r = NULL;
13128   __Pyx_RefNannyDeclarations
13129   int __pyx_t_1;
13130   __Pyx_RefNannySetupContext("PyDataType_SHAPE", 0);
13131 
13132   /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":750
13133  *
13134  * cdef inline tuple PyDataType_SHAPE(dtype d):
13135  *     if PyDataType_HASSUBARRAY(d):             # <<<<<<<<<<<<<<
13136  *         return <tuple>d.subarray.shape
13137  *     else:
13138  */
13139   __pyx_t_1 = (PyDataType_HASSUBARRAY(__pyx_v_d) != 0);
13140   if (__pyx_t_1) {
13141 
13142     /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":751
13143  * cdef inline tuple PyDataType_SHAPE(dtype d):
13144  *     if PyDataType_HASSUBARRAY(d):
13145  *         return <tuple>d.subarray.shape             # <<<<<<<<<<<<<<
13146  *     else:
13147  *         return ()
13148  */
13149     __Pyx_XDECREF(__pyx_r);
13150     __Pyx_INCREF(((PyObject*)__pyx_v_d->subarray->shape));
13151     __pyx_r = ((PyObject*)__pyx_v_d->subarray->shape);
13152     goto __pyx_L0;
13153 
13154     /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":750
13155  *
13156  * cdef inline tuple PyDataType_SHAPE(dtype d):
13157  *     if PyDataType_HASSUBARRAY(d):             # <<<<<<<<<<<<<<
13158  *         return <tuple>d.subarray.shape
13159  *     else:
13160  */
13161   }
13162 
13163   /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":753
13164  *         return <tuple>d.subarray.shape
13165  *     else:
13166  *         return ()             # <<<<<<<<<<<<<<
13167  *
13168  *
13169  */
13170   /*else*/ {
13171     __Pyx_XDECREF(__pyx_r);
13172     __Pyx_INCREF(__pyx_empty_tuple);
13173     __pyx_r = __pyx_empty_tuple;
13174     goto __pyx_L0;
13175   }
13176 
13177   /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":749
13178  *     return PyArray_MultiIterNew(5, <void*>a, <void*>b, <void*>c, <void*> d, <void*> e)
13179  *
13180  * cdef inline tuple PyDataType_SHAPE(dtype d):             # <<<<<<<<<<<<<<
13181  *     if PyDataType_HASSUBARRAY(d):
13182  *         return <tuple>d.subarray.shape
13183  */
13184 
13185   /* function exit code */
13186   __pyx_L0:;
13187   __Pyx_XGIVEREF(__pyx_r);
13188   __Pyx_RefNannyFinishContext();
13189   return __pyx_r;
13190 }
13191 
13192 /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":868
13193  *     int _import_umath() except -1
13194  *
13195  * cdef inline void set_array_base(ndarray arr, object base):             # <<<<<<<<<<<<<<
13196  *     Py_INCREF(base) # important to do this before stealing the reference below!
13197  *     PyArray_SetBaseObject(arr, base)
13198  */
13199 
__pyx_f_5numpy_set_array_base(PyArrayObject * __pyx_v_arr,PyObject * __pyx_v_base)13200 static CYTHON_INLINE void __pyx_f_5numpy_set_array_base(PyArrayObject *__pyx_v_arr, PyObject *__pyx_v_base) {
13201   __Pyx_RefNannyDeclarations
13202   __Pyx_RefNannySetupContext("set_array_base", 0);
13203 
13204   /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":869
13205  *
13206  * cdef inline void set_array_base(ndarray arr, object base):
13207  *     Py_INCREF(base) # important to do this before stealing the reference below!             # <<<<<<<<<<<<<<
13208  *     PyArray_SetBaseObject(arr, base)
13209  *
13210  */
13211   Py_INCREF(__pyx_v_base);
13212 
13213   /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":870
13214  * cdef inline void set_array_base(ndarray arr, object base):
13215  *     Py_INCREF(base) # important to do this before stealing the reference below!
13216  *     PyArray_SetBaseObject(arr, base)             # <<<<<<<<<<<<<<
13217  *
13218  * cdef inline object get_array_base(ndarray arr):
13219  */
13220   (void)(PyArray_SetBaseObject(__pyx_v_arr, __pyx_v_base));
13221 
13222   /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":868
13223  *     int _import_umath() except -1
13224  *
13225  * cdef inline void set_array_base(ndarray arr, object base):             # <<<<<<<<<<<<<<
13226  *     Py_INCREF(base) # important to do this before stealing the reference below!
13227  *     PyArray_SetBaseObject(arr, base)
13228  */
13229 
13230   /* function exit code */
13231   __Pyx_RefNannyFinishContext();
13232 }
13233 
13234 /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":872
13235  *     PyArray_SetBaseObject(arr, base)
13236  *
13237  * cdef inline object get_array_base(ndarray arr):             # <<<<<<<<<<<<<<
13238  *     base = PyArray_BASE(arr)
13239  *     if base is NULL:
13240  */
13241 
__pyx_f_5numpy_get_array_base(PyArrayObject * __pyx_v_arr)13242 static CYTHON_INLINE PyObject *__pyx_f_5numpy_get_array_base(PyArrayObject *__pyx_v_arr) {
13243   PyObject *__pyx_v_base;
13244   PyObject *__pyx_r = NULL;
13245   __Pyx_RefNannyDeclarations
13246   int __pyx_t_1;
13247   __Pyx_RefNannySetupContext("get_array_base", 0);
13248 
13249   /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":873
13250  *
13251  * cdef inline object get_array_base(ndarray arr):
13252  *     base = PyArray_BASE(arr)             # <<<<<<<<<<<<<<
13253  *     if base is NULL:
13254  *         return None
13255  */
13256   __pyx_v_base = PyArray_BASE(__pyx_v_arr);
13257 
13258   /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":874
13259  * cdef inline object get_array_base(ndarray arr):
13260  *     base = PyArray_BASE(arr)
13261  *     if base is NULL:             # <<<<<<<<<<<<<<
13262  *         return None
13263  *     return <object>base
13264  */
13265   __pyx_t_1 = ((__pyx_v_base == NULL) != 0);
13266   if (__pyx_t_1) {
13267 
13268     /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":875
13269  *     base = PyArray_BASE(arr)
13270  *     if base is NULL:
13271  *         return None             # <<<<<<<<<<<<<<
13272  *     return <object>base
13273  *
13274  */
13275     __Pyx_XDECREF(__pyx_r);
13276     __pyx_r = Py_None; __Pyx_INCREF(Py_None);
13277     goto __pyx_L0;
13278 
13279     /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":874
13280  * cdef inline object get_array_base(ndarray arr):
13281  *     base = PyArray_BASE(arr)
13282  *     if base is NULL:             # <<<<<<<<<<<<<<
13283  *         return None
13284  *     return <object>base
13285  */
13286   }
13287 
13288   /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":876
13289  *     if base is NULL:
13290  *         return None
13291  *     return <object>base             # <<<<<<<<<<<<<<
13292  *
13293  * # Versions of the import_* functions which are more suitable for
13294  */
13295   __Pyx_XDECREF(__pyx_r);
13296   __Pyx_INCREF(((PyObject *)__pyx_v_base));
13297   __pyx_r = ((PyObject *)__pyx_v_base);
13298   goto __pyx_L0;
13299 
13300   /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":872
13301  *     PyArray_SetBaseObject(arr, base)
13302  *
13303  * cdef inline object get_array_base(ndarray arr):             # <<<<<<<<<<<<<<
13304  *     base = PyArray_BASE(arr)
13305  *     if base is NULL:
13306  */
13307 
13308   /* function exit code */
13309   __pyx_L0:;
13310   __Pyx_XGIVEREF(__pyx_r);
13311   __Pyx_RefNannyFinishContext();
13312   return __pyx_r;
13313 }
13314 
13315 /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":880
13316  * # Versions of the import_* functions which are more suitable for
13317  * # Cython code.
13318  * cdef inline int import_array() except -1:             # <<<<<<<<<<<<<<
13319  *     try:
13320  *         __pyx_import_array()
13321  */
13322 
__pyx_f_5numpy_import_array(void)13323 static CYTHON_INLINE int __pyx_f_5numpy_import_array(void) {
13324   int __pyx_r;
13325   __Pyx_RefNannyDeclarations
13326   PyObject *__pyx_t_1 = NULL;
13327   PyObject *__pyx_t_2 = NULL;
13328   PyObject *__pyx_t_3 = NULL;
13329   int __pyx_t_4;
13330   PyObject *__pyx_t_5 = NULL;
13331   PyObject *__pyx_t_6 = NULL;
13332   PyObject *__pyx_t_7 = NULL;
13333   PyObject *__pyx_t_8 = NULL;
13334   int __pyx_lineno = 0;
13335   const char *__pyx_filename = NULL;
13336   int __pyx_clineno = 0;
13337   __Pyx_RefNannySetupContext("import_array", 0);
13338 
13339   /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":881
13340  * # Cython code.
13341  * cdef inline int import_array() except -1:
13342  *     try:             # <<<<<<<<<<<<<<
13343  *         __pyx_import_array()
13344  *     except Exception:
13345  */
13346   {
13347     __Pyx_PyThreadState_declare
13348     __Pyx_PyThreadState_assign
13349     __Pyx_ExceptionSave(&__pyx_t_1, &__pyx_t_2, &__pyx_t_3);
13350     __Pyx_XGOTREF(__pyx_t_1);
13351     __Pyx_XGOTREF(__pyx_t_2);
13352     __Pyx_XGOTREF(__pyx_t_3);
13353     /*try:*/ {
13354 
13355       /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":882
13356  * cdef inline int import_array() except -1:
13357  *     try:
13358  *         __pyx_import_array()             # <<<<<<<<<<<<<<
13359  *     except Exception:
13360  *         raise ImportError("numpy.core.multiarray failed to import")
13361  */
13362       __pyx_t_4 = _import_array(); if (unlikely(__pyx_t_4 == ((int)-1))) __PYX_ERR(2, 882, __pyx_L3_error)
13363 
13364       /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":881
13365  * # Cython code.
13366  * cdef inline int import_array() except -1:
13367  *     try:             # <<<<<<<<<<<<<<
13368  *         __pyx_import_array()
13369  *     except Exception:
13370  */
13371     }
13372     __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
13373     __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
13374     __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
13375     goto __pyx_L8_try_end;
13376     __pyx_L3_error:;
13377 
13378     /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":883
13379  *     try:
13380  *         __pyx_import_array()
13381  *     except Exception:             # <<<<<<<<<<<<<<
13382  *         raise ImportError("numpy.core.multiarray failed to import")
13383  *
13384  */
13385     __pyx_t_4 = __Pyx_PyErr_ExceptionMatches(((PyObject *)(&((PyTypeObject*)PyExc_Exception)[0])));
13386     if (__pyx_t_4) {
13387       __Pyx_AddTraceback("numpy.import_array", __pyx_clineno, __pyx_lineno, __pyx_filename);
13388       if (__Pyx_GetException(&__pyx_t_5, &__pyx_t_6, &__pyx_t_7) < 0) __PYX_ERR(2, 883, __pyx_L5_except_error)
13389       __Pyx_GOTREF(__pyx_t_5);
13390       __Pyx_GOTREF(__pyx_t_6);
13391       __Pyx_GOTREF(__pyx_t_7);
13392 
13393       /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":884
13394  *         __pyx_import_array()
13395  *     except Exception:
13396  *         raise ImportError("numpy.core.multiarray failed to import")             # <<<<<<<<<<<<<<
13397  *
13398  * cdef inline int import_umath() except -1:
13399  */
13400       __pyx_t_8 = __Pyx_PyObject_Call(__pyx_builtin_ImportError, __pyx_tuple__19, NULL); if (unlikely(!__pyx_t_8)) __PYX_ERR(2, 884, __pyx_L5_except_error)
13401       __Pyx_GOTREF(__pyx_t_8);
13402       __Pyx_Raise(__pyx_t_8, 0, 0, 0);
13403       __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
13404       __PYX_ERR(2, 884, __pyx_L5_except_error)
13405     }
13406     goto __pyx_L5_except_error;
13407     __pyx_L5_except_error:;
13408 
13409     /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":881
13410  * # Cython code.
13411  * cdef inline int import_array() except -1:
13412  *     try:             # <<<<<<<<<<<<<<
13413  *         __pyx_import_array()
13414  *     except Exception:
13415  */
13416     __Pyx_XGIVEREF(__pyx_t_1);
13417     __Pyx_XGIVEREF(__pyx_t_2);
13418     __Pyx_XGIVEREF(__pyx_t_3);
13419     __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3);
13420     goto __pyx_L1_error;
13421     __pyx_L8_try_end:;
13422   }
13423 
13424   /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":880
13425  * # Versions of the import_* functions which are more suitable for
13426  * # Cython code.
13427  * cdef inline int import_array() except -1:             # <<<<<<<<<<<<<<
13428  *     try:
13429  *         __pyx_import_array()
13430  */
13431 
13432   /* function exit code */
13433   __pyx_r = 0;
13434   goto __pyx_L0;
13435   __pyx_L1_error:;
13436   __Pyx_XDECREF(__pyx_t_5);
13437   __Pyx_XDECREF(__pyx_t_6);
13438   __Pyx_XDECREF(__pyx_t_7);
13439   __Pyx_XDECREF(__pyx_t_8);
13440   __Pyx_AddTraceback("numpy.import_array", __pyx_clineno, __pyx_lineno, __pyx_filename);
13441   __pyx_r = -1;
13442   __pyx_L0:;
13443   __Pyx_RefNannyFinishContext();
13444   return __pyx_r;
13445 }
13446 
13447 /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":886
13448  *         raise ImportError("numpy.core.multiarray failed to import")
13449  *
13450  * cdef inline int import_umath() except -1:             # <<<<<<<<<<<<<<
13451  *     try:
13452  *         _import_umath()
13453  */
13454 
__pyx_f_5numpy_import_umath(void)13455 static CYTHON_INLINE int __pyx_f_5numpy_import_umath(void) {
13456   int __pyx_r;
13457   __Pyx_RefNannyDeclarations
13458   PyObject *__pyx_t_1 = NULL;
13459   PyObject *__pyx_t_2 = NULL;
13460   PyObject *__pyx_t_3 = NULL;
13461   int __pyx_t_4;
13462   PyObject *__pyx_t_5 = NULL;
13463   PyObject *__pyx_t_6 = NULL;
13464   PyObject *__pyx_t_7 = NULL;
13465   PyObject *__pyx_t_8 = NULL;
13466   int __pyx_lineno = 0;
13467   const char *__pyx_filename = NULL;
13468   int __pyx_clineno = 0;
13469   __Pyx_RefNannySetupContext("import_umath", 0);
13470 
13471   /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":887
13472  *
13473  * cdef inline int import_umath() except -1:
13474  *     try:             # <<<<<<<<<<<<<<
13475  *         _import_umath()
13476  *     except Exception:
13477  */
13478   {
13479     __Pyx_PyThreadState_declare
13480     __Pyx_PyThreadState_assign
13481     __Pyx_ExceptionSave(&__pyx_t_1, &__pyx_t_2, &__pyx_t_3);
13482     __Pyx_XGOTREF(__pyx_t_1);
13483     __Pyx_XGOTREF(__pyx_t_2);
13484     __Pyx_XGOTREF(__pyx_t_3);
13485     /*try:*/ {
13486 
13487       /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":888
13488  * cdef inline int import_umath() except -1:
13489  *     try:
13490  *         _import_umath()             # <<<<<<<<<<<<<<
13491  *     except Exception:
13492  *         raise ImportError("numpy.core.umath failed to import")
13493  */
13494       __pyx_t_4 = _import_umath(); if (unlikely(__pyx_t_4 == ((int)-1))) __PYX_ERR(2, 888, __pyx_L3_error)
13495 
13496       /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":887
13497  *
13498  * cdef inline int import_umath() except -1:
13499  *     try:             # <<<<<<<<<<<<<<
13500  *         _import_umath()
13501  *     except Exception:
13502  */
13503     }
13504     __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
13505     __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
13506     __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
13507     goto __pyx_L8_try_end;
13508     __pyx_L3_error:;
13509 
13510     /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":889
13511  *     try:
13512  *         _import_umath()
13513  *     except Exception:             # <<<<<<<<<<<<<<
13514  *         raise ImportError("numpy.core.umath failed to import")
13515  *
13516  */
13517     __pyx_t_4 = __Pyx_PyErr_ExceptionMatches(((PyObject *)(&((PyTypeObject*)PyExc_Exception)[0])));
13518     if (__pyx_t_4) {
13519       __Pyx_AddTraceback("numpy.import_umath", __pyx_clineno, __pyx_lineno, __pyx_filename);
13520       if (__Pyx_GetException(&__pyx_t_5, &__pyx_t_6, &__pyx_t_7) < 0) __PYX_ERR(2, 889, __pyx_L5_except_error)
13521       __Pyx_GOTREF(__pyx_t_5);
13522       __Pyx_GOTREF(__pyx_t_6);
13523       __Pyx_GOTREF(__pyx_t_7);
13524 
13525       /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":890
13526  *         _import_umath()
13527  *     except Exception:
13528  *         raise ImportError("numpy.core.umath failed to import")             # <<<<<<<<<<<<<<
13529  *
13530  * cdef inline int import_ufunc() except -1:
13531  */
13532       __pyx_t_8 = __Pyx_PyObject_Call(__pyx_builtin_ImportError, __pyx_tuple__20, NULL); if (unlikely(!__pyx_t_8)) __PYX_ERR(2, 890, __pyx_L5_except_error)
13533       __Pyx_GOTREF(__pyx_t_8);
13534       __Pyx_Raise(__pyx_t_8, 0, 0, 0);
13535       __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
13536       __PYX_ERR(2, 890, __pyx_L5_except_error)
13537     }
13538     goto __pyx_L5_except_error;
13539     __pyx_L5_except_error:;
13540 
13541     /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":887
13542  *
13543  * cdef inline int import_umath() except -1:
13544  *     try:             # <<<<<<<<<<<<<<
13545  *         _import_umath()
13546  *     except Exception:
13547  */
13548     __Pyx_XGIVEREF(__pyx_t_1);
13549     __Pyx_XGIVEREF(__pyx_t_2);
13550     __Pyx_XGIVEREF(__pyx_t_3);
13551     __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3);
13552     goto __pyx_L1_error;
13553     __pyx_L8_try_end:;
13554   }
13555 
13556   /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":886
13557  *         raise ImportError("numpy.core.multiarray failed to import")
13558  *
13559  * cdef inline int import_umath() except -1:             # <<<<<<<<<<<<<<
13560  *     try:
13561  *         _import_umath()
13562  */
13563 
13564   /* function exit code */
13565   __pyx_r = 0;
13566   goto __pyx_L0;
13567   __pyx_L1_error:;
13568   __Pyx_XDECREF(__pyx_t_5);
13569   __Pyx_XDECREF(__pyx_t_6);
13570   __Pyx_XDECREF(__pyx_t_7);
13571   __Pyx_XDECREF(__pyx_t_8);
13572   __Pyx_AddTraceback("numpy.import_umath", __pyx_clineno, __pyx_lineno, __pyx_filename);
13573   __pyx_r = -1;
13574   __pyx_L0:;
13575   __Pyx_RefNannyFinishContext();
13576   return __pyx_r;
13577 }
13578 
13579 /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":892
13580  *         raise ImportError("numpy.core.umath failed to import")
13581  *
13582  * cdef inline int import_ufunc() except -1:             # <<<<<<<<<<<<<<
13583  *     try:
13584  *         _import_umath()
13585  */
13586 
__pyx_f_5numpy_import_ufunc(void)13587 static CYTHON_INLINE int __pyx_f_5numpy_import_ufunc(void) {
13588   int __pyx_r;
13589   __Pyx_RefNannyDeclarations
13590   PyObject *__pyx_t_1 = NULL;
13591   PyObject *__pyx_t_2 = NULL;
13592   PyObject *__pyx_t_3 = NULL;
13593   int __pyx_t_4;
13594   PyObject *__pyx_t_5 = NULL;
13595   PyObject *__pyx_t_6 = NULL;
13596   PyObject *__pyx_t_7 = NULL;
13597   PyObject *__pyx_t_8 = NULL;
13598   int __pyx_lineno = 0;
13599   const char *__pyx_filename = NULL;
13600   int __pyx_clineno = 0;
13601   __Pyx_RefNannySetupContext("import_ufunc", 0);
13602 
13603   /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":893
13604  *
13605  * cdef inline int import_ufunc() except -1:
13606  *     try:             # <<<<<<<<<<<<<<
13607  *         _import_umath()
13608  *     except Exception:
13609  */
13610   {
13611     __Pyx_PyThreadState_declare
13612     __Pyx_PyThreadState_assign
13613     __Pyx_ExceptionSave(&__pyx_t_1, &__pyx_t_2, &__pyx_t_3);
13614     __Pyx_XGOTREF(__pyx_t_1);
13615     __Pyx_XGOTREF(__pyx_t_2);
13616     __Pyx_XGOTREF(__pyx_t_3);
13617     /*try:*/ {
13618 
13619       /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":894
13620  * cdef inline int import_ufunc() except -1:
13621  *     try:
13622  *         _import_umath()             # <<<<<<<<<<<<<<
13623  *     except Exception:
13624  *         raise ImportError("numpy.core.umath failed to import")
13625  */
13626       __pyx_t_4 = _import_umath(); if (unlikely(__pyx_t_4 == ((int)-1))) __PYX_ERR(2, 894, __pyx_L3_error)
13627 
13628       /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":893
13629  *
13630  * cdef inline int import_ufunc() except -1:
13631  *     try:             # <<<<<<<<<<<<<<
13632  *         _import_umath()
13633  *     except Exception:
13634  */
13635     }
13636     __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
13637     __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
13638     __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
13639     goto __pyx_L8_try_end;
13640     __pyx_L3_error:;
13641 
13642     /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":895
13643  *     try:
13644  *         _import_umath()
13645  *     except Exception:             # <<<<<<<<<<<<<<
13646  *         raise ImportError("numpy.core.umath failed to import")
13647  *
13648  */
13649     __pyx_t_4 = __Pyx_PyErr_ExceptionMatches(((PyObject *)(&((PyTypeObject*)PyExc_Exception)[0])));
13650     if (__pyx_t_4) {
13651       __Pyx_AddTraceback("numpy.import_ufunc", __pyx_clineno, __pyx_lineno, __pyx_filename);
13652       if (__Pyx_GetException(&__pyx_t_5, &__pyx_t_6, &__pyx_t_7) < 0) __PYX_ERR(2, 895, __pyx_L5_except_error)
13653       __Pyx_GOTREF(__pyx_t_5);
13654       __Pyx_GOTREF(__pyx_t_6);
13655       __Pyx_GOTREF(__pyx_t_7);
13656 
13657       /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":896
13658  *         _import_umath()
13659  *     except Exception:
13660  *         raise ImportError("numpy.core.umath failed to import")             # <<<<<<<<<<<<<<
13661  *
13662  * cdef extern from *:
13663  */
13664       __pyx_t_8 = __Pyx_PyObject_Call(__pyx_builtin_ImportError, __pyx_tuple__20, NULL); if (unlikely(!__pyx_t_8)) __PYX_ERR(2, 896, __pyx_L5_except_error)
13665       __Pyx_GOTREF(__pyx_t_8);
13666       __Pyx_Raise(__pyx_t_8, 0, 0, 0);
13667       __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
13668       __PYX_ERR(2, 896, __pyx_L5_except_error)
13669     }
13670     goto __pyx_L5_except_error;
13671     __pyx_L5_except_error:;
13672 
13673     /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":893
13674  *
13675  * cdef inline int import_ufunc() except -1:
13676  *     try:             # <<<<<<<<<<<<<<
13677  *         _import_umath()
13678  *     except Exception:
13679  */
13680     __Pyx_XGIVEREF(__pyx_t_1);
13681     __Pyx_XGIVEREF(__pyx_t_2);
13682     __Pyx_XGIVEREF(__pyx_t_3);
13683     __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3);
13684     goto __pyx_L1_error;
13685     __pyx_L8_try_end:;
13686   }
13687 
13688   /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":892
13689  *         raise ImportError("numpy.core.umath failed to import")
13690  *
13691  * cdef inline int import_ufunc() except -1:             # <<<<<<<<<<<<<<
13692  *     try:
13693  *         _import_umath()
13694  */
13695 
13696   /* function exit code */
13697   __pyx_r = 0;
13698   goto __pyx_L0;
13699   __pyx_L1_error:;
13700   __Pyx_XDECREF(__pyx_t_5);
13701   __Pyx_XDECREF(__pyx_t_6);
13702   __Pyx_XDECREF(__pyx_t_7);
13703   __Pyx_XDECREF(__pyx_t_8);
13704   __Pyx_AddTraceback("numpy.import_ufunc", __pyx_clineno, __pyx_lineno, __pyx_filename);
13705   __pyx_r = -1;
13706   __pyx_L0:;
13707   __Pyx_RefNannyFinishContext();
13708   return __pyx_r;
13709 }
13710 
13711 /* "View.MemoryView":122
13712  *         cdef bint dtype_is_object
13713  *
13714  *     def __cinit__(array self, tuple shape, Py_ssize_t itemsize, format not None,             # <<<<<<<<<<<<<<
13715  *                   mode="c", bint allocate_buffer=True):
13716  *
13717  */
13718 
13719 /* Python wrapper */
13720 static int __pyx_array___cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
__pyx_array___cinit__(PyObject * __pyx_v_self,PyObject * __pyx_args,PyObject * __pyx_kwds)13721 static int __pyx_array___cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
13722   PyObject *__pyx_v_shape = 0;
13723   Py_ssize_t __pyx_v_itemsize;
13724   PyObject *__pyx_v_format = 0;
13725   PyObject *__pyx_v_mode = 0;
13726   int __pyx_v_allocate_buffer;
13727   int __pyx_lineno = 0;
13728   const char *__pyx_filename = NULL;
13729   int __pyx_clineno = 0;
13730   int __pyx_r;
13731   __Pyx_RefNannyDeclarations
13732   __Pyx_RefNannySetupContext("__cinit__ (wrapper)", 0);
13733   {
13734     static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_shape,&__pyx_n_s_itemsize,&__pyx_n_s_format,&__pyx_n_s_mode,&__pyx_n_s_allocate_buffer,0};
13735     PyObject* values[5] = {0,0,0,0,0};
13736     values[3] = ((PyObject *)__pyx_n_s_c);
13737     if (unlikely(__pyx_kwds)) {
13738       Py_ssize_t kw_args;
13739       const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
13740       switch (pos_args) {
13741         case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
13742         CYTHON_FALLTHROUGH;
13743         case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
13744         CYTHON_FALLTHROUGH;
13745         case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
13746         CYTHON_FALLTHROUGH;
13747         case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
13748         CYTHON_FALLTHROUGH;
13749         case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
13750         CYTHON_FALLTHROUGH;
13751         case  0: break;
13752         default: goto __pyx_L5_argtuple_error;
13753       }
13754       kw_args = PyDict_Size(__pyx_kwds);
13755       switch (pos_args) {
13756         case  0:
13757         if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_shape)) != 0)) kw_args--;
13758         else goto __pyx_L5_argtuple_error;
13759         CYTHON_FALLTHROUGH;
13760         case  1:
13761         if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_itemsize)) != 0)) kw_args--;
13762         else {
13763           __Pyx_RaiseArgtupleInvalid("__cinit__", 0, 3, 5, 1); __PYX_ERR(3, 122, __pyx_L3_error)
13764         }
13765         CYTHON_FALLTHROUGH;
13766         case  2:
13767         if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_format)) != 0)) kw_args--;
13768         else {
13769           __Pyx_RaiseArgtupleInvalid("__cinit__", 0, 3, 5, 2); __PYX_ERR(3, 122, __pyx_L3_error)
13770         }
13771         CYTHON_FALLTHROUGH;
13772         case  3:
13773         if (kw_args > 0) {
13774           PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_mode);
13775           if (value) { values[3] = value; kw_args--; }
13776         }
13777         CYTHON_FALLTHROUGH;
13778         case  4:
13779         if (kw_args > 0) {
13780           PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_allocate_buffer);
13781           if (value) { values[4] = value; kw_args--; }
13782         }
13783       }
13784       if (unlikely(kw_args > 0)) {
13785         if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__cinit__") < 0)) __PYX_ERR(3, 122, __pyx_L3_error)
13786       }
13787     } else {
13788       switch (PyTuple_GET_SIZE(__pyx_args)) {
13789         case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
13790         CYTHON_FALLTHROUGH;
13791         case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
13792         CYTHON_FALLTHROUGH;
13793         case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
13794         values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
13795         values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
13796         break;
13797         default: goto __pyx_L5_argtuple_error;
13798       }
13799     }
13800     __pyx_v_shape = ((PyObject*)values[0]);
13801     __pyx_v_itemsize = __Pyx_PyIndex_AsSsize_t(values[1]); if (unlikely((__pyx_v_itemsize == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(3, 122, __pyx_L3_error)
13802     __pyx_v_format = values[2];
13803     __pyx_v_mode = values[3];
13804     if (values[4]) {
13805       __pyx_v_allocate_buffer = __Pyx_PyObject_IsTrue(values[4]); if (unlikely((__pyx_v_allocate_buffer == (int)-1) && PyErr_Occurred())) __PYX_ERR(3, 123, __pyx_L3_error)
13806     } else {
13807 
13808       /* "View.MemoryView":123
13809  *
13810  *     def __cinit__(array self, tuple shape, Py_ssize_t itemsize, format not None,
13811  *                   mode="c", bint allocate_buffer=True):             # <<<<<<<<<<<<<<
13812  *
13813  *         cdef int idx
13814  */
13815       __pyx_v_allocate_buffer = ((int)1);
13816     }
13817   }
13818   goto __pyx_L4_argument_unpacking_done;
13819   __pyx_L5_argtuple_error:;
13820   __Pyx_RaiseArgtupleInvalid("__cinit__", 0, 3, 5, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(3, 122, __pyx_L3_error)
13821   __pyx_L3_error:;
13822   __Pyx_AddTraceback("View.MemoryView.array.__cinit__", __pyx_clineno, __pyx_lineno, __pyx_filename);
13823   __Pyx_RefNannyFinishContext();
13824   return -1;
13825   __pyx_L4_argument_unpacking_done:;
13826   if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_shape), (&PyTuple_Type), 1, "shape", 1))) __PYX_ERR(3, 122, __pyx_L1_error)
13827   if (unlikely(((PyObject *)__pyx_v_format) == Py_None)) {
13828     PyErr_Format(PyExc_TypeError, "Argument '%.200s' must not be None", "format"); __PYX_ERR(3, 122, __pyx_L1_error)
13829   }
13830   __pyx_r = __pyx_array___pyx_pf_15View_dot_MemoryView_5array___cinit__(((struct __pyx_array_obj *)__pyx_v_self), __pyx_v_shape, __pyx_v_itemsize, __pyx_v_format, __pyx_v_mode, __pyx_v_allocate_buffer);
13831 
13832   /* "View.MemoryView":122
13833  *         cdef bint dtype_is_object
13834  *
13835  *     def __cinit__(array self, tuple shape, Py_ssize_t itemsize, format not None,             # <<<<<<<<<<<<<<
13836  *                   mode="c", bint allocate_buffer=True):
13837  *
13838  */
13839 
13840   /* function exit code */
13841   goto __pyx_L0;
13842   __pyx_L1_error:;
13843   __pyx_r = -1;
13844   __pyx_L0:;
13845   __Pyx_RefNannyFinishContext();
13846   return __pyx_r;
13847 }
13848 
__pyx_array___pyx_pf_15View_dot_MemoryView_5array___cinit__(struct __pyx_array_obj * __pyx_v_self,PyObject * __pyx_v_shape,Py_ssize_t __pyx_v_itemsize,PyObject * __pyx_v_format,PyObject * __pyx_v_mode,int __pyx_v_allocate_buffer)13849 static int __pyx_array___pyx_pf_15View_dot_MemoryView_5array___cinit__(struct __pyx_array_obj *__pyx_v_self, PyObject *__pyx_v_shape, Py_ssize_t __pyx_v_itemsize, PyObject *__pyx_v_format, PyObject *__pyx_v_mode, int __pyx_v_allocate_buffer) {
13850   int __pyx_v_idx;
13851   Py_ssize_t __pyx_v_i;
13852   Py_ssize_t __pyx_v_dim;
13853   PyObject **__pyx_v_p;
13854   char __pyx_v_order;
13855   int __pyx_r;
13856   __Pyx_RefNannyDeclarations
13857   Py_ssize_t __pyx_t_1;
13858   int __pyx_t_2;
13859   PyObject *__pyx_t_3 = NULL;
13860   int __pyx_t_4;
13861   PyObject *__pyx_t_5 = NULL;
13862   PyObject *__pyx_t_6 = NULL;
13863   char *__pyx_t_7;
13864   int __pyx_t_8;
13865   Py_ssize_t __pyx_t_9;
13866   PyObject *__pyx_t_10 = NULL;
13867   Py_ssize_t __pyx_t_11;
13868   int __pyx_lineno = 0;
13869   const char *__pyx_filename = NULL;
13870   int __pyx_clineno = 0;
13871   __Pyx_RefNannySetupContext("__cinit__", 0);
13872   __Pyx_INCREF(__pyx_v_format);
13873 
13874   /* "View.MemoryView":129
13875  *         cdef PyObject **p
13876  *
13877  *         self.ndim = <int> len(shape)             # <<<<<<<<<<<<<<
13878  *         self.itemsize = itemsize
13879  *
13880  */
13881   if (unlikely(__pyx_v_shape == Py_None)) {
13882     PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
13883     __PYX_ERR(3, 129, __pyx_L1_error)
13884   }
13885   __pyx_t_1 = PyTuple_GET_SIZE(__pyx_v_shape); if (unlikely(__pyx_t_1 == ((Py_ssize_t)-1))) __PYX_ERR(3, 129, __pyx_L1_error)
13886   __pyx_v_self->ndim = ((int)__pyx_t_1);
13887 
13888   /* "View.MemoryView":130
13889  *
13890  *         self.ndim = <int> len(shape)
13891  *         self.itemsize = itemsize             # <<<<<<<<<<<<<<
13892  *
13893  *         if not self.ndim:
13894  */
13895   __pyx_v_self->itemsize = __pyx_v_itemsize;
13896 
13897   /* "View.MemoryView":132
13898  *         self.itemsize = itemsize
13899  *
13900  *         if not self.ndim:             # <<<<<<<<<<<<<<
13901  *             raise ValueError("Empty shape tuple for cython.array")
13902  *
13903  */
13904   __pyx_t_2 = ((!(__pyx_v_self->ndim != 0)) != 0);
13905   if (unlikely(__pyx_t_2)) {
13906 
13907     /* "View.MemoryView":133
13908  *
13909  *         if not self.ndim:
13910  *             raise ValueError("Empty shape tuple for cython.array")             # <<<<<<<<<<<<<<
13911  *
13912  *         if itemsize <= 0:
13913  */
13914     __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__21, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(3, 133, __pyx_L1_error)
13915     __Pyx_GOTREF(__pyx_t_3);
13916     __Pyx_Raise(__pyx_t_3, 0, 0, 0);
13917     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
13918     __PYX_ERR(3, 133, __pyx_L1_error)
13919 
13920     /* "View.MemoryView":132
13921  *         self.itemsize = itemsize
13922  *
13923  *         if not self.ndim:             # <<<<<<<<<<<<<<
13924  *             raise ValueError("Empty shape tuple for cython.array")
13925  *
13926  */
13927   }
13928 
13929   /* "View.MemoryView":135
13930  *             raise ValueError("Empty shape tuple for cython.array")
13931  *
13932  *         if itemsize <= 0:             # <<<<<<<<<<<<<<
13933  *             raise ValueError("itemsize <= 0 for cython.array")
13934  *
13935  */
13936   __pyx_t_2 = ((__pyx_v_itemsize <= 0) != 0);
13937   if (unlikely(__pyx_t_2)) {
13938 
13939     /* "View.MemoryView":136
13940  *
13941  *         if itemsize <= 0:
13942  *             raise ValueError("itemsize <= 0 for cython.array")             # <<<<<<<<<<<<<<
13943  *
13944  *         if not isinstance(format, bytes):
13945  */
13946     __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__22, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(3, 136, __pyx_L1_error)
13947     __Pyx_GOTREF(__pyx_t_3);
13948     __Pyx_Raise(__pyx_t_3, 0, 0, 0);
13949     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
13950     __PYX_ERR(3, 136, __pyx_L1_error)
13951 
13952     /* "View.MemoryView":135
13953  *             raise ValueError("Empty shape tuple for cython.array")
13954  *
13955  *         if itemsize <= 0:             # <<<<<<<<<<<<<<
13956  *             raise ValueError("itemsize <= 0 for cython.array")
13957  *
13958  */
13959   }
13960 
13961   /* "View.MemoryView":138
13962  *             raise ValueError("itemsize <= 0 for cython.array")
13963  *
13964  *         if not isinstance(format, bytes):             # <<<<<<<<<<<<<<
13965  *             format = format.encode('ASCII')
13966  *         self._format = format  # keep a reference to the byte string
13967  */
13968   __pyx_t_2 = PyBytes_Check(__pyx_v_format);
13969   __pyx_t_4 = ((!(__pyx_t_2 != 0)) != 0);
13970   if (__pyx_t_4) {
13971 
13972     /* "View.MemoryView":139
13973  *
13974  *         if not isinstance(format, bytes):
13975  *             format = format.encode('ASCII')             # <<<<<<<<<<<<<<
13976  *         self._format = format  # keep a reference to the byte string
13977  *         self.format = self._format
13978  */
13979     __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_format, __pyx_n_s_encode); if (unlikely(!__pyx_t_5)) __PYX_ERR(3, 139, __pyx_L1_error)
13980     __Pyx_GOTREF(__pyx_t_5);
13981     __pyx_t_6 = NULL;
13982     if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_5))) {
13983       __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_5);
13984       if (likely(__pyx_t_6)) {
13985         PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
13986         __Pyx_INCREF(__pyx_t_6);
13987         __Pyx_INCREF(function);
13988         __Pyx_DECREF_SET(__pyx_t_5, function);
13989       }
13990     }
13991     __pyx_t_3 = (__pyx_t_6) ? __Pyx_PyObject_Call2Args(__pyx_t_5, __pyx_t_6, __pyx_n_s_ASCII) : __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_n_s_ASCII);
13992     __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
13993     if (unlikely(!__pyx_t_3)) __PYX_ERR(3, 139, __pyx_L1_error)
13994     __Pyx_GOTREF(__pyx_t_3);
13995     __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
13996     __Pyx_DECREF_SET(__pyx_v_format, __pyx_t_3);
13997     __pyx_t_3 = 0;
13998 
13999     /* "View.MemoryView":138
14000  *             raise ValueError("itemsize <= 0 for cython.array")
14001  *
14002  *         if not isinstance(format, bytes):             # <<<<<<<<<<<<<<
14003  *             format = format.encode('ASCII')
14004  *         self._format = format  # keep a reference to the byte string
14005  */
14006   }
14007 
14008   /* "View.MemoryView":140
14009  *         if not isinstance(format, bytes):
14010  *             format = format.encode('ASCII')
14011  *         self._format = format  # keep a reference to the byte string             # <<<<<<<<<<<<<<
14012  *         self.format = self._format
14013  *
14014  */
14015   if (!(likely(PyBytes_CheckExact(__pyx_v_format))||((__pyx_v_format) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "bytes", Py_TYPE(__pyx_v_format)->tp_name), 0))) __PYX_ERR(3, 140, __pyx_L1_error)
14016   __pyx_t_3 = __pyx_v_format;
14017   __Pyx_INCREF(__pyx_t_3);
14018   __Pyx_GIVEREF(__pyx_t_3);
14019   __Pyx_GOTREF(__pyx_v_self->_format);
14020   __Pyx_DECREF(__pyx_v_self->_format);
14021   __pyx_v_self->_format = ((PyObject*)__pyx_t_3);
14022   __pyx_t_3 = 0;
14023 
14024   /* "View.MemoryView":141
14025  *             format = format.encode('ASCII')
14026  *         self._format = format  # keep a reference to the byte string
14027  *         self.format = self._format             # <<<<<<<<<<<<<<
14028  *
14029  *
14030  */
14031   if (unlikely(__pyx_v_self->_format == Py_None)) {
14032     PyErr_SetString(PyExc_TypeError, "expected bytes, NoneType found");
14033     __PYX_ERR(3, 141, __pyx_L1_error)
14034   }
14035   __pyx_t_7 = __Pyx_PyBytes_AsWritableString(__pyx_v_self->_format); if (unlikely((!__pyx_t_7) && PyErr_Occurred())) __PYX_ERR(3, 141, __pyx_L1_error)
14036   __pyx_v_self->format = __pyx_t_7;
14037 
14038   /* "View.MemoryView":144
14039  *
14040  *
14041  *         self._shape = <Py_ssize_t *> PyObject_Malloc(sizeof(Py_ssize_t)*self.ndim*2)             # <<<<<<<<<<<<<<
14042  *         self._strides = self._shape + self.ndim
14043  *
14044  */
14045   __pyx_v_self->_shape = ((Py_ssize_t *)PyObject_Malloc((((sizeof(Py_ssize_t)) * __pyx_v_self->ndim) * 2)));
14046 
14047   /* "View.MemoryView":145
14048  *
14049  *         self._shape = <Py_ssize_t *> PyObject_Malloc(sizeof(Py_ssize_t)*self.ndim*2)
14050  *         self._strides = self._shape + self.ndim             # <<<<<<<<<<<<<<
14051  *
14052  *         if not self._shape:
14053  */
14054   __pyx_v_self->_strides = (__pyx_v_self->_shape + __pyx_v_self->ndim);
14055 
14056   /* "View.MemoryView":147
14057  *         self._strides = self._shape + self.ndim
14058  *
14059  *         if not self._shape:             # <<<<<<<<<<<<<<
14060  *             raise MemoryError("unable to allocate shape and strides.")
14061  *
14062  */
14063   __pyx_t_4 = ((!(__pyx_v_self->_shape != 0)) != 0);
14064   if (unlikely(__pyx_t_4)) {
14065 
14066     /* "View.MemoryView":148
14067  *
14068  *         if not self._shape:
14069  *             raise MemoryError("unable to allocate shape and strides.")             # <<<<<<<<<<<<<<
14070  *
14071  *
14072  */
14073     __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_MemoryError, __pyx_tuple__23, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(3, 148, __pyx_L1_error)
14074     __Pyx_GOTREF(__pyx_t_3);
14075     __Pyx_Raise(__pyx_t_3, 0, 0, 0);
14076     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
14077     __PYX_ERR(3, 148, __pyx_L1_error)
14078 
14079     /* "View.MemoryView":147
14080  *         self._strides = self._shape + self.ndim
14081  *
14082  *         if not self._shape:             # <<<<<<<<<<<<<<
14083  *             raise MemoryError("unable to allocate shape and strides.")
14084  *
14085  */
14086   }
14087 
14088   /* "View.MemoryView":151
14089  *
14090  *
14091  *         for idx, dim in enumerate(shape):             # <<<<<<<<<<<<<<
14092  *             if dim <= 0:
14093  *                 raise ValueError("Invalid shape in axis %d: %d." % (idx, dim))
14094  */
14095   __pyx_t_8 = 0;
14096   __pyx_t_3 = __pyx_v_shape; __Pyx_INCREF(__pyx_t_3); __pyx_t_1 = 0;
14097   for (;;) {
14098     if (__pyx_t_1 >= PyTuple_GET_SIZE(__pyx_t_3)) break;
14099     #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
14100     __pyx_t_5 = PyTuple_GET_ITEM(__pyx_t_3, __pyx_t_1); __Pyx_INCREF(__pyx_t_5); __pyx_t_1++; if (unlikely(0 < 0)) __PYX_ERR(3, 151, __pyx_L1_error)
14101     #else
14102     __pyx_t_5 = PySequence_ITEM(__pyx_t_3, __pyx_t_1); __pyx_t_1++; if (unlikely(!__pyx_t_5)) __PYX_ERR(3, 151, __pyx_L1_error)
14103     __Pyx_GOTREF(__pyx_t_5);
14104     #endif
14105     __pyx_t_9 = __Pyx_PyIndex_AsSsize_t(__pyx_t_5); if (unlikely((__pyx_t_9 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(3, 151, __pyx_L1_error)
14106     __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
14107     __pyx_v_dim = __pyx_t_9;
14108     __pyx_v_idx = __pyx_t_8;
14109     __pyx_t_8 = (__pyx_t_8 + 1);
14110 
14111     /* "View.MemoryView":152
14112  *
14113  *         for idx, dim in enumerate(shape):
14114  *             if dim <= 0:             # <<<<<<<<<<<<<<
14115  *                 raise ValueError("Invalid shape in axis %d: %d." % (idx, dim))
14116  *             self._shape[idx] = dim
14117  */
14118     __pyx_t_4 = ((__pyx_v_dim <= 0) != 0);
14119     if (unlikely(__pyx_t_4)) {
14120 
14121       /* "View.MemoryView":153
14122  *         for idx, dim in enumerate(shape):
14123  *             if dim <= 0:
14124  *                 raise ValueError("Invalid shape in axis %d: %d." % (idx, dim))             # <<<<<<<<<<<<<<
14125  *             self._shape[idx] = dim
14126  *
14127  */
14128       __pyx_t_5 = __Pyx_PyInt_From_int(__pyx_v_idx); if (unlikely(!__pyx_t_5)) __PYX_ERR(3, 153, __pyx_L1_error)
14129       __Pyx_GOTREF(__pyx_t_5);
14130       __pyx_t_6 = PyInt_FromSsize_t(__pyx_v_dim); if (unlikely(!__pyx_t_6)) __PYX_ERR(3, 153, __pyx_L1_error)
14131       __Pyx_GOTREF(__pyx_t_6);
14132       __pyx_t_10 = PyTuple_New(2); if (unlikely(!__pyx_t_10)) __PYX_ERR(3, 153, __pyx_L1_error)
14133       __Pyx_GOTREF(__pyx_t_10);
14134       __Pyx_GIVEREF(__pyx_t_5);
14135       PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_5);
14136       __Pyx_GIVEREF(__pyx_t_6);
14137       PyTuple_SET_ITEM(__pyx_t_10, 1, __pyx_t_6);
14138       __pyx_t_5 = 0;
14139       __pyx_t_6 = 0;
14140       __pyx_t_6 = __Pyx_PyString_Format(__pyx_kp_s_Invalid_shape_in_axis_d_d, __pyx_t_10); if (unlikely(!__pyx_t_6)) __PYX_ERR(3, 153, __pyx_L1_error)
14141       __Pyx_GOTREF(__pyx_t_6);
14142       __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
14143       __pyx_t_10 = __Pyx_PyObject_CallOneArg(__pyx_builtin_ValueError, __pyx_t_6); if (unlikely(!__pyx_t_10)) __PYX_ERR(3, 153, __pyx_L1_error)
14144       __Pyx_GOTREF(__pyx_t_10);
14145       __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
14146       __Pyx_Raise(__pyx_t_10, 0, 0, 0);
14147       __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
14148       __PYX_ERR(3, 153, __pyx_L1_error)
14149 
14150       /* "View.MemoryView":152
14151  *
14152  *         for idx, dim in enumerate(shape):
14153  *             if dim <= 0:             # <<<<<<<<<<<<<<
14154  *                 raise ValueError("Invalid shape in axis %d: %d." % (idx, dim))
14155  *             self._shape[idx] = dim
14156  */
14157     }
14158 
14159     /* "View.MemoryView":154
14160  *             if dim <= 0:
14161  *                 raise ValueError("Invalid shape in axis %d: %d." % (idx, dim))
14162  *             self._shape[idx] = dim             # <<<<<<<<<<<<<<
14163  *
14164  *         cdef char order
14165  */
14166     (__pyx_v_self->_shape[__pyx_v_idx]) = __pyx_v_dim;
14167 
14168     /* "View.MemoryView":151
14169  *
14170  *
14171  *         for idx, dim in enumerate(shape):             # <<<<<<<<<<<<<<
14172  *             if dim <= 0:
14173  *                 raise ValueError("Invalid shape in axis %d: %d." % (idx, dim))
14174  */
14175   }
14176   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
14177 
14178   /* "View.MemoryView":157
14179  *
14180  *         cdef char order
14181  *         if mode == 'fortran':             # <<<<<<<<<<<<<<
14182  *             order = b'F'
14183  *             self.mode = u'fortran'
14184  */
14185   __pyx_t_4 = (__Pyx_PyString_Equals(__pyx_v_mode, __pyx_n_s_fortran, Py_EQ)); if (unlikely(__pyx_t_4 < 0)) __PYX_ERR(3, 157, __pyx_L1_error)
14186   if (__pyx_t_4) {
14187 
14188     /* "View.MemoryView":158
14189  *         cdef char order
14190  *         if mode == 'fortran':
14191  *             order = b'F'             # <<<<<<<<<<<<<<
14192  *             self.mode = u'fortran'
14193  *         elif mode == 'c':
14194  */
14195     __pyx_v_order = 'F';
14196 
14197     /* "View.MemoryView":159
14198  *         if mode == 'fortran':
14199  *             order = b'F'
14200  *             self.mode = u'fortran'             # <<<<<<<<<<<<<<
14201  *         elif mode == 'c':
14202  *             order = b'C'
14203  */
14204     __Pyx_INCREF(__pyx_n_u_fortran);
14205     __Pyx_GIVEREF(__pyx_n_u_fortran);
14206     __Pyx_GOTREF(__pyx_v_self->mode);
14207     __Pyx_DECREF(__pyx_v_self->mode);
14208     __pyx_v_self->mode = __pyx_n_u_fortran;
14209 
14210     /* "View.MemoryView":157
14211  *
14212  *         cdef char order
14213  *         if mode == 'fortran':             # <<<<<<<<<<<<<<
14214  *             order = b'F'
14215  *             self.mode = u'fortran'
14216  */
14217     goto __pyx_L10;
14218   }
14219 
14220   /* "View.MemoryView":160
14221  *             order = b'F'
14222  *             self.mode = u'fortran'
14223  *         elif mode == 'c':             # <<<<<<<<<<<<<<
14224  *             order = b'C'
14225  *             self.mode = u'c'
14226  */
14227   __pyx_t_4 = (__Pyx_PyString_Equals(__pyx_v_mode, __pyx_n_s_c, Py_EQ)); if (unlikely(__pyx_t_4 < 0)) __PYX_ERR(3, 160, __pyx_L1_error)
14228   if (likely(__pyx_t_4)) {
14229 
14230     /* "View.MemoryView":161
14231  *             self.mode = u'fortran'
14232  *         elif mode == 'c':
14233  *             order = b'C'             # <<<<<<<<<<<<<<
14234  *             self.mode = u'c'
14235  *         else:
14236  */
14237     __pyx_v_order = 'C';
14238 
14239     /* "View.MemoryView":162
14240  *         elif mode == 'c':
14241  *             order = b'C'
14242  *             self.mode = u'c'             # <<<<<<<<<<<<<<
14243  *         else:
14244  *             raise ValueError("Invalid mode, expected 'c' or 'fortran', got %s" % mode)
14245  */
14246     __Pyx_INCREF(__pyx_n_u_c);
14247     __Pyx_GIVEREF(__pyx_n_u_c);
14248     __Pyx_GOTREF(__pyx_v_self->mode);
14249     __Pyx_DECREF(__pyx_v_self->mode);
14250     __pyx_v_self->mode = __pyx_n_u_c;
14251 
14252     /* "View.MemoryView":160
14253  *             order = b'F'
14254  *             self.mode = u'fortran'
14255  *         elif mode == 'c':             # <<<<<<<<<<<<<<
14256  *             order = b'C'
14257  *             self.mode = u'c'
14258  */
14259     goto __pyx_L10;
14260   }
14261 
14262   /* "View.MemoryView":164
14263  *             self.mode = u'c'
14264  *         else:
14265  *             raise ValueError("Invalid mode, expected 'c' or 'fortran', got %s" % mode)             # <<<<<<<<<<<<<<
14266  *
14267  *         self.len = fill_contig_strides_array(self._shape, self._strides,
14268  */
14269   /*else*/ {
14270     __pyx_t_3 = __Pyx_PyString_FormatSafe(__pyx_kp_s_Invalid_mode_expected_c_or_fortr, __pyx_v_mode); if (unlikely(!__pyx_t_3)) __PYX_ERR(3, 164, __pyx_L1_error)
14271     __Pyx_GOTREF(__pyx_t_3);
14272     __pyx_t_10 = __Pyx_PyObject_CallOneArg(__pyx_builtin_ValueError, __pyx_t_3); if (unlikely(!__pyx_t_10)) __PYX_ERR(3, 164, __pyx_L1_error)
14273     __Pyx_GOTREF(__pyx_t_10);
14274     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
14275     __Pyx_Raise(__pyx_t_10, 0, 0, 0);
14276     __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
14277     __PYX_ERR(3, 164, __pyx_L1_error)
14278   }
14279   __pyx_L10:;
14280 
14281   /* "View.MemoryView":166
14282  *             raise ValueError("Invalid mode, expected 'c' or 'fortran', got %s" % mode)
14283  *
14284  *         self.len = fill_contig_strides_array(self._shape, self._strides,             # <<<<<<<<<<<<<<
14285  *                                              itemsize, self.ndim, order)
14286  *
14287  */
14288   __pyx_v_self->len = __pyx_fill_contig_strides_array(__pyx_v_self->_shape, __pyx_v_self->_strides, __pyx_v_itemsize, __pyx_v_self->ndim, __pyx_v_order);
14289 
14290   /* "View.MemoryView":169
14291  *                                              itemsize, self.ndim, order)
14292  *
14293  *         self.free_data = allocate_buffer             # <<<<<<<<<<<<<<
14294  *         self.dtype_is_object = format == b'O'
14295  *         if allocate_buffer:
14296  */
14297   __pyx_v_self->free_data = __pyx_v_allocate_buffer;
14298 
14299   /* "View.MemoryView":170
14300  *
14301  *         self.free_data = allocate_buffer
14302  *         self.dtype_is_object = format == b'O'             # <<<<<<<<<<<<<<
14303  *         if allocate_buffer:
14304  *
14305  */
14306   __pyx_t_10 = PyObject_RichCompare(__pyx_v_format, __pyx_n_b_O, Py_EQ); __Pyx_XGOTREF(__pyx_t_10); if (unlikely(!__pyx_t_10)) __PYX_ERR(3, 170, __pyx_L1_error)
14307   __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_10); if (unlikely((__pyx_t_4 == (int)-1) && PyErr_Occurred())) __PYX_ERR(3, 170, __pyx_L1_error)
14308   __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
14309   __pyx_v_self->dtype_is_object = __pyx_t_4;
14310 
14311   /* "View.MemoryView":171
14312  *         self.free_data = allocate_buffer
14313  *         self.dtype_is_object = format == b'O'
14314  *         if allocate_buffer:             # <<<<<<<<<<<<<<
14315  *
14316  *
14317  */
14318   __pyx_t_4 = (__pyx_v_allocate_buffer != 0);
14319   if (__pyx_t_4) {
14320 
14321     /* "View.MemoryView":174
14322  *
14323  *
14324  *             self.data = <char *>malloc(self.len)             # <<<<<<<<<<<<<<
14325  *             if not self.data:
14326  *                 raise MemoryError("unable to allocate array data.")
14327  */
14328     __pyx_v_self->data = ((char *)malloc(__pyx_v_self->len));
14329 
14330     /* "View.MemoryView":175
14331  *
14332  *             self.data = <char *>malloc(self.len)
14333  *             if not self.data:             # <<<<<<<<<<<<<<
14334  *                 raise MemoryError("unable to allocate array data.")
14335  *
14336  */
14337     __pyx_t_4 = ((!(__pyx_v_self->data != 0)) != 0);
14338     if (unlikely(__pyx_t_4)) {
14339 
14340       /* "View.MemoryView":176
14341  *             self.data = <char *>malloc(self.len)
14342  *             if not self.data:
14343  *                 raise MemoryError("unable to allocate array data.")             # <<<<<<<<<<<<<<
14344  *
14345  *             if self.dtype_is_object:
14346  */
14347       __pyx_t_10 = __Pyx_PyObject_Call(__pyx_builtin_MemoryError, __pyx_tuple__24, NULL); if (unlikely(!__pyx_t_10)) __PYX_ERR(3, 176, __pyx_L1_error)
14348       __Pyx_GOTREF(__pyx_t_10);
14349       __Pyx_Raise(__pyx_t_10, 0, 0, 0);
14350       __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
14351       __PYX_ERR(3, 176, __pyx_L1_error)
14352 
14353       /* "View.MemoryView":175
14354  *
14355  *             self.data = <char *>malloc(self.len)
14356  *             if not self.data:             # <<<<<<<<<<<<<<
14357  *                 raise MemoryError("unable to allocate array data.")
14358  *
14359  */
14360     }
14361 
14362     /* "View.MemoryView":178
14363  *                 raise MemoryError("unable to allocate array data.")
14364  *
14365  *             if self.dtype_is_object:             # <<<<<<<<<<<<<<
14366  *                 p = <PyObject **> self.data
14367  *                 for i in range(self.len / itemsize):
14368  */
14369     __pyx_t_4 = (__pyx_v_self->dtype_is_object != 0);
14370     if (__pyx_t_4) {
14371 
14372       /* "View.MemoryView":179
14373  *
14374  *             if self.dtype_is_object:
14375  *                 p = <PyObject **> self.data             # <<<<<<<<<<<<<<
14376  *                 for i in range(self.len / itemsize):
14377  *                     p[i] = Py_None
14378  */
14379       __pyx_v_p = ((PyObject **)__pyx_v_self->data);
14380 
14381       /* "View.MemoryView":180
14382  *             if self.dtype_is_object:
14383  *                 p = <PyObject **> self.data
14384  *                 for i in range(self.len / itemsize):             # <<<<<<<<<<<<<<
14385  *                     p[i] = Py_None
14386  *                     Py_INCREF(Py_None)
14387  */
14388       if (unlikely(__pyx_v_itemsize == 0)) {
14389         PyErr_SetString(PyExc_ZeroDivisionError, "integer division or modulo by zero");
14390         __PYX_ERR(3, 180, __pyx_L1_error)
14391       }
14392       else if (sizeof(Py_ssize_t) == sizeof(long) && (!(((Py_ssize_t)-1) > 0)) && unlikely(__pyx_v_itemsize == (Py_ssize_t)-1)  && unlikely(UNARY_NEG_WOULD_OVERFLOW(__pyx_v_self->len))) {
14393         PyErr_SetString(PyExc_OverflowError, "value too large to perform division");
14394         __PYX_ERR(3, 180, __pyx_L1_error)
14395       }
14396       __pyx_t_1 = __Pyx_div_Py_ssize_t(__pyx_v_self->len, __pyx_v_itemsize);
14397       __pyx_t_9 = __pyx_t_1;
14398       for (__pyx_t_11 = 0; __pyx_t_11 < __pyx_t_9; __pyx_t_11+=1) {
14399         __pyx_v_i = __pyx_t_11;
14400 
14401         /* "View.MemoryView":181
14402  *                 p = <PyObject **> self.data
14403  *                 for i in range(self.len / itemsize):
14404  *                     p[i] = Py_None             # <<<<<<<<<<<<<<
14405  *                     Py_INCREF(Py_None)
14406  *
14407  */
14408         (__pyx_v_p[__pyx_v_i]) = Py_None;
14409 
14410         /* "View.MemoryView":182
14411  *                 for i in range(self.len / itemsize):
14412  *                     p[i] = Py_None
14413  *                     Py_INCREF(Py_None)             # <<<<<<<<<<<<<<
14414  *
14415  *     @cname('getbuffer')
14416  */
14417         Py_INCREF(Py_None);
14418       }
14419 
14420       /* "View.MemoryView":178
14421  *                 raise MemoryError("unable to allocate array data.")
14422  *
14423  *             if self.dtype_is_object:             # <<<<<<<<<<<<<<
14424  *                 p = <PyObject **> self.data
14425  *                 for i in range(self.len / itemsize):
14426  */
14427     }
14428 
14429     /* "View.MemoryView":171
14430  *         self.free_data = allocate_buffer
14431  *         self.dtype_is_object = format == b'O'
14432  *         if allocate_buffer:             # <<<<<<<<<<<<<<
14433  *
14434  *
14435  */
14436   }
14437 
14438   /* "View.MemoryView":122
14439  *         cdef bint dtype_is_object
14440  *
14441  *     def __cinit__(array self, tuple shape, Py_ssize_t itemsize, format not None,             # <<<<<<<<<<<<<<
14442  *                   mode="c", bint allocate_buffer=True):
14443  *
14444  */
14445 
14446   /* function exit code */
14447   __pyx_r = 0;
14448   goto __pyx_L0;
14449   __pyx_L1_error:;
14450   __Pyx_XDECREF(__pyx_t_3);
14451   __Pyx_XDECREF(__pyx_t_5);
14452   __Pyx_XDECREF(__pyx_t_6);
14453   __Pyx_XDECREF(__pyx_t_10);
14454   __Pyx_AddTraceback("View.MemoryView.array.__cinit__", __pyx_clineno, __pyx_lineno, __pyx_filename);
14455   __pyx_r = -1;
14456   __pyx_L0:;
14457   __Pyx_XDECREF(__pyx_v_format);
14458   __Pyx_RefNannyFinishContext();
14459   return __pyx_r;
14460 }
14461 
14462 /* "View.MemoryView":185
14463  *
14464  *     @cname('getbuffer')
14465  *     def __getbuffer__(self, Py_buffer *info, int flags):             # <<<<<<<<<<<<<<
14466  *         cdef int bufmode = -1
14467  *         if self.mode == u"c":
14468  */
14469 
14470 /* Python wrapper */
14471 static CYTHON_UNUSED int __pyx_array_getbuffer(PyObject *__pyx_v_self, Py_buffer *__pyx_v_info, int __pyx_v_flags); /*proto*/
__pyx_array_getbuffer(PyObject * __pyx_v_self,Py_buffer * __pyx_v_info,int __pyx_v_flags)14472 static CYTHON_UNUSED int __pyx_array_getbuffer(PyObject *__pyx_v_self, Py_buffer *__pyx_v_info, int __pyx_v_flags) {
14473   int __pyx_r;
14474   __Pyx_RefNannyDeclarations
14475   __Pyx_RefNannySetupContext("__getbuffer__ (wrapper)", 0);
14476   __pyx_r = __pyx_array___pyx_pf_15View_dot_MemoryView_5array_2__getbuffer__(((struct __pyx_array_obj *)__pyx_v_self), ((Py_buffer *)__pyx_v_info), ((int)__pyx_v_flags));
14477 
14478   /* function exit code */
14479   __Pyx_RefNannyFinishContext();
14480   return __pyx_r;
14481 }
14482 
__pyx_array___pyx_pf_15View_dot_MemoryView_5array_2__getbuffer__(struct __pyx_array_obj * __pyx_v_self,Py_buffer * __pyx_v_info,int __pyx_v_flags)14483 static int __pyx_array___pyx_pf_15View_dot_MemoryView_5array_2__getbuffer__(struct __pyx_array_obj *__pyx_v_self, Py_buffer *__pyx_v_info, int __pyx_v_flags) {
14484   int __pyx_v_bufmode;
14485   int __pyx_r;
14486   __Pyx_RefNannyDeclarations
14487   int __pyx_t_1;
14488   int __pyx_t_2;
14489   PyObject *__pyx_t_3 = NULL;
14490   char *__pyx_t_4;
14491   Py_ssize_t __pyx_t_5;
14492   int __pyx_t_6;
14493   Py_ssize_t *__pyx_t_7;
14494   int __pyx_lineno = 0;
14495   const char *__pyx_filename = NULL;
14496   int __pyx_clineno = 0;
14497   if (__pyx_v_info == NULL) {
14498     PyErr_SetString(PyExc_BufferError, "PyObject_GetBuffer: view==NULL argument is obsolete");
14499     return -1;
14500   }
14501   __Pyx_RefNannySetupContext("__getbuffer__", 0);
14502   __pyx_v_info->obj = Py_None; __Pyx_INCREF(Py_None);
14503   __Pyx_GIVEREF(__pyx_v_info->obj);
14504 
14505   /* "View.MemoryView":186
14506  *     @cname('getbuffer')
14507  *     def __getbuffer__(self, Py_buffer *info, int flags):
14508  *         cdef int bufmode = -1             # <<<<<<<<<<<<<<
14509  *         if self.mode == u"c":
14510  *             bufmode = PyBUF_C_CONTIGUOUS | PyBUF_ANY_CONTIGUOUS
14511  */
14512   __pyx_v_bufmode = -1;
14513 
14514   /* "View.MemoryView":187
14515  *     def __getbuffer__(self, Py_buffer *info, int flags):
14516  *         cdef int bufmode = -1
14517  *         if self.mode == u"c":             # <<<<<<<<<<<<<<
14518  *             bufmode = PyBUF_C_CONTIGUOUS | PyBUF_ANY_CONTIGUOUS
14519  *         elif self.mode == u"fortran":
14520  */
14521   __pyx_t_1 = (__Pyx_PyUnicode_Equals(__pyx_v_self->mode, __pyx_n_u_c, Py_EQ)); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(3, 187, __pyx_L1_error)
14522   __pyx_t_2 = (__pyx_t_1 != 0);
14523   if (__pyx_t_2) {
14524 
14525     /* "View.MemoryView":188
14526  *         cdef int bufmode = -1
14527  *         if self.mode == u"c":
14528  *             bufmode = PyBUF_C_CONTIGUOUS | PyBUF_ANY_CONTIGUOUS             # <<<<<<<<<<<<<<
14529  *         elif self.mode == u"fortran":
14530  *             bufmode = PyBUF_F_CONTIGUOUS | PyBUF_ANY_CONTIGUOUS
14531  */
14532     __pyx_v_bufmode = (PyBUF_C_CONTIGUOUS | PyBUF_ANY_CONTIGUOUS);
14533 
14534     /* "View.MemoryView":187
14535  *     def __getbuffer__(self, Py_buffer *info, int flags):
14536  *         cdef int bufmode = -1
14537  *         if self.mode == u"c":             # <<<<<<<<<<<<<<
14538  *             bufmode = PyBUF_C_CONTIGUOUS | PyBUF_ANY_CONTIGUOUS
14539  *         elif self.mode == u"fortran":
14540  */
14541     goto __pyx_L3;
14542   }
14543 
14544   /* "View.MemoryView":189
14545  *         if self.mode == u"c":
14546  *             bufmode = PyBUF_C_CONTIGUOUS | PyBUF_ANY_CONTIGUOUS
14547  *         elif self.mode == u"fortran":             # <<<<<<<<<<<<<<
14548  *             bufmode = PyBUF_F_CONTIGUOUS | PyBUF_ANY_CONTIGUOUS
14549  *         if not (flags & bufmode):
14550  */
14551   __pyx_t_2 = (__Pyx_PyUnicode_Equals(__pyx_v_self->mode, __pyx_n_u_fortran, Py_EQ)); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(3, 189, __pyx_L1_error)
14552   __pyx_t_1 = (__pyx_t_2 != 0);
14553   if (__pyx_t_1) {
14554 
14555     /* "View.MemoryView":190
14556  *             bufmode = PyBUF_C_CONTIGUOUS | PyBUF_ANY_CONTIGUOUS
14557  *         elif self.mode == u"fortran":
14558  *             bufmode = PyBUF_F_CONTIGUOUS | PyBUF_ANY_CONTIGUOUS             # <<<<<<<<<<<<<<
14559  *         if not (flags & bufmode):
14560  *             raise ValueError("Can only create a buffer that is contiguous in memory.")
14561  */
14562     __pyx_v_bufmode = (PyBUF_F_CONTIGUOUS | PyBUF_ANY_CONTIGUOUS);
14563 
14564     /* "View.MemoryView":189
14565  *         if self.mode == u"c":
14566  *             bufmode = PyBUF_C_CONTIGUOUS | PyBUF_ANY_CONTIGUOUS
14567  *         elif self.mode == u"fortran":             # <<<<<<<<<<<<<<
14568  *             bufmode = PyBUF_F_CONTIGUOUS | PyBUF_ANY_CONTIGUOUS
14569  *         if not (flags & bufmode):
14570  */
14571   }
14572   __pyx_L3:;
14573 
14574   /* "View.MemoryView":191
14575  *         elif self.mode == u"fortran":
14576  *             bufmode = PyBUF_F_CONTIGUOUS | PyBUF_ANY_CONTIGUOUS
14577  *         if not (flags & bufmode):             # <<<<<<<<<<<<<<
14578  *             raise ValueError("Can only create a buffer that is contiguous in memory.")
14579  *         info.buf = self.data
14580  */
14581   __pyx_t_1 = ((!((__pyx_v_flags & __pyx_v_bufmode) != 0)) != 0);
14582   if (unlikely(__pyx_t_1)) {
14583 
14584     /* "View.MemoryView":192
14585  *             bufmode = PyBUF_F_CONTIGUOUS | PyBUF_ANY_CONTIGUOUS
14586  *         if not (flags & bufmode):
14587  *             raise ValueError("Can only create a buffer that is contiguous in memory.")             # <<<<<<<<<<<<<<
14588  *         info.buf = self.data
14589  *         info.len = self.len
14590  */
14591     __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__25, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(3, 192, __pyx_L1_error)
14592     __Pyx_GOTREF(__pyx_t_3);
14593     __Pyx_Raise(__pyx_t_3, 0, 0, 0);
14594     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
14595     __PYX_ERR(3, 192, __pyx_L1_error)
14596 
14597     /* "View.MemoryView":191
14598  *         elif self.mode == u"fortran":
14599  *             bufmode = PyBUF_F_CONTIGUOUS | PyBUF_ANY_CONTIGUOUS
14600  *         if not (flags & bufmode):             # <<<<<<<<<<<<<<
14601  *             raise ValueError("Can only create a buffer that is contiguous in memory.")
14602  *         info.buf = self.data
14603  */
14604   }
14605 
14606   /* "View.MemoryView":193
14607  *         if not (flags & bufmode):
14608  *             raise ValueError("Can only create a buffer that is contiguous in memory.")
14609  *         info.buf = self.data             # <<<<<<<<<<<<<<
14610  *         info.len = self.len
14611  *         info.ndim = self.ndim
14612  */
14613   __pyx_t_4 = __pyx_v_self->data;
14614   __pyx_v_info->buf = __pyx_t_4;
14615 
14616   /* "View.MemoryView":194
14617  *             raise ValueError("Can only create a buffer that is contiguous in memory.")
14618  *         info.buf = self.data
14619  *         info.len = self.len             # <<<<<<<<<<<<<<
14620  *         info.ndim = self.ndim
14621  *         info.shape = self._shape
14622  */
14623   __pyx_t_5 = __pyx_v_self->len;
14624   __pyx_v_info->len = __pyx_t_5;
14625 
14626   /* "View.MemoryView":195
14627  *         info.buf = self.data
14628  *         info.len = self.len
14629  *         info.ndim = self.ndim             # <<<<<<<<<<<<<<
14630  *         info.shape = self._shape
14631  *         info.strides = self._strides
14632  */
14633   __pyx_t_6 = __pyx_v_self->ndim;
14634   __pyx_v_info->ndim = __pyx_t_6;
14635 
14636   /* "View.MemoryView":196
14637  *         info.len = self.len
14638  *         info.ndim = self.ndim
14639  *         info.shape = self._shape             # <<<<<<<<<<<<<<
14640  *         info.strides = self._strides
14641  *         info.suboffsets = NULL
14642  */
14643   __pyx_t_7 = __pyx_v_self->_shape;
14644   __pyx_v_info->shape = __pyx_t_7;
14645 
14646   /* "View.MemoryView":197
14647  *         info.ndim = self.ndim
14648  *         info.shape = self._shape
14649  *         info.strides = self._strides             # <<<<<<<<<<<<<<
14650  *         info.suboffsets = NULL
14651  *         info.itemsize = self.itemsize
14652  */
14653   __pyx_t_7 = __pyx_v_self->_strides;
14654   __pyx_v_info->strides = __pyx_t_7;
14655 
14656   /* "View.MemoryView":198
14657  *         info.shape = self._shape
14658  *         info.strides = self._strides
14659  *         info.suboffsets = NULL             # <<<<<<<<<<<<<<
14660  *         info.itemsize = self.itemsize
14661  *         info.readonly = 0
14662  */
14663   __pyx_v_info->suboffsets = NULL;
14664 
14665   /* "View.MemoryView":199
14666  *         info.strides = self._strides
14667  *         info.suboffsets = NULL
14668  *         info.itemsize = self.itemsize             # <<<<<<<<<<<<<<
14669  *         info.readonly = 0
14670  *
14671  */
14672   __pyx_t_5 = __pyx_v_self->itemsize;
14673   __pyx_v_info->itemsize = __pyx_t_5;
14674 
14675   /* "View.MemoryView":200
14676  *         info.suboffsets = NULL
14677  *         info.itemsize = self.itemsize
14678  *         info.readonly = 0             # <<<<<<<<<<<<<<
14679  *
14680  *         if flags & PyBUF_FORMAT:
14681  */
14682   __pyx_v_info->readonly = 0;
14683 
14684   /* "View.MemoryView":202
14685  *         info.readonly = 0
14686  *
14687  *         if flags & PyBUF_FORMAT:             # <<<<<<<<<<<<<<
14688  *             info.format = self.format
14689  *         else:
14690  */
14691   __pyx_t_1 = ((__pyx_v_flags & PyBUF_FORMAT) != 0);
14692   if (__pyx_t_1) {
14693 
14694     /* "View.MemoryView":203
14695  *
14696  *         if flags & PyBUF_FORMAT:
14697  *             info.format = self.format             # <<<<<<<<<<<<<<
14698  *         else:
14699  *             info.format = NULL
14700  */
14701     __pyx_t_4 = __pyx_v_self->format;
14702     __pyx_v_info->format = __pyx_t_4;
14703 
14704     /* "View.MemoryView":202
14705  *         info.readonly = 0
14706  *
14707  *         if flags & PyBUF_FORMAT:             # <<<<<<<<<<<<<<
14708  *             info.format = self.format
14709  *         else:
14710  */
14711     goto __pyx_L5;
14712   }
14713 
14714   /* "View.MemoryView":205
14715  *             info.format = self.format
14716  *         else:
14717  *             info.format = NULL             # <<<<<<<<<<<<<<
14718  *
14719  *         info.obj = self
14720  */
14721   /*else*/ {
14722     __pyx_v_info->format = NULL;
14723   }
14724   __pyx_L5:;
14725 
14726   /* "View.MemoryView":207
14727  *             info.format = NULL
14728  *
14729  *         info.obj = self             # <<<<<<<<<<<<<<
14730  *
14731  *     __pyx_getbuffer = capsule(<void *> &__pyx_array_getbuffer, "getbuffer(obj, view, flags)")
14732  */
14733   __Pyx_INCREF(((PyObject *)__pyx_v_self));
14734   __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
14735   __Pyx_GOTREF(__pyx_v_info->obj);
14736   __Pyx_DECREF(__pyx_v_info->obj);
14737   __pyx_v_info->obj = ((PyObject *)__pyx_v_self);
14738 
14739   /* "View.MemoryView":185
14740  *
14741  *     @cname('getbuffer')
14742  *     def __getbuffer__(self, Py_buffer *info, int flags):             # <<<<<<<<<<<<<<
14743  *         cdef int bufmode = -1
14744  *         if self.mode == u"c":
14745  */
14746 
14747   /* function exit code */
14748   __pyx_r = 0;
14749   goto __pyx_L0;
14750   __pyx_L1_error:;
14751   __Pyx_XDECREF(__pyx_t_3);
14752   __Pyx_AddTraceback("View.MemoryView.array.__getbuffer__", __pyx_clineno, __pyx_lineno, __pyx_filename);
14753   __pyx_r = -1;
14754   if (__pyx_v_info->obj != NULL) {
14755     __Pyx_GOTREF(__pyx_v_info->obj);
14756     __Pyx_DECREF(__pyx_v_info->obj); __pyx_v_info->obj = 0;
14757   }
14758   goto __pyx_L2;
14759   __pyx_L0:;
14760   if (__pyx_v_info->obj == Py_None) {
14761     __Pyx_GOTREF(__pyx_v_info->obj);
14762     __Pyx_DECREF(__pyx_v_info->obj); __pyx_v_info->obj = 0;
14763   }
14764   __pyx_L2:;
14765   __Pyx_RefNannyFinishContext();
14766   return __pyx_r;
14767 }
14768 
14769 /* "View.MemoryView":211
14770  *     __pyx_getbuffer = capsule(<void *> &__pyx_array_getbuffer, "getbuffer(obj, view, flags)")
14771  *
14772  *     def __dealloc__(array self):             # <<<<<<<<<<<<<<
14773  *         if self.callback_free_data != NULL:
14774  *             self.callback_free_data(self.data)
14775  */
14776 
14777 /* Python wrapper */
14778 static void __pyx_array___dealloc__(PyObject *__pyx_v_self); /*proto*/
__pyx_array___dealloc__(PyObject * __pyx_v_self)14779 static void __pyx_array___dealloc__(PyObject *__pyx_v_self) {
14780   __Pyx_RefNannyDeclarations
14781   __Pyx_RefNannySetupContext("__dealloc__ (wrapper)", 0);
14782   __pyx_array___pyx_pf_15View_dot_MemoryView_5array_4__dealloc__(((struct __pyx_array_obj *)__pyx_v_self));
14783 
14784   /* function exit code */
14785   __Pyx_RefNannyFinishContext();
14786 }
14787 
__pyx_array___pyx_pf_15View_dot_MemoryView_5array_4__dealloc__(struct __pyx_array_obj * __pyx_v_self)14788 static void __pyx_array___pyx_pf_15View_dot_MemoryView_5array_4__dealloc__(struct __pyx_array_obj *__pyx_v_self) {
14789   __Pyx_RefNannyDeclarations
14790   int __pyx_t_1;
14791   __Pyx_RefNannySetupContext("__dealloc__", 0);
14792 
14793   /* "View.MemoryView":212
14794  *
14795  *     def __dealloc__(array self):
14796  *         if self.callback_free_data != NULL:             # <<<<<<<<<<<<<<
14797  *             self.callback_free_data(self.data)
14798  *         elif self.free_data:
14799  */
14800   __pyx_t_1 = ((__pyx_v_self->callback_free_data != NULL) != 0);
14801   if (__pyx_t_1) {
14802 
14803     /* "View.MemoryView":213
14804  *     def __dealloc__(array self):
14805  *         if self.callback_free_data != NULL:
14806  *             self.callback_free_data(self.data)             # <<<<<<<<<<<<<<
14807  *         elif self.free_data:
14808  *             if self.dtype_is_object:
14809  */
14810     __pyx_v_self->callback_free_data(__pyx_v_self->data);
14811 
14812     /* "View.MemoryView":212
14813  *
14814  *     def __dealloc__(array self):
14815  *         if self.callback_free_data != NULL:             # <<<<<<<<<<<<<<
14816  *             self.callback_free_data(self.data)
14817  *         elif self.free_data:
14818  */
14819     goto __pyx_L3;
14820   }
14821 
14822   /* "View.MemoryView":214
14823  *         if self.callback_free_data != NULL:
14824  *             self.callback_free_data(self.data)
14825  *         elif self.free_data:             # <<<<<<<<<<<<<<
14826  *             if self.dtype_is_object:
14827  *                 refcount_objects_in_slice(self.data, self._shape,
14828  */
14829   __pyx_t_1 = (__pyx_v_self->free_data != 0);
14830   if (__pyx_t_1) {
14831 
14832     /* "View.MemoryView":215
14833  *             self.callback_free_data(self.data)
14834  *         elif self.free_data:
14835  *             if self.dtype_is_object:             # <<<<<<<<<<<<<<
14836  *                 refcount_objects_in_slice(self.data, self._shape,
14837  *                                           self._strides, self.ndim, False)
14838  */
14839     __pyx_t_1 = (__pyx_v_self->dtype_is_object != 0);
14840     if (__pyx_t_1) {
14841 
14842       /* "View.MemoryView":216
14843  *         elif self.free_data:
14844  *             if self.dtype_is_object:
14845  *                 refcount_objects_in_slice(self.data, self._shape,             # <<<<<<<<<<<<<<
14846  *                                           self._strides, self.ndim, False)
14847  *             free(self.data)
14848  */
14849       __pyx_memoryview_refcount_objects_in_slice(__pyx_v_self->data, __pyx_v_self->_shape, __pyx_v_self->_strides, __pyx_v_self->ndim, 0);
14850 
14851       /* "View.MemoryView":215
14852  *             self.callback_free_data(self.data)
14853  *         elif self.free_data:
14854  *             if self.dtype_is_object:             # <<<<<<<<<<<<<<
14855  *                 refcount_objects_in_slice(self.data, self._shape,
14856  *                                           self._strides, self.ndim, False)
14857  */
14858     }
14859 
14860     /* "View.MemoryView":218
14861  *                 refcount_objects_in_slice(self.data, self._shape,
14862  *                                           self._strides, self.ndim, False)
14863  *             free(self.data)             # <<<<<<<<<<<<<<
14864  *         PyObject_Free(self._shape)
14865  *
14866  */
14867     free(__pyx_v_self->data);
14868 
14869     /* "View.MemoryView":214
14870  *         if self.callback_free_data != NULL:
14871  *             self.callback_free_data(self.data)
14872  *         elif self.free_data:             # <<<<<<<<<<<<<<
14873  *             if self.dtype_is_object:
14874  *                 refcount_objects_in_slice(self.data, self._shape,
14875  */
14876   }
14877   __pyx_L3:;
14878 
14879   /* "View.MemoryView":219
14880  *                                           self._strides, self.ndim, False)
14881  *             free(self.data)
14882  *         PyObject_Free(self._shape)             # <<<<<<<<<<<<<<
14883  *
14884  *     @property
14885  */
14886   PyObject_Free(__pyx_v_self->_shape);
14887 
14888   /* "View.MemoryView":211
14889  *     __pyx_getbuffer = capsule(<void *> &__pyx_array_getbuffer, "getbuffer(obj, view, flags)")
14890  *
14891  *     def __dealloc__(array self):             # <<<<<<<<<<<<<<
14892  *         if self.callback_free_data != NULL:
14893  *             self.callback_free_data(self.data)
14894  */
14895 
14896   /* function exit code */
14897   __Pyx_RefNannyFinishContext();
14898 }
14899 
14900 /* "View.MemoryView":222
14901  *
14902  *     @property
14903  *     def memview(self):             # <<<<<<<<<<<<<<
14904  *         return self.get_memview()
14905  *
14906  */
14907 
14908 /* Python wrapper */
14909 static PyObject *__pyx_pw_15View_dot_MemoryView_5array_7memview_1__get__(PyObject *__pyx_v_self); /*proto*/
__pyx_pw_15View_dot_MemoryView_5array_7memview_1__get__(PyObject * __pyx_v_self)14910 static PyObject *__pyx_pw_15View_dot_MemoryView_5array_7memview_1__get__(PyObject *__pyx_v_self) {
14911   PyObject *__pyx_r = 0;
14912   __Pyx_RefNannyDeclarations
14913   __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
14914   __pyx_r = __pyx_pf_15View_dot_MemoryView_5array_7memview___get__(((struct __pyx_array_obj *)__pyx_v_self));
14915 
14916   /* function exit code */
14917   __Pyx_RefNannyFinishContext();
14918   return __pyx_r;
14919 }
14920 
__pyx_pf_15View_dot_MemoryView_5array_7memview___get__(struct __pyx_array_obj * __pyx_v_self)14921 static PyObject *__pyx_pf_15View_dot_MemoryView_5array_7memview___get__(struct __pyx_array_obj *__pyx_v_self) {
14922   PyObject *__pyx_r = NULL;
14923   __Pyx_RefNannyDeclarations
14924   PyObject *__pyx_t_1 = NULL;
14925   int __pyx_lineno = 0;
14926   const char *__pyx_filename = NULL;
14927   int __pyx_clineno = 0;
14928   __Pyx_RefNannySetupContext("__get__", 0);
14929 
14930   /* "View.MemoryView":223
14931  *     @property
14932  *     def memview(self):
14933  *         return self.get_memview()             # <<<<<<<<<<<<<<
14934  *
14935  *     @cname('get_memview')
14936  */
14937   __Pyx_XDECREF(__pyx_r);
14938   __pyx_t_1 = ((struct __pyx_vtabstruct_array *)__pyx_v_self->__pyx_vtab)->get_memview(__pyx_v_self); if (unlikely(!__pyx_t_1)) __PYX_ERR(3, 223, __pyx_L1_error)
14939   __Pyx_GOTREF(__pyx_t_1);
14940   __pyx_r = __pyx_t_1;
14941   __pyx_t_1 = 0;
14942   goto __pyx_L0;
14943 
14944   /* "View.MemoryView":222
14945  *
14946  *     @property
14947  *     def memview(self):             # <<<<<<<<<<<<<<
14948  *         return self.get_memview()
14949  *
14950  */
14951 
14952   /* function exit code */
14953   __pyx_L1_error:;
14954   __Pyx_XDECREF(__pyx_t_1);
14955   __Pyx_AddTraceback("View.MemoryView.array.memview.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
14956   __pyx_r = NULL;
14957   __pyx_L0:;
14958   __Pyx_XGIVEREF(__pyx_r);
14959   __Pyx_RefNannyFinishContext();
14960   return __pyx_r;
14961 }
14962 
14963 /* "View.MemoryView":226
14964  *
14965  *     @cname('get_memview')
14966  *     cdef get_memview(self):             # <<<<<<<<<<<<<<
14967  *         flags =  PyBUF_ANY_CONTIGUOUS|PyBUF_FORMAT|PyBUF_WRITABLE
14968  *         return  memoryview(self, flags, self.dtype_is_object)
14969  */
14970 
__pyx_array_get_memview(struct __pyx_array_obj * __pyx_v_self)14971 static PyObject *__pyx_array_get_memview(struct __pyx_array_obj *__pyx_v_self) {
14972   int __pyx_v_flags;
14973   PyObject *__pyx_r = NULL;
14974   __Pyx_RefNannyDeclarations
14975   PyObject *__pyx_t_1 = NULL;
14976   PyObject *__pyx_t_2 = NULL;
14977   PyObject *__pyx_t_3 = NULL;
14978   int __pyx_lineno = 0;
14979   const char *__pyx_filename = NULL;
14980   int __pyx_clineno = 0;
14981   __Pyx_RefNannySetupContext("get_memview", 0);
14982 
14983   /* "View.MemoryView":227
14984  *     @cname('get_memview')
14985  *     cdef get_memview(self):
14986  *         flags =  PyBUF_ANY_CONTIGUOUS|PyBUF_FORMAT|PyBUF_WRITABLE             # <<<<<<<<<<<<<<
14987  *         return  memoryview(self, flags, self.dtype_is_object)
14988  *
14989  */
14990   __pyx_v_flags = ((PyBUF_ANY_CONTIGUOUS | PyBUF_FORMAT) | PyBUF_WRITABLE);
14991 
14992   /* "View.MemoryView":228
14993  *     cdef get_memview(self):
14994  *         flags =  PyBUF_ANY_CONTIGUOUS|PyBUF_FORMAT|PyBUF_WRITABLE
14995  *         return  memoryview(self, flags, self.dtype_is_object)             # <<<<<<<<<<<<<<
14996  *
14997  *     def __len__(self):
14998  */
14999   __Pyx_XDECREF(__pyx_r);
15000   __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_flags); if (unlikely(!__pyx_t_1)) __PYX_ERR(3, 228, __pyx_L1_error)
15001   __Pyx_GOTREF(__pyx_t_1);
15002   __pyx_t_2 = __Pyx_PyBool_FromLong(__pyx_v_self->dtype_is_object); if (unlikely(!__pyx_t_2)) __PYX_ERR(3, 228, __pyx_L1_error)
15003   __Pyx_GOTREF(__pyx_t_2);
15004   __pyx_t_3 = PyTuple_New(3); if (unlikely(!__pyx_t_3)) __PYX_ERR(3, 228, __pyx_L1_error)
15005   __Pyx_GOTREF(__pyx_t_3);
15006   __Pyx_INCREF(((PyObject *)__pyx_v_self));
15007   __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
15008   PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)__pyx_v_self));
15009   __Pyx_GIVEREF(__pyx_t_1);
15010   PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_1);
15011   __Pyx_GIVEREF(__pyx_t_2);
15012   PyTuple_SET_ITEM(__pyx_t_3, 2, __pyx_t_2);
15013   __pyx_t_1 = 0;
15014   __pyx_t_2 = 0;
15015   __pyx_t_2 = __Pyx_PyObject_Call(((PyObject *)__pyx_memoryview_type), __pyx_t_3, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(3, 228, __pyx_L1_error)
15016   __Pyx_GOTREF(__pyx_t_2);
15017   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
15018   __pyx_r = __pyx_t_2;
15019   __pyx_t_2 = 0;
15020   goto __pyx_L0;
15021 
15022   /* "View.MemoryView":226
15023  *
15024  *     @cname('get_memview')
15025  *     cdef get_memview(self):             # <<<<<<<<<<<<<<
15026  *         flags =  PyBUF_ANY_CONTIGUOUS|PyBUF_FORMAT|PyBUF_WRITABLE
15027  *         return  memoryview(self, flags, self.dtype_is_object)
15028  */
15029 
15030   /* function exit code */
15031   __pyx_L1_error:;
15032   __Pyx_XDECREF(__pyx_t_1);
15033   __Pyx_XDECREF(__pyx_t_2);
15034   __Pyx_XDECREF(__pyx_t_3);
15035   __Pyx_AddTraceback("View.MemoryView.array.get_memview", __pyx_clineno, __pyx_lineno, __pyx_filename);
15036   __pyx_r = 0;
15037   __pyx_L0:;
15038   __Pyx_XGIVEREF(__pyx_r);
15039   __Pyx_RefNannyFinishContext();
15040   return __pyx_r;
15041 }
15042 
15043 /* "View.MemoryView":230
15044  *         return  memoryview(self, flags, self.dtype_is_object)
15045  *
15046  *     def __len__(self):             # <<<<<<<<<<<<<<
15047  *         return self._shape[0]
15048  *
15049  */
15050 
15051 /* Python wrapper */
15052 static Py_ssize_t __pyx_array___len__(PyObject *__pyx_v_self); /*proto*/
__pyx_array___len__(PyObject * __pyx_v_self)15053 static Py_ssize_t __pyx_array___len__(PyObject *__pyx_v_self) {
15054   Py_ssize_t __pyx_r;
15055   __Pyx_RefNannyDeclarations
15056   __Pyx_RefNannySetupContext("__len__ (wrapper)", 0);
15057   __pyx_r = __pyx_array___pyx_pf_15View_dot_MemoryView_5array_6__len__(((struct __pyx_array_obj *)__pyx_v_self));
15058 
15059   /* function exit code */
15060   __Pyx_RefNannyFinishContext();
15061   return __pyx_r;
15062 }
15063 
__pyx_array___pyx_pf_15View_dot_MemoryView_5array_6__len__(struct __pyx_array_obj * __pyx_v_self)15064 static Py_ssize_t __pyx_array___pyx_pf_15View_dot_MemoryView_5array_6__len__(struct __pyx_array_obj *__pyx_v_self) {
15065   Py_ssize_t __pyx_r;
15066   __Pyx_RefNannyDeclarations
15067   __Pyx_RefNannySetupContext("__len__", 0);
15068 
15069   /* "View.MemoryView":231
15070  *
15071  *     def __len__(self):
15072  *         return self._shape[0]             # <<<<<<<<<<<<<<
15073  *
15074  *     def __getattr__(self, attr):
15075  */
15076   __pyx_r = (__pyx_v_self->_shape[0]);
15077   goto __pyx_L0;
15078 
15079   /* "View.MemoryView":230
15080  *         return  memoryview(self, flags, self.dtype_is_object)
15081  *
15082  *     def __len__(self):             # <<<<<<<<<<<<<<
15083  *         return self._shape[0]
15084  *
15085  */
15086 
15087   /* function exit code */
15088   __pyx_L0:;
15089   __Pyx_RefNannyFinishContext();
15090   return __pyx_r;
15091 }
15092 
15093 /* "View.MemoryView":233
15094  *         return self._shape[0]
15095  *
15096  *     def __getattr__(self, attr):             # <<<<<<<<<<<<<<
15097  *         return getattr(self.memview, attr)
15098  *
15099  */
15100 
15101 /* Python wrapper */
15102 static PyObject *__pyx_array___getattr__(PyObject *__pyx_v_self, PyObject *__pyx_v_attr); /*proto*/
__pyx_array___getattr__(PyObject * __pyx_v_self,PyObject * __pyx_v_attr)15103 static PyObject *__pyx_array___getattr__(PyObject *__pyx_v_self, PyObject *__pyx_v_attr) {
15104   PyObject *__pyx_r = 0;
15105   __Pyx_RefNannyDeclarations
15106   __Pyx_RefNannySetupContext("__getattr__ (wrapper)", 0);
15107   __pyx_r = __pyx_array___pyx_pf_15View_dot_MemoryView_5array_8__getattr__(((struct __pyx_array_obj *)__pyx_v_self), ((PyObject *)__pyx_v_attr));
15108 
15109   /* function exit code */
15110   __Pyx_RefNannyFinishContext();
15111   return __pyx_r;
15112 }
15113 
__pyx_array___pyx_pf_15View_dot_MemoryView_5array_8__getattr__(struct __pyx_array_obj * __pyx_v_self,PyObject * __pyx_v_attr)15114 static PyObject *__pyx_array___pyx_pf_15View_dot_MemoryView_5array_8__getattr__(struct __pyx_array_obj *__pyx_v_self, PyObject *__pyx_v_attr) {
15115   PyObject *__pyx_r = NULL;
15116   __Pyx_RefNannyDeclarations
15117   PyObject *__pyx_t_1 = NULL;
15118   PyObject *__pyx_t_2 = NULL;
15119   int __pyx_lineno = 0;
15120   const char *__pyx_filename = NULL;
15121   int __pyx_clineno = 0;
15122   __Pyx_RefNannySetupContext("__getattr__", 0);
15123 
15124   /* "View.MemoryView":234
15125  *
15126  *     def __getattr__(self, attr):
15127  *         return getattr(self.memview, attr)             # <<<<<<<<<<<<<<
15128  *
15129  *     def __getitem__(self, item):
15130  */
15131   __Pyx_XDECREF(__pyx_r);
15132   __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_memview); if (unlikely(!__pyx_t_1)) __PYX_ERR(3, 234, __pyx_L1_error)
15133   __Pyx_GOTREF(__pyx_t_1);
15134   __pyx_t_2 = __Pyx_GetAttr(__pyx_t_1, __pyx_v_attr); if (unlikely(!__pyx_t_2)) __PYX_ERR(3, 234, __pyx_L1_error)
15135   __Pyx_GOTREF(__pyx_t_2);
15136   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
15137   __pyx_r = __pyx_t_2;
15138   __pyx_t_2 = 0;
15139   goto __pyx_L0;
15140 
15141   /* "View.MemoryView":233
15142  *         return self._shape[0]
15143  *
15144  *     def __getattr__(self, attr):             # <<<<<<<<<<<<<<
15145  *         return getattr(self.memview, attr)
15146  *
15147  */
15148 
15149   /* function exit code */
15150   __pyx_L1_error:;
15151   __Pyx_XDECREF(__pyx_t_1);
15152   __Pyx_XDECREF(__pyx_t_2);
15153   __Pyx_AddTraceback("View.MemoryView.array.__getattr__", __pyx_clineno, __pyx_lineno, __pyx_filename);
15154   __pyx_r = NULL;
15155   __pyx_L0:;
15156   __Pyx_XGIVEREF(__pyx_r);
15157   __Pyx_RefNannyFinishContext();
15158   return __pyx_r;
15159 }
15160 
15161 /* "View.MemoryView":236
15162  *         return getattr(self.memview, attr)
15163  *
15164  *     def __getitem__(self, item):             # <<<<<<<<<<<<<<
15165  *         return self.memview[item]
15166  *
15167  */
15168 
15169 /* Python wrapper */
15170 static PyObject *__pyx_array___getitem__(PyObject *__pyx_v_self, PyObject *__pyx_v_item); /*proto*/
__pyx_array___getitem__(PyObject * __pyx_v_self,PyObject * __pyx_v_item)15171 static PyObject *__pyx_array___getitem__(PyObject *__pyx_v_self, PyObject *__pyx_v_item) {
15172   PyObject *__pyx_r = 0;
15173   __Pyx_RefNannyDeclarations
15174   __Pyx_RefNannySetupContext("__getitem__ (wrapper)", 0);
15175   __pyx_r = __pyx_array___pyx_pf_15View_dot_MemoryView_5array_10__getitem__(((struct __pyx_array_obj *)__pyx_v_self), ((PyObject *)__pyx_v_item));
15176 
15177   /* function exit code */
15178   __Pyx_RefNannyFinishContext();
15179   return __pyx_r;
15180 }
15181 
__pyx_array___pyx_pf_15View_dot_MemoryView_5array_10__getitem__(struct __pyx_array_obj * __pyx_v_self,PyObject * __pyx_v_item)15182 static PyObject *__pyx_array___pyx_pf_15View_dot_MemoryView_5array_10__getitem__(struct __pyx_array_obj *__pyx_v_self, PyObject *__pyx_v_item) {
15183   PyObject *__pyx_r = NULL;
15184   __Pyx_RefNannyDeclarations
15185   PyObject *__pyx_t_1 = NULL;
15186   PyObject *__pyx_t_2 = NULL;
15187   int __pyx_lineno = 0;
15188   const char *__pyx_filename = NULL;
15189   int __pyx_clineno = 0;
15190   __Pyx_RefNannySetupContext("__getitem__", 0);
15191 
15192   /* "View.MemoryView":237
15193  *
15194  *     def __getitem__(self, item):
15195  *         return self.memview[item]             # <<<<<<<<<<<<<<
15196  *
15197  *     def __setitem__(self, item, value):
15198  */
15199   __Pyx_XDECREF(__pyx_r);
15200   __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_memview); if (unlikely(!__pyx_t_1)) __PYX_ERR(3, 237, __pyx_L1_error)
15201   __Pyx_GOTREF(__pyx_t_1);
15202   __pyx_t_2 = __Pyx_PyObject_GetItem(__pyx_t_1, __pyx_v_item); if (unlikely(!__pyx_t_2)) __PYX_ERR(3, 237, __pyx_L1_error)
15203   __Pyx_GOTREF(__pyx_t_2);
15204   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
15205   __pyx_r = __pyx_t_2;
15206   __pyx_t_2 = 0;
15207   goto __pyx_L0;
15208 
15209   /* "View.MemoryView":236
15210  *         return getattr(self.memview, attr)
15211  *
15212  *     def __getitem__(self, item):             # <<<<<<<<<<<<<<
15213  *         return self.memview[item]
15214  *
15215  */
15216 
15217   /* function exit code */
15218   __pyx_L1_error:;
15219   __Pyx_XDECREF(__pyx_t_1);
15220   __Pyx_XDECREF(__pyx_t_2);
15221   __Pyx_AddTraceback("View.MemoryView.array.__getitem__", __pyx_clineno, __pyx_lineno, __pyx_filename);
15222   __pyx_r = NULL;
15223   __pyx_L0:;
15224   __Pyx_XGIVEREF(__pyx_r);
15225   __Pyx_RefNannyFinishContext();
15226   return __pyx_r;
15227 }
15228 
15229 /* "View.MemoryView":239
15230  *         return self.memview[item]
15231  *
15232  *     def __setitem__(self, item, value):             # <<<<<<<<<<<<<<
15233  *         self.memview[item] = value
15234  *
15235  */
15236 
15237 /* Python wrapper */
15238 static int __pyx_array___setitem__(PyObject *__pyx_v_self, PyObject *__pyx_v_item, PyObject *__pyx_v_value); /*proto*/
__pyx_array___setitem__(PyObject * __pyx_v_self,PyObject * __pyx_v_item,PyObject * __pyx_v_value)15239 static int __pyx_array___setitem__(PyObject *__pyx_v_self, PyObject *__pyx_v_item, PyObject *__pyx_v_value) {
15240   int __pyx_r;
15241   __Pyx_RefNannyDeclarations
15242   __Pyx_RefNannySetupContext("__setitem__ (wrapper)", 0);
15243   __pyx_r = __pyx_array___pyx_pf_15View_dot_MemoryView_5array_12__setitem__(((struct __pyx_array_obj *)__pyx_v_self), ((PyObject *)__pyx_v_item), ((PyObject *)__pyx_v_value));
15244 
15245   /* function exit code */
15246   __Pyx_RefNannyFinishContext();
15247   return __pyx_r;
15248 }
15249 
__pyx_array___pyx_pf_15View_dot_MemoryView_5array_12__setitem__(struct __pyx_array_obj * __pyx_v_self,PyObject * __pyx_v_item,PyObject * __pyx_v_value)15250 static int __pyx_array___pyx_pf_15View_dot_MemoryView_5array_12__setitem__(struct __pyx_array_obj *__pyx_v_self, PyObject *__pyx_v_item, PyObject *__pyx_v_value) {
15251   int __pyx_r;
15252   __Pyx_RefNannyDeclarations
15253   PyObject *__pyx_t_1 = NULL;
15254   int __pyx_lineno = 0;
15255   const char *__pyx_filename = NULL;
15256   int __pyx_clineno = 0;
15257   __Pyx_RefNannySetupContext("__setitem__", 0);
15258 
15259   /* "View.MemoryView":240
15260  *
15261  *     def __setitem__(self, item, value):
15262  *         self.memview[item] = value             # <<<<<<<<<<<<<<
15263  *
15264  *
15265  */
15266   __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_memview); if (unlikely(!__pyx_t_1)) __PYX_ERR(3, 240, __pyx_L1_error)
15267   __Pyx_GOTREF(__pyx_t_1);
15268   if (unlikely(PyObject_SetItem(__pyx_t_1, __pyx_v_item, __pyx_v_value) < 0)) __PYX_ERR(3, 240, __pyx_L1_error)
15269   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
15270 
15271   /* "View.MemoryView":239
15272  *         return self.memview[item]
15273  *
15274  *     def __setitem__(self, item, value):             # <<<<<<<<<<<<<<
15275  *         self.memview[item] = value
15276  *
15277  */
15278 
15279   /* function exit code */
15280   __pyx_r = 0;
15281   goto __pyx_L0;
15282   __pyx_L1_error:;
15283   __Pyx_XDECREF(__pyx_t_1);
15284   __Pyx_AddTraceback("View.MemoryView.array.__setitem__", __pyx_clineno, __pyx_lineno, __pyx_filename);
15285   __pyx_r = -1;
15286   __pyx_L0:;
15287   __Pyx_RefNannyFinishContext();
15288   return __pyx_r;
15289 }
15290 
15291 /* "(tree fragment)":1
15292  * def __reduce_cython__(self):             # <<<<<<<<<<<<<<
15293  *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
15294  * def __setstate_cython__(self, __pyx_state):
15295  */
15296 
15297 /* Python wrapper */
15298 static PyObject *__pyx_pw___pyx_array_1__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
__pyx_pw___pyx_array_1__reduce_cython__(PyObject * __pyx_v_self,CYTHON_UNUSED PyObject * unused)15299 static PyObject *__pyx_pw___pyx_array_1__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
15300   PyObject *__pyx_r = 0;
15301   __Pyx_RefNannyDeclarations
15302   __Pyx_RefNannySetupContext("__reduce_cython__ (wrapper)", 0);
15303   __pyx_r = __pyx_pf___pyx_array___reduce_cython__(((struct __pyx_array_obj *)__pyx_v_self));
15304 
15305   /* function exit code */
15306   __Pyx_RefNannyFinishContext();
15307   return __pyx_r;
15308 }
15309 
__pyx_pf___pyx_array___reduce_cython__(CYTHON_UNUSED struct __pyx_array_obj * __pyx_v_self)15310 static PyObject *__pyx_pf___pyx_array___reduce_cython__(CYTHON_UNUSED struct __pyx_array_obj *__pyx_v_self) {
15311   PyObject *__pyx_r = NULL;
15312   __Pyx_RefNannyDeclarations
15313   PyObject *__pyx_t_1 = NULL;
15314   int __pyx_lineno = 0;
15315   const char *__pyx_filename = NULL;
15316   int __pyx_clineno = 0;
15317   __Pyx_RefNannySetupContext("__reduce_cython__", 0);
15318 
15319   /* "(tree fragment)":2
15320  * def __reduce_cython__(self):
15321  *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")             # <<<<<<<<<<<<<<
15322  * def __setstate_cython__(self, __pyx_state):
15323  *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
15324  */
15325   __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__26, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(3, 2, __pyx_L1_error)
15326   __Pyx_GOTREF(__pyx_t_1);
15327   __Pyx_Raise(__pyx_t_1, 0, 0, 0);
15328   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
15329   __PYX_ERR(3, 2, __pyx_L1_error)
15330 
15331   /* "(tree fragment)":1
15332  * def __reduce_cython__(self):             # <<<<<<<<<<<<<<
15333  *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
15334  * def __setstate_cython__(self, __pyx_state):
15335  */
15336 
15337   /* function exit code */
15338   __pyx_L1_error:;
15339   __Pyx_XDECREF(__pyx_t_1);
15340   __Pyx_AddTraceback("View.MemoryView.array.__reduce_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename);
15341   __pyx_r = NULL;
15342   __Pyx_XGIVEREF(__pyx_r);
15343   __Pyx_RefNannyFinishContext();
15344   return __pyx_r;
15345 }
15346 
15347 /* "(tree fragment)":3
15348  * def __reduce_cython__(self):
15349  *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
15350  * def __setstate_cython__(self, __pyx_state):             # <<<<<<<<<<<<<<
15351  *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
15352  */
15353 
15354 /* Python wrapper */
15355 static PyObject *__pyx_pw___pyx_array_3__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state); /*proto*/
__pyx_pw___pyx_array_3__setstate_cython__(PyObject * __pyx_v_self,PyObject * __pyx_v___pyx_state)15356 static PyObject *__pyx_pw___pyx_array_3__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state) {
15357   PyObject *__pyx_r = 0;
15358   __Pyx_RefNannyDeclarations
15359   __Pyx_RefNannySetupContext("__setstate_cython__ (wrapper)", 0);
15360   __pyx_r = __pyx_pf___pyx_array_2__setstate_cython__(((struct __pyx_array_obj *)__pyx_v_self), ((PyObject *)__pyx_v___pyx_state));
15361 
15362   /* function exit code */
15363   __Pyx_RefNannyFinishContext();
15364   return __pyx_r;
15365 }
15366 
__pyx_pf___pyx_array_2__setstate_cython__(CYTHON_UNUSED struct __pyx_array_obj * __pyx_v_self,CYTHON_UNUSED PyObject * __pyx_v___pyx_state)15367 static PyObject *__pyx_pf___pyx_array_2__setstate_cython__(CYTHON_UNUSED struct __pyx_array_obj *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v___pyx_state) {
15368   PyObject *__pyx_r = NULL;
15369   __Pyx_RefNannyDeclarations
15370   PyObject *__pyx_t_1 = NULL;
15371   int __pyx_lineno = 0;
15372   const char *__pyx_filename = NULL;
15373   int __pyx_clineno = 0;
15374   __Pyx_RefNannySetupContext("__setstate_cython__", 0);
15375 
15376   /* "(tree fragment)":4
15377  *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
15378  * def __setstate_cython__(self, __pyx_state):
15379  *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")             # <<<<<<<<<<<<<<
15380  */
15381   __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__27, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(3, 4, __pyx_L1_error)
15382   __Pyx_GOTREF(__pyx_t_1);
15383   __Pyx_Raise(__pyx_t_1, 0, 0, 0);
15384   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
15385   __PYX_ERR(3, 4, __pyx_L1_error)
15386 
15387   /* "(tree fragment)":3
15388  * def __reduce_cython__(self):
15389  *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
15390  * def __setstate_cython__(self, __pyx_state):             # <<<<<<<<<<<<<<
15391  *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
15392  */
15393 
15394   /* function exit code */
15395   __pyx_L1_error:;
15396   __Pyx_XDECREF(__pyx_t_1);
15397   __Pyx_AddTraceback("View.MemoryView.array.__setstate_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename);
15398   __pyx_r = NULL;
15399   __Pyx_XGIVEREF(__pyx_r);
15400   __Pyx_RefNannyFinishContext();
15401   return __pyx_r;
15402 }
15403 
15404 /* "View.MemoryView":244
15405  *
15406  * @cname("__pyx_array_new")
15407  * cdef array array_cwrapper(tuple shape, Py_ssize_t itemsize, char *format,             # <<<<<<<<<<<<<<
15408  *                           char *mode, char *buf):
15409  *     cdef array result
15410  */
15411 
__pyx_array_new(PyObject * __pyx_v_shape,Py_ssize_t __pyx_v_itemsize,char * __pyx_v_format,char * __pyx_v_mode,char * __pyx_v_buf)15412 static struct __pyx_array_obj *__pyx_array_new(PyObject *__pyx_v_shape, Py_ssize_t __pyx_v_itemsize, char *__pyx_v_format, char *__pyx_v_mode, char *__pyx_v_buf) {
15413   struct __pyx_array_obj *__pyx_v_result = 0;
15414   struct __pyx_array_obj *__pyx_r = NULL;
15415   __Pyx_RefNannyDeclarations
15416   int __pyx_t_1;
15417   PyObject *__pyx_t_2 = NULL;
15418   PyObject *__pyx_t_3 = NULL;
15419   PyObject *__pyx_t_4 = NULL;
15420   PyObject *__pyx_t_5 = NULL;
15421   int __pyx_lineno = 0;
15422   const char *__pyx_filename = NULL;
15423   int __pyx_clineno = 0;
15424   __Pyx_RefNannySetupContext("array_cwrapper", 0);
15425 
15426   /* "View.MemoryView":248
15427  *     cdef array result
15428  *
15429  *     if buf == NULL:             # <<<<<<<<<<<<<<
15430  *         result = array(shape, itemsize, format, mode.decode('ASCII'))
15431  *     else:
15432  */
15433   __pyx_t_1 = ((__pyx_v_buf == NULL) != 0);
15434   if (__pyx_t_1) {
15435 
15436     /* "View.MemoryView":249
15437  *
15438  *     if buf == NULL:
15439  *         result = array(shape, itemsize, format, mode.decode('ASCII'))             # <<<<<<<<<<<<<<
15440  *     else:
15441  *         result = array(shape, itemsize, format, mode.decode('ASCII'),
15442  */
15443     __pyx_t_2 = PyInt_FromSsize_t(__pyx_v_itemsize); if (unlikely(!__pyx_t_2)) __PYX_ERR(3, 249, __pyx_L1_error)
15444     __Pyx_GOTREF(__pyx_t_2);
15445     __pyx_t_3 = __Pyx_PyBytes_FromString(__pyx_v_format); if (unlikely(!__pyx_t_3)) __PYX_ERR(3, 249, __pyx_L1_error)
15446     __Pyx_GOTREF(__pyx_t_3);
15447     __pyx_t_4 = __Pyx_decode_c_string(__pyx_v_mode, 0, strlen(__pyx_v_mode), NULL, NULL, PyUnicode_DecodeASCII); if (unlikely(!__pyx_t_4)) __PYX_ERR(3, 249, __pyx_L1_error)
15448     __Pyx_GOTREF(__pyx_t_4);
15449     __pyx_t_5 = PyTuple_New(4); if (unlikely(!__pyx_t_5)) __PYX_ERR(3, 249, __pyx_L1_error)
15450     __Pyx_GOTREF(__pyx_t_5);
15451     __Pyx_INCREF(__pyx_v_shape);
15452     __Pyx_GIVEREF(__pyx_v_shape);
15453     PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_v_shape);
15454     __Pyx_GIVEREF(__pyx_t_2);
15455     PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_t_2);
15456     __Pyx_GIVEREF(__pyx_t_3);
15457     PyTuple_SET_ITEM(__pyx_t_5, 2, __pyx_t_3);
15458     __Pyx_GIVEREF(__pyx_t_4);
15459     PyTuple_SET_ITEM(__pyx_t_5, 3, __pyx_t_4);
15460     __pyx_t_2 = 0;
15461     __pyx_t_3 = 0;
15462     __pyx_t_4 = 0;
15463     __pyx_t_4 = __Pyx_PyObject_Call(((PyObject *)__pyx_array_type), __pyx_t_5, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(3, 249, __pyx_L1_error)
15464     __Pyx_GOTREF(__pyx_t_4);
15465     __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
15466     __pyx_v_result = ((struct __pyx_array_obj *)__pyx_t_4);
15467     __pyx_t_4 = 0;
15468 
15469     /* "View.MemoryView":248
15470  *     cdef array result
15471  *
15472  *     if buf == NULL:             # <<<<<<<<<<<<<<
15473  *         result = array(shape, itemsize, format, mode.decode('ASCII'))
15474  *     else:
15475  */
15476     goto __pyx_L3;
15477   }
15478 
15479   /* "View.MemoryView":251
15480  *         result = array(shape, itemsize, format, mode.decode('ASCII'))
15481  *     else:
15482  *         result = array(shape, itemsize, format, mode.decode('ASCII'),             # <<<<<<<<<<<<<<
15483  *                        allocate_buffer=False)
15484  *         result.data = buf
15485  */
15486   /*else*/ {
15487     __pyx_t_4 = PyInt_FromSsize_t(__pyx_v_itemsize); if (unlikely(!__pyx_t_4)) __PYX_ERR(3, 251, __pyx_L1_error)
15488     __Pyx_GOTREF(__pyx_t_4);
15489     __pyx_t_5 = __Pyx_PyBytes_FromString(__pyx_v_format); if (unlikely(!__pyx_t_5)) __PYX_ERR(3, 251, __pyx_L1_error)
15490     __Pyx_GOTREF(__pyx_t_5);
15491     __pyx_t_3 = __Pyx_decode_c_string(__pyx_v_mode, 0, strlen(__pyx_v_mode), NULL, NULL, PyUnicode_DecodeASCII); if (unlikely(!__pyx_t_3)) __PYX_ERR(3, 251, __pyx_L1_error)
15492     __Pyx_GOTREF(__pyx_t_3);
15493     __pyx_t_2 = PyTuple_New(4); if (unlikely(!__pyx_t_2)) __PYX_ERR(3, 251, __pyx_L1_error)
15494     __Pyx_GOTREF(__pyx_t_2);
15495     __Pyx_INCREF(__pyx_v_shape);
15496     __Pyx_GIVEREF(__pyx_v_shape);
15497     PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_shape);
15498     __Pyx_GIVEREF(__pyx_t_4);
15499     PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_t_4);
15500     __Pyx_GIVEREF(__pyx_t_5);
15501     PyTuple_SET_ITEM(__pyx_t_2, 2, __pyx_t_5);
15502     __Pyx_GIVEREF(__pyx_t_3);
15503     PyTuple_SET_ITEM(__pyx_t_2, 3, __pyx_t_3);
15504     __pyx_t_4 = 0;
15505     __pyx_t_5 = 0;
15506     __pyx_t_3 = 0;
15507 
15508     /* "View.MemoryView":252
15509  *     else:
15510  *         result = array(shape, itemsize, format, mode.decode('ASCII'),
15511  *                        allocate_buffer=False)             # <<<<<<<<<<<<<<
15512  *         result.data = buf
15513  *
15514  */
15515     __pyx_t_3 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(3, 252, __pyx_L1_error)
15516     __Pyx_GOTREF(__pyx_t_3);
15517     if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_allocate_buffer, Py_False) < 0) __PYX_ERR(3, 252, __pyx_L1_error)
15518 
15519     /* "View.MemoryView":251
15520  *         result = array(shape, itemsize, format, mode.decode('ASCII'))
15521  *     else:
15522  *         result = array(shape, itemsize, format, mode.decode('ASCII'),             # <<<<<<<<<<<<<<
15523  *                        allocate_buffer=False)
15524  *         result.data = buf
15525  */
15526     __pyx_t_5 = __Pyx_PyObject_Call(((PyObject *)__pyx_array_type), __pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_5)) __PYX_ERR(3, 251, __pyx_L1_error)
15527     __Pyx_GOTREF(__pyx_t_5);
15528     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
15529     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
15530     __pyx_v_result = ((struct __pyx_array_obj *)__pyx_t_5);
15531     __pyx_t_5 = 0;
15532 
15533     /* "View.MemoryView":253
15534  *         result = array(shape, itemsize, format, mode.decode('ASCII'),
15535  *                        allocate_buffer=False)
15536  *         result.data = buf             # <<<<<<<<<<<<<<
15537  *
15538  *     return result
15539  */
15540     __pyx_v_result->data = __pyx_v_buf;
15541   }
15542   __pyx_L3:;
15543 
15544   /* "View.MemoryView":255
15545  *         result.data = buf
15546  *
15547  *     return result             # <<<<<<<<<<<<<<
15548  *
15549  *
15550  */
15551   __Pyx_XDECREF(((PyObject *)__pyx_r));
15552   __Pyx_INCREF(((PyObject *)__pyx_v_result));
15553   __pyx_r = __pyx_v_result;
15554   goto __pyx_L0;
15555 
15556   /* "View.MemoryView":244
15557  *
15558  * @cname("__pyx_array_new")
15559  * cdef array array_cwrapper(tuple shape, Py_ssize_t itemsize, char *format,             # <<<<<<<<<<<<<<
15560  *                           char *mode, char *buf):
15561  *     cdef array result
15562  */
15563 
15564   /* function exit code */
15565   __pyx_L1_error:;
15566   __Pyx_XDECREF(__pyx_t_2);
15567   __Pyx_XDECREF(__pyx_t_3);
15568   __Pyx_XDECREF(__pyx_t_4);
15569   __Pyx_XDECREF(__pyx_t_5);
15570   __Pyx_AddTraceback("View.MemoryView.array_cwrapper", __pyx_clineno, __pyx_lineno, __pyx_filename);
15571   __pyx_r = 0;
15572   __pyx_L0:;
15573   __Pyx_XDECREF((PyObject *)__pyx_v_result);
15574   __Pyx_XGIVEREF((PyObject *)__pyx_r);
15575   __Pyx_RefNannyFinishContext();
15576   return __pyx_r;
15577 }
15578 
15579 /* "View.MemoryView":281
15580  * cdef class Enum(object):
15581  *     cdef object name
15582  *     def __init__(self, name):             # <<<<<<<<<<<<<<
15583  *         self.name = name
15584  *     def __repr__(self):
15585  */
15586 
15587 /* Python wrapper */
15588 static int __pyx_MemviewEnum___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
__pyx_MemviewEnum___init__(PyObject * __pyx_v_self,PyObject * __pyx_args,PyObject * __pyx_kwds)15589 static int __pyx_MemviewEnum___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
15590   PyObject *__pyx_v_name = 0;
15591   int __pyx_lineno = 0;
15592   const char *__pyx_filename = NULL;
15593   int __pyx_clineno = 0;
15594   int __pyx_r;
15595   __Pyx_RefNannyDeclarations
15596   __Pyx_RefNannySetupContext("__init__ (wrapper)", 0);
15597   {
15598     static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_name,0};
15599     PyObject* values[1] = {0};
15600     if (unlikely(__pyx_kwds)) {
15601       Py_ssize_t kw_args;
15602       const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
15603       switch (pos_args) {
15604         case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
15605         CYTHON_FALLTHROUGH;
15606         case  0: break;
15607         default: goto __pyx_L5_argtuple_error;
15608       }
15609       kw_args = PyDict_Size(__pyx_kwds);
15610       switch (pos_args) {
15611         case  0:
15612         if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_name)) != 0)) kw_args--;
15613         else goto __pyx_L5_argtuple_error;
15614       }
15615       if (unlikely(kw_args > 0)) {
15616         if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__init__") < 0)) __PYX_ERR(3, 281, __pyx_L3_error)
15617       }
15618     } else if (PyTuple_GET_SIZE(__pyx_args) != 1) {
15619       goto __pyx_L5_argtuple_error;
15620     } else {
15621       values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
15622     }
15623     __pyx_v_name = values[0];
15624   }
15625   goto __pyx_L4_argument_unpacking_done;
15626   __pyx_L5_argtuple_error:;
15627   __Pyx_RaiseArgtupleInvalid("__init__", 1, 1, 1, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(3, 281, __pyx_L3_error)
15628   __pyx_L3_error:;
15629   __Pyx_AddTraceback("View.MemoryView.Enum.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
15630   __Pyx_RefNannyFinishContext();
15631   return -1;
15632   __pyx_L4_argument_unpacking_done:;
15633   __pyx_r = __pyx_MemviewEnum___pyx_pf_15View_dot_MemoryView_4Enum___init__(((struct __pyx_MemviewEnum_obj *)__pyx_v_self), __pyx_v_name);
15634 
15635   /* function exit code */
15636   __Pyx_RefNannyFinishContext();
15637   return __pyx_r;
15638 }
15639 
__pyx_MemviewEnum___pyx_pf_15View_dot_MemoryView_4Enum___init__(struct __pyx_MemviewEnum_obj * __pyx_v_self,PyObject * __pyx_v_name)15640 static int __pyx_MemviewEnum___pyx_pf_15View_dot_MemoryView_4Enum___init__(struct __pyx_MemviewEnum_obj *__pyx_v_self, PyObject *__pyx_v_name) {
15641   int __pyx_r;
15642   __Pyx_RefNannyDeclarations
15643   __Pyx_RefNannySetupContext("__init__", 0);
15644 
15645   /* "View.MemoryView":282
15646  *     cdef object name
15647  *     def __init__(self, name):
15648  *         self.name = name             # <<<<<<<<<<<<<<
15649  *     def __repr__(self):
15650  *         return self.name
15651  */
15652   __Pyx_INCREF(__pyx_v_name);
15653   __Pyx_GIVEREF(__pyx_v_name);
15654   __Pyx_GOTREF(__pyx_v_self->name);
15655   __Pyx_DECREF(__pyx_v_self->name);
15656   __pyx_v_self->name = __pyx_v_name;
15657 
15658   /* "View.MemoryView":281
15659  * cdef class Enum(object):
15660  *     cdef object name
15661  *     def __init__(self, name):             # <<<<<<<<<<<<<<
15662  *         self.name = name
15663  *     def __repr__(self):
15664  */
15665 
15666   /* function exit code */
15667   __pyx_r = 0;
15668   __Pyx_RefNannyFinishContext();
15669   return __pyx_r;
15670 }
15671 
15672 /* "View.MemoryView":283
15673  *     def __init__(self, name):
15674  *         self.name = name
15675  *     def __repr__(self):             # <<<<<<<<<<<<<<
15676  *         return self.name
15677  *
15678  */
15679 
15680 /* Python wrapper */
15681 static PyObject *__pyx_MemviewEnum___repr__(PyObject *__pyx_v_self); /*proto*/
__pyx_MemviewEnum___repr__(PyObject * __pyx_v_self)15682 static PyObject *__pyx_MemviewEnum___repr__(PyObject *__pyx_v_self) {
15683   PyObject *__pyx_r = 0;
15684   __Pyx_RefNannyDeclarations
15685   __Pyx_RefNannySetupContext("__repr__ (wrapper)", 0);
15686   __pyx_r = __pyx_MemviewEnum___pyx_pf_15View_dot_MemoryView_4Enum_2__repr__(((struct __pyx_MemviewEnum_obj *)__pyx_v_self));
15687 
15688   /* function exit code */
15689   __Pyx_RefNannyFinishContext();
15690   return __pyx_r;
15691 }
15692 
__pyx_MemviewEnum___pyx_pf_15View_dot_MemoryView_4Enum_2__repr__(struct __pyx_MemviewEnum_obj * __pyx_v_self)15693 static PyObject *__pyx_MemviewEnum___pyx_pf_15View_dot_MemoryView_4Enum_2__repr__(struct __pyx_MemviewEnum_obj *__pyx_v_self) {
15694   PyObject *__pyx_r = NULL;
15695   __Pyx_RefNannyDeclarations
15696   __Pyx_RefNannySetupContext("__repr__", 0);
15697 
15698   /* "View.MemoryView":284
15699  *         self.name = name
15700  *     def __repr__(self):
15701  *         return self.name             # <<<<<<<<<<<<<<
15702  *
15703  * cdef generic = Enum("<strided and direct or indirect>")
15704  */
15705   __Pyx_XDECREF(__pyx_r);
15706   __Pyx_INCREF(__pyx_v_self->name);
15707   __pyx_r = __pyx_v_self->name;
15708   goto __pyx_L0;
15709 
15710   /* "View.MemoryView":283
15711  *     def __init__(self, name):
15712  *         self.name = name
15713  *     def __repr__(self):             # <<<<<<<<<<<<<<
15714  *         return self.name
15715  *
15716  */
15717 
15718   /* function exit code */
15719   __pyx_L0:;
15720   __Pyx_XGIVEREF(__pyx_r);
15721   __Pyx_RefNannyFinishContext();
15722   return __pyx_r;
15723 }
15724 
15725 /* "(tree fragment)":1
15726  * def __reduce_cython__(self):             # <<<<<<<<<<<<<<
15727  *     cdef tuple state
15728  *     cdef object _dict
15729  */
15730 
15731 /* Python wrapper */
15732 static PyObject *__pyx_pw___pyx_MemviewEnum_1__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
__pyx_pw___pyx_MemviewEnum_1__reduce_cython__(PyObject * __pyx_v_self,CYTHON_UNUSED PyObject * unused)15733 static PyObject *__pyx_pw___pyx_MemviewEnum_1__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
15734   PyObject *__pyx_r = 0;
15735   __Pyx_RefNannyDeclarations
15736   __Pyx_RefNannySetupContext("__reduce_cython__ (wrapper)", 0);
15737   __pyx_r = __pyx_pf___pyx_MemviewEnum___reduce_cython__(((struct __pyx_MemviewEnum_obj *)__pyx_v_self));
15738 
15739   /* function exit code */
15740   __Pyx_RefNannyFinishContext();
15741   return __pyx_r;
15742 }
15743 
__pyx_pf___pyx_MemviewEnum___reduce_cython__(struct __pyx_MemviewEnum_obj * __pyx_v_self)15744 static PyObject *__pyx_pf___pyx_MemviewEnum___reduce_cython__(struct __pyx_MemviewEnum_obj *__pyx_v_self) {
15745   PyObject *__pyx_v_state = 0;
15746   PyObject *__pyx_v__dict = 0;
15747   int __pyx_v_use_setstate;
15748   PyObject *__pyx_r = NULL;
15749   __Pyx_RefNannyDeclarations
15750   PyObject *__pyx_t_1 = NULL;
15751   int __pyx_t_2;
15752   int __pyx_t_3;
15753   PyObject *__pyx_t_4 = NULL;
15754   PyObject *__pyx_t_5 = NULL;
15755   int __pyx_lineno = 0;
15756   const char *__pyx_filename = NULL;
15757   int __pyx_clineno = 0;
15758   __Pyx_RefNannySetupContext("__reduce_cython__", 0);
15759 
15760   /* "(tree fragment)":5
15761  *     cdef object _dict
15762  *     cdef bint use_setstate
15763  *     state = (self.name,)             # <<<<<<<<<<<<<<
15764  *     _dict = getattr(self, '__dict__', None)
15765  *     if _dict is not None:
15766  */
15767   __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(3, 5, __pyx_L1_error)
15768   __Pyx_GOTREF(__pyx_t_1);
15769   __Pyx_INCREF(__pyx_v_self->name);
15770   __Pyx_GIVEREF(__pyx_v_self->name);
15771   PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_self->name);
15772   __pyx_v_state = ((PyObject*)__pyx_t_1);
15773   __pyx_t_1 = 0;
15774 
15775   /* "(tree fragment)":6
15776  *     cdef bint use_setstate
15777  *     state = (self.name,)
15778  *     _dict = getattr(self, '__dict__', None)             # <<<<<<<<<<<<<<
15779  *     if _dict is not None:
15780  *         state += (_dict,)
15781  */
15782   __pyx_t_1 = __Pyx_GetAttr3(((PyObject *)__pyx_v_self), __pyx_n_s_dict, Py_None); if (unlikely(!__pyx_t_1)) __PYX_ERR(3, 6, __pyx_L1_error)
15783   __Pyx_GOTREF(__pyx_t_1);
15784   __pyx_v__dict = __pyx_t_1;
15785   __pyx_t_1 = 0;
15786 
15787   /* "(tree fragment)":7
15788  *     state = (self.name,)
15789  *     _dict = getattr(self, '__dict__', None)
15790  *     if _dict is not None:             # <<<<<<<<<<<<<<
15791  *         state += (_dict,)
15792  *         use_setstate = True
15793  */
15794   __pyx_t_2 = (__pyx_v__dict != Py_None);
15795   __pyx_t_3 = (__pyx_t_2 != 0);
15796   if (__pyx_t_3) {
15797 
15798     /* "(tree fragment)":8
15799  *     _dict = getattr(self, '__dict__', None)
15800  *     if _dict is not None:
15801  *         state += (_dict,)             # <<<<<<<<<<<<<<
15802  *         use_setstate = True
15803  *     else:
15804  */
15805     __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(3, 8, __pyx_L1_error)
15806     __Pyx_GOTREF(__pyx_t_1);
15807     __Pyx_INCREF(__pyx_v__dict);
15808     __Pyx_GIVEREF(__pyx_v__dict);
15809     PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v__dict);
15810     __pyx_t_4 = PyNumber_InPlaceAdd(__pyx_v_state, __pyx_t_1); if (unlikely(!__pyx_t_4)) __PYX_ERR(3, 8, __pyx_L1_error)
15811     __Pyx_GOTREF(__pyx_t_4);
15812     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
15813     __Pyx_DECREF_SET(__pyx_v_state, ((PyObject*)__pyx_t_4));
15814     __pyx_t_4 = 0;
15815 
15816     /* "(tree fragment)":9
15817  *     if _dict is not None:
15818  *         state += (_dict,)
15819  *         use_setstate = True             # <<<<<<<<<<<<<<
15820  *     else:
15821  *         use_setstate = self.name is not None
15822  */
15823     __pyx_v_use_setstate = 1;
15824 
15825     /* "(tree fragment)":7
15826  *     state = (self.name,)
15827  *     _dict = getattr(self, '__dict__', None)
15828  *     if _dict is not None:             # <<<<<<<<<<<<<<
15829  *         state += (_dict,)
15830  *         use_setstate = True
15831  */
15832     goto __pyx_L3;
15833   }
15834 
15835   /* "(tree fragment)":11
15836  *         use_setstate = True
15837  *     else:
15838  *         use_setstate = self.name is not None             # <<<<<<<<<<<<<<
15839  *     if use_setstate:
15840  *         return __pyx_unpickle_Enum, (type(self), 0xb068931, None), state
15841  */
15842   /*else*/ {
15843     __pyx_t_3 = (__pyx_v_self->name != Py_None);
15844     __pyx_v_use_setstate = __pyx_t_3;
15845   }
15846   __pyx_L3:;
15847 
15848   /* "(tree fragment)":12
15849  *     else:
15850  *         use_setstate = self.name is not None
15851  *     if use_setstate:             # <<<<<<<<<<<<<<
15852  *         return __pyx_unpickle_Enum, (type(self), 0xb068931, None), state
15853  *     else:
15854  */
15855   __pyx_t_3 = (__pyx_v_use_setstate != 0);
15856   if (__pyx_t_3) {
15857 
15858     /* "(tree fragment)":13
15859  *         use_setstate = self.name is not None
15860  *     if use_setstate:
15861  *         return __pyx_unpickle_Enum, (type(self), 0xb068931, None), state             # <<<<<<<<<<<<<<
15862  *     else:
15863  *         return __pyx_unpickle_Enum, (type(self), 0xb068931, state)
15864  */
15865     __Pyx_XDECREF(__pyx_r);
15866     __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_pyx_unpickle_Enum); if (unlikely(!__pyx_t_4)) __PYX_ERR(3, 13, __pyx_L1_error)
15867     __Pyx_GOTREF(__pyx_t_4);
15868     __pyx_t_1 = PyTuple_New(3); if (unlikely(!__pyx_t_1)) __PYX_ERR(3, 13, __pyx_L1_error)
15869     __Pyx_GOTREF(__pyx_t_1);
15870     __Pyx_INCREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
15871     __Pyx_GIVEREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
15872     PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
15873     __Pyx_INCREF(__pyx_int_184977713);
15874     __Pyx_GIVEREF(__pyx_int_184977713);
15875     PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_int_184977713);
15876     __Pyx_INCREF(Py_None);
15877     __Pyx_GIVEREF(Py_None);
15878     PyTuple_SET_ITEM(__pyx_t_1, 2, Py_None);
15879     __pyx_t_5 = PyTuple_New(3); if (unlikely(!__pyx_t_5)) __PYX_ERR(3, 13, __pyx_L1_error)
15880     __Pyx_GOTREF(__pyx_t_5);
15881     __Pyx_GIVEREF(__pyx_t_4);
15882     PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_4);
15883     __Pyx_GIVEREF(__pyx_t_1);
15884     PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_t_1);
15885     __Pyx_INCREF(__pyx_v_state);
15886     __Pyx_GIVEREF(__pyx_v_state);
15887     PyTuple_SET_ITEM(__pyx_t_5, 2, __pyx_v_state);
15888     __pyx_t_4 = 0;
15889     __pyx_t_1 = 0;
15890     __pyx_r = __pyx_t_5;
15891     __pyx_t_5 = 0;
15892     goto __pyx_L0;
15893 
15894     /* "(tree fragment)":12
15895  *     else:
15896  *         use_setstate = self.name is not None
15897  *     if use_setstate:             # <<<<<<<<<<<<<<
15898  *         return __pyx_unpickle_Enum, (type(self), 0xb068931, None), state
15899  *     else:
15900  */
15901   }
15902 
15903   /* "(tree fragment)":15
15904  *         return __pyx_unpickle_Enum, (type(self), 0xb068931, None), state
15905  *     else:
15906  *         return __pyx_unpickle_Enum, (type(self), 0xb068931, state)             # <<<<<<<<<<<<<<
15907  * def __setstate_cython__(self, __pyx_state):
15908  *     __pyx_unpickle_Enum__set_state(self, __pyx_state)
15909  */
15910   /*else*/ {
15911     __Pyx_XDECREF(__pyx_r);
15912     __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_n_s_pyx_unpickle_Enum); if (unlikely(!__pyx_t_5)) __PYX_ERR(3, 15, __pyx_L1_error)
15913     __Pyx_GOTREF(__pyx_t_5);
15914     __pyx_t_1 = PyTuple_New(3); if (unlikely(!__pyx_t_1)) __PYX_ERR(3, 15, __pyx_L1_error)
15915     __Pyx_GOTREF(__pyx_t_1);
15916     __Pyx_INCREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
15917     __Pyx_GIVEREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
15918     PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
15919     __Pyx_INCREF(__pyx_int_184977713);
15920     __Pyx_GIVEREF(__pyx_int_184977713);
15921     PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_int_184977713);
15922     __Pyx_INCREF(__pyx_v_state);
15923     __Pyx_GIVEREF(__pyx_v_state);
15924     PyTuple_SET_ITEM(__pyx_t_1, 2, __pyx_v_state);
15925     __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) __PYX_ERR(3, 15, __pyx_L1_error)
15926     __Pyx_GOTREF(__pyx_t_4);
15927     __Pyx_GIVEREF(__pyx_t_5);
15928     PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_5);
15929     __Pyx_GIVEREF(__pyx_t_1);
15930     PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_1);
15931     __pyx_t_5 = 0;
15932     __pyx_t_1 = 0;
15933     __pyx_r = __pyx_t_4;
15934     __pyx_t_4 = 0;
15935     goto __pyx_L0;
15936   }
15937 
15938   /* "(tree fragment)":1
15939  * def __reduce_cython__(self):             # <<<<<<<<<<<<<<
15940  *     cdef tuple state
15941  *     cdef object _dict
15942  */
15943 
15944   /* function exit code */
15945   __pyx_L1_error:;
15946   __Pyx_XDECREF(__pyx_t_1);
15947   __Pyx_XDECREF(__pyx_t_4);
15948   __Pyx_XDECREF(__pyx_t_5);
15949   __Pyx_AddTraceback("View.MemoryView.Enum.__reduce_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename);
15950   __pyx_r = NULL;
15951   __pyx_L0:;
15952   __Pyx_XDECREF(__pyx_v_state);
15953   __Pyx_XDECREF(__pyx_v__dict);
15954   __Pyx_XGIVEREF(__pyx_r);
15955   __Pyx_RefNannyFinishContext();
15956   return __pyx_r;
15957 }
15958 
15959 /* "(tree fragment)":16
15960  *     else:
15961  *         return __pyx_unpickle_Enum, (type(self), 0xb068931, state)
15962  * def __setstate_cython__(self, __pyx_state):             # <<<<<<<<<<<<<<
15963  *     __pyx_unpickle_Enum__set_state(self, __pyx_state)
15964  */
15965 
15966 /* Python wrapper */
15967 static PyObject *__pyx_pw___pyx_MemviewEnum_3__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state); /*proto*/
__pyx_pw___pyx_MemviewEnum_3__setstate_cython__(PyObject * __pyx_v_self,PyObject * __pyx_v___pyx_state)15968 static PyObject *__pyx_pw___pyx_MemviewEnum_3__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state) {
15969   PyObject *__pyx_r = 0;
15970   __Pyx_RefNannyDeclarations
15971   __Pyx_RefNannySetupContext("__setstate_cython__ (wrapper)", 0);
15972   __pyx_r = __pyx_pf___pyx_MemviewEnum_2__setstate_cython__(((struct __pyx_MemviewEnum_obj *)__pyx_v_self), ((PyObject *)__pyx_v___pyx_state));
15973 
15974   /* function exit code */
15975   __Pyx_RefNannyFinishContext();
15976   return __pyx_r;
15977 }
15978 
__pyx_pf___pyx_MemviewEnum_2__setstate_cython__(struct __pyx_MemviewEnum_obj * __pyx_v_self,PyObject * __pyx_v___pyx_state)15979 static PyObject *__pyx_pf___pyx_MemviewEnum_2__setstate_cython__(struct __pyx_MemviewEnum_obj *__pyx_v_self, PyObject *__pyx_v___pyx_state) {
15980   PyObject *__pyx_r = NULL;
15981   __Pyx_RefNannyDeclarations
15982   PyObject *__pyx_t_1 = NULL;
15983   int __pyx_lineno = 0;
15984   const char *__pyx_filename = NULL;
15985   int __pyx_clineno = 0;
15986   __Pyx_RefNannySetupContext("__setstate_cython__", 0);
15987 
15988   /* "(tree fragment)":17
15989  *         return __pyx_unpickle_Enum, (type(self), 0xb068931, state)
15990  * def __setstate_cython__(self, __pyx_state):
15991  *     __pyx_unpickle_Enum__set_state(self, __pyx_state)             # <<<<<<<<<<<<<<
15992  */
15993   if (!(likely(PyTuple_CheckExact(__pyx_v___pyx_state))||((__pyx_v___pyx_state) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_v___pyx_state)->tp_name), 0))) __PYX_ERR(3, 17, __pyx_L1_error)
15994   __pyx_t_1 = __pyx_unpickle_Enum__set_state(__pyx_v_self, ((PyObject*)__pyx_v___pyx_state)); if (unlikely(!__pyx_t_1)) __PYX_ERR(3, 17, __pyx_L1_error)
15995   __Pyx_GOTREF(__pyx_t_1);
15996   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
15997 
15998   /* "(tree fragment)":16
15999  *     else:
16000  *         return __pyx_unpickle_Enum, (type(self), 0xb068931, state)
16001  * def __setstate_cython__(self, __pyx_state):             # <<<<<<<<<<<<<<
16002  *     __pyx_unpickle_Enum__set_state(self, __pyx_state)
16003  */
16004 
16005   /* function exit code */
16006   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
16007   goto __pyx_L0;
16008   __pyx_L1_error:;
16009   __Pyx_XDECREF(__pyx_t_1);
16010   __Pyx_AddTraceback("View.MemoryView.Enum.__setstate_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename);
16011   __pyx_r = NULL;
16012   __pyx_L0:;
16013   __Pyx_XGIVEREF(__pyx_r);
16014   __Pyx_RefNannyFinishContext();
16015   return __pyx_r;
16016 }
16017 
16018 /* "View.MemoryView":298
16019  *
16020  * @cname('__pyx_align_pointer')
16021  * cdef void *align_pointer(void *memory, size_t alignment) nogil:             # <<<<<<<<<<<<<<
16022  *     "Align pointer memory on a given boundary"
16023  *     cdef Py_intptr_t aligned_p = <Py_intptr_t> memory
16024  */
16025 
__pyx_align_pointer(void * __pyx_v_memory,size_t __pyx_v_alignment)16026 static void *__pyx_align_pointer(void *__pyx_v_memory, size_t __pyx_v_alignment) {
16027   Py_intptr_t __pyx_v_aligned_p;
16028   size_t __pyx_v_offset;
16029   void *__pyx_r;
16030   int __pyx_t_1;
16031 
16032   /* "View.MemoryView":300
16033  * cdef void *align_pointer(void *memory, size_t alignment) nogil:
16034  *     "Align pointer memory on a given boundary"
16035  *     cdef Py_intptr_t aligned_p = <Py_intptr_t> memory             # <<<<<<<<<<<<<<
16036  *     cdef size_t offset
16037  *
16038  */
16039   __pyx_v_aligned_p = ((Py_intptr_t)__pyx_v_memory);
16040 
16041   /* "View.MemoryView":304
16042  *
16043  *     with cython.cdivision(True):
16044  *         offset = aligned_p % alignment             # <<<<<<<<<<<<<<
16045  *
16046  *     if offset > 0:
16047  */
16048   __pyx_v_offset = (__pyx_v_aligned_p % __pyx_v_alignment);
16049 
16050   /* "View.MemoryView":306
16051  *         offset = aligned_p % alignment
16052  *
16053  *     if offset > 0:             # <<<<<<<<<<<<<<
16054  *         aligned_p += alignment - offset
16055  *
16056  */
16057   __pyx_t_1 = ((__pyx_v_offset > 0) != 0);
16058   if (__pyx_t_1) {
16059 
16060     /* "View.MemoryView":307
16061  *
16062  *     if offset > 0:
16063  *         aligned_p += alignment - offset             # <<<<<<<<<<<<<<
16064  *
16065  *     return <void *> aligned_p
16066  */
16067     __pyx_v_aligned_p = (__pyx_v_aligned_p + (__pyx_v_alignment - __pyx_v_offset));
16068 
16069     /* "View.MemoryView":306
16070  *         offset = aligned_p % alignment
16071  *
16072  *     if offset > 0:             # <<<<<<<<<<<<<<
16073  *         aligned_p += alignment - offset
16074  *
16075  */
16076   }
16077 
16078   /* "View.MemoryView":309
16079  *         aligned_p += alignment - offset
16080  *
16081  *     return <void *> aligned_p             # <<<<<<<<<<<<<<
16082  *
16083  *
16084  */
16085   __pyx_r = ((void *)__pyx_v_aligned_p);
16086   goto __pyx_L0;
16087 
16088   /* "View.MemoryView":298
16089  *
16090  * @cname('__pyx_align_pointer')
16091  * cdef void *align_pointer(void *memory, size_t alignment) nogil:             # <<<<<<<<<<<<<<
16092  *     "Align pointer memory on a given boundary"
16093  *     cdef Py_intptr_t aligned_p = <Py_intptr_t> memory
16094  */
16095 
16096   /* function exit code */
16097   __pyx_L0:;
16098   return __pyx_r;
16099 }
16100 
16101 /* "View.MemoryView":345
16102  *     cdef __Pyx_TypeInfo *typeinfo
16103  *
16104  *     def __cinit__(memoryview self, object obj, int flags, bint dtype_is_object=False):             # <<<<<<<<<<<<<<
16105  *         self.obj = obj
16106  *         self.flags = flags
16107  */
16108 
16109 /* Python wrapper */
16110 static int __pyx_memoryview___cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
__pyx_memoryview___cinit__(PyObject * __pyx_v_self,PyObject * __pyx_args,PyObject * __pyx_kwds)16111 static int __pyx_memoryview___cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
16112   PyObject *__pyx_v_obj = 0;
16113   int __pyx_v_flags;
16114   int __pyx_v_dtype_is_object;
16115   int __pyx_lineno = 0;
16116   const char *__pyx_filename = NULL;
16117   int __pyx_clineno = 0;
16118   int __pyx_r;
16119   __Pyx_RefNannyDeclarations
16120   __Pyx_RefNannySetupContext("__cinit__ (wrapper)", 0);
16121   {
16122     static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_obj,&__pyx_n_s_flags,&__pyx_n_s_dtype_is_object,0};
16123     PyObject* values[3] = {0,0,0};
16124     if (unlikely(__pyx_kwds)) {
16125       Py_ssize_t kw_args;
16126       const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
16127       switch (pos_args) {
16128         case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
16129         CYTHON_FALLTHROUGH;
16130         case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
16131         CYTHON_FALLTHROUGH;
16132         case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
16133         CYTHON_FALLTHROUGH;
16134         case  0: break;
16135         default: goto __pyx_L5_argtuple_error;
16136       }
16137       kw_args = PyDict_Size(__pyx_kwds);
16138       switch (pos_args) {
16139         case  0:
16140         if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_obj)) != 0)) kw_args--;
16141         else goto __pyx_L5_argtuple_error;
16142         CYTHON_FALLTHROUGH;
16143         case  1:
16144         if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_flags)) != 0)) kw_args--;
16145         else {
16146           __Pyx_RaiseArgtupleInvalid("__cinit__", 0, 2, 3, 1); __PYX_ERR(3, 345, __pyx_L3_error)
16147         }
16148         CYTHON_FALLTHROUGH;
16149         case  2:
16150         if (kw_args > 0) {
16151           PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_dtype_is_object);
16152           if (value) { values[2] = value; kw_args--; }
16153         }
16154       }
16155       if (unlikely(kw_args > 0)) {
16156         if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__cinit__") < 0)) __PYX_ERR(3, 345, __pyx_L3_error)
16157       }
16158     } else {
16159       switch (PyTuple_GET_SIZE(__pyx_args)) {
16160         case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
16161         CYTHON_FALLTHROUGH;
16162         case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
16163         values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
16164         break;
16165         default: goto __pyx_L5_argtuple_error;
16166       }
16167     }
16168     __pyx_v_obj = values[0];
16169     __pyx_v_flags = __Pyx_PyInt_As_int(values[1]); if (unlikely((__pyx_v_flags == (int)-1) && PyErr_Occurred())) __PYX_ERR(3, 345, __pyx_L3_error)
16170     if (values[2]) {
16171       __pyx_v_dtype_is_object = __Pyx_PyObject_IsTrue(values[2]); if (unlikely((__pyx_v_dtype_is_object == (int)-1) && PyErr_Occurred())) __PYX_ERR(3, 345, __pyx_L3_error)
16172     } else {
16173       __pyx_v_dtype_is_object = ((int)0);
16174     }
16175   }
16176   goto __pyx_L4_argument_unpacking_done;
16177   __pyx_L5_argtuple_error:;
16178   __Pyx_RaiseArgtupleInvalid("__cinit__", 0, 2, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(3, 345, __pyx_L3_error)
16179   __pyx_L3_error:;
16180   __Pyx_AddTraceback("View.MemoryView.memoryview.__cinit__", __pyx_clineno, __pyx_lineno, __pyx_filename);
16181   __Pyx_RefNannyFinishContext();
16182   return -1;
16183   __pyx_L4_argument_unpacking_done:;
16184   __pyx_r = __pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview___cinit__(((struct __pyx_memoryview_obj *)__pyx_v_self), __pyx_v_obj, __pyx_v_flags, __pyx_v_dtype_is_object);
16185 
16186   /* function exit code */
16187   __Pyx_RefNannyFinishContext();
16188   return __pyx_r;
16189 }
16190 
__pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview___cinit__(struct __pyx_memoryview_obj * __pyx_v_self,PyObject * __pyx_v_obj,int __pyx_v_flags,int __pyx_v_dtype_is_object)16191 static int __pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview___cinit__(struct __pyx_memoryview_obj *__pyx_v_self, PyObject *__pyx_v_obj, int __pyx_v_flags, int __pyx_v_dtype_is_object) {
16192   int __pyx_r;
16193   __Pyx_RefNannyDeclarations
16194   int __pyx_t_1;
16195   int __pyx_t_2;
16196   int __pyx_t_3;
16197   int __pyx_t_4;
16198   int __pyx_lineno = 0;
16199   const char *__pyx_filename = NULL;
16200   int __pyx_clineno = 0;
16201   __Pyx_RefNannySetupContext("__cinit__", 0);
16202 
16203   /* "View.MemoryView":346
16204  *
16205  *     def __cinit__(memoryview self, object obj, int flags, bint dtype_is_object=False):
16206  *         self.obj = obj             # <<<<<<<<<<<<<<
16207  *         self.flags = flags
16208  *         if type(self) is memoryview or obj is not None:
16209  */
16210   __Pyx_INCREF(__pyx_v_obj);
16211   __Pyx_GIVEREF(__pyx_v_obj);
16212   __Pyx_GOTREF(__pyx_v_self->obj);
16213   __Pyx_DECREF(__pyx_v_self->obj);
16214   __pyx_v_self->obj = __pyx_v_obj;
16215 
16216   /* "View.MemoryView":347
16217  *     def __cinit__(memoryview self, object obj, int flags, bint dtype_is_object=False):
16218  *         self.obj = obj
16219  *         self.flags = flags             # <<<<<<<<<<<<<<
16220  *         if type(self) is memoryview or obj is not None:
16221  *             __Pyx_GetBuffer(obj, &self.view, flags)
16222  */
16223   __pyx_v_self->flags = __pyx_v_flags;
16224 
16225   /* "View.MemoryView":348
16226  *         self.obj = obj
16227  *         self.flags = flags
16228  *         if type(self) is memoryview or obj is not None:             # <<<<<<<<<<<<<<
16229  *             __Pyx_GetBuffer(obj, &self.view, flags)
16230  *             if <PyObject *> self.view.obj == NULL:
16231  */
16232   __pyx_t_2 = (((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))) == ((PyObject *)__pyx_memoryview_type));
16233   __pyx_t_3 = (__pyx_t_2 != 0);
16234   if (!__pyx_t_3) {
16235   } else {
16236     __pyx_t_1 = __pyx_t_3;
16237     goto __pyx_L4_bool_binop_done;
16238   }
16239   __pyx_t_3 = (__pyx_v_obj != Py_None);
16240   __pyx_t_2 = (__pyx_t_3 != 0);
16241   __pyx_t_1 = __pyx_t_2;
16242   __pyx_L4_bool_binop_done:;
16243   if (__pyx_t_1) {
16244 
16245     /* "View.MemoryView":349
16246  *         self.flags = flags
16247  *         if type(self) is memoryview or obj is not None:
16248  *             __Pyx_GetBuffer(obj, &self.view, flags)             # <<<<<<<<<<<<<<
16249  *             if <PyObject *> self.view.obj == NULL:
16250  *                 (<__pyx_buffer *> &self.view).obj = Py_None
16251  */
16252     __pyx_t_4 = __Pyx_GetBuffer(__pyx_v_obj, (&__pyx_v_self->view), __pyx_v_flags); if (unlikely(__pyx_t_4 == ((int)-1))) __PYX_ERR(3, 349, __pyx_L1_error)
16253 
16254     /* "View.MemoryView":350
16255  *         if type(self) is memoryview or obj is not None:
16256  *             __Pyx_GetBuffer(obj, &self.view, flags)
16257  *             if <PyObject *> self.view.obj == NULL:             # <<<<<<<<<<<<<<
16258  *                 (<__pyx_buffer *> &self.view).obj = Py_None
16259  *                 Py_INCREF(Py_None)
16260  */
16261     __pyx_t_1 = ((((PyObject *)__pyx_v_self->view.obj) == NULL) != 0);
16262     if (__pyx_t_1) {
16263 
16264       /* "View.MemoryView":351
16265  *             __Pyx_GetBuffer(obj, &self.view, flags)
16266  *             if <PyObject *> self.view.obj == NULL:
16267  *                 (<__pyx_buffer *> &self.view).obj = Py_None             # <<<<<<<<<<<<<<
16268  *                 Py_INCREF(Py_None)
16269  *
16270  */
16271       ((Py_buffer *)(&__pyx_v_self->view))->obj = Py_None;
16272 
16273       /* "View.MemoryView":352
16274  *             if <PyObject *> self.view.obj == NULL:
16275  *                 (<__pyx_buffer *> &self.view).obj = Py_None
16276  *                 Py_INCREF(Py_None)             # <<<<<<<<<<<<<<
16277  *
16278  *         global __pyx_memoryview_thread_locks_used
16279  */
16280       Py_INCREF(Py_None);
16281 
16282       /* "View.MemoryView":350
16283  *         if type(self) is memoryview or obj is not None:
16284  *             __Pyx_GetBuffer(obj, &self.view, flags)
16285  *             if <PyObject *> self.view.obj == NULL:             # <<<<<<<<<<<<<<
16286  *                 (<__pyx_buffer *> &self.view).obj = Py_None
16287  *                 Py_INCREF(Py_None)
16288  */
16289     }
16290 
16291     /* "View.MemoryView":348
16292  *         self.obj = obj
16293  *         self.flags = flags
16294  *         if type(self) is memoryview or obj is not None:             # <<<<<<<<<<<<<<
16295  *             __Pyx_GetBuffer(obj, &self.view, flags)
16296  *             if <PyObject *> self.view.obj == NULL:
16297  */
16298   }
16299 
16300   /* "View.MemoryView":355
16301  *
16302  *         global __pyx_memoryview_thread_locks_used
16303  *         if __pyx_memoryview_thread_locks_used < THREAD_LOCKS_PREALLOCATED:             # <<<<<<<<<<<<<<
16304  *             self.lock = __pyx_memoryview_thread_locks[__pyx_memoryview_thread_locks_used]
16305  *             __pyx_memoryview_thread_locks_used += 1
16306  */
16307   __pyx_t_1 = ((__pyx_memoryview_thread_locks_used < 8) != 0);
16308   if (__pyx_t_1) {
16309 
16310     /* "View.MemoryView":356
16311  *         global __pyx_memoryview_thread_locks_used
16312  *         if __pyx_memoryview_thread_locks_used < THREAD_LOCKS_PREALLOCATED:
16313  *             self.lock = __pyx_memoryview_thread_locks[__pyx_memoryview_thread_locks_used]             # <<<<<<<<<<<<<<
16314  *             __pyx_memoryview_thread_locks_used += 1
16315  *         if self.lock is NULL:
16316  */
16317     __pyx_v_self->lock = (__pyx_memoryview_thread_locks[__pyx_memoryview_thread_locks_used]);
16318 
16319     /* "View.MemoryView":357
16320  *         if __pyx_memoryview_thread_locks_used < THREAD_LOCKS_PREALLOCATED:
16321  *             self.lock = __pyx_memoryview_thread_locks[__pyx_memoryview_thread_locks_used]
16322  *             __pyx_memoryview_thread_locks_used += 1             # <<<<<<<<<<<<<<
16323  *         if self.lock is NULL:
16324  *             self.lock = PyThread_allocate_lock()
16325  */
16326     __pyx_memoryview_thread_locks_used = (__pyx_memoryview_thread_locks_used + 1);
16327 
16328     /* "View.MemoryView":355
16329  *
16330  *         global __pyx_memoryview_thread_locks_used
16331  *         if __pyx_memoryview_thread_locks_used < THREAD_LOCKS_PREALLOCATED:             # <<<<<<<<<<<<<<
16332  *             self.lock = __pyx_memoryview_thread_locks[__pyx_memoryview_thread_locks_used]
16333  *             __pyx_memoryview_thread_locks_used += 1
16334  */
16335   }
16336 
16337   /* "View.MemoryView":358
16338  *             self.lock = __pyx_memoryview_thread_locks[__pyx_memoryview_thread_locks_used]
16339  *             __pyx_memoryview_thread_locks_used += 1
16340  *         if self.lock is NULL:             # <<<<<<<<<<<<<<
16341  *             self.lock = PyThread_allocate_lock()
16342  *             if self.lock is NULL:
16343  */
16344   __pyx_t_1 = ((__pyx_v_self->lock == NULL) != 0);
16345   if (__pyx_t_1) {
16346 
16347     /* "View.MemoryView":359
16348  *             __pyx_memoryview_thread_locks_used += 1
16349  *         if self.lock is NULL:
16350  *             self.lock = PyThread_allocate_lock()             # <<<<<<<<<<<<<<
16351  *             if self.lock is NULL:
16352  *                 raise MemoryError
16353  */
16354     __pyx_v_self->lock = PyThread_allocate_lock();
16355 
16356     /* "View.MemoryView":360
16357  *         if self.lock is NULL:
16358  *             self.lock = PyThread_allocate_lock()
16359  *             if self.lock is NULL:             # <<<<<<<<<<<<<<
16360  *                 raise MemoryError
16361  *
16362  */
16363     __pyx_t_1 = ((__pyx_v_self->lock == NULL) != 0);
16364     if (unlikely(__pyx_t_1)) {
16365 
16366       /* "View.MemoryView":361
16367  *             self.lock = PyThread_allocate_lock()
16368  *             if self.lock is NULL:
16369  *                 raise MemoryError             # <<<<<<<<<<<<<<
16370  *
16371  *         if flags & PyBUF_FORMAT:
16372  */
16373       PyErr_NoMemory(); __PYX_ERR(3, 361, __pyx_L1_error)
16374 
16375       /* "View.MemoryView":360
16376  *         if self.lock is NULL:
16377  *             self.lock = PyThread_allocate_lock()
16378  *             if self.lock is NULL:             # <<<<<<<<<<<<<<
16379  *                 raise MemoryError
16380  *
16381  */
16382     }
16383 
16384     /* "View.MemoryView":358
16385  *             self.lock = __pyx_memoryview_thread_locks[__pyx_memoryview_thread_locks_used]
16386  *             __pyx_memoryview_thread_locks_used += 1
16387  *         if self.lock is NULL:             # <<<<<<<<<<<<<<
16388  *             self.lock = PyThread_allocate_lock()
16389  *             if self.lock is NULL:
16390  */
16391   }
16392 
16393   /* "View.MemoryView":363
16394  *                 raise MemoryError
16395  *
16396  *         if flags & PyBUF_FORMAT:             # <<<<<<<<<<<<<<
16397  *             self.dtype_is_object = (self.view.format[0] == b'O' and self.view.format[1] == b'\0')
16398  *         else:
16399  */
16400   __pyx_t_1 = ((__pyx_v_flags & PyBUF_FORMAT) != 0);
16401   if (__pyx_t_1) {
16402 
16403     /* "View.MemoryView":364
16404  *
16405  *         if flags & PyBUF_FORMAT:
16406  *             self.dtype_is_object = (self.view.format[0] == b'O' and self.view.format[1] == b'\0')             # <<<<<<<<<<<<<<
16407  *         else:
16408  *             self.dtype_is_object = dtype_is_object
16409  */
16410     __pyx_t_2 = (((__pyx_v_self->view.format[0]) == 'O') != 0);
16411     if (__pyx_t_2) {
16412     } else {
16413       __pyx_t_1 = __pyx_t_2;
16414       goto __pyx_L11_bool_binop_done;
16415     }
16416     __pyx_t_2 = (((__pyx_v_self->view.format[1]) == '\x00') != 0);
16417     __pyx_t_1 = __pyx_t_2;
16418     __pyx_L11_bool_binop_done:;
16419     __pyx_v_self->dtype_is_object = __pyx_t_1;
16420 
16421     /* "View.MemoryView":363
16422  *                 raise MemoryError
16423  *
16424  *         if flags & PyBUF_FORMAT:             # <<<<<<<<<<<<<<
16425  *             self.dtype_is_object = (self.view.format[0] == b'O' and self.view.format[1] == b'\0')
16426  *         else:
16427  */
16428     goto __pyx_L10;
16429   }
16430 
16431   /* "View.MemoryView":366
16432  *             self.dtype_is_object = (self.view.format[0] == b'O' and self.view.format[1] == b'\0')
16433  *         else:
16434  *             self.dtype_is_object = dtype_is_object             # <<<<<<<<<<<<<<
16435  *
16436  *         self.acquisition_count_aligned_p = <__pyx_atomic_int *> align_pointer(
16437  */
16438   /*else*/ {
16439     __pyx_v_self->dtype_is_object = __pyx_v_dtype_is_object;
16440   }
16441   __pyx_L10:;
16442 
16443   /* "View.MemoryView":368
16444  *             self.dtype_is_object = dtype_is_object
16445  *
16446  *         self.acquisition_count_aligned_p = <__pyx_atomic_int *> align_pointer(             # <<<<<<<<<<<<<<
16447  *                   <void *> &self.acquisition_count[0], sizeof(__pyx_atomic_int))
16448  *         self.typeinfo = NULL
16449  */
16450   __pyx_v_self->acquisition_count_aligned_p = ((__pyx_atomic_int *)__pyx_align_pointer(((void *)(&(__pyx_v_self->acquisition_count[0]))), (sizeof(__pyx_atomic_int))));
16451 
16452   /* "View.MemoryView":370
16453  *         self.acquisition_count_aligned_p = <__pyx_atomic_int *> align_pointer(
16454  *                   <void *> &self.acquisition_count[0], sizeof(__pyx_atomic_int))
16455  *         self.typeinfo = NULL             # <<<<<<<<<<<<<<
16456  *
16457  *     def __dealloc__(memoryview self):
16458  */
16459   __pyx_v_self->typeinfo = NULL;
16460 
16461   /* "View.MemoryView":345
16462  *     cdef __Pyx_TypeInfo *typeinfo
16463  *
16464  *     def __cinit__(memoryview self, object obj, int flags, bint dtype_is_object=False):             # <<<<<<<<<<<<<<
16465  *         self.obj = obj
16466  *         self.flags = flags
16467  */
16468 
16469   /* function exit code */
16470   __pyx_r = 0;
16471   goto __pyx_L0;
16472   __pyx_L1_error:;
16473   __Pyx_AddTraceback("View.MemoryView.memoryview.__cinit__", __pyx_clineno, __pyx_lineno, __pyx_filename);
16474   __pyx_r = -1;
16475   __pyx_L0:;
16476   __Pyx_RefNannyFinishContext();
16477   return __pyx_r;
16478 }
16479 
16480 /* "View.MemoryView":372
16481  *         self.typeinfo = NULL
16482  *
16483  *     def __dealloc__(memoryview self):             # <<<<<<<<<<<<<<
16484  *         if self.obj is not None:
16485  *             __Pyx_ReleaseBuffer(&self.view)
16486  */
16487 
16488 /* Python wrapper */
16489 static void __pyx_memoryview___dealloc__(PyObject *__pyx_v_self); /*proto*/
__pyx_memoryview___dealloc__(PyObject * __pyx_v_self)16490 static void __pyx_memoryview___dealloc__(PyObject *__pyx_v_self) {
16491   __Pyx_RefNannyDeclarations
16492   __Pyx_RefNannySetupContext("__dealloc__ (wrapper)", 0);
16493   __pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_2__dealloc__(((struct __pyx_memoryview_obj *)__pyx_v_self));
16494 
16495   /* function exit code */
16496   __Pyx_RefNannyFinishContext();
16497 }
16498 
__pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_2__dealloc__(struct __pyx_memoryview_obj * __pyx_v_self)16499 static void __pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_2__dealloc__(struct __pyx_memoryview_obj *__pyx_v_self) {
16500   int __pyx_v_i;
16501   __Pyx_RefNannyDeclarations
16502   int __pyx_t_1;
16503   int __pyx_t_2;
16504   int __pyx_t_3;
16505   int __pyx_t_4;
16506   int __pyx_t_5;
16507   PyThread_type_lock __pyx_t_6;
16508   PyThread_type_lock __pyx_t_7;
16509   __Pyx_RefNannySetupContext("__dealloc__", 0);
16510 
16511   /* "View.MemoryView":373
16512  *
16513  *     def __dealloc__(memoryview self):
16514  *         if self.obj is not None:             # <<<<<<<<<<<<<<
16515  *             __Pyx_ReleaseBuffer(&self.view)
16516  *         elif (<__pyx_buffer *> &self.view).obj == Py_None:
16517  */
16518   __pyx_t_1 = (__pyx_v_self->obj != Py_None);
16519   __pyx_t_2 = (__pyx_t_1 != 0);
16520   if (__pyx_t_2) {
16521 
16522     /* "View.MemoryView":374
16523  *     def __dealloc__(memoryview self):
16524  *         if self.obj is not None:
16525  *             __Pyx_ReleaseBuffer(&self.view)             # <<<<<<<<<<<<<<
16526  *         elif (<__pyx_buffer *> &self.view).obj == Py_None:
16527  *
16528  */
16529     __Pyx_ReleaseBuffer((&__pyx_v_self->view));
16530 
16531     /* "View.MemoryView":373
16532  *
16533  *     def __dealloc__(memoryview self):
16534  *         if self.obj is not None:             # <<<<<<<<<<<<<<
16535  *             __Pyx_ReleaseBuffer(&self.view)
16536  *         elif (<__pyx_buffer *> &self.view).obj == Py_None:
16537  */
16538     goto __pyx_L3;
16539   }
16540 
16541   /* "View.MemoryView":375
16542  *         if self.obj is not None:
16543  *             __Pyx_ReleaseBuffer(&self.view)
16544  *         elif (<__pyx_buffer *> &self.view).obj == Py_None:             # <<<<<<<<<<<<<<
16545  *
16546  *             (<__pyx_buffer *> &self.view).obj = NULL
16547  */
16548   __pyx_t_2 = ((((Py_buffer *)(&__pyx_v_self->view))->obj == Py_None) != 0);
16549   if (__pyx_t_2) {
16550 
16551     /* "View.MemoryView":377
16552  *         elif (<__pyx_buffer *> &self.view).obj == Py_None:
16553  *
16554  *             (<__pyx_buffer *> &self.view).obj = NULL             # <<<<<<<<<<<<<<
16555  *             Py_DECREF(Py_None)
16556  *
16557  */
16558     ((Py_buffer *)(&__pyx_v_self->view))->obj = NULL;
16559 
16560     /* "View.MemoryView":378
16561  *
16562  *             (<__pyx_buffer *> &self.view).obj = NULL
16563  *             Py_DECREF(Py_None)             # <<<<<<<<<<<<<<
16564  *
16565  *         cdef int i
16566  */
16567     Py_DECREF(Py_None);
16568 
16569     /* "View.MemoryView":375
16570  *         if self.obj is not None:
16571  *             __Pyx_ReleaseBuffer(&self.view)
16572  *         elif (<__pyx_buffer *> &self.view).obj == Py_None:             # <<<<<<<<<<<<<<
16573  *
16574  *             (<__pyx_buffer *> &self.view).obj = NULL
16575  */
16576   }
16577   __pyx_L3:;
16578 
16579   /* "View.MemoryView":382
16580  *         cdef int i
16581  *         global __pyx_memoryview_thread_locks_used
16582  *         if self.lock != NULL:             # <<<<<<<<<<<<<<
16583  *             for i in range(__pyx_memoryview_thread_locks_used):
16584  *                 if __pyx_memoryview_thread_locks[i] is self.lock:
16585  */
16586   __pyx_t_2 = ((__pyx_v_self->lock != NULL) != 0);
16587   if (__pyx_t_2) {
16588 
16589     /* "View.MemoryView":383
16590  *         global __pyx_memoryview_thread_locks_used
16591  *         if self.lock != NULL:
16592  *             for i in range(__pyx_memoryview_thread_locks_used):             # <<<<<<<<<<<<<<
16593  *                 if __pyx_memoryview_thread_locks[i] is self.lock:
16594  *                     __pyx_memoryview_thread_locks_used -= 1
16595  */
16596     __pyx_t_3 = __pyx_memoryview_thread_locks_used;
16597     __pyx_t_4 = __pyx_t_3;
16598     for (__pyx_t_5 = 0; __pyx_t_5 < __pyx_t_4; __pyx_t_5+=1) {
16599       __pyx_v_i = __pyx_t_5;
16600 
16601       /* "View.MemoryView":384
16602  *         if self.lock != NULL:
16603  *             for i in range(__pyx_memoryview_thread_locks_used):
16604  *                 if __pyx_memoryview_thread_locks[i] is self.lock:             # <<<<<<<<<<<<<<
16605  *                     __pyx_memoryview_thread_locks_used -= 1
16606  *                     if i != __pyx_memoryview_thread_locks_used:
16607  */
16608       __pyx_t_2 = (((__pyx_memoryview_thread_locks[__pyx_v_i]) == __pyx_v_self->lock) != 0);
16609       if (__pyx_t_2) {
16610 
16611         /* "View.MemoryView":385
16612  *             for i in range(__pyx_memoryview_thread_locks_used):
16613  *                 if __pyx_memoryview_thread_locks[i] is self.lock:
16614  *                     __pyx_memoryview_thread_locks_used -= 1             # <<<<<<<<<<<<<<
16615  *                     if i != __pyx_memoryview_thread_locks_used:
16616  *                         __pyx_memoryview_thread_locks[i], __pyx_memoryview_thread_locks[__pyx_memoryview_thread_locks_used] = (
16617  */
16618         __pyx_memoryview_thread_locks_used = (__pyx_memoryview_thread_locks_used - 1);
16619 
16620         /* "View.MemoryView":386
16621  *                 if __pyx_memoryview_thread_locks[i] is self.lock:
16622  *                     __pyx_memoryview_thread_locks_used -= 1
16623  *                     if i != __pyx_memoryview_thread_locks_used:             # <<<<<<<<<<<<<<
16624  *                         __pyx_memoryview_thread_locks[i], __pyx_memoryview_thread_locks[__pyx_memoryview_thread_locks_used] = (
16625  *                             __pyx_memoryview_thread_locks[__pyx_memoryview_thread_locks_used], __pyx_memoryview_thread_locks[i])
16626  */
16627         __pyx_t_2 = ((__pyx_v_i != __pyx_memoryview_thread_locks_used) != 0);
16628         if (__pyx_t_2) {
16629 
16630           /* "View.MemoryView":388
16631  *                     if i != __pyx_memoryview_thread_locks_used:
16632  *                         __pyx_memoryview_thread_locks[i], __pyx_memoryview_thread_locks[__pyx_memoryview_thread_locks_used] = (
16633  *                             __pyx_memoryview_thread_locks[__pyx_memoryview_thread_locks_used], __pyx_memoryview_thread_locks[i])             # <<<<<<<<<<<<<<
16634  *                     break
16635  *             else:
16636  */
16637           __pyx_t_6 = (__pyx_memoryview_thread_locks[__pyx_memoryview_thread_locks_used]);
16638           __pyx_t_7 = (__pyx_memoryview_thread_locks[__pyx_v_i]);
16639 
16640           /* "View.MemoryView":387
16641  *                     __pyx_memoryview_thread_locks_used -= 1
16642  *                     if i != __pyx_memoryview_thread_locks_used:
16643  *                         __pyx_memoryview_thread_locks[i], __pyx_memoryview_thread_locks[__pyx_memoryview_thread_locks_used] = (             # <<<<<<<<<<<<<<
16644  *                             __pyx_memoryview_thread_locks[__pyx_memoryview_thread_locks_used], __pyx_memoryview_thread_locks[i])
16645  *                     break
16646  */
16647           (__pyx_memoryview_thread_locks[__pyx_v_i]) = __pyx_t_6;
16648           (__pyx_memoryview_thread_locks[__pyx_memoryview_thread_locks_used]) = __pyx_t_7;
16649 
16650           /* "View.MemoryView":386
16651  *                 if __pyx_memoryview_thread_locks[i] is self.lock:
16652  *                     __pyx_memoryview_thread_locks_used -= 1
16653  *                     if i != __pyx_memoryview_thread_locks_used:             # <<<<<<<<<<<<<<
16654  *                         __pyx_memoryview_thread_locks[i], __pyx_memoryview_thread_locks[__pyx_memoryview_thread_locks_used] = (
16655  *                             __pyx_memoryview_thread_locks[__pyx_memoryview_thread_locks_used], __pyx_memoryview_thread_locks[i])
16656  */
16657         }
16658 
16659         /* "View.MemoryView":389
16660  *                         __pyx_memoryview_thread_locks[i], __pyx_memoryview_thread_locks[__pyx_memoryview_thread_locks_used] = (
16661  *                             __pyx_memoryview_thread_locks[__pyx_memoryview_thread_locks_used], __pyx_memoryview_thread_locks[i])
16662  *                     break             # <<<<<<<<<<<<<<
16663  *             else:
16664  *                 PyThread_free_lock(self.lock)
16665  */
16666         goto __pyx_L6_break;
16667 
16668         /* "View.MemoryView":384
16669  *         if self.lock != NULL:
16670  *             for i in range(__pyx_memoryview_thread_locks_used):
16671  *                 if __pyx_memoryview_thread_locks[i] is self.lock:             # <<<<<<<<<<<<<<
16672  *                     __pyx_memoryview_thread_locks_used -= 1
16673  *                     if i != __pyx_memoryview_thread_locks_used:
16674  */
16675       }
16676     }
16677     /*else*/ {
16678 
16679       /* "View.MemoryView":391
16680  *                     break
16681  *             else:
16682  *                 PyThread_free_lock(self.lock)             # <<<<<<<<<<<<<<
16683  *
16684  *     cdef char *get_item_pointer(memoryview self, object index) except NULL:
16685  */
16686       PyThread_free_lock(__pyx_v_self->lock);
16687     }
16688     __pyx_L6_break:;
16689 
16690     /* "View.MemoryView":382
16691  *         cdef int i
16692  *         global __pyx_memoryview_thread_locks_used
16693  *         if self.lock != NULL:             # <<<<<<<<<<<<<<
16694  *             for i in range(__pyx_memoryview_thread_locks_used):
16695  *                 if __pyx_memoryview_thread_locks[i] is self.lock:
16696  */
16697   }
16698 
16699   /* "View.MemoryView":372
16700  *         self.typeinfo = NULL
16701  *
16702  *     def __dealloc__(memoryview self):             # <<<<<<<<<<<<<<
16703  *         if self.obj is not None:
16704  *             __Pyx_ReleaseBuffer(&self.view)
16705  */
16706 
16707   /* function exit code */
16708   __Pyx_RefNannyFinishContext();
16709 }
16710 
16711 /* "View.MemoryView":393
16712  *                 PyThread_free_lock(self.lock)
16713  *
16714  *     cdef char *get_item_pointer(memoryview self, object index) except NULL:             # <<<<<<<<<<<<<<
16715  *         cdef Py_ssize_t dim
16716  *         cdef char *itemp = <char *> self.view.buf
16717  */
16718 
__pyx_memoryview_get_item_pointer(struct __pyx_memoryview_obj * __pyx_v_self,PyObject * __pyx_v_index)16719 static char *__pyx_memoryview_get_item_pointer(struct __pyx_memoryview_obj *__pyx_v_self, PyObject *__pyx_v_index) {
16720   Py_ssize_t __pyx_v_dim;
16721   char *__pyx_v_itemp;
16722   PyObject *__pyx_v_idx = NULL;
16723   char *__pyx_r;
16724   __Pyx_RefNannyDeclarations
16725   Py_ssize_t __pyx_t_1;
16726   PyObject *__pyx_t_2 = NULL;
16727   Py_ssize_t __pyx_t_3;
16728   PyObject *(*__pyx_t_4)(PyObject *);
16729   PyObject *__pyx_t_5 = NULL;
16730   Py_ssize_t __pyx_t_6;
16731   char *__pyx_t_7;
16732   int __pyx_lineno = 0;
16733   const char *__pyx_filename = NULL;
16734   int __pyx_clineno = 0;
16735   __Pyx_RefNannySetupContext("get_item_pointer", 0);
16736 
16737   /* "View.MemoryView":395
16738  *     cdef char *get_item_pointer(memoryview self, object index) except NULL:
16739  *         cdef Py_ssize_t dim
16740  *         cdef char *itemp = <char *> self.view.buf             # <<<<<<<<<<<<<<
16741  *
16742  *         for dim, idx in enumerate(index):
16743  */
16744   __pyx_v_itemp = ((char *)__pyx_v_self->view.buf);
16745 
16746   /* "View.MemoryView":397
16747  *         cdef char *itemp = <char *> self.view.buf
16748  *
16749  *         for dim, idx in enumerate(index):             # <<<<<<<<<<<<<<
16750  *             itemp = pybuffer_index(&self.view, itemp, idx, dim)
16751  *
16752  */
16753   __pyx_t_1 = 0;
16754   if (likely(PyList_CheckExact(__pyx_v_index)) || PyTuple_CheckExact(__pyx_v_index)) {
16755     __pyx_t_2 = __pyx_v_index; __Pyx_INCREF(__pyx_t_2); __pyx_t_3 = 0;
16756     __pyx_t_4 = NULL;
16757   } else {
16758     __pyx_t_3 = -1; __pyx_t_2 = PyObject_GetIter(__pyx_v_index); if (unlikely(!__pyx_t_2)) __PYX_ERR(3, 397, __pyx_L1_error)
16759     __Pyx_GOTREF(__pyx_t_2);
16760     __pyx_t_4 = Py_TYPE(__pyx_t_2)->tp_iternext; if (unlikely(!__pyx_t_4)) __PYX_ERR(3, 397, __pyx_L1_error)
16761   }
16762   for (;;) {
16763     if (likely(!__pyx_t_4)) {
16764       if (likely(PyList_CheckExact(__pyx_t_2))) {
16765         if (__pyx_t_3 >= PyList_GET_SIZE(__pyx_t_2)) break;
16766         #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
16767         __pyx_t_5 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_3); __Pyx_INCREF(__pyx_t_5); __pyx_t_3++; if (unlikely(0 < 0)) __PYX_ERR(3, 397, __pyx_L1_error)
16768         #else
16769         __pyx_t_5 = PySequence_ITEM(__pyx_t_2, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_5)) __PYX_ERR(3, 397, __pyx_L1_error)
16770         __Pyx_GOTREF(__pyx_t_5);
16771         #endif
16772       } else {
16773         if (__pyx_t_3 >= PyTuple_GET_SIZE(__pyx_t_2)) break;
16774         #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
16775         __pyx_t_5 = PyTuple_GET_ITEM(__pyx_t_2, __pyx_t_3); __Pyx_INCREF(__pyx_t_5); __pyx_t_3++; if (unlikely(0 < 0)) __PYX_ERR(3, 397, __pyx_L1_error)
16776         #else
16777         __pyx_t_5 = PySequence_ITEM(__pyx_t_2, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_5)) __PYX_ERR(3, 397, __pyx_L1_error)
16778         __Pyx_GOTREF(__pyx_t_5);
16779         #endif
16780       }
16781     } else {
16782       __pyx_t_5 = __pyx_t_4(__pyx_t_2);
16783       if (unlikely(!__pyx_t_5)) {
16784         PyObject* exc_type = PyErr_Occurred();
16785         if (exc_type) {
16786           if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
16787           else __PYX_ERR(3, 397, __pyx_L1_error)
16788         }
16789         break;
16790       }
16791       __Pyx_GOTREF(__pyx_t_5);
16792     }
16793     __Pyx_XDECREF_SET(__pyx_v_idx, __pyx_t_5);
16794     __pyx_t_5 = 0;
16795     __pyx_v_dim = __pyx_t_1;
16796     __pyx_t_1 = (__pyx_t_1 + 1);
16797 
16798     /* "View.MemoryView":398
16799  *
16800  *         for dim, idx in enumerate(index):
16801  *             itemp = pybuffer_index(&self.view, itemp, idx, dim)             # <<<<<<<<<<<<<<
16802  *
16803  *         return itemp
16804  */
16805     __pyx_t_6 = __Pyx_PyIndex_AsSsize_t(__pyx_v_idx); if (unlikely((__pyx_t_6 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(3, 398, __pyx_L1_error)
16806     __pyx_t_7 = __pyx_pybuffer_index((&__pyx_v_self->view), __pyx_v_itemp, __pyx_t_6, __pyx_v_dim); if (unlikely(__pyx_t_7 == ((char *)NULL))) __PYX_ERR(3, 398, __pyx_L1_error)
16807     __pyx_v_itemp = __pyx_t_7;
16808 
16809     /* "View.MemoryView":397
16810  *         cdef char *itemp = <char *> self.view.buf
16811  *
16812  *         for dim, idx in enumerate(index):             # <<<<<<<<<<<<<<
16813  *             itemp = pybuffer_index(&self.view, itemp, idx, dim)
16814  *
16815  */
16816   }
16817   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
16818 
16819   /* "View.MemoryView":400
16820  *             itemp = pybuffer_index(&self.view, itemp, idx, dim)
16821  *
16822  *         return itemp             # <<<<<<<<<<<<<<
16823  *
16824  *
16825  */
16826   __pyx_r = __pyx_v_itemp;
16827   goto __pyx_L0;
16828 
16829   /* "View.MemoryView":393
16830  *                 PyThread_free_lock(self.lock)
16831  *
16832  *     cdef char *get_item_pointer(memoryview self, object index) except NULL:             # <<<<<<<<<<<<<<
16833  *         cdef Py_ssize_t dim
16834  *         cdef char *itemp = <char *> self.view.buf
16835  */
16836 
16837   /* function exit code */
16838   __pyx_L1_error:;
16839   __Pyx_XDECREF(__pyx_t_2);
16840   __Pyx_XDECREF(__pyx_t_5);
16841   __Pyx_AddTraceback("View.MemoryView.memoryview.get_item_pointer", __pyx_clineno, __pyx_lineno, __pyx_filename);
16842   __pyx_r = NULL;
16843   __pyx_L0:;
16844   __Pyx_XDECREF(__pyx_v_idx);
16845   __Pyx_RefNannyFinishContext();
16846   return __pyx_r;
16847 }
16848 
16849 /* "View.MemoryView":403
16850  *
16851  *
16852  *     def __getitem__(memoryview self, object index):             # <<<<<<<<<<<<<<
16853  *         if index is Ellipsis:
16854  *             return self
16855  */
16856 
16857 /* Python wrapper */
16858 static PyObject *__pyx_memoryview___getitem__(PyObject *__pyx_v_self, PyObject *__pyx_v_index); /*proto*/
__pyx_memoryview___getitem__(PyObject * __pyx_v_self,PyObject * __pyx_v_index)16859 static PyObject *__pyx_memoryview___getitem__(PyObject *__pyx_v_self, PyObject *__pyx_v_index) {
16860   PyObject *__pyx_r = 0;
16861   __Pyx_RefNannyDeclarations
16862   __Pyx_RefNannySetupContext("__getitem__ (wrapper)", 0);
16863   __pyx_r = __pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_4__getitem__(((struct __pyx_memoryview_obj *)__pyx_v_self), ((PyObject *)__pyx_v_index));
16864 
16865   /* function exit code */
16866   __Pyx_RefNannyFinishContext();
16867   return __pyx_r;
16868 }
16869 
__pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_4__getitem__(struct __pyx_memoryview_obj * __pyx_v_self,PyObject * __pyx_v_index)16870 static PyObject *__pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_4__getitem__(struct __pyx_memoryview_obj *__pyx_v_self, PyObject *__pyx_v_index) {
16871   PyObject *__pyx_v_have_slices = NULL;
16872   PyObject *__pyx_v_indices = NULL;
16873   char *__pyx_v_itemp;
16874   PyObject *__pyx_r = NULL;
16875   __Pyx_RefNannyDeclarations
16876   int __pyx_t_1;
16877   int __pyx_t_2;
16878   PyObject *__pyx_t_3 = NULL;
16879   PyObject *__pyx_t_4 = NULL;
16880   PyObject *__pyx_t_5 = NULL;
16881   char *__pyx_t_6;
16882   int __pyx_lineno = 0;
16883   const char *__pyx_filename = NULL;
16884   int __pyx_clineno = 0;
16885   __Pyx_RefNannySetupContext("__getitem__", 0);
16886 
16887   /* "View.MemoryView":404
16888  *
16889  *     def __getitem__(memoryview self, object index):
16890  *         if index is Ellipsis:             # <<<<<<<<<<<<<<
16891  *             return self
16892  *
16893  */
16894   __pyx_t_1 = (__pyx_v_index == __pyx_builtin_Ellipsis);
16895   __pyx_t_2 = (__pyx_t_1 != 0);
16896   if (__pyx_t_2) {
16897 
16898     /* "View.MemoryView":405
16899  *     def __getitem__(memoryview self, object index):
16900  *         if index is Ellipsis:
16901  *             return self             # <<<<<<<<<<<<<<
16902  *
16903  *         have_slices, indices = _unellipsify(index, self.view.ndim)
16904  */
16905     __Pyx_XDECREF(__pyx_r);
16906     __Pyx_INCREF(((PyObject *)__pyx_v_self));
16907     __pyx_r = ((PyObject *)__pyx_v_self);
16908     goto __pyx_L0;
16909 
16910     /* "View.MemoryView":404
16911  *
16912  *     def __getitem__(memoryview self, object index):
16913  *         if index is Ellipsis:             # <<<<<<<<<<<<<<
16914  *             return self
16915  *
16916  */
16917   }
16918 
16919   /* "View.MemoryView":407
16920  *             return self
16921  *
16922  *         have_slices, indices = _unellipsify(index, self.view.ndim)             # <<<<<<<<<<<<<<
16923  *
16924  *         cdef char *itemp
16925  */
16926   __pyx_t_3 = _unellipsify(__pyx_v_index, __pyx_v_self->view.ndim); if (unlikely(!__pyx_t_3)) __PYX_ERR(3, 407, __pyx_L1_error)
16927   __Pyx_GOTREF(__pyx_t_3);
16928   if (likely(__pyx_t_3 != Py_None)) {
16929     PyObject* sequence = __pyx_t_3;
16930     Py_ssize_t size = __Pyx_PySequence_SIZE(sequence);
16931     if (unlikely(size != 2)) {
16932       if (size > 2) __Pyx_RaiseTooManyValuesError(2);
16933       else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
16934       __PYX_ERR(3, 407, __pyx_L1_error)
16935     }
16936     #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
16937     __pyx_t_4 = PyTuple_GET_ITEM(sequence, 0);
16938     __pyx_t_5 = PyTuple_GET_ITEM(sequence, 1);
16939     __Pyx_INCREF(__pyx_t_4);
16940     __Pyx_INCREF(__pyx_t_5);
16941     #else
16942     __pyx_t_4 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(3, 407, __pyx_L1_error)
16943     __Pyx_GOTREF(__pyx_t_4);
16944     __pyx_t_5 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_5)) __PYX_ERR(3, 407, __pyx_L1_error)
16945     __Pyx_GOTREF(__pyx_t_5);
16946     #endif
16947     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
16948   } else {
16949     __Pyx_RaiseNoneNotIterableError(); __PYX_ERR(3, 407, __pyx_L1_error)
16950   }
16951   __pyx_v_have_slices = __pyx_t_4;
16952   __pyx_t_4 = 0;
16953   __pyx_v_indices = __pyx_t_5;
16954   __pyx_t_5 = 0;
16955 
16956   /* "View.MemoryView":410
16957  *
16958  *         cdef char *itemp
16959  *         if have_slices:             # <<<<<<<<<<<<<<
16960  *             return memview_slice(self, indices)
16961  *         else:
16962  */
16963   __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_v_have_slices); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(3, 410, __pyx_L1_error)
16964   if (__pyx_t_2) {
16965 
16966     /* "View.MemoryView":411
16967  *         cdef char *itemp
16968  *         if have_slices:
16969  *             return memview_slice(self, indices)             # <<<<<<<<<<<<<<
16970  *         else:
16971  *             itemp = self.get_item_pointer(indices)
16972  */
16973     __Pyx_XDECREF(__pyx_r);
16974     __pyx_t_3 = ((PyObject *)__pyx_memview_slice(__pyx_v_self, __pyx_v_indices)); if (unlikely(!__pyx_t_3)) __PYX_ERR(3, 411, __pyx_L1_error)
16975     __Pyx_GOTREF(__pyx_t_3);
16976     __pyx_r = __pyx_t_3;
16977     __pyx_t_3 = 0;
16978     goto __pyx_L0;
16979 
16980     /* "View.MemoryView":410
16981  *
16982  *         cdef char *itemp
16983  *         if have_slices:             # <<<<<<<<<<<<<<
16984  *             return memview_slice(self, indices)
16985  *         else:
16986  */
16987   }
16988 
16989   /* "View.MemoryView":413
16990  *             return memview_slice(self, indices)
16991  *         else:
16992  *             itemp = self.get_item_pointer(indices)             # <<<<<<<<<<<<<<
16993  *             return self.convert_item_to_object(itemp)
16994  *
16995  */
16996   /*else*/ {
16997     __pyx_t_6 = ((struct __pyx_vtabstruct_memoryview *)__pyx_v_self->__pyx_vtab)->get_item_pointer(__pyx_v_self, __pyx_v_indices); if (unlikely(__pyx_t_6 == ((char *)NULL))) __PYX_ERR(3, 413, __pyx_L1_error)
16998     __pyx_v_itemp = __pyx_t_6;
16999 
17000     /* "View.MemoryView":414
17001  *         else:
17002  *             itemp = self.get_item_pointer(indices)
17003  *             return self.convert_item_to_object(itemp)             # <<<<<<<<<<<<<<
17004  *
17005  *     def __setitem__(memoryview self, object index, object value):
17006  */
17007     __Pyx_XDECREF(__pyx_r);
17008     __pyx_t_3 = ((struct __pyx_vtabstruct_memoryview *)__pyx_v_self->__pyx_vtab)->convert_item_to_object(__pyx_v_self, __pyx_v_itemp); if (unlikely(!__pyx_t_3)) __PYX_ERR(3, 414, __pyx_L1_error)
17009     __Pyx_GOTREF(__pyx_t_3);
17010     __pyx_r = __pyx_t_3;
17011     __pyx_t_3 = 0;
17012     goto __pyx_L0;
17013   }
17014 
17015   /* "View.MemoryView":403
17016  *
17017  *
17018  *     def __getitem__(memoryview self, object index):             # <<<<<<<<<<<<<<
17019  *         if index is Ellipsis:
17020  *             return self
17021  */
17022 
17023   /* function exit code */
17024   __pyx_L1_error:;
17025   __Pyx_XDECREF(__pyx_t_3);
17026   __Pyx_XDECREF(__pyx_t_4);
17027   __Pyx_XDECREF(__pyx_t_5);
17028   __Pyx_AddTraceback("View.MemoryView.memoryview.__getitem__", __pyx_clineno, __pyx_lineno, __pyx_filename);
17029   __pyx_r = NULL;
17030   __pyx_L0:;
17031   __Pyx_XDECREF(__pyx_v_have_slices);
17032   __Pyx_XDECREF(__pyx_v_indices);
17033   __Pyx_XGIVEREF(__pyx_r);
17034   __Pyx_RefNannyFinishContext();
17035   return __pyx_r;
17036 }
17037 
17038 /* "View.MemoryView":416
17039  *             return self.convert_item_to_object(itemp)
17040  *
17041  *     def __setitem__(memoryview self, object index, object value):             # <<<<<<<<<<<<<<
17042  *         if self.view.readonly:
17043  *             raise TypeError("Cannot assign to read-only memoryview")
17044  */
17045 
17046 /* Python wrapper */
17047 static int __pyx_memoryview___setitem__(PyObject *__pyx_v_self, PyObject *__pyx_v_index, PyObject *__pyx_v_value); /*proto*/
__pyx_memoryview___setitem__(PyObject * __pyx_v_self,PyObject * __pyx_v_index,PyObject * __pyx_v_value)17048 static int __pyx_memoryview___setitem__(PyObject *__pyx_v_self, PyObject *__pyx_v_index, PyObject *__pyx_v_value) {
17049   int __pyx_r;
17050   __Pyx_RefNannyDeclarations
17051   __Pyx_RefNannySetupContext("__setitem__ (wrapper)", 0);
17052   __pyx_r = __pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_6__setitem__(((struct __pyx_memoryview_obj *)__pyx_v_self), ((PyObject *)__pyx_v_index), ((PyObject *)__pyx_v_value));
17053 
17054   /* function exit code */
17055   __Pyx_RefNannyFinishContext();
17056   return __pyx_r;
17057 }
17058 
__pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_6__setitem__(struct __pyx_memoryview_obj * __pyx_v_self,PyObject * __pyx_v_index,PyObject * __pyx_v_value)17059 static int __pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_6__setitem__(struct __pyx_memoryview_obj *__pyx_v_self, PyObject *__pyx_v_index, PyObject *__pyx_v_value) {
17060   PyObject *__pyx_v_have_slices = NULL;
17061   PyObject *__pyx_v_obj = NULL;
17062   int __pyx_r;
17063   __Pyx_RefNannyDeclarations
17064   int __pyx_t_1;
17065   PyObject *__pyx_t_2 = NULL;
17066   PyObject *__pyx_t_3 = NULL;
17067   PyObject *__pyx_t_4 = NULL;
17068   int __pyx_lineno = 0;
17069   const char *__pyx_filename = NULL;
17070   int __pyx_clineno = 0;
17071   __Pyx_RefNannySetupContext("__setitem__", 0);
17072   __Pyx_INCREF(__pyx_v_index);
17073 
17074   /* "View.MemoryView":417
17075  *
17076  *     def __setitem__(memoryview self, object index, object value):
17077  *         if self.view.readonly:             # <<<<<<<<<<<<<<
17078  *             raise TypeError("Cannot assign to read-only memoryview")
17079  *
17080  */
17081   __pyx_t_1 = (__pyx_v_self->view.readonly != 0);
17082   if (unlikely(__pyx_t_1)) {
17083 
17084     /* "View.MemoryView":418
17085  *     def __setitem__(memoryview self, object index, object value):
17086  *         if self.view.readonly:
17087  *             raise TypeError("Cannot assign to read-only memoryview")             # <<<<<<<<<<<<<<
17088  *
17089  *         have_slices, index = _unellipsify(index, self.view.ndim)
17090  */
17091     __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__28, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(3, 418, __pyx_L1_error)
17092     __Pyx_GOTREF(__pyx_t_2);
17093     __Pyx_Raise(__pyx_t_2, 0, 0, 0);
17094     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
17095     __PYX_ERR(3, 418, __pyx_L1_error)
17096 
17097     /* "View.MemoryView":417
17098  *
17099  *     def __setitem__(memoryview self, object index, object value):
17100  *         if self.view.readonly:             # <<<<<<<<<<<<<<
17101  *             raise TypeError("Cannot assign to read-only memoryview")
17102  *
17103  */
17104   }
17105 
17106   /* "View.MemoryView":420
17107  *             raise TypeError("Cannot assign to read-only memoryview")
17108  *
17109  *         have_slices, index = _unellipsify(index, self.view.ndim)             # <<<<<<<<<<<<<<
17110  *
17111  *         if have_slices:
17112  */
17113   __pyx_t_2 = _unellipsify(__pyx_v_index, __pyx_v_self->view.ndim); if (unlikely(!__pyx_t_2)) __PYX_ERR(3, 420, __pyx_L1_error)
17114   __Pyx_GOTREF(__pyx_t_2);
17115   if (likely(__pyx_t_2 != Py_None)) {
17116     PyObject* sequence = __pyx_t_2;
17117     Py_ssize_t size = __Pyx_PySequence_SIZE(sequence);
17118     if (unlikely(size != 2)) {
17119       if (size > 2) __Pyx_RaiseTooManyValuesError(2);
17120       else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
17121       __PYX_ERR(3, 420, __pyx_L1_error)
17122     }
17123     #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
17124     __pyx_t_3 = PyTuple_GET_ITEM(sequence, 0);
17125     __pyx_t_4 = PyTuple_GET_ITEM(sequence, 1);
17126     __Pyx_INCREF(__pyx_t_3);
17127     __Pyx_INCREF(__pyx_t_4);
17128     #else
17129     __pyx_t_3 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(3, 420, __pyx_L1_error)
17130     __Pyx_GOTREF(__pyx_t_3);
17131     __pyx_t_4 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_4)) __PYX_ERR(3, 420, __pyx_L1_error)
17132     __Pyx_GOTREF(__pyx_t_4);
17133     #endif
17134     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
17135   } else {
17136     __Pyx_RaiseNoneNotIterableError(); __PYX_ERR(3, 420, __pyx_L1_error)
17137   }
17138   __pyx_v_have_slices = __pyx_t_3;
17139   __pyx_t_3 = 0;
17140   __Pyx_DECREF_SET(__pyx_v_index, __pyx_t_4);
17141   __pyx_t_4 = 0;
17142 
17143   /* "View.MemoryView":422
17144  *         have_slices, index = _unellipsify(index, self.view.ndim)
17145  *
17146  *         if have_slices:             # <<<<<<<<<<<<<<
17147  *             obj = self.is_slice(value)
17148  *             if obj:
17149  */
17150   __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_have_slices); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(3, 422, __pyx_L1_error)
17151   if (__pyx_t_1) {
17152 
17153     /* "View.MemoryView":423
17154  *
17155  *         if have_slices:
17156  *             obj = self.is_slice(value)             # <<<<<<<<<<<<<<
17157  *             if obj:
17158  *                 self.setitem_slice_assignment(self[index], obj)
17159  */
17160     __pyx_t_2 = ((struct __pyx_vtabstruct_memoryview *)__pyx_v_self->__pyx_vtab)->is_slice(__pyx_v_self, __pyx_v_value); if (unlikely(!__pyx_t_2)) __PYX_ERR(3, 423, __pyx_L1_error)
17161     __Pyx_GOTREF(__pyx_t_2);
17162     __pyx_v_obj = __pyx_t_2;
17163     __pyx_t_2 = 0;
17164 
17165     /* "View.MemoryView":424
17166  *         if have_slices:
17167  *             obj = self.is_slice(value)
17168  *             if obj:             # <<<<<<<<<<<<<<
17169  *                 self.setitem_slice_assignment(self[index], obj)
17170  *             else:
17171  */
17172     __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_obj); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(3, 424, __pyx_L1_error)
17173     if (__pyx_t_1) {
17174 
17175       /* "View.MemoryView":425
17176  *             obj = self.is_slice(value)
17177  *             if obj:
17178  *                 self.setitem_slice_assignment(self[index], obj)             # <<<<<<<<<<<<<<
17179  *             else:
17180  *                 self.setitem_slice_assign_scalar(self[index], value)
17181  */
17182       __pyx_t_2 = __Pyx_PyObject_GetItem(((PyObject *)__pyx_v_self), __pyx_v_index); if (unlikely(!__pyx_t_2)) __PYX_ERR(3, 425, __pyx_L1_error)
17183       __Pyx_GOTREF(__pyx_t_2);
17184       __pyx_t_4 = ((struct __pyx_vtabstruct_memoryview *)__pyx_v_self->__pyx_vtab)->setitem_slice_assignment(__pyx_v_self, __pyx_t_2, __pyx_v_obj); if (unlikely(!__pyx_t_4)) __PYX_ERR(3, 425, __pyx_L1_error)
17185       __Pyx_GOTREF(__pyx_t_4);
17186       __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
17187       __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
17188 
17189       /* "View.MemoryView":424
17190  *         if have_slices:
17191  *             obj = self.is_slice(value)
17192  *             if obj:             # <<<<<<<<<<<<<<
17193  *                 self.setitem_slice_assignment(self[index], obj)
17194  *             else:
17195  */
17196       goto __pyx_L5;
17197     }
17198 
17199     /* "View.MemoryView":427
17200  *                 self.setitem_slice_assignment(self[index], obj)
17201  *             else:
17202  *                 self.setitem_slice_assign_scalar(self[index], value)             # <<<<<<<<<<<<<<
17203  *         else:
17204  *             self.setitem_indexed(index, value)
17205  */
17206     /*else*/ {
17207       __pyx_t_4 = __Pyx_PyObject_GetItem(((PyObject *)__pyx_v_self), __pyx_v_index); if (unlikely(!__pyx_t_4)) __PYX_ERR(3, 427, __pyx_L1_error)
17208       __Pyx_GOTREF(__pyx_t_4);
17209       if (!(likely(((__pyx_t_4) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_4, __pyx_memoryview_type))))) __PYX_ERR(3, 427, __pyx_L1_error)
17210       __pyx_t_2 = ((struct __pyx_vtabstruct_memoryview *)__pyx_v_self->__pyx_vtab)->setitem_slice_assign_scalar(__pyx_v_self, ((struct __pyx_memoryview_obj *)__pyx_t_4), __pyx_v_value); if (unlikely(!__pyx_t_2)) __PYX_ERR(3, 427, __pyx_L1_error)
17211       __Pyx_GOTREF(__pyx_t_2);
17212       __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
17213       __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
17214     }
17215     __pyx_L5:;
17216 
17217     /* "View.MemoryView":422
17218  *         have_slices, index = _unellipsify(index, self.view.ndim)
17219  *
17220  *         if have_slices:             # <<<<<<<<<<<<<<
17221  *             obj = self.is_slice(value)
17222  *             if obj:
17223  */
17224     goto __pyx_L4;
17225   }
17226 
17227   /* "View.MemoryView":429
17228  *                 self.setitem_slice_assign_scalar(self[index], value)
17229  *         else:
17230  *             self.setitem_indexed(index, value)             # <<<<<<<<<<<<<<
17231  *
17232  *     cdef is_slice(self, obj):
17233  */
17234   /*else*/ {
17235     __pyx_t_2 = ((struct __pyx_vtabstruct_memoryview *)__pyx_v_self->__pyx_vtab)->setitem_indexed(__pyx_v_self, __pyx_v_index, __pyx_v_value); if (unlikely(!__pyx_t_2)) __PYX_ERR(3, 429, __pyx_L1_error)
17236     __Pyx_GOTREF(__pyx_t_2);
17237     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
17238   }
17239   __pyx_L4:;
17240 
17241   /* "View.MemoryView":416
17242  *             return self.convert_item_to_object(itemp)
17243  *
17244  *     def __setitem__(memoryview self, object index, object value):             # <<<<<<<<<<<<<<
17245  *         if self.view.readonly:
17246  *             raise TypeError("Cannot assign to read-only memoryview")
17247  */
17248 
17249   /* function exit code */
17250   __pyx_r = 0;
17251   goto __pyx_L0;
17252   __pyx_L1_error:;
17253   __Pyx_XDECREF(__pyx_t_2);
17254   __Pyx_XDECREF(__pyx_t_3);
17255   __Pyx_XDECREF(__pyx_t_4);
17256   __Pyx_AddTraceback("View.MemoryView.memoryview.__setitem__", __pyx_clineno, __pyx_lineno, __pyx_filename);
17257   __pyx_r = -1;
17258   __pyx_L0:;
17259   __Pyx_XDECREF(__pyx_v_have_slices);
17260   __Pyx_XDECREF(__pyx_v_obj);
17261   __Pyx_XDECREF(__pyx_v_index);
17262   __Pyx_RefNannyFinishContext();
17263   return __pyx_r;
17264 }
17265 
17266 /* "View.MemoryView":431
17267  *             self.setitem_indexed(index, value)
17268  *
17269  *     cdef is_slice(self, obj):             # <<<<<<<<<<<<<<
17270  *         if not isinstance(obj, memoryview):
17271  *             try:
17272  */
17273 
__pyx_memoryview_is_slice(struct __pyx_memoryview_obj * __pyx_v_self,PyObject * __pyx_v_obj)17274 static PyObject *__pyx_memoryview_is_slice(struct __pyx_memoryview_obj *__pyx_v_self, PyObject *__pyx_v_obj) {
17275   PyObject *__pyx_r = NULL;
17276   __Pyx_RefNannyDeclarations
17277   int __pyx_t_1;
17278   int __pyx_t_2;
17279   PyObject *__pyx_t_3 = NULL;
17280   PyObject *__pyx_t_4 = NULL;
17281   PyObject *__pyx_t_5 = NULL;
17282   PyObject *__pyx_t_6 = NULL;
17283   PyObject *__pyx_t_7 = NULL;
17284   PyObject *__pyx_t_8 = NULL;
17285   int __pyx_t_9;
17286   int __pyx_lineno = 0;
17287   const char *__pyx_filename = NULL;
17288   int __pyx_clineno = 0;
17289   __Pyx_RefNannySetupContext("is_slice", 0);
17290   __Pyx_INCREF(__pyx_v_obj);
17291 
17292   /* "View.MemoryView":432
17293  *
17294  *     cdef is_slice(self, obj):
17295  *         if not isinstance(obj, memoryview):             # <<<<<<<<<<<<<<
17296  *             try:
17297  *                 obj = memoryview(obj, self.flags & ~PyBUF_WRITABLE | PyBUF_ANY_CONTIGUOUS,
17298  */
17299   __pyx_t_1 = __Pyx_TypeCheck(__pyx_v_obj, __pyx_memoryview_type);
17300   __pyx_t_2 = ((!(__pyx_t_1 != 0)) != 0);
17301   if (__pyx_t_2) {
17302 
17303     /* "View.MemoryView":433
17304  *     cdef is_slice(self, obj):
17305  *         if not isinstance(obj, memoryview):
17306  *             try:             # <<<<<<<<<<<<<<
17307  *                 obj = memoryview(obj, self.flags & ~PyBUF_WRITABLE | PyBUF_ANY_CONTIGUOUS,
17308  *                                  self.dtype_is_object)
17309  */
17310     {
17311       __Pyx_PyThreadState_declare
17312       __Pyx_PyThreadState_assign
17313       __Pyx_ExceptionSave(&__pyx_t_3, &__pyx_t_4, &__pyx_t_5);
17314       __Pyx_XGOTREF(__pyx_t_3);
17315       __Pyx_XGOTREF(__pyx_t_4);
17316       __Pyx_XGOTREF(__pyx_t_5);
17317       /*try:*/ {
17318 
17319         /* "View.MemoryView":434
17320  *         if not isinstance(obj, memoryview):
17321  *             try:
17322  *                 obj = memoryview(obj, self.flags & ~PyBUF_WRITABLE | PyBUF_ANY_CONTIGUOUS,             # <<<<<<<<<<<<<<
17323  *                                  self.dtype_is_object)
17324  *             except TypeError:
17325  */
17326         __pyx_t_6 = __Pyx_PyInt_From_int(((__pyx_v_self->flags & (~PyBUF_WRITABLE)) | PyBUF_ANY_CONTIGUOUS)); if (unlikely(!__pyx_t_6)) __PYX_ERR(3, 434, __pyx_L4_error)
17327         __Pyx_GOTREF(__pyx_t_6);
17328 
17329         /* "View.MemoryView":435
17330  *             try:
17331  *                 obj = memoryview(obj, self.flags & ~PyBUF_WRITABLE | PyBUF_ANY_CONTIGUOUS,
17332  *                                  self.dtype_is_object)             # <<<<<<<<<<<<<<
17333  *             except TypeError:
17334  *                 return None
17335  */
17336         __pyx_t_7 = __Pyx_PyBool_FromLong(__pyx_v_self->dtype_is_object); if (unlikely(!__pyx_t_7)) __PYX_ERR(3, 435, __pyx_L4_error)
17337         __Pyx_GOTREF(__pyx_t_7);
17338 
17339         /* "View.MemoryView":434
17340  *         if not isinstance(obj, memoryview):
17341  *             try:
17342  *                 obj = memoryview(obj, self.flags & ~PyBUF_WRITABLE | PyBUF_ANY_CONTIGUOUS,             # <<<<<<<<<<<<<<
17343  *                                  self.dtype_is_object)
17344  *             except TypeError:
17345  */
17346         __pyx_t_8 = PyTuple_New(3); if (unlikely(!__pyx_t_8)) __PYX_ERR(3, 434, __pyx_L4_error)
17347         __Pyx_GOTREF(__pyx_t_8);
17348         __Pyx_INCREF(__pyx_v_obj);
17349         __Pyx_GIVEREF(__pyx_v_obj);
17350         PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_v_obj);
17351         __Pyx_GIVEREF(__pyx_t_6);
17352         PyTuple_SET_ITEM(__pyx_t_8, 1, __pyx_t_6);
17353         __Pyx_GIVEREF(__pyx_t_7);
17354         PyTuple_SET_ITEM(__pyx_t_8, 2, __pyx_t_7);
17355         __pyx_t_6 = 0;
17356         __pyx_t_7 = 0;
17357         __pyx_t_7 = __Pyx_PyObject_Call(((PyObject *)__pyx_memoryview_type), __pyx_t_8, NULL); if (unlikely(!__pyx_t_7)) __PYX_ERR(3, 434, __pyx_L4_error)
17358         __Pyx_GOTREF(__pyx_t_7);
17359         __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
17360         __Pyx_DECREF_SET(__pyx_v_obj, __pyx_t_7);
17361         __pyx_t_7 = 0;
17362 
17363         /* "View.MemoryView":433
17364  *     cdef is_slice(self, obj):
17365  *         if not isinstance(obj, memoryview):
17366  *             try:             # <<<<<<<<<<<<<<
17367  *                 obj = memoryview(obj, self.flags & ~PyBUF_WRITABLE | PyBUF_ANY_CONTIGUOUS,
17368  *                                  self.dtype_is_object)
17369  */
17370       }
17371       __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
17372       __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
17373       __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
17374       goto __pyx_L9_try_end;
17375       __pyx_L4_error:;
17376       __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
17377       __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
17378       __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
17379 
17380       /* "View.MemoryView":436
17381  *                 obj = memoryview(obj, self.flags & ~PyBUF_WRITABLE | PyBUF_ANY_CONTIGUOUS,
17382  *                                  self.dtype_is_object)
17383  *             except TypeError:             # <<<<<<<<<<<<<<
17384  *                 return None
17385  *
17386  */
17387       __pyx_t_9 = __Pyx_PyErr_ExceptionMatches(__pyx_builtin_TypeError);
17388       if (__pyx_t_9) {
17389         __Pyx_AddTraceback("View.MemoryView.memoryview.is_slice", __pyx_clineno, __pyx_lineno, __pyx_filename);
17390         if (__Pyx_GetException(&__pyx_t_7, &__pyx_t_8, &__pyx_t_6) < 0) __PYX_ERR(3, 436, __pyx_L6_except_error)
17391         __Pyx_GOTREF(__pyx_t_7);
17392         __Pyx_GOTREF(__pyx_t_8);
17393         __Pyx_GOTREF(__pyx_t_6);
17394 
17395         /* "View.MemoryView":437
17396  *                                  self.dtype_is_object)
17397  *             except TypeError:
17398  *                 return None             # <<<<<<<<<<<<<<
17399  *
17400  *         return obj
17401  */
17402         __Pyx_XDECREF(__pyx_r);
17403         __pyx_r = Py_None; __Pyx_INCREF(Py_None);
17404         __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
17405         __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
17406         __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
17407         goto __pyx_L7_except_return;
17408       }
17409       goto __pyx_L6_except_error;
17410       __pyx_L6_except_error:;
17411 
17412       /* "View.MemoryView":433
17413  *     cdef is_slice(self, obj):
17414  *         if not isinstance(obj, memoryview):
17415  *             try:             # <<<<<<<<<<<<<<
17416  *                 obj = memoryview(obj, self.flags & ~PyBUF_WRITABLE | PyBUF_ANY_CONTIGUOUS,
17417  *                                  self.dtype_is_object)
17418  */
17419       __Pyx_XGIVEREF(__pyx_t_3);
17420       __Pyx_XGIVEREF(__pyx_t_4);
17421       __Pyx_XGIVEREF(__pyx_t_5);
17422       __Pyx_ExceptionReset(__pyx_t_3, __pyx_t_4, __pyx_t_5);
17423       goto __pyx_L1_error;
17424       __pyx_L7_except_return:;
17425       __Pyx_XGIVEREF(__pyx_t_3);
17426       __Pyx_XGIVEREF(__pyx_t_4);
17427       __Pyx_XGIVEREF(__pyx_t_5);
17428       __Pyx_ExceptionReset(__pyx_t_3, __pyx_t_4, __pyx_t_5);
17429       goto __pyx_L0;
17430       __pyx_L9_try_end:;
17431     }
17432 
17433     /* "View.MemoryView":432
17434  *
17435  *     cdef is_slice(self, obj):
17436  *         if not isinstance(obj, memoryview):             # <<<<<<<<<<<<<<
17437  *             try:
17438  *                 obj = memoryview(obj, self.flags & ~PyBUF_WRITABLE | PyBUF_ANY_CONTIGUOUS,
17439  */
17440   }
17441 
17442   /* "View.MemoryView":439
17443  *                 return None
17444  *
17445  *         return obj             # <<<<<<<<<<<<<<
17446  *
17447  *     cdef setitem_slice_assignment(self, dst, src):
17448  */
17449   __Pyx_XDECREF(__pyx_r);
17450   __Pyx_INCREF(__pyx_v_obj);
17451   __pyx_r = __pyx_v_obj;
17452   goto __pyx_L0;
17453 
17454   /* "View.MemoryView":431
17455  *             self.setitem_indexed(index, value)
17456  *
17457  *     cdef is_slice(self, obj):             # <<<<<<<<<<<<<<
17458  *         if not isinstance(obj, memoryview):
17459  *             try:
17460  */
17461 
17462   /* function exit code */
17463   __pyx_L1_error:;
17464   __Pyx_XDECREF(__pyx_t_6);
17465   __Pyx_XDECREF(__pyx_t_7);
17466   __Pyx_XDECREF(__pyx_t_8);
17467   __Pyx_AddTraceback("View.MemoryView.memoryview.is_slice", __pyx_clineno, __pyx_lineno, __pyx_filename);
17468   __pyx_r = 0;
17469   __pyx_L0:;
17470   __Pyx_XDECREF(__pyx_v_obj);
17471   __Pyx_XGIVEREF(__pyx_r);
17472   __Pyx_RefNannyFinishContext();
17473   return __pyx_r;
17474 }
17475 
17476 /* "View.MemoryView":441
17477  *         return obj
17478  *
17479  *     cdef setitem_slice_assignment(self, dst, src):             # <<<<<<<<<<<<<<
17480  *         cdef __Pyx_memviewslice dst_slice
17481  *         cdef __Pyx_memviewslice src_slice
17482  */
17483 
__pyx_memoryview_setitem_slice_assignment(struct __pyx_memoryview_obj * __pyx_v_self,PyObject * __pyx_v_dst,PyObject * __pyx_v_src)17484 static PyObject *__pyx_memoryview_setitem_slice_assignment(struct __pyx_memoryview_obj *__pyx_v_self, PyObject *__pyx_v_dst, PyObject *__pyx_v_src) {
17485   __Pyx_memviewslice __pyx_v_dst_slice;
17486   __Pyx_memviewslice __pyx_v_src_slice;
17487   PyObject *__pyx_r = NULL;
17488   __Pyx_RefNannyDeclarations
17489   __Pyx_memviewslice *__pyx_t_1;
17490   __Pyx_memviewslice *__pyx_t_2;
17491   PyObject *__pyx_t_3 = NULL;
17492   int __pyx_t_4;
17493   int __pyx_t_5;
17494   int __pyx_t_6;
17495   int __pyx_lineno = 0;
17496   const char *__pyx_filename = NULL;
17497   int __pyx_clineno = 0;
17498   __Pyx_RefNannySetupContext("setitem_slice_assignment", 0);
17499 
17500   /* "View.MemoryView":445
17501  *         cdef __Pyx_memviewslice src_slice
17502  *
17503  *         memoryview_copy_contents(get_slice_from_memview(src, &src_slice)[0],             # <<<<<<<<<<<<<<
17504  *                                  get_slice_from_memview(dst, &dst_slice)[0],
17505  *                                  src.ndim, dst.ndim, self.dtype_is_object)
17506  */
17507   if (!(likely(((__pyx_v_src) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_src, __pyx_memoryview_type))))) __PYX_ERR(3, 445, __pyx_L1_error)
17508   __pyx_t_1 = __pyx_memoryview_get_slice_from_memoryview(((struct __pyx_memoryview_obj *)__pyx_v_src), (&__pyx_v_src_slice)); if (unlikely(__pyx_t_1 == ((__Pyx_memviewslice *)NULL))) __PYX_ERR(3, 445, __pyx_L1_error)
17509 
17510   /* "View.MemoryView":446
17511  *
17512  *         memoryview_copy_contents(get_slice_from_memview(src, &src_slice)[0],
17513  *                                  get_slice_from_memview(dst, &dst_slice)[0],             # <<<<<<<<<<<<<<
17514  *                                  src.ndim, dst.ndim, self.dtype_is_object)
17515  *
17516  */
17517   if (!(likely(((__pyx_v_dst) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_dst, __pyx_memoryview_type))))) __PYX_ERR(3, 446, __pyx_L1_error)
17518   __pyx_t_2 = __pyx_memoryview_get_slice_from_memoryview(((struct __pyx_memoryview_obj *)__pyx_v_dst), (&__pyx_v_dst_slice)); if (unlikely(__pyx_t_2 == ((__Pyx_memviewslice *)NULL))) __PYX_ERR(3, 446, __pyx_L1_error)
17519 
17520   /* "View.MemoryView":447
17521  *         memoryview_copy_contents(get_slice_from_memview(src, &src_slice)[0],
17522  *                                  get_slice_from_memview(dst, &dst_slice)[0],
17523  *                                  src.ndim, dst.ndim, self.dtype_is_object)             # <<<<<<<<<<<<<<
17524  *
17525  *     cdef setitem_slice_assign_scalar(self, memoryview dst, value):
17526  */
17527   __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_src, __pyx_n_s_ndim); if (unlikely(!__pyx_t_3)) __PYX_ERR(3, 447, __pyx_L1_error)
17528   __Pyx_GOTREF(__pyx_t_3);
17529   __pyx_t_4 = __Pyx_PyInt_As_int(__pyx_t_3); if (unlikely((__pyx_t_4 == (int)-1) && PyErr_Occurred())) __PYX_ERR(3, 447, __pyx_L1_error)
17530   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
17531   __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_dst, __pyx_n_s_ndim); if (unlikely(!__pyx_t_3)) __PYX_ERR(3, 447, __pyx_L1_error)
17532   __Pyx_GOTREF(__pyx_t_3);
17533   __pyx_t_5 = __Pyx_PyInt_As_int(__pyx_t_3); if (unlikely((__pyx_t_5 == (int)-1) && PyErr_Occurred())) __PYX_ERR(3, 447, __pyx_L1_error)
17534   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
17535 
17536   /* "View.MemoryView":445
17537  *         cdef __Pyx_memviewslice src_slice
17538  *
17539  *         memoryview_copy_contents(get_slice_from_memview(src, &src_slice)[0],             # <<<<<<<<<<<<<<
17540  *                                  get_slice_from_memview(dst, &dst_slice)[0],
17541  *                                  src.ndim, dst.ndim, self.dtype_is_object)
17542  */
17543   __pyx_t_6 = __pyx_memoryview_copy_contents((__pyx_t_1[0]), (__pyx_t_2[0]), __pyx_t_4, __pyx_t_5, __pyx_v_self->dtype_is_object); if (unlikely(__pyx_t_6 == ((int)-1))) __PYX_ERR(3, 445, __pyx_L1_error)
17544 
17545   /* "View.MemoryView":441
17546  *         return obj
17547  *
17548  *     cdef setitem_slice_assignment(self, dst, src):             # <<<<<<<<<<<<<<
17549  *         cdef __Pyx_memviewslice dst_slice
17550  *         cdef __Pyx_memviewslice src_slice
17551  */
17552 
17553   /* function exit code */
17554   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
17555   goto __pyx_L0;
17556   __pyx_L1_error:;
17557   __Pyx_XDECREF(__pyx_t_3);
17558   __Pyx_AddTraceback("View.MemoryView.memoryview.setitem_slice_assignment", __pyx_clineno, __pyx_lineno, __pyx_filename);
17559   __pyx_r = 0;
17560   __pyx_L0:;
17561   __Pyx_XGIVEREF(__pyx_r);
17562   __Pyx_RefNannyFinishContext();
17563   return __pyx_r;
17564 }
17565 
17566 /* "View.MemoryView":449
17567  *                                  src.ndim, dst.ndim, self.dtype_is_object)
17568  *
17569  *     cdef setitem_slice_assign_scalar(self, memoryview dst, value):             # <<<<<<<<<<<<<<
17570  *         cdef int array[128]
17571  *         cdef void *tmp = NULL
17572  */
17573 
__pyx_memoryview_setitem_slice_assign_scalar(struct __pyx_memoryview_obj * __pyx_v_self,struct __pyx_memoryview_obj * __pyx_v_dst,PyObject * __pyx_v_value)17574 static PyObject *__pyx_memoryview_setitem_slice_assign_scalar(struct __pyx_memoryview_obj *__pyx_v_self, struct __pyx_memoryview_obj *__pyx_v_dst, PyObject *__pyx_v_value) {
17575   int __pyx_v_array[0x80];
17576   void *__pyx_v_tmp;
17577   void *__pyx_v_item;
17578   __Pyx_memviewslice *__pyx_v_dst_slice;
17579   __Pyx_memviewslice __pyx_v_tmp_slice;
17580   PyObject *__pyx_r = NULL;
17581   __Pyx_RefNannyDeclarations
17582   __Pyx_memviewslice *__pyx_t_1;
17583   int __pyx_t_2;
17584   PyObject *__pyx_t_3 = NULL;
17585   int __pyx_t_4;
17586   int __pyx_t_5;
17587   char const *__pyx_t_6;
17588   PyObject *__pyx_t_7 = NULL;
17589   PyObject *__pyx_t_8 = NULL;
17590   PyObject *__pyx_t_9 = NULL;
17591   PyObject *__pyx_t_10 = NULL;
17592   PyObject *__pyx_t_11 = NULL;
17593   PyObject *__pyx_t_12 = NULL;
17594   int __pyx_lineno = 0;
17595   const char *__pyx_filename = NULL;
17596   int __pyx_clineno = 0;
17597   __Pyx_RefNannySetupContext("setitem_slice_assign_scalar", 0);
17598 
17599   /* "View.MemoryView":451
17600  *     cdef setitem_slice_assign_scalar(self, memoryview dst, value):
17601  *         cdef int array[128]
17602  *         cdef void *tmp = NULL             # <<<<<<<<<<<<<<
17603  *         cdef void *item
17604  *
17605  */
17606   __pyx_v_tmp = NULL;
17607 
17608   /* "View.MemoryView":456
17609  *         cdef __Pyx_memviewslice *dst_slice
17610  *         cdef __Pyx_memviewslice tmp_slice
17611  *         dst_slice = get_slice_from_memview(dst, &tmp_slice)             # <<<<<<<<<<<<<<
17612  *
17613  *         if <size_t>self.view.itemsize > sizeof(array):
17614  */
17615   __pyx_t_1 = __pyx_memoryview_get_slice_from_memoryview(__pyx_v_dst, (&__pyx_v_tmp_slice)); if (unlikely(__pyx_t_1 == ((__Pyx_memviewslice *)NULL))) __PYX_ERR(3, 456, __pyx_L1_error)
17616   __pyx_v_dst_slice = __pyx_t_1;
17617 
17618   /* "View.MemoryView":458
17619  *         dst_slice = get_slice_from_memview(dst, &tmp_slice)
17620  *
17621  *         if <size_t>self.view.itemsize > sizeof(array):             # <<<<<<<<<<<<<<
17622  *             tmp = PyMem_Malloc(self.view.itemsize)
17623  *             if tmp == NULL:
17624  */
17625   __pyx_t_2 = ((((size_t)__pyx_v_self->view.itemsize) > (sizeof(__pyx_v_array))) != 0);
17626   if (__pyx_t_2) {
17627 
17628     /* "View.MemoryView":459
17629  *
17630  *         if <size_t>self.view.itemsize > sizeof(array):
17631  *             tmp = PyMem_Malloc(self.view.itemsize)             # <<<<<<<<<<<<<<
17632  *             if tmp == NULL:
17633  *                 raise MemoryError
17634  */
17635     __pyx_v_tmp = PyMem_Malloc(__pyx_v_self->view.itemsize);
17636 
17637     /* "View.MemoryView":460
17638  *         if <size_t>self.view.itemsize > sizeof(array):
17639  *             tmp = PyMem_Malloc(self.view.itemsize)
17640  *             if tmp == NULL:             # <<<<<<<<<<<<<<
17641  *                 raise MemoryError
17642  *             item = tmp
17643  */
17644     __pyx_t_2 = ((__pyx_v_tmp == NULL) != 0);
17645     if (unlikely(__pyx_t_2)) {
17646 
17647       /* "View.MemoryView":461
17648  *             tmp = PyMem_Malloc(self.view.itemsize)
17649  *             if tmp == NULL:
17650  *                 raise MemoryError             # <<<<<<<<<<<<<<
17651  *             item = tmp
17652  *         else:
17653  */
17654       PyErr_NoMemory(); __PYX_ERR(3, 461, __pyx_L1_error)
17655 
17656       /* "View.MemoryView":460
17657  *         if <size_t>self.view.itemsize > sizeof(array):
17658  *             tmp = PyMem_Malloc(self.view.itemsize)
17659  *             if tmp == NULL:             # <<<<<<<<<<<<<<
17660  *                 raise MemoryError
17661  *             item = tmp
17662  */
17663     }
17664 
17665     /* "View.MemoryView":462
17666  *             if tmp == NULL:
17667  *                 raise MemoryError
17668  *             item = tmp             # <<<<<<<<<<<<<<
17669  *         else:
17670  *             item = <void *> array
17671  */
17672     __pyx_v_item = __pyx_v_tmp;
17673 
17674     /* "View.MemoryView":458
17675  *         dst_slice = get_slice_from_memview(dst, &tmp_slice)
17676  *
17677  *         if <size_t>self.view.itemsize > sizeof(array):             # <<<<<<<<<<<<<<
17678  *             tmp = PyMem_Malloc(self.view.itemsize)
17679  *             if tmp == NULL:
17680  */
17681     goto __pyx_L3;
17682   }
17683 
17684   /* "View.MemoryView":464
17685  *             item = tmp
17686  *         else:
17687  *             item = <void *> array             # <<<<<<<<<<<<<<
17688  *
17689  *         try:
17690  */
17691   /*else*/ {
17692     __pyx_v_item = ((void *)__pyx_v_array);
17693   }
17694   __pyx_L3:;
17695 
17696   /* "View.MemoryView":466
17697  *             item = <void *> array
17698  *
17699  *         try:             # <<<<<<<<<<<<<<
17700  *             if self.dtype_is_object:
17701  *                 (<PyObject **> item)[0] = <PyObject *> value
17702  */
17703   /*try:*/ {
17704 
17705     /* "View.MemoryView":467
17706  *
17707  *         try:
17708  *             if self.dtype_is_object:             # <<<<<<<<<<<<<<
17709  *                 (<PyObject **> item)[0] = <PyObject *> value
17710  *             else:
17711  */
17712     __pyx_t_2 = (__pyx_v_self->dtype_is_object != 0);
17713     if (__pyx_t_2) {
17714 
17715       /* "View.MemoryView":468
17716  *         try:
17717  *             if self.dtype_is_object:
17718  *                 (<PyObject **> item)[0] = <PyObject *> value             # <<<<<<<<<<<<<<
17719  *             else:
17720  *                 self.assign_item_from_object(<char *> item, value)
17721  */
17722       (((PyObject **)__pyx_v_item)[0]) = ((PyObject *)__pyx_v_value);
17723 
17724       /* "View.MemoryView":467
17725  *
17726  *         try:
17727  *             if self.dtype_is_object:             # <<<<<<<<<<<<<<
17728  *                 (<PyObject **> item)[0] = <PyObject *> value
17729  *             else:
17730  */
17731       goto __pyx_L8;
17732     }
17733 
17734     /* "View.MemoryView":470
17735  *                 (<PyObject **> item)[0] = <PyObject *> value
17736  *             else:
17737  *                 self.assign_item_from_object(<char *> item, value)             # <<<<<<<<<<<<<<
17738  *
17739  *
17740  */
17741     /*else*/ {
17742       __pyx_t_3 = ((struct __pyx_vtabstruct_memoryview *)__pyx_v_self->__pyx_vtab)->assign_item_from_object(__pyx_v_self, ((char *)__pyx_v_item), __pyx_v_value); if (unlikely(!__pyx_t_3)) __PYX_ERR(3, 470, __pyx_L6_error)
17743       __Pyx_GOTREF(__pyx_t_3);
17744       __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
17745     }
17746     __pyx_L8:;
17747 
17748     /* "View.MemoryView":474
17749  *
17750  *
17751  *             if self.view.suboffsets != NULL:             # <<<<<<<<<<<<<<
17752  *                 assert_direct_dimensions(self.view.suboffsets, self.view.ndim)
17753  *             slice_assign_scalar(dst_slice, dst.view.ndim, self.view.itemsize,
17754  */
17755     __pyx_t_2 = ((__pyx_v_self->view.suboffsets != NULL) != 0);
17756     if (__pyx_t_2) {
17757 
17758       /* "View.MemoryView":475
17759  *
17760  *             if self.view.suboffsets != NULL:
17761  *                 assert_direct_dimensions(self.view.suboffsets, self.view.ndim)             # <<<<<<<<<<<<<<
17762  *             slice_assign_scalar(dst_slice, dst.view.ndim, self.view.itemsize,
17763  *                                 item, self.dtype_is_object)
17764  */
17765       __pyx_t_3 = assert_direct_dimensions(__pyx_v_self->view.suboffsets, __pyx_v_self->view.ndim); if (unlikely(!__pyx_t_3)) __PYX_ERR(3, 475, __pyx_L6_error)
17766       __Pyx_GOTREF(__pyx_t_3);
17767       __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
17768 
17769       /* "View.MemoryView":474
17770  *
17771  *
17772  *             if self.view.suboffsets != NULL:             # <<<<<<<<<<<<<<
17773  *                 assert_direct_dimensions(self.view.suboffsets, self.view.ndim)
17774  *             slice_assign_scalar(dst_slice, dst.view.ndim, self.view.itemsize,
17775  */
17776     }
17777 
17778     /* "View.MemoryView":476
17779  *             if self.view.suboffsets != NULL:
17780  *                 assert_direct_dimensions(self.view.suboffsets, self.view.ndim)
17781  *             slice_assign_scalar(dst_slice, dst.view.ndim, self.view.itemsize,             # <<<<<<<<<<<<<<
17782  *                                 item, self.dtype_is_object)
17783  *         finally:
17784  */
17785     __pyx_memoryview_slice_assign_scalar(__pyx_v_dst_slice, __pyx_v_dst->view.ndim, __pyx_v_self->view.itemsize, __pyx_v_item, __pyx_v_self->dtype_is_object);
17786   }
17787 
17788   /* "View.MemoryView":479
17789  *                                 item, self.dtype_is_object)
17790  *         finally:
17791  *             PyMem_Free(tmp)             # <<<<<<<<<<<<<<
17792  *
17793  *     cdef setitem_indexed(self, index, value):
17794  */
17795   /*finally:*/ {
17796     /*normal exit:*/{
17797       PyMem_Free(__pyx_v_tmp);
17798       goto __pyx_L7;
17799     }
17800     __pyx_L6_error:;
17801     /*exception exit:*/{
17802       __Pyx_PyThreadState_declare
17803       __Pyx_PyThreadState_assign
17804       __pyx_t_7 = 0; __pyx_t_8 = 0; __pyx_t_9 = 0; __pyx_t_10 = 0; __pyx_t_11 = 0; __pyx_t_12 = 0;
17805       __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
17806       if (PY_MAJOR_VERSION >= 3) __Pyx_ExceptionSwap(&__pyx_t_10, &__pyx_t_11, &__pyx_t_12);
17807       if ((PY_MAJOR_VERSION < 3) || unlikely(__Pyx_GetException(&__pyx_t_7, &__pyx_t_8, &__pyx_t_9) < 0)) __Pyx_ErrFetch(&__pyx_t_7, &__pyx_t_8, &__pyx_t_9);
17808       __Pyx_XGOTREF(__pyx_t_7);
17809       __Pyx_XGOTREF(__pyx_t_8);
17810       __Pyx_XGOTREF(__pyx_t_9);
17811       __Pyx_XGOTREF(__pyx_t_10);
17812       __Pyx_XGOTREF(__pyx_t_11);
17813       __Pyx_XGOTREF(__pyx_t_12);
17814       __pyx_t_4 = __pyx_lineno; __pyx_t_5 = __pyx_clineno; __pyx_t_6 = __pyx_filename;
17815       {
17816         PyMem_Free(__pyx_v_tmp);
17817       }
17818       if (PY_MAJOR_VERSION >= 3) {
17819         __Pyx_XGIVEREF(__pyx_t_10);
17820         __Pyx_XGIVEREF(__pyx_t_11);
17821         __Pyx_XGIVEREF(__pyx_t_12);
17822         __Pyx_ExceptionReset(__pyx_t_10, __pyx_t_11, __pyx_t_12);
17823       }
17824       __Pyx_XGIVEREF(__pyx_t_7);
17825       __Pyx_XGIVEREF(__pyx_t_8);
17826       __Pyx_XGIVEREF(__pyx_t_9);
17827       __Pyx_ErrRestore(__pyx_t_7, __pyx_t_8, __pyx_t_9);
17828       __pyx_t_7 = 0; __pyx_t_8 = 0; __pyx_t_9 = 0; __pyx_t_10 = 0; __pyx_t_11 = 0; __pyx_t_12 = 0;
17829       __pyx_lineno = __pyx_t_4; __pyx_clineno = __pyx_t_5; __pyx_filename = __pyx_t_6;
17830       goto __pyx_L1_error;
17831     }
17832     __pyx_L7:;
17833   }
17834 
17835   /* "View.MemoryView":449
17836  *                                  src.ndim, dst.ndim, self.dtype_is_object)
17837  *
17838  *     cdef setitem_slice_assign_scalar(self, memoryview dst, value):             # <<<<<<<<<<<<<<
17839  *         cdef int array[128]
17840  *         cdef void *tmp = NULL
17841  */
17842 
17843   /* function exit code */
17844   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
17845   goto __pyx_L0;
17846   __pyx_L1_error:;
17847   __Pyx_XDECREF(__pyx_t_3);
17848   __Pyx_AddTraceback("View.MemoryView.memoryview.setitem_slice_assign_scalar", __pyx_clineno, __pyx_lineno, __pyx_filename);
17849   __pyx_r = 0;
17850   __pyx_L0:;
17851   __Pyx_XGIVEREF(__pyx_r);
17852   __Pyx_RefNannyFinishContext();
17853   return __pyx_r;
17854 }
17855 
17856 /* "View.MemoryView":481
17857  *             PyMem_Free(tmp)
17858  *
17859  *     cdef setitem_indexed(self, index, value):             # <<<<<<<<<<<<<<
17860  *         cdef char *itemp = self.get_item_pointer(index)
17861  *         self.assign_item_from_object(itemp, value)
17862  */
17863 
__pyx_memoryview_setitem_indexed(struct __pyx_memoryview_obj * __pyx_v_self,PyObject * __pyx_v_index,PyObject * __pyx_v_value)17864 static PyObject *__pyx_memoryview_setitem_indexed(struct __pyx_memoryview_obj *__pyx_v_self, PyObject *__pyx_v_index, PyObject *__pyx_v_value) {
17865   char *__pyx_v_itemp;
17866   PyObject *__pyx_r = NULL;
17867   __Pyx_RefNannyDeclarations
17868   char *__pyx_t_1;
17869   PyObject *__pyx_t_2 = NULL;
17870   int __pyx_lineno = 0;
17871   const char *__pyx_filename = NULL;
17872   int __pyx_clineno = 0;
17873   __Pyx_RefNannySetupContext("setitem_indexed", 0);
17874 
17875   /* "View.MemoryView":482
17876  *
17877  *     cdef setitem_indexed(self, index, value):
17878  *         cdef char *itemp = self.get_item_pointer(index)             # <<<<<<<<<<<<<<
17879  *         self.assign_item_from_object(itemp, value)
17880  *
17881  */
17882   __pyx_t_1 = ((struct __pyx_vtabstruct_memoryview *)__pyx_v_self->__pyx_vtab)->get_item_pointer(__pyx_v_self, __pyx_v_index); if (unlikely(__pyx_t_1 == ((char *)NULL))) __PYX_ERR(3, 482, __pyx_L1_error)
17883   __pyx_v_itemp = __pyx_t_1;
17884 
17885   /* "View.MemoryView":483
17886  *     cdef setitem_indexed(self, index, value):
17887  *         cdef char *itemp = self.get_item_pointer(index)
17888  *         self.assign_item_from_object(itemp, value)             # <<<<<<<<<<<<<<
17889  *
17890  *     cdef convert_item_to_object(self, char *itemp):
17891  */
17892   __pyx_t_2 = ((struct __pyx_vtabstruct_memoryview *)__pyx_v_self->__pyx_vtab)->assign_item_from_object(__pyx_v_self, __pyx_v_itemp, __pyx_v_value); if (unlikely(!__pyx_t_2)) __PYX_ERR(3, 483, __pyx_L1_error)
17893   __Pyx_GOTREF(__pyx_t_2);
17894   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
17895 
17896   /* "View.MemoryView":481
17897  *             PyMem_Free(tmp)
17898  *
17899  *     cdef setitem_indexed(self, index, value):             # <<<<<<<<<<<<<<
17900  *         cdef char *itemp = self.get_item_pointer(index)
17901  *         self.assign_item_from_object(itemp, value)
17902  */
17903 
17904   /* function exit code */
17905   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
17906   goto __pyx_L0;
17907   __pyx_L1_error:;
17908   __Pyx_XDECREF(__pyx_t_2);
17909   __Pyx_AddTraceback("View.MemoryView.memoryview.setitem_indexed", __pyx_clineno, __pyx_lineno, __pyx_filename);
17910   __pyx_r = 0;
17911   __pyx_L0:;
17912   __Pyx_XGIVEREF(__pyx_r);
17913   __Pyx_RefNannyFinishContext();
17914   return __pyx_r;
17915 }
17916 
17917 /* "View.MemoryView":485
17918  *         self.assign_item_from_object(itemp, value)
17919  *
17920  *     cdef convert_item_to_object(self, char *itemp):             # <<<<<<<<<<<<<<
17921  *         """Only used if instantiated manually by the user, or if Cython doesn't
17922  *         know how to convert the type"""
17923  */
17924 
__pyx_memoryview_convert_item_to_object(struct __pyx_memoryview_obj * __pyx_v_self,char * __pyx_v_itemp)17925 static PyObject *__pyx_memoryview_convert_item_to_object(struct __pyx_memoryview_obj *__pyx_v_self, char *__pyx_v_itemp) {
17926   PyObject *__pyx_v_struct = NULL;
17927   PyObject *__pyx_v_bytesitem = 0;
17928   PyObject *__pyx_v_result = NULL;
17929   PyObject *__pyx_r = NULL;
17930   __Pyx_RefNannyDeclarations
17931   PyObject *__pyx_t_1 = NULL;
17932   PyObject *__pyx_t_2 = NULL;
17933   PyObject *__pyx_t_3 = NULL;
17934   PyObject *__pyx_t_4 = NULL;
17935   PyObject *__pyx_t_5 = NULL;
17936   PyObject *__pyx_t_6 = NULL;
17937   PyObject *__pyx_t_7 = NULL;
17938   int __pyx_t_8;
17939   PyObject *__pyx_t_9 = NULL;
17940   size_t __pyx_t_10;
17941   int __pyx_t_11;
17942   int __pyx_lineno = 0;
17943   const char *__pyx_filename = NULL;
17944   int __pyx_clineno = 0;
17945   __Pyx_RefNannySetupContext("convert_item_to_object", 0);
17946 
17947   /* "View.MemoryView":488
17948  *         """Only used if instantiated manually by the user, or if Cython doesn't
17949  *         know how to convert the type"""
17950  *         import struct             # <<<<<<<<<<<<<<
17951  *         cdef bytes bytesitem
17952  *
17953  */
17954   __pyx_t_1 = __Pyx_Import(__pyx_n_s_struct, 0, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(3, 488, __pyx_L1_error)
17955   __Pyx_GOTREF(__pyx_t_1);
17956   __pyx_v_struct = __pyx_t_1;
17957   __pyx_t_1 = 0;
17958 
17959   /* "View.MemoryView":491
17960  *         cdef bytes bytesitem
17961  *
17962  *         bytesitem = itemp[:self.view.itemsize]             # <<<<<<<<<<<<<<
17963  *         try:
17964  *             result = struct.unpack(self.view.format, bytesitem)
17965  */
17966   __pyx_t_1 = __Pyx_PyBytes_FromStringAndSize(__pyx_v_itemp + 0, __pyx_v_self->view.itemsize - 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(3, 491, __pyx_L1_error)
17967   __Pyx_GOTREF(__pyx_t_1);
17968   __pyx_v_bytesitem = ((PyObject*)__pyx_t_1);
17969   __pyx_t_1 = 0;
17970 
17971   /* "View.MemoryView":492
17972  *
17973  *         bytesitem = itemp[:self.view.itemsize]
17974  *         try:             # <<<<<<<<<<<<<<
17975  *             result = struct.unpack(self.view.format, bytesitem)
17976  *         except struct.error:
17977  */
17978   {
17979     __Pyx_PyThreadState_declare
17980     __Pyx_PyThreadState_assign
17981     __Pyx_ExceptionSave(&__pyx_t_2, &__pyx_t_3, &__pyx_t_4);
17982     __Pyx_XGOTREF(__pyx_t_2);
17983     __Pyx_XGOTREF(__pyx_t_3);
17984     __Pyx_XGOTREF(__pyx_t_4);
17985     /*try:*/ {
17986 
17987       /* "View.MemoryView":493
17988  *         bytesitem = itemp[:self.view.itemsize]
17989  *         try:
17990  *             result = struct.unpack(self.view.format, bytesitem)             # <<<<<<<<<<<<<<
17991  *         except struct.error:
17992  *             raise ValueError("Unable to convert item to object")
17993  */
17994       __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_struct, __pyx_n_s_unpack); if (unlikely(!__pyx_t_5)) __PYX_ERR(3, 493, __pyx_L3_error)
17995       __Pyx_GOTREF(__pyx_t_5);
17996       __pyx_t_6 = __Pyx_PyBytes_FromString(__pyx_v_self->view.format); if (unlikely(!__pyx_t_6)) __PYX_ERR(3, 493, __pyx_L3_error)
17997       __Pyx_GOTREF(__pyx_t_6);
17998       __pyx_t_7 = NULL;
17999       __pyx_t_8 = 0;
18000       if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_5))) {
18001         __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_5);
18002         if (likely(__pyx_t_7)) {
18003           PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
18004           __Pyx_INCREF(__pyx_t_7);
18005           __Pyx_INCREF(function);
18006           __Pyx_DECREF_SET(__pyx_t_5, function);
18007           __pyx_t_8 = 1;
18008         }
18009       }
18010       #if CYTHON_FAST_PYCALL
18011       if (PyFunction_Check(__pyx_t_5)) {
18012         PyObject *__pyx_temp[3] = {__pyx_t_7, __pyx_t_6, __pyx_v_bytesitem};
18013         __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_5, __pyx_temp+1-__pyx_t_8, 2+__pyx_t_8); if (unlikely(!__pyx_t_1)) __PYX_ERR(3, 493, __pyx_L3_error)
18014         __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
18015         __Pyx_GOTREF(__pyx_t_1);
18016         __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
18017       } else
18018       #endif
18019       #if CYTHON_FAST_PYCCALL
18020       if (__Pyx_PyFastCFunction_Check(__pyx_t_5)) {
18021         PyObject *__pyx_temp[3] = {__pyx_t_7, __pyx_t_6, __pyx_v_bytesitem};
18022         __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_5, __pyx_temp+1-__pyx_t_8, 2+__pyx_t_8); if (unlikely(!__pyx_t_1)) __PYX_ERR(3, 493, __pyx_L3_error)
18023         __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
18024         __Pyx_GOTREF(__pyx_t_1);
18025         __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
18026       } else
18027       #endif
18028       {
18029         __pyx_t_9 = PyTuple_New(2+__pyx_t_8); if (unlikely(!__pyx_t_9)) __PYX_ERR(3, 493, __pyx_L3_error)
18030         __Pyx_GOTREF(__pyx_t_9);
18031         if (__pyx_t_7) {
18032           __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_7); __pyx_t_7 = NULL;
18033         }
18034         __Pyx_GIVEREF(__pyx_t_6);
18035         PyTuple_SET_ITEM(__pyx_t_9, 0+__pyx_t_8, __pyx_t_6);
18036         __Pyx_INCREF(__pyx_v_bytesitem);
18037         __Pyx_GIVEREF(__pyx_v_bytesitem);
18038         PyTuple_SET_ITEM(__pyx_t_9, 1+__pyx_t_8, __pyx_v_bytesitem);
18039         __pyx_t_6 = 0;
18040         __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_9, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(3, 493, __pyx_L3_error)
18041         __Pyx_GOTREF(__pyx_t_1);
18042         __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
18043       }
18044       __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
18045       __pyx_v_result = __pyx_t_1;
18046       __pyx_t_1 = 0;
18047 
18048       /* "View.MemoryView":492
18049  *
18050  *         bytesitem = itemp[:self.view.itemsize]
18051  *         try:             # <<<<<<<<<<<<<<
18052  *             result = struct.unpack(self.view.format, bytesitem)
18053  *         except struct.error:
18054  */
18055     }
18056 
18057     /* "View.MemoryView":497
18058  *             raise ValueError("Unable to convert item to object")
18059  *         else:
18060  *             if len(self.view.format) == 1:             # <<<<<<<<<<<<<<
18061  *                 return result[0]
18062  *             return result
18063  */
18064     /*else:*/ {
18065       __pyx_t_10 = strlen(__pyx_v_self->view.format);
18066       __pyx_t_11 = ((__pyx_t_10 == 1) != 0);
18067       if (__pyx_t_11) {
18068 
18069         /* "View.MemoryView":498
18070  *         else:
18071  *             if len(self.view.format) == 1:
18072  *                 return result[0]             # <<<<<<<<<<<<<<
18073  *             return result
18074  *
18075  */
18076         __Pyx_XDECREF(__pyx_r);
18077         __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_result, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(3, 498, __pyx_L5_except_error)
18078         __Pyx_GOTREF(__pyx_t_1);
18079         __pyx_r = __pyx_t_1;
18080         __pyx_t_1 = 0;
18081         goto __pyx_L6_except_return;
18082 
18083         /* "View.MemoryView":497
18084  *             raise ValueError("Unable to convert item to object")
18085  *         else:
18086  *             if len(self.view.format) == 1:             # <<<<<<<<<<<<<<
18087  *                 return result[0]
18088  *             return result
18089  */
18090       }
18091 
18092       /* "View.MemoryView":499
18093  *             if len(self.view.format) == 1:
18094  *                 return result[0]
18095  *             return result             # <<<<<<<<<<<<<<
18096  *
18097  *     cdef assign_item_from_object(self, char *itemp, object value):
18098  */
18099       __Pyx_XDECREF(__pyx_r);
18100       __Pyx_INCREF(__pyx_v_result);
18101       __pyx_r = __pyx_v_result;
18102       goto __pyx_L6_except_return;
18103     }
18104     __pyx_L3_error:;
18105     __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
18106     __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
18107     __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
18108     __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
18109     __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
18110 
18111     /* "View.MemoryView":494
18112  *         try:
18113  *             result = struct.unpack(self.view.format, bytesitem)
18114  *         except struct.error:             # <<<<<<<<<<<<<<
18115  *             raise ValueError("Unable to convert item to object")
18116  *         else:
18117  */
18118     __Pyx_ErrFetch(&__pyx_t_1, &__pyx_t_5, &__pyx_t_9);
18119     __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_struct, __pyx_n_s_error); if (unlikely(!__pyx_t_6)) __PYX_ERR(3, 494, __pyx_L5_except_error)
18120     __Pyx_GOTREF(__pyx_t_6);
18121     __pyx_t_8 = __Pyx_PyErr_GivenExceptionMatches(__pyx_t_1, __pyx_t_6);
18122     __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
18123     __Pyx_ErrRestore(__pyx_t_1, __pyx_t_5, __pyx_t_9);
18124     __pyx_t_1 = 0; __pyx_t_5 = 0; __pyx_t_9 = 0;
18125     if (__pyx_t_8) {
18126       __Pyx_AddTraceback("View.MemoryView.memoryview.convert_item_to_object", __pyx_clineno, __pyx_lineno, __pyx_filename);
18127       if (__Pyx_GetException(&__pyx_t_9, &__pyx_t_5, &__pyx_t_1) < 0) __PYX_ERR(3, 494, __pyx_L5_except_error)
18128       __Pyx_GOTREF(__pyx_t_9);
18129       __Pyx_GOTREF(__pyx_t_5);
18130       __Pyx_GOTREF(__pyx_t_1);
18131 
18132       /* "View.MemoryView":495
18133  *             result = struct.unpack(self.view.format, bytesitem)
18134  *         except struct.error:
18135  *             raise ValueError("Unable to convert item to object")             # <<<<<<<<<<<<<<
18136  *         else:
18137  *             if len(self.view.format) == 1:
18138  */
18139       __pyx_t_6 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__29, NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(3, 495, __pyx_L5_except_error)
18140       __Pyx_GOTREF(__pyx_t_6);
18141       __Pyx_Raise(__pyx_t_6, 0, 0, 0);
18142       __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
18143       __PYX_ERR(3, 495, __pyx_L5_except_error)
18144     }
18145     goto __pyx_L5_except_error;
18146     __pyx_L5_except_error:;
18147 
18148     /* "View.MemoryView":492
18149  *
18150  *         bytesitem = itemp[:self.view.itemsize]
18151  *         try:             # <<<<<<<<<<<<<<
18152  *             result = struct.unpack(self.view.format, bytesitem)
18153  *         except struct.error:
18154  */
18155     __Pyx_XGIVEREF(__pyx_t_2);
18156     __Pyx_XGIVEREF(__pyx_t_3);
18157     __Pyx_XGIVEREF(__pyx_t_4);
18158     __Pyx_ExceptionReset(__pyx_t_2, __pyx_t_3, __pyx_t_4);
18159     goto __pyx_L1_error;
18160     __pyx_L6_except_return:;
18161     __Pyx_XGIVEREF(__pyx_t_2);
18162     __Pyx_XGIVEREF(__pyx_t_3);
18163     __Pyx_XGIVEREF(__pyx_t_4);
18164     __Pyx_ExceptionReset(__pyx_t_2, __pyx_t_3, __pyx_t_4);
18165     goto __pyx_L0;
18166   }
18167 
18168   /* "View.MemoryView":485
18169  *         self.assign_item_from_object(itemp, value)
18170  *
18171  *     cdef convert_item_to_object(self, char *itemp):             # <<<<<<<<<<<<<<
18172  *         """Only used if instantiated manually by the user, or if Cython doesn't
18173  *         know how to convert the type"""
18174  */
18175 
18176   /* function exit code */
18177   __pyx_L1_error:;
18178   __Pyx_XDECREF(__pyx_t_1);
18179   __Pyx_XDECREF(__pyx_t_5);
18180   __Pyx_XDECREF(__pyx_t_6);
18181   __Pyx_XDECREF(__pyx_t_7);
18182   __Pyx_XDECREF(__pyx_t_9);
18183   __Pyx_AddTraceback("View.MemoryView.memoryview.convert_item_to_object", __pyx_clineno, __pyx_lineno, __pyx_filename);
18184   __pyx_r = 0;
18185   __pyx_L0:;
18186   __Pyx_XDECREF(__pyx_v_struct);
18187   __Pyx_XDECREF(__pyx_v_bytesitem);
18188   __Pyx_XDECREF(__pyx_v_result);
18189   __Pyx_XGIVEREF(__pyx_r);
18190   __Pyx_RefNannyFinishContext();
18191   return __pyx_r;
18192 }
18193 
18194 /* "View.MemoryView":501
18195  *             return result
18196  *
18197  *     cdef assign_item_from_object(self, char *itemp, object value):             # <<<<<<<<<<<<<<
18198  *         """Only used if instantiated manually by the user, or if Cython doesn't
18199  *         know how to convert the type"""
18200  */
18201 
__pyx_memoryview_assign_item_from_object(struct __pyx_memoryview_obj * __pyx_v_self,char * __pyx_v_itemp,PyObject * __pyx_v_value)18202 static PyObject *__pyx_memoryview_assign_item_from_object(struct __pyx_memoryview_obj *__pyx_v_self, char *__pyx_v_itemp, PyObject *__pyx_v_value) {
18203   PyObject *__pyx_v_struct = NULL;
18204   char __pyx_v_c;
18205   PyObject *__pyx_v_bytesvalue = 0;
18206   Py_ssize_t __pyx_v_i;
18207   PyObject *__pyx_r = NULL;
18208   __Pyx_RefNannyDeclarations
18209   PyObject *__pyx_t_1 = NULL;
18210   int __pyx_t_2;
18211   int __pyx_t_3;
18212   PyObject *__pyx_t_4 = NULL;
18213   PyObject *__pyx_t_5 = NULL;
18214   PyObject *__pyx_t_6 = NULL;
18215   int __pyx_t_7;
18216   PyObject *__pyx_t_8 = NULL;
18217   Py_ssize_t __pyx_t_9;
18218   PyObject *__pyx_t_10 = NULL;
18219   char *__pyx_t_11;
18220   char *__pyx_t_12;
18221   char *__pyx_t_13;
18222   char *__pyx_t_14;
18223   int __pyx_lineno = 0;
18224   const char *__pyx_filename = NULL;
18225   int __pyx_clineno = 0;
18226   __Pyx_RefNannySetupContext("assign_item_from_object", 0);
18227 
18228   /* "View.MemoryView":504
18229  *         """Only used if instantiated manually by the user, or if Cython doesn't
18230  *         know how to convert the type"""
18231  *         import struct             # <<<<<<<<<<<<<<
18232  *         cdef char c
18233  *         cdef bytes bytesvalue
18234  */
18235   __pyx_t_1 = __Pyx_Import(__pyx_n_s_struct, 0, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(3, 504, __pyx_L1_error)
18236   __Pyx_GOTREF(__pyx_t_1);
18237   __pyx_v_struct = __pyx_t_1;
18238   __pyx_t_1 = 0;
18239 
18240   /* "View.MemoryView":509
18241  *         cdef Py_ssize_t i
18242  *
18243  *         if isinstance(value, tuple):             # <<<<<<<<<<<<<<
18244  *             bytesvalue = struct.pack(self.view.format, *value)
18245  *         else:
18246  */
18247   __pyx_t_2 = PyTuple_Check(__pyx_v_value);
18248   __pyx_t_3 = (__pyx_t_2 != 0);
18249   if (__pyx_t_3) {
18250 
18251     /* "View.MemoryView":510
18252  *
18253  *         if isinstance(value, tuple):
18254  *             bytesvalue = struct.pack(self.view.format, *value)             # <<<<<<<<<<<<<<
18255  *         else:
18256  *             bytesvalue = struct.pack(self.view.format, value)
18257  */
18258     __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_struct, __pyx_n_s_pack); if (unlikely(!__pyx_t_1)) __PYX_ERR(3, 510, __pyx_L1_error)
18259     __Pyx_GOTREF(__pyx_t_1);
18260     __pyx_t_4 = __Pyx_PyBytes_FromString(__pyx_v_self->view.format); if (unlikely(!__pyx_t_4)) __PYX_ERR(3, 510, __pyx_L1_error)
18261     __Pyx_GOTREF(__pyx_t_4);
18262     __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) __PYX_ERR(3, 510, __pyx_L1_error)
18263     __Pyx_GOTREF(__pyx_t_5);
18264     __Pyx_GIVEREF(__pyx_t_4);
18265     PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_4);
18266     __pyx_t_4 = 0;
18267     __pyx_t_4 = __Pyx_PySequence_Tuple(__pyx_v_value); if (unlikely(!__pyx_t_4)) __PYX_ERR(3, 510, __pyx_L1_error)
18268     __Pyx_GOTREF(__pyx_t_4);
18269     __pyx_t_6 = PyNumber_Add(__pyx_t_5, __pyx_t_4); if (unlikely(!__pyx_t_6)) __PYX_ERR(3, 510, __pyx_L1_error)
18270     __Pyx_GOTREF(__pyx_t_6);
18271     __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
18272     __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
18273     __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_6, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(3, 510, __pyx_L1_error)
18274     __Pyx_GOTREF(__pyx_t_4);
18275     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
18276     __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
18277     if (!(likely(PyBytes_CheckExact(__pyx_t_4))||((__pyx_t_4) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "bytes", Py_TYPE(__pyx_t_4)->tp_name), 0))) __PYX_ERR(3, 510, __pyx_L1_error)
18278     __pyx_v_bytesvalue = ((PyObject*)__pyx_t_4);
18279     __pyx_t_4 = 0;
18280 
18281     /* "View.MemoryView":509
18282  *         cdef Py_ssize_t i
18283  *
18284  *         if isinstance(value, tuple):             # <<<<<<<<<<<<<<
18285  *             bytesvalue = struct.pack(self.view.format, *value)
18286  *         else:
18287  */
18288     goto __pyx_L3;
18289   }
18290 
18291   /* "View.MemoryView":512
18292  *             bytesvalue = struct.pack(self.view.format, *value)
18293  *         else:
18294  *             bytesvalue = struct.pack(self.view.format, value)             # <<<<<<<<<<<<<<
18295  *
18296  *         for i, c in enumerate(bytesvalue):
18297  */
18298   /*else*/ {
18299     __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_struct, __pyx_n_s_pack); if (unlikely(!__pyx_t_6)) __PYX_ERR(3, 512, __pyx_L1_error)
18300     __Pyx_GOTREF(__pyx_t_6);
18301     __pyx_t_1 = __Pyx_PyBytes_FromString(__pyx_v_self->view.format); if (unlikely(!__pyx_t_1)) __PYX_ERR(3, 512, __pyx_L1_error)
18302     __Pyx_GOTREF(__pyx_t_1);
18303     __pyx_t_5 = NULL;
18304     __pyx_t_7 = 0;
18305     if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_6))) {
18306       __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_6);
18307       if (likely(__pyx_t_5)) {
18308         PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
18309         __Pyx_INCREF(__pyx_t_5);
18310         __Pyx_INCREF(function);
18311         __Pyx_DECREF_SET(__pyx_t_6, function);
18312         __pyx_t_7 = 1;
18313       }
18314     }
18315     #if CYTHON_FAST_PYCALL
18316     if (PyFunction_Check(__pyx_t_6)) {
18317       PyObject *__pyx_temp[3] = {__pyx_t_5, __pyx_t_1, __pyx_v_value};
18318       __pyx_t_4 = __Pyx_PyFunction_FastCall(__pyx_t_6, __pyx_temp+1-__pyx_t_7, 2+__pyx_t_7); if (unlikely(!__pyx_t_4)) __PYX_ERR(3, 512, __pyx_L1_error)
18319       __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
18320       __Pyx_GOTREF(__pyx_t_4);
18321       __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
18322     } else
18323     #endif
18324     #if CYTHON_FAST_PYCCALL
18325     if (__Pyx_PyFastCFunction_Check(__pyx_t_6)) {
18326       PyObject *__pyx_temp[3] = {__pyx_t_5, __pyx_t_1, __pyx_v_value};
18327       __pyx_t_4 = __Pyx_PyCFunction_FastCall(__pyx_t_6, __pyx_temp+1-__pyx_t_7, 2+__pyx_t_7); if (unlikely(!__pyx_t_4)) __PYX_ERR(3, 512, __pyx_L1_error)
18328       __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
18329       __Pyx_GOTREF(__pyx_t_4);
18330       __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
18331     } else
18332     #endif
18333     {
18334       __pyx_t_8 = PyTuple_New(2+__pyx_t_7); if (unlikely(!__pyx_t_8)) __PYX_ERR(3, 512, __pyx_L1_error)
18335       __Pyx_GOTREF(__pyx_t_8);
18336       if (__pyx_t_5) {
18337         __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_5); __pyx_t_5 = NULL;
18338       }
18339       __Pyx_GIVEREF(__pyx_t_1);
18340       PyTuple_SET_ITEM(__pyx_t_8, 0+__pyx_t_7, __pyx_t_1);
18341       __Pyx_INCREF(__pyx_v_value);
18342       __Pyx_GIVEREF(__pyx_v_value);
18343       PyTuple_SET_ITEM(__pyx_t_8, 1+__pyx_t_7, __pyx_v_value);
18344       __pyx_t_1 = 0;
18345       __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_8, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(3, 512, __pyx_L1_error)
18346       __Pyx_GOTREF(__pyx_t_4);
18347       __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
18348     }
18349     __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
18350     if (!(likely(PyBytes_CheckExact(__pyx_t_4))||((__pyx_t_4) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "bytes", Py_TYPE(__pyx_t_4)->tp_name), 0))) __PYX_ERR(3, 512, __pyx_L1_error)
18351     __pyx_v_bytesvalue = ((PyObject*)__pyx_t_4);
18352     __pyx_t_4 = 0;
18353   }
18354   __pyx_L3:;
18355 
18356   /* "View.MemoryView":514
18357  *             bytesvalue = struct.pack(self.view.format, value)
18358  *
18359  *         for i, c in enumerate(bytesvalue):             # <<<<<<<<<<<<<<
18360  *             itemp[i] = c
18361  *
18362  */
18363   __pyx_t_9 = 0;
18364   if (unlikely(__pyx_v_bytesvalue == Py_None)) {
18365     PyErr_SetString(PyExc_TypeError, "'NoneType' is not iterable");
18366     __PYX_ERR(3, 514, __pyx_L1_error)
18367   }
18368   __Pyx_INCREF(__pyx_v_bytesvalue);
18369   __pyx_t_10 = __pyx_v_bytesvalue;
18370   __pyx_t_12 = PyBytes_AS_STRING(__pyx_t_10);
18371   __pyx_t_13 = (__pyx_t_12 + PyBytes_GET_SIZE(__pyx_t_10));
18372   for (__pyx_t_14 = __pyx_t_12; __pyx_t_14 < __pyx_t_13; __pyx_t_14++) {
18373     __pyx_t_11 = __pyx_t_14;
18374     __pyx_v_c = (__pyx_t_11[0]);
18375 
18376     /* "View.MemoryView":515
18377  *
18378  *         for i, c in enumerate(bytesvalue):
18379  *             itemp[i] = c             # <<<<<<<<<<<<<<
18380  *
18381  *     @cname('getbuffer')
18382  */
18383     __pyx_v_i = __pyx_t_9;
18384 
18385     /* "View.MemoryView":514
18386  *             bytesvalue = struct.pack(self.view.format, value)
18387  *
18388  *         for i, c in enumerate(bytesvalue):             # <<<<<<<<<<<<<<
18389  *             itemp[i] = c
18390  *
18391  */
18392     __pyx_t_9 = (__pyx_t_9 + 1);
18393 
18394     /* "View.MemoryView":515
18395  *
18396  *         for i, c in enumerate(bytesvalue):
18397  *             itemp[i] = c             # <<<<<<<<<<<<<<
18398  *
18399  *     @cname('getbuffer')
18400  */
18401     (__pyx_v_itemp[__pyx_v_i]) = __pyx_v_c;
18402   }
18403   __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
18404 
18405   /* "View.MemoryView":501
18406  *             return result
18407  *
18408  *     cdef assign_item_from_object(self, char *itemp, object value):             # <<<<<<<<<<<<<<
18409  *         """Only used if instantiated manually by the user, or if Cython doesn't
18410  *         know how to convert the type"""
18411  */
18412 
18413   /* function exit code */
18414   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
18415   goto __pyx_L0;
18416   __pyx_L1_error:;
18417   __Pyx_XDECREF(__pyx_t_1);
18418   __Pyx_XDECREF(__pyx_t_4);
18419   __Pyx_XDECREF(__pyx_t_5);
18420   __Pyx_XDECREF(__pyx_t_6);
18421   __Pyx_XDECREF(__pyx_t_8);
18422   __Pyx_XDECREF(__pyx_t_10);
18423   __Pyx_AddTraceback("View.MemoryView.memoryview.assign_item_from_object", __pyx_clineno, __pyx_lineno, __pyx_filename);
18424   __pyx_r = 0;
18425   __pyx_L0:;
18426   __Pyx_XDECREF(__pyx_v_struct);
18427   __Pyx_XDECREF(__pyx_v_bytesvalue);
18428   __Pyx_XGIVEREF(__pyx_r);
18429   __Pyx_RefNannyFinishContext();
18430   return __pyx_r;
18431 }
18432 
18433 /* "View.MemoryView":518
18434  *
18435  *     @cname('getbuffer')
18436  *     def __getbuffer__(self, Py_buffer *info, int flags):             # <<<<<<<<<<<<<<
18437  *         if flags & PyBUF_WRITABLE and self.view.readonly:
18438  *             raise ValueError("Cannot create writable memory view from read-only memoryview")
18439  */
18440 
18441 /* Python wrapper */
18442 static CYTHON_UNUSED int __pyx_memoryview_getbuffer(PyObject *__pyx_v_self, Py_buffer *__pyx_v_info, int __pyx_v_flags); /*proto*/
__pyx_memoryview_getbuffer(PyObject * __pyx_v_self,Py_buffer * __pyx_v_info,int __pyx_v_flags)18443 static CYTHON_UNUSED int __pyx_memoryview_getbuffer(PyObject *__pyx_v_self, Py_buffer *__pyx_v_info, int __pyx_v_flags) {
18444   int __pyx_r;
18445   __Pyx_RefNannyDeclarations
18446   __Pyx_RefNannySetupContext("__getbuffer__ (wrapper)", 0);
18447   __pyx_r = __pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_8__getbuffer__(((struct __pyx_memoryview_obj *)__pyx_v_self), ((Py_buffer *)__pyx_v_info), ((int)__pyx_v_flags));
18448 
18449   /* function exit code */
18450   __Pyx_RefNannyFinishContext();
18451   return __pyx_r;
18452 }
18453 
__pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_8__getbuffer__(struct __pyx_memoryview_obj * __pyx_v_self,Py_buffer * __pyx_v_info,int __pyx_v_flags)18454 static int __pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_8__getbuffer__(struct __pyx_memoryview_obj *__pyx_v_self, Py_buffer *__pyx_v_info, int __pyx_v_flags) {
18455   int __pyx_r;
18456   __Pyx_RefNannyDeclarations
18457   int __pyx_t_1;
18458   int __pyx_t_2;
18459   PyObject *__pyx_t_3 = NULL;
18460   Py_ssize_t *__pyx_t_4;
18461   char *__pyx_t_5;
18462   void *__pyx_t_6;
18463   int __pyx_t_7;
18464   Py_ssize_t __pyx_t_8;
18465   int __pyx_lineno = 0;
18466   const char *__pyx_filename = NULL;
18467   int __pyx_clineno = 0;
18468   if (__pyx_v_info == NULL) {
18469     PyErr_SetString(PyExc_BufferError, "PyObject_GetBuffer: view==NULL argument is obsolete");
18470     return -1;
18471   }
18472   __Pyx_RefNannySetupContext("__getbuffer__", 0);
18473   __pyx_v_info->obj = Py_None; __Pyx_INCREF(Py_None);
18474   __Pyx_GIVEREF(__pyx_v_info->obj);
18475 
18476   /* "View.MemoryView":519
18477  *     @cname('getbuffer')
18478  *     def __getbuffer__(self, Py_buffer *info, int flags):
18479  *         if flags & PyBUF_WRITABLE and self.view.readonly:             # <<<<<<<<<<<<<<
18480  *             raise ValueError("Cannot create writable memory view from read-only memoryview")
18481  *
18482  */
18483   __pyx_t_2 = ((__pyx_v_flags & PyBUF_WRITABLE) != 0);
18484   if (__pyx_t_2) {
18485   } else {
18486     __pyx_t_1 = __pyx_t_2;
18487     goto __pyx_L4_bool_binop_done;
18488   }
18489   __pyx_t_2 = (__pyx_v_self->view.readonly != 0);
18490   __pyx_t_1 = __pyx_t_2;
18491   __pyx_L4_bool_binop_done:;
18492   if (unlikely(__pyx_t_1)) {
18493 
18494     /* "View.MemoryView":520
18495  *     def __getbuffer__(self, Py_buffer *info, int flags):
18496  *         if flags & PyBUF_WRITABLE and self.view.readonly:
18497  *             raise ValueError("Cannot create writable memory view from read-only memoryview")             # <<<<<<<<<<<<<<
18498  *
18499  *         if flags & PyBUF_ND:
18500  */
18501     __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__30, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(3, 520, __pyx_L1_error)
18502     __Pyx_GOTREF(__pyx_t_3);
18503     __Pyx_Raise(__pyx_t_3, 0, 0, 0);
18504     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
18505     __PYX_ERR(3, 520, __pyx_L1_error)
18506 
18507     /* "View.MemoryView":519
18508  *     @cname('getbuffer')
18509  *     def __getbuffer__(self, Py_buffer *info, int flags):
18510  *         if flags & PyBUF_WRITABLE and self.view.readonly:             # <<<<<<<<<<<<<<
18511  *             raise ValueError("Cannot create writable memory view from read-only memoryview")
18512  *
18513  */
18514   }
18515 
18516   /* "View.MemoryView":522
18517  *             raise ValueError("Cannot create writable memory view from read-only memoryview")
18518  *
18519  *         if flags & PyBUF_ND:             # <<<<<<<<<<<<<<
18520  *             info.shape = self.view.shape
18521  *         else:
18522  */
18523   __pyx_t_1 = ((__pyx_v_flags & PyBUF_ND) != 0);
18524   if (__pyx_t_1) {
18525 
18526     /* "View.MemoryView":523
18527  *
18528  *         if flags & PyBUF_ND:
18529  *             info.shape = self.view.shape             # <<<<<<<<<<<<<<
18530  *         else:
18531  *             info.shape = NULL
18532  */
18533     __pyx_t_4 = __pyx_v_self->view.shape;
18534     __pyx_v_info->shape = __pyx_t_4;
18535 
18536     /* "View.MemoryView":522
18537  *             raise ValueError("Cannot create writable memory view from read-only memoryview")
18538  *
18539  *         if flags & PyBUF_ND:             # <<<<<<<<<<<<<<
18540  *             info.shape = self.view.shape
18541  *         else:
18542  */
18543     goto __pyx_L6;
18544   }
18545 
18546   /* "View.MemoryView":525
18547  *             info.shape = self.view.shape
18548  *         else:
18549  *             info.shape = NULL             # <<<<<<<<<<<<<<
18550  *
18551  *         if flags & PyBUF_STRIDES:
18552  */
18553   /*else*/ {
18554     __pyx_v_info->shape = NULL;
18555   }
18556   __pyx_L6:;
18557 
18558   /* "View.MemoryView":527
18559  *             info.shape = NULL
18560  *
18561  *         if flags & PyBUF_STRIDES:             # <<<<<<<<<<<<<<
18562  *             info.strides = self.view.strides
18563  *         else:
18564  */
18565   __pyx_t_1 = ((__pyx_v_flags & PyBUF_STRIDES) != 0);
18566   if (__pyx_t_1) {
18567 
18568     /* "View.MemoryView":528
18569  *
18570  *         if flags & PyBUF_STRIDES:
18571  *             info.strides = self.view.strides             # <<<<<<<<<<<<<<
18572  *         else:
18573  *             info.strides = NULL
18574  */
18575     __pyx_t_4 = __pyx_v_self->view.strides;
18576     __pyx_v_info->strides = __pyx_t_4;
18577 
18578     /* "View.MemoryView":527
18579  *             info.shape = NULL
18580  *
18581  *         if flags & PyBUF_STRIDES:             # <<<<<<<<<<<<<<
18582  *             info.strides = self.view.strides
18583  *         else:
18584  */
18585     goto __pyx_L7;
18586   }
18587 
18588   /* "View.MemoryView":530
18589  *             info.strides = self.view.strides
18590  *         else:
18591  *             info.strides = NULL             # <<<<<<<<<<<<<<
18592  *
18593  *         if flags & PyBUF_INDIRECT:
18594  */
18595   /*else*/ {
18596     __pyx_v_info->strides = NULL;
18597   }
18598   __pyx_L7:;
18599 
18600   /* "View.MemoryView":532
18601  *             info.strides = NULL
18602  *
18603  *         if flags & PyBUF_INDIRECT:             # <<<<<<<<<<<<<<
18604  *             info.suboffsets = self.view.suboffsets
18605  *         else:
18606  */
18607   __pyx_t_1 = ((__pyx_v_flags & PyBUF_INDIRECT) != 0);
18608   if (__pyx_t_1) {
18609 
18610     /* "View.MemoryView":533
18611  *
18612  *         if flags & PyBUF_INDIRECT:
18613  *             info.suboffsets = self.view.suboffsets             # <<<<<<<<<<<<<<
18614  *         else:
18615  *             info.suboffsets = NULL
18616  */
18617     __pyx_t_4 = __pyx_v_self->view.suboffsets;
18618     __pyx_v_info->suboffsets = __pyx_t_4;
18619 
18620     /* "View.MemoryView":532
18621  *             info.strides = NULL
18622  *
18623  *         if flags & PyBUF_INDIRECT:             # <<<<<<<<<<<<<<
18624  *             info.suboffsets = self.view.suboffsets
18625  *         else:
18626  */
18627     goto __pyx_L8;
18628   }
18629 
18630   /* "View.MemoryView":535
18631  *             info.suboffsets = self.view.suboffsets
18632  *         else:
18633  *             info.suboffsets = NULL             # <<<<<<<<<<<<<<
18634  *
18635  *         if flags & PyBUF_FORMAT:
18636  */
18637   /*else*/ {
18638     __pyx_v_info->suboffsets = NULL;
18639   }
18640   __pyx_L8:;
18641 
18642   /* "View.MemoryView":537
18643  *             info.suboffsets = NULL
18644  *
18645  *         if flags & PyBUF_FORMAT:             # <<<<<<<<<<<<<<
18646  *             info.format = self.view.format
18647  *         else:
18648  */
18649   __pyx_t_1 = ((__pyx_v_flags & PyBUF_FORMAT) != 0);
18650   if (__pyx_t_1) {
18651 
18652     /* "View.MemoryView":538
18653  *
18654  *         if flags & PyBUF_FORMAT:
18655  *             info.format = self.view.format             # <<<<<<<<<<<<<<
18656  *         else:
18657  *             info.format = NULL
18658  */
18659     __pyx_t_5 = __pyx_v_self->view.format;
18660     __pyx_v_info->format = __pyx_t_5;
18661 
18662     /* "View.MemoryView":537
18663  *             info.suboffsets = NULL
18664  *
18665  *         if flags & PyBUF_FORMAT:             # <<<<<<<<<<<<<<
18666  *             info.format = self.view.format
18667  *         else:
18668  */
18669     goto __pyx_L9;
18670   }
18671 
18672   /* "View.MemoryView":540
18673  *             info.format = self.view.format
18674  *         else:
18675  *             info.format = NULL             # <<<<<<<<<<<<<<
18676  *
18677  *         info.buf = self.view.buf
18678  */
18679   /*else*/ {
18680     __pyx_v_info->format = NULL;
18681   }
18682   __pyx_L9:;
18683 
18684   /* "View.MemoryView":542
18685  *             info.format = NULL
18686  *
18687  *         info.buf = self.view.buf             # <<<<<<<<<<<<<<
18688  *         info.ndim = self.view.ndim
18689  *         info.itemsize = self.view.itemsize
18690  */
18691   __pyx_t_6 = __pyx_v_self->view.buf;
18692   __pyx_v_info->buf = __pyx_t_6;
18693 
18694   /* "View.MemoryView":543
18695  *
18696  *         info.buf = self.view.buf
18697  *         info.ndim = self.view.ndim             # <<<<<<<<<<<<<<
18698  *         info.itemsize = self.view.itemsize
18699  *         info.len = self.view.len
18700  */
18701   __pyx_t_7 = __pyx_v_self->view.ndim;
18702   __pyx_v_info->ndim = __pyx_t_7;
18703 
18704   /* "View.MemoryView":544
18705  *         info.buf = self.view.buf
18706  *         info.ndim = self.view.ndim
18707  *         info.itemsize = self.view.itemsize             # <<<<<<<<<<<<<<
18708  *         info.len = self.view.len
18709  *         info.readonly = self.view.readonly
18710  */
18711   __pyx_t_8 = __pyx_v_self->view.itemsize;
18712   __pyx_v_info->itemsize = __pyx_t_8;
18713 
18714   /* "View.MemoryView":545
18715  *         info.ndim = self.view.ndim
18716  *         info.itemsize = self.view.itemsize
18717  *         info.len = self.view.len             # <<<<<<<<<<<<<<
18718  *         info.readonly = self.view.readonly
18719  *         info.obj = self
18720  */
18721   __pyx_t_8 = __pyx_v_self->view.len;
18722   __pyx_v_info->len = __pyx_t_8;
18723 
18724   /* "View.MemoryView":546
18725  *         info.itemsize = self.view.itemsize
18726  *         info.len = self.view.len
18727  *         info.readonly = self.view.readonly             # <<<<<<<<<<<<<<
18728  *         info.obj = self
18729  *
18730  */
18731   __pyx_t_1 = __pyx_v_self->view.readonly;
18732   __pyx_v_info->readonly = __pyx_t_1;
18733 
18734   /* "View.MemoryView":547
18735  *         info.len = self.view.len
18736  *         info.readonly = self.view.readonly
18737  *         info.obj = self             # <<<<<<<<<<<<<<
18738  *
18739  *     __pyx_getbuffer = capsule(<void *> &__pyx_memoryview_getbuffer, "getbuffer(obj, view, flags)")
18740  */
18741   __Pyx_INCREF(((PyObject *)__pyx_v_self));
18742   __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
18743   __Pyx_GOTREF(__pyx_v_info->obj);
18744   __Pyx_DECREF(__pyx_v_info->obj);
18745   __pyx_v_info->obj = ((PyObject *)__pyx_v_self);
18746 
18747   /* "View.MemoryView":518
18748  *
18749  *     @cname('getbuffer')
18750  *     def __getbuffer__(self, Py_buffer *info, int flags):             # <<<<<<<<<<<<<<
18751  *         if flags & PyBUF_WRITABLE and self.view.readonly:
18752  *             raise ValueError("Cannot create writable memory view from read-only memoryview")
18753  */
18754 
18755   /* function exit code */
18756   __pyx_r = 0;
18757   goto __pyx_L0;
18758   __pyx_L1_error:;
18759   __Pyx_XDECREF(__pyx_t_3);
18760   __Pyx_AddTraceback("View.MemoryView.memoryview.__getbuffer__", __pyx_clineno, __pyx_lineno, __pyx_filename);
18761   __pyx_r = -1;
18762   if (__pyx_v_info->obj != NULL) {
18763     __Pyx_GOTREF(__pyx_v_info->obj);
18764     __Pyx_DECREF(__pyx_v_info->obj); __pyx_v_info->obj = 0;
18765   }
18766   goto __pyx_L2;
18767   __pyx_L0:;
18768   if (__pyx_v_info->obj == Py_None) {
18769     __Pyx_GOTREF(__pyx_v_info->obj);
18770     __Pyx_DECREF(__pyx_v_info->obj); __pyx_v_info->obj = 0;
18771   }
18772   __pyx_L2:;
18773   __Pyx_RefNannyFinishContext();
18774   return __pyx_r;
18775 }
18776 
18777 /* "View.MemoryView":553
18778  *
18779  *     @property
18780  *     def T(self):             # <<<<<<<<<<<<<<
18781  *         cdef _memoryviewslice result = memoryview_copy(self)
18782  *         transpose_memslice(&result.from_slice)
18783  */
18784 
18785 /* Python wrapper */
18786 static PyObject *__pyx_pw_15View_dot_MemoryView_10memoryview_1T_1__get__(PyObject *__pyx_v_self); /*proto*/
__pyx_pw_15View_dot_MemoryView_10memoryview_1T_1__get__(PyObject * __pyx_v_self)18787 static PyObject *__pyx_pw_15View_dot_MemoryView_10memoryview_1T_1__get__(PyObject *__pyx_v_self) {
18788   PyObject *__pyx_r = 0;
18789   __Pyx_RefNannyDeclarations
18790   __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
18791   __pyx_r = __pyx_pf_15View_dot_MemoryView_10memoryview_1T___get__(((struct __pyx_memoryview_obj *)__pyx_v_self));
18792 
18793   /* function exit code */
18794   __Pyx_RefNannyFinishContext();
18795   return __pyx_r;
18796 }
18797 
__pyx_pf_15View_dot_MemoryView_10memoryview_1T___get__(struct __pyx_memoryview_obj * __pyx_v_self)18798 static PyObject *__pyx_pf_15View_dot_MemoryView_10memoryview_1T___get__(struct __pyx_memoryview_obj *__pyx_v_self) {
18799   struct __pyx_memoryviewslice_obj *__pyx_v_result = 0;
18800   PyObject *__pyx_r = NULL;
18801   __Pyx_RefNannyDeclarations
18802   PyObject *__pyx_t_1 = NULL;
18803   int __pyx_t_2;
18804   int __pyx_lineno = 0;
18805   const char *__pyx_filename = NULL;
18806   int __pyx_clineno = 0;
18807   __Pyx_RefNannySetupContext("__get__", 0);
18808 
18809   /* "View.MemoryView":554
18810  *     @property
18811  *     def T(self):
18812  *         cdef _memoryviewslice result = memoryview_copy(self)             # <<<<<<<<<<<<<<
18813  *         transpose_memslice(&result.from_slice)
18814  *         return result
18815  */
18816   __pyx_t_1 = __pyx_memoryview_copy_object(__pyx_v_self); if (unlikely(!__pyx_t_1)) __PYX_ERR(3, 554, __pyx_L1_error)
18817   __Pyx_GOTREF(__pyx_t_1);
18818   if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_memoryviewslice_type))))) __PYX_ERR(3, 554, __pyx_L1_error)
18819   __pyx_v_result = ((struct __pyx_memoryviewslice_obj *)__pyx_t_1);
18820   __pyx_t_1 = 0;
18821 
18822   /* "View.MemoryView":555
18823  *     def T(self):
18824  *         cdef _memoryviewslice result = memoryview_copy(self)
18825  *         transpose_memslice(&result.from_slice)             # <<<<<<<<<<<<<<
18826  *         return result
18827  *
18828  */
18829   __pyx_t_2 = __pyx_memslice_transpose((&__pyx_v_result->from_slice)); if (unlikely(__pyx_t_2 == ((int)0))) __PYX_ERR(3, 555, __pyx_L1_error)
18830 
18831   /* "View.MemoryView":556
18832  *         cdef _memoryviewslice result = memoryview_copy(self)
18833  *         transpose_memslice(&result.from_slice)
18834  *         return result             # <<<<<<<<<<<<<<
18835  *
18836  *     @property
18837  */
18838   __Pyx_XDECREF(__pyx_r);
18839   __Pyx_INCREF(((PyObject *)__pyx_v_result));
18840   __pyx_r = ((PyObject *)__pyx_v_result);
18841   goto __pyx_L0;
18842 
18843   /* "View.MemoryView":553
18844  *
18845  *     @property
18846  *     def T(self):             # <<<<<<<<<<<<<<
18847  *         cdef _memoryviewslice result = memoryview_copy(self)
18848  *         transpose_memslice(&result.from_slice)
18849  */
18850 
18851   /* function exit code */
18852   __pyx_L1_error:;
18853   __Pyx_XDECREF(__pyx_t_1);
18854   __Pyx_AddTraceback("View.MemoryView.memoryview.T.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
18855   __pyx_r = NULL;
18856   __pyx_L0:;
18857   __Pyx_XDECREF((PyObject *)__pyx_v_result);
18858   __Pyx_XGIVEREF(__pyx_r);
18859   __Pyx_RefNannyFinishContext();
18860   return __pyx_r;
18861 }
18862 
18863 /* "View.MemoryView":559
18864  *
18865  *     @property
18866  *     def base(self):             # <<<<<<<<<<<<<<
18867  *         return self.obj
18868  *
18869  */
18870 
18871 /* Python wrapper */
18872 static PyObject *__pyx_pw_15View_dot_MemoryView_10memoryview_4base_1__get__(PyObject *__pyx_v_self); /*proto*/
__pyx_pw_15View_dot_MemoryView_10memoryview_4base_1__get__(PyObject * __pyx_v_self)18873 static PyObject *__pyx_pw_15View_dot_MemoryView_10memoryview_4base_1__get__(PyObject *__pyx_v_self) {
18874   PyObject *__pyx_r = 0;
18875   __Pyx_RefNannyDeclarations
18876   __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
18877   __pyx_r = __pyx_pf_15View_dot_MemoryView_10memoryview_4base___get__(((struct __pyx_memoryview_obj *)__pyx_v_self));
18878 
18879   /* function exit code */
18880   __Pyx_RefNannyFinishContext();
18881   return __pyx_r;
18882 }
18883 
__pyx_pf_15View_dot_MemoryView_10memoryview_4base___get__(struct __pyx_memoryview_obj * __pyx_v_self)18884 static PyObject *__pyx_pf_15View_dot_MemoryView_10memoryview_4base___get__(struct __pyx_memoryview_obj *__pyx_v_self) {
18885   PyObject *__pyx_r = NULL;
18886   __Pyx_RefNannyDeclarations
18887   __Pyx_RefNannySetupContext("__get__", 0);
18888 
18889   /* "View.MemoryView":560
18890  *     @property
18891  *     def base(self):
18892  *         return self.obj             # <<<<<<<<<<<<<<
18893  *
18894  *     @property
18895  */
18896   __Pyx_XDECREF(__pyx_r);
18897   __Pyx_INCREF(__pyx_v_self->obj);
18898   __pyx_r = __pyx_v_self->obj;
18899   goto __pyx_L0;
18900 
18901   /* "View.MemoryView":559
18902  *
18903  *     @property
18904  *     def base(self):             # <<<<<<<<<<<<<<
18905  *         return self.obj
18906  *
18907  */
18908 
18909   /* function exit code */
18910   __pyx_L0:;
18911   __Pyx_XGIVEREF(__pyx_r);
18912   __Pyx_RefNannyFinishContext();
18913   return __pyx_r;
18914 }
18915 
18916 /* "View.MemoryView":563
18917  *
18918  *     @property
18919  *     def shape(self):             # <<<<<<<<<<<<<<
18920  *         return tuple([length for length in self.view.shape[:self.view.ndim]])
18921  *
18922  */
18923 
18924 /* Python wrapper */
18925 static PyObject *__pyx_pw_15View_dot_MemoryView_10memoryview_5shape_1__get__(PyObject *__pyx_v_self); /*proto*/
__pyx_pw_15View_dot_MemoryView_10memoryview_5shape_1__get__(PyObject * __pyx_v_self)18926 static PyObject *__pyx_pw_15View_dot_MemoryView_10memoryview_5shape_1__get__(PyObject *__pyx_v_self) {
18927   PyObject *__pyx_r = 0;
18928   __Pyx_RefNannyDeclarations
18929   __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
18930   __pyx_r = __pyx_pf_15View_dot_MemoryView_10memoryview_5shape___get__(((struct __pyx_memoryview_obj *)__pyx_v_self));
18931 
18932   /* function exit code */
18933   __Pyx_RefNannyFinishContext();
18934   return __pyx_r;
18935 }
18936 
__pyx_pf_15View_dot_MemoryView_10memoryview_5shape___get__(struct __pyx_memoryview_obj * __pyx_v_self)18937 static PyObject *__pyx_pf_15View_dot_MemoryView_10memoryview_5shape___get__(struct __pyx_memoryview_obj *__pyx_v_self) {
18938   Py_ssize_t __pyx_v_length;
18939   PyObject *__pyx_r = NULL;
18940   __Pyx_RefNannyDeclarations
18941   PyObject *__pyx_t_1 = NULL;
18942   Py_ssize_t *__pyx_t_2;
18943   Py_ssize_t *__pyx_t_3;
18944   Py_ssize_t *__pyx_t_4;
18945   PyObject *__pyx_t_5 = NULL;
18946   int __pyx_lineno = 0;
18947   const char *__pyx_filename = NULL;
18948   int __pyx_clineno = 0;
18949   __Pyx_RefNannySetupContext("__get__", 0);
18950 
18951   /* "View.MemoryView":564
18952  *     @property
18953  *     def shape(self):
18954  *         return tuple([length for length in self.view.shape[:self.view.ndim]])             # <<<<<<<<<<<<<<
18955  *
18956  *     @property
18957  */
18958   __Pyx_XDECREF(__pyx_r);
18959   __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(3, 564, __pyx_L1_error)
18960   __Pyx_GOTREF(__pyx_t_1);
18961   __pyx_t_3 = (__pyx_v_self->view.shape + __pyx_v_self->view.ndim);
18962   for (__pyx_t_4 = __pyx_v_self->view.shape; __pyx_t_4 < __pyx_t_3; __pyx_t_4++) {
18963     __pyx_t_2 = __pyx_t_4;
18964     __pyx_v_length = (__pyx_t_2[0]);
18965     __pyx_t_5 = PyInt_FromSsize_t(__pyx_v_length); if (unlikely(!__pyx_t_5)) __PYX_ERR(3, 564, __pyx_L1_error)
18966     __Pyx_GOTREF(__pyx_t_5);
18967     if (unlikely(__Pyx_ListComp_Append(__pyx_t_1, (PyObject*)__pyx_t_5))) __PYX_ERR(3, 564, __pyx_L1_error)
18968     __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
18969   }
18970   __pyx_t_5 = PyList_AsTuple(((PyObject*)__pyx_t_1)); if (unlikely(!__pyx_t_5)) __PYX_ERR(3, 564, __pyx_L1_error)
18971   __Pyx_GOTREF(__pyx_t_5);
18972   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
18973   __pyx_r = __pyx_t_5;
18974   __pyx_t_5 = 0;
18975   goto __pyx_L0;
18976 
18977   /* "View.MemoryView":563
18978  *
18979  *     @property
18980  *     def shape(self):             # <<<<<<<<<<<<<<
18981  *         return tuple([length for length in self.view.shape[:self.view.ndim]])
18982  *
18983  */
18984 
18985   /* function exit code */
18986   __pyx_L1_error:;
18987   __Pyx_XDECREF(__pyx_t_1);
18988   __Pyx_XDECREF(__pyx_t_5);
18989   __Pyx_AddTraceback("View.MemoryView.memoryview.shape.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
18990   __pyx_r = NULL;
18991   __pyx_L0:;
18992   __Pyx_XGIVEREF(__pyx_r);
18993   __Pyx_RefNannyFinishContext();
18994   return __pyx_r;
18995 }
18996 
18997 /* "View.MemoryView":567
18998  *
18999  *     @property
19000  *     def strides(self):             # <<<<<<<<<<<<<<
19001  *         if self.view.strides == NULL:
19002  *
19003  */
19004 
19005 /* Python wrapper */
19006 static PyObject *__pyx_pw_15View_dot_MemoryView_10memoryview_7strides_1__get__(PyObject *__pyx_v_self); /*proto*/
__pyx_pw_15View_dot_MemoryView_10memoryview_7strides_1__get__(PyObject * __pyx_v_self)19007 static PyObject *__pyx_pw_15View_dot_MemoryView_10memoryview_7strides_1__get__(PyObject *__pyx_v_self) {
19008   PyObject *__pyx_r = 0;
19009   __Pyx_RefNannyDeclarations
19010   __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
19011   __pyx_r = __pyx_pf_15View_dot_MemoryView_10memoryview_7strides___get__(((struct __pyx_memoryview_obj *)__pyx_v_self));
19012 
19013   /* function exit code */
19014   __Pyx_RefNannyFinishContext();
19015   return __pyx_r;
19016 }
19017 
__pyx_pf_15View_dot_MemoryView_10memoryview_7strides___get__(struct __pyx_memoryview_obj * __pyx_v_self)19018 static PyObject *__pyx_pf_15View_dot_MemoryView_10memoryview_7strides___get__(struct __pyx_memoryview_obj *__pyx_v_self) {
19019   Py_ssize_t __pyx_v_stride;
19020   PyObject *__pyx_r = NULL;
19021   __Pyx_RefNannyDeclarations
19022   int __pyx_t_1;
19023   PyObject *__pyx_t_2 = NULL;
19024   Py_ssize_t *__pyx_t_3;
19025   Py_ssize_t *__pyx_t_4;
19026   Py_ssize_t *__pyx_t_5;
19027   PyObject *__pyx_t_6 = NULL;
19028   int __pyx_lineno = 0;
19029   const char *__pyx_filename = NULL;
19030   int __pyx_clineno = 0;
19031   __Pyx_RefNannySetupContext("__get__", 0);
19032 
19033   /* "View.MemoryView":568
19034  *     @property
19035  *     def strides(self):
19036  *         if self.view.strides == NULL:             # <<<<<<<<<<<<<<
19037  *
19038  *             raise ValueError("Buffer view does not expose strides")
19039  */
19040   __pyx_t_1 = ((__pyx_v_self->view.strides == NULL) != 0);
19041   if (unlikely(__pyx_t_1)) {
19042 
19043     /* "View.MemoryView":570
19044  *         if self.view.strides == NULL:
19045  *
19046  *             raise ValueError("Buffer view does not expose strides")             # <<<<<<<<<<<<<<
19047  *
19048  *         return tuple([stride for stride in self.view.strides[:self.view.ndim]])
19049  */
19050     __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__31, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(3, 570, __pyx_L1_error)
19051     __Pyx_GOTREF(__pyx_t_2);
19052     __Pyx_Raise(__pyx_t_2, 0, 0, 0);
19053     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
19054     __PYX_ERR(3, 570, __pyx_L1_error)
19055 
19056     /* "View.MemoryView":568
19057  *     @property
19058  *     def strides(self):
19059  *         if self.view.strides == NULL:             # <<<<<<<<<<<<<<
19060  *
19061  *             raise ValueError("Buffer view does not expose strides")
19062  */
19063   }
19064 
19065   /* "View.MemoryView":572
19066  *             raise ValueError("Buffer view does not expose strides")
19067  *
19068  *         return tuple([stride for stride in self.view.strides[:self.view.ndim]])             # <<<<<<<<<<<<<<
19069  *
19070  *     @property
19071  */
19072   __Pyx_XDECREF(__pyx_r);
19073   __pyx_t_2 = PyList_New(0); if (unlikely(!__pyx_t_2)) __PYX_ERR(3, 572, __pyx_L1_error)
19074   __Pyx_GOTREF(__pyx_t_2);
19075   __pyx_t_4 = (__pyx_v_self->view.strides + __pyx_v_self->view.ndim);
19076   for (__pyx_t_5 = __pyx_v_self->view.strides; __pyx_t_5 < __pyx_t_4; __pyx_t_5++) {
19077     __pyx_t_3 = __pyx_t_5;
19078     __pyx_v_stride = (__pyx_t_3[0]);
19079     __pyx_t_6 = PyInt_FromSsize_t(__pyx_v_stride); if (unlikely(!__pyx_t_6)) __PYX_ERR(3, 572, __pyx_L1_error)
19080     __Pyx_GOTREF(__pyx_t_6);
19081     if (unlikely(__Pyx_ListComp_Append(__pyx_t_2, (PyObject*)__pyx_t_6))) __PYX_ERR(3, 572, __pyx_L1_error)
19082     __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
19083   }
19084   __pyx_t_6 = PyList_AsTuple(((PyObject*)__pyx_t_2)); if (unlikely(!__pyx_t_6)) __PYX_ERR(3, 572, __pyx_L1_error)
19085   __Pyx_GOTREF(__pyx_t_6);
19086   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
19087   __pyx_r = __pyx_t_6;
19088   __pyx_t_6 = 0;
19089   goto __pyx_L0;
19090 
19091   /* "View.MemoryView":567
19092  *
19093  *     @property
19094  *     def strides(self):             # <<<<<<<<<<<<<<
19095  *         if self.view.strides == NULL:
19096  *
19097  */
19098 
19099   /* function exit code */
19100   __pyx_L1_error:;
19101   __Pyx_XDECREF(__pyx_t_2);
19102   __Pyx_XDECREF(__pyx_t_6);
19103   __Pyx_AddTraceback("View.MemoryView.memoryview.strides.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
19104   __pyx_r = NULL;
19105   __pyx_L0:;
19106   __Pyx_XGIVEREF(__pyx_r);
19107   __Pyx_RefNannyFinishContext();
19108   return __pyx_r;
19109 }
19110 
19111 /* "View.MemoryView":575
19112  *
19113  *     @property
19114  *     def suboffsets(self):             # <<<<<<<<<<<<<<
19115  *         if self.view.suboffsets == NULL:
19116  *             return (-1,) * self.view.ndim
19117  */
19118 
19119 /* Python wrapper */
19120 static PyObject *__pyx_pw_15View_dot_MemoryView_10memoryview_10suboffsets_1__get__(PyObject *__pyx_v_self); /*proto*/
__pyx_pw_15View_dot_MemoryView_10memoryview_10suboffsets_1__get__(PyObject * __pyx_v_self)19121 static PyObject *__pyx_pw_15View_dot_MemoryView_10memoryview_10suboffsets_1__get__(PyObject *__pyx_v_self) {
19122   PyObject *__pyx_r = 0;
19123   __Pyx_RefNannyDeclarations
19124   __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
19125   __pyx_r = __pyx_pf_15View_dot_MemoryView_10memoryview_10suboffsets___get__(((struct __pyx_memoryview_obj *)__pyx_v_self));
19126 
19127   /* function exit code */
19128   __Pyx_RefNannyFinishContext();
19129   return __pyx_r;
19130 }
19131 
__pyx_pf_15View_dot_MemoryView_10memoryview_10suboffsets___get__(struct __pyx_memoryview_obj * __pyx_v_self)19132 static PyObject *__pyx_pf_15View_dot_MemoryView_10memoryview_10suboffsets___get__(struct __pyx_memoryview_obj *__pyx_v_self) {
19133   Py_ssize_t __pyx_v_suboffset;
19134   PyObject *__pyx_r = NULL;
19135   __Pyx_RefNannyDeclarations
19136   int __pyx_t_1;
19137   PyObject *__pyx_t_2 = NULL;
19138   PyObject *__pyx_t_3 = NULL;
19139   Py_ssize_t *__pyx_t_4;
19140   Py_ssize_t *__pyx_t_5;
19141   Py_ssize_t *__pyx_t_6;
19142   int __pyx_lineno = 0;
19143   const char *__pyx_filename = NULL;
19144   int __pyx_clineno = 0;
19145   __Pyx_RefNannySetupContext("__get__", 0);
19146 
19147   /* "View.MemoryView":576
19148  *     @property
19149  *     def suboffsets(self):
19150  *         if self.view.suboffsets == NULL:             # <<<<<<<<<<<<<<
19151  *             return (-1,) * self.view.ndim
19152  *
19153  */
19154   __pyx_t_1 = ((__pyx_v_self->view.suboffsets == NULL) != 0);
19155   if (__pyx_t_1) {
19156 
19157     /* "View.MemoryView":577
19158  *     def suboffsets(self):
19159  *         if self.view.suboffsets == NULL:
19160  *             return (-1,) * self.view.ndim             # <<<<<<<<<<<<<<
19161  *
19162  *         return tuple([suboffset for suboffset in self.view.suboffsets[:self.view.ndim]])
19163  */
19164     __Pyx_XDECREF(__pyx_r);
19165     __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_self->view.ndim); if (unlikely(!__pyx_t_2)) __PYX_ERR(3, 577, __pyx_L1_error)
19166     __Pyx_GOTREF(__pyx_t_2);
19167     __pyx_t_3 = PyNumber_Multiply(__pyx_tuple__32, __pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(3, 577, __pyx_L1_error)
19168     __Pyx_GOTREF(__pyx_t_3);
19169     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
19170     __pyx_r = __pyx_t_3;
19171     __pyx_t_3 = 0;
19172     goto __pyx_L0;
19173 
19174     /* "View.MemoryView":576
19175  *     @property
19176  *     def suboffsets(self):
19177  *         if self.view.suboffsets == NULL:             # <<<<<<<<<<<<<<
19178  *             return (-1,) * self.view.ndim
19179  *
19180  */
19181   }
19182 
19183   /* "View.MemoryView":579
19184  *             return (-1,) * self.view.ndim
19185  *
19186  *         return tuple([suboffset for suboffset in self.view.suboffsets[:self.view.ndim]])             # <<<<<<<<<<<<<<
19187  *
19188  *     @property
19189  */
19190   __Pyx_XDECREF(__pyx_r);
19191   __pyx_t_3 = PyList_New(0); if (unlikely(!__pyx_t_3)) __PYX_ERR(3, 579, __pyx_L1_error)
19192   __Pyx_GOTREF(__pyx_t_3);
19193   __pyx_t_5 = (__pyx_v_self->view.suboffsets + __pyx_v_self->view.ndim);
19194   for (__pyx_t_6 = __pyx_v_self->view.suboffsets; __pyx_t_6 < __pyx_t_5; __pyx_t_6++) {
19195     __pyx_t_4 = __pyx_t_6;
19196     __pyx_v_suboffset = (__pyx_t_4[0]);
19197     __pyx_t_2 = PyInt_FromSsize_t(__pyx_v_suboffset); if (unlikely(!__pyx_t_2)) __PYX_ERR(3, 579, __pyx_L1_error)
19198     __Pyx_GOTREF(__pyx_t_2);
19199     if (unlikely(__Pyx_ListComp_Append(__pyx_t_3, (PyObject*)__pyx_t_2))) __PYX_ERR(3, 579, __pyx_L1_error)
19200     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
19201   }
19202   __pyx_t_2 = PyList_AsTuple(((PyObject*)__pyx_t_3)); if (unlikely(!__pyx_t_2)) __PYX_ERR(3, 579, __pyx_L1_error)
19203   __Pyx_GOTREF(__pyx_t_2);
19204   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
19205   __pyx_r = __pyx_t_2;
19206   __pyx_t_2 = 0;
19207   goto __pyx_L0;
19208 
19209   /* "View.MemoryView":575
19210  *
19211  *     @property
19212  *     def suboffsets(self):             # <<<<<<<<<<<<<<
19213  *         if self.view.suboffsets == NULL:
19214  *             return (-1,) * self.view.ndim
19215  */
19216 
19217   /* function exit code */
19218   __pyx_L1_error:;
19219   __Pyx_XDECREF(__pyx_t_2);
19220   __Pyx_XDECREF(__pyx_t_3);
19221   __Pyx_AddTraceback("View.MemoryView.memoryview.suboffsets.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
19222   __pyx_r = NULL;
19223   __pyx_L0:;
19224   __Pyx_XGIVEREF(__pyx_r);
19225   __Pyx_RefNannyFinishContext();
19226   return __pyx_r;
19227 }
19228 
19229 /* "View.MemoryView":582
19230  *
19231  *     @property
19232  *     def ndim(self):             # <<<<<<<<<<<<<<
19233  *         return self.view.ndim
19234  *
19235  */
19236 
19237 /* Python wrapper */
19238 static PyObject *__pyx_pw_15View_dot_MemoryView_10memoryview_4ndim_1__get__(PyObject *__pyx_v_self); /*proto*/
__pyx_pw_15View_dot_MemoryView_10memoryview_4ndim_1__get__(PyObject * __pyx_v_self)19239 static PyObject *__pyx_pw_15View_dot_MemoryView_10memoryview_4ndim_1__get__(PyObject *__pyx_v_self) {
19240   PyObject *__pyx_r = 0;
19241   __Pyx_RefNannyDeclarations
19242   __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
19243   __pyx_r = __pyx_pf_15View_dot_MemoryView_10memoryview_4ndim___get__(((struct __pyx_memoryview_obj *)__pyx_v_self));
19244 
19245   /* function exit code */
19246   __Pyx_RefNannyFinishContext();
19247   return __pyx_r;
19248 }
19249 
__pyx_pf_15View_dot_MemoryView_10memoryview_4ndim___get__(struct __pyx_memoryview_obj * __pyx_v_self)19250 static PyObject *__pyx_pf_15View_dot_MemoryView_10memoryview_4ndim___get__(struct __pyx_memoryview_obj *__pyx_v_self) {
19251   PyObject *__pyx_r = NULL;
19252   __Pyx_RefNannyDeclarations
19253   PyObject *__pyx_t_1 = NULL;
19254   int __pyx_lineno = 0;
19255   const char *__pyx_filename = NULL;
19256   int __pyx_clineno = 0;
19257   __Pyx_RefNannySetupContext("__get__", 0);
19258 
19259   /* "View.MemoryView":583
19260  *     @property
19261  *     def ndim(self):
19262  *         return self.view.ndim             # <<<<<<<<<<<<<<
19263  *
19264  *     @property
19265  */
19266   __Pyx_XDECREF(__pyx_r);
19267   __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_self->view.ndim); if (unlikely(!__pyx_t_1)) __PYX_ERR(3, 583, __pyx_L1_error)
19268   __Pyx_GOTREF(__pyx_t_1);
19269   __pyx_r = __pyx_t_1;
19270   __pyx_t_1 = 0;
19271   goto __pyx_L0;
19272 
19273   /* "View.MemoryView":582
19274  *
19275  *     @property
19276  *     def ndim(self):             # <<<<<<<<<<<<<<
19277  *         return self.view.ndim
19278  *
19279  */
19280 
19281   /* function exit code */
19282   __pyx_L1_error:;
19283   __Pyx_XDECREF(__pyx_t_1);
19284   __Pyx_AddTraceback("View.MemoryView.memoryview.ndim.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
19285   __pyx_r = NULL;
19286   __pyx_L0:;
19287   __Pyx_XGIVEREF(__pyx_r);
19288   __Pyx_RefNannyFinishContext();
19289   return __pyx_r;
19290 }
19291 
19292 /* "View.MemoryView":586
19293  *
19294  *     @property
19295  *     def itemsize(self):             # <<<<<<<<<<<<<<
19296  *         return self.view.itemsize
19297  *
19298  */
19299 
19300 /* Python wrapper */
19301 static PyObject *__pyx_pw_15View_dot_MemoryView_10memoryview_8itemsize_1__get__(PyObject *__pyx_v_self); /*proto*/
__pyx_pw_15View_dot_MemoryView_10memoryview_8itemsize_1__get__(PyObject * __pyx_v_self)19302 static PyObject *__pyx_pw_15View_dot_MemoryView_10memoryview_8itemsize_1__get__(PyObject *__pyx_v_self) {
19303   PyObject *__pyx_r = 0;
19304   __Pyx_RefNannyDeclarations
19305   __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
19306   __pyx_r = __pyx_pf_15View_dot_MemoryView_10memoryview_8itemsize___get__(((struct __pyx_memoryview_obj *)__pyx_v_self));
19307 
19308   /* function exit code */
19309   __Pyx_RefNannyFinishContext();
19310   return __pyx_r;
19311 }
19312 
__pyx_pf_15View_dot_MemoryView_10memoryview_8itemsize___get__(struct __pyx_memoryview_obj * __pyx_v_self)19313 static PyObject *__pyx_pf_15View_dot_MemoryView_10memoryview_8itemsize___get__(struct __pyx_memoryview_obj *__pyx_v_self) {
19314   PyObject *__pyx_r = NULL;
19315   __Pyx_RefNannyDeclarations
19316   PyObject *__pyx_t_1 = NULL;
19317   int __pyx_lineno = 0;
19318   const char *__pyx_filename = NULL;
19319   int __pyx_clineno = 0;
19320   __Pyx_RefNannySetupContext("__get__", 0);
19321 
19322   /* "View.MemoryView":587
19323  *     @property
19324  *     def itemsize(self):
19325  *         return self.view.itemsize             # <<<<<<<<<<<<<<
19326  *
19327  *     @property
19328  */
19329   __Pyx_XDECREF(__pyx_r);
19330   __pyx_t_1 = PyInt_FromSsize_t(__pyx_v_self->view.itemsize); if (unlikely(!__pyx_t_1)) __PYX_ERR(3, 587, __pyx_L1_error)
19331   __Pyx_GOTREF(__pyx_t_1);
19332   __pyx_r = __pyx_t_1;
19333   __pyx_t_1 = 0;
19334   goto __pyx_L0;
19335 
19336   /* "View.MemoryView":586
19337  *
19338  *     @property
19339  *     def itemsize(self):             # <<<<<<<<<<<<<<
19340  *         return self.view.itemsize
19341  *
19342  */
19343 
19344   /* function exit code */
19345   __pyx_L1_error:;
19346   __Pyx_XDECREF(__pyx_t_1);
19347   __Pyx_AddTraceback("View.MemoryView.memoryview.itemsize.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
19348   __pyx_r = NULL;
19349   __pyx_L0:;
19350   __Pyx_XGIVEREF(__pyx_r);
19351   __Pyx_RefNannyFinishContext();
19352   return __pyx_r;
19353 }
19354 
19355 /* "View.MemoryView":590
19356  *
19357  *     @property
19358  *     def nbytes(self):             # <<<<<<<<<<<<<<
19359  *         return self.size * self.view.itemsize
19360  *
19361  */
19362 
19363 /* Python wrapper */
19364 static PyObject *__pyx_pw_15View_dot_MemoryView_10memoryview_6nbytes_1__get__(PyObject *__pyx_v_self); /*proto*/
__pyx_pw_15View_dot_MemoryView_10memoryview_6nbytes_1__get__(PyObject * __pyx_v_self)19365 static PyObject *__pyx_pw_15View_dot_MemoryView_10memoryview_6nbytes_1__get__(PyObject *__pyx_v_self) {
19366   PyObject *__pyx_r = 0;
19367   __Pyx_RefNannyDeclarations
19368   __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
19369   __pyx_r = __pyx_pf_15View_dot_MemoryView_10memoryview_6nbytes___get__(((struct __pyx_memoryview_obj *)__pyx_v_self));
19370 
19371   /* function exit code */
19372   __Pyx_RefNannyFinishContext();
19373   return __pyx_r;
19374 }
19375 
__pyx_pf_15View_dot_MemoryView_10memoryview_6nbytes___get__(struct __pyx_memoryview_obj * __pyx_v_self)19376 static PyObject *__pyx_pf_15View_dot_MemoryView_10memoryview_6nbytes___get__(struct __pyx_memoryview_obj *__pyx_v_self) {
19377   PyObject *__pyx_r = NULL;
19378   __Pyx_RefNannyDeclarations
19379   PyObject *__pyx_t_1 = NULL;
19380   PyObject *__pyx_t_2 = NULL;
19381   PyObject *__pyx_t_3 = NULL;
19382   int __pyx_lineno = 0;
19383   const char *__pyx_filename = NULL;
19384   int __pyx_clineno = 0;
19385   __Pyx_RefNannySetupContext("__get__", 0);
19386 
19387   /* "View.MemoryView":591
19388  *     @property
19389  *     def nbytes(self):
19390  *         return self.size * self.view.itemsize             # <<<<<<<<<<<<<<
19391  *
19392  *     @property
19393  */
19394   __Pyx_XDECREF(__pyx_r);
19395   __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_size); if (unlikely(!__pyx_t_1)) __PYX_ERR(3, 591, __pyx_L1_error)
19396   __Pyx_GOTREF(__pyx_t_1);
19397   __pyx_t_2 = PyInt_FromSsize_t(__pyx_v_self->view.itemsize); if (unlikely(!__pyx_t_2)) __PYX_ERR(3, 591, __pyx_L1_error)
19398   __Pyx_GOTREF(__pyx_t_2);
19399   __pyx_t_3 = PyNumber_Multiply(__pyx_t_1, __pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(3, 591, __pyx_L1_error)
19400   __Pyx_GOTREF(__pyx_t_3);
19401   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
19402   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
19403   __pyx_r = __pyx_t_3;
19404   __pyx_t_3 = 0;
19405   goto __pyx_L0;
19406 
19407   /* "View.MemoryView":590
19408  *
19409  *     @property
19410  *     def nbytes(self):             # <<<<<<<<<<<<<<
19411  *         return self.size * self.view.itemsize
19412  *
19413  */
19414 
19415   /* function exit code */
19416   __pyx_L1_error:;
19417   __Pyx_XDECREF(__pyx_t_1);
19418   __Pyx_XDECREF(__pyx_t_2);
19419   __Pyx_XDECREF(__pyx_t_3);
19420   __Pyx_AddTraceback("View.MemoryView.memoryview.nbytes.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
19421   __pyx_r = NULL;
19422   __pyx_L0:;
19423   __Pyx_XGIVEREF(__pyx_r);
19424   __Pyx_RefNannyFinishContext();
19425   return __pyx_r;
19426 }
19427 
19428 /* "View.MemoryView":594
19429  *
19430  *     @property
19431  *     def size(self):             # <<<<<<<<<<<<<<
19432  *         if self._size is None:
19433  *             result = 1
19434  */
19435 
19436 /* Python wrapper */
19437 static PyObject *__pyx_pw_15View_dot_MemoryView_10memoryview_4size_1__get__(PyObject *__pyx_v_self); /*proto*/
__pyx_pw_15View_dot_MemoryView_10memoryview_4size_1__get__(PyObject * __pyx_v_self)19438 static PyObject *__pyx_pw_15View_dot_MemoryView_10memoryview_4size_1__get__(PyObject *__pyx_v_self) {
19439   PyObject *__pyx_r = 0;
19440   __Pyx_RefNannyDeclarations
19441   __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
19442   __pyx_r = __pyx_pf_15View_dot_MemoryView_10memoryview_4size___get__(((struct __pyx_memoryview_obj *)__pyx_v_self));
19443 
19444   /* function exit code */
19445   __Pyx_RefNannyFinishContext();
19446   return __pyx_r;
19447 }
19448 
__pyx_pf_15View_dot_MemoryView_10memoryview_4size___get__(struct __pyx_memoryview_obj * __pyx_v_self)19449 static PyObject *__pyx_pf_15View_dot_MemoryView_10memoryview_4size___get__(struct __pyx_memoryview_obj *__pyx_v_self) {
19450   PyObject *__pyx_v_result = NULL;
19451   PyObject *__pyx_v_length = NULL;
19452   PyObject *__pyx_r = NULL;
19453   __Pyx_RefNannyDeclarations
19454   int __pyx_t_1;
19455   int __pyx_t_2;
19456   Py_ssize_t *__pyx_t_3;
19457   Py_ssize_t *__pyx_t_4;
19458   Py_ssize_t *__pyx_t_5;
19459   PyObject *__pyx_t_6 = NULL;
19460   int __pyx_lineno = 0;
19461   const char *__pyx_filename = NULL;
19462   int __pyx_clineno = 0;
19463   __Pyx_RefNannySetupContext("__get__", 0);
19464 
19465   /* "View.MemoryView":595
19466  *     @property
19467  *     def size(self):
19468  *         if self._size is None:             # <<<<<<<<<<<<<<
19469  *             result = 1
19470  *
19471  */
19472   __pyx_t_1 = (__pyx_v_self->_size == Py_None);
19473   __pyx_t_2 = (__pyx_t_1 != 0);
19474   if (__pyx_t_2) {
19475 
19476     /* "View.MemoryView":596
19477  *     def size(self):
19478  *         if self._size is None:
19479  *             result = 1             # <<<<<<<<<<<<<<
19480  *
19481  *             for length in self.view.shape[:self.view.ndim]:
19482  */
19483     __Pyx_INCREF(__pyx_int_1);
19484     __pyx_v_result = __pyx_int_1;
19485 
19486     /* "View.MemoryView":598
19487  *             result = 1
19488  *
19489  *             for length in self.view.shape[:self.view.ndim]:             # <<<<<<<<<<<<<<
19490  *                 result *= length
19491  *
19492  */
19493     __pyx_t_4 = (__pyx_v_self->view.shape + __pyx_v_self->view.ndim);
19494     for (__pyx_t_5 = __pyx_v_self->view.shape; __pyx_t_5 < __pyx_t_4; __pyx_t_5++) {
19495       __pyx_t_3 = __pyx_t_5;
19496       __pyx_t_6 = PyInt_FromSsize_t((__pyx_t_3[0])); if (unlikely(!__pyx_t_6)) __PYX_ERR(3, 598, __pyx_L1_error)
19497       __Pyx_GOTREF(__pyx_t_6);
19498       __Pyx_XDECREF_SET(__pyx_v_length, __pyx_t_6);
19499       __pyx_t_6 = 0;
19500 
19501       /* "View.MemoryView":599
19502  *
19503  *             for length in self.view.shape[:self.view.ndim]:
19504  *                 result *= length             # <<<<<<<<<<<<<<
19505  *
19506  *             self._size = result
19507  */
19508       __pyx_t_6 = PyNumber_InPlaceMultiply(__pyx_v_result, __pyx_v_length); if (unlikely(!__pyx_t_6)) __PYX_ERR(3, 599, __pyx_L1_error)
19509       __Pyx_GOTREF(__pyx_t_6);
19510       __Pyx_DECREF_SET(__pyx_v_result, __pyx_t_6);
19511       __pyx_t_6 = 0;
19512     }
19513 
19514     /* "View.MemoryView":601
19515  *                 result *= length
19516  *
19517  *             self._size = result             # <<<<<<<<<<<<<<
19518  *
19519  *         return self._size
19520  */
19521     __Pyx_INCREF(__pyx_v_result);
19522     __Pyx_GIVEREF(__pyx_v_result);
19523     __Pyx_GOTREF(__pyx_v_self->_size);
19524     __Pyx_DECREF(__pyx_v_self->_size);
19525     __pyx_v_self->_size = __pyx_v_result;
19526 
19527     /* "View.MemoryView":595
19528  *     @property
19529  *     def size(self):
19530  *         if self._size is None:             # <<<<<<<<<<<<<<
19531  *             result = 1
19532  *
19533  */
19534   }
19535 
19536   /* "View.MemoryView":603
19537  *             self._size = result
19538  *
19539  *         return self._size             # <<<<<<<<<<<<<<
19540  *
19541  *     def __len__(self):
19542  */
19543   __Pyx_XDECREF(__pyx_r);
19544   __Pyx_INCREF(__pyx_v_self->_size);
19545   __pyx_r = __pyx_v_self->_size;
19546   goto __pyx_L0;
19547 
19548   /* "View.MemoryView":594
19549  *
19550  *     @property
19551  *     def size(self):             # <<<<<<<<<<<<<<
19552  *         if self._size is None:
19553  *             result = 1
19554  */
19555 
19556   /* function exit code */
19557   __pyx_L1_error:;
19558   __Pyx_XDECREF(__pyx_t_6);
19559   __Pyx_AddTraceback("View.MemoryView.memoryview.size.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
19560   __pyx_r = NULL;
19561   __pyx_L0:;
19562   __Pyx_XDECREF(__pyx_v_result);
19563   __Pyx_XDECREF(__pyx_v_length);
19564   __Pyx_XGIVEREF(__pyx_r);
19565   __Pyx_RefNannyFinishContext();
19566   return __pyx_r;
19567 }
19568 
19569 /* "View.MemoryView":605
19570  *         return self._size
19571  *
19572  *     def __len__(self):             # <<<<<<<<<<<<<<
19573  *         if self.view.ndim >= 1:
19574  *             return self.view.shape[0]
19575  */
19576 
19577 /* Python wrapper */
19578 static Py_ssize_t __pyx_memoryview___len__(PyObject *__pyx_v_self); /*proto*/
__pyx_memoryview___len__(PyObject * __pyx_v_self)19579 static Py_ssize_t __pyx_memoryview___len__(PyObject *__pyx_v_self) {
19580   Py_ssize_t __pyx_r;
19581   __Pyx_RefNannyDeclarations
19582   __Pyx_RefNannySetupContext("__len__ (wrapper)", 0);
19583   __pyx_r = __pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_10__len__(((struct __pyx_memoryview_obj *)__pyx_v_self));
19584 
19585   /* function exit code */
19586   __Pyx_RefNannyFinishContext();
19587   return __pyx_r;
19588 }
19589 
__pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_10__len__(struct __pyx_memoryview_obj * __pyx_v_self)19590 static Py_ssize_t __pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_10__len__(struct __pyx_memoryview_obj *__pyx_v_self) {
19591   Py_ssize_t __pyx_r;
19592   __Pyx_RefNannyDeclarations
19593   int __pyx_t_1;
19594   __Pyx_RefNannySetupContext("__len__", 0);
19595 
19596   /* "View.MemoryView":606
19597  *
19598  *     def __len__(self):
19599  *         if self.view.ndim >= 1:             # <<<<<<<<<<<<<<
19600  *             return self.view.shape[0]
19601  *
19602  */
19603   __pyx_t_1 = ((__pyx_v_self->view.ndim >= 1) != 0);
19604   if (__pyx_t_1) {
19605 
19606     /* "View.MemoryView":607
19607  *     def __len__(self):
19608  *         if self.view.ndim >= 1:
19609  *             return self.view.shape[0]             # <<<<<<<<<<<<<<
19610  *
19611  *         return 0
19612  */
19613     __pyx_r = (__pyx_v_self->view.shape[0]);
19614     goto __pyx_L0;
19615 
19616     /* "View.MemoryView":606
19617  *
19618  *     def __len__(self):
19619  *         if self.view.ndim >= 1:             # <<<<<<<<<<<<<<
19620  *             return self.view.shape[0]
19621  *
19622  */
19623   }
19624 
19625   /* "View.MemoryView":609
19626  *             return self.view.shape[0]
19627  *
19628  *         return 0             # <<<<<<<<<<<<<<
19629  *
19630  *     def __repr__(self):
19631  */
19632   __pyx_r = 0;
19633   goto __pyx_L0;
19634 
19635   /* "View.MemoryView":605
19636  *         return self._size
19637  *
19638  *     def __len__(self):             # <<<<<<<<<<<<<<
19639  *         if self.view.ndim >= 1:
19640  *             return self.view.shape[0]
19641  */
19642 
19643   /* function exit code */
19644   __pyx_L0:;
19645   __Pyx_RefNannyFinishContext();
19646   return __pyx_r;
19647 }
19648 
19649 /* "View.MemoryView":611
19650  *         return 0
19651  *
19652  *     def __repr__(self):             # <<<<<<<<<<<<<<
19653  *         return "<MemoryView of %r at 0x%x>" % (self.base.__class__.__name__,
19654  *                                                id(self))
19655  */
19656 
19657 /* Python wrapper */
19658 static PyObject *__pyx_memoryview___repr__(PyObject *__pyx_v_self); /*proto*/
__pyx_memoryview___repr__(PyObject * __pyx_v_self)19659 static PyObject *__pyx_memoryview___repr__(PyObject *__pyx_v_self) {
19660   PyObject *__pyx_r = 0;
19661   __Pyx_RefNannyDeclarations
19662   __Pyx_RefNannySetupContext("__repr__ (wrapper)", 0);
19663   __pyx_r = __pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_12__repr__(((struct __pyx_memoryview_obj *)__pyx_v_self));
19664 
19665   /* function exit code */
19666   __Pyx_RefNannyFinishContext();
19667   return __pyx_r;
19668 }
19669 
__pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_12__repr__(struct __pyx_memoryview_obj * __pyx_v_self)19670 static PyObject *__pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_12__repr__(struct __pyx_memoryview_obj *__pyx_v_self) {
19671   PyObject *__pyx_r = NULL;
19672   __Pyx_RefNannyDeclarations
19673   PyObject *__pyx_t_1 = NULL;
19674   PyObject *__pyx_t_2 = NULL;
19675   PyObject *__pyx_t_3 = NULL;
19676   int __pyx_lineno = 0;
19677   const char *__pyx_filename = NULL;
19678   int __pyx_clineno = 0;
19679   __Pyx_RefNannySetupContext("__repr__", 0);
19680 
19681   /* "View.MemoryView":612
19682  *
19683  *     def __repr__(self):
19684  *         return "<MemoryView of %r at 0x%x>" % (self.base.__class__.__name__,             # <<<<<<<<<<<<<<
19685  *                                                id(self))
19686  *
19687  */
19688   __Pyx_XDECREF(__pyx_r);
19689   __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_base); if (unlikely(!__pyx_t_1)) __PYX_ERR(3, 612, __pyx_L1_error)
19690   __Pyx_GOTREF(__pyx_t_1);
19691   __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_class); if (unlikely(!__pyx_t_2)) __PYX_ERR(3, 612, __pyx_L1_error)
19692   __Pyx_GOTREF(__pyx_t_2);
19693   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
19694   __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_name_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(3, 612, __pyx_L1_error)
19695   __Pyx_GOTREF(__pyx_t_1);
19696   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
19697 
19698   /* "View.MemoryView":613
19699  *     def __repr__(self):
19700  *         return "<MemoryView of %r at 0x%x>" % (self.base.__class__.__name__,
19701  *                                                id(self))             # <<<<<<<<<<<<<<
19702  *
19703  *     def __str__(self):
19704  */
19705   __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_builtin_id, ((PyObject *)__pyx_v_self)); if (unlikely(!__pyx_t_2)) __PYX_ERR(3, 613, __pyx_L1_error)
19706   __Pyx_GOTREF(__pyx_t_2);
19707 
19708   /* "View.MemoryView":612
19709  *
19710  *     def __repr__(self):
19711  *         return "<MemoryView of %r at 0x%x>" % (self.base.__class__.__name__,             # <<<<<<<<<<<<<<
19712  *                                                id(self))
19713  *
19714  */
19715   __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(3, 612, __pyx_L1_error)
19716   __Pyx_GOTREF(__pyx_t_3);
19717   __Pyx_GIVEREF(__pyx_t_1);
19718   PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_1);
19719   __Pyx_GIVEREF(__pyx_t_2);
19720   PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_2);
19721   __pyx_t_1 = 0;
19722   __pyx_t_2 = 0;
19723   __pyx_t_2 = __Pyx_PyString_Format(__pyx_kp_s_MemoryView_of_r_at_0x_x, __pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(3, 612, __pyx_L1_error)
19724   __Pyx_GOTREF(__pyx_t_2);
19725   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
19726   __pyx_r = __pyx_t_2;
19727   __pyx_t_2 = 0;
19728   goto __pyx_L0;
19729 
19730   /* "View.MemoryView":611
19731  *         return 0
19732  *
19733  *     def __repr__(self):             # <<<<<<<<<<<<<<
19734  *         return "<MemoryView of %r at 0x%x>" % (self.base.__class__.__name__,
19735  *                                                id(self))
19736  */
19737 
19738   /* function exit code */
19739   __pyx_L1_error:;
19740   __Pyx_XDECREF(__pyx_t_1);
19741   __Pyx_XDECREF(__pyx_t_2);
19742   __Pyx_XDECREF(__pyx_t_3);
19743   __Pyx_AddTraceback("View.MemoryView.memoryview.__repr__", __pyx_clineno, __pyx_lineno, __pyx_filename);
19744   __pyx_r = NULL;
19745   __pyx_L0:;
19746   __Pyx_XGIVEREF(__pyx_r);
19747   __Pyx_RefNannyFinishContext();
19748   return __pyx_r;
19749 }
19750 
19751 /* "View.MemoryView":615
19752  *                                                id(self))
19753  *
19754  *     def __str__(self):             # <<<<<<<<<<<<<<
19755  *         return "<MemoryView of %r object>" % (self.base.__class__.__name__,)
19756  *
19757  */
19758 
19759 /* Python wrapper */
19760 static PyObject *__pyx_memoryview___str__(PyObject *__pyx_v_self); /*proto*/
__pyx_memoryview___str__(PyObject * __pyx_v_self)19761 static PyObject *__pyx_memoryview___str__(PyObject *__pyx_v_self) {
19762   PyObject *__pyx_r = 0;
19763   __Pyx_RefNannyDeclarations
19764   __Pyx_RefNannySetupContext("__str__ (wrapper)", 0);
19765   __pyx_r = __pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_14__str__(((struct __pyx_memoryview_obj *)__pyx_v_self));
19766 
19767   /* function exit code */
19768   __Pyx_RefNannyFinishContext();
19769   return __pyx_r;
19770 }
19771 
__pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_14__str__(struct __pyx_memoryview_obj * __pyx_v_self)19772 static PyObject *__pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_14__str__(struct __pyx_memoryview_obj *__pyx_v_self) {
19773   PyObject *__pyx_r = NULL;
19774   __Pyx_RefNannyDeclarations
19775   PyObject *__pyx_t_1 = NULL;
19776   PyObject *__pyx_t_2 = NULL;
19777   int __pyx_lineno = 0;
19778   const char *__pyx_filename = NULL;
19779   int __pyx_clineno = 0;
19780   __Pyx_RefNannySetupContext("__str__", 0);
19781 
19782   /* "View.MemoryView":616
19783  *
19784  *     def __str__(self):
19785  *         return "<MemoryView of %r object>" % (self.base.__class__.__name__,)             # <<<<<<<<<<<<<<
19786  *
19787  *
19788  */
19789   __Pyx_XDECREF(__pyx_r);
19790   __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_base); if (unlikely(!__pyx_t_1)) __PYX_ERR(3, 616, __pyx_L1_error)
19791   __Pyx_GOTREF(__pyx_t_1);
19792   __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_class); if (unlikely(!__pyx_t_2)) __PYX_ERR(3, 616, __pyx_L1_error)
19793   __Pyx_GOTREF(__pyx_t_2);
19794   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
19795   __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_name_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(3, 616, __pyx_L1_error)
19796   __Pyx_GOTREF(__pyx_t_1);
19797   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
19798   __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(3, 616, __pyx_L1_error)
19799   __Pyx_GOTREF(__pyx_t_2);
19800   __Pyx_GIVEREF(__pyx_t_1);
19801   PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_1);
19802   __pyx_t_1 = 0;
19803   __pyx_t_1 = __Pyx_PyString_Format(__pyx_kp_s_MemoryView_of_r_object, __pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(3, 616, __pyx_L1_error)
19804   __Pyx_GOTREF(__pyx_t_1);
19805   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
19806   __pyx_r = __pyx_t_1;
19807   __pyx_t_1 = 0;
19808   goto __pyx_L0;
19809 
19810   /* "View.MemoryView":615
19811  *                                                id(self))
19812  *
19813  *     def __str__(self):             # <<<<<<<<<<<<<<
19814  *         return "<MemoryView of %r object>" % (self.base.__class__.__name__,)
19815  *
19816  */
19817 
19818   /* function exit code */
19819   __pyx_L1_error:;
19820   __Pyx_XDECREF(__pyx_t_1);
19821   __Pyx_XDECREF(__pyx_t_2);
19822   __Pyx_AddTraceback("View.MemoryView.memoryview.__str__", __pyx_clineno, __pyx_lineno, __pyx_filename);
19823   __pyx_r = NULL;
19824   __pyx_L0:;
19825   __Pyx_XGIVEREF(__pyx_r);
19826   __Pyx_RefNannyFinishContext();
19827   return __pyx_r;
19828 }
19829 
19830 /* "View.MemoryView":619
19831  *
19832  *
19833  *     def is_c_contig(self):             # <<<<<<<<<<<<<<
19834  *         cdef __Pyx_memviewslice *mslice
19835  *         cdef __Pyx_memviewslice tmp
19836  */
19837 
19838 /* Python wrapper */
19839 static PyObject *__pyx_memoryview_is_c_contig(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
__pyx_memoryview_is_c_contig(PyObject * __pyx_v_self,CYTHON_UNUSED PyObject * unused)19840 static PyObject *__pyx_memoryview_is_c_contig(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
19841   PyObject *__pyx_r = 0;
19842   __Pyx_RefNannyDeclarations
19843   __Pyx_RefNannySetupContext("is_c_contig (wrapper)", 0);
19844   __pyx_r = __pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_16is_c_contig(((struct __pyx_memoryview_obj *)__pyx_v_self));
19845 
19846   /* function exit code */
19847   __Pyx_RefNannyFinishContext();
19848   return __pyx_r;
19849 }
19850 
__pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_16is_c_contig(struct __pyx_memoryview_obj * __pyx_v_self)19851 static PyObject *__pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_16is_c_contig(struct __pyx_memoryview_obj *__pyx_v_self) {
19852   __Pyx_memviewslice *__pyx_v_mslice;
19853   __Pyx_memviewslice __pyx_v_tmp;
19854   PyObject *__pyx_r = NULL;
19855   __Pyx_RefNannyDeclarations
19856   __Pyx_memviewslice *__pyx_t_1;
19857   PyObject *__pyx_t_2 = NULL;
19858   int __pyx_lineno = 0;
19859   const char *__pyx_filename = NULL;
19860   int __pyx_clineno = 0;
19861   __Pyx_RefNannySetupContext("is_c_contig", 0);
19862 
19863   /* "View.MemoryView":622
19864  *         cdef __Pyx_memviewslice *mslice
19865  *         cdef __Pyx_memviewslice tmp
19866  *         mslice = get_slice_from_memview(self, &tmp)             # <<<<<<<<<<<<<<
19867  *         return slice_is_contig(mslice[0], 'C', self.view.ndim)
19868  *
19869  */
19870   __pyx_t_1 = __pyx_memoryview_get_slice_from_memoryview(__pyx_v_self, (&__pyx_v_tmp)); if (unlikely(__pyx_t_1 == ((__Pyx_memviewslice *)NULL))) __PYX_ERR(3, 622, __pyx_L1_error)
19871   __pyx_v_mslice = __pyx_t_1;
19872 
19873   /* "View.MemoryView":623
19874  *         cdef __Pyx_memviewslice tmp
19875  *         mslice = get_slice_from_memview(self, &tmp)
19876  *         return slice_is_contig(mslice[0], 'C', self.view.ndim)             # <<<<<<<<<<<<<<
19877  *
19878  *     def is_f_contig(self):
19879  */
19880   __Pyx_XDECREF(__pyx_r);
19881   __pyx_t_2 = __Pyx_PyBool_FromLong(__pyx_memviewslice_is_contig((__pyx_v_mslice[0]), 'C', __pyx_v_self->view.ndim)); if (unlikely(!__pyx_t_2)) __PYX_ERR(3, 623, __pyx_L1_error)
19882   __Pyx_GOTREF(__pyx_t_2);
19883   __pyx_r = __pyx_t_2;
19884   __pyx_t_2 = 0;
19885   goto __pyx_L0;
19886 
19887   /* "View.MemoryView":619
19888  *
19889  *
19890  *     def is_c_contig(self):             # <<<<<<<<<<<<<<
19891  *         cdef __Pyx_memviewslice *mslice
19892  *         cdef __Pyx_memviewslice tmp
19893  */
19894 
19895   /* function exit code */
19896   __pyx_L1_error:;
19897   __Pyx_XDECREF(__pyx_t_2);
19898   __Pyx_AddTraceback("View.MemoryView.memoryview.is_c_contig", __pyx_clineno, __pyx_lineno, __pyx_filename);
19899   __pyx_r = NULL;
19900   __pyx_L0:;
19901   __Pyx_XGIVEREF(__pyx_r);
19902   __Pyx_RefNannyFinishContext();
19903   return __pyx_r;
19904 }
19905 
19906 /* "View.MemoryView":625
19907  *         return slice_is_contig(mslice[0], 'C', self.view.ndim)
19908  *
19909  *     def is_f_contig(self):             # <<<<<<<<<<<<<<
19910  *         cdef __Pyx_memviewslice *mslice
19911  *         cdef __Pyx_memviewslice tmp
19912  */
19913 
19914 /* Python wrapper */
19915 static PyObject *__pyx_memoryview_is_f_contig(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
__pyx_memoryview_is_f_contig(PyObject * __pyx_v_self,CYTHON_UNUSED PyObject * unused)19916 static PyObject *__pyx_memoryview_is_f_contig(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
19917   PyObject *__pyx_r = 0;
19918   __Pyx_RefNannyDeclarations
19919   __Pyx_RefNannySetupContext("is_f_contig (wrapper)", 0);
19920   __pyx_r = __pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_18is_f_contig(((struct __pyx_memoryview_obj *)__pyx_v_self));
19921 
19922   /* function exit code */
19923   __Pyx_RefNannyFinishContext();
19924   return __pyx_r;
19925 }
19926 
__pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_18is_f_contig(struct __pyx_memoryview_obj * __pyx_v_self)19927 static PyObject *__pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_18is_f_contig(struct __pyx_memoryview_obj *__pyx_v_self) {
19928   __Pyx_memviewslice *__pyx_v_mslice;
19929   __Pyx_memviewslice __pyx_v_tmp;
19930   PyObject *__pyx_r = NULL;
19931   __Pyx_RefNannyDeclarations
19932   __Pyx_memviewslice *__pyx_t_1;
19933   PyObject *__pyx_t_2 = NULL;
19934   int __pyx_lineno = 0;
19935   const char *__pyx_filename = NULL;
19936   int __pyx_clineno = 0;
19937   __Pyx_RefNannySetupContext("is_f_contig", 0);
19938 
19939   /* "View.MemoryView":628
19940  *         cdef __Pyx_memviewslice *mslice
19941  *         cdef __Pyx_memviewslice tmp
19942  *         mslice = get_slice_from_memview(self, &tmp)             # <<<<<<<<<<<<<<
19943  *         return slice_is_contig(mslice[0], 'F', self.view.ndim)
19944  *
19945  */
19946   __pyx_t_1 = __pyx_memoryview_get_slice_from_memoryview(__pyx_v_self, (&__pyx_v_tmp)); if (unlikely(__pyx_t_1 == ((__Pyx_memviewslice *)NULL))) __PYX_ERR(3, 628, __pyx_L1_error)
19947   __pyx_v_mslice = __pyx_t_1;
19948 
19949   /* "View.MemoryView":629
19950  *         cdef __Pyx_memviewslice tmp
19951  *         mslice = get_slice_from_memview(self, &tmp)
19952  *         return slice_is_contig(mslice[0], 'F', self.view.ndim)             # <<<<<<<<<<<<<<
19953  *
19954  *     def copy(self):
19955  */
19956   __Pyx_XDECREF(__pyx_r);
19957   __pyx_t_2 = __Pyx_PyBool_FromLong(__pyx_memviewslice_is_contig((__pyx_v_mslice[0]), 'F', __pyx_v_self->view.ndim)); if (unlikely(!__pyx_t_2)) __PYX_ERR(3, 629, __pyx_L1_error)
19958   __Pyx_GOTREF(__pyx_t_2);
19959   __pyx_r = __pyx_t_2;
19960   __pyx_t_2 = 0;
19961   goto __pyx_L0;
19962 
19963   /* "View.MemoryView":625
19964  *         return slice_is_contig(mslice[0], 'C', self.view.ndim)
19965  *
19966  *     def is_f_contig(self):             # <<<<<<<<<<<<<<
19967  *         cdef __Pyx_memviewslice *mslice
19968  *         cdef __Pyx_memviewslice tmp
19969  */
19970 
19971   /* function exit code */
19972   __pyx_L1_error:;
19973   __Pyx_XDECREF(__pyx_t_2);
19974   __Pyx_AddTraceback("View.MemoryView.memoryview.is_f_contig", __pyx_clineno, __pyx_lineno, __pyx_filename);
19975   __pyx_r = NULL;
19976   __pyx_L0:;
19977   __Pyx_XGIVEREF(__pyx_r);
19978   __Pyx_RefNannyFinishContext();
19979   return __pyx_r;
19980 }
19981 
19982 /* "View.MemoryView":631
19983  *         return slice_is_contig(mslice[0], 'F', self.view.ndim)
19984  *
19985  *     def copy(self):             # <<<<<<<<<<<<<<
19986  *         cdef __Pyx_memviewslice mslice
19987  *         cdef int flags = self.flags & ~PyBUF_F_CONTIGUOUS
19988  */
19989 
19990 /* Python wrapper */
19991 static PyObject *__pyx_memoryview_copy(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
__pyx_memoryview_copy(PyObject * __pyx_v_self,CYTHON_UNUSED PyObject * unused)19992 static PyObject *__pyx_memoryview_copy(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
19993   PyObject *__pyx_r = 0;
19994   __Pyx_RefNannyDeclarations
19995   __Pyx_RefNannySetupContext("copy (wrapper)", 0);
19996   __pyx_r = __pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_20copy(((struct __pyx_memoryview_obj *)__pyx_v_self));
19997 
19998   /* function exit code */
19999   __Pyx_RefNannyFinishContext();
20000   return __pyx_r;
20001 }
20002 
__pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_20copy(struct __pyx_memoryview_obj * __pyx_v_self)20003 static PyObject *__pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_20copy(struct __pyx_memoryview_obj *__pyx_v_self) {
20004   __Pyx_memviewslice __pyx_v_mslice;
20005   int __pyx_v_flags;
20006   PyObject *__pyx_r = NULL;
20007   __Pyx_RefNannyDeclarations
20008   __Pyx_memviewslice __pyx_t_1;
20009   PyObject *__pyx_t_2 = NULL;
20010   int __pyx_lineno = 0;
20011   const char *__pyx_filename = NULL;
20012   int __pyx_clineno = 0;
20013   __Pyx_RefNannySetupContext("copy", 0);
20014 
20015   /* "View.MemoryView":633
20016  *     def copy(self):
20017  *         cdef __Pyx_memviewslice mslice
20018  *         cdef int flags = self.flags & ~PyBUF_F_CONTIGUOUS             # <<<<<<<<<<<<<<
20019  *
20020  *         slice_copy(self, &mslice)
20021  */
20022   __pyx_v_flags = (__pyx_v_self->flags & (~PyBUF_F_CONTIGUOUS));
20023 
20024   /* "View.MemoryView":635
20025  *         cdef int flags = self.flags & ~PyBUF_F_CONTIGUOUS
20026  *
20027  *         slice_copy(self, &mslice)             # <<<<<<<<<<<<<<
20028  *         mslice = slice_copy_contig(&mslice, "c", self.view.ndim,
20029  *                                    self.view.itemsize,
20030  */
20031   __pyx_memoryview_slice_copy(__pyx_v_self, (&__pyx_v_mslice));
20032 
20033   /* "View.MemoryView":636
20034  *
20035  *         slice_copy(self, &mslice)
20036  *         mslice = slice_copy_contig(&mslice, "c", self.view.ndim,             # <<<<<<<<<<<<<<
20037  *                                    self.view.itemsize,
20038  *                                    flags|PyBUF_C_CONTIGUOUS,
20039  */
20040   __pyx_t_1 = __pyx_memoryview_copy_new_contig((&__pyx_v_mslice), ((char *)"c"), __pyx_v_self->view.ndim, __pyx_v_self->view.itemsize, (__pyx_v_flags | PyBUF_C_CONTIGUOUS), __pyx_v_self->dtype_is_object); if (unlikely(PyErr_Occurred())) __PYX_ERR(3, 636, __pyx_L1_error)
20041   __pyx_v_mslice = __pyx_t_1;
20042 
20043   /* "View.MemoryView":641
20044  *                                    self.dtype_is_object)
20045  *
20046  *         return memoryview_copy_from_slice(self, &mslice)             # <<<<<<<<<<<<<<
20047  *
20048  *     def copy_fortran(self):
20049  */
20050   __Pyx_XDECREF(__pyx_r);
20051   __pyx_t_2 = __pyx_memoryview_copy_object_from_slice(__pyx_v_self, (&__pyx_v_mslice)); if (unlikely(!__pyx_t_2)) __PYX_ERR(3, 641, __pyx_L1_error)
20052   __Pyx_GOTREF(__pyx_t_2);
20053   __pyx_r = __pyx_t_2;
20054   __pyx_t_2 = 0;
20055   goto __pyx_L0;
20056 
20057   /* "View.MemoryView":631
20058  *         return slice_is_contig(mslice[0], 'F', self.view.ndim)
20059  *
20060  *     def copy(self):             # <<<<<<<<<<<<<<
20061  *         cdef __Pyx_memviewslice mslice
20062  *         cdef int flags = self.flags & ~PyBUF_F_CONTIGUOUS
20063  */
20064 
20065   /* function exit code */
20066   __pyx_L1_error:;
20067   __Pyx_XDECREF(__pyx_t_2);
20068   __Pyx_AddTraceback("View.MemoryView.memoryview.copy", __pyx_clineno, __pyx_lineno, __pyx_filename);
20069   __pyx_r = NULL;
20070   __pyx_L0:;
20071   __Pyx_XGIVEREF(__pyx_r);
20072   __Pyx_RefNannyFinishContext();
20073   return __pyx_r;
20074 }
20075 
20076 /* "View.MemoryView":643
20077  *         return memoryview_copy_from_slice(self, &mslice)
20078  *
20079  *     def copy_fortran(self):             # <<<<<<<<<<<<<<
20080  *         cdef __Pyx_memviewslice src, dst
20081  *         cdef int flags = self.flags & ~PyBUF_C_CONTIGUOUS
20082  */
20083 
20084 /* Python wrapper */
20085 static PyObject *__pyx_memoryview_copy_fortran(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
__pyx_memoryview_copy_fortran(PyObject * __pyx_v_self,CYTHON_UNUSED PyObject * unused)20086 static PyObject *__pyx_memoryview_copy_fortran(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
20087   PyObject *__pyx_r = 0;
20088   __Pyx_RefNannyDeclarations
20089   __Pyx_RefNannySetupContext("copy_fortran (wrapper)", 0);
20090   __pyx_r = __pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_22copy_fortran(((struct __pyx_memoryview_obj *)__pyx_v_self));
20091 
20092   /* function exit code */
20093   __Pyx_RefNannyFinishContext();
20094   return __pyx_r;
20095 }
20096 
__pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_22copy_fortran(struct __pyx_memoryview_obj * __pyx_v_self)20097 static PyObject *__pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_22copy_fortran(struct __pyx_memoryview_obj *__pyx_v_self) {
20098   __Pyx_memviewslice __pyx_v_src;
20099   __Pyx_memviewslice __pyx_v_dst;
20100   int __pyx_v_flags;
20101   PyObject *__pyx_r = NULL;
20102   __Pyx_RefNannyDeclarations
20103   __Pyx_memviewslice __pyx_t_1;
20104   PyObject *__pyx_t_2 = NULL;
20105   int __pyx_lineno = 0;
20106   const char *__pyx_filename = NULL;
20107   int __pyx_clineno = 0;
20108   __Pyx_RefNannySetupContext("copy_fortran", 0);
20109 
20110   /* "View.MemoryView":645
20111  *     def copy_fortran(self):
20112  *         cdef __Pyx_memviewslice src, dst
20113  *         cdef int flags = self.flags & ~PyBUF_C_CONTIGUOUS             # <<<<<<<<<<<<<<
20114  *
20115  *         slice_copy(self, &src)
20116  */
20117   __pyx_v_flags = (__pyx_v_self->flags & (~PyBUF_C_CONTIGUOUS));
20118 
20119   /* "View.MemoryView":647
20120  *         cdef int flags = self.flags & ~PyBUF_C_CONTIGUOUS
20121  *
20122  *         slice_copy(self, &src)             # <<<<<<<<<<<<<<
20123  *         dst = slice_copy_contig(&src, "fortran", self.view.ndim,
20124  *                                 self.view.itemsize,
20125  */
20126   __pyx_memoryview_slice_copy(__pyx_v_self, (&__pyx_v_src));
20127 
20128   /* "View.MemoryView":648
20129  *
20130  *         slice_copy(self, &src)
20131  *         dst = slice_copy_contig(&src, "fortran", self.view.ndim,             # <<<<<<<<<<<<<<
20132  *                                 self.view.itemsize,
20133  *                                 flags|PyBUF_F_CONTIGUOUS,
20134  */
20135   __pyx_t_1 = __pyx_memoryview_copy_new_contig((&__pyx_v_src), ((char *)"fortran"), __pyx_v_self->view.ndim, __pyx_v_self->view.itemsize, (__pyx_v_flags | PyBUF_F_CONTIGUOUS), __pyx_v_self->dtype_is_object); if (unlikely(PyErr_Occurred())) __PYX_ERR(3, 648, __pyx_L1_error)
20136   __pyx_v_dst = __pyx_t_1;
20137 
20138   /* "View.MemoryView":653
20139  *                                 self.dtype_is_object)
20140  *
20141  *         return memoryview_copy_from_slice(self, &dst)             # <<<<<<<<<<<<<<
20142  *
20143  *
20144  */
20145   __Pyx_XDECREF(__pyx_r);
20146   __pyx_t_2 = __pyx_memoryview_copy_object_from_slice(__pyx_v_self, (&__pyx_v_dst)); if (unlikely(!__pyx_t_2)) __PYX_ERR(3, 653, __pyx_L1_error)
20147   __Pyx_GOTREF(__pyx_t_2);
20148   __pyx_r = __pyx_t_2;
20149   __pyx_t_2 = 0;
20150   goto __pyx_L0;
20151 
20152   /* "View.MemoryView":643
20153  *         return memoryview_copy_from_slice(self, &mslice)
20154  *
20155  *     def copy_fortran(self):             # <<<<<<<<<<<<<<
20156  *         cdef __Pyx_memviewslice src, dst
20157  *         cdef int flags = self.flags & ~PyBUF_C_CONTIGUOUS
20158  */
20159 
20160   /* function exit code */
20161   __pyx_L1_error:;
20162   __Pyx_XDECREF(__pyx_t_2);
20163   __Pyx_AddTraceback("View.MemoryView.memoryview.copy_fortran", __pyx_clineno, __pyx_lineno, __pyx_filename);
20164   __pyx_r = NULL;
20165   __pyx_L0:;
20166   __Pyx_XGIVEREF(__pyx_r);
20167   __Pyx_RefNannyFinishContext();
20168   return __pyx_r;
20169 }
20170 
20171 /* "(tree fragment)":1
20172  * def __reduce_cython__(self):             # <<<<<<<<<<<<<<
20173  *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
20174  * def __setstate_cython__(self, __pyx_state):
20175  */
20176 
20177 /* Python wrapper */
20178 static PyObject *__pyx_pw___pyx_memoryview_1__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
__pyx_pw___pyx_memoryview_1__reduce_cython__(PyObject * __pyx_v_self,CYTHON_UNUSED PyObject * unused)20179 static PyObject *__pyx_pw___pyx_memoryview_1__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
20180   PyObject *__pyx_r = 0;
20181   __Pyx_RefNannyDeclarations
20182   __Pyx_RefNannySetupContext("__reduce_cython__ (wrapper)", 0);
20183   __pyx_r = __pyx_pf___pyx_memoryview___reduce_cython__(((struct __pyx_memoryview_obj *)__pyx_v_self));
20184 
20185   /* function exit code */
20186   __Pyx_RefNannyFinishContext();
20187   return __pyx_r;
20188 }
20189 
__pyx_pf___pyx_memoryview___reduce_cython__(CYTHON_UNUSED struct __pyx_memoryview_obj * __pyx_v_self)20190 static PyObject *__pyx_pf___pyx_memoryview___reduce_cython__(CYTHON_UNUSED struct __pyx_memoryview_obj *__pyx_v_self) {
20191   PyObject *__pyx_r = NULL;
20192   __Pyx_RefNannyDeclarations
20193   PyObject *__pyx_t_1 = NULL;
20194   int __pyx_lineno = 0;
20195   const char *__pyx_filename = NULL;
20196   int __pyx_clineno = 0;
20197   __Pyx_RefNannySetupContext("__reduce_cython__", 0);
20198 
20199   /* "(tree fragment)":2
20200  * def __reduce_cython__(self):
20201  *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")             # <<<<<<<<<<<<<<
20202  * def __setstate_cython__(self, __pyx_state):
20203  *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
20204  */
20205   __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__33, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(3, 2, __pyx_L1_error)
20206   __Pyx_GOTREF(__pyx_t_1);
20207   __Pyx_Raise(__pyx_t_1, 0, 0, 0);
20208   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
20209   __PYX_ERR(3, 2, __pyx_L1_error)
20210 
20211   /* "(tree fragment)":1
20212  * def __reduce_cython__(self):             # <<<<<<<<<<<<<<
20213  *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
20214  * def __setstate_cython__(self, __pyx_state):
20215  */
20216 
20217   /* function exit code */
20218   __pyx_L1_error:;
20219   __Pyx_XDECREF(__pyx_t_1);
20220   __Pyx_AddTraceback("View.MemoryView.memoryview.__reduce_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename);
20221   __pyx_r = NULL;
20222   __Pyx_XGIVEREF(__pyx_r);
20223   __Pyx_RefNannyFinishContext();
20224   return __pyx_r;
20225 }
20226 
20227 /* "(tree fragment)":3
20228  * def __reduce_cython__(self):
20229  *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
20230  * def __setstate_cython__(self, __pyx_state):             # <<<<<<<<<<<<<<
20231  *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
20232  */
20233 
20234 /* Python wrapper */
20235 static PyObject *__pyx_pw___pyx_memoryview_3__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state); /*proto*/
__pyx_pw___pyx_memoryview_3__setstate_cython__(PyObject * __pyx_v_self,PyObject * __pyx_v___pyx_state)20236 static PyObject *__pyx_pw___pyx_memoryview_3__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state) {
20237   PyObject *__pyx_r = 0;
20238   __Pyx_RefNannyDeclarations
20239   __Pyx_RefNannySetupContext("__setstate_cython__ (wrapper)", 0);
20240   __pyx_r = __pyx_pf___pyx_memoryview_2__setstate_cython__(((struct __pyx_memoryview_obj *)__pyx_v_self), ((PyObject *)__pyx_v___pyx_state));
20241 
20242   /* function exit code */
20243   __Pyx_RefNannyFinishContext();
20244   return __pyx_r;
20245 }
20246 
__pyx_pf___pyx_memoryview_2__setstate_cython__(CYTHON_UNUSED struct __pyx_memoryview_obj * __pyx_v_self,CYTHON_UNUSED PyObject * __pyx_v___pyx_state)20247 static PyObject *__pyx_pf___pyx_memoryview_2__setstate_cython__(CYTHON_UNUSED struct __pyx_memoryview_obj *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v___pyx_state) {
20248   PyObject *__pyx_r = NULL;
20249   __Pyx_RefNannyDeclarations
20250   PyObject *__pyx_t_1 = NULL;
20251   int __pyx_lineno = 0;
20252   const char *__pyx_filename = NULL;
20253   int __pyx_clineno = 0;
20254   __Pyx_RefNannySetupContext("__setstate_cython__", 0);
20255 
20256   /* "(tree fragment)":4
20257  *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
20258  * def __setstate_cython__(self, __pyx_state):
20259  *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")             # <<<<<<<<<<<<<<
20260  */
20261   __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__34, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(3, 4, __pyx_L1_error)
20262   __Pyx_GOTREF(__pyx_t_1);
20263   __Pyx_Raise(__pyx_t_1, 0, 0, 0);
20264   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
20265   __PYX_ERR(3, 4, __pyx_L1_error)
20266 
20267   /* "(tree fragment)":3
20268  * def __reduce_cython__(self):
20269  *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
20270  * def __setstate_cython__(self, __pyx_state):             # <<<<<<<<<<<<<<
20271  *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
20272  */
20273 
20274   /* function exit code */
20275   __pyx_L1_error:;
20276   __Pyx_XDECREF(__pyx_t_1);
20277   __Pyx_AddTraceback("View.MemoryView.memoryview.__setstate_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename);
20278   __pyx_r = NULL;
20279   __Pyx_XGIVEREF(__pyx_r);
20280   __Pyx_RefNannyFinishContext();
20281   return __pyx_r;
20282 }
20283 
20284 /* "View.MemoryView":657
20285  *
20286  * @cname('__pyx_memoryview_new')
20287  * cdef memoryview_cwrapper(object o, int flags, bint dtype_is_object, __Pyx_TypeInfo *typeinfo):             # <<<<<<<<<<<<<<
20288  *     cdef memoryview result = memoryview(o, flags, dtype_is_object)
20289  *     result.typeinfo = typeinfo
20290  */
20291 
__pyx_memoryview_new(PyObject * __pyx_v_o,int __pyx_v_flags,int __pyx_v_dtype_is_object,__Pyx_TypeInfo * __pyx_v_typeinfo)20292 static PyObject *__pyx_memoryview_new(PyObject *__pyx_v_o, int __pyx_v_flags, int __pyx_v_dtype_is_object, __Pyx_TypeInfo *__pyx_v_typeinfo) {
20293   struct __pyx_memoryview_obj *__pyx_v_result = 0;
20294   PyObject *__pyx_r = NULL;
20295   __Pyx_RefNannyDeclarations
20296   PyObject *__pyx_t_1 = NULL;
20297   PyObject *__pyx_t_2 = NULL;
20298   PyObject *__pyx_t_3 = NULL;
20299   int __pyx_lineno = 0;
20300   const char *__pyx_filename = NULL;
20301   int __pyx_clineno = 0;
20302   __Pyx_RefNannySetupContext("memoryview_cwrapper", 0);
20303 
20304   /* "View.MemoryView":658
20305  * @cname('__pyx_memoryview_new')
20306  * cdef memoryview_cwrapper(object o, int flags, bint dtype_is_object, __Pyx_TypeInfo *typeinfo):
20307  *     cdef memoryview result = memoryview(o, flags, dtype_is_object)             # <<<<<<<<<<<<<<
20308  *     result.typeinfo = typeinfo
20309  *     return result
20310  */
20311   __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_flags); if (unlikely(!__pyx_t_1)) __PYX_ERR(3, 658, __pyx_L1_error)
20312   __Pyx_GOTREF(__pyx_t_1);
20313   __pyx_t_2 = __Pyx_PyBool_FromLong(__pyx_v_dtype_is_object); if (unlikely(!__pyx_t_2)) __PYX_ERR(3, 658, __pyx_L1_error)
20314   __Pyx_GOTREF(__pyx_t_2);
20315   __pyx_t_3 = PyTuple_New(3); if (unlikely(!__pyx_t_3)) __PYX_ERR(3, 658, __pyx_L1_error)
20316   __Pyx_GOTREF(__pyx_t_3);
20317   __Pyx_INCREF(__pyx_v_o);
20318   __Pyx_GIVEREF(__pyx_v_o);
20319   PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_o);
20320   __Pyx_GIVEREF(__pyx_t_1);
20321   PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_1);
20322   __Pyx_GIVEREF(__pyx_t_2);
20323   PyTuple_SET_ITEM(__pyx_t_3, 2, __pyx_t_2);
20324   __pyx_t_1 = 0;
20325   __pyx_t_2 = 0;
20326   __pyx_t_2 = __Pyx_PyObject_Call(((PyObject *)__pyx_memoryview_type), __pyx_t_3, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(3, 658, __pyx_L1_error)
20327   __Pyx_GOTREF(__pyx_t_2);
20328   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
20329   __pyx_v_result = ((struct __pyx_memoryview_obj *)__pyx_t_2);
20330   __pyx_t_2 = 0;
20331 
20332   /* "View.MemoryView":659
20333  * cdef memoryview_cwrapper(object o, int flags, bint dtype_is_object, __Pyx_TypeInfo *typeinfo):
20334  *     cdef memoryview result = memoryview(o, flags, dtype_is_object)
20335  *     result.typeinfo = typeinfo             # <<<<<<<<<<<<<<
20336  *     return result
20337  *
20338  */
20339   __pyx_v_result->typeinfo = __pyx_v_typeinfo;
20340 
20341   /* "View.MemoryView":660
20342  *     cdef memoryview result = memoryview(o, flags, dtype_is_object)
20343  *     result.typeinfo = typeinfo
20344  *     return result             # <<<<<<<<<<<<<<
20345  *
20346  * @cname('__pyx_memoryview_check')
20347  */
20348   __Pyx_XDECREF(__pyx_r);
20349   __Pyx_INCREF(((PyObject *)__pyx_v_result));
20350   __pyx_r = ((PyObject *)__pyx_v_result);
20351   goto __pyx_L0;
20352 
20353   /* "View.MemoryView":657
20354  *
20355  * @cname('__pyx_memoryview_new')
20356  * cdef memoryview_cwrapper(object o, int flags, bint dtype_is_object, __Pyx_TypeInfo *typeinfo):             # <<<<<<<<<<<<<<
20357  *     cdef memoryview result = memoryview(o, flags, dtype_is_object)
20358  *     result.typeinfo = typeinfo
20359  */
20360 
20361   /* function exit code */
20362   __pyx_L1_error:;
20363   __Pyx_XDECREF(__pyx_t_1);
20364   __Pyx_XDECREF(__pyx_t_2);
20365   __Pyx_XDECREF(__pyx_t_3);
20366   __Pyx_AddTraceback("View.MemoryView.memoryview_cwrapper", __pyx_clineno, __pyx_lineno, __pyx_filename);
20367   __pyx_r = 0;
20368   __pyx_L0:;
20369   __Pyx_XDECREF((PyObject *)__pyx_v_result);
20370   __Pyx_XGIVEREF(__pyx_r);
20371   __Pyx_RefNannyFinishContext();
20372   return __pyx_r;
20373 }
20374 
20375 /* "View.MemoryView":663
20376  *
20377  * @cname('__pyx_memoryview_check')
20378  * cdef inline bint memoryview_check(object o):             # <<<<<<<<<<<<<<
20379  *     return isinstance(o, memoryview)
20380  *
20381  */
20382 
__pyx_memoryview_check(PyObject * __pyx_v_o)20383 static CYTHON_INLINE int __pyx_memoryview_check(PyObject *__pyx_v_o) {
20384   int __pyx_r;
20385   __Pyx_RefNannyDeclarations
20386   int __pyx_t_1;
20387   __Pyx_RefNannySetupContext("memoryview_check", 0);
20388 
20389   /* "View.MemoryView":664
20390  * @cname('__pyx_memoryview_check')
20391  * cdef inline bint memoryview_check(object o):
20392  *     return isinstance(o, memoryview)             # <<<<<<<<<<<<<<
20393  *
20394  * cdef tuple _unellipsify(object index, int ndim):
20395  */
20396   __pyx_t_1 = __Pyx_TypeCheck(__pyx_v_o, __pyx_memoryview_type);
20397   __pyx_r = __pyx_t_1;
20398   goto __pyx_L0;
20399 
20400   /* "View.MemoryView":663
20401  *
20402  * @cname('__pyx_memoryview_check')
20403  * cdef inline bint memoryview_check(object o):             # <<<<<<<<<<<<<<
20404  *     return isinstance(o, memoryview)
20405  *
20406  */
20407 
20408   /* function exit code */
20409   __pyx_L0:;
20410   __Pyx_RefNannyFinishContext();
20411   return __pyx_r;
20412 }
20413 
20414 /* "View.MemoryView":666
20415  *     return isinstance(o, memoryview)
20416  *
20417  * cdef tuple _unellipsify(object index, int ndim):             # <<<<<<<<<<<<<<
20418  *     """
20419  *     Replace all ellipses with full slices and fill incomplete indices with
20420  */
20421 
_unellipsify(PyObject * __pyx_v_index,int __pyx_v_ndim)20422 static PyObject *_unellipsify(PyObject *__pyx_v_index, int __pyx_v_ndim) {
20423   PyObject *__pyx_v_tup = NULL;
20424   PyObject *__pyx_v_result = NULL;
20425   int __pyx_v_have_slices;
20426   int __pyx_v_seen_ellipsis;
20427   CYTHON_UNUSED PyObject *__pyx_v_idx = NULL;
20428   PyObject *__pyx_v_item = NULL;
20429   Py_ssize_t __pyx_v_nslices;
20430   PyObject *__pyx_r = NULL;
20431   __Pyx_RefNannyDeclarations
20432   int __pyx_t_1;
20433   int __pyx_t_2;
20434   PyObject *__pyx_t_3 = NULL;
20435   PyObject *__pyx_t_4 = NULL;
20436   Py_ssize_t __pyx_t_5;
20437   PyObject *(*__pyx_t_6)(PyObject *);
20438   PyObject *__pyx_t_7 = NULL;
20439   Py_ssize_t __pyx_t_8;
20440   int __pyx_t_9;
20441   int __pyx_t_10;
20442   PyObject *__pyx_t_11 = NULL;
20443   int __pyx_lineno = 0;
20444   const char *__pyx_filename = NULL;
20445   int __pyx_clineno = 0;
20446   __Pyx_RefNannySetupContext("_unellipsify", 0);
20447 
20448   /* "View.MemoryView":671
20449  *     full slices.
20450  *     """
20451  *     if not isinstance(index, tuple):             # <<<<<<<<<<<<<<
20452  *         tup = (index,)
20453  *     else:
20454  */
20455   __pyx_t_1 = PyTuple_Check(__pyx_v_index);
20456   __pyx_t_2 = ((!(__pyx_t_1 != 0)) != 0);
20457   if (__pyx_t_2) {
20458 
20459     /* "View.MemoryView":672
20460  *     """
20461  *     if not isinstance(index, tuple):
20462  *         tup = (index,)             # <<<<<<<<<<<<<<
20463  *     else:
20464  *         tup = index
20465  */
20466     __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(3, 672, __pyx_L1_error)
20467     __Pyx_GOTREF(__pyx_t_3);
20468     __Pyx_INCREF(__pyx_v_index);
20469     __Pyx_GIVEREF(__pyx_v_index);
20470     PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_index);
20471     __pyx_v_tup = __pyx_t_3;
20472     __pyx_t_3 = 0;
20473 
20474     /* "View.MemoryView":671
20475  *     full slices.
20476  *     """
20477  *     if not isinstance(index, tuple):             # <<<<<<<<<<<<<<
20478  *         tup = (index,)
20479  *     else:
20480  */
20481     goto __pyx_L3;
20482   }
20483 
20484   /* "View.MemoryView":674
20485  *         tup = (index,)
20486  *     else:
20487  *         tup = index             # <<<<<<<<<<<<<<
20488  *
20489  *     result = []
20490  */
20491   /*else*/ {
20492     __Pyx_INCREF(__pyx_v_index);
20493     __pyx_v_tup = __pyx_v_index;
20494   }
20495   __pyx_L3:;
20496 
20497   /* "View.MemoryView":676
20498  *         tup = index
20499  *
20500  *     result = []             # <<<<<<<<<<<<<<
20501  *     have_slices = False
20502  *     seen_ellipsis = False
20503  */
20504   __pyx_t_3 = PyList_New(0); if (unlikely(!__pyx_t_3)) __PYX_ERR(3, 676, __pyx_L1_error)
20505   __Pyx_GOTREF(__pyx_t_3);
20506   __pyx_v_result = ((PyObject*)__pyx_t_3);
20507   __pyx_t_3 = 0;
20508 
20509   /* "View.MemoryView":677
20510  *
20511  *     result = []
20512  *     have_slices = False             # <<<<<<<<<<<<<<
20513  *     seen_ellipsis = False
20514  *     for idx, item in enumerate(tup):
20515  */
20516   __pyx_v_have_slices = 0;
20517 
20518   /* "View.MemoryView":678
20519  *     result = []
20520  *     have_slices = False
20521  *     seen_ellipsis = False             # <<<<<<<<<<<<<<
20522  *     for idx, item in enumerate(tup):
20523  *         if item is Ellipsis:
20524  */
20525   __pyx_v_seen_ellipsis = 0;
20526 
20527   /* "View.MemoryView":679
20528  *     have_slices = False
20529  *     seen_ellipsis = False
20530  *     for idx, item in enumerate(tup):             # <<<<<<<<<<<<<<
20531  *         if item is Ellipsis:
20532  *             if not seen_ellipsis:
20533  */
20534   __Pyx_INCREF(__pyx_int_0);
20535   __pyx_t_3 = __pyx_int_0;
20536   if (likely(PyList_CheckExact(__pyx_v_tup)) || PyTuple_CheckExact(__pyx_v_tup)) {
20537     __pyx_t_4 = __pyx_v_tup; __Pyx_INCREF(__pyx_t_4); __pyx_t_5 = 0;
20538     __pyx_t_6 = NULL;
20539   } else {
20540     __pyx_t_5 = -1; __pyx_t_4 = PyObject_GetIter(__pyx_v_tup); if (unlikely(!__pyx_t_4)) __PYX_ERR(3, 679, __pyx_L1_error)
20541     __Pyx_GOTREF(__pyx_t_4);
20542     __pyx_t_6 = Py_TYPE(__pyx_t_4)->tp_iternext; if (unlikely(!__pyx_t_6)) __PYX_ERR(3, 679, __pyx_L1_error)
20543   }
20544   for (;;) {
20545     if (likely(!__pyx_t_6)) {
20546       if (likely(PyList_CheckExact(__pyx_t_4))) {
20547         if (__pyx_t_5 >= PyList_GET_SIZE(__pyx_t_4)) break;
20548         #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
20549         __pyx_t_7 = PyList_GET_ITEM(__pyx_t_4, __pyx_t_5); __Pyx_INCREF(__pyx_t_7); __pyx_t_5++; if (unlikely(0 < 0)) __PYX_ERR(3, 679, __pyx_L1_error)
20550         #else
20551         __pyx_t_7 = PySequence_ITEM(__pyx_t_4, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_7)) __PYX_ERR(3, 679, __pyx_L1_error)
20552         __Pyx_GOTREF(__pyx_t_7);
20553         #endif
20554       } else {
20555         if (__pyx_t_5 >= PyTuple_GET_SIZE(__pyx_t_4)) break;
20556         #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
20557         __pyx_t_7 = PyTuple_GET_ITEM(__pyx_t_4, __pyx_t_5); __Pyx_INCREF(__pyx_t_7); __pyx_t_5++; if (unlikely(0 < 0)) __PYX_ERR(3, 679, __pyx_L1_error)
20558         #else
20559         __pyx_t_7 = PySequence_ITEM(__pyx_t_4, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_7)) __PYX_ERR(3, 679, __pyx_L1_error)
20560         __Pyx_GOTREF(__pyx_t_7);
20561         #endif
20562       }
20563     } else {
20564       __pyx_t_7 = __pyx_t_6(__pyx_t_4);
20565       if (unlikely(!__pyx_t_7)) {
20566         PyObject* exc_type = PyErr_Occurred();
20567         if (exc_type) {
20568           if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
20569           else __PYX_ERR(3, 679, __pyx_L1_error)
20570         }
20571         break;
20572       }
20573       __Pyx_GOTREF(__pyx_t_7);
20574     }
20575     __Pyx_XDECREF_SET(__pyx_v_item, __pyx_t_7);
20576     __pyx_t_7 = 0;
20577     __Pyx_INCREF(__pyx_t_3);
20578     __Pyx_XDECREF_SET(__pyx_v_idx, __pyx_t_3);
20579     __pyx_t_7 = __Pyx_PyInt_AddObjC(__pyx_t_3, __pyx_int_1, 1, 0, 0); if (unlikely(!__pyx_t_7)) __PYX_ERR(3, 679, __pyx_L1_error)
20580     __Pyx_GOTREF(__pyx_t_7);
20581     __Pyx_DECREF(__pyx_t_3);
20582     __pyx_t_3 = __pyx_t_7;
20583     __pyx_t_7 = 0;
20584 
20585     /* "View.MemoryView":680
20586  *     seen_ellipsis = False
20587  *     for idx, item in enumerate(tup):
20588  *         if item is Ellipsis:             # <<<<<<<<<<<<<<
20589  *             if not seen_ellipsis:
20590  *                 result.extend([slice(None)] * (ndim - len(tup) + 1))
20591  */
20592     __pyx_t_2 = (__pyx_v_item == __pyx_builtin_Ellipsis);
20593     __pyx_t_1 = (__pyx_t_2 != 0);
20594     if (__pyx_t_1) {
20595 
20596       /* "View.MemoryView":681
20597  *     for idx, item in enumerate(tup):
20598  *         if item is Ellipsis:
20599  *             if not seen_ellipsis:             # <<<<<<<<<<<<<<
20600  *                 result.extend([slice(None)] * (ndim - len(tup) + 1))
20601  *                 seen_ellipsis = True
20602  */
20603       __pyx_t_1 = ((!(__pyx_v_seen_ellipsis != 0)) != 0);
20604       if (__pyx_t_1) {
20605 
20606         /* "View.MemoryView":682
20607  *         if item is Ellipsis:
20608  *             if not seen_ellipsis:
20609  *                 result.extend([slice(None)] * (ndim - len(tup) + 1))             # <<<<<<<<<<<<<<
20610  *                 seen_ellipsis = True
20611  *             else:
20612  */
20613         __pyx_t_8 = PyObject_Length(__pyx_v_tup); if (unlikely(__pyx_t_8 == ((Py_ssize_t)-1))) __PYX_ERR(3, 682, __pyx_L1_error)
20614         __pyx_t_7 = PyList_New(1 * ((((__pyx_v_ndim - __pyx_t_8) + 1)<0) ? 0:((__pyx_v_ndim - __pyx_t_8) + 1))); if (unlikely(!__pyx_t_7)) __PYX_ERR(3, 682, __pyx_L1_error)
20615         __Pyx_GOTREF(__pyx_t_7);
20616         { Py_ssize_t __pyx_temp;
20617           for (__pyx_temp=0; __pyx_temp < ((__pyx_v_ndim - __pyx_t_8) + 1); __pyx_temp++) {
20618             __Pyx_INCREF(__pyx_slice__35);
20619             __Pyx_GIVEREF(__pyx_slice__35);
20620             PyList_SET_ITEM(__pyx_t_7, __pyx_temp, __pyx_slice__35);
20621           }
20622         }
20623         __pyx_t_9 = __Pyx_PyList_Extend(__pyx_v_result, __pyx_t_7); if (unlikely(__pyx_t_9 == ((int)-1))) __PYX_ERR(3, 682, __pyx_L1_error)
20624         __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
20625 
20626         /* "View.MemoryView":683
20627  *             if not seen_ellipsis:
20628  *                 result.extend([slice(None)] * (ndim - len(tup) + 1))
20629  *                 seen_ellipsis = True             # <<<<<<<<<<<<<<
20630  *             else:
20631  *                 result.append(slice(None))
20632  */
20633         __pyx_v_seen_ellipsis = 1;
20634 
20635         /* "View.MemoryView":681
20636  *     for idx, item in enumerate(tup):
20637  *         if item is Ellipsis:
20638  *             if not seen_ellipsis:             # <<<<<<<<<<<<<<
20639  *                 result.extend([slice(None)] * (ndim - len(tup) + 1))
20640  *                 seen_ellipsis = True
20641  */
20642         goto __pyx_L7;
20643       }
20644 
20645       /* "View.MemoryView":685
20646  *                 seen_ellipsis = True
20647  *             else:
20648  *                 result.append(slice(None))             # <<<<<<<<<<<<<<
20649  *             have_slices = True
20650  *         else:
20651  */
20652       /*else*/ {
20653         __pyx_t_9 = __Pyx_PyList_Append(__pyx_v_result, __pyx_slice__35); if (unlikely(__pyx_t_9 == ((int)-1))) __PYX_ERR(3, 685, __pyx_L1_error)
20654       }
20655       __pyx_L7:;
20656 
20657       /* "View.MemoryView":686
20658  *             else:
20659  *                 result.append(slice(None))
20660  *             have_slices = True             # <<<<<<<<<<<<<<
20661  *         else:
20662  *             if not isinstance(item, slice) and not PyIndex_Check(item):
20663  */
20664       __pyx_v_have_slices = 1;
20665 
20666       /* "View.MemoryView":680
20667  *     seen_ellipsis = False
20668  *     for idx, item in enumerate(tup):
20669  *         if item is Ellipsis:             # <<<<<<<<<<<<<<
20670  *             if not seen_ellipsis:
20671  *                 result.extend([slice(None)] * (ndim - len(tup) + 1))
20672  */
20673       goto __pyx_L6;
20674     }
20675 
20676     /* "View.MemoryView":688
20677  *             have_slices = True
20678  *         else:
20679  *             if not isinstance(item, slice) and not PyIndex_Check(item):             # <<<<<<<<<<<<<<
20680  *                 raise TypeError("Cannot index with type '%s'" % type(item))
20681  *
20682  */
20683     /*else*/ {
20684       __pyx_t_2 = PySlice_Check(__pyx_v_item);
20685       __pyx_t_10 = ((!(__pyx_t_2 != 0)) != 0);
20686       if (__pyx_t_10) {
20687       } else {
20688         __pyx_t_1 = __pyx_t_10;
20689         goto __pyx_L9_bool_binop_done;
20690       }
20691       __pyx_t_10 = ((!(PyIndex_Check(__pyx_v_item) != 0)) != 0);
20692       __pyx_t_1 = __pyx_t_10;
20693       __pyx_L9_bool_binop_done:;
20694       if (unlikely(__pyx_t_1)) {
20695 
20696         /* "View.MemoryView":689
20697  *         else:
20698  *             if not isinstance(item, slice) and not PyIndex_Check(item):
20699  *                 raise TypeError("Cannot index with type '%s'" % type(item))             # <<<<<<<<<<<<<<
20700  *
20701  *             have_slices = have_slices or isinstance(item, slice)
20702  */
20703         __pyx_t_7 = __Pyx_PyString_FormatSafe(__pyx_kp_s_Cannot_index_with_type_s, ((PyObject *)Py_TYPE(__pyx_v_item))); if (unlikely(!__pyx_t_7)) __PYX_ERR(3, 689, __pyx_L1_error)
20704         __Pyx_GOTREF(__pyx_t_7);
20705         __pyx_t_11 = __Pyx_PyObject_CallOneArg(__pyx_builtin_TypeError, __pyx_t_7); if (unlikely(!__pyx_t_11)) __PYX_ERR(3, 689, __pyx_L1_error)
20706         __Pyx_GOTREF(__pyx_t_11);
20707         __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
20708         __Pyx_Raise(__pyx_t_11, 0, 0, 0);
20709         __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
20710         __PYX_ERR(3, 689, __pyx_L1_error)
20711 
20712         /* "View.MemoryView":688
20713  *             have_slices = True
20714  *         else:
20715  *             if not isinstance(item, slice) and not PyIndex_Check(item):             # <<<<<<<<<<<<<<
20716  *                 raise TypeError("Cannot index with type '%s'" % type(item))
20717  *
20718  */
20719       }
20720 
20721       /* "View.MemoryView":691
20722  *                 raise TypeError("Cannot index with type '%s'" % type(item))
20723  *
20724  *             have_slices = have_slices or isinstance(item, slice)             # <<<<<<<<<<<<<<
20725  *             result.append(item)
20726  *
20727  */
20728       __pyx_t_10 = (__pyx_v_have_slices != 0);
20729       if (!__pyx_t_10) {
20730       } else {
20731         __pyx_t_1 = __pyx_t_10;
20732         goto __pyx_L11_bool_binop_done;
20733       }
20734       __pyx_t_10 = PySlice_Check(__pyx_v_item);
20735       __pyx_t_2 = (__pyx_t_10 != 0);
20736       __pyx_t_1 = __pyx_t_2;
20737       __pyx_L11_bool_binop_done:;
20738       __pyx_v_have_slices = __pyx_t_1;
20739 
20740       /* "View.MemoryView":692
20741  *
20742  *             have_slices = have_slices or isinstance(item, slice)
20743  *             result.append(item)             # <<<<<<<<<<<<<<
20744  *
20745  *     nslices = ndim - len(result)
20746  */
20747       __pyx_t_9 = __Pyx_PyList_Append(__pyx_v_result, __pyx_v_item); if (unlikely(__pyx_t_9 == ((int)-1))) __PYX_ERR(3, 692, __pyx_L1_error)
20748     }
20749     __pyx_L6:;
20750 
20751     /* "View.MemoryView":679
20752  *     have_slices = False
20753  *     seen_ellipsis = False
20754  *     for idx, item in enumerate(tup):             # <<<<<<<<<<<<<<
20755  *         if item is Ellipsis:
20756  *             if not seen_ellipsis:
20757  */
20758   }
20759   __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
20760   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
20761 
20762   /* "View.MemoryView":694
20763  *             result.append(item)
20764  *
20765  *     nslices = ndim - len(result)             # <<<<<<<<<<<<<<
20766  *     if nslices:
20767  *         result.extend([slice(None)] * nslices)
20768  */
20769   __pyx_t_5 = PyList_GET_SIZE(__pyx_v_result); if (unlikely(__pyx_t_5 == ((Py_ssize_t)-1))) __PYX_ERR(3, 694, __pyx_L1_error)
20770   __pyx_v_nslices = (__pyx_v_ndim - __pyx_t_5);
20771 
20772   /* "View.MemoryView":695
20773  *
20774  *     nslices = ndim - len(result)
20775  *     if nslices:             # <<<<<<<<<<<<<<
20776  *         result.extend([slice(None)] * nslices)
20777  *
20778  */
20779   __pyx_t_1 = (__pyx_v_nslices != 0);
20780   if (__pyx_t_1) {
20781 
20782     /* "View.MemoryView":696
20783  *     nslices = ndim - len(result)
20784  *     if nslices:
20785  *         result.extend([slice(None)] * nslices)             # <<<<<<<<<<<<<<
20786  *
20787  *     return have_slices or nslices, tuple(result)
20788  */
20789     __pyx_t_3 = PyList_New(1 * ((__pyx_v_nslices<0) ? 0:__pyx_v_nslices)); if (unlikely(!__pyx_t_3)) __PYX_ERR(3, 696, __pyx_L1_error)
20790     __Pyx_GOTREF(__pyx_t_3);
20791     { Py_ssize_t __pyx_temp;
20792       for (__pyx_temp=0; __pyx_temp < __pyx_v_nslices; __pyx_temp++) {
20793         __Pyx_INCREF(__pyx_slice__35);
20794         __Pyx_GIVEREF(__pyx_slice__35);
20795         PyList_SET_ITEM(__pyx_t_3, __pyx_temp, __pyx_slice__35);
20796       }
20797     }
20798     __pyx_t_9 = __Pyx_PyList_Extend(__pyx_v_result, __pyx_t_3); if (unlikely(__pyx_t_9 == ((int)-1))) __PYX_ERR(3, 696, __pyx_L1_error)
20799     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
20800 
20801     /* "View.MemoryView":695
20802  *
20803  *     nslices = ndim - len(result)
20804  *     if nslices:             # <<<<<<<<<<<<<<
20805  *         result.extend([slice(None)] * nslices)
20806  *
20807  */
20808   }
20809 
20810   /* "View.MemoryView":698
20811  *         result.extend([slice(None)] * nslices)
20812  *
20813  *     return have_slices or nslices, tuple(result)             # <<<<<<<<<<<<<<
20814  *
20815  * cdef assert_direct_dimensions(Py_ssize_t *suboffsets, int ndim):
20816  */
20817   __Pyx_XDECREF(__pyx_r);
20818   if (!__pyx_v_have_slices) {
20819   } else {
20820     __pyx_t_4 = __Pyx_PyBool_FromLong(__pyx_v_have_slices); if (unlikely(!__pyx_t_4)) __PYX_ERR(3, 698, __pyx_L1_error)
20821     __Pyx_GOTREF(__pyx_t_4);
20822     __pyx_t_3 = __pyx_t_4;
20823     __pyx_t_4 = 0;
20824     goto __pyx_L14_bool_binop_done;
20825   }
20826   __pyx_t_4 = PyInt_FromSsize_t(__pyx_v_nslices); if (unlikely(!__pyx_t_4)) __PYX_ERR(3, 698, __pyx_L1_error)
20827   __Pyx_GOTREF(__pyx_t_4);
20828   __pyx_t_3 = __pyx_t_4;
20829   __pyx_t_4 = 0;
20830   __pyx_L14_bool_binop_done:;
20831   __pyx_t_4 = PyList_AsTuple(__pyx_v_result); if (unlikely(!__pyx_t_4)) __PYX_ERR(3, 698, __pyx_L1_error)
20832   __Pyx_GOTREF(__pyx_t_4);
20833   __pyx_t_11 = PyTuple_New(2); if (unlikely(!__pyx_t_11)) __PYX_ERR(3, 698, __pyx_L1_error)
20834   __Pyx_GOTREF(__pyx_t_11);
20835   __Pyx_GIVEREF(__pyx_t_3);
20836   PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_t_3);
20837   __Pyx_GIVEREF(__pyx_t_4);
20838   PyTuple_SET_ITEM(__pyx_t_11, 1, __pyx_t_4);
20839   __pyx_t_3 = 0;
20840   __pyx_t_4 = 0;
20841   __pyx_r = ((PyObject*)__pyx_t_11);
20842   __pyx_t_11 = 0;
20843   goto __pyx_L0;
20844 
20845   /* "View.MemoryView":666
20846  *     return isinstance(o, memoryview)
20847  *
20848  * cdef tuple _unellipsify(object index, int ndim):             # <<<<<<<<<<<<<<
20849  *     """
20850  *     Replace all ellipses with full slices and fill incomplete indices with
20851  */
20852 
20853   /* function exit code */
20854   __pyx_L1_error:;
20855   __Pyx_XDECREF(__pyx_t_3);
20856   __Pyx_XDECREF(__pyx_t_4);
20857   __Pyx_XDECREF(__pyx_t_7);
20858   __Pyx_XDECREF(__pyx_t_11);
20859   __Pyx_AddTraceback("View.MemoryView._unellipsify", __pyx_clineno, __pyx_lineno, __pyx_filename);
20860   __pyx_r = 0;
20861   __pyx_L0:;
20862   __Pyx_XDECREF(__pyx_v_tup);
20863   __Pyx_XDECREF(__pyx_v_result);
20864   __Pyx_XDECREF(__pyx_v_idx);
20865   __Pyx_XDECREF(__pyx_v_item);
20866   __Pyx_XGIVEREF(__pyx_r);
20867   __Pyx_RefNannyFinishContext();
20868   return __pyx_r;
20869 }
20870 
20871 /* "View.MemoryView":700
20872  *     return have_slices or nslices, tuple(result)
20873  *
20874  * cdef assert_direct_dimensions(Py_ssize_t *suboffsets, int ndim):             # <<<<<<<<<<<<<<
20875  *     for suboffset in suboffsets[:ndim]:
20876  *         if suboffset >= 0:
20877  */
20878 
assert_direct_dimensions(Py_ssize_t * __pyx_v_suboffsets,int __pyx_v_ndim)20879 static PyObject *assert_direct_dimensions(Py_ssize_t *__pyx_v_suboffsets, int __pyx_v_ndim) {
20880   Py_ssize_t __pyx_v_suboffset;
20881   PyObject *__pyx_r = NULL;
20882   __Pyx_RefNannyDeclarations
20883   Py_ssize_t *__pyx_t_1;
20884   Py_ssize_t *__pyx_t_2;
20885   Py_ssize_t *__pyx_t_3;
20886   int __pyx_t_4;
20887   PyObject *__pyx_t_5 = NULL;
20888   int __pyx_lineno = 0;
20889   const char *__pyx_filename = NULL;
20890   int __pyx_clineno = 0;
20891   __Pyx_RefNannySetupContext("assert_direct_dimensions", 0);
20892 
20893   /* "View.MemoryView":701
20894  *
20895  * cdef assert_direct_dimensions(Py_ssize_t *suboffsets, int ndim):
20896  *     for suboffset in suboffsets[:ndim]:             # <<<<<<<<<<<<<<
20897  *         if suboffset >= 0:
20898  *             raise ValueError("Indirect dimensions not supported")
20899  */
20900   __pyx_t_2 = (__pyx_v_suboffsets + __pyx_v_ndim);
20901   for (__pyx_t_3 = __pyx_v_suboffsets; __pyx_t_3 < __pyx_t_2; __pyx_t_3++) {
20902     __pyx_t_1 = __pyx_t_3;
20903     __pyx_v_suboffset = (__pyx_t_1[0]);
20904 
20905     /* "View.MemoryView":702
20906  * cdef assert_direct_dimensions(Py_ssize_t *suboffsets, int ndim):
20907  *     for suboffset in suboffsets[:ndim]:
20908  *         if suboffset >= 0:             # <<<<<<<<<<<<<<
20909  *             raise ValueError("Indirect dimensions not supported")
20910  *
20911  */
20912     __pyx_t_4 = ((__pyx_v_suboffset >= 0) != 0);
20913     if (unlikely(__pyx_t_4)) {
20914 
20915       /* "View.MemoryView":703
20916  *     for suboffset in suboffsets[:ndim]:
20917  *         if suboffset >= 0:
20918  *             raise ValueError("Indirect dimensions not supported")             # <<<<<<<<<<<<<<
20919  *
20920  *
20921  */
20922       __pyx_t_5 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__36, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(3, 703, __pyx_L1_error)
20923       __Pyx_GOTREF(__pyx_t_5);
20924       __Pyx_Raise(__pyx_t_5, 0, 0, 0);
20925       __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
20926       __PYX_ERR(3, 703, __pyx_L1_error)
20927 
20928       /* "View.MemoryView":702
20929  * cdef assert_direct_dimensions(Py_ssize_t *suboffsets, int ndim):
20930  *     for suboffset in suboffsets[:ndim]:
20931  *         if suboffset >= 0:             # <<<<<<<<<<<<<<
20932  *             raise ValueError("Indirect dimensions not supported")
20933  *
20934  */
20935     }
20936   }
20937 
20938   /* "View.MemoryView":700
20939  *     return have_slices or nslices, tuple(result)
20940  *
20941  * cdef assert_direct_dimensions(Py_ssize_t *suboffsets, int ndim):             # <<<<<<<<<<<<<<
20942  *     for suboffset in suboffsets[:ndim]:
20943  *         if suboffset >= 0:
20944  */
20945 
20946   /* function exit code */
20947   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
20948   goto __pyx_L0;
20949   __pyx_L1_error:;
20950   __Pyx_XDECREF(__pyx_t_5);
20951   __Pyx_AddTraceback("View.MemoryView.assert_direct_dimensions", __pyx_clineno, __pyx_lineno, __pyx_filename);
20952   __pyx_r = 0;
20953   __pyx_L0:;
20954   __Pyx_XGIVEREF(__pyx_r);
20955   __Pyx_RefNannyFinishContext();
20956   return __pyx_r;
20957 }
20958 
20959 /* "View.MemoryView":710
20960  *
20961  * @cname('__pyx_memview_slice')
20962  * cdef memoryview memview_slice(memoryview memview, object indices):             # <<<<<<<<<<<<<<
20963  *     cdef int new_ndim = 0, suboffset_dim = -1, dim
20964  *     cdef bint negative_step
20965  */
20966 
__pyx_memview_slice(struct __pyx_memoryview_obj * __pyx_v_memview,PyObject * __pyx_v_indices)20967 static struct __pyx_memoryview_obj *__pyx_memview_slice(struct __pyx_memoryview_obj *__pyx_v_memview, PyObject *__pyx_v_indices) {
20968   int __pyx_v_new_ndim;
20969   int __pyx_v_suboffset_dim;
20970   int __pyx_v_dim;
20971   __Pyx_memviewslice __pyx_v_src;
20972   __Pyx_memviewslice __pyx_v_dst;
20973   __Pyx_memviewslice *__pyx_v_p_src;
20974   struct __pyx_memoryviewslice_obj *__pyx_v_memviewsliceobj = 0;
20975   __Pyx_memviewslice *__pyx_v_p_dst;
20976   int *__pyx_v_p_suboffset_dim;
20977   Py_ssize_t __pyx_v_start;
20978   Py_ssize_t __pyx_v_stop;
20979   Py_ssize_t __pyx_v_step;
20980   int __pyx_v_have_start;
20981   int __pyx_v_have_stop;
20982   int __pyx_v_have_step;
20983   PyObject *__pyx_v_index = NULL;
20984   struct __pyx_memoryview_obj *__pyx_r = NULL;
20985   __Pyx_RefNannyDeclarations
20986   int __pyx_t_1;
20987   int __pyx_t_2;
20988   PyObject *__pyx_t_3 = NULL;
20989   struct __pyx_memoryview_obj *__pyx_t_4;
20990   char *__pyx_t_5;
20991   int __pyx_t_6;
20992   Py_ssize_t __pyx_t_7;
20993   PyObject *(*__pyx_t_8)(PyObject *);
20994   PyObject *__pyx_t_9 = NULL;
20995   Py_ssize_t __pyx_t_10;
20996   int __pyx_t_11;
20997   Py_ssize_t __pyx_t_12;
20998   int __pyx_lineno = 0;
20999   const char *__pyx_filename = NULL;
21000   int __pyx_clineno = 0;
21001   __Pyx_RefNannySetupContext("memview_slice", 0);
21002 
21003   /* "View.MemoryView":711
21004  * @cname('__pyx_memview_slice')
21005  * cdef memoryview memview_slice(memoryview memview, object indices):
21006  *     cdef int new_ndim = 0, suboffset_dim = -1, dim             # <<<<<<<<<<<<<<
21007  *     cdef bint negative_step
21008  *     cdef __Pyx_memviewslice src, dst
21009  */
21010   __pyx_v_new_ndim = 0;
21011   __pyx_v_suboffset_dim = -1;
21012 
21013   /* "View.MemoryView":718
21014  *
21015  *
21016  *     memset(&dst, 0, sizeof(dst))             # <<<<<<<<<<<<<<
21017  *
21018  *     cdef _memoryviewslice memviewsliceobj
21019  */
21020   (void)(memset((&__pyx_v_dst), 0, (sizeof(__pyx_v_dst))));
21021 
21022   /* "View.MemoryView":722
21023  *     cdef _memoryviewslice memviewsliceobj
21024  *
21025  *     assert memview.view.ndim > 0             # <<<<<<<<<<<<<<
21026  *
21027  *     if isinstance(memview, _memoryviewslice):
21028  */
21029   #ifndef CYTHON_WITHOUT_ASSERTIONS
21030   if (unlikely(!Py_OptimizeFlag)) {
21031     if (unlikely(!((__pyx_v_memview->view.ndim > 0) != 0))) {
21032       PyErr_SetNone(PyExc_AssertionError);
21033       __PYX_ERR(3, 722, __pyx_L1_error)
21034     }
21035   }
21036   #endif
21037 
21038   /* "View.MemoryView":724
21039  *     assert memview.view.ndim > 0
21040  *
21041  *     if isinstance(memview, _memoryviewslice):             # <<<<<<<<<<<<<<
21042  *         memviewsliceobj = memview
21043  *         p_src = &memviewsliceobj.from_slice
21044  */
21045   __pyx_t_1 = __Pyx_TypeCheck(((PyObject *)__pyx_v_memview), __pyx_memoryviewslice_type);
21046   __pyx_t_2 = (__pyx_t_1 != 0);
21047   if (__pyx_t_2) {
21048 
21049     /* "View.MemoryView":725
21050  *
21051  *     if isinstance(memview, _memoryviewslice):
21052  *         memviewsliceobj = memview             # <<<<<<<<<<<<<<
21053  *         p_src = &memviewsliceobj.from_slice
21054  *     else:
21055  */
21056     if (!(likely(((((PyObject *)__pyx_v_memview)) == Py_None) || likely(__Pyx_TypeTest(((PyObject *)__pyx_v_memview), __pyx_memoryviewslice_type))))) __PYX_ERR(3, 725, __pyx_L1_error)
21057     __pyx_t_3 = ((PyObject *)__pyx_v_memview);
21058     __Pyx_INCREF(__pyx_t_3);
21059     __pyx_v_memviewsliceobj = ((struct __pyx_memoryviewslice_obj *)__pyx_t_3);
21060     __pyx_t_3 = 0;
21061 
21062     /* "View.MemoryView":726
21063  *     if isinstance(memview, _memoryviewslice):
21064  *         memviewsliceobj = memview
21065  *         p_src = &memviewsliceobj.from_slice             # <<<<<<<<<<<<<<
21066  *     else:
21067  *         slice_copy(memview, &src)
21068  */
21069     __pyx_v_p_src = (&__pyx_v_memviewsliceobj->from_slice);
21070 
21071     /* "View.MemoryView":724
21072  *     assert memview.view.ndim > 0
21073  *
21074  *     if isinstance(memview, _memoryviewslice):             # <<<<<<<<<<<<<<
21075  *         memviewsliceobj = memview
21076  *         p_src = &memviewsliceobj.from_slice
21077  */
21078     goto __pyx_L3;
21079   }
21080 
21081   /* "View.MemoryView":728
21082  *         p_src = &memviewsliceobj.from_slice
21083  *     else:
21084  *         slice_copy(memview, &src)             # <<<<<<<<<<<<<<
21085  *         p_src = &src
21086  *
21087  */
21088   /*else*/ {
21089     __pyx_memoryview_slice_copy(__pyx_v_memview, (&__pyx_v_src));
21090 
21091     /* "View.MemoryView":729
21092  *     else:
21093  *         slice_copy(memview, &src)
21094  *         p_src = &src             # <<<<<<<<<<<<<<
21095  *
21096  *
21097  */
21098     __pyx_v_p_src = (&__pyx_v_src);
21099   }
21100   __pyx_L3:;
21101 
21102   /* "View.MemoryView":735
21103  *
21104  *
21105  *     dst.memview = p_src.memview             # <<<<<<<<<<<<<<
21106  *     dst.data = p_src.data
21107  *
21108  */
21109   __pyx_t_4 = __pyx_v_p_src->memview;
21110   __pyx_v_dst.memview = __pyx_t_4;
21111 
21112   /* "View.MemoryView":736
21113  *
21114  *     dst.memview = p_src.memview
21115  *     dst.data = p_src.data             # <<<<<<<<<<<<<<
21116  *
21117  *
21118  */
21119   __pyx_t_5 = __pyx_v_p_src->data;
21120   __pyx_v_dst.data = __pyx_t_5;
21121 
21122   /* "View.MemoryView":741
21123  *
21124  *
21125  *     cdef __Pyx_memviewslice *p_dst = &dst             # <<<<<<<<<<<<<<
21126  *     cdef int *p_suboffset_dim = &suboffset_dim
21127  *     cdef Py_ssize_t start, stop, step
21128  */
21129   __pyx_v_p_dst = (&__pyx_v_dst);
21130 
21131   /* "View.MemoryView":742
21132  *
21133  *     cdef __Pyx_memviewslice *p_dst = &dst
21134  *     cdef int *p_suboffset_dim = &suboffset_dim             # <<<<<<<<<<<<<<
21135  *     cdef Py_ssize_t start, stop, step
21136  *     cdef bint have_start, have_stop, have_step
21137  */
21138   __pyx_v_p_suboffset_dim = (&__pyx_v_suboffset_dim);
21139 
21140   /* "View.MemoryView":746
21141  *     cdef bint have_start, have_stop, have_step
21142  *
21143  *     for dim, index in enumerate(indices):             # <<<<<<<<<<<<<<
21144  *         if PyIndex_Check(index):
21145  *             slice_memviewslice(
21146  */
21147   __pyx_t_6 = 0;
21148   if (likely(PyList_CheckExact(__pyx_v_indices)) || PyTuple_CheckExact(__pyx_v_indices)) {
21149     __pyx_t_3 = __pyx_v_indices; __Pyx_INCREF(__pyx_t_3); __pyx_t_7 = 0;
21150     __pyx_t_8 = NULL;
21151   } else {
21152     __pyx_t_7 = -1; __pyx_t_3 = PyObject_GetIter(__pyx_v_indices); if (unlikely(!__pyx_t_3)) __PYX_ERR(3, 746, __pyx_L1_error)
21153     __Pyx_GOTREF(__pyx_t_3);
21154     __pyx_t_8 = Py_TYPE(__pyx_t_3)->tp_iternext; if (unlikely(!__pyx_t_8)) __PYX_ERR(3, 746, __pyx_L1_error)
21155   }
21156   for (;;) {
21157     if (likely(!__pyx_t_8)) {
21158       if (likely(PyList_CheckExact(__pyx_t_3))) {
21159         if (__pyx_t_7 >= PyList_GET_SIZE(__pyx_t_3)) break;
21160         #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
21161         __pyx_t_9 = PyList_GET_ITEM(__pyx_t_3, __pyx_t_7); __Pyx_INCREF(__pyx_t_9); __pyx_t_7++; if (unlikely(0 < 0)) __PYX_ERR(3, 746, __pyx_L1_error)
21162         #else
21163         __pyx_t_9 = PySequence_ITEM(__pyx_t_3, __pyx_t_7); __pyx_t_7++; if (unlikely(!__pyx_t_9)) __PYX_ERR(3, 746, __pyx_L1_error)
21164         __Pyx_GOTREF(__pyx_t_9);
21165         #endif
21166       } else {
21167         if (__pyx_t_7 >= PyTuple_GET_SIZE(__pyx_t_3)) break;
21168         #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
21169         __pyx_t_9 = PyTuple_GET_ITEM(__pyx_t_3, __pyx_t_7); __Pyx_INCREF(__pyx_t_9); __pyx_t_7++; if (unlikely(0 < 0)) __PYX_ERR(3, 746, __pyx_L1_error)
21170         #else
21171         __pyx_t_9 = PySequence_ITEM(__pyx_t_3, __pyx_t_7); __pyx_t_7++; if (unlikely(!__pyx_t_9)) __PYX_ERR(3, 746, __pyx_L1_error)
21172         __Pyx_GOTREF(__pyx_t_9);
21173         #endif
21174       }
21175     } else {
21176       __pyx_t_9 = __pyx_t_8(__pyx_t_3);
21177       if (unlikely(!__pyx_t_9)) {
21178         PyObject* exc_type = PyErr_Occurred();
21179         if (exc_type) {
21180           if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
21181           else __PYX_ERR(3, 746, __pyx_L1_error)
21182         }
21183         break;
21184       }
21185       __Pyx_GOTREF(__pyx_t_9);
21186     }
21187     __Pyx_XDECREF_SET(__pyx_v_index, __pyx_t_9);
21188     __pyx_t_9 = 0;
21189     __pyx_v_dim = __pyx_t_6;
21190     __pyx_t_6 = (__pyx_t_6 + 1);
21191 
21192     /* "View.MemoryView":747
21193  *
21194  *     for dim, index in enumerate(indices):
21195  *         if PyIndex_Check(index):             # <<<<<<<<<<<<<<
21196  *             slice_memviewslice(
21197  *                 p_dst, p_src.shape[dim], p_src.strides[dim], p_src.suboffsets[dim],
21198  */
21199     __pyx_t_2 = (PyIndex_Check(__pyx_v_index) != 0);
21200     if (__pyx_t_2) {
21201 
21202       /* "View.MemoryView":751
21203  *                 p_dst, p_src.shape[dim], p_src.strides[dim], p_src.suboffsets[dim],
21204  *                 dim, new_ndim, p_suboffset_dim,
21205  *                 index, 0, 0, # start, stop, step             # <<<<<<<<<<<<<<
21206  *                 0, 0, 0, # have_{start,stop,step}
21207  *                 False)
21208  */
21209       __pyx_t_10 = __Pyx_PyIndex_AsSsize_t(__pyx_v_index); if (unlikely((__pyx_t_10 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(3, 751, __pyx_L1_error)
21210 
21211       /* "View.MemoryView":748
21212  *     for dim, index in enumerate(indices):
21213  *         if PyIndex_Check(index):
21214  *             slice_memviewslice(             # <<<<<<<<<<<<<<
21215  *                 p_dst, p_src.shape[dim], p_src.strides[dim], p_src.suboffsets[dim],
21216  *                 dim, new_ndim, p_suboffset_dim,
21217  */
21218       __pyx_t_11 = __pyx_memoryview_slice_memviewslice(__pyx_v_p_dst, (__pyx_v_p_src->shape[__pyx_v_dim]), (__pyx_v_p_src->strides[__pyx_v_dim]), (__pyx_v_p_src->suboffsets[__pyx_v_dim]), __pyx_v_dim, __pyx_v_new_ndim, __pyx_v_p_suboffset_dim, __pyx_t_10, 0, 0, 0, 0, 0, 0); if (unlikely(__pyx_t_11 == ((int)-1))) __PYX_ERR(3, 748, __pyx_L1_error)
21219 
21220       /* "View.MemoryView":747
21221  *
21222  *     for dim, index in enumerate(indices):
21223  *         if PyIndex_Check(index):             # <<<<<<<<<<<<<<
21224  *             slice_memviewslice(
21225  *                 p_dst, p_src.shape[dim], p_src.strides[dim], p_src.suboffsets[dim],
21226  */
21227       goto __pyx_L6;
21228     }
21229 
21230     /* "View.MemoryView":754
21231  *                 0, 0, 0, # have_{start,stop,step}
21232  *                 False)
21233  *         elif index is None:             # <<<<<<<<<<<<<<
21234  *             p_dst.shape[new_ndim] = 1
21235  *             p_dst.strides[new_ndim] = 0
21236  */
21237     __pyx_t_2 = (__pyx_v_index == Py_None);
21238     __pyx_t_1 = (__pyx_t_2 != 0);
21239     if (__pyx_t_1) {
21240 
21241       /* "View.MemoryView":755
21242  *                 False)
21243  *         elif index is None:
21244  *             p_dst.shape[new_ndim] = 1             # <<<<<<<<<<<<<<
21245  *             p_dst.strides[new_ndim] = 0
21246  *             p_dst.suboffsets[new_ndim] = -1
21247  */
21248       (__pyx_v_p_dst->shape[__pyx_v_new_ndim]) = 1;
21249 
21250       /* "View.MemoryView":756
21251  *         elif index is None:
21252  *             p_dst.shape[new_ndim] = 1
21253  *             p_dst.strides[new_ndim] = 0             # <<<<<<<<<<<<<<
21254  *             p_dst.suboffsets[new_ndim] = -1
21255  *             new_ndim += 1
21256  */
21257       (__pyx_v_p_dst->strides[__pyx_v_new_ndim]) = 0;
21258 
21259       /* "View.MemoryView":757
21260  *             p_dst.shape[new_ndim] = 1
21261  *             p_dst.strides[new_ndim] = 0
21262  *             p_dst.suboffsets[new_ndim] = -1             # <<<<<<<<<<<<<<
21263  *             new_ndim += 1
21264  *         else:
21265  */
21266       (__pyx_v_p_dst->suboffsets[__pyx_v_new_ndim]) = -1L;
21267 
21268       /* "View.MemoryView":758
21269  *             p_dst.strides[new_ndim] = 0
21270  *             p_dst.suboffsets[new_ndim] = -1
21271  *             new_ndim += 1             # <<<<<<<<<<<<<<
21272  *         else:
21273  *             start = index.start or 0
21274  */
21275       __pyx_v_new_ndim = (__pyx_v_new_ndim + 1);
21276 
21277       /* "View.MemoryView":754
21278  *                 0, 0, 0, # have_{start,stop,step}
21279  *                 False)
21280  *         elif index is None:             # <<<<<<<<<<<<<<
21281  *             p_dst.shape[new_ndim] = 1
21282  *             p_dst.strides[new_ndim] = 0
21283  */
21284       goto __pyx_L6;
21285     }
21286 
21287     /* "View.MemoryView":760
21288  *             new_ndim += 1
21289  *         else:
21290  *             start = index.start or 0             # <<<<<<<<<<<<<<
21291  *             stop = index.stop or 0
21292  *             step = index.step or 0
21293  */
21294     /*else*/ {
21295       __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_v_index, __pyx_n_s_start); if (unlikely(!__pyx_t_9)) __PYX_ERR(3, 760, __pyx_L1_error)
21296       __Pyx_GOTREF(__pyx_t_9);
21297       __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_9); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(3, 760, __pyx_L1_error)
21298       if (!__pyx_t_1) {
21299         __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
21300       } else {
21301         __pyx_t_12 = __Pyx_PyIndex_AsSsize_t(__pyx_t_9); if (unlikely((__pyx_t_12 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(3, 760, __pyx_L1_error)
21302         __pyx_t_10 = __pyx_t_12;
21303         __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
21304         goto __pyx_L7_bool_binop_done;
21305       }
21306       __pyx_t_10 = 0;
21307       __pyx_L7_bool_binop_done:;
21308       __pyx_v_start = __pyx_t_10;
21309 
21310       /* "View.MemoryView":761
21311  *         else:
21312  *             start = index.start or 0
21313  *             stop = index.stop or 0             # <<<<<<<<<<<<<<
21314  *             step = index.step or 0
21315  *
21316  */
21317       __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_v_index, __pyx_n_s_stop); if (unlikely(!__pyx_t_9)) __PYX_ERR(3, 761, __pyx_L1_error)
21318       __Pyx_GOTREF(__pyx_t_9);
21319       __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_9); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(3, 761, __pyx_L1_error)
21320       if (!__pyx_t_1) {
21321         __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
21322       } else {
21323         __pyx_t_12 = __Pyx_PyIndex_AsSsize_t(__pyx_t_9); if (unlikely((__pyx_t_12 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(3, 761, __pyx_L1_error)
21324         __pyx_t_10 = __pyx_t_12;
21325         __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
21326         goto __pyx_L9_bool_binop_done;
21327       }
21328       __pyx_t_10 = 0;
21329       __pyx_L9_bool_binop_done:;
21330       __pyx_v_stop = __pyx_t_10;
21331 
21332       /* "View.MemoryView":762
21333  *             start = index.start or 0
21334  *             stop = index.stop or 0
21335  *             step = index.step or 0             # <<<<<<<<<<<<<<
21336  *
21337  *             have_start = index.start is not None
21338  */
21339       __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_v_index, __pyx_n_s_step); if (unlikely(!__pyx_t_9)) __PYX_ERR(3, 762, __pyx_L1_error)
21340       __Pyx_GOTREF(__pyx_t_9);
21341       __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_9); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(3, 762, __pyx_L1_error)
21342       if (!__pyx_t_1) {
21343         __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
21344       } else {
21345         __pyx_t_12 = __Pyx_PyIndex_AsSsize_t(__pyx_t_9); if (unlikely((__pyx_t_12 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(3, 762, __pyx_L1_error)
21346         __pyx_t_10 = __pyx_t_12;
21347         __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
21348         goto __pyx_L11_bool_binop_done;
21349       }
21350       __pyx_t_10 = 0;
21351       __pyx_L11_bool_binop_done:;
21352       __pyx_v_step = __pyx_t_10;
21353 
21354       /* "View.MemoryView":764
21355  *             step = index.step or 0
21356  *
21357  *             have_start = index.start is not None             # <<<<<<<<<<<<<<
21358  *             have_stop = index.stop is not None
21359  *             have_step = index.step is not None
21360  */
21361       __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_v_index, __pyx_n_s_start); if (unlikely(!__pyx_t_9)) __PYX_ERR(3, 764, __pyx_L1_error)
21362       __Pyx_GOTREF(__pyx_t_9);
21363       __pyx_t_1 = (__pyx_t_9 != Py_None);
21364       __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
21365       __pyx_v_have_start = __pyx_t_1;
21366 
21367       /* "View.MemoryView":765
21368  *
21369  *             have_start = index.start is not None
21370  *             have_stop = index.stop is not None             # <<<<<<<<<<<<<<
21371  *             have_step = index.step is not None
21372  *
21373  */
21374       __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_v_index, __pyx_n_s_stop); if (unlikely(!__pyx_t_9)) __PYX_ERR(3, 765, __pyx_L1_error)
21375       __Pyx_GOTREF(__pyx_t_9);
21376       __pyx_t_1 = (__pyx_t_9 != Py_None);
21377       __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
21378       __pyx_v_have_stop = __pyx_t_1;
21379 
21380       /* "View.MemoryView":766
21381  *             have_start = index.start is not None
21382  *             have_stop = index.stop is not None
21383  *             have_step = index.step is not None             # <<<<<<<<<<<<<<
21384  *
21385  *             slice_memviewslice(
21386  */
21387       __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_v_index, __pyx_n_s_step); if (unlikely(!__pyx_t_9)) __PYX_ERR(3, 766, __pyx_L1_error)
21388       __Pyx_GOTREF(__pyx_t_9);
21389       __pyx_t_1 = (__pyx_t_9 != Py_None);
21390       __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
21391       __pyx_v_have_step = __pyx_t_1;
21392 
21393       /* "View.MemoryView":768
21394  *             have_step = index.step is not None
21395  *
21396  *             slice_memviewslice(             # <<<<<<<<<<<<<<
21397  *                 p_dst, p_src.shape[dim], p_src.strides[dim], p_src.suboffsets[dim],
21398  *                 dim, new_ndim, p_suboffset_dim,
21399  */
21400       __pyx_t_11 = __pyx_memoryview_slice_memviewslice(__pyx_v_p_dst, (__pyx_v_p_src->shape[__pyx_v_dim]), (__pyx_v_p_src->strides[__pyx_v_dim]), (__pyx_v_p_src->suboffsets[__pyx_v_dim]), __pyx_v_dim, __pyx_v_new_ndim, __pyx_v_p_suboffset_dim, __pyx_v_start, __pyx_v_stop, __pyx_v_step, __pyx_v_have_start, __pyx_v_have_stop, __pyx_v_have_step, 1); if (unlikely(__pyx_t_11 == ((int)-1))) __PYX_ERR(3, 768, __pyx_L1_error)
21401 
21402       /* "View.MemoryView":774
21403  *                 have_start, have_stop, have_step,
21404  *                 True)
21405  *             new_ndim += 1             # <<<<<<<<<<<<<<
21406  *
21407  *     if isinstance(memview, _memoryviewslice):
21408  */
21409       __pyx_v_new_ndim = (__pyx_v_new_ndim + 1);
21410     }
21411     __pyx_L6:;
21412 
21413     /* "View.MemoryView":746
21414  *     cdef bint have_start, have_stop, have_step
21415  *
21416  *     for dim, index in enumerate(indices):             # <<<<<<<<<<<<<<
21417  *         if PyIndex_Check(index):
21418  *             slice_memviewslice(
21419  */
21420   }
21421   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
21422 
21423   /* "View.MemoryView":776
21424  *             new_ndim += 1
21425  *
21426  *     if isinstance(memview, _memoryviewslice):             # <<<<<<<<<<<<<<
21427  *         return memoryview_fromslice(dst, new_ndim,
21428  *                                     memviewsliceobj.to_object_func,
21429  */
21430   __pyx_t_1 = __Pyx_TypeCheck(((PyObject *)__pyx_v_memview), __pyx_memoryviewslice_type);
21431   __pyx_t_2 = (__pyx_t_1 != 0);
21432   if (__pyx_t_2) {
21433 
21434     /* "View.MemoryView":777
21435  *
21436  *     if isinstance(memview, _memoryviewslice):
21437  *         return memoryview_fromslice(dst, new_ndim,             # <<<<<<<<<<<<<<
21438  *                                     memviewsliceobj.to_object_func,
21439  *                                     memviewsliceobj.to_dtype_func,
21440  */
21441     __Pyx_XDECREF(((PyObject *)__pyx_r));
21442 
21443     /* "View.MemoryView":778
21444  *     if isinstance(memview, _memoryviewslice):
21445  *         return memoryview_fromslice(dst, new_ndim,
21446  *                                     memviewsliceobj.to_object_func,             # <<<<<<<<<<<<<<
21447  *                                     memviewsliceobj.to_dtype_func,
21448  *                                     memview.dtype_is_object)
21449  */
21450     if (unlikely(!__pyx_v_memviewsliceobj)) { __Pyx_RaiseUnboundLocalError("memviewsliceobj"); __PYX_ERR(3, 778, __pyx_L1_error) }
21451 
21452     /* "View.MemoryView":779
21453  *         return memoryview_fromslice(dst, new_ndim,
21454  *                                     memviewsliceobj.to_object_func,
21455  *                                     memviewsliceobj.to_dtype_func,             # <<<<<<<<<<<<<<
21456  *                                     memview.dtype_is_object)
21457  *     else:
21458  */
21459     if (unlikely(!__pyx_v_memviewsliceobj)) { __Pyx_RaiseUnboundLocalError("memviewsliceobj"); __PYX_ERR(3, 779, __pyx_L1_error) }
21460 
21461     /* "View.MemoryView":777
21462  *
21463  *     if isinstance(memview, _memoryviewslice):
21464  *         return memoryview_fromslice(dst, new_ndim,             # <<<<<<<<<<<<<<
21465  *                                     memviewsliceobj.to_object_func,
21466  *                                     memviewsliceobj.to_dtype_func,
21467  */
21468     __pyx_t_3 = __pyx_memoryview_fromslice(__pyx_v_dst, __pyx_v_new_ndim, __pyx_v_memviewsliceobj->to_object_func, __pyx_v_memviewsliceobj->to_dtype_func, __pyx_v_memview->dtype_is_object); if (unlikely(!__pyx_t_3)) __PYX_ERR(3, 777, __pyx_L1_error)
21469     __Pyx_GOTREF(__pyx_t_3);
21470     if (!(likely(((__pyx_t_3) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_3, __pyx_memoryview_type))))) __PYX_ERR(3, 777, __pyx_L1_error)
21471     __pyx_r = ((struct __pyx_memoryview_obj *)__pyx_t_3);
21472     __pyx_t_3 = 0;
21473     goto __pyx_L0;
21474 
21475     /* "View.MemoryView":776
21476  *             new_ndim += 1
21477  *
21478  *     if isinstance(memview, _memoryviewslice):             # <<<<<<<<<<<<<<
21479  *         return memoryview_fromslice(dst, new_ndim,
21480  *                                     memviewsliceobj.to_object_func,
21481  */
21482   }
21483 
21484   /* "View.MemoryView":782
21485  *                                     memview.dtype_is_object)
21486  *     else:
21487  *         return memoryview_fromslice(dst, new_ndim, NULL, NULL,             # <<<<<<<<<<<<<<
21488  *                                     memview.dtype_is_object)
21489  *
21490  */
21491   /*else*/ {
21492     __Pyx_XDECREF(((PyObject *)__pyx_r));
21493 
21494     /* "View.MemoryView":783
21495  *     else:
21496  *         return memoryview_fromslice(dst, new_ndim, NULL, NULL,
21497  *                                     memview.dtype_is_object)             # <<<<<<<<<<<<<<
21498  *
21499  *
21500  */
21501     __pyx_t_3 = __pyx_memoryview_fromslice(__pyx_v_dst, __pyx_v_new_ndim, NULL, NULL, __pyx_v_memview->dtype_is_object); if (unlikely(!__pyx_t_3)) __PYX_ERR(3, 782, __pyx_L1_error)
21502     __Pyx_GOTREF(__pyx_t_3);
21503 
21504     /* "View.MemoryView":782
21505  *                                     memview.dtype_is_object)
21506  *     else:
21507  *         return memoryview_fromslice(dst, new_ndim, NULL, NULL,             # <<<<<<<<<<<<<<
21508  *                                     memview.dtype_is_object)
21509  *
21510  */
21511     if (!(likely(((__pyx_t_3) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_3, __pyx_memoryview_type))))) __PYX_ERR(3, 782, __pyx_L1_error)
21512     __pyx_r = ((struct __pyx_memoryview_obj *)__pyx_t_3);
21513     __pyx_t_3 = 0;
21514     goto __pyx_L0;
21515   }
21516 
21517   /* "View.MemoryView":710
21518  *
21519  * @cname('__pyx_memview_slice')
21520  * cdef memoryview memview_slice(memoryview memview, object indices):             # <<<<<<<<<<<<<<
21521  *     cdef int new_ndim = 0, suboffset_dim = -1, dim
21522  *     cdef bint negative_step
21523  */
21524 
21525   /* function exit code */
21526   __pyx_L1_error:;
21527   __Pyx_XDECREF(__pyx_t_3);
21528   __Pyx_XDECREF(__pyx_t_9);
21529   __Pyx_AddTraceback("View.MemoryView.memview_slice", __pyx_clineno, __pyx_lineno, __pyx_filename);
21530   __pyx_r = 0;
21531   __pyx_L0:;
21532   __Pyx_XDECREF((PyObject *)__pyx_v_memviewsliceobj);
21533   __Pyx_XDECREF(__pyx_v_index);
21534   __Pyx_XGIVEREF((PyObject *)__pyx_r);
21535   __Pyx_RefNannyFinishContext();
21536   return __pyx_r;
21537 }
21538 
21539 /* "View.MemoryView":807
21540  *
21541  * @cname('__pyx_memoryview_slice_memviewslice')
21542  * cdef int slice_memviewslice(             # <<<<<<<<<<<<<<
21543  *         __Pyx_memviewslice *dst,
21544  *         Py_ssize_t shape, Py_ssize_t stride, Py_ssize_t suboffset,
21545  */
21546 
__pyx_memoryview_slice_memviewslice(__Pyx_memviewslice * __pyx_v_dst,Py_ssize_t __pyx_v_shape,Py_ssize_t __pyx_v_stride,Py_ssize_t __pyx_v_suboffset,int __pyx_v_dim,int __pyx_v_new_ndim,int * __pyx_v_suboffset_dim,Py_ssize_t __pyx_v_start,Py_ssize_t __pyx_v_stop,Py_ssize_t __pyx_v_step,int __pyx_v_have_start,int __pyx_v_have_stop,int __pyx_v_have_step,int __pyx_v_is_slice)21547 static int __pyx_memoryview_slice_memviewslice(__Pyx_memviewslice *__pyx_v_dst, Py_ssize_t __pyx_v_shape, Py_ssize_t __pyx_v_stride, Py_ssize_t __pyx_v_suboffset, int __pyx_v_dim, int __pyx_v_new_ndim, int *__pyx_v_suboffset_dim, Py_ssize_t __pyx_v_start, Py_ssize_t __pyx_v_stop, Py_ssize_t __pyx_v_step, int __pyx_v_have_start, int __pyx_v_have_stop, int __pyx_v_have_step, int __pyx_v_is_slice) {
21548   Py_ssize_t __pyx_v_new_shape;
21549   int __pyx_v_negative_step;
21550   int __pyx_r;
21551   int __pyx_t_1;
21552   int __pyx_t_2;
21553   int __pyx_t_3;
21554   int __pyx_lineno = 0;
21555   const char *__pyx_filename = NULL;
21556   int __pyx_clineno = 0;
21557 
21558   /* "View.MemoryView":827
21559  *     cdef bint negative_step
21560  *
21561  *     if not is_slice:             # <<<<<<<<<<<<<<
21562  *
21563  *         if start < 0:
21564  */
21565   __pyx_t_1 = ((!(__pyx_v_is_slice != 0)) != 0);
21566   if (__pyx_t_1) {
21567 
21568     /* "View.MemoryView":829
21569  *     if not is_slice:
21570  *
21571  *         if start < 0:             # <<<<<<<<<<<<<<
21572  *             start += shape
21573  *         if not 0 <= start < shape:
21574  */
21575     __pyx_t_1 = ((__pyx_v_start < 0) != 0);
21576     if (__pyx_t_1) {
21577 
21578       /* "View.MemoryView":830
21579  *
21580  *         if start < 0:
21581  *             start += shape             # <<<<<<<<<<<<<<
21582  *         if not 0 <= start < shape:
21583  *             _err_dim(IndexError, "Index out of bounds (axis %d)", dim)
21584  */
21585       __pyx_v_start = (__pyx_v_start + __pyx_v_shape);
21586 
21587       /* "View.MemoryView":829
21588  *     if not is_slice:
21589  *
21590  *         if start < 0:             # <<<<<<<<<<<<<<
21591  *             start += shape
21592  *         if not 0 <= start < shape:
21593  */
21594     }
21595 
21596     /* "View.MemoryView":831
21597  *         if start < 0:
21598  *             start += shape
21599  *         if not 0 <= start < shape:             # <<<<<<<<<<<<<<
21600  *             _err_dim(IndexError, "Index out of bounds (axis %d)", dim)
21601  *     else:
21602  */
21603     __pyx_t_1 = (0 <= __pyx_v_start);
21604     if (__pyx_t_1) {
21605       __pyx_t_1 = (__pyx_v_start < __pyx_v_shape);
21606     }
21607     __pyx_t_2 = ((!(__pyx_t_1 != 0)) != 0);
21608     if (__pyx_t_2) {
21609 
21610       /* "View.MemoryView":832
21611  *             start += shape
21612  *         if not 0 <= start < shape:
21613  *             _err_dim(IndexError, "Index out of bounds (axis %d)", dim)             # <<<<<<<<<<<<<<
21614  *     else:
21615  *
21616  */
21617       __pyx_t_3 = __pyx_memoryview_err_dim(__pyx_builtin_IndexError, ((char *)"Index out of bounds (axis %d)"), __pyx_v_dim); if (unlikely(__pyx_t_3 == ((int)-1))) __PYX_ERR(3, 832, __pyx_L1_error)
21618 
21619       /* "View.MemoryView":831
21620  *         if start < 0:
21621  *             start += shape
21622  *         if not 0 <= start < shape:             # <<<<<<<<<<<<<<
21623  *             _err_dim(IndexError, "Index out of bounds (axis %d)", dim)
21624  *     else:
21625  */
21626     }
21627 
21628     /* "View.MemoryView":827
21629  *     cdef bint negative_step
21630  *
21631  *     if not is_slice:             # <<<<<<<<<<<<<<
21632  *
21633  *         if start < 0:
21634  */
21635     goto __pyx_L3;
21636   }
21637 
21638   /* "View.MemoryView":835
21639  *     else:
21640  *
21641  *         negative_step = have_step != 0 and step < 0             # <<<<<<<<<<<<<<
21642  *
21643  *         if have_step and step == 0:
21644  */
21645   /*else*/ {
21646     __pyx_t_1 = ((__pyx_v_have_step != 0) != 0);
21647     if (__pyx_t_1) {
21648     } else {
21649       __pyx_t_2 = __pyx_t_1;
21650       goto __pyx_L6_bool_binop_done;
21651     }
21652     __pyx_t_1 = ((__pyx_v_step < 0) != 0);
21653     __pyx_t_2 = __pyx_t_1;
21654     __pyx_L6_bool_binop_done:;
21655     __pyx_v_negative_step = __pyx_t_2;
21656 
21657     /* "View.MemoryView":837
21658  *         negative_step = have_step != 0 and step < 0
21659  *
21660  *         if have_step and step == 0:             # <<<<<<<<<<<<<<
21661  *             _err_dim(ValueError, "Step may not be zero (axis %d)", dim)
21662  *
21663  */
21664     __pyx_t_1 = (__pyx_v_have_step != 0);
21665     if (__pyx_t_1) {
21666     } else {
21667       __pyx_t_2 = __pyx_t_1;
21668       goto __pyx_L9_bool_binop_done;
21669     }
21670     __pyx_t_1 = ((__pyx_v_step == 0) != 0);
21671     __pyx_t_2 = __pyx_t_1;
21672     __pyx_L9_bool_binop_done:;
21673     if (__pyx_t_2) {
21674 
21675       /* "View.MemoryView":838
21676  *
21677  *         if have_step and step == 0:
21678  *             _err_dim(ValueError, "Step may not be zero (axis %d)", dim)             # <<<<<<<<<<<<<<
21679  *
21680  *
21681  */
21682       __pyx_t_3 = __pyx_memoryview_err_dim(__pyx_builtin_ValueError, ((char *)"Step may not be zero (axis %d)"), __pyx_v_dim); if (unlikely(__pyx_t_3 == ((int)-1))) __PYX_ERR(3, 838, __pyx_L1_error)
21683 
21684       /* "View.MemoryView":837
21685  *         negative_step = have_step != 0 and step < 0
21686  *
21687  *         if have_step and step == 0:             # <<<<<<<<<<<<<<
21688  *             _err_dim(ValueError, "Step may not be zero (axis %d)", dim)
21689  *
21690  */
21691     }
21692 
21693     /* "View.MemoryView":841
21694  *
21695  *
21696  *         if have_start:             # <<<<<<<<<<<<<<
21697  *             if start < 0:
21698  *                 start += shape
21699  */
21700     __pyx_t_2 = (__pyx_v_have_start != 0);
21701     if (__pyx_t_2) {
21702 
21703       /* "View.MemoryView":842
21704  *
21705  *         if have_start:
21706  *             if start < 0:             # <<<<<<<<<<<<<<
21707  *                 start += shape
21708  *                 if start < 0:
21709  */
21710       __pyx_t_2 = ((__pyx_v_start < 0) != 0);
21711       if (__pyx_t_2) {
21712 
21713         /* "View.MemoryView":843
21714  *         if have_start:
21715  *             if start < 0:
21716  *                 start += shape             # <<<<<<<<<<<<<<
21717  *                 if start < 0:
21718  *                     start = 0
21719  */
21720         __pyx_v_start = (__pyx_v_start + __pyx_v_shape);
21721 
21722         /* "View.MemoryView":844
21723  *             if start < 0:
21724  *                 start += shape
21725  *                 if start < 0:             # <<<<<<<<<<<<<<
21726  *                     start = 0
21727  *             elif start >= shape:
21728  */
21729         __pyx_t_2 = ((__pyx_v_start < 0) != 0);
21730         if (__pyx_t_2) {
21731 
21732           /* "View.MemoryView":845
21733  *                 start += shape
21734  *                 if start < 0:
21735  *                     start = 0             # <<<<<<<<<<<<<<
21736  *             elif start >= shape:
21737  *                 if negative_step:
21738  */
21739           __pyx_v_start = 0;
21740 
21741           /* "View.MemoryView":844
21742  *             if start < 0:
21743  *                 start += shape
21744  *                 if start < 0:             # <<<<<<<<<<<<<<
21745  *                     start = 0
21746  *             elif start >= shape:
21747  */
21748         }
21749 
21750         /* "View.MemoryView":842
21751  *
21752  *         if have_start:
21753  *             if start < 0:             # <<<<<<<<<<<<<<
21754  *                 start += shape
21755  *                 if start < 0:
21756  */
21757         goto __pyx_L12;
21758       }
21759 
21760       /* "View.MemoryView":846
21761  *                 if start < 0:
21762  *                     start = 0
21763  *             elif start >= shape:             # <<<<<<<<<<<<<<
21764  *                 if negative_step:
21765  *                     start = shape - 1
21766  */
21767       __pyx_t_2 = ((__pyx_v_start >= __pyx_v_shape) != 0);
21768       if (__pyx_t_2) {
21769 
21770         /* "View.MemoryView":847
21771  *                     start = 0
21772  *             elif start >= shape:
21773  *                 if negative_step:             # <<<<<<<<<<<<<<
21774  *                     start = shape - 1
21775  *                 else:
21776  */
21777         __pyx_t_2 = (__pyx_v_negative_step != 0);
21778         if (__pyx_t_2) {
21779 
21780           /* "View.MemoryView":848
21781  *             elif start >= shape:
21782  *                 if negative_step:
21783  *                     start = shape - 1             # <<<<<<<<<<<<<<
21784  *                 else:
21785  *                     start = shape
21786  */
21787           __pyx_v_start = (__pyx_v_shape - 1);
21788 
21789           /* "View.MemoryView":847
21790  *                     start = 0
21791  *             elif start >= shape:
21792  *                 if negative_step:             # <<<<<<<<<<<<<<
21793  *                     start = shape - 1
21794  *                 else:
21795  */
21796           goto __pyx_L14;
21797         }
21798 
21799         /* "View.MemoryView":850
21800  *                     start = shape - 1
21801  *                 else:
21802  *                     start = shape             # <<<<<<<<<<<<<<
21803  *         else:
21804  *             if negative_step:
21805  */
21806         /*else*/ {
21807           __pyx_v_start = __pyx_v_shape;
21808         }
21809         __pyx_L14:;
21810 
21811         /* "View.MemoryView":846
21812  *                 if start < 0:
21813  *                     start = 0
21814  *             elif start >= shape:             # <<<<<<<<<<<<<<
21815  *                 if negative_step:
21816  *                     start = shape - 1
21817  */
21818       }
21819       __pyx_L12:;
21820 
21821       /* "View.MemoryView":841
21822  *
21823  *
21824  *         if have_start:             # <<<<<<<<<<<<<<
21825  *             if start < 0:
21826  *                 start += shape
21827  */
21828       goto __pyx_L11;
21829     }
21830 
21831     /* "View.MemoryView":852
21832  *                     start = shape
21833  *         else:
21834  *             if negative_step:             # <<<<<<<<<<<<<<
21835  *                 start = shape - 1
21836  *             else:
21837  */
21838     /*else*/ {
21839       __pyx_t_2 = (__pyx_v_negative_step != 0);
21840       if (__pyx_t_2) {
21841 
21842         /* "View.MemoryView":853
21843  *         else:
21844  *             if negative_step:
21845  *                 start = shape - 1             # <<<<<<<<<<<<<<
21846  *             else:
21847  *                 start = 0
21848  */
21849         __pyx_v_start = (__pyx_v_shape - 1);
21850 
21851         /* "View.MemoryView":852
21852  *                     start = shape
21853  *         else:
21854  *             if negative_step:             # <<<<<<<<<<<<<<
21855  *                 start = shape - 1
21856  *             else:
21857  */
21858         goto __pyx_L15;
21859       }
21860 
21861       /* "View.MemoryView":855
21862  *                 start = shape - 1
21863  *             else:
21864  *                 start = 0             # <<<<<<<<<<<<<<
21865  *
21866  *         if have_stop:
21867  */
21868       /*else*/ {
21869         __pyx_v_start = 0;
21870       }
21871       __pyx_L15:;
21872     }
21873     __pyx_L11:;
21874 
21875     /* "View.MemoryView":857
21876  *                 start = 0
21877  *
21878  *         if have_stop:             # <<<<<<<<<<<<<<
21879  *             if stop < 0:
21880  *                 stop += shape
21881  */
21882     __pyx_t_2 = (__pyx_v_have_stop != 0);
21883     if (__pyx_t_2) {
21884 
21885       /* "View.MemoryView":858
21886  *
21887  *         if have_stop:
21888  *             if stop < 0:             # <<<<<<<<<<<<<<
21889  *                 stop += shape
21890  *                 if stop < 0:
21891  */
21892       __pyx_t_2 = ((__pyx_v_stop < 0) != 0);
21893       if (__pyx_t_2) {
21894 
21895         /* "View.MemoryView":859
21896  *         if have_stop:
21897  *             if stop < 0:
21898  *                 stop += shape             # <<<<<<<<<<<<<<
21899  *                 if stop < 0:
21900  *                     stop = 0
21901  */
21902         __pyx_v_stop = (__pyx_v_stop + __pyx_v_shape);
21903 
21904         /* "View.MemoryView":860
21905  *             if stop < 0:
21906  *                 stop += shape
21907  *                 if stop < 0:             # <<<<<<<<<<<<<<
21908  *                     stop = 0
21909  *             elif stop > shape:
21910  */
21911         __pyx_t_2 = ((__pyx_v_stop < 0) != 0);
21912         if (__pyx_t_2) {
21913 
21914           /* "View.MemoryView":861
21915  *                 stop += shape
21916  *                 if stop < 0:
21917  *                     stop = 0             # <<<<<<<<<<<<<<
21918  *             elif stop > shape:
21919  *                 stop = shape
21920  */
21921           __pyx_v_stop = 0;
21922 
21923           /* "View.MemoryView":860
21924  *             if stop < 0:
21925  *                 stop += shape
21926  *                 if stop < 0:             # <<<<<<<<<<<<<<
21927  *                     stop = 0
21928  *             elif stop > shape:
21929  */
21930         }
21931 
21932         /* "View.MemoryView":858
21933  *
21934  *         if have_stop:
21935  *             if stop < 0:             # <<<<<<<<<<<<<<
21936  *                 stop += shape
21937  *                 if stop < 0:
21938  */
21939         goto __pyx_L17;
21940       }
21941 
21942       /* "View.MemoryView":862
21943  *                 if stop < 0:
21944  *                     stop = 0
21945  *             elif stop > shape:             # <<<<<<<<<<<<<<
21946  *                 stop = shape
21947  *         else:
21948  */
21949       __pyx_t_2 = ((__pyx_v_stop > __pyx_v_shape) != 0);
21950       if (__pyx_t_2) {
21951 
21952         /* "View.MemoryView":863
21953  *                     stop = 0
21954  *             elif stop > shape:
21955  *                 stop = shape             # <<<<<<<<<<<<<<
21956  *         else:
21957  *             if negative_step:
21958  */
21959         __pyx_v_stop = __pyx_v_shape;
21960 
21961         /* "View.MemoryView":862
21962  *                 if stop < 0:
21963  *                     stop = 0
21964  *             elif stop > shape:             # <<<<<<<<<<<<<<
21965  *                 stop = shape
21966  *         else:
21967  */
21968       }
21969       __pyx_L17:;
21970 
21971       /* "View.MemoryView":857
21972  *                 start = 0
21973  *
21974  *         if have_stop:             # <<<<<<<<<<<<<<
21975  *             if stop < 0:
21976  *                 stop += shape
21977  */
21978       goto __pyx_L16;
21979     }
21980 
21981     /* "View.MemoryView":865
21982  *                 stop = shape
21983  *         else:
21984  *             if negative_step:             # <<<<<<<<<<<<<<
21985  *                 stop = -1
21986  *             else:
21987  */
21988     /*else*/ {
21989       __pyx_t_2 = (__pyx_v_negative_step != 0);
21990       if (__pyx_t_2) {
21991 
21992         /* "View.MemoryView":866
21993  *         else:
21994  *             if negative_step:
21995  *                 stop = -1             # <<<<<<<<<<<<<<
21996  *             else:
21997  *                 stop = shape
21998  */
21999         __pyx_v_stop = -1L;
22000 
22001         /* "View.MemoryView":865
22002  *                 stop = shape
22003  *         else:
22004  *             if negative_step:             # <<<<<<<<<<<<<<
22005  *                 stop = -1
22006  *             else:
22007  */
22008         goto __pyx_L19;
22009       }
22010 
22011       /* "View.MemoryView":868
22012  *                 stop = -1
22013  *             else:
22014  *                 stop = shape             # <<<<<<<<<<<<<<
22015  *
22016  *         if not have_step:
22017  */
22018       /*else*/ {
22019         __pyx_v_stop = __pyx_v_shape;
22020       }
22021       __pyx_L19:;
22022     }
22023     __pyx_L16:;
22024 
22025     /* "View.MemoryView":870
22026  *                 stop = shape
22027  *
22028  *         if not have_step:             # <<<<<<<<<<<<<<
22029  *             step = 1
22030  *
22031  */
22032     __pyx_t_2 = ((!(__pyx_v_have_step != 0)) != 0);
22033     if (__pyx_t_2) {
22034 
22035       /* "View.MemoryView":871
22036  *
22037  *         if not have_step:
22038  *             step = 1             # <<<<<<<<<<<<<<
22039  *
22040  *
22041  */
22042       __pyx_v_step = 1;
22043 
22044       /* "View.MemoryView":870
22045  *                 stop = shape
22046  *
22047  *         if not have_step:             # <<<<<<<<<<<<<<
22048  *             step = 1
22049  *
22050  */
22051     }
22052 
22053     /* "View.MemoryView":875
22054  *
22055  *         with cython.cdivision(True):
22056  *             new_shape = (stop - start) // step             # <<<<<<<<<<<<<<
22057  *
22058  *             if (stop - start) - step * new_shape:
22059  */
22060     __pyx_v_new_shape = ((__pyx_v_stop - __pyx_v_start) / __pyx_v_step);
22061 
22062     /* "View.MemoryView":877
22063  *             new_shape = (stop - start) // step
22064  *
22065  *             if (stop - start) - step * new_shape:             # <<<<<<<<<<<<<<
22066  *                 new_shape += 1
22067  *
22068  */
22069     __pyx_t_2 = (((__pyx_v_stop - __pyx_v_start) - (__pyx_v_step * __pyx_v_new_shape)) != 0);
22070     if (__pyx_t_2) {
22071 
22072       /* "View.MemoryView":878
22073  *
22074  *             if (stop - start) - step * new_shape:
22075  *                 new_shape += 1             # <<<<<<<<<<<<<<
22076  *
22077  *         if new_shape < 0:
22078  */
22079       __pyx_v_new_shape = (__pyx_v_new_shape + 1);
22080 
22081       /* "View.MemoryView":877
22082  *             new_shape = (stop - start) // step
22083  *
22084  *             if (stop - start) - step * new_shape:             # <<<<<<<<<<<<<<
22085  *                 new_shape += 1
22086  *
22087  */
22088     }
22089 
22090     /* "View.MemoryView":880
22091  *                 new_shape += 1
22092  *
22093  *         if new_shape < 0:             # <<<<<<<<<<<<<<
22094  *             new_shape = 0
22095  *
22096  */
22097     __pyx_t_2 = ((__pyx_v_new_shape < 0) != 0);
22098     if (__pyx_t_2) {
22099 
22100       /* "View.MemoryView":881
22101  *
22102  *         if new_shape < 0:
22103  *             new_shape = 0             # <<<<<<<<<<<<<<
22104  *
22105  *
22106  */
22107       __pyx_v_new_shape = 0;
22108 
22109       /* "View.MemoryView":880
22110  *                 new_shape += 1
22111  *
22112  *         if new_shape < 0:             # <<<<<<<<<<<<<<
22113  *             new_shape = 0
22114  *
22115  */
22116     }
22117 
22118     /* "View.MemoryView":884
22119  *
22120  *
22121  *         dst.strides[new_ndim] = stride * step             # <<<<<<<<<<<<<<
22122  *         dst.shape[new_ndim] = new_shape
22123  *         dst.suboffsets[new_ndim] = suboffset
22124  */
22125     (__pyx_v_dst->strides[__pyx_v_new_ndim]) = (__pyx_v_stride * __pyx_v_step);
22126 
22127     /* "View.MemoryView":885
22128  *
22129  *         dst.strides[new_ndim] = stride * step
22130  *         dst.shape[new_ndim] = new_shape             # <<<<<<<<<<<<<<
22131  *         dst.suboffsets[new_ndim] = suboffset
22132  *
22133  */
22134     (__pyx_v_dst->shape[__pyx_v_new_ndim]) = __pyx_v_new_shape;
22135 
22136     /* "View.MemoryView":886
22137  *         dst.strides[new_ndim] = stride * step
22138  *         dst.shape[new_ndim] = new_shape
22139  *         dst.suboffsets[new_ndim] = suboffset             # <<<<<<<<<<<<<<
22140  *
22141  *
22142  */
22143     (__pyx_v_dst->suboffsets[__pyx_v_new_ndim]) = __pyx_v_suboffset;
22144   }
22145   __pyx_L3:;
22146 
22147   /* "View.MemoryView":889
22148  *
22149  *
22150  *     if suboffset_dim[0] < 0:             # <<<<<<<<<<<<<<
22151  *         dst.data += start * stride
22152  *     else:
22153  */
22154   __pyx_t_2 = (((__pyx_v_suboffset_dim[0]) < 0) != 0);
22155   if (__pyx_t_2) {
22156 
22157     /* "View.MemoryView":890
22158  *
22159  *     if suboffset_dim[0] < 0:
22160  *         dst.data += start * stride             # <<<<<<<<<<<<<<
22161  *     else:
22162  *         dst.suboffsets[suboffset_dim[0]] += start * stride
22163  */
22164     __pyx_v_dst->data = (__pyx_v_dst->data + (__pyx_v_start * __pyx_v_stride));
22165 
22166     /* "View.MemoryView":889
22167  *
22168  *
22169  *     if suboffset_dim[0] < 0:             # <<<<<<<<<<<<<<
22170  *         dst.data += start * stride
22171  *     else:
22172  */
22173     goto __pyx_L23;
22174   }
22175 
22176   /* "View.MemoryView":892
22177  *         dst.data += start * stride
22178  *     else:
22179  *         dst.suboffsets[suboffset_dim[0]] += start * stride             # <<<<<<<<<<<<<<
22180  *
22181  *     if suboffset >= 0:
22182  */
22183   /*else*/ {
22184     __pyx_t_3 = (__pyx_v_suboffset_dim[0]);
22185     (__pyx_v_dst->suboffsets[__pyx_t_3]) = ((__pyx_v_dst->suboffsets[__pyx_t_3]) + (__pyx_v_start * __pyx_v_stride));
22186   }
22187   __pyx_L23:;
22188 
22189   /* "View.MemoryView":894
22190  *         dst.suboffsets[suboffset_dim[0]] += start * stride
22191  *
22192  *     if suboffset >= 0:             # <<<<<<<<<<<<<<
22193  *         if not is_slice:
22194  *             if new_ndim == 0:
22195  */
22196   __pyx_t_2 = ((__pyx_v_suboffset >= 0) != 0);
22197   if (__pyx_t_2) {
22198 
22199     /* "View.MemoryView":895
22200  *
22201  *     if suboffset >= 0:
22202  *         if not is_slice:             # <<<<<<<<<<<<<<
22203  *             if new_ndim == 0:
22204  *                 dst.data = (<char **> dst.data)[0] + suboffset
22205  */
22206     __pyx_t_2 = ((!(__pyx_v_is_slice != 0)) != 0);
22207     if (__pyx_t_2) {
22208 
22209       /* "View.MemoryView":896
22210  *     if suboffset >= 0:
22211  *         if not is_slice:
22212  *             if new_ndim == 0:             # <<<<<<<<<<<<<<
22213  *                 dst.data = (<char **> dst.data)[0] + suboffset
22214  *             else:
22215  */
22216       __pyx_t_2 = ((__pyx_v_new_ndim == 0) != 0);
22217       if (__pyx_t_2) {
22218 
22219         /* "View.MemoryView":897
22220  *         if not is_slice:
22221  *             if new_ndim == 0:
22222  *                 dst.data = (<char **> dst.data)[0] + suboffset             # <<<<<<<<<<<<<<
22223  *             else:
22224  *                 _err_dim(IndexError, "All dimensions preceding dimension %d "
22225  */
22226         __pyx_v_dst->data = ((((char **)__pyx_v_dst->data)[0]) + __pyx_v_suboffset);
22227 
22228         /* "View.MemoryView":896
22229  *     if suboffset >= 0:
22230  *         if not is_slice:
22231  *             if new_ndim == 0:             # <<<<<<<<<<<<<<
22232  *                 dst.data = (<char **> dst.data)[0] + suboffset
22233  *             else:
22234  */
22235         goto __pyx_L26;
22236       }
22237 
22238       /* "View.MemoryView":899
22239  *                 dst.data = (<char **> dst.data)[0] + suboffset
22240  *             else:
22241  *                 _err_dim(IndexError, "All dimensions preceding dimension %d "             # <<<<<<<<<<<<<<
22242  *                                      "must be indexed and not sliced", dim)
22243  *         else:
22244  */
22245       /*else*/ {
22246 
22247         /* "View.MemoryView":900
22248  *             else:
22249  *                 _err_dim(IndexError, "All dimensions preceding dimension %d "
22250  *                                      "must be indexed and not sliced", dim)             # <<<<<<<<<<<<<<
22251  *         else:
22252  *             suboffset_dim[0] = new_ndim
22253  */
22254         __pyx_t_3 = __pyx_memoryview_err_dim(__pyx_builtin_IndexError, ((char *)"All dimensions preceding dimension %d must be indexed and not sliced"), __pyx_v_dim); if (unlikely(__pyx_t_3 == ((int)-1))) __PYX_ERR(3, 899, __pyx_L1_error)
22255       }
22256       __pyx_L26:;
22257 
22258       /* "View.MemoryView":895
22259  *
22260  *     if suboffset >= 0:
22261  *         if not is_slice:             # <<<<<<<<<<<<<<
22262  *             if new_ndim == 0:
22263  *                 dst.data = (<char **> dst.data)[0] + suboffset
22264  */
22265       goto __pyx_L25;
22266     }
22267 
22268     /* "View.MemoryView":902
22269  *                                      "must be indexed and not sliced", dim)
22270  *         else:
22271  *             suboffset_dim[0] = new_ndim             # <<<<<<<<<<<<<<
22272  *
22273  *     return 0
22274  */
22275     /*else*/ {
22276       (__pyx_v_suboffset_dim[0]) = __pyx_v_new_ndim;
22277     }
22278     __pyx_L25:;
22279 
22280     /* "View.MemoryView":894
22281  *         dst.suboffsets[suboffset_dim[0]] += start * stride
22282  *
22283  *     if suboffset >= 0:             # <<<<<<<<<<<<<<
22284  *         if not is_slice:
22285  *             if new_ndim == 0:
22286  */
22287   }
22288 
22289   /* "View.MemoryView":904
22290  *             suboffset_dim[0] = new_ndim
22291  *
22292  *     return 0             # <<<<<<<<<<<<<<
22293  *
22294  *
22295  */
22296   __pyx_r = 0;
22297   goto __pyx_L0;
22298 
22299   /* "View.MemoryView":807
22300  *
22301  * @cname('__pyx_memoryview_slice_memviewslice')
22302  * cdef int slice_memviewslice(             # <<<<<<<<<<<<<<
22303  *         __Pyx_memviewslice *dst,
22304  *         Py_ssize_t shape, Py_ssize_t stride, Py_ssize_t suboffset,
22305  */
22306 
22307   /* function exit code */
22308   __pyx_L1_error:;
22309   {
22310     #ifdef WITH_THREAD
22311     PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure();
22312     #endif
22313     __Pyx_AddTraceback("View.MemoryView.slice_memviewslice", __pyx_clineno, __pyx_lineno, __pyx_filename);
22314     #ifdef WITH_THREAD
22315     __Pyx_PyGILState_Release(__pyx_gilstate_save);
22316     #endif
22317   }
22318   __pyx_r = -1;
22319   __pyx_L0:;
22320   return __pyx_r;
22321 }
22322 
22323 /* "View.MemoryView":910
22324  *
22325  * @cname('__pyx_pybuffer_index')
22326  * cdef char *pybuffer_index(Py_buffer *view, char *bufp, Py_ssize_t index,             # <<<<<<<<<<<<<<
22327  *                           Py_ssize_t dim) except NULL:
22328  *     cdef Py_ssize_t shape, stride, suboffset = -1
22329  */
22330 
__pyx_pybuffer_index(Py_buffer * __pyx_v_view,char * __pyx_v_bufp,Py_ssize_t __pyx_v_index,Py_ssize_t __pyx_v_dim)22331 static char *__pyx_pybuffer_index(Py_buffer *__pyx_v_view, char *__pyx_v_bufp, Py_ssize_t __pyx_v_index, Py_ssize_t __pyx_v_dim) {
22332   Py_ssize_t __pyx_v_shape;
22333   Py_ssize_t __pyx_v_stride;
22334   Py_ssize_t __pyx_v_suboffset;
22335   Py_ssize_t __pyx_v_itemsize;
22336   char *__pyx_v_resultp;
22337   char *__pyx_r;
22338   __Pyx_RefNannyDeclarations
22339   Py_ssize_t __pyx_t_1;
22340   int __pyx_t_2;
22341   PyObject *__pyx_t_3 = NULL;
22342   PyObject *__pyx_t_4 = NULL;
22343   int __pyx_lineno = 0;
22344   const char *__pyx_filename = NULL;
22345   int __pyx_clineno = 0;
22346   __Pyx_RefNannySetupContext("pybuffer_index", 0);
22347 
22348   /* "View.MemoryView":912
22349  * cdef char *pybuffer_index(Py_buffer *view, char *bufp, Py_ssize_t index,
22350  *                           Py_ssize_t dim) except NULL:
22351  *     cdef Py_ssize_t shape, stride, suboffset = -1             # <<<<<<<<<<<<<<
22352  *     cdef Py_ssize_t itemsize = view.itemsize
22353  *     cdef char *resultp
22354  */
22355   __pyx_v_suboffset = -1L;
22356 
22357   /* "View.MemoryView":913
22358  *                           Py_ssize_t dim) except NULL:
22359  *     cdef Py_ssize_t shape, stride, suboffset = -1
22360  *     cdef Py_ssize_t itemsize = view.itemsize             # <<<<<<<<<<<<<<
22361  *     cdef char *resultp
22362  *
22363  */
22364   __pyx_t_1 = __pyx_v_view->itemsize;
22365   __pyx_v_itemsize = __pyx_t_1;
22366 
22367   /* "View.MemoryView":916
22368  *     cdef char *resultp
22369  *
22370  *     if view.ndim == 0:             # <<<<<<<<<<<<<<
22371  *         shape = view.len / itemsize
22372  *         stride = itemsize
22373  */
22374   __pyx_t_2 = ((__pyx_v_view->ndim == 0) != 0);
22375   if (__pyx_t_2) {
22376 
22377     /* "View.MemoryView":917
22378  *
22379  *     if view.ndim == 0:
22380  *         shape = view.len / itemsize             # <<<<<<<<<<<<<<
22381  *         stride = itemsize
22382  *     else:
22383  */
22384     if (unlikely(__pyx_v_itemsize == 0)) {
22385       PyErr_SetString(PyExc_ZeroDivisionError, "integer division or modulo by zero");
22386       __PYX_ERR(3, 917, __pyx_L1_error)
22387     }
22388     else if (sizeof(Py_ssize_t) == sizeof(long) && (!(((Py_ssize_t)-1) > 0)) && unlikely(__pyx_v_itemsize == (Py_ssize_t)-1)  && unlikely(UNARY_NEG_WOULD_OVERFLOW(__pyx_v_view->len))) {
22389       PyErr_SetString(PyExc_OverflowError, "value too large to perform division");
22390       __PYX_ERR(3, 917, __pyx_L1_error)
22391     }
22392     __pyx_v_shape = __Pyx_div_Py_ssize_t(__pyx_v_view->len, __pyx_v_itemsize);
22393 
22394     /* "View.MemoryView":918
22395  *     if view.ndim == 0:
22396  *         shape = view.len / itemsize
22397  *         stride = itemsize             # <<<<<<<<<<<<<<
22398  *     else:
22399  *         shape = view.shape[dim]
22400  */
22401     __pyx_v_stride = __pyx_v_itemsize;
22402 
22403     /* "View.MemoryView":916
22404  *     cdef char *resultp
22405  *
22406  *     if view.ndim == 0:             # <<<<<<<<<<<<<<
22407  *         shape = view.len / itemsize
22408  *         stride = itemsize
22409  */
22410     goto __pyx_L3;
22411   }
22412 
22413   /* "View.MemoryView":920
22414  *         stride = itemsize
22415  *     else:
22416  *         shape = view.shape[dim]             # <<<<<<<<<<<<<<
22417  *         stride = view.strides[dim]
22418  *         if view.suboffsets != NULL:
22419  */
22420   /*else*/ {
22421     __pyx_v_shape = (__pyx_v_view->shape[__pyx_v_dim]);
22422 
22423     /* "View.MemoryView":921
22424  *     else:
22425  *         shape = view.shape[dim]
22426  *         stride = view.strides[dim]             # <<<<<<<<<<<<<<
22427  *         if view.suboffsets != NULL:
22428  *             suboffset = view.suboffsets[dim]
22429  */
22430     __pyx_v_stride = (__pyx_v_view->strides[__pyx_v_dim]);
22431 
22432     /* "View.MemoryView":922
22433  *         shape = view.shape[dim]
22434  *         stride = view.strides[dim]
22435  *         if view.suboffsets != NULL:             # <<<<<<<<<<<<<<
22436  *             suboffset = view.suboffsets[dim]
22437  *
22438  */
22439     __pyx_t_2 = ((__pyx_v_view->suboffsets != NULL) != 0);
22440     if (__pyx_t_2) {
22441 
22442       /* "View.MemoryView":923
22443  *         stride = view.strides[dim]
22444  *         if view.suboffsets != NULL:
22445  *             suboffset = view.suboffsets[dim]             # <<<<<<<<<<<<<<
22446  *
22447  *     if index < 0:
22448  */
22449       __pyx_v_suboffset = (__pyx_v_view->suboffsets[__pyx_v_dim]);
22450 
22451       /* "View.MemoryView":922
22452  *         shape = view.shape[dim]
22453  *         stride = view.strides[dim]
22454  *         if view.suboffsets != NULL:             # <<<<<<<<<<<<<<
22455  *             suboffset = view.suboffsets[dim]
22456  *
22457  */
22458     }
22459   }
22460   __pyx_L3:;
22461 
22462   /* "View.MemoryView":925
22463  *             suboffset = view.suboffsets[dim]
22464  *
22465  *     if index < 0:             # <<<<<<<<<<<<<<
22466  *         index += view.shape[dim]
22467  *         if index < 0:
22468  */
22469   __pyx_t_2 = ((__pyx_v_index < 0) != 0);
22470   if (__pyx_t_2) {
22471 
22472     /* "View.MemoryView":926
22473  *
22474  *     if index < 0:
22475  *         index += view.shape[dim]             # <<<<<<<<<<<<<<
22476  *         if index < 0:
22477  *             raise IndexError("Out of bounds on buffer access (axis %d)" % dim)
22478  */
22479     __pyx_v_index = (__pyx_v_index + (__pyx_v_view->shape[__pyx_v_dim]));
22480 
22481     /* "View.MemoryView":927
22482  *     if index < 0:
22483  *         index += view.shape[dim]
22484  *         if index < 0:             # <<<<<<<<<<<<<<
22485  *             raise IndexError("Out of bounds on buffer access (axis %d)" % dim)
22486  *
22487  */
22488     __pyx_t_2 = ((__pyx_v_index < 0) != 0);
22489     if (unlikely(__pyx_t_2)) {
22490 
22491       /* "View.MemoryView":928
22492  *         index += view.shape[dim]
22493  *         if index < 0:
22494  *             raise IndexError("Out of bounds on buffer access (axis %d)" % dim)             # <<<<<<<<<<<<<<
22495  *
22496  *     if index >= shape:
22497  */
22498       __pyx_t_3 = PyInt_FromSsize_t(__pyx_v_dim); if (unlikely(!__pyx_t_3)) __PYX_ERR(3, 928, __pyx_L1_error)
22499       __Pyx_GOTREF(__pyx_t_3);
22500       __pyx_t_4 = __Pyx_PyString_Format(__pyx_kp_s_Out_of_bounds_on_buffer_access_a, __pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(3, 928, __pyx_L1_error)
22501       __Pyx_GOTREF(__pyx_t_4);
22502       __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
22503       __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_builtin_IndexError, __pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(3, 928, __pyx_L1_error)
22504       __Pyx_GOTREF(__pyx_t_3);
22505       __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
22506       __Pyx_Raise(__pyx_t_3, 0, 0, 0);
22507       __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
22508       __PYX_ERR(3, 928, __pyx_L1_error)
22509 
22510       /* "View.MemoryView":927
22511  *     if index < 0:
22512  *         index += view.shape[dim]
22513  *         if index < 0:             # <<<<<<<<<<<<<<
22514  *             raise IndexError("Out of bounds on buffer access (axis %d)" % dim)
22515  *
22516  */
22517     }
22518 
22519     /* "View.MemoryView":925
22520  *             suboffset = view.suboffsets[dim]
22521  *
22522  *     if index < 0:             # <<<<<<<<<<<<<<
22523  *         index += view.shape[dim]
22524  *         if index < 0:
22525  */
22526   }
22527 
22528   /* "View.MemoryView":930
22529  *             raise IndexError("Out of bounds on buffer access (axis %d)" % dim)
22530  *
22531  *     if index >= shape:             # <<<<<<<<<<<<<<
22532  *         raise IndexError("Out of bounds on buffer access (axis %d)" % dim)
22533  *
22534  */
22535   __pyx_t_2 = ((__pyx_v_index >= __pyx_v_shape) != 0);
22536   if (unlikely(__pyx_t_2)) {
22537 
22538     /* "View.MemoryView":931
22539  *
22540  *     if index >= shape:
22541  *         raise IndexError("Out of bounds on buffer access (axis %d)" % dim)             # <<<<<<<<<<<<<<
22542  *
22543  *     resultp = bufp + index * stride
22544  */
22545     __pyx_t_3 = PyInt_FromSsize_t(__pyx_v_dim); if (unlikely(!__pyx_t_3)) __PYX_ERR(3, 931, __pyx_L1_error)
22546     __Pyx_GOTREF(__pyx_t_3);
22547     __pyx_t_4 = __Pyx_PyString_Format(__pyx_kp_s_Out_of_bounds_on_buffer_access_a, __pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(3, 931, __pyx_L1_error)
22548     __Pyx_GOTREF(__pyx_t_4);
22549     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
22550     __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_builtin_IndexError, __pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(3, 931, __pyx_L1_error)
22551     __Pyx_GOTREF(__pyx_t_3);
22552     __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
22553     __Pyx_Raise(__pyx_t_3, 0, 0, 0);
22554     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
22555     __PYX_ERR(3, 931, __pyx_L1_error)
22556 
22557     /* "View.MemoryView":930
22558  *             raise IndexError("Out of bounds on buffer access (axis %d)" % dim)
22559  *
22560  *     if index >= shape:             # <<<<<<<<<<<<<<
22561  *         raise IndexError("Out of bounds on buffer access (axis %d)" % dim)
22562  *
22563  */
22564   }
22565 
22566   /* "View.MemoryView":933
22567  *         raise IndexError("Out of bounds on buffer access (axis %d)" % dim)
22568  *
22569  *     resultp = bufp + index * stride             # <<<<<<<<<<<<<<
22570  *     if suboffset >= 0:
22571  *         resultp = (<char **> resultp)[0] + suboffset
22572  */
22573   __pyx_v_resultp = (__pyx_v_bufp + (__pyx_v_index * __pyx_v_stride));
22574 
22575   /* "View.MemoryView":934
22576  *
22577  *     resultp = bufp + index * stride
22578  *     if suboffset >= 0:             # <<<<<<<<<<<<<<
22579  *         resultp = (<char **> resultp)[0] + suboffset
22580  *
22581  */
22582   __pyx_t_2 = ((__pyx_v_suboffset >= 0) != 0);
22583   if (__pyx_t_2) {
22584 
22585     /* "View.MemoryView":935
22586  *     resultp = bufp + index * stride
22587  *     if suboffset >= 0:
22588  *         resultp = (<char **> resultp)[0] + suboffset             # <<<<<<<<<<<<<<
22589  *
22590  *     return resultp
22591  */
22592     __pyx_v_resultp = ((((char **)__pyx_v_resultp)[0]) + __pyx_v_suboffset);
22593 
22594     /* "View.MemoryView":934
22595  *
22596  *     resultp = bufp + index * stride
22597  *     if suboffset >= 0:             # <<<<<<<<<<<<<<
22598  *         resultp = (<char **> resultp)[0] + suboffset
22599  *
22600  */
22601   }
22602 
22603   /* "View.MemoryView":937
22604  *         resultp = (<char **> resultp)[0] + suboffset
22605  *
22606  *     return resultp             # <<<<<<<<<<<<<<
22607  *
22608  *
22609  */
22610   __pyx_r = __pyx_v_resultp;
22611   goto __pyx_L0;
22612 
22613   /* "View.MemoryView":910
22614  *
22615  * @cname('__pyx_pybuffer_index')
22616  * cdef char *pybuffer_index(Py_buffer *view, char *bufp, Py_ssize_t index,             # <<<<<<<<<<<<<<
22617  *                           Py_ssize_t dim) except NULL:
22618  *     cdef Py_ssize_t shape, stride, suboffset = -1
22619  */
22620 
22621   /* function exit code */
22622   __pyx_L1_error:;
22623   __Pyx_XDECREF(__pyx_t_3);
22624   __Pyx_XDECREF(__pyx_t_4);
22625   __Pyx_AddTraceback("View.MemoryView.pybuffer_index", __pyx_clineno, __pyx_lineno, __pyx_filename);
22626   __pyx_r = NULL;
22627   __pyx_L0:;
22628   __Pyx_RefNannyFinishContext();
22629   return __pyx_r;
22630 }
22631 
22632 /* "View.MemoryView":943
22633  *
22634  * @cname('__pyx_memslice_transpose')
22635  * cdef int transpose_memslice(__Pyx_memviewslice *memslice) nogil except 0:             # <<<<<<<<<<<<<<
22636  *     cdef int ndim = memslice.memview.view.ndim
22637  *
22638  */
22639 
__pyx_memslice_transpose(__Pyx_memviewslice * __pyx_v_memslice)22640 static int __pyx_memslice_transpose(__Pyx_memviewslice *__pyx_v_memslice) {
22641   int __pyx_v_ndim;
22642   Py_ssize_t *__pyx_v_shape;
22643   Py_ssize_t *__pyx_v_strides;
22644   int __pyx_v_i;
22645   int __pyx_v_j;
22646   int __pyx_r;
22647   int __pyx_t_1;
22648   Py_ssize_t *__pyx_t_2;
22649   long __pyx_t_3;
22650   long __pyx_t_4;
22651   Py_ssize_t __pyx_t_5;
22652   Py_ssize_t __pyx_t_6;
22653   int __pyx_t_7;
22654   int __pyx_t_8;
22655   int __pyx_t_9;
22656   int __pyx_lineno = 0;
22657   const char *__pyx_filename = NULL;
22658   int __pyx_clineno = 0;
22659 
22660   /* "View.MemoryView":944
22661  * @cname('__pyx_memslice_transpose')
22662  * cdef int transpose_memslice(__Pyx_memviewslice *memslice) nogil except 0:
22663  *     cdef int ndim = memslice.memview.view.ndim             # <<<<<<<<<<<<<<
22664  *
22665  *     cdef Py_ssize_t *shape = memslice.shape
22666  */
22667   __pyx_t_1 = __pyx_v_memslice->memview->view.ndim;
22668   __pyx_v_ndim = __pyx_t_1;
22669 
22670   /* "View.MemoryView":946
22671  *     cdef int ndim = memslice.memview.view.ndim
22672  *
22673  *     cdef Py_ssize_t *shape = memslice.shape             # <<<<<<<<<<<<<<
22674  *     cdef Py_ssize_t *strides = memslice.strides
22675  *
22676  */
22677   __pyx_t_2 = __pyx_v_memslice->shape;
22678   __pyx_v_shape = __pyx_t_2;
22679 
22680   /* "View.MemoryView":947
22681  *
22682  *     cdef Py_ssize_t *shape = memslice.shape
22683  *     cdef Py_ssize_t *strides = memslice.strides             # <<<<<<<<<<<<<<
22684  *
22685  *
22686  */
22687   __pyx_t_2 = __pyx_v_memslice->strides;
22688   __pyx_v_strides = __pyx_t_2;
22689 
22690   /* "View.MemoryView":951
22691  *
22692  *     cdef int i, j
22693  *     for i in range(ndim / 2):             # <<<<<<<<<<<<<<
22694  *         j = ndim - 1 - i
22695  *         strides[i], strides[j] = strides[j], strides[i]
22696  */
22697   __pyx_t_3 = __Pyx_div_long(__pyx_v_ndim, 2);
22698   __pyx_t_4 = __pyx_t_3;
22699   for (__pyx_t_1 = 0; __pyx_t_1 < __pyx_t_4; __pyx_t_1+=1) {
22700     __pyx_v_i = __pyx_t_1;
22701 
22702     /* "View.MemoryView":952
22703  *     cdef int i, j
22704  *     for i in range(ndim / 2):
22705  *         j = ndim - 1 - i             # <<<<<<<<<<<<<<
22706  *         strides[i], strides[j] = strides[j], strides[i]
22707  *         shape[i], shape[j] = shape[j], shape[i]
22708  */
22709     __pyx_v_j = ((__pyx_v_ndim - 1) - __pyx_v_i);
22710 
22711     /* "View.MemoryView":953
22712  *     for i in range(ndim / 2):
22713  *         j = ndim - 1 - i
22714  *         strides[i], strides[j] = strides[j], strides[i]             # <<<<<<<<<<<<<<
22715  *         shape[i], shape[j] = shape[j], shape[i]
22716  *
22717  */
22718     __pyx_t_5 = (__pyx_v_strides[__pyx_v_j]);
22719     __pyx_t_6 = (__pyx_v_strides[__pyx_v_i]);
22720     (__pyx_v_strides[__pyx_v_i]) = __pyx_t_5;
22721     (__pyx_v_strides[__pyx_v_j]) = __pyx_t_6;
22722 
22723     /* "View.MemoryView":954
22724  *         j = ndim - 1 - i
22725  *         strides[i], strides[j] = strides[j], strides[i]
22726  *         shape[i], shape[j] = shape[j], shape[i]             # <<<<<<<<<<<<<<
22727  *
22728  *         if memslice.suboffsets[i] >= 0 or memslice.suboffsets[j] >= 0:
22729  */
22730     __pyx_t_6 = (__pyx_v_shape[__pyx_v_j]);
22731     __pyx_t_5 = (__pyx_v_shape[__pyx_v_i]);
22732     (__pyx_v_shape[__pyx_v_i]) = __pyx_t_6;
22733     (__pyx_v_shape[__pyx_v_j]) = __pyx_t_5;
22734 
22735     /* "View.MemoryView":956
22736  *         shape[i], shape[j] = shape[j], shape[i]
22737  *
22738  *         if memslice.suboffsets[i] >= 0 or memslice.suboffsets[j] >= 0:             # <<<<<<<<<<<<<<
22739  *             _err(ValueError, "Cannot transpose memoryview with indirect dimensions")
22740  *
22741  */
22742     __pyx_t_8 = (((__pyx_v_memslice->suboffsets[__pyx_v_i]) >= 0) != 0);
22743     if (!__pyx_t_8) {
22744     } else {
22745       __pyx_t_7 = __pyx_t_8;
22746       goto __pyx_L6_bool_binop_done;
22747     }
22748     __pyx_t_8 = (((__pyx_v_memslice->suboffsets[__pyx_v_j]) >= 0) != 0);
22749     __pyx_t_7 = __pyx_t_8;
22750     __pyx_L6_bool_binop_done:;
22751     if (__pyx_t_7) {
22752 
22753       /* "View.MemoryView":957
22754  *
22755  *         if memslice.suboffsets[i] >= 0 or memslice.suboffsets[j] >= 0:
22756  *             _err(ValueError, "Cannot transpose memoryview with indirect dimensions")             # <<<<<<<<<<<<<<
22757  *
22758  *     return 1
22759  */
22760       __pyx_t_9 = __pyx_memoryview_err(__pyx_builtin_ValueError, ((char *)"Cannot transpose memoryview with indirect dimensions")); if (unlikely(__pyx_t_9 == ((int)-1))) __PYX_ERR(3, 957, __pyx_L1_error)
22761 
22762       /* "View.MemoryView":956
22763  *         shape[i], shape[j] = shape[j], shape[i]
22764  *
22765  *         if memslice.suboffsets[i] >= 0 or memslice.suboffsets[j] >= 0:             # <<<<<<<<<<<<<<
22766  *             _err(ValueError, "Cannot transpose memoryview with indirect dimensions")
22767  *
22768  */
22769     }
22770   }
22771 
22772   /* "View.MemoryView":959
22773  *             _err(ValueError, "Cannot transpose memoryview with indirect dimensions")
22774  *
22775  *     return 1             # <<<<<<<<<<<<<<
22776  *
22777  *
22778  */
22779   __pyx_r = 1;
22780   goto __pyx_L0;
22781 
22782   /* "View.MemoryView":943
22783  *
22784  * @cname('__pyx_memslice_transpose')
22785  * cdef int transpose_memslice(__Pyx_memviewslice *memslice) nogil except 0:             # <<<<<<<<<<<<<<
22786  *     cdef int ndim = memslice.memview.view.ndim
22787  *
22788  */
22789 
22790   /* function exit code */
22791   __pyx_L1_error:;
22792   {
22793     #ifdef WITH_THREAD
22794     PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure();
22795     #endif
22796     __Pyx_AddTraceback("View.MemoryView.transpose_memslice", __pyx_clineno, __pyx_lineno, __pyx_filename);
22797     #ifdef WITH_THREAD
22798     __Pyx_PyGILState_Release(__pyx_gilstate_save);
22799     #endif
22800   }
22801   __pyx_r = 0;
22802   __pyx_L0:;
22803   return __pyx_r;
22804 }
22805 
22806 /* "View.MemoryView":976
22807  *     cdef int (*to_dtype_func)(char *, object) except 0
22808  *
22809  *     def __dealloc__(self):             # <<<<<<<<<<<<<<
22810  *         __PYX_XDEC_MEMVIEW(&self.from_slice, 1)
22811  *
22812  */
22813 
22814 /* Python wrapper */
22815 static void __pyx_memoryviewslice___dealloc__(PyObject *__pyx_v_self); /*proto*/
__pyx_memoryviewslice___dealloc__(PyObject * __pyx_v_self)22816 static void __pyx_memoryviewslice___dealloc__(PyObject *__pyx_v_self) {
22817   __Pyx_RefNannyDeclarations
22818   __Pyx_RefNannySetupContext("__dealloc__ (wrapper)", 0);
22819   __pyx_memoryviewslice___pyx_pf_15View_dot_MemoryView_16_memoryviewslice___dealloc__(((struct __pyx_memoryviewslice_obj *)__pyx_v_self));
22820 
22821   /* function exit code */
22822   __Pyx_RefNannyFinishContext();
22823 }
22824 
__pyx_memoryviewslice___pyx_pf_15View_dot_MemoryView_16_memoryviewslice___dealloc__(struct __pyx_memoryviewslice_obj * __pyx_v_self)22825 static void __pyx_memoryviewslice___pyx_pf_15View_dot_MemoryView_16_memoryviewslice___dealloc__(struct __pyx_memoryviewslice_obj *__pyx_v_self) {
22826   __Pyx_RefNannyDeclarations
22827   __Pyx_RefNannySetupContext("__dealloc__", 0);
22828 
22829   /* "View.MemoryView":977
22830  *
22831  *     def __dealloc__(self):
22832  *         __PYX_XDEC_MEMVIEW(&self.from_slice, 1)             # <<<<<<<<<<<<<<
22833  *
22834  *     cdef convert_item_to_object(self, char *itemp):
22835  */
22836   __PYX_XDEC_MEMVIEW((&__pyx_v_self->from_slice), 1);
22837 
22838   /* "View.MemoryView":976
22839  *     cdef int (*to_dtype_func)(char *, object) except 0
22840  *
22841  *     def __dealloc__(self):             # <<<<<<<<<<<<<<
22842  *         __PYX_XDEC_MEMVIEW(&self.from_slice, 1)
22843  *
22844  */
22845 
22846   /* function exit code */
22847   __Pyx_RefNannyFinishContext();
22848 }
22849 
22850 /* "View.MemoryView":979
22851  *         __PYX_XDEC_MEMVIEW(&self.from_slice, 1)
22852  *
22853  *     cdef convert_item_to_object(self, char *itemp):             # <<<<<<<<<<<<<<
22854  *         if self.to_object_func != NULL:
22855  *             return self.to_object_func(itemp)
22856  */
22857 
__pyx_memoryviewslice_convert_item_to_object(struct __pyx_memoryviewslice_obj * __pyx_v_self,char * __pyx_v_itemp)22858 static PyObject *__pyx_memoryviewslice_convert_item_to_object(struct __pyx_memoryviewslice_obj *__pyx_v_self, char *__pyx_v_itemp) {
22859   PyObject *__pyx_r = NULL;
22860   __Pyx_RefNannyDeclarations
22861   int __pyx_t_1;
22862   PyObject *__pyx_t_2 = NULL;
22863   int __pyx_lineno = 0;
22864   const char *__pyx_filename = NULL;
22865   int __pyx_clineno = 0;
22866   __Pyx_RefNannySetupContext("convert_item_to_object", 0);
22867 
22868   /* "View.MemoryView":980
22869  *
22870  *     cdef convert_item_to_object(self, char *itemp):
22871  *         if self.to_object_func != NULL:             # <<<<<<<<<<<<<<
22872  *             return self.to_object_func(itemp)
22873  *         else:
22874  */
22875   __pyx_t_1 = ((__pyx_v_self->to_object_func != NULL) != 0);
22876   if (__pyx_t_1) {
22877 
22878     /* "View.MemoryView":981
22879  *     cdef convert_item_to_object(self, char *itemp):
22880  *         if self.to_object_func != NULL:
22881  *             return self.to_object_func(itemp)             # <<<<<<<<<<<<<<
22882  *         else:
22883  *             return memoryview.convert_item_to_object(self, itemp)
22884  */
22885     __Pyx_XDECREF(__pyx_r);
22886     __pyx_t_2 = __pyx_v_self->to_object_func(__pyx_v_itemp); if (unlikely(!__pyx_t_2)) __PYX_ERR(3, 981, __pyx_L1_error)
22887     __Pyx_GOTREF(__pyx_t_2);
22888     __pyx_r = __pyx_t_2;
22889     __pyx_t_2 = 0;
22890     goto __pyx_L0;
22891 
22892     /* "View.MemoryView":980
22893  *
22894  *     cdef convert_item_to_object(self, char *itemp):
22895  *         if self.to_object_func != NULL:             # <<<<<<<<<<<<<<
22896  *             return self.to_object_func(itemp)
22897  *         else:
22898  */
22899   }
22900 
22901   /* "View.MemoryView":983
22902  *             return self.to_object_func(itemp)
22903  *         else:
22904  *             return memoryview.convert_item_to_object(self, itemp)             # <<<<<<<<<<<<<<
22905  *
22906  *     cdef assign_item_from_object(self, char *itemp, object value):
22907  */
22908   /*else*/ {
22909     __Pyx_XDECREF(__pyx_r);
22910     __pyx_t_2 = __pyx_memoryview_convert_item_to_object(((struct __pyx_memoryview_obj *)__pyx_v_self), __pyx_v_itemp); if (unlikely(!__pyx_t_2)) __PYX_ERR(3, 983, __pyx_L1_error)
22911     __Pyx_GOTREF(__pyx_t_2);
22912     __pyx_r = __pyx_t_2;
22913     __pyx_t_2 = 0;
22914     goto __pyx_L0;
22915   }
22916 
22917   /* "View.MemoryView":979
22918  *         __PYX_XDEC_MEMVIEW(&self.from_slice, 1)
22919  *
22920  *     cdef convert_item_to_object(self, char *itemp):             # <<<<<<<<<<<<<<
22921  *         if self.to_object_func != NULL:
22922  *             return self.to_object_func(itemp)
22923  */
22924 
22925   /* function exit code */
22926   __pyx_L1_error:;
22927   __Pyx_XDECREF(__pyx_t_2);
22928   __Pyx_AddTraceback("View.MemoryView._memoryviewslice.convert_item_to_object", __pyx_clineno, __pyx_lineno, __pyx_filename);
22929   __pyx_r = 0;
22930   __pyx_L0:;
22931   __Pyx_XGIVEREF(__pyx_r);
22932   __Pyx_RefNannyFinishContext();
22933   return __pyx_r;
22934 }
22935 
22936 /* "View.MemoryView":985
22937  *             return memoryview.convert_item_to_object(self, itemp)
22938  *
22939  *     cdef assign_item_from_object(self, char *itemp, object value):             # <<<<<<<<<<<<<<
22940  *         if self.to_dtype_func != NULL:
22941  *             self.to_dtype_func(itemp, value)
22942  */
22943 
__pyx_memoryviewslice_assign_item_from_object(struct __pyx_memoryviewslice_obj * __pyx_v_self,char * __pyx_v_itemp,PyObject * __pyx_v_value)22944 static PyObject *__pyx_memoryviewslice_assign_item_from_object(struct __pyx_memoryviewslice_obj *__pyx_v_self, char *__pyx_v_itemp, PyObject *__pyx_v_value) {
22945   PyObject *__pyx_r = NULL;
22946   __Pyx_RefNannyDeclarations
22947   int __pyx_t_1;
22948   int __pyx_t_2;
22949   PyObject *__pyx_t_3 = NULL;
22950   int __pyx_lineno = 0;
22951   const char *__pyx_filename = NULL;
22952   int __pyx_clineno = 0;
22953   __Pyx_RefNannySetupContext("assign_item_from_object", 0);
22954 
22955   /* "View.MemoryView":986
22956  *
22957  *     cdef assign_item_from_object(self, char *itemp, object value):
22958  *         if self.to_dtype_func != NULL:             # <<<<<<<<<<<<<<
22959  *             self.to_dtype_func(itemp, value)
22960  *         else:
22961  */
22962   __pyx_t_1 = ((__pyx_v_self->to_dtype_func != NULL) != 0);
22963   if (__pyx_t_1) {
22964 
22965     /* "View.MemoryView":987
22966  *     cdef assign_item_from_object(self, char *itemp, object value):
22967  *         if self.to_dtype_func != NULL:
22968  *             self.to_dtype_func(itemp, value)             # <<<<<<<<<<<<<<
22969  *         else:
22970  *             memoryview.assign_item_from_object(self, itemp, value)
22971  */
22972     __pyx_t_2 = __pyx_v_self->to_dtype_func(__pyx_v_itemp, __pyx_v_value); if (unlikely(__pyx_t_2 == ((int)0))) __PYX_ERR(3, 987, __pyx_L1_error)
22973 
22974     /* "View.MemoryView":986
22975  *
22976  *     cdef assign_item_from_object(self, char *itemp, object value):
22977  *         if self.to_dtype_func != NULL:             # <<<<<<<<<<<<<<
22978  *             self.to_dtype_func(itemp, value)
22979  *         else:
22980  */
22981     goto __pyx_L3;
22982   }
22983 
22984   /* "View.MemoryView":989
22985  *             self.to_dtype_func(itemp, value)
22986  *         else:
22987  *             memoryview.assign_item_from_object(self, itemp, value)             # <<<<<<<<<<<<<<
22988  *
22989  *     @property
22990  */
22991   /*else*/ {
22992     __pyx_t_3 = __pyx_memoryview_assign_item_from_object(((struct __pyx_memoryview_obj *)__pyx_v_self), __pyx_v_itemp, __pyx_v_value); if (unlikely(!__pyx_t_3)) __PYX_ERR(3, 989, __pyx_L1_error)
22993     __Pyx_GOTREF(__pyx_t_3);
22994     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
22995   }
22996   __pyx_L3:;
22997 
22998   /* "View.MemoryView":985
22999  *             return memoryview.convert_item_to_object(self, itemp)
23000  *
23001  *     cdef assign_item_from_object(self, char *itemp, object value):             # <<<<<<<<<<<<<<
23002  *         if self.to_dtype_func != NULL:
23003  *             self.to_dtype_func(itemp, value)
23004  */
23005 
23006   /* function exit code */
23007   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
23008   goto __pyx_L0;
23009   __pyx_L1_error:;
23010   __Pyx_XDECREF(__pyx_t_3);
23011   __Pyx_AddTraceback("View.MemoryView._memoryviewslice.assign_item_from_object", __pyx_clineno, __pyx_lineno, __pyx_filename);
23012   __pyx_r = 0;
23013   __pyx_L0:;
23014   __Pyx_XGIVEREF(__pyx_r);
23015   __Pyx_RefNannyFinishContext();
23016   return __pyx_r;
23017 }
23018 
23019 /* "View.MemoryView":992
23020  *
23021  *     @property
23022  *     def base(self):             # <<<<<<<<<<<<<<
23023  *         return self.from_object
23024  *
23025  */
23026 
23027 /* Python wrapper */
23028 static PyObject *__pyx_pw_15View_dot_MemoryView_16_memoryviewslice_4base_1__get__(PyObject *__pyx_v_self); /*proto*/
__pyx_pw_15View_dot_MemoryView_16_memoryviewslice_4base_1__get__(PyObject * __pyx_v_self)23029 static PyObject *__pyx_pw_15View_dot_MemoryView_16_memoryviewslice_4base_1__get__(PyObject *__pyx_v_self) {
23030   PyObject *__pyx_r = 0;
23031   __Pyx_RefNannyDeclarations
23032   __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
23033   __pyx_r = __pyx_pf_15View_dot_MemoryView_16_memoryviewslice_4base___get__(((struct __pyx_memoryviewslice_obj *)__pyx_v_self));
23034 
23035   /* function exit code */
23036   __Pyx_RefNannyFinishContext();
23037   return __pyx_r;
23038 }
23039 
__pyx_pf_15View_dot_MemoryView_16_memoryviewslice_4base___get__(struct __pyx_memoryviewslice_obj * __pyx_v_self)23040 static PyObject *__pyx_pf_15View_dot_MemoryView_16_memoryviewslice_4base___get__(struct __pyx_memoryviewslice_obj *__pyx_v_self) {
23041   PyObject *__pyx_r = NULL;
23042   __Pyx_RefNannyDeclarations
23043   __Pyx_RefNannySetupContext("__get__", 0);
23044 
23045   /* "View.MemoryView":993
23046  *     @property
23047  *     def base(self):
23048  *         return self.from_object             # <<<<<<<<<<<<<<
23049  *
23050  *     __pyx_getbuffer = capsule(<void *> &__pyx_memoryview_getbuffer, "getbuffer(obj, view, flags)")
23051  */
23052   __Pyx_XDECREF(__pyx_r);
23053   __Pyx_INCREF(__pyx_v_self->from_object);
23054   __pyx_r = __pyx_v_self->from_object;
23055   goto __pyx_L0;
23056 
23057   /* "View.MemoryView":992
23058  *
23059  *     @property
23060  *     def base(self):             # <<<<<<<<<<<<<<
23061  *         return self.from_object
23062  *
23063  */
23064 
23065   /* function exit code */
23066   __pyx_L0:;
23067   __Pyx_XGIVEREF(__pyx_r);
23068   __Pyx_RefNannyFinishContext();
23069   return __pyx_r;
23070 }
23071 
23072 /* "(tree fragment)":1
23073  * def __reduce_cython__(self):             # <<<<<<<<<<<<<<
23074  *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
23075  * def __setstate_cython__(self, __pyx_state):
23076  */
23077 
23078 /* Python wrapper */
23079 static PyObject *__pyx_pw___pyx_memoryviewslice_1__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
__pyx_pw___pyx_memoryviewslice_1__reduce_cython__(PyObject * __pyx_v_self,CYTHON_UNUSED PyObject * unused)23080 static PyObject *__pyx_pw___pyx_memoryviewslice_1__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
23081   PyObject *__pyx_r = 0;
23082   __Pyx_RefNannyDeclarations
23083   __Pyx_RefNannySetupContext("__reduce_cython__ (wrapper)", 0);
23084   __pyx_r = __pyx_pf___pyx_memoryviewslice___reduce_cython__(((struct __pyx_memoryviewslice_obj *)__pyx_v_self));
23085 
23086   /* function exit code */
23087   __Pyx_RefNannyFinishContext();
23088   return __pyx_r;
23089 }
23090 
__pyx_pf___pyx_memoryviewslice___reduce_cython__(CYTHON_UNUSED struct __pyx_memoryviewslice_obj * __pyx_v_self)23091 static PyObject *__pyx_pf___pyx_memoryviewslice___reduce_cython__(CYTHON_UNUSED struct __pyx_memoryviewslice_obj *__pyx_v_self) {
23092   PyObject *__pyx_r = NULL;
23093   __Pyx_RefNannyDeclarations
23094   PyObject *__pyx_t_1 = NULL;
23095   int __pyx_lineno = 0;
23096   const char *__pyx_filename = NULL;
23097   int __pyx_clineno = 0;
23098   __Pyx_RefNannySetupContext("__reduce_cython__", 0);
23099 
23100   /* "(tree fragment)":2
23101  * def __reduce_cython__(self):
23102  *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")             # <<<<<<<<<<<<<<
23103  * def __setstate_cython__(self, __pyx_state):
23104  *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
23105  */
23106   __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__37, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(3, 2, __pyx_L1_error)
23107   __Pyx_GOTREF(__pyx_t_1);
23108   __Pyx_Raise(__pyx_t_1, 0, 0, 0);
23109   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
23110   __PYX_ERR(3, 2, __pyx_L1_error)
23111 
23112   /* "(tree fragment)":1
23113  * def __reduce_cython__(self):             # <<<<<<<<<<<<<<
23114  *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
23115  * def __setstate_cython__(self, __pyx_state):
23116  */
23117 
23118   /* function exit code */
23119   __pyx_L1_error:;
23120   __Pyx_XDECREF(__pyx_t_1);
23121   __Pyx_AddTraceback("View.MemoryView._memoryviewslice.__reduce_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename);
23122   __pyx_r = NULL;
23123   __Pyx_XGIVEREF(__pyx_r);
23124   __Pyx_RefNannyFinishContext();
23125   return __pyx_r;
23126 }
23127 
23128 /* "(tree fragment)":3
23129  * def __reduce_cython__(self):
23130  *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
23131  * def __setstate_cython__(self, __pyx_state):             # <<<<<<<<<<<<<<
23132  *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
23133  */
23134 
23135 /* Python wrapper */
23136 static PyObject *__pyx_pw___pyx_memoryviewslice_3__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state); /*proto*/
__pyx_pw___pyx_memoryviewslice_3__setstate_cython__(PyObject * __pyx_v_self,PyObject * __pyx_v___pyx_state)23137 static PyObject *__pyx_pw___pyx_memoryviewslice_3__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state) {
23138   PyObject *__pyx_r = 0;
23139   __Pyx_RefNannyDeclarations
23140   __Pyx_RefNannySetupContext("__setstate_cython__ (wrapper)", 0);
23141   __pyx_r = __pyx_pf___pyx_memoryviewslice_2__setstate_cython__(((struct __pyx_memoryviewslice_obj *)__pyx_v_self), ((PyObject *)__pyx_v___pyx_state));
23142 
23143   /* function exit code */
23144   __Pyx_RefNannyFinishContext();
23145   return __pyx_r;
23146 }
23147 
__pyx_pf___pyx_memoryviewslice_2__setstate_cython__(CYTHON_UNUSED struct __pyx_memoryviewslice_obj * __pyx_v_self,CYTHON_UNUSED PyObject * __pyx_v___pyx_state)23148 static PyObject *__pyx_pf___pyx_memoryviewslice_2__setstate_cython__(CYTHON_UNUSED struct __pyx_memoryviewslice_obj *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v___pyx_state) {
23149   PyObject *__pyx_r = NULL;
23150   __Pyx_RefNannyDeclarations
23151   PyObject *__pyx_t_1 = NULL;
23152   int __pyx_lineno = 0;
23153   const char *__pyx_filename = NULL;
23154   int __pyx_clineno = 0;
23155   __Pyx_RefNannySetupContext("__setstate_cython__", 0);
23156 
23157   /* "(tree fragment)":4
23158  *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
23159  * def __setstate_cython__(self, __pyx_state):
23160  *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")             # <<<<<<<<<<<<<<
23161  */
23162   __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__38, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(3, 4, __pyx_L1_error)
23163   __Pyx_GOTREF(__pyx_t_1);
23164   __Pyx_Raise(__pyx_t_1, 0, 0, 0);
23165   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
23166   __PYX_ERR(3, 4, __pyx_L1_error)
23167 
23168   /* "(tree fragment)":3
23169  * def __reduce_cython__(self):
23170  *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
23171  * def __setstate_cython__(self, __pyx_state):             # <<<<<<<<<<<<<<
23172  *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
23173  */
23174 
23175   /* function exit code */
23176   __pyx_L1_error:;
23177   __Pyx_XDECREF(__pyx_t_1);
23178   __Pyx_AddTraceback("View.MemoryView._memoryviewslice.__setstate_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename);
23179   __pyx_r = NULL;
23180   __Pyx_XGIVEREF(__pyx_r);
23181   __Pyx_RefNannyFinishContext();
23182   return __pyx_r;
23183 }
23184 
23185 /* "View.MemoryView":999
23186  *
23187  * @cname('__pyx_memoryview_fromslice')
23188  * cdef memoryview_fromslice(__Pyx_memviewslice memviewslice,             # <<<<<<<<<<<<<<
23189  *                           int ndim,
23190  *                           object (*to_object_func)(char *),
23191  */
23192 
__pyx_memoryview_fromslice(__Pyx_memviewslice __pyx_v_memviewslice,int __pyx_v_ndim,PyObject * (* __pyx_v_to_object_func)(char *),int (* __pyx_v_to_dtype_func)(char *,PyObject *),int __pyx_v_dtype_is_object)23193 static PyObject *__pyx_memoryview_fromslice(__Pyx_memviewslice __pyx_v_memviewslice, int __pyx_v_ndim, PyObject *(*__pyx_v_to_object_func)(char *), int (*__pyx_v_to_dtype_func)(char *, PyObject *), int __pyx_v_dtype_is_object) {
23194   struct __pyx_memoryviewslice_obj *__pyx_v_result = 0;
23195   Py_ssize_t __pyx_v_suboffset;
23196   PyObject *__pyx_v_length = NULL;
23197   PyObject *__pyx_r = NULL;
23198   __Pyx_RefNannyDeclarations
23199   int __pyx_t_1;
23200   PyObject *__pyx_t_2 = NULL;
23201   PyObject *__pyx_t_3 = NULL;
23202   __Pyx_TypeInfo *__pyx_t_4;
23203   Py_buffer __pyx_t_5;
23204   Py_ssize_t *__pyx_t_6;
23205   Py_ssize_t *__pyx_t_7;
23206   Py_ssize_t *__pyx_t_8;
23207   Py_ssize_t __pyx_t_9;
23208   int __pyx_lineno = 0;
23209   const char *__pyx_filename = NULL;
23210   int __pyx_clineno = 0;
23211   __Pyx_RefNannySetupContext("memoryview_fromslice", 0);
23212 
23213   /* "View.MemoryView":1007
23214  *     cdef _memoryviewslice result
23215  *
23216  *     if <PyObject *> memviewslice.memview == Py_None:             # <<<<<<<<<<<<<<
23217  *         return None
23218  *
23219  */
23220   __pyx_t_1 = ((((PyObject *)__pyx_v_memviewslice.memview) == Py_None) != 0);
23221   if (__pyx_t_1) {
23222 
23223     /* "View.MemoryView":1008
23224  *
23225  *     if <PyObject *> memviewslice.memview == Py_None:
23226  *         return None             # <<<<<<<<<<<<<<
23227  *
23228  *
23229  */
23230     __Pyx_XDECREF(__pyx_r);
23231     __pyx_r = Py_None; __Pyx_INCREF(Py_None);
23232     goto __pyx_L0;
23233 
23234     /* "View.MemoryView":1007
23235  *     cdef _memoryviewslice result
23236  *
23237  *     if <PyObject *> memviewslice.memview == Py_None:             # <<<<<<<<<<<<<<
23238  *         return None
23239  *
23240  */
23241   }
23242 
23243   /* "View.MemoryView":1013
23244  *
23245  *
23246  *     result = _memoryviewslice(None, 0, dtype_is_object)             # <<<<<<<<<<<<<<
23247  *
23248  *     result.from_slice = memviewslice
23249  */
23250   __pyx_t_2 = __Pyx_PyBool_FromLong(__pyx_v_dtype_is_object); if (unlikely(!__pyx_t_2)) __PYX_ERR(3, 1013, __pyx_L1_error)
23251   __Pyx_GOTREF(__pyx_t_2);
23252   __pyx_t_3 = PyTuple_New(3); if (unlikely(!__pyx_t_3)) __PYX_ERR(3, 1013, __pyx_L1_error)
23253   __Pyx_GOTREF(__pyx_t_3);
23254   __Pyx_INCREF(Py_None);
23255   __Pyx_GIVEREF(Py_None);
23256   PyTuple_SET_ITEM(__pyx_t_3, 0, Py_None);
23257   __Pyx_INCREF(__pyx_int_0);
23258   __Pyx_GIVEREF(__pyx_int_0);
23259   PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_int_0);
23260   __Pyx_GIVEREF(__pyx_t_2);
23261   PyTuple_SET_ITEM(__pyx_t_3, 2, __pyx_t_2);
23262   __pyx_t_2 = 0;
23263   __pyx_t_2 = __Pyx_PyObject_Call(((PyObject *)__pyx_memoryviewslice_type), __pyx_t_3, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(3, 1013, __pyx_L1_error)
23264   __Pyx_GOTREF(__pyx_t_2);
23265   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
23266   __pyx_v_result = ((struct __pyx_memoryviewslice_obj *)__pyx_t_2);
23267   __pyx_t_2 = 0;
23268 
23269   /* "View.MemoryView":1015
23270  *     result = _memoryviewslice(None, 0, dtype_is_object)
23271  *
23272  *     result.from_slice = memviewslice             # <<<<<<<<<<<<<<
23273  *     __PYX_INC_MEMVIEW(&memviewslice, 1)
23274  *
23275  */
23276   __pyx_v_result->from_slice = __pyx_v_memviewslice;
23277 
23278   /* "View.MemoryView":1016
23279  *
23280  *     result.from_slice = memviewslice
23281  *     __PYX_INC_MEMVIEW(&memviewslice, 1)             # <<<<<<<<<<<<<<
23282  *
23283  *     result.from_object = (<memoryview> memviewslice.memview).base
23284  */
23285   __PYX_INC_MEMVIEW((&__pyx_v_memviewslice), 1);
23286 
23287   /* "View.MemoryView":1018
23288  *     __PYX_INC_MEMVIEW(&memviewslice, 1)
23289  *
23290  *     result.from_object = (<memoryview> memviewslice.memview).base             # <<<<<<<<<<<<<<
23291  *     result.typeinfo = memviewslice.memview.typeinfo
23292  *
23293  */
23294   __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_memviewslice.memview), __pyx_n_s_base); if (unlikely(!__pyx_t_2)) __PYX_ERR(3, 1018, __pyx_L1_error)
23295   __Pyx_GOTREF(__pyx_t_2);
23296   __Pyx_GIVEREF(__pyx_t_2);
23297   __Pyx_GOTREF(__pyx_v_result->from_object);
23298   __Pyx_DECREF(__pyx_v_result->from_object);
23299   __pyx_v_result->from_object = __pyx_t_2;
23300   __pyx_t_2 = 0;
23301 
23302   /* "View.MemoryView":1019
23303  *
23304  *     result.from_object = (<memoryview> memviewslice.memview).base
23305  *     result.typeinfo = memviewslice.memview.typeinfo             # <<<<<<<<<<<<<<
23306  *
23307  *     result.view = memviewslice.memview.view
23308  */
23309   __pyx_t_4 = __pyx_v_memviewslice.memview->typeinfo;
23310   __pyx_v_result->__pyx_base.typeinfo = __pyx_t_4;
23311 
23312   /* "View.MemoryView":1021
23313  *     result.typeinfo = memviewslice.memview.typeinfo
23314  *
23315  *     result.view = memviewslice.memview.view             # <<<<<<<<<<<<<<
23316  *     result.view.buf = <void *> memviewslice.data
23317  *     result.view.ndim = ndim
23318  */
23319   __pyx_t_5 = __pyx_v_memviewslice.memview->view;
23320   __pyx_v_result->__pyx_base.view = __pyx_t_5;
23321 
23322   /* "View.MemoryView":1022
23323  *
23324  *     result.view = memviewslice.memview.view
23325  *     result.view.buf = <void *> memviewslice.data             # <<<<<<<<<<<<<<
23326  *     result.view.ndim = ndim
23327  *     (<__pyx_buffer *> &result.view).obj = Py_None
23328  */
23329   __pyx_v_result->__pyx_base.view.buf = ((void *)__pyx_v_memviewslice.data);
23330 
23331   /* "View.MemoryView":1023
23332  *     result.view = memviewslice.memview.view
23333  *     result.view.buf = <void *> memviewslice.data
23334  *     result.view.ndim = ndim             # <<<<<<<<<<<<<<
23335  *     (<__pyx_buffer *> &result.view).obj = Py_None
23336  *     Py_INCREF(Py_None)
23337  */
23338   __pyx_v_result->__pyx_base.view.ndim = __pyx_v_ndim;
23339 
23340   /* "View.MemoryView":1024
23341  *     result.view.buf = <void *> memviewslice.data
23342  *     result.view.ndim = ndim
23343  *     (<__pyx_buffer *> &result.view).obj = Py_None             # <<<<<<<<<<<<<<
23344  *     Py_INCREF(Py_None)
23345  *
23346  */
23347   ((Py_buffer *)(&__pyx_v_result->__pyx_base.view))->obj = Py_None;
23348 
23349   /* "View.MemoryView":1025
23350  *     result.view.ndim = ndim
23351  *     (<__pyx_buffer *> &result.view).obj = Py_None
23352  *     Py_INCREF(Py_None)             # <<<<<<<<<<<<<<
23353  *
23354  *     if (<memoryview>memviewslice.memview).flags & PyBUF_WRITABLE:
23355  */
23356   Py_INCREF(Py_None);
23357 
23358   /* "View.MemoryView":1027
23359  *     Py_INCREF(Py_None)
23360  *
23361  *     if (<memoryview>memviewslice.memview).flags & PyBUF_WRITABLE:             # <<<<<<<<<<<<<<
23362  *         result.flags = PyBUF_RECORDS
23363  *     else:
23364  */
23365   __pyx_t_1 = ((((struct __pyx_memoryview_obj *)__pyx_v_memviewslice.memview)->flags & PyBUF_WRITABLE) != 0);
23366   if (__pyx_t_1) {
23367 
23368     /* "View.MemoryView":1028
23369  *
23370  *     if (<memoryview>memviewslice.memview).flags & PyBUF_WRITABLE:
23371  *         result.flags = PyBUF_RECORDS             # <<<<<<<<<<<<<<
23372  *     else:
23373  *         result.flags = PyBUF_RECORDS_RO
23374  */
23375     __pyx_v_result->__pyx_base.flags = PyBUF_RECORDS;
23376 
23377     /* "View.MemoryView":1027
23378  *     Py_INCREF(Py_None)
23379  *
23380  *     if (<memoryview>memviewslice.memview).flags & PyBUF_WRITABLE:             # <<<<<<<<<<<<<<
23381  *         result.flags = PyBUF_RECORDS
23382  *     else:
23383  */
23384     goto __pyx_L4;
23385   }
23386 
23387   /* "View.MemoryView":1030
23388  *         result.flags = PyBUF_RECORDS
23389  *     else:
23390  *         result.flags = PyBUF_RECORDS_RO             # <<<<<<<<<<<<<<
23391  *
23392  *     result.view.shape = <Py_ssize_t *> result.from_slice.shape
23393  */
23394   /*else*/ {
23395     __pyx_v_result->__pyx_base.flags = PyBUF_RECORDS_RO;
23396   }
23397   __pyx_L4:;
23398 
23399   /* "View.MemoryView":1032
23400  *         result.flags = PyBUF_RECORDS_RO
23401  *
23402  *     result.view.shape = <Py_ssize_t *> result.from_slice.shape             # <<<<<<<<<<<<<<
23403  *     result.view.strides = <Py_ssize_t *> result.from_slice.strides
23404  *
23405  */
23406   __pyx_v_result->__pyx_base.view.shape = ((Py_ssize_t *)__pyx_v_result->from_slice.shape);
23407 
23408   /* "View.MemoryView":1033
23409  *
23410  *     result.view.shape = <Py_ssize_t *> result.from_slice.shape
23411  *     result.view.strides = <Py_ssize_t *> result.from_slice.strides             # <<<<<<<<<<<<<<
23412  *
23413  *
23414  */
23415   __pyx_v_result->__pyx_base.view.strides = ((Py_ssize_t *)__pyx_v_result->from_slice.strides);
23416 
23417   /* "View.MemoryView":1036
23418  *
23419  *
23420  *     result.view.suboffsets = NULL             # <<<<<<<<<<<<<<
23421  *     for suboffset in result.from_slice.suboffsets[:ndim]:
23422  *         if suboffset >= 0:
23423  */
23424   __pyx_v_result->__pyx_base.view.suboffsets = NULL;
23425 
23426   /* "View.MemoryView":1037
23427  *
23428  *     result.view.suboffsets = NULL
23429  *     for suboffset in result.from_slice.suboffsets[:ndim]:             # <<<<<<<<<<<<<<
23430  *         if suboffset >= 0:
23431  *             result.view.suboffsets = <Py_ssize_t *> result.from_slice.suboffsets
23432  */
23433   __pyx_t_7 = (__pyx_v_result->from_slice.suboffsets + __pyx_v_ndim);
23434   for (__pyx_t_8 = __pyx_v_result->from_slice.suboffsets; __pyx_t_8 < __pyx_t_7; __pyx_t_8++) {
23435     __pyx_t_6 = __pyx_t_8;
23436     __pyx_v_suboffset = (__pyx_t_6[0]);
23437 
23438     /* "View.MemoryView":1038
23439  *     result.view.suboffsets = NULL
23440  *     for suboffset in result.from_slice.suboffsets[:ndim]:
23441  *         if suboffset >= 0:             # <<<<<<<<<<<<<<
23442  *             result.view.suboffsets = <Py_ssize_t *> result.from_slice.suboffsets
23443  *             break
23444  */
23445     __pyx_t_1 = ((__pyx_v_suboffset >= 0) != 0);
23446     if (__pyx_t_1) {
23447 
23448       /* "View.MemoryView":1039
23449  *     for suboffset in result.from_slice.suboffsets[:ndim]:
23450  *         if suboffset >= 0:
23451  *             result.view.suboffsets = <Py_ssize_t *> result.from_slice.suboffsets             # <<<<<<<<<<<<<<
23452  *             break
23453  *
23454  */
23455       __pyx_v_result->__pyx_base.view.suboffsets = ((Py_ssize_t *)__pyx_v_result->from_slice.suboffsets);
23456 
23457       /* "View.MemoryView":1040
23458  *         if suboffset >= 0:
23459  *             result.view.suboffsets = <Py_ssize_t *> result.from_slice.suboffsets
23460  *             break             # <<<<<<<<<<<<<<
23461  *
23462  *     result.view.len = result.view.itemsize
23463  */
23464       goto __pyx_L6_break;
23465 
23466       /* "View.MemoryView":1038
23467  *     result.view.suboffsets = NULL
23468  *     for suboffset in result.from_slice.suboffsets[:ndim]:
23469  *         if suboffset >= 0:             # <<<<<<<<<<<<<<
23470  *             result.view.suboffsets = <Py_ssize_t *> result.from_slice.suboffsets
23471  *             break
23472  */
23473     }
23474   }
23475   __pyx_L6_break:;
23476 
23477   /* "View.MemoryView":1042
23478  *             break
23479  *
23480  *     result.view.len = result.view.itemsize             # <<<<<<<<<<<<<<
23481  *     for length in result.view.shape[:ndim]:
23482  *         result.view.len *= length
23483  */
23484   __pyx_t_9 = __pyx_v_result->__pyx_base.view.itemsize;
23485   __pyx_v_result->__pyx_base.view.len = __pyx_t_9;
23486 
23487   /* "View.MemoryView":1043
23488  *
23489  *     result.view.len = result.view.itemsize
23490  *     for length in result.view.shape[:ndim]:             # <<<<<<<<<<<<<<
23491  *         result.view.len *= length
23492  *
23493  */
23494   __pyx_t_7 = (__pyx_v_result->__pyx_base.view.shape + __pyx_v_ndim);
23495   for (__pyx_t_8 = __pyx_v_result->__pyx_base.view.shape; __pyx_t_8 < __pyx_t_7; __pyx_t_8++) {
23496     __pyx_t_6 = __pyx_t_8;
23497     __pyx_t_2 = PyInt_FromSsize_t((__pyx_t_6[0])); if (unlikely(!__pyx_t_2)) __PYX_ERR(3, 1043, __pyx_L1_error)
23498     __Pyx_GOTREF(__pyx_t_2);
23499     __Pyx_XDECREF_SET(__pyx_v_length, __pyx_t_2);
23500     __pyx_t_2 = 0;
23501 
23502     /* "View.MemoryView":1044
23503  *     result.view.len = result.view.itemsize
23504  *     for length in result.view.shape[:ndim]:
23505  *         result.view.len *= length             # <<<<<<<<<<<<<<
23506  *
23507  *     result.to_object_func = to_object_func
23508  */
23509     __pyx_t_2 = PyInt_FromSsize_t(__pyx_v_result->__pyx_base.view.len); if (unlikely(!__pyx_t_2)) __PYX_ERR(3, 1044, __pyx_L1_error)
23510     __Pyx_GOTREF(__pyx_t_2);
23511     __pyx_t_3 = PyNumber_InPlaceMultiply(__pyx_t_2, __pyx_v_length); if (unlikely(!__pyx_t_3)) __PYX_ERR(3, 1044, __pyx_L1_error)
23512     __Pyx_GOTREF(__pyx_t_3);
23513     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
23514     __pyx_t_9 = __Pyx_PyIndex_AsSsize_t(__pyx_t_3); if (unlikely((__pyx_t_9 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(3, 1044, __pyx_L1_error)
23515     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
23516     __pyx_v_result->__pyx_base.view.len = __pyx_t_9;
23517   }
23518 
23519   /* "View.MemoryView":1046
23520  *         result.view.len *= length
23521  *
23522  *     result.to_object_func = to_object_func             # <<<<<<<<<<<<<<
23523  *     result.to_dtype_func = to_dtype_func
23524  *
23525  */
23526   __pyx_v_result->to_object_func = __pyx_v_to_object_func;
23527 
23528   /* "View.MemoryView":1047
23529  *
23530  *     result.to_object_func = to_object_func
23531  *     result.to_dtype_func = to_dtype_func             # <<<<<<<<<<<<<<
23532  *
23533  *     return result
23534  */
23535   __pyx_v_result->to_dtype_func = __pyx_v_to_dtype_func;
23536 
23537   /* "View.MemoryView":1049
23538  *     result.to_dtype_func = to_dtype_func
23539  *
23540  *     return result             # <<<<<<<<<<<<<<
23541  *
23542  * @cname('__pyx_memoryview_get_slice_from_memoryview')
23543  */
23544   __Pyx_XDECREF(__pyx_r);
23545   __Pyx_INCREF(((PyObject *)__pyx_v_result));
23546   __pyx_r = ((PyObject *)__pyx_v_result);
23547   goto __pyx_L0;
23548 
23549   /* "View.MemoryView":999
23550  *
23551  * @cname('__pyx_memoryview_fromslice')
23552  * cdef memoryview_fromslice(__Pyx_memviewslice memviewslice,             # <<<<<<<<<<<<<<
23553  *                           int ndim,
23554  *                           object (*to_object_func)(char *),
23555  */
23556 
23557   /* function exit code */
23558   __pyx_L1_error:;
23559   __Pyx_XDECREF(__pyx_t_2);
23560   __Pyx_XDECREF(__pyx_t_3);
23561   __Pyx_AddTraceback("View.MemoryView.memoryview_fromslice", __pyx_clineno, __pyx_lineno, __pyx_filename);
23562   __pyx_r = 0;
23563   __pyx_L0:;
23564   __Pyx_XDECREF((PyObject *)__pyx_v_result);
23565   __Pyx_XDECREF(__pyx_v_length);
23566   __Pyx_XGIVEREF(__pyx_r);
23567   __Pyx_RefNannyFinishContext();
23568   return __pyx_r;
23569 }
23570 
23571 /* "View.MemoryView":1052
23572  *
23573  * @cname('__pyx_memoryview_get_slice_from_memoryview')
23574  * cdef __Pyx_memviewslice *get_slice_from_memview(memoryview memview,             # <<<<<<<<<<<<<<
23575  *                                                    __Pyx_memviewslice *mslice) except NULL:
23576  *     cdef _memoryviewslice obj
23577  */
23578 
__pyx_memoryview_get_slice_from_memoryview(struct __pyx_memoryview_obj * __pyx_v_memview,__Pyx_memviewslice * __pyx_v_mslice)23579 static __Pyx_memviewslice *__pyx_memoryview_get_slice_from_memoryview(struct __pyx_memoryview_obj *__pyx_v_memview, __Pyx_memviewslice *__pyx_v_mslice) {
23580   struct __pyx_memoryviewslice_obj *__pyx_v_obj = 0;
23581   __Pyx_memviewslice *__pyx_r;
23582   __Pyx_RefNannyDeclarations
23583   int __pyx_t_1;
23584   int __pyx_t_2;
23585   PyObject *__pyx_t_3 = NULL;
23586   int __pyx_lineno = 0;
23587   const char *__pyx_filename = NULL;
23588   int __pyx_clineno = 0;
23589   __Pyx_RefNannySetupContext("get_slice_from_memview", 0);
23590 
23591   /* "View.MemoryView":1055
23592  *                                                    __Pyx_memviewslice *mslice) except NULL:
23593  *     cdef _memoryviewslice obj
23594  *     if isinstance(memview, _memoryviewslice):             # <<<<<<<<<<<<<<
23595  *         obj = memview
23596  *         return &obj.from_slice
23597  */
23598   __pyx_t_1 = __Pyx_TypeCheck(((PyObject *)__pyx_v_memview), __pyx_memoryviewslice_type);
23599   __pyx_t_2 = (__pyx_t_1 != 0);
23600   if (__pyx_t_2) {
23601 
23602     /* "View.MemoryView":1056
23603  *     cdef _memoryviewslice obj
23604  *     if isinstance(memview, _memoryviewslice):
23605  *         obj = memview             # <<<<<<<<<<<<<<
23606  *         return &obj.from_slice
23607  *     else:
23608  */
23609     if (!(likely(((((PyObject *)__pyx_v_memview)) == Py_None) || likely(__Pyx_TypeTest(((PyObject *)__pyx_v_memview), __pyx_memoryviewslice_type))))) __PYX_ERR(3, 1056, __pyx_L1_error)
23610     __pyx_t_3 = ((PyObject *)__pyx_v_memview);
23611     __Pyx_INCREF(__pyx_t_3);
23612     __pyx_v_obj = ((struct __pyx_memoryviewslice_obj *)__pyx_t_3);
23613     __pyx_t_3 = 0;
23614 
23615     /* "View.MemoryView":1057
23616  *     if isinstance(memview, _memoryviewslice):
23617  *         obj = memview
23618  *         return &obj.from_slice             # <<<<<<<<<<<<<<
23619  *     else:
23620  *         slice_copy(memview, mslice)
23621  */
23622     __pyx_r = (&__pyx_v_obj->from_slice);
23623     goto __pyx_L0;
23624 
23625     /* "View.MemoryView":1055
23626  *                                                    __Pyx_memviewslice *mslice) except NULL:
23627  *     cdef _memoryviewslice obj
23628  *     if isinstance(memview, _memoryviewslice):             # <<<<<<<<<<<<<<
23629  *         obj = memview
23630  *         return &obj.from_slice
23631  */
23632   }
23633 
23634   /* "View.MemoryView":1059
23635  *         return &obj.from_slice
23636  *     else:
23637  *         slice_copy(memview, mslice)             # <<<<<<<<<<<<<<
23638  *         return mslice
23639  *
23640  */
23641   /*else*/ {
23642     __pyx_memoryview_slice_copy(__pyx_v_memview, __pyx_v_mslice);
23643 
23644     /* "View.MemoryView":1060
23645  *     else:
23646  *         slice_copy(memview, mslice)
23647  *         return mslice             # <<<<<<<<<<<<<<
23648  *
23649  * @cname('__pyx_memoryview_slice_copy')
23650  */
23651     __pyx_r = __pyx_v_mslice;
23652     goto __pyx_L0;
23653   }
23654 
23655   /* "View.MemoryView":1052
23656  *
23657  * @cname('__pyx_memoryview_get_slice_from_memoryview')
23658  * cdef __Pyx_memviewslice *get_slice_from_memview(memoryview memview,             # <<<<<<<<<<<<<<
23659  *                                                    __Pyx_memviewslice *mslice) except NULL:
23660  *     cdef _memoryviewslice obj
23661  */
23662 
23663   /* function exit code */
23664   __pyx_L1_error:;
23665   __Pyx_XDECREF(__pyx_t_3);
23666   __Pyx_AddTraceback("View.MemoryView.get_slice_from_memview", __pyx_clineno, __pyx_lineno, __pyx_filename);
23667   __pyx_r = NULL;
23668   __pyx_L0:;
23669   __Pyx_XDECREF((PyObject *)__pyx_v_obj);
23670   __Pyx_RefNannyFinishContext();
23671   return __pyx_r;
23672 }
23673 
23674 /* "View.MemoryView":1063
23675  *
23676  * @cname('__pyx_memoryview_slice_copy')
23677  * cdef void slice_copy(memoryview memview, __Pyx_memviewslice *dst):             # <<<<<<<<<<<<<<
23678  *     cdef int dim
23679  *     cdef (Py_ssize_t*) shape, strides, suboffsets
23680  */
23681 
__pyx_memoryview_slice_copy(struct __pyx_memoryview_obj * __pyx_v_memview,__Pyx_memviewslice * __pyx_v_dst)23682 static void __pyx_memoryview_slice_copy(struct __pyx_memoryview_obj *__pyx_v_memview, __Pyx_memviewslice *__pyx_v_dst) {
23683   int __pyx_v_dim;
23684   Py_ssize_t *__pyx_v_shape;
23685   Py_ssize_t *__pyx_v_strides;
23686   Py_ssize_t *__pyx_v_suboffsets;
23687   __Pyx_RefNannyDeclarations
23688   Py_ssize_t *__pyx_t_1;
23689   int __pyx_t_2;
23690   int __pyx_t_3;
23691   int __pyx_t_4;
23692   Py_ssize_t __pyx_t_5;
23693   __Pyx_RefNannySetupContext("slice_copy", 0);
23694 
23695   /* "View.MemoryView":1067
23696  *     cdef (Py_ssize_t*) shape, strides, suboffsets
23697  *
23698  *     shape = memview.view.shape             # <<<<<<<<<<<<<<
23699  *     strides = memview.view.strides
23700  *     suboffsets = memview.view.suboffsets
23701  */
23702   __pyx_t_1 = __pyx_v_memview->view.shape;
23703   __pyx_v_shape = __pyx_t_1;
23704 
23705   /* "View.MemoryView":1068
23706  *
23707  *     shape = memview.view.shape
23708  *     strides = memview.view.strides             # <<<<<<<<<<<<<<
23709  *     suboffsets = memview.view.suboffsets
23710  *
23711  */
23712   __pyx_t_1 = __pyx_v_memview->view.strides;
23713   __pyx_v_strides = __pyx_t_1;
23714 
23715   /* "View.MemoryView":1069
23716  *     shape = memview.view.shape
23717  *     strides = memview.view.strides
23718  *     suboffsets = memview.view.suboffsets             # <<<<<<<<<<<<<<
23719  *
23720  *     dst.memview = <__pyx_memoryview *> memview
23721  */
23722   __pyx_t_1 = __pyx_v_memview->view.suboffsets;
23723   __pyx_v_suboffsets = __pyx_t_1;
23724 
23725   /* "View.MemoryView":1071
23726  *     suboffsets = memview.view.suboffsets
23727  *
23728  *     dst.memview = <__pyx_memoryview *> memview             # <<<<<<<<<<<<<<
23729  *     dst.data = <char *> memview.view.buf
23730  *
23731  */
23732   __pyx_v_dst->memview = ((struct __pyx_memoryview_obj *)__pyx_v_memview);
23733 
23734   /* "View.MemoryView":1072
23735  *
23736  *     dst.memview = <__pyx_memoryview *> memview
23737  *     dst.data = <char *> memview.view.buf             # <<<<<<<<<<<<<<
23738  *
23739  *     for dim in range(memview.view.ndim):
23740  */
23741   __pyx_v_dst->data = ((char *)__pyx_v_memview->view.buf);
23742 
23743   /* "View.MemoryView":1074
23744  *     dst.data = <char *> memview.view.buf
23745  *
23746  *     for dim in range(memview.view.ndim):             # <<<<<<<<<<<<<<
23747  *         dst.shape[dim] = shape[dim]
23748  *         dst.strides[dim] = strides[dim]
23749  */
23750   __pyx_t_2 = __pyx_v_memview->view.ndim;
23751   __pyx_t_3 = __pyx_t_2;
23752   for (__pyx_t_4 = 0; __pyx_t_4 < __pyx_t_3; __pyx_t_4+=1) {
23753     __pyx_v_dim = __pyx_t_4;
23754 
23755     /* "View.MemoryView":1075
23756  *
23757  *     for dim in range(memview.view.ndim):
23758  *         dst.shape[dim] = shape[dim]             # <<<<<<<<<<<<<<
23759  *         dst.strides[dim] = strides[dim]
23760  *         dst.suboffsets[dim] = suboffsets[dim] if suboffsets else -1
23761  */
23762     (__pyx_v_dst->shape[__pyx_v_dim]) = (__pyx_v_shape[__pyx_v_dim]);
23763 
23764     /* "View.MemoryView":1076
23765  *     for dim in range(memview.view.ndim):
23766  *         dst.shape[dim] = shape[dim]
23767  *         dst.strides[dim] = strides[dim]             # <<<<<<<<<<<<<<
23768  *         dst.suboffsets[dim] = suboffsets[dim] if suboffsets else -1
23769  *
23770  */
23771     (__pyx_v_dst->strides[__pyx_v_dim]) = (__pyx_v_strides[__pyx_v_dim]);
23772 
23773     /* "View.MemoryView":1077
23774  *         dst.shape[dim] = shape[dim]
23775  *         dst.strides[dim] = strides[dim]
23776  *         dst.suboffsets[dim] = suboffsets[dim] if suboffsets else -1             # <<<<<<<<<<<<<<
23777  *
23778  * @cname('__pyx_memoryview_copy_object')
23779  */
23780     if ((__pyx_v_suboffsets != 0)) {
23781       __pyx_t_5 = (__pyx_v_suboffsets[__pyx_v_dim]);
23782     } else {
23783       __pyx_t_5 = -1L;
23784     }
23785     (__pyx_v_dst->suboffsets[__pyx_v_dim]) = __pyx_t_5;
23786   }
23787 
23788   /* "View.MemoryView":1063
23789  *
23790  * @cname('__pyx_memoryview_slice_copy')
23791  * cdef void slice_copy(memoryview memview, __Pyx_memviewslice *dst):             # <<<<<<<<<<<<<<
23792  *     cdef int dim
23793  *     cdef (Py_ssize_t*) shape, strides, suboffsets
23794  */
23795 
23796   /* function exit code */
23797   __Pyx_RefNannyFinishContext();
23798 }
23799 
23800 /* "View.MemoryView":1080
23801  *
23802  * @cname('__pyx_memoryview_copy_object')
23803  * cdef memoryview_copy(memoryview memview):             # <<<<<<<<<<<<<<
23804  *     "Create a new memoryview object"
23805  *     cdef __Pyx_memviewslice memviewslice
23806  */
23807 
__pyx_memoryview_copy_object(struct __pyx_memoryview_obj * __pyx_v_memview)23808 static PyObject *__pyx_memoryview_copy_object(struct __pyx_memoryview_obj *__pyx_v_memview) {
23809   __Pyx_memviewslice __pyx_v_memviewslice;
23810   PyObject *__pyx_r = NULL;
23811   __Pyx_RefNannyDeclarations
23812   PyObject *__pyx_t_1 = NULL;
23813   int __pyx_lineno = 0;
23814   const char *__pyx_filename = NULL;
23815   int __pyx_clineno = 0;
23816   __Pyx_RefNannySetupContext("memoryview_copy", 0);
23817 
23818   /* "View.MemoryView":1083
23819  *     "Create a new memoryview object"
23820  *     cdef __Pyx_memviewslice memviewslice
23821  *     slice_copy(memview, &memviewslice)             # <<<<<<<<<<<<<<
23822  *     return memoryview_copy_from_slice(memview, &memviewslice)
23823  *
23824  */
23825   __pyx_memoryview_slice_copy(__pyx_v_memview, (&__pyx_v_memviewslice));
23826 
23827   /* "View.MemoryView":1084
23828  *     cdef __Pyx_memviewslice memviewslice
23829  *     slice_copy(memview, &memviewslice)
23830  *     return memoryview_copy_from_slice(memview, &memviewslice)             # <<<<<<<<<<<<<<
23831  *
23832  * @cname('__pyx_memoryview_copy_object_from_slice')
23833  */
23834   __Pyx_XDECREF(__pyx_r);
23835   __pyx_t_1 = __pyx_memoryview_copy_object_from_slice(__pyx_v_memview, (&__pyx_v_memviewslice)); if (unlikely(!__pyx_t_1)) __PYX_ERR(3, 1084, __pyx_L1_error)
23836   __Pyx_GOTREF(__pyx_t_1);
23837   __pyx_r = __pyx_t_1;
23838   __pyx_t_1 = 0;
23839   goto __pyx_L0;
23840 
23841   /* "View.MemoryView":1080
23842  *
23843  * @cname('__pyx_memoryview_copy_object')
23844  * cdef memoryview_copy(memoryview memview):             # <<<<<<<<<<<<<<
23845  *     "Create a new memoryview object"
23846  *     cdef __Pyx_memviewslice memviewslice
23847  */
23848 
23849   /* function exit code */
23850   __pyx_L1_error:;
23851   __Pyx_XDECREF(__pyx_t_1);
23852   __Pyx_AddTraceback("View.MemoryView.memoryview_copy", __pyx_clineno, __pyx_lineno, __pyx_filename);
23853   __pyx_r = 0;
23854   __pyx_L0:;
23855   __Pyx_XGIVEREF(__pyx_r);
23856   __Pyx_RefNannyFinishContext();
23857   return __pyx_r;
23858 }
23859 
23860 /* "View.MemoryView":1087
23861  *
23862  * @cname('__pyx_memoryview_copy_object_from_slice')
23863  * cdef memoryview_copy_from_slice(memoryview memview, __Pyx_memviewslice *memviewslice):             # <<<<<<<<<<<<<<
23864  *     """
23865  *     Create a new memoryview object from a given memoryview object and slice.
23866  */
23867 
__pyx_memoryview_copy_object_from_slice(struct __pyx_memoryview_obj * __pyx_v_memview,__Pyx_memviewslice * __pyx_v_memviewslice)23868 static PyObject *__pyx_memoryview_copy_object_from_slice(struct __pyx_memoryview_obj *__pyx_v_memview, __Pyx_memviewslice *__pyx_v_memviewslice) {
23869   PyObject *(*__pyx_v_to_object_func)(char *);
23870   int (*__pyx_v_to_dtype_func)(char *, PyObject *);
23871   PyObject *__pyx_r = NULL;
23872   __Pyx_RefNannyDeclarations
23873   int __pyx_t_1;
23874   int __pyx_t_2;
23875   PyObject *(*__pyx_t_3)(char *);
23876   int (*__pyx_t_4)(char *, PyObject *);
23877   PyObject *__pyx_t_5 = NULL;
23878   int __pyx_lineno = 0;
23879   const char *__pyx_filename = NULL;
23880   int __pyx_clineno = 0;
23881   __Pyx_RefNannySetupContext("memoryview_copy_from_slice", 0);
23882 
23883   /* "View.MemoryView":1094
23884  *     cdef int (*to_dtype_func)(char *, object) except 0
23885  *
23886  *     if isinstance(memview, _memoryviewslice):             # <<<<<<<<<<<<<<
23887  *         to_object_func = (<_memoryviewslice> memview).to_object_func
23888  *         to_dtype_func = (<_memoryviewslice> memview).to_dtype_func
23889  */
23890   __pyx_t_1 = __Pyx_TypeCheck(((PyObject *)__pyx_v_memview), __pyx_memoryviewslice_type);
23891   __pyx_t_2 = (__pyx_t_1 != 0);
23892   if (__pyx_t_2) {
23893 
23894     /* "View.MemoryView":1095
23895  *
23896  *     if isinstance(memview, _memoryviewslice):
23897  *         to_object_func = (<_memoryviewslice> memview).to_object_func             # <<<<<<<<<<<<<<
23898  *         to_dtype_func = (<_memoryviewslice> memview).to_dtype_func
23899  *     else:
23900  */
23901     __pyx_t_3 = ((struct __pyx_memoryviewslice_obj *)__pyx_v_memview)->to_object_func;
23902     __pyx_v_to_object_func = __pyx_t_3;
23903 
23904     /* "View.MemoryView":1096
23905  *     if isinstance(memview, _memoryviewslice):
23906  *         to_object_func = (<_memoryviewslice> memview).to_object_func
23907  *         to_dtype_func = (<_memoryviewslice> memview).to_dtype_func             # <<<<<<<<<<<<<<
23908  *     else:
23909  *         to_object_func = NULL
23910  */
23911     __pyx_t_4 = ((struct __pyx_memoryviewslice_obj *)__pyx_v_memview)->to_dtype_func;
23912     __pyx_v_to_dtype_func = __pyx_t_4;
23913 
23914     /* "View.MemoryView":1094
23915  *     cdef int (*to_dtype_func)(char *, object) except 0
23916  *
23917  *     if isinstance(memview, _memoryviewslice):             # <<<<<<<<<<<<<<
23918  *         to_object_func = (<_memoryviewslice> memview).to_object_func
23919  *         to_dtype_func = (<_memoryviewslice> memview).to_dtype_func
23920  */
23921     goto __pyx_L3;
23922   }
23923 
23924   /* "View.MemoryView":1098
23925  *         to_dtype_func = (<_memoryviewslice> memview).to_dtype_func
23926  *     else:
23927  *         to_object_func = NULL             # <<<<<<<<<<<<<<
23928  *         to_dtype_func = NULL
23929  *
23930  */
23931   /*else*/ {
23932     __pyx_v_to_object_func = NULL;
23933 
23934     /* "View.MemoryView":1099
23935  *     else:
23936  *         to_object_func = NULL
23937  *         to_dtype_func = NULL             # <<<<<<<<<<<<<<
23938  *
23939  *     return memoryview_fromslice(memviewslice[0], memview.view.ndim,
23940  */
23941     __pyx_v_to_dtype_func = NULL;
23942   }
23943   __pyx_L3:;
23944 
23945   /* "View.MemoryView":1101
23946  *         to_dtype_func = NULL
23947  *
23948  *     return memoryview_fromslice(memviewslice[0], memview.view.ndim,             # <<<<<<<<<<<<<<
23949  *                                 to_object_func, to_dtype_func,
23950  *                                 memview.dtype_is_object)
23951  */
23952   __Pyx_XDECREF(__pyx_r);
23953 
23954   /* "View.MemoryView":1103
23955  *     return memoryview_fromslice(memviewslice[0], memview.view.ndim,
23956  *                                 to_object_func, to_dtype_func,
23957  *                                 memview.dtype_is_object)             # <<<<<<<<<<<<<<
23958  *
23959  *
23960  */
23961   __pyx_t_5 = __pyx_memoryview_fromslice((__pyx_v_memviewslice[0]), __pyx_v_memview->view.ndim, __pyx_v_to_object_func, __pyx_v_to_dtype_func, __pyx_v_memview->dtype_is_object); if (unlikely(!__pyx_t_5)) __PYX_ERR(3, 1101, __pyx_L1_error)
23962   __Pyx_GOTREF(__pyx_t_5);
23963   __pyx_r = __pyx_t_5;
23964   __pyx_t_5 = 0;
23965   goto __pyx_L0;
23966 
23967   /* "View.MemoryView":1087
23968  *
23969  * @cname('__pyx_memoryview_copy_object_from_slice')
23970  * cdef memoryview_copy_from_slice(memoryview memview, __Pyx_memviewslice *memviewslice):             # <<<<<<<<<<<<<<
23971  *     """
23972  *     Create a new memoryview object from a given memoryview object and slice.
23973  */
23974 
23975   /* function exit code */
23976   __pyx_L1_error:;
23977   __Pyx_XDECREF(__pyx_t_5);
23978   __Pyx_AddTraceback("View.MemoryView.memoryview_copy_from_slice", __pyx_clineno, __pyx_lineno, __pyx_filename);
23979   __pyx_r = 0;
23980   __pyx_L0:;
23981   __Pyx_XGIVEREF(__pyx_r);
23982   __Pyx_RefNannyFinishContext();
23983   return __pyx_r;
23984 }
23985 
23986 /* "View.MemoryView":1109
23987  *
23988  *
23989  * cdef Py_ssize_t abs_py_ssize_t(Py_ssize_t arg) nogil:             # <<<<<<<<<<<<<<
23990  *     if arg < 0:
23991  *         return -arg
23992  */
23993 
abs_py_ssize_t(Py_ssize_t __pyx_v_arg)23994 static Py_ssize_t abs_py_ssize_t(Py_ssize_t __pyx_v_arg) {
23995   Py_ssize_t __pyx_r;
23996   int __pyx_t_1;
23997 
23998   /* "View.MemoryView":1110
23999  *
24000  * cdef Py_ssize_t abs_py_ssize_t(Py_ssize_t arg) nogil:
24001  *     if arg < 0:             # <<<<<<<<<<<<<<
24002  *         return -arg
24003  *     else:
24004  */
24005   __pyx_t_1 = ((__pyx_v_arg < 0) != 0);
24006   if (__pyx_t_1) {
24007 
24008     /* "View.MemoryView":1111
24009  * cdef Py_ssize_t abs_py_ssize_t(Py_ssize_t arg) nogil:
24010  *     if arg < 0:
24011  *         return -arg             # <<<<<<<<<<<<<<
24012  *     else:
24013  *         return arg
24014  */
24015     __pyx_r = (-__pyx_v_arg);
24016     goto __pyx_L0;
24017 
24018     /* "View.MemoryView":1110
24019  *
24020  * cdef Py_ssize_t abs_py_ssize_t(Py_ssize_t arg) nogil:
24021  *     if arg < 0:             # <<<<<<<<<<<<<<
24022  *         return -arg
24023  *     else:
24024  */
24025   }
24026 
24027   /* "View.MemoryView":1113
24028  *         return -arg
24029  *     else:
24030  *         return arg             # <<<<<<<<<<<<<<
24031  *
24032  * @cname('__pyx_get_best_slice_order')
24033  */
24034   /*else*/ {
24035     __pyx_r = __pyx_v_arg;
24036     goto __pyx_L0;
24037   }
24038 
24039   /* "View.MemoryView":1109
24040  *
24041  *
24042  * cdef Py_ssize_t abs_py_ssize_t(Py_ssize_t arg) nogil:             # <<<<<<<<<<<<<<
24043  *     if arg < 0:
24044  *         return -arg
24045  */
24046 
24047   /* function exit code */
24048   __pyx_L0:;
24049   return __pyx_r;
24050 }
24051 
24052 /* "View.MemoryView":1116
24053  *
24054  * @cname('__pyx_get_best_slice_order')
24055  * cdef char get_best_order(__Pyx_memviewslice *mslice, int ndim) nogil:             # <<<<<<<<<<<<<<
24056  *     """
24057  *     Figure out the best memory access order for a given slice.
24058  */
24059 
__pyx_get_best_slice_order(__Pyx_memviewslice * __pyx_v_mslice,int __pyx_v_ndim)24060 static char __pyx_get_best_slice_order(__Pyx_memviewslice *__pyx_v_mslice, int __pyx_v_ndim) {
24061   int __pyx_v_i;
24062   Py_ssize_t __pyx_v_c_stride;
24063   Py_ssize_t __pyx_v_f_stride;
24064   char __pyx_r;
24065   int __pyx_t_1;
24066   int __pyx_t_2;
24067   int __pyx_t_3;
24068   int __pyx_t_4;
24069 
24070   /* "View.MemoryView":1121
24071  *     """
24072  *     cdef int i
24073  *     cdef Py_ssize_t c_stride = 0             # <<<<<<<<<<<<<<
24074  *     cdef Py_ssize_t f_stride = 0
24075  *
24076  */
24077   __pyx_v_c_stride = 0;
24078 
24079   /* "View.MemoryView":1122
24080  *     cdef int i
24081  *     cdef Py_ssize_t c_stride = 0
24082  *     cdef Py_ssize_t f_stride = 0             # <<<<<<<<<<<<<<
24083  *
24084  *     for i in range(ndim - 1, -1, -1):
24085  */
24086   __pyx_v_f_stride = 0;
24087 
24088   /* "View.MemoryView":1124
24089  *     cdef Py_ssize_t f_stride = 0
24090  *
24091  *     for i in range(ndim - 1, -1, -1):             # <<<<<<<<<<<<<<
24092  *         if mslice.shape[i] > 1:
24093  *             c_stride = mslice.strides[i]
24094  */
24095   for (__pyx_t_1 = (__pyx_v_ndim - 1); __pyx_t_1 > -1; __pyx_t_1-=1) {
24096     __pyx_v_i = __pyx_t_1;
24097 
24098     /* "View.MemoryView":1125
24099  *
24100  *     for i in range(ndim - 1, -1, -1):
24101  *         if mslice.shape[i] > 1:             # <<<<<<<<<<<<<<
24102  *             c_stride = mslice.strides[i]
24103  *             break
24104  */
24105     __pyx_t_2 = (((__pyx_v_mslice->shape[__pyx_v_i]) > 1) != 0);
24106     if (__pyx_t_2) {
24107 
24108       /* "View.MemoryView":1126
24109  *     for i in range(ndim - 1, -1, -1):
24110  *         if mslice.shape[i] > 1:
24111  *             c_stride = mslice.strides[i]             # <<<<<<<<<<<<<<
24112  *             break
24113  *
24114  */
24115       __pyx_v_c_stride = (__pyx_v_mslice->strides[__pyx_v_i]);
24116 
24117       /* "View.MemoryView":1127
24118  *         if mslice.shape[i] > 1:
24119  *             c_stride = mslice.strides[i]
24120  *             break             # <<<<<<<<<<<<<<
24121  *
24122  *     for i in range(ndim):
24123  */
24124       goto __pyx_L4_break;
24125 
24126       /* "View.MemoryView":1125
24127  *
24128  *     for i in range(ndim - 1, -1, -1):
24129  *         if mslice.shape[i] > 1:             # <<<<<<<<<<<<<<
24130  *             c_stride = mslice.strides[i]
24131  *             break
24132  */
24133     }
24134   }
24135   __pyx_L4_break:;
24136 
24137   /* "View.MemoryView":1129
24138  *             break
24139  *
24140  *     for i in range(ndim):             # <<<<<<<<<<<<<<
24141  *         if mslice.shape[i] > 1:
24142  *             f_stride = mslice.strides[i]
24143  */
24144   __pyx_t_1 = __pyx_v_ndim;
24145   __pyx_t_3 = __pyx_t_1;
24146   for (__pyx_t_4 = 0; __pyx_t_4 < __pyx_t_3; __pyx_t_4+=1) {
24147     __pyx_v_i = __pyx_t_4;
24148 
24149     /* "View.MemoryView":1130
24150  *
24151  *     for i in range(ndim):
24152  *         if mslice.shape[i] > 1:             # <<<<<<<<<<<<<<
24153  *             f_stride = mslice.strides[i]
24154  *             break
24155  */
24156     __pyx_t_2 = (((__pyx_v_mslice->shape[__pyx_v_i]) > 1) != 0);
24157     if (__pyx_t_2) {
24158 
24159       /* "View.MemoryView":1131
24160  *     for i in range(ndim):
24161  *         if mslice.shape[i] > 1:
24162  *             f_stride = mslice.strides[i]             # <<<<<<<<<<<<<<
24163  *             break
24164  *
24165  */
24166       __pyx_v_f_stride = (__pyx_v_mslice->strides[__pyx_v_i]);
24167 
24168       /* "View.MemoryView":1132
24169  *         if mslice.shape[i] > 1:
24170  *             f_stride = mslice.strides[i]
24171  *             break             # <<<<<<<<<<<<<<
24172  *
24173  *     if abs_py_ssize_t(c_stride) <= abs_py_ssize_t(f_stride):
24174  */
24175       goto __pyx_L7_break;
24176 
24177       /* "View.MemoryView":1130
24178  *
24179  *     for i in range(ndim):
24180  *         if mslice.shape[i] > 1:             # <<<<<<<<<<<<<<
24181  *             f_stride = mslice.strides[i]
24182  *             break
24183  */
24184     }
24185   }
24186   __pyx_L7_break:;
24187 
24188   /* "View.MemoryView":1134
24189  *             break
24190  *
24191  *     if abs_py_ssize_t(c_stride) <= abs_py_ssize_t(f_stride):             # <<<<<<<<<<<<<<
24192  *         return 'C'
24193  *     else:
24194  */
24195   __pyx_t_2 = ((abs_py_ssize_t(__pyx_v_c_stride) <= abs_py_ssize_t(__pyx_v_f_stride)) != 0);
24196   if (__pyx_t_2) {
24197 
24198     /* "View.MemoryView":1135
24199  *
24200  *     if abs_py_ssize_t(c_stride) <= abs_py_ssize_t(f_stride):
24201  *         return 'C'             # <<<<<<<<<<<<<<
24202  *     else:
24203  *         return 'F'
24204  */
24205     __pyx_r = 'C';
24206     goto __pyx_L0;
24207 
24208     /* "View.MemoryView":1134
24209  *             break
24210  *
24211  *     if abs_py_ssize_t(c_stride) <= abs_py_ssize_t(f_stride):             # <<<<<<<<<<<<<<
24212  *         return 'C'
24213  *     else:
24214  */
24215   }
24216 
24217   /* "View.MemoryView":1137
24218  *         return 'C'
24219  *     else:
24220  *         return 'F'             # <<<<<<<<<<<<<<
24221  *
24222  * @cython.cdivision(True)
24223  */
24224   /*else*/ {
24225     __pyx_r = 'F';
24226     goto __pyx_L0;
24227   }
24228 
24229   /* "View.MemoryView":1116
24230  *
24231  * @cname('__pyx_get_best_slice_order')
24232  * cdef char get_best_order(__Pyx_memviewslice *mslice, int ndim) nogil:             # <<<<<<<<<<<<<<
24233  *     """
24234  *     Figure out the best memory access order for a given slice.
24235  */
24236 
24237   /* function exit code */
24238   __pyx_L0:;
24239   return __pyx_r;
24240 }
24241 
24242 /* "View.MemoryView":1140
24243  *
24244  * @cython.cdivision(True)
24245  * cdef void _copy_strided_to_strided(char *src_data, Py_ssize_t *src_strides,             # <<<<<<<<<<<<<<
24246  *                                    char *dst_data, Py_ssize_t *dst_strides,
24247  *                                    Py_ssize_t *src_shape, Py_ssize_t *dst_shape,
24248  */
24249 
_copy_strided_to_strided(char * __pyx_v_src_data,Py_ssize_t * __pyx_v_src_strides,char * __pyx_v_dst_data,Py_ssize_t * __pyx_v_dst_strides,Py_ssize_t * __pyx_v_src_shape,Py_ssize_t * __pyx_v_dst_shape,int __pyx_v_ndim,size_t __pyx_v_itemsize)24250 static void _copy_strided_to_strided(char *__pyx_v_src_data, Py_ssize_t *__pyx_v_src_strides, char *__pyx_v_dst_data, Py_ssize_t *__pyx_v_dst_strides, Py_ssize_t *__pyx_v_src_shape, Py_ssize_t *__pyx_v_dst_shape, int __pyx_v_ndim, size_t __pyx_v_itemsize) {
24251   CYTHON_UNUSED Py_ssize_t __pyx_v_i;
24252   CYTHON_UNUSED Py_ssize_t __pyx_v_src_extent;
24253   Py_ssize_t __pyx_v_dst_extent;
24254   Py_ssize_t __pyx_v_src_stride;
24255   Py_ssize_t __pyx_v_dst_stride;
24256   int __pyx_t_1;
24257   int __pyx_t_2;
24258   int __pyx_t_3;
24259   Py_ssize_t __pyx_t_4;
24260   Py_ssize_t __pyx_t_5;
24261   Py_ssize_t __pyx_t_6;
24262 
24263   /* "View.MemoryView":1147
24264  *
24265  *     cdef Py_ssize_t i
24266  *     cdef Py_ssize_t src_extent = src_shape[0]             # <<<<<<<<<<<<<<
24267  *     cdef Py_ssize_t dst_extent = dst_shape[0]
24268  *     cdef Py_ssize_t src_stride = src_strides[0]
24269  */
24270   __pyx_v_src_extent = (__pyx_v_src_shape[0]);
24271 
24272   /* "View.MemoryView":1148
24273  *     cdef Py_ssize_t i
24274  *     cdef Py_ssize_t src_extent = src_shape[0]
24275  *     cdef Py_ssize_t dst_extent = dst_shape[0]             # <<<<<<<<<<<<<<
24276  *     cdef Py_ssize_t src_stride = src_strides[0]
24277  *     cdef Py_ssize_t dst_stride = dst_strides[0]
24278  */
24279   __pyx_v_dst_extent = (__pyx_v_dst_shape[0]);
24280 
24281   /* "View.MemoryView":1149
24282  *     cdef Py_ssize_t src_extent = src_shape[0]
24283  *     cdef Py_ssize_t dst_extent = dst_shape[0]
24284  *     cdef Py_ssize_t src_stride = src_strides[0]             # <<<<<<<<<<<<<<
24285  *     cdef Py_ssize_t dst_stride = dst_strides[0]
24286  *
24287  */
24288   __pyx_v_src_stride = (__pyx_v_src_strides[0]);
24289 
24290   /* "View.MemoryView":1150
24291  *     cdef Py_ssize_t dst_extent = dst_shape[0]
24292  *     cdef Py_ssize_t src_stride = src_strides[0]
24293  *     cdef Py_ssize_t dst_stride = dst_strides[0]             # <<<<<<<<<<<<<<
24294  *
24295  *     if ndim == 1:
24296  */
24297   __pyx_v_dst_stride = (__pyx_v_dst_strides[0]);
24298 
24299   /* "View.MemoryView":1152
24300  *     cdef Py_ssize_t dst_stride = dst_strides[0]
24301  *
24302  *     if ndim == 1:             # <<<<<<<<<<<<<<
24303  *        if (src_stride > 0 and dst_stride > 0 and
24304  *            <size_t> src_stride == itemsize == <size_t> dst_stride):
24305  */
24306   __pyx_t_1 = ((__pyx_v_ndim == 1) != 0);
24307   if (__pyx_t_1) {
24308 
24309     /* "View.MemoryView":1153
24310  *
24311  *     if ndim == 1:
24312  *        if (src_stride > 0 and dst_stride > 0 and             # <<<<<<<<<<<<<<
24313  *            <size_t> src_stride == itemsize == <size_t> dst_stride):
24314  *            memcpy(dst_data, src_data, itemsize * dst_extent)
24315  */
24316     __pyx_t_2 = ((__pyx_v_src_stride > 0) != 0);
24317     if (__pyx_t_2) {
24318     } else {
24319       __pyx_t_1 = __pyx_t_2;
24320       goto __pyx_L5_bool_binop_done;
24321     }
24322     __pyx_t_2 = ((__pyx_v_dst_stride > 0) != 0);
24323     if (__pyx_t_2) {
24324     } else {
24325       __pyx_t_1 = __pyx_t_2;
24326       goto __pyx_L5_bool_binop_done;
24327     }
24328 
24329     /* "View.MemoryView":1154
24330  *     if ndim == 1:
24331  *        if (src_stride > 0 and dst_stride > 0 and
24332  *            <size_t> src_stride == itemsize == <size_t> dst_stride):             # <<<<<<<<<<<<<<
24333  *            memcpy(dst_data, src_data, itemsize * dst_extent)
24334  *        else:
24335  */
24336     __pyx_t_2 = (((size_t)__pyx_v_src_stride) == __pyx_v_itemsize);
24337     if (__pyx_t_2) {
24338       __pyx_t_2 = (__pyx_v_itemsize == ((size_t)__pyx_v_dst_stride));
24339     }
24340     __pyx_t_3 = (__pyx_t_2 != 0);
24341     __pyx_t_1 = __pyx_t_3;
24342     __pyx_L5_bool_binop_done:;
24343 
24344     /* "View.MemoryView":1153
24345  *
24346  *     if ndim == 1:
24347  *        if (src_stride > 0 and dst_stride > 0 and             # <<<<<<<<<<<<<<
24348  *            <size_t> src_stride == itemsize == <size_t> dst_stride):
24349  *            memcpy(dst_data, src_data, itemsize * dst_extent)
24350  */
24351     if (__pyx_t_1) {
24352 
24353       /* "View.MemoryView":1155
24354  *        if (src_stride > 0 and dst_stride > 0 and
24355  *            <size_t> src_stride == itemsize == <size_t> dst_stride):
24356  *            memcpy(dst_data, src_data, itemsize * dst_extent)             # <<<<<<<<<<<<<<
24357  *        else:
24358  *            for i in range(dst_extent):
24359  */
24360       (void)(memcpy(__pyx_v_dst_data, __pyx_v_src_data, (__pyx_v_itemsize * __pyx_v_dst_extent)));
24361 
24362       /* "View.MemoryView":1153
24363  *
24364  *     if ndim == 1:
24365  *        if (src_stride > 0 and dst_stride > 0 and             # <<<<<<<<<<<<<<
24366  *            <size_t> src_stride == itemsize == <size_t> dst_stride):
24367  *            memcpy(dst_data, src_data, itemsize * dst_extent)
24368  */
24369       goto __pyx_L4;
24370     }
24371 
24372     /* "View.MemoryView":1157
24373  *            memcpy(dst_data, src_data, itemsize * dst_extent)
24374  *        else:
24375  *            for i in range(dst_extent):             # <<<<<<<<<<<<<<
24376  *                memcpy(dst_data, src_data, itemsize)
24377  *                src_data += src_stride
24378  */
24379     /*else*/ {
24380       __pyx_t_4 = __pyx_v_dst_extent;
24381       __pyx_t_5 = __pyx_t_4;
24382       for (__pyx_t_6 = 0; __pyx_t_6 < __pyx_t_5; __pyx_t_6+=1) {
24383         __pyx_v_i = __pyx_t_6;
24384 
24385         /* "View.MemoryView":1158
24386  *        else:
24387  *            for i in range(dst_extent):
24388  *                memcpy(dst_data, src_data, itemsize)             # <<<<<<<<<<<<<<
24389  *                src_data += src_stride
24390  *                dst_data += dst_stride
24391  */
24392         (void)(memcpy(__pyx_v_dst_data, __pyx_v_src_data, __pyx_v_itemsize));
24393 
24394         /* "View.MemoryView":1159
24395  *            for i in range(dst_extent):
24396  *                memcpy(dst_data, src_data, itemsize)
24397  *                src_data += src_stride             # <<<<<<<<<<<<<<
24398  *                dst_data += dst_stride
24399  *     else:
24400  */
24401         __pyx_v_src_data = (__pyx_v_src_data + __pyx_v_src_stride);
24402 
24403         /* "View.MemoryView":1160
24404  *                memcpy(dst_data, src_data, itemsize)
24405  *                src_data += src_stride
24406  *                dst_data += dst_stride             # <<<<<<<<<<<<<<
24407  *     else:
24408  *         for i in range(dst_extent):
24409  */
24410         __pyx_v_dst_data = (__pyx_v_dst_data + __pyx_v_dst_stride);
24411       }
24412     }
24413     __pyx_L4:;
24414 
24415     /* "View.MemoryView":1152
24416  *     cdef Py_ssize_t dst_stride = dst_strides[0]
24417  *
24418  *     if ndim == 1:             # <<<<<<<<<<<<<<
24419  *        if (src_stride > 0 and dst_stride > 0 and
24420  *            <size_t> src_stride == itemsize == <size_t> dst_stride):
24421  */
24422     goto __pyx_L3;
24423   }
24424 
24425   /* "View.MemoryView":1162
24426  *                dst_data += dst_stride
24427  *     else:
24428  *         for i in range(dst_extent):             # <<<<<<<<<<<<<<
24429  *             _copy_strided_to_strided(src_data, src_strides + 1,
24430  *                                      dst_data, dst_strides + 1,
24431  */
24432   /*else*/ {
24433     __pyx_t_4 = __pyx_v_dst_extent;
24434     __pyx_t_5 = __pyx_t_4;
24435     for (__pyx_t_6 = 0; __pyx_t_6 < __pyx_t_5; __pyx_t_6+=1) {
24436       __pyx_v_i = __pyx_t_6;
24437 
24438       /* "View.MemoryView":1163
24439  *     else:
24440  *         for i in range(dst_extent):
24441  *             _copy_strided_to_strided(src_data, src_strides + 1,             # <<<<<<<<<<<<<<
24442  *                                      dst_data, dst_strides + 1,
24443  *                                      src_shape + 1, dst_shape + 1,
24444  */
24445       _copy_strided_to_strided(__pyx_v_src_data, (__pyx_v_src_strides + 1), __pyx_v_dst_data, (__pyx_v_dst_strides + 1), (__pyx_v_src_shape + 1), (__pyx_v_dst_shape + 1), (__pyx_v_ndim - 1), __pyx_v_itemsize);
24446 
24447       /* "View.MemoryView":1167
24448  *                                      src_shape + 1, dst_shape + 1,
24449  *                                      ndim - 1, itemsize)
24450  *             src_data += src_stride             # <<<<<<<<<<<<<<
24451  *             dst_data += dst_stride
24452  *
24453  */
24454       __pyx_v_src_data = (__pyx_v_src_data + __pyx_v_src_stride);
24455 
24456       /* "View.MemoryView":1168
24457  *                                      ndim - 1, itemsize)
24458  *             src_data += src_stride
24459  *             dst_data += dst_stride             # <<<<<<<<<<<<<<
24460  *
24461  * cdef void copy_strided_to_strided(__Pyx_memviewslice *src,
24462  */
24463       __pyx_v_dst_data = (__pyx_v_dst_data + __pyx_v_dst_stride);
24464     }
24465   }
24466   __pyx_L3:;
24467 
24468   /* "View.MemoryView":1140
24469  *
24470  * @cython.cdivision(True)
24471  * cdef void _copy_strided_to_strided(char *src_data, Py_ssize_t *src_strides,             # <<<<<<<<<<<<<<
24472  *                                    char *dst_data, Py_ssize_t *dst_strides,
24473  *                                    Py_ssize_t *src_shape, Py_ssize_t *dst_shape,
24474  */
24475 
24476   /* function exit code */
24477 }
24478 
24479 /* "View.MemoryView":1170
24480  *             dst_data += dst_stride
24481  *
24482  * cdef void copy_strided_to_strided(__Pyx_memviewslice *src,             # <<<<<<<<<<<<<<
24483  *                                   __Pyx_memviewslice *dst,
24484  *                                   int ndim, size_t itemsize) nogil:
24485  */
24486 
copy_strided_to_strided(__Pyx_memviewslice * __pyx_v_src,__Pyx_memviewslice * __pyx_v_dst,int __pyx_v_ndim,size_t __pyx_v_itemsize)24487 static void copy_strided_to_strided(__Pyx_memviewslice *__pyx_v_src, __Pyx_memviewslice *__pyx_v_dst, int __pyx_v_ndim, size_t __pyx_v_itemsize) {
24488 
24489   /* "View.MemoryView":1173
24490  *                                   __Pyx_memviewslice *dst,
24491  *                                   int ndim, size_t itemsize) nogil:
24492  *     _copy_strided_to_strided(src.data, src.strides, dst.data, dst.strides,             # <<<<<<<<<<<<<<
24493  *                              src.shape, dst.shape, ndim, itemsize)
24494  *
24495  */
24496   _copy_strided_to_strided(__pyx_v_src->data, __pyx_v_src->strides, __pyx_v_dst->data, __pyx_v_dst->strides, __pyx_v_src->shape, __pyx_v_dst->shape, __pyx_v_ndim, __pyx_v_itemsize);
24497 
24498   /* "View.MemoryView":1170
24499  *             dst_data += dst_stride
24500  *
24501  * cdef void copy_strided_to_strided(__Pyx_memviewslice *src,             # <<<<<<<<<<<<<<
24502  *                                   __Pyx_memviewslice *dst,
24503  *                                   int ndim, size_t itemsize) nogil:
24504  */
24505 
24506   /* function exit code */
24507 }
24508 
24509 /* "View.MemoryView":1177
24510  *
24511  * @cname('__pyx_memoryview_slice_get_size')
24512  * cdef Py_ssize_t slice_get_size(__Pyx_memviewslice *src, int ndim) nogil:             # <<<<<<<<<<<<<<
24513  *     "Return the size of the memory occupied by the slice in number of bytes"
24514  *     cdef Py_ssize_t shape, size = src.memview.view.itemsize
24515  */
24516 
__pyx_memoryview_slice_get_size(__Pyx_memviewslice * __pyx_v_src,int __pyx_v_ndim)24517 static Py_ssize_t __pyx_memoryview_slice_get_size(__Pyx_memviewslice *__pyx_v_src, int __pyx_v_ndim) {
24518   Py_ssize_t __pyx_v_shape;
24519   Py_ssize_t __pyx_v_size;
24520   Py_ssize_t __pyx_r;
24521   Py_ssize_t __pyx_t_1;
24522   Py_ssize_t *__pyx_t_2;
24523   Py_ssize_t *__pyx_t_3;
24524   Py_ssize_t *__pyx_t_4;
24525 
24526   /* "View.MemoryView":1179
24527  * cdef Py_ssize_t slice_get_size(__Pyx_memviewslice *src, int ndim) nogil:
24528  *     "Return the size of the memory occupied by the slice in number of bytes"
24529  *     cdef Py_ssize_t shape, size = src.memview.view.itemsize             # <<<<<<<<<<<<<<
24530  *
24531  *     for shape in src.shape[:ndim]:
24532  */
24533   __pyx_t_1 = __pyx_v_src->memview->view.itemsize;
24534   __pyx_v_size = __pyx_t_1;
24535 
24536   /* "View.MemoryView":1181
24537  *     cdef Py_ssize_t shape, size = src.memview.view.itemsize
24538  *
24539  *     for shape in src.shape[:ndim]:             # <<<<<<<<<<<<<<
24540  *         size *= shape
24541  *
24542  */
24543   __pyx_t_3 = (__pyx_v_src->shape + __pyx_v_ndim);
24544   for (__pyx_t_4 = __pyx_v_src->shape; __pyx_t_4 < __pyx_t_3; __pyx_t_4++) {
24545     __pyx_t_2 = __pyx_t_4;
24546     __pyx_v_shape = (__pyx_t_2[0]);
24547 
24548     /* "View.MemoryView":1182
24549  *
24550  *     for shape in src.shape[:ndim]:
24551  *         size *= shape             # <<<<<<<<<<<<<<
24552  *
24553  *     return size
24554  */
24555     __pyx_v_size = (__pyx_v_size * __pyx_v_shape);
24556   }
24557 
24558   /* "View.MemoryView":1184
24559  *         size *= shape
24560  *
24561  *     return size             # <<<<<<<<<<<<<<
24562  *
24563  * @cname('__pyx_fill_contig_strides_array')
24564  */
24565   __pyx_r = __pyx_v_size;
24566   goto __pyx_L0;
24567 
24568   /* "View.MemoryView":1177
24569  *
24570  * @cname('__pyx_memoryview_slice_get_size')
24571  * cdef Py_ssize_t slice_get_size(__Pyx_memviewslice *src, int ndim) nogil:             # <<<<<<<<<<<<<<
24572  *     "Return the size of the memory occupied by the slice in number of bytes"
24573  *     cdef Py_ssize_t shape, size = src.memview.view.itemsize
24574  */
24575 
24576   /* function exit code */
24577   __pyx_L0:;
24578   return __pyx_r;
24579 }
24580 
24581 /* "View.MemoryView":1187
24582  *
24583  * @cname('__pyx_fill_contig_strides_array')
24584  * cdef Py_ssize_t fill_contig_strides_array(             # <<<<<<<<<<<<<<
24585  *                 Py_ssize_t *shape, Py_ssize_t *strides, Py_ssize_t stride,
24586  *                 int ndim, char order) nogil:
24587  */
24588 
__pyx_fill_contig_strides_array(Py_ssize_t * __pyx_v_shape,Py_ssize_t * __pyx_v_strides,Py_ssize_t __pyx_v_stride,int __pyx_v_ndim,char __pyx_v_order)24589 static Py_ssize_t __pyx_fill_contig_strides_array(Py_ssize_t *__pyx_v_shape, Py_ssize_t *__pyx_v_strides, Py_ssize_t __pyx_v_stride, int __pyx_v_ndim, char __pyx_v_order) {
24590   int __pyx_v_idx;
24591   Py_ssize_t __pyx_r;
24592   int __pyx_t_1;
24593   int __pyx_t_2;
24594   int __pyx_t_3;
24595   int __pyx_t_4;
24596 
24597   /* "View.MemoryView":1196
24598  *     cdef int idx
24599  *
24600  *     if order == 'F':             # <<<<<<<<<<<<<<
24601  *         for idx in range(ndim):
24602  *             strides[idx] = stride
24603  */
24604   __pyx_t_1 = ((__pyx_v_order == 'F') != 0);
24605   if (__pyx_t_1) {
24606 
24607     /* "View.MemoryView":1197
24608  *
24609  *     if order == 'F':
24610  *         for idx in range(ndim):             # <<<<<<<<<<<<<<
24611  *             strides[idx] = stride
24612  *             stride *= shape[idx]
24613  */
24614     __pyx_t_2 = __pyx_v_ndim;
24615     __pyx_t_3 = __pyx_t_2;
24616     for (__pyx_t_4 = 0; __pyx_t_4 < __pyx_t_3; __pyx_t_4+=1) {
24617       __pyx_v_idx = __pyx_t_4;
24618 
24619       /* "View.MemoryView":1198
24620  *     if order == 'F':
24621  *         for idx in range(ndim):
24622  *             strides[idx] = stride             # <<<<<<<<<<<<<<
24623  *             stride *= shape[idx]
24624  *     else:
24625  */
24626       (__pyx_v_strides[__pyx_v_idx]) = __pyx_v_stride;
24627 
24628       /* "View.MemoryView":1199
24629  *         for idx in range(ndim):
24630  *             strides[idx] = stride
24631  *             stride *= shape[idx]             # <<<<<<<<<<<<<<
24632  *     else:
24633  *         for idx in range(ndim - 1, -1, -1):
24634  */
24635       __pyx_v_stride = (__pyx_v_stride * (__pyx_v_shape[__pyx_v_idx]));
24636     }
24637 
24638     /* "View.MemoryView":1196
24639  *     cdef int idx
24640  *
24641  *     if order == 'F':             # <<<<<<<<<<<<<<
24642  *         for idx in range(ndim):
24643  *             strides[idx] = stride
24644  */
24645     goto __pyx_L3;
24646   }
24647 
24648   /* "View.MemoryView":1201
24649  *             stride *= shape[idx]
24650  *     else:
24651  *         for idx in range(ndim - 1, -1, -1):             # <<<<<<<<<<<<<<
24652  *             strides[idx] = stride
24653  *             stride *= shape[idx]
24654  */
24655   /*else*/ {
24656     for (__pyx_t_2 = (__pyx_v_ndim - 1); __pyx_t_2 > -1; __pyx_t_2-=1) {
24657       __pyx_v_idx = __pyx_t_2;
24658 
24659       /* "View.MemoryView":1202
24660  *     else:
24661  *         for idx in range(ndim - 1, -1, -1):
24662  *             strides[idx] = stride             # <<<<<<<<<<<<<<
24663  *             stride *= shape[idx]
24664  *
24665  */
24666       (__pyx_v_strides[__pyx_v_idx]) = __pyx_v_stride;
24667 
24668       /* "View.MemoryView":1203
24669  *         for idx in range(ndim - 1, -1, -1):
24670  *             strides[idx] = stride
24671  *             stride *= shape[idx]             # <<<<<<<<<<<<<<
24672  *
24673  *     return stride
24674  */
24675       __pyx_v_stride = (__pyx_v_stride * (__pyx_v_shape[__pyx_v_idx]));
24676     }
24677   }
24678   __pyx_L3:;
24679 
24680   /* "View.MemoryView":1205
24681  *             stride *= shape[idx]
24682  *
24683  *     return stride             # <<<<<<<<<<<<<<
24684  *
24685  * @cname('__pyx_memoryview_copy_data_to_temp')
24686  */
24687   __pyx_r = __pyx_v_stride;
24688   goto __pyx_L0;
24689 
24690   /* "View.MemoryView":1187
24691  *
24692  * @cname('__pyx_fill_contig_strides_array')
24693  * cdef Py_ssize_t fill_contig_strides_array(             # <<<<<<<<<<<<<<
24694  *                 Py_ssize_t *shape, Py_ssize_t *strides, Py_ssize_t stride,
24695  *                 int ndim, char order) nogil:
24696  */
24697 
24698   /* function exit code */
24699   __pyx_L0:;
24700   return __pyx_r;
24701 }
24702 
24703 /* "View.MemoryView":1208
24704  *
24705  * @cname('__pyx_memoryview_copy_data_to_temp')
24706  * cdef void *copy_data_to_temp(__Pyx_memviewslice *src,             # <<<<<<<<<<<<<<
24707  *                              __Pyx_memviewslice *tmpslice,
24708  *                              char order,
24709  */
24710 
__pyx_memoryview_copy_data_to_temp(__Pyx_memviewslice * __pyx_v_src,__Pyx_memviewslice * __pyx_v_tmpslice,char __pyx_v_order,int __pyx_v_ndim)24711 static void *__pyx_memoryview_copy_data_to_temp(__Pyx_memviewslice *__pyx_v_src, __Pyx_memviewslice *__pyx_v_tmpslice, char __pyx_v_order, int __pyx_v_ndim) {
24712   int __pyx_v_i;
24713   void *__pyx_v_result;
24714   size_t __pyx_v_itemsize;
24715   size_t __pyx_v_size;
24716   void *__pyx_r;
24717   Py_ssize_t __pyx_t_1;
24718   int __pyx_t_2;
24719   int __pyx_t_3;
24720   struct __pyx_memoryview_obj *__pyx_t_4;
24721   int __pyx_t_5;
24722   int __pyx_t_6;
24723   int __pyx_lineno = 0;
24724   const char *__pyx_filename = NULL;
24725   int __pyx_clineno = 0;
24726 
24727   /* "View.MemoryView":1219
24728  *     cdef void *result
24729  *
24730  *     cdef size_t itemsize = src.memview.view.itemsize             # <<<<<<<<<<<<<<
24731  *     cdef size_t size = slice_get_size(src, ndim)
24732  *
24733  */
24734   __pyx_t_1 = __pyx_v_src->memview->view.itemsize;
24735   __pyx_v_itemsize = __pyx_t_1;
24736 
24737   /* "View.MemoryView":1220
24738  *
24739  *     cdef size_t itemsize = src.memview.view.itemsize
24740  *     cdef size_t size = slice_get_size(src, ndim)             # <<<<<<<<<<<<<<
24741  *
24742  *     result = malloc(size)
24743  */
24744   __pyx_v_size = __pyx_memoryview_slice_get_size(__pyx_v_src, __pyx_v_ndim);
24745 
24746   /* "View.MemoryView":1222
24747  *     cdef size_t size = slice_get_size(src, ndim)
24748  *
24749  *     result = malloc(size)             # <<<<<<<<<<<<<<
24750  *     if not result:
24751  *         _err(MemoryError, NULL)
24752  */
24753   __pyx_v_result = malloc(__pyx_v_size);
24754 
24755   /* "View.MemoryView":1223
24756  *
24757  *     result = malloc(size)
24758  *     if not result:             # <<<<<<<<<<<<<<
24759  *         _err(MemoryError, NULL)
24760  *
24761  */
24762   __pyx_t_2 = ((!(__pyx_v_result != 0)) != 0);
24763   if (__pyx_t_2) {
24764 
24765     /* "View.MemoryView":1224
24766  *     result = malloc(size)
24767  *     if not result:
24768  *         _err(MemoryError, NULL)             # <<<<<<<<<<<<<<
24769  *
24770  *
24771  */
24772     __pyx_t_3 = __pyx_memoryview_err(__pyx_builtin_MemoryError, NULL); if (unlikely(__pyx_t_3 == ((int)-1))) __PYX_ERR(3, 1224, __pyx_L1_error)
24773 
24774     /* "View.MemoryView":1223
24775  *
24776  *     result = malloc(size)
24777  *     if not result:             # <<<<<<<<<<<<<<
24778  *         _err(MemoryError, NULL)
24779  *
24780  */
24781   }
24782 
24783   /* "View.MemoryView":1227
24784  *
24785  *
24786  *     tmpslice.data = <char *> result             # <<<<<<<<<<<<<<
24787  *     tmpslice.memview = src.memview
24788  *     for i in range(ndim):
24789  */
24790   __pyx_v_tmpslice->data = ((char *)__pyx_v_result);
24791 
24792   /* "View.MemoryView":1228
24793  *
24794  *     tmpslice.data = <char *> result
24795  *     tmpslice.memview = src.memview             # <<<<<<<<<<<<<<
24796  *     for i in range(ndim):
24797  *         tmpslice.shape[i] = src.shape[i]
24798  */
24799   __pyx_t_4 = __pyx_v_src->memview;
24800   __pyx_v_tmpslice->memview = __pyx_t_4;
24801 
24802   /* "View.MemoryView":1229
24803  *     tmpslice.data = <char *> result
24804  *     tmpslice.memview = src.memview
24805  *     for i in range(ndim):             # <<<<<<<<<<<<<<
24806  *         tmpslice.shape[i] = src.shape[i]
24807  *         tmpslice.suboffsets[i] = -1
24808  */
24809   __pyx_t_3 = __pyx_v_ndim;
24810   __pyx_t_5 = __pyx_t_3;
24811   for (__pyx_t_6 = 0; __pyx_t_6 < __pyx_t_5; __pyx_t_6+=1) {
24812     __pyx_v_i = __pyx_t_6;
24813 
24814     /* "View.MemoryView":1230
24815  *     tmpslice.memview = src.memview
24816  *     for i in range(ndim):
24817  *         tmpslice.shape[i] = src.shape[i]             # <<<<<<<<<<<<<<
24818  *         tmpslice.suboffsets[i] = -1
24819  *
24820  */
24821     (__pyx_v_tmpslice->shape[__pyx_v_i]) = (__pyx_v_src->shape[__pyx_v_i]);
24822 
24823     /* "View.MemoryView":1231
24824  *     for i in range(ndim):
24825  *         tmpslice.shape[i] = src.shape[i]
24826  *         tmpslice.suboffsets[i] = -1             # <<<<<<<<<<<<<<
24827  *
24828  *     fill_contig_strides_array(&tmpslice.shape[0], &tmpslice.strides[0], itemsize,
24829  */
24830     (__pyx_v_tmpslice->suboffsets[__pyx_v_i]) = -1L;
24831   }
24832 
24833   /* "View.MemoryView":1233
24834  *         tmpslice.suboffsets[i] = -1
24835  *
24836  *     fill_contig_strides_array(&tmpslice.shape[0], &tmpslice.strides[0], itemsize,             # <<<<<<<<<<<<<<
24837  *                               ndim, order)
24838  *
24839  */
24840   (void)(__pyx_fill_contig_strides_array((&(__pyx_v_tmpslice->shape[0])), (&(__pyx_v_tmpslice->strides[0])), __pyx_v_itemsize, __pyx_v_ndim, __pyx_v_order));
24841 
24842   /* "View.MemoryView":1237
24843  *
24844  *
24845  *     for i in range(ndim):             # <<<<<<<<<<<<<<
24846  *         if tmpslice.shape[i] == 1:
24847  *             tmpslice.strides[i] = 0
24848  */
24849   __pyx_t_3 = __pyx_v_ndim;
24850   __pyx_t_5 = __pyx_t_3;
24851   for (__pyx_t_6 = 0; __pyx_t_6 < __pyx_t_5; __pyx_t_6+=1) {
24852     __pyx_v_i = __pyx_t_6;
24853 
24854     /* "View.MemoryView":1238
24855  *
24856  *     for i in range(ndim):
24857  *         if tmpslice.shape[i] == 1:             # <<<<<<<<<<<<<<
24858  *             tmpslice.strides[i] = 0
24859  *
24860  */
24861     __pyx_t_2 = (((__pyx_v_tmpslice->shape[__pyx_v_i]) == 1) != 0);
24862     if (__pyx_t_2) {
24863 
24864       /* "View.MemoryView":1239
24865  *     for i in range(ndim):
24866  *         if tmpslice.shape[i] == 1:
24867  *             tmpslice.strides[i] = 0             # <<<<<<<<<<<<<<
24868  *
24869  *     if slice_is_contig(src[0], order, ndim):
24870  */
24871       (__pyx_v_tmpslice->strides[__pyx_v_i]) = 0;
24872 
24873       /* "View.MemoryView":1238
24874  *
24875  *     for i in range(ndim):
24876  *         if tmpslice.shape[i] == 1:             # <<<<<<<<<<<<<<
24877  *             tmpslice.strides[i] = 0
24878  *
24879  */
24880     }
24881   }
24882 
24883   /* "View.MemoryView":1241
24884  *             tmpslice.strides[i] = 0
24885  *
24886  *     if slice_is_contig(src[0], order, ndim):             # <<<<<<<<<<<<<<
24887  *         memcpy(result, src.data, size)
24888  *     else:
24889  */
24890   __pyx_t_2 = (__pyx_memviewslice_is_contig((__pyx_v_src[0]), __pyx_v_order, __pyx_v_ndim) != 0);
24891   if (__pyx_t_2) {
24892 
24893     /* "View.MemoryView":1242
24894  *
24895  *     if slice_is_contig(src[0], order, ndim):
24896  *         memcpy(result, src.data, size)             # <<<<<<<<<<<<<<
24897  *     else:
24898  *         copy_strided_to_strided(src, tmpslice, ndim, itemsize)
24899  */
24900     (void)(memcpy(__pyx_v_result, __pyx_v_src->data, __pyx_v_size));
24901 
24902     /* "View.MemoryView":1241
24903  *             tmpslice.strides[i] = 0
24904  *
24905  *     if slice_is_contig(src[0], order, ndim):             # <<<<<<<<<<<<<<
24906  *         memcpy(result, src.data, size)
24907  *     else:
24908  */
24909     goto __pyx_L9;
24910   }
24911 
24912   /* "View.MemoryView":1244
24913  *         memcpy(result, src.data, size)
24914  *     else:
24915  *         copy_strided_to_strided(src, tmpslice, ndim, itemsize)             # <<<<<<<<<<<<<<
24916  *
24917  *     return result
24918  */
24919   /*else*/ {
24920     copy_strided_to_strided(__pyx_v_src, __pyx_v_tmpslice, __pyx_v_ndim, __pyx_v_itemsize);
24921   }
24922   __pyx_L9:;
24923 
24924   /* "View.MemoryView":1246
24925  *         copy_strided_to_strided(src, tmpslice, ndim, itemsize)
24926  *
24927  *     return result             # <<<<<<<<<<<<<<
24928  *
24929  *
24930  */
24931   __pyx_r = __pyx_v_result;
24932   goto __pyx_L0;
24933 
24934   /* "View.MemoryView":1208
24935  *
24936  * @cname('__pyx_memoryview_copy_data_to_temp')
24937  * cdef void *copy_data_to_temp(__Pyx_memviewslice *src,             # <<<<<<<<<<<<<<
24938  *                              __Pyx_memviewslice *tmpslice,
24939  *                              char order,
24940  */
24941 
24942   /* function exit code */
24943   __pyx_L1_error:;
24944   {
24945     #ifdef WITH_THREAD
24946     PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure();
24947     #endif
24948     __Pyx_AddTraceback("View.MemoryView.copy_data_to_temp", __pyx_clineno, __pyx_lineno, __pyx_filename);
24949     #ifdef WITH_THREAD
24950     __Pyx_PyGILState_Release(__pyx_gilstate_save);
24951     #endif
24952   }
24953   __pyx_r = NULL;
24954   __pyx_L0:;
24955   return __pyx_r;
24956 }
24957 
24958 /* "View.MemoryView":1251
24959  *
24960  * @cname('__pyx_memoryview_err_extents')
24961  * cdef int _err_extents(int i, Py_ssize_t extent1,             # <<<<<<<<<<<<<<
24962  *                              Py_ssize_t extent2) except -1 with gil:
24963  *     raise ValueError("got differing extents in dimension %d (got %d and %d)" %
24964  */
24965 
__pyx_memoryview_err_extents(int __pyx_v_i,Py_ssize_t __pyx_v_extent1,Py_ssize_t __pyx_v_extent2)24966 static int __pyx_memoryview_err_extents(int __pyx_v_i, Py_ssize_t __pyx_v_extent1, Py_ssize_t __pyx_v_extent2) {
24967   int __pyx_r;
24968   __Pyx_RefNannyDeclarations
24969   PyObject *__pyx_t_1 = NULL;
24970   PyObject *__pyx_t_2 = NULL;
24971   PyObject *__pyx_t_3 = NULL;
24972   PyObject *__pyx_t_4 = NULL;
24973   int __pyx_lineno = 0;
24974   const char *__pyx_filename = NULL;
24975   int __pyx_clineno = 0;
24976   #ifdef WITH_THREAD
24977   PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure();
24978   #endif
24979   __Pyx_RefNannySetupContext("_err_extents", 0);
24980 
24981   /* "View.MemoryView":1254
24982  *                              Py_ssize_t extent2) except -1 with gil:
24983  *     raise ValueError("got differing extents in dimension %d (got %d and %d)" %
24984  *                                                         (i, extent1, extent2))             # <<<<<<<<<<<<<<
24985  *
24986  * @cname('__pyx_memoryview_err_dim')
24987  */
24988   __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_i); if (unlikely(!__pyx_t_1)) __PYX_ERR(3, 1254, __pyx_L1_error)
24989   __Pyx_GOTREF(__pyx_t_1);
24990   __pyx_t_2 = PyInt_FromSsize_t(__pyx_v_extent1); if (unlikely(!__pyx_t_2)) __PYX_ERR(3, 1254, __pyx_L1_error)
24991   __Pyx_GOTREF(__pyx_t_2);
24992   __pyx_t_3 = PyInt_FromSsize_t(__pyx_v_extent2); if (unlikely(!__pyx_t_3)) __PYX_ERR(3, 1254, __pyx_L1_error)
24993   __Pyx_GOTREF(__pyx_t_3);
24994   __pyx_t_4 = PyTuple_New(3); if (unlikely(!__pyx_t_4)) __PYX_ERR(3, 1254, __pyx_L1_error)
24995   __Pyx_GOTREF(__pyx_t_4);
24996   __Pyx_GIVEREF(__pyx_t_1);
24997   PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_1);
24998   __Pyx_GIVEREF(__pyx_t_2);
24999   PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_2);
25000   __Pyx_GIVEREF(__pyx_t_3);
25001   PyTuple_SET_ITEM(__pyx_t_4, 2, __pyx_t_3);
25002   __pyx_t_1 = 0;
25003   __pyx_t_2 = 0;
25004   __pyx_t_3 = 0;
25005 
25006   /* "View.MemoryView":1253
25007  * cdef int _err_extents(int i, Py_ssize_t extent1,
25008  *                              Py_ssize_t extent2) except -1 with gil:
25009  *     raise ValueError("got differing extents in dimension %d (got %d and %d)" %             # <<<<<<<<<<<<<<
25010  *                                                         (i, extent1, extent2))
25011  *
25012  */
25013   __pyx_t_3 = __Pyx_PyString_Format(__pyx_kp_s_got_differing_extents_in_dimensi, __pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(3, 1253, __pyx_L1_error)
25014   __Pyx_GOTREF(__pyx_t_3);
25015   __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
25016   __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_builtin_ValueError, __pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(3, 1253, __pyx_L1_error)
25017   __Pyx_GOTREF(__pyx_t_4);
25018   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
25019   __Pyx_Raise(__pyx_t_4, 0, 0, 0);
25020   __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
25021   __PYX_ERR(3, 1253, __pyx_L1_error)
25022 
25023   /* "View.MemoryView":1251
25024  *
25025  * @cname('__pyx_memoryview_err_extents')
25026  * cdef int _err_extents(int i, Py_ssize_t extent1,             # <<<<<<<<<<<<<<
25027  *                              Py_ssize_t extent2) except -1 with gil:
25028  *     raise ValueError("got differing extents in dimension %d (got %d and %d)" %
25029  */
25030 
25031   /* function exit code */
25032   __pyx_L1_error:;
25033   __Pyx_XDECREF(__pyx_t_1);
25034   __Pyx_XDECREF(__pyx_t_2);
25035   __Pyx_XDECREF(__pyx_t_3);
25036   __Pyx_XDECREF(__pyx_t_4);
25037   __Pyx_AddTraceback("View.MemoryView._err_extents", __pyx_clineno, __pyx_lineno, __pyx_filename);
25038   __pyx_r = -1;
25039   __Pyx_RefNannyFinishContext();
25040   #ifdef WITH_THREAD
25041   __Pyx_PyGILState_Release(__pyx_gilstate_save);
25042   #endif
25043   return __pyx_r;
25044 }
25045 
25046 /* "View.MemoryView":1257
25047  *
25048  * @cname('__pyx_memoryview_err_dim')
25049  * cdef int _err_dim(object error, char *msg, int dim) except -1 with gil:             # <<<<<<<<<<<<<<
25050  *     raise error(msg.decode('ascii') % dim)
25051  *
25052  */
25053 
__pyx_memoryview_err_dim(PyObject * __pyx_v_error,char * __pyx_v_msg,int __pyx_v_dim)25054 static int __pyx_memoryview_err_dim(PyObject *__pyx_v_error, char *__pyx_v_msg, int __pyx_v_dim) {
25055   int __pyx_r;
25056   __Pyx_RefNannyDeclarations
25057   PyObject *__pyx_t_1 = NULL;
25058   PyObject *__pyx_t_2 = NULL;
25059   PyObject *__pyx_t_3 = NULL;
25060   PyObject *__pyx_t_4 = NULL;
25061   int __pyx_lineno = 0;
25062   const char *__pyx_filename = NULL;
25063   int __pyx_clineno = 0;
25064   #ifdef WITH_THREAD
25065   PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure();
25066   #endif
25067   __Pyx_RefNannySetupContext("_err_dim", 0);
25068   __Pyx_INCREF(__pyx_v_error);
25069 
25070   /* "View.MemoryView":1258
25071  * @cname('__pyx_memoryview_err_dim')
25072  * cdef int _err_dim(object error, char *msg, int dim) except -1 with gil:
25073  *     raise error(msg.decode('ascii') % dim)             # <<<<<<<<<<<<<<
25074  *
25075  * @cname('__pyx_memoryview_err')
25076  */
25077   __pyx_t_2 = __Pyx_decode_c_string(__pyx_v_msg, 0, strlen(__pyx_v_msg), NULL, NULL, PyUnicode_DecodeASCII); if (unlikely(!__pyx_t_2)) __PYX_ERR(3, 1258, __pyx_L1_error)
25078   __Pyx_GOTREF(__pyx_t_2);
25079   __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_dim); if (unlikely(!__pyx_t_3)) __PYX_ERR(3, 1258, __pyx_L1_error)
25080   __Pyx_GOTREF(__pyx_t_3);
25081   __pyx_t_4 = PyUnicode_Format(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(3, 1258, __pyx_L1_error)
25082   __Pyx_GOTREF(__pyx_t_4);
25083   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
25084   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
25085   __Pyx_INCREF(__pyx_v_error);
25086   __pyx_t_3 = __pyx_v_error; __pyx_t_2 = NULL;
25087   if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
25088     __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3);
25089     if (likely(__pyx_t_2)) {
25090       PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
25091       __Pyx_INCREF(__pyx_t_2);
25092       __Pyx_INCREF(function);
25093       __Pyx_DECREF_SET(__pyx_t_3, function);
25094     }
25095   }
25096   __pyx_t_1 = (__pyx_t_2) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_2, __pyx_t_4) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4);
25097   __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
25098   __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
25099   if (unlikely(!__pyx_t_1)) __PYX_ERR(3, 1258, __pyx_L1_error)
25100   __Pyx_GOTREF(__pyx_t_1);
25101   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
25102   __Pyx_Raise(__pyx_t_1, 0, 0, 0);
25103   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
25104   __PYX_ERR(3, 1258, __pyx_L1_error)
25105 
25106   /* "View.MemoryView":1257
25107  *
25108  * @cname('__pyx_memoryview_err_dim')
25109  * cdef int _err_dim(object error, char *msg, int dim) except -1 with gil:             # <<<<<<<<<<<<<<
25110  *     raise error(msg.decode('ascii') % dim)
25111  *
25112  */
25113 
25114   /* function exit code */
25115   __pyx_L1_error:;
25116   __Pyx_XDECREF(__pyx_t_1);
25117   __Pyx_XDECREF(__pyx_t_2);
25118   __Pyx_XDECREF(__pyx_t_3);
25119   __Pyx_XDECREF(__pyx_t_4);
25120   __Pyx_AddTraceback("View.MemoryView._err_dim", __pyx_clineno, __pyx_lineno, __pyx_filename);
25121   __pyx_r = -1;
25122   __Pyx_XDECREF(__pyx_v_error);
25123   __Pyx_RefNannyFinishContext();
25124   #ifdef WITH_THREAD
25125   __Pyx_PyGILState_Release(__pyx_gilstate_save);
25126   #endif
25127   return __pyx_r;
25128 }
25129 
25130 /* "View.MemoryView":1261
25131  *
25132  * @cname('__pyx_memoryview_err')
25133  * cdef int _err(object error, char *msg) except -1 with gil:             # <<<<<<<<<<<<<<
25134  *     if msg != NULL:
25135  *         raise error(msg.decode('ascii'))
25136  */
25137 
__pyx_memoryview_err(PyObject * __pyx_v_error,char * __pyx_v_msg)25138 static int __pyx_memoryview_err(PyObject *__pyx_v_error, char *__pyx_v_msg) {
25139   int __pyx_r;
25140   __Pyx_RefNannyDeclarations
25141   int __pyx_t_1;
25142   PyObject *__pyx_t_2 = NULL;
25143   PyObject *__pyx_t_3 = NULL;
25144   PyObject *__pyx_t_4 = NULL;
25145   PyObject *__pyx_t_5 = NULL;
25146   int __pyx_lineno = 0;
25147   const char *__pyx_filename = NULL;
25148   int __pyx_clineno = 0;
25149   #ifdef WITH_THREAD
25150   PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure();
25151   #endif
25152   __Pyx_RefNannySetupContext("_err", 0);
25153   __Pyx_INCREF(__pyx_v_error);
25154 
25155   /* "View.MemoryView":1262
25156  * @cname('__pyx_memoryview_err')
25157  * cdef int _err(object error, char *msg) except -1 with gil:
25158  *     if msg != NULL:             # <<<<<<<<<<<<<<
25159  *         raise error(msg.decode('ascii'))
25160  *     else:
25161  */
25162   __pyx_t_1 = ((__pyx_v_msg != NULL) != 0);
25163   if (unlikely(__pyx_t_1)) {
25164 
25165     /* "View.MemoryView":1263
25166  * cdef int _err(object error, char *msg) except -1 with gil:
25167  *     if msg != NULL:
25168  *         raise error(msg.decode('ascii'))             # <<<<<<<<<<<<<<
25169  *     else:
25170  *         raise error
25171  */
25172     __pyx_t_3 = __Pyx_decode_c_string(__pyx_v_msg, 0, strlen(__pyx_v_msg), NULL, NULL, PyUnicode_DecodeASCII); if (unlikely(!__pyx_t_3)) __PYX_ERR(3, 1263, __pyx_L1_error)
25173     __Pyx_GOTREF(__pyx_t_3);
25174     __Pyx_INCREF(__pyx_v_error);
25175     __pyx_t_4 = __pyx_v_error; __pyx_t_5 = NULL;
25176     if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_4))) {
25177       __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4);
25178       if (likely(__pyx_t_5)) {
25179         PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
25180         __Pyx_INCREF(__pyx_t_5);
25181         __Pyx_INCREF(function);
25182         __Pyx_DECREF_SET(__pyx_t_4, function);
25183       }
25184     }
25185     __pyx_t_2 = (__pyx_t_5) ? __Pyx_PyObject_Call2Args(__pyx_t_4, __pyx_t_5, __pyx_t_3) : __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_3);
25186     __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
25187     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
25188     if (unlikely(!__pyx_t_2)) __PYX_ERR(3, 1263, __pyx_L1_error)
25189     __Pyx_GOTREF(__pyx_t_2);
25190     __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
25191     __Pyx_Raise(__pyx_t_2, 0, 0, 0);
25192     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
25193     __PYX_ERR(3, 1263, __pyx_L1_error)
25194 
25195     /* "View.MemoryView":1262
25196  * @cname('__pyx_memoryview_err')
25197  * cdef int _err(object error, char *msg) except -1 with gil:
25198  *     if msg != NULL:             # <<<<<<<<<<<<<<
25199  *         raise error(msg.decode('ascii'))
25200  *     else:
25201  */
25202   }
25203 
25204   /* "View.MemoryView":1265
25205  *         raise error(msg.decode('ascii'))
25206  *     else:
25207  *         raise error             # <<<<<<<<<<<<<<
25208  *
25209  * @cname('__pyx_memoryview_copy_contents')
25210  */
25211   /*else*/ {
25212     __Pyx_Raise(__pyx_v_error, 0, 0, 0);
25213     __PYX_ERR(3, 1265, __pyx_L1_error)
25214   }
25215 
25216   /* "View.MemoryView":1261
25217  *
25218  * @cname('__pyx_memoryview_err')
25219  * cdef int _err(object error, char *msg) except -1 with gil:             # <<<<<<<<<<<<<<
25220  *     if msg != NULL:
25221  *         raise error(msg.decode('ascii'))
25222  */
25223 
25224   /* function exit code */
25225   __pyx_L1_error:;
25226   __Pyx_XDECREF(__pyx_t_2);
25227   __Pyx_XDECREF(__pyx_t_3);
25228   __Pyx_XDECREF(__pyx_t_4);
25229   __Pyx_XDECREF(__pyx_t_5);
25230   __Pyx_AddTraceback("View.MemoryView._err", __pyx_clineno, __pyx_lineno, __pyx_filename);
25231   __pyx_r = -1;
25232   __Pyx_XDECREF(__pyx_v_error);
25233   __Pyx_RefNannyFinishContext();
25234   #ifdef WITH_THREAD
25235   __Pyx_PyGILState_Release(__pyx_gilstate_save);
25236   #endif
25237   return __pyx_r;
25238 }
25239 
25240 /* "View.MemoryView":1268
25241  *
25242  * @cname('__pyx_memoryview_copy_contents')
25243  * cdef int memoryview_copy_contents(__Pyx_memviewslice src,             # <<<<<<<<<<<<<<
25244  *                                   __Pyx_memviewslice dst,
25245  *                                   int src_ndim, int dst_ndim,
25246  */
25247 
__pyx_memoryview_copy_contents(__Pyx_memviewslice __pyx_v_src,__Pyx_memviewslice __pyx_v_dst,int __pyx_v_src_ndim,int __pyx_v_dst_ndim,int __pyx_v_dtype_is_object)25248 static int __pyx_memoryview_copy_contents(__Pyx_memviewslice __pyx_v_src, __Pyx_memviewslice __pyx_v_dst, int __pyx_v_src_ndim, int __pyx_v_dst_ndim, int __pyx_v_dtype_is_object) {
25249   void *__pyx_v_tmpdata;
25250   size_t __pyx_v_itemsize;
25251   int __pyx_v_i;
25252   char __pyx_v_order;
25253   int __pyx_v_broadcasting;
25254   int __pyx_v_direct_copy;
25255   __Pyx_memviewslice __pyx_v_tmp;
25256   int __pyx_v_ndim;
25257   int __pyx_r;
25258   Py_ssize_t __pyx_t_1;
25259   int __pyx_t_2;
25260   int __pyx_t_3;
25261   int __pyx_t_4;
25262   int __pyx_t_5;
25263   int __pyx_t_6;
25264   void *__pyx_t_7;
25265   int __pyx_t_8;
25266   int __pyx_lineno = 0;
25267   const char *__pyx_filename = NULL;
25268   int __pyx_clineno = 0;
25269 
25270   /* "View.MemoryView":1276
25271  *     Check for overlapping memory and verify the shapes.
25272  *     """
25273  *     cdef void *tmpdata = NULL             # <<<<<<<<<<<<<<
25274  *     cdef size_t itemsize = src.memview.view.itemsize
25275  *     cdef int i
25276  */
25277   __pyx_v_tmpdata = NULL;
25278 
25279   /* "View.MemoryView":1277
25280  *     """
25281  *     cdef void *tmpdata = NULL
25282  *     cdef size_t itemsize = src.memview.view.itemsize             # <<<<<<<<<<<<<<
25283  *     cdef int i
25284  *     cdef char order = get_best_order(&src, src_ndim)
25285  */
25286   __pyx_t_1 = __pyx_v_src.memview->view.itemsize;
25287   __pyx_v_itemsize = __pyx_t_1;
25288 
25289   /* "View.MemoryView":1279
25290  *     cdef size_t itemsize = src.memview.view.itemsize
25291  *     cdef int i
25292  *     cdef char order = get_best_order(&src, src_ndim)             # <<<<<<<<<<<<<<
25293  *     cdef bint broadcasting = False
25294  *     cdef bint direct_copy = False
25295  */
25296   __pyx_v_order = __pyx_get_best_slice_order((&__pyx_v_src), __pyx_v_src_ndim);
25297 
25298   /* "View.MemoryView":1280
25299  *     cdef int i
25300  *     cdef char order = get_best_order(&src, src_ndim)
25301  *     cdef bint broadcasting = False             # <<<<<<<<<<<<<<
25302  *     cdef bint direct_copy = False
25303  *     cdef __Pyx_memviewslice tmp
25304  */
25305   __pyx_v_broadcasting = 0;
25306 
25307   /* "View.MemoryView":1281
25308  *     cdef char order = get_best_order(&src, src_ndim)
25309  *     cdef bint broadcasting = False
25310  *     cdef bint direct_copy = False             # <<<<<<<<<<<<<<
25311  *     cdef __Pyx_memviewslice tmp
25312  *
25313  */
25314   __pyx_v_direct_copy = 0;
25315 
25316   /* "View.MemoryView":1284
25317  *     cdef __Pyx_memviewslice tmp
25318  *
25319  *     if src_ndim < dst_ndim:             # <<<<<<<<<<<<<<
25320  *         broadcast_leading(&src, src_ndim, dst_ndim)
25321  *     elif dst_ndim < src_ndim:
25322  */
25323   __pyx_t_2 = ((__pyx_v_src_ndim < __pyx_v_dst_ndim) != 0);
25324   if (__pyx_t_2) {
25325 
25326     /* "View.MemoryView":1285
25327  *
25328  *     if src_ndim < dst_ndim:
25329  *         broadcast_leading(&src, src_ndim, dst_ndim)             # <<<<<<<<<<<<<<
25330  *     elif dst_ndim < src_ndim:
25331  *         broadcast_leading(&dst, dst_ndim, src_ndim)
25332  */
25333     __pyx_memoryview_broadcast_leading((&__pyx_v_src), __pyx_v_src_ndim, __pyx_v_dst_ndim);
25334 
25335     /* "View.MemoryView":1284
25336  *     cdef __Pyx_memviewslice tmp
25337  *
25338  *     if src_ndim < dst_ndim:             # <<<<<<<<<<<<<<
25339  *         broadcast_leading(&src, src_ndim, dst_ndim)
25340  *     elif dst_ndim < src_ndim:
25341  */
25342     goto __pyx_L3;
25343   }
25344 
25345   /* "View.MemoryView":1286
25346  *     if src_ndim < dst_ndim:
25347  *         broadcast_leading(&src, src_ndim, dst_ndim)
25348  *     elif dst_ndim < src_ndim:             # <<<<<<<<<<<<<<
25349  *         broadcast_leading(&dst, dst_ndim, src_ndim)
25350  *
25351  */
25352   __pyx_t_2 = ((__pyx_v_dst_ndim < __pyx_v_src_ndim) != 0);
25353   if (__pyx_t_2) {
25354 
25355     /* "View.MemoryView":1287
25356  *         broadcast_leading(&src, src_ndim, dst_ndim)
25357  *     elif dst_ndim < src_ndim:
25358  *         broadcast_leading(&dst, dst_ndim, src_ndim)             # <<<<<<<<<<<<<<
25359  *
25360  *     cdef int ndim = max(src_ndim, dst_ndim)
25361  */
25362     __pyx_memoryview_broadcast_leading((&__pyx_v_dst), __pyx_v_dst_ndim, __pyx_v_src_ndim);
25363 
25364     /* "View.MemoryView":1286
25365  *     if src_ndim < dst_ndim:
25366  *         broadcast_leading(&src, src_ndim, dst_ndim)
25367  *     elif dst_ndim < src_ndim:             # <<<<<<<<<<<<<<
25368  *         broadcast_leading(&dst, dst_ndim, src_ndim)
25369  *
25370  */
25371   }
25372   __pyx_L3:;
25373 
25374   /* "View.MemoryView":1289
25375  *         broadcast_leading(&dst, dst_ndim, src_ndim)
25376  *
25377  *     cdef int ndim = max(src_ndim, dst_ndim)             # <<<<<<<<<<<<<<
25378  *
25379  *     for i in range(ndim):
25380  */
25381   __pyx_t_3 = __pyx_v_dst_ndim;
25382   __pyx_t_4 = __pyx_v_src_ndim;
25383   if (((__pyx_t_3 > __pyx_t_4) != 0)) {
25384     __pyx_t_5 = __pyx_t_3;
25385   } else {
25386     __pyx_t_5 = __pyx_t_4;
25387   }
25388   __pyx_v_ndim = __pyx_t_5;
25389 
25390   /* "View.MemoryView":1291
25391  *     cdef int ndim = max(src_ndim, dst_ndim)
25392  *
25393  *     for i in range(ndim):             # <<<<<<<<<<<<<<
25394  *         if src.shape[i] != dst.shape[i]:
25395  *             if src.shape[i] == 1:
25396  */
25397   __pyx_t_5 = __pyx_v_ndim;
25398   __pyx_t_3 = __pyx_t_5;
25399   for (__pyx_t_4 = 0; __pyx_t_4 < __pyx_t_3; __pyx_t_4+=1) {
25400     __pyx_v_i = __pyx_t_4;
25401 
25402     /* "View.MemoryView":1292
25403  *
25404  *     for i in range(ndim):
25405  *         if src.shape[i] != dst.shape[i]:             # <<<<<<<<<<<<<<
25406  *             if src.shape[i] == 1:
25407  *                 broadcasting = True
25408  */
25409     __pyx_t_2 = (((__pyx_v_src.shape[__pyx_v_i]) != (__pyx_v_dst.shape[__pyx_v_i])) != 0);
25410     if (__pyx_t_2) {
25411 
25412       /* "View.MemoryView":1293
25413  *     for i in range(ndim):
25414  *         if src.shape[i] != dst.shape[i]:
25415  *             if src.shape[i] == 1:             # <<<<<<<<<<<<<<
25416  *                 broadcasting = True
25417  *                 src.strides[i] = 0
25418  */
25419       __pyx_t_2 = (((__pyx_v_src.shape[__pyx_v_i]) == 1) != 0);
25420       if (__pyx_t_2) {
25421 
25422         /* "View.MemoryView":1294
25423  *         if src.shape[i] != dst.shape[i]:
25424  *             if src.shape[i] == 1:
25425  *                 broadcasting = True             # <<<<<<<<<<<<<<
25426  *                 src.strides[i] = 0
25427  *             else:
25428  */
25429         __pyx_v_broadcasting = 1;
25430 
25431         /* "View.MemoryView":1295
25432  *             if src.shape[i] == 1:
25433  *                 broadcasting = True
25434  *                 src.strides[i] = 0             # <<<<<<<<<<<<<<
25435  *             else:
25436  *                 _err_extents(i, dst.shape[i], src.shape[i])
25437  */
25438         (__pyx_v_src.strides[__pyx_v_i]) = 0;
25439 
25440         /* "View.MemoryView":1293
25441  *     for i in range(ndim):
25442  *         if src.shape[i] != dst.shape[i]:
25443  *             if src.shape[i] == 1:             # <<<<<<<<<<<<<<
25444  *                 broadcasting = True
25445  *                 src.strides[i] = 0
25446  */
25447         goto __pyx_L7;
25448       }
25449 
25450       /* "View.MemoryView":1297
25451  *                 src.strides[i] = 0
25452  *             else:
25453  *                 _err_extents(i, dst.shape[i], src.shape[i])             # <<<<<<<<<<<<<<
25454  *
25455  *         if src.suboffsets[i] >= 0:
25456  */
25457       /*else*/ {
25458         __pyx_t_6 = __pyx_memoryview_err_extents(__pyx_v_i, (__pyx_v_dst.shape[__pyx_v_i]), (__pyx_v_src.shape[__pyx_v_i])); if (unlikely(__pyx_t_6 == ((int)-1))) __PYX_ERR(3, 1297, __pyx_L1_error)
25459       }
25460       __pyx_L7:;
25461 
25462       /* "View.MemoryView":1292
25463  *
25464  *     for i in range(ndim):
25465  *         if src.shape[i] != dst.shape[i]:             # <<<<<<<<<<<<<<
25466  *             if src.shape[i] == 1:
25467  *                 broadcasting = True
25468  */
25469     }
25470 
25471     /* "View.MemoryView":1299
25472  *                 _err_extents(i, dst.shape[i], src.shape[i])
25473  *
25474  *         if src.suboffsets[i] >= 0:             # <<<<<<<<<<<<<<
25475  *             _err_dim(ValueError, "Dimension %d is not direct", i)
25476  *
25477  */
25478     __pyx_t_2 = (((__pyx_v_src.suboffsets[__pyx_v_i]) >= 0) != 0);
25479     if (__pyx_t_2) {
25480 
25481       /* "View.MemoryView":1300
25482  *
25483  *         if src.suboffsets[i] >= 0:
25484  *             _err_dim(ValueError, "Dimension %d is not direct", i)             # <<<<<<<<<<<<<<
25485  *
25486  *     if slices_overlap(&src, &dst, ndim, itemsize):
25487  */
25488       __pyx_t_6 = __pyx_memoryview_err_dim(__pyx_builtin_ValueError, ((char *)"Dimension %d is not direct"), __pyx_v_i); if (unlikely(__pyx_t_6 == ((int)-1))) __PYX_ERR(3, 1300, __pyx_L1_error)
25489 
25490       /* "View.MemoryView":1299
25491  *                 _err_extents(i, dst.shape[i], src.shape[i])
25492  *
25493  *         if src.suboffsets[i] >= 0:             # <<<<<<<<<<<<<<
25494  *             _err_dim(ValueError, "Dimension %d is not direct", i)
25495  *
25496  */
25497     }
25498   }
25499 
25500   /* "View.MemoryView":1302
25501  *             _err_dim(ValueError, "Dimension %d is not direct", i)
25502  *
25503  *     if slices_overlap(&src, &dst, ndim, itemsize):             # <<<<<<<<<<<<<<
25504  *
25505  *         if not slice_is_contig(src, order, ndim):
25506  */
25507   __pyx_t_2 = (__pyx_slices_overlap((&__pyx_v_src), (&__pyx_v_dst), __pyx_v_ndim, __pyx_v_itemsize) != 0);
25508   if (__pyx_t_2) {
25509 
25510     /* "View.MemoryView":1304
25511  *     if slices_overlap(&src, &dst, ndim, itemsize):
25512  *
25513  *         if not slice_is_contig(src, order, ndim):             # <<<<<<<<<<<<<<
25514  *             order = get_best_order(&dst, ndim)
25515  *
25516  */
25517     __pyx_t_2 = ((!(__pyx_memviewslice_is_contig(__pyx_v_src, __pyx_v_order, __pyx_v_ndim) != 0)) != 0);
25518     if (__pyx_t_2) {
25519 
25520       /* "View.MemoryView":1305
25521  *
25522  *         if not slice_is_contig(src, order, ndim):
25523  *             order = get_best_order(&dst, ndim)             # <<<<<<<<<<<<<<
25524  *
25525  *         tmpdata = copy_data_to_temp(&src, &tmp, order, ndim)
25526  */
25527       __pyx_v_order = __pyx_get_best_slice_order((&__pyx_v_dst), __pyx_v_ndim);
25528 
25529       /* "View.MemoryView":1304
25530  *     if slices_overlap(&src, &dst, ndim, itemsize):
25531  *
25532  *         if not slice_is_contig(src, order, ndim):             # <<<<<<<<<<<<<<
25533  *             order = get_best_order(&dst, ndim)
25534  *
25535  */
25536     }
25537 
25538     /* "View.MemoryView":1307
25539  *             order = get_best_order(&dst, ndim)
25540  *
25541  *         tmpdata = copy_data_to_temp(&src, &tmp, order, ndim)             # <<<<<<<<<<<<<<
25542  *         src = tmp
25543  *
25544  */
25545     __pyx_t_7 = __pyx_memoryview_copy_data_to_temp((&__pyx_v_src), (&__pyx_v_tmp), __pyx_v_order, __pyx_v_ndim); if (unlikely(__pyx_t_7 == ((void *)NULL))) __PYX_ERR(3, 1307, __pyx_L1_error)
25546     __pyx_v_tmpdata = __pyx_t_7;
25547 
25548     /* "View.MemoryView":1308
25549  *
25550  *         tmpdata = copy_data_to_temp(&src, &tmp, order, ndim)
25551  *         src = tmp             # <<<<<<<<<<<<<<
25552  *
25553  *     if not broadcasting:
25554  */
25555     __pyx_v_src = __pyx_v_tmp;
25556 
25557     /* "View.MemoryView":1302
25558  *             _err_dim(ValueError, "Dimension %d is not direct", i)
25559  *
25560  *     if slices_overlap(&src, &dst, ndim, itemsize):             # <<<<<<<<<<<<<<
25561  *
25562  *         if not slice_is_contig(src, order, ndim):
25563  */
25564   }
25565 
25566   /* "View.MemoryView":1310
25567  *         src = tmp
25568  *
25569  *     if not broadcasting:             # <<<<<<<<<<<<<<
25570  *
25571  *
25572  */
25573   __pyx_t_2 = ((!(__pyx_v_broadcasting != 0)) != 0);
25574   if (__pyx_t_2) {
25575 
25576     /* "View.MemoryView":1313
25577  *
25578  *
25579  *         if slice_is_contig(src, 'C', ndim):             # <<<<<<<<<<<<<<
25580  *             direct_copy = slice_is_contig(dst, 'C', ndim)
25581  *         elif slice_is_contig(src, 'F', ndim):
25582  */
25583     __pyx_t_2 = (__pyx_memviewslice_is_contig(__pyx_v_src, 'C', __pyx_v_ndim) != 0);
25584     if (__pyx_t_2) {
25585 
25586       /* "View.MemoryView":1314
25587  *
25588  *         if slice_is_contig(src, 'C', ndim):
25589  *             direct_copy = slice_is_contig(dst, 'C', ndim)             # <<<<<<<<<<<<<<
25590  *         elif slice_is_contig(src, 'F', ndim):
25591  *             direct_copy = slice_is_contig(dst, 'F', ndim)
25592  */
25593       __pyx_v_direct_copy = __pyx_memviewslice_is_contig(__pyx_v_dst, 'C', __pyx_v_ndim);
25594 
25595       /* "View.MemoryView":1313
25596  *
25597  *
25598  *         if slice_is_contig(src, 'C', ndim):             # <<<<<<<<<<<<<<
25599  *             direct_copy = slice_is_contig(dst, 'C', ndim)
25600  *         elif slice_is_contig(src, 'F', ndim):
25601  */
25602       goto __pyx_L12;
25603     }
25604 
25605     /* "View.MemoryView":1315
25606  *         if slice_is_contig(src, 'C', ndim):
25607  *             direct_copy = slice_is_contig(dst, 'C', ndim)
25608  *         elif slice_is_contig(src, 'F', ndim):             # <<<<<<<<<<<<<<
25609  *             direct_copy = slice_is_contig(dst, 'F', ndim)
25610  *
25611  */
25612     __pyx_t_2 = (__pyx_memviewslice_is_contig(__pyx_v_src, 'F', __pyx_v_ndim) != 0);
25613     if (__pyx_t_2) {
25614 
25615       /* "View.MemoryView":1316
25616  *             direct_copy = slice_is_contig(dst, 'C', ndim)
25617  *         elif slice_is_contig(src, 'F', ndim):
25618  *             direct_copy = slice_is_contig(dst, 'F', ndim)             # <<<<<<<<<<<<<<
25619  *
25620  *         if direct_copy:
25621  */
25622       __pyx_v_direct_copy = __pyx_memviewslice_is_contig(__pyx_v_dst, 'F', __pyx_v_ndim);
25623 
25624       /* "View.MemoryView":1315
25625  *         if slice_is_contig(src, 'C', ndim):
25626  *             direct_copy = slice_is_contig(dst, 'C', ndim)
25627  *         elif slice_is_contig(src, 'F', ndim):             # <<<<<<<<<<<<<<
25628  *             direct_copy = slice_is_contig(dst, 'F', ndim)
25629  *
25630  */
25631     }
25632     __pyx_L12:;
25633 
25634     /* "View.MemoryView":1318
25635  *             direct_copy = slice_is_contig(dst, 'F', ndim)
25636  *
25637  *         if direct_copy:             # <<<<<<<<<<<<<<
25638  *
25639  *             refcount_copying(&dst, dtype_is_object, ndim, False)
25640  */
25641     __pyx_t_2 = (__pyx_v_direct_copy != 0);
25642     if (__pyx_t_2) {
25643 
25644       /* "View.MemoryView":1320
25645  *         if direct_copy:
25646  *
25647  *             refcount_copying(&dst, dtype_is_object, ndim, False)             # <<<<<<<<<<<<<<
25648  *             memcpy(dst.data, src.data, slice_get_size(&src, ndim))
25649  *             refcount_copying(&dst, dtype_is_object, ndim, True)
25650  */
25651       __pyx_memoryview_refcount_copying((&__pyx_v_dst), __pyx_v_dtype_is_object, __pyx_v_ndim, 0);
25652 
25653       /* "View.MemoryView":1321
25654  *
25655  *             refcount_copying(&dst, dtype_is_object, ndim, False)
25656  *             memcpy(dst.data, src.data, slice_get_size(&src, ndim))             # <<<<<<<<<<<<<<
25657  *             refcount_copying(&dst, dtype_is_object, ndim, True)
25658  *             free(tmpdata)
25659  */
25660       (void)(memcpy(__pyx_v_dst.data, __pyx_v_src.data, __pyx_memoryview_slice_get_size((&__pyx_v_src), __pyx_v_ndim)));
25661 
25662       /* "View.MemoryView":1322
25663  *             refcount_copying(&dst, dtype_is_object, ndim, False)
25664  *             memcpy(dst.data, src.data, slice_get_size(&src, ndim))
25665  *             refcount_copying(&dst, dtype_is_object, ndim, True)             # <<<<<<<<<<<<<<
25666  *             free(tmpdata)
25667  *             return 0
25668  */
25669       __pyx_memoryview_refcount_copying((&__pyx_v_dst), __pyx_v_dtype_is_object, __pyx_v_ndim, 1);
25670 
25671       /* "View.MemoryView":1323
25672  *             memcpy(dst.data, src.data, slice_get_size(&src, ndim))
25673  *             refcount_copying(&dst, dtype_is_object, ndim, True)
25674  *             free(tmpdata)             # <<<<<<<<<<<<<<
25675  *             return 0
25676  *
25677  */
25678       free(__pyx_v_tmpdata);
25679 
25680       /* "View.MemoryView":1324
25681  *             refcount_copying(&dst, dtype_is_object, ndim, True)
25682  *             free(tmpdata)
25683  *             return 0             # <<<<<<<<<<<<<<
25684  *
25685  *     if order == 'F' == get_best_order(&dst, ndim):
25686  */
25687       __pyx_r = 0;
25688       goto __pyx_L0;
25689 
25690       /* "View.MemoryView":1318
25691  *             direct_copy = slice_is_contig(dst, 'F', ndim)
25692  *
25693  *         if direct_copy:             # <<<<<<<<<<<<<<
25694  *
25695  *             refcount_copying(&dst, dtype_is_object, ndim, False)
25696  */
25697     }
25698 
25699     /* "View.MemoryView":1310
25700  *         src = tmp
25701  *
25702  *     if not broadcasting:             # <<<<<<<<<<<<<<
25703  *
25704  *
25705  */
25706   }
25707 
25708   /* "View.MemoryView":1326
25709  *             return 0
25710  *
25711  *     if order == 'F' == get_best_order(&dst, ndim):             # <<<<<<<<<<<<<<
25712  *
25713  *
25714  */
25715   __pyx_t_2 = (__pyx_v_order == 'F');
25716   if (__pyx_t_2) {
25717     __pyx_t_2 = ('F' == __pyx_get_best_slice_order((&__pyx_v_dst), __pyx_v_ndim));
25718   }
25719   __pyx_t_8 = (__pyx_t_2 != 0);
25720   if (__pyx_t_8) {
25721 
25722     /* "View.MemoryView":1329
25723  *
25724  *
25725  *         transpose_memslice(&src)             # <<<<<<<<<<<<<<
25726  *         transpose_memslice(&dst)
25727  *
25728  */
25729     __pyx_t_5 = __pyx_memslice_transpose((&__pyx_v_src)); if (unlikely(__pyx_t_5 == ((int)0))) __PYX_ERR(3, 1329, __pyx_L1_error)
25730 
25731     /* "View.MemoryView":1330
25732  *
25733  *         transpose_memslice(&src)
25734  *         transpose_memslice(&dst)             # <<<<<<<<<<<<<<
25735  *
25736  *     refcount_copying(&dst, dtype_is_object, ndim, False)
25737  */
25738     __pyx_t_5 = __pyx_memslice_transpose((&__pyx_v_dst)); if (unlikely(__pyx_t_5 == ((int)0))) __PYX_ERR(3, 1330, __pyx_L1_error)
25739 
25740     /* "View.MemoryView":1326
25741  *             return 0
25742  *
25743  *     if order == 'F' == get_best_order(&dst, ndim):             # <<<<<<<<<<<<<<
25744  *
25745  *
25746  */
25747   }
25748 
25749   /* "View.MemoryView":1332
25750  *         transpose_memslice(&dst)
25751  *
25752  *     refcount_copying(&dst, dtype_is_object, ndim, False)             # <<<<<<<<<<<<<<
25753  *     copy_strided_to_strided(&src, &dst, ndim, itemsize)
25754  *     refcount_copying(&dst, dtype_is_object, ndim, True)
25755  */
25756   __pyx_memoryview_refcount_copying((&__pyx_v_dst), __pyx_v_dtype_is_object, __pyx_v_ndim, 0);
25757 
25758   /* "View.MemoryView":1333
25759  *
25760  *     refcount_copying(&dst, dtype_is_object, ndim, False)
25761  *     copy_strided_to_strided(&src, &dst, ndim, itemsize)             # <<<<<<<<<<<<<<
25762  *     refcount_copying(&dst, dtype_is_object, ndim, True)
25763  *
25764  */
25765   copy_strided_to_strided((&__pyx_v_src), (&__pyx_v_dst), __pyx_v_ndim, __pyx_v_itemsize);
25766 
25767   /* "View.MemoryView":1334
25768  *     refcount_copying(&dst, dtype_is_object, ndim, False)
25769  *     copy_strided_to_strided(&src, &dst, ndim, itemsize)
25770  *     refcount_copying(&dst, dtype_is_object, ndim, True)             # <<<<<<<<<<<<<<
25771  *
25772  *     free(tmpdata)
25773  */
25774   __pyx_memoryview_refcount_copying((&__pyx_v_dst), __pyx_v_dtype_is_object, __pyx_v_ndim, 1);
25775 
25776   /* "View.MemoryView":1336
25777  *     refcount_copying(&dst, dtype_is_object, ndim, True)
25778  *
25779  *     free(tmpdata)             # <<<<<<<<<<<<<<
25780  *     return 0
25781  *
25782  */
25783   free(__pyx_v_tmpdata);
25784 
25785   /* "View.MemoryView":1337
25786  *
25787  *     free(tmpdata)
25788  *     return 0             # <<<<<<<<<<<<<<
25789  *
25790  * @cname('__pyx_memoryview_broadcast_leading')
25791  */
25792   __pyx_r = 0;
25793   goto __pyx_L0;
25794 
25795   /* "View.MemoryView":1268
25796  *
25797  * @cname('__pyx_memoryview_copy_contents')
25798  * cdef int memoryview_copy_contents(__Pyx_memviewslice src,             # <<<<<<<<<<<<<<
25799  *                                   __Pyx_memviewslice dst,
25800  *                                   int src_ndim, int dst_ndim,
25801  */
25802 
25803   /* function exit code */
25804   __pyx_L1_error:;
25805   {
25806     #ifdef WITH_THREAD
25807     PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure();
25808     #endif
25809     __Pyx_AddTraceback("View.MemoryView.memoryview_copy_contents", __pyx_clineno, __pyx_lineno, __pyx_filename);
25810     #ifdef WITH_THREAD
25811     __Pyx_PyGILState_Release(__pyx_gilstate_save);
25812     #endif
25813   }
25814   __pyx_r = -1;
25815   __pyx_L0:;
25816   return __pyx_r;
25817 }
25818 
25819 /* "View.MemoryView":1340
25820  *
25821  * @cname('__pyx_memoryview_broadcast_leading')
25822  * cdef void broadcast_leading(__Pyx_memviewslice *mslice,             # <<<<<<<<<<<<<<
25823  *                             int ndim,
25824  *                             int ndim_other) nogil:
25825  */
25826 
__pyx_memoryview_broadcast_leading(__Pyx_memviewslice * __pyx_v_mslice,int __pyx_v_ndim,int __pyx_v_ndim_other)25827 static void __pyx_memoryview_broadcast_leading(__Pyx_memviewslice *__pyx_v_mslice, int __pyx_v_ndim, int __pyx_v_ndim_other) {
25828   int __pyx_v_i;
25829   int __pyx_v_offset;
25830   int __pyx_t_1;
25831   int __pyx_t_2;
25832   int __pyx_t_3;
25833 
25834   /* "View.MemoryView":1344
25835  *                             int ndim_other) nogil:
25836  *     cdef int i
25837  *     cdef int offset = ndim_other - ndim             # <<<<<<<<<<<<<<
25838  *
25839  *     for i in range(ndim - 1, -1, -1):
25840  */
25841   __pyx_v_offset = (__pyx_v_ndim_other - __pyx_v_ndim);
25842 
25843   /* "View.MemoryView":1346
25844  *     cdef int offset = ndim_other - ndim
25845  *
25846  *     for i in range(ndim - 1, -1, -1):             # <<<<<<<<<<<<<<
25847  *         mslice.shape[i + offset] = mslice.shape[i]
25848  *         mslice.strides[i + offset] = mslice.strides[i]
25849  */
25850   for (__pyx_t_1 = (__pyx_v_ndim - 1); __pyx_t_1 > -1; __pyx_t_1-=1) {
25851     __pyx_v_i = __pyx_t_1;
25852 
25853     /* "View.MemoryView":1347
25854  *
25855  *     for i in range(ndim - 1, -1, -1):
25856  *         mslice.shape[i + offset] = mslice.shape[i]             # <<<<<<<<<<<<<<
25857  *         mslice.strides[i + offset] = mslice.strides[i]
25858  *         mslice.suboffsets[i + offset] = mslice.suboffsets[i]
25859  */
25860     (__pyx_v_mslice->shape[(__pyx_v_i + __pyx_v_offset)]) = (__pyx_v_mslice->shape[__pyx_v_i]);
25861 
25862     /* "View.MemoryView":1348
25863  *     for i in range(ndim - 1, -1, -1):
25864  *         mslice.shape[i + offset] = mslice.shape[i]
25865  *         mslice.strides[i + offset] = mslice.strides[i]             # <<<<<<<<<<<<<<
25866  *         mslice.suboffsets[i + offset] = mslice.suboffsets[i]
25867  *
25868  */
25869     (__pyx_v_mslice->strides[(__pyx_v_i + __pyx_v_offset)]) = (__pyx_v_mslice->strides[__pyx_v_i]);
25870 
25871     /* "View.MemoryView":1349
25872  *         mslice.shape[i + offset] = mslice.shape[i]
25873  *         mslice.strides[i + offset] = mslice.strides[i]
25874  *         mslice.suboffsets[i + offset] = mslice.suboffsets[i]             # <<<<<<<<<<<<<<
25875  *
25876  *     for i in range(offset):
25877  */
25878     (__pyx_v_mslice->suboffsets[(__pyx_v_i + __pyx_v_offset)]) = (__pyx_v_mslice->suboffsets[__pyx_v_i]);
25879   }
25880 
25881   /* "View.MemoryView":1351
25882  *         mslice.suboffsets[i + offset] = mslice.suboffsets[i]
25883  *
25884  *     for i in range(offset):             # <<<<<<<<<<<<<<
25885  *         mslice.shape[i] = 1
25886  *         mslice.strides[i] = mslice.strides[0]
25887  */
25888   __pyx_t_1 = __pyx_v_offset;
25889   __pyx_t_2 = __pyx_t_1;
25890   for (__pyx_t_3 = 0; __pyx_t_3 < __pyx_t_2; __pyx_t_3+=1) {
25891     __pyx_v_i = __pyx_t_3;
25892 
25893     /* "View.MemoryView":1352
25894  *
25895  *     for i in range(offset):
25896  *         mslice.shape[i] = 1             # <<<<<<<<<<<<<<
25897  *         mslice.strides[i] = mslice.strides[0]
25898  *         mslice.suboffsets[i] = -1
25899  */
25900     (__pyx_v_mslice->shape[__pyx_v_i]) = 1;
25901 
25902     /* "View.MemoryView":1353
25903  *     for i in range(offset):
25904  *         mslice.shape[i] = 1
25905  *         mslice.strides[i] = mslice.strides[0]             # <<<<<<<<<<<<<<
25906  *         mslice.suboffsets[i] = -1
25907  *
25908  */
25909     (__pyx_v_mslice->strides[__pyx_v_i]) = (__pyx_v_mslice->strides[0]);
25910 
25911     /* "View.MemoryView":1354
25912  *         mslice.shape[i] = 1
25913  *         mslice.strides[i] = mslice.strides[0]
25914  *         mslice.suboffsets[i] = -1             # <<<<<<<<<<<<<<
25915  *
25916  *
25917  */
25918     (__pyx_v_mslice->suboffsets[__pyx_v_i]) = -1L;
25919   }
25920 
25921   /* "View.MemoryView":1340
25922  *
25923  * @cname('__pyx_memoryview_broadcast_leading')
25924  * cdef void broadcast_leading(__Pyx_memviewslice *mslice,             # <<<<<<<<<<<<<<
25925  *                             int ndim,
25926  *                             int ndim_other) nogil:
25927  */
25928 
25929   /* function exit code */
25930 }
25931 
25932 /* "View.MemoryView":1362
25933  *
25934  * @cname('__pyx_memoryview_refcount_copying')
25935  * cdef void refcount_copying(__Pyx_memviewslice *dst, bint dtype_is_object,             # <<<<<<<<<<<<<<
25936  *                            int ndim, bint inc) nogil:
25937  *
25938  */
25939 
__pyx_memoryview_refcount_copying(__Pyx_memviewslice * __pyx_v_dst,int __pyx_v_dtype_is_object,int __pyx_v_ndim,int __pyx_v_inc)25940 static void __pyx_memoryview_refcount_copying(__Pyx_memviewslice *__pyx_v_dst, int __pyx_v_dtype_is_object, int __pyx_v_ndim, int __pyx_v_inc) {
25941   int __pyx_t_1;
25942 
25943   /* "View.MemoryView":1366
25944  *
25945  *
25946  *     if dtype_is_object:             # <<<<<<<<<<<<<<
25947  *         refcount_objects_in_slice_with_gil(dst.data, dst.shape,
25948  *                                            dst.strides, ndim, inc)
25949  */
25950   __pyx_t_1 = (__pyx_v_dtype_is_object != 0);
25951   if (__pyx_t_1) {
25952 
25953     /* "View.MemoryView":1367
25954  *
25955  *     if dtype_is_object:
25956  *         refcount_objects_in_slice_with_gil(dst.data, dst.shape,             # <<<<<<<<<<<<<<
25957  *                                            dst.strides, ndim, inc)
25958  *
25959  */
25960     __pyx_memoryview_refcount_objects_in_slice_with_gil(__pyx_v_dst->data, __pyx_v_dst->shape, __pyx_v_dst->strides, __pyx_v_ndim, __pyx_v_inc);
25961 
25962     /* "View.MemoryView":1366
25963  *
25964  *
25965  *     if dtype_is_object:             # <<<<<<<<<<<<<<
25966  *         refcount_objects_in_slice_with_gil(dst.data, dst.shape,
25967  *                                            dst.strides, ndim, inc)
25968  */
25969   }
25970 
25971   /* "View.MemoryView":1362
25972  *
25973  * @cname('__pyx_memoryview_refcount_copying')
25974  * cdef void refcount_copying(__Pyx_memviewslice *dst, bint dtype_is_object,             # <<<<<<<<<<<<<<
25975  *                            int ndim, bint inc) nogil:
25976  *
25977  */
25978 
25979   /* function exit code */
25980 }
25981 
25982 /* "View.MemoryView":1371
25983  *
25984  * @cname('__pyx_memoryview_refcount_objects_in_slice_with_gil')
25985  * cdef void refcount_objects_in_slice_with_gil(char *data, Py_ssize_t *shape,             # <<<<<<<<<<<<<<
25986  *                                              Py_ssize_t *strides, int ndim,
25987  *                                              bint inc) with gil:
25988  */
25989 
__pyx_memoryview_refcount_objects_in_slice_with_gil(char * __pyx_v_data,Py_ssize_t * __pyx_v_shape,Py_ssize_t * __pyx_v_strides,int __pyx_v_ndim,int __pyx_v_inc)25990 static void __pyx_memoryview_refcount_objects_in_slice_with_gil(char *__pyx_v_data, Py_ssize_t *__pyx_v_shape, Py_ssize_t *__pyx_v_strides, int __pyx_v_ndim, int __pyx_v_inc) {
25991   __Pyx_RefNannyDeclarations
25992   #ifdef WITH_THREAD
25993   PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure();
25994   #endif
25995   __Pyx_RefNannySetupContext("refcount_objects_in_slice_with_gil", 0);
25996 
25997   /* "View.MemoryView":1374
25998  *                                              Py_ssize_t *strides, int ndim,
25999  *                                              bint inc) with gil:
26000  *     refcount_objects_in_slice(data, shape, strides, ndim, inc)             # <<<<<<<<<<<<<<
26001  *
26002  * @cname('__pyx_memoryview_refcount_objects_in_slice')
26003  */
26004   __pyx_memoryview_refcount_objects_in_slice(__pyx_v_data, __pyx_v_shape, __pyx_v_strides, __pyx_v_ndim, __pyx_v_inc);
26005 
26006   /* "View.MemoryView":1371
26007  *
26008  * @cname('__pyx_memoryview_refcount_objects_in_slice_with_gil')
26009  * cdef void refcount_objects_in_slice_with_gil(char *data, Py_ssize_t *shape,             # <<<<<<<<<<<<<<
26010  *                                              Py_ssize_t *strides, int ndim,
26011  *                                              bint inc) with gil:
26012  */
26013 
26014   /* function exit code */
26015   __Pyx_RefNannyFinishContext();
26016   #ifdef WITH_THREAD
26017   __Pyx_PyGILState_Release(__pyx_gilstate_save);
26018   #endif
26019 }
26020 
26021 /* "View.MemoryView":1377
26022  *
26023  * @cname('__pyx_memoryview_refcount_objects_in_slice')
26024  * cdef void refcount_objects_in_slice(char *data, Py_ssize_t *shape,             # <<<<<<<<<<<<<<
26025  *                                     Py_ssize_t *strides, int ndim, bint inc):
26026  *     cdef Py_ssize_t i
26027  */
26028 
__pyx_memoryview_refcount_objects_in_slice(char * __pyx_v_data,Py_ssize_t * __pyx_v_shape,Py_ssize_t * __pyx_v_strides,int __pyx_v_ndim,int __pyx_v_inc)26029 static void __pyx_memoryview_refcount_objects_in_slice(char *__pyx_v_data, Py_ssize_t *__pyx_v_shape, Py_ssize_t *__pyx_v_strides, int __pyx_v_ndim, int __pyx_v_inc) {
26030   CYTHON_UNUSED Py_ssize_t __pyx_v_i;
26031   __Pyx_RefNannyDeclarations
26032   Py_ssize_t __pyx_t_1;
26033   Py_ssize_t __pyx_t_2;
26034   Py_ssize_t __pyx_t_3;
26035   int __pyx_t_4;
26036   __Pyx_RefNannySetupContext("refcount_objects_in_slice", 0);
26037 
26038   /* "View.MemoryView":1381
26039  *     cdef Py_ssize_t i
26040  *
26041  *     for i in range(shape[0]):             # <<<<<<<<<<<<<<
26042  *         if ndim == 1:
26043  *             if inc:
26044  */
26045   __pyx_t_1 = (__pyx_v_shape[0]);
26046   __pyx_t_2 = __pyx_t_1;
26047   for (__pyx_t_3 = 0; __pyx_t_3 < __pyx_t_2; __pyx_t_3+=1) {
26048     __pyx_v_i = __pyx_t_3;
26049 
26050     /* "View.MemoryView":1382
26051  *
26052  *     for i in range(shape[0]):
26053  *         if ndim == 1:             # <<<<<<<<<<<<<<
26054  *             if inc:
26055  *                 Py_INCREF((<PyObject **> data)[0])
26056  */
26057     __pyx_t_4 = ((__pyx_v_ndim == 1) != 0);
26058     if (__pyx_t_4) {
26059 
26060       /* "View.MemoryView":1383
26061  *     for i in range(shape[0]):
26062  *         if ndim == 1:
26063  *             if inc:             # <<<<<<<<<<<<<<
26064  *                 Py_INCREF((<PyObject **> data)[0])
26065  *             else:
26066  */
26067       __pyx_t_4 = (__pyx_v_inc != 0);
26068       if (__pyx_t_4) {
26069 
26070         /* "View.MemoryView":1384
26071  *         if ndim == 1:
26072  *             if inc:
26073  *                 Py_INCREF((<PyObject **> data)[0])             # <<<<<<<<<<<<<<
26074  *             else:
26075  *                 Py_DECREF((<PyObject **> data)[0])
26076  */
26077         Py_INCREF((((PyObject **)__pyx_v_data)[0]));
26078 
26079         /* "View.MemoryView":1383
26080  *     for i in range(shape[0]):
26081  *         if ndim == 1:
26082  *             if inc:             # <<<<<<<<<<<<<<
26083  *                 Py_INCREF((<PyObject **> data)[0])
26084  *             else:
26085  */
26086         goto __pyx_L6;
26087       }
26088 
26089       /* "View.MemoryView":1386
26090  *                 Py_INCREF((<PyObject **> data)[0])
26091  *             else:
26092  *                 Py_DECREF((<PyObject **> data)[0])             # <<<<<<<<<<<<<<
26093  *         else:
26094  *             refcount_objects_in_slice(data, shape + 1, strides + 1,
26095  */
26096       /*else*/ {
26097         Py_DECREF((((PyObject **)__pyx_v_data)[0]));
26098       }
26099       __pyx_L6:;
26100 
26101       /* "View.MemoryView":1382
26102  *
26103  *     for i in range(shape[0]):
26104  *         if ndim == 1:             # <<<<<<<<<<<<<<
26105  *             if inc:
26106  *                 Py_INCREF((<PyObject **> data)[0])
26107  */
26108       goto __pyx_L5;
26109     }
26110 
26111     /* "View.MemoryView":1388
26112  *                 Py_DECREF((<PyObject **> data)[0])
26113  *         else:
26114  *             refcount_objects_in_slice(data, shape + 1, strides + 1,             # <<<<<<<<<<<<<<
26115  *                                       ndim - 1, inc)
26116  *
26117  */
26118     /*else*/ {
26119 
26120       /* "View.MemoryView":1389
26121  *         else:
26122  *             refcount_objects_in_slice(data, shape + 1, strides + 1,
26123  *                                       ndim - 1, inc)             # <<<<<<<<<<<<<<
26124  *
26125  *         data += strides[0]
26126  */
26127       __pyx_memoryview_refcount_objects_in_slice(__pyx_v_data, (__pyx_v_shape + 1), (__pyx_v_strides + 1), (__pyx_v_ndim - 1), __pyx_v_inc);
26128     }
26129     __pyx_L5:;
26130 
26131     /* "View.MemoryView":1391
26132  *                                       ndim - 1, inc)
26133  *
26134  *         data += strides[0]             # <<<<<<<<<<<<<<
26135  *
26136  *
26137  */
26138     __pyx_v_data = (__pyx_v_data + (__pyx_v_strides[0]));
26139   }
26140 
26141   /* "View.MemoryView":1377
26142  *
26143  * @cname('__pyx_memoryview_refcount_objects_in_slice')
26144  * cdef void refcount_objects_in_slice(char *data, Py_ssize_t *shape,             # <<<<<<<<<<<<<<
26145  *                                     Py_ssize_t *strides, int ndim, bint inc):
26146  *     cdef Py_ssize_t i
26147  */
26148 
26149   /* function exit code */
26150   __Pyx_RefNannyFinishContext();
26151 }
26152 
26153 /* "View.MemoryView":1397
26154  *
26155  * @cname('__pyx_memoryview_slice_assign_scalar')
26156  * cdef void slice_assign_scalar(__Pyx_memviewslice *dst, int ndim,             # <<<<<<<<<<<<<<
26157  *                               size_t itemsize, void *item,
26158  *                               bint dtype_is_object) nogil:
26159  */
26160 
__pyx_memoryview_slice_assign_scalar(__Pyx_memviewslice * __pyx_v_dst,int __pyx_v_ndim,size_t __pyx_v_itemsize,void * __pyx_v_item,int __pyx_v_dtype_is_object)26161 static void __pyx_memoryview_slice_assign_scalar(__Pyx_memviewslice *__pyx_v_dst, int __pyx_v_ndim, size_t __pyx_v_itemsize, void *__pyx_v_item, int __pyx_v_dtype_is_object) {
26162 
26163   /* "View.MemoryView":1400
26164  *                               size_t itemsize, void *item,
26165  *                               bint dtype_is_object) nogil:
26166  *     refcount_copying(dst, dtype_is_object, ndim, False)             # <<<<<<<<<<<<<<
26167  *     _slice_assign_scalar(dst.data, dst.shape, dst.strides, ndim,
26168  *                          itemsize, item)
26169  */
26170   __pyx_memoryview_refcount_copying(__pyx_v_dst, __pyx_v_dtype_is_object, __pyx_v_ndim, 0);
26171 
26172   /* "View.MemoryView":1401
26173  *                               bint dtype_is_object) nogil:
26174  *     refcount_copying(dst, dtype_is_object, ndim, False)
26175  *     _slice_assign_scalar(dst.data, dst.shape, dst.strides, ndim,             # <<<<<<<<<<<<<<
26176  *                          itemsize, item)
26177  *     refcount_copying(dst, dtype_is_object, ndim, True)
26178  */
26179   __pyx_memoryview__slice_assign_scalar(__pyx_v_dst->data, __pyx_v_dst->shape, __pyx_v_dst->strides, __pyx_v_ndim, __pyx_v_itemsize, __pyx_v_item);
26180 
26181   /* "View.MemoryView":1403
26182  *     _slice_assign_scalar(dst.data, dst.shape, dst.strides, ndim,
26183  *                          itemsize, item)
26184  *     refcount_copying(dst, dtype_is_object, ndim, True)             # <<<<<<<<<<<<<<
26185  *
26186  *
26187  */
26188   __pyx_memoryview_refcount_copying(__pyx_v_dst, __pyx_v_dtype_is_object, __pyx_v_ndim, 1);
26189 
26190   /* "View.MemoryView":1397
26191  *
26192  * @cname('__pyx_memoryview_slice_assign_scalar')
26193  * cdef void slice_assign_scalar(__Pyx_memviewslice *dst, int ndim,             # <<<<<<<<<<<<<<
26194  *                               size_t itemsize, void *item,
26195  *                               bint dtype_is_object) nogil:
26196  */
26197 
26198   /* function exit code */
26199 }
26200 
26201 /* "View.MemoryView":1407
26202  *
26203  * @cname('__pyx_memoryview__slice_assign_scalar')
26204  * cdef void _slice_assign_scalar(char *data, Py_ssize_t *shape,             # <<<<<<<<<<<<<<
26205  *                               Py_ssize_t *strides, int ndim,
26206  *                               size_t itemsize, void *item) nogil:
26207  */
26208 
__pyx_memoryview__slice_assign_scalar(char * __pyx_v_data,Py_ssize_t * __pyx_v_shape,Py_ssize_t * __pyx_v_strides,int __pyx_v_ndim,size_t __pyx_v_itemsize,void * __pyx_v_item)26209 static void __pyx_memoryview__slice_assign_scalar(char *__pyx_v_data, Py_ssize_t *__pyx_v_shape, Py_ssize_t *__pyx_v_strides, int __pyx_v_ndim, size_t __pyx_v_itemsize, void *__pyx_v_item) {
26210   CYTHON_UNUSED Py_ssize_t __pyx_v_i;
26211   Py_ssize_t __pyx_v_stride;
26212   Py_ssize_t __pyx_v_extent;
26213   int __pyx_t_1;
26214   Py_ssize_t __pyx_t_2;
26215   Py_ssize_t __pyx_t_3;
26216   Py_ssize_t __pyx_t_4;
26217 
26218   /* "View.MemoryView":1411
26219  *                               size_t itemsize, void *item) nogil:
26220  *     cdef Py_ssize_t i
26221  *     cdef Py_ssize_t stride = strides[0]             # <<<<<<<<<<<<<<
26222  *     cdef Py_ssize_t extent = shape[0]
26223  *
26224  */
26225   __pyx_v_stride = (__pyx_v_strides[0]);
26226 
26227   /* "View.MemoryView":1412
26228  *     cdef Py_ssize_t i
26229  *     cdef Py_ssize_t stride = strides[0]
26230  *     cdef Py_ssize_t extent = shape[0]             # <<<<<<<<<<<<<<
26231  *
26232  *     if ndim == 1:
26233  */
26234   __pyx_v_extent = (__pyx_v_shape[0]);
26235 
26236   /* "View.MemoryView":1414
26237  *     cdef Py_ssize_t extent = shape[0]
26238  *
26239  *     if ndim == 1:             # <<<<<<<<<<<<<<
26240  *         for i in range(extent):
26241  *             memcpy(data, item, itemsize)
26242  */
26243   __pyx_t_1 = ((__pyx_v_ndim == 1) != 0);
26244   if (__pyx_t_1) {
26245 
26246     /* "View.MemoryView":1415
26247  *
26248  *     if ndim == 1:
26249  *         for i in range(extent):             # <<<<<<<<<<<<<<
26250  *             memcpy(data, item, itemsize)
26251  *             data += stride
26252  */
26253     __pyx_t_2 = __pyx_v_extent;
26254     __pyx_t_3 = __pyx_t_2;
26255     for (__pyx_t_4 = 0; __pyx_t_4 < __pyx_t_3; __pyx_t_4+=1) {
26256       __pyx_v_i = __pyx_t_4;
26257 
26258       /* "View.MemoryView":1416
26259  *     if ndim == 1:
26260  *         for i in range(extent):
26261  *             memcpy(data, item, itemsize)             # <<<<<<<<<<<<<<
26262  *             data += stride
26263  *     else:
26264  */
26265       (void)(memcpy(__pyx_v_data, __pyx_v_item, __pyx_v_itemsize));
26266 
26267       /* "View.MemoryView":1417
26268  *         for i in range(extent):
26269  *             memcpy(data, item, itemsize)
26270  *             data += stride             # <<<<<<<<<<<<<<
26271  *     else:
26272  *         for i in range(extent):
26273  */
26274       __pyx_v_data = (__pyx_v_data + __pyx_v_stride);
26275     }
26276 
26277     /* "View.MemoryView":1414
26278  *     cdef Py_ssize_t extent = shape[0]
26279  *
26280  *     if ndim == 1:             # <<<<<<<<<<<<<<
26281  *         for i in range(extent):
26282  *             memcpy(data, item, itemsize)
26283  */
26284     goto __pyx_L3;
26285   }
26286 
26287   /* "View.MemoryView":1419
26288  *             data += stride
26289  *     else:
26290  *         for i in range(extent):             # <<<<<<<<<<<<<<
26291  *             _slice_assign_scalar(data, shape + 1, strides + 1,
26292  *                                 ndim - 1, itemsize, item)
26293  */
26294   /*else*/ {
26295     __pyx_t_2 = __pyx_v_extent;
26296     __pyx_t_3 = __pyx_t_2;
26297     for (__pyx_t_4 = 0; __pyx_t_4 < __pyx_t_3; __pyx_t_4+=1) {
26298       __pyx_v_i = __pyx_t_4;
26299 
26300       /* "View.MemoryView":1420
26301  *     else:
26302  *         for i in range(extent):
26303  *             _slice_assign_scalar(data, shape + 1, strides + 1,             # <<<<<<<<<<<<<<
26304  *                                 ndim - 1, itemsize, item)
26305  *             data += stride
26306  */
26307       __pyx_memoryview__slice_assign_scalar(__pyx_v_data, (__pyx_v_shape + 1), (__pyx_v_strides + 1), (__pyx_v_ndim - 1), __pyx_v_itemsize, __pyx_v_item);
26308 
26309       /* "View.MemoryView":1422
26310  *             _slice_assign_scalar(data, shape + 1, strides + 1,
26311  *                                 ndim - 1, itemsize, item)
26312  *             data += stride             # <<<<<<<<<<<<<<
26313  *
26314  *
26315  */
26316       __pyx_v_data = (__pyx_v_data + __pyx_v_stride);
26317     }
26318   }
26319   __pyx_L3:;
26320 
26321   /* "View.MemoryView":1407
26322  *
26323  * @cname('__pyx_memoryview__slice_assign_scalar')
26324  * cdef void _slice_assign_scalar(char *data, Py_ssize_t *shape,             # <<<<<<<<<<<<<<
26325  *                               Py_ssize_t *strides, int ndim,
26326  *                               size_t itemsize, void *item) nogil:
26327  */
26328 
26329   /* function exit code */
26330 }
26331 
26332 /* "(tree fragment)":1
26333  * def __pyx_unpickle_Enum(__pyx_type, long __pyx_checksum, __pyx_state):             # <<<<<<<<<<<<<<
26334  *     cdef object __pyx_PickleError
26335  *     cdef object __pyx_result
26336  */
26337 
26338 /* Python wrapper */
26339 static PyObject *__pyx_pw_15View_dot_MemoryView_1__pyx_unpickle_Enum(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
26340 static PyMethodDef __pyx_mdef_15View_dot_MemoryView_1__pyx_unpickle_Enum = {"__pyx_unpickle_Enum", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_15View_dot_MemoryView_1__pyx_unpickle_Enum, METH_VARARGS|METH_KEYWORDS, 0};
__pyx_pw_15View_dot_MemoryView_1__pyx_unpickle_Enum(PyObject * __pyx_self,PyObject * __pyx_args,PyObject * __pyx_kwds)26341 static PyObject *__pyx_pw_15View_dot_MemoryView_1__pyx_unpickle_Enum(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
26342   PyObject *__pyx_v___pyx_type = 0;
26343   long __pyx_v___pyx_checksum;
26344   PyObject *__pyx_v___pyx_state = 0;
26345   int __pyx_lineno = 0;
26346   const char *__pyx_filename = NULL;
26347   int __pyx_clineno = 0;
26348   PyObject *__pyx_r = 0;
26349   __Pyx_RefNannyDeclarations
26350   __Pyx_RefNannySetupContext("__pyx_unpickle_Enum (wrapper)", 0);
26351   {
26352     static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_pyx_type,&__pyx_n_s_pyx_checksum,&__pyx_n_s_pyx_state,0};
26353     PyObject* values[3] = {0,0,0};
26354     if (unlikely(__pyx_kwds)) {
26355       Py_ssize_t kw_args;
26356       const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
26357       switch (pos_args) {
26358         case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
26359         CYTHON_FALLTHROUGH;
26360         case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
26361         CYTHON_FALLTHROUGH;
26362         case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
26363         CYTHON_FALLTHROUGH;
26364         case  0: break;
26365         default: goto __pyx_L5_argtuple_error;
26366       }
26367       kw_args = PyDict_Size(__pyx_kwds);
26368       switch (pos_args) {
26369         case  0:
26370         if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_pyx_type)) != 0)) kw_args--;
26371         else goto __pyx_L5_argtuple_error;
26372         CYTHON_FALLTHROUGH;
26373         case  1:
26374         if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_pyx_checksum)) != 0)) kw_args--;
26375         else {
26376           __Pyx_RaiseArgtupleInvalid("__pyx_unpickle_Enum", 1, 3, 3, 1); __PYX_ERR(3, 1, __pyx_L3_error)
26377         }
26378         CYTHON_FALLTHROUGH;
26379         case  2:
26380         if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_pyx_state)) != 0)) kw_args--;
26381         else {
26382           __Pyx_RaiseArgtupleInvalid("__pyx_unpickle_Enum", 1, 3, 3, 2); __PYX_ERR(3, 1, __pyx_L3_error)
26383         }
26384       }
26385       if (unlikely(kw_args > 0)) {
26386         if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__pyx_unpickle_Enum") < 0)) __PYX_ERR(3, 1, __pyx_L3_error)
26387       }
26388     } else if (PyTuple_GET_SIZE(__pyx_args) != 3) {
26389       goto __pyx_L5_argtuple_error;
26390     } else {
26391       values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
26392       values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
26393       values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
26394     }
26395     __pyx_v___pyx_type = values[0];
26396     __pyx_v___pyx_checksum = __Pyx_PyInt_As_long(values[1]); if (unlikely((__pyx_v___pyx_checksum == (long)-1) && PyErr_Occurred())) __PYX_ERR(3, 1, __pyx_L3_error)
26397     __pyx_v___pyx_state = values[2];
26398   }
26399   goto __pyx_L4_argument_unpacking_done;
26400   __pyx_L5_argtuple_error:;
26401   __Pyx_RaiseArgtupleInvalid("__pyx_unpickle_Enum", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(3, 1, __pyx_L3_error)
26402   __pyx_L3_error:;
26403   __Pyx_AddTraceback("View.MemoryView.__pyx_unpickle_Enum", __pyx_clineno, __pyx_lineno, __pyx_filename);
26404   __Pyx_RefNannyFinishContext();
26405   return NULL;
26406   __pyx_L4_argument_unpacking_done:;
26407   __pyx_r = __pyx_pf_15View_dot_MemoryView___pyx_unpickle_Enum(__pyx_self, __pyx_v___pyx_type, __pyx_v___pyx_checksum, __pyx_v___pyx_state);
26408 
26409   /* function exit code */
26410   __Pyx_RefNannyFinishContext();
26411   return __pyx_r;
26412 }
26413 
__pyx_pf_15View_dot_MemoryView___pyx_unpickle_Enum(CYTHON_UNUSED PyObject * __pyx_self,PyObject * __pyx_v___pyx_type,long __pyx_v___pyx_checksum,PyObject * __pyx_v___pyx_state)26414 static PyObject *__pyx_pf_15View_dot_MemoryView___pyx_unpickle_Enum(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v___pyx_type, long __pyx_v___pyx_checksum, PyObject *__pyx_v___pyx_state) {
26415   PyObject *__pyx_v___pyx_PickleError = 0;
26416   PyObject *__pyx_v___pyx_result = 0;
26417   PyObject *__pyx_r = NULL;
26418   __Pyx_RefNannyDeclarations
26419   int __pyx_t_1;
26420   PyObject *__pyx_t_2 = NULL;
26421   PyObject *__pyx_t_3 = NULL;
26422   PyObject *__pyx_t_4 = NULL;
26423   PyObject *__pyx_t_5 = NULL;
26424   int __pyx_t_6;
26425   int __pyx_lineno = 0;
26426   const char *__pyx_filename = NULL;
26427   int __pyx_clineno = 0;
26428   __Pyx_RefNannySetupContext("__pyx_unpickle_Enum", 0);
26429 
26430   /* "(tree fragment)":4
26431  *     cdef object __pyx_PickleError
26432  *     cdef object __pyx_result
26433  *     if __pyx_checksum != 0xb068931:             # <<<<<<<<<<<<<<
26434  *         from pickle import PickleError as __pyx_PickleError
26435  *         raise __pyx_PickleError("Incompatible checksums (%s vs 0xb068931 = (name))" % __pyx_checksum)
26436  */
26437   __pyx_t_1 = ((__pyx_v___pyx_checksum != 0xb068931) != 0);
26438   if (__pyx_t_1) {
26439 
26440     /* "(tree fragment)":5
26441  *     cdef object __pyx_result
26442  *     if __pyx_checksum != 0xb068931:
26443  *         from pickle import PickleError as __pyx_PickleError             # <<<<<<<<<<<<<<
26444  *         raise __pyx_PickleError("Incompatible checksums (%s vs 0xb068931 = (name))" % __pyx_checksum)
26445  *     __pyx_result = Enum.__new__(__pyx_type)
26446  */
26447     __pyx_t_2 = PyList_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(3, 5, __pyx_L1_error)
26448     __Pyx_GOTREF(__pyx_t_2);
26449     __Pyx_INCREF(__pyx_n_s_PickleError);
26450     __Pyx_GIVEREF(__pyx_n_s_PickleError);
26451     PyList_SET_ITEM(__pyx_t_2, 0, __pyx_n_s_PickleError);
26452     __pyx_t_3 = __Pyx_Import(__pyx_n_s_pickle, __pyx_t_2, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(3, 5, __pyx_L1_error)
26453     __Pyx_GOTREF(__pyx_t_3);
26454     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
26455     __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_3, __pyx_n_s_PickleError); if (unlikely(!__pyx_t_2)) __PYX_ERR(3, 5, __pyx_L1_error)
26456     __Pyx_GOTREF(__pyx_t_2);
26457     __Pyx_INCREF(__pyx_t_2);
26458     __pyx_v___pyx_PickleError = __pyx_t_2;
26459     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
26460     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
26461 
26462     /* "(tree fragment)":6
26463  *     if __pyx_checksum != 0xb068931:
26464  *         from pickle import PickleError as __pyx_PickleError
26465  *         raise __pyx_PickleError("Incompatible checksums (%s vs 0xb068931 = (name))" % __pyx_checksum)             # <<<<<<<<<<<<<<
26466  *     __pyx_result = Enum.__new__(__pyx_type)
26467  *     if __pyx_state is not None:
26468  */
26469     __pyx_t_2 = __Pyx_PyInt_From_long(__pyx_v___pyx_checksum); if (unlikely(!__pyx_t_2)) __PYX_ERR(3, 6, __pyx_L1_error)
26470     __Pyx_GOTREF(__pyx_t_2);
26471     __pyx_t_4 = __Pyx_PyString_Format(__pyx_kp_s_Incompatible_checksums_s_vs_0xb0, __pyx_t_2); if (unlikely(!__pyx_t_4)) __PYX_ERR(3, 6, __pyx_L1_error)
26472     __Pyx_GOTREF(__pyx_t_4);
26473     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
26474     __Pyx_INCREF(__pyx_v___pyx_PickleError);
26475     __pyx_t_2 = __pyx_v___pyx_PickleError; __pyx_t_5 = NULL;
26476     if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) {
26477       __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_2);
26478       if (likely(__pyx_t_5)) {
26479         PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
26480         __Pyx_INCREF(__pyx_t_5);
26481         __Pyx_INCREF(function);
26482         __Pyx_DECREF_SET(__pyx_t_2, function);
26483       }
26484     }
26485     __pyx_t_3 = (__pyx_t_5) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_5, __pyx_t_4) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_4);
26486     __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
26487     __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
26488     if (unlikely(!__pyx_t_3)) __PYX_ERR(3, 6, __pyx_L1_error)
26489     __Pyx_GOTREF(__pyx_t_3);
26490     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
26491     __Pyx_Raise(__pyx_t_3, 0, 0, 0);
26492     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
26493     __PYX_ERR(3, 6, __pyx_L1_error)
26494 
26495     /* "(tree fragment)":4
26496  *     cdef object __pyx_PickleError
26497  *     cdef object __pyx_result
26498  *     if __pyx_checksum != 0xb068931:             # <<<<<<<<<<<<<<
26499  *         from pickle import PickleError as __pyx_PickleError
26500  *         raise __pyx_PickleError("Incompatible checksums (%s vs 0xb068931 = (name))" % __pyx_checksum)
26501  */
26502   }
26503 
26504   /* "(tree fragment)":7
26505  *         from pickle import PickleError as __pyx_PickleError
26506  *         raise __pyx_PickleError("Incompatible checksums (%s vs 0xb068931 = (name))" % __pyx_checksum)
26507  *     __pyx_result = Enum.__new__(__pyx_type)             # <<<<<<<<<<<<<<
26508  *     if __pyx_state is not None:
26509  *         __pyx_unpickle_Enum__set_state(<Enum> __pyx_result, __pyx_state)
26510  */
26511   __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_MemviewEnum_type), __pyx_n_s_new); if (unlikely(!__pyx_t_2)) __PYX_ERR(3, 7, __pyx_L1_error)
26512   __Pyx_GOTREF(__pyx_t_2);
26513   __pyx_t_4 = NULL;
26514   if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
26515     __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_2);
26516     if (likely(__pyx_t_4)) {
26517       PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
26518       __Pyx_INCREF(__pyx_t_4);
26519       __Pyx_INCREF(function);
26520       __Pyx_DECREF_SET(__pyx_t_2, function);
26521     }
26522   }
26523   __pyx_t_3 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_4, __pyx_v___pyx_type) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_v___pyx_type);
26524   __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
26525   if (unlikely(!__pyx_t_3)) __PYX_ERR(3, 7, __pyx_L1_error)
26526   __Pyx_GOTREF(__pyx_t_3);
26527   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
26528   __pyx_v___pyx_result = __pyx_t_3;
26529   __pyx_t_3 = 0;
26530 
26531   /* "(tree fragment)":8
26532  *         raise __pyx_PickleError("Incompatible checksums (%s vs 0xb068931 = (name))" % __pyx_checksum)
26533  *     __pyx_result = Enum.__new__(__pyx_type)
26534  *     if __pyx_state is not None:             # <<<<<<<<<<<<<<
26535  *         __pyx_unpickle_Enum__set_state(<Enum> __pyx_result, __pyx_state)
26536  *     return __pyx_result
26537  */
26538   __pyx_t_1 = (__pyx_v___pyx_state != Py_None);
26539   __pyx_t_6 = (__pyx_t_1 != 0);
26540   if (__pyx_t_6) {
26541 
26542     /* "(tree fragment)":9
26543  *     __pyx_result = Enum.__new__(__pyx_type)
26544  *     if __pyx_state is not None:
26545  *         __pyx_unpickle_Enum__set_state(<Enum> __pyx_result, __pyx_state)             # <<<<<<<<<<<<<<
26546  *     return __pyx_result
26547  * cdef __pyx_unpickle_Enum__set_state(Enum __pyx_result, tuple __pyx_state):
26548  */
26549     if (!(likely(PyTuple_CheckExact(__pyx_v___pyx_state))||((__pyx_v___pyx_state) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_v___pyx_state)->tp_name), 0))) __PYX_ERR(3, 9, __pyx_L1_error)
26550     __pyx_t_3 = __pyx_unpickle_Enum__set_state(((struct __pyx_MemviewEnum_obj *)__pyx_v___pyx_result), ((PyObject*)__pyx_v___pyx_state)); if (unlikely(!__pyx_t_3)) __PYX_ERR(3, 9, __pyx_L1_error)
26551     __Pyx_GOTREF(__pyx_t_3);
26552     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
26553 
26554     /* "(tree fragment)":8
26555  *         raise __pyx_PickleError("Incompatible checksums (%s vs 0xb068931 = (name))" % __pyx_checksum)
26556  *     __pyx_result = Enum.__new__(__pyx_type)
26557  *     if __pyx_state is not None:             # <<<<<<<<<<<<<<
26558  *         __pyx_unpickle_Enum__set_state(<Enum> __pyx_result, __pyx_state)
26559  *     return __pyx_result
26560  */
26561   }
26562 
26563   /* "(tree fragment)":10
26564  *     if __pyx_state is not None:
26565  *         __pyx_unpickle_Enum__set_state(<Enum> __pyx_result, __pyx_state)
26566  *     return __pyx_result             # <<<<<<<<<<<<<<
26567  * cdef __pyx_unpickle_Enum__set_state(Enum __pyx_result, tuple __pyx_state):
26568  *     __pyx_result.name = __pyx_state[0]
26569  */
26570   __Pyx_XDECREF(__pyx_r);
26571   __Pyx_INCREF(__pyx_v___pyx_result);
26572   __pyx_r = __pyx_v___pyx_result;
26573   goto __pyx_L0;
26574 
26575   /* "(tree fragment)":1
26576  * def __pyx_unpickle_Enum(__pyx_type, long __pyx_checksum, __pyx_state):             # <<<<<<<<<<<<<<
26577  *     cdef object __pyx_PickleError
26578  *     cdef object __pyx_result
26579  */
26580 
26581   /* function exit code */
26582   __pyx_L1_error:;
26583   __Pyx_XDECREF(__pyx_t_2);
26584   __Pyx_XDECREF(__pyx_t_3);
26585   __Pyx_XDECREF(__pyx_t_4);
26586   __Pyx_XDECREF(__pyx_t_5);
26587   __Pyx_AddTraceback("View.MemoryView.__pyx_unpickle_Enum", __pyx_clineno, __pyx_lineno, __pyx_filename);
26588   __pyx_r = NULL;
26589   __pyx_L0:;
26590   __Pyx_XDECREF(__pyx_v___pyx_PickleError);
26591   __Pyx_XDECREF(__pyx_v___pyx_result);
26592   __Pyx_XGIVEREF(__pyx_r);
26593   __Pyx_RefNannyFinishContext();
26594   return __pyx_r;
26595 }
26596 
26597 /* "(tree fragment)":11
26598  *         __pyx_unpickle_Enum__set_state(<Enum> __pyx_result, __pyx_state)
26599  *     return __pyx_result
26600  * cdef __pyx_unpickle_Enum__set_state(Enum __pyx_result, tuple __pyx_state):             # <<<<<<<<<<<<<<
26601  *     __pyx_result.name = __pyx_state[0]
26602  *     if len(__pyx_state) > 1 and hasattr(__pyx_result, '__dict__'):
26603  */
26604 
__pyx_unpickle_Enum__set_state(struct __pyx_MemviewEnum_obj * __pyx_v___pyx_result,PyObject * __pyx_v___pyx_state)26605 static PyObject *__pyx_unpickle_Enum__set_state(struct __pyx_MemviewEnum_obj *__pyx_v___pyx_result, PyObject *__pyx_v___pyx_state) {
26606   PyObject *__pyx_r = NULL;
26607   __Pyx_RefNannyDeclarations
26608   PyObject *__pyx_t_1 = NULL;
26609   int __pyx_t_2;
26610   Py_ssize_t __pyx_t_3;
26611   int __pyx_t_4;
26612   int __pyx_t_5;
26613   PyObject *__pyx_t_6 = NULL;
26614   PyObject *__pyx_t_7 = NULL;
26615   PyObject *__pyx_t_8 = NULL;
26616   int __pyx_lineno = 0;
26617   const char *__pyx_filename = NULL;
26618   int __pyx_clineno = 0;
26619   __Pyx_RefNannySetupContext("__pyx_unpickle_Enum__set_state", 0);
26620 
26621   /* "(tree fragment)":12
26622  *     return __pyx_result
26623  * cdef __pyx_unpickle_Enum__set_state(Enum __pyx_result, tuple __pyx_state):
26624  *     __pyx_result.name = __pyx_state[0]             # <<<<<<<<<<<<<<
26625  *     if len(__pyx_state) > 1 and hasattr(__pyx_result, '__dict__'):
26626  *         __pyx_result.__dict__.update(__pyx_state[1])
26627  */
26628   if (unlikely(__pyx_v___pyx_state == Py_None)) {
26629     PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
26630     __PYX_ERR(3, 12, __pyx_L1_error)
26631   }
26632   __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(3, 12, __pyx_L1_error)
26633   __Pyx_GOTREF(__pyx_t_1);
26634   __Pyx_GIVEREF(__pyx_t_1);
26635   __Pyx_GOTREF(__pyx_v___pyx_result->name);
26636   __Pyx_DECREF(__pyx_v___pyx_result->name);
26637   __pyx_v___pyx_result->name = __pyx_t_1;
26638   __pyx_t_1 = 0;
26639 
26640   /* "(tree fragment)":13
26641  * cdef __pyx_unpickle_Enum__set_state(Enum __pyx_result, tuple __pyx_state):
26642  *     __pyx_result.name = __pyx_state[0]
26643  *     if len(__pyx_state) > 1 and hasattr(__pyx_result, '__dict__'):             # <<<<<<<<<<<<<<
26644  *         __pyx_result.__dict__.update(__pyx_state[1])
26645  */
26646   if (unlikely(__pyx_v___pyx_state == Py_None)) {
26647     PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
26648     __PYX_ERR(3, 13, __pyx_L1_error)
26649   }
26650   __pyx_t_3 = PyTuple_GET_SIZE(__pyx_v___pyx_state); if (unlikely(__pyx_t_3 == ((Py_ssize_t)-1))) __PYX_ERR(3, 13, __pyx_L1_error)
26651   __pyx_t_4 = ((__pyx_t_3 > 1) != 0);
26652   if (__pyx_t_4) {
26653   } else {
26654     __pyx_t_2 = __pyx_t_4;
26655     goto __pyx_L4_bool_binop_done;
26656   }
26657   __pyx_t_4 = __Pyx_HasAttr(((PyObject *)__pyx_v___pyx_result), __pyx_n_s_dict); if (unlikely(__pyx_t_4 == ((int)-1))) __PYX_ERR(3, 13, __pyx_L1_error)
26658   __pyx_t_5 = (__pyx_t_4 != 0);
26659   __pyx_t_2 = __pyx_t_5;
26660   __pyx_L4_bool_binop_done:;
26661   if (__pyx_t_2) {
26662 
26663     /* "(tree fragment)":14
26664  *     __pyx_result.name = __pyx_state[0]
26665  *     if len(__pyx_state) > 1 and hasattr(__pyx_result, '__dict__'):
26666  *         __pyx_result.__dict__.update(__pyx_state[1])             # <<<<<<<<<<<<<<
26667  */
26668     __pyx_t_6 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v___pyx_result), __pyx_n_s_dict); if (unlikely(!__pyx_t_6)) __PYX_ERR(3, 14, __pyx_L1_error)
26669     __Pyx_GOTREF(__pyx_t_6);
26670     __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_update); if (unlikely(!__pyx_t_7)) __PYX_ERR(3, 14, __pyx_L1_error)
26671     __Pyx_GOTREF(__pyx_t_7);
26672     __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
26673     if (unlikely(__pyx_v___pyx_state == Py_None)) {
26674       PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
26675       __PYX_ERR(3, 14, __pyx_L1_error)
26676     }
26677     __pyx_t_6 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_6)) __PYX_ERR(3, 14, __pyx_L1_error)
26678     __Pyx_GOTREF(__pyx_t_6);
26679     __pyx_t_8 = NULL;
26680     if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_7))) {
26681       __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_7);
26682       if (likely(__pyx_t_8)) {
26683         PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7);
26684         __Pyx_INCREF(__pyx_t_8);
26685         __Pyx_INCREF(function);
26686         __Pyx_DECREF_SET(__pyx_t_7, function);
26687       }
26688     }
26689     __pyx_t_1 = (__pyx_t_8) ? __Pyx_PyObject_Call2Args(__pyx_t_7, __pyx_t_8, __pyx_t_6) : __Pyx_PyObject_CallOneArg(__pyx_t_7, __pyx_t_6);
26690     __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
26691     __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
26692     if (unlikely(!__pyx_t_1)) __PYX_ERR(3, 14, __pyx_L1_error)
26693     __Pyx_GOTREF(__pyx_t_1);
26694     __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
26695     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
26696 
26697     /* "(tree fragment)":13
26698  * cdef __pyx_unpickle_Enum__set_state(Enum __pyx_result, tuple __pyx_state):
26699  *     __pyx_result.name = __pyx_state[0]
26700  *     if len(__pyx_state) > 1 and hasattr(__pyx_result, '__dict__'):             # <<<<<<<<<<<<<<
26701  *         __pyx_result.__dict__.update(__pyx_state[1])
26702  */
26703   }
26704 
26705   /* "(tree fragment)":11
26706  *         __pyx_unpickle_Enum__set_state(<Enum> __pyx_result, __pyx_state)
26707  *     return __pyx_result
26708  * cdef __pyx_unpickle_Enum__set_state(Enum __pyx_result, tuple __pyx_state):             # <<<<<<<<<<<<<<
26709  *     __pyx_result.name = __pyx_state[0]
26710  *     if len(__pyx_state) > 1 and hasattr(__pyx_result, '__dict__'):
26711  */
26712 
26713   /* function exit code */
26714   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
26715   goto __pyx_L0;
26716   __pyx_L1_error:;
26717   __Pyx_XDECREF(__pyx_t_1);
26718   __Pyx_XDECREF(__pyx_t_6);
26719   __Pyx_XDECREF(__pyx_t_7);
26720   __Pyx_XDECREF(__pyx_t_8);
26721   __Pyx_AddTraceback("View.MemoryView.__pyx_unpickle_Enum__set_state", __pyx_clineno, __pyx_lineno, __pyx_filename);
26722   __pyx_r = 0;
26723   __pyx_L0:;
26724   __Pyx_XGIVEREF(__pyx_r);
26725   __Pyx_RefNannyFinishContext();
26726   return __pyx_r;
26727 }
26728 
26729 /* "BufferFormatFromTypeInfo":1463
26730  *
26731  * @cname('__pyx_format_from_typeinfo')
26732  * cdef bytes format_from_typeinfo(__Pyx_TypeInfo *type):             # <<<<<<<<<<<<<<
26733  *     cdef __Pyx_StructField *field
26734  *     cdef __pyx_typeinfo_string fmt
26735  */
26736 
__pyx_format_from_typeinfo(__Pyx_TypeInfo * __pyx_v_type)26737 static PyObject *__pyx_format_from_typeinfo(__Pyx_TypeInfo *__pyx_v_type) {
26738   __Pyx_StructField *__pyx_v_field;
26739   struct __pyx_typeinfo_string __pyx_v_fmt;
26740   PyObject *__pyx_v_part = 0;
26741   PyObject *__pyx_v_result = 0;
26742   PyObject *__pyx_v_alignment = NULL;
26743   PyObject *__pyx_v_parts = NULL;
26744   PyObject *__pyx_v_extents = NULL;
26745   int __pyx_v_i;
26746   PyObject *__pyx_r = NULL;
26747   __Pyx_RefNannyDeclarations
26748   int __pyx_t_1;
26749   PyObject *__pyx_t_2 = NULL;
26750   __Pyx_StructField *__pyx_t_3;
26751   PyObject *__pyx_t_4 = NULL;
26752   PyObject *__pyx_t_5 = NULL;
26753   int __pyx_t_6;
26754   int __pyx_t_7;
26755   int __pyx_t_8;
26756   int __pyx_t_9;
26757   int __pyx_lineno = 0;
26758   const char *__pyx_filename = NULL;
26759   int __pyx_clineno = 0;
26760   __Pyx_RefNannySetupContext("format_from_typeinfo", 0);
26761 
26762   /* "BufferFormatFromTypeInfo":1468
26763  *     cdef bytes part, result
26764  *
26765  *     if type.typegroup == 'S':             # <<<<<<<<<<<<<<
26766  *         assert type.fields != NULL
26767  *         assert type.fields.type != NULL
26768  */
26769   __pyx_t_1 = ((__pyx_v_type->typegroup == 'S') != 0);
26770   if (__pyx_t_1) {
26771 
26772     /* "BufferFormatFromTypeInfo":1469
26773  *
26774  *     if type.typegroup == 'S':
26775  *         assert type.fields != NULL             # <<<<<<<<<<<<<<
26776  *         assert type.fields.type != NULL
26777  *
26778  */
26779     #ifndef CYTHON_WITHOUT_ASSERTIONS
26780     if (unlikely(!Py_OptimizeFlag)) {
26781       if (unlikely(!((__pyx_v_type->fields != NULL) != 0))) {
26782         PyErr_SetNone(PyExc_AssertionError);
26783         __PYX_ERR(3, 1469, __pyx_L1_error)
26784       }
26785     }
26786     #endif
26787 
26788     /* "BufferFormatFromTypeInfo":1470
26789  *     if type.typegroup == 'S':
26790  *         assert type.fields != NULL
26791  *         assert type.fields.type != NULL             # <<<<<<<<<<<<<<
26792  *
26793  *         if type.flags & __PYX_BUF_FLAGS_PACKED_STRUCT:
26794  */
26795     #ifndef CYTHON_WITHOUT_ASSERTIONS
26796     if (unlikely(!Py_OptimizeFlag)) {
26797       if (unlikely(!((__pyx_v_type->fields->type != NULL) != 0))) {
26798         PyErr_SetNone(PyExc_AssertionError);
26799         __PYX_ERR(3, 1470, __pyx_L1_error)
26800       }
26801     }
26802     #endif
26803 
26804     /* "BufferFormatFromTypeInfo":1472
26805  *         assert type.fields.type != NULL
26806  *
26807  *         if type.flags & __PYX_BUF_FLAGS_PACKED_STRUCT:             # <<<<<<<<<<<<<<
26808  *             alignment = b'^'
26809  *         else:
26810  */
26811     __pyx_t_1 = ((__pyx_v_type->flags & __PYX_BUF_FLAGS_PACKED_STRUCT) != 0);
26812     if (__pyx_t_1) {
26813 
26814       /* "BufferFormatFromTypeInfo":1473
26815  *
26816  *         if type.flags & __PYX_BUF_FLAGS_PACKED_STRUCT:
26817  *             alignment = b'^'             # <<<<<<<<<<<<<<
26818  *         else:
26819  *             alignment = b''
26820  */
26821       __Pyx_INCREF(__pyx_kp_b__39);
26822       __pyx_v_alignment = __pyx_kp_b__39;
26823 
26824       /* "BufferFormatFromTypeInfo":1472
26825  *         assert type.fields.type != NULL
26826  *
26827  *         if type.flags & __PYX_BUF_FLAGS_PACKED_STRUCT:             # <<<<<<<<<<<<<<
26828  *             alignment = b'^'
26829  *         else:
26830  */
26831       goto __pyx_L4;
26832     }
26833 
26834     /* "BufferFormatFromTypeInfo":1475
26835  *             alignment = b'^'
26836  *         else:
26837  *             alignment = b''             # <<<<<<<<<<<<<<
26838  *
26839  *         parts = [b"T{"]
26840  */
26841     /*else*/ {
26842       __Pyx_INCREF(__pyx_kp_b__40);
26843       __pyx_v_alignment = __pyx_kp_b__40;
26844     }
26845     __pyx_L4:;
26846 
26847     /* "BufferFormatFromTypeInfo":1477
26848  *             alignment = b''
26849  *
26850  *         parts = [b"T{"]             # <<<<<<<<<<<<<<
26851  *         field = type.fields
26852  *
26853  */
26854     __pyx_t_2 = PyList_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(3, 1477, __pyx_L1_error)
26855     __Pyx_GOTREF(__pyx_t_2);
26856     __Pyx_INCREF(__pyx_kp_b_T);
26857     __Pyx_GIVEREF(__pyx_kp_b_T);
26858     PyList_SET_ITEM(__pyx_t_2, 0, __pyx_kp_b_T);
26859     __pyx_v_parts = ((PyObject*)__pyx_t_2);
26860     __pyx_t_2 = 0;
26861 
26862     /* "BufferFormatFromTypeInfo":1478
26863  *
26864  *         parts = [b"T{"]
26865  *         field = type.fields             # <<<<<<<<<<<<<<
26866  *
26867  *         while field.type:
26868  */
26869     __pyx_t_3 = __pyx_v_type->fields;
26870     __pyx_v_field = __pyx_t_3;
26871 
26872     /* "BufferFormatFromTypeInfo":1480
26873  *         field = type.fields
26874  *
26875  *         while field.type:             # <<<<<<<<<<<<<<
26876  *             part = format_from_typeinfo(field.type)
26877  *             parts.append(part + b':' + field.name + b':')
26878  */
26879     while (1) {
26880       __pyx_t_1 = (__pyx_v_field->type != 0);
26881       if (!__pyx_t_1) break;
26882 
26883       /* "BufferFormatFromTypeInfo":1481
26884  *
26885  *         while field.type:
26886  *             part = format_from_typeinfo(field.type)             # <<<<<<<<<<<<<<
26887  *             parts.append(part + b':' + field.name + b':')
26888  *             field += 1
26889  */
26890       __pyx_t_2 = __pyx_format_from_typeinfo(__pyx_v_field->type); if (unlikely(!__pyx_t_2)) __PYX_ERR(3, 1481, __pyx_L1_error)
26891       __Pyx_GOTREF(__pyx_t_2);
26892       __Pyx_XDECREF_SET(__pyx_v_part, ((PyObject*)__pyx_t_2));
26893       __pyx_t_2 = 0;
26894 
26895       /* "BufferFormatFromTypeInfo":1482
26896  *         while field.type:
26897  *             part = format_from_typeinfo(field.type)
26898  *             parts.append(part + b':' + field.name + b':')             # <<<<<<<<<<<<<<
26899  *             field += 1
26900  *
26901  */
26902       __pyx_t_2 = PyNumber_Add(__pyx_v_part, __pyx_kp_b__41); if (unlikely(!__pyx_t_2)) __PYX_ERR(3, 1482, __pyx_L1_error)
26903       __Pyx_GOTREF(__pyx_t_2);
26904       __pyx_t_4 = __Pyx_PyBytes_FromString(__pyx_v_field->name); if (unlikely(!__pyx_t_4)) __PYX_ERR(3, 1482, __pyx_L1_error)
26905       __Pyx_GOTREF(__pyx_t_4);
26906       __pyx_t_5 = PyNumber_Add(__pyx_t_2, __pyx_t_4); if (unlikely(!__pyx_t_5)) __PYX_ERR(3, 1482, __pyx_L1_error)
26907       __Pyx_GOTREF(__pyx_t_5);
26908       __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
26909       __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
26910       __pyx_t_4 = PyNumber_Add(__pyx_t_5, __pyx_kp_b__41); if (unlikely(!__pyx_t_4)) __PYX_ERR(3, 1482, __pyx_L1_error)
26911       __Pyx_GOTREF(__pyx_t_4);
26912       __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
26913       __pyx_t_6 = __Pyx_PyList_Append(__pyx_v_parts, __pyx_t_4); if (unlikely(__pyx_t_6 == ((int)-1))) __PYX_ERR(3, 1482, __pyx_L1_error)
26914       __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
26915 
26916       /* "BufferFormatFromTypeInfo":1483
26917  *             part = format_from_typeinfo(field.type)
26918  *             parts.append(part + b':' + field.name + b':')
26919  *             field += 1             # <<<<<<<<<<<<<<
26920  *
26921  *         result = alignment.join(parts) + b'}'
26922  */
26923       __pyx_v_field = (__pyx_v_field + 1);
26924     }
26925 
26926     /* "BufferFormatFromTypeInfo":1485
26927  *             field += 1
26928  *
26929  *         result = alignment.join(parts) + b'}'             # <<<<<<<<<<<<<<
26930  *     else:
26931  *         fmt = __Pyx_TypeInfoToFormat(type)
26932  */
26933     __pyx_t_4 = __Pyx_PyBytes_Join(__pyx_v_alignment, __pyx_v_parts); if (unlikely(!__pyx_t_4)) __PYX_ERR(3, 1485, __pyx_L1_error)
26934     __Pyx_GOTREF(__pyx_t_4);
26935     __pyx_t_5 = PyNumber_Add(__pyx_t_4, __pyx_kp_b__42); if (unlikely(!__pyx_t_5)) __PYX_ERR(3, 1485, __pyx_L1_error)
26936     __Pyx_GOTREF(__pyx_t_5);
26937     __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
26938     if (!(likely(PyBytes_CheckExact(__pyx_t_5))||((__pyx_t_5) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "bytes", Py_TYPE(__pyx_t_5)->tp_name), 0))) __PYX_ERR(3, 1485, __pyx_L1_error)
26939     __pyx_v_result = ((PyObject*)__pyx_t_5);
26940     __pyx_t_5 = 0;
26941 
26942     /* "BufferFormatFromTypeInfo":1468
26943  *     cdef bytes part, result
26944  *
26945  *     if type.typegroup == 'S':             # <<<<<<<<<<<<<<
26946  *         assert type.fields != NULL
26947  *         assert type.fields.type != NULL
26948  */
26949     goto __pyx_L3;
26950   }
26951 
26952   /* "BufferFormatFromTypeInfo":1487
26953  *         result = alignment.join(parts) + b'}'
26954  *     else:
26955  *         fmt = __Pyx_TypeInfoToFormat(type)             # <<<<<<<<<<<<<<
26956  *         if type.arraysize[0]:
26957  *             extents = [unicode(type.arraysize[i]) for i in range(type.ndim)]
26958  */
26959   /*else*/ {
26960     __pyx_v_fmt = __Pyx_TypeInfoToFormat(__pyx_v_type);
26961 
26962     /* "BufferFormatFromTypeInfo":1488
26963  *     else:
26964  *         fmt = __Pyx_TypeInfoToFormat(type)
26965  *         if type.arraysize[0]:             # <<<<<<<<<<<<<<
26966  *             extents = [unicode(type.arraysize[i]) for i in range(type.ndim)]
26967  *             result = (u"(%s)" % u','.join(extents)).encode('ascii') + fmt.string
26968  */
26969     __pyx_t_1 = ((__pyx_v_type->arraysize[0]) != 0);
26970     if (__pyx_t_1) {
26971 
26972       /* "BufferFormatFromTypeInfo":1489
26973  *         fmt = __Pyx_TypeInfoToFormat(type)
26974  *         if type.arraysize[0]:
26975  *             extents = [unicode(type.arraysize[i]) for i in range(type.ndim)]             # <<<<<<<<<<<<<<
26976  *             result = (u"(%s)" % u','.join(extents)).encode('ascii') + fmt.string
26977  *         else:
26978  */
26979       __pyx_t_5 = PyList_New(0); if (unlikely(!__pyx_t_5)) __PYX_ERR(3, 1489, __pyx_L1_error)
26980       __Pyx_GOTREF(__pyx_t_5);
26981       __pyx_t_7 = __pyx_v_type->ndim;
26982       __pyx_t_8 = __pyx_t_7;
26983       for (__pyx_t_9 = 0; __pyx_t_9 < __pyx_t_8; __pyx_t_9+=1) {
26984         __pyx_v_i = __pyx_t_9;
26985         __pyx_t_4 = __Pyx_PyInt_FromSize_t((__pyx_v_type->arraysize[__pyx_v_i])); if (unlikely(!__pyx_t_4)) __PYX_ERR(3, 1489, __pyx_L1_error)
26986         __Pyx_GOTREF(__pyx_t_4);
26987         __pyx_t_2 = __Pyx_PyObject_Unicode(__pyx_t_4); if (unlikely(!__pyx_t_2)) __PYX_ERR(3, 1489, __pyx_L1_error)
26988         __Pyx_GOTREF(__pyx_t_2);
26989         __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
26990         if (unlikely(__Pyx_ListComp_Append(__pyx_t_5, (PyObject*)__pyx_t_2))) __PYX_ERR(3, 1489, __pyx_L1_error)
26991         __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
26992       }
26993       __pyx_v_extents = ((PyObject*)__pyx_t_5);
26994       __pyx_t_5 = 0;
26995 
26996       /* "BufferFormatFromTypeInfo":1490
26997  *         if type.arraysize[0]:
26998  *             extents = [unicode(type.arraysize[i]) for i in range(type.ndim)]
26999  *             result = (u"(%s)" % u','.join(extents)).encode('ascii') + fmt.string             # <<<<<<<<<<<<<<
27000  *         else:
27001  *             result = fmt.string
27002  */
27003       __pyx_t_5 = PyUnicode_Join(__pyx_kp_u__43, __pyx_v_extents); if (unlikely(!__pyx_t_5)) __PYX_ERR(3, 1490, __pyx_L1_error)
27004       __Pyx_GOTREF(__pyx_t_5);
27005       __pyx_t_2 = PyUnicode_Format(__pyx_kp_u_s, __pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(3, 1490, __pyx_L1_error)
27006       __Pyx_GOTREF(__pyx_t_2);
27007       __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
27008       __pyx_t_5 = PyUnicode_AsASCIIString(((PyObject*)__pyx_t_2)); if (unlikely(!__pyx_t_5)) __PYX_ERR(3, 1490, __pyx_L1_error)
27009       __Pyx_GOTREF(__pyx_t_5);
27010       __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
27011       __pyx_t_2 = __Pyx_PyObject_FromString(__pyx_v_fmt.string); if (unlikely(!__pyx_t_2)) __PYX_ERR(3, 1490, __pyx_L1_error)
27012       __Pyx_GOTREF(__pyx_t_2);
27013       __pyx_t_4 = PyNumber_Add(__pyx_t_5, __pyx_t_2); if (unlikely(!__pyx_t_4)) __PYX_ERR(3, 1490, __pyx_L1_error)
27014       __Pyx_GOTREF(__pyx_t_4);
27015       __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
27016       __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
27017       if (!(likely(PyBytes_CheckExact(__pyx_t_4))||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "bytes", Py_TYPE(__pyx_t_4)->tp_name), 0))) __PYX_ERR(3, 1490, __pyx_L1_error)
27018       __pyx_v_result = ((PyObject*)__pyx_t_4);
27019       __pyx_t_4 = 0;
27020 
27021       /* "BufferFormatFromTypeInfo":1488
27022  *     else:
27023  *         fmt = __Pyx_TypeInfoToFormat(type)
27024  *         if type.arraysize[0]:             # <<<<<<<<<<<<<<
27025  *             extents = [unicode(type.arraysize[i]) for i in range(type.ndim)]
27026  *             result = (u"(%s)" % u','.join(extents)).encode('ascii') + fmt.string
27027  */
27028       goto __pyx_L7;
27029     }
27030 
27031     /* "BufferFormatFromTypeInfo":1492
27032  *             result = (u"(%s)" % u','.join(extents)).encode('ascii') + fmt.string
27033  *         else:
27034  *             result = fmt.string             # <<<<<<<<<<<<<<
27035  *
27036  *     return result
27037  */
27038     /*else*/ {
27039       __pyx_t_4 = __Pyx_PyObject_FromString(__pyx_v_fmt.string); if (unlikely(!__pyx_t_4)) __PYX_ERR(3, 1492, __pyx_L1_error)
27040       __Pyx_GOTREF(__pyx_t_4);
27041       __pyx_v_result = ((PyObject*)__pyx_t_4);
27042       __pyx_t_4 = 0;
27043     }
27044     __pyx_L7:;
27045   }
27046   __pyx_L3:;
27047 
27048   /* "BufferFormatFromTypeInfo":1494
27049  *             result = fmt.string
27050  *
27051  *     return result             # <<<<<<<<<<<<<<
27052  */
27053   __Pyx_XDECREF(__pyx_r);
27054   __Pyx_INCREF(__pyx_v_result);
27055   __pyx_r = __pyx_v_result;
27056   goto __pyx_L0;
27057 
27058   /* "BufferFormatFromTypeInfo":1463
27059  *
27060  * @cname('__pyx_format_from_typeinfo')
27061  * cdef bytes format_from_typeinfo(__Pyx_TypeInfo *type):             # <<<<<<<<<<<<<<
27062  *     cdef __Pyx_StructField *field
27063  *     cdef __pyx_typeinfo_string fmt
27064  */
27065 
27066   /* function exit code */
27067   __pyx_L1_error:;
27068   __Pyx_XDECREF(__pyx_t_2);
27069   __Pyx_XDECREF(__pyx_t_4);
27070   __Pyx_XDECREF(__pyx_t_5);
27071   __Pyx_AddTraceback("BufferFormatFromTypeInfo.format_from_typeinfo", __pyx_clineno, __pyx_lineno, __pyx_filename);
27072   __pyx_r = 0;
27073   __pyx_L0:;
27074   __Pyx_XDECREF(__pyx_v_part);
27075   __Pyx_XDECREF(__pyx_v_result);
27076   __Pyx_XDECREF(__pyx_v_alignment);
27077   __Pyx_XDECREF(__pyx_v_parts);
27078   __Pyx_XDECREF(__pyx_v_extents);
27079   __Pyx_XGIVEREF(__pyx_r);
27080   __Pyx_RefNannyFinishContext();
27081   return __pyx_r;
27082 }
27083 static struct __pyx_vtabstruct_array __pyx_vtable_array;
27084 
__pyx_tp_new_array(PyTypeObject * t,PyObject * a,PyObject * k)27085 static PyObject *__pyx_tp_new_array(PyTypeObject *t, PyObject *a, PyObject *k) {
27086   struct __pyx_array_obj *p;
27087   PyObject *o;
27088   if (likely((t->tp_flags & Py_TPFLAGS_IS_ABSTRACT) == 0)) {
27089     o = (*t->tp_alloc)(t, 0);
27090   } else {
27091     o = (PyObject *) PyBaseObject_Type.tp_new(t, __pyx_empty_tuple, 0);
27092   }
27093   if (unlikely(!o)) return 0;
27094   p = ((struct __pyx_array_obj *)o);
27095   p->__pyx_vtab = __pyx_vtabptr_array;
27096   p->mode = ((PyObject*)Py_None); Py_INCREF(Py_None);
27097   p->_format = ((PyObject*)Py_None); Py_INCREF(Py_None);
27098   if (unlikely(__pyx_array___cinit__(o, a, k) < 0)) goto bad;
27099   return o;
27100   bad:
27101   Py_DECREF(o); o = 0;
27102   return NULL;
27103 }
27104 
__pyx_tp_dealloc_array(PyObject * o)27105 static void __pyx_tp_dealloc_array(PyObject *o) {
27106   struct __pyx_array_obj *p = (struct __pyx_array_obj *)o;
27107   #if CYTHON_USE_TP_FINALIZE
27108   if (unlikely(PyType_HasFeature(Py_TYPE(o), Py_TPFLAGS_HAVE_FINALIZE) && Py_TYPE(o)->tp_finalize) && (!PyType_IS_GC(Py_TYPE(o)) || !_PyGC_FINALIZED(o))) {
27109     if (PyObject_CallFinalizerFromDealloc(o)) return;
27110   }
27111   #endif
27112   {
27113     PyObject *etype, *eval, *etb;
27114     PyErr_Fetch(&etype, &eval, &etb);
27115     __Pyx_SET_REFCNT(o, Py_REFCNT(o) + 1);
27116     __pyx_array___dealloc__(o);
27117     __Pyx_SET_REFCNT(o, Py_REFCNT(o) - 1);
27118     PyErr_Restore(etype, eval, etb);
27119   }
27120   Py_CLEAR(p->mode);
27121   Py_CLEAR(p->_format);
27122   (*Py_TYPE(o)->tp_free)(o);
27123 }
__pyx_sq_item_array(PyObject * o,Py_ssize_t i)27124 static PyObject *__pyx_sq_item_array(PyObject *o, Py_ssize_t i) {
27125   PyObject *r;
27126   PyObject *x = PyInt_FromSsize_t(i); if(!x) return 0;
27127   r = Py_TYPE(o)->tp_as_mapping->mp_subscript(o, x);
27128   Py_DECREF(x);
27129   return r;
27130 }
27131 
__pyx_mp_ass_subscript_array(PyObject * o,PyObject * i,PyObject * v)27132 static int __pyx_mp_ass_subscript_array(PyObject *o, PyObject *i, PyObject *v) {
27133   if (v) {
27134     return __pyx_array___setitem__(o, i, v);
27135   }
27136   else {
27137     PyErr_Format(PyExc_NotImplementedError,
27138       "Subscript deletion not supported by %.200s", Py_TYPE(o)->tp_name);
27139     return -1;
27140   }
27141 }
27142 
__pyx_tp_getattro_array(PyObject * o,PyObject * n)27143 static PyObject *__pyx_tp_getattro_array(PyObject *o, PyObject *n) {
27144   PyObject *v = __Pyx_PyObject_GenericGetAttr(o, n);
27145   if (!v && PyErr_ExceptionMatches(PyExc_AttributeError)) {
27146     PyErr_Clear();
27147     v = __pyx_array___getattr__(o, n);
27148   }
27149   return v;
27150 }
27151 
__pyx_getprop___pyx_array_memview(PyObject * o,CYTHON_UNUSED void * x)27152 static PyObject *__pyx_getprop___pyx_array_memview(PyObject *o, CYTHON_UNUSED void *x) {
27153   return __pyx_pw_15View_dot_MemoryView_5array_7memview_1__get__(o);
27154 }
27155 
27156 static PyMethodDef __pyx_methods_array[] = {
27157   {"__getattr__", (PyCFunction)__pyx_array___getattr__, METH_O|METH_COEXIST, 0},
27158   {"__reduce_cython__", (PyCFunction)__pyx_pw___pyx_array_1__reduce_cython__, METH_NOARGS, 0},
27159   {"__setstate_cython__", (PyCFunction)__pyx_pw___pyx_array_3__setstate_cython__, METH_O, 0},
27160   {0, 0, 0, 0}
27161 };
27162 
27163 static struct PyGetSetDef __pyx_getsets_array[] = {
27164   {(char *)"memview", __pyx_getprop___pyx_array_memview, 0, (char *)0, 0},
27165   {0, 0, 0, 0, 0}
27166 };
27167 
27168 static PySequenceMethods __pyx_tp_as_sequence_array = {
27169   __pyx_array___len__, /*sq_length*/
27170   0, /*sq_concat*/
27171   0, /*sq_repeat*/
27172   __pyx_sq_item_array, /*sq_item*/
27173   0, /*sq_slice*/
27174   0, /*sq_ass_item*/
27175   0, /*sq_ass_slice*/
27176   0, /*sq_contains*/
27177   0, /*sq_inplace_concat*/
27178   0, /*sq_inplace_repeat*/
27179 };
27180 
27181 static PyMappingMethods __pyx_tp_as_mapping_array = {
27182   __pyx_array___len__, /*mp_length*/
27183   __pyx_array___getitem__, /*mp_subscript*/
27184   __pyx_mp_ass_subscript_array, /*mp_ass_subscript*/
27185 };
27186 
27187 static PyBufferProcs __pyx_tp_as_buffer_array = {
27188   #if PY_MAJOR_VERSION < 3
27189   0, /*bf_getreadbuffer*/
27190   #endif
27191   #if PY_MAJOR_VERSION < 3
27192   0, /*bf_getwritebuffer*/
27193   #endif
27194   #if PY_MAJOR_VERSION < 3
27195   0, /*bf_getsegcount*/
27196   #endif
27197   #if PY_MAJOR_VERSION < 3
27198   0, /*bf_getcharbuffer*/
27199   #endif
27200   __pyx_array_getbuffer, /*bf_getbuffer*/
27201   0, /*bf_releasebuffer*/
27202 };
27203 
27204 static PyTypeObject __pyx_type___pyx_array = {
27205   PyVarObject_HEAD_INIT(0, 0)
27206   "qutip.cy.brtools.array", /*tp_name*/
27207   sizeof(struct __pyx_array_obj), /*tp_basicsize*/
27208   0, /*tp_itemsize*/
27209   __pyx_tp_dealloc_array, /*tp_dealloc*/
27210   #if PY_VERSION_HEX < 0x030800b4
27211   0, /*tp_print*/
27212   #endif
27213   #if PY_VERSION_HEX >= 0x030800b4
27214   0, /*tp_vectorcall_offset*/
27215   #endif
27216   0, /*tp_getattr*/
27217   0, /*tp_setattr*/
27218   #if PY_MAJOR_VERSION < 3
27219   0, /*tp_compare*/
27220   #endif
27221   #if PY_MAJOR_VERSION >= 3
27222   0, /*tp_as_async*/
27223   #endif
27224   0, /*tp_repr*/
27225   0, /*tp_as_number*/
27226   &__pyx_tp_as_sequence_array, /*tp_as_sequence*/
27227   &__pyx_tp_as_mapping_array, /*tp_as_mapping*/
27228   0, /*tp_hash*/
27229   0, /*tp_call*/
27230   0, /*tp_str*/
27231   __pyx_tp_getattro_array, /*tp_getattro*/
27232   0, /*tp_setattro*/
27233   &__pyx_tp_as_buffer_array, /*tp_as_buffer*/
27234   Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE, /*tp_flags*/
27235   0, /*tp_doc*/
27236   0, /*tp_traverse*/
27237   0, /*tp_clear*/
27238   0, /*tp_richcompare*/
27239   0, /*tp_weaklistoffset*/
27240   0, /*tp_iter*/
27241   0, /*tp_iternext*/
27242   __pyx_methods_array, /*tp_methods*/
27243   0, /*tp_members*/
27244   __pyx_getsets_array, /*tp_getset*/
27245   0, /*tp_base*/
27246   0, /*tp_dict*/
27247   0, /*tp_descr_get*/
27248   0, /*tp_descr_set*/
27249   0, /*tp_dictoffset*/
27250   0, /*tp_init*/
27251   0, /*tp_alloc*/
27252   __pyx_tp_new_array, /*tp_new*/
27253   0, /*tp_free*/
27254   0, /*tp_is_gc*/
27255   0, /*tp_bases*/
27256   0, /*tp_mro*/
27257   0, /*tp_cache*/
27258   0, /*tp_subclasses*/
27259   0, /*tp_weaklist*/
27260   0, /*tp_del*/
27261   0, /*tp_version_tag*/
27262   #if PY_VERSION_HEX >= 0x030400a1
27263   0, /*tp_finalize*/
27264   #endif
27265   #if PY_VERSION_HEX >= 0x030800b1
27266   0, /*tp_vectorcall*/
27267   #endif
27268   #if PY_VERSION_HEX >= 0x030800b4 && PY_VERSION_HEX < 0x03090000
27269   0, /*tp_print*/
27270   #endif
27271 };
27272 
__pyx_tp_new_Enum(PyTypeObject * t,CYTHON_UNUSED PyObject * a,CYTHON_UNUSED PyObject * k)27273 static PyObject *__pyx_tp_new_Enum(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
27274   struct __pyx_MemviewEnum_obj *p;
27275   PyObject *o;
27276   if (likely((t->tp_flags & Py_TPFLAGS_IS_ABSTRACT) == 0)) {
27277     o = (*t->tp_alloc)(t, 0);
27278   } else {
27279     o = (PyObject *) PyBaseObject_Type.tp_new(t, __pyx_empty_tuple, 0);
27280   }
27281   if (unlikely(!o)) return 0;
27282   p = ((struct __pyx_MemviewEnum_obj *)o);
27283   p->name = Py_None; Py_INCREF(Py_None);
27284   return o;
27285 }
27286 
__pyx_tp_dealloc_Enum(PyObject * o)27287 static void __pyx_tp_dealloc_Enum(PyObject *o) {
27288   struct __pyx_MemviewEnum_obj *p = (struct __pyx_MemviewEnum_obj *)o;
27289   #if CYTHON_USE_TP_FINALIZE
27290   if (unlikely(PyType_HasFeature(Py_TYPE(o), Py_TPFLAGS_HAVE_FINALIZE) && Py_TYPE(o)->tp_finalize) && !_PyGC_FINALIZED(o)) {
27291     if (PyObject_CallFinalizerFromDealloc(o)) return;
27292   }
27293   #endif
27294   PyObject_GC_UnTrack(o);
27295   Py_CLEAR(p->name);
27296   (*Py_TYPE(o)->tp_free)(o);
27297 }
27298 
__pyx_tp_traverse_Enum(PyObject * o,visitproc v,void * a)27299 static int __pyx_tp_traverse_Enum(PyObject *o, visitproc v, void *a) {
27300   int e;
27301   struct __pyx_MemviewEnum_obj *p = (struct __pyx_MemviewEnum_obj *)o;
27302   if (p->name) {
27303     e = (*v)(p->name, a); if (e) return e;
27304   }
27305   return 0;
27306 }
27307 
__pyx_tp_clear_Enum(PyObject * o)27308 static int __pyx_tp_clear_Enum(PyObject *o) {
27309   PyObject* tmp;
27310   struct __pyx_MemviewEnum_obj *p = (struct __pyx_MemviewEnum_obj *)o;
27311   tmp = ((PyObject*)p->name);
27312   p->name = Py_None; Py_INCREF(Py_None);
27313   Py_XDECREF(tmp);
27314   return 0;
27315 }
27316 
27317 static PyMethodDef __pyx_methods_Enum[] = {
27318   {"__reduce_cython__", (PyCFunction)__pyx_pw___pyx_MemviewEnum_1__reduce_cython__, METH_NOARGS, 0},
27319   {"__setstate_cython__", (PyCFunction)__pyx_pw___pyx_MemviewEnum_3__setstate_cython__, METH_O, 0},
27320   {0, 0, 0, 0}
27321 };
27322 
27323 static PyTypeObject __pyx_type___pyx_MemviewEnum = {
27324   PyVarObject_HEAD_INIT(0, 0)
27325   "qutip.cy.brtools.Enum", /*tp_name*/
27326   sizeof(struct __pyx_MemviewEnum_obj), /*tp_basicsize*/
27327   0, /*tp_itemsize*/
27328   __pyx_tp_dealloc_Enum, /*tp_dealloc*/
27329   #if PY_VERSION_HEX < 0x030800b4
27330   0, /*tp_print*/
27331   #endif
27332   #if PY_VERSION_HEX >= 0x030800b4
27333   0, /*tp_vectorcall_offset*/
27334   #endif
27335   0, /*tp_getattr*/
27336   0, /*tp_setattr*/
27337   #if PY_MAJOR_VERSION < 3
27338   0, /*tp_compare*/
27339   #endif
27340   #if PY_MAJOR_VERSION >= 3
27341   0, /*tp_as_async*/
27342   #endif
27343   __pyx_MemviewEnum___repr__, /*tp_repr*/
27344   0, /*tp_as_number*/
27345   0, /*tp_as_sequence*/
27346   0, /*tp_as_mapping*/
27347   0, /*tp_hash*/
27348   0, /*tp_call*/
27349   0, /*tp_str*/
27350   0, /*tp_getattro*/
27351   0, /*tp_setattro*/
27352   0, /*tp_as_buffer*/
27353   Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
27354   0, /*tp_doc*/
27355   __pyx_tp_traverse_Enum, /*tp_traverse*/
27356   __pyx_tp_clear_Enum, /*tp_clear*/
27357   0, /*tp_richcompare*/
27358   0, /*tp_weaklistoffset*/
27359   0, /*tp_iter*/
27360   0, /*tp_iternext*/
27361   __pyx_methods_Enum, /*tp_methods*/
27362   0, /*tp_members*/
27363   0, /*tp_getset*/
27364   0, /*tp_base*/
27365   0, /*tp_dict*/
27366   0, /*tp_descr_get*/
27367   0, /*tp_descr_set*/
27368   0, /*tp_dictoffset*/
27369   __pyx_MemviewEnum___init__, /*tp_init*/
27370   0, /*tp_alloc*/
27371   __pyx_tp_new_Enum, /*tp_new*/
27372   0, /*tp_free*/
27373   0, /*tp_is_gc*/
27374   0, /*tp_bases*/
27375   0, /*tp_mro*/
27376   0, /*tp_cache*/
27377   0, /*tp_subclasses*/
27378   0, /*tp_weaklist*/
27379   0, /*tp_del*/
27380   0, /*tp_version_tag*/
27381   #if PY_VERSION_HEX >= 0x030400a1
27382   0, /*tp_finalize*/
27383   #endif
27384   #if PY_VERSION_HEX >= 0x030800b1
27385   0, /*tp_vectorcall*/
27386   #endif
27387   #if PY_VERSION_HEX >= 0x030800b4 && PY_VERSION_HEX < 0x03090000
27388   0, /*tp_print*/
27389   #endif
27390 };
27391 static struct __pyx_vtabstruct_memoryview __pyx_vtable_memoryview;
27392 
__pyx_tp_new_memoryview(PyTypeObject * t,PyObject * a,PyObject * k)27393 static PyObject *__pyx_tp_new_memoryview(PyTypeObject *t, PyObject *a, PyObject *k) {
27394   struct __pyx_memoryview_obj *p;
27395   PyObject *o;
27396   if (likely((t->tp_flags & Py_TPFLAGS_IS_ABSTRACT) == 0)) {
27397     o = (*t->tp_alloc)(t, 0);
27398   } else {
27399     o = (PyObject *) PyBaseObject_Type.tp_new(t, __pyx_empty_tuple, 0);
27400   }
27401   if (unlikely(!o)) return 0;
27402   p = ((struct __pyx_memoryview_obj *)o);
27403   p->__pyx_vtab = __pyx_vtabptr_memoryview;
27404   p->obj = Py_None; Py_INCREF(Py_None);
27405   p->_size = Py_None; Py_INCREF(Py_None);
27406   p->_array_interface = Py_None; Py_INCREF(Py_None);
27407   p->view.obj = NULL;
27408   if (unlikely(__pyx_memoryview___cinit__(o, a, k) < 0)) goto bad;
27409   return o;
27410   bad:
27411   Py_DECREF(o); o = 0;
27412   return NULL;
27413 }
27414 
__pyx_tp_dealloc_memoryview(PyObject * o)27415 static void __pyx_tp_dealloc_memoryview(PyObject *o) {
27416   struct __pyx_memoryview_obj *p = (struct __pyx_memoryview_obj *)o;
27417   #if CYTHON_USE_TP_FINALIZE
27418   if (unlikely(PyType_HasFeature(Py_TYPE(o), Py_TPFLAGS_HAVE_FINALIZE) && Py_TYPE(o)->tp_finalize) && !_PyGC_FINALIZED(o)) {
27419     if (PyObject_CallFinalizerFromDealloc(o)) return;
27420   }
27421   #endif
27422   PyObject_GC_UnTrack(o);
27423   {
27424     PyObject *etype, *eval, *etb;
27425     PyErr_Fetch(&etype, &eval, &etb);
27426     __Pyx_SET_REFCNT(o, Py_REFCNT(o) + 1);
27427     __pyx_memoryview___dealloc__(o);
27428     __Pyx_SET_REFCNT(o, Py_REFCNT(o) - 1);
27429     PyErr_Restore(etype, eval, etb);
27430   }
27431   Py_CLEAR(p->obj);
27432   Py_CLEAR(p->_size);
27433   Py_CLEAR(p->_array_interface);
27434   (*Py_TYPE(o)->tp_free)(o);
27435 }
27436 
__pyx_tp_traverse_memoryview(PyObject * o,visitproc v,void * a)27437 static int __pyx_tp_traverse_memoryview(PyObject *o, visitproc v, void *a) {
27438   int e;
27439   struct __pyx_memoryview_obj *p = (struct __pyx_memoryview_obj *)o;
27440   if (p->obj) {
27441     e = (*v)(p->obj, a); if (e) return e;
27442   }
27443   if (p->_size) {
27444     e = (*v)(p->_size, a); if (e) return e;
27445   }
27446   if (p->_array_interface) {
27447     e = (*v)(p->_array_interface, a); if (e) return e;
27448   }
27449   if (p->view.obj) {
27450     e = (*v)(p->view.obj, a); if (e) return e;
27451   }
27452   return 0;
27453 }
27454 
__pyx_tp_clear_memoryview(PyObject * o)27455 static int __pyx_tp_clear_memoryview(PyObject *o) {
27456   PyObject* tmp;
27457   struct __pyx_memoryview_obj *p = (struct __pyx_memoryview_obj *)o;
27458   tmp = ((PyObject*)p->obj);
27459   p->obj = Py_None; Py_INCREF(Py_None);
27460   Py_XDECREF(tmp);
27461   tmp = ((PyObject*)p->_size);
27462   p->_size = Py_None; Py_INCREF(Py_None);
27463   Py_XDECREF(tmp);
27464   tmp = ((PyObject*)p->_array_interface);
27465   p->_array_interface = Py_None; Py_INCREF(Py_None);
27466   Py_XDECREF(tmp);
27467   Py_CLEAR(p->view.obj);
27468   return 0;
27469 }
__pyx_sq_item_memoryview(PyObject * o,Py_ssize_t i)27470 static PyObject *__pyx_sq_item_memoryview(PyObject *o, Py_ssize_t i) {
27471   PyObject *r;
27472   PyObject *x = PyInt_FromSsize_t(i); if(!x) return 0;
27473   r = Py_TYPE(o)->tp_as_mapping->mp_subscript(o, x);
27474   Py_DECREF(x);
27475   return r;
27476 }
27477 
__pyx_mp_ass_subscript_memoryview(PyObject * o,PyObject * i,PyObject * v)27478 static int __pyx_mp_ass_subscript_memoryview(PyObject *o, PyObject *i, PyObject *v) {
27479   if (v) {
27480     return __pyx_memoryview___setitem__(o, i, v);
27481   }
27482   else {
27483     PyErr_Format(PyExc_NotImplementedError,
27484       "Subscript deletion not supported by %.200s", Py_TYPE(o)->tp_name);
27485     return -1;
27486   }
27487 }
27488 
__pyx_getprop___pyx_memoryview_T(PyObject * o,CYTHON_UNUSED void * x)27489 static PyObject *__pyx_getprop___pyx_memoryview_T(PyObject *o, CYTHON_UNUSED void *x) {
27490   return __pyx_pw_15View_dot_MemoryView_10memoryview_1T_1__get__(o);
27491 }
27492 
__pyx_getprop___pyx_memoryview_base(PyObject * o,CYTHON_UNUSED void * x)27493 static PyObject *__pyx_getprop___pyx_memoryview_base(PyObject *o, CYTHON_UNUSED void *x) {
27494   return __pyx_pw_15View_dot_MemoryView_10memoryview_4base_1__get__(o);
27495 }
27496 
__pyx_getprop___pyx_memoryview_shape(PyObject * o,CYTHON_UNUSED void * x)27497 static PyObject *__pyx_getprop___pyx_memoryview_shape(PyObject *o, CYTHON_UNUSED void *x) {
27498   return __pyx_pw_15View_dot_MemoryView_10memoryview_5shape_1__get__(o);
27499 }
27500 
__pyx_getprop___pyx_memoryview_strides(PyObject * o,CYTHON_UNUSED void * x)27501 static PyObject *__pyx_getprop___pyx_memoryview_strides(PyObject *o, CYTHON_UNUSED void *x) {
27502   return __pyx_pw_15View_dot_MemoryView_10memoryview_7strides_1__get__(o);
27503 }
27504 
__pyx_getprop___pyx_memoryview_suboffsets(PyObject * o,CYTHON_UNUSED void * x)27505 static PyObject *__pyx_getprop___pyx_memoryview_suboffsets(PyObject *o, CYTHON_UNUSED void *x) {
27506   return __pyx_pw_15View_dot_MemoryView_10memoryview_10suboffsets_1__get__(o);
27507 }
27508 
__pyx_getprop___pyx_memoryview_ndim(PyObject * o,CYTHON_UNUSED void * x)27509 static PyObject *__pyx_getprop___pyx_memoryview_ndim(PyObject *o, CYTHON_UNUSED void *x) {
27510   return __pyx_pw_15View_dot_MemoryView_10memoryview_4ndim_1__get__(o);
27511 }
27512 
__pyx_getprop___pyx_memoryview_itemsize(PyObject * o,CYTHON_UNUSED void * x)27513 static PyObject *__pyx_getprop___pyx_memoryview_itemsize(PyObject *o, CYTHON_UNUSED void *x) {
27514   return __pyx_pw_15View_dot_MemoryView_10memoryview_8itemsize_1__get__(o);
27515 }
27516 
__pyx_getprop___pyx_memoryview_nbytes(PyObject * o,CYTHON_UNUSED void * x)27517 static PyObject *__pyx_getprop___pyx_memoryview_nbytes(PyObject *o, CYTHON_UNUSED void *x) {
27518   return __pyx_pw_15View_dot_MemoryView_10memoryview_6nbytes_1__get__(o);
27519 }
27520 
__pyx_getprop___pyx_memoryview_size(PyObject * o,CYTHON_UNUSED void * x)27521 static PyObject *__pyx_getprop___pyx_memoryview_size(PyObject *o, CYTHON_UNUSED void *x) {
27522   return __pyx_pw_15View_dot_MemoryView_10memoryview_4size_1__get__(o);
27523 }
27524 
27525 static PyMethodDef __pyx_methods_memoryview[] = {
27526   {"is_c_contig", (PyCFunction)__pyx_memoryview_is_c_contig, METH_NOARGS, 0},
27527   {"is_f_contig", (PyCFunction)__pyx_memoryview_is_f_contig, METH_NOARGS, 0},
27528   {"copy", (PyCFunction)__pyx_memoryview_copy, METH_NOARGS, 0},
27529   {"copy_fortran", (PyCFunction)__pyx_memoryview_copy_fortran, METH_NOARGS, 0},
27530   {"__reduce_cython__", (PyCFunction)__pyx_pw___pyx_memoryview_1__reduce_cython__, METH_NOARGS, 0},
27531   {"__setstate_cython__", (PyCFunction)__pyx_pw___pyx_memoryview_3__setstate_cython__, METH_O, 0},
27532   {0, 0, 0, 0}
27533 };
27534 
27535 static struct PyGetSetDef __pyx_getsets_memoryview[] = {
27536   {(char *)"T", __pyx_getprop___pyx_memoryview_T, 0, (char *)0, 0},
27537   {(char *)"base", __pyx_getprop___pyx_memoryview_base, 0, (char *)0, 0},
27538   {(char *)"shape", __pyx_getprop___pyx_memoryview_shape, 0, (char *)0, 0},
27539   {(char *)"strides", __pyx_getprop___pyx_memoryview_strides, 0, (char *)0, 0},
27540   {(char *)"suboffsets", __pyx_getprop___pyx_memoryview_suboffsets, 0, (char *)0, 0},
27541   {(char *)"ndim", __pyx_getprop___pyx_memoryview_ndim, 0, (char *)0, 0},
27542   {(char *)"itemsize", __pyx_getprop___pyx_memoryview_itemsize, 0, (char *)0, 0},
27543   {(char *)"nbytes", __pyx_getprop___pyx_memoryview_nbytes, 0, (char *)0, 0},
27544   {(char *)"size", __pyx_getprop___pyx_memoryview_size, 0, (char *)0, 0},
27545   {0, 0, 0, 0, 0}
27546 };
27547 
27548 static PySequenceMethods __pyx_tp_as_sequence_memoryview = {
27549   __pyx_memoryview___len__, /*sq_length*/
27550   0, /*sq_concat*/
27551   0, /*sq_repeat*/
27552   __pyx_sq_item_memoryview, /*sq_item*/
27553   0, /*sq_slice*/
27554   0, /*sq_ass_item*/
27555   0, /*sq_ass_slice*/
27556   0, /*sq_contains*/
27557   0, /*sq_inplace_concat*/
27558   0, /*sq_inplace_repeat*/
27559 };
27560 
27561 static PyMappingMethods __pyx_tp_as_mapping_memoryview = {
27562   __pyx_memoryview___len__, /*mp_length*/
27563   __pyx_memoryview___getitem__, /*mp_subscript*/
27564   __pyx_mp_ass_subscript_memoryview, /*mp_ass_subscript*/
27565 };
27566 
27567 static PyBufferProcs __pyx_tp_as_buffer_memoryview = {
27568   #if PY_MAJOR_VERSION < 3
27569   0, /*bf_getreadbuffer*/
27570   #endif
27571   #if PY_MAJOR_VERSION < 3
27572   0, /*bf_getwritebuffer*/
27573   #endif
27574   #if PY_MAJOR_VERSION < 3
27575   0, /*bf_getsegcount*/
27576   #endif
27577   #if PY_MAJOR_VERSION < 3
27578   0, /*bf_getcharbuffer*/
27579   #endif
27580   __pyx_memoryview_getbuffer, /*bf_getbuffer*/
27581   0, /*bf_releasebuffer*/
27582 };
27583 
27584 static PyTypeObject __pyx_type___pyx_memoryview = {
27585   PyVarObject_HEAD_INIT(0, 0)
27586   "qutip.cy.brtools.memoryview", /*tp_name*/
27587   sizeof(struct __pyx_memoryview_obj), /*tp_basicsize*/
27588   0, /*tp_itemsize*/
27589   __pyx_tp_dealloc_memoryview, /*tp_dealloc*/
27590   #if PY_VERSION_HEX < 0x030800b4
27591   0, /*tp_print*/
27592   #endif
27593   #if PY_VERSION_HEX >= 0x030800b4
27594   0, /*tp_vectorcall_offset*/
27595   #endif
27596   0, /*tp_getattr*/
27597   0, /*tp_setattr*/
27598   #if PY_MAJOR_VERSION < 3
27599   0, /*tp_compare*/
27600   #endif
27601   #if PY_MAJOR_VERSION >= 3
27602   0, /*tp_as_async*/
27603   #endif
27604   __pyx_memoryview___repr__, /*tp_repr*/
27605   0, /*tp_as_number*/
27606   &__pyx_tp_as_sequence_memoryview, /*tp_as_sequence*/
27607   &__pyx_tp_as_mapping_memoryview, /*tp_as_mapping*/
27608   0, /*tp_hash*/
27609   0, /*tp_call*/
27610   __pyx_memoryview___str__, /*tp_str*/
27611   0, /*tp_getattro*/
27612   0, /*tp_setattro*/
27613   &__pyx_tp_as_buffer_memoryview, /*tp_as_buffer*/
27614   Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
27615   0, /*tp_doc*/
27616   __pyx_tp_traverse_memoryview, /*tp_traverse*/
27617   __pyx_tp_clear_memoryview, /*tp_clear*/
27618   0, /*tp_richcompare*/
27619   0, /*tp_weaklistoffset*/
27620   0, /*tp_iter*/
27621   0, /*tp_iternext*/
27622   __pyx_methods_memoryview, /*tp_methods*/
27623   0, /*tp_members*/
27624   __pyx_getsets_memoryview, /*tp_getset*/
27625   0, /*tp_base*/
27626   0, /*tp_dict*/
27627   0, /*tp_descr_get*/
27628   0, /*tp_descr_set*/
27629   0, /*tp_dictoffset*/
27630   0, /*tp_init*/
27631   0, /*tp_alloc*/
27632   __pyx_tp_new_memoryview, /*tp_new*/
27633   0, /*tp_free*/
27634   0, /*tp_is_gc*/
27635   0, /*tp_bases*/
27636   0, /*tp_mro*/
27637   0, /*tp_cache*/
27638   0, /*tp_subclasses*/
27639   0, /*tp_weaklist*/
27640   0, /*tp_del*/
27641   0, /*tp_version_tag*/
27642   #if PY_VERSION_HEX >= 0x030400a1
27643   0, /*tp_finalize*/
27644   #endif
27645   #if PY_VERSION_HEX >= 0x030800b1
27646   0, /*tp_vectorcall*/
27647   #endif
27648   #if PY_VERSION_HEX >= 0x030800b4 && PY_VERSION_HEX < 0x03090000
27649   0, /*tp_print*/
27650   #endif
27651 };
27652 static struct __pyx_vtabstruct__memoryviewslice __pyx_vtable__memoryviewslice;
27653 
__pyx_tp_new__memoryviewslice(PyTypeObject * t,PyObject * a,PyObject * k)27654 static PyObject *__pyx_tp_new__memoryviewslice(PyTypeObject *t, PyObject *a, PyObject *k) {
27655   struct __pyx_memoryviewslice_obj *p;
27656   PyObject *o = __pyx_tp_new_memoryview(t, a, k);
27657   if (unlikely(!o)) return 0;
27658   p = ((struct __pyx_memoryviewslice_obj *)o);
27659   p->__pyx_base.__pyx_vtab = (struct __pyx_vtabstruct_memoryview*)__pyx_vtabptr__memoryviewslice;
27660   p->from_object = Py_None; Py_INCREF(Py_None);
27661   p->from_slice.memview = NULL;
27662   return o;
27663 }
27664 
__pyx_tp_dealloc__memoryviewslice(PyObject * o)27665 static void __pyx_tp_dealloc__memoryviewslice(PyObject *o) {
27666   struct __pyx_memoryviewslice_obj *p = (struct __pyx_memoryviewslice_obj *)o;
27667   #if CYTHON_USE_TP_FINALIZE
27668   if (unlikely(PyType_HasFeature(Py_TYPE(o), Py_TPFLAGS_HAVE_FINALIZE) && Py_TYPE(o)->tp_finalize) && !_PyGC_FINALIZED(o)) {
27669     if (PyObject_CallFinalizerFromDealloc(o)) return;
27670   }
27671   #endif
27672   PyObject_GC_UnTrack(o);
27673   {
27674     PyObject *etype, *eval, *etb;
27675     PyErr_Fetch(&etype, &eval, &etb);
27676     __Pyx_SET_REFCNT(o, Py_REFCNT(o) + 1);
27677     __pyx_memoryviewslice___dealloc__(o);
27678     __Pyx_SET_REFCNT(o, Py_REFCNT(o) - 1);
27679     PyErr_Restore(etype, eval, etb);
27680   }
27681   Py_CLEAR(p->from_object);
27682   PyObject_GC_Track(o);
27683   __pyx_tp_dealloc_memoryview(o);
27684 }
27685 
__pyx_tp_traverse__memoryviewslice(PyObject * o,visitproc v,void * a)27686 static int __pyx_tp_traverse__memoryviewslice(PyObject *o, visitproc v, void *a) {
27687   int e;
27688   struct __pyx_memoryviewslice_obj *p = (struct __pyx_memoryviewslice_obj *)o;
27689   e = __pyx_tp_traverse_memoryview(o, v, a); if (e) return e;
27690   if (p->from_object) {
27691     e = (*v)(p->from_object, a); if (e) return e;
27692   }
27693   return 0;
27694 }
27695 
__pyx_tp_clear__memoryviewslice(PyObject * o)27696 static int __pyx_tp_clear__memoryviewslice(PyObject *o) {
27697   PyObject* tmp;
27698   struct __pyx_memoryviewslice_obj *p = (struct __pyx_memoryviewslice_obj *)o;
27699   __pyx_tp_clear_memoryview(o);
27700   tmp = ((PyObject*)p->from_object);
27701   p->from_object = Py_None; Py_INCREF(Py_None);
27702   Py_XDECREF(tmp);
27703   __PYX_XDEC_MEMVIEW(&p->from_slice, 1);
27704   return 0;
27705 }
27706 
__pyx_getprop___pyx_memoryviewslice_base(PyObject * o,CYTHON_UNUSED void * x)27707 static PyObject *__pyx_getprop___pyx_memoryviewslice_base(PyObject *o, CYTHON_UNUSED void *x) {
27708   return __pyx_pw_15View_dot_MemoryView_16_memoryviewslice_4base_1__get__(o);
27709 }
27710 
27711 static PyMethodDef __pyx_methods__memoryviewslice[] = {
27712   {"__reduce_cython__", (PyCFunction)__pyx_pw___pyx_memoryviewslice_1__reduce_cython__, METH_NOARGS, 0},
27713   {"__setstate_cython__", (PyCFunction)__pyx_pw___pyx_memoryviewslice_3__setstate_cython__, METH_O, 0},
27714   {0, 0, 0, 0}
27715 };
27716 
27717 static struct PyGetSetDef __pyx_getsets__memoryviewslice[] = {
27718   {(char *)"base", __pyx_getprop___pyx_memoryviewslice_base, 0, (char *)0, 0},
27719   {0, 0, 0, 0, 0}
27720 };
27721 
27722 static PyTypeObject __pyx_type___pyx_memoryviewslice = {
27723   PyVarObject_HEAD_INIT(0, 0)
27724   "qutip.cy.brtools._memoryviewslice", /*tp_name*/
27725   sizeof(struct __pyx_memoryviewslice_obj), /*tp_basicsize*/
27726   0, /*tp_itemsize*/
27727   __pyx_tp_dealloc__memoryviewslice, /*tp_dealloc*/
27728   #if PY_VERSION_HEX < 0x030800b4
27729   0, /*tp_print*/
27730   #endif
27731   #if PY_VERSION_HEX >= 0x030800b4
27732   0, /*tp_vectorcall_offset*/
27733   #endif
27734   0, /*tp_getattr*/
27735   0, /*tp_setattr*/
27736   #if PY_MAJOR_VERSION < 3
27737   0, /*tp_compare*/
27738   #endif
27739   #if PY_MAJOR_VERSION >= 3
27740   0, /*tp_as_async*/
27741   #endif
27742   #if CYTHON_COMPILING_IN_PYPY
27743   __pyx_memoryview___repr__, /*tp_repr*/
27744   #else
27745   0, /*tp_repr*/
27746   #endif
27747   0, /*tp_as_number*/
27748   0, /*tp_as_sequence*/
27749   0, /*tp_as_mapping*/
27750   0, /*tp_hash*/
27751   0, /*tp_call*/
27752   #if CYTHON_COMPILING_IN_PYPY
27753   __pyx_memoryview___str__, /*tp_str*/
27754   #else
27755   0, /*tp_str*/
27756   #endif
27757   0, /*tp_getattro*/
27758   0, /*tp_setattro*/
27759   0, /*tp_as_buffer*/
27760   Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
27761   "Internal class for passing memoryview slices to Python", /*tp_doc*/
27762   __pyx_tp_traverse__memoryviewslice, /*tp_traverse*/
27763   __pyx_tp_clear__memoryviewslice, /*tp_clear*/
27764   0, /*tp_richcompare*/
27765   0, /*tp_weaklistoffset*/
27766   0, /*tp_iter*/
27767   0, /*tp_iternext*/
27768   __pyx_methods__memoryviewslice, /*tp_methods*/
27769   0, /*tp_members*/
27770   __pyx_getsets__memoryviewslice, /*tp_getset*/
27771   0, /*tp_base*/
27772   0, /*tp_dict*/
27773   0, /*tp_descr_get*/
27774   0, /*tp_descr_set*/
27775   0, /*tp_dictoffset*/
27776   0, /*tp_init*/
27777   0, /*tp_alloc*/
27778   __pyx_tp_new__memoryviewslice, /*tp_new*/
27779   0, /*tp_free*/
27780   0, /*tp_is_gc*/
27781   0, /*tp_bases*/
27782   0, /*tp_mro*/
27783   0, /*tp_cache*/
27784   0, /*tp_subclasses*/
27785   0, /*tp_weaklist*/
27786   0, /*tp_del*/
27787   0, /*tp_version_tag*/
27788   #if PY_VERSION_HEX >= 0x030400a1
27789   0, /*tp_finalize*/
27790   #endif
27791   #if PY_VERSION_HEX >= 0x030800b1
27792   0, /*tp_vectorcall*/
27793   #endif
27794   #if PY_VERSION_HEX >= 0x030800b4 && PY_VERSION_HEX < 0x03090000
27795   0, /*tp_print*/
27796   #endif
27797 };
27798 
27799 static PyMethodDef __pyx_methods[] = {
27800   {"dense_add_mult", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_5qutip_2cy_7brtools_1dense_add_mult, METH_VARARGS|METH_KEYWORDS, __pyx_doc_5qutip_2cy_7brtools_dense_add_mult},
27801   {"cop_super_term", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_5qutip_2cy_7brtools_5cop_super_term, METH_VARARGS|METH_KEYWORDS, 0},
27802   {0, 0, 0, 0}
27803 };
27804 
27805 #if PY_MAJOR_VERSION >= 3
27806 #if CYTHON_PEP489_MULTI_PHASE_INIT
27807 static PyObject* __pyx_pymod_create(PyObject *spec, PyModuleDef *def); /*proto*/
27808 static int __pyx_pymod_exec_brtools(PyObject* module); /*proto*/
27809 static PyModuleDef_Slot __pyx_moduledef_slots[] = {
27810   {Py_mod_create, (void*)__pyx_pymod_create},
27811   {Py_mod_exec, (void*)__pyx_pymod_exec_brtools},
27812   {0, NULL}
27813 };
27814 #endif
27815 
27816 static struct PyModuleDef __pyx_moduledef = {
27817     PyModuleDef_HEAD_INIT,
27818     "brtools",
27819     0, /* m_doc */
27820   #if CYTHON_PEP489_MULTI_PHASE_INIT
27821     0, /* m_size */
27822   #else
27823     -1, /* m_size */
27824   #endif
27825     __pyx_methods /* m_methods */,
27826   #if CYTHON_PEP489_MULTI_PHASE_INIT
27827     __pyx_moduledef_slots, /* m_slots */
27828   #else
27829     NULL, /* m_reload */
27830   #endif
27831     NULL, /* m_traverse */
27832     NULL, /* m_clear */
27833     NULL /* m_free */
27834 };
27835 #endif
27836 #ifndef CYTHON_SMALL_CODE
27837 #if defined(__clang__)
27838     #define CYTHON_SMALL_CODE
27839 #elif defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3))
27840     #define CYTHON_SMALL_CODE __attribute__((cold))
27841 #else
27842     #define CYTHON_SMALL_CODE
27843 #endif
27844 #endif
27845 
27846 static __Pyx_StringTabEntry __pyx_string_tab[] = {
27847   {&__pyx_n_s_A, __pyx_k_A, sizeof(__pyx_k_A), 0, 0, 1, 1},
27848   {&__pyx_n_s_ASCII, __pyx_k_ASCII, sizeof(__pyx_k_ASCII), 0, 0, 1, 1},
27849   {&__pyx_kp_u_Algorithm_failed_to_converge, __pyx_k_Algorithm_failed_to_converge, sizeof(__pyx_k_Algorithm_failed_to_converge), 0, 1, 0, 0},
27850   {&__pyx_n_s_B, __pyx_k_B, sizeof(__pyx_k_B), 0, 0, 1, 1},
27851   {&__pyx_kp_s_Buffer_view_does_not_expose_stri, __pyx_k_Buffer_view_does_not_expose_stri, sizeof(__pyx_k_Buffer_view_does_not_expose_stri), 0, 0, 1, 0},
27852   {&__pyx_kp_u_COO_Matrix_cannot_be_expanded, __pyx_k_COO_Matrix_cannot_be_expanded, sizeof(__pyx_k_COO_Matrix_cannot_be_expanded), 0, 1, 0, 0},
27853   {&__pyx_kp_u_COO_Matrix_is_not_initialized, __pyx_k_COO_Matrix_is_not_initialized, sizeof(__pyx_k_COO_Matrix_is_not_initialized), 0, 1, 0, 0},
27854   {&__pyx_kp_u_CSR_Matrix_cannot_be_expanded, __pyx_k_CSR_Matrix_cannot_be_expanded, sizeof(__pyx_k_CSR_Matrix_cannot_be_expanded), 0, 1, 0, 0},
27855   {&__pyx_kp_u_CSR_Matrix_is_not_initialized, __pyx_k_CSR_Matrix_is_not_initialized, sizeof(__pyx_k_CSR_Matrix_is_not_initialized), 0, 1, 0, 0},
27856   {&__pyx_kp_s_Can_only_create_a_buffer_that_is, __pyx_k_Can_only_create_a_buffer_that_is, sizeof(__pyx_k_Can_only_create_a_buffer_that_is), 0, 0, 1, 0},
27857   {&__pyx_kp_s_Cannot_assign_to_read_only_memor, __pyx_k_Cannot_assign_to_read_only_memor, sizeof(__pyx_k_Cannot_assign_to_read_only_memor), 0, 0, 1, 0},
27858   {&__pyx_kp_s_Cannot_create_writable_memory_vi, __pyx_k_Cannot_create_writable_memory_vi, sizeof(__pyx_k_Cannot_create_writable_memory_vi), 0, 0, 1, 0},
27859   {&__pyx_kp_u_Cannot_expand_data_structures_pa, __pyx_k_Cannot_expand_data_structures_pa, sizeof(__pyx_k_Cannot_expand_data_structures_pa), 0, 1, 0, 0},
27860   {&__pyx_kp_s_Cannot_index_with_type_s, __pyx_k_Cannot_index_with_type_s, sizeof(__pyx_k_Cannot_index_with_type_s), 0, 0, 1, 0},
27861   {&__pyx_kp_u_Could_not_allocate_memory, __pyx_k_Could_not_allocate_memory, sizeof(__pyx_k_Could_not_allocate_memory), 0, 1, 0, 0},
27862   {&__pyx_kp_u_Data_length_cannot_be_larger_tha, __pyx_k_Data_length_cannot_be_larger_tha, sizeof(__pyx_k_Data_length_cannot_be_larger_tha), 0, 1, 0, 0},
27863   {&__pyx_n_s_Ellipsis, __pyx_k_Ellipsis, sizeof(__pyx_k_Ellipsis), 0, 0, 1, 1},
27864   {&__pyx_kp_s_Empty_shape_tuple_for_cython_arr, __pyx_k_Empty_shape_tuple_for_cython_arr, sizeof(__pyx_k_Empty_shape_tuple_for_cython_arr), 0, 0, 1, 0},
27865   {&__pyx_kp_u_Error_in_Cython_code, __pyx_k_Error_in_Cython_code, sizeof(__pyx_k_Error_in_Cython_code), 0, 1, 0, 0},
27866   {&__pyx_kp_u_Error_in_parameter_s, __pyx_k_Error_in_parameter_s, sizeof(__pyx_k_Error_in_parameter_s), 0, 1, 0, 0},
27867   {&__pyx_kp_u_Error_manipulating_COO_Matrix_st, __pyx_k_Error_manipulating_COO_Matrix_st, sizeof(__pyx_k_Error_manipulating_COO_Matrix_st), 0, 1, 0, 0},
27868   {&__pyx_kp_u_Error_manipulating_CSR_Matrix_st, __pyx_k_Error_manipulating_CSR_Matrix_st, sizeof(__pyx_k_Error_manipulating_CSR_Matrix_st), 0, 1, 0, 0},
27869   {&__pyx_n_s_ImportError, __pyx_k_ImportError, sizeof(__pyx_k_ImportError), 0, 0, 1, 1},
27870   {&__pyx_kp_s_Incompatible_checksums_s_vs_0xb0, __pyx_k_Incompatible_checksums_s_vs_0xb0, sizeof(__pyx_k_Incompatible_checksums_s_vs_0xb0), 0, 0, 1, 0},
27871   {&__pyx_n_s_IndexError, __pyx_k_IndexError, sizeof(__pyx_k_IndexError), 0, 0, 1, 1},
27872   {&__pyx_kp_s_Indirect_dimensions_not_supporte, __pyx_k_Indirect_dimensions_not_supporte, sizeof(__pyx_k_Indirect_dimensions_not_supporte), 0, 0, 1, 0},
27873   {&__pyx_kp_s_Invalid_mode_expected_c_or_fortr, __pyx_k_Invalid_mode_expected_c_or_fortr, sizeof(__pyx_k_Invalid_mode_expected_c_or_fortr), 0, 0, 1, 0},
27874   {&__pyx_kp_s_Invalid_shape_in_axis_d_d, __pyx_k_Invalid_shape_in_axis_d_d, sizeof(__pyx_k_Invalid_shape_in_axis_d_d), 0, 0, 1, 0},
27875   {&__pyx_kp_u_Invalid_transA_value, __pyx_k_Invalid_transA_value, sizeof(__pyx_k_Invalid_transA_value), 0, 1, 0, 0},
27876   {&__pyx_kp_u_Invalid_transB_value, __pyx_k_Invalid_transB_value, sizeof(__pyx_k_Invalid_transB_value), 0, 1, 0, 0},
27877   {&__pyx_n_s_MemoryError, __pyx_k_MemoryError, sizeof(__pyx_k_MemoryError), 0, 0, 1, 1},
27878   {&__pyx_kp_s_MemoryView_of_r_at_0x_x, __pyx_k_MemoryView_of_r_at_0x_x, sizeof(__pyx_k_MemoryView_of_r_at_0x_x), 0, 0, 1, 0},
27879   {&__pyx_kp_s_MemoryView_of_r_object, __pyx_k_MemoryView_of_r_object, sizeof(__pyx_k_MemoryView_of_r_object), 0, 0, 1, 0},
27880   {&__pyx_kp_u_NumPy_already_has_lock_on_data, __pyx_k_NumPy_already_has_lock_on_data, sizeof(__pyx_k_NumPy_already_has_lock_on_data), 0, 1, 0, 0},
27881   {&__pyx_n_b_O, __pyx_k_O, sizeof(__pyx_k_O), 0, 0, 0, 1},
27882   {&__pyx_kp_s_Out_of_bounds_on_buffer_access_a, __pyx_k_Out_of_bounds_on_buffer_access_a, sizeof(__pyx_k_Out_of_bounds_on_buffer_access_a), 0, 0, 1, 0},
27883   {&__pyx_n_s_PickleError, __pyx_k_PickleError, sizeof(__pyx_k_PickleError), 0, 0, 1, 1},
27884   {&__pyx_kp_b_T, __pyx_k_T, sizeof(__pyx_k_T), 0, 0, 0, 0},
27885   {&__pyx_n_s_TypeError, __pyx_k_TypeError, sizeof(__pyx_k_TypeError), 0, 0, 1, 1},
27886   {&__pyx_kp_s_Unable_to_convert_item_to_object, __pyx_k_Unable_to_convert_item_to_object, sizeof(__pyx_k_Unable_to_convert_item_to_object), 0, 0, 1, 0},
27887   {&__pyx_n_s_ValueError, __pyx_k_ValueError, sizeof(__pyx_k_ValueError), 0, 0, 1, 1},
27888   {&__pyx_n_s_View_MemoryView, __pyx_k_View_MemoryView, sizeof(__pyx_k_View_MemoryView), 0, 0, 1, 1},
27889   {&__pyx_kp_b__39, __pyx_k__39, sizeof(__pyx_k__39), 0, 0, 0, 0},
27890   {&__pyx_kp_b__40, __pyx_k__40, sizeof(__pyx_k__40), 0, 0, 0, 0},
27891   {&__pyx_kp_b__41, __pyx_k__41, sizeof(__pyx_k__41), 0, 0, 0, 0},
27892   {&__pyx_kp_b__42, __pyx_k__42, sizeof(__pyx_k__42), 0, 0, 0, 0},
27893   {&__pyx_kp_u__43, __pyx_k__43, sizeof(__pyx_k__43), 0, 1, 0, 0},
27894   {&__pyx_n_s_allocate_buffer, __pyx_k_allocate_buffer, sizeof(__pyx_k_allocate_buffer), 0, 0, 1, 1},
27895   {&__pyx_n_s_alpha, __pyx_k_alpha, sizeof(__pyx_k_alpha), 0, 0, 1, 1},
27896   {&__pyx_n_s_ans, __pyx_k_ans, sizeof(__pyx_k_ans), 0, 0, 1, 1},
27897   {&__pyx_n_s_argsort, __pyx_k_argsort, sizeof(__pyx_k_argsort), 0, 0, 1, 1},
27898   {&__pyx_n_s_array, __pyx_k_array, sizeof(__pyx_k_array), 0, 0, 1, 1},
27899   {&__pyx_n_s_atol, __pyx_k_atol, sizeof(__pyx_k_atol), 0, 0, 1, 1},
27900   {&__pyx_n_s_base, __pyx_k_base, sizeof(__pyx_k_base), 0, 0, 1, 1},
27901   {&__pyx_n_s_c, __pyx_k_c, sizeof(__pyx_k_c), 0, 0, 1, 1},
27902   {&__pyx_n_u_c, __pyx_k_c, sizeof(__pyx_k_c), 0, 1, 0, 1},
27903   {&__pyx_n_s_class, __pyx_k_class, sizeof(__pyx_k_class), 0, 0, 1, 1},
27904   {&__pyx_n_s_cline_in_traceback, __pyx_k_cline_in_traceback, sizeof(__pyx_k_cline_in_traceback), 0, 0, 1, 1},
27905   {&__pyx_n_s_col, __pyx_k_col, sizeof(__pyx_k_col), 0, 0, 1, 1},
27906   {&__pyx_kp_s_contiguous_and_direct, __pyx_k_contiguous_and_direct, sizeof(__pyx_k_contiguous_and_direct), 0, 0, 1, 0},
27907   {&__pyx_kp_s_contiguous_and_indirect, __pyx_k_contiguous_and_indirect, sizeof(__pyx_k_contiguous_and_indirect), 0, 0, 1, 0},
27908   {&__pyx_n_s_coo_matrix, __pyx_k_coo_matrix, sizeof(__pyx_k_coo_matrix), 0, 0, 1, 1},
27909   {&__pyx_n_s_cop, __pyx_k_cop, sizeof(__pyx_k_cop), 0, 0, 1, 1},
27910   {&__pyx_n_s_data, __pyx_k_data, sizeof(__pyx_k_data), 0, 0, 1, 1},
27911   {&__pyx_n_s_diags, __pyx_k_diags, sizeof(__pyx_k_diags), 0, 0, 1, 1},
27912   {&__pyx_n_s_dict, __pyx_k_dict, sizeof(__pyx_k_dict), 0, 0, 1, 1},
27913   {&__pyx_n_s_dtype, __pyx_k_dtype, sizeof(__pyx_k_dtype), 0, 0, 1, 1},
27914   {&__pyx_n_s_dtype_is_object, __pyx_k_dtype_is_object, sizeof(__pyx_k_dtype_is_object), 0, 0, 1, 1},
27915   {&__pyx_n_s_eigh_unsafe, __pyx_k_eigh_unsafe, sizeof(__pyx_k_eigh_unsafe), 0, 0, 1, 1},
27916   {&__pyx_n_s_empty, __pyx_k_empty, sizeof(__pyx_k_empty), 0, 0, 1, 1},
27917   {&__pyx_n_s_encode, __pyx_k_encode, sizeof(__pyx_k_encode), 0, 0, 1, 1},
27918   {&__pyx_n_s_enumerate, __pyx_k_enumerate, sizeof(__pyx_k_enumerate), 0, 0, 1, 1},
27919   {&__pyx_n_s_error, __pyx_k_error, sizeof(__pyx_k_error), 0, 0, 1, 1},
27920   {&__pyx_n_s_evecs, __pyx_k_evecs, sizeof(__pyx_k_evecs), 0, 0, 1, 1},
27921   {&__pyx_n_s_fast_csr_matrix, __pyx_k_fast_csr_matrix, sizeof(__pyx_k_fast_csr_matrix), 0, 0, 1, 1},
27922   {&__pyx_n_s_flags, __pyx_k_flags, sizeof(__pyx_k_flags), 0, 0, 1, 1},
27923   {&__pyx_n_s_format, __pyx_k_format, sizeof(__pyx_k_format), 0, 0, 1, 1},
27924   {&__pyx_n_s_fortran, __pyx_k_fortran, sizeof(__pyx_k_fortran), 0, 0, 1, 1},
27925   {&__pyx_n_u_fortran, __pyx_k_fortran, sizeof(__pyx_k_fortran), 0, 1, 0, 1},
27926   {&__pyx_n_s_getstate, __pyx_k_getstate, sizeof(__pyx_k_getstate), 0, 0, 1, 1},
27927   {&__pyx_kp_s_got_differing_extents_in_dimensi, __pyx_k_got_differing_extents_in_dimensi, sizeof(__pyx_k_got_differing_extents_in_dimensi), 0, 0, 1, 0},
27928   {&__pyx_n_s_id, __pyx_k_id, sizeof(__pyx_k_id), 0, 0, 1, 1},
27929   {&__pyx_n_s_idx, __pyx_k_idx, sizeof(__pyx_k_idx), 0, 0, 1, 1},
27930   {&__pyx_n_s_ii, __pyx_k_ii, sizeof(__pyx_k_ii), 0, 0, 1, 1},
27931   {&__pyx_n_s_import, __pyx_k_import, sizeof(__pyx_k_import), 0, 0, 1, 1},
27932   {&__pyx_n_s_ind, __pyx_k_ind, sizeof(__pyx_k_ind), 0, 0, 1, 1},
27933   {&__pyx_n_s_indices, __pyx_k_indices, sizeof(__pyx_k_indices), 0, 0, 1, 1},
27934   {&__pyx_n_s_indptr, __pyx_k_indptr, sizeof(__pyx_k_indptr), 0, 0, 1, 1},
27935   {&__pyx_n_s_int32, __pyx_k_int32, sizeof(__pyx_k_int32), 0, 0, 1, 1},
27936   {&__pyx_n_s_itemsize, __pyx_k_itemsize, sizeof(__pyx_k_itemsize), 0, 0, 1, 1},
27937   {&__pyx_kp_s_itemsize_0_for_cython_array, __pyx_k_itemsize_0_for_cython_array, sizeof(__pyx_k_itemsize_0_for_cython_array), 0, 0, 1, 0},
27938   {&__pyx_n_s_jj, __pyx_k_jj, sizeof(__pyx_k_jj), 0, 0, 1, 1},
27939   {&__pyx_n_s_join, __pyx_k_join, sizeof(__pyx_k_join), 0, 0, 1, 1},
27940   {&__pyx_n_s_liou_from_diag_ham, __pyx_k_liou_from_diag_ham, sizeof(__pyx_k_liou_from_diag_ham), 0, 0, 1, 1},
27941   {&__pyx_n_s_main, __pyx_k_main, sizeof(__pyx_k_main), 0, 0, 1, 1},
27942   {&__pyx_n_s_memview, __pyx_k_memview, sizeof(__pyx_k_memview), 0, 0, 1, 1},
27943   {&__pyx_n_s_mode, __pyx_k_mode, sizeof(__pyx_k_mode), 0, 0, 1, 1},
27944   {&__pyx_n_s_name, __pyx_k_name, sizeof(__pyx_k_name), 0, 0, 1, 1},
27945   {&__pyx_n_s_name_2, __pyx_k_name_2, sizeof(__pyx_k_name_2), 0, 0, 1, 1},
27946   {&__pyx_n_s_ndim, __pyx_k_ndim, sizeof(__pyx_k_ndim), 0, 0, 1, 1},
27947   {&__pyx_n_s_new, __pyx_k_new, sizeof(__pyx_k_new), 0, 0, 1, 1},
27948   {&__pyx_n_s_nnz, __pyx_k_nnz, sizeof(__pyx_k_nnz), 0, 0, 1, 1},
27949   {&__pyx_kp_s_no_default___reduce___due_to_non, __pyx_k_no_default___reduce___due_to_non, sizeof(__pyx_k_no_default___reduce___due_to_non), 0, 0, 1, 0},
27950   {&__pyx_n_s_np, __pyx_k_np, sizeof(__pyx_k_np), 0, 0, 1, 1},
27951   {&__pyx_n_s_nrows, __pyx_k_nrows, sizeof(__pyx_k_nrows), 0, 0, 1, 1},
27952   {&__pyx_n_s_numpy, __pyx_k_numpy, sizeof(__pyx_k_numpy), 0, 0, 1, 1},
27953   {&__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},
27954   {&__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},
27955   {&__pyx_n_s_obj, __pyx_k_obj, sizeof(__pyx_k_obj), 0, 0, 1, 1},
27956   {&__pyx_n_s_pack, __pyx_k_pack, sizeof(__pyx_k_pack), 0, 0, 1, 1},
27957   {&__pyx_n_s_pickle, __pyx_k_pickle, sizeof(__pyx_k_pickle), 0, 0, 1, 1},
27958   {&__pyx_n_s_ptr, __pyx_k_ptr, sizeof(__pyx_k_ptr), 0, 0, 1, 1},
27959   {&__pyx_n_s_pyx_PickleError, __pyx_k_pyx_PickleError, sizeof(__pyx_k_pyx_PickleError), 0, 0, 1, 1},
27960   {&__pyx_n_s_pyx_checksum, __pyx_k_pyx_checksum, sizeof(__pyx_k_pyx_checksum), 0, 0, 1, 1},
27961   {&__pyx_n_s_pyx_getbuffer, __pyx_k_pyx_getbuffer, sizeof(__pyx_k_pyx_getbuffer), 0, 0, 1, 1},
27962   {&__pyx_n_s_pyx_result, __pyx_k_pyx_result, sizeof(__pyx_k_pyx_result), 0, 0, 1, 1},
27963   {&__pyx_n_s_pyx_state, __pyx_k_pyx_state, sizeof(__pyx_k_pyx_state), 0, 0, 1, 1},
27964   {&__pyx_n_s_pyx_type, __pyx_k_pyx_type, sizeof(__pyx_k_pyx_type), 0, 0, 1, 1},
27965   {&__pyx_n_s_pyx_unpickle_Enum, __pyx_k_pyx_unpickle_Enum, sizeof(__pyx_k_pyx_unpickle_Enum), 0, 0, 1, 1},
27966   {&__pyx_n_s_pyx_vtable, __pyx_k_pyx_vtable, sizeof(__pyx_k_pyx_vtable), 0, 0, 1, 1},
27967   {&__pyx_n_s_qutip_cy_brtools, __pyx_k_qutip_cy_brtools, sizeof(__pyx_k_qutip_cy_brtools), 0, 0, 1, 1},
27968   {&__pyx_kp_s_qutip_cy_brtools_pyx, __pyx_k_qutip_cy_brtools_pyx, sizeof(__pyx_k_qutip_cy_brtools_pyx), 0, 0, 1, 0},
27969   {&__pyx_n_s_qutip_fastsparse, __pyx_k_qutip_fastsparse, sizeof(__pyx_k_qutip_fastsparse), 0, 0, 1, 1},
27970   {&__pyx_n_s_qutip_settings, __pyx_k_qutip_settings, sizeof(__pyx_k_qutip_settings), 0, 0, 1, 1},
27971   {&__pyx_n_s_range, __pyx_k_range, sizeof(__pyx_k_range), 0, 0, 1, 1},
27972   {&__pyx_n_s_reduce, __pyx_k_reduce, sizeof(__pyx_k_reduce), 0, 0, 1, 1},
27973   {&__pyx_n_s_reduce_cython, __pyx_k_reduce_cython, sizeof(__pyx_k_reduce_cython), 0, 0, 1, 1},
27974   {&__pyx_n_s_reduce_ex, __pyx_k_reduce_ex, sizeof(__pyx_k_reduce_ex), 0, 0, 1, 1},
27975   {&__pyx_n_s_row, __pyx_k_row, sizeof(__pyx_k_row), 0, 0, 1, 1},
27976   {&__pyx_kp_u_s, __pyx_k_s, sizeof(__pyx_k_s), 0, 1, 0, 0},
27977   {&__pyx_n_s_scipy_sparse, __pyx_k_scipy_sparse, sizeof(__pyx_k_scipy_sparse), 0, 0, 1, 1},
27978   {&__pyx_n_s_setstate, __pyx_k_setstate, sizeof(__pyx_k_setstate), 0, 0, 1, 1},
27979   {&__pyx_n_s_setstate_cython, __pyx_k_setstate_cython, sizeof(__pyx_k_setstate_cython), 0, 0, 1, 1},
27980   {&__pyx_n_s_shape, __pyx_k_shape, sizeof(__pyx_k_shape), 0, 0, 1, 1},
27981   {&__pyx_n_s_size, __pyx_k_size, sizeof(__pyx_k_size), 0, 0, 1, 1},
27982   {&__pyx_n_s_start, __pyx_k_start, sizeof(__pyx_k_start), 0, 0, 1, 1},
27983   {&__pyx_n_s_step, __pyx_k_step, sizeof(__pyx_k_step), 0, 0, 1, 1},
27984   {&__pyx_n_s_stop, __pyx_k_stop, sizeof(__pyx_k_stop), 0, 0, 1, 1},
27985   {&__pyx_kp_s_strided_and_direct, __pyx_k_strided_and_direct, sizeof(__pyx_k_strided_and_direct), 0, 0, 1, 0},
27986   {&__pyx_kp_s_strided_and_direct_or_indirect, __pyx_k_strided_and_direct_or_indirect, sizeof(__pyx_k_strided_and_direct_or_indirect), 0, 0, 1, 0},
27987   {&__pyx_kp_s_strided_and_indirect, __pyx_k_strided_and_indirect, sizeof(__pyx_k_strided_and_indirect), 0, 0, 1, 0},
27988   {&__pyx_kp_s_stringsource, __pyx_k_stringsource, sizeof(__pyx_k_stringsource), 0, 0, 1, 0},
27989   {&__pyx_n_s_struct, __pyx_k_struct, sizeof(__pyx_k_struct), 0, 0, 1, 1},
27990   {&__pyx_n_s_test, __pyx_k_test, sizeof(__pyx_k_test), 0, 0, 1, 1},
27991   {&__pyx_kp_s_unable_to_allocate_array_data, __pyx_k_unable_to_allocate_array_data, sizeof(__pyx_k_unable_to_allocate_array_data), 0, 0, 1, 0},
27992   {&__pyx_kp_s_unable_to_allocate_shape_and_str, __pyx_k_unable_to_allocate_shape_and_str, sizeof(__pyx_k_unable_to_allocate_shape_and_str), 0, 0, 1, 0},
27993   {&__pyx_n_s_unpack, __pyx_k_unpack, sizeof(__pyx_k_unpack), 0, 0, 1, 1},
27994   {&__pyx_n_s_update, __pyx_k_update, sizeof(__pyx_k_update), 0, 0, 1, 1},
27995   {&__pyx_n_s_val1, __pyx_k_val1, sizeof(__pyx_k_val1), 0, 0, 1, 1},
27996   {&__pyx_n_s_val2, __pyx_k_val2, sizeof(__pyx_k_val2), 0, 0, 1, 1},
27997   {0, 0, 0, 0, 0, 0, 0}
27998 };
__Pyx_InitCachedBuiltins(void)27999 static CYTHON_SMALL_CODE int __Pyx_InitCachedBuiltins(void) {
28000   __pyx_builtin_MemoryError = __Pyx_GetBuiltinName(__pyx_n_s_MemoryError); if (!__pyx_builtin_MemoryError) __PYX_ERR(0, 66, __pyx_L1_error)
28001   __pyx_builtin_range = __Pyx_GetBuiltinName(__pyx_n_s_range); if (!__pyx_builtin_range) __PYX_ERR(0, 175, __pyx_L1_error)
28002   __pyx_builtin_ImportError = __Pyx_GetBuiltinName(__pyx_n_s_ImportError); if (!__pyx_builtin_ImportError) __PYX_ERR(2, 884, __pyx_L1_error)
28003   __pyx_builtin_ValueError = __Pyx_GetBuiltinName(__pyx_n_s_ValueError); if (!__pyx_builtin_ValueError) __PYX_ERR(3, 133, __pyx_L1_error)
28004   __pyx_builtin_enumerate = __Pyx_GetBuiltinName(__pyx_n_s_enumerate); if (!__pyx_builtin_enumerate) __PYX_ERR(3, 151, __pyx_L1_error)
28005   __pyx_builtin_TypeError = __Pyx_GetBuiltinName(__pyx_n_s_TypeError); if (!__pyx_builtin_TypeError) __PYX_ERR(3, 2, __pyx_L1_error)
28006   __pyx_builtin_Ellipsis = __Pyx_GetBuiltinName(__pyx_n_s_Ellipsis); if (!__pyx_builtin_Ellipsis) __PYX_ERR(3, 404, __pyx_L1_error)
28007   __pyx_builtin_id = __Pyx_GetBuiltinName(__pyx_n_s_id); if (!__pyx_builtin_id) __PYX_ERR(3, 613, __pyx_L1_error)
28008   __pyx_builtin_IndexError = __Pyx_GetBuiltinName(__pyx_n_s_IndexError); if (!__pyx_builtin_IndexError) __PYX_ERR(3, 832, __pyx_L1_error)
28009   return 0;
28010   __pyx_L1_error:;
28011   return -1;
28012 }
28013 
__Pyx_InitCachedConstants(void)28014 static CYTHON_SMALL_CODE int __Pyx_InitCachedConstants(void) {
28015   __Pyx_RefNannyDeclarations
28016   __Pyx_RefNannySetupContext("__Pyx_InitCachedConstants", 0);
28017 
28018   /* "qutip/cy/sparse_routines.pxi":66
28019  *         free_CSR(C)
28020  *     if E == -1:
28021  *         raise MemoryError('Could not allocate memory.')             # <<<<<<<<<<<<<<
28022  *     elif E == -2:
28023  *         raise Exception('Error manipulating CSR_Matrix structure.')
28024  */
28025   __pyx_tuple_ = PyTuple_Pack(1, __pyx_kp_u_Could_not_allocate_memory); if (unlikely(!__pyx_tuple_)) __PYX_ERR(0, 66, __pyx_L1_error)
28026   __Pyx_GOTREF(__pyx_tuple_);
28027   __Pyx_GIVEREF(__pyx_tuple_);
28028 
28029   /* "qutip/cy/sparse_routines.pxi":68
28030  *         raise MemoryError('Could not allocate memory.')
28031  *     elif E == -2:
28032  *         raise Exception('Error manipulating CSR_Matrix structure.')             # <<<<<<<<<<<<<<
28033  *     elif E == -3:
28034  *         raise Exception('CSR_Matrix is not initialized.')
28035  */
28036   __pyx_tuple__2 = PyTuple_Pack(1, __pyx_kp_u_Error_manipulating_CSR_Matrix_st); if (unlikely(!__pyx_tuple__2)) __PYX_ERR(0, 68, __pyx_L1_error)
28037   __Pyx_GOTREF(__pyx_tuple__2);
28038   __Pyx_GIVEREF(__pyx_tuple__2);
28039 
28040   /* "qutip/cy/sparse_routines.pxi":70
28041  *         raise Exception('Error manipulating CSR_Matrix structure.')
28042  *     elif E == -3:
28043  *         raise Exception('CSR_Matrix is not initialized.')             # <<<<<<<<<<<<<<
28044  *     elif E == -4:
28045  *         raise Exception('NumPy already has lock on data.')
28046  */
28047   __pyx_tuple__3 = PyTuple_Pack(1, __pyx_kp_u_CSR_Matrix_is_not_initialized); if (unlikely(!__pyx_tuple__3)) __PYX_ERR(0, 70, __pyx_L1_error)
28048   __Pyx_GOTREF(__pyx_tuple__3);
28049   __Pyx_GIVEREF(__pyx_tuple__3);
28050 
28051   /* "qutip/cy/sparse_routines.pxi":72
28052  *         raise Exception('CSR_Matrix is not initialized.')
28053  *     elif E == -4:
28054  *         raise Exception('NumPy already has lock on data.')             # <<<<<<<<<<<<<<
28055  *     elif E == -5:
28056  *         raise Exception('Cannot expand data structures past max_length.')
28057  */
28058   __pyx_tuple__4 = PyTuple_Pack(1, __pyx_kp_u_NumPy_already_has_lock_on_data); if (unlikely(!__pyx_tuple__4)) __PYX_ERR(0, 72, __pyx_L1_error)
28059   __Pyx_GOTREF(__pyx_tuple__4);
28060   __Pyx_GIVEREF(__pyx_tuple__4);
28061 
28062   /* "qutip/cy/sparse_routines.pxi":74
28063  *         raise Exception('NumPy already has lock on data.')
28064  *     elif E == -5:
28065  *         raise Exception('Cannot expand data structures past max_length.')             # <<<<<<<<<<<<<<
28066  *     elif E == -6:
28067  *         raise Exception('CSR_Matrix cannot be expanded.')
28068  */
28069   __pyx_tuple__5 = PyTuple_Pack(1, __pyx_kp_u_Cannot_expand_data_structures_pa); if (unlikely(!__pyx_tuple__5)) __PYX_ERR(0, 74, __pyx_L1_error)
28070   __Pyx_GOTREF(__pyx_tuple__5);
28071   __Pyx_GIVEREF(__pyx_tuple__5);
28072 
28073   /* "qutip/cy/sparse_routines.pxi":76
28074  *         raise Exception('Cannot expand data structures past max_length.')
28075  *     elif E == -6:
28076  *         raise Exception('CSR_Matrix cannot be expanded.')             # <<<<<<<<<<<<<<
28077  *     elif E == -7:
28078  *         raise Exception('Data length cannot be larger than max_length')
28079  */
28080   __pyx_tuple__6 = PyTuple_Pack(1, __pyx_kp_u_CSR_Matrix_cannot_be_expanded); if (unlikely(!__pyx_tuple__6)) __PYX_ERR(0, 76, __pyx_L1_error)
28081   __Pyx_GOTREF(__pyx_tuple__6);
28082   __Pyx_GIVEREF(__pyx_tuple__6);
28083 
28084   /* "qutip/cy/sparse_routines.pxi":78
28085  *         raise Exception('CSR_Matrix cannot be expanded.')
28086  *     elif E == -7:
28087  *         raise Exception('Data length cannot be larger than max_length')             # <<<<<<<<<<<<<<
28088  *     else:
28089  *         raise Exception('Error in Cython code.')
28090  */
28091   __pyx_tuple__7 = PyTuple_Pack(1, __pyx_kp_u_Data_length_cannot_be_larger_tha); if (unlikely(!__pyx_tuple__7)) __PYX_ERR(0, 78, __pyx_L1_error)
28092   __Pyx_GOTREF(__pyx_tuple__7);
28093   __Pyx_GIVEREF(__pyx_tuple__7);
28094 
28095   /* "qutip/cy/sparse_routines.pxi":80
28096  *         raise Exception('Data length cannot be larger than max_length')
28097  *     else:
28098  *         raise Exception('Error in Cython code.')             # <<<<<<<<<<<<<<
28099  *
28100  *
28101  */
28102   __pyx_tuple__8 = PyTuple_Pack(1, __pyx_kp_u_Error_in_Cython_code); if (unlikely(!__pyx_tuple__8)) __PYX_ERR(0, 80, __pyx_L1_error)
28103   __Pyx_GOTREF(__pyx_tuple__8);
28104   __Pyx_GIVEREF(__pyx_tuple__8);
28105 
28106   /* "qutip/cy/sparse_routines.pxi":89
28107  *         raise MemoryError('Could not allocate memory.')
28108  *     elif E == -2:
28109  *         raise Exception('Error manipulating COO_Matrix structure.')             # <<<<<<<<<<<<<<
28110  *     elif E == -3:
28111  *         raise Exception('COO_Matrix is not initialized.')
28112  */
28113   __pyx_tuple__9 = PyTuple_Pack(1, __pyx_kp_u_Error_manipulating_COO_Matrix_st); if (unlikely(!__pyx_tuple__9)) __PYX_ERR(0, 89, __pyx_L1_error)
28114   __Pyx_GOTREF(__pyx_tuple__9);
28115   __Pyx_GIVEREF(__pyx_tuple__9);
28116 
28117   /* "qutip/cy/sparse_routines.pxi":91
28118  *         raise Exception('Error manipulating COO_Matrix structure.')
28119  *     elif E == -3:
28120  *         raise Exception('COO_Matrix is not initialized.')             # <<<<<<<<<<<<<<
28121  *     elif E == -4:
28122  *         raise Exception('NumPy already has lock on data.')
28123  */
28124   __pyx_tuple__10 = PyTuple_Pack(1, __pyx_kp_u_COO_Matrix_is_not_initialized); if (unlikely(!__pyx_tuple__10)) __PYX_ERR(0, 91, __pyx_L1_error)
28125   __Pyx_GOTREF(__pyx_tuple__10);
28126   __Pyx_GIVEREF(__pyx_tuple__10);
28127 
28128   /* "qutip/cy/sparse_routines.pxi":97
28129  *         raise Exception('Cannot expand data structures past max_length.')
28130  *     elif E == -6:
28131  *         raise Exception('COO_Matrix cannot be expanded.')             # <<<<<<<<<<<<<<
28132  *     elif E == -7:
28133  *         raise Exception('Data length cannot be larger than max_length')
28134  */
28135   __pyx_tuple__11 = PyTuple_Pack(1, __pyx_kp_u_COO_Matrix_cannot_be_expanded); if (unlikely(!__pyx_tuple__11)) __PYX_ERR(0, 97, __pyx_L1_error)
28136   __Pyx_GOTREF(__pyx_tuple__11);
28137   __Pyx_GIVEREF(__pyx_tuple__11);
28138 
28139   /* "qutip/cy/brtools.pyx":157
28140  *             raise Exception("Error in parameter : %s" & abs(info))
28141  *         else:
28142  *             raise Exception("Algorithm failed to converge")             # <<<<<<<<<<<<<<
28143  *
28144  *
28145  */
28146   __pyx_tuple__12 = PyTuple_Pack(1, __pyx_kp_u_Algorithm_failed_to_converge); if (unlikely(!__pyx_tuple__12)) __PYX_ERR(1, 157, __pyx_L1_error)
28147   __Pyx_GOTREF(__pyx_tuple__12);
28148   __Pyx_GIVEREF(__pyx_tuple__12);
28149 
28150   /* "qutip/cy/brtools.pyx":322
28151  *         tA = b'C'
28152  *     else:
28153  *         raise Exception('Invalid transA value.')             # <<<<<<<<<<<<<<
28154  *     if transB == 0:
28155  *         tB = b'N'
28156  */
28157   __pyx_tuple__15 = PyTuple_Pack(1, __pyx_kp_u_Invalid_transA_value); if (unlikely(!__pyx_tuple__15)) __PYX_ERR(1, 322, __pyx_L1_error)
28158   __Pyx_GOTREF(__pyx_tuple__15);
28159   __Pyx_GIVEREF(__pyx_tuple__15);
28160 
28161   /* "qutip/cy/brtools.pyx":330
28162  *         tB = b'C'
28163  *     else:
28164  *         raise Exception('Invalid transB value.')             # <<<<<<<<<<<<<<
28165  *
28166  *     zgemm(&tA, &tB, &Arows, &Bcols, &Brows, &alpha, A, &Arows, B, &Brows, &beta, C, &Arows)
28167  */
28168   __pyx_tuple__16 = PyTuple_Pack(1, __pyx_kp_u_Invalid_transB_value); if (unlikely(!__pyx_tuple__16)) __PYX_ERR(1, 330, __pyx_L1_error)
28169   __Pyx_GOTREF(__pyx_tuple__16);
28170   __Pyx_GIVEREF(__pyx_tuple__16);
28171 
28172   /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":884
28173  *         __pyx_import_array()
28174  *     except Exception:
28175  *         raise ImportError("numpy.core.multiarray failed to import")             # <<<<<<<<<<<<<<
28176  *
28177  * cdef inline int import_umath() except -1:
28178  */
28179   __pyx_tuple__19 = PyTuple_Pack(1, __pyx_kp_u_numpy_core_multiarray_failed_to); if (unlikely(!__pyx_tuple__19)) __PYX_ERR(2, 884, __pyx_L1_error)
28180   __Pyx_GOTREF(__pyx_tuple__19);
28181   __Pyx_GIVEREF(__pyx_tuple__19);
28182 
28183   /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":890
28184  *         _import_umath()
28185  *     except Exception:
28186  *         raise ImportError("numpy.core.umath failed to import")             # <<<<<<<<<<<<<<
28187  *
28188  * cdef inline int import_ufunc() except -1:
28189  */
28190   __pyx_tuple__20 = PyTuple_Pack(1, __pyx_kp_u_numpy_core_umath_failed_to_impor); if (unlikely(!__pyx_tuple__20)) __PYX_ERR(2, 890, __pyx_L1_error)
28191   __Pyx_GOTREF(__pyx_tuple__20);
28192   __Pyx_GIVEREF(__pyx_tuple__20);
28193 
28194   /* "View.MemoryView":133
28195  *
28196  *         if not self.ndim:
28197  *             raise ValueError("Empty shape tuple for cython.array")             # <<<<<<<<<<<<<<
28198  *
28199  *         if itemsize <= 0:
28200  */
28201   __pyx_tuple__21 = PyTuple_Pack(1, __pyx_kp_s_Empty_shape_tuple_for_cython_arr); if (unlikely(!__pyx_tuple__21)) __PYX_ERR(3, 133, __pyx_L1_error)
28202   __Pyx_GOTREF(__pyx_tuple__21);
28203   __Pyx_GIVEREF(__pyx_tuple__21);
28204 
28205   /* "View.MemoryView":136
28206  *
28207  *         if itemsize <= 0:
28208  *             raise ValueError("itemsize <= 0 for cython.array")             # <<<<<<<<<<<<<<
28209  *
28210  *         if not isinstance(format, bytes):
28211  */
28212   __pyx_tuple__22 = PyTuple_Pack(1, __pyx_kp_s_itemsize_0_for_cython_array); if (unlikely(!__pyx_tuple__22)) __PYX_ERR(3, 136, __pyx_L1_error)
28213   __Pyx_GOTREF(__pyx_tuple__22);
28214   __Pyx_GIVEREF(__pyx_tuple__22);
28215 
28216   /* "View.MemoryView":148
28217  *
28218  *         if not self._shape:
28219  *             raise MemoryError("unable to allocate shape and strides.")             # <<<<<<<<<<<<<<
28220  *
28221  *
28222  */
28223   __pyx_tuple__23 = PyTuple_Pack(1, __pyx_kp_s_unable_to_allocate_shape_and_str); if (unlikely(!__pyx_tuple__23)) __PYX_ERR(3, 148, __pyx_L1_error)
28224   __Pyx_GOTREF(__pyx_tuple__23);
28225   __Pyx_GIVEREF(__pyx_tuple__23);
28226 
28227   /* "View.MemoryView":176
28228  *             self.data = <char *>malloc(self.len)
28229  *             if not self.data:
28230  *                 raise MemoryError("unable to allocate array data.")             # <<<<<<<<<<<<<<
28231  *
28232  *             if self.dtype_is_object:
28233  */
28234   __pyx_tuple__24 = PyTuple_Pack(1, __pyx_kp_s_unable_to_allocate_array_data); if (unlikely(!__pyx_tuple__24)) __PYX_ERR(3, 176, __pyx_L1_error)
28235   __Pyx_GOTREF(__pyx_tuple__24);
28236   __Pyx_GIVEREF(__pyx_tuple__24);
28237 
28238   /* "View.MemoryView":192
28239  *             bufmode = PyBUF_F_CONTIGUOUS | PyBUF_ANY_CONTIGUOUS
28240  *         if not (flags & bufmode):
28241  *             raise ValueError("Can only create a buffer that is contiguous in memory.")             # <<<<<<<<<<<<<<
28242  *         info.buf = self.data
28243  *         info.len = self.len
28244  */
28245   __pyx_tuple__25 = PyTuple_Pack(1, __pyx_kp_s_Can_only_create_a_buffer_that_is); if (unlikely(!__pyx_tuple__25)) __PYX_ERR(3, 192, __pyx_L1_error)
28246   __Pyx_GOTREF(__pyx_tuple__25);
28247   __Pyx_GIVEREF(__pyx_tuple__25);
28248 
28249   /* "(tree fragment)":2
28250  * def __reduce_cython__(self):
28251  *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")             # <<<<<<<<<<<<<<
28252  * def __setstate_cython__(self, __pyx_state):
28253  *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
28254  */
28255   __pyx_tuple__26 = PyTuple_Pack(1, __pyx_kp_s_no_default___reduce___due_to_non); if (unlikely(!__pyx_tuple__26)) __PYX_ERR(3, 2, __pyx_L1_error)
28256   __Pyx_GOTREF(__pyx_tuple__26);
28257   __Pyx_GIVEREF(__pyx_tuple__26);
28258 
28259   /* "(tree fragment)":4
28260  *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
28261  * def __setstate_cython__(self, __pyx_state):
28262  *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")             # <<<<<<<<<<<<<<
28263  */
28264   __pyx_tuple__27 = PyTuple_Pack(1, __pyx_kp_s_no_default___reduce___due_to_non); if (unlikely(!__pyx_tuple__27)) __PYX_ERR(3, 4, __pyx_L1_error)
28265   __Pyx_GOTREF(__pyx_tuple__27);
28266   __Pyx_GIVEREF(__pyx_tuple__27);
28267 
28268   /* "View.MemoryView":418
28269  *     def __setitem__(memoryview self, object index, object value):
28270  *         if self.view.readonly:
28271  *             raise TypeError("Cannot assign to read-only memoryview")             # <<<<<<<<<<<<<<
28272  *
28273  *         have_slices, index = _unellipsify(index, self.view.ndim)
28274  */
28275   __pyx_tuple__28 = PyTuple_Pack(1, __pyx_kp_s_Cannot_assign_to_read_only_memor); if (unlikely(!__pyx_tuple__28)) __PYX_ERR(3, 418, __pyx_L1_error)
28276   __Pyx_GOTREF(__pyx_tuple__28);
28277   __Pyx_GIVEREF(__pyx_tuple__28);
28278 
28279   /* "View.MemoryView":495
28280  *             result = struct.unpack(self.view.format, bytesitem)
28281  *         except struct.error:
28282  *             raise ValueError("Unable to convert item to object")             # <<<<<<<<<<<<<<
28283  *         else:
28284  *             if len(self.view.format) == 1:
28285  */
28286   __pyx_tuple__29 = PyTuple_Pack(1, __pyx_kp_s_Unable_to_convert_item_to_object); if (unlikely(!__pyx_tuple__29)) __PYX_ERR(3, 495, __pyx_L1_error)
28287   __Pyx_GOTREF(__pyx_tuple__29);
28288   __Pyx_GIVEREF(__pyx_tuple__29);
28289 
28290   /* "View.MemoryView":520
28291  *     def __getbuffer__(self, Py_buffer *info, int flags):
28292  *         if flags & PyBUF_WRITABLE and self.view.readonly:
28293  *             raise ValueError("Cannot create writable memory view from read-only memoryview")             # <<<<<<<<<<<<<<
28294  *
28295  *         if flags & PyBUF_ND:
28296  */
28297   __pyx_tuple__30 = PyTuple_Pack(1, __pyx_kp_s_Cannot_create_writable_memory_vi); if (unlikely(!__pyx_tuple__30)) __PYX_ERR(3, 520, __pyx_L1_error)
28298   __Pyx_GOTREF(__pyx_tuple__30);
28299   __Pyx_GIVEREF(__pyx_tuple__30);
28300 
28301   /* "View.MemoryView":570
28302  *         if self.view.strides == NULL:
28303  *
28304  *             raise ValueError("Buffer view does not expose strides")             # <<<<<<<<<<<<<<
28305  *
28306  *         return tuple([stride for stride in self.view.strides[:self.view.ndim]])
28307  */
28308   __pyx_tuple__31 = PyTuple_Pack(1, __pyx_kp_s_Buffer_view_does_not_expose_stri); if (unlikely(!__pyx_tuple__31)) __PYX_ERR(3, 570, __pyx_L1_error)
28309   __Pyx_GOTREF(__pyx_tuple__31);
28310   __Pyx_GIVEREF(__pyx_tuple__31);
28311 
28312   /* "View.MemoryView":577
28313  *     def suboffsets(self):
28314  *         if self.view.suboffsets == NULL:
28315  *             return (-1,) * self.view.ndim             # <<<<<<<<<<<<<<
28316  *
28317  *         return tuple([suboffset for suboffset in self.view.suboffsets[:self.view.ndim]])
28318  */
28319   __pyx_tuple__32 = PyTuple_New(1); if (unlikely(!__pyx_tuple__32)) __PYX_ERR(3, 577, __pyx_L1_error)
28320   __Pyx_GOTREF(__pyx_tuple__32);
28321   __Pyx_INCREF(__pyx_int_neg_1);
28322   __Pyx_GIVEREF(__pyx_int_neg_1);
28323   PyTuple_SET_ITEM(__pyx_tuple__32, 0, __pyx_int_neg_1);
28324   __Pyx_GIVEREF(__pyx_tuple__32);
28325 
28326   /* "(tree fragment)":2
28327  * def __reduce_cython__(self):
28328  *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")             # <<<<<<<<<<<<<<
28329  * def __setstate_cython__(self, __pyx_state):
28330  *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
28331  */
28332   __pyx_tuple__33 = PyTuple_Pack(1, __pyx_kp_s_no_default___reduce___due_to_non); if (unlikely(!__pyx_tuple__33)) __PYX_ERR(3, 2, __pyx_L1_error)
28333   __Pyx_GOTREF(__pyx_tuple__33);
28334   __Pyx_GIVEREF(__pyx_tuple__33);
28335 
28336   /* "(tree fragment)":4
28337  *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
28338  * def __setstate_cython__(self, __pyx_state):
28339  *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")             # <<<<<<<<<<<<<<
28340  */
28341   __pyx_tuple__34 = PyTuple_Pack(1, __pyx_kp_s_no_default___reduce___due_to_non); if (unlikely(!__pyx_tuple__34)) __PYX_ERR(3, 4, __pyx_L1_error)
28342   __Pyx_GOTREF(__pyx_tuple__34);
28343   __Pyx_GIVEREF(__pyx_tuple__34);
28344 
28345   /* "View.MemoryView":682
28346  *         if item is Ellipsis:
28347  *             if not seen_ellipsis:
28348  *                 result.extend([slice(None)] * (ndim - len(tup) + 1))             # <<<<<<<<<<<<<<
28349  *                 seen_ellipsis = True
28350  *             else:
28351  */
28352   __pyx_slice__35 = PySlice_New(Py_None, Py_None, Py_None); if (unlikely(!__pyx_slice__35)) __PYX_ERR(3, 682, __pyx_L1_error)
28353   __Pyx_GOTREF(__pyx_slice__35);
28354   __Pyx_GIVEREF(__pyx_slice__35);
28355 
28356   /* "View.MemoryView":703
28357  *     for suboffset in suboffsets[:ndim]:
28358  *         if suboffset >= 0:
28359  *             raise ValueError("Indirect dimensions not supported")             # <<<<<<<<<<<<<<
28360  *
28361  *
28362  */
28363   __pyx_tuple__36 = PyTuple_Pack(1, __pyx_kp_s_Indirect_dimensions_not_supporte); if (unlikely(!__pyx_tuple__36)) __PYX_ERR(3, 703, __pyx_L1_error)
28364   __Pyx_GOTREF(__pyx_tuple__36);
28365   __Pyx_GIVEREF(__pyx_tuple__36);
28366 
28367   /* "(tree fragment)":2
28368  * def __reduce_cython__(self):
28369  *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")             # <<<<<<<<<<<<<<
28370  * def __setstate_cython__(self, __pyx_state):
28371  *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
28372  */
28373   __pyx_tuple__37 = PyTuple_Pack(1, __pyx_kp_s_no_default___reduce___due_to_non); if (unlikely(!__pyx_tuple__37)) __PYX_ERR(3, 2, __pyx_L1_error)
28374   __Pyx_GOTREF(__pyx_tuple__37);
28375   __Pyx_GIVEREF(__pyx_tuple__37);
28376 
28377   /* "(tree fragment)":4
28378  *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
28379  * def __setstate_cython__(self, __pyx_state):
28380  *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")             # <<<<<<<<<<<<<<
28381  */
28382   __pyx_tuple__38 = PyTuple_Pack(1, __pyx_kp_s_no_default___reduce___due_to_non); if (unlikely(!__pyx_tuple__38)) __PYX_ERR(3, 4, __pyx_L1_error)
28383   __Pyx_GOTREF(__pyx_tuple__38);
28384   __Pyx_GIVEREF(__pyx_tuple__38);
28385 
28386   /* "qutip/cy/brtools.pyx":249
28387  * @cython.boundscheck(False)
28388  * @cython.wraparound(False)
28389  * def liou_from_diag_ham(double[::1] diags):             # <<<<<<<<<<<<<<
28390  *     cdef unsigned int nrows = diags.shape[0]
28391  *     cdef np.ndarray[complex, ndim=1, mode='c'] data = np.empty(nrows**2, dtype=complex)
28392  */
28393   __pyx_tuple__44 = PyTuple_Pack(13, __pyx_n_s_diags, __pyx_n_s_diags, __pyx_n_s_nrows, __pyx_n_s_data, __pyx_n_s_ind, __pyx_n_s_ptr, __pyx_n_s_idx, __pyx_n_s_nnz, __pyx_n_s_ii, __pyx_n_s_jj, __pyx_n_s_val1, __pyx_n_s_val2, __pyx_n_s_ans); if (unlikely(!__pyx_tuple__44)) __PYX_ERR(1, 249, __pyx_L1_error)
28394   __Pyx_GOTREF(__pyx_tuple__44);
28395   __Pyx_GIVEREF(__pyx_tuple__44);
28396   __pyx_codeobj__45 = (PyObject*)__Pyx_PyCode_New(1, 0, 13, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__44, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_qutip_cy_brtools_pyx, __pyx_n_s_liou_from_diag_ham, 249, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__45)) __PYX_ERR(1, 249, __pyx_L1_error)
28397 
28398   /* "View.MemoryView":286
28399  *         return self.name
28400  *
28401  * cdef generic = Enum("<strided and direct or indirect>")             # <<<<<<<<<<<<<<
28402  * cdef strided = Enum("<strided and direct>") # default
28403  * cdef indirect = Enum("<strided and indirect>")
28404  */
28405   __pyx_tuple__46 = PyTuple_Pack(1, __pyx_kp_s_strided_and_direct_or_indirect); if (unlikely(!__pyx_tuple__46)) __PYX_ERR(3, 286, __pyx_L1_error)
28406   __Pyx_GOTREF(__pyx_tuple__46);
28407   __Pyx_GIVEREF(__pyx_tuple__46);
28408 
28409   /* "View.MemoryView":287
28410  *
28411  * cdef generic = Enum("<strided and direct or indirect>")
28412  * cdef strided = Enum("<strided and direct>") # default             # <<<<<<<<<<<<<<
28413  * cdef indirect = Enum("<strided and indirect>")
28414  *
28415  */
28416   __pyx_tuple__47 = PyTuple_Pack(1, __pyx_kp_s_strided_and_direct); if (unlikely(!__pyx_tuple__47)) __PYX_ERR(3, 287, __pyx_L1_error)
28417   __Pyx_GOTREF(__pyx_tuple__47);
28418   __Pyx_GIVEREF(__pyx_tuple__47);
28419 
28420   /* "View.MemoryView":288
28421  * cdef generic = Enum("<strided and direct or indirect>")
28422  * cdef strided = Enum("<strided and direct>") # default
28423  * cdef indirect = Enum("<strided and indirect>")             # <<<<<<<<<<<<<<
28424  *
28425  *
28426  */
28427   __pyx_tuple__48 = PyTuple_Pack(1, __pyx_kp_s_strided_and_indirect); if (unlikely(!__pyx_tuple__48)) __PYX_ERR(3, 288, __pyx_L1_error)
28428   __Pyx_GOTREF(__pyx_tuple__48);
28429   __Pyx_GIVEREF(__pyx_tuple__48);
28430 
28431   /* "View.MemoryView":291
28432  *
28433  *
28434  * cdef contiguous = Enum("<contiguous and direct>")             # <<<<<<<<<<<<<<
28435  * cdef indirect_contiguous = Enum("<contiguous and indirect>")
28436  *
28437  */
28438   __pyx_tuple__49 = PyTuple_Pack(1, __pyx_kp_s_contiguous_and_direct); if (unlikely(!__pyx_tuple__49)) __PYX_ERR(3, 291, __pyx_L1_error)
28439   __Pyx_GOTREF(__pyx_tuple__49);
28440   __Pyx_GIVEREF(__pyx_tuple__49);
28441 
28442   /* "View.MemoryView":292
28443  *
28444  * cdef contiguous = Enum("<contiguous and direct>")
28445  * cdef indirect_contiguous = Enum("<contiguous and indirect>")             # <<<<<<<<<<<<<<
28446  *
28447  *
28448  */
28449   __pyx_tuple__50 = PyTuple_Pack(1, __pyx_kp_s_contiguous_and_indirect); if (unlikely(!__pyx_tuple__50)) __PYX_ERR(3, 292, __pyx_L1_error)
28450   __Pyx_GOTREF(__pyx_tuple__50);
28451   __Pyx_GIVEREF(__pyx_tuple__50);
28452 
28453   /* "(tree fragment)":1
28454  * def __pyx_unpickle_Enum(__pyx_type, long __pyx_checksum, __pyx_state):             # <<<<<<<<<<<<<<
28455  *     cdef object __pyx_PickleError
28456  *     cdef object __pyx_result
28457  */
28458   __pyx_tuple__51 = PyTuple_Pack(5, __pyx_n_s_pyx_type, __pyx_n_s_pyx_checksum, __pyx_n_s_pyx_state, __pyx_n_s_pyx_PickleError, __pyx_n_s_pyx_result); if (unlikely(!__pyx_tuple__51)) __PYX_ERR(3, 1, __pyx_L1_error)
28459   __Pyx_GOTREF(__pyx_tuple__51);
28460   __Pyx_GIVEREF(__pyx_tuple__51);
28461   __pyx_codeobj__52 = (PyObject*)__Pyx_PyCode_New(3, 0, 5, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__51, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_stringsource, __pyx_n_s_pyx_unpickle_Enum, 1, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__52)) __PYX_ERR(3, 1, __pyx_L1_error)
28462   __Pyx_RefNannyFinishContext();
28463   return 0;
28464   __pyx_L1_error:;
28465   __Pyx_RefNannyFinishContext();
28466   return -1;
28467 }
28468 
__Pyx_InitGlobals(void)28469 static CYTHON_SMALL_CODE int __Pyx_InitGlobals(void) {
28470   if (__Pyx_InitStrings(__pyx_string_tab) < 0) __PYX_ERR(1, 1, __pyx_L1_error);
28471   __pyx_int_0 = PyInt_FromLong(0); if (unlikely(!__pyx_int_0)) __PYX_ERR(1, 1, __pyx_L1_error)
28472   __pyx_int_1 = PyInt_FromLong(1); if (unlikely(!__pyx_int_1)) __PYX_ERR(1, 1, __pyx_L1_error)
28473   __pyx_int_184977713 = PyInt_FromLong(184977713L); if (unlikely(!__pyx_int_184977713)) __PYX_ERR(1, 1, __pyx_L1_error)
28474   __pyx_int_neg_1 = PyInt_FromLong(-1); if (unlikely(!__pyx_int_neg_1)) __PYX_ERR(1, 1, __pyx_L1_error)
28475   return 0;
28476   __pyx_L1_error:;
28477   return -1;
28478 }
28479 
28480 static CYTHON_SMALL_CODE int __Pyx_modinit_global_init_code(void); /*proto*/
28481 static CYTHON_SMALL_CODE int __Pyx_modinit_variable_export_code(void); /*proto*/
28482 static CYTHON_SMALL_CODE int __Pyx_modinit_function_export_code(void); /*proto*/
28483 static CYTHON_SMALL_CODE int __Pyx_modinit_type_init_code(void); /*proto*/
28484 static CYTHON_SMALL_CODE int __Pyx_modinit_type_import_code(void); /*proto*/
28485 static CYTHON_SMALL_CODE int __Pyx_modinit_variable_import_code(void); /*proto*/
28486 static CYTHON_SMALL_CODE int __Pyx_modinit_function_import_code(void); /*proto*/
28487 
__Pyx_modinit_global_init_code(void)28488 static int __Pyx_modinit_global_init_code(void) {
28489   __Pyx_RefNannyDeclarations
28490   __Pyx_RefNannySetupContext("__Pyx_modinit_global_init_code", 0);
28491   /*--- Global init code ---*/
28492   generic = Py_None; Py_INCREF(Py_None);
28493   strided = Py_None; Py_INCREF(Py_None);
28494   indirect = Py_None; Py_INCREF(Py_None);
28495   contiguous = Py_None; Py_INCREF(Py_None);
28496   indirect_contiguous = Py_None; Py_INCREF(Py_None);
28497   __Pyx_RefNannyFinishContext();
28498   return 0;
28499 }
28500 
__Pyx_modinit_variable_export_code(void)28501 static int __Pyx_modinit_variable_export_code(void) {
28502   __Pyx_RefNannyDeclarations
28503   __Pyx_RefNannySetupContext("__Pyx_modinit_variable_export_code", 0);
28504   /*--- Variable export code ---*/
28505   __Pyx_RefNannyFinishContext();
28506   return 0;
28507 }
28508 
__Pyx_modinit_function_export_code(void)28509 static int __Pyx_modinit_function_export_code(void) {
28510   __Pyx_RefNannyDeclarations
28511   int __pyx_lineno = 0;
28512   const char *__pyx_filename = NULL;
28513   int __pyx_clineno = 0;
28514   __Pyx_RefNannySetupContext("__Pyx_modinit_function_export_code", 0);
28515   /*--- Function export code ---*/
28516   if (__Pyx_ExportFunction("farray_alloc", (void (*)(void))__pyx_f_5qutip_2cy_7brtools_farray_alloc, "__Pyx_memviewslice (int)") < 0) __PYX_ERR(1, 1, __pyx_L1_error)
28517   if (__Pyx_ExportFunction("dense_add_mult", (void (*)(void))__pyx_f_5qutip_2cy_7brtools_dense_add_mult, "void (__Pyx_memviewslice, __Pyx_memviewslice, __pyx_t_double_complex, int __pyx_skip_dispatch)") < 0) __PYX_ERR(1, 1, __pyx_L1_error)
28518   if (__Pyx_ExportFunction("ZHEEVR", (void (*)(void))__pyx_f_5qutip_2cy_7brtools_ZHEEVR, "void (__Pyx_memviewslice, double *, __Pyx_memviewslice, int)") < 0) __PYX_ERR(1, 1, __pyx_L1_error)
28519   if (__Pyx_ExportFunction("dense_to_eigbasis", (void (*)(void))__pyx_f_5qutip_2cy_7brtools_dense_to_eigbasis, "__Pyx_memviewslice (__Pyx_memviewslice, __Pyx_memviewslice, unsigned int, double)") < 0) __PYX_ERR(1, 1, __pyx_L1_error)
28520   if (__Pyx_ExportFunction("diag_liou_mult", (void (*)(void))__pyx_f_5qutip_2cy_7brtools_diag_liou_mult, "void (double *, __pyx_t_double_complex *, __pyx_t_double_complex *, unsigned int)") < 0) __PYX_ERR(1, 1, __pyx_L1_error)
28521   if (__Pyx_ExportFunction("vec_to_eigbasis", (void (*)(void))__pyx_f_5qutip_2cy_7brtools_vec_to_eigbasis, "__pyx_t_double_complex *(__Pyx_memviewslice, __Pyx_memviewslice, unsigned int)") < 0) __PYX_ERR(1, 1, __pyx_L1_error)
28522   if (__Pyx_ExportFunction("vec_to_fockbasis", (void (*)(void))__pyx_f_5qutip_2cy_7brtools_vec_to_fockbasis, "PyArrayObject *(__pyx_t_double_complex *, __Pyx_memviewslice, unsigned int)") < 0) __PYX_ERR(1, 1, __pyx_L1_error)
28523   if (__Pyx_ExportFunction("cop_super_mult", (void (*)(void))__pyx_f_5qutip_2cy_7brtools_cop_super_mult, "void (__Pyx_memviewslice, __Pyx_memviewslice, __pyx_t_double_complex *, __pyx_t_double_complex, __pyx_t_double_complex *, unsigned int, double)") < 0) __PYX_ERR(1, 1, __pyx_L1_error)
28524   if (__Pyx_ExportFunction("vec2mat_index", (void (*)(void))__pyx_f_5qutip_2cy_7brtools_vec2mat_index, "void (int, int, int *)") < 0) __PYX_ERR(1, 1, __pyx_L1_error)
28525   if (__Pyx_ExportFunction("skew_and_dwmin", (void (*)(void))__pyx_f_5qutip_2cy_7brtools_skew_and_dwmin, "double (double *, __Pyx_memviewslice, unsigned int)") < 0) __PYX_ERR(1, 1, __pyx_L1_error)
28526   if (__Pyx_ExportFunction("br_term_mult", (void (*)(void))__pyx_f_5qutip_2cy_7brtools_br_term_mult, "void (double, __Pyx_memviewslice, __Pyx_memviewslice, __Pyx_memviewslice, double, __pyx_t_5qutip_2cy_7brtools_spec_func, __pyx_t_double_complex *, __pyx_t_double_complex *, unsigned int, int, double, double)") < 0) __PYX_ERR(1, 1, __pyx_L1_error)
28527   __Pyx_RefNannyFinishContext();
28528   return 0;
28529   __pyx_L1_error:;
28530   __Pyx_RefNannyFinishContext();
28531   return -1;
28532 }
28533 
__Pyx_modinit_type_init_code(void)28534 static int __Pyx_modinit_type_init_code(void) {
28535   __Pyx_RefNannyDeclarations
28536   int __pyx_lineno = 0;
28537   const char *__pyx_filename = NULL;
28538   int __pyx_clineno = 0;
28539   __Pyx_RefNannySetupContext("__Pyx_modinit_type_init_code", 0);
28540   /*--- Type init code ---*/
28541   __pyx_vtabptr_array = &__pyx_vtable_array;
28542   __pyx_vtable_array.get_memview = (PyObject *(*)(struct __pyx_array_obj *))__pyx_array_get_memview;
28543   if (PyType_Ready(&__pyx_type___pyx_array) < 0) __PYX_ERR(3, 105, __pyx_L1_error)
28544   #if PY_VERSION_HEX < 0x030800B1
28545   __pyx_type___pyx_array.tp_print = 0;
28546   #endif
28547   if (__Pyx_SetVtable(__pyx_type___pyx_array.tp_dict, __pyx_vtabptr_array) < 0) __PYX_ERR(3, 105, __pyx_L1_error)
28548   if (__Pyx_setup_reduce((PyObject*)&__pyx_type___pyx_array) < 0) __PYX_ERR(3, 105, __pyx_L1_error)
28549   __pyx_array_type = &__pyx_type___pyx_array;
28550   if (PyType_Ready(&__pyx_type___pyx_MemviewEnum) < 0) __PYX_ERR(3, 279, __pyx_L1_error)
28551   #if PY_VERSION_HEX < 0x030800B1
28552   __pyx_type___pyx_MemviewEnum.tp_print = 0;
28553   #endif
28554   if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type___pyx_MemviewEnum.tp_dictoffset && __pyx_type___pyx_MemviewEnum.tp_getattro == PyObject_GenericGetAttr)) {
28555     __pyx_type___pyx_MemviewEnum.tp_getattro = __Pyx_PyObject_GenericGetAttr;
28556   }
28557   if (__Pyx_setup_reduce((PyObject*)&__pyx_type___pyx_MemviewEnum) < 0) __PYX_ERR(3, 279, __pyx_L1_error)
28558   __pyx_MemviewEnum_type = &__pyx_type___pyx_MemviewEnum;
28559   __pyx_vtabptr_memoryview = &__pyx_vtable_memoryview;
28560   __pyx_vtable_memoryview.get_item_pointer = (char *(*)(struct __pyx_memoryview_obj *, PyObject *))__pyx_memoryview_get_item_pointer;
28561   __pyx_vtable_memoryview.is_slice = (PyObject *(*)(struct __pyx_memoryview_obj *, PyObject *))__pyx_memoryview_is_slice;
28562   __pyx_vtable_memoryview.setitem_slice_assignment = (PyObject *(*)(struct __pyx_memoryview_obj *, PyObject *, PyObject *))__pyx_memoryview_setitem_slice_assignment;
28563   __pyx_vtable_memoryview.setitem_slice_assign_scalar = (PyObject *(*)(struct __pyx_memoryview_obj *, struct __pyx_memoryview_obj *, PyObject *))__pyx_memoryview_setitem_slice_assign_scalar;
28564   __pyx_vtable_memoryview.setitem_indexed = (PyObject *(*)(struct __pyx_memoryview_obj *, PyObject *, PyObject *))__pyx_memoryview_setitem_indexed;
28565   __pyx_vtable_memoryview.convert_item_to_object = (PyObject *(*)(struct __pyx_memoryview_obj *, char *))__pyx_memoryview_convert_item_to_object;
28566   __pyx_vtable_memoryview.assign_item_from_object = (PyObject *(*)(struct __pyx_memoryview_obj *, char *, PyObject *))__pyx_memoryview_assign_item_from_object;
28567   if (PyType_Ready(&__pyx_type___pyx_memoryview) < 0) __PYX_ERR(3, 330, __pyx_L1_error)
28568   #if PY_VERSION_HEX < 0x030800B1
28569   __pyx_type___pyx_memoryview.tp_print = 0;
28570   #endif
28571   if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type___pyx_memoryview.tp_dictoffset && __pyx_type___pyx_memoryview.tp_getattro == PyObject_GenericGetAttr)) {
28572     __pyx_type___pyx_memoryview.tp_getattro = __Pyx_PyObject_GenericGetAttr;
28573   }
28574   if (__Pyx_SetVtable(__pyx_type___pyx_memoryview.tp_dict, __pyx_vtabptr_memoryview) < 0) __PYX_ERR(3, 330, __pyx_L1_error)
28575   if (__Pyx_setup_reduce((PyObject*)&__pyx_type___pyx_memoryview) < 0) __PYX_ERR(3, 330, __pyx_L1_error)
28576   __pyx_memoryview_type = &__pyx_type___pyx_memoryview;
28577   __pyx_vtabptr__memoryviewslice = &__pyx_vtable__memoryviewslice;
28578   __pyx_vtable__memoryviewslice.__pyx_base = *__pyx_vtabptr_memoryview;
28579   __pyx_vtable__memoryviewslice.__pyx_base.convert_item_to_object = (PyObject *(*)(struct __pyx_memoryview_obj *, char *))__pyx_memoryviewslice_convert_item_to_object;
28580   __pyx_vtable__memoryviewslice.__pyx_base.assign_item_from_object = (PyObject *(*)(struct __pyx_memoryview_obj *, char *, PyObject *))__pyx_memoryviewslice_assign_item_from_object;
28581   __pyx_type___pyx_memoryviewslice.tp_base = __pyx_memoryview_type;
28582   if (PyType_Ready(&__pyx_type___pyx_memoryviewslice) < 0) __PYX_ERR(3, 965, __pyx_L1_error)
28583   #if PY_VERSION_HEX < 0x030800B1
28584   __pyx_type___pyx_memoryviewslice.tp_print = 0;
28585   #endif
28586   if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type___pyx_memoryviewslice.tp_dictoffset && __pyx_type___pyx_memoryviewslice.tp_getattro == PyObject_GenericGetAttr)) {
28587     __pyx_type___pyx_memoryviewslice.tp_getattro = __Pyx_PyObject_GenericGetAttr;
28588   }
28589   if (__Pyx_SetVtable(__pyx_type___pyx_memoryviewslice.tp_dict, __pyx_vtabptr__memoryviewslice) < 0) __PYX_ERR(3, 965, __pyx_L1_error)
28590   if (__Pyx_setup_reduce((PyObject*)&__pyx_type___pyx_memoryviewslice) < 0) __PYX_ERR(3, 965, __pyx_L1_error)
28591   __pyx_memoryviewslice_type = &__pyx_type___pyx_memoryviewslice;
28592   __Pyx_RefNannyFinishContext();
28593   return 0;
28594   __pyx_L1_error:;
28595   __Pyx_RefNannyFinishContext();
28596   return -1;
28597 }
28598 
__Pyx_modinit_type_import_code(void)28599 static int __Pyx_modinit_type_import_code(void) {
28600   __Pyx_RefNannyDeclarations
28601   PyObject *__pyx_t_1 = NULL;
28602   int __pyx_lineno = 0;
28603   const char *__pyx_filename = NULL;
28604   int __pyx_clineno = 0;
28605   __Pyx_RefNannySetupContext("__Pyx_modinit_type_import_code", 0);
28606   /*--- Type import code ---*/
28607   __pyx_t_1 = PyImport_ImportModule(__Pyx_BUILTIN_MODULE_NAME); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 9, __pyx_L1_error)
28608   __Pyx_GOTREF(__pyx_t_1);
28609   __pyx_ptype_7cpython_4type_type = __Pyx_ImportType(__pyx_t_1, __Pyx_BUILTIN_MODULE_NAME, "type",
28610   #if defined(PYPY_VERSION_NUM) && PYPY_VERSION_NUM < 0x050B0000
28611   sizeof(PyTypeObject),
28612   #else
28613   sizeof(PyHeapTypeObject),
28614   #endif
28615   __Pyx_ImportType_CheckSize_Warn);
28616    if (!__pyx_ptype_7cpython_4type_type) __PYX_ERR(4, 9, __pyx_L1_error)
28617   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
28618   __pyx_t_1 = PyImport_ImportModule("numpy"); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 199, __pyx_L1_error)
28619   __Pyx_GOTREF(__pyx_t_1);
28620   __pyx_ptype_5numpy_dtype = __Pyx_ImportType(__pyx_t_1, "numpy", "dtype", sizeof(PyArray_Descr), __Pyx_ImportType_CheckSize_Ignore);
28621    if (!__pyx_ptype_5numpy_dtype) __PYX_ERR(2, 199, __pyx_L1_error)
28622   __pyx_ptype_5numpy_flatiter = __Pyx_ImportType(__pyx_t_1, "numpy", "flatiter", sizeof(PyArrayIterObject), __Pyx_ImportType_CheckSize_Ignore);
28623    if (!__pyx_ptype_5numpy_flatiter) __PYX_ERR(2, 222, __pyx_L1_error)
28624   __pyx_ptype_5numpy_broadcast = __Pyx_ImportType(__pyx_t_1, "numpy", "broadcast", sizeof(PyArrayMultiIterObject), __Pyx_ImportType_CheckSize_Ignore);
28625    if (!__pyx_ptype_5numpy_broadcast) __PYX_ERR(2, 226, __pyx_L1_error)
28626   __pyx_ptype_5numpy_ndarray = __Pyx_ImportType(__pyx_t_1, "numpy", "ndarray", sizeof(PyArrayObject), __Pyx_ImportType_CheckSize_Ignore);
28627    if (!__pyx_ptype_5numpy_ndarray) __PYX_ERR(2, 238, __pyx_L1_error)
28628   __pyx_ptype_5numpy_ufunc = __Pyx_ImportType(__pyx_t_1, "numpy", "ufunc", sizeof(PyUFuncObject), __Pyx_ImportType_CheckSize_Ignore);
28629    if (!__pyx_ptype_5numpy_ufunc) __PYX_ERR(2, 764, __pyx_L1_error)
28630   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
28631   __Pyx_RefNannyFinishContext();
28632   return 0;
28633   __pyx_L1_error:;
28634   __Pyx_XDECREF(__pyx_t_1);
28635   __Pyx_RefNannyFinishContext();
28636   return -1;
28637 }
28638 
__Pyx_modinit_variable_import_code(void)28639 static int __Pyx_modinit_variable_import_code(void) {
28640   __Pyx_RefNannyDeclarations
28641   __Pyx_RefNannySetupContext("__Pyx_modinit_variable_import_code", 0);
28642   /*--- Variable import code ---*/
28643   __Pyx_RefNannyFinishContext();
28644   return 0;
28645 }
28646 
__Pyx_modinit_function_import_code(void)28647 static int __Pyx_modinit_function_import_code(void) {
28648   __Pyx_RefNannyDeclarations
28649   PyObject *__pyx_t_1 = NULL;
28650   int __pyx_lineno = 0;
28651   const char *__pyx_filename = NULL;
28652   int __pyx_clineno = 0;
28653   __Pyx_RefNannySetupContext("__Pyx_modinit_function_import_code", 0);
28654   /*--- Function import code ---*/
28655   __pyx_t_1 = PyImport_ImportModule("scipy.linalg.cython_lapack"); if (!__pyx_t_1) __PYX_ERR(1, 1, __pyx_L1_error)
28656   __Pyx_GOTREF(__pyx_t_1);
28657   if (__Pyx_ImportFunction(__pyx_t_1, "zgeev", (void (**)(void))&__pyx_f_5scipy_6linalg_13cython_lapack_zgeev, "void (char *, char *, int *, __pyx_t_double_complex *, int *, __pyx_t_double_complex *, __pyx_t_double_complex *, int *, __pyx_t_double_complex *, int *, __pyx_t_double_complex *, int *, __pyx_t_5scipy_6linalg_13cython_lapack_d *, int *)") < 0) __PYX_ERR(1, 1, __pyx_L1_error)
28658   if (__Pyx_ImportFunction(__pyx_t_1, "zheevr", (void (**)(void))&__pyx_f_5scipy_6linalg_13cython_lapack_zheevr, "void (char *, char *, char *, int *, __pyx_t_double_complex *, int *, __pyx_t_5scipy_6linalg_13cython_lapack_d *, __pyx_t_5scipy_6linalg_13cython_lapack_d *, int *, int *, __pyx_t_5scipy_6linalg_13cython_lapack_d *, int *, __pyx_t_5scipy_6linalg_13cython_lapack_d *, __pyx_t_double_complex *, int *, int *, __pyx_t_double_complex *, int *, __pyx_t_5scipy_6linalg_13cython_lapack_d *, int *, int *, int *, int *)") < 0) __PYX_ERR(1, 1, __pyx_L1_error)
28659   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
28660   __pyx_t_1 = PyImport_ImportModule("scipy.linalg.cython_blas"); if (!__pyx_t_1) __PYX_ERR(1, 1, __pyx_L1_error)
28661   __Pyx_GOTREF(__pyx_t_1);
28662   if (__Pyx_ImportFunction(__pyx_t_1, "zaxpy", (void (**)(void))&__pyx_f_5scipy_6linalg_11cython_blas_zaxpy, "void (int *, __pyx_t_double_complex *, __pyx_t_double_complex *, int *, __pyx_t_double_complex *, int *)") < 0) __PYX_ERR(1, 1, __pyx_L1_error)
28663   if (__Pyx_ImportFunction(__pyx_t_1, "zgemm", (void (**)(void))&__pyx_f_5scipy_6linalg_11cython_blas_zgemm, "void (char *, char *, int *, int *, int *, __pyx_t_double_complex *, __pyx_t_double_complex *, int *, __pyx_t_double_complex *, int *, __pyx_t_double_complex *, __pyx_t_double_complex *, int *)") < 0) __PYX_ERR(1, 1, __pyx_L1_error)
28664   if (__Pyx_ImportFunction(__pyx_t_1, "zgemv", (void (**)(void))&__pyx_f_5scipy_6linalg_11cython_blas_zgemv, "void (char *, int *, int *, __pyx_t_double_complex *, __pyx_t_double_complex *, int *, __pyx_t_double_complex *, int *, __pyx_t_double_complex *, __pyx_t_double_complex *, int *)") < 0) __PYX_ERR(1, 1, __pyx_L1_error)
28665   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
28666   __pyx_t_1 = PyImport_ImportModule("qutip.cy.spmath"); if (!__pyx_t_1) __PYX_ERR(1, 1, __pyx_L1_error)
28667   __Pyx_GOTREF(__pyx_t_1);
28668   if (__Pyx_ImportFunction(__pyx_t_1, "_safe_multiply", (void (**)(void))&__pyx_f_5qutip_2cy_6spmath__safe_multiply, "int (int, int)") < 0) __PYX_ERR(1, 1, __pyx_L1_error)
28669   if (__Pyx_ImportFunction(__pyx_t_1, "_zcsr_add", (void (**)(void))&__pyx_f_5qutip_2cy_6spmath__zcsr_add, "void (__pyx_t_5qutip_2cy_14sparse_structs_CSR_Matrix *, __pyx_t_5qutip_2cy_14sparse_structs_CSR_Matrix *, __pyx_t_5qutip_2cy_14sparse_structs_CSR_Matrix *, __pyx_t_double_complex)") < 0) __PYX_ERR(1, 1, __pyx_L1_error)
28670   if (__Pyx_ImportFunction(__pyx_t_1, "_zcsr_mult", (void (**)(void))&__pyx_f_5qutip_2cy_6spmath__zcsr_mult, "void (__pyx_t_5qutip_2cy_14sparse_structs_CSR_Matrix *, __pyx_t_5qutip_2cy_14sparse_structs_CSR_Matrix *, __pyx_t_5qutip_2cy_14sparse_structs_CSR_Matrix *)") < 0) __PYX_ERR(1, 1, __pyx_L1_error)
28671   if (__Pyx_ImportFunction(__pyx_t_1, "_zcsr_kron", (void (**)(void))&__pyx_f_5qutip_2cy_6spmath__zcsr_kron, "void (__pyx_t_5qutip_2cy_14sparse_structs_CSR_Matrix *, __pyx_t_5qutip_2cy_14sparse_structs_CSR_Matrix *, __pyx_t_5qutip_2cy_14sparse_structs_CSR_Matrix *)") < 0) __PYX_ERR(1, 1, __pyx_L1_error)
28672   if (__Pyx_ImportFunction(__pyx_t_1, "_zcsr_kron_core", (void (**)(void))&__pyx_f_5qutip_2cy_6spmath__zcsr_kron_core, "void (__pyx_t_double_complex *, int *, int *, __pyx_t_double_complex *, int *, int *, __pyx_t_5qutip_2cy_14sparse_structs_CSR_Matrix *, int, int, int)") < 0) __PYX_ERR(1, 1, __pyx_L1_error)
28673   if (__Pyx_ImportFunction(__pyx_t_1, "_zcsr_transpose", (void (**)(void))&__pyx_f_5qutip_2cy_6spmath__zcsr_transpose, "void (__pyx_t_5qutip_2cy_14sparse_structs_CSR_Matrix *, __pyx_t_5qutip_2cy_14sparse_structs_CSR_Matrix *)") < 0) __PYX_ERR(1, 1, __pyx_L1_error)
28674   if (__Pyx_ImportFunction(__pyx_t_1, "_zcsr_adjoint", (void (**)(void))&__pyx_f_5qutip_2cy_6spmath__zcsr_adjoint, "void (__pyx_t_5qutip_2cy_14sparse_structs_CSR_Matrix *, __pyx_t_5qutip_2cy_14sparse_structs_CSR_Matrix *)") < 0) __PYX_ERR(1, 1, __pyx_L1_error)
28675   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
28676   __pyx_t_1 = PyImport_ImportModule("qutip.cy.spconvert"); if (!__pyx_t_1) __PYX_ERR(1, 1, __pyx_L1_error)
28677   __Pyx_GOTREF(__pyx_t_1);
28678   if (__Pyx_ImportFunction(__pyx_t_1, "fdense2D_to_CSR", (void (**)(void))&__pyx_f_5qutip_2cy_9spconvert_fdense2D_to_CSR, "void (__Pyx_memviewslice, __pyx_t_5qutip_2cy_14sparse_structs_CSR_Matrix *, unsigned int, unsigned int)") < 0) __PYX_ERR(1, 1, __pyx_L1_error)
28679   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
28680   __pyx_t_1 = PyImport_ImportModule("qutip.cy.spmatfuncs"); if (!__pyx_t_1) __PYX_ERR(1, 1, __pyx_L1_error)
28681   __Pyx_GOTREF(__pyx_t_1);
28682   if (__Pyx_ImportFunction(__pyx_t_1, "spmvpy", (void (**)(void))&__pyx_f_5qutip_2cy_10spmatfuncs_spmvpy, "void (__pyx_t_double_complex *, int *, int *, __pyx_t_double_complex *, __pyx_t_double_complex, __pyx_t_double_complex *, unsigned int)") < 0) __PYX_ERR(1, 1, __pyx_L1_error)
28683   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
28684   __Pyx_RefNannyFinishContext();
28685   return 0;
28686   __pyx_L1_error:;
28687   __Pyx_XDECREF(__pyx_t_1);
28688   __Pyx_RefNannyFinishContext();
28689   return -1;
28690 }
28691 
28692 
28693 #ifndef CYTHON_NO_PYINIT_EXPORT
28694 #define __Pyx_PyMODINIT_FUNC PyMODINIT_FUNC
28695 #elif PY_MAJOR_VERSION < 3
28696 #ifdef __cplusplus
28697 #define __Pyx_PyMODINIT_FUNC extern "C" void
28698 #else
28699 #define __Pyx_PyMODINIT_FUNC void
28700 #endif
28701 #else
28702 #ifdef __cplusplus
28703 #define __Pyx_PyMODINIT_FUNC extern "C" PyObject *
28704 #else
28705 #define __Pyx_PyMODINIT_FUNC PyObject *
28706 #endif
28707 #endif
28708 
28709 
28710 #if PY_MAJOR_VERSION < 3
28711 __Pyx_PyMODINIT_FUNC initbrtools(void) CYTHON_SMALL_CODE; /*proto*/
initbrtools(void)28712 __Pyx_PyMODINIT_FUNC initbrtools(void)
28713 #else
28714 __Pyx_PyMODINIT_FUNC PyInit_brtools(void) CYTHON_SMALL_CODE; /*proto*/
28715 __Pyx_PyMODINIT_FUNC PyInit_brtools(void)
28716 #if CYTHON_PEP489_MULTI_PHASE_INIT
28717 {
28718   return PyModuleDef_Init(&__pyx_moduledef);
28719 }
28720 static CYTHON_SMALL_CODE int __Pyx_check_single_interpreter(void) {
28721     #if PY_VERSION_HEX >= 0x030700A1
28722     static PY_INT64_T main_interpreter_id = -1;
28723     PY_INT64_T current_id = PyInterpreterState_GetID(PyThreadState_Get()->interp);
28724     if (main_interpreter_id == -1) {
28725         main_interpreter_id = current_id;
28726         return (unlikely(current_id == -1)) ? -1 : 0;
28727     } else if (unlikely(main_interpreter_id != current_id))
28728     #else
28729     static PyInterpreterState *main_interpreter = NULL;
28730     PyInterpreterState *current_interpreter = PyThreadState_Get()->interp;
28731     if (!main_interpreter) {
28732         main_interpreter = current_interpreter;
28733     } else if (unlikely(main_interpreter != current_interpreter))
28734     #endif
28735     {
28736         PyErr_SetString(
28737             PyExc_ImportError,
28738             "Interpreter change detected - this module can only be loaded into one interpreter per process.");
28739         return -1;
28740     }
28741     return 0;
28742 }
28743 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) {
28744     PyObject *value = PyObject_GetAttrString(spec, from_name);
28745     int result = 0;
28746     if (likely(value)) {
28747         if (allow_none || value != Py_None) {
28748             result = PyDict_SetItemString(moddict, to_name, value);
28749         }
28750         Py_DECREF(value);
28751     } else if (PyErr_ExceptionMatches(PyExc_AttributeError)) {
28752         PyErr_Clear();
28753     } else {
28754         result = -1;
28755     }
28756     return result;
28757 }
28758 static CYTHON_SMALL_CODE PyObject* __pyx_pymod_create(PyObject *spec, CYTHON_UNUSED PyModuleDef *def) {
28759     PyObject *module = NULL, *moddict, *modname;
28760     if (__Pyx_check_single_interpreter())
28761         return NULL;
28762     if (__pyx_m)
28763         return __Pyx_NewRef(__pyx_m);
28764     modname = PyObject_GetAttrString(spec, "name");
28765     if (unlikely(!modname)) goto bad;
28766     module = PyModule_NewObject(modname);
28767     Py_DECREF(modname);
28768     if (unlikely(!module)) goto bad;
28769     moddict = PyModule_GetDict(module);
28770     if (unlikely(!moddict)) goto bad;
28771     if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "loader", "__loader__", 1) < 0)) goto bad;
28772     if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "origin", "__file__", 1) < 0)) goto bad;
28773     if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "parent", "__package__", 1) < 0)) goto bad;
28774     if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "submodule_search_locations", "__path__", 0) < 0)) goto bad;
28775     return module;
28776 bad:
28777     Py_XDECREF(module);
28778     return NULL;
28779 }
28780 
28781 
28782 static CYTHON_SMALL_CODE int __pyx_pymod_exec_brtools(PyObject *__pyx_pyinit_module)
28783 #endif
28784 #endif
28785 {
28786   PyObject *__pyx_t_1 = NULL;
28787   PyObject *__pyx_t_2 = NULL;
28788   int __pyx_t_3;
28789   static PyThread_type_lock __pyx_t_4[8];
28790   int __pyx_lineno = 0;
28791   const char *__pyx_filename = NULL;
28792   int __pyx_clineno = 0;
28793   __Pyx_RefNannyDeclarations
28794   #if CYTHON_PEP489_MULTI_PHASE_INIT
28795   if (__pyx_m) {
28796     if (__pyx_m == __pyx_pyinit_module) return 0;
28797     PyErr_SetString(PyExc_RuntimeError, "Module 'brtools' has already been imported. Re-initialisation is not supported.");
28798     return -1;
28799   }
28800   #elif PY_MAJOR_VERSION >= 3
28801   if (__pyx_m) return __Pyx_NewRef(__pyx_m);
28802   #endif
28803   #if CYTHON_REFNANNY
28804 __Pyx_RefNanny = __Pyx_RefNannyImportAPI("refnanny");
28805 if (!__Pyx_RefNanny) {
28806   PyErr_Clear();
28807   __Pyx_RefNanny = __Pyx_RefNannyImportAPI("Cython.Runtime.refnanny");
28808   if (!__Pyx_RefNanny)
28809       Py_FatalError("failed to import 'refnanny' module");
28810 }
28811 #endif
28812   __Pyx_RefNannySetupContext("__Pyx_PyMODINIT_FUNC PyInit_brtools(void)", 0);
28813   if (__Pyx_check_binary_version() < 0) __PYX_ERR(1, 1, __pyx_L1_error)
28814   #ifdef __Pxy_PyFrame_Initialize_Offsets
28815   __Pxy_PyFrame_Initialize_Offsets();
28816   #endif
28817   __pyx_empty_tuple = PyTuple_New(0); if (unlikely(!__pyx_empty_tuple)) __PYX_ERR(1, 1, __pyx_L1_error)
28818   __pyx_empty_bytes = PyBytes_FromStringAndSize("", 0); if (unlikely(!__pyx_empty_bytes)) __PYX_ERR(1, 1, __pyx_L1_error)
28819   __pyx_empty_unicode = PyUnicode_FromStringAndSize("", 0); if (unlikely(!__pyx_empty_unicode)) __PYX_ERR(1, 1, __pyx_L1_error)
28820   #ifdef __Pyx_CyFunction_USED
28821   if (__pyx_CyFunction_init() < 0) __PYX_ERR(1, 1, __pyx_L1_error)
28822   #endif
28823   #ifdef __Pyx_FusedFunction_USED
28824   if (__pyx_FusedFunction_init() < 0) __PYX_ERR(1, 1, __pyx_L1_error)
28825   #endif
28826   #ifdef __Pyx_Coroutine_USED
28827   if (__pyx_Coroutine_init() < 0) __PYX_ERR(1, 1, __pyx_L1_error)
28828   #endif
28829   #ifdef __Pyx_Generator_USED
28830   if (__pyx_Generator_init() < 0) __PYX_ERR(1, 1, __pyx_L1_error)
28831   #endif
28832   #ifdef __Pyx_AsyncGen_USED
28833   if (__pyx_AsyncGen_init() < 0) __PYX_ERR(1, 1, __pyx_L1_error)
28834   #endif
28835   #ifdef __Pyx_StopAsyncIteration_USED
28836   if (__pyx_StopAsyncIteration_init() < 0) __PYX_ERR(1, 1, __pyx_L1_error)
28837   #endif
28838   /*--- Library function declarations ---*/
28839   /*--- Threads initialization code ---*/
28840   #if defined(__PYX_FORCE_INIT_THREADS) && __PYX_FORCE_INIT_THREADS
28841   #ifdef WITH_THREAD /* Python build with threading support? */
28842   PyEval_InitThreads();
28843   #endif
28844   #endif
28845   /*--- Module creation code ---*/
28846   #if CYTHON_PEP489_MULTI_PHASE_INIT
28847   __pyx_m = __pyx_pyinit_module;
28848   Py_INCREF(__pyx_m);
28849   #else
28850   #if PY_MAJOR_VERSION < 3
28851   __pyx_m = Py_InitModule4("brtools", __pyx_methods, 0, 0, PYTHON_API_VERSION); Py_XINCREF(__pyx_m);
28852   #else
28853   __pyx_m = PyModule_Create(&__pyx_moduledef);
28854   #endif
28855   if (unlikely(!__pyx_m)) __PYX_ERR(1, 1, __pyx_L1_error)
28856   #endif
28857   __pyx_d = PyModule_GetDict(__pyx_m); if (unlikely(!__pyx_d)) __PYX_ERR(1, 1, __pyx_L1_error)
28858   Py_INCREF(__pyx_d);
28859   __pyx_b = PyImport_AddModule(__Pyx_BUILTIN_MODULE_NAME); if (unlikely(!__pyx_b)) __PYX_ERR(1, 1, __pyx_L1_error)
28860   Py_INCREF(__pyx_b);
28861   __pyx_cython_runtime = PyImport_AddModule((char *) "cython_runtime"); if (unlikely(!__pyx_cython_runtime)) __PYX_ERR(1, 1, __pyx_L1_error)
28862   Py_INCREF(__pyx_cython_runtime);
28863   if (PyObject_SetAttrString(__pyx_m, "__builtins__", __pyx_b) < 0) __PYX_ERR(1, 1, __pyx_L1_error);
28864   /*--- Initialize various global constants etc. ---*/
28865   if (__Pyx_InitGlobals() < 0) __PYX_ERR(1, 1, __pyx_L1_error)
28866   #if PY_MAJOR_VERSION < 3 && (__PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT)
28867   if (__Pyx_init_sys_getdefaultencoding_params() < 0) __PYX_ERR(1, 1, __pyx_L1_error)
28868   #endif
28869   if (__pyx_module_is_main_qutip__cy__brtools) {
28870     if (PyObject_SetAttr(__pyx_m, __pyx_n_s_name_2, __pyx_n_s_main) < 0) __PYX_ERR(1, 1, __pyx_L1_error)
28871   }
28872   #if PY_MAJOR_VERSION >= 3
28873   {
28874     PyObject *modules = PyImport_GetModuleDict(); if (unlikely(!modules)) __PYX_ERR(1, 1, __pyx_L1_error)
28875     if (!PyDict_GetItemString(modules, "qutip.cy.brtools")) {
28876       if (unlikely(PyDict_SetItemString(modules, "qutip.cy.brtools", __pyx_m) < 0)) __PYX_ERR(1, 1, __pyx_L1_error)
28877     }
28878   }
28879   #endif
28880   /*--- Builtin init code ---*/
28881   if (__Pyx_InitCachedBuiltins() < 0) __PYX_ERR(1, 1, __pyx_L1_error)
28882   /*--- Constants init code ---*/
28883   if (__Pyx_InitCachedConstants() < 0) __PYX_ERR(1, 1, __pyx_L1_error)
28884   /*--- Global type/function init code ---*/
28885   (void)__Pyx_modinit_global_init_code();
28886   (void)__Pyx_modinit_variable_export_code();
28887   if (unlikely(__Pyx_modinit_function_export_code() < 0)) __PYX_ERR(1, 1, __pyx_L1_error)
28888   if (unlikely(__Pyx_modinit_type_init_code() < 0)) __PYX_ERR(1, 1, __pyx_L1_error)
28889   if (unlikely(__Pyx_modinit_type_import_code() < 0)) __PYX_ERR(1, 1, __pyx_L1_error)
28890   (void)__Pyx_modinit_variable_import_code();
28891   if (unlikely(__Pyx_modinit_function_import_code() < 0)) __PYX_ERR(1, 1, __pyx_L1_error)
28892   /*--- Execution code ---*/
28893   #if defined(__Pyx_Generator_USED) || defined(__Pyx_Coroutine_USED)
28894   if (__Pyx_patch_abc() < 0) __PYX_ERR(1, 1, __pyx_L1_error)
28895   #endif
28896 
28897   /* "qutip/cy/brtools.pyx":47
28898  * from libcpp.vector cimport vector
28899  * from qutip.cy.sparse_structs cimport (CSR_Matrix, COO_Matrix)
28900  * from qutip.settings import eigh_unsafe             # <<<<<<<<<<<<<<
28901  * import numpy as np
28902  *
28903  */
28904   __pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 47, __pyx_L1_error)
28905   __Pyx_GOTREF(__pyx_t_1);
28906   __Pyx_INCREF(__pyx_n_s_eigh_unsafe);
28907   __Pyx_GIVEREF(__pyx_n_s_eigh_unsafe);
28908   PyList_SET_ITEM(__pyx_t_1, 0, __pyx_n_s_eigh_unsafe);
28909   __pyx_t_2 = __Pyx_Import(__pyx_n_s_qutip_settings, __pyx_t_1, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 47, __pyx_L1_error)
28910   __Pyx_GOTREF(__pyx_t_2);
28911   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
28912   __pyx_t_1 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_eigh_unsafe); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 47, __pyx_L1_error)
28913   __Pyx_GOTREF(__pyx_t_1);
28914   if (PyDict_SetItem(__pyx_d, __pyx_n_s_eigh_unsafe, __pyx_t_1) < 0) __PYX_ERR(1, 47, __pyx_L1_error)
28915   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
28916   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
28917 
28918   /* "qutip/cy/brtools.pyx":48
28919  * from qutip.cy.sparse_structs cimport (CSR_Matrix, COO_Matrix)
28920  * from qutip.settings import eigh_unsafe
28921  * import numpy as np             # <<<<<<<<<<<<<<
28922  *
28923  * include "sparse_routines.pxi"
28924  */
28925   __pyx_t_2 = __Pyx_Import(__pyx_n_s_numpy, 0, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 48, __pyx_L1_error)
28926   __Pyx_GOTREF(__pyx_t_2);
28927   if (PyDict_SetItem(__pyx_d, __pyx_n_s_np, __pyx_t_2) < 0) __PYX_ERR(1, 48, __pyx_L1_error)
28928   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
28929 
28930   /* "qutip/cy/sparse_routines.pxi":35
28931  * #    OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28932  * ###############################################################################
28933  * import numpy as np             # <<<<<<<<<<<<<<
28934  * from scipy.sparse import coo_matrix
28935  * from qutip.fastsparse import fast_csr_matrix
28936  */
28937   __pyx_t_2 = __Pyx_Import(__pyx_n_s_numpy, 0, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 35, __pyx_L1_error)
28938   __Pyx_GOTREF(__pyx_t_2);
28939   if (PyDict_SetItem(__pyx_d, __pyx_n_s_np, __pyx_t_2) < 0) __PYX_ERR(0, 35, __pyx_L1_error)
28940   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
28941 
28942   /* "qutip/cy/sparse_routines.pxi":36
28943  * ###############################################################################
28944  * import numpy as np
28945  * from scipy.sparse import coo_matrix             # <<<<<<<<<<<<<<
28946  * from qutip.fastsparse import fast_csr_matrix
28947  * cimport numpy as np
28948  */
28949   __pyx_t_2 = PyList_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 36, __pyx_L1_error)
28950   __Pyx_GOTREF(__pyx_t_2);
28951   __Pyx_INCREF(__pyx_n_s_coo_matrix);
28952   __Pyx_GIVEREF(__pyx_n_s_coo_matrix);
28953   PyList_SET_ITEM(__pyx_t_2, 0, __pyx_n_s_coo_matrix);
28954   __pyx_t_1 = __Pyx_Import(__pyx_n_s_scipy_sparse, __pyx_t_2, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 36, __pyx_L1_error)
28955   __Pyx_GOTREF(__pyx_t_1);
28956   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
28957   __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_1, __pyx_n_s_coo_matrix); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 36, __pyx_L1_error)
28958   __Pyx_GOTREF(__pyx_t_2);
28959   if (PyDict_SetItem(__pyx_d, __pyx_n_s_coo_matrix, __pyx_t_2) < 0) __PYX_ERR(0, 36, __pyx_L1_error)
28960   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
28961   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
28962 
28963   /* "qutip/cy/sparse_routines.pxi":37
28964  * import numpy as np
28965  * from scipy.sparse import coo_matrix
28966  * from qutip.fastsparse import fast_csr_matrix             # <<<<<<<<<<<<<<
28967  * cimport numpy as np
28968  * cimport cython
28969  */
28970   __pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 37, __pyx_L1_error)
28971   __Pyx_GOTREF(__pyx_t_1);
28972   __Pyx_INCREF(__pyx_n_s_fast_csr_matrix);
28973   __Pyx_GIVEREF(__pyx_n_s_fast_csr_matrix);
28974   PyList_SET_ITEM(__pyx_t_1, 0, __pyx_n_s_fast_csr_matrix);
28975   __pyx_t_2 = __Pyx_Import(__pyx_n_s_qutip_fastsparse, __pyx_t_1, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 37, __pyx_L1_error)
28976   __Pyx_GOTREF(__pyx_t_2);
28977   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
28978   __pyx_t_1 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_fast_csr_matrix); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 37, __pyx_L1_error)
28979   __Pyx_GOTREF(__pyx_t_1);
28980   if (PyDict_SetItem(__pyx_d, __pyx_n_s_fast_csr_matrix, __pyx_t_1) < 0) __PYX_ERR(0, 37, __pyx_L1_error)
28981   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
28982   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
28983 
28984   /* "qutip/cy/sparse_routines.pxi":43
28985  * from libcpp.vector cimport vector
28986  * from qutip.cy.sparse_structs cimport CSR_Matrix, COO_Matrix
28987  * np.import_array()             # <<<<<<<<<<<<<<
28988  *
28989  * cdef extern from "numpy/arrayobject.h" nogil:
28990  */
28991   __pyx_t_3 = __pyx_f_5numpy_import_array(); if (unlikely(__pyx_t_3 == ((int)-1))) __PYX_ERR(0, 43, __pyx_L1_error)
28992 
28993   /* "qutip/cy/brtools.pyx":59
28994  *
28995  *
28996  * cdef int use_zgeev = eigh_unsafe             # <<<<<<<<<<<<<<
28997  *
28998  *
28999  */
29000   __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_eigh_unsafe); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 59, __pyx_L1_error)
29001   __Pyx_GOTREF(__pyx_t_2);
29002   __pyx_t_3 = __Pyx_PyInt_As_int(__pyx_t_2); if (unlikely((__pyx_t_3 == (int)-1) && PyErr_Occurred())) __PYX_ERR(1, 59, __pyx_L1_error)
29003   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
29004   __pyx_v_5qutip_2cy_7brtools_use_zgeev = __pyx_t_3;
29005 
29006   /* "qutip/cy/brtools.pyx":249
29007  * @cython.boundscheck(False)
29008  * @cython.wraparound(False)
29009  * def liou_from_diag_ham(double[::1] diags):             # <<<<<<<<<<<<<<
29010  *     cdef unsigned int nrows = diags.shape[0]
29011  *     cdef np.ndarray[complex, ndim=1, mode='c'] data = np.empty(nrows**2, dtype=complex)
29012  */
29013   __pyx_t_2 = PyCFunction_NewEx(&__pyx_mdef_5qutip_2cy_7brtools_3liou_from_diag_ham, NULL, __pyx_n_s_qutip_cy_brtools); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 249, __pyx_L1_error)
29014   __Pyx_GOTREF(__pyx_t_2);
29015   if (PyDict_SetItem(__pyx_d, __pyx_n_s_liou_from_diag_ham, __pyx_t_2) < 0) __PYX_ERR(1, 249, __pyx_L1_error)
29016   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
29017 
29018   /* "qutip/cy/brtools.pyx":312
29019  *          int Arows, int Acols, int Brows, int Bcols,
29020  *          int transA = 0, int transB = 0,
29021  *          double complex alpha = 1, double complex beta = 0):             # <<<<<<<<<<<<<<
29022  *     cdef double complex * C = <double complex *>PyDataMem_NEW((Acols*Brows)*sizeof(double complex))
29023  *     cdef char tA, tB
29024  */
29025   __pyx_k__13 = __pyx_t_double_complex_from_parts(1, 0);
29026   __pyx_k__14 = __pyx_t_double_complex_from_parts(0, 0);
29027 
29028   /* "qutip/cy/brtools.pyx":340
29029  *                         double complex * out,
29030  *                        int Arows, int Acols, int transA = 0,
29031  *                        double complex alpha=1, double complex beta=1):             # <<<<<<<<<<<<<<
29032  *     cdef char tA
29033  *     cdef int idx = 1, idy = 1
29034  */
29035   __pyx_k__17 = __pyx_t_double_complex_from_parts(1, 0);
29036   __pyx_k__18 = __pyx_t_double_complex_from_parts(1, 0);
29037 
29038   /* "qutip/cy/brtools.pyx":1
29039  * #cython: language_level=3             # <<<<<<<<<<<<<<
29040  * # This file is part of QuTiP: Quantum Toolbox in Python.
29041  * #
29042  */
29043   __pyx_t_2 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 1, __pyx_L1_error)
29044   __Pyx_GOTREF(__pyx_t_2);
29045   if (PyDict_SetItem(__pyx_d, __pyx_n_s_test, __pyx_t_2) < 0) __PYX_ERR(1, 1, __pyx_L1_error)
29046   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
29047 
29048   /* "View.MemoryView":209
29049  *         info.obj = self
29050  *
29051  *     __pyx_getbuffer = capsule(<void *> &__pyx_array_getbuffer, "getbuffer(obj, view, flags)")             # <<<<<<<<<<<<<<
29052  *
29053  *     def __dealloc__(array self):
29054  */
29055   __pyx_t_2 = __pyx_capsule_create(((void *)(&__pyx_array_getbuffer)), ((char *)"getbuffer(obj, view, flags)")); if (unlikely(!__pyx_t_2)) __PYX_ERR(3, 209, __pyx_L1_error)
29056   __Pyx_GOTREF(__pyx_t_2);
29057   if (PyDict_SetItem((PyObject *)__pyx_array_type->tp_dict, __pyx_n_s_pyx_getbuffer, __pyx_t_2) < 0) __PYX_ERR(3, 209, __pyx_L1_error)
29058   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
29059   PyType_Modified(__pyx_array_type);
29060 
29061   /* "View.MemoryView":286
29062  *         return self.name
29063  *
29064  * cdef generic = Enum("<strided and direct or indirect>")             # <<<<<<<<<<<<<<
29065  * cdef strided = Enum("<strided and direct>") # default
29066  * cdef indirect = Enum("<strided and indirect>")
29067  */
29068   __pyx_t_2 = __Pyx_PyObject_Call(((PyObject *)__pyx_MemviewEnum_type), __pyx_tuple__46, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(3, 286, __pyx_L1_error)
29069   __Pyx_GOTREF(__pyx_t_2);
29070   __Pyx_XGOTREF(generic);
29071   __Pyx_DECREF_SET(generic, __pyx_t_2);
29072   __Pyx_GIVEREF(__pyx_t_2);
29073   __pyx_t_2 = 0;
29074 
29075   /* "View.MemoryView":287
29076  *
29077  * cdef generic = Enum("<strided and direct or indirect>")
29078  * cdef strided = Enum("<strided and direct>") # default             # <<<<<<<<<<<<<<
29079  * cdef indirect = Enum("<strided and indirect>")
29080  *
29081  */
29082   __pyx_t_2 = __Pyx_PyObject_Call(((PyObject *)__pyx_MemviewEnum_type), __pyx_tuple__47, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(3, 287, __pyx_L1_error)
29083   __Pyx_GOTREF(__pyx_t_2);
29084   __Pyx_XGOTREF(strided);
29085   __Pyx_DECREF_SET(strided, __pyx_t_2);
29086   __Pyx_GIVEREF(__pyx_t_2);
29087   __pyx_t_2 = 0;
29088 
29089   /* "View.MemoryView":288
29090  * cdef generic = Enum("<strided and direct or indirect>")
29091  * cdef strided = Enum("<strided and direct>") # default
29092  * cdef indirect = Enum("<strided and indirect>")             # <<<<<<<<<<<<<<
29093  *
29094  *
29095  */
29096   __pyx_t_2 = __Pyx_PyObject_Call(((PyObject *)__pyx_MemviewEnum_type), __pyx_tuple__48, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(3, 288, __pyx_L1_error)
29097   __Pyx_GOTREF(__pyx_t_2);
29098   __Pyx_XGOTREF(indirect);
29099   __Pyx_DECREF_SET(indirect, __pyx_t_2);
29100   __Pyx_GIVEREF(__pyx_t_2);
29101   __pyx_t_2 = 0;
29102 
29103   /* "View.MemoryView":291
29104  *
29105  *
29106  * cdef contiguous = Enum("<contiguous and direct>")             # <<<<<<<<<<<<<<
29107  * cdef indirect_contiguous = Enum("<contiguous and indirect>")
29108  *
29109  */
29110   __pyx_t_2 = __Pyx_PyObject_Call(((PyObject *)__pyx_MemviewEnum_type), __pyx_tuple__49, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(3, 291, __pyx_L1_error)
29111   __Pyx_GOTREF(__pyx_t_2);
29112   __Pyx_XGOTREF(contiguous);
29113   __Pyx_DECREF_SET(contiguous, __pyx_t_2);
29114   __Pyx_GIVEREF(__pyx_t_2);
29115   __pyx_t_2 = 0;
29116 
29117   /* "View.MemoryView":292
29118  *
29119  * cdef contiguous = Enum("<contiguous and direct>")
29120  * cdef indirect_contiguous = Enum("<contiguous and indirect>")             # <<<<<<<<<<<<<<
29121  *
29122  *
29123  */
29124   __pyx_t_2 = __Pyx_PyObject_Call(((PyObject *)__pyx_MemviewEnum_type), __pyx_tuple__50, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(3, 292, __pyx_L1_error)
29125   __Pyx_GOTREF(__pyx_t_2);
29126   __Pyx_XGOTREF(indirect_contiguous);
29127   __Pyx_DECREF_SET(indirect_contiguous, __pyx_t_2);
29128   __Pyx_GIVEREF(__pyx_t_2);
29129   __pyx_t_2 = 0;
29130 
29131   /* "View.MemoryView":316
29132  *
29133  * DEF THREAD_LOCKS_PREALLOCATED = 8
29134  * cdef int __pyx_memoryview_thread_locks_used = 0             # <<<<<<<<<<<<<<
29135  * cdef PyThread_type_lock[THREAD_LOCKS_PREALLOCATED] __pyx_memoryview_thread_locks = [
29136  *     PyThread_allocate_lock(),
29137  */
29138   __pyx_memoryview_thread_locks_used = 0;
29139 
29140   /* "View.MemoryView":317
29141  * DEF THREAD_LOCKS_PREALLOCATED = 8
29142  * cdef int __pyx_memoryview_thread_locks_used = 0
29143  * cdef PyThread_type_lock[THREAD_LOCKS_PREALLOCATED] __pyx_memoryview_thread_locks = [             # <<<<<<<<<<<<<<
29144  *     PyThread_allocate_lock(),
29145  *     PyThread_allocate_lock(),
29146  */
29147   __pyx_t_4[0] = PyThread_allocate_lock();
29148   __pyx_t_4[1] = PyThread_allocate_lock();
29149   __pyx_t_4[2] = PyThread_allocate_lock();
29150   __pyx_t_4[3] = PyThread_allocate_lock();
29151   __pyx_t_4[4] = PyThread_allocate_lock();
29152   __pyx_t_4[5] = PyThread_allocate_lock();
29153   __pyx_t_4[6] = PyThread_allocate_lock();
29154   __pyx_t_4[7] = PyThread_allocate_lock();
29155   memcpy(&(__pyx_memoryview_thread_locks[0]), __pyx_t_4, sizeof(__pyx_memoryview_thread_locks[0]) * (8));
29156 
29157   /* "View.MemoryView":549
29158  *         info.obj = self
29159  *
29160  *     __pyx_getbuffer = capsule(<void *> &__pyx_memoryview_getbuffer, "getbuffer(obj, view, flags)")             # <<<<<<<<<<<<<<
29161  *
29162  *
29163  */
29164   __pyx_t_2 = __pyx_capsule_create(((void *)(&__pyx_memoryview_getbuffer)), ((char *)"getbuffer(obj, view, flags)")); if (unlikely(!__pyx_t_2)) __PYX_ERR(3, 549, __pyx_L1_error)
29165   __Pyx_GOTREF(__pyx_t_2);
29166   if (PyDict_SetItem((PyObject *)__pyx_memoryview_type->tp_dict, __pyx_n_s_pyx_getbuffer, __pyx_t_2) < 0) __PYX_ERR(3, 549, __pyx_L1_error)
29167   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
29168   PyType_Modified(__pyx_memoryview_type);
29169 
29170   /* "View.MemoryView":995
29171  *         return self.from_object
29172  *
29173  *     __pyx_getbuffer = capsule(<void *> &__pyx_memoryview_getbuffer, "getbuffer(obj, view, flags)")             # <<<<<<<<<<<<<<
29174  *
29175  *
29176  */
29177   __pyx_t_2 = __pyx_capsule_create(((void *)(&__pyx_memoryview_getbuffer)), ((char *)"getbuffer(obj, view, flags)")); if (unlikely(!__pyx_t_2)) __PYX_ERR(3, 995, __pyx_L1_error)
29178   __Pyx_GOTREF(__pyx_t_2);
29179   if (PyDict_SetItem((PyObject *)__pyx_memoryviewslice_type->tp_dict, __pyx_n_s_pyx_getbuffer, __pyx_t_2) < 0) __PYX_ERR(3, 995, __pyx_L1_error)
29180   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
29181   PyType_Modified(__pyx_memoryviewslice_type);
29182 
29183   /* "(tree fragment)":1
29184  * def __pyx_unpickle_Enum(__pyx_type, long __pyx_checksum, __pyx_state):             # <<<<<<<<<<<<<<
29185  *     cdef object __pyx_PickleError
29186  *     cdef object __pyx_result
29187  */
29188   __pyx_t_2 = PyCFunction_NewEx(&__pyx_mdef_15View_dot_MemoryView_1__pyx_unpickle_Enum, NULL, __pyx_n_s_View_MemoryView); if (unlikely(!__pyx_t_2)) __PYX_ERR(3, 1, __pyx_L1_error)
29189   __Pyx_GOTREF(__pyx_t_2);
29190   if (PyDict_SetItem(__pyx_d, __pyx_n_s_pyx_unpickle_Enum, __pyx_t_2) < 0) __PYX_ERR(3, 1, __pyx_L1_error)
29191   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
29192 
29193   /* "BufferFormatFromTypeInfo":1463
29194  *
29195  * @cname('__pyx_format_from_typeinfo')
29196  * cdef bytes format_from_typeinfo(__Pyx_TypeInfo *type):             # <<<<<<<<<<<<<<
29197  *     cdef __Pyx_StructField *field
29198  *     cdef __pyx_typeinfo_string fmt
29199  */
29200 
29201   /*--- Wrapped vars code ---*/
29202 
29203   goto __pyx_L0;
29204   __pyx_L1_error:;
29205   __Pyx_XDECREF(__pyx_t_1);
29206   __Pyx_XDECREF(__pyx_t_2);
29207   if (__pyx_m) {
29208     if (__pyx_d) {
29209       __Pyx_AddTraceback("init qutip.cy.brtools", __pyx_clineno, __pyx_lineno, __pyx_filename);
29210     }
29211     Py_CLEAR(__pyx_m);
29212   } else if (!PyErr_Occurred()) {
29213     PyErr_SetString(PyExc_ImportError, "init qutip.cy.brtools");
29214   }
29215   __pyx_L0:;
29216   __Pyx_RefNannyFinishContext();
29217   #if CYTHON_PEP489_MULTI_PHASE_INIT
29218   return (__pyx_m != NULL) ? 0 : -1;
29219   #elif PY_MAJOR_VERSION >= 3
29220   return __pyx_m;
29221   #else
29222   return;
29223   #endif
29224 }
29225 
29226 /* --- Runtime support code --- */
29227 /* Refnanny */
29228 #if CYTHON_REFNANNY
__Pyx_RefNannyImportAPI(const char * modname)29229 static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname) {
29230     PyObject *m = NULL, *p = NULL;
29231     void *r = NULL;
29232     m = PyImport_ImportModule(modname);
29233     if (!m) goto end;
29234     p = PyObject_GetAttrString(m, "RefNannyAPI");
29235     if (!p) goto end;
29236     r = PyLong_AsVoidPtr(p);
29237 end:
29238     Py_XDECREF(p);
29239     Py_XDECREF(m);
29240     return (__Pyx_RefNannyAPIStruct *)r;
29241 }
29242 #endif
29243 
29244 /* PyObjectGetAttrStr */
29245 #if CYTHON_USE_TYPE_SLOTS
__Pyx_PyObject_GetAttrStr(PyObject * obj,PyObject * attr_name)29246 static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStr(PyObject* obj, PyObject* attr_name) {
29247     PyTypeObject* tp = Py_TYPE(obj);
29248     if (likely(tp->tp_getattro))
29249         return tp->tp_getattro(obj, attr_name);
29250 #if PY_MAJOR_VERSION < 3
29251     if (likely(tp->tp_getattr))
29252         return tp->tp_getattr(obj, PyString_AS_STRING(attr_name));
29253 #endif
29254     return PyObject_GetAttr(obj, attr_name);
29255 }
29256 #endif
29257 
29258 /* GetBuiltinName */
__Pyx_GetBuiltinName(PyObject * name)29259 static PyObject *__Pyx_GetBuiltinName(PyObject *name) {
29260     PyObject* result = __Pyx_PyObject_GetAttrStr(__pyx_b, name);
29261     if (unlikely(!result)) {
29262         PyErr_Format(PyExc_NameError,
29263 #if PY_MAJOR_VERSION >= 3
29264             "name '%U' is not defined", name);
29265 #else
29266             "name '%.200s' is not defined", PyString_AS_STRING(name));
29267 #endif
29268     }
29269     return result;
29270 }
29271 
29272 /* PyObjectCall */
29273 #if CYTHON_COMPILING_IN_CPYTHON
__Pyx_PyObject_Call(PyObject * func,PyObject * arg,PyObject * kw)29274 static CYTHON_INLINE PyObject* __Pyx_PyObject_Call(PyObject *func, PyObject *arg, PyObject *kw) {
29275     PyObject *result;
29276     ternaryfunc call = func->ob_type->tp_call;
29277     if (unlikely(!call))
29278         return PyObject_Call(func, arg, kw);
29279     if (unlikely(Py_EnterRecursiveCall((char*)" while calling a Python object")))
29280         return NULL;
29281     result = (*call)(func, arg, kw);
29282     Py_LeaveRecursiveCall();
29283     if (unlikely(!result) && unlikely(!PyErr_Occurred())) {
29284         PyErr_SetString(
29285             PyExc_SystemError,
29286             "NULL result without error in PyObject_Call");
29287     }
29288     return result;
29289 }
29290 #endif
29291 
29292 /* PyErrFetchRestore */
29293 #if CYTHON_FAST_THREAD_STATE
__Pyx_ErrRestoreInState(PyThreadState * tstate,PyObject * type,PyObject * value,PyObject * tb)29294 static CYTHON_INLINE void __Pyx_ErrRestoreInState(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb) {
29295     PyObject *tmp_type, *tmp_value, *tmp_tb;
29296     tmp_type = tstate->curexc_type;
29297     tmp_value = tstate->curexc_value;
29298     tmp_tb = tstate->curexc_traceback;
29299     tstate->curexc_type = type;
29300     tstate->curexc_value = value;
29301     tstate->curexc_traceback = tb;
29302     Py_XDECREF(tmp_type);
29303     Py_XDECREF(tmp_value);
29304     Py_XDECREF(tmp_tb);
29305 }
__Pyx_ErrFetchInState(PyThreadState * tstate,PyObject ** type,PyObject ** value,PyObject ** tb)29306 static CYTHON_INLINE void __Pyx_ErrFetchInState(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) {
29307     *type = tstate->curexc_type;
29308     *value = tstate->curexc_value;
29309     *tb = tstate->curexc_traceback;
29310     tstate->curexc_type = 0;
29311     tstate->curexc_value = 0;
29312     tstate->curexc_traceback = 0;
29313 }
29314 #endif
29315 
29316 /* RaiseException */
29317 #if PY_MAJOR_VERSION < 3
__Pyx_Raise(PyObject * type,PyObject * value,PyObject * tb,CYTHON_UNUSED PyObject * cause)29318 static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb,
29319                         CYTHON_UNUSED PyObject *cause) {
29320     __Pyx_PyThreadState_declare
29321     Py_XINCREF(type);
29322     if (!value || value == Py_None)
29323         value = NULL;
29324     else
29325         Py_INCREF(value);
29326     if (!tb || tb == Py_None)
29327         tb = NULL;
29328     else {
29329         Py_INCREF(tb);
29330         if (!PyTraceBack_Check(tb)) {
29331             PyErr_SetString(PyExc_TypeError,
29332                 "raise: arg 3 must be a traceback or None");
29333             goto raise_error;
29334         }
29335     }
29336     if (PyType_Check(type)) {
29337 #if CYTHON_COMPILING_IN_PYPY
29338         if (!value) {
29339             Py_INCREF(Py_None);
29340             value = Py_None;
29341         }
29342 #endif
29343         PyErr_NormalizeException(&type, &value, &tb);
29344     } else {
29345         if (value) {
29346             PyErr_SetString(PyExc_TypeError,
29347                 "instance exception may not have a separate value");
29348             goto raise_error;
29349         }
29350         value = type;
29351         type = (PyObject*) Py_TYPE(type);
29352         Py_INCREF(type);
29353         if (!PyType_IsSubtype((PyTypeObject *)type, (PyTypeObject *)PyExc_BaseException)) {
29354             PyErr_SetString(PyExc_TypeError,
29355                 "raise: exception class must be a subclass of BaseException");
29356             goto raise_error;
29357         }
29358     }
29359     __Pyx_PyThreadState_assign
29360     __Pyx_ErrRestore(type, value, tb);
29361     return;
29362 raise_error:
29363     Py_XDECREF(value);
29364     Py_XDECREF(type);
29365     Py_XDECREF(tb);
29366     return;
29367 }
29368 #else
__Pyx_Raise(PyObject * type,PyObject * value,PyObject * tb,PyObject * cause)29369 static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause) {
29370     PyObject* owned_instance = NULL;
29371     if (tb == Py_None) {
29372         tb = 0;
29373     } else if (tb && !PyTraceBack_Check(tb)) {
29374         PyErr_SetString(PyExc_TypeError,
29375             "raise: arg 3 must be a traceback or None");
29376         goto bad;
29377     }
29378     if (value == Py_None)
29379         value = 0;
29380     if (PyExceptionInstance_Check(type)) {
29381         if (value) {
29382             PyErr_SetString(PyExc_TypeError,
29383                 "instance exception may not have a separate value");
29384             goto bad;
29385         }
29386         value = type;
29387         type = (PyObject*) Py_TYPE(value);
29388     } else if (PyExceptionClass_Check(type)) {
29389         PyObject *instance_class = NULL;
29390         if (value && PyExceptionInstance_Check(value)) {
29391             instance_class = (PyObject*) Py_TYPE(value);
29392             if (instance_class != type) {
29393                 int is_subclass = PyObject_IsSubclass(instance_class, type);
29394                 if (!is_subclass) {
29395                     instance_class = NULL;
29396                 } else if (unlikely(is_subclass == -1)) {
29397                     goto bad;
29398                 } else {
29399                     type = instance_class;
29400                 }
29401             }
29402         }
29403         if (!instance_class) {
29404             PyObject *args;
29405             if (!value)
29406                 args = PyTuple_New(0);
29407             else if (PyTuple_Check(value)) {
29408                 Py_INCREF(value);
29409                 args = value;
29410             } else
29411                 args = PyTuple_Pack(1, value);
29412             if (!args)
29413                 goto bad;
29414             owned_instance = PyObject_Call(type, args, NULL);
29415             Py_DECREF(args);
29416             if (!owned_instance)
29417                 goto bad;
29418             value = owned_instance;
29419             if (!PyExceptionInstance_Check(value)) {
29420                 PyErr_Format(PyExc_TypeError,
29421                              "calling %R should have returned an instance of "
29422                              "BaseException, not %R",
29423                              type, Py_TYPE(value));
29424                 goto bad;
29425             }
29426         }
29427     } else {
29428         PyErr_SetString(PyExc_TypeError,
29429             "raise: exception class must be a subclass of BaseException");
29430         goto bad;
29431     }
29432     if (cause) {
29433         PyObject *fixed_cause;
29434         if (cause == Py_None) {
29435             fixed_cause = NULL;
29436         } else if (PyExceptionClass_Check(cause)) {
29437             fixed_cause = PyObject_CallObject(cause, NULL);
29438             if (fixed_cause == NULL)
29439                 goto bad;
29440         } else if (PyExceptionInstance_Check(cause)) {
29441             fixed_cause = cause;
29442             Py_INCREF(fixed_cause);
29443         } else {
29444             PyErr_SetString(PyExc_TypeError,
29445                             "exception causes must derive from "
29446                             "BaseException");
29447             goto bad;
29448         }
29449         PyException_SetCause(value, fixed_cause);
29450     }
29451     PyErr_SetObject(type, value);
29452     if (tb) {
29453 #if CYTHON_COMPILING_IN_PYPY
29454         PyObject *tmp_type, *tmp_value, *tmp_tb;
29455         PyErr_Fetch(&tmp_type, &tmp_value, &tmp_tb);
29456         Py_INCREF(tb);
29457         PyErr_Restore(tmp_type, tmp_value, tb);
29458         Py_XDECREF(tmp_tb);
29459 #else
29460         PyThreadState *tstate = __Pyx_PyThreadState_Current;
29461         PyObject* tmp_tb = tstate->curexc_traceback;
29462         if (tb != tmp_tb) {
29463             Py_INCREF(tb);
29464             tstate->curexc_traceback = tb;
29465             Py_XDECREF(tmp_tb);
29466         }
29467 #endif
29468     }
29469 bad:
29470     Py_XDECREF(owned_instance);
29471     return;
29472 }
29473 #endif
29474 
29475 /* 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)29476 static void __Pyx_WriteUnraisable(const char *name, CYTHON_UNUSED int clineno,
29477                                   CYTHON_UNUSED int lineno, CYTHON_UNUSED const char *filename,
29478                                   int full_traceback, CYTHON_UNUSED int nogil) {
29479     PyObject *old_exc, *old_val, *old_tb;
29480     PyObject *ctx;
29481     __Pyx_PyThreadState_declare
29482 #ifdef WITH_THREAD
29483     PyGILState_STATE state;
29484     if (nogil)
29485         state = PyGILState_Ensure();
29486 #ifdef _MSC_VER
29487     else state = (PyGILState_STATE)-1;
29488 #endif
29489 #endif
29490     __Pyx_PyThreadState_assign
29491     __Pyx_ErrFetch(&old_exc, &old_val, &old_tb);
29492     if (full_traceback) {
29493         Py_XINCREF(old_exc);
29494         Py_XINCREF(old_val);
29495         Py_XINCREF(old_tb);
29496         __Pyx_ErrRestore(old_exc, old_val, old_tb);
29497         PyErr_PrintEx(1);
29498     }
29499     #if PY_MAJOR_VERSION < 3
29500     ctx = PyString_FromString(name);
29501     #else
29502     ctx = PyUnicode_FromString(name);
29503     #endif
29504     __Pyx_ErrRestore(old_exc, old_val, old_tb);
29505     if (!ctx) {
29506         PyErr_WriteUnraisable(Py_None);
29507     } else {
29508         PyErr_WriteUnraisable(ctx);
29509         Py_DECREF(ctx);
29510     }
29511 #ifdef WITH_THREAD
29512     if (nogil)
29513         PyGILState_Release(state);
29514 #endif
29515 }
29516 
29517 /* ExtTypeTest */
__Pyx_TypeTest(PyObject * obj,PyTypeObject * type)29518 static CYTHON_INLINE int __Pyx_TypeTest(PyObject *obj, PyTypeObject *type) {
29519     if (unlikely(!type)) {
29520         PyErr_SetString(PyExc_SystemError, "Missing type object");
29521         return 0;
29522     }
29523     if (likely(__Pyx_TypeCheck(obj, type)))
29524         return 1;
29525     PyErr_Format(PyExc_TypeError, "Cannot convert %.200s to %.200s",
29526                  Py_TYPE(obj)->tp_name, type->tp_name);
29527     return 0;
29528 }
29529 
29530 /* IsLittleEndian */
__Pyx_Is_Little_Endian(void)29531 static CYTHON_INLINE int __Pyx_Is_Little_Endian(void)
29532 {
29533   union {
29534     uint32_t u32;
29535     uint8_t u8[4];
29536   } S;
29537   S.u32 = 0x01020304;
29538   return S.u8[0] == 4;
29539 }
29540 
29541 /* BufferFormatCheck */
__Pyx_BufFmt_Init(__Pyx_BufFmt_Context * ctx,__Pyx_BufFmt_StackElem * stack,__Pyx_TypeInfo * type)29542 static void __Pyx_BufFmt_Init(__Pyx_BufFmt_Context* ctx,
29543                               __Pyx_BufFmt_StackElem* stack,
29544                               __Pyx_TypeInfo* type) {
29545   stack[0].field = &ctx->root;
29546   stack[0].parent_offset = 0;
29547   ctx->root.type = type;
29548   ctx->root.name = "buffer dtype";
29549   ctx->root.offset = 0;
29550   ctx->head = stack;
29551   ctx->head->field = &ctx->root;
29552   ctx->fmt_offset = 0;
29553   ctx->head->parent_offset = 0;
29554   ctx->new_packmode = '@';
29555   ctx->enc_packmode = '@';
29556   ctx->new_count = 1;
29557   ctx->enc_count = 0;
29558   ctx->enc_type = 0;
29559   ctx->is_complex = 0;
29560   ctx->is_valid_array = 0;
29561   ctx->struct_alignment = 0;
29562   while (type->typegroup == 'S') {
29563     ++ctx->head;
29564     ctx->head->field = type->fields;
29565     ctx->head->parent_offset = 0;
29566     type = type->fields->type;
29567   }
29568 }
__Pyx_BufFmt_ParseNumber(const char ** ts)29569 static int __Pyx_BufFmt_ParseNumber(const char** ts) {
29570     int count;
29571     const char* t = *ts;
29572     if (*t < '0' || *t > '9') {
29573       return -1;
29574     } else {
29575         count = *t++ - '0';
29576         while (*t >= '0' && *t <= '9') {
29577             count *= 10;
29578             count += *t++ - '0';
29579         }
29580     }
29581     *ts = t;
29582     return count;
29583 }
__Pyx_BufFmt_ExpectNumber(const char ** ts)29584 static int __Pyx_BufFmt_ExpectNumber(const char **ts) {
29585     int number = __Pyx_BufFmt_ParseNumber(ts);
29586     if (number == -1)
29587         PyErr_Format(PyExc_ValueError,\
29588                      "Does not understand character buffer dtype format string ('%c')", **ts);
29589     return number;
29590 }
__Pyx_BufFmt_RaiseUnexpectedChar(char ch)29591 static void __Pyx_BufFmt_RaiseUnexpectedChar(char ch) {
29592   PyErr_Format(PyExc_ValueError,
29593                "Unexpected format string character: '%c'", ch);
29594 }
__Pyx_BufFmt_DescribeTypeChar(char ch,int is_complex)29595 static const char* __Pyx_BufFmt_DescribeTypeChar(char ch, int is_complex) {
29596   switch (ch) {
29597     case '?': return "'bool'";
29598     case 'c': return "'char'";
29599     case 'b': return "'signed char'";
29600     case 'B': return "'unsigned char'";
29601     case 'h': return "'short'";
29602     case 'H': return "'unsigned short'";
29603     case 'i': return "'int'";
29604     case 'I': return "'unsigned int'";
29605     case 'l': return "'long'";
29606     case 'L': return "'unsigned long'";
29607     case 'q': return "'long long'";
29608     case 'Q': return "'unsigned long long'";
29609     case 'f': return (is_complex ? "'complex float'" : "'float'");
29610     case 'd': return (is_complex ? "'complex double'" : "'double'");
29611     case 'g': return (is_complex ? "'complex long double'" : "'long double'");
29612     case 'T': return "a struct";
29613     case 'O': return "Python object";
29614     case 'P': return "a pointer";
29615     case 's': case 'p': return "a string";
29616     case 0: return "end";
29617     default: return "unparseable format string";
29618   }
29619 }
__Pyx_BufFmt_TypeCharToStandardSize(char ch,int is_complex)29620 static size_t __Pyx_BufFmt_TypeCharToStandardSize(char ch, int is_complex) {
29621   switch (ch) {
29622     case '?': case 'c': case 'b': case 'B': case 's': case 'p': return 1;
29623     case 'h': case 'H': return 2;
29624     case 'i': case 'I': case 'l': case 'L': return 4;
29625     case 'q': case 'Q': return 8;
29626     case 'f': return (is_complex ? 8 : 4);
29627     case 'd': return (is_complex ? 16 : 8);
29628     case 'g': {
29629       PyErr_SetString(PyExc_ValueError, "Python does not define a standard format string size for long double ('g')..");
29630       return 0;
29631     }
29632     case 'O': case 'P': return sizeof(void*);
29633     default:
29634       __Pyx_BufFmt_RaiseUnexpectedChar(ch);
29635       return 0;
29636     }
29637 }
__Pyx_BufFmt_TypeCharToNativeSize(char ch,int is_complex)29638 static size_t __Pyx_BufFmt_TypeCharToNativeSize(char ch, int is_complex) {
29639   switch (ch) {
29640     case '?': case 'c': case 'b': case 'B': case 's': case 'p': return 1;
29641     case 'h': case 'H': return sizeof(short);
29642     case 'i': case 'I': return sizeof(int);
29643     case 'l': case 'L': return sizeof(long);
29644     #ifdef HAVE_LONG_LONG
29645     case 'q': case 'Q': return sizeof(PY_LONG_LONG);
29646     #endif
29647     case 'f': return sizeof(float) * (is_complex ? 2 : 1);
29648     case 'd': return sizeof(double) * (is_complex ? 2 : 1);
29649     case 'g': return sizeof(long double) * (is_complex ? 2 : 1);
29650     case 'O': case 'P': return sizeof(void*);
29651     default: {
29652       __Pyx_BufFmt_RaiseUnexpectedChar(ch);
29653       return 0;
29654     }
29655   }
29656 }
29657 typedef struct { char c; short x; } __Pyx_st_short;
29658 typedef struct { char c; int x; } __Pyx_st_int;
29659 typedef struct { char c; long x; } __Pyx_st_long;
29660 typedef struct { char c; float x; } __Pyx_st_float;
29661 typedef struct { char c; double x; } __Pyx_st_double;
29662 typedef struct { char c; long double x; } __Pyx_st_longdouble;
29663 typedef struct { char c; void *x; } __Pyx_st_void_p;
29664 #ifdef HAVE_LONG_LONG
29665 typedef struct { char c; PY_LONG_LONG x; } __Pyx_st_longlong;
29666 #endif
__Pyx_BufFmt_TypeCharToAlignment(char ch,CYTHON_UNUSED int is_complex)29667 static size_t __Pyx_BufFmt_TypeCharToAlignment(char ch, CYTHON_UNUSED int is_complex) {
29668   switch (ch) {
29669     case '?': case 'c': case 'b': case 'B': case 's': case 'p': return 1;
29670     case 'h': case 'H': return sizeof(__Pyx_st_short) - sizeof(short);
29671     case 'i': case 'I': return sizeof(__Pyx_st_int) - sizeof(int);
29672     case 'l': case 'L': return sizeof(__Pyx_st_long) - sizeof(long);
29673 #ifdef HAVE_LONG_LONG
29674     case 'q': case 'Q': return sizeof(__Pyx_st_longlong) - sizeof(PY_LONG_LONG);
29675 #endif
29676     case 'f': return sizeof(__Pyx_st_float) - sizeof(float);
29677     case 'd': return sizeof(__Pyx_st_double) - sizeof(double);
29678     case 'g': return sizeof(__Pyx_st_longdouble) - sizeof(long double);
29679     case 'P': case 'O': return sizeof(__Pyx_st_void_p) - sizeof(void*);
29680     default:
29681       __Pyx_BufFmt_RaiseUnexpectedChar(ch);
29682       return 0;
29683     }
29684 }
29685 /* These are for computing the padding at the end of the struct to align
29686    on the first member of the struct. This will probably the same as above,
29687    but we don't have any guarantees.
29688  */
29689 typedef struct { short x; char c; } __Pyx_pad_short;
29690 typedef struct { int x; char c; } __Pyx_pad_int;
29691 typedef struct { long x; char c; } __Pyx_pad_long;
29692 typedef struct { float x; char c; } __Pyx_pad_float;
29693 typedef struct { double x; char c; } __Pyx_pad_double;
29694 typedef struct { long double x; char c; } __Pyx_pad_longdouble;
29695 typedef struct { void *x; char c; } __Pyx_pad_void_p;
29696 #ifdef HAVE_LONG_LONG
29697 typedef struct { PY_LONG_LONG x; char c; } __Pyx_pad_longlong;
29698 #endif
__Pyx_BufFmt_TypeCharToPadding(char ch,CYTHON_UNUSED int is_complex)29699 static size_t __Pyx_BufFmt_TypeCharToPadding(char ch, CYTHON_UNUSED int is_complex) {
29700   switch (ch) {
29701     case '?': case 'c': case 'b': case 'B': case 's': case 'p': return 1;
29702     case 'h': case 'H': return sizeof(__Pyx_pad_short) - sizeof(short);
29703     case 'i': case 'I': return sizeof(__Pyx_pad_int) - sizeof(int);
29704     case 'l': case 'L': return sizeof(__Pyx_pad_long) - sizeof(long);
29705 #ifdef HAVE_LONG_LONG
29706     case 'q': case 'Q': return sizeof(__Pyx_pad_longlong) - sizeof(PY_LONG_LONG);
29707 #endif
29708     case 'f': return sizeof(__Pyx_pad_float) - sizeof(float);
29709     case 'd': return sizeof(__Pyx_pad_double) - sizeof(double);
29710     case 'g': return sizeof(__Pyx_pad_longdouble) - sizeof(long double);
29711     case 'P': case 'O': return sizeof(__Pyx_pad_void_p) - sizeof(void*);
29712     default:
29713       __Pyx_BufFmt_RaiseUnexpectedChar(ch);
29714       return 0;
29715     }
29716 }
__Pyx_BufFmt_TypeCharToGroup(char ch,int is_complex)29717 static char __Pyx_BufFmt_TypeCharToGroup(char ch, int is_complex) {
29718   switch (ch) {
29719     case 'c':
29720         return 'H';
29721     case 'b': case 'h': case 'i':
29722     case 'l': case 'q': case 's': case 'p':
29723         return 'I';
29724     case '?': case 'B': case 'H': case 'I': case 'L': case 'Q':
29725         return 'U';
29726     case 'f': case 'd': case 'g':
29727         return (is_complex ? 'C' : 'R');
29728     case 'O':
29729         return 'O';
29730     case 'P':
29731         return 'P';
29732     default: {
29733       __Pyx_BufFmt_RaiseUnexpectedChar(ch);
29734       return 0;
29735     }
29736   }
29737 }
__Pyx_BufFmt_RaiseExpected(__Pyx_BufFmt_Context * ctx)29738 static void __Pyx_BufFmt_RaiseExpected(__Pyx_BufFmt_Context* ctx) {
29739   if (ctx->head == NULL || ctx->head->field == &ctx->root) {
29740     const char* expected;
29741     const char* quote;
29742     if (ctx->head == NULL) {
29743       expected = "end";
29744       quote = "";
29745     } else {
29746       expected = ctx->head->field->type->name;
29747       quote = "'";
29748     }
29749     PyErr_Format(PyExc_ValueError,
29750                  "Buffer dtype mismatch, expected %s%s%s but got %s",
29751                  quote, expected, quote,
29752                  __Pyx_BufFmt_DescribeTypeChar(ctx->enc_type, ctx->is_complex));
29753   } else {
29754     __Pyx_StructField* field = ctx->head->field;
29755     __Pyx_StructField* parent = (ctx->head - 1)->field;
29756     PyErr_Format(PyExc_ValueError,
29757                  "Buffer dtype mismatch, expected '%s' but got %s in '%s.%s'",
29758                  field->type->name, __Pyx_BufFmt_DescribeTypeChar(ctx->enc_type, ctx->is_complex),
29759                  parent->type->name, field->name);
29760   }
29761 }
__Pyx_BufFmt_ProcessTypeChunk(__Pyx_BufFmt_Context * ctx)29762 static int __Pyx_BufFmt_ProcessTypeChunk(__Pyx_BufFmt_Context* ctx) {
29763   char group;
29764   size_t size, offset, arraysize = 1;
29765   if (ctx->enc_type == 0) return 0;
29766   if (ctx->head->field->type->arraysize[0]) {
29767     int i, ndim = 0;
29768     if (ctx->enc_type == 's' || ctx->enc_type == 'p') {
29769         ctx->is_valid_array = ctx->head->field->type->ndim == 1;
29770         ndim = 1;
29771         if (ctx->enc_count != ctx->head->field->type->arraysize[0]) {
29772             PyErr_Format(PyExc_ValueError,
29773                          "Expected a dimension of size %zu, got %zu",
29774                          ctx->head->field->type->arraysize[0], ctx->enc_count);
29775             return -1;
29776         }
29777     }
29778     if (!ctx->is_valid_array) {
29779       PyErr_Format(PyExc_ValueError, "Expected %d dimensions, got %d",
29780                    ctx->head->field->type->ndim, ndim);
29781       return -1;
29782     }
29783     for (i = 0; i < ctx->head->field->type->ndim; i++) {
29784       arraysize *= ctx->head->field->type->arraysize[i];
29785     }
29786     ctx->is_valid_array = 0;
29787     ctx->enc_count = 1;
29788   }
29789   group = __Pyx_BufFmt_TypeCharToGroup(ctx->enc_type, ctx->is_complex);
29790   do {
29791     __Pyx_StructField* field = ctx->head->field;
29792     __Pyx_TypeInfo* type = field->type;
29793     if (ctx->enc_packmode == '@' || ctx->enc_packmode == '^') {
29794       size = __Pyx_BufFmt_TypeCharToNativeSize(ctx->enc_type, ctx->is_complex);
29795     } else {
29796       size = __Pyx_BufFmt_TypeCharToStandardSize(ctx->enc_type, ctx->is_complex);
29797     }
29798     if (ctx->enc_packmode == '@') {
29799       size_t align_at = __Pyx_BufFmt_TypeCharToAlignment(ctx->enc_type, ctx->is_complex);
29800       size_t align_mod_offset;
29801       if (align_at == 0) return -1;
29802       align_mod_offset = ctx->fmt_offset % align_at;
29803       if (align_mod_offset > 0) ctx->fmt_offset += align_at - align_mod_offset;
29804       if (ctx->struct_alignment == 0)
29805           ctx->struct_alignment = __Pyx_BufFmt_TypeCharToPadding(ctx->enc_type,
29806                                                                  ctx->is_complex);
29807     }
29808     if (type->size != size || type->typegroup != group) {
29809       if (type->typegroup == 'C' && type->fields != NULL) {
29810         size_t parent_offset = ctx->head->parent_offset + field->offset;
29811         ++ctx->head;
29812         ctx->head->field = type->fields;
29813         ctx->head->parent_offset = parent_offset;
29814         continue;
29815       }
29816       if ((type->typegroup == 'H' || group == 'H') && type->size == size) {
29817       } else {
29818           __Pyx_BufFmt_RaiseExpected(ctx);
29819           return -1;
29820       }
29821     }
29822     offset = ctx->head->parent_offset + field->offset;
29823     if (ctx->fmt_offset != offset) {
29824       PyErr_Format(PyExc_ValueError,
29825                    "Buffer dtype mismatch; next field is at offset %" CYTHON_FORMAT_SSIZE_T "d but %" CYTHON_FORMAT_SSIZE_T "d expected",
29826                    (Py_ssize_t)ctx->fmt_offset, (Py_ssize_t)offset);
29827       return -1;
29828     }
29829     ctx->fmt_offset += size;
29830     if (arraysize)
29831       ctx->fmt_offset += (arraysize - 1) * size;
29832     --ctx->enc_count;
29833     while (1) {
29834       if (field == &ctx->root) {
29835         ctx->head = NULL;
29836         if (ctx->enc_count != 0) {
29837           __Pyx_BufFmt_RaiseExpected(ctx);
29838           return -1;
29839         }
29840         break;
29841       }
29842       ctx->head->field = ++field;
29843       if (field->type == NULL) {
29844         --ctx->head;
29845         field = ctx->head->field;
29846         continue;
29847       } else if (field->type->typegroup == 'S') {
29848         size_t parent_offset = ctx->head->parent_offset + field->offset;
29849         if (field->type->fields->type == NULL) continue;
29850         field = field->type->fields;
29851         ++ctx->head;
29852         ctx->head->field = field;
29853         ctx->head->parent_offset = parent_offset;
29854         break;
29855       } else {
29856         break;
29857       }
29858     }
29859   } while (ctx->enc_count);
29860   ctx->enc_type = 0;
29861   ctx->is_complex = 0;
29862   return 0;
29863 }
29864 static PyObject *
__pyx_buffmt_parse_array(__Pyx_BufFmt_Context * ctx,const char ** tsp)29865 __pyx_buffmt_parse_array(__Pyx_BufFmt_Context* ctx, const char** tsp)
29866 {
29867     const char *ts = *tsp;
29868     int i = 0, number, ndim;
29869     ++ts;
29870     if (ctx->new_count != 1) {
29871         PyErr_SetString(PyExc_ValueError,
29872                         "Cannot handle repeated arrays in format string");
29873         return NULL;
29874     }
29875     if (__Pyx_BufFmt_ProcessTypeChunk(ctx) == -1) return NULL;
29876     ndim = ctx->head->field->type->ndim;
29877     while (*ts && *ts != ')') {
29878         switch (*ts) {
29879             case ' ': case '\f': case '\r': case '\n': case '\t': case '\v':  continue;
29880             default:  break;
29881         }
29882         number = __Pyx_BufFmt_ExpectNumber(&ts);
29883         if (number == -1) return NULL;
29884         if (i < ndim && (size_t) number != ctx->head->field->type->arraysize[i])
29885             return PyErr_Format(PyExc_ValueError,
29886                         "Expected a dimension of size %zu, got %d",
29887                         ctx->head->field->type->arraysize[i], number);
29888         if (*ts != ',' && *ts != ')')
29889             return PyErr_Format(PyExc_ValueError,
29890                                 "Expected a comma in format string, got '%c'", *ts);
29891         if (*ts == ',') ts++;
29892         i++;
29893     }
29894     if (i != ndim)
29895         return PyErr_Format(PyExc_ValueError, "Expected %d dimension(s), got %d",
29896                             ctx->head->field->type->ndim, i);
29897     if (!*ts) {
29898         PyErr_SetString(PyExc_ValueError,
29899                         "Unexpected end of format string, expected ')'");
29900         return NULL;
29901     }
29902     ctx->is_valid_array = 1;
29903     ctx->new_count = 1;
29904     *tsp = ++ts;
29905     return Py_None;
29906 }
__Pyx_BufFmt_CheckString(__Pyx_BufFmt_Context * ctx,const char * ts)29907 static const char* __Pyx_BufFmt_CheckString(__Pyx_BufFmt_Context* ctx, const char* ts) {
29908   int got_Z = 0;
29909   while (1) {
29910     switch(*ts) {
29911       case 0:
29912         if (ctx->enc_type != 0 && ctx->head == NULL) {
29913           __Pyx_BufFmt_RaiseExpected(ctx);
29914           return NULL;
29915         }
29916         if (__Pyx_BufFmt_ProcessTypeChunk(ctx) == -1) return NULL;
29917         if (ctx->head != NULL) {
29918           __Pyx_BufFmt_RaiseExpected(ctx);
29919           return NULL;
29920         }
29921         return ts;
29922       case ' ':
29923       case '\r':
29924       case '\n':
29925         ++ts;
29926         break;
29927       case '<':
29928         if (!__Pyx_Is_Little_Endian()) {
29929           PyErr_SetString(PyExc_ValueError, "Little-endian buffer not supported on big-endian compiler");
29930           return NULL;
29931         }
29932         ctx->new_packmode = '=';
29933         ++ts;
29934         break;
29935       case '>':
29936       case '!':
29937         if (__Pyx_Is_Little_Endian()) {
29938           PyErr_SetString(PyExc_ValueError, "Big-endian buffer not supported on little-endian compiler");
29939           return NULL;
29940         }
29941         ctx->new_packmode = '=';
29942         ++ts;
29943         break;
29944       case '=':
29945       case '@':
29946       case '^':
29947         ctx->new_packmode = *ts++;
29948         break;
29949       case 'T':
29950         {
29951           const char* ts_after_sub;
29952           size_t i, struct_count = ctx->new_count;
29953           size_t struct_alignment = ctx->struct_alignment;
29954           ctx->new_count = 1;
29955           ++ts;
29956           if (*ts != '{') {
29957             PyErr_SetString(PyExc_ValueError, "Buffer acquisition: Expected '{' after 'T'");
29958             return NULL;
29959           }
29960           if (__Pyx_BufFmt_ProcessTypeChunk(ctx) == -1) return NULL;
29961           ctx->enc_type = 0;
29962           ctx->enc_count = 0;
29963           ctx->struct_alignment = 0;
29964           ++ts;
29965           ts_after_sub = ts;
29966           for (i = 0; i != struct_count; ++i) {
29967             ts_after_sub = __Pyx_BufFmt_CheckString(ctx, ts);
29968             if (!ts_after_sub) return NULL;
29969           }
29970           ts = ts_after_sub;
29971           if (struct_alignment) ctx->struct_alignment = struct_alignment;
29972         }
29973         break;
29974       case '}':
29975         {
29976           size_t alignment = ctx->struct_alignment;
29977           ++ts;
29978           if (__Pyx_BufFmt_ProcessTypeChunk(ctx) == -1) return NULL;
29979           ctx->enc_type = 0;
29980           if (alignment && ctx->fmt_offset % alignment) {
29981             ctx->fmt_offset += alignment - (ctx->fmt_offset % alignment);
29982           }
29983         }
29984         return ts;
29985       case 'x':
29986         if (__Pyx_BufFmt_ProcessTypeChunk(ctx) == -1) return NULL;
29987         ctx->fmt_offset += ctx->new_count;
29988         ctx->new_count = 1;
29989         ctx->enc_count = 0;
29990         ctx->enc_type = 0;
29991         ctx->enc_packmode = ctx->new_packmode;
29992         ++ts;
29993         break;
29994       case 'Z':
29995         got_Z = 1;
29996         ++ts;
29997         if (*ts != 'f' && *ts != 'd' && *ts != 'g') {
29998           __Pyx_BufFmt_RaiseUnexpectedChar('Z');
29999           return NULL;
30000         }
30001         CYTHON_FALLTHROUGH;
30002       case '?': case 'c': case 'b': case 'B': case 'h': case 'H': case 'i': case 'I':
30003       case 'l': case 'L': case 'q': case 'Q':
30004       case 'f': case 'd': case 'g':
30005       case 'O': case 'p':
30006         if ((ctx->enc_type == *ts) && (got_Z == ctx->is_complex) &&
30007             (ctx->enc_packmode == ctx->new_packmode) && (!ctx->is_valid_array)) {
30008           ctx->enc_count += ctx->new_count;
30009           ctx->new_count = 1;
30010           got_Z = 0;
30011           ++ts;
30012           break;
30013         }
30014         CYTHON_FALLTHROUGH;
30015       case 's':
30016         if (__Pyx_BufFmt_ProcessTypeChunk(ctx) == -1) return NULL;
30017         ctx->enc_count = ctx->new_count;
30018         ctx->enc_packmode = ctx->new_packmode;
30019         ctx->enc_type = *ts;
30020         ctx->is_complex = got_Z;
30021         ++ts;
30022         ctx->new_count = 1;
30023         got_Z = 0;
30024         break;
30025       case ':':
30026         ++ts;
30027         while(*ts != ':') ++ts;
30028         ++ts;
30029         break;
30030       case '(':
30031         if (!__pyx_buffmt_parse_array(ctx, &ts)) return NULL;
30032         break;
30033       default:
30034         {
30035           int number = __Pyx_BufFmt_ExpectNumber(&ts);
30036           if (number == -1) return NULL;
30037           ctx->new_count = (size_t)number;
30038         }
30039     }
30040   }
30041 }
30042 
30043 /* BufferGetAndValidate */
__Pyx_SafeReleaseBuffer(Py_buffer * info)30044   static CYTHON_INLINE void __Pyx_SafeReleaseBuffer(Py_buffer* info) {
30045   if (unlikely(info->buf == NULL)) return;
30046   if (info->suboffsets == __Pyx_minusones) info->suboffsets = NULL;
30047   __Pyx_ReleaseBuffer(info);
30048 }
__Pyx_ZeroBuffer(Py_buffer * buf)30049 static void __Pyx_ZeroBuffer(Py_buffer* buf) {
30050   buf->buf = NULL;
30051   buf->obj = NULL;
30052   buf->strides = __Pyx_zeros;
30053   buf->shape = __Pyx_zeros;
30054   buf->suboffsets = __Pyx_minusones;
30055 }
__Pyx__GetBufferAndValidate(Py_buffer * buf,PyObject * obj,__Pyx_TypeInfo * dtype,int flags,int nd,int cast,__Pyx_BufFmt_StackElem * stack)30056 static int __Pyx__GetBufferAndValidate(
30057         Py_buffer* buf, PyObject* obj,  __Pyx_TypeInfo* dtype, int flags,
30058         int nd, int cast, __Pyx_BufFmt_StackElem* stack)
30059 {
30060   buf->buf = NULL;
30061   if (unlikely(__Pyx_GetBuffer(obj, buf, flags) == -1)) {
30062     __Pyx_ZeroBuffer(buf);
30063     return -1;
30064   }
30065   if (unlikely(buf->ndim != nd)) {
30066     PyErr_Format(PyExc_ValueError,
30067                  "Buffer has wrong number of dimensions (expected %d, got %d)",
30068                  nd, buf->ndim);
30069     goto fail;
30070   }
30071   if (!cast) {
30072     __Pyx_BufFmt_Context ctx;
30073     __Pyx_BufFmt_Init(&ctx, stack, dtype);
30074     if (!__Pyx_BufFmt_CheckString(&ctx, buf->format)) goto fail;
30075   }
30076   if (unlikely((size_t)buf->itemsize != dtype->size)) {
30077     PyErr_Format(PyExc_ValueError,
30078       "Item size of buffer (%" CYTHON_FORMAT_SSIZE_T "d byte%s) does not match size of '%s' (%" CYTHON_FORMAT_SSIZE_T "d byte%s)",
30079       buf->itemsize, (buf->itemsize > 1) ? "s" : "",
30080       dtype->name, (Py_ssize_t)dtype->size, (dtype->size > 1) ? "s" : "");
30081     goto fail;
30082   }
30083   if (buf->suboffsets == NULL) buf->suboffsets = __Pyx_minusones;
30084   return 0;
30085 fail:;
30086   __Pyx_SafeReleaseBuffer(buf);
30087   return -1;
30088 }
30089 
30090 /* BufferFallbackError */
__Pyx_RaiseBufferFallbackError(void)30091   static void __Pyx_RaiseBufferFallbackError(void) {
30092   PyErr_SetString(PyExc_ValueError,
30093      "Buffer acquisition failed on assignment; and then reacquiring the old buffer failed too!");
30094 }
30095 
30096 /* PyDictVersioning */
30097   #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_TYPE_SLOTS
__Pyx_get_tp_dict_version(PyObject * obj)30098 static CYTHON_INLINE PY_UINT64_T __Pyx_get_tp_dict_version(PyObject *obj) {
30099     PyObject *dict = Py_TYPE(obj)->tp_dict;
30100     return likely(dict) ? __PYX_GET_DICT_VERSION(dict) : 0;
30101 }
__Pyx_get_object_dict_version(PyObject * obj)30102 static CYTHON_INLINE PY_UINT64_T __Pyx_get_object_dict_version(PyObject *obj) {
30103     PyObject **dictptr = NULL;
30104     Py_ssize_t offset = Py_TYPE(obj)->tp_dictoffset;
30105     if (offset) {
30106 #if CYTHON_COMPILING_IN_CPYTHON
30107         dictptr = (likely(offset > 0)) ? (PyObject **) ((char *)obj + offset) : _PyObject_GetDictPtr(obj);
30108 #else
30109         dictptr = _PyObject_GetDictPtr(obj);
30110 #endif
30111     }
30112     return (dictptr && *dictptr) ? __PYX_GET_DICT_VERSION(*dictptr) : 0;
30113 }
__Pyx_object_dict_version_matches(PyObject * obj,PY_UINT64_T tp_dict_version,PY_UINT64_T obj_dict_version)30114 static CYTHON_INLINE int __Pyx_object_dict_version_matches(PyObject* obj, PY_UINT64_T tp_dict_version, PY_UINT64_T obj_dict_version) {
30115     PyObject *dict = Py_TYPE(obj)->tp_dict;
30116     if (unlikely(!dict) || unlikely(tp_dict_version != __PYX_GET_DICT_VERSION(dict)))
30117         return 0;
30118     return obj_dict_version == __Pyx_get_object_dict_version(obj);
30119 }
30120 #endif
30121 
30122 /* GetModuleGlobalName */
30123   #if CYTHON_USE_DICT_VERSIONS
__Pyx__GetModuleGlobalName(PyObject * name,PY_UINT64_T * dict_version,PyObject ** dict_cached_value)30124 static PyObject *__Pyx__GetModuleGlobalName(PyObject *name, PY_UINT64_T *dict_version, PyObject **dict_cached_value)
30125 #else
30126 static CYTHON_INLINE PyObject *__Pyx__GetModuleGlobalName(PyObject *name)
30127 #endif
30128 {
30129     PyObject *result;
30130 #if !CYTHON_AVOID_BORROWED_REFS
30131 #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030500A1
30132     result = _PyDict_GetItem_KnownHash(__pyx_d, name, ((PyASCIIObject *) name)->hash);
30133     __PYX_UPDATE_DICT_CACHE(__pyx_d, result, *dict_cached_value, *dict_version)
30134     if (likely(result)) {
30135         return __Pyx_NewRef(result);
30136     } else if (unlikely(PyErr_Occurred())) {
30137         return NULL;
30138     }
30139 #else
30140     result = PyDict_GetItem(__pyx_d, name);
30141     __PYX_UPDATE_DICT_CACHE(__pyx_d, result, *dict_cached_value, *dict_version)
30142     if (likely(result)) {
30143         return __Pyx_NewRef(result);
30144     }
30145 #endif
30146 #else
30147     result = PyObject_GetItem(__pyx_d, name);
30148     __PYX_UPDATE_DICT_CACHE(__pyx_d, result, *dict_cached_value, *dict_version)
30149     if (likely(result)) {
30150         return __Pyx_NewRef(result);
30151     }
30152     PyErr_Clear();
30153 #endif
30154     return __Pyx_GetBuiltinName(name);
30155 }
30156 
30157 /* GetItemInt */
__Pyx_GetItemInt_Generic(PyObject * o,PyObject * j)30158   static PyObject *__Pyx_GetItemInt_Generic(PyObject *o, PyObject* j) {
30159     PyObject *r;
30160     if (!j) return NULL;
30161     r = PyObject_GetItem(o, j);
30162     Py_DECREF(j);
30163     return r;
30164 }
__Pyx_GetItemInt_List_Fast(PyObject * o,Py_ssize_t i,CYTHON_NCP_UNUSED int wraparound,CYTHON_NCP_UNUSED int boundscheck)30165 static CYTHON_INLINE PyObject *__Pyx_GetItemInt_List_Fast(PyObject *o, Py_ssize_t i,
30166                                                               CYTHON_NCP_UNUSED int wraparound,
30167                                                               CYTHON_NCP_UNUSED int boundscheck) {
30168 #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
30169     Py_ssize_t wrapped_i = i;
30170     if (wraparound & unlikely(i < 0)) {
30171         wrapped_i += PyList_GET_SIZE(o);
30172     }
30173     if ((!boundscheck) || likely(__Pyx_is_valid_index(wrapped_i, PyList_GET_SIZE(o)))) {
30174         PyObject *r = PyList_GET_ITEM(o, wrapped_i);
30175         Py_INCREF(r);
30176         return r;
30177     }
30178     return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i));
30179 #else
30180     return PySequence_GetItem(o, i);
30181 #endif
30182 }
__Pyx_GetItemInt_Tuple_Fast(PyObject * o,Py_ssize_t i,CYTHON_NCP_UNUSED int wraparound,CYTHON_NCP_UNUSED int boundscheck)30183 static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Tuple_Fast(PyObject *o, Py_ssize_t i,
30184                                                               CYTHON_NCP_UNUSED int wraparound,
30185                                                               CYTHON_NCP_UNUSED int boundscheck) {
30186 #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
30187     Py_ssize_t wrapped_i = i;
30188     if (wraparound & unlikely(i < 0)) {
30189         wrapped_i += PyTuple_GET_SIZE(o);
30190     }
30191     if ((!boundscheck) || likely(__Pyx_is_valid_index(wrapped_i, PyTuple_GET_SIZE(o)))) {
30192         PyObject *r = PyTuple_GET_ITEM(o, wrapped_i);
30193         Py_INCREF(r);
30194         return r;
30195     }
30196     return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i));
30197 #else
30198     return PySequence_GetItem(o, i);
30199 #endif
30200 }
__Pyx_GetItemInt_Fast(PyObject * o,Py_ssize_t i,int is_list,CYTHON_NCP_UNUSED int wraparound,CYTHON_NCP_UNUSED int boundscheck)30201 static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Fast(PyObject *o, Py_ssize_t i, int is_list,
30202                                                      CYTHON_NCP_UNUSED int wraparound,
30203                                                      CYTHON_NCP_UNUSED int boundscheck) {
30204 #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS && CYTHON_USE_TYPE_SLOTS
30205     if (is_list || PyList_CheckExact(o)) {
30206         Py_ssize_t n = ((!wraparound) | likely(i >= 0)) ? i : i + PyList_GET_SIZE(o);
30207         if ((!boundscheck) || (likely(__Pyx_is_valid_index(n, PyList_GET_SIZE(o))))) {
30208             PyObject *r = PyList_GET_ITEM(o, n);
30209             Py_INCREF(r);
30210             return r;
30211         }
30212     }
30213     else if (PyTuple_CheckExact(o)) {
30214         Py_ssize_t n = ((!wraparound) | likely(i >= 0)) ? i : i + PyTuple_GET_SIZE(o);
30215         if ((!boundscheck) || likely(__Pyx_is_valid_index(n, PyTuple_GET_SIZE(o)))) {
30216             PyObject *r = PyTuple_GET_ITEM(o, n);
30217             Py_INCREF(r);
30218             return r;
30219         }
30220     } else {
30221         PySequenceMethods *m = Py_TYPE(o)->tp_as_sequence;
30222         if (likely(m && m->sq_item)) {
30223             if (wraparound && unlikely(i < 0) && likely(m->sq_length)) {
30224                 Py_ssize_t l = m->sq_length(o);
30225                 if (likely(l >= 0)) {
30226                     i += l;
30227                 } else {
30228                     if (!PyErr_ExceptionMatches(PyExc_OverflowError))
30229                         return NULL;
30230                     PyErr_Clear();
30231                 }
30232             }
30233             return m->sq_item(o, i);
30234         }
30235     }
30236 #else
30237     if (is_list || PySequence_Check(o)) {
30238         return PySequence_GetItem(o, i);
30239     }
30240 #endif
30241     return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i));
30242 }
30243 
30244 /* MemviewSliceInit */
30245   static int
__Pyx_init_memviewslice(struct __pyx_memoryview_obj * memview,int ndim,__Pyx_memviewslice * memviewslice,int memview_is_new_reference)30246 __Pyx_init_memviewslice(struct __pyx_memoryview_obj *memview,
30247                         int ndim,
30248                         __Pyx_memviewslice *memviewslice,
30249                         int memview_is_new_reference)
30250 {
30251     __Pyx_RefNannyDeclarations
30252     int i, retval=-1;
30253     Py_buffer *buf = &memview->view;
30254     __Pyx_RefNannySetupContext("init_memviewslice", 0);
30255     if (unlikely(memviewslice->memview || memviewslice->data)) {
30256         PyErr_SetString(PyExc_ValueError,
30257             "memviewslice is already initialized!");
30258         goto fail;
30259     }
30260     if (buf->strides) {
30261         for (i = 0; i < ndim; i++) {
30262             memviewslice->strides[i] = buf->strides[i];
30263         }
30264     } else {
30265         Py_ssize_t stride = buf->itemsize;
30266         for (i = ndim - 1; i >= 0; i--) {
30267             memviewslice->strides[i] = stride;
30268             stride *= buf->shape[i];
30269         }
30270     }
30271     for (i = 0; i < ndim; i++) {
30272         memviewslice->shape[i]   = buf->shape[i];
30273         if (buf->suboffsets) {
30274             memviewslice->suboffsets[i] = buf->suboffsets[i];
30275         } else {
30276             memviewslice->suboffsets[i] = -1;
30277         }
30278     }
30279     memviewslice->memview = memview;
30280     memviewslice->data = (char *)buf->buf;
30281     if (__pyx_add_acquisition_count(memview) == 0 && !memview_is_new_reference) {
30282         Py_INCREF(memview);
30283     }
30284     retval = 0;
30285     goto no_fail;
30286 fail:
30287     memviewslice->memview = 0;
30288     memviewslice->data = 0;
30289     retval = -1;
30290 no_fail:
30291     __Pyx_RefNannyFinishContext();
30292     return retval;
30293 }
30294 #ifndef Py_NO_RETURN
30295 #define Py_NO_RETURN
30296 #endif
__pyx_fatalerror(const char * fmt,...)30297 static void __pyx_fatalerror(const char *fmt, ...) Py_NO_RETURN {
30298     va_list vargs;
30299     char msg[200];
30300 #ifdef HAVE_STDARG_PROTOTYPES
30301     va_start(vargs, fmt);
30302 #else
30303     va_start(vargs);
30304 #endif
30305     vsnprintf(msg, 200, fmt, vargs);
30306     va_end(vargs);
30307     Py_FatalError(msg);
30308 }
30309 static CYTHON_INLINE int
__pyx_add_acquisition_count_locked(__pyx_atomic_int * acquisition_count,PyThread_type_lock lock)30310 __pyx_add_acquisition_count_locked(__pyx_atomic_int *acquisition_count,
30311                                    PyThread_type_lock lock)
30312 {
30313     int result;
30314     PyThread_acquire_lock(lock, 1);
30315     result = (*acquisition_count)++;
30316     PyThread_release_lock(lock);
30317     return result;
30318 }
30319 static CYTHON_INLINE int
__pyx_sub_acquisition_count_locked(__pyx_atomic_int * acquisition_count,PyThread_type_lock lock)30320 __pyx_sub_acquisition_count_locked(__pyx_atomic_int *acquisition_count,
30321                                    PyThread_type_lock lock)
30322 {
30323     int result;
30324     PyThread_acquire_lock(lock, 1);
30325     result = (*acquisition_count)--;
30326     PyThread_release_lock(lock);
30327     return result;
30328 }
30329 static CYTHON_INLINE void
__Pyx_INC_MEMVIEW(__Pyx_memviewslice * memslice,int have_gil,int lineno)30330 __Pyx_INC_MEMVIEW(__Pyx_memviewslice *memslice, int have_gil, int lineno)
30331 {
30332     int first_time;
30333     struct __pyx_memoryview_obj *memview = memslice->memview;
30334     if (unlikely(!memview || (PyObject *) memview == Py_None))
30335         return;
30336     if (unlikely(__pyx_get_slice_count(memview) < 0))
30337         __pyx_fatalerror("Acquisition count is %d (line %d)",
30338                          __pyx_get_slice_count(memview), lineno);
30339     first_time = __pyx_add_acquisition_count(memview) == 0;
30340     if (unlikely(first_time)) {
30341         if (have_gil) {
30342             Py_INCREF((PyObject *) memview);
30343         } else {
30344             PyGILState_STATE _gilstate = PyGILState_Ensure();
30345             Py_INCREF((PyObject *) memview);
30346             PyGILState_Release(_gilstate);
30347         }
30348     }
30349 }
__Pyx_XDEC_MEMVIEW(__Pyx_memviewslice * memslice,int have_gil,int lineno)30350 static CYTHON_INLINE void __Pyx_XDEC_MEMVIEW(__Pyx_memviewslice *memslice,
30351                                              int have_gil, int lineno) {
30352     int last_time;
30353     struct __pyx_memoryview_obj *memview = memslice->memview;
30354     if (unlikely(!memview || (PyObject *) memview == Py_None)) {
30355         memslice->memview = NULL;
30356         return;
30357     }
30358     if (unlikely(__pyx_get_slice_count(memview) <= 0))
30359         __pyx_fatalerror("Acquisition count is %d (line %d)",
30360                          __pyx_get_slice_count(memview), lineno);
30361     last_time = __pyx_sub_acquisition_count(memview) == 1;
30362     memslice->data = NULL;
30363     if (unlikely(last_time)) {
30364         if (have_gil) {
30365             Py_CLEAR(memslice->memview);
30366         } else {
30367             PyGILState_STATE _gilstate = PyGILState_Ensure();
30368             Py_CLEAR(memslice->memview);
30369             PyGILState_Release(_gilstate);
30370         }
30371     } else {
30372         memslice->memview = NULL;
30373     }
30374 }
30375 
30376 /* RaiseArgTupleInvalid */
__Pyx_RaiseArgtupleInvalid(const char * func_name,int exact,Py_ssize_t num_min,Py_ssize_t num_max,Py_ssize_t num_found)30377   static void __Pyx_RaiseArgtupleInvalid(
30378     const char* func_name,
30379     int exact,
30380     Py_ssize_t num_min,
30381     Py_ssize_t num_max,
30382     Py_ssize_t num_found)
30383 {
30384     Py_ssize_t num_expected;
30385     const char *more_or_less;
30386     if (num_found < num_min) {
30387         num_expected = num_min;
30388         more_or_less = "at least";
30389     } else {
30390         num_expected = num_max;
30391         more_or_less = "at most";
30392     }
30393     if (exact) {
30394         more_or_less = "exactly";
30395     }
30396     PyErr_Format(PyExc_TypeError,
30397                  "%.200s() takes %.8s %" CYTHON_FORMAT_SSIZE_T "d positional argument%.1s (%" CYTHON_FORMAT_SSIZE_T "d given)",
30398                  func_name, more_or_less, num_expected,
30399                  (num_expected == 1) ? "" : "s", num_found);
30400 }
30401 
30402 /* RaiseDoubleKeywords */
__Pyx_RaiseDoubleKeywordsError(const char * func_name,PyObject * kw_name)30403   static void __Pyx_RaiseDoubleKeywordsError(
30404     const char* func_name,
30405     PyObject* kw_name)
30406 {
30407     PyErr_Format(PyExc_TypeError,
30408         #if PY_MAJOR_VERSION >= 3
30409         "%s() got multiple values for keyword argument '%U'", func_name, kw_name);
30410         #else
30411         "%s() got multiple values for keyword argument '%s'", func_name,
30412         PyString_AsString(kw_name));
30413         #endif
30414 }
30415 
30416 /* ParseKeywords */
__Pyx_ParseOptionalKeywords(PyObject * kwds,PyObject ** argnames[],PyObject * kwds2,PyObject * values[],Py_ssize_t num_pos_args,const char * function_name)30417   static int __Pyx_ParseOptionalKeywords(
30418     PyObject *kwds,
30419     PyObject **argnames[],
30420     PyObject *kwds2,
30421     PyObject *values[],
30422     Py_ssize_t num_pos_args,
30423     const char* function_name)
30424 {
30425     PyObject *key = 0, *value = 0;
30426     Py_ssize_t pos = 0;
30427     PyObject*** name;
30428     PyObject*** first_kw_arg = argnames + num_pos_args;
30429     while (PyDict_Next(kwds, &pos, &key, &value)) {
30430         name = first_kw_arg;
30431         while (*name && (**name != key)) name++;
30432         if (*name) {
30433             values[name-argnames] = value;
30434             continue;
30435         }
30436         name = first_kw_arg;
30437         #if PY_MAJOR_VERSION < 3
30438         if (likely(PyString_Check(key))) {
30439             while (*name) {
30440                 if ((CYTHON_COMPILING_IN_PYPY || PyString_GET_SIZE(**name) == PyString_GET_SIZE(key))
30441                         && _PyString_Eq(**name, key)) {
30442                     values[name-argnames] = value;
30443                     break;
30444                 }
30445                 name++;
30446             }
30447             if (*name) continue;
30448             else {
30449                 PyObject*** argname = argnames;
30450                 while (argname != first_kw_arg) {
30451                     if ((**argname == key) || (
30452                             (CYTHON_COMPILING_IN_PYPY || PyString_GET_SIZE(**argname) == PyString_GET_SIZE(key))
30453                              && _PyString_Eq(**argname, key))) {
30454                         goto arg_passed_twice;
30455                     }
30456                     argname++;
30457                 }
30458             }
30459         } else
30460         #endif
30461         if (likely(PyUnicode_Check(key))) {
30462             while (*name) {
30463                 int cmp = (**name == key) ? 0 :
30464                 #if !CYTHON_COMPILING_IN_PYPY && PY_MAJOR_VERSION >= 3
30465                     (__Pyx_PyUnicode_GET_LENGTH(**name) != __Pyx_PyUnicode_GET_LENGTH(key)) ? 1 :
30466                 #endif
30467                     PyUnicode_Compare(**name, key);
30468                 if (cmp < 0 && unlikely(PyErr_Occurred())) goto bad;
30469                 if (cmp == 0) {
30470                     values[name-argnames] = value;
30471                     break;
30472                 }
30473                 name++;
30474             }
30475             if (*name) continue;
30476             else {
30477                 PyObject*** argname = argnames;
30478                 while (argname != first_kw_arg) {
30479                     int cmp = (**argname == key) ? 0 :
30480                     #if !CYTHON_COMPILING_IN_PYPY && PY_MAJOR_VERSION >= 3
30481                         (__Pyx_PyUnicode_GET_LENGTH(**argname) != __Pyx_PyUnicode_GET_LENGTH(key)) ? 1 :
30482                     #endif
30483                         PyUnicode_Compare(**argname, key);
30484                     if (cmp < 0 && unlikely(PyErr_Occurred())) goto bad;
30485                     if (cmp == 0) goto arg_passed_twice;
30486                     argname++;
30487                 }
30488             }
30489         } else
30490             goto invalid_keyword_type;
30491         if (kwds2) {
30492             if (unlikely(PyDict_SetItem(kwds2, key, value))) goto bad;
30493         } else {
30494             goto invalid_keyword;
30495         }
30496     }
30497     return 0;
30498 arg_passed_twice:
30499     __Pyx_RaiseDoubleKeywordsError(function_name, key);
30500     goto bad;
30501 invalid_keyword_type:
30502     PyErr_Format(PyExc_TypeError,
30503         "%.200s() keywords must be strings", function_name);
30504     goto bad;
30505 invalid_keyword:
30506     PyErr_Format(PyExc_TypeError,
30507     #if PY_MAJOR_VERSION < 3
30508         "%.200s() got an unexpected keyword argument '%.200s'",
30509         function_name, PyString_AsString(key));
30510     #else
30511         "%s() got an unexpected keyword argument '%U'",
30512         function_name, key);
30513     #endif
30514 bad:
30515     return -1;
30516 }
30517 
30518 /* None */
__Pyx_RaiseUnboundLocalError(const char * varname)30519   static CYTHON_INLINE void __Pyx_RaiseUnboundLocalError(const char *varname) {
30520     PyErr_Format(PyExc_UnboundLocalError, "local variable '%s' referenced before assignment", varname);
30521 }
30522 
30523 /* PyCFunctionFastCall */
30524   #if CYTHON_FAST_PYCCALL
__Pyx_PyCFunction_FastCall(PyObject * func_obj,PyObject ** args,Py_ssize_t nargs)30525 static CYTHON_INLINE PyObject * __Pyx_PyCFunction_FastCall(PyObject *func_obj, PyObject **args, Py_ssize_t nargs) {
30526     PyCFunctionObject *func = (PyCFunctionObject*)func_obj;
30527     PyCFunction meth = PyCFunction_GET_FUNCTION(func);
30528     PyObject *self = PyCFunction_GET_SELF(func);
30529     int flags = PyCFunction_GET_FLAGS(func);
30530     assert(PyCFunction_Check(func));
30531     assert(METH_FASTCALL == (flags & ~(METH_CLASS | METH_STATIC | METH_COEXIST | METH_KEYWORDS | METH_STACKLESS)));
30532     assert(nargs >= 0);
30533     assert(nargs == 0 || args != NULL);
30534     /* _PyCFunction_FastCallDict() must not be called with an exception set,
30535        because it may clear it (directly or indirectly) and so the
30536        caller loses its exception */
30537     assert(!PyErr_Occurred());
30538     if ((PY_VERSION_HEX < 0x030700A0) || unlikely(flags & METH_KEYWORDS)) {
30539         return (*((__Pyx_PyCFunctionFastWithKeywords)(void*)meth)) (self, args, nargs, NULL);
30540     } else {
30541         return (*((__Pyx_PyCFunctionFast)(void*)meth)) (self, args, nargs);
30542     }
30543 }
30544 #endif
30545 
30546 /* PyFunctionFastCall */
30547   #if CYTHON_FAST_PYCALL
__Pyx_PyFunction_FastCallNoKw(PyCodeObject * co,PyObject ** args,Py_ssize_t na,PyObject * globals)30548 static PyObject* __Pyx_PyFunction_FastCallNoKw(PyCodeObject *co, PyObject **args, Py_ssize_t na,
30549                                                PyObject *globals) {
30550     PyFrameObject *f;
30551     PyThreadState *tstate = __Pyx_PyThreadState_Current;
30552     PyObject **fastlocals;
30553     Py_ssize_t i;
30554     PyObject *result;
30555     assert(globals != NULL);
30556     /* XXX Perhaps we should create a specialized
30557        PyFrame_New() that doesn't take locals, but does
30558        take builtins without sanity checking them.
30559        */
30560     assert(tstate != NULL);
30561     f = PyFrame_New(tstate, co, globals, NULL);
30562     if (f == NULL) {
30563         return NULL;
30564     }
30565     fastlocals = __Pyx_PyFrame_GetLocalsplus(f);
30566     for (i = 0; i < na; i++) {
30567         Py_INCREF(*args);
30568         fastlocals[i] = *args++;
30569     }
30570     result = PyEval_EvalFrameEx(f,0);
30571     ++tstate->recursion_depth;
30572     Py_DECREF(f);
30573     --tstate->recursion_depth;
30574     return result;
30575 }
30576 #if 1 || PY_VERSION_HEX < 0x030600B1
__Pyx_PyFunction_FastCallDict(PyObject * func,PyObject ** args,Py_ssize_t nargs,PyObject * kwargs)30577 static PyObject *__Pyx_PyFunction_FastCallDict(PyObject *func, PyObject **args, Py_ssize_t nargs, PyObject *kwargs) {
30578     PyCodeObject *co = (PyCodeObject *)PyFunction_GET_CODE(func);
30579     PyObject *globals = PyFunction_GET_GLOBALS(func);
30580     PyObject *argdefs = PyFunction_GET_DEFAULTS(func);
30581     PyObject *closure;
30582 #if PY_MAJOR_VERSION >= 3
30583     PyObject *kwdefs;
30584 #endif
30585     PyObject *kwtuple, **k;
30586     PyObject **d;
30587     Py_ssize_t nd;
30588     Py_ssize_t nk;
30589     PyObject *result;
30590     assert(kwargs == NULL || PyDict_Check(kwargs));
30591     nk = kwargs ? PyDict_Size(kwargs) : 0;
30592     if (Py_EnterRecursiveCall((char*)" while calling a Python object")) {
30593         return NULL;
30594     }
30595     if (
30596 #if PY_MAJOR_VERSION >= 3
30597             co->co_kwonlyargcount == 0 &&
30598 #endif
30599             likely(kwargs == NULL || nk == 0) &&
30600             co->co_flags == (CO_OPTIMIZED | CO_NEWLOCALS | CO_NOFREE)) {
30601         if (argdefs == NULL && co->co_argcount == nargs) {
30602             result = __Pyx_PyFunction_FastCallNoKw(co, args, nargs, globals);
30603             goto done;
30604         }
30605         else if (nargs == 0 && argdefs != NULL
30606                  && co->co_argcount == Py_SIZE(argdefs)) {
30607             /* function called with no arguments, but all parameters have
30608                a default value: use default values as arguments .*/
30609             args = &PyTuple_GET_ITEM(argdefs, 0);
30610             result =__Pyx_PyFunction_FastCallNoKw(co, args, Py_SIZE(argdefs), globals);
30611             goto done;
30612         }
30613     }
30614     if (kwargs != NULL) {
30615         Py_ssize_t pos, i;
30616         kwtuple = PyTuple_New(2 * nk);
30617         if (kwtuple == NULL) {
30618             result = NULL;
30619             goto done;
30620         }
30621         k = &PyTuple_GET_ITEM(kwtuple, 0);
30622         pos = i = 0;
30623         while (PyDict_Next(kwargs, &pos, &k[i], &k[i+1])) {
30624             Py_INCREF(k[i]);
30625             Py_INCREF(k[i+1]);
30626             i += 2;
30627         }
30628         nk = i / 2;
30629     }
30630     else {
30631         kwtuple = NULL;
30632         k = NULL;
30633     }
30634     closure = PyFunction_GET_CLOSURE(func);
30635 #if PY_MAJOR_VERSION >= 3
30636     kwdefs = PyFunction_GET_KW_DEFAULTS(func);
30637 #endif
30638     if (argdefs != NULL) {
30639         d = &PyTuple_GET_ITEM(argdefs, 0);
30640         nd = Py_SIZE(argdefs);
30641     }
30642     else {
30643         d = NULL;
30644         nd = 0;
30645     }
30646 #if PY_MAJOR_VERSION >= 3
30647     result = PyEval_EvalCodeEx((PyObject*)co, globals, (PyObject *)NULL,
30648                                args, (int)nargs,
30649                                k, (int)nk,
30650                                d, (int)nd, kwdefs, closure);
30651 #else
30652     result = PyEval_EvalCodeEx(co, globals, (PyObject *)NULL,
30653                                args, (int)nargs,
30654                                k, (int)nk,
30655                                d, (int)nd, closure);
30656 #endif
30657     Py_XDECREF(kwtuple);
30658 done:
30659     Py_LeaveRecursiveCall();
30660     return result;
30661 }
30662 #endif
30663 #endif
30664 
30665 /* PyObjectCallMethO */
30666   #if CYTHON_COMPILING_IN_CPYTHON
__Pyx_PyObject_CallMethO(PyObject * func,PyObject * arg)30667 static CYTHON_INLINE PyObject* __Pyx_PyObject_CallMethO(PyObject *func, PyObject *arg) {
30668     PyObject *self, *result;
30669     PyCFunction cfunc;
30670     cfunc = PyCFunction_GET_FUNCTION(func);
30671     self = PyCFunction_GET_SELF(func);
30672     if (unlikely(Py_EnterRecursiveCall((char*)" while calling a Python object")))
30673         return NULL;
30674     result = cfunc(self, arg);
30675     Py_LeaveRecursiveCall();
30676     if (unlikely(!result) && unlikely(!PyErr_Occurred())) {
30677         PyErr_SetString(
30678             PyExc_SystemError,
30679             "NULL result without error in PyObject_Call");
30680     }
30681     return result;
30682 }
30683 #endif
30684 
30685 /* PyObjectCallOneArg */
30686   #if CYTHON_COMPILING_IN_CPYTHON
__Pyx__PyObject_CallOneArg(PyObject * func,PyObject * arg)30687 static PyObject* __Pyx__PyObject_CallOneArg(PyObject *func, PyObject *arg) {
30688     PyObject *result;
30689     PyObject *args = PyTuple_New(1);
30690     if (unlikely(!args)) return NULL;
30691     Py_INCREF(arg);
30692     PyTuple_SET_ITEM(args, 0, arg);
30693     result = __Pyx_PyObject_Call(func, args, NULL);
30694     Py_DECREF(args);
30695     return result;
30696 }
__Pyx_PyObject_CallOneArg(PyObject * func,PyObject * arg)30697 static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg) {
30698 #if CYTHON_FAST_PYCALL
30699     if (PyFunction_Check(func)) {
30700         return __Pyx_PyFunction_FastCall(func, &arg, 1);
30701     }
30702 #endif
30703     if (likely(PyCFunction_Check(func))) {
30704         if (likely(PyCFunction_GET_FLAGS(func) & METH_O)) {
30705             return __Pyx_PyObject_CallMethO(func, arg);
30706 #if CYTHON_FAST_PYCCALL
30707         } else if (__Pyx_PyFastCFunction_Check(func)) {
30708             return __Pyx_PyCFunction_FastCall(func, &arg, 1);
30709 #endif
30710         }
30711     }
30712     return __Pyx__PyObject_CallOneArg(func, arg);
30713 }
30714 #else
__Pyx_PyObject_CallOneArg(PyObject * func,PyObject * arg)30715 static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg) {
30716     PyObject *result;
30717     PyObject *args = PyTuple_Pack(1, arg);
30718     if (unlikely(!args)) return NULL;
30719     result = __Pyx_PyObject_Call(func, args, NULL);
30720     Py_DECREF(args);
30721     return result;
30722 }
30723 #endif
30724 
30725 /* PyObjectCall2Args */
__Pyx_PyObject_Call2Args(PyObject * function,PyObject * arg1,PyObject * arg2)30726   static CYTHON_UNUSED PyObject* __Pyx_PyObject_Call2Args(PyObject* function, PyObject* arg1, PyObject* arg2) {
30727     PyObject *args, *result = NULL;
30728     #if CYTHON_FAST_PYCALL
30729     if (PyFunction_Check(function)) {
30730         PyObject *args[2] = {arg1, arg2};
30731         return __Pyx_PyFunction_FastCall(function, args, 2);
30732     }
30733     #endif
30734     #if CYTHON_FAST_PYCCALL
30735     if (__Pyx_PyFastCFunction_Check(function)) {
30736         PyObject *args[2] = {arg1, arg2};
30737         return __Pyx_PyCFunction_FastCall(function, args, 2);
30738     }
30739     #endif
30740     args = PyTuple_New(2);
30741     if (unlikely(!args)) goto done;
30742     Py_INCREF(arg1);
30743     PyTuple_SET_ITEM(args, 0, arg1);
30744     Py_INCREF(arg2);
30745     PyTuple_SET_ITEM(args, 1, arg2);
30746     Py_INCREF(function);
30747     result = __Pyx_PyObject_Call(function, args, NULL);
30748     Py_DECREF(args);
30749     Py_DECREF(function);
30750 done:
30751     return result;
30752 }
30753 
30754 /* ObjectGetItem */
30755   #if CYTHON_USE_TYPE_SLOTS
__Pyx_PyObject_GetIndex(PyObject * obj,PyObject * index)30756 static PyObject *__Pyx_PyObject_GetIndex(PyObject *obj, PyObject* index) {
30757     PyObject *runerr;
30758     Py_ssize_t key_value;
30759     PySequenceMethods *m = Py_TYPE(obj)->tp_as_sequence;
30760     if (unlikely(!(m && m->sq_item))) {
30761         PyErr_Format(PyExc_TypeError, "'%.200s' object is not subscriptable", Py_TYPE(obj)->tp_name);
30762         return NULL;
30763     }
30764     key_value = __Pyx_PyIndex_AsSsize_t(index);
30765     if (likely(key_value != -1 || !(runerr = PyErr_Occurred()))) {
30766         return __Pyx_GetItemInt_Fast(obj, key_value, 0, 1, 1);
30767     }
30768     if (PyErr_GivenExceptionMatches(runerr, PyExc_OverflowError)) {
30769         PyErr_Clear();
30770         PyErr_Format(PyExc_IndexError, "cannot fit '%.200s' into an index-sized integer", Py_TYPE(index)->tp_name);
30771     }
30772     return NULL;
30773 }
__Pyx_PyObject_GetItem(PyObject * obj,PyObject * key)30774 static PyObject *__Pyx_PyObject_GetItem(PyObject *obj, PyObject* key) {
30775     PyMappingMethods *m = Py_TYPE(obj)->tp_as_mapping;
30776     if (likely(m && m->mp_subscript)) {
30777         return m->mp_subscript(obj, key);
30778     }
30779     return __Pyx_PyObject_GetIndex(obj, key);
30780 }
30781 #endif
30782 
30783 /* GetTopmostException */
30784   #if CYTHON_USE_EXC_INFO_STACK
30785 static _PyErr_StackItem *
__Pyx_PyErr_GetTopmostException(PyThreadState * tstate)30786 __Pyx_PyErr_GetTopmostException(PyThreadState *tstate)
30787 {
30788     _PyErr_StackItem *exc_info = tstate->exc_info;
30789     while ((exc_info->exc_type == NULL || exc_info->exc_type == Py_None) &&
30790            exc_info->previous_item != NULL)
30791     {
30792         exc_info = exc_info->previous_item;
30793     }
30794     return exc_info;
30795 }
30796 #endif
30797 
30798 /* SaveResetException */
30799   #if CYTHON_FAST_THREAD_STATE
__Pyx__ExceptionSave(PyThreadState * tstate,PyObject ** type,PyObject ** value,PyObject ** tb)30800 static CYTHON_INLINE void __Pyx__ExceptionSave(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) {
30801     #if CYTHON_USE_EXC_INFO_STACK
30802     _PyErr_StackItem *exc_info = __Pyx_PyErr_GetTopmostException(tstate);
30803     *type = exc_info->exc_type;
30804     *value = exc_info->exc_value;
30805     *tb = exc_info->exc_traceback;
30806     #else
30807     *type = tstate->exc_type;
30808     *value = tstate->exc_value;
30809     *tb = tstate->exc_traceback;
30810     #endif
30811     Py_XINCREF(*type);
30812     Py_XINCREF(*value);
30813     Py_XINCREF(*tb);
30814 }
__Pyx__ExceptionReset(PyThreadState * tstate,PyObject * type,PyObject * value,PyObject * tb)30815 static CYTHON_INLINE void __Pyx__ExceptionReset(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb) {
30816     PyObject *tmp_type, *tmp_value, *tmp_tb;
30817     #if CYTHON_USE_EXC_INFO_STACK
30818     _PyErr_StackItem *exc_info = tstate->exc_info;
30819     tmp_type = exc_info->exc_type;
30820     tmp_value = exc_info->exc_value;
30821     tmp_tb = exc_info->exc_traceback;
30822     exc_info->exc_type = type;
30823     exc_info->exc_value = value;
30824     exc_info->exc_traceback = tb;
30825     #else
30826     tmp_type = tstate->exc_type;
30827     tmp_value = tstate->exc_value;
30828     tmp_tb = tstate->exc_traceback;
30829     tstate->exc_type = type;
30830     tstate->exc_value = value;
30831     tstate->exc_traceback = tb;
30832     #endif
30833     Py_XDECREF(tmp_type);
30834     Py_XDECREF(tmp_value);
30835     Py_XDECREF(tmp_tb);
30836 }
30837 #endif
30838 
30839 /* PyErrExceptionMatches */
30840   #if CYTHON_FAST_THREAD_STATE
__Pyx_PyErr_ExceptionMatchesTuple(PyObject * exc_type,PyObject * tuple)30841 static int __Pyx_PyErr_ExceptionMatchesTuple(PyObject *exc_type, PyObject *tuple) {
30842     Py_ssize_t i, n;
30843     n = PyTuple_GET_SIZE(tuple);
30844 #if PY_MAJOR_VERSION >= 3
30845     for (i=0; i<n; i++) {
30846         if (exc_type == PyTuple_GET_ITEM(tuple, i)) return 1;
30847     }
30848 #endif
30849     for (i=0; i<n; i++) {
30850         if (__Pyx_PyErr_GivenExceptionMatches(exc_type, PyTuple_GET_ITEM(tuple, i))) return 1;
30851     }
30852     return 0;
30853 }
__Pyx_PyErr_ExceptionMatchesInState(PyThreadState * tstate,PyObject * err)30854 static CYTHON_INLINE int __Pyx_PyErr_ExceptionMatchesInState(PyThreadState* tstate, PyObject* err) {
30855     PyObject *exc_type = tstate->curexc_type;
30856     if (exc_type == err) return 1;
30857     if (unlikely(!exc_type)) return 0;
30858     if (unlikely(PyTuple_Check(err)))
30859         return __Pyx_PyErr_ExceptionMatchesTuple(exc_type, err);
30860     return __Pyx_PyErr_GivenExceptionMatches(exc_type, err);
30861 }
30862 #endif
30863 
30864 /* GetException */
30865   #if CYTHON_FAST_THREAD_STATE
__Pyx__GetException(PyThreadState * tstate,PyObject ** type,PyObject ** value,PyObject ** tb)30866 static int __Pyx__GetException(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb)
30867 #else
30868 static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb)
30869 #endif
30870 {
30871     PyObject *local_type, *local_value, *local_tb;
30872 #if CYTHON_FAST_THREAD_STATE
30873     PyObject *tmp_type, *tmp_value, *tmp_tb;
30874     local_type = tstate->curexc_type;
30875     local_value = tstate->curexc_value;
30876     local_tb = tstate->curexc_traceback;
30877     tstate->curexc_type = 0;
30878     tstate->curexc_value = 0;
30879     tstate->curexc_traceback = 0;
30880 #else
30881     PyErr_Fetch(&local_type, &local_value, &local_tb);
30882 #endif
30883     PyErr_NormalizeException(&local_type, &local_value, &local_tb);
30884 #if CYTHON_FAST_THREAD_STATE
30885     if (unlikely(tstate->curexc_type))
30886 #else
30887     if (unlikely(PyErr_Occurred()))
30888 #endif
30889         goto bad;
30890     #if PY_MAJOR_VERSION >= 3
30891     if (local_tb) {
30892         if (unlikely(PyException_SetTraceback(local_value, local_tb) < 0))
30893             goto bad;
30894     }
30895     #endif
30896     Py_XINCREF(local_tb);
30897     Py_XINCREF(local_type);
30898     Py_XINCREF(local_value);
30899     *type = local_type;
30900     *value = local_value;
30901     *tb = local_tb;
30902 #if CYTHON_FAST_THREAD_STATE
30903     #if CYTHON_USE_EXC_INFO_STACK
30904     {
30905         _PyErr_StackItem *exc_info = tstate->exc_info;
30906         tmp_type = exc_info->exc_type;
30907         tmp_value = exc_info->exc_value;
30908         tmp_tb = exc_info->exc_traceback;
30909         exc_info->exc_type = local_type;
30910         exc_info->exc_value = local_value;
30911         exc_info->exc_traceback = local_tb;
30912     }
30913     #else
30914     tmp_type = tstate->exc_type;
30915     tmp_value = tstate->exc_value;
30916     tmp_tb = tstate->exc_traceback;
30917     tstate->exc_type = local_type;
30918     tstate->exc_value = local_value;
30919     tstate->exc_traceback = local_tb;
30920     #endif
30921     Py_XDECREF(tmp_type);
30922     Py_XDECREF(tmp_value);
30923     Py_XDECREF(tmp_tb);
30924 #else
30925     PyErr_SetExcInfo(local_type, local_value, local_tb);
30926 #endif
30927     return 0;
30928 bad:
30929     *type = 0;
30930     *value = 0;
30931     *tb = 0;
30932     Py_XDECREF(local_type);
30933     Py_XDECREF(local_value);
30934     Py_XDECREF(local_tb);
30935     return -1;
30936 }
30937 
30938 /* ArgTypeTest */
__Pyx__ArgTypeTest(PyObject * obj,PyTypeObject * type,const char * name,int exact)30939   static int __Pyx__ArgTypeTest(PyObject *obj, PyTypeObject *type, const char *name, int exact)
30940 {
30941     if (unlikely(!type)) {
30942         PyErr_SetString(PyExc_SystemError, "Missing type object");
30943         return 0;
30944     }
30945     else if (exact) {
30946         #if PY_MAJOR_VERSION == 2
30947         if ((type == &PyBaseString_Type) && likely(__Pyx_PyBaseString_CheckExact(obj))) return 1;
30948         #endif
30949     }
30950     else {
30951         if (likely(__Pyx_TypeCheck(obj, type))) return 1;
30952     }
30953     PyErr_Format(PyExc_TypeError,
30954         "Argument '%.200s' has incorrect type (expected %.200s, got %.200s)",
30955         name, type->tp_name, Py_TYPE(obj)->tp_name);
30956     return 0;
30957 }
30958 
30959 /* BytesEquals */
__Pyx_PyBytes_Equals(PyObject * s1,PyObject * s2,int equals)30960   static CYTHON_INLINE int __Pyx_PyBytes_Equals(PyObject* s1, PyObject* s2, int equals) {
30961 #if CYTHON_COMPILING_IN_PYPY
30962     return PyObject_RichCompareBool(s1, s2, equals);
30963 #else
30964     if (s1 == s2) {
30965         return (equals == Py_EQ);
30966     } else if (PyBytes_CheckExact(s1) & PyBytes_CheckExact(s2)) {
30967         const char *ps1, *ps2;
30968         Py_ssize_t length = PyBytes_GET_SIZE(s1);
30969         if (length != PyBytes_GET_SIZE(s2))
30970             return (equals == Py_NE);
30971         ps1 = PyBytes_AS_STRING(s1);
30972         ps2 = PyBytes_AS_STRING(s2);
30973         if (ps1[0] != ps2[0]) {
30974             return (equals == Py_NE);
30975         } else if (length == 1) {
30976             return (equals == Py_EQ);
30977         } else {
30978             int result;
30979 #if CYTHON_USE_UNICODE_INTERNALS
30980             Py_hash_t hash1, hash2;
30981             hash1 = ((PyBytesObject*)s1)->ob_shash;
30982             hash2 = ((PyBytesObject*)s2)->ob_shash;
30983             if (hash1 != hash2 && hash1 != -1 && hash2 != -1) {
30984                 return (equals == Py_NE);
30985             }
30986 #endif
30987             result = memcmp(ps1, ps2, (size_t)length);
30988             return (equals == Py_EQ) ? (result == 0) : (result != 0);
30989         }
30990     } else if ((s1 == Py_None) & PyBytes_CheckExact(s2)) {
30991         return (equals == Py_NE);
30992     } else if ((s2 == Py_None) & PyBytes_CheckExact(s1)) {
30993         return (equals == Py_NE);
30994     } else {
30995         int result;
30996         PyObject* py_result = PyObject_RichCompare(s1, s2, equals);
30997         if (!py_result)
30998             return -1;
30999         result = __Pyx_PyObject_IsTrue(py_result);
31000         Py_DECREF(py_result);
31001         return result;
31002     }
31003 #endif
31004 }
31005 
31006 /* UnicodeEquals */
__Pyx_PyUnicode_Equals(PyObject * s1,PyObject * s2,int equals)31007   static CYTHON_INLINE int __Pyx_PyUnicode_Equals(PyObject* s1, PyObject* s2, int equals) {
31008 #if CYTHON_COMPILING_IN_PYPY
31009     return PyObject_RichCompareBool(s1, s2, equals);
31010 #else
31011 #if PY_MAJOR_VERSION < 3
31012     PyObject* owned_ref = NULL;
31013 #endif
31014     int s1_is_unicode, s2_is_unicode;
31015     if (s1 == s2) {
31016         goto return_eq;
31017     }
31018     s1_is_unicode = PyUnicode_CheckExact(s1);
31019     s2_is_unicode = PyUnicode_CheckExact(s2);
31020 #if PY_MAJOR_VERSION < 3
31021     if ((s1_is_unicode & (!s2_is_unicode)) && PyString_CheckExact(s2)) {
31022         owned_ref = PyUnicode_FromObject(s2);
31023         if (unlikely(!owned_ref))
31024             return -1;
31025         s2 = owned_ref;
31026         s2_is_unicode = 1;
31027     } else if ((s2_is_unicode & (!s1_is_unicode)) && PyString_CheckExact(s1)) {
31028         owned_ref = PyUnicode_FromObject(s1);
31029         if (unlikely(!owned_ref))
31030             return -1;
31031         s1 = owned_ref;
31032         s1_is_unicode = 1;
31033     } else if (((!s2_is_unicode) & (!s1_is_unicode))) {
31034         return __Pyx_PyBytes_Equals(s1, s2, equals);
31035     }
31036 #endif
31037     if (s1_is_unicode & s2_is_unicode) {
31038         Py_ssize_t length;
31039         int kind;
31040         void *data1, *data2;
31041         if (unlikely(__Pyx_PyUnicode_READY(s1) < 0) || unlikely(__Pyx_PyUnicode_READY(s2) < 0))
31042             return -1;
31043         length = __Pyx_PyUnicode_GET_LENGTH(s1);
31044         if (length != __Pyx_PyUnicode_GET_LENGTH(s2)) {
31045             goto return_ne;
31046         }
31047 #if CYTHON_USE_UNICODE_INTERNALS
31048         {
31049             Py_hash_t hash1, hash2;
31050         #if CYTHON_PEP393_ENABLED
31051             hash1 = ((PyASCIIObject*)s1)->hash;
31052             hash2 = ((PyASCIIObject*)s2)->hash;
31053         #else
31054             hash1 = ((PyUnicodeObject*)s1)->hash;
31055             hash2 = ((PyUnicodeObject*)s2)->hash;
31056         #endif
31057             if (hash1 != hash2 && hash1 != -1 && hash2 != -1) {
31058                 goto return_ne;
31059             }
31060         }
31061 #endif
31062         kind = __Pyx_PyUnicode_KIND(s1);
31063         if (kind != __Pyx_PyUnicode_KIND(s2)) {
31064             goto return_ne;
31065         }
31066         data1 = __Pyx_PyUnicode_DATA(s1);
31067         data2 = __Pyx_PyUnicode_DATA(s2);
31068         if (__Pyx_PyUnicode_READ(kind, data1, 0) != __Pyx_PyUnicode_READ(kind, data2, 0)) {
31069             goto return_ne;
31070         } else if (length == 1) {
31071             goto return_eq;
31072         } else {
31073             int result = memcmp(data1, data2, (size_t)(length * kind));
31074             #if PY_MAJOR_VERSION < 3
31075             Py_XDECREF(owned_ref);
31076             #endif
31077             return (equals == Py_EQ) ? (result == 0) : (result != 0);
31078         }
31079     } else if ((s1 == Py_None) & s2_is_unicode) {
31080         goto return_ne;
31081     } else if ((s2 == Py_None) & s1_is_unicode) {
31082         goto return_ne;
31083     } else {
31084         int result;
31085         PyObject* py_result = PyObject_RichCompare(s1, s2, equals);
31086         #if PY_MAJOR_VERSION < 3
31087         Py_XDECREF(owned_ref);
31088         #endif
31089         if (!py_result)
31090             return -1;
31091         result = __Pyx_PyObject_IsTrue(py_result);
31092         Py_DECREF(py_result);
31093         return result;
31094     }
31095 return_eq:
31096     #if PY_MAJOR_VERSION < 3
31097     Py_XDECREF(owned_ref);
31098     #endif
31099     return (equals == Py_EQ);
31100 return_ne:
31101     #if PY_MAJOR_VERSION < 3
31102     Py_XDECREF(owned_ref);
31103     #endif
31104     return (equals == Py_NE);
31105 #endif
31106 }
31107 
31108 /* None */
__Pyx_div_Py_ssize_t(Py_ssize_t a,Py_ssize_t b)31109   static CYTHON_INLINE Py_ssize_t __Pyx_div_Py_ssize_t(Py_ssize_t a, Py_ssize_t b) {
31110     Py_ssize_t q = a / b;
31111     Py_ssize_t r = a - q*b;
31112     q -= ((r != 0) & ((r ^ b) < 0));
31113     return q;
31114 }
31115 
31116 /* GetAttr */
__Pyx_GetAttr(PyObject * o,PyObject * n)31117   static CYTHON_INLINE PyObject *__Pyx_GetAttr(PyObject *o, PyObject *n) {
31118 #if CYTHON_USE_TYPE_SLOTS
31119 #if PY_MAJOR_VERSION >= 3
31120     if (likely(PyUnicode_Check(n)))
31121 #else
31122     if (likely(PyString_Check(n)))
31123 #endif
31124         return __Pyx_PyObject_GetAttrStr(o, n);
31125 #endif
31126     return PyObject_GetAttr(o, n);
31127 }
31128 
31129 /* decode_c_string */
__Pyx_decode_c_string(const char * cstring,Py_ssize_t start,Py_ssize_t stop,const char * encoding,const char * errors,PyObject * (* decode_func)(const char * s,Py_ssize_t size,const char * errors))31130   static CYTHON_INLINE PyObject* __Pyx_decode_c_string(
31131          const char* cstring, Py_ssize_t start, Py_ssize_t stop,
31132          const char* encoding, const char* errors,
31133          PyObject* (*decode_func)(const char *s, Py_ssize_t size, const char *errors)) {
31134     Py_ssize_t length;
31135     if (unlikely((start < 0) | (stop < 0))) {
31136         size_t slen = strlen(cstring);
31137         if (unlikely(slen > (size_t) PY_SSIZE_T_MAX)) {
31138             PyErr_SetString(PyExc_OverflowError,
31139                             "c-string too long to convert to Python");
31140             return NULL;
31141         }
31142         length = (Py_ssize_t) slen;
31143         if (start < 0) {
31144             start += length;
31145             if (start < 0)
31146                 start = 0;
31147         }
31148         if (stop < 0)
31149             stop += length;
31150     }
31151     if (unlikely(stop <= start))
31152         return __Pyx_NewRef(__pyx_empty_unicode);
31153     length = stop - start;
31154     cstring += start;
31155     if (decode_func) {
31156         return decode_func(cstring, length, errors);
31157     } else {
31158         return PyUnicode_Decode(cstring, length, encoding, errors);
31159     }
31160 }
31161 
31162 /* GetAttr3 */
__Pyx_GetAttr3Default(PyObject * d)31163   static PyObject *__Pyx_GetAttr3Default(PyObject *d) {
31164     __Pyx_PyThreadState_declare
31165     __Pyx_PyThreadState_assign
31166     if (unlikely(!__Pyx_PyErr_ExceptionMatches(PyExc_AttributeError)))
31167         return NULL;
31168     __Pyx_PyErr_Clear();
31169     Py_INCREF(d);
31170     return d;
31171 }
__Pyx_GetAttr3(PyObject * o,PyObject * n,PyObject * d)31172 static CYTHON_INLINE PyObject *__Pyx_GetAttr3(PyObject *o, PyObject *n, PyObject *d) {
31173     PyObject *r = __Pyx_GetAttr(o, n);
31174     return (likely(r)) ? r : __Pyx_GetAttr3Default(d);
31175 }
31176 
31177 /* RaiseTooManyValuesToUnpack */
__Pyx_RaiseTooManyValuesError(Py_ssize_t expected)31178   static CYTHON_INLINE void __Pyx_RaiseTooManyValuesError(Py_ssize_t expected) {
31179     PyErr_Format(PyExc_ValueError,
31180                  "too many values to unpack (expected %" CYTHON_FORMAT_SSIZE_T "d)", expected);
31181 }
31182 
31183 /* RaiseNeedMoreValuesToUnpack */
__Pyx_RaiseNeedMoreValuesError(Py_ssize_t index)31184   static CYTHON_INLINE void __Pyx_RaiseNeedMoreValuesError(Py_ssize_t index) {
31185     PyErr_Format(PyExc_ValueError,
31186                  "need more than %" CYTHON_FORMAT_SSIZE_T "d value%.1s to unpack",
31187                  index, (index == 1) ? "" : "s");
31188 }
31189 
31190 /* RaiseNoneIterError */
__Pyx_RaiseNoneNotIterableError(void)31191   static CYTHON_INLINE void __Pyx_RaiseNoneNotIterableError(void) {
31192     PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable");
31193 }
31194 
31195 /* SwapException */
31196   #if CYTHON_FAST_THREAD_STATE
__Pyx__ExceptionSwap(PyThreadState * tstate,PyObject ** type,PyObject ** value,PyObject ** tb)31197 static CYTHON_INLINE void __Pyx__ExceptionSwap(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) {
31198     PyObject *tmp_type, *tmp_value, *tmp_tb;
31199     #if CYTHON_USE_EXC_INFO_STACK
31200     _PyErr_StackItem *exc_info = tstate->exc_info;
31201     tmp_type = exc_info->exc_type;
31202     tmp_value = exc_info->exc_value;
31203     tmp_tb = exc_info->exc_traceback;
31204     exc_info->exc_type = *type;
31205     exc_info->exc_value = *value;
31206     exc_info->exc_traceback = *tb;
31207     #else
31208     tmp_type = tstate->exc_type;
31209     tmp_value = tstate->exc_value;
31210     tmp_tb = tstate->exc_traceback;
31211     tstate->exc_type = *type;
31212     tstate->exc_value = *value;
31213     tstate->exc_traceback = *tb;
31214     #endif
31215     *type = tmp_type;
31216     *value = tmp_value;
31217     *tb = tmp_tb;
31218 }
31219 #else
__Pyx_ExceptionSwap(PyObject ** type,PyObject ** value,PyObject ** tb)31220 static CYTHON_INLINE void __Pyx_ExceptionSwap(PyObject **type, PyObject **value, PyObject **tb) {
31221     PyObject *tmp_type, *tmp_value, *tmp_tb;
31222     PyErr_GetExcInfo(&tmp_type, &tmp_value, &tmp_tb);
31223     PyErr_SetExcInfo(*type, *value, *tb);
31224     *type = tmp_type;
31225     *value = tmp_value;
31226     *tb = tmp_tb;
31227 }
31228 #endif
31229 
31230 /* Import */
__Pyx_Import(PyObject * name,PyObject * from_list,int level)31231   static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, int level) {
31232     PyObject *empty_list = 0;
31233     PyObject *module = 0;
31234     PyObject *global_dict = 0;
31235     PyObject *empty_dict = 0;
31236     PyObject *list;
31237     #if PY_MAJOR_VERSION < 3
31238     PyObject *py_import;
31239     py_import = __Pyx_PyObject_GetAttrStr(__pyx_b, __pyx_n_s_import);
31240     if (!py_import)
31241         goto bad;
31242     #endif
31243     if (from_list)
31244         list = from_list;
31245     else {
31246         empty_list = PyList_New(0);
31247         if (!empty_list)
31248             goto bad;
31249         list = empty_list;
31250     }
31251     global_dict = PyModule_GetDict(__pyx_m);
31252     if (!global_dict)
31253         goto bad;
31254     empty_dict = PyDict_New();
31255     if (!empty_dict)
31256         goto bad;
31257     {
31258         #if PY_MAJOR_VERSION >= 3
31259         if (level == -1) {
31260             if ((1) && (strchr(__Pyx_MODULE_NAME, '.'))) {
31261                 module = PyImport_ImportModuleLevelObject(
31262                     name, global_dict, empty_dict, list, 1);
31263                 if (!module) {
31264                     if (!PyErr_ExceptionMatches(PyExc_ImportError))
31265                         goto bad;
31266                     PyErr_Clear();
31267                 }
31268             }
31269             level = 0;
31270         }
31271         #endif
31272         if (!module) {
31273             #if PY_MAJOR_VERSION < 3
31274             PyObject *py_level = PyInt_FromLong(level);
31275             if (!py_level)
31276                 goto bad;
31277             module = PyObject_CallFunctionObjArgs(py_import,
31278                 name, global_dict, empty_dict, list, py_level, (PyObject *)NULL);
31279             Py_DECREF(py_level);
31280             #else
31281             module = PyImport_ImportModuleLevelObject(
31282                 name, global_dict, empty_dict, list, level);
31283             #endif
31284         }
31285     }
31286 bad:
31287     #if PY_MAJOR_VERSION < 3
31288     Py_XDECREF(py_import);
31289     #endif
31290     Py_XDECREF(empty_list);
31291     Py_XDECREF(empty_dict);
31292     return module;
31293 }
31294 
31295 /* FastTypeChecks */
31296   #if CYTHON_COMPILING_IN_CPYTHON
__Pyx_InBases(PyTypeObject * a,PyTypeObject * b)31297 static int __Pyx_InBases(PyTypeObject *a, PyTypeObject *b) {
31298     while (a) {
31299         a = a->tp_base;
31300         if (a == b)
31301             return 1;
31302     }
31303     return b == &PyBaseObject_Type;
31304 }
__Pyx_IsSubtype(PyTypeObject * a,PyTypeObject * b)31305 static CYTHON_INLINE int __Pyx_IsSubtype(PyTypeObject *a, PyTypeObject *b) {
31306     PyObject *mro;
31307     if (a == b) return 1;
31308     mro = a->tp_mro;
31309     if (likely(mro)) {
31310         Py_ssize_t i, n;
31311         n = PyTuple_GET_SIZE(mro);
31312         for (i = 0; i < n; i++) {
31313             if (PyTuple_GET_ITEM(mro, i) == (PyObject *)b)
31314                 return 1;
31315         }
31316         return 0;
31317     }
31318     return __Pyx_InBases(a, b);
31319 }
31320 #if PY_MAJOR_VERSION == 2
__Pyx_inner_PyErr_GivenExceptionMatches2(PyObject * err,PyObject * exc_type1,PyObject * exc_type2)31321 static int __Pyx_inner_PyErr_GivenExceptionMatches2(PyObject *err, PyObject* exc_type1, PyObject* exc_type2) {
31322     PyObject *exception, *value, *tb;
31323     int res;
31324     __Pyx_PyThreadState_declare
31325     __Pyx_PyThreadState_assign
31326     __Pyx_ErrFetch(&exception, &value, &tb);
31327     res = exc_type1 ? PyObject_IsSubclass(err, exc_type1) : 0;
31328     if (unlikely(res == -1)) {
31329         PyErr_WriteUnraisable(err);
31330         res = 0;
31331     }
31332     if (!res) {
31333         res = PyObject_IsSubclass(err, exc_type2);
31334         if (unlikely(res == -1)) {
31335             PyErr_WriteUnraisable(err);
31336             res = 0;
31337         }
31338     }
31339     __Pyx_ErrRestore(exception, value, tb);
31340     return res;
31341 }
31342 #else
__Pyx_inner_PyErr_GivenExceptionMatches2(PyObject * err,PyObject * exc_type1,PyObject * exc_type2)31343 static CYTHON_INLINE int __Pyx_inner_PyErr_GivenExceptionMatches2(PyObject *err, PyObject* exc_type1, PyObject *exc_type2) {
31344     int res = exc_type1 ? __Pyx_IsSubtype((PyTypeObject*)err, (PyTypeObject*)exc_type1) : 0;
31345     if (!res) {
31346         res = __Pyx_IsSubtype((PyTypeObject*)err, (PyTypeObject*)exc_type2);
31347     }
31348     return res;
31349 }
31350 #endif
__Pyx_PyErr_GivenExceptionMatchesTuple(PyObject * exc_type,PyObject * tuple)31351 static int __Pyx_PyErr_GivenExceptionMatchesTuple(PyObject *exc_type, PyObject *tuple) {
31352     Py_ssize_t i, n;
31353     assert(PyExceptionClass_Check(exc_type));
31354     n = PyTuple_GET_SIZE(tuple);
31355 #if PY_MAJOR_VERSION >= 3
31356     for (i=0; i<n; i++) {
31357         if (exc_type == PyTuple_GET_ITEM(tuple, i)) return 1;
31358     }
31359 #endif
31360     for (i=0; i<n; i++) {
31361         PyObject *t = PyTuple_GET_ITEM(tuple, i);
31362         #if PY_MAJOR_VERSION < 3
31363         if (likely(exc_type == t)) return 1;
31364         #endif
31365         if (likely(PyExceptionClass_Check(t))) {
31366             if (__Pyx_inner_PyErr_GivenExceptionMatches2(exc_type, NULL, t)) return 1;
31367         } else {
31368         }
31369     }
31370     return 0;
31371 }
__Pyx_PyErr_GivenExceptionMatches(PyObject * err,PyObject * exc_type)31372 static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches(PyObject *err, PyObject* exc_type) {
31373     if (likely(err == exc_type)) return 1;
31374     if (likely(PyExceptionClass_Check(err))) {
31375         if (likely(PyExceptionClass_Check(exc_type))) {
31376             return __Pyx_inner_PyErr_GivenExceptionMatches2(err, NULL, exc_type);
31377         } else if (likely(PyTuple_Check(exc_type))) {
31378             return __Pyx_PyErr_GivenExceptionMatchesTuple(err, exc_type);
31379         } else {
31380         }
31381     }
31382     return PyErr_GivenExceptionMatches(err, exc_type);
31383 }
__Pyx_PyErr_GivenExceptionMatches2(PyObject * err,PyObject * exc_type1,PyObject * exc_type2)31384 static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches2(PyObject *err, PyObject *exc_type1, PyObject *exc_type2) {
31385     assert(PyExceptionClass_Check(exc_type1));
31386     assert(PyExceptionClass_Check(exc_type2));
31387     if (likely(err == exc_type1 || err == exc_type2)) return 1;
31388     if (likely(PyExceptionClass_Check(err))) {
31389         return __Pyx_inner_PyErr_GivenExceptionMatches2(err, exc_type1, exc_type2);
31390     }
31391     return (PyErr_GivenExceptionMatches(err, exc_type1) || PyErr_GivenExceptionMatches(err, exc_type2));
31392 }
31393 #endif
31394 
31395 /* PyIntBinop */
31396   #if !CYTHON_COMPILING_IN_PYPY
__Pyx_PyInt_AddObjC(PyObject * op1,PyObject * op2,CYTHON_UNUSED long intval,int inplace,int zerodivision_check)31397 static PyObject* __Pyx_PyInt_AddObjC(PyObject *op1, PyObject *op2, CYTHON_UNUSED long intval, int inplace, int zerodivision_check) {
31398     (void)inplace;
31399     (void)zerodivision_check;
31400     #if PY_MAJOR_VERSION < 3
31401     if (likely(PyInt_CheckExact(op1))) {
31402         const long b = intval;
31403         long x;
31404         long a = PyInt_AS_LONG(op1);
31405             x = (long)((unsigned long)a + b);
31406             if (likely((x^a) >= 0 || (x^b) >= 0))
31407                 return PyInt_FromLong(x);
31408             return PyLong_Type.tp_as_number->nb_add(op1, op2);
31409     }
31410     #endif
31411     #if CYTHON_USE_PYLONG_INTERNALS
31412     if (likely(PyLong_CheckExact(op1))) {
31413         const long b = intval;
31414         long a, x;
31415 #ifdef HAVE_LONG_LONG
31416         const PY_LONG_LONG llb = intval;
31417         PY_LONG_LONG lla, llx;
31418 #endif
31419         const digit* digits = ((PyLongObject*)op1)->ob_digit;
31420         const Py_ssize_t size = Py_SIZE(op1);
31421         if (likely(__Pyx_sst_abs(size) <= 1)) {
31422             a = likely(size) ? digits[0] : 0;
31423             if (size == -1) a = -a;
31424         } else {
31425             switch (size) {
31426                 case -2:
31427                     if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
31428                         a = -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
31429                         break;
31430 #ifdef HAVE_LONG_LONG
31431                     } else if (8 * sizeof(PY_LONG_LONG) - 1 > 2 * PyLong_SHIFT) {
31432                         lla = -(PY_LONG_LONG) (((((unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
31433                         goto long_long;
31434 #endif
31435                     }
31436                     CYTHON_FALLTHROUGH;
31437                 case 2:
31438                     if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
31439                         a = (long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
31440                         break;
31441 #ifdef HAVE_LONG_LONG
31442                     } else if (8 * sizeof(PY_LONG_LONG) - 1 > 2 * PyLong_SHIFT) {
31443                         lla = (PY_LONG_LONG) (((((unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
31444                         goto long_long;
31445 #endif
31446                     }
31447                     CYTHON_FALLTHROUGH;
31448                 case -3:
31449                     if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
31450                         a = -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
31451                         break;
31452 #ifdef HAVE_LONG_LONG
31453                     } else if (8 * sizeof(PY_LONG_LONG) - 1 > 3 * PyLong_SHIFT) {
31454                         lla = -(PY_LONG_LONG) (((((((unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
31455                         goto long_long;
31456 #endif
31457                     }
31458                     CYTHON_FALLTHROUGH;
31459                 case 3:
31460                     if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
31461                         a = (long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
31462                         break;
31463 #ifdef HAVE_LONG_LONG
31464                     } else if (8 * sizeof(PY_LONG_LONG) - 1 > 3 * PyLong_SHIFT) {
31465                         lla = (PY_LONG_LONG) (((((((unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
31466                         goto long_long;
31467 #endif
31468                     }
31469                     CYTHON_FALLTHROUGH;
31470                 case -4:
31471                     if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) {
31472                         a = -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
31473                         break;
31474 #ifdef HAVE_LONG_LONG
31475                     } else if (8 * sizeof(PY_LONG_LONG) - 1 > 4 * PyLong_SHIFT) {
31476                         lla = -(PY_LONG_LONG) (((((((((unsigned PY_LONG_LONG)digits[3]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
31477                         goto long_long;
31478 #endif
31479                     }
31480                     CYTHON_FALLTHROUGH;
31481                 case 4:
31482                     if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) {
31483                         a = (long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
31484                         break;
31485 #ifdef HAVE_LONG_LONG
31486                     } else if (8 * sizeof(PY_LONG_LONG) - 1 > 4 * PyLong_SHIFT) {
31487                         lla = (PY_LONG_LONG) (((((((((unsigned PY_LONG_LONG)digits[3]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
31488                         goto long_long;
31489 #endif
31490                     }
31491                     CYTHON_FALLTHROUGH;
31492                 default: return PyLong_Type.tp_as_number->nb_add(op1, op2);
31493             }
31494         }
31495                 x = a + b;
31496             return PyLong_FromLong(x);
31497 #ifdef HAVE_LONG_LONG
31498         long_long:
31499                 llx = lla + llb;
31500             return PyLong_FromLongLong(llx);
31501 #endif
31502 
31503 
31504     }
31505     #endif
31506     if (PyFloat_CheckExact(op1)) {
31507         const long b = intval;
31508         double a = PyFloat_AS_DOUBLE(op1);
31509             double result;
31510             PyFPE_START_PROTECT("add", return NULL)
31511             result = ((double)a) + (double)b;
31512             PyFPE_END_PROTECT(result)
31513             return PyFloat_FromDouble(result);
31514     }
31515     return (inplace ? PyNumber_InPlaceAdd : PyNumber_Add)(op1, op2);
31516 }
31517 #endif
31518 
31519 /* None */
__Pyx_div_long(long a,long b)31520   static CYTHON_INLINE long __Pyx_div_long(long a, long b) {
31521     long q = a / b;
31522     long r = a - q*b;
31523     q -= ((r != 0) & ((r ^ b) < 0));
31524     return q;
31525 }
31526 
31527 /* ImportFrom */
__Pyx_ImportFrom(PyObject * module,PyObject * name)31528   static PyObject* __Pyx_ImportFrom(PyObject* module, PyObject* name) {
31529     PyObject* value = __Pyx_PyObject_GetAttrStr(module, name);
31530     if (unlikely(!value) && PyErr_ExceptionMatches(PyExc_AttributeError)) {
31531         PyErr_Format(PyExc_ImportError,
31532         #if PY_MAJOR_VERSION < 3
31533             "cannot import name %.230s", PyString_AS_STRING(name));
31534         #else
31535             "cannot import name %S", name);
31536         #endif
31537     }
31538     return value;
31539 }
31540 
31541 /* HasAttr */
__Pyx_HasAttr(PyObject * o,PyObject * n)31542   static CYTHON_INLINE int __Pyx_HasAttr(PyObject *o, PyObject *n) {
31543     PyObject *r;
31544     if (unlikely(!__Pyx_PyBaseString_Check(n))) {
31545         PyErr_SetString(PyExc_TypeError,
31546                         "hasattr(): attribute name must be string");
31547         return -1;
31548     }
31549     r = __Pyx_GetAttr(o, n);
31550     if (unlikely(!r)) {
31551         PyErr_Clear();
31552         return 0;
31553     } else {
31554         Py_DECREF(r);
31555         return 1;
31556     }
31557 }
31558 
31559 /* StringJoin */
31560   #if !CYTHON_COMPILING_IN_CPYTHON
__Pyx_PyBytes_Join(PyObject * sep,PyObject * values)31561 static CYTHON_INLINE PyObject* __Pyx_PyBytes_Join(PyObject* sep, PyObject* values) {
31562     return PyObject_CallMethodObjArgs(sep, __pyx_n_s_join, values, NULL);
31563 }
31564 #endif
31565 
31566 /* PyObject_GenericGetAttrNoDict */
31567   #if CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP && PY_VERSION_HEX < 0x03070000
__Pyx_RaiseGenericGetAttributeError(PyTypeObject * tp,PyObject * attr_name)31568 static PyObject *__Pyx_RaiseGenericGetAttributeError(PyTypeObject *tp, PyObject *attr_name) {
31569     PyErr_Format(PyExc_AttributeError,
31570 #if PY_MAJOR_VERSION >= 3
31571                  "'%.50s' object has no attribute '%U'",
31572                  tp->tp_name, attr_name);
31573 #else
31574                  "'%.50s' object has no attribute '%.400s'",
31575                  tp->tp_name, PyString_AS_STRING(attr_name));
31576 #endif
31577     return NULL;
31578 }
__Pyx_PyObject_GenericGetAttrNoDict(PyObject * obj,PyObject * attr_name)31579 static CYTHON_INLINE PyObject* __Pyx_PyObject_GenericGetAttrNoDict(PyObject* obj, PyObject* attr_name) {
31580     PyObject *descr;
31581     PyTypeObject *tp = Py_TYPE(obj);
31582     if (unlikely(!PyString_Check(attr_name))) {
31583         return PyObject_GenericGetAttr(obj, attr_name);
31584     }
31585     assert(!tp->tp_dictoffset);
31586     descr = _PyType_Lookup(tp, attr_name);
31587     if (unlikely(!descr)) {
31588         return __Pyx_RaiseGenericGetAttributeError(tp, attr_name);
31589     }
31590     Py_INCREF(descr);
31591     #if PY_MAJOR_VERSION < 3
31592     if (likely(PyType_HasFeature(Py_TYPE(descr), Py_TPFLAGS_HAVE_CLASS)))
31593     #endif
31594     {
31595         descrgetfunc f = Py_TYPE(descr)->tp_descr_get;
31596         if (unlikely(f)) {
31597             PyObject *res = f(descr, obj, (PyObject *)tp);
31598             Py_DECREF(descr);
31599             return res;
31600         }
31601     }
31602     return descr;
31603 }
31604 #endif
31605 
31606 /* PyObject_GenericGetAttr */
31607   #if CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP && PY_VERSION_HEX < 0x03070000
__Pyx_PyObject_GenericGetAttr(PyObject * obj,PyObject * attr_name)31608 static PyObject* __Pyx_PyObject_GenericGetAttr(PyObject* obj, PyObject* attr_name) {
31609     if (unlikely(Py_TYPE(obj)->tp_dictoffset)) {
31610         return PyObject_GenericGetAttr(obj, attr_name);
31611     }
31612     return __Pyx_PyObject_GenericGetAttrNoDict(obj, attr_name);
31613 }
31614 #endif
31615 
31616 /* SetVTable */
__Pyx_SetVtable(PyObject * dict,void * vtable)31617   static int __Pyx_SetVtable(PyObject *dict, void *vtable) {
31618 #if PY_VERSION_HEX >= 0x02070000
31619     PyObject *ob = PyCapsule_New(vtable, 0, 0);
31620 #else
31621     PyObject *ob = PyCObject_FromVoidPtr(vtable, 0);
31622 #endif
31623     if (!ob)
31624         goto bad;
31625     if (PyDict_SetItem(dict, __pyx_n_s_pyx_vtable, ob) < 0)
31626         goto bad;
31627     Py_DECREF(ob);
31628     return 0;
31629 bad:
31630     Py_XDECREF(ob);
31631     return -1;
31632 }
31633 
31634 /* PyObjectGetAttrStrNoError */
__Pyx_PyObject_GetAttrStr_ClearAttributeError(void)31635   static void __Pyx_PyObject_GetAttrStr_ClearAttributeError(void) {
31636     __Pyx_PyThreadState_declare
31637     __Pyx_PyThreadState_assign
31638     if (likely(__Pyx_PyErr_ExceptionMatches(PyExc_AttributeError)))
31639         __Pyx_PyErr_Clear();
31640 }
__Pyx_PyObject_GetAttrStrNoError(PyObject * obj,PyObject * attr_name)31641 static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStrNoError(PyObject* obj, PyObject* attr_name) {
31642     PyObject *result;
31643 #if CYTHON_COMPILING_IN_CPYTHON && CYTHON_USE_TYPE_SLOTS && PY_VERSION_HEX >= 0x030700B1
31644     PyTypeObject* tp = Py_TYPE(obj);
31645     if (likely(tp->tp_getattro == PyObject_GenericGetAttr)) {
31646         return _PyObject_GenericGetAttrWithDict(obj, attr_name, NULL, 1);
31647     }
31648 #endif
31649     result = __Pyx_PyObject_GetAttrStr(obj, attr_name);
31650     if (unlikely(!result)) {
31651         __Pyx_PyObject_GetAttrStr_ClearAttributeError();
31652     }
31653     return result;
31654 }
31655 
31656 /* SetupReduce */
__Pyx_setup_reduce_is_named(PyObject * meth,PyObject * name)31657   static int __Pyx_setup_reduce_is_named(PyObject* meth, PyObject* name) {
31658   int ret;
31659   PyObject *name_attr;
31660   name_attr = __Pyx_PyObject_GetAttrStr(meth, __pyx_n_s_name_2);
31661   if (likely(name_attr)) {
31662       ret = PyObject_RichCompareBool(name_attr, name, Py_EQ);
31663   } else {
31664       ret = -1;
31665   }
31666   if (unlikely(ret < 0)) {
31667       PyErr_Clear();
31668       ret = 0;
31669   }
31670   Py_XDECREF(name_attr);
31671   return ret;
31672 }
__Pyx_setup_reduce(PyObject * type_obj)31673 static int __Pyx_setup_reduce(PyObject* type_obj) {
31674     int ret = 0;
31675     PyObject *object_reduce = NULL;
31676     PyObject *object_reduce_ex = NULL;
31677     PyObject *reduce = NULL;
31678     PyObject *reduce_ex = NULL;
31679     PyObject *reduce_cython = NULL;
31680     PyObject *setstate = NULL;
31681     PyObject *setstate_cython = NULL;
31682 #if CYTHON_USE_PYTYPE_LOOKUP
31683     if (_PyType_Lookup((PyTypeObject*)type_obj, __pyx_n_s_getstate)) goto __PYX_GOOD;
31684 #else
31685     if (PyObject_HasAttr(type_obj, __pyx_n_s_getstate)) goto __PYX_GOOD;
31686 #endif
31687 #if CYTHON_USE_PYTYPE_LOOKUP
31688     object_reduce_ex = _PyType_Lookup(&PyBaseObject_Type, __pyx_n_s_reduce_ex); if (!object_reduce_ex) goto __PYX_BAD;
31689 #else
31690     object_reduce_ex = __Pyx_PyObject_GetAttrStr((PyObject*)&PyBaseObject_Type, __pyx_n_s_reduce_ex); if (!object_reduce_ex) goto __PYX_BAD;
31691 #endif
31692     reduce_ex = __Pyx_PyObject_GetAttrStr(type_obj, __pyx_n_s_reduce_ex); if (unlikely(!reduce_ex)) goto __PYX_BAD;
31693     if (reduce_ex == object_reduce_ex) {
31694 #if CYTHON_USE_PYTYPE_LOOKUP
31695         object_reduce = _PyType_Lookup(&PyBaseObject_Type, __pyx_n_s_reduce); if (!object_reduce) goto __PYX_BAD;
31696 #else
31697         object_reduce = __Pyx_PyObject_GetAttrStr((PyObject*)&PyBaseObject_Type, __pyx_n_s_reduce); if (!object_reduce) goto __PYX_BAD;
31698 #endif
31699         reduce = __Pyx_PyObject_GetAttrStr(type_obj, __pyx_n_s_reduce); if (unlikely(!reduce)) goto __PYX_BAD;
31700         if (reduce == object_reduce || __Pyx_setup_reduce_is_named(reduce, __pyx_n_s_reduce_cython)) {
31701             reduce_cython = __Pyx_PyObject_GetAttrStrNoError(type_obj, __pyx_n_s_reduce_cython);
31702             if (likely(reduce_cython)) {
31703                 ret = PyDict_SetItem(((PyTypeObject*)type_obj)->tp_dict, __pyx_n_s_reduce, reduce_cython); if (unlikely(ret < 0)) goto __PYX_BAD;
31704                 ret = PyDict_DelItem(((PyTypeObject*)type_obj)->tp_dict, __pyx_n_s_reduce_cython); if (unlikely(ret < 0)) goto __PYX_BAD;
31705             } else if (reduce == object_reduce || PyErr_Occurred()) {
31706                 goto __PYX_BAD;
31707             }
31708             setstate = __Pyx_PyObject_GetAttrStr(type_obj, __pyx_n_s_setstate);
31709             if (!setstate) PyErr_Clear();
31710             if (!setstate || __Pyx_setup_reduce_is_named(setstate, __pyx_n_s_setstate_cython)) {
31711                 setstate_cython = __Pyx_PyObject_GetAttrStrNoError(type_obj, __pyx_n_s_setstate_cython);
31712                 if (likely(setstate_cython)) {
31713                     ret = PyDict_SetItem(((PyTypeObject*)type_obj)->tp_dict, __pyx_n_s_setstate, setstate_cython); if (unlikely(ret < 0)) goto __PYX_BAD;
31714                     ret = PyDict_DelItem(((PyTypeObject*)type_obj)->tp_dict, __pyx_n_s_setstate_cython); if (unlikely(ret < 0)) goto __PYX_BAD;
31715                 } else if (!setstate || PyErr_Occurred()) {
31716                     goto __PYX_BAD;
31717                 }
31718             }
31719             PyType_Modified((PyTypeObject*)type_obj);
31720         }
31721     }
31722     goto __PYX_GOOD;
31723 __PYX_BAD:
31724     if (!PyErr_Occurred())
31725         PyErr_Format(PyExc_RuntimeError, "Unable to initialize pickling for %s", ((PyTypeObject*)type_obj)->tp_name);
31726     ret = -1;
31727 __PYX_GOOD:
31728 #if !CYTHON_USE_PYTYPE_LOOKUP
31729     Py_XDECREF(object_reduce);
31730     Py_XDECREF(object_reduce_ex);
31731 #endif
31732     Py_XDECREF(reduce);
31733     Py_XDECREF(reduce_ex);
31734     Py_XDECREF(reduce_cython);
31735     Py_XDECREF(setstate);
31736     Py_XDECREF(setstate_cython);
31737     return ret;
31738 }
31739 
31740 /* TypeImport */
31741   #ifndef __PYX_HAVE_RT_ImportType
31742 #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)31743 static PyTypeObject *__Pyx_ImportType(PyObject *module, const char *module_name, const char *class_name,
31744     size_t size, enum __Pyx_ImportType_CheckSize check_size)
31745 {
31746     PyObject *result = 0;
31747     char warning[200];
31748     Py_ssize_t basicsize;
31749 #ifdef Py_LIMITED_API
31750     PyObject *py_basicsize;
31751 #endif
31752     result = PyObject_GetAttrString(module, class_name);
31753     if (!result)
31754         goto bad;
31755     if (!PyType_Check(result)) {
31756         PyErr_Format(PyExc_TypeError,
31757             "%.200s.%.200s is not a type object",
31758             module_name, class_name);
31759         goto bad;
31760     }
31761 #ifndef Py_LIMITED_API
31762     basicsize = ((PyTypeObject *)result)->tp_basicsize;
31763 #else
31764     py_basicsize = PyObject_GetAttrString(result, "__basicsize__");
31765     if (!py_basicsize)
31766         goto bad;
31767     basicsize = PyLong_AsSsize_t(py_basicsize);
31768     Py_DECREF(py_basicsize);
31769     py_basicsize = 0;
31770     if (basicsize == (Py_ssize_t)-1 && PyErr_Occurred())
31771         goto bad;
31772 #endif
31773     if ((size_t)basicsize < size) {
31774         PyErr_Format(PyExc_ValueError,
31775             "%.200s.%.200s size changed, may indicate binary incompatibility. "
31776             "Expected %zd from C header, got %zd from PyObject",
31777             module_name, class_name, size, basicsize);
31778         goto bad;
31779     }
31780     if (check_size == __Pyx_ImportType_CheckSize_Error && (size_t)basicsize != size) {
31781         PyErr_Format(PyExc_ValueError,
31782             "%.200s.%.200s size changed, may indicate binary incompatibility. "
31783             "Expected %zd from C header, got %zd from PyObject",
31784             module_name, class_name, size, basicsize);
31785         goto bad;
31786     }
31787     else if (check_size == __Pyx_ImportType_CheckSize_Warn && (size_t)basicsize > size) {
31788         PyOS_snprintf(warning, sizeof(warning),
31789             "%s.%s size changed, may indicate binary incompatibility. "
31790             "Expected %zd from C header, got %zd from PyObject",
31791             module_name, class_name, size, basicsize);
31792         if (PyErr_WarnEx(NULL, warning, 0) < 0) goto bad;
31793     }
31794     return (PyTypeObject *)result;
31795 bad:
31796     Py_XDECREF(result);
31797     return NULL;
31798 }
31799 #endif
31800 
31801 /* CLineInTraceback */
31802   #ifndef CYTHON_CLINE_IN_TRACEBACK
__Pyx_CLineForTraceback(CYTHON_NCP_UNUSED PyThreadState * tstate,int c_line)31803 static int __Pyx_CLineForTraceback(CYTHON_NCP_UNUSED PyThreadState *tstate, int c_line) {
31804     PyObject *use_cline;
31805     PyObject *ptype, *pvalue, *ptraceback;
31806 #if CYTHON_COMPILING_IN_CPYTHON
31807     PyObject **cython_runtime_dict;
31808 #endif
31809     if (unlikely(!__pyx_cython_runtime)) {
31810         return c_line;
31811     }
31812     __Pyx_ErrFetchInState(tstate, &ptype, &pvalue, &ptraceback);
31813 #if CYTHON_COMPILING_IN_CPYTHON
31814     cython_runtime_dict = _PyObject_GetDictPtr(__pyx_cython_runtime);
31815     if (likely(cython_runtime_dict)) {
31816         __PYX_PY_DICT_LOOKUP_IF_MODIFIED(
31817             use_cline, *cython_runtime_dict,
31818             __Pyx_PyDict_GetItemStr(*cython_runtime_dict, __pyx_n_s_cline_in_traceback))
31819     } else
31820 #endif
31821     {
31822       PyObject *use_cline_obj = __Pyx_PyObject_GetAttrStr(__pyx_cython_runtime, __pyx_n_s_cline_in_traceback);
31823       if (use_cline_obj) {
31824         use_cline = PyObject_Not(use_cline_obj) ? Py_False : Py_True;
31825         Py_DECREF(use_cline_obj);
31826       } else {
31827         PyErr_Clear();
31828         use_cline = NULL;
31829       }
31830     }
31831     if (!use_cline) {
31832         c_line = 0;
31833         PyObject_SetAttr(__pyx_cython_runtime, __pyx_n_s_cline_in_traceback, Py_False);
31834     }
31835     else if (use_cline == Py_False || (use_cline != Py_True && PyObject_Not(use_cline) != 0)) {
31836         c_line = 0;
31837     }
31838     __Pyx_ErrRestoreInState(tstate, ptype, pvalue, ptraceback);
31839     return c_line;
31840 }
31841 #endif
31842 
31843 /* CodeObjectCache */
__pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry * entries,int count,int code_line)31844   static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line) {
31845     int start = 0, mid = 0, end = count - 1;
31846     if (end >= 0 && code_line > entries[end].code_line) {
31847         return count;
31848     }
31849     while (start < end) {
31850         mid = start + (end - start) / 2;
31851         if (code_line < entries[mid].code_line) {
31852             end = mid;
31853         } else if (code_line > entries[mid].code_line) {
31854              start = mid + 1;
31855         } else {
31856             return mid;
31857         }
31858     }
31859     if (code_line <= entries[mid].code_line) {
31860         return mid;
31861     } else {
31862         return mid + 1;
31863     }
31864 }
__pyx_find_code_object(int code_line)31865 static PyCodeObject *__pyx_find_code_object(int code_line) {
31866     PyCodeObject* code_object;
31867     int pos;
31868     if (unlikely(!code_line) || unlikely(!__pyx_code_cache.entries)) {
31869         return NULL;
31870     }
31871     pos = __pyx_bisect_code_objects(__pyx_code_cache.entries, __pyx_code_cache.count, code_line);
31872     if (unlikely(pos >= __pyx_code_cache.count) || unlikely(__pyx_code_cache.entries[pos].code_line != code_line)) {
31873         return NULL;
31874     }
31875     code_object = __pyx_code_cache.entries[pos].code_object;
31876     Py_INCREF(code_object);
31877     return code_object;
31878 }
__pyx_insert_code_object(int code_line,PyCodeObject * code_object)31879 static void __pyx_insert_code_object(int code_line, PyCodeObject* code_object) {
31880     int pos, i;
31881     __Pyx_CodeObjectCacheEntry* entries = __pyx_code_cache.entries;
31882     if (unlikely(!code_line)) {
31883         return;
31884     }
31885     if (unlikely(!entries)) {
31886         entries = (__Pyx_CodeObjectCacheEntry*)PyMem_Malloc(64*sizeof(__Pyx_CodeObjectCacheEntry));
31887         if (likely(entries)) {
31888             __pyx_code_cache.entries = entries;
31889             __pyx_code_cache.max_count = 64;
31890             __pyx_code_cache.count = 1;
31891             entries[0].code_line = code_line;
31892             entries[0].code_object = code_object;
31893             Py_INCREF(code_object);
31894         }
31895         return;
31896     }
31897     pos = __pyx_bisect_code_objects(__pyx_code_cache.entries, __pyx_code_cache.count, code_line);
31898     if ((pos < __pyx_code_cache.count) && unlikely(__pyx_code_cache.entries[pos].code_line == code_line)) {
31899         PyCodeObject* tmp = entries[pos].code_object;
31900         entries[pos].code_object = code_object;
31901         Py_DECREF(tmp);
31902         return;
31903     }
31904     if (__pyx_code_cache.count == __pyx_code_cache.max_count) {
31905         int new_max = __pyx_code_cache.max_count + 64;
31906         entries = (__Pyx_CodeObjectCacheEntry*)PyMem_Realloc(
31907             __pyx_code_cache.entries, ((size_t)new_max) * sizeof(__Pyx_CodeObjectCacheEntry));
31908         if (unlikely(!entries)) {
31909             return;
31910         }
31911         __pyx_code_cache.entries = entries;
31912         __pyx_code_cache.max_count = new_max;
31913     }
31914     for (i=__pyx_code_cache.count; i>pos; i--) {
31915         entries[i] = entries[i-1];
31916     }
31917     entries[pos].code_line = code_line;
31918     entries[pos].code_object = code_object;
31919     __pyx_code_cache.count++;
31920     Py_INCREF(code_object);
31921 }
31922 
31923 /* AddTraceback */
31924   #include "compile.h"
31925 #include "frameobject.h"
31926 #include "traceback.h"
__Pyx_CreateCodeObjectForTraceback(const char * funcname,int c_line,int py_line,const char * filename)31927 static PyCodeObject* __Pyx_CreateCodeObjectForTraceback(
31928             const char *funcname, int c_line,
31929             int py_line, const char *filename) {
31930     PyCodeObject *py_code = 0;
31931     PyObject *py_srcfile = 0;
31932     PyObject *py_funcname = 0;
31933     #if PY_MAJOR_VERSION < 3
31934     py_srcfile = PyString_FromString(filename);
31935     #else
31936     py_srcfile = PyUnicode_FromString(filename);
31937     #endif
31938     if (!py_srcfile) goto bad;
31939     if (c_line) {
31940         #if PY_MAJOR_VERSION < 3
31941         py_funcname = PyString_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, c_line);
31942         #else
31943         py_funcname = PyUnicode_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, c_line);
31944         #endif
31945     }
31946     else {
31947         #if PY_MAJOR_VERSION < 3
31948         py_funcname = PyString_FromString(funcname);
31949         #else
31950         py_funcname = PyUnicode_FromString(funcname);
31951         #endif
31952     }
31953     if (!py_funcname) goto bad;
31954     py_code = __Pyx_PyCode_New(
31955         0,
31956         0,
31957         0,
31958         0,
31959         0,
31960         __pyx_empty_bytes, /*PyObject *code,*/
31961         __pyx_empty_tuple, /*PyObject *consts,*/
31962         __pyx_empty_tuple, /*PyObject *names,*/
31963         __pyx_empty_tuple, /*PyObject *varnames,*/
31964         __pyx_empty_tuple, /*PyObject *freevars,*/
31965         __pyx_empty_tuple, /*PyObject *cellvars,*/
31966         py_srcfile,   /*PyObject *filename,*/
31967         py_funcname,  /*PyObject *name,*/
31968         py_line,
31969         __pyx_empty_bytes  /*PyObject *lnotab*/
31970     );
31971     Py_DECREF(py_srcfile);
31972     Py_DECREF(py_funcname);
31973     return py_code;
31974 bad:
31975     Py_XDECREF(py_srcfile);
31976     Py_XDECREF(py_funcname);
31977     return NULL;
31978 }
__Pyx_AddTraceback(const char * funcname,int c_line,int py_line,const char * filename)31979 static void __Pyx_AddTraceback(const char *funcname, int c_line,
31980                                int py_line, const char *filename) {
31981     PyCodeObject *py_code = 0;
31982     PyFrameObject *py_frame = 0;
31983     PyThreadState *tstate = __Pyx_PyThreadState_Current;
31984     if (c_line) {
31985         c_line = __Pyx_CLineForTraceback(tstate, c_line);
31986     }
31987     py_code = __pyx_find_code_object(c_line ? -c_line : py_line);
31988     if (!py_code) {
31989         py_code = __Pyx_CreateCodeObjectForTraceback(
31990             funcname, c_line, py_line, filename);
31991         if (!py_code) goto bad;
31992         __pyx_insert_code_object(c_line ? -c_line : py_line, py_code);
31993     }
31994     py_frame = PyFrame_New(
31995         tstate,            /*PyThreadState *tstate,*/
31996         py_code,           /*PyCodeObject *code,*/
31997         __pyx_d,    /*PyObject *globals,*/
31998         0                  /*PyObject *locals*/
31999     );
32000     if (!py_frame) goto bad;
32001     __Pyx_PyFrame_SetLineNumber(py_frame, py_line);
32002     PyTraceBack_Here(py_frame);
32003 bad:
32004     Py_XDECREF(py_code);
32005     Py_XDECREF(py_frame);
32006 }
32007 
32008 /* Declarations */
32009   #if CYTHON_CCOMPLEX
32010   #ifdef __cplusplus
__pyx_t_double_complex_from_parts(double x,double y)32011     static CYTHON_INLINE __pyx_t_double_complex __pyx_t_double_complex_from_parts(double x, double y) {
32012       return ::std::complex< double >(x, y);
32013     }
32014   #else
__pyx_t_double_complex_from_parts(double x,double y)32015     static CYTHON_INLINE __pyx_t_double_complex __pyx_t_double_complex_from_parts(double x, double y) {
32016       return x + y*(__pyx_t_double_complex)_Complex_I;
32017     }
32018   #endif
32019 #else
__pyx_t_double_complex_from_parts(double x,double y)32020     static CYTHON_INLINE __pyx_t_double_complex __pyx_t_double_complex_from_parts(double x, double y) {
32021       __pyx_t_double_complex z;
32022       z.real = x;
32023       z.imag = y;
32024       return z;
32025     }
32026 #endif
32027 
32028 /* Arithmetic */
32029   #if CYTHON_CCOMPLEX
32030 #else
__Pyx_c_eq_double(__pyx_t_double_complex a,__pyx_t_double_complex b)32031     static CYTHON_INLINE int __Pyx_c_eq_double(__pyx_t_double_complex a, __pyx_t_double_complex b) {
32032        return (a.real == b.real) && (a.imag == b.imag);
32033     }
__Pyx_c_sum_double(__pyx_t_double_complex a,__pyx_t_double_complex b)32034     static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_sum_double(__pyx_t_double_complex a, __pyx_t_double_complex b) {
32035         __pyx_t_double_complex z;
32036         z.real = a.real + b.real;
32037         z.imag = a.imag + b.imag;
32038         return z;
32039     }
__Pyx_c_diff_double(__pyx_t_double_complex a,__pyx_t_double_complex b)32040     static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_diff_double(__pyx_t_double_complex a, __pyx_t_double_complex b) {
32041         __pyx_t_double_complex z;
32042         z.real = a.real - b.real;
32043         z.imag = a.imag - b.imag;
32044         return z;
32045     }
__Pyx_c_prod_double(__pyx_t_double_complex a,__pyx_t_double_complex b)32046     static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_prod_double(__pyx_t_double_complex a, __pyx_t_double_complex b) {
32047         __pyx_t_double_complex z;
32048         z.real = a.real * b.real - a.imag * b.imag;
32049         z.imag = a.real * b.imag + a.imag * b.real;
32050         return z;
32051     }
32052     #if 1
__Pyx_c_quot_double(__pyx_t_double_complex a,__pyx_t_double_complex b)32053     static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_quot_double(__pyx_t_double_complex a, __pyx_t_double_complex b) {
32054         if (b.imag == 0) {
32055             return __pyx_t_double_complex_from_parts(a.real / b.real, a.imag / b.real);
32056         } else if (fabs(b.real) >= fabs(b.imag)) {
32057             if (b.real == 0 && b.imag == 0) {
32058                 return __pyx_t_double_complex_from_parts(a.real / b.real, a.imag / b.imag);
32059             } else {
32060                 double r = b.imag / b.real;
32061                 double s = (double)(1.0) / (b.real + b.imag * r);
32062                 return __pyx_t_double_complex_from_parts(
32063                     (a.real + a.imag * r) * s, (a.imag - a.real * r) * s);
32064             }
32065         } else {
32066             double r = b.real / b.imag;
32067             double s = (double)(1.0) / (b.imag + b.real * r);
32068             return __pyx_t_double_complex_from_parts(
32069                 (a.real * r + a.imag) * s, (a.imag * r - a.real) * s);
32070         }
32071     }
32072     #else
__Pyx_c_quot_double(__pyx_t_double_complex a,__pyx_t_double_complex b)32073     static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_quot_double(__pyx_t_double_complex a, __pyx_t_double_complex b) {
32074         if (b.imag == 0) {
32075             return __pyx_t_double_complex_from_parts(a.real / b.real, a.imag / b.real);
32076         } else {
32077             double denom = b.real * b.real + b.imag * b.imag;
32078             return __pyx_t_double_complex_from_parts(
32079                 (a.real * b.real + a.imag * b.imag) / denom,
32080                 (a.imag * b.real - a.real * b.imag) / denom);
32081         }
32082     }
32083     #endif
__Pyx_c_neg_double(__pyx_t_double_complex a)32084     static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_neg_double(__pyx_t_double_complex a) {
32085         __pyx_t_double_complex z;
32086         z.real = -a.real;
32087         z.imag = -a.imag;
32088         return z;
32089     }
__Pyx_c_is_zero_double(__pyx_t_double_complex a)32090     static CYTHON_INLINE int __Pyx_c_is_zero_double(__pyx_t_double_complex a) {
32091        return (a.real == 0) && (a.imag == 0);
32092     }
__Pyx_c_conj_double(__pyx_t_double_complex a)32093     static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_conj_double(__pyx_t_double_complex a) {
32094         __pyx_t_double_complex z;
32095         z.real =  a.real;
32096         z.imag = -a.imag;
32097         return z;
32098     }
32099     #if 1
__Pyx_c_abs_double(__pyx_t_double_complex z)32100         static CYTHON_INLINE double __Pyx_c_abs_double(__pyx_t_double_complex z) {
32101           #if !defined(HAVE_HYPOT) || defined(_MSC_VER)
32102             return sqrt(z.real*z.real + z.imag*z.imag);
32103           #else
32104             return hypot(z.real, z.imag);
32105           #endif
32106         }
__Pyx_c_pow_double(__pyx_t_double_complex a,__pyx_t_double_complex b)32107         static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_pow_double(__pyx_t_double_complex a, __pyx_t_double_complex b) {
32108             __pyx_t_double_complex z;
32109             double r, lnr, theta, z_r, z_theta;
32110             if (b.imag == 0 && b.real == (int)b.real) {
32111                 if (b.real < 0) {
32112                     double denom = a.real * a.real + a.imag * a.imag;
32113                     a.real = a.real / denom;
32114                     a.imag = -a.imag / denom;
32115                     b.real = -b.real;
32116                 }
32117                 switch ((int)b.real) {
32118                     case 0:
32119                         z.real = 1;
32120                         z.imag = 0;
32121                         return z;
32122                     case 1:
32123                         return a;
32124                     case 2:
32125                         return __Pyx_c_prod_double(a, a);
32126                     case 3:
32127                         z = __Pyx_c_prod_double(a, a);
32128                         return __Pyx_c_prod_double(z, a);
32129                     case 4:
32130                         z = __Pyx_c_prod_double(a, a);
32131                         return __Pyx_c_prod_double(z, z);
32132                 }
32133             }
32134             if (a.imag == 0) {
32135                 if (a.real == 0) {
32136                     return a;
32137                 } else if (b.imag == 0) {
32138                     z.real = pow(a.real, b.real);
32139                     z.imag = 0;
32140                     return z;
32141                 } else if (a.real > 0) {
32142                     r = a.real;
32143                     theta = 0;
32144                 } else {
32145                     r = -a.real;
32146                     theta = atan2(0.0, -1.0);
32147                 }
32148             } else {
32149                 r = __Pyx_c_abs_double(a);
32150                 theta = atan2(a.imag, a.real);
32151             }
32152             lnr = log(r);
32153             z_r = exp(lnr * b.real - theta * b.imag);
32154             z_theta = theta * b.real + lnr * b.imag;
32155             z.real = z_r * cos(z_theta);
32156             z.imag = z_r * sin(z_theta);
32157             return z;
32158         }
32159     #endif
32160 #endif
32161 
32162 #if PY_MAJOR_VERSION < 3
__Pyx_GetBuffer(PyObject * obj,Py_buffer * view,int flags)32163 static int __Pyx_GetBuffer(PyObject *obj, Py_buffer *view, int flags) {
32164     if (PyObject_CheckBuffer(obj)) return PyObject_GetBuffer(obj, view, flags);
32165         if (__Pyx_TypeCheck(obj, __pyx_array_type)) return __pyx_array_getbuffer(obj, view, flags);
32166         if (__Pyx_TypeCheck(obj, __pyx_memoryview_type)) return __pyx_memoryview_getbuffer(obj, view, flags);
32167     PyErr_Format(PyExc_TypeError, "'%.200s' does not have the buffer interface", Py_TYPE(obj)->tp_name);
32168     return -1;
32169 }
__Pyx_ReleaseBuffer(Py_buffer * view)32170 static void __Pyx_ReleaseBuffer(Py_buffer *view) {
32171     PyObject *obj = view->obj;
32172     if (!obj) return;
32173     if (PyObject_CheckBuffer(obj)) {
32174         PyBuffer_Release(view);
32175         return;
32176     }
32177     if ((0)) {}
32178     view->obj = NULL;
32179     Py_DECREF(obj);
32180 }
32181 #endif
32182 
32183 
32184   /* MemviewSliceIsContig */
32185   static int
__pyx_memviewslice_is_contig(const __Pyx_memviewslice mvs,char order,int ndim)32186 __pyx_memviewslice_is_contig(const __Pyx_memviewslice mvs, char order, int ndim)
32187 {
32188     int i, index, step, start;
32189     Py_ssize_t itemsize = mvs.memview->view.itemsize;
32190     if (order == 'F') {
32191         step = 1;
32192         start = 0;
32193     } else {
32194         step = -1;
32195         start = ndim - 1;
32196     }
32197     for (i = 0; i < ndim; i++) {
32198         index = start + step * i;
32199         if (mvs.suboffsets[index] >= 0 || mvs.strides[index] != itemsize)
32200             return 0;
32201         itemsize *= mvs.shape[index];
32202     }
32203     return 1;
32204 }
32205 
32206 /* OverlappingSlices */
32207   static void
__pyx_get_array_memory_extents(__Pyx_memviewslice * slice,void ** out_start,void ** out_end,int ndim,size_t itemsize)32208 __pyx_get_array_memory_extents(__Pyx_memviewslice *slice,
32209                                void **out_start, void **out_end,
32210                                int ndim, size_t itemsize)
32211 {
32212     char *start, *end;
32213     int i;
32214     start = end = slice->data;
32215     for (i = 0; i < ndim; i++) {
32216         Py_ssize_t stride = slice->strides[i];
32217         Py_ssize_t extent = slice->shape[i];
32218         if (extent == 0) {
32219             *out_start = *out_end = start;
32220             return;
32221         } else {
32222             if (stride > 0)
32223                 end += stride * (extent - 1);
32224             else
32225                 start += stride * (extent - 1);
32226         }
32227     }
32228     *out_start = start;
32229     *out_end = end + itemsize;
32230 }
32231 static int
__pyx_slices_overlap(__Pyx_memviewslice * slice1,__Pyx_memviewslice * slice2,int ndim,size_t itemsize)32232 __pyx_slices_overlap(__Pyx_memviewslice *slice1,
32233                      __Pyx_memviewslice *slice2,
32234                      int ndim, size_t itemsize)
32235 {
32236     void *start1, *end1, *start2, *end2;
32237     __pyx_get_array_memory_extents(slice1, &start1, &end1, ndim, itemsize);
32238     __pyx_get_array_memory_extents(slice2, &start2, &end2, ndim, itemsize);
32239     return (start1 < end2) && (start2 < end1);
32240 }
32241 
32242 /* Capsule */
32243   static CYTHON_INLINE PyObject *
__pyx_capsule_create(void * p,CYTHON_UNUSED const char * sig)32244 __pyx_capsule_create(void *p, CYTHON_UNUSED const char *sig)
32245 {
32246     PyObject *cobj;
32247 #if PY_VERSION_HEX >= 0x02070000
32248     cobj = PyCapsule_New(p, sig, NULL);
32249 #else
32250     cobj = PyCObject_FromVoidPtr(p, NULL);
32251 #endif
32252     return cobj;
32253 }
32254 
32255 /* CIntFromPyVerify */
32256   #define __PYX_VERIFY_RETURN_INT(target_type, func_type, func_value)\
32257     __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, 0)
32258 #define __PYX_VERIFY_RETURN_INT_EXC(target_type, func_type, func_value)\
32259     __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, 1)
32260 #define __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, exc)\
32261     {\
32262         func_type value = func_value;\
32263         if (sizeof(target_type) < sizeof(func_type)) {\
32264             if (unlikely(value != (func_type) (target_type) value)) {\
32265                 func_type zero = 0;\
32266                 if (exc && unlikely(value == (func_type)-1 && PyErr_Occurred()))\
32267                     return (target_type) -1;\
32268                 if (is_unsigned && unlikely(value < zero))\
32269                     goto raise_neg_overflow;\
32270                 else\
32271                     goto raise_overflow;\
32272             }\
32273         }\
32274         return (target_type) value;\
32275     }
32276 
32277 /* TypeInfoCompare */
32278   static int
__pyx_typeinfo_cmp(__Pyx_TypeInfo * a,__Pyx_TypeInfo * b)32279 __pyx_typeinfo_cmp(__Pyx_TypeInfo *a, __Pyx_TypeInfo *b)
32280 {
32281     int i;
32282     if (!a || !b)
32283         return 0;
32284     if (a == b)
32285         return 1;
32286     if (a->size != b->size || a->typegroup != b->typegroup ||
32287             a->is_unsigned != b->is_unsigned || a->ndim != b->ndim) {
32288         if (a->typegroup == 'H' || b->typegroup == 'H') {
32289             return a->size == b->size;
32290         } else {
32291             return 0;
32292         }
32293     }
32294     if (a->ndim) {
32295         for (i = 0; i < a->ndim; i++)
32296             if (a->arraysize[i] != b->arraysize[i])
32297                 return 0;
32298     }
32299     if (a->typegroup == 'S') {
32300         if (a->flags != b->flags)
32301             return 0;
32302         if (a->fields || b->fields) {
32303             if (!(a->fields && b->fields))
32304                 return 0;
32305             for (i = 0; a->fields[i].type && b->fields[i].type; i++) {
32306                 __Pyx_StructField *field_a = a->fields + i;
32307                 __Pyx_StructField *field_b = b->fields + i;
32308                 if (field_a->offset != field_b->offset ||
32309                     !__pyx_typeinfo_cmp(field_a->type, field_b->type))
32310                     return 0;
32311             }
32312             return !a->fields[i].type && !b->fields[i].type;
32313         }
32314     }
32315     return 1;
32316 }
32317 
32318 /* MemviewSliceValidateAndInit */
32319   static int
__pyx_check_strides(Py_buffer * buf,int dim,int ndim,int spec)32320 __pyx_check_strides(Py_buffer *buf, int dim, int ndim, int spec)
32321 {
32322     if (buf->shape[dim] <= 1)
32323         return 1;
32324     if (buf->strides) {
32325         if (spec & __Pyx_MEMVIEW_CONTIG) {
32326             if (spec & (__Pyx_MEMVIEW_PTR|__Pyx_MEMVIEW_FULL)) {
32327                 if (unlikely(buf->strides[dim] != sizeof(void *))) {
32328                     PyErr_Format(PyExc_ValueError,
32329                                  "Buffer is not indirectly contiguous "
32330                                  "in dimension %d.", dim);
32331                     goto fail;
32332                 }
32333             } else if (unlikely(buf->strides[dim] != buf->itemsize)) {
32334                 PyErr_SetString(PyExc_ValueError,
32335                                 "Buffer and memoryview are not contiguous "
32336                                 "in the same dimension.");
32337                 goto fail;
32338             }
32339         }
32340         if (spec & __Pyx_MEMVIEW_FOLLOW) {
32341             Py_ssize_t stride = buf->strides[dim];
32342             if (stride < 0)
32343                 stride = -stride;
32344             if (unlikely(stride < buf->itemsize)) {
32345                 PyErr_SetString(PyExc_ValueError,
32346                                 "Buffer and memoryview are not contiguous "
32347                                 "in the same dimension.");
32348                 goto fail;
32349             }
32350         }
32351     } else {
32352         if (unlikely(spec & __Pyx_MEMVIEW_CONTIG && dim != ndim - 1)) {
32353             PyErr_Format(PyExc_ValueError,
32354                          "C-contiguous buffer is not contiguous in "
32355                          "dimension %d", dim);
32356             goto fail;
32357         } else if (unlikely(spec & (__Pyx_MEMVIEW_PTR))) {
32358             PyErr_Format(PyExc_ValueError,
32359                          "C-contiguous buffer is not indirect in "
32360                          "dimension %d", dim);
32361             goto fail;
32362         } else if (unlikely(buf->suboffsets)) {
32363             PyErr_SetString(PyExc_ValueError,
32364                             "Buffer exposes suboffsets but no strides");
32365             goto fail;
32366         }
32367     }
32368     return 1;
32369 fail:
32370     return 0;
32371 }
32372 static int
__pyx_check_suboffsets(Py_buffer * buf,int dim,CYTHON_UNUSED int ndim,int spec)32373 __pyx_check_suboffsets(Py_buffer *buf, int dim, CYTHON_UNUSED int ndim, int spec)
32374 {
32375     if (spec & __Pyx_MEMVIEW_DIRECT) {
32376         if (unlikely(buf->suboffsets && buf->suboffsets[dim] >= 0)) {
32377             PyErr_Format(PyExc_ValueError,
32378                          "Buffer not compatible with direct access "
32379                          "in dimension %d.", dim);
32380             goto fail;
32381         }
32382     }
32383     if (spec & __Pyx_MEMVIEW_PTR) {
32384         if (unlikely(!buf->suboffsets || (buf->suboffsets[dim] < 0))) {
32385             PyErr_Format(PyExc_ValueError,
32386                          "Buffer is not indirectly accessible "
32387                          "in dimension %d.", dim);
32388             goto fail;
32389         }
32390     }
32391     return 1;
32392 fail:
32393     return 0;
32394 }
32395 static int
__pyx_verify_contig(Py_buffer * buf,int ndim,int c_or_f_flag)32396 __pyx_verify_contig(Py_buffer *buf, int ndim, int c_or_f_flag)
32397 {
32398     int i;
32399     if (c_or_f_flag & __Pyx_IS_F_CONTIG) {
32400         Py_ssize_t stride = 1;
32401         for (i = 0; i < ndim; i++) {
32402             if (unlikely(stride * buf->itemsize != buf->strides[i]  &&  buf->shape[i] > 1)) {
32403                 PyErr_SetString(PyExc_ValueError,
32404                     "Buffer not fortran contiguous.");
32405                 goto fail;
32406             }
32407             stride = stride * buf->shape[i];
32408         }
32409     } else if (c_or_f_flag & __Pyx_IS_C_CONTIG) {
32410         Py_ssize_t stride = 1;
32411         for (i = ndim - 1; i >- 1; i--) {
32412             if (unlikely(stride * buf->itemsize != buf->strides[i]  &&  buf->shape[i] > 1)) {
32413                 PyErr_SetString(PyExc_ValueError,
32414                     "Buffer not C contiguous.");
32415                 goto fail;
32416             }
32417             stride = stride * buf->shape[i];
32418         }
32419     }
32420     return 1;
32421 fail:
32422     return 0;
32423 }
__Pyx_ValidateAndInit_memviewslice(int * axes_specs,int c_or_f_flag,int buf_flags,int ndim,__Pyx_TypeInfo * dtype,__Pyx_BufFmt_StackElem stack[],__Pyx_memviewslice * memviewslice,PyObject * original_obj)32424 static int __Pyx_ValidateAndInit_memviewslice(
32425                 int *axes_specs,
32426                 int c_or_f_flag,
32427                 int buf_flags,
32428                 int ndim,
32429                 __Pyx_TypeInfo *dtype,
32430                 __Pyx_BufFmt_StackElem stack[],
32431                 __Pyx_memviewslice *memviewslice,
32432                 PyObject *original_obj)
32433 {
32434     struct __pyx_memoryview_obj *memview, *new_memview;
32435     __Pyx_RefNannyDeclarations
32436     Py_buffer *buf;
32437     int i, spec = 0, retval = -1;
32438     __Pyx_BufFmt_Context ctx;
32439     int from_memoryview = __pyx_memoryview_check(original_obj);
32440     __Pyx_RefNannySetupContext("ValidateAndInit_memviewslice", 0);
32441     if (from_memoryview && __pyx_typeinfo_cmp(dtype, ((struct __pyx_memoryview_obj *)
32442                                                             original_obj)->typeinfo)) {
32443         memview = (struct __pyx_memoryview_obj *) original_obj;
32444         new_memview = NULL;
32445     } else {
32446         memview = (struct __pyx_memoryview_obj *) __pyx_memoryview_new(
32447                                             original_obj, buf_flags, 0, dtype);
32448         new_memview = memview;
32449         if (unlikely(!memview))
32450             goto fail;
32451     }
32452     buf = &memview->view;
32453     if (unlikely(buf->ndim != ndim)) {
32454         PyErr_Format(PyExc_ValueError,
32455                 "Buffer has wrong number of dimensions (expected %d, got %d)",
32456                 ndim, buf->ndim);
32457         goto fail;
32458     }
32459     if (new_memview) {
32460         __Pyx_BufFmt_Init(&ctx, stack, dtype);
32461         if (unlikely(!__Pyx_BufFmt_CheckString(&ctx, buf->format))) goto fail;
32462     }
32463     if (unlikely((unsigned) buf->itemsize != dtype->size)) {
32464         PyErr_Format(PyExc_ValueError,
32465                      "Item size of buffer (%" CYTHON_FORMAT_SSIZE_T "u byte%s) "
32466                      "does not match size of '%s' (%" CYTHON_FORMAT_SSIZE_T "u byte%s)",
32467                      buf->itemsize,
32468                      (buf->itemsize > 1) ? "s" : "",
32469                      dtype->name,
32470                      dtype->size,
32471                      (dtype->size > 1) ? "s" : "");
32472         goto fail;
32473     }
32474     if (buf->len > 0) {
32475         for (i = 0; i < ndim; i++) {
32476             spec = axes_specs[i];
32477             if (unlikely(!__pyx_check_strides(buf, i, ndim, spec)))
32478                 goto fail;
32479             if (unlikely(!__pyx_check_suboffsets(buf, i, ndim, spec)))
32480                 goto fail;
32481         }
32482         if (unlikely(buf->strides && !__pyx_verify_contig(buf, ndim, c_or_f_flag)))
32483             goto fail;
32484     }
32485     if (unlikely(__Pyx_init_memviewslice(memview, ndim, memviewslice,
32486                                          new_memview != NULL) == -1)) {
32487         goto fail;
32488     }
32489     retval = 0;
32490     goto no_fail;
32491 fail:
32492     Py_XDECREF(new_memview);
32493     retval = -1;
32494 no_fail:
32495     __Pyx_RefNannyFinishContext();
32496     return retval;
32497 }
32498 
32499 /* ObjectToMemviewSlice */
__Pyx_PyObject_to_MemoryviewSlice_dcd____pyx_t_double_complex(PyObject * obj,int writable_flag)32500   static CYTHON_INLINE __Pyx_memviewslice __Pyx_PyObject_to_MemoryviewSlice_dcd____pyx_t_double_complex(PyObject *obj, int writable_flag) {
32501     __Pyx_memviewslice result = { 0, 0, { 0 }, { 0 }, { 0 } };
32502     __Pyx_BufFmt_StackElem stack[1];
32503     int axes_specs[] = { (__Pyx_MEMVIEW_DIRECT | __Pyx_MEMVIEW_CONTIG), (__Pyx_MEMVIEW_DIRECT | __Pyx_MEMVIEW_FOLLOW) };
32504     int retcode;
32505     if (obj == Py_None) {
32506         result.memview = (struct __pyx_memoryview_obj *) Py_None;
32507         return result;
32508     }
32509     retcode = __Pyx_ValidateAndInit_memviewslice(axes_specs, __Pyx_IS_F_CONTIG,
32510                                                  (PyBUF_F_CONTIGUOUS | PyBUF_FORMAT) | writable_flag, 2,
32511                                                  &__Pyx_TypeInfo___pyx_t_double_complex, stack,
32512                                                  &result, obj);
32513     if (unlikely(retcode == -1))
32514         goto __pyx_fail;
32515     return result;
32516 __pyx_fail:
32517     result.memview = NULL;
32518     result.data = NULL;
32519     return result;
32520 }
32521 
32522 /* FromPy */
__Pyx_PyComplex_As___pyx_t_double_complex(PyObject * o)32523   static __pyx_t_double_complex __Pyx_PyComplex_As___pyx_t_double_complex(PyObject* o) {
32524     Py_complex cval;
32525 #if !CYTHON_COMPILING_IN_PYPY
32526     if (PyComplex_CheckExact(o))
32527         cval = ((PyComplexObject *)o)->cval;
32528     else
32529 #endif
32530         cval = PyComplex_AsCComplex(o);
32531     return __pyx_t_double_complex_from_parts(
32532                (double)cval.real,
32533                (double)cval.imag);
32534 }
32535 
32536 /* ObjectToMemviewSlice */
__Pyx_PyObject_to_MemoryviewSlice_dc_double(PyObject * obj,int writable_flag)32537   static CYTHON_INLINE __Pyx_memviewslice __Pyx_PyObject_to_MemoryviewSlice_dc_double(PyObject *obj, int writable_flag) {
32538     __Pyx_memviewslice result = { 0, 0, { 0 }, { 0 }, { 0 } };
32539     __Pyx_BufFmt_StackElem stack[1];
32540     int axes_specs[] = { (__Pyx_MEMVIEW_DIRECT | __Pyx_MEMVIEW_CONTIG) };
32541     int retcode;
32542     if (obj == Py_None) {
32543         result.memview = (struct __pyx_memoryview_obj *) Py_None;
32544         return result;
32545     }
32546     retcode = __Pyx_ValidateAndInit_memviewslice(axes_specs, __Pyx_IS_C_CONTIG,
32547                                                  (PyBUF_C_CONTIGUOUS | PyBUF_FORMAT) | writable_flag, 1,
32548                                                  &__Pyx_TypeInfo_double, stack,
32549                                                  &result, obj);
32550     if (unlikely(retcode == -1))
32551         goto __pyx_fail;
32552     return result;
32553 __pyx_fail:
32554     result.memview = NULL;
32555     result.data = NULL;
32556     return result;
32557 }
32558 
32559 /* None */
__Pyx_pow_Py_ssize_t(Py_ssize_t b,Py_ssize_t e)32560   static CYTHON_INLINE Py_ssize_t __Pyx_pow_Py_ssize_t(Py_ssize_t b, Py_ssize_t e) {
32561     Py_ssize_t t = b;
32562     switch (e) {
32563         case 3:
32564             t *= b;
32565         CYTHON_FALLTHROUGH;
32566         case 2:
32567             t *= b;
32568         CYTHON_FALLTHROUGH;
32569         case 1:
32570             return t;
32571         case 0:
32572             return 1;
32573     }
32574     #if 1
32575     if (unlikely(e<0)) return 0;
32576     #endif
32577     t = 1;
32578     while (likely(e)) {
32579         t *= (b * (e&1)) | ((~e)&1);
32580         b *= b;
32581         e >>= 1;
32582     }
32583     return t;
32584 }
32585 
32586 /* MemviewDtypeToObject */
__pyx_memview_get_double(const char * itemp)32587   static CYTHON_INLINE PyObject *__pyx_memview_get_double(const char *itemp) {
32588     return (PyObject *) PyFloat_FromDouble(*(double *) itemp);
32589 }
__pyx_memview_set_double(const char * itemp,PyObject * obj)32590 static CYTHON_INLINE int __pyx_memview_set_double(const char *itemp, PyObject *obj) {
32591     double value = __pyx_PyFloat_AsDouble(obj);
32592     if ((value == (double)-1) && PyErr_Occurred())
32593         return 0;
32594     *(double *) itemp = value;
32595     return 1;
32596 }
32597 
32598 /* None */
__Pyx_pow_long(long b,long e)32599   static CYTHON_INLINE long __Pyx_pow_long(long b, long e) {
32600     long t = b;
32601     switch (e) {
32602         case 3:
32603             t *= b;
32604         CYTHON_FALLTHROUGH;
32605         case 2:
32606             t *= b;
32607         CYTHON_FALLTHROUGH;
32608         case 1:
32609             return t;
32610         case 0:
32611             return 1;
32612     }
32613     #if 1
32614     if (unlikely(e<0)) return 0;
32615     #endif
32616     t = 1;
32617     while (likely(e)) {
32618         t *= (b * (e&1)) | ((~e)&1);
32619         b *= b;
32620         e >>= 1;
32621     }
32622     return t;
32623 }
32624 
32625 /* Declarations */
32626   #if CYTHON_CCOMPLEX
32627   #ifdef __cplusplus
__pyx_t_float_complex_from_parts(float x,float y)32628     static CYTHON_INLINE __pyx_t_float_complex __pyx_t_float_complex_from_parts(float x, float y) {
32629       return ::std::complex< float >(x, y);
32630     }
32631   #else
__pyx_t_float_complex_from_parts(float x,float y)32632     static CYTHON_INLINE __pyx_t_float_complex __pyx_t_float_complex_from_parts(float x, float y) {
32633       return x + y*(__pyx_t_float_complex)_Complex_I;
32634     }
32635   #endif
32636 #else
__pyx_t_float_complex_from_parts(float x,float y)32637     static CYTHON_INLINE __pyx_t_float_complex __pyx_t_float_complex_from_parts(float x, float y) {
32638       __pyx_t_float_complex z;
32639       z.real = x;
32640       z.imag = y;
32641       return z;
32642     }
32643 #endif
32644 
32645 /* Arithmetic */
32646   #if CYTHON_CCOMPLEX
32647 #else
__Pyx_c_eq_float(__pyx_t_float_complex a,__pyx_t_float_complex b)32648     static CYTHON_INLINE int __Pyx_c_eq_float(__pyx_t_float_complex a, __pyx_t_float_complex b) {
32649        return (a.real == b.real) && (a.imag == b.imag);
32650     }
__Pyx_c_sum_float(__pyx_t_float_complex a,__pyx_t_float_complex b)32651     static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_sum_float(__pyx_t_float_complex a, __pyx_t_float_complex b) {
32652         __pyx_t_float_complex z;
32653         z.real = a.real + b.real;
32654         z.imag = a.imag + b.imag;
32655         return z;
32656     }
__Pyx_c_diff_float(__pyx_t_float_complex a,__pyx_t_float_complex b)32657     static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_diff_float(__pyx_t_float_complex a, __pyx_t_float_complex b) {
32658         __pyx_t_float_complex z;
32659         z.real = a.real - b.real;
32660         z.imag = a.imag - b.imag;
32661         return z;
32662     }
__Pyx_c_prod_float(__pyx_t_float_complex a,__pyx_t_float_complex b)32663     static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_prod_float(__pyx_t_float_complex a, __pyx_t_float_complex b) {
32664         __pyx_t_float_complex z;
32665         z.real = a.real * b.real - a.imag * b.imag;
32666         z.imag = a.real * b.imag + a.imag * b.real;
32667         return z;
32668     }
32669     #if 1
__Pyx_c_quot_float(__pyx_t_float_complex a,__pyx_t_float_complex b)32670     static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_quot_float(__pyx_t_float_complex a, __pyx_t_float_complex b) {
32671         if (b.imag == 0) {
32672             return __pyx_t_float_complex_from_parts(a.real / b.real, a.imag / b.real);
32673         } else if (fabsf(b.real) >= fabsf(b.imag)) {
32674             if (b.real == 0 && b.imag == 0) {
32675                 return __pyx_t_float_complex_from_parts(a.real / b.real, a.imag / b.imag);
32676             } else {
32677                 float r = b.imag / b.real;
32678                 float s = (float)(1.0) / (b.real + b.imag * r);
32679                 return __pyx_t_float_complex_from_parts(
32680                     (a.real + a.imag * r) * s, (a.imag - a.real * r) * s);
32681             }
32682         } else {
32683             float r = b.real / b.imag;
32684             float s = (float)(1.0) / (b.imag + b.real * r);
32685             return __pyx_t_float_complex_from_parts(
32686                 (a.real * r + a.imag) * s, (a.imag * r - a.real) * s);
32687         }
32688     }
32689     #else
__Pyx_c_quot_float(__pyx_t_float_complex a,__pyx_t_float_complex b)32690     static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_quot_float(__pyx_t_float_complex a, __pyx_t_float_complex b) {
32691         if (b.imag == 0) {
32692             return __pyx_t_float_complex_from_parts(a.real / b.real, a.imag / b.real);
32693         } else {
32694             float denom = b.real * b.real + b.imag * b.imag;
32695             return __pyx_t_float_complex_from_parts(
32696                 (a.real * b.real + a.imag * b.imag) / denom,
32697                 (a.imag * b.real - a.real * b.imag) / denom);
32698         }
32699     }
32700     #endif
__Pyx_c_neg_float(__pyx_t_float_complex a)32701     static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_neg_float(__pyx_t_float_complex a) {
32702         __pyx_t_float_complex z;
32703         z.real = -a.real;
32704         z.imag = -a.imag;
32705         return z;
32706     }
__Pyx_c_is_zero_float(__pyx_t_float_complex a)32707     static CYTHON_INLINE int __Pyx_c_is_zero_float(__pyx_t_float_complex a) {
32708        return (a.real == 0) && (a.imag == 0);
32709     }
__Pyx_c_conj_float(__pyx_t_float_complex a)32710     static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_conj_float(__pyx_t_float_complex a) {
32711         __pyx_t_float_complex z;
32712         z.real =  a.real;
32713         z.imag = -a.imag;
32714         return z;
32715     }
32716     #if 1
__Pyx_c_abs_float(__pyx_t_float_complex z)32717         static CYTHON_INLINE float __Pyx_c_abs_float(__pyx_t_float_complex z) {
32718           #if !defined(HAVE_HYPOT) || defined(_MSC_VER)
32719             return sqrtf(z.real*z.real + z.imag*z.imag);
32720           #else
32721             return hypotf(z.real, z.imag);
32722           #endif
32723         }
__Pyx_c_pow_float(__pyx_t_float_complex a,__pyx_t_float_complex b)32724         static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_pow_float(__pyx_t_float_complex a, __pyx_t_float_complex b) {
32725             __pyx_t_float_complex z;
32726             float r, lnr, theta, z_r, z_theta;
32727             if (b.imag == 0 && b.real == (int)b.real) {
32728                 if (b.real < 0) {
32729                     float denom = a.real * a.real + a.imag * a.imag;
32730                     a.real = a.real / denom;
32731                     a.imag = -a.imag / denom;
32732                     b.real = -b.real;
32733                 }
32734                 switch ((int)b.real) {
32735                     case 0:
32736                         z.real = 1;
32737                         z.imag = 0;
32738                         return z;
32739                     case 1:
32740                         return a;
32741                     case 2:
32742                         return __Pyx_c_prod_float(a, a);
32743                     case 3:
32744                         z = __Pyx_c_prod_float(a, a);
32745                         return __Pyx_c_prod_float(z, a);
32746                     case 4:
32747                         z = __Pyx_c_prod_float(a, a);
32748                         return __Pyx_c_prod_float(z, z);
32749                 }
32750             }
32751             if (a.imag == 0) {
32752                 if (a.real == 0) {
32753                     return a;
32754                 } else if (b.imag == 0) {
32755                     z.real = powf(a.real, b.real);
32756                     z.imag = 0;
32757                     return z;
32758                 } else if (a.real > 0) {
32759                     r = a.real;
32760                     theta = 0;
32761                 } else {
32762                     r = -a.real;
32763                     theta = atan2f(0.0, -1.0);
32764                 }
32765             } else {
32766                 r = __Pyx_c_abs_float(a);
32767                 theta = atan2f(a.imag, a.real);
32768             }
32769             lnr = logf(r);
32770             z_r = expf(lnr * b.real - theta * b.imag);
32771             z_theta = theta * b.real + lnr * b.imag;
32772             z.real = z_r * cosf(z_theta);
32773             z.imag = z_r * sinf(z_theta);
32774             return z;
32775         }
32776     #endif
32777 #endif
32778 
32779 /* MemviewSliceCopyTemplate */
32780   static __Pyx_memviewslice
__pyx_memoryview_copy_new_contig(const __Pyx_memviewslice * from_mvs,const char * mode,int ndim,size_t sizeof_dtype,int contig_flag,int dtype_is_object)32781 __pyx_memoryview_copy_new_contig(const __Pyx_memviewslice *from_mvs,
32782                                  const char *mode, int ndim,
32783                                  size_t sizeof_dtype, int contig_flag,
32784                                  int dtype_is_object)
32785 {
32786     __Pyx_RefNannyDeclarations
32787     int i;
32788     __Pyx_memviewslice new_mvs = { 0, 0, { 0 }, { 0 }, { 0 } };
32789     struct __pyx_memoryview_obj *from_memview = from_mvs->memview;
32790     Py_buffer *buf = &from_memview->view;
32791     PyObject *shape_tuple = NULL;
32792     PyObject *temp_int = NULL;
32793     struct __pyx_array_obj *array_obj = NULL;
32794     struct __pyx_memoryview_obj *memview_obj = NULL;
32795     __Pyx_RefNannySetupContext("__pyx_memoryview_copy_new_contig", 0);
32796     for (i = 0; i < ndim; i++) {
32797         if (unlikely(from_mvs->suboffsets[i] >= 0)) {
32798             PyErr_Format(PyExc_ValueError, "Cannot copy memoryview slice with "
32799                                            "indirect dimensions (axis %d)", i);
32800             goto fail;
32801         }
32802     }
32803     shape_tuple = PyTuple_New(ndim);
32804     if (unlikely(!shape_tuple)) {
32805         goto fail;
32806     }
32807     __Pyx_GOTREF(shape_tuple);
32808     for(i = 0; i < ndim; i++) {
32809         temp_int = PyInt_FromSsize_t(from_mvs->shape[i]);
32810         if(unlikely(!temp_int)) {
32811             goto fail;
32812         } else {
32813             PyTuple_SET_ITEM(shape_tuple, i, temp_int);
32814             temp_int = NULL;
32815         }
32816     }
32817     array_obj = __pyx_array_new(shape_tuple, sizeof_dtype, buf->format, (char *) mode, NULL);
32818     if (unlikely(!array_obj)) {
32819         goto fail;
32820     }
32821     __Pyx_GOTREF(array_obj);
32822     memview_obj = (struct __pyx_memoryview_obj *) __pyx_memoryview_new(
32823                                     (PyObject *) array_obj, contig_flag,
32824                                     dtype_is_object,
32825                                     from_mvs->memview->typeinfo);
32826     if (unlikely(!memview_obj))
32827         goto fail;
32828     if (unlikely(__Pyx_init_memviewslice(memview_obj, ndim, &new_mvs, 1) < 0))
32829         goto fail;
32830     if (unlikely(__pyx_memoryview_copy_contents(*from_mvs, new_mvs, ndim, ndim,
32831                                                 dtype_is_object) < 0))
32832         goto fail;
32833     goto no_fail;
32834 fail:
32835     __Pyx_XDECREF(new_mvs.memview);
32836     new_mvs.memview = NULL;
32837     new_mvs.data = NULL;
32838 no_fail:
32839     __Pyx_XDECREF(shape_tuple);
32840     __Pyx_XDECREF(temp_int);
32841     __Pyx_XDECREF(array_obj);
32842     __Pyx_RefNannyFinishContext();
32843     return new_mvs;
32844 }
32845 
32846 /* CIntFromPy */
__Pyx_PyInt_As_int(PyObject * x)32847   static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *x) {
32848 #ifdef __Pyx_HAS_GCC_DIAGNOSTIC
32849 #pragma GCC diagnostic push
32850 #pragma GCC diagnostic ignored "-Wconversion"
32851 #endif
32852     const int neg_one = (int) -1, const_zero = (int) 0;
32853 #ifdef __Pyx_HAS_GCC_DIAGNOSTIC
32854 #pragma GCC diagnostic pop
32855 #endif
32856     const int is_unsigned = neg_one > const_zero;
32857 #if PY_MAJOR_VERSION < 3
32858     if (likely(PyInt_Check(x))) {
32859         if (sizeof(int) < sizeof(long)) {
32860             __PYX_VERIFY_RETURN_INT(int, long, PyInt_AS_LONG(x))
32861         } else {
32862             long val = PyInt_AS_LONG(x);
32863             if (is_unsigned && unlikely(val < 0)) {
32864                 goto raise_neg_overflow;
32865             }
32866             return (int) val;
32867         }
32868     } else
32869 #endif
32870     if (likely(PyLong_Check(x))) {
32871         if (is_unsigned) {
32872 #if CYTHON_USE_PYLONG_INTERNALS
32873             const digit* digits = ((PyLongObject*)x)->ob_digit;
32874             switch (Py_SIZE(x)) {
32875                 case  0: return (int) 0;
32876                 case  1: __PYX_VERIFY_RETURN_INT(int, digit, digits[0])
32877                 case 2:
32878                     if (8 * sizeof(int) > 1 * PyLong_SHIFT) {
32879                         if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
32880                             __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
32881                         } else if (8 * sizeof(int) >= 2 * PyLong_SHIFT) {
32882                             return (int) (((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0]));
32883                         }
32884                     }
32885                     break;
32886                 case 3:
32887                     if (8 * sizeof(int) > 2 * PyLong_SHIFT) {
32888                         if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
32889                             __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
32890                         } else if (8 * sizeof(int) >= 3 * PyLong_SHIFT) {
32891                             return (int) (((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]));
32892                         }
32893                     }
32894                     break;
32895                 case 4:
32896                     if (8 * sizeof(int) > 3 * PyLong_SHIFT) {
32897                         if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
32898                             __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])))
32899                         } else if (8 * sizeof(int) >= 4 * PyLong_SHIFT) {
32900                             return (int) (((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]));
32901                         }
32902                     }
32903                     break;
32904             }
32905 #endif
32906 #if CYTHON_COMPILING_IN_CPYTHON
32907             if (unlikely(Py_SIZE(x) < 0)) {
32908                 goto raise_neg_overflow;
32909             }
32910 #else
32911             {
32912                 int result = PyObject_RichCompareBool(x, Py_False, Py_LT);
32913                 if (unlikely(result < 0))
32914                     return (int) -1;
32915                 if (unlikely(result == 1))
32916                     goto raise_neg_overflow;
32917             }
32918 #endif
32919             if (sizeof(int) <= sizeof(unsigned long)) {
32920                 __PYX_VERIFY_RETURN_INT_EXC(int, unsigned long, PyLong_AsUnsignedLong(x))
32921 #ifdef HAVE_LONG_LONG
32922             } else if (sizeof(int) <= sizeof(unsigned PY_LONG_LONG)) {
32923                 __PYX_VERIFY_RETURN_INT_EXC(int, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x))
32924 #endif
32925             }
32926         } else {
32927 #if CYTHON_USE_PYLONG_INTERNALS
32928             const digit* digits = ((PyLongObject*)x)->ob_digit;
32929             switch (Py_SIZE(x)) {
32930                 case  0: return (int) 0;
32931                 case -1: __PYX_VERIFY_RETURN_INT(int, sdigit, (sdigit) (-(sdigit)digits[0]))
32932                 case  1: __PYX_VERIFY_RETURN_INT(int,  digit, +digits[0])
32933                 case -2:
32934                     if (8 * sizeof(int) - 1 > 1 * PyLong_SHIFT) {
32935                         if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
32936                             __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
32937                         } else if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) {
32938                             return (int) (((int)-1)*(((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
32939                         }
32940                     }
32941                     break;
32942                 case 2:
32943                     if (8 * sizeof(int) > 1 * PyLong_SHIFT) {
32944                         if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
32945                             __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
32946                         } else if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) {
32947                             return (int) ((((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
32948                         }
32949                     }
32950                     break;
32951                 case -3:
32952                     if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) {
32953                         if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
32954                             __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
32955                         } else if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) {
32956                             return (int) (((int)-1)*(((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
32957                         }
32958                     }
32959                     break;
32960                 case 3:
32961                     if (8 * sizeof(int) > 2 * PyLong_SHIFT) {
32962                         if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
32963                             __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
32964                         } else if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) {
32965                             return (int) ((((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
32966                         }
32967                     }
32968                     break;
32969                 case -4:
32970                     if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) {
32971                         if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
32972                             __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])))
32973                         } else if (8 * sizeof(int) - 1 > 4 * PyLong_SHIFT) {
32974                             return (int) (((int)-1)*(((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
32975                         }
32976                     }
32977                     break;
32978                 case 4:
32979                     if (8 * sizeof(int) > 3 * PyLong_SHIFT) {
32980                         if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
32981                             __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])))
32982                         } else if (8 * sizeof(int) - 1 > 4 * PyLong_SHIFT) {
32983                             return (int) ((((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
32984                         }
32985                     }
32986                     break;
32987             }
32988 #endif
32989             if (sizeof(int) <= sizeof(long)) {
32990                 __PYX_VERIFY_RETURN_INT_EXC(int, long, PyLong_AsLong(x))
32991 #ifdef HAVE_LONG_LONG
32992             } else if (sizeof(int) <= sizeof(PY_LONG_LONG)) {
32993                 __PYX_VERIFY_RETURN_INT_EXC(int, PY_LONG_LONG, PyLong_AsLongLong(x))
32994 #endif
32995             }
32996         }
32997         {
32998 #if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray)
32999             PyErr_SetString(PyExc_RuntimeError,
33000                             "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers");
33001 #else
33002             int val;
33003             PyObject *v = __Pyx_PyNumber_IntOrLong(x);
33004  #if PY_MAJOR_VERSION < 3
33005             if (likely(v) && !PyLong_Check(v)) {
33006                 PyObject *tmp = v;
33007                 v = PyNumber_Long(tmp);
33008                 Py_DECREF(tmp);
33009             }
33010  #endif
33011             if (likely(v)) {
33012                 int one = 1; int is_little = (int)*(unsigned char *)&one;
33013                 unsigned char *bytes = (unsigned char *)&val;
33014                 int ret = _PyLong_AsByteArray((PyLongObject *)v,
33015                                               bytes, sizeof(val),
33016                                               is_little, !is_unsigned);
33017                 Py_DECREF(v);
33018                 if (likely(!ret))
33019                     return val;
33020             }
33021 #endif
33022             return (int) -1;
33023         }
33024     } else {
33025         int val;
33026         PyObject *tmp = __Pyx_PyNumber_IntOrLong(x);
33027         if (!tmp) return (int) -1;
33028         val = __Pyx_PyInt_As_int(tmp);
33029         Py_DECREF(tmp);
33030         return val;
33031     }
33032 raise_overflow:
33033     PyErr_SetString(PyExc_OverflowError,
33034         "value too large to convert to int");
33035     return (int) -1;
33036 raise_neg_overflow:
33037     PyErr_SetString(PyExc_OverflowError,
33038         "can't convert negative value to int");
33039     return (int) -1;
33040 }
33041 
33042 /* TypeInfoToFormat */
__Pyx_TypeInfoToFormat(__Pyx_TypeInfo * type)33043   static struct __pyx_typeinfo_string __Pyx_TypeInfoToFormat(__Pyx_TypeInfo *type) {
33044     struct __pyx_typeinfo_string result = { {0} };
33045     char *buf = (char *) result.string;
33046     size_t size = type->size;
33047     switch (type->typegroup) {
33048         case 'H':
33049             *buf = 'c';
33050             break;
33051         case 'I':
33052         case 'U':
33053             if (size == 1)
33054                 *buf = (type->is_unsigned) ? 'B' : 'b';
33055             else if (size == 2)
33056                 *buf = (type->is_unsigned) ? 'H' : 'h';
33057             else if (size == 4)
33058                 *buf = (type->is_unsigned) ? 'I' : 'i';
33059             else if (size == 8)
33060                 *buf = (type->is_unsigned) ? 'Q' : 'q';
33061             break;
33062         case 'P':
33063             *buf = 'P';
33064             break;
33065         case 'C':
33066          {
33067             __Pyx_TypeInfo complex_type = *type;
33068             complex_type.typegroup = 'R';
33069             complex_type.size /= 2;
33070             *buf++ = 'Z';
33071             *buf = __Pyx_TypeInfoToFormat(&complex_type).string[0];
33072             break;
33073          }
33074         case 'R':
33075             if (size == 4)
33076                 *buf = 'f';
33077             else if (size == 8)
33078                 *buf = 'd';
33079             else
33080                 *buf = 'g';
33081             break;
33082     }
33083     return result;
33084 }
33085 
33086 /* CIntFromPy */
__Pyx_PyInt_As_unsigned_int(PyObject * x)33087   static CYTHON_INLINE unsigned int __Pyx_PyInt_As_unsigned_int(PyObject *x) {
33088 #ifdef __Pyx_HAS_GCC_DIAGNOSTIC
33089 #pragma GCC diagnostic push
33090 #pragma GCC diagnostic ignored "-Wconversion"
33091 #endif
33092     const unsigned int neg_one = (unsigned int) -1, const_zero = (unsigned int) 0;
33093 #ifdef __Pyx_HAS_GCC_DIAGNOSTIC
33094 #pragma GCC diagnostic pop
33095 #endif
33096     const int is_unsigned = neg_one > const_zero;
33097 #if PY_MAJOR_VERSION < 3
33098     if (likely(PyInt_Check(x))) {
33099         if (sizeof(unsigned int) < sizeof(long)) {
33100             __PYX_VERIFY_RETURN_INT(unsigned int, long, PyInt_AS_LONG(x))
33101         } else {
33102             long val = PyInt_AS_LONG(x);
33103             if (is_unsigned && unlikely(val < 0)) {
33104                 goto raise_neg_overflow;
33105             }
33106             return (unsigned int) val;
33107         }
33108     } else
33109 #endif
33110     if (likely(PyLong_Check(x))) {
33111         if (is_unsigned) {
33112 #if CYTHON_USE_PYLONG_INTERNALS
33113             const digit* digits = ((PyLongObject*)x)->ob_digit;
33114             switch (Py_SIZE(x)) {
33115                 case  0: return (unsigned int) 0;
33116                 case  1: __PYX_VERIFY_RETURN_INT(unsigned int, digit, digits[0])
33117                 case 2:
33118                     if (8 * sizeof(unsigned int) > 1 * PyLong_SHIFT) {
33119                         if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
33120                             __PYX_VERIFY_RETURN_INT(unsigned int, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
33121                         } else if (8 * sizeof(unsigned int) >= 2 * PyLong_SHIFT) {
33122                             return (unsigned int) (((((unsigned int)digits[1]) << PyLong_SHIFT) | (unsigned int)digits[0]));
33123                         }
33124                     }
33125                     break;
33126                 case 3:
33127                     if (8 * sizeof(unsigned int) > 2 * PyLong_SHIFT) {
33128                         if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
33129                             __PYX_VERIFY_RETURN_INT(unsigned int, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
33130                         } else if (8 * sizeof(unsigned int) >= 3 * PyLong_SHIFT) {
33131                             return (unsigned int) (((((((unsigned int)digits[2]) << PyLong_SHIFT) | (unsigned int)digits[1]) << PyLong_SHIFT) | (unsigned int)digits[0]));
33132                         }
33133                     }
33134                     break;
33135                 case 4:
33136                     if (8 * sizeof(unsigned int) > 3 * PyLong_SHIFT) {
33137                         if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
33138                             __PYX_VERIFY_RETURN_INT(unsigned 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])))
33139                         } else if (8 * sizeof(unsigned int) >= 4 * PyLong_SHIFT) {
33140                             return (unsigned int) (((((((((unsigned int)digits[3]) << PyLong_SHIFT) | (unsigned int)digits[2]) << PyLong_SHIFT) | (unsigned int)digits[1]) << PyLong_SHIFT) | (unsigned int)digits[0]));
33141                         }
33142                     }
33143                     break;
33144             }
33145 #endif
33146 #if CYTHON_COMPILING_IN_CPYTHON
33147             if (unlikely(Py_SIZE(x) < 0)) {
33148                 goto raise_neg_overflow;
33149             }
33150 #else
33151             {
33152                 int result = PyObject_RichCompareBool(x, Py_False, Py_LT);
33153                 if (unlikely(result < 0))
33154                     return (unsigned int) -1;
33155                 if (unlikely(result == 1))
33156                     goto raise_neg_overflow;
33157             }
33158 #endif
33159             if (sizeof(unsigned int) <= sizeof(unsigned long)) {
33160                 __PYX_VERIFY_RETURN_INT_EXC(unsigned int, unsigned long, PyLong_AsUnsignedLong(x))
33161 #ifdef HAVE_LONG_LONG
33162             } else if (sizeof(unsigned int) <= sizeof(unsigned PY_LONG_LONG)) {
33163                 __PYX_VERIFY_RETURN_INT_EXC(unsigned int, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x))
33164 #endif
33165             }
33166         } else {
33167 #if CYTHON_USE_PYLONG_INTERNALS
33168             const digit* digits = ((PyLongObject*)x)->ob_digit;
33169             switch (Py_SIZE(x)) {
33170                 case  0: return (unsigned int) 0;
33171                 case -1: __PYX_VERIFY_RETURN_INT(unsigned int, sdigit, (sdigit) (-(sdigit)digits[0]))
33172                 case  1: __PYX_VERIFY_RETURN_INT(unsigned int,  digit, +digits[0])
33173                 case -2:
33174                     if (8 * sizeof(unsigned int) - 1 > 1 * PyLong_SHIFT) {
33175                         if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
33176                             __PYX_VERIFY_RETURN_INT(unsigned int, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
33177                         } else if (8 * sizeof(unsigned int) - 1 > 2 * PyLong_SHIFT) {
33178                             return (unsigned int) (((unsigned int)-1)*(((((unsigned int)digits[1]) << PyLong_SHIFT) | (unsigned int)digits[0])));
33179                         }
33180                     }
33181                     break;
33182                 case 2:
33183                     if (8 * sizeof(unsigned int) > 1 * PyLong_SHIFT) {
33184                         if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
33185                             __PYX_VERIFY_RETURN_INT(unsigned int, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
33186                         } else if (8 * sizeof(unsigned int) - 1 > 2 * PyLong_SHIFT) {
33187                             return (unsigned int) ((((((unsigned int)digits[1]) << PyLong_SHIFT) | (unsigned int)digits[0])));
33188                         }
33189                     }
33190                     break;
33191                 case -3:
33192                     if (8 * sizeof(unsigned int) - 1 > 2 * PyLong_SHIFT) {
33193                         if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
33194                             __PYX_VERIFY_RETURN_INT(unsigned int, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
33195                         } else if (8 * sizeof(unsigned int) - 1 > 3 * PyLong_SHIFT) {
33196                             return (unsigned int) (((unsigned int)-1)*(((((((unsigned int)digits[2]) << PyLong_SHIFT) | (unsigned int)digits[1]) << PyLong_SHIFT) | (unsigned int)digits[0])));
33197                         }
33198                     }
33199                     break;
33200                 case 3:
33201                     if (8 * sizeof(unsigned int) > 2 * PyLong_SHIFT) {
33202                         if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
33203                             __PYX_VERIFY_RETURN_INT(unsigned int, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
33204                         } else if (8 * sizeof(unsigned int) - 1 > 3 * PyLong_SHIFT) {
33205                             return (unsigned int) ((((((((unsigned int)digits[2]) << PyLong_SHIFT) | (unsigned int)digits[1]) << PyLong_SHIFT) | (unsigned int)digits[0])));
33206                         }
33207                     }
33208                     break;
33209                 case -4:
33210                     if (8 * sizeof(unsigned int) - 1 > 3 * PyLong_SHIFT) {
33211                         if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
33212                             __PYX_VERIFY_RETURN_INT(unsigned 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])))
33213                         } else if (8 * sizeof(unsigned int) - 1 > 4 * PyLong_SHIFT) {
33214                             return (unsigned int) (((unsigned int)-1)*(((((((((unsigned int)digits[3]) << PyLong_SHIFT) | (unsigned int)digits[2]) << PyLong_SHIFT) | (unsigned int)digits[1]) << PyLong_SHIFT) | (unsigned int)digits[0])));
33215                         }
33216                     }
33217                     break;
33218                 case 4:
33219                     if (8 * sizeof(unsigned int) > 3 * PyLong_SHIFT) {
33220                         if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
33221                             __PYX_VERIFY_RETURN_INT(unsigned 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])))
33222                         } else if (8 * sizeof(unsigned int) - 1 > 4 * PyLong_SHIFT) {
33223                             return (unsigned int) ((((((((((unsigned int)digits[3]) << PyLong_SHIFT) | (unsigned int)digits[2]) << PyLong_SHIFT) | (unsigned int)digits[1]) << PyLong_SHIFT) | (unsigned int)digits[0])));
33224                         }
33225                     }
33226                     break;
33227             }
33228 #endif
33229             if (sizeof(unsigned int) <= sizeof(long)) {
33230                 __PYX_VERIFY_RETURN_INT_EXC(unsigned int, long, PyLong_AsLong(x))
33231 #ifdef HAVE_LONG_LONG
33232             } else if (sizeof(unsigned int) <= sizeof(PY_LONG_LONG)) {
33233                 __PYX_VERIFY_RETURN_INT_EXC(unsigned int, PY_LONG_LONG, PyLong_AsLongLong(x))
33234 #endif
33235             }
33236         }
33237         {
33238 #if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray)
33239             PyErr_SetString(PyExc_RuntimeError,
33240                             "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers");
33241 #else
33242             unsigned int val;
33243             PyObject *v = __Pyx_PyNumber_IntOrLong(x);
33244  #if PY_MAJOR_VERSION < 3
33245             if (likely(v) && !PyLong_Check(v)) {
33246                 PyObject *tmp = v;
33247                 v = PyNumber_Long(tmp);
33248                 Py_DECREF(tmp);
33249             }
33250  #endif
33251             if (likely(v)) {
33252                 int one = 1; int is_little = (int)*(unsigned char *)&one;
33253                 unsigned char *bytes = (unsigned char *)&val;
33254                 int ret = _PyLong_AsByteArray((PyLongObject *)v,
33255                                               bytes, sizeof(val),
33256                                               is_little, !is_unsigned);
33257                 Py_DECREF(v);
33258                 if (likely(!ret))
33259                     return val;
33260             }
33261 #endif
33262             return (unsigned int) -1;
33263         }
33264     } else {
33265         unsigned int val;
33266         PyObject *tmp = __Pyx_PyNumber_IntOrLong(x);
33267         if (!tmp) return (unsigned int) -1;
33268         val = __Pyx_PyInt_As_unsigned_int(tmp);
33269         Py_DECREF(tmp);
33270         return val;
33271     }
33272 raise_overflow:
33273     PyErr_SetString(PyExc_OverflowError,
33274         "value too large to convert to unsigned int");
33275     return (unsigned int) -1;
33276 raise_neg_overflow:
33277     PyErr_SetString(PyExc_OverflowError,
33278         "can't convert negative value to unsigned int");
33279     return (unsigned int) -1;
33280 }
33281 
33282 /* CIntToPy */
__Pyx_PyInt_From_int(int value)33283   static CYTHON_INLINE PyObject* __Pyx_PyInt_From_int(int value) {
33284 #ifdef __Pyx_HAS_GCC_DIAGNOSTIC
33285 #pragma GCC diagnostic push
33286 #pragma GCC diagnostic ignored "-Wconversion"
33287 #endif
33288     const int neg_one = (int) -1, const_zero = (int) 0;
33289 #ifdef __Pyx_HAS_GCC_DIAGNOSTIC
33290 #pragma GCC diagnostic pop
33291 #endif
33292     const int is_unsigned = neg_one > const_zero;
33293     if (is_unsigned) {
33294         if (sizeof(int) < sizeof(long)) {
33295             return PyInt_FromLong((long) value);
33296         } else if (sizeof(int) <= sizeof(unsigned long)) {
33297             return PyLong_FromUnsignedLong((unsigned long) value);
33298 #ifdef HAVE_LONG_LONG
33299         } else if (sizeof(int) <= sizeof(unsigned PY_LONG_LONG)) {
33300             return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value);
33301 #endif
33302         }
33303     } else {
33304         if (sizeof(int) <= sizeof(long)) {
33305             return PyInt_FromLong((long) value);
33306 #ifdef HAVE_LONG_LONG
33307         } else if (sizeof(int) <= sizeof(PY_LONG_LONG)) {
33308             return PyLong_FromLongLong((PY_LONG_LONG) value);
33309 #endif
33310         }
33311     }
33312     {
33313         int one = 1; int little = (int)*(unsigned char *)&one;
33314         unsigned char *bytes = (unsigned char *)&value;
33315         return _PyLong_FromByteArray(bytes, sizeof(int),
33316                                      little, !is_unsigned);
33317     }
33318 }
33319 
33320 /* CIntFromPy */
__Pyx_PyInt_As_size_t(PyObject * x)33321   static CYTHON_INLINE size_t __Pyx_PyInt_As_size_t(PyObject *x) {
33322 #ifdef __Pyx_HAS_GCC_DIAGNOSTIC
33323 #pragma GCC diagnostic push
33324 #pragma GCC diagnostic ignored "-Wconversion"
33325 #endif
33326     const size_t neg_one = (size_t) -1, const_zero = (size_t) 0;
33327 #ifdef __Pyx_HAS_GCC_DIAGNOSTIC
33328 #pragma GCC diagnostic pop
33329 #endif
33330     const int is_unsigned = neg_one > const_zero;
33331 #if PY_MAJOR_VERSION < 3
33332     if (likely(PyInt_Check(x))) {
33333         if (sizeof(size_t) < sizeof(long)) {
33334             __PYX_VERIFY_RETURN_INT(size_t, long, PyInt_AS_LONG(x))
33335         } else {
33336             long val = PyInt_AS_LONG(x);
33337             if (is_unsigned && unlikely(val < 0)) {
33338                 goto raise_neg_overflow;
33339             }
33340             return (size_t) val;
33341         }
33342     } else
33343 #endif
33344     if (likely(PyLong_Check(x))) {
33345         if (is_unsigned) {
33346 #if CYTHON_USE_PYLONG_INTERNALS
33347             const digit* digits = ((PyLongObject*)x)->ob_digit;
33348             switch (Py_SIZE(x)) {
33349                 case  0: return (size_t) 0;
33350                 case  1: __PYX_VERIFY_RETURN_INT(size_t, digit, digits[0])
33351                 case 2:
33352                     if (8 * sizeof(size_t) > 1 * PyLong_SHIFT) {
33353                         if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
33354                             __PYX_VERIFY_RETURN_INT(size_t, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
33355                         } else if (8 * sizeof(size_t) >= 2 * PyLong_SHIFT) {
33356                             return (size_t) (((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
33357                         }
33358                     }
33359                     break;
33360                 case 3:
33361                     if (8 * sizeof(size_t) > 2 * PyLong_SHIFT) {
33362                         if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
33363                             __PYX_VERIFY_RETURN_INT(size_t, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
33364                         } else if (8 * sizeof(size_t) >= 3 * PyLong_SHIFT) {
33365                             return (size_t) (((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
33366                         }
33367                     }
33368                     break;
33369                 case 4:
33370                     if (8 * sizeof(size_t) > 3 * PyLong_SHIFT) {
33371                         if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
33372                             __PYX_VERIFY_RETURN_INT(size_t, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
33373                         } else if (8 * sizeof(size_t) >= 4 * PyLong_SHIFT) {
33374                             return (size_t) (((((((((size_t)digits[3]) << PyLong_SHIFT) | (size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
33375                         }
33376                     }
33377                     break;
33378             }
33379 #endif
33380 #if CYTHON_COMPILING_IN_CPYTHON
33381             if (unlikely(Py_SIZE(x) < 0)) {
33382                 goto raise_neg_overflow;
33383             }
33384 #else
33385             {
33386                 int result = PyObject_RichCompareBool(x, Py_False, Py_LT);
33387                 if (unlikely(result < 0))
33388                     return (size_t) -1;
33389                 if (unlikely(result == 1))
33390                     goto raise_neg_overflow;
33391             }
33392 #endif
33393             if (sizeof(size_t) <= sizeof(unsigned long)) {
33394                 __PYX_VERIFY_RETURN_INT_EXC(size_t, unsigned long, PyLong_AsUnsignedLong(x))
33395 #ifdef HAVE_LONG_LONG
33396             } else if (sizeof(size_t) <= sizeof(unsigned PY_LONG_LONG)) {
33397                 __PYX_VERIFY_RETURN_INT_EXC(size_t, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x))
33398 #endif
33399             }
33400         } else {
33401 #if CYTHON_USE_PYLONG_INTERNALS
33402             const digit* digits = ((PyLongObject*)x)->ob_digit;
33403             switch (Py_SIZE(x)) {
33404                 case  0: return (size_t) 0;
33405                 case -1: __PYX_VERIFY_RETURN_INT(size_t, sdigit, (sdigit) (-(sdigit)digits[0]))
33406                 case  1: __PYX_VERIFY_RETURN_INT(size_t,  digit, +digits[0])
33407                 case -2:
33408                     if (8 * sizeof(size_t) - 1 > 1 * PyLong_SHIFT) {
33409                         if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
33410                             __PYX_VERIFY_RETURN_INT(size_t, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
33411                         } else if (8 * sizeof(size_t) - 1 > 2 * PyLong_SHIFT) {
33412                             return (size_t) (((size_t)-1)*(((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])));
33413                         }
33414                     }
33415                     break;
33416                 case 2:
33417                     if (8 * sizeof(size_t) > 1 * PyLong_SHIFT) {
33418                         if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
33419                             __PYX_VERIFY_RETURN_INT(size_t, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
33420                         } else if (8 * sizeof(size_t) - 1 > 2 * PyLong_SHIFT) {
33421                             return (size_t) ((((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])));
33422                         }
33423                     }
33424                     break;
33425                 case -3:
33426                     if (8 * sizeof(size_t) - 1 > 2 * PyLong_SHIFT) {
33427                         if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
33428                             __PYX_VERIFY_RETURN_INT(size_t, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
33429                         } else if (8 * sizeof(size_t) - 1 > 3 * PyLong_SHIFT) {
33430                             return (size_t) (((size_t)-1)*(((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])));
33431                         }
33432                     }
33433                     break;
33434                 case 3:
33435                     if (8 * sizeof(size_t) > 2 * PyLong_SHIFT) {
33436                         if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
33437                             __PYX_VERIFY_RETURN_INT(size_t, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
33438                         } else if (8 * sizeof(size_t) - 1 > 3 * PyLong_SHIFT) {
33439                             return (size_t) ((((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])));
33440                         }
33441                     }
33442                     break;
33443                 case -4:
33444                     if (8 * sizeof(size_t) - 1 > 3 * PyLong_SHIFT) {
33445                         if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
33446                             __PYX_VERIFY_RETURN_INT(size_t, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
33447                         } else if (8 * sizeof(size_t) - 1 > 4 * PyLong_SHIFT) {
33448                             return (size_t) (((size_t)-1)*(((((((((size_t)digits[3]) << PyLong_SHIFT) | (size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])));
33449                         }
33450                     }
33451                     break;
33452                 case 4:
33453                     if (8 * sizeof(size_t) > 3 * PyLong_SHIFT) {
33454                         if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
33455                             __PYX_VERIFY_RETURN_INT(size_t, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
33456                         } else if (8 * sizeof(size_t) - 1 > 4 * PyLong_SHIFT) {
33457                             return (size_t) ((((((((((size_t)digits[3]) << PyLong_SHIFT) | (size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])));
33458                         }
33459                     }
33460                     break;
33461             }
33462 #endif
33463             if (sizeof(size_t) <= sizeof(long)) {
33464                 __PYX_VERIFY_RETURN_INT_EXC(size_t, long, PyLong_AsLong(x))
33465 #ifdef HAVE_LONG_LONG
33466             } else if (sizeof(size_t) <= sizeof(PY_LONG_LONG)) {
33467                 __PYX_VERIFY_RETURN_INT_EXC(size_t, PY_LONG_LONG, PyLong_AsLongLong(x))
33468 #endif
33469             }
33470         }
33471         {
33472 #if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray)
33473             PyErr_SetString(PyExc_RuntimeError,
33474                             "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers");
33475 #else
33476             size_t val;
33477             PyObject *v = __Pyx_PyNumber_IntOrLong(x);
33478  #if PY_MAJOR_VERSION < 3
33479             if (likely(v) && !PyLong_Check(v)) {
33480                 PyObject *tmp = v;
33481                 v = PyNumber_Long(tmp);
33482                 Py_DECREF(tmp);
33483             }
33484  #endif
33485             if (likely(v)) {
33486                 int one = 1; int is_little = (int)*(unsigned char *)&one;
33487                 unsigned char *bytes = (unsigned char *)&val;
33488                 int ret = _PyLong_AsByteArray((PyLongObject *)v,
33489                                               bytes, sizeof(val),
33490                                               is_little, !is_unsigned);
33491                 Py_DECREF(v);
33492                 if (likely(!ret))
33493                     return val;
33494             }
33495 #endif
33496             return (size_t) -1;
33497         }
33498     } else {
33499         size_t val;
33500         PyObject *tmp = __Pyx_PyNumber_IntOrLong(x);
33501         if (!tmp) return (size_t) -1;
33502         val = __Pyx_PyInt_As_size_t(tmp);
33503         Py_DECREF(tmp);
33504         return val;
33505     }
33506 raise_overflow:
33507     PyErr_SetString(PyExc_OverflowError,
33508         "value too large to convert to size_t");
33509     return (size_t) -1;
33510 raise_neg_overflow:
33511     PyErr_SetString(PyExc_OverflowError,
33512         "can't convert negative value to size_t");
33513     return (size_t) -1;
33514 }
33515 
33516 /* CIntToPy */
__Pyx_PyInt_From_long(long value)33517   static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value) {
33518 #ifdef __Pyx_HAS_GCC_DIAGNOSTIC
33519 #pragma GCC diagnostic push
33520 #pragma GCC diagnostic ignored "-Wconversion"
33521 #endif
33522     const long neg_one = (long) -1, const_zero = (long) 0;
33523 #ifdef __Pyx_HAS_GCC_DIAGNOSTIC
33524 #pragma GCC diagnostic pop
33525 #endif
33526     const int is_unsigned = neg_one > const_zero;
33527     if (is_unsigned) {
33528         if (sizeof(long) < sizeof(long)) {
33529             return PyInt_FromLong((long) value);
33530         } else if (sizeof(long) <= sizeof(unsigned long)) {
33531             return PyLong_FromUnsignedLong((unsigned long) value);
33532 #ifdef HAVE_LONG_LONG
33533         } else if (sizeof(long) <= sizeof(unsigned PY_LONG_LONG)) {
33534             return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value);
33535 #endif
33536         }
33537     } else {
33538         if (sizeof(long) <= sizeof(long)) {
33539             return PyInt_FromLong((long) value);
33540 #ifdef HAVE_LONG_LONG
33541         } else if (sizeof(long) <= sizeof(PY_LONG_LONG)) {
33542             return PyLong_FromLongLong((PY_LONG_LONG) value);
33543 #endif
33544         }
33545     }
33546     {
33547         int one = 1; int little = (int)*(unsigned char *)&one;
33548         unsigned char *bytes = (unsigned char *)&value;
33549         return _PyLong_FromByteArray(bytes, sizeof(long),
33550                                      little, !is_unsigned);
33551     }
33552 }
33553 
33554 /* CIntToPy */
__Pyx_PyInt_From_unsigned_int(unsigned int value)33555   static CYTHON_INLINE PyObject* __Pyx_PyInt_From_unsigned_int(unsigned int value) {
33556 #ifdef __Pyx_HAS_GCC_DIAGNOSTIC
33557 #pragma GCC diagnostic push
33558 #pragma GCC diagnostic ignored "-Wconversion"
33559 #endif
33560     const unsigned int neg_one = (unsigned int) -1, const_zero = (unsigned int) 0;
33561 #ifdef __Pyx_HAS_GCC_DIAGNOSTIC
33562 #pragma GCC diagnostic pop
33563 #endif
33564     const int is_unsigned = neg_one > const_zero;
33565     if (is_unsigned) {
33566         if (sizeof(unsigned int) < sizeof(long)) {
33567             return PyInt_FromLong((long) value);
33568         } else if (sizeof(unsigned int) <= sizeof(unsigned long)) {
33569             return PyLong_FromUnsignedLong((unsigned long) value);
33570 #ifdef HAVE_LONG_LONG
33571         } else if (sizeof(unsigned int) <= sizeof(unsigned PY_LONG_LONG)) {
33572             return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value);
33573 #endif
33574         }
33575     } else {
33576         if (sizeof(unsigned int) <= sizeof(long)) {
33577             return PyInt_FromLong((long) value);
33578 #ifdef HAVE_LONG_LONG
33579         } else if (sizeof(unsigned int) <= sizeof(PY_LONG_LONG)) {
33580             return PyLong_FromLongLong((PY_LONG_LONG) value);
33581 #endif
33582         }
33583     }
33584     {
33585         int one = 1; int little = (int)*(unsigned char *)&one;
33586         unsigned char *bytes = (unsigned char *)&value;
33587         return _PyLong_FromByteArray(bytes, sizeof(unsigned int),
33588                                      little, !is_unsigned);
33589     }
33590 }
33591 
33592 /* CIntFromPy */
__Pyx_PyInt_As_long(PyObject * x)33593   static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *x) {
33594 #ifdef __Pyx_HAS_GCC_DIAGNOSTIC
33595 #pragma GCC diagnostic push
33596 #pragma GCC diagnostic ignored "-Wconversion"
33597 #endif
33598     const long neg_one = (long) -1, const_zero = (long) 0;
33599 #ifdef __Pyx_HAS_GCC_DIAGNOSTIC
33600 #pragma GCC diagnostic pop
33601 #endif
33602     const int is_unsigned = neg_one > const_zero;
33603 #if PY_MAJOR_VERSION < 3
33604     if (likely(PyInt_Check(x))) {
33605         if (sizeof(long) < sizeof(long)) {
33606             __PYX_VERIFY_RETURN_INT(long, long, PyInt_AS_LONG(x))
33607         } else {
33608             long val = PyInt_AS_LONG(x);
33609             if (is_unsigned && unlikely(val < 0)) {
33610                 goto raise_neg_overflow;
33611             }
33612             return (long) val;
33613         }
33614     } else
33615 #endif
33616     if (likely(PyLong_Check(x))) {
33617         if (is_unsigned) {
33618 #if CYTHON_USE_PYLONG_INTERNALS
33619             const digit* digits = ((PyLongObject*)x)->ob_digit;
33620             switch (Py_SIZE(x)) {
33621                 case  0: return (long) 0;
33622                 case  1: __PYX_VERIFY_RETURN_INT(long, digit, digits[0])
33623                 case 2:
33624                     if (8 * sizeof(long) > 1 * PyLong_SHIFT) {
33625                         if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
33626                             __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
33627                         } else if (8 * sizeof(long) >= 2 * PyLong_SHIFT) {
33628                             return (long) (((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0]));
33629                         }
33630                     }
33631                     break;
33632                 case 3:
33633                     if (8 * sizeof(long) > 2 * PyLong_SHIFT) {
33634                         if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
33635                             __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
33636                         } else if (8 * sizeof(long) >= 3 * PyLong_SHIFT) {
33637                             return (long) (((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]));
33638                         }
33639                     }
33640                     break;
33641                 case 4:
33642                     if (8 * sizeof(long) > 3 * PyLong_SHIFT) {
33643                         if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
33644                             __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])))
33645                         } else if (8 * sizeof(long) >= 4 * PyLong_SHIFT) {
33646                             return (long) (((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]));
33647                         }
33648                     }
33649                     break;
33650             }
33651 #endif
33652 #if CYTHON_COMPILING_IN_CPYTHON
33653             if (unlikely(Py_SIZE(x) < 0)) {
33654                 goto raise_neg_overflow;
33655             }
33656 #else
33657             {
33658                 int result = PyObject_RichCompareBool(x, Py_False, Py_LT);
33659                 if (unlikely(result < 0))
33660                     return (long) -1;
33661                 if (unlikely(result == 1))
33662                     goto raise_neg_overflow;
33663             }
33664 #endif
33665             if (sizeof(long) <= sizeof(unsigned long)) {
33666                 __PYX_VERIFY_RETURN_INT_EXC(long, unsigned long, PyLong_AsUnsignedLong(x))
33667 #ifdef HAVE_LONG_LONG
33668             } else if (sizeof(long) <= sizeof(unsigned PY_LONG_LONG)) {
33669                 __PYX_VERIFY_RETURN_INT_EXC(long, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x))
33670 #endif
33671             }
33672         } else {
33673 #if CYTHON_USE_PYLONG_INTERNALS
33674             const digit* digits = ((PyLongObject*)x)->ob_digit;
33675             switch (Py_SIZE(x)) {
33676                 case  0: return (long) 0;
33677                 case -1: __PYX_VERIFY_RETURN_INT(long, sdigit, (sdigit) (-(sdigit)digits[0]))
33678                 case  1: __PYX_VERIFY_RETURN_INT(long,  digit, +digits[0])
33679                 case -2:
33680                     if (8 * sizeof(long) - 1 > 1 * PyLong_SHIFT) {
33681                         if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
33682                             __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
33683                         } else if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
33684                             return (long) (((long)-1)*(((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
33685                         }
33686                     }
33687                     break;
33688                 case 2:
33689                     if (8 * sizeof(long) > 1 * PyLong_SHIFT) {
33690                         if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
33691                             __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
33692                         } else if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
33693                             return (long) ((((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
33694                         }
33695                     }
33696                     break;
33697                 case -3:
33698                     if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
33699                         if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
33700                             __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
33701                         } else if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
33702                             return (long) (((long)-1)*(((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
33703                         }
33704                     }
33705                     break;
33706                 case 3:
33707                     if (8 * sizeof(long) > 2 * PyLong_SHIFT) {
33708                         if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
33709                             __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
33710                         } else if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
33711                             return (long) ((((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
33712                         }
33713                     }
33714                     break;
33715                 case -4:
33716                     if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
33717                         if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
33718                             __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])))
33719                         } else if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) {
33720                             return (long) (((long)-1)*(((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
33721                         }
33722                     }
33723                     break;
33724                 case 4:
33725                     if (8 * sizeof(long) > 3 * PyLong_SHIFT) {
33726                         if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
33727                             __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])))
33728                         } else if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) {
33729                             return (long) ((((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
33730                         }
33731                     }
33732                     break;
33733             }
33734 #endif
33735             if (sizeof(long) <= sizeof(long)) {
33736                 __PYX_VERIFY_RETURN_INT_EXC(long, long, PyLong_AsLong(x))
33737 #ifdef HAVE_LONG_LONG
33738             } else if (sizeof(long) <= sizeof(PY_LONG_LONG)) {
33739                 __PYX_VERIFY_RETURN_INT_EXC(long, PY_LONG_LONG, PyLong_AsLongLong(x))
33740 #endif
33741             }
33742         }
33743         {
33744 #if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray)
33745             PyErr_SetString(PyExc_RuntimeError,
33746                             "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers");
33747 #else
33748             long val;
33749             PyObject *v = __Pyx_PyNumber_IntOrLong(x);
33750  #if PY_MAJOR_VERSION < 3
33751             if (likely(v) && !PyLong_Check(v)) {
33752                 PyObject *tmp = v;
33753                 v = PyNumber_Long(tmp);
33754                 Py_DECREF(tmp);
33755             }
33756  #endif
33757             if (likely(v)) {
33758                 int one = 1; int is_little = (int)*(unsigned char *)&one;
33759                 unsigned char *bytes = (unsigned char *)&val;
33760                 int ret = _PyLong_AsByteArray((PyLongObject *)v,
33761                                               bytes, sizeof(val),
33762                                               is_little, !is_unsigned);
33763                 Py_DECREF(v);
33764                 if (likely(!ret))
33765                     return val;
33766             }
33767 #endif
33768             return (long) -1;
33769         }
33770     } else {
33771         long val;
33772         PyObject *tmp = __Pyx_PyNumber_IntOrLong(x);
33773         if (!tmp) return (long) -1;
33774         val = __Pyx_PyInt_As_long(tmp);
33775         Py_DECREF(tmp);
33776         return val;
33777     }
33778 raise_overflow:
33779     PyErr_SetString(PyExc_OverflowError,
33780         "value too large to convert to long");
33781     return (long) -1;
33782 raise_neg_overflow:
33783     PyErr_SetString(PyExc_OverflowError,
33784         "can't convert negative value to long");
33785     return (long) -1;
33786 }
33787 
33788 /* CIntFromPy */
__Pyx_PyInt_As_char(PyObject * x)33789   static CYTHON_INLINE char __Pyx_PyInt_As_char(PyObject *x) {
33790 #ifdef __Pyx_HAS_GCC_DIAGNOSTIC
33791 #pragma GCC diagnostic push
33792 #pragma GCC diagnostic ignored "-Wconversion"
33793 #endif
33794     const char neg_one = (char) -1, const_zero = (char) 0;
33795 #ifdef __Pyx_HAS_GCC_DIAGNOSTIC
33796 #pragma GCC diagnostic pop
33797 #endif
33798     const int is_unsigned = neg_one > const_zero;
33799 #if PY_MAJOR_VERSION < 3
33800     if (likely(PyInt_Check(x))) {
33801         if (sizeof(char) < sizeof(long)) {
33802             __PYX_VERIFY_RETURN_INT(char, long, PyInt_AS_LONG(x))
33803         } else {
33804             long val = PyInt_AS_LONG(x);
33805             if (is_unsigned && unlikely(val < 0)) {
33806                 goto raise_neg_overflow;
33807             }
33808             return (char) val;
33809         }
33810     } else
33811 #endif
33812     if (likely(PyLong_Check(x))) {
33813         if (is_unsigned) {
33814 #if CYTHON_USE_PYLONG_INTERNALS
33815             const digit* digits = ((PyLongObject*)x)->ob_digit;
33816             switch (Py_SIZE(x)) {
33817                 case  0: return (char) 0;
33818                 case  1: __PYX_VERIFY_RETURN_INT(char, digit, digits[0])
33819                 case 2:
33820                     if (8 * sizeof(char) > 1 * PyLong_SHIFT) {
33821                         if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
33822                             __PYX_VERIFY_RETURN_INT(char, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
33823                         } else if (8 * sizeof(char) >= 2 * PyLong_SHIFT) {
33824                             return (char) (((((char)digits[1]) << PyLong_SHIFT) | (char)digits[0]));
33825                         }
33826                     }
33827                     break;
33828                 case 3:
33829                     if (8 * sizeof(char) > 2 * PyLong_SHIFT) {
33830                         if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
33831                             __PYX_VERIFY_RETURN_INT(char, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
33832                         } else if (8 * sizeof(char) >= 3 * PyLong_SHIFT) {
33833                             return (char) (((((((char)digits[2]) << PyLong_SHIFT) | (char)digits[1]) << PyLong_SHIFT) | (char)digits[0]));
33834                         }
33835                     }
33836                     break;
33837                 case 4:
33838                     if (8 * sizeof(char) > 3 * PyLong_SHIFT) {
33839                         if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
33840                             __PYX_VERIFY_RETURN_INT(char, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
33841                         } else if (8 * sizeof(char) >= 4 * PyLong_SHIFT) {
33842                             return (char) (((((((((char)digits[3]) << PyLong_SHIFT) | (char)digits[2]) << PyLong_SHIFT) | (char)digits[1]) << PyLong_SHIFT) | (char)digits[0]));
33843                         }
33844                     }
33845                     break;
33846             }
33847 #endif
33848 #if CYTHON_COMPILING_IN_CPYTHON
33849             if (unlikely(Py_SIZE(x) < 0)) {
33850                 goto raise_neg_overflow;
33851             }
33852 #else
33853             {
33854                 int result = PyObject_RichCompareBool(x, Py_False, Py_LT);
33855                 if (unlikely(result < 0))
33856                     return (char) -1;
33857                 if (unlikely(result == 1))
33858                     goto raise_neg_overflow;
33859             }
33860 #endif
33861             if (sizeof(char) <= sizeof(unsigned long)) {
33862                 __PYX_VERIFY_RETURN_INT_EXC(char, unsigned long, PyLong_AsUnsignedLong(x))
33863 #ifdef HAVE_LONG_LONG
33864             } else if (sizeof(char) <= sizeof(unsigned PY_LONG_LONG)) {
33865                 __PYX_VERIFY_RETURN_INT_EXC(char, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x))
33866 #endif
33867             }
33868         } else {
33869 #if CYTHON_USE_PYLONG_INTERNALS
33870             const digit* digits = ((PyLongObject*)x)->ob_digit;
33871             switch (Py_SIZE(x)) {
33872                 case  0: return (char) 0;
33873                 case -1: __PYX_VERIFY_RETURN_INT(char, sdigit, (sdigit) (-(sdigit)digits[0]))
33874                 case  1: __PYX_VERIFY_RETURN_INT(char,  digit, +digits[0])
33875                 case -2:
33876                     if (8 * sizeof(char) - 1 > 1 * PyLong_SHIFT) {
33877                         if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
33878                             __PYX_VERIFY_RETURN_INT(char, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
33879                         } else if (8 * sizeof(char) - 1 > 2 * PyLong_SHIFT) {
33880                             return (char) (((char)-1)*(((((char)digits[1]) << PyLong_SHIFT) | (char)digits[0])));
33881                         }
33882                     }
33883                     break;
33884                 case 2:
33885                     if (8 * sizeof(char) > 1 * PyLong_SHIFT) {
33886                         if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
33887                             __PYX_VERIFY_RETURN_INT(char, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
33888                         } else if (8 * sizeof(char) - 1 > 2 * PyLong_SHIFT) {
33889                             return (char) ((((((char)digits[1]) << PyLong_SHIFT) | (char)digits[0])));
33890                         }
33891                     }
33892                     break;
33893                 case -3:
33894                     if (8 * sizeof(char) - 1 > 2 * PyLong_SHIFT) {
33895                         if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
33896                             __PYX_VERIFY_RETURN_INT(char, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
33897                         } else if (8 * sizeof(char) - 1 > 3 * PyLong_SHIFT) {
33898                             return (char) (((char)-1)*(((((((char)digits[2]) << PyLong_SHIFT) | (char)digits[1]) << PyLong_SHIFT) | (char)digits[0])));
33899                         }
33900                     }
33901                     break;
33902                 case 3:
33903                     if (8 * sizeof(char) > 2 * PyLong_SHIFT) {
33904                         if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
33905                             __PYX_VERIFY_RETURN_INT(char, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
33906                         } else if (8 * sizeof(char) - 1 > 3 * PyLong_SHIFT) {
33907                             return (char) ((((((((char)digits[2]) << PyLong_SHIFT) | (char)digits[1]) << PyLong_SHIFT) | (char)digits[0])));
33908                         }
33909                     }
33910                     break;
33911                 case -4:
33912                     if (8 * sizeof(char) - 1 > 3 * PyLong_SHIFT) {
33913                         if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
33914                             __PYX_VERIFY_RETURN_INT(char, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
33915                         } else if (8 * sizeof(char) - 1 > 4 * PyLong_SHIFT) {
33916                             return (char) (((char)-1)*(((((((((char)digits[3]) << PyLong_SHIFT) | (char)digits[2]) << PyLong_SHIFT) | (char)digits[1]) << PyLong_SHIFT) | (char)digits[0])));
33917                         }
33918                     }
33919                     break;
33920                 case 4:
33921                     if (8 * sizeof(char) > 3 * PyLong_SHIFT) {
33922                         if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
33923                             __PYX_VERIFY_RETURN_INT(char, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
33924                         } else if (8 * sizeof(char) - 1 > 4 * PyLong_SHIFT) {
33925                             return (char) ((((((((((char)digits[3]) << PyLong_SHIFT) | (char)digits[2]) << PyLong_SHIFT) | (char)digits[1]) << PyLong_SHIFT) | (char)digits[0])));
33926                         }
33927                     }
33928                     break;
33929             }
33930 #endif
33931             if (sizeof(char) <= sizeof(long)) {
33932                 __PYX_VERIFY_RETURN_INT_EXC(char, long, PyLong_AsLong(x))
33933 #ifdef HAVE_LONG_LONG
33934             } else if (sizeof(char) <= sizeof(PY_LONG_LONG)) {
33935                 __PYX_VERIFY_RETURN_INT_EXC(char, PY_LONG_LONG, PyLong_AsLongLong(x))
33936 #endif
33937             }
33938         }
33939         {
33940 #if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray)
33941             PyErr_SetString(PyExc_RuntimeError,
33942                             "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers");
33943 #else
33944             char val;
33945             PyObject *v = __Pyx_PyNumber_IntOrLong(x);
33946  #if PY_MAJOR_VERSION < 3
33947             if (likely(v) && !PyLong_Check(v)) {
33948                 PyObject *tmp = v;
33949                 v = PyNumber_Long(tmp);
33950                 Py_DECREF(tmp);
33951             }
33952  #endif
33953             if (likely(v)) {
33954                 int one = 1; int is_little = (int)*(unsigned char *)&one;
33955                 unsigned char *bytes = (unsigned char *)&val;
33956                 int ret = _PyLong_AsByteArray((PyLongObject *)v,
33957                                               bytes, sizeof(val),
33958                                               is_little, !is_unsigned);
33959                 Py_DECREF(v);
33960                 if (likely(!ret))
33961                     return val;
33962             }
33963 #endif
33964             return (char) -1;
33965         }
33966     } else {
33967         char val;
33968         PyObject *tmp = __Pyx_PyNumber_IntOrLong(x);
33969         if (!tmp) return (char) -1;
33970         val = __Pyx_PyInt_As_char(tmp);
33971         Py_DECREF(tmp);
33972         return val;
33973     }
33974 raise_overflow:
33975     PyErr_SetString(PyExc_OverflowError,
33976         "value too large to convert to char");
33977     return (char) -1;
33978 raise_neg_overflow:
33979     PyErr_SetString(PyExc_OverflowError,
33980         "can't convert negative value to char");
33981     return (char) -1;
33982 }
33983 
33984 /* ObjectToMemviewSlice */
__Pyx_PyObject_to_MemoryviewSlice_dc___pyx_t_double_complex(PyObject * obj,int writable_flag)33985   static CYTHON_INLINE __Pyx_memviewslice __Pyx_PyObject_to_MemoryviewSlice_dc___pyx_t_double_complex(PyObject *obj, int writable_flag) {
33986     __Pyx_memviewslice result = { 0, 0, { 0 }, { 0 }, { 0 } };
33987     __Pyx_BufFmt_StackElem stack[1];
33988     int axes_specs[] = { (__Pyx_MEMVIEW_DIRECT | __Pyx_MEMVIEW_CONTIG) };
33989     int retcode;
33990     if (obj == Py_None) {
33991         result.memview = (struct __pyx_memoryview_obj *) Py_None;
33992         return result;
33993     }
33994     retcode = __Pyx_ValidateAndInit_memviewslice(axes_specs, __Pyx_IS_C_CONTIG,
33995                                                  (PyBUF_C_CONTIGUOUS | PyBUF_FORMAT) | writable_flag, 1,
33996                                                  &__Pyx_TypeInfo___pyx_t_double_complex, stack,
33997                                                  &result, obj);
33998     if (unlikely(retcode == -1))
33999         goto __pyx_fail;
34000     return result;
34001 __pyx_fail:
34002     result.memview = NULL;
34003     result.data = NULL;
34004     return result;
34005 }
34006 
34007 /* ObjectToMemviewSlice */
__Pyx_PyObject_to_MemoryviewSlice_dc_int(PyObject * obj,int writable_flag)34008   static CYTHON_INLINE __Pyx_memviewslice __Pyx_PyObject_to_MemoryviewSlice_dc_int(PyObject *obj, int writable_flag) {
34009     __Pyx_memviewslice result = { 0, 0, { 0 }, { 0 }, { 0 } };
34010     __Pyx_BufFmt_StackElem stack[1];
34011     int axes_specs[] = { (__Pyx_MEMVIEW_DIRECT | __Pyx_MEMVIEW_CONTIG) };
34012     int retcode;
34013     if (obj == Py_None) {
34014         result.memview = (struct __pyx_memoryview_obj *) Py_None;
34015         return result;
34016     }
34017     retcode = __Pyx_ValidateAndInit_memviewslice(axes_specs, __Pyx_IS_C_CONTIG,
34018                                                  (PyBUF_C_CONTIGUOUS | PyBUF_FORMAT) | writable_flag, 1,
34019                                                  &__Pyx_TypeInfo_int, stack,
34020                                                  &result, obj);
34021     if (unlikely(retcode == -1))
34022         goto __pyx_fail;
34023     return result;
34024 __pyx_fail:
34025     result.memview = NULL;
34026     result.data = NULL;
34027     return result;
34028 }
34029 
34030 /* ObjectToMemviewSlice */
__Pyx_PyObject_to_MemoryviewSlice_d_dc___pyx_t_double_complex(PyObject * obj,int writable_flag)34031   static CYTHON_INLINE __Pyx_memviewslice __Pyx_PyObject_to_MemoryviewSlice_d_dc___pyx_t_double_complex(PyObject *obj, int writable_flag) {
34032     __Pyx_memviewslice result = { 0, 0, { 0 }, { 0 }, { 0 } };
34033     __Pyx_BufFmt_StackElem stack[1];
34034     int axes_specs[] = { (__Pyx_MEMVIEW_DIRECT | __Pyx_MEMVIEW_FOLLOW), (__Pyx_MEMVIEW_DIRECT | __Pyx_MEMVIEW_CONTIG) };
34035     int retcode;
34036     if (obj == Py_None) {
34037         result.memview = (struct __pyx_memoryview_obj *) Py_None;
34038         return result;
34039     }
34040     retcode = __Pyx_ValidateAndInit_memviewslice(axes_specs, __Pyx_IS_C_CONTIG,
34041                                                  (PyBUF_C_CONTIGUOUS | PyBUF_FORMAT) | writable_flag, 2,
34042                                                  &__Pyx_TypeInfo___pyx_t_double_complex, stack,
34043                                                  &result, obj);
34044     if (unlikely(retcode == -1))
34045         goto __pyx_fail;
34046     return result;
34047 __pyx_fail:
34048     result.memview = NULL;
34049     result.data = NULL;
34050     return result;
34051 }
34052 
34053 /* ObjectToMemviewSlice */
__Pyx_PyObject_to_MemoryviewSlice_ds_long(PyObject * obj,int writable_flag)34054   static CYTHON_INLINE __Pyx_memviewslice __Pyx_PyObject_to_MemoryviewSlice_ds_long(PyObject *obj, int writable_flag) {
34055     __Pyx_memviewslice result = { 0, 0, { 0 }, { 0 }, { 0 } };
34056     __Pyx_BufFmt_StackElem stack[1];
34057     int axes_specs[] = { (__Pyx_MEMVIEW_DIRECT | __Pyx_MEMVIEW_STRIDED) };
34058     int retcode;
34059     if (obj == Py_None) {
34060         result.memview = (struct __pyx_memoryview_obj *) Py_None;
34061         return result;
34062     }
34063     retcode = __Pyx_ValidateAndInit_memviewslice(axes_specs, 0,
34064                                                  PyBUF_RECORDS_RO | writable_flag, 1,
34065                                                  &__Pyx_TypeInfo_long, stack,
34066                                                  &result, obj);
34067     if (unlikely(retcode == -1))
34068         goto __pyx_fail;
34069     return result;
34070 __pyx_fail:
34071     result.memview = NULL;
34072     result.data = NULL;
34073     return result;
34074 }
34075 
34076 /* CheckBinaryVersion */
__Pyx_check_binary_version(void)34077   static int __Pyx_check_binary_version(void) {
34078     char ctversion[4], rtversion[4];
34079     PyOS_snprintf(ctversion, 4, "%d.%d", PY_MAJOR_VERSION, PY_MINOR_VERSION);
34080     PyOS_snprintf(rtversion, 4, "%s", Py_GetVersion());
34081     if (ctversion[0] != rtversion[0] || ctversion[2] != rtversion[2]) {
34082         char message[200];
34083         PyOS_snprintf(message, sizeof(message),
34084                       "compiletime version %s of module '%.100s' "
34085                       "does not match runtime version %s",
34086                       ctversion, __Pyx_MODULE_NAME, rtversion);
34087         return PyErr_WarnEx(NULL, message, 1);
34088     }
34089     return 0;
34090 }
34091 
34092 /* FunctionExport */
__Pyx_ExportFunction(const char * name,void (* f)(void),const char * sig)34093   static int __Pyx_ExportFunction(const char *name, void (*f)(void), const char *sig) {
34094     PyObject *d = 0;
34095     PyObject *cobj = 0;
34096     union {
34097         void (*fp)(void);
34098         void *p;
34099     } tmp;
34100     d = PyObject_GetAttrString(__pyx_m, (char *)"__pyx_capi__");
34101     if (!d) {
34102         PyErr_Clear();
34103         d = PyDict_New();
34104         if (!d)
34105             goto bad;
34106         Py_INCREF(d);
34107         if (PyModule_AddObject(__pyx_m, (char *)"__pyx_capi__", d) < 0)
34108             goto bad;
34109     }
34110     tmp.fp = f;
34111 #if PY_VERSION_HEX >= 0x02070000
34112     cobj = PyCapsule_New(tmp.p, sig, 0);
34113 #else
34114     cobj = PyCObject_FromVoidPtrAndDesc(tmp.p, (void *)sig, 0);
34115 #endif
34116     if (!cobj)
34117         goto bad;
34118     if (PyDict_SetItemString(d, name, cobj) < 0)
34119         goto bad;
34120     Py_DECREF(cobj);
34121     Py_DECREF(d);
34122     return 0;
34123 bad:
34124     Py_XDECREF(cobj);
34125     Py_XDECREF(d);
34126     return -1;
34127 }
34128 
34129 /* FunctionImport */
34130   #ifndef __PYX_HAVE_RT_ImportFunction
34131 #define __PYX_HAVE_RT_ImportFunction
__Pyx_ImportFunction(PyObject * module,const char * funcname,void (** f)(void),const char * sig)34132 static int __Pyx_ImportFunction(PyObject *module, const char *funcname, void (**f)(void), const char *sig) {
34133     PyObject *d = 0;
34134     PyObject *cobj = 0;
34135     union {
34136         void (*fp)(void);
34137         void *p;
34138     } tmp;
34139     d = PyObject_GetAttrString(module, (char *)"__pyx_capi__");
34140     if (!d)
34141         goto bad;
34142     cobj = PyDict_GetItemString(d, funcname);
34143     if (!cobj) {
34144         PyErr_Format(PyExc_ImportError,
34145             "%.200s does not export expected C function %.200s",
34146                 PyModule_GetName(module), funcname);
34147         goto bad;
34148     }
34149 #if PY_VERSION_HEX >= 0x02070000
34150     if (!PyCapsule_IsValid(cobj, sig)) {
34151         PyErr_Format(PyExc_TypeError,
34152             "C function %.200s.%.200s has wrong signature (expected %.500s, got %.500s)",
34153              PyModule_GetName(module), funcname, sig, PyCapsule_GetName(cobj));
34154         goto bad;
34155     }
34156     tmp.p = PyCapsule_GetPointer(cobj, sig);
34157 #else
34158     {const char *desc, *s1, *s2;
34159     desc = (const char *)PyCObject_GetDesc(cobj);
34160     if (!desc)
34161         goto bad;
34162     s1 = desc; s2 = sig;
34163     while (*s1 != '\0' && *s1 == *s2) { s1++; s2++; }
34164     if (*s1 != *s2) {
34165         PyErr_Format(PyExc_TypeError,
34166             "C function %.200s.%.200s has wrong signature (expected %.500s, got %.500s)",
34167              PyModule_GetName(module), funcname, sig, desc);
34168         goto bad;
34169     }
34170     tmp.p = PyCObject_AsVoidPtr(cobj);}
34171 #endif
34172     *f = tmp.fp;
34173     if (!(*f))
34174         goto bad;
34175     Py_DECREF(d);
34176     return 0;
34177 bad:
34178     Py_XDECREF(d);
34179     return -1;
34180 }
34181 #endif
34182 
34183 /* InitStrings */
__Pyx_InitStrings(__Pyx_StringTabEntry * t)34184   static int __Pyx_InitStrings(__Pyx_StringTabEntry *t) {
34185     while (t->p) {
34186         #if PY_MAJOR_VERSION < 3
34187         if (t->is_unicode) {
34188             *t->p = PyUnicode_DecodeUTF8(t->s, t->n - 1, NULL);
34189         } else if (t->intern) {
34190             *t->p = PyString_InternFromString(t->s);
34191         } else {
34192             *t->p = PyString_FromStringAndSize(t->s, t->n - 1);
34193         }
34194         #else
34195         if (t->is_unicode | t->is_str) {
34196             if (t->intern) {
34197                 *t->p = PyUnicode_InternFromString(t->s);
34198             } else if (t->encoding) {
34199                 *t->p = PyUnicode_Decode(t->s, t->n - 1, t->encoding, NULL);
34200             } else {
34201                 *t->p = PyUnicode_FromStringAndSize(t->s, t->n - 1);
34202             }
34203         } else {
34204             *t->p = PyBytes_FromStringAndSize(t->s, t->n - 1);
34205         }
34206         #endif
34207         if (!*t->p)
34208             return -1;
34209         if (PyObject_Hash(*t->p) == -1)
34210             return -1;
34211         ++t;
34212     }
34213     return 0;
34214 }
34215 
__Pyx_PyUnicode_FromString(const char * c_str)34216 static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(const char* c_str) {
34217     return __Pyx_PyUnicode_FromStringAndSize(c_str, (Py_ssize_t)strlen(c_str));
34218 }
__Pyx_PyObject_AsString(PyObject * o)34219 static CYTHON_INLINE const char* __Pyx_PyObject_AsString(PyObject* o) {
34220     Py_ssize_t ignore;
34221     return __Pyx_PyObject_AsStringAndSize(o, &ignore);
34222 }
34223 #if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT
34224 #if !CYTHON_PEP393_ENABLED
__Pyx_PyUnicode_AsStringAndSize(PyObject * o,Py_ssize_t * length)34225 static const char* __Pyx_PyUnicode_AsStringAndSize(PyObject* o, Py_ssize_t *length) {
34226     char* defenc_c;
34227     PyObject* defenc = _PyUnicode_AsDefaultEncodedString(o, NULL);
34228     if (!defenc) return NULL;
34229     defenc_c = PyBytes_AS_STRING(defenc);
34230 #if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
34231     {
34232         char* end = defenc_c + PyBytes_GET_SIZE(defenc);
34233         char* c;
34234         for (c = defenc_c; c < end; c++) {
34235             if ((unsigned char) (*c) >= 128) {
34236                 PyUnicode_AsASCIIString(o);
34237                 return NULL;
34238             }
34239         }
34240     }
34241 #endif
34242     *length = PyBytes_GET_SIZE(defenc);
34243     return defenc_c;
34244 }
34245 #else
__Pyx_PyUnicode_AsStringAndSize(PyObject * o,Py_ssize_t * length)34246 static CYTHON_INLINE const char* __Pyx_PyUnicode_AsStringAndSize(PyObject* o, Py_ssize_t *length) {
34247     if (unlikely(__Pyx_PyUnicode_READY(o) == -1)) return NULL;
34248 #if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
34249     if (likely(PyUnicode_IS_ASCII(o))) {
34250         *length = PyUnicode_GET_LENGTH(o);
34251         return PyUnicode_AsUTF8(o);
34252     } else {
34253         PyUnicode_AsASCIIString(o);
34254         return NULL;
34255     }
34256 #else
34257     return PyUnicode_AsUTF8AndSize(o, length);
34258 #endif
34259 }
34260 #endif
34261 #endif
__Pyx_PyObject_AsStringAndSize(PyObject * o,Py_ssize_t * length)34262 static CYTHON_INLINE const char* __Pyx_PyObject_AsStringAndSize(PyObject* o, Py_ssize_t *length) {
34263 #if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT
34264     if (
34265 #if PY_MAJOR_VERSION < 3 && __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
34266             __Pyx_sys_getdefaultencoding_not_ascii &&
34267 #endif
34268             PyUnicode_Check(o)) {
34269         return __Pyx_PyUnicode_AsStringAndSize(o, length);
34270     } else
34271 #endif
34272 #if (!CYTHON_COMPILING_IN_PYPY) || (defined(PyByteArray_AS_STRING) && defined(PyByteArray_GET_SIZE))
34273     if (PyByteArray_Check(o)) {
34274         *length = PyByteArray_GET_SIZE(o);
34275         return PyByteArray_AS_STRING(o);
34276     } else
34277 #endif
34278     {
34279         char* result;
34280         int r = PyBytes_AsStringAndSize(o, &result, length);
34281         if (unlikely(r < 0)) {
34282             return NULL;
34283         } else {
34284             return result;
34285         }
34286     }
34287 }
__Pyx_PyObject_IsTrue(PyObject * x)34288 static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject* x) {
34289    int is_true = x == Py_True;
34290    if (is_true | (x == Py_False) | (x == Py_None)) return is_true;
34291    else return PyObject_IsTrue(x);
34292 }
__Pyx_PyObject_IsTrueAndDecref(PyObject * x)34293 static CYTHON_INLINE int __Pyx_PyObject_IsTrueAndDecref(PyObject* x) {
34294     int retval;
34295     if (unlikely(!x)) return -1;
34296     retval = __Pyx_PyObject_IsTrue(x);
34297     Py_DECREF(x);
34298     return retval;
34299 }
__Pyx_PyNumber_IntOrLongWrongResultType(PyObject * result,const char * type_name)34300 static PyObject* __Pyx_PyNumber_IntOrLongWrongResultType(PyObject* result, const char* type_name) {
34301 #if PY_MAJOR_VERSION >= 3
34302     if (PyLong_Check(result)) {
34303         if (PyErr_WarnFormat(PyExc_DeprecationWarning, 1,
34304                 "__int__ returned non-int (type %.200s).  "
34305                 "The ability to return an instance of a strict subclass of int "
34306                 "is deprecated, and may be removed in a future version of Python.",
34307                 Py_TYPE(result)->tp_name)) {
34308             Py_DECREF(result);
34309             return NULL;
34310         }
34311         return result;
34312     }
34313 #endif
34314     PyErr_Format(PyExc_TypeError,
34315                  "__%.4s__ returned non-%.4s (type %.200s)",
34316                  type_name, type_name, Py_TYPE(result)->tp_name);
34317     Py_DECREF(result);
34318     return NULL;
34319 }
__Pyx_PyNumber_IntOrLong(PyObject * x)34320 static CYTHON_INLINE PyObject* __Pyx_PyNumber_IntOrLong(PyObject* x) {
34321 #if CYTHON_USE_TYPE_SLOTS
34322   PyNumberMethods *m;
34323 #endif
34324   const char *name = NULL;
34325   PyObject *res = NULL;
34326 #if PY_MAJOR_VERSION < 3
34327   if (likely(PyInt_Check(x) || PyLong_Check(x)))
34328 #else
34329   if (likely(PyLong_Check(x)))
34330 #endif
34331     return __Pyx_NewRef(x);
34332 #if CYTHON_USE_TYPE_SLOTS
34333   m = Py_TYPE(x)->tp_as_number;
34334   #if PY_MAJOR_VERSION < 3
34335   if (m && m->nb_int) {
34336     name = "int";
34337     res = m->nb_int(x);
34338   }
34339   else if (m && m->nb_long) {
34340     name = "long";
34341     res = m->nb_long(x);
34342   }
34343   #else
34344   if (likely(m && m->nb_int)) {
34345     name = "int";
34346     res = m->nb_int(x);
34347   }
34348   #endif
34349 #else
34350   if (!PyBytes_CheckExact(x) && !PyUnicode_CheckExact(x)) {
34351     res = PyNumber_Int(x);
34352   }
34353 #endif
34354   if (likely(res)) {
34355 #if PY_MAJOR_VERSION < 3
34356     if (unlikely(!PyInt_Check(res) && !PyLong_Check(res))) {
34357 #else
34358     if (unlikely(!PyLong_CheckExact(res))) {
34359 #endif
34360         return __Pyx_PyNumber_IntOrLongWrongResultType(res, name);
34361     }
34362   }
34363   else if (!PyErr_Occurred()) {
34364     PyErr_SetString(PyExc_TypeError,
34365                     "an integer is required");
34366   }
34367   return res;
34368 }
34369 static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject* b) {
34370   Py_ssize_t ival;
34371   PyObject *x;
34372 #if PY_MAJOR_VERSION < 3
34373   if (likely(PyInt_CheckExact(b))) {
34374     if (sizeof(Py_ssize_t) >= sizeof(long))
34375         return PyInt_AS_LONG(b);
34376     else
34377         return PyInt_AsSsize_t(b);
34378   }
34379 #endif
34380   if (likely(PyLong_CheckExact(b))) {
34381     #if CYTHON_USE_PYLONG_INTERNALS
34382     const digit* digits = ((PyLongObject*)b)->ob_digit;
34383     const Py_ssize_t size = Py_SIZE(b);
34384     if (likely(__Pyx_sst_abs(size) <= 1)) {
34385         ival = likely(size) ? digits[0] : 0;
34386         if (size == -1) ival = -ival;
34387         return ival;
34388     } else {
34389       switch (size) {
34390          case 2:
34391            if (8 * sizeof(Py_ssize_t) > 2 * PyLong_SHIFT) {
34392              return (Py_ssize_t) (((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
34393            }
34394            break;
34395          case -2:
34396            if (8 * sizeof(Py_ssize_t) > 2 * PyLong_SHIFT) {
34397              return -(Py_ssize_t) (((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
34398            }
34399            break;
34400          case 3:
34401            if (8 * sizeof(Py_ssize_t) > 3 * PyLong_SHIFT) {
34402              return (Py_ssize_t) (((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
34403            }
34404            break;
34405          case -3:
34406            if (8 * sizeof(Py_ssize_t) > 3 * PyLong_SHIFT) {
34407              return -(Py_ssize_t) (((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
34408            }
34409            break;
34410          case 4:
34411            if (8 * sizeof(Py_ssize_t) > 4 * PyLong_SHIFT) {
34412              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]));
34413            }
34414            break;
34415          case -4:
34416            if (8 * sizeof(Py_ssize_t) > 4 * PyLong_SHIFT) {
34417              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]));
34418            }
34419            break;
34420       }
34421     }
34422     #endif
34423     return PyLong_AsSsize_t(b);
34424   }
34425   x = PyNumber_Index(b);
34426   if (!x) return -1;
34427   ival = PyInt_AsSsize_t(x);
34428   Py_DECREF(x);
34429   return ival;
34430 }
34431 static CYTHON_INLINE PyObject * __Pyx_PyBool_FromLong(long b) {
34432   return b ? __Pyx_NewRef(Py_True) : __Pyx_NewRef(Py_False);
34433 }
34434 static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t ival) {
34435     return PyInt_FromSize_t(ival);
34436 }
34437 
34438 
34439 #endif /* Py_PYTHON_H */
34440