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.br_tensor",
20         "sources": [
21             "qutip/cy/br_tensor.pyx"
22         ]
23     },
24     "module_name": "qutip.cy.br_tensor"
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__br_tensor
647 #define __PYX_HAVE_API__qutip__cy__br_tensor
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 <algorithm>
658 #include "ios"
659 #include "new"
660 #include "stdexcept"
661 #include "typeinfo"
662 #include <vector>
663 #include "pythread.h"
664 #include <stdlib.h>
665 #include "pystate.h"
666 #ifdef _OPENMP
667 #include <omp.h>
668 #endif /* _OPENMP */
669 
670 #if defined(PYREX_WITHOUT_ASSERTIONS) && !defined(CYTHON_WITHOUT_ASSERTIONS)
671 #define CYTHON_WITHOUT_ASSERTIONS
672 #endif
673 
674 typedef struct {PyObject **p; const char *s; const Py_ssize_t n; const char* encoding;
675                 const char is_unicode; const char is_str; const char intern; } __Pyx_StringTabEntry;
676 
677 #define __PYX_DEFAULT_STRING_ENCODING_IS_ASCII 0
678 #define __PYX_DEFAULT_STRING_ENCODING_IS_UTF8 0
679 #define __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT (PY_MAJOR_VERSION >= 3 && __PYX_DEFAULT_STRING_ENCODING_IS_UTF8)
680 #define __PYX_DEFAULT_STRING_ENCODING ""
681 #define __Pyx_PyObject_FromString __Pyx_PyBytes_FromString
682 #define __Pyx_PyObject_FromStringAndSize __Pyx_PyBytes_FromStringAndSize
683 #define __Pyx_uchar_cast(c) ((unsigned char)c)
684 #define __Pyx_long_cast(x) ((long)x)
685 #define __Pyx_fits_Py_ssize_t(v, type, is_signed)  (\
686     (sizeof(type) < sizeof(Py_ssize_t))  ||\
687     (sizeof(type) > sizeof(Py_ssize_t) &&\
688           likely(v < (type)PY_SSIZE_T_MAX ||\
689                  v == (type)PY_SSIZE_T_MAX)  &&\
690           (!is_signed || likely(v > (type)PY_SSIZE_T_MIN ||\
691                                 v == (type)PY_SSIZE_T_MIN)))  ||\
692     (sizeof(type) == sizeof(Py_ssize_t) &&\
693           (is_signed || likely(v < (type)PY_SSIZE_T_MAX ||\
694                                v == (type)PY_SSIZE_T_MAX)))  )
__Pyx_is_valid_index(Py_ssize_t i,Py_ssize_t limit)695 static CYTHON_INLINE int __Pyx_is_valid_index(Py_ssize_t i, Py_ssize_t limit) {
696     return (size_t) i < (size_t) limit;
697 }
698 #if defined (__cplusplus) && __cplusplus >= 201103L
699     #include <cstdlib>
700     #define __Pyx_sst_abs(value) std::abs(value)
701 #elif SIZEOF_INT >= SIZEOF_SIZE_T
702     #define __Pyx_sst_abs(value) abs(value)
703 #elif SIZEOF_LONG >= SIZEOF_SIZE_T
704     #define __Pyx_sst_abs(value) labs(value)
705 #elif defined (_MSC_VER)
706     #define __Pyx_sst_abs(value) ((Py_ssize_t)_abs64(value))
707 #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
708     #define __Pyx_sst_abs(value) llabs(value)
709 #elif defined (__GNUC__)
710     #define __Pyx_sst_abs(value) __builtin_llabs(value)
711 #else
712     #define __Pyx_sst_abs(value) ((value<0) ? -value : value)
713 #endif
714 static CYTHON_INLINE const char* __Pyx_PyObject_AsString(PyObject*);
715 static CYTHON_INLINE const char* __Pyx_PyObject_AsStringAndSize(PyObject*, Py_ssize_t* length);
716 #define __Pyx_PyByteArray_FromString(s) PyByteArray_FromStringAndSize((const char*)s, strlen((const char*)s))
717 #define __Pyx_PyByteArray_FromStringAndSize(s, l) PyByteArray_FromStringAndSize((const char*)s, l)
718 #define __Pyx_PyBytes_FromString        PyBytes_FromString
719 #define __Pyx_PyBytes_FromStringAndSize PyBytes_FromStringAndSize
720 static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(const char*);
721 #if PY_MAJOR_VERSION < 3
722     #define __Pyx_PyStr_FromString        __Pyx_PyBytes_FromString
723     #define __Pyx_PyStr_FromStringAndSize __Pyx_PyBytes_FromStringAndSize
724 #else
725     #define __Pyx_PyStr_FromString        __Pyx_PyUnicode_FromString
726     #define __Pyx_PyStr_FromStringAndSize __Pyx_PyUnicode_FromStringAndSize
727 #endif
728 #define __Pyx_PyBytes_AsWritableString(s)     ((char*) PyBytes_AS_STRING(s))
729 #define __Pyx_PyBytes_AsWritableSString(s)    ((signed char*) PyBytes_AS_STRING(s))
730 #define __Pyx_PyBytes_AsWritableUString(s)    ((unsigned char*) PyBytes_AS_STRING(s))
731 #define __Pyx_PyBytes_AsString(s)     ((const char*) PyBytes_AS_STRING(s))
732 #define __Pyx_PyBytes_AsSString(s)    ((const signed char*) PyBytes_AS_STRING(s))
733 #define __Pyx_PyBytes_AsUString(s)    ((const unsigned char*) PyBytes_AS_STRING(s))
734 #define __Pyx_PyObject_AsWritableString(s)    ((char*) __Pyx_PyObject_AsString(s))
735 #define __Pyx_PyObject_AsWritableSString(s)    ((signed char*) __Pyx_PyObject_AsString(s))
736 #define __Pyx_PyObject_AsWritableUString(s)    ((unsigned char*) __Pyx_PyObject_AsString(s))
737 #define __Pyx_PyObject_AsSString(s)    ((const signed char*) __Pyx_PyObject_AsString(s))
738 #define __Pyx_PyObject_AsUString(s)    ((const unsigned char*) __Pyx_PyObject_AsString(s))
739 #define __Pyx_PyObject_FromCString(s)  __Pyx_PyObject_FromString((const char*)s)
740 #define __Pyx_PyBytes_FromCString(s)   __Pyx_PyBytes_FromString((const char*)s)
741 #define __Pyx_PyByteArray_FromCString(s)   __Pyx_PyByteArray_FromString((const char*)s)
742 #define __Pyx_PyStr_FromCString(s)     __Pyx_PyStr_FromString((const char*)s)
743 #define __Pyx_PyUnicode_FromCString(s) __Pyx_PyUnicode_FromString((const char*)s)
__Pyx_Py_UNICODE_strlen(const Py_UNICODE * u)744 static CYTHON_INLINE size_t __Pyx_Py_UNICODE_strlen(const Py_UNICODE *u) {
745     const Py_UNICODE *u_end = u;
746     while (*u_end++) ;
747     return (size_t)(u_end - u - 1);
748 }
749 #define __Pyx_PyUnicode_FromUnicode(u)       PyUnicode_FromUnicode(u, __Pyx_Py_UNICODE_strlen(u))
750 #define __Pyx_PyUnicode_FromUnicodeAndLength PyUnicode_FromUnicode
751 #define __Pyx_PyUnicode_AsUnicode            PyUnicode_AsUnicode
752 #define __Pyx_NewRef(obj) (Py_INCREF(obj), obj)
753 #define __Pyx_Owned_Py_None(b) __Pyx_NewRef(Py_None)
754 static CYTHON_INLINE PyObject * __Pyx_PyBool_FromLong(long b);
755 static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject*);
756 static CYTHON_INLINE int __Pyx_PyObject_IsTrueAndDecref(PyObject*);
757 static CYTHON_INLINE PyObject* __Pyx_PyNumber_IntOrLong(PyObject* x);
758 #define __Pyx_PySequence_Tuple(obj)\
759     (likely(PyTuple_CheckExact(obj)) ? __Pyx_NewRef(obj) : PySequence_Tuple(obj))
760 static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject*);
761 static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t);
762 #if CYTHON_ASSUME_SAFE_MACROS
763 #define __pyx_PyFloat_AsDouble(x) (PyFloat_CheckExact(x) ? PyFloat_AS_DOUBLE(x) : PyFloat_AsDouble(x))
764 #else
765 #define __pyx_PyFloat_AsDouble(x) PyFloat_AsDouble(x)
766 #endif
767 #define __pyx_PyFloat_AsFloat(x) ((float) __pyx_PyFloat_AsDouble(x))
768 #if PY_MAJOR_VERSION >= 3
769 #define __Pyx_PyNumber_Int(x) (PyLong_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Long(x))
770 #else
771 #define __Pyx_PyNumber_Int(x) (PyInt_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Int(x))
772 #endif
773 #define __Pyx_PyNumber_Float(x) (PyFloat_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Float(x))
774 #if PY_MAJOR_VERSION < 3 && __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
775 static int __Pyx_sys_getdefaultencoding_not_ascii;
__Pyx_init_sys_getdefaultencoding_params(void)776 static int __Pyx_init_sys_getdefaultencoding_params(void) {
777     PyObject* sys;
778     PyObject* default_encoding = NULL;
779     PyObject* ascii_chars_u = NULL;
780     PyObject* ascii_chars_b = NULL;
781     const char* default_encoding_c;
782     sys = PyImport_ImportModule("sys");
783     if (!sys) goto bad;
784     default_encoding = PyObject_CallMethod(sys, (char*) "getdefaultencoding", NULL);
785     Py_DECREF(sys);
786     if (!default_encoding) goto bad;
787     default_encoding_c = PyBytes_AsString(default_encoding);
788     if (!default_encoding_c) goto bad;
789     if (strcmp(default_encoding_c, "ascii") == 0) {
790         __Pyx_sys_getdefaultencoding_not_ascii = 0;
791     } else {
792         char ascii_chars[128];
793         int c;
794         for (c = 0; c < 128; c++) {
795             ascii_chars[c] = c;
796         }
797         __Pyx_sys_getdefaultencoding_not_ascii = 1;
798         ascii_chars_u = PyUnicode_DecodeASCII(ascii_chars, 128, NULL);
799         if (!ascii_chars_u) goto bad;
800         ascii_chars_b = PyUnicode_AsEncodedString(ascii_chars_u, default_encoding_c, NULL);
801         if (!ascii_chars_b || !PyBytes_Check(ascii_chars_b) || memcmp(ascii_chars, PyBytes_AS_STRING(ascii_chars_b), 128) != 0) {
802             PyErr_Format(
803                 PyExc_ValueError,
804                 "This module compiled with c_string_encoding=ascii, but default encoding '%.200s' is not a superset of ascii.",
805                 default_encoding_c);
806             goto bad;
807         }
808         Py_DECREF(ascii_chars_u);
809         Py_DECREF(ascii_chars_b);
810     }
811     Py_DECREF(default_encoding);
812     return 0;
813 bad:
814     Py_XDECREF(default_encoding);
815     Py_XDECREF(ascii_chars_u);
816     Py_XDECREF(ascii_chars_b);
817     return -1;
818 }
819 #endif
820 #if __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT && PY_MAJOR_VERSION >= 3
821 #define __Pyx_PyUnicode_FromStringAndSize(c_str, size) PyUnicode_DecodeUTF8(c_str, size, NULL)
822 #else
823 #define __Pyx_PyUnicode_FromStringAndSize(c_str, size) PyUnicode_Decode(c_str, size, __PYX_DEFAULT_STRING_ENCODING, NULL)
824 #if __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT
825 static char* __PYX_DEFAULT_STRING_ENCODING;
__Pyx_init_sys_getdefaultencoding_params(void)826 static int __Pyx_init_sys_getdefaultencoding_params(void) {
827     PyObject* sys;
828     PyObject* default_encoding = NULL;
829     char* default_encoding_c;
830     sys = PyImport_ImportModule("sys");
831     if (!sys) goto bad;
832     default_encoding = PyObject_CallMethod(sys, (char*) (const char*) "getdefaultencoding", NULL);
833     Py_DECREF(sys);
834     if (!default_encoding) goto bad;
835     default_encoding_c = PyBytes_AsString(default_encoding);
836     if (!default_encoding_c) goto bad;
837     __PYX_DEFAULT_STRING_ENCODING = (char*) malloc(strlen(default_encoding_c) + 1);
838     if (!__PYX_DEFAULT_STRING_ENCODING) goto bad;
839     strcpy(__PYX_DEFAULT_STRING_ENCODING, default_encoding_c);
840     Py_DECREF(default_encoding);
841     return 0;
842 bad:
843     Py_XDECREF(default_encoding);
844     return -1;
845 }
846 #endif
847 #endif
848 
849 
850 /* Test for GCC > 2.95 */
851 #if defined(__GNUC__)     && (__GNUC__ > 2 || (__GNUC__ == 2 && (__GNUC_MINOR__ > 95)))
852   #define likely(x)   __builtin_expect(!!(x), 1)
853   #define unlikely(x) __builtin_expect(!!(x), 0)
854 #else /* !__GNUC__ or GCC < 2.95 */
855   #define likely(x)   (x)
856   #define unlikely(x) (x)
857 #endif /* __GNUC__ */
__Pyx_pretend_to_initialize(void * ptr)858 static CYTHON_INLINE void __Pyx_pretend_to_initialize(void* ptr) { (void)ptr; }
859 
860 static PyObject *__pyx_m = NULL;
861 static PyObject *__pyx_d;
862 static PyObject *__pyx_b;
863 static PyObject *__pyx_cython_runtime = NULL;
864 static PyObject *__pyx_empty_tuple;
865 static PyObject *__pyx_empty_bytes;
866 static PyObject *__pyx_empty_unicode;
867 static int __pyx_lineno;
868 static int __pyx_clineno = 0;
869 static const char * __pyx_cfilenm= __FILE__;
870 static const char *__pyx_filename;
871 
872 /* Header.proto */
873 #if !defined(CYTHON_CCOMPLEX)
874   #if defined(__cplusplus)
875     #define CYTHON_CCOMPLEX 1
876   #elif defined(_Complex_I)
877     #define CYTHON_CCOMPLEX 1
878   #else
879     #define CYTHON_CCOMPLEX 0
880   #endif
881 #endif
882 #if CYTHON_CCOMPLEX
883   #ifdef __cplusplus
884     #include <complex>
885   #else
886     #include <complex.h>
887   #endif
888 #endif
889 #if CYTHON_CCOMPLEX && !defined(__cplusplus) && defined(__sun__) && defined(__GNUC__)
890   #undef _Complex_I
891   #define _Complex_I 1.0fj
892 #endif
893 
894 
895 static const char *__pyx_f[] = {
896   "qutip/cy/sparse_routines.pxi",
897   "qutip/cy/br_tensor.pyx",
898   "__init__.pxd",
899   "stringsource",
900   "type.pxd",
901 };
902 /* BufferFormatStructs.proto */
903 #define IS_UNSIGNED(type) (((type) -1) > 0)
904 struct __Pyx_StructField_;
905 #define __PYX_BUF_FLAGS_PACKED_STRUCT (1 << 0)
906 typedef struct {
907   const char* name;
908   struct __Pyx_StructField_* fields;
909   size_t size;
910   size_t arraysize[8];
911   int ndim;
912   char typegroup;
913   char is_unsigned;
914   int flags;
915 } __Pyx_TypeInfo;
916 typedef struct __Pyx_StructField_ {
917   __Pyx_TypeInfo* type;
918   const char* name;
919   size_t offset;
920 } __Pyx_StructField;
921 typedef struct {
922   __Pyx_StructField* field;
923   size_t parent_offset;
924 } __Pyx_BufFmt_StackElem;
925 typedef struct {
926   __Pyx_StructField root;
927   __Pyx_BufFmt_StackElem* head;
928   size_t fmt_offset;
929   size_t new_count, enc_count;
930   size_t struct_alignment;
931   int is_complex;
932   char enc_type;
933   char new_packmode;
934   char enc_packmode;
935   char is_valid_array;
936 } __Pyx_BufFmt_Context;
937 
938 /* MemviewSliceStruct.proto */
939 struct __pyx_memoryview_obj;
940 typedef struct {
941   struct __pyx_memoryview_obj *memview;
942   char *data;
943   Py_ssize_t shape[8];
944   Py_ssize_t strides[8];
945   Py_ssize_t suboffsets[8];
946 } __Pyx_memviewslice;
947 #define __Pyx_MemoryView_Len(m)  (m.shape[0])
948 
949 /* Atomics.proto */
950 #include <pythread.h>
951 #ifndef CYTHON_ATOMICS
952     #define CYTHON_ATOMICS 1
953 #endif
954 #define __pyx_atomic_int_type int
955 #if CYTHON_ATOMICS && __GNUC__ >= 4 && (__GNUC_MINOR__ > 1 ||\
956                     (__GNUC_MINOR__ == 1 && __GNUC_PATCHLEVEL >= 2)) &&\
957                     !defined(__i386__)
958     #define __pyx_atomic_incr_aligned(value, lock) __sync_fetch_and_add(value, 1)
959     #define __pyx_atomic_decr_aligned(value, lock) __sync_fetch_and_sub(value, 1)
960     #ifdef __PYX_DEBUG_ATOMICS
961         #warning "Using GNU atomics"
962     #endif
963 #elif CYTHON_ATOMICS && defined(_MSC_VER) && 0
964     #include <Windows.h>
965     #undef __pyx_atomic_int_type
966     #define __pyx_atomic_int_type LONG
967     #define __pyx_atomic_incr_aligned(value, lock) InterlockedIncrement(value)
968     #define __pyx_atomic_decr_aligned(value, lock) InterlockedDecrement(value)
969     #ifdef __PYX_DEBUG_ATOMICS
970         #pragma message ("Using MSVC atomics")
971     #endif
972 #elif CYTHON_ATOMICS && (defined(__ICC) || defined(__INTEL_COMPILER)) && 0
973     #define __pyx_atomic_incr_aligned(value, lock) _InterlockedIncrement(value)
974     #define __pyx_atomic_decr_aligned(value, lock) _InterlockedDecrement(value)
975     #ifdef __PYX_DEBUG_ATOMICS
976         #warning "Using Intel atomics"
977     #endif
978 #else
979     #undef CYTHON_ATOMICS
980     #define CYTHON_ATOMICS 0
981     #ifdef __PYX_DEBUG_ATOMICS
982         #warning "Not using atomics"
983     #endif
984 #endif
985 typedef volatile __pyx_atomic_int_type __pyx_atomic_int;
986 #if CYTHON_ATOMICS
987     #define __pyx_add_acquisition_count(memview)\
988              __pyx_atomic_incr_aligned(__pyx_get_slice_count_pointer(memview), memview->lock)
989     #define __pyx_sub_acquisition_count(memview)\
990             __pyx_atomic_decr_aligned(__pyx_get_slice_count_pointer(memview), memview->lock)
991 #else
992     #define __pyx_add_acquisition_count(memview)\
993             __pyx_add_acquisition_count_locked(__pyx_get_slice_count_pointer(memview), memview->lock)
994     #define __pyx_sub_acquisition_count(memview)\
995             __pyx_sub_acquisition_count_locked(__pyx_get_slice_count_pointer(memview), memview->lock)
996 #endif
997 
998 /* ForceInitThreads.proto */
999 #ifndef __PYX_FORCE_INIT_THREADS
1000   #define __PYX_FORCE_INIT_THREADS 0
1001 #endif
1002 
1003 /* NoFastGil.proto */
1004 #define __Pyx_PyGILState_Ensure PyGILState_Ensure
1005 #define __Pyx_PyGILState_Release PyGILState_Release
1006 #define __Pyx_FastGIL_Remember()
1007 #define __Pyx_FastGIL_Forget()
1008 #define __Pyx_FastGilFuncInit()
1009 
1010 
1011 /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":689
1012  * # in Cython to enable them only on the right systems.
1013  *
1014  * ctypedef npy_int8       int8_t             # <<<<<<<<<<<<<<
1015  * ctypedef npy_int16      int16_t
1016  * ctypedef npy_int32      int32_t
1017  */
1018 typedef npy_int8 __pyx_t_5numpy_int8_t;
1019 
1020 /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":690
1021  *
1022  * ctypedef npy_int8       int8_t
1023  * ctypedef npy_int16      int16_t             # <<<<<<<<<<<<<<
1024  * ctypedef npy_int32      int32_t
1025  * ctypedef npy_int64      int64_t
1026  */
1027 typedef npy_int16 __pyx_t_5numpy_int16_t;
1028 
1029 /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":691
1030  * ctypedef npy_int8       int8_t
1031  * ctypedef npy_int16      int16_t
1032  * ctypedef npy_int32      int32_t             # <<<<<<<<<<<<<<
1033  * ctypedef npy_int64      int64_t
1034  * #ctypedef npy_int96      int96_t
1035  */
1036 typedef npy_int32 __pyx_t_5numpy_int32_t;
1037 
1038 /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":692
1039  * ctypedef npy_int16      int16_t
1040  * ctypedef npy_int32      int32_t
1041  * ctypedef npy_int64      int64_t             # <<<<<<<<<<<<<<
1042  * #ctypedef npy_int96      int96_t
1043  * #ctypedef npy_int128     int128_t
1044  */
1045 typedef npy_int64 __pyx_t_5numpy_int64_t;
1046 
1047 /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":696
1048  * #ctypedef npy_int128     int128_t
1049  *
1050  * ctypedef npy_uint8      uint8_t             # <<<<<<<<<<<<<<
1051  * ctypedef npy_uint16     uint16_t
1052  * ctypedef npy_uint32     uint32_t
1053  */
1054 typedef npy_uint8 __pyx_t_5numpy_uint8_t;
1055 
1056 /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":697
1057  *
1058  * ctypedef npy_uint8      uint8_t
1059  * ctypedef npy_uint16     uint16_t             # <<<<<<<<<<<<<<
1060  * ctypedef npy_uint32     uint32_t
1061  * ctypedef npy_uint64     uint64_t
1062  */
1063 typedef npy_uint16 __pyx_t_5numpy_uint16_t;
1064 
1065 /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":698
1066  * ctypedef npy_uint8      uint8_t
1067  * ctypedef npy_uint16     uint16_t
1068  * ctypedef npy_uint32     uint32_t             # <<<<<<<<<<<<<<
1069  * ctypedef npy_uint64     uint64_t
1070  * #ctypedef npy_uint96     uint96_t
1071  */
1072 typedef npy_uint32 __pyx_t_5numpy_uint32_t;
1073 
1074 /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":699
1075  * ctypedef npy_uint16     uint16_t
1076  * ctypedef npy_uint32     uint32_t
1077  * ctypedef npy_uint64     uint64_t             # <<<<<<<<<<<<<<
1078  * #ctypedef npy_uint96     uint96_t
1079  * #ctypedef npy_uint128    uint128_t
1080  */
1081 typedef npy_uint64 __pyx_t_5numpy_uint64_t;
1082 
1083 /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":703
1084  * #ctypedef npy_uint128    uint128_t
1085  *
1086  * ctypedef npy_float32    float32_t             # <<<<<<<<<<<<<<
1087  * ctypedef npy_float64    float64_t
1088  * #ctypedef npy_float80    float80_t
1089  */
1090 typedef npy_float32 __pyx_t_5numpy_float32_t;
1091 
1092 /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":704
1093  *
1094  * ctypedef npy_float32    float32_t
1095  * ctypedef npy_float64    float64_t             # <<<<<<<<<<<<<<
1096  * #ctypedef npy_float80    float80_t
1097  * #ctypedef npy_float128   float128_t
1098  */
1099 typedef npy_float64 __pyx_t_5numpy_float64_t;
1100 
1101 /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":713
1102  * # The int types are mapped a bit surprising --
1103  * # numpy.int corresponds to 'l' and numpy.long to 'q'
1104  * ctypedef npy_long       int_t             # <<<<<<<<<<<<<<
1105  * ctypedef npy_longlong   long_t
1106  * ctypedef npy_longlong   longlong_t
1107  */
1108 typedef npy_long __pyx_t_5numpy_int_t;
1109 
1110 /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":714
1111  * # numpy.int corresponds to 'l' and numpy.long to 'q'
1112  * ctypedef npy_long       int_t
1113  * ctypedef npy_longlong   long_t             # <<<<<<<<<<<<<<
1114  * ctypedef npy_longlong   longlong_t
1115  *
1116  */
1117 typedef npy_longlong __pyx_t_5numpy_long_t;
1118 
1119 /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":715
1120  * ctypedef npy_long       int_t
1121  * ctypedef npy_longlong   long_t
1122  * ctypedef npy_longlong   longlong_t             # <<<<<<<<<<<<<<
1123  *
1124  * ctypedef npy_ulong      uint_t
1125  */
1126 typedef npy_longlong __pyx_t_5numpy_longlong_t;
1127 
1128 /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":717
1129  * ctypedef npy_longlong   longlong_t
1130  *
1131  * ctypedef npy_ulong      uint_t             # <<<<<<<<<<<<<<
1132  * ctypedef npy_ulonglong  ulong_t
1133  * ctypedef npy_ulonglong  ulonglong_t
1134  */
1135 typedef npy_ulong __pyx_t_5numpy_uint_t;
1136 
1137 /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":718
1138  *
1139  * ctypedef npy_ulong      uint_t
1140  * ctypedef npy_ulonglong  ulong_t             # <<<<<<<<<<<<<<
1141  * ctypedef npy_ulonglong  ulonglong_t
1142  *
1143  */
1144 typedef npy_ulonglong __pyx_t_5numpy_ulong_t;
1145 
1146 /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":719
1147  * ctypedef npy_ulong      uint_t
1148  * ctypedef npy_ulonglong  ulong_t
1149  * ctypedef npy_ulonglong  ulonglong_t             # <<<<<<<<<<<<<<
1150  *
1151  * ctypedef npy_intp       intp_t
1152  */
1153 typedef npy_ulonglong __pyx_t_5numpy_ulonglong_t;
1154 
1155 /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":721
1156  * ctypedef npy_ulonglong  ulonglong_t
1157  *
1158  * ctypedef npy_intp       intp_t             # <<<<<<<<<<<<<<
1159  * ctypedef npy_uintp      uintp_t
1160  *
1161  */
1162 typedef npy_intp __pyx_t_5numpy_intp_t;
1163 
1164 /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":722
1165  *
1166  * ctypedef npy_intp       intp_t
1167  * ctypedef npy_uintp      uintp_t             # <<<<<<<<<<<<<<
1168  *
1169  * ctypedef npy_double     float_t
1170  */
1171 typedef npy_uintp __pyx_t_5numpy_uintp_t;
1172 
1173 /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":724
1174  * ctypedef npy_uintp      uintp_t
1175  *
1176  * ctypedef npy_double     float_t             # <<<<<<<<<<<<<<
1177  * ctypedef npy_double     double_t
1178  * ctypedef npy_longdouble longdouble_t
1179  */
1180 typedef npy_double __pyx_t_5numpy_float_t;
1181 
1182 /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":725
1183  *
1184  * ctypedef npy_double     float_t
1185  * ctypedef npy_double     double_t             # <<<<<<<<<<<<<<
1186  * ctypedef npy_longdouble longdouble_t
1187  *
1188  */
1189 typedef npy_double __pyx_t_5numpy_double_t;
1190 
1191 /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":726
1192  * ctypedef npy_double     float_t
1193  * ctypedef npy_double     double_t
1194  * ctypedef npy_longdouble longdouble_t             # <<<<<<<<<<<<<<
1195  *
1196  * ctypedef npy_cfloat      cfloat_t
1197  */
1198 typedef npy_longdouble __pyx_t_5numpy_longdouble_t;
1199 /* Declarations.proto */
1200 #if CYTHON_CCOMPLEX
1201   #ifdef __cplusplus
1202     typedef ::std::complex< double > __pyx_t_double_complex;
1203   #else
1204     typedef double _Complex __pyx_t_double_complex;
1205   #endif
1206 #else
1207     typedef struct { double real, imag; } __pyx_t_double_complex;
1208 #endif
1209 static CYTHON_INLINE __pyx_t_double_complex __pyx_t_double_complex_from_parts(double, double);
1210 
1211 /* Declarations.proto */
1212 #if CYTHON_CCOMPLEX
1213   #ifdef __cplusplus
1214     typedef ::std::complex< float > __pyx_t_float_complex;
1215   #else
1216     typedef float _Complex __pyx_t_float_complex;
1217   #endif
1218 #else
1219     typedef struct { float real, imag; } __pyx_t_float_complex;
1220 #endif
1221 static CYTHON_INLINE __pyx_t_float_complex __pyx_t_float_complex_from_parts(float, float);
1222 
1223 
1224 /*--- Type declarations ---*/
1225 struct __pyx_array_obj;
1226 struct __pyx_MemviewEnum_obj;
1227 struct __pyx_memoryview_obj;
1228 struct __pyx_memoryviewslice_obj;
1229 
1230 /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":728
1231  * ctypedef npy_longdouble longdouble_t
1232  *
1233  * ctypedef npy_cfloat      cfloat_t             # <<<<<<<<<<<<<<
1234  * ctypedef npy_cdouble     cdouble_t
1235  * ctypedef npy_clongdouble clongdouble_t
1236  */
1237 typedef npy_cfloat __pyx_t_5numpy_cfloat_t;
1238 
1239 /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":729
1240  *
1241  * ctypedef npy_cfloat      cfloat_t
1242  * ctypedef npy_cdouble     cdouble_t             # <<<<<<<<<<<<<<
1243  * ctypedef npy_clongdouble clongdouble_t
1244  *
1245  */
1246 typedef npy_cdouble __pyx_t_5numpy_cdouble_t;
1247 
1248 /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":730
1249  * ctypedef npy_cfloat      cfloat_t
1250  * ctypedef npy_cdouble     cdouble_t
1251  * ctypedef npy_clongdouble clongdouble_t             # <<<<<<<<<<<<<<
1252  *
1253  * ctypedef npy_cdouble     complex_t
1254  */
1255 typedef npy_clongdouble __pyx_t_5numpy_clongdouble_t;
1256 
1257 /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":732
1258  * ctypedef npy_clongdouble clongdouble_t
1259  *
1260  * ctypedef npy_cdouble     complex_t             # <<<<<<<<<<<<<<
1261  *
1262  * cdef inline object PyArray_MultiIterNew1(a):
1263  */
1264 typedef npy_cdouble __pyx_t_5numpy_complex_t;
1265 
1266 /* "qutip/cy/brtools.pxd":38
1267  *
1268  * #Spectral function with signature (w,t)
1269  * ctypedef complex (*spec_func)(double, double)             # <<<<<<<<<<<<<<
1270  *
1271  * cdef complex[::1,:] farray_alloc(int nrows)
1272  */
1273 typedef __pyx_t_double_complex (*__pyx_t_5qutip_2cy_7brtools_spec_func)(double, double);
1274 struct __pyx_t_5qutip_2cy_14sparse_structs__csr_mat;
1275 struct __pyx_t_5qutip_2cy_14sparse_structs__coo_mat;
1276 
1277 /* "qutip/cy/sparse_structs.pxd":35
1278  * ###############################################################################
1279  *
1280  * cdef struct _csr_mat:             # <<<<<<<<<<<<<<
1281  *     double complex * data
1282  *     int * indices
1283  */
1284 struct __pyx_t_5qutip_2cy_14sparse_structs__csr_mat {
1285   __pyx_t_double_complex *data;
1286   int *indices;
1287   int *indptr;
1288   int nnz;
1289   int nrows;
1290   int ncols;
1291   int is_set;
1292   int max_length;
1293   int numpy_lock;
1294 };
1295 
1296 /* "qutip/cy/sparse_structs.pxd":46
1297  *     int numpy_lock
1298  *
1299  * cdef struct _coo_mat:             # <<<<<<<<<<<<<<
1300  *     double complex * data
1301  *     int * rows
1302  */
1303 struct __pyx_t_5qutip_2cy_14sparse_structs__coo_mat {
1304   __pyx_t_double_complex *data;
1305   int *rows;
1306   int *cols;
1307   int nnz;
1308   int nrows;
1309   int ncols;
1310   int is_set;
1311   int max_length;
1312   int numpy_lock;
1313 };
1314 
1315 /* "qutip/cy/sparse_structs.pxd":57
1316  *     int numpy_lock
1317  *
1318  * ctypedef _csr_mat CSR_Matrix             # <<<<<<<<<<<<<<
1319  * ctypedef _coo_mat COO_Matrix
1320  */
1321 typedef struct __pyx_t_5qutip_2cy_14sparse_structs__csr_mat __pyx_t_5qutip_2cy_14sparse_structs_CSR_Matrix;
1322 
1323 /* "qutip/cy/sparse_structs.pxd":58
1324  *
1325  * ctypedef _csr_mat CSR_Matrix
1326  * ctypedef _coo_mat COO_Matrix             # <<<<<<<<<<<<<<
1327  */
1328 typedef struct __pyx_t_5qutip_2cy_14sparse_structs__coo_mat __pyx_t_5qutip_2cy_14sparse_structs_COO_Matrix;
1329 struct __pyx_t_5qutip_2cy_9br_tensor__data_ind_pair;
1330 struct __pyx_opt_args_5qutip_2cy_9br_tensor_raise_error_CSR;
1331 struct __pyx_opt_args_5qutip_2cy_9br_tensor_raise_error_COO;
1332 struct __pyx_opt_args_5qutip_2cy_9br_tensor_init_CSR;
1333 struct __pyx_opt_args_5qutip_2cy_9br_tensor_init_COO;
1334 struct __pyx_opt_args_5qutip_2cy_9br_tensor_expand_CSR;
1335 
1336 /* "qutip/cy/sparse_routines.pxi":54
1337  *
1338  * #Struct used for CSR indices sorting
1339  * cdef struct _data_ind_pair:             # <<<<<<<<<<<<<<
1340  *     double complex data
1341  *     int ind
1342  */
1343 struct __pyx_t_5qutip_2cy_9br_tensor__data_ind_pair {
1344   __pyx_t_double_complex data;
1345   int ind;
1346 };
1347 
1348 /* "qutip/cy/sparse_routines.pxi":58
1349  *     int ind
1350  *
1351  * ctypedef _data_ind_pair data_ind_pair             # <<<<<<<<<<<<<<
1352  * ctypedef int (*cfptr)(data_ind_pair, data_ind_pair)
1353  *
1354  */
1355 typedef struct __pyx_t_5qutip_2cy_9br_tensor__data_ind_pair __pyx_t_5qutip_2cy_9br_tensor_data_ind_pair;
1356 
1357 /* "qutip/cy/sparse_routines.pxi":59
1358  *
1359  * ctypedef _data_ind_pair data_ind_pair
1360  * ctypedef int (*cfptr)(data_ind_pair, data_ind_pair)             # <<<<<<<<<<<<<<
1361  *
1362  *
1363  */
1364 typedef int (*__pyx_t_5qutip_2cy_9br_tensor_cfptr)(__pyx_t_5qutip_2cy_9br_tensor_data_ind_pair, __pyx_t_5qutip_2cy_9br_tensor_data_ind_pair);
1365 
1366 /* "qutip/cy/sparse_routines.pxi":62
1367  *
1368  *
1369  * cdef void raise_error_CSR(int E, CSR_Matrix * C = NULL):             # <<<<<<<<<<<<<<
1370  *     if not C.numpy_lock and C != NULL:
1371  *         free_CSR(C)
1372  */
1373 struct __pyx_opt_args_5qutip_2cy_9br_tensor_raise_error_CSR {
1374   int __pyx_n;
1375   __pyx_t_5qutip_2cy_14sparse_structs_CSR_Matrix *C;
1376 };
1377 
1378 /* "qutip/cy/sparse_routines.pxi":83
1379  *
1380  *
1381  * cdef void raise_error_COO(int E, COO_Matrix * C = NULL):             # <<<<<<<<<<<<<<
1382  *     if not C.numpy_lock and C != NULL:
1383  *         free_COO(C)
1384  */
1385 struct __pyx_opt_args_5qutip_2cy_9br_tensor_raise_error_COO {
1386   int __pyx_n;
1387   __pyx_t_5qutip_2cy_14sparse_structs_COO_Matrix *C;
1388 };
1389 
1390 /* "qutip/cy/sparse_routines.pxi":113
1391  * @cython.boundscheck(False)
1392  * @cython.wraparound(False)
1393  * cdef void init_CSR(CSR_Matrix * mat, int nnz, int nrows, int ncols = 0,             # <<<<<<<<<<<<<<
1394  *                 int max_length = 0, int init_zeros = 1):
1395  *     """
1396  */
1397 struct __pyx_opt_args_5qutip_2cy_9br_tensor_init_CSR {
1398   int __pyx_n;
1399   int ncols;
1400   int max_length;
1401   int init_zeros;
1402 };
1403 
1404 /* "qutip/cy/sparse_routines.pxi":184
1405  * @cython.boundscheck(False)
1406  * @cython.wraparound(False)
1407  * cdef void init_COO(COO_Matrix * mat, int nnz, int nrows, int ncols = 0,             # <<<<<<<<<<<<<<
1408  *                 int max_length = 0, int init_zeros = 1):
1409  *     """
1410  */
1411 struct __pyx_opt_args_5qutip_2cy_9br_tensor_init_COO {
1412   int __pyx_n;
1413   int ncols;
1414   int max_length;
1415   int init_zeros;
1416 };
1417 
1418 /* "qutip/cy/sparse_routines.pxi":286
1419  * @cython.boundscheck(False)
1420  * @cython.wraparound(False)
1421  * cdef void expand_CSR(CSR_Matrix * mat, int init_zeros=0):             # <<<<<<<<<<<<<<
1422  *     """
1423  *     Expands the length of CSR data and indices arrays to accomodate
1424  */
1425 struct __pyx_opt_args_5qutip_2cy_9br_tensor_expand_CSR {
1426   int __pyx_n;
1427   int init_zeros;
1428 };
1429 
1430 /* "View.MemoryView":105
1431  *
1432  * @cname("__pyx_array")
1433  * cdef class array:             # <<<<<<<<<<<<<<
1434  *
1435  *     cdef:
1436  */
1437 struct __pyx_array_obj {
1438   PyObject_HEAD
1439   struct __pyx_vtabstruct_array *__pyx_vtab;
1440   char *data;
1441   Py_ssize_t len;
1442   char *format;
1443   int ndim;
1444   Py_ssize_t *_shape;
1445   Py_ssize_t *_strides;
1446   Py_ssize_t itemsize;
1447   PyObject *mode;
1448   PyObject *_format;
1449   void (*callback_free_data)(void *);
1450   int free_data;
1451   int dtype_is_object;
1452 };
1453 
1454 
1455 /* "View.MemoryView":279
1456  *
1457  * @cname('__pyx_MemviewEnum')
1458  * cdef class Enum(object):             # <<<<<<<<<<<<<<
1459  *     cdef object name
1460  *     def __init__(self, name):
1461  */
1462 struct __pyx_MemviewEnum_obj {
1463   PyObject_HEAD
1464   PyObject *name;
1465 };
1466 
1467 
1468 /* "View.MemoryView":330
1469  *
1470  * @cname('__pyx_memoryview')
1471  * cdef class memoryview(object):             # <<<<<<<<<<<<<<
1472  *
1473  *     cdef object obj
1474  */
1475 struct __pyx_memoryview_obj {
1476   PyObject_HEAD
1477   struct __pyx_vtabstruct_memoryview *__pyx_vtab;
1478   PyObject *obj;
1479   PyObject *_size;
1480   PyObject *_array_interface;
1481   PyThread_type_lock lock;
1482   __pyx_atomic_int acquisition_count[2];
1483   __pyx_atomic_int *acquisition_count_aligned_p;
1484   Py_buffer view;
1485   int flags;
1486   int dtype_is_object;
1487   __Pyx_TypeInfo *typeinfo;
1488 };
1489 
1490 
1491 /* "View.MemoryView":965
1492  *
1493  * @cname('__pyx_memoryviewslice')
1494  * cdef class _memoryviewslice(memoryview):             # <<<<<<<<<<<<<<
1495  *     "Internal class for passing memoryview slices to Python"
1496  *
1497  */
1498 struct __pyx_memoryviewslice_obj {
1499   struct __pyx_memoryview_obj __pyx_base;
1500   __Pyx_memviewslice from_slice;
1501   PyObject *from_object;
1502   PyObject *(*to_object_func)(char *);
1503   int (*to_dtype_func)(char *, PyObject *);
1504 };
1505 
1506 
1507 
1508 /* "View.MemoryView":105
1509  *
1510  * @cname("__pyx_array")
1511  * cdef class array:             # <<<<<<<<<<<<<<
1512  *
1513  *     cdef:
1514  */
1515 
1516 struct __pyx_vtabstruct_array {
1517   PyObject *(*get_memview)(struct __pyx_array_obj *);
1518 };
1519 static struct __pyx_vtabstruct_array *__pyx_vtabptr_array;
1520 
1521 
1522 /* "View.MemoryView":330
1523  *
1524  * @cname('__pyx_memoryview')
1525  * cdef class memoryview(object):             # <<<<<<<<<<<<<<
1526  *
1527  *     cdef object obj
1528  */
1529 
1530 struct __pyx_vtabstruct_memoryview {
1531   char *(*get_item_pointer)(struct __pyx_memoryview_obj *, PyObject *);
1532   PyObject *(*is_slice)(struct __pyx_memoryview_obj *, PyObject *);
1533   PyObject *(*setitem_slice_assignment)(struct __pyx_memoryview_obj *, PyObject *, PyObject *);
1534   PyObject *(*setitem_slice_assign_scalar)(struct __pyx_memoryview_obj *, struct __pyx_memoryview_obj *, PyObject *);
1535   PyObject *(*setitem_indexed)(struct __pyx_memoryview_obj *, PyObject *, PyObject *);
1536   PyObject *(*convert_item_to_object)(struct __pyx_memoryview_obj *, char *);
1537   PyObject *(*assign_item_from_object)(struct __pyx_memoryview_obj *, char *, PyObject *);
1538 };
1539 static struct __pyx_vtabstruct_memoryview *__pyx_vtabptr_memoryview;
1540 
1541 
1542 /* "View.MemoryView":965
1543  *
1544  * @cname('__pyx_memoryviewslice')
1545  * cdef class _memoryviewslice(memoryview):             # <<<<<<<<<<<<<<
1546  *     "Internal class for passing memoryview slices to Python"
1547  *
1548  */
1549 
1550 struct __pyx_vtabstruct__memoryviewslice {
1551   struct __pyx_vtabstruct_memoryview __pyx_base;
1552 };
1553 static struct __pyx_vtabstruct__memoryviewslice *__pyx_vtabptr__memoryviewslice;
1554 
1555 /* --- Runtime support code (head) --- */
1556 /* Refnanny.proto */
1557 #ifndef CYTHON_REFNANNY
1558   #define CYTHON_REFNANNY 0
1559 #endif
1560 #if CYTHON_REFNANNY
1561   typedef struct {
1562     void (*INCREF)(void*, PyObject*, int);
1563     void (*DECREF)(void*, PyObject*, int);
1564     void (*GOTREF)(void*, PyObject*, int);
1565     void (*GIVEREF)(void*, PyObject*, int);
1566     void* (*SetupContext)(const char*, int, const char*);
1567     void (*FinishContext)(void**);
1568   } __Pyx_RefNannyAPIStruct;
1569   static __Pyx_RefNannyAPIStruct *__Pyx_RefNanny = NULL;
1570   static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname);
1571   #define __Pyx_RefNannyDeclarations void *__pyx_refnanny = NULL;
1572 #ifdef WITH_THREAD
1573   #define __Pyx_RefNannySetupContext(name, acquire_gil)\
1574           if (acquire_gil) {\
1575               PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure();\
1576               __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__);\
1577               PyGILState_Release(__pyx_gilstate_save);\
1578           } else {\
1579               __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__);\
1580           }
1581 #else
1582   #define __Pyx_RefNannySetupContext(name, acquire_gil)\
1583           __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__)
1584 #endif
1585   #define __Pyx_RefNannyFinishContext()\
1586           __Pyx_RefNanny->FinishContext(&__pyx_refnanny)
1587   #define __Pyx_INCREF(r)  __Pyx_RefNanny->INCREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
1588   #define __Pyx_DECREF(r)  __Pyx_RefNanny->DECREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
1589   #define __Pyx_GOTREF(r)  __Pyx_RefNanny->GOTREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
1590   #define __Pyx_GIVEREF(r) __Pyx_RefNanny->GIVEREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
1591   #define __Pyx_XINCREF(r)  do { if((r) != NULL) {__Pyx_INCREF(r); }} while(0)
1592   #define __Pyx_XDECREF(r)  do { if((r) != NULL) {__Pyx_DECREF(r); }} while(0)
1593   #define __Pyx_XGOTREF(r)  do { if((r) != NULL) {__Pyx_GOTREF(r); }} while(0)
1594   #define __Pyx_XGIVEREF(r) do { if((r) != NULL) {__Pyx_GIVEREF(r);}} while(0)
1595 #else
1596   #define __Pyx_RefNannyDeclarations
1597   #define __Pyx_RefNannySetupContext(name, acquire_gil)
1598   #define __Pyx_RefNannyFinishContext()
1599   #define __Pyx_INCREF(r) Py_INCREF(r)
1600   #define __Pyx_DECREF(r) Py_DECREF(r)
1601   #define __Pyx_GOTREF(r)
1602   #define __Pyx_GIVEREF(r)
1603   #define __Pyx_XINCREF(r) Py_XINCREF(r)
1604   #define __Pyx_XDECREF(r) Py_XDECREF(r)
1605   #define __Pyx_XGOTREF(r)
1606   #define __Pyx_XGIVEREF(r)
1607 #endif
1608 #define __Pyx_XDECREF_SET(r, v) do {\
1609         PyObject *tmp = (PyObject *) r;\
1610         r = v; __Pyx_XDECREF(tmp);\
1611     } while (0)
1612 #define __Pyx_DECREF_SET(r, v) do {\
1613         PyObject *tmp = (PyObject *) r;\
1614         r = v; __Pyx_DECREF(tmp);\
1615     } while (0)
1616 #define __Pyx_CLEAR(r)    do { PyObject* tmp = ((PyObject*)(r)); r = NULL; __Pyx_DECREF(tmp);} while(0)
1617 #define __Pyx_XCLEAR(r)   do { if((r) != NULL) {PyObject* tmp = ((PyObject*)(r)); r = NULL; __Pyx_DECREF(tmp);}} while(0)
1618 
1619 /* PyObjectGetAttrStr.proto */
1620 #if CYTHON_USE_TYPE_SLOTS
1621 static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStr(PyObject* obj, PyObject* attr_name);
1622 #else
1623 #define __Pyx_PyObject_GetAttrStr(o,n) PyObject_GetAttr(o,n)
1624 #endif
1625 
1626 /* GetBuiltinName.proto */
1627 static PyObject *__Pyx_GetBuiltinName(PyObject *name);
1628 
1629 /* PyObjectCall.proto */
1630 #if CYTHON_COMPILING_IN_CPYTHON
1631 static CYTHON_INLINE PyObject* __Pyx_PyObject_Call(PyObject *func, PyObject *arg, PyObject *kw);
1632 #else
1633 #define __Pyx_PyObject_Call(func, arg, kw) PyObject_Call(func, arg, kw)
1634 #endif
1635 
1636 /* PyThreadStateGet.proto */
1637 #if CYTHON_FAST_THREAD_STATE
1638 #define __Pyx_PyThreadState_declare  PyThreadState *__pyx_tstate;
1639 #define __Pyx_PyThreadState_assign  __pyx_tstate = __Pyx_PyThreadState_Current;
1640 #define __Pyx_PyErr_Occurred()  __pyx_tstate->curexc_type
1641 #else
1642 #define __Pyx_PyThreadState_declare
1643 #define __Pyx_PyThreadState_assign
1644 #define __Pyx_PyErr_Occurred()  PyErr_Occurred()
1645 #endif
1646 
1647 /* PyErrFetchRestore.proto */
1648 #if CYTHON_FAST_THREAD_STATE
1649 #define __Pyx_PyErr_Clear() __Pyx_ErrRestore(NULL, NULL, NULL)
1650 #define __Pyx_ErrRestoreWithState(type, value, tb)  __Pyx_ErrRestoreInState(PyThreadState_GET(), type, value, tb)
1651 #define __Pyx_ErrFetchWithState(type, value, tb)    __Pyx_ErrFetchInState(PyThreadState_GET(), type, value, tb)
1652 #define __Pyx_ErrRestore(type, value, tb)  __Pyx_ErrRestoreInState(__pyx_tstate, type, value, tb)
1653 #define __Pyx_ErrFetch(type, value, tb)    __Pyx_ErrFetchInState(__pyx_tstate, type, value, tb)
1654 static CYTHON_INLINE void __Pyx_ErrRestoreInState(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb);
1655 static CYTHON_INLINE void __Pyx_ErrFetchInState(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb);
1656 #if CYTHON_COMPILING_IN_CPYTHON
1657 #define __Pyx_PyErr_SetNone(exc) (Py_INCREF(exc), __Pyx_ErrRestore((exc), NULL, NULL))
1658 #else
1659 #define __Pyx_PyErr_SetNone(exc) PyErr_SetNone(exc)
1660 #endif
1661 #else
1662 #define __Pyx_PyErr_Clear() PyErr_Clear()
1663 #define __Pyx_PyErr_SetNone(exc) PyErr_SetNone(exc)
1664 #define __Pyx_ErrRestoreWithState(type, value, tb)  PyErr_Restore(type, value, tb)
1665 #define __Pyx_ErrFetchWithState(type, value, tb)  PyErr_Fetch(type, value, tb)
1666 #define __Pyx_ErrRestoreInState(tstate, type, value, tb)  PyErr_Restore(type, value, tb)
1667 #define __Pyx_ErrFetchInState(tstate, type, value, tb)  PyErr_Fetch(type, value, tb)
1668 #define __Pyx_ErrRestore(type, value, tb)  PyErr_Restore(type, value, tb)
1669 #define __Pyx_ErrFetch(type, value, tb)  PyErr_Fetch(type, value, tb)
1670 #endif
1671 
1672 /* RaiseException.proto */
1673 static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause);
1674 
1675 /* WriteUnraisableException.proto */
1676 static void __Pyx_WriteUnraisable(const char *name, int clineno,
1677                                   int lineno, const char *filename,
1678                                   int full_traceback, int nogil);
1679 
1680 /* ExtTypeTest.proto */
1681 static CYTHON_INLINE int __Pyx_TypeTest(PyObject *obj, PyTypeObject *type);
1682 
1683 /* IsLittleEndian.proto */
1684 static CYTHON_INLINE int __Pyx_Is_Little_Endian(void);
1685 
1686 /* BufferFormatCheck.proto */
1687 static const char* __Pyx_BufFmt_CheckString(__Pyx_BufFmt_Context* ctx, const char* ts);
1688 static void __Pyx_BufFmt_Init(__Pyx_BufFmt_Context* ctx,
1689                               __Pyx_BufFmt_StackElem* stack,
1690                               __Pyx_TypeInfo* type);
1691 
1692 /* BufferGetAndValidate.proto */
1693 #define __Pyx_GetBufferAndValidate(buf, obj, dtype, flags, nd, cast, stack)\
1694     ((obj == Py_None || obj == NULL) ?\
1695     (__Pyx_ZeroBuffer(buf), 0) :\
1696     __Pyx__GetBufferAndValidate(buf, obj, dtype, flags, nd, cast, stack))
1697 static int  __Pyx__GetBufferAndValidate(Py_buffer* buf, PyObject* obj,
1698     __Pyx_TypeInfo* dtype, int flags, int nd, int cast, __Pyx_BufFmt_StackElem* stack);
1699 static void __Pyx_ZeroBuffer(Py_buffer* buf);
1700 static CYTHON_INLINE void __Pyx_SafeReleaseBuffer(Py_buffer* info);
1701 static Py_ssize_t __Pyx_minusones[] = { -1, -1, -1, -1, -1, -1, -1, -1 };
1702 static Py_ssize_t __Pyx_zeros[] = { 0, 0, 0, 0, 0, 0, 0, 0 };
1703 
1704 /* BufferFallbackError.proto */
1705 static void __Pyx_RaiseBufferFallbackError(void);
1706 
1707 /* PyDictVersioning.proto */
1708 #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_TYPE_SLOTS
1709 #define __PYX_DICT_VERSION_INIT  ((PY_UINT64_T) -1)
1710 #define __PYX_GET_DICT_VERSION(dict)  (((PyDictObject*)(dict))->ma_version_tag)
1711 #define __PYX_UPDATE_DICT_CACHE(dict, value, cache_var, version_var)\
1712     (version_var) = __PYX_GET_DICT_VERSION(dict);\
1713     (cache_var) = (value);
1714 #define __PYX_PY_DICT_LOOKUP_IF_MODIFIED(VAR, DICT, LOOKUP) {\
1715     static PY_UINT64_T __pyx_dict_version = 0;\
1716     static PyObject *__pyx_dict_cached_value = NULL;\
1717     if (likely(__PYX_GET_DICT_VERSION(DICT) == __pyx_dict_version)) {\
1718         (VAR) = __pyx_dict_cached_value;\
1719     } else {\
1720         (VAR) = __pyx_dict_cached_value = (LOOKUP);\
1721         __pyx_dict_version = __PYX_GET_DICT_VERSION(DICT);\
1722     }\
1723 }
1724 static CYTHON_INLINE PY_UINT64_T __Pyx_get_tp_dict_version(PyObject *obj);
1725 static CYTHON_INLINE PY_UINT64_T __Pyx_get_object_dict_version(PyObject *obj);
1726 static CYTHON_INLINE int __Pyx_object_dict_version_matches(PyObject* obj, PY_UINT64_T tp_dict_version, PY_UINT64_T obj_dict_version);
1727 #else
1728 #define __PYX_GET_DICT_VERSION(dict)  (0)
1729 #define __PYX_UPDATE_DICT_CACHE(dict, value, cache_var, version_var)
1730 #define __PYX_PY_DICT_LOOKUP_IF_MODIFIED(VAR, DICT, LOOKUP)  (VAR) = (LOOKUP);
1731 #endif
1732 
1733 /* GetModuleGlobalName.proto */
1734 #if CYTHON_USE_DICT_VERSIONS
1735 #define __Pyx_GetModuleGlobalName(var, name)  {\
1736     static PY_UINT64_T __pyx_dict_version = 0;\
1737     static PyObject *__pyx_dict_cached_value = NULL;\
1738     (var) = (likely(__pyx_dict_version == __PYX_GET_DICT_VERSION(__pyx_d))) ?\
1739         (likely(__pyx_dict_cached_value) ? __Pyx_NewRef(__pyx_dict_cached_value) : __Pyx_GetBuiltinName(name)) :\
1740         __Pyx__GetModuleGlobalName(name, &__pyx_dict_version, &__pyx_dict_cached_value);\
1741 }
1742 #define __Pyx_GetModuleGlobalNameUncached(var, name)  {\
1743     PY_UINT64_T __pyx_dict_version;\
1744     PyObject *__pyx_dict_cached_value;\
1745     (var) = __Pyx__GetModuleGlobalName(name, &__pyx_dict_version, &__pyx_dict_cached_value);\
1746 }
1747 static PyObject *__Pyx__GetModuleGlobalName(PyObject *name, PY_UINT64_T *dict_version, PyObject **dict_cached_value);
1748 #else
1749 #define __Pyx_GetModuleGlobalName(var, name)  (var) = __Pyx__GetModuleGlobalName(name)
1750 #define __Pyx_GetModuleGlobalNameUncached(var, name)  (var) = __Pyx__GetModuleGlobalName(name)
1751 static CYTHON_INLINE PyObject *__Pyx__GetModuleGlobalName(PyObject *name);
1752 #endif
1753 
1754 /* GetItemInt.proto */
1755 #define __Pyx_GetItemInt(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck)\
1756     (__Pyx_fits_Py_ssize_t(i, type, is_signed) ?\
1757     __Pyx_GetItemInt_Fast(o, (Py_ssize_t)i, is_list, wraparound, boundscheck) :\
1758     (is_list ? (PyErr_SetString(PyExc_IndexError, "list index out of range"), (PyObject*)NULL) :\
1759                __Pyx_GetItemInt_Generic(o, to_py_func(i))))
1760 #define __Pyx_GetItemInt_List(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck)\
1761     (__Pyx_fits_Py_ssize_t(i, type, is_signed) ?\
1762     __Pyx_GetItemInt_List_Fast(o, (Py_ssize_t)i, wraparound, boundscheck) :\
1763     (PyErr_SetString(PyExc_IndexError, "list index out of range"), (PyObject*)NULL))
1764 static CYTHON_INLINE PyObject *__Pyx_GetItemInt_List_Fast(PyObject *o, Py_ssize_t i,
1765                                                               int wraparound, int boundscheck);
1766 #define __Pyx_GetItemInt_Tuple(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck)\
1767     (__Pyx_fits_Py_ssize_t(i, type, is_signed) ?\
1768     __Pyx_GetItemInt_Tuple_Fast(o, (Py_ssize_t)i, wraparound, boundscheck) :\
1769     (PyErr_SetString(PyExc_IndexError, "tuple index out of range"), (PyObject*)NULL))
1770 static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Tuple_Fast(PyObject *o, Py_ssize_t i,
1771                                                               int wraparound, int boundscheck);
1772 static PyObject *__Pyx_GetItemInt_Generic(PyObject *o, PyObject* j);
1773 static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Fast(PyObject *o, Py_ssize_t i,
1774                                                      int is_list, int wraparound, int boundscheck);
1775 
1776 /* MemviewSliceInit.proto */
1777 #define __Pyx_BUF_MAX_NDIMS %(BUF_MAX_NDIMS)d
1778 #define __Pyx_MEMVIEW_DIRECT   1
1779 #define __Pyx_MEMVIEW_PTR      2
1780 #define __Pyx_MEMVIEW_FULL     4
1781 #define __Pyx_MEMVIEW_CONTIG   8
1782 #define __Pyx_MEMVIEW_STRIDED  16
1783 #define __Pyx_MEMVIEW_FOLLOW   32
1784 #define __Pyx_IS_C_CONTIG 1
1785 #define __Pyx_IS_F_CONTIG 2
1786 static int __Pyx_init_memviewslice(
1787                 struct __pyx_memoryview_obj *memview,
1788                 int ndim,
1789                 __Pyx_memviewslice *memviewslice,
1790                 int memview_is_new_reference);
1791 static CYTHON_INLINE int __pyx_add_acquisition_count_locked(
1792     __pyx_atomic_int *acquisition_count, PyThread_type_lock lock);
1793 static CYTHON_INLINE int __pyx_sub_acquisition_count_locked(
1794     __pyx_atomic_int *acquisition_count, PyThread_type_lock lock);
1795 #define __pyx_get_slice_count_pointer(memview) (memview->acquisition_count_aligned_p)
1796 #define __pyx_get_slice_count(memview) (*__pyx_get_slice_count_pointer(memview))
1797 #define __PYX_INC_MEMVIEW(slice, have_gil) __Pyx_INC_MEMVIEW(slice, have_gil, __LINE__)
1798 #define __PYX_XDEC_MEMVIEW(slice, have_gil) __Pyx_XDEC_MEMVIEW(slice, have_gil, __LINE__)
1799 static CYTHON_INLINE void __Pyx_INC_MEMVIEW(__Pyx_memviewslice *, int, int);
1800 static CYTHON_INLINE void __Pyx_XDEC_MEMVIEW(__Pyx_memviewslice *, int, int);
1801 
1802 /* RaiseArgTupleInvalid.proto */
1803 static void __Pyx_RaiseArgtupleInvalid(const char* func_name, int exact,
1804     Py_ssize_t num_min, Py_ssize_t num_max, Py_ssize_t num_found);
1805 
1806 /* RaiseDoubleKeywords.proto */
1807 static void __Pyx_RaiseDoubleKeywordsError(const char* func_name, PyObject* kw_name);
1808 
1809 /* ParseKeywords.proto */
1810 static int __Pyx_ParseOptionalKeywords(PyObject *kwds, PyObject **argnames[],\
1811     PyObject *kwds2, PyObject *values[], Py_ssize_t num_pos_args,\
1812     const char* function_name);
1813 
1814 /* PyCFunctionFastCall.proto */
1815 #if CYTHON_FAST_PYCCALL
1816 static CYTHON_INLINE PyObject *__Pyx_PyCFunction_FastCall(PyObject *func, PyObject **args, Py_ssize_t nargs);
1817 #else
1818 #define __Pyx_PyCFunction_FastCall(func, args, nargs)  (assert(0), NULL)
1819 #endif
1820 
1821 /* PyFunctionFastCall.proto */
1822 #if CYTHON_FAST_PYCALL
1823 #define __Pyx_PyFunction_FastCall(func, args, nargs)\
1824     __Pyx_PyFunction_FastCallDict((func), (args), (nargs), NULL)
1825 #if 1 || PY_VERSION_HEX < 0x030600B1
1826 static PyObject *__Pyx_PyFunction_FastCallDict(PyObject *func, PyObject **args, Py_ssize_t nargs, PyObject *kwargs);
1827 #else
1828 #define __Pyx_PyFunction_FastCallDict(func, args, nargs, kwargs) _PyFunction_FastCallDict(func, args, nargs, kwargs)
1829 #endif
1830 #define __Pyx_BUILD_ASSERT_EXPR(cond)\
1831     (sizeof(char [1 - 2*!(cond)]) - 1)
1832 #ifndef Py_MEMBER_SIZE
1833 #define Py_MEMBER_SIZE(type, member) sizeof(((type *)0)->member)
1834 #endif
1835   static size_t __pyx_pyframe_localsplus_offset = 0;
1836   #include "frameobject.h"
1837   #define __Pxy_PyFrame_Initialize_Offsets()\
1838     ((void)__Pyx_BUILD_ASSERT_EXPR(sizeof(PyFrameObject) == offsetof(PyFrameObject, f_localsplus) + Py_MEMBER_SIZE(PyFrameObject, f_localsplus)),\
1839      (void)(__pyx_pyframe_localsplus_offset = ((size_t)PyFrame_Type.tp_basicsize) - Py_MEMBER_SIZE(PyFrameObject, f_localsplus)))
1840   #define __Pyx_PyFrame_GetLocalsplus(frame)\
1841     (assert(__pyx_pyframe_localsplus_offset), (PyObject **)(((char *)(frame)) + __pyx_pyframe_localsplus_offset))
1842 #endif
1843 
1844 /* PyObjectCall2Args.proto */
1845 static CYTHON_UNUSED PyObject* __Pyx_PyObject_Call2Args(PyObject* function, PyObject* arg1, PyObject* arg2);
1846 
1847 /* PyObjectCallMethO.proto */
1848 #if CYTHON_COMPILING_IN_CPYTHON
1849 static CYTHON_INLINE PyObject* __Pyx_PyObject_CallMethO(PyObject *func, PyObject *arg);
1850 #endif
1851 
1852 /* PyObjectCallOneArg.proto */
1853 static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg);
1854 
1855 /* ArgTypeTest.proto */
1856 #define __Pyx_ArgTypeTest(obj, type, none_allowed, name, exact)\
1857     ((likely((Py_TYPE(obj) == type) | (none_allowed && (obj == Py_None)))) ? 1 :\
1858         __Pyx__ArgTypeTest(obj, type, name, exact))
1859 static int __Pyx__ArgTypeTest(PyObject *obj, PyTypeObject *type, const char *name, int exact);
1860 
1861 /* ListAppend.proto */
1862 #if CYTHON_USE_PYLIST_INTERNALS && CYTHON_ASSUME_SAFE_MACROS
__Pyx_PyList_Append(PyObject * list,PyObject * x)1863 static CYTHON_INLINE int __Pyx_PyList_Append(PyObject* list, PyObject* x) {
1864     PyListObject* L = (PyListObject*) list;
1865     Py_ssize_t len = Py_SIZE(list);
1866     if (likely(L->allocated > len) & likely(len > (L->allocated >> 1))) {
1867         Py_INCREF(x);
1868         PyList_SET_ITEM(list, len, x);
1869         __Pyx_SET_SIZE(list, len + 1);
1870         return 0;
1871     }
1872     return PyList_Append(list, x);
1873 }
1874 #else
1875 #define __Pyx_PyList_Append(L,x) PyList_Append(L,x)
1876 #endif
1877 
1878 /* ListCompAppend.proto */
1879 #if CYTHON_USE_PYLIST_INTERNALS && CYTHON_ASSUME_SAFE_MACROS
__Pyx_ListComp_Append(PyObject * list,PyObject * x)1880 static CYTHON_INLINE int __Pyx_ListComp_Append(PyObject* list, PyObject* x) {
1881     PyListObject* L = (PyListObject*) list;
1882     Py_ssize_t len = Py_SIZE(list);
1883     if (likely(L->allocated > len)) {
1884         Py_INCREF(x);
1885         PyList_SET_ITEM(list, len, x);
1886         __Pyx_SET_SIZE(list, len + 1);
1887         return 0;
1888     }
1889     return PyList_Append(list, x);
1890 }
1891 #else
1892 #define __Pyx_ListComp_Append(L,x) PyList_Append(L,x)
1893 #endif
1894 
1895 /* GetTopmostException.proto */
1896 #if CYTHON_USE_EXC_INFO_STACK
1897 static _PyErr_StackItem * __Pyx_PyErr_GetTopmostException(PyThreadState *tstate);
1898 #endif
1899 
1900 /* SaveResetException.proto */
1901 #if CYTHON_FAST_THREAD_STATE
1902 #define __Pyx_ExceptionSave(type, value, tb)  __Pyx__ExceptionSave(__pyx_tstate, type, value, tb)
1903 static CYTHON_INLINE void __Pyx__ExceptionSave(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb);
1904 #define __Pyx_ExceptionReset(type, value, tb)  __Pyx__ExceptionReset(__pyx_tstate, type, value, tb)
1905 static CYTHON_INLINE void __Pyx__ExceptionReset(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb);
1906 #else
1907 #define __Pyx_ExceptionSave(type, value, tb)   PyErr_GetExcInfo(type, value, tb)
1908 #define __Pyx_ExceptionReset(type, value, tb)  PyErr_SetExcInfo(type, value, tb)
1909 #endif
1910 
1911 /* PyErrExceptionMatches.proto */
1912 #if CYTHON_FAST_THREAD_STATE
1913 #define __Pyx_PyErr_ExceptionMatches(err) __Pyx_PyErr_ExceptionMatchesInState(__pyx_tstate, err)
1914 static CYTHON_INLINE int __Pyx_PyErr_ExceptionMatchesInState(PyThreadState* tstate, PyObject* err);
1915 #else
1916 #define __Pyx_PyErr_ExceptionMatches(err)  PyErr_ExceptionMatches(err)
1917 #endif
1918 
1919 /* GetException.proto */
1920 #if CYTHON_FAST_THREAD_STATE
1921 #define __Pyx_GetException(type, value, tb)  __Pyx__GetException(__pyx_tstate, type, value, tb)
1922 static int __Pyx__GetException(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb);
1923 #else
1924 static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb);
1925 #endif
1926 
1927 /* IncludeStringH.proto */
1928 #include <string.h>
1929 
1930 /* BytesEquals.proto */
1931 static CYTHON_INLINE int __Pyx_PyBytes_Equals(PyObject* s1, PyObject* s2, int equals);
1932 
1933 /* UnicodeEquals.proto */
1934 static CYTHON_INLINE int __Pyx_PyUnicode_Equals(PyObject* s1, PyObject* s2, int equals);
1935 
1936 /* StrEquals.proto */
1937 #if PY_MAJOR_VERSION >= 3
1938 #define __Pyx_PyString_Equals __Pyx_PyUnicode_Equals
1939 #else
1940 #define __Pyx_PyString_Equals __Pyx_PyBytes_Equals
1941 #endif
1942 
1943 /* None.proto */
1944 static CYTHON_INLINE Py_ssize_t __Pyx_div_Py_ssize_t(Py_ssize_t, Py_ssize_t);
1945 
1946 /* UnaryNegOverflows.proto */
1947 #define UNARY_NEG_WOULD_OVERFLOW(x)\
1948         (((x) < 0) & ((unsigned long)(x) == 0-(unsigned long)(x)))
1949 
1950 static CYTHON_UNUSED int __pyx_array_getbuffer(PyObject *__pyx_v_self, Py_buffer *__pyx_v_info, int __pyx_v_flags); /*proto*/
1951 static PyObject *__pyx_array_get_memview(struct __pyx_array_obj *); /*proto*/
1952 /* GetAttr.proto */
1953 static CYTHON_INLINE PyObject *__Pyx_GetAttr(PyObject *, PyObject *);
1954 
1955 /* ObjectGetItem.proto */
1956 #if CYTHON_USE_TYPE_SLOTS
1957 static CYTHON_INLINE PyObject *__Pyx_PyObject_GetItem(PyObject *obj, PyObject* key);
1958 #else
1959 #define __Pyx_PyObject_GetItem(obj, key)  PyObject_GetItem(obj, key)
1960 #endif
1961 
1962 /* decode_c_string_utf16.proto */
__Pyx_PyUnicode_DecodeUTF16(const char * s,Py_ssize_t size,const char * errors)1963 static CYTHON_INLINE PyObject *__Pyx_PyUnicode_DecodeUTF16(const char *s, Py_ssize_t size, const char *errors) {
1964     int byteorder = 0;
1965     return PyUnicode_DecodeUTF16(s, size, errors, &byteorder);
1966 }
__Pyx_PyUnicode_DecodeUTF16LE(const char * s,Py_ssize_t size,const char * errors)1967 static CYTHON_INLINE PyObject *__Pyx_PyUnicode_DecodeUTF16LE(const char *s, Py_ssize_t size, const char *errors) {
1968     int byteorder = -1;
1969     return PyUnicode_DecodeUTF16(s, size, errors, &byteorder);
1970 }
__Pyx_PyUnicode_DecodeUTF16BE(const char * s,Py_ssize_t size,const char * errors)1971 static CYTHON_INLINE PyObject *__Pyx_PyUnicode_DecodeUTF16BE(const char *s, Py_ssize_t size, const char *errors) {
1972     int byteorder = 1;
1973     return PyUnicode_DecodeUTF16(s, size, errors, &byteorder);
1974 }
1975 
1976 /* decode_c_string.proto */
1977 static CYTHON_INLINE PyObject* __Pyx_decode_c_string(
1978          const char* cstring, Py_ssize_t start, Py_ssize_t stop,
1979          const char* encoding, const char* errors,
1980          PyObject* (*decode_func)(const char *s, Py_ssize_t size, const char *errors));
1981 
1982 /* GetAttr3.proto */
1983 static CYTHON_INLINE PyObject *__Pyx_GetAttr3(PyObject *, PyObject *, PyObject *);
1984 
1985 /* RaiseTooManyValuesToUnpack.proto */
1986 static CYTHON_INLINE void __Pyx_RaiseTooManyValuesError(Py_ssize_t expected);
1987 
1988 /* RaiseNeedMoreValuesToUnpack.proto */
1989 static CYTHON_INLINE void __Pyx_RaiseNeedMoreValuesError(Py_ssize_t index);
1990 
1991 /* RaiseNoneIterError.proto */
1992 static CYTHON_INLINE void __Pyx_RaiseNoneNotIterableError(void);
1993 
1994 /* SwapException.proto */
1995 #if CYTHON_FAST_THREAD_STATE
1996 #define __Pyx_ExceptionSwap(type, value, tb)  __Pyx__ExceptionSwap(__pyx_tstate, type, value, tb)
1997 static CYTHON_INLINE void __Pyx__ExceptionSwap(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb);
1998 #else
1999 static CYTHON_INLINE void __Pyx_ExceptionSwap(PyObject **type, PyObject **value, PyObject **tb);
2000 #endif
2001 
2002 /* Import.proto */
2003 static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, int level);
2004 
2005 /* FastTypeChecks.proto */
2006 #if CYTHON_COMPILING_IN_CPYTHON
2007 #define __Pyx_TypeCheck(obj, type) __Pyx_IsSubtype(Py_TYPE(obj), (PyTypeObject *)type)
2008 static CYTHON_INLINE int __Pyx_IsSubtype(PyTypeObject *a, PyTypeObject *b);
2009 static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches(PyObject *err, PyObject *type);
2010 static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches2(PyObject *err, PyObject *type1, PyObject *type2);
2011 #else
2012 #define __Pyx_TypeCheck(obj, type) PyObject_TypeCheck(obj, (PyTypeObject *)type)
2013 #define __Pyx_PyErr_GivenExceptionMatches(err, type) PyErr_GivenExceptionMatches(err, type)
2014 #define __Pyx_PyErr_GivenExceptionMatches2(err, type1, type2) (PyErr_GivenExceptionMatches(err, type1) || PyErr_GivenExceptionMatches(err, type2))
2015 #endif
2016 #define __Pyx_PyException_Check(obj) __Pyx_TypeCheck(obj, PyExc_Exception)
2017 
2018 static CYTHON_UNUSED int __pyx_memoryview_getbuffer(PyObject *__pyx_v_self, Py_buffer *__pyx_v_info, int __pyx_v_flags); /*proto*/
2019 /* PyIntBinop.proto */
2020 #if !CYTHON_COMPILING_IN_PYPY
2021 static PyObject* __Pyx_PyInt_AddObjC(PyObject *op1, PyObject *op2, long intval, int inplace, int zerodivision_check);
2022 #else
2023 #define __Pyx_PyInt_AddObjC(op1, op2, intval, inplace, zerodivision_check)\
2024     (inplace ? PyNumber_InPlaceAdd(op1, op2) : PyNumber_Add(op1, op2))
2025 #endif
2026 
2027 /* ListExtend.proto */
__Pyx_PyList_Extend(PyObject * L,PyObject * v)2028 static CYTHON_INLINE int __Pyx_PyList_Extend(PyObject* L, PyObject* v) {
2029 #if CYTHON_COMPILING_IN_CPYTHON
2030     PyObject* none = _PyList_Extend((PyListObject*)L, v);
2031     if (unlikely(!none))
2032         return -1;
2033     Py_DECREF(none);
2034     return 0;
2035 #else
2036     return PyList_SetSlice(L, PY_SSIZE_T_MAX, PY_SSIZE_T_MAX, v);
2037 #endif
2038 }
2039 
2040 /* None.proto */
2041 static CYTHON_INLINE void __Pyx_RaiseUnboundLocalError(const char *varname);
2042 
2043 /* None.proto */
2044 static CYTHON_INLINE long __Pyx_div_long(long, long);
2045 
2046 /* ImportFrom.proto */
2047 static PyObject* __Pyx_ImportFrom(PyObject* module, PyObject* name);
2048 
2049 /* HasAttr.proto */
2050 static CYTHON_INLINE int __Pyx_HasAttr(PyObject *, PyObject *);
2051 
2052 /* PyObject_GenericGetAttrNoDict.proto */
2053 #if CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP && PY_VERSION_HEX < 0x03070000
2054 static CYTHON_INLINE PyObject* __Pyx_PyObject_GenericGetAttrNoDict(PyObject* obj, PyObject* attr_name);
2055 #else
2056 #define __Pyx_PyObject_GenericGetAttrNoDict PyObject_GenericGetAttr
2057 #endif
2058 
2059 /* PyObject_GenericGetAttr.proto */
2060 #if CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP && PY_VERSION_HEX < 0x03070000
2061 static PyObject* __Pyx_PyObject_GenericGetAttr(PyObject* obj, PyObject* attr_name);
2062 #else
2063 #define __Pyx_PyObject_GenericGetAttr PyObject_GenericGetAttr
2064 #endif
2065 
2066 /* SetVTable.proto */
2067 static int __Pyx_SetVtable(PyObject *dict, void *vtable);
2068 
2069 /* PyObjectGetAttrStrNoError.proto */
2070 static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStrNoError(PyObject* obj, PyObject* attr_name);
2071 
2072 /* SetupReduce.proto */
2073 static int __Pyx_setup_reduce(PyObject* type_obj);
2074 
2075 /* TypeImport.proto */
2076 #ifndef __PYX_HAVE_RT_ImportType_proto
2077 #define __PYX_HAVE_RT_ImportType_proto
2078 enum __Pyx_ImportType_CheckSize {
2079    __Pyx_ImportType_CheckSize_Error = 0,
2080    __Pyx_ImportType_CheckSize_Warn = 1,
2081    __Pyx_ImportType_CheckSize_Ignore = 2
2082 };
2083 static PyTypeObject *__Pyx_ImportType(PyObject* module, const char *module_name, const char *class_name, size_t size, enum __Pyx_ImportType_CheckSize check_size);
2084 #endif
2085 
2086 /* CLineInTraceback.proto */
2087 #ifdef CYTHON_CLINE_IN_TRACEBACK
2088 #define __Pyx_CLineForTraceback(tstate, c_line)  (((CYTHON_CLINE_IN_TRACEBACK)) ? c_line : 0)
2089 #else
2090 static int __Pyx_CLineForTraceback(PyThreadState *tstate, int c_line);
2091 #endif
2092 
2093 /* CodeObjectCache.proto */
2094 typedef struct {
2095     PyCodeObject* code_object;
2096     int code_line;
2097 } __Pyx_CodeObjectCacheEntry;
2098 struct __Pyx_CodeObjectCache {
2099     int count;
2100     int max_count;
2101     __Pyx_CodeObjectCacheEntry* entries;
2102 };
2103 static struct __Pyx_CodeObjectCache __pyx_code_cache = {0,0,NULL};
2104 static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line);
2105 static PyCodeObject *__pyx_find_code_object(int code_line);
2106 static void __pyx_insert_code_object(int code_line, PyCodeObject* code_object);
2107 
2108 /* AddTraceback.proto */
2109 static void __Pyx_AddTraceback(const char *funcname, int c_line,
2110                                int py_line, const char *filename);
2111 
2112 /* RealImag.proto */
2113 #if CYTHON_CCOMPLEX
2114   #ifdef __cplusplus
2115     #define __Pyx_CREAL(z) ((z).real())
2116     #define __Pyx_CIMAG(z) ((z).imag())
2117   #else
2118     #define __Pyx_CREAL(z) (__real__(z))
2119     #define __Pyx_CIMAG(z) (__imag__(z))
2120   #endif
2121 #else
2122     #define __Pyx_CREAL(z) ((z).real)
2123     #define __Pyx_CIMAG(z) ((z).imag)
2124 #endif
2125 #if defined(__cplusplus) && CYTHON_CCOMPLEX\
2126         && (defined(_WIN32) || defined(__clang__) || (defined(__GNUC__) && (__GNUC__ >= 5 || __GNUC__ == 4 && __GNUC_MINOR__ >= 4 )) || __cplusplus >= 201103)
2127     #define __Pyx_SET_CREAL(z,x) ((z).real(x))
2128     #define __Pyx_SET_CIMAG(z,y) ((z).imag(y))
2129 #else
2130     #define __Pyx_SET_CREAL(z,x) __Pyx_CREAL(z) = (x)
2131     #define __Pyx_SET_CIMAG(z,y) __Pyx_CIMAG(z) = (y)
2132 #endif
2133 
2134 /* Arithmetic.proto */
2135 #if CYTHON_CCOMPLEX
2136     #define __Pyx_c_eq_double(a, b)   ((a)==(b))
2137     #define __Pyx_c_sum_double(a, b)  ((a)+(b))
2138     #define __Pyx_c_diff_double(a, b) ((a)-(b))
2139     #define __Pyx_c_prod_double(a, b) ((a)*(b))
2140     #define __Pyx_c_quot_double(a, b) ((a)/(b))
2141     #define __Pyx_c_neg_double(a)     (-(a))
2142   #ifdef __cplusplus
2143     #define __Pyx_c_is_zero_double(z) ((z)==(double)0)
2144     #define __Pyx_c_conj_double(z)    (::std::conj(z))
2145     #if 1
2146         #define __Pyx_c_abs_double(z)     (::std::abs(z))
2147         #define __Pyx_c_pow_double(a, b)  (::std::pow(a, b))
2148     #endif
2149   #else
2150     #define __Pyx_c_is_zero_double(z) ((z)==0)
2151     #define __Pyx_c_conj_double(z)    (conj(z))
2152     #if 1
2153         #define __Pyx_c_abs_double(z)     (cabs(z))
2154         #define __Pyx_c_pow_double(a, b)  (cpow(a, b))
2155     #endif
2156  #endif
2157 #else
2158     static CYTHON_INLINE int __Pyx_c_eq_double(__pyx_t_double_complex, __pyx_t_double_complex);
2159     static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_sum_double(__pyx_t_double_complex, __pyx_t_double_complex);
2160     static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_diff_double(__pyx_t_double_complex, __pyx_t_double_complex);
2161     static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_prod_double(__pyx_t_double_complex, __pyx_t_double_complex);
2162     static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_quot_double(__pyx_t_double_complex, __pyx_t_double_complex);
2163     static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_neg_double(__pyx_t_double_complex);
2164     static CYTHON_INLINE int __Pyx_c_is_zero_double(__pyx_t_double_complex);
2165     static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_conj_double(__pyx_t_double_complex);
2166     #if 1
2167         static CYTHON_INLINE double __Pyx_c_abs_double(__pyx_t_double_complex);
2168         static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_pow_double(__pyx_t_double_complex, __pyx_t_double_complex);
2169     #endif
2170 #endif
2171 
2172 #if PY_MAJOR_VERSION < 3
2173     static int __Pyx_GetBuffer(PyObject *obj, Py_buffer *view, int flags);
2174     static void __Pyx_ReleaseBuffer(Py_buffer *view);
2175 #else
2176     #define __Pyx_GetBuffer PyObject_GetBuffer
2177     #define __Pyx_ReleaseBuffer PyBuffer_Release
2178 #endif
2179 
2180 
2181 /* BufferStructDeclare.proto */
2182 typedef struct {
2183   Py_ssize_t shape, strides, suboffsets;
2184 } __Pyx_Buf_DimInfo;
2185 typedef struct {
2186   size_t refcount;
2187   Py_buffer pybuffer;
2188 } __Pyx_Buffer;
2189 typedef struct {
2190   __Pyx_Buffer *rcbuffer;
2191   char *data;
2192   __Pyx_Buf_DimInfo diminfo[8];
2193 } __Pyx_LocalBuf_ND;
2194 
2195 /* MemviewSliceIsContig.proto */
2196 static int __pyx_memviewslice_is_contig(const __Pyx_memviewslice mvs, char order, int ndim);
2197 
2198 /* OverlappingSlices.proto */
2199 static int __pyx_slices_overlap(__Pyx_memviewslice *slice1,
2200                                 __Pyx_memviewslice *slice2,
2201                                 int ndim, size_t itemsize);
2202 
2203 /* Capsule.proto */
2204 static CYTHON_INLINE PyObject *__pyx_capsule_create(void *p, const char *sig);
2205 
2206 /* TypeInfoCompare.proto */
2207 static int __pyx_typeinfo_cmp(__Pyx_TypeInfo *a, __Pyx_TypeInfo *b);
2208 
2209 /* MemviewSliceValidateAndInit.proto */
2210 static int __Pyx_ValidateAndInit_memviewslice(
2211                 int *axes_specs,
2212                 int c_or_f_flag,
2213                 int buf_flags,
2214                 int ndim,
2215                 __Pyx_TypeInfo *dtype,
2216                 __Pyx_BufFmt_StackElem stack[],
2217                 __Pyx_memviewslice *memviewslice,
2218                 PyObject *original_obj);
2219 
2220 /* ObjectToMemviewSlice.proto */
2221 static CYTHON_INLINE __Pyx_memviewslice __Pyx_PyObject_to_MemoryviewSlice_dcd____pyx_t_double_complex(PyObject *, int writable_flag);
2222 
2223 /* ObjectToMemviewSlice.proto */
2224 static CYTHON_INLINE __Pyx_memviewslice __Pyx_PyObject_to_MemoryviewSlice_d_dc_double(PyObject *, int writable_flag);
2225 
2226 /* GCCDiagnostics.proto */
2227 #if defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6))
2228 #define __Pyx_HAS_GCC_DIAGNOSTIC
2229 #endif
2230 
2231 /* CppExceptionConversion.proto */
2232 #ifndef __Pyx_CppExn2PyErr
2233 #include <new>
2234 #include <typeinfo>
2235 #include <stdexcept>
2236 #include <ios>
__Pyx_CppExn2PyErr()2237 static void __Pyx_CppExn2PyErr() {
2238   try {
2239     if (PyErr_Occurred())
2240       ; // let the latest Python exn pass through and ignore the current one
2241     else
2242       throw;
2243   } catch (const std::bad_alloc& exn) {
2244     PyErr_SetString(PyExc_MemoryError, exn.what());
2245   } catch (const std::bad_cast& exn) {
2246     PyErr_SetString(PyExc_TypeError, exn.what());
2247   } catch (const std::bad_typeid& exn) {
2248     PyErr_SetString(PyExc_TypeError, exn.what());
2249   } catch (const std::domain_error& exn) {
2250     PyErr_SetString(PyExc_ValueError, exn.what());
2251   } catch (const std::invalid_argument& exn) {
2252     PyErr_SetString(PyExc_ValueError, exn.what());
2253   } catch (const std::ios_base::failure& exn) {
2254     PyErr_SetString(PyExc_IOError, exn.what());
2255   } catch (const std::out_of_range& exn) {
2256     PyErr_SetString(PyExc_IndexError, exn.what());
2257   } catch (const std::overflow_error& exn) {
2258     PyErr_SetString(PyExc_OverflowError, exn.what());
2259   } catch (const std::range_error& exn) {
2260     PyErr_SetString(PyExc_ArithmeticError, exn.what());
2261   } catch (const std::underflow_error& exn) {
2262     PyErr_SetString(PyExc_ArithmeticError, exn.what());
2263   } catch (const std::exception& exn) {
2264     PyErr_SetString(PyExc_RuntimeError, exn.what());
2265   }
2266   catch (...)
2267   {
2268     PyErr_SetString(PyExc_RuntimeError, "Unknown exception");
2269   }
2270 }
2271 #endif
2272 
2273 /* None.proto */
2274 static CYTHON_INLINE long __Pyx_pow_long(long, long);
2275 
2276 /* ToPy.proto */
2277 #define __pyx_PyComplex_FromComplex(z)\
2278         PyComplex_FromDoubles((double)__Pyx_CREAL(z),\
2279                               (double)__Pyx_CIMAG(z))
2280 
2281 /* MemviewDtypeToObject.proto */
2282 static CYTHON_INLINE PyObject *__pyx_memview_get_double(const char *itemp);
2283 static CYTHON_INLINE int __pyx_memview_set_double(const char *itemp, PyObject *obj);
2284 
2285 /* FromPy.proto */
2286 static __pyx_t_double_complex __Pyx_PyComplex_As___pyx_t_double_complex(PyObject*);
2287 
2288 /* MemviewDtypeToObject.proto */
2289 static CYTHON_INLINE PyObject *__pyx_memview_get___pyx_t_double_complex(const char *itemp);
2290 static CYTHON_INLINE int __pyx_memview_set___pyx_t_double_complex(const char *itemp, PyObject *obj);
2291 
2292 /* Arithmetic.proto */
2293 #if CYTHON_CCOMPLEX
2294     #define __Pyx_c_eq_float(a, b)   ((a)==(b))
2295     #define __Pyx_c_sum_float(a, b)  ((a)+(b))
2296     #define __Pyx_c_diff_float(a, b) ((a)-(b))
2297     #define __Pyx_c_prod_float(a, b) ((a)*(b))
2298     #define __Pyx_c_quot_float(a, b) ((a)/(b))
2299     #define __Pyx_c_neg_float(a)     (-(a))
2300   #ifdef __cplusplus
2301     #define __Pyx_c_is_zero_float(z) ((z)==(float)0)
2302     #define __Pyx_c_conj_float(z)    (::std::conj(z))
2303     #if 1
2304         #define __Pyx_c_abs_float(z)     (::std::abs(z))
2305         #define __Pyx_c_pow_float(a, b)  (::std::pow(a, b))
2306     #endif
2307   #else
2308     #define __Pyx_c_is_zero_float(z) ((z)==0)
2309     #define __Pyx_c_conj_float(z)    (conjf(z))
2310     #if 1
2311         #define __Pyx_c_abs_float(z)     (cabsf(z))
2312         #define __Pyx_c_pow_float(a, b)  (cpowf(a, b))
2313     #endif
2314  #endif
2315 #else
2316     static CYTHON_INLINE int __Pyx_c_eq_float(__pyx_t_float_complex, __pyx_t_float_complex);
2317     static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_sum_float(__pyx_t_float_complex, __pyx_t_float_complex);
2318     static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_diff_float(__pyx_t_float_complex, __pyx_t_float_complex);
2319     static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_prod_float(__pyx_t_float_complex, __pyx_t_float_complex);
2320     static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_quot_float(__pyx_t_float_complex, __pyx_t_float_complex);
2321     static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_neg_float(__pyx_t_float_complex);
2322     static CYTHON_INLINE int __Pyx_c_is_zero_float(__pyx_t_float_complex);
2323     static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_conj_float(__pyx_t_float_complex);
2324     #if 1
2325         static CYTHON_INLINE float __Pyx_c_abs_float(__pyx_t_float_complex);
2326         static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_pow_float(__pyx_t_float_complex, __pyx_t_float_complex);
2327     #endif
2328 #endif
2329 
2330 /* MemviewSliceCopyTemplate.proto */
2331 static __Pyx_memviewslice
2332 __pyx_memoryview_copy_new_contig(const __Pyx_memviewslice *from_mvs,
2333                                  const char *mode, int ndim,
2334                                  size_t sizeof_dtype, int contig_flag,
2335                                  int dtype_is_object);
2336 
2337 /* CIntFromPy.proto */
2338 static CYTHON_INLINE unsigned int __Pyx_PyInt_As_unsigned_int(PyObject *);
2339 
2340 /* CIntFromPy.proto */
2341 static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *);
2342 
2343 /* CIntToPy.proto */
2344 static CYTHON_INLINE PyObject* __Pyx_PyInt_From_int(int value);
2345 
2346 /* CIntFromPy.proto */
2347 static CYTHON_INLINE size_t __Pyx_PyInt_As_size_t(PyObject *);
2348 
2349 /* CIntToPy.proto */
2350 static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value);
2351 
2352 /* CIntToPy.proto */
2353 static CYTHON_INLINE PyObject* __Pyx_PyInt_From_unsigned_int(unsigned int value);
2354 
2355 /* CIntFromPy.proto */
2356 static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *);
2357 
2358 /* CIntFromPy.proto */
2359 static CYTHON_INLINE char __Pyx_PyInt_As_char(PyObject *);
2360 
2361 /* ObjectToMemviewSlice.proto */
2362 static CYTHON_INLINE __Pyx_memviewslice __Pyx_PyObject_to_MemoryviewSlice_dc___pyx_t_double_complex(PyObject *, int writable_flag);
2363 
2364 /* ObjectToMemviewSlice.proto */
2365 static CYTHON_INLINE __Pyx_memviewslice __Pyx_PyObject_to_MemoryviewSlice_dc_int(PyObject *, int writable_flag);
2366 
2367 /* ObjectToMemviewSlice.proto */
2368 static CYTHON_INLINE __Pyx_memviewslice __Pyx_PyObject_to_MemoryviewSlice_dc_double(PyObject *, int writable_flag);
2369 
2370 /* CheckBinaryVersion.proto */
2371 static int __Pyx_check_binary_version(void);
2372 
2373 /* FunctionImport.proto */
2374 static int __Pyx_ImportFunction(PyObject *module, const char *funcname, void (**f)(void), const char *sig);
2375 
2376 /* InitStrings.proto */
2377 static int __Pyx_InitStrings(__Pyx_StringTabEntry *t);
2378 
2379 static PyObject *__pyx_array_get_memview(struct __pyx_array_obj *__pyx_v_self); /* proto*/
2380 static char *__pyx_memoryview_get_item_pointer(struct __pyx_memoryview_obj *__pyx_v_self, PyObject *__pyx_v_index); /* proto*/
2381 static PyObject *__pyx_memoryview_is_slice(struct __pyx_memoryview_obj *__pyx_v_self, PyObject *__pyx_v_obj); /* proto*/
2382 static PyObject *__pyx_memoryview_setitem_slice_assignment(struct __pyx_memoryview_obj *__pyx_v_self, PyObject *__pyx_v_dst, PyObject *__pyx_v_src); /* proto*/
2383 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*/
2384 static PyObject *__pyx_memoryview_setitem_indexed(struct __pyx_memoryview_obj *__pyx_v_self, PyObject *__pyx_v_index, PyObject *__pyx_v_value); /* proto*/
2385 static PyObject *__pyx_memoryview_convert_item_to_object(struct __pyx_memoryview_obj *__pyx_v_self, char *__pyx_v_itemp); /* proto*/
2386 static PyObject *__pyx_memoryview_assign_item_from_object(struct __pyx_memoryview_obj *__pyx_v_self, char *__pyx_v_itemp, PyObject *__pyx_v_value); /* proto*/
2387 static PyObject *__pyx_memoryviewslice_convert_item_to_object(struct __pyx_memoryviewslice_obj *__pyx_v_self, char *__pyx_v_itemp); /* proto*/
2388 static PyObject *__pyx_memoryviewslice_assign_item_from_object(struct __pyx_memoryviewslice_obj *__pyx_v_self, char *__pyx_v_itemp, PyObject *__pyx_v_value); /* proto*/
2389 
2390 /* Module declarations from 'cpython.buffer' */
2391 
2392 /* Module declarations from 'libc.string' */
2393 
2394 /* Module declarations from 'libc.stdio' */
2395 
2396 /* Module declarations from '__builtin__' */
2397 
2398 /* Module declarations from 'cpython.type' */
2399 static PyTypeObject *__pyx_ptype_7cpython_4type_type = 0;
2400 
2401 /* Module declarations from 'cpython' */
2402 
2403 /* Module declarations from 'cpython.object' */
2404 
2405 /* Module declarations from 'cpython.ref' */
2406 
2407 /* Module declarations from 'cpython.mem' */
2408 
2409 /* Module declarations from 'numpy' */
2410 
2411 /* Module declarations from 'numpy' */
2412 static PyTypeObject *__pyx_ptype_5numpy_dtype = 0;
2413 static PyTypeObject *__pyx_ptype_5numpy_flatiter = 0;
2414 static PyTypeObject *__pyx_ptype_5numpy_broadcast = 0;
2415 static PyTypeObject *__pyx_ptype_5numpy_ndarray = 0;
2416 static PyTypeObject *__pyx_ptype_5numpy_ufunc = 0;
2417 static CYTHON_INLINE int __pyx_f_5numpy_import_array(void); /*proto*/
2418 
2419 /* Module declarations from 'cython.view' */
2420 
2421 /* Module declarations from 'cython' */
2422 
2423 /* Module declarations from 'libcpp' */
2424 
2425 /* Module declarations from 'qutip.cy.brtools' */
2426 static void (*__pyx_f_5qutip_2cy_7brtools_ZHEEVR)(__Pyx_memviewslice, double *, __Pyx_memviewslice, int); /*proto*/
2427 static __Pyx_memviewslice (*__pyx_f_5qutip_2cy_7brtools_dense_to_eigbasis)(__Pyx_memviewslice, __Pyx_memviewslice, unsigned int, double); /*proto*/
2428 static void (*__pyx_f_5qutip_2cy_7brtools_vec2mat_index)(int, int, int *); /*proto*/
2429 static double (*__pyx_f_5qutip_2cy_7brtools_skew_and_dwmin)(double *, __Pyx_memviewslice, unsigned int); /*proto*/
2430 
2431 /* Module declarations from 'libc.math' */
2432 
2433 /* Module declarations from 'libcpp.algorithm' */
2434 
2435 /* Module declarations from 'libcpp.vector' */
2436 
2437 /* Module declarations from 'qutip.cy.sparse_structs' */
2438 
2439 /* Module declarations from 'qutip.cy.br_tensor' */
2440 static PyTypeObject *__pyx_array_type = 0;
2441 static PyTypeObject *__pyx_MemviewEnum_type = 0;
2442 static PyTypeObject *__pyx_memoryview_type = 0;
2443 static PyTypeObject *__pyx_memoryviewslice_type = 0;
2444 static PyObject *generic = 0;
2445 static PyObject *strided = 0;
2446 static PyObject *indirect = 0;
2447 static PyObject *contiguous = 0;
2448 static PyObject *indirect_contiguous = 0;
2449 static int __pyx_memoryview_thread_locks_used;
2450 static PyThread_type_lock __pyx_memoryview_thread_locks[8];
2451 static void __pyx_f_5qutip_2cy_9br_tensor_raise_error_CSR(int, struct __pyx_opt_args_5qutip_2cy_9br_tensor_raise_error_CSR *__pyx_optional_args); /*proto*/
2452 static void __pyx_f_5qutip_2cy_9br_tensor_raise_error_COO(int, struct __pyx_opt_args_5qutip_2cy_9br_tensor_raise_error_COO *__pyx_optional_args); /*proto*/
2453 static CYTHON_INLINE int __pyx_f_5qutip_2cy_9br_tensor_int_min(int, int); /*proto*/
2454 static void __pyx_f_5qutip_2cy_9br_tensor_init_CSR(__pyx_t_5qutip_2cy_14sparse_structs_CSR_Matrix *, int, int, struct __pyx_opt_args_5qutip_2cy_9br_tensor_init_CSR *__pyx_optional_args); /*proto*/
2455 static void __pyx_f_5qutip_2cy_9br_tensor_init_COO(__pyx_t_5qutip_2cy_14sparse_structs_COO_Matrix *, int, int, struct __pyx_opt_args_5qutip_2cy_9br_tensor_init_COO *__pyx_optional_args); /*proto*/
2456 static void __pyx_f_5qutip_2cy_9br_tensor_free_CSR(__pyx_t_5qutip_2cy_14sparse_structs_CSR_Matrix *); /*proto*/
2457 static void __pyx_f_5qutip_2cy_9br_tensor_free_COO(__pyx_t_5qutip_2cy_14sparse_structs_COO_Matrix *); /*proto*/
2458 static PyObject *__pyx_f_5qutip_2cy_9br_tensor_CSR_to_scipy(__pyx_t_5qutip_2cy_14sparse_structs_CSR_Matrix *); /*proto*/
2459 static void __pyx_f_5qutip_2cy_9br_tensor_COO_to_CSR(__pyx_t_5qutip_2cy_14sparse_structs_CSR_Matrix *, __pyx_t_5qutip_2cy_14sparse_structs_COO_Matrix *); /*proto*/
2460 static int __pyx_f_5qutip_2cy_9br_tensor_ind_sort(__pyx_t_5qutip_2cy_9br_tensor_data_ind_pair, __pyx_t_5qutip_2cy_9br_tensor_data_ind_pair); /*proto*/
2461 static struct __pyx_array_obj *__pyx_array_new(PyObject *, Py_ssize_t, char *, char *, char *); /*proto*/
2462 static void *__pyx_align_pointer(void *, size_t); /*proto*/
2463 static PyObject *__pyx_memoryview_new(PyObject *, int, int, __Pyx_TypeInfo *); /*proto*/
2464 static CYTHON_INLINE int __pyx_memoryview_check(PyObject *); /*proto*/
2465 static PyObject *_unellipsify(PyObject *, int); /*proto*/
2466 static PyObject *assert_direct_dimensions(Py_ssize_t *, int); /*proto*/
2467 static struct __pyx_memoryview_obj *__pyx_memview_slice(struct __pyx_memoryview_obj *, PyObject *); /*proto*/
2468 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*/
2469 static char *__pyx_pybuffer_index(Py_buffer *, char *, Py_ssize_t, Py_ssize_t); /*proto*/
2470 static int __pyx_memslice_transpose(__Pyx_memviewslice *); /*proto*/
2471 static PyObject *__pyx_memoryview_fromslice(__Pyx_memviewslice, int, PyObject *(*)(char *), int (*)(char *, PyObject *), int); /*proto*/
2472 static __Pyx_memviewslice *__pyx_memoryview_get_slice_from_memoryview(struct __pyx_memoryview_obj *, __Pyx_memviewslice *); /*proto*/
2473 static void __pyx_memoryview_slice_copy(struct __pyx_memoryview_obj *, __Pyx_memviewslice *); /*proto*/
2474 static PyObject *__pyx_memoryview_copy_object(struct __pyx_memoryview_obj *); /*proto*/
2475 static PyObject *__pyx_memoryview_copy_object_from_slice(struct __pyx_memoryview_obj *, __Pyx_memviewslice *); /*proto*/
2476 static Py_ssize_t abs_py_ssize_t(Py_ssize_t); /*proto*/
2477 static char __pyx_get_best_slice_order(__Pyx_memviewslice *, int); /*proto*/
2478 static void _copy_strided_to_strided(char *, Py_ssize_t *, char *, Py_ssize_t *, Py_ssize_t *, Py_ssize_t *, int, size_t); /*proto*/
2479 static void copy_strided_to_strided(__Pyx_memviewslice *, __Pyx_memviewslice *, int, size_t); /*proto*/
2480 static Py_ssize_t __pyx_memoryview_slice_get_size(__Pyx_memviewslice *, int); /*proto*/
2481 static Py_ssize_t __pyx_fill_contig_strides_array(Py_ssize_t *, Py_ssize_t *, Py_ssize_t, int, char); /*proto*/
2482 static void *__pyx_memoryview_copy_data_to_temp(__Pyx_memviewslice *, __Pyx_memviewslice *, char, int); /*proto*/
2483 static int __pyx_memoryview_err_extents(int, Py_ssize_t, Py_ssize_t); /*proto*/
2484 static int __pyx_memoryview_err_dim(PyObject *, char *, int); /*proto*/
2485 static int __pyx_memoryview_err(PyObject *, char *); /*proto*/
2486 static int __pyx_memoryview_copy_contents(__Pyx_memviewslice, __Pyx_memviewslice, int, int, int); /*proto*/
2487 static void __pyx_memoryview_broadcast_leading(__Pyx_memviewslice *, int, int); /*proto*/
2488 static void __pyx_memoryview_refcount_copying(__Pyx_memviewslice *, int, int, int); /*proto*/
2489 static void __pyx_memoryview_refcount_objects_in_slice_with_gil(char *, Py_ssize_t *, Py_ssize_t *, int, int); /*proto*/
2490 static void __pyx_memoryview_refcount_objects_in_slice(char *, Py_ssize_t *, Py_ssize_t *, int, int); /*proto*/
2491 static void __pyx_memoryview_slice_assign_scalar(__Pyx_memviewslice *, int, size_t, void *, int); /*proto*/
2492 static void __pyx_memoryview__slice_assign_scalar(char *, Py_ssize_t *, Py_ssize_t *, int, size_t, void *); /*proto*/
2493 static PyObject *__pyx_unpickle_Enum__set_state(struct __pyx_MemviewEnum_obj *, PyObject *); /*proto*/
2494 static __Pyx_TypeInfo __Pyx_TypeInfo___pyx_t_double_complex = { "double complex", NULL, sizeof(__pyx_t_double_complex), { 0 }, 0, 'C', 0, 0 };
2495 static __Pyx_TypeInfo __Pyx_TypeInfo_int = { "int", NULL, sizeof(int), { 0 }, 0, IS_UNSIGNED(int) ? 'U' : 'I', IS_UNSIGNED(int), 0 };
2496 static __Pyx_TypeInfo __Pyx_TypeInfo_double = { "double", NULL, sizeof(double), { 0 }, 0, 'R', 0, 0 };
2497 #define __Pyx_MODULE_NAME "qutip.cy.br_tensor"
2498 extern int __pyx_module_is_main_qutip__cy__br_tensor;
2499 int __pyx_module_is_main_qutip__cy__br_tensor = 0;
2500 
2501 /* Implementation of 'qutip.cy.br_tensor' */
2502 static PyObject *__pyx_builtin_MemoryError;
2503 static PyObject *__pyx_builtin_range;
2504 static PyObject *__pyx_builtin_DeprecationWarning;
2505 static PyObject *__pyx_builtin_enumerate;
2506 static PyObject *__pyx_builtin_TypeError;
2507 static PyObject *__pyx_builtin_ImportError;
2508 static PyObject *__pyx_builtin_ValueError;
2509 static PyObject *__pyx_builtin_Ellipsis;
2510 static PyObject *__pyx_builtin_id;
2511 static PyObject *__pyx_builtin_IndexError;
2512 static const char __pyx_k_A[] = "A";
2513 static const char __pyx_k_F[] = "F";
2514 static const char __pyx_k_H[] = "H";
2515 static const char __pyx_k_I[] = "I";
2516 static const char __pyx_k_J[] = "J";
2517 static const char __pyx_k_K[] = "K";
2518 static const char __pyx_k_L[] = "L";
2519 static const char __pyx_k_O[] = "O";
2520 static const char __pyx_k_a[] = "a";
2521 static const char __pyx_k_c[] = "c";
2522 static const char __pyx_k_k[] = "k";
2523 static const char __pyx_k_H0[] = "H0";
2524 static const char __pyx_k_ab[] = "ab";
2525 static const char __pyx_k_cd[] = "cd";
2526 static const char __pyx_k_id[] = "id";
2527 static const char __pyx_k_kk[] = "kk";
2528 static const char __pyx_k_np[] = "np";
2529 static const char __pyx_k__37[] = "*";
2530 static const char __pyx_k_col[] = "col";
2531 static const char __pyx_k_coo[] = "coo";
2532 static const char __pyx_k_cop[] = "cop";
2533 static const char __pyx_k_csr[] = "csr";
2534 static const char __pyx_k_new[] = "__new__";
2535 static const char __pyx_k_nnz[] = "nnz";
2536 static const char __pyx_k_obj[] = "obj";
2537 static const char __pyx_k_row[] = "row";
2538 static const char __pyx_k_Qobj[] = "Qobj";
2539 static const char __pyx_k_atol[] = "atol";
2540 static const char __pyx_k_base[] = "base";
2541 static const char __pyx_k_copy[] = "copy";
2542 static const char __pyx_k_data[] = "data";
2543 static const char __pyx_k_dict[] = "__dict__";
2544 static const char __pyx_k_dims[] = "dims";
2545 static const char __pyx_k_elem[] = "elem";
2546 static const char __pyx_k_full[] = "full";
2547 static const char __pyx_k_main[] = "__main__";
2548 static const char __pyx_k_mode[] = "mode";
2549 static const char __pyx_k_name[] = "name";
2550 static const char __pyx_k_ndim[] = "ndim";
2551 static const char __pyx_k_pack[] = "pack";
2552 static const char __pyx_k_qset[] = "qset";
2553 static const char __pyx_k_size[] = "size";
2554 static const char __pyx_k_skew[] = "skew";
2555 static const char __pyx_k_step[] = "step";
2556 static const char __pyx_k_stop[] = "stop";
2557 static const char __pyx_k_test[] = "__test__";
2558 static const char __pyx_k_warn[] = "warn";
2559 static const char __pyx_k_ASCII[] = "ASCII";
2560 static const char __pyx_k_A_eig[] = "A_eig";
2561 static const char __pyx_k_a_ops[] = "a_ops";
2562 static const char __pyx_k_c_ops[] = "c_ops";
2563 static const char __pyx_k_class[] = "__class__";
2564 static const char __pyx_k_dtype[] = "dtype";
2565 static const char __pyx_k_ekets[] = "ekets";
2566 static const char __pyx_k_error[] = "error";
2567 static const char __pyx_k_evals[] = "evals";
2568 static const char __pyx_k_evecs[] = "evecs";
2569 static const char __pyx_k_flags[] = "flags";
2570 static const char __pyx_k_nrows[] = "nrows";
2571 static const char __pyx_k_numpy[] = "numpy";
2572 static const char __pyx_k_order[] = "order";
2573 static const char __pyx_k_range[] = "range";
2574 static const char __pyx_k_shape[] = "shape";
2575 static const char __pyx_k_start[] = "start";
2576 static const char __pyx_k_zeros[] = "zeros";
2577 static const char __pyx_k_dw_min[] = "dw_min";
2578 static const char __pyx_k_encode[] = "encode";
2579 static const char __pyx_k_format[] = "format";
2580 static const char __pyx_k_import[] = "__import__";
2581 static const char __pyx_k_indptr[] = "indptr";
2582 static const char __pyx_k_isherm[] = "isherm";
2583 static const char __pyx_k_name_2[] = "__name__";
2584 static const char __pyx_k_pickle[] = "pickle";
2585 static const char __pyx_k_reduce[] = "__reduce__";
2586 static const char __pyx_k_struct[] = "struct";
2587 static const char __pyx_k_unpack[] = "unpack";
2588 static const char __pyx_k_update[] = "update";
2589 static const char __pyx_k_a_ops_2[] = "_a_ops";
2590 static const char __pyx_k_ac_elem[] = "ac_elem";
2591 static const char __pyx_k_asarray[] = "asarray";
2592 static const char __pyx_k_bd_elem[] = "bd_elem";
2593 static const char __pyx_k_br_term[] = "_br_term";
2594 static const char __pyx_k_fortran[] = "fortran";
2595 static const char __pyx_k_indices[] = "indices";
2596 static const char __pyx_k_memview[] = "memview";
2597 static const char __pyx_k_op_dims[] = "op_dims";
2598 static const char __pyx_k_Ellipsis[] = "Ellipsis";
2599 static const char __pyx_k_coo_cols[] = "coo_cols";
2600 static const char __pyx_k_coo_data[] = "coo_data";
2601 static const char __pyx_k_coo_rows[] = "coo_rows";
2602 static const char __pyx_k_getstate[] = "__getstate__";
2603 static const char __pyx_k_itemsize[] = "itemsize";
2604 static const char __pyx_k_ket_dims[] = "ket_dims";
2605 static const char __pyx_k_pyx_type[] = "__pyx_type";
2606 static const char __pyx_k_setstate[] = "__setstate__";
2607 static const char __pyx_k_sop_dims[] = "sop_dims";
2608 static const char __pyx_k_spectral[] = "spectral";
2609 static const char __pyx_k_warnings[] = "warnings";
2610 static const char __pyx_k_TypeError[] = "TypeError";
2611 static const char __pyx_k_enumerate[] = "enumerate";
2612 static const char __pyx_k_pyx_state[] = "__pyx_state";
2613 static const char __pyx_k_reduce_ex[] = "__reduce_ex__";
2614 static const char __pyx_k_IndexError[] = "IndexError";
2615 static const char __pyx_k_ValueError[] = "ValueError";
2616 static const char __pyx_k_coo_matrix[] = "coo_matrix";
2617 static const char __pyx_k_pyx_result[] = "__pyx_result";
2618 static const char __pyx_k_pyx_vtable[] = "__pyx_vtable__";
2619 static const char __pyx_k_qutip_qobj[] = "qutip.qobj";
2620 static const char __pyx_k_sec_cutoff[] = "sec_cutoff";
2621 static const char __pyx_k_spectra_cb[] = "spectra_cb";
2622 static const char __pyx_k_ImportError[] = "ImportError";
2623 static const char __pyx_k_MemoryError[] = "MemoryError";
2624 static const char __pyx_k_PickleError[] = "PickleError";
2625 static const char __pyx_k_use_secular[] = "use_secular";
2626 static const char __pyx_k_pyx_checksum[] = "__pyx_checksum";
2627 static const char __pyx_k_scipy_sparse[] = "scipy.sparse";
2628 static const char __pyx_k_stringsource[] = "stringsource";
2629 static const char __pyx_k_pyx_getbuffer[] = "__pyx_getbuffer";
2630 static const char __pyx_k_reduce_cython[] = "__reduce_cython__";
2631 static const char __pyx_k_cop_super_term[] = "cop_super_term";
2632 static const char __pyx_k_qutip_settings[] = "qutip.settings";
2633 static const char __pyx_k_View_MemoryView[] = "View.MemoryView";
2634 static const char __pyx_k_allocate_buffer[] = "allocate_buffer";
2635 static const char __pyx_k_dtype_is_object[] = "dtype_is_object";
2636 static const char __pyx_k_fast_csr_matrix[] = "fast_csr_matrix";
2637 static const char __pyx_k_pyx_PickleError[] = "__pyx_PickleError";
2638 static const char __pyx_k_setstate_cython[] = "__setstate_cython__";
2639 static const char __pyx_k_qutip_cy_brtools[] = "qutip.cy.brtools";
2640 static const char __pyx_k_qutip_fastsparse[] = "qutip.fastsparse";
2641 static const char __pyx_k_pyx_unpickle_Enum[] = "__pyx_unpickle_Enum";
2642 static const char __pyx_k_DeprecationWarning[] = "DeprecationWarning";
2643 static const char __pyx_k_cline_in_traceback[] = "cline_in_traceback";
2644 static const char __pyx_k_liou_from_diag_ham[] = "liou_from_diag_ham";
2645 static const char __pyx_k_qutip_cy_br_tensor[] = "qutip.cy.br_tensor";
2646 static const char __pyx_k_strided_and_direct[] = "<strided and direct>";
2647 static const char __pyx_k_Error_in_Cython_code[] = "Error in Cython code.";
2648 static const char __pyx_k_strided_and_indirect[] = "<strided and indirect>";
2649 static const char __pyx_k_bloch_redfield_tensor[] = "bloch_redfield_tensor";
2650 static const char __pyx_k_contiguous_and_direct[] = "<contiguous and direct>";
2651 static const char __pyx_k_MemoryView_of_r_object[] = "<MemoryView of %r object>";
2652 static const char __pyx_k_qutip_cy_br_tensor_pyx[] = "qutip/cy/br_tensor.pyx";
2653 static const char __pyx_k_MemoryView_of_r_at_0x_x[] = "<MemoryView of %r at 0x%x>";
2654 static const char __pyx_k_contiguous_and_indirect[] = "<contiguous and indirect>";
2655 static const char __pyx_k_Cannot_index_with_type_s[] = "Cannot index with type '%s'";
2656 static const char __pyx_k_Could_not_allocate_memory[] = "Could not allocate memory.";
2657 static const char __pyx_k_Invalid_shape_in_axis_d_d[] = "Invalid shape in axis %d: %d.";
2658 static const char __pyx_k_itemsize_0_for_cython_array[] = "itemsize <= 0 for cython.array";
2659 static const char __pyx_k_COO_Matrix_cannot_be_expanded[] = "COO_Matrix cannot be expanded.";
2660 static const char __pyx_k_COO_Matrix_is_not_initialized[] = "COO_Matrix is not initialized.";
2661 static const char __pyx_k_CSR_Matrix_cannot_be_expanded[] = "CSR_Matrix cannot be expanded.";
2662 static const char __pyx_k_CSR_Matrix_is_not_initialized[] = "CSR_Matrix is not initialized.";
2663 static const char __pyx_k_H_must_be_an_instance_of_Qobj[] = "H must be an instance of Qobj";
2664 static const char __pyx_k_unable_to_allocate_array_data[] = "unable to allocate array data.";
2665 static const char __pyx_k_NumPy_already_has_lock_on_data[] = "NumPy already has lock on data.";
2666 static const char __pyx_k_strided_and_direct_or_indirect[] = "<strided and direct or indirect>";
2667 static const char __pyx_k_numpy_core_multiarray_failed_to[] = "numpy.core.multiarray failed to import";
2668 static const char __pyx_k_Buffer_view_does_not_expose_stri[] = "Buffer view does not expose strides";
2669 static const char __pyx_k_Can_only_create_a_buffer_that_is[] = "Can only create a buffer that is contiguous in memory.";
2670 static const char __pyx_k_Cannot_assign_to_read_only_memor[] = "Cannot assign to read-only memoryview";
2671 static const char __pyx_k_Cannot_create_writable_memory_vi[] = "Cannot create writable memory view from read-only memoryview";
2672 static const char __pyx_k_Cannot_expand_data_structures_pa[] = "Cannot expand data structures past max_length.";
2673 static const char __pyx_k_Data_length_cannot_be_larger_tha[] = "Data length cannot be larger than max_length";
2674 static const char __pyx_k_Empty_shape_tuple_for_cython_arr[] = "Empty shape tuple for cython.array";
2675 static const char __pyx_k_Error_manipulating_COO_Matrix_st[] = "Error manipulating COO_Matrix structure.";
2676 static const char __pyx_k_Error_manipulating_CSR_Matrix_st[] = "Error manipulating CSR_Matrix structure.";
2677 static const char __pyx_k_Incompatible_checksums_s_vs_0xb0[] = "Incompatible checksums (%s vs 0xb068931 = (name))";
2678 static const char __pyx_k_Indirect_dimensions_not_supporte[] = "Indirect dimensions not supported";
2679 static const char __pyx_k_Invalid_mode_expected_c_or_fortr[] = "Invalid mode, expected 'c' or 'fortran', got %s";
2680 static const char __pyx_k_Operators_in_a_ops_must_be_Hermi[] = "Operators in a_ops must be Hermitian Qobj.";
2681 static const char __pyx_k_Out_of_bounds_on_buffer_access_a[] = "Out of bounds on buffer access (axis %d)";
2682 static const char __pyx_k_The_use_of_spectra_cb_is_depreci[] = "The use of spectra_cb is depreciated.";
2683 static const char __pyx_k_Unable_to_convert_item_to_object[] = "Unable to convert item to object";
2684 static const char __pyx_k_got_differing_extents_in_dimensi[] = "got differing extents in dimension %d (got %d and %d)";
2685 static const char __pyx_k_no_default___reduce___due_to_non[] = "no default __reduce__ due to non-trivial __cinit__";
2686 static const char __pyx_k_numpy_core_umath_failed_to_impor[] = "numpy.core.umath failed to import";
2687 static const char __pyx_k_unable_to_allocate_shape_and_str[] = "unable to allocate shape and strides.";
2688 static PyObject *__pyx_n_s_A;
2689 static PyObject *__pyx_n_s_ASCII;
2690 static PyObject *__pyx_n_s_A_eig;
2691 static PyObject *__pyx_kp_s_Buffer_view_does_not_expose_stri;
2692 static PyObject *__pyx_kp_u_COO_Matrix_cannot_be_expanded;
2693 static PyObject *__pyx_kp_u_COO_Matrix_is_not_initialized;
2694 static PyObject *__pyx_kp_u_CSR_Matrix_cannot_be_expanded;
2695 static PyObject *__pyx_kp_u_CSR_Matrix_is_not_initialized;
2696 static PyObject *__pyx_kp_s_Can_only_create_a_buffer_that_is;
2697 static PyObject *__pyx_kp_s_Cannot_assign_to_read_only_memor;
2698 static PyObject *__pyx_kp_s_Cannot_create_writable_memory_vi;
2699 static PyObject *__pyx_kp_u_Cannot_expand_data_structures_pa;
2700 static PyObject *__pyx_kp_s_Cannot_index_with_type_s;
2701 static PyObject *__pyx_kp_u_Could_not_allocate_memory;
2702 static PyObject *__pyx_kp_u_Data_length_cannot_be_larger_tha;
2703 static PyObject *__pyx_n_s_DeprecationWarning;
2704 static PyObject *__pyx_n_s_Ellipsis;
2705 static PyObject *__pyx_kp_s_Empty_shape_tuple_for_cython_arr;
2706 static PyObject *__pyx_kp_u_Error_in_Cython_code;
2707 static PyObject *__pyx_kp_u_Error_manipulating_COO_Matrix_st;
2708 static PyObject *__pyx_kp_u_Error_manipulating_CSR_Matrix_st;
2709 static PyObject *__pyx_n_u_F;
2710 static PyObject *__pyx_n_s_H;
2711 static PyObject *__pyx_n_s_H0;
2712 static PyObject *__pyx_kp_u_H_must_be_an_instance_of_Qobj;
2713 static PyObject *__pyx_n_s_I;
2714 static PyObject *__pyx_n_s_ImportError;
2715 static PyObject *__pyx_kp_s_Incompatible_checksums_s_vs_0xb0;
2716 static PyObject *__pyx_n_s_IndexError;
2717 static PyObject *__pyx_kp_s_Indirect_dimensions_not_supporte;
2718 static PyObject *__pyx_kp_s_Invalid_mode_expected_c_or_fortr;
2719 static PyObject *__pyx_kp_s_Invalid_shape_in_axis_d_d;
2720 static PyObject *__pyx_n_s_J;
2721 static PyObject *__pyx_n_s_K;
2722 static PyObject *__pyx_n_s_L;
2723 static PyObject *__pyx_n_s_MemoryError;
2724 static PyObject *__pyx_kp_s_MemoryView_of_r_at_0x_x;
2725 static PyObject *__pyx_kp_s_MemoryView_of_r_object;
2726 static PyObject *__pyx_kp_u_NumPy_already_has_lock_on_data;
2727 static PyObject *__pyx_n_b_O;
2728 static PyObject *__pyx_kp_u_Operators_in_a_ops_must_be_Hermi;
2729 static PyObject *__pyx_kp_s_Out_of_bounds_on_buffer_access_a;
2730 static PyObject *__pyx_n_s_PickleError;
2731 static PyObject *__pyx_n_s_Qobj;
2732 static PyObject *__pyx_kp_u_The_use_of_spectra_cb_is_depreci;
2733 static PyObject *__pyx_n_s_TypeError;
2734 static PyObject *__pyx_kp_s_Unable_to_convert_item_to_object;
2735 static PyObject *__pyx_n_s_ValueError;
2736 static PyObject *__pyx_n_s_View_MemoryView;
2737 static PyObject *__pyx_n_s__37;
2738 static PyObject *__pyx_n_s_a;
2739 static PyObject *__pyx_n_s_a_ops;
2740 static PyObject *__pyx_n_s_a_ops_2;
2741 static PyObject *__pyx_n_s_ab;
2742 static PyObject *__pyx_n_s_ac_elem;
2743 static PyObject *__pyx_n_s_allocate_buffer;
2744 static PyObject *__pyx_n_s_asarray;
2745 static PyObject *__pyx_n_s_atol;
2746 static PyObject *__pyx_n_s_base;
2747 static PyObject *__pyx_n_s_bd_elem;
2748 static PyObject *__pyx_n_s_bloch_redfield_tensor;
2749 static PyObject *__pyx_n_s_br_term;
2750 static PyObject *__pyx_n_s_c;
2751 static PyObject *__pyx_n_u_c;
2752 static PyObject *__pyx_n_s_c_ops;
2753 static PyObject *__pyx_n_s_cd;
2754 static PyObject *__pyx_n_s_class;
2755 static PyObject *__pyx_n_s_cline_in_traceback;
2756 static PyObject *__pyx_n_s_col;
2757 static PyObject *__pyx_kp_s_contiguous_and_direct;
2758 static PyObject *__pyx_kp_s_contiguous_and_indirect;
2759 static PyObject *__pyx_n_s_coo;
2760 static PyObject *__pyx_n_s_coo_cols;
2761 static PyObject *__pyx_n_s_coo_data;
2762 static PyObject *__pyx_n_s_coo_matrix;
2763 static PyObject *__pyx_n_s_coo_rows;
2764 static PyObject *__pyx_n_s_cop;
2765 static PyObject *__pyx_n_s_cop_super_term;
2766 static PyObject *__pyx_n_s_copy;
2767 static PyObject *__pyx_n_s_csr;
2768 static PyObject *__pyx_n_s_data;
2769 static PyObject *__pyx_n_s_dict;
2770 static PyObject *__pyx_n_s_dims;
2771 static PyObject *__pyx_n_s_dtype;
2772 static PyObject *__pyx_n_s_dtype_is_object;
2773 static PyObject *__pyx_n_s_dw_min;
2774 static PyObject *__pyx_n_s_ekets;
2775 static PyObject *__pyx_n_s_elem;
2776 static PyObject *__pyx_n_s_encode;
2777 static PyObject *__pyx_n_s_enumerate;
2778 static PyObject *__pyx_n_s_error;
2779 static PyObject *__pyx_n_s_evals;
2780 static PyObject *__pyx_n_s_evecs;
2781 static PyObject *__pyx_n_s_fast_csr_matrix;
2782 static PyObject *__pyx_n_s_flags;
2783 static PyObject *__pyx_n_s_format;
2784 static PyObject *__pyx_n_s_fortran;
2785 static PyObject *__pyx_n_u_fortran;
2786 static PyObject *__pyx_n_s_full;
2787 static PyObject *__pyx_n_s_getstate;
2788 static PyObject *__pyx_kp_s_got_differing_extents_in_dimensi;
2789 static PyObject *__pyx_n_s_id;
2790 static PyObject *__pyx_n_s_import;
2791 static PyObject *__pyx_n_s_indices;
2792 static PyObject *__pyx_n_s_indptr;
2793 static PyObject *__pyx_n_s_isherm;
2794 static PyObject *__pyx_n_s_itemsize;
2795 static PyObject *__pyx_kp_s_itemsize_0_for_cython_array;
2796 static PyObject *__pyx_n_s_k;
2797 static PyObject *__pyx_n_s_ket_dims;
2798 static PyObject *__pyx_n_s_kk;
2799 static PyObject *__pyx_n_s_liou_from_diag_ham;
2800 static PyObject *__pyx_n_s_main;
2801 static PyObject *__pyx_n_s_memview;
2802 static PyObject *__pyx_n_s_mode;
2803 static PyObject *__pyx_n_s_name;
2804 static PyObject *__pyx_n_s_name_2;
2805 static PyObject *__pyx_n_s_ndim;
2806 static PyObject *__pyx_n_s_new;
2807 static PyObject *__pyx_n_s_nnz;
2808 static PyObject *__pyx_kp_s_no_default___reduce___due_to_non;
2809 static PyObject *__pyx_n_s_np;
2810 static PyObject *__pyx_n_s_nrows;
2811 static PyObject *__pyx_n_s_numpy;
2812 static PyObject *__pyx_kp_u_numpy_core_multiarray_failed_to;
2813 static PyObject *__pyx_kp_u_numpy_core_umath_failed_to_impor;
2814 static PyObject *__pyx_n_s_obj;
2815 static PyObject *__pyx_n_s_op_dims;
2816 static PyObject *__pyx_n_s_order;
2817 static PyObject *__pyx_n_s_pack;
2818 static PyObject *__pyx_n_s_pickle;
2819 static PyObject *__pyx_n_s_pyx_PickleError;
2820 static PyObject *__pyx_n_s_pyx_checksum;
2821 static PyObject *__pyx_n_s_pyx_getbuffer;
2822 static PyObject *__pyx_n_s_pyx_result;
2823 static PyObject *__pyx_n_s_pyx_state;
2824 static PyObject *__pyx_n_s_pyx_type;
2825 static PyObject *__pyx_n_s_pyx_unpickle_Enum;
2826 static PyObject *__pyx_n_s_pyx_vtable;
2827 static PyObject *__pyx_n_s_qset;
2828 static PyObject *__pyx_n_s_qutip_cy_br_tensor;
2829 static PyObject *__pyx_kp_s_qutip_cy_br_tensor_pyx;
2830 static PyObject *__pyx_n_s_qutip_cy_brtools;
2831 static PyObject *__pyx_n_s_qutip_fastsparse;
2832 static PyObject *__pyx_n_s_qutip_qobj;
2833 static PyObject *__pyx_n_s_qutip_settings;
2834 static PyObject *__pyx_n_s_range;
2835 static PyObject *__pyx_n_s_reduce;
2836 static PyObject *__pyx_n_s_reduce_cython;
2837 static PyObject *__pyx_n_s_reduce_ex;
2838 static PyObject *__pyx_n_s_row;
2839 static PyObject *__pyx_n_s_scipy_sparse;
2840 static PyObject *__pyx_n_s_sec_cutoff;
2841 static PyObject *__pyx_n_s_setstate;
2842 static PyObject *__pyx_n_s_setstate_cython;
2843 static PyObject *__pyx_n_s_shape;
2844 static PyObject *__pyx_n_s_size;
2845 static PyObject *__pyx_n_s_skew;
2846 static PyObject *__pyx_n_s_sop_dims;
2847 static PyObject *__pyx_n_s_spectra_cb;
2848 static PyObject *__pyx_n_s_spectral;
2849 static PyObject *__pyx_n_s_start;
2850 static PyObject *__pyx_n_s_step;
2851 static PyObject *__pyx_n_s_stop;
2852 static PyObject *__pyx_kp_s_strided_and_direct;
2853 static PyObject *__pyx_kp_s_strided_and_direct_or_indirect;
2854 static PyObject *__pyx_kp_s_strided_and_indirect;
2855 static PyObject *__pyx_kp_s_stringsource;
2856 static PyObject *__pyx_n_s_struct;
2857 static PyObject *__pyx_n_s_test;
2858 static PyObject *__pyx_kp_s_unable_to_allocate_array_data;
2859 static PyObject *__pyx_kp_s_unable_to_allocate_shape_and_str;
2860 static PyObject *__pyx_n_s_unpack;
2861 static PyObject *__pyx_n_s_update;
2862 static PyObject *__pyx_n_s_use_secular;
2863 static PyObject *__pyx_n_s_warn;
2864 static PyObject *__pyx_n_s_warnings;
2865 static PyObject *__pyx_n_s_zeros;
2866 static PyObject *__pyx_pf_5qutip_2cy_9br_tensor__br_term(CYTHON_UNUSED PyObject *__pyx_self, __Pyx_memviewslice __pyx_v_A, __Pyx_memviewslice __pyx_v_evecs, __Pyx_memviewslice __pyx_v_skew, double __pyx_v_dw_min, PyObject *__pyx_v_spectral, unsigned int __pyx_v_nrows, int __pyx_v_use_secular, double __pyx_v_sec_cutoff, double __pyx_v_atol); /* proto */
2867 static PyObject *__pyx_pf_5qutip_2cy_9br_tensor_2bloch_redfield_tensor(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_H, PyObject *__pyx_v_a_ops, PyObject *__pyx_v_spectra_cb, PyObject *__pyx_v_c_ops, bool __pyx_v_use_secular, double __pyx_v_sec_cutoff, double __pyx_v_atol); /* proto */
2868 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 */
2869 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 */
2870 static void __pyx_array___pyx_pf_15View_dot_MemoryView_5array_4__dealloc__(struct __pyx_array_obj *__pyx_v_self); /* proto */
2871 static PyObject *__pyx_pf_15View_dot_MemoryView_5array_7memview___get__(struct __pyx_array_obj *__pyx_v_self); /* proto */
2872 static Py_ssize_t __pyx_array___pyx_pf_15View_dot_MemoryView_5array_6__len__(struct __pyx_array_obj *__pyx_v_self); /* proto */
2873 static PyObject *__pyx_array___pyx_pf_15View_dot_MemoryView_5array_8__getattr__(struct __pyx_array_obj *__pyx_v_self, PyObject *__pyx_v_attr); /* proto */
2874 static PyObject *__pyx_array___pyx_pf_15View_dot_MemoryView_5array_10__getitem__(struct __pyx_array_obj *__pyx_v_self, PyObject *__pyx_v_item); /* proto */
2875 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 */
2876 static PyObject *__pyx_pf___pyx_array___reduce_cython__(CYTHON_UNUSED struct __pyx_array_obj *__pyx_v_self); /* proto */
2877 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 */
2878 static int __pyx_MemviewEnum___pyx_pf_15View_dot_MemoryView_4Enum___init__(struct __pyx_MemviewEnum_obj *__pyx_v_self, PyObject *__pyx_v_name); /* proto */
2879 static PyObject *__pyx_MemviewEnum___pyx_pf_15View_dot_MemoryView_4Enum_2__repr__(struct __pyx_MemviewEnum_obj *__pyx_v_self); /* proto */
2880 static PyObject *__pyx_pf___pyx_MemviewEnum___reduce_cython__(struct __pyx_MemviewEnum_obj *__pyx_v_self); /* proto */
2881 static PyObject *__pyx_pf___pyx_MemviewEnum_2__setstate_cython__(struct __pyx_MemviewEnum_obj *__pyx_v_self, PyObject *__pyx_v___pyx_state); /* proto */
2882 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 */
2883 static void __pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_2__dealloc__(struct __pyx_memoryview_obj *__pyx_v_self); /* proto */
2884 static PyObject *__pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_4__getitem__(struct __pyx_memoryview_obj *__pyx_v_self, PyObject *__pyx_v_index); /* proto */
2885 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 */
2886 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 */
2887 static PyObject *__pyx_pf_15View_dot_MemoryView_10memoryview_1T___get__(struct __pyx_memoryview_obj *__pyx_v_self); /* proto */
2888 static PyObject *__pyx_pf_15View_dot_MemoryView_10memoryview_4base___get__(struct __pyx_memoryview_obj *__pyx_v_self); /* proto */
2889 static PyObject *__pyx_pf_15View_dot_MemoryView_10memoryview_5shape___get__(struct __pyx_memoryview_obj *__pyx_v_self); /* proto */
2890 static PyObject *__pyx_pf_15View_dot_MemoryView_10memoryview_7strides___get__(struct __pyx_memoryview_obj *__pyx_v_self); /* proto */
2891 static PyObject *__pyx_pf_15View_dot_MemoryView_10memoryview_10suboffsets___get__(struct __pyx_memoryview_obj *__pyx_v_self); /* proto */
2892 static PyObject *__pyx_pf_15View_dot_MemoryView_10memoryview_4ndim___get__(struct __pyx_memoryview_obj *__pyx_v_self); /* proto */
2893 static PyObject *__pyx_pf_15View_dot_MemoryView_10memoryview_8itemsize___get__(struct __pyx_memoryview_obj *__pyx_v_self); /* proto */
2894 static PyObject *__pyx_pf_15View_dot_MemoryView_10memoryview_6nbytes___get__(struct __pyx_memoryview_obj *__pyx_v_self); /* proto */
2895 static PyObject *__pyx_pf_15View_dot_MemoryView_10memoryview_4size___get__(struct __pyx_memoryview_obj *__pyx_v_self); /* proto */
2896 static Py_ssize_t __pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_10__len__(struct __pyx_memoryview_obj *__pyx_v_self); /* proto */
2897 static PyObject *__pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_12__repr__(struct __pyx_memoryview_obj *__pyx_v_self); /* proto */
2898 static PyObject *__pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_14__str__(struct __pyx_memoryview_obj *__pyx_v_self); /* proto */
2899 static PyObject *__pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_16is_c_contig(struct __pyx_memoryview_obj *__pyx_v_self); /* proto */
2900 static PyObject *__pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_18is_f_contig(struct __pyx_memoryview_obj *__pyx_v_self); /* proto */
2901 static PyObject *__pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_20copy(struct __pyx_memoryview_obj *__pyx_v_self); /* proto */
2902 static PyObject *__pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_22copy_fortran(struct __pyx_memoryview_obj *__pyx_v_self); /* proto */
2903 static PyObject *__pyx_pf___pyx_memoryview___reduce_cython__(CYTHON_UNUSED struct __pyx_memoryview_obj *__pyx_v_self); /* proto */
2904 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 */
2905 static void __pyx_memoryviewslice___pyx_pf_15View_dot_MemoryView_16_memoryviewslice___dealloc__(struct __pyx_memoryviewslice_obj *__pyx_v_self); /* proto */
2906 static PyObject *__pyx_pf_15View_dot_MemoryView_16_memoryviewslice_4base___get__(struct __pyx_memoryviewslice_obj *__pyx_v_self); /* proto */
2907 static PyObject *__pyx_pf___pyx_memoryviewslice___reduce_cython__(CYTHON_UNUSED struct __pyx_memoryviewslice_obj *__pyx_v_self); /* proto */
2908 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 */
2909 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 */
2910 static PyObject *__pyx_tp_new_array(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
2911 static PyObject *__pyx_tp_new_Enum(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
2912 static PyObject *__pyx_tp_new_memoryview(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
2913 static PyObject *__pyx_tp_new__memoryviewslice(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
2914 static PyObject *__pyx_int_0;
2915 static PyObject *__pyx_int_1;
2916 static PyObject *__pyx_int_184977713;
2917 static PyObject *__pyx_int_neg_1;
2918 static PyObject *__pyx_k__12;
2919 static double __pyx_k__13;
2920 static PyObject *__pyx_tuple_;
2921 static PyObject *__pyx_tuple__2;
2922 static PyObject *__pyx_tuple__3;
2923 static PyObject *__pyx_tuple__4;
2924 static PyObject *__pyx_tuple__5;
2925 static PyObject *__pyx_tuple__6;
2926 static PyObject *__pyx_tuple__7;
2927 static PyObject *__pyx_tuple__8;
2928 static PyObject *__pyx_tuple__9;
2929 static PyObject *__pyx_slice__33;
2930 static PyObject *__pyx_tuple__10;
2931 static PyObject *__pyx_tuple__11;
2932 static PyObject *__pyx_tuple__14;
2933 static PyObject *__pyx_tuple__15;
2934 static PyObject *__pyx_tuple__16;
2935 static PyObject *__pyx_tuple__17;
2936 static PyObject *__pyx_tuple__18;
2937 static PyObject *__pyx_tuple__19;
2938 static PyObject *__pyx_tuple__20;
2939 static PyObject *__pyx_tuple__21;
2940 static PyObject *__pyx_tuple__22;
2941 static PyObject *__pyx_tuple__23;
2942 static PyObject *__pyx_tuple__24;
2943 static PyObject *__pyx_tuple__25;
2944 static PyObject *__pyx_tuple__26;
2945 static PyObject *__pyx_tuple__27;
2946 static PyObject *__pyx_tuple__28;
2947 static PyObject *__pyx_tuple__29;
2948 static PyObject *__pyx_tuple__30;
2949 static PyObject *__pyx_tuple__31;
2950 static PyObject *__pyx_tuple__32;
2951 static PyObject *__pyx_tuple__34;
2952 static PyObject *__pyx_tuple__35;
2953 static PyObject *__pyx_tuple__36;
2954 static PyObject *__pyx_tuple__38;
2955 static PyObject *__pyx_tuple__40;
2956 static PyObject *__pyx_tuple__42;
2957 static PyObject *__pyx_tuple__43;
2958 static PyObject *__pyx_tuple__44;
2959 static PyObject *__pyx_tuple__45;
2960 static PyObject *__pyx_tuple__46;
2961 static PyObject *__pyx_tuple__47;
2962 static PyObject *__pyx_codeobj__39;
2963 static PyObject *__pyx_codeobj__41;
2964 static PyObject *__pyx_codeobj__48;
2965 /* Late includes */
2966 
2967 /* "qutip/cy/sparse_routines.pxi":62
2968  *
2969  *
2970  * cdef void raise_error_CSR(int E, CSR_Matrix * C = NULL):             # <<<<<<<<<<<<<<
2971  *     if not C.numpy_lock and C != NULL:
2972  *         free_CSR(C)
2973  */
2974 
__pyx_f_5qutip_2cy_9br_tensor_raise_error_CSR(int __pyx_v_E,struct __pyx_opt_args_5qutip_2cy_9br_tensor_raise_error_CSR * __pyx_optional_args)2975 static void __pyx_f_5qutip_2cy_9br_tensor_raise_error_CSR(int __pyx_v_E, struct __pyx_opt_args_5qutip_2cy_9br_tensor_raise_error_CSR *__pyx_optional_args) {
2976   __pyx_t_5qutip_2cy_14sparse_structs_CSR_Matrix *__pyx_v_C = ((__pyx_t_5qutip_2cy_14sparse_structs_CSR_Matrix *)NULL);
2977   __Pyx_RefNannyDeclarations
2978   int __pyx_t_1;
2979   int __pyx_t_2;
2980   PyObject *__pyx_t_3 = NULL;
2981   int __pyx_lineno = 0;
2982   const char *__pyx_filename = NULL;
2983   int __pyx_clineno = 0;
2984   __Pyx_RefNannySetupContext("raise_error_CSR", 0);
2985   if (__pyx_optional_args) {
2986     if (__pyx_optional_args->__pyx_n > 0) {
2987       __pyx_v_C = __pyx_optional_args->C;
2988     }
2989   }
2990 
2991   /* "qutip/cy/sparse_routines.pxi":63
2992  *
2993  * cdef void raise_error_CSR(int E, CSR_Matrix * C = NULL):
2994  *     if not C.numpy_lock and C != NULL:             # <<<<<<<<<<<<<<
2995  *         free_CSR(C)
2996  *     if E == -1:
2997  */
2998   __pyx_t_2 = ((!(__pyx_v_C->numpy_lock != 0)) != 0);
2999   if (__pyx_t_2) {
3000   } else {
3001     __pyx_t_1 = __pyx_t_2;
3002     goto __pyx_L4_bool_binop_done;
3003   }
3004   __pyx_t_2 = ((__pyx_v_C != NULL) != 0);
3005   __pyx_t_1 = __pyx_t_2;
3006   __pyx_L4_bool_binop_done:;
3007   if (__pyx_t_1) {
3008 
3009     /* "qutip/cy/sparse_routines.pxi":64
3010  * cdef void raise_error_CSR(int E, CSR_Matrix * C = NULL):
3011  *     if not C.numpy_lock and C != NULL:
3012  *         free_CSR(C)             # <<<<<<<<<<<<<<
3013  *     if E == -1:
3014  *         raise MemoryError('Could not allocate memory.')
3015  */
3016     __pyx_f_5qutip_2cy_9br_tensor_free_CSR(__pyx_v_C);
3017 
3018     /* "qutip/cy/sparse_routines.pxi":63
3019  *
3020  * cdef void raise_error_CSR(int E, CSR_Matrix * C = NULL):
3021  *     if not C.numpy_lock and C != NULL:             # <<<<<<<<<<<<<<
3022  *         free_CSR(C)
3023  *     if E == -1:
3024  */
3025   }
3026 
3027   /* "qutip/cy/sparse_routines.pxi":65
3028  *     if not C.numpy_lock and C != NULL:
3029  *         free_CSR(C)
3030  *     if E == -1:             # <<<<<<<<<<<<<<
3031  *         raise MemoryError('Could not allocate memory.')
3032  *     elif E == -2:
3033  */
3034   switch (__pyx_v_E) {
3035     case -1L:
3036 
3037     /* "qutip/cy/sparse_routines.pxi":66
3038  *         free_CSR(C)
3039  *     if E == -1:
3040  *         raise MemoryError('Could not allocate memory.')             # <<<<<<<<<<<<<<
3041  *     elif E == -2:
3042  *         raise Exception('Error manipulating CSR_Matrix structure.')
3043  */
3044     __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_MemoryError, __pyx_tuple_, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 66, __pyx_L1_error)
3045     __Pyx_GOTREF(__pyx_t_3);
3046     __Pyx_Raise(__pyx_t_3, 0, 0, 0);
3047     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
3048     __PYX_ERR(0, 66, __pyx_L1_error)
3049 
3050     /* "qutip/cy/sparse_routines.pxi":65
3051  *     if not C.numpy_lock and C != NULL:
3052  *         free_CSR(C)
3053  *     if E == -1:             # <<<<<<<<<<<<<<
3054  *         raise MemoryError('Could not allocate memory.')
3055  *     elif E == -2:
3056  */
3057     break;
3058     case -2L:
3059 
3060     /* "qutip/cy/sparse_routines.pxi":68
3061  *         raise MemoryError('Could not allocate memory.')
3062  *     elif E == -2:
3063  *         raise Exception('Error manipulating CSR_Matrix structure.')             # <<<<<<<<<<<<<<
3064  *     elif E == -3:
3065  *         raise Exception('CSR_Matrix is not initialized.')
3066  */
3067     __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)
3068     __Pyx_GOTREF(__pyx_t_3);
3069     __Pyx_Raise(__pyx_t_3, 0, 0, 0);
3070     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
3071     __PYX_ERR(0, 68, __pyx_L1_error)
3072 
3073     /* "qutip/cy/sparse_routines.pxi":67
3074  *     if E == -1:
3075  *         raise MemoryError('Could not allocate memory.')
3076  *     elif E == -2:             # <<<<<<<<<<<<<<
3077  *         raise Exception('Error manipulating CSR_Matrix structure.')
3078  *     elif E == -3:
3079  */
3080     break;
3081     case -3L:
3082 
3083     /* "qutip/cy/sparse_routines.pxi":70
3084  *         raise Exception('Error manipulating CSR_Matrix structure.')
3085  *     elif E == -3:
3086  *         raise Exception('CSR_Matrix is not initialized.')             # <<<<<<<<<<<<<<
3087  *     elif E == -4:
3088  *         raise Exception('NumPy already has lock on data.')
3089  */
3090     __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)
3091     __Pyx_GOTREF(__pyx_t_3);
3092     __Pyx_Raise(__pyx_t_3, 0, 0, 0);
3093     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
3094     __PYX_ERR(0, 70, __pyx_L1_error)
3095 
3096     /* "qutip/cy/sparse_routines.pxi":69
3097  *     elif E == -2:
3098  *         raise Exception('Error manipulating CSR_Matrix structure.')
3099  *     elif E == -3:             # <<<<<<<<<<<<<<
3100  *         raise Exception('CSR_Matrix is not initialized.')
3101  *     elif E == -4:
3102  */
3103     break;
3104     case -4L:
3105 
3106     /* "qutip/cy/sparse_routines.pxi":72
3107  *         raise Exception('CSR_Matrix is not initialized.')
3108  *     elif E == -4:
3109  *         raise Exception('NumPy already has lock on data.')             # <<<<<<<<<<<<<<
3110  *     elif E == -5:
3111  *         raise Exception('Cannot expand data structures past max_length.')
3112  */
3113     __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)
3114     __Pyx_GOTREF(__pyx_t_3);
3115     __Pyx_Raise(__pyx_t_3, 0, 0, 0);
3116     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
3117     __PYX_ERR(0, 72, __pyx_L1_error)
3118 
3119     /* "qutip/cy/sparse_routines.pxi":71
3120  *     elif E == -3:
3121  *         raise Exception('CSR_Matrix is not initialized.')
3122  *     elif E == -4:             # <<<<<<<<<<<<<<
3123  *         raise Exception('NumPy already has lock on data.')
3124  *     elif E == -5:
3125  */
3126     break;
3127     case -5L:
3128 
3129     /* "qutip/cy/sparse_routines.pxi":74
3130  *         raise Exception('NumPy already has lock on data.')
3131  *     elif E == -5:
3132  *         raise Exception('Cannot expand data structures past max_length.')             # <<<<<<<<<<<<<<
3133  *     elif E == -6:
3134  *         raise Exception('CSR_Matrix cannot be expanded.')
3135  */
3136     __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)
3137     __Pyx_GOTREF(__pyx_t_3);
3138     __Pyx_Raise(__pyx_t_3, 0, 0, 0);
3139     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
3140     __PYX_ERR(0, 74, __pyx_L1_error)
3141 
3142     /* "qutip/cy/sparse_routines.pxi":73
3143  *     elif E == -4:
3144  *         raise Exception('NumPy already has lock on data.')
3145  *     elif E == -5:             # <<<<<<<<<<<<<<
3146  *         raise Exception('Cannot expand data structures past max_length.')
3147  *     elif E == -6:
3148  */
3149     break;
3150     case -6L:
3151 
3152     /* "qutip/cy/sparse_routines.pxi":76
3153  *         raise Exception('Cannot expand data structures past max_length.')
3154  *     elif E == -6:
3155  *         raise Exception('CSR_Matrix cannot be expanded.')             # <<<<<<<<<<<<<<
3156  *     elif E == -7:
3157  *         raise Exception('Data length cannot be larger than max_length')
3158  */
3159     __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)
3160     __Pyx_GOTREF(__pyx_t_3);
3161     __Pyx_Raise(__pyx_t_3, 0, 0, 0);
3162     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
3163     __PYX_ERR(0, 76, __pyx_L1_error)
3164 
3165     /* "qutip/cy/sparse_routines.pxi":75
3166  *     elif E == -5:
3167  *         raise Exception('Cannot expand data structures past max_length.')
3168  *     elif E == -6:             # <<<<<<<<<<<<<<
3169  *         raise Exception('CSR_Matrix cannot be expanded.')
3170  *     elif E == -7:
3171  */
3172     break;
3173     case -7L:
3174 
3175     /* "qutip/cy/sparse_routines.pxi":78
3176  *         raise Exception('CSR_Matrix cannot be expanded.')
3177  *     elif E == -7:
3178  *         raise Exception('Data length cannot be larger than max_length')             # <<<<<<<<<<<<<<
3179  *     else:
3180  *         raise Exception('Error in Cython code.')
3181  */
3182     __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)
3183     __Pyx_GOTREF(__pyx_t_3);
3184     __Pyx_Raise(__pyx_t_3, 0, 0, 0);
3185     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
3186     __PYX_ERR(0, 78, __pyx_L1_error)
3187 
3188     /* "qutip/cy/sparse_routines.pxi":77
3189  *     elif E == -6:
3190  *         raise Exception('CSR_Matrix cannot be expanded.')
3191  *     elif E == -7:             # <<<<<<<<<<<<<<
3192  *         raise Exception('Data length cannot be larger than max_length')
3193  *     else:
3194  */
3195     break;
3196     default:
3197 
3198     /* "qutip/cy/sparse_routines.pxi":80
3199  *         raise Exception('Data length cannot be larger than max_length')
3200  *     else:
3201  *         raise Exception('Error in Cython code.')             # <<<<<<<<<<<<<<
3202  *
3203  *
3204  */
3205     __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)
3206     __Pyx_GOTREF(__pyx_t_3);
3207     __Pyx_Raise(__pyx_t_3, 0, 0, 0);
3208     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
3209     __PYX_ERR(0, 80, __pyx_L1_error)
3210     break;
3211   }
3212 
3213   /* "qutip/cy/sparse_routines.pxi":62
3214  *
3215  *
3216  * cdef void raise_error_CSR(int E, CSR_Matrix * C = NULL):             # <<<<<<<<<<<<<<
3217  *     if not C.numpy_lock and C != NULL:
3218  *         free_CSR(C)
3219  */
3220 
3221   /* function exit code */
3222   __pyx_L1_error:;
3223   __Pyx_XDECREF(__pyx_t_3);
3224   __Pyx_WriteUnraisable("qutip.cy.br_tensor.raise_error_CSR", __pyx_clineno, __pyx_lineno, __pyx_filename, 1, 0);
3225   __Pyx_RefNannyFinishContext();
3226 }
3227 
3228 /* "qutip/cy/sparse_routines.pxi":83
3229  *
3230  *
3231  * cdef void raise_error_COO(int E, COO_Matrix * C = NULL):             # <<<<<<<<<<<<<<
3232  *     if not C.numpy_lock and C != NULL:
3233  *         free_COO(C)
3234  */
3235 
__pyx_f_5qutip_2cy_9br_tensor_raise_error_COO(int __pyx_v_E,struct __pyx_opt_args_5qutip_2cy_9br_tensor_raise_error_COO * __pyx_optional_args)3236 static void __pyx_f_5qutip_2cy_9br_tensor_raise_error_COO(int __pyx_v_E, struct __pyx_opt_args_5qutip_2cy_9br_tensor_raise_error_COO *__pyx_optional_args) {
3237   __pyx_t_5qutip_2cy_14sparse_structs_COO_Matrix *__pyx_v_C = ((__pyx_t_5qutip_2cy_14sparse_structs_COO_Matrix *)NULL);
3238   __Pyx_RefNannyDeclarations
3239   int __pyx_t_1;
3240   int __pyx_t_2;
3241   PyObject *__pyx_t_3 = NULL;
3242   int __pyx_lineno = 0;
3243   const char *__pyx_filename = NULL;
3244   int __pyx_clineno = 0;
3245   __Pyx_RefNannySetupContext("raise_error_COO", 0);
3246   if (__pyx_optional_args) {
3247     if (__pyx_optional_args->__pyx_n > 0) {
3248       __pyx_v_C = __pyx_optional_args->C;
3249     }
3250   }
3251 
3252   /* "qutip/cy/sparse_routines.pxi":84
3253  *
3254  * cdef void raise_error_COO(int E, COO_Matrix * C = NULL):
3255  *     if not C.numpy_lock and C != NULL:             # <<<<<<<<<<<<<<
3256  *         free_COO(C)
3257  *     if E == -1:
3258  */
3259   __pyx_t_2 = ((!(__pyx_v_C->numpy_lock != 0)) != 0);
3260   if (__pyx_t_2) {
3261   } else {
3262     __pyx_t_1 = __pyx_t_2;
3263     goto __pyx_L4_bool_binop_done;
3264   }
3265   __pyx_t_2 = ((__pyx_v_C != NULL) != 0);
3266   __pyx_t_1 = __pyx_t_2;
3267   __pyx_L4_bool_binop_done:;
3268   if (__pyx_t_1) {
3269 
3270     /* "qutip/cy/sparse_routines.pxi":85
3271  * cdef void raise_error_COO(int E, COO_Matrix * C = NULL):
3272  *     if not C.numpy_lock and C != NULL:
3273  *         free_COO(C)             # <<<<<<<<<<<<<<
3274  *     if E == -1:
3275  *         raise MemoryError('Could not allocate memory.')
3276  */
3277     __pyx_f_5qutip_2cy_9br_tensor_free_COO(__pyx_v_C);
3278 
3279     /* "qutip/cy/sparse_routines.pxi":84
3280  *
3281  * cdef void raise_error_COO(int E, COO_Matrix * C = NULL):
3282  *     if not C.numpy_lock and C != NULL:             # <<<<<<<<<<<<<<
3283  *         free_COO(C)
3284  *     if E == -1:
3285  */
3286   }
3287 
3288   /* "qutip/cy/sparse_routines.pxi":86
3289  *     if not C.numpy_lock and C != NULL:
3290  *         free_COO(C)
3291  *     if E == -1:             # <<<<<<<<<<<<<<
3292  *         raise MemoryError('Could not allocate memory.')
3293  *     elif E == -2:
3294  */
3295   switch (__pyx_v_E) {
3296     case -1L:
3297 
3298     /* "qutip/cy/sparse_routines.pxi":87
3299  *         free_COO(C)
3300  *     if E == -1:
3301  *         raise MemoryError('Could not allocate memory.')             # <<<<<<<<<<<<<<
3302  *     elif E == -2:
3303  *         raise Exception('Error manipulating COO_Matrix structure.')
3304  */
3305     __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_MemoryError, __pyx_tuple_, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 87, __pyx_L1_error)
3306     __Pyx_GOTREF(__pyx_t_3);
3307     __Pyx_Raise(__pyx_t_3, 0, 0, 0);
3308     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
3309     __PYX_ERR(0, 87, __pyx_L1_error)
3310 
3311     /* "qutip/cy/sparse_routines.pxi":86
3312  *     if not C.numpy_lock and C != NULL:
3313  *         free_COO(C)
3314  *     if E == -1:             # <<<<<<<<<<<<<<
3315  *         raise MemoryError('Could not allocate memory.')
3316  *     elif E == -2:
3317  */
3318     break;
3319     case -2L:
3320 
3321     /* "qutip/cy/sparse_routines.pxi":89
3322  *         raise MemoryError('Could not allocate memory.')
3323  *     elif E == -2:
3324  *         raise Exception('Error manipulating COO_Matrix structure.')             # <<<<<<<<<<<<<<
3325  *     elif E == -3:
3326  *         raise Exception('COO_Matrix is not initialized.')
3327  */
3328     __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)
3329     __Pyx_GOTREF(__pyx_t_3);
3330     __Pyx_Raise(__pyx_t_3, 0, 0, 0);
3331     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
3332     __PYX_ERR(0, 89, __pyx_L1_error)
3333 
3334     /* "qutip/cy/sparse_routines.pxi":88
3335  *     if E == -1:
3336  *         raise MemoryError('Could not allocate memory.')
3337  *     elif E == -2:             # <<<<<<<<<<<<<<
3338  *         raise Exception('Error manipulating COO_Matrix structure.')
3339  *     elif E == -3:
3340  */
3341     break;
3342     case -3L:
3343 
3344     /* "qutip/cy/sparse_routines.pxi":91
3345  *         raise Exception('Error manipulating COO_Matrix structure.')
3346  *     elif E == -3:
3347  *         raise Exception('COO_Matrix is not initialized.')             # <<<<<<<<<<<<<<
3348  *     elif E == -4:
3349  *         raise Exception('NumPy already has lock on data.')
3350  */
3351     __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)
3352     __Pyx_GOTREF(__pyx_t_3);
3353     __Pyx_Raise(__pyx_t_3, 0, 0, 0);
3354     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
3355     __PYX_ERR(0, 91, __pyx_L1_error)
3356 
3357     /* "qutip/cy/sparse_routines.pxi":90
3358  *     elif E == -2:
3359  *         raise Exception('Error manipulating COO_Matrix structure.')
3360  *     elif E == -3:             # <<<<<<<<<<<<<<
3361  *         raise Exception('COO_Matrix is not initialized.')
3362  *     elif E == -4:
3363  */
3364     break;
3365     case -4L:
3366 
3367     /* "qutip/cy/sparse_routines.pxi":93
3368  *         raise Exception('COO_Matrix is not initialized.')
3369  *     elif E == -4:
3370  *         raise Exception('NumPy already has lock on data.')             # <<<<<<<<<<<<<<
3371  *     elif E == -5:
3372  *         raise Exception('Cannot expand data structures past max_length.')
3373  */
3374     __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)
3375     __Pyx_GOTREF(__pyx_t_3);
3376     __Pyx_Raise(__pyx_t_3, 0, 0, 0);
3377     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
3378     __PYX_ERR(0, 93, __pyx_L1_error)
3379 
3380     /* "qutip/cy/sparse_routines.pxi":92
3381  *     elif E == -3:
3382  *         raise Exception('COO_Matrix is not initialized.')
3383  *     elif E == -4:             # <<<<<<<<<<<<<<
3384  *         raise Exception('NumPy already has lock on data.')
3385  *     elif E == -5:
3386  */
3387     break;
3388     case -5L:
3389 
3390     /* "qutip/cy/sparse_routines.pxi":95
3391  *         raise Exception('NumPy already has lock on data.')
3392  *     elif E == -5:
3393  *         raise Exception('Cannot expand data structures past max_length.')             # <<<<<<<<<<<<<<
3394  *     elif E == -6:
3395  *         raise Exception('COO_Matrix cannot be expanded.')
3396  */
3397     __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)
3398     __Pyx_GOTREF(__pyx_t_3);
3399     __Pyx_Raise(__pyx_t_3, 0, 0, 0);
3400     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
3401     __PYX_ERR(0, 95, __pyx_L1_error)
3402 
3403     /* "qutip/cy/sparse_routines.pxi":94
3404  *     elif E == -4:
3405  *         raise Exception('NumPy already has lock on data.')
3406  *     elif E == -5:             # <<<<<<<<<<<<<<
3407  *         raise Exception('Cannot expand data structures past max_length.')
3408  *     elif E == -6:
3409  */
3410     break;
3411     case -6L:
3412 
3413     /* "qutip/cy/sparse_routines.pxi":97
3414  *         raise Exception('Cannot expand data structures past max_length.')
3415  *     elif E == -6:
3416  *         raise Exception('COO_Matrix cannot be expanded.')             # <<<<<<<<<<<<<<
3417  *     elif E == -7:
3418  *         raise Exception('Data length cannot be larger than max_length')
3419  */
3420     __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)
3421     __Pyx_GOTREF(__pyx_t_3);
3422     __Pyx_Raise(__pyx_t_3, 0, 0, 0);
3423     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
3424     __PYX_ERR(0, 97, __pyx_L1_error)
3425 
3426     /* "qutip/cy/sparse_routines.pxi":96
3427  *     elif E == -5:
3428  *         raise Exception('Cannot expand data structures past max_length.')
3429  *     elif E == -6:             # <<<<<<<<<<<<<<
3430  *         raise Exception('COO_Matrix cannot be expanded.')
3431  *     elif E == -7:
3432  */
3433     break;
3434     case -7L:
3435 
3436     /* "qutip/cy/sparse_routines.pxi":99
3437  *         raise Exception('COO_Matrix cannot be expanded.')
3438  *     elif E == -7:
3439  *         raise Exception('Data length cannot be larger than max_length')             # <<<<<<<<<<<<<<
3440  *     else:
3441  *         raise Exception('Error in Cython code.')
3442  */
3443     __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)
3444     __Pyx_GOTREF(__pyx_t_3);
3445     __Pyx_Raise(__pyx_t_3, 0, 0, 0);
3446     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
3447     __PYX_ERR(0, 99, __pyx_L1_error)
3448 
3449     /* "qutip/cy/sparse_routines.pxi":98
3450  *     elif E == -6:
3451  *         raise Exception('COO_Matrix cannot be expanded.')
3452  *     elif E == -7:             # <<<<<<<<<<<<<<
3453  *         raise Exception('Data length cannot be larger than max_length')
3454  *     else:
3455  */
3456     break;
3457     default:
3458 
3459     /* "qutip/cy/sparse_routines.pxi":101
3460  *         raise Exception('Data length cannot be larger than max_length')
3461  *     else:
3462  *         raise Exception('Error in Cython code.')             # <<<<<<<<<<<<<<
3463  *
3464  *
3465  */
3466     __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)
3467     __Pyx_GOTREF(__pyx_t_3);
3468     __Pyx_Raise(__pyx_t_3, 0, 0, 0);
3469     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
3470     __PYX_ERR(0, 101, __pyx_L1_error)
3471     break;
3472   }
3473 
3474   /* "qutip/cy/sparse_routines.pxi":83
3475  *
3476  *
3477  * cdef void raise_error_COO(int E, COO_Matrix * C = NULL):             # <<<<<<<<<<<<<<
3478  *     if not C.numpy_lock and C != NULL:
3479  *         free_COO(C)
3480  */
3481 
3482   /* function exit code */
3483   __pyx_L1_error:;
3484   __Pyx_XDECREF(__pyx_t_3);
3485   __Pyx_WriteUnraisable("qutip.cy.br_tensor.raise_error_COO", __pyx_clineno, __pyx_lineno, __pyx_filename, 1, 0);
3486   __Pyx_RefNannyFinishContext();
3487 }
3488 
3489 /* "qutip/cy/sparse_routines.pxi":104
3490  *
3491  *
3492  * cdef inline int int_min(int a, int b) nogil:             # <<<<<<<<<<<<<<
3493  *     return b if b < a else a
3494  *
3495  */
3496 
__pyx_f_5qutip_2cy_9br_tensor_int_min(int __pyx_v_a,int __pyx_v_b)3497 static CYTHON_INLINE int __pyx_f_5qutip_2cy_9br_tensor_int_min(int __pyx_v_a, int __pyx_v_b) {
3498   int __pyx_r;
3499   int __pyx_t_1;
3500 
3501   /* "qutip/cy/sparse_routines.pxi":105
3502  *
3503  * cdef inline int int_min(int a, int b) nogil:
3504  *     return b if b < a else a             # <<<<<<<<<<<<<<
3505  *
3506  * cdef inline int int_max(int a, int b) nogil:
3507  */
3508   if (((__pyx_v_b < __pyx_v_a) != 0)) {
3509     __pyx_t_1 = __pyx_v_b;
3510   } else {
3511     __pyx_t_1 = __pyx_v_a;
3512   }
3513   __pyx_r = __pyx_t_1;
3514   goto __pyx_L0;
3515 
3516   /* "qutip/cy/sparse_routines.pxi":104
3517  *
3518  *
3519  * cdef inline int int_min(int a, int b) nogil:             # <<<<<<<<<<<<<<
3520  *     return b if b < a else a
3521  *
3522  */
3523 
3524   /* function exit code */
3525   __pyx_L0:;
3526   return __pyx_r;
3527 }
3528 
3529 /* "qutip/cy/sparse_routines.pxi":107
3530  *     return b if b < a else a
3531  *
3532  * cdef inline int int_max(int a, int b) nogil:             # <<<<<<<<<<<<<<
3533  *     return a if a > b else b
3534  *
3535  */
3536 
__pyx_f_5qutip_2cy_9br_tensor_int_max(int __pyx_v_a,int __pyx_v_b)3537 static CYTHON_INLINE int __pyx_f_5qutip_2cy_9br_tensor_int_max(int __pyx_v_a, int __pyx_v_b) {
3538   int __pyx_r;
3539   int __pyx_t_1;
3540 
3541   /* "qutip/cy/sparse_routines.pxi":108
3542  *
3543  * cdef inline int int_max(int a, int b) nogil:
3544  *     return a if a > b else b             # <<<<<<<<<<<<<<
3545  *
3546  *
3547  */
3548   if (((__pyx_v_a > __pyx_v_b) != 0)) {
3549     __pyx_t_1 = __pyx_v_a;
3550   } else {
3551     __pyx_t_1 = __pyx_v_b;
3552   }
3553   __pyx_r = __pyx_t_1;
3554   goto __pyx_L0;
3555 
3556   /* "qutip/cy/sparse_routines.pxi":107
3557  *     return b if b < a else a
3558  *
3559  * cdef inline int int_max(int a, int b) nogil:             # <<<<<<<<<<<<<<
3560  *     return a if a > b else b
3561  *
3562  */
3563 
3564   /* function exit code */
3565   __pyx_L0:;
3566   return __pyx_r;
3567 }
3568 
3569 /* "qutip/cy/sparse_routines.pxi":113
3570  * @cython.boundscheck(False)
3571  * @cython.wraparound(False)
3572  * cdef void init_CSR(CSR_Matrix * mat, int nnz, int nrows, int ncols = 0,             # <<<<<<<<<<<<<<
3573  *                 int max_length = 0, int init_zeros = 1):
3574  *     """
3575  */
3576 
__pyx_f_5qutip_2cy_9br_tensor_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_9br_tensor_init_CSR * __pyx_optional_args)3577 static void __pyx_f_5qutip_2cy_9br_tensor_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_9br_tensor_init_CSR *__pyx_optional_args) {
3578   int __pyx_v_ncols = ((int)0);
3579   int __pyx_v_max_length = ((int)0);
3580   int __pyx_v_init_zeros = ((int)1);
3581   __Pyx_RefNannyDeclarations
3582   int __pyx_t_1;
3583   struct __pyx_opt_args_5qutip_2cy_9br_tensor_raise_error_CSR __pyx_t_2;
3584   __Pyx_RefNannySetupContext("init_CSR", 0);
3585   if (__pyx_optional_args) {
3586     if (__pyx_optional_args->__pyx_n > 0) {
3587       __pyx_v_ncols = __pyx_optional_args->ncols;
3588       if (__pyx_optional_args->__pyx_n > 1) {
3589         __pyx_v_max_length = __pyx_optional_args->max_length;
3590         if (__pyx_optional_args->__pyx_n > 2) {
3591           __pyx_v_init_zeros = __pyx_optional_args->init_zeros;
3592         }
3593       }
3594     }
3595   }
3596 
3597   /* "qutip/cy/sparse_routines.pxi":134
3598  *         Default value of zero indicates no resizing.
3599  *     """
3600  *     if max_length == 0:             # <<<<<<<<<<<<<<
3601  *         max_length = nnz
3602  *     if nnz > max_length:
3603  */
3604   __pyx_t_1 = ((__pyx_v_max_length == 0) != 0);
3605   if (__pyx_t_1) {
3606 
3607     /* "qutip/cy/sparse_routines.pxi":135
3608  *     """
3609  *     if max_length == 0:
3610  *         max_length = nnz             # <<<<<<<<<<<<<<
3611  *     if nnz > max_length:
3612  *         raise_error_CSR(-7, mat)
3613  */
3614     __pyx_v_max_length = __pyx_v_nnz;
3615 
3616     /* "qutip/cy/sparse_routines.pxi":134
3617  *         Default value of zero indicates no resizing.
3618  *     """
3619  *     if max_length == 0:             # <<<<<<<<<<<<<<
3620  *         max_length = nnz
3621  *     if nnz > max_length:
3622  */
3623   }
3624 
3625   /* "qutip/cy/sparse_routines.pxi":136
3626  *     if max_length == 0:
3627  *         max_length = nnz
3628  *     if nnz > max_length:             # <<<<<<<<<<<<<<
3629  *         raise_error_CSR(-7, mat)
3630  *     if init_zeros:
3631  */
3632   __pyx_t_1 = ((__pyx_v_nnz > __pyx_v_max_length) != 0);
3633   if (__pyx_t_1) {
3634 
3635     /* "qutip/cy/sparse_routines.pxi":137
3636  *         max_length = nnz
3637  *     if nnz > max_length:
3638  *         raise_error_CSR(-7, mat)             # <<<<<<<<<<<<<<
3639  *     if init_zeros:
3640  *         mat.data = <double complex *>PyDataMem_NEW_ZEROED(nnz, sizeof(double complex))
3641  */
3642     __pyx_t_2.__pyx_n = 1;
3643     __pyx_t_2.C = __pyx_v_mat;
3644     __pyx_f_5qutip_2cy_9br_tensor_raise_error_CSR(-7, &__pyx_t_2);
3645 
3646     /* "qutip/cy/sparse_routines.pxi":136
3647  *     if max_length == 0:
3648  *         max_length = nnz
3649  *     if nnz > max_length:             # <<<<<<<<<<<<<<
3650  *         raise_error_CSR(-7, mat)
3651  *     if init_zeros:
3652  */
3653   }
3654 
3655   /* "qutip/cy/sparse_routines.pxi":138
3656  *     if nnz > max_length:
3657  *         raise_error_CSR(-7, mat)
3658  *     if init_zeros:             # <<<<<<<<<<<<<<
3659  *         mat.data = <double complex *>PyDataMem_NEW_ZEROED(nnz, sizeof(double complex))
3660  *     else:
3661  */
3662   __pyx_t_1 = (__pyx_v_init_zeros != 0);
3663   if (__pyx_t_1) {
3664 
3665     /* "qutip/cy/sparse_routines.pxi":139
3666  *         raise_error_CSR(-7, mat)
3667  *     if init_zeros:
3668  *         mat.data = <double complex *>PyDataMem_NEW_ZEROED(nnz, sizeof(double complex))             # <<<<<<<<<<<<<<
3669  *     else:
3670  *         mat.data = <double complex *>PyDataMem_NEW(nnz * sizeof(double complex))
3671  */
3672     __pyx_v_mat->data = ((__pyx_t_double_complex *)PyDataMem_NEW_ZEROED(__pyx_v_nnz, (sizeof(__pyx_t_double_complex))));
3673 
3674     /* "qutip/cy/sparse_routines.pxi":138
3675  *     if nnz > max_length:
3676  *         raise_error_CSR(-7, mat)
3677  *     if init_zeros:             # <<<<<<<<<<<<<<
3678  *         mat.data = <double complex *>PyDataMem_NEW_ZEROED(nnz, sizeof(double complex))
3679  *     else:
3680  */
3681     goto __pyx_L5;
3682   }
3683 
3684   /* "qutip/cy/sparse_routines.pxi":141
3685  *         mat.data = <double complex *>PyDataMem_NEW_ZEROED(nnz, sizeof(double complex))
3686  *     else:
3687  *         mat.data = <double complex *>PyDataMem_NEW(nnz * sizeof(double complex))             # <<<<<<<<<<<<<<
3688  *     if mat.data == NULL:
3689  *         raise_error_CSR(-1, mat)
3690  */
3691   /*else*/ {
3692     __pyx_v_mat->data = ((__pyx_t_double_complex *)PyDataMem_NEW((__pyx_v_nnz * (sizeof(__pyx_t_double_complex)))));
3693   }
3694   __pyx_L5:;
3695 
3696   /* "qutip/cy/sparse_routines.pxi":142
3697  *     else:
3698  *         mat.data = <double complex *>PyDataMem_NEW(nnz * sizeof(double complex))
3699  *     if mat.data == NULL:             # <<<<<<<<<<<<<<
3700  *         raise_error_CSR(-1, mat)
3701  *     if init_zeros:
3702  */
3703   __pyx_t_1 = ((__pyx_v_mat->data == NULL) != 0);
3704   if (__pyx_t_1) {
3705 
3706     /* "qutip/cy/sparse_routines.pxi":143
3707  *         mat.data = <double complex *>PyDataMem_NEW(nnz * sizeof(double complex))
3708  *     if mat.data == NULL:
3709  *         raise_error_CSR(-1, mat)             # <<<<<<<<<<<<<<
3710  *     if init_zeros:
3711  *         mat.indices = <int *>PyDataMem_NEW_ZEROED(nnz, sizeof(int))
3712  */
3713     __pyx_t_2.__pyx_n = 1;
3714     __pyx_t_2.C = __pyx_v_mat;
3715     __pyx_f_5qutip_2cy_9br_tensor_raise_error_CSR(-1, &__pyx_t_2);
3716 
3717     /* "qutip/cy/sparse_routines.pxi":142
3718  *     else:
3719  *         mat.data = <double complex *>PyDataMem_NEW(nnz * sizeof(double complex))
3720  *     if mat.data == NULL:             # <<<<<<<<<<<<<<
3721  *         raise_error_CSR(-1, mat)
3722  *     if init_zeros:
3723  */
3724   }
3725 
3726   /* "qutip/cy/sparse_routines.pxi":144
3727  *     if mat.data == NULL:
3728  *         raise_error_CSR(-1, mat)
3729  *     if init_zeros:             # <<<<<<<<<<<<<<
3730  *         mat.indices = <int *>PyDataMem_NEW_ZEROED(nnz, sizeof(int))
3731  *         mat.indptr = <int *>PyDataMem_NEW_ZEROED((nrows+1), sizeof(int))
3732  */
3733   __pyx_t_1 = (__pyx_v_init_zeros != 0);
3734   if (__pyx_t_1) {
3735 
3736     /* "qutip/cy/sparse_routines.pxi":145
3737  *         raise_error_CSR(-1, mat)
3738  *     if init_zeros:
3739  *         mat.indices = <int *>PyDataMem_NEW_ZEROED(nnz, sizeof(int))             # <<<<<<<<<<<<<<
3740  *         mat.indptr = <int *>PyDataMem_NEW_ZEROED((nrows+1), sizeof(int))
3741  *     else:
3742  */
3743     __pyx_v_mat->indices = ((int *)PyDataMem_NEW_ZEROED(__pyx_v_nnz, (sizeof(int))));
3744 
3745     /* "qutip/cy/sparse_routines.pxi":146
3746  *     if init_zeros:
3747  *         mat.indices = <int *>PyDataMem_NEW_ZEROED(nnz, sizeof(int))
3748  *         mat.indptr = <int *>PyDataMem_NEW_ZEROED((nrows+1), sizeof(int))             # <<<<<<<<<<<<<<
3749  *     else:
3750  *         mat.indices = <int *>PyDataMem_NEW(nnz * sizeof(int))
3751  */
3752     __pyx_v_mat->indptr = ((int *)PyDataMem_NEW_ZEROED((__pyx_v_nrows + 1), (sizeof(int))));
3753 
3754     /* "qutip/cy/sparse_routines.pxi":144
3755  *     if mat.data == NULL:
3756  *         raise_error_CSR(-1, mat)
3757  *     if init_zeros:             # <<<<<<<<<<<<<<
3758  *         mat.indices = <int *>PyDataMem_NEW_ZEROED(nnz, sizeof(int))
3759  *         mat.indptr = <int *>PyDataMem_NEW_ZEROED((nrows+1), sizeof(int))
3760  */
3761     goto __pyx_L7;
3762   }
3763 
3764   /* "qutip/cy/sparse_routines.pxi":148
3765  *         mat.indptr = <int *>PyDataMem_NEW_ZEROED((nrows+1), sizeof(int))
3766  *     else:
3767  *         mat.indices = <int *>PyDataMem_NEW(nnz * sizeof(int))             # <<<<<<<<<<<<<<
3768  *         mat.indptr = <int *>PyDataMem_NEW((nrows+1) * sizeof(int))
3769  *     mat.nnz = nnz
3770  */
3771   /*else*/ {
3772     __pyx_v_mat->indices = ((int *)PyDataMem_NEW((__pyx_v_nnz * (sizeof(int)))));
3773 
3774     /* "qutip/cy/sparse_routines.pxi":149
3775  *     else:
3776  *         mat.indices = <int *>PyDataMem_NEW(nnz * sizeof(int))
3777  *         mat.indptr = <int *>PyDataMem_NEW((nrows+1) * sizeof(int))             # <<<<<<<<<<<<<<
3778  *     mat.nnz = nnz
3779  *     mat.nrows = nrows
3780  */
3781     __pyx_v_mat->indptr = ((int *)PyDataMem_NEW(((__pyx_v_nrows + 1) * (sizeof(int)))));
3782   }
3783   __pyx_L7:;
3784 
3785   /* "qutip/cy/sparse_routines.pxi":150
3786  *         mat.indices = <int *>PyDataMem_NEW(nnz * sizeof(int))
3787  *         mat.indptr = <int *>PyDataMem_NEW((nrows+1) * sizeof(int))
3788  *     mat.nnz = nnz             # <<<<<<<<<<<<<<
3789  *     mat.nrows = nrows
3790  *     if ncols == 0:
3791  */
3792   __pyx_v_mat->nnz = __pyx_v_nnz;
3793 
3794   /* "qutip/cy/sparse_routines.pxi":151
3795  *         mat.indptr = <int *>PyDataMem_NEW((nrows+1) * sizeof(int))
3796  *     mat.nnz = nnz
3797  *     mat.nrows = nrows             # <<<<<<<<<<<<<<
3798  *     if ncols == 0:
3799  *         mat.ncols = nrows
3800  */
3801   __pyx_v_mat->nrows = __pyx_v_nrows;
3802 
3803   /* "qutip/cy/sparse_routines.pxi":152
3804  *     mat.nnz = nnz
3805  *     mat.nrows = nrows
3806  *     if ncols == 0:             # <<<<<<<<<<<<<<
3807  *         mat.ncols = nrows
3808  *     else:
3809  */
3810   __pyx_t_1 = ((__pyx_v_ncols == 0) != 0);
3811   if (__pyx_t_1) {
3812 
3813     /* "qutip/cy/sparse_routines.pxi":153
3814  *     mat.nrows = nrows
3815  *     if ncols == 0:
3816  *         mat.ncols = nrows             # <<<<<<<<<<<<<<
3817  *     else:
3818  *         mat.ncols = ncols
3819  */
3820     __pyx_v_mat->ncols = __pyx_v_nrows;
3821 
3822     /* "qutip/cy/sparse_routines.pxi":152
3823  *     mat.nnz = nnz
3824  *     mat.nrows = nrows
3825  *     if ncols == 0:             # <<<<<<<<<<<<<<
3826  *         mat.ncols = nrows
3827  *     else:
3828  */
3829     goto __pyx_L8;
3830   }
3831 
3832   /* "qutip/cy/sparse_routines.pxi":155
3833  *         mat.ncols = nrows
3834  *     else:
3835  *         mat.ncols = ncols             # <<<<<<<<<<<<<<
3836  *     mat.is_set = 1
3837  *     mat.max_length = max_length
3838  */
3839   /*else*/ {
3840     __pyx_v_mat->ncols = __pyx_v_ncols;
3841   }
3842   __pyx_L8:;
3843 
3844   /* "qutip/cy/sparse_routines.pxi":156
3845  *     else:
3846  *         mat.ncols = ncols
3847  *     mat.is_set = 1             # <<<<<<<<<<<<<<
3848  *     mat.max_length = max_length
3849  *     mat.numpy_lock = 0
3850  */
3851   __pyx_v_mat->is_set = 1;
3852 
3853   /* "qutip/cy/sparse_routines.pxi":157
3854  *         mat.ncols = ncols
3855  *     mat.is_set = 1
3856  *     mat.max_length = max_length             # <<<<<<<<<<<<<<
3857  *     mat.numpy_lock = 0
3858  *
3859  */
3860   __pyx_v_mat->max_length = __pyx_v_max_length;
3861 
3862   /* "qutip/cy/sparse_routines.pxi":158
3863  *     mat.is_set = 1
3864  *     mat.max_length = max_length
3865  *     mat.numpy_lock = 0             # <<<<<<<<<<<<<<
3866  *
3867  *
3868  */
3869   __pyx_v_mat->numpy_lock = 0;
3870 
3871   /* "qutip/cy/sparse_routines.pxi":113
3872  * @cython.boundscheck(False)
3873  * @cython.wraparound(False)
3874  * cdef void init_CSR(CSR_Matrix * mat, int nnz, int nrows, int ncols = 0,             # <<<<<<<<<<<<<<
3875  *                 int max_length = 0, int init_zeros = 1):
3876  *     """
3877  */
3878 
3879   /* function exit code */
3880   __Pyx_RefNannyFinishContext();
3881 }
3882 
3883 /* "qutip/cy/sparse_routines.pxi":163
3884  * @cython.boundscheck(False)
3885  * @cython.wraparound(False)
3886  * cdef void copy_CSR(CSR_Matrix * out, CSR_Matrix * mat):             # <<<<<<<<<<<<<<
3887  *     """
3888  *     Copy a CSR_Matrix.
3889  */
3890 
__pyx_f_5qutip_2cy_9br_tensor_copy_CSR(__pyx_t_5qutip_2cy_14sparse_structs_CSR_Matrix * __pyx_v_out,__pyx_t_5qutip_2cy_14sparse_structs_CSR_Matrix * __pyx_v_mat)3891 static void __pyx_f_5qutip_2cy_9br_tensor_copy_CSR(__pyx_t_5qutip_2cy_14sparse_structs_CSR_Matrix *__pyx_v_out, __pyx_t_5qutip_2cy_14sparse_structs_CSR_Matrix *__pyx_v_mat) {
3892   size_t __pyx_v_kk;
3893   __Pyx_RefNannyDeclarations
3894   int __pyx_t_1;
3895   struct __pyx_opt_args_5qutip_2cy_9br_tensor_init_CSR __pyx_t_2;
3896   int __pyx_t_3;
3897   int __pyx_t_4;
3898   size_t __pyx_t_5;
3899   long __pyx_t_6;
3900   long __pyx_t_7;
3901   __Pyx_RefNannySetupContext("copy_CSR", 0);
3902 
3903   /* "qutip/cy/sparse_routines.pxi":168
3904  *     """
3905  *     cdef size_t kk
3906  *     if not mat.is_set:             # <<<<<<<<<<<<<<
3907  *         raise_error_CSR(-3)
3908  *     elif out.is_set:
3909  */
3910   __pyx_t_1 = ((!(__pyx_v_mat->is_set != 0)) != 0);
3911   if (__pyx_t_1) {
3912 
3913     /* "qutip/cy/sparse_routines.pxi":169
3914  *     cdef size_t kk
3915  *     if not mat.is_set:
3916  *         raise_error_CSR(-3)             # <<<<<<<<<<<<<<
3917  *     elif out.is_set:
3918  *         raise_error_CSR(-2)
3919  */
3920     __pyx_f_5qutip_2cy_9br_tensor_raise_error_CSR(-3, NULL);
3921 
3922     /* "qutip/cy/sparse_routines.pxi":168
3923  *     """
3924  *     cdef size_t kk
3925  *     if not mat.is_set:             # <<<<<<<<<<<<<<
3926  *         raise_error_CSR(-3)
3927  *     elif out.is_set:
3928  */
3929     goto __pyx_L3;
3930   }
3931 
3932   /* "qutip/cy/sparse_routines.pxi":170
3933  *     if not mat.is_set:
3934  *         raise_error_CSR(-3)
3935  *     elif out.is_set:             # <<<<<<<<<<<<<<
3936  *         raise_error_CSR(-2)
3937  *     init_CSR(out, mat.nnz, mat.nrows, mat.nrows, mat.max_length)
3938  */
3939   __pyx_t_1 = (__pyx_v_out->is_set != 0);
3940   if (__pyx_t_1) {
3941 
3942     /* "qutip/cy/sparse_routines.pxi":171
3943  *         raise_error_CSR(-3)
3944  *     elif out.is_set:
3945  *         raise_error_CSR(-2)             # <<<<<<<<<<<<<<
3946  *     init_CSR(out, mat.nnz, mat.nrows, mat.nrows, mat.max_length)
3947  *     # We cannot use memcpy here since there are issues with
3948  */
3949     __pyx_f_5qutip_2cy_9br_tensor_raise_error_CSR(-2, NULL);
3950 
3951     /* "qutip/cy/sparse_routines.pxi":170
3952  *     if not mat.is_set:
3953  *         raise_error_CSR(-3)
3954  *     elif out.is_set:             # <<<<<<<<<<<<<<
3955  *         raise_error_CSR(-2)
3956  *     init_CSR(out, mat.nnz, mat.nrows, mat.nrows, mat.max_length)
3957  */
3958   }
3959   __pyx_L3:;
3960 
3961   /* "qutip/cy/sparse_routines.pxi":172
3962  *     elif out.is_set:
3963  *         raise_error_CSR(-2)
3964  *     init_CSR(out, mat.nnz, mat.nrows, mat.nrows, mat.max_length)             # <<<<<<<<<<<<<<
3965  *     # We cannot use memcpy here since there are issues with
3966  *     # doing so on Win with the GCC compiler
3967  */
3968   __pyx_t_2.__pyx_n = 2;
3969   __pyx_t_2.ncols = __pyx_v_mat->nrows;
3970   __pyx_t_2.max_length = __pyx_v_mat->max_length;
3971   __pyx_f_5qutip_2cy_9br_tensor_init_CSR(__pyx_v_out, __pyx_v_mat->nnz, __pyx_v_mat->nrows, &__pyx_t_2);
3972 
3973   /* "qutip/cy/sparse_routines.pxi":175
3974  *     # We cannot use memcpy here since there are issues with
3975  *     # doing so on Win with the GCC compiler
3976  *     for kk in range(mat.nnz):             # <<<<<<<<<<<<<<
3977  *         out.data[kk] = mat.data[kk]
3978  *         out.indices[kk] = mat.indices[kk]
3979  */
3980   __pyx_t_3 = __pyx_v_mat->nnz;
3981   __pyx_t_4 = __pyx_t_3;
3982   for (__pyx_t_5 = 0; __pyx_t_5 < __pyx_t_4; __pyx_t_5+=1) {
3983     __pyx_v_kk = __pyx_t_5;
3984 
3985     /* "qutip/cy/sparse_routines.pxi":176
3986  *     # doing so on Win with the GCC compiler
3987  *     for kk in range(mat.nnz):
3988  *         out.data[kk] = mat.data[kk]             # <<<<<<<<<<<<<<
3989  *         out.indices[kk] = mat.indices[kk]
3990  *     for kk in range(mat.nrows+1):
3991  */
3992     (__pyx_v_out->data[__pyx_v_kk]) = (__pyx_v_mat->data[__pyx_v_kk]);
3993 
3994     /* "qutip/cy/sparse_routines.pxi":177
3995  *     for kk in range(mat.nnz):
3996  *         out.data[kk] = mat.data[kk]
3997  *         out.indices[kk] = mat.indices[kk]             # <<<<<<<<<<<<<<
3998  *     for kk in range(mat.nrows+1):
3999  *         out.indptr[kk] = mat.indptr[kk]
4000  */
4001     (__pyx_v_out->indices[__pyx_v_kk]) = (__pyx_v_mat->indices[__pyx_v_kk]);
4002   }
4003 
4004   /* "qutip/cy/sparse_routines.pxi":178
4005  *         out.data[kk] = mat.data[kk]
4006  *         out.indices[kk] = mat.indices[kk]
4007  *     for kk in range(mat.nrows+1):             # <<<<<<<<<<<<<<
4008  *         out.indptr[kk] = mat.indptr[kk]
4009  *
4010  */
4011   __pyx_t_6 = (__pyx_v_mat->nrows + 1);
4012   __pyx_t_7 = __pyx_t_6;
4013   for (__pyx_t_5 = 0; __pyx_t_5 < __pyx_t_7; __pyx_t_5+=1) {
4014     __pyx_v_kk = __pyx_t_5;
4015 
4016     /* "qutip/cy/sparse_routines.pxi":179
4017  *         out.indices[kk] = mat.indices[kk]
4018  *     for kk in range(mat.nrows+1):
4019  *         out.indptr[kk] = mat.indptr[kk]             # <<<<<<<<<<<<<<
4020  *
4021  *
4022  */
4023     (__pyx_v_out->indptr[__pyx_v_kk]) = (__pyx_v_mat->indptr[__pyx_v_kk]);
4024   }
4025 
4026   /* "qutip/cy/sparse_routines.pxi":163
4027  * @cython.boundscheck(False)
4028  * @cython.wraparound(False)
4029  * cdef void copy_CSR(CSR_Matrix * out, CSR_Matrix * mat):             # <<<<<<<<<<<<<<
4030  *     """
4031  *     Copy a CSR_Matrix.
4032  */
4033 
4034   /* function exit code */
4035   __Pyx_RefNannyFinishContext();
4036 }
4037 
4038 /* "qutip/cy/sparse_routines.pxi":184
4039  * @cython.boundscheck(False)
4040  * @cython.wraparound(False)
4041  * cdef void init_COO(COO_Matrix * mat, int nnz, int nrows, int ncols = 0,             # <<<<<<<<<<<<<<
4042  *                 int max_length = 0, int init_zeros = 1):
4043  *     """
4044  */
4045 
__pyx_f_5qutip_2cy_9br_tensor_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_9br_tensor_init_COO * __pyx_optional_args)4046 static void __pyx_f_5qutip_2cy_9br_tensor_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_9br_tensor_init_COO *__pyx_optional_args) {
4047   int __pyx_v_ncols = ((int)0);
4048   int __pyx_v_max_length = ((int)0);
4049   int __pyx_v_init_zeros = ((int)1);
4050   __Pyx_RefNannyDeclarations
4051   int __pyx_t_1;
4052   struct __pyx_opt_args_5qutip_2cy_9br_tensor_raise_error_COO __pyx_t_2;
4053   __Pyx_RefNannySetupContext("init_COO", 0);
4054   if (__pyx_optional_args) {
4055     if (__pyx_optional_args->__pyx_n > 0) {
4056       __pyx_v_ncols = __pyx_optional_args->ncols;
4057       if (__pyx_optional_args->__pyx_n > 1) {
4058         __pyx_v_max_length = __pyx_optional_args->max_length;
4059         if (__pyx_optional_args->__pyx_n > 2) {
4060           __pyx_v_init_zeros = __pyx_optional_args->init_zeros;
4061         }
4062       }
4063     }
4064   }
4065 
4066   /* "qutip/cy/sparse_routines.pxi":204
4067  *         Default value of zero indicates no resizing.
4068  *     """
4069  *     if max_length == 0:             # <<<<<<<<<<<<<<
4070  *         max_length = nnz
4071  *     if nnz > max_length:
4072  */
4073   __pyx_t_1 = ((__pyx_v_max_length == 0) != 0);
4074   if (__pyx_t_1) {
4075 
4076     /* "qutip/cy/sparse_routines.pxi":205
4077  *     """
4078  *     if max_length == 0:
4079  *         max_length = nnz             # <<<<<<<<<<<<<<
4080  *     if nnz > max_length:
4081  *         raise_error_COO(-7, mat)
4082  */
4083     __pyx_v_max_length = __pyx_v_nnz;
4084 
4085     /* "qutip/cy/sparse_routines.pxi":204
4086  *         Default value of zero indicates no resizing.
4087  *     """
4088  *     if max_length == 0:             # <<<<<<<<<<<<<<
4089  *         max_length = nnz
4090  *     if nnz > max_length:
4091  */
4092   }
4093 
4094   /* "qutip/cy/sparse_routines.pxi":206
4095  *     if max_length == 0:
4096  *         max_length = nnz
4097  *     if nnz > max_length:             # <<<<<<<<<<<<<<
4098  *         raise_error_COO(-7, mat)
4099  *     if init_zeros:
4100  */
4101   __pyx_t_1 = ((__pyx_v_nnz > __pyx_v_max_length) != 0);
4102   if (__pyx_t_1) {
4103 
4104     /* "qutip/cy/sparse_routines.pxi":207
4105  *         max_length = nnz
4106  *     if nnz > max_length:
4107  *         raise_error_COO(-7, mat)             # <<<<<<<<<<<<<<
4108  *     if init_zeros:
4109  *         mat.data = <double complex *>PyDataMem_NEW_ZEROED(nnz, sizeof(double complex))
4110  */
4111     __pyx_t_2.__pyx_n = 1;
4112     __pyx_t_2.C = __pyx_v_mat;
4113     __pyx_f_5qutip_2cy_9br_tensor_raise_error_COO(-7, &__pyx_t_2);
4114 
4115     /* "qutip/cy/sparse_routines.pxi":206
4116  *     if max_length == 0:
4117  *         max_length = nnz
4118  *     if nnz > max_length:             # <<<<<<<<<<<<<<
4119  *         raise_error_COO(-7, mat)
4120  *     if init_zeros:
4121  */
4122   }
4123 
4124   /* "qutip/cy/sparse_routines.pxi":208
4125  *     if nnz > max_length:
4126  *         raise_error_COO(-7, mat)
4127  *     if init_zeros:             # <<<<<<<<<<<<<<
4128  *         mat.data = <double complex *>PyDataMem_NEW_ZEROED(nnz, sizeof(double complex))
4129  *     else:
4130  */
4131   __pyx_t_1 = (__pyx_v_init_zeros != 0);
4132   if (__pyx_t_1) {
4133 
4134     /* "qutip/cy/sparse_routines.pxi":209
4135  *         raise_error_COO(-7, mat)
4136  *     if init_zeros:
4137  *         mat.data = <double complex *>PyDataMem_NEW_ZEROED(nnz, sizeof(double complex))             # <<<<<<<<<<<<<<
4138  *     else:
4139  *         mat.data = <double complex *>PyDataMem_NEW(nnz * sizeof(double complex))
4140  */
4141     __pyx_v_mat->data = ((__pyx_t_double_complex *)PyDataMem_NEW_ZEROED(__pyx_v_nnz, (sizeof(__pyx_t_double_complex))));
4142 
4143     /* "qutip/cy/sparse_routines.pxi":208
4144  *     if nnz > max_length:
4145  *         raise_error_COO(-7, mat)
4146  *     if init_zeros:             # <<<<<<<<<<<<<<
4147  *         mat.data = <double complex *>PyDataMem_NEW_ZEROED(nnz, sizeof(double complex))
4148  *     else:
4149  */
4150     goto __pyx_L5;
4151   }
4152 
4153   /* "qutip/cy/sparse_routines.pxi":211
4154  *         mat.data = <double complex *>PyDataMem_NEW_ZEROED(nnz, sizeof(double complex))
4155  *     else:
4156  *         mat.data = <double complex *>PyDataMem_NEW(nnz * sizeof(double complex))             # <<<<<<<<<<<<<<
4157  *     if mat.data == NULL:
4158  *         raise_error_COO(-1, mat)
4159  */
4160   /*else*/ {
4161     __pyx_v_mat->data = ((__pyx_t_double_complex *)PyDataMem_NEW((__pyx_v_nnz * (sizeof(__pyx_t_double_complex)))));
4162   }
4163   __pyx_L5:;
4164 
4165   /* "qutip/cy/sparse_routines.pxi":212
4166  *     else:
4167  *         mat.data = <double complex *>PyDataMem_NEW(nnz * sizeof(double complex))
4168  *     if mat.data == NULL:             # <<<<<<<<<<<<<<
4169  *         raise_error_COO(-1, mat)
4170  *     if init_zeros:
4171  */
4172   __pyx_t_1 = ((__pyx_v_mat->data == NULL) != 0);
4173   if (__pyx_t_1) {
4174 
4175     /* "qutip/cy/sparse_routines.pxi":213
4176  *         mat.data = <double complex *>PyDataMem_NEW(nnz * sizeof(double complex))
4177  *     if mat.data == NULL:
4178  *         raise_error_COO(-1, mat)             # <<<<<<<<<<<<<<
4179  *     if init_zeros:
4180  *         mat.rows = <int *>PyDataMem_NEW_ZEROED(nnz, sizeof(int))
4181  */
4182     __pyx_t_2.__pyx_n = 1;
4183     __pyx_t_2.C = __pyx_v_mat;
4184     __pyx_f_5qutip_2cy_9br_tensor_raise_error_COO(-1, &__pyx_t_2);
4185 
4186     /* "qutip/cy/sparse_routines.pxi":212
4187  *     else:
4188  *         mat.data = <double complex *>PyDataMem_NEW(nnz * sizeof(double complex))
4189  *     if mat.data == NULL:             # <<<<<<<<<<<<<<
4190  *         raise_error_COO(-1, mat)
4191  *     if init_zeros:
4192  */
4193   }
4194 
4195   /* "qutip/cy/sparse_routines.pxi":214
4196  *     if mat.data == NULL:
4197  *         raise_error_COO(-1, mat)
4198  *     if init_zeros:             # <<<<<<<<<<<<<<
4199  *         mat.rows = <int *>PyDataMem_NEW_ZEROED(nnz, sizeof(int))
4200  *         mat.cols = <int *>PyDataMem_NEW_ZEROED(nnz, sizeof(int))
4201  */
4202   __pyx_t_1 = (__pyx_v_init_zeros != 0);
4203   if (__pyx_t_1) {
4204 
4205     /* "qutip/cy/sparse_routines.pxi":215
4206  *         raise_error_COO(-1, mat)
4207  *     if init_zeros:
4208  *         mat.rows = <int *>PyDataMem_NEW_ZEROED(nnz, sizeof(int))             # <<<<<<<<<<<<<<
4209  *         mat.cols = <int *>PyDataMem_NEW_ZEROED(nnz, sizeof(int))
4210  *     else:
4211  */
4212     __pyx_v_mat->rows = ((int *)PyDataMem_NEW_ZEROED(__pyx_v_nnz, (sizeof(int))));
4213 
4214     /* "qutip/cy/sparse_routines.pxi":216
4215  *     if init_zeros:
4216  *         mat.rows = <int *>PyDataMem_NEW_ZEROED(nnz, sizeof(int))
4217  *         mat.cols = <int *>PyDataMem_NEW_ZEROED(nnz, sizeof(int))             # <<<<<<<<<<<<<<
4218  *     else:
4219  *         mat.rows = <int *>PyDataMem_NEW(nnz * sizeof(int))
4220  */
4221     __pyx_v_mat->cols = ((int *)PyDataMem_NEW_ZEROED(__pyx_v_nnz, (sizeof(int))));
4222 
4223     /* "qutip/cy/sparse_routines.pxi":214
4224  *     if mat.data == NULL:
4225  *         raise_error_COO(-1, mat)
4226  *     if init_zeros:             # <<<<<<<<<<<<<<
4227  *         mat.rows = <int *>PyDataMem_NEW_ZEROED(nnz, sizeof(int))
4228  *         mat.cols = <int *>PyDataMem_NEW_ZEROED(nnz, sizeof(int))
4229  */
4230     goto __pyx_L7;
4231   }
4232 
4233   /* "qutip/cy/sparse_routines.pxi":218
4234  *         mat.cols = <int *>PyDataMem_NEW_ZEROED(nnz, sizeof(int))
4235  *     else:
4236  *         mat.rows = <int *>PyDataMem_NEW(nnz * sizeof(int))             # <<<<<<<<<<<<<<
4237  *         mat.cols = <int *>PyDataMem_NEW(nnz * sizeof(int))
4238  *     mat.nnz = nnz
4239  */
4240   /*else*/ {
4241     __pyx_v_mat->rows = ((int *)PyDataMem_NEW((__pyx_v_nnz * (sizeof(int)))));
4242 
4243     /* "qutip/cy/sparse_routines.pxi":219
4244  *     else:
4245  *         mat.rows = <int *>PyDataMem_NEW(nnz * sizeof(int))
4246  *         mat.cols = <int *>PyDataMem_NEW(nnz * sizeof(int))             # <<<<<<<<<<<<<<
4247  *     mat.nnz = nnz
4248  *     mat.nrows = nrows
4249  */
4250     __pyx_v_mat->cols = ((int *)PyDataMem_NEW((__pyx_v_nnz * (sizeof(int)))));
4251   }
4252   __pyx_L7:;
4253 
4254   /* "qutip/cy/sparse_routines.pxi":220
4255  *         mat.rows = <int *>PyDataMem_NEW(nnz * sizeof(int))
4256  *         mat.cols = <int *>PyDataMem_NEW(nnz * sizeof(int))
4257  *     mat.nnz = nnz             # <<<<<<<<<<<<<<
4258  *     mat.nrows = nrows
4259  *     if ncols == 0:
4260  */
4261   __pyx_v_mat->nnz = __pyx_v_nnz;
4262 
4263   /* "qutip/cy/sparse_routines.pxi":221
4264  *         mat.cols = <int *>PyDataMem_NEW(nnz * sizeof(int))
4265  *     mat.nnz = nnz
4266  *     mat.nrows = nrows             # <<<<<<<<<<<<<<
4267  *     if ncols == 0:
4268  *         mat.ncols = nrows
4269  */
4270   __pyx_v_mat->nrows = __pyx_v_nrows;
4271 
4272   /* "qutip/cy/sparse_routines.pxi":222
4273  *     mat.nnz = nnz
4274  *     mat.nrows = nrows
4275  *     if ncols == 0:             # <<<<<<<<<<<<<<
4276  *         mat.ncols = nrows
4277  *     else:
4278  */
4279   __pyx_t_1 = ((__pyx_v_ncols == 0) != 0);
4280   if (__pyx_t_1) {
4281 
4282     /* "qutip/cy/sparse_routines.pxi":223
4283  *     mat.nrows = nrows
4284  *     if ncols == 0:
4285  *         mat.ncols = nrows             # <<<<<<<<<<<<<<
4286  *     else:
4287  *         mat.ncols = ncols
4288  */
4289     __pyx_v_mat->ncols = __pyx_v_nrows;
4290 
4291     /* "qutip/cy/sparse_routines.pxi":222
4292  *     mat.nnz = nnz
4293  *     mat.nrows = nrows
4294  *     if ncols == 0:             # <<<<<<<<<<<<<<
4295  *         mat.ncols = nrows
4296  *     else:
4297  */
4298     goto __pyx_L8;
4299   }
4300 
4301   /* "qutip/cy/sparse_routines.pxi":225
4302  *         mat.ncols = nrows
4303  *     else:
4304  *         mat.ncols = ncols             # <<<<<<<<<<<<<<
4305  *     mat.is_set = 1
4306  *     mat.max_length = max_length
4307  */
4308   /*else*/ {
4309     __pyx_v_mat->ncols = __pyx_v_ncols;
4310   }
4311   __pyx_L8:;
4312 
4313   /* "qutip/cy/sparse_routines.pxi":226
4314  *     else:
4315  *         mat.ncols = ncols
4316  *     mat.is_set = 1             # <<<<<<<<<<<<<<
4317  *     mat.max_length = max_length
4318  *     mat.numpy_lock = 0
4319  */
4320   __pyx_v_mat->is_set = 1;
4321 
4322   /* "qutip/cy/sparse_routines.pxi":227
4323  *         mat.ncols = ncols
4324  *     mat.is_set = 1
4325  *     mat.max_length = max_length             # <<<<<<<<<<<<<<
4326  *     mat.numpy_lock = 0
4327  *
4328  */
4329   __pyx_v_mat->max_length = __pyx_v_max_length;
4330 
4331   /* "qutip/cy/sparse_routines.pxi":228
4332  *     mat.is_set = 1
4333  *     mat.max_length = max_length
4334  *     mat.numpy_lock = 0             # <<<<<<<<<<<<<<
4335  *
4336  * @cython.boundscheck(False)
4337  */
4338   __pyx_v_mat->numpy_lock = 0;
4339 
4340   /* "qutip/cy/sparse_routines.pxi":184
4341  * @cython.boundscheck(False)
4342  * @cython.wraparound(False)
4343  * cdef void init_COO(COO_Matrix * mat, int nnz, int nrows, int ncols = 0,             # <<<<<<<<<<<<<<
4344  *                 int max_length = 0, int init_zeros = 1):
4345  *     """
4346  */
4347 
4348   /* function exit code */
4349   __Pyx_RefNannyFinishContext();
4350 }
4351 
4352 /* "qutip/cy/sparse_routines.pxi":232
4353  * @cython.boundscheck(False)
4354  * @cython.wraparound(False)
4355  * cdef void free_CSR(CSR_Matrix * mat):             # <<<<<<<<<<<<<<
4356  *     """
4357  *     Manually free CSR_Matrix data structures if
4358  */
4359 
__pyx_f_5qutip_2cy_9br_tensor_free_CSR(__pyx_t_5qutip_2cy_14sparse_structs_CSR_Matrix * __pyx_v_mat)4360 static void __pyx_f_5qutip_2cy_9br_tensor_free_CSR(__pyx_t_5qutip_2cy_14sparse_structs_CSR_Matrix *__pyx_v_mat) {
4361   __Pyx_RefNannyDeclarations
4362   int __pyx_t_1;
4363   int __pyx_t_2;
4364   __Pyx_RefNannySetupContext("free_CSR", 0);
4365 
4366   /* "qutip/cy/sparse_routines.pxi":237
4367  *     data is not locked by NumPy.
4368  *     """
4369  *     if not mat.numpy_lock and mat.is_set:             # <<<<<<<<<<<<<<
4370  *         if mat.data != NULL:
4371  *             PyDataMem_FREE(mat.data)
4372  */
4373   __pyx_t_2 = ((!(__pyx_v_mat->numpy_lock != 0)) != 0);
4374   if (__pyx_t_2) {
4375   } else {
4376     __pyx_t_1 = __pyx_t_2;
4377     goto __pyx_L4_bool_binop_done;
4378   }
4379   __pyx_t_2 = (__pyx_v_mat->is_set != 0);
4380   __pyx_t_1 = __pyx_t_2;
4381   __pyx_L4_bool_binop_done:;
4382   if (__pyx_t_1) {
4383 
4384     /* "qutip/cy/sparse_routines.pxi":238
4385  *     """
4386  *     if not mat.numpy_lock and mat.is_set:
4387  *         if mat.data != NULL:             # <<<<<<<<<<<<<<
4388  *             PyDataMem_FREE(mat.data)
4389  *         if mat.indices != NULL:
4390  */
4391     __pyx_t_1 = ((__pyx_v_mat->data != NULL) != 0);
4392     if (__pyx_t_1) {
4393 
4394       /* "qutip/cy/sparse_routines.pxi":239
4395  *     if not mat.numpy_lock and mat.is_set:
4396  *         if mat.data != NULL:
4397  *             PyDataMem_FREE(mat.data)             # <<<<<<<<<<<<<<
4398  *         if mat.indices != NULL:
4399  *             PyDataMem_FREE(mat.indices)
4400  */
4401       PyDataMem_FREE(__pyx_v_mat->data);
4402 
4403       /* "qutip/cy/sparse_routines.pxi":238
4404  *     """
4405  *     if not mat.numpy_lock and mat.is_set:
4406  *         if mat.data != NULL:             # <<<<<<<<<<<<<<
4407  *             PyDataMem_FREE(mat.data)
4408  *         if mat.indices != NULL:
4409  */
4410     }
4411 
4412     /* "qutip/cy/sparse_routines.pxi":240
4413  *         if mat.data != NULL:
4414  *             PyDataMem_FREE(mat.data)
4415  *         if mat.indices != NULL:             # <<<<<<<<<<<<<<
4416  *             PyDataMem_FREE(mat.indices)
4417  *         if mat.indptr != NULL:
4418  */
4419     __pyx_t_1 = ((__pyx_v_mat->indices != NULL) != 0);
4420     if (__pyx_t_1) {
4421 
4422       /* "qutip/cy/sparse_routines.pxi":241
4423  *             PyDataMem_FREE(mat.data)
4424  *         if mat.indices != NULL:
4425  *             PyDataMem_FREE(mat.indices)             # <<<<<<<<<<<<<<
4426  *         if mat.indptr != NULL:
4427  *             PyDataMem_FREE(mat.indptr)
4428  */
4429       PyDataMem_FREE(__pyx_v_mat->indices);
4430 
4431       /* "qutip/cy/sparse_routines.pxi":240
4432  *         if mat.data != NULL:
4433  *             PyDataMem_FREE(mat.data)
4434  *         if mat.indices != NULL:             # <<<<<<<<<<<<<<
4435  *             PyDataMem_FREE(mat.indices)
4436  *         if mat.indptr != NULL:
4437  */
4438     }
4439 
4440     /* "qutip/cy/sparse_routines.pxi":242
4441  *         if mat.indices != NULL:
4442  *             PyDataMem_FREE(mat.indices)
4443  *         if mat.indptr != NULL:             # <<<<<<<<<<<<<<
4444  *             PyDataMem_FREE(mat.indptr)
4445  *         mat.is_set = 0
4446  */
4447     __pyx_t_1 = ((__pyx_v_mat->indptr != NULL) != 0);
4448     if (__pyx_t_1) {
4449 
4450       /* "qutip/cy/sparse_routines.pxi":243
4451  *             PyDataMem_FREE(mat.indices)
4452  *         if mat.indptr != NULL:
4453  *             PyDataMem_FREE(mat.indptr)             # <<<<<<<<<<<<<<
4454  *         mat.is_set = 0
4455  *     else:
4456  */
4457       PyDataMem_FREE(__pyx_v_mat->indptr);
4458 
4459       /* "qutip/cy/sparse_routines.pxi":242
4460  *         if mat.indices != NULL:
4461  *             PyDataMem_FREE(mat.indices)
4462  *         if mat.indptr != NULL:             # <<<<<<<<<<<<<<
4463  *             PyDataMem_FREE(mat.indptr)
4464  *         mat.is_set = 0
4465  */
4466     }
4467 
4468     /* "qutip/cy/sparse_routines.pxi":244
4469  *         if mat.indptr != NULL:
4470  *             PyDataMem_FREE(mat.indptr)
4471  *         mat.is_set = 0             # <<<<<<<<<<<<<<
4472  *     else:
4473  *         raise_error_CSR(-2)
4474  */
4475     __pyx_v_mat->is_set = 0;
4476 
4477     /* "qutip/cy/sparse_routines.pxi":237
4478  *     data is not locked by NumPy.
4479  *     """
4480  *     if not mat.numpy_lock and mat.is_set:             # <<<<<<<<<<<<<<
4481  *         if mat.data != NULL:
4482  *             PyDataMem_FREE(mat.data)
4483  */
4484     goto __pyx_L3;
4485   }
4486 
4487   /* "qutip/cy/sparse_routines.pxi":246
4488  *         mat.is_set = 0
4489  *     else:
4490  *         raise_error_CSR(-2)             # <<<<<<<<<<<<<<
4491  *
4492  * @cython.boundscheck(False)
4493  */
4494   /*else*/ {
4495     __pyx_f_5qutip_2cy_9br_tensor_raise_error_CSR(-2, NULL);
4496   }
4497   __pyx_L3:;
4498 
4499   /* "qutip/cy/sparse_routines.pxi":232
4500  * @cython.boundscheck(False)
4501  * @cython.wraparound(False)
4502  * cdef void free_CSR(CSR_Matrix * mat):             # <<<<<<<<<<<<<<
4503  *     """
4504  *     Manually free CSR_Matrix data structures if
4505  */
4506 
4507   /* function exit code */
4508   __Pyx_RefNannyFinishContext();
4509 }
4510 
4511 /* "qutip/cy/sparse_routines.pxi":250
4512  * @cython.boundscheck(False)
4513  * @cython.wraparound(False)
4514  * cdef void free_COO(COO_Matrix * mat):             # <<<<<<<<<<<<<<
4515  *     """
4516  *     Manually free COO_Matrix data structures if
4517  */
4518 
__pyx_f_5qutip_2cy_9br_tensor_free_COO(__pyx_t_5qutip_2cy_14sparse_structs_COO_Matrix * __pyx_v_mat)4519 static void __pyx_f_5qutip_2cy_9br_tensor_free_COO(__pyx_t_5qutip_2cy_14sparse_structs_COO_Matrix *__pyx_v_mat) {
4520   __Pyx_RefNannyDeclarations
4521   int __pyx_t_1;
4522   int __pyx_t_2;
4523   __Pyx_RefNannySetupContext("free_COO", 0);
4524 
4525   /* "qutip/cy/sparse_routines.pxi":255
4526  *     data is not locked by NumPy.
4527  *     """
4528  *     if not mat.numpy_lock and mat.is_set:             # <<<<<<<<<<<<<<
4529  *         if mat.data != NULL:
4530  *             PyDataMem_FREE(mat.data)
4531  */
4532   __pyx_t_2 = ((!(__pyx_v_mat->numpy_lock != 0)) != 0);
4533   if (__pyx_t_2) {
4534   } else {
4535     __pyx_t_1 = __pyx_t_2;
4536     goto __pyx_L4_bool_binop_done;
4537   }
4538   __pyx_t_2 = (__pyx_v_mat->is_set != 0);
4539   __pyx_t_1 = __pyx_t_2;
4540   __pyx_L4_bool_binop_done:;
4541   if (__pyx_t_1) {
4542 
4543     /* "qutip/cy/sparse_routines.pxi":256
4544  *     """
4545  *     if not mat.numpy_lock and mat.is_set:
4546  *         if mat.data != NULL:             # <<<<<<<<<<<<<<
4547  *             PyDataMem_FREE(mat.data)
4548  *         if mat.rows != NULL:
4549  */
4550     __pyx_t_1 = ((__pyx_v_mat->data != NULL) != 0);
4551     if (__pyx_t_1) {
4552 
4553       /* "qutip/cy/sparse_routines.pxi":257
4554  *     if not mat.numpy_lock and mat.is_set:
4555  *         if mat.data != NULL:
4556  *             PyDataMem_FREE(mat.data)             # <<<<<<<<<<<<<<
4557  *         if mat.rows != NULL:
4558  *             PyDataMem_FREE(mat.rows)
4559  */
4560       PyDataMem_FREE(__pyx_v_mat->data);
4561 
4562       /* "qutip/cy/sparse_routines.pxi":256
4563  *     """
4564  *     if not mat.numpy_lock and mat.is_set:
4565  *         if mat.data != NULL:             # <<<<<<<<<<<<<<
4566  *             PyDataMem_FREE(mat.data)
4567  *         if mat.rows != NULL:
4568  */
4569     }
4570 
4571     /* "qutip/cy/sparse_routines.pxi":258
4572  *         if mat.data != NULL:
4573  *             PyDataMem_FREE(mat.data)
4574  *         if mat.rows != NULL:             # <<<<<<<<<<<<<<
4575  *             PyDataMem_FREE(mat.rows)
4576  *         if mat.cols != NULL:
4577  */
4578     __pyx_t_1 = ((__pyx_v_mat->rows != NULL) != 0);
4579     if (__pyx_t_1) {
4580 
4581       /* "qutip/cy/sparse_routines.pxi":259
4582  *             PyDataMem_FREE(mat.data)
4583  *         if mat.rows != NULL:
4584  *             PyDataMem_FREE(mat.rows)             # <<<<<<<<<<<<<<
4585  *         if mat.cols != NULL:
4586  *             PyDataMem_FREE(mat.cols)
4587  */
4588       PyDataMem_FREE(__pyx_v_mat->rows);
4589 
4590       /* "qutip/cy/sparse_routines.pxi":258
4591  *         if mat.data != NULL:
4592  *             PyDataMem_FREE(mat.data)
4593  *         if mat.rows != NULL:             # <<<<<<<<<<<<<<
4594  *             PyDataMem_FREE(mat.rows)
4595  *         if mat.cols != NULL:
4596  */
4597     }
4598 
4599     /* "qutip/cy/sparse_routines.pxi":260
4600  *         if mat.rows != NULL:
4601  *             PyDataMem_FREE(mat.rows)
4602  *         if mat.cols != NULL:             # <<<<<<<<<<<<<<
4603  *             PyDataMem_FREE(mat.cols)
4604  *         mat.is_set = 0
4605  */
4606     __pyx_t_1 = ((__pyx_v_mat->cols != NULL) != 0);
4607     if (__pyx_t_1) {
4608 
4609       /* "qutip/cy/sparse_routines.pxi":261
4610  *             PyDataMem_FREE(mat.rows)
4611  *         if mat.cols != NULL:
4612  *             PyDataMem_FREE(mat.cols)             # <<<<<<<<<<<<<<
4613  *         mat.is_set = 0
4614  *     else:
4615  */
4616       PyDataMem_FREE(__pyx_v_mat->cols);
4617 
4618       /* "qutip/cy/sparse_routines.pxi":260
4619  *         if mat.rows != NULL:
4620  *             PyDataMem_FREE(mat.rows)
4621  *         if mat.cols != NULL:             # <<<<<<<<<<<<<<
4622  *             PyDataMem_FREE(mat.cols)
4623  *         mat.is_set = 0
4624  */
4625     }
4626 
4627     /* "qutip/cy/sparse_routines.pxi":262
4628  *         if mat.cols != NULL:
4629  *             PyDataMem_FREE(mat.cols)
4630  *         mat.is_set = 0             # <<<<<<<<<<<<<<
4631  *     else:
4632  *         raise_error_COO(-2)
4633  */
4634     __pyx_v_mat->is_set = 0;
4635 
4636     /* "qutip/cy/sparse_routines.pxi":255
4637  *     data is not locked by NumPy.
4638  *     """
4639  *     if not mat.numpy_lock and mat.is_set:             # <<<<<<<<<<<<<<
4640  *         if mat.data != NULL:
4641  *             PyDataMem_FREE(mat.data)
4642  */
4643     goto __pyx_L3;
4644   }
4645 
4646   /* "qutip/cy/sparse_routines.pxi":264
4647  *         mat.is_set = 0
4648  *     else:
4649  *         raise_error_COO(-2)             # <<<<<<<<<<<<<<
4650  *
4651  *
4652  */
4653   /*else*/ {
4654     __pyx_f_5qutip_2cy_9br_tensor_raise_error_COO(-2, NULL);
4655   }
4656   __pyx_L3:;
4657 
4658   /* "qutip/cy/sparse_routines.pxi":250
4659  * @cython.boundscheck(False)
4660  * @cython.wraparound(False)
4661  * cdef void free_COO(COO_Matrix * mat):             # <<<<<<<<<<<<<<
4662  *     """
4663  *     Manually free COO_Matrix data structures if
4664  */
4665 
4666   /* function exit code */
4667   __Pyx_RefNannyFinishContext();
4668 }
4669 
4670 /* "qutip/cy/sparse_routines.pxi":269
4671  * @cython.boundscheck(False)
4672  * @cython.wraparound(False)
4673  * cdef void shorten_CSR(CSR_Matrix * mat, int N):             # <<<<<<<<<<<<<<
4674  *     """
4675  *     Shortends the length of CSR data and indices arrays.
4676  */
4677 
__pyx_f_5qutip_2cy_9br_tensor_shorten_CSR(__pyx_t_5qutip_2cy_14sparse_structs_CSR_Matrix * __pyx_v_mat,int __pyx_v_N)4678 static void __pyx_f_5qutip_2cy_9br_tensor_shorten_CSR(__pyx_t_5qutip_2cy_14sparse_structs_CSR_Matrix *__pyx_v_mat, int __pyx_v_N) {
4679   __Pyx_RefNannyDeclarations
4680   int __pyx_t_1;
4681   int __pyx_t_2;
4682   struct __pyx_opt_args_5qutip_2cy_9br_tensor_raise_error_CSR __pyx_t_3;
4683   __Pyx_RefNannySetupContext("shorten_CSR", 0);
4684 
4685   /* "qutip/cy/sparse_routines.pxi":273
4686  *     Shortends the length of CSR data and indices arrays.
4687  *     """
4688  *     if (not mat.numpy_lock) and mat.is_set:             # <<<<<<<<<<<<<<
4689  *         mat.data = <double complex *>PyDataMem_RENEW(mat.data, N * sizeof(double complex))
4690  *         mat.indices = <int *>PyDataMem_RENEW(mat.indices, N * sizeof(int))
4691  */
4692   __pyx_t_2 = ((!(__pyx_v_mat->numpy_lock != 0)) != 0);
4693   if (__pyx_t_2) {
4694   } else {
4695     __pyx_t_1 = __pyx_t_2;
4696     goto __pyx_L4_bool_binop_done;
4697   }
4698   __pyx_t_2 = (__pyx_v_mat->is_set != 0);
4699   __pyx_t_1 = __pyx_t_2;
4700   __pyx_L4_bool_binop_done:;
4701   if (__pyx_t_1) {
4702 
4703     /* "qutip/cy/sparse_routines.pxi":274
4704  *     """
4705  *     if (not mat.numpy_lock) and mat.is_set:
4706  *         mat.data = <double complex *>PyDataMem_RENEW(mat.data, N * sizeof(double complex))             # <<<<<<<<<<<<<<
4707  *         mat.indices = <int *>PyDataMem_RENEW(mat.indices, N * sizeof(int))
4708  *         mat.nnz = N
4709  */
4710     __pyx_v_mat->data = ((__pyx_t_double_complex *)PyDataMem_RENEW(__pyx_v_mat->data, (__pyx_v_N * (sizeof(__pyx_t_double_complex)))));
4711 
4712     /* "qutip/cy/sparse_routines.pxi":275
4713  *     if (not mat.numpy_lock) and mat.is_set:
4714  *         mat.data = <double complex *>PyDataMem_RENEW(mat.data, N * sizeof(double complex))
4715  *         mat.indices = <int *>PyDataMem_RENEW(mat.indices, N * sizeof(int))             # <<<<<<<<<<<<<<
4716  *         mat.nnz = N
4717  *     else:
4718  */
4719     __pyx_v_mat->indices = ((int *)PyDataMem_RENEW(__pyx_v_mat->indices, (__pyx_v_N * (sizeof(int)))));
4720 
4721     /* "qutip/cy/sparse_routines.pxi":276
4722  *         mat.data = <double complex *>PyDataMem_RENEW(mat.data, N * sizeof(double complex))
4723  *         mat.indices = <int *>PyDataMem_RENEW(mat.indices, N * sizeof(int))
4724  *         mat.nnz = N             # <<<<<<<<<<<<<<
4725  *     else:
4726  *         if mat.numpy_lock:
4727  */
4728     __pyx_v_mat->nnz = __pyx_v_N;
4729 
4730     /* "qutip/cy/sparse_routines.pxi":273
4731  *     Shortends the length of CSR data and indices arrays.
4732  *     """
4733  *     if (not mat.numpy_lock) and mat.is_set:             # <<<<<<<<<<<<<<
4734  *         mat.data = <double complex *>PyDataMem_RENEW(mat.data, N * sizeof(double complex))
4735  *         mat.indices = <int *>PyDataMem_RENEW(mat.indices, N * sizeof(int))
4736  */
4737     goto __pyx_L3;
4738   }
4739 
4740   /* "qutip/cy/sparse_routines.pxi":278
4741  *         mat.nnz = N
4742  *     else:
4743  *         if mat.numpy_lock:             # <<<<<<<<<<<<<<
4744  *             raise_error_CSR(-4, mat)
4745  *         elif not mat.is_set:
4746  */
4747   /*else*/ {
4748     __pyx_t_1 = (__pyx_v_mat->numpy_lock != 0);
4749     if (__pyx_t_1) {
4750 
4751       /* "qutip/cy/sparse_routines.pxi":279
4752  *     else:
4753  *         if mat.numpy_lock:
4754  *             raise_error_CSR(-4, mat)             # <<<<<<<<<<<<<<
4755  *         elif not mat.is_set:
4756  *             raise_error_CSR(-3, mat)
4757  */
4758       __pyx_t_3.__pyx_n = 1;
4759       __pyx_t_3.C = __pyx_v_mat;
4760       __pyx_f_5qutip_2cy_9br_tensor_raise_error_CSR(-4, &__pyx_t_3);
4761 
4762       /* "qutip/cy/sparse_routines.pxi":278
4763  *         mat.nnz = N
4764  *     else:
4765  *         if mat.numpy_lock:             # <<<<<<<<<<<<<<
4766  *             raise_error_CSR(-4, mat)
4767  *         elif not mat.is_set:
4768  */
4769       goto __pyx_L6;
4770     }
4771 
4772     /* "qutip/cy/sparse_routines.pxi":280
4773  *         if mat.numpy_lock:
4774  *             raise_error_CSR(-4, mat)
4775  *         elif not mat.is_set:             # <<<<<<<<<<<<<<
4776  *             raise_error_CSR(-3, mat)
4777  *
4778  */
4779     __pyx_t_1 = ((!(__pyx_v_mat->is_set != 0)) != 0);
4780     if (__pyx_t_1) {
4781 
4782       /* "qutip/cy/sparse_routines.pxi":281
4783  *             raise_error_CSR(-4, mat)
4784  *         elif not mat.is_set:
4785  *             raise_error_CSR(-3, mat)             # <<<<<<<<<<<<<<
4786  *
4787  *
4788  */
4789       __pyx_t_3.__pyx_n = 1;
4790       __pyx_t_3.C = __pyx_v_mat;
4791       __pyx_f_5qutip_2cy_9br_tensor_raise_error_CSR(-3, &__pyx_t_3);
4792 
4793       /* "qutip/cy/sparse_routines.pxi":280
4794  *         if mat.numpy_lock:
4795  *             raise_error_CSR(-4, mat)
4796  *         elif not mat.is_set:             # <<<<<<<<<<<<<<
4797  *             raise_error_CSR(-3, mat)
4798  *
4799  */
4800     }
4801     __pyx_L6:;
4802   }
4803   __pyx_L3:;
4804 
4805   /* "qutip/cy/sparse_routines.pxi":269
4806  * @cython.boundscheck(False)
4807  * @cython.wraparound(False)
4808  * cdef void shorten_CSR(CSR_Matrix * mat, int N):             # <<<<<<<<<<<<<<
4809  *     """
4810  *     Shortends the length of CSR data and indices arrays.
4811  */
4812 
4813   /* function exit code */
4814   __Pyx_RefNannyFinishContext();
4815 }
4816 
4817 /* "qutip/cy/sparse_routines.pxi":286
4818  * @cython.boundscheck(False)
4819  * @cython.wraparound(False)
4820  * cdef void expand_CSR(CSR_Matrix * mat, int init_zeros=0):             # <<<<<<<<<<<<<<
4821  *     """
4822  *     Expands the length of CSR data and indices arrays to accomodate
4823  */
4824 
__pyx_f_5qutip_2cy_9br_tensor_expand_CSR(__pyx_t_5qutip_2cy_14sparse_structs_CSR_Matrix * __pyx_v_mat,struct __pyx_opt_args_5qutip_2cy_9br_tensor_expand_CSR * __pyx_optional_args)4825 static void __pyx_f_5qutip_2cy_9br_tensor_expand_CSR(__pyx_t_5qutip_2cy_14sparse_structs_CSR_Matrix *__pyx_v_mat, struct __pyx_opt_args_5qutip_2cy_9br_tensor_expand_CSR *__pyx_optional_args) {
4826   int __pyx_v_init_zeros = ((int)0);
4827   size_t __pyx_v_ii;
4828   int __pyx_v_new_size;
4829   __pyx_t_double_complex *__pyx_v_new_data;
4830   int *__pyx_v_new_ind;
4831   __Pyx_RefNannyDeclarations
4832   int __pyx_t_1;
4833   struct __pyx_opt_args_5qutip_2cy_9br_tensor_raise_error_CSR __pyx_t_2;
4834   int __pyx_t_3;
4835   int __pyx_t_4;
4836   int __pyx_t_5;
4837   size_t __pyx_t_6;
4838   __Pyx_RefNannySetupContext("expand_CSR", 0);
4839   if (__pyx_optional_args) {
4840     if (__pyx_optional_args->__pyx_n > 0) {
4841       __pyx_v_init_zeros = __pyx_optional_args->init_zeros;
4842     }
4843   }
4844 
4845   /* "qutip/cy/sparse_routines.pxi":293
4846  *     cdef size_t ii
4847  *     cdef int new_size
4848  *     if mat.nnz == mat.max_length:             # <<<<<<<<<<<<<<
4849  *         raise_error_CSR(-5, mat) #Cannot expand data past max_length.
4850  *     elif (not mat.numpy_lock) and mat.is_set:
4851  */
4852   __pyx_t_1 = ((__pyx_v_mat->nnz == __pyx_v_mat->max_length) != 0);
4853   if (__pyx_t_1) {
4854 
4855     /* "qutip/cy/sparse_routines.pxi":294
4856  *     cdef int new_size
4857  *     if mat.nnz == mat.max_length:
4858  *         raise_error_CSR(-5, mat) #Cannot expand data past max_length.             # <<<<<<<<<<<<<<
4859  *     elif (not mat.numpy_lock) and mat.is_set:
4860  *         new_size = int_min(2*mat.nnz, mat.max_length)
4861  */
4862     __pyx_t_2.__pyx_n = 1;
4863     __pyx_t_2.C = __pyx_v_mat;
4864     __pyx_f_5qutip_2cy_9br_tensor_raise_error_CSR(-5, &__pyx_t_2);
4865 
4866     /* "qutip/cy/sparse_routines.pxi":293
4867  *     cdef size_t ii
4868  *     cdef int new_size
4869  *     if mat.nnz == mat.max_length:             # <<<<<<<<<<<<<<
4870  *         raise_error_CSR(-5, mat) #Cannot expand data past max_length.
4871  *     elif (not mat.numpy_lock) and mat.is_set:
4872  */
4873     goto __pyx_L3;
4874   }
4875 
4876   /* "qutip/cy/sparse_routines.pxi":295
4877  *     if mat.nnz == mat.max_length:
4878  *         raise_error_CSR(-5, mat) #Cannot expand data past max_length.
4879  *     elif (not mat.numpy_lock) and mat.is_set:             # <<<<<<<<<<<<<<
4880  *         new_size = int_min(2*mat.nnz, mat.max_length)
4881  *         new_data = <double complex *>PyDataMem_RENEW(mat.data, new_size * sizeof(double complex))
4882  */
4883   __pyx_t_3 = ((!(__pyx_v_mat->numpy_lock != 0)) != 0);
4884   if (__pyx_t_3) {
4885   } else {
4886     __pyx_t_1 = __pyx_t_3;
4887     goto __pyx_L4_bool_binop_done;
4888   }
4889   __pyx_t_3 = (__pyx_v_mat->is_set != 0);
4890   __pyx_t_1 = __pyx_t_3;
4891   __pyx_L4_bool_binop_done:;
4892   if (__pyx_t_1) {
4893 
4894     /* "qutip/cy/sparse_routines.pxi":296
4895  *         raise_error_CSR(-5, mat) #Cannot expand data past max_length.
4896  *     elif (not mat.numpy_lock) and mat.is_set:
4897  *         new_size = int_min(2*mat.nnz, mat.max_length)             # <<<<<<<<<<<<<<
4898  *         new_data = <double complex *>PyDataMem_RENEW(mat.data, new_size * sizeof(double complex))
4899  *         if new_data == NULL:
4900  */
4901     __pyx_v_new_size = __pyx_f_5qutip_2cy_9br_tensor_int_min((2 * __pyx_v_mat->nnz), __pyx_v_mat->max_length);
4902 
4903     /* "qutip/cy/sparse_routines.pxi":297
4904  *     elif (not mat.numpy_lock) and mat.is_set:
4905  *         new_size = int_min(2*mat.nnz, mat.max_length)
4906  *         new_data = <double complex *>PyDataMem_RENEW(mat.data, new_size * sizeof(double complex))             # <<<<<<<<<<<<<<
4907  *         if new_data == NULL:
4908  *             raise_error_CSR(-1, mat)
4909  */
4910     __pyx_v_new_data = ((__pyx_t_double_complex *)PyDataMem_RENEW(__pyx_v_mat->data, (__pyx_v_new_size * (sizeof(__pyx_t_double_complex)))));
4911 
4912     /* "qutip/cy/sparse_routines.pxi":298
4913  *         new_size = int_min(2*mat.nnz, mat.max_length)
4914  *         new_data = <double complex *>PyDataMem_RENEW(mat.data, new_size * sizeof(double complex))
4915  *         if new_data == NULL:             # <<<<<<<<<<<<<<
4916  *             raise_error_CSR(-1, mat)
4917  *         else:
4918  */
4919     __pyx_t_1 = ((__pyx_v_new_data == NULL) != 0);
4920     if (__pyx_t_1) {
4921 
4922       /* "qutip/cy/sparse_routines.pxi":299
4923  *         new_data = <double complex *>PyDataMem_RENEW(mat.data, new_size * sizeof(double complex))
4924  *         if new_data == NULL:
4925  *             raise_error_CSR(-1, mat)             # <<<<<<<<<<<<<<
4926  *         else:
4927  *             mat.data = new_data
4928  */
4929       __pyx_t_2.__pyx_n = 1;
4930       __pyx_t_2.C = __pyx_v_mat;
4931       __pyx_f_5qutip_2cy_9br_tensor_raise_error_CSR(-1, &__pyx_t_2);
4932 
4933       /* "qutip/cy/sparse_routines.pxi":298
4934  *         new_size = int_min(2*mat.nnz, mat.max_length)
4935  *         new_data = <double complex *>PyDataMem_RENEW(mat.data, new_size * sizeof(double complex))
4936  *         if new_data == NULL:             # <<<<<<<<<<<<<<
4937  *             raise_error_CSR(-1, mat)
4938  *         else:
4939  */
4940       goto __pyx_L6;
4941     }
4942 
4943     /* "qutip/cy/sparse_routines.pxi":301
4944  *             raise_error_CSR(-1, mat)
4945  *         else:
4946  *             mat.data = new_data             # <<<<<<<<<<<<<<
4947  *             if init_zeros == 1:
4948  *                 for ii in range(mat.nnz, new_size):
4949  */
4950     /*else*/ {
4951       __pyx_v_mat->data = __pyx_v_new_data;
4952 
4953       /* "qutip/cy/sparse_routines.pxi":302
4954  *         else:
4955  *             mat.data = new_data
4956  *             if init_zeros == 1:             # <<<<<<<<<<<<<<
4957  *                 for ii in range(mat.nnz, new_size):
4958  *                     mat.data[ii] = 0
4959  */
4960       __pyx_t_1 = ((__pyx_v_init_zeros == 1) != 0);
4961       if (__pyx_t_1) {
4962 
4963         /* "qutip/cy/sparse_routines.pxi":303
4964  *             mat.data = new_data
4965  *             if init_zeros == 1:
4966  *                 for ii in range(mat.nnz, new_size):             # <<<<<<<<<<<<<<
4967  *                     mat.data[ii] = 0
4968  *
4969  */
4970         __pyx_t_4 = __pyx_v_new_size;
4971         __pyx_t_5 = __pyx_t_4;
4972         for (__pyx_t_6 = __pyx_v_mat->nnz; __pyx_t_6 < __pyx_t_5; __pyx_t_6+=1) {
4973           __pyx_v_ii = __pyx_t_6;
4974 
4975           /* "qutip/cy/sparse_routines.pxi":304
4976  *             if init_zeros == 1:
4977  *                 for ii in range(mat.nnz, new_size):
4978  *                     mat.data[ii] = 0             # <<<<<<<<<<<<<<
4979  *
4980  *         new_ind = <int *>PyDataMem_RENEW(mat.indices, new_size * sizeof(int))
4981  */
4982           (__pyx_v_mat->data[__pyx_v_ii]) = __pyx_t_double_complex_from_parts(0, 0);
4983         }
4984 
4985         /* "qutip/cy/sparse_routines.pxi":302
4986  *         else:
4987  *             mat.data = new_data
4988  *             if init_zeros == 1:             # <<<<<<<<<<<<<<
4989  *                 for ii in range(mat.nnz, new_size):
4990  *                     mat.data[ii] = 0
4991  */
4992       }
4993     }
4994     __pyx_L6:;
4995 
4996     /* "qutip/cy/sparse_routines.pxi":306
4997  *                     mat.data[ii] = 0
4998  *
4999  *         new_ind = <int *>PyDataMem_RENEW(mat.indices, new_size * sizeof(int))             # <<<<<<<<<<<<<<
5000  *         mat.indices = new_ind
5001  *         if init_zeros == 1:
5002  */
5003     __pyx_v_new_ind = ((int *)PyDataMem_RENEW(__pyx_v_mat->indices, (__pyx_v_new_size * (sizeof(int)))));
5004 
5005     /* "qutip/cy/sparse_routines.pxi":307
5006  *
5007  *         new_ind = <int *>PyDataMem_RENEW(mat.indices, new_size * sizeof(int))
5008  *         mat.indices = new_ind             # <<<<<<<<<<<<<<
5009  *         if init_zeros == 1:
5010  *             for ii in range(mat.nnz, new_size):
5011  */
5012     __pyx_v_mat->indices = __pyx_v_new_ind;
5013 
5014     /* "qutip/cy/sparse_routines.pxi":308
5015  *         new_ind = <int *>PyDataMem_RENEW(mat.indices, new_size * sizeof(int))
5016  *         mat.indices = new_ind
5017  *         if init_zeros == 1:             # <<<<<<<<<<<<<<
5018  *             for ii in range(mat.nnz, new_size):
5019  *                 mat.indices[ii] = 0
5020  */
5021     __pyx_t_1 = ((__pyx_v_init_zeros == 1) != 0);
5022     if (__pyx_t_1) {
5023 
5024       /* "qutip/cy/sparse_routines.pxi":309
5025  *         mat.indices = new_ind
5026  *         if init_zeros == 1:
5027  *             for ii in range(mat.nnz, new_size):             # <<<<<<<<<<<<<<
5028  *                 mat.indices[ii] = 0
5029  *         mat.nnz = new_size
5030  */
5031       __pyx_t_4 = __pyx_v_new_size;
5032       __pyx_t_5 = __pyx_t_4;
5033       for (__pyx_t_6 = __pyx_v_mat->nnz; __pyx_t_6 < __pyx_t_5; __pyx_t_6+=1) {
5034         __pyx_v_ii = __pyx_t_6;
5035 
5036         /* "qutip/cy/sparse_routines.pxi":310
5037  *         if init_zeros == 1:
5038  *             for ii in range(mat.nnz, new_size):
5039  *                 mat.indices[ii] = 0             # <<<<<<<<<<<<<<
5040  *         mat.nnz = new_size
5041  *     else:
5042  */
5043         (__pyx_v_mat->indices[__pyx_v_ii]) = 0;
5044       }
5045 
5046       /* "qutip/cy/sparse_routines.pxi":308
5047  *         new_ind = <int *>PyDataMem_RENEW(mat.indices, new_size * sizeof(int))
5048  *         mat.indices = new_ind
5049  *         if init_zeros == 1:             # <<<<<<<<<<<<<<
5050  *             for ii in range(mat.nnz, new_size):
5051  *                 mat.indices[ii] = 0
5052  */
5053     }
5054 
5055     /* "qutip/cy/sparse_routines.pxi":311
5056  *             for ii in range(mat.nnz, new_size):
5057  *                 mat.indices[ii] = 0
5058  *         mat.nnz = new_size             # <<<<<<<<<<<<<<
5059  *     else:
5060  *         if mat.numpy_lock:
5061  */
5062     __pyx_v_mat->nnz = __pyx_v_new_size;
5063 
5064     /* "qutip/cy/sparse_routines.pxi":295
5065  *     if mat.nnz == mat.max_length:
5066  *         raise_error_CSR(-5, mat) #Cannot expand data past max_length.
5067  *     elif (not mat.numpy_lock) and mat.is_set:             # <<<<<<<<<<<<<<
5068  *         new_size = int_min(2*mat.nnz, mat.max_length)
5069  *         new_data = <double complex *>PyDataMem_RENEW(mat.data, new_size * sizeof(double complex))
5070  */
5071     goto __pyx_L3;
5072   }
5073 
5074   /* "qutip/cy/sparse_routines.pxi":313
5075  *         mat.nnz = new_size
5076  *     else:
5077  *         if mat.numpy_lock:             # <<<<<<<<<<<<<<
5078  *             raise_error_CSR(-4, mat)
5079  *         elif not mat.is_set:
5080  */
5081   /*else*/ {
5082     __pyx_t_1 = (__pyx_v_mat->numpy_lock != 0);
5083     if (__pyx_t_1) {
5084 
5085       /* "qutip/cy/sparse_routines.pxi":314
5086  *     else:
5087  *         if mat.numpy_lock:
5088  *             raise_error_CSR(-4, mat)             # <<<<<<<<<<<<<<
5089  *         elif not mat.is_set:
5090  *             raise_error_CSR(-3, mat)
5091  */
5092       __pyx_t_2.__pyx_n = 1;
5093       __pyx_t_2.C = __pyx_v_mat;
5094       __pyx_f_5qutip_2cy_9br_tensor_raise_error_CSR(-4, &__pyx_t_2);
5095 
5096       /* "qutip/cy/sparse_routines.pxi":313
5097  *         mat.nnz = new_size
5098  *     else:
5099  *         if mat.numpy_lock:             # <<<<<<<<<<<<<<
5100  *             raise_error_CSR(-4, mat)
5101  *         elif not mat.is_set:
5102  */
5103       goto __pyx_L13;
5104     }
5105 
5106     /* "qutip/cy/sparse_routines.pxi":315
5107  *         if mat.numpy_lock:
5108  *             raise_error_CSR(-4, mat)
5109  *         elif not mat.is_set:             # <<<<<<<<<<<<<<
5110  *             raise_error_CSR(-3, mat)
5111  *
5112  */
5113     __pyx_t_1 = ((!(__pyx_v_mat->is_set != 0)) != 0);
5114     if (__pyx_t_1) {
5115 
5116       /* "qutip/cy/sparse_routines.pxi":316
5117  *             raise_error_CSR(-4, mat)
5118  *         elif not mat.is_set:
5119  *             raise_error_CSR(-3, mat)             # <<<<<<<<<<<<<<
5120  *
5121  *
5122  */
5123       __pyx_t_2.__pyx_n = 1;
5124       __pyx_t_2.C = __pyx_v_mat;
5125       __pyx_f_5qutip_2cy_9br_tensor_raise_error_CSR(-3, &__pyx_t_2);
5126 
5127       /* "qutip/cy/sparse_routines.pxi":315
5128  *         if mat.numpy_lock:
5129  *             raise_error_CSR(-4, mat)
5130  *         elif not mat.is_set:             # <<<<<<<<<<<<<<
5131  *             raise_error_CSR(-3, mat)
5132  *
5133  */
5134     }
5135     __pyx_L13:;
5136   }
5137   __pyx_L3:;
5138 
5139   /* "qutip/cy/sparse_routines.pxi":286
5140  * @cython.boundscheck(False)
5141  * @cython.wraparound(False)
5142  * cdef void expand_CSR(CSR_Matrix * mat, int init_zeros=0):             # <<<<<<<<<<<<<<
5143  *     """
5144  *     Expands the length of CSR data and indices arrays to accomodate
5145  */
5146 
5147   /* function exit code */
5148   __Pyx_RefNannyFinishContext();
5149 }
5150 
5151 /* "qutip/cy/sparse_routines.pxi":321
5152  * @cython.boundscheck(False)
5153  * @cython.wraparound(False)
5154  * cdef object CSR_to_scipy(CSR_Matrix * mat):             # <<<<<<<<<<<<<<
5155  *     """
5156  *     Converts a CSR_Matrix struct to a SciPy csr_matrix class object.
5157  */
5158 
__pyx_f_5qutip_2cy_9br_tensor_CSR_to_scipy(__pyx_t_5qutip_2cy_14sparse_structs_CSR_Matrix * __pyx_v_mat)5159 static PyObject *__pyx_f_5qutip_2cy_9br_tensor_CSR_to_scipy(__pyx_t_5qutip_2cy_14sparse_structs_CSR_Matrix *__pyx_v_mat) {
5160   npy_intp __pyx_v_dat_len;
5161   npy_intp __pyx_v_ptr_len;
5162   PyArrayObject *__pyx_v__data = 0;
5163   PyArrayObject *__pyx_v__ind = 0;
5164   PyArrayObject *__pyx_v__ptr = 0;
5165   __Pyx_LocalBuf_ND __pyx_pybuffernd__data;
5166   __Pyx_Buffer __pyx_pybuffer__data;
5167   __Pyx_LocalBuf_ND __pyx_pybuffernd__ind;
5168   __Pyx_Buffer __pyx_pybuffer__ind;
5169   __Pyx_LocalBuf_ND __pyx_pybuffernd__ptr;
5170   __Pyx_Buffer __pyx_pybuffer__ptr;
5171   PyObject *__pyx_r = NULL;
5172   __Pyx_RefNannyDeclarations
5173   int __pyx_t_1;
5174   int __pyx_t_2;
5175   int __pyx_t_3;
5176   PyObject *__pyx_t_4 = NULL;
5177   PyArrayObject *__pyx_t_5 = NULL;
5178   PyObject *__pyx_t_6 = NULL;
5179   PyObject *__pyx_t_7 = NULL;
5180   PyObject *__pyx_t_8 = NULL;
5181   PyArrayObject *__pyx_t_9 = NULL;
5182   PyObject *__pyx_t_10 = NULL;
5183   PyObject *__pyx_t_11 = NULL;
5184   PyObject *__pyx_t_12 = NULL;
5185   PyObject *__pyx_t_13 = NULL;
5186   PyObject *__pyx_t_14 = NULL;
5187   int __pyx_lineno = 0;
5188   const char *__pyx_filename = NULL;
5189   int __pyx_clineno = 0;
5190   __Pyx_RefNannySetupContext("CSR_to_scipy", 0);
5191   __pyx_pybuffer__data.pybuffer.buf = NULL;
5192   __pyx_pybuffer__data.refcount = 0;
5193   __pyx_pybuffernd__data.data = NULL;
5194   __pyx_pybuffernd__data.rcbuffer = &__pyx_pybuffer__data;
5195   __pyx_pybuffer__ind.pybuffer.buf = NULL;
5196   __pyx_pybuffer__ind.refcount = 0;
5197   __pyx_pybuffernd__ind.data = NULL;
5198   __pyx_pybuffernd__ind.rcbuffer = &__pyx_pybuffer__ind;
5199   __pyx_pybuffer__ptr.pybuffer.buf = NULL;
5200   __pyx_pybuffer__ptr.refcount = 0;
5201   __pyx_pybuffernd__ptr.data = NULL;
5202   __pyx_pybuffernd__ptr.rcbuffer = &__pyx_pybuffer__ptr;
5203 
5204   /* "qutip/cy/sparse_routines.pxi":336
5205  *     cdef np.ndarray[complex, ndim=1] _data
5206  *     cdef np.ndarray[int, ndim=1] _ind, _ptr
5207  *     if (not mat.numpy_lock) and mat.is_set:             # <<<<<<<<<<<<<<
5208  *         dat_len = mat.nnz
5209  *         ptr_len = mat.nrows+1
5210  */
5211   __pyx_t_2 = ((!(__pyx_v_mat->numpy_lock != 0)) != 0);
5212   if (__pyx_t_2) {
5213   } else {
5214     __pyx_t_1 = __pyx_t_2;
5215     goto __pyx_L4_bool_binop_done;
5216   }
5217   __pyx_t_2 = (__pyx_v_mat->is_set != 0);
5218   __pyx_t_1 = __pyx_t_2;
5219   __pyx_L4_bool_binop_done:;
5220   if (__pyx_t_1) {
5221 
5222     /* "qutip/cy/sparse_routines.pxi":337
5223  *     cdef np.ndarray[int, ndim=1] _ind, _ptr
5224  *     if (not mat.numpy_lock) and mat.is_set:
5225  *         dat_len = mat.nnz             # <<<<<<<<<<<<<<
5226  *         ptr_len = mat.nrows+1
5227  *         _data = np.PyArray_SimpleNewFromData(1, &dat_len, np.NPY_COMPLEX128, mat.data)
5228  */
5229     __pyx_t_3 = __pyx_v_mat->nnz;
5230     __pyx_v_dat_len = __pyx_t_3;
5231 
5232     /* "qutip/cy/sparse_routines.pxi":338
5233  *     if (not mat.numpy_lock) and mat.is_set:
5234  *         dat_len = mat.nnz
5235  *         ptr_len = mat.nrows+1             # <<<<<<<<<<<<<<
5236  *         _data = np.PyArray_SimpleNewFromData(1, &dat_len, np.NPY_COMPLEX128, mat.data)
5237  *         PyArray_ENABLEFLAGS(_data, np.NPY_ARRAY_OWNDATA)
5238  */
5239     __pyx_v_ptr_len = (__pyx_v_mat->nrows + 1);
5240 
5241     /* "qutip/cy/sparse_routines.pxi":339
5242  *         dat_len = mat.nnz
5243  *         ptr_len = mat.nrows+1
5244  *         _data = np.PyArray_SimpleNewFromData(1, &dat_len, np.NPY_COMPLEX128, mat.data)             # <<<<<<<<<<<<<<
5245  *         PyArray_ENABLEFLAGS(_data, np.NPY_ARRAY_OWNDATA)
5246  *
5247  */
5248     __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)
5249     __Pyx_GOTREF(__pyx_t_4);
5250     if (!(likely(((__pyx_t_4) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_4, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 339, __pyx_L1_error)
5251     __pyx_t_5 = ((PyArrayObject *)__pyx_t_4);
5252     {
5253       __Pyx_BufFmt_StackElem __pyx_stack[1];
5254       __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd__data.rcbuffer->pybuffer);
5255       __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);
5256       if (unlikely(__pyx_t_3 < 0)) {
5257         PyErr_Fetch(&__pyx_t_6, &__pyx_t_7, &__pyx_t_8);
5258         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)) {
5259           Py_XDECREF(__pyx_t_6); Py_XDECREF(__pyx_t_7); Py_XDECREF(__pyx_t_8);
5260           __Pyx_RaiseBufferFallbackError();
5261         } else {
5262           PyErr_Restore(__pyx_t_6, __pyx_t_7, __pyx_t_8);
5263         }
5264         __pyx_t_6 = __pyx_t_7 = __pyx_t_8 = 0;
5265       }
5266       __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];
5267       if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(0, 339, __pyx_L1_error)
5268     }
5269     __pyx_t_5 = 0;
5270     __pyx_v__data = ((PyArrayObject *)__pyx_t_4);
5271     __pyx_t_4 = 0;
5272 
5273     /* "qutip/cy/sparse_routines.pxi":340
5274  *         ptr_len = mat.nrows+1
5275  *         _data = np.PyArray_SimpleNewFromData(1, &dat_len, np.NPY_COMPLEX128, mat.data)
5276  *         PyArray_ENABLEFLAGS(_data, np.NPY_ARRAY_OWNDATA)             # <<<<<<<<<<<<<<
5277  *
5278  *         _ind = np.PyArray_SimpleNewFromData(1, &dat_len, np.NPY_INT32, mat.indices)
5279  */
5280     PyArray_ENABLEFLAGS(((PyArrayObject *)__pyx_v__data), NPY_ARRAY_OWNDATA);
5281 
5282     /* "qutip/cy/sparse_routines.pxi":342
5283  *         PyArray_ENABLEFLAGS(_data, np.NPY_ARRAY_OWNDATA)
5284  *
5285  *         _ind = np.PyArray_SimpleNewFromData(1, &dat_len, np.NPY_INT32, mat.indices)             # <<<<<<<<<<<<<<
5286  *         PyArray_ENABLEFLAGS(_ind, np.NPY_ARRAY_OWNDATA)
5287  *
5288  */
5289     __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)
5290     __Pyx_GOTREF(__pyx_t_4);
5291     if (!(likely(((__pyx_t_4) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_4, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 342, __pyx_L1_error)
5292     __pyx_t_9 = ((PyArrayObject *)__pyx_t_4);
5293     {
5294       __Pyx_BufFmt_StackElem __pyx_stack[1];
5295       __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd__ind.rcbuffer->pybuffer);
5296       __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);
5297       if (unlikely(__pyx_t_3 < 0)) {
5298         PyErr_Fetch(&__pyx_t_8, &__pyx_t_7, &__pyx_t_6);
5299         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)) {
5300           Py_XDECREF(__pyx_t_8); Py_XDECREF(__pyx_t_7); Py_XDECREF(__pyx_t_6);
5301           __Pyx_RaiseBufferFallbackError();
5302         } else {
5303           PyErr_Restore(__pyx_t_8, __pyx_t_7, __pyx_t_6);
5304         }
5305         __pyx_t_8 = __pyx_t_7 = __pyx_t_6 = 0;
5306       }
5307       __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];
5308       if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(0, 342, __pyx_L1_error)
5309     }
5310     __pyx_t_9 = 0;
5311     __pyx_v__ind = ((PyArrayObject *)__pyx_t_4);
5312     __pyx_t_4 = 0;
5313 
5314     /* "qutip/cy/sparse_routines.pxi":343
5315  *
5316  *         _ind = np.PyArray_SimpleNewFromData(1, &dat_len, np.NPY_INT32, mat.indices)
5317  *         PyArray_ENABLEFLAGS(_ind, np.NPY_ARRAY_OWNDATA)             # <<<<<<<<<<<<<<
5318  *
5319  *         _ptr = np.PyArray_SimpleNewFromData(1, &ptr_len, np.NPY_INT32, mat.indptr)
5320  */
5321     PyArray_ENABLEFLAGS(((PyArrayObject *)__pyx_v__ind), NPY_ARRAY_OWNDATA);
5322 
5323     /* "qutip/cy/sparse_routines.pxi":345
5324  *         PyArray_ENABLEFLAGS(_ind, np.NPY_ARRAY_OWNDATA)
5325  *
5326  *         _ptr = np.PyArray_SimpleNewFromData(1, &ptr_len, np.NPY_INT32, mat.indptr)             # <<<<<<<<<<<<<<
5327  *         PyArray_ENABLEFLAGS(_ptr, np.NPY_ARRAY_OWNDATA)
5328  *         mat.numpy_lock = 1
5329  */
5330     __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)
5331     __Pyx_GOTREF(__pyx_t_4);
5332     if (!(likely(((__pyx_t_4) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_4, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 345, __pyx_L1_error)
5333     __pyx_t_9 = ((PyArrayObject *)__pyx_t_4);
5334     {
5335       __Pyx_BufFmt_StackElem __pyx_stack[1];
5336       __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd__ptr.rcbuffer->pybuffer);
5337       __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);
5338       if (unlikely(__pyx_t_3 < 0)) {
5339         PyErr_Fetch(&__pyx_t_6, &__pyx_t_7, &__pyx_t_8);
5340         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)) {
5341           Py_XDECREF(__pyx_t_6); Py_XDECREF(__pyx_t_7); Py_XDECREF(__pyx_t_8);
5342           __Pyx_RaiseBufferFallbackError();
5343         } else {
5344           PyErr_Restore(__pyx_t_6, __pyx_t_7, __pyx_t_8);
5345         }
5346         __pyx_t_6 = __pyx_t_7 = __pyx_t_8 = 0;
5347       }
5348       __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];
5349       if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(0, 345, __pyx_L1_error)
5350     }
5351     __pyx_t_9 = 0;
5352     __pyx_v__ptr = ((PyArrayObject *)__pyx_t_4);
5353     __pyx_t_4 = 0;
5354 
5355     /* "qutip/cy/sparse_routines.pxi":346
5356  *
5357  *         _ptr = np.PyArray_SimpleNewFromData(1, &ptr_len, np.NPY_INT32, mat.indptr)
5358  *         PyArray_ENABLEFLAGS(_ptr, np.NPY_ARRAY_OWNDATA)             # <<<<<<<<<<<<<<
5359  *         mat.numpy_lock = 1
5360  *         return fast_csr_matrix((_data, _ind, _ptr), shape=(mat.nrows,mat.ncols))
5361  */
5362     PyArray_ENABLEFLAGS(((PyArrayObject *)__pyx_v__ptr), NPY_ARRAY_OWNDATA);
5363 
5364     /* "qutip/cy/sparse_routines.pxi":347
5365  *         _ptr = np.PyArray_SimpleNewFromData(1, &ptr_len, np.NPY_INT32, mat.indptr)
5366  *         PyArray_ENABLEFLAGS(_ptr, np.NPY_ARRAY_OWNDATA)
5367  *         mat.numpy_lock = 1             # <<<<<<<<<<<<<<
5368  *         return fast_csr_matrix((_data, _ind, _ptr), shape=(mat.nrows,mat.ncols))
5369  *     else:
5370  */
5371     __pyx_v_mat->numpy_lock = 1;
5372 
5373     /* "qutip/cy/sparse_routines.pxi":348
5374  *         PyArray_ENABLEFLAGS(_ptr, np.NPY_ARRAY_OWNDATA)
5375  *         mat.numpy_lock = 1
5376  *         return fast_csr_matrix((_data, _ind, _ptr), shape=(mat.nrows,mat.ncols))             # <<<<<<<<<<<<<<
5377  *     else:
5378  *         if mat.numpy_lock:
5379  */
5380     __Pyx_XDECREF(__pyx_r);
5381     __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_fast_csr_matrix); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 348, __pyx_L1_error)
5382     __Pyx_GOTREF(__pyx_t_4);
5383     __pyx_t_10 = PyTuple_New(3); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 348, __pyx_L1_error)
5384     __Pyx_GOTREF(__pyx_t_10);
5385     __Pyx_INCREF(((PyObject *)__pyx_v__data));
5386     __Pyx_GIVEREF(((PyObject *)__pyx_v__data));
5387     PyTuple_SET_ITEM(__pyx_t_10, 0, ((PyObject *)__pyx_v__data));
5388     __Pyx_INCREF(((PyObject *)__pyx_v__ind));
5389     __Pyx_GIVEREF(((PyObject *)__pyx_v__ind));
5390     PyTuple_SET_ITEM(__pyx_t_10, 1, ((PyObject *)__pyx_v__ind));
5391     __Pyx_INCREF(((PyObject *)__pyx_v__ptr));
5392     __Pyx_GIVEREF(((PyObject *)__pyx_v__ptr));
5393     PyTuple_SET_ITEM(__pyx_t_10, 2, ((PyObject *)__pyx_v__ptr));
5394     __pyx_t_11 = PyTuple_New(1); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 348, __pyx_L1_error)
5395     __Pyx_GOTREF(__pyx_t_11);
5396     __Pyx_GIVEREF(__pyx_t_10);
5397     PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_t_10);
5398     __pyx_t_10 = 0;
5399     __pyx_t_10 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 348, __pyx_L1_error)
5400     __Pyx_GOTREF(__pyx_t_10);
5401     __pyx_t_12 = __Pyx_PyInt_From_int(__pyx_v_mat->nrows); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 348, __pyx_L1_error)
5402     __Pyx_GOTREF(__pyx_t_12);
5403     __pyx_t_13 = __Pyx_PyInt_From_int(__pyx_v_mat->ncols); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 348, __pyx_L1_error)
5404     __Pyx_GOTREF(__pyx_t_13);
5405     __pyx_t_14 = PyTuple_New(2); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 348, __pyx_L1_error)
5406     __Pyx_GOTREF(__pyx_t_14);
5407     __Pyx_GIVEREF(__pyx_t_12);
5408     PyTuple_SET_ITEM(__pyx_t_14, 0, __pyx_t_12);
5409     __Pyx_GIVEREF(__pyx_t_13);
5410     PyTuple_SET_ITEM(__pyx_t_14, 1, __pyx_t_13);
5411     __pyx_t_12 = 0;
5412     __pyx_t_13 = 0;
5413     if (PyDict_SetItem(__pyx_t_10, __pyx_n_s_shape, __pyx_t_14) < 0) __PYX_ERR(0, 348, __pyx_L1_error)
5414     __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
5415     __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)
5416     __Pyx_GOTREF(__pyx_t_14);
5417     __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
5418     __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
5419     __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
5420     __pyx_r = __pyx_t_14;
5421     __pyx_t_14 = 0;
5422     goto __pyx_L0;
5423 
5424     /* "qutip/cy/sparse_routines.pxi":336
5425  *     cdef np.ndarray[complex, ndim=1] _data
5426  *     cdef np.ndarray[int, ndim=1] _ind, _ptr
5427  *     if (not mat.numpy_lock) and mat.is_set:             # <<<<<<<<<<<<<<
5428  *         dat_len = mat.nnz
5429  *         ptr_len = mat.nrows+1
5430  */
5431   }
5432 
5433   /* "qutip/cy/sparse_routines.pxi":350
5434  *         return fast_csr_matrix((_data, _ind, _ptr), shape=(mat.nrows,mat.ncols))
5435  *     else:
5436  *         if mat.numpy_lock:             # <<<<<<<<<<<<<<
5437  *             raise_error_CSR(-4)
5438  *         elif not mat.is_set:
5439  */
5440   /*else*/ {
5441     __pyx_t_1 = (__pyx_v_mat->numpy_lock != 0);
5442     if (__pyx_t_1) {
5443 
5444       /* "qutip/cy/sparse_routines.pxi":351
5445  *     else:
5446  *         if mat.numpy_lock:
5447  *             raise_error_CSR(-4)             # <<<<<<<<<<<<<<
5448  *         elif not mat.is_set:
5449  *             raise_error_CSR(-3)
5450  */
5451       __pyx_f_5qutip_2cy_9br_tensor_raise_error_CSR(-4, NULL);
5452 
5453       /* "qutip/cy/sparse_routines.pxi":350
5454  *         return fast_csr_matrix((_data, _ind, _ptr), shape=(mat.nrows,mat.ncols))
5455  *     else:
5456  *         if mat.numpy_lock:             # <<<<<<<<<<<<<<
5457  *             raise_error_CSR(-4)
5458  *         elif not mat.is_set:
5459  */
5460       goto __pyx_L6;
5461     }
5462 
5463     /* "qutip/cy/sparse_routines.pxi":352
5464  *         if mat.numpy_lock:
5465  *             raise_error_CSR(-4)
5466  *         elif not mat.is_set:             # <<<<<<<<<<<<<<
5467  *             raise_error_CSR(-3)
5468  *
5469  */
5470     __pyx_t_1 = ((!(__pyx_v_mat->is_set != 0)) != 0);
5471     if (__pyx_t_1) {
5472 
5473       /* "qutip/cy/sparse_routines.pxi":353
5474  *             raise_error_CSR(-4)
5475  *         elif not mat.is_set:
5476  *             raise_error_CSR(-3)             # <<<<<<<<<<<<<<
5477  *
5478  *
5479  */
5480       __pyx_f_5qutip_2cy_9br_tensor_raise_error_CSR(-3, NULL);
5481 
5482       /* "qutip/cy/sparse_routines.pxi":352
5483  *         if mat.numpy_lock:
5484  *             raise_error_CSR(-4)
5485  *         elif not mat.is_set:             # <<<<<<<<<<<<<<
5486  *             raise_error_CSR(-3)
5487  *
5488  */
5489     }
5490     __pyx_L6:;
5491   }
5492 
5493   /* "qutip/cy/sparse_routines.pxi":321
5494  * @cython.boundscheck(False)
5495  * @cython.wraparound(False)
5496  * cdef object CSR_to_scipy(CSR_Matrix * mat):             # <<<<<<<<<<<<<<
5497  *     """
5498  *     Converts a CSR_Matrix struct to a SciPy csr_matrix class object.
5499  */
5500 
5501   /* function exit code */
5502   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
5503   goto __pyx_L0;
5504   __pyx_L1_error:;
5505   __Pyx_XDECREF(__pyx_t_4);
5506   __Pyx_XDECREF(__pyx_t_10);
5507   __Pyx_XDECREF(__pyx_t_11);
5508   __Pyx_XDECREF(__pyx_t_12);
5509   __Pyx_XDECREF(__pyx_t_13);
5510   __Pyx_XDECREF(__pyx_t_14);
5511   { PyObject *__pyx_type, *__pyx_value, *__pyx_tb;
5512     __Pyx_PyThreadState_declare
5513     __Pyx_PyThreadState_assign
5514     __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb);
5515     __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd__data.rcbuffer->pybuffer);
5516     __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd__ind.rcbuffer->pybuffer);
5517     __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd__ptr.rcbuffer->pybuffer);
5518   __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}
5519   __Pyx_AddTraceback("qutip.cy.br_tensor.CSR_to_scipy", __pyx_clineno, __pyx_lineno, __pyx_filename);
5520   __pyx_r = 0;
5521   goto __pyx_L2;
5522   __pyx_L0:;
5523   __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd__data.rcbuffer->pybuffer);
5524   __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd__ind.rcbuffer->pybuffer);
5525   __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd__ptr.rcbuffer->pybuffer);
5526   __pyx_L2:;
5527   __Pyx_XDECREF((PyObject *)__pyx_v__data);
5528   __Pyx_XDECREF((PyObject *)__pyx_v__ind);
5529   __Pyx_XDECREF((PyObject *)__pyx_v__ptr);
5530   __Pyx_XGIVEREF(__pyx_r);
5531   __Pyx_RefNannyFinishContext();
5532   return __pyx_r;
5533 }
5534 
5535 /* "qutip/cy/sparse_routines.pxi":358
5536  * @cython.boundscheck(False)
5537  * @cython.wraparound(False)
5538  * cdef object COO_to_scipy(COO_Matrix * mat):             # <<<<<<<<<<<<<<
5539  *     """
5540  *     Converts a COO_Matrix struct to a SciPy coo_matrix class object.
5541  */
5542 
__pyx_f_5qutip_2cy_9br_tensor_COO_to_scipy(__pyx_t_5qutip_2cy_14sparse_structs_COO_Matrix * __pyx_v_mat)5543 static PyObject *__pyx_f_5qutip_2cy_9br_tensor_COO_to_scipy(__pyx_t_5qutip_2cy_14sparse_structs_COO_Matrix *__pyx_v_mat) {
5544   npy_intp __pyx_v_dat_len;
5545   PyArrayObject *__pyx_v__data = 0;
5546   PyArrayObject *__pyx_v__row = 0;
5547   PyArrayObject *__pyx_v__col = 0;
5548   __Pyx_LocalBuf_ND __pyx_pybuffernd__col;
5549   __Pyx_Buffer __pyx_pybuffer__col;
5550   __Pyx_LocalBuf_ND __pyx_pybuffernd__data;
5551   __Pyx_Buffer __pyx_pybuffer__data;
5552   __Pyx_LocalBuf_ND __pyx_pybuffernd__row;
5553   __Pyx_Buffer __pyx_pybuffer__row;
5554   PyObject *__pyx_r = NULL;
5555   __Pyx_RefNannyDeclarations
5556   int __pyx_t_1;
5557   int __pyx_t_2;
5558   int __pyx_t_3;
5559   PyObject *__pyx_t_4 = NULL;
5560   PyArrayObject *__pyx_t_5 = NULL;
5561   PyObject *__pyx_t_6 = NULL;
5562   PyObject *__pyx_t_7 = NULL;
5563   PyObject *__pyx_t_8 = NULL;
5564   PyArrayObject *__pyx_t_9 = NULL;
5565   PyObject *__pyx_t_10 = NULL;
5566   PyObject *__pyx_t_11 = NULL;
5567   PyObject *__pyx_t_12 = NULL;
5568   PyObject *__pyx_t_13 = NULL;
5569   PyObject *__pyx_t_14 = NULL;
5570   int __pyx_lineno = 0;
5571   const char *__pyx_filename = NULL;
5572   int __pyx_clineno = 0;
5573   __Pyx_RefNannySetupContext("COO_to_scipy", 0);
5574   __pyx_pybuffer__data.pybuffer.buf = NULL;
5575   __pyx_pybuffer__data.refcount = 0;
5576   __pyx_pybuffernd__data.data = NULL;
5577   __pyx_pybuffernd__data.rcbuffer = &__pyx_pybuffer__data;
5578   __pyx_pybuffer__row.pybuffer.buf = NULL;
5579   __pyx_pybuffer__row.refcount = 0;
5580   __pyx_pybuffernd__row.data = NULL;
5581   __pyx_pybuffernd__row.rcbuffer = &__pyx_pybuffer__row;
5582   __pyx_pybuffer__col.pybuffer.buf = NULL;
5583   __pyx_pybuffer__col.refcount = 0;
5584   __pyx_pybuffernd__col.data = NULL;
5585   __pyx_pybuffernd__col.rcbuffer = &__pyx_pybuffer__col;
5586 
5587   /* "qutip/cy/sparse_routines.pxi":373
5588  *     cdef np.ndarray[complex, ndim=1] _data
5589  *     cdef np.ndarray[int, ndim=1] _row, _col
5590  *     if (not mat.numpy_lock) and mat.is_set:             # <<<<<<<<<<<<<<
5591  *         dat_len = mat.nnz
5592  *         _data = np.PyArray_SimpleNewFromData(1, &dat_len, np.NPY_COMPLEX128, mat.data)
5593  */
5594   __pyx_t_2 = ((!(__pyx_v_mat->numpy_lock != 0)) != 0);
5595   if (__pyx_t_2) {
5596   } else {
5597     __pyx_t_1 = __pyx_t_2;
5598     goto __pyx_L4_bool_binop_done;
5599   }
5600   __pyx_t_2 = (__pyx_v_mat->is_set != 0);
5601   __pyx_t_1 = __pyx_t_2;
5602   __pyx_L4_bool_binop_done:;
5603   if (__pyx_t_1) {
5604 
5605     /* "qutip/cy/sparse_routines.pxi":374
5606  *     cdef np.ndarray[int, ndim=1] _row, _col
5607  *     if (not mat.numpy_lock) and mat.is_set:
5608  *         dat_len = mat.nnz             # <<<<<<<<<<<<<<
5609  *         _data = np.PyArray_SimpleNewFromData(1, &dat_len, np.NPY_COMPLEX128, mat.data)
5610  *         PyArray_ENABLEFLAGS(_data, np.NPY_ARRAY_OWNDATA)
5611  */
5612     __pyx_t_3 = __pyx_v_mat->nnz;
5613     __pyx_v_dat_len = __pyx_t_3;
5614 
5615     /* "qutip/cy/sparse_routines.pxi":375
5616  *     if (not mat.numpy_lock) and mat.is_set:
5617  *         dat_len = mat.nnz
5618  *         _data = np.PyArray_SimpleNewFromData(1, &dat_len, np.NPY_COMPLEX128, mat.data)             # <<<<<<<<<<<<<<
5619  *         PyArray_ENABLEFLAGS(_data, np.NPY_ARRAY_OWNDATA)
5620  *
5621  */
5622     __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)
5623     __Pyx_GOTREF(__pyx_t_4);
5624     if (!(likely(((__pyx_t_4) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_4, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 375, __pyx_L1_error)
5625     __pyx_t_5 = ((PyArrayObject *)__pyx_t_4);
5626     {
5627       __Pyx_BufFmt_StackElem __pyx_stack[1];
5628       __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd__data.rcbuffer->pybuffer);
5629       __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);
5630       if (unlikely(__pyx_t_3 < 0)) {
5631         PyErr_Fetch(&__pyx_t_6, &__pyx_t_7, &__pyx_t_8);
5632         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)) {
5633           Py_XDECREF(__pyx_t_6); Py_XDECREF(__pyx_t_7); Py_XDECREF(__pyx_t_8);
5634           __Pyx_RaiseBufferFallbackError();
5635         } else {
5636           PyErr_Restore(__pyx_t_6, __pyx_t_7, __pyx_t_8);
5637         }
5638         __pyx_t_6 = __pyx_t_7 = __pyx_t_8 = 0;
5639       }
5640       __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];
5641       if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(0, 375, __pyx_L1_error)
5642     }
5643     __pyx_t_5 = 0;
5644     __pyx_v__data = ((PyArrayObject *)__pyx_t_4);
5645     __pyx_t_4 = 0;
5646 
5647     /* "qutip/cy/sparse_routines.pxi":376
5648  *         dat_len = mat.nnz
5649  *         _data = np.PyArray_SimpleNewFromData(1, &dat_len, np.NPY_COMPLEX128, mat.data)
5650  *         PyArray_ENABLEFLAGS(_data, np.NPY_ARRAY_OWNDATA)             # <<<<<<<<<<<<<<
5651  *
5652  *         _row = np.PyArray_SimpleNewFromData(1, &dat_len, np.NPY_INT32, mat.rows)
5653  */
5654     PyArray_ENABLEFLAGS(((PyArrayObject *)__pyx_v__data), NPY_ARRAY_OWNDATA);
5655 
5656     /* "qutip/cy/sparse_routines.pxi":378
5657  *         PyArray_ENABLEFLAGS(_data, np.NPY_ARRAY_OWNDATA)
5658  *
5659  *         _row = np.PyArray_SimpleNewFromData(1, &dat_len, np.NPY_INT32, mat.rows)             # <<<<<<<<<<<<<<
5660  *         PyArray_ENABLEFLAGS(_row, np.NPY_ARRAY_OWNDATA)
5661  *
5662  */
5663     __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)
5664     __Pyx_GOTREF(__pyx_t_4);
5665     if (!(likely(((__pyx_t_4) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_4, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 378, __pyx_L1_error)
5666     __pyx_t_9 = ((PyArrayObject *)__pyx_t_4);
5667     {
5668       __Pyx_BufFmt_StackElem __pyx_stack[1];
5669       __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd__row.rcbuffer->pybuffer);
5670       __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);
5671       if (unlikely(__pyx_t_3 < 0)) {
5672         PyErr_Fetch(&__pyx_t_8, &__pyx_t_7, &__pyx_t_6);
5673         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)) {
5674           Py_XDECREF(__pyx_t_8); Py_XDECREF(__pyx_t_7); Py_XDECREF(__pyx_t_6);
5675           __Pyx_RaiseBufferFallbackError();
5676         } else {
5677           PyErr_Restore(__pyx_t_8, __pyx_t_7, __pyx_t_6);
5678         }
5679         __pyx_t_8 = __pyx_t_7 = __pyx_t_6 = 0;
5680       }
5681       __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];
5682       if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(0, 378, __pyx_L1_error)
5683     }
5684     __pyx_t_9 = 0;
5685     __pyx_v__row = ((PyArrayObject *)__pyx_t_4);
5686     __pyx_t_4 = 0;
5687 
5688     /* "qutip/cy/sparse_routines.pxi":379
5689  *
5690  *         _row = np.PyArray_SimpleNewFromData(1, &dat_len, np.NPY_INT32, mat.rows)
5691  *         PyArray_ENABLEFLAGS(_row, np.NPY_ARRAY_OWNDATA)             # <<<<<<<<<<<<<<
5692  *
5693  *         _col = np.PyArray_SimpleNewFromData(1, &dat_len, np.NPY_INT32, mat.cols)
5694  */
5695     PyArray_ENABLEFLAGS(((PyArrayObject *)__pyx_v__row), NPY_ARRAY_OWNDATA);
5696 
5697     /* "qutip/cy/sparse_routines.pxi":381
5698  *         PyArray_ENABLEFLAGS(_row, np.NPY_ARRAY_OWNDATA)
5699  *
5700  *         _col = np.PyArray_SimpleNewFromData(1, &dat_len, np.NPY_INT32, mat.cols)             # <<<<<<<<<<<<<<
5701  *         PyArray_ENABLEFLAGS(_col, np.NPY_ARRAY_OWNDATA)
5702  *         mat.numpy_lock = 1
5703  */
5704     __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)
5705     __Pyx_GOTREF(__pyx_t_4);
5706     if (!(likely(((__pyx_t_4) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_4, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 381, __pyx_L1_error)
5707     __pyx_t_9 = ((PyArrayObject *)__pyx_t_4);
5708     {
5709       __Pyx_BufFmt_StackElem __pyx_stack[1];
5710       __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd__col.rcbuffer->pybuffer);
5711       __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);
5712       if (unlikely(__pyx_t_3 < 0)) {
5713         PyErr_Fetch(&__pyx_t_6, &__pyx_t_7, &__pyx_t_8);
5714         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)) {
5715           Py_XDECREF(__pyx_t_6); Py_XDECREF(__pyx_t_7); Py_XDECREF(__pyx_t_8);
5716           __Pyx_RaiseBufferFallbackError();
5717         } else {
5718           PyErr_Restore(__pyx_t_6, __pyx_t_7, __pyx_t_8);
5719         }
5720         __pyx_t_6 = __pyx_t_7 = __pyx_t_8 = 0;
5721       }
5722       __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];
5723       if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(0, 381, __pyx_L1_error)
5724     }
5725     __pyx_t_9 = 0;
5726     __pyx_v__col = ((PyArrayObject *)__pyx_t_4);
5727     __pyx_t_4 = 0;
5728 
5729     /* "qutip/cy/sparse_routines.pxi":382
5730  *
5731  *         _col = np.PyArray_SimpleNewFromData(1, &dat_len, np.NPY_INT32, mat.cols)
5732  *         PyArray_ENABLEFLAGS(_col, np.NPY_ARRAY_OWNDATA)             # <<<<<<<<<<<<<<
5733  *         mat.numpy_lock = 1
5734  *         return coo_matrix((_data, (_row, _col)), shape=(mat.nrows,mat.ncols))
5735  */
5736     PyArray_ENABLEFLAGS(((PyArrayObject *)__pyx_v__col), NPY_ARRAY_OWNDATA);
5737 
5738     /* "qutip/cy/sparse_routines.pxi":383
5739  *         _col = np.PyArray_SimpleNewFromData(1, &dat_len, np.NPY_INT32, mat.cols)
5740  *         PyArray_ENABLEFLAGS(_col, np.NPY_ARRAY_OWNDATA)
5741  *         mat.numpy_lock = 1             # <<<<<<<<<<<<<<
5742  *         return coo_matrix((_data, (_row, _col)), shape=(mat.nrows,mat.ncols))
5743  *     else:
5744  */
5745     __pyx_v_mat->numpy_lock = 1;
5746 
5747     /* "qutip/cy/sparse_routines.pxi":384
5748  *         PyArray_ENABLEFLAGS(_col, np.NPY_ARRAY_OWNDATA)
5749  *         mat.numpy_lock = 1
5750  *         return coo_matrix((_data, (_row, _col)), shape=(mat.nrows,mat.ncols))             # <<<<<<<<<<<<<<
5751  *     else:
5752  *         if mat.numpy_lock:
5753  */
5754     __Pyx_XDECREF(__pyx_r);
5755     __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_coo_matrix); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 384, __pyx_L1_error)
5756     __Pyx_GOTREF(__pyx_t_4);
5757     __pyx_t_10 = PyTuple_New(2); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 384, __pyx_L1_error)
5758     __Pyx_GOTREF(__pyx_t_10);
5759     __Pyx_INCREF(((PyObject *)__pyx_v__row));
5760     __Pyx_GIVEREF(((PyObject *)__pyx_v__row));
5761     PyTuple_SET_ITEM(__pyx_t_10, 0, ((PyObject *)__pyx_v__row));
5762     __Pyx_INCREF(((PyObject *)__pyx_v__col));
5763     __Pyx_GIVEREF(((PyObject *)__pyx_v__col));
5764     PyTuple_SET_ITEM(__pyx_t_10, 1, ((PyObject *)__pyx_v__col));
5765     __pyx_t_11 = PyTuple_New(2); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 384, __pyx_L1_error)
5766     __Pyx_GOTREF(__pyx_t_11);
5767     __Pyx_INCREF(((PyObject *)__pyx_v__data));
5768     __Pyx_GIVEREF(((PyObject *)__pyx_v__data));
5769     PyTuple_SET_ITEM(__pyx_t_11, 0, ((PyObject *)__pyx_v__data));
5770     __Pyx_GIVEREF(__pyx_t_10);
5771     PyTuple_SET_ITEM(__pyx_t_11, 1, __pyx_t_10);
5772     __pyx_t_10 = 0;
5773     __pyx_t_10 = PyTuple_New(1); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 384, __pyx_L1_error)
5774     __Pyx_GOTREF(__pyx_t_10);
5775     __Pyx_GIVEREF(__pyx_t_11);
5776     PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_11);
5777     __pyx_t_11 = 0;
5778     __pyx_t_11 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 384, __pyx_L1_error)
5779     __Pyx_GOTREF(__pyx_t_11);
5780     __pyx_t_12 = __Pyx_PyInt_From_int(__pyx_v_mat->nrows); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 384, __pyx_L1_error)
5781     __Pyx_GOTREF(__pyx_t_12);
5782     __pyx_t_13 = __Pyx_PyInt_From_int(__pyx_v_mat->ncols); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 384, __pyx_L1_error)
5783     __Pyx_GOTREF(__pyx_t_13);
5784     __pyx_t_14 = PyTuple_New(2); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 384, __pyx_L1_error)
5785     __Pyx_GOTREF(__pyx_t_14);
5786     __Pyx_GIVEREF(__pyx_t_12);
5787     PyTuple_SET_ITEM(__pyx_t_14, 0, __pyx_t_12);
5788     __Pyx_GIVEREF(__pyx_t_13);
5789     PyTuple_SET_ITEM(__pyx_t_14, 1, __pyx_t_13);
5790     __pyx_t_12 = 0;
5791     __pyx_t_13 = 0;
5792     if (PyDict_SetItem(__pyx_t_11, __pyx_n_s_shape, __pyx_t_14) < 0) __PYX_ERR(0, 384, __pyx_L1_error)
5793     __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
5794     __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)
5795     __Pyx_GOTREF(__pyx_t_14);
5796     __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
5797     __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
5798     __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
5799     __pyx_r = __pyx_t_14;
5800     __pyx_t_14 = 0;
5801     goto __pyx_L0;
5802 
5803     /* "qutip/cy/sparse_routines.pxi":373
5804  *     cdef np.ndarray[complex, ndim=1] _data
5805  *     cdef np.ndarray[int, ndim=1] _row, _col
5806  *     if (not mat.numpy_lock) and mat.is_set:             # <<<<<<<<<<<<<<
5807  *         dat_len = mat.nnz
5808  *         _data = np.PyArray_SimpleNewFromData(1, &dat_len, np.NPY_COMPLEX128, mat.data)
5809  */
5810   }
5811 
5812   /* "qutip/cy/sparse_routines.pxi":386
5813  *         return coo_matrix((_data, (_row, _col)), shape=(mat.nrows,mat.ncols))
5814  *     else:
5815  *         if mat.numpy_lock:             # <<<<<<<<<<<<<<
5816  *             raise_error_COO(-4)
5817  *         elif not mat.is_set:
5818  */
5819   /*else*/ {
5820     __pyx_t_1 = (__pyx_v_mat->numpy_lock != 0);
5821     if (__pyx_t_1) {
5822 
5823       /* "qutip/cy/sparse_routines.pxi":387
5824  *     else:
5825  *         if mat.numpy_lock:
5826  *             raise_error_COO(-4)             # <<<<<<<<<<<<<<
5827  *         elif not mat.is_set:
5828  *             raise_error_COO(-3)
5829  */
5830       __pyx_f_5qutip_2cy_9br_tensor_raise_error_COO(-4, NULL);
5831 
5832       /* "qutip/cy/sparse_routines.pxi":386
5833  *         return coo_matrix((_data, (_row, _col)), shape=(mat.nrows,mat.ncols))
5834  *     else:
5835  *         if mat.numpy_lock:             # <<<<<<<<<<<<<<
5836  *             raise_error_COO(-4)
5837  *         elif not mat.is_set:
5838  */
5839       goto __pyx_L6;
5840     }
5841 
5842     /* "qutip/cy/sparse_routines.pxi":388
5843  *         if mat.numpy_lock:
5844  *             raise_error_COO(-4)
5845  *         elif not mat.is_set:             # <<<<<<<<<<<<<<
5846  *             raise_error_COO(-3)
5847  *
5848  */
5849     __pyx_t_1 = ((!(__pyx_v_mat->is_set != 0)) != 0);
5850     if (__pyx_t_1) {
5851 
5852       /* "qutip/cy/sparse_routines.pxi":389
5853  *             raise_error_COO(-4)
5854  *         elif not mat.is_set:
5855  *             raise_error_COO(-3)             # <<<<<<<<<<<<<<
5856  *
5857  *
5858  */
5859       __pyx_f_5qutip_2cy_9br_tensor_raise_error_COO(-3, NULL);
5860 
5861       /* "qutip/cy/sparse_routines.pxi":388
5862  *         if mat.numpy_lock:
5863  *             raise_error_COO(-4)
5864  *         elif not mat.is_set:             # <<<<<<<<<<<<<<
5865  *             raise_error_COO(-3)
5866  *
5867  */
5868     }
5869     __pyx_L6:;
5870   }
5871 
5872   /* "qutip/cy/sparse_routines.pxi":358
5873  * @cython.boundscheck(False)
5874  * @cython.wraparound(False)
5875  * cdef object COO_to_scipy(COO_Matrix * mat):             # <<<<<<<<<<<<<<
5876  *     """
5877  *     Converts a COO_Matrix struct to a SciPy coo_matrix class object.
5878  */
5879 
5880   /* function exit code */
5881   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
5882   goto __pyx_L0;
5883   __pyx_L1_error:;
5884   __Pyx_XDECREF(__pyx_t_4);
5885   __Pyx_XDECREF(__pyx_t_10);
5886   __Pyx_XDECREF(__pyx_t_11);
5887   __Pyx_XDECREF(__pyx_t_12);
5888   __Pyx_XDECREF(__pyx_t_13);
5889   __Pyx_XDECREF(__pyx_t_14);
5890   { PyObject *__pyx_type, *__pyx_value, *__pyx_tb;
5891     __Pyx_PyThreadState_declare
5892     __Pyx_PyThreadState_assign
5893     __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb);
5894     __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd__col.rcbuffer->pybuffer);
5895     __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd__data.rcbuffer->pybuffer);
5896     __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd__row.rcbuffer->pybuffer);
5897   __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}
5898   __Pyx_AddTraceback("qutip.cy.br_tensor.COO_to_scipy", __pyx_clineno, __pyx_lineno, __pyx_filename);
5899   __pyx_r = 0;
5900   goto __pyx_L2;
5901   __pyx_L0:;
5902   __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd__col.rcbuffer->pybuffer);
5903   __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd__data.rcbuffer->pybuffer);
5904   __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd__row.rcbuffer->pybuffer);
5905   __pyx_L2:;
5906   __Pyx_XDECREF((PyObject *)__pyx_v__data);
5907   __Pyx_XDECREF((PyObject *)__pyx_v__row);
5908   __Pyx_XDECREF((PyObject *)__pyx_v__col);
5909   __Pyx_XGIVEREF(__pyx_r);
5910   __Pyx_RefNannyFinishContext();
5911   return __pyx_r;
5912 }
5913 
5914 /* "qutip/cy/sparse_routines.pxi":395
5915  * @cython.boundscheck(False)
5916  * @cython.wraparound(False)
5917  * cdef void COO_to_CSR(CSR_Matrix * out, COO_Matrix * mat):             # <<<<<<<<<<<<<<
5918  *     """
5919  *     Conversion from COO to CSR. Not in place,
5920  */
5921 
__pyx_f_5qutip_2cy_9br_tensor_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)5922 static void __pyx_f_5qutip_2cy_9br_tensor_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) {
5923   int __pyx_v_i;
5924   int __pyx_v_j;
5925   int __pyx_v_iad;
5926   int __pyx_v_j0;
5927   __pyx_t_double_complex __pyx_v_val;
5928   size_t __pyx_v_kk;
5929   __Pyx_RefNannyDeclarations
5930   struct __pyx_opt_args_5qutip_2cy_9br_tensor_init_CSR __pyx_t_1;
5931   int __pyx_t_2;
5932   int __pyx_t_3;
5933   size_t __pyx_t_4;
5934   __Pyx_RefNannySetupContext("COO_to_CSR", 0);
5935 
5936   /* "qutip/cy/sparse_routines.pxi":403
5937  *     cdef double complex val
5938  *     cdef size_t kk
5939  *     init_CSR(out, mat.nnz, mat.nrows, mat.ncols, max_length=0, init_zeros=1)             # <<<<<<<<<<<<<<
5940  *     # Determine row lengths
5941  *     for kk in range(mat.nnz):
5942  */
5943   __pyx_t_1.__pyx_n = 3;
5944   __pyx_t_1.ncols = __pyx_v_mat->ncols;
5945   __pyx_t_1.max_length = 0;
5946   __pyx_t_1.init_zeros = 1;
5947   __pyx_f_5qutip_2cy_9br_tensor_init_CSR(__pyx_v_out, __pyx_v_mat->nnz, __pyx_v_mat->nrows, &__pyx_t_1);
5948 
5949   /* "qutip/cy/sparse_routines.pxi":405
5950  *     init_CSR(out, mat.nnz, mat.nrows, mat.ncols, max_length=0, init_zeros=1)
5951  *     # Determine row lengths
5952  *     for kk in range(mat.nnz):             # <<<<<<<<<<<<<<
5953  *         out.indptr[mat.rows[kk]] = out.indptr[mat.rows[kk]] + 1
5954  *     # Starting position of rows
5955  */
5956   __pyx_t_2 = __pyx_v_mat->nnz;
5957   __pyx_t_3 = __pyx_t_2;
5958   for (__pyx_t_4 = 0; __pyx_t_4 < __pyx_t_3; __pyx_t_4+=1) {
5959     __pyx_v_kk = __pyx_t_4;
5960 
5961     /* "qutip/cy/sparse_routines.pxi":406
5962  *     # Determine row lengths
5963  *     for kk in range(mat.nnz):
5964  *         out.indptr[mat.rows[kk]] = out.indptr[mat.rows[kk]] + 1             # <<<<<<<<<<<<<<
5965  *     # Starting position of rows
5966  *     j = 0
5967  */
5968     (__pyx_v_out->indptr[(__pyx_v_mat->rows[__pyx_v_kk])]) = ((__pyx_v_out->indptr[(__pyx_v_mat->rows[__pyx_v_kk])]) + 1);
5969   }
5970 
5971   /* "qutip/cy/sparse_routines.pxi":408
5972  *         out.indptr[mat.rows[kk]] = out.indptr[mat.rows[kk]] + 1
5973  *     # Starting position of rows
5974  *     j = 0             # <<<<<<<<<<<<<<
5975  *     for kk in range(mat.nrows):
5976  *         j0 = out.indptr[kk]
5977  */
5978   __pyx_v_j = 0;
5979 
5980   /* "qutip/cy/sparse_routines.pxi":409
5981  *     # Starting position of rows
5982  *     j = 0
5983  *     for kk in range(mat.nrows):             # <<<<<<<<<<<<<<
5984  *         j0 = out.indptr[kk]
5985  *         out.indptr[kk] = j
5986  */
5987   __pyx_t_2 = __pyx_v_mat->nrows;
5988   __pyx_t_3 = __pyx_t_2;
5989   for (__pyx_t_4 = 0; __pyx_t_4 < __pyx_t_3; __pyx_t_4+=1) {
5990     __pyx_v_kk = __pyx_t_4;
5991 
5992     /* "qutip/cy/sparse_routines.pxi":410
5993  *     j = 0
5994  *     for kk in range(mat.nrows):
5995  *         j0 = out.indptr[kk]             # <<<<<<<<<<<<<<
5996  *         out.indptr[kk] = j
5997  *         j += j0
5998  */
5999     __pyx_v_j0 = (__pyx_v_out->indptr[__pyx_v_kk]);
6000 
6001     /* "qutip/cy/sparse_routines.pxi":411
6002  *     for kk in range(mat.nrows):
6003  *         j0 = out.indptr[kk]
6004  *         out.indptr[kk] = j             # <<<<<<<<<<<<<<
6005  *         j += j0
6006  *     #Do the data
6007  */
6008     (__pyx_v_out->indptr[__pyx_v_kk]) = __pyx_v_j;
6009 
6010     /* "qutip/cy/sparse_routines.pxi":412
6011  *         j0 = out.indptr[kk]
6012  *         out.indptr[kk] = j
6013  *         j += j0             # <<<<<<<<<<<<<<
6014  *     #Do the data
6015  *     for kk in range(mat.nnz):
6016  */
6017     __pyx_v_j = (__pyx_v_j + __pyx_v_j0);
6018   }
6019 
6020   /* "qutip/cy/sparse_routines.pxi":414
6021  *         j += j0
6022  *     #Do the data
6023  *     for kk in range(mat.nnz):             # <<<<<<<<<<<<<<
6024  *         i = mat.rows[kk]
6025  *         j = mat.cols[kk]
6026  */
6027   __pyx_t_2 = __pyx_v_mat->nnz;
6028   __pyx_t_3 = __pyx_t_2;
6029   for (__pyx_t_4 = 0; __pyx_t_4 < __pyx_t_3; __pyx_t_4+=1) {
6030     __pyx_v_kk = __pyx_t_4;
6031 
6032     /* "qutip/cy/sparse_routines.pxi":415
6033  *     #Do the data
6034  *     for kk in range(mat.nnz):
6035  *         i = mat.rows[kk]             # <<<<<<<<<<<<<<
6036  *         j = mat.cols[kk]
6037  *         val = mat.data[kk]
6038  */
6039     __pyx_v_i = (__pyx_v_mat->rows[__pyx_v_kk]);
6040 
6041     /* "qutip/cy/sparse_routines.pxi":416
6042  *     for kk in range(mat.nnz):
6043  *         i = mat.rows[kk]
6044  *         j = mat.cols[kk]             # <<<<<<<<<<<<<<
6045  *         val = mat.data[kk]
6046  *         iad = out.indptr[i]
6047  */
6048     __pyx_v_j = (__pyx_v_mat->cols[__pyx_v_kk]);
6049 
6050     /* "qutip/cy/sparse_routines.pxi":417
6051  *         i = mat.rows[kk]
6052  *         j = mat.cols[kk]
6053  *         val = mat.data[kk]             # <<<<<<<<<<<<<<
6054  *         iad = out.indptr[i]
6055  *         out.data[iad] = val
6056  */
6057     __pyx_v_val = (__pyx_v_mat->data[__pyx_v_kk]);
6058 
6059     /* "qutip/cy/sparse_routines.pxi":418
6060  *         j = mat.cols[kk]
6061  *         val = mat.data[kk]
6062  *         iad = out.indptr[i]             # <<<<<<<<<<<<<<
6063  *         out.data[iad] = val
6064  *         out.indices[iad] = j
6065  */
6066     __pyx_v_iad = (__pyx_v_out->indptr[__pyx_v_i]);
6067 
6068     /* "qutip/cy/sparse_routines.pxi":419
6069  *         val = mat.data[kk]
6070  *         iad = out.indptr[i]
6071  *         out.data[iad] = val             # <<<<<<<<<<<<<<
6072  *         out.indices[iad] = j
6073  *         out.indptr[i] = iad+1
6074  */
6075     (__pyx_v_out->data[__pyx_v_iad]) = __pyx_v_val;
6076 
6077     /* "qutip/cy/sparse_routines.pxi":420
6078  *         iad = out.indptr[i]
6079  *         out.data[iad] = val
6080  *         out.indices[iad] = j             # <<<<<<<<<<<<<<
6081  *         out.indptr[i] = iad+1
6082  *     # Shift back
6083  */
6084     (__pyx_v_out->indices[__pyx_v_iad]) = __pyx_v_j;
6085 
6086     /* "qutip/cy/sparse_routines.pxi":421
6087  *         out.data[iad] = val
6088  *         out.indices[iad] = j
6089  *         out.indptr[i] = iad+1             # <<<<<<<<<<<<<<
6090  *     # Shift back
6091  *     for kk in range(mat.nrows,0,-1):
6092  */
6093     (__pyx_v_out->indptr[__pyx_v_i]) = (__pyx_v_iad + 1);
6094   }
6095 
6096   /* "qutip/cy/sparse_routines.pxi":423
6097  *         out.indptr[i] = iad+1
6098  *     # Shift back
6099  *     for kk in range(mat.nrows,0,-1):             # <<<<<<<<<<<<<<
6100  *         out.indptr[kk] = out.indptr[kk-1]
6101  *     out.indptr[0] = 0
6102  */
6103   for (__pyx_t_4 = __pyx_v_mat->nrows + 1; __pyx_t_4 > 0 + 1; ) { __pyx_t_4-=1;
6104     __pyx_v_kk = __pyx_t_4;
6105 
6106     /* "qutip/cy/sparse_routines.pxi":424
6107  *     # Shift back
6108  *     for kk in range(mat.nrows,0,-1):
6109  *         out.indptr[kk] = out.indptr[kk-1]             # <<<<<<<<<<<<<<
6110  *     out.indptr[0] = 0
6111  *
6112  */
6113     (__pyx_v_out->indptr[__pyx_v_kk]) = (__pyx_v_out->indptr[(__pyx_v_kk - 1)]);
6114   }
6115 
6116   /* "qutip/cy/sparse_routines.pxi":425
6117  *     for kk in range(mat.nrows,0,-1):
6118  *         out.indptr[kk] = out.indptr[kk-1]
6119  *     out.indptr[0] = 0             # <<<<<<<<<<<<<<
6120  *
6121  *
6122  */
6123   (__pyx_v_out->indptr[0]) = 0;
6124 
6125   /* "qutip/cy/sparse_routines.pxi":395
6126  * @cython.boundscheck(False)
6127  * @cython.wraparound(False)
6128  * cdef void COO_to_CSR(CSR_Matrix * out, COO_Matrix * mat):             # <<<<<<<<<<<<<<
6129  *     """
6130  *     Conversion from COO to CSR. Not in place,
6131  */
6132 
6133   /* function exit code */
6134   __Pyx_RefNannyFinishContext();
6135 }
6136 
6137 /* "qutip/cy/sparse_routines.pxi":430
6138  * @cython.boundscheck(False)
6139  * @cython.wraparound(False)
6140  * cdef void CSR_to_COO(COO_Matrix * out, CSR_Matrix * mat):             # <<<<<<<<<<<<<<
6141  *     """
6142  *     Converts a CSR_Matrix to a COO_Matrix.
6143  */
6144 
__pyx_f_5qutip_2cy_9br_tensor_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)6145 static void __pyx_f_5qutip_2cy_9br_tensor_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) {
6146   int __pyx_v_k1;
6147   int __pyx_v_k2;
6148   size_t __pyx_v_jj;
6149   size_t __pyx_v_kk;
6150   __Pyx_RefNannyDeclarations
6151   struct __pyx_opt_args_5qutip_2cy_9br_tensor_init_COO __pyx_t_1;
6152   int __pyx_t_2;
6153   int __pyx_t_3;
6154   size_t __pyx_t_4;
6155   size_t __pyx_t_5;
6156   __Pyx_RefNannySetupContext("CSR_to_COO", 0);
6157 
6158   /* "qutip/cy/sparse_routines.pxi":436
6159  *     cdef int k1, k2
6160  *     cdef size_t jj, kk
6161  *     init_COO(out, mat.nnz, mat.nrows, mat.ncols)             # <<<<<<<<<<<<<<
6162  *     for kk in range(mat.nnz):
6163  *         out.data[kk] = mat.data[kk]
6164  */
6165   __pyx_t_1.__pyx_n = 1;
6166   __pyx_t_1.ncols = __pyx_v_mat->ncols;
6167   __pyx_f_5qutip_2cy_9br_tensor_init_COO(__pyx_v_out, __pyx_v_mat->nnz, __pyx_v_mat->nrows, &__pyx_t_1);
6168 
6169   /* "qutip/cy/sparse_routines.pxi":437
6170  *     cdef size_t jj, kk
6171  *     init_COO(out, mat.nnz, mat.nrows, mat.ncols)
6172  *     for kk in range(mat.nnz):             # <<<<<<<<<<<<<<
6173  *         out.data[kk] = mat.data[kk]
6174  *         out.cols[kk] = mat.indices[kk]
6175  */
6176   __pyx_t_2 = __pyx_v_mat->nnz;
6177   __pyx_t_3 = __pyx_t_2;
6178   for (__pyx_t_4 = 0; __pyx_t_4 < __pyx_t_3; __pyx_t_4+=1) {
6179     __pyx_v_kk = __pyx_t_4;
6180 
6181     /* "qutip/cy/sparse_routines.pxi":438
6182  *     init_COO(out, mat.nnz, mat.nrows, mat.ncols)
6183  *     for kk in range(mat.nnz):
6184  *         out.data[kk] = mat.data[kk]             # <<<<<<<<<<<<<<
6185  *         out.cols[kk] = mat.indices[kk]
6186  *     for kk in range(mat.nrows-1,0,-1):
6187  */
6188     (__pyx_v_out->data[__pyx_v_kk]) = (__pyx_v_mat->data[__pyx_v_kk]);
6189 
6190     /* "qutip/cy/sparse_routines.pxi":439
6191  *     for kk in range(mat.nnz):
6192  *         out.data[kk] = mat.data[kk]
6193  *         out.cols[kk] = mat.indices[kk]             # <<<<<<<<<<<<<<
6194  *     for kk in range(mat.nrows-1,0,-1):
6195  *         k1 = mat.indptr[kk+1]
6196  */
6197     (__pyx_v_out->cols[__pyx_v_kk]) = (__pyx_v_mat->indices[__pyx_v_kk]);
6198   }
6199 
6200   /* "qutip/cy/sparse_routines.pxi":440
6201  *         out.data[kk] = mat.data[kk]
6202  *         out.cols[kk] = mat.indices[kk]
6203  *     for kk in range(mat.nrows-1,0,-1):             # <<<<<<<<<<<<<<
6204  *         k1 = mat.indptr[kk+1]
6205  *         k2 = mat.indptr[kk]
6206  */
6207   for (__pyx_t_4 = (__pyx_v_mat->nrows - 1) + 1; __pyx_t_4 > 0 + 1; ) { __pyx_t_4-=1;
6208     __pyx_v_kk = __pyx_t_4;
6209 
6210     /* "qutip/cy/sparse_routines.pxi":441
6211  *         out.cols[kk] = mat.indices[kk]
6212  *     for kk in range(mat.nrows-1,0,-1):
6213  *         k1 = mat.indptr[kk+1]             # <<<<<<<<<<<<<<
6214  *         k2 = mat.indptr[kk]
6215  *         for jj in range(k2, k1):
6216  */
6217     __pyx_v_k1 = (__pyx_v_mat->indptr[(__pyx_v_kk + 1)]);
6218 
6219     /* "qutip/cy/sparse_routines.pxi":442
6220  *     for kk in range(mat.nrows-1,0,-1):
6221  *         k1 = mat.indptr[kk+1]
6222  *         k2 = mat.indptr[kk]             # <<<<<<<<<<<<<<
6223  *         for jj in range(k2, k1):
6224  *             out.rows[jj] = kk
6225  */
6226     __pyx_v_k2 = (__pyx_v_mat->indptr[__pyx_v_kk]);
6227 
6228     /* "qutip/cy/sparse_routines.pxi":443
6229  *         k1 = mat.indptr[kk+1]
6230  *         k2 = mat.indptr[kk]
6231  *         for jj in range(k2, k1):             # <<<<<<<<<<<<<<
6232  *             out.rows[jj] = kk
6233  *
6234  */
6235     __pyx_t_2 = __pyx_v_k1;
6236     __pyx_t_3 = __pyx_t_2;
6237     for (__pyx_t_5 = __pyx_v_k2; __pyx_t_5 < __pyx_t_3; __pyx_t_5+=1) {
6238       __pyx_v_jj = __pyx_t_5;
6239 
6240       /* "qutip/cy/sparse_routines.pxi":444
6241  *         k2 = mat.indptr[kk]
6242  *         for jj in range(k2, k1):
6243  *             out.rows[jj] = kk             # <<<<<<<<<<<<<<
6244  *
6245  *
6246  */
6247       (__pyx_v_out->rows[__pyx_v_jj]) = __pyx_v_kk;
6248     }
6249   }
6250 
6251   /* "qutip/cy/sparse_routines.pxi":430
6252  * @cython.boundscheck(False)
6253  * @cython.wraparound(False)
6254  * cdef void CSR_to_COO(COO_Matrix * out, CSR_Matrix * mat):             # <<<<<<<<<<<<<<
6255  *     """
6256  *     Converts a CSR_Matrix to a COO_Matrix.
6257  */
6258 
6259   /* function exit code */
6260   __Pyx_RefNannyFinishContext();
6261 }
6262 
6263 /* "qutip/cy/sparse_routines.pxi":450
6264  * @cython.boundscheck(False)
6265  * @cython.wraparound(False)
6266  * cdef void COO_to_CSR_inplace(CSR_Matrix * out, COO_Matrix * mat):             # <<<<<<<<<<<<<<
6267  *     """
6268  *     In place conversion from COO to CSR. In place, but not sorted.
6269  */
6270 
__pyx_f_5qutip_2cy_9br_tensor_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)6271 static void __pyx_f_5qutip_2cy_9br_tensor_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) {
6272   size_t __pyx_v_kk;
6273   int __pyx_v_i;
6274   int __pyx_v_j;
6275   int __pyx_v_init;
6276   int __pyx_v_inext;
6277   int __pyx_v_jnext;
6278   int __pyx_v_ipos;
6279   int *__pyx_v__tmp_rows;
6280   __pyx_t_double_complex __pyx_v_val;
6281   __pyx_t_double_complex __pyx_v_val_next;
6282   int *__pyx_v_work;
6283   __Pyx_RefNannyDeclarations
6284   int __pyx_t_1;
6285   int __pyx_t_2;
6286   size_t __pyx_t_3;
6287   long __pyx_t_4;
6288   size_t __pyx_t_5;
6289   int __pyx_t_6;
6290   __pyx_t_double_complex *__pyx_t_7;
6291   int *__pyx_t_8;
6292   __Pyx_RefNannySetupContext("COO_to_CSR_inplace", 0);
6293 
6294   /* "qutip/cy/sparse_routines.pxi":460
6295  *     cdef int * _tmp_rows
6296  *     cdef complex val, val_next
6297  *     cdef int * work = <int *>PyDataMem_NEW_ZEROED(mat.nrows+1, sizeof(int))             # <<<<<<<<<<<<<<
6298  *     # Determine output indptr array
6299  *     for kk in range(mat.nnz):
6300  */
6301   __pyx_v_work = ((int *)PyDataMem_NEW_ZEROED((__pyx_v_mat->nrows + 1), (sizeof(int))));
6302 
6303   /* "qutip/cy/sparse_routines.pxi":462
6304  *     cdef int * work = <int *>PyDataMem_NEW_ZEROED(mat.nrows+1, sizeof(int))
6305  *     # Determine output indptr array
6306  *     for kk in range(mat.nnz):             # <<<<<<<<<<<<<<
6307  *         i = mat.rows[kk]
6308  *         work[i+1] += 1
6309  */
6310   __pyx_t_1 = __pyx_v_mat->nnz;
6311   __pyx_t_2 = __pyx_t_1;
6312   for (__pyx_t_3 = 0; __pyx_t_3 < __pyx_t_2; __pyx_t_3+=1) {
6313     __pyx_v_kk = __pyx_t_3;
6314 
6315     /* "qutip/cy/sparse_routines.pxi":463
6316  *     # Determine output indptr array
6317  *     for kk in range(mat.nnz):
6318  *         i = mat.rows[kk]             # <<<<<<<<<<<<<<
6319  *         work[i+1] += 1
6320  *     work[0] = 0
6321  */
6322     __pyx_v_i = (__pyx_v_mat->rows[__pyx_v_kk]);
6323 
6324     /* "qutip/cy/sparse_routines.pxi":464
6325  *     for kk in range(mat.nnz):
6326  *         i = mat.rows[kk]
6327  *         work[i+1] += 1             # <<<<<<<<<<<<<<
6328  *     work[0] = 0
6329  *     for kk in range(mat.nrows):
6330  */
6331     __pyx_t_4 = (__pyx_v_i + 1);
6332     (__pyx_v_work[__pyx_t_4]) = ((__pyx_v_work[__pyx_t_4]) + 1);
6333   }
6334 
6335   /* "qutip/cy/sparse_routines.pxi":465
6336  *         i = mat.rows[kk]
6337  *         work[i+1] += 1
6338  *     work[0] = 0             # <<<<<<<<<<<<<<
6339  *     for kk in range(mat.nrows):
6340  *         work[kk+1] += work[kk]
6341  */
6342   (__pyx_v_work[0]) = 0;
6343 
6344   /* "qutip/cy/sparse_routines.pxi":466
6345  *         work[i+1] += 1
6346  *     work[0] = 0
6347  *     for kk in range(mat.nrows):             # <<<<<<<<<<<<<<
6348  *         work[kk+1] += work[kk]
6349  *
6350  */
6351   __pyx_t_1 = __pyx_v_mat->nrows;
6352   __pyx_t_2 = __pyx_t_1;
6353   for (__pyx_t_3 = 0; __pyx_t_3 < __pyx_t_2; __pyx_t_3+=1) {
6354     __pyx_v_kk = __pyx_t_3;
6355 
6356     /* "qutip/cy/sparse_routines.pxi":467
6357  *     work[0] = 0
6358  *     for kk in range(mat.nrows):
6359  *         work[kk+1] += work[kk]             # <<<<<<<<<<<<<<
6360  *
6361  *     if mat.nnz < (mat.nrows+1):
6362  */
6363     __pyx_t_5 = (__pyx_v_kk + 1);
6364     (__pyx_v_work[__pyx_t_5]) = ((__pyx_v_work[__pyx_t_5]) + (__pyx_v_work[__pyx_v_kk]));
6365   }
6366 
6367   /* "qutip/cy/sparse_routines.pxi":469
6368  *         work[kk+1] += work[kk]
6369  *
6370  *     if mat.nnz < (mat.nrows+1):             # <<<<<<<<<<<<<<
6371  *         _tmp_rows = <int *>PyDataMem_RENEW(mat.rows, (mat.nrows+1) * sizeof(int))
6372  *         mat.rows = _tmp_rows
6373  */
6374   __pyx_t_6 = ((__pyx_v_mat->nnz < (__pyx_v_mat->nrows + 1)) != 0);
6375   if (__pyx_t_6) {
6376 
6377     /* "qutip/cy/sparse_routines.pxi":470
6378  *
6379  *     if mat.nnz < (mat.nrows+1):
6380  *         _tmp_rows = <int *>PyDataMem_RENEW(mat.rows, (mat.nrows+1) * sizeof(int))             # <<<<<<<<<<<<<<
6381  *         mat.rows = _tmp_rows
6382  *     init = 0
6383  */
6384     __pyx_v__tmp_rows = ((int *)PyDataMem_RENEW(__pyx_v_mat->rows, ((__pyx_v_mat->nrows + 1) * (sizeof(int)))));
6385 
6386     /* "qutip/cy/sparse_routines.pxi":471
6387  *     if mat.nnz < (mat.nrows+1):
6388  *         _tmp_rows = <int *>PyDataMem_RENEW(mat.rows, (mat.nrows+1) * sizeof(int))
6389  *         mat.rows = _tmp_rows             # <<<<<<<<<<<<<<
6390  *     init = 0
6391  *     while init < mat.nnz:
6392  */
6393     __pyx_v_mat->rows = __pyx_v__tmp_rows;
6394 
6395     /* "qutip/cy/sparse_routines.pxi":469
6396  *         work[kk+1] += work[kk]
6397  *
6398  *     if mat.nnz < (mat.nrows+1):             # <<<<<<<<<<<<<<
6399  *         _tmp_rows = <int *>PyDataMem_RENEW(mat.rows, (mat.nrows+1) * sizeof(int))
6400  *         mat.rows = _tmp_rows
6401  */
6402   }
6403 
6404   /* "qutip/cy/sparse_routines.pxi":472
6405  *         _tmp_rows = <int *>PyDataMem_RENEW(mat.rows, (mat.nrows+1) * sizeof(int))
6406  *         mat.rows = _tmp_rows
6407  *     init = 0             # <<<<<<<<<<<<<<
6408  *     while init < mat.nnz:
6409  *         while (mat.rows[init] < 0):
6410  */
6411   __pyx_v_init = 0;
6412 
6413   /* "qutip/cy/sparse_routines.pxi":473
6414  *         mat.rows = _tmp_rows
6415  *     init = 0
6416  *     while init < mat.nnz:             # <<<<<<<<<<<<<<
6417  *         while (mat.rows[init] < 0):
6418  *             init += 1
6419  */
6420   while (1) {
6421     __pyx_t_6 = ((__pyx_v_init < __pyx_v_mat->nnz) != 0);
6422     if (!__pyx_t_6) break;
6423 
6424     /* "qutip/cy/sparse_routines.pxi":474
6425  *     init = 0
6426  *     while init < mat.nnz:
6427  *         while (mat.rows[init] < 0):             # <<<<<<<<<<<<<<
6428  *             init += 1
6429  *         val = mat.data[init]
6430  */
6431     while (1) {
6432       __pyx_t_6 = (((__pyx_v_mat->rows[__pyx_v_init]) < 0) != 0);
6433       if (!__pyx_t_6) break;
6434 
6435       /* "qutip/cy/sparse_routines.pxi":475
6436  *     while init < mat.nnz:
6437  *         while (mat.rows[init] < 0):
6438  *             init += 1             # <<<<<<<<<<<<<<
6439  *         val = mat.data[init]
6440  *         i = mat.rows[init]
6441  */
6442       __pyx_v_init = (__pyx_v_init + 1);
6443     }
6444 
6445     /* "qutip/cy/sparse_routines.pxi":476
6446  *         while (mat.rows[init] < 0):
6447  *             init += 1
6448  *         val = mat.data[init]             # <<<<<<<<<<<<<<
6449  *         i = mat.rows[init]
6450  *         j = mat.cols[init]
6451  */
6452     __pyx_v_val = (__pyx_v_mat->data[__pyx_v_init]);
6453 
6454     /* "qutip/cy/sparse_routines.pxi":477
6455  *             init += 1
6456  *         val = mat.data[init]
6457  *         i = mat.rows[init]             # <<<<<<<<<<<<<<
6458  *         j = mat.cols[init]
6459  *         mat.rows[init] = -1
6460  */
6461     __pyx_v_i = (__pyx_v_mat->rows[__pyx_v_init]);
6462 
6463     /* "qutip/cy/sparse_routines.pxi":478
6464  *         val = mat.data[init]
6465  *         i = mat.rows[init]
6466  *         j = mat.cols[init]             # <<<<<<<<<<<<<<
6467  *         mat.rows[init] = -1
6468  *         while 1:
6469  */
6470     __pyx_v_j = (__pyx_v_mat->cols[__pyx_v_init]);
6471 
6472     /* "qutip/cy/sparse_routines.pxi":479
6473  *         i = mat.rows[init]
6474  *         j = mat.cols[init]
6475  *         mat.rows[init] = -1             # <<<<<<<<<<<<<<
6476  *         while 1:
6477  *             ipos = work[i]
6478  */
6479     (__pyx_v_mat->rows[__pyx_v_init]) = -1;
6480 
6481     /* "qutip/cy/sparse_routines.pxi":480
6482  *         j = mat.cols[init]
6483  *         mat.rows[init] = -1
6484  *         while 1:             # <<<<<<<<<<<<<<
6485  *             ipos = work[i]
6486  *             val_next = mat.data[ipos]
6487  */
6488     while (1) {
6489 
6490       /* "qutip/cy/sparse_routines.pxi":481
6491  *         mat.rows[init] = -1
6492  *         while 1:
6493  *             ipos = work[i]             # <<<<<<<<<<<<<<
6494  *             val_next = mat.data[ipos]
6495  *             inext = mat.rows[ipos]
6496  */
6497       __pyx_v_ipos = (__pyx_v_work[__pyx_v_i]);
6498 
6499       /* "qutip/cy/sparse_routines.pxi":482
6500  *         while 1:
6501  *             ipos = work[i]
6502  *             val_next = mat.data[ipos]             # <<<<<<<<<<<<<<
6503  *             inext = mat.rows[ipos]
6504  *             jnext = mat.cols[ipos]
6505  */
6506       __pyx_v_val_next = (__pyx_v_mat->data[__pyx_v_ipos]);
6507 
6508       /* "qutip/cy/sparse_routines.pxi":483
6509  *             ipos = work[i]
6510  *             val_next = mat.data[ipos]
6511  *             inext = mat.rows[ipos]             # <<<<<<<<<<<<<<
6512  *             jnext = mat.cols[ipos]
6513  *
6514  */
6515       __pyx_v_inext = (__pyx_v_mat->rows[__pyx_v_ipos]);
6516 
6517       /* "qutip/cy/sparse_routines.pxi":484
6518  *             val_next = mat.data[ipos]
6519  *             inext = mat.rows[ipos]
6520  *             jnext = mat.cols[ipos]             # <<<<<<<<<<<<<<
6521  *
6522  *             mat.data[ipos] = val
6523  */
6524       __pyx_v_jnext = (__pyx_v_mat->cols[__pyx_v_ipos]);
6525 
6526       /* "qutip/cy/sparse_routines.pxi":486
6527  *             jnext = mat.cols[ipos]
6528  *
6529  *             mat.data[ipos] = val             # <<<<<<<<<<<<<<
6530  *             mat.cols[ipos] = j
6531  *             mat.rows[ipos] = -1
6532  */
6533       (__pyx_v_mat->data[__pyx_v_ipos]) = __pyx_v_val;
6534 
6535       /* "qutip/cy/sparse_routines.pxi":487
6536  *
6537  *             mat.data[ipos] = val
6538  *             mat.cols[ipos] = j             # <<<<<<<<<<<<<<
6539  *             mat.rows[ipos] = -1
6540  *             work[i] += 1
6541  */
6542       (__pyx_v_mat->cols[__pyx_v_ipos]) = __pyx_v_j;
6543 
6544       /* "qutip/cy/sparse_routines.pxi":488
6545  *             mat.data[ipos] = val
6546  *             mat.cols[ipos] = j
6547  *             mat.rows[ipos] = -1             # <<<<<<<<<<<<<<
6548  *             work[i] += 1
6549  *             if inext < 0:
6550  */
6551       (__pyx_v_mat->rows[__pyx_v_ipos]) = -1;
6552 
6553       /* "qutip/cy/sparse_routines.pxi":489
6554  *             mat.cols[ipos] = j
6555  *             mat.rows[ipos] = -1
6556  *             work[i] += 1             # <<<<<<<<<<<<<<
6557  *             if inext < 0:
6558  *                 break
6559  */
6560       __pyx_t_1 = __pyx_v_i;
6561       (__pyx_v_work[__pyx_t_1]) = ((__pyx_v_work[__pyx_t_1]) + 1);
6562 
6563       /* "qutip/cy/sparse_routines.pxi":490
6564  *             mat.rows[ipos] = -1
6565  *             work[i] += 1
6566  *             if inext < 0:             # <<<<<<<<<<<<<<
6567  *                 break
6568  *             val = val_next
6569  */
6570       __pyx_t_6 = ((__pyx_v_inext < 0) != 0);
6571       if (__pyx_t_6) {
6572 
6573         /* "qutip/cy/sparse_routines.pxi":491
6574  *             work[i] += 1
6575  *             if inext < 0:
6576  *                 break             # <<<<<<<<<<<<<<
6577  *             val = val_next
6578  *             i = inext
6579  */
6580         goto __pyx_L13_break;
6581 
6582         /* "qutip/cy/sparse_routines.pxi":490
6583  *             mat.rows[ipos] = -1
6584  *             work[i] += 1
6585  *             if inext < 0:             # <<<<<<<<<<<<<<
6586  *                 break
6587  *             val = val_next
6588  */
6589       }
6590 
6591       /* "qutip/cy/sparse_routines.pxi":492
6592  *             if inext < 0:
6593  *                 break
6594  *             val = val_next             # <<<<<<<<<<<<<<
6595  *             i = inext
6596  *             j = jnext
6597  */
6598       __pyx_v_val = __pyx_v_val_next;
6599 
6600       /* "qutip/cy/sparse_routines.pxi":493
6601  *                 break
6602  *             val = val_next
6603  *             i = inext             # <<<<<<<<<<<<<<
6604  *             j = jnext
6605  *         init += 1
6606  */
6607       __pyx_v_i = __pyx_v_inext;
6608 
6609       /* "qutip/cy/sparse_routines.pxi":494
6610  *             val = val_next
6611  *             i = inext
6612  *             j = jnext             # <<<<<<<<<<<<<<
6613  *         init += 1
6614  *
6615  */
6616       __pyx_v_j = __pyx_v_jnext;
6617     }
6618     __pyx_L13_break:;
6619 
6620     /* "qutip/cy/sparse_routines.pxi":495
6621  *             i = inext
6622  *             j = jnext
6623  *         init += 1             # <<<<<<<<<<<<<<
6624  *
6625  *     for kk in range(mat.nrows):
6626  */
6627     __pyx_v_init = (__pyx_v_init + 1);
6628   }
6629 
6630   /* "qutip/cy/sparse_routines.pxi":497
6631  *         init += 1
6632  *
6633  *     for kk in range(mat.nrows):             # <<<<<<<<<<<<<<
6634  *         mat.rows[kk+1] = work[kk]
6635  *     mat.rows[0] = 0
6636  */
6637   __pyx_t_1 = __pyx_v_mat->nrows;
6638   __pyx_t_2 = __pyx_t_1;
6639   for (__pyx_t_3 = 0; __pyx_t_3 < __pyx_t_2; __pyx_t_3+=1) {
6640     __pyx_v_kk = __pyx_t_3;
6641 
6642     /* "qutip/cy/sparse_routines.pxi":498
6643  *
6644  *     for kk in range(mat.nrows):
6645  *         mat.rows[kk+1] = work[kk]             # <<<<<<<<<<<<<<
6646  *     mat.rows[0] = 0
6647  *
6648  */
6649     (__pyx_v_mat->rows[(__pyx_v_kk + 1)]) = (__pyx_v_work[__pyx_v_kk]);
6650   }
6651 
6652   /* "qutip/cy/sparse_routines.pxi":499
6653  *     for kk in range(mat.nrows):
6654  *         mat.rows[kk+1] = work[kk]
6655  *     mat.rows[0] = 0             # <<<<<<<<<<<<<<
6656  *
6657  *     if mat.nnz > (mat.nrows+1):
6658  */
6659   (__pyx_v_mat->rows[0]) = 0;
6660 
6661   /* "qutip/cy/sparse_routines.pxi":501
6662  *     mat.rows[0] = 0
6663  *
6664  *     if mat.nnz > (mat.nrows+1):             # <<<<<<<<<<<<<<
6665  *         _tmp_rows = <int *>PyDataMem_RENEW(mat.rows, (mat.nrows+1) * sizeof(int))
6666  *         mat.rows = _tmp_rows
6667  */
6668   __pyx_t_6 = ((__pyx_v_mat->nnz > (__pyx_v_mat->nrows + 1)) != 0);
6669   if (__pyx_t_6) {
6670 
6671     /* "qutip/cy/sparse_routines.pxi":502
6672  *
6673  *     if mat.nnz > (mat.nrows+1):
6674  *         _tmp_rows = <int *>PyDataMem_RENEW(mat.rows, (mat.nrows+1) * sizeof(int))             # <<<<<<<<<<<<<<
6675  *         mat.rows = _tmp_rows
6676  *     #Free working array
6677  */
6678     __pyx_v__tmp_rows = ((int *)PyDataMem_RENEW(__pyx_v_mat->rows, ((__pyx_v_mat->nrows + 1) * (sizeof(int)))));
6679 
6680     /* "qutip/cy/sparse_routines.pxi":503
6681  *     if mat.nnz > (mat.nrows+1):
6682  *         _tmp_rows = <int *>PyDataMem_RENEW(mat.rows, (mat.nrows+1) * sizeof(int))
6683  *         mat.rows = _tmp_rows             # <<<<<<<<<<<<<<
6684  *     #Free working array
6685  *     PyDataMem_FREE(work)
6686  */
6687     __pyx_v_mat->rows = __pyx_v__tmp_rows;
6688 
6689     /* "qutip/cy/sparse_routines.pxi":501
6690  *     mat.rows[0] = 0
6691  *
6692  *     if mat.nnz > (mat.nrows+1):             # <<<<<<<<<<<<<<
6693  *         _tmp_rows = <int *>PyDataMem_RENEW(mat.rows, (mat.nrows+1) * sizeof(int))
6694  *         mat.rows = _tmp_rows
6695  */
6696   }
6697 
6698   /* "qutip/cy/sparse_routines.pxi":505
6699  *         mat.rows = _tmp_rows
6700  *     #Free working array
6701  *     PyDataMem_FREE(work)             # <<<<<<<<<<<<<<
6702  *     #Set CSR pointers to original COO data.
6703  *     out.data = mat.data
6704  */
6705   PyDataMem_FREE(__pyx_v_work);
6706 
6707   /* "qutip/cy/sparse_routines.pxi":507
6708  *     PyDataMem_FREE(work)
6709  *     #Set CSR pointers to original COO data.
6710  *     out.data = mat.data             # <<<<<<<<<<<<<<
6711  *     out.indices = mat.cols
6712  *     out.indptr = mat.rows
6713  */
6714   __pyx_t_7 = __pyx_v_mat->data;
6715   __pyx_v_out->data = __pyx_t_7;
6716 
6717   /* "qutip/cy/sparse_routines.pxi":508
6718  *     #Set CSR pointers to original COO data.
6719  *     out.data = mat.data
6720  *     out.indices = mat.cols             # <<<<<<<<<<<<<<
6721  *     out.indptr = mat.rows
6722  *     out.nrows = mat.nrows
6723  */
6724   __pyx_t_8 = __pyx_v_mat->cols;
6725   __pyx_v_out->indices = __pyx_t_8;
6726 
6727   /* "qutip/cy/sparse_routines.pxi":509
6728  *     out.data = mat.data
6729  *     out.indices = mat.cols
6730  *     out.indptr = mat.rows             # <<<<<<<<<<<<<<
6731  *     out.nrows = mat.nrows
6732  *     out.ncols = mat.ncols
6733  */
6734   __pyx_t_8 = __pyx_v_mat->rows;
6735   __pyx_v_out->indptr = __pyx_t_8;
6736 
6737   /* "qutip/cy/sparse_routines.pxi":510
6738  *     out.indices = mat.cols
6739  *     out.indptr = mat.rows
6740  *     out.nrows = mat.nrows             # <<<<<<<<<<<<<<
6741  *     out.ncols = mat.ncols
6742  *     out.nnz = mat.nnz
6743  */
6744   __pyx_t_1 = __pyx_v_mat->nrows;
6745   __pyx_v_out->nrows = __pyx_t_1;
6746 
6747   /* "qutip/cy/sparse_routines.pxi":511
6748  *     out.indptr = mat.rows
6749  *     out.nrows = mat.nrows
6750  *     out.ncols = mat.ncols             # <<<<<<<<<<<<<<
6751  *     out.nnz = mat.nnz
6752  *     out.max_length = mat.nnz
6753  */
6754   __pyx_t_1 = __pyx_v_mat->ncols;
6755   __pyx_v_out->ncols = __pyx_t_1;
6756 
6757   /* "qutip/cy/sparse_routines.pxi":512
6758  *     out.nrows = mat.nrows
6759  *     out.ncols = mat.ncols
6760  *     out.nnz = mat.nnz             # <<<<<<<<<<<<<<
6761  *     out.max_length = mat.nnz
6762  *     out.is_set = 1
6763  */
6764   __pyx_t_1 = __pyx_v_mat->nnz;
6765   __pyx_v_out->nnz = __pyx_t_1;
6766 
6767   /* "qutip/cy/sparse_routines.pxi":513
6768  *     out.ncols = mat.ncols
6769  *     out.nnz = mat.nnz
6770  *     out.max_length = mat.nnz             # <<<<<<<<<<<<<<
6771  *     out.is_set = 1
6772  *     out.numpy_lock = 0
6773  */
6774   __pyx_t_1 = __pyx_v_mat->nnz;
6775   __pyx_v_out->max_length = __pyx_t_1;
6776 
6777   /* "qutip/cy/sparse_routines.pxi":514
6778  *     out.nnz = mat.nnz
6779  *     out.max_length = mat.nnz
6780  *     out.is_set = 1             # <<<<<<<<<<<<<<
6781  *     out.numpy_lock = 0
6782  *
6783  */
6784   __pyx_v_out->is_set = 1;
6785 
6786   /* "qutip/cy/sparse_routines.pxi":515
6787  *     out.max_length = mat.nnz
6788  *     out.is_set = 1
6789  *     out.numpy_lock = 0             # <<<<<<<<<<<<<<
6790  *
6791  *
6792  */
6793   __pyx_v_out->numpy_lock = 0;
6794 
6795   /* "qutip/cy/sparse_routines.pxi":450
6796  * @cython.boundscheck(False)
6797  * @cython.wraparound(False)
6798  * cdef void COO_to_CSR_inplace(CSR_Matrix * out, COO_Matrix * mat):             # <<<<<<<<<<<<<<
6799  *     """
6800  *     In place conversion from COO to CSR. In place, but not sorted.
6801  */
6802 
6803   /* function exit code */
6804   __Pyx_RefNannyFinishContext();
6805 }
6806 
6807 /* "qutip/cy/sparse_routines.pxi":520
6808  * @cython.boundscheck(False)
6809  * @cython.wraparound(False)
6810  * cdef int ind_sort(data_ind_pair x, data_ind_pair y):             # <<<<<<<<<<<<<<
6811  *     return x.ind < y.ind
6812  *
6813  */
6814 
__pyx_f_5qutip_2cy_9br_tensor_ind_sort(__pyx_t_5qutip_2cy_9br_tensor_data_ind_pair __pyx_v_x,__pyx_t_5qutip_2cy_9br_tensor_data_ind_pair __pyx_v_y)6815 static int __pyx_f_5qutip_2cy_9br_tensor_ind_sort(__pyx_t_5qutip_2cy_9br_tensor_data_ind_pair __pyx_v_x, __pyx_t_5qutip_2cy_9br_tensor_data_ind_pair __pyx_v_y) {
6816   int __pyx_r;
6817   __Pyx_RefNannyDeclarations
6818   __Pyx_RefNannySetupContext("ind_sort", 0);
6819 
6820   /* "qutip/cy/sparse_routines.pxi":521
6821  * @cython.wraparound(False)
6822  * cdef int ind_sort(data_ind_pair x, data_ind_pair y):
6823  *     return x.ind < y.ind             # <<<<<<<<<<<<<<
6824  *
6825  *
6826  */
6827   __pyx_r = (__pyx_v_x.ind < __pyx_v_y.ind);
6828   goto __pyx_L0;
6829 
6830   /* "qutip/cy/sparse_routines.pxi":520
6831  * @cython.boundscheck(False)
6832  * @cython.wraparound(False)
6833  * cdef int ind_sort(data_ind_pair x, data_ind_pair y):             # <<<<<<<<<<<<<<
6834  *     return x.ind < y.ind
6835  *
6836  */
6837 
6838   /* function exit code */
6839   __pyx_L0:;
6840   __Pyx_RefNannyFinishContext();
6841   return __pyx_r;
6842 }
6843 
6844 /* "qutip/cy/sparse_routines.pxi":526
6845  * @cython.boundscheck(False)
6846  * @cython.wraparound(False)
6847  * cdef void sort_indices(CSR_Matrix * mat):             # <<<<<<<<<<<<<<
6848  *     """
6849  *     Sorts the indices of a CSR_Matrix inplace.
6850  */
6851 
__pyx_f_5qutip_2cy_9br_tensor_sort_indices(__pyx_t_5qutip_2cy_14sparse_structs_CSR_Matrix * __pyx_v_mat)6852 static void __pyx_f_5qutip_2cy_9br_tensor_sort_indices(__pyx_t_5qutip_2cy_14sparse_structs_CSR_Matrix *__pyx_v_mat) {
6853   size_t __pyx_v_ii;
6854   size_t __pyx_v_jj;
6855   std::vector<__pyx_t_5qutip_2cy_9br_tensor_data_ind_pair>  __pyx_v_pairs;
6856   __pyx_t_5qutip_2cy_9br_tensor_cfptr __pyx_v_cfptr_;
6857   int __pyx_v_row_start;
6858   int __pyx_v_row_end;
6859   int __pyx_v_length;
6860   __Pyx_RefNannyDeclarations
6861   int __pyx_t_1;
6862   int __pyx_t_2;
6863   size_t __pyx_t_3;
6864   int __pyx_t_4;
6865   int __pyx_t_5;
6866   size_t __pyx_t_6;
6867   __pyx_t_double_complex __pyx_t_7;
6868   int __pyx_t_8;
6869   int __pyx_lineno = 0;
6870   const char *__pyx_filename = NULL;
6871   int __pyx_clineno = 0;
6872   __Pyx_RefNannySetupContext("sort_indices", 0);
6873 
6874   /* "qutip/cy/sparse_routines.pxi":532
6875  *     cdef size_t ii, jj
6876  *     cdef vector[data_ind_pair] pairs
6877  *     cdef cfptr cfptr_ = &ind_sort             # <<<<<<<<<<<<<<
6878  *     cdef int row_start, row_end, length
6879  *
6880  */
6881   __pyx_v_cfptr_ = (&__pyx_f_5qutip_2cy_9br_tensor_ind_sort);
6882 
6883   /* "qutip/cy/sparse_routines.pxi":535
6884  *     cdef int row_start, row_end, length
6885  *
6886  *     for ii in range(mat.nrows):             # <<<<<<<<<<<<<<
6887  *         row_start = mat.indptr[ii]
6888  *         row_end = mat.indptr[ii+1]
6889  */
6890   __pyx_t_1 = __pyx_v_mat->nrows;
6891   __pyx_t_2 = __pyx_t_1;
6892   for (__pyx_t_3 = 0; __pyx_t_3 < __pyx_t_2; __pyx_t_3+=1) {
6893     __pyx_v_ii = __pyx_t_3;
6894 
6895     /* "qutip/cy/sparse_routines.pxi":536
6896  *
6897  *     for ii in range(mat.nrows):
6898  *         row_start = mat.indptr[ii]             # <<<<<<<<<<<<<<
6899  *         row_end = mat.indptr[ii+1]
6900  *         length = row_end - row_start
6901  */
6902     __pyx_v_row_start = (__pyx_v_mat->indptr[__pyx_v_ii]);
6903 
6904     /* "qutip/cy/sparse_routines.pxi":537
6905  *     for ii in range(mat.nrows):
6906  *         row_start = mat.indptr[ii]
6907  *         row_end = mat.indptr[ii+1]             # <<<<<<<<<<<<<<
6908  *         length = row_end - row_start
6909  *         pairs.resize(length)
6910  */
6911     __pyx_v_row_end = (__pyx_v_mat->indptr[(__pyx_v_ii + 1)]);
6912 
6913     /* "qutip/cy/sparse_routines.pxi":538
6914  *         row_start = mat.indptr[ii]
6915  *         row_end = mat.indptr[ii+1]
6916  *         length = row_end - row_start             # <<<<<<<<<<<<<<
6917  *         pairs.resize(length)
6918  *
6919  */
6920     __pyx_v_length = (__pyx_v_row_end - __pyx_v_row_start);
6921 
6922     /* "qutip/cy/sparse_routines.pxi":539
6923  *         row_end = mat.indptr[ii+1]
6924  *         length = row_end - row_start
6925  *         pairs.resize(length)             # <<<<<<<<<<<<<<
6926  *
6927  *         for jj in range(length):
6928  */
6929     try {
6930       __pyx_v_pairs.resize(__pyx_v_length);
6931     } catch(...) {
6932       __Pyx_CppExn2PyErr();
6933       __PYX_ERR(0, 539, __pyx_L1_error)
6934     }
6935 
6936     /* "qutip/cy/sparse_routines.pxi":541
6937  *         pairs.resize(length)
6938  *
6939  *         for jj in range(length):             # <<<<<<<<<<<<<<
6940  *             pairs[jj].data = mat.data[row_start+jj]
6941  *             pairs[jj].ind = mat.indices[row_start+jj]
6942  */
6943     __pyx_t_4 = __pyx_v_length;
6944     __pyx_t_5 = __pyx_t_4;
6945     for (__pyx_t_6 = 0; __pyx_t_6 < __pyx_t_5; __pyx_t_6+=1) {
6946       __pyx_v_jj = __pyx_t_6;
6947 
6948       /* "qutip/cy/sparse_routines.pxi":542
6949  *
6950  *         for jj in range(length):
6951  *             pairs[jj].data = mat.data[row_start+jj]             # <<<<<<<<<<<<<<
6952  *             pairs[jj].ind = mat.indices[row_start+jj]
6953  *
6954  */
6955       (__pyx_v_pairs[__pyx_v_jj]).data = (__pyx_v_mat->data[(__pyx_v_row_start + __pyx_v_jj)]);
6956 
6957       /* "qutip/cy/sparse_routines.pxi":543
6958  *         for jj in range(length):
6959  *             pairs[jj].data = mat.data[row_start+jj]
6960  *             pairs[jj].ind = mat.indices[row_start+jj]             # <<<<<<<<<<<<<<
6961  *
6962  *         sort(pairs.begin(),pairs.end(),cfptr_)
6963  */
6964       (__pyx_v_pairs[__pyx_v_jj]).ind = (__pyx_v_mat->indices[(__pyx_v_row_start + __pyx_v_jj)]);
6965     }
6966 
6967     /* "qutip/cy/sparse_routines.pxi":545
6968  *             pairs[jj].ind = mat.indices[row_start+jj]
6969  *
6970  *         sort(pairs.begin(),pairs.end(),cfptr_)             # <<<<<<<<<<<<<<
6971  *
6972  *         for jj in range(length):
6973  */
6974     std::sort<std::vector<__pyx_t_5qutip_2cy_9br_tensor_data_ind_pair> ::iterator,__pyx_t_5qutip_2cy_9br_tensor_cfptr>(__pyx_v_pairs.begin(), __pyx_v_pairs.end(), __pyx_v_cfptr_);
6975 
6976     /* "qutip/cy/sparse_routines.pxi":547
6977  *         sort(pairs.begin(),pairs.end(),cfptr_)
6978  *
6979  *         for jj in range(length):             # <<<<<<<<<<<<<<
6980  *             mat.data[row_start+jj] = pairs[jj].data
6981  *             mat.indices[row_start+jj] = pairs[jj].ind
6982  */
6983     __pyx_t_4 = __pyx_v_length;
6984     __pyx_t_5 = __pyx_t_4;
6985     for (__pyx_t_6 = 0; __pyx_t_6 < __pyx_t_5; __pyx_t_6+=1) {
6986       __pyx_v_jj = __pyx_t_6;
6987 
6988       /* "qutip/cy/sparse_routines.pxi":548
6989  *
6990  *         for jj in range(length):
6991  *             mat.data[row_start+jj] = pairs[jj].data             # <<<<<<<<<<<<<<
6992  *             mat.indices[row_start+jj] = pairs[jj].ind
6993  *
6994  */
6995       __pyx_t_7 = (__pyx_v_pairs[__pyx_v_jj]).data;
6996       (__pyx_v_mat->data[(__pyx_v_row_start + __pyx_v_jj)]) = __pyx_t_7;
6997 
6998       /* "qutip/cy/sparse_routines.pxi":549
6999  *         for jj in range(length):
7000  *             mat.data[row_start+jj] = pairs[jj].data
7001  *             mat.indices[row_start+jj] = pairs[jj].ind             # <<<<<<<<<<<<<<
7002  *
7003  *
7004  */
7005       __pyx_t_8 = (__pyx_v_pairs[__pyx_v_jj]).ind;
7006       (__pyx_v_mat->indices[(__pyx_v_row_start + __pyx_v_jj)]) = __pyx_t_8;
7007     }
7008   }
7009 
7010   /* "qutip/cy/sparse_routines.pxi":526
7011  * @cython.boundscheck(False)
7012  * @cython.wraparound(False)
7013  * cdef void sort_indices(CSR_Matrix * mat):             # <<<<<<<<<<<<<<
7014  *     """
7015  *     Sorts the indices of a CSR_Matrix inplace.
7016  */
7017 
7018   /* function exit code */
7019   goto __pyx_L0;
7020   __pyx_L1_error:;
7021   __Pyx_WriteUnraisable("qutip.cy.br_tensor.sort_indices", __pyx_clineno, __pyx_lineno, __pyx_filename, 1, 0);
7022   __pyx_L0:;
7023   __Pyx_RefNannyFinishContext();
7024 }
7025 
7026 /* "qutip/cy/sparse_routines.pxi":555
7027  * @cython.boundscheck(False)
7028  * @cython.wraparound(False)
7029  * cdef CSR_Matrix CSR_from_scipy(object A):             # <<<<<<<<<<<<<<
7030  *     """
7031  *     Converts a SciPy CSR sparse matrix to a
7032  */
7033 
__pyx_f_5qutip_2cy_9br_tensor_CSR_from_scipy(PyObject * __pyx_v_A)7034 static __pyx_t_5qutip_2cy_14sparse_structs_CSR_Matrix __pyx_f_5qutip_2cy_9br_tensor_CSR_from_scipy(PyObject *__pyx_v_A) {
7035   __Pyx_memviewslice __pyx_v_data = { 0, 0, { 0 }, { 0 }, { 0 } };
7036   __Pyx_memviewslice __pyx_v_ind = { 0, 0, { 0 }, { 0 }, { 0 } };
7037   __Pyx_memviewslice __pyx_v_ptr = { 0, 0, { 0 }, { 0 }, { 0 } };
7038   int __pyx_v_nrows;
7039   int __pyx_v_ncols;
7040   int __pyx_v_nnz;
7041   __pyx_t_5qutip_2cy_14sparse_structs_CSR_Matrix __pyx_v_mat;
7042   __pyx_t_5qutip_2cy_14sparse_structs_CSR_Matrix __pyx_r;
7043   __Pyx_RefNannyDeclarations
7044   PyObject *__pyx_t_1 = NULL;
7045   __Pyx_memviewslice __pyx_t_2 = { 0, 0, { 0 }, { 0 }, { 0 } };
7046   __Pyx_memviewslice __pyx_t_3 = { 0, 0, { 0 }, { 0 }, { 0 } };
7047   PyObject *__pyx_t_4 = NULL;
7048   int __pyx_t_5;
7049   Py_ssize_t __pyx_t_6;
7050   int __pyx_lineno = 0;
7051   const char *__pyx_filename = NULL;
7052   int __pyx_clineno = 0;
7053   __Pyx_RefNannySetupContext("CSR_from_scipy", 0);
7054 
7055   /* "qutip/cy/sparse_routines.pxi":560
7056  *     CSR_Matrix struct.
7057  *     """
7058  *     cdef complex[::1] data = A.data             # <<<<<<<<<<<<<<
7059  *     cdef int[::1] ind = A.indices
7060  *     cdef int[::1] ptr = A.indptr
7061  */
7062   __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)
7063   __Pyx_GOTREF(__pyx_t_1);
7064   __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)
7065   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
7066   __pyx_v_data = __pyx_t_2;
7067   __pyx_t_2.memview = NULL;
7068   __pyx_t_2.data = NULL;
7069 
7070   /* "qutip/cy/sparse_routines.pxi":561
7071  *     """
7072  *     cdef complex[::1] data = A.data
7073  *     cdef int[::1] ind = A.indices             # <<<<<<<<<<<<<<
7074  *     cdef int[::1] ptr = A.indptr
7075  *     cdef int nrows = A.shape[0]
7076  */
7077   __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)
7078   __Pyx_GOTREF(__pyx_t_1);
7079   __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)
7080   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
7081   __pyx_v_ind = __pyx_t_3;
7082   __pyx_t_3.memview = NULL;
7083   __pyx_t_3.data = NULL;
7084 
7085   /* "qutip/cy/sparse_routines.pxi":562
7086  *     cdef complex[::1] data = A.data
7087  *     cdef int[::1] ind = A.indices
7088  *     cdef int[::1] ptr = A.indptr             # <<<<<<<<<<<<<<
7089  *     cdef int nrows = A.shape[0]
7090  *     cdef int ncols = A.shape[1]
7091  */
7092   __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)
7093   __Pyx_GOTREF(__pyx_t_1);
7094   __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)
7095   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
7096   __pyx_v_ptr = __pyx_t_3;
7097   __pyx_t_3.memview = NULL;
7098   __pyx_t_3.data = NULL;
7099 
7100   /* "qutip/cy/sparse_routines.pxi":563
7101  *     cdef int[::1] ind = A.indices
7102  *     cdef int[::1] ptr = A.indptr
7103  *     cdef int nrows = A.shape[0]             # <<<<<<<<<<<<<<
7104  *     cdef int ncols = A.shape[1]
7105  *     cdef int nnz = ptr[nrows]
7106  */
7107   __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)
7108   __Pyx_GOTREF(__pyx_t_1);
7109   __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)
7110   __Pyx_GOTREF(__pyx_t_4);
7111   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
7112   __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)
7113   __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
7114   __pyx_v_nrows = __pyx_t_5;
7115 
7116   /* "qutip/cy/sparse_routines.pxi":564
7117  *     cdef int[::1] ptr = A.indptr
7118  *     cdef int nrows = A.shape[0]
7119  *     cdef int ncols = A.shape[1]             # <<<<<<<<<<<<<<
7120  *     cdef int nnz = ptr[nrows]
7121  *
7122  */
7123   __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)
7124   __Pyx_GOTREF(__pyx_t_4);
7125   __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)
7126   __Pyx_GOTREF(__pyx_t_1);
7127   __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
7128   __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)
7129   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
7130   __pyx_v_ncols = __pyx_t_5;
7131 
7132   /* "qutip/cy/sparse_routines.pxi":565
7133  *     cdef int nrows = A.shape[0]
7134  *     cdef int ncols = A.shape[1]
7135  *     cdef int nnz = ptr[nrows]             # <<<<<<<<<<<<<<
7136  *
7137  *     cdef CSR_Matrix mat
7138  */
7139   __pyx_t_6 = __pyx_v_nrows;
7140   __pyx_v_nnz = (*((int *) ( /* dim=0 */ ((char *) (((int *) __pyx_v_ptr.data) + __pyx_t_6)) )));
7141 
7142   /* "qutip/cy/sparse_routines.pxi":569
7143  *     cdef CSR_Matrix mat
7144  *
7145  *     mat.data = &data[0]             # <<<<<<<<<<<<<<
7146  *     mat.indices = &ind[0]
7147  *     mat.indptr = &ptr[0]
7148  */
7149   __pyx_t_6 = 0;
7150   __pyx_v_mat.data = (&(*((__pyx_t_double_complex *) ( /* dim=0 */ ((char *) (((__pyx_t_double_complex *) __pyx_v_data.data) + __pyx_t_6)) ))));
7151 
7152   /* "qutip/cy/sparse_routines.pxi":570
7153  *
7154  *     mat.data = &data[0]
7155  *     mat.indices = &ind[0]             # <<<<<<<<<<<<<<
7156  *     mat.indptr = &ptr[0]
7157  *     mat.nrows = nrows
7158  */
7159   __pyx_t_6 = 0;
7160   __pyx_v_mat.indices = (&(*((int *) ( /* dim=0 */ ((char *) (((int *) __pyx_v_ind.data) + __pyx_t_6)) ))));
7161 
7162   /* "qutip/cy/sparse_routines.pxi":571
7163  *     mat.data = &data[0]
7164  *     mat.indices = &ind[0]
7165  *     mat.indptr = &ptr[0]             # <<<<<<<<<<<<<<
7166  *     mat.nrows = nrows
7167  *     mat.ncols = ncols
7168  */
7169   __pyx_t_6 = 0;
7170   __pyx_v_mat.indptr = (&(*((int *) ( /* dim=0 */ ((char *) (((int *) __pyx_v_ptr.data) + __pyx_t_6)) ))));
7171 
7172   /* "qutip/cy/sparse_routines.pxi":572
7173  *     mat.indices = &ind[0]
7174  *     mat.indptr = &ptr[0]
7175  *     mat.nrows = nrows             # <<<<<<<<<<<<<<
7176  *     mat.ncols = ncols
7177  *     mat.nnz = nnz
7178  */
7179   __pyx_v_mat.nrows = __pyx_v_nrows;
7180 
7181   /* "qutip/cy/sparse_routines.pxi":573
7182  *     mat.indptr = &ptr[0]
7183  *     mat.nrows = nrows
7184  *     mat.ncols = ncols             # <<<<<<<<<<<<<<
7185  *     mat.nnz = nnz
7186  *     mat.max_length = nnz
7187  */
7188   __pyx_v_mat.ncols = __pyx_v_ncols;
7189 
7190   /* "qutip/cy/sparse_routines.pxi":574
7191  *     mat.nrows = nrows
7192  *     mat.ncols = ncols
7193  *     mat.nnz = nnz             # <<<<<<<<<<<<<<
7194  *     mat.max_length = nnz
7195  *     mat.is_set = 1
7196  */
7197   __pyx_v_mat.nnz = __pyx_v_nnz;
7198 
7199   /* "qutip/cy/sparse_routines.pxi":575
7200  *     mat.ncols = ncols
7201  *     mat.nnz = nnz
7202  *     mat.max_length = nnz             # <<<<<<<<<<<<<<
7203  *     mat.is_set = 1
7204  *     mat.numpy_lock = 1
7205  */
7206   __pyx_v_mat.max_length = __pyx_v_nnz;
7207 
7208   /* "qutip/cy/sparse_routines.pxi":576
7209  *     mat.nnz = nnz
7210  *     mat.max_length = nnz
7211  *     mat.is_set = 1             # <<<<<<<<<<<<<<
7212  *     mat.numpy_lock = 1
7213  *
7214  */
7215   __pyx_v_mat.is_set = 1;
7216 
7217   /* "qutip/cy/sparse_routines.pxi":577
7218  *     mat.max_length = nnz
7219  *     mat.is_set = 1
7220  *     mat.numpy_lock = 1             # <<<<<<<<<<<<<<
7221  *
7222  *     return mat
7223  */
7224   __pyx_v_mat.numpy_lock = 1;
7225 
7226   /* "qutip/cy/sparse_routines.pxi":579
7227  *     mat.numpy_lock = 1
7228  *
7229  *     return mat             # <<<<<<<<<<<<<<
7230  *
7231  *
7232  */
7233   __pyx_r = __pyx_v_mat;
7234   goto __pyx_L0;
7235 
7236   /* "qutip/cy/sparse_routines.pxi":555
7237  * @cython.boundscheck(False)
7238  * @cython.wraparound(False)
7239  * cdef CSR_Matrix CSR_from_scipy(object A):             # <<<<<<<<<<<<<<
7240  *     """
7241  *     Converts a SciPy CSR sparse matrix to a
7242  */
7243 
7244   /* function exit code */
7245   __pyx_L1_error:;
7246   __Pyx_XDECREF(__pyx_t_1);
7247   __PYX_XDEC_MEMVIEW(&__pyx_t_2, 1);
7248   __PYX_XDEC_MEMVIEW(&__pyx_t_3, 1);
7249   __Pyx_XDECREF(__pyx_t_4);
7250   __Pyx_WriteUnraisable("qutip.cy.br_tensor.CSR_from_scipy", __pyx_clineno, __pyx_lineno, __pyx_filename, 1, 0);
7251   __Pyx_pretend_to_initialize(&__pyx_r);
7252   __pyx_L0:;
7253   __PYX_XDEC_MEMVIEW(&__pyx_v_data, 1);
7254   __PYX_XDEC_MEMVIEW(&__pyx_v_ind, 1);
7255   __PYX_XDEC_MEMVIEW(&__pyx_v_ptr, 1);
7256   __Pyx_RefNannyFinishContext();
7257   return __pyx_r;
7258 }
7259 
7260 /* "qutip/cy/sparse_routines.pxi":584
7261  * @cython.boundscheck(False)
7262  * @cython.wraparound(False)
7263  * cdef void CSR_from_scipy_inplace(object A, CSR_Matrix* mat):             # <<<<<<<<<<<<<<
7264  *     """
7265  *     Converts a SciPy CSR sparse matrix to a
7266  */
7267 
__pyx_f_5qutip_2cy_9br_tensor_CSR_from_scipy_inplace(PyObject * __pyx_v_A,__pyx_t_5qutip_2cy_14sparse_structs_CSR_Matrix * __pyx_v_mat)7268 static void __pyx_f_5qutip_2cy_9br_tensor_CSR_from_scipy_inplace(PyObject *__pyx_v_A, __pyx_t_5qutip_2cy_14sparse_structs_CSR_Matrix *__pyx_v_mat) {
7269   __Pyx_memviewslice __pyx_v_data = { 0, 0, { 0 }, { 0 }, { 0 } };
7270   __Pyx_memviewslice __pyx_v_ind = { 0, 0, { 0 }, { 0 }, { 0 } };
7271   __Pyx_memviewslice __pyx_v_ptr = { 0, 0, { 0 }, { 0 }, { 0 } };
7272   int __pyx_v_nrows;
7273   int __pyx_v_ncols;
7274   int __pyx_v_nnz;
7275   __Pyx_RefNannyDeclarations
7276   PyObject *__pyx_t_1 = NULL;
7277   __Pyx_memviewslice __pyx_t_2 = { 0, 0, { 0 }, { 0 }, { 0 } };
7278   __Pyx_memviewslice __pyx_t_3 = { 0, 0, { 0 }, { 0 }, { 0 } };
7279   PyObject *__pyx_t_4 = NULL;
7280   int __pyx_t_5;
7281   Py_ssize_t __pyx_t_6;
7282   int __pyx_lineno = 0;
7283   const char *__pyx_filename = NULL;
7284   int __pyx_clineno = 0;
7285   __Pyx_RefNannySetupContext("CSR_from_scipy_inplace", 0);
7286 
7287   /* "qutip/cy/sparse_routines.pxi":589
7288  *     CSR_Matrix struct.
7289  *     """
7290  *     cdef complex[::1] data = A.data             # <<<<<<<<<<<<<<
7291  *     cdef int[::1] ind = A.indices
7292  *     cdef int[::1] ptr = A.indptr
7293  */
7294   __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)
7295   __Pyx_GOTREF(__pyx_t_1);
7296   __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)
7297   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
7298   __pyx_v_data = __pyx_t_2;
7299   __pyx_t_2.memview = NULL;
7300   __pyx_t_2.data = NULL;
7301 
7302   /* "qutip/cy/sparse_routines.pxi":590
7303  *     """
7304  *     cdef complex[::1] data = A.data
7305  *     cdef int[::1] ind = A.indices             # <<<<<<<<<<<<<<
7306  *     cdef int[::1] ptr = A.indptr
7307  *     cdef int nrows = A.shape[0]
7308  */
7309   __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)
7310   __Pyx_GOTREF(__pyx_t_1);
7311   __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)
7312   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
7313   __pyx_v_ind = __pyx_t_3;
7314   __pyx_t_3.memview = NULL;
7315   __pyx_t_3.data = NULL;
7316 
7317   /* "qutip/cy/sparse_routines.pxi":591
7318  *     cdef complex[::1] data = A.data
7319  *     cdef int[::1] ind = A.indices
7320  *     cdef int[::1] ptr = A.indptr             # <<<<<<<<<<<<<<
7321  *     cdef int nrows = A.shape[0]
7322  *     cdef int ncols = A.shape[1]
7323  */
7324   __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)
7325   __Pyx_GOTREF(__pyx_t_1);
7326   __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)
7327   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
7328   __pyx_v_ptr = __pyx_t_3;
7329   __pyx_t_3.memview = NULL;
7330   __pyx_t_3.data = NULL;
7331 
7332   /* "qutip/cy/sparse_routines.pxi":592
7333  *     cdef int[::1] ind = A.indices
7334  *     cdef int[::1] ptr = A.indptr
7335  *     cdef int nrows = A.shape[0]             # <<<<<<<<<<<<<<
7336  *     cdef int ncols = A.shape[1]
7337  *     cdef int nnz = ptr[nrows]
7338  */
7339   __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)
7340   __Pyx_GOTREF(__pyx_t_1);
7341   __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)
7342   __Pyx_GOTREF(__pyx_t_4);
7343   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
7344   __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)
7345   __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
7346   __pyx_v_nrows = __pyx_t_5;
7347 
7348   /* "qutip/cy/sparse_routines.pxi":593
7349  *     cdef int[::1] ptr = A.indptr
7350  *     cdef int nrows = A.shape[0]
7351  *     cdef int ncols = A.shape[1]             # <<<<<<<<<<<<<<
7352  *     cdef int nnz = ptr[nrows]
7353  *
7354  */
7355   __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)
7356   __Pyx_GOTREF(__pyx_t_4);
7357   __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)
7358   __Pyx_GOTREF(__pyx_t_1);
7359   __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
7360   __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)
7361   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
7362   __pyx_v_ncols = __pyx_t_5;
7363 
7364   /* "qutip/cy/sparse_routines.pxi":594
7365  *     cdef int nrows = A.shape[0]
7366  *     cdef int ncols = A.shape[1]
7367  *     cdef int nnz = ptr[nrows]             # <<<<<<<<<<<<<<
7368  *
7369  *     mat.data = &data[0]
7370  */
7371   __pyx_t_6 = __pyx_v_nrows;
7372   __pyx_v_nnz = (*((int *) ( /* dim=0 */ ((char *) (((int *) __pyx_v_ptr.data) + __pyx_t_6)) )));
7373 
7374   /* "qutip/cy/sparse_routines.pxi":596
7375  *     cdef int nnz = ptr[nrows]
7376  *
7377  *     mat.data = &data[0]             # <<<<<<<<<<<<<<
7378  *     mat.indices = &ind[0]
7379  *     mat.indptr = &ptr[0]
7380  */
7381   __pyx_t_6 = 0;
7382   __pyx_v_mat->data = (&(*((__pyx_t_double_complex *) ( /* dim=0 */ ((char *) (((__pyx_t_double_complex *) __pyx_v_data.data) + __pyx_t_6)) ))));
7383 
7384   /* "qutip/cy/sparse_routines.pxi":597
7385  *
7386  *     mat.data = &data[0]
7387  *     mat.indices = &ind[0]             # <<<<<<<<<<<<<<
7388  *     mat.indptr = &ptr[0]
7389  *     mat.nrows = nrows
7390  */
7391   __pyx_t_6 = 0;
7392   __pyx_v_mat->indices = (&(*((int *) ( /* dim=0 */ ((char *) (((int *) __pyx_v_ind.data) + __pyx_t_6)) ))));
7393 
7394   /* "qutip/cy/sparse_routines.pxi":598
7395  *     mat.data = &data[0]
7396  *     mat.indices = &ind[0]
7397  *     mat.indptr = &ptr[0]             # <<<<<<<<<<<<<<
7398  *     mat.nrows = nrows
7399  *     mat.ncols = ncols
7400  */
7401   __pyx_t_6 = 0;
7402   __pyx_v_mat->indptr = (&(*((int *) ( /* dim=0 */ ((char *) (((int *) __pyx_v_ptr.data) + __pyx_t_6)) ))));
7403 
7404   /* "qutip/cy/sparse_routines.pxi":599
7405  *     mat.indices = &ind[0]
7406  *     mat.indptr = &ptr[0]
7407  *     mat.nrows = nrows             # <<<<<<<<<<<<<<
7408  *     mat.ncols = ncols
7409  *     mat.nnz = nnz
7410  */
7411   __pyx_v_mat->nrows = __pyx_v_nrows;
7412 
7413   /* "qutip/cy/sparse_routines.pxi":600
7414  *     mat.indptr = &ptr[0]
7415  *     mat.nrows = nrows
7416  *     mat.ncols = ncols             # <<<<<<<<<<<<<<
7417  *     mat.nnz = nnz
7418  *     mat.max_length = nnz
7419  */
7420   __pyx_v_mat->ncols = __pyx_v_ncols;
7421 
7422   /* "qutip/cy/sparse_routines.pxi":601
7423  *     mat.nrows = nrows
7424  *     mat.ncols = ncols
7425  *     mat.nnz = nnz             # <<<<<<<<<<<<<<
7426  *     mat.max_length = nnz
7427  *     mat.is_set = 1
7428  */
7429   __pyx_v_mat->nnz = __pyx_v_nnz;
7430 
7431   /* "qutip/cy/sparse_routines.pxi":602
7432  *     mat.ncols = ncols
7433  *     mat.nnz = nnz
7434  *     mat.max_length = nnz             # <<<<<<<<<<<<<<
7435  *     mat.is_set = 1
7436  *     mat.numpy_lock = 1
7437  */
7438   __pyx_v_mat->max_length = __pyx_v_nnz;
7439 
7440   /* "qutip/cy/sparse_routines.pxi":603
7441  *     mat.nnz = nnz
7442  *     mat.max_length = nnz
7443  *     mat.is_set = 1             # <<<<<<<<<<<<<<
7444  *     mat.numpy_lock = 1
7445  *
7446  */
7447   __pyx_v_mat->is_set = 1;
7448 
7449   /* "qutip/cy/sparse_routines.pxi":604
7450  *     mat.max_length = nnz
7451  *     mat.is_set = 1
7452  *     mat.numpy_lock = 1             # <<<<<<<<<<<<<<
7453  *
7454  *
7455  */
7456   __pyx_v_mat->numpy_lock = 1;
7457 
7458   /* "qutip/cy/sparse_routines.pxi":584
7459  * @cython.boundscheck(False)
7460  * @cython.wraparound(False)
7461  * cdef void CSR_from_scipy_inplace(object A, CSR_Matrix* mat):             # <<<<<<<<<<<<<<
7462  *     """
7463  *     Converts a SciPy CSR sparse matrix to a
7464  */
7465 
7466   /* function exit code */
7467   goto __pyx_L0;
7468   __pyx_L1_error:;
7469   __Pyx_XDECREF(__pyx_t_1);
7470   __PYX_XDEC_MEMVIEW(&__pyx_t_2, 1);
7471   __PYX_XDEC_MEMVIEW(&__pyx_t_3, 1);
7472   __Pyx_XDECREF(__pyx_t_4);
7473   __Pyx_WriteUnraisable("qutip.cy.br_tensor.CSR_from_scipy_inplace", __pyx_clineno, __pyx_lineno, __pyx_filename, 1, 0);
7474   __pyx_L0:;
7475   __PYX_XDEC_MEMVIEW(&__pyx_v_data, 1);
7476   __PYX_XDEC_MEMVIEW(&__pyx_v_ind, 1);
7477   __PYX_XDEC_MEMVIEW(&__pyx_v_ptr, 1);
7478   __Pyx_RefNannyFinishContext();
7479 }
7480 
7481 /* "qutip/cy/sparse_routines.pxi":609
7482  * @cython.boundscheck(False)
7483  * @cython.wraparound(False)
7484  * cdef COO_Matrix COO_from_scipy(object A):             # <<<<<<<<<<<<<<
7485  *     """
7486  *     Converts a SciPy COO sparse matrix to a
7487  */
7488 
__pyx_f_5qutip_2cy_9br_tensor_COO_from_scipy(PyObject * __pyx_v_A)7489 static __pyx_t_5qutip_2cy_14sparse_structs_COO_Matrix __pyx_f_5qutip_2cy_9br_tensor_COO_from_scipy(PyObject *__pyx_v_A) {
7490   __Pyx_memviewslice __pyx_v_data = { 0, 0, { 0 }, { 0 }, { 0 } };
7491   __Pyx_memviewslice __pyx_v_rows = { 0, 0, { 0 }, { 0 }, { 0 } };
7492   __Pyx_memviewslice __pyx_v_cols = { 0, 0, { 0 }, { 0 }, { 0 } };
7493   int __pyx_v_nrows;
7494   int __pyx_v_ncols;
7495   int __pyx_v_nnz;
7496   __pyx_t_5qutip_2cy_14sparse_structs_COO_Matrix __pyx_v_mat;
7497   __pyx_t_5qutip_2cy_14sparse_structs_COO_Matrix __pyx_r;
7498   __Pyx_RefNannyDeclarations
7499   PyObject *__pyx_t_1 = NULL;
7500   __Pyx_memviewslice __pyx_t_2 = { 0, 0, { 0 }, { 0 }, { 0 } };
7501   __Pyx_memviewslice __pyx_t_3 = { 0, 0, { 0 }, { 0 }, { 0 } };
7502   PyObject *__pyx_t_4 = NULL;
7503   int __pyx_t_5;
7504   Py_ssize_t __pyx_t_6;
7505   int __pyx_lineno = 0;
7506   const char *__pyx_filename = NULL;
7507   int __pyx_clineno = 0;
7508   __Pyx_RefNannySetupContext("COO_from_scipy", 0);
7509 
7510   /* "qutip/cy/sparse_routines.pxi":614
7511  *     COO_Matrix struct.
7512  *     """
7513  *     cdef complex[::1] data = A.data             # <<<<<<<<<<<<<<
7514  *     cdef int[::1] rows = A.row
7515  *     cdef int[::1] cols = A.col
7516  */
7517   __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)
7518   __Pyx_GOTREF(__pyx_t_1);
7519   __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)
7520   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
7521   __pyx_v_data = __pyx_t_2;
7522   __pyx_t_2.memview = NULL;
7523   __pyx_t_2.data = NULL;
7524 
7525   /* "qutip/cy/sparse_routines.pxi":615
7526  *     """
7527  *     cdef complex[::1] data = A.data
7528  *     cdef int[::1] rows = A.row             # <<<<<<<<<<<<<<
7529  *     cdef int[::1] cols = A.col
7530  *     cdef int nrows = A.shape[0]
7531  */
7532   __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)
7533   __Pyx_GOTREF(__pyx_t_1);
7534   __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)
7535   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
7536   __pyx_v_rows = __pyx_t_3;
7537   __pyx_t_3.memview = NULL;
7538   __pyx_t_3.data = NULL;
7539 
7540   /* "qutip/cy/sparse_routines.pxi":616
7541  *     cdef complex[::1] data = A.data
7542  *     cdef int[::1] rows = A.row
7543  *     cdef int[::1] cols = A.col             # <<<<<<<<<<<<<<
7544  *     cdef int nrows = A.shape[0]
7545  *     cdef int ncols = A.shape[1]
7546  */
7547   __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)
7548   __Pyx_GOTREF(__pyx_t_1);
7549   __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)
7550   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
7551   __pyx_v_cols = __pyx_t_3;
7552   __pyx_t_3.memview = NULL;
7553   __pyx_t_3.data = NULL;
7554 
7555   /* "qutip/cy/sparse_routines.pxi":617
7556  *     cdef int[::1] rows = A.row
7557  *     cdef int[::1] cols = A.col
7558  *     cdef int nrows = A.shape[0]             # <<<<<<<<<<<<<<
7559  *     cdef int ncols = A.shape[1]
7560  *     cdef int nnz = data.shape[0]
7561  */
7562   __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)
7563   __Pyx_GOTREF(__pyx_t_1);
7564   __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)
7565   __Pyx_GOTREF(__pyx_t_4);
7566   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
7567   __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)
7568   __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
7569   __pyx_v_nrows = __pyx_t_5;
7570 
7571   /* "qutip/cy/sparse_routines.pxi":618
7572  *     cdef int[::1] cols = A.col
7573  *     cdef int nrows = A.shape[0]
7574  *     cdef int ncols = A.shape[1]             # <<<<<<<<<<<<<<
7575  *     cdef int nnz = data.shape[0]
7576  *
7577  */
7578   __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)
7579   __Pyx_GOTREF(__pyx_t_4);
7580   __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)
7581   __Pyx_GOTREF(__pyx_t_1);
7582   __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
7583   __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)
7584   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
7585   __pyx_v_ncols = __pyx_t_5;
7586 
7587   /* "qutip/cy/sparse_routines.pxi":619
7588  *     cdef int nrows = A.shape[0]
7589  *     cdef int ncols = A.shape[1]
7590  *     cdef int nnz = data.shape[0]             # <<<<<<<<<<<<<<
7591  *
7592  *     cdef COO_Matrix mat
7593  */
7594   __pyx_v_nnz = (__pyx_v_data.shape[0]);
7595 
7596   /* "qutip/cy/sparse_routines.pxi":622
7597  *
7598  *     cdef COO_Matrix mat
7599  *     mat.data = &data[0]             # <<<<<<<<<<<<<<
7600  *     mat.rows = &rows[0]
7601  *     mat.cols = &cols[0]
7602  */
7603   __pyx_t_6 = 0;
7604   __pyx_v_mat.data = (&(*((__pyx_t_double_complex *) ( /* dim=0 */ ((char *) (((__pyx_t_double_complex *) __pyx_v_data.data) + __pyx_t_6)) ))));
7605 
7606   /* "qutip/cy/sparse_routines.pxi":623
7607  *     cdef COO_Matrix mat
7608  *     mat.data = &data[0]
7609  *     mat.rows = &rows[0]             # <<<<<<<<<<<<<<
7610  *     mat.cols = &cols[0]
7611  *     mat.nrows = nrows
7612  */
7613   __pyx_t_6 = 0;
7614   __pyx_v_mat.rows = (&(*((int *) ( /* dim=0 */ ((char *) (((int *) __pyx_v_rows.data) + __pyx_t_6)) ))));
7615 
7616   /* "qutip/cy/sparse_routines.pxi":624
7617  *     mat.data = &data[0]
7618  *     mat.rows = &rows[0]
7619  *     mat.cols = &cols[0]             # <<<<<<<<<<<<<<
7620  *     mat.nrows = nrows
7621  *     mat.ncols = ncols
7622  */
7623   __pyx_t_6 = 0;
7624   __pyx_v_mat.cols = (&(*((int *) ( /* dim=0 */ ((char *) (((int *) __pyx_v_cols.data) + __pyx_t_6)) ))));
7625 
7626   /* "qutip/cy/sparse_routines.pxi":625
7627  *     mat.rows = &rows[0]
7628  *     mat.cols = &cols[0]
7629  *     mat.nrows = nrows             # <<<<<<<<<<<<<<
7630  *     mat.ncols = ncols
7631  *     mat.nnz = nnz
7632  */
7633   __pyx_v_mat.nrows = __pyx_v_nrows;
7634 
7635   /* "qutip/cy/sparse_routines.pxi":626
7636  *     mat.cols = &cols[0]
7637  *     mat.nrows = nrows
7638  *     mat.ncols = ncols             # <<<<<<<<<<<<<<
7639  *     mat.nnz = nnz
7640  *     mat.max_length = nnz
7641  */
7642   __pyx_v_mat.ncols = __pyx_v_ncols;
7643 
7644   /* "qutip/cy/sparse_routines.pxi":627
7645  *     mat.nrows = nrows
7646  *     mat.ncols = ncols
7647  *     mat.nnz = nnz             # <<<<<<<<<<<<<<
7648  *     mat.max_length = nnz
7649  *     mat.is_set = 1
7650  */
7651   __pyx_v_mat.nnz = __pyx_v_nnz;
7652 
7653   /* "qutip/cy/sparse_routines.pxi":628
7654  *     mat.ncols = ncols
7655  *     mat.nnz = nnz
7656  *     mat.max_length = nnz             # <<<<<<<<<<<<<<
7657  *     mat.is_set = 1
7658  *     mat.numpy_lock = 1
7659  */
7660   __pyx_v_mat.max_length = __pyx_v_nnz;
7661 
7662   /* "qutip/cy/sparse_routines.pxi":629
7663  *     mat.nnz = nnz
7664  *     mat.max_length = nnz
7665  *     mat.is_set = 1             # <<<<<<<<<<<<<<
7666  *     mat.numpy_lock = 1
7667  *
7668  */
7669   __pyx_v_mat.is_set = 1;
7670 
7671   /* "qutip/cy/sparse_routines.pxi":630
7672  *     mat.max_length = nnz
7673  *     mat.is_set = 1
7674  *     mat.numpy_lock = 1             # <<<<<<<<<<<<<<
7675  *
7676  *     return mat
7677  */
7678   __pyx_v_mat.numpy_lock = 1;
7679 
7680   /* "qutip/cy/sparse_routines.pxi":632
7681  *     mat.numpy_lock = 1
7682  *
7683  *     return mat             # <<<<<<<<<<<<<<
7684  *
7685  *
7686  */
7687   __pyx_r = __pyx_v_mat;
7688   goto __pyx_L0;
7689 
7690   /* "qutip/cy/sparse_routines.pxi":609
7691  * @cython.boundscheck(False)
7692  * @cython.wraparound(False)
7693  * cdef COO_Matrix COO_from_scipy(object A):             # <<<<<<<<<<<<<<
7694  *     """
7695  *     Converts a SciPy COO sparse matrix to a
7696  */
7697 
7698   /* function exit code */
7699   __pyx_L1_error:;
7700   __Pyx_XDECREF(__pyx_t_1);
7701   __PYX_XDEC_MEMVIEW(&__pyx_t_2, 1);
7702   __PYX_XDEC_MEMVIEW(&__pyx_t_3, 1);
7703   __Pyx_XDECREF(__pyx_t_4);
7704   __Pyx_WriteUnraisable("qutip.cy.br_tensor.COO_from_scipy", __pyx_clineno, __pyx_lineno, __pyx_filename, 1, 0);
7705   __Pyx_pretend_to_initialize(&__pyx_r);
7706   __pyx_L0:;
7707   __PYX_XDEC_MEMVIEW(&__pyx_v_data, 1);
7708   __PYX_XDEC_MEMVIEW(&__pyx_v_rows, 1);
7709   __PYX_XDEC_MEMVIEW(&__pyx_v_cols, 1);
7710   __Pyx_RefNannyFinishContext();
7711   return __pyx_r;
7712 }
7713 
7714 /* "qutip/cy/sparse_routines.pxi":637
7715  * @cython.boundscheck(False)
7716  * @cython.wraparound(False)
7717  * cdef void identity_CSR(CSR_Matrix * mat, unsigned int nrows):             # <<<<<<<<<<<<<<
7718  *     cdef size_t kk
7719  *     init_CSR(mat, nrows, nrows, nrows, 0, 0)
7720  */
7721 
__pyx_f_5qutip_2cy_9br_tensor_identity_CSR(__pyx_t_5qutip_2cy_14sparse_structs_CSR_Matrix * __pyx_v_mat,unsigned int __pyx_v_nrows)7722 static void __pyx_f_5qutip_2cy_9br_tensor_identity_CSR(__pyx_t_5qutip_2cy_14sparse_structs_CSR_Matrix *__pyx_v_mat, unsigned int __pyx_v_nrows) {
7723   size_t __pyx_v_kk;
7724   __Pyx_RefNannyDeclarations
7725   struct __pyx_opt_args_5qutip_2cy_9br_tensor_init_CSR __pyx_t_1;
7726   unsigned int __pyx_t_2;
7727   unsigned int __pyx_t_3;
7728   size_t __pyx_t_4;
7729   __Pyx_RefNannySetupContext("identity_CSR", 0);
7730 
7731   /* "qutip/cy/sparse_routines.pxi":639
7732  * cdef void identity_CSR(CSR_Matrix * mat, unsigned int nrows):
7733  *     cdef size_t kk
7734  *     init_CSR(mat, nrows, nrows, nrows, 0, 0)             # <<<<<<<<<<<<<<
7735  *     for kk in range(nrows):
7736  *         mat.data[kk] = 1
7737  */
7738   __pyx_t_1.__pyx_n = 3;
7739   __pyx_t_1.ncols = __pyx_v_nrows;
7740   __pyx_t_1.max_length = 0;
7741   __pyx_t_1.init_zeros = 0;
7742   __pyx_f_5qutip_2cy_9br_tensor_init_CSR(__pyx_v_mat, __pyx_v_nrows, __pyx_v_nrows, &__pyx_t_1);
7743 
7744   /* "qutip/cy/sparse_routines.pxi":640
7745  *     cdef size_t kk
7746  *     init_CSR(mat, nrows, nrows, nrows, 0, 0)
7747  *     for kk in range(nrows):             # <<<<<<<<<<<<<<
7748  *         mat.data[kk] = 1
7749  *         mat.indices[kk] = kk
7750  */
7751   __pyx_t_2 = __pyx_v_nrows;
7752   __pyx_t_3 = __pyx_t_2;
7753   for (__pyx_t_4 = 0; __pyx_t_4 < __pyx_t_3; __pyx_t_4+=1) {
7754     __pyx_v_kk = __pyx_t_4;
7755 
7756     /* "qutip/cy/sparse_routines.pxi":641
7757  *     init_CSR(mat, nrows, nrows, nrows, 0, 0)
7758  *     for kk in range(nrows):
7759  *         mat.data[kk] = 1             # <<<<<<<<<<<<<<
7760  *         mat.indices[kk] = kk
7761  *         mat.indptr[kk] = kk
7762  */
7763     (__pyx_v_mat->data[__pyx_v_kk]) = __pyx_t_double_complex_from_parts(1, 0);
7764 
7765     /* "qutip/cy/sparse_routines.pxi":642
7766  *     for kk in range(nrows):
7767  *         mat.data[kk] = 1
7768  *         mat.indices[kk] = kk             # <<<<<<<<<<<<<<
7769  *         mat.indptr[kk] = kk
7770  *     mat.indptr[nrows] = nrows
7771  */
7772     (__pyx_v_mat->indices[__pyx_v_kk]) = __pyx_v_kk;
7773 
7774     /* "qutip/cy/sparse_routines.pxi":643
7775  *         mat.data[kk] = 1
7776  *         mat.indices[kk] = kk
7777  *         mat.indptr[kk] = kk             # <<<<<<<<<<<<<<
7778  *     mat.indptr[nrows] = nrows
7779  */
7780     (__pyx_v_mat->indptr[__pyx_v_kk]) = __pyx_v_kk;
7781   }
7782 
7783   /* "qutip/cy/sparse_routines.pxi":644
7784  *         mat.indices[kk] = kk
7785  *         mat.indptr[kk] = kk
7786  *     mat.indptr[nrows] = nrows             # <<<<<<<<<<<<<<
7787  */
7788   (__pyx_v_mat->indptr[__pyx_v_nrows]) = __pyx_v_nrows;
7789 
7790   /* "qutip/cy/sparse_routines.pxi":637
7791  * @cython.boundscheck(False)
7792  * @cython.wraparound(False)
7793  * cdef void identity_CSR(CSR_Matrix * mat, unsigned int nrows):             # <<<<<<<<<<<<<<
7794  *     cdef size_t kk
7795  *     init_CSR(mat, nrows, nrows, nrows, 0, 0)
7796  */
7797 
7798   /* function exit code */
7799   __Pyx_RefNannyFinishContext();
7800 }
7801 
7802 /* "qutip/cy/br_tensor.pyx":50
7803  * @cython.boundscheck(False)
7804  * @cython.wraparound(False)
7805  * def _br_term(complex[::1,:] A, complex[::1,:] evecs,             # <<<<<<<<<<<<<<
7806  *                 double[:,::1] skew, double dw_min, object spectral,
7807  *                 unsigned int nrows, int use_secular, double sec_cutoff,
7808  */
7809 
7810 /* Python wrapper */
7811 static PyObject *__pyx_pw_5qutip_2cy_9br_tensor_1_br_term(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
7812 static PyMethodDef __pyx_mdef_5qutip_2cy_9br_tensor_1_br_term = {"_br_term", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_5qutip_2cy_9br_tensor_1_br_term, METH_VARARGS|METH_KEYWORDS, 0};
__pyx_pw_5qutip_2cy_9br_tensor_1_br_term(PyObject * __pyx_self,PyObject * __pyx_args,PyObject * __pyx_kwds)7813 static PyObject *__pyx_pw_5qutip_2cy_9br_tensor_1_br_term(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
7814   __Pyx_memviewslice __pyx_v_A = { 0, 0, { 0 }, { 0 }, { 0 } };
7815   __Pyx_memviewslice __pyx_v_evecs = { 0, 0, { 0 }, { 0 }, { 0 } };
7816   __Pyx_memviewslice __pyx_v_skew = { 0, 0, { 0 }, { 0 }, { 0 } };
7817   double __pyx_v_dw_min;
7818   PyObject *__pyx_v_spectral = 0;
7819   unsigned int __pyx_v_nrows;
7820   int __pyx_v_use_secular;
7821   double __pyx_v_sec_cutoff;
7822   double __pyx_v_atol;
7823   int __pyx_lineno = 0;
7824   const char *__pyx_filename = NULL;
7825   int __pyx_clineno = 0;
7826   PyObject *__pyx_r = 0;
7827   __Pyx_RefNannyDeclarations
7828   __Pyx_RefNannySetupContext("_br_term (wrapper)", 0);
7829   {
7830     static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_A,&__pyx_n_s_evecs,&__pyx_n_s_skew,&__pyx_n_s_dw_min,&__pyx_n_s_spectral,&__pyx_n_s_nrows,&__pyx_n_s_use_secular,&__pyx_n_s_sec_cutoff,&__pyx_n_s_atol,0};
7831     PyObject* values[9] = {0,0,0,0,0,0,0,0,0};
7832     if (unlikely(__pyx_kwds)) {
7833       Py_ssize_t kw_args;
7834       const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
7835       switch (pos_args) {
7836         case  9: values[8] = PyTuple_GET_ITEM(__pyx_args, 8);
7837         CYTHON_FALLTHROUGH;
7838         case  8: values[7] = PyTuple_GET_ITEM(__pyx_args, 7);
7839         CYTHON_FALLTHROUGH;
7840         case  7: values[6] = PyTuple_GET_ITEM(__pyx_args, 6);
7841         CYTHON_FALLTHROUGH;
7842         case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
7843         CYTHON_FALLTHROUGH;
7844         case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
7845         CYTHON_FALLTHROUGH;
7846         case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
7847         CYTHON_FALLTHROUGH;
7848         case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
7849         CYTHON_FALLTHROUGH;
7850         case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
7851         CYTHON_FALLTHROUGH;
7852         case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
7853         CYTHON_FALLTHROUGH;
7854         case  0: break;
7855         default: goto __pyx_L5_argtuple_error;
7856       }
7857       kw_args = PyDict_Size(__pyx_kwds);
7858       switch (pos_args) {
7859         case  0:
7860         if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_A)) != 0)) kw_args--;
7861         else goto __pyx_L5_argtuple_error;
7862         CYTHON_FALLTHROUGH;
7863         case  1:
7864         if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_evecs)) != 0)) kw_args--;
7865         else {
7866           __Pyx_RaiseArgtupleInvalid("_br_term", 1, 9, 9, 1); __PYX_ERR(1, 50, __pyx_L3_error)
7867         }
7868         CYTHON_FALLTHROUGH;
7869         case  2:
7870         if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_skew)) != 0)) kw_args--;
7871         else {
7872           __Pyx_RaiseArgtupleInvalid("_br_term", 1, 9, 9, 2); __PYX_ERR(1, 50, __pyx_L3_error)
7873         }
7874         CYTHON_FALLTHROUGH;
7875         case  3:
7876         if (likely((values[3] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_dw_min)) != 0)) kw_args--;
7877         else {
7878           __Pyx_RaiseArgtupleInvalid("_br_term", 1, 9, 9, 3); __PYX_ERR(1, 50, __pyx_L3_error)
7879         }
7880         CYTHON_FALLTHROUGH;
7881         case  4:
7882         if (likely((values[4] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_spectral)) != 0)) kw_args--;
7883         else {
7884           __Pyx_RaiseArgtupleInvalid("_br_term", 1, 9, 9, 4); __PYX_ERR(1, 50, __pyx_L3_error)
7885         }
7886         CYTHON_FALLTHROUGH;
7887         case  5:
7888         if (likely((values[5] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_nrows)) != 0)) kw_args--;
7889         else {
7890           __Pyx_RaiseArgtupleInvalid("_br_term", 1, 9, 9, 5); __PYX_ERR(1, 50, __pyx_L3_error)
7891         }
7892         CYTHON_FALLTHROUGH;
7893         case  6:
7894         if (likely((values[6] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_use_secular)) != 0)) kw_args--;
7895         else {
7896           __Pyx_RaiseArgtupleInvalid("_br_term", 1, 9, 9, 6); __PYX_ERR(1, 50, __pyx_L3_error)
7897         }
7898         CYTHON_FALLTHROUGH;
7899         case  7:
7900         if (likely((values[7] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_sec_cutoff)) != 0)) kw_args--;
7901         else {
7902           __Pyx_RaiseArgtupleInvalid("_br_term", 1, 9, 9, 7); __PYX_ERR(1, 50, __pyx_L3_error)
7903         }
7904         CYTHON_FALLTHROUGH;
7905         case  8:
7906         if (likely((values[8] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_atol)) != 0)) kw_args--;
7907         else {
7908           __Pyx_RaiseArgtupleInvalid("_br_term", 1, 9, 9, 8); __PYX_ERR(1, 50, __pyx_L3_error)
7909         }
7910       }
7911       if (unlikely(kw_args > 0)) {
7912         if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_br_term") < 0)) __PYX_ERR(1, 50, __pyx_L3_error)
7913       }
7914     } else if (PyTuple_GET_SIZE(__pyx_args) != 9) {
7915       goto __pyx_L5_argtuple_error;
7916     } else {
7917       values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
7918       values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
7919       values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
7920       values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
7921       values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
7922       values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
7923       values[6] = PyTuple_GET_ITEM(__pyx_args, 6);
7924       values[7] = PyTuple_GET_ITEM(__pyx_args, 7);
7925       values[8] = PyTuple_GET_ITEM(__pyx_args, 8);
7926     }
7927     __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, 50, __pyx_L3_error)
7928     __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, 50, __pyx_L3_error)
7929     __pyx_v_skew = __Pyx_PyObject_to_MemoryviewSlice_d_dc_double(values[2], PyBUF_WRITABLE); if (unlikely(!__pyx_v_skew.memview)) __PYX_ERR(1, 51, __pyx_L3_error)
7930     __pyx_v_dw_min = __pyx_PyFloat_AsDouble(values[3]); if (unlikely((__pyx_v_dw_min == (double)-1) && PyErr_Occurred())) __PYX_ERR(1, 51, __pyx_L3_error)
7931     __pyx_v_spectral = values[4];
7932     __pyx_v_nrows = __Pyx_PyInt_As_unsigned_int(values[5]); if (unlikely((__pyx_v_nrows == (unsigned int)-1) && PyErr_Occurred())) __PYX_ERR(1, 52, __pyx_L3_error)
7933     __pyx_v_use_secular = __Pyx_PyInt_As_int(values[6]); if (unlikely((__pyx_v_use_secular == (int)-1) && PyErr_Occurred())) __PYX_ERR(1, 52, __pyx_L3_error)
7934     __pyx_v_sec_cutoff = __pyx_PyFloat_AsDouble(values[7]); if (unlikely((__pyx_v_sec_cutoff == (double)-1) && PyErr_Occurred())) __PYX_ERR(1, 52, __pyx_L3_error)
7935     __pyx_v_atol = __pyx_PyFloat_AsDouble(values[8]); if (unlikely((__pyx_v_atol == (double)-1) && PyErr_Occurred())) __PYX_ERR(1, 53, __pyx_L3_error)
7936   }
7937   goto __pyx_L4_argument_unpacking_done;
7938   __pyx_L5_argtuple_error:;
7939   __Pyx_RaiseArgtupleInvalid("_br_term", 1, 9, 9, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(1, 50, __pyx_L3_error)
7940   __pyx_L3_error:;
7941   __Pyx_AddTraceback("qutip.cy.br_tensor._br_term", __pyx_clineno, __pyx_lineno, __pyx_filename);
7942   __Pyx_RefNannyFinishContext();
7943   return NULL;
7944   __pyx_L4_argument_unpacking_done:;
7945   __pyx_r = __pyx_pf_5qutip_2cy_9br_tensor__br_term(__pyx_self, __pyx_v_A, __pyx_v_evecs, __pyx_v_skew, __pyx_v_dw_min, __pyx_v_spectral, __pyx_v_nrows, __pyx_v_use_secular, __pyx_v_sec_cutoff, __pyx_v_atol);
7946 
7947   /* function exit code */
7948   __Pyx_RefNannyFinishContext();
7949   return __pyx_r;
7950 }
7951 
__pyx_pf_5qutip_2cy_9br_tensor__br_term(CYTHON_UNUSED PyObject * __pyx_self,__Pyx_memviewslice __pyx_v_A,__Pyx_memviewslice __pyx_v_evecs,__Pyx_memviewslice __pyx_v_skew,double __pyx_v_dw_min,PyObject * __pyx_v_spectral,unsigned int __pyx_v_nrows,int __pyx_v_use_secular,double __pyx_v_sec_cutoff,double __pyx_v_atol)7952 static PyObject *__pyx_pf_5qutip_2cy_9br_tensor__br_term(CYTHON_UNUSED PyObject *__pyx_self, __Pyx_memviewslice __pyx_v_A, __Pyx_memviewslice __pyx_v_evecs, __Pyx_memviewslice __pyx_v_skew, double __pyx_v_dw_min, PyObject *__pyx_v_spectral, unsigned int __pyx_v_nrows, int __pyx_v_use_secular, double __pyx_v_sec_cutoff, double __pyx_v_atol) {
7953   size_t __pyx_v_kk;
7954   size_t __pyx_v_I;
7955   size_t __pyx_v_J;
7956   int __pyx_v_ab[2];
7957   int __pyx_v_cd[2];
7958   __Pyx_memviewslice __pyx_v_A_eig = { 0, 0, { 0 }, { 0 }, { 0 } };
7959   __pyx_t_double_complex __pyx_v_elem;
7960   __pyx_t_double_complex __pyx_v_ac_elem;
7961   __pyx_t_double_complex __pyx_v_bd_elem;
7962   std::vector<int>  __pyx_v_coo_rows;
7963   std::vector<int>  __pyx_v_coo_cols;
7964   std::vector<__pyx_t_double_complex>  __pyx_v_coo_data;
7965   unsigned int __pyx_v_nnz;
7966   __pyx_t_5qutip_2cy_14sparse_structs_COO_Matrix __pyx_v_coo;
7967   __pyx_t_5qutip_2cy_14sparse_structs_CSR_Matrix __pyx_v_csr;
7968   PyObject *__pyx_r = NULL;
7969   __Pyx_RefNannyDeclarations
7970   __Pyx_memviewslice __pyx_t_1 = { 0, 0, { 0 }, { 0 }, { 0 } };
7971   long __pyx_t_2;
7972   long __pyx_t_3;
7973   size_t __pyx_t_4;
7974   long __pyx_t_5;
7975   long __pyx_t_6;
7976   size_t __pyx_t_7;
7977   int __pyx_t_8;
7978   int __pyx_t_9;
7979   Py_ssize_t __pyx_t_10;
7980   Py_ssize_t __pyx_t_11;
7981   Py_ssize_t __pyx_t_12;
7982   Py_ssize_t __pyx_t_13;
7983   PyObject *__pyx_t_14 = NULL;
7984   PyObject *__pyx_t_15 = NULL;
7985   PyObject *__pyx_t_16 = NULL;
7986   PyObject *__pyx_t_17 = NULL;
7987   PyObject *__pyx_t_18 = NULL;
7988   PyObject *__pyx_t_19 = NULL;
7989   __pyx_t_double_complex __pyx_t_20;
7990   unsigned int __pyx_t_21;
7991   unsigned int __pyx_t_22;
7992   size_t __pyx_t_23;
7993   size_t __pyx_t_24;
7994   size_t __pyx_t_25;
7995   int __pyx_lineno = 0;
7996   const char *__pyx_filename = NULL;
7997   int __pyx_clineno = 0;
7998   __Pyx_RefNannySetupContext("_br_term", 0);
7999 
8000   /* "qutip/cy/br_tensor.pyx":58
8001  *     cdef size_t I, J # vector index variables
8002  *     cdef int[2] ab, cd #matrix indexing variables
8003  *     cdef complex[::1,:] A_eig = dense_to_eigbasis(A, evecs, nrows, atol)             # <<<<<<<<<<<<<<
8004  *     cdef complex elem, ac_elem, bd_elem
8005  *     cdef vector[int] coo_rows, coo_cols
8006  */
8007   __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, 58, __pyx_L1_error)
8008   __pyx_v_A_eig = __pyx_t_1;
8009   __pyx_t_1.memview = NULL;
8010   __pyx_t_1.data = NULL;
8011 
8012   /* "qutip/cy/br_tensor.pyx":66
8013  *     cdef CSR_Matrix csr
8014  *
8015  *     for I in range(nrows**2):             # <<<<<<<<<<<<<<
8016  *         vec2mat_index(nrows, I, ab)
8017  *         for J in range(nrows**2):
8018  */
8019   __pyx_t_2 = __Pyx_pow_long(((long)__pyx_v_nrows), 2);
8020   __pyx_t_3 = __pyx_t_2;
8021   for (__pyx_t_4 = 0; __pyx_t_4 < __pyx_t_3; __pyx_t_4+=1) {
8022     __pyx_v_I = __pyx_t_4;
8023 
8024     /* "qutip/cy/br_tensor.pyx":67
8025  *
8026  *     for I in range(nrows**2):
8027  *         vec2mat_index(nrows, I, ab)             # <<<<<<<<<<<<<<
8028  *         for J in range(nrows**2):
8029  *             vec2mat_index(nrows, J, cd)
8030  */
8031     __pyx_f_5qutip_2cy_7brtools_vec2mat_index(__pyx_v_nrows, __pyx_v_I, __pyx_v_ab);
8032 
8033     /* "qutip/cy/br_tensor.pyx":68
8034  *     for I in range(nrows**2):
8035  *         vec2mat_index(nrows, I, ab)
8036  *         for J in range(nrows**2):             # <<<<<<<<<<<<<<
8037  *             vec2mat_index(nrows, J, cd)
8038  *
8039  */
8040     __pyx_t_5 = __Pyx_pow_long(((long)__pyx_v_nrows), 2);
8041     __pyx_t_6 = __pyx_t_5;
8042     for (__pyx_t_7 = 0; __pyx_t_7 < __pyx_t_6; __pyx_t_7+=1) {
8043       __pyx_v_J = __pyx_t_7;
8044 
8045       /* "qutip/cy/br_tensor.pyx":69
8046  *         vec2mat_index(nrows, I, ab)
8047  *         for J in range(nrows**2):
8048  *             vec2mat_index(nrows, J, cd)             # <<<<<<<<<<<<<<
8049  *
8050  *             if (not use_secular) or (fabs(skew[ab[0],ab[1]]-skew[cd[0],cd[1]]) < (dw_min * sec_cutoff)):
8051  */
8052       __pyx_f_5qutip_2cy_7brtools_vec2mat_index(__pyx_v_nrows, __pyx_v_J, __pyx_v_cd);
8053 
8054       /* "qutip/cy/br_tensor.pyx":71
8055  *             vec2mat_index(nrows, J, cd)
8056  *
8057  *             if (not use_secular) or (fabs(skew[ab[0],ab[1]]-skew[cd[0],cd[1]]) < (dw_min * sec_cutoff)):             # <<<<<<<<<<<<<<
8058  *                 elem = (A_eig[ab[0],cd[0]]*A_eig[cd[1],ab[1]]) * 0.5
8059  *                 elem *= (spectral(skew[cd[0],ab[0]])+spectral(skew[cd[1],ab[1]]))
8060  */
8061       __pyx_t_9 = ((!(__pyx_v_use_secular != 0)) != 0);
8062       if (!__pyx_t_9) {
8063       } else {
8064         __pyx_t_8 = __pyx_t_9;
8065         goto __pyx_L8_bool_binop_done;
8066       }
8067       __pyx_t_10 = (__pyx_v_ab[0]);
8068       __pyx_t_11 = (__pyx_v_ab[1]);
8069       __pyx_t_12 = (__pyx_v_cd[0]);
8070       __pyx_t_13 = (__pyx_v_cd[1]);
8071       __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);
8072       __pyx_t_8 = __pyx_t_9;
8073       __pyx_L8_bool_binop_done:;
8074       if (__pyx_t_8) {
8075 
8076         /* "qutip/cy/br_tensor.pyx":72
8077  *
8078  *             if (not use_secular) or (fabs(skew[ab[0],ab[1]]-skew[cd[0],cd[1]]) < (dw_min * sec_cutoff)):
8079  *                 elem = (A_eig[ab[0],cd[0]]*A_eig[cd[1],ab[1]]) * 0.5             # <<<<<<<<<<<<<<
8080  *                 elem *= (spectral(skew[cd[0],ab[0]])+spectral(skew[cd[1],ab[1]]))
8081  *
8082  */
8083         __pyx_t_13 = (__pyx_v_ab[0]);
8084         __pyx_t_12 = (__pyx_v_cd[0]);
8085         __pyx_t_11 = (__pyx_v_cd[1]);
8086         __pyx_t_10 = (__pyx_v_ab[1]);
8087         __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));
8088 
8089         /* "qutip/cy/br_tensor.pyx":73
8090  *             if (not use_secular) or (fabs(skew[ab[0],ab[1]]-skew[cd[0],cd[1]]) < (dw_min * sec_cutoff)):
8091  *                 elem = (A_eig[ab[0],cd[0]]*A_eig[cd[1],ab[1]]) * 0.5
8092  *                 elem *= (spectral(skew[cd[0],ab[0]])+spectral(skew[cd[1],ab[1]]))             # <<<<<<<<<<<<<<
8093  *
8094  *                 if (ab[0]==cd[0]):
8095  */
8096         __pyx_t_14 = __pyx_PyComplex_FromComplex(__pyx_v_elem); if (unlikely(!__pyx_t_14)) __PYX_ERR(1, 73, __pyx_L1_error)
8097         __Pyx_GOTREF(__pyx_t_14);
8098         __pyx_t_10 = (__pyx_v_cd[0]);
8099         __pyx_t_11 = (__pyx_v_ab[0]);
8100         __pyx_t_16 = PyFloat_FromDouble((*((double *) ( /* dim=1 */ ((char *) (((double *) ( /* dim=0 */ (__pyx_v_skew.data + __pyx_t_10 * __pyx_v_skew.strides[0]) )) + __pyx_t_11)) )))); if (unlikely(!__pyx_t_16)) __PYX_ERR(1, 73, __pyx_L1_error)
8101         __Pyx_GOTREF(__pyx_t_16);
8102         __Pyx_INCREF(__pyx_v_spectral);
8103         __pyx_t_17 = __pyx_v_spectral; __pyx_t_18 = NULL;
8104         if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_17))) {
8105           __pyx_t_18 = PyMethod_GET_SELF(__pyx_t_17);
8106           if (likely(__pyx_t_18)) {
8107             PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_17);
8108             __Pyx_INCREF(__pyx_t_18);
8109             __Pyx_INCREF(function);
8110             __Pyx_DECREF_SET(__pyx_t_17, function);
8111           }
8112         }
8113         __pyx_t_15 = (__pyx_t_18) ? __Pyx_PyObject_Call2Args(__pyx_t_17, __pyx_t_18, __pyx_t_16) : __Pyx_PyObject_CallOneArg(__pyx_t_17, __pyx_t_16);
8114         __Pyx_XDECREF(__pyx_t_18); __pyx_t_18 = 0;
8115         __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;
8116         if (unlikely(!__pyx_t_15)) __PYX_ERR(1, 73, __pyx_L1_error)
8117         __Pyx_GOTREF(__pyx_t_15);
8118         __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
8119         __pyx_t_11 = (__pyx_v_cd[1]);
8120         __pyx_t_10 = (__pyx_v_ab[1]);
8121         __pyx_t_16 = PyFloat_FromDouble((*((double *) ( /* dim=1 */ ((char *) (((double *) ( /* dim=0 */ (__pyx_v_skew.data + __pyx_t_11 * __pyx_v_skew.strides[0]) )) + __pyx_t_10)) )))); if (unlikely(!__pyx_t_16)) __PYX_ERR(1, 73, __pyx_L1_error)
8122         __Pyx_GOTREF(__pyx_t_16);
8123         __Pyx_INCREF(__pyx_v_spectral);
8124         __pyx_t_18 = __pyx_v_spectral; __pyx_t_19 = NULL;
8125         if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_18))) {
8126           __pyx_t_19 = PyMethod_GET_SELF(__pyx_t_18);
8127           if (likely(__pyx_t_19)) {
8128             PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_18);
8129             __Pyx_INCREF(__pyx_t_19);
8130             __Pyx_INCREF(function);
8131             __Pyx_DECREF_SET(__pyx_t_18, function);
8132           }
8133         }
8134         __pyx_t_17 = (__pyx_t_19) ? __Pyx_PyObject_Call2Args(__pyx_t_18, __pyx_t_19, __pyx_t_16) : __Pyx_PyObject_CallOneArg(__pyx_t_18, __pyx_t_16);
8135         __Pyx_XDECREF(__pyx_t_19); __pyx_t_19 = 0;
8136         __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;
8137         if (unlikely(!__pyx_t_17)) __PYX_ERR(1, 73, __pyx_L1_error)
8138         __Pyx_GOTREF(__pyx_t_17);
8139         __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
8140         __pyx_t_18 = PyNumber_Add(__pyx_t_15, __pyx_t_17); if (unlikely(!__pyx_t_18)) __PYX_ERR(1, 73, __pyx_L1_error)
8141         __Pyx_GOTREF(__pyx_t_18);
8142         __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
8143         __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
8144         __pyx_t_17 = PyNumber_InPlaceMultiply(__pyx_t_14, __pyx_t_18); if (unlikely(!__pyx_t_17)) __PYX_ERR(1, 73, __pyx_L1_error)
8145         __Pyx_GOTREF(__pyx_t_17);
8146         __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
8147         __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
8148         __pyx_t_20 = __Pyx_PyComplex_As___pyx_t_double_complex(__pyx_t_17); if (unlikely(PyErr_Occurred())) __PYX_ERR(1, 73, __pyx_L1_error)
8149         __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
8150         __pyx_v_elem = __pyx_t_20;
8151 
8152         /* "qutip/cy/br_tensor.pyx":75
8153  *                 elem *= (spectral(skew[cd[0],ab[0]])+spectral(skew[cd[1],ab[1]]))
8154  *
8155  *                 if (ab[0]==cd[0]):             # <<<<<<<<<<<<<<
8156  *                     ac_elem = 0
8157  *                     for kk in range(nrows):
8158  */
8159         __pyx_t_8 = (((__pyx_v_ab[0]) == (__pyx_v_cd[0])) != 0);
8160         if (__pyx_t_8) {
8161 
8162           /* "qutip/cy/br_tensor.pyx":76
8163  *
8164  *                 if (ab[0]==cd[0]):
8165  *                     ac_elem = 0             # <<<<<<<<<<<<<<
8166  *                     for kk in range(nrows):
8167  *                         ac_elem += A_eig[cd[1],kk]*A_eig[kk,ab[1]] * spectral(skew[cd[1],kk])
8168  */
8169           __pyx_v_ac_elem = __pyx_t_double_complex_from_parts(0, 0);
8170 
8171           /* "qutip/cy/br_tensor.pyx":77
8172  *                 if (ab[0]==cd[0]):
8173  *                     ac_elem = 0
8174  *                     for kk in range(nrows):             # <<<<<<<<<<<<<<
8175  *                         ac_elem += A_eig[cd[1],kk]*A_eig[kk,ab[1]] * spectral(skew[cd[1],kk])
8176  *                     elem -= 0.5*ac_elem
8177  */
8178           __pyx_t_21 = __pyx_v_nrows;
8179           __pyx_t_22 = __pyx_t_21;
8180           for (__pyx_t_23 = 0; __pyx_t_23 < __pyx_t_22; __pyx_t_23+=1) {
8181             __pyx_v_kk = __pyx_t_23;
8182 
8183             /* "qutip/cy/br_tensor.pyx":78
8184  *                     ac_elem = 0
8185  *                     for kk in range(nrows):
8186  *                         ac_elem += A_eig[cd[1],kk]*A_eig[kk,ab[1]] * spectral(skew[cd[1],kk])             # <<<<<<<<<<<<<<
8187  *                     elem -= 0.5*ac_elem
8188  *
8189  */
8190             __pyx_t_17 = __pyx_PyComplex_FromComplex(__pyx_v_ac_elem); if (unlikely(!__pyx_t_17)) __PYX_ERR(1, 78, __pyx_L1_error)
8191             __Pyx_GOTREF(__pyx_t_17);
8192             __pyx_t_10 = (__pyx_v_cd[1]);
8193             __pyx_t_24 = __pyx_v_kk;
8194             __pyx_t_25 = __pyx_v_kk;
8195             __pyx_t_11 = (__pyx_v_ab[1]);
8196             __pyx_t_20 = __Pyx_c_prod_double((*((__pyx_t_double_complex *) ( /* dim=1 */ (( /* dim=0 */ ((char *) (((__pyx_t_double_complex *) __pyx_v_A_eig.data) + __pyx_t_10)) ) + __pyx_t_24 * __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_25)) ) + __pyx_t_11 * __pyx_v_A_eig.strides[1]) ))));
8197             __pyx_t_18 = __pyx_PyComplex_FromComplex(__pyx_t_20); if (unlikely(!__pyx_t_18)) __PYX_ERR(1, 78, __pyx_L1_error)
8198             __Pyx_GOTREF(__pyx_t_18);
8199             __pyx_t_11 = (__pyx_v_cd[1]);
8200             __pyx_t_25 = __pyx_v_kk;
8201             __pyx_t_15 = PyFloat_FromDouble((*((double *) ( /* dim=1 */ ((char *) (((double *) ( /* dim=0 */ (__pyx_v_skew.data + __pyx_t_11 * __pyx_v_skew.strides[0]) )) + __pyx_t_25)) )))); if (unlikely(!__pyx_t_15)) __PYX_ERR(1, 78, __pyx_L1_error)
8202             __Pyx_GOTREF(__pyx_t_15);
8203             __Pyx_INCREF(__pyx_v_spectral);
8204             __pyx_t_16 = __pyx_v_spectral; __pyx_t_19 = NULL;
8205             if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_16))) {
8206               __pyx_t_19 = PyMethod_GET_SELF(__pyx_t_16);
8207               if (likely(__pyx_t_19)) {
8208                 PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_16);
8209                 __Pyx_INCREF(__pyx_t_19);
8210                 __Pyx_INCREF(function);
8211                 __Pyx_DECREF_SET(__pyx_t_16, function);
8212               }
8213             }
8214             __pyx_t_14 = (__pyx_t_19) ? __Pyx_PyObject_Call2Args(__pyx_t_16, __pyx_t_19, __pyx_t_15) : __Pyx_PyObject_CallOneArg(__pyx_t_16, __pyx_t_15);
8215             __Pyx_XDECREF(__pyx_t_19); __pyx_t_19 = 0;
8216             __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
8217             if (unlikely(!__pyx_t_14)) __PYX_ERR(1, 78, __pyx_L1_error)
8218             __Pyx_GOTREF(__pyx_t_14);
8219             __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;
8220             __pyx_t_16 = PyNumber_Multiply(__pyx_t_18, __pyx_t_14); if (unlikely(!__pyx_t_16)) __PYX_ERR(1, 78, __pyx_L1_error)
8221             __Pyx_GOTREF(__pyx_t_16);
8222             __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
8223             __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
8224             __pyx_t_14 = PyNumber_InPlaceAdd(__pyx_t_17, __pyx_t_16); if (unlikely(!__pyx_t_14)) __PYX_ERR(1, 78, __pyx_L1_error)
8225             __Pyx_GOTREF(__pyx_t_14);
8226             __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
8227             __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;
8228             __pyx_t_20 = __Pyx_PyComplex_As___pyx_t_double_complex(__pyx_t_14); if (unlikely(PyErr_Occurred())) __PYX_ERR(1, 78, __pyx_L1_error)
8229             __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
8230             __pyx_v_ac_elem = __pyx_t_20;
8231           }
8232 
8233           /* "qutip/cy/br_tensor.pyx":79
8234  *                     for kk in range(nrows):
8235  *                         ac_elem += A_eig[cd[1],kk]*A_eig[kk,ab[1]] * spectral(skew[cd[1],kk])
8236  *                     elem -= 0.5*ac_elem             # <<<<<<<<<<<<<<
8237  *
8238  *                 if (ab[1]==cd[1]):
8239  */
8240           __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));
8241 
8242           /* "qutip/cy/br_tensor.pyx":75
8243  *                 elem *= (spectral(skew[cd[0],ab[0]])+spectral(skew[cd[1],ab[1]]))
8244  *
8245  *                 if (ab[0]==cd[0]):             # <<<<<<<<<<<<<<
8246  *                     ac_elem = 0
8247  *                     for kk in range(nrows):
8248  */
8249         }
8250 
8251         /* "qutip/cy/br_tensor.pyx":81
8252  *                     elem -= 0.5*ac_elem
8253  *
8254  *                 if (ab[1]==cd[1]):             # <<<<<<<<<<<<<<
8255  *                     bd_elem = 0
8256  *                     for kk in range(nrows):
8257  */
8258         __pyx_t_8 = (((__pyx_v_ab[1]) == (__pyx_v_cd[1])) != 0);
8259         if (__pyx_t_8) {
8260 
8261           /* "qutip/cy/br_tensor.pyx":82
8262  *
8263  *                 if (ab[1]==cd[1]):
8264  *                     bd_elem = 0             # <<<<<<<<<<<<<<
8265  *                     for kk in range(nrows):
8266  *                         bd_elem += A_eig[ab[0],kk]*A_eig[kk,cd[0]] * spectral(skew[cd[0],kk])
8267  */
8268           __pyx_v_bd_elem = __pyx_t_double_complex_from_parts(0, 0);
8269 
8270           /* "qutip/cy/br_tensor.pyx":83
8271  *                 if (ab[1]==cd[1]):
8272  *                     bd_elem = 0
8273  *                     for kk in range(nrows):             # <<<<<<<<<<<<<<
8274  *                         bd_elem += A_eig[ab[0],kk]*A_eig[kk,cd[0]] * spectral(skew[cd[0],kk])
8275  *                     elem -= 0.5*bd_elem
8276  */
8277           __pyx_t_21 = __pyx_v_nrows;
8278           __pyx_t_22 = __pyx_t_21;
8279           for (__pyx_t_23 = 0; __pyx_t_23 < __pyx_t_22; __pyx_t_23+=1) {
8280             __pyx_v_kk = __pyx_t_23;
8281 
8282             /* "qutip/cy/br_tensor.pyx":84
8283  *                     bd_elem = 0
8284  *                     for kk in range(nrows):
8285  *                         bd_elem += A_eig[ab[0],kk]*A_eig[kk,cd[0]] * spectral(skew[cd[0],kk])             # <<<<<<<<<<<<<<
8286  *                     elem -= 0.5*bd_elem
8287  *
8288  */
8289             __pyx_t_14 = __pyx_PyComplex_FromComplex(__pyx_v_bd_elem); if (unlikely(!__pyx_t_14)) __PYX_ERR(1, 84, __pyx_L1_error)
8290             __Pyx_GOTREF(__pyx_t_14);
8291             __pyx_t_11 = (__pyx_v_ab[0]);
8292             __pyx_t_25 = __pyx_v_kk;
8293             __pyx_t_24 = __pyx_v_kk;
8294             __pyx_t_10 = (__pyx_v_cd[0]);
8295             __pyx_t_20 = __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_25 * __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_24)) ) + __pyx_t_10 * __pyx_v_A_eig.strides[1]) ))));
8296             __pyx_t_16 = __pyx_PyComplex_FromComplex(__pyx_t_20); if (unlikely(!__pyx_t_16)) __PYX_ERR(1, 84, __pyx_L1_error)
8297             __Pyx_GOTREF(__pyx_t_16);
8298             __pyx_t_10 = (__pyx_v_cd[0]);
8299             __pyx_t_24 = __pyx_v_kk;
8300             __pyx_t_18 = PyFloat_FromDouble((*((double *) ( /* dim=1 */ ((char *) (((double *) ( /* dim=0 */ (__pyx_v_skew.data + __pyx_t_10 * __pyx_v_skew.strides[0]) )) + __pyx_t_24)) )))); if (unlikely(!__pyx_t_18)) __PYX_ERR(1, 84, __pyx_L1_error)
8301             __Pyx_GOTREF(__pyx_t_18);
8302             __Pyx_INCREF(__pyx_v_spectral);
8303             __pyx_t_15 = __pyx_v_spectral; __pyx_t_19 = NULL;
8304             if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_15))) {
8305               __pyx_t_19 = PyMethod_GET_SELF(__pyx_t_15);
8306               if (likely(__pyx_t_19)) {
8307                 PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_15);
8308                 __Pyx_INCREF(__pyx_t_19);
8309                 __Pyx_INCREF(function);
8310                 __Pyx_DECREF_SET(__pyx_t_15, function);
8311               }
8312             }
8313             __pyx_t_17 = (__pyx_t_19) ? __Pyx_PyObject_Call2Args(__pyx_t_15, __pyx_t_19, __pyx_t_18) : __Pyx_PyObject_CallOneArg(__pyx_t_15, __pyx_t_18);
8314             __Pyx_XDECREF(__pyx_t_19); __pyx_t_19 = 0;
8315             __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
8316             if (unlikely(!__pyx_t_17)) __PYX_ERR(1, 84, __pyx_L1_error)
8317             __Pyx_GOTREF(__pyx_t_17);
8318             __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
8319             __pyx_t_15 = PyNumber_Multiply(__pyx_t_16, __pyx_t_17); if (unlikely(!__pyx_t_15)) __PYX_ERR(1, 84, __pyx_L1_error)
8320             __Pyx_GOTREF(__pyx_t_15);
8321             __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;
8322             __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
8323             __pyx_t_17 = PyNumber_InPlaceAdd(__pyx_t_14, __pyx_t_15); if (unlikely(!__pyx_t_17)) __PYX_ERR(1, 84, __pyx_L1_error)
8324             __Pyx_GOTREF(__pyx_t_17);
8325             __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
8326             __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
8327             __pyx_t_20 = __Pyx_PyComplex_As___pyx_t_double_complex(__pyx_t_17); if (unlikely(PyErr_Occurred())) __PYX_ERR(1, 84, __pyx_L1_error)
8328             __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
8329             __pyx_v_bd_elem = __pyx_t_20;
8330           }
8331 
8332           /* "qutip/cy/br_tensor.pyx":85
8333  *                     for kk in range(nrows):
8334  *                         bd_elem += A_eig[ab[0],kk]*A_eig[kk,cd[0]] * spectral(skew[cd[0],kk])
8335  *                     elem -= 0.5*bd_elem             # <<<<<<<<<<<<<<
8336  *
8337  *                 if (elem != 0):
8338  */
8339           __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));
8340 
8341           /* "qutip/cy/br_tensor.pyx":81
8342  *                     elem -= 0.5*ac_elem
8343  *
8344  *                 if (ab[1]==cd[1]):             # <<<<<<<<<<<<<<
8345  *                     bd_elem = 0
8346  *                     for kk in range(nrows):
8347  */
8348         }
8349 
8350         /* "qutip/cy/br_tensor.pyx":87
8351  *                     elem -= 0.5*bd_elem
8352  *
8353  *                 if (elem != 0):             # <<<<<<<<<<<<<<
8354  *                     coo_rows.push_back(I)
8355  *                     coo_cols.push_back(J)
8356  */
8357         __pyx_t_8 = ((!__Pyx_c_eq_double(__pyx_v_elem, __pyx_t_double_complex_from_parts(0, 0))) != 0);
8358         if (__pyx_t_8) {
8359 
8360           /* "qutip/cy/br_tensor.pyx":88
8361  *
8362  *                 if (elem != 0):
8363  *                     coo_rows.push_back(I)             # <<<<<<<<<<<<<<
8364  *                     coo_cols.push_back(J)
8365  *                     coo_data.push_back(elem)
8366  */
8367           try {
8368             __pyx_v_coo_rows.push_back(__pyx_v_I);
8369           } catch(...) {
8370             __Pyx_CppExn2PyErr();
8371             __PYX_ERR(1, 88, __pyx_L1_error)
8372           }
8373 
8374           /* "qutip/cy/br_tensor.pyx":89
8375  *                 if (elem != 0):
8376  *                     coo_rows.push_back(I)
8377  *                     coo_cols.push_back(J)             # <<<<<<<<<<<<<<
8378  *                     coo_data.push_back(elem)
8379  *
8380  */
8381           try {
8382             __pyx_v_coo_cols.push_back(__pyx_v_J);
8383           } catch(...) {
8384             __Pyx_CppExn2PyErr();
8385             __PYX_ERR(1, 89, __pyx_L1_error)
8386           }
8387 
8388           /* "qutip/cy/br_tensor.pyx":90
8389  *                     coo_rows.push_back(I)
8390  *                     coo_cols.push_back(J)
8391  *                     coo_data.push_back(elem)             # <<<<<<<<<<<<<<
8392  *
8393  *     PyDataMem_FREE(&A_eig[0,0])
8394  */
8395           try {
8396             __pyx_v_coo_data.push_back(__pyx_v_elem);
8397           } catch(...) {
8398             __Pyx_CppExn2PyErr();
8399             __PYX_ERR(1, 90, __pyx_L1_error)
8400           }
8401 
8402           /* "qutip/cy/br_tensor.pyx":87
8403  *                     elem -= 0.5*bd_elem
8404  *
8405  *                 if (elem != 0):             # <<<<<<<<<<<<<<
8406  *                     coo_rows.push_back(I)
8407  *                     coo_cols.push_back(J)
8408  */
8409         }
8410 
8411         /* "qutip/cy/br_tensor.pyx":71
8412  *             vec2mat_index(nrows, J, cd)
8413  *
8414  *             if (not use_secular) or (fabs(skew[ab[0],ab[1]]-skew[cd[0],cd[1]]) < (dw_min * sec_cutoff)):             # <<<<<<<<<<<<<<
8415  *                 elem = (A_eig[ab[0],cd[0]]*A_eig[cd[1],ab[1]]) * 0.5
8416  *                 elem *= (spectral(skew[cd[0],ab[0]])+spectral(skew[cd[1],ab[1]]))
8417  */
8418       }
8419     }
8420   }
8421 
8422   /* "qutip/cy/br_tensor.pyx":92
8423  *                     coo_data.push_back(elem)
8424  *
8425  *     PyDataMem_FREE(&A_eig[0,0])             # <<<<<<<<<<<<<<
8426  *
8427  *     #Number of elements in BR tensor
8428  */
8429   __pyx_t_10 = 0;
8430   __pyx_t_11 = 0;
8431   PyDataMem_FREE((&(*((__pyx_t_double_complex *) ( /* dim=1 */ (( /* dim=0 */ ((char *) (((__pyx_t_double_complex *) __pyx_v_A_eig.data) + __pyx_t_10)) ) + __pyx_t_11 * __pyx_v_A_eig.strides[1]) )))));
8432 
8433   /* "qutip/cy/br_tensor.pyx":95
8434  *
8435  *     #Number of elements in BR tensor
8436  *     nnz = coo_rows.size()             # <<<<<<<<<<<<<<
8437  *     coo.nnz = nnz
8438  *     coo.rows = coo_rows.data()
8439  */
8440   __pyx_v_nnz = __pyx_v_coo_rows.size();
8441 
8442   /* "qutip/cy/br_tensor.pyx":96
8443  *     #Number of elements in BR tensor
8444  *     nnz = coo_rows.size()
8445  *     coo.nnz = nnz             # <<<<<<<<<<<<<<
8446  *     coo.rows = coo_rows.data()
8447  *     coo.cols = coo_cols.data()
8448  */
8449   __pyx_v_coo.nnz = __pyx_v_nnz;
8450 
8451   /* "qutip/cy/br_tensor.pyx":97
8452  *     nnz = coo_rows.size()
8453  *     coo.nnz = nnz
8454  *     coo.rows = coo_rows.data()             # <<<<<<<<<<<<<<
8455  *     coo.cols = coo_cols.data()
8456  *     coo.data = coo_data.data()
8457  */
8458   __pyx_v_coo.rows = __pyx_v_coo_rows.data();
8459 
8460   /* "qutip/cy/br_tensor.pyx":98
8461  *     coo.nnz = nnz
8462  *     coo.rows = coo_rows.data()
8463  *     coo.cols = coo_cols.data()             # <<<<<<<<<<<<<<
8464  *     coo.data = coo_data.data()
8465  *     coo.nrows = nrows**2
8466  */
8467   __pyx_v_coo.cols = __pyx_v_coo_cols.data();
8468 
8469   /* "qutip/cy/br_tensor.pyx":99
8470  *     coo.rows = coo_rows.data()
8471  *     coo.cols = coo_cols.data()
8472  *     coo.data = coo_data.data()             # <<<<<<<<<<<<<<
8473  *     coo.nrows = nrows**2
8474  *     coo.ncols = nrows**2
8475  */
8476   __pyx_v_coo.data = __pyx_v_coo_data.data();
8477 
8478   /* "qutip/cy/br_tensor.pyx":100
8479  *     coo.cols = coo_cols.data()
8480  *     coo.data = coo_data.data()
8481  *     coo.nrows = nrows**2             # <<<<<<<<<<<<<<
8482  *     coo.ncols = nrows**2
8483  *     coo.is_set = 1
8484  */
8485   __pyx_v_coo.nrows = __Pyx_pow_long(((long)__pyx_v_nrows), 2);
8486 
8487   /* "qutip/cy/br_tensor.pyx":101
8488  *     coo.data = coo_data.data()
8489  *     coo.nrows = nrows**2
8490  *     coo.ncols = nrows**2             # <<<<<<<<<<<<<<
8491  *     coo.is_set = 1
8492  *     coo.max_length = nnz
8493  */
8494   __pyx_v_coo.ncols = __Pyx_pow_long(((long)__pyx_v_nrows), 2);
8495 
8496   /* "qutip/cy/br_tensor.pyx":102
8497  *     coo.nrows = nrows**2
8498  *     coo.ncols = nrows**2
8499  *     coo.is_set = 1             # <<<<<<<<<<<<<<
8500  *     coo.max_length = nnz
8501  *     COO_to_CSR(&csr, &coo)
8502  */
8503   __pyx_v_coo.is_set = 1;
8504 
8505   /* "qutip/cy/br_tensor.pyx":103
8506  *     coo.ncols = nrows**2
8507  *     coo.is_set = 1
8508  *     coo.max_length = nnz             # <<<<<<<<<<<<<<
8509  *     COO_to_CSR(&csr, &coo)
8510  *     return CSR_to_scipy(&csr)
8511  */
8512   __pyx_v_coo.max_length = __pyx_v_nnz;
8513 
8514   /* "qutip/cy/br_tensor.pyx":104
8515  *     coo.is_set = 1
8516  *     coo.max_length = nnz
8517  *     COO_to_CSR(&csr, &coo)             # <<<<<<<<<<<<<<
8518  *     return CSR_to_scipy(&csr)
8519  *
8520  */
8521   __pyx_f_5qutip_2cy_9br_tensor_COO_to_CSR((&__pyx_v_csr), (&__pyx_v_coo));
8522 
8523   /* "qutip/cy/br_tensor.pyx":105
8524  *     coo.max_length = nnz
8525  *     COO_to_CSR(&csr, &coo)
8526  *     return CSR_to_scipy(&csr)             # <<<<<<<<<<<<<<
8527  *
8528  *
8529  */
8530   __Pyx_XDECREF(__pyx_r);
8531   __pyx_t_17 = __pyx_f_5qutip_2cy_9br_tensor_CSR_to_scipy((&__pyx_v_csr)); if (unlikely(!__pyx_t_17)) __PYX_ERR(1, 105, __pyx_L1_error)
8532   __Pyx_GOTREF(__pyx_t_17);
8533   __pyx_r = __pyx_t_17;
8534   __pyx_t_17 = 0;
8535   goto __pyx_L0;
8536 
8537   /* "qutip/cy/br_tensor.pyx":50
8538  * @cython.boundscheck(False)
8539  * @cython.wraparound(False)
8540  * def _br_term(complex[::1,:] A, complex[::1,:] evecs,             # <<<<<<<<<<<<<<
8541  *                 double[:,::1] skew, double dw_min, object spectral,
8542  *                 unsigned int nrows, int use_secular, double sec_cutoff,
8543  */
8544 
8545   /* function exit code */
8546   __pyx_L1_error:;
8547   __PYX_XDEC_MEMVIEW(&__pyx_t_1, 1);
8548   __Pyx_XDECREF(__pyx_t_14);
8549   __Pyx_XDECREF(__pyx_t_15);
8550   __Pyx_XDECREF(__pyx_t_16);
8551   __Pyx_XDECREF(__pyx_t_17);
8552   __Pyx_XDECREF(__pyx_t_18);
8553   __Pyx_XDECREF(__pyx_t_19);
8554   __Pyx_AddTraceback("qutip.cy.br_tensor._br_term", __pyx_clineno, __pyx_lineno, __pyx_filename);
8555   __pyx_r = NULL;
8556   __pyx_L0:;
8557   __PYX_XDEC_MEMVIEW(&__pyx_v_A_eig, 1);
8558   __PYX_XDEC_MEMVIEW(&__pyx_v_A, 1);
8559   __PYX_XDEC_MEMVIEW(&__pyx_v_evecs, 1);
8560   __PYX_XDEC_MEMVIEW(&__pyx_v_skew, 1);
8561   __Pyx_XGIVEREF(__pyx_r);
8562   __Pyx_RefNannyFinishContext();
8563   return __pyx_r;
8564 }
8565 
8566 /* "qutip/cy/br_tensor.pyx":110
8567  * @cython.boundscheck(False)
8568  * @cython.wraparound(False)
8569  * def bloch_redfield_tensor(object H, list a_ops, spectra_cb=None,             # <<<<<<<<<<<<<<
8570  *                  list c_ops=[], bool use_secular=True,
8571  *                  double sec_cutoff=0.1,
8572  */
8573 
8574 /* Python wrapper */
8575 static PyObject *__pyx_pw_5qutip_2cy_9br_tensor_3bloch_redfield_tensor(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
8576 static char __pyx_doc_5qutip_2cy_9br_tensor_2bloch_redfield_tensor[] = "\n     Calculates the time-independent Bloch-Redfield tensor for a system given\n     a set of operators and corresponding spectral functions that describes the\n     system's couplingto its environment.\n\n     Parameters\n     ----------\n\n     H : :class:`qutip.qobj`\n         System Hamiltonian.\n\n     a_ops : list\n         Nested list of system operators that couple to the environment,\n         and the corresponding bath spectra represented as Python\n         functions.\n\n     spectra_cb : list\n         Depreciated.\n\n     c_ops : list\n         List of system collapse operators.\n\n     use_secular : bool {True, False}\n         Flag that indicates if the secular approximation should\n         be used.\n\n     sec_cutoff : float {0.1}\n         Threshold for secular approximation.\n\n    atol : float {qutip.settings.atol}\n        Threshold for removing small parameters.\n\n     Returns\n     -------\n\n     R, kets: :class:`qutip.Qobj`, list of :class:`qutip.Qobj`\n\n         R is the Bloch-Redfield tensor and kets is a list eigenstates of the\n         Hamiltonian.\n\n     ";
8577 static PyMethodDef __pyx_mdef_5qutip_2cy_9br_tensor_3bloch_redfield_tensor = {"bloch_redfield_tensor", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_5qutip_2cy_9br_tensor_3bloch_redfield_tensor, METH_VARARGS|METH_KEYWORDS, __pyx_doc_5qutip_2cy_9br_tensor_2bloch_redfield_tensor};
__pyx_pw_5qutip_2cy_9br_tensor_3bloch_redfield_tensor(PyObject * __pyx_self,PyObject * __pyx_args,PyObject * __pyx_kwds)8578 static PyObject *__pyx_pw_5qutip_2cy_9br_tensor_3bloch_redfield_tensor(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
8579   PyObject *__pyx_v_H = 0;
8580   PyObject *__pyx_v_a_ops = 0;
8581   PyObject *__pyx_v_spectra_cb = 0;
8582   PyObject *__pyx_v_c_ops = 0;
8583   bool __pyx_v_use_secular;
8584   double __pyx_v_sec_cutoff;
8585   double __pyx_v_atol;
8586   int __pyx_lineno = 0;
8587   const char *__pyx_filename = NULL;
8588   int __pyx_clineno = 0;
8589   PyObject *__pyx_r = 0;
8590   __Pyx_RefNannyDeclarations
8591   __Pyx_RefNannySetupContext("bloch_redfield_tensor (wrapper)", 0);
8592   {
8593     static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_H,&__pyx_n_s_a_ops,&__pyx_n_s_spectra_cb,&__pyx_n_s_c_ops,&__pyx_n_s_use_secular,&__pyx_n_s_sec_cutoff,&__pyx_n_s_atol,0};
8594     PyObject* values[7] = {0,0,0,0,0,0,0};
8595     values[2] = ((PyObject *)Py_None);
8596     values[3] = __pyx_k__12;
8597     if (unlikely(__pyx_kwds)) {
8598       Py_ssize_t kw_args;
8599       const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
8600       switch (pos_args) {
8601         case  7: values[6] = PyTuple_GET_ITEM(__pyx_args, 6);
8602         CYTHON_FALLTHROUGH;
8603         case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
8604         CYTHON_FALLTHROUGH;
8605         case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
8606         CYTHON_FALLTHROUGH;
8607         case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
8608         CYTHON_FALLTHROUGH;
8609         case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
8610         CYTHON_FALLTHROUGH;
8611         case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
8612         CYTHON_FALLTHROUGH;
8613         case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
8614         CYTHON_FALLTHROUGH;
8615         case  0: break;
8616         default: goto __pyx_L5_argtuple_error;
8617       }
8618       kw_args = PyDict_Size(__pyx_kwds);
8619       switch (pos_args) {
8620         case  0:
8621         if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_H)) != 0)) kw_args--;
8622         else goto __pyx_L5_argtuple_error;
8623         CYTHON_FALLTHROUGH;
8624         case  1:
8625         if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_a_ops)) != 0)) kw_args--;
8626         else {
8627           __Pyx_RaiseArgtupleInvalid("bloch_redfield_tensor", 0, 2, 7, 1); __PYX_ERR(1, 110, __pyx_L3_error)
8628         }
8629         CYTHON_FALLTHROUGH;
8630         case  2:
8631         if (kw_args > 0) {
8632           PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_spectra_cb);
8633           if (value) { values[2] = value; kw_args--; }
8634         }
8635         CYTHON_FALLTHROUGH;
8636         case  3:
8637         if (kw_args > 0) {
8638           PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_c_ops);
8639           if (value) { values[3] = value; kw_args--; }
8640         }
8641         CYTHON_FALLTHROUGH;
8642         case  4:
8643         if (kw_args > 0) {
8644           PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_use_secular);
8645           if (value) { values[4] = value; kw_args--; }
8646         }
8647         CYTHON_FALLTHROUGH;
8648         case  5:
8649         if (kw_args > 0) {
8650           PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_sec_cutoff);
8651           if (value) { values[5] = value; kw_args--; }
8652         }
8653         CYTHON_FALLTHROUGH;
8654         case  6:
8655         if (kw_args > 0) {
8656           PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_atol);
8657           if (value) { values[6] = value; kw_args--; }
8658         }
8659       }
8660       if (unlikely(kw_args > 0)) {
8661         if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "bloch_redfield_tensor") < 0)) __PYX_ERR(1, 110, __pyx_L3_error)
8662       }
8663     } else {
8664       switch (PyTuple_GET_SIZE(__pyx_args)) {
8665         case  7: values[6] = PyTuple_GET_ITEM(__pyx_args, 6);
8666         CYTHON_FALLTHROUGH;
8667         case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
8668         CYTHON_FALLTHROUGH;
8669         case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
8670         CYTHON_FALLTHROUGH;
8671         case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
8672         CYTHON_FALLTHROUGH;
8673         case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
8674         CYTHON_FALLTHROUGH;
8675         case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
8676         values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
8677         break;
8678         default: goto __pyx_L5_argtuple_error;
8679       }
8680     }
8681     __pyx_v_H = values[0];
8682     __pyx_v_a_ops = ((PyObject*)values[1]);
8683     __pyx_v_spectra_cb = values[2];
8684     __pyx_v_c_ops = ((PyObject*)values[3]);
8685     if (values[4]) {
8686       __pyx_v_use_secular = __Pyx_PyObject_IsTrue(values[4]); if (unlikely((__pyx_v_use_secular == ((bool)-1)) && PyErr_Occurred())) __PYX_ERR(1, 111, __pyx_L3_error)
8687     } else {
8688 
8689       /* "qutip/cy/br_tensor.pyx":111
8690  * @cython.wraparound(False)
8691  * def bloch_redfield_tensor(object H, list a_ops, spectra_cb=None,
8692  *                  list c_ops=[], bool use_secular=True,             # <<<<<<<<<<<<<<
8693  *                  double sec_cutoff=0.1,
8694  *                  double atol = qset.atol):
8695  */
8696       __pyx_v_use_secular = ((bool)1);
8697     }
8698     if (values[5]) {
8699       __pyx_v_sec_cutoff = __pyx_PyFloat_AsDouble(values[5]); if (unlikely((__pyx_v_sec_cutoff == (double)-1) && PyErr_Occurred())) __PYX_ERR(1, 112, __pyx_L3_error)
8700     } else {
8701       __pyx_v_sec_cutoff = ((double)0.1);
8702     }
8703     if (values[6]) {
8704       __pyx_v_atol = __pyx_PyFloat_AsDouble(values[6]); if (unlikely((__pyx_v_atol == (double)-1) && PyErr_Occurred())) __PYX_ERR(1, 113, __pyx_L3_error)
8705     } else {
8706       __pyx_v_atol = __pyx_k__13;
8707     }
8708   }
8709   goto __pyx_L4_argument_unpacking_done;
8710   __pyx_L5_argtuple_error:;
8711   __Pyx_RaiseArgtupleInvalid("bloch_redfield_tensor", 0, 2, 7, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(1, 110, __pyx_L3_error)
8712   __pyx_L3_error:;
8713   __Pyx_AddTraceback("qutip.cy.br_tensor.bloch_redfield_tensor", __pyx_clineno, __pyx_lineno, __pyx_filename);
8714   __Pyx_RefNannyFinishContext();
8715   return NULL;
8716   __pyx_L4_argument_unpacking_done:;
8717   if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_a_ops), (&PyList_Type), 1, "a_ops", 1))) __PYX_ERR(1, 110, __pyx_L1_error)
8718   if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_c_ops), (&PyList_Type), 1, "c_ops", 1))) __PYX_ERR(1, 111, __pyx_L1_error)
8719   __pyx_r = __pyx_pf_5qutip_2cy_9br_tensor_2bloch_redfield_tensor(__pyx_self, __pyx_v_H, __pyx_v_a_ops, __pyx_v_spectra_cb, __pyx_v_c_ops, __pyx_v_use_secular, __pyx_v_sec_cutoff, __pyx_v_atol);
8720 
8721   /* "qutip/cy/br_tensor.pyx":110
8722  * @cython.boundscheck(False)
8723  * @cython.wraparound(False)
8724  * def bloch_redfield_tensor(object H, list a_ops, spectra_cb=None,             # <<<<<<<<<<<<<<
8725  *                  list c_ops=[], bool use_secular=True,
8726  *                  double sec_cutoff=0.1,
8727  */
8728 
8729   /* function exit code */
8730   goto __pyx_L0;
8731   __pyx_L1_error:;
8732   __pyx_r = NULL;
8733   __pyx_L0:;
8734   __Pyx_RefNannyFinishContext();
8735   return __pyx_r;
8736 }
8737 
__pyx_pf_5qutip_2cy_9br_tensor_2bloch_redfield_tensor(CYTHON_UNUSED PyObject * __pyx_self,PyObject * __pyx_v_H,PyObject * __pyx_v_a_ops,PyObject * __pyx_v_spectra_cb,PyObject * __pyx_v_c_ops,bool __pyx_v_use_secular,double __pyx_v_sec_cutoff,double __pyx_v_atol)8738 static PyObject *__pyx_pf_5qutip_2cy_9br_tensor_2bloch_redfield_tensor(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_H, PyObject *__pyx_v_a_ops, PyObject *__pyx_v_spectra_cb, PyObject *__pyx_v_c_ops, bool __pyx_v_use_secular, double __pyx_v_sec_cutoff, double __pyx_v_atol) {
8739   PyObject *__pyx_v__a_ops = 0;
8740   PyObject *__pyx_v_a = 0;
8741   PyObject *__pyx_v_cop = 0;
8742   PyObject *__pyx_v_L = 0;
8743   int __pyx_v_K;
8744   int __pyx_v_kk;
8745   int __pyx_v_nrows;
8746   PyObject *__pyx_v_op_dims = 0;
8747   PyObject *__pyx_v_sop_dims = 0;
8748   PyObject *__pyx_v_ekets = 0;
8749   PyObject *__pyx_v_ket_dims = 0;
8750   __Pyx_memviewslice __pyx_v_H0 = { 0, 0, { 0 }, { 0 }, { 0 } };
8751   __Pyx_memviewslice __pyx_v_evecs = { 0, 0, { 0 }, { 0 }, { 0 } };
8752   __Pyx_memviewslice __pyx_v_evals = { 0, 0, { 0 }, { 0 }, { 0 } };
8753   __Pyx_memviewslice __pyx_v_skew = { 0, 0, { 0 }, { 0 }, { 0 } };
8754   double __pyx_v_dw_min;
8755   int __pyx_7genexpr__pyx_v_k;
8756   int __pyx_8genexpr1__pyx_v_k;
8757   PyObject *__pyx_r = NULL;
8758   __Pyx_RefNannyDeclarations
8759   PyObject *__pyx_t_1 = NULL;
8760   PyObject *__pyx_t_2 = NULL;
8761   int __pyx_t_3;
8762   PyObject *__pyx_t_4 = NULL;
8763   Py_ssize_t __pyx_t_5;
8764   int __pyx_t_6;
8765   int __pyx_t_7;
8766   int __pyx_t_8;
8767   int __pyx_t_9;
8768   __Pyx_memviewslice __pyx_t_10 = { 0, 0, { 0 }, { 0 }, { 0 } };
8769   PyObject *__pyx_t_11 = NULL;
8770   __Pyx_memviewslice __pyx_t_12 = { 0, 0, { 0 }, { 0 }, { 0 } };
8771   Py_ssize_t __pyx_t_13;
8772   PyObject *__pyx_t_14 = NULL;
8773   PyObject *__pyx_t_15 = NULL;
8774   PyObject *__pyx_t_16 = NULL;
8775   PyObject *__pyx_t_17 = NULL;
8776   PyObject *__pyx_t_18 = NULL;
8777   int __pyx_t_19;
8778   int __pyx_t_20;
8779   __Pyx_memviewslice __pyx_t_21 = { 0, 0, { 0 }, { 0 }, { 0 } };
8780   __Pyx_memviewslice __pyx_t_22 = { 0, 0, { 0 }, { 0 }, { 0 } };
8781   PyObject *__pyx_t_23 = NULL;
8782   PyObject *__pyx_t_24 = NULL;
8783   PyObject *__pyx_t_25 = NULL;
8784   PyObject *__pyx_t_26 = NULL;
8785   PyObject *__pyx_t_27 = NULL;
8786   int __pyx_lineno = 0;
8787   const char *__pyx_filename = NULL;
8788   int __pyx_clineno = 0;
8789   __Pyx_RefNannySetupContext("bloch_redfield_tensor", 0);
8790   __Pyx_INCREF(__pyx_v_a_ops);
8791 
8792   /* "qutip/cy/br_tensor.pyx":158
8793  *      cdef object a, cop, L
8794  *      cdef int K, kk
8795  *      cdef int nrows = H.shape[0]             # <<<<<<<<<<<<<<
8796  *      cdef list op_dims = H.dims
8797  *      cdef list sop_dims = [[op_dims[0], op_dims[0]], [op_dims[1], op_dims[1]]]
8798  */
8799   __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_H, __pyx_n_s_shape); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 158, __pyx_L1_error)
8800   __Pyx_GOTREF(__pyx_t_1);
8801   __pyx_t_2 = __Pyx_GetItemInt(__pyx_t_1, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 158, __pyx_L1_error)
8802   __Pyx_GOTREF(__pyx_t_2);
8803   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
8804   __pyx_t_3 = __Pyx_PyInt_As_int(__pyx_t_2); if (unlikely((__pyx_t_3 == (int)-1) && PyErr_Occurred())) __PYX_ERR(1, 158, __pyx_L1_error)
8805   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
8806   __pyx_v_nrows = __pyx_t_3;
8807 
8808   /* "qutip/cy/br_tensor.pyx":159
8809  *      cdef int K, kk
8810  *      cdef int nrows = H.shape[0]
8811  *      cdef list op_dims = H.dims             # <<<<<<<<<<<<<<
8812  *      cdef list sop_dims = [[op_dims[0], op_dims[0]], [op_dims[1], op_dims[1]]]
8813  *      cdef list ekets, ket_dims
8814  */
8815   __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_H, __pyx_n_s_dims); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 159, __pyx_L1_error)
8816   __Pyx_GOTREF(__pyx_t_2);
8817   if (!(likely(PyList_CheckExact(__pyx_t_2))||((__pyx_t_2) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "list", Py_TYPE(__pyx_t_2)->tp_name), 0))) __PYX_ERR(1, 159, __pyx_L1_error)
8818   __pyx_v_op_dims = ((PyObject*)__pyx_t_2);
8819   __pyx_t_2 = 0;
8820 
8821   /* "qutip/cy/br_tensor.pyx":160
8822  *      cdef int nrows = H.shape[0]
8823  *      cdef list op_dims = H.dims
8824  *      cdef list sop_dims = [[op_dims[0], op_dims[0]], [op_dims[1], op_dims[1]]]             # <<<<<<<<<<<<<<
8825  *      cdef list ekets, ket_dims
8826  *
8827  */
8828   if (unlikely(__pyx_v_op_dims == Py_None)) {
8829     PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
8830     __PYX_ERR(1, 160, __pyx_L1_error)
8831   }
8832   if (unlikely(__pyx_v_op_dims == Py_None)) {
8833     PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
8834     __PYX_ERR(1, 160, __pyx_L1_error)
8835   }
8836   __pyx_t_2 = PyList_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 160, __pyx_L1_error)
8837   __Pyx_GOTREF(__pyx_t_2);
8838   __Pyx_INCREF(PyList_GET_ITEM(__pyx_v_op_dims, 0));
8839   __Pyx_GIVEREF(PyList_GET_ITEM(__pyx_v_op_dims, 0));
8840   PyList_SET_ITEM(__pyx_t_2, 0, PyList_GET_ITEM(__pyx_v_op_dims, 0));
8841   __Pyx_INCREF(PyList_GET_ITEM(__pyx_v_op_dims, 0));
8842   __Pyx_GIVEREF(PyList_GET_ITEM(__pyx_v_op_dims, 0));
8843   PyList_SET_ITEM(__pyx_t_2, 1, PyList_GET_ITEM(__pyx_v_op_dims, 0));
8844   if (unlikely(__pyx_v_op_dims == Py_None)) {
8845     PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
8846     __PYX_ERR(1, 160, __pyx_L1_error)
8847   }
8848   if (unlikely(__pyx_v_op_dims == Py_None)) {
8849     PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
8850     __PYX_ERR(1, 160, __pyx_L1_error)
8851   }
8852   __pyx_t_1 = PyList_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 160, __pyx_L1_error)
8853   __Pyx_GOTREF(__pyx_t_1);
8854   __Pyx_INCREF(PyList_GET_ITEM(__pyx_v_op_dims, 1));
8855   __Pyx_GIVEREF(PyList_GET_ITEM(__pyx_v_op_dims, 1));
8856   PyList_SET_ITEM(__pyx_t_1, 0, PyList_GET_ITEM(__pyx_v_op_dims, 1));
8857   __Pyx_INCREF(PyList_GET_ITEM(__pyx_v_op_dims, 1));
8858   __Pyx_GIVEREF(PyList_GET_ITEM(__pyx_v_op_dims, 1));
8859   PyList_SET_ITEM(__pyx_t_1, 1, PyList_GET_ITEM(__pyx_v_op_dims, 1));
8860   __pyx_t_4 = PyList_New(2); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 160, __pyx_L1_error)
8861   __Pyx_GOTREF(__pyx_t_4);
8862   __Pyx_GIVEREF(__pyx_t_2);
8863   PyList_SET_ITEM(__pyx_t_4, 0, __pyx_t_2);
8864   __Pyx_GIVEREF(__pyx_t_1);
8865   PyList_SET_ITEM(__pyx_t_4, 1, __pyx_t_1);
8866   __pyx_t_2 = 0;
8867   __pyx_t_1 = 0;
8868   __pyx_v_sop_dims = ((PyObject*)__pyx_t_4);
8869   __pyx_t_4 = 0;
8870 
8871   /* "qutip/cy/br_tensor.pyx":163
8872  *      cdef list ekets, ket_dims
8873  *
8874  *      ket_dims = [op_dims[0], [1] * len(op_dims[0])]             # <<<<<<<<<<<<<<
8875  *
8876  *      if not (spectra_cb is None):
8877  */
8878   if (unlikely(__pyx_v_op_dims == Py_None)) {
8879     PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
8880     __PYX_ERR(1, 163, __pyx_L1_error)
8881   }
8882   if (unlikely(__pyx_v_op_dims == Py_None)) {
8883     PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
8884     __PYX_ERR(1, 163, __pyx_L1_error)
8885   }
8886   __pyx_t_4 = PyList_GET_ITEM(__pyx_v_op_dims, 0);
8887   __Pyx_INCREF(__pyx_t_4);
8888   __pyx_t_5 = PyObject_Length(__pyx_t_4); if (unlikely(__pyx_t_5 == ((Py_ssize_t)-1))) __PYX_ERR(1, 163, __pyx_L1_error)
8889   __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
8890   __pyx_t_4 = PyList_New(1 * ((__pyx_t_5<0) ? 0:__pyx_t_5)); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 163, __pyx_L1_error)
8891   __Pyx_GOTREF(__pyx_t_4);
8892   { Py_ssize_t __pyx_temp;
8893     for (__pyx_temp=0; __pyx_temp < __pyx_t_5; __pyx_temp++) {
8894       __Pyx_INCREF(__pyx_int_1);
8895       __Pyx_GIVEREF(__pyx_int_1);
8896       PyList_SET_ITEM(__pyx_t_4, __pyx_temp, __pyx_int_1);
8897     }
8898   }
8899   __pyx_t_1 = PyList_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 163, __pyx_L1_error)
8900   __Pyx_GOTREF(__pyx_t_1);
8901   __Pyx_INCREF(PyList_GET_ITEM(__pyx_v_op_dims, 0));
8902   __Pyx_GIVEREF(PyList_GET_ITEM(__pyx_v_op_dims, 0));
8903   PyList_SET_ITEM(__pyx_t_1, 0, PyList_GET_ITEM(__pyx_v_op_dims, 0));
8904   __Pyx_GIVEREF(__pyx_t_4);
8905   PyList_SET_ITEM(__pyx_t_1, 1, __pyx_t_4);
8906   __pyx_t_4 = 0;
8907   __pyx_v_ket_dims = ((PyObject*)__pyx_t_1);
8908   __pyx_t_1 = 0;
8909 
8910   /* "qutip/cy/br_tensor.pyx":165
8911  *      ket_dims = [op_dims[0], [1] * len(op_dims[0])]
8912  *
8913  *      if not (spectra_cb is None):             # <<<<<<<<<<<<<<
8914  *          warnings.warn("The use of spectra_cb is depreciated.", DeprecationWarning)
8915  *          _a_ops = []
8916  */
8917   __pyx_t_6 = (__pyx_v_spectra_cb != Py_None);
8918   __pyx_t_7 = (__pyx_t_6 != 0);
8919   if (__pyx_t_7) {
8920 
8921     /* "qutip/cy/br_tensor.pyx":166
8922  *
8923  *      if not (spectra_cb is None):
8924  *          warnings.warn("The use of spectra_cb is depreciated.", DeprecationWarning)             # <<<<<<<<<<<<<<
8925  *          _a_ops = []
8926  *          for kk, a in enumerate(a_ops):
8927  */
8928     __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_warnings); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 166, __pyx_L1_error)
8929     __Pyx_GOTREF(__pyx_t_1);
8930     __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_warn); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 166, __pyx_L1_error)
8931     __Pyx_GOTREF(__pyx_t_4);
8932     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
8933     __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_tuple__14, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 166, __pyx_L1_error)
8934     __Pyx_GOTREF(__pyx_t_1);
8935     __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
8936     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
8937 
8938     /* "qutip/cy/br_tensor.pyx":167
8939  *      if not (spectra_cb is None):
8940  *          warnings.warn("The use of spectra_cb is depreciated.", DeprecationWarning)
8941  *          _a_ops = []             # <<<<<<<<<<<<<<
8942  *          for kk, a in enumerate(a_ops):
8943  *              _a_ops.append([a,spectra_cb[kk]])
8944  */
8945     __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 167, __pyx_L1_error)
8946     __Pyx_GOTREF(__pyx_t_1);
8947     __pyx_v__a_ops = ((PyObject*)__pyx_t_1);
8948     __pyx_t_1 = 0;
8949 
8950     /* "qutip/cy/br_tensor.pyx":168
8951  *          warnings.warn("The use of spectra_cb is depreciated.", DeprecationWarning)
8952  *          _a_ops = []
8953  *          for kk, a in enumerate(a_ops):             # <<<<<<<<<<<<<<
8954  *              _a_ops.append([a,spectra_cb[kk]])
8955  *          a_ops = _a_ops
8956  */
8957     __pyx_t_3 = 0;
8958     __pyx_t_1 = __pyx_v_a_ops; __Pyx_INCREF(__pyx_t_1); __pyx_t_5 = 0;
8959     for (;;) {
8960       if (__pyx_t_5 >= PyList_GET_SIZE(__pyx_t_1)) break;
8961       #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
8962       __pyx_t_4 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_5); __Pyx_INCREF(__pyx_t_4); __pyx_t_5++; if (unlikely(0 < 0)) __PYX_ERR(1, 168, __pyx_L1_error)
8963       #else
8964       __pyx_t_4 = PySequence_ITEM(__pyx_t_1, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 168, __pyx_L1_error)
8965       __Pyx_GOTREF(__pyx_t_4);
8966       #endif
8967       __Pyx_XDECREF_SET(__pyx_v_a, __pyx_t_4);
8968       __pyx_t_4 = 0;
8969       __pyx_v_kk = __pyx_t_3;
8970       __pyx_t_3 = (__pyx_t_3 + 1);
8971 
8972       /* "qutip/cy/br_tensor.pyx":169
8973  *          _a_ops = []
8974  *          for kk, a in enumerate(a_ops):
8975  *              _a_ops.append([a,spectra_cb[kk]])             # <<<<<<<<<<<<<<
8976  *          a_ops = _a_ops
8977  *
8978  */
8979       __pyx_t_4 = __Pyx_GetItemInt(__pyx_v_spectra_cb, __pyx_v_kk, int, 1, __Pyx_PyInt_From_int, 0, 0, 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 169, __pyx_L1_error)
8980       __Pyx_GOTREF(__pyx_t_4);
8981       __pyx_t_2 = PyList_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 169, __pyx_L1_error)
8982       __Pyx_GOTREF(__pyx_t_2);
8983       __Pyx_INCREF(__pyx_v_a);
8984       __Pyx_GIVEREF(__pyx_v_a);
8985       PyList_SET_ITEM(__pyx_t_2, 0, __pyx_v_a);
8986       __Pyx_GIVEREF(__pyx_t_4);
8987       PyList_SET_ITEM(__pyx_t_2, 1, __pyx_t_4);
8988       __pyx_t_4 = 0;
8989       __pyx_t_8 = __Pyx_PyList_Append(__pyx_v__a_ops, __pyx_t_2); if (unlikely(__pyx_t_8 == ((int)-1))) __PYX_ERR(1, 169, __pyx_L1_error)
8990       __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
8991 
8992       /* "qutip/cy/br_tensor.pyx":168
8993  *          warnings.warn("The use of spectra_cb is depreciated.", DeprecationWarning)
8994  *          _a_ops = []
8995  *          for kk, a in enumerate(a_ops):             # <<<<<<<<<<<<<<
8996  *              _a_ops.append([a,spectra_cb[kk]])
8997  *          a_ops = _a_ops
8998  */
8999     }
9000     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
9001 
9002     /* "qutip/cy/br_tensor.pyx":170
9003  *          for kk, a in enumerate(a_ops):
9004  *              _a_ops.append([a,spectra_cb[kk]])
9005  *          a_ops = _a_ops             # <<<<<<<<<<<<<<
9006  *
9007  *      K = len(a_ops)
9008  */
9009     __Pyx_INCREF(__pyx_v__a_ops);
9010     __Pyx_DECREF_SET(__pyx_v_a_ops, __pyx_v__a_ops);
9011 
9012     /* "qutip/cy/br_tensor.pyx":165
9013  *      ket_dims = [op_dims[0], [1] * len(op_dims[0])]
9014  *
9015  *      if not (spectra_cb is None):             # <<<<<<<<<<<<<<
9016  *          warnings.warn("The use of spectra_cb is depreciated.", DeprecationWarning)
9017  *          _a_ops = []
9018  */
9019   }
9020 
9021   /* "qutip/cy/br_tensor.pyx":172
9022  *          a_ops = _a_ops
9023  *
9024  *      K = len(a_ops)             # <<<<<<<<<<<<<<
9025  *
9026  *      # Sanity checks for input parameters
9027  */
9028   if (unlikely(__pyx_v_a_ops == Py_None)) {
9029     PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
9030     __PYX_ERR(1, 172, __pyx_L1_error)
9031   }
9032   __pyx_t_5 = PyList_GET_SIZE(__pyx_v_a_ops); if (unlikely(__pyx_t_5 == ((Py_ssize_t)-1))) __PYX_ERR(1, 172, __pyx_L1_error)
9033   __pyx_v_K = __pyx_t_5;
9034 
9035   /* "qutip/cy/br_tensor.pyx":175
9036  *
9037  *      # Sanity checks for input parameters
9038  *      if not isinstance(H, Qobj):             # <<<<<<<<<<<<<<
9039  *          raise TypeError("H must be an instance of Qobj")
9040  *
9041  */
9042   __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_Qobj); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 175, __pyx_L1_error)
9043   __Pyx_GOTREF(__pyx_t_1);
9044   __pyx_t_7 = PyObject_IsInstance(__pyx_v_H, __pyx_t_1); if (unlikely(__pyx_t_7 == ((int)-1))) __PYX_ERR(1, 175, __pyx_L1_error)
9045   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
9046   __pyx_t_6 = ((!(__pyx_t_7 != 0)) != 0);
9047   if (unlikely(__pyx_t_6)) {
9048 
9049     /* "qutip/cy/br_tensor.pyx":176
9050  *      # Sanity checks for input parameters
9051  *      if not isinstance(H, Qobj):
9052  *          raise TypeError("H must be an instance of Qobj")             # <<<<<<<<<<<<<<
9053  *
9054  *      for a in a_ops:
9055  */
9056     __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__15, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 176, __pyx_L1_error)
9057     __Pyx_GOTREF(__pyx_t_1);
9058     __Pyx_Raise(__pyx_t_1, 0, 0, 0);
9059     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
9060     __PYX_ERR(1, 176, __pyx_L1_error)
9061 
9062     /* "qutip/cy/br_tensor.pyx":175
9063  *
9064  *      # Sanity checks for input parameters
9065  *      if not isinstance(H, Qobj):             # <<<<<<<<<<<<<<
9066  *          raise TypeError("H must be an instance of Qobj")
9067  *
9068  */
9069   }
9070 
9071   /* "qutip/cy/br_tensor.pyx":178
9072  *          raise TypeError("H must be an instance of Qobj")
9073  *
9074  *      for a in a_ops:             # <<<<<<<<<<<<<<
9075  *          if not isinstance(a[0], Qobj) or not a[0].isherm:
9076  *              raise TypeError("Operators in a_ops must be Hermitian Qobj.")
9077  */
9078   if (unlikely(__pyx_v_a_ops == Py_None)) {
9079     PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable");
9080     __PYX_ERR(1, 178, __pyx_L1_error)
9081   }
9082   __pyx_t_1 = __pyx_v_a_ops; __Pyx_INCREF(__pyx_t_1); __pyx_t_5 = 0;
9083   for (;;) {
9084     if (__pyx_t_5 >= PyList_GET_SIZE(__pyx_t_1)) break;
9085     #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
9086     __pyx_t_2 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_5); __Pyx_INCREF(__pyx_t_2); __pyx_t_5++; if (unlikely(0 < 0)) __PYX_ERR(1, 178, __pyx_L1_error)
9087     #else
9088     __pyx_t_2 = PySequence_ITEM(__pyx_t_1, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 178, __pyx_L1_error)
9089     __Pyx_GOTREF(__pyx_t_2);
9090     #endif
9091     __Pyx_XDECREF_SET(__pyx_v_a, __pyx_t_2);
9092     __pyx_t_2 = 0;
9093 
9094     /* "qutip/cy/br_tensor.pyx":179
9095  *
9096  *      for a in a_ops:
9097  *          if not isinstance(a[0], Qobj) or not a[0].isherm:             # <<<<<<<<<<<<<<
9098  *              raise TypeError("Operators in a_ops must be Hermitian Qobj.")
9099  *
9100  */
9101     __pyx_t_2 = __Pyx_GetItemInt(__pyx_v_a, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 179, __pyx_L1_error)
9102     __Pyx_GOTREF(__pyx_t_2);
9103     __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_Qobj); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 179, __pyx_L1_error)
9104     __Pyx_GOTREF(__pyx_t_4);
9105     __pyx_t_7 = PyObject_IsInstance(__pyx_t_2, __pyx_t_4); if (unlikely(__pyx_t_7 == ((int)-1))) __PYX_ERR(1, 179, __pyx_L1_error)
9106     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
9107     __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
9108     __pyx_t_9 = ((!(__pyx_t_7 != 0)) != 0);
9109     if (!__pyx_t_9) {
9110     } else {
9111       __pyx_t_6 = __pyx_t_9;
9112       goto __pyx_L10_bool_binop_done;
9113     }
9114     __pyx_t_4 = __Pyx_GetItemInt(__pyx_v_a, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 179, __pyx_L1_error)
9115     __Pyx_GOTREF(__pyx_t_4);
9116     __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_isherm); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 179, __pyx_L1_error)
9117     __Pyx_GOTREF(__pyx_t_2);
9118     __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
9119     __pyx_t_9 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_9 < 0)) __PYX_ERR(1, 179, __pyx_L1_error)
9120     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
9121     __pyx_t_7 = ((!__pyx_t_9) != 0);
9122     __pyx_t_6 = __pyx_t_7;
9123     __pyx_L10_bool_binop_done:;
9124     if (unlikely(__pyx_t_6)) {
9125 
9126       /* "qutip/cy/br_tensor.pyx":180
9127  *      for a in a_ops:
9128  *          if not isinstance(a[0], Qobj) or not a[0].isherm:
9129  *              raise TypeError("Operators in a_ops must be Hermitian Qobj.")             # <<<<<<<<<<<<<<
9130  *
9131  *      cdef complex[::1,:] H0 = H.full('F')
9132  */
9133       __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__16, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 180, __pyx_L1_error)
9134       __Pyx_GOTREF(__pyx_t_2);
9135       __Pyx_Raise(__pyx_t_2, 0, 0, 0);
9136       __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
9137       __PYX_ERR(1, 180, __pyx_L1_error)
9138 
9139       /* "qutip/cy/br_tensor.pyx":179
9140  *
9141  *      for a in a_ops:
9142  *          if not isinstance(a[0], Qobj) or not a[0].isherm:             # <<<<<<<<<<<<<<
9143  *              raise TypeError("Operators in a_ops must be Hermitian Qobj.")
9144  *
9145  */
9146     }
9147 
9148     /* "qutip/cy/br_tensor.pyx":178
9149  *          raise TypeError("H must be an instance of Qobj")
9150  *
9151  *      for a in a_ops:             # <<<<<<<<<<<<<<
9152  *          if not isinstance(a[0], Qobj) or not a[0].isherm:
9153  *              raise TypeError("Operators in a_ops must be Hermitian Qobj.")
9154  */
9155   }
9156   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
9157 
9158   /* "qutip/cy/br_tensor.pyx":182
9159  *              raise TypeError("Operators in a_ops must be Hermitian Qobj.")
9160  *
9161  *      cdef complex[::1,:] H0 = H.full('F')             # <<<<<<<<<<<<<<
9162  *      cdef complex[::1,:] evecs = np.zeros((nrows,nrows), dtype=complex, order='F')
9163  *      cdef double[::1] evals = np.zeros(nrows, dtype=float)
9164  */
9165   __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_H, __pyx_n_s_full); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 182, __pyx_L1_error)
9166   __Pyx_GOTREF(__pyx_t_2);
9167   __pyx_t_4 = NULL;
9168   if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
9169     __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_2);
9170     if (likely(__pyx_t_4)) {
9171       PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
9172       __Pyx_INCREF(__pyx_t_4);
9173       __Pyx_INCREF(function);
9174       __Pyx_DECREF_SET(__pyx_t_2, function);
9175     }
9176   }
9177   __pyx_t_1 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_4, __pyx_n_u_F) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_n_u_F);
9178   __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
9179   if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 182, __pyx_L1_error)
9180   __Pyx_GOTREF(__pyx_t_1);
9181   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
9182   __pyx_t_10 = __Pyx_PyObject_to_MemoryviewSlice_dcd____pyx_t_double_complex(__pyx_t_1, PyBUF_WRITABLE); if (unlikely(!__pyx_t_10.memview)) __PYX_ERR(1, 182, __pyx_L1_error)
9183   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
9184   __pyx_v_H0 = __pyx_t_10;
9185   __pyx_t_10.memview = NULL;
9186   __pyx_t_10.data = NULL;
9187 
9188   /* "qutip/cy/br_tensor.pyx":183
9189  *
9190  *      cdef complex[::1,:] H0 = H.full('F')
9191  *      cdef complex[::1,:] evecs = np.zeros((nrows,nrows), dtype=complex, order='F')             # <<<<<<<<<<<<<<
9192  *      cdef double[::1] evals = np.zeros(nrows, dtype=float)
9193  *
9194  */
9195   __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_np); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 183, __pyx_L1_error)
9196   __Pyx_GOTREF(__pyx_t_1);
9197   __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_zeros); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 183, __pyx_L1_error)
9198   __Pyx_GOTREF(__pyx_t_2);
9199   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
9200   __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_nrows); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 183, __pyx_L1_error)
9201   __Pyx_GOTREF(__pyx_t_1);
9202   __pyx_t_4 = __Pyx_PyInt_From_int(__pyx_v_nrows); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 183, __pyx_L1_error)
9203   __Pyx_GOTREF(__pyx_t_4);
9204   __pyx_t_11 = PyTuple_New(2); if (unlikely(!__pyx_t_11)) __PYX_ERR(1, 183, __pyx_L1_error)
9205   __Pyx_GOTREF(__pyx_t_11);
9206   __Pyx_GIVEREF(__pyx_t_1);
9207   PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_t_1);
9208   __Pyx_GIVEREF(__pyx_t_4);
9209   PyTuple_SET_ITEM(__pyx_t_11, 1, __pyx_t_4);
9210   __pyx_t_1 = 0;
9211   __pyx_t_4 = 0;
9212   __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 183, __pyx_L1_error)
9213   __Pyx_GOTREF(__pyx_t_4);
9214   __Pyx_GIVEREF(__pyx_t_11);
9215   PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_11);
9216   __pyx_t_11 = 0;
9217   __pyx_t_11 = __Pyx_PyDict_NewPresized(2); if (unlikely(!__pyx_t_11)) __PYX_ERR(1, 183, __pyx_L1_error)
9218   __Pyx_GOTREF(__pyx_t_11);
9219   if (PyDict_SetItem(__pyx_t_11, __pyx_n_s_dtype, ((PyObject *)(&PyComplex_Type))) < 0) __PYX_ERR(1, 183, __pyx_L1_error)
9220   if (PyDict_SetItem(__pyx_t_11, __pyx_n_s_order, __pyx_n_u_F) < 0) __PYX_ERR(1, 183, __pyx_L1_error)
9221   __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_4, __pyx_t_11); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 183, __pyx_L1_error)
9222   __Pyx_GOTREF(__pyx_t_1);
9223   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
9224   __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
9225   __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
9226   __pyx_t_10 = __Pyx_PyObject_to_MemoryviewSlice_dcd____pyx_t_double_complex(__pyx_t_1, PyBUF_WRITABLE); if (unlikely(!__pyx_t_10.memview)) __PYX_ERR(1, 183, __pyx_L1_error)
9227   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
9228   __pyx_v_evecs = __pyx_t_10;
9229   __pyx_t_10.memview = NULL;
9230   __pyx_t_10.data = NULL;
9231 
9232   /* "qutip/cy/br_tensor.pyx":184
9233  *      cdef complex[::1,:] H0 = H.full('F')
9234  *      cdef complex[::1,:] evecs = np.zeros((nrows,nrows), dtype=complex, order='F')
9235  *      cdef double[::1] evals = np.zeros(nrows, dtype=float)             # <<<<<<<<<<<<<<
9236  *
9237  *      ZHEEVR(H0, &evals[0], evecs, nrows)
9238  */
9239   __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_np); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 184, __pyx_L1_error)
9240   __Pyx_GOTREF(__pyx_t_1);
9241   __pyx_t_11 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_zeros); if (unlikely(!__pyx_t_11)) __PYX_ERR(1, 184, __pyx_L1_error)
9242   __Pyx_GOTREF(__pyx_t_11);
9243   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
9244   __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_nrows); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 184, __pyx_L1_error)
9245   __Pyx_GOTREF(__pyx_t_1);
9246   __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 184, __pyx_L1_error)
9247   __Pyx_GOTREF(__pyx_t_4);
9248   __Pyx_GIVEREF(__pyx_t_1);
9249   PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_1);
9250   __pyx_t_1 = 0;
9251   __pyx_t_1 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 184, __pyx_L1_error)
9252   __Pyx_GOTREF(__pyx_t_1);
9253   if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_dtype, ((PyObject *)(&PyFloat_Type))) < 0) __PYX_ERR(1, 184, __pyx_L1_error)
9254   __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_11, __pyx_t_4, __pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 184, __pyx_L1_error)
9255   __Pyx_GOTREF(__pyx_t_2);
9256   __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
9257   __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
9258   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
9259   __pyx_t_12 = __Pyx_PyObject_to_MemoryviewSlice_dc_double(__pyx_t_2, PyBUF_WRITABLE); if (unlikely(!__pyx_t_12.memview)) __PYX_ERR(1, 184, __pyx_L1_error)
9260   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
9261   __pyx_v_evals = __pyx_t_12;
9262   __pyx_t_12.memview = NULL;
9263   __pyx_t_12.data = NULL;
9264 
9265   /* "qutip/cy/br_tensor.pyx":186
9266  *      cdef double[::1] evals = np.zeros(nrows, dtype=float)
9267  *
9268  *      ZHEEVR(H0, &evals[0], evecs, nrows)             # <<<<<<<<<<<<<<
9269  *      L = liou_from_diag_ham(evals)
9270  *
9271  */
9272   __pyx_t_13 = 0;
9273   __pyx_f_5qutip_2cy_7brtools_ZHEEVR(__pyx_v_H0, (&(*((double *) ( /* dim=0 */ ((char *) (((double *) __pyx_v_evals.data) + __pyx_t_13)) )))), __pyx_v_evecs, __pyx_v_nrows);
9274 
9275   /* "qutip/cy/br_tensor.pyx":187
9276  *
9277  *      ZHEEVR(H0, &evals[0], evecs, nrows)
9278  *      L = liou_from_diag_ham(evals)             # <<<<<<<<<<<<<<
9279  *
9280  *      for cop in c_ops:
9281  */
9282   __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_liou_from_diag_ham); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 187, __pyx_L1_error)
9283   __Pyx_GOTREF(__pyx_t_1);
9284   __pyx_t_4 = __pyx_memoryview_fromslice(__pyx_v_evals, 1, (PyObject *(*)(char *)) __pyx_memview_get_double, (int (*)(char *, PyObject *)) __pyx_memview_set_double, 0);; if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 187, __pyx_L1_error)
9285   __Pyx_GOTREF(__pyx_t_4);
9286   __pyx_t_11 = NULL;
9287   if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_1))) {
9288     __pyx_t_11 = PyMethod_GET_SELF(__pyx_t_1);
9289     if (likely(__pyx_t_11)) {
9290       PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
9291       __Pyx_INCREF(__pyx_t_11);
9292       __Pyx_INCREF(function);
9293       __Pyx_DECREF_SET(__pyx_t_1, function);
9294     }
9295   }
9296   __pyx_t_2 = (__pyx_t_11) ? __Pyx_PyObject_Call2Args(__pyx_t_1, __pyx_t_11, __pyx_t_4) : __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_4);
9297   __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
9298   __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
9299   if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 187, __pyx_L1_error)
9300   __Pyx_GOTREF(__pyx_t_2);
9301   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
9302   __pyx_v_L = __pyx_t_2;
9303   __pyx_t_2 = 0;
9304 
9305   /* "qutip/cy/br_tensor.pyx":189
9306  *      L = liou_from_diag_ham(evals)
9307  *
9308  *      for cop in c_ops:             # <<<<<<<<<<<<<<
9309  *          L = L + cop_super_term(cop.full('F'), evecs, 1,
9310  *                                nrows, atol)
9311  */
9312   if (unlikely(__pyx_v_c_ops == Py_None)) {
9313     PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable");
9314     __PYX_ERR(1, 189, __pyx_L1_error)
9315   }
9316   __pyx_t_2 = __pyx_v_c_ops; __Pyx_INCREF(__pyx_t_2); __pyx_t_5 = 0;
9317   for (;;) {
9318     if (__pyx_t_5 >= PyList_GET_SIZE(__pyx_t_2)) break;
9319     #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
9320     __pyx_t_1 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_5); __Pyx_INCREF(__pyx_t_1); __pyx_t_5++; if (unlikely(0 < 0)) __PYX_ERR(1, 189, __pyx_L1_error)
9321     #else
9322     __pyx_t_1 = PySequence_ITEM(__pyx_t_2, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 189, __pyx_L1_error)
9323     __Pyx_GOTREF(__pyx_t_1);
9324     #endif
9325     __Pyx_XDECREF_SET(__pyx_v_cop, __pyx_t_1);
9326     __pyx_t_1 = 0;
9327 
9328     /* "qutip/cy/br_tensor.pyx":190
9329  *
9330  *      for cop in c_ops:
9331  *          L = L + cop_super_term(cop.full('F'), evecs, 1,             # <<<<<<<<<<<<<<
9332  *                                nrows, atol)
9333  *
9334  */
9335     __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_cop_super_term); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 190, __pyx_L1_error)
9336     __Pyx_GOTREF(__pyx_t_4);
9337     __pyx_t_14 = __Pyx_PyObject_GetAttrStr(__pyx_v_cop, __pyx_n_s_full); if (unlikely(!__pyx_t_14)) __PYX_ERR(1, 190, __pyx_L1_error)
9338     __Pyx_GOTREF(__pyx_t_14);
9339     __pyx_t_15 = NULL;
9340     if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_14))) {
9341       __pyx_t_15 = PyMethod_GET_SELF(__pyx_t_14);
9342       if (likely(__pyx_t_15)) {
9343         PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_14);
9344         __Pyx_INCREF(__pyx_t_15);
9345         __Pyx_INCREF(function);
9346         __Pyx_DECREF_SET(__pyx_t_14, function);
9347       }
9348     }
9349     __pyx_t_11 = (__pyx_t_15) ? __Pyx_PyObject_Call2Args(__pyx_t_14, __pyx_t_15, __pyx_n_u_F) : __Pyx_PyObject_CallOneArg(__pyx_t_14, __pyx_n_u_F);
9350     __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
9351     if (unlikely(!__pyx_t_11)) __PYX_ERR(1, 190, __pyx_L1_error)
9352     __Pyx_GOTREF(__pyx_t_11);
9353     __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
9354     __pyx_t_14 = __pyx_memoryview_fromslice(__pyx_v_evecs, 2, (PyObject *(*)(char *)) __pyx_memview_get___pyx_t_double_complex, (int (*)(char *, PyObject *)) __pyx_memview_set___pyx_t_double_complex, 0);; if (unlikely(!__pyx_t_14)) __PYX_ERR(1, 190, __pyx_L1_error)
9355     __Pyx_GOTREF(__pyx_t_14);
9356 
9357     /* "qutip/cy/br_tensor.pyx":191
9358  *      for cop in c_ops:
9359  *          L = L + cop_super_term(cop.full('F'), evecs, 1,
9360  *                                nrows, atol)             # <<<<<<<<<<<<<<
9361  *
9362  *      #only lindblad collapse terms
9363  */
9364     __pyx_t_15 = __Pyx_PyInt_From_int(__pyx_v_nrows); if (unlikely(!__pyx_t_15)) __PYX_ERR(1, 191, __pyx_L1_error)
9365     __Pyx_GOTREF(__pyx_t_15);
9366     __pyx_t_16 = PyFloat_FromDouble(__pyx_v_atol); if (unlikely(!__pyx_t_16)) __PYX_ERR(1, 191, __pyx_L1_error)
9367     __Pyx_GOTREF(__pyx_t_16);
9368     __pyx_t_17 = NULL;
9369     __pyx_t_3 = 0;
9370     if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_4))) {
9371       __pyx_t_17 = PyMethod_GET_SELF(__pyx_t_4);
9372       if (likely(__pyx_t_17)) {
9373         PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
9374         __Pyx_INCREF(__pyx_t_17);
9375         __Pyx_INCREF(function);
9376         __Pyx_DECREF_SET(__pyx_t_4, function);
9377         __pyx_t_3 = 1;
9378       }
9379     }
9380     #if CYTHON_FAST_PYCALL
9381     if (PyFunction_Check(__pyx_t_4)) {
9382       PyObject *__pyx_temp[6] = {__pyx_t_17, __pyx_t_11, __pyx_t_14, __pyx_int_1, __pyx_t_15, __pyx_t_16};
9383       __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_3, 5+__pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 190, __pyx_L1_error)
9384       __Pyx_XDECREF(__pyx_t_17); __pyx_t_17 = 0;
9385       __Pyx_GOTREF(__pyx_t_1);
9386       __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
9387       __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
9388       __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
9389       __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;
9390     } else
9391     #endif
9392     #if CYTHON_FAST_PYCCALL
9393     if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) {
9394       PyObject *__pyx_temp[6] = {__pyx_t_17, __pyx_t_11, __pyx_t_14, __pyx_int_1, __pyx_t_15, __pyx_t_16};
9395       __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_3, 5+__pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 190, __pyx_L1_error)
9396       __Pyx_XDECREF(__pyx_t_17); __pyx_t_17 = 0;
9397       __Pyx_GOTREF(__pyx_t_1);
9398       __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
9399       __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
9400       __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
9401       __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;
9402     } else
9403     #endif
9404     {
9405       __pyx_t_18 = PyTuple_New(5+__pyx_t_3); if (unlikely(!__pyx_t_18)) __PYX_ERR(1, 190, __pyx_L1_error)
9406       __Pyx_GOTREF(__pyx_t_18);
9407       if (__pyx_t_17) {
9408         __Pyx_GIVEREF(__pyx_t_17); PyTuple_SET_ITEM(__pyx_t_18, 0, __pyx_t_17); __pyx_t_17 = NULL;
9409       }
9410       __Pyx_GIVEREF(__pyx_t_11);
9411       PyTuple_SET_ITEM(__pyx_t_18, 0+__pyx_t_3, __pyx_t_11);
9412       __Pyx_GIVEREF(__pyx_t_14);
9413       PyTuple_SET_ITEM(__pyx_t_18, 1+__pyx_t_3, __pyx_t_14);
9414       __Pyx_INCREF(__pyx_int_1);
9415       __Pyx_GIVEREF(__pyx_int_1);
9416       PyTuple_SET_ITEM(__pyx_t_18, 2+__pyx_t_3, __pyx_int_1);
9417       __Pyx_GIVEREF(__pyx_t_15);
9418       PyTuple_SET_ITEM(__pyx_t_18, 3+__pyx_t_3, __pyx_t_15);
9419       __Pyx_GIVEREF(__pyx_t_16);
9420       PyTuple_SET_ITEM(__pyx_t_18, 4+__pyx_t_3, __pyx_t_16);
9421       __pyx_t_11 = 0;
9422       __pyx_t_14 = 0;
9423       __pyx_t_15 = 0;
9424       __pyx_t_16 = 0;
9425       __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_18, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 190, __pyx_L1_error)
9426       __Pyx_GOTREF(__pyx_t_1);
9427       __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
9428     }
9429     __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
9430 
9431     /* "qutip/cy/br_tensor.pyx":190
9432  *
9433  *      for cop in c_ops:
9434  *          L = L + cop_super_term(cop.full('F'), evecs, 1,             # <<<<<<<<<<<<<<
9435  *                                nrows, atol)
9436  *
9437  */
9438     __pyx_t_4 = PyNumber_Add(__pyx_v_L, __pyx_t_1); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 190, __pyx_L1_error)
9439     __Pyx_GOTREF(__pyx_t_4);
9440     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
9441     __Pyx_DECREF_SET(__pyx_v_L, __pyx_t_4);
9442     __pyx_t_4 = 0;
9443 
9444     /* "qutip/cy/br_tensor.pyx":189
9445  *      L = liou_from_diag_ham(evals)
9446  *
9447  *      for cop in c_ops:             # <<<<<<<<<<<<<<
9448  *          L = L + cop_super_term(cop.full('F'), evecs, 1,
9449  *                                nrows, atol)
9450  */
9451   }
9452   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
9453 
9454   /* "qutip/cy/br_tensor.pyx":194
9455  *
9456  *      #only lindblad collapse terms
9457  *      if K == 0:             # <<<<<<<<<<<<<<
9458  *          ekets = [Qobj(np.asarray(evecs[:,k]),
9459  *                dims=ket_dims) for k in range(nrows)]
9460  */
9461   __pyx_t_6 = ((__pyx_v_K == 0) != 0);
9462   if (__pyx_t_6) {
9463 
9464     /* "qutip/cy/br_tensor.pyx":195
9465  *      #only lindblad collapse terms
9466  *      if K == 0:
9467  *          ekets = [Qobj(np.asarray(evecs[:,k]),             # <<<<<<<<<<<<<<
9468  *                dims=ket_dims) for k in range(nrows)]
9469  *
9470  */
9471     { /* enter inner scope */
9472       __pyx_t_2 = PyList_New(0); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 195, __pyx_L1_error)
9473       __Pyx_GOTREF(__pyx_t_2);
9474 
9475       /* "qutip/cy/br_tensor.pyx":196
9476  *      if K == 0:
9477  *          ekets = [Qobj(np.asarray(evecs[:,k]),
9478  *                dims=ket_dims) for k in range(nrows)]             # <<<<<<<<<<<<<<
9479  *
9480  *          return Qobj(L, dims=sop_dims, copy=False), ekets
9481  */
9482       __pyx_t_3 = __pyx_v_nrows;
9483       __pyx_t_19 = __pyx_t_3;
9484       for (__pyx_t_20 = 0; __pyx_t_20 < __pyx_t_19; __pyx_t_20+=1) {
9485         __pyx_7genexpr__pyx_v_k = __pyx_t_20;
9486 
9487         /* "qutip/cy/br_tensor.pyx":195
9488  *      #only lindblad collapse terms
9489  *      if K == 0:
9490  *          ekets = [Qobj(np.asarray(evecs[:,k]),             # <<<<<<<<<<<<<<
9491  *                dims=ket_dims) for k in range(nrows)]
9492  *
9493  */
9494         __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_Qobj); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 195, __pyx_L1_error)
9495         __Pyx_GOTREF(__pyx_t_4);
9496         __Pyx_GetModuleGlobalName(__pyx_t_18, __pyx_n_s_np); if (unlikely(!__pyx_t_18)) __PYX_ERR(1, 195, __pyx_L1_error)
9497         __Pyx_GOTREF(__pyx_t_18);
9498         __pyx_t_16 = __Pyx_PyObject_GetAttrStr(__pyx_t_18, __pyx_n_s_asarray); if (unlikely(!__pyx_t_16)) __PYX_ERR(1, 195, __pyx_L1_error)
9499         __Pyx_GOTREF(__pyx_t_16);
9500         __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
9501         __pyx_t_21.data = __pyx_v_evecs.data;
9502         __pyx_t_21.memview = __pyx_v_evecs.memview;
9503         __PYX_INC_MEMVIEW(&__pyx_t_21, 0);
9504         __pyx_t_21.shape[0] = __pyx_v_evecs.shape[0];
9505 __pyx_t_21.strides[0] = __pyx_v_evecs.strides[0];
9506     __pyx_t_21.suboffsets[0] = -1;
9507 
9508 {
9509     Py_ssize_t __pyx_tmp_idx = __pyx_7genexpr__pyx_v_k;
9510     Py_ssize_t __pyx_tmp_stride = __pyx_v_evecs.strides[1];
9511         __pyx_t_21.data += __pyx_tmp_idx * __pyx_tmp_stride;
9512 }
9513 
9514 __pyx_t_18 = __pyx_memoryview_fromslice(__pyx_t_21, 1, (PyObject *(*)(char *)) __pyx_memview_get___pyx_t_double_complex, (int (*)(char *, PyObject *)) __pyx_memview_set___pyx_t_double_complex, 0);; if (unlikely(!__pyx_t_18)) __PYX_ERR(1, 195, __pyx_L1_error)
9515         __Pyx_GOTREF(__pyx_t_18);
9516         __PYX_XDEC_MEMVIEW(&__pyx_t_21, 1);
9517         __pyx_t_21.memview = NULL;
9518         __pyx_t_21.data = NULL;
9519         __pyx_t_15 = NULL;
9520         if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_16))) {
9521           __pyx_t_15 = PyMethod_GET_SELF(__pyx_t_16);
9522           if (likely(__pyx_t_15)) {
9523             PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_16);
9524             __Pyx_INCREF(__pyx_t_15);
9525             __Pyx_INCREF(function);
9526             __Pyx_DECREF_SET(__pyx_t_16, function);
9527           }
9528         }
9529         __pyx_t_1 = (__pyx_t_15) ? __Pyx_PyObject_Call2Args(__pyx_t_16, __pyx_t_15, __pyx_t_18) : __Pyx_PyObject_CallOneArg(__pyx_t_16, __pyx_t_18);
9530         __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
9531         __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
9532         if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 195, __pyx_L1_error)
9533         __Pyx_GOTREF(__pyx_t_1);
9534         __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;
9535         __pyx_t_16 = PyTuple_New(1); if (unlikely(!__pyx_t_16)) __PYX_ERR(1, 195, __pyx_L1_error)
9536         __Pyx_GOTREF(__pyx_t_16);
9537         __Pyx_GIVEREF(__pyx_t_1);
9538         PyTuple_SET_ITEM(__pyx_t_16, 0, __pyx_t_1);
9539         __pyx_t_1 = 0;
9540 
9541         /* "qutip/cy/br_tensor.pyx":196
9542  *      if K == 0:
9543  *          ekets = [Qobj(np.asarray(evecs[:,k]),
9544  *                dims=ket_dims) for k in range(nrows)]             # <<<<<<<<<<<<<<
9545  *
9546  *          return Qobj(L, dims=sop_dims, copy=False), ekets
9547  */
9548         __pyx_t_1 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 196, __pyx_L1_error)
9549         __Pyx_GOTREF(__pyx_t_1);
9550         if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_dims, __pyx_v_ket_dims) < 0) __PYX_ERR(1, 196, __pyx_L1_error)
9551 
9552         /* "qutip/cy/br_tensor.pyx":195
9553  *      #only lindblad collapse terms
9554  *      if K == 0:
9555  *          ekets = [Qobj(np.asarray(evecs[:,k]),             # <<<<<<<<<<<<<<
9556  *                dims=ket_dims) for k in range(nrows)]
9557  *
9558  */
9559         __pyx_t_18 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_16, __pyx_t_1); if (unlikely(!__pyx_t_18)) __PYX_ERR(1, 195, __pyx_L1_error)
9560         __Pyx_GOTREF(__pyx_t_18);
9561         __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
9562         __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;
9563         __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
9564         if (unlikely(__Pyx_ListComp_Append(__pyx_t_2, (PyObject*)__pyx_t_18))) __PYX_ERR(1, 195, __pyx_L1_error)
9565         __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
9566       }
9567     } /* exit inner scope */
9568     __pyx_v_ekets = ((PyObject*)__pyx_t_2);
9569     __pyx_t_2 = 0;
9570 
9571     /* "qutip/cy/br_tensor.pyx":198
9572  *                dims=ket_dims) for k in range(nrows)]
9573  *
9574  *          return Qobj(L, dims=sop_dims, copy=False), ekets             # <<<<<<<<<<<<<<
9575  *
9576  *      #has some br operators and spectra
9577  */
9578     __Pyx_XDECREF(__pyx_r);
9579     __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_Qobj); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 198, __pyx_L1_error)
9580     __Pyx_GOTREF(__pyx_t_2);
9581     __pyx_t_18 = PyTuple_New(1); if (unlikely(!__pyx_t_18)) __PYX_ERR(1, 198, __pyx_L1_error)
9582     __Pyx_GOTREF(__pyx_t_18);
9583     __Pyx_INCREF(__pyx_v_L);
9584     __Pyx_GIVEREF(__pyx_v_L);
9585     PyTuple_SET_ITEM(__pyx_t_18, 0, __pyx_v_L);
9586     __pyx_t_1 = __Pyx_PyDict_NewPresized(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 198, __pyx_L1_error)
9587     __Pyx_GOTREF(__pyx_t_1);
9588     if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_dims, __pyx_v_sop_dims) < 0) __PYX_ERR(1, 198, __pyx_L1_error)
9589     if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_copy, Py_False) < 0) __PYX_ERR(1, 198, __pyx_L1_error)
9590     __pyx_t_16 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_18, __pyx_t_1); if (unlikely(!__pyx_t_16)) __PYX_ERR(1, 198, __pyx_L1_error)
9591     __Pyx_GOTREF(__pyx_t_16);
9592     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
9593     __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
9594     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
9595     __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 198, __pyx_L1_error)
9596     __Pyx_GOTREF(__pyx_t_1);
9597     __Pyx_GIVEREF(__pyx_t_16);
9598     PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_16);
9599     __Pyx_INCREF(__pyx_v_ekets);
9600     __Pyx_GIVEREF(__pyx_v_ekets);
9601     PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_v_ekets);
9602     __pyx_t_16 = 0;
9603     __pyx_r = __pyx_t_1;
9604     __pyx_t_1 = 0;
9605     goto __pyx_L0;
9606 
9607     /* "qutip/cy/br_tensor.pyx":194
9608  *
9609  *      #only lindblad collapse terms
9610  *      if K == 0:             # <<<<<<<<<<<<<<
9611  *          ekets = [Qobj(np.asarray(evecs[:,k]),
9612  *                dims=ket_dims) for k in range(nrows)]
9613  */
9614   }
9615 
9616   /* "qutip/cy/br_tensor.pyx":201
9617  *
9618  *      #has some br operators and spectra
9619  *      cdef double[:,::1] skew = np.zeros((nrows,nrows), dtype=float)             # <<<<<<<<<<<<<<
9620  *      cdef double dw_min = skew_and_dwmin(&evals[0], skew, nrows)
9621  *
9622  */
9623   __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_np); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 201, __pyx_L1_error)
9624   __Pyx_GOTREF(__pyx_t_1);
9625   __pyx_t_16 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_zeros); if (unlikely(!__pyx_t_16)) __PYX_ERR(1, 201, __pyx_L1_error)
9626   __Pyx_GOTREF(__pyx_t_16);
9627   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
9628   __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_nrows); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 201, __pyx_L1_error)
9629   __Pyx_GOTREF(__pyx_t_1);
9630   __pyx_t_18 = __Pyx_PyInt_From_int(__pyx_v_nrows); if (unlikely(!__pyx_t_18)) __PYX_ERR(1, 201, __pyx_L1_error)
9631   __Pyx_GOTREF(__pyx_t_18);
9632   __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 201, __pyx_L1_error)
9633   __Pyx_GOTREF(__pyx_t_2);
9634   __Pyx_GIVEREF(__pyx_t_1);
9635   PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_1);
9636   __Pyx_GIVEREF(__pyx_t_18);
9637   PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_t_18);
9638   __pyx_t_1 = 0;
9639   __pyx_t_18 = 0;
9640   __pyx_t_18 = PyTuple_New(1); if (unlikely(!__pyx_t_18)) __PYX_ERR(1, 201, __pyx_L1_error)
9641   __Pyx_GOTREF(__pyx_t_18);
9642   __Pyx_GIVEREF(__pyx_t_2);
9643   PyTuple_SET_ITEM(__pyx_t_18, 0, __pyx_t_2);
9644   __pyx_t_2 = 0;
9645   __pyx_t_2 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 201, __pyx_L1_error)
9646   __Pyx_GOTREF(__pyx_t_2);
9647   if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_dtype, ((PyObject *)(&PyFloat_Type))) < 0) __PYX_ERR(1, 201, __pyx_L1_error)
9648   __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_16, __pyx_t_18, __pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 201, __pyx_L1_error)
9649   __Pyx_GOTREF(__pyx_t_1);
9650   __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;
9651   __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
9652   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
9653   __pyx_t_22 = __Pyx_PyObject_to_MemoryviewSlice_d_dc_double(__pyx_t_1, PyBUF_WRITABLE); if (unlikely(!__pyx_t_22.memview)) __PYX_ERR(1, 201, __pyx_L1_error)
9654   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
9655   __pyx_v_skew = __pyx_t_22;
9656   __pyx_t_22.memview = NULL;
9657   __pyx_t_22.data = NULL;
9658 
9659   /* "qutip/cy/br_tensor.pyx":202
9660  *      #has some br operators and spectra
9661  *      cdef double[:,::1] skew = np.zeros((nrows,nrows), dtype=float)
9662  *      cdef double dw_min = skew_and_dwmin(&evals[0], skew, nrows)             # <<<<<<<<<<<<<<
9663  *
9664  *      for a in a_ops:
9665  */
9666   __pyx_t_13 = 0;
9667   __pyx_v_dw_min = __pyx_f_5qutip_2cy_7brtools_skew_and_dwmin((&(*((double *) ( /* dim=0 */ ((char *) (((double *) __pyx_v_evals.data) + __pyx_t_13)) )))), __pyx_v_skew, __pyx_v_nrows);
9668 
9669   /* "qutip/cy/br_tensor.pyx":204
9670  *      cdef double dw_min = skew_and_dwmin(&evals[0], skew, nrows)
9671  *
9672  *      for a in a_ops:             # <<<<<<<<<<<<<<
9673  *          L = L + _br_term(a[0].full('F'), evecs, skew, dw_min, a[1],
9674  *                         nrows, use_secular, sec_cutoff, atol)
9675  */
9676   if (unlikely(__pyx_v_a_ops == Py_None)) {
9677     PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable");
9678     __PYX_ERR(1, 204, __pyx_L1_error)
9679   }
9680   __pyx_t_1 = __pyx_v_a_ops; __Pyx_INCREF(__pyx_t_1); __pyx_t_5 = 0;
9681   for (;;) {
9682     if (__pyx_t_5 >= PyList_GET_SIZE(__pyx_t_1)) break;
9683     #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
9684     __pyx_t_2 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_5); __Pyx_INCREF(__pyx_t_2); __pyx_t_5++; if (unlikely(0 < 0)) __PYX_ERR(1, 204, __pyx_L1_error)
9685     #else
9686     __pyx_t_2 = PySequence_ITEM(__pyx_t_1, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 204, __pyx_L1_error)
9687     __Pyx_GOTREF(__pyx_t_2);
9688     #endif
9689     __Pyx_XDECREF_SET(__pyx_v_a, __pyx_t_2);
9690     __pyx_t_2 = 0;
9691 
9692     /* "qutip/cy/br_tensor.pyx":205
9693  *
9694  *      for a in a_ops:
9695  *          L = L + _br_term(a[0].full('F'), evecs, skew, dw_min, a[1],             # <<<<<<<<<<<<<<
9696  *                         nrows, use_secular, sec_cutoff, atol)
9697  *
9698  */
9699     __Pyx_GetModuleGlobalName(__pyx_t_18, __pyx_n_s_br_term); if (unlikely(!__pyx_t_18)) __PYX_ERR(1, 205, __pyx_L1_error)
9700     __Pyx_GOTREF(__pyx_t_18);
9701     __pyx_t_4 = __Pyx_GetItemInt(__pyx_v_a, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 205, __pyx_L1_error)
9702     __Pyx_GOTREF(__pyx_t_4);
9703     __pyx_t_15 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_full); if (unlikely(!__pyx_t_15)) __PYX_ERR(1, 205, __pyx_L1_error)
9704     __Pyx_GOTREF(__pyx_t_15);
9705     __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
9706     __pyx_t_4 = NULL;
9707     if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_15))) {
9708       __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_15);
9709       if (likely(__pyx_t_4)) {
9710         PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_15);
9711         __Pyx_INCREF(__pyx_t_4);
9712         __Pyx_INCREF(function);
9713         __Pyx_DECREF_SET(__pyx_t_15, function);
9714       }
9715     }
9716     __pyx_t_16 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_15, __pyx_t_4, __pyx_n_u_F) : __Pyx_PyObject_CallOneArg(__pyx_t_15, __pyx_n_u_F);
9717     __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
9718     if (unlikely(!__pyx_t_16)) __PYX_ERR(1, 205, __pyx_L1_error)
9719     __Pyx_GOTREF(__pyx_t_16);
9720     __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
9721     __pyx_t_15 = __pyx_memoryview_fromslice(__pyx_v_evecs, 2, (PyObject *(*)(char *)) __pyx_memview_get___pyx_t_double_complex, (int (*)(char *, PyObject *)) __pyx_memview_set___pyx_t_double_complex, 0);; if (unlikely(!__pyx_t_15)) __PYX_ERR(1, 205, __pyx_L1_error)
9722     __Pyx_GOTREF(__pyx_t_15);
9723     __pyx_t_4 = __pyx_memoryview_fromslice(__pyx_v_skew, 2, (PyObject *(*)(char *)) __pyx_memview_get_double, (int (*)(char *, PyObject *)) __pyx_memview_set_double, 0);; if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 205, __pyx_L1_error)
9724     __Pyx_GOTREF(__pyx_t_4);
9725     __pyx_t_14 = PyFloat_FromDouble(__pyx_v_dw_min); if (unlikely(!__pyx_t_14)) __PYX_ERR(1, 205, __pyx_L1_error)
9726     __Pyx_GOTREF(__pyx_t_14);
9727     __pyx_t_11 = __Pyx_GetItemInt(__pyx_v_a, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 0); if (unlikely(!__pyx_t_11)) __PYX_ERR(1, 205, __pyx_L1_error)
9728     __Pyx_GOTREF(__pyx_t_11);
9729 
9730     /* "qutip/cy/br_tensor.pyx":206
9731  *      for a in a_ops:
9732  *          L = L + _br_term(a[0].full('F'), evecs, skew, dw_min, a[1],
9733  *                         nrows, use_secular, sec_cutoff, atol)             # <<<<<<<<<<<<<<
9734  *
9735  *      ekets = [Qobj(np.asarray(evecs[:,k]),
9736  */
9737     __pyx_t_17 = __Pyx_PyInt_From_int(__pyx_v_nrows); if (unlikely(!__pyx_t_17)) __PYX_ERR(1, 206, __pyx_L1_error)
9738     __Pyx_GOTREF(__pyx_t_17);
9739     __pyx_t_23 = __Pyx_PyBool_FromLong(__pyx_v_use_secular); if (unlikely(!__pyx_t_23)) __PYX_ERR(1, 206, __pyx_L1_error)
9740     __Pyx_GOTREF(__pyx_t_23);
9741     __pyx_t_24 = PyFloat_FromDouble(__pyx_v_sec_cutoff); if (unlikely(!__pyx_t_24)) __PYX_ERR(1, 206, __pyx_L1_error)
9742     __Pyx_GOTREF(__pyx_t_24);
9743     __pyx_t_25 = PyFloat_FromDouble(__pyx_v_atol); if (unlikely(!__pyx_t_25)) __PYX_ERR(1, 206, __pyx_L1_error)
9744     __Pyx_GOTREF(__pyx_t_25);
9745     __pyx_t_26 = NULL;
9746     __pyx_t_3 = 0;
9747     if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_18))) {
9748       __pyx_t_26 = PyMethod_GET_SELF(__pyx_t_18);
9749       if (likely(__pyx_t_26)) {
9750         PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_18);
9751         __Pyx_INCREF(__pyx_t_26);
9752         __Pyx_INCREF(function);
9753         __Pyx_DECREF_SET(__pyx_t_18, function);
9754         __pyx_t_3 = 1;
9755       }
9756     }
9757     #if CYTHON_FAST_PYCALL
9758     if (PyFunction_Check(__pyx_t_18)) {
9759       PyObject *__pyx_temp[10] = {__pyx_t_26, __pyx_t_16, __pyx_t_15, __pyx_t_4, __pyx_t_14, __pyx_t_11, __pyx_t_17, __pyx_t_23, __pyx_t_24, __pyx_t_25};
9760       __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_18, __pyx_temp+1-__pyx_t_3, 9+__pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 205, __pyx_L1_error)
9761       __Pyx_XDECREF(__pyx_t_26); __pyx_t_26 = 0;
9762       __Pyx_GOTREF(__pyx_t_2);
9763       __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;
9764       __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
9765       __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
9766       __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
9767       __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
9768       __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
9769       __Pyx_DECREF(__pyx_t_23); __pyx_t_23 = 0;
9770       __Pyx_DECREF(__pyx_t_24); __pyx_t_24 = 0;
9771       __Pyx_DECREF(__pyx_t_25); __pyx_t_25 = 0;
9772     } else
9773     #endif
9774     #if CYTHON_FAST_PYCCALL
9775     if (__Pyx_PyFastCFunction_Check(__pyx_t_18)) {
9776       PyObject *__pyx_temp[10] = {__pyx_t_26, __pyx_t_16, __pyx_t_15, __pyx_t_4, __pyx_t_14, __pyx_t_11, __pyx_t_17, __pyx_t_23, __pyx_t_24, __pyx_t_25};
9777       __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_18, __pyx_temp+1-__pyx_t_3, 9+__pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 205, __pyx_L1_error)
9778       __Pyx_XDECREF(__pyx_t_26); __pyx_t_26 = 0;
9779       __Pyx_GOTREF(__pyx_t_2);
9780       __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;
9781       __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
9782       __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
9783       __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
9784       __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
9785       __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
9786       __Pyx_DECREF(__pyx_t_23); __pyx_t_23 = 0;
9787       __Pyx_DECREF(__pyx_t_24); __pyx_t_24 = 0;
9788       __Pyx_DECREF(__pyx_t_25); __pyx_t_25 = 0;
9789     } else
9790     #endif
9791     {
9792       __pyx_t_27 = PyTuple_New(9+__pyx_t_3); if (unlikely(!__pyx_t_27)) __PYX_ERR(1, 205, __pyx_L1_error)
9793       __Pyx_GOTREF(__pyx_t_27);
9794       if (__pyx_t_26) {
9795         __Pyx_GIVEREF(__pyx_t_26); PyTuple_SET_ITEM(__pyx_t_27, 0, __pyx_t_26); __pyx_t_26 = NULL;
9796       }
9797       __Pyx_GIVEREF(__pyx_t_16);
9798       PyTuple_SET_ITEM(__pyx_t_27, 0+__pyx_t_3, __pyx_t_16);
9799       __Pyx_GIVEREF(__pyx_t_15);
9800       PyTuple_SET_ITEM(__pyx_t_27, 1+__pyx_t_3, __pyx_t_15);
9801       __Pyx_GIVEREF(__pyx_t_4);
9802       PyTuple_SET_ITEM(__pyx_t_27, 2+__pyx_t_3, __pyx_t_4);
9803       __Pyx_GIVEREF(__pyx_t_14);
9804       PyTuple_SET_ITEM(__pyx_t_27, 3+__pyx_t_3, __pyx_t_14);
9805       __Pyx_GIVEREF(__pyx_t_11);
9806       PyTuple_SET_ITEM(__pyx_t_27, 4+__pyx_t_3, __pyx_t_11);
9807       __Pyx_GIVEREF(__pyx_t_17);
9808       PyTuple_SET_ITEM(__pyx_t_27, 5+__pyx_t_3, __pyx_t_17);
9809       __Pyx_GIVEREF(__pyx_t_23);
9810       PyTuple_SET_ITEM(__pyx_t_27, 6+__pyx_t_3, __pyx_t_23);
9811       __Pyx_GIVEREF(__pyx_t_24);
9812       PyTuple_SET_ITEM(__pyx_t_27, 7+__pyx_t_3, __pyx_t_24);
9813       __Pyx_GIVEREF(__pyx_t_25);
9814       PyTuple_SET_ITEM(__pyx_t_27, 8+__pyx_t_3, __pyx_t_25);
9815       __pyx_t_16 = 0;
9816       __pyx_t_15 = 0;
9817       __pyx_t_4 = 0;
9818       __pyx_t_14 = 0;
9819       __pyx_t_11 = 0;
9820       __pyx_t_17 = 0;
9821       __pyx_t_23 = 0;
9822       __pyx_t_24 = 0;
9823       __pyx_t_25 = 0;
9824       __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_18, __pyx_t_27, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 205, __pyx_L1_error)
9825       __Pyx_GOTREF(__pyx_t_2);
9826       __Pyx_DECREF(__pyx_t_27); __pyx_t_27 = 0;
9827     }
9828     __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
9829 
9830     /* "qutip/cy/br_tensor.pyx":205
9831  *
9832  *      for a in a_ops:
9833  *          L = L + _br_term(a[0].full('F'), evecs, skew, dw_min, a[1],             # <<<<<<<<<<<<<<
9834  *                         nrows, use_secular, sec_cutoff, atol)
9835  *
9836  */
9837     __pyx_t_18 = PyNumber_Add(__pyx_v_L, __pyx_t_2); if (unlikely(!__pyx_t_18)) __PYX_ERR(1, 205, __pyx_L1_error)
9838     __Pyx_GOTREF(__pyx_t_18);
9839     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
9840     __Pyx_DECREF_SET(__pyx_v_L, __pyx_t_18);
9841     __pyx_t_18 = 0;
9842 
9843     /* "qutip/cy/br_tensor.pyx":204
9844  *      cdef double dw_min = skew_and_dwmin(&evals[0], skew, nrows)
9845  *
9846  *      for a in a_ops:             # <<<<<<<<<<<<<<
9847  *          L = L + _br_term(a[0].full('F'), evecs, skew, dw_min, a[1],
9848  *                         nrows, use_secular, sec_cutoff, atol)
9849  */
9850   }
9851   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
9852 
9853   /* "qutip/cy/br_tensor.pyx":208
9854  *                         nrows, use_secular, sec_cutoff, atol)
9855  *
9856  *      ekets = [Qobj(np.asarray(evecs[:,k]),             # <<<<<<<<<<<<<<
9857  *                    dims=ket_dims) for k in range(nrows)]
9858  *
9859  */
9860   { /* enter inner scope */
9861     __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 208, __pyx_L1_error)
9862     __Pyx_GOTREF(__pyx_t_1);
9863 
9864     /* "qutip/cy/br_tensor.pyx":209
9865  *
9866  *      ekets = [Qobj(np.asarray(evecs[:,k]),
9867  *                    dims=ket_dims) for k in range(nrows)]             # <<<<<<<<<<<<<<
9868  *
9869  *
9870  */
9871     __pyx_t_3 = __pyx_v_nrows;
9872     __pyx_t_19 = __pyx_t_3;
9873     for (__pyx_t_20 = 0; __pyx_t_20 < __pyx_t_19; __pyx_t_20+=1) {
9874       __pyx_8genexpr1__pyx_v_k = __pyx_t_20;
9875 
9876       /* "qutip/cy/br_tensor.pyx":208
9877  *                         nrows, use_secular, sec_cutoff, atol)
9878  *
9879  *      ekets = [Qobj(np.asarray(evecs[:,k]),             # <<<<<<<<<<<<<<
9880  *                    dims=ket_dims) for k in range(nrows)]
9881  *
9882  */
9883       __Pyx_GetModuleGlobalName(__pyx_t_18, __pyx_n_s_Qobj); if (unlikely(!__pyx_t_18)) __PYX_ERR(1, 208, __pyx_L1_error)
9884       __Pyx_GOTREF(__pyx_t_18);
9885       __Pyx_GetModuleGlobalName(__pyx_t_27, __pyx_n_s_np); if (unlikely(!__pyx_t_27)) __PYX_ERR(1, 208, __pyx_L1_error)
9886       __Pyx_GOTREF(__pyx_t_27);
9887       __pyx_t_25 = __Pyx_PyObject_GetAttrStr(__pyx_t_27, __pyx_n_s_asarray); if (unlikely(!__pyx_t_25)) __PYX_ERR(1, 208, __pyx_L1_error)
9888       __Pyx_GOTREF(__pyx_t_25);
9889       __Pyx_DECREF(__pyx_t_27); __pyx_t_27 = 0;
9890       __pyx_t_21.data = __pyx_v_evecs.data;
9891       __pyx_t_21.memview = __pyx_v_evecs.memview;
9892       __PYX_INC_MEMVIEW(&__pyx_t_21, 0);
9893       __pyx_t_21.shape[0] = __pyx_v_evecs.shape[0];
9894 __pyx_t_21.strides[0] = __pyx_v_evecs.strides[0];
9895     __pyx_t_21.suboffsets[0] = -1;
9896 
9897 {
9898     Py_ssize_t __pyx_tmp_idx = __pyx_8genexpr1__pyx_v_k;
9899     Py_ssize_t __pyx_tmp_stride = __pyx_v_evecs.strides[1];
9900         __pyx_t_21.data += __pyx_tmp_idx * __pyx_tmp_stride;
9901 }
9902 
9903 __pyx_t_27 = __pyx_memoryview_fromslice(__pyx_t_21, 1, (PyObject *(*)(char *)) __pyx_memview_get___pyx_t_double_complex, (int (*)(char *, PyObject *)) __pyx_memview_set___pyx_t_double_complex, 0);; if (unlikely(!__pyx_t_27)) __PYX_ERR(1, 208, __pyx_L1_error)
9904       __Pyx_GOTREF(__pyx_t_27);
9905       __PYX_XDEC_MEMVIEW(&__pyx_t_21, 1);
9906       __pyx_t_21.memview = NULL;
9907       __pyx_t_21.data = NULL;
9908       __pyx_t_24 = NULL;
9909       if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_25))) {
9910         __pyx_t_24 = PyMethod_GET_SELF(__pyx_t_25);
9911         if (likely(__pyx_t_24)) {
9912           PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_25);
9913           __Pyx_INCREF(__pyx_t_24);
9914           __Pyx_INCREF(function);
9915           __Pyx_DECREF_SET(__pyx_t_25, function);
9916         }
9917       }
9918       __pyx_t_2 = (__pyx_t_24) ? __Pyx_PyObject_Call2Args(__pyx_t_25, __pyx_t_24, __pyx_t_27) : __Pyx_PyObject_CallOneArg(__pyx_t_25, __pyx_t_27);
9919       __Pyx_XDECREF(__pyx_t_24); __pyx_t_24 = 0;
9920       __Pyx_DECREF(__pyx_t_27); __pyx_t_27 = 0;
9921       if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 208, __pyx_L1_error)
9922       __Pyx_GOTREF(__pyx_t_2);
9923       __Pyx_DECREF(__pyx_t_25); __pyx_t_25 = 0;
9924       __pyx_t_25 = PyTuple_New(1); if (unlikely(!__pyx_t_25)) __PYX_ERR(1, 208, __pyx_L1_error)
9925       __Pyx_GOTREF(__pyx_t_25);
9926       __Pyx_GIVEREF(__pyx_t_2);
9927       PyTuple_SET_ITEM(__pyx_t_25, 0, __pyx_t_2);
9928       __pyx_t_2 = 0;
9929 
9930       /* "qutip/cy/br_tensor.pyx":209
9931  *
9932  *      ekets = [Qobj(np.asarray(evecs[:,k]),
9933  *                    dims=ket_dims) for k in range(nrows)]             # <<<<<<<<<<<<<<
9934  *
9935  *
9936  */
9937       __pyx_t_2 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 209, __pyx_L1_error)
9938       __Pyx_GOTREF(__pyx_t_2);
9939       if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_dims, __pyx_v_ket_dims) < 0) __PYX_ERR(1, 209, __pyx_L1_error)
9940 
9941       /* "qutip/cy/br_tensor.pyx":208
9942  *                         nrows, use_secular, sec_cutoff, atol)
9943  *
9944  *      ekets = [Qobj(np.asarray(evecs[:,k]),             # <<<<<<<<<<<<<<
9945  *                    dims=ket_dims) for k in range(nrows)]
9946  *
9947  */
9948       __pyx_t_27 = __Pyx_PyObject_Call(__pyx_t_18, __pyx_t_25, __pyx_t_2); if (unlikely(!__pyx_t_27)) __PYX_ERR(1, 208, __pyx_L1_error)
9949       __Pyx_GOTREF(__pyx_t_27);
9950       __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
9951       __Pyx_DECREF(__pyx_t_25); __pyx_t_25 = 0;
9952       __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
9953       if (unlikely(__Pyx_ListComp_Append(__pyx_t_1, (PyObject*)__pyx_t_27))) __PYX_ERR(1, 208, __pyx_L1_error)
9954       __Pyx_DECREF(__pyx_t_27); __pyx_t_27 = 0;
9955     }
9956   } /* exit inner scope */
9957   __pyx_v_ekets = ((PyObject*)__pyx_t_1);
9958   __pyx_t_1 = 0;
9959 
9960   /* "qutip/cy/br_tensor.pyx":212
9961  *
9962  *
9963  *      return Qobj(L, dims=sop_dims, copy=False), ekets             # <<<<<<<<<<<<<<
9964  */
9965   __Pyx_XDECREF(__pyx_r);
9966   __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_Qobj); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 212, __pyx_L1_error)
9967   __Pyx_GOTREF(__pyx_t_1);
9968   __pyx_t_27 = PyTuple_New(1); if (unlikely(!__pyx_t_27)) __PYX_ERR(1, 212, __pyx_L1_error)
9969   __Pyx_GOTREF(__pyx_t_27);
9970   __Pyx_INCREF(__pyx_v_L);
9971   __Pyx_GIVEREF(__pyx_v_L);
9972   PyTuple_SET_ITEM(__pyx_t_27, 0, __pyx_v_L);
9973   __pyx_t_2 = __Pyx_PyDict_NewPresized(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 212, __pyx_L1_error)
9974   __Pyx_GOTREF(__pyx_t_2);
9975   if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_dims, __pyx_v_sop_dims) < 0) __PYX_ERR(1, 212, __pyx_L1_error)
9976   if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_copy, Py_False) < 0) __PYX_ERR(1, 212, __pyx_L1_error)
9977   __pyx_t_25 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_27, __pyx_t_2); if (unlikely(!__pyx_t_25)) __PYX_ERR(1, 212, __pyx_L1_error)
9978   __Pyx_GOTREF(__pyx_t_25);
9979   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
9980   __Pyx_DECREF(__pyx_t_27); __pyx_t_27 = 0;
9981   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
9982   __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 212, __pyx_L1_error)
9983   __Pyx_GOTREF(__pyx_t_2);
9984   __Pyx_GIVEREF(__pyx_t_25);
9985   PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_25);
9986   __Pyx_INCREF(__pyx_v_ekets);
9987   __Pyx_GIVEREF(__pyx_v_ekets);
9988   PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_v_ekets);
9989   __pyx_t_25 = 0;
9990   __pyx_r = __pyx_t_2;
9991   __pyx_t_2 = 0;
9992   goto __pyx_L0;
9993 
9994   /* "qutip/cy/br_tensor.pyx":110
9995  * @cython.boundscheck(False)
9996  * @cython.wraparound(False)
9997  * def bloch_redfield_tensor(object H, list a_ops, spectra_cb=None,             # <<<<<<<<<<<<<<
9998  *                  list c_ops=[], bool use_secular=True,
9999  *                  double sec_cutoff=0.1,
10000  */
10001 
10002   /* function exit code */
10003   __pyx_L1_error:;
10004   __Pyx_XDECREF(__pyx_t_1);
10005   __Pyx_XDECREF(__pyx_t_2);
10006   __Pyx_XDECREF(__pyx_t_4);
10007   __PYX_XDEC_MEMVIEW(&__pyx_t_10, 1);
10008   __Pyx_XDECREF(__pyx_t_11);
10009   __PYX_XDEC_MEMVIEW(&__pyx_t_12, 1);
10010   __Pyx_XDECREF(__pyx_t_14);
10011   __Pyx_XDECREF(__pyx_t_15);
10012   __Pyx_XDECREF(__pyx_t_16);
10013   __Pyx_XDECREF(__pyx_t_17);
10014   __Pyx_XDECREF(__pyx_t_18);
10015   __PYX_XDEC_MEMVIEW(&__pyx_t_21, 1);
10016   __PYX_XDEC_MEMVIEW(&__pyx_t_22, 1);
10017   __Pyx_XDECREF(__pyx_t_23);
10018   __Pyx_XDECREF(__pyx_t_24);
10019   __Pyx_XDECREF(__pyx_t_25);
10020   __Pyx_XDECREF(__pyx_t_26);
10021   __Pyx_XDECREF(__pyx_t_27);
10022   __Pyx_AddTraceback("qutip.cy.br_tensor.bloch_redfield_tensor", __pyx_clineno, __pyx_lineno, __pyx_filename);
10023   __pyx_r = NULL;
10024   __pyx_L0:;
10025   __Pyx_XDECREF(__pyx_v__a_ops);
10026   __Pyx_XDECREF(__pyx_v_a);
10027   __Pyx_XDECREF(__pyx_v_cop);
10028   __Pyx_XDECREF(__pyx_v_L);
10029   __Pyx_XDECREF(__pyx_v_op_dims);
10030   __Pyx_XDECREF(__pyx_v_sop_dims);
10031   __Pyx_XDECREF(__pyx_v_ekets);
10032   __Pyx_XDECREF(__pyx_v_ket_dims);
10033   __PYX_XDEC_MEMVIEW(&__pyx_v_H0, 1);
10034   __PYX_XDEC_MEMVIEW(&__pyx_v_evecs, 1);
10035   __PYX_XDEC_MEMVIEW(&__pyx_v_evals, 1);
10036   __PYX_XDEC_MEMVIEW(&__pyx_v_skew, 1);
10037   __Pyx_XDECREF(__pyx_v_a_ops);
10038   __Pyx_XGIVEREF(__pyx_r);
10039   __Pyx_RefNannyFinishContext();
10040   return __pyx_r;
10041 }
10042 
10043 /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":734
10044  * ctypedef npy_cdouble     complex_t
10045  *
10046  * cdef inline object PyArray_MultiIterNew1(a):             # <<<<<<<<<<<<<<
10047  *     return PyArray_MultiIterNew(1, <void*>a)
10048  *
10049  */
10050 
__pyx_f_5numpy_PyArray_MultiIterNew1(PyObject * __pyx_v_a)10051 static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew1(PyObject *__pyx_v_a) {
10052   PyObject *__pyx_r = NULL;
10053   __Pyx_RefNannyDeclarations
10054   PyObject *__pyx_t_1 = NULL;
10055   int __pyx_lineno = 0;
10056   const char *__pyx_filename = NULL;
10057   int __pyx_clineno = 0;
10058   __Pyx_RefNannySetupContext("PyArray_MultiIterNew1", 0);
10059 
10060   /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":735
10061  *
10062  * cdef inline object PyArray_MultiIterNew1(a):
10063  *     return PyArray_MultiIterNew(1, <void*>a)             # <<<<<<<<<<<<<<
10064  *
10065  * cdef inline object PyArray_MultiIterNew2(a, b):
10066  */
10067   __Pyx_XDECREF(__pyx_r);
10068   __pyx_t_1 = PyArray_MultiIterNew(1, ((void *)__pyx_v_a)); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 735, __pyx_L1_error)
10069   __Pyx_GOTREF(__pyx_t_1);
10070   __pyx_r = __pyx_t_1;
10071   __pyx_t_1 = 0;
10072   goto __pyx_L0;
10073 
10074   /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":734
10075  * ctypedef npy_cdouble     complex_t
10076  *
10077  * cdef inline object PyArray_MultiIterNew1(a):             # <<<<<<<<<<<<<<
10078  *     return PyArray_MultiIterNew(1, <void*>a)
10079  *
10080  */
10081 
10082   /* function exit code */
10083   __pyx_L1_error:;
10084   __Pyx_XDECREF(__pyx_t_1);
10085   __Pyx_AddTraceback("numpy.PyArray_MultiIterNew1", __pyx_clineno, __pyx_lineno, __pyx_filename);
10086   __pyx_r = 0;
10087   __pyx_L0:;
10088   __Pyx_XGIVEREF(__pyx_r);
10089   __Pyx_RefNannyFinishContext();
10090   return __pyx_r;
10091 }
10092 
10093 /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":737
10094  *     return PyArray_MultiIterNew(1, <void*>a)
10095  *
10096  * cdef inline object PyArray_MultiIterNew2(a, b):             # <<<<<<<<<<<<<<
10097  *     return PyArray_MultiIterNew(2, <void*>a, <void*>b)
10098  *
10099  */
10100 
__pyx_f_5numpy_PyArray_MultiIterNew2(PyObject * __pyx_v_a,PyObject * __pyx_v_b)10101 static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew2(PyObject *__pyx_v_a, PyObject *__pyx_v_b) {
10102   PyObject *__pyx_r = NULL;
10103   __Pyx_RefNannyDeclarations
10104   PyObject *__pyx_t_1 = NULL;
10105   int __pyx_lineno = 0;
10106   const char *__pyx_filename = NULL;
10107   int __pyx_clineno = 0;
10108   __Pyx_RefNannySetupContext("PyArray_MultiIterNew2", 0);
10109 
10110   /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":738
10111  *
10112  * cdef inline object PyArray_MultiIterNew2(a, b):
10113  *     return PyArray_MultiIterNew(2, <void*>a, <void*>b)             # <<<<<<<<<<<<<<
10114  *
10115  * cdef inline object PyArray_MultiIterNew3(a, b, c):
10116  */
10117   __Pyx_XDECREF(__pyx_r);
10118   __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)
10119   __Pyx_GOTREF(__pyx_t_1);
10120   __pyx_r = __pyx_t_1;
10121   __pyx_t_1 = 0;
10122   goto __pyx_L0;
10123 
10124   /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":737
10125  *     return PyArray_MultiIterNew(1, <void*>a)
10126  *
10127  * cdef inline object PyArray_MultiIterNew2(a, b):             # <<<<<<<<<<<<<<
10128  *     return PyArray_MultiIterNew(2, <void*>a, <void*>b)
10129  *
10130  */
10131 
10132   /* function exit code */
10133   __pyx_L1_error:;
10134   __Pyx_XDECREF(__pyx_t_1);
10135   __Pyx_AddTraceback("numpy.PyArray_MultiIterNew2", __pyx_clineno, __pyx_lineno, __pyx_filename);
10136   __pyx_r = 0;
10137   __pyx_L0:;
10138   __Pyx_XGIVEREF(__pyx_r);
10139   __Pyx_RefNannyFinishContext();
10140   return __pyx_r;
10141 }
10142 
10143 /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":740
10144  *     return PyArray_MultiIterNew(2, <void*>a, <void*>b)
10145  *
10146  * cdef inline object PyArray_MultiIterNew3(a, b, c):             # <<<<<<<<<<<<<<
10147  *     return PyArray_MultiIterNew(3, <void*>a, <void*>b, <void*> c)
10148  *
10149  */
10150 
__pyx_f_5numpy_PyArray_MultiIterNew3(PyObject * __pyx_v_a,PyObject * __pyx_v_b,PyObject * __pyx_v_c)10151 static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew3(PyObject *__pyx_v_a, PyObject *__pyx_v_b, PyObject *__pyx_v_c) {
10152   PyObject *__pyx_r = NULL;
10153   __Pyx_RefNannyDeclarations
10154   PyObject *__pyx_t_1 = NULL;
10155   int __pyx_lineno = 0;
10156   const char *__pyx_filename = NULL;
10157   int __pyx_clineno = 0;
10158   __Pyx_RefNannySetupContext("PyArray_MultiIterNew3", 0);
10159 
10160   /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":741
10161  *
10162  * cdef inline object PyArray_MultiIterNew3(a, b, c):
10163  *     return PyArray_MultiIterNew(3, <void*>a, <void*>b, <void*> c)             # <<<<<<<<<<<<<<
10164  *
10165  * cdef inline object PyArray_MultiIterNew4(a, b, c, d):
10166  */
10167   __Pyx_XDECREF(__pyx_r);
10168   __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)
10169   __Pyx_GOTREF(__pyx_t_1);
10170   __pyx_r = __pyx_t_1;
10171   __pyx_t_1 = 0;
10172   goto __pyx_L0;
10173 
10174   /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":740
10175  *     return PyArray_MultiIterNew(2, <void*>a, <void*>b)
10176  *
10177  * cdef inline object PyArray_MultiIterNew3(a, b, c):             # <<<<<<<<<<<<<<
10178  *     return PyArray_MultiIterNew(3, <void*>a, <void*>b, <void*> c)
10179  *
10180  */
10181 
10182   /* function exit code */
10183   __pyx_L1_error:;
10184   __Pyx_XDECREF(__pyx_t_1);
10185   __Pyx_AddTraceback("numpy.PyArray_MultiIterNew3", __pyx_clineno, __pyx_lineno, __pyx_filename);
10186   __pyx_r = 0;
10187   __pyx_L0:;
10188   __Pyx_XGIVEREF(__pyx_r);
10189   __Pyx_RefNannyFinishContext();
10190   return __pyx_r;
10191 }
10192 
10193 /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":743
10194  *     return PyArray_MultiIterNew(3, <void*>a, <void*>b, <void*> c)
10195  *
10196  * cdef inline object PyArray_MultiIterNew4(a, b, c, d):             # <<<<<<<<<<<<<<
10197  *     return PyArray_MultiIterNew(4, <void*>a, <void*>b, <void*>c, <void*> d)
10198  *
10199  */
10200 
__pyx_f_5numpy_PyArray_MultiIterNew4(PyObject * __pyx_v_a,PyObject * __pyx_v_b,PyObject * __pyx_v_c,PyObject * __pyx_v_d)10201 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) {
10202   PyObject *__pyx_r = NULL;
10203   __Pyx_RefNannyDeclarations
10204   PyObject *__pyx_t_1 = NULL;
10205   int __pyx_lineno = 0;
10206   const char *__pyx_filename = NULL;
10207   int __pyx_clineno = 0;
10208   __Pyx_RefNannySetupContext("PyArray_MultiIterNew4", 0);
10209 
10210   /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":744
10211  *
10212  * cdef inline object PyArray_MultiIterNew4(a, b, c, d):
10213  *     return PyArray_MultiIterNew(4, <void*>a, <void*>b, <void*>c, <void*> d)             # <<<<<<<<<<<<<<
10214  *
10215  * cdef inline object PyArray_MultiIterNew5(a, b, c, d, e):
10216  */
10217   __Pyx_XDECREF(__pyx_r);
10218   __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)
10219   __Pyx_GOTREF(__pyx_t_1);
10220   __pyx_r = __pyx_t_1;
10221   __pyx_t_1 = 0;
10222   goto __pyx_L0;
10223 
10224   /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":743
10225  *     return PyArray_MultiIterNew(3, <void*>a, <void*>b, <void*> c)
10226  *
10227  * cdef inline object PyArray_MultiIterNew4(a, b, c, d):             # <<<<<<<<<<<<<<
10228  *     return PyArray_MultiIterNew(4, <void*>a, <void*>b, <void*>c, <void*> d)
10229  *
10230  */
10231 
10232   /* function exit code */
10233   __pyx_L1_error:;
10234   __Pyx_XDECREF(__pyx_t_1);
10235   __Pyx_AddTraceback("numpy.PyArray_MultiIterNew4", __pyx_clineno, __pyx_lineno, __pyx_filename);
10236   __pyx_r = 0;
10237   __pyx_L0:;
10238   __Pyx_XGIVEREF(__pyx_r);
10239   __Pyx_RefNannyFinishContext();
10240   return __pyx_r;
10241 }
10242 
10243 /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":746
10244  *     return PyArray_MultiIterNew(4, <void*>a, <void*>b, <void*>c, <void*> d)
10245  *
10246  * cdef inline object PyArray_MultiIterNew5(a, b, c, d, e):             # <<<<<<<<<<<<<<
10247  *     return PyArray_MultiIterNew(5, <void*>a, <void*>b, <void*>c, <void*> d, <void*> e)
10248  *
10249  */
10250 
__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)10251 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) {
10252   PyObject *__pyx_r = NULL;
10253   __Pyx_RefNannyDeclarations
10254   PyObject *__pyx_t_1 = NULL;
10255   int __pyx_lineno = 0;
10256   const char *__pyx_filename = NULL;
10257   int __pyx_clineno = 0;
10258   __Pyx_RefNannySetupContext("PyArray_MultiIterNew5", 0);
10259 
10260   /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":747
10261  *
10262  * cdef inline object PyArray_MultiIterNew5(a, b, c, d, e):
10263  *     return PyArray_MultiIterNew(5, <void*>a, <void*>b, <void*>c, <void*> d, <void*> e)             # <<<<<<<<<<<<<<
10264  *
10265  * cdef inline tuple PyDataType_SHAPE(dtype d):
10266  */
10267   __Pyx_XDECREF(__pyx_r);
10268   __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)
10269   __Pyx_GOTREF(__pyx_t_1);
10270   __pyx_r = __pyx_t_1;
10271   __pyx_t_1 = 0;
10272   goto __pyx_L0;
10273 
10274   /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":746
10275  *     return PyArray_MultiIterNew(4, <void*>a, <void*>b, <void*>c, <void*> d)
10276  *
10277  * cdef inline object PyArray_MultiIterNew5(a, b, c, d, e):             # <<<<<<<<<<<<<<
10278  *     return PyArray_MultiIterNew(5, <void*>a, <void*>b, <void*>c, <void*> d, <void*> e)
10279  *
10280  */
10281 
10282   /* function exit code */
10283   __pyx_L1_error:;
10284   __Pyx_XDECREF(__pyx_t_1);
10285   __Pyx_AddTraceback("numpy.PyArray_MultiIterNew5", __pyx_clineno, __pyx_lineno, __pyx_filename);
10286   __pyx_r = 0;
10287   __pyx_L0:;
10288   __Pyx_XGIVEREF(__pyx_r);
10289   __Pyx_RefNannyFinishContext();
10290   return __pyx_r;
10291 }
10292 
10293 /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":749
10294  *     return PyArray_MultiIterNew(5, <void*>a, <void*>b, <void*>c, <void*> d, <void*> e)
10295  *
10296  * cdef inline tuple PyDataType_SHAPE(dtype d):             # <<<<<<<<<<<<<<
10297  *     if PyDataType_HASSUBARRAY(d):
10298  *         return <tuple>d.subarray.shape
10299  */
10300 
__pyx_f_5numpy_PyDataType_SHAPE(PyArray_Descr * __pyx_v_d)10301 static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyDataType_SHAPE(PyArray_Descr *__pyx_v_d) {
10302   PyObject *__pyx_r = NULL;
10303   __Pyx_RefNannyDeclarations
10304   int __pyx_t_1;
10305   __Pyx_RefNannySetupContext("PyDataType_SHAPE", 0);
10306 
10307   /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":750
10308  *
10309  * cdef inline tuple PyDataType_SHAPE(dtype d):
10310  *     if PyDataType_HASSUBARRAY(d):             # <<<<<<<<<<<<<<
10311  *         return <tuple>d.subarray.shape
10312  *     else:
10313  */
10314   __pyx_t_1 = (PyDataType_HASSUBARRAY(__pyx_v_d) != 0);
10315   if (__pyx_t_1) {
10316 
10317     /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":751
10318  * cdef inline tuple PyDataType_SHAPE(dtype d):
10319  *     if PyDataType_HASSUBARRAY(d):
10320  *         return <tuple>d.subarray.shape             # <<<<<<<<<<<<<<
10321  *     else:
10322  *         return ()
10323  */
10324     __Pyx_XDECREF(__pyx_r);
10325     __Pyx_INCREF(((PyObject*)__pyx_v_d->subarray->shape));
10326     __pyx_r = ((PyObject*)__pyx_v_d->subarray->shape);
10327     goto __pyx_L0;
10328 
10329     /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":750
10330  *
10331  * cdef inline tuple PyDataType_SHAPE(dtype d):
10332  *     if PyDataType_HASSUBARRAY(d):             # <<<<<<<<<<<<<<
10333  *         return <tuple>d.subarray.shape
10334  *     else:
10335  */
10336   }
10337 
10338   /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":753
10339  *         return <tuple>d.subarray.shape
10340  *     else:
10341  *         return ()             # <<<<<<<<<<<<<<
10342  *
10343  *
10344  */
10345   /*else*/ {
10346     __Pyx_XDECREF(__pyx_r);
10347     __Pyx_INCREF(__pyx_empty_tuple);
10348     __pyx_r = __pyx_empty_tuple;
10349     goto __pyx_L0;
10350   }
10351 
10352   /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":749
10353  *     return PyArray_MultiIterNew(5, <void*>a, <void*>b, <void*>c, <void*> d, <void*> e)
10354  *
10355  * cdef inline tuple PyDataType_SHAPE(dtype d):             # <<<<<<<<<<<<<<
10356  *     if PyDataType_HASSUBARRAY(d):
10357  *         return <tuple>d.subarray.shape
10358  */
10359 
10360   /* function exit code */
10361   __pyx_L0:;
10362   __Pyx_XGIVEREF(__pyx_r);
10363   __Pyx_RefNannyFinishContext();
10364   return __pyx_r;
10365 }
10366 
10367 /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":868
10368  *     int _import_umath() except -1
10369  *
10370  * cdef inline void set_array_base(ndarray arr, object base):             # <<<<<<<<<<<<<<
10371  *     Py_INCREF(base) # important to do this before stealing the reference below!
10372  *     PyArray_SetBaseObject(arr, base)
10373  */
10374 
__pyx_f_5numpy_set_array_base(PyArrayObject * __pyx_v_arr,PyObject * __pyx_v_base)10375 static CYTHON_INLINE void __pyx_f_5numpy_set_array_base(PyArrayObject *__pyx_v_arr, PyObject *__pyx_v_base) {
10376   __Pyx_RefNannyDeclarations
10377   __Pyx_RefNannySetupContext("set_array_base", 0);
10378 
10379   /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":869
10380  *
10381  * cdef inline void set_array_base(ndarray arr, object base):
10382  *     Py_INCREF(base) # important to do this before stealing the reference below!             # <<<<<<<<<<<<<<
10383  *     PyArray_SetBaseObject(arr, base)
10384  *
10385  */
10386   Py_INCREF(__pyx_v_base);
10387 
10388   /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":870
10389  * cdef inline void set_array_base(ndarray arr, object base):
10390  *     Py_INCREF(base) # important to do this before stealing the reference below!
10391  *     PyArray_SetBaseObject(arr, base)             # <<<<<<<<<<<<<<
10392  *
10393  * cdef inline object get_array_base(ndarray arr):
10394  */
10395   (void)(PyArray_SetBaseObject(__pyx_v_arr, __pyx_v_base));
10396 
10397   /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":868
10398  *     int _import_umath() except -1
10399  *
10400  * cdef inline void set_array_base(ndarray arr, object base):             # <<<<<<<<<<<<<<
10401  *     Py_INCREF(base) # important to do this before stealing the reference below!
10402  *     PyArray_SetBaseObject(arr, base)
10403  */
10404 
10405   /* function exit code */
10406   __Pyx_RefNannyFinishContext();
10407 }
10408 
10409 /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":872
10410  *     PyArray_SetBaseObject(arr, base)
10411  *
10412  * cdef inline object get_array_base(ndarray arr):             # <<<<<<<<<<<<<<
10413  *     base = PyArray_BASE(arr)
10414  *     if base is NULL:
10415  */
10416 
__pyx_f_5numpy_get_array_base(PyArrayObject * __pyx_v_arr)10417 static CYTHON_INLINE PyObject *__pyx_f_5numpy_get_array_base(PyArrayObject *__pyx_v_arr) {
10418   PyObject *__pyx_v_base;
10419   PyObject *__pyx_r = NULL;
10420   __Pyx_RefNannyDeclarations
10421   int __pyx_t_1;
10422   __Pyx_RefNannySetupContext("get_array_base", 0);
10423 
10424   /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":873
10425  *
10426  * cdef inline object get_array_base(ndarray arr):
10427  *     base = PyArray_BASE(arr)             # <<<<<<<<<<<<<<
10428  *     if base is NULL:
10429  *         return None
10430  */
10431   __pyx_v_base = PyArray_BASE(__pyx_v_arr);
10432 
10433   /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":874
10434  * cdef inline object get_array_base(ndarray arr):
10435  *     base = PyArray_BASE(arr)
10436  *     if base is NULL:             # <<<<<<<<<<<<<<
10437  *         return None
10438  *     return <object>base
10439  */
10440   __pyx_t_1 = ((__pyx_v_base == NULL) != 0);
10441   if (__pyx_t_1) {
10442 
10443     /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":875
10444  *     base = PyArray_BASE(arr)
10445  *     if base is NULL:
10446  *         return None             # <<<<<<<<<<<<<<
10447  *     return <object>base
10448  *
10449  */
10450     __Pyx_XDECREF(__pyx_r);
10451     __pyx_r = Py_None; __Pyx_INCREF(Py_None);
10452     goto __pyx_L0;
10453 
10454     /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":874
10455  * cdef inline object get_array_base(ndarray arr):
10456  *     base = PyArray_BASE(arr)
10457  *     if base is NULL:             # <<<<<<<<<<<<<<
10458  *         return None
10459  *     return <object>base
10460  */
10461   }
10462 
10463   /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":876
10464  *     if base is NULL:
10465  *         return None
10466  *     return <object>base             # <<<<<<<<<<<<<<
10467  *
10468  * # Versions of the import_* functions which are more suitable for
10469  */
10470   __Pyx_XDECREF(__pyx_r);
10471   __Pyx_INCREF(((PyObject *)__pyx_v_base));
10472   __pyx_r = ((PyObject *)__pyx_v_base);
10473   goto __pyx_L0;
10474 
10475   /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":872
10476  *     PyArray_SetBaseObject(arr, base)
10477  *
10478  * cdef inline object get_array_base(ndarray arr):             # <<<<<<<<<<<<<<
10479  *     base = PyArray_BASE(arr)
10480  *     if base is NULL:
10481  */
10482 
10483   /* function exit code */
10484   __pyx_L0:;
10485   __Pyx_XGIVEREF(__pyx_r);
10486   __Pyx_RefNannyFinishContext();
10487   return __pyx_r;
10488 }
10489 
10490 /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":880
10491  * # Versions of the import_* functions which are more suitable for
10492  * # Cython code.
10493  * cdef inline int import_array() except -1:             # <<<<<<<<<<<<<<
10494  *     try:
10495  *         __pyx_import_array()
10496  */
10497 
__pyx_f_5numpy_import_array(void)10498 static CYTHON_INLINE int __pyx_f_5numpy_import_array(void) {
10499   int __pyx_r;
10500   __Pyx_RefNannyDeclarations
10501   PyObject *__pyx_t_1 = NULL;
10502   PyObject *__pyx_t_2 = NULL;
10503   PyObject *__pyx_t_3 = NULL;
10504   int __pyx_t_4;
10505   PyObject *__pyx_t_5 = NULL;
10506   PyObject *__pyx_t_6 = NULL;
10507   PyObject *__pyx_t_7 = NULL;
10508   PyObject *__pyx_t_8 = NULL;
10509   int __pyx_lineno = 0;
10510   const char *__pyx_filename = NULL;
10511   int __pyx_clineno = 0;
10512   __Pyx_RefNannySetupContext("import_array", 0);
10513 
10514   /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":881
10515  * # Cython code.
10516  * cdef inline int import_array() except -1:
10517  *     try:             # <<<<<<<<<<<<<<
10518  *         __pyx_import_array()
10519  *     except Exception:
10520  */
10521   {
10522     __Pyx_PyThreadState_declare
10523     __Pyx_PyThreadState_assign
10524     __Pyx_ExceptionSave(&__pyx_t_1, &__pyx_t_2, &__pyx_t_3);
10525     __Pyx_XGOTREF(__pyx_t_1);
10526     __Pyx_XGOTREF(__pyx_t_2);
10527     __Pyx_XGOTREF(__pyx_t_3);
10528     /*try:*/ {
10529 
10530       /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":882
10531  * cdef inline int import_array() except -1:
10532  *     try:
10533  *         __pyx_import_array()             # <<<<<<<<<<<<<<
10534  *     except Exception:
10535  *         raise ImportError("numpy.core.multiarray failed to import")
10536  */
10537       __pyx_t_4 = _import_array(); if (unlikely(__pyx_t_4 == ((int)-1))) __PYX_ERR(2, 882, __pyx_L3_error)
10538 
10539       /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":881
10540  * # Cython code.
10541  * cdef inline int import_array() except -1:
10542  *     try:             # <<<<<<<<<<<<<<
10543  *         __pyx_import_array()
10544  *     except Exception:
10545  */
10546     }
10547     __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
10548     __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
10549     __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
10550     goto __pyx_L8_try_end;
10551     __pyx_L3_error:;
10552 
10553     /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":883
10554  *     try:
10555  *         __pyx_import_array()
10556  *     except Exception:             # <<<<<<<<<<<<<<
10557  *         raise ImportError("numpy.core.multiarray failed to import")
10558  *
10559  */
10560     __pyx_t_4 = __Pyx_PyErr_ExceptionMatches(((PyObject *)(&((PyTypeObject*)PyExc_Exception)[0])));
10561     if (__pyx_t_4) {
10562       __Pyx_AddTraceback("numpy.import_array", __pyx_clineno, __pyx_lineno, __pyx_filename);
10563       if (__Pyx_GetException(&__pyx_t_5, &__pyx_t_6, &__pyx_t_7) < 0) __PYX_ERR(2, 883, __pyx_L5_except_error)
10564       __Pyx_GOTREF(__pyx_t_5);
10565       __Pyx_GOTREF(__pyx_t_6);
10566       __Pyx_GOTREF(__pyx_t_7);
10567 
10568       /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":884
10569  *         __pyx_import_array()
10570  *     except Exception:
10571  *         raise ImportError("numpy.core.multiarray failed to import")             # <<<<<<<<<<<<<<
10572  *
10573  * cdef inline int import_umath() except -1:
10574  */
10575       __pyx_t_8 = __Pyx_PyObject_Call(__pyx_builtin_ImportError, __pyx_tuple__17, NULL); if (unlikely(!__pyx_t_8)) __PYX_ERR(2, 884, __pyx_L5_except_error)
10576       __Pyx_GOTREF(__pyx_t_8);
10577       __Pyx_Raise(__pyx_t_8, 0, 0, 0);
10578       __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
10579       __PYX_ERR(2, 884, __pyx_L5_except_error)
10580     }
10581     goto __pyx_L5_except_error;
10582     __pyx_L5_except_error:;
10583 
10584     /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":881
10585  * # Cython code.
10586  * cdef inline int import_array() except -1:
10587  *     try:             # <<<<<<<<<<<<<<
10588  *         __pyx_import_array()
10589  *     except Exception:
10590  */
10591     __Pyx_XGIVEREF(__pyx_t_1);
10592     __Pyx_XGIVEREF(__pyx_t_2);
10593     __Pyx_XGIVEREF(__pyx_t_3);
10594     __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3);
10595     goto __pyx_L1_error;
10596     __pyx_L8_try_end:;
10597   }
10598 
10599   /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":880
10600  * # Versions of the import_* functions which are more suitable for
10601  * # Cython code.
10602  * cdef inline int import_array() except -1:             # <<<<<<<<<<<<<<
10603  *     try:
10604  *         __pyx_import_array()
10605  */
10606 
10607   /* function exit code */
10608   __pyx_r = 0;
10609   goto __pyx_L0;
10610   __pyx_L1_error:;
10611   __Pyx_XDECREF(__pyx_t_5);
10612   __Pyx_XDECREF(__pyx_t_6);
10613   __Pyx_XDECREF(__pyx_t_7);
10614   __Pyx_XDECREF(__pyx_t_8);
10615   __Pyx_AddTraceback("numpy.import_array", __pyx_clineno, __pyx_lineno, __pyx_filename);
10616   __pyx_r = -1;
10617   __pyx_L0:;
10618   __Pyx_RefNannyFinishContext();
10619   return __pyx_r;
10620 }
10621 
10622 /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":886
10623  *         raise ImportError("numpy.core.multiarray failed to import")
10624  *
10625  * cdef inline int import_umath() except -1:             # <<<<<<<<<<<<<<
10626  *     try:
10627  *         _import_umath()
10628  */
10629 
__pyx_f_5numpy_import_umath(void)10630 static CYTHON_INLINE int __pyx_f_5numpy_import_umath(void) {
10631   int __pyx_r;
10632   __Pyx_RefNannyDeclarations
10633   PyObject *__pyx_t_1 = NULL;
10634   PyObject *__pyx_t_2 = NULL;
10635   PyObject *__pyx_t_3 = NULL;
10636   int __pyx_t_4;
10637   PyObject *__pyx_t_5 = NULL;
10638   PyObject *__pyx_t_6 = NULL;
10639   PyObject *__pyx_t_7 = NULL;
10640   PyObject *__pyx_t_8 = NULL;
10641   int __pyx_lineno = 0;
10642   const char *__pyx_filename = NULL;
10643   int __pyx_clineno = 0;
10644   __Pyx_RefNannySetupContext("import_umath", 0);
10645 
10646   /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":887
10647  *
10648  * cdef inline int import_umath() except -1:
10649  *     try:             # <<<<<<<<<<<<<<
10650  *         _import_umath()
10651  *     except Exception:
10652  */
10653   {
10654     __Pyx_PyThreadState_declare
10655     __Pyx_PyThreadState_assign
10656     __Pyx_ExceptionSave(&__pyx_t_1, &__pyx_t_2, &__pyx_t_3);
10657     __Pyx_XGOTREF(__pyx_t_1);
10658     __Pyx_XGOTREF(__pyx_t_2);
10659     __Pyx_XGOTREF(__pyx_t_3);
10660     /*try:*/ {
10661 
10662       /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":888
10663  * cdef inline int import_umath() except -1:
10664  *     try:
10665  *         _import_umath()             # <<<<<<<<<<<<<<
10666  *     except Exception:
10667  *         raise ImportError("numpy.core.umath failed to import")
10668  */
10669       __pyx_t_4 = _import_umath(); if (unlikely(__pyx_t_4 == ((int)-1))) __PYX_ERR(2, 888, __pyx_L3_error)
10670 
10671       /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":887
10672  *
10673  * cdef inline int import_umath() except -1:
10674  *     try:             # <<<<<<<<<<<<<<
10675  *         _import_umath()
10676  *     except Exception:
10677  */
10678     }
10679     __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
10680     __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
10681     __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
10682     goto __pyx_L8_try_end;
10683     __pyx_L3_error:;
10684 
10685     /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":889
10686  *     try:
10687  *         _import_umath()
10688  *     except Exception:             # <<<<<<<<<<<<<<
10689  *         raise ImportError("numpy.core.umath failed to import")
10690  *
10691  */
10692     __pyx_t_4 = __Pyx_PyErr_ExceptionMatches(((PyObject *)(&((PyTypeObject*)PyExc_Exception)[0])));
10693     if (__pyx_t_4) {
10694       __Pyx_AddTraceback("numpy.import_umath", __pyx_clineno, __pyx_lineno, __pyx_filename);
10695       if (__Pyx_GetException(&__pyx_t_5, &__pyx_t_6, &__pyx_t_7) < 0) __PYX_ERR(2, 889, __pyx_L5_except_error)
10696       __Pyx_GOTREF(__pyx_t_5);
10697       __Pyx_GOTREF(__pyx_t_6);
10698       __Pyx_GOTREF(__pyx_t_7);
10699 
10700       /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":890
10701  *         _import_umath()
10702  *     except Exception:
10703  *         raise ImportError("numpy.core.umath failed to import")             # <<<<<<<<<<<<<<
10704  *
10705  * cdef inline int import_ufunc() except -1:
10706  */
10707       __pyx_t_8 = __Pyx_PyObject_Call(__pyx_builtin_ImportError, __pyx_tuple__18, NULL); if (unlikely(!__pyx_t_8)) __PYX_ERR(2, 890, __pyx_L5_except_error)
10708       __Pyx_GOTREF(__pyx_t_8);
10709       __Pyx_Raise(__pyx_t_8, 0, 0, 0);
10710       __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
10711       __PYX_ERR(2, 890, __pyx_L5_except_error)
10712     }
10713     goto __pyx_L5_except_error;
10714     __pyx_L5_except_error:;
10715 
10716     /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":887
10717  *
10718  * cdef inline int import_umath() except -1:
10719  *     try:             # <<<<<<<<<<<<<<
10720  *         _import_umath()
10721  *     except Exception:
10722  */
10723     __Pyx_XGIVEREF(__pyx_t_1);
10724     __Pyx_XGIVEREF(__pyx_t_2);
10725     __Pyx_XGIVEREF(__pyx_t_3);
10726     __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3);
10727     goto __pyx_L1_error;
10728     __pyx_L8_try_end:;
10729   }
10730 
10731   /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":886
10732  *         raise ImportError("numpy.core.multiarray failed to import")
10733  *
10734  * cdef inline int import_umath() except -1:             # <<<<<<<<<<<<<<
10735  *     try:
10736  *         _import_umath()
10737  */
10738 
10739   /* function exit code */
10740   __pyx_r = 0;
10741   goto __pyx_L0;
10742   __pyx_L1_error:;
10743   __Pyx_XDECREF(__pyx_t_5);
10744   __Pyx_XDECREF(__pyx_t_6);
10745   __Pyx_XDECREF(__pyx_t_7);
10746   __Pyx_XDECREF(__pyx_t_8);
10747   __Pyx_AddTraceback("numpy.import_umath", __pyx_clineno, __pyx_lineno, __pyx_filename);
10748   __pyx_r = -1;
10749   __pyx_L0:;
10750   __Pyx_RefNannyFinishContext();
10751   return __pyx_r;
10752 }
10753 
10754 /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":892
10755  *         raise ImportError("numpy.core.umath failed to import")
10756  *
10757  * cdef inline int import_ufunc() except -1:             # <<<<<<<<<<<<<<
10758  *     try:
10759  *         _import_umath()
10760  */
10761 
__pyx_f_5numpy_import_ufunc(void)10762 static CYTHON_INLINE int __pyx_f_5numpy_import_ufunc(void) {
10763   int __pyx_r;
10764   __Pyx_RefNannyDeclarations
10765   PyObject *__pyx_t_1 = NULL;
10766   PyObject *__pyx_t_2 = NULL;
10767   PyObject *__pyx_t_3 = NULL;
10768   int __pyx_t_4;
10769   PyObject *__pyx_t_5 = NULL;
10770   PyObject *__pyx_t_6 = NULL;
10771   PyObject *__pyx_t_7 = NULL;
10772   PyObject *__pyx_t_8 = NULL;
10773   int __pyx_lineno = 0;
10774   const char *__pyx_filename = NULL;
10775   int __pyx_clineno = 0;
10776   __Pyx_RefNannySetupContext("import_ufunc", 0);
10777 
10778   /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":893
10779  *
10780  * cdef inline int import_ufunc() except -1:
10781  *     try:             # <<<<<<<<<<<<<<
10782  *         _import_umath()
10783  *     except Exception:
10784  */
10785   {
10786     __Pyx_PyThreadState_declare
10787     __Pyx_PyThreadState_assign
10788     __Pyx_ExceptionSave(&__pyx_t_1, &__pyx_t_2, &__pyx_t_3);
10789     __Pyx_XGOTREF(__pyx_t_1);
10790     __Pyx_XGOTREF(__pyx_t_2);
10791     __Pyx_XGOTREF(__pyx_t_3);
10792     /*try:*/ {
10793 
10794       /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":894
10795  * cdef inline int import_ufunc() except -1:
10796  *     try:
10797  *         _import_umath()             # <<<<<<<<<<<<<<
10798  *     except Exception:
10799  *         raise ImportError("numpy.core.umath failed to import")
10800  */
10801       __pyx_t_4 = _import_umath(); if (unlikely(__pyx_t_4 == ((int)-1))) __PYX_ERR(2, 894, __pyx_L3_error)
10802 
10803       /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":893
10804  *
10805  * cdef inline int import_ufunc() except -1:
10806  *     try:             # <<<<<<<<<<<<<<
10807  *         _import_umath()
10808  *     except Exception:
10809  */
10810     }
10811     __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
10812     __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
10813     __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
10814     goto __pyx_L8_try_end;
10815     __pyx_L3_error:;
10816 
10817     /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":895
10818  *     try:
10819  *         _import_umath()
10820  *     except Exception:             # <<<<<<<<<<<<<<
10821  *         raise ImportError("numpy.core.umath failed to import")
10822  *
10823  */
10824     __pyx_t_4 = __Pyx_PyErr_ExceptionMatches(((PyObject *)(&((PyTypeObject*)PyExc_Exception)[0])));
10825     if (__pyx_t_4) {
10826       __Pyx_AddTraceback("numpy.import_ufunc", __pyx_clineno, __pyx_lineno, __pyx_filename);
10827       if (__Pyx_GetException(&__pyx_t_5, &__pyx_t_6, &__pyx_t_7) < 0) __PYX_ERR(2, 895, __pyx_L5_except_error)
10828       __Pyx_GOTREF(__pyx_t_5);
10829       __Pyx_GOTREF(__pyx_t_6);
10830       __Pyx_GOTREF(__pyx_t_7);
10831 
10832       /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":896
10833  *         _import_umath()
10834  *     except Exception:
10835  *         raise ImportError("numpy.core.umath failed to import")             # <<<<<<<<<<<<<<
10836  *
10837  * cdef extern from *:
10838  */
10839       __pyx_t_8 = __Pyx_PyObject_Call(__pyx_builtin_ImportError, __pyx_tuple__18, NULL); if (unlikely(!__pyx_t_8)) __PYX_ERR(2, 896, __pyx_L5_except_error)
10840       __Pyx_GOTREF(__pyx_t_8);
10841       __Pyx_Raise(__pyx_t_8, 0, 0, 0);
10842       __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
10843       __PYX_ERR(2, 896, __pyx_L5_except_error)
10844     }
10845     goto __pyx_L5_except_error;
10846     __pyx_L5_except_error:;
10847 
10848     /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":893
10849  *
10850  * cdef inline int import_ufunc() except -1:
10851  *     try:             # <<<<<<<<<<<<<<
10852  *         _import_umath()
10853  *     except Exception:
10854  */
10855     __Pyx_XGIVEREF(__pyx_t_1);
10856     __Pyx_XGIVEREF(__pyx_t_2);
10857     __Pyx_XGIVEREF(__pyx_t_3);
10858     __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3);
10859     goto __pyx_L1_error;
10860     __pyx_L8_try_end:;
10861   }
10862 
10863   /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":892
10864  *         raise ImportError("numpy.core.umath failed to import")
10865  *
10866  * cdef inline int import_ufunc() except -1:             # <<<<<<<<<<<<<<
10867  *     try:
10868  *         _import_umath()
10869  */
10870 
10871   /* function exit code */
10872   __pyx_r = 0;
10873   goto __pyx_L0;
10874   __pyx_L1_error:;
10875   __Pyx_XDECREF(__pyx_t_5);
10876   __Pyx_XDECREF(__pyx_t_6);
10877   __Pyx_XDECREF(__pyx_t_7);
10878   __Pyx_XDECREF(__pyx_t_8);
10879   __Pyx_AddTraceback("numpy.import_ufunc", __pyx_clineno, __pyx_lineno, __pyx_filename);
10880   __pyx_r = -1;
10881   __pyx_L0:;
10882   __Pyx_RefNannyFinishContext();
10883   return __pyx_r;
10884 }
10885 
10886 /* "View.MemoryView":122
10887  *         cdef bint dtype_is_object
10888  *
10889  *     def __cinit__(array self, tuple shape, Py_ssize_t itemsize, format not None,             # <<<<<<<<<<<<<<
10890  *                   mode="c", bint allocate_buffer=True):
10891  *
10892  */
10893 
10894 /* Python wrapper */
10895 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)10896 static int __pyx_array___cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
10897   PyObject *__pyx_v_shape = 0;
10898   Py_ssize_t __pyx_v_itemsize;
10899   PyObject *__pyx_v_format = 0;
10900   PyObject *__pyx_v_mode = 0;
10901   int __pyx_v_allocate_buffer;
10902   int __pyx_lineno = 0;
10903   const char *__pyx_filename = NULL;
10904   int __pyx_clineno = 0;
10905   int __pyx_r;
10906   __Pyx_RefNannyDeclarations
10907   __Pyx_RefNannySetupContext("__cinit__ (wrapper)", 0);
10908   {
10909     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};
10910     PyObject* values[5] = {0,0,0,0,0};
10911     values[3] = ((PyObject *)__pyx_n_s_c);
10912     if (unlikely(__pyx_kwds)) {
10913       Py_ssize_t kw_args;
10914       const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
10915       switch (pos_args) {
10916         case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
10917         CYTHON_FALLTHROUGH;
10918         case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
10919         CYTHON_FALLTHROUGH;
10920         case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
10921         CYTHON_FALLTHROUGH;
10922         case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
10923         CYTHON_FALLTHROUGH;
10924         case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
10925         CYTHON_FALLTHROUGH;
10926         case  0: break;
10927         default: goto __pyx_L5_argtuple_error;
10928       }
10929       kw_args = PyDict_Size(__pyx_kwds);
10930       switch (pos_args) {
10931         case  0:
10932         if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_shape)) != 0)) kw_args--;
10933         else goto __pyx_L5_argtuple_error;
10934         CYTHON_FALLTHROUGH;
10935         case  1:
10936         if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_itemsize)) != 0)) kw_args--;
10937         else {
10938           __Pyx_RaiseArgtupleInvalid("__cinit__", 0, 3, 5, 1); __PYX_ERR(3, 122, __pyx_L3_error)
10939         }
10940         CYTHON_FALLTHROUGH;
10941         case  2:
10942         if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_format)) != 0)) kw_args--;
10943         else {
10944           __Pyx_RaiseArgtupleInvalid("__cinit__", 0, 3, 5, 2); __PYX_ERR(3, 122, __pyx_L3_error)
10945         }
10946         CYTHON_FALLTHROUGH;
10947         case  3:
10948         if (kw_args > 0) {
10949           PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_mode);
10950           if (value) { values[3] = value; kw_args--; }
10951         }
10952         CYTHON_FALLTHROUGH;
10953         case  4:
10954         if (kw_args > 0) {
10955           PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_allocate_buffer);
10956           if (value) { values[4] = value; kw_args--; }
10957         }
10958       }
10959       if (unlikely(kw_args > 0)) {
10960         if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__cinit__") < 0)) __PYX_ERR(3, 122, __pyx_L3_error)
10961       }
10962     } else {
10963       switch (PyTuple_GET_SIZE(__pyx_args)) {
10964         case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
10965         CYTHON_FALLTHROUGH;
10966         case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
10967         CYTHON_FALLTHROUGH;
10968         case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
10969         values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
10970         values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
10971         break;
10972         default: goto __pyx_L5_argtuple_error;
10973       }
10974     }
10975     __pyx_v_shape = ((PyObject*)values[0]);
10976     __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)
10977     __pyx_v_format = values[2];
10978     __pyx_v_mode = values[3];
10979     if (values[4]) {
10980       __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)
10981     } else {
10982 
10983       /* "View.MemoryView":123
10984  *
10985  *     def __cinit__(array self, tuple shape, Py_ssize_t itemsize, format not None,
10986  *                   mode="c", bint allocate_buffer=True):             # <<<<<<<<<<<<<<
10987  *
10988  *         cdef int idx
10989  */
10990       __pyx_v_allocate_buffer = ((int)1);
10991     }
10992   }
10993   goto __pyx_L4_argument_unpacking_done;
10994   __pyx_L5_argtuple_error:;
10995   __Pyx_RaiseArgtupleInvalid("__cinit__", 0, 3, 5, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(3, 122, __pyx_L3_error)
10996   __pyx_L3_error:;
10997   __Pyx_AddTraceback("View.MemoryView.array.__cinit__", __pyx_clineno, __pyx_lineno, __pyx_filename);
10998   __Pyx_RefNannyFinishContext();
10999   return -1;
11000   __pyx_L4_argument_unpacking_done:;
11001   if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_shape), (&PyTuple_Type), 1, "shape", 1))) __PYX_ERR(3, 122, __pyx_L1_error)
11002   if (unlikely(((PyObject *)__pyx_v_format) == Py_None)) {
11003     PyErr_Format(PyExc_TypeError, "Argument '%.200s' must not be None", "format"); __PYX_ERR(3, 122, __pyx_L1_error)
11004   }
11005   __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);
11006 
11007   /* "View.MemoryView":122
11008  *         cdef bint dtype_is_object
11009  *
11010  *     def __cinit__(array self, tuple shape, Py_ssize_t itemsize, format not None,             # <<<<<<<<<<<<<<
11011  *                   mode="c", bint allocate_buffer=True):
11012  *
11013  */
11014 
11015   /* function exit code */
11016   goto __pyx_L0;
11017   __pyx_L1_error:;
11018   __pyx_r = -1;
11019   __pyx_L0:;
11020   __Pyx_RefNannyFinishContext();
11021   return __pyx_r;
11022 }
11023 
__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)11024 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) {
11025   int __pyx_v_idx;
11026   Py_ssize_t __pyx_v_i;
11027   Py_ssize_t __pyx_v_dim;
11028   PyObject **__pyx_v_p;
11029   char __pyx_v_order;
11030   int __pyx_r;
11031   __Pyx_RefNannyDeclarations
11032   Py_ssize_t __pyx_t_1;
11033   int __pyx_t_2;
11034   PyObject *__pyx_t_3 = NULL;
11035   int __pyx_t_4;
11036   PyObject *__pyx_t_5 = NULL;
11037   PyObject *__pyx_t_6 = NULL;
11038   char *__pyx_t_7;
11039   int __pyx_t_8;
11040   Py_ssize_t __pyx_t_9;
11041   PyObject *__pyx_t_10 = NULL;
11042   Py_ssize_t __pyx_t_11;
11043   int __pyx_lineno = 0;
11044   const char *__pyx_filename = NULL;
11045   int __pyx_clineno = 0;
11046   __Pyx_RefNannySetupContext("__cinit__", 0);
11047   __Pyx_INCREF(__pyx_v_format);
11048 
11049   /* "View.MemoryView":129
11050  *         cdef PyObject **p
11051  *
11052  *         self.ndim = <int> len(shape)             # <<<<<<<<<<<<<<
11053  *         self.itemsize = itemsize
11054  *
11055  */
11056   if (unlikely(__pyx_v_shape == Py_None)) {
11057     PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
11058     __PYX_ERR(3, 129, __pyx_L1_error)
11059   }
11060   __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)
11061   __pyx_v_self->ndim = ((int)__pyx_t_1);
11062 
11063   /* "View.MemoryView":130
11064  *
11065  *         self.ndim = <int> len(shape)
11066  *         self.itemsize = itemsize             # <<<<<<<<<<<<<<
11067  *
11068  *         if not self.ndim:
11069  */
11070   __pyx_v_self->itemsize = __pyx_v_itemsize;
11071 
11072   /* "View.MemoryView":132
11073  *         self.itemsize = itemsize
11074  *
11075  *         if not self.ndim:             # <<<<<<<<<<<<<<
11076  *             raise ValueError("Empty shape tuple for cython.array")
11077  *
11078  */
11079   __pyx_t_2 = ((!(__pyx_v_self->ndim != 0)) != 0);
11080   if (unlikely(__pyx_t_2)) {
11081 
11082     /* "View.MemoryView":133
11083  *
11084  *         if not self.ndim:
11085  *             raise ValueError("Empty shape tuple for cython.array")             # <<<<<<<<<<<<<<
11086  *
11087  *         if itemsize <= 0:
11088  */
11089     __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__19, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(3, 133, __pyx_L1_error)
11090     __Pyx_GOTREF(__pyx_t_3);
11091     __Pyx_Raise(__pyx_t_3, 0, 0, 0);
11092     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
11093     __PYX_ERR(3, 133, __pyx_L1_error)
11094 
11095     /* "View.MemoryView":132
11096  *         self.itemsize = itemsize
11097  *
11098  *         if not self.ndim:             # <<<<<<<<<<<<<<
11099  *             raise ValueError("Empty shape tuple for cython.array")
11100  *
11101  */
11102   }
11103 
11104   /* "View.MemoryView":135
11105  *             raise ValueError("Empty shape tuple for cython.array")
11106  *
11107  *         if itemsize <= 0:             # <<<<<<<<<<<<<<
11108  *             raise ValueError("itemsize <= 0 for cython.array")
11109  *
11110  */
11111   __pyx_t_2 = ((__pyx_v_itemsize <= 0) != 0);
11112   if (unlikely(__pyx_t_2)) {
11113 
11114     /* "View.MemoryView":136
11115  *
11116  *         if itemsize <= 0:
11117  *             raise ValueError("itemsize <= 0 for cython.array")             # <<<<<<<<<<<<<<
11118  *
11119  *         if not isinstance(format, bytes):
11120  */
11121     __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__20, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(3, 136, __pyx_L1_error)
11122     __Pyx_GOTREF(__pyx_t_3);
11123     __Pyx_Raise(__pyx_t_3, 0, 0, 0);
11124     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
11125     __PYX_ERR(3, 136, __pyx_L1_error)
11126 
11127     /* "View.MemoryView":135
11128  *             raise ValueError("Empty shape tuple for cython.array")
11129  *
11130  *         if itemsize <= 0:             # <<<<<<<<<<<<<<
11131  *             raise ValueError("itemsize <= 0 for cython.array")
11132  *
11133  */
11134   }
11135 
11136   /* "View.MemoryView":138
11137  *             raise ValueError("itemsize <= 0 for cython.array")
11138  *
11139  *         if not isinstance(format, bytes):             # <<<<<<<<<<<<<<
11140  *             format = format.encode('ASCII')
11141  *         self._format = format  # keep a reference to the byte string
11142  */
11143   __pyx_t_2 = PyBytes_Check(__pyx_v_format);
11144   __pyx_t_4 = ((!(__pyx_t_2 != 0)) != 0);
11145   if (__pyx_t_4) {
11146 
11147     /* "View.MemoryView":139
11148  *
11149  *         if not isinstance(format, bytes):
11150  *             format = format.encode('ASCII')             # <<<<<<<<<<<<<<
11151  *         self._format = format  # keep a reference to the byte string
11152  *         self.format = self._format
11153  */
11154     __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)
11155     __Pyx_GOTREF(__pyx_t_5);
11156     __pyx_t_6 = NULL;
11157     if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_5))) {
11158       __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_5);
11159       if (likely(__pyx_t_6)) {
11160         PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
11161         __Pyx_INCREF(__pyx_t_6);
11162         __Pyx_INCREF(function);
11163         __Pyx_DECREF_SET(__pyx_t_5, function);
11164       }
11165     }
11166     __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);
11167     __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
11168     if (unlikely(!__pyx_t_3)) __PYX_ERR(3, 139, __pyx_L1_error)
11169     __Pyx_GOTREF(__pyx_t_3);
11170     __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
11171     __Pyx_DECREF_SET(__pyx_v_format, __pyx_t_3);
11172     __pyx_t_3 = 0;
11173 
11174     /* "View.MemoryView":138
11175  *             raise ValueError("itemsize <= 0 for cython.array")
11176  *
11177  *         if not isinstance(format, bytes):             # <<<<<<<<<<<<<<
11178  *             format = format.encode('ASCII')
11179  *         self._format = format  # keep a reference to the byte string
11180  */
11181   }
11182 
11183   /* "View.MemoryView":140
11184  *         if not isinstance(format, bytes):
11185  *             format = format.encode('ASCII')
11186  *         self._format = format  # keep a reference to the byte string             # <<<<<<<<<<<<<<
11187  *         self.format = self._format
11188  *
11189  */
11190   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)
11191   __pyx_t_3 = __pyx_v_format;
11192   __Pyx_INCREF(__pyx_t_3);
11193   __Pyx_GIVEREF(__pyx_t_3);
11194   __Pyx_GOTREF(__pyx_v_self->_format);
11195   __Pyx_DECREF(__pyx_v_self->_format);
11196   __pyx_v_self->_format = ((PyObject*)__pyx_t_3);
11197   __pyx_t_3 = 0;
11198 
11199   /* "View.MemoryView":141
11200  *             format = format.encode('ASCII')
11201  *         self._format = format  # keep a reference to the byte string
11202  *         self.format = self._format             # <<<<<<<<<<<<<<
11203  *
11204  *
11205  */
11206   if (unlikely(__pyx_v_self->_format == Py_None)) {
11207     PyErr_SetString(PyExc_TypeError, "expected bytes, NoneType found");
11208     __PYX_ERR(3, 141, __pyx_L1_error)
11209   }
11210   __pyx_t_7 = __Pyx_PyBytes_AsWritableString(__pyx_v_self->_format); if (unlikely((!__pyx_t_7) && PyErr_Occurred())) __PYX_ERR(3, 141, __pyx_L1_error)
11211   __pyx_v_self->format = __pyx_t_7;
11212 
11213   /* "View.MemoryView":144
11214  *
11215  *
11216  *         self._shape = <Py_ssize_t *> PyObject_Malloc(sizeof(Py_ssize_t)*self.ndim*2)             # <<<<<<<<<<<<<<
11217  *         self._strides = self._shape + self.ndim
11218  *
11219  */
11220   __pyx_v_self->_shape = ((Py_ssize_t *)PyObject_Malloc((((sizeof(Py_ssize_t)) * __pyx_v_self->ndim) * 2)));
11221 
11222   /* "View.MemoryView":145
11223  *
11224  *         self._shape = <Py_ssize_t *> PyObject_Malloc(sizeof(Py_ssize_t)*self.ndim*2)
11225  *         self._strides = self._shape + self.ndim             # <<<<<<<<<<<<<<
11226  *
11227  *         if not self._shape:
11228  */
11229   __pyx_v_self->_strides = (__pyx_v_self->_shape + __pyx_v_self->ndim);
11230 
11231   /* "View.MemoryView":147
11232  *         self._strides = self._shape + self.ndim
11233  *
11234  *         if not self._shape:             # <<<<<<<<<<<<<<
11235  *             raise MemoryError("unable to allocate shape and strides.")
11236  *
11237  */
11238   __pyx_t_4 = ((!(__pyx_v_self->_shape != 0)) != 0);
11239   if (unlikely(__pyx_t_4)) {
11240 
11241     /* "View.MemoryView":148
11242  *
11243  *         if not self._shape:
11244  *             raise MemoryError("unable to allocate shape and strides.")             # <<<<<<<<<<<<<<
11245  *
11246  *
11247  */
11248     __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_MemoryError, __pyx_tuple__21, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(3, 148, __pyx_L1_error)
11249     __Pyx_GOTREF(__pyx_t_3);
11250     __Pyx_Raise(__pyx_t_3, 0, 0, 0);
11251     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
11252     __PYX_ERR(3, 148, __pyx_L1_error)
11253 
11254     /* "View.MemoryView":147
11255  *         self._strides = self._shape + self.ndim
11256  *
11257  *         if not self._shape:             # <<<<<<<<<<<<<<
11258  *             raise MemoryError("unable to allocate shape and strides.")
11259  *
11260  */
11261   }
11262 
11263   /* "View.MemoryView":151
11264  *
11265  *
11266  *         for idx, dim in enumerate(shape):             # <<<<<<<<<<<<<<
11267  *             if dim <= 0:
11268  *                 raise ValueError("Invalid shape in axis %d: %d." % (idx, dim))
11269  */
11270   __pyx_t_8 = 0;
11271   __pyx_t_3 = __pyx_v_shape; __Pyx_INCREF(__pyx_t_3); __pyx_t_1 = 0;
11272   for (;;) {
11273     if (__pyx_t_1 >= PyTuple_GET_SIZE(__pyx_t_3)) break;
11274     #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
11275     __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)
11276     #else
11277     __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)
11278     __Pyx_GOTREF(__pyx_t_5);
11279     #endif
11280     __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)
11281     __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
11282     __pyx_v_dim = __pyx_t_9;
11283     __pyx_v_idx = __pyx_t_8;
11284     __pyx_t_8 = (__pyx_t_8 + 1);
11285 
11286     /* "View.MemoryView":152
11287  *
11288  *         for idx, dim in enumerate(shape):
11289  *             if dim <= 0:             # <<<<<<<<<<<<<<
11290  *                 raise ValueError("Invalid shape in axis %d: %d." % (idx, dim))
11291  *             self._shape[idx] = dim
11292  */
11293     __pyx_t_4 = ((__pyx_v_dim <= 0) != 0);
11294     if (unlikely(__pyx_t_4)) {
11295 
11296       /* "View.MemoryView":153
11297  *         for idx, dim in enumerate(shape):
11298  *             if dim <= 0:
11299  *                 raise ValueError("Invalid shape in axis %d: %d." % (idx, dim))             # <<<<<<<<<<<<<<
11300  *             self._shape[idx] = dim
11301  *
11302  */
11303       __pyx_t_5 = __Pyx_PyInt_From_int(__pyx_v_idx); if (unlikely(!__pyx_t_5)) __PYX_ERR(3, 153, __pyx_L1_error)
11304       __Pyx_GOTREF(__pyx_t_5);
11305       __pyx_t_6 = PyInt_FromSsize_t(__pyx_v_dim); if (unlikely(!__pyx_t_6)) __PYX_ERR(3, 153, __pyx_L1_error)
11306       __Pyx_GOTREF(__pyx_t_6);
11307       __pyx_t_10 = PyTuple_New(2); if (unlikely(!__pyx_t_10)) __PYX_ERR(3, 153, __pyx_L1_error)
11308       __Pyx_GOTREF(__pyx_t_10);
11309       __Pyx_GIVEREF(__pyx_t_5);
11310       PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_5);
11311       __Pyx_GIVEREF(__pyx_t_6);
11312       PyTuple_SET_ITEM(__pyx_t_10, 1, __pyx_t_6);
11313       __pyx_t_5 = 0;
11314       __pyx_t_6 = 0;
11315       __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)
11316       __Pyx_GOTREF(__pyx_t_6);
11317       __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
11318       __pyx_t_10 = __Pyx_PyObject_CallOneArg(__pyx_builtin_ValueError, __pyx_t_6); if (unlikely(!__pyx_t_10)) __PYX_ERR(3, 153, __pyx_L1_error)
11319       __Pyx_GOTREF(__pyx_t_10);
11320       __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
11321       __Pyx_Raise(__pyx_t_10, 0, 0, 0);
11322       __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
11323       __PYX_ERR(3, 153, __pyx_L1_error)
11324 
11325       /* "View.MemoryView":152
11326  *
11327  *         for idx, dim in enumerate(shape):
11328  *             if dim <= 0:             # <<<<<<<<<<<<<<
11329  *                 raise ValueError("Invalid shape in axis %d: %d." % (idx, dim))
11330  *             self._shape[idx] = dim
11331  */
11332     }
11333 
11334     /* "View.MemoryView":154
11335  *             if dim <= 0:
11336  *                 raise ValueError("Invalid shape in axis %d: %d." % (idx, dim))
11337  *             self._shape[idx] = dim             # <<<<<<<<<<<<<<
11338  *
11339  *         cdef char order
11340  */
11341     (__pyx_v_self->_shape[__pyx_v_idx]) = __pyx_v_dim;
11342 
11343     /* "View.MemoryView":151
11344  *
11345  *
11346  *         for idx, dim in enumerate(shape):             # <<<<<<<<<<<<<<
11347  *             if dim <= 0:
11348  *                 raise ValueError("Invalid shape in axis %d: %d." % (idx, dim))
11349  */
11350   }
11351   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
11352 
11353   /* "View.MemoryView":157
11354  *
11355  *         cdef char order
11356  *         if mode == 'fortran':             # <<<<<<<<<<<<<<
11357  *             order = b'F'
11358  *             self.mode = u'fortran'
11359  */
11360   __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)
11361   if (__pyx_t_4) {
11362 
11363     /* "View.MemoryView":158
11364  *         cdef char order
11365  *         if mode == 'fortran':
11366  *             order = b'F'             # <<<<<<<<<<<<<<
11367  *             self.mode = u'fortran'
11368  *         elif mode == 'c':
11369  */
11370     __pyx_v_order = 'F';
11371 
11372     /* "View.MemoryView":159
11373  *         if mode == 'fortran':
11374  *             order = b'F'
11375  *             self.mode = u'fortran'             # <<<<<<<<<<<<<<
11376  *         elif mode == 'c':
11377  *             order = b'C'
11378  */
11379     __Pyx_INCREF(__pyx_n_u_fortran);
11380     __Pyx_GIVEREF(__pyx_n_u_fortran);
11381     __Pyx_GOTREF(__pyx_v_self->mode);
11382     __Pyx_DECREF(__pyx_v_self->mode);
11383     __pyx_v_self->mode = __pyx_n_u_fortran;
11384 
11385     /* "View.MemoryView":157
11386  *
11387  *         cdef char order
11388  *         if mode == 'fortran':             # <<<<<<<<<<<<<<
11389  *             order = b'F'
11390  *             self.mode = u'fortran'
11391  */
11392     goto __pyx_L10;
11393   }
11394 
11395   /* "View.MemoryView":160
11396  *             order = b'F'
11397  *             self.mode = u'fortran'
11398  *         elif mode == 'c':             # <<<<<<<<<<<<<<
11399  *             order = b'C'
11400  *             self.mode = u'c'
11401  */
11402   __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)
11403   if (likely(__pyx_t_4)) {
11404 
11405     /* "View.MemoryView":161
11406  *             self.mode = u'fortran'
11407  *         elif mode == 'c':
11408  *             order = b'C'             # <<<<<<<<<<<<<<
11409  *             self.mode = u'c'
11410  *         else:
11411  */
11412     __pyx_v_order = 'C';
11413 
11414     /* "View.MemoryView":162
11415  *         elif mode == 'c':
11416  *             order = b'C'
11417  *             self.mode = u'c'             # <<<<<<<<<<<<<<
11418  *         else:
11419  *             raise ValueError("Invalid mode, expected 'c' or 'fortran', got %s" % mode)
11420  */
11421     __Pyx_INCREF(__pyx_n_u_c);
11422     __Pyx_GIVEREF(__pyx_n_u_c);
11423     __Pyx_GOTREF(__pyx_v_self->mode);
11424     __Pyx_DECREF(__pyx_v_self->mode);
11425     __pyx_v_self->mode = __pyx_n_u_c;
11426 
11427     /* "View.MemoryView":160
11428  *             order = b'F'
11429  *             self.mode = u'fortran'
11430  *         elif mode == 'c':             # <<<<<<<<<<<<<<
11431  *             order = b'C'
11432  *             self.mode = u'c'
11433  */
11434     goto __pyx_L10;
11435   }
11436 
11437   /* "View.MemoryView":164
11438  *             self.mode = u'c'
11439  *         else:
11440  *             raise ValueError("Invalid mode, expected 'c' or 'fortran', got %s" % mode)             # <<<<<<<<<<<<<<
11441  *
11442  *         self.len = fill_contig_strides_array(self._shape, self._strides,
11443  */
11444   /*else*/ {
11445     __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)
11446     __Pyx_GOTREF(__pyx_t_3);
11447     __pyx_t_10 = __Pyx_PyObject_CallOneArg(__pyx_builtin_ValueError, __pyx_t_3); if (unlikely(!__pyx_t_10)) __PYX_ERR(3, 164, __pyx_L1_error)
11448     __Pyx_GOTREF(__pyx_t_10);
11449     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
11450     __Pyx_Raise(__pyx_t_10, 0, 0, 0);
11451     __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
11452     __PYX_ERR(3, 164, __pyx_L1_error)
11453   }
11454   __pyx_L10:;
11455 
11456   /* "View.MemoryView":166
11457  *             raise ValueError("Invalid mode, expected 'c' or 'fortran', got %s" % mode)
11458  *
11459  *         self.len = fill_contig_strides_array(self._shape, self._strides,             # <<<<<<<<<<<<<<
11460  *                                              itemsize, self.ndim, order)
11461  *
11462  */
11463   __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);
11464 
11465   /* "View.MemoryView":169
11466  *                                              itemsize, self.ndim, order)
11467  *
11468  *         self.free_data = allocate_buffer             # <<<<<<<<<<<<<<
11469  *         self.dtype_is_object = format == b'O'
11470  *         if allocate_buffer:
11471  */
11472   __pyx_v_self->free_data = __pyx_v_allocate_buffer;
11473 
11474   /* "View.MemoryView":170
11475  *
11476  *         self.free_data = allocate_buffer
11477  *         self.dtype_is_object = format == b'O'             # <<<<<<<<<<<<<<
11478  *         if allocate_buffer:
11479  *
11480  */
11481   __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)
11482   __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)
11483   __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
11484   __pyx_v_self->dtype_is_object = __pyx_t_4;
11485 
11486   /* "View.MemoryView":171
11487  *         self.free_data = allocate_buffer
11488  *         self.dtype_is_object = format == b'O'
11489  *         if allocate_buffer:             # <<<<<<<<<<<<<<
11490  *
11491  *
11492  */
11493   __pyx_t_4 = (__pyx_v_allocate_buffer != 0);
11494   if (__pyx_t_4) {
11495 
11496     /* "View.MemoryView":174
11497  *
11498  *
11499  *             self.data = <char *>malloc(self.len)             # <<<<<<<<<<<<<<
11500  *             if not self.data:
11501  *                 raise MemoryError("unable to allocate array data.")
11502  */
11503     __pyx_v_self->data = ((char *)malloc(__pyx_v_self->len));
11504 
11505     /* "View.MemoryView":175
11506  *
11507  *             self.data = <char *>malloc(self.len)
11508  *             if not self.data:             # <<<<<<<<<<<<<<
11509  *                 raise MemoryError("unable to allocate array data.")
11510  *
11511  */
11512     __pyx_t_4 = ((!(__pyx_v_self->data != 0)) != 0);
11513     if (unlikely(__pyx_t_4)) {
11514 
11515       /* "View.MemoryView":176
11516  *             self.data = <char *>malloc(self.len)
11517  *             if not self.data:
11518  *                 raise MemoryError("unable to allocate array data.")             # <<<<<<<<<<<<<<
11519  *
11520  *             if self.dtype_is_object:
11521  */
11522       __pyx_t_10 = __Pyx_PyObject_Call(__pyx_builtin_MemoryError, __pyx_tuple__22, NULL); if (unlikely(!__pyx_t_10)) __PYX_ERR(3, 176, __pyx_L1_error)
11523       __Pyx_GOTREF(__pyx_t_10);
11524       __Pyx_Raise(__pyx_t_10, 0, 0, 0);
11525       __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
11526       __PYX_ERR(3, 176, __pyx_L1_error)
11527 
11528       /* "View.MemoryView":175
11529  *
11530  *             self.data = <char *>malloc(self.len)
11531  *             if not self.data:             # <<<<<<<<<<<<<<
11532  *                 raise MemoryError("unable to allocate array data.")
11533  *
11534  */
11535     }
11536 
11537     /* "View.MemoryView":178
11538  *                 raise MemoryError("unable to allocate array data.")
11539  *
11540  *             if self.dtype_is_object:             # <<<<<<<<<<<<<<
11541  *                 p = <PyObject **> self.data
11542  *                 for i in range(self.len / itemsize):
11543  */
11544     __pyx_t_4 = (__pyx_v_self->dtype_is_object != 0);
11545     if (__pyx_t_4) {
11546 
11547       /* "View.MemoryView":179
11548  *
11549  *             if self.dtype_is_object:
11550  *                 p = <PyObject **> self.data             # <<<<<<<<<<<<<<
11551  *                 for i in range(self.len / itemsize):
11552  *                     p[i] = Py_None
11553  */
11554       __pyx_v_p = ((PyObject **)__pyx_v_self->data);
11555 
11556       /* "View.MemoryView":180
11557  *             if self.dtype_is_object:
11558  *                 p = <PyObject **> self.data
11559  *                 for i in range(self.len / itemsize):             # <<<<<<<<<<<<<<
11560  *                     p[i] = Py_None
11561  *                     Py_INCREF(Py_None)
11562  */
11563       if (unlikely(__pyx_v_itemsize == 0)) {
11564         PyErr_SetString(PyExc_ZeroDivisionError, "integer division or modulo by zero");
11565         __PYX_ERR(3, 180, __pyx_L1_error)
11566       }
11567       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))) {
11568         PyErr_SetString(PyExc_OverflowError, "value too large to perform division");
11569         __PYX_ERR(3, 180, __pyx_L1_error)
11570       }
11571       __pyx_t_1 = __Pyx_div_Py_ssize_t(__pyx_v_self->len, __pyx_v_itemsize);
11572       __pyx_t_9 = __pyx_t_1;
11573       for (__pyx_t_11 = 0; __pyx_t_11 < __pyx_t_9; __pyx_t_11+=1) {
11574         __pyx_v_i = __pyx_t_11;
11575 
11576         /* "View.MemoryView":181
11577  *                 p = <PyObject **> self.data
11578  *                 for i in range(self.len / itemsize):
11579  *                     p[i] = Py_None             # <<<<<<<<<<<<<<
11580  *                     Py_INCREF(Py_None)
11581  *
11582  */
11583         (__pyx_v_p[__pyx_v_i]) = Py_None;
11584 
11585         /* "View.MemoryView":182
11586  *                 for i in range(self.len / itemsize):
11587  *                     p[i] = Py_None
11588  *                     Py_INCREF(Py_None)             # <<<<<<<<<<<<<<
11589  *
11590  *     @cname('getbuffer')
11591  */
11592         Py_INCREF(Py_None);
11593       }
11594 
11595       /* "View.MemoryView":178
11596  *                 raise MemoryError("unable to allocate array data.")
11597  *
11598  *             if self.dtype_is_object:             # <<<<<<<<<<<<<<
11599  *                 p = <PyObject **> self.data
11600  *                 for i in range(self.len / itemsize):
11601  */
11602     }
11603 
11604     /* "View.MemoryView":171
11605  *         self.free_data = allocate_buffer
11606  *         self.dtype_is_object = format == b'O'
11607  *         if allocate_buffer:             # <<<<<<<<<<<<<<
11608  *
11609  *
11610  */
11611   }
11612 
11613   /* "View.MemoryView":122
11614  *         cdef bint dtype_is_object
11615  *
11616  *     def __cinit__(array self, tuple shape, Py_ssize_t itemsize, format not None,             # <<<<<<<<<<<<<<
11617  *                   mode="c", bint allocate_buffer=True):
11618  *
11619  */
11620 
11621   /* function exit code */
11622   __pyx_r = 0;
11623   goto __pyx_L0;
11624   __pyx_L1_error:;
11625   __Pyx_XDECREF(__pyx_t_3);
11626   __Pyx_XDECREF(__pyx_t_5);
11627   __Pyx_XDECREF(__pyx_t_6);
11628   __Pyx_XDECREF(__pyx_t_10);
11629   __Pyx_AddTraceback("View.MemoryView.array.__cinit__", __pyx_clineno, __pyx_lineno, __pyx_filename);
11630   __pyx_r = -1;
11631   __pyx_L0:;
11632   __Pyx_XDECREF(__pyx_v_format);
11633   __Pyx_RefNannyFinishContext();
11634   return __pyx_r;
11635 }
11636 
11637 /* "View.MemoryView":185
11638  *
11639  *     @cname('getbuffer')
11640  *     def __getbuffer__(self, Py_buffer *info, int flags):             # <<<<<<<<<<<<<<
11641  *         cdef int bufmode = -1
11642  *         if self.mode == u"c":
11643  */
11644 
11645 /* Python wrapper */
11646 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)11647 static CYTHON_UNUSED int __pyx_array_getbuffer(PyObject *__pyx_v_self, Py_buffer *__pyx_v_info, int __pyx_v_flags) {
11648   int __pyx_r;
11649   __Pyx_RefNannyDeclarations
11650   __Pyx_RefNannySetupContext("__getbuffer__ (wrapper)", 0);
11651   __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));
11652 
11653   /* function exit code */
11654   __Pyx_RefNannyFinishContext();
11655   return __pyx_r;
11656 }
11657 
__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)11658 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) {
11659   int __pyx_v_bufmode;
11660   int __pyx_r;
11661   __Pyx_RefNannyDeclarations
11662   int __pyx_t_1;
11663   int __pyx_t_2;
11664   PyObject *__pyx_t_3 = NULL;
11665   char *__pyx_t_4;
11666   Py_ssize_t __pyx_t_5;
11667   int __pyx_t_6;
11668   Py_ssize_t *__pyx_t_7;
11669   int __pyx_lineno = 0;
11670   const char *__pyx_filename = NULL;
11671   int __pyx_clineno = 0;
11672   if (__pyx_v_info == NULL) {
11673     PyErr_SetString(PyExc_BufferError, "PyObject_GetBuffer: view==NULL argument is obsolete");
11674     return -1;
11675   }
11676   __Pyx_RefNannySetupContext("__getbuffer__", 0);
11677   __pyx_v_info->obj = Py_None; __Pyx_INCREF(Py_None);
11678   __Pyx_GIVEREF(__pyx_v_info->obj);
11679 
11680   /* "View.MemoryView":186
11681  *     @cname('getbuffer')
11682  *     def __getbuffer__(self, Py_buffer *info, int flags):
11683  *         cdef int bufmode = -1             # <<<<<<<<<<<<<<
11684  *         if self.mode == u"c":
11685  *             bufmode = PyBUF_C_CONTIGUOUS | PyBUF_ANY_CONTIGUOUS
11686  */
11687   __pyx_v_bufmode = -1;
11688 
11689   /* "View.MemoryView":187
11690  *     def __getbuffer__(self, Py_buffer *info, int flags):
11691  *         cdef int bufmode = -1
11692  *         if self.mode == u"c":             # <<<<<<<<<<<<<<
11693  *             bufmode = PyBUF_C_CONTIGUOUS | PyBUF_ANY_CONTIGUOUS
11694  *         elif self.mode == u"fortran":
11695  */
11696   __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)
11697   __pyx_t_2 = (__pyx_t_1 != 0);
11698   if (__pyx_t_2) {
11699 
11700     /* "View.MemoryView":188
11701  *         cdef int bufmode = -1
11702  *         if self.mode == u"c":
11703  *             bufmode = PyBUF_C_CONTIGUOUS | PyBUF_ANY_CONTIGUOUS             # <<<<<<<<<<<<<<
11704  *         elif self.mode == u"fortran":
11705  *             bufmode = PyBUF_F_CONTIGUOUS | PyBUF_ANY_CONTIGUOUS
11706  */
11707     __pyx_v_bufmode = (PyBUF_C_CONTIGUOUS | PyBUF_ANY_CONTIGUOUS);
11708 
11709     /* "View.MemoryView":187
11710  *     def __getbuffer__(self, Py_buffer *info, int flags):
11711  *         cdef int bufmode = -1
11712  *         if self.mode == u"c":             # <<<<<<<<<<<<<<
11713  *             bufmode = PyBUF_C_CONTIGUOUS | PyBUF_ANY_CONTIGUOUS
11714  *         elif self.mode == u"fortran":
11715  */
11716     goto __pyx_L3;
11717   }
11718 
11719   /* "View.MemoryView":189
11720  *         if self.mode == u"c":
11721  *             bufmode = PyBUF_C_CONTIGUOUS | PyBUF_ANY_CONTIGUOUS
11722  *         elif self.mode == u"fortran":             # <<<<<<<<<<<<<<
11723  *             bufmode = PyBUF_F_CONTIGUOUS | PyBUF_ANY_CONTIGUOUS
11724  *         if not (flags & bufmode):
11725  */
11726   __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)
11727   __pyx_t_1 = (__pyx_t_2 != 0);
11728   if (__pyx_t_1) {
11729 
11730     /* "View.MemoryView":190
11731  *             bufmode = PyBUF_C_CONTIGUOUS | PyBUF_ANY_CONTIGUOUS
11732  *         elif self.mode == u"fortran":
11733  *             bufmode = PyBUF_F_CONTIGUOUS | PyBUF_ANY_CONTIGUOUS             # <<<<<<<<<<<<<<
11734  *         if not (flags & bufmode):
11735  *             raise ValueError("Can only create a buffer that is contiguous in memory.")
11736  */
11737     __pyx_v_bufmode = (PyBUF_F_CONTIGUOUS | PyBUF_ANY_CONTIGUOUS);
11738 
11739     /* "View.MemoryView":189
11740  *         if self.mode == u"c":
11741  *             bufmode = PyBUF_C_CONTIGUOUS | PyBUF_ANY_CONTIGUOUS
11742  *         elif self.mode == u"fortran":             # <<<<<<<<<<<<<<
11743  *             bufmode = PyBUF_F_CONTIGUOUS | PyBUF_ANY_CONTIGUOUS
11744  *         if not (flags & bufmode):
11745  */
11746   }
11747   __pyx_L3:;
11748 
11749   /* "View.MemoryView":191
11750  *         elif self.mode == u"fortran":
11751  *             bufmode = PyBUF_F_CONTIGUOUS | PyBUF_ANY_CONTIGUOUS
11752  *         if not (flags & bufmode):             # <<<<<<<<<<<<<<
11753  *             raise ValueError("Can only create a buffer that is contiguous in memory.")
11754  *         info.buf = self.data
11755  */
11756   __pyx_t_1 = ((!((__pyx_v_flags & __pyx_v_bufmode) != 0)) != 0);
11757   if (unlikely(__pyx_t_1)) {
11758 
11759     /* "View.MemoryView":192
11760  *             bufmode = PyBUF_F_CONTIGUOUS | PyBUF_ANY_CONTIGUOUS
11761  *         if not (flags & bufmode):
11762  *             raise ValueError("Can only create a buffer that is contiguous in memory.")             # <<<<<<<<<<<<<<
11763  *         info.buf = self.data
11764  *         info.len = self.len
11765  */
11766     __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__23, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(3, 192, __pyx_L1_error)
11767     __Pyx_GOTREF(__pyx_t_3);
11768     __Pyx_Raise(__pyx_t_3, 0, 0, 0);
11769     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
11770     __PYX_ERR(3, 192, __pyx_L1_error)
11771 
11772     /* "View.MemoryView":191
11773  *         elif self.mode == u"fortran":
11774  *             bufmode = PyBUF_F_CONTIGUOUS | PyBUF_ANY_CONTIGUOUS
11775  *         if not (flags & bufmode):             # <<<<<<<<<<<<<<
11776  *             raise ValueError("Can only create a buffer that is contiguous in memory.")
11777  *         info.buf = self.data
11778  */
11779   }
11780 
11781   /* "View.MemoryView":193
11782  *         if not (flags & bufmode):
11783  *             raise ValueError("Can only create a buffer that is contiguous in memory.")
11784  *         info.buf = self.data             # <<<<<<<<<<<<<<
11785  *         info.len = self.len
11786  *         info.ndim = self.ndim
11787  */
11788   __pyx_t_4 = __pyx_v_self->data;
11789   __pyx_v_info->buf = __pyx_t_4;
11790 
11791   /* "View.MemoryView":194
11792  *             raise ValueError("Can only create a buffer that is contiguous in memory.")
11793  *         info.buf = self.data
11794  *         info.len = self.len             # <<<<<<<<<<<<<<
11795  *         info.ndim = self.ndim
11796  *         info.shape = self._shape
11797  */
11798   __pyx_t_5 = __pyx_v_self->len;
11799   __pyx_v_info->len = __pyx_t_5;
11800 
11801   /* "View.MemoryView":195
11802  *         info.buf = self.data
11803  *         info.len = self.len
11804  *         info.ndim = self.ndim             # <<<<<<<<<<<<<<
11805  *         info.shape = self._shape
11806  *         info.strides = self._strides
11807  */
11808   __pyx_t_6 = __pyx_v_self->ndim;
11809   __pyx_v_info->ndim = __pyx_t_6;
11810 
11811   /* "View.MemoryView":196
11812  *         info.len = self.len
11813  *         info.ndim = self.ndim
11814  *         info.shape = self._shape             # <<<<<<<<<<<<<<
11815  *         info.strides = self._strides
11816  *         info.suboffsets = NULL
11817  */
11818   __pyx_t_7 = __pyx_v_self->_shape;
11819   __pyx_v_info->shape = __pyx_t_7;
11820 
11821   /* "View.MemoryView":197
11822  *         info.ndim = self.ndim
11823  *         info.shape = self._shape
11824  *         info.strides = self._strides             # <<<<<<<<<<<<<<
11825  *         info.suboffsets = NULL
11826  *         info.itemsize = self.itemsize
11827  */
11828   __pyx_t_7 = __pyx_v_self->_strides;
11829   __pyx_v_info->strides = __pyx_t_7;
11830 
11831   /* "View.MemoryView":198
11832  *         info.shape = self._shape
11833  *         info.strides = self._strides
11834  *         info.suboffsets = NULL             # <<<<<<<<<<<<<<
11835  *         info.itemsize = self.itemsize
11836  *         info.readonly = 0
11837  */
11838   __pyx_v_info->suboffsets = NULL;
11839 
11840   /* "View.MemoryView":199
11841  *         info.strides = self._strides
11842  *         info.suboffsets = NULL
11843  *         info.itemsize = self.itemsize             # <<<<<<<<<<<<<<
11844  *         info.readonly = 0
11845  *
11846  */
11847   __pyx_t_5 = __pyx_v_self->itemsize;
11848   __pyx_v_info->itemsize = __pyx_t_5;
11849 
11850   /* "View.MemoryView":200
11851  *         info.suboffsets = NULL
11852  *         info.itemsize = self.itemsize
11853  *         info.readonly = 0             # <<<<<<<<<<<<<<
11854  *
11855  *         if flags & PyBUF_FORMAT:
11856  */
11857   __pyx_v_info->readonly = 0;
11858 
11859   /* "View.MemoryView":202
11860  *         info.readonly = 0
11861  *
11862  *         if flags & PyBUF_FORMAT:             # <<<<<<<<<<<<<<
11863  *             info.format = self.format
11864  *         else:
11865  */
11866   __pyx_t_1 = ((__pyx_v_flags & PyBUF_FORMAT) != 0);
11867   if (__pyx_t_1) {
11868 
11869     /* "View.MemoryView":203
11870  *
11871  *         if flags & PyBUF_FORMAT:
11872  *             info.format = self.format             # <<<<<<<<<<<<<<
11873  *         else:
11874  *             info.format = NULL
11875  */
11876     __pyx_t_4 = __pyx_v_self->format;
11877     __pyx_v_info->format = __pyx_t_4;
11878 
11879     /* "View.MemoryView":202
11880  *         info.readonly = 0
11881  *
11882  *         if flags & PyBUF_FORMAT:             # <<<<<<<<<<<<<<
11883  *             info.format = self.format
11884  *         else:
11885  */
11886     goto __pyx_L5;
11887   }
11888 
11889   /* "View.MemoryView":205
11890  *             info.format = self.format
11891  *         else:
11892  *             info.format = NULL             # <<<<<<<<<<<<<<
11893  *
11894  *         info.obj = self
11895  */
11896   /*else*/ {
11897     __pyx_v_info->format = NULL;
11898   }
11899   __pyx_L5:;
11900 
11901   /* "View.MemoryView":207
11902  *             info.format = NULL
11903  *
11904  *         info.obj = self             # <<<<<<<<<<<<<<
11905  *
11906  *     __pyx_getbuffer = capsule(<void *> &__pyx_array_getbuffer, "getbuffer(obj, view, flags)")
11907  */
11908   __Pyx_INCREF(((PyObject *)__pyx_v_self));
11909   __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
11910   __Pyx_GOTREF(__pyx_v_info->obj);
11911   __Pyx_DECREF(__pyx_v_info->obj);
11912   __pyx_v_info->obj = ((PyObject *)__pyx_v_self);
11913 
11914   /* "View.MemoryView":185
11915  *
11916  *     @cname('getbuffer')
11917  *     def __getbuffer__(self, Py_buffer *info, int flags):             # <<<<<<<<<<<<<<
11918  *         cdef int bufmode = -1
11919  *         if self.mode == u"c":
11920  */
11921 
11922   /* function exit code */
11923   __pyx_r = 0;
11924   goto __pyx_L0;
11925   __pyx_L1_error:;
11926   __Pyx_XDECREF(__pyx_t_3);
11927   __Pyx_AddTraceback("View.MemoryView.array.__getbuffer__", __pyx_clineno, __pyx_lineno, __pyx_filename);
11928   __pyx_r = -1;
11929   if (__pyx_v_info->obj != NULL) {
11930     __Pyx_GOTREF(__pyx_v_info->obj);
11931     __Pyx_DECREF(__pyx_v_info->obj); __pyx_v_info->obj = 0;
11932   }
11933   goto __pyx_L2;
11934   __pyx_L0:;
11935   if (__pyx_v_info->obj == Py_None) {
11936     __Pyx_GOTREF(__pyx_v_info->obj);
11937     __Pyx_DECREF(__pyx_v_info->obj); __pyx_v_info->obj = 0;
11938   }
11939   __pyx_L2:;
11940   __Pyx_RefNannyFinishContext();
11941   return __pyx_r;
11942 }
11943 
11944 /* "View.MemoryView":211
11945  *     __pyx_getbuffer = capsule(<void *> &__pyx_array_getbuffer, "getbuffer(obj, view, flags)")
11946  *
11947  *     def __dealloc__(array self):             # <<<<<<<<<<<<<<
11948  *         if self.callback_free_data != NULL:
11949  *             self.callback_free_data(self.data)
11950  */
11951 
11952 /* Python wrapper */
11953 static void __pyx_array___dealloc__(PyObject *__pyx_v_self); /*proto*/
__pyx_array___dealloc__(PyObject * __pyx_v_self)11954 static void __pyx_array___dealloc__(PyObject *__pyx_v_self) {
11955   __Pyx_RefNannyDeclarations
11956   __Pyx_RefNannySetupContext("__dealloc__ (wrapper)", 0);
11957   __pyx_array___pyx_pf_15View_dot_MemoryView_5array_4__dealloc__(((struct __pyx_array_obj *)__pyx_v_self));
11958 
11959   /* function exit code */
11960   __Pyx_RefNannyFinishContext();
11961 }
11962 
__pyx_array___pyx_pf_15View_dot_MemoryView_5array_4__dealloc__(struct __pyx_array_obj * __pyx_v_self)11963 static void __pyx_array___pyx_pf_15View_dot_MemoryView_5array_4__dealloc__(struct __pyx_array_obj *__pyx_v_self) {
11964   __Pyx_RefNannyDeclarations
11965   int __pyx_t_1;
11966   __Pyx_RefNannySetupContext("__dealloc__", 0);
11967 
11968   /* "View.MemoryView":212
11969  *
11970  *     def __dealloc__(array self):
11971  *         if self.callback_free_data != NULL:             # <<<<<<<<<<<<<<
11972  *             self.callback_free_data(self.data)
11973  *         elif self.free_data:
11974  */
11975   __pyx_t_1 = ((__pyx_v_self->callback_free_data != NULL) != 0);
11976   if (__pyx_t_1) {
11977 
11978     /* "View.MemoryView":213
11979  *     def __dealloc__(array self):
11980  *         if self.callback_free_data != NULL:
11981  *             self.callback_free_data(self.data)             # <<<<<<<<<<<<<<
11982  *         elif self.free_data:
11983  *             if self.dtype_is_object:
11984  */
11985     __pyx_v_self->callback_free_data(__pyx_v_self->data);
11986 
11987     /* "View.MemoryView":212
11988  *
11989  *     def __dealloc__(array self):
11990  *         if self.callback_free_data != NULL:             # <<<<<<<<<<<<<<
11991  *             self.callback_free_data(self.data)
11992  *         elif self.free_data:
11993  */
11994     goto __pyx_L3;
11995   }
11996 
11997   /* "View.MemoryView":214
11998  *         if self.callback_free_data != NULL:
11999  *             self.callback_free_data(self.data)
12000  *         elif self.free_data:             # <<<<<<<<<<<<<<
12001  *             if self.dtype_is_object:
12002  *                 refcount_objects_in_slice(self.data, self._shape,
12003  */
12004   __pyx_t_1 = (__pyx_v_self->free_data != 0);
12005   if (__pyx_t_1) {
12006 
12007     /* "View.MemoryView":215
12008  *             self.callback_free_data(self.data)
12009  *         elif self.free_data:
12010  *             if self.dtype_is_object:             # <<<<<<<<<<<<<<
12011  *                 refcount_objects_in_slice(self.data, self._shape,
12012  *                                           self._strides, self.ndim, False)
12013  */
12014     __pyx_t_1 = (__pyx_v_self->dtype_is_object != 0);
12015     if (__pyx_t_1) {
12016 
12017       /* "View.MemoryView":216
12018  *         elif self.free_data:
12019  *             if self.dtype_is_object:
12020  *                 refcount_objects_in_slice(self.data, self._shape,             # <<<<<<<<<<<<<<
12021  *                                           self._strides, self.ndim, False)
12022  *             free(self.data)
12023  */
12024       __pyx_memoryview_refcount_objects_in_slice(__pyx_v_self->data, __pyx_v_self->_shape, __pyx_v_self->_strides, __pyx_v_self->ndim, 0);
12025 
12026       /* "View.MemoryView":215
12027  *             self.callback_free_data(self.data)
12028  *         elif self.free_data:
12029  *             if self.dtype_is_object:             # <<<<<<<<<<<<<<
12030  *                 refcount_objects_in_slice(self.data, self._shape,
12031  *                                           self._strides, self.ndim, False)
12032  */
12033     }
12034 
12035     /* "View.MemoryView":218
12036  *                 refcount_objects_in_slice(self.data, self._shape,
12037  *                                           self._strides, self.ndim, False)
12038  *             free(self.data)             # <<<<<<<<<<<<<<
12039  *         PyObject_Free(self._shape)
12040  *
12041  */
12042     free(__pyx_v_self->data);
12043 
12044     /* "View.MemoryView":214
12045  *         if self.callback_free_data != NULL:
12046  *             self.callback_free_data(self.data)
12047  *         elif self.free_data:             # <<<<<<<<<<<<<<
12048  *             if self.dtype_is_object:
12049  *                 refcount_objects_in_slice(self.data, self._shape,
12050  */
12051   }
12052   __pyx_L3:;
12053 
12054   /* "View.MemoryView":219
12055  *                                           self._strides, self.ndim, False)
12056  *             free(self.data)
12057  *         PyObject_Free(self._shape)             # <<<<<<<<<<<<<<
12058  *
12059  *     @property
12060  */
12061   PyObject_Free(__pyx_v_self->_shape);
12062 
12063   /* "View.MemoryView":211
12064  *     __pyx_getbuffer = capsule(<void *> &__pyx_array_getbuffer, "getbuffer(obj, view, flags)")
12065  *
12066  *     def __dealloc__(array self):             # <<<<<<<<<<<<<<
12067  *         if self.callback_free_data != NULL:
12068  *             self.callback_free_data(self.data)
12069  */
12070 
12071   /* function exit code */
12072   __Pyx_RefNannyFinishContext();
12073 }
12074 
12075 /* "View.MemoryView":222
12076  *
12077  *     @property
12078  *     def memview(self):             # <<<<<<<<<<<<<<
12079  *         return self.get_memview()
12080  *
12081  */
12082 
12083 /* Python wrapper */
12084 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)12085 static PyObject *__pyx_pw_15View_dot_MemoryView_5array_7memview_1__get__(PyObject *__pyx_v_self) {
12086   PyObject *__pyx_r = 0;
12087   __Pyx_RefNannyDeclarations
12088   __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
12089   __pyx_r = __pyx_pf_15View_dot_MemoryView_5array_7memview___get__(((struct __pyx_array_obj *)__pyx_v_self));
12090 
12091   /* function exit code */
12092   __Pyx_RefNannyFinishContext();
12093   return __pyx_r;
12094 }
12095 
__pyx_pf_15View_dot_MemoryView_5array_7memview___get__(struct __pyx_array_obj * __pyx_v_self)12096 static PyObject *__pyx_pf_15View_dot_MemoryView_5array_7memview___get__(struct __pyx_array_obj *__pyx_v_self) {
12097   PyObject *__pyx_r = NULL;
12098   __Pyx_RefNannyDeclarations
12099   PyObject *__pyx_t_1 = NULL;
12100   int __pyx_lineno = 0;
12101   const char *__pyx_filename = NULL;
12102   int __pyx_clineno = 0;
12103   __Pyx_RefNannySetupContext("__get__", 0);
12104 
12105   /* "View.MemoryView":223
12106  *     @property
12107  *     def memview(self):
12108  *         return self.get_memview()             # <<<<<<<<<<<<<<
12109  *
12110  *     @cname('get_memview')
12111  */
12112   __Pyx_XDECREF(__pyx_r);
12113   __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)
12114   __Pyx_GOTREF(__pyx_t_1);
12115   __pyx_r = __pyx_t_1;
12116   __pyx_t_1 = 0;
12117   goto __pyx_L0;
12118 
12119   /* "View.MemoryView":222
12120  *
12121  *     @property
12122  *     def memview(self):             # <<<<<<<<<<<<<<
12123  *         return self.get_memview()
12124  *
12125  */
12126 
12127   /* function exit code */
12128   __pyx_L1_error:;
12129   __Pyx_XDECREF(__pyx_t_1);
12130   __Pyx_AddTraceback("View.MemoryView.array.memview.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
12131   __pyx_r = NULL;
12132   __pyx_L0:;
12133   __Pyx_XGIVEREF(__pyx_r);
12134   __Pyx_RefNannyFinishContext();
12135   return __pyx_r;
12136 }
12137 
12138 /* "View.MemoryView":226
12139  *
12140  *     @cname('get_memview')
12141  *     cdef get_memview(self):             # <<<<<<<<<<<<<<
12142  *         flags =  PyBUF_ANY_CONTIGUOUS|PyBUF_FORMAT|PyBUF_WRITABLE
12143  *         return  memoryview(self, flags, self.dtype_is_object)
12144  */
12145 
__pyx_array_get_memview(struct __pyx_array_obj * __pyx_v_self)12146 static PyObject *__pyx_array_get_memview(struct __pyx_array_obj *__pyx_v_self) {
12147   int __pyx_v_flags;
12148   PyObject *__pyx_r = NULL;
12149   __Pyx_RefNannyDeclarations
12150   PyObject *__pyx_t_1 = NULL;
12151   PyObject *__pyx_t_2 = NULL;
12152   PyObject *__pyx_t_3 = NULL;
12153   int __pyx_lineno = 0;
12154   const char *__pyx_filename = NULL;
12155   int __pyx_clineno = 0;
12156   __Pyx_RefNannySetupContext("get_memview", 0);
12157 
12158   /* "View.MemoryView":227
12159  *     @cname('get_memview')
12160  *     cdef get_memview(self):
12161  *         flags =  PyBUF_ANY_CONTIGUOUS|PyBUF_FORMAT|PyBUF_WRITABLE             # <<<<<<<<<<<<<<
12162  *         return  memoryview(self, flags, self.dtype_is_object)
12163  *
12164  */
12165   __pyx_v_flags = ((PyBUF_ANY_CONTIGUOUS | PyBUF_FORMAT) | PyBUF_WRITABLE);
12166 
12167   /* "View.MemoryView":228
12168  *     cdef get_memview(self):
12169  *         flags =  PyBUF_ANY_CONTIGUOUS|PyBUF_FORMAT|PyBUF_WRITABLE
12170  *         return  memoryview(self, flags, self.dtype_is_object)             # <<<<<<<<<<<<<<
12171  *
12172  *     def __len__(self):
12173  */
12174   __Pyx_XDECREF(__pyx_r);
12175   __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_flags); if (unlikely(!__pyx_t_1)) __PYX_ERR(3, 228, __pyx_L1_error)
12176   __Pyx_GOTREF(__pyx_t_1);
12177   __pyx_t_2 = __Pyx_PyBool_FromLong(__pyx_v_self->dtype_is_object); if (unlikely(!__pyx_t_2)) __PYX_ERR(3, 228, __pyx_L1_error)
12178   __Pyx_GOTREF(__pyx_t_2);
12179   __pyx_t_3 = PyTuple_New(3); if (unlikely(!__pyx_t_3)) __PYX_ERR(3, 228, __pyx_L1_error)
12180   __Pyx_GOTREF(__pyx_t_3);
12181   __Pyx_INCREF(((PyObject *)__pyx_v_self));
12182   __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
12183   PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)__pyx_v_self));
12184   __Pyx_GIVEREF(__pyx_t_1);
12185   PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_1);
12186   __Pyx_GIVEREF(__pyx_t_2);
12187   PyTuple_SET_ITEM(__pyx_t_3, 2, __pyx_t_2);
12188   __pyx_t_1 = 0;
12189   __pyx_t_2 = 0;
12190   __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)
12191   __Pyx_GOTREF(__pyx_t_2);
12192   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
12193   __pyx_r = __pyx_t_2;
12194   __pyx_t_2 = 0;
12195   goto __pyx_L0;
12196 
12197   /* "View.MemoryView":226
12198  *
12199  *     @cname('get_memview')
12200  *     cdef get_memview(self):             # <<<<<<<<<<<<<<
12201  *         flags =  PyBUF_ANY_CONTIGUOUS|PyBUF_FORMAT|PyBUF_WRITABLE
12202  *         return  memoryview(self, flags, self.dtype_is_object)
12203  */
12204 
12205   /* function exit code */
12206   __pyx_L1_error:;
12207   __Pyx_XDECREF(__pyx_t_1);
12208   __Pyx_XDECREF(__pyx_t_2);
12209   __Pyx_XDECREF(__pyx_t_3);
12210   __Pyx_AddTraceback("View.MemoryView.array.get_memview", __pyx_clineno, __pyx_lineno, __pyx_filename);
12211   __pyx_r = 0;
12212   __pyx_L0:;
12213   __Pyx_XGIVEREF(__pyx_r);
12214   __Pyx_RefNannyFinishContext();
12215   return __pyx_r;
12216 }
12217 
12218 /* "View.MemoryView":230
12219  *         return  memoryview(self, flags, self.dtype_is_object)
12220  *
12221  *     def __len__(self):             # <<<<<<<<<<<<<<
12222  *         return self._shape[0]
12223  *
12224  */
12225 
12226 /* Python wrapper */
12227 static Py_ssize_t __pyx_array___len__(PyObject *__pyx_v_self); /*proto*/
__pyx_array___len__(PyObject * __pyx_v_self)12228 static Py_ssize_t __pyx_array___len__(PyObject *__pyx_v_self) {
12229   Py_ssize_t __pyx_r;
12230   __Pyx_RefNannyDeclarations
12231   __Pyx_RefNannySetupContext("__len__ (wrapper)", 0);
12232   __pyx_r = __pyx_array___pyx_pf_15View_dot_MemoryView_5array_6__len__(((struct __pyx_array_obj *)__pyx_v_self));
12233 
12234   /* function exit code */
12235   __Pyx_RefNannyFinishContext();
12236   return __pyx_r;
12237 }
12238 
__pyx_array___pyx_pf_15View_dot_MemoryView_5array_6__len__(struct __pyx_array_obj * __pyx_v_self)12239 static Py_ssize_t __pyx_array___pyx_pf_15View_dot_MemoryView_5array_6__len__(struct __pyx_array_obj *__pyx_v_self) {
12240   Py_ssize_t __pyx_r;
12241   __Pyx_RefNannyDeclarations
12242   __Pyx_RefNannySetupContext("__len__", 0);
12243 
12244   /* "View.MemoryView":231
12245  *
12246  *     def __len__(self):
12247  *         return self._shape[0]             # <<<<<<<<<<<<<<
12248  *
12249  *     def __getattr__(self, attr):
12250  */
12251   __pyx_r = (__pyx_v_self->_shape[0]);
12252   goto __pyx_L0;
12253 
12254   /* "View.MemoryView":230
12255  *         return  memoryview(self, flags, self.dtype_is_object)
12256  *
12257  *     def __len__(self):             # <<<<<<<<<<<<<<
12258  *         return self._shape[0]
12259  *
12260  */
12261 
12262   /* function exit code */
12263   __pyx_L0:;
12264   __Pyx_RefNannyFinishContext();
12265   return __pyx_r;
12266 }
12267 
12268 /* "View.MemoryView":233
12269  *         return self._shape[0]
12270  *
12271  *     def __getattr__(self, attr):             # <<<<<<<<<<<<<<
12272  *         return getattr(self.memview, attr)
12273  *
12274  */
12275 
12276 /* Python wrapper */
12277 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)12278 static PyObject *__pyx_array___getattr__(PyObject *__pyx_v_self, PyObject *__pyx_v_attr) {
12279   PyObject *__pyx_r = 0;
12280   __Pyx_RefNannyDeclarations
12281   __Pyx_RefNannySetupContext("__getattr__ (wrapper)", 0);
12282   __pyx_r = __pyx_array___pyx_pf_15View_dot_MemoryView_5array_8__getattr__(((struct __pyx_array_obj *)__pyx_v_self), ((PyObject *)__pyx_v_attr));
12283 
12284   /* function exit code */
12285   __Pyx_RefNannyFinishContext();
12286   return __pyx_r;
12287 }
12288 
__pyx_array___pyx_pf_15View_dot_MemoryView_5array_8__getattr__(struct __pyx_array_obj * __pyx_v_self,PyObject * __pyx_v_attr)12289 static PyObject *__pyx_array___pyx_pf_15View_dot_MemoryView_5array_8__getattr__(struct __pyx_array_obj *__pyx_v_self, PyObject *__pyx_v_attr) {
12290   PyObject *__pyx_r = NULL;
12291   __Pyx_RefNannyDeclarations
12292   PyObject *__pyx_t_1 = NULL;
12293   PyObject *__pyx_t_2 = NULL;
12294   int __pyx_lineno = 0;
12295   const char *__pyx_filename = NULL;
12296   int __pyx_clineno = 0;
12297   __Pyx_RefNannySetupContext("__getattr__", 0);
12298 
12299   /* "View.MemoryView":234
12300  *
12301  *     def __getattr__(self, attr):
12302  *         return getattr(self.memview, attr)             # <<<<<<<<<<<<<<
12303  *
12304  *     def __getitem__(self, item):
12305  */
12306   __Pyx_XDECREF(__pyx_r);
12307   __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)
12308   __Pyx_GOTREF(__pyx_t_1);
12309   __pyx_t_2 = __Pyx_GetAttr(__pyx_t_1, __pyx_v_attr); if (unlikely(!__pyx_t_2)) __PYX_ERR(3, 234, __pyx_L1_error)
12310   __Pyx_GOTREF(__pyx_t_2);
12311   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
12312   __pyx_r = __pyx_t_2;
12313   __pyx_t_2 = 0;
12314   goto __pyx_L0;
12315 
12316   /* "View.MemoryView":233
12317  *         return self._shape[0]
12318  *
12319  *     def __getattr__(self, attr):             # <<<<<<<<<<<<<<
12320  *         return getattr(self.memview, attr)
12321  *
12322  */
12323 
12324   /* function exit code */
12325   __pyx_L1_error:;
12326   __Pyx_XDECREF(__pyx_t_1);
12327   __Pyx_XDECREF(__pyx_t_2);
12328   __Pyx_AddTraceback("View.MemoryView.array.__getattr__", __pyx_clineno, __pyx_lineno, __pyx_filename);
12329   __pyx_r = NULL;
12330   __pyx_L0:;
12331   __Pyx_XGIVEREF(__pyx_r);
12332   __Pyx_RefNannyFinishContext();
12333   return __pyx_r;
12334 }
12335 
12336 /* "View.MemoryView":236
12337  *         return getattr(self.memview, attr)
12338  *
12339  *     def __getitem__(self, item):             # <<<<<<<<<<<<<<
12340  *         return self.memview[item]
12341  *
12342  */
12343 
12344 /* Python wrapper */
12345 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)12346 static PyObject *__pyx_array___getitem__(PyObject *__pyx_v_self, PyObject *__pyx_v_item) {
12347   PyObject *__pyx_r = 0;
12348   __Pyx_RefNannyDeclarations
12349   __Pyx_RefNannySetupContext("__getitem__ (wrapper)", 0);
12350   __pyx_r = __pyx_array___pyx_pf_15View_dot_MemoryView_5array_10__getitem__(((struct __pyx_array_obj *)__pyx_v_self), ((PyObject *)__pyx_v_item));
12351 
12352   /* function exit code */
12353   __Pyx_RefNannyFinishContext();
12354   return __pyx_r;
12355 }
12356 
__pyx_array___pyx_pf_15View_dot_MemoryView_5array_10__getitem__(struct __pyx_array_obj * __pyx_v_self,PyObject * __pyx_v_item)12357 static PyObject *__pyx_array___pyx_pf_15View_dot_MemoryView_5array_10__getitem__(struct __pyx_array_obj *__pyx_v_self, PyObject *__pyx_v_item) {
12358   PyObject *__pyx_r = NULL;
12359   __Pyx_RefNannyDeclarations
12360   PyObject *__pyx_t_1 = NULL;
12361   PyObject *__pyx_t_2 = NULL;
12362   int __pyx_lineno = 0;
12363   const char *__pyx_filename = NULL;
12364   int __pyx_clineno = 0;
12365   __Pyx_RefNannySetupContext("__getitem__", 0);
12366 
12367   /* "View.MemoryView":237
12368  *
12369  *     def __getitem__(self, item):
12370  *         return self.memview[item]             # <<<<<<<<<<<<<<
12371  *
12372  *     def __setitem__(self, item, value):
12373  */
12374   __Pyx_XDECREF(__pyx_r);
12375   __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)
12376   __Pyx_GOTREF(__pyx_t_1);
12377   __pyx_t_2 = __Pyx_PyObject_GetItem(__pyx_t_1, __pyx_v_item); if (unlikely(!__pyx_t_2)) __PYX_ERR(3, 237, __pyx_L1_error)
12378   __Pyx_GOTREF(__pyx_t_2);
12379   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
12380   __pyx_r = __pyx_t_2;
12381   __pyx_t_2 = 0;
12382   goto __pyx_L0;
12383 
12384   /* "View.MemoryView":236
12385  *         return getattr(self.memview, attr)
12386  *
12387  *     def __getitem__(self, item):             # <<<<<<<<<<<<<<
12388  *         return self.memview[item]
12389  *
12390  */
12391 
12392   /* function exit code */
12393   __pyx_L1_error:;
12394   __Pyx_XDECREF(__pyx_t_1);
12395   __Pyx_XDECREF(__pyx_t_2);
12396   __Pyx_AddTraceback("View.MemoryView.array.__getitem__", __pyx_clineno, __pyx_lineno, __pyx_filename);
12397   __pyx_r = NULL;
12398   __pyx_L0:;
12399   __Pyx_XGIVEREF(__pyx_r);
12400   __Pyx_RefNannyFinishContext();
12401   return __pyx_r;
12402 }
12403 
12404 /* "View.MemoryView":239
12405  *         return self.memview[item]
12406  *
12407  *     def __setitem__(self, item, value):             # <<<<<<<<<<<<<<
12408  *         self.memview[item] = value
12409  *
12410  */
12411 
12412 /* Python wrapper */
12413 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)12414 static int __pyx_array___setitem__(PyObject *__pyx_v_self, PyObject *__pyx_v_item, PyObject *__pyx_v_value) {
12415   int __pyx_r;
12416   __Pyx_RefNannyDeclarations
12417   __Pyx_RefNannySetupContext("__setitem__ (wrapper)", 0);
12418   __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));
12419 
12420   /* function exit code */
12421   __Pyx_RefNannyFinishContext();
12422   return __pyx_r;
12423 }
12424 
__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)12425 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) {
12426   int __pyx_r;
12427   __Pyx_RefNannyDeclarations
12428   PyObject *__pyx_t_1 = NULL;
12429   int __pyx_lineno = 0;
12430   const char *__pyx_filename = NULL;
12431   int __pyx_clineno = 0;
12432   __Pyx_RefNannySetupContext("__setitem__", 0);
12433 
12434   /* "View.MemoryView":240
12435  *
12436  *     def __setitem__(self, item, value):
12437  *         self.memview[item] = value             # <<<<<<<<<<<<<<
12438  *
12439  *
12440  */
12441   __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)
12442   __Pyx_GOTREF(__pyx_t_1);
12443   if (unlikely(PyObject_SetItem(__pyx_t_1, __pyx_v_item, __pyx_v_value) < 0)) __PYX_ERR(3, 240, __pyx_L1_error)
12444   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
12445 
12446   /* "View.MemoryView":239
12447  *         return self.memview[item]
12448  *
12449  *     def __setitem__(self, item, value):             # <<<<<<<<<<<<<<
12450  *         self.memview[item] = value
12451  *
12452  */
12453 
12454   /* function exit code */
12455   __pyx_r = 0;
12456   goto __pyx_L0;
12457   __pyx_L1_error:;
12458   __Pyx_XDECREF(__pyx_t_1);
12459   __Pyx_AddTraceback("View.MemoryView.array.__setitem__", __pyx_clineno, __pyx_lineno, __pyx_filename);
12460   __pyx_r = -1;
12461   __pyx_L0:;
12462   __Pyx_RefNannyFinishContext();
12463   return __pyx_r;
12464 }
12465 
12466 /* "(tree fragment)":1
12467  * def __reduce_cython__(self):             # <<<<<<<<<<<<<<
12468  *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
12469  * def __setstate_cython__(self, __pyx_state):
12470  */
12471 
12472 /* Python wrapper */
12473 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)12474 static PyObject *__pyx_pw___pyx_array_1__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
12475   PyObject *__pyx_r = 0;
12476   __Pyx_RefNannyDeclarations
12477   __Pyx_RefNannySetupContext("__reduce_cython__ (wrapper)", 0);
12478   __pyx_r = __pyx_pf___pyx_array___reduce_cython__(((struct __pyx_array_obj *)__pyx_v_self));
12479 
12480   /* function exit code */
12481   __Pyx_RefNannyFinishContext();
12482   return __pyx_r;
12483 }
12484 
__pyx_pf___pyx_array___reduce_cython__(CYTHON_UNUSED struct __pyx_array_obj * __pyx_v_self)12485 static PyObject *__pyx_pf___pyx_array___reduce_cython__(CYTHON_UNUSED struct __pyx_array_obj *__pyx_v_self) {
12486   PyObject *__pyx_r = NULL;
12487   __Pyx_RefNannyDeclarations
12488   PyObject *__pyx_t_1 = NULL;
12489   int __pyx_lineno = 0;
12490   const char *__pyx_filename = NULL;
12491   int __pyx_clineno = 0;
12492   __Pyx_RefNannySetupContext("__reduce_cython__", 0);
12493 
12494   /* "(tree fragment)":2
12495  * def __reduce_cython__(self):
12496  *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")             # <<<<<<<<<<<<<<
12497  * def __setstate_cython__(self, __pyx_state):
12498  *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
12499  */
12500   __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__24, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(3, 2, __pyx_L1_error)
12501   __Pyx_GOTREF(__pyx_t_1);
12502   __Pyx_Raise(__pyx_t_1, 0, 0, 0);
12503   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
12504   __PYX_ERR(3, 2, __pyx_L1_error)
12505 
12506   /* "(tree fragment)":1
12507  * def __reduce_cython__(self):             # <<<<<<<<<<<<<<
12508  *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
12509  * def __setstate_cython__(self, __pyx_state):
12510  */
12511 
12512   /* function exit code */
12513   __pyx_L1_error:;
12514   __Pyx_XDECREF(__pyx_t_1);
12515   __Pyx_AddTraceback("View.MemoryView.array.__reduce_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename);
12516   __pyx_r = NULL;
12517   __Pyx_XGIVEREF(__pyx_r);
12518   __Pyx_RefNannyFinishContext();
12519   return __pyx_r;
12520 }
12521 
12522 /* "(tree fragment)":3
12523  * def __reduce_cython__(self):
12524  *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
12525  * def __setstate_cython__(self, __pyx_state):             # <<<<<<<<<<<<<<
12526  *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
12527  */
12528 
12529 /* Python wrapper */
12530 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)12531 static PyObject *__pyx_pw___pyx_array_3__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state) {
12532   PyObject *__pyx_r = 0;
12533   __Pyx_RefNannyDeclarations
12534   __Pyx_RefNannySetupContext("__setstate_cython__ (wrapper)", 0);
12535   __pyx_r = __pyx_pf___pyx_array_2__setstate_cython__(((struct __pyx_array_obj *)__pyx_v_self), ((PyObject *)__pyx_v___pyx_state));
12536 
12537   /* function exit code */
12538   __Pyx_RefNannyFinishContext();
12539   return __pyx_r;
12540 }
12541 
__pyx_pf___pyx_array_2__setstate_cython__(CYTHON_UNUSED struct __pyx_array_obj * __pyx_v_self,CYTHON_UNUSED PyObject * __pyx_v___pyx_state)12542 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) {
12543   PyObject *__pyx_r = NULL;
12544   __Pyx_RefNannyDeclarations
12545   PyObject *__pyx_t_1 = NULL;
12546   int __pyx_lineno = 0;
12547   const char *__pyx_filename = NULL;
12548   int __pyx_clineno = 0;
12549   __Pyx_RefNannySetupContext("__setstate_cython__", 0);
12550 
12551   /* "(tree fragment)":4
12552  *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
12553  * def __setstate_cython__(self, __pyx_state):
12554  *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")             # <<<<<<<<<<<<<<
12555  */
12556   __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__25, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(3, 4, __pyx_L1_error)
12557   __Pyx_GOTREF(__pyx_t_1);
12558   __Pyx_Raise(__pyx_t_1, 0, 0, 0);
12559   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
12560   __PYX_ERR(3, 4, __pyx_L1_error)
12561 
12562   /* "(tree fragment)":3
12563  * def __reduce_cython__(self):
12564  *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
12565  * def __setstate_cython__(self, __pyx_state):             # <<<<<<<<<<<<<<
12566  *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
12567  */
12568 
12569   /* function exit code */
12570   __pyx_L1_error:;
12571   __Pyx_XDECREF(__pyx_t_1);
12572   __Pyx_AddTraceback("View.MemoryView.array.__setstate_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename);
12573   __pyx_r = NULL;
12574   __Pyx_XGIVEREF(__pyx_r);
12575   __Pyx_RefNannyFinishContext();
12576   return __pyx_r;
12577 }
12578 
12579 /* "View.MemoryView":244
12580  *
12581  * @cname("__pyx_array_new")
12582  * cdef array array_cwrapper(tuple shape, Py_ssize_t itemsize, char *format,             # <<<<<<<<<<<<<<
12583  *                           char *mode, char *buf):
12584  *     cdef array result
12585  */
12586 
__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)12587 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) {
12588   struct __pyx_array_obj *__pyx_v_result = 0;
12589   struct __pyx_array_obj *__pyx_r = NULL;
12590   __Pyx_RefNannyDeclarations
12591   int __pyx_t_1;
12592   PyObject *__pyx_t_2 = NULL;
12593   PyObject *__pyx_t_3 = NULL;
12594   PyObject *__pyx_t_4 = NULL;
12595   PyObject *__pyx_t_5 = NULL;
12596   int __pyx_lineno = 0;
12597   const char *__pyx_filename = NULL;
12598   int __pyx_clineno = 0;
12599   __Pyx_RefNannySetupContext("array_cwrapper", 0);
12600 
12601   /* "View.MemoryView":248
12602  *     cdef array result
12603  *
12604  *     if buf == NULL:             # <<<<<<<<<<<<<<
12605  *         result = array(shape, itemsize, format, mode.decode('ASCII'))
12606  *     else:
12607  */
12608   __pyx_t_1 = ((__pyx_v_buf == NULL) != 0);
12609   if (__pyx_t_1) {
12610 
12611     /* "View.MemoryView":249
12612  *
12613  *     if buf == NULL:
12614  *         result = array(shape, itemsize, format, mode.decode('ASCII'))             # <<<<<<<<<<<<<<
12615  *     else:
12616  *         result = array(shape, itemsize, format, mode.decode('ASCII'),
12617  */
12618     __pyx_t_2 = PyInt_FromSsize_t(__pyx_v_itemsize); if (unlikely(!__pyx_t_2)) __PYX_ERR(3, 249, __pyx_L1_error)
12619     __Pyx_GOTREF(__pyx_t_2);
12620     __pyx_t_3 = __Pyx_PyBytes_FromString(__pyx_v_format); if (unlikely(!__pyx_t_3)) __PYX_ERR(3, 249, __pyx_L1_error)
12621     __Pyx_GOTREF(__pyx_t_3);
12622     __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)
12623     __Pyx_GOTREF(__pyx_t_4);
12624     __pyx_t_5 = PyTuple_New(4); if (unlikely(!__pyx_t_5)) __PYX_ERR(3, 249, __pyx_L1_error)
12625     __Pyx_GOTREF(__pyx_t_5);
12626     __Pyx_INCREF(__pyx_v_shape);
12627     __Pyx_GIVEREF(__pyx_v_shape);
12628     PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_v_shape);
12629     __Pyx_GIVEREF(__pyx_t_2);
12630     PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_t_2);
12631     __Pyx_GIVEREF(__pyx_t_3);
12632     PyTuple_SET_ITEM(__pyx_t_5, 2, __pyx_t_3);
12633     __Pyx_GIVEREF(__pyx_t_4);
12634     PyTuple_SET_ITEM(__pyx_t_5, 3, __pyx_t_4);
12635     __pyx_t_2 = 0;
12636     __pyx_t_3 = 0;
12637     __pyx_t_4 = 0;
12638     __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)
12639     __Pyx_GOTREF(__pyx_t_4);
12640     __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
12641     __pyx_v_result = ((struct __pyx_array_obj *)__pyx_t_4);
12642     __pyx_t_4 = 0;
12643 
12644     /* "View.MemoryView":248
12645  *     cdef array result
12646  *
12647  *     if buf == NULL:             # <<<<<<<<<<<<<<
12648  *         result = array(shape, itemsize, format, mode.decode('ASCII'))
12649  *     else:
12650  */
12651     goto __pyx_L3;
12652   }
12653 
12654   /* "View.MemoryView":251
12655  *         result = array(shape, itemsize, format, mode.decode('ASCII'))
12656  *     else:
12657  *         result = array(shape, itemsize, format, mode.decode('ASCII'),             # <<<<<<<<<<<<<<
12658  *                        allocate_buffer=False)
12659  *         result.data = buf
12660  */
12661   /*else*/ {
12662     __pyx_t_4 = PyInt_FromSsize_t(__pyx_v_itemsize); if (unlikely(!__pyx_t_4)) __PYX_ERR(3, 251, __pyx_L1_error)
12663     __Pyx_GOTREF(__pyx_t_4);
12664     __pyx_t_5 = __Pyx_PyBytes_FromString(__pyx_v_format); if (unlikely(!__pyx_t_5)) __PYX_ERR(3, 251, __pyx_L1_error)
12665     __Pyx_GOTREF(__pyx_t_5);
12666     __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)
12667     __Pyx_GOTREF(__pyx_t_3);
12668     __pyx_t_2 = PyTuple_New(4); if (unlikely(!__pyx_t_2)) __PYX_ERR(3, 251, __pyx_L1_error)
12669     __Pyx_GOTREF(__pyx_t_2);
12670     __Pyx_INCREF(__pyx_v_shape);
12671     __Pyx_GIVEREF(__pyx_v_shape);
12672     PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_shape);
12673     __Pyx_GIVEREF(__pyx_t_4);
12674     PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_t_4);
12675     __Pyx_GIVEREF(__pyx_t_5);
12676     PyTuple_SET_ITEM(__pyx_t_2, 2, __pyx_t_5);
12677     __Pyx_GIVEREF(__pyx_t_3);
12678     PyTuple_SET_ITEM(__pyx_t_2, 3, __pyx_t_3);
12679     __pyx_t_4 = 0;
12680     __pyx_t_5 = 0;
12681     __pyx_t_3 = 0;
12682 
12683     /* "View.MemoryView":252
12684  *     else:
12685  *         result = array(shape, itemsize, format, mode.decode('ASCII'),
12686  *                        allocate_buffer=False)             # <<<<<<<<<<<<<<
12687  *         result.data = buf
12688  *
12689  */
12690     __pyx_t_3 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(3, 252, __pyx_L1_error)
12691     __Pyx_GOTREF(__pyx_t_3);
12692     if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_allocate_buffer, Py_False) < 0) __PYX_ERR(3, 252, __pyx_L1_error)
12693 
12694     /* "View.MemoryView":251
12695  *         result = array(shape, itemsize, format, mode.decode('ASCII'))
12696  *     else:
12697  *         result = array(shape, itemsize, format, mode.decode('ASCII'),             # <<<<<<<<<<<<<<
12698  *                        allocate_buffer=False)
12699  *         result.data = buf
12700  */
12701     __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)
12702     __Pyx_GOTREF(__pyx_t_5);
12703     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
12704     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
12705     __pyx_v_result = ((struct __pyx_array_obj *)__pyx_t_5);
12706     __pyx_t_5 = 0;
12707 
12708     /* "View.MemoryView":253
12709  *         result = array(shape, itemsize, format, mode.decode('ASCII'),
12710  *                        allocate_buffer=False)
12711  *         result.data = buf             # <<<<<<<<<<<<<<
12712  *
12713  *     return result
12714  */
12715     __pyx_v_result->data = __pyx_v_buf;
12716   }
12717   __pyx_L3:;
12718 
12719   /* "View.MemoryView":255
12720  *         result.data = buf
12721  *
12722  *     return result             # <<<<<<<<<<<<<<
12723  *
12724  *
12725  */
12726   __Pyx_XDECREF(((PyObject *)__pyx_r));
12727   __Pyx_INCREF(((PyObject *)__pyx_v_result));
12728   __pyx_r = __pyx_v_result;
12729   goto __pyx_L0;
12730 
12731   /* "View.MemoryView":244
12732  *
12733  * @cname("__pyx_array_new")
12734  * cdef array array_cwrapper(tuple shape, Py_ssize_t itemsize, char *format,             # <<<<<<<<<<<<<<
12735  *                           char *mode, char *buf):
12736  *     cdef array result
12737  */
12738 
12739   /* function exit code */
12740   __pyx_L1_error:;
12741   __Pyx_XDECREF(__pyx_t_2);
12742   __Pyx_XDECREF(__pyx_t_3);
12743   __Pyx_XDECREF(__pyx_t_4);
12744   __Pyx_XDECREF(__pyx_t_5);
12745   __Pyx_AddTraceback("View.MemoryView.array_cwrapper", __pyx_clineno, __pyx_lineno, __pyx_filename);
12746   __pyx_r = 0;
12747   __pyx_L0:;
12748   __Pyx_XDECREF((PyObject *)__pyx_v_result);
12749   __Pyx_XGIVEREF((PyObject *)__pyx_r);
12750   __Pyx_RefNannyFinishContext();
12751   return __pyx_r;
12752 }
12753 
12754 /* "View.MemoryView":281
12755  * cdef class Enum(object):
12756  *     cdef object name
12757  *     def __init__(self, name):             # <<<<<<<<<<<<<<
12758  *         self.name = name
12759  *     def __repr__(self):
12760  */
12761 
12762 /* Python wrapper */
12763 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)12764 static int __pyx_MemviewEnum___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
12765   PyObject *__pyx_v_name = 0;
12766   int __pyx_lineno = 0;
12767   const char *__pyx_filename = NULL;
12768   int __pyx_clineno = 0;
12769   int __pyx_r;
12770   __Pyx_RefNannyDeclarations
12771   __Pyx_RefNannySetupContext("__init__ (wrapper)", 0);
12772   {
12773     static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_name,0};
12774     PyObject* values[1] = {0};
12775     if (unlikely(__pyx_kwds)) {
12776       Py_ssize_t kw_args;
12777       const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
12778       switch (pos_args) {
12779         case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
12780         CYTHON_FALLTHROUGH;
12781         case  0: break;
12782         default: goto __pyx_L5_argtuple_error;
12783       }
12784       kw_args = PyDict_Size(__pyx_kwds);
12785       switch (pos_args) {
12786         case  0:
12787         if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_name)) != 0)) kw_args--;
12788         else goto __pyx_L5_argtuple_error;
12789       }
12790       if (unlikely(kw_args > 0)) {
12791         if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__init__") < 0)) __PYX_ERR(3, 281, __pyx_L3_error)
12792       }
12793     } else if (PyTuple_GET_SIZE(__pyx_args) != 1) {
12794       goto __pyx_L5_argtuple_error;
12795     } else {
12796       values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
12797     }
12798     __pyx_v_name = values[0];
12799   }
12800   goto __pyx_L4_argument_unpacking_done;
12801   __pyx_L5_argtuple_error:;
12802   __Pyx_RaiseArgtupleInvalid("__init__", 1, 1, 1, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(3, 281, __pyx_L3_error)
12803   __pyx_L3_error:;
12804   __Pyx_AddTraceback("View.MemoryView.Enum.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
12805   __Pyx_RefNannyFinishContext();
12806   return -1;
12807   __pyx_L4_argument_unpacking_done:;
12808   __pyx_r = __pyx_MemviewEnum___pyx_pf_15View_dot_MemoryView_4Enum___init__(((struct __pyx_MemviewEnum_obj *)__pyx_v_self), __pyx_v_name);
12809 
12810   /* function exit code */
12811   __Pyx_RefNannyFinishContext();
12812   return __pyx_r;
12813 }
12814 
__pyx_MemviewEnum___pyx_pf_15View_dot_MemoryView_4Enum___init__(struct __pyx_MemviewEnum_obj * __pyx_v_self,PyObject * __pyx_v_name)12815 static int __pyx_MemviewEnum___pyx_pf_15View_dot_MemoryView_4Enum___init__(struct __pyx_MemviewEnum_obj *__pyx_v_self, PyObject *__pyx_v_name) {
12816   int __pyx_r;
12817   __Pyx_RefNannyDeclarations
12818   __Pyx_RefNannySetupContext("__init__", 0);
12819 
12820   /* "View.MemoryView":282
12821  *     cdef object name
12822  *     def __init__(self, name):
12823  *         self.name = name             # <<<<<<<<<<<<<<
12824  *     def __repr__(self):
12825  *         return self.name
12826  */
12827   __Pyx_INCREF(__pyx_v_name);
12828   __Pyx_GIVEREF(__pyx_v_name);
12829   __Pyx_GOTREF(__pyx_v_self->name);
12830   __Pyx_DECREF(__pyx_v_self->name);
12831   __pyx_v_self->name = __pyx_v_name;
12832 
12833   /* "View.MemoryView":281
12834  * cdef class Enum(object):
12835  *     cdef object name
12836  *     def __init__(self, name):             # <<<<<<<<<<<<<<
12837  *         self.name = name
12838  *     def __repr__(self):
12839  */
12840 
12841   /* function exit code */
12842   __pyx_r = 0;
12843   __Pyx_RefNannyFinishContext();
12844   return __pyx_r;
12845 }
12846 
12847 /* "View.MemoryView":283
12848  *     def __init__(self, name):
12849  *         self.name = name
12850  *     def __repr__(self):             # <<<<<<<<<<<<<<
12851  *         return self.name
12852  *
12853  */
12854 
12855 /* Python wrapper */
12856 static PyObject *__pyx_MemviewEnum___repr__(PyObject *__pyx_v_self); /*proto*/
__pyx_MemviewEnum___repr__(PyObject * __pyx_v_self)12857 static PyObject *__pyx_MemviewEnum___repr__(PyObject *__pyx_v_self) {
12858   PyObject *__pyx_r = 0;
12859   __Pyx_RefNannyDeclarations
12860   __Pyx_RefNannySetupContext("__repr__ (wrapper)", 0);
12861   __pyx_r = __pyx_MemviewEnum___pyx_pf_15View_dot_MemoryView_4Enum_2__repr__(((struct __pyx_MemviewEnum_obj *)__pyx_v_self));
12862 
12863   /* function exit code */
12864   __Pyx_RefNannyFinishContext();
12865   return __pyx_r;
12866 }
12867 
__pyx_MemviewEnum___pyx_pf_15View_dot_MemoryView_4Enum_2__repr__(struct __pyx_MemviewEnum_obj * __pyx_v_self)12868 static PyObject *__pyx_MemviewEnum___pyx_pf_15View_dot_MemoryView_4Enum_2__repr__(struct __pyx_MemviewEnum_obj *__pyx_v_self) {
12869   PyObject *__pyx_r = NULL;
12870   __Pyx_RefNannyDeclarations
12871   __Pyx_RefNannySetupContext("__repr__", 0);
12872 
12873   /* "View.MemoryView":284
12874  *         self.name = name
12875  *     def __repr__(self):
12876  *         return self.name             # <<<<<<<<<<<<<<
12877  *
12878  * cdef generic = Enum("<strided and direct or indirect>")
12879  */
12880   __Pyx_XDECREF(__pyx_r);
12881   __Pyx_INCREF(__pyx_v_self->name);
12882   __pyx_r = __pyx_v_self->name;
12883   goto __pyx_L0;
12884 
12885   /* "View.MemoryView":283
12886  *     def __init__(self, name):
12887  *         self.name = name
12888  *     def __repr__(self):             # <<<<<<<<<<<<<<
12889  *         return self.name
12890  *
12891  */
12892 
12893   /* function exit code */
12894   __pyx_L0:;
12895   __Pyx_XGIVEREF(__pyx_r);
12896   __Pyx_RefNannyFinishContext();
12897   return __pyx_r;
12898 }
12899 
12900 /* "(tree fragment)":1
12901  * def __reduce_cython__(self):             # <<<<<<<<<<<<<<
12902  *     cdef tuple state
12903  *     cdef object _dict
12904  */
12905 
12906 /* Python wrapper */
12907 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)12908 static PyObject *__pyx_pw___pyx_MemviewEnum_1__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
12909   PyObject *__pyx_r = 0;
12910   __Pyx_RefNannyDeclarations
12911   __Pyx_RefNannySetupContext("__reduce_cython__ (wrapper)", 0);
12912   __pyx_r = __pyx_pf___pyx_MemviewEnum___reduce_cython__(((struct __pyx_MemviewEnum_obj *)__pyx_v_self));
12913 
12914   /* function exit code */
12915   __Pyx_RefNannyFinishContext();
12916   return __pyx_r;
12917 }
12918 
__pyx_pf___pyx_MemviewEnum___reduce_cython__(struct __pyx_MemviewEnum_obj * __pyx_v_self)12919 static PyObject *__pyx_pf___pyx_MemviewEnum___reduce_cython__(struct __pyx_MemviewEnum_obj *__pyx_v_self) {
12920   PyObject *__pyx_v_state = 0;
12921   PyObject *__pyx_v__dict = 0;
12922   int __pyx_v_use_setstate;
12923   PyObject *__pyx_r = NULL;
12924   __Pyx_RefNannyDeclarations
12925   PyObject *__pyx_t_1 = NULL;
12926   int __pyx_t_2;
12927   int __pyx_t_3;
12928   PyObject *__pyx_t_4 = NULL;
12929   PyObject *__pyx_t_5 = NULL;
12930   int __pyx_lineno = 0;
12931   const char *__pyx_filename = NULL;
12932   int __pyx_clineno = 0;
12933   __Pyx_RefNannySetupContext("__reduce_cython__", 0);
12934 
12935   /* "(tree fragment)":5
12936  *     cdef object _dict
12937  *     cdef bint use_setstate
12938  *     state = (self.name,)             # <<<<<<<<<<<<<<
12939  *     _dict = getattr(self, '__dict__', None)
12940  *     if _dict is not None:
12941  */
12942   __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(3, 5, __pyx_L1_error)
12943   __Pyx_GOTREF(__pyx_t_1);
12944   __Pyx_INCREF(__pyx_v_self->name);
12945   __Pyx_GIVEREF(__pyx_v_self->name);
12946   PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_self->name);
12947   __pyx_v_state = ((PyObject*)__pyx_t_1);
12948   __pyx_t_1 = 0;
12949 
12950   /* "(tree fragment)":6
12951  *     cdef bint use_setstate
12952  *     state = (self.name,)
12953  *     _dict = getattr(self, '__dict__', None)             # <<<<<<<<<<<<<<
12954  *     if _dict is not None:
12955  *         state += (_dict,)
12956  */
12957   __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)
12958   __Pyx_GOTREF(__pyx_t_1);
12959   __pyx_v__dict = __pyx_t_1;
12960   __pyx_t_1 = 0;
12961 
12962   /* "(tree fragment)":7
12963  *     state = (self.name,)
12964  *     _dict = getattr(self, '__dict__', None)
12965  *     if _dict is not None:             # <<<<<<<<<<<<<<
12966  *         state += (_dict,)
12967  *         use_setstate = True
12968  */
12969   __pyx_t_2 = (__pyx_v__dict != Py_None);
12970   __pyx_t_3 = (__pyx_t_2 != 0);
12971   if (__pyx_t_3) {
12972 
12973     /* "(tree fragment)":8
12974  *     _dict = getattr(self, '__dict__', None)
12975  *     if _dict is not None:
12976  *         state += (_dict,)             # <<<<<<<<<<<<<<
12977  *         use_setstate = True
12978  *     else:
12979  */
12980     __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(3, 8, __pyx_L1_error)
12981     __Pyx_GOTREF(__pyx_t_1);
12982     __Pyx_INCREF(__pyx_v__dict);
12983     __Pyx_GIVEREF(__pyx_v__dict);
12984     PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v__dict);
12985     __pyx_t_4 = PyNumber_InPlaceAdd(__pyx_v_state, __pyx_t_1); if (unlikely(!__pyx_t_4)) __PYX_ERR(3, 8, __pyx_L1_error)
12986     __Pyx_GOTREF(__pyx_t_4);
12987     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
12988     __Pyx_DECREF_SET(__pyx_v_state, ((PyObject*)__pyx_t_4));
12989     __pyx_t_4 = 0;
12990 
12991     /* "(tree fragment)":9
12992  *     if _dict is not None:
12993  *         state += (_dict,)
12994  *         use_setstate = True             # <<<<<<<<<<<<<<
12995  *     else:
12996  *         use_setstate = self.name is not None
12997  */
12998     __pyx_v_use_setstate = 1;
12999 
13000     /* "(tree fragment)":7
13001  *     state = (self.name,)
13002  *     _dict = getattr(self, '__dict__', None)
13003  *     if _dict is not None:             # <<<<<<<<<<<<<<
13004  *         state += (_dict,)
13005  *         use_setstate = True
13006  */
13007     goto __pyx_L3;
13008   }
13009 
13010   /* "(tree fragment)":11
13011  *         use_setstate = True
13012  *     else:
13013  *         use_setstate = self.name is not None             # <<<<<<<<<<<<<<
13014  *     if use_setstate:
13015  *         return __pyx_unpickle_Enum, (type(self), 0xb068931, None), state
13016  */
13017   /*else*/ {
13018     __pyx_t_3 = (__pyx_v_self->name != Py_None);
13019     __pyx_v_use_setstate = __pyx_t_3;
13020   }
13021   __pyx_L3:;
13022 
13023   /* "(tree fragment)":12
13024  *     else:
13025  *         use_setstate = self.name is not None
13026  *     if use_setstate:             # <<<<<<<<<<<<<<
13027  *         return __pyx_unpickle_Enum, (type(self), 0xb068931, None), state
13028  *     else:
13029  */
13030   __pyx_t_3 = (__pyx_v_use_setstate != 0);
13031   if (__pyx_t_3) {
13032 
13033     /* "(tree fragment)":13
13034  *         use_setstate = self.name is not None
13035  *     if use_setstate:
13036  *         return __pyx_unpickle_Enum, (type(self), 0xb068931, None), state             # <<<<<<<<<<<<<<
13037  *     else:
13038  *         return __pyx_unpickle_Enum, (type(self), 0xb068931, state)
13039  */
13040     __Pyx_XDECREF(__pyx_r);
13041     __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_pyx_unpickle_Enum); if (unlikely(!__pyx_t_4)) __PYX_ERR(3, 13, __pyx_L1_error)
13042     __Pyx_GOTREF(__pyx_t_4);
13043     __pyx_t_1 = PyTuple_New(3); if (unlikely(!__pyx_t_1)) __PYX_ERR(3, 13, __pyx_L1_error)
13044     __Pyx_GOTREF(__pyx_t_1);
13045     __Pyx_INCREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
13046     __Pyx_GIVEREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
13047     PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
13048     __Pyx_INCREF(__pyx_int_184977713);
13049     __Pyx_GIVEREF(__pyx_int_184977713);
13050     PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_int_184977713);
13051     __Pyx_INCREF(Py_None);
13052     __Pyx_GIVEREF(Py_None);
13053     PyTuple_SET_ITEM(__pyx_t_1, 2, Py_None);
13054     __pyx_t_5 = PyTuple_New(3); if (unlikely(!__pyx_t_5)) __PYX_ERR(3, 13, __pyx_L1_error)
13055     __Pyx_GOTREF(__pyx_t_5);
13056     __Pyx_GIVEREF(__pyx_t_4);
13057     PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_4);
13058     __Pyx_GIVEREF(__pyx_t_1);
13059     PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_t_1);
13060     __Pyx_INCREF(__pyx_v_state);
13061     __Pyx_GIVEREF(__pyx_v_state);
13062     PyTuple_SET_ITEM(__pyx_t_5, 2, __pyx_v_state);
13063     __pyx_t_4 = 0;
13064     __pyx_t_1 = 0;
13065     __pyx_r = __pyx_t_5;
13066     __pyx_t_5 = 0;
13067     goto __pyx_L0;
13068 
13069     /* "(tree fragment)":12
13070  *     else:
13071  *         use_setstate = self.name is not None
13072  *     if use_setstate:             # <<<<<<<<<<<<<<
13073  *         return __pyx_unpickle_Enum, (type(self), 0xb068931, None), state
13074  *     else:
13075  */
13076   }
13077 
13078   /* "(tree fragment)":15
13079  *         return __pyx_unpickle_Enum, (type(self), 0xb068931, None), state
13080  *     else:
13081  *         return __pyx_unpickle_Enum, (type(self), 0xb068931, state)             # <<<<<<<<<<<<<<
13082  * def __setstate_cython__(self, __pyx_state):
13083  *     __pyx_unpickle_Enum__set_state(self, __pyx_state)
13084  */
13085   /*else*/ {
13086     __Pyx_XDECREF(__pyx_r);
13087     __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_n_s_pyx_unpickle_Enum); if (unlikely(!__pyx_t_5)) __PYX_ERR(3, 15, __pyx_L1_error)
13088     __Pyx_GOTREF(__pyx_t_5);
13089     __pyx_t_1 = PyTuple_New(3); if (unlikely(!__pyx_t_1)) __PYX_ERR(3, 15, __pyx_L1_error)
13090     __Pyx_GOTREF(__pyx_t_1);
13091     __Pyx_INCREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
13092     __Pyx_GIVEREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
13093     PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
13094     __Pyx_INCREF(__pyx_int_184977713);
13095     __Pyx_GIVEREF(__pyx_int_184977713);
13096     PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_int_184977713);
13097     __Pyx_INCREF(__pyx_v_state);
13098     __Pyx_GIVEREF(__pyx_v_state);
13099     PyTuple_SET_ITEM(__pyx_t_1, 2, __pyx_v_state);
13100     __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) __PYX_ERR(3, 15, __pyx_L1_error)
13101     __Pyx_GOTREF(__pyx_t_4);
13102     __Pyx_GIVEREF(__pyx_t_5);
13103     PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_5);
13104     __Pyx_GIVEREF(__pyx_t_1);
13105     PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_1);
13106     __pyx_t_5 = 0;
13107     __pyx_t_1 = 0;
13108     __pyx_r = __pyx_t_4;
13109     __pyx_t_4 = 0;
13110     goto __pyx_L0;
13111   }
13112 
13113   /* "(tree fragment)":1
13114  * def __reduce_cython__(self):             # <<<<<<<<<<<<<<
13115  *     cdef tuple state
13116  *     cdef object _dict
13117  */
13118 
13119   /* function exit code */
13120   __pyx_L1_error:;
13121   __Pyx_XDECREF(__pyx_t_1);
13122   __Pyx_XDECREF(__pyx_t_4);
13123   __Pyx_XDECREF(__pyx_t_5);
13124   __Pyx_AddTraceback("View.MemoryView.Enum.__reduce_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename);
13125   __pyx_r = NULL;
13126   __pyx_L0:;
13127   __Pyx_XDECREF(__pyx_v_state);
13128   __Pyx_XDECREF(__pyx_v__dict);
13129   __Pyx_XGIVEREF(__pyx_r);
13130   __Pyx_RefNannyFinishContext();
13131   return __pyx_r;
13132 }
13133 
13134 /* "(tree fragment)":16
13135  *     else:
13136  *         return __pyx_unpickle_Enum, (type(self), 0xb068931, state)
13137  * def __setstate_cython__(self, __pyx_state):             # <<<<<<<<<<<<<<
13138  *     __pyx_unpickle_Enum__set_state(self, __pyx_state)
13139  */
13140 
13141 /* Python wrapper */
13142 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)13143 static PyObject *__pyx_pw___pyx_MemviewEnum_3__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state) {
13144   PyObject *__pyx_r = 0;
13145   __Pyx_RefNannyDeclarations
13146   __Pyx_RefNannySetupContext("__setstate_cython__ (wrapper)", 0);
13147   __pyx_r = __pyx_pf___pyx_MemviewEnum_2__setstate_cython__(((struct __pyx_MemviewEnum_obj *)__pyx_v_self), ((PyObject *)__pyx_v___pyx_state));
13148 
13149   /* function exit code */
13150   __Pyx_RefNannyFinishContext();
13151   return __pyx_r;
13152 }
13153 
__pyx_pf___pyx_MemviewEnum_2__setstate_cython__(struct __pyx_MemviewEnum_obj * __pyx_v_self,PyObject * __pyx_v___pyx_state)13154 static PyObject *__pyx_pf___pyx_MemviewEnum_2__setstate_cython__(struct __pyx_MemviewEnum_obj *__pyx_v_self, PyObject *__pyx_v___pyx_state) {
13155   PyObject *__pyx_r = NULL;
13156   __Pyx_RefNannyDeclarations
13157   PyObject *__pyx_t_1 = NULL;
13158   int __pyx_lineno = 0;
13159   const char *__pyx_filename = NULL;
13160   int __pyx_clineno = 0;
13161   __Pyx_RefNannySetupContext("__setstate_cython__", 0);
13162 
13163   /* "(tree fragment)":17
13164  *         return __pyx_unpickle_Enum, (type(self), 0xb068931, state)
13165  * def __setstate_cython__(self, __pyx_state):
13166  *     __pyx_unpickle_Enum__set_state(self, __pyx_state)             # <<<<<<<<<<<<<<
13167  */
13168   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)
13169   __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)
13170   __Pyx_GOTREF(__pyx_t_1);
13171   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
13172 
13173   /* "(tree fragment)":16
13174  *     else:
13175  *         return __pyx_unpickle_Enum, (type(self), 0xb068931, state)
13176  * def __setstate_cython__(self, __pyx_state):             # <<<<<<<<<<<<<<
13177  *     __pyx_unpickle_Enum__set_state(self, __pyx_state)
13178  */
13179 
13180   /* function exit code */
13181   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
13182   goto __pyx_L0;
13183   __pyx_L1_error:;
13184   __Pyx_XDECREF(__pyx_t_1);
13185   __Pyx_AddTraceback("View.MemoryView.Enum.__setstate_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename);
13186   __pyx_r = NULL;
13187   __pyx_L0:;
13188   __Pyx_XGIVEREF(__pyx_r);
13189   __Pyx_RefNannyFinishContext();
13190   return __pyx_r;
13191 }
13192 
13193 /* "View.MemoryView":298
13194  *
13195  * @cname('__pyx_align_pointer')
13196  * cdef void *align_pointer(void *memory, size_t alignment) nogil:             # <<<<<<<<<<<<<<
13197  *     "Align pointer memory on a given boundary"
13198  *     cdef Py_intptr_t aligned_p = <Py_intptr_t> memory
13199  */
13200 
__pyx_align_pointer(void * __pyx_v_memory,size_t __pyx_v_alignment)13201 static void *__pyx_align_pointer(void *__pyx_v_memory, size_t __pyx_v_alignment) {
13202   Py_intptr_t __pyx_v_aligned_p;
13203   size_t __pyx_v_offset;
13204   void *__pyx_r;
13205   int __pyx_t_1;
13206 
13207   /* "View.MemoryView":300
13208  * cdef void *align_pointer(void *memory, size_t alignment) nogil:
13209  *     "Align pointer memory on a given boundary"
13210  *     cdef Py_intptr_t aligned_p = <Py_intptr_t> memory             # <<<<<<<<<<<<<<
13211  *     cdef size_t offset
13212  *
13213  */
13214   __pyx_v_aligned_p = ((Py_intptr_t)__pyx_v_memory);
13215 
13216   /* "View.MemoryView":304
13217  *
13218  *     with cython.cdivision(True):
13219  *         offset = aligned_p % alignment             # <<<<<<<<<<<<<<
13220  *
13221  *     if offset > 0:
13222  */
13223   __pyx_v_offset = (__pyx_v_aligned_p % __pyx_v_alignment);
13224 
13225   /* "View.MemoryView":306
13226  *         offset = aligned_p % alignment
13227  *
13228  *     if offset > 0:             # <<<<<<<<<<<<<<
13229  *         aligned_p += alignment - offset
13230  *
13231  */
13232   __pyx_t_1 = ((__pyx_v_offset > 0) != 0);
13233   if (__pyx_t_1) {
13234 
13235     /* "View.MemoryView":307
13236  *
13237  *     if offset > 0:
13238  *         aligned_p += alignment - offset             # <<<<<<<<<<<<<<
13239  *
13240  *     return <void *> aligned_p
13241  */
13242     __pyx_v_aligned_p = (__pyx_v_aligned_p + (__pyx_v_alignment - __pyx_v_offset));
13243 
13244     /* "View.MemoryView":306
13245  *         offset = aligned_p % alignment
13246  *
13247  *     if offset > 0:             # <<<<<<<<<<<<<<
13248  *         aligned_p += alignment - offset
13249  *
13250  */
13251   }
13252 
13253   /* "View.MemoryView":309
13254  *         aligned_p += alignment - offset
13255  *
13256  *     return <void *> aligned_p             # <<<<<<<<<<<<<<
13257  *
13258  *
13259  */
13260   __pyx_r = ((void *)__pyx_v_aligned_p);
13261   goto __pyx_L0;
13262 
13263   /* "View.MemoryView":298
13264  *
13265  * @cname('__pyx_align_pointer')
13266  * cdef void *align_pointer(void *memory, size_t alignment) nogil:             # <<<<<<<<<<<<<<
13267  *     "Align pointer memory on a given boundary"
13268  *     cdef Py_intptr_t aligned_p = <Py_intptr_t> memory
13269  */
13270 
13271   /* function exit code */
13272   __pyx_L0:;
13273   return __pyx_r;
13274 }
13275 
13276 /* "View.MemoryView":345
13277  *     cdef __Pyx_TypeInfo *typeinfo
13278  *
13279  *     def __cinit__(memoryview self, object obj, int flags, bint dtype_is_object=False):             # <<<<<<<<<<<<<<
13280  *         self.obj = obj
13281  *         self.flags = flags
13282  */
13283 
13284 /* Python wrapper */
13285 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)13286 static int __pyx_memoryview___cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
13287   PyObject *__pyx_v_obj = 0;
13288   int __pyx_v_flags;
13289   int __pyx_v_dtype_is_object;
13290   int __pyx_lineno = 0;
13291   const char *__pyx_filename = NULL;
13292   int __pyx_clineno = 0;
13293   int __pyx_r;
13294   __Pyx_RefNannyDeclarations
13295   __Pyx_RefNannySetupContext("__cinit__ (wrapper)", 0);
13296   {
13297     static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_obj,&__pyx_n_s_flags,&__pyx_n_s_dtype_is_object,0};
13298     PyObject* values[3] = {0,0,0};
13299     if (unlikely(__pyx_kwds)) {
13300       Py_ssize_t kw_args;
13301       const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
13302       switch (pos_args) {
13303         case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
13304         CYTHON_FALLTHROUGH;
13305         case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
13306         CYTHON_FALLTHROUGH;
13307         case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
13308         CYTHON_FALLTHROUGH;
13309         case  0: break;
13310         default: goto __pyx_L5_argtuple_error;
13311       }
13312       kw_args = PyDict_Size(__pyx_kwds);
13313       switch (pos_args) {
13314         case  0:
13315         if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_obj)) != 0)) kw_args--;
13316         else goto __pyx_L5_argtuple_error;
13317         CYTHON_FALLTHROUGH;
13318         case  1:
13319         if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_flags)) != 0)) kw_args--;
13320         else {
13321           __Pyx_RaiseArgtupleInvalid("__cinit__", 0, 2, 3, 1); __PYX_ERR(3, 345, __pyx_L3_error)
13322         }
13323         CYTHON_FALLTHROUGH;
13324         case  2:
13325         if (kw_args > 0) {
13326           PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_dtype_is_object);
13327           if (value) { values[2] = value; kw_args--; }
13328         }
13329       }
13330       if (unlikely(kw_args > 0)) {
13331         if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__cinit__") < 0)) __PYX_ERR(3, 345, __pyx_L3_error)
13332       }
13333     } else {
13334       switch (PyTuple_GET_SIZE(__pyx_args)) {
13335         case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
13336         CYTHON_FALLTHROUGH;
13337         case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
13338         values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
13339         break;
13340         default: goto __pyx_L5_argtuple_error;
13341       }
13342     }
13343     __pyx_v_obj = values[0];
13344     __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)
13345     if (values[2]) {
13346       __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)
13347     } else {
13348       __pyx_v_dtype_is_object = ((int)0);
13349     }
13350   }
13351   goto __pyx_L4_argument_unpacking_done;
13352   __pyx_L5_argtuple_error:;
13353   __Pyx_RaiseArgtupleInvalid("__cinit__", 0, 2, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(3, 345, __pyx_L3_error)
13354   __pyx_L3_error:;
13355   __Pyx_AddTraceback("View.MemoryView.memoryview.__cinit__", __pyx_clineno, __pyx_lineno, __pyx_filename);
13356   __Pyx_RefNannyFinishContext();
13357   return -1;
13358   __pyx_L4_argument_unpacking_done:;
13359   __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);
13360 
13361   /* function exit code */
13362   __Pyx_RefNannyFinishContext();
13363   return __pyx_r;
13364 }
13365 
__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)13366 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) {
13367   int __pyx_r;
13368   __Pyx_RefNannyDeclarations
13369   int __pyx_t_1;
13370   int __pyx_t_2;
13371   int __pyx_t_3;
13372   int __pyx_t_4;
13373   int __pyx_lineno = 0;
13374   const char *__pyx_filename = NULL;
13375   int __pyx_clineno = 0;
13376   __Pyx_RefNannySetupContext("__cinit__", 0);
13377 
13378   /* "View.MemoryView":346
13379  *
13380  *     def __cinit__(memoryview self, object obj, int flags, bint dtype_is_object=False):
13381  *         self.obj = obj             # <<<<<<<<<<<<<<
13382  *         self.flags = flags
13383  *         if type(self) is memoryview or obj is not None:
13384  */
13385   __Pyx_INCREF(__pyx_v_obj);
13386   __Pyx_GIVEREF(__pyx_v_obj);
13387   __Pyx_GOTREF(__pyx_v_self->obj);
13388   __Pyx_DECREF(__pyx_v_self->obj);
13389   __pyx_v_self->obj = __pyx_v_obj;
13390 
13391   /* "View.MemoryView":347
13392  *     def __cinit__(memoryview self, object obj, int flags, bint dtype_is_object=False):
13393  *         self.obj = obj
13394  *         self.flags = flags             # <<<<<<<<<<<<<<
13395  *         if type(self) is memoryview or obj is not None:
13396  *             __Pyx_GetBuffer(obj, &self.view, flags)
13397  */
13398   __pyx_v_self->flags = __pyx_v_flags;
13399 
13400   /* "View.MemoryView":348
13401  *         self.obj = obj
13402  *         self.flags = flags
13403  *         if type(self) is memoryview or obj is not None:             # <<<<<<<<<<<<<<
13404  *             __Pyx_GetBuffer(obj, &self.view, flags)
13405  *             if <PyObject *> self.view.obj == NULL:
13406  */
13407   __pyx_t_2 = (((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))) == ((PyObject *)__pyx_memoryview_type));
13408   __pyx_t_3 = (__pyx_t_2 != 0);
13409   if (!__pyx_t_3) {
13410   } else {
13411     __pyx_t_1 = __pyx_t_3;
13412     goto __pyx_L4_bool_binop_done;
13413   }
13414   __pyx_t_3 = (__pyx_v_obj != Py_None);
13415   __pyx_t_2 = (__pyx_t_3 != 0);
13416   __pyx_t_1 = __pyx_t_2;
13417   __pyx_L4_bool_binop_done:;
13418   if (__pyx_t_1) {
13419 
13420     /* "View.MemoryView":349
13421  *         self.flags = flags
13422  *         if type(self) is memoryview or obj is not None:
13423  *             __Pyx_GetBuffer(obj, &self.view, flags)             # <<<<<<<<<<<<<<
13424  *             if <PyObject *> self.view.obj == NULL:
13425  *                 (<__pyx_buffer *> &self.view).obj = Py_None
13426  */
13427     __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)
13428 
13429     /* "View.MemoryView":350
13430  *         if type(self) is memoryview or obj is not None:
13431  *             __Pyx_GetBuffer(obj, &self.view, flags)
13432  *             if <PyObject *> self.view.obj == NULL:             # <<<<<<<<<<<<<<
13433  *                 (<__pyx_buffer *> &self.view).obj = Py_None
13434  *                 Py_INCREF(Py_None)
13435  */
13436     __pyx_t_1 = ((((PyObject *)__pyx_v_self->view.obj) == NULL) != 0);
13437     if (__pyx_t_1) {
13438 
13439       /* "View.MemoryView":351
13440  *             __Pyx_GetBuffer(obj, &self.view, flags)
13441  *             if <PyObject *> self.view.obj == NULL:
13442  *                 (<__pyx_buffer *> &self.view).obj = Py_None             # <<<<<<<<<<<<<<
13443  *                 Py_INCREF(Py_None)
13444  *
13445  */
13446       ((Py_buffer *)(&__pyx_v_self->view))->obj = Py_None;
13447 
13448       /* "View.MemoryView":352
13449  *             if <PyObject *> self.view.obj == NULL:
13450  *                 (<__pyx_buffer *> &self.view).obj = Py_None
13451  *                 Py_INCREF(Py_None)             # <<<<<<<<<<<<<<
13452  *
13453  *         global __pyx_memoryview_thread_locks_used
13454  */
13455       Py_INCREF(Py_None);
13456 
13457       /* "View.MemoryView":350
13458  *         if type(self) is memoryview or obj is not None:
13459  *             __Pyx_GetBuffer(obj, &self.view, flags)
13460  *             if <PyObject *> self.view.obj == NULL:             # <<<<<<<<<<<<<<
13461  *                 (<__pyx_buffer *> &self.view).obj = Py_None
13462  *                 Py_INCREF(Py_None)
13463  */
13464     }
13465 
13466     /* "View.MemoryView":348
13467  *         self.obj = obj
13468  *         self.flags = flags
13469  *         if type(self) is memoryview or obj is not None:             # <<<<<<<<<<<<<<
13470  *             __Pyx_GetBuffer(obj, &self.view, flags)
13471  *             if <PyObject *> self.view.obj == NULL:
13472  */
13473   }
13474 
13475   /* "View.MemoryView":355
13476  *
13477  *         global __pyx_memoryview_thread_locks_used
13478  *         if __pyx_memoryview_thread_locks_used < THREAD_LOCKS_PREALLOCATED:             # <<<<<<<<<<<<<<
13479  *             self.lock = __pyx_memoryview_thread_locks[__pyx_memoryview_thread_locks_used]
13480  *             __pyx_memoryview_thread_locks_used += 1
13481  */
13482   __pyx_t_1 = ((__pyx_memoryview_thread_locks_used < 8) != 0);
13483   if (__pyx_t_1) {
13484 
13485     /* "View.MemoryView":356
13486  *         global __pyx_memoryview_thread_locks_used
13487  *         if __pyx_memoryview_thread_locks_used < THREAD_LOCKS_PREALLOCATED:
13488  *             self.lock = __pyx_memoryview_thread_locks[__pyx_memoryview_thread_locks_used]             # <<<<<<<<<<<<<<
13489  *             __pyx_memoryview_thread_locks_used += 1
13490  *         if self.lock is NULL:
13491  */
13492     __pyx_v_self->lock = (__pyx_memoryview_thread_locks[__pyx_memoryview_thread_locks_used]);
13493 
13494     /* "View.MemoryView":357
13495  *         if __pyx_memoryview_thread_locks_used < THREAD_LOCKS_PREALLOCATED:
13496  *             self.lock = __pyx_memoryview_thread_locks[__pyx_memoryview_thread_locks_used]
13497  *             __pyx_memoryview_thread_locks_used += 1             # <<<<<<<<<<<<<<
13498  *         if self.lock is NULL:
13499  *             self.lock = PyThread_allocate_lock()
13500  */
13501     __pyx_memoryview_thread_locks_used = (__pyx_memoryview_thread_locks_used + 1);
13502 
13503     /* "View.MemoryView":355
13504  *
13505  *         global __pyx_memoryview_thread_locks_used
13506  *         if __pyx_memoryview_thread_locks_used < THREAD_LOCKS_PREALLOCATED:             # <<<<<<<<<<<<<<
13507  *             self.lock = __pyx_memoryview_thread_locks[__pyx_memoryview_thread_locks_used]
13508  *             __pyx_memoryview_thread_locks_used += 1
13509  */
13510   }
13511 
13512   /* "View.MemoryView":358
13513  *             self.lock = __pyx_memoryview_thread_locks[__pyx_memoryview_thread_locks_used]
13514  *             __pyx_memoryview_thread_locks_used += 1
13515  *         if self.lock is NULL:             # <<<<<<<<<<<<<<
13516  *             self.lock = PyThread_allocate_lock()
13517  *             if self.lock is NULL:
13518  */
13519   __pyx_t_1 = ((__pyx_v_self->lock == NULL) != 0);
13520   if (__pyx_t_1) {
13521 
13522     /* "View.MemoryView":359
13523  *             __pyx_memoryview_thread_locks_used += 1
13524  *         if self.lock is NULL:
13525  *             self.lock = PyThread_allocate_lock()             # <<<<<<<<<<<<<<
13526  *             if self.lock is NULL:
13527  *                 raise MemoryError
13528  */
13529     __pyx_v_self->lock = PyThread_allocate_lock();
13530 
13531     /* "View.MemoryView":360
13532  *         if self.lock is NULL:
13533  *             self.lock = PyThread_allocate_lock()
13534  *             if self.lock is NULL:             # <<<<<<<<<<<<<<
13535  *                 raise MemoryError
13536  *
13537  */
13538     __pyx_t_1 = ((__pyx_v_self->lock == NULL) != 0);
13539     if (unlikely(__pyx_t_1)) {
13540 
13541       /* "View.MemoryView":361
13542  *             self.lock = PyThread_allocate_lock()
13543  *             if self.lock is NULL:
13544  *                 raise MemoryError             # <<<<<<<<<<<<<<
13545  *
13546  *         if flags & PyBUF_FORMAT:
13547  */
13548       PyErr_NoMemory(); __PYX_ERR(3, 361, __pyx_L1_error)
13549 
13550       /* "View.MemoryView":360
13551  *         if self.lock is NULL:
13552  *             self.lock = PyThread_allocate_lock()
13553  *             if self.lock is NULL:             # <<<<<<<<<<<<<<
13554  *                 raise MemoryError
13555  *
13556  */
13557     }
13558 
13559     /* "View.MemoryView":358
13560  *             self.lock = __pyx_memoryview_thread_locks[__pyx_memoryview_thread_locks_used]
13561  *             __pyx_memoryview_thread_locks_used += 1
13562  *         if self.lock is NULL:             # <<<<<<<<<<<<<<
13563  *             self.lock = PyThread_allocate_lock()
13564  *             if self.lock is NULL:
13565  */
13566   }
13567 
13568   /* "View.MemoryView":363
13569  *                 raise MemoryError
13570  *
13571  *         if flags & PyBUF_FORMAT:             # <<<<<<<<<<<<<<
13572  *             self.dtype_is_object = (self.view.format[0] == b'O' and self.view.format[1] == b'\0')
13573  *         else:
13574  */
13575   __pyx_t_1 = ((__pyx_v_flags & PyBUF_FORMAT) != 0);
13576   if (__pyx_t_1) {
13577 
13578     /* "View.MemoryView":364
13579  *
13580  *         if flags & PyBUF_FORMAT:
13581  *             self.dtype_is_object = (self.view.format[0] == b'O' and self.view.format[1] == b'\0')             # <<<<<<<<<<<<<<
13582  *         else:
13583  *             self.dtype_is_object = dtype_is_object
13584  */
13585     __pyx_t_2 = (((__pyx_v_self->view.format[0]) == 'O') != 0);
13586     if (__pyx_t_2) {
13587     } else {
13588       __pyx_t_1 = __pyx_t_2;
13589       goto __pyx_L11_bool_binop_done;
13590     }
13591     __pyx_t_2 = (((__pyx_v_self->view.format[1]) == '\x00') != 0);
13592     __pyx_t_1 = __pyx_t_2;
13593     __pyx_L11_bool_binop_done:;
13594     __pyx_v_self->dtype_is_object = __pyx_t_1;
13595 
13596     /* "View.MemoryView":363
13597  *                 raise MemoryError
13598  *
13599  *         if flags & PyBUF_FORMAT:             # <<<<<<<<<<<<<<
13600  *             self.dtype_is_object = (self.view.format[0] == b'O' and self.view.format[1] == b'\0')
13601  *         else:
13602  */
13603     goto __pyx_L10;
13604   }
13605 
13606   /* "View.MemoryView":366
13607  *             self.dtype_is_object = (self.view.format[0] == b'O' and self.view.format[1] == b'\0')
13608  *         else:
13609  *             self.dtype_is_object = dtype_is_object             # <<<<<<<<<<<<<<
13610  *
13611  *         self.acquisition_count_aligned_p = <__pyx_atomic_int *> align_pointer(
13612  */
13613   /*else*/ {
13614     __pyx_v_self->dtype_is_object = __pyx_v_dtype_is_object;
13615   }
13616   __pyx_L10:;
13617 
13618   /* "View.MemoryView":368
13619  *             self.dtype_is_object = dtype_is_object
13620  *
13621  *         self.acquisition_count_aligned_p = <__pyx_atomic_int *> align_pointer(             # <<<<<<<<<<<<<<
13622  *                   <void *> &self.acquisition_count[0], sizeof(__pyx_atomic_int))
13623  *         self.typeinfo = NULL
13624  */
13625   __pyx_v_self->acquisition_count_aligned_p = ((__pyx_atomic_int *)__pyx_align_pointer(((void *)(&(__pyx_v_self->acquisition_count[0]))), (sizeof(__pyx_atomic_int))));
13626 
13627   /* "View.MemoryView":370
13628  *         self.acquisition_count_aligned_p = <__pyx_atomic_int *> align_pointer(
13629  *                   <void *> &self.acquisition_count[0], sizeof(__pyx_atomic_int))
13630  *         self.typeinfo = NULL             # <<<<<<<<<<<<<<
13631  *
13632  *     def __dealloc__(memoryview self):
13633  */
13634   __pyx_v_self->typeinfo = NULL;
13635 
13636   /* "View.MemoryView":345
13637  *     cdef __Pyx_TypeInfo *typeinfo
13638  *
13639  *     def __cinit__(memoryview self, object obj, int flags, bint dtype_is_object=False):             # <<<<<<<<<<<<<<
13640  *         self.obj = obj
13641  *         self.flags = flags
13642  */
13643 
13644   /* function exit code */
13645   __pyx_r = 0;
13646   goto __pyx_L0;
13647   __pyx_L1_error:;
13648   __Pyx_AddTraceback("View.MemoryView.memoryview.__cinit__", __pyx_clineno, __pyx_lineno, __pyx_filename);
13649   __pyx_r = -1;
13650   __pyx_L0:;
13651   __Pyx_RefNannyFinishContext();
13652   return __pyx_r;
13653 }
13654 
13655 /* "View.MemoryView":372
13656  *         self.typeinfo = NULL
13657  *
13658  *     def __dealloc__(memoryview self):             # <<<<<<<<<<<<<<
13659  *         if self.obj is not None:
13660  *             __Pyx_ReleaseBuffer(&self.view)
13661  */
13662 
13663 /* Python wrapper */
13664 static void __pyx_memoryview___dealloc__(PyObject *__pyx_v_self); /*proto*/
__pyx_memoryview___dealloc__(PyObject * __pyx_v_self)13665 static void __pyx_memoryview___dealloc__(PyObject *__pyx_v_self) {
13666   __Pyx_RefNannyDeclarations
13667   __Pyx_RefNannySetupContext("__dealloc__ (wrapper)", 0);
13668   __pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_2__dealloc__(((struct __pyx_memoryview_obj *)__pyx_v_self));
13669 
13670   /* function exit code */
13671   __Pyx_RefNannyFinishContext();
13672 }
13673 
__pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_2__dealloc__(struct __pyx_memoryview_obj * __pyx_v_self)13674 static void __pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_2__dealloc__(struct __pyx_memoryview_obj *__pyx_v_self) {
13675   int __pyx_v_i;
13676   __Pyx_RefNannyDeclarations
13677   int __pyx_t_1;
13678   int __pyx_t_2;
13679   int __pyx_t_3;
13680   int __pyx_t_4;
13681   int __pyx_t_5;
13682   PyThread_type_lock __pyx_t_6;
13683   PyThread_type_lock __pyx_t_7;
13684   __Pyx_RefNannySetupContext("__dealloc__", 0);
13685 
13686   /* "View.MemoryView":373
13687  *
13688  *     def __dealloc__(memoryview self):
13689  *         if self.obj is not None:             # <<<<<<<<<<<<<<
13690  *             __Pyx_ReleaseBuffer(&self.view)
13691  *         elif (<__pyx_buffer *> &self.view).obj == Py_None:
13692  */
13693   __pyx_t_1 = (__pyx_v_self->obj != Py_None);
13694   __pyx_t_2 = (__pyx_t_1 != 0);
13695   if (__pyx_t_2) {
13696 
13697     /* "View.MemoryView":374
13698  *     def __dealloc__(memoryview self):
13699  *         if self.obj is not None:
13700  *             __Pyx_ReleaseBuffer(&self.view)             # <<<<<<<<<<<<<<
13701  *         elif (<__pyx_buffer *> &self.view).obj == Py_None:
13702  *
13703  */
13704     __Pyx_ReleaseBuffer((&__pyx_v_self->view));
13705 
13706     /* "View.MemoryView":373
13707  *
13708  *     def __dealloc__(memoryview self):
13709  *         if self.obj is not None:             # <<<<<<<<<<<<<<
13710  *             __Pyx_ReleaseBuffer(&self.view)
13711  *         elif (<__pyx_buffer *> &self.view).obj == Py_None:
13712  */
13713     goto __pyx_L3;
13714   }
13715 
13716   /* "View.MemoryView":375
13717  *         if self.obj is not None:
13718  *             __Pyx_ReleaseBuffer(&self.view)
13719  *         elif (<__pyx_buffer *> &self.view).obj == Py_None:             # <<<<<<<<<<<<<<
13720  *
13721  *             (<__pyx_buffer *> &self.view).obj = NULL
13722  */
13723   __pyx_t_2 = ((((Py_buffer *)(&__pyx_v_self->view))->obj == Py_None) != 0);
13724   if (__pyx_t_2) {
13725 
13726     /* "View.MemoryView":377
13727  *         elif (<__pyx_buffer *> &self.view).obj == Py_None:
13728  *
13729  *             (<__pyx_buffer *> &self.view).obj = NULL             # <<<<<<<<<<<<<<
13730  *             Py_DECREF(Py_None)
13731  *
13732  */
13733     ((Py_buffer *)(&__pyx_v_self->view))->obj = NULL;
13734 
13735     /* "View.MemoryView":378
13736  *
13737  *             (<__pyx_buffer *> &self.view).obj = NULL
13738  *             Py_DECREF(Py_None)             # <<<<<<<<<<<<<<
13739  *
13740  *         cdef int i
13741  */
13742     Py_DECREF(Py_None);
13743 
13744     /* "View.MemoryView":375
13745  *         if self.obj is not None:
13746  *             __Pyx_ReleaseBuffer(&self.view)
13747  *         elif (<__pyx_buffer *> &self.view).obj == Py_None:             # <<<<<<<<<<<<<<
13748  *
13749  *             (<__pyx_buffer *> &self.view).obj = NULL
13750  */
13751   }
13752   __pyx_L3:;
13753 
13754   /* "View.MemoryView":382
13755  *         cdef int i
13756  *         global __pyx_memoryview_thread_locks_used
13757  *         if self.lock != NULL:             # <<<<<<<<<<<<<<
13758  *             for i in range(__pyx_memoryview_thread_locks_used):
13759  *                 if __pyx_memoryview_thread_locks[i] is self.lock:
13760  */
13761   __pyx_t_2 = ((__pyx_v_self->lock != NULL) != 0);
13762   if (__pyx_t_2) {
13763 
13764     /* "View.MemoryView":383
13765  *         global __pyx_memoryview_thread_locks_used
13766  *         if self.lock != NULL:
13767  *             for i in range(__pyx_memoryview_thread_locks_used):             # <<<<<<<<<<<<<<
13768  *                 if __pyx_memoryview_thread_locks[i] is self.lock:
13769  *                     __pyx_memoryview_thread_locks_used -= 1
13770  */
13771     __pyx_t_3 = __pyx_memoryview_thread_locks_used;
13772     __pyx_t_4 = __pyx_t_3;
13773     for (__pyx_t_5 = 0; __pyx_t_5 < __pyx_t_4; __pyx_t_5+=1) {
13774       __pyx_v_i = __pyx_t_5;
13775 
13776       /* "View.MemoryView":384
13777  *         if self.lock != NULL:
13778  *             for i in range(__pyx_memoryview_thread_locks_used):
13779  *                 if __pyx_memoryview_thread_locks[i] is self.lock:             # <<<<<<<<<<<<<<
13780  *                     __pyx_memoryview_thread_locks_used -= 1
13781  *                     if i != __pyx_memoryview_thread_locks_used:
13782  */
13783       __pyx_t_2 = (((__pyx_memoryview_thread_locks[__pyx_v_i]) == __pyx_v_self->lock) != 0);
13784       if (__pyx_t_2) {
13785 
13786         /* "View.MemoryView":385
13787  *             for i in range(__pyx_memoryview_thread_locks_used):
13788  *                 if __pyx_memoryview_thread_locks[i] is self.lock:
13789  *                     __pyx_memoryview_thread_locks_used -= 1             # <<<<<<<<<<<<<<
13790  *                     if i != __pyx_memoryview_thread_locks_used:
13791  *                         __pyx_memoryview_thread_locks[i], __pyx_memoryview_thread_locks[__pyx_memoryview_thread_locks_used] = (
13792  */
13793         __pyx_memoryview_thread_locks_used = (__pyx_memoryview_thread_locks_used - 1);
13794 
13795         /* "View.MemoryView":386
13796  *                 if __pyx_memoryview_thread_locks[i] is self.lock:
13797  *                     __pyx_memoryview_thread_locks_used -= 1
13798  *                     if i != __pyx_memoryview_thread_locks_used:             # <<<<<<<<<<<<<<
13799  *                         __pyx_memoryview_thread_locks[i], __pyx_memoryview_thread_locks[__pyx_memoryview_thread_locks_used] = (
13800  *                             __pyx_memoryview_thread_locks[__pyx_memoryview_thread_locks_used], __pyx_memoryview_thread_locks[i])
13801  */
13802         __pyx_t_2 = ((__pyx_v_i != __pyx_memoryview_thread_locks_used) != 0);
13803         if (__pyx_t_2) {
13804 
13805           /* "View.MemoryView":388
13806  *                     if i != __pyx_memoryview_thread_locks_used:
13807  *                         __pyx_memoryview_thread_locks[i], __pyx_memoryview_thread_locks[__pyx_memoryview_thread_locks_used] = (
13808  *                             __pyx_memoryview_thread_locks[__pyx_memoryview_thread_locks_used], __pyx_memoryview_thread_locks[i])             # <<<<<<<<<<<<<<
13809  *                     break
13810  *             else:
13811  */
13812           __pyx_t_6 = (__pyx_memoryview_thread_locks[__pyx_memoryview_thread_locks_used]);
13813           __pyx_t_7 = (__pyx_memoryview_thread_locks[__pyx_v_i]);
13814 
13815           /* "View.MemoryView":387
13816  *                     __pyx_memoryview_thread_locks_used -= 1
13817  *                     if i != __pyx_memoryview_thread_locks_used:
13818  *                         __pyx_memoryview_thread_locks[i], __pyx_memoryview_thread_locks[__pyx_memoryview_thread_locks_used] = (             # <<<<<<<<<<<<<<
13819  *                             __pyx_memoryview_thread_locks[__pyx_memoryview_thread_locks_used], __pyx_memoryview_thread_locks[i])
13820  *                     break
13821  */
13822           (__pyx_memoryview_thread_locks[__pyx_v_i]) = __pyx_t_6;
13823           (__pyx_memoryview_thread_locks[__pyx_memoryview_thread_locks_used]) = __pyx_t_7;
13824 
13825           /* "View.MemoryView":386
13826  *                 if __pyx_memoryview_thread_locks[i] is self.lock:
13827  *                     __pyx_memoryview_thread_locks_used -= 1
13828  *                     if i != __pyx_memoryview_thread_locks_used:             # <<<<<<<<<<<<<<
13829  *                         __pyx_memoryview_thread_locks[i], __pyx_memoryview_thread_locks[__pyx_memoryview_thread_locks_used] = (
13830  *                             __pyx_memoryview_thread_locks[__pyx_memoryview_thread_locks_used], __pyx_memoryview_thread_locks[i])
13831  */
13832         }
13833 
13834         /* "View.MemoryView":389
13835  *                         __pyx_memoryview_thread_locks[i], __pyx_memoryview_thread_locks[__pyx_memoryview_thread_locks_used] = (
13836  *                             __pyx_memoryview_thread_locks[__pyx_memoryview_thread_locks_used], __pyx_memoryview_thread_locks[i])
13837  *                     break             # <<<<<<<<<<<<<<
13838  *             else:
13839  *                 PyThread_free_lock(self.lock)
13840  */
13841         goto __pyx_L6_break;
13842 
13843         /* "View.MemoryView":384
13844  *         if self.lock != NULL:
13845  *             for i in range(__pyx_memoryview_thread_locks_used):
13846  *                 if __pyx_memoryview_thread_locks[i] is self.lock:             # <<<<<<<<<<<<<<
13847  *                     __pyx_memoryview_thread_locks_used -= 1
13848  *                     if i != __pyx_memoryview_thread_locks_used:
13849  */
13850       }
13851     }
13852     /*else*/ {
13853 
13854       /* "View.MemoryView":391
13855  *                     break
13856  *             else:
13857  *                 PyThread_free_lock(self.lock)             # <<<<<<<<<<<<<<
13858  *
13859  *     cdef char *get_item_pointer(memoryview self, object index) except NULL:
13860  */
13861       PyThread_free_lock(__pyx_v_self->lock);
13862     }
13863     __pyx_L6_break:;
13864 
13865     /* "View.MemoryView":382
13866  *         cdef int i
13867  *         global __pyx_memoryview_thread_locks_used
13868  *         if self.lock != NULL:             # <<<<<<<<<<<<<<
13869  *             for i in range(__pyx_memoryview_thread_locks_used):
13870  *                 if __pyx_memoryview_thread_locks[i] is self.lock:
13871  */
13872   }
13873 
13874   /* "View.MemoryView":372
13875  *         self.typeinfo = NULL
13876  *
13877  *     def __dealloc__(memoryview self):             # <<<<<<<<<<<<<<
13878  *         if self.obj is not None:
13879  *             __Pyx_ReleaseBuffer(&self.view)
13880  */
13881 
13882   /* function exit code */
13883   __Pyx_RefNannyFinishContext();
13884 }
13885 
13886 /* "View.MemoryView":393
13887  *                 PyThread_free_lock(self.lock)
13888  *
13889  *     cdef char *get_item_pointer(memoryview self, object index) except NULL:             # <<<<<<<<<<<<<<
13890  *         cdef Py_ssize_t dim
13891  *         cdef char *itemp = <char *> self.view.buf
13892  */
13893 
__pyx_memoryview_get_item_pointer(struct __pyx_memoryview_obj * __pyx_v_self,PyObject * __pyx_v_index)13894 static char *__pyx_memoryview_get_item_pointer(struct __pyx_memoryview_obj *__pyx_v_self, PyObject *__pyx_v_index) {
13895   Py_ssize_t __pyx_v_dim;
13896   char *__pyx_v_itemp;
13897   PyObject *__pyx_v_idx = NULL;
13898   char *__pyx_r;
13899   __Pyx_RefNannyDeclarations
13900   Py_ssize_t __pyx_t_1;
13901   PyObject *__pyx_t_2 = NULL;
13902   Py_ssize_t __pyx_t_3;
13903   PyObject *(*__pyx_t_4)(PyObject *);
13904   PyObject *__pyx_t_5 = NULL;
13905   Py_ssize_t __pyx_t_6;
13906   char *__pyx_t_7;
13907   int __pyx_lineno = 0;
13908   const char *__pyx_filename = NULL;
13909   int __pyx_clineno = 0;
13910   __Pyx_RefNannySetupContext("get_item_pointer", 0);
13911 
13912   /* "View.MemoryView":395
13913  *     cdef char *get_item_pointer(memoryview self, object index) except NULL:
13914  *         cdef Py_ssize_t dim
13915  *         cdef char *itemp = <char *> self.view.buf             # <<<<<<<<<<<<<<
13916  *
13917  *         for dim, idx in enumerate(index):
13918  */
13919   __pyx_v_itemp = ((char *)__pyx_v_self->view.buf);
13920 
13921   /* "View.MemoryView":397
13922  *         cdef char *itemp = <char *> self.view.buf
13923  *
13924  *         for dim, idx in enumerate(index):             # <<<<<<<<<<<<<<
13925  *             itemp = pybuffer_index(&self.view, itemp, idx, dim)
13926  *
13927  */
13928   __pyx_t_1 = 0;
13929   if (likely(PyList_CheckExact(__pyx_v_index)) || PyTuple_CheckExact(__pyx_v_index)) {
13930     __pyx_t_2 = __pyx_v_index; __Pyx_INCREF(__pyx_t_2); __pyx_t_3 = 0;
13931     __pyx_t_4 = NULL;
13932   } else {
13933     __pyx_t_3 = -1; __pyx_t_2 = PyObject_GetIter(__pyx_v_index); if (unlikely(!__pyx_t_2)) __PYX_ERR(3, 397, __pyx_L1_error)
13934     __Pyx_GOTREF(__pyx_t_2);
13935     __pyx_t_4 = Py_TYPE(__pyx_t_2)->tp_iternext; if (unlikely(!__pyx_t_4)) __PYX_ERR(3, 397, __pyx_L1_error)
13936   }
13937   for (;;) {
13938     if (likely(!__pyx_t_4)) {
13939       if (likely(PyList_CheckExact(__pyx_t_2))) {
13940         if (__pyx_t_3 >= PyList_GET_SIZE(__pyx_t_2)) break;
13941         #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
13942         __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)
13943         #else
13944         __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)
13945         __Pyx_GOTREF(__pyx_t_5);
13946         #endif
13947       } else {
13948         if (__pyx_t_3 >= PyTuple_GET_SIZE(__pyx_t_2)) break;
13949         #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
13950         __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)
13951         #else
13952         __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)
13953         __Pyx_GOTREF(__pyx_t_5);
13954         #endif
13955       }
13956     } else {
13957       __pyx_t_5 = __pyx_t_4(__pyx_t_2);
13958       if (unlikely(!__pyx_t_5)) {
13959         PyObject* exc_type = PyErr_Occurred();
13960         if (exc_type) {
13961           if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
13962           else __PYX_ERR(3, 397, __pyx_L1_error)
13963         }
13964         break;
13965       }
13966       __Pyx_GOTREF(__pyx_t_5);
13967     }
13968     __Pyx_XDECREF_SET(__pyx_v_idx, __pyx_t_5);
13969     __pyx_t_5 = 0;
13970     __pyx_v_dim = __pyx_t_1;
13971     __pyx_t_1 = (__pyx_t_1 + 1);
13972 
13973     /* "View.MemoryView":398
13974  *
13975  *         for dim, idx in enumerate(index):
13976  *             itemp = pybuffer_index(&self.view, itemp, idx, dim)             # <<<<<<<<<<<<<<
13977  *
13978  *         return itemp
13979  */
13980     __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)
13981     __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)
13982     __pyx_v_itemp = __pyx_t_7;
13983 
13984     /* "View.MemoryView":397
13985  *         cdef char *itemp = <char *> self.view.buf
13986  *
13987  *         for dim, idx in enumerate(index):             # <<<<<<<<<<<<<<
13988  *             itemp = pybuffer_index(&self.view, itemp, idx, dim)
13989  *
13990  */
13991   }
13992   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
13993 
13994   /* "View.MemoryView":400
13995  *             itemp = pybuffer_index(&self.view, itemp, idx, dim)
13996  *
13997  *         return itemp             # <<<<<<<<<<<<<<
13998  *
13999  *
14000  */
14001   __pyx_r = __pyx_v_itemp;
14002   goto __pyx_L0;
14003 
14004   /* "View.MemoryView":393
14005  *                 PyThread_free_lock(self.lock)
14006  *
14007  *     cdef char *get_item_pointer(memoryview self, object index) except NULL:             # <<<<<<<<<<<<<<
14008  *         cdef Py_ssize_t dim
14009  *         cdef char *itemp = <char *> self.view.buf
14010  */
14011 
14012   /* function exit code */
14013   __pyx_L1_error:;
14014   __Pyx_XDECREF(__pyx_t_2);
14015   __Pyx_XDECREF(__pyx_t_5);
14016   __Pyx_AddTraceback("View.MemoryView.memoryview.get_item_pointer", __pyx_clineno, __pyx_lineno, __pyx_filename);
14017   __pyx_r = NULL;
14018   __pyx_L0:;
14019   __Pyx_XDECREF(__pyx_v_idx);
14020   __Pyx_RefNannyFinishContext();
14021   return __pyx_r;
14022 }
14023 
14024 /* "View.MemoryView":403
14025  *
14026  *
14027  *     def __getitem__(memoryview self, object index):             # <<<<<<<<<<<<<<
14028  *         if index is Ellipsis:
14029  *             return self
14030  */
14031 
14032 /* Python wrapper */
14033 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)14034 static PyObject *__pyx_memoryview___getitem__(PyObject *__pyx_v_self, PyObject *__pyx_v_index) {
14035   PyObject *__pyx_r = 0;
14036   __Pyx_RefNannyDeclarations
14037   __Pyx_RefNannySetupContext("__getitem__ (wrapper)", 0);
14038   __pyx_r = __pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_4__getitem__(((struct __pyx_memoryview_obj *)__pyx_v_self), ((PyObject *)__pyx_v_index));
14039 
14040   /* function exit code */
14041   __Pyx_RefNannyFinishContext();
14042   return __pyx_r;
14043 }
14044 
__pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_4__getitem__(struct __pyx_memoryview_obj * __pyx_v_self,PyObject * __pyx_v_index)14045 static PyObject *__pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_4__getitem__(struct __pyx_memoryview_obj *__pyx_v_self, PyObject *__pyx_v_index) {
14046   PyObject *__pyx_v_have_slices = NULL;
14047   PyObject *__pyx_v_indices = NULL;
14048   char *__pyx_v_itemp;
14049   PyObject *__pyx_r = NULL;
14050   __Pyx_RefNannyDeclarations
14051   int __pyx_t_1;
14052   int __pyx_t_2;
14053   PyObject *__pyx_t_3 = NULL;
14054   PyObject *__pyx_t_4 = NULL;
14055   PyObject *__pyx_t_5 = NULL;
14056   char *__pyx_t_6;
14057   int __pyx_lineno = 0;
14058   const char *__pyx_filename = NULL;
14059   int __pyx_clineno = 0;
14060   __Pyx_RefNannySetupContext("__getitem__", 0);
14061 
14062   /* "View.MemoryView":404
14063  *
14064  *     def __getitem__(memoryview self, object index):
14065  *         if index is Ellipsis:             # <<<<<<<<<<<<<<
14066  *             return self
14067  *
14068  */
14069   __pyx_t_1 = (__pyx_v_index == __pyx_builtin_Ellipsis);
14070   __pyx_t_2 = (__pyx_t_1 != 0);
14071   if (__pyx_t_2) {
14072 
14073     /* "View.MemoryView":405
14074  *     def __getitem__(memoryview self, object index):
14075  *         if index is Ellipsis:
14076  *             return self             # <<<<<<<<<<<<<<
14077  *
14078  *         have_slices, indices = _unellipsify(index, self.view.ndim)
14079  */
14080     __Pyx_XDECREF(__pyx_r);
14081     __Pyx_INCREF(((PyObject *)__pyx_v_self));
14082     __pyx_r = ((PyObject *)__pyx_v_self);
14083     goto __pyx_L0;
14084 
14085     /* "View.MemoryView":404
14086  *
14087  *     def __getitem__(memoryview self, object index):
14088  *         if index is Ellipsis:             # <<<<<<<<<<<<<<
14089  *             return self
14090  *
14091  */
14092   }
14093 
14094   /* "View.MemoryView":407
14095  *             return self
14096  *
14097  *         have_slices, indices = _unellipsify(index, self.view.ndim)             # <<<<<<<<<<<<<<
14098  *
14099  *         cdef char *itemp
14100  */
14101   __pyx_t_3 = _unellipsify(__pyx_v_index, __pyx_v_self->view.ndim); if (unlikely(!__pyx_t_3)) __PYX_ERR(3, 407, __pyx_L1_error)
14102   __Pyx_GOTREF(__pyx_t_3);
14103   if (likely(__pyx_t_3 != Py_None)) {
14104     PyObject* sequence = __pyx_t_3;
14105     Py_ssize_t size = __Pyx_PySequence_SIZE(sequence);
14106     if (unlikely(size != 2)) {
14107       if (size > 2) __Pyx_RaiseTooManyValuesError(2);
14108       else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
14109       __PYX_ERR(3, 407, __pyx_L1_error)
14110     }
14111     #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
14112     __pyx_t_4 = PyTuple_GET_ITEM(sequence, 0);
14113     __pyx_t_5 = PyTuple_GET_ITEM(sequence, 1);
14114     __Pyx_INCREF(__pyx_t_4);
14115     __Pyx_INCREF(__pyx_t_5);
14116     #else
14117     __pyx_t_4 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(3, 407, __pyx_L1_error)
14118     __Pyx_GOTREF(__pyx_t_4);
14119     __pyx_t_5 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_5)) __PYX_ERR(3, 407, __pyx_L1_error)
14120     __Pyx_GOTREF(__pyx_t_5);
14121     #endif
14122     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
14123   } else {
14124     __Pyx_RaiseNoneNotIterableError(); __PYX_ERR(3, 407, __pyx_L1_error)
14125   }
14126   __pyx_v_have_slices = __pyx_t_4;
14127   __pyx_t_4 = 0;
14128   __pyx_v_indices = __pyx_t_5;
14129   __pyx_t_5 = 0;
14130 
14131   /* "View.MemoryView":410
14132  *
14133  *         cdef char *itemp
14134  *         if have_slices:             # <<<<<<<<<<<<<<
14135  *             return memview_slice(self, indices)
14136  *         else:
14137  */
14138   __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_v_have_slices); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(3, 410, __pyx_L1_error)
14139   if (__pyx_t_2) {
14140 
14141     /* "View.MemoryView":411
14142  *         cdef char *itemp
14143  *         if have_slices:
14144  *             return memview_slice(self, indices)             # <<<<<<<<<<<<<<
14145  *         else:
14146  *             itemp = self.get_item_pointer(indices)
14147  */
14148     __Pyx_XDECREF(__pyx_r);
14149     __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)
14150     __Pyx_GOTREF(__pyx_t_3);
14151     __pyx_r = __pyx_t_3;
14152     __pyx_t_3 = 0;
14153     goto __pyx_L0;
14154 
14155     /* "View.MemoryView":410
14156  *
14157  *         cdef char *itemp
14158  *         if have_slices:             # <<<<<<<<<<<<<<
14159  *             return memview_slice(self, indices)
14160  *         else:
14161  */
14162   }
14163 
14164   /* "View.MemoryView":413
14165  *             return memview_slice(self, indices)
14166  *         else:
14167  *             itemp = self.get_item_pointer(indices)             # <<<<<<<<<<<<<<
14168  *             return self.convert_item_to_object(itemp)
14169  *
14170  */
14171   /*else*/ {
14172     __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)
14173     __pyx_v_itemp = __pyx_t_6;
14174 
14175     /* "View.MemoryView":414
14176  *         else:
14177  *             itemp = self.get_item_pointer(indices)
14178  *             return self.convert_item_to_object(itemp)             # <<<<<<<<<<<<<<
14179  *
14180  *     def __setitem__(memoryview self, object index, object value):
14181  */
14182     __Pyx_XDECREF(__pyx_r);
14183     __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)
14184     __Pyx_GOTREF(__pyx_t_3);
14185     __pyx_r = __pyx_t_3;
14186     __pyx_t_3 = 0;
14187     goto __pyx_L0;
14188   }
14189 
14190   /* "View.MemoryView":403
14191  *
14192  *
14193  *     def __getitem__(memoryview self, object index):             # <<<<<<<<<<<<<<
14194  *         if index is Ellipsis:
14195  *             return self
14196  */
14197 
14198   /* function exit code */
14199   __pyx_L1_error:;
14200   __Pyx_XDECREF(__pyx_t_3);
14201   __Pyx_XDECREF(__pyx_t_4);
14202   __Pyx_XDECREF(__pyx_t_5);
14203   __Pyx_AddTraceback("View.MemoryView.memoryview.__getitem__", __pyx_clineno, __pyx_lineno, __pyx_filename);
14204   __pyx_r = NULL;
14205   __pyx_L0:;
14206   __Pyx_XDECREF(__pyx_v_have_slices);
14207   __Pyx_XDECREF(__pyx_v_indices);
14208   __Pyx_XGIVEREF(__pyx_r);
14209   __Pyx_RefNannyFinishContext();
14210   return __pyx_r;
14211 }
14212 
14213 /* "View.MemoryView":416
14214  *             return self.convert_item_to_object(itemp)
14215  *
14216  *     def __setitem__(memoryview self, object index, object value):             # <<<<<<<<<<<<<<
14217  *         if self.view.readonly:
14218  *             raise TypeError("Cannot assign to read-only memoryview")
14219  */
14220 
14221 /* Python wrapper */
14222 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)14223 static int __pyx_memoryview___setitem__(PyObject *__pyx_v_self, PyObject *__pyx_v_index, PyObject *__pyx_v_value) {
14224   int __pyx_r;
14225   __Pyx_RefNannyDeclarations
14226   __Pyx_RefNannySetupContext("__setitem__ (wrapper)", 0);
14227   __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));
14228 
14229   /* function exit code */
14230   __Pyx_RefNannyFinishContext();
14231   return __pyx_r;
14232 }
14233 
__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)14234 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) {
14235   PyObject *__pyx_v_have_slices = NULL;
14236   PyObject *__pyx_v_obj = NULL;
14237   int __pyx_r;
14238   __Pyx_RefNannyDeclarations
14239   int __pyx_t_1;
14240   PyObject *__pyx_t_2 = NULL;
14241   PyObject *__pyx_t_3 = NULL;
14242   PyObject *__pyx_t_4 = NULL;
14243   int __pyx_lineno = 0;
14244   const char *__pyx_filename = NULL;
14245   int __pyx_clineno = 0;
14246   __Pyx_RefNannySetupContext("__setitem__", 0);
14247   __Pyx_INCREF(__pyx_v_index);
14248 
14249   /* "View.MemoryView":417
14250  *
14251  *     def __setitem__(memoryview self, object index, object value):
14252  *         if self.view.readonly:             # <<<<<<<<<<<<<<
14253  *             raise TypeError("Cannot assign to read-only memoryview")
14254  *
14255  */
14256   __pyx_t_1 = (__pyx_v_self->view.readonly != 0);
14257   if (unlikely(__pyx_t_1)) {
14258 
14259     /* "View.MemoryView":418
14260  *     def __setitem__(memoryview self, object index, object value):
14261  *         if self.view.readonly:
14262  *             raise TypeError("Cannot assign to read-only memoryview")             # <<<<<<<<<<<<<<
14263  *
14264  *         have_slices, index = _unellipsify(index, self.view.ndim)
14265  */
14266     __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__26, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(3, 418, __pyx_L1_error)
14267     __Pyx_GOTREF(__pyx_t_2);
14268     __Pyx_Raise(__pyx_t_2, 0, 0, 0);
14269     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
14270     __PYX_ERR(3, 418, __pyx_L1_error)
14271 
14272     /* "View.MemoryView":417
14273  *
14274  *     def __setitem__(memoryview self, object index, object value):
14275  *         if self.view.readonly:             # <<<<<<<<<<<<<<
14276  *             raise TypeError("Cannot assign to read-only memoryview")
14277  *
14278  */
14279   }
14280 
14281   /* "View.MemoryView":420
14282  *             raise TypeError("Cannot assign to read-only memoryview")
14283  *
14284  *         have_slices, index = _unellipsify(index, self.view.ndim)             # <<<<<<<<<<<<<<
14285  *
14286  *         if have_slices:
14287  */
14288   __pyx_t_2 = _unellipsify(__pyx_v_index, __pyx_v_self->view.ndim); if (unlikely(!__pyx_t_2)) __PYX_ERR(3, 420, __pyx_L1_error)
14289   __Pyx_GOTREF(__pyx_t_2);
14290   if (likely(__pyx_t_2 != Py_None)) {
14291     PyObject* sequence = __pyx_t_2;
14292     Py_ssize_t size = __Pyx_PySequence_SIZE(sequence);
14293     if (unlikely(size != 2)) {
14294       if (size > 2) __Pyx_RaiseTooManyValuesError(2);
14295       else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
14296       __PYX_ERR(3, 420, __pyx_L1_error)
14297     }
14298     #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
14299     __pyx_t_3 = PyTuple_GET_ITEM(sequence, 0);
14300     __pyx_t_4 = PyTuple_GET_ITEM(sequence, 1);
14301     __Pyx_INCREF(__pyx_t_3);
14302     __Pyx_INCREF(__pyx_t_4);
14303     #else
14304     __pyx_t_3 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(3, 420, __pyx_L1_error)
14305     __Pyx_GOTREF(__pyx_t_3);
14306     __pyx_t_4 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_4)) __PYX_ERR(3, 420, __pyx_L1_error)
14307     __Pyx_GOTREF(__pyx_t_4);
14308     #endif
14309     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
14310   } else {
14311     __Pyx_RaiseNoneNotIterableError(); __PYX_ERR(3, 420, __pyx_L1_error)
14312   }
14313   __pyx_v_have_slices = __pyx_t_3;
14314   __pyx_t_3 = 0;
14315   __Pyx_DECREF_SET(__pyx_v_index, __pyx_t_4);
14316   __pyx_t_4 = 0;
14317 
14318   /* "View.MemoryView":422
14319  *         have_slices, index = _unellipsify(index, self.view.ndim)
14320  *
14321  *         if have_slices:             # <<<<<<<<<<<<<<
14322  *             obj = self.is_slice(value)
14323  *             if obj:
14324  */
14325   __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_have_slices); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(3, 422, __pyx_L1_error)
14326   if (__pyx_t_1) {
14327 
14328     /* "View.MemoryView":423
14329  *
14330  *         if have_slices:
14331  *             obj = self.is_slice(value)             # <<<<<<<<<<<<<<
14332  *             if obj:
14333  *                 self.setitem_slice_assignment(self[index], obj)
14334  */
14335     __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)
14336     __Pyx_GOTREF(__pyx_t_2);
14337     __pyx_v_obj = __pyx_t_2;
14338     __pyx_t_2 = 0;
14339 
14340     /* "View.MemoryView":424
14341  *         if have_slices:
14342  *             obj = self.is_slice(value)
14343  *             if obj:             # <<<<<<<<<<<<<<
14344  *                 self.setitem_slice_assignment(self[index], obj)
14345  *             else:
14346  */
14347     __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_obj); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(3, 424, __pyx_L1_error)
14348     if (__pyx_t_1) {
14349 
14350       /* "View.MemoryView":425
14351  *             obj = self.is_slice(value)
14352  *             if obj:
14353  *                 self.setitem_slice_assignment(self[index], obj)             # <<<<<<<<<<<<<<
14354  *             else:
14355  *                 self.setitem_slice_assign_scalar(self[index], value)
14356  */
14357       __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)
14358       __Pyx_GOTREF(__pyx_t_2);
14359       __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)
14360       __Pyx_GOTREF(__pyx_t_4);
14361       __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
14362       __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
14363 
14364       /* "View.MemoryView":424
14365  *         if have_slices:
14366  *             obj = self.is_slice(value)
14367  *             if obj:             # <<<<<<<<<<<<<<
14368  *                 self.setitem_slice_assignment(self[index], obj)
14369  *             else:
14370  */
14371       goto __pyx_L5;
14372     }
14373 
14374     /* "View.MemoryView":427
14375  *                 self.setitem_slice_assignment(self[index], obj)
14376  *             else:
14377  *                 self.setitem_slice_assign_scalar(self[index], value)             # <<<<<<<<<<<<<<
14378  *         else:
14379  *             self.setitem_indexed(index, value)
14380  */
14381     /*else*/ {
14382       __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)
14383       __Pyx_GOTREF(__pyx_t_4);
14384       if (!(likely(((__pyx_t_4) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_4, __pyx_memoryview_type))))) __PYX_ERR(3, 427, __pyx_L1_error)
14385       __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)
14386       __Pyx_GOTREF(__pyx_t_2);
14387       __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
14388       __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
14389     }
14390     __pyx_L5:;
14391 
14392     /* "View.MemoryView":422
14393  *         have_slices, index = _unellipsify(index, self.view.ndim)
14394  *
14395  *         if have_slices:             # <<<<<<<<<<<<<<
14396  *             obj = self.is_slice(value)
14397  *             if obj:
14398  */
14399     goto __pyx_L4;
14400   }
14401 
14402   /* "View.MemoryView":429
14403  *                 self.setitem_slice_assign_scalar(self[index], value)
14404  *         else:
14405  *             self.setitem_indexed(index, value)             # <<<<<<<<<<<<<<
14406  *
14407  *     cdef is_slice(self, obj):
14408  */
14409   /*else*/ {
14410     __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)
14411     __Pyx_GOTREF(__pyx_t_2);
14412     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
14413   }
14414   __pyx_L4:;
14415 
14416   /* "View.MemoryView":416
14417  *             return self.convert_item_to_object(itemp)
14418  *
14419  *     def __setitem__(memoryview self, object index, object value):             # <<<<<<<<<<<<<<
14420  *         if self.view.readonly:
14421  *             raise TypeError("Cannot assign to read-only memoryview")
14422  */
14423 
14424   /* function exit code */
14425   __pyx_r = 0;
14426   goto __pyx_L0;
14427   __pyx_L1_error:;
14428   __Pyx_XDECREF(__pyx_t_2);
14429   __Pyx_XDECREF(__pyx_t_3);
14430   __Pyx_XDECREF(__pyx_t_4);
14431   __Pyx_AddTraceback("View.MemoryView.memoryview.__setitem__", __pyx_clineno, __pyx_lineno, __pyx_filename);
14432   __pyx_r = -1;
14433   __pyx_L0:;
14434   __Pyx_XDECREF(__pyx_v_have_slices);
14435   __Pyx_XDECREF(__pyx_v_obj);
14436   __Pyx_XDECREF(__pyx_v_index);
14437   __Pyx_RefNannyFinishContext();
14438   return __pyx_r;
14439 }
14440 
14441 /* "View.MemoryView":431
14442  *             self.setitem_indexed(index, value)
14443  *
14444  *     cdef is_slice(self, obj):             # <<<<<<<<<<<<<<
14445  *         if not isinstance(obj, memoryview):
14446  *             try:
14447  */
14448 
__pyx_memoryview_is_slice(struct __pyx_memoryview_obj * __pyx_v_self,PyObject * __pyx_v_obj)14449 static PyObject *__pyx_memoryview_is_slice(struct __pyx_memoryview_obj *__pyx_v_self, PyObject *__pyx_v_obj) {
14450   PyObject *__pyx_r = NULL;
14451   __Pyx_RefNannyDeclarations
14452   int __pyx_t_1;
14453   int __pyx_t_2;
14454   PyObject *__pyx_t_3 = NULL;
14455   PyObject *__pyx_t_4 = NULL;
14456   PyObject *__pyx_t_5 = NULL;
14457   PyObject *__pyx_t_6 = NULL;
14458   PyObject *__pyx_t_7 = NULL;
14459   PyObject *__pyx_t_8 = NULL;
14460   int __pyx_t_9;
14461   int __pyx_lineno = 0;
14462   const char *__pyx_filename = NULL;
14463   int __pyx_clineno = 0;
14464   __Pyx_RefNannySetupContext("is_slice", 0);
14465   __Pyx_INCREF(__pyx_v_obj);
14466 
14467   /* "View.MemoryView":432
14468  *
14469  *     cdef is_slice(self, obj):
14470  *         if not isinstance(obj, memoryview):             # <<<<<<<<<<<<<<
14471  *             try:
14472  *                 obj = memoryview(obj, self.flags & ~PyBUF_WRITABLE | PyBUF_ANY_CONTIGUOUS,
14473  */
14474   __pyx_t_1 = __Pyx_TypeCheck(__pyx_v_obj, __pyx_memoryview_type);
14475   __pyx_t_2 = ((!(__pyx_t_1 != 0)) != 0);
14476   if (__pyx_t_2) {
14477 
14478     /* "View.MemoryView":433
14479  *     cdef is_slice(self, obj):
14480  *         if not isinstance(obj, memoryview):
14481  *             try:             # <<<<<<<<<<<<<<
14482  *                 obj = memoryview(obj, self.flags & ~PyBUF_WRITABLE | PyBUF_ANY_CONTIGUOUS,
14483  *                                  self.dtype_is_object)
14484  */
14485     {
14486       __Pyx_PyThreadState_declare
14487       __Pyx_PyThreadState_assign
14488       __Pyx_ExceptionSave(&__pyx_t_3, &__pyx_t_4, &__pyx_t_5);
14489       __Pyx_XGOTREF(__pyx_t_3);
14490       __Pyx_XGOTREF(__pyx_t_4);
14491       __Pyx_XGOTREF(__pyx_t_5);
14492       /*try:*/ {
14493 
14494         /* "View.MemoryView":434
14495  *         if not isinstance(obj, memoryview):
14496  *             try:
14497  *                 obj = memoryview(obj, self.flags & ~PyBUF_WRITABLE | PyBUF_ANY_CONTIGUOUS,             # <<<<<<<<<<<<<<
14498  *                                  self.dtype_is_object)
14499  *             except TypeError:
14500  */
14501         __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)
14502         __Pyx_GOTREF(__pyx_t_6);
14503 
14504         /* "View.MemoryView":435
14505  *             try:
14506  *                 obj = memoryview(obj, self.flags & ~PyBUF_WRITABLE | PyBUF_ANY_CONTIGUOUS,
14507  *                                  self.dtype_is_object)             # <<<<<<<<<<<<<<
14508  *             except TypeError:
14509  *                 return None
14510  */
14511         __pyx_t_7 = __Pyx_PyBool_FromLong(__pyx_v_self->dtype_is_object); if (unlikely(!__pyx_t_7)) __PYX_ERR(3, 435, __pyx_L4_error)
14512         __Pyx_GOTREF(__pyx_t_7);
14513 
14514         /* "View.MemoryView":434
14515  *         if not isinstance(obj, memoryview):
14516  *             try:
14517  *                 obj = memoryview(obj, self.flags & ~PyBUF_WRITABLE | PyBUF_ANY_CONTIGUOUS,             # <<<<<<<<<<<<<<
14518  *                                  self.dtype_is_object)
14519  *             except TypeError:
14520  */
14521         __pyx_t_8 = PyTuple_New(3); if (unlikely(!__pyx_t_8)) __PYX_ERR(3, 434, __pyx_L4_error)
14522         __Pyx_GOTREF(__pyx_t_8);
14523         __Pyx_INCREF(__pyx_v_obj);
14524         __Pyx_GIVEREF(__pyx_v_obj);
14525         PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_v_obj);
14526         __Pyx_GIVEREF(__pyx_t_6);
14527         PyTuple_SET_ITEM(__pyx_t_8, 1, __pyx_t_6);
14528         __Pyx_GIVEREF(__pyx_t_7);
14529         PyTuple_SET_ITEM(__pyx_t_8, 2, __pyx_t_7);
14530         __pyx_t_6 = 0;
14531         __pyx_t_7 = 0;
14532         __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)
14533         __Pyx_GOTREF(__pyx_t_7);
14534         __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
14535         __Pyx_DECREF_SET(__pyx_v_obj, __pyx_t_7);
14536         __pyx_t_7 = 0;
14537 
14538         /* "View.MemoryView":433
14539  *     cdef is_slice(self, obj):
14540  *         if not isinstance(obj, memoryview):
14541  *             try:             # <<<<<<<<<<<<<<
14542  *                 obj = memoryview(obj, self.flags & ~PyBUF_WRITABLE | PyBUF_ANY_CONTIGUOUS,
14543  *                                  self.dtype_is_object)
14544  */
14545       }
14546       __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
14547       __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
14548       __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
14549       goto __pyx_L9_try_end;
14550       __pyx_L4_error:;
14551       __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
14552       __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
14553       __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
14554 
14555       /* "View.MemoryView":436
14556  *                 obj = memoryview(obj, self.flags & ~PyBUF_WRITABLE | PyBUF_ANY_CONTIGUOUS,
14557  *                                  self.dtype_is_object)
14558  *             except TypeError:             # <<<<<<<<<<<<<<
14559  *                 return None
14560  *
14561  */
14562       __pyx_t_9 = __Pyx_PyErr_ExceptionMatches(__pyx_builtin_TypeError);
14563       if (__pyx_t_9) {
14564         __Pyx_AddTraceback("View.MemoryView.memoryview.is_slice", __pyx_clineno, __pyx_lineno, __pyx_filename);
14565         if (__Pyx_GetException(&__pyx_t_7, &__pyx_t_8, &__pyx_t_6) < 0) __PYX_ERR(3, 436, __pyx_L6_except_error)
14566         __Pyx_GOTREF(__pyx_t_7);
14567         __Pyx_GOTREF(__pyx_t_8);
14568         __Pyx_GOTREF(__pyx_t_6);
14569 
14570         /* "View.MemoryView":437
14571  *                                  self.dtype_is_object)
14572  *             except TypeError:
14573  *                 return None             # <<<<<<<<<<<<<<
14574  *
14575  *         return obj
14576  */
14577         __Pyx_XDECREF(__pyx_r);
14578         __pyx_r = Py_None; __Pyx_INCREF(Py_None);
14579         __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
14580         __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
14581         __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
14582         goto __pyx_L7_except_return;
14583       }
14584       goto __pyx_L6_except_error;
14585       __pyx_L6_except_error:;
14586 
14587       /* "View.MemoryView":433
14588  *     cdef is_slice(self, obj):
14589  *         if not isinstance(obj, memoryview):
14590  *             try:             # <<<<<<<<<<<<<<
14591  *                 obj = memoryview(obj, self.flags & ~PyBUF_WRITABLE | PyBUF_ANY_CONTIGUOUS,
14592  *                                  self.dtype_is_object)
14593  */
14594       __Pyx_XGIVEREF(__pyx_t_3);
14595       __Pyx_XGIVEREF(__pyx_t_4);
14596       __Pyx_XGIVEREF(__pyx_t_5);
14597       __Pyx_ExceptionReset(__pyx_t_3, __pyx_t_4, __pyx_t_5);
14598       goto __pyx_L1_error;
14599       __pyx_L7_except_return:;
14600       __Pyx_XGIVEREF(__pyx_t_3);
14601       __Pyx_XGIVEREF(__pyx_t_4);
14602       __Pyx_XGIVEREF(__pyx_t_5);
14603       __Pyx_ExceptionReset(__pyx_t_3, __pyx_t_4, __pyx_t_5);
14604       goto __pyx_L0;
14605       __pyx_L9_try_end:;
14606     }
14607 
14608     /* "View.MemoryView":432
14609  *
14610  *     cdef is_slice(self, obj):
14611  *         if not isinstance(obj, memoryview):             # <<<<<<<<<<<<<<
14612  *             try:
14613  *                 obj = memoryview(obj, self.flags & ~PyBUF_WRITABLE | PyBUF_ANY_CONTIGUOUS,
14614  */
14615   }
14616 
14617   /* "View.MemoryView":439
14618  *                 return None
14619  *
14620  *         return obj             # <<<<<<<<<<<<<<
14621  *
14622  *     cdef setitem_slice_assignment(self, dst, src):
14623  */
14624   __Pyx_XDECREF(__pyx_r);
14625   __Pyx_INCREF(__pyx_v_obj);
14626   __pyx_r = __pyx_v_obj;
14627   goto __pyx_L0;
14628 
14629   /* "View.MemoryView":431
14630  *             self.setitem_indexed(index, value)
14631  *
14632  *     cdef is_slice(self, obj):             # <<<<<<<<<<<<<<
14633  *         if not isinstance(obj, memoryview):
14634  *             try:
14635  */
14636 
14637   /* function exit code */
14638   __pyx_L1_error:;
14639   __Pyx_XDECREF(__pyx_t_6);
14640   __Pyx_XDECREF(__pyx_t_7);
14641   __Pyx_XDECREF(__pyx_t_8);
14642   __Pyx_AddTraceback("View.MemoryView.memoryview.is_slice", __pyx_clineno, __pyx_lineno, __pyx_filename);
14643   __pyx_r = 0;
14644   __pyx_L0:;
14645   __Pyx_XDECREF(__pyx_v_obj);
14646   __Pyx_XGIVEREF(__pyx_r);
14647   __Pyx_RefNannyFinishContext();
14648   return __pyx_r;
14649 }
14650 
14651 /* "View.MemoryView":441
14652  *         return obj
14653  *
14654  *     cdef setitem_slice_assignment(self, dst, src):             # <<<<<<<<<<<<<<
14655  *         cdef __Pyx_memviewslice dst_slice
14656  *         cdef __Pyx_memviewslice src_slice
14657  */
14658 
__pyx_memoryview_setitem_slice_assignment(struct __pyx_memoryview_obj * __pyx_v_self,PyObject * __pyx_v_dst,PyObject * __pyx_v_src)14659 static PyObject *__pyx_memoryview_setitem_slice_assignment(struct __pyx_memoryview_obj *__pyx_v_self, PyObject *__pyx_v_dst, PyObject *__pyx_v_src) {
14660   __Pyx_memviewslice __pyx_v_dst_slice;
14661   __Pyx_memviewslice __pyx_v_src_slice;
14662   PyObject *__pyx_r = NULL;
14663   __Pyx_RefNannyDeclarations
14664   __Pyx_memviewslice *__pyx_t_1;
14665   __Pyx_memviewslice *__pyx_t_2;
14666   PyObject *__pyx_t_3 = NULL;
14667   int __pyx_t_4;
14668   int __pyx_t_5;
14669   int __pyx_t_6;
14670   int __pyx_lineno = 0;
14671   const char *__pyx_filename = NULL;
14672   int __pyx_clineno = 0;
14673   __Pyx_RefNannySetupContext("setitem_slice_assignment", 0);
14674 
14675   /* "View.MemoryView":445
14676  *         cdef __Pyx_memviewslice src_slice
14677  *
14678  *         memoryview_copy_contents(get_slice_from_memview(src, &src_slice)[0],             # <<<<<<<<<<<<<<
14679  *                                  get_slice_from_memview(dst, &dst_slice)[0],
14680  *                                  src.ndim, dst.ndim, self.dtype_is_object)
14681  */
14682   if (!(likely(((__pyx_v_src) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_src, __pyx_memoryview_type))))) __PYX_ERR(3, 445, __pyx_L1_error)
14683   __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)
14684 
14685   /* "View.MemoryView":446
14686  *
14687  *         memoryview_copy_contents(get_slice_from_memview(src, &src_slice)[0],
14688  *                                  get_slice_from_memview(dst, &dst_slice)[0],             # <<<<<<<<<<<<<<
14689  *                                  src.ndim, dst.ndim, self.dtype_is_object)
14690  *
14691  */
14692   if (!(likely(((__pyx_v_dst) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_dst, __pyx_memoryview_type))))) __PYX_ERR(3, 446, __pyx_L1_error)
14693   __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)
14694 
14695   /* "View.MemoryView":447
14696  *         memoryview_copy_contents(get_slice_from_memview(src, &src_slice)[0],
14697  *                                  get_slice_from_memview(dst, &dst_slice)[0],
14698  *                                  src.ndim, dst.ndim, self.dtype_is_object)             # <<<<<<<<<<<<<<
14699  *
14700  *     cdef setitem_slice_assign_scalar(self, memoryview dst, value):
14701  */
14702   __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)
14703   __Pyx_GOTREF(__pyx_t_3);
14704   __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)
14705   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
14706   __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)
14707   __Pyx_GOTREF(__pyx_t_3);
14708   __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)
14709   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
14710 
14711   /* "View.MemoryView":445
14712  *         cdef __Pyx_memviewslice src_slice
14713  *
14714  *         memoryview_copy_contents(get_slice_from_memview(src, &src_slice)[0],             # <<<<<<<<<<<<<<
14715  *                                  get_slice_from_memview(dst, &dst_slice)[0],
14716  *                                  src.ndim, dst.ndim, self.dtype_is_object)
14717  */
14718   __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)
14719 
14720   /* "View.MemoryView":441
14721  *         return obj
14722  *
14723  *     cdef setitem_slice_assignment(self, dst, src):             # <<<<<<<<<<<<<<
14724  *         cdef __Pyx_memviewslice dst_slice
14725  *         cdef __Pyx_memviewslice src_slice
14726  */
14727 
14728   /* function exit code */
14729   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
14730   goto __pyx_L0;
14731   __pyx_L1_error:;
14732   __Pyx_XDECREF(__pyx_t_3);
14733   __Pyx_AddTraceback("View.MemoryView.memoryview.setitem_slice_assignment", __pyx_clineno, __pyx_lineno, __pyx_filename);
14734   __pyx_r = 0;
14735   __pyx_L0:;
14736   __Pyx_XGIVEREF(__pyx_r);
14737   __Pyx_RefNannyFinishContext();
14738   return __pyx_r;
14739 }
14740 
14741 /* "View.MemoryView":449
14742  *                                  src.ndim, dst.ndim, self.dtype_is_object)
14743  *
14744  *     cdef setitem_slice_assign_scalar(self, memoryview dst, value):             # <<<<<<<<<<<<<<
14745  *         cdef int array[128]
14746  *         cdef void *tmp = NULL
14747  */
14748 
__pyx_memoryview_setitem_slice_assign_scalar(struct __pyx_memoryview_obj * __pyx_v_self,struct __pyx_memoryview_obj * __pyx_v_dst,PyObject * __pyx_v_value)14749 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) {
14750   int __pyx_v_array[0x80];
14751   void *__pyx_v_tmp;
14752   void *__pyx_v_item;
14753   __Pyx_memviewslice *__pyx_v_dst_slice;
14754   __Pyx_memviewslice __pyx_v_tmp_slice;
14755   PyObject *__pyx_r = NULL;
14756   __Pyx_RefNannyDeclarations
14757   __Pyx_memviewslice *__pyx_t_1;
14758   int __pyx_t_2;
14759   PyObject *__pyx_t_3 = NULL;
14760   int __pyx_t_4;
14761   int __pyx_t_5;
14762   char const *__pyx_t_6;
14763   PyObject *__pyx_t_7 = NULL;
14764   PyObject *__pyx_t_8 = NULL;
14765   PyObject *__pyx_t_9 = NULL;
14766   PyObject *__pyx_t_10 = NULL;
14767   PyObject *__pyx_t_11 = NULL;
14768   PyObject *__pyx_t_12 = NULL;
14769   int __pyx_lineno = 0;
14770   const char *__pyx_filename = NULL;
14771   int __pyx_clineno = 0;
14772   __Pyx_RefNannySetupContext("setitem_slice_assign_scalar", 0);
14773 
14774   /* "View.MemoryView":451
14775  *     cdef setitem_slice_assign_scalar(self, memoryview dst, value):
14776  *         cdef int array[128]
14777  *         cdef void *tmp = NULL             # <<<<<<<<<<<<<<
14778  *         cdef void *item
14779  *
14780  */
14781   __pyx_v_tmp = NULL;
14782 
14783   /* "View.MemoryView":456
14784  *         cdef __Pyx_memviewslice *dst_slice
14785  *         cdef __Pyx_memviewslice tmp_slice
14786  *         dst_slice = get_slice_from_memview(dst, &tmp_slice)             # <<<<<<<<<<<<<<
14787  *
14788  *         if <size_t>self.view.itemsize > sizeof(array):
14789  */
14790   __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)
14791   __pyx_v_dst_slice = __pyx_t_1;
14792 
14793   /* "View.MemoryView":458
14794  *         dst_slice = get_slice_from_memview(dst, &tmp_slice)
14795  *
14796  *         if <size_t>self.view.itemsize > sizeof(array):             # <<<<<<<<<<<<<<
14797  *             tmp = PyMem_Malloc(self.view.itemsize)
14798  *             if tmp == NULL:
14799  */
14800   __pyx_t_2 = ((((size_t)__pyx_v_self->view.itemsize) > (sizeof(__pyx_v_array))) != 0);
14801   if (__pyx_t_2) {
14802 
14803     /* "View.MemoryView":459
14804  *
14805  *         if <size_t>self.view.itemsize > sizeof(array):
14806  *             tmp = PyMem_Malloc(self.view.itemsize)             # <<<<<<<<<<<<<<
14807  *             if tmp == NULL:
14808  *                 raise MemoryError
14809  */
14810     __pyx_v_tmp = PyMem_Malloc(__pyx_v_self->view.itemsize);
14811 
14812     /* "View.MemoryView":460
14813  *         if <size_t>self.view.itemsize > sizeof(array):
14814  *             tmp = PyMem_Malloc(self.view.itemsize)
14815  *             if tmp == NULL:             # <<<<<<<<<<<<<<
14816  *                 raise MemoryError
14817  *             item = tmp
14818  */
14819     __pyx_t_2 = ((__pyx_v_tmp == NULL) != 0);
14820     if (unlikely(__pyx_t_2)) {
14821 
14822       /* "View.MemoryView":461
14823  *             tmp = PyMem_Malloc(self.view.itemsize)
14824  *             if tmp == NULL:
14825  *                 raise MemoryError             # <<<<<<<<<<<<<<
14826  *             item = tmp
14827  *         else:
14828  */
14829       PyErr_NoMemory(); __PYX_ERR(3, 461, __pyx_L1_error)
14830 
14831       /* "View.MemoryView":460
14832  *         if <size_t>self.view.itemsize > sizeof(array):
14833  *             tmp = PyMem_Malloc(self.view.itemsize)
14834  *             if tmp == NULL:             # <<<<<<<<<<<<<<
14835  *                 raise MemoryError
14836  *             item = tmp
14837  */
14838     }
14839 
14840     /* "View.MemoryView":462
14841  *             if tmp == NULL:
14842  *                 raise MemoryError
14843  *             item = tmp             # <<<<<<<<<<<<<<
14844  *         else:
14845  *             item = <void *> array
14846  */
14847     __pyx_v_item = __pyx_v_tmp;
14848 
14849     /* "View.MemoryView":458
14850  *         dst_slice = get_slice_from_memview(dst, &tmp_slice)
14851  *
14852  *         if <size_t>self.view.itemsize > sizeof(array):             # <<<<<<<<<<<<<<
14853  *             tmp = PyMem_Malloc(self.view.itemsize)
14854  *             if tmp == NULL:
14855  */
14856     goto __pyx_L3;
14857   }
14858 
14859   /* "View.MemoryView":464
14860  *             item = tmp
14861  *         else:
14862  *             item = <void *> array             # <<<<<<<<<<<<<<
14863  *
14864  *         try:
14865  */
14866   /*else*/ {
14867     __pyx_v_item = ((void *)__pyx_v_array);
14868   }
14869   __pyx_L3:;
14870 
14871   /* "View.MemoryView":466
14872  *             item = <void *> array
14873  *
14874  *         try:             # <<<<<<<<<<<<<<
14875  *             if self.dtype_is_object:
14876  *                 (<PyObject **> item)[0] = <PyObject *> value
14877  */
14878   /*try:*/ {
14879 
14880     /* "View.MemoryView":467
14881  *
14882  *         try:
14883  *             if self.dtype_is_object:             # <<<<<<<<<<<<<<
14884  *                 (<PyObject **> item)[0] = <PyObject *> value
14885  *             else:
14886  */
14887     __pyx_t_2 = (__pyx_v_self->dtype_is_object != 0);
14888     if (__pyx_t_2) {
14889 
14890       /* "View.MemoryView":468
14891  *         try:
14892  *             if self.dtype_is_object:
14893  *                 (<PyObject **> item)[0] = <PyObject *> value             # <<<<<<<<<<<<<<
14894  *             else:
14895  *                 self.assign_item_from_object(<char *> item, value)
14896  */
14897       (((PyObject **)__pyx_v_item)[0]) = ((PyObject *)__pyx_v_value);
14898 
14899       /* "View.MemoryView":467
14900  *
14901  *         try:
14902  *             if self.dtype_is_object:             # <<<<<<<<<<<<<<
14903  *                 (<PyObject **> item)[0] = <PyObject *> value
14904  *             else:
14905  */
14906       goto __pyx_L8;
14907     }
14908 
14909     /* "View.MemoryView":470
14910  *                 (<PyObject **> item)[0] = <PyObject *> value
14911  *             else:
14912  *                 self.assign_item_from_object(<char *> item, value)             # <<<<<<<<<<<<<<
14913  *
14914  *
14915  */
14916     /*else*/ {
14917       __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)
14918       __Pyx_GOTREF(__pyx_t_3);
14919       __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
14920     }
14921     __pyx_L8:;
14922 
14923     /* "View.MemoryView":474
14924  *
14925  *
14926  *             if self.view.suboffsets != NULL:             # <<<<<<<<<<<<<<
14927  *                 assert_direct_dimensions(self.view.suboffsets, self.view.ndim)
14928  *             slice_assign_scalar(dst_slice, dst.view.ndim, self.view.itemsize,
14929  */
14930     __pyx_t_2 = ((__pyx_v_self->view.suboffsets != NULL) != 0);
14931     if (__pyx_t_2) {
14932 
14933       /* "View.MemoryView":475
14934  *
14935  *             if self.view.suboffsets != NULL:
14936  *                 assert_direct_dimensions(self.view.suboffsets, self.view.ndim)             # <<<<<<<<<<<<<<
14937  *             slice_assign_scalar(dst_slice, dst.view.ndim, self.view.itemsize,
14938  *                                 item, self.dtype_is_object)
14939  */
14940       __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)
14941       __Pyx_GOTREF(__pyx_t_3);
14942       __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
14943 
14944       /* "View.MemoryView":474
14945  *
14946  *
14947  *             if self.view.suboffsets != NULL:             # <<<<<<<<<<<<<<
14948  *                 assert_direct_dimensions(self.view.suboffsets, self.view.ndim)
14949  *             slice_assign_scalar(dst_slice, dst.view.ndim, self.view.itemsize,
14950  */
14951     }
14952 
14953     /* "View.MemoryView":476
14954  *             if self.view.suboffsets != NULL:
14955  *                 assert_direct_dimensions(self.view.suboffsets, self.view.ndim)
14956  *             slice_assign_scalar(dst_slice, dst.view.ndim, self.view.itemsize,             # <<<<<<<<<<<<<<
14957  *                                 item, self.dtype_is_object)
14958  *         finally:
14959  */
14960     __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);
14961   }
14962 
14963   /* "View.MemoryView":479
14964  *                                 item, self.dtype_is_object)
14965  *         finally:
14966  *             PyMem_Free(tmp)             # <<<<<<<<<<<<<<
14967  *
14968  *     cdef setitem_indexed(self, index, value):
14969  */
14970   /*finally:*/ {
14971     /*normal exit:*/{
14972       PyMem_Free(__pyx_v_tmp);
14973       goto __pyx_L7;
14974     }
14975     __pyx_L6_error:;
14976     /*exception exit:*/{
14977       __Pyx_PyThreadState_declare
14978       __Pyx_PyThreadState_assign
14979       __pyx_t_7 = 0; __pyx_t_8 = 0; __pyx_t_9 = 0; __pyx_t_10 = 0; __pyx_t_11 = 0; __pyx_t_12 = 0;
14980       __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
14981       if (PY_MAJOR_VERSION >= 3) __Pyx_ExceptionSwap(&__pyx_t_10, &__pyx_t_11, &__pyx_t_12);
14982       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);
14983       __Pyx_XGOTREF(__pyx_t_7);
14984       __Pyx_XGOTREF(__pyx_t_8);
14985       __Pyx_XGOTREF(__pyx_t_9);
14986       __Pyx_XGOTREF(__pyx_t_10);
14987       __Pyx_XGOTREF(__pyx_t_11);
14988       __Pyx_XGOTREF(__pyx_t_12);
14989       __pyx_t_4 = __pyx_lineno; __pyx_t_5 = __pyx_clineno; __pyx_t_6 = __pyx_filename;
14990       {
14991         PyMem_Free(__pyx_v_tmp);
14992       }
14993       if (PY_MAJOR_VERSION >= 3) {
14994         __Pyx_XGIVEREF(__pyx_t_10);
14995         __Pyx_XGIVEREF(__pyx_t_11);
14996         __Pyx_XGIVEREF(__pyx_t_12);
14997         __Pyx_ExceptionReset(__pyx_t_10, __pyx_t_11, __pyx_t_12);
14998       }
14999       __Pyx_XGIVEREF(__pyx_t_7);
15000       __Pyx_XGIVEREF(__pyx_t_8);
15001       __Pyx_XGIVEREF(__pyx_t_9);
15002       __Pyx_ErrRestore(__pyx_t_7, __pyx_t_8, __pyx_t_9);
15003       __pyx_t_7 = 0; __pyx_t_8 = 0; __pyx_t_9 = 0; __pyx_t_10 = 0; __pyx_t_11 = 0; __pyx_t_12 = 0;
15004       __pyx_lineno = __pyx_t_4; __pyx_clineno = __pyx_t_5; __pyx_filename = __pyx_t_6;
15005       goto __pyx_L1_error;
15006     }
15007     __pyx_L7:;
15008   }
15009 
15010   /* "View.MemoryView":449
15011  *                                  src.ndim, dst.ndim, self.dtype_is_object)
15012  *
15013  *     cdef setitem_slice_assign_scalar(self, memoryview dst, value):             # <<<<<<<<<<<<<<
15014  *         cdef int array[128]
15015  *         cdef void *tmp = NULL
15016  */
15017 
15018   /* function exit code */
15019   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
15020   goto __pyx_L0;
15021   __pyx_L1_error:;
15022   __Pyx_XDECREF(__pyx_t_3);
15023   __Pyx_AddTraceback("View.MemoryView.memoryview.setitem_slice_assign_scalar", __pyx_clineno, __pyx_lineno, __pyx_filename);
15024   __pyx_r = 0;
15025   __pyx_L0:;
15026   __Pyx_XGIVEREF(__pyx_r);
15027   __Pyx_RefNannyFinishContext();
15028   return __pyx_r;
15029 }
15030 
15031 /* "View.MemoryView":481
15032  *             PyMem_Free(tmp)
15033  *
15034  *     cdef setitem_indexed(self, index, value):             # <<<<<<<<<<<<<<
15035  *         cdef char *itemp = self.get_item_pointer(index)
15036  *         self.assign_item_from_object(itemp, value)
15037  */
15038 
__pyx_memoryview_setitem_indexed(struct __pyx_memoryview_obj * __pyx_v_self,PyObject * __pyx_v_index,PyObject * __pyx_v_value)15039 static PyObject *__pyx_memoryview_setitem_indexed(struct __pyx_memoryview_obj *__pyx_v_self, PyObject *__pyx_v_index, PyObject *__pyx_v_value) {
15040   char *__pyx_v_itemp;
15041   PyObject *__pyx_r = NULL;
15042   __Pyx_RefNannyDeclarations
15043   char *__pyx_t_1;
15044   PyObject *__pyx_t_2 = NULL;
15045   int __pyx_lineno = 0;
15046   const char *__pyx_filename = NULL;
15047   int __pyx_clineno = 0;
15048   __Pyx_RefNannySetupContext("setitem_indexed", 0);
15049 
15050   /* "View.MemoryView":482
15051  *
15052  *     cdef setitem_indexed(self, index, value):
15053  *         cdef char *itemp = self.get_item_pointer(index)             # <<<<<<<<<<<<<<
15054  *         self.assign_item_from_object(itemp, value)
15055  *
15056  */
15057   __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)
15058   __pyx_v_itemp = __pyx_t_1;
15059 
15060   /* "View.MemoryView":483
15061  *     cdef setitem_indexed(self, index, value):
15062  *         cdef char *itemp = self.get_item_pointer(index)
15063  *         self.assign_item_from_object(itemp, value)             # <<<<<<<<<<<<<<
15064  *
15065  *     cdef convert_item_to_object(self, char *itemp):
15066  */
15067   __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)
15068   __Pyx_GOTREF(__pyx_t_2);
15069   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
15070 
15071   /* "View.MemoryView":481
15072  *             PyMem_Free(tmp)
15073  *
15074  *     cdef setitem_indexed(self, index, value):             # <<<<<<<<<<<<<<
15075  *         cdef char *itemp = self.get_item_pointer(index)
15076  *         self.assign_item_from_object(itemp, value)
15077  */
15078 
15079   /* function exit code */
15080   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
15081   goto __pyx_L0;
15082   __pyx_L1_error:;
15083   __Pyx_XDECREF(__pyx_t_2);
15084   __Pyx_AddTraceback("View.MemoryView.memoryview.setitem_indexed", __pyx_clineno, __pyx_lineno, __pyx_filename);
15085   __pyx_r = 0;
15086   __pyx_L0:;
15087   __Pyx_XGIVEREF(__pyx_r);
15088   __Pyx_RefNannyFinishContext();
15089   return __pyx_r;
15090 }
15091 
15092 /* "View.MemoryView":485
15093  *         self.assign_item_from_object(itemp, value)
15094  *
15095  *     cdef convert_item_to_object(self, char *itemp):             # <<<<<<<<<<<<<<
15096  *         """Only used if instantiated manually by the user, or if Cython doesn't
15097  *         know how to convert the type"""
15098  */
15099 
__pyx_memoryview_convert_item_to_object(struct __pyx_memoryview_obj * __pyx_v_self,char * __pyx_v_itemp)15100 static PyObject *__pyx_memoryview_convert_item_to_object(struct __pyx_memoryview_obj *__pyx_v_self, char *__pyx_v_itemp) {
15101   PyObject *__pyx_v_struct = NULL;
15102   PyObject *__pyx_v_bytesitem = 0;
15103   PyObject *__pyx_v_result = NULL;
15104   PyObject *__pyx_r = NULL;
15105   __Pyx_RefNannyDeclarations
15106   PyObject *__pyx_t_1 = NULL;
15107   PyObject *__pyx_t_2 = NULL;
15108   PyObject *__pyx_t_3 = NULL;
15109   PyObject *__pyx_t_4 = NULL;
15110   PyObject *__pyx_t_5 = NULL;
15111   PyObject *__pyx_t_6 = NULL;
15112   PyObject *__pyx_t_7 = NULL;
15113   int __pyx_t_8;
15114   PyObject *__pyx_t_9 = NULL;
15115   size_t __pyx_t_10;
15116   int __pyx_t_11;
15117   int __pyx_lineno = 0;
15118   const char *__pyx_filename = NULL;
15119   int __pyx_clineno = 0;
15120   __Pyx_RefNannySetupContext("convert_item_to_object", 0);
15121 
15122   /* "View.MemoryView":488
15123  *         """Only used if instantiated manually by the user, or if Cython doesn't
15124  *         know how to convert the type"""
15125  *         import struct             # <<<<<<<<<<<<<<
15126  *         cdef bytes bytesitem
15127  *
15128  */
15129   __pyx_t_1 = __Pyx_Import(__pyx_n_s_struct, 0, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(3, 488, __pyx_L1_error)
15130   __Pyx_GOTREF(__pyx_t_1);
15131   __pyx_v_struct = __pyx_t_1;
15132   __pyx_t_1 = 0;
15133 
15134   /* "View.MemoryView":491
15135  *         cdef bytes bytesitem
15136  *
15137  *         bytesitem = itemp[:self.view.itemsize]             # <<<<<<<<<<<<<<
15138  *         try:
15139  *             result = struct.unpack(self.view.format, bytesitem)
15140  */
15141   __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)
15142   __Pyx_GOTREF(__pyx_t_1);
15143   __pyx_v_bytesitem = ((PyObject*)__pyx_t_1);
15144   __pyx_t_1 = 0;
15145 
15146   /* "View.MemoryView":492
15147  *
15148  *         bytesitem = itemp[:self.view.itemsize]
15149  *         try:             # <<<<<<<<<<<<<<
15150  *             result = struct.unpack(self.view.format, bytesitem)
15151  *         except struct.error:
15152  */
15153   {
15154     __Pyx_PyThreadState_declare
15155     __Pyx_PyThreadState_assign
15156     __Pyx_ExceptionSave(&__pyx_t_2, &__pyx_t_3, &__pyx_t_4);
15157     __Pyx_XGOTREF(__pyx_t_2);
15158     __Pyx_XGOTREF(__pyx_t_3);
15159     __Pyx_XGOTREF(__pyx_t_4);
15160     /*try:*/ {
15161 
15162       /* "View.MemoryView":493
15163  *         bytesitem = itemp[:self.view.itemsize]
15164  *         try:
15165  *             result = struct.unpack(self.view.format, bytesitem)             # <<<<<<<<<<<<<<
15166  *         except struct.error:
15167  *             raise ValueError("Unable to convert item to object")
15168  */
15169       __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)
15170       __Pyx_GOTREF(__pyx_t_5);
15171       __pyx_t_6 = __Pyx_PyBytes_FromString(__pyx_v_self->view.format); if (unlikely(!__pyx_t_6)) __PYX_ERR(3, 493, __pyx_L3_error)
15172       __Pyx_GOTREF(__pyx_t_6);
15173       __pyx_t_7 = NULL;
15174       __pyx_t_8 = 0;
15175       if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_5))) {
15176         __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_5);
15177         if (likely(__pyx_t_7)) {
15178           PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
15179           __Pyx_INCREF(__pyx_t_7);
15180           __Pyx_INCREF(function);
15181           __Pyx_DECREF_SET(__pyx_t_5, function);
15182           __pyx_t_8 = 1;
15183         }
15184       }
15185       #if CYTHON_FAST_PYCALL
15186       if (PyFunction_Check(__pyx_t_5)) {
15187         PyObject *__pyx_temp[3] = {__pyx_t_7, __pyx_t_6, __pyx_v_bytesitem};
15188         __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)
15189         __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
15190         __Pyx_GOTREF(__pyx_t_1);
15191         __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
15192       } else
15193       #endif
15194       #if CYTHON_FAST_PYCCALL
15195       if (__Pyx_PyFastCFunction_Check(__pyx_t_5)) {
15196         PyObject *__pyx_temp[3] = {__pyx_t_7, __pyx_t_6, __pyx_v_bytesitem};
15197         __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)
15198         __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
15199         __Pyx_GOTREF(__pyx_t_1);
15200         __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
15201       } else
15202       #endif
15203       {
15204         __pyx_t_9 = PyTuple_New(2+__pyx_t_8); if (unlikely(!__pyx_t_9)) __PYX_ERR(3, 493, __pyx_L3_error)
15205         __Pyx_GOTREF(__pyx_t_9);
15206         if (__pyx_t_7) {
15207           __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_7); __pyx_t_7 = NULL;
15208         }
15209         __Pyx_GIVEREF(__pyx_t_6);
15210         PyTuple_SET_ITEM(__pyx_t_9, 0+__pyx_t_8, __pyx_t_6);
15211         __Pyx_INCREF(__pyx_v_bytesitem);
15212         __Pyx_GIVEREF(__pyx_v_bytesitem);
15213         PyTuple_SET_ITEM(__pyx_t_9, 1+__pyx_t_8, __pyx_v_bytesitem);
15214         __pyx_t_6 = 0;
15215         __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)
15216         __Pyx_GOTREF(__pyx_t_1);
15217         __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
15218       }
15219       __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
15220       __pyx_v_result = __pyx_t_1;
15221       __pyx_t_1 = 0;
15222 
15223       /* "View.MemoryView":492
15224  *
15225  *         bytesitem = itemp[:self.view.itemsize]
15226  *         try:             # <<<<<<<<<<<<<<
15227  *             result = struct.unpack(self.view.format, bytesitem)
15228  *         except struct.error:
15229  */
15230     }
15231 
15232     /* "View.MemoryView":497
15233  *             raise ValueError("Unable to convert item to object")
15234  *         else:
15235  *             if len(self.view.format) == 1:             # <<<<<<<<<<<<<<
15236  *                 return result[0]
15237  *             return result
15238  */
15239     /*else:*/ {
15240       __pyx_t_10 = strlen(__pyx_v_self->view.format);
15241       __pyx_t_11 = ((__pyx_t_10 == 1) != 0);
15242       if (__pyx_t_11) {
15243 
15244         /* "View.MemoryView":498
15245  *         else:
15246  *             if len(self.view.format) == 1:
15247  *                 return result[0]             # <<<<<<<<<<<<<<
15248  *             return result
15249  *
15250  */
15251         __Pyx_XDECREF(__pyx_r);
15252         __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)
15253         __Pyx_GOTREF(__pyx_t_1);
15254         __pyx_r = __pyx_t_1;
15255         __pyx_t_1 = 0;
15256         goto __pyx_L6_except_return;
15257 
15258         /* "View.MemoryView":497
15259  *             raise ValueError("Unable to convert item to object")
15260  *         else:
15261  *             if len(self.view.format) == 1:             # <<<<<<<<<<<<<<
15262  *                 return result[0]
15263  *             return result
15264  */
15265       }
15266 
15267       /* "View.MemoryView":499
15268  *             if len(self.view.format) == 1:
15269  *                 return result[0]
15270  *             return result             # <<<<<<<<<<<<<<
15271  *
15272  *     cdef assign_item_from_object(self, char *itemp, object value):
15273  */
15274       __Pyx_XDECREF(__pyx_r);
15275       __Pyx_INCREF(__pyx_v_result);
15276       __pyx_r = __pyx_v_result;
15277       goto __pyx_L6_except_return;
15278     }
15279     __pyx_L3_error:;
15280     __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
15281     __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
15282     __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
15283     __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
15284     __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
15285 
15286     /* "View.MemoryView":494
15287  *         try:
15288  *             result = struct.unpack(self.view.format, bytesitem)
15289  *         except struct.error:             # <<<<<<<<<<<<<<
15290  *             raise ValueError("Unable to convert item to object")
15291  *         else:
15292  */
15293     __Pyx_ErrFetch(&__pyx_t_1, &__pyx_t_5, &__pyx_t_9);
15294     __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)
15295     __Pyx_GOTREF(__pyx_t_6);
15296     __pyx_t_8 = __Pyx_PyErr_GivenExceptionMatches(__pyx_t_1, __pyx_t_6);
15297     __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
15298     __Pyx_ErrRestore(__pyx_t_1, __pyx_t_5, __pyx_t_9);
15299     __pyx_t_1 = 0; __pyx_t_5 = 0; __pyx_t_9 = 0;
15300     if (__pyx_t_8) {
15301       __Pyx_AddTraceback("View.MemoryView.memoryview.convert_item_to_object", __pyx_clineno, __pyx_lineno, __pyx_filename);
15302       if (__Pyx_GetException(&__pyx_t_9, &__pyx_t_5, &__pyx_t_1) < 0) __PYX_ERR(3, 494, __pyx_L5_except_error)
15303       __Pyx_GOTREF(__pyx_t_9);
15304       __Pyx_GOTREF(__pyx_t_5);
15305       __Pyx_GOTREF(__pyx_t_1);
15306 
15307       /* "View.MemoryView":495
15308  *             result = struct.unpack(self.view.format, bytesitem)
15309  *         except struct.error:
15310  *             raise ValueError("Unable to convert item to object")             # <<<<<<<<<<<<<<
15311  *         else:
15312  *             if len(self.view.format) == 1:
15313  */
15314       __pyx_t_6 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__27, NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(3, 495, __pyx_L5_except_error)
15315       __Pyx_GOTREF(__pyx_t_6);
15316       __Pyx_Raise(__pyx_t_6, 0, 0, 0);
15317       __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
15318       __PYX_ERR(3, 495, __pyx_L5_except_error)
15319     }
15320     goto __pyx_L5_except_error;
15321     __pyx_L5_except_error:;
15322 
15323     /* "View.MemoryView":492
15324  *
15325  *         bytesitem = itemp[:self.view.itemsize]
15326  *         try:             # <<<<<<<<<<<<<<
15327  *             result = struct.unpack(self.view.format, bytesitem)
15328  *         except struct.error:
15329  */
15330     __Pyx_XGIVEREF(__pyx_t_2);
15331     __Pyx_XGIVEREF(__pyx_t_3);
15332     __Pyx_XGIVEREF(__pyx_t_4);
15333     __Pyx_ExceptionReset(__pyx_t_2, __pyx_t_3, __pyx_t_4);
15334     goto __pyx_L1_error;
15335     __pyx_L6_except_return:;
15336     __Pyx_XGIVEREF(__pyx_t_2);
15337     __Pyx_XGIVEREF(__pyx_t_3);
15338     __Pyx_XGIVEREF(__pyx_t_4);
15339     __Pyx_ExceptionReset(__pyx_t_2, __pyx_t_3, __pyx_t_4);
15340     goto __pyx_L0;
15341   }
15342 
15343   /* "View.MemoryView":485
15344  *         self.assign_item_from_object(itemp, value)
15345  *
15346  *     cdef convert_item_to_object(self, char *itemp):             # <<<<<<<<<<<<<<
15347  *         """Only used if instantiated manually by the user, or if Cython doesn't
15348  *         know how to convert the type"""
15349  */
15350 
15351   /* function exit code */
15352   __pyx_L1_error:;
15353   __Pyx_XDECREF(__pyx_t_1);
15354   __Pyx_XDECREF(__pyx_t_5);
15355   __Pyx_XDECREF(__pyx_t_6);
15356   __Pyx_XDECREF(__pyx_t_7);
15357   __Pyx_XDECREF(__pyx_t_9);
15358   __Pyx_AddTraceback("View.MemoryView.memoryview.convert_item_to_object", __pyx_clineno, __pyx_lineno, __pyx_filename);
15359   __pyx_r = 0;
15360   __pyx_L0:;
15361   __Pyx_XDECREF(__pyx_v_struct);
15362   __Pyx_XDECREF(__pyx_v_bytesitem);
15363   __Pyx_XDECREF(__pyx_v_result);
15364   __Pyx_XGIVEREF(__pyx_r);
15365   __Pyx_RefNannyFinishContext();
15366   return __pyx_r;
15367 }
15368 
15369 /* "View.MemoryView":501
15370  *             return result
15371  *
15372  *     cdef assign_item_from_object(self, char *itemp, object value):             # <<<<<<<<<<<<<<
15373  *         """Only used if instantiated manually by the user, or if Cython doesn't
15374  *         know how to convert the type"""
15375  */
15376 
__pyx_memoryview_assign_item_from_object(struct __pyx_memoryview_obj * __pyx_v_self,char * __pyx_v_itemp,PyObject * __pyx_v_value)15377 static PyObject *__pyx_memoryview_assign_item_from_object(struct __pyx_memoryview_obj *__pyx_v_self, char *__pyx_v_itemp, PyObject *__pyx_v_value) {
15378   PyObject *__pyx_v_struct = NULL;
15379   char __pyx_v_c;
15380   PyObject *__pyx_v_bytesvalue = 0;
15381   Py_ssize_t __pyx_v_i;
15382   PyObject *__pyx_r = NULL;
15383   __Pyx_RefNannyDeclarations
15384   PyObject *__pyx_t_1 = NULL;
15385   int __pyx_t_2;
15386   int __pyx_t_3;
15387   PyObject *__pyx_t_4 = NULL;
15388   PyObject *__pyx_t_5 = NULL;
15389   PyObject *__pyx_t_6 = NULL;
15390   int __pyx_t_7;
15391   PyObject *__pyx_t_8 = NULL;
15392   Py_ssize_t __pyx_t_9;
15393   PyObject *__pyx_t_10 = NULL;
15394   char *__pyx_t_11;
15395   char *__pyx_t_12;
15396   char *__pyx_t_13;
15397   char *__pyx_t_14;
15398   int __pyx_lineno = 0;
15399   const char *__pyx_filename = NULL;
15400   int __pyx_clineno = 0;
15401   __Pyx_RefNannySetupContext("assign_item_from_object", 0);
15402 
15403   /* "View.MemoryView":504
15404  *         """Only used if instantiated manually by the user, or if Cython doesn't
15405  *         know how to convert the type"""
15406  *         import struct             # <<<<<<<<<<<<<<
15407  *         cdef char c
15408  *         cdef bytes bytesvalue
15409  */
15410   __pyx_t_1 = __Pyx_Import(__pyx_n_s_struct, 0, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(3, 504, __pyx_L1_error)
15411   __Pyx_GOTREF(__pyx_t_1);
15412   __pyx_v_struct = __pyx_t_1;
15413   __pyx_t_1 = 0;
15414 
15415   /* "View.MemoryView":509
15416  *         cdef Py_ssize_t i
15417  *
15418  *         if isinstance(value, tuple):             # <<<<<<<<<<<<<<
15419  *             bytesvalue = struct.pack(self.view.format, *value)
15420  *         else:
15421  */
15422   __pyx_t_2 = PyTuple_Check(__pyx_v_value);
15423   __pyx_t_3 = (__pyx_t_2 != 0);
15424   if (__pyx_t_3) {
15425 
15426     /* "View.MemoryView":510
15427  *
15428  *         if isinstance(value, tuple):
15429  *             bytesvalue = struct.pack(self.view.format, *value)             # <<<<<<<<<<<<<<
15430  *         else:
15431  *             bytesvalue = struct.pack(self.view.format, value)
15432  */
15433     __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)
15434     __Pyx_GOTREF(__pyx_t_1);
15435     __pyx_t_4 = __Pyx_PyBytes_FromString(__pyx_v_self->view.format); if (unlikely(!__pyx_t_4)) __PYX_ERR(3, 510, __pyx_L1_error)
15436     __Pyx_GOTREF(__pyx_t_4);
15437     __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) __PYX_ERR(3, 510, __pyx_L1_error)
15438     __Pyx_GOTREF(__pyx_t_5);
15439     __Pyx_GIVEREF(__pyx_t_4);
15440     PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_4);
15441     __pyx_t_4 = 0;
15442     __pyx_t_4 = __Pyx_PySequence_Tuple(__pyx_v_value); if (unlikely(!__pyx_t_4)) __PYX_ERR(3, 510, __pyx_L1_error)
15443     __Pyx_GOTREF(__pyx_t_4);
15444     __pyx_t_6 = PyNumber_Add(__pyx_t_5, __pyx_t_4); if (unlikely(!__pyx_t_6)) __PYX_ERR(3, 510, __pyx_L1_error)
15445     __Pyx_GOTREF(__pyx_t_6);
15446     __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
15447     __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
15448     __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)
15449     __Pyx_GOTREF(__pyx_t_4);
15450     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
15451     __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
15452     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)
15453     __pyx_v_bytesvalue = ((PyObject*)__pyx_t_4);
15454     __pyx_t_4 = 0;
15455 
15456     /* "View.MemoryView":509
15457  *         cdef Py_ssize_t i
15458  *
15459  *         if isinstance(value, tuple):             # <<<<<<<<<<<<<<
15460  *             bytesvalue = struct.pack(self.view.format, *value)
15461  *         else:
15462  */
15463     goto __pyx_L3;
15464   }
15465 
15466   /* "View.MemoryView":512
15467  *             bytesvalue = struct.pack(self.view.format, *value)
15468  *         else:
15469  *             bytesvalue = struct.pack(self.view.format, value)             # <<<<<<<<<<<<<<
15470  *
15471  *         for i, c in enumerate(bytesvalue):
15472  */
15473   /*else*/ {
15474     __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)
15475     __Pyx_GOTREF(__pyx_t_6);
15476     __pyx_t_1 = __Pyx_PyBytes_FromString(__pyx_v_self->view.format); if (unlikely(!__pyx_t_1)) __PYX_ERR(3, 512, __pyx_L1_error)
15477     __Pyx_GOTREF(__pyx_t_1);
15478     __pyx_t_5 = NULL;
15479     __pyx_t_7 = 0;
15480     if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_6))) {
15481       __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_6);
15482       if (likely(__pyx_t_5)) {
15483         PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
15484         __Pyx_INCREF(__pyx_t_5);
15485         __Pyx_INCREF(function);
15486         __Pyx_DECREF_SET(__pyx_t_6, function);
15487         __pyx_t_7 = 1;
15488       }
15489     }
15490     #if CYTHON_FAST_PYCALL
15491     if (PyFunction_Check(__pyx_t_6)) {
15492       PyObject *__pyx_temp[3] = {__pyx_t_5, __pyx_t_1, __pyx_v_value};
15493       __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)
15494       __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
15495       __Pyx_GOTREF(__pyx_t_4);
15496       __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
15497     } else
15498     #endif
15499     #if CYTHON_FAST_PYCCALL
15500     if (__Pyx_PyFastCFunction_Check(__pyx_t_6)) {
15501       PyObject *__pyx_temp[3] = {__pyx_t_5, __pyx_t_1, __pyx_v_value};
15502       __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)
15503       __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
15504       __Pyx_GOTREF(__pyx_t_4);
15505       __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
15506     } else
15507     #endif
15508     {
15509       __pyx_t_8 = PyTuple_New(2+__pyx_t_7); if (unlikely(!__pyx_t_8)) __PYX_ERR(3, 512, __pyx_L1_error)
15510       __Pyx_GOTREF(__pyx_t_8);
15511       if (__pyx_t_5) {
15512         __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_5); __pyx_t_5 = NULL;
15513       }
15514       __Pyx_GIVEREF(__pyx_t_1);
15515       PyTuple_SET_ITEM(__pyx_t_8, 0+__pyx_t_7, __pyx_t_1);
15516       __Pyx_INCREF(__pyx_v_value);
15517       __Pyx_GIVEREF(__pyx_v_value);
15518       PyTuple_SET_ITEM(__pyx_t_8, 1+__pyx_t_7, __pyx_v_value);
15519       __pyx_t_1 = 0;
15520       __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)
15521       __Pyx_GOTREF(__pyx_t_4);
15522       __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
15523     }
15524     __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
15525     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)
15526     __pyx_v_bytesvalue = ((PyObject*)__pyx_t_4);
15527     __pyx_t_4 = 0;
15528   }
15529   __pyx_L3:;
15530 
15531   /* "View.MemoryView":514
15532  *             bytesvalue = struct.pack(self.view.format, value)
15533  *
15534  *         for i, c in enumerate(bytesvalue):             # <<<<<<<<<<<<<<
15535  *             itemp[i] = c
15536  *
15537  */
15538   __pyx_t_9 = 0;
15539   if (unlikely(__pyx_v_bytesvalue == Py_None)) {
15540     PyErr_SetString(PyExc_TypeError, "'NoneType' is not iterable");
15541     __PYX_ERR(3, 514, __pyx_L1_error)
15542   }
15543   __Pyx_INCREF(__pyx_v_bytesvalue);
15544   __pyx_t_10 = __pyx_v_bytesvalue;
15545   __pyx_t_12 = PyBytes_AS_STRING(__pyx_t_10);
15546   __pyx_t_13 = (__pyx_t_12 + PyBytes_GET_SIZE(__pyx_t_10));
15547   for (__pyx_t_14 = __pyx_t_12; __pyx_t_14 < __pyx_t_13; __pyx_t_14++) {
15548     __pyx_t_11 = __pyx_t_14;
15549     __pyx_v_c = (__pyx_t_11[0]);
15550 
15551     /* "View.MemoryView":515
15552  *
15553  *         for i, c in enumerate(bytesvalue):
15554  *             itemp[i] = c             # <<<<<<<<<<<<<<
15555  *
15556  *     @cname('getbuffer')
15557  */
15558     __pyx_v_i = __pyx_t_9;
15559 
15560     /* "View.MemoryView":514
15561  *             bytesvalue = struct.pack(self.view.format, value)
15562  *
15563  *         for i, c in enumerate(bytesvalue):             # <<<<<<<<<<<<<<
15564  *             itemp[i] = c
15565  *
15566  */
15567     __pyx_t_9 = (__pyx_t_9 + 1);
15568 
15569     /* "View.MemoryView":515
15570  *
15571  *         for i, c in enumerate(bytesvalue):
15572  *             itemp[i] = c             # <<<<<<<<<<<<<<
15573  *
15574  *     @cname('getbuffer')
15575  */
15576     (__pyx_v_itemp[__pyx_v_i]) = __pyx_v_c;
15577   }
15578   __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
15579 
15580   /* "View.MemoryView":501
15581  *             return result
15582  *
15583  *     cdef assign_item_from_object(self, char *itemp, object value):             # <<<<<<<<<<<<<<
15584  *         """Only used if instantiated manually by the user, or if Cython doesn't
15585  *         know how to convert the type"""
15586  */
15587 
15588   /* function exit code */
15589   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
15590   goto __pyx_L0;
15591   __pyx_L1_error:;
15592   __Pyx_XDECREF(__pyx_t_1);
15593   __Pyx_XDECREF(__pyx_t_4);
15594   __Pyx_XDECREF(__pyx_t_5);
15595   __Pyx_XDECREF(__pyx_t_6);
15596   __Pyx_XDECREF(__pyx_t_8);
15597   __Pyx_XDECREF(__pyx_t_10);
15598   __Pyx_AddTraceback("View.MemoryView.memoryview.assign_item_from_object", __pyx_clineno, __pyx_lineno, __pyx_filename);
15599   __pyx_r = 0;
15600   __pyx_L0:;
15601   __Pyx_XDECREF(__pyx_v_struct);
15602   __Pyx_XDECREF(__pyx_v_bytesvalue);
15603   __Pyx_XGIVEREF(__pyx_r);
15604   __Pyx_RefNannyFinishContext();
15605   return __pyx_r;
15606 }
15607 
15608 /* "View.MemoryView":518
15609  *
15610  *     @cname('getbuffer')
15611  *     def __getbuffer__(self, Py_buffer *info, int flags):             # <<<<<<<<<<<<<<
15612  *         if flags & PyBUF_WRITABLE and self.view.readonly:
15613  *             raise ValueError("Cannot create writable memory view from read-only memoryview")
15614  */
15615 
15616 /* Python wrapper */
15617 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)15618 static CYTHON_UNUSED int __pyx_memoryview_getbuffer(PyObject *__pyx_v_self, Py_buffer *__pyx_v_info, int __pyx_v_flags) {
15619   int __pyx_r;
15620   __Pyx_RefNannyDeclarations
15621   __Pyx_RefNannySetupContext("__getbuffer__ (wrapper)", 0);
15622   __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));
15623 
15624   /* function exit code */
15625   __Pyx_RefNannyFinishContext();
15626   return __pyx_r;
15627 }
15628 
__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)15629 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) {
15630   int __pyx_r;
15631   __Pyx_RefNannyDeclarations
15632   int __pyx_t_1;
15633   int __pyx_t_2;
15634   PyObject *__pyx_t_3 = NULL;
15635   Py_ssize_t *__pyx_t_4;
15636   char *__pyx_t_5;
15637   void *__pyx_t_6;
15638   int __pyx_t_7;
15639   Py_ssize_t __pyx_t_8;
15640   int __pyx_lineno = 0;
15641   const char *__pyx_filename = NULL;
15642   int __pyx_clineno = 0;
15643   if (__pyx_v_info == NULL) {
15644     PyErr_SetString(PyExc_BufferError, "PyObject_GetBuffer: view==NULL argument is obsolete");
15645     return -1;
15646   }
15647   __Pyx_RefNannySetupContext("__getbuffer__", 0);
15648   __pyx_v_info->obj = Py_None; __Pyx_INCREF(Py_None);
15649   __Pyx_GIVEREF(__pyx_v_info->obj);
15650 
15651   /* "View.MemoryView":519
15652  *     @cname('getbuffer')
15653  *     def __getbuffer__(self, Py_buffer *info, int flags):
15654  *         if flags & PyBUF_WRITABLE and self.view.readonly:             # <<<<<<<<<<<<<<
15655  *             raise ValueError("Cannot create writable memory view from read-only memoryview")
15656  *
15657  */
15658   __pyx_t_2 = ((__pyx_v_flags & PyBUF_WRITABLE) != 0);
15659   if (__pyx_t_2) {
15660   } else {
15661     __pyx_t_1 = __pyx_t_2;
15662     goto __pyx_L4_bool_binop_done;
15663   }
15664   __pyx_t_2 = (__pyx_v_self->view.readonly != 0);
15665   __pyx_t_1 = __pyx_t_2;
15666   __pyx_L4_bool_binop_done:;
15667   if (unlikely(__pyx_t_1)) {
15668 
15669     /* "View.MemoryView":520
15670  *     def __getbuffer__(self, Py_buffer *info, int flags):
15671  *         if flags & PyBUF_WRITABLE and self.view.readonly:
15672  *             raise ValueError("Cannot create writable memory view from read-only memoryview")             # <<<<<<<<<<<<<<
15673  *
15674  *         if flags & PyBUF_ND:
15675  */
15676     __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__28, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(3, 520, __pyx_L1_error)
15677     __Pyx_GOTREF(__pyx_t_3);
15678     __Pyx_Raise(__pyx_t_3, 0, 0, 0);
15679     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
15680     __PYX_ERR(3, 520, __pyx_L1_error)
15681 
15682     /* "View.MemoryView":519
15683  *     @cname('getbuffer')
15684  *     def __getbuffer__(self, Py_buffer *info, int flags):
15685  *         if flags & PyBUF_WRITABLE and self.view.readonly:             # <<<<<<<<<<<<<<
15686  *             raise ValueError("Cannot create writable memory view from read-only memoryview")
15687  *
15688  */
15689   }
15690 
15691   /* "View.MemoryView":522
15692  *             raise ValueError("Cannot create writable memory view from read-only memoryview")
15693  *
15694  *         if flags & PyBUF_ND:             # <<<<<<<<<<<<<<
15695  *             info.shape = self.view.shape
15696  *         else:
15697  */
15698   __pyx_t_1 = ((__pyx_v_flags & PyBUF_ND) != 0);
15699   if (__pyx_t_1) {
15700 
15701     /* "View.MemoryView":523
15702  *
15703  *         if flags & PyBUF_ND:
15704  *             info.shape = self.view.shape             # <<<<<<<<<<<<<<
15705  *         else:
15706  *             info.shape = NULL
15707  */
15708     __pyx_t_4 = __pyx_v_self->view.shape;
15709     __pyx_v_info->shape = __pyx_t_4;
15710 
15711     /* "View.MemoryView":522
15712  *             raise ValueError("Cannot create writable memory view from read-only memoryview")
15713  *
15714  *         if flags & PyBUF_ND:             # <<<<<<<<<<<<<<
15715  *             info.shape = self.view.shape
15716  *         else:
15717  */
15718     goto __pyx_L6;
15719   }
15720 
15721   /* "View.MemoryView":525
15722  *             info.shape = self.view.shape
15723  *         else:
15724  *             info.shape = NULL             # <<<<<<<<<<<<<<
15725  *
15726  *         if flags & PyBUF_STRIDES:
15727  */
15728   /*else*/ {
15729     __pyx_v_info->shape = NULL;
15730   }
15731   __pyx_L6:;
15732 
15733   /* "View.MemoryView":527
15734  *             info.shape = NULL
15735  *
15736  *         if flags & PyBUF_STRIDES:             # <<<<<<<<<<<<<<
15737  *             info.strides = self.view.strides
15738  *         else:
15739  */
15740   __pyx_t_1 = ((__pyx_v_flags & PyBUF_STRIDES) != 0);
15741   if (__pyx_t_1) {
15742 
15743     /* "View.MemoryView":528
15744  *
15745  *         if flags & PyBUF_STRIDES:
15746  *             info.strides = self.view.strides             # <<<<<<<<<<<<<<
15747  *         else:
15748  *             info.strides = NULL
15749  */
15750     __pyx_t_4 = __pyx_v_self->view.strides;
15751     __pyx_v_info->strides = __pyx_t_4;
15752 
15753     /* "View.MemoryView":527
15754  *             info.shape = NULL
15755  *
15756  *         if flags & PyBUF_STRIDES:             # <<<<<<<<<<<<<<
15757  *             info.strides = self.view.strides
15758  *         else:
15759  */
15760     goto __pyx_L7;
15761   }
15762 
15763   /* "View.MemoryView":530
15764  *             info.strides = self.view.strides
15765  *         else:
15766  *             info.strides = NULL             # <<<<<<<<<<<<<<
15767  *
15768  *         if flags & PyBUF_INDIRECT:
15769  */
15770   /*else*/ {
15771     __pyx_v_info->strides = NULL;
15772   }
15773   __pyx_L7:;
15774 
15775   /* "View.MemoryView":532
15776  *             info.strides = NULL
15777  *
15778  *         if flags & PyBUF_INDIRECT:             # <<<<<<<<<<<<<<
15779  *             info.suboffsets = self.view.suboffsets
15780  *         else:
15781  */
15782   __pyx_t_1 = ((__pyx_v_flags & PyBUF_INDIRECT) != 0);
15783   if (__pyx_t_1) {
15784 
15785     /* "View.MemoryView":533
15786  *
15787  *         if flags & PyBUF_INDIRECT:
15788  *             info.suboffsets = self.view.suboffsets             # <<<<<<<<<<<<<<
15789  *         else:
15790  *             info.suboffsets = NULL
15791  */
15792     __pyx_t_4 = __pyx_v_self->view.suboffsets;
15793     __pyx_v_info->suboffsets = __pyx_t_4;
15794 
15795     /* "View.MemoryView":532
15796  *             info.strides = NULL
15797  *
15798  *         if flags & PyBUF_INDIRECT:             # <<<<<<<<<<<<<<
15799  *             info.suboffsets = self.view.suboffsets
15800  *         else:
15801  */
15802     goto __pyx_L8;
15803   }
15804 
15805   /* "View.MemoryView":535
15806  *             info.suboffsets = self.view.suboffsets
15807  *         else:
15808  *             info.suboffsets = NULL             # <<<<<<<<<<<<<<
15809  *
15810  *         if flags & PyBUF_FORMAT:
15811  */
15812   /*else*/ {
15813     __pyx_v_info->suboffsets = NULL;
15814   }
15815   __pyx_L8:;
15816 
15817   /* "View.MemoryView":537
15818  *             info.suboffsets = NULL
15819  *
15820  *         if flags & PyBUF_FORMAT:             # <<<<<<<<<<<<<<
15821  *             info.format = self.view.format
15822  *         else:
15823  */
15824   __pyx_t_1 = ((__pyx_v_flags & PyBUF_FORMAT) != 0);
15825   if (__pyx_t_1) {
15826 
15827     /* "View.MemoryView":538
15828  *
15829  *         if flags & PyBUF_FORMAT:
15830  *             info.format = self.view.format             # <<<<<<<<<<<<<<
15831  *         else:
15832  *             info.format = NULL
15833  */
15834     __pyx_t_5 = __pyx_v_self->view.format;
15835     __pyx_v_info->format = __pyx_t_5;
15836 
15837     /* "View.MemoryView":537
15838  *             info.suboffsets = NULL
15839  *
15840  *         if flags & PyBUF_FORMAT:             # <<<<<<<<<<<<<<
15841  *             info.format = self.view.format
15842  *         else:
15843  */
15844     goto __pyx_L9;
15845   }
15846 
15847   /* "View.MemoryView":540
15848  *             info.format = self.view.format
15849  *         else:
15850  *             info.format = NULL             # <<<<<<<<<<<<<<
15851  *
15852  *         info.buf = self.view.buf
15853  */
15854   /*else*/ {
15855     __pyx_v_info->format = NULL;
15856   }
15857   __pyx_L9:;
15858 
15859   /* "View.MemoryView":542
15860  *             info.format = NULL
15861  *
15862  *         info.buf = self.view.buf             # <<<<<<<<<<<<<<
15863  *         info.ndim = self.view.ndim
15864  *         info.itemsize = self.view.itemsize
15865  */
15866   __pyx_t_6 = __pyx_v_self->view.buf;
15867   __pyx_v_info->buf = __pyx_t_6;
15868 
15869   /* "View.MemoryView":543
15870  *
15871  *         info.buf = self.view.buf
15872  *         info.ndim = self.view.ndim             # <<<<<<<<<<<<<<
15873  *         info.itemsize = self.view.itemsize
15874  *         info.len = self.view.len
15875  */
15876   __pyx_t_7 = __pyx_v_self->view.ndim;
15877   __pyx_v_info->ndim = __pyx_t_7;
15878 
15879   /* "View.MemoryView":544
15880  *         info.buf = self.view.buf
15881  *         info.ndim = self.view.ndim
15882  *         info.itemsize = self.view.itemsize             # <<<<<<<<<<<<<<
15883  *         info.len = self.view.len
15884  *         info.readonly = self.view.readonly
15885  */
15886   __pyx_t_8 = __pyx_v_self->view.itemsize;
15887   __pyx_v_info->itemsize = __pyx_t_8;
15888 
15889   /* "View.MemoryView":545
15890  *         info.ndim = self.view.ndim
15891  *         info.itemsize = self.view.itemsize
15892  *         info.len = self.view.len             # <<<<<<<<<<<<<<
15893  *         info.readonly = self.view.readonly
15894  *         info.obj = self
15895  */
15896   __pyx_t_8 = __pyx_v_self->view.len;
15897   __pyx_v_info->len = __pyx_t_8;
15898 
15899   /* "View.MemoryView":546
15900  *         info.itemsize = self.view.itemsize
15901  *         info.len = self.view.len
15902  *         info.readonly = self.view.readonly             # <<<<<<<<<<<<<<
15903  *         info.obj = self
15904  *
15905  */
15906   __pyx_t_1 = __pyx_v_self->view.readonly;
15907   __pyx_v_info->readonly = __pyx_t_1;
15908 
15909   /* "View.MemoryView":547
15910  *         info.len = self.view.len
15911  *         info.readonly = self.view.readonly
15912  *         info.obj = self             # <<<<<<<<<<<<<<
15913  *
15914  *     __pyx_getbuffer = capsule(<void *> &__pyx_memoryview_getbuffer, "getbuffer(obj, view, flags)")
15915  */
15916   __Pyx_INCREF(((PyObject *)__pyx_v_self));
15917   __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
15918   __Pyx_GOTREF(__pyx_v_info->obj);
15919   __Pyx_DECREF(__pyx_v_info->obj);
15920   __pyx_v_info->obj = ((PyObject *)__pyx_v_self);
15921 
15922   /* "View.MemoryView":518
15923  *
15924  *     @cname('getbuffer')
15925  *     def __getbuffer__(self, Py_buffer *info, int flags):             # <<<<<<<<<<<<<<
15926  *         if flags & PyBUF_WRITABLE and self.view.readonly:
15927  *             raise ValueError("Cannot create writable memory view from read-only memoryview")
15928  */
15929 
15930   /* function exit code */
15931   __pyx_r = 0;
15932   goto __pyx_L0;
15933   __pyx_L1_error:;
15934   __Pyx_XDECREF(__pyx_t_3);
15935   __Pyx_AddTraceback("View.MemoryView.memoryview.__getbuffer__", __pyx_clineno, __pyx_lineno, __pyx_filename);
15936   __pyx_r = -1;
15937   if (__pyx_v_info->obj != NULL) {
15938     __Pyx_GOTREF(__pyx_v_info->obj);
15939     __Pyx_DECREF(__pyx_v_info->obj); __pyx_v_info->obj = 0;
15940   }
15941   goto __pyx_L2;
15942   __pyx_L0:;
15943   if (__pyx_v_info->obj == Py_None) {
15944     __Pyx_GOTREF(__pyx_v_info->obj);
15945     __Pyx_DECREF(__pyx_v_info->obj); __pyx_v_info->obj = 0;
15946   }
15947   __pyx_L2:;
15948   __Pyx_RefNannyFinishContext();
15949   return __pyx_r;
15950 }
15951 
15952 /* "View.MemoryView":553
15953  *
15954  *     @property
15955  *     def T(self):             # <<<<<<<<<<<<<<
15956  *         cdef _memoryviewslice result = memoryview_copy(self)
15957  *         transpose_memslice(&result.from_slice)
15958  */
15959 
15960 /* Python wrapper */
15961 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)15962 static PyObject *__pyx_pw_15View_dot_MemoryView_10memoryview_1T_1__get__(PyObject *__pyx_v_self) {
15963   PyObject *__pyx_r = 0;
15964   __Pyx_RefNannyDeclarations
15965   __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
15966   __pyx_r = __pyx_pf_15View_dot_MemoryView_10memoryview_1T___get__(((struct __pyx_memoryview_obj *)__pyx_v_self));
15967 
15968   /* function exit code */
15969   __Pyx_RefNannyFinishContext();
15970   return __pyx_r;
15971 }
15972 
__pyx_pf_15View_dot_MemoryView_10memoryview_1T___get__(struct __pyx_memoryview_obj * __pyx_v_self)15973 static PyObject *__pyx_pf_15View_dot_MemoryView_10memoryview_1T___get__(struct __pyx_memoryview_obj *__pyx_v_self) {
15974   struct __pyx_memoryviewslice_obj *__pyx_v_result = 0;
15975   PyObject *__pyx_r = NULL;
15976   __Pyx_RefNannyDeclarations
15977   PyObject *__pyx_t_1 = NULL;
15978   int __pyx_t_2;
15979   int __pyx_lineno = 0;
15980   const char *__pyx_filename = NULL;
15981   int __pyx_clineno = 0;
15982   __Pyx_RefNannySetupContext("__get__", 0);
15983 
15984   /* "View.MemoryView":554
15985  *     @property
15986  *     def T(self):
15987  *         cdef _memoryviewslice result = memoryview_copy(self)             # <<<<<<<<<<<<<<
15988  *         transpose_memslice(&result.from_slice)
15989  *         return result
15990  */
15991   __pyx_t_1 = __pyx_memoryview_copy_object(__pyx_v_self); if (unlikely(!__pyx_t_1)) __PYX_ERR(3, 554, __pyx_L1_error)
15992   __Pyx_GOTREF(__pyx_t_1);
15993   if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_memoryviewslice_type))))) __PYX_ERR(3, 554, __pyx_L1_error)
15994   __pyx_v_result = ((struct __pyx_memoryviewslice_obj *)__pyx_t_1);
15995   __pyx_t_1 = 0;
15996 
15997   /* "View.MemoryView":555
15998  *     def T(self):
15999  *         cdef _memoryviewslice result = memoryview_copy(self)
16000  *         transpose_memslice(&result.from_slice)             # <<<<<<<<<<<<<<
16001  *         return result
16002  *
16003  */
16004   __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)
16005 
16006   /* "View.MemoryView":556
16007  *         cdef _memoryviewslice result = memoryview_copy(self)
16008  *         transpose_memslice(&result.from_slice)
16009  *         return result             # <<<<<<<<<<<<<<
16010  *
16011  *     @property
16012  */
16013   __Pyx_XDECREF(__pyx_r);
16014   __Pyx_INCREF(((PyObject *)__pyx_v_result));
16015   __pyx_r = ((PyObject *)__pyx_v_result);
16016   goto __pyx_L0;
16017 
16018   /* "View.MemoryView":553
16019  *
16020  *     @property
16021  *     def T(self):             # <<<<<<<<<<<<<<
16022  *         cdef _memoryviewslice result = memoryview_copy(self)
16023  *         transpose_memslice(&result.from_slice)
16024  */
16025 
16026   /* function exit code */
16027   __pyx_L1_error:;
16028   __Pyx_XDECREF(__pyx_t_1);
16029   __Pyx_AddTraceback("View.MemoryView.memoryview.T.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
16030   __pyx_r = NULL;
16031   __pyx_L0:;
16032   __Pyx_XDECREF((PyObject *)__pyx_v_result);
16033   __Pyx_XGIVEREF(__pyx_r);
16034   __Pyx_RefNannyFinishContext();
16035   return __pyx_r;
16036 }
16037 
16038 /* "View.MemoryView":559
16039  *
16040  *     @property
16041  *     def base(self):             # <<<<<<<<<<<<<<
16042  *         return self.obj
16043  *
16044  */
16045 
16046 /* Python wrapper */
16047 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)16048 static PyObject *__pyx_pw_15View_dot_MemoryView_10memoryview_4base_1__get__(PyObject *__pyx_v_self) {
16049   PyObject *__pyx_r = 0;
16050   __Pyx_RefNannyDeclarations
16051   __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
16052   __pyx_r = __pyx_pf_15View_dot_MemoryView_10memoryview_4base___get__(((struct __pyx_memoryview_obj *)__pyx_v_self));
16053 
16054   /* function exit code */
16055   __Pyx_RefNannyFinishContext();
16056   return __pyx_r;
16057 }
16058 
__pyx_pf_15View_dot_MemoryView_10memoryview_4base___get__(struct __pyx_memoryview_obj * __pyx_v_self)16059 static PyObject *__pyx_pf_15View_dot_MemoryView_10memoryview_4base___get__(struct __pyx_memoryview_obj *__pyx_v_self) {
16060   PyObject *__pyx_r = NULL;
16061   __Pyx_RefNannyDeclarations
16062   __Pyx_RefNannySetupContext("__get__", 0);
16063 
16064   /* "View.MemoryView":560
16065  *     @property
16066  *     def base(self):
16067  *         return self.obj             # <<<<<<<<<<<<<<
16068  *
16069  *     @property
16070  */
16071   __Pyx_XDECREF(__pyx_r);
16072   __Pyx_INCREF(__pyx_v_self->obj);
16073   __pyx_r = __pyx_v_self->obj;
16074   goto __pyx_L0;
16075 
16076   /* "View.MemoryView":559
16077  *
16078  *     @property
16079  *     def base(self):             # <<<<<<<<<<<<<<
16080  *         return self.obj
16081  *
16082  */
16083 
16084   /* function exit code */
16085   __pyx_L0:;
16086   __Pyx_XGIVEREF(__pyx_r);
16087   __Pyx_RefNannyFinishContext();
16088   return __pyx_r;
16089 }
16090 
16091 /* "View.MemoryView":563
16092  *
16093  *     @property
16094  *     def shape(self):             # <<<<<<<<<<<<<<
16095  *         return tuple([length for length in self.view.shape[:self.view.ndim]])
16096  *
16097  */
16098 
16099 /* Python wrapper */
16100 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)16101 static PyObject *__pyx_pw_15View_dot_MemoryView_10memoryview_5shape_1__get__(PyObject *__pyx_v_self) {
16102   PyObject *__pyx_r = 0;
16103   __Pyx_RefNannyDeclarations
16104   __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
16105   __pyx_r = __pyx_pf_15View_dot_MemoryView_10memoryview_5shape___get__(((struct __pyx_memoryview_obj *)__pyx_v_self));
16106 
16107   /* function exit code */
16108   __Pyx_RefNannyFinishContext();
16109   return __pyx_r;
16110 }
16111 
__pyx_pf_15View_dot_MemoryView_10memoryview_5shape___get__(struct __pyx_memoryview_obj * __pyx_v_self)16112 static PyObject *__pyx_pf_15View_dot_MemoryView_10memoryview_5shape___get__(struct __pyx_memoryview_obj *__pyx_v_self) {
16113   Py_ssize_t __pyx_v_length;
16114   PyObject *__pyx_r = NULL;
16115   __Pyx_RefNannyDeclarations
16116   PyObject *__pyx_t_1 = NULL;
16117   Py_ssize_t *__pyx_t_2;
16118   Py_ssize_t *__pyx_t_3;
16119   Py_ssize_t *__pyx_t_4;
16120   PyObject *__pyx_t_5 = NULL;
16121   int __pyx_lineno = 0;
16122   const char *__pyx_filename = NULL;
16123   int __pyx_clineno = 0;
16124   __Pyx_RefNannySetupContext("__get__", 0);
16125 
16126   /* "View.MemoryView":564
16127  *     @property
16128  *     def shape(self):
16129  *         return tuple([length for length in self.view.shape[:self.view.ndim]])             # <<<<<<<<<<<<<<
16130  *
16131  *     @property
16132  */
16133   __Pyx_XDECREF(__pyx_r);
16134   __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(3, 564, __pyx_L1_error)
16135   __Pyx_GOTREF(__pyx_t_1);
16136   __pyx_t_3 = (__pyx_v_self->view.shape + __pyx_v_self->view.ndim);
16137   for (__pyx_t_4 = __pyx_v_self->view.shape; __pyx_t_4 < __pyx_t_3; __pyx_t_4++) {
16138     __pyx_t_2 = __pyx_t_4;
16139     __pyx_v_length = (__pyx_t_2[0]);
16140     __pyx_t_5 = PyInt_FromSsize_t(__pyx_v_length); if (unlikely(!__pyx_t_5)) __PYX_ERR(3, 564, __pyx_L1_error)
16141     __Pyx_GOTREF(__pyx_t_5);
16142     if (unlikely(__Pyx_ListComp_Append(__pyx_t_1, (PyObject*)__pyx_t_5))) __PYX_ERR(3, 564, __pyx_L1_error)
16143     __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
16144   }
16145   __pyx_t_5 = PyList_AsTuple(((PyObject*)__pyx_t_1)); if (unlikely(!__pyx_t_5)) __PYX_ERR(3, 564, __pyx_L1_error)
16146   __Pyx_GOTREF(__pyx_t_5);
16147   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
16148   __pyx_r = __pyx_t_5;
16149   __pyx_t_5 = 0;
16150   goto __pyx_L0;
16151 
16152   /* "View.MemoryView":563
16153  *
16154  *     @property
16155  *     def shape(self):             # <<<<<<<<<<<<<<
16156  *         return tuple([length for length in self.view.shape[:self.view.ndim]])
16157  *
16158  */
16159 
16160   /* function exit code */
16161   __pyx_L1_error:;
16162   __Pyx_XDECREF(__pyx_t_1);
16163   __Pyx_XDECREF(__pyx_t_5);
16164   __Pyx_AddTraceback("View.MemoryView.memoryview.shape.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
16165   __pyx_r = NULL;
16166   __pyx_L0:;
16167   __Pyx_XGIVEREF(__pyx_r);
16168   __Pyx_RefNannyFinishContext();
16169   return __pyx_r;
16170 }
16171 
16172 /* "View.MemoryView":567
16173  *
16174  *     @property
16175  *     def strides(self):             # <<<<<<<<<<<<<<
16176  *         if self.view.strides == NULL:
16177  *
16178  */
16179 
16180 /* Python wrapper */
16181 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)16182 static PyObject *__pyx_pw_15View_dot_MemoryView_10memoryview_7strides_1__get__(PyObject *__pyx_v_self) {
16183   PyObject *__pyx_r = 0;
16184   __Pyx_RefNannyDeclarations
16185   __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
16186   __pyx_r = __pyx_pf_15View_dot_MemoryView_10memoryview_7strides___get__(((struct __pyx_memoryview_obj *)__pyx_v_self));
16187 
16188   /* function exit code */
16189   __Pyx_RefNannyFinishContext();
16190   return __pyx_r;
16191 }
16192 
__pyx_pf_15View_dot_MemoryView_10memoryview_7strides___get__(struct __pyx_memoryview_obj * __pyx_v_self)16193 static PyObject *__pyx_pf_15View_dot_MemoryView_10memoryview_7strides___get__(struct __pyx_memoryview_obj *__pyx_v_self) {
16194   Py_ssize_t __pyx_v_stride;
16195   PyObject *__pyx_r = NULL;
16196   __Pyx_RefNannyDeclarations
16197   int __pyx_t_1;
16198   PyObject *__pyx_t_2 = NULL;
16199   Py_ssize_t *__pyx_t_3;
16200   Py_ssize_t *__pyx_t_4;
16201   Py_ssize_t *__pyx_t_5;
16202   PyObject *__pyx_t_6 = NULL;
16203   int __pyx_lineno = 0;
16204   const char *__pyx_filename = NULL;
16205   int __pyx_clineno = 0;
16206   __Pyx_RefNannySetupContext("__get__", 0);
16207 
16208   /* "View.MemoryView":568
16209  *     @property
16210  *     def strides(self):
16211  *         if self.view.strides == NULL:             # <<<<<<<<<<<<<<
16212  *
16213  *             raise ValueError("Buffer view does not expose strides")
16214  */
16215   __pyx_t_1 = ((__pyx_v_self->view.strides == NULL) != 0);
16216   if (unlikely(__pyx_t_1)) {
16217 
16218     /* "View.MemoryView":570
16219  *         if self.view.strides == NULL:
16220  *
16221  *             raise ValueError("Buffer view does not expose strides")             # <<<<<<<<<<<<<<
16222  *
16223  *         return tuple([stride for stride in self.view.strides[:self.view.ndim]])
16224  */
16225     __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__29, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(3, 570, __pyx_L1_error)
16226     __Pyx_GOTREF(__pyx_t_2);
16227     __Pyx_Raise(__pyx_t_2, 0, 0, 0);
16228     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
16229     __PYX_ERR(3, 570, __pyx_L1_error)
16230 
16231     /* "View.MemoryView":568
16232  *     @property
16233  *     def strides(self):
16234  *         if self.view.strides == NULL:             # <<<<<<<<<<<<<<
16235  *
16236  *             raise ValueError("Buffer view does not expose strides")
16237  */
16238   }
16239 
16240   /* "View.MemoryView":572
16241  *             raise ValueError("Buffer view does not expose strides")
16242  *
16243  *         return tuple([stride for stride in self.view.strides[:self.view.ndim]])             # <<<<<<<<<<<<<<
16244  *
16245  *     @property
16246  */
16247   __Pyx_XDECREF(__pyx_r);
16248   __pyx_t_2 = PyList_New(0); if (unlikely(!__pyx_t_2)) __PYX_ERR(3, 572, __pyx_L1_error)
16249   __Pyx_GOTREF(__pyx_t_2);
16250   __pyx_t_4 = (__pyx_v_self->view.strides + __pyx_v_self->view.ndim);
16251   for (__pyx_t_5 = __pyx_v_self->view.strides; __pyx_t_5 < __pyx_t_4; __pyx_t_5++) {
16252     __pyx_t_3 = __pyx_t_5;
16253     __pyx_v_stride = (__pyx_t_3[0]);
16254     __pyx_t_6 = PyInt_FromSsize_t(__pyx_v_stride); if (unlikely(!__pyx_t_6)) __PYX_ERR(3, 572, __pyx_L1_error)
16255     __Pyx_GOTREF(__pyx_t_6);
16256     if (unlikely(__Pyx_ListComp_Append(__pyx_t_2, (PyObject*)__pyx_t_6))) __PYX_ERR(3, 572, __pyx_L1_error)
16257     __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
16258   }
16259   __pyx_t_6 = PyList_AsTuple(((PyObject*)__pyx_t_2)); if (unlikely(!__pyx_t_6)) __PYX_ERR(3, 572, __pyx_L1_error)
16260   __Pyx_GOTREF(__pyx_t_6);
16261   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
16262   __pyx_r = __pyx_t_6;
16263   __pyx_t_6 = 0;
16264   goto __pyx_L0;
16265 
16266   /* "View.MemoryView":567
16267  *
16268  *     @property
16269  *     def strides(self):             # <<<<<<<<<<<<<<
16270  *         if self.view.strides == NULL:
16271  *
16272  */
16273 
16274   /* function exit code */
16275   __pyx_L1_error:;
16276   __Pyx_XDECREF(__pyx_t_2);
16277   __Pyx_XDECREF(__pyx_t_6);
16278   __Pyx_AddTraceback("View.MemoryView.memoryview.strides.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
16279   __pyx_r = NULL;
16280   __pyx_L0:;
16281   __Pyx_XGIVEREF(__pyx_r);
16282   __Pyx_RefNannyFinishContext();
16283   return __pyx_r;
16284 }
16285 
16286 /* "View.MemoryView":575
16287  *
16288  *     @property
16289  *     def suboffsets(self):             # <<<<<<<<<<<<<<
16290  *         if self.view.suboffsets == NULL:
16291  *             return (-1,) * self.view.ndim
16292  */
16293 
16294 /* Python wrapper */
16295 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)16296 static PyObject *__pyx_pw_15View_dot_MemoryView_10memoryview_10suboffsets_1__get__(PyObject *__pyx_v_self) {
16297   PyObject *__pyx_r = 0;
16298   __Pyx_RefNannyDeclarations
16299   __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
16300   __pyx_r = __pyx_pf_15View_dot_MemoryView_10memoryview_10suboffsets___get__(((struct __pyx_memoryview_obj *)__pyx_v_self));
16301 
16302   /* function exit code */
16303   __Pyx_RefNannyFinishContext();
16304   return __pyx_r;
16305 }
16306 
__pyx_pf_15View_dot_MemoryView_10memoryview_10suboffsets___get__(struct __pyx_memoryview_obj * __pyx_v_self)16307 static PyObject *__pyx_pf_15View_dot_MemoryView_10memoryview_10suboffsets___get__(struct __pyx_memoryview_obj *__pyx_v_self) {
16308   Py_ssize_t __pyx_v_suboffset;
16309   PyObject *__pyx_r = NULL;
16310   __Pyx_RefNannyDeclarations
16311   int __pyx_t_1;
16312   PyObject *__pyx_t_2 = NULL;
16313   PyObject *__pyx_t_3 = NULL;
16314   Py_ssize_t *__pyx_t_4;
16315   Py_ssize_t *__pyx_t_5;
16316   Py_ssize_t *__pyx_t_6;
16317   int __pyx_lineno = 0;
16318   const char *__pyx_filename = NULL;
16319   int __pyx_clineno = 0;
16320   __Pyx_RefNannySetupContext("__get__", 0);
16321 
16322   /* "View.MemoryView":576
16323  *     @property
16324  *     def suboffsets(self):
16325  *         if self.view.suboffsets == NULL:             # <<<<<<<<<<<<<<
16326  *             return (-1,) * self.view.ndim
16327  *
16328  */
16329   __pyx_t_1 = ((__pyx_v_self->view.suboffsets == NULL) != 0);
16330   if (__pyx_t_1) {
16331 
16332     /* "View.MemoryView":577
16333  *     def suboffsets(self):
16334  *         if self.view.suboffsets == NULL:
16335  *             return (-1,) * self.view.ndim             # <<<<<<<<<<<<<<
16336  *
16337  *         return tuple([suboffset for suboffset in self.view.suboffsets[:self.view.ndim]])
16338  */
16339     __Pyx_XDECREF(__pyx_r);
16340     __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_self->view.ndim); if (unlikely(!__pyx_t_2)) __PYX_ERR(3, 577, __pyx_L1_error)
16341     __Pyx_GOTREF(__pyx_t_2);
16342     __pyx_t_3 = PyNumber_Multiply(__pyx_tuple__30, __pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(3, 577, __pyx_L1_error)
16343     __Pyx_GOTREF(__pyx_t_3);
16344     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
16345     __pyx_r = __pyx_t_3;
16346     __pyx_t_3 = 0;
16347     goto __pyx_L0;
16348 
16349     /* "View.MemoryView":576
16350  *     @property
16351  *     def suboffsets(self):
16352  *         if self.view.suboffsets == NULL:             # <<<<<<<<<<<<<<
16353  *             return (-1,) * self.view.ndim
16354  *
16355  */
16356   }
16357 
16358   /* "View.MemoryView":579
16359  *             return (-1,) * self.view.ndim
16360  *
16361  *         return tuple([suboffset for suboffset in self.view.suboffsets[:self.view.ndim]])             # <<<<<<<<<<<<<<
16362  *
16363  *     @property
16364  */
16365   __Pyx_XDECREF(__pyx_r);
16366   __pyx_t_3 = PyList_New(0); if (unlikely(!__pyx_t_3)) __PYX_ERR(3, 579, __pyx_L1_error)
16367   __Pyx_GOTREF(__pyx_t_3);
16368   __pyx_t_5 = (__pyx_v_self->view.suboffsets + __pyx_v_self->view.ndim);
16369   for (__pyx_t_6 = __pyx_v_self->view.suboffsets; __pyx_t_6 < __pyx_t_5; __pyx_t_6++) {
16370     __pyx_t_4 = __pyx_t_6;
16371     __pyx_v_suboffset = (__pyx_t_4[0]);
16372     __pyx_t_2 = PyInt_FromSsize_t(__pyx_v_suboffset); if (unlikely(!__pyx_t_2)) __PYX_ERR(3, 579, __pyx_L1_error)
16373     __Pyx_GOTREF(__pyx_t_2);
16374     if (unlikely(__Pyx_ListComp_Append(__pyx_t_3, (PyObject*)__pyx_t_2))) __PYX_ERR(3, 579, __pyx_L1_error)
16375     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
16376   }
16377   __pyx_t_2 = PyList_AsTuple(((PyObject*)__pyx_t_3)); if (unlikely(!__pyx_t_2)) __PYX_ERR(3, 579, __pyx_L1_error)
16378   __Pyx_GOTREF(__pyx_t_2);
16379   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
16380   __pyx_r = __pyx_t_2;
16381   __pyx_t_2 = 0;
16382   goto __pyx_L0;
16383 
16384   /* "View.MemoryView":575
16385  *
16386  *     @property
16387  *     def suboffsets(self):             # <<<<<<<<<<<<<<
16388  *         if self.view.suboffsets == NULL:
16389  *             return (-1,) * self.view.ndim
16390  */
16391 
16392   /* function exit code */
16393   __pyx_L1_error:;
16394   __Pyx_XDECREF(__pyx_t_2);
16395   __Pyx_XDECREF(__pyx_t_3);
16396   __Pyx_AddTraceback("View.MemoryView.memoryview.suboffsets.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
16397   __pyx_r = NULL;
16398   __pyx_L0:;
16399   __Pyx_XGIVEREF(__pyx_r);
16400   __Pyx_RefNannyFinishContext();
16401   return __pyx_r;
16402 }
16403 
16404 /* "View.MemoryView":582
16405  *
16406  *     @property
16407  *     def ndim(self):             # <<<<<<<<<<<<<<
16408  *         return self.view.ndim
16409  *
16410  */
16411 
16412 /* Python wrapper */
16413 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)16414 static PyObject *__pyx_pw_15View_dot_MemoryView_10memoryview_4ndim_1__get__(PyObject *__pyx_v_self) {
16415   PyObject *__pyx_r = 0;
16416   __Pyx_RefNannyDeclarations
16417   __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
16418   __pyx_r = __pyx_pf_15View_dot_MemoryView_10memoryview_4ndim___get__(((struct __pyx_memoryview_obj *)__pyx_v_self));
16419 
16420   /* function exit code */
16421   __Pyx_RefNannyFinishContext();
16422   return __pyx_r;
16423 }
16424 
__pyx_pf_15View_dot_MemoryView_10memoryview_4ndim___get__(struct __pyx_memoryview_obj * __pyx_v_self)16425 static PyObject *__pyx_pf_15View_dot_MemoryView_10memoryview_4ndim___get__(struct __pyx_memoryview_obj *__pyx_v_self) {
16426   PyObject *__pyx_r = NULL;
16427   __Pyx_RefNannyDeclarations
16428   PyObject *__pyx_t_1 = NULL;
16429   int __pyx_lineno = 0;
16430   const char *__pyx_filename = NULL;
16431   int __pyx_clineno = 0;
16432   __Pyx_RefNannySetupContext("__get__", 0);
16433 
16434   /* "View.MemoryView":583
16435  *     @property
16436  *     def ndim(self):
16437  *         return self.view.ndim             # <<<<<<<<<<<<<<
16438  *
16439  *     @property
16440  */
16441   __Pyx_XDECREF(__pyx_r);
16442   __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_self->view.ndim); if (unlikely(!__pyx_t_1)) __PYX_ERR(3, 583, __pyx_L1_error)
16443   __Pyx_GOTREF(__pyx_t_1);
16444   __pyx_r = __pyx_t_1;
16445   __pyx_t_1 = 0;
16446   goto __pyx_L0;
16447 
16448   /* "View.MemoryView":582
16449  *
16450  *     @property
16451  *     def ndim(self):             # <<<<<<<<<<<<<<
16452  *         return self.view.ndim
16453  *
16454  */
16455 
16456   /* function exit code */
16457   __pyx_L1_error:;
16458   __Pyx_XDECREF(__pyx_t_1);
16459   __Pyx_AddTraceback("View.MemoryView.memoryview.ndim.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
16460   __pyx_r = NULL;
16461   __pyx_L0:;
16462   __Pyx_XGIVEREF(__pyx_r);
16463   __Pyx_RefNannyFinishContext();
16464   return __pyx_r;
16465 }
16466 
16467 /* "View.MemoryView":586
16468  *
16469  *     @property
16470  *     def itemsize(self):             # <<<<<<<<<<<<<<
16471  *         return self.view.itemsize
16472  *
16473  */
16474 
16475 /* Python wrapper */
16476 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)16477 static PyObject *__pyx_pw_15View_dot_MemoryView_10memoryview_8itemsize_1__get__(PyObject *__pyx_v_self) {
16478   PyObject *__pyx_r = 0;
16479   __Pyx_RefNannyDeclarations
16480   __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
16481   __pyx_r = __pyx_pf_15View_dot_MemoryView_10memoryview_8itemsize___get__(((struct __pyx_memoryview_obj *)__pyx_v_self));
16482 
16483   /* function exit code */
16484   __Pyx_RefNannyFinishContext();
16485   return __pyx_r;
16486 }
16487 
__pyx_pf_15View_dot_MemoryView_10memoryview_8itemsize___get__(struct __pyx_memoryview_obj * __pyx_v_self)16488 static PyObject *__pyx_pf_15View_dot_MemoryView_10memoryview_8itemsize___get__(struct __pyx_memoryview_obj *__pyx_v_self) {
16489   PyObject *__pyx_r = NULL;
16490   __Pyx_RefNannyDeclarations
16491   PyObject *__pyx_t_1 = NULL;
16492   int __pyx_lineno = 0;
16493   const char *__pyx_filename = NULL;
16494   int __pyx_clineno = 0;
16495   __Pyx_RefNannySetupContext("__get__", 0);
16496 
16497   /* "View.MemoryView":587
16498  *     @property
16499  *     def itemsize(self):
16500  *         return self.view.itemsize             # <<<<<<<<<<<<<<
16501  *
16502  *     @property
16503  */
16504   __Pyx_XDECREF(__pyx_r);
16505   __pyx_t_1 = PyInt_FromSsize_t(__pyx_v_self->view.itemsize); if (unlikely(!__pyx_t_1)) __PYX_ERR(3, 587, __pyx_L1_error)
16506   __Pyx_GOTREF(__pyx_t_1);
16507   __pyx_r = __pyx_t_1;
16508   __pyx_t_1 = 0;
16509   goto __pyx_L0;
16510 
16511   /* "View.MemoryView":586
16512  *
16513  *     @property
16514  *     def itemsize(self):             # <<<<<<<<<<<<<<
16515  *         return self.view.itemsize
16516  *
16517  */
16518 
16519   /* function exit code */
16520   __pyx_L1_error:;
16521   __Pyx_XDECREF(__pyx_t_1);
16522   __Pyx_AddTraceback("View.MemoryView.memoryview.itemsize.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
16523   __pyx_r = NULL;
16524   __pyx_L0:;
16525   __Pyx_XGIVEREF(__pyx_r);
16526   __Pyx_RefNannyFinishContext();
16527   return __pyx_r;
16528 }
16529 
16530 /* "View.MemoryView":590
16531  *
16532  *     @property
16533  *     def nbytes(self):             # <<<<<<<<<<<<<<
16534  *         return self.size * self.view.itemsize
16535  *
16536  */
16537 
16538 /* Python wrapper */
16539 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)16540 static PyObject *__pyx_pw_15View_dot_MemoryView_10memoryview_6nbytes_1__get__(PyObject *__pyx_v_self) {
16541   PyObject *__pyx_r = 0;
16542   __Pyx_RefNannyDeclarations
16543   __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
16544   __pyx_r = __pyx_pf_15View_dot_MemoryView_10memoryview_6nbytes___get__(((struct __pyx_memoryview_obj *)__pyx_v_self));
16545 
16546   /* function exit code */
16547   __Pyx_RefNannyFinishContext();
16548   return __pyx_r;
16549 }
16550 
__pyx_pf_15View_dot_MemoryView_10memoryview_6nbytes___get__(struct __pyx_memoryview_obj * __pyx_v_self)16551 static PyObject *__pyx_pf_15View_dot_MemoryView_10memoryview_6nbytes___get__(struct __pyx_memoryview_obj *__pyx_v_self) {
16552   PyObject *__pyx_r = NULL;
16553   __Pyx_RefNannyDeclarations
16554   PyObject *__pyx_t_1 = NULL;
16555   PyObject *__pyx_t_2 = NULL;
16556   PyObject *__pyx_t_3 = NULL;
16557   int __pyx_lineno = 0;
16558   const char *__pyx_filename = NULL;
16559   int __pyx_clineno = 0;
16560   __Pyx_RefNannySetupContext("__get__", 0);
16561 
16562   /* "View.MemoryView":591
16563  *     @property
16564  *     def nbytes(self):
16565  *         return self.size * self.view.itemsize             # <<<<<<<<<<<<<<
16566  *
16567  *     @property
16568  */
16569   __Pyx_XDECREF(__pyx_r);
16570   __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)
16571   __Pyx_GOTREF(__pyx_t_1);
16572   __pyx_t_2 = PyInt_FromSsize_t(__pyx_v_self->view.itemsize); if (unlikely(!__pyx_t_2)) __PYX_ERR(3, 591, __pyx_L1_error)
16573   __Pyx_GOTREF(__pyx_t_2);
16574   __pyx_t_3 = PyNumber_Multiply(__pyx_t_1, __pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(3, 591, __pyx_L1_error)
16575   __Pyx_GOTREF(__pyx_t_3);
16576   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
16577   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
16578   __pyx_r = __pyx_t_3;
16579   __pyx_t_3 = 0;
16580   goto __pyx_L0;
16581 
16582   /* "View.MemoryView":590
16583  *
16584  *     @property
16585  *     def nbytes(self):             # <<<<<<<<<<<<<<
16586  *         return self.size * self.view.itemsize
16587  *
16588  */
16589 
16590   /* function exit code */
16591   __pyx_L1_error:;
16592   __Pyx_XDECREF(__pyx_t_1);
16593   __Pyx_XDECREF(__pyx_t_2);
16594   __Pyx_XDECREF(__pyx_t_3);
16595   __Pyx_AddTraceback("View.MemoryView.memoryview.nbytes.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
16596   __pyx_r = NULL;
16597   __pyx_L0:;
16598   __Pyx_XGIVEREF(__pyx_r);
16599   __Pyx_RefNannyFinishContext();
16600   return __pyx_r;
16601 }
16602 
16603 /* "View.MemoryView":594
16604  *
16605  *     @property
16606  *     def size(self):             # <<<<<<<<<<<<<<
16607  *         if self._size is None:
16608  *             result = 1
16609  */
16610 
16611 /* Python wrapper */
16612 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)16613 static PyObject *__pyx_pw_15View_dot_MemoryView_10memoryview_4size_1__get__(PyObject *__pyx_v_self) {
16614   PyObject *__pyx_r = 0;
16615   __Pyx_RefNannyDeclarations
16616   __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
16617   __pyx_r = __pyx_pf_15View_dot_MemoryView_10memoryview_4size___get__(((struct __pyx_memoryview_obj *)__pyx_v_self));
16618 
16619   /* function exit code */
16620   __Pyx_RefNannyFinishContext();
16621   return __pyx_r;
16622 }
16623 
__pyx_pf_15View_dot_MemoryView_10memoryview_4size___get__(struct __pyx_memoryview_obj * __pyx_v_self)16624 static PyObject *__pyx_pf_15View_dot_MemoryView_10memoryview_4size___get__(struct __pyx_memoryview_obj *__pyx_v_self) {
16625   PyObject *__pyx_v_result = NULL;
16626   PyObject *__pyx_v_length = NULL;
16627   PyObject *__pyx_r = NULL;
16628   __Pyx_RefNannyDeclarations
16629   int __pyx_t_1;
16630   int __pyx_t_2;
16631   Py_ssize_t *__pyx_t_3;
16632   Py_ssize_t *__pyx_t_4;
16633   Py_ssize_t *__pyx_t_5;
16634   PyObject *__pyx_t_6 = NULL;
16635   int __pyx_lineno = 0;
16636   const char *__pyx_filename = NULL;
16637   int __pyx_clineno = 0;
16638   __Pyx_RefNannySetupContext("__get__", 0);
16639 
16640   /* "View.MemoryView":595
16641  *     @property
16642  *     def size(self):
16643  *         if self._size is None:             # <<<<<<<<<<<<<<
16644  *             result = 1
16645  *
16646  */
16647   __pyx_t_1 = (__pyx_v_self->_size == Py_None);
16648   __pyx_t_2 = (__pyx_t_1 != 0);
16649   if (__pyx_t_2) {
16650 
16651     /* "View.MemoryView":596
16652  *     def size(self):
16653  *         if self._size is None:
16654  *             result = 1             # <<<<<<<<<<<<<<
16655  *
16656  *             for length in self.view.shape[:self.view.ndim]:
16657  */
16658     __Pyx_INCREF(__pyx_int_1);
16659     __pyx_v_result = __pyx_int_1;
16660 
16661     /* "View.MemoryView":598
16662  *             result = 1
16663  *
16664  *             for length in self.view.shape[:self.view.ndim]:             # <<<<<<<<<<<<<<
16665  *                 result *= length
16666  *
16667  */
16668     __pyx_t_4 = (__pyx_v_self->view.shape + __pyx_v_self->view.ndim);
16669     for (__pyx_t_5 = __pyx_v_self->view.shape; __pyx_t_5 < __pyx_t_4; __pyx_t_5++) {
16670       __pyx_t_3 = __pyx_t_5;
16671       __pyx_t_6 = PyInt_FromSsize_t((__pyx_t_3[0])); if (unlikely(!__pyx_t_6)) __PYX_ERR(3, 598, __pyx_L1_error)
16672       __Pyx_GOTREF(__pyx_t_6);
16673       __Pyx_XDECREF_SET(__pyx_v_length, __pyx_t_6);
16674       __pyx_t_6 = 0;
16675 
16676       /* "View.MemoryView":599
16677  *
16678  *             for length in self.view.shape[:self.view.ndim]:
16679  *                 result *= length             # <<<<<<<<<<<<<<
16680  *
16681  *             self._size = result
16682  */
16683       __pyx_t_6 = PyNumber_InPlaceMultiply(__pyx_v_result, __pyx_v_length); if (unlikely(!__pyx_t_6)) __PYX_ERR(3, 599, __pyx_L1_error)
16684       __Pyx_GOTREF(__pyx_t_6);
16685       __Pyx_DECREF_SET(__pyx_v_result, __pyx_t_6);
16686       __pyx_t_6 = 0;
16687     }
16688 
16689     /* "View.MemoryView":601
16690  *                 result *= length
16691  *
16692  *             self._size = result             # <<<<<<<<<<<<<<
16693  *
16694  *         return self._size
16695  */
16696     __Pyx_INCREF(__pyx_v_result);
16697     __Pyx_GIVEREF(__pyx_v_result);
16698     __Pyx_GOTREF(__pyx_v_self->_size);
16699     __Pyx_DECREF(__pyx_v_self->_size);
16700     __pyx_v_self->_size = __pyx_v_result;
16701 
16702     /* "View.MemoryView":595
16703  *     @property
16704  *     def size(self):
16705  *         if self._size is None:             # <<<<<<<<<<<<<<
16706  *             result = 1
16707  *
16708  */
16709   }
16710 
16711   /* "View.MemoryView":603
16712  *             self._size = result
16713  *
16714  *         return self._size             # <<<<<<<<<<<<<<
16715  *
16716  *     def __len__(self):
16717  */
16718   __Pyx_XDECREF(__pyx_r);
16719   __Pyx_INCREF(__pyx_v_self->_size);
16720   __pyx_r = __pyx_v_self->_size;
16721   goto __pyx_L0;
16722 
16723   /* "View.MemoryView":594
16724  *
16725  *     @property
16726  *     def size(self):             # <<<<<<<<<<<<<<
16727  *         if self._size is None:
16728  *             result = 1
16729  */
16730 
16731   /* function exit code */
16732   __pyx_L1_error:;
16733   __Pyx_XDECREF(__pyx_t_6);
16734   __Pyx_AddTraceback("View.MemoryView.memoryview.size.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
16735   __pyx_r = NULL;
16736   __pyx_L0:;
16737   __Pyx_XDECREF(__pyx_v_result);
16738   __Pyx_XDECREF(__pyx_v_length);
16739   __Pyx_XGIVEREF(__pyx_r);
16740   __Pyx_RefNannyFinishContext();
16741   return __pyx_r;
16742 }
16743 
16744 /* "View.MemoryView":605
16745  *         return self._size
16746  *
16747  *     def __len__(self):             # <<<<<<<<<<<<<<
16748  *         if self.view.ndim >= 1:
16749  *             return self.view.shape[0]
16750  */
16751 
16752 /* Python wrapper */
16753 static Py_ssize_t __pyx_memoryview___len__(PyObject *__pyx_v_self); /*proto*/
__pyx_memoryview___len__(PyObject * __pyx_v_self)16754 static Py_ssize_t __pyx_memoryview___len__(PyObject *__pyx_v_self) {
16755   Py_ssize_t __pyx_r;
16756   __Pyx_RefNannyDeclarations
16757   __Pyx_RefNannySetupContext("__len__ (wrapper)", 0);
16758   __pyx_r = __pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_10__len__(((struct __pyx_memoryview_obj *)__pyx_v_self));
16759 
16760   /* function exit code */
16761   __Pyx_RefNannyFinishContext();
16762   return __pyx_r;
16763 }
16764 
__pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_10__len__(struct __pyx_memoryview_obj * __pyx_v_self)16765 static Py_ssize_t __pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_10__len__(struct __pyx_memoryview_obj *__pyx_v_self) {
16766   Py_ssize_t __pyx_r;
16767   __Pyx_RefNannyDeclarations
16768   int __pyx_t_1;
16769   __Pyx_RefNannySetupContext("__len__", 0);
16770 
16771   /* "View.MemoryView":606
16772  *
16773  *     def __len__(self):
16774  *         if self.view.ndim >= 1:             # <<<<<<<<<<<<<<
16775  *             return self.view.shape[0]
16776  *
16777  */
16778   __pyx_t_1 = ((__pyx_v_self->view.ndim >= 1) != 0);
16779   if (__pyx_t_1) {
16780 
16781     /* "View.MemoryView":607
16782  *     def __len__(self):
16783  *         if self.view.ndim >= 1:
16784  *             return self.view.shape[0]             # <<<<<<<<<<<<<<
16785  *
16786  *         return 0
16787  */
16788     __pyx_r = (__pyx_v_self->view.shape[0]);
16789     goto __pyx_L0;
16790 
16791     /* "View.MemoryView":606
16792  *
16793  *     def __len__(self):
16794  *         if self.view.ndim >= 1:             # <<<<<<<<<<<<<<
16795  *             return self.view.shape[0]
16796  *
16797  */
16798   }
16799 
16800   /* "View.MemoryView":609
16801  *             return self.view.shape[0]
16802  *
16803  *         return 0             # <<<<<<<<<<<<<<
16804  *
16805  *     def __repr__(self):
16806  */
16807   __pyx_r = 0;
16808   goto __pyx_L0;
16809 
16810   /* "View.MemoryView":605
16811  *         return self._size
16812  *
16813  *     def __len__(self):             # <<<<<<<<<<<<<<
16814  *         if self.view.ndim >= 1:
16815  *             return self.view.shape[0]
16816  */
16817 
16818   /* function exit code */
16819   __pyx_L0:;
16820   __Pyx_RefNannyFinishContext();
16821   return __pyx_r;
16822 }
16823 
16824 /* "View.MemoryView":611
16825  *         return 0
16826  *
16827  *     def __repr__(self):             # <<<<<<<<<<<<<<
16828  *         return "<MemoryView of %r at 0x%x>" % (self.base.__class__.__name__,
16829  *                                                id(self))
16830  */
16831 
16832 /* Python wrapper */
16833 static PyObject *__pyx_memoryview___repr__(PyObject *__pyx_v_self); /*proto*/
__pyx_memoryview___repr__(PyObject * __pyx_v_self)16834 static PyObject *__pyx_memoryview___repr__(PyObject *__pyx_v_self) {
16835   PyObject *__pyx_r = 0;
16836   __Pyx_RefNannyDeclarations
16837   __Pyx_RefNannySetupContext("__repr__ (wrapper)", 0);
16838   __pyx_r = __pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_12__repr__(((struct __pyx_memoryview_obj *)__pyx_v_self));
16839 
16840   /* function exit code */
16841   __Pyx_RefNannyFinishContext();
16842   return __pyx_r;
16843 }
16844 
__pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_12__repr__(struct __pyx_memoryview_obj * __pyx_v_self)16845 static PyObject *__pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_12__repr__(struct __pyx_memoryview_obj *__pyx_v_self) {
16846   PyObject *__pyx_r = NULL;
16847   __Pyx_RefNannyDeclarations
16848   PyObject *__pyx_t_1 = NULL;
16849   PyObject *__pyx_t_2 = NULL;
16850   PyObject *__pyx_t_3 = NULL;
16851   int __pyx_lineno = 0;
16852   const char *__pyx_filename = NULL;
16853   int __pyx_clineno = 0;
16854   __Pyx_RefNannySetupContext("__repr__", 0);
16855 
16856   /* "View.MemoryView":612
16857  *
16858  *     def __repr__(self):
16859  *         return "<MemoryView of %r at 0x%x>" % (self.base.__class__.__name__,             # <<<<<<<<<<<<<<
16860  *                                                id(self))
16861  *
16862  */
16863   __Pyx_XDECREF(__pyx_r);
16864   __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)
16865   __Pyx_GOTREF(__pyx_t_1);
16866   __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)
16867   __Pyx_GOTREF(__pyx_t_2);
16868   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
16869   __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)
16870   __Pyx_GOTREF(__pyx_t_1);
16871   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
16872 
16873   /* "View.MemoryView":613
16874  *     def __repr__(self):
16875  *         return "<MemoryView of %r at 0x%x>" % (self.base.__class__.__name__,
16876  *                                                id(self))             # <<<<<<<<<<<<<<
16877  *
16878  *     def __str__(self):
16879  */
16880   __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)
16881   __Pyx_GOTREF(__pyx_t_2);
16882 
16883   /* "View.MemoryView":612
16884  *
16885  *     def __repr__(self):
16886  *         return "<MemoryView of %r at 0x%x>" % (self.base.__class__.__name__,             # <<<<<<<<<<<<<<
16887  *                                                id(self))
16888  *
16889  */
16890   __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(3, 612, __pyx_L1_error)
16891   __Pyx_GOTREF(__pyx_t_3);
16892   __Pyx_GIVEREF(__pyx_t_1);
16893   PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_1);
16894   __Pyx_GIVEREF(__pyx_t_2);
16895   PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_2);
16896   __pyx_t_1 = 0;
16897   __pyx_t_2 = 0;
16898   __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)
16899   __Pyx_GOTREF(__pyx_t_2);
16900   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
16901   __pyx_r = __pyx_t_2;
16902   __pyx_t_2 = 0;
16903   goto __pyx_L0;
16904 
16905   /* "View.MemoryView":611
16906  *         return 0
16907  *
16908  *     def __repr__(self):             # <<<<<<<<<<<<<<
16909  *         return "<MemoryView of %r at 0x%x>" % (self.base.__class__.__name__,
16910  *                                                id(self))
16911  */
16912 
16913   /* function exit code */
16914   __pyx_L1_error:;
16915   __Pyx_XDECREF(__pyx_t_1);
16916   __Pyx_XDECREF(__pyx_t_2);
16917   __Pyx_XDECREF(__pyx_t_3);
16918   __Pyx_AddTraceback("View.MemoryView.memoryview.__repr__", __pyx_clineno, __pyx_lineno, __pyx_filename);
16919   __pyx_r = NULL;
16920   __pyx_L0:;
16921   __Pyx_XGIVEREF(__pyx_r);
16922   __Pyx_RefNannyFinishContext();
16923   return __pyx_r;
16924 }
16925 
16926 /* "View.MemoryView":615
16927  *                                                id(self))
16928  *
16929  *     def __str__(self):             # <<<<<<<<<<<<<<
16930  *         return "<MemoryView of %r object>" % (self.base.__class__.__name__,)
16931  *
16932  */
16933 
16934 /* Python wrapper */
16935 static PyObject *__pyx_memoryview___str__(PyObject *__pyx_v_self); /*proto*/
__pyx_memoryview___str__(PyObject * __pyx_v_self)16936 static PyObject *__pyx_memoryview___str__(PyObject *__pyx_v_self) {
16937   PyObject *__pyx_r = 0;
16938   __Pyx_RefNannyDeclarations
16939   __Pyx_RefNannySetupContext("__str__ (wrapper)", 0);
16940   __pyx_r = __pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_14__str__(((struct __pyx_memoryview_obj *)__pyx_v_self));
16941 
16942   /* function exit code */
16943   __Pyx_RefNannyFinishContext();
16944   return __pyx_r;
16945 }
16946 
__pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_14__str__(struct __pyx_memoryview_obj * __pyx_v_self)16947 static PyObject *__pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_14__str__(struct __pyx_memoryview_obj *__pyx_v_self) {
16948   PyObject *__pyx_r = NULL;
16949   __Pyx_RefNannyDeclarations
16950   PyObject *__pyx_t_1 = NULL;
16951   PyObject *__pyx_t_2 = NULL;
16952   int __pyx_lineno = 0;
16953   const char *__pyx_filename = NULL;
16954   int __pyx_clineno = 0;
16955   __Pyx_RefNannySetupContext("__str__", 0);
16956 
16957   /* "View.MemoryView":616
16958  *
16959  *     def __str__(self):
16960  *         return "<MemoryView of %r object>" % (self.base.__class__.__name__,)             # <<<<<<<<<<<<<<
16961  *
16962  *
16963  */
16964   __Pyx_XDECREF(__pyx_r);
16965   __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)
16966   __Pyx_GOTREF(__pyx_t_1);
16967   __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)
16968   __Pyx_GOTREF(__pyx_t_2);
16969   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
16970   __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)
16971   __Pyx_GOTREF(__pyx_t_1);
16972   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
16973   __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(3, 616, __pyx_L1_error)
16974   __Pyx_GOTREF(__pyx_t_2);
16975   __Pyx_GIVEREF(__pyx_t_1);
16976   PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_1);
16977   __pyx_t_1 = 0;
16978   __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)
16979   __Pyx_GOTREF(__pyx_t_1);
16980   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
16981   __pyx_r = __pyx_t_1;
16982   __pyx_t_1 = 0;
16983   goto __pyx_L0;
16984 
16985   /* "View.MemoryView":615
16986  *                                                id(self))
16987  *
16988  *     def __str__(self):             # <<<<<<<<<<<<<<
16989  *         return "<MemoryView of %r object>" % (self.base.__class__.__name__,)
16990  *
16991  */
16992 
16993   /* function exit code */
16994   __pyx_L1_error:;
16995   __Pyx_XDECREF(__pyx_t_1);
16996   __Pyx_XDECREF(__pyx_t_2);
16997   __Pyx_AddTraceback("View.MemoryView.memoryview.__str__", __pyx_clineno, __pyx_lineno, __pyx_filename);
16998   __pyx_r = NULL;
16999   __pyx_L0:;
17000   __Pyx_XGIVEREF(__pyx_r);
17001   __Pyx_RefNannyFinishContext();
17002   return __pyx_r;
17003 }
17004 
17005 /* "View.MemoryView":619
17006  *
17007  *
17008  *     def is_c_contig(self):             # <<<<<<<<<<<<<<
17009  *         cdef __Pyx_memviewslice *mslice
17010  *         cdef __Pyx_memviewslice tmp
17011  */
17012 
17013 /* Python wrapper */
17014 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)17015 static PyObject *__pyx_memoryview_is_c_contig(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
17016   PyObject *__pyx_r = 0;
17017   __Pyx_RefNannyDeclarations
17018   __Pyx_RefNannySetupContext("is_c_contig (wrapper)", 0);
17019   __pyx_r = __pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_16is_c_contig(((struct __pyx_memoryview_obj *)__pyx_v_self));
17020 
17021   /* function exit code */
17022   __Pyx_RefNannyFinishContext();
17023   return __pyx_r;
17024 }
17025 
__pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_16is_c_contig(struct __pyx_memoryview_obj * __pyx_v_self)17026 static PyObject *__pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_16is_c_contig(struct __pyx_memoryview_obj *__pyx_v_self) {
17027   __Pyx_memviewslice *__pyx_v_mslice;
17028   __Pyx_memviewslice __pyx_v_tmp;
17029   PyObject *__pyx_r = NULL;
17030   __Pyx_RefNannyDeclarations
17031   __Pyx_memviewslice *__pyx_t_1;
17032   PyObject *__pyx_t_2 = NULL;
17033   int __pyx_lineno = 0;
17034   const char *__pyx_filename = NULL;
17035   int __pyx_clineno = 0;
17036   __Pyx_RefNannySetupContext("is_c_contig", 0);
17037 
17038   /* "View.MemoryView":622
17039  *         cdef __Pyx_memviewslice *mslice
17040  *         cdef __Pyx_memviewslice tmp
17041  *         mslice = get_slice_from_memview(self, &tmp)             # <<<<<<<<<<<<<<
17042  *         return slice_is_contig(mslice[0], 'C', self.view.ndim)
17043  *
17044  */
17045   __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)
17046   __pyx_v_mslice = __pyx_t_1;
17047 
17048   /* "View.MemoryView":623
17049  *         cdef __Pyx_memviewslice tmp
17050  *         mslice = get_slice_from_memview(self, &tmp)
17051  *         return slice_is_contig(mslice[0], 'C', self.view.ndim)             # <<<<<<<<<<<<<<
17052  *
17053  *     def is_f_contig(self):
17054  */
17055   __Pyx_XDECREF(__pyx_r);
17056   __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)
17057   __Pyx_GOTREF(__pyx_t_2);
17058   __pyx_r = __pyx_t_2;
17059   __pyx_t_2 = 0;
17060   goto __pyx_L0;
17061 
17062   /* "View.MemoryView":619
17063  *
17064  *
17065  *     def is_c_contig(self):             # <<<<<<<<<<<<<<
17066  *         cdef __Pyx_memviewslice *mslice
17067  *         cdef __Pyx_memviewslice tmp
17068  */
17069 
17070   /* function exit code */
17071   __pyx_L1_error:;
17072   __Pyx_XDECREF(__pyx_t_2);
17073   __Pyx_AddTraceback("View.MemoryView.memoryview.is_c_contig", __pyx_clineno, __pyx_lineno, __pyx_filename);
17074   __pyx_r = NULL;
17075   __pyx_L0:;
17076   __Pyx_XGIVEREF(__pyx_r);
17077   __Pyx_RefNannyFinishContext();
17078   return __pyx_r;
17079 }
17080 
17081 /* "View.MemoryView":625
17082  *         return slice_is_contig(mslice[0], 'C', self.view.ndim)
17083  *
17084  *     def is_f_contig(self):             # <<<<<<<<<<<<<<
17085  *         cdef __Pyx_memviewslice *mslice
17086  *         cdef __Pyx_memviewslice tmp
17087  */
17088 
17089 /* Python wrapper */
17090 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)17091 static PyObject *__pyx_memoryview_is_f_contig(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
17092   PyObject *__pyx_r = 0;
17093   __Pyx_RefNannyDeclarations
17094   __Pyx_RefNannySetupContext("is_f_contig (wrapper)", 0);
17095   __pyx_r = __pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_18is_f_contig(((struct __pyx_memoryview_obj *)__pyx_v_self));
17096 
17097   /* function exit code */
17098   __Pyx_RefNannyFinishContext();
17099   return __pyx_r;
17100 }
17101 
__pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_18is_f_contig(struct __pyx_memoryview_obj * __pyx_v_self)17102 static PyObject *__pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_18is_f_contig(struct __pyx_memoryview_obj *__pyx_v_self) {
17103   __Pyx_memviewslice *__pyx_v_mslice;
17104   __Pyx_memviewslice __pyx_v_tmp;
17105   PyObject *__pyx_r = NULL;
17106   __Pyx_RefNannyDeclarations
17107   __Pyx_memviewslice *__pyx_t_1;
17108   PyObject *__pyx_t_2 = NULL;
17109   int __pyx_lineno = 0;
17110   const char *__pyx_filename = NULL;
17111   int __pyx_clineno = 0;
17112   __Pyx_RefNannySetupContext("is_f_contig", 0);
17113 
17114   /* "View.MemoryView":628
17115  *         cdef __Pyx_memviewslice *mslice
17116  *         cdef __Pyx_memviewslice tmp
17117  *         mslice = get_slice_from_memview(self, &tmp)             # <<<<<<<<<<<<<<
17118  *         return slice_is_contig(mslice[0], 'F', self.view.ndim)
17119  *
17120  */
17121   __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)
17122   __pyx_v_mslice = __pyx_t_1;
17123 
17124   /* "View.MemoryView":629
17125  *         cdef __Pyx_memviewslice tmp
17126  *         mslice = get_slice_from_memview(self, &tmp)
17127  *         return slice_is_contig(mslice[0], 'F', self.view.ndim)             # <<<<<<<<<<<<<<
17128  *
17129  *     def copy(self):
17130  */
17131   __Pyx_XDECREF(__pyx_r);
17132   __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)
17133   __Pyx_GOTREF(__pyx_t_2);
17134   __pyx_r = __pyx_t_2;
17135   __pyx_t_2 = 0;
17136   goto __pyx_L0;
17137 
17138   /* "View.MemoryView":625
17139  *         return slice_is_contig(mslice[0], 'C', self.view.ndim)
17140  *
17141  *     def is_f_contig(self):             # <<<<<<<<<<<<<<
17142  *         cdef __Pyx_memviewslice *mslice
17143  *         cdef __Pyx_memviewslice tmp
17144  */
17145 
17146   /* function exit code */
17147   __pyx_L1_error:;
17148   __Pyx_XDECREF(__pyx_t_2);
17149   __Pyx_AddTraceback("View.MemoryView.memoryview.is_f_contig", __pyx_clineno, __pyx_lineno, __pyx_filename);
17150   __pyx_r = NULL;
17151   __pyx_L0:;
17152   __Pyx_XGIVEREF(__pyx_r);
17153   __Pyx_RefNannyFinishContext();
17154   return __pyx_r;
17155 }
17156 
17157 /* "View.MemoryView":631
17158  *         return slice_is_contig(mslice[0], 'F', self.view.ndim)
17159  *
17160  *     def copy(self):             # <<<<<<<<<<<<<<
17161  *         cdef __Pyx_memviewslice mslice
17162  *         cdef int flags = self.flags & ~PyBUF_F_CONTIGUOUS
17163  */
17164 
17165 /* Python wrapper */
17166 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)17167 static PyObject *__pyx_memoryview_copy(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
17168   PyObject *__pyx_r = 0;
17169   __Pyx_RefNannyDeclarations
17170   __Pyx_RefNannySetupContext("copy (wrapper)", 0);
17171   __pyx_r = __pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_20copy(((struct __pyx_memoryview_obj *)__pyx_v_self));
17172 
17173   /* function exit code */
17174   __Pyx_RefNannyFinishContext();
17175   return __pyx_r;
17176 }
17177 
__pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_20copy(struct __pyx_memoryview_obj * __pyx_v_self)17178 static PyObject *__pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_20copy(struct __pyx_memoryview_obj *__pyx_v_self) {
17179   __Pyx_memviewslice __pyx_v_mslice;
17180   int __pyx_v_flags;
17181   PyObject *__pyx_r = NULL;
17182   __Pyx_RefNannyDeclarations
17183   __Pyx_memviewslice __pyx_t_1;
17184   PyObject *__pyx_t_2 = NULL;
17185   int __pyx_lineno = 0;
17186   const char *__pyx_filename = NULL;
17187   int __pyx_clineno = 0;
17188   __Pyx_RefNannySetupContext("copy", 0);
17189 
17190   /* "View.MemoryView":633
17191  *     def copy(self):
17192  *         cdef __Pyx_memviewslice mslice
17193  *         cdef int flags = self.flags & ~PyBUF_F_CONTIGUOUS             # <<<<<<<<<<<<<<
17194  *
17195  *         slice_copy(self, &mslice)
17196  */
17197   __pyx_v_flags = (__pyx_v_self->flags & (~PyBUF_F_CONTIGUOUS));
17198 
17199   /* "View.MemoryView":635
17200  *         cdef int flags = self.flags & ~PyBUF_F_CONTIGUOUS
17201  *
17202  *         slice_copy(self, &mslice)             # <<<<<<<<<<<<<<
17203  *         mslice = slice_copy_contig(&mslice, "c", self.view.ndim,
17204  *                                    self.view.itemsize,
17205  */
17206   __pyx_memoryview_slice_copy(__pyx_v_self, (&__pyx_v_mslice));
17207 
17208   /* "View.MemoryView":636
17209  *
17210  *         slice_copy(self, &mslice)
17211  *         mslice = slice_copy_contig(&mslice, "c", self.view.ndim,             # <<<<<<<<<<<<<<
17212  *                                    self.view.itemsize,
17213  *                                    flags|PyBUF_C_CONTIGUOUS,
17214  */
17215   __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)
17216   __pyx_v_mslice = __pyx_t_1;
17217 
17218   /* "View.MemoryView":641
17219  *                                    self.dtype_is_object)
17220  *
17221  *         return memoryview_copy_from_slice(self, &mslice)             # <<<<<<<<<<<<<<
17222  *
17223  *     def copy_fortran(self):
17224  */
17225   __Pyx_XDECREF(__pyx_r);
17226   __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)
17227   __Pyx_GOTREF(__pyx_t_2);
17228   __pyx_r = __pyx_t_2;
17229   __pyx_t_2 = 0;
17230   goto __pyx_L0;
17231 
17232   /* "View.MemoryView":631
17233  *         return slice_is_contig(mslice[0], 'F', self.view.ndim)
17234  *
17235  *     def copy(self):             # <<<<<<<<<<<<<<
17236  *         cdef __Pyx_memviewslice mslice
17237  *         cdef int flags = self.flags & ~PyBUF_F_CONTIGUOUS
17238  */
17239 
17240   /* function exit code */
17241   __pyx_L1_error:;
17242   __Pyx_XDECREF(__pyx_t_2);
17243   __Pyx_AddTraceback("View.MemoryView.memoryview.copy", __pyx_clineno, __pyx_lineno, __pyx_filename);
17244   __pyx_r = NULL;
17245   __pyx_L0:;
17246   __Pyx_XGIVEREF(__pyx_r);
17247   __Pyx_RefNannyFinishContext();
17248   return __pyx_r;
17249 }
17250 
17251 /* "View.MemoryView":643
17252  *         return memoryview_copy_from_slice(self, &mslice)
17253  *
17254  *     def copy_fortran(self):             # <<<<<<<<<<<<<<
17255  *         cdef __Pyx_memviewslice src, dst
17256  *         cdef int flags = self.flags & ~PyBUF_C_CONTIGUOUS
17257  */
17258 
17259 /* Python wrapper */
17260 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)17261 static PyObject *__pyx_memoryview_copy_fortran(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
17262   PyObject *__pyx_r = 0;
17263   __Pyx_RefNannyDeclarations
17264   __Pyx_RefNannySetupContext("copy_fortran (wrapper)", 0);
17265   __pyx_r = __pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_22copy_fortran(((struct __pyx_memoryview_obj *)__pyx_v_self));
17266 
17267   /* function exit code */
17268   __Pyx_RefNannyFinishContext();
17269   return __pyx_r;
17270 }
17271 
__pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_22copy_fortran(struct __pyx_memoryview_obj * __pyx_v_self)17272 static PyObject *__pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_22copy_fortran(struct __pyx_memoryview_obj *__pyx_v_self) {
17273   __Pyx_memviewslice __pyx_v_src;
17274   __Pyx_memviewslice __pyx_v_dst;
17275   int __pyx_v_flags;
17276   PyObject *__pyx_r = NULL;
17277   __Pyx_RefNannyDeclarations
17278   __Pyx_memviewslice __pyx_t_1;
17279   PyObject *__pyx_t_2 = NULL;
17280   int __pyx_lineno = 0;
17281   const char *__pyx_filename = NULL;
17282   int __pyx_clineno = 0;
17283   __Pyx_RefNannySetupContext("copy_fortran", 0);
17284 
17285   /* "View.MemoryView":645
17286  *     def copy_fortran(self):
17287  *         cdef __Pyx_memviewslice src, dst
17288  *         cdef int flags = self.flags & ~PyBUF_C_CONTIGUOUS             # <<<<<<<<<<<<<<
17289  *
17290  *         slice_copy(self, &src)
17291  */
17292   __pyx_v_flags = (__pyx_v_self->flags & (~PyBUF_C_CONTIGUOUS));
17293 
17294   /* "View.MemoryView":647
17295  *         cdef int flags = self.flags & ~PyBUF_C_CONTIGUOUS
17296  *
17297  *         slice_copy(self, &src)             # <<<<<<<<<<<<<<
17298  *         dst = slice_copy_contig(&src, "fortran", self.view.ndim,
17299  *                                 self.view.itemsize,
17300  */
17301   __pyx_memoryview_slice_copy(__pyx_v_self, (&__pyx_v_src));
17302 
17303   /* "View.MemoryView":648
17304  *
17305  *         slice_copy(self, &src)
17306  *         dst = slice_copy_contig(&src, "fortran", self.view.ndim,             # <<<<<<<<<<<<<<
17307  *                                 self.view.itemsize,
17308  *                                 flags|PyBUF_F_CONTIGUOUS,
17309  */
17310   __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)
17311   __pyx_v_dst = __pyx_t_1;
17312 
17313   /* "View.MemoryView":653
17314  *                                 self.dtype_is_object)
17315  *
17316  *         return memoryview_copy_from_slice(self, &dst)             # <<<<<<<<<<<<<<
17317  *
17318  *
17319  */
17320   __Pyx_XDECREF(__pyx_r);
17321   __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)
17322   __Pyx_GOTREF(__pyx_t_2);
17323   __pyx_r = __pyx_t_2;
17324   __pyx_t_2 = 0;
17325   goto __pyx_L0;
17326 
17327   /* "View.MemoryView":643
17328  *         return memoryview_copy_from_slice(self, &mslice)
17329  *
17330  *     def copy_fortran(self):             # <<<<<<<<<<<<<<
17331  *         cdef __Pyx_memviewslice src, dst
17332  *         cdef int flags = self.flags & ~PyBUF_C_CONTIGUOUS
17333  */
17334 
17335   /* function exit code */
17336   __pyx_L1_error:;
17337   __Pyx_XDECREF(__pyx_t_2);
17338   __Pyx_AddTraceback("View.MemoryView.memoryview.copy_fortran", __pyx_clineno, __pyx_lineno, __pyx_filename);
17339   __pyx_r = NULL;
17340   __pyx_L0:;
17341   __Pyx_XGIVEREF(__pyx_r);
17342   __Pyx_RefNannyFinishContext();
17343   return __pyx_r;
17344 }
17345 
17346 /* "(tree fragment)":1
17347  * def __reduce_cython__(self):             # <<<<<<<<<<<<<<
17348  *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
17349  * def __setstate_cython__(self, __pyx_state):
17350  */
17351 
17352 /* Python wrapper */
17353 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)17354 static PyObject *__pyx_pw___pyx_memoryview_1__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
17355   PyObject *__pyx_r = 0;
17356   __Pyx_RefNannyDeclarations
17357   __Pyx_RefNannySetupContext("__reduce_cython__ (wrapper)", 0);
17358   __pyx_r = __pyx_pf___pyx_memoryview___reduce_cython__(((struct __pyx_memoryview_obj *)__pyx_v_self));
17359 
17360   /* function exit code */
17361   __Pyx_RefNannyFinishContext();
17362   return __pyx_r;
17363 }
17364 
__pyx_pf___pyx_memoryview___reduce_cython__(CYTHON_UNUSED struct __pyx_memoryview_obj * __pyx_v_self)17365 static PyObject *__pyx_pf___pyx_memoryview___reduce_cython__(CYTHON_UNUSED struct __pyx_memoryview_obj *__pyx_v_self) {
17366   PyObject *__pyx_r = NULL;
17367   __Pyx_RefNannyDeclarations
17368   PyObject *__pyx_t_1 = NULL;
17369   int __pyx_lineno = 0;
17370   const char *__pyx_filename = NULL;
17371   int __pyx_clineno = 0;
17372   __Pyx_RefNannySetupContext("__reduce_cython__", 0);
17373 
17374   /* "(tree fragment)":2
17375  * def __reduce_cython__(self):
17376  *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")             # <<<<<<<<<<<<<<
17377  * def __setstate_cython__(self, __pyx_state):
17378  *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
17379  */
17380   __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__31, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(3, 2, __pyx_L1_error)
17381   __Pyx_GOTREF(__pyx_t_1);
17382   __Pyx_Raise(__pyx_t_1, 0, 0, 0);
17383   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
17384   __PYX_ERR(3, 2, __pyx_L1_error)
17385 
17386   /* "(tree fragment)":1
17387  * def __reduce_cython__(self):             # <<<<<<<<<<<<<<
17388  *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
17389  * def __setstate_cython__(self, __pyx_state):
17390  */
17391 
17392   /* function exit code */
17393   __pyx_L1_error:;
17394   __Pyx_XDECREF(__pyx_t_1);
17395   __Pyx_AddTraceback("View.MemoryView.memoryview.__reduce_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename);
17396   __pyx_r = NULL;
17397   __Pyx_XGIVEREF(__pyx_r);
17398   __Pyx_RefNannyFinishContext();
17399   return __pyx_r;
17400 }
17401 
17402 /* "(tree fragment)":3
17403  * def __reduce_cython__(self):
17404  *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
17405  * def __setstate_cython__(self, __pyx_state):             # <<<<<<<<<<<<<<
17406  *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
17407  */
17408 
17409 /* Python wrapper */
17410 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)17411 static PyObject *__pyx_pw___pyx_memoryview_3__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state) {
17412   PyObject *__pyx_r = 0;
17413   __Pyx_RefNannyDeclarations
17414   __Pyx_RefNannySetupContext("__setstate_cython__ (wrapper)", 0);
17415   __pyx_r = __pyx_pf___pyx_memoryview_2__setstate_cython__(((struct __pyx_memoryview_obj *)__pyx_v_self), ((PyObject *)__pyx_v___pyx_state));
17416 
17417   /* function exit code */
17418   __Pyx_RefNannyFinishContext();
17419   return __pyx_r;
17420 }
17421 
__pyx_pf___pyx_memoryview_2__setstate_cython__(CYTHON_UNUSED struct __pyx_memoryview_obj * __pyx_v_self,CYTHON_UNUSED PyObject * __pyx_v___pyx_state)17422 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) {
17423   PyObject *__pyx_r = NULL;
17424   __Pyx_RefNannyDeclarations
17425   PyObject *__pyx_t_1 = NULL;
17426   int __pyx_lineno = 0;
17427   const char *__pyx_filename = NULL;
17428   int __pyx_clineno = 0;
17429   __Pyx_RefNannySetupContext("__setstate_cython__", 0);
17430 
17431   /* "(tree fragment)":4
17432  *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
17433  * def __setstate_cython__(self, __pyx_state):
17434  *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")             # <<<<<<<<<<<<<<
17435  */
17436   __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__32, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(3, 4, __pyx_L1_error)
17437   __Pyx_GOTREF(__pyx_t_1);
17438   __Pyx_Raise(__pyx_t_1, 0, 0, 0);
17439   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
17440   __PYX_ERR(3, 4, __pyx_L1_error)
17441 
17442   /* "(tree fragment)":3
17443  * def __reduce_cython__(self):
17444  *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
17445  * def __setstate_cython__(self, __pyx_state):             # <<<<<<<<<<<<<<
17446  *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
17447  */
17448 
17449   /* function exit code */
17450   __pyx_L1_error:;
17451   __Pyx_XDECREF(__pyx_t_1);
17452   __Pyx_AddTraceback("View.MemoryView.memoryview.__setstate_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename);
17453   __pyx_r = NULL;
17454   __Pyx_XGIVEREF(__pyx_r);
17455   __Pyx_RefNannyFinishContext();
17456   return __pyx_r;
17457 }
17458 
17459 /* "View.MemoryView":657
17460  *
17461  * @cname('__pyx_memoryview_new')
17462  * cdef memoryview_cwrapper(object o, int flags, bint dtype_is_object, __Pyx_TypeInfo *typeinfo):             # <<<<<<<<<<<<<<
17463  *     cdef memoryview result = memoryview(o, flags, dtype_is_object)
17464  *     result.typeinfo = typeinfo
17465  */
17466 
__pyx_memoryview_new(PyObject * __pyx_v_o,int __pyx_v_flags,int __pyx_v_dtype_is_object,__Pyx_TypeInfo * __pyx_v_typeinfo)17467 static PyObject *__pyx_memoryview_new(PyObject *__pyx_v_o, int __pyx_v_flags, int __pyx_v_dtype_is_object, __Pyx_TypeInfo *__pyx_v_typeinfo) {
17468   struct __pyx_memoryview_obj *__pyx_v_result = 0;
17469   PyObject *__pyx_r = NULL;
17470   __Pyx_RefNannyDeclarations
17471   PyObject *__pyx_t_1 = NULL;
17472   PyObject *__pyx_t_2 = NULL;
17473   PyObject *__pyx_t_3 = NULL;
17474   int __pyx_lineno = 0;
17475   const char *__pyx_filename = NULL;
17476   int __pyx_clineno = 0;
17477   __Pyx_RefNannySetupContext("memoryview_cwrapper", 0);
17478 
17479   /* "View.MemoryView":658
17480  * @cname('__pyx_memoryview_new')
17481  * cdef memoryview_cwrapper(object o, int flags, bint dtype_is_object, __Pyx_TypeInfo *typeinfo):
17482  *     cdef memoryview result = memoryview(o, flags, dtype_is_object)             # <<<<<<<<<<<<<<
17483  *     result.typeinfo = typeinfo
17484  *     return result
17485  */
17486   __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_flags); if (unlikely(!__pyx_t_1)) __PYX_ERR(3, 658, __pyx_L1_error)
17487   __Pyx_GOTREF(__pyx_t_1);
17488   __pyx_t_2 = __Pyx_PyBool_FromLong(__pyx_v_dtype_is_object); if (unlikely(!__pyx_t_2)) __PYX_ERR(3, 658, __pyx_L1_error)
17489   __Pyx_GOTREF(__pyx_t_2);
17490   __pyx_t_3 = PyTuple_New(3); if (unlikely(!__pyx_t_3)) __PYX_ERR(3, 658, __pyx_L1_error)
17491   __Pyx_GOTREF(__pyx_t_3);
17492   __Pyx_INCREF(__pyx_v_o);
17493   __Pyx_GIVEREF(__pyx_v_o);
17494   PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_o);
17495   __Pyx_GIVEREF(__pyx_t_1);
17496   PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_1);
17497   __Pyx_GIVEREF(__pyx_t_2);
17498   PyTuple_SET_ITEM(__pyx_t_3, 2, __pyx_t_2);
17499   __pyx_t_1 = 0;
17500   __pyx_t_2 = 0;
17501   __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)
17502   __Pyx_GOTREF(__pyx_t_2);
17503   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
17504   __pyx_v_result = ((struct __pyx_memoryview_obj *)__pyx_t_2);
17505   __pyx_t_2 = 0;
17506 
17507   /* "View.MemoryView":659
17508  * cdef memoryview_cwrapper(object o, int flags, bint dtype_is_object, __Pyx_TypeInfo *typeinfo):
17509  *     cdef memoryview result = memoryview(o, flags, dtype_is_object)
17510  *     result.typeinfo = typeinfo             # <<<<<<<<<<<<<<
17511  *     return result
17512  *
17513  */
17514   __pyx_v_result->typeinfo = __pyx_v_typeinfo;
17515 
17516   /* "View.MemoryView":660
17517  *     cdef memoryview result = memoryview(o, flags, dtype_is_object)
17518  *     result.typeinfo = typeinfo
17519  *     return result             # <<<<<<<<<<<<<<
17520  *
17521  * @cname('__pyx_memoryview_check')
17522  */
17523   __Pyx_XDECREF(__pyx_r);
17524   __Pyx_INCREF(((PyObject *)__pyx_v_result));
17525   __pyx_r = ((PyObject *)__pyx_v_result);
17526   goto __pyx_L0;
17527 
17528   /* "View.MemoryView":657
17529  *
17530  * @cname('__pyx_memoryview_new')
17531  * cdef memoryview_cwrapper(object o, int flags, bint dtype_is_object, __Pyx_TypeInfo *typeinfo):             # <<<<<<<<<<<<<<
17532  *     cdef memoryview result = memoryview(o, flags, dtype_is_object)
17533  *     result.typeinfo = typeinfo
17534  */
17535 
17536   /* function exit code */
17537   __pyx_L1_error:;
17538   __Pyx_XDECREF(__pyx_t_1);
17539   __Pyx_XDECREF(__pyx_t_2);
17540   __Pyx_XDECREF(__pyx_t_3);
17541   __Pyx_AddTraceback("View.MemoryView.memoryview_cwrapper", __pyx_clineno, __pyx_lineno, __pyx_filename);
17542   __pyx_r = 0;
17543   __pyx_L0:;
17544   __Pyx_XDECREF((PyObject *)__pyx_v_result);
17545   __Pyx_XGIVEREF(__pyx_r);
17546   __Pyx_RefNannyFinishContext();
17547   return __pyx_r;
17548 }
17549 
17550 /* "View.MemoryView":663
17551  *
17552  * @cname('__pyx_memoryview_check')
17553  * cdef inline bint memoryview_check(object o):             # <<<<<<<<<<<<<<
17554  *     return isinstance(o, memoryview)
17555  *
17556  */
17557 
__pyx_memoryview_check(PyObject * __pyx_v_o)17558 static CYTHON_INLINE int __pyx_memoryview_check(PyObject *__pyx_v_o) {
17559   int __pyx_r;
17560   __Pyx_RefNannyDeclarations
17561   int __pyx_t_1;
17562   __Pyx_RefNannySetupContext("memoryview_check", 0);
17563 
17564   /* "View.MemoryView":664
17565  * @cname('__pyx_memoryview_check')
17566  * cdef inline bint memoryview_check(object o):
17567  *     return isinstance(o, memoryview)             # <<<<<<<<<<<<<<
17568  *
17569  * cdef tuple _unellipsify(object index, int ndim):
17570  */
17571   __pyx_t_1 = __Pyx_TypeCheck(__pyx_v_o, __pyx_memoryview_type);
17572   __pyx_r = __pyx_t_1;
17573   goto __pyx_L0;
17574 
17575   /* "View.MemoryView":663
17576  *
17577  * @cname('__pyx_memoryview_check')
17578  * cdef inline bint memoryview_check(object o):             # <<<<<<<<<<<<<<
17579  *     return isinstance(o, memoryview)
17580  *
17581  */
17582 
17583   /* function exit code */
17584   __pyx_L0:;
17585   __Pyx_RefNannyFinishContext();
17586   return __pyx_r;
17587 }
17588 
17589 /* "View.MemoryView":666
17590  *     return isinstance(o, memoryview)
17591  *
17592  * cdef tuple _unellipsify(object index, int ndim):             # <<<<<<<<<<<<<<
17593  *     """
17594  *     Replace all ellipses with full slices and fill incomplete indices with
17595  */
17596 
_unellipsify(PyObject * __pyx_v_index,int __pyx_v_ndim)17597 static PyObject *_unellipsify(PyObject *__pyx_v_index, int __pyx_v_ndim) {
17598   PyObject *__pyx_v_tup = NULL;
17599   PyObject *__pyx_v_result = NULL;
17600   int __pyx_v_have_slices;
17601   int __pyx_v_seen_ellipsis;
17602   CYTHON_UNUSED PyObject *__pyx_v_idx = NULL;
17603   PyObject *__pyx_v_item = NULL;
17604   Py_ssize_t __pyx_v_nslices;
17605   PyObject *__pyx_r = NULL;
17606   __Pyx_RefNannyDeclarations
17607   int __pyx_t_1;
17608   int __pyx_t_2;
17609   PyObject *__pyx_t_3 = NULL;
17610   PyObject *__pyx_t_4 = NULL;
17611   Py_ssize_t __pyx_t_5;
17612   PyObject *(*__pyx_t_6)(PyObject *);
17613   PyObject *__pyx_t_7 = NULL;
17614   Py_ssize_t __pyx_t_8;
17615   int __pyx_t_9;
17616   int __pyx_t_10;
17617   PyObject *__pyx_t_11 = NULL;
17618   int __pyx_lineno = 0;
17619   const char *__pyx_filename = NULL;
17620   int __pyx_clineno = 0;
17621   __Pyx_RefNannySetupContext("_unellipsify", 0);
17622 
17623   /* "View.MemoryView":671
17624  *     full slices.
17625  *     """
17626  *     if not isinstance(index, tuple):             # <<<<<<<<<<<<<<
17627  *         tup = (index,)
17628  *     else:
17629  */
17630   __pyx_t_1 = PyTuple_Check(__pyx_v_index);
17631   __pyx_t_2 = ((!(__pyx_t_1 != 0)) != 0);
17632   if (__pyx_t_2) {
17633 
17634     /* "View.MemoryView":672
17635  *     """
17636  *     if not isinstance(index, tuple):
17637  *         tup = (index,)             # <<<<<<<<<<<<<<
17638  *     else:
17639  *         tup = index
17640  */
17641     __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(3, 672, __pyx_L1_error)
17642     __Pyx_GOTREF(__pyx_t_3);
17643     __Pyx_INCREF(__pyx_v_index);
17644     __Pyx_GIVEREF(__pyx_v_index);
17645     PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_index);
17646     __pyx_v_tup = __pyx_t_3;
17647     __pyx_t_3 = 0;
17648 
17649     /* "View.MemoryView":671
17650  *     full slices.
17651  *     """
17652  *     if not isinstance(index, tuple):             # <<<<<<<<<<<<<<
17653  *         tup = (index,)
17654  *     else:
17655  */
17656     goto __pyx_L3;
17657   }
17658 
17659   /* "View.MemoryView":674
17660  *         tup = (index,)
17661  *     else:
17662  *         tup = index             # <<<<<<<<<<<<<<
17663  *
17664  *     result = []
17665  */
17666   /*else*/ {
17667     __Pyx_INCREF(__pyx_v_index);
17668     __pyx_v_tup = __pyx_v_index;
17669   }
17670   __pyx_L3:;
17671 
17672   /* "View.MemoryView":676
17673  *         tup = index
17674  *
17675  *     result = []             # <<<<<<<<<<<<<<
17676  *     have_slices = False
17677  *     seen_ellipsis = False
17678  */
17679   __pyx_t_3 = PyList_New(0); if (unlikely(!__pyx_t_3)) __PYX_ERR(3, 676, __pyx_L1_error)
17680   __Pyx_GOTREF(__pyx_t_3);
17681   __pyx_v_result = ((PyObject*)__pyx_t_3);
17682   __pyx_t_3 = 0;
17683 
17684   /* "View.MemoryView":677
17685  *
17686  *     result = []
17687  *     have_slices = False             # <<<<<<<<<<<<<<
17688  *     seen_ellipsis = False
17689  *     for idx, item in enumerate(tup):
17690  */
17691   __pyx_v_have_slices = 0;
17692 
17693   /* "View.MemoryView":678
17694  *     result = []
17695  *     have_slices = False
17696  *     seen_ellipsis = False             # <<<<<<<<<<<<<<
17697  *     for idx, item in enumerate(tup):
17698  *         if item is Ellipsis:
17699  */
17700   __pyx_v_seen_ellipsis = 0;
17701 
17702   /* "View.MemoryView":679
17703  *     have_slices = False
17704  *     seen_ellipsis = False
17705  *     for idx, item in enumerate(tup):             # <<<<<<<<<<<<<<
17706  *         if item is Ellipsis:
17707  *             if not seen_ellipsis:
17708  */
17709   __Pyx_INCREF(__pyx_int_0);
17710   __pyx_t_3 = __pyx_int_0;
17711   if (likely(PyList_CheckExact(__pyx_v_tup)) || PyTuple_CheckExact(__pyx_v_tup)) {
17712     __pyx_t_4 = __pyx_v_tup; __Pyx_INCREF(__pyx_t_4); __pyx_t_5 = 0;
17713     __pyx_t_6 = NULL;
17714   } else {
17715     __pyx_t_5 = -1; __pyx_t_4 = PyObject_GetIter(__pyx_v_tup); if (unlikely(!__pyx_t_4)) __PYX_ERR(3, 679, __pyx_L1_error)
17716     __Pyx_GOTREF(__pyx_t_4);
17717     __pyx_t_6 = Py_TYPE(__pyx_t_4)->tp_iternext; if (unlikely(!__pyx_t_6)) __PYX_ERR(3, 679, __pyx_L1_error)
17718   }
17719   for (;;) {
17720     if (likely(!__pyx_t_6)) {
17721       if (likely(PyList_CheckExact(__pyx_t_4))) {
17722         if (__pyx_t_5 >= PyList_GET_SIZE(__pyx_t_4)) break;
17723         #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
17724         __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)
17725         #else
17726         __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)
17727         __Pyx_GOTREF(__pyx_t_7);
17728         #endif
17729       } else {
17730         if (__pyx_t_5 >= PyTuple_GET_SIZE(__pyx_t_4)) break;
17731         #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
17732         __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)
17733         #else
17734         __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)
17735         __Pyx_GOTREF(__pyx_t_7);
17736         #endif
17737       }
17738     } else {
17739       __pyx_t_7 = __pyx_t_6(__pyx_t_4);
17740       if (unlikely(!__pyx_t_7)) {
17741         PyObject* exc_type = PyErr_Occurred();
17742         if (exc_type) {
17743           if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
17744           else __PYX_ERR(3, 679, __pyx_L1_error)
17745         }
17746         break;
17747       }
17748       __Pyx_GOTREF(__pyx_t_7);
17749     }
17750     __Pyx_XDECREF_SET(__pyx_v_item, __pyx_t_7);
17751     __pyx_t_7 = 0;
17752     __Pyx_INCREF(__pyx_t_3);
17753     __Pyx_XDECREF_SET(__pyx_v_idx, __pyx_t_3);
17754     __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)
17755     __Pyx_GOTREF(__pyx_t_7);
17756     __Pyx_DECREF(__pyx_t_3);
17757     __pyx_t_3 = __pyx_t_7;
17758     __pyx_t_7 = 0;
17759 
17760     /* "View.MemoryView":680
17761  *     seen_ellipsis = False
17762  *     for idx, item in enumerate(tup):
17763  *         if item is Ellipsis:             # <<<<<<<<<<<<<<
17764  *             if not seen_ellipsis:
17765  *                 result.extend([slice(None)] * (ndim - len(tup) + 1))
17766  */
17767     __pyx_t_2 = (__pyx_v_item == __pyx_builtin_Ellipsis);
17768     __pyx_t_1 = (__pyx_t_2 != 0);
17769     if (__pyx_t_1) {
17770 
17771       /* "View.MemoryView":681
17772  *     for idx, item in enumerate(tup):
17773  *         if item is Ellipsis:
17774  *             if not seen_ellipsis:             # <<<<<<<<<<<<<<
17775  *                 result.extend([slice(None)] * (ndim - len(tup) + 1))
17776  *                 seen_ellipsis = True
17777  */
17778       __pyx_t_1 = ((!(__pyx_v_seen_ellipsis != 0)) != 0);
17779       if (__pyx_t_1) {
17780 
17781         /* "View.MemoryView":682
17782  *         if item is Ellipsis:
17783  *             if not seen_ellipsis:
17784  *                 result.extend([slice(None)] * (ndim - len(tup) + 1))             # <<<<<<<<<<<<<<
17785  *                 seen_ellipsis = True
17786  *             else:
17787  */
17788         __pyx_t_8 = PyObject_Length(__pyx_v_tup); if (unlikely(__pyx_t_8 == ((Py_ssize_t)-1))) __PYX_ERR(3, 682, __pyx_L1_error)
17789         __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)
17790         __Pyx_GOTREF(__pyx_t_7);
17791         { Py_ssize_t __pyx_temp;
17792           for (__pyx_temp=0; __pyx_temp < ((__pyx_v_ndim - __pyx_t_8) + 1); __pyx_temp++) {
17793             __Pyx_INCREF(__pyx_slice__33);
17794             __Pyx_GIVEREF(__pyx_slice__33);
17795             PyList_SET_ITEM(__pyx_t_7, __pyx_temp, __pyx_slice__33);
17796           }
17797         }
17798         __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)
17799         __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
17800 
17801         /* "View.MemoryView":683
17802  *             if not seen_ellipsis:
17803  *                 result.extend([slice(None)] * (ndim - len(tup) + 1))
17804  *                 seen_ellipsis = True             # <<<<<<<<<<<<<<
17805  *             else:
17806  *                 result.append(slice(None))
17807  */
17808         __pyx_v_seen_ellipsis = 1;
17809 
17810         /* "View.MemoryView":681
17811  *     for idx, item in enumerate(tup):
17812  *         if item is Ellipsis:
17813  *             if not seen_ellipsis:             # <<<<<<<<<<<<<<
17814  *                 result.extend([slice(None)] * (ndim - len(tup) + 1))
17815  *                 seen_ellipsis = True
17816  */
17817         goto __pyx_L7;
17818       }
17819 
17820       /* "View.MemoryView":685
17821  *                 seen_ellipsis = True
17822  *             else:
17823  *                 result.append(slice(None))             # <<<<<<<<<<<<<<
17824  *             have_slices = True
17825  *         else:
17826  */
17827       /*else*/ {
17828         __pyx_t_9 = __Pyx_PyList_Append(__pyx_v_result, __pyx_slice__33); if (unlikely(__pyx_t_9 == ((int)-1))) __PYX_ERR(3, 685, __pyx_L1_error)
17829       }
17830       __pyx_L7:;
17831 
17832       /* "View.MemoryView":686
17833  *             else:
17834  *                 result.append(slice(None))
17835  *             have_slices = True             # <<<<<<<<<<<<<<
17836  *         else:
17837  *             if not isinstance(item, slice) and not PyIndex_Check(item):
17838  */
17839       __pyx_v_have_slices = 1;
17840 
17841       /* "View.MemoryView":680
17842  *     seen_ellipsis = False
17843  *     for idx, item in enumerate(tup):
17844  *         if item is Ellipsis:             # <<<<<<<<<<<<<<
17845  *             if not seen_ellipsis:
17846  *                 result.extend([slice(None)] * (ndim - len(tup) + 1))
17847  */
17848       goto __pyx_L6;
17849     }
17850 
17851     /* "View.MemoryView":688
17852  *             have_slices = True
17853  *         else:
17854  *             if not isinstance(item, slice) and not PyIndex_Check(item):             # <<<<<<<<<<<<<<
17855  *                 raise TypeError("Cannot index with type '%s'" % type(item))
17856  *
17857  */
17858     /*else*/ {
17859       __pyx_t_2 = PySlice_Check(__pyx_v_item);
17860       __pyx_t_10 = ((!(__pyx_t_2 != 0)) != 0);
17861       if (__pyx_t_10) {
17862       } else {
17863         __pyx_t_1 = __pyx_t_10;
17864         goto __pyx_L9_bool_binop_done;
17865       }
17866       __pyx_t_10 = ((!(PyIndex_Check(__pyx_v_item) != 0)) != 0);
17867       __pyx_t_1 = __pyx_t_10;
17868       __pyx_L9_bool_binop_done:;
17869       if (unlikely(__pyx_t_1)) {
17870 
17871         /* "View.MemoryView":689
17872  *         else:
17873  *             if not isinstance(item, slice) and not PyIndex_Check(item):
17874  *                 raise TypeError("Cannot index with type '%s'" % type(item))             # <<<<<<<<<<<<<<
17875  *
17876  *             have_slices = have_slices or isinstance(item, slice)
17877  */
17878         __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)
17879         __Pyx_GOTREF(__pyx_t_7);
17880         __pyx_t_11 = __Pyx_PyObject_CallOneArg(__pyx_builtin_TypeError, __pyx_t_7); if (unlikely(!__pyx_t_11)) __PYX_ERR(3, 689, __pyx_L1_error)
17881         __Pyx_GOTREF(__pyx_t_11);
17882         __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
17883         __Pyx_Raise(__pyx_t_11, 0, 0, 0);
17884         __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
17885         __PYX_ERR(3, 689, __pyx_L1_error)
17886 
17887         /* "View.MemoryView":688
17888  *             have_slices = True
17889  *         else:
17890  *             if not isinstance(item, slice) and not PyIndex_Check(item):             # <<<<<<<<<<<<<<
17891  *                 raise TypeError("Cannot index with type '%s'" % type(item))
17892  *
17893  */
17894       }
17895 
17896       /* "View.MemoryView":691
17897  *                 raise TypeError("Cannot index with type '%s'" % type(item))
17898  *
17899  *             have_slices = have_slices or isinstance(item, slice)             # <<<<<<<<<<<<<<
17900  *             result.append(item)
17901  *
17902  */
17903       __pyx_t_10 = (__pyx_v_have_slices != 0);
17904       if (!__pyx_t_10) {
17905       } else {
17906         __pyx_t_1 = __pyx_t_10;
17907         goto __pyx_L11_bool_binop_done;
17908       }
17909       __pyx_t_10 = PySlice_Check(__pyx_v_item);
17910       __pyx_t_2 = (__pyx_t_10 != 0);
17911       __pyx_t_1 = __pyx_t_2;
17912       __pyx_L11_bool_binop_done:;
17913       __pyx_v_have_slices = __pyx_t_1;
17914 
17915       /* "View.MemoryView":692
17916  *
17917  *             have_slices = have_slices or isinstance(item, slice)
17918  *             result.append(item)             # <<<<<<<<<<<<<<
17919  *
17920  *     nslices = ndim - len(result)
17921  */
17922       __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)
17923     }
17924     __pyx_L6:;
17925 
17926     /* "View.MemoryView":679
17927  *     have_slices = False
17928  *     seen_ellipsis = False
17929  *     for idx, item in enumerate(tup):             # <<<<<<<<<<<<<<
17930  *         if item is Ellipsis:
17931  *             if not seen_ellipsis:
17932  */
17933   }
17934   __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
17935   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
17936 
17937   /* "View.MemoryView":694
17938  *             result.append(item)
17939  *
17940  *     nslices = ndim - len(result)             # <<<<<<<<<<<<<<
17941  *     if nslices:
17942  *         result.extend([slice(None)] * nslices)
17943  */
17944   __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)
17945   __pyx_v_nslices = (__pyx_v_ndim - __pyx_t_5);
17946 
17947   /* "View.MemoryView":695
17948  *
17949  *     nslices = ndim - len(result)
17950  *     if nslices:             # <<<<<<<<<<<<<<
17951  *         result.extend([slice(None)] * nslices)
17952  *
17953  */
17954   __pyx_t_1 = (__pyx_v_nslices != 0);
17955   if (__pyx_t_1) {
17956 
17957     /* "View.MemoryView":696
17958  *     nslices = ndim - len(result)
17959  *     if nslices:
17960  *         result.extend([slice(None)] * nslices)             # <<<<<<<<<<<<<<
17961  *
17962  *     return have_slices or nslices, tuple(result)
17963  */
17964     __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)
17965     __Pyx_GOTREF(__pyx_t_3);
17966     { Py_ssize_t __pyx_temp;
17967       for (__pyx_temp=0; __pyx_temp < __pyx_v_nslices; __pyx_temp++) {
17968         __Pyx_INCREF(__pyx_slice__33);
17969         __Pyx_GIVEREF(__pyx_slice__33);
17970         PyList_SET_ITEM(__pyx_t_3, __pyx_temp, __pyx_slice__33);
17971       }
17972     }
17973     __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)
17974     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
17975 
17976     /* "View.MemoryView":695
17977  *
17978  *     nslices = ndim - len(result)
17979  *     if nslices:             # <<<<<<<<<<<<<<
17980  *         result.extend([slice(None)] * nslices)
17981  *
17982  */
17983   }
17984 
17985   /* "View.MemoryView":698
17986  *         result.extend([slice(None)] * nslices)
17987  *
17988  *     return have_slices or nslices, tuple(result)             # <<<<<<<<<<<<<<
17989  *
17990  * cdef assert_direct_dimensions(Py_ssize_t *suboffsets, int ndim):
17991  */
17992   __Pyx_XDECREF(__pyx_r);
17993   if (!__pyx_v_have_slices) {
17994   } else {
17995     __pyx_t_4 = __Pyx_PyBool_FromLong(__pyx_v_have_slices); if (unlikely(!__pyx_t_4)) __PYX_ERR(3, 698, __pyx_L1_error)
17996     __Pyx_GOTREF(__pyx_t_4);
17997     __pyx_t_3 = __pyx_t_4;
17998     __pyx_t_4 = 0;
17999     goto __pyx_L14_bool_binop_done;
18000   }
18001   __pyx_t_4 = PyInt_FromSsize_t(__pyx_v_nslices); if (unlikely(!__pyx_t_4)) __PYX_ERR(3, 698, __pyx_L1_error)
18002   __Pyx_GOTREF(__pyx_t_4);
18003   __pyx_t_3 = __pyx_t_4;
18004   __pyx_t_4 = 0;
18005   __pyx_L14_bool_binop_done:;
18006   __pyx_t_4 = PyList_AsTuple(__pyx_v_result); if (unlikely(!__pyx_t_4)) __PYX_ERR(3, 698, __pyx_L1_error)
18007   __Pyx_GOTREF(__pyx_t_4);
18008   __pyx_t_11 = PyTuple_New(2); if (unlikely(!__pyx_t_11)) __PYX_ERR(3, 698, __pyx_L1_error)
18009   __Pyx_GOTREF(__pyx_t_11);
18010   __Pyx_GIVEREF(__pyx_t_3);
18011   PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_t_3);
18012   __Pyx_GIVEREF(__pyx_t_4);
18013   PyTuple_SET_ITEM(__pyx_t_11, 1, __pyx_t_4);
18014   __pyx_t_3 = 0;
18015   __pyx_t_4 = 0;
18016   __pyx_r = ((PyObject*)__pyx_t_11);
18017   __pyx_t_11 = 0;
18018   goto __pyx_L0;
18019 
18020   /* "View.MemoryView":666
18021  *     return isinstance(o, memoryview)
18022  *
18023  * cdef tuple _unellipsify(object index, int ndim):             # <<<<<<<<<<<<<<
18024  *     """
18025  *     Replace all ellipses with full slices and fill incomplete indices with
18026  */
18027 
18028   /* function exit code */
18029   __pyx_L1_error:;
18030   __Pyx_XDECREF(__pyx_t_3);
18031   __Pyx_XDECREF(__pyx_t_4);
18032   __Pyx_XDECREF(__pyx_t_7);
18033   __Pyx_XDECREF(__pyx_t_11);
18034   __Pyx_AddTraceback("View.MemoryView._unellipsify", __pyx_clineno, __pyx_lineno, __pyx_filename);
18035   __pyx_r = 0;
18036   __pyx_L0:;
18037   __Pyx_XDECREF(__pyx_v_tup);
18038   __Pyx_XDECREF(__pyx_v_result);
18039   __Pyx_XDECREF(__pyx_v_idx);
18040   __Pyx_XDECREF(__pyx_v_item);
18041   __Pyx_XGIVEREF(__pyx_r);
18042   __Pyx_RefNannyFinishContext();
18043   return __pyx_r;
18044 }
18045 
18046 /* "View.MemoryView":700
18047  *     return have_slices or nslices, tuple(result)
18048  *
18049  * cdef assert_direct_dimensions(Py_ssize_t *suboffsets, int ndim):             # <<<<<<<<<<<<<<
18050  *     for suboffset in suboffsets[:ndim]:
18051  *         if suboffset >= 0:
18052  */
18053 
assert_direct_dimensions(Py_ssize_t * __pyx_v_suboffsets,int __pyx_v_ndim)18054 static PyObject *assert_direct_dimensions(Py_ssize_t *__pyx_v_suboffsets, int __pyx_v_ndim) {
18055   Py_ssize_t __pyx_v_suboffset;
18056   PyObject *__pyx_r = NULL;
18057   __Pyx_RefNannyDeclarations
18058   Py_ssize_t *__pyx_t_1;
18059   Py_ssize_t *__pyx_t_2;
18060   Py_ssize_t *__pyx_t_3;
18061   int __pyx_t_4;
18062   PyObject *__pyx_t_5 = NULL;
18063   int __pyx_lineno = 0;
18064   const char *__pyx_filename = NULL;
18065   int __pyx_clineno = 0;
18066   __Pyx_RefNannySetupContext("assert_direct_dimensions", 0);
18067 
18068   /* "View.MemoryView":701
18069  *
18070  * cdef assert_direct_dimensions(Py_ssize_t *suboffsets, int ndim):
18071  *     for suboffset in suboffsets[:ndim]:             # <<<<<<<<<<<<<<
18072  *         if suboffset >= 0:
18073  *             raise ValueError("Indirect dimensions not supported")
18074  */
18075   __pyx_t_2 = (__pyx_v_suboffsets + __pyx_v_ndim);
18076   for (__pyx_t_3 = __pyx_v_suboffsets; __pyx_t_3 < __pyx_t_2; __pyx_t_3++) {
18077     __pyx_t_1 = __pyx_t_3;
18078     __pyx_v_suboffset = (__pyx_t_1[0]);
18079 
18080     /* "View.MemoryView":702
18081  * cdef assert_direct_dimensions(Py_ssize_t *suboffsets, int ndim):
18082  *     for suboffset in suboffsets[:ndim]:
18083  *         if suboffset >= 0:             # <<<<<<<<<<<<<<
18084  *             raise ValueError("Indirect dimensions not supported")
18085  *
18086  */
18087     __pyx_t_4 = ((__pyx_v_suboffset >= 0) != 0);
18088     if (unlikely(__pyx_t_4)) {
18089 
18090       /* "View.MemoryView":703
18091  *     for suboffset in suboffsets[:ndim]:
18092  *         if suboffset >= 0:
18093  *             raise ValueError("Indirect dimensions not supported")             # <<<<<<<<<<<<<<
18094  *
18095  *
18096  */
18097       __pyx_t_5 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__34, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(3, 703, __pyx_L1_error)
18098       __Pyx_GOTREF(__pyx_t_5);
18099       __Pyx_Raise(__pyx_t_5, 0, 0, 0);
18100       __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
18101       __PYX_ERR(3, 703, __pyx_L1_error)
18102 
18103       /* "View.MemoryView":702
18104  * cdef assert_direct_dimensions(Py_ssize_t *suboffsets, int ndim):
18105  *     for suboffset in suboffsets[:ndim]:
18106  *         if suboffset >= 0:             # <<<<<<<<<<<<<<
18107  *             raise ValueError("Indirect dimensions not supported")
18108  *
18109  */
18110     }
18111   }
18112 
18113   /* "View.MemoryView":700
18114  *     return have_slices or nslices, tuple(result)
18115  *
18116  * cdef assert_direct_dimensions(Py_ssize_t *suboffsets, int ndim):             # <<<<<<<<<<<<<<
18117  *     for suboffset in suboffsets[:ndim]:
18118  *         if suboffset >= 0:
18119  */
18120 
18121   /* function exit code */
18122   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
18123   goto __pyx_L0;
18124   __pyx_L1_error:;
18125   __Pyx_XDECREF(__pyx_t_5);
18126   __Pyx_AddTraceback("View.MemoryView.assert_direct_dimensions", __pyx_clineno, __pyx_lineno, __pyx_filename);
18127   __pyx_r = 0;
18128   __pyx_L0:;
18129   __Pyx_XGIVEREF(__pyx_r);
18130   __Pyx_RefNannyFinishContext();
18131   return __pyx_r;
18132 }
18133 
18134 /* "View.MemoryView":710
18135  *
18136  * @cname('__pyx_memview_slice')
18137  * cdef memoryview memview_slice(memoryview memview, object indices):             # <<<<<<<<<<<<<<
18138  *     cdef int new_ndim = 0, suboffset_dim = -1, dim
18139  *     cdef bint negative_step
18140  */
18141 
__pyx_memview_slice(struct __pyx_memoryview_obj * __pyx_v_memview,PyObject * __pyx_v_indices)18142 static struct __pyx_memoryview_obj *__pyx_memview_slice(struct __pyx_memoryview_obj *__pyx_v_memview, PyObject *__pyx_v_indices) {
18143   int __pyx_v_new_ndim;
18144   int __pyx_v_suboffset_dim;
18145   int __pyx_v_dim;
18146   __Pyx_memviewslice __pyx_v_src;
18147   __Pyx_memviewslice __pyx_v_dst;
18148   __Pyx_memviewslice *__pyx_v_p_src;
18149   struct __pyx_memoryviewslice_obj *__pyx_v_memviewsliceobj = 0;
18150   __Pyx_memviewslice *__pyx_v_p_dst;
18151   int *__pyx_v_p_suboffset_dim;
18152   Py_ssize_t __pyx_v_start;
18153   Py_ssize_t __pyx_v_stop;
18154   Py_ssize_t __pyx_v_step;
18155   int __pyx_v_have_start;
18156   int __pyx_v_have_stop;
18157   int __pyx_v_have_step;
18158   PyObject *__pyx_v_index = NULL;
18159   struct __pyx_memoryview_obj *__pyx_r = NULL;
18160   __Pyx_RefNannyDeclarations
18161   int __pyx_t_1;
18162   int __pyx_t_2;
18163   PyObject *__pyx_t_3 = NULL;
18164   struct __pyx_memoryview_obj *__pyx_t_4;
18165   char *__pyx_t_5;
18166   int __pyx_t_6;
18167   Py_ssize_t __pyx_t_7;
18168   PyObject *(*__pyx_t_8)(PyObject *);
18169   PyObject *__pyx_t_9 = NULL;
18170   Py_ssize_t __pyx_t_10;
18171   int __pyx_t_11;
18172   Py_ssize_t __pyx_t_12;
18173   int __pyx_lineno = 0;
18174   const char *__pyx_filename = NULL;
18175   int __pyx_clineno = 0;
18176   __Pyx_RefNannySetupContext("memview_slice", 0);
18177 
18178   /* "View.MemoryView":711
18179  * @cname('__pyx_memview_slice')
18180  * cdef memoryview memview_slice(memoryview memview, object indices):
18181  *     cdef int new_ndim = 0, suboffset_dim = -1, dim             # <<<<<<<<<<<<<<
18182  *     cdef bint negative_step
18183  *     cdef __Pyx_memviewslice src, dst
18184  */
18185   __pyx_v_new_ndim = 0;
18186   __pyx_v_suboffset_dim = -1;
18187 
18188   /* "View.MemoryView":718
18189  *
18190  *
18191  *     memset(&dst, 0, sizeof(dst))             # <<<<<<<<<<<<<<
18192  *
18193  *     cdef _memoryviewslice memviewsliceobj
18194  */
18195   (void)(memset((&__pyx_v_dst), 0, (sizeof(__pyx_v_dst))));
18196 
18197   /* "View.MemoryView":722
18198  *     cdef _memoryviewslice memviewsliceobj
18199  *
18200  *     assert memview.view.ndim > 0             # <<<<<<<<<<<<<<
18201  *
18202  *     if isinstance(memview, _memoryviewslice):
18203  */
18204   #ifndef CYTHON_WITHOUT_ASSERTIONS
18205   if (unlikely(!Py_OptimizeFlag)) {
18206     if (unlikely(!((__pyx_v_memview->view.ndim > 0) != 0))) {
18207       PyErr_SetNone(PyExc_AssertionError);
18208       __PYX_ERR(3, 722, __pyx_L1_error)
18209     }
18210   }
18211   #endif
18212 
18213   /* "View.MemoryView":724
18214  *     assert memview.view.ndim > 0
18215  *
18216  *     if isinstance(memview, _memoryviewslice):             # <<<<<<<<<<<<<<
18217  *         memviewsliceobj = memview
18218  *         p_src = &memviewsliceobj.from_slice
18219  */
18220   __pyx_t_1 = __Pyx_TypeCheck(((PyObject *)__pyx_v_memview), __pyx_memoryviewslice_type);
18221   __pyx_t_2 = (__pyx_t_1 != 0);
18222   if (__pyx_t_2) {
18223 
18224     /* "View.MemoryView":725
18225  *
18226  *     if isinstance(memview, _memoryviewslice):
18227  *         memviewsliceobj = memview             # <<<<<<<<<<<<<<
18228  *         p_src = &memviewsliceobj.from_slice
18229  *     else:
18230  */
18231     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)
18232     __pyx_t_3 = ((PyObject *)__pyx_v_memview);
18233     __Pyx_INCREF(__pyx_t_3);
18234     __pyx_v_memviewsliceobj = ((struct __pyx_memoryviewslice_obj *)__pyx_t_3);
18235     __pyx_t_3 = 0;
18236 
18237     /* "View.MemoryView":726
18238  *     if isinstance(memview, _memoryviewslice):
18239  *         memviewsliceobj = memview
18240  *         p_src = &memviewsliceobj.from_slice             # <<<<<<<<<<<<<<
18241  *     else:
18242  *         slice_copy(memview, &src)
18243  */
18244     __pyx_v_p_src = (&__pyx_v_memviewsliceobj->from_slice);
18245 
18246     /* "View.MemoryView":724
18247  *     assert memview.view.ndim > 0
18248  *
18249  *     if isinstance(memview, _memoryviewslice):             # <<<<<<<<<<<<<<
18250  *         memviewsliceobj = memview
18251  *         p_src = &memviewsliceobj.from_slice
18252  */
18253     goto __pyx_L3;
18254   }
18255 
18256   /* "View.MemoryView":728
18257  *         p_src = &memviewsliceobj.from_slice
18258  *     else:
18259  *         slice_copy(memview, &src)             # <<<<<<<<<<<<<<
18260  *         p_src = &src
18261  *
18262  */
18263   /*else*/ {
18264     __pyx_memoryview_slice_copy(__pyx_v_memview, (&__pyx_v_src));
18265 
18266     /* "View.MemoryView":729
18267  *     else:
18268  *         slice_copy(memview, &src)
18269  *         p_src = &src             # <<<<<<<<<<<<<<
18270  *
18271  *
18272  */
18273     __pyx_v_p_src = (&__pyx_v_src);
18274   }
18275   __pyx_L3:;
18276 
18277   /* "View.MemoryView":735
18278  *
18279  *
18280  *     dst.memview = p_src.memview             # <<<<<<<<<<<<<<
18281  *     dst.data = p_src.data
18282  *
18283  */
18284   __pyx_t_4 = __pyx_v_p_src->memview;
18285   __pyx_v_dst.memview = __pyx_t_4;
18286 
18287   /* "View.MemoryView":736
18288  *
18289  *     dst.memview = p_src.memview
18290  *     dst.data = p_src.data             # <<<<<<<<<<<<<<
18291  *
18292  *
18293  */
18294   __pyx_t_5 = __pyx_v_p_src->data;
18295   __pyx_v_dst.data = __pyx_t_5;
18296 
18297   /* "View.MemoryView":741
18298  *
18299  *
18300  *     cdef __Pyx_memviewslice *p_dst = &dst             # <<<<<<<<<<<<<<
18301  *     cdef int *p_suboffset_dim = &suboffset_dim
18302  *     cdef Py_ssize_t start, stop, step
18303  */
18304   __pyx_v_p_dst = (&__pyx_v_dst);
18305 
18306   /* "View.MemoryView":742
18307  *
18308  *     cdef __Pyx_memviewslice *p_dst = &dst
18309  *     cdef int *p_suboffset_dim = &suboffset_dim             # <<<<<<<<<<<<<<
18310  *     cdef Py_ssize_t start, stop, step
18311  *     cdef bint have_start, have_stop, have_step
18312  */
18313   __pyx_v_p_suboffset_dim = (&__pyx_v_suboffset_dim);
18314 
18315   /* "View.MemoryView":746
18316  *     cdef bint have_start, have_stop, have_step
18317  *
18318  *     for dim, index in enumerate(indices):             # <<<<<<<<<<<<<<
18319  *         if PyIndex_Check(index):
18320  *             slice_memviewslice(
18321  */
18322   __pyx_t_6 = 0;
18323   if (likely(PyList_CheckExact(__pyx_v_indices)) || PyTuple_CheckExact(__pyx_v_indices)) {
18324     __pyx_t_3 = __pyx_v_indices; __Pyx_INCREF(__pyx_t_3); __pyx_t_7 = 0;
18325     __pyx_t_8 = NULL;
18326   } else {
18327     __pyx_t_7 = -1; __pyx_t_3 = PyObject_GetIter(__pyx_v_indices); if (unlikely(!__pyx_t_3)) __PYX_ERR(3, 746, __pyx_L1_error)
18328     __Pyx_GOTREF(__pyx_t_3);
18329     __pyx_t_8 = Py_TYPE(__pyx_t_3)->tp_iternext; if (unlikely(!__pyx_t_8)) __PYX_ERR(3, 746, __pyx_L1_error)
18330   }
18331   for (;;) {
18332     if (likely(!__pyx_t_8)) {
18333       if (likely(PyList_CheckExact(__pyx_t_3))) {
18334         if (__pyx_t_7 >= PyList_GET_SIZE(__pyx_t_3)) break;
18335         #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
18336         __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)
18337         #else
18338         __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)
18339         __Pyx_GOTREF(__pyx_t_9);
18340         #endif
18341       } else {
18342         if (__pyx_t_7 >= PyTuple_GET_SIZE(__pyx_t_3)) break;
18343         #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
18344         __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)
18345         #else
18346         __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)
18347         __Pyx_GOTREF(__pyx_t_9);
18348         #endif
18349       }
18350     } else {
18351       __pyx_t_9 = __pyx_t_8(__pyx_t_3);
18352       if (unlikely(!__pyx_t_9)) {
18353         PyObject* exc_type = PyErr_Occurred();
18354         if (exc_type) {
18355           if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
18356           else __PYX_ERR(3, 746, __pyx_L1_error)
18357         }
18358         break;
18359       }
18360       __Pyx_GOTREF(__pyx_t_9);
18361     }
18362     __Pyx_XDECREF_SET(__pyx_v_index, __pyx_t_9);
18363     __pyx_t_9 = 0;
18364     __pyx_v_dim = __pyx_t_6;
18365     __pyx_t_6 = (__pyx_t_6 + 1);
18366 
18367     /* "View.MemoryView":747
18368  *
18369  *     for dim, index in enumerate(indices):
18370  *         if PyIndex_Check(index):             # <<<<<<<<<<<<<<
18371  *             slice_memviewslice(
18372  *                 p_dst, p_src.shape[dim], p_src.strides[dim], p_src.suboffsets[dim],
18373  */
18374     __pyx_t_2 = (PyIndex_Check(__pyx_v_index) != 0);
18375     if (__pyx_t_2) {
18376 
18377       /* "View.MemoryView":751
18378  *                 p_dst, p_src.shape[dim], p_src.strides[dim], p_src.suboffsets[dim],
18379  *                 dim, new_ndim, p_suboffset_dim,
18380  *                 index, 0, 0, # start, stop, step             # <<<<<<<<<<<<<<
18381  *                 0, 0, 0, # have_{start,stop,step}
18382  *                 False)
18383  */
18384       __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)
18385 
18386       /* "View.MemoryView":748
18387  *     for dim, index in enumerate(indices):
18388  *         if PyIndex_Check(index):
18389  *             slice_memviewslice(             # <<<<<<<<<<<<<<
18390  *                 p_dst, p_src.shape[dim], p_src.strides[dim], p_src.suboffsets[dim],
18391  *                 dim, new_ndim, p_suboffset_dim,
18392  */
18393       __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)
18394 
18395       /* "View.MemoryView":747
18396  *
18397  *     for dim, index in enumerate(indices):
18398  *         if PyIndex_Check(index):             # <<<<<<<<<<<<<<
18399  *             slice_memviewslice(
18400  *                 p_dst, p_src.shape[dim], p_src.strides[dim], p_src.suboffsets[dim],
18401  */
18402       goto __pyx_L6;
18403     }
18404 
18405     /* "View.MemoryView":754
18406  *                 0, 0, 0, # have_{start,stop,step}
18407  *                 False)
18408  *         elif index is None:             # <<<<<<<<<<<<<<
18409  *             p_dst.shape[new_ndim] = 1
18410  *             p_dst.strides[new_ndim] = 0
18411  */
18412     __pyx_t_2 = (__pyx_v_index == Py_None);
18413     __pyx_t_1 = (__pyx_t_2 != 0);
18414     if (__pyx_t_1) {
18415 
18416       /* "View.MemoryView":755
18417  *                 False)
18418  *         elif index is None:
18419  *             p_dst.shape[new_ndim] = 1             # <<<<<<<<<<<<<<
18420  *             p_dst.strides[new_ndim] = 0
18421  *             p_dst.suboffsets[new_ndim] = -1
18422  */
18423       (__pyx_v_p_dst->shape[__pyx_v_new_ndim]) = 1;
18424 
18425       /* "View.MemoryView":756
18426  *         elif index is None:
18427  *             p_dst.shape[new_ndim] = 1
18428  *             p_dst.strides[new_ndim] = 0             # <<<<<<<<<<<<<<
18429  *             p_dst.suboffsets[new_ndim] = -1
18430  *             new_ndim += 1
18431  */
18432       (__pyx_v_p_dst->strides[__pyx_v_new_ndim]) = 0;
18433 
18434       /* "View.MemoryView":757
18435  *             p_dst.shape[new_ndim] = 1
18436  *             p_dst.strides[new_ndim] = 0
18437  *             p_dst.suboffsets[new_ndim] = -1             # <<<<<<<<<<<<<<
18438  *             new_ndim += 1
18439  *         else:
18440  */
18441       (__pyx_v_p_dst->suboffsets[__pyx_v_new_ndim]) = -1L;
18442 
18443       /* "View.MemoryView":758
18444  *             p_dst.strides[new_ndim] = 0
18445  *             p_dst.suboffsets[new_ndim] = -1
18446  *             new_ndim += 1             # <<<<<<<<<<<<<<
18447  *         else:
18448  *             start = index.start or 0
18449  */
18450       __pyx_v_new_ndim = (__pyx_v_new_ndim + 1);
18451 
18452       /* "View.MemoryView":754
18453  *                 0, 0, 0, # have_{start,stop,step}
18454  *                 False)
18455  *         elif index is None:             # <<<<<<<<<<<<<<
18456  *             p_dst.shape[new_ndim] = 1
18457  *             p_dst.strides[new_ndim] = 0
18458  */
18459       goto __pyx_L6;
18460     }
18461 
18462     /* "View.MemoryView":760
18463  *             new_ndim += 1
18464  *         else:
18465  *             start = index.start or 0             # <<<<<<<<<<<<<<
18466  *             stop = index.stop or 0
18467  *             step = index.step or 0
18468  */
18469     /*else*/ {
18470       __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)
18471       __Pyx_GOTREF(__pyx_t_9);
18472       __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_9); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(3, 760, __pyx_L1_error)
18473       if (!__pyx_t_1) {
18474         __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
18475       } else {
18476         __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)
18477         __pyx_t_10 = __pyx_t_12;
18478         __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
18479         goto __pyx_L7_bool_binop_done;
18480       }
18481       __pyx_t_10 = 0;
18482       __pyx_L7_bool_binop_done:;
18483       __pyx_v_start = __pyx_t_10;
18484 
18485       /* "View.MemoryView":761
18486  *         else:
18487  *             start = index.start or 0
18488  *             stop = index.stop or 0             # <<<<<<<<<<<<<<
18489  *             step = index.step or 0
18490  *
18491  */
18492       __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)
18493       __Pyx_GOTREF(__pyx_t_9);
18494       __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_9); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(3, 761, __pyx_L1_error)
18495       if (!__pyx_t_1) {
18496         __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
18497       } else {
18498         __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)
18499         __pyx_t_10 = __pyx_t_12;
18500         __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
18501         goto __pyx_L9_bool_binop_done;
18502       }
18503       __pyx_t_10 = 0;
18504       __pyx_L9_bool_binop_done:;
18505       __pyx_v_stop = __pyx_t_10;
18506 
18507       /* "View.MemoryView":762
18508  *             start = index.start or 0
18509  *             stop = index.stop or 0
18510  *             step = index.step or 0             # <<<<<<<<<<<<<<
18511  *
18512  *             have_start = index.start is not None
18513  */
18514       __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)
18515       __Pyx_GOTREF(__pyx_t_9);
18516       __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_9); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(3, 762, __pyx_L1_error)
18517       if (!__pyx_t_1) {
18518         __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
18519       } else {
18520         __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)
18521         __pyx_t_10 = __pyx_t_12;
18522         __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
18523         goto __pyx_L11_bool_binop_done;
18524       }
18525       __pyx_t_10 = 0;
18526       __pyx_L11_bool_binop_done:;
18527       __pyx_v_step = __pyx_t_10;
18528 
18529       /* "View.MemoryView":764
18530  *             step = index.step or 0
18531  *
18532  *             have_start = index.start is not None             # <<<<<<<<<<<<<<
18533  *             have_stop = index.stop is not None
18534  *             have_step = index.step is not None
18535  */
18536       __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)
18537       __Pyx_GOTREF(__pyx_t_9);
18538       __pyx_t_1 = (__pyx_t_9 != Py_None);
18539       __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
18540       __pyx_v_have_start = __pyx_t_1;
18541 
18542       /* "View.MemoryView":765
18543  *
18544  *             have_start = index.start is not None
18545  *             have_stop = index.stop is not None             # <<<<<<<<<<<<<<
18546  *             have_step = index.step is not None
18547  *
18548  */
18549       __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)
18550       __Pyx_GOTREF(__pyx_t_9);
18551       __pyx_t_1 = (__pyx_t_9 != Py_None);
18552       __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
18553       __pyx_v_have_stop = __pyx_t_1;
18554 
18555       /* "View.MemoryView":766
18556  *             have_start = index.start is not None
18557  *             have_stop = index.stop is not None
18558  *             have_step = index.step is not None             # <<<<<<<<<<<<<<
18559  *
18560  *             slice_memviewslice(
18561  */
18562       __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)
18563       __Pyx_GOTREF(__pyx_t_9);
18564       __pyx_t_1 = (__pyx_t_9 != Py_None);
18565       __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
18566       __pyx_v_have_step = __pyx_t_1;
18567 
18568       /* "View.MemoryView":768
18569  *             have_step = index.step is not None
18570  *
18571  *             slice_memviewslice(             # <<<<<<<<<<<<<<
18572  *                 p_dst, p_src.shape[dim], p_src.strides[dim], p_src.suboffsets[dim],
18573  *                 dim, new_ndim, p_suboffset_dim,
18574  */
18575       __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)
18576 
18577       /* "View.MemoryView":774
18578  *                 have_start, have_stop, have_step,
18579  *                 True)
18580  *             new_ndim += 1             # <<<<<<<<<<<<<<
18581  *
18582  *     if isinstance(memview, _memoryviewslice):
18583  */
18584       __pyx_v_new_ndim = (__pyx_v_new_ndim + 1);
18585     }
18586     __pyx_L6:;
18587 
18588     /* "View.MemoryView":746
18589  *     cdef bint have_start, have_stop, have_step
18590  *
18591  *     for dim, index in enumerate(indices):             # <<<<<<<<<<<<<<
18592  *         if PyIndex_Check(index):
18593  *             slice_memviewslice(
18594  */
18595   }
18596   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
18597 
18598   /* "View.MemoryView":776
18599  *             new_ndim += 1
18600  *
18601  *     if isinstance(memview, _memoryviewslice):             # <<<<<<<<<<<<<<
18602  *         return memoryview_fromslice(dst, new_ndim,
18603  *                                     memviewsliceobj.to_object_func,
18604  */
18605   __pyx_t_1 = __Pyx_TypeCheck(((PyObject *)__pyx_v_memview), __pyx_memoryviewslice_type);
18606   __pyx_t_2 = (__pyx_t_1 != 0);
18607   if (__pyx_t_2) {
18608 
18609     /* "View.MemoryView":777
18610  *
18611  *     if isinstance(memview, _memoryviewslice):
18612  *         return memoryview_fromslice(dst, new_ndim,             # <<<<<<<<<<<<<<
18613  *                                     memviewsliceobj.to_object_func,
18614  *                                     memviewsliceobj.to_dtype_func,
18615  */
18616     __Pyx_XDECREF(((PyObject *)__pyx_r));
18617 
18618     /* "View.MemoryView":778
18619  *     if isinstance(memview, _memoryviewslice):
18620  *         return memoryview_fromslice(dst, new_ndim,
18621  *                                     memviewsliceobj.to_object_func,             # <<<<<<<<<<<<<<
18622  *                                     memviewsliceobj.to_dtype_func,
18623  *                                     memview.dtype_is_object)
18624  */
18625     if (unlikely(!__pyx_v_memviewsliceobj)) { __Pyx_RaiseUnboundLocalError("memviewsliceobj"); __PYX_ERR(3, 778, __pyx_L1_error) }
18626 
18627     /* "View.MemoryView":779
18628  *         return memoryview_fromslice(dst, new_ndim,
18629  *                                     memviewsliceobj.to_object_func,
18630  *                                     memviewsliceobj.to_dtype_func,             # <<<<<<<<<<<<<<
18631  *                                     memview.dtype_is_object)
18632  *     else:
18633  */
18634     if (unlikely(!__pyx_v_memviewsliceobj)) { __Pyx_RaiseUnboundLocalError("memviewsliceobj"); __PYX_ERR(3, 779, __pyx_L1_error) }
18635 
18636     /* "View.MemoryView":777
18637  *
18638  *     if isinstance(memview, _memoryviewslice):
18639  *         return memoryview_fromslice(dst, new_ndim,             # <<<<<<<<<<<<<<
18640  *                                     memviewsliceobj.to_object_func,
18641  *                                     memviewsliceobj.to_dtype_func,
18642  */
18643     __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)
18644     __Pyx_GOTREF(__pyx_t_3);
18645     if (!(likely(((__pyx_t_3) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_3, __pyx_memoryview_type))))) __PYX_ERR(3, 777, __pyx_L1_error)
18646     __pyx_r = ((struct __pyx_memoryview_obj *)__pyx_t_3);
18647     __pyx_t_3 = 0;
18648     goto __pyx_L0;
18649 
18650     /* "View.MemoryView":776
18651  *             new_ndim += 1
18652  *
18653  *     if isinstance(memview, _memoryviewslice):             # <<<<<<<<<<<<<<
18654  *         return memoryview_fromslice(dst, new_ndim,
18655  *                                     memviewsliceobj.to_object_func,
18656  */
18657   }
18658 
18659   /* "View.MemoryView":782
18660  *                                     memview.dtype_is_object)
18661  *     else:
18662  *         return memoryview_fromslice(dst, new_ndim, NULL, NULL,             # <<<<<<<<<<<<<<
18663  *                                     memview.dtype_is_object)
18664  *
18665  */
18666   /*else*/ {
18667     __Pyx_XDECREF(((PyObject *)__pyx_r));
18668 
18669     /* "View.MemoryView":783
18670  *     else:
18671  *         return memoryview_fromslice(dst, new_ndim, NULL, NULL,
18672  *                                     memview.dtype_is_object)             # <<<<<<<<<<<<<<
18673  *
18674  *
18675  */
18676     __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)
18677     __Pyx_GOTREF(__pyx_t_3);
18678 
18679     /* "View.MemoryView":782
18680  *                                     memview.dtype_is_object)
18681  *     else:
18682  *         return memoryview_fromslice(dst, new_ndim, NULL, NULL,             # <<<<<<<<<<<<<<
18683  *                                     memview.dtype_is_object)
18684  *
18685  */
18686     if (!(likely(((__pyx_t_3) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_3, __pyx_memoryview_type))))) __PYX_ERR(3, 782, __pyx_L1_error)
18687     __pyx_r = ((struct __pyx_memoryview_obj *)__pyx_t_3);
18688     __pyx_t_3 = 0;
18689     goto __pyx_L0;
18690   }
18691 
18692   /* "View.MemoryView":710
18693  *
18694  * @cname('__pyx_memview_slice')
18695  * cdef memoryview memview_slice(memoryview memview, object indices):             # <<<<<<<<<<<<<<
18696  *     cdef int new_ndim = 0, suboffset_dim = -1, dim
18697  *     cdef bint negative_step
18698  */
18699 
18700   /* function exit code */
18701   __pyx_L1_error:;
18702   __Pyx_XDECREF(__pyx_t_3);
18703   __Pyx_XDECREF(__pyx_t_9);
18704   __Pyx_AddTraceback("View.MemoryView.memview_slice", __pyx_clineno, __pyx_lineno, __pyx_filename);
18705   __pyx_r = 0;
18706   __pyx_L0:;
18707   __Pyx_XDECREF((PyObject *)__pyx_v_memviewsliceobj);
18708   __Pyx_XDECREF(__pyx_v_index);
18709   __Pyx_XGIVEREF((PyObject *)__pyx_r);
18710   __Pyx_RefNannyFinishContext();
18711   return __pyx_r;
18712 }
18713 
18714 /* "View.MemoryView":807
18715  *
18716  * @cname('__pyx_memoryview_slice_memviewslice')
18717  * cdef int slice_memviewslice(             # <<<<<<<<<<<<<<
18718  *         __Pyx_memviewslice *dst,
18719  *         Py_ssize_t shape, Py_ssize_t stride, Py_ssize_t suboffset,
18720  */
18721 
__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)18722 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) {
18723   Py_ssize_t __pyx_v_new_shape;
18724   int __pyx_v_negative_step;
18725   int __pyx_r;
18726   int __pyx_t_1;
18727   int __pyx_t_2;
18728   int __pyx_t_3;
18729   int __pyx_lineno = 0;
18730   const char *__pyx_filename = NULL;
18731   int __pyx_clineno = 0;
18732 
18733   /* "View.MemoryView":827
18734  *     cdef bint negative_step
18735  *
18736  *     if not is_slice:             # <<<<<<<<<<<<<<
18737  *
18738  *         if start < 0:
18739  */
18740   __pyx_t_1 = ((!(__pyx_v_is_slice != 0)) != 0);
18741   if (__pyx_t_1) {
18742 
18743     /* "View.MemoryView":829
18744  *     if not is_slice:
18745  *
18746  *         if start < 0:             # <<<<<<<<<<<<<<
18747  *             start += shape
18748  *         if not 0 <= start < shape:
18749  */
18750     __pyx_t_1 = ((__pyx_v_start < 0) != 0);
18751     if (__pyx_t_1) {
18752 
18753       /* "View.MemoryView":830
18754  *
18755  *         if start < 0:
18756  *             start += shape             # <<<<<<<<<<<<<<
18757  *         if not 0 <= start < shape:
18758  *             _err_dim(IndexError, "Index out of bounds (axis %d)", dim)
18759  */
18760       __pyx_v_start = (__pyx_v_start + __pyx_v_shape);
18761 
18762       /* "View.MemoryView":829
18763  *     if not is_slice:
18764  *
18765  *         if start < 0:             # <<<<<<<<<<<<<<
18766  *             start += shape
18767  *         if not 0 <= start < shape:
18768  */
18769     }
18770 
18771     /* "View.MemoryView":831
18772  *         if start < 0:
18773  *             start += shape
18774  *         if not 0 <= start < shape:             # <<<<<<<<<<<<<<
18775  *             _err_dim(IndexError, "Index out of bounds (axis %d)", dim)
18776  *     else:
18777  */
18778     __pyx_t_1 = (0 <= __pyx_v_start);
18779     if (__pyx_t_1) {
18780       __pyx_t_1 = (__pyx_v_start < __pyx_v_shape);
18781     }
18782     __pyx_t_2 = ((!(__pyx_t_1 != 0)) != 0);
18783     if (__pyx_t_2) {
18784 
18785       /* "View.MemoryView":832
18786  *             start += shape
18787  *         if not 0 <= start < shape:
18788  *             _err_dim(IndexError, "Index out of bounds (axis %d)", dim)             # <<<<<<<<<<<<<<
18789  *     else:
18790  *
18791  */
18792       __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)
18793 
18794       /* "View.MemoryView":831
18795  *         if start < 0:
18796  *             start += shape
18797  *         if not 0 <= start < shape:             # <<<<<<<<<<<<<<
18798  *             _err_dim(IndexError, "Index out of bounds (axis %d)", dim)
18799  *     else:
18800  */
18801     }
18802 
18803     /* "View.MemoryView":827
18804  *     cdef bint negative_step
18805  *
18806  *     if not is_slice:             # <<<<<<<<<<<<<<
18807  *
18808  *         if start < 0:
18809  */
18810     goto __pyx_L3;
18811   }
18812 
18813   /* "View.MemoryView":835
18814  *     else:
18815  *
18816  *         negative_step = have_step != 0 and step < 0             # <<<<<<<<<<<<<<
18817  *
18818  *         if have_step and step == 0:
18819  */
18820   /*else*/ {
18821     __pyx_t_1 = ((__pyx_v_have_step != 0) != 0);
18822     if (__pyx_t_1) {
18823     } else {
18824       __pyx_t_2 = __pyx_t_1;
18825       goto __pyx_L6_bool_binop_done;
18826     }
18827     __pyx_t_1 = ((__pyx_v_step < 0) != 0);
18828     __pyx_t_2 = __pyx_t_1;
18829     __pyx_L6_bool_binop_done:;
18830     __pyx_v_negative_step = __pyx_t_2;
18831 
18832     /* "View.MemoryView":837
18833  *         negative_step = have_step != 0 and step < 0
18834  *
18835  *         if have_step and step == 0:             # <<<<<<<<<<<<<<
18836  *             _err_dim(ValueError, "Step may not be zero (axis %d)", dim)
18837  *
18838  */
18839     __pyx_t_1 = (__pyx_v_have_step != 0);
18840     if (__pyx_t_1) {
18841     } else {
18842       __pyx_t_2 = __pyx_t_1;
18843       goto __pyx_L9_bool_binop_done;
18844     }
18845     __pyx_t_1 = ((__pyx_v_step == 0) != 0);
18846     __pyx_t_2 = __pyx_t_1;
18847     __pyx_L9_bool_binop_done:;
18848     if (__pyx_t_2) {
18849 
18850       /* "View.MemoryView":838
18851  *
18852  *         if have_step and step == 0:
18853  *             _err_dim(ValueError, "Step may not be zero (axis %d)", dim)             # <<<<<<<<<<<<<<
18854  *
18855  *
18856  */
18857       __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)
18858 
18859       /* "View.MemoryView":837
18860  *         negative_step = have_step != 0 and step < 0
18861  *
18862  *         if have_step and step == 0:             # <<<<<<<<<<<<<<
18863  *             _err_dim(ValueError, "Step may not be zero (axis %d)", dim)
18864  *
18865  */
18866     }
18867 
18868     /* "View.MemoryView":841
18869  *
18870  *
18871  *         if have_start:             # <<<<<<<<<<<<<<
18872  *             if start < 0:
18873  *                 start += shape
18874  */
18875     __pyx_t_2 = (__pyx_v_have_start != 0);
18876     if (__pyx_t_2) {
18877 
18878       /* "View.MemoryView":842
18879  *
18880  *         if have_start:
18881  *             if start < 0:             # <<<<<<<<<<<<<<
18882  *                 start += shape
18883  *                 if start < 0:
18884  */
18885       __pyx_t_2 = ((__pyx_v_start < 0) != 0);
18886       if (__pyx_t_2) {
18887 
18888         /* "View.MemoryView":843
18889  *         if have_start:
18890  *             if start < 0:
18891  *                 start += shape             # <<<<<<<<<<<<<<
18892  *                 if start < 0:
18893  *                     start = 0
18894  */
18895         __pyx_v_start = (__pyx_v_start + __pyx_v_shape);
18896 
18897         /* "View.MemoryView":844
18898  *             if start < 0:
18899  *                 start += shape
18900  *                 if start < 0:             # <<<<<<<<<<<<<<
18901  *                     start = 0
18902  *             elif start >= shape:
18903  */
18904         __pyx_t_2 = ((__pyx_v_start < 0) != 0);
18905         if (__pyx_t_2) {
18906 
18907           /* "View.MemoryView":845
18908  *                 start += shape
18909  *                 if start < 0:
18910  *                     start = 0             # <<<<<<<<<<<<<<
18911  *             elif start >= shape:
18912  *                 if negative_step:
18913  */
18914           __pyx_v_start = 0;
18915 
18916           /* "View.MemoryView":844
18917  *             if start < 0:
18918  *                 start += shape
18919  *                 if start < 0:             # <<<<<<<<<<<<<<
18920  *                     start = 0
18921  *             elif start >= shape:
18922  */
18923         }
18924 
18925         /* "View.MemoryView":842
18926  *
18927  *         if have_start:
18928  *             if start < 0:             # <<<<<<<<<<<<<<
18929  *                 start += shape
18930  *                 if start < 0:
18931  */
18932         goto __pyx_L12;
18933       }
18934 
18935       /* "View.MemoryView":846
18936  *                 if start < 0:
18937  *                     start = 0
18938  *             elif start >= shape:             # <<<<<<<<<<<<<<
18939  *                 if negative_step:
18940  *                     start = shape - 1
18941  */
18942       __pyx_t_2 = ((__pyx_v_start >= __pyx_v_shape) != 0);
18943       if (__pyx_t_2) {
18944 
18945         /* "View.MemoryView":847
18946  *                     start = 0
18947  *             elif start >= shape:
18948  *                 if negative_step:             # <<<<<<<<<<<<<<
18949  *                     start = shape - 1
18950  *                 else:
18951  */
18952         __pyx_t_2 = (__pyx_v_negative_step != 0);
18953         if (__pyx_t_2) {
18954 
18955           /* "View.MemoryView":848
18956  *             elif start >= shape:
18957  *                 if negative_step:
18958  *                     start = shape - 1             # <<<<<<<<<<<<<<
18959  *                 else:
18960  *                     start = shape
18961  */
18962           __pyx_v_start = (__pyx_v_shape - 1);
18963 
18964           /* "View.MemoryView":847
18965  *                     start = 0
18966  *             elif start >= shape:
18967  *                 if negative_step:             # <<<<<<<<<<<<<<
18968  *                     start = shape - 1
18969  *                 else:
18970  */
18971           goto __pyx_L14;
18972         }
18973 
18974         /* "View.MemoryView":850
18975  *                     start = shape - 1
18976  *                 else:
18977  *                     start = shape             # <<<<<<<<<<<<<<
18978  *         else:
18979  *             if negative_step:
18980  */
18981         /*else*/ {
18982           __pyx_v_start = __pyx_v_shape;
18983         }
18984         __pyx_L14:;
18985 
18986         /* "View.MemoryView":846
18987  *                 if start < 0:
18988  *                     start = 0
18989  *             elif start >= shape:             # <<<<<<<<<<<<<<
18990  *                 if negative_step:
18991  *                     start = shape - 1
18992  */
18993       }
18994       __pyx_L12:;
18995 
18996       /* "View.MemoryView":841
18997  *
18998  *
18999  *         if have_start:             # <<<<<<<<<<<<<<
19000  *             if start < 0:
19001  *                 start += shape
19002  */
19003       goto __pyx_L11;
19004     }
19005 
19006     /* "View.MemoryView":852
19007  *                     start = shape
19008  *         else:
19009  *             if negative_step:             # <<<<<<<<<<<<<<
19010  *                 start = shape - 1
19011  *             else:
19012  */
19013     /*else*/ {
19014       __pyx_t_2 = (__pyx_v_negative_step != 0);
19015       if (__pyx_t_2) {
19016 
19017         /* "View.MemoryView":853
19018  *         else:
19019  *             if negative_step:
19020  *                 start = shape - 1             # <<<<<<<<<<<<<<
19021  *             else:
19022  *                 start = 0
19023  */
19024         __pyx_v_start = (__pyx_v_shape - 1);
19025 
19026         /* "View.MemoryView":852
19027  *                     start = shape
19028  *         else:
19029  *             if negative_step:             # <<<<<<<<<<<<<<
19030  *                 start = shape - 1
19031  *             else:
19032  */
19033         goto __pyx_L15;
19034       }
19035 
19036       /* "View.MemoryView":855
19037  *                 start = shape - 1
19038  *             else:
19039  *                 start = 0             # <<<<<<<<<<<<<<
19040  *
19041  *         if have_stop:
19042  */
19043       /*else*/ {
19044         __pyx_v_start = 0;
19045       }
19046       __pyx_L15:;
19047     }
19048     __pyx_L11:;
19049 
19050     /* "View.MemoryView":857
19051  *                 start = 0
19052  *
19053  *         if have_stop:             # <<<<<<<<<<<<<<
19054  *             if stop < 0:
19055  *                 stop += shape
19056  */
19057     __pyx_t_2 = (__pyx_v_have_stop != 0);
19058     if (__pyx_t_2) {
19059 
19060       /* "View.MemoryView":858
19061  *
19062  *         if have_stop:
19063  *             if stop < 0:             # <<<<<<<<<<<<<<
19064  *                 stop += shape
19065  *                 if stop < 0:
19066  */
19067       __pyx_t_2 = ((__pyx_v_stop < 0) != 0);
19068       if (__pyx_t_2) {
19069 
19070         /* "View.MemoryView":859
19071  *         if have_stop:
19072  *             if stop < 0:
19073  *                 stop += shape             # <<<<<<<<<<<<<<
19074  *                 if stop < 0:
19075  *                     stop = 0
19076  */
19077         __pyx_v_stop = (__pyx_v_stop + __pyx_v_shape);
19078 
19079         /* "View.MemoryView":860
19080  *             if stop < 0:
19081  *                 stop += shape
19082  *                 if stop < 0:             # <<<<<<<<<<<<<<
19083  *                     stop = 0
19084  *             elif stop > shape:
19085  */
19086         __pyx_t_2 = ((__pyx_v_stop < 0) != 0);
19087         if (__pyx_t_2) {
19088 
19089           /* "View.MemoryView":861
19090  *                 stop += shape
19091  *                 if stop < 0:
19092  *                     stop = 0             # <<<<<<<<<<<<<<
19093  *             elif stop > shape:
19094  *                 stop = shape
19095  */
19096           __pyx_v_stop = 0;
19097 
19098           /* "View.MemoryView":860
19099  *             if stop < 0:
19100  *                 stop += shape
19101  *                 if stop < 0:             # <<<<<<<<<<<<<<
19102  *                     stop = 0
19103  *             elif stop > shape:
19104  */
19105         }
19106 
19107         /* "View.MemoryView":858
19108  *
19109  *         if have_stop:
19110  *             if stop < 0:             # <<<<<<<<<<<<<<
19111  *                 stop += shape
19112  *                 if stop < 0:
19113  */
19114         goto __pyx_L17;
19115       }
19116 
19117       /* "View.MemoryView":862
19118  *                 if stop < 0:
19119  *                     stop = 0
19120  *             elif stop > shape:             # <<<<<<<<<<<<<<
19121  *                 stop = shape
19122  *         else:
19123  */
19124       __pyx_t_2 = ((__pyx_v_stop > __pyx_v_shape) != 0);
19125       if (__pyx_t_2) {
19126 
19127         /* "View.MemoryView":863
19128  *                     stop = 0
19129  *             elif stop > shape:
19130  *                 stop = shape             # <<<<<<<<<<<<<<
19131  *         else:
19132  *             if negative_step:
19133  */
19134         __pyx_v_stop = __pyx_v_shape;
19135 
19136         /* "View.MemoryView":862
19137  *                 if stop < 0:
19138  *                     stop = 0
19139  *             elif stop > shape:             # <<<<<<<<<<<<<<
19140  *                 stop = shape
19141  *         else:
19142  */
19143       }
19144       __pyx_L17:;
19145 
19146       /* "View.MemoryView":857
19147  *                 start = 0
19148  *
19149  *         if have_stop:             # <<<<<<<<<<<<<<
19150  *             if stop < 0:
19151  *                 stop += shape
19152  */
19153       goto __pyx_L16;
19154     }
19155 
19156     /* "View.MemoryView":865
19157  *                 stop = shape
19158  *         else:
19159  *             if negative_step:             # <<<<<<<<<<<<<<
19160  *                 stop = -1
19161  *             else:
19162  */
19163     /*else*/ {
19164       __pyx_t_2 = (__pyx_v_negative_step != 0);
19165       if (__pyx_t_2) {
19166 
19167         /* "View.MemoryView":866
19168  *         else:
19169  *             if negative_step:
19170  *                 stop = -1             # <<<<<<<<<<<<<<
19171  *             else:
19172  *                 stop = shape
19173  */
19174         __pyx_v_stop = -1L;
19175 
19176         /* "View.MemoryView":865
19177  *                 stop = shape
19178  *         else:
19179  *             if negative_step:             # <<<<<<<<<<<<<<
19180  *                 stop = -1
19181  *             else:
19182  */
19183         goto __pyx_L19;
19184       }
19185 
19186       /* "View.MemoryView":868
19187  *                 stop = -1
19188  *             else:
19189  *                 stop = shape             # <<<<<<<<<<<<<<
19190  *
19191  *         if not have_step:
19192  */
19193       /*else*/ {
19194         __pyx_v_stop = __pyx_v_shape;
19195       }
19196       __pyx_L19:;
19197     }
19198     __pyx_L16:;
19199 
19200     /* "View.MemoryView":870
19201  *                 stop = shape
19202  *
19203  *         if not have_step:             # <<<<<<<<<<<<<<
19204  *             step = 1
19205  *
19206  */
19207     __pyx_t_2 = ((!(__pyx_v_have_step != 0)) != 0);
19208     if (__pyx_t_2) {
19209 
19210       /* "View.MemoryView":871
19211  *
19212  *         if not have_step:
19213  *             step = 1             # <<<<<<<<<<<<<<
19214  *
19215  *
19216  */
19217       __pyx_v_step = 1;
19218 
19219       /* "View.MemoryView":870
19220  *                 stop = shape
19221  *
19222  *         if not have_step:             # <<<<<<<<<<<<<<
19223  *             step = 1
19224  *
19225  */
19226     }
19227 
19228     /* "View.MemoryView":875
19229  *
19230  *         with cython.cdivision(True):
19231  *             new_shape = (stop - start) // step             # <<<<<<<<<<<<<<
19232  *
19233  *             if (stop - start) - step * new_shape:
19234  */
19235     __pyx_v_new_shape = ((__pyx_v_stop - __pyx_v_start) / __pyx_v_step);
19236 
19237     /* "View.MemoryView":877
19238  *             new_shape = (stop - start) // step
19239  *
19240  *             if (stop - start) - step * new_shape:             # <<<<<<<<<<<<<<
19241  *                 new_shape += 1
19242  *
19243  */
19244     __pyx_t_2 = (((__pyx_v_stop - __pyx_v_start) - (__pyx_v_step * __pyx_v_new_shape)) != 0);
19245     if (__pyx_t_2) {
19246 
19247       /* "View.MemoryView":878
19248  *
19249  *             if (stop - start) - step * new_shape:
19250  *                 new_shape += 1             # <<<<<<<<<<<<<<
19251  *
19252  *         if new_shape < 0:
19253  */
19254       __pyx_v_new_shape = (__pyx_v_new_shape + 1);
19255 
19256       /* "View.MemoryView":877
19257  *             new_shape = (stop - start) // step
19258  *
19259  *             if (stop - start) - step * new_shape:             # <<<<<<<<<<<<<<
19260  *                 new_shape += 1
19261  *
19262  */
19263     }
19264 
19265     /* "View.MemoryView":880
19266  *                 new_shape += 1
19267  *
19268  *         if new_shape < 0:             # <<<<<<<<<<<<<<
19269  *             new_shape = 0
19270  *
19271  */
19272     __pyx_t_2 = ((__pyx_v_new_shape < 0) != 0);
19273     if (__pyx_t_2) {
19274 
19275       /* "View.MemoryView":881
19276  *
19277  *         if new_shape < 0:
19278  *             new_shape = 0             # <<<<<<<<<<<<<<
19279  *
19280  *
19281  */
19282       __pyx_v_new_shape = 0;
19283 
19284       /* "View.MemoryView":880
19285  *                 new_shape += 1
19286  *
19287  *         if new_shape < 0:             # <<<<<<<<<<<<<<
19288  *             new_shape = 0
19289  *
19290  */
19291     }
19292 
19293     /* "View.MemoryView":884
19294  *
19295  *
19296  *         dst.strides[new_ndim] = stride * step             # <<<<<<<<<<<<<<
19297  *         dst.shape[new_ndim] = new_shape
19298  *         dst.suboffsets[new_ndim] = suboffset
19299  */
19300     (__pyx_v_dst->strides[__pyx_v_new_ndim]) = (__pyx_v_stride * __pyx_v_step);
19301 
19302     /* "View.MemoryView":885
19303  *
19304  *         dst.strides[new_ndim] = stride * step
19305  *         dst.shape[new_ndim] = new_shape             # <<<<<<<<<<<<<<
19306  *         dst.suboffsets[new_ndim] = suboffset
19307  *
19308  */
19309     (__pyx_v_dst->shape[__pyx_v_new_ndim]) = __pyx_v_new_shape;
19310 
19311     /* "View.MemoryView":886
19312  *         dst.strides[new_ndim] = stride * step
19313  *         dst.shape[new_ndim] = new_shape
19314  *         dst.suboffsets[new_ndim] = suboffset             # <<<<<<<<<<<<<<
19315  *
19316  *
19317  */
19318     (__pyx_v_dst->suboffsets[__pyx_v_new_ndim]) = __pyx_v_suboffset;
19319   }
19320   __pyx_L3:;
19321 
19322   /* "View.MemoryView":889
19323  *
19324  *
19325  *     if suboffset_dim[0] < 0:             # <<<<<<<<<<<<<<
19326  *         dst.data += start * stride
19327  *     else:
19328  */
19329   __pyx_t_2 = (((__pyx_v_suboffset_dim[0]) < 0) != 0);
19330   if (__pyx_t_2) {
19331 
19332     /* "View.MemoryView":890
19333  *
19334  *     if suboffset_dim[0] < 0:
19335  *         dst.data += start * stride             # <<<<<<<<<<<<<<
19336  *     else:
19337  *         dst.suboffsets[suboffset_dim[0]] += start * stride
19338  */
19339     __pyx_v_dst->data = (__pyx_v_dst->data + (__pyx_v_start * __pyx_v_stride));
19340 
19341     /* "View.MemoryView":889
19342  *
19343  *
19344  *     if suboffset_dim[0] < 0:             # <<<<<<<<<<<<<<
19345  *         dst.data += start * stride
19346  *     else:
19347  */
19348     goto __pyx_L23;
19349   }
19350 
19351   /* "View.MemoryView":892
19352  *         dst.data += start * stride
19353  *     else:
19354  *         dst.suboffsets[suboffset_dim[0]] += start * stride             # <<<<<<<<<<<<<<
19355  *
19356  *     if suboffset >= 0:
19357  */
19358   /*else*/ {
19359     __pyx_t_3 = (__pyx_v_suboffset_dim[0]);
19360     (__pyx_v_dst->suboffsets[__pyx_t_3]) = ((__pyx_v_dst->suboffsets[__pyx_t_3]) + (__pyx_v_start * __pyx_v_stride));
19361   }
19362   __pyx_L23:;
19363 
19364   /* "View.MemoryView":894
19365  *         dst.suboffsets[suboffset_dim[0]] += start * stride
19366  *
19367  *     if suboffset >= 0:             # <<<<<<<<<<<<<<
19368  *         if not is_slice:
19369  *             if new_ndim == 0:
19370  */
19371   __pyx_t_2 = ((__pyx_v_suboffset >= 0) != 0);
19372   if (__pyx_t_2) {
19373 
19374     /* "View.MemoryView":895
19375  *
19376  *     if suboffset >= 0:
19377  *         if not is_slice:             # <<<<<<<<<<<<<<
19378  *             if new_ndim == 0:
19379  *                 dst.data = (<char **> dst.data)[0] + suboffset
19380  */
19381     __pyx_t_2 = ((!(__pyx_v_is_slice != 0)) != 0);
19382     if (__pyx_t_2) {
19383 
19384       /* "View.MemoryView":896
19385  *     if suboffset >= 0:
19386  *         if not is_slice:
19387  *             if new_ndim == 0:             # <<<<<<<<<<<<<<
19388  *                 dst.data = (<char **> dst.data)[0] + suboffset
19389  *             else:
19390  */
19391       __pyx_t_2 = ((__pyx_v_new_ndim == 0) != 0);
19392       if (__pyx_t_2) {
19393 
19394         /* "View.MemoryView":897
19395  *         if not is_slice:
19396  *             if new_ndim == 0:
19397  *                 dst.data = (<char **> dst.data)[0] + suboffset             # <<<<<<<<<<<<<<
19398  *             else:
19399  *                 _err_dim(IndexError, "All dimensions preceding dimension %d "
19400  */
19401         __pyx_v_dst->data = ((((char **)__pyx_v_dst->data)[0]) + __pyx_v_suboffset);
19402 
19403         /* "View.MemoryView":896
19404  *     if suboffset >= 0:
19405  *         if not is_slice:
19406  *             if new_ndim == 0:             # <<<<<<<<<<<<<<
19407  *                 dst.data = (<char **> dst.data)[0] + suboffset
19408  *             else:
19409  */
19410         goto __pyx_L26;
19411       }
19412 
19413       /* "View.MemoryView":899
19414  *                 dst.data = (<char **> dst.data)[0] + suboffset
19415  *             else:
19416  *                 _err_dim(IndexError, "All dimensions preceding dimension %d "             # <<<<<<<<<<<<<<
19417  *                                      "must be indexed and not sliced", dim)
19418  *         else:
19419  */
19420       /*else*/ {
19421 
19422         /* "View.MemoryView":900
19423  *             else:
19424  *                 _err_dim(IndexError, "All dimensions preceding dimension %d "
19425  *                                      "must be indexed and not sliced", dim)             # <<<<<<<<<<<<<<
19426  *         else:
19427  *             suboffset_dim[0] = new_ndim
19428  */
19429         __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)
19430       }
19431       __pyx_L26:;
19432 
19433       /* "View.MemoryView":895
19434  *
19435  *     if suboffset >= 0:
19436  *         if not is_slice:             # <<<<<<<<<<<<<<
19437  *             if new_ndim == 0:
19438  *                 dst.data = (<char **> dst.data)[0] + suboffset
19439  */
19440       goto __pyx_L25;
19441     }
19442 
19443     /* "View.MemoryView":902
19444  *                                      "must be indexed and not sliced", dim)
19445  *         else:
19446  *             suboffset_dim[0] = new_ndim             # <<<<<<<<<<<<<<
19447  *
19448  *     return 0
19449  */
19450     /*else*/ {
19451       (__pyx_v_suboffset_dim[0]) = __pyx_v_new_ndim;
19452     }
19453     __pyx_L25:;
19454 
19455     /* "View.MemoryView":894
19456  *         dst.suboffsets[suboffset_dim[0]] += start * stride
19457  *
19458  *     if suboffset >= 0:             # <<<<<<<<<<<<<<
19459  *         if not is_slice:
19460  *             if new_ndim == 0:
19461  */
19462   }
19463 
19464   /* "View.MemoryView":904
19465  *             suboffset_dim[0] = new_ndim
19466  *
19467  *     return 0             # <<<<<<<<<<<<<<
19468  *
19469  *
19470  */
19471   __pyx_r = 0;
19472   goto __pyx_L0;
19473 
19474   /* "View.MemoryView":807
19475  *
19476  * @cname('__pyx_memoryview_slice_memviewslice')
19477  * cdef int slice_memviewslice(             # <<<<<<<<<<<<<<
19478  *         __Pyx_memviewslice *dst,
19479  *         Py_ssize_t shape, Py_ssize_t stride, Py_ssize_t suboffset,
19480  */
19481 
19482   /* function exit code */
19483   __pyx_L1_error:;
19484   {
19485     #ifdef WITH_THREAD
19486     PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure();
19487     #endif
19488     __Pyx_AddTraceback("View.MemoryView.slice_memviewslice", __pyx_clineno, __pyx_lineno, __pyx_filename);
19489     #ifdef WITH_THREAD
19490     __Pyx_PyGILState_Release(__pyx_gilstate_save);
19491     #endif
19492   }
19493   __pyx_r = -1;
19494   __pyx_L0:;
19495   return __pyx_r;
19496 }
19497 
19498 /* "View.MemoryView":910
19499  *
19500  * @cname('__pyx_pybuffer_index')
19501  * cdef char *pybuffer_index(Py_buffer *view, char *bufp, Py_ssize_t index,             # <<<<<<<<<<<<<<
19502  *                           Py_ssize_t dim) except NULL:
19503  *     cdef Py_ssize_t shape, stride, suboffset = -1
19504  */
19505 
__pyx_pybuffer_index(Py_buffer * __pyx_v_view,char * __pyx_v_bufp,Py_ssize_t __pyx_v_index,Py_ssize_t __pyx_v_dim)19506 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) {
19507   Py_ssize_t __pyx_v_shape;
19508   Py_ssize_t __pyx_v_stride;
19509   Py_ssize_t __pyx_v_suboffset;
19510   Py_ssize_t __pyx_v_itemsize;
19511   char *__pyx_v_resultp;
19512   char *__pyx_r;
19513   __Pyx_RefNannyDeclarations
19514   Py_ssize_t __pyx_t_1;
19515   int __pyx_t_2;
19516   PyObject *__pyx_t_3 = NULL;
19517   PyObject *__pyx_t_4 = NULL;
19518   int __pyx_lineno = 0;
19519   const char *__pyx_filename = NULL;
19520   int __pyx_clineno = 0;
19521   __Pyx_RefNannySetupContext("pybuffer_index", 0);
19522 
19523   /* "View.MemoryView":912
19524  * cdef char *pybuffer_index(Py_buffer *view, char *bufp, Py_ssize_t index,
19525  *                           Py_ssize_t dim) except NULL:
19526  *     cdef Py_ssize_t shape, stride, suboffset = -1             # <<<<<<<<<<<<<<
19527  *     cdef Py_ssize_t itemsize = view.itemsize
19528  *     cdef char *resultp
19529  */
19530   __pyx_v_suboffset = -1L;
19531 
19532   /* "View.MemoryView":913
19533  *                           Py_ssize_t dim) except NULL:
19534  *     cdef Py_ssize_t shape, stride, suboffset = -1
19535  *     cdef Py_ssize_t itemsize = view.itemsize             # <<<<<<<<<<<<<<
19536  *     cdef char *resultp
19537  *
19538  */
19539   __pyx_t_1 = __pyx_v_view->itemsize;
19540   __pyx_v_itemsize = __pyx_t_1;
19541 
19542   /* "View.MemoryView":916
19543  *     cdef char *resultp
19544  *
19545  *     if view.ndim == 0:             # <<<<<<<<<<<<<<
19546  *         shape = view.len / itemsize
19547  *         stride = itemsize
19548  */
19549   __pyx_t_2 = ((__pyx_v_view->ndim == 0) != 0);
19550   if (__pyx_t_2) {
19551 
19552     /* "View.MemoryView":917
19553  *
19554  *     if view.ndim == 0:
19555  *         shape = view.len / itemsize             # <<<<<<<<<<<<<<
19556  *         stride = itemsize
19557  *     else:
19558  */
19559     if (unlikely(__pyx_v_itemsize == 0)) {
19560       PyErr_SetString(PyExc_ZeroDivisionError, "integer division or modulo by zero");
19561       __PYX_ERR(3, 917, __pyx_L1_error)
19562     }
19563     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))) {
19564       PyErr_SetString(PyExc_OverflowError, "value too large to perform division");
19565       __PYX_ERR(3, 917, __pyx_L1_error)
19566     }
19567     __pyx_v_shape = __Pyx_div_Py_ssize_t(__pyx_v_view->len, __pyx_v_itemsize);
19568 
19569     /* "View.MemoryView":918
19570  *     if view.ndim == 0:
19571  *         shape = view.len / itemsize
19572  *         stride = itemsize             # <<<<<<<<<<<<<<
19573  *     else:
19574  *         shape = view.shape[dim]
19575  */
19576     __pyx_v_stride = __pyx_v_itemsize;
19577 
19578     /* "View.MemoryView":916
19579  *     cdef char *resultp
19580  *
19581  *     if view.ndim == 0:             # <<<<<<<<<<<<<<
19582  *         shape = view.len / itemsize
19583  *         stride = itemsize
19584  */
19585     goto __pyx_L3;
19586   }
19587 
19588   /* "View.MemoryView":920
19589  *         stride = itemsize
19590  *     else:
19591  *         shape = view.shape[dim]             # <<<<<<<<<<<<<<
19592  *         stride = view.strides[dim]
19593  *         if view.suboffsets != NULL:
19594  */
19595   /*else*/ {
19596     __pyx_v_shape = (__pyx_v_view->shape[__pyx_v_dim]);
19597 
19598     /* "View.MemoryView":921
19599  *     else:
19600  *         shape = view.shape[dim]
19601  *         stride = view.strides[dim]             # <<<<<<<<<<<<<<
19602  *         if view.suboffsets != NULL:
19603  *             suboffset = view.suboffsets[dim]
19604  */
19605     __pyx_v_stride = (__pyx_v_view->strides[__pyx_v_dim]);
19606 
19607     /* "View.MemoryView":922
19608  *         shape = view.shape[dim]
19609  *         stride = view.strides[dim]
19610  *         if view.suboffsets != NULL:             # <<<<<<<<<<<<<<
19611  *             suboffset = view.suboffsets[dim]
19612  *
19613  */
19614     __pyx_t_2 = ((__pyx_v_view->suboffsets != NULL) != 0);
19615     if (__pyx_t_2) {
19616 
19617       /* "View.MemoryView":923
19618  *         stride = view.strides[dim]
19619  *         if view.suboffsets != NULL:
19620  *             suboffset = view.suboffsets[dim]             # <<<<<<<<<<<<<<
19621  *
19622  *     if index < 0:
19623  */
19624       __pyx_v_suboffset = (__pyx_v_view->suboffsets[__pyx_v_dim]);
19625 
19626       /* "View.MemoryView":922
19627  *         shape = view.shape[dim]
19628  *         stride = view.strides[dim]
19629  *         if view.suboffsets != NULL:             # <<<<<<<<<<<<<<
19630  *             suboffset = view.suboffsets[dim]
19631  *
19632  */
19633     }
19634   }
19635   __pyx_L3:;
19636 
19637   /* "View.MemoryView":925
19638  *             suboffset = view.suboffsets[dim]
19639  *
19640  *     if index < 0:             # <<<<<<<<<<<<<<
19641  *         index += view.shape[dim]
19642  *         if index < 0:
19643  */
19644   __pyx_t_2 = ((__pyx_v_index < 0) != 0);
19645   if (__pyx_t_2) {
19646 
19647     /* "View.MemoryView":926
19648  *
19649  *     if index < 0:
19650  *         index += view.shape[dim]             # <<<<<<<<<<<<<<
19651  *         if index < 0:
19652  *             raise IndexError("Out of bounds on buffer access (axis %d)" % dim)
19653  */
19654     __pyx_v_index = (__pyx_v_index + (__pyx_v_view->shape[__pyx_v_dim]));
19655 
19656     /* "View.MemoryView":927
19657  *     if index < 0:
19658  *         index += view.shape[dim]
19659  *         if index < 0:             # <<<<<<<<<<<<<<
19660  *             raise IndexError("Out of bounds on buffer access (axis %d)" % dim)
19661  *
19662  */
19663     __pyx_t_2 = ((__pyx_v_index < 0) != 0);
19664     if (unlikely(__pyx_t_2)) {
19665 
19666       /* "View.MemoryView":928
19667  *         index += view.shape[dim]
19668  *         if index < 0:
19669  *             raise IndexError("Out of bounds on buffer access (axis %d)" % dim)             # <<<<<<<<<<<<<<
19670  *
19671  *     if index >= shape:
19672  */
19673       __pyx_t_3 = PyInt_FromSsize_t(__pyx_v_dim); if (unlikely(!__pyx_t_3)) __PYX_ERR(3, 928, __pyx_L1_error)
19674       __Pyx_GOTREF(__pyx_t_3);
19675       __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)
19676       __Pyx_GOTREF(__pyx_t_4);
19677       __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
19678       __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_builtin_IndexError, __pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(3, 928, __pyx_L1_error)
19679       __Pyx_GOTREF(__pyx_t_3);
19680       __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
19681       __Pyx_Raise(__pyx_t_3, 0, 0, 0);
19682       __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
19683       __PYX_ERR(3, 928, __pyx_L1_error)
19684 
19685       /* "View.MemoryView":927
19686  *     if index < 0:
19687  *         index += view.shape[dim]
19688  *         if index < 0:             # <<<<<<<<<<<<<<
19689  *             raise IndexError("Out of bounds on buffer access (axis %d)" % dim)
19690  *
19691  */
19692     }
19693 
19694     /* "View.MemoryView":925
19695  *             suboffset = view.suboffsets[dim]
19696  *
19697  *     if index < 0:             # <<<<<<<<<<<<<<
19698  *         index += view.shape[dim]
19699  *         if index < 0:
19700  */
19701   }
19702 
19703   /* "View.MemoryView":930
19704  *             raise IndexError("Out of bounds on buffer access (axis %d)" % dim)
19705  *
19706  *     if index >= shape:             # <<<<<<<<<<<<<<
19707  *         raise IndexError("Out of bounds on buffer access (axis %d)" % dim)
19708  *
19709  */
19710   __pyx_t_2 = ((__pyx_v_index >= __pyx_v_shape) != 0);
19711   if (unlikely(__pyx_t_2)) {
19712 
19713     /* "View.MemoryView":931
19714  *
19715  *     if index >= shape:
19716  *         raise IndexError("Out of bounds on buffer access (axis %d)" % dim)             # <<<<<<<<<<<<<<
19717  *
19718  *     resultp = bufp + index * stride
19719  */
19720     __pyx_t_3 = PyInt_FromSsize_t(__pyx_v_dim); if (unlikely(!__pyx_t_3)) __PYX_ERR(3, 931, __pyx_L1_error)
19721     __Pyx_GOTREF(__pyx_t_3);
19722     __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)
19723     __Pyx_GOTREF(__pyx_t_4);
19724     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
19725     __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_builtin_IndexError, __pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(3, 931, __pyx_L1_error)
19726     __Pyx_GOTREF(__pyx_t_3);
19727     __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
19728     __Pyx_Raise(__pyx_t_3, 0, 0, 0);
19729     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
19730     __PYX_ERR(3, 931, __pyx_L1_error)
19731 
19732     /* "View.MemoryView":930
19733  *             raise IndexError("Out of bounds on buffer access (axis %d)" % dim)
19734  *
19735  *     if index >= shape:             # <<<<<<<<<<<<<<
19736  *         raise IndexError("Out of bounds on buffer access (axis %d)" % dim)
19737  *
19738  */
19739   }
19740 
19741   /* "View.MemoryView":933
19742  *         raise IndexError("Out of bounds on buffer access (axis %d)" % dim)
19743  *
19744  *     resultp = bufp + index * stride             # <<<<<<<<<<<<<<
19745  *     if suboffset >= 0:
19746  *         resultp = (<char **> resultp)[0] + suboffset
19747  */
19748   __pyx_v_resultp = (__pyx_v_bufp + (__pyx_v_index * __pyx_v_stride));
19749 
19750   /* "View.MemoryView":934
19751  *
19752  *     resultp = bufp + index * stride
19753  *     if suboffset >= 0:             # <<<<<<<<<<<<<<
19754  *         resultp = (<char **> resultp)[0] + suboffset
19755  *
19756  */
19757   __pyx_t_2 = ((__pyx_v_suboffset >= 0) != 0);
19758   if (__pyx_t_2) {
19759 
19760     /* "View.MemoryView":935
19761  *     resultp = bufp + index * stride
19762  *     if suboffset >= 0:
19763  *         resultp = (<char **> resultp)[0] + suboffset             # <<<<<<<<<<<<<<
19764  *
19765  *     return resultp
19766  */
19767     __pyx_v_resultp = ((((char **)__pyx_v_resultp)[0]) + __pyx_v_suboffset);
19768 
19769     /* "View.MemoryView":934
19770  *
19771  *     resultp = bufp + index * stride
19772  *     if suboffset >= 0:             # <<<<<<<<<<<<<<
19773  *         resultp = (<char **> resultp)[0] + suboffset
19774  *
19775  */
19776   }
19777 
19778   /* "View.MemoryView":937
19779  *         resultp = (<char **> resultp)[0] + suboffset
19780  *
19781  *     return resultp             # <<<<<<<<<<<<<<
19782  *
19783  *
19784  */
19785   __pyx_r = __pyx_v_resultp;
19786   goto __pyx_L0;
19787 
19788   /* "View.MemoryView":910
19789  *
19790  * @cname('__pyx_pybuffer_index')
19791  * cdef char *pybuffer_index(Py_buffer *view, char *bufp, Py_ssize_t index,             # <<<<<<<<<<<<<<
19792  *                           Py_ssize_t dim) except NULL:
19793  *     cdef Py_ssize_t shape, stride, suboffset = -1
19794  */
19795 
19796   /* function exit code */
19797   __pyx_L1_error:;
19798   __Pyx_XDECREF(__pyx_t_3);
19799   __Pyx_XDECREF(__pyx_t_4);
19800   __Pyx_AddTraceback("View.MemoryView.pybuffer_index", __pyx_clineno, __pyx_lineno, __pyx_filename);
19801   __pyx_r = NULL;
19802   __pyx_L0:;
19803   __Pyx_RefNannyFinishContext();
19804   return __pyx_r;
19805 }
19806 
19807 /* "View.MemoryView":943
19808  *
19809  * @cname('__pyx_memslice_transpose')
19810  * cdef int transpose_memslice(__Pyx_memviewslice *memslice) nogil except 0:             # <<<<<<<<<<<<<<
19811  *     cdef int ndim = memslice.memview.view.ndim
19812  *
19813  */
19814 
__pyx_memslice_transpose(__Pyx_memviewslice * __pyx_v_memslice)19815 static int __pyx_memslice_transpose(__Pyx_memviewslice *__pyx_v_memslice) {
19816   int __pyx_v_ndim;
19817   Py_ssize_t *__pyx_v_shape;
19818   Py_ssize_t *__pyx_v_strides;
19819   int __pyx_v_i;
19820   int __pyx_v_j;
19821   int __pyx_r;
19822   int __pyx_t_1;
19823   Py_ssize_t *__pyx_t_2;
19824   long __pyx_t_3;
19825   long __pyx_t_4;
19826   Py_ssize_t __pyx_t_5;
19827   Py_ssize_t __pyx_t_6;
19828   int __pyx_t_7;
19829   int __pyx_t_8;
19830   int __pyx_t_9;
19831   int __pyx_lineno = 0;
19832   const char *__pyx_filename = NULL;
19833   int __pyx_clineno = 0;
19834 
19835   /* "View.MemoryView":944
19836  * @cname('__pyx_memslice_transpose')
19837  * cdef int transpose_memslice(__Pyx_memviewslice *memslice) nogil except 0:
19838  *     cdef int ndim = memslice.memview.view.ndim             # <<<<<<<<<<<<<<
19839  *
19840  *     cdef Py_ssize_t *shape = memslice.shape
19841  */
19842   __pyx_t_1 = __pyx_v_memslice->memview->view.ndim;
19843   __pyx_v_ndim = __pyx_t_1;
19844 
19845   /* "View.MemoryView":946
19846  *     cdef int ndim = memslice.memview.view.ndim
19847  *
19848  *     cdef Py_ssize_t *shape = memslice.shape             # <<<<<<<<<<<<<<
19849  *     cdef Py_ssize_t *strides = memslice.strides
19850  *
19851  */
19852   __pyx_t_2 = __pyx_v_memslice->shape;
19853   __pyx_v_shape = __pyx_t_2;
19854 
19855   /* "View.MemoryView":947
19856  *
19857  *     cdef Py_ssize_t *shape = memslice.shape
19858  *     cdef Py_ssize_t *strides = memslice.strides             # <<<<<<<<<<<<<<
19859  *
19860  *
19861  */
19862   __pyx_t_2 = __pyx_v_memslice->strides;
19863   __pyx_v_strides = __pyx_t_2;
19864 
19865   /* "View.MemoryView":951
19866  *
19867  *     cdef int i, j
19868  *     for i in range(ndim / 2):             # <<<<<<<<<<<<<<
19869  *         j = ndim - 1 - i
19870  *         strides[i], strides[j] = strides[j], strides[i]
19871  */
19872   __pyx_t_3 = __Pyx_div_long(__pyx_v_ndim, 2);
19873   __pyx_t_4 = __pyx_t_3;
19874   for (__pyx_t_1 = 0; __pyx_t_1 < __pyx_t_4; __pyx_t_1+=1) {
19875     __pyx_v_i = __pyx_t_1;
19876 
19877     /* "View.MemoryView":952
19878  *     cdef int i, j
19879  *     for i in range(ndim / 2):
19880  *         j = ndim - 1 - i             # <<<<<<<<<<<<<<
19881  *         strides[i], strides[j] = strides[j], strides[i]
19882  *         shape[i], shape[j] = shape[j], shape[i]
19883  */
19884     __pyx_v_j = ((__pyx_v_ndim - 1) - __pyx_v_i);
19885 
19886     /* "View.MemoryView":953
19887  *     for i in range(ndim / 2):
19888  *         j = ndim - 1 - i
19889  *         strides[i], strides[j] = strides[j], strides[i]             # <<<<<<<<<<<<<<
19890  *         shape[i], shape[j] = shape[j], shape[i]
19891  *
19892  */
19893     __pyx_t_5 = (__pyx_v_strides[__pyx_v_j]);
19894     __pyx_t_6 = (__pyx_v_strides[__pyx_v_i]);
19895     (__pyx_v_strides[__pyx_v_i]) = __pyx_t_5;
19896     (__pyx_v_strides[__pyx_v_j]) = __pyx_t_6;
19897 
19898     /* "View.MemoryView":954
19899  *         j = ndim - 1 - i
19900  *         strides[i], strides[j] = strides[j], strides[i]
19901  *         shape[i], shape[j] = shape[j], shape[i]             # <<<<<<<<<<<<<<
19902  *
19903  *         if memslice.suboffsets[i] >= 0 or memslice.suboffsets[j] >= 0:
19904  */
19905     __pyx_t_6 = (__pyx_v_shape[__pyx_v_j]);
19906     __pyx_t_5 = (__pyx_v_shape[__pyx_v_i]);
19907     (__pyx_v_shape[__pyx_v_i]) = __pyx_t_6;
19908     (__pyx_v_shape[__pyx_v_j]) = __pyx_t_5;
19909 
19910     /* "View.MemoryView":956
19911  *         shape[i], shape[j] = shape[j], shape[i]
19912  *
19913  *         if memslice.suboffsets[i] >= 0 or memslice.suboffsets[j] >= 0:             # <<<<<<<<<<<<<<
19914  *             _err(ValueError, "Cannot transpose memoryview with indirect dimensions")
19915  *
19916  */
19917     __pyx_t_8 = (((__pyx_v_memslice->suboffsets[__pyx_v_i]) >= 0) != 0);
19918     if (!__pyx_t_8) {
19919     } else {
19920       __pyx_t_7 = __pyx_t_8;
19921       goto __pyx_L6_bool_binop_done;
19922     }
19923     __pyx_t_8 = (((__pyx_v_memslice->suboffsets[__pyx_v_j]) >= 0) != 0);
19924     __pyx_t_7 = __pyx_t_8;
19925     __pyx_L6_bool_binop_done:;
19926     if (__pyx_t_7) {
19927 
19928       /* "View.MemoryView":957
19929  *
19930  *         if memslice.suboffsets[i] >= 0 or memslice.suboffsets[j] >= 0:
19931  *             _err(ValueError, "Cannot transpose memoryview with indirect dimensions")             # <<<<<<<<<<<<<<
19932  *
19933  *     return 1
19934  */
19935       __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)
19936 
19937       /* "View.MemoryView":956
19938  *         shape[i], shape[j] = shape[j], shape[i]
19939  *
19940  *         if memslice.suboffsets[i] >= 0 or memslice.suboffsets[j] >= 0:             # <<<<<<<<<<<<<<
19941  *             _err(ValueError, "Cannot transpose memoryview with indirect dimensions")
19942  *
19943  */
19944     }
19945   }
19946 
19947   /* "View.MemoryView":959
19948  *             _err(ValueError, "Cannot transpose memoryview with indirect dimensions")
19949  *
19950  *     return 1             # <<<<<<<<<<<<<<
19951  *
19952  *
19953  */
19954   __pyx_r = 1;
19955   goto __pyx_L0;
19956 
19957   /* "View.MemoryView":943
19958  *
19959  * @cname('__pyx_memslice_transpose')
19960  * cdef int transpose_memslice(__Pyx_memviewslice *memslice) nogil except 0:             # <<<<<<<<<<<<<<
19961  *     cdef int ndim = memslice.memview.view.ndim
19962  *
19963  */
19964 
19965   /* function exit code */
19966   __pyx_L1_error:;
19967   {
19968     #ifdef WITH_THREAD
19969     PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure();
19970     #endif
19971     __Pyx_AddTraceback("View.MemoryView.transpose_memslice", __pyx_clineno, __pyx_lineno, __pyx_filename);
19972     #ifdef WITH_THREAD
19973     __Pyx_PyGILState_Release(__pyx_gilstate_save);
19974     #endif
19975   }
19976   __pyx_r = 0;
19977   __pyx_L0:;
19978   return __pyx_r;
19979 }
19980 
19981 /* "View.MemoryView":976
19982  *     cdef int (*to_dtype_func)(char *, object) except 0
19983  *
19984  *     def __dealloc__(self):             # <<<<<<<<<<<<<<
19985  *         __PYX_XDEC_MEMVIEW(&self.from_slice, 1)
19986  *
19987  */
19988 
19989 /* Python wrapper */
19990 static void __pyx_memoryviewslice___dealloc__(PyObject *__pyx_v_self); /*proto*/
__pyx_memoryviewslice___dealloc__(PyObject * __pyx_v_self)19991 static void __pyx_memoryviewslice___dealloc__(PyObject *__pyx_v_self) {
19992   __Pyx_RefNannyDeclarations
19993   __Pyx_RefNannySetupContext("__dealloc__ (wrapper)", 0);
19994   __pyx_memoryviewslice___pyx_pf_15View_dot_MemoryView_16_memoryviewslice___dealloc__(((struct __pyx_memoryviewslice_obj *)__pyx_v_self));
19995 
19996   /* function exit code */
19997   __Pyx_RefNannyFinishContext();
19998 }
19999 
__pyx_memoryviewslice___pyx_pf_15View_dot_MemoryView_16_memoryviewslice___dealloc__(struct __pyx_memoryviewslice_obj * __pyx_v_self)20000 static void __pyx_memoryviewslice___pyx_pf_15View_dot_MemoryView_16_memoryviewslice___dealloc__(struct __pyx_memoryviewslice_obj *__pyx_v_self) {
20001   __Pyx_RefNannyDeclarations
20002   __Pyx_RefNannySetupContext("__dealloc__", 0);
20003 
20004   /* "View.MemoryView":977
20005  *
20006  *     def __dealloc__(self):
20007  *         __PYX_XDEC_MEMVIEW(&self.from_slice, 1)             # <<<<<<<<<<<<<<
20008  *
20009  *     cdef convert_item_to_object(self, char *itemp):
20010  */
20011   __PYX_XDEC_MEMVIEW((&__pyx_v_self->from_slice), 1);
20012 
20013   /* "View.MemoryView":976
20014  *     cdef int (*to_dtype_func)(char *, object) except 0
20015  *
20016  *     def __dealloc__(self):             # <<<<<<<<<<<<<<
20017  *         __PYX_XDEC_MEMVIEW(&self.from_slice, 1)
20018  *
20019  */
20020 
20021   /* function exit code */
20022   __Pyx_RefNannyFinishContext();
20023 }
20024 
20025 /* "View.MemoryView":979
20026  *         __PYX_XDEC_MEMVIEW(&self.from_slice, 1)
20027  *
20028  *     cdef convert_item_to_object(self, char *itemp):             # <<<<<<<<<<<<<<
20029  *         if self.to_object_func != NULL:
20030  *             return self.to_object_func(itemp)
20031  */
20032 
__pyx_memoryviewslice_convert_item_to_object(struct __pyx_memoryviewslice_obj * __pyx_v_self,char * __pyx_v_itemp)20033 static PyObject *__pyx_memoryviewslice_convert_item_to_object(struct __pyx_memoryviewslice_obj *__pyx_v_self, char *__pyx_v_itemp) {
20034   PyObject *__pyx_r = NULL;
20035   __Pyx_RefNannyDeclarations
20036   int __pyx_t_1;
20037   PyObject *__pyx_t_2 = NULL;
20038   int __pyx_lineno = 0;
20039   const char *__pyx_filename = NULL;
20040   int __pyx_clineno = 0;
20041   __Pyx_RefNannySetupContext("convert_item_to_object", 0);
20042 
20043   /* "View.MemoryView":980
20044  *
20045  *     cdef convert_item_to_object(self, char *itemp):
20046  *         if self.to_object_func != NULL:             # <<<<<<<<<<<<<<
20047  *             return self.to_object_func(itemp)
20048  *         else:
20049  */
20050   __pyx_t_1 = ((__pyx_v_self->to_object_func != NULL) != 0);
20051   if (__pyx_t_1) {
20052 
20053     /* "View.MemoryView":981
20054  *     cdef convert_item_to_object(self, char *itemp):
20055  *         if self.to_object_func != NULL:
20056  *             return self.to_object_func(itemp)             # <<<<<<<<<<<<<<
20057  *         else:
20058  *             return memoryview.convert_item_to_object(self, itemp)
20059  */
20060     __Pyx_XDECREF(__pyx_r);
20061     __pyx_t_2 = __pyx_v_self->to_object_func(__pyx_v_itemp); if (unlikely(!__pyx_t_2)) __PYX_ERR(3, 981, __pyx_L1_error)
20062     __Pyx_GOTREF(__pyx_t_2);
20063     __pyx_r = __pyx_t_2;
20064     __pyx_t_2 = 0;
20065     goto __pyx_L0;
20066 
20067     /* "View.MemoryView":980
20068  *
20069  *     cdef convert_item_to_object(self, char *itemp):
20070  *         if self.to_object_func != NULL:             # <<<<<<<<<<<<<<
20071  *             return self.to_object_func(itemp)
20072  *         else:
20073  */
20074   }
20075 
20076   /* "View.MemoryView":983
20077  *             return self.to_object_func(itemp)
20078  *         else:
20079  *             return memoryview.convert_item_to_object(self, itemp)             # <<<<<<<<<<<<<<
20080  *
20081  *     cdef assign_item_from_object(self, char *itemp, object value):
20082  */
20083   /*else*/ {
20084     __Pyx_XDECREF(__pyx_r);
20085     __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)
20086     __Pyx_GOTREF(__pyx_t_2);
20087     __pyx_r = __pyx_t_2;
20088     __pyx_t_2 = 0;
20089     goto __pyx_L0;
20090   }
20091 
20092   /* "View.MemoryView":979
20093  *         __PYX_XDEC_MEMVIEW(&self.from_slice, 1)
20094  *
20095  *     cdef convert_item_to_object(self, char *itemp):             # <<<<<<<<<<<<<<
20096  *         if self.to_object_func != NULL:
20097  *             return self.to_object_func(itemp)
20098  */
20099 
20100   /* function exit code */
20101   __pyx_L1_error:;
20102   __Pyx_XDECREF(__pyx_t_2);
20103   __Pyx_AddTraceback("View.MemoryView._memoryviewslice.convert_item_to_object", __pyx_clineno, __pyx_lineno, __pyx_filename);
20104   __pyx_r = 0;
20105   __pyx_L0:;
20106   __Pyx_XGIVEREF(__pyx_r);
20107   __Pyx_RefNannyFinishContext();
20108   return __pyx_r;
20109 }
20110 
20111 /* "View.MemoryView":985
20112  *             return memoryview.convert_item_to_object(self, itemp)
20113  *
20114  *     cdef assign_item_from_object(self, char *itemp, object value):             # <<<<<<<<<<<<<<
20115  *         if self.to_dtype_func != NULL:
20116  *             self.to_dtype_func(itemp, value)
20117  */
20118 
__pyx_memoryviewslice_assign_item_from_object(struct __pyx_memoryviewslice_obj * __pyx_v_self,char * __pyx_v_itemp,PyObject * __pyx_v_value)20119 static PyObject *__pyx_memoryviewslice_assign_item_from_object(struct __pyx_memoryviewslice_obj *__pyx_v_self, char *__pyx_v_itemp, PyObject *__pyx_v_value) {
20120   PyObject *__pyx_r = NULL;
20121   __Pyx_RefNannyDeclarations
20122   int __pyx_t_1;
20123   int __pyx_t_2;
20124   PyObject *__pyx_t_3 = NULL;
20125   int __pyx_lineno = 0;
20126   const char *__pyx_filename = NULL;
20127   int __pyx_clineno = 0;
20128   __Pyx_RefNannySetupContext("assign_item_from_object", 0);
20129 
20130   /* "View.MemoryView":986
20131  *
20132  *     cdef assign_item_from_object(self, char *itemp, object value):
20133  *         if self.to_dtype_func != NULL:             # <<<<<<<<<<<<<<
20134  *             self.to_dtype_func(itemp, value)
20135  *         else:
20136  */
20137   __pyx_t_1 = ((__pyx_v_self->to_dtype_func != NULL) != 0);
20138   if (__pyx_t_1) {
20139 
20140     /* "View.MemoryView":987
20141  *     cdef assign_item_from_object(self, char *itemp, object value):
20142  *         if self.to_dtype_func != NULL:
20143  *             self.to_dtype_func(itemp, value)             # <<<<<<<<<<<<<<
20144  *         else:
20145  *             memoryview.assign_item_from_object(self, itemp, value)
20146  */
20147     __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)
20148 
20149     /* "View.MemoryView":986
20150  *
20151  *     cdef assign_item_from_object(self, char *itemp, object value):
20152  *         if self.to_dtype_func != NULL:             # <<<<<<<<<<<<<<
20153  *             self.to_dtype_func(itemp, value)
20154  *         else:
20155  */
20156     goto __pyx_L3;
20157   }
20158 
20159   /* "View.MemoryView":989
20160  *             self.to_dtype_func(itemp, value)
20161  *         else:
20162  *             memoryview.assign_item_from_object(self, itemp, value)             # <<<<<<<<<<<<<<
20163  *
20164  *     @property
20165  */
20166   /*else*/ {
20167     __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)
20168     __Pyx_GOTREF(__pyx_t_3);
20169     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
20170   }
20171   __pyx_L3:;
20172 
20173   /* "View.MemoryView":985
20174  *             return memoryview.convert_item_to_object(self, itemp)
20175  *
20176  *     cdef assign_item_from_object(self, char *itemp, object value):             # <<<<<<<<<<<<<<
20177  *         if self.to_dtype_func != NULL:
20178  *             self.to_dtype_func(itemp, value)
20179  */
20180 
20181   /* function exit code */
20182   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
20183   goto __pyx_L0;
20184   __pyx_L1_error:;
20185   __Pyx_XDECREF(__pyx_t_3);
20186   __Pyx_AddTraceback("View.MemoryView._memoryviewslice.assign_item_from_object", __pyx_clineno, __pyx_lineno, __pyx_filename);
20187   __pyx_r = 0;
20188   __pyx_L0:;
20189   __Pyx_XGIVEREF(__pyx_r);
20190   __Pyx_RefNannyFinishContext();
20191   return __pyx_r;
20192 }
20193 
20194 /* "View.MemoryView":992
20195  *
20196  *     @property
20197  *     def base(self):             # <<<<<<<<<<<<<<
20198  *         return self.from_object
20199  *
20200  */
20201 
20202 /* Python wrapper */
20203 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)20204 static PyObject *__pyx_pw_15View_dot_MemoryView_16_memoryviewslice_4base_1__get__(PyObject *__pyx_v_self) {
20205   PyObject *__pyx_r = 0;
20206   __Pyx_RefNannyDeclarations
20207   __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
20208   __pyx_r = __pyx_pf_15View_dot_MemoryView_16_memoryviewslice_4base___get__(((struct __pyx_memoryviewslice_obj *)__pyx_v_self));
20209 
20210   /* function exit code */
20211   __Pyx_RefNannyFinishContext();
20212   return __pyx_r;
20213 }
20214 
__pyx_pf_15View_dot_MemoryView_16_memoryviewslice_4base___get__(struct __pyx_memoryviewslice_obj * __pyx_v_self)20215 static PyObject *__pyx_pf_15View_dot_MemoryView_16_memoryviewslice_4base___get__(struct __pyx_memoryviewslice_obj *__pyx_v_self) {
20216   PyObject *__pyx_r = NULL;
20217   __Pyx_RefNannyDeclarations
20218   __Pyx_RefNannySetupContext("__get__", 0);
20219 
20220   /* "View.MemoryView":993
20221  *     @property
20222  *     def base(self):
20223  *         return self.from_object             # <<<<<<<<<<<<<<
20224  *
20225  *     __pyx_getbuffer = capsule(<void *> &__pyx_memoryview_getbuffer, "getbuffer(obj, view, flags)")
20226  */
20227   __Pyx_XDECREF(__pyx_r);
20228   __Pyx_INCREF(__pyx_v_self->from_object);
20229   __pyx_r = __pyx_v_self->from_object;
20230   goto __pyx_L0;
20231 
20232   /* "View.MemoryView":992
20233  *
20234  *     @property
20235  *     def base(self):             # <<<<<<<<<<<<<<
20236  *         return self.from_object
20237  *
20238  */
20239 
20240   /* function exit code */
20241   __pyx_L0:;
20242   __Pyx_XGIVEREF(__pyx_r);
20243   __Pyx_RefNannyFinishContext();
20244   return __pyx_r;
20245 }
20246 
20247 /* "(tree fragment)":1
20248  * def __reduce_cython__(self):             # <<<<<<<<<<<<<<
20249  *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
20250  * def __setstate_cython__(self, __pyx_state):
20251  */
20252 
20253 /* Python wrapper */
20254 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)20255 static PyObject *__pyx_pw___pyx_memoryviewslice_1__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
20256   PyObject *__pyx_r = 0;
20257   __Pyx_RefNannyDeclarations
20258   __Pyx_RefNannySetupContext("__reduce_cython__ (wrapper)", 0);
20259   __pyx_r = __pyx_pf___pyx_memoryviewslice___reduce_cython__(((struct __pyx_memoryviewslice_obj *)__pyx_v_self));
20260 
20261   /* function exit code */
20262   __Pyx_RefNannyFinishContext();
20263   return __pyx_r;
20264 }
20265 
__pyx_pf___pyx_memoryviewslice___reduce_cython__(CYTHON_UNUSED struct __pyx_memoryviewslice_obj * __pyx_v_self)20266 static PyObject *__pyx_pf___pyx_memoryviewslice___reduce_cython__(CYTHON_UNUSED struct __pyx_memoryviewslice_obj *__pyx_v_self) {
20267   PyObject *__pyx_r = NULL;
20268   __Pyx_RefNannyDeclarations
20269   PyObject *__pyx_t_1 = NULL;
20270   int __pyx_lineno = 0;
20271   const char *__pyx_filename = NULL;
20272   int __pyx_clineno = 0;
20273   __Pyx_RefNannySetupContext("__reduce_cython__", 0);
20274 
20275   /* "(tree fragment)":2
20276  * def __reduce_cython__(self):
20277  *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")             # <<<<<<<<<<<<<<
20278  * def __setstate_cython__(self, __pyx_state):
20279  *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
20280  */
20281   __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__35, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(3, 2, __pyx_L1_error)
20282   __Pyx_GOTREF(__pyx_t_1);
20283   __Pyx_Raise(__pyx_t_1, 0, 0, 0);
20284   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
20285   __PYX_ERR(3, 2, __pyx_L1_error)
20286 
20287   /* "(tree fragment)":1
20288  * def __reduce_cython__(self):             # <<<<<<<<<<<<<<
20289  *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
20290  * def __setstate_cython__(self, __pyx_state):
20291  */
20292 
20293   /* function exit code */
20294   __pyx_L1_error:;
20295   __Pyx_XDECREF(__pyx_t_1);
20296   __Pyx_AddTraceback("View.MemoryView._memoryviewslice.__reduce_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename);
20297   __pyx_r = NULL;
20298   __Pyx_XGIVEREF(__pyx_r);
20299   __Pyx_RefNannyFinishContext();
20300   return __pyx_r;
20301 }
20302 
20303 /* "(tree fragment)":3
20304  * def __reduce_cython__(self):
20305  *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
20306  * def __setstate_cython__(self, __pyx_state):             # <<<<<<<<<<<<<<
20307  *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
20308  */
20309 
20310 /* Python wrapper */
20311 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)20312 static PyObject *__pyx_pw___pyx_memoryviewslice_3__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state) {
20313   PyObject *__pyx_r = 0;
20314   __Pyx_RefNannyDeclarations
20315   __Pyx_RefNannySetupContext("__setstate_cython__ (wrapper)", 0);
20316   __pyx_r = __pyx_pf___pyx_memoryviewslice_2__setstate_cython__(((struct __pyx_memoryviewslice_obj *)__pyx_v_self), ((PyObject *)__pyx_v___pyx_state));
20317 
20318   /* function exit code */
20319   __Pyx_RefNannyFinishContext();
20320   return __pyx_r;
20321 }
20322 
__pyx_pf___pyx_memoryviewslice_2__setstate_cython__(CYTHON_UNUSED struct __pyx_memoryviewslice_obj * __pyx_v_self,CYTHON_UNUSED PyObject * __pyx_v___pyx_state)20323 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) {
20324   PyObject *__pyx_r = NULL;
20325   __Pyx_RefNannyDeclarations
20326   PyObject *__pyx_t_1 = NULL;
20327   int __pyx_lineno = 0;
20328   const char *__pyx_filename = NULL;
20329   int __pyx_clineno = 0;
20330   __Pyx_RefNannySetupContext("__setstate_cython__", 0);
20331 
20332   /* "(tree fragment)":4
20333  *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
20334  * def __setstate_cython__(self, __pyx_state):
20335  *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")             # <<<<<<<<<<<<<<
20336  */
20337   __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__36, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(3, 4, __pyx_L1_error)
20338   __Pyx_GOTREF(__pyx_t_1);
20339   __Pyx_Raise(__pyx_t_1, 0, 0, 0);
20340   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
20341   __PYX_ERR(3, 4, __pyx_L1_error)
20342 
20343   /* "(tree fragment)":3
20344  * def __reduce_cython__(self):
20345  *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
20346  * def __setstate_cython__(self, __pyx_state):             # <<<<<<<<<<<<<<
20347  *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
20348  */
20349 
20350   /* function exit code */
20351   __pyx_L1_error:;
20352   __Pyx_XDECREF(__pyx_t_1);
20353   __Pyx_AddTraceback("View.MemoryView._memoryviewslice.__setstate_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename);
20354   __pyx_r = NULL;
20355   __Pyx_XGIVEREF(__pyx_r);
20356   __Pyx_RefNannyFinishContext();
20357   return __pyx_r;
20358 }
20359 
20360 /* "View.MemoryView":999
20361  *
20362  * @cname('__pyx_memoryview_fromslice')
20363  * cdef memoryview_fromslice(__Pyx_memviewslice memviewslice,             # <<<<<<<<<<<<<<
20364  *                           int ndim,
20365  *                           object (*to_object_func)(char *),
20366  */
20367 
__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)20368 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) {
20369   struct __pyx_memoryviewslice_obj *__pyx_v_result = 0;
20370   Py_ssize_t __pyx_v_suboffset;
20371   PyObject *__pyx_v_length = NULL;
20372   PyObject *__pyx_r = NULL;
20373   __Pyx_RefNannyDeclarations
20374   int __pyx_t_1;
20375   PyObject *__pyx_t_2 = NULL;
20376   PyObject *__pyx_t_3 = NULL;
20377   __Pyx_TypeInfo *__pyx_t_4;
20378   Py_buffer __pyx_t_5;
20379   Py_ssize_t *__pyx_t_6;
20380   Py_ssize_t *__pyx_t_7;
20381   Py_ssize_t *__pyx_t_8;
20382   Py_ssize_t __pyx_t_9;
20383   int __pyx_lineno = 0;
20384   const char *__pyx_filename = NULL;
20385   int __pyx_clineno = 0;
20386   __Pyx_RefNannySetupContext("memoryview_fromslice", 0);
20387 
20388   /* "View.MemoryView":1007
20389  *     cdef _memoryviewslice result
20390  *
20391  *     if <PyObject *> memviewslice.memview == Py_None:             # <<<<<<<<<<<<<<
20392  *         return None
20393  *
20394  */
20395   __pyx_t_1 = ((((PyObject *)__pyx_v_memviewslice.memview) == Py_None) != 0);
20396   if (__pyx_t_1) {
20397 
20398     /* "View.MemoryView":1008
20399  *
20400  *     if <PyObject *> memviewslice.memview == Py_None:
20401  *         return None             # <<<<<<<<<<<<<<
20402  *
20403  *
20404  */
20405     __Pyx_XDECREF(__pyx_r);
20406     __pyx_r = Py_None; __Pyx_INCREF(Py_None);
20407     goto __pyx_L0;
20408 
20409     /* "View.MemoryView":1007
20410  *     cdef _memoryviewslice result
20411  *
20412  *     if <PyObject *> memviewslice.memview == Py_None:             # <<<<<<<<<<<<<<
20413  *         return None
20414  *
20415  */
20416   }
20417 
20418   /* "View.MemoryView":1013
20419  *
20420  *
20421  *     result = _memoryviewslice(None, 0, dtype_is_object)             # <<<<<<<<<<<<<<
20422  *
20423  *     result.from_slice = memviewslice
20424  */
20425   __pyx_t_2 = __Pyx_PyBool_FromLong(__pyx_v_dtype_is_object); if (unlikely(!__pyx_t_2)) __PYX_ERR(3, 1013, __pyx_L1_error)
20426   __Pyx_GOTREF(__pyx_t_2);
20427   __pyx_t_3 = PyTuple_New(3); if (unlikely(!__pyx_t_3)) __PYX_ERR(3, 1013, __pyx_L1_error)
20428   __Pyx_GOTREF(__pyx_t_3);
20429   __Pyx_INCREF(Py_None);
20430   __Pyx_GIVEREF(Py_None);
20431   PyTuple_SET_ITEM(__pyx_t_3, 0, Py_None);
20432   __Pyx_INCREF(__pyx_int_0);
20433   __Pyx_GIVEREF(__pyx_int_0);
20434   PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_int_0);
20435   __Pyx_GIVEREF(__pyx_t_2);
20436   PyTuple_SET_ITEM(__pyx_t_3, 2, __pyx_t_2);
20437   __pyx_t_2 = 0;
20438   __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)
20439   __Pyx_GOTREF(__pyx_t_2);
20440   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
20441   __pyx_v_result = ((struct __pyx_memoryviewslice_obj *)__pyx_t_2);
20442   __pyx_t_2 = 0;
20443 
20444   /* "View.MemoryView":1015
20445  *     result = _memoryviewslice(None, 0, dtype_is_object)
20446  *
20447  *     result.from_slice = memviewslice             # <<<<<<<<<<<<<<
20448  *     __PYX_INC_MEMVIEW(&memviewslice, 1)
20449  *
20450  */
20451   __pyx_v_result->from_slice = __pyx_v_memviewslice;
20452 
20453   /* "View.MemoryView":1016
20454  *
20455  *     result.from_slice = memviewslice
20456  *     __PYX_INC_MEMVIEW(&memviewslice, 1)             # <<<<<<<<<<<<<<
20457  *
20458  *     result.from_object = (<memoryview> memviewslice.memview).base
20459  */
20460   __PYX_INC_MEMVIEW((&__pyx_v_memviewslice), 1);
20461 
20462   /* "View.MemoryView":1018
20463  *     __PYX_INC_MEMVIEW(&memviewslice, 1)
20464  *
20465  *     result.from_object = (<memoryview> memviewslice.memview).base             # <<<<<<<<<<<<<<
20466  *     result.typeinfo = memviewslice.memview.typeinfo
20467  *
20468  */
20469   __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)
20470   __Pyx_GOTREF(__pyx_t_2);
20471   __Pyx_GIVEREF(__pyx_t_2);
20472   __Pyx_GOTREF(__pyx_v_result->from_object);
20473   __Pyx_DECREF(__pyx_v_result->from_object);
20474   __pyx_v_result->from_object = __pyx_t_2;
20475   __pyx_t_2 = 0;
20476 
20477   /* "View.MemoryView":1019
20478  *
20479  *     result.from_object = (<memoryview> memviewslice.memview).base
20480  *     result.typeinfo = memviewslice.memview.typeinfo             # <<<<<<<<<<<<<<
20481  *
20482  *     result.view = memviewslice.memview.view
20483  */
20484   __pyx_t_4 = __pyx_v_memviewslice.memview->typeinfo;
20485   __pyx_v_result->__pyx_base.typeinfo = __pyx_t_4;
20486 
20487   /* "View.MemoryView":1021
20488  *     result.typeinfo = memviewslice.memview.typeinfo
20489  *
20490  *     result.view = memviewslice.memview.view             # <<<<<<<<<<<<<<
20491  *     result.view.buf = <void *> memviewslice.data
20492  *     result.view.ndim = ndim
20493  */
20494   __pyx_t_5 = __pyx_v_memviewslice.memview->view;
20495   __pyx_v_result->__pyx_base.view = __pyx_t_5;
20496 
20497   /* "View.MemoryView":1022
20498  *
20499  *     result.view = memviewslice.memview.view
20500  *     result.view.buf = <void *> memviewslice.data             # <<<<<<<<<<<<<<
20501  *     result.view.ndim = ndim
20502  *     (<__pyx_buffer *> &result.view).obj = Py_None
20503  */
20504   __pyx_v_result->__pyx_base.view.buf = ((void *)__pyx_v_memviewslice.data);
20505 
20506   /* "View.MemoryView":1023
20507  *     result.view = memviewslice.memview.view
20508  *     result.view.buf = <void *> memviewslice.data
20509  *     result.view.ndim = ndim             # <<<<<<<<<<<<<<
20510  *     (<__pyx_buffer *> &result.view).obj = Py_None
20511  *     Py_INCREF(Py_None)
20512  */
20513   __pyx_v_result->__pyx_base.view.ndim = __pyx_v_ndim;
20514 
20515   /* "View.MemoryView":1024
20516  *     result.view.buf = <void *> memviewslice.data
20517  *     result.view.ndim = ndim
20518  *     (<__pyx_buffer *> &result.view).obj = Py_None             # <<<<<<<<<<<<<<
20519  *     Py_INCREF(Py_None)
20520  *
20521  */
20522   ((Py_buffer *)(&__pyx_v_result->__pyx_base.view))->obj = Py_None;
20523 
20524   /* "View.MemoryView":1025
20525  *     result.view.ndim = ndim
20526  *     (<__pyx_buffer *> &result.view).obj = Py_None
20527  *     Py_INCREF(Py_None)             # <<<<<<<<<<<<<<
20528  *
20529  *     if (<memoryview>memviewslice.memview).flags & PyBUF_WRITABLE:
20530  */
20531   Py_INCREF(Py_None);
20532 
20533   /* "View.MemoryView":1027
20534  *     Py_INCREF(Py_None)
20535  *
20536  *     if (<memoryview>memviewslice.memview).flags & PyBUF_WRITABLE:             # <<<<<<<<<<<<<<
20537  *         result.flags = PyBUF_RECORDS
20538  *     else:
20539  */
20540   __pyx_t_1 = ((((struct __pyx_memoryview_obj *)__pyx_v_memviewslice.memview)->flags & PyBUF_WRITABLE) != 0);
20541   if (__pyx_t_1) {
20542 
20543     /* "View.MemoryView":1028
20544  *
20545  *     if (<memoryview>memviewslice.memview).flags & PyBUF_WRITABLE:
20546  *         result.flags = PyBUF_RECORDS             # <<<<<<<<<<<<<<
20547  *     else:
20548  *         result.flags = PyBUF_RECORDS_RO
20549  */
20550     __pyx_v_result->__pyx_base.flags = PyBUF_RECORDS;
20551 
20552     /* "View.MemoryView":1027
20553  *     Py_INCREF(Py_None)
20554  *
20555  *     if (<memoryview>memviewslice.memview).flags & PyBUF_WRITABLE:             # <<<<<<<<<<<<<<
20556  *         result.flags = PyBUF_RECORDS
20557  *     else:
20558  */
20559     goto __pyx_L4;
20560   }
20561 
20562   /* "View.MemoryView":1030
20563  *         result.flags = PyBUF_RECORDS
20564  *     else:
20565  *         result.flags = PyBUF_RECORDS_RO             # <<<<<<<<<<<<<<
20566  *
20567  *     result.view.shape = <Py_ssize_t *> result.from_slice.shape
20568  */
20569   /*else*/ {
20570     __pyx_v_result->__pyx_base.flags = PyBUF_RECORDS_RO;
20571   }
20572   __pyx_L4:;
20573 
20574   /* "View.MemoryView":1032
20575  *         result.flags = PyBUF_RECORDS_RO
20576  *
20577  *     result.view.shape = <Py_ssize_t *> result.from_slice.shape             # <<<<<<<<<<<<<<
20578  *     result.view.strides = <Py_ssize_t *> result.from_slice.strides
20579  *
20580  */
20581   __pyx_v_result->__pyx_base.view.shape = ((Py_ssize_t *)__pyx_v_result->from_slice.shape);
20582 
20583   /* "View.MemoryView":1033
20584  *
20585  *     result.view.shape = <Py_ssize_t *> result.from_slice.shape
20586  *     result.view.strides = <Py_ssize_t *> result.from_slice.strides             # <<<<<<<<<<<<<<
20587  *
20588  *
20589  */
20590   __pyx_v_result->__pyx_base.view.strides = ((Py_ssize_t *)__pyx_v_result->from_slice.strides);
20591 
20592   /* "View.MemoryView":1036
20593  *
20594  *
20595  *     result.view.suboffsets = NULL             # <<<<<<<<<<<<<<
20596  *     for suboffset in result.from_slice.suboffsets[:ndim]:
20597  *         if suboffset >= 0:
20598  */
20599   __pyx_v_result->__pyx_base.view.suboffsets = NULL;
20600 
20601   /* "View.MemoryView":1037
20602  *
20603  *     result.view.suboffsets = NULL
20604  *     for suboffset in result.from_slice.suboffsets[:ndim]:             # <<<<<<<<<<<<<<
20605  *         if suboffset >= 0:
20606  *             result.view.suboffsets = <Py_ssize_t *> result.from_slice.suboffsets
20607  */
20608   __pyx_t_7 = (__pyx_v_result->from_slice.suboffsets + __pyx_v_ndim);
20609   for (__pyx_t_8 = __pyx_v_result->from_slice.suboffsets; __pyx_t_8 < __pyx_t_7; __pyx_t_8++) {
20610     __pyx_t_6 = __pyx_t_8;
20611     __pyx_v_suboffset = (__pyx_t_6[0]);
20612 
20613     /* "View.MemoryView":1038
20614  *     result.view.suboffsets = NULL
20615  *     for suboffset in result.from_slice.suboffsets[:ndim]:
20616  *         if suboffset >= 0:             # <<<<<<<<<<<<<<
20617  *             result.view.suboffsets = <Py_ssize_t *> result.from_slice.suboffsets
20618  *             break
20619  */
20620     __pyx_t_1 = ((__pyx_v_suboffset >= 0) != 0);
20621     if (__pyx_t_1) {
20622 
20623       /* "View.MemoryView":1039
20624  *     for suboffset in result.from_slice.suboffsets[:ndim]:
20625  *         if suboffset >= 0:
20626  *             result.view.suboffsets = <Py_ssize_t *> result.from_slice.suboffsets             # <<<<<<<<<<<<<<
20627  *             break
20628  *
20629  */
20630       __pyx_v_result->__pyx_base.view.suboffsets = ((Py_ssize_t *)__pyx_v_result->from_slice.suboffsets);
20631 
20632       /* "View.MemoryView":1040
20633  *         if suboffset >= 0:
20634  *             result.view.suboffsets = <Py_ssize_t *> result.from_slice.suboffsets
20635  *             break             # <<<<<<<<<<<<<<
20636  *
20637  *     result.view.len = result.view.itemsize
20638  */
20639       goto __pyx_L6_break;
20640 
20641       /* "View.MemoryView":1038
20642  *     result.view.suboffsets = NULL
20643  *     for suboffset in result.from_slice.suboffsets[:ndim]:
20644  *         if suboffset >= 0:             # <<<<<<<<<<<<<<
20645  *             result.view.suboffsets = <Py_ssize_t *> result.from_slice.suboffsets
20646  *             break
20647  */
20648     }
20649   }
20650   __pyx_L6_break:;
20651 
20652   /* "View.MemoryView":1042
20653  *             break
20654  *
20655  *     result.view.len = result.view.itemsize             # <<<<<<<<<<<<<<
20656  *     for length in result.view.shape[:ndim]:
20657  *         result.view.len *= length
20658  */
20659   __pyx_t_9 = __pyx_v_result->__pyx_base.view.itemsize;
20660   __pyx_v_result->__pyx_base.view.len = __pyx_t_9;
20661 
20662   /* "View.MemoryView":1043
20663  *
20664  *     result.view.len = result.view.itemsize
20665  *     for length in result.view.shape[:ndim]:             # <<<<<<<<<<<<<<
20666  *         result.view.len *= length
20667  *
20668  */
20669   __pyx_t_7 = (__pyx_v_result->__pyx_base.view.shape + __pyx_v_ndim);
20670   for (__pyx_t_8 = __pyx_v_result->__pyx_base.view.shape; __pyx_t_8 < __pyx_t_7; __pyx_t_8++) {
20671     __pyx_t_6 = __pyx_t_8;
20672     __pyx_t_2 = PyInt_FromSsize_t((__pyx_t_6[0])); if (unlikely(!__pyx_t_2)) __PYX_ERR(3, 1043, __pyx_L1_error)
20673     __Pyx_GOTREF(__pyx_t_2);
20674     __Pyx_XDECREF_SET(__pyx_v_length, __pyx_t_2);
20675     __pyx_t_2 = 0;
20676 
20677     /* "View.MemoryView":1044
20678  *     result.view.len = result.view.itemsize
20679  *     for length in result.view.shape[:ndim]:
20680  *         result.view.len *= length             # <<<<<<<<<<<<<<
20681  *
20682  *     result.to_object_func = to_object_func
20683  */
20684     __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)
20685     __Pyx_GOTREF(__pyx_t_2);
20686     __pyx_t_3 = PyNumber_InPlaceMultiply(__pyx_t_2, __pyx_v_length); if (unlikely(!__pyx_t_3)) __PYX_ERR(3, 1044, __pyx_L1_error)
20687     __Pyx_GOTREF(__pyx_t_3);
20688     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
20689     __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)
20690     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
20691     __pyx_v_result->__pyx_base.view.len = __pyx_t_9;
20692   }
20693 
20694   /* "View.MemoryView":1046
20695  *         result.view.len *= length
20696  *
20697  *     result.to_object_func = to_object_func             # <<<<<<<<<<<<<<
20698  *     result.to_dtype_func = to_dtype_func
20699  *
20700  */
20701   __pyx_v_result->to_object_func = __pyx_v_to_object_func;
20702 
20703   /* "View.MemoryView":1047
20704  *
20705  *     result.to_object_func = to_object_func
20706  *     result.to_dtype_func = to_dtype_func             # <<<<<<<<<<<<<<
20707  *
20708  *     return result
20709  */
20710   __pyx_v_result->to_dtype_func = __pyx_v_to_dtype_func;
20711 
20712   /* "View.MemoryView":1049
20713  *     result.to_dtype_func = to_dtype_func
20714  *
20715  *     return result             # <<<<<<<<<<<<<<
20716  *
20717  * @cname('__pyx_memoryview_get_slice_from_memoryview')
20718  */
20719   __Pyx_XDECREF(__pyx_r);
20720   __Pyx_INCREF(((PyObject *)__pyx_v_result));
20721   __pyx_r = ((PyObject *)__pyx_v_result);
20722   goto __pyx_L0;
20723 
20724   /* "View.MemoryView":999
20725  *
20726  * @cname('__pyx_memoryview_fromslice')
20727  * cdef memoryview_fromslice(__Pyx_memviewslice memviewslice,             # <<<<<<<<<<<<<<
20728  *                           int ndim,
20729  *                           object (*to_object_func)(char *),
20730  */
20731 
20732   /* function exit code */
20733   __pyx_L1_error:;
20734   __Pyx_XDECREF(__pyx_t_2);
20735   __Pyx_XDECREF(__pyx_t_3);
20736   __Pyx_AddTraceback("View.MemoryView.memoryview_fromslice", __pyx_clineno, __pyx_lineno, __pyx_filename);
20737   __pyx_r = 0;
20738   __pyx_L0:;
20739   __Pyx_XDECREF((PyObject *)__pyx_v_result);
20740   __Pyx_XDECREF(__pyx_v_length);
20741   __Pyx_XGIVEREF(__pyx_r);
20742   __Pyx_RefNannyFinishContext();
20743   return __pyx_r;
20744 }
20745 
20746 /* "View.MemoryView":1052
20747  *
20748  * @cname('__pyx_memoryview_get_slice_from_memoryview')
20749  * cdef __Pyx_memviewslice *get_slice_from_memview(memoryview memview,             # <<<<<<<<<<<<<<
20750  *                                                    __Pyx_memviewslice *mslice) except NULL:
20751  *     cdef _memoryviewslice obj
20752  */
20753 
__pyx_memoryview_get_slice_from_memoryview(struct __pyx_memoryview_obj * __pyx_v_memview,__Pyx_memviewslice * __pyx_v_mslice)20754 static __Pyx_memviewslice *__pyx_memoryview_get_slice_from_memoryview(struct __pyx_memoryview_obj *__pyx_v_memview, __Pyx_memviewslice *__pyx_v_mslice) {
20755   struct __pyx_memoryviewslice_obj *__pyx_v_obj = 0;
20756   __Pyx_memviewslice *__pyx_r;
20757   __Pyx_RefNannyDeclarations
20758   int __pyx_t_1;
20759   int __pyx_t_2;
20760   PyObject *__pyx_t_3 = NULL;
20761   int __pyx_lineno = 0;
20762   const char *__pyx_filename = NULL;
20763   int __pyx_clineno = 0;
20764   __Pyx_RefNannySetupContext("get_slice_from_memview", 0);
20765 
20766   /* "View.MemoryView":1055
20767  *                                                    __Pyx_memviewslice *mslice) except NULL:
20768  *     cdef _memoryviewslice obj
20769  *     if isinstance(memview, _memoryviewslice):             # <<<<<<<<<<<<<<
20770  *         obj = memview
20771  *         return &obj.from_slice
20772  */
20773   __pyx_t_1 = __Pyx_TypeCheck(((PyObject *)__pyx_v_memview), __pyx_memoryviewslice_type);
20774   __pyx_t_2 = (__pyx_t_1 != 0);
20775   if (__pyx_t_2) {
20776 
20777     /* "View.MemoryView":1056
20778  *     cdef _memoryviewslice obj
20779  *     if isinstance(memview, _memoryviewslice):
20780  *         obj = memview             # <<<<<<<<<<<<<<
20781  *         return &obj.from_slice
20782  *     else:
20783  */
20784     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)
20785     __pyx_t_3 = ((PyObject *)__pyx_v_memview);
20786     __Pyx_INCREF(__pyx_t_3);
20787     __pyx_v_obj = ((struct __pyx_memoryviewslice_obj *)__pyx_t_3);
20788     __pyx_t_3 = 0;
20789 
20790     /* "View.MemoryView":1057
20791  *     if isinstance(memview, _memoryviewslice):
20792  *         obj = memview
20793  *         return &obj.from_slice             # <<<<<<<<<<<<<<
20794  *     else:
20795  *         slice_copy(memview, mslice)
20796  */
20797     __pyx_r = (&__pyx_v_obj->from_slice);
20798     goto __pyx_L0;
20799 
20800     /* "View.MemoryView":1055
20801  *                                                    __Pyx_memviewslice *mslice) except NULL:
20802  *     cdef _memoryviewslice obj
20803  *     if isinstance(memview, _memoryviewslice):             # <<<<<<<<<<<<<<
20804  *         obj = memview
20805  *         return &obj.from_slice
20806  */
20807   }
20808 
20809   /* "View.MemoryView":1059
20810  *         return &obj.from_slice
20811  *     else:
20812  *         slice_copy(memview, mslice)             # <<<<<<<<<<<<<<
20813  *         return mslice
20814  *
20815  */
20816   /*else*/ {
20817     __pyx_memoryview_slice_copy(__pyx_v_memview, __pyx_v_mslice);
20818 
20819     /* "View.MemoryView":1060
20820  *     else:
20821  *         slice_copy(memview, mslice)
20822  *         return mslice             # <<<<<<<<<<<<<<
20823  *
20824  * @cname('__pyx_memoryview_slice_copy')
20825  */
20826     __pyx_r = __pyx_v_mslice;
20827     goto __pyx_L0;
20828   }
20829 
20830   /* "View.MemoryView":1052
20831  *
20832  * @cname('__pyx_memoryview_get_slice_from_memoryview')
20833  * cdef __Pyx_memviewslice *get_slice_from_memview(memoryview memview,             # <<<<<<<<<<<<<<
20834  *                                                    __Pyx_memviewslice *mslice) except NULL:
20835  *     cdef _memoryviewslice obj
20836  */
20837 
20838   /* function exit code */
20839   __pyx_L1_error:;
20840   __Pyx_XDECREF(__pyx_t_3);
20841   __Pyx_AddTraceback("View.MemoryView.get_slice_from_memview", __pyx_clineno, __pyx_lineno, __pyx_filename);
20842   __pyx_r = NULL;
20843   __pyx_L0:;
20844   __Pyx_XDECREF((PyObject *)__pyx_v_obj);
20845   __Pyx_RefNannyFinishContext();
20846   return __pyx_r;
20847 }
20848 
20849 /* "View.MemoryView":1063
20850  *
20851  * @cname('__pyx_memoryview_slice_copy')
20852  * cdef void slice_copy(memoryview memview, __Pyx_memviewslice *dst):             # <<<<<<<<<<<<<<
20853  *     cdef int dim
20854  *     cdef (Py_ssize_t*) shape, strides, suboffsets
20855  */
20856 
__pyx_memoryview_slice_copy(struct __pyx_memoryview_obj * __pyx_v_memview,__Pyx_memviewslice * __pyx_v_dst)20857 static void __pyx_memoryview_slice_copy(struct __pyx_memoryview_obj *__pyx_v_memview, __Pyx_memviewslice *__pyx_v_dst) {
20858   int __pyx_v_dim;
20859   Py_ssize_t *__pyx_v_shape;
20860   Py_ssize_t *__pyx_v_strides;
20861   Py_ssize_t *__pyx_v_suboffsets;
20862   __Pyx_RefNannyDeclarations
20863   Py_ssize_t *__pyx_t_1;
20864   int __pyx_t_2;
20865   int __pyx_t_3;
20866   int __pyx_t_4;
20867   Py_ssize_t __pyx_t_5;
20868   __Pyx_RefNannySetupContext("slice_copy", 0);
20869 
20870   /* "View.MemoryView":1067
20871  *     cdef (Py_ssize_t*) shape, strides, suboffsets
20872  *
20873  *     shape = memview.view.shape             # <<<<<<<<<<<<<<
20874  *     strides = memview.view.strides
20875  *     suboffsets = memview.view.suboffsets
20876  */
20877   __pyx_t_1 = __pyx_v_memview->view.shape;
20878   __pyx_v_shape = __pyx_t_1;
20879 
20880   /* "View.MemoryView":1068
20881  *
20882  *     shape = memview.view.shape
20883  *     strides = memview.view.strides             # <<<<<<<<<<<<<<
20884  *     suboffsets = memview.view.suboffsets
20885  *
20886  */
20887   __pyx_t_1 = __pyx_v_memview->view.strides;
20888   __pyx_v_strides = __pyx_t_1;
20889 
20890   /* "View.MemoryView":1069
20891  *     shape = memview.view.shape
20892  *     strides = memview.view.strides
20893  *     suboffsets = memview.view.suboffsets             # <<<<<<<<<<<<<<
20894  *
20895  *     dst.memview = <__pyx_memoryview *> memview
20896  */
20897   __pyx_t_1 = __pyx_v_memview->view.suboffsets;
20898   __pyx_v_suboffsets = __pyx_t_1;
20899 
20900   /* "View.MemoryView":1071
20901  *     suboffsets = memview.view.suboffsets
20902  *
20903  *     dst.memview = <__pyx_memoryview *> memview             # <<<<<<<<<<<<<<
20904  *     dst.data = <char *> memview.view.buf
20905  *
20906  */
20907   __pyx_v_dst->memview = ((struct __pyx_memoryview_obj *)__pyx_v_memview);
20908 
20909   /* "View.MemoryView":1072
20910  *
20911  *     dst.memview = <__pyx_memoryview *> memview
20912  *     dst.data = <char *> memview.view.buf             # <<<<<<<<<<<<<<
20913  *
20914  *     for dim in range(memview.view.ndim):
20915  */
20916   __pyx_v_dst->data = ((char *)__pyx_v_memview->view.buf);
20917 
20918   /* "View.MemoryView":1074
20919  *     dst.data = <char *> memview.view.buf
20920  *
20921  *     for dim in range(memview.view.ndim):             # <<<<<<<<<<<<<<
20922  *         dst.shape[dim] = shape[dim]
20923  *         dst.strides[dim] = strides[dim]
20924  */
20925   __pyx_t_2 = __pyx_v_memview->view.ndim;
20926   __pyx_t_3 = __pyx_t_2;
20927   for (__pyx_t_4 = 0; __pyx_t_4 < __pyx_t_3; __pyx_t_4+=1) {
20928     __pyx_v_dim = __pyx_t_4;
20929 
20930     /* "View.MemoryView":1075
20931  *
20932  *     for dim in range(memview.view.ndim):
20933  *         dst.shape[dim] = shape[dim]             # <<<<<<<<<<<<<<
20934  *         dst.strides[dim] = strides[dim]
20935  *         dst.suboffsets[dim] = suboffsets[dim] if suboffsets else -1
20936  */
20937     (__pyx_v_dst->shape[__pyx_v_dim]) = (__pyx_v_shape[__pyx_v_dim]);
20938 
20939     /* "View.MemoryView":1076
20940  *     for dim in range(memview.view.ndim):
20941  *         dst.shape[dim] = shape[dim]
20942  *         dst.strides[dim] = strides[dim]             # <<<<<<<<<<<<<<
20943  *         dst.suboffsets[dim] = suboffsets[dim] if suboffsets else -1
20944  *
20945  */
20946     (__pyx_v_dst->strides[__pyx_v_dim]) = (__pyx_v_strides[__pyx_v_dim]);
20947 
20948     /* "View.MemoryView":1077
20949  *         dst.shape[dim] = shape[dim]
20950  *         dst.strides[dim] = strides[dim]
20951  *         dst.suboffsets[dim] = suboffsets[dim] if suboffsets else -1             # <<<<<<<<<<<<<<
20952  *
20953  * @cname('__pyx_memoryview_copy_object')
20954  */
20955     if ((__pyx_v_suboffsets != 0)) {
20956       __pyx_t_5 = (__pyx_v_suboffsets[__pyx_v_dim]);
20957     } else {
20958       __pyx_t_5 = -1L;
20959     }
20960     (__pyx_v_dst->suboffsets[__pyx_v_dim]) = __pyx_t_5;
20961   }
20962 
20963   /* "View.MemoryView":1063
20964  *
20965  * @cname('__pyx_memoryview_slice_copy')
20966  * cdef void slice_copy(memoryview memview, __Pyx_memviewslice *dst):             # <<<<<<<<<<<<<<
20967  *     cdef int dim
20968  *     cdef (Py_ssize_t*) shape, strides, suboffsets
20969  */
20970 
20971   /* function exit code */
20972   __Pyx_RefNannyFinishContext();
20973 }
20974 
20975 /* "View.MemoryView":1080
20976  *
20977  * @cname('__pyx_memoryview_copy_object')
20978  * cdef memoryview_copy(memoryview memview):             # <<<<<<<<<<<<<<
20979  *     "Create a new memoryview object"
20980  *     cdef __Pyx_memviewslice memviewslice
20981  */
20982 
__pyx_memoryview_copy_object(struct __pyx_memoryview_obj * __pyx_v_memview)20983 static PyObject *__pyx_memoryview_copy_object(struct __pyx_memoryview_obj *__pyx_v_memview) {
20984   __Pyx_memviewslice __pyx_v_memviewslice;
20985   PyObject *__pyx_r = NULL;
20986   __Pyx_RefNannyDeclarations
20987   PyObject *__pyx_t_1 = NULL;
20988   int __pyx_lineno = 0;
20989   const char *__pyx_filename = NULL;
20990   int __pyx_clineno = 0;
20991   __Pyx_RefNannySetupContext("memoryview_copy", 0);
20992 
20993   /* "View.MemoryView":1083
20994  *     "Create a new memoryview object"
20995  *     cdef __Pyx_memviewslice memviewslice
20996  *     slice_copy(memview, &memviewslice)             # <<<<<<<<<<<<<<
20997  *     return memoryview_copy_from_slice(memview, &memviewslice)
20998  *
20999  */
21000   __pyx_memoryview_slice_copy(__pyx_v_memview, (&__pyx_v_memviewslice));
21001 
21002   /* "View.MemoryView":1084
21003  *     cdef __Pyx_memviewslice memviewslice
21004  *     slice_copy(memview, &memviewslice)
21005  *     return memoryview_copy_from_slice(memview, &memviewslice)             # <<<<<<<<<<<<<<
21006  *
21007  * @cname('__pyx_memoryview_copy_object_from_slice')
21008  */
21009   __Pyx_XDECREF(__pyx_r);
21010   __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)
21011   __Pyx_GOTREF(__pyx_t_1);
21012   __pyx_r = __pyx_t_1;
21013   __pyx_t_1 = 0;
21014   goto __pyx_L0;
21015 
21016   /* "View.MemoryView":1080
21017  *
21018  * @cname('__pyx_memoryview_copy_object')
21019  * cdef memoryview_copy(memoryview memview):             # <<<<<<<<<<<<<<
21020  *     "Create a new memoryview object"
21021  *     cdef __Pyx_memviewslice memviewslice
21022  */
21023 
21024   /* function exit code */
21025   __pyx_L1_error:;
21026   __Pyx_XDECREF(__pyx_t_1);
21027   __Pyx_AddTraceback("View.MemoryView.memoryview_copy", __pyx_clineno, __pyx_lineno, __pyx_filename);
21028   __pyx_r = 0;
21029   __pyx_L0:;
21030   __Pyx_XGIVEREF(__pyx_r);
21031   __Pyx_RefNannyFinishContext();
21032   return __pyx_r;
21033 }
21034 
21035 /* "View.MemoryView":1087
21036  *
21037  * @cname('__pyx_memoryview_copy_object_from_slice')
21038  * cdef memoryview_copy_from_slice(memoryview memview, __Pyx_memviewslice *memviewslice):             # <<<<<<<<<<<<<<
21039  *     """
21040  *     Create a new memoryview object from a given memoryview object and slice.
21041  */
21042 
__pyx_memoryview_copy_object_from_slice(struct __pyx_memoryview_obj * __pyx_v_memview,__Pyx_memviewslice * __pyx_v_memviewslice)21043 static PyObject *__pyx_memoryview_copy_object_from_slice(struct __pyx_memoryview_obj *__pyx_v_memview, __Pyx_memviewslice *__pyx_v_memviewslice) {
21044   PyObject *(*__pyx_v_to_object_func)(char *);
21045   int (*__pyx_v_to_dtype_func)(char *, PyObject *);
21046   PyObject *__pyx_r = NULL;
21047   __Pyx_RefNannyDeclarations
21048   int __pyx_t_1;
21049   int __pyx_t_2;
21050   PyObject *(*__pyx_t_3)(char *);
21051   int (*__pyx_t_4)(char *, PyObject *);
21052   PyObject *__pyx_t_5 = NULL;
21053   int __pyx_lineno = 0;
21054   const char *__pyx_filename = NULL;
21055   int __pyx_clineno = 0;
21056   __Pyx_RefNannySetupContext("memoryview_copy_from_slice", 0);
21057 
21058   /* "View.MemoryView":1094
21059  *     cdef int (*to_dtype_func)(char *, object) except 0
21060  *
21061  *     if isinstance(memview, _memoryviewslice):             # <<<<<<<<<<<<<<
21062  *         to_object_func = (<_memoryviewslice> memview).to_object_func
21063  *         to_dtype_func = (<_memoryviewslice> memview).to_dtype_func
21064  */
21065   __pyx_t_1 = __Pyx_TypeCheck(((PyObject *)__pyx_v_memview), __pyx_memoryviewslice_type);
21066   __pyx_t_2 = (__pyx_t_1 != 0);
21067   if (__pyx_t_2) {
21068 
21069     /* "View.MemoryView":1095
21070  *
21071  *     if isinstance(memview, _memoryviewslice):
21072  *         to_object_func = (<_memoryviewslice> memview).to_object_func             # <<<<<<<<<<<<<<
21073  *         to_dtype_func = (<_memoryviewslice> memview).to_dtype_func
21074  *     else:
21075  */
21076     __pyx_t_3 = ((struct __pyx_memoryviewslice_obj *)__pyx_v_memview)->to_object_func;
21077     __pyx_v_to_object_func = __pyx_t_3;
21078 
21079     /* "View.MemoryView":1096
21080  *     if isinstance(memview, _memoryviewslice):
21081  *         to_object_func = (<_memoryviewslice> memview).to_object_func
21082  *         to_dtype_func = (<_memoryviewslice> memview).to_dtype_func             # <<<<<<<<<<<<<<
21083  *     else:
21084  *         to_object_func = NULL
21085  */
21086     __pyx_t_4 = ((struct __pyx_memoryviewslice_obj *)__pyx_v_memview)->to_dtype_func;
21087     __pyx_v_to_dtype_func = __pyx_t_4;
21088 
21089     /* "View.MemoryView":1094
21090  *     cdef int (*to_dtype_func)(char *, object) except 0
21091  *
21092  *     if isinstance(memview, _memoryviewslice):             # <<<<<<<<<<<<<<
21093  *         to_object_func = (<_memoryviewslice> memview).to_object_func
21094  *         to_dtype_func = (<_memoryviewslice> memview).to_dtype_func
21095  */
21096     goto __pyx_L3;
21097   }
21098 
21099   /* "View.MemoryView":1098
21100  *         to_dtype_func = (<_memoryviewslice> memview).to_dtype_func
21101  *     else:
21102  *         to_object_func = NULL             # <<<<<<<<<<<<<<
21103  *         to_dtype_func = NULL
21104  *
21105  */
21106   /*else*/ {
21107     __pyx_v_to_object_func = NULL;
21108 
21109     /* "View.MemoryView":1099
21110  *     else:
21111  *         to_object_func = NULL
21112  *         to_dtype_func = NULL             # <<<<<<<<<<<<<<
21113  *
21114  *     return memoryview_fromslice(memviewslice[0], memview.view.ndim,
21115  */
21116     __pyx_v_to_dtype_func = NULL;
21117   }
21118   __pyx_L3:;
21119 
21120   /* "View.MemoryView":1101
21121  *         to_dtype_func = NULL
21122  *
21123  *     return memoryview_fromslice(memviewslice[0], memview.view.ndim,             # <<<<<<<<<<<<<<
21124  *                                 to_object_func, to_dtype_func,
21125  *                                 memview.dtype_is_object)
21126  */
21127   __Pyx_XDECREF(__pyx_r);
21128 
21129   /* "View.MemoryView":1103
21130  *     return memoryview_fromslice(memviewslice[0], memview.view.ndim,
21131  *                                 to_object_func, to_dtype_func,
21132  *                                 memview.dtype_is_object)             # <<<<<<<<<<<<<<
21133  *
21134  *
21135  */
21136   __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)
21137   __Pyx_GOTREF(__pyx_t_5);
21138   __pyx_r = __pyx_t_5;
21139   __pyx_t_5 = 0;
21140   goto __pyx_L0;
21141 
21142   /* "View.MemoryView":1087
21143  *
21144  * @cname('__pyx_memoryview_copy_object_from_slice')
21145  * cdef memoryview_copy_from_slice(memoryview memview, __Pyx_memviewslice *memviewslice):             # <<<<<<<<<<<<<<
21146  *     """
21147  *     Create a new memoryview object from a given memoryview object and slice.
21148  */
21149 
21150   /* function exit code */
21151   __pyx_L1_error:;
21152   __Pyx_XDECREF(__pyx_t_5);
21153   __Pyx_AddTraceback("View.MemoryView.memoryview_copy_from_slice", __pyx_clineno, __pyx_lineno, __pyx_filename);
21154   __pyx_r = 0;
21155   __pyx_L0:;
21156   __Pyx_XGIVEREF(__pyx_r);
21157   __Pyx_RefNannyFinishContext();
21158   return __pyx_r;
21159 }
21160 
21161 /* "View.MemoryView":1109
21162  *
21163  *
21164  * cdef Py_ssize_t abs_py_ssize_t(Py_ssize_t arg) nogil:             # <<<<<<<<<<<<<<
21165  *     if arg < 0:
21166  *         return -arg
21167  */
21168 
abs_py_ssize_t(Py_ssize_t __pyx_v_arg)21169 static Py_ssize_t abs_py_ssize_t(Py_ssize_t __pyx_v_arg) {
21170   Py_ssize_t __pyx_r;
21171   int __pyx_t_1;
21172 
21173   /* "View.MemoryView":1110
21174  *
21175  * cdef Py_ssize_t abs_py_ssize_t(Py_ssize_t arg) nogil:
21176  *     if arg < 0:             # <<<<<<<<<<<<<<
21177  *         return -arg
21178  *     else:
21179  */
21180   __pyx_t_1 = ((__pyx_v_arg < 0) != 0);
21181   if (__pyx_t_1) {
21182 
21183     /* "View.MemoryView":1111
21184  * cdef Py_ssize_t abs_py_ssize_t(Py_ssize_t arg) nogil:
21185  *     if arg < 0:
21186  *         return -arg             # <<<<<<<<<<<<<<
21187  *     else:
21188  *         return arg
21189  */
21190     __pyx_r = (-__pyx_v_arg);
21191     goto __pyx_L0;
21192 
21193     /* "View.MemoryView":1110
21194  *
21195  * cdef Py_ssize_t abs_py_ssize_t(Py_ssize_t arg) nogil:
21196  *     if arg < 0:             # <<<<<<<<<<<<<<
21197  *         return -arg
21198  *     else:
21199  */
21200   }
21201 
21202   /* "View.MemoryView":1113
21203  *         return -arg
21204  *     else:
21205  *         return arg             # <<<<<<<<<<<<<<
21206  *
21207  * @cname('__pyx_get_best_slice_order')
21208  */
21209   /*else*/ {
21210     __pyx_r = __pyx_v_arg;
21211     goto __pyx_L0;
21212   }
21213 
21214   /* "View.MemoryView":1109
21215  *
21216  *
21217  * cdef Py_ssize_t abs_py_ssize_t(Py_ssize_t arg) nogil:             # <<<<<<<<<<<<<<
21218  *     if arg < 0:
21219  *         return -arg
21220  */
21221 
21222   /* function exit code */
21223   __pyx_L0:;
21224   return __pyx_r;
21225 }
21226 
21227 /* "View.MemoryView":1116
21228  *
21229  * @cname('__pyx_get_best_slice_order')
21230  * cdef char get_best_order(__Pyx_memviewslice *mslice, int ndim) nogil:             # <<<<<<<<<<<<<<
21231  *     """
21232  *     Figure out the best memory access order for a given slice.
21233  */
21234 
__pyx_get_best_slice_order(__Pyx_memviewslice * __pyx_v_mslice,int __pyx_v_ndim)21235 static char __pyx_get_best_slice_order(__Pyx_memviewslice *__pyx_v_mslice, int __pyx_v_ndim) {
21236   int __pyx_v_i;
21237   Py_ssize_t __pyx_v_c_stride;
21238   Py_ssize_t __pyx_v_f_stride;
21239   char __pyx_r;
21240   int __pyx_t_1;
21241   int __pyx_t_2;
21242   int __pyx_t_3;
21243   int __pyx_t_4;
21244 
21245   /* "View.MemoryView":1121
21246  *     """
21247  *     cdef int i
21248  *     cdef Py_ssize_t c_stride = 0             # <<<<<<<<<<<<<<
21249  *     cdef Py_ssize_t f_stride = 0
21250  *
21251  */
21252   __pyx_v_c_stride = 0;
21253 
21254   /* "View.MemoryView":1122
21255  *     cdef int i
21256  *     cdef Py_ssize_t c_stride = 0
21257  *     cdef Py_ssize_t f_stride = 0             # <<<<<<<<<<<<<<
21258  *
21259  *     for i in range(ndim - 1, -1, -1):
21260  */
21261   __pyx_v_f_stride = 0;
21262 
21263   /* "View.MemoryView":1124
21264  *     cdef Py_ssize_t f_stride = 0
21265  *
21266  *     for i in range(ndim - 1, -1, -1):             # <<<<<<<<<<<<<<
21267  *         if mslice.shape[i] > 1:
21268  *             c_stride = mslice.strides[i]
21269  */
21270   for (__pyx_t_1 = (__pyx_v_ndim - 1); __pyx_t_1 > -1; __pyx_t_1-=1) {
21271     __pyx_v_i = __pyx_t_1;
21272 
21273     /* "View.MemoryView":1125
21274  *
21275  *     for i in range(ndim - 1, -1, -1):
21276  *         if mslice.shape[i] > 1:             # <<<<<<<<<<<<<<
21277  *             c_stride = mslice.strides[i]
21278  *             break
21279  */
21280     __pyx_t_2 = (((__pyx_v_mslice->shape[__pyx_v_i]) > 1) != 0);
21281     if (__pyx_t_2) {
21282 
21283       /* "View.MemoryView":1126
21284  *     for i in range(ndim - 1, -1, -1):
21285  *         if mslice.shape[i] > 1:
21286  *             c_stride = mslice.strides[i]             # <<<<<<<<<<<<<<
21287  *             break
21288  *
21289  */
21290       __pyx_v_c_stride = (__pyx_v_mslice->strides[__pyx_v_i]);
21291 
21292       /* "View.MemoryView":1127
21293  *         if mslice.shape[i] > 1:
21294  *             c_stride = mslice.strides[i]
21295  *             break             # <<<<<<<<<<<<<<
21296  *
21297  *     for i in range(ndim):
21298  */
21299       goto __pyx_L4_break;
21300 
21301       /* "View.MemoryView":1125
21302  *
21303  *     for i in range(ndim - 1, -1, -1):
21304  *         if mslice.shape[i] > 1:             # <<<<<<<<<<<<<<
21305  *             c_stride = mslice.strides[i]
21306  *             break
21307  */
21308     }
21309   }
21310   __pyx_L4_break:;
21311 
21312   /* "View.MemoryView":1129
21313  *             break
21314  *
21315  *     for i in range(ndim):             # <<<<<<<<<<<<<<
21316  *         if mslice.shape[i] > 1:
21317  *             f_stride = mslice.strides[i]
21318  */
21319   __pyx_t_1 = __pyx_v_ndim;
21320   __pyx_t_3 = __pyx_t_1;
21321   for (__pyx_t_4 = 0; __pyx_t_4 < __pyx_t_3; __pyx_t_4+=1) {
21322     __pyx_v_i = __pyx_t_4;
21323 
21324     /* "View.MemoryView":1130
21325  *
21326  *     for i in range(ndim):
21327  *         if mslice.shape[i] > 1:             # <<<<<<<<<<<<<<
21328  *             f_stride = mslice.strides[i]
21329  *             break
21330  */
21331     __pyx_t_2 = (((__pyx_v_mslice->shape[__pyx_v_i]) > 1) != 0);
21332     if (__pyx_t_2) {
21333 
21334       /* "View.MemoryView":1131
21335  *     for i in range(ndim):
21336  *         if mslice.shape[i] > 1:
21337  *             f_stride = mslice.strides[i]             # <<<<<<<<<<<<<<
21338  *             break
21339  *
21340  */
21341       __pyx_v_f_stride = (__pyx_v_mslice->strides[__pyx_v_i]);
21342 
21343       /* "View.MemoryView":1132
21344  *         if mslice.shape[i] > 1:
21345  *             f_stride = mslice.strides[i]
21346  *             break             # <<<<<<<<<<<<<<
21347  *
21348  *     if abs_py_ssize_t(c_stride) <= abs_py_ssize_t(f_stride):
21349  */
21350       goto __pyx_L7_break;
21351 
21352       /* "View.MemoryView":1130
21353  *
21354  *     for i in range(ndim):
21355  *         if mslice.shape[i] > 1:             # <<<<<<<<<<<<<<
21356  *             f_stride = mslice.strides[i]
21357  *             break
21358  */
21359     }
21360   }
21361   __pyx_L7_break:;
21362 
21363   /* "View.MemoryView":1134
21364  *             break
21365  *
21366  *     if abs_py_ssize_t(c_stride) <= abs_py_ssize_t(f_stride):             # <<<<<<<<<<<<<<
21367  *         return 'C'
21368  *     else:
21369  */
21370   __pyx_t_2 = ((abs_py_ssize_t(__pyx_v_c_stride) <= abs_py_ssize_t(__pyx_v_f_stride)) != 0);
21371   if (__pyx_t_2) {
21372 
21373     /* "View.MemoryView":1135
21374  *
21375  *     if abs_py_ssize_t(c_stride) <= abs_py_ssize_t(f_stride):
21376  *         return 'C'             # <<<<<<<<<<<<<<
21377  *     else:
21378  *         return 'F'
21379  */
21380     __pyx_r = 'C';
21381     goto __pyx_L0;
21382 
21383     /* "View.MemoryView":1134
21384  *             break
21385  *
21386  *     if abs_py_ssize_t(c_stride) <= abs_py_ssize_t(f_stride):             # <<<<<<<<<<<<<<
21387  *         return 'C'
21388  *     else:
21389  */
21390   }
21391 
21392   /* "View.MemoryView":1137
21393  *         return 'C'
21394  *     else:
21395  *         return 'F'             # <<<<<<<<<<<<<<
21396  *
21397  * @cython.cdivision(True)
21398  */
21399   /*else*/ {
21400     __pyx_r = 'F';
21401     goto __pyx_L0;
21402   }
21403 
21404   /* "View.MemoryView":1116
21405  *
21406  * @cname('__pyx_get_best_slice_order')
21407  * cdef char get_best_order(__Pyx_memviewslice *mslice, int ndim) nogil:             # <<<<<<<<<<<<<<
21408  *     """
21409  *     Figure out the best memory access order for a given slice.
21410  */
21411 
21412   /* function exit code */
21413   __pyx_L0:;
21414   return __pyx_r;
21415 }
21416 
21417 /* "View.MemoryView":1140
21418  *
21419  * @cython.cdivision(True)
21420  * cdef void _copy_strided_to_strided(char *src_data, Py_ssize_t *src_strides,             # <<<<<<<<<<<<<<
21421  *                                    char *dst_data, Py_ssize_t *dst_strides,
21422  *                                    Py_ssize_t *src_shape, Py_ssize_t *dst_shape,
21423  */
21424 
_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)21425 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) {
21426   CYTHON_UNUSED Py_ssize_t __pyx_v_i;
21427   CYTHON_UNUSED Py_ssize_t __pyx_v_src_extent;
21428   Py_ssize_t __pyx_v_dst_extent;
21429   Py_ssize_t __pyx_v_src_stride;
21430   Py_ssize_t __pyx_v_dst_stride;
21431   int __pyx_t_1;
21432   int __pyx_t_2;
21433   int __pyx_t_3;
21434   Py_ssize_t __pyx_t_4;
21435   Py_ssize_t __pyx_t_5;
21436   Py_ssize_t __pyx_t_6;
21437 
21438   /* "View.MemoryView":1147
21439  *
21440  *     cdef Py_ssize_t i
21441  *     cdef Py_ssize_t src_extent = src_shape[0]             # <<<<<<<<<<<<<<
21442  *     cdef Py_ssize_t dst_extent = dst_shape[0]
21443  *     cdef Py_ssize_t src_stride = src_strides[0]
21444  */
21445   __pyx_v_src_extent = (__pyx_v_src_shape[0]);
21446 
21447   /* "View.MemoryView":1148
21448  *     cdef Py_ssize_t i
21449  *     cdef Py_ssize_t src_extent = src_shape[0]
21450  *     cdef Py_ssize_t dst_extent = dst_shape[0]             # <<<<<<<<<<<<<<
21451  *     cdef Py_ssize_t src_stride = src_strides[0]
21452  *     cdef Py_ssize_t dst_stride = dst_strides[0]
21453  */
21454   __pyx_v_dst_extent = (__pyx_v_dst_shape[0]);
21455 
21456   /* "View.MemoryView":1149
21457  *     cdef Py_ssize_t src_extent = src_shape[0]
21458  *     cdef Py_ssize_t dst_extent = dst_shape[0]
21459  *     cdef Py_ssize_t src_stride = src_strides[0]             # <<<<<<<<<<<<<<
21460  *     cdef Py_ssize_t dst_stride = dst_strides[0]
21461  *
21462  */
21463   __pyx_v_src_stride = (__pyx_v_src_strides[0]);
21464 
21465   /* "View.MemoryView":1150
21466  *     cdef Py_ssize_t dst_extent = dst_shape[0]
21467  *     cdef Py_ssize_t src_stride = src_strides[0]
21468  *     cdef Py_ssize_t dst_stride = dst_strides[0]             # <<<<<<<<<<<<<<
21469  *
21470  *     if ndim == 1:
21471  */
21472   __pyx_v_dst_stride = (__pyx_v_dst_strides[0]);
21473 
21474   /* "View.MemoryView":1152
21475  *     cdef Py_ssize_t dst_stride = dst_strides[0]
21476  *
21477  *     if ndim == 1:             # <<<<<<<<<<<<<<
21478  *        if (src_stride > 0 and dst_stride > 0 and
21479  *            <size_t> src_stride == itemsize == <size_t> dst_stride):
21480  */
21481   __pyx_t_1 = ((__pyx_v_ndim == 1) != 0);
21482   if (__pyx_t_1) {
21483 
21484     /* "View.MemoryView":1153
21485  *
21486  *     if ndim == 1:
21487  *        if (src_stride > 0 and dst_stride > 0 and             # <<<<<<<<<<<<<<
21488  *            <size_t> src_stride == itemsize == <size_t> dst_stride):
21489  *            memcpy(dst_data, src_data, itemsize * dst_extent)
21490  */
21491     __pyx_t_2 = ((__pyx_v_src_stride > 0) != 0);
21492     if (__pyx_t_2) {
21493     } else {
21494       __pyx_t_1 = __pyx_t_2;
21495       goto __pyx_L5_bool_binop_done;
21496     }
21497     __pyx_t_2 = ((__pyx_v_dst_stride > 0) != 0);
21498     if (__pyx_t_2) {
21499     } else {
21500       __pyx_t_1 = __pyx_t_2;
21501       goto __pyx_L5_bool_binop_done;
21502     }
21503 
21504     /* "View.MemoryView":1154
21505  *     if ndim == 1:
21506  *        if (src_stride > 0 and dst_stride > 0 and
21507  *            <size_t> src_stride == itemsize == <size_t> dst_stride):             # <<<<<<<<<<<<<<
21508  *            memcpy(dst_data, src_data, itemsize * dst_extent)
21509  *        else:
21510  */
21511     __pyx_t_2 = (((size_t)__pyx_v_src_stride) == __pyx_v_itemsize);
21512     if (__pyx_t_2) {
21513       __pyx_t_2 = (__pyx_v_itemsize == ((size_t)__pyx_v_dst_stride));
21514     }
21515     __pyx_t_3 = (__pyx_t_2 != 0);
21516     __pyx_t_1 = __pyx_t_3;
21517     __pyx_L5_bool_binop_done:;
21518 
21519     /* "View.MemoryView":1153
21520  *
21521  *     if ndim == 1:
21522  *        if (src_stride > 0 and dst_stride > 0 and             # <<<<<<<<<<<<<<
21523  *            <size_t> src_stride == itemsize == <size_t> dst_stride):
21524  *            memcpy(dst_data, src_data, itemsize * dst_extent)
21525  */
21526     if (__pyx_t_1) {
21527 
21528       /* "View.MemoryView":1155
21529  *        if (src_stride > 0 and dst_stride > 0 and
21530  *            <size_t> src_stride == itemsize == <size_t> dst_stride):
21531  *            memcpy(dst_data, src_data, itemsize * dst_extent)             # <<<<<<<<<<<<<<
21532  *        else:
21533  *            for i in range(dst_extent):
21534  */
21535       (void)(memcpy(__pyx_v_dst_data, __pyx_v_src_data, (__pyx_v_itemsize * __pyx_v_dst_extent)));
21536 
21537       /* "View.MemoryView":1153
21538  *
21539  *     if ndim == 1:
21540  *        if (src_stride > 0 and dst_stride > 0 and             # <<<<<<<<<<<<<<
21541  *            <size_t> src_stride == itemsize == <size_t> dst_stride):
21542  *            memcpy(dst_data, src_data, itemsize * dst_extent)
21543  */
21544       goto __pyx_L4;
21545     }
21546 
21547     /* "View.MemoryView":1157
21548  *            memcpy(dst_data, src_data, itemsize * dst_extent)
21549  *        else:
21550  *            for i in range(dst_extent):             # <<<<<<<<<<<<<<
21551  *                memcpy(dst_data, src_data, itemsize)
21552  *                src_data += src_stride
21553  */
21554     /*else*/ {
21555       __pyx_t_4 = __pyx_v_dst_extent;
21556       __pyx_t_5 = __pyx_t_4;
21557       for (__pyx_t_6 = 0; __pyx_t_6 < __pyx_t_5; __pyx_t_6+=1) {
21558         __pyx_v_i = __pyx_t_6;
21559 
21560         /* "View.MemoryView":1158
21561  *        else:
21562  *            for i in range(dst_extent):
21563  *                memcpy(dst_data, src_data, itemsize)             # <<<<<<<<<<<<<<
21564  *                src_data += src_stride
21565  *                dst_data += dst_stride
21566  */
21567         (void)(memcpy(__pyx_v_dst_data, __pyx_v_src_data, __pyx_v_itemsize));
21568 
21569         /* "View.MemoryView":1159
21570  *            for i in range(dst_extent):
21571  *                memcpy(dst_data, src_data, itemsize)
21572  *                src_data += src_stride             # <<<<<<<<<<<<<<
21573  *                dst_data += dst_stride
21574  *     else:
21575  */
21576         __pyx_v_src_data = (__pyx_v_src_data + __pyx_v_src_stride);
21577 
21578         /* "View.MemoryView":1160
21579  *                memcpy(dst_data, src_data, itemsize)
21580  *                src_data += src_stride
21581  *                dst_data += dst_stride             # <<<<<<<<<<<<<<
21582  *     else:
21583  *         for i in range(dst_extent):
21584  */
21585         __pyx_v_dst_data = (__pyx_v_dst_data + __pyx_v_dst_stride);
21586       }
21587     }
21588     __pyx_L4:;
21589 
21590     /* "View.MemoryView":1152
21591  *     cdef Py_ssize_t dst_stride = dst_strides[0]
21592  *
21593  *     if ndim == 1:             # <<<<<<<<<<<<<<
21594  *        if (src_stride > 0 and dst_stride > 0 and
21595  *            <size_t> src_stride == itemsize == <size_t> dst_stride):
21596  */
21597     goto __pyx_L3;
21598   }
21599 
21600   /* "View.MemoryView":1162
21601  *                dst_data += dst_stride
21602  *     else:
21603  *         for i in range(dst_extent):             # <<<<<<<<<<<<<<
21604  *             _copy_strided_to_strided(src_data, src_strides + 1,
21605  *                                      dst_data, dst_strides + 1,
21606  */
21607   /*else*/ {
21608     __pyx_t_4 = __pyx_v_dst_extent;
21609     __pyx_t_5 = __pyx_t_4;
21610     for (__pyx_t_6 = 0; __pyx_t_6 < __pyx_t_5; __pyx_t_6+=1) {
21611       __pyx_v_i = __pyx_t_6;
21612 
21613       /* "View.MemoryView":1163
21614  *     else:
21615  *         for i in range(dst_extent):
21616  *             _copy_strided_to_strided(src_data, src_strides + 1,             # <<<<<<<<<<<<<<
21617  *                                      dst_data, dst_strides + 1,
21618  *                                      src_shape + 1, dst_shape + 1,
21619  */
21620       _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);
21621 
21622       /* "View.MemoryView":1167
21623  *                                      src_shape + 1, dst_shape + 1,
21624  *                                      ndim - 1, itemsize)
21625  *             src_data += src_stride             # <<<<<<<<<<<<<<
21626  *             dst_data += dst_stride
21627  *
21628  */
21629       __pyx_v_src_data = (__pyx_v_src_data + __pyx_v_src_stride);
21630 
21631       /* "View.MemoryView":1168
21632  *                                      ndim - 1, itemsize)
21633  *             src_data += src_stride
21634  *             dst_data += dst_stride             # <<<<<<<<<<<<<<
21635  *
21636  * cdef void copy_strided_to_strided(__Pyx_memviewslice *src,
21637  */
21638       __pyx_v_dst_data = (__pyx_v_dst_data + __pyx_v_dst_stride);
21639     }
21640   }
21641   __pyx_L3:;
21642 
21643   /* "View.MemoryView":1140
21644  *
21645  * @cython.cdivision(True)
21646  * cdef void _copy_strided_to_strided(char *src_data, Py_ssize_t *src_strides,             # <<<<<<<<<<<<<<
21647  *                                    char *dst_data, Py_ssize_t *dst_strides,
21648  *                                    Py_ssize_t *src_shape, Py_ssize_t *dst_shape,
21649  */
21650 
21651   /* function exit code */
21652 }
21653 
21654 /* "View.MemoryView":1170
21655  *             dst_data += dst_stride
21656  *
21657  * cdef void copy_strided_to_strided(__Pyx_memviewslice *src,             # <<<<<<<<<<<<<<
21658  *                                   __Pyx_memviewslice *dst,
21659  *                                   int ndim, size_t itemsize) nogil:
21660  */
21661 
copy_strided_to_strided(__Pyx_memviewslice * __pyx_v_src,__Pyx_memviewslice * __pyx_v_dst,int __pyx_v_ndim,size_t __pyx_v_itemsize)21662 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) {
21663 
21664   /* "View.MemoryView":1173
21665  *                                   __Pyx_memviewslice *dst,
21666  *                                   int ndim, size_t itemsize) nogil:
21667  *     _copy_strided_to_strided(src.data, src.strides, dst.data, dst.strides,             # <<<<<<<<<<<<<<
21668  *                              src.shape, dst.shape, ndim, itemsize)
21669  *
21670  */
21671   _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);
21672 
21673   /* "View.MemoryView":1170
21674  *             dst_data += dst_stride
21675  *
21676  * cdef void copy_strided_to_strided(__Pyx_memviewslice *src,             # <<<<<<<<<<<<<<
21677  *                                   __Pyx_memviewslice *dst,
21678  *                                   int ndim, size_t itemsize) nogil:
21679  */
21680 
21681   /* function exit code */
21682 }
21683 
21684 /* "View.MemoryView":1177
21685  *
21686  * @cname('__pyx_memoryview_slice_get_size')
21687  * cdef Py_ssize_t slice_get_size(__Pyx_memviewslice *src, int ndim) nogil:             # <<<<<<<<<<<<<<
21688  *     "Return the size of the memory occupied by the slice in number of bytes"
21689  *     cdef Py_ssize_t shape, size = src.memview.view.itemsize
21690  */
21691 
__pyx_memoryview_slice_get_size(__Pyx_memviewslice * __pyx_v_src,int __pyx_v_ndim)21692 static Py_ssize_t __pyx_memoryview_slice_get_size(__Pyx_memviewslice *__pyx_v_src, int __pyx_v_ndim) {
21693   Py_ssize_t __pyx_v_shape;
21694   Py_ssize_t __pyx_v_size;
21695   Py_ssize_t __pyx_r;
21696   Py_ssize_t __pyx_t_1;
21697   Py_ssize_t *__pyx_t_2;
21698   Py_ssize_t *__pyx_t_3;
21699   Py_ssize_t *__pyx_t_4;
21700 
21701   /* "View.MemoryView":1179
21702  * cdef Py_ssize_t slice_get_size(__Pyx_memviewslice *src, int ndim) nogil:
21703  *     "Return the size of the memory occupied by the slice in number of bytes"
21704  *     cdef Py_ssize_t shape, size = src.memview.view.itemsize             # <<<<<<<<<<<<<<
21705  *
21706  *     for shape in src.shape[:ndim]:
21707  */
21708   __pyx_t_1 = __pyx_v_src->memview->view.itemsize;
21709   __pyx_v_size = __pyx_t_1;
21710 
21711   /* "View.MemoryView":1181
21712  *     cdef Py_ssize_t shape, size = src.memview.view.itemsize
21713  *
21714  *     for shape in src.shape[:ndim]:             # <<<<<<<<<<<<<<
21715  *         size *= shape
21716  *
21717  */
21718   __pyx_t_3 = (__pyx_v_src->shape + __pyx_v_ndim);
21719   for (__pyx_t_4 = __pyx_v_src->shape; __pyx_t_4 < __pyx_t_3; __pyx_t_4++) {
21720     __pyx_t_2 = __pyx_t_4;
21721     __pyx_v_shape = (__pyx_t_2[0]);
21722 
21723     /* "View.MemoryView":1182
21724  *
21725  *     for shape in src.shape[:ndim]:
21726  *         size *= shape             # <<<<<<<<<<<<<<
21727  *
21728  *     return size
21729  */
21730     __pyx_v_size = (__pyx_v_size * __pyx_v_shape);
21731   }
21732 
21733   /* "View.MemoryView":1184
21734  *         size *= shape
21735  *
21736  *     return size             # <<<<<<<<<<<<<<
21737  *
21738  * @cname('__pyx_fill_contig_strides_array')
21739  */
21740   __pyx_r = __pyx_v_size;
21741   goto __pyx_L0;
21742 
21743   /* "View.MemoryView":1177
21744  *
21745  * @cname('__pyx_memoryview_slice_get_size')
21746  * cdef Py_ssize_t slice_get_size(__Pyx_memviewslice *src, int ndim) nogil:             # <<<<<<<<<<<<<<
21747  *     "Return the size of the memory occupied by the slice in number of bytes"
21748  *     cdef Py_ssize_t shape, size = src.memview.view.itemsize
21749  */
21750 
21751   /* function exit code */
21752   __pyx_L0:;
21753   return __pyx_r;
21754 }
21755 
21756 /* "View.MemoryView":1187
21757  *
21758  * @cname('__pyx_fill_contig_strides_array')
21759  * cdef Py_ssize_t fill_contig_strides_array(             # <<<<<<<<<<<<<<
21760  *                 Py_ssize_t *shape, Py_ssize_t *strides, Py_ssize_t stride,
21761  *                 int ndim, char order) nogil:
21762  */
21763 
__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)21764 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) {
21765   int __pyx_v_idx;
21766   Py_ssize_t __pyx_r;
21767   int __pyx_t_1;
21768   int __pyx_t_2;
21769   int __pyx_t_3;
21770   int __pyx_t_4;
21771 
21772   /* "View.MemoryView":1196
21773  *     cdef int idx
21774  *
21775  *     if order == 'F':             # <<<<<<<<<<<<<<
21776  *         for idx in range(ndim):
21777  *             strides[idx] = stride
21778  */
21779   __pyx_t_1 = ((__pyx_v_order == 'F') != 0);
21780   if (__pyx_t_1) {
21781 
21782     /* "View.MemoryView":1197
21783  *
21784  *     if order == 'F':
21785  *         for idx in range(ndim):             # <<<<<<<<<<<<<<
21786  *             strides[idx] = stride
21787  *             stride *= shape[idx]
21788  */
21789     __pyx_t_2 = __pyx_v_ndim;
21790     __pyx_t_3 = __pyx_t_2;
21791     for (__pyx_t_4 = 0; __pyx_t_4 < __pyx_t_3; __pyx_t_4+=1) {
21792       __pyx_v_idx = __pyx_t_4;
21793 
21794       /* "View.MemoryView":1198
21795  *     if order == 'F':
21796  *         for idx in range(ndim):
21797  *             strides[idx] = stride             # <<<<<<<<<<<<<<
21798  *             stride *= shape[idx]
21799  *     else:
21800  */
21801       (__pyx_v_strides[__pyx_v_idx]) = __pyx_v_stride;
21802 
21803       /* "View.MemoryView":1199
21804  *         for idx in range(ndim):
21805  *             strides[idx] = stride
21806  *             stride *= shape[idx]             # <<<<<<<<<<<<<<
21807  *     else:
21808  *         for idx in range(ndim - 1, -1, -1):
21809  */
21810       __pyx_v_stride = (__pyx_v_stride * (__pyx_v_shape[__pyx_v_idx]));
21811     }
21812 
21813     /* "View.MemoryView":1196
21814  *     cdef int idx
21815  *
21816  *     if order == 'F':             # <<<<<<<<<<<<<<
21817  *         for idx in range(ndim):
21818  *             strides[idx] = stride
21819  */
21820     goto __pyx_L3;
21821   }
21822 
21823   /* "View.MemoryView":1201
21824  *             stride *= shape[idx]
21825  *     else:
21826  *         for idx in range(ndim - 1, -1, -1):             # <<<<<<<<<<<<<<
21827  *             strides[idx] = stride
21828  *             stride *= shape[idx]
21829  */
21830   /*else*/ {
21831     for (__pyx_t_2 = (__pyx_v_ndim - 1); __pyx_t_2 > -1; __pyx_t_2-=1) {
21832       __pyx_v_idx = __pyx_t_2;
21833 
21834       /* "View.MemoryView":1202
21835  *     else:
21836  *         for idx in range(ndim - 1, -1, -1):
21837  *             strides[idx] = stride             # <<<<<<<<<<<<<<
21838  *             stride *= shape[idx]
21839  *
21840  */
21841       (__pyx_v_strides[__pyx_v_idx]) = __pyx_v_stride;
21842 
21843       /* "View.MemoryView":1203
21844  *         for idx in range(ndim - 1, -1, -1):
21845  *             strides[idx] = stride
21846  *             stride *= shape[idx]             # <<<<<<<<<<<<<<
21847  *
21848  *     return stride
21849  */
21850       __pyx_v_stride = (__pyx_v_stride * (__pyx_v_shape[__pyx_v_idx]));
21851     }
21852   }
21853   __pyx_L3:;
21854 
21855   /* "View.MemoryView":1205
21856  *             stride *= shape[idx]
21857  *
21858  *     return stride             # <<<<<<<<<<<<<<
21859  *
21860  * @cname('__pyx_memoryview_copy_data_to_temp')
21861  */
21862   __pyx_r = __pyx_v_stride;
21863   goto __pyx_L0;
21864 
21865   /* "View.MemoryView":1187
21866  *
21867  * @cname('__pyx_fill_contig_strides_array')
21868  * cdef Py_ssize_t fill_contig_strides_array(             # <<<<<<<<<<<<<<
21869  *                 Py_ssize_t *shape, Py_ssize_t *strides, Py_ssize_t stride,
21870  *                 int ndim, char order) nogil:
21871  */
21872 
21873   /* function exit code */
21874   __pyx_L0:;
21875   return __pyx_r;
21876 }
21877 
21878 /* "View.MemoryView":1208
21879  *
21880  * @cname('__pyx_memoryview_copy_data_to_temp')
21881  * cdef void *copy_data_to_temp(__Pyx_memviewslice *src,             # <<<<<<<<<<<<<<
21882  *                              __Pyx_memviewslice *tmpslice,
21883  *                              char order,
21884  */
21885 
__pyx_memoryview_copy_data_to_temp(__Pyx_memviewslice * __pyx_v_src,__Pyx_memviewslice * __pyx_v_tmpslice,char __pyx_v_order,int __pyx_v_ndim)21886 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) {
21887   int __pyx_v_i;
21888   void *__pyx_v_result;
21889   size_t __pyx_v_itemsize;
21890   size_t __pyx_v_size;
21891   void *__pyx_r;
21892   Py_ssize_t __pyx_t_1;
21893   int __pyx_t_2;
21894   int __pyx_t_3;
21895   struct __pyx_memoryview_obj *__pyx_t_4;
21896   int __pyx_t_5;
21897   int __pyx_t_6;
21898   int __pyx_lineno = 0;
21899   const char *__pyx_filename = NULL;
21900   int __pyx_clineno = 0;
21901 
21902   /* "View.MemoryView":1219
21903  *     cdef void *result
21904  *
21905  *     cdef size_t itemsize = src.memview.view.itemsize             # <<<<<<<<<<<<<<
21906  *     cdef size_t size = slice_get_size(src, ndim)
21907  *
21908  */
21909   __pyx_t_1 = __pyx_v_src->memview->view.itemsize;
21910   __pyx_v_itemsize = __pyx_t_1;
21911 
21912   /* "View.MemoryView":1220
21913  *
21914  *     cdef size_t itemsize = src.memview.view.itemsize
21915  *     cdef size_t size = slice_get_size(src, ndim)             # <<<<<<<<<<<<<<
21916  *
21917  *     result = malloc(size)
21918  */
21919   __pyx_v_size = __pyx_memoryview_slice_get_size(__pyx_v_src, __pyx_v_ndim);
21920 
21921   /* "View.MemoryView":1222
21922  *     cdef size_t size = slice_get_size(src, ndim)
21923  *
21924  *     result = malloc(size)             # <<<<<<<<<<<<<<
21925  *     if not result:
21926  *         _err(MemoryError, NULL)
21927  */
21928   __pyx_v_result = malloc(__pyx_v_size);
21929 
21930   /* "View.MemoryView":1223
21931  *
21932  *     result = malloc(size)
21933  *     if not result:             # <<<<<<<<<<<<<<
21934  *         _err(MemoryError, NULL)
21935  *
21936  */
21937   __pyx_t_2 = ((!(__pyx_v_result != 0)) != 0);
21938   if (__pyx_t_2) {
21939 
21940     /* "View.MemoryView":1224
21941  *     result = malloc(size)
21942  *     if not result:
21943  *         _err(MemoryError, NULL)             # <<<<<<<<<<<<<<
21944  *
21945  *
21946  */
21947     __pyx_t_3 = __pyx_memoryview_err(__pyx_builtin_MemoryError, NULL); if (unlikely(__pyx_t_3 == ((int)-1))) __PYX_ERR(3, 1224, __pyx_L1_error)
21948 
21949     /* "View.MemoryView":1223
21950  *
21951  *     result = malloc(size)
21952  *     if not result:             # <<<<<<<<<<<<<<
21953  *         _err(MemoryError, NULL)
21954  *
21955  */
21956   }
21957 
21958   /* "View.MemoryView":1227
21959  *
21960  *
21961  *     tmpslice.data = <char *> result             # <<<<<<<<<<<<<<
21962  *     tmpslice.memview = src.memview
21963  *     for i in range(ndim):
21964  */
21965   __pyx_v_tmpslice->data = ((char *)__pyx_v_result);
21966 
21967   /* "View.MemoryView":1228
21968  *
21969  *     tmpslice.data = <char *> result
21970  *     tmpslice.memview = src.memview             # <<<<<<<<<<<<<<
21971  *     for i in range(ndim):
21972  *         tmpslice.shape[i] = src.shape[i]
21973  */
21974   __pyx_t_4 = __pyx_v_src->memview;
21975   __pyx_v_tmpslice->memview = __pyx_t_4;
21976 
21977   /* "View.MemoryView":1229
21978  *     tmpslice.data = <char *> result
21979  *     tmpslice.memview = src.memview
21980  *     for i in range(ndim):             # <<<<<<<<<<<<<<
21981  *         tmpslice.shape[i] = src.shape[i]
21982  *         tmpslice.suboffsets[i] = -1
21983  */
21984   __pyx_t_3 = __pyx_v_ndim;
21985   __pyx_t_5 = __pyx_t_3;
21986   for (__pyx_t_6 = 0; __pyx_t_6 < __pyx_t_5; __pyx_t_6+=1) {
21987     __pyx_v_i = __pyx_t_6;
21988 
21989     /* "View.MemoryView":1230
21990  *     tmpslice.memview = src.memview
21991  *     for i in range(ndim):
21992  *         tmpslice.shape[i] = src.shape[i]             # <<<<<<<<<<<<<<
21993  *         tmpslice.suboffsets[i] = -1
21994  *
21995  */
21996     (__pyx_v_tmpslice->shape[__pyx_v_i]) = (__pyx_v_src->shape[__pyx_v_i]);
21997 
21998     /* "View.MemoryView":1231
21999  *     for i in range(ndim):
22000  *         tmpslice.shape[i] = src.shape[i]
22001  *         tmpslice.suboffsets[i] = -1             # <<<<<<<<<<<<<<
22002  *
22003  *     fill_contig_strides_array(&tmpslice.shape[0], &tmpslice.strides[0], itemsize,
22004  */
22005     (__pyx_v_tmpslice->suboffsets[__pyx_v_i]) = -1L;
22006   }
22007 
22008   /* "View.MemoryView":1233
22009  *         tmpslice.suboffsets[i] = -1
22010  *
22011  *     fill_contig_strides_array(&tmpslice.shape[0], &tmpslice.strides[0], itemsize,             # <<<<<<<<<<<<<<
22012  *                               ndim, order)
22013  *
22014  */
22015   (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));
22016 
22017   /* "View.MemoryView":1237
22018  *
22019  *
22020  *     for i in range(ndim):             # <<<<<<<<<<<<<<
22021  *         if tmpslice.shape[i] == 1:
22022  *             tmpslice.strides[i] = 0
22023  */
22024   __pyx_t_3 = __pyx_v_ndim;
22025   __pyx_t_5 = __pyx_t_3;
22026   for (__pyx_t_6 = 0; __pyx_t_6 < __pyx_t_5; __pyx_t_6+=1) {
22027     __pyx_v_i = __pyx_t_6;
22028 
22029     /* "View.MemoryView":1238
22030  *
22031  *     for i in range(ndim):
22032  *         if tmpslice.shape[i] == 1:             # <<<<<<<<<<<<<<
22033  *             tmpslice.strides[i] = 0
22034  *
22035  */
22036     __pyx_t_2 = (((__pyx_v_tmpslice->shape[__pyx_v_i]) == 1) != 0);
22037     if (__pyx_t_2) {
22038 
22039       /* "View.MemoryView":1239
22040  *     for i in range(ndim):
22041  *         if tmpslice.shape[i] == 1:
22042  *             tmpslice.strides[i] = 0             # <<<<<<<<<<<<<<
22043  *
22044  *     if slice_is_contig(src[0], order, ndim):
22045  */
22046       (__pyx_v_tmpslice->strides[__pyx_v_i]) = 0;
22047 
22048       /* "View.MemoryView":1238
22049  *
22050  *     for i in range(ndim):
22051  *         if tmpslice.shape[i] == 1:             # <<<<<<<<<<<<<<
22052  *             tmpslice.strides[i] = 0
22053  *
22054  */
22055     }
22056   }
22057 
22058   /* "View.MemoryView":1241
22059  *             tmpslice.strides[i] = 0
22060  *
22061  *     if slice_is_contig(src[0], order, ndim):             # <<<<<<<<<<<<<<
22062  *         memcpy(result, src.data, size)
22063  *     else:
22064  */
22065   __pyx_t_2 = (__pyx_memviewslice_is_contig((__pyx_v_src[0]), __pyx_v_order, __pyx_v_ndim) != 0);
22066   if (__pyx_t_2) {
22067 
22068     /* "View.MemoryView":1242
22069  *
22070  *     if slice_is_contig(src[0], order, ndim):
22071  *         memcpy(result, src.data, size)             # <<<<<<<<<<<<<<
22072  *     else:
22073  *         copy_strided_to_strided(src, tmpslice, ndim, itemsize)
22074  */
22075     (void)(memcpy(__pyx_v_result, __pyx_v_src->data, __pyx_v_size));
22076 
22077     /* "View.MemoryView":1241
22078  *             tmpslice.strides[i] = 0
22079  *
22080  *     if slice_is_contig(src[0], order, ndim):             # <<<<<<<<<<<<<<
22081  *         memcpy(result, src.data, size)
22082  *     else:
22083  */
22084     goto __pyx_L9;
22085   }
22086 
22087   /* "View.MemoryView":1244
22088  *         memcpy(result, src.data, size)
22089  *     else:
22090  *         copy_strided_to_strided(src, tmpslice, ndim, itemsize)             # <<<<<<<<<<<<<<
22091  *
22092  *     return result
22093  */
22094   /*else*/ {
22095     copy_strided_to_strided(__pyx_v_src, __pyx_v_tmpslice, __pyx_v_ndim, __pyx_v_itemsize);
22096   }
22097   __pyx_L9:;
22098 
22099   /* "View.MemoryView":1246
22100  *         copy_strided_to_strided(src, tmpslice, ndim, itemsize)
22101  *
22102  *     return result             # <<<<<<<<<<<<<<
22103  *
22104  *
22105  */
22106   __pyx_r = __pyx_v_result;
22107   goto __pyx_L0;
22108 
22109   /* "View.MemoryView":1208
22110  *
22111  * @cname('__pyx_memoryview_copy_data_to_temp')
22112  * cdef void *copy_data_to_temp(__Pyx_memviewslice *src,             # <<<<<<<<<<<<<<
22113  *                              __Pyx_memviewslice *tmpslice,
22114  *                              char order,
22115  */
22116 
22117   /* function exit code */
22118   __pyx_L1_error:;
22119   {
22120     #ifdef WITH_THREAD
22121     PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure();
22122     #endif
22123     __Pyx_AddTraceback("View.MemoryView.copy_data_to_temp", __pyx_clineno, __pyx_lineno, __pyx_filename);
22124     #ifdef WITH_THREAD
22125     __Pyx_PyGILState_Release(__pyx_gilstate_save);
22126     #endif
22127   }
22128   __pyx_r = NULL;
22129   __pyx_L0:;
22130   return __pyx_r;
22131 }
22132 
22133 /* "View.MemoryView":1251
22134  *
22135  * @cname('__pyx_memoryview_err_extents')
22136  * cdef int _err_extents(int i, Py_ssize_t extent1,             # <<<<<<<<<<<<<<
22137  *                              Py_ssize_t extent2) except -1 with gil:
22138  *     raise ValueError("got differing extents in dimension %d (got %d and %d)" %
22139  */
22140 
__pyx_memoryview_err_extents(int __pyx_v_i,Py_ssize_t __pyx_v_extent1,Py_ssize_t __pyx_v_extent2)22141 static int __pyx_memoryview_err_extents(int __pyx_v_i, Py_ssize_t __pyx_v_extent1, Py_ssize_t __pyx_v_extent2) {
22142   int __pyx_r;
22143   __Pyx_RefNannyDeclarations
22144   PyObject *__pyx_t_1 = NULL;
22145   PyObject *__pyx_t_2 = NULL;
22146   PyObject *__pyx_t_3 = NULL;
22147   PyObject *__pyx_t_4 = NULL;
22148   int __pyx_lineno = 0;
22149   const char *__pyx_filename = NULL;
22150   int __pyx_clineno = 0;
22151   #ifdef WITH_THREAD
22152   PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure();
22153   #endif
22154   __Pyx_RefNannySetupContext("_err_extents", 0);
22155 
22156   /* "View.MemoryView":1254
22157  *                              Py_ssize_t extent2) except -1 with gil:
22158  *     raise ValueError("got differing extents in dimension %d (got %d and %d)" %
22159  *                                                         (i, extent1, extent2))             # <<<<<<<<<<<<<<
22160  *
22161  * @cname('__pyx_memoryview_err_dim')
22162  */
22163   __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_i); if (unlikely(!__pyx_t_1)) __PYX_ERR(3, 1254, __pyx_L1_error)
22164   __Pyx_GOTREF(__pyx_t_1);
22165   __pyx_t_2 = PyInt_FromSsize_t(__pyx_v_extent1); if (unlikely(!__pyx_t_2)) __PYX_ERR(3, 1254, __pyx_L1_error)
22166   __Pyx_GOTREF(__pyx_t_2);
22167   __pyx_t_3 = PyInt_FromSsize_t(__pyx_v_extent2); if (unlikely(!__pyx_t_3)) __PYX_ERR(3, 1254, __pyx_L1_error)
22168   __Pyx_GOTREF(__pyx_t_3);
22169   __pyx_t_4 = PyTuple_New(3); if (unlikely(!__pyx_t_4)) __PYX_ERR(3, 1254, __pyx_L1_error)
22170   __Pyx_GOTREF(__pyx_t_4);
22171   __Pyx_GIVEREF(__pyx_t_1);
22172   PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_1);
22173   __Pyx_GIVEREF(__pyx_t_2);
22174   PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_2);
22175   __Pyx_GIVEREF(__pyx_t_3);
22176   PyTuple_SET_ITEM(__pyx_t_4, 2, __pyx_t_3);
22177   __pyx_t_1 = 0;
22178   __pyx_t_2 = 0;
22179   __pyx_t_3 = 0;
22180 
22181   /* "View.MemoryView":1253
22182  * cdef int _err_extents(int i, Py_ssize_t extent1,
22183  *                              Py_ssize_t extent2) except -1 with gil:
22184  *     raise ValueError("got differing extents in dimension %d (got %d and %d)" %             # <<<<<<<<<<<<<<
22185  *                                                         (i, extent1, extent2))
22186  *
22187  */
22188   __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)
22189   __Pyx_GOTREF(__pyx_t_3);
22190   __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
22191   __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_builtin_ValueError, __pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(3, 1253, __pyx_L1_error)
22192   __Pyx_GOTREF(__pyx_t_4);
22193   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
22194   __Pyx_Raise(__pyx_t_4, 0, 0, 0);
22195   __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
22196   __PYX_ERR(3, 1253, __pyx_L1_error)
22197 
22198   /* "View.MemoryView":1251
22199  *
22200  * @cname('__pyx_memoryview_err_extents')
22201  * cdef int _err_extents(int i, Py_ssize_t extent1,             # <<<<<<<<<<<<<<
22202  *                              Py_ssize_t extent2) except -1 with gil:
22203  *     raise ValueError("got differing extents in dimension %d (got %d and %d)" %
22204  */
22205 
22206   /* function exit code */
22207   __pyx_L1_error:;
22208   __Pyx_XDECREF(__pyx_t_1);
22209   __Pyx_XDECREF(__pyx_t_2);
22210   __Pyx_XDECREF(__pyx_t_3);
22211   __Pyx_XDECREF(__pyx_t_4);
22212   __Pyx_AddTraceback("View.MemoryView._err_extents", __pyx_clineno, __pyx_lineno, __pyx_filename);
22213   __pyx_r = -1;
22214   __Pyx_RefNannyFinishContext();
22215   #ifdef WITH_THREAD
22216   __Pyx_PyGILState_Release(__pyx_gilstate_save);
22217   #endif
22218   return __pyx_r;
22219 }
22220 
22221 /* "View.MemoryView":1257
22222  *
22223  * @cname('__pyx_memoryview_err_dim')
22224  * cdef int _err_dim(object error, char *msg, int dim) except -1 with gil:             # <<<<<<<<<<<<<<
22225  *     raise error(msg.decode('ascii') % dim)
22226  *
22227  */
22228 
__pyx_memoryview_err_dim(PyObject * __pyx_v_error,char * __pyx_v_msg,int __pyx_v_dim)22229 static int __pyx_memoryview_err_dim(PyObject *__pyx_v_error, char *__pyx_v_msg, int __pyx_v_dim) {
22230   int __pyx_r;
22231   __Pyx_RefNannyDeclarations
22232   PyObject *__pyx_t_1 = NULL;
22233   PyObject *__pyx_t_2 = NULL;
22234   PyObject *__pyx_t_3 = NULL;
22235   PyObject *__pyx_t_4 = NULL;
22236   int __pyx_lineno = 0;
22237   const char *__pyx_filename = NULL;
22238   int __pyx_clineno = 0;
22239   #ifdef WITH_THREAD
22240   PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure();
22241   #endif
22242   __Pyx_RefNannySetupContext("_err_dim", 0);
22243   __Pyx_INCREF(__pyx_v_error);
22244 
22245   /* "View.MemoryView":1258
22246  * @cname('__pyx_memoryview_err_dim')
22247  * cdef int _err_dim(object error, char *msg, int dim) except -1 with gil:
22248  *     raise error(msg.decode('ascii') % dim)             # <<<<<<<<<<<<<<
22249  *
22250  * @cname('__pyx_memoryview_err')
22251  */
22252   __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)
22253   __Pyx_GOTREF(__pyx_t_2);
22254   __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_dim); if (unlikely(!__pyx_t_3)) __PYX_ERR(3, 1258, __pyx_L1_error)
22255   __Pyx_GOTREF(__pyx_t_3);
22256   __pyx_t_4 = PyUnicode_Format(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(3, 1258, __pyx_L1_error)
22257   __Pyx_GOTREF(__pyx_t_4);
22258   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
22259   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
22260   __Pyx_INCREF(__pyx_v_error);
22261   __pyx_t_3 = __pyx_v_error; __pyx_t_2 = NULL;
22262   if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
22263     __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3);
22264     if (likely(__pyx_t_2)) {
22265       PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
22266       __Pyx_INCREF(__pyx_t_2);
22267       __Pyx_INCREF(function);
22268       __Pyx_DECREF_SET(__pyx_t_3, function);
22269     }
22270   }
22271   __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);
22272   __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
22273   __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
22274   if (unlikely(!__pyx_t_1)) __PYX_ERR(3, 1258, __pyx_L1_error)
22275   __Pyx_GOTREF(__pyx_t_1);
22276   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
22277   __Pyx_Raise(__pyx_t_1, 0, 0, 0);
22278   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
22279   __PYX_ERR(3, 1258, __pyx_L1_error)
22280 
22281   /* "View.MemoryView":1257
22282  *
22283  * @cname('__pyx_memoryview_err_dim')
22284  * cdef int _err_dim(object error, char *msg, int dim) except -1 with gil:             # <<<<<<<<<<<<<<
22285  *     raise error(msg.decode('ascii') % dim)
22286  *
22287  */
22288 
22289   /* function exit code */
22290   __pyx_L1_error:;
22291   __Pyx_XDECREF(__pyx_t_1);
22292   __Pyx_XDECREF(__pyx_t_2);
22293   __Pyx_XDECREF(__pyx_t_3);
22294   __Pyx_XDECREF(__pyx_t_4);
22295   __Pyx_AddTraceback("View.MemoryView._err_dim", __pyx_clineno, __pyx_lineno, __pyx_filename);
22296   __pyx_r = -1;
22297   __Pyx_XDECREF(__pyx_v_error);
22298   __Pyx_RefNannyFinishContext();
22299   #ifdef WITH_THREAD
22300   __Pyx_PyGILState_Release(__pyx_gilstate_save);
22301   #endif
22302   return __pyx_r;
22303 }
22304 
22305 /* "View.MemoryView":1261
22306  *
22307  * @cname('__pyx_memoryview_err')
22308  * cdef int _err(object error, char *msg) except -1 with gil:             # <<<<<<<<<<<<<<
22309  *     if msg != NULL:
22310  *         raise error(msg.decode('ascii'))
22311  */
22312 
__pyx_memoryview_err(PyObject * __pyx_v_error,char * __pyx_v_msg)22313 static int __pyx_memoryview_err(PyObject *__pyx_v_error, char *__pyx_v_msg) {
22314   int __pyx_r;
22315   __Pyx_RefNannyDeclarations
22316   int __pyx_t_1;
22317   PyObject *__pyx_t_2 = NULL;
22318   PyObject *__pyx_t_3 = NULL;
22319   PyObject *__pyx_t_4 = NULL;
22320   PyObject *__pyx_t_5 = NULL;
22321   int __pyx_lineno = 0;
22322   const char *__pyx_filename = NULL;
22323   int __pyx_clineno = 0;
22324   #ifdef WITH_THREAD
22325   PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure();
22326   #endif
22327   __Pyx_RefNannySetupContext("_err", 0);
22328   __Pyx_INCREF(__pyx_v_error);
22329 
22330   /* "View.MemoryView":1262
22331  * @cname('__pyx_memoryview_err')
22332  * cdef int _err(object error, char *msg) except -1 with gil:
22333  *     if msg != NULL:             # <<<<<<<<<<<<<<
22334  *         raise error(msg.decode('ascii'))
22335  *     else:
22336  */
22337   __pyx_t_1 = ((__pyx_v_msg != NULL) != 0);
22338   if (unlikely(__pyx_t_1)) {
22339 
22340     /* "View.MemoryView":1263
22341  * cdef int _err(object error, char *msg) except -1 with gil:
22342  *     if msg != NULL:
22343  *         raise error(msg.decode('ascii'))             # <<<<<<<<<<<<<<
22344  *     else:
22345  *         raise error
22346  */
22347     __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)
22348     __Pyx_GOTREF(__pyx_t_3);
22349     __Pyx_INCREF(__pyx_v_error);
22350     __pyx_t_4 = __pyx_v_error; __pyx_t_5 = NULL;
22351     if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_4))) {
22352       __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4);
22353       if (likely(__pyx_t_5)) {
22354         PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
22355         __Pyx_INCREF(__pyx_t_5);
22356         __Pyx_INCREF(function);
22357         __Pyx_DECREF_SET(__pyx_t_4, function);
22358       }
22359     }
22360     __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);
22361     __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
22362     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
22363     if (unlikely(!__pyx_t_2)) __PYX_ERR(3, 1263, __pyx_L1_error)
22364     __Pyx_GOTREF(__pyx_t_2);
22365     __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
22366     __Pyx_Raise(__pyx_t_2, 0, 0, 0);
22367     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
22368     __PYX_ERR(3, 1263, __pyx_L1_error)
22369 
22370     /* "View.MemoryView":1262
22371  * @cname('__pyx_memoryview_err')
22372  * cdef int _err(object error, char *msg) except -1 with gil:
22373  *     if msg != NULL:             # <<<<<<<<<<<<<<
22374  *         raise error(msg.decode('ascii'))
22375  *     else:
22376  */
22377   }
22378 
22379   /* "View.MemoryView":1265
22380  *         raise error(msg.decode('ascii'))
22381  *     else:
22382  *         raise error             # <<<<<<<<<<<<<<
22383  *
22384  * @cname('__pyx_memoryview_copy_contents')
22385  */
22386   /*else*/ {
22387     __Pyx_Raise(__pyx_v_error, 0, 0, 0);
22388     __PYX_ERR(3, 1265, __pyx_L1_error)
22389   }
22390 
22391   /* "View.MemoryView":1261
22392  *
22393  * @cname('__pyx_memoryview_err')
22394  * cdef int _err(object error, char *msg) except -1 with gil:             # <<<<<<<<<<<<<<
22395  *     if msg != NULL:
22396  *         raise error(msg.decode('ascii'))
22397  */
22398 
22399   /* function exit code */
22400   __pyx_L1_error:;
22401   __Pyx_XDECREF(__pyx_t_2);
22402   __Pyx_XDECREF(__pyx_t_3);
22403   __Pyx_XDECREF(__pyx_t_4);
22404   __Pyx_XDECREF(__pyx_t_5);
22405   __Pyx_AddTraceback("View.MemoryView._err", __pyx_clineno, __pyx_lineno, __pyx_filename);
22406   __pyx_r = -1;
22407   __Pyx_XDECREF(__pyx_v_error);
22408   __Pyx_RefNannyFinishContext();
22409   #ifdef WITH_THREAD
22410   __Pyx_PyGILState_Release(__pyx_gilstate_save);
22411   #endif
22412   return __pyx_r;
22413 }
22414 
22415 /* "View.MemoryView":1268
22416  *
22417  * @cname('__pyx_memoryview_copy_contents')
22418  * cdef int memoryview_copy_contents(__Pyx_memviewslice src,             # <<<<<<<<<<<<<<
22419  *                                   __Pyx_memviewslice dst,
22420  *                                   int src_ndim, int dst_ndim,
22421  */
22422 
__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)22423 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) {
22424   void *__pyx_v_tmpdata;
22425   size_t __pyx_v_itemsize;
22426   int __pyx_v_i;
22427   char __pyx_v_order;
22428   int __pyx_v_broadcasting;
22429   int __pyx_v_direct_copy;
22430   __Pyx_memviewslice __pyx_v_tmp;
22431   int __pyx_v_ndim;
22432   int __pyx_r;
22433   Py_ssize_t __pyx_t_1;
22434   int __pyx_t_2;
22435   int __pyx_t_3;
22436   int __pyx_t_4;
22437   int __pyx_t_5;
22438   int __pyx_t_6;
22439   void *__pyx_t_7;
22440   int __pyx_t_8;
22441   int __pyx_lineno = 0;
22442   const char *__pyx_filename = NULL;
22443   int __pyx_clineno = 0;
22444 
22445   /* "View.MemoryView":1276
22446  *     Check for overlapping memory and verify the shapes.
22447  *     """
22448  *     cdef void *tmpdata = NULL             # <<<<<<<<<<<<<<
22449  *     cdef size_t itemsize = src.memview.view.itemsize
22450  *     cdef int i
22451  */
22452   __pyx_v_tmpdata = NULL;
22453 
22454   /* "View.MemoryView":1277
22455  *     """
22456  *     cdef void *tmpdata = NULL
22457  *     cdef size_t itemsize = src.memview.view.itemsize             # <<<<<<<<<<<<<<
22458  *     cdef int i
22459  *     cdef char order = get_best_order(&src, src_ndim)
22460  */
22461   __pyx_t_1 = __pyx_v_src.memview->view.itemsize;
22462   __pyx_v_itemsize = __pyx_t_1;
22463 
22464   /* "View.MemoryView":1279
22465  *     cdef size_t itemsize = src.memview.view.itemsize
22466  *     cdef int i
22467  *     cdef char order = get_best_order(&src, src_ndim)             # <<<<<<<<<<<<<<
22468  *     cdef bint broadcasting = False
22469  *     cdef bint direct_copy = False
22470  */
22471   __pyx_v_order = __pyx_get_best_slice_order((&__pyx_v_src), __pyx_v_src_ndim);
22472 
22473   /* "View.MemoryView":1280
22474  *     cdef int i
22475  *     cdef char order = get_best_order(&src, src_ndim)
22476  *     cdef bint broadcasting = False             # <<<<<<<<<<<<<<
22477  *     cdef bint direct_copy = False
22478  *     cdef __Pyx_memviewslice tmp
22479  */
22480   __pyx_v_broadcasting = 0;
22481 
22482   /* "View.MemoryView":1281
22483  *     cdef char order = get_best_order(&src, src_ndim)
22484  *     cdef bint broadcasting = False
22485  *     cdef bint direct_copy = False             # <<<<<<<<<<<<<<
22486  *     cdef __Pyx_memviewslice tmp
22487  *
22488  */
22489   __pyx_v_direct_copy = 0;
22490 
22491   /* "View.MemoryView":1284
22492  *     cdef __Pyx_memviewslice tmp
22493  *
22494  *     if src_ndim < dst_ndim:             # <<<<<<<<<<<<<<
22495  *         broadcast_leading(&src, src_ndim, dst_ndim)
22496  *     elif dst_ndim < src_ndim:
22497  */
22498   __pyx_t_2 = ((__pyx_v_src_ndim < __pyx_v_dst_ndim) != 0);
22499   if (__pyx_t_2) {
22500 
22501     /* "View.MemoryView":1285
22502  *
22503  *     if src_ndim < dst_ndim:
22504  *         broadcast_leading(&src, src_ndim, dst_ndim)             # <<<<<<<<<<<<<<
22505  *     elif dst_ndim < src_ndim:
22506  *         broadcast_leading(&dst, dst_ndim, src_ndim)
22507  */
22508     __pyx_memoryview_broadcast_leading((&__pyx_v_src), __pyx_v_src_ndim, __pyx_v_dst_ndim);
22509 
22510     /* "View.MemoryView":1284
22511  *     cdef __Pyx_memviewslice tmp
22512  *
22513  *     if src_ndim < dst_ndim:             # <<<<<<<<<<<<<<
22514  *         broadcast_leading(&src, src_ndim, dst_ndim)
22515  *     elif dst_ndim < src_ndim:
22516  */
22517     goto __pyx_L3;
22518   }
22519 
22520   /* "View.MemoryView":1286
22521  *     if src_ndim < dst_ndim:
22522  *         broadcast_leading(&src, src_ndim, dst_ndim)
22523  *     elif dst_ndim < src_ndim:             # <<<<<<<<<<<<<<
22524  *         broadcast_leading(&dst, dst_ndim, src_ndim)
22525  *
22526  */
22527   __pyx_t_2 = ((__pyx_v_dst_ndim < __pyx_v_src_ndim) != 0);
22528   if (__pyx_t_2) {
22529 
22530     /* "View.MemoryView":1287
22531  *         broadcast_leading(&src, src_ndim, dst_ndim)
22532  *     elif dst_ndim < src_ndim:
22533  *         broadcast_leading(&dst, dst_ndim, src_ndim)             # <<<<<<<<<<<<<<
22534  *
22535  *     cdef int ndim = max(src_ndim, dst_ndim)
22536  */
22537     __pyx_memoryview_broadcast_leading((&__pyx_v_dst), __pyx_v_dst_ndim, __pyx_v_src_ndim);
22538 
22539     /* "View.MemoryView":1286
22540  *     if src_ndim < dst_ndim:
22541  *         broadcast_leading(&src, src_ndim, dst_ndim)
22542  *     elif dst_ndim < src_ndim:             # <<<<<<<<<<<<<<
22543  *         broadcast_leading(&dst, dst_ndim, src_ndim)
22544  *
22545  */
22546   }
22547   __pyx_L3:;
22548 
22549   /* "View.MemoryView":1289
22550  *         broadcast_leading(&dst, dst_ndim, src_ndim)
22551  *
22552  *     cdef int ndim = max(src_ndim, dst_ndim)             # <<<<<<<<<<<<<<
22553  *
22554  *     for i in range(ndim):
22555  */
22556   __pyx_t_3 = __pyx_v_dst_ndim;
22557   __pyx_t_4 = __pyx_v_src_ndim;
22558   if (((__pyx_t_3 > __pyx_t_4) != 0)) {
22559     __pyx_t_5 = __pyx_t_3;
22560   } else {
22561     __pyx_t_5 = __pyx_t_4;
22562   }
22563   __pyx_v_ndim = __pyx_t_5;
22564 
22565   /* "View.MemoryView":1291
22566  *     cdef int ndim = max(src_ndim, dst_ndim)
22567  *
22568  *     for i in range(ndim):             # <<<<<<<<<<<<<<
22569  *         if src.shape[i] != dst.shape[i]:
22570  *             if src.shape[i] == 1:
22571  */
22572   __pyx_t_5 = __pyx_v_ndim;
22573   __pyx_t_3 = __pyx_t_5;
22574   for (__pyx_t_4 = 0; __pyx_t_4 < __pyx_t_3; __pyx_t_4+=1) {
22575     __pyx_v_i = __pyx_t_4;
22576 
22577     /* "View.MemoryView":1292
22578  *
22579  *     for i in range(ndim):
22580  *         if src.shape[i] != dst.shape[i]:             # <<<<<<<<<<<<<<
22581  *             if src.shape[i] == 1:
22582  *                 broadcasting = True
22583  */
22584     __pyx_t_2 = (((__pyx_v_src.shape[__pyx_v_i]) != (__pyx_v_dst.shape[__pyx_v_i])) != 0);
22585     if (__pyx_t_2) {
22586 
22587       /* "View.MemoryView":1293
22588  *     for i in range(ndim):
22589  *         if src.shape[i] != dst.shape[i]:
22590  *             if src.shape[i] == 1:             # <<<<<<<<<<<<<<
22591  *                 broadcasting = True
22592  *                 src.strides[i] = 0
22593  */
22594       __pyx_t_2 = (((__pyx_v_src.shape[__pyx_v_i]) == 1) != 0);
22595       if (__pyx_t_2) {
22596 
22597         /* "View.MemoryView":1294
22598  *         if src.shape[i] != dst.shape[i]:
22599  *             if src.shape[i] == 1:
22600  *                 broadcasting = True             # <<<<<<<<<<<<<<
22601  *                 src.strides[i] = 0
22602  *             else:
22603  */
22604         __pyx_v_broadcasting = 1;
22605 
22606         /* "View.MemoryView":1295
22607  *             if src.shape[i] == 1:
22608  *                 broadcasting = True
22609  *                 src.strides[i] = 0             # <<<<<<<<<<<<<<
22610  *             else:
22611  *                 _err_extents(i, dst.shape[i], src.shape[i])
22612  */
22613         (__pyx_v_src.strides[__pyx_v_i]) = 0;
22614 
22615         /* "View.MemoryView":1293
22616  *     for i in range(ndim):
22617  *         if src.shape[i] != dst.shape[i]:
22618  *             if src.shape[i] == 1:             # <<<<<<<<<<<<<<
22619  *                 broadcasting = True
22620  *                 src.strides[i] = 0
22621  */
22622         goto __pyx_L7;
22623       }
22624 
22625       /* "View.MemoryView":1297
22626  *                 src.strides[i] = 0
22627  *             else:
22628  *                 _err_extents(i, dst.shape[i], src.shape[i])             # <<<<<<<<<<<<<<
22629  *
22630  *         if src.suboffsets[i] >= 0:
22631  */
22632       /*else*/ {
22633         __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)
22634       }
22635       __pyx_L7:;
22636 
22637       /* "View.MemoryView":1292
22638  *
22639  *     for i in range(ndim):
22640  *         if src.shape[i] != dst.shape[i]:             # <<<<<<<<<<<<<<
22641  *             if src.shape[i] == 1:
22642  *                 broadcasting = True
22643  */
22644     }
22645 
22646     /* "View.MemoryView":1299
22647  *                 _err_extents(i, dst.shape[i], src.shape[i])
22648  *
22649  *         if src.suboffsets[i] >= 0:             # <<<<<<<<<<<<<<
22650  *             _err_dim(ValueError, "Dimension %d is not direct", i)
22651  *
22652  */
22653     __pyx_t_2 = (((__pyx_v_src.suboffsets[__pyx_v_i]) >= 0) != 0);
22654     if (__pyx_t_2) {
22655 
22656       /* "View.MemoryView":1300
22657  *
22658  *         if src.suboffsets[i] >= 0:
22659  *             _err_dim(ValueError, "Dimension %d is not direct", i)             # <<<<<<<<<<<<<<
22660  *
22661  *     if slices_overlap(&src, &dst, ndim, itemsize):
22662  */
22663       __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)
22664 
22665       /* "View.MemoryView":1299
22666  *                 _err_extents(i, dst.shape[i], src.shape[i])
22667  *
22668  *         if src.suboffsets[i] >= 0:             # <<<<<<<<<<<<<<
22669  *             _err_dim(ValueError, "Dimension %d is not direct", i)
22670  *
22671  */
22672     }
22673   }
22674 
22675   /* "View.MemoryView":1302
22676  *             _err_dim(ValueError, "Dimension %d is not direct", i)
22677  *
22678  *     if slices_overlap(&src, &dst, ndim, itemsize):             # <<<<<<<<<<<<<<
22679  *
22680  *         if not slice_is_contig(src, order, ndim):
22681  */
22682   __pyx_t_2 = (__pyx_slices_overlap((&__pyx_v_src), (&__pyx_v_dst), __pyx_v_ndim, __pyx_v_itemsize) != 0);
22683   if (__pyx_t_2) {
22684 
22685     /* "View.MemoryView":1304
22686  *     if slices_overlap(&src, &dst, ndim, itemsize):
22687  *
22688  *         if not slice_is_contig(src, order, ndim):             # <<<<<<<<<<<<<<
22689  *             order = get_best_order(&dst, ndim)
22690  *
22691  */
22692     __pyx_t_2 = ((!(__pyx_memviewslice_is_contig(__pyx_v_src, __pyx_v_order, __pyx_v_ndim) != 0)) != 0);
22693     if (__pyx_t_2) {
22694 
22695       /* "View.MemoryView":1305
22696  *
22697  *         if not slice_is_contig(src, order, ndim):
22698  *             order = get_best_order(&dst, ndim)             # <<<<<<<<<<<<<<
22699  *
22700  *         tmpdata = copy_data_to_temp(&src, &tmp, order, ndim)
22701  */
22702       __pyx_v_order = __pyx_get_best_slice_order((&__pyx_v_dst), __pyx_v_ndim);
22703 
22704       /* "View.MemoryView":1304
22705  *     if slices_overlap(&src, &dst, ndim, itemsize):
22706  *
22707  *         if not slice_is_contig(src, order, ndim):             # <<<<<<<<<<<<<<
22708  *             order = get_best_order(&dst, ndim)
22709  *
22710  */
22711     }
22712 
22713     /* "View.MemoryView":1307
22714  *             order = get_best_order(&dst, ndim)
22715  *
22716  *         tmpdata = copy_data_to_temp(&src, &tmp, order, ndim)             # <<<<<<<<<<<<<<
22717  *         src = tmp
22718  *
22719  */
22720     __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)
22721     __pyx_v_tmpdata = __pyx_t_7;
22722 
22723     /* "View.MemoryView":1308
22724  *
22725  *         tmpdata = copy_data_to_temp(&src, &tmp, order, ndim)
22726  *         src = tmp             # <<<<<<<<<<<<<<
22727  *
22728  *     if not broadcasting:
22729  */
22730     __pyx_v_src = __pyx_v_tmp;
22731 
22732     /* "View.MemoryView":1302
22733  *             _err_dim(ValueError, "Dimension %d is not direct", i)
22734  *
22735  *     if slices_overlap(&src, &dst, ndim, itemsize):             # <<<<<<<<<<<<<<
22736  *
22737  *         if not slice_is_contig(src, order, ndim):
22738  */
22739   }
22740 
22741   /* "View.MemoryView":1310
22742  *         src = tmp
22743  *
22744  *     if not broadcasting:             # <<<<<<<<<<<<<<
22745  *
22746  *
22747  */
22748   __pyx_t_2 = ((!(__pyx_v_broadcasting != 0)) != 0);
22749   if (__pyx_t_2) {
22750 
22751     /* "View.MemoryView":1313
22752  *
22753  *
22754  *         if slice_is_contig(src, 'C', ndim):             # <<<<<<<<<<<<<<
22755  *             direct_copy = slice_is_contig(dst, 'C', ndim)
22756  *         elif slice_is_contig(src, 'F', ndim):
22757  */
22758     __pyx_t_2 = (__pyx_memviewslice_is_contig(__pyx_v_src, 'C', __pyx_v_ndim) != 0);
22759     if (__pyx_t_2) {
22760 
22761       /* "View.MemoryView":1314
22762  *
22763  *         if slice_is_contig(src, 'C', ndim):
22764  *             direct_copy = slice_is_contig(dst, 'C', ndim)             # <<<<<<<<<<<<<<
22765  *         elif slice_is_contig(src, 'F', ndim):
22766  *             direct_copy = slice_is_contig(dst, 'F', ndim)
22767  */
22768       __pyx_v_direct_copy = __pyx_memviewslice_is_contig(__pyx_v_dst, 'C', __pyx_v_ndim);
22769 
22770       /* "View.MemoryView":1313
22771  *
22772  *
22773  *         if slice_is_contig(src, 'C', ndim):             # <<<<<<<<<<<<<<
22774  *             direct_copy = slice_is_contig(dst, 'C', ndim)
22775  *         elif slice_is_contig(src, 'F', ndim):
22776  */
22777       goto __pyx_L12;
22778     }
22779 
22780     /* "View.MemoryView":1315
22781  *         if slice_is_contig(src, 'C', ndim):
22782  *             direct_copy = slice_is_contig(dst, 'C', ndim)
22783  *         elif slice_is_contig(src, 'F', ndim):             # <<<<<<<<<<<<<<
22784  *             direct_copy = slice_is_contig(dst, 'F', ndim)
22785  *
22786  */
22787     __pyx_t_2 = (__pyx_memviewslice_is_contig(__pyx_v_src, 'F', __pyx_v_ndim) != 0);
22788     if (__pyx_t_2) {
22789 
22790       /* "View.MemoryView":1316
22791  *             direct_copy = slice_is_contig(dst, 'C', ndim)
22792  *         elif slice_is_contig(src, 'F', ndim):
22793  *             direct_copy = slice_is_contig(dst, 'F', ndim)             # <<<<<<<<<<<<<<
22794  *
22795  *         if direct_copy:
22796  */
22797       __pyx_v_direct_copy = __pyx_memviewslice_is_contig(__pyx_v_dst, 'F', __pyx_v_ndim);
22798 
22799       /* "View.MemoryView":1315
22800  *         if slice_is_contig(src, 'C', ndim):
22801  *             direct_copy = slice_is_contig(dst, 'C', ndim)
22802  *         elif slice_is_contig(src, 'F', ndim):             # <<<<<<<<<<<<<<
22803  *             direct_copy = slice_is_contig(dst, 'F', ndim)
22804  *
22805  */
22806     }
22807     __pyx_L12:;
22808 
22809     /* "View.MemoryView":1318
22810  *             direct_copy = slice_is_contig(dst, 'F', ndim)
22811  *
22812  *         if direct_copy:             # <<<<<<<<<<<<<<
22813  *
22814  *             refcount_copying(&dst, dtype_is_object, ndim, False)
22815  */
22816     __pyx_t_2 = (__pyx_v_direct_copy != 0);
22817     if (__pyx_t_2) {
22818 
22819       /* "View.MemoryView":1320
22820  *         if direct_copy:
22821  *
22822  *             refcount_copying(&dst, dtype_is_object, ndim, False)             # <<<<<<<<<<<<<<
22823  *             memcpy(dst.data, src.data, slice_get_size(&src, ndim))
22824  *             refcount_copying(&dst, dtype_is_object, ndim, True)
22825  */
22826       __pyx_memoryview_refcount_copying((&__pyx_v_dst), __pyx_v_dtype_is_object, __pyx_v_ndim, 0);
22827 
22828       /* "View.MemoryView":1321
22829  *
22830  *             refcount_copying(&dst, dtype_is_object, ndim, False)
22831  *             memcpy(dst.data, src.data, slice_get_size(&src, ndim))             # <<<<<<<<<<<<<<
22832  *             refcount_copying(&dst, dtype_is_object, ndim, True)
22833  *             free(tmpdata)
22834  */
22835       (void)(memcpy(__pyx_v_dst.data, __pyx_v_src.data, __pyx_memoryview_slice_get_size((&__pyx_v_src), __pyx_v_ndim)));
22836 
22837       /* "View.MemoryView":1322
22838  *             refcount_copying(&dst, dtype_is_object, ndim, False)
22839  *             memcpy(dst.data, src.data, slice_get_size(&src, ndim))
22840  *             refcount_copying(&dst, dtype_is_object, ndim, True)             # <<<<<<<<<<<<<<
22841  *             free(tmpdata)
22842  *             return 0
22843  */
22844       __pyx_memoryview_refcount_copying((&__pyx_v_dst), __pyx_v_dtype_is_object, __pyx_v_ndim, 1);
22845 
22846       /* "View.MemoryView":1323
22847  *             memcpy(dst.data, src.data, slice_get_size(&src, ndim))
22848  *             refcount_copying(&dst, dtype_is_object, ndim, True)
22849  *             free(tmpdata)             # <<<<<<<<<<<<<<
22850  *             return 0
22851  *
22852  */
22853       free(__pyx_v_tmpdata);
22854 
22855       /* "View.MemoryView":1324
22856  *             refcount_copying(&dst, dtype_is_object, ndim, True)
22857  *             free(tmpdata)
22858  *             return 0             # <<<<<<<<<<<<<<
22859  *
22860  *     if order == 'F' == get_best_order(&dst, ndim):
22861  */
22862       __pyx_r = 0;
22863       goto __pyx_L0;
22864 
22865       /* "View.MemoryView":1318
22866  *             direct_copy = slice_is_contig(dst, 'F', ndim)
22867  *
22868  *         if direct_copy:             # <<<<<<<<<<<<<<
22869  *
22870  *             refcount_copying(&dst, dtype_is_object, ndim, False)
22871  */
22872     }
22873 
22874     /* "View.MemoryView":1310
22875  *         src = tmp
22876  *
22877  *     if not broadcasting:             # <<<<<<<<<<<<<<
22878  *
22879  *
22880  */
22881   }
22882 
22883   /* "View.MemoryView":1326
22884  *             return 0
22885  *
22886  *     if order == 'F' == get_best_order(&dst, ndim):             # <<<<<<<<<<<<<<
22887  *
22888  *
22889  */
22890   __pyx_t_2 = (__pyx_v_order == 'F');
22891   if (__pyx_t_2) {
22892     __pyx_t_2 = ('F' == __pyx_get_best_slice_order((&__pyx_v_dst), __pyx_v_ndim));
22893   }
22894   __pyx_t_8 = (__pyx_t_2 != 0);
22895   if (__pyx_t_8) {
22896 
22897     /* "View.MemoryView":1329
22898  *
22899  *
22900  *         transpose_memslice(&src)             # <<<<<<<<<<<<<<
22901  *         transpose_memslice(&dst)
22902  *
22903  */
22904     __pyx_t_5 = __pyx_memslice_transpose((&__pyx_v_src)); if (unlikely(__pyx_t_5 == ((int)0))) __PYX_ERR(3, 1329, __pyx_L1_error)
22905 
22906     /* "View.MemoryView":1330
22907  *
22908  *         transpose_memslice(&src)
22909  *         transpose_memslice(&dst)             # <<<<<<<<<<<<<<
22910  *
22911  *     refcount_copying(&dst, dtype_is_object, ndim, False)
22912  */
22913     __pyx_t_5 = __pyx_memslice_transpose((&__pyx_v_dst)); if (unlikely(__pyx_t_5 == ((int)0))) __PYX_ERR(3, 1330, __pyx_L1_error)
22914 
22915     /* "View.MemoryView":1326
22916  *             return 0
22917  *
22918  *     if order == 'F' == get_best_order(&dst, ndim):             # <<<<<<<<<<<<<<
22919  *
22920  *
22921  */
22922   }
22923 
22924   /* "View.MemoryView":1332
22925  *         transpose_memslice(&dst)
22926  *
22927  *     refcount_copying(&dst, dtype_is_object, ndim, False)             # <<<<<<<<<<<<<<
22928  *     copy_strided_to_strided(&src, &dst, ndim, itemsize)
22929  *     refcount_copying(&dst, dtype_is_object, ndim, True)
22930  */
22931   __pyx_memoryview_refcount_copying((&__pyx_v_dst), __pyx_v_dtype_is_object, __pyx_v_ndim, 0);
22932 
22933   /* "View.MemoryView":1333
22934  *
22935  *     refcount_copying(&dst, dtype_is_object, ndim, False)
22936  *     copy_strided_to_strided(&src, &dst, ndim, itemsize)             # <<<<<<<<<<<<<<
22937  *     refcount_copying(&dst, dtype_is_object, ndim, True)
22938  *
22939  */
22940   copy_strided_to_strided((&__pyx_v_src), (&__pyx_v_dst), __pyx_v_ndim, __pyx_v_itemsize);
22941 
22942   /* "View.MemoryView":1334
22943  *     refcount_copying(&dst, dtype_is_object, ndim, False)
22944  *     copy_strided_to_strided(&src, &dst, ndim, itemsize)
22945  *     refcount_copying(&dst, dtype_is_object, ndim, True)             # <<<<<<<<<<<<<<
22946  *
22947  *     free(tmpdata)
22948  */
22949   __pyx_memoryview_refcount_copying((&__pyx_v_dst), __pyx_v_dtype_is_object, __pyx_v_ndim, 1);
22950 
22951   /* "View.MemoryView":1336
22952  *     refcount_copying(&dst, dtype_is_object, ndim, True)
22953  *
22954  *     free(tmpdata)             # <<<<<<<<<<<<<<
22955  *     return 0
22956  *
22957  */
22958   free(__pyx_v_tmpdata);
22959 
22960   /* "View.MemoryView":1337
22961  *
22962  *     free(tmpdata)
22963  *     return 0             # <<<<<<<<<<<<<<
22964  *
22965  * @cname('__pyx_memoryview_broadcast_leading')
22966  */
22967   __pyx_r = 0;
22968   goto __pyx_L0;
22969 
22970   /* "View.MemoryView":1268
22971  *
22972  * @cname('__pyx_memoryview_copy_contents')
22973  * cdef int memoryview_copy_contents(__Pyx_memviewslice src,             # <<<<<<<<<<<<<<
22974  *                                   __Pyx_memviewslice dst,
22975  *                                   int src_ndim, int dst_ndim,
22976  */
22977 
22978   /* function exit code */
22979   __pyx_L1_error:;
22980   {
22981     #ifdef WITH_THREAD
22982     PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure();
22983     #endif
22984     __Pyx_AddTraceback("View.MemoryView.memoryview_copy_contents", __pyx_clineno, __pyx_lineno, __pyx_filename);
22985     #ifdef WITH_THREAD
22986     __Pyx_PyGILState_Release(__pyx_gilstate_save);
22987     #endif
22988   }
22989   __pyx_r = -1;
22990   __pyx_L0:;
22991   return __pyx_r;
22992 }
22993 
22994 /* "View.MemoryView":1340
22995  *
22996  * @cname('__pyx_memoryview_broadcast_leading')
22997  * cdef void broadcast_leading(__Pyx_memviewslice *mslice,             # <<<<<<<<<<<<<<
22998  *                             int ndim,
22999  *                             int ndim_other) nogil:
23000  */
23001 
__pyx_memoryview_broadcast_leading(__Pyx_memviewslice * __pyx_v_mslice,int __pyx_v_ndim,int __pyx_v_ndim_other)23002 static void __pyx_memoryview_broadcast_leading(__Pyx_memviewslice *__pyx_v_mslice, int __pyx_v_ndim, int __pyx_v_ndim_other) {
23003   int __pyx_v_i;
23004   int __pyx_v_offset;
23005   int __pyx_t_1;
23006   int __pyx_t_2;
23007   int __pyx_t_3;
23008 
23009   /* "View.MemoryView":1344
23010  *                             int ndim_other) nogil:
23011  *     cdef int i
23012  *     cdef int offset = ndim_other - ndim             # <<<<<<<<<<<<<<
23013  *
23014  *     for i in range(ndim - 1, -1, -1):
23015  */
23016   __pyx_v_offset = (__pyx_v_ndim_other - __pyx_v_ndim);
23017 
23018   /* "View.MemoryView":1346
23019  *     cdef int offset = ndim_other - ndim
23020  *
23021  *     for i in range(ndim - 1, -1, -1):             # <<<<<<<<<<<<<<
23022  *         mslice.shape[i + offset] = mslice.shape[i]
23023  *         mslice.strides[i + offset] = mslice.strides[i]
23024  */
23025   for (__pyx_t_1 = (__pyx_v_ndim - 1); __pyx_t_1 > -1; __pyx_t_1-=1) {
23026     __pyx_v_i = __pyx_t_1;
23027 
23028     /* "View.MemoryView":1347
23029  *
23030  *     for i in range(ndim - 1, -1, -1):
23031  *         mslice.shape[i + offset] = mslice.shape[i]             # <<<<<<<<<<<<<<
23032  *         mslice.strides[i + offset] = mslice.strides[i]
23033  *         mslice.suboffsets[i + offset] = mslice.suboffsets[i]
23034  */
23035     (__pyx_v_mslice->shape[(__pyx_v_i + __pyx_v_offset)]) = (__pyx_v_mslice->shape[__pyx_v_i]);
23036 
23037     /* "View.MemoryView":1348
23038  *     for i in range(ndim - 1, -1, -1):
23039  *         mslice.shape[i + offset] = mslice.shape[i]
23040  *         mslice.strides[i + offset] = mslice.strides[i]             # <<<<<<<<<<<<<<
23041  *         mslice.suboffsets[i + offset] = mslice.suboffsets[i]
23042  *
23043  */
23044     (__pyx_v_mslice->strides[(__pyx_v_i + __pyx_v_offset)]) = (__pyx_v_mslice->strides[__pyx_v_i]);
23045 
23046     /* "View.MemoryView":1349
23047  *         mslice.shape[i + offset] = mslice.shape[i]
23048  *         mslice.strides[i + offset] = mslice.strides[i]
23049  *         mslice.suboffsets[i + offset] = mslice.suboffsets[i]             # <<<<<<<<<<<<<<
23050  *
23051  *     for i in range(offset):
23052  */
23053     (__pyx_v_mslice->suboffsets[(__pyx_v_i + __pyx_v_offset)]) = (__pyx_v_mslice->suboffsets[__pyx_v_i]);
23054   }
23055 
23056   /* "View.MemoryView":1351
23057  *         mslice.suboffsets[i + offset] = mslice.suboffsets[i]
23058  *
23059  *     for i in range(offset):             # <<<<<<<<<<<<<<
23060  *         mslice.shape[i] = 1
23061  *         mslice.strides[i] = mslice.strides[0]
23062  */
23063   __pyx_t_1 = __pyx_v_offset;
23064   __pyx_t_2 = __pyx_t_1;
23065   for (__pyx_t_3 = 0; __pyx_t_3 < __pyx_t_2; __pyx_t_3+=1) {
23066     __pyx_v_i = __pyx_t_3;
23067 
23068     /* "View.MemoryView":1352
23069  *
23070  *     for i in range(offset):
23071  *         mslice.shape[i] = 1             # <<<<<<<<<<<<<<
23072  *         mslice.strides[i] = mslice.strides[0]
23073  *         mslice.suboffsets[i] = -1
23074  */
23075     (__pyx_v_mslice->shape[__pyx_v_i]) = 1;
23076 
23077     /* "View.MemoryView":1353
23078  *     for i in range(offset):
23079  *         mslice.shape[i] = 1
23080  *         mslice.strides[i] = mslice.strides[0]             # <<<<<<<<<<<<<<
23081  *         mslice.suboffsets[i] = -1
23082  *
23083  */
23084     (__pyx_v_mslice->strides[__pyx_v_i]) = (__pyx_v_mslice->strides[0]);
23085 
23086     /* "View.MemoryView":1354
23087  *         mslice.shape[i] = 1
23088  *         mslice.strides[i] = mslice.strides[0]
23089  *         mslice.suboffsets[i] = -1             # <<<<<<<<<<<<<<
23090  *
23091  *
23092  */
23093     (__pyx_v_mslice->suboffsets[__pyx_v_i]) = -1L;
23094   }
23095 
23096   /* "View.MemoryView":1340
23097  *
23098  * @cname('__pyx_memoryview_broadcast_leading')
23099  * cdef void broadcast_leading(__Pyx_memviewslice *mslice,             # <<<<<<<<<<<<<<
23100  *                             int ndim,
23101  *                             int ndim_other) nogil:
23102  */
23103 
23104   /* function exit code */
23105 }
23106 
23107 /* "View.MemoryView":1362
23108  *
23109  * @cname('__pyx_memoryview_refcount_copying')
23110  * cdef void refcount_copying(__Pyx_memviewslice *dst, bint dtype_is_object,             # <<<<<<<<<<<<<<
23111  *                            int ndim, bint inc) nogil:
23112  *
23113  */
23114 
__pyx_memoryview_refcount_copying(__Pyx_memviewslice * __pyx_v_dst,int __pyx_v_dtype_is_object,int __pyx_v_ndim,int __pyx_v_inc)23115 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) {
23116   int __pyx_t_1;
23117 
23118   /* "View.MemoryView":1366
23119  *
23120  *
23121  *     if dtype_is_object:             # <<<<<<<<<<<<<<
23122  *         refcount_objects_in_slice_with_gil(dst.data, dst.shape,
23123  *                                            dst.strides, ndim, inc)
23124  */
23125   __pyx_t_1 = (__pyx_v_dtype_is_object != 0);
23126   if (__pyx_t_1) {
23127 
23128     /* "View.MemoryView":1367
23129  *
23130  *     if dtype_is_object:
23131  *         refcount_objects_in_slice_with_gil(dst.data, dst.shape,             # <<<<<<<<<<<<<<
23132  *                                            dst.strides, ndim, inc)
23133  *
23134  */
23135     __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);
23136 
23137     /* "View.MemoryView":1366
23138  *
23139  *
23140  *     if dtype_is_object:             # <<<<<<<<<<<<<<
23141  *         refcount_objects_in_slice_with_gil(dst.data, dst.shape,
23142  *                                            dst.strides, ndim, inc)
23143  */
23144   }
23145 
23146   /* "View.MemoryView":1362
23147  *
23148  * @cname('__pyx_memoryview_refcount_copying')
23149  * cdef void refcount_copying(__Pyx_memviewslice *dst, bint dtype_is_object,             # <<<<<<<<<<<<<<
23150  *                            int ndim, bint inc) nogil:
23151  *
23152  */
23153 
23154   /* function exit code */
23155 }
23156 
23157 /* "View.MemoryView":1371
23158  *
23159  * @cname('__pyx_memoryview_refcount_objects_in_slice_with_gil')
23160  * cdef void refcount_objects_in_slice_with_gil(char *data, Py_ssize_t *shape,             # <<<<<<<<<<<<<<
23161  *                                              Py_ssize_t *strides, int ndim,
23162  *                                              bint inc) with gil:
23163  */
23164 
__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)23165 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) {
23166   __Pyx_RefNannyDeclarations
23167   #ifdef WITH_THREAD
23168   PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure();
23169   #endif
23170   __Pyx_RefNannySetupContext("refcount_objects_in_slice_with_gil", 0);
23171 
23172   /* "View.MemoryView":1374
23173  *                                              Py_ssize_t *strides, int ndim,
23174  *                                              bint inc) with gil:
23175  *     refcount_objects_in_slice(data, shape, strides, ndim, inc)             # <<<<<<<<<<<<<<
23176  *
23177  * @cname('__pyx_memoryview_refcount_objects_in_slice')
23178  */
23179   __pyx_memoryview_refcount_objects_in_slice(__pyx_v_data, __pyx_v_shape, __pyx_v_strides, __pyx_v_ndim, __pyx_v_inc);
23180 
23181   /* "View.MemoryView":1371
23182  *
23183  * @cname('__pyx_memoryview_refcount_objects_in_slice_with_gil')
23184  * cdef void refcount_objects_in_slice_with_gil(char *data, Py_ssize_t *shape,             # <<<<<<<<<<<<<<
23185  *                                              Py_ssize_t *strides, int ndim,
23186  *                                              bint inc) with gil:
23187  */
23188 
23189   /* function exit code */
23190   __Pyx_RefNannyFinishContext();
23191   #ifdef WITH_THREAD
23192   __Pyx_PyGILState_Release(__pyx_gilstate_save);
23193   #endif
23194 }
23195 
23196 /* "View.MemoryView":1377
23197  *
23198  * @cname('__pyx_memoryview_refcount_objects_in_slice')
23199  * cdef void refcount_objects_in_slice(char *data, Py_ssize_t *shape,             # <<<<<<<<<<<<<<
23200  *                                     Py_ssize_t *strides, int ndim, bint inc):
23201  *     cdef Py_ssize_t i
23202  */
23203 
__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)23204 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) {
23205   CYTHON_UNUSED Py_ssize_t __pyx_v_i;
23206   __Pyx_RefNannyDeclarations
23207   Py_ssize_t __pyx_t_1;
23208   Py_ssize_t __pyx_t_2;
23209   Py_ssize_t __pyx_t_3;
23210   int __pyx_t_4;
23211   __Pyx_RefNannySetupContext("refcount_objects_in_slice", 0);
23212 
23213   /* "View.MemoryView":1381
23214  *     cdef Py_ssize_t i
23215  *
23216  *     for i in range(shape[0]):             # <<<<<<<<<<<<<<
23217  *         if ndim == 1:
23218  *             if inc:
23219  */
23220   __pyx_t_1 = (__pyx_v_shape[0]);
23221   __pyx_t_2 = __pyx_t_1;
23222   for (__pyx_t_3 = 0; __pyx_t_3 < __pyx_t_2; __pyx_t_3+=1) {
23223     __pyx_v_i = __pyx_t_3;
23224 
23225     /* "View.MemoryView":1382
23226  *
23227  *     for i in range(shape[0]):
23228  *         if ndim == 1:             # <<<<<<<<<<<<<<
23229  *             if inc:
23230  *                 Py_INCREF((<PyObject **> data)[0])
23231  */
23232     __pyx_t_4 = ((__pyx_v_ndim == 1) != 0);
23233     if (__pyx_t_4) {
23234 
23235       /* "View.MemoryView":1383
23236  *     for i in range(shape[0]):
23237  *         if ndim == 1:
23238  *             if inc:             # <<<<<<<<<<<<<<
23239  *                 Py_INCREF((<PyObject **> data)[0])
23240  *             else:
23241  */
23242       __pyx_t_4 = (__pyx_v_inc != 0);
23243       if (__pyx_t_4) {
23244 
23245         /* "View.MemoryView":1384
23246  *         if ndim == 1:
23247  *             if inc:
23248  *                 Py_INCREF((<PyObject **> data)[0])             # <<<<<<<<<<<<<<
23249  *             else:
23250  *                 Py_DECREF((<PyObject **> data)[0])
23251  */
23252         Py_INCREF((((PyObject **)__pyx_v_data)[0]));
23253 
23254         /* "View.MemoryView":1383
23255  *     for i in range(shape[0]):
23256  *         if ndim == 1:
23257  *             if inc:             # <<<<<<<<<<<<<<
23258  *                 Py_INCREF((<PyObject **> data)[0])
23259  *             else:
23260  */
23261         goto __pyx_L6;
23262       }
23263 
23264       /* "View.MemoryView":1386
23265  *                 Py_INCREF((<PyObject **> data)[0])
23266  *             else:
23267  *                 Py_DECREF((<PyObject **> data)[0])             # <<<<<<<<<<<<<<
23268  *         else:
23269  *             refcount_objects_in_slice(data, shape + 1, strides + 1,
23270  */
23271       /*else*/ {
23272         Py_DECREF((((PyObject **)__pyx_v_data)[0]));
23273       }
23274       __pyx_L6:;
23275 
23276       /* "View.MemoryView":1382
23277  *
23278  *     for i in range(shape[0]):
23279  *         if ndim == 1:             # <<<<<<<<<<<<<<
23280  *             if inc:
23281  *                 Py_INCREF((<PyObject **> data)[0])
23282  */
23283       goto __pyx_L5;
23284     }
23285 
23286     /* "View.MemoryView":1388
23287  *                 Py_DECREF((<PyObject **> data)[0])
23288  *         else:
23289  *             refcount_objects_in_slice(data, shape + 1, strides + 1,             # <<<<<<<<<<<<<<
23290  *                                       ndim - 1, inc)
23291  *
23292  */
23293     /*else*/ {
23294 
23295       /* "View.MemoryView":1389
23296  *         else:
23297  *             refcount_objects_in_slice(data, shape + 1, strides + 1,
23298  *                                       ndim - 1, inc)             # <<<<<<<<<<<<<<
23299  *
23300  *         data += strides[0]
23301  */
23302       __pyx_memoryview_refcount_objects_in_slice(__pyx_v_data, (__pyx_v_shape + 1), (__pyx_v_strides + 1), (__pyx_v_ndim - 1), __pyx_v_inc);
23303     }
23304     __pyx_L5:;
23305 
23306     /* "View.MemoryView":1391
23307  *                                       ndim - 1, inc)
23308  *
23309  *         data += strides[0]             # <<<<<<<<<<<<<<
23310  *
23311  *
23312  */
23313     __pyx_v_data = (__pyx_v_data + (__pyx_v_strides[0]));
23314   }
23315 
23316   /* "View.MemoryView":1377
23317  *
23318  * @cname('__pyx_memoryview_refcount_objects_in_slice')
23319  * cdef void refcount_objects_in_slice(char *data, Py_ssize_t *shape,             # <<<<<<<<<<<<<<
23320  *                                     Py_ssize_t *strides, int ndim, bint inc):
23321  *     cdef Py_ssize_t i
23322  */
23323 
23324   /* function exit code */
23325   __Pyx_RefNannyFinishContext();
23326 }
23327 
23328 /* "View.MemoryView":1397
23329  *
23330  * @cname('__pyx_memoryview_slice_assign_scalar')
23331  * cdef void slice_assign_scalar(__Pyx_memviewslice *dst, int ndim,             # <<<<<<<<<<<<<<
23332  *                               size_t itemsize, void *item,
23333  *                               bint dtype_is_object) nogil:
23334  */
23335 
__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)23336 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) {
23337 
23338   /* "View.MemoryView":1400
23339  *                               size_t itemsize, void *item,
23340  *                               bint dtype_is_object) nogil:
23341  *     refcount_copying(dst, dtype_is_object, ndim, False)             # <<<<<<<<<<<<<<
23342  *     _slice_assign_scalar(dst.data, dst.shape, dst.strides, ndim,
23343  *                          itemsize, item)
23344  */
23345   __pyx_memoryview_refcount_copying(__pyx_v_dst, __pyx_v_dtype_is_object, __pyx_v_ndim, 0);
23346 
23347   /* "View.MemoryView":1401
23348  *                               bint dtype_is_object) nogil:
23349  *     refcount_copying(dst, dtype_is_object, ndim, False)
23350  *     _slice_assign_scalar(dst.data, dst.shape, dst.strides, ndim,             # <<<<<<<<<<<<<<
23351  *                          itemsize, item)
23352  *     refcount_copying(dst, dtype_is_object, ndim, True)
23353  */
23354   __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);
23355 
23356   /* "View.MemoryView":1403
23357  *     _slice_assign_scalar(dst.data, dst.shape, dst.strides, ndim,
23358  *                          itemsize, item)
23359  *     refcount_copying(dst, dtype_is_object, ndim, True)             # <<<<<<<<<<<<<<
23360  *
23361  *
23362  */
23363   __pyx_memoryview_refcount_copying(__pyx_v_dst, __pyx_v_dtype_is_object, __pyx_v_ndim, 1);
23364 
23365   /* "View.MemoryView":1397
23366  *
23367  * @cname('__pyx_memoryview_slice_assign_scalar')
23368  * cdef void slice_assign_scalar(__Pyx_memviewslice *dst, int ndim,             # <<<<<<<<<<<<<<
23369  *                               size_t itemsize, void *item,
23370  *                               bint dtype_is_object) nogil:
23371  */
23372 
23373   /* function exit code */
23374 }
23375 
23376 /* "View.MemoryView":1407
23377  *
23378  * @cname('__pyx_memoryview__slice_assign_scalar')
23379  * cdef void _slice_assign_scalar(char *data, Py_ssize_t *shape,             # <<<<<<<<<<<<<<
23380  *                               Py_ssize_t *strides, int ndim,
23381  *                               size_t itemsize, void *item) nogil:
23382  */
23383 
__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)23384 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) {
23385   CYTHON_UNUSED Py_ssize_t __pyx_v_i;
23386   Py_ssize_t __pyx_v_stride;
23387   Py_ssize_t __pyx_v_extent;
23388   int __pyx_t_1;
23389   Py_ssize_t __pyx_t_2;
23390   Py_ssize_t __pyx_t_3;
23391   Py_ssize_t __pyx_t_4;
23392 
23393   /* "View.MemoryView":1411
23394  *                               size_t itemsize, void *item) nogil:
23395  *     cdef Py_ssize_t i
23396  *     cdef Py_ssize_t stride = strides[0]             # <<<<<<<<<<<<<<
23397  *     cdef Py_ssize_t extent = shape[0]
23398  *
23399  */
23400   __pyx_v_stride = (__pyx_v_strides[0]);
23401 
23402   /* "View.MemoryView":1412
23403  *     cdef Py_ssize_t i
23404  *     cdef Py_ssize_t stride = strides[0]
23405  *     cdef Py_ssize_t extent = shape[0]             # <<<<<<<<<<<<<<
23406  *
23407  *     if ndim == 1:
23408  */
23409   __pyx_v_extent = (__pyx_v_shape[0]);
23410 
23411   /* "View.MemoryView":1414
23412  *     cdef Py_ssize_t extent = shape[0]
23413  *
23414  *     if ndim == 1:             # <<<<<<<<<<<<<<
23415  *         for i in range(extent):
23416  *             memcpy(data, item, itemsize)
23417  */
23418   __pyx_t_1 = ((__pyx_v_ndim == 1) != 0);
23419   if (__pyx_t_1) {
23420 
23421     /* "View.MemoryView":1415
23422  *
23423  *     if ndim == 1:
23424  *         for i in range(extent):             # <<<<<<<<<<<<<<
23425  *             memcpy(data, item, itemsize)
23426  *             data += stride
23427  */
23428     __pyx_t_2 = __pyx_v_extent;
23429     __pyx_t_3 = __pyx_t_2;
23430     for (__pyx_t_4 = 0; __pyx_t_4 < __pyx_t_3; __pyx_t_4+=1) {
23431       __pyx_v_i = __pyx_t_4;
23432 
23433       /* "View.MemoryView":1416
23434  *     if ndim == 1:
23435  *         for i in range(extent):
23436  *             memcpy(data, item, itemsize)             # <<<<<<<<<<<<<<
23437  *             data += stride
23438  *     else:
23439  */
23440       (void)(memcpy(__pyx_v_data, __pyx_v_item, __pyx_v_itemsize));
23441 
23442       /* "View.MemoryView":1417
23443  *         for i in range(extent):
23444  *             memcpy(data, item, itemsize)
23445  *             data += stride             # <<<<<<<<<<<<<<
23446  *     else:
23447  *         for i in range(extent):
23448  */
23449       __pyx_v_data = (__pyx_v_data + __pyx_v_stride);
23450     }
23451 
23452     /* "View.MemoryView":1414
23453  *     cdef Py_ssize_t extent = shape[0]
23454  *
23455  *     if ndim == 1:             # <<<<<<<<<<<<<<
23456  *         for i in range(extent):
23457  *             memcpy(data, item, itemsize)
23458  */
23459     goto __pyx_L3;
23460   }
23461 
23462   /* "View.MemoryView":1419
23463  *             data += stride
23464  *     else:
23465  *         for i in range(extent):             # <<<<<<<<<<<<<<
23466  *             _slice_assign_scalar(data, shape + 1, strides + 1,
23467  *                                 ndim - 1, itemsize, item)
23468  */
23469   /*else*/ {
23470     __pyx_t_2 = __pyx_v_extent;
23471     __pyx_t_3 = __pyx_t_2;
23472     for (__pyx_t_4 = 0; __pyx_t_4 < __pyx_t_3; __pyx_t_4+=1) {
23473       __pyx_v_i = __pyx_t_4;
23474 
23475       /* "View.MemoryView":1420
23476  *     else:
23477  *         for i in range(extent):
23478  *             _slice_assign_scalar(data, shape + 1, strides + 1,             # <<<<<<<<<<<<<<
23479  *                                 ndim - 1, itemsize, item)
23480  *             data += stride
23481  */
23482       __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);
23483 
23484       /* "View.MemoryView":1422
23485  *             _slice_assign_scalar(data, shape + 1, strides + 1,
23486  *                                 ndim - 1, itemsize, item)
23487  *             data += stride             # <<<<<<<<<<<<<<
23488  *
23489  *
23490  */
23491       __pyx_v_data = (__pyx_v_data + __pyx_v_stride);
23492     }
23493   }
23494   __pyx_L3:;
23495 
23496   /* "View.MemoryView":1407
23497  *
23498  * @cname('__pyx_memoryview__slice_assign_scalar')
23499  * cdef void _slice_assign_scalar(char *data, Py_ssize_t *shape,             # <<<<<<<<<<<<<<
23500  *                               Py_ssize_t *strides, int ndim,
23501  *                               size_t itemsize, void *item) nogil:
23502  */
23503 
23504   /* function exit code */
23505 }
23506 
23507 /* "(tree fragment)":1
23508  * def __pyx_unpickle_Enum(__pyx_type, long __pyx_checksum, __pyx_state):             # <<<<<<<<<<<<<<
23509  *     cdef object __pyx_PickleError
23510  *     cdef object __pyx_result
23511  */
23512 
23513 /* Python wrapper */
23514 static PyObject *__pyx_pw_15View_dot_MemoryView_1__pyx_unpickle_Enum(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
23515 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)23516 static PyObject *__pyx_pw_15View_dot_MemoryView_1__pyx_unpickle_Enum(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
23517   PyObject *__pyx_v___pyx_type = 0;
23518   long __pyx_v___pyx_checksum;
23519   PyObject *__pyx_v___pyx_state = 0;
23520   int __pyx_lineno = 0;
23521   const char *__pyx_filename = NULL;
23522   int __pyx_clineno = 0;
23523   PyObject *__pyx_r = 0;
23524   __Pyx_RefNannyDeclarations
23525   __Pyx_RefNannySetupContext("__pyx_unpickle_Enum (wrapper)", 0);
23526   {
23527     static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_pyx_type,&__pyx_n_s_pyx_checksum,&__pyx_n_s_pyx_state,0};
23528     PyObject* values[3] = {0,0,0};
23529     if (unlikely(__pyx_kwds)) {
23530       Py_ssize_t kw_args;
23531       const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
23532       switch (pos_args) {
23533         case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
23534         CYTHON_FALLTHROUGH;
23535         case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
23536         CYTHON_FALLTHROUGH;
23537         case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
23538         CYTHON_FALLTHROUGH;
23539         case  0: break;
23540         default: goto __pyx_L5_argtuple_error;
23541       }
23542       kw_args = PyDict_Size(__pyx_kwds);
23543       switch (pos_args) {
23544         case  0:
23545         if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_pyx_type)) != 0)) kw_args--;
23546         else goto __pyx_L5_argtuple_error;
23547         CYTHON_FALLTHROUGH;
23548         case  1:
23549         if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_pyx_checksum)) != 0)) kw_args--;
23550         else {
23551           __Pyx_RaiseArgtupleInvalid("__pyx_unpickle_Enum", 1, 3, 3, 1); __PYX_ERR(3, 1, __pyx_L3_error)
23552         }
23553         CYTHON_FALLTHROUGH;
23554         case  2:
23555         if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_pyx_state)) != 0)) kw_args--;
23556         else {
23557           __Pyx_RaiseArgtupleInvalid("__pyx_unpickle_Enum", 1, 3, 3, 2); __PYX_ERR(3, 1, __pyx_L3_error)
23558         }
23559       }
23560       if (unlikely(kw_args > 0)) {
23561         if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__pyx_unpickle_Enum") < 0)) __PYX_ERR(3, 1, __pyx_L3_error)
23562       }
23563     } else if (PyTuple_GET_SIZE(__pyx_args) != 3) {
23564       goto __pyx_L5_argtuple_error;
23565     } else {
23566       values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
23567       values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
23568       values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
23569     }
23570     __pyx_v___pyx_type = values[0];
23571     __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)
23572     __pyx_v___pyx_state = values[2];
23573   }
23574   goto __pyx_L4_argument_unpacking_done;
23575   __pyx_L5_argtuple_error:;
23576   __Pyx_RaiseArgtupleInvalid("__pyx_unpickle_Enum", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(3, 1, __pyx_L3_error)
23577   __pyx_L3_error:;
23578   __Pyx_AddTraceback("View.MemoryView.__pyx_unpickle_Enum", __pyx_clineno, __pyx_lineno, __pyx_filename);
23579   __Pyx_RefNannyFinishContext();
23580   return NULL;
23581   __pyx_L4_argument_unpacking_done:;
23582   __pyx_r = __pyx_pf_15View_dot_MemoryView___pyx_unpickle_Enum(__pyx_self, __pyx_v___pyx_type, __pyx_v___pyx_checksum, __pyx_v___pyx_state);
23583 
23584   /* function exit code */
23585   __Pyx_RefNannyFinishContext();
23586   return __pyx_r;
23587 }
23588 
__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)23589 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) {
23590   PyObject *__pyx_v___pyx_PickleError = 0;
23591   PyObject *__pyx_v___pyx_result = 0;
23592   PyObject *__pyx_r = NULL;
23593   __Pyx_RefNannyDeclarations
23594   int __pyx_t_1;
23595   PyObject *__pyx_t_2 = NULL;
23596   PyObject *__pyx_t_3 = NULL;
23597   PyObject *__pyx_t_4 = NULL;
23598   PyObject *__pyx_t_5 = NULL;
23599   int __pyx_t_6;
23600   int __pyx_lineno = 0;
23601   const char *__pyx_filename = NULL;
23602   int __pyx_clineno = 0;
23603   __Pyx_RefNannySetupContext("__pyx_unpickle_Enum", 0);
23604 
23605   /* "(tree fragment)":4
23606  *     cdef object __pyx_PickleError
23607  *     cdef object __pyx_result
23608  *     if __pyx_checksum != 0xb068931:             # <<<<<<<<<<<<<<
23609  *         from pickle import PickleError as __pyx_PickleError
23610  *         raise __pyx_PickleError("Incompatible checksums (%s vs 0xb068931 = (name))" % __pyx_checksum)
23611  */
23612   __pyx_t_1 = ((__pyx_v___pyx_checksum != 0xb068931) != 0);
23613   if (__pyx_t_1) {
23614 
23615     /* "(tree fragment)":5
23616  *     cdef object __pyx_result
23617  *     if __pyx_checksum != 0xb068931:
23618  *         from pickle import PickleError as __pyx_PickleError             # <<<<<<<<<<<<<<
23619  *         raise __pyx_PickleError("Incompatible checksums (%s vs 0xb068931 = (name))" % __pyx_checksum)
23620  *     __pyx_result = Enum.__new__(__pyx_type)
23621  */
23622     __pyx_t_2 = PyList_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(3, 5, __pyx_L1_error)
23623     __Pyx_GOTREF(__pyx_t_2);
23624     __Pyx_INCREF(__pyx_n_s_PickleError);
23625     __Pyx_GIVEREF(__pyx_n_s_PickleError);
23626     PyList_SET_ITEM(__pyx_t_2, 0, __pyx_n_s_PickleError);
23627     __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)
23628     __Pyx_GOTREF(__pyx_t_3);
23629     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
23630     __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_3, __pyx_n_s_PickleError); if (unlikely(!__pyx_t_2)) __PYX_ERR(3, 5, __pyx_L1_error)
23631     __Pyx_GOTREF(__pyx_t_2);
23632     __Pyx_INCREF(__pyx_t_2);
23633     __pyx_v___pyx_PickleError = __pyx_t_2;
23634     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
23635     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
23636 
23637     /* "(tree fragment)":6
23638  *     if __pyx_checksum != 0xb068931:
23639  *         from pickle import PickleError as __pyx_PickleError
23640  *         raise __pyx_PickleError("Incompatible checksums (%s vs 0xb068931 = (name))" % __pyx_checksum)             # <<<<<<<<<<<<<<
23641  *     __pyx_result = Enum.__new__(__pyx_type)
23642  *     if __pyx_state is not None:
23643  */
23644     __pyx_t_2 = __Pyx_PyInt_From_long(__pyx_v___pyx_checksum); if (unlikely(!__pyx_t_2)) __PYX_ERR(3, 6, __pyx_L1_error)
23645     __Pyx_GOTREF(__pyx_t_2);
23646     __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)
23647     __Pyx_GOTREF(__pyx_t_4);
23648     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
23649     __Pyx_INCREF(__pyx_v___pyx_PickleError);
23650     __pyx_t_2 = __pyx_v___pyx_PickleError; __pyx_t_5 = NULL;
23651     if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) {
23652       __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_2);
23653       if (likely(__pyx_t_5)) {
23654         PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
23655         __Pyx_INCREF(__pyx_t_5);
23656         __Pyx_INCREF(function);
23657         __Pyx_DECREF_SET(__pyx_t_2, function);
23658       }
23659     }
23660     __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);
23661     __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
23662     __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
23663     if (unlikely(!__pyx_t_3)) __PYX_ERR(3, 6, __pyx_L1_error)
23664     __Pyx_GOTREF(__pyx_t_3);
23665     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
23666     __Pyx_Raise(__pyx_t_3, 0, 0, 0);
23667     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
23668     __PYX_ERR(3, 6, __pyx_L1_error)
23669 
23670     /* "(tree fragment)":4
23671  *     cdef object __pyx_PickleError
23672  *     cdef object __pyx_result
23673  *     if __pyx_checksum != 0xb068931:             # <<<<<<<<<<<<<<
23674  *         from pickle import PickleError as __pyx_PickleError
23675  *         raise __pyx_PickleError("Incompatible checksums (%s vs 0xb068931 = (name))" % __pyx_checksum)
23676  */
23677   }
23678 
23679   /* "(tree fragment)":7
23680  *         from pickle import PickleError as __pyx_PickleError
23681  *         raise __pyx_PickleError("Incompatible checksums (%s vs 0xb068931 = (name))" % __pyx_checksum)
23682  *     __pyx_result = Enum.__new__(__pyx_type)             # <<<<<<<<<<<<<<
23683  *     if __pyx_state is not None:
23684  *         __pyx_unpickle_Enum__set_state(<Enum> __pyx_result, __pyx_state)
23685  */
23686   __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)
23687   __Pyx_GOTREF(__pyx_t_2);
23688   __pyx_t_4 = NULL;
23689   if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
23690     __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_2);
23691     if (likely(__pyx_t_4)) {
23692       PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
23693       __Pyx_INCREF(__pyx_t_4);
23694       __Pyx_INCREF(function);
23695       __Pyx_DECREF_SET(__pyx_t_2, function);
23696     }
23697   }
23698   __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);
23699   __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
23700   if (unlikely(!__pyx_t_3)) __PYX_ERR(3, 7, __pyx_L1_error)
23701   __Pyx_GOTREF(__pyx_t_3);
23702   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
23703   __pyx_v___pyx_result = __pyx_t_3;
23704   __pyx_t_3 = 0;
23705 
23706   /* "(tree fragment)":8
23707  *         raise __pyx_PickleError("Incompatible checksums (%s vs 0xb068931 = (name))" % __pyx_checksum)
23708  *     __pyx_result = Enum.__new__(__pyx_type)
23709  *     if __pyx_state is not None:             # <<<<<<<<<<<<<<
23710  *         __pyx_unpickle_Enum__set_state(<Enum> __pyx_result, __pyx_state)
23711  *     return __pyx_result
23712  */
23713   __pyx_t_1 = (__pyx_v___pyx_state != Py_None);
23714   __pyx_t_6 = (__pyx_t_1 != 0);
23715   if (__pyx_t_6) {
23716 
23717     /* "(tree fragment)":9
23718  *     __pyx_result = Enum.__new__(__pyx_type)
23719  *     if __pyx_state is not None:
23720  *         __pyx_unpickle_Enum__set_state(<Enum> __pyx_result, __pyx_state)             # <<<<<<<<<<<<<<
23721  *     return __pyx_result
23722  * cdef __pyx_unpickle_Enum__set_state(Enum __pyx_result, tuple __pyx_state):
23723  */
23724     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)
23725     __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)
23726     __Pyx_GOTREF(__pyx_t_3);
23727     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
23728 
23729     /* "(tree fragment)":8
23730  *         raise __pyx_PickleError("Incompatible checksums (%s vs 0xb068931 = (name))" % __pyx_checksum)
23731  *     __pyx_result = Enum.__new__(__pyx_type)
23732  *     if __pyx_state is not None:             # <<<<<<<<<<<<<<
23733  *         __pyx_unpickle_Enum__set_state(<Enum> __pyx_result, __pyx_state)
23734  *     return __pyx_result
23735  */
23736   }
23737 
23738   /* "(tree fragment)":10
23739  *     if __pyx_state is not None:
23740  *         __pyx_unpickle_Enum__set_state(<Enum> __pyx_result, __pyx_state)
23741  *     return __pyx_result             # <<<<<<<<<<<<<<
23742  * cdef __pyx_unpickle_Enum__set_state(Enum __pyx_result, tuple __pyx_state):
23743  *     __pyx_result.name = __pyx_state[0]
23744  */
23745   __Pyx_XDECREF(__pyx_r);
23746   __Pyx_INCREF(__pyx_v___pyx_result);
23747   __pyx_r = __pyx_v___pyx_result;
23748   goto __pyx_L0;
23749 
23750   /* "(tree fragment)":1
23751  * def __pyx_unpickle_Enum(__pyx_type, long __pyx_checksum, __pyx_state):             # <<<<<<<<<<<<<<
23752  *     cdef object __pyx_PickleError
23753  *     cdef object __pyx_result
23754  */
23755 
23756   /* function exit code */
23757   __pyx_L1_error:;
23758   __Pyx_XDECREF(__pyx_t_2);
23759   __Pyx_XDECREF(__pyx_t_3);
23760   __Pyx_XDECREF(__pyx_t_4);
23761   __Pyx_XDECREF(__pyx_t_5);
23762   __Pyx_AddTraceback("View.MemoryView.__pyx_unpickle_Enum", __pyx_clineno, __pyx_lineno, __pyx_filename);
23763   __pyx_r = NULL;
23764   __pyx_L0:;
23765   __Pyx_XDECREF(__pyx_v___pyx_PickleError);
23766   __Pyx_XDECREF(__pyx_v___pyx_result);
23767   __Pyx_XGIVEREF(__pyx_r);
23768   __Pyx_RefNannyFinishContext();
23769   return __pyx_r;
23770 }
23771 
23772 /* "(tree fragment)":11
23773  *         __pyx_unpickle_Enum__set_state(<Enum> __pyx_result, __pyx_state)
23774  *     return __pyx_result
23775  * cdef __pyx_unpickle_Enum__set_state(Enum __pyx_result, tuple __pyx_state):             # <<<<<<<<<<<<<<
23776  *     __pyx_result.name = __pyx_state[0]
23777  *     if len(__pyx_state) > 1 and hasattr(__pyx_result, '__dict__'):
23778  */
23779 
__pyx_unpickle_Enum__set_state(struct __pyx_MemviewEnum_obj * __pyx_v___pyx_result,PyObject * __pyx_v___pyx_state)23780 static PyObject *__pyx_unpickle_Enum__set_state(struct __pyx_MemviewEnum_obj *__pyx_v___pyx_result, PyObject *__pyx_v___pyx_state) {
23781   PyObject *__pyx_r = NULL;
23782   __Pyx_RefNannyDeclarations
23783   PyObject *__pyx_t_1 = NULL;
23784   int __pyx_t_2;
23785   Py_ssize_t __pyx_t_3;
23786   int __pyx_t_4;
23787   int __pyx_t_5;
23788   PyObject *__pyx_t_6 = NULL;
23789   PyObject *__pyx_t_7 = NULL;
23790   PyObject *__pyx_t_8 = NULL;
23791   int __pyx_lineno = 0;
23792   const char *__pyx_filename = NULL;
23793   int __pyx_clineno = 0;
23794   __Pyx_RefNannySetupContext("__pyx_unpickle_Enum__set_state", 0);
23795 
23796   /* "(tree fragment)":12
23797  *     return __pyx_result
23798  * cdef __pyx_unpickle_Enum__set_state(Enum __pyx_result, tuple __pyx_state):
23799  *     __pyx_result.name = __pyx_state[0]             # <<<<<<<<<<<<<<
23800  *     if len(__pyx_state) > 1 and hasattr(__pyx_result, '__dict__'):
23801  *         __pyx_result.__dict__.update(__pyx_state[1])
23802  */
23803   if (unlikely(__pyx_v___pyx_state == Py_None)) {
23804     PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
23805     __PYX_ERR(3, 12, __pyx_L1_error)
23806   }
23807   __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)
23808   __Pyx_GOTREF(__pyx_t_1);
23809   __Pyx_GIVEREF(__pyx_t_1);
23810   __Pyx_GOTREF(__pyx_v___pyx_result->name);
23811   __Pyx_DECREF(__pyx_v___pyx_result->name);
23812   __pyx_v___pyx_result->name = __pyx_t_1;
23813   __pyx_t_1 = 0;
23814 
23815   /* "(tree fragment)":13
23816  * cdef __pyx_unpickle_Enum__set_state(Enum __pyx_result, tuple __pyx_state):
23817  *     __pyx_result.name = __pyx_state[0]
23818  *     if len(__pyx_state) > 1 and hasattr(__pyx_result, '__dict__'):             # <<<<<<<<<<<<<<
23819  *         __pyx_result.__dict__.update(__pyx_state[1])
23820  */
23821   if (unlikely(__pyx_v___pyx_state == Py_None)) {
23822     PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
23823     __PYX_ERR(3, 13, __pyx_L1_error)
23824   }
23825   __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)
23826   __pyx_t_4 = ((__pyx_t_3 > 1) != 0);
23827   if (__pyx_t_4) {
23828   } else {
23829     __pyx_t_2 = __pyx_t_4;
23830     goto __pyx_L4_bool_binop_done;
23831   }
23832   __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)
23833   __pyx_t_5 = (__pyx_t_4 != 0);
23834   __pyx_t_2 = __pyx_t_5;
23835   __pyx_L4_bool_binop_done:;
23836   if (__pyx_t_2) {
23837 
23838     /* "(tree fragment)":14
23839  *     __pyx_result.name = __pyx_state[0]
23840  *     if len(__pyx_state) > 1 and hasattr(__pyx_result, '__dict__'):
23841  *         __pyx_result.__dict__.update(__pyx_state[1])             # <<<<<<<<<<<<<<
23842  */
23843     __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)
23844     __Pyx_GOTREF(__pyx_t_6);
23845     __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)
23846     __Pyx_GOTREF(__pyx_t_7);
23847     __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
23848     if (unlikely(__pyx_v___pyx_state == Py_None)) {
23849       PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
23850       __PYX_ERR(3, 14, __pyx_L1_error)
23851     }
23852     __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)
23853     __Pyx_GOTREF(__pyx_t_6);
23854     __pyx_t_8 = NULL;
23855     if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_7))) {
23856       __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_7);
23857       if (likely(__pyx_t_8)) {
23858         PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7);
23859         __Pyx_INCREF(__pyx_t_8);
23860         __Pyx_INCREF(function);
23861         __Pyx_DECREF_SET(__pyx_t_7, function);
23862       }
23863     }
23864     __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);
23865     __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
23866     __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
23867     if (unlikely(!__pyx_t_1)) __PYX_ERR(3, 14, __pyx_L1_error)
23868     __Pyx_GOTREF(__pyx_t_1);
23869     __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
23870     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
23871 
23872     /* "(tree fragment)":13
23873  * cdef __pyx_unpickle_Enum__set_state(Enum __pyx_result, tuple __pyx_state):
23874  *     __pyx_result.name = __pyx_state[0]
23875  *     if len(__pyx_state) > 1 and hasattr(__pyx_result, '__dict__'):             # <<<<<<<<<<<<<<
23876  *         __pyx_result.__dict__.update(__pyx_state[1])
23877  */
23878   }
23879 
23880   /* "(tree fragment)":11
23881  *         __pyx_unpickle_Enum__set_state(<Enum> __pyx_result, __pyx_state)
23882  *     return __pyx_result
23883  * cdef __pyx_unpickle_Enum__set_state(Enum __pyx_result, tuple __pyx_state):             # <<<<<<<<<<<<<<
23884  *     __pyx_result.name = __pyx_state[0]
23885  *     if len(__pyx_state) > 1 and hasattr(__pyx_result, '__dict__'):
23886  */
23887 
23888   /* function exit code */
23889   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
23890   goto __pyx_L0;
23891   __pyx_L1_error:;
23892   __Pyx_XDECREF(__pyx_t_1);
23893   __Pyx_XDECREF(__pyx_t_6);
23894   __Pyx_XDECREF(__pyx_t_7);
23895   __Pyx_XDECREF(__pyx_t_8);
23896   __Pyx_AddTraceback("View.MemoryView.__pyx_unpickle_Enum__set_state", __pyx_clineno, __pyx_lineno, __pyx_filename);
23897   __pyx_r = 0;
23898   __pyx_L0:;
23899   __Pyx_XGIVEREF(__pyx_r);
23900   __Pyx_RefNannyFinishContext();
23901   return __pyx_r;
23902 }
23903 static struct __pyx_vtabstruct_array __pyx_vtable_array;
23904 
__pyx_tp_new_array(PyTypeObject * t,PyObject * a,PyObject * k)23905 static PyObject *__pyx_tp_new_array(PyTypeObject *t, PyObject *a, PyObject *k) {
23906   struct __pyx_array_obj *p;
23907   PyObject *o;
23908   if (likely((t->tp_flags & Py_TPFLAGS_IS_ABSTRACT) == 0)) {
23909     o = (*t->tp_alloc)(t, 0);
23910   } else {
23911     o = (PyObject *) PyBaseObject_Type.tp_new(t, __pyx_empty_tuple, 0);
23912   }
23913   if (unlikely(!o)) return 0;
23914   p = ((struct __pyx_array_obj *)o);
23915   p->__pyx_vtab = __pyx_vtabptr_array;
23916   p->mode = ((PyObject*)Py_None); Py_INCREF(Py_None);
23917   p->_format = ((PyObject*)Py_None); Py_INCREF(Py_None);
23918   if (unlikely(__pyx_array___cinit__(o, a, k) < 0)) goto bad;
23919   return o;
23920   bad:
23921   Py_DECREF(o); o = 0;
23922   return NULL;
23923 }
23924 
__pyx_tp_dealloc_array(PyObject * o)23925 static void __pyx_tp_dealloc_array(PyObject *o) {
23926   struct __pyx_array_obj *p = (struct __pyx_array_obj *)o;
23927   #if CYTHON_USE_TP_FINALIZE
23928   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))) {
23929     if (PyObject_CallFinalizerFromDealloc(o)) return;
23930   }
23931   #endif
23932   {
23933     PyObject *etype, *eval, *etb;
23934     PyErr_Fetch(&etype, &eval, &etb);
23935     __Pyx_SET_REFCNT(o, Py_REFCNT(o) + 1);
23936     __pyx_array___dealloc__(o);
23937     __Pyx_SET_REFCNT(o, Py_REFCNT(o) - 1);
23938     PyErr_Restore(etype, eval, etb);
23939   }
23940   Py_CLEAR(p->mode);
23941   Py_CLEAR(p->_format);
23942   (*Py_TYPE(o)->tp_free)(o);
23943 }
__pyx_sq_item_array(PyObject * o,Py_ssize_t i)23944 static PyObject *__pyx_sq_item_array(PyObject *o, Py_ssize_t i) {
23945   PyObject *r;
23946   PyObject *x = PyInt_FromSsize_t(i); if(!x) return 0;
23947   r = Py_TYPE(o)->tp_as_mapping->mp_subscript(o, x);
23948   Py_DECREF(x);
23949   return r;
23950 }
23951 
__pyx_mp_ass_subscript_array(PyObject * o,PyObject * i,PyObject * v)23952 static int __pyx_mp_ass_subscript_array(PyObject *o, PyObject *i, PyObject *v) {
23953   if (v) {
23954     return __pyx_array___setitem__(o, i, v);
23955   }
23956   else {
23957     PyErr_Format(PyExc_NotImplementedError,
23958       "Subscript deletion not supported by %.200s", Py_TYPE(o)->tp_name);
23959     return -1;
23960   }
23961 }
23962 
__pyx_tp_getattro_array(PyObject * o,PyObject * n)23963 static PyObject *__pyx_tp_getattro_array(PyObject *o, PyObject *n) {
23964   PyObject *v = __Pyx_PyObject_GenericGetAttr(o, n);
23965   if (!v && PyErr_ExceptionMatches(PyExc_AttributeError)) {
23966     PyErr_Clear();
23967     v = __pyx_array___getattr__(o, n);
23968   }
23969   return v;
23970 }
23971 
__pyx_getprop___pyx_array_memview(PyObject * o,CYTHON_UNUSED void * x)23972 static PyObject *__pyx_getprop___pyx_array_memview(PyObject *o, CYTHON_UNUSED void *x) {
23973   return __pyx_pw_15View_dot_MemoryView_5array_7memview_1__get__(o);
23974 }
23975 
23976 static PyMethodDef __pyx_methods_array[] = {
23977   {"__getattr__", (PyCFunction)__pyx_array___getattr__, METH_O|METH_COEXIST, 0},
23978   {"__reduce_cython__", (PyCFunction)__pyx_pw___pyx_array_1__reduce_cython__, METH_NOARGS, 0},
23979   {"__setstate_cython__", (PyCFunction)__pyx_pw___pyx_array_3__setstate_cython__, METH_O, 0},
23980   {0, 0, 0, 0}
23981 };
23982 
23983 static struct PyGetSetDef __pyx_getsets_array[] = {
23984   {(char *)"memview", __pyx_getprop___pyx_array_memview, 0, (char *)0, 0},
23985   {0, 0, 0, 0, 0}
23986 };
23987 
23988 static PySequenceMethods __pyx_tp_as_sequence_array = {
23989   __pyx_array___len__, /*sq_length*/
23990   0, /*sq_concat*/
23991   0, /*sq_repeat*/
23992   __pyx_sq_item_array, /*sq_item*/
23993   0, /*sq_slice*/
23994   0, /*sq_ass_item*/
23995   0, /*sq_ass_slice*/
23996   0, /*sq_contains*/
23997   0, /*sq_inplace_concat*/
23998   0, /*sq_inplace_repeat*/
23999 };
24000 
24001 static PyMappingMethods __pyx_tp_as_mapping_array = {
24002   __pyx_array___len__, /*mp_length*/
24003   __pyx_array___getitem__, /*mp_subscript*/
24004   __pyx_mp_ass_subscript_array, /*mp_ass_subscript*/
24005 };
24006 
24007 static PyBufferProcs __pyx_tp_as_buffer_array = {
24008   #if PY_MAJOR_VERSION < 3
24009   0, /*bf_getreadbuffer*/
24010   #endif
24011   #if PY_MAJOR_VERSION < 3
24012   0, /*bf_getwritebuffer*/
24013   #endif
24014   #if PY_MAJOR_VERSION < 3
24015   0, /*bf_getsegcount*/
24016   #endif
24017   #if PY_MAJOR_VERSION < 3
24018   0, /*bf_getcharbuffer*/
24019   #endif
24020   __pyx_array_getbuffer, /*bf_getbuffer*/
24021   0, /*bf_releasebuffer*/
24022 };
24023 
24024 static PyTypeObject __pyx_type___pyx_array = {
24025   PyVarObject_HEAD_INIT(0, 0)
24026   "qutip.cy.br_tensor.array", /*tp_name*/
24027   sizeof(struct __pyx_array_obj), /*tp_basicsize*/
24028   0, /*tp_itemsize*/
24029   __pyx_tp_dealloc_array, /*tp_dealloc*/
24030   #if PY_VERSION_HEX < 0x030800b4
24031   0, /*tp_print*/
24032   #endif
24033   #if PY_VERSION_HEX >= 0x030800b4
24034   0, /*tp_vectorcall_offset*/
24035   #endif
24036   0, /*tp_getattr*/
24037   0, /*tp_setattr*/
24038   #if PY_MAJOR_VERSION < 3
24039   0, /*tp_compare*/
24040   #endif
24041   #if PY_MAJOR_VERSION >= 3
24042   0, /*tp_as_async*/
24043   #endif
24044   0, /*tp_repr*/
24045   0, /*tp_as_number*/
24046   &__pyx_tp_as_sequence_array, /*tp_as_sequence*/
24047   &__pyx_tp_as_mapping_array, /*tp_as_mapping*/
24048   0, /*tp_hash*/
24049   0, /*tp_call*/
24050   0, /*tp_str*/
24051   __pyx_tp_getattro_array, /*tp_getattro*/
24052   0, /*tp_setattro*/
24053   &__pyx_tp_as_buffer_array, /*tp_as_buffer*/
24054   Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE, /*tp_flags*/
24055   0, /*tp_doc*/
24056   0, /*tp_traverse*/
24057   0, /*tp_clear*/
24058   0, /*tp_richcompare*/
24059   0, /*tp_weaklistoffset*/
24060   0, /*tp_iter*/
24061   0, /*tp_iternext*/
24062   __pyx_methods_array, /*tp_methods*/
24063   0, /*tp_members*/
24064   __pyx_getsets_array, /*tp_getset*/
24065   0, /*tp_base*/
24066   0, /*tp_dict*/
24067   0, /*tp_descr_get*/
24068   0, /*tp_descr_set*/
24069   0, /*tp_dictoffset*/
24070   0, /*tp_init*/
24071   0, /*tp_alloc*/
24072   __pyx_tp_new_array, /*tp_new*/
24073   0, /*tp_free*/
24074   0, /*tp_is_gc*/
24075   0, /*tp_bases*/
24076   0, /*tp_mro*/
24077   0, /*tp_cache*/
24078   0, /*tp_subclasses*/
24079   0, /*tp_weaklist*/
24080   0, /*tp_del*/
24081   0, /*tp_version_tag*/
24082   #if PY_VERSION_HEX >= 0x030400a1
24083   0, /*tp_finalize*/
24084   #endif
24085   #if PY_VERSION_HEX >= 0x030800b1
24086   0, /*tp_vectorcall*/
24087   #endif
24088   #if PY_VERSION_HEX >= 0x030800b4 && PY_VERSION_HEX < 0x03090000
24089   0, /*tp_print*/
24090   #endif
24091 };
24092 
__pyx_tp_new_Enum(PyTypeObject * t,CYTHON_UNUSED PyObject * a,CYTHON_UNUSED PyObject * k)24093 static PyObject *__pyx_tp_new_Enum(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
24094   struct __pyx_MemviewEnum_obj *p;
24095   PyObject *o;
24096   if (likely((t->tp_flags & Py_TPFLAGS_IS_ABSTRACT) == 0)) {
24097     o = (*t->tp_alloc)(t, 0);
24098   } else {
24099     o = (PyObject *) PyBaseObject_Type.tp_new(t, __pyx_empty_tuple, 0);
24100   }
24101   if (unlikely(!o)) return 0;
24102   p = ((struct __pyx_MemviewEnum_obj *)o);
24103   p->name = Py_None; Py_INCREF(Py_None);
24104   return o;
24105 }
24106 
__pyx_tp_dealloc_Enum(PyObject * o)24107 static void __pyx_tp_dealloc_Enum(PyObject *o) {
24108   struct __pyx_MemviewEnum_obj *p = (struct __pyx_MemviewEnum_obj *)o;
24109   #if CYTHON_USE_TP_FINALIZE
24110   if (unlikely(PyType_HasFeature(Py_TYPE(o), Py_TPFLAGS_HAVE_FINALIZE) && Py_TYPE(o)->tp_finalize) && !_PyGC_FINALIZED(o)) {
24111     if (PyObject_CallFinalizerFromDealloc(o)) return;
24112   }
24113   #endif
24114   PyObject_GC_UnTrack(o);
24115   Py_CLEAR(p->name);
24116   (*Py_TYPE(o)->tp_free)(o);
24117 }
24118 
__pyx_tp_traverse_Enum(PyObject * o,visitproc v,void * a)24119 static int __pyx_tp_traverse_Enum(PyObject *o, visitproc v, void *a) {
24120   int e;
24121   struct __pyx_MemviewEnum_obj *p = (struct __pyx_MemviewEnum_obj *)o;
24122   if (p->name) {
24123     e = (*v)(p->name, a); if (e) return e;
24124   }
24125   return 0;
24126 }
24127 
__pyx_tp_clear_Enum(PyObject * o)24128 static int __pyx_tp_clear_Enum(PyObject *o) {
24129   PyObject* tmp;
24130   struct __pyx_MemviewEnum_obj *p = (struct __pyx_MemviewEnum_obj *)o;
24131   tmp = ((PyObject*)p->name);
24132   p->name = Py_None; Py_INCREF(Py_None);
24133   Py_XDECREF(tmp);
24134   return 0;
24135 }
24136 
24137 static PyMethodDef __pyx_methods_Enum[] = {
24138   {"__reduce_cython__", (PyCFunction)__pyx_pw___pyx_MemviewEnum_1__reduce_cython__, METH_NOARGS, 0},
24139   {"__setstate_cython__", (PyCFunction)__pyx_pw___pyx_MemviewEnum_3__setstate_cython__, METH_O, 0},
24140   {0, 0, 0, 0}
24141 };
24142 
24143 static PyTypeObject __pyx_type___pyx_MemviewEnum = {
24144   PyVarObject_HEAD_INIT(0, 0)
24145   "qutip.cy.br_tensor.Enum", /*tp_name*/
24146   sizeof(struct __pyx_MemviewEnum_obj), /*tp_basicsize*/
24147   0, /*tp_itemsize*/
24148   __pyx_tp_dealloc_Enum, /*tp_dealloc*/
24149   #if PY_VERSION_HEX < 0x030800b4
24150   0, /*tp_print*/
24151   #endif
24152   #if PY_VERSION_HEX >= 0x030800b4
24153   0, /*tp_vectorcall_offset*/
24154   #endif
24155   0, /*tp_getattr*/
24156   0, /*tp_setattr*/
24157   #if PY_MAJOR_VERSION < 3
24158   0, /*tp_compare*/
24159   #endif
24160   #if PY_MAJOR_VERSION >= 3
24161   0, /*tp_as_async*/
24162   #endif
24163   __pyx_MemviewEnum___repr__, /*tp_repr*/
24164   0, /*tp_as_number*/
24165   0, /*tp_as_sequence*/
24166   0, /*tp_as_mapping*/
24167   0, /*tp_hash*/
24168   0, /*tp_call*/
24169   0, /*tp_str*/
24170   0, /*tp_getattro*/
24171   0, /*tp_setattro*/
24172   0, /*tp_as_buffer*/
24173   Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
24174   0, /*tp_doc*/
24175   __pyx_tp_traverse_Enum, /*tp_traverse*/
24176   __pyx_tp_clear_Enum, /*tp_clear*/
24177   0, /*tp_richcompare*/
24178   0, /*tp_weaklistoffset*/
24179   0, /*tp_iter*/
24180   0, /*tp_iternext*/
24181   __pyx_methods_Enum, /*tp_methods*/
24182   0, /*tp_members*/
24183   0, /*tp_getset*/
24184   0, /*tp_base*/
24185   0, /*tp_dict*/
24186   0, /*tp_descr_get*/
24187   0, /*tp_descr_set*/
24188   0, /*tp_dictoffset*/
24189   __pyx_MemviewEnum___init__, /*tp_init*/
24190   0, /*tp_alloc*/
24191   __pyx_tp_new_Enum, /*tp_new*/
24192   0, /*tp_free*/
24193   0, /*tp_is_gc*/
24194   0, /*tp_bases*/
24195   0, /*tp_mro*/
24196   0, /*tp_cache*/
24197   0, /*tp_subclasses*/
24198   0, /*tp_weaklist*/
24199   0, /*tp_del*/
24200   0, /*tp_version_tag*/
24201   #if PY_VERSION_HEX >= 0x030400a1
24202   0, /*tp_finalize*/
24203   #endif
24204   #if PY_VERSION_HEX >= 0x030800b1
24205   0, /*tp_vectorcall*/
24206   #endif
24207   #if PY_VERSION_HEX >= 0x030800b4 && PY_VERSION_HEX < 0x03090000
24208   0, /*tp_print*/
24209   #endif
24210 };
24211 static struct __pyx_vtabstruct_memoryview __pyx_vtable_memoryview;
24212 
__pyx_tp_new_memoryview(PyTypeObject * t,PyObject * a,PyObject * k)24213 static PyObject *__pyx_tp_new_memoryview(PyTypeObject *t, PyObject *a, PyObject *k) {
24214   struct __pyx_memoryview_obj *p;
24215   PyObject *o;
24216   if (likely((t->tp_flags & Py_TPFLAGS_IS_ABSTRACT) == 0)) {
24217     o = (*t->tp_alloc)(t, 0);
24218   } else {
24219     o = (PyObject *) PyBaseObject_Type.tp_new(t, __pyx_empty_tuple, 0);
24220   }
24221   if (unlikely(!o)) return 0;
24222   p = ((struct __pyx_memoryview_obj *)o);
24223   p->__pyx_vtab = __pyx_vtabptr_memoryview;
24224   p->obj = Py_None; Py_INCREF(Py_None);
24225   p->_size = Py_None; Py_INCREF(Py_None);
24226   p->_array_interface = Py_None; Py_INCREF(Py_None);
24227   p->view.obj = NULL;
24228   if (unlikely(__pyx_memoryview___cinit__(o, a, k) < 0)) goto bad;
24229   return o;
24230   bad:
24231   Py_DECREF(o); o = 0;
24232   return NULL;
24233 }
24234 
__pyx_tp_dealloc_memoryview(PyObject * o)24235 static void __pyx_tp_dealloc_memoryview(PyObject *o) {
24236   struct __pyx_memoryview_obj *p = (struct __pyx_memoryview_obj *)o;
24237   #if CYTHON_USE_TP_FINALIZE
24238   if (unlikely(PyType_HasFeature(Py_TYPE(o), Py_TPFLAGS_HAVE_FINALIZE) && Py_TYPE(o)->tp_finalize) && !_PyGC_FINALIZED(o)) {
24239     if (PyObject_CallFinalizerFromDealloc(o)) return;
24240   }
24241   #endif
24242   PyObject_GC_UnTrack(o);
24243   {
24244     PyObject *etype, *eval, *etb;
24245     PyErr_Fetch(&etype, &eval, &etb);
24246     __Pyx_SET_REFCNT(o, Py_REFCNT(o) + 1);
24247     __pyx_memoryview___dealloc__(o);
24248     __Pyx_SET_REFCNT(o, Py_REFCNT(o) - 1);
24249     PyErr_Restore(etype, eval, etb);
24250   }
24251   Py_CLEAR(p->obj);
24252   Py_CLEAR(p->_size);
24253   Py_CLEAR(p->_array_interface);
24254   (*Py_TYPE(o)->tp_free)(o);
24255 }
24256 
__pyx_tp_traverse_memoryview(PyObject * o,visitproc v,void * a)24257 static int __pyx_tp_traverse_memoryview(PyObject *o, visitproc v, void *a) {
24258   int e;
24259   struct __pyx_memoryview_obj *p = (struct __pyx_memoryview_obj *)o;
24260   if (p->obj) {
24261     e = (*v)(p->obj, a); if (e) return e;
24262   }
24263   if (p->_size) {
24264     e = (*v)(p->_size, a); if (e) return e;
24265   }
24266   if (p->_array_interface) {
24267     e = (*v)(p->_array_interface, a); if (e) return e;
24268   }
24269   if (p->view.obj) {
24270     e = (*v)(p->view.obj, a); if (e) return e;
24271   }
24272   return 0;
24273 }
24274 
__pyx_tp_clear_memoryview(PyObject * o)24275 static int __pyx_tp_clear_memoryview(PyObject *o) {
24276   PyObject* tmp;
24277   struct __pyx_memoryview_obj *p = (struct __pyx_memoryview_obj *)o;
24278   tmp = ((PyObject*)p->obj);
24279   p->obj = Py_None; Py_INCREF(Py_None);
24280   Py_XDECREF(tmp);
24281   tmp = ((PyObject*)p->_size);
24282   p->_size = Py_None; Py_INCREF(Py_None);
24283   Py_XDECREF(tmp);
24284   tmp = ((PyObject*)p->_array_interface);
24285   p->_array_interface = Py_None; Py_INCREF(Py_None);
24286   Py_XDECREF(tmp);
24287   Py_CLEAR(p->view.obj);
24288   return 0;
24289 }
__pyx_sq_item_memoryview(PyObject * o,Py_ssize_t i)24290 static PyObject *__pyx_sq_item_memoryview(PyObject *o, Py_ssize_t i) {
24291   PyObject *r;
24292   PyObject *x = PyInt_FromSsize_t(i); if(!x) return 0;
24293   r = Py_TYPE(o)->tp_as_mapping->mp_subscript(o, x);
24294   Py_DECREF(x);
24295   return r;
24296 }
24297 
__pyx_mp_ass_subscript_memoryview(PyObject * o,PyObject * i,PyObject * v)24298 static int __pyx_mp_ass_subscript_memoryview(PyObject *o, PyObject *i, PyObject *v) {
24299   if (v) {
24300     return __pyx_memoryview___setitem__(o, i, v);
24301   }
24302   else {
24303     PyErr_Format(PyExc_NotImplementedError,
24304       "Subscript deletion not supported by %.200s", Py_TYPE(o)->tp_name);
24305     return -1;
24306   }
24307 }
24308 
__pyx_getprop___pyx_memoryview_T(PyObject * o,CYTHON_UNUSED void * x)24309 static PyObject *__pyx_getprop___pyx_memoryview_T(PyObject *o, CYTHON_UNUSED void *x) {
24310   return __pyx_pw_15View_dot_MemoryView_10memoryview_1T_1__get__(o);
24311 }
24312 
__pyx_getprop___pyx_memoryview_base(PyObject * o,CYTHON_UNUSED void * x)24313 static PyObject *__pyx_getprop___pyx_memoryview_base(PyObject *o, CYTHON_UNUSED void *x) {
24314   return __pyx_pw_15View_dot_MemoryView_10memoryview_4base_1__get__(o);
24315 }
24316 
__pyx_getprop___pyx_memoryview_shape(PyObject * o,CYTHON_UNUSED void * x)24317 static PyObject *__pyx_getprop___pyx_memoryview_shape(PyObject *o, CYTHON_UNUSED void *x) {
24318   return __pyx_pw_15View_dot_MemoryView_10memoryview_5shape_1__get__(o);
24319 }
24320 
__pyx_getprop___pyx_memoryview_strides(PyObject * o,CYTHON_UNUSED void * x)24321 static PyObject *__pyx_getprop___pyx_memoryview_strides(PyObject *o, CYTHON_UNUSED void *x) {
24322   return __pyx_pw_15View_dot_MemoryView_10memoryview_7strides_1__get__(o);
24323 }
24324 
__pyx_getprop___pyx_memoryview_suboffsets(PyObject * o,CYTHON_UNUSED void * x)24325 static PyObject *__pyx_getprop___pyx_memoryview_suboffsets(PyObject *o, CYTHON_UNUSED void *x) {
24326   return __pyx_pw_15View_dot_MemoryView_10memoryview_10suboffsets_1__get__(o);
24327 }
24328 
__pyx_getprop___pyx_memoryview_ndim(PyObject * o,CYTHON_UNUSED void * x)24329 static PyObject *__pyx_getprop___pyx_memoryview_ndim(PyObject *o, CYTHON_UNUSED void *x) {
24330   return __pyx_pw_15View_dot_MemoryView_10memoryview_4ndim_1__get__(o);
24331 }
24332 
__pyx_getprop___pyx_memoryview_itemsize(PyObject * o,CYTHON_UNUSED void * x)24333 static PyObject *__pyx_getprop___pyx_memoryview_itemsize(PyObject *o, CYTHON_UNUSED void *x) {
24334   return __pyx_pw_15View_dot_MemoryView_10memoryview_8itemsize_1__get__(o);
24335 }
24336 
__pyx_getprop___pyx_memoryview_nbytes(PyObject * o,CYTHON_UNUSED void * x)24337 static PyObject *__pyx_getprop___pyx_memoryview_nbytes(PyObject *o, CYTHON_UNUSED void *x) {
24338   return __pyx_pw_15View_dot_MemoryView_10memoryview_6nbytes_1__get__(o);
24339 }
24340 
__pyx_getprop___pyx_memoryview_size(PyObject * o,CYTHON_UNUSED void * x)24341 static PyObject *__pyx_getprop___pyx_memoryview_size(PyObject *o, CYTHON_UNUSED void *x) {
24342   return __pyx_pw_15View_dot_MemoryView_10memoryview_4size_1__get__(o);
24343 }
24344 
24345 static PyMethodDef __pyx_methods_memoryview[] = {
24346   {"is_c_contig", (PyCFunction)__pyx_memoryview_is_c_contig, METH_NOARGS, 0},
24347   {"is_f_contig", (PyCFunction)__pyx_memoryview_is_f_contig, METH_NOARGS, 0},
24348   {"copy", (PyCFunction)__pyx_memoryview_copy, METH_NOARGS, 0},
24349   {"copy_fortran", (PyCFunction)__pyx_memoryview_copy_fortran, METH_NOARGS, 0},
24350   {"__reduce_cython__", (PyCFunction)__pyx_pw___pyx_memoryview_1__reduce_cython__, METH_NOARGS, 0},
24351   {"__setstate_cython__", (PyCFunction)__pyx_pw___pyx_memoryview_3__setstate_cython__, METH_O, 0},
24352   {0, 0, 0, 0}
24353 };
24354 
24355 static struct PyGetSetDef __pyx_getsets_memoryview[] = {
24356   {(char *)"T", __pyx_getprop___pyx_memoryview_T, 0, (char *)0, 0},
24357   {(char *)"base", __pyx_getprop___pyx_memoryview_base, 0, (char *)0, 0},
24358   {(char *)"shape", __pyx_getprop___pyx_memoryview_shape, 0, (char *)0, 0},
24359   {(char *)"strides", __pyx_getprop___pyx_memoryview_strides, 0, (char *)0, 0},
24360   {(char *)"suboffsets", __pyx_getprop___pyx_memoryview_suboffsets, 0, (char *)0, 0},
24361   {(char *)"ndim", __pyx_getprop___pyx_memoryview_ndim, 0, (char *)0, 0},
24362   {(char *)"itemsize", __pyx_getprop___pyx_memoryview_itemsize, 0, (char *)0, 0},
24363   {(char *)"nbytes", __pyx_getprop___pyx_memoryview_nbytes, 0, (char *)0, 0},
24364   {(char *)"size", __pyx_getprop___pyx_memoryview_size, 0, (char *)0, 0},
24365   {0, 0, 0, 0, 0}
24366 };
24367 
24368 static PySequenceMethods __pyx_tp_as_sequence_memoryview = {
24369   __pyx_memoryview___len__, /*sq_length*/
24370   0, /*sq_concat*/
24371   0, /*sq_repeat*/
24372   __pyx_sq_item_memoryview, /*sq_item*/
24373   0, /*sq_slice*/
24374   0, /*sq_ass_item*/
24375   0, /*sq_ass_slice*/
24376   0, /*sq_contains*/
24377   0, /*sq_inplace_concat*/
24378   0, /*sq_inplace_repeat*/
24379 };
24380 
24381 static PyMappingMethods __pyx_tp_as_mapping_memoryview = {
24382   __pyx_memoryview___len__, /*mp_length*/
24383   __pyx_memoryview___getitem__, /*mp_subscript*/
24384   __pyx_mp_ass_subscript_memoryview, /*mp_ass_subscript*/
24385 };
24386 
24387 static PyBufferProcs __pyx_tp_as_buffer_memoryview = {
24388   #if PY_MAJOR_VERSION < 3
24389   0, /*bf_getreadbuffer*/
24390   #endif
24391   #if PY_MAJOR_VERSION < 3
24392   0, /*bf_getwritebuffer*/
24393   #endif
24394   #if PY_MAJOR_VERSION < 3
24395   0, /*bf_getsegcount*/
24396   #endif
24397   #if PY_MAJOR_VERSION < 3
24398   0, /*bf_getcharbuffer*/
24399   #endif
24400   __pyx_memoryview_getbuffer, /*bf_getbuffer*/
24401   0, /*bf_releasebuffer*/
24402 };
24403 
24404 static PyTypeObject __pyx_type___pyx_memoryview = {
24405   PyVarObject_HEAD_INIT(0, 0)
24406   "qutip.cy.br_tensor.memoryview", /*tp_name*/
24407   sizeof(struct __pyx_memoryview_obj), /*tp_basicsize*/
24408   0, /*tp_itemsize*/
24409   __pyx_tp_dealloc_memoryview, /*tp_dealloc*/
24410   #if PY_VERSION_HEX < 0x030800b4
24411   0, /*tp_print*/
24412   #endif
24413   #if PY_VERSION_HEX >= 0x030800b4
24414   0, /*tp_vectorcall_offset*/
24415   #endif
24416   0, /*tp_getattr*/
24417   0, /*tp_setattr*/
24418   #if PY_MAJOR_VERSION < 3
24419   0, /*tp_compare*/
24420   #endif
24421   #if PY_MAJOR_VERSION >= 3
24422   0, /*tp_as_async*/
24423   #endif
24424   __pyx_memoryview___repr__, /*tp_repr*/
24425   0, /*tp_as_number*/
24426   &__pyx_tp_as_sequence_memoryview, /*tp_as_sequence*/
24427   &__pyx_tp_as_mapping_memoryview, /*tp_as_mapping*/
24428   0, /*tp_hash*/
24429   0, /*tp_call*/
24430   __pyx_memoryview___str__, /*tp_str*/
24431   0, /*tp_getattro*/
24432   0, /*tp_setattro*/
24433   &__pyx_tp_as_buffer_memoryview, /*tp_as_buffer*/
24434   Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
24435   0, /*tp_doc*/
24436   __pyx_tp_traverse_memoryview, /*tp_traverse*/
24437   __pyx_tp_clear_memoryview, /*tp_clear*/
24438   0, /*tp_richcompare*/
24439   0, /*tp_weaklistoffset*/
24440   0, /*tp_iter*/
24441   0, /*tp_iternext*/
24442   __pyx_methods_memoryview, /*tp_methods*/
24443   0, /*tp_members*/
24444   __pyx_getsets_memoryview, /*tp_getset*/
24445   0, /*tp_base*/
24446   0, /*tp_dict*/
24447   0, /*tp_descr_get*/
24448   0, /*tp_descr_set*/
24449   0, /*tp_dictoffset*/
24450   0, /*tp_init*/
24451   0, /*tp_alloc*/
24452   __pyx_tp_new_memoryview, /*tp_new*/
24453   0, /*tp_free*/
24454   0, /*tp_is_gc*/
24455   0, /*tp_bases*/
24456   0, /*tp_mro*/
24457   0, /*tp_cache*/
24458   0, /*tp_subclasses*/
24459   0, /*tp_weaklist*/
24460   0, /*tp_del*/
24461   0, /*tp_version_tag*/
24462   #if PY_VERSION_HEX >= 0x030400a1
24463   0, /*tp_finalize*/
24464   #endif
24465   #if PY_VERSION_HEX >= 0x030800b1
24466   0, /*tp_vectorcall*/
24467   #endif
24468   #if PY_VERSION_HEX >= 0x030800b4 && PY_VERSION_HEX < 0x03090000
24469   0, /*tp_print*/
24470   #endif
24471 };
24472 static struct __pyx_vtabstruct__memoryviewslice __pyx_vtable__memoryviewslice;
24473 
__pyx_tp_new__memoryviewslice(PyTypeObject * t,PyObject * a,PyObject * k)24474 static PyObject *__pyx_tp_new__memoryviewslice(PyTypeObject *t, PyObject *a, PyObject *k) {
24475   struct __pyx_memoryviewslice_obj *p;
24476   PyObject *o = __pyx_tp_new_memoryview(t, a, k);
24477   if (unlikely(!o)) return 0;
24478   p = ((struct __pyx_memoryviewslice_obj *)o);
24479   p->__pyx_base.__pyx_vtab = (struct __pyx_vtabstruct_memoryview*)__pyx_vtabptr__memoryviewslice;
24480   p->from_object = Py_None; Py_INCREF(Py_None);
24481   p->from_slice.memview = NULL;
24482   return o;
24483 }
24484 
__pyx_tp_dealloc__memoryviewslice(PyObject * o)24485 static void __pyx_tp_dealloc__memoryviewslice(PyObject *o) {
24486   struct __pyx_memoryviewslice_obj *p = (struct __pyx_memoryviewslice_obj *)o;
24487   #if CYTHON_USE_TP_FINALIZE
24488   if (unlikely(PyType_HasFeature(Py_TYPE(o), Py_TPFLAGS_HAVE_FINALIZE) && Py_TYPE(o)->tp_finalize) && !_PyGC_FINALIZED(o)) {
24489     if (PyObject_CallFinalizerFromDealloc(o)) return;
24490   }
24491   #endif
24492   PyObject_GC_UnTrack(o);
24493   {
24494     PyObject *etype, *eval, *etb;
24495     PyErr_Fetch(&etype, &eval, &etb);
24496     __Pyx_SET_REFCNT(o, Py_REFCNT(o) + 1);
24497     __pyx_memoryviewslice___dealloc__(o);
24498     __Pyx_SET_REFCNT(o, Py_REFCNT(o) - 1);
24499     PyErr_Restore(etype, eval, etb);
24500   }
24501   Py_CLEAR(p->from_object);
24502   PyObject_GC_Track(o);
24503   __pyx_tp_dealloc_memoryview(o);
24504 }
24505 
__pyx_tp_traverse__memoryviewslice(PyObject * o,visitproc v,void * a)24506 static int __pyx_tp_traverse__memoryviewslice(PyObject *o, visitproc v, void *a) {
24507   int e;
24508   struct __pyx_memoryviewslice_obj *p = (struct __pyx_memoryviewslice_obj *)o;
24509   e = __pyx_tp_traverse_memoryview(o, v, a); if (e) return e;
24510   if (p->from_object) {
24511     e = (*v)(p->from_object, a); if (e) return e;
24512   }
24513   return 0;
24514 }
24515 
__pyx_tp_clear__memoryviewslice(PyObject * o)24516 static int __pyx_tp_clear__memoryviewslice(PyObject *o) {
24517   PyObject* tmp;
24518   struct __pyx_memoryviewslice_obj *p = (struct __pyx_memoryviewslice_obj *)o;
24519   __pyx_tp_clear_memoryview(o);
24520   tmp = ((PyObject*)p->from_object);
24521   p->from_object = Py_None; Py_INCREF(Py_None);
24522   Py_XDECREF(tmp);
24523   __PYX_XDEC_MEMVIEW(&p->from_slice, 1);
24524   return 0;
24525 }
24526 
__pyx_getprop___pyx_memoryviewslice_base(PyObject * o,CYTHON_UNUSED void * x)24527 static PyObject *__pyx_getprop___pyx_memoryviewslice_base(PyObject *o, CYTHON_UNUSED void *x) {
24528   return __pyx_pw_15View_dot_MemoryView_16_memoryviewslice_4base_1__get__(o);
24529 }
24530 
24531 static PyMethodDef __pyx_methods__memoryviewslice[] = {
24532   {"__reduce_cython__", (PyCFunction)__pyx_pw___pyx_memoryviewslice_1__reduce_cython__, METH_NOARGS, 0},
24533   {"__setstate_cython__", (PyCFunction)__pyx_pw___pyx_memoryviewslice_3__setstate_cython__, METH_O, 0},
24534   {0, 0, 0, 0}
24535 };
24536 
24537 static struct PyGetSetDef __pyx_getsets__memoryviewslice[] = {
24538   {(char *)"base", __pyx_getprop___pyx_memoryviewslice_base, 0, (char *)0, 0},
24539   {0, 0, 0, 0, 0}
24540 };
24541 
24542 static PyTypeObject __pyx_type___pyx_memoryviewslice = {
24543   PyVarObject_HEAD_INIT(0, 0)
24544   "qutip.cy.br_tensor._memoryviewslice", /*tp_name*/
24545   sizeof(struct __pyx_memoryviewslice_obj), /*tp_basicsize*/
24546   0, /*tp_itemsize*/
24547   __pyx_tp_dealloc__memoryviewslice, /*tp_dealloc*/
24548   #if PY_VERSION_HEX < 0x030800b4
24549   0, /*tp_print*/
24550   #endif
24551   #if PY_VERSION_HEX >= 0x030800b4
24552   0, /*tp_vectorcall_offset*/
24553   #endif
24554   0, /*tp_getattr*/
24555   0, /*tp_setattr*/
24556   #if PY_MAJOR_VERSION < 3
24557   0, /*tp_compare*/
24558   #endif
24559   #if PY_MAJOR_VERSION >= 3
24560   0, /*tp_as_async*/
24561   #endif
24562   #if CYTHON_COMPILING_IN_PYPY
24563   __pyx_memoryview___repr__, /*tp_repr*/
24564   #else
24565   0, /*tp_repr*/
24566   #endif
24567   0, /*tp_as_number*/
24568   0, /*tp_as_sequence*/
24569   0, /*tp_as_mapping*/
24570   0, /*tp_hash*/
24571   0, /*tp_call*/
24572   #if CYTHON_COMPILING_IN_PYPY
24573   __pyx_memoryview___str__, /*tp_str*/
24574   #else
24575   0, /*tp_str*/
24576   #endif
24577   0, /*tp_getattro*/
24578   0, /*tp_setattro*/
24579   0, /*tp_as_buffer*/
24580   Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
24581   "Internal class for passing memoryview slices to Python", /*tp_doc*/
24582   __pyx_tp_traverse__memoryviewslice, /*tp_traverse*/
24583   __pyx_tp_clear__memoryviewslice, /*tp_clear*/
24584   0, /*tp_richcompare*/
24585   0, /*tp_weaklistoffset*/
24586   0, /*tp_iter*/
24587   0, /*tp_iternext*/
24588   __pyx_methods__memoryviewslice, /*tp_methods*/
24589   0, /*tp_members*/
24590   __pyx_getsets__memoryviewslice, /*tp_getset*/
24591   0, /*tp_base*/
24592   0, /*tp_dict*/
24593   0, /*tp_descr_get*/
24594   0, /*tp_descr_set*/
24595   0, /*tp_dictoffset*/
24596   0, /*tp_init*/
24597   0, /*tp_alloc*/
24598   __pyx_tp_new__memoryviewslice, /*tp_new*/
24599   0, /*tp_free*/
24600   0, /*tp_is_gc*/
24601   0, /*tp_bases*/
24602   0, /*tp_mro*/
24603   0, /*tp_cache*/
24604   0, /*tp_subclasses*/
24605   0, /*tp_weaklist*/
24606   0, /*tp_del*/
24607   0, /*tp_version_tag*/
24608   #if PY_VERSION_HEX >= 0x030400a1
24609   0, /*tp_finalize*/
24610   #endif
24611   #if PY_VERSION_HEX >= 0x030800b1
24612   0, /*tp_vectorcall*/
24613   #endif
24614   #if PY_VERSION_HEX >= 0x030800b4 && PY_VERSION_HEX < 0x03090000
24615   0, /*tp_print*/
24616   #endif
24617 };
24618 
24619 static PyMethodDef __pyx_methods[] = {
24620   {0, 0, 0, 0}
24621 };
24622 
24623 #if PY_MAJOR_VERSION >= 3
24624 #if CYTHON_PEP489_MULTI_PHASE_INIT
24625 static PyObject* __pyx_pymod_create(PyObject *spec, PyModuleDef *def); /*proto*/
24626 static int __pyx_pymod_exec_br_tensor(PyObject* module); /*proto*/
24627 static PyModuleDef_Slot __pyx_moduledef_slots[] = {
24628   {Py_mod_create, (void*)__pyx_pymod_create},
24629   {Py_mod_exec, (void*)__pyx_pymod_exec_br_tensor},
24630   {0, NULL}
24631 };
24632 #endif
24633 
24634 static struct PyModuleDef __pyx_moduledef = {
24635     PyModuleDef_HEAD_INIT,
24636     "br_tensor",
24637     0, /* m_doc */
24638   #if CYTHON_PEP489_MULTI_PHASE_INIT
24639     0, /* m_size */
24640   #else
24641     -1, /* m_size */
24642   #endif
24643     __pyx_methods /* m_methods */,
24644   #if CYTHON_PEP489_MULTI_PHASE_INIT
24645     __pyx_moduledef_slots, /* m_slots */
24646   #else
24647     NULL, /* m_reload */
24648   #endif
24649     NULL, /* m_traverse */
24650     NULL, /* m_clear */
24651     NULL /* m_free */
24652 };
24653 #endif
24654 #ifndef CYTHON_SMALL_CODE
24655 #if defined(__clang__)
24656     #define CYTHON_SMALL_CODE
24657 #elif defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3))
24658     #define CYTHON_SMALL_CODE __attribute__((cold))
24659 #else
24660     #define CYTHON_SMALL_CODE
24661 #endif
24662 #endif
24663 
24664 static __Pyx_StringTabEntry __pyx_string_tab[] = {
24665   {&__pyx_n_s_A, __pyx_k_A, sizeof(__pyx_k_A), 0, 0, 1, 1},
24666   {&__pyx_n_s_ASCII, __pyx_k_ASCII, sizeof(__pyx_k_ASCII), 0, 0, 1, 1},
24667   {&__pyx_n_s_A_eig, __pyx_k_A_eig, sizeof(__pyx_k_A_eig), 0, 0, 1, 1},
24668   {&__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},
24669   {&__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},
24670   {&__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},
24671   {&__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},
24672   {&__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},
24673   {&__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},
24674   {&__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},
24675   {&__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},
24676   {&__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},
24677   {&__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},
24678   {&__pyx_kp_u_Could_not_allocate_memory, __pyx_k_Could_not_allocate_memory, sizeof(__pyx_k_Could_not_allocate_memory), 0, 1, 0, 0},
24679   {&__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},
24680   {&__pyx_n_s_DeprecationWarning, __pyx_k_DeprecationWarning, sizeof(__pyx_k_DeprecationWarning), 0, 0, 1, 1},
24681   {&__pyx_n_s_Ellipsis, __pyx_k_Ellipsis, sizeof(__pyx_k_Ellipsis), 0, 0, 1, 1},
24682   {&__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},
24683   {&__pyx_kp_u_Error_in_Cython_code, __pyx_k_Error_in_Cython_code, sizeof(__pyx_k_Error_in_Cython_code), 0, 1, 0, 0},
24684   {&__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},
24685   {&__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},
24686   {&__pyx_n_u_F, __pyx_k_F, sizeof(__pyx_k_F), 0, 1, 0, 1},
24687   {&__pyx_n_s_H, __pyx_k_H, sizeof(__pyx_k_H), 0, 0, 1, 1},
24688   {&__pyx_n_s_H0, __pyx_k_H0, sizeof(__pyx_k_H0), 0, 0, 1, 1},
24689   {&__pyx_kp_u_H_must_be_an_instance_of_Qobj, __pyx_k_H_must_be_an_instance_of_Qobj, sizeof(__pyx_k_H_must_be_an_instance_of_Qobj), 0, 1, 0, 0},
24690   {&__pyx_n_s_I, __pyx_k_I, sizeof(__pyx_k_I), 0, 0, 1, 1},
24691   {&__pyx_n_s_ImportError, __pyx_k_ImportError, sizeof(__pyx_k_ImportError), 0, 0, 1, 1},
24692   {&__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},
24693   {&__pyx_n_s_IndexError, __pyx_k_IndexError, sizeof(__pyx_k_IndexError), 0, 0, 1, 1},
24694   {&__pyx_kp_s_Indirect_dimensions_not_supporte, __pyx_k_Indirect_dimensions_not_supporte, sizeof(__pyx_k_Indirect_dimensions_not_supporte), 0, 0, 1, 0},
24695   {&__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},
24696   {&__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},
24697   {&__pyx_n_s_J, __pyx_k_J, sizeof(__pyx_k_J), 0, 0, 1, 1},
24698   {&__pyx_n_s_K, __pyx_k_K, sizeof(__pyx_k_K), 0, 0, 1, 1},
24699   {&__pyx_n_s_L, __pyx_k_L, sizeof(__pyx_k_L), 0, 0, 1, 1},
24700   {&__pyx_n_s_MemoryError, __pyx_k_MemoryError, sizeof(__pyx_k_MemoryError), 0, 0, 1, 1},
24701   {&__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},
24702   {&__pyx_kp_s_MemoryView_of_r_object, __pyx_k_MemoryView_of_r_object, sizeof(__pyx_k_MemoryView_of_r_object), 0, 0, 1, 0},
24703   {&__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},
24704   {&__pyx_n_b_O, __pyx_k_O, sizeof(__pyx_k_O), 0, 0, 0, 1},
24705   {&__pyx_kp_u_Operators_in_a_ops_must_be_Hermi, __pyx_k_Operators_in_a_ops_must_be_Hermi, sizeof(__pyx_k_Operators_in_a_ops_must_be_Hermi), 0, 1, 0, 0},
24706   {&__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},
24707   {&__pyx_n_s_PickleError, __pyx_k_PickleError, sizeof(__pyx_k_PickleError), 0, 0, 1, 1},
24708   {&__pyx_n_s_Qobj, __pyx_k_Qobj, sizeof(__pyx_k_Qobj), 0, 0, 1, 1},
24709   {&__pyx_kp_u_The_use_of_spectra_cb_is_depreci, __pyx_k_The_use_of_spectra_cb_is_depreci, sizeof(__pyx_k_The_use_of_spectra_cb_is_depreci), 0, 1, 0, 0},
24710   {&__pyx_n_s_TypeError, __pyx_k_TypeError, sizeof(__pyx_k_TypeError), 0, 0, 1, 1},
24711   {&__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},
24712   {&__pyx_n_s_ValueError, __pyx_k_ValueError, sizeof(__pyx_k_ValueError), 0, 0, 1, 1},
24713   {&__pyx_n_s_View_MemoryView, __pyx_k_View_MemoryView, sizeof(__pyx_k_View_MemoryView), 0, 0, 1, 1},
24714   {&__pyx_n_s__37, __pyx_k__37, sizeof(__pyx_k__37), 0, 0, 1, 1},
24715   {&__pyx_n_s_a, __pyx_k_a, sizeof(__pyx_k_a), 0, 0, 1, 1},
24716   {&__pyx_n_s_a_ops, __pyx_k_a_ops, sizeof(__pyx_k_a_ops), 0, 0, 1, 1},
24717   {&__pyx_n_s_a_ops_2, __pyx_k_a_ops_2, sizeof(__pyx_k_a_ops_2), 0, 0, 1, 1},
24718   {&__pyx_n_s_ab, __pyx_k_ab, sizeof(__pyx_k_ab), 0, 0, 1, 1},
24719   {&__pyx_n_s_ac_elem, __pyx_k_ac_elem, sizeof(__pyx_k_ac_elem), 0, 0, 1, 1},
24720   {&__pyx_n_s_allocate_buffer, __pyx_k_allocate_buffer, sizeof(__pyx_k_allocate_buffer), 0, 0, 1, 1},
24721   {&__pyx_n_s_asarray, __pyx_k_asarray, sizeof(__pyx_k_asarray), 0, 0, 1, 1},
24722   {&__pyx_n_s_atol, __pyx_k_atol, sizeof(__pyx_k_atol), 0, 0, 1, 1},
24723   {&__pyx_n_s_base, __pyx_k_base, sizeof(__pyx_k_base), 0, 0, 1, 1},
24724   {&__pyx_n_s_bd_elem, __pyx_k_bd_elem, sizeof(__pyx_k_bd_elem), 0, 0, 1, 1},
24725   {&__pyx_n_s_bloch_redfield_tensor, __pyx_k_bloch_redfield_tensor, sizeof(__pyx_k_bloch_redfield_tensor), 0, 0, 1, 1},
24726   {&__pyx_n_s_br_term, __pyx_k_br_term, sizeof(__pyx_k_br_term), 0, 0, 1, 1},
24727   {&__pyx_n_s_c, __pyx_k_c, sizeof(__pyx_k_c), 0, 0, 1, 1},
24728   {&__pyx_n_u_c, __pyx_k_c, sizeof(__pyx_k_c), 0, 1, 0, 1},
24729   {&__pyx_n_s_c_ops, __pyx_k_c_ops, sizeof(__pyx_k_c_ops), 0, 0, 1, 1},
24730   {&__pyx_n_s_cd, __pyx_k_cd, sizeof(__pyx_k_cd), 0, 0, 1, 1},
24731   {&__pyx_n_s_class, __pyx_k_class, sizeof(__pyx_k_class), 0, 0, 1, 1},
24732   {&__pyx_n_s_cline_in_traceback, __pyx_k_cline_in_traceback, sizeof(__pyx_k_cline_in_traceback), 0, 0, 1, 1},
24733   {&__pyx_n_s_col, __pyx_k_col, sizeof(__pyx_k_col), 0, 0, 1, 1},
24734   {&__pyx_kp_s_contiguous_and_direct, __pyx_k_contiguous_and_direct, sizeof(__pyx_k_contiguous_and_direct), 0, 0, 1, 0},
24735   {&__pyx_kp_s_contiguous_and_indirect, __pyx_k_contiguous_and_indirect, sizeof(__pyx_k_contiguous_and_indirect), 0, 0, 1, 0},
24736   {&__pyx_n_s_coo, __pyx_k_coo, sizeof(__pyx_k_coo), 0, 0, 1, 1},
24737   {&__pyx_n_s_coo_cols, __pyx_k_coo_cols, sizeof(__pyx_k_coo_cols), 0, 0, 1, 1},
24738   {&__pyx_n_s_coo_data, __pyx_k_coo_data, sizeof(__pyx_k_coo_data), 0, 0, 1, 1},
24739   {&__pyx_n_s_coo_matrix, __pyx_k_coo_matrix, sizeof(__pyx_k_coo_matrix), 0, 0, 1, 1},
24740   {&__pyx_n_s_coo_rows, __pyx_k_coo_rows, sizeof(__pyx_k_coo_rows), 0, 0, 1, 1},
24741   {&__pyx_n_s_cop, __pyx_k_cop, sizeof(__pyx_k_cop), 0, 0, 1, 1},
24742   {&__pyx_n_s_cop_super_term, __pyx_k_cop_super_term, sizeof(__pyx_k_cop_super_term), 0, 0, 1, 1},
24743   {&__pyx_n_s_copy, __pyx_k_copy, sizeof(__pyx_k_copy), 0, 0, 1, 1},
24744   {&__pyx_n_s_csr, __pyx_k_csr, sizeof(__pyx_k_csr), 0, 0, 1, 1},
24745   {&__pyx_n_s_data, __pyx_k_data, sizeof(__pyx_k_data), 0, 0, 1, 1},
24746   {&__pyx_n_s_dict, __pyx_k_dict, sizeof(__pyx_k_dict), 0, 0, 1, 1},
24747   {&__pyx_n_s_dims, __pyx_k_dims, sizeof(__pyx_k_dims), 0, 0, 1, 1},
24748   {&__pyx_n_s_dtype, __pyx_k_dtype, sizeof(__pyx_k_dtype), 0, 0, 1, 1},
24749   {&__pyx_n_s_dtype_is_object, __pyx_k_dtype_is_object, sizeof(__pyx_k_dtype_is_object), 0, 0, 1, 1},
24750   {&__pyx_n_s_dw_min, __pyx_k_dw_min, sizeof(__pyx_k_dw_min), 0, 0, 1, 1},
24751   {&__pyx_n_s_ekets, __pyx_k_ekets, sizeof(__pyx_k_ekets), 0, 0, 1, 1},
24752   {&__pyx_n_s_elem, __pyx_k_elem, sizeof(__pyx_k_elem), 0, 0, 1, 1},
24753   {&__pyx_n_s_encode, __pyx_k_encode, sizeof(__pyx_k_encode), 0, 0, 1, 1},
24754   {&__pyx_n_s_enumerate, __pyx_k_enumerate, sizeof(__pyx_k_enumerate), 0, 0, 1, 1},
24755   {&__pyx_n_s_error, __pyx_k_error, sizeof(__pyx_k_error), 0, 0, 1, 1},
24756   {&__pyx_n_s_evals, __pyx_k_evals, sizeof(__pyx_k_evals), 0, 0, 1, 1},
24757   {&__pyx_n_s_evecs, __pyx_k_evecs, sizeof(__pyx_k_evecs), 0, 0, 1, 1},
24758   {&__pyx_n_s_fast_csr_matrix, __pyx_k_fast_csr_matrix, sizeof(__pyx_k_fast_csr_matrix), 0, 0, 1, 1},
24759   {&__pyx_n_s_flags, __pyx_k_flags, sizeof(__pyx_k_flags), 0, 0, 1, 1},
24760   {&__pyx_n_s_format, __pyx_k_format, sizeof(__pyx_k_format), 0, 0, 1, 1},
24761   {&__pyx_n_s_fortran, __pyx_k_fortran, sizeof(__pyx_k_fortran), 0, 0, 1, 1},
24762   {&__pyx_n_u_fortran, __pyx_k_fortran, sizeof(__pyx_k_fortran), 0, 1, 0, 1},
24763   {&__pyx_n_s_full, __pyx_k_full, sizeof(__pyx_k_full), 0, 0, 1, 1},
24764   {&__pyx_n_s_getstate, __pyx_k_getstate, sizeof(__pyx_k_getstate), 0, 0, 1, 1},
24765   {&__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},
24766   {&__pyx_n_s_id, __pyx_k_id, sizeof(__pyx_k_id), 0, 0, 1, 1},
24767   {&__pyx_n_s_import, __pyx_k_import, sizeof(__pyx_k_import), 0, 0, 1, 1},
24768   {&__pyx_n_s_indices, __pyx_k_indices, sizeof(__pyx_k_indices), 0, 0, 1, 1},
24769   {&__pyx_n_s_indptr, __pyx_k_indptr, sizeof(__pyx_k_indptr), 0, 0, 1, 1},
24770   {&__pyx_n_s_isherm, __pyx_k_isherm, sizeof(__pyx_k_isherm), 0, 0, 1, 1},
24771   {&__pyx_n_s_itemsize, __pyx_k_itemsize, sizeof(__pyx_k_itemsize), 0, 0, 1, 1},
24772   {&__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},
24773   {&__pyx_n_s_k, __pyx_k_k, sizeof(__pyx_k_k), 0, 0, 1, 1},
24774   {&__pyx_n_s_ket_dims, __pyx_k_ket_dims, sizeof(__pyx_k_ket_dims), 0, 0, 1, 1},
24775   {&__pyx_n_s_kk, __pyx_k_kk, sizeof(__pyx_k_kk), 0, 0, 1, 1},
24776   {&__pyx_n_s_liou_from_diag_ham, __pyx_k_liou_from_diag_ham, sizeof(__pyx_k_liou_from_diag_ham), 0, 0, 1, 1},
24777   {&__pyx_n_s_main, __pyx_k_main, sizeof(__pyx_k_main), 0, 0, 1, 1},
24778   {&__pyx_n_s_memview, __pyx_k_memview, sizeof(__pyx_k_memview), 0, 0, 1, 1},
24779   {&__pyx_n_s_mode, __pyx_k_mode, sizeof(__pyx_k_mode), 0, 0, 1, 1},
24780   {&__pyx_n_s_name, __pyx_k_name, sizeof(__pyx_k_name), 0, 0, 1, 1},
24781   {&__pyx_n_s_name_2, __pyx_k_name_2, sizeof(__pyx_k_name_2), 0, 0, 1, 1},
24782   {&__pyx_n_s_ndim, __pyx_k_ndim, sizeof(__pyx_k_ndim), 0, 0, 1, 1},
24783   {&__pyx_n_s_new, __pyx_k_new, sizeof(__pyx_k_new), 0, 0, 1, 1},
24784   {&__pyx_n_s_nnz, __pyx_k_nnz, sizeof(__pyx_k_nnz), 0, 0, 1, 1},
24785   {&__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},
24786   {&__pyx_n_s_np, __pyx_k_np, sizeof(__pyx_k_np), 0, 0, 1, 1},
24787   {&__pyx_n_s_nrows, __pyx_k_nrows, sizeof(__pyx_k_nrows), 0, 0, 1, 1},
24788   {&__pyx_n_s_numpy, __pyx_k_numpy, sizeof(__pyx_k_numpy), 0, 0, 1, 1},
24789   {&__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},
24790   {&__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},
24791   {&__pyx_n_s_obj, __pyx_k_obj, sizeof(__pyx_k_obj), 0, 0, 1, 1},
24792   {&__pyx_n_s_op_dims, __pyx_k_op_dims, sizeof(__pyx_k_op_dims), 0, 0, 1, 1},
24793   {&__pyx_n_s_order, __pyx_k_order, sizeof(__pyx_k_order), 0, 0, 1, 1},
24794   {&__pyx_n_s_pack, __pyx_k_pack, sizeof(__pyx_k_pack), 0, 0, 1, 1},
24795   {&__pyx_n_s_pickle, __pyx_k_pickle, sizeof(__pyx_k_pickle), 0, 0, 1, 1},
24796   {&__pyx_n_s_pyx_PickleError, __pyx_k_pyx_PickleError, sizeof(__pyx_k_pyx_PickleError), 0, 0, 1, 1},
24797   {&__pyx_n_s_pyx_checksum, __pyx_k_pyx_checksum, sizeof(__pyx_k_pyx_checksum), 0, 0, 1, 1},
24798   {&__pyx_n_s_pyx_getbuffer, __pyx_k_pyx_getbuffer, sizeof(__pyx_k_pyx_getbuffer), 0, 0, 1, 1},
24799   {&__pyx_n_s_pyx_result, __pyx_k_pyx_result, sizeof(__pyx_k_pyx_result), 0, 0, 1, 1},
24800   {&__pyx_n_s_pyx_state, __pyx_k_pyx_state, sizeof(__pyx_k_pyx_state), 0, 0, 1, 1},
24801   {&__pyx_n_s_pyx_type, __pyx_k_pyx_type, sizeof(__pyx_k_pyx_type), 0, 0, 1, 1},
24802   {&__pyx_n_s_pyx_unpickle_Enum, __pyx_k_pyx_unpickle_Enum, sizeof(__pyx_k_pyx_unpickle_Enum), 0, 0, 1, 1},
24803   {&__pyx_n_s_pyx_vtable, __pyx_k_pyx_vtable, sizeof(__pyx_k_pyx_vtable), 0, 0, 1, 1},
24804   {&__pyx_n_s_qset, __pyx_k_qset, sizeof(__pyx_k_qset), 0, 0, 1, 1},
24805   {&__pyx_n_s_qutip_cy_br_tensor, __pyx_k_qutip_cy_br_tensor, sizeof(__pyx_k_qutip_cy_br_tensor), 0, 0, 1, 1},
24806   {&__pyx_kp_s_qutip_cy_br_tensor_pyx, __pyx_k_qutip_cy_br_tensor_pyx, sizeof(__pyx_k_qutip_cy_br_tensor_pyx), 0, 0, 1, 0},
24807   {&__pyx_n_s_qutip_cy_brtools, __pyx_k_qutip_cy_brtools, sizeof(__pyx_k_qutip_cy_brtools), 0, 0, 1, 1},
24808   {&__pyx_n_s_qutip_fastsparse, __pyx_k_qutip_fastsparse, sizeof(__pyx_k_qutip_fastsparse), 0, 0, 1, 1},
24809   {&__pyx_n_s_qutip_qobj, __pyx_k_qutip_qobj, sizeof(__pyx_k_qutip_qobj), 0, 0, 1, 1},
24810   {&__pyx_n_s_qutip_settings, __pyx_k_qutip_settings, sizeof(__pyx_k_qutip_settings), 0, 0, 1, 1},
24811   {&__pyx_n_s_range, __pyx_k_range, sizeof(__pyx_k_range), 0, 0, 1, 1},
24812   {&__pyx_n_s_reduce, __pyx_k_reduce, sizeof(__pyx_k_reduce), 0, 0, 1, 1},
24813   {&__pyx_n_s_reduce_cython, __pyx_k_reduce_cython, sizeof(__pyx_k_reduce_cython), 0, 0, 1, 1},
24814   {&__pyx_n_s_reduce_ex, __pyx_k_reduce_ex, sizeof(__pyx_k_reduce_ex), 0, 0, 1, 1},
24815   {&__pyx_n_s_row, __pyx_k_row, sizeof(__pyx_k_row), 0, 0, 1, 1},
24816   {&__pyx_n_s_scipy_sparse, __pyx_k_scipy_sparse, sizeof(__pyx_k_scipy_sparse), 0, 0, 1, 1},
24817   {&__pyx_n_s_sec_cutoff, __pyx_k_sec_cutoff, sizeof(__pyx_k_sec_cutoff), 0, 0, 1, 1},
24818   {&__pyx_n_s_setstate, __pyx_k_setstate, sizeof(__pyx_k_setstate), 0, 0, 1, 1},
24819   {&__pyx_n_s_setstate_cython, __pyx_k_setstate_cython, sizeof(__pyx_k_setstate_cython), 0, 0, 1, 1},
24820   {&__pyx_n_s_shape, __pyx_k_shape, sizeof(__pyx_k_shape), 0, 0, 1, 1},
24821   {&__pyx_n_s_size, __pyx_k_size, sizeof(__pyx_k_size), 0, 0, 1, 1},
24822   {&__pyx_n_s_skew, __pyx_k_skew, sizeof(__pyx_k_skew), 0, 0, 1, 1},
24823   {&__pyx_n_s_sop_dims, __pyx_k_sop_dims, sizeof(__pyx_k_sop_dims), 0, 0, 1, 1},
24824   {&__pyx_n_s_spectra_cb, __pyx_k_spectra_cb, sizeof(__pyx_k_spectra_cb), 0, 0, 1, 1},
24825   {&__pyx_n_s_spectral, __pyx_k_spectral, sizeof(__pyx_k_spectral), 0, 0, 1, 1},
24826   {&__pyx_n_s_start, __pyx_k_start, sizeof(__pyx_k_start), 0, 0, 1, 1},
24827   {&__pyx_n_s_step, __pyx_k_step, sizeof(__pyx_k_step), 0, 0, 1, 1},
24828   {&__pyx_n_s_stop, __pyx_k_stop, sizeof(__pyx_k_stop), 0, 0, 1, 1},
24829   {&__pyx_kp_s_strided_and_direct, __pyx_k_strided_and_direct, sizeof(__pyx_k_strided_and_direct), 0, 0, 1, 0},
24830   {&__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},
24831   {&__pyx_kp_s_strided_and_indirect, __pyx_k_strided_and_indirect, sizeof(__pyx_k_strided_and_indirect), 0, 0, 1, 0},
24832   {&__pyx_kp_s_stringsource, __pyx_k_stringsource, sizeof(__pyx_k_stringsource), 0, 0, 1, 0},
24833   {&__pyx_n_s_struct, __pyx_k_struct, sizeof(__pyx_k_struct), 0, 0, 1, 1},
24834   {&__pyx_n_s_test, __pyx_k_test, sizeof(__pyx_k_test), 0, 0, 1, 1},
24835   {&__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},
24836   {&__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},
24837   {&__pyx_n_s_unpack, __pyx_k_unpack, sizeof(__pyx_k_unpack), 0, 0, 1, 1},
24838   {&__pyx_n_s_update, __pyx_k_update, sizeof(__pyx_k_update), 0, 0, 1, 1},
24839   {&__pyx_n_s_use_secular, __pyx_k_use_secular, sizeof(__pyx_k_use_secular), 0, 0, 1, 1},
24840   {&__pyx_n_s_warn, __pyx_k_warn, sizeof(__pyx_k_warn), 0, 0, 1, 1},
24841   {&__pyx_n_s_warnings, __pyx_k_warnings, sizeof(__pyx_k_warnings), 0, 0, 1, 1},
24842   {&__pyx_n_s_zeros, __pyx_k_zeros, sizeof(__pyx_k_zeros), 0, 0, 1, 1},
24843   {0, 0, 0, 0, 0, 0, 0}
24844 };
__Pyx_InitCachedBuiltins(void)24845 static CYTHON_SMALL_CODE int __Pyx_InitCachedBuiltins(void) {
24846   __pyx_builtin_MemoryError = __Pyx_GetBuiltinName(__pyx_n_s_MemoryError); if (!__pyx_builtin_MemoryError) __PYX_ERR(0, 66, __pyx_L1_error)
24847   __pyx_builtin_range = __Pyx_GetBuiltinName(__pyx_n_s_range); if (!__pyx_builtin_range) __PYX_ERR(0, 175, __pyx_L1_error)
24848   __pyx_builtin_DeprecationWarning = __Pyx_GetBuiltinName(__pyx_n_s_DeprecationWarning); if (!__pyx_builtin_DeprecationWarning) __PYX_ERR(1, 166, __pyx_L1_error)
24849   __pyx_builtin_enumerate = __Pyx_GetBuiltinName(__pyx_n_s_enumerate); if (!__pyx_builtin_enumerate) __PYX_ERR(1, 168, __pyx_L1_error)
24850   __pyx_builtin_TypeError = __Pyx_GetBuiltinName(__pyx_n_s_TypeError); if (!__pyx_builtin_TypeError) __PYX_ERR(1, 176, __pyx_L1_error)
24851   __pyx_builtin_ImportError = __Pyx_GetBuiltinName(__pyx_n_s_ImportError); if (!__pyx_builtin_ImportError) __PYX_ERR(2, 884, __pyx_L1_error)
24852   __pyx_builtin_ValueError = __Pyx_GetBuiltinName(__pyx_n_s_ValueError); if (!__pyx_builtin_ValueError) __PYX_ERR(3, 133, __pyx_L1_error)
24853   __pyx_builtin_Ellipsis = __Pyx_GetBuiltinName(__pyx_n_s_Ellipsis); if (!__pyx_builtin_Ellipsis) __PYX_ERR(3, 404, __pyx_L1_error)
24854   __pyx_builtin_id = __Pyx_GetBuiltinName(__pyx_n_s_id); if (!__pyx_builtin_id) __PYX_ERR(3, 613, __pyx_L1_error)
24855   __pyx_builtin_IndexError = __Pyx_GetBuiltinName(__pyx_n_s_IndexError); if (!__pyx_builtin_IndexError) __PYX_ERR(3, 832, __pyx_L1_error)
24856   return 0;
24857   __pyx_L1_error:;
24858   return -1;
24859 }
24860 
__Pyx_InitCachedConstants(void)24861 static CYTHON_SMALL_CODE int __Pyx_InitCachedConstants(void) {
24862   __Pyx_RefNannyDeclarations
24863   __Pyx_RefNannySetupContext("__Pyx_InitCachedConstants", 0);
24864 
24865   /* "qutip/cy/sparse_routines.pxi":66
24866  *         free_CSR(C)
24867  *     if E == -1:
24868  *         raise MemoryError('Could not allocate memory.')             # <<<<<<<<<<<<<<
24869  *     elif E == -2:
24870  *         raise Exception('Error manipulating CSR_Matrix structure.')
24871  */
24872   __pyx_tuple_ = PyTuple_Pack(1, __pyx_kp_u_Could_not_allocate_memory); if (unlikely(!__pyx_tuple_)) __PYX_ERR(0, 66, __pyx_L1_error)
24873   __Pyx_GOTREF(__pyx_tuple_);
24874   __Pyx_GIVEREF(__pyx_tuple_);
24875 
24876   /* "qutip/cy/sparse_routines.pxi":68
24877  *         raise MemoryError('Could not allocate memory.')
24878  *     elif E == -2:
24879  *         raise Exception('Error manipulating CSR_Matrix structure.')             # <<<<<<<<<<<<<<
24880  *     elif E == -3:
24881  *         raise Exception('CSR_Matrix is not initialized.')
24882  */
24883   __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)
24884   __Pyx_GOTREF(__pyx_tuple__2);
24885   __Pyx_GIVEREF(__pyx_tuple__2);
24886 
24887   /* "qutip/cy/sparse_routines.pxi":70
24888  *         raise Exception('Error manipulating CSR_Matrix structure.')
24889  *     elif E == -3:
24890  *         raise Exception('CSR_Matrix is not initialized.')             # <<<<<<<<<<<<<<
24891  *     elif E == -4:
24892  *         raise Exception('NumPy already has lock on data.')
24893  */
24894   __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)
24895   __Pyx_GOTREF(__pyx_tuple__3);
24896   __Pyx_GIVEREF(__pyx_tuple__3);
24897 
24898   /* "qutip/cy/sparse_routines.pxi":72
24899  *         raise Exception('CSR_Matrix is not initialized.')
24900  *     elif E == -4:
24901  *         raise Exception('NumPy already has lock on data.')             # <<<<<<<<<<<<<<
24902  *     elif E == -5:
24903  *         raise Exception('Cannot expand data structures past max_length.')
24904  */
24905   __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)
24906   __Pyx_GOTREF(__pyx_tuple__4);
24907   __Pyx_GIVEREF(__pyx_tuple__4);
24908 
24909   /* "qutip/cy/sparse_routines.pxi":74
24910  *         raise Exception('NumPy already has lock on data.')
24911  *     elif E == -5:
24912  *         raise Exception('Cannot expand data structures past max_length.')             # <<<<<<<<<<<<<<
24913  *     elif E == -6:
24914  *         raise Exception('CSR_Matrix cannot be expanded.')
24915  */
24916   __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)
24917   __Pyx_GOTREF(__pyx_tuple__5);
24918   __Pyx_GIVEREF(__pyx_tuple__5);
24919 
24920   /* "qutip/cy/sparse_routines.pxi":76
24921  *         raise Exception('Cannot expand data structures past max_length.')
24922  *     elif E == -6:
24923  *         raise Exception('CSR_Matrix cannot be expanded.')             # <<<<<<<<<<<<<<
24924  *     elif E == -7:
24925  *         raise Exception('Data length cannot be larger than max_length')
24926  */
24927   __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)
24928   __Pyx_GOTREF(__pyx_tuple__6);
24929   __Pyx_GIVEREF(__pyx_tuple__6);
24930 
24931   /* "qutip/cy/sparse_routines.pxi":78
24932  *         raise Exception('CSR_Matrix cannot be expanded.')
24933  *     elif E == -7:
24934  *         raise Exception('Data length cannot be larger than max_length')             # <<<<<<<<<<<<<<
24935  *     else:
24936  *         raise Exception('Error in Cython code.')
24937  */
24938   __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)
24939   __Pyx_GOTREF(__pyx_tuple__7);
24940   __Pyx_GIVEREF(__pyx_tuple__7);
24941 
24942   /* "qutip/cy/sparse_routines.pxi":80
24943  *         raise Exception('Data length cannot be larger than max_length')
24944  *     else:
24945  *         raise Exception('Error in Cython code.')             # <<<<<<<<<<<<<<
24946  *
24947  *
24948  */
24949   __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)
24950   __Pyx_GOTREF(__pyx_tuple__8);
24951   __Pyx_GIVEREF(__pyx_tuple__8);
24952 
24953   /* "qutip/cy/sparse_routines.pxi":89
24954  *         raise MemoryError('Could not allocate memory.')
24955  *     elif E == -2:
24956  *         raise Exception('Error manipulating COO_Matrix structure.')             # <<<<<<<<<<<<<<
24957  *     elif E == -3:
24958  *         raise Exception('COO_Matrix is not initialized.')
24959  */
24960   __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)
24961   __Pyx_GOTREF(__pyx_tuple__9);
24962   __Pyx_GIVEREF(__pyx_tuple__9);
24963 
24964   /* "qutip/cy/sparse_routines.pxi":91
24965  *         raise Exception('Error manipulating COO_Matrix structure.')
24966  *     elif E == -3:
24967  *         raise Exception('COO_Matrix is not initialized.')             # <<<<<<<<<<<<<<
24968  *     elif E == -4:
24969  *         raise Exception('NumPy already has lock on data.')
24970  */
24971   __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)
24972   __Pyx_GOTREF(__pyx_tuple__10);
24973   __Pyx_GIVEREF(__pyx_tuple__10);
24974 
24975   /* "qutip/cy/sparse_routines.pxi":97
24976  *         raise Exception('Cannot expand data structures past max_length.')
24977  *     elif E == -6:
24978  *         raise Exception('COO_Matrix cannot be expanded.')             # <<<<<<<<<<<<<<
24979  *     elif E == -7:
24980  *         raise Exception('Data length cannot be larger than max_length')
24981  */
24982   __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)
24983   __Pyx_GOTREF(__pyx_tuple__11);
24984   __Pyx_GIVEREF(__pyx_tuple__11);
24985 
24986   /* "qutip/cy/br_tensor.pyx":166
24987  *
24988  *      if not (spectra_cb is None):
24989  *          warnings.warn("The use of spectra_cb is depreciated.", DeprecationWarning)             # <<<<<<<<<<<<<<
24990  *          _a_ops = []
24991  *          for kk, a in enumerate(a_ops):
24992  */
24993   __pyx_tuple__14 = PyTuple_Pack(2, __pyx_kp_u_The_use_of_spectra_cb_is_depreci, __pyx_builtin_DeprecationWarning); if (unlikely(!__pyx_tuple__14)) __PYX_ERR(1, 166, __pyx_L1_error)
24994   __Pyx_GOTREF(__pyx_tuple__14);
24995   __Pyx_GIVEREF(__pyx_tuple__14);
24996 
24997   /* "qutip/cy/br_tensor.pyx":176
24998  *      # Sanity checks for input parameters
24999  *      if not isinstance(H, Qobj):
25000  *          raise TypeError("H must be an instance of Qobj")             # <<<<<<<<<<<<<<
25001  *
25002  *      for a in a_ops:
25003  */
25004   __pyx_tuple__15 = PyTuple_Pack(1, __pyx_kp_u_H_must_be_an_instance_of_Qobj); if (unlikely(!__pyx_tuple__15)) __PYX_ERR(1, 176, __pyx_L1_error)
25005   __Pyx_GOTREF(__pyx_tuple__15);
25006   __Pyx_GIVEREF(__pyx_tuple__15);
25007 
25008   /* "qutip/cy/br_tensor.pyx":180
25009  *      for a in a_ops:
25010  *          if not isinstance(a[0], Qobj) or not a[0].isherm:
25011  *              raise TypeError("Operators in a_ops must be Hermitian Qobj.")             # <<<<<<<<<<<<<<
25012  *
25013  *      cdef complex[::1,:] H0 = H.full('F')
25014  */
25015   __pyx_tuple__16 = PyTuple_Pack(1, __pyx_kp_u_Operators_in_a_ops_must_be_Hermi); if (unlikely(!__pyx_tuple__16)) __PYX_ERR(1, 180, __pyx_L1_error)
25016   __Pyx_GOTREF(__pyx_tuple__16);
25017   __Pyx_GIVEREF(__pyx_tuple__16);
25018 
25019   /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":884
25020  *         __pyx_import_array()
25021  *     except Exception:
25022  *         raise ImportError("numpy.core.multiarray failed to import")             # <<<<<<<<<<<<<<
25023  *
25024  * cdef inline int import_umath() except -1:
25025  */
25026   __pyx_tuple__17 = PyTuple_Pack(1, __pyx_kp_u_numpy_core_multiarray_failed_to); if (unlikely(!__pyx_tuple__17)) __PYX_ERR(2, 884, __pyx_L1_error)
25027   __Pyx_GOTREF(__pyx_tuple__17);
25028   __Pyx_GIVEREF(__pyx_tuple__17);
25029 
25030   /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":890
25031  *         _import_umath()
25032  *     except Exception:
25033  *         raise ImportError("numpy.core.umath failed to import")             # <<<<<<<<<<<<<<
25034  *
25035  * cdef inline int import_ufunc() except -1:
25036  */
25037   __pyx_tuple__18 = PyTuple_Pack(1, __pyx_kp_u_numpy_core_umath_failed_to_impor); if (unlikely(!__pyx_tuple__18)) __PYX_ERR(2, 890, __pyx_L1_error)
25038   __Pyx_GOTREF(__pyx_tuple__18);
25039   __Pyx_GIVEREF(__pyx_tuple__18);
25040 
25041   /* "View.MemoryView":133
25042  *
25043  *         if not self.ndim:
25044  *             raise ValueError("Empty shape tuple for cython.array")             # <<<<<<<<<<<<<<
25045  *
25046  *         if itemsize <= 0:
25047  */
25048   __pyx_tuple__19 = PyTuple_Pack(1, __pyx_kp_s_Empty_shape_tuple_for_cython_arr); if (unlikely(!__pyx_tuple__19)) __PYX_ERR(3, 133, __pyx_L1_error)
25049   __Pyx_GOTREF(__pyx_tuple__19);
25050   __Pyx_GIVEREF(__pyx_tuple__19);
25051 
25052   /* "View.MemoryView":136
25053  *
25054  *         if itemsize <= 0:
25055  *             raise ValueError("itemsize <= 0 for cython.array")             # <<<<<<<<<<<<<<
25056  *
25057  *         if not isinstance(format, bytes):
25058  */
25059   __pyx_tuple__20 = PyTuple_Pack(1, __pyx_kp_s_itemsize_0_for_cython_array); if (unlikely(!__pyx_tuple__20)) __PYX_ERR(3, 136, __pyx_L1_error)
25060   __Pyx_GOTREF(__pyx_tuple__20);
25061   __Pyx_GIVEREF(__pyx_tuple__20);
25062 
25063   /* "View.MemoryView":148
25064  *
25065  *         if not self._shape:
25066  *             raise MemoryError("unable to allocate shape and strides.")             # <<<<<<<<<<<<<<
25067  *
25068  *
25069  */
25070   __pyx_tuple__21 = PyTuple_Pack(1, __pyx_kp_s_unable_to_allocate_shape_and_str); if (unlikely(!__pyx_tuple__21)) __PYX_ERR(3, 148, __pyx_L1_error)
25071   __Pyx_GOTREF(__pyx_tuple__21);
25072   __Pyx_GIVEREF(__pyx_tuple__21);
25073 
25074   /* "View.MemoryView":176
25075  *             self.data = <char *>malloc(self.len)
25076  *             if not self.data:
25077  *                 raise MemoryError("unable to allocate array data.")             # <<<<<<<<<<<<<<
25078  *
25079  *             if self.dtype_is_object:
25080  */
25081   __pyx_tuple__22 = PyTuple_Pack(1, __pyx_kp_s_unable_to_allocate_array_data); if (unlikely(!__pyx_tuple__22)) __PYX_ERR(3, 176, __pyx_L1_error)
25082   __Pyx_GOTREF(__pyx_tuple__22);
25083   __Pyx_GIVEREF(__pyx_tuple__22);
25084 
25085   /* "View.MemoryView":192
25086  *             bufmode = PyBUF_F_CONTIGUOUS | PyBUF_ANY_CONTIGUOUS
25087  *         if not (flags & bufmode):
25088  *             raise ValueError("Can only create a buffer that is contiguous in memory.")             # <<<<<<<<<<<<<<
25089  *         info.buf = self.data
25090  *         info.len = self.len
25091  */
25092   __pyx_tuple__23 = PyTuple_Pack(1, __pyx_kp_s_Can_only_create_a_buffer_that_is); if (unlikely(!__pyx_tuple__23)) __PYX_ERR(3, 192, __pyx_L1_error)
25093   __Pyx_GOTREF(__pyx_tuple__23);
25094   __Pyx_GIVEREF(__pyx_tuple__23);
25095 
25096   /* "(tree fragment)":2
25097  * def __reduce_cython__(self):
25098  *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")             # <<<<<<<<<<<<<<
25099  * def __setstate_cython__(self, __pyx_state):
25100  *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
25101  */
25102   __pyx_tuple__24 = PyTuple_Pack(1, __pyx_kp_s_no_default___reduce___due_to_non); if (unlikely(!__pyx_tuple__24)) __PYX_ERR(3, 2, __pyx_L1_error)
25103   __Pyx_GOTREF(__pyx_tuple__24);
25104   __Pyx_GIVEREF(__pyx_tuple__24);
25105 
25106   /* "(tree fragment)":4
25107  *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
25108  * def __setstate_cython__(self, __pyx_state):
25109  *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")             # <<<<<<<<<<<<<<
25110  */
25111   __pyx_tuple__25 = PyTuple_Pack(1, __pyx_kp_s_no_default___reduce___due_to_non); if (unlikely(!__pyx_tuple__25)) __PYX_ERR(3, 4, __pyx_L1_error)
25112   __Pyx_GOTREF(__pyx_tuple__25);
25113   __Pyx_GIVEREF(__pyx_tuple__25);
25114 
25115   /* "View.MemoryView":418
25116  *     def __setitem__(memoryview self, object index, object value):
25117  *         if self.view.readonly:
25118  *             raise TypeError("Cannot assign to read-only memoryview")             # <<<<<<<<<<<<<<
25119  *
25120  *         have_slices, index = _unellipsify(index, self.view.ndim)
25121  */
25122   __pyx_tuple__26 = PyTuple_Pack(1, __pyx_kp_s_Cannot_assign_to_read_only_memor); if (unlikely(!__pyx_tuple__26)) __PYX_ERR(3, 418, __pyx_L1_error)
25123   __Pyx_GOTREF(__pyx_tuple__26);
25124   __Pyx_GIVEREF(__pyx_tuple__26);
25125 
25126   /* "View.MemoryView":495
25127  *             result = struct.unpack(self.view.format, bytesitem)
25128  *         except struct.error:
25129  *             raise ValueError("Unable to convert item to object")             # <<<<<<<<<<<<<<
25130  *         else:
25131  *             if len(self.view.format) == 1:
25132  */
25133   __pyx_tuple__27 = PyTuple_Pack(1, __pyx_kp_s_Unable_to_convert_item_to_object); if (unlikely(!__pyx_tuple__27)) __PYX_ERR(3, 495, __pyx_L1_error)
25134   __Pyx_GOTREF(__pyx_tuple__27);
25135   __Pyx_GIVEREF(__pyx_tuple__27);
25136 
25137   /* "View.MemoryView":520
25138  *     def __getbuffer__(self, Py_buffer *info, int flags):
25139  *         if flags & PyBUF_WRITABLE and self.view.readonly:
25140  *             raise ValueError("Cannot create writable memory view from read-only memoryview")             # <<<<<<<<<<<<<<
25141  *
25142  *         if flags & PyBUF_ND:
25143  */
25144   __pyx_tuple__28 = PyTuple_Pack(1, __pyx_kp_s_Cannot_create_writable_memory_vi); if (unlikely(!__pyx_tuple__28)) __PYX_ERR(3, 520, __pyx_L1_error)
25145   __Pyx_GOTREF(__pyx_tuple__28);
25146   __Pyx_GIVEREF(__pyx_tuple__28);
25147 
25148   /* "View.MemoryView":570
25149  *         if self.view.strides == NULL:
25150  *
25151  *             raise ValueError("Buffer view does not expose strides")             # <<<<<<<<<<<<<<
25152  *
25153  *         return tuple([stride for stride in self.view.strides[:self.view.ndim]])
25154  */
25155   __pyx_tuple__29 = PyTuple_Pack(1, __pyx_kp_s_Buffer_view_does_not_expose_stri); if (unlikely(!__pyx_tuple__29)) __PYX_ERR(3, 570, __pyx_L1_error)
25156   __Pyx_GOTREF(__pyx_tuple__29);
25157   __Pyx_GIVEREF(__pyx_tuple__29);
25158 
25159   /* "View.MemoryView":577
25160  *     def suboffsets(self):
25161  *         if self.view.suboffsets == NULL:
25162  *             return (-1,) * self.view.ndim             # <<<<<<<<<<<<<<
25163  *
25164  *         return tuple([suboffset for suboffset in self.view.suboffsets[:self.view.ndim]])
25165  */
25166   __pyx_tuple__30 = PyTuple_New(1); if (unlikely(!__pyx_tuple__30)) __PYX_ERR(3, 577, __pyx_L1_error)
25167   __Pyx_GOTREF(__pyx_tuple__30);
25168   __Pyx_INCREF(__pyx_int_neg_1);
25169   __Pyx_GIVEREF(__pyx_int_neg_1);
25170   PyTuple_SET_ITEM(__pyx_tuple__30, 0, __pyx_int_neg_1);
25171   __Pyx_GIVEREF(__pyx_tuple__30);
25172 
25173   /* "(tree fragment)":2
25174  * def __reduce_cython__(self):
25175  *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")             # <<<<<<<<<<<<<<
25176  * def __setstate_cython__(self, __pyx_state):
25177  *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
25178  */
25179   __pyx_tuple__31 = PyTuple_Pack(1, __pyx_kp_s_no_default___reduce___due_to_non); if (unlikely(!__pyx_tuple__31)) __PYX_ERR(3, 2, __pyx_L1_error)
25180   __Pyx_GOTREF(__pyx_tuple__31);
25181   __Pyx_GIVEREF(__pyx_tuple__31);
25182 
25183   /* "(tree fragment)":4
25184  *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
25185  * def __setstate_cython__(self, __pyx_state):
25186  *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")             # <<<<<<<<<<<<<<
25187  */
25188   __pyx_tuple__32 = PyTuple_Pack(1, __pyx_kp_s_no_default___reduce___due_to_non); if (unlikely(!__pyx_tuple__32)) __PYX_ERR(3, 4, __pyx_L1_error)
25189   __Pyx_GOTREF(__pyx_tuple__32);
25190   __Pyx_GIVEREF(__pyx_tuple__32);
25191 
25192   /* "View.MemoryView":682
25193  *         if item is Ellipsis:
25194  *             if not seen_ellipsis:
25195  *                 result.extend([slice(None)] * (ndim - len(tup) + 1))             # <<<<<<<<<<<<<<
25196  *                 seen_ellipsis = True
25197  *             else:
25198  */
25199   __pyx_slice__33 = PySlice_New(Py_None, Py_None, Py_None); if (unlikely(!__pyx_slice__33)) __PYX_ERR(3, 682, __pyx_L1_error)
25200   __Pyx_GOTREF(__pyx_slice__33);
25201   __Pyx_GIVEREF(__pyx_slice__33);
25202 
25203   /* "View.MemoryView":703
25204  *     for suboffset in suboffsets[:ndim]:
25205  *         if suboffset >= 0:
25206  *             raise ValueError("Indirect dimensions not supported")             # <<<<<<<<<<<<<<
25207  *
25208  *
25209  */
25210   __pyx_tuple__34 = PyTuple_Pack(1, __pyx_kp_s_Indirect_dimensions_not_supporte); if (unlikely(!__pyx_tuple__34)) __PYX_ERR(3, 703, __pyx_L1_error)
25211   __Pyx_GOTREF(__pyx_tuple__34);
25212   __Pyx_GIVEREF(__pyx_tuple__34);
25213 
25214   /* "(tree fragment)":2
25215  * def __reduce_cython__(self):
25216  *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")             # <<<<<<<<<<<<<<
25217  * def __setstate_cython__(self, __pyx_state):
25218  *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
25219  */
25220   __pyx_tuple__35 = PyTuple_Pack(1, __pyx_kp_s_no_default___reduce___due_to_non); if (unlikely(!__pyx_tuple__35)) __PYX_ERR(3, 2, __pyx_L1_error)
25221   __Pyx_GOTREF(__pyx_tuple__35);
25222   __Pyx_GIVEREF(__pyx_tuple__35);
25223 
25224   /* "(tree fragment)":4
25225  *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
25226  * def __setstate_cython__(self, __pyx_state):
25227  *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")             # <<<<<<<<<<<<<<
25228  */
25229   __pyx_tuple__36 = PyTuple_Pack(1, __pyx_kp_s_no_default___reduce___due_to_non); if (unlikely(!__pyx_tuple__36)) __PYX_ERR(3, 4, __pyx_L1_error)
25230   __Pyx_GOTREF(__pyx_tuple__36);
25231   __Pyx_GIVEREF(__pyx_tuple__36);
25232 
25233   /* "qutip/cy/br_tensor.pyx":50
25234  * @cython.boundscheck(False)
25235  * @cython.wraparound(False)
25236  * def _br_term(complex[::1,:] A, complex[::1,:] evecs,             # <<<<<<<<<<<<<<
25237  *                 double[:,::1] skew, double dw_min, object spectral,
25238  *                 unsigned int nrows, int use_secular, double sec_cutoff,
25239  */
25240   __pyx_tuple__38 = PyTuple_Pack(24, __pyx_n_s_A, __pyx_n_s_evecs, __pyx_n_s_skew, __pyx_n_s_dw_min, __pyx_n_s_spectral, __pyx_n_s_nrows, __pyx_n_s_use_secular, __pyx_n_s_sec_cutoff, __pyx_n_s_atol, __pyx_n_s_kk, __pyx_n_s_I, __pyx_n_s_J, __pyx_n_s_ab, __pyx_n_s_cd, __pyx_n_s_A_eig, __pyx_n_s_elem, __pyx_n_s_ac_elem, __pyx_n_s_bd_elem, __pyx_n_s_coo_rows, __pyx_n_s_coo_cols, __pyx_n_s_coo_data, __pyx_n_s_nnz, __pyx_n_s_coo, __pyx_n_s_csr); if (unlikely(!__pyx_tuple__38)) __PYX_ERR(1, 50, __pyx_L1_error)
25241   __Pyx_GOTREF(__pyx_tuple__38);
25242   __Pyx_GIVEREF(__pyx_tuple__38);
25243   __pyx_codeobj__39 = (PyObject*)__Pyx_PyCode_New(9, 0, 24, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__38, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_qutip_cy_br_tensor_pyx, __pyx_n_s_br_term, 50, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__39)) __PYX_ERR(1, 50, __pyx_L1_error)
25244 
25245   /* "qutip/cy/br_tensor.pyx":110
25246  * @cython.boundscheck(False)
25247  * @cython.wraparound(False)
25248  * def bloch_redfield_tensor(object H, list a_ops, spectra_cb=None,             # <<<<<<<<<<<<<<
25249  *                  list c_ops=[], bool use_secular=True,
25250  *                  double sec_cutoff=0.1,
25251  */
25252   __pyx_tuple__40 = PyTuple_Pack(25, __pyx_n_s_H, __pyx_n_s_a_ops, __pyx_n_s_spectra_cb, __pyx_n_s_c_ops, __pyx_n_s_use_secular, __pyx_n_s_sec_cutoff, __pyx_n_s_atol, __pyx_n_s_a_ops_2, __pyx_n_s_a, __pyx_n_s_cop, __pyx_n_s_L, __pyx_n_s_K, __pyx_n_s_kk, __pyx_n_s_nrows, __pyx_n_s_op_dims, __pyx_n_s_sop_dims, __pyx_n_s_ekets, __pyx_n_s_ket_dims, __pyx_n_s_H0, __pyx_n_s_evecs, __pyx_n_s_evals, __pyx_n_s_skew, __pyx_n_s_dw_min, __pyx_n_s_k, __pyx_n_s_k); if (unlikely(!__pyx_tuple__40)) __PYX_ERR(1, 110, __pyx_L1_error)
25253   __Pyx_GOTREF(__pyx_tuple__40);
25254   __Pyx_GIVEREF(__pyx_tuple__40);
25255   __pyx_codeobj__41 = (PyObject*)__Pyx_PyCode_New(7, 0, 25, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__40, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_qutip_cy_br_tensor_pyx, __pyx_n_s_bloch_redfield_tensor, 110, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__41)) __PYX_ERR(1, 110, __pyx_L1_error)
25256 
25257   /* "View.MemoryView":286
25258  *         return self.name
25259  *
25260  * cdef generic = Enum("<strided and direct or indirect>")             # <<<<<<<<<<<<<<
25261  * cdef strided = Enum("<strided and direct>") # default
25262  * cdef indirect = Enum("<strided and indirect>")
25263  */
25264   __pyx_tuple__42 = PyTuple_Pack(1, __pyx_kp_s_strided_and_direct_or_indirect); if (unlikely(!__pyx_tuple__42)) __PYX_ERR(3, 286, __pyx_L1_error)
25265   __Pyx_GOTREF(__pyx_tuple__42);
25266   __Pyx_GIVEREF(__pyx_tuple__42);
25267 
25268   /* "View.MemoryView":287
25269  *
25270  * cdef generic = Enum("<strided and direct or indirect>")
25271  * cdef strided = Enum("<strided and direct>") # default             # <<<<<<<<<<<<<<
25272  * cdef indirect = Enum("<strided and indirect>")
25273  *
25274  */
25275   __pyx_tuple__43 = PyTuple_Pack(1, __pyx_kp_s_strided_and_direct); if (unlikely(!__pyx_tuple__43)) __PYX_ERR(3, 287, __pyx_L1_error)
25276   __Pyx_GOTREF(__pyx_tuple__43);
25277   __Pyx_GIVEREF(__pyx_tuple__43);
25278 
25279   /* "View.MemoryView":288
25280  * cdef generic = Enum("<strided and direct or indirect>")
25281  * cdef strided = Enum("<strided and direct>") # default
25282  * cdef indirect = Enum("<strided and indirect>")             # <<<<<<<<<<<<<<
25283  *
25284  *
25285  */
25286   __pyx_tuple__44 = PyTuple_Pack(1, __pyx_kp_s_strided_and_indirect); if (unlikely(!__pyx_tuple__44)) __PYX_ERR(3, 288, __pyx_L1_error)
25287   __Pyx_GOTREF(__pyx_tuple__44);
25288   __Pyx_GIVEREF(__pyx_tuple__44);
25289 
25290   /* "View.MemoryView":291
25291  *
25292  *
25293  * cdef contiguous = Enum("<contiguous and direct>")             # <<<<<<<<<<<<<<
25294  * cdef indirect_contiguous = Enum("<contiguous and indirect>")
25295  *
25296  */
25297   __pyx_tuple__45 = PyTuple_Pack(1, __pyx_kp_s_contiguous_and_direct); if (unlikely(!__pyx_tuple__45)) __PYX_ERR(3, 291, __pyx_L1_error)
25298   __Pyx_GOTREF(__pyx_tuple__45);
25299   __Pyx_GIVEREF(__pyx_tuple__45);
25300 
25301   /* "View.MemoryView":292
25302  *
25303  * cdef contiguous = Enum("<contiguous and direct>")
25304  * cdef indirect_contiguous = Enum("<contiguous and indirect>")             # <<<<<<<<<<<<<<
25305  *
25306  *
25307  */
25308   __pyx_tuple__46 = PyTuple_Pack(1, __pyx_kp_s_contiguous_and_indirect); if (unlikely(!__pyx_tuple__46)) __PYX_ERR(3, 292, __pyx_L1_error)
25309   __Pyx_GOTREF(__pyx_tuple__46);
25310   __Pyx_GIVEREF(__pyx_tuple__46);
25311 
25312   /* "(tree fragment)":1
25313  * def __pyx_unpickle_Enum(__pyx_type, long __pyx_checksum, __pyx_state):             # <<<<<<<<<<<<<<
25314  *     cdef object __pyx_PickleError
25315  *     cdef object __pyx_result
25316  */
25317   __pyx_tuple__47 = 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__47)) __PYX_ERR(3, 1, __pyx_L1_error)
25318   __Pyx_GOTREF(__pyx_tuple__47);
25319   __Pyx_GIVEREF(__pyx_tuple__47);
25320   __pyx_codeobj__48 = (PyObject*)__Pyx_PyCode_New(3, 0, 5, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__47, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_stringsource, __pyx_n_s_pyx_unpickle_Enum, 1, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__48)) __PYX_ERR(3, 1, __pyx_L1_error)
25321   __Pyx_RefNannyFinishContext();
25322   return 0;
25323   __pyx_L1_error:;
25324   __Pyx_RefNannyFinishContext();
25325   return -1;
25326 }
25327 
__Pyx_InitGlobals(void)25328 static CYTHON_SMALL_CODE int __Pyx_InitGlobals(void) {
25329   if (__Pyx_InitStrings(__pyx_string_tab) < 0) __PYX_ERR(1, 1, __pyx_L1_error);
25330   __pyx_int_0 = PyInt_FromLong(0); if (unlikely(!__pyx_int_0)) __PYX_ERR(1, 1, __pyx_L1_error)
25331   __pyx_int_1 = PyInt_FromLong(1); if (unlikely(!__pyx_int_1)) __PYX_ERR(1, 1, __pyx_L1_error)
25332   __pyx_int_184977713 = PyInt_FromLong(184977713L); if (unlikely(!__pyx_int_184977713)) __PYX_ERR(1, 1, __pyx_L1_error)
25333   __pyx_int_neg_1 = PyInt_FromLong(-1); if (unlikely(!__pyx_int_neg_1)) __PYX_ERR(1, 1, __pyx_L1_error)
25334   return 0;
25335   __pyx_L1_error:;
25336   return -1;
25337 }
25338 
25339 static CYTHON_SMALL_CODE int __Pyx_modinit_global_init_code(void); /*proto*/
25340 static CYTHON_SMALL_CODE int __Pyx_modinit_variable_export_code(void); /*proto*/
25341 static CYTHON_SMALL_CODE int __Pyx_modinit_function_export_code(void); /*proto*/
25342 static CYTHON_SMALL_CODE int __Pyx_modinit_type_init_code(void); /*proto*/
25343 static CYTHON_SMALL_CODE int __Pyx_modinit_type_import_code(void); /*proto*/
25344 static CYTHON_SMALL_CODE int __Pyx_modinit_variable_import_code(void); /*proto*/
25345 static CYTHON_SMALL_CODE int __Pyx_modinit_function_import_code(void); /*proto*/
25346 
__Pyx_modinit_global_init_code(void)25347 static int __Pyx_modinit_global_init_code(void) {
25348   __Pyx_RefNannyDeclarations
25349   __Pyx_RefNannySetupContext("__Pyx_modinit_global_init_code", 0);
25350   /*--- Global init code ---*/
25351   generic = Py_None; Py_INCREF(Py_None);
25352   strided = Py_None; Py_INCREF(Py_None);
25353   indirect = Py_None; Py_INCREF(Py_None);
25354   contiguous = Py_None; Py_INCREF(Py_None);
25355   indirect_contiguous = Py_None; Py_INCREF(Py_None);
25356   __Pyx_RefNannyFinishContext();
25357   return 0;
25358 }
25359 
__Pyx_modinit_variable_export_code(void)25360 static int __Pyx_modinit_variable_export_code(void) {
25361   __Pyx_RefNannyDeclarations
25362   __Pyx_RefNannySetupContext("__Pyx_modinit_variable_export_code", 0);
25363   /*--- Variable export code ---*/
25364   __Pyx_RefNannyFinishContext();
25365   return 0;
25366 }
25367 
__Pyx_modinit_function_export_code(void)25368 static int __Pyx_modinit_function_export_code(void) {
25369   __Pyx_RefNannyDeclarations
25370   __Pyx_RefNannySetupContext("__Pyx_modinit_function_export_code", 0);
25371   /*--- Function export code ---*/
25372   __Pyx_RefNannyFinishContext();
25373   return 0;
25374 }
25375 
__Pyx_modinit_type_init_code(void)25376 static int __Pyx_modinit_type_init_code(void) {
25377   __Pyx_RefNannyDeclarations
25378   int __pyx_lineno = 0;
25379   const char *__pyx_filename = NULL;
25380   int __pyx_clineno = 0;
25381   __Pyx_RefNannySetupContext("__Pyx_modinit_type_init_code", 0);
25382   /*--- Type init code ---*/
25383   __pyx_vtabptr_array = &__pyx_vtable_array;
25384   __pyx_vtable_array.get_memview = (PyObject *(*)(struct __pyx_array_obj *))__pyx_array_get_memview;
25385   if (PyType_Ready(&__pyx_type___pyx_array) < 0) __PYX_ERR(3, 105, __pyx_L1_error)
25386   #if PY_VERSION_HEX < 0x030800B1
25387   __pyx_type___pyx_array.tp_print = 0;
25388   #endif
25389   if (__Pyx_SetVtable(__pyx_type___pyx_array.tp_dict, __pyx_vtabptr_array) < 0) __PYX_ERR(3, 105, __pyx_L1_error)
25390   if (__Pyx_setup_reduce((PyObject*)&__pyx_type___pyx_array) < 0) __PYX_ERR(3, 105, __pyx_L1_error)
25391   __pyx_array_type = &__pyx_type___pyx_array;
25392   if (PyType_Ready(&__pyx_type___pyx_MemviewEnum) < 0) __PYX_ERR(3, 279, __pyx_L1_error)
25393   #if PY_VERSION_HEX < 0x030800B1
25394   __pyx_type___pyx_MemviewEnum.tp_print = 0;
25395   #endif
25396   if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type___pyx_MemviewEnum.tp_dictoffset && __pyx_type___pyx_MemviewEnum.tp_getattro == PyObject_GenericGetAttr)) {
25397     __pyx_type___pyx_MemviewEnum.tp_getattro = __Pyx_PyObject_GenericGetAttr;
25398   }
25399   if (__Pyx_setup_reduce((PyObject*)&__pyx_type___pyx_MemviewEnum) < 0) __PYX_ERR(3, 279, __pyx_L1_error)
25400   __pyx_MemviewEnum_type = &__pyx_type___pyx_MemviewEnum;
25401   __pyx_vtabptr_memoryview = &__pyx_vtable_memoryview;
25402   __pyx_vtable_memoryview.get_item_pointer = (char *(*)(struct __pyx_memoryview_obj *, PyObject *))__pyx_memoryview_get_item_pointer;
25403   __pyx_vtable_memoryview.is_slice = (PyObject *(*)(struct __pyx_memoryview_obj *, PyObject *))__pyx_memoryview_is_slice;
25404   __pyx_vtable_memoryview.setitem_slice_assignment = (PyObject *(*)(struct __pyx_memoryview_obj *, PyObject *, PyObject *))__pyx_memoryview_setitem_slice_assignment;
25405   __pyx_vtable_memoryview.setitem_slice_assign_scalar = (PyObject *(*)(struct __pyx_memoryview_obj *, struct __pyx_memoryview_obj *, PyObject *))__pyx_memoryview_setitem_slice_assign_scalar;
25406   __pyx_vtable_memoryview.setitem_indexed = (PyObject *(*)(struct __pyx_memoryview_obj *, PyObject *, PyObject *))__pyx_memoryview_setitem_indexed;
25407   __pyx_vtable_memoryview.convert_item_to_object = (PyObject *(*)(struct __pyx_memoryview_obj *, char *))__pyx_memoryview_convert_item_to_object;
25408   __pyx_vtable_memoryview.assign_item_from_object = (PyObject *(*)(struct __pyx_memoryview_obj *, char *, PyObject *))__pyx_memoryview_assign_item_from_object;
25409   if (PyType_Ready(&__pyx_type___pyx_memoryview) < 0) __PYX_ERR(3, 330, __pyx_L1_error)
25410   #if PY_VERSION_HEX < 0x030800B1
25411   __pyx_type___pyx_memoryview.tp_print = 0;
25412   #endif
25413   if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type___pyx_memoryview.tp_dictoffset && __pyx_type___pyx_memoryview.tp_getattro == PyObject_GenericGetAttr)) {
25414     __pyx_type___pyx_memoryview.tp_getattro = __Pyx_PyObject_GenericGetAttr;
25415   }
25416   if (__Pyx_SetVtable(__pyx_type___pyx_memoryview.tp_dict, __pyx_vtabptr_memoryview) < 0) __PYX_ERR(3, 330, __pyx_L1_error)
25417   if (__Pyx_setup_reduce((PyObject*)&__pyx_type___pyx_memoryview) < 0) __PYX_ERR(3, 330, __pyx_L1_error)
25418   __pyx_memoryview_type = &__pyx_type___pyx_memoryview;
25419   __pyx_vtabptr__memoryviewslice = &__pyx_vtable__memoryviewslice;
25420   __pyx_vtable__memoryviewslice.__pyx_base = *__pyx_vtabptr_memoryview;
25421   __pyx_vtable__memoryviewslice.__pyx_base.convert_item_to_object = (PyObject *(*)(struct __pyx_memoryview_obj *, char *))__pyx_memoryviewslice_convert_item_to_object;
25422   __pyx_vtable__memoryviewslice.__pyx_base.assign_item_from_object = (PyObject *(*)(struct __pyx_memoryview_obj *, char *, PyObject *))__pyx_memoryviewslice_assign_item_from_object;
25423   __pyx_type___pyx_memoryviewslice.tp_base = __pyx_memoryview_type;
25424   if (PyType_Ready(&__pyx_type___pyx_memoryviewslice) < 0) __PYX_ERR(3, 965, __pyx_L1_error)
25425   #if PY_VERSION_HEX < 0x030800B1
25426   __pyx_type___pyx_memoryviewslice.tp_print = 0;
25427   #endif
25428   if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type___pyx_memoryviewslice.tp_dictoffset && __pyx_type___pyx_memoryviewslice.tp_getattro == PyObject_GenericGetAttr)) {
25429     __pyx_type___pyx_memoryviewslice.tp_getattro = __Pyx_PyObject_GenericGetAttr;
25430   }
25431   if (__Pyx_SetVtable(__pyx_type___pyx_memoryviewslice.tp_dict, __pyx_vtabptr__memoryviewslice) < 0) __PYX_ERR(3, 965, __pyx_L1_error)
25432   if (__Pyx_setup_reduce((PyObject*)&__pyx_type___pyx_memoryviewslice) < 0) __PYX_ERR(3, 965, __pyx_L1_error)
25433   __pyx_memoryviewslice_type = &__pyx_type___pyx_memoryviewslice;
25434   __Pyx_RefNannyFinishContext();
25435   return 0;
25436   __pyx_L1_error:;
25437   __Pyx_RefNannyFinishContext();
25438   return -1;
25439 }
25440 
__Pyx_modinit_type_import_code(void)25441 static int __Pyx_modinit_type_import_code(void) {
25442   __Pyx_RefNannyDeclarations
25443   PyObject *__pyx_t_1 = NULL;
25444   int __pyx_lineno = 0;
25445   const char *__pyx_filename = NULL;
25446   int __pyx_clineno = 0;
25447   __Pyx_RefNannySetupContext("__Pyx_modinit_type_import_code", 0);
25448   /*--- Type import code ---*/
25449   __pyx_t_1 = PyImport_ImportModule(__Pyx_BUILTIN_MODULE_NAME); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 9, __pyx_L1_error)
25450   __Pyx_GOTREF(__pyx_t_1);
25451   __pyx_ptype_7cpython_4type_type = __Pyx_ImportType(__pyx_t_1, __Pyx_BUILTIN_MODULE_NAME, "type",
25452   #if defined(PYPY_VERSION_NUM) && PYPY_VERSION_NUM < 0x050B0000
25453   sizeof(PyTypeObject),
25454   #else
25455   sizeof(PyHeapTypeObject),
25456   #endif
25457   __Pyx_ImportType_CheckSize_Warn);
25458    if (!__pyx_ptype_7cpython_4type_type) __PYX_ERR(4, 9, __pyx_L1_error)
25459   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
25460   __pyx_t_1 = PyImport_ImportModule("numpy"); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 199, __pyx_L1_error)
25461   __Pyx_GOTREF(__pyx_t_1);
25462   __pyx_ptype_5numpy_dtype = __Pyx_ImportType(__pyx_t_1, "numpy", "dtype", sizeof(PyArray_Descr), __Pyx_ImportType_CheckSize_Ignore);
25463    if (!__pyx_ptype_5numpy_dtype) __PYX_ERR(2, 199, __pyx_L1_error)
25464   __pyx_ptype_5numpy_flatiter = __Pyx_ImportType(__pyx_t_1, "numpy", "flatiter", sizeof(PyArrayIterObject), __Pyx_ImportType_CheckSize_Ignore);
25465    if (!__pyx_ptype_5numpy_flatiter) __PYX_ERR(2, 222, __pyx_L1_error)
25466   __pyx_ptype_5numpy_broadcast = __Pyx_ImportType(__pyx_t_1, "numpy", "broadcast", sizeof(PyArrayMultiIterObject), __Pyx_ImportType_CheckSize_Ignore);
25467    if (!__pyx_ptype_5numpy_broadcast) __PYX_ERR(2, 226, __pyx_L1_error)
25468   __pyx_ptype_5numpy_ndarray = __Pyx_ImportType(__pyx_t_1, "numpy", "ndarray", sizeof(PyArrayObject), __Pyx_ImportType_CheckSize_Ignore);
25469    if (!__pyx_ptype_5numpy_ndarray) __PYX_ERR(2, 238, __pyx_L1_error)
25470   __pyx_ptype_5numpy_ufunc = __Pyx_ImportType(__pyx_t_1, "numpy", "ufunc", sizeof(PyUFuncObject), __Pyx_ImportType_CheckSize_Ignore);
25471    if (!__pyx_ptype_5numpy_ufunc) __PYX_ERR(2, 764, __pyx_L1_error)
25472   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
25473   __Pyx_RefNannyFinishContext();
25474   return 0;
25475   __pyx_L1_error:;
25476   __Pyx_XDECREF(__pyx_t_1);
25477   __Pyx_RefNannyFinishContext();
25478   return -1;
25479 }
25480 
__Pyx_modinit_variable_import_code(void)25481 static int __Pyx_modinit_variable_import_code(void) {
25482   __Pyx_RefNannyDeclarations
25483   __Pyx_RefNannySetupContext("__Pyx_modinit_variable_import_code", 0);
25484   /*--- Variable import code ---*/
25485   __Pyx_RefNannyFinishContext();
25486   return 0;
25487 }
25488 
__Pyx_modinit_function_import_code(void)25489 static int __Pyx_modinit_function_import_code(void) {
25490   __Pyx_RefNannyDeclarations
25491   PyObject *__pyx_t_1 = NULL;
25492   int __pyx_lineno = 0;
25493   const char *__pyx_filename = NULL;
25494   int __pyx_clineno = 0;
25495   __Pyx_RefNannySetupContext("__Pyx_modinit_function_import_code", 0);
25496   /*--- Function import code ---*/
25497   __pyx_t_1 = PyImport_ImportModule("qutip.cy.brtools"); if (!__pyx_t_1) __PYX_ERR(1, 1, __pyx_L1_error)
25498   __Pyx_GOTREF(__pyx_t_1);
25499   if (__Pyx_ImportFunction(__pyx_t_1, "ZHEEVR", (void (**)(void))&__pyx_f_5qutip_2cy_7brtools_ZHEEVR, "void (__Pyx_memviewslice, double *, __Pyx_memviewslice, int)") < 0) __PYX_ERR(1, 1, __pyx_L1_error)
25500   if (__Pyx_ImportFunction(__pyx_t_1, "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)
25501   if (__Pyx_ImportFunction(__pyx_t_1, "vec2mat_index", (void (**)(void))&__pyx_f_5qutip_2cy_7brtools_vec2mat_index, "void (int, int, int *)") < 0) __PYX_ERR(1, 1, __pyx_L1_error)
25502   if (__Pyx_ImportFunction(__pyx_t_1, "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)
25503   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
25504   __Pyx_RefNannyFinishContext();
25505   return 0;
25506   __pyx_L1_error:;
25507   __Pyx_XDECREF(__pyx_t_1);
25508   __Pyx_RefNannyFinishContext();
25509   return -1;
25510 }
25511 
25512 
25513 #ifndef CYTHON_NO_PYINIT_EXPORT
25514 #define __Pyx_PyMODINIT_FUNC PyMODINIT_FUNC
25515 #elif PY_MAJOR_VERSION < 3
25516 #ifdef __cplusplus
25517 #define __Pyx_PyMODINIT_FUNC extern "C" void
25518 #else
25519 #define __Pyx_PyMODINIT_FUNC void
25520 #endif
25521 #else
25522 #ifdef __cplusplus
25523 #define __Pyx_PyMODINIT_FUNC extern "C" PyObject *
25524 #else
25525 #define __Pyx_PyMODINIT_FUNC PyObject *
25526 #endif
25527 #endif
25528 
25529 
25530 #if PY_MAJOR_VERSION < 3
25531 __Pyx_PyMODINIT_FUNC initbr_tensor(void) CYTHON_SMALL_CODE; /*proto*/
initbr_tensor(void)25532 __Pyx_PyMODINIT_FUNC initbr_tensor(void)
25533 #else
25534 __Pyx_PyMODINIT_FUNC PyInit_br_tensor(void) CYTHON_SMALL_CODE; /*proto*/
25535 __Pyx_PyMODINIT_FUNC PyInit_br_tensor(void)
25536 #if CYTHON_PEP489_MULTI_PHASE_INIT
25537 {
25538   return PyModuleDef_Init(&__pyx_moduledef);
25539 }
25540 static CYTHON_SMALL_CODE int __Pyx_check_single_interpreter(void) {
25541     #if PY_VERSION_HEX >= 0x030700A1
25542     static PY_INT64_T main_interpreter_id = -1;
25543     PY_INT64_T current_id = PyInterpreterState_GetID(PyThreadState_Get()->interp);
25544     if (main_interpreter_id == -1) {
25545         main_interpreter_id = current_id;
25546         return (unlikely(current_id == -1)) ? -1 : 0;
25547     } else if (unlikely(main_interpreter_id != current_id))
25548     #else
25549     static PyInterpreterState *main_interpreter = NULL;
25550     PyInterpreterState *current_interpreter = PyThreadState_Get()->interp;
25551     if (!main_interpreter) {
25552         main_interpreter = current_interpreter;
25553     } else if (unlikely(main_interpreter != current_interpreter))
25554     #endif
25555     {
25556         PyErr_SetString(
25557             PyExc_ImportError,
25558             "Interpreter change detected - this module can only be loaded into one interpreter per process.");
25559         return -1;
25560     }
25561     return 0;
25562 }
25563 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) {
25564     PyObject *value = PyObject_GetAttrString(spec, from_name);
25565     int result = 0;
25566     if (likely(value)) {
25567         if (allow_none || value != Py_None) {
25568             result = PyDict_SetItemString(moddict, to_name, value);
25569         }
25570         Py_DECREF(value);
25571     } else if (PyErr_ExceptionMatches(PyExc_AttributeError)) {
25572         PyErr_Clear();
25573     } else {
25574         result = -1;
25575     }
25576     return result;
25577 }
25578 static CYTHON_SMALL_CODE PyObject* __pyx_pymod_create(PyObject *spec, CYTHON_UNUSED PyModuleDef *def) {
25579     PyObject *module = NULL, *moddict, *modname;
25580     if (__Pyx_check_single_interpreter())
25581         return NULL;
25582     if (__pyx_m)
25583         return __Pyx_NewRef(__pyx_m);
25584     modname = PyObject_GetAttrString(spec, "name");
25585     if (unlikely(!modname)) goto bad;
25586     module = PyModule_NewObject(modname);
25587     Py_DECREF(modname);
25588     if (unlikely(!module)) goto bad;
25589     moddict = PyModule_GetDict(module);
25590     if (unlikely(!moddict)) goto bad;
25591     if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "loader", "__loader__", 1) < 0)) goto bad;
25592     if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "origin", "__file__", 1) < 0)) goto bad;
25593     if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "parent", "__package__", 1) < 0)) goto bad;
25594     if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "submodule_search_locations", "__path__", 0) < 0)) goto bad;
25595     return module;
25596 bad:
25597     Py_XDECREF(module);
25598     return NULL;
25599 }
25600 
25601 
25602 static CYTHON_SMALL_CODE int __pyx_pymod_exec_br_tensor(PyObject *__pyx_pyinit_module)
25603 #endif
25604 #endif
25605 {
25606   PyObject *__pyx_t_1 = NULL;
25607   PyObject *__pyx_t_2 = NULL;
25608   int __pyx_t_3;
25609   double __pyx_t_4;
25610   static PyThread_type_lock __pyx_t_5[8];
25611   int __pyx_lineno = 0;
25612   const char *__pyx_filename = NULL;
25613   int __pyx_clineno = 0;
25614   __Pyx_RefNannyDeclarations
25615   #if CYTHON_PEP489_MULTI_PHASE_INIT
25616   if (__pyx_m) {
25617     if (__pyx_m == __pyx_pyinit_module) return 0;
25618     PyErr_SetString(PyExc_RuntimeError, "Module 'br_tensor' has already been imported. Re-initialisation is not supported.");
25619     return -1;
25620   }
25621   #elif PY_MAJOR_VERSION >= 3
25622   if (__pyx_m) return __Pyx_NewRef(__pyx_m);
25623   #endif
25624   #if CYTHON_REFNANNY
25625 __Pyx_RefNanny = __Pyx_RefNannyImportAPI("refnanny");
25626 if (!__Pyx_RefNanny) {
25627   PyErr_Clear();
25628   __Pyx_RefNanny = __Pyx_RefNannyImportAPI("Cython.Runtime.refnanny");
25629   if (!__Pyx_RefNanny)
25630       Py_FatalError("failed to import 'refnanny' module");
25631 }
25632 #endif
25633   __Pyx_RefNannySetupContext("__Pyx_PyMODINIT_FUNC PyInit_br_tensor(void)", 0);
25634   if (__Pyx_check_binary_version() < 0) __PYX_ERR(1, 1, __pyx_L1_error)
25635   #ifdef __Pxy_PyFrame_Initialize_Offsets
25636   __Pxy_PyFrame_Initialize_Offsets();
25637   #endif
25638   __pyx_empty_tuple = PyTuple_New(0); if (unlikely(!__pyx_empty_tuple)) __PYX_ERR(1, 1, __pyx_L1_error)
25639   __pyx_empty_bytes = PyBytes_FromStringAndSize("", 0); if (unlikely(!__pyx_empty_bytes)) __PYX_ERR(1, 1, __pyx_L1_error)
25640   __pyx_empty_unicode = PyUnicode_FromStringAndSize("", 0); if (unlikely(!__pyx_empty_unicode)) __PYX_ERR(1, 1, __pyx_L1_error)
25641   #ifdef __Pyx_CyFunction_USED
25642   if (__pyx_CyFunction_init() < 0) __PYX_ERR(1, 1, __pyx_L1_error)
25643   #endif
25644   #ifdef __Pyx_FusedFunction_USED
25645   if (__pyx_FusedFunction_init() < 0) __PYX_ERR(1, 1, __pyx_L1_error)
25646   #endif
25647   #ifdef __Pyx_Coroutine_USED
25648   if (__pyx_Coroutine_init() < 0) __PYX_ERR(1, 1, __pyx_L1_error)
25649   #endif
25650   #ifdef __Pyx_Generator_USED
25651   if (__pyx_Generator_init() < 0) __PYX_ERR(1, 1, __pyx_L1_error)
25652   #endif
25653   #ifdef __Pyx_AsyncGen_USED
25654   if (__pyx_AsyncGen_init() < 0) __PYX_ERR(1, 1, __pyx_L1_error)
25655   #endif
25656   #ifdef __Pyx_StopAsyncIteration_USED
25657   if (__pyx_StopAsyncIteration_init() < 0) __PYX_ERR(1, 1, __pyx_L1_error)
25658   #endif
25659   /*--- Library function declarations ---*/
25660   /*--- Threads initialization code ---*/
25661   #if defined(__PYX_FORCE_INIT_THREADS) && __PYX_FORCE_INIT_THREADS
25662   #ifdef WITH_THREAD /* Python build with threading support? */
25663   PyEval_InitThreads();
25664   #endif
25665   #endif
25666   /*--- Module creation code ---*/
25667   #if CYTHON_PEP489_MULTI_PHASE_INIT
25668   __pyx_m = __pyx_pyinit_module;
25669   Py_INCREF(__pyx_m);
25670   #else
25671   #if PY_MAJOR_VERSION < 3
25672   __pyx_m = Py_InitModule4("br_tensor", __pyx_methods, 0, 0, PYTHON_API_VERSION); Py_XINCREF(__pyx_m);
25673   #else
25674   __pyx_m = PyModule_Create(&__pyx_moduledef);
25675   #endif
25676   if (unlikely(!__pyx_m)) __PYX_ERR(1, 1, __pyx_L1_error)
25677   #endif
25678   __pyx_d = PyModule_GetDict(__pyx_m); if (unlikely(!__pyx_d)) __PYX_ERR(1, 1, __pyx_L1_error)
25679   Py_INCREF(__pyx_d);
25680   __pyx_b = PyImport_AddModule(__Pyx_BUILTIN_MODULE_NAME); if (unlikely(!__pyx_b)) __PYX_ERR(1, 1, __pyx_L1_error)
25681   Py_INCREF(__pyx_b);
25682   __pyx_cython_runtime = PyImport_AddModule((char *) "cython_runtime"); if (unlikely(!__pyx_cython_runtime)) __PYX_ERR(1, 1, __pyx_L1_error)
25683   Py_INCREF(__pyx_cython_runtime);
25684   if (PyObject_SetAttrString(__pyx_m, "__builtins__", __pyx_b) < 0) __PYX_ERR(1, 1, __pyx_L1_error);
25685   /*--- Initialize various global constants etc. ---*/
25686   if (__Pyx_InitGlobals() < 0) __PYX_ERR(1, 1, __pyx_L1_error)
25687   #if PY_MAJOR_VERSION < 3 && (__PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT)
25688   if (__Pyx_init_sys_getdefaultencoding_params() < 0) __PYX_ERR(1, 1, __pyx_L1_error)
25689   #endif
25690   if (__pyx_module_is_main_qutip__cy__br_tensor) {
25691     if (PyObject_SetAttr(__pyx_m, __pyx_n_s_name_2, __pyx_n_s_main) < 0) __PYX_ERR(1, 1, __pyx_L1_error)
25692   }
25693   #if PY_MAJOR_VERSION >= 3
25694   {
25695     PyObject *modules = PyImport_GetModuleDict(); if (unlikely(!modules)) __PYX_ERR(1, 1, __pyx_L1_error)
25696     if (!PyDict_GetItemString(modules, "qutip.cy.br_tensor")) {
25697       if (unlikely(PyDict_SetItemString(modules, "qutip.cy.br_tensor", __pyx_m) < 0)) __PYX_ERR(1, 1, __pyx_L1_error)
25698     }
25699   }
25700   #endif
25701   /*--- Builtin init code ---*/
25702   if (__Pyx_InitCachedBuiltins() < 0) __PYX_ERR(1, 1, __pyx_L1_error)
25703   /*--- Constants init code ---*/
25704   if (__Pyx_InitCachedConstants() < 0) __PYX_ERR(1, 1, __pyx_L1_error)
25705   /*--- Global type/function init code ---*/
25706   (void)__Pyx_modinit_global_init_code();
25707   (void)__Pyx_modinit_variable_export_code();
25708   (void)__Pyx_modinit_function_export_code();
25709   if (unlikely(__Pyx_modinit_type_init_code() < 0)) __PYX_ERR(1, 1, __pyx_L1_error)
25710   if (unlikely(__Pyx_modinit_type_import_code() < 0)) __PYX_ERR(1, 1, __pyx_L1_error)
25711   (void)__Pyx_modinit_variable_import_code();
25712   if (unlikely(__Pyx_modinit_function_import_code() < 0)) __PYX_ERR(1, 1, __pyx_L1_error)
25713   /*--- Execution code ---*/
25714   #if defined(__Pyx_Generator_USED) || defined(__Pyx_Coroutine_USED)
25715   if (__Pyx_patch_abc() < 0) __PYX_ERR(1, 1, __pyx_L1_error)
25716   #endif
25717 
25718   /* "qutip/cy/br_tensor.pyx":34
25719  * #    OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25720  * ###############################################################################
25721  * import warnings             # <<<<<<<<<<<<<<
25722  * import numpy as np
25723  * import qutip.settings as qset
25724  */
25725   __pyx_t_1 = __Pyx_Import(__pyx_n_s_warnings, 0, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 34, __pyx_L1_error)
25726   __Pyx_GOTREF(__pyx_t_1);
25727   if (PyDict_SetItem(__pyx_d, __pyx_n_s_warnings, __pyx_t_1) < 0) __PYX_ERR(1, 34, __pyx_L1_error)
25728   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
25729 
25730   /* "qutip/cy/br_tensor.pyx":35
25731  * ###############################################################################
25732  * import warnings
25733  * import numpy as np             # <<<<<<<<<<<<<<
25734  * import qutip.settings as qset
25735  * from qutip.qobj import Qobj
25736  */
25737   __pyx_t_1 = __Pyx_Import(__pyx_n_s_numpy, 0, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 35, __pyx_L1_error)
25738   __Pyx_GOTREF(__pyx_t_1);
25739   if (PyDict_SetItem(__pyx_d, __pyx_n_s_np, __pyx_t_1) < 0) __PYX_ERR(1, 35, __pyx_L1_error)
25740   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
25741 
25742   /* "qutip/cy/br_tensor.pyx":36
25743  * import warnings
25744  * import numpy as np
25745  * import qutip.settings as qset             # <<<<<<<<<<<<<<
25746  * from qutip.qobj import Qobj
25747  * cimport numpy as np
25748  */
25749   __pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 36, __pyx_L1_error)
25750   __Pyx_GOTREF(__pyx_t_1);
25751   __Pyx_INCREF(__pyx_n_s__37);
25752   __Pyx_GIVEREF(__pyx_n_s__37);
25753   PyList_SET_ITEM(__pyx_t_1, 0, __pyx_n_s__37);
25754   __pyx_t_2 = __Pyx_Import(__pyx_n_s_qutip_settings, __pyx_t_1, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 36, __pyx_L1_error)
25755   __Pyx_GOTREF(__pyx_t_2);
25756   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
25757   if (PyDict_SetItem(__pyx_d, __pyx_n_s_qset, __pyx_t_2) < 0) __PYX_ERR(1, 36, __pyx_L1_error)
25758   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
25759 
25760   /* "qutip/cy/br_tensor.pyx":37
25761  * import numpy as np
25762  * import qutip.settings as qset
25763  * from qutip.qobj import Qobj             # <<<<<<<<<<<<<<
25764  * cimport numpy as np
25765  * cimport cython
25766  */
25767   __pyx_t_2 = PyList_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 37, __pyx_L1_error)
25768   __Pyx_GOTREF(__pyx_t_2);
25769   __Pyx_INCREF(__pyx_n_s_Qobj);
25770   __Pyx_GIVEREF(__pyx_n_s_Qobj);
25771   PyList_SET_ITEM(__pyx_t_2, 0, __pyx_n_s_Qobj);
25772   __pyx_t_1 = __Pyx_Import(__pyx_n_s_qutip_qobj, __pyx_t_2, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 37, __pyx_L1_error)
25773   __Pyx_GOTREF(__pyx_t_1);
25774   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
25775   __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_1, __pyx_n_s_Qobj); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 37, __pyx_L1_error)
25776   __Pyx_GOTREF(__pyx_t_2);
25777   if (PyDict_SetItem(__pyx_d, __pyx_n_s_Qobj, __pyx_t_2) < 0) __PYX_ERR(1, 37, __pyx_L1_error)
25778   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
25779   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
25780 
25781   /* "qutip/cy/br_tensor.pyx":43
25782  * from qutip.cy.brtools cimport (vec2mat_index, dense_to_eigbasis,
25783  *                               ZHEEVR, skew_and_dwmin)
25784  * from qutip.cy.brtools import (liou_from_diag_ham, cop_super_term)             # <<<<<<<<<<<<<<
25785  * from libc.math cimport fabs
25786  *
25787  */
25788   __pyx_t_1 = PyList_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 43, __pyx_L1_error)
25789   __Pyx_GOTREF(__pyx_t_1);
25790   __Pyx_INCREF(__pyx_n_s_liou_from_diag_ham);
25791   __Pyx_GIVEREF(__pyx_n_s_liou_from_diag_ham);
25792   PyList_SET_ITEM(__pyx_t_1, 0, __pyx_n_s_liou_from_diag_ham);
25793   __Pyx_INCREF(__pyx_n_s_cop_super_term);
25794   __Pyx_GIVEREF(__pyx_n_s_cop_super_term);
25795   PyList_SET_ITEM(__pyx_t_1, 1, __pyx_n_s_cop_super_term);
25796   __pyx_t_2 = __Pyx_Import(__pyx_n_s_qutip_cy_brtools, __pyx_t_1, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 43, __pyx_L1_error)
25797   __Pyx_GOTREF(__pyx_t_2);
25798   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
25799   __pyx_t_1 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_liou_from_diag_ham); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 43, __pyx_L1_error)
25800   __Pyx_GOTREF(__pyx_t_1);
25801   if (PyDict_SetItem(__pyx_d, __pyx_n_s_liou_from_diag_ham, __pyx_t_1) < 0) __PYX_ERR(1, 43, __pyx_L1_error)
25802   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
25803   __pyx_t_1 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_cop_super_term); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 43, __pyx_L1_error)
25804   __Pyx_GOTREF(__pyx_t_1);
25805   if (PyDict_SetItem(__pyx_d, __pyx_n_s_cop_super_term, __pyx_t_1) < 0) __PYX_ERR(1, 43, __pyx_L1_error)
25806   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
25807   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
25808 
25809   /* "qutip/cy/sparse_routines.pxi":35
25810  * #    OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25811  * ###############################################################################
25812  * import numpy as np             # <<<<<<<<<<<<<<
25813  * from scipy.sparse import coo_matrix
25814  * from qutip.fastsparse import fast_csr_matrix
25815  */
25816   __pyx_t_2 = __Pyx_Import(__pyx_n_s_numpy, 0, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 35, __pyx_L1_error)
25817   __Pyx_GOTREF(__pyx_t_2);
25818   if (PyDict_SetItem(__pyx_d, __pyx_n_s_np, __pyx_t_2) < 0) __PYX_ERR(0, 35, __pyx_L1_error)
25819   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
25820 
25821   /* "qutip/cy/sparse_routines.pxi":36
25822  * ###############################################################################
25823  * import numpy as np
25824  * from scipy.sparse import coo_matrix             # <<<<<<<<<<<<<<
25825  * from qutip.fastsparse import fast_csr_matrix
25826  * cimport numpy as np
25827  */
25828   __pyx_t_2 = PyList_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 36, __pyx_L1_error)
25829   __Pyx_GOTREF(__pyx_t_2);
25830   __Pyx_INCREF(__pyx_n_s_coo_matrix);
25831   __Pyx_GIVEREF(__pyx_n_s_coo_matrix);
25832   PyList_SET_ITEM(__pyx_t_2, 0, __pyx_n_s_coo_matrix);
25833   __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)
25834   __Pyx_GOTREF(__pyx_t_1);
25835   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
25836   __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)
25837   __Pyx_GOTREF(__pyx_t_2);
25838   if (PyDict_SetItem(__pyx_d, __pyx_n_s_coo_matrix, __pyx_t_2) < 0) __PYX_ERR(0, 36, __pyx_L1_error)
25839   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
25840   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
25841 
25842   /* "qutip/cy/sparse_routines.pxi":37
25843  * import numpy as np
25844  * from scipy.sparse import coo_matrix
25845  * from qutip.fastsparse import fast_csr_matrix             # <<<<<<<<<<<<<<
25846  * cimport numpy as np
25847  * cimport cython
25848  */
25849   __pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 37, __pyx_L1_error)
25850   __Pyx_GOTREF(__pyx_t_1);
25851   __Pyx_INCREF(__pyx_n_s_fast_csr_matrix);
25852   __Pyx_GIVEREF(__pyx_n_s_fast_csr_matrix);
25853   PyList_SET_ITEM(__pyx_t_1, 0, __pyx_n_s_fast_csr_matrix);
25854   __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)
25855   __Pyx_GOTREF(__pyx_t_2);
25856   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
25857   __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)
25858   __Pyx_GOTREF(__pyx_t_1);
25859   if (PyDict_SetItem(__pyx_d, __pyx_n_s_fast_csr_matrix, __pyx_t_1) < 0) __PYX_ERR(0, 37, __pyx_L1_error)
25860   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
25861   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
25862 
25863   /* "qutip/cy/sparse_routines.pxi":43
25864  * from libcpp.vector cimport vector
25865  * from qutip.cy.sparse_structs cimport CSR_Matrix, COO_Matrix
25866  * np.import_array()             # <<<<<<<<<<<<<<
25867  *
25868  * cdef extern from "numpy/arrayobject.h" nogil:
25869  */
25870   __pyx_t_3 = __pyx_f_5numpy_import_array(); if (unlikely(__pyx_t_3 == ((int)-1))) __PYX_ERR(0, 43, __pyx_L1_error)
25871 
25872   /* "qutip/cy/br_tensor.pyx":50
25873  * @cython.boundscheck(False)
25874  * @cython.wraparound(False)
25875  * def _br_term(complex[::1,:] A, complex[::1,:] evecs,             # <<<<<<<<<<<<<<
25876  *                 double[:,::1] skew, double dw_min, object spectral,
25877  *                 unsigned int nrows, int use_secular, double sec_cutoff,
25878  */
25879   __pyx_t_2 = PyCFunction_NewEx(&__pyx_mdef_5qutip_2cy_9br_tensor_1_br_term, NULL, __pyx_n_s_qutip_cy_br_tensor); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 50, __pyx_L1_error)
25880   __Pyx_GOTREF(__pyx_t_2);
25881   if (PyDict_SetItem(__pyx_d, __pyx_n_s_br_term, __pyx_t_2) < 0) __PYX_ERR(1, 50, __pyx_L1_error)
25882   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
25883 
25884   /* "qutip/cy/br_tensor.pyx":111
25885  * @cython.wraparound(False)
25886  * def bloch_redfield_tensor(object H, list a_ops, spectra_cb=None,
25887  *                  list c_ops=[], bool use_secular=True,             # <<<<<<<<<<<<<<
25888  *                  double sec_cutoff=0.1,
25889  *                  double atol = qset.atol):
25890  */
25891   __pyx_t_2 = PyList_New(0); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 111, __pyx_L1_error)
25892   __Pyx_GOTREF(__pyx_t_2);
25893   __pyx_k__12 = ((PyObject*)__pyx_t_2);
25894   __Pyx_GIVEREF(__pyx_t_2);
25895   __pyx_t_2 = 0;
25896 
25897   /* "qutip/cy/br_tensor.pyx":113
25898  *                  list c_ops=[], bool use_secular=True,
25899  *                  double sec_cutoff=0.1,
25900  *                  double atol = qset.atol):             # <<<<<<<<<<<<<<
25901  *      """
25902  *      Calculates the time-independent Bloch-Redfield tensor for a system given
25903  */
25904   __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_qset); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 113, __pyx_L1_error)
25905   __Pyx_GOTREF(__pyx_t_2);
25906   __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_atol); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 113, __pyx_L1_error)
25907   __Pyx_GOTREF(__pyx_t_1);
25908   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
25909   __pyx_t_4 = __pyx_PyFloat_AsDouble(__pyx_t_1); if (unlikely((__pyx_t_4 == (double)-1) && PyErr_Occurred())) __PYX_ERR(1, 113, __pyx_L1_error)
25910   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
25911   __pyx_k__13 = __pyx_t_4;
25912 
25913   /* "qutip/cy/br_tensor.pyx":110
25914  * @cython.boundscheck(False)
25915  * @cython.wraparound(False)
25916  * def bloch_redfield_tensor(object H, list a_ops, spectra_cb=None,             # <<<<<<<<<<<<<<
25917  *                  list c_ops=[], bool use_secular=True,
25918  *                  double sec_cutoff=0.1,
25919  */
25920   __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_5qutip_2cy_9br_tensor_3bloch_redfield_tensor, NULL, __pyx_n_s_qutip_cy_br_tensor); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 110, __pyx_L1_error)
25921   __Pyx_GOTREF(__pyx_t_1);
25922   if (PyDict_SetItem(__pyx_d, __pyx_n_s_bloch_redfield_tensor, __pyx_t_1) < 0) __PYX_ERR(1, 110, __pyx_L1_error)
25923   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
25924 
25925   /* "qutip/cy/br_tensor.pyx":1
25926  * #cython: language_level=3             # <<<<<<<<<<<<<<
25927  * # This file is part of QuTiP: Quantum Toolbox in Python.
25928  * #
25929  */
25930   __pyx_t_1 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 1, __pyx_L1_error)
25931   __Pyx_GOTREF(__pyx_t_1);
25932   if (PyDict_SetItem(__pyx_d, __pyx_n_s_test, __pyx_t_1) < 0) __PYX_ERR(1, 1, __pyx_L1_error)
25933   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
25934 
25935   /* "View.MemoryView":209
25936  *         info.obj = self
25937  *
25938  *     __pyx_getbuffer = capsule(<void *> &__pyx_array_getbuffer, "getbuffer(obj, view, flags)")             # <<<<<<<<<<<<<<
25939  *
25940  *     def __dealloc__(array self):
25941  */
25942   __pyx_t_1 = __pyx_capsule_create(((void *)(&__pyx_array_getbuffer)), ((char *)"getbuffer(obj, view, flags)")); if (unlikely(!__pyx_t_1)) __PYX_ERR(3, 209, __pyx_L1_error)
25943   __Pyx_GOTREF(__pyx_t_1);
25944   if (PyDict_SetItem((PyObject *)__pyx_array_type->tp_dict, __pyx_n_s_pyx_getbuffer, __pyx_t_1) < 0) __PYX_ERR(3, 209, __pyx_L1_error)
25945   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
25946   PyType_Modified(__pyx_array_type);
25947 
25948   /* "View.MemoryView":286
25949  *         return self.name
25950  *
25951  * cdef generic = Enum("<strided and direct or indirect>")             # <<<<<<<<<<<<<<
25952  * cdef strided = Enum("<strided and direct>") # default
25953  * cdef indirect = Enum("<strided and indirect>")
25954  */
25955   __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)__pyx_MemviewEnum_type), __pyx_tuple__42, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(3, 286, __pyx_L1_error)
25956   __Pyx_GOTREF(__pyx_t_1);
25957   __Pyx_XGOTREF(generic);
25958   __Pyx_DECREF_SET(generic, __pyx_t_1);
25959   __Pyx_GIVEREF(__pyx_t_1);
25960   __pyx_t_1 = 0;
25961 
25962   /* "View.MemoryView":287
25963  *
25964  * cdef generic = Enum("<strided and direct or indirect>")
25965  * cdef strided = Enum("<strided and direct>") # default             # <<<<<<<<<<<<<<
25966  * cdef indirect = Enum("<strided and indirect>")
25967  *
25968  */
25969   __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)__pyx_MemviewEnum_type), __pyx_tuple__43, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(3, 287, __pyx_L1_error)
25970   __Pyx_GOTREF(__pyx_t_1);
25971   __Pyx_XGOTREF(strided);
25972   __Pyx_DECREF_SET(strided, __pyx_t_1);
25973   __Pyx_GIVEREF(__pyx_t_1);
25974   __pyx_t_1 = 0;
25975 
25976   /* "View.MemoryView":288
25977  * cdef generic = Enum("<strided and direct or indirect>")
25978  * cdef strided = Enum("<strided and direct>") # default
25979  * cdef indirect = Enum("<strided and indirect>")             # <<<<<<<<<<<<<<
25980  *
25981  *
25982  */
25983   __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)__pyx_MemviewEnum_type), __pyx_tuple__44, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(3, 288, __pyx_L1_error)
25984   __Pyx_GOTREF(__pyx_t_1);
25985   __Pyx_XGOTREF(indirect);
25986   __Pyx_DECREF_SET(indirect, __pyx_t_1);
25987   __Pyx_GIVEREF(__pyx_t_1);
25988   __pyx_t_1 = 0;
25989 
25990   /* "View.MemoryView":291
25991  *
25992  *
25993  * cdef contiguous = Enum("<contiguous and direct>")             # <<<<<<<<<<<<<<
25994  * cdef indirect_contiguous = Enum("<contiguous and indirect>")
25995  *
25996  */
25997   __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)__pyx_MemviewEnum_type), __pyx_tuple__45, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(3, 291, __pyx_L1_error)
25998   __Pyx_GOTREF(__pyx_t_1);
25999   __Pyx_XGOTREF(contiguous);
26000   __Pyx_DECREF_SET(contiguous, __pyx_t_1);
26001   __Pyx_GIVEREF(__pyx_t_1);
26002   __pyx_t_1 = 0;
26003 
26004   /* "View.MemoryView":292
26005  *
26006  * cdef contiguous = Enum("<contiguous and direct>")
26007  * cdef indirect_contiguous = Enum("<contiguous and indirect>")             # <<<<<<<<<<<<<<
26008  *
26009  *
26010  */
26011   __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)__pyx_MemviewEnum_type), __pyx_tuple__46, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(3, 292, __pyx_L1_error)
26012   __Pyx_GOTREF(__pyx_t_1);
26013   __Pyx_XGOTREF(indirect_contiguous);
26014   __Pyx_DECREF_SET(indirect_contiguous, __pyx_t_1);
26015   __Pyx_GIVEREF(__pyx_t_1);
26016   __pyx_t_1 = 0;
26017 
26018   /* "View.MemoryView":316
26019  *
26020  * DEF THREAD_LOCKS_PREALLOCATED = 8
26021  * cdef int __pyx_memoryview_thread_locks_used = 0             # <<<<<<<<<<<<<<
26022  * cdef PyThread_type_lock[THREAD_LOCKS_PREALLOCATED] __pyx_memoryview_thread_locks = [
26023  *     PyThread_allocate_lock(),
26024  */
26025   __pyx_memoryview_thread_locks_used = 0;
26026 
26027   /* "View.MemoryView":317
26028  * DEF THREAD_LOCKS_PREALLOCATED = 8
26029  * cdef int __pyx_memoryview_thread_locks_used = 0
26030  * cdef PyThread_type_lock[THREAD_LOCKS_PREALLOCATED] __pyx_memoryview_thread_locks = [             # <<<<<<<<<<<<<<
26031  *     PyThread_allocate_lock(),
26032  *     PyThread_allocate_lock(),
26033  */
26034   __pyx_t_5[0] = PyThread_allocate_lock();
26035   __pyx_t_5[1] = PyThread_allocate_lock();
26036   __pyx_t_5[2] = PyThread_allocate_lock();
26037   __pyx_t_5[3] = PyThread_allocate_lock();
26038   __pyx_t_5[4] = PyThread_allocate_lock();
26039   __pyx_t_5[5] = PyThread_allocate_lock();
26040   __pyx_t_5[6] = PyThread_allocate_lock();
26041   __pyx_t_5[7] = PyThread_allocate_lock();
26042   memcpy(&(__pyx_memoryview_thread_locks[0]), __pyx_t_5, sizeof(__pyx_memoryview_thread_locks[0]) * (8));
26043 
26044   /* "View.MemoryView":549
26045  *         info.obj = self
26046  *
26047  *     __pyx_getbuffer = capsule(<void *> &__pyx_memoryview_getbuffer, "getbuffer(obj, view, flags)")             # <<<<<<<<<<<<<<
26048  *
26049  *
26050  */
26051   __pyx_t_1 = __pyx_capsule_create(((void *)(&__pyx_memoryview_getbuffer)), ((char *)"getbuffer(obj, view, flags)")); if (unlikely(!__pyx_t_1)) __PYX_ERR(3, 549, __pyx_L1_error)
26052   __Pyx_GOTREF(__pyx_t_1);
26053   if (PyDict_SetItem((PyObject *)__pyx_memoryview_type->tp_dict, __pyx_n_s_pyx_getbuffer, __pyx_t_1) < 0) __PYX_ERR(3, 549, __pyx_L1_error)
26054   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
26055   PyType_Modified(__pyx_memoryview_type);
26056 
26057   /* "View.MemoryView":995
26058  *         return self.from_object
26059  *
26060  *     __pyx_getbuffer = capsule(<void *> &__pyx_memoryview_getbuffer, "getbuffer(obj, view, flags)")             # <<<<<<<<<<<<<<
26061  *
26062  *
26063  */
26064   __pyx_t_1 = __pyx_capsule_create(((void *)(&__pyx_memoryview_getbuffer)), ((char *)"getbuffer(obj, view, flags)")); if (unlikely(!__pyx_t_1)) __PYX_ERR(3, 995, __pyx_L1_error)
26065   __Pyx_GOTREF(__pyx_t_1);
26066   if (PyDict_SetItem((PyObject *)__pyx_memoryviewslice_type->tp_dict, __pyx_n_s_pyx_getbuffer, __pyx_t_1) < 0) __PYX_ERR(3, 995, __pyx_L1_error)
26067   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
26068   PyType_Modified(__pyx_memoryviewslice_type);
26069 
26070   /* "(tree fragment)":1
26071  * def __pyx_unpickle_Enum(__pyx_type, long __pyx_checksum, __pyx_state):             # <<<<<<<<<<<<<<
26072  *     cdef object __pyx_PickleError
26073  *     cdef object __pyx_result
26074  */
26075   __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_15View_dot_MemoryView_1__pyx_unpickle_Enum, NULL, __pyx_n_s_View_MemoryView); if (unlikely(!__pyx_t_1)) __PYX_ERR(3, 1, __pyx_L1_error)
26076   __Pyx_GOTREF(__pyx_t_1);
26077   if (PyDict_SetItem(__pyx_d, __pyx_n_s_pyx_unpickle_Enum, __pyx_t_1) < 0) __PYX_ERR(3, 1, __pyx_L1_error)
26078   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
26079 
26080   /* "(tree fragment)":11
26081  *         __pyx_unpickle_Enum__set_state(<Enum> __pyx_result, __pyx_state)
26082  *     return __pyx_result
26083  * cdef __pyx_unpickle_Enum__set_state(Enum __pyx_result, tuple __pyx_state):             # <<<<<<<<<<<<<<
26084  *     __pyx_result.name = __pyx_state[0]
26085  *     if len(__pyx_state) > 1 and hasattr(__pyx_result, '__dict__'):
26086  */
26087 
26088   /*--- Wrapped vars code ---*/
26089 
26090   goto __pyx_L0;
26091   __pyx_L1_error:;
26092   __Pyx_XDECREF(__pyx_t_1);
26093   __Pyx_XDECREF(__pyx_t_2);
26094   if (__pyx_m) {
26095     if (__pyx_d) {
26096       __Pyx_AddTraceback("init qutip.cy.br_tensor", __pyx_clineno, __pyx_lineno, __pyx_filename);
26097     }
26098     Py_CLEAR(__pyx_m);
26099   } else if (!PyErr_Occurred()) {
26100     PyErr_SetString(PyExc_ImportError, "init qutip.cy.br_tensor");
26101   }
26102   __pyx_L0:;
26103   __Pyx_RefNannyFinishContext();
26104   #if CYTHON_PEP489_MULTI_PHASE_INIT
26105   return (__pyx_m != NULL) ? 0 : -1;
26106   #elif PY_MAJOR_VERSION >= 3
26107   return __pyx_m;
26108   #else
26109   return;
26110   #endif
26111 }
26112 
26113 /* --- Runtime support code --- */
26114 /* Refnanny */
26115 #if CYTHON_REFNANNY
__Pyx_RefNannyImportAPI(const char * modname)26116 static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname) {
26117     PyObject *m = NULL, *p = NULL;
26118     void *r = NULL;
26119     m = PyImport_ImportModule(modname);
26120     if (!m) goto end;
26121     p = PyObject_GetAttrString(m, "RefNannyAPI");
26122     if (!p) goto end;
26123     r = PyLong_AsVoidPtr(p);
26124 end:
26125     Py_XDECREF(p);
26126     Py_XDECREF(m);
26127     return (__Pyx_RefNannyAPIStruct *)r;
26128 }
26129 #endif
26130 
26131 /* PyObjectGetAttrStr */
26132 #if CYTHON_USE_TYPE_SLOTS
__Pyx_PyObject_GetAttrStr(PyObject * obj,PyObject * attr_name)26133 static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStr(PyObject* obj, PyObject* attr_name) {
26134     PyTypeObject* tp = Py_TYPE(obj);
26135     if (likely(tp->tp_getattro))
26136         return tp->tp_getattro(obj, attr_name);
26137 #if PY_MAJOR_VERSION < 3
26138     if (likely(tp->tp_getattr))
26139         return tp->tp_getattr(obj, PyString_AS_STRING(attr_name));
26140 #endif
26141     return PyObject_GetAttr(obj, attr_name);
26142 }
26143 #endif
26144 
26145 /* GetBuiltinName */
__Pyx_GetBuiltinName(PyObject * name)26146 static PyObject *__Pyx_GetBuiltinName(PyObject *name) {
26147     PyObject* result = __Pyx_PyObject_GetAttrStr(__pyx_b, name);
26148     if (unlikely(!result)) {
26149         PyErr_Format(PyExc_NameError,
26150 #if PY_MAJOR_VERSION >= 3
26151             "name '%U' is not defined", name);
26152 #else
26153             "name '%.200s' is not defined", PyString_AS_STRING(name));
26154 #endif
26155     }
26156     return result;
26157 }
26158 
26159 /* PyObjectCall */
26160 #if CYTHON_COMPILING_IN_CPYTHON
__Pyx_PyObject_Call(PyObject * func,PyObject * arg,PyObject * kw)26161 static CYTHON_INLINE PyObject* __Pyx_PyObject_Call(PyObject *func, PyObject *arg, PyObject *kw) {
26162     PyObject *result;
26163     ternaryfunc call = func->ob_type->tp_call;
26164     if (unlikely(!call))
26165         return PyObject_Call(func, arg, kw);
26166     if (unlikely(Py_EnterRecursiveCall((char*)" while calling a Python object")))
26167         return NULL;
26168     result = (*call)(func, arg, kw);
26169     Py_LeaveRecursiveCall();
26170     if (unlikely(!result) && unlikely(!PyErr_Occurred())) {
26171         PyErr_SetString(
26172             PyExc_SystemError,
26173             "NULL result without error in PyObject_Call");
26174     }
26175     return result;
26176 }
26177 #endif
26178 
26179 /* PyErrFetchRestore */
26180 #if CYTHON_FAST_THREAD_STATE
__Pyx_ErrRestoreInState(PyThreadState * tstate,PyObject * type,PyObject * value,PyObject * tb)26181 static CYTHON_INLINE void __Pyx_ErrRestoreInState(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb) {
26182     PyObject *tmp_type, *tmp_value, *tmp_tb;
26183     tmp_type = tstate->curexc_type;
26184     tmp_value = tstate->curexc_value;
26185     tmp_tb = tstate->curexc_traceback;
26186     tstate->curexc_type = type;
26187     tstate->curexc_value = value;
26188     tstate->curexc_traceback = tb;
26189     Py_XDECREF(tmp_type);
26190     Py_XDECREF(tmp_value);
26191     Py_XDECREF(tmp_tb);
26192 }
__Pyx_ErrFetchInState(PyThreadState * tstate,PyObject ** type,PyObject ** value,PyObject ** tb)26193 static CYTHON_INLINE void __Pyx_ErrFetchInState(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) {
26194     *type = tstate->curexc_type;
26195     *value = tstate->curexc_value;
26196     *tb = tstate->curexc_traceback;
26197     tstate->curexc_type = 0;
26198     tstate->curexc_value = 0;
26199     tstate->curexc_traceback = 0;
26200 }
26201 #endif
26202 
26203 /* RaiseException */
26204 #if PY_MAJOR_VERSION < 3
__Pyx_Raise(PyObject * type,PyObject * value,PyObject * tb,CYTHON_UNUSED PyObject * cause)26205 static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb,
26206                         CYTHON_UNUSED PyObject *cause) {
26207     __Pyx_PyThreadState_declare
26208     Py_XINCREF(type);
26209     if (!value || value == Py_None)
26210         value = NULL;
26211     else
26212         Py_INCREF(value);
26213     if (!tb || tb == Py_None)
26214         tb = NULL;
26215     else {
26216         Py_INCREF(tb);
26217         if (!PyTraceBack_Check(tb)) {
26218             PyErr_SetString(PyExc_TypeError,
26219                 "raise: arg 3 must be a traceback or None");
26220             goto raise_error;
26221         }
26222     }
26223     if (PyType_Check(type)) {
26224 #if CYTHON_COMPILING_IN_PYPY
26225         if (!value) {
26226             Py_INCREF(Py_None);
26227             value = Py_None;
26228         }
26229 #endif
26230         PyErr_NormalizeException(&type, &value, &tb);
26231     } else {
26232         if (value) {
26233             PyErr_SetString(PyExc_TypeError,
26234                 "instance exception may not have a separate value");
26235             goto raise_error;
26236         }
26237         value = type;
26238         type = (PyObject*) Py_TYPE(type);
26239         Py_INCREF(type);
26240         if (!PyType_IsSubtype((PyTypeObject *)type, (PyTypeObject *)PyExc_BaseException)) {
26241             PyErr_SetString(PyExc_TypeError,
26242                 "raise: exception class must be a subclass of BaseException");
26243             goto raise_error;
26244         }
26245     }
26246     __Pyx_PyThreadState_assign
26247     __Pyx_ErrRestore(type, value, tb);
26248     return;
26249 raise_error:
26250     Py_XDECREF(value);
26251     Py_XDECREF(type);
26252     Py_XDECREF(tb);
26253     return;
26254 }
26255 #else
__Pyx_Raise(PyObject * type,PyObject * value,PyObject * tb,PyObject * cause)26256 static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause) {
26257     PyObject* owned_instance = NULL;
26258     if (tb == Py_None) {
26259         tb = 0;
26260     } else if (tb && !PyTraceBack_Check(tb)) {
26261         PyErr_SetString(PyExc_TypeError,
26262             "raise: arg 3 must be a traceback or None");
26263         goto bad;
26264     }
26265     if (value == Py_None)
26266         value = 0;
26267     if (PyExceptionInstance_Check(type)) {
26268         if (value) {
26269             PyErr_SetString(PyExc_TypeError,
26270                 "instance exception may not have a separate value");
26271             goto bad;
26272         }
26273         value = type;
26274         type = (PyObject*) Py_TYPE(value);
26275     } else if (PyExceptionClass_Check(type)) {
26276         PyObject *instance_class = NULL;
26277         if (value && PyExceptionInstance_Check(value)) {
26278             instance_class = (PyObject*) Py_TYPE(value);
26279             if (instance_class != type) {
26280                 int is_subclass = PyObject_IsSubclass(instance_class, type);
26281                 if (!is_subclass) {
26282                     instance_class = NULL;
26283                 } else if (unlikely(is_subclass == -1)) {
26284                     goto bad;
26285                 } else {
26286                     type = instance_class;
26287                 }
26288             }
26289         }
26290         if (!instance_class) {
26291             PyObject *args;
26292             if (!value)
26293                 args = PyTuple_New(0);
26294             else if (PyTuple_Check(value)) {
26295                 Py_INCREF(value);
26296                 args = value;
26297             } else
26298                 args = PyTuple_Pack(1, value);
26299             if (!args)
26300                 goto bad;
26301             owned_instance = PyObject_Call(type, args, NULL);
26302             Py_DECREF(args);
26303             if (!owned_instance)
26304                 goto bad;
26305             value = owned_instance;
26306             if (!PyExceptionInstance_Check(value)) {
26307                 PyErr_Format(PyExc_TypeError,
26308                              "calling %R should have returned an instance of "
26309                              "BaseException, not %R",
26310                              type, Py_TYPE(value));
26311                 goto bad;
26312             }
26313         }
26314     } else {
26315         PyErr_SetString(PyExc_TypeError,
26316             "raise: exception class must be a subclass of BaseException");
26317         goto bad;
26318     }
26319     if (cause) {
26320         PyObject *fixed_cause;
26321         if (cause == Py_None) {
26322             fixed_cause = NULL;
26323         } else if (PyExceptionClass_Check(cause)) {
26324             fixed_cause = PyObject_CallObject(cause, NULL);
26325             if (fixed_cause == NULL)
26326                 goto bad;
26327         } else if (PyExceptionInstance_Check(cause)) {
26328             fixed_cause = cause;
26329             Py_INCREF(fixed_cause);
26330         } else {
26331             PyErr_SetString(PyExc_TypeError,
26332                             "exception causes must derive from "
26333                             "BaseException");
26334             goto bad;
26335         }
26336         PyException_SetCause(value, fixed_cause);
26337     }
26338     PyErr_SetObject(type, value);
26339     if (tb) {
26340 #if CYTHON_COMPILING_IN_PYPY
26341         PyObject *tmp_type, *tmp_value, *tmp_tb;
26342         PyErr_Fetch(&tmp_type, &tmp_value, &tmp_tb);
26343         Py_INCREF(tb);
26344         PyErr_Restore(tmp_type, tmp_value, tb);
26345         Py_XDECREF(tmp_tb);
26346 #else
26347         PyThreadState *tstate = __Pyx_PyThreadState_Current;
26348         PyObject* tmp_tb = tstate->curexc_traceback;
26349         if (tb != tmp_tb) {
26350             Py_INCREF(tb);
26351             tstate->curexc_traceback = tb;
26352             Py_XDECREF(tmp_tb);
26353         }
26354 #endif
26355     }
26356 bad:
26357     Py_XDECREF(owned_instance);
26358     return;
26359 }
26360 #endif
26361 
26362 /* 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)26363 static void __Pyx_WriteUnraisable(const char *name, CYTHON_UNUSED int clineno,
26364                                   CYTHON_UNUSED int lineno, CYTHON_UNUSED const char *filename,
26365                                   int full_traceback, CYTHON_UNUSED int nogil) {
26366     PyObject *old_exc, *old_val, *old_tb;
26367     PyObject *ctx;
26368     __Pyx_PyThreadState_declare
26369 #ifdef WITH_THREAD
26370     PyGILState_STATE state;
26371     if (nogil)
26372         state = PyGILState_Ensure();
26373 #ifdef _MSC_VER
26374     else state = (PyGILState_STATE)-1;
26375 #endif
26376 #endif
26377     __Pyx_PyThreadState_assign
26378     __Pyx_ErrFetch(&old_exc, &old_val, &old_tb);
26379     if (full_traceback) {
26380         Py_XINCREF(old_exc);
26381         Py_XINCREF(old_val);
26382         Py_XINCREF(old_tb);
26383         __Pyx_ErrRestore(old_exc, old_val, old_tb);
26384         PyErr_PrintEx(1);
26385     }
26386     #if PY_MAJOR_VERSION < 3
26387     ctx = PyString_FromString(name);
26388     #else
26389     ctx = PyUnicode_FromString(name);
26390     #endif
26391     __Pyx_ErrRestore(old_exc, old_val, old_tb);
26392     if (!ctx) {
26393         PyErr_WriteUnraisable(Py_None);
26394     } else {
26395         PyErr_WriteUnraisable(ctx);
26396         Py_DECREF(ctx);
26397     }
26398 #ifdef WITH_THREAD
26399     if (nogil)
26400         PyGILState_Release(state);
26401 #endif
26402 }
26403 
26404 /* ExtTypeTest */
__Pyx_TypeTest(PyObject * obj,PyTypeObject * type)26405 static CYTHON_INLINE int __Pyx_TypeTest(PyObject *obj, PyTypeObject *type) {
26406     if (unlikely(!type)) {
26407         PyErr_SetString(PyExc_SystemError, "Missing type object");
26408         return 0;
26409     }
26410     if (likely(__Pyx_TypeCheck(obj, type)))
26411         return 1;
26412     PyErr_Format(PyExc_TypeError, "Cannot convert %.200s to %.200s",
26413                  Py_TYPE(obj)->tp_name, type->tp_name);
26414     return 0;
26415 }
26416 
26417 /* IsLittleEndian */
__Pyx_Is_Little_Endian(void)26418 static CYTHON_INLINE int __Pyx_Is_Little_Endian(void)
26419 {
26420   union {
26421     uint32_t u32;
26422     uint8_t u8[4];
26423   } S;
26424   S.u32 = 0x01020304;
26425   return S.u8[0] == 4;
26426 }
26427 
26428 /* BufferFormatCheck */
__Pyx_BufFmt_Init(__Pyx_BufFmt_Context * ctx,__Pyx_BufFmt_StackElem * stack,__Pyx_TypeInfo * type)26429 static void __Pyx_BufFmt_Init(__Pyx_BufFmt_Context* ctx,
26430                               __Pyx_BufFmt_StackElem* stack,
26431                               __Pyx_TypeInfo* type) {
26432   stack[0].field = &ctx->root;
26433   stack[0].parent_offset = 0;
26434   ctx->root.type = type;
26435   ctx->root.name = "buffer dtype";
26436   ctx->root.offset = 0;
26437   ctx->head = stack;
26438   ctx->head->field = &ctx->root;
26439   ctx->fmt_offset = 0;
26440   ctx->head->parent_offset = 0;
26441   ctx->new_packmode = '@';
26442   ctx->enc_packmode = '@';
26443   ctx->new_count = 1;
26444   ctx->enc_count = 0;
26445   ctx->enc_type = 0;
26446   ctx->is_complex = 0;
26447   ctx->is_valid_array = 0;
26448   ctx->struct_alignment = 0;
26449   while (type->typegroup == 'S') {
26450     ++ctx->head;
26451     ctx->head->field = type->fields;
26452     ctx->head->parent_offset = 0;
26453     type = type->fields->type;
26454   }
26455 }
__Pyx_BufFmt_ParseNumber(const char ** ts)26456 static int __Pyx_BufFmt_ParseNumber(const char** ts) {
26457     int count;
26458     const char* t = *ts;
26459     if (*t < '0' || *t > '9') {
26460       return -1;
26461     } else {
26462         count = *t++ - '0';
26463         while (*t >= '0' && *t <= '9') {
26464             count *= 10;
26465             count += *t++ - '0';
26466         }
26467     }
26468     *ts = t;
26469     return count;
26470 }
__Pyx_BufFmt_ExpectNumber(const char ** ts)26471 static int __Pyx_BufFmt_ExpectNumber(const char **ts) {
26472     int number = __Pyx_BufFmt_ParseNumber(ts);
26473     if (number == -1)
26474         PyErr_Format(PyExc_ValueError,\
26475                      "Does not understand character buffer dtype format string ('%c')", **ts);
26476     return number;
26477 }
__Pyx_BufFmt_RaiseUnexpectedChar(char ch)26478 static void __Pyx_BufFmt_RaiseUnexpectedChar(char ch) {
26479   PyErr_Format(PyExc_ValueError,
26480                "Unexpected format string character: '%c'", ch);
26481 }
__Pyx_BufFmt_DescribeTypeChar(char ch,int is_complex)26482 static const char* __Pyx_BufFmt_DescribeTypeChar(char ch, int is_complex) {
26483   switch (ch) {
26484     case '?': return "'bool'";
26485     case 'c': return "'char'";
26486     case 'b': return "'signed char'";
26487     case 'B': return "'unsigned char'";
26488     case 'h': return "'short'";
26489     case 'H': return "'unsigned short'";
26490     case 'i': return "'int'";
26491     case 'I': return "'unsigned int'";
26492     case 'l': return "'long'";
26493     case 'L': return "'unsigned long'";
26494     case 'q': return "'long long'";
26495     case 'Q': return "'unsigned long long'";
26496     case 'f': return (is_complex ? "'complex float'" : "'float'");
26497     case 'd': return (is_complex ? "'complex double'" : "'double'");
26498     case 'g': return (is_complex ? "'complex long double'" : "'long double'");
26499     case 'T': return "a struct";
26500     case 'O': return "Python object";
26501     case 'P': return "a pointer";
26502     case 's': case 'p': return "a string";
26503     case 0: return "end";
26504     default: return "unparseable format string";
26505   }
26506 }
__Pyx_BufFmt_TypeCharToStandardSize(char ch,int is_complex)26507 static size_t __Pyx_BufFmt_TypeCharToStandardSize(char ch, int is_complex) {
26508   switch (ch) {
26509     case '?': case 'c': case 'b': case 'B': case 's': case 'p': return 1;
26510     case 'h': case 'H': return 2;
26511     case 'i': case 'I': case 'l': case 'L': return 4;
26512     case 'q': case 'Q': return 8;
26513     case 'f': return (is_complex ? 8 : 4);
26514     case 'd': return (is_complex ? 16 : 8);
26515     case 'g': {
26516       PyErr_SetString(PyExc_ValueError, "Python does not define a standard format string size for long double ('g')..");
26517       return 0;
26518     }
26519     case 'O': case 'P': return sizeof(void*);
26520     default:
26521       __Pyx_BufFmt_RaiseUnexpectedChar(ch);
26522       return 0;
26523     }
26524 }
__Pyx_BufFmt_TypeCharToNativeSize(char ch,int is_complex)26525 static size_t __Pyx_BufFmt_TypeCharToNativeSize(char ch, int is_complex) {
26526   switch (ch) {
26527     case '?': case 'c': case 'b': case 'B': case 's': case 'p': return 1;
26528     case 'h': case 'H': return sizeof(short);
26529     case 'i': case 'I': return sizeof(int);
26530     case 'l': case 'L': return sizeof(long);
26531     #ifdef HAVE_LONG_LONG
26532     case 'q': case 'Q': return sizeof(PY_LONG_LONG);
26533     #endif
26534     case 'f': return sizeof(float) * (is_complex ? 2 : 1);
26535     case 'd': return sizeof(double) * (is_complex ? 2 : 1);
26536     case 'g': return sizeof(long double) * (is_complex ? 2 : 1);
26537     case 'O': case 'P': return sizeof(void*);
26538     default: {
26539       __Pyx_BufFmt_RaiseUnexpectedChar(ch);
26540       return 0;
26541     }
26542   }
26543 }
26544 typedef struct { char c; short x; } __Pyx_st_short;
26545 typedef struct { char c; int x; } __Pyx_st_int;
26546 typedef struct { char c; long x; } __Pyx_st_long;
26547 typedef struct { char c; float x; } __Pyx_st_float;
26548 typedef struct { char c; double x; } __Pyx_st_double;
26549 typedef struct { char c; long double x; } __Pyx_st_longdouble;
26550 typedef struct { char c; void *x; } __Pyx_st_void_p;
26551 #ifdef HAVE_LONG_LONG
26552 typedef struct { char c; PY_LONG_LONG x; } __Pyx_st_longlong;
26553 #endif
__Pyx_BufFmt_TypeCharToAlignment(char ch,CYTHON_UNUSED int is_complex)26554 static size_t __Pyx_BufFmt_TypeCharToAlignment(char ch, CYTHON_UNUSED int is_complex) {
26555   switch (ch) {
26556     case '?': case 'c': case 'b': case 'B': case 's': case 'p': return 1;
26557     case 'h': case 'H': return sizeof(__Pyx_st_short) - sizeof(short);
26558     case 'i': case 'I': return sizeof(__Pyx_st_int) - sizeof(int);
26559     case 'l': case 'L': return sizeof(__Pyx_st_long) - sizeof(long);
26560 #ifdef HAVE_LONG_LONG
26561     case 'q': case 'Q': return sizeof(__Pyx_st_longlong) - sizeof(PY_LONG_LONG);
26562 #endif
26563     case 'f': return sizeof(__Pyx_st_float) - sizeof(float);
26564     case 'd': return sizeof(__Pyx_st_double) - sizeof(double);
26565     case 'g': return sizeof(__Pyx_st_longdouble) - sizeof(long double);
26566     case 'P': case 'O': return sizeof(__Pyx_st_void_p) - sizeof(void*);
26567     default:
26568       __Pyx_BufFmt_RaiseUnexpectedChar(ch);
26569       return 0;
26570     }
26571 }
26572 /* These are for computing the padding at the end of the struct to align
26573    on the first member of the struct. This will probably the same as above,
26574    but we don't have any guarantees.
26575  */
26576 typedef struct { short x; char c; } __Pyx_pad_short;
26577 typedef struct { int x; char c; } __Pyx_pad_int;
26578 typedef struct { long x; char c; } __Pyx_pad_long;
26579 typedef struct { float x; char c; } __Pyx_pad_float;
26580 typedef struct { double x; char c; } __Pyx_pad_double;
26581 typedef struct { long double x; char c; } __Pyx_pad_longdouble;
26582 typedef struct { void *x; char c; } __Pyx_pad_void_p;
26583 #ifdef HAVE_LONG_LONG
26584 typedef struct { PY_LONG_LONG x; char c; } __Pyx_pad_longlong;
26585 #endif
__Pyx_BufFmt_TypeCharToPadding(char ch,CYTHON_UNUSED int is_complex)26586 static size_t __Pyx_BufFmt_TypeCharToPadding(char ch, CYTHON_UNUSED int is_complex) {
26587   switch (ch) {
26588     case '?': case 'c': case 'b': case 'B': case 's': case 'p': return 1;
26589     case 'h': case 'H': return sizeof(__Pyx_pad_short) - sizeof(short);
26590     case 'i': case 'I': return sizeof(__Pyx_pad_int) - sizeof(int);
26591     case 'l': case 'L': return sizeof(__Pyx_pad_long) - sizeof(long);
26592 #ifdef HAVE_LONG_LONG
26593     case 'q': case 'Q': return sizeof(__Pyx_pad_longlong) - sizeof(PY_LONG_LONG);
26594 #endif
26595     case 'f': return sizeof(__Pyx_pad_float) - sizeof(float);
26596     case 'd': return sizeof(__Pyx_pad_double) - sizeof(double);
26597     case 'g': return sizeof(__Pyx_pad_longdouble) - sizeof(long double);
26598     case 'P': case 'O': return sizeof(__Pyx_pad_void_p) - sizeof(void*);
26599     default:
26600       __Pyx_BufFmt_RaiseUnexpectedChar(ch);
26601       return 0;
26602     }
26603 }
__Pyx_BufFmt_TypeCharToGroup(char ch,int is_complex)26604 static char __Pyx_BufFmt_TypeCharToGroup(char ch, int is_complex) {
26605   switch (ch) {
26606     case 'c':
26607         return 'H';
26608     case 'b': case 'h': case 'i':
26609     case 'l': case 'q': case 's': case 'p':
26610         return 'I';
26611     case '?': case 'B': case 'H': case 'I': case 'L': case 'Q':
26612         return 'U';
26613     case 'f': case 'd': case 'g':
26614         return (is_complex ? 'C' : 'R');
26615     case 'O':
26616         return 'O';
26617     case 'P':
26618         return 'P';
26619     default: {
26620       __Pyx_BufFmt_RaiseUnexpectedChar(ch);
26621       return 0;
26622     }
26623   }
26624 }
__Pyx_BufFmt_RaiseExpected(__Pyx_BufFmt_Context * ctx)26625 static void __Pyx_BufFmt_RaiseExpected(__Pyx_BufFmt_Context* ctx) {
26626   if (ctx->head == NULL || ctx->head->field == &ctx->root) {
26627     const char* expected;
26628     const char* quote;
26629     if (ctx->head == NULL) {
26630       expected = "end";
26631       quote = "";
26632     } else {
26633       expected = ctx->head->field->type->name;
26634       quote = "'";
26635     }
26636     PyErr_Format(PyExc_ValueError,
26637                  "Buffer dtype mismatch, expected %s%s%s but got %s",
26638                  quote, expected, quote,
26639                  __Pyx_BufFmt_DescribeTypeChar(ctx->enc_type, ctx->is_complex));
26640   } else {
26641     __Pyx_StructField* field = ctx->head->field;
26642     __Pyx_StructField* parent = (ctx->head - 1)->field;
26643     PyErr_Format(PyExc_ValueError,
26644                  "Buffer dtype mismatch, expected '%s' but got %s in '%s.%s'",
26645                  field->type->name, __Pyx_BufFmt_DescribeTypeChar(ctx->enc_type, ctx->is_complex),
26646                  parent->type->name, field->name);
26647   }
26648 }
__Pyx_BufFmt_ProcessTypeChunk(__Pyx_BufFmt_Context * ctx)26649 static int __Pyx_BufFmt_ProcessTypeChunk(__Pyx_BufFmt_Context* ctx) {
26650   char group;
26651   size_t size, offset, arraysize = 1;
26652   if (ctx->enc_type == 0) return 0;
26653   if (ctx->head->field->type->arraysize[0]) {
26654     int i, ndim = 0;
26655     if (ctx->enc_type == 's' || ctx->enc_type == 'p') {
26656         ctx->is_valid_array = ctx->head->field->type->ndim == 1;
26657         ndim = 1;
26658         if (ctx->enc_count != ctx->head->field->type->arraysize[0]) {
26659             PyErr_Format(PyExc_ValueError,
26660                          "Expected a dimension of size %zu, got %zu",
26661                          ctx->head->field->type->arraysize[0], ctx->enc_count);
26662             return -1;
26663         }
26664     }
26665     if (!ctx->is_valid_array) {
26666       PyErr_Format(PyExc_ValueError, "Expected %d dimensions, got %d",
26667                    ctx->head->field->type->ndim, ndim);
26668       return -1;
26669     }
26670     for (i = 0; i < ctx->head->field->type->ndim; i++) {
26671       arraysize *= ctx->head->field->type->arraysize[i];
26672     }
26673     ctx->is_valid_array = 0;
26674     ctx->enc_count = 1;
26675   }
26676   group = __Pyx_BufFmt_TypeCharToGroup(ctx->enc_type, ctx->is_complex);
26677   do {
26678     __Pyx_StructField* field = ctx->head->field;
26679     __Pyx_TypeInfo* type = field->type;
26680     if (ctx->enc_packmode == '@' || ctx->enc_packmode == '^') {
26681       size = __Pyx_BufFmt_TypeCharToNativeSize(ctx->enc_type, ctx->is_complex);
26682     } else {
26683       size = __Pyx_BufFmt_TypeCharToStandardSize(ctx->enc_type, ctx->is_complex);
26684     }
26685     if (ctx->enc_packmode == '@') {
26686       size_t align_at = __Pyx_BufFmt_TypeCharToAlignment(ctx->enc_type, ctx->is_complex);
26687       size_t align_mod_offset;
26688       if (align_at == 0) return -1;
26689       align_mod_offset = ctx->fmt_offset % align_at;
26690       if (align_mod_offset > 0) ctx->fmt_offset += align_at - align_mod_offset;
26691       if (ctx->struct_alignment == 0)
26692           ctx->struct_alignment = __Pyx_BufFmt_TypeCharToPadding(ctx->enc_type,
26693                                                                  ctx->is_complex);
26694     }
26695     if (type->size != size || type->typegroup != group) {
26696       if (type->typegroup == 'C' && type->fields != NULL) {
26697         size_t parent_offset = ctx->head->parent_offset + field->offset;
26698         ++ctx->head;
26699         ctx->head->field = type->fields;
26700         ctx->head->parent_offset = parent_offset;
26701         continue;
26702       }
26703       if ((type->typegroup == 'H' || group == 'H') && type->size == size) {
26704       } else {
26705           __Pyx_BufFmt_RaiseExpected(ctx);
26706           return -1;
26707       }
26708     }
26709     offset = ctx->head->parent_offset + field->offset;
26710     if (ctx->fmt_offset != offset) {
26711       PyErr_Format(PyExc_ValueError,
26712                    "Buffer dtype mismatch; next field is at offset %" CYTHON_FORMAT_SSIZE_T "d but %" CYTHON_FORMAT_SSIZE_T "d expected",
26713                    (Py_ssize_t)ctx->fmt_offset, (Py_ssize_t)offset);
26714       return -1;
26715     }
26716     ctx->fmt_offset += size;
26717     if (arraysize)
26718       ctx->fmt_offset += (arraysize - 1) * size;
26719     --ctx->enc_count;
26720     while (1) {
26721       if (field == &ctx->root) {
26722         ctx->head = NULL;
26723         if (ctx->enc_count != 0) {
26724           __Pyx_BufFmt_RaiseExpected(ctx);
26725           return -1;
26726         }
26727         break;
26728       }
26729       ctx->head->field = ++field;
26730       if (field->type == NULL) {
26731         --ctx->head;
26732         field = ctx->head->field;
26733         continue;
26734       } else if (field->type->typegroup == 'S') {
26735         size_t parent_offset = ctx->head->parent_offset + field->offset;
26736         if (field->type->fields->type == NULL) continue;
26737         field = field->type->fields;
26738         ++ctx->head;
26739         ctx->head->field = field;
26740         ctx->head->parent_offset = parent_offset;
26741         break;
26742       } else {
26743         break;
26744       }
26745     }
26746   } while (ctx->enc_count);
26747   ctx->enc_type = 0;
26748   ctx->is_complex = 0;
26749   return 0;
26750 }
26751 static PyObject *
__pyx_buffmt_parse_array(__Pyx_BufFmt_Context * ctx,const char ** tsp)26752 __pyx_buffmt_parse_array(__Pyx_BufFmt_Context* ctx, const char** tsp)
26753 {
26754     const char *ts = *tsp;
26755     int i = 0, number, ndim;
26756     ++ts;
26757     if (ctx->new_count != 1) {
26758         PyErr_SetString(PyExc_ValueError,
26759                         "Cannot handle repeated arrays in format string");
26760         return NULL;
26761     }
26762     if (__Pyx_BufFmt_ProcessTypeChunk(ctx) == -1) return NULL;
26763     ndim = ctx->head->field->type->ndim;
26764     while (*ts && *ts != ')') {
26765         switch (*ts) {
26766             case ' ': case '\f': case '\r': case '\n': case '\t': case '\v':  continue;
26767             default:  break;
26768         }
26769         number = __Pyx_BufFmt_ExpectNumber(&ts);
26770         if (number == -1) return NULL;
26771         if (i < ndim && (size_t) number != ctx->head->field->type->arraysize[i])
26772             return PyErr_Format(PyExc_ValueError,
26773                         "Expected a dimension of size %zu, got %d",
26774                         ctx->head->field->type->arraysize[i], number);
26775         if (*ts != ',' && *ts != ')')
26776             return PyErr_Format(PyExc_ValueError,
26777                                 "Expected a comma in format string, got '%c'", *ts);
26778         if (*ts == ',') ts++;
26779         i++;
26780     }
26781     if (i != ndim)
26782         return PyErr_Format(PyExc_ValueError, "Expected %d dimension(s), got %d",
26783                             ctx->head->field->type->ndim, i);
26784     if (!*ts) {
26785         PyErr_SetString(PyExc_ValueError,
26786                         "Unexpected end of format string, expected ')'");
26787         return NULL;
26788     }
26789     ctx->is_valid_array = 1;
26790     ctx->new_count = 1;
26791     *tsp = ++ts;
26792     return Py_None;
26793 }
__Pyx_BufFmt_CheckString(__Pyx_BufFmt_Context * ctx,const char * ts)26794 static const char* __Pyx_BufFmt_CheckString(__Pyx_BufFmt_Context* ctx, const char* ts) {
26795   int got_Z = 0;
26796   while (1) {
26797     switch(*ts) {
26798       case 0:
26799         if (ctx->enc_type != 0 && ctx->head == NULL) {
26800           __Pyx_BufFmt_RaiseExpected(ctx);
26801           return NULL;
26802         }
26803         if (__Pyx_BufFmt_ProcessTypeChunk(ctx) == -1) return NULL;
26804         if (ctx->head != NULL) {
26805           __Pyx_BufFmt_RaiseExpected(ctx);
26806           return NULL;
26807         }
26808         return ts;
26809       case ' ':
26810       case '\r':
26811       case '\n':
26812         ++ts;
26813         break;
26814       case '<':
26815         if (!__Pyx_Is_Little_Endian()) {
26816           PyErr_SetString(PyExc_ValueError, "Little-endian buffer not supported on big-endian compiler");
26817           return NULL;
26818         }
26819         ctx->new_packmode = '=';
26820         ++ts;
26821         break;
26822       case '>':
26823       case '!':
26824         if (__Pyx_Is_Little_Endian()) {
26825           PyErr_SetString(PyExc_ValueError, "Big-endian buffer not supported on little-endian compiler");
26826           return NULL;
26827         }
26828         ctx->new_packmode = '=';
26829         ++ts;
26830         break;
26831       case '=':
26832       case '@':
26833       case '^':
26834         ctx->new_packmode = *ts++;
26835         break;
26836       case 'T':
26837         {
26838           const char* ts_after_sub;
26839           size_t i, struct_count = ctx->new_count;
26840           size_t struct_alignment = ctx->struct_alignment;
26841           ctx->new_count = 1;
26842           ++ts;
26843           if (*ts != '{') {
26844             PyErr_SetString(PyExc_ValueError, "Buffer acquisition: Expected '{' after 'T'");
26845             return NULL;
26846           }
26847           if (__Pyx_BufFmt_ProcessTypeChunk(ctx) == -1) return NULL;
26848           ctx->enc_type = 0;
26849           ctx->enc_count = 0;
26850           ctx->struct_alignment = 0;
26851           ++ts;
26852           ts_after_sub = ts;
26853           for (i = 0; i != struct_count; ++i) {
26854             ts_after_sub = __Pyx_BufFmt_CheckString(ctx, ts);
26855             if (!ts_after_sub) return NULL;
26856           }
26857           ts = ts_after_sub;
26858           if (struct_alignment) ctx->struct_alignment = struct_alignment;
26859         }
26860         break;
26861       case '}':
26862         {
26863           size_t alignment = ctx->struct_alignment;
26864           ++ts;
26865           if (__Pyx_BufFmt_ProcessTypeChunk(ctx) == -1) return NULL;
26866           ctx->enc_type = 0;
26867           if (alignment && ctx->fmt_offset % alignment) {
26868             ctx->fmt_offset += alignment - (ctx->fmt_offset % alignment);
26869           }
26870         }
26871         return ts;
26872       case 'x':
26873         if (__Pyx_BufFmt_ProcessTypeChunk(ctx) == -1) return NULL;
26874         ctx->fmt_offset += ctx->new_count;
26875         ctx->new_count = 1;
26876         ctx->enc_count = 0;
26877         ctx->enc_type = 0;
26878         ctx->enc_packmode = ctx->new_packmode;
26879         ++ts;
26880         break;
26881       case 'Z':
26882         got_Z = 1;
26883         ++ts;
26884         if (*ts != 'f' && *ts != 'd' && *ts != 'g') {
26885           __Pyx_BufFmt_RaiseUnexpectedChar('Z');
26886           return NULL;
26887         }
26888         CYTHON_FALLTHROUGH;
26889       case '?': case 'c': case 'b': case 'B': case 'h': case 'H': case 'i': case 'I':
26890       case 'l': case 'L': case 'q': case 'Q':
26891       case 'f': case 'd': case 'g':
26892       case 'O': case 'p':
26893         if ((ctx->enc_type == *ts) && (got_Z == ctx->is_complex) &&
26894             (ctx->enc_packmode == ctx->new_packmode) && (!ctx->is_valid_array)) {
26895           ctx->enc_count += ctx->new_count;
26896           ctx->new_count = 1;
26897           got_Z = 0;
26898           ++ts;
26899           break;
26900         }
26901         CYTHON_FALLTHROUGH;
26902       case 's':
26903         if (__Pyx_BufFmt_ProcessTypeChunk(ctx) == -1) return NULL;
26904         ctx->enc_count = ctx->new_count;
26905         ctx->enc_packmode = ctx->new_packmode;
26906         ctx->enc_type = *ts;
26907         ctx->is_complex = got_Z;
26908         ++ts;
26909         ctx->new_count = 1;
26910         got_Z = 0;
26911         break;
26912       case ':':
26913         ++ts;
26914         while(*ts != ':') ++ts;
26915         ++ts;
26916         break;
26917       case '(':
26918         if (!__pyx_buffmt_parse_array(ctx, &ts)) return NULL;
26919         break;
26920       default:
26921         {
26922           int number = __Pyx_BufFmt_ExpectNumber(&ts);
26923           if (number == -1) return NULL;
26924           ctx->new_count = (size_t)number;
26925         }
26926     }
26927   }
26928 }
26929 
26930 /* BufferGetAndValidate */
__Pyx_SafeReleaseBuffer(Py_buffer * info)26931   static CYTHON_INLINE void __Pyx_SafeReleaseBuffer(Py_buffer* info) {
26932   if (unlikely(info->buf == NULL)) return;
26933   if (info->suboffsets == __Pyx_minusones) info->suboffsets = NULL;
26934   __Pyx_ReleaseBuffer(info);
26935 }
__Pyx_ZeroBuffer(Py_buffer * buf)26936 static void __Pyx_ZeroBuffer(Py_buffer* buf) {
26937   buf->buf = NULL;
26938   buf->obj = NULL;
26939   buf->strides = __Pyx_zeros;
26940   buf->shape = __Pyx_zeros;
26941   buf->suboffsets = __Pyx_minusones;
26942 }
__Pyx__GetBufferAndValidate(Py_buffer * buf,PyObject * obj,__Pyx_TypeInfo * dtype,int flags,int nd,int cast,__Pyx_BufFmt_StackElem * stack)26943 static int __Pyx__GetBufferAndValidate(
26944         Py_buffer* buf, PyObject* obj,  __Pyx_TypeInfo* dtype, int flags,
26945         int nd, int cast, __Pyx_BufFmt_StackElem* stack)
26946 {
26947   buf->buf = NULL;
26948   if (unlikely(__Pyx_GetBuffer(obj, buf, flags) == -1)) {
26949     __Pyx_ZeroBuffer(buf);
26950     return -1;
26951   }
26952   if (unlikely(buf->ndim != nd)) {
26953     PyErr_Format(PyExc_ValueError,
26954                  "Buffer has wrong number of dimensions (expected %d, got %d)",
26955                  nd, buf->ndim);
26956     goto fail;
26957   }
26958   if (!cast) {
26959     __Pyx_BufFmt_Context ctx;
26960     __Pyx_BufFmt_Init(&ctx, stack, dtype);
26961     if (!__Pyx_BufFmt_CheckString(&ctx, buf->format)) goto fail;
26962   }
26963   if (unlikely((size_t)buf->itemsize != dtype->size)) {
26964     PyErr_Format(PyExc_ValueError,
26965       "Item size of buffer (%" CYTHON_FORMAT_SSIZE_T "d byte%s) does not match size of '%s' (%" CYTHON_FORMAT_SSIZE_T "d byte%s)",
26966       buf->itemsize, (buf->itemsize > 1) ? "s" : "",
26967       dtype->name, (Py_ssize_t)dtype->size, (dtype->size > 1) ? "s" : "");
26968     goto fail;
26969   }
26970   if (buf->suboffsets == NULL) buf->suboffsets = __Pyx_minusones;
26971   return 0;
26972 fail:;
26973   __Pyx_SafeReleaseBuffer(buf);
26974   return -1;
26975 }
26976 
26977 /* BufferFallbackError */
__Pyx_RaiseBufferFallbackError(void)26978   static void __Pyx_RaiseBufferFallbackError(void) {
26979   PyErr_SetString(PyExc_ValueError,
26980      "Buffer acquisition failed on assignment; and then reacquiring the old buffer failed too!");
26981 }
26982 
26983 /* PyDictVersioning */
26984   #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_TYPE_SLOTS
__Pyx_get_tp_dict_version(PyObject * obj)26985 static CYTHON_INLINE PY_UINT64_T __Pyx_get_tp_dict_version(PyObject *obj) {
26986     PyObject *dict = Py_TYPE(obj)->tp_dict;
26987     return likely(dict) ? __PYX_GET_DICT_VERSION(dict) : 0;
26988 }
__Pyx_get_object_dict_version(PyObject * obj)26989 static CYTHON_INLINE PY_UINT64_T __Pyx_get_object_dict_version(PyObject *obj) {
26990     PyObject **dictptr = NULL;
26991     Py_ssize_t offset = Py_TYPE(obj)->tp_dictoffset;
26992     if (offset) {
26993 #if CYTHON_COMPILING_IN_CPYTHON
26994         dictptr = (likely(offset > 0)) ? (PyObject **) ((char *)obj + offset) : _PyObject_GetDictPtr(obj);
26995 #else
26996         dictptr = _PyObject_GetDictPtr(obj);
26997 #endif
26998     }
26999     return (dictptr && *dictptr) ? __PYX_GET_DICT_VERSION(*dictptr) : 0;
27000 }
__Pyx_object_dict_version_matches(PyObject * obj,PY_UINT64_T tp_dict_version,PY_UINT64_T obj_dict_version)27001 static CYTHON_INLINE int __Pyx_object_dict_version_matches(PyObject* obj, PY_UINT64_T tp_dict_version, PY_UINT64_T obj_dict_version) {
27002     PyObject *dict = Py_TYPE(obj)->tp_dict;
27003     if (unlikely(!dict) || unlikely(tp_dict_version != __PYX_GET_DICT_VERSION(dict)))
27004         return 0;
27005     return obj_dict_version == __Pyx_get_object_dict_version(obj);
27006 }
27007 #endif
27008 
27009 /* GetModuleGlobalName */
27010   #if CYTHON_USE_DICT_VERSIONS
__Pyx__GetModuleGlobalName(PyObject * name,PY_UINT64_T * dict_version,PyObject ** dict_cached_value)27011 static PyObject *__Pyx__GetModuleGlobalName(PyObject *name, PY_UINT64_T *dict_version, PyObject **dict_cached_value)
27012 #else
27013 static CYTHON_INLINE PyObject *__Pyx__GetModuleGlobalName(PyObject *name)
27014 #endif
27015 {
27016     PyObject *result;
27017 #if !CYTHON_AVOID_BORROWED_REFS
27018 #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030500A1
27019     result = _PyDict_GetItem_KnownHash(__pyx_d, name, ((PyASCIIObject *) name)->hash);
27020     __PYX_UPDATE_DICT_CACHE(__pyx_d, result, *dict_cached_value, *dict_version)
27021     if (likely(result)) {
27022         return __Pyx_NewRef(result);
27023     } else if (unlikely(PyErr_Occurred())) {
27024         return NULL;
27025     }
27026 #else
27027     result = PyDict_GetItem(__pyx_d, name);
27028     __PYX_UPDATE_DICT_CACHE(__pyx_d, result, *dict_cached_value, *dict_version)
27029     if (likely(result)) {
27030         return __Pyx_NewRef(result);
27031     }
27032 #endif
27033 #else
27034     result = PyObject_GetItem(__pyx_d, name);
27035     __PYX_UPDATE_DICT_CACHE(__pyx_d, result, *dict_cached_value, *dict_version)
27036     if (likely(result)) {
27037         return __Pyx_NewRef(result);
27038     }
27039     PyErr_Clear();
27040 #endif
27041     return __Pyx_GetBuiltinName(name);
27042 }
27043 
27044 /* GetItemInt */
__Pyx_GetItemInt_Generic(PyObject * o,PyObject * j)27045   static PyObject *__Pyx_GetItemInt_Generic(PyObject *o, PyObject* j) {
27046     PyObject *r;
27047     if (!j) return NULL;
27048     r = PyObject_GetItem(o, j);
27049     Py_DECREF(j);
27050     return r;
27051 }
__Pyx_GetItemInt_List_Fast(PyObject * o,Py_ssize_t i,CYTHON_NCP_UNUSED int wraparound,CYTHON_NCP_UNUSED int boundscheck)27052 static CYTHON_INLINE PyObject *__Pyx_GetItemInt_List_Fast(PyObject *o, Py_ssize_t i,
27053                                                               CYTHON_NCP_UNUSED int wraparound,
27054                                                               CYTHON_NCP_UNUSED int boundscheck) {
27055 #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
27056     Py_ssize_t wrapped_i = i;
27057     if (wraparound & unlikely(i < 0)) {
27058         wrapped_i += PyList_GET_SIZE(o);
27059     }
27060     if ((!boundscheck) || likely(__Pyx_is_valid_index(wrapped_i, PyList_GET_SIZE(o)))) {
27061         PyObject *r = PyList_GET_ITEM(o, wrapped_i);
27062         Py_INCREF(r);
27063         return r;
27064     }
27065     return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i));
27066 #else
27067     return PySequence_GetItem(o, i);
27068 #endif
27069 }
__Pyx_GetItemInt_Tuple_Fast(PyObject * o,Py_ssize_t i,CYTHON_NCP_UNUSED int wraparound,CYTHON_NCP_UNUSED int boundscheck)27070 static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Tuple_Fast(PyObject *o, Py_ssize_t i,
27071                                                               CYTHON_NCP_UNUSED int wraparound,
27072                                                               CYTHON_NCP_UNUSED int boundscheck) {
27073 #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
27074     Py_ssize_t wrapped_i = i;
27075     if (wraparound & unlikely(i < 0)) {
27076         wrapped_i += PyTuple_GET_SIZE(o);
27077     }
27078     if ((!boundscheck) || likely(__Pyx_is_valid_index(wrapped_i, PyTuple_GET_SIZE(o)))) {
27079         PyObject *r = PyTuple_GET_ITEM(o, wrapped_i);
27080         Py_INCREF(r);
27081         return r;
27082     }
27083     return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i));
27084 #else
27085     return PySequence_GetItem(o, i);
27086 #endif
27087 }
__Pyx_GetItemInt_Fast(PyObject * o,Py_ssize_t i,int is_list,CYTHON_NCP_UNUSED int wraparound,CYTHON_NCP_UNUSED int boundscheck)27088 static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Fast(PyObject *o, Py_ssize_t i, int is_list,
27089                                                      CYTHON_NCP_UNUSED int wraparound,
27090                                                      CYTHON_NCP_UNUSED int boundscheck) {
27091 #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS && CYTHON_USE_TYPE_SLOTS
27092     if (is_list || PyList_CheckExact(o)) {
27093         Py_ssize_t n = ((!wraparound) | likely(i >= 0)) ? i : i + PyList_GET_SIZE(o);
27094         if ((!boundscheck) || (likely(__Pyx_is_valid_index(n, PyList_GET_SIZE(o))))) {
27095             PyObject *r = PyList_GET_ITEM(o, n);
27096             Py_INCREF(r);
27097             return r;
27098         }
27099     }
27100     else if (PyTuple_CheckExact(o)) {
27101         Py_ssize_t n = ((!wraparound) | likely(i >= 0)) ? i : i + PyTuple_GET_SIZE(o);
27102         if ((!boundscheck) || likely(__Pyx_is_valid_index(n, PyTuple_GET_SIZE(o)))) {
27103             PyObject *r = PyTuple_GET_ITEM(o, n);
27104             Py_INCREF(r);
27105             return r;
27106         }
27107     } else {
27108         PySequenceMethods *m = Py_TYPE(o)->tp_as_sequence;
27109         if (likely(m && m->sq_item)) {
27110             if (wraparound && unlikely(i < 0) && likely(m->sq_length)) {
27111                 Py_ssize_t l = m->sq_length(o);
27112                 if (likely(l >= 0)) {
27113                     i += l;
27114                 } else {
27115                     if (!PyErr_ExceptionMatches(PyExc_OverflowError))
27116                         return NULL;
27117                     PyErr_Clear();
27118                 }
27119             }
27120             return m->sq_item(o, i);
27121         }
27122     }
27123 #else
27124     if (is_list || PySequence_Check(o)) {
27125         return PySequence_GetItem(o, i);
27126     }
27127 #endif
27128     return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i));
27129 }
27130 
27131 /* MemviewSliceInit */
27132   static int
__Pyx_init_memviewslice(struct __pyx_memoryview_obj * memview,int ndim,__Pyx_memviewslice * memviewslice,int memview_is_new_reference)27133 __Pyx_init_memviewslice(struct __pyx_memoryview_obj *memview,
27134                         int ndim,
27135                         __Pyx_memviewslice *memviewslice,
27136                         int memview_is_new_reference)
27137 {
27138     __Pyx_RefNannyDeclarations
27139     int i, retval=-1;
27140     Py_buffer *buf = &memview->view;
27141     __Pyx_RefNannySetupContext("init_memviewslice", 0);
27142     if (unlikely(memviewslice->memview || memviewslice->data)) {
27143         PyErr_SetString(PyExc_ValueError,
27144             "memviewslice is already initialized!");
27145         goto fail;
27146     }
27147     if (buf->strides) {
27148         for (i = 0; i < ndim; i++) {
27149             memviewslice->strides[i] = buf->strides[i];
27150         }
27151     } else {
27152         Py_ssize_t stride = buf->itemsize;
27153         for (i = ndim - 1; i >= 0; i--) {
27154             memviewslice->strides[i] = stride;
27155             stride *= buf->shape[i];
27156         }
27157     }
27158     for (i = 0; i < ndim; i++) {
27159         memviewslice->shape[i]   = buf->shape[i];
27160         if (buf->suboffsets) {
27161             memviewslice->suboffsets[i] = buf->suboffsets[i];
27162         } else {
27163             memviewslice->suboffsets[i] = -1;
27164         }
27165     }
27166     memviewslice->memview = memview;
27167     memviewslice->data = (char *)buf->buf;
27168     if (__pyx_add_acquisition_count(memview) == 0 && !memview_is_new_reference) {
27169         Py_INCREF(memview);
27170     }
27171     retval = 0;
27172     goto no_fail;
27173 fail:
27174     memviewslice->memview = 0;
27175     memviewslice->data = 0;
27176     retval = -1;
27177 no_fail:
27178     __Pyx_RefNannyFinishContext();
27179     return retval;
27180 }
27181 #ifndef Py_NO_RETURN
27182 #define Py_NO_RETURN
27183 #endif
__pyx_fatalerror(const char * fmt,...)27184 static void __pyx_fatalerror(const char *fmt, ...) Py_NO_RETURN {
27185     va_list vargs;
27186     char msg[200];
27187 #ifdef HAVE_STDARG_PROTOTYPES
27188     va_start(vargs, fmt);
27189 #else
27190     va_start(vargs);
27191 #endif
27192     vsnprintf(msg, 200, fmt, vargs);
27193     va_end(vargs);
27194     Py_FatalError(msg);
27195 }
27196 static CYTHON_INLINE int
__pyx_add_acquisition_count_locked(__pyx_atomic_int * acquisition_count,PyThread_type_lock lock)27197 __pyx_add_acquisition_count_locked(__pyx_atomic_int *acquisition_count,
27198                                    PyThread_type_lock lock)
27199 {
27200     int result;
27201     PyThread_acquire_lock(lock, 1);
27202     result = (*acquisition_count)++;
27203     PyThread_release_lock(lock);
27204     return result;
27205 }
27206 static CYTHON_INLINE int
__pyx_sub_acquisition_count_locked(__pyx_atomic_int * acquisition_count,PyThread_type_lock lock)27207 __pyx_sub_acquisition_count_locked(__pyx_atomic_int *acquisition_count,
27208                                    PyThread_type_lock lock)
27209 {
27210     int result;
27211     PyThread_acquire_lock(lock, 1);
27212     result = (*acquisition_count)--;
27213     PyThread_release_lock(lock);
27214     return result;
27215 }
27216 static CYTHON_INLINE void
__Pyx_INC_MEMVIEW(__Pyx_memviewslice * memslice,int have_gil,int lineno)27217 __Pyx_INC_MEMVIEW(__Pyx_memviewslice *memslice, int have_gil, int lineno)
27218 {
27219     int first_time;
27220     struct __pyx_memoryview_obj *memview = memslice->memview;
27221     if (unlikely(!memview || (PyObject *) memview == Py_None))
27222         return;
27223     if (unlikely(__pyx_get_slice_count(memview) < 0))
27224         __pyx_fatalerror("Acquisition count is %d (line %d)",
27225                          __pyx_get_slice_count(memview), lineno);
27226     first_time = __pyx_add_acquisition_count(memview) == 0;
27227     if (unlikely(first_time)) {
27228         if (have_gil) {
27229             Py_INCREF((PyObject *) memview);
27230         } else {
27231             PyGILState_STATE _gilstate = PyGILState_Ensure();
27232             Py_INCREF((PyObject *) memview);
27233             PyGILState_Release(_gilstate);
27234         }
27235     }
27236 }
__Pyx_XDEC_MEMVIEW(__Pyx_memviewslice * memslice,int have_gil,int lineno)27237 static CYTHON_INLINE void __Pyx_XDEC_MEMVIEW(__Pyx_memviewslice *memslice,
27238                                              int have_gil, int lineno) {
27239     int last_time;
27240     struct __pyx_memoryview_obj *memview = memslice->memview;
27241     if (unlikely(!memview || (PyObject *) memview == Py_None)) {
27242         memslice->memview = NULL;
27243         return;
27244     }
27245     if (unlikely(__pyx_get_slice_count(memview) <= 0))
27246         __pyx_fatalerror("Acquisition count is %d (line %d)",
27247                          __pyx_get_slice_count(memview), lineno);
27248     last_time = __pyx_sub_acquisition_count(memview) == 1;
27249     memslice->data = NULL;
27250     if (unlikely(last_time)) {
27251         if (have_gil) {
27252             Py_CLEAR(memslice->memview);
27253         } else {
27254             PyGILState_STATE _gilstate = PyGILState_Ensure();
27255             Py_CLEAR(memslice->memview);
27256             PyGILState_Release(_gilstate);
27257         }
27258     } else {
27259         memslice->memview = NULL;
27260     }
27261 }
27262 
27263 /* RaiseArgTupleInvalid */
__Pyx_RaiseArgtupleInvalid(const char * func_name,int exact,Py_ssize_t num_min,Py_ssize_t num_max,Py_ssize_t num_found)27264   static void __Pyx_RaiseArgtupleInvalid(
27265     const char* func_name,
27266     int exact,
27267     Py_ssize_t num_min,
27268     Py_ssize_t num_max,
27269     Py_ssize_t num_found)
27270 {
27271     Py_ssize_t num_expected;
27272     const char *more_or_less;
27273     if (num_found < num_min) {
27274         num_expected = num_min;
27275         more_or_less = "at least";
27276     } else {
27277         num_expected = num_max;
27278         more_or_less = "at most";
27279     }
27280     if (exact) {
27281         more_or_less = "exactly";
27282     }
27283     PyErr_Format(PyExc_TypeError,
27284                  "%.200s() takes %.8s %" CYTHON_FORMAT_SSIZE_T "d positional argument%.1s (%" CYTHON_FORMAT_SSIZE_T "d given)",
27285                  func_name, more_or_less, num_expected,
27286                  (num_expected == 1) ? "" : "s", num_found);
27287 }
27288 
27289 /* RaiseDoubleKeywords */
__Pyx_RaiseDoubleKeywordsError(const char * func_name,PyObject * kw_name)27290   static void __Pyx_RaiseDoubleKeywordsError(
27291     const char* func_name,
27292     PyObject* kw_name)
27293 {
27294     PyErr_Format(PyExc_TypeError,
27295         #if PY_MAJOR_VERSION >= 3
27296         "%s() got multiple values for keyword argument '%U'", func_name, kw_name);
27297         #else
27298         "%s() got multiple values for keyword argument '%s'", func_name,
27299         PyString_AsString(kw_name));
27300         #endif
27301 }
27302 
27303 /* ParseKeywords */
__Pyx_ParseOptionalKeywords(PyObject * kwds,PyObject ** argnames[],PyObject * kwds2,PyObject * values[],Py_ssize_t num_pos_args,const char * function_name)27304   static int __Pyx_ParseOptionalKeywords(
27305     PyObject *kwds,
27306     PyObject **argnames[],
27307     PyObject *kwds2,
27308     PyObject *values[],
27309     Py_ssize_t num_pos_args,
27310     const char* function_name)
27311 {
27312     PyObject *key = 0, *value = 0;
27313     Py_ssize_t pos = 0;
27314     PyObject*** name;
27315     PyObject*** first_kw_arg = argnames + num_pos_args;
27316     while (PyDict_Next(kwds, &pos, &key, &value)) {
27317         name = first_kw_arg;
27318         while (*name && (**name != key)) name++;
27319         if (*name) {
27320             values[name-argnames] = value;
27321             continue;
27322         }
27323         name = first_kw_arg;
27324         #if PY_MAJOR_VERSION < 3
27325         if (likely(PyString_Check(key))) {
27326             while (*name) {
27327                 if ((CYTHON_COMPILING_IN_PYPY || PyString_GET_SIZE(**name) == PyString_GET_SIZE(key))
27328                         && _PyString_Eq(**name, key)) {
27329                     values[name-argnames] = value;
27330                     break;
27331                 }
27332                 name++;
27333             }
27334             if (*name) continue;
27335             else {
27336                 PyObject*** argname = argnames;
27337                 while (argname != first_kw_arg) {
27338                     if ((**argname == key) || (
27339                             (CYTHON_COMPILING_IN_PYPY || PyString_GET_SIZE(**argname) == PyString_GET_SIZE(key))
27340                              && _PyString_Eq(**argname, key))) {
27341                         goto arg_passed_twice;
27342                     }
27343                     argname++;
27344                 }
27345             }
27346         } else
27347         #endif
27348         if (likely(PyUnicode_Check(key))) {
27349             while (*name) {
27350                 int cmp = (**name == key) ? 0 :
27351                 #if !CYTHON_COMPILING_IN_PYPY && PY_MAJOR_VERSION >= 3
27352                     (__Pyx_PyUnicode_GET_LENGTH(**name) != __Pyx_PyUnicode_GET_LENGTH(key)) ? 1 :
27353                 #endif
27354                     PyUnicode_Compare(**name, key);
27355                 if (cmp < 0 && unlikely(PyErr_Occurred())) goto bad;
27356                 if (cmp == 0) {
27357                     values[name-argnames] = value;
27358                     break;
27359                 }
27360                 name++;
27361             }
27362             if (*name) continue;
27363             else {
27364                 PyObject*** argname = argnames;
27365                 while (argname != first_kw_arg) {
27366                     int cmp = (**argname == key) ? 0 :
27367                     #if !CYTHON_COMPILING_IN_PYPY && PY_MAJOR_VERSION >= 3
27368                         (__Pyx_PyUnicode_GET_LENGTH(**argname) != __Pyx_PyUnicode_GET_LENGTH(key)) ? 1 :
27369                     #endif
27370                         PyUnicode_Compare(**argname, key);
27371                     if (cmp < 0 && unlikely(PyErr_Occurred())) goto bad;
27372                     if (cmp == 0) goto arg_passed_twice;
27373                     argname++;
27374                 }
27375             }
27376         } else
27377             goto invalid_keyword_type;
27378         if (kwds2) {
27379             if (unlikely(PyDict_SetItem(kwds2, key, value))) goto bad;
27380         } else {
27381             goto invalid_keyword;
27382         }
27383     }
27384     return 0;
27385 arg_passed_twice:
27386     __Pyx_RaiseDoubleKeywordsError(function_name, key);
27387     goto bad;
27388 invalid_keyword_type:
27389     PyErr_Format(PyExc_TypeError,
27390         "%.200s() keywords must be strings", function_name);
27391     goto bad;
27392 invalid_keyword:
27393     PyErr_Format(PyExc_TypeError,
27394     #if PY_MAJOR_VERSION < 3
27395         "%.200s() got an unexpected keyword argument '%.200s'",
27396         function_name, PyString_AsString(key));
27397     #else
27398         "%s() got an unexpected keyword argument '%U'",
27399         function_name, key);
27400     #endif
27401 bad:
27402     return -1;
27403 }
27404 
27405 /* PyCFunctionFastCall */
27406   #if CYTHON_FAST_PYCCALL
__Pyx_PyCFunction_FastCall(PyObject * func_obj,PyObject ** args,Py_ssize_t nargs)27407 static CYTHON_INLINE PyObject * __Pyx_PyCFunction_FastCall(PyObject *func_obj, PyObject **args, Py_ssize_t nargs) {
27408     PyCFunctionObject *func = (PyCFunctionObject*)func_obj;
27409     PyCFunction meth = PyCFunction_GET_FUNCTION(func);
27410     PyObject *self = PyCFunction_GET_SELF(func);
27411     int flags = PyCFunction_GET_FLAGS(func);
27412     assert(PyCFunction_Check(func));
27413     assert(METH_FASTCALL == (flags & ~(METH_CLASS | METH_STATIC | METH_COEXIST | METH_KEYWORDS | METH_STACKLESS)));
27414     assert(nargs >= 0);
27415     assert(nargs == 0 || args != NULL);
27416     /* _PyCFunction_FastCallDict() must not be called with an exception set,
27417        because it may clear it (directly or indirectly) and so the
27418        caller loses its exception */
27419     assert(!PyErr_Occurred());
27420     if ((PY_VERSION_HEX < 0x030700A0) || unlikely(flags & METH_KEYWORDS)) {
27421         return (*((__Pyx_PyCFunctionFastWithKeywords)(void*)meth)) (self, args, nargs, NULL);
27422     } else {
27423         return (*((__Pyx_PyCFunctionFast)(void*)meth)) (self, args, nargs);
27424     }
27425 }
27426 #endif
27427 
27428 /* PyFunctionFastCall */
27429   #if CYTHON_FAST_PYCALL
__Pyx_PyFunction_FastCallNoKw(PyCodeObject * co,PyObject ** args,Py_ssize_t na,PyObject * globals)27430 static PyObject* __Pyx_PyFunction_FastCallNoKw(PyCodeObject *co, PyObject **args, Py_ssize_t na,
27431                                                PyObject *globals) {
27432     PyFrameObject *f;
27433     PyThreadState *tstate = __Pyx_PyThreadState_Current;
27434     PyObject **fastlocals;
27435     Py_ssize_t i;
27436     PyObject *result;
27437     assert(globals != NULL);
27438     /* XXX Perhaps we should create a specialized
27439        PyFrame_New() that doesn't take locals, but does
27440        take builtins without sanity checking them.
27441        */
27442     assert(tstate != NULL);
27443     f = PyFrame_New(tstate, co, globals, NULL);
27444     if (f == NULL) {
27445         return NULL;
27446     }
27447     fastlocals = __Pyx_PyFrame_GetLocalsplus(f);
27448     for (i = 0; i < na; i++) {
27449         Py_INCREF(*args);
27450         fastlocals[i] = *args++;
27451     }
27452     result = PyEval_EvalFrameEx(f,0);
27453     ++tstate->recursion_depth;
27454     Py_DECREF(f);
27455     --tstate->recursion_depth;
27456     return result;
27457 }
27458 #if 1 || PY_VERSION_HEX < 0x030600B1
__Pyx_PyFunction_FastCallDict(PyObject * func,PyObject ** args,Py_ssize_t nargs,PyObject * kwargs)27459 static PyObject *__Pyx_PyFunction_FastCallDict(PyObject *func, PyObject **args, Py_ssize_t nargs, PyObject *kwargs) {
27460     PyCodeObject *co = (PyCodeObject *)PyFunction_GET_CODE(func);
27461     PyObject *globals = PyFunction_GET_GLOBALS(func);
27462     PyObject *argdefs = PyFunction_GET_DEFAULTS(func);
27463     PyObject *closure;
27464 #if PY_MAJOR_VERSION >= 3
27465     PyObject *kwdefs;
27466 #endif
27467     PyObject *kwtuple, **k;
27468     PyObject **d;
27469     Py_ssize_t nd;
27470     Py_ssize_t nk;
27471     PyObject *result;
27472     assert(kwargs == NULL || PyDict_Check(kwargs));
27473     nk = kwargs ? PyDict_Size(kwargs) : 0;
27474     if (Py_EnterRecursiveCall((char*)" while calling a Python object")) {
27475         return NULL;
27476     }
27477     if (
27478 #if PY_MAJOR_VERSION >= 3
27479             co->co_kwonlyargcount == 0 &&
27480 #endif
27481             likely(kwargs == NULL || nk == 0) &&
27482             co->co_flags == (CO_OPTIMIZED | CO_NEWLOCALS | CO_NOFREE)) {
27483         if (argdefs == NULL && co->co_argcount == nargs) {
27484             result = __Pyx_PyFunction_FastCallNoKw(co, args, nargs, globals);
27485             goto done;
27486         }
27487         else if (nargs == 0 && argdefs != NULL
27488                  && co->co_argcount == Py_SIZE(argdefs)) {
27489             /* function called with no arguments, but all parameters have
27490                a default value: use default values as arguments .*/
27491             args = &PyTuple_GET_ITEM(argdefs, 0);
27492             result =__Pyx_PyFunction_FastCallNoKw(co, args, Py_SIZE(argdefs), globals);
27493             goto done;
27494         }
27495     }
27496     if (kwargs != NULL) {
27497         Py_ssize_t pos, i;
27498         kwtuple = PyTuple_New(2 * nk);
27499         if (kwtuple == NULL) {
27500             result = NULL;
27501             goto done;
27502         }
27503         k = &PyTuple_GET_ITEM(kwtuple, 0);
27504         pos = i = 0;
27505         while (PyDict_Next(kwargs, &pos, &k[i], &k[i+1])) {
27506             Py_INCREF(k[i]);
27507             Py_INCREF(k[i+1]);
27508             i += 2;
27509         }
27510         nk = i / 2;
27511     }
27512     else {
27513         kwtuple = NULL;
27514         k = NULL;
27515     }
27516     closure = PyFunction_GET_CLOSURE(func);
27517 #if PY_MAJOR_VERSION >= 3
27518     kwdefs = PyFunction_GET_KW_DEFAULTS(func);
27519 #endif
27520     if (argdefs != NULL) {
27521         d = &PyTuple_GET_ITEM(argdefs, 0);
27522         nd = Py_SIZE(argdefs);
27523     }
27524     else {
27525         d = NULL;
27526         nd = 0;
27527     }
27528 #if PY_MAJOR_VERSION >= 3
27529     result = PyEval_EvalCodeEx((PyObject*)co, globals, (PyObject *)NULL,
27530                                args, (int)nargs,
27531                                k, (int)nk,
27532                                d, (int)nd, kwdefs, closure);
27533 #else
27534     result = PyEval_EvalCodeEx(co, globals, (PyObject *)NULL,
27535                                args, (int)nargs,
27536                                k, (int)nk,
27537                                d, (int)nd, closure);
27538 #endif
27539     Py_XDECREF(kwtuple);
27540 done:
27541     Py_LeaveRecursiveCall();
27542     return result;
27543 }
27544 #endif
27545 #endif
27546 
27547 /* PyObjectCall2Args */
__Pyx_PyObject_Call2Args(PyObject * function,PyObject * arg1,PyObject * arg2)27548   static CYTHON_UNUSED PyObject* __Pyx_PyObject_Call2Args(PyObject* function, PyObject* arg1, PyObject* arg2) {
27549     PyObject *args, *result = NULL;
27550     #if CYTHON_FAST_PYCALL
27551     if (PyFunction_Check(function)) {
27552         PyObject *args[2] = {arg1, arg2};
27553         return __Pyx_PyFunction_FastCall(function, args, 2);
27554     }
27555     #endif
27556     #if CYTHON_FAST_PYCCALL
27557     if (__Pyx_PyFastCFunction_Check(function)) {
27558         PyObject *args[2] = {arg1, arg2};
27559         return __Pyx_PyCFunction_FastCall(function, args, 2);
27560     }
27561     #endif
27562     args = PyTuple_New(2);
27563     if (unlikely(!args)) goto done;
27564     Py_INCREF(arg1);
27565     PyTuple_SET_ITEM(args, 0, arg1);
27566     Py_INCREF(arg2);
27567     PyTuple_SET_ITEM(args, 1, arg2);
27568     Py_INCREF(function);
27569     result = __Pyx_PyObject_Call(function, args, NULL);
27570     Py_DECREF(args);
27571     Py_DECREF(function);
27572 done:
27573     return result;
27574 }
27575 
27576 /* PyObjectCallMethO */
27577   #if CYTHON_COMPILING_IN_CPYTHON
__Pyx_PyObject_CallMethO(PyObject * func,PyObject * arg)27578 static CYTHON_INLINE PyObject* __Pyx_PyObject_CallMethO(PyObject *func, PyObject *arg) {
27579     PyObject *self, *result;
27580     PyCFunction cfunc;
27581     cfunc = PyCFunction_GET_FUNCTION(func);
27582     self = PyCFunction_GET_SELF(func);
27583     if (unlikely(Py_EnterRecursiveCall((char*)" while calling a Python object")))
27584         return NULL;
27585     result = cfunc(self, arg);
27586     Py_LeaveRecursiveCall();
27587     if (unlikely(!result) && unlikely(!PyErr_Occurred())) {
27588         PyErr_SetString(
27589             PyExc_SystemError,
27590             "NULL result without error in PyObject_Call");
27591     }
27592     return result;
27593 }
27594 #endif
27595 
27596 /* PyObjectCallOneArg */
27597   #if CYTHON_COMPILING_IN_CPYTHON
__Pyx__PyObject_CallOneArg(PyObject * func,PyObject * arg)27598 static PyObject* __Pyx__PyObject_CallOneArg(PyObject *func, PyObject *arg) {
27599     PyObject *result;
27600     PyObject *args = PyTuple_New(1);
27601     if (unlikely(!args)) return NULL;
27602     Py_INCREF(arg);
27603     PyTuple_SET_ITEM(args, 0, arg);
27604     result = __Pyx_PyObject_Call(func, args, NULL);
27605     Py_DECREF(args);
27606     return result;
27607 }
__Pyx_PyObject_CallOneArg(PyObject * func,PyObject * arg)27608 static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg) {
27609 #if CYTHON_FAST_PYCALL
27610     if (PyFunction_Check(func)) {
27611         return __Pyx_PyFunction_FastCall(func, &arg, 1);
27612     }
27613 #endif
27614     if (likely(PyCFunction_Check(func))) {
27615         if (likely(PyCFunction_GET_FLAGS(func) & METH_O)) {
27616             return __Pyx_PyObject_CallMethO(func, arg);
27617 #if CYTHON_FAST_PYCCALL
27618         } else if (__Pyx_PyFastCFunction_Check(func)) {
27619             return __Pyx_PyCFunction_FastCall(func, &arg, 1);
27620 #endif
27621         }
27622     }
27623     return __Pyx__PyObject_CallOneArg(func, arg);
27624 }
27625 #else
__Pyx_PyObject_CallOneArg(PyObject * func,PyObject * arg)27626 static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg) {
27627     PyObject *result;
27628     PyObject *args = PyTuple_Pack(1, arg);
27629     if (unlikely(!args)) return NULL;
27630     result = __Pyx_PyObject_Call(func, args, NULL);
27631     Py_DECREF(args);
27632     return result;
27633 }
27634 #endif
27635 
27636 /* ArgTypeTest */
__Pyx__ArgTypeTest(PyObject * obj,PyTypeObject * type,const char * name,int exact)27637   static int __Pyx__ArgTypeTest(PyObject *obj, PyTypeObject *type, const char *name, int exact)
27638 {
27639     if (unlikely(!type)) {
27640         PyErr_SetString(PyExc_SystemError, "Missing type object");
27641         return 0;
27642     }
27643     else if (exact) {
27644         #if PY_MAJOR_VERSION == 2
27645         if ((type == &PyBaseString_Type) && likely(__Pyx_PyBaseString_CheckExact(obj))) return 1;
27646         #endif
27647     }
27648     else {
27649         if (likely(__Pyx_TypeCheck(obj, type))) return 1;
27650     }
27651     PyErr_Format(PyExc_TypeError,
27652         "Argument '%.200s' has incorrect type (expected %.200s, got %.200s)",
27653         name, type->tp_name, Py_TYPE(obj)->tp_name);
27654     return 0;
27655 }
27656 
27657 /* GetTopmostException */
27658   #if CYTHON_USE_EXC_INFO_STACK
27659 static _PyErr_StackItem *
__Pyx_PyErr_GetTopmostException(PyThreadState * tstate)27660 __Pyx_PyErr_GetTopmostException(PyThreadState *tstate)
27661 {
27662     _PyErr_StackItem *exc_info = tstate->exc_info;
27663     while ((exc_info->exc_type == NULL || exc_info->exc_type == Py_None) &&
27664            exc_info->previous_item != NULL)
27665     {
27666         exc_info = exc_info->previous_item;
27667     }
27668     return exc_info;
27669 }
27670 #endif
27671 
27672 /* SaveResetException */
27673   #if CYTHON_FAST_THREAD_STATE
__Pyx__ExceptionSave(PyThreadState * tstate,PyObject ** type,PyObject ** value,PyObject ** tb)27674 static CYTHON_INLINE void __Pyx__ExceptionSave(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) {
27675     #if CYTHON_USE_EXC_INFO_STACK
27676     _PyErr_StackItem *exc_info = __Pyx_PyErr_GetTopmostException(tstate);
27677     *type = exc_info->exc_type;
27678     *value = exc_info->exc_value;
27679     *tb = exc_info->exc_traceback;
27680     #else
27681     *type = tstate->exc_type;
27682     *value = tstate->exc_value;
27683     *tb = tstate->exc_traceback;
27684     #endif
27685     Py_XINCREF(*type);
27686     Py_XINCREF(*value);
27687     Py_XINCREF(*tb);
27688 }
__Pyx__ExceptionReset(PyThreadState * tstate,PyObject * type,PyObject * value,PyObject * tb)27689 static CYTHON_INLINE void __Pyx__ExceptionReset(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb) {
27690     PyObject *tmp_type, *tmp_value, *tmp_tb;
27691     #if CYTHON_USE_EXC_INFO_STACK
27692     _PyErr_StackItem *exc_info = tstate->exc_info;
27693     tmp_type = exc_info->exc_type;
27694     tmp_value = exc_info->exc_value;
27695     tmp_tb = exc_info->exc_traceback;
27696     exc_info->exc_type = type;
27697     exc_info->exc_value = value;
27698     exc_info->exc_traceback = tb;
27699     #else
27700     tmp_type = tstate->exc_type;
27701     tmp_value = tstate->exc_value;
27702     tmp_tb = tstate->exc_traceback;
27703     tstate->exc_type = type;
27704     tstate->exc_value = value;
27705     tstate->exc_traceback = tb;
27706     #endif
27707     Py_XDECREF(tmp_type);
27708     Py_XDECREF(tmp_value);
27709     Py_XDECREF(tmp_tb);
27710 }
27711 #endif
27712 
27713 /* PyErrExceptionMatches */
27714   #if CYTHON_FAST_THREAD_STATE
__Pyx_PyErr_ExceptionMatchesTuple(PyObject * exc_type,PyObject * tuple)27715 static int __Pyx_PyErr_ExceptionMatchesTuple(PyObject *exc_type, PyObject *tuple) {
27716     Py_ssize_t i, n;
27717     n = PyTuple_GET_SIZE(tuple);
27718 #if PY_MAJOR_VERSION >= 3
27719     for (i=0; i<n; i++) {
27720         if (exc_type == PyTuple_GET_ITEM(tuple, i)) return 1;
27721     }
27722 #endif
27723     for (i=0; i<n; i++) {
27724         if (__Pyx_PyErr_GivenExceptionMatches(exc_type, PyTuple_GET_ITEM(tuple, i))) return 1;
27725     }
27726     return 0;
27727 }
__Pyx_PyErr_ExceptionMatchesInState(PyThreadState * tstate,PyObject * err)27728 static CYTHON_INLINE int __Pyx_PyErr_ExceptionMatchesInState(PyThreadState* tstate, PyObject* err) {
27729     PyObject *exc_type = tstate->curexc_type;
27730     if (exc_type == err) return 1;
27731     if (unlikely(!exc_type)) return 0;
27732     if (unlikely(PyTuple_Check(err)))
27733         return __Pyx_PyErr_ExceptionMatchesTuple(exc_type, err);
27734     return __Pyx_PyErr_GivenExceptionMatches(exc_type, err);
27735 }
27736 #endif
27737 
27738 /* GetException */
27739   #if CYTHON_FAST_THREAD_STATE
__Pyx__GetException(PyThreadState * tstate,PyObject ** type,PyObject ** value,PyObject ** tb)27740 static int __Pyx__GetException(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb)
27741 #else
27742 static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb)
27743 #endif
27744 {
27745     PyObject *local_type, *local_value, *local_tb;
27746 #if CYTHON_FAST_THREAD_STATE
27747     PyObject *tmp_type, *tmp_value, *tmp_tb;
27748     local_type = tstate->curexc_type;
27749     local_value = tstate->curexc_value;
27750     local_tb = tstate->curexc_traceback;
27751     tstate->curexc_type = 0;
27752     tstate->curexc_value = 0;
27753     tstate->curexc_traceback = 0;
27754 #else
27755     PyErr_Fetch(&local_type, &local_value, &local_tb);
27756 #endif
27757     PyErr_NormalizeException(&local_type, &local_value, &local_tb);
27758 #if CYTHON_FAST_THREAD_STATE
27759     if (unlikely(tstate->curexc_type))
27760 #else
27761     if (unlikely(PyErr_Occurred()))
27762 #endif
27763         goto bad;
27764     #if PY_MAJOR_VERSION >= 3
27765     if (local_tb) {
27766         if (unlikely(PyException_SetTraceback(local_value, local_tb) < 0))
27767             goto bad;
27768     }
27769     #endif
27770     Py_XINCREF(local_tb);
27771     Py_XINCREF(local_type);
27772     Py_XINCREF(local_value);
27773     *type = local_type;
27774     *value = local_value;
27775     *tb = local_tb;
27776 #if CYTHON_FAST_THREAD_STATE
27777     #if CYTHON_USE_EXC_INFO_STACK
27778     {
27779         _PyErr_StackItem *exc_info = tstate->exc_info;
27780         tmp_type = exc_info->exc_type;
27781         tmp_value = exc_info->exc_value;
27782         tmp_tb = exc_info->exc_traceback;
27783         exc_info->exc_type = local_type;
27784         exc_info->exc_value = local_value;
27785         exc_info->exc_traceback = local_tb;
27786     }
27787     #else
27788     tmp_type = tstate->exc_type;
27789     tmp_value = tstate->exc_value;
27790     tmp_tb = tstate->exc_traceback;
27791     tstate->exc_type = local_type;
27792     tstate->exc_value = local_value;
27793     tstate->exc_traceback = local_tb;
27794     #endif
27795     Py_XDECREF(tmp_type);
27796     Py_XDECREF(tmp_value);
27797     Py_XDECREF(tmp_tb);
27798 #else
27799     PyErr_SetExcInfo(local_type, local_value, local_tb);
27800 #endif
27801     return 0;
27802 bad:
27803     *type = 0;
27804     *value = 0;
27805     *tb = 0;
27806     Py_XDECREF(local_type);
27807     Py_XDECREF(local_value);
27808     Py_XDECREF(local_tb);
27809     return -1;
27810 }
27811 
27812 /* BytesEquals */
__Pyx_PyBytes_Equals(PyObject * s1,PyObject * s2,int equals)27813   static CYTHON_INLINE int __Pyx_PyBytes_Equals(PyObject* s1, PyObject* s2, int equals) {
27814 #if CYTHON_COMPILING_IN_PYPY
27815     return PyObject_RichCompareBool(s1, s2, equals);
27816 #else
27817     if (s1 == s2) {
27818         return (equals == Py_EQ);
27819     } else if (PyBytes_CheckExact(s1) & PyBytes_CheckExact(s2)) {
27820         const char *ps1, *ps2;
27821         Py_ssize_t length = PyBytes_GET_SIZE(s1);
27822         if (length != PyBytes_GET_SIZE(s2))
27823             return (equals == Py_NE);
27824         ps1 = PyBytes_AS_STRING(s1);
27825         ps2 = PyBytes_AS_STRING(s2);
27826         if (ps1[0] != ps2[0]) {
27827             return (equals == Py_NE);
27828         } else if (length == 1) {
27829             return (equals == Py_EQ);
27830         } else {
27831             int result;
27832 #if CYTHON_USE_UNICODE_INTERNALS
27833             Py_hash_t hash1, hash2;
27834             hash1 = ((PyBytesObject*)s1)->ob_shash;
27835             hash2 = ((PyBytesObject*)s2)->ob_shash;
27836             if (hash1 != hash2 && hash1 != -1 && hash2 != -1) {
27837                 return (equals == Py_NE);
27838             }
27839 #endif
27840             result = memcmp(ps1, ps2, (size_t)length);
27841             return (equals == Py_EQ) ? (result == 0) : (result != 0);
27842         }
27843     } else if ((s1 == Py_None) & PyBytes_CheckExact(s2)) {
27844         return (equals == Py_NE);
27845     } else if ((s2 == Py_None) & PyBytes_CheckExact(s1)) {
27846         return (equals == Py_NE);
27847     } else {
27848         int result;
27849         PyObject* py_result = PyObject_RichCompare(s1, s2, equals);
27850         if (!py_result)
27851             return -1;
27852         result = __Pyx_PyObject_IsTrue(py_result);
27853         Py_DECREF(py_result);
27854         return result;
27855     }
27856 #endif
27857 }
27858 
27859 /* UnicodeEquals */
__Pyx_PyUnicode_Equals(PyObject * s1,PyObject * s2,int equals)27860   static CYTHON_INLINE int __Pyx_PyUnicode_Equals(PyObject* s1, PyObject* s2, int equals) {
27861 #if CYTHON_COMPILING_IN_PYPY
27862     return PyObject_RichCompareBool(s1, s2, equals);
27863 #else
27864 #if PY_MAJOR_VERSION < 3
27865     PyObject* owned_ref = NULL;
27866 #endif
27867     int s1_is_unicode, s2_is_unicode;
27868     if (s1 == s2) {
27869         goto return_eq;
27870     }
27871     s1_is_unicode = PyUnicode_CheckExact(s1);
27872     s2_is_unicode = PyUnicode_CheckExact(s2);
27873 #if PY_MAJOR_VERSION < 3
27874     if ((s1_is_unicode & (!s2_is_unicode)) && PyString_CheckExact(s2)) {
27875         owned_ref = PyUnicode_FromObject(s2);
27876         if (unlikely(!owned_ref))
27877             return -1;
27878         s2 = owned_ref;
27879         s2_is_unicode = 1;
27880     } else if ((s2_is_unicode & (!s1_is_unicode)) && PyString_CheckExact(s1)) {
27881         owned_ref = PyUnicode_FromObject(s1);
27882         if (unlikely(!owned_ref))
27883             return -1;
27884         s1 = owned_ref;
27885         s1_is_unicode = 1;
27886     } else if (((!s2_is_unicode) & (!s1_is_unicode))) {
27887         return __Pyx_PyBytes_Equals(s1, s2, equals);
27888     }
27889 #endif
27890     if (s1_is_unicode & s2_is_unicode) {
27891         Py_ssize_t length;
27892         int kind;
27893         void *data1, *data2;
27894         if (unlikely(__Pyx_PyUnicode_READY(s1) < 0) || unlikely(__Pyx_PyUnicode_READY(s2) < 0))
27895             return -1;
27896         length = __Pyx_PyUnicode_GET_LENGTH(s1);
27897         if (length != __Pyx_PyUnicode_GET_LENGTH(s2)) {
27898             goto return_ne;
27899         }
27900 #if CYTHON_USE_UNICODE_INTERNALS
27901         {
27902             Py_hash_t hash1, hash2;
27903         #if CYTHON_PEP393_ENABLED
27904             hash1 = ((PyASCIIObject*)s1)->hash;
27905             hash2 = ((PyASCIIObject*)s2)->hash;
27906         #else
27907             hash1 = ((PyUnicodeObject*)s1)->hash;
27908             hash2 = ((PyUnicodeObject*)s2)->hash;
27909         #endif
27910             if (hash1 != hash2 && hash1 != -1 && hash2 != -1) {
27911                 goto return_ne;
27912             }
27913         }
27914 #endif
27915         kind = __Pyx_PyUnicode_KIND(s1);
27916         if (kind != __Pyx_PyUnicode_KIND(s2)) {
27917             goto return_ne;
27918         }
27919         data1 = __Pyx_PyUnicode_DATA(s1);
27920         data2 = __Pyx_PyUnicode_DATA(s2);
27921         if (__Pyx_PyUnicode_READ(kind, data1, 0) != __Pyx_PyUnicode_READ(kind, data2, 0)) {
27922             goto return_ne;
27923         } else if (length == 1) {
27924             goto return_eq;
27925         } else {
27926             int result = memcmp(data1, data2, (size_t)(length * kind));
27927             #if PY_MAJOR_VERSION < 3
27928             Py_XDECREF(owned_ref);
27929             #endif
27930             return (equals == Py_EQ) ? (result == 0) : (result != 0);
27931         }
27932     } else if ((s1 == Py_None) & s2_is_unicode) {
27933         goto return_ne;
27934     } else if ((s2 == Py_None) & s1_is_unicode) {
27935         goto return_ne;
27936     } else {
27937         int result;
27938         PyObject* py_result = PyObject_RichCompare(s1, s2, equals);
27939         #if PY_MAJOR_VERSION < 3
27940         Py_XDECREF(owned_ref);
27941         #endif
27942         if (!py_result)
27943             return -1;
27944         result = __Pyx_PyObject_IsTrue(py_result);
27945         Py_DECREF(py_result);
27946         return result;
27947     }
27948 return_eq:
27949     #if PY_MAJOR_VERSION < 3
27950     Py_XDECREF(owned_ref);
27951     #endif
27952     return (equals == Py_EQ);
27953 return_ne:
27954     #if PY_MAJOR_VERSION < 3
27955     Py_XDECREF(owned_ref);
27956     #endif
27957     return (equals == Py_NE);
27958 #endif
27959 }
27960 
27961 /* None */
__Pyx_div_Py_ssize_t(Py_ssize_t a,Py_ssize_t b)27962   static CYTHON_INLINE Py_ssize_t __Pyx_div_Py_ssize_t(Py_ssize_t a, Py_ssize_t b) {
27963     Py_ssize_t q = a / b;
27964     Py_ssize_t r = a - q*b;
27965     q -= ((r != 0) & ((r ^ b) < 0));
27966     return q;
27967 }
27968 
27969 /* GetAttr */
__Pyx_GetAttr(PyObject * o,PyObject * n)27970   static CYTHON_INLINE PyObject *__Pyx_GetAttr(PyObject *o, PyObject *n) {
27971 #if CYTHON_USE_TYPE_SLOTS
27972 #if PY_MAJOR_VERSION >= 3
27973     if (likely(PyUnicode_Check(n)))
27974 #else
27975     if (likely(PyString_Check(n)))
27976 #endif
27977         return __Pyx_PyObject_GetAttrStr(o, n);
27978 #endif
27979     return PyObject_GetAttr(o, n);
27980 }
27981 
27982 /* ObjectGetItem */
27983   #if CYTHON_USE_TYPE_SLOTS
__Pyx_PyObject_GetIndex(PyObject * obj,PyObject * index)27984 static PyObject *__Pyx_PyObject_GetIndex(PyObject *obj, PyObject* index) {
27985     PyObject *runerr;
27986     Py_ssize_t key_value;
27987     PySequenceMethods *m = Py_TYPE(obj)->tp_as_sequence;
27988     if (unlikely(!(m && m->sq_item))) {
27989         PyErr_Format(PyExc_TypeError, "'%.200s' object is not subscriptable", Py_TYPE(obj)->tp_name);
27990         return NULL;
27991     }
27992     key_value = __Pyx_PyIndex_AsSsize_t(index);
27993     if (likely(key_value != -1 || !(runerr = PyErr_Occurred()))) {
27994         return __Pyx_GetItemInt_Fast(obj, key_value, 0, 1, 1);
27995     }
27996     if (PyErr_GivenExceptionMatches(runerr, PyExc_OverflowError)) {
27997         PyErr_Clear();
27998         PyErr_Format(PyExc_IndexError, "cannot fit '%.200s' into an index-sized integer", Py_TYPE(index)->tp_name);
27999     }
28000     return NULL;
28001 }
__Pyx_PyObject_GetItem(PyObject * obj,PyObject * key)28002 static PyObject *__Pyx_PyObject_GetItem(PyObject *obj, PyObject* key) {
28003     PyMappingMethods *m = Py_TYPE(obj)->tp_as_mapping;
28004     if (likely(m && m->mp_subscript)) {
28005         return m->mp_subscript(obj, key);
28006     }
28007     return __Pyx_PyObject_GetIndex(obj, key);
28008 }
28009 #endif
28010 
28011 /* 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))28012   static CYTHON_INLINE PyObject* __Pyx_decode_c_string(
28013          const char* cstring, Py_ssize_t start, Py_ssize_t stop,
28014          const char* encoding, const char* errors,
28015          PyObject* (*decode_func)(const char *s, Py_ssize_t size, const char *errors)) {
28016     Py_ssize_t length;
28017     if (unlikely((start < 0) | (stop < 0))) {
28018         size_t slen = strlen(cstring);
28019         if (unlikely(slen > (size_t) PY_SSIZE_T_MAX)) {
28020             PyErr_SetString(PyExc_OverflowError,
28021                             "c-string too long to convert to Python");
28022             return NULL;
28023         }
28024         length = (Py_ssize_t) slen;
28025         if (start < 0) {
28026             start += length;
28027             if (start < 0)
28028                 start = 0;
28029         }
28030         if (stop < 0)
28031             stop += length;
28032     }
28033     if (unlikely(stop <= start))
28034         return __Pyx_NewRef(__pyx_empty_unicode);
28035     length = stop - start;
28036     cstring += start;
28037     if (decode_func) {
28038         return decode_func(cstring, length, errors);
28039     } else {
28040         return PyUnicode_Decode(cstring, length, encoding, errors);
28041     }
28042 }
28043 
28044 /* GetAttr3 */
__Pyx_GetAttr3Default(PyObject * d)28045   static PyObject *__Pyx_GetAttr3Default(PyObject *d) {
28046     __Pyx_PyThreadState_declare
28047     __Pyx_PyThreadState_assign
28048     if (unlikely(!__Pyx_PyErr_ExceptionMatches(PyExc_AttributeError)))
28049         return NULL;
28050     __Pyx_PyErr_Clear();
28051     Py_INCREF(d);
28052     return d;
28053 }
__Pyx_GetAttr3(PyObject * o,PyObject * n,PyObject * d)28054 static CYTHON_INLINE PyObject *__Pyx_GetAttr3(PyObject *o, PyObject *n, PyObject *d) {
28055     PyObject *r = __Pyx_GetAttr(o, n);
28056     return (likely(r)) ? r : __Pyx_GetAttr3Default(d);
28057 }
28058 
28059 /* RaiseTooManyValuesToUnpack */
__Pyx_RaiseTooManyValuesError(Py_ssize_t expected)28060   static CYTHON_INLINE void __Pyx_RaiseTooManyValuesError(Py_ssize_t expected) {
28061     PyErr_Format(PyExc_ValueError,
28062                  "too many values to unpack (expected %" CYTHON_FORMAT_SSIZE_T "d)", expected);
28063 }
28064 
28065 /* RaiseNeedMoreValuesToUnpack */
__Pyx_RaiseNeedMoreValuesError(Py_ssize_t index)28066   static CYTHON_INLINE void __Pyx_RaiseNeedMoreValuesError(Py_ssize_t index) {
28067     PyErr_Format(PyExc_ValueError,
28068                  "need more than %" CYTHON_FORMAT_SSIZE_T "d value%.1s to unpack",
28069                  index, (index == 1) ? "" : "s");
28070 }
28071 
28072 /* RaiseNoneIterError */
__Pyx_RaiseNoneNotIterableError(void)28073   static CYTHON_INLINE void __Pyx_RaiseNoneNotIterableError(void) {
28074     PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable");
28075 }
28076 
28077 /* SwapException */
28078   #if CYTHON_FAST_THREAD_STATE
__Pyx__ExceptionSwap(PyThreadState * tstate,PyObject ** type,PyObject ** value,PyObject ** tb)28079 static CYTHON_INLINE void __Pyx__ExceptionSwap(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) {
28080     PyObject *tmp_type, *tmp_value, *tmp_tb;
28081     #if CYTHON_USE_EXC_INFO_STACK
28082     _PyErr_StackItem *exc_info = tstate->exc_info;
28083     tmp_type = exc_info->exc_type;
28084     tmp_value = exc_info->exc_value;
28085     tmp_tb = exc_info->exc_traceback;
28086     exc_info->exc_type = *type;
28087     exc_info->exc_value = *value;
28088     exc_info->exc_traceback = *tb;
28089     #else
28090     tmp_type = tstate->exc_type;
28091     tmp_value = tstate->exc_value;
28092     tmp_tb = tstate->exc_traceback;
28093     tstate->exc_type = *type;
28094     tstate->exc_value = *value;
28095     tstate->exc_traceback = *tb;
28096     #endif
28097     *type = tmp_type;
28098     *value = tmp_value;
28099     *tb = tmp_tb;
28100 }
28101 #else
__Pyx_ExceptionSwap(PyObject ** type,PyObject ** value,PyObject ** tb)28102 static CYTHON_INLINE void __Pyx_ExceptionSwap(PyObject **type, PyObject **value, PyObject **tb) {
28103     PyObject *tmp_type, *tmp_value, *tmp_tb;
28104     PyErr_GetExcInfo(&tmp_type, &tmp_value, &tmp_tb);
28105     PyErr_SetExcInfo(*type, *value, *tb);
28106     *type = tmp_type;
28107     *value = tmp_value;
28108     *tb = tmp_tb;
28109 }
28110 #endif
28111 
28112 /* Import */
__Pyx_Import(PyObject * name,PyObject * from_list,int level)28113   static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, int level) {
28114     PyObject *empty_list = 0;
28115     PyObject *module = 0;
28116     PyObject *global_dict = 0;
28117     PyObject *empty_dict = 0;
28118     PyObject *list;
28119     #if PY_MAJOR_VERSION < 3
28120     PyObject *py_import;
28121     py_import = __Pyx_PyObject_GetAttrStr(__pyx_b, __pyx_n_s_import);
28122     if (!py_import)
28123         goto bad;
28124     #endif
28125     if (from_list)
28126         list = from_list;
28127     else {
28128         empty_list = PyList_New(0);
28129         if (!empty_list)
28130             goto bad;
28131         list = empty_list;
28132     }
28133     global_dict = PyModule_GetDict(__pyx_m);
28134     if (!global_dict)
28135         goto bad;
28136     empty_dict = PyDict_New();
28137     if (!empty_dict)
28138         goto bad;
28139     {
28140         #if PY_MAJOR_VERSION >= 3
28141         if (level == -1) {
28142             if ((1) && (strchr(__Pyx_MODULE_NAME, '.'))) {
28143                 module = PyImport_ImportModuleLevelObject(
28144                     name, global_dict, empty_dict, list, 1);
28145                 if (!module) {
28146                     if (!PyErr_ExceptionMatches(PyExc_ImportError))
28147                         goto bad;
28148                     PyErr_Clear();
28149                 }
28150             }
28151             level = 0;
28152         }
28153         #endif
28154         if (!module) {
28155             #if PY_MAJOR_VERSION < 3
28156             PyObject *py_level = PyInt_FromLong(level);
28157             if (!py_level)
28158                 goto bad;
28159             module = PyObject_CallFunctionObjArgs(py_import,
28160                 name, global_dict, empty_dict, list, py_level, (PyObject *)NULL);
28161             Py_DECREF(py_level);
28162             #else
28163             module = PyImport_ImportModuleLevelObject(
28164                 name, global_dict, empty_dict, list, level);
28165             #endif
28166         }
28167     }
28168 bad:
28169     #if PY_MAJOR_VERSION < 3
28170     Py_XDECREF(py_import);
28171     #endif
28172     Py_XDECREF(empty_list);
28173     Py_XDECREF(empty_dict);
28174     return module;
28175 }
28176 
28177 /* FastTypeChecks */
28178   #if CYTHON_COMPILING_IN_CPYTHON
__Pyx_InBases(PyTypeObject * a,PyTypeObject * b)28179 static int __Pyx_InBases(PyTypeObject *a, PyTypeObject *b) {
28180     while (a) {
28181         a = a->tp_base;
28182         if (a == b)
28183             return 1;
28184     }
28185     return b == &PyBaseObject_Type;
28186 }
__Pyx_IsSubtype(PyTypeObject * a,PyTypeObject * b)28187 static CYTHON_INLINE int __Pyx_IsSubtype(PyTypeObject *a, PyTypeObject *b) {
28188     PyObject *mro;
28189     if (a == b) return 1;
28190     mro = a->tp_mro;
28191     if (likely(mro)) {
28192         Py_ssize_t i, n;
28193         n = PyTuple_GET_SIZE(mro);
28194         for (i = 0; i < n; i++) {
28195             if (PyTuple_GET_ITEM(mro, i) == (PyObject *)b)
28196                 return 1;
28197         }
28198         return 0;
28199     }
28200     return __Pyx_InBases(a, b);
28201 }
28202 #if PY_MAJOR_VERSION == 2
__Pyx_inner_PyErr_GivenExceptionMatches2(PyObject * err,PyObject * exc_type1,PyObject * exc_type2)28203 static int __Pyx_inner_PyErr_GivenExceptionMatches2(PyObject *err, PyObject* exc_type1, PyObject* exc_type2) {
28204     PyObject *exception, *value, *tb;
28205     int res;
28206     __Pyx_PyThreadState_declare
28207     __Pyx_PyThreadState_assign
28208     __Pyx_ErrFetch(&exception, &value, &tb);
28209     res = exc_type1 ? PyObject_IsSubclass(err, exc_type1) : 0;
28210     if (unlikely(res == -1)) {
28211         PyErr_WriteUnraisable(err);
28212         res = 0;
28213     }
28214     if (!res) {
28215         res = PyObject_IsSubclass(err, exc_type2);
28216         if (unlikely(res == -1)) {
28217             PyErr_WriteUnraisable(err);
28218             res = 0;
28219         }
28220     }
28221     __Pyx_ErrRestore(exception, value, tb);
28222     return res;
28223 }
28224 #else
__Pyx_inner_PyErr_GivenExceptionMatches2(PyObject * err,PyObject * exc_type1,PyObject * exc_type2)28225 static CYTHON_INLINE int __Pyx_inner_PyErr_GivenExceptionMatches2(PyObject *err, PyObject* exc_type1, PyObject *exc_type2) {
28226     int res = exc_type1 ? __Pyx_IsSubtype((PyTypeObject*)err, (PyTypeObject*)exc_type1) : 0;
28227     if (!res) {
28228         res = __Pyx_IsSubtype((PyTypeObject*)err, (PyTypeObject*)exc_type2);
28229     }
28230     return res;
28231 }
28232 #endif
__Pyx_PyErr_GivenExceptionMatchesTuple(PyObject * exc_type,PyObject * tuple)28233 static int __Pyx_PyErr_GivenExceptionMatchesTuple(PyObject *exc_type, PyObject *tuple) {
28234     Py_ssize_t i, n;
28235     assert(PyExceptionClass_Check(exc_type));
28236     n = PyTuple_GET_SIZE(tuple);
28237 #if PY_MAJOR_VERSION >= 3
28238     for (i=0; i<n; i++) {
28239         if (exc_type == PyTuple_GET_ITEM(tuple, i)) return 1;
28240     }
28241 #endif
28242     for (i=0; i<n; i++) {
28243         PyObject *t = PyTuple_GET_ITEM(tuple, i);
28244         #if PY_MAJOR_VERSION < 3
28245         if (likely(exc_type == t)) return 1;
28246         #endif
28247         if (likely(PyExceptionClass_Check(t))) {
28248             if (__Pyx_inner_PyErr_GivenExceptionMatches2(exc_type, NULL, t)) return 1;
28249         } else {
28250         }
28251     }
28252     return 0;
28253 }
__Pyx_PyErr_GivenExceptionMatches(PyObject * err,PyObject * exc_type)28254 static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches(PyObject *err, PyObject* exc_type) {
28255     if (likely(err == exc_type)) return 1;
28256     if (likely(PyExceptionClass_Check(err))) {
28257         if (likely(PyExceptionClass_Check(exc_type))) {
28258             return __Pyx_inner_PyErr_GivenExceptionMatches2(err, NULL, exc_type);
28259         } else if (likely(PyTuple_Check(exc_type))) {
28260             return __Pyx_PyErr_GivenExceptionMatchesTuple(err, exc_type);
28261         } else {
28262         }
28263     }
28264     return PyErr_GivenExceptionMatches(err, exc_type);
28265 }
__Pyx_PyErr_GivenExceptionMatches2(PyObject * err,PyObject * exc_type1,PyObject * exc_type2)28266 static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches2(PyObject *err, PyObject *exc_type1, PyObject *exc_type2) {
28267     assert(PyExceptionClass_Check(exc_type1));
28268     assert(PyExceptionClass_Check(exc_type2));
28269     if (likely(err == exc_type1 || err == exc_type2)) return 1;
28270     if (likely(PyExceptionClass_Check(err))) {
28271         return __Pyx_inner_PyErr_GivenExceptionMatches2(err, exc_type1, exc_type2);
28272     }
28273     return (PyErr_GivenExceptionMatches(err, exc_type1) || PyErr_GivenExceptionMatches(err, exc_type2));
28274 }
28275 #endif
28276 
28277 /* PyIntBinop */
28278   #if !CYTHON_COMPILING_IN_PYPY
__Pyx_PyInt_AddObjC(PyObject * op1,PyObject * op2,CYTHON_UNUSED long intval,int inplace,int zerodivision_check)28279 static PyObject* __Pyx_PyInt_AddObjC(PyObject *op1, PyObject *op2, CYTHON_UNUSED long intval, int inplace, int zerodivision_check) {
28280     (void)inplace;
28281     (void)zerodivision_check;
28282     #if PY_MAJOR_VERSION < 3
28283     if (likely(PyInt_CheckExact(op1))) {
28284         const long b = intval;
28285         long x;
28286         long a = PyInt_AS_LONG(op1);
28287             x = (long)((unsigned long)a + b);
28288             if (likely((x^a) >= 0 || (x^b) >= 0))
28289                 return PyInt_FromLong(x);
28290             return PyLong_Type.tp_as_number->nb_add(op1, op2);
28291     }
28292     #endif
28293     #if CYTHON_USE_PYLONG_INTERNALS
28294     if (likely(PyLong_CheckExact(op1))) {
28295         const long b = intval;
28296         long a, x;
28297 #ifdef HAVE_LONG_LONG
28298         const PY_LONG_LONG llb = intval;
28299         PY_LONG_LONG lla, llx;
28300 #endif
28301         const digit* digits = ((PyLongObject*)op1)->ob_digit;
28302         const Py_ssize_t size = Py_SIZE(op1);
28303         if (likely(__Pyx_sst_abs(size) <= 1)) {
28304             a = likely(size) ? digits[0] : 0;
28305             if (size == -1) a = -a;
28306         } else {
28307             switch (size) {
28308                 case -2:
28309                     if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
28310                         a = -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
28311                         break;
28312 #ifdef HAVE_LONG_LONG
28313                     } else if (8 * sizeof(PY_LONG_LONG) - 1 > 2 * PyLong_SHIFT) {
28314                         lla = -(PY_LONG_LONG) (((((unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
28315                         goto long_long;
28316 #endif
28317                     }
28318                     CYTHON_FALLTHROUGH;
28319                 case 2:
28320                     if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
28321                         a = (long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
28322                         break;
28323 #ifdef HAVE_LONG_LONG
28324                     } else if (8 * sizeof(PY_LONG_LONG) - 1 > 2 * PyLong_SHIFT) {
28325                         lla = (PY_LONG_LONG) (((((unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
28326                         goto long_long;
28327 #endif
28328                     }
28329                     CYTHON_FALLTHROUGH;
28330                 case -3:
28331                     if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
28332                         a = -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
28333                         break;
28334 #ifdef HAVE_LONG_LONG
28335                     } else if (8 * sizeof(PY_LONG_LONG) - 1 > 3 * PyLong_SHIFT) {
28336                         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]));
28337                         goto long_long;
28338 #endif
28339                     }
28340                     CYTHON_FALLTHROUGH;
28341                 case 3:
28342                     if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
28343                         a = (long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
28344                         break;
28345 #ifdef HAVE_LONG_LONG
28346                     } else if (8 * sizeof(PY_LONG_LONG) - 1 > 3 * PyLong_SHIFT) {
28347                         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]));
28348                         goto long_long;
28349 #endif
28350                     }
28351                     CYTHON_FALLTHROUGH;
28352                 case -4:
28353                     if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) {
28354                         a = -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
28355                         break;
28356 #ifdef HAVE_LONG_LONG
28357                     } else if (8 * sizeof(PY_LONG_LONG) - 1 > 4 * PyLong_SHIFT) {
28358                         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]));
28359                         goto long_long;
28360 #endif
28361                     }
28362                     CYTHON_FALLTHROUGH;
28363                 case 4:
28364                     if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) {
28365                         a = (long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
28366                         break;
28367 #ifdef HAVE_LONG_LONG
28368                     } else if (8 * sizeof(PY_LONG_LONG) - 1 > 4 * PyLong_SHIFT) {
28369                         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]));
28370                         goto long_long;
28371 #endif
28372                     }
28373                     CYTHON_FALLTHROUGH;
28374                 default: return PyLong_Type.tp_as_number->nb_add(op1, op2);
28375             }
28376         }
28377                 x = a + b;
28378             return PyLong_FromLong(x);
28379 #ifdef HAVE_LONG_LONG
28380         long_long:
28381                 llx = lla + llb;
28382             return PyLong_FromLongLong(llx);
28383 #endif
28384 
28385 
28386     }
28387     #endif
28388     if (PyFloat_CheckExact(op1)) {
28389         const long b = intval;
28390         double a = PyFloat_AS_DOUBLE(op1);
28391             double result;
28392             PyFPE_START_PROTECT("add", return NULL)
28393             result = ((double)a) + (double)b;
28394             PyFPE_END_PROTECT(result)
28395             return PyFloat_FromDouble(result);
28396     }
28397     return (inplace ? PyNumber_InPlaceAdd : PyNumber_Add)(op1, op2);
28398 }
28399 #endif
28400 
28401 /* None */
__Pyx_RaiseUnboundLocalError(const char * varname)28402   static CYTHON_INLINE void __Pyx_RaiseUnboundLocalError(const char *varname) {
28403     PyErr_Format(PyExc_UnboundLocalError, "local variable '%s' referenced before assignment", varname);
28404 }
28405 
28406 /* None */
__Pyx_div_long(long a,long b)28407   static CYTHON_INLINE long __Pyx_div_long(long a, long b) {
28408     long q = a / b;
28409     long r = a - q*b;
28410     q -= ((r != 0) & ((r ^ b) < 0));
28411     return q;
28412 }
28413 
28414 /* ImportFrom */
__Pyx_ImportFrom(PyObject * module,PyObject * name)28415   static PyObject* __Pyx_ImportFrom(PyObject* module, PyObject* name) {
28416     PyObject* value = __Pyx_PyObject_GetAttrStr(module, name);
28417     if (unlikely(!value) && PyErr_ExceptionMatches(PyExc_AttributeError)) {
28418         PyErr_Format(PyExc_ImportError,
28419         #if PY_MAJOR_VERSION < 3
28420             "cannot import name %.230s", PyString_AS_STRING(name));
28421         #else
28422             "cannot import name %S", name);
28423         #endif
28424     }
28425     return value;
28426 }
28427 
28428 /* HasAttr */
__Pyx_HasAttr(PyObject * o,PyObject * n)28429   static CYTHON_INLINE int __Pyx_HasAttr(PyObject *o, PyObject *n) {
28430     PyObject *r;
28431     if (unlikely(!__Pyx_PyBaseString_Check(n))) {
28432         PyErr_SetString(PyExc_TypeError,
28433                         "hasattr(): attribute name must be string");
28434         return -1;
28435     }
28436     r = __Pyx_GetAttr(o, n);
28437     if (unlikely(!r)) {
28438         PyErr_Clear();
28439         return 0;
28440     } else {
28441         Py_DECREF(r);
28442         return 1;
28443     }
28444 }
28445 
28446 /* PyObject_GenericGetAttrNoDict */
28447   #if CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP && PY_VERSION_HEX < 0x03070000
__Pyx_RaiseGenericGetAttributeError(PyTypeObject * tp,PyObject * attr_name)28448 static PyObject *__Pyx_RaiseGenericGetAttributeError(PyTypeObject *tp, PyObject *attr_name) {
28449     PyErr_Format(PyExc_AttributeError,
28450 #if PY_MAJOR_VERSION >= 3
28451                  "'%.50s' object has no attribute '%U'",
28452                  tp->tp_name, attr_name);
28453 #else
28454                  "'%.50s' object has no attribute '%.400s'",
28455                  tp->tp_name, PyString_AS_STRING(attr_name));
28456 #endif
28457     return NULL;
28458 }
__Pyx_PyObject_GenericGetAttrNoDict(PyObject * obj,PyObject * attr_name)28459 static CYTHON_INLINE PyObject* __Pyx_PyObject_GenericGetAttrNoDict(PyObject* obj, PyObject* attr_name) {
28460     PyObject *descr;
28461     PyTypeObject *tp = Py_TYPE(obj);
28462     if (unlikely(!PyString_Check(attr_name))) {
28463         return PyObject_GenericGetAttr(obj, attr_name);
28464     }
28465     assert(!tp->tp_dictoffset);
28466     descr = _PyType_Lookup(tp, attr_name);
28467     if (unlikely(!descr)) {
28468         return __Pyx_RaiseGenericGetAttributeError(tp, attr_name);
28469     }
28470     Py_INCREF(descr);
28471     #if PY_MAJOR_VERSION < 3
28472     if (likely(PyType_HasFeature(Py_TYPE(descr), Py_TPFLAGS_HAVE_CLASS)))
28473     #endif
28474     {
28475         descrgetfunc f = Py_TYPE(descr)->tp_descr_get;
28476         if (unlikely(f)) {
28477             PyObject *res = f(descr, obj, (PyObject *)tp);
28478             Py_DECREF(descr);
28479             return res;
28480         }
28481     }
28482     return descr;
28483 }
28484 #endif
28485 
28486 /* PyObject_GenericGetAttr */
28487   #if CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP && PY_VERSION_HEX < 0x03070000
__Pyx_PyObject_GenericGetAttr(PyObject * obj,PyObject * attr_name)28488 static PyObject* __Pyx_PyObject_GenericGetAttr(PyObject* obj, PyObject* attr_name) {
28489     if (unlikely(Py_TYPE(obj)->tp_dictoffset)) {
28490         return PyObject_GenericGetAttr(obj, attr_name);
28491     }
28492     return __Pyx_PyObject_GenericGetAttrNoDict(obj, attr_name);
28493 }
28494 #endif
28495 
28496 /* SetVTable */
__Pyx_SetVtable(PyObject * dict,void * vtable)28497   static int __Pyx_SetVtable(PyObject *dict, void *vtable) {
28498 #if PY_VERSION_HEX >= 0x02070000
28499     PyObject *ob = PyCapsule_New(vtable, 0, 0);
28500 #else
28501     PyObject *ob = PyCObject_FromVoidPtr(vtable, 0);
28502 #endif
28503     if (!ob)
28504         goto bad;
28505     if (PyDict_SetItem(dict, __pyx_n_s_pyx_vtable, ob) < 0)
28506         goto bad;
28507     Py_DECREF(ob);
28508     return 0;
28509 bad:
28510     Py_XDECREF(ob);
28511     return -1;
28512 }
28513 
28514 /* PyObjectGetAttrStrNoError */
__Pyx_PyObject_GetAttrStr_ClearAttributeError(void)28515   static void __Pyx_PyObject_GetAttrStr_ClearAttributeError(void) {
28516     __Pyx_PyThreadState_declare
28517     __Pyx_PyThreadState_assign
28518     if (likely(__Pyx_PyErr_ExceptionMatches(PyExc_AttributeError)))
28519         __Pyx_PyErr_Clear();
28520 }
__Pyx_PyObject_GetAttrStrNoError(PyObject * obj,PyObject * attr_name)28521 static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStrNoError(PyObject* obj, PyObject* attr_name) {
28522     PyObject *result;
28523 #if CYTHON_COMPILING_IN_CPYTHON && CYTHON_USE_TYPE_SLOTS && PY_VERSION_HEX >= 0x030700B1
28524     PyTypeObject* tp = Py_TYPE(obj);
28525     if (likely(tp->tp_getattro == PyObject_GenericGetAttr)) {
28526         return _PyObject_GenericGetAttrWithDict(obj, attr_name, NULL, 1);
28527     }
28528 #endif
28529     result = __Pyx_PyObject_GetAttrStr(obj, attr_name);
28530     if (unlikely(!result)) {
28531         __Pyx_PyObject_GetAttrStr_ClearAttributeError();
28532     }
28533     return result;
28534 }
28535 
28536 /* SetupReduce */
__Pyx_setup_reduce_is_named(PyObject * meth,PyObject * name)28537   static int __Pyx_setup_reduce_is_named(PyObject* meth, PyObject* name) {
28538   int ret;
28539   PyObject *name_attr;
28540   name_attr = __Pyx_PyObject_GetAttrStr(meth, __pyx_n_s_name_2);
28541   if (likely(name_attr)) {
28542       ret = PyObject_RichCompareBool(name_attr, name, Py_EQ);
28543   } else {
28544       ret = -1;
28545   }
28546   if (unlikely(ret < 0)) {
28547       PyErr_Clear();
28548       ret = 0;
28549   }
28550   Py_XDECREF(name_attr);
28551   return ret;
28552 }
__Pyx_setup_reduce(PyObject * type_obj)28553 static int __Pyx_setup_reduce(PyObject* type_obj) {
28554     int ret = 0;
28555     PyObject *object_reduce = NULL;
28556     PyObject *object_reduce_ex = NULL;
28557     PyObject *reduce = NULL;
28558     PyObject *reduce_ex = NULL;
28559     PyObject *reduce_cython = NULL;
28560     PyObject *setstate = NULL;
28561     PyObject *setstate_cython = NULL;
28562 #if CYTHON_USE_PYTYPE_LOOKUP
28563     if (_PyType_Lookup((PyTypeObject*)type_obj, __pyx_n_s_getstate)) goto __PYX_GOOD;
28564 #else
28565     if (PyObject_HasAttr(type_obj, __pyx_n_s_getstate)) goto __PYX_GOOD;
28566 #endif
28567 #if CYTHON_USE_PYTYPE_LOOKUP
28568     object_reduce_ex = _PyType_Lookup(&PyBaseObject_Type, __pyx_n_s_reduce_ex); if (!object_reduce_ex) goto __PYX_BAD;
28569 #else
28570     object_reduce_ex = __Pyx_PyObject_GetAttrStr((PyObject*)&PyBaseObject_Type, __pyx_n_s_reduce_ex); if (!object_reduce_ex) goto __PYX_BAD;
28571 #endif
28572     reduce_ex = __Pyx_PyObject_GetAttrStr(type_obj, __pyx_n_s_reduce_ex); if (unlikely(!reduce_ex)) goto __PYX_BAD;
28573     if (reduce_ex == object_reduce_ex) {
28574 #if CYTHON_USE_PYTYPE_LOOKUP
28575         object_reduce = _PyType_Lookup(&PyBaseObject_Type, __pyx_n_s_reduce); if (!object_reduce) goto __PYX_BAD;
28576 #else
28577         object_reduce = __Pyx_PyObject_GetAttrStr((PyObject*)&PyBaseObject_Type, __pyx_n_s_reduce); if (!object_reduce) goto __PYX_BAD;
28578 #endif
28579         reduce = __Pyx_PyObject_GetAttrStr(type_obj, __pyx_n_s_reduce); if (unlikely(!reduce)) goto __PYX_BAD;
28580         if (reduce == object_reduce || __Pyx_setup_reduce_is_named(reduce, __pyx_n_s_reduce_cython)) {
28581             reduce_cython = __Pyx_PyObject_GetAttrStrNoError(type_obj, __pyx_n_s_reduce_cython);
28582             if (likely(reduce_cython)) {
28583                 ret = PyDict_SetItem(((PyTypeObject*)type_obj)->tp_dict, __pyx_n_s_reduce, reduce_cython); if (unlikely(ret < 0)) goto __PYX_BAD;
28584                 ret = PyDict_DelItem(((PyTypeObject*)type_obj)->tp_dict, __pyx_n_s_reduce_cython); if (unlikely(ret < 0)) goto __PYX_BAD;
28585             } else if (reduce == object_reduce || PyErr_Occurred()) {
28586                 goto __PYX_BAD;
28587             }
28588             setstate = __Pyx_PyObject_GetAttrStr(type_obj, __pyx_n_s_setstate);
28589             if (!setstate) PyErr_Clear();
28590             if (!setstate || __Pyx_setup_reduce_is_named(setstate, __pyx_n_s_setstate_cython)) {
28591                 setstate_cython = __Pyx_PyObject_GetAttrStrNoError(type_obj, __pyx_n_s_setstate_cython);
28592                 if (likely(setstate_cython)) {
28593                     ret = PyDict_SetItem(((PyTypeObject*)type_obj)->tp_dict, __pyx_n_s_setstate, setstate_cython); if (unlikely(ret < 0)) goto __PYX_BAD;
28594                     ret = PyDict_DelItem(((PyTypeObject*)type_obj)->tp_dict, __pyx_n_s_setstate_cython); if (unlikely(ret < 0)) goto __PYX_BAD;
28595                 } else if (!setstate || PyErr_Occurred()) {
28596                     goto __PYX_BAD;
28597                 }
28598             }
28599             PyType_Modified((PyTypeObject*)type_obj);
28600         }
28601     }
28602     goto __PYX_GOOD;
28603 __PYX_BAD:
28604     if (!PyErr_Occurred())
28605         PyErr_Format(PyExc_RuntimeError, "Unable to initialize pickling for %s", ((PyTypeObject*)type_obj)->tp_name);
28606     ret = -1;
28607 __PYX_GOOD:
28608 #if !CYTHON_USE_PYTYPE_LOOKUP
28609     Py_XDECREF(object_reduce);
28610     Py_XDECREF(object_reduce_ex);
28611 #endif
28612     Py_XDECREF(reduce);
28613     Py_XDECREF(reduce_ex);
28614     Py_XDECREF(reduce_cython);
28615     Py_XDECREF(setstate);
28616     Py_XDECREF(setstate_cython);
28617     return ret;
28618 }
28619 
28620 /* TypeImport */
28621   #ifndef __PYX_HAVE_RT_ImportType
28622 #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)28623 static PyTypeObject *__Pyx_ImportType(PyObject *module, const char *module_name, const char *class_name,
28624     size_t size, enum __Pyx_ImportType_CheckSize check_size)
28625 {
28626     PyObject *result = 0;
28627     char warning[200];
28628     Py_ssize_t basicsize;
28629 #ifdef Py_LIMITED_API
28630     PyObject *py_basicsize;
28631 #endif
28632     result = PyObject_GetAttrString(module, class_name);
28633     if (!result)
28634         goto bad;
28635     if (!PyType_Check(result)) {
28636         PyErr_Format(PyExc_TypeError,
28637             "%.200s.%.200s is not a type object",
28638             module_name, class_name);
28639         goto bad;
28640     }
28641 #ifndef Py_LIMITED_API
28642     basicsize = ((PyTypeObject *)result)->tp_basicsize;
28643 #else
28644     py_basicsize = PyObject_GetAttrString(result, "__basicsize__");
28645     if (!py_basicsize)
28646         goto bad;
28647     basicsize = PyLong_AsSsize_t(py_basicsize);
28648     Py_DECREF(py_basicsize);
28649     py_basicsize = 0;
28650     if (basicsize == (Py_ssize_t)-1 && PyErr_Occurred())
28651         goto bad;
28652 #endif
28653     if ((size_t)basicsize < size) {
28654         PyErr_Format(PyExc_ValueError,
28655             "%.200s.%.200s size changed, may indicate binary incompatibility. "
28656             "Expected %zd from C header, got %zd from PyObject",
28657             module_name, class_name, size, basicsize);
28658         goto bad;
28659     }
28660     if (check_size == __Pyx_ImportType_CheckSize_Error && (size_t)basicsize != size) {
28661         PyErr_Format(PyExc_ValueError,
28662             "%.200s.%.200s size changed, may indicate binary incompatibility. "
28663             "Expected %zd from C header, got %zd from PyObject",
28664             module_name, class_name, size, basicsize);
28665         goto bad;
28666     }
28667     else if (check_size == __Pyx_ImportType_CheckSize_Warn && (size_t)basicsize > size) {
28668         PyOS_snprintf(warning, sizeof(warning),
28669             "%s.%s size changed, may indicate binary incompatibility. "
28670             "Expected %zd from C header, got %zd from PyObject",
28671             module_name, class_name, size, basicsize);
28672         if (PyErr_WarnEx(NULL, warning, 0) < 0) goto bad;
28673     }
28674     return (PyTypeObject *)result;
28675 bad:
28676     Py_XDECREF(result);
28677     return NULL;
28678 }
28679 #endif
28680 
28681 /* CLineInTraceback */
28682   #ifndef CYTHON_CLINE_IN_TRACEBACK
__Pyx_CLineForTraceback(CYTHON_NCP_UNUSED PyThreadState * tstate,int c_line)28683 static int __Pyx_CLineForTraceback(CYTHON_NCP_UNUSED PyThreadState *tstate, int c_line) {
28684     PyObject *use_cline;
28685     PyObject *ptype, *pvalue, *ptraceback;
28686 #if CYTHON_COMPILING_IN_CPYTHON
28687     PyObject **cython_runtime_dict;
28688 #endif
28689     if (unlikely(!__pyx_cython_runtime)) {
28690         return c_line;
28691     }
28692     __Pyx_ErrFetchInState(tstate, &ptype, &pvalue, &ptraceback);
28693 #if CYTHON_COMPILING_IN_CPYTHON
28694     cython_runtime_dict = _PyObject_GetDictPtr(__pyx_cython_runtime);
28695     if (likely(cython_runtime_dict)) {
28696         __PYX_PY_DICT_LOOKUP_IF_MODIFIED(
28697             use_cline, *cython_runtime_dict,
28698             __Pyx_PyDict_GetItemStr(*cython_runtime_dict, __pyx_n_s_cline_in_traceback))
28699     } else
28700 #endif
28701     {
28702       PyObject *use_cline_obj = __Pyx_PyObject_GetAttrStr(__pyx_cython_runtime, __pyx_n_s_cline_in_traceback);
28703       if (use_cline_obj) {
28704         use_cline = PyObject_Not(use_cline_obj) ? Py_False : Py_True;
28705         Py_DECREF(use_cline_obj);
28706       } else {
28707         PyErr_Clear();
28708         use_cline = NULL;
28709       }
28710     }
28711     if (!use_cline) {
28712         c_line = 0;
28713         PyObject_SetAttr(__pyx_cython_runtime, __pyx_n_s_cline_in_traceback, Py_False);
28714     }
28715     else if (use_cline == Py_False || (use_cline != Py_True && PyObject_Not(use_cline) != 0)) {
28716         c_line = 0;
28717     }
28718     __Pyx_ErrRestoreInState(tstate, ptype, pvalue, ptraceback);
28719     return c_line;
28720 }
28721 #endif
28722 
28723 /* CodeObjectCache */
__pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry * entries,int count,int code_line)28724   static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line) {
28725     int start = 0, mid = 0, end = count - 1;
28726     if (end >= 0 && code_line > entries[end].code_line) {
28727         return count;
28728     }
28729     while (start < end) {
28730         mid = start + (end - start) / 2;
28731         if (code_line < entries[mid].code_line) {
28732             end = mid;
28733         } else if (code_line > entries[mid].code_line) {
28734              start = mid + 1;
28735         } else {
28736             return mid;
28737         }
28738     }
28739     if (code_line <= entries[mid].code_line) {
28740         return mid;
28741     } else {
28742         return mid + 1;
28743     }
28744 }
__pyx_find_code_object(int code_line)28745 static PyCodeObject *__pyx_find_code_object(int code_line) {
28746     PyCodeObject* code_object;
28747     int pos;
28748     if (unlikely(!code_line) || unlikely(!__pyx_code_cache.entries)) {
28749         return NULL;
28750     }
28751     pos = __pyx_bisect_code_objects(__pyx_code_cache.entries, __pyx_code_cache.count, code_line);
28752     if (unlikely(pos >= __pyx_code_cache.count) || unlikely(__pyx_code_cache.entries[pos].code_line != code_line)) {
28753         return NULL;
28754     }
28755     code_object = __pyx_code_cache.entries[pos].code_object;
28756     Py_INCREF(code_object);
28757     return code_object;
28758 }
__pyx_insert_code_object(int code_line,PyCodeObject * code_object)28759 static void __pyx_insert_code_object(int code_line, PyCodeObject* code_object) {
28760     int pos, i;
28761     __Pyx_CodeObjectCacheEntry* entries = __pyx_code_cache.entries;
28762     if (unlikely(!code_line)) {
28763         return;
28764     }
28765     if (unlikely(!entries)) {
28766         entries = (__Pyx_CodeObjectCacheEntry*)PyMem_Malloc(64*sizeof(__Pyx_CodeObjectCacheEntry));
28767         if (likely(entries)) {
28768             __pyx_code_cache.entries = entries;
28769             __pyx_code_cache.max_count = 64;
28770             __pyx_code_cache.count = 1;
28771             entries[0].code_line = code_line;
28772             entries[0].code_object = code_object;
28773             Py_INCREF(code_object);
28774         }
28775         return;
28776     }
28777     pos = __pyx_bisect_code_objects(__pyx_code_cache.entries, __pyx_code_cache.count, code_line);
28778     if ((pos < __pyx_code_cache.count) && unlikely(__pyx_code_cache.entries[pos].code_line == code_line)) {
28779         PyCodeObject* tmp = entries[pos].code_object;
28780         entries[pos].code_object = code_object;
28781         Py_DECREF(tmp);
28782         return;
28783     }
28784     if (__pyx_code_cache.count == __pyx_code_cache.max_count) {
28785         int new_max = __pyx_code_cache.max_count + 64;
28786         entries = (__Pyx_CodeObjectCacheEntry*)PyMem_Realloc(
28787             __pyx_code_cache.entries, ((size_t)new_max) * sizeof(__Pyx_CodeObjectCacheEntry));
28788         if (unlikely(!entries)) {
28789             return;
28790         }
28791         __pyx_code_cache.entries = entries;
28792         __pyx_code_cache.max_count = new_max;
28793     }
28794     for (i=__pyx_code_cache.count; i>pos; i--) {
28795         entries[i] = entries[i-1];
28796     }
28797     entries[pos].code_line = code_line;
28798     entries[pos].code_object = code_object;
28799     __pyx_code_cache.count++;
28800     Py_INCREF(code_object);
28801 }
28802 
28803 /* AddTraceback */
28804   #include "compile.h"
28805 #include "frameobject.h"
28806 #include "traceback.h"
__Pyx_CreateCodeObjectForTraceback(const char * funcname,int c_line,int py_line,const char * filename)28807 static PyCodeObject* __Pyx_CreateCodeObjectForTraceback(
28808             const char *funcname, int c_line,
28809             int py_line, const char *filename) {
28810     PyCodeObject *py_code = 0;
28811     PyObject *py_srcfile = 0;
28812     PyObject *py_funcname = 0;
28813     #if PY_MAJOR_VERSION < 3
28814     py_srcfile = PyString_FromString(filename);
28815     #else
28816     py_srcfile = PyUnicode_FromString(filename);
28817     #endif
28818     if (!py_srcfile) goto bad;
28819     if (c_line) {
28820         #if PY_MAJOR_VERSION < 3
28821         py_funcname = PyString_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, c_line);
28822         #else
28823         py_funcname = PyUnicode_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, c_line);
28824         #endif
28825     }
28826     else {
28827         #if PY_MAJOR_VERSION < 3
28828         py_funcname = PyString_FromString(funcname);
28829         #else
28830         py_funcname = PyUnicode_FromString(funcname);
28831         #endif
28832     }
28833     if (!py_funcname) goto bad;
28834     py_code = __Pyx_PyCode_New(
28835         0,
28836         0,
28837         0,
28838         0,
28839         0,
28840         __pyx_empty_bytes, /*PyObject *code,*/
28841         __pyx_empty_tuple, /*PyObject *consts,*/
28842         __pyx_empty_tuple, /*PyObject *names,*/
28843         __pyx_empty_tuple, /*PyObject *varnames,*/
28844         __pyx_empty_tuple, /*PyObject *freevars,*/
28845         __pyx_empty_tuple, /*PyObject *cellvars,*/
28846         py_srcfile,   /*PyObject *filename,*/
28847         py_funcname,  /*PyObject *name,*/
28848         py_line,
28849         __pyx_empty_bytes  /*PyObject *lnotab*/
28850     );
28851     Py_DECREF(py_srcfile);
28852     Py_DECREF(py_funcname);
28853     return py_code;
28854 bad:
28855     Py_XDECREF(py_srcfile);
28856     Py_XDECREF(py_funcname);
28857     return NULL;
28858 }
__Pyx_AddTraceback(const char * funcname,int c_line,int py_line,const char * filename)28859 static void __Pyx_AddTraceback(const char *funcname, int c_line,
28860                                int py_line, const char *filename) {
28861     PyCodeObject *py_code = 0;
28862     PyFrameObject *py_frame = 0;
28863     PyThreadState *tstate = __Pyx_PyThreadState_Current;
28864     if (c_line) {
28865         c_line = __Pyx_CLineForTraceback(tstate, c_line);
28866     }
28867     py_code = __pyx_find_code_object(c_line ? -c_line : py_line);
28868     if (!py_code) {
28869         py_code = __Pyx_CreateCodeObjectForTraceback(
28870             funcname, c_line, py_line, filename);
28871         if (!py_code) goto bad;
28872         __pyx_insert_code_object(c_line ? -c_line : py_line, py_code);
28873     }
28874     py_frame = PyFrame_New(
28875         tstate,            /*PyThreadState *tstate,*/
28876         py_code,           /*PyCodeObject *code,*/
28877         __pyx_d,    /*PyObject *globals,*/
28878         0                  /*PyObject *locals*/
28879     );
28880     if (!py_frame) goto bad;
28881     __Pyx_PyFrame_SetLineNumber(py_frame, py_line);
28882     PyTraceBack_Here(py_frame);
28883 bad:
28884     Py_XDECREF(py_code);
28885     Py_XDECREF(py_frame);
28886 }
28887 
28888 /* Declarations */
28889   #if CYTHON_CCOMPLEX
28890   #ifdef __cplusplus
__pyx_t_double_complex_from_parts(double x,double y)28891     static CYTHON_INLINE __pyx_t_double_complex __pyx_t_double_complex_from_parts(double x, double y) {
28892       return ::std::complex< double >(x, y);
28893     }
28894   #else
__pyx_t_double_complex_from_parts(double x,double y)28895     static CYTHON_INLINE __pyx_t_double_complex __pyx_t_double_complex_from_parts(double x, double y) {
28896       return x + y*(__pyx_t_double_complex)_Complex_I;
28897     }
28898   #endif
28899 #else
__pyx_t_double_complex_from_parts(double x,double y)28900     static CYTHON_INLINE __pyx_t_double_complex __pyx_t_double_complex_from_parts(double x, double y) {
28901       __pyx_t_double_complex z;
28902       z.real = x;
28903       z.imag = y;
28904       return z;
28905     }
28906 #endif
28907 
28908 /* Arithmetic */
28909   #if CYTHON_CCOMPLEX
28910 #else
__Pyx_c_eq_double(__pyx_t_double_complex a,__pyx_t_double_complex b)28911     static CYTHON_INLINE int __Pyx_c_eq_double(__pyx_t_double_complex a, __pyx_t_double_complex b) {
28912        return (a.real == b.real) && (a.imag == b.imag);
28913     }
__Pyx_c_sum_double(__pyx_t_double_complex a,__pyx_t_double_complex b)28914     static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_sum_double(__pyx_t_double_complex a, __pyx_t_double_complex b) {
28915         __pyx_t_double_complex z;
28916         z.real = a.real + b.real;
28917         z.imag = a.imag + b.imag;
28918         return z;
28919     }
__Pyx_c_diff_double(__pyx_t_double_complex a,__pyx_t_double_complex b)28920     static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_diff_double(__pyx_t_double_complex a, __pyx_t_double_complex b) {
28921         __pyx_t_double_complex z;
28922         z.real = a.real - b.real;
28923         z.imag = a.imag - b.imag;
28924         return z;
28925     }
__Pyx_c_prod_double(__pyx_t_double_complex a,__pyx_t_double_complex b)28926     static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_prod_double(__pyx_t_double_complex a, __pyx_t_double_complex b) {
28927         __pyx_t_double_complex z;
28928         z.real = a.real * b.real - a.imag * b.imag;
28929         z.imag = a.real * b.imag + a.imag * b.real;
28930         return z;
28931     }
28932     #if 1
__Pyx_c_quot_double(__pyx_t_double_complex a,__pyx_t_double_complex b)28933     static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_quot_double(__pyx_t_double_complex a, __pyx_t_double_complex b) {
28934         if (b.imag == 0) {
28935             return __pyx_t_double_complex_from_parts(a.real / b.real, a.imag / b.real);
28936         } else if (fabs(b.real) >= fabs(b.imag)) {
28937             if (b.real == 0 && b.imag == 0) {
28938                 return __pyx_t_double_complex_from_parts(a.real / b.real, a.imag / b.imag);
28939             } else {
28940                 double r = b.imag / b.real;
28941                 double s = (double)(1.0) / (b.real + b.imag * r);
28942                 return __pyx_t_double_complex_from_parts(
28943                     (a.real + a.imag * r) * s, (a.imag - a.real * r) * s);
28944             }
28945         } else {
28946             double r = b.real / b.imag;
28947             double s = (double)(1.0) / (b.imag + b.real * r);
28948             return __pyx_t_double_complex_from_parts(
28949                 (a.real * r + a.imag) * s, (a.imag * r - a.real) * s);
28950         }
28951     }
28952     #else
__Pyx_c_quot_double(__pyx_t_double_complex a,__pyx_t_double_complex b)28953     static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_quot_double(__pyx_t_double_complex a, __pyx_t_double_complex b) {
28954         if (b.imag == 0) {
28955             return __pyx_t_double_complex_from_parts(a.real / b.real, a.imag / b.real);
28956         } else {
28957             double denom = b.real * b.real + b.imag * b.imag;
28958             return __pyx_t_double_complex_from_parts(
28959                 (a.real * b.real + a.imag * b.imag) / denom,
28960                 (a.imag * b.real - a.real * b.imag) / denom);
28961         }
28962     }
28963     #endif
__Pyx_c_neg_double(__pyx_t_double_complex a)28964     static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_neg_double(__pyx_t_double_complex a) {
28965         __pyx_t_double_complex z;
28966         z.real = -a.real;
28967         z.imag = -a.imag;
28968         return z;
28969     }
__Pyx_c_is_zero_double(__pyx_t_double_complex a)28970     static CYTHON_INLINE int __Pyx_c_is_zero_double(__pyx_t_double_complex a) {
28971        return (a.real == 0) && (a.imag == 0);
28972     }
__Pyx_c_conj_double(__pyx_t_double_complex a)28973     static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_conj_double(__pyx_t_double_complex a) {
28974         __pyx_t_double_complex z;
28975         z.real =  a.real;
28976         z.imag = -a.imag;
28977         return z;
28978     }
28979     #if 1
__Pyx_c_abs_double(__pyx_t_double_complex z)28980         static CYTHON_INLINE double __Pyx_c_abs_double(__pyx_t_double_complex z) {
28981           #if !defined(HAVE_HYPOT) || defined(_MSC_VER)
28982             return sqrt(z.real*z.real + z.imag*z.imag);
28983           #else
28984             return hypot(z.real, z.imag);
28985           #endif
28986         }
__Pyx_c_pow_double(__pyx_t_double_complex a,__pyx_t_double_complex b)28987         static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_pow_double(__pyx_t_double_complex a, __pyx_t_double_complex b) {
28988             __pyx_t_double_complex z;
28989             double r, lnr, theta, z_r, z_theta;
28990             if (b.imag == 0 && b.real == (int)b.real) {
28991                 if (b.real < 0) {
28992                     double denom = a.real * a.real + a.imag * a.imag;
28993                     a.real = a.real / denom;
28994                     a.imag = -a.imag / denom;
28995                     b.real = -b.real;
28996                 }
28997                 switch ((int)b.real) {
28998                     case 0:
28999                         z.real = 1;
29000                         z.imag = 0;
29001                         return z;
29002                     case 1:
29003                         return a;
29004                     case 2:
29005                         return __Pyx_c_prod_double(a, a);
29006                     case 3:
29007                         z = __Pyx_c_prod_double(a, a);
29008                         return __Pyx_c_prod_double(z, a);
29009                     case 4:
29010                         z = __Pyx_c_prod_double(a, a);
29011                         return __Pyx_c_prod_double(z, z);
29012                 }
29013             }
29014             if (a.imag == 0) {
29015                 if (a.real == 0) {
29016                     return a;
29017                 } else if (b.imag == 0) {
29018                     z.real = pow(a.real, b.real);
29019                     z.imag = 0;
29020                     return z;
29021                 } else if (a.real > 0) {
29022                     r = a.real;
29023                     theta = 0;
29024                 } else {
29025                     r = -a.real;
29026                     theta = atan2(0.0, -1.0);
29027                 }
29028             } else {
29029                 r = __Pyx_c_abs_double(a);
29030                 theta = atan2(a.imag, a.real);
29031             }
29032             lnr = log(r);
29033             z_r = exp(lnr * b.real - theta * b.imag);
29034             z_theta = theta * b.real + lnr * b.imag;
29035             z.real = z_r * cos(z_theta);
29036             z.imag = z_r * sin(z_theta);
29037             return z;
29038         }
29039     #endif
29040 #endif
29041 
29042 #if PY_MAJOR_VERSION < 3
__Pyx_GetBuffer(PyObject * obj,Py_buffer * view,int flags)29043 static int __Pyx_GetBuffer(PyObject *obj, Py_buffer *view, int flags) {
29044     if (PyObject_CheckBuffer(obj)) return PyObject_GetBuffer(obj, view, flags);
29045         if (__Pyx_TypeCheck(obj, __pyx_array_type)) return __pyx_array_getbuffer(obj, view, flags);
29046         if (__Pyx_TypeCheck(obj, __pyx_memoryview_type)) return __pyx_memoryview_getbuffer(obj, view, flags);
29047     PyErr_Format(PyExc_TypeError, "'%.200s' does not have the buffer interface", Py_TYPE(obj)->tp_name);
29048     return -1;
29049 }
__Pyx_ReleaseBuffer(Py_buffer * view)29050 static void __Pyx_ReleaseBuffer(Py_buffer *view) {
29051     PyObject *obj = view->obj;
29052     if (!obj) return;
29053     if (PyObject_CheckBuffer(obj)) {
29054         PyBuffer_Release(view);
29055         return;
29056     }
29057     if ((0)) {}
29058     view->obj = NULL;
29059     Py_DECREF(obj);
29060 }
29061 #endif
29062 
29063 
29064   /* MemviewSliceIsContig */
29065   static int
__pyx_memviewslice_is_contig(const __Pyx_memviewslice mvs,char order,int ndim)29066 __pyx_memviewslice_is_contig(const __Pyx_memviewslice mvs, char order, int ndim)
29067 {
29068     int i, index, step, start;
29069     Py_ssize_t itemsize = mvs.memview->view.itemsize;
29070     if (order == 'F') {
29071         step = 1;
29072         start = 0;
29073     } else {
29074         step = -1;
29075         start = ndim - 1;
29076     }
29077     for (i = 0; i < ndim; i++) {
29078         index = start + step * i;
29079         if (mvs.suboffsets[index] >= 0 || mvs.strides[index] != itemsize)
29080             return 0;
29081         itemsize *= mvs.shape[index];
29082     }
29083     return 1;
29084 }
29085 
29086 /* OverlappingSlices */
29087   static void
__pyx_get_array_memory_extents(__Pyx_memviewslice * slice,void ** out_start,void ** out_end,int ndim,size_t itemsize)29088 __pyx_get_array_memory_extents(__Pyx_memviewslice *slice,
29089                                void **out_start, void **out_end,
29090                                int ndim, size_t itemsize)
29091 {
29092     char *start, *end;
29093     int i;
29094     start = end = slice->data;
29095     for (i = 0; i < ndim; i++) {
29096         Py_ssize_t stride = slice->strides[i];
29097         Py_ssize_t extent = slice->shape[i];
29098         if (extent == 0) {
29099             *out_start = *out_end = start;
29100             return;
29101         } else {
29102             if (stride > 0)
29103                 end += stride * (extent - 1);
29104             else
29105                 start += stride * (extent - 1);
29106         }
29107     }
29108     *out_start = start;
29109     *out_end = end + itemsize;
29110 }
29111 static int
__pyx_slices_overlap(__Pyx_memviewslice * slice1,__Pyx_memviewslice * slice2,int ndim,size_t itemsize)29112 __pyx_slices_overlap(__Pyx_memviewslice *slice1,
29113                      __Pyx_memviewslice *slice2,
29114                      int ndim, size_t itemsize)
29115 {
29116     void *start1, *end1, *start2, *end2;
29117     __pyx_get_array_memory_extents(slice1, &start1, &end1, ndim, itemsize);
29118     __pyx_get_array_memory_extents(slice2, &start2, &end2, ndim, itemsize);
29119     return (start1 < end2) && (start2 < end1);
29120 }
29121 
29122 /* Capsule */
29123   static CYTHON_INLINE PyObject *
__pyx_capsule_create(void * p,CYTHON_UNUSED const char * sig)29124 __pyx_capsule_create(void *p, CYTHON_UNUSED const char *sig)
29125 {
29126     PyObject *cobj;
29127 #if PY_VERSION_HEX >= 0x02070000
29128     cobj = PyCapsule_New(p, sig, NULL);
29129 #else
29130     cobj = PyCObject_FromVoidPtr(p, NULL);
29131 #endif
29132     return cobj;
29133 }
29134 
29135 /* TypeInfoCompare */
29136   static int
__pyx_typeinfo_cmp(__Pyx_TypeInfo * a,__Pyx_TypeInfo * b)29137 __pyx_typeinfo_cmp(__Pyx_TypeInfo *a, __Pyx_TypeInfo *b)
29138 {
29139     int i;
29140     if (!a || !b)
29141         return 0;
29142     if (a == b)
29143         return 1;
29144     if (a->size != b->size || a->typegroup != b->typegroup ||
29145             a->is_unsigned != b->is_unsigned || a->ndim != b->ndim) {
29146         if (a->typegroup == 'H' || b->typegroup == 'H') {
29147             return a->size == b->size;
29148         } else {
29149             return 0;
29150         }
29151     }
29152     if (a->ndim) {
29153         for (i = 0; i < a->ndim; i++)
29154             if (a->arraysize[i] != b->arraysize[i])
29155                 return 0;
29156     }
29157     if (a->typegroup == 'S') {
29158         if (a->flags != b->flags)
29159             return 0;
29160         if (a->fields || b->fields) {
29161             if (!(a->fields && b->fields))
29162                 return 0;
29163             for (i = 0; a->fields[i].type && b->fields[i].type; i++) {
29164                 __Pyx_StructField *field_a = a->fields + i;
29165                 __Pyx_StructField *field_b = b->fields + i;
29166                 if (field_a->offset != field_b->offset ||
29167                     !__pyx_typeinfo_cmp(field_a->type, field_b->type))
29168                     return 0;
29169             }
29170             return !a->fields[i].type && !b->fields[i].type;
29171         }
29172     }
29173     return 1;
29174 }
29175 
29176 /* MemviewSliceValidateAndInit */
29177   static int
__pyx_check_strides(Py_buffer * buf,int dim,int ndim,int spec)29178 __pyx_check_strides(Py_buffer *buf, int dim, int ndim, int spec)
29179 {
29180     if (buf->shape[dim] <= 1)
29181         return 1;
29182     if (buf->strides) {
29183         if (spec & __Pyx_MEMVIEW_CONTIG) {
29184             if (spec & (__Pyx_MEMVIEW_PTR|__Pyx_MEMVIEW_FULL)) {
29185                 if (unlikely(buf->strides[dim] != sizeof(void *))) {
29186                     PyErr_Format(PyExc_ValueError,
29187                                  "Buffer is not indirectly contiguous "
29188                                  "in dimension %d.", dim);
29189                     goto fail;
29190                 }
29191             } else if (unlikely(buf->strides[dim] != buf->itemsize)) {
29192                 PyErr_SetString(PyExc_ValueError,
29193                                 "Buffer and memoryview are not contiguous "
29194                                 "in the same dimension.");
29195                 goto fail;
29196             }
29197         }
29198         if (spec & __Pyx_MEMVIEW_FOLLOW) {
29199             Py_ssize_t stride = buf->strides[dim];
29200             if (stride < 0)
29201                 stride = -stride;
29202             if (unlikely(stride < buf->itemsize)) {
29203                 PyErr_SetString(PyExc_ValueError,
29204                                 "Buffer and memoryview are not contiguous "
29205                                 "in the same dimension.");
29206                 goto fail;
29207             }
29208         }
29209     } else {
29210         if (unlikely(spec & __Pyx_MEMVIEW_CONTIG && dim != ndim - 1)) {
29211             PyErr_Format(PyExc_ValueError,
29212                          "C-contiguous buffer is not contiguous in "
29213                          "dimension %d", dim);
29214             goto fail;
29215         } else if (unlikely(spec & (__Pyx_MEMVIEW_PTR))) {
29216             PyErr_Format(PyExc_ValueError,
29217                          "C-contiguous buffer is not indirect in "
29218                          "dimension %d", dim);
29219             goto fail;
29220         } else if (unlikely(buf->suboffsets)) {
29221             PyErr_SetString(PyExc_ValueError,
29222                             "Buffer exposes suboffsets but no strides");
29223             goto fail;
29224         }
29225     }
29226     return 1;
29227 fail:
29228     return 0;
29229 }
29230 static int
__pyx_check_suboffsets(Py_buffer * buf,int dim,CYTHON_UNUSED int ndim,int spec)29231 __pyx_check_suboffsets(Py_buffer *buf, int dim, CYTHON_UNUSED int ndim, int spec)
29232 {
29233     if (spec & __Pyx_MEMVIEW_DIRECT) {
29234         if (unlikely(buf->suboffsets && buf->suboffsets[dim] >= 0)) {
29235             PyErr_Format(PyExc_ValueError,
29236                          "Buffer not compatible with direct access "
29237                          "in dimension %d.", dim);
29238             goto fail;
29239         }
29240     }
29241     if (spec & __Pyx_MEMVIEW_PTR) {
29242         if (unlikely(!buf->suboffsets || (buf->suboffsets[dim] < 0))) {
29243             PyErr_Format(PyExc_ValueError,
29244                          "Buffer is not indirectly accessible "
29245                          "in dimension %d.", dim);
29246             goto fail;
29247         }
29248     }
29249     return 1;
29250 fail:
29251     return 0;
29252 }
29253 static int
__pyx_verify_contig(Py_buffer * buf,int ndim,int c_or_f_flag)29254 __pyx_verify_contig(Py_buffer *buf, int ndim, int c_or_f_flag)
29255 {
29256     int i;
29257     if (c_or_f_flag & __Pyx_IS_F_CONTIG) {
29258         Py_ssize_t stride = 1;
29259         for (i = 0; i < ndim; i++) {
29260             if (unlikely(stride * buf->itemsize != buf->strides[i]  &&  buf->shape[i] > 1)) {
29261                 PyErr_SetString(PyExc_ValueError,
29262                     "Buffer not fortran contiguous.");
29263                 goto fail;
29264             }
29265             stride = stride * buf->shape[i];
29266         }
29267     } else if (c_or_f_flag & __Pyx_IS_C_CONTIG) {
29268         Py_ssize_t stride = 1;
29269         for (i = ndim - 1; i >- 1; i--) {
29270             if (unlikely(stride * buf->itemsize != buf->strides[i]  &&  buf->shape[i] > 1)) {
29271                 PyErr_SetString(PyExc_ValueError,
29272                     "Buffer not C contiguous.");
29273                 goto fail;
29274             }
29275             stride = stride * buf->shape[i];
29276         }
29277     }
29278     return 1;
29279 fail:
29280     return 0;
29281 }
__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)29282 static int __Pyx_ValidateAndInit_memviewslice(
29283                 int *axes_specs,
29284                 int c_or_f_flag,
29285                 int buf_flags,
29286                 int ndim,
29287                 __Pyx_TypeInfo *dtype,
29288                 __Pyx_BufFmt_StackElem stack[],
29289                 __Pyx_memviewslice *memviewslice,
29290                 PyObject *original_obj)
29291 {
29292     struct __pyx_memoryview_obj *memview, *new_memview;
29293     __Pyx_RefNannyDeclarations
29294     Py_buffer *buf;
29295     int i, spec = 0, retval = -1;
29296     __Pyx_BufFmt_Context ctx;
29297     int from_memoryview = __pyx_memoryview_check(original_obj);
29298     __Pyx_RefNannySetupContext("ValidateAndInit_memviewslice", 0);
29299     if (from_memoryview && __pyx_typeinfo_cmp(dtype, ((struct __pyx_memoryview_obj *)
29300                                                             original_obj)->typeinfo)) {
29301         memview = (struct __pyx_memoryview_obj *) original_obj;
29302         new_memview = NULL;
29303     } else {
29304         memview = (struct __pyx_memoryview_obj *) __pyx_memoryview_new(
29305                                             original_obj, buf_flags, 0, dtype);
29306         new_memview = memview;
29307         if (unlikely(!memview))
29308             goto fail;
29309     }
29310     buf = &memview->view;
29311     if (unlikely(buf->ndim != ndim)) {
29312         PyErr_Format(PyExc_ValueError,
29313                 "Buffer has wrong number of dimensions (expected %d, got %d)",
29314                 ndim, buf->ndim);
29315         goto fail;
29316     }
29317     if (new_memview) {
29318         __Pyx_BufFmt_Init(&ctx, stack, dtype);
29319         if (unlikely(!__Pyx_BufFmt_CheckString(&ctx, buf->format))) goto fail;
29320     }
29321     if (unlikely((unsigned) buf->itemsize != dtype->size)) {
29322         PyErr_Format(PyExc_ValueError,
29323                      "Item size of buffer (%" CYTHON_FORMAT_SSIZE_T "u byte%s) "
29324                      "does not match size of '%s' (%" CYTHON_FORMAT_SSIZE_T "u byte%s)",
29325                      buf->itemsize,
29326                      (buf->itemsize > 1) ? "s" : "",
29327                      dtype->name,
29328                      dtype->size,
29329                      (dtype->size > 1) ? "s" : "");
29330         goto fail;
29331     }
29332     if (buf->len > 0) {
29333         for (i = 0; i < ndim; i++) {
29334             spec = axes_specs[i];
29335             if (unlikely(!__pyx_check_strides(buf, i, ndim, spec)))
29336                 goto fail;
29337             if (unlikely(!__pyx_check_suboffsets(buf, i, ndim, spec)))
29338                 goto fail;
29339         }
29340         if (unlikely(buf->strides && !__pyx_verify_contig(buf, ndim, c_or_f_flag)))
29341             goto fail;
29342     }
29343     if (unlikely(__Pyx_init_memviewslice(memview, ndim, memviewslice,
29344                                          new_memview != NULL) == -1)) {
29345         goto fail;
29346     }
29347     retval = 0;
29348     goto no_fail;
29349 fail:
29350     Py_XDECREF(new_memview);
29351     retval = -1;
29352 no_fail:
29353     __Pyx_RefNannyFinishContext();
29354     return retval;
29355 }
29356 
29357 /* ObjectToMemviewSlice */
__Pyx_PyObject_to_MemoryviewSlice_dcd____pyx_t_double_complex(PyObject * obj,int writable_flag)29358   static CYTHON_INLINE __Pyx_memviewslice __Pyx_PyObject_to_MemoryviewSlice_dcd____pyx_t_double_complex(PyObject *obj, int writable_flag) {
29359     __Pyx_memviewslice result = { 0, 0, { 0 }, { 0 }, { 0 } };
29360     __Pyx_BufFmt_StackElem stack[1];
29361     int axes_specs[] = { (__Pyx_MEMVIEW_DIRECT | __Pyx_MEMVIEW_CONTIG), (__Pyx_MEMVIEW_DIRECT | __Pyx_MEMVIEW_FOLLOW) };
29362     int retcode;
29363     if (obj == Py_None) {
29364         result.memview = (struct __pyx_memoryview_obj *) Py_None;
29365         return result;
29366     }
29367     retcode = __Pyx_ValidateAndInit_memviewslice(axes_specs, __Pyx_IS_F_CONTIG,
29368                                                  (PyBUF_F_CONTIGUOUS | PyBUF_FORMAT) | writable_flag, 2,
29369                                                  &__Pyx_TypeInfo___pyx_t_double_complex, stack,
29370                                                  &result, obj);
29371     if (unlikely(retcode == -1))
29372         goto __pyx_fail;
29373     return result;
29374 __pyx_fail:
29375     result.memview = NULL;
29376     result.data = NULL;
29377     return result;
29378 }
29379 
29380 /* ObjectToMemviewSlice */
__Pyx_PyObject_to_MemoryviewSlice_d_dc_double(PyObject * obj,int writable_flag)29381   static CYTHON_INLINE __Pyx_memviewslice __Pyx_PyObject_to_MemoryviewSlice_d_dc_double(PyObject *obj, int writable_flag) {
29382     __Pyx_memviewslice result = { 0, 0, { 0 }, { 0 }, { 0 } };
29383     __Pyx_BufFmt_StackElem stack[1];
29384     int axes_specs[] = { (__Pyx_MEMVIEW_DIRECT | __Pyx_MEMVIEW_FOLLOW), (__Pyx_MEMVIEW_DIRECT | __Pyx_MEMVIEW_CONTIG) };
29385     int retcode;
29386     if (obj == Py_None) {
29387         result.memview = (struct __pyx_memoryview_obj *) Py_None;
29388         return result;
29389     }
29390     retcode = __Pyx_ValidateAndInit_memviewslice(axes_specs, __Pyx_IS_C_CONTIG,
29391                                                  (PyBUF_C_CONTIGUOUS | PyBUF_FORMAT) | writable_flag, 2,
29392                                                  &__Pyx_TypeInfo_double, stack,
29393                                                  &result, obj);
29394     if (unlikely(retcode == -1))
29395         goto __pyx_fail;
29396     return result;
29397 __pyx_fail:
29398     result.memview = NULL;
29399     result.data = NULL;
29400     return result;
29401 }
29402 
29403 /* CIntFromPyVerify */
29404   #define __PYX_VERIFY_RETURN_INT(target_type, func_type, func_value)\
29405     __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, 0)
29406 #define __PYX_VERIFY_RETURN_INT_EXC(target_type, func_type, func_value)\
29407     __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, 1)
29408 #define __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, exc)\
29409     {\
29410         func_type value = func_value;\
29411         if (sizeof(target_type) < sizeof(func_type)) {\
29412             if (unlikely(value != (func_type) (target_type) value)) {\
29413                 func_type zero = 0;\
29414                 if (exc && unlikely(value == (func_type)-1 && PyErr_Occurred()))\
29415                     return (target_type) -1;\
29416                 if (is_unsigned && unlikely(value < zero))\
29417                     goto raise_neg_overflow;\
29418                 else\
29419                     goto raise_overflow;\
29420             }\
29421         }\
29422         return (target_type) value;\
29423     }
29424 
29425 /* None */
__Pyx_pow_long(long b,long e)29426   static CYTHON_INLINE long __Pyx_pow_long(long b, long e) {
29427     long t = b;
29428     switch (e) {
29429         case 3:
29430             t *= b;
29431         CYTHON_FALLTHROUGH;
29432         case 2:
29433             t *= b;
29434         CYTHON_FALLTHROUGH;
29435         case 1:
29436             return t;
29437         case 0:
29438             return 1;
29439     }
29440     #if 1
29441     if (unlikely(e<0)) return 0;
29442     #endif
29443     t = 1;
29444     while (likely(e)) {
29445         t *= (b * (e&1)) | ((~e)&1);
29446         b *= b;
29447         e >>= 1;
29448     }
29449     return t;
29450 }
29451 
29452 /* MemviewDtypeToObject */
__pyx_memview_get_double(const char * itemp)29453   static CYTHON_INLINE PyObject *__pyx_memview_get_double(const char *itemp) {
29454     return (PyObject *) PyFloat_FromDouble(*(double *) itemp);
29455 }
__pyx_memview_set_double(const char * itemp,PyObject * obj)29456 static CYTHON_INLINE int __pyx_memview_set_double(const char *itemp, PyObject *obj) {
29457     double value = __pyx_PyFloat_AsDouble(obj);
29458     if ((value == (double)-1) && PyErr_Occurred())
29459         return 0;
29460     *(double *) itemp = value;
29461     return 1;
29462 }
29463 
29464 /* FromPy */
__Pyx_PyComplex_As___pyx_t_double_complex(PyObject * o)29465   static __pyx_t_double_complex __Pyx_PyComplex_As___pyx_t_double_complex(PyObject* o) {
29466     Py_complex cval;
29467 #if !CYTHON_COMPILING_IN_PYPY
29468     if (PyComplex_CheckExact(o))
29469         cval = ((PyComplexObject *)o)->cval;
29470     else
29471 #endif
29472         cval = PyComplex_AsCComplex(o);
29473     return __pyx_t_double_complex_from_parts(
29474                (double)cval.real,
29475                (double)cval.imag);
29476 }
29477 
29478 /* MemviewDtypeToObject */
__pyx_memview_get___pyx_t_double_complex(const char * itemp)29479   static CYTHON_INLINE PyObject *__pyx_memview_get___pyx_t_double_complex(const char *itemp) {
29480     return (PyObject *) __pyx_PyComplex_FromComplex(*(__pyx_t_double_complex *) itemp);
29481 }
__pyx_memview_set___pyx_t_double_complex(const char * itemp,PyObject * obj)29482 static CYTHON_INLINE int __pyx_memview_set___pyx_t_double_complex(const char *itemp, PyObject *obj) {
29483     __pyx_t_double_complex value = __Pyx_PyComplex_As___pyx_t_double_complex(obj);
29484     if (PyErr_Occurred())
29485         return 0;
29486     *(__pyx_t_double_complex *) itemp = value;
29487     return 1;
29488 }
29489 
29490 /* Declarations */
29491   #if CYTHON_CCOMPLEX
29492   #ifdef __cplusplus
__pyx_t_float_complex_from_parts(float x,float y)29493     static CYTHON_INLINE __pyx_t_float_complex __pyx_t_float_complex_from_parts(float x, float y) {
29494       return ::std::complex< float >(x, y);
29495     }
29496   #else
__pyx_t_float_complex_from_parts(float x,float y)29497     static CYTHON_INLINE __pyx_t_float_complex __pyx_t_float_complex_from_parts(float x, float y) {
29498       return x + y*(__pyx_t_float_complex)_Complex_I;
29499     }
29500   #endif
29501 #else
__pyx_t_float_complex_from_parts(float x,float y)29502     static CYTHON_INLINE __pyx_t_float_complex __pyx_t_float_complex_from_parts(float x, float y) {
29503       __pyx_t_float_complex z;
29504       z.real = x;
29505       z.imag = y;
29506       return z;
29507     }
29508 #endif
29509 
29510 /* Arithmetic */
29511   #if CYTHON_CCOMPLEX
29512 #else
__Pyx_c_eq_float(__pyx_t_float_complex a,__pyx_t_float_complex b)29513     static CYTHON_INLINE int __Pyx_c_eq_float(__pyx_t_float_complex a, __pyx_t_float_complex b) {
29514        return (a.real == b.real) && (a.imag == b.imag);
29515     }
__Pyx_c_sum_float(__pyx_t_float_complex a,__pyx_t_float_complex b)29516     static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_sum_float(__pyx_t_float_complex a, __pyx_t_float_complex b) {
29517         __pyx_t_float_complex z;
29518         z.real = a.real + b.real;
29519         z.imag = a.imag + b.imag;
29520         return z;
29521     }
__Pyx_c_diff_float(__pyx_t_float_complex a,__pyx_t_float_complex b)29522     static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_diff_float(__pyx_t_float_complex a, __pyx_t_float_complex b) {
29523         __pyx_t_float_complex z;
29524         z.real = a.real - b.real;
29525         z.imag = a.imag - b.imag;
29526         return z;
29527     }
__Pyx_c_prod_float(__pyx_t_float_complex a,__pyx_t_float_complex b)29528     static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_prod_float(__pyx_t_float_complex a, __pyx_t_float_complex b) {
29529         __pyx_t_float_complex z;
29530         z.real = a.real * b.real - a.imag * b.imag;
29531         z.imag = a.real * b.imag + a.imag * b.real;
29532         return z;
29533     }
29534     #if 1
__Pyx_c_quot_float(__pyx_t_float_complex a,__pyx_t_float_complex b)29535     static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_quot_float(__pyx_t_float_complex a, __pyx_t_float_complex b) {
29536         if (b.imag == 0) {
29537             return __pyx_t_float_complex_from_parts(a.real / b.real, a.imag / b.real);
29538         } else if (fabsf(b.real) >= fabsf(b.imag)) {
29539             if (b.real == 0 && b.imag == 0) {
29540                 return __pyx_t_float_complex_from_parts(a.real / b.real, a.imag / b.imag);
29541             } else {
29542                 float r = b.imag / b.real;
29543                 float s = (float)(1.0) / (b.real + b.imag * r);
29544                 return __pyx_t_float_complex_from_parts(
29545                     (a.real + a.imag * r) * s, (a.imag - a.real * r) * s);
29546             }
29547         } else {
29548             float r = b.real / b.imag;
29549             float s = (float)(1.0) / (b.imag + b.real * r);
29550             return __pyx_t_float_complex_from_parts(
29551                 (a.real * r + a.imag) * s, (a.imag * r - a.real) * s);
29552         }
29553     }
29554     #else
__Pyx_c_quot_float(__pyx_t_float_complex a,__pyx_t_float_complex b)29555     static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_quot_float(__pyx_t_float_complex a, __pyx_t_float_complex b) {
29556         if (b.imag == 0) {
29557             return __pyx_t_float_complex_from_parts(a.real / b.real, a.imag / b.real);
29558         } else {
29559             float denom = b.real * b.real + b.imag * b.imag;
29560             return __pyx_t_float_complex_from_parts(
29561                 (a.real * b.real + a.imag * b.imag) / denom,
29562                 (a.imag * b.real - a.real * b.imag) / denom);
29563         }
29564     }
29565     #endif
__Pyx_c_neg_float(__pyx_t_float_complex a)29566     static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_neg_float(__pyx_t_float_complex a) {
29567         __pyx_t_float_complex z;
29568         z.real = -a.real;
29569         z.imag = -a.imag;
29570         return z;
29571     }
__Pyx_c_is_zero_float(__pyx_t_float_complex a)29572     static CYTHON_INLINE int __Pyx_c_is_zero_float(__pyx_t_float_complex a) {
29573        return (a.real == 0) && (a.imag == 0);
29574     }
__Pyx_c_conj_float(__pyx_t_float_complex a)29575     static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_conj_float(__pyx_t_float_complex a) {
29576         __pyx_t_float_complex z;
29577         z.real =  a.real;
29578         z.imag = -a.imag;
29579         return z;
29580     }
29581     #if 1
__Pyx_c_abs_float(__pyx_t_float_complex z)29582         static CYTHON_INLINE float __Pyx_c_abs_float(__pyx_t_float_complex z) {
29583           #if !defined(HAVE_HYPOT) || defined(_MSC_VER)
29584             return sqrtf(z.real*z.real + z.imag*z.imag);
29585           #else
29586             return hypotf(z.real, z.imag);
29587           #endif
29588         }
__Pyx_c_pow_float(__pyx_t_float_complex a,__pyx_t_float_complex b)29589         static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_pow_float(__pyx_t_float_complex a, __pyx_t_float_complex b) {
29590             __pyx_t_float_complex z;
29591             float r, lnr, theta, z_r, z_theta;
29592             if (b.imag == 0 && b.real == (int)b.real) {
29593                 if (b.real < 0) {
29594                     float denom = a.real * a.real + a.imag * a.imag;
29595                     a.real = a.real / denom;
29596                     a.imag = -a.imag / denom;
29597                     b.real = -b.real;
29598                 }
29599                 switch ((int)b.real) {
29600                     case 0:
29601                         z.real = 1;
29602                         z.imag = 0;
29603                         return z;
29604                     case 1:
29605                         return a;
29606                     case 2:
29607                         return __Pyx_c_prod_float(a, a);
29608                     case 3:
29609                         z = __Pyx_c_prod_float(a, a);
29610                         return __Pyx_c_prod_float(z, a);
29611                     case 4:
29612                         z = __Pyx_c_prod_float(a, a);
29613                         return __Pyx_c_prod_float(z, z);
29614                 }
29615             }
29616             if (a.imag == 0) {
29617                 if (a.real == 0) {
29618                     return a;
29619                 } else if (b.imag == 0) {
29620                     z.real = powf(a.real, b.real);
29621                     z.imag = 0;
29622                     return z;
29623                 } else if (a.real > 0) {
29624                     r = a.real;
29625                     theta = 0;
29626                 } else {
29627                     r = -a.real;
29628                     theta = atan2f(0.0, -1.0);
29629                 }
29630             } else {
29631                 r = __Pyx_c_abs_float(a);
29632                 theta = atan2f(a.imag, a.real);
29633             }
29634             lnr = logf(r);
29635             z_r = expf(lnr * b.real - theta * b.imag);
29636             z_theta = theta * b.real + lnr * b.imag;
29637             z.real = z_r * cosf(z_theta);
29638             z.imag = z_r * sinf(z_theta);
29639             return z;
29640         }
29641     #endif
29642 #endif
29643 
29644 /* MemviewSliceCopyTemplate */
29645   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)29646 __pyx_memoryview_copy_new_contig(const __Pyx_memviewslice *from_mvs,
29647                                  const char *mode, int ndim,
29648                                  size_t sizeof_dtype, int contig_flag,
29649                                  int dtype_is_object)
29650 {
29651     __Pyx_RefNannyDeclarations
29652     int i;
29653     __Pyx_memviewslice new_mvs = { 0, 0, { 0 }, { 0 }, { 0 } };
29654     struct __pyx_memoryview_obj *from_memview = from_mvs->memview;
29655     Py_buffer *buf = &from_memview->view;
29656     PyObject *shape_tuple = NULL;
29657     PyObject *temp_int = NULL;
29658     struct __pyx_array_obj *array_obj = NULL;
29659     struct __pyx_memoryview_obj *memview_obj = NULL;
29660     __Pyx_RefNannySetupContext("__pyx_memoryview_copy_new_contig", 0);
29661     for (i = 0; i < ndim; i++) {
29662         if (unlikely(from_mvs->suboffsets[i] >= 0)) {
29663             PyErr_Format(PyExc_ValueError, "Cannot copy memoryview slice with "
29664                                            "indirect dimensions (axis %d)", i);
29665             goto fail;
29666         }
29667     }
29668     shape_tuple = PyTuple_New(ndim);
29669     if (unlikely(!shape_tuple)) {
29670         goto fail;
29671     }
29672     __Pyx_GOTREF(shape_tuple);
29673     for(i = 0; i < ndim; i++) {
29674         temp_int = PyInt_FromSsize_t(from_mvs->shape[i]);
29675         if(unlikely(!temp_int)) {
29676             goto fail;
29677         } else {
29678             PyTuple_SET_ITEM(shape_tuple, i, temp_int);
29679             temp_int = NULL;
29680         }
29681     }
29682     array_obj = __pyx_array_new(shape_tuple, sizeof_dtype, buf->format, (char *) mode, NULL);
29683     if (unlikely(!array_obj)) {
29684         goto fail;
29685     }
29686     __Pyx_GOTREF(array_obj);
29687     memview_obj = (struct __pyx_memoryview_obj *) __pyx_memoryview_new(
29688                                     (PyObject *) array_obj, contig_flag,
29689                                     dtype_is_object,
29690                                     from_mvs->memview->typeinfo);
29691     if (unlikely(!memview_obj))
29692         goto fail;
29693     if (unlikely(__Pyx_init_memviewslice(memview_obj, ndim, &new_mvs, 1) < 0))
29694         goto fail;
29695     if (unlikely(__pyx_memoryview_copy_contents(*from_mvs, new_mvs, ndim, ndim,
29696                                                 dtype_is_object) < 0))
29697         goto fail;
29698     goto no_fail;
29699 fail:
29700     __Pyx_XDECREF(new_mvs.memview);
29701     new_mvs.memview = NULL;
29702     new_mvs.data = NULL;
29703 no_fail:
29704     __Pyx_XDECREF(shape_tuple);
29705     __Pyx_XDECREF(temp_int);
29706     __Pyx_XDECREF(array_obj);
29707     __Pyx_RefNannyFinishContext();
29708     return new_mvs;
29709 }
29710 
29711 /* CIntFromPy */
__Pyx_PyInt_As_unsigned_int(PyObject * x)29712   static CYTHON_INLINE unsigned int __Pyx_PyInt_As_unsigned_int(PyObject *x) {
29713 #ifdef __Pyx_HAS_GCC_DIAGNOSTIC
29714 #pragma GCC diagnostic push
29715 #pragma GCC diagnostic ignored "-Wconversion"
29716 #endif
29717     const unsigned int neg_one = (unsigned int) -1, const_zero = (unsigned int) 0;
29718 #ifdef __Pyx_HAS_GCC_DIAGNOSTIC
29719 #pragma GCC diagnostic pop
29720 #endif
29721     const int is_unsigned = neg_one > const_zero;
29722 #if PY_MAJOR_VERSION < 3
29723     if (likely(PyInt_Check(x))) {
29724         if (sizeof(unsigned int) < sizeof(long)) {
29725             __PYX_VERIFY_RETURN_INT(unsigned int, long, PyInt_AS_LONG(x))
29726         } else {
29727             long val = PyInt_AS_LONG(x);
29728             if (is_unsigned && unlikely(val < 0)) {
29729                 goto raise_neg_overflow;
29730             }
29731             return (unsigned int) val;
29732         }
29733     } else
29734 #endif
29735     if (likely(PyLong_Check(x))) {
29736         if (is_unsigned) {
29737 #if CYTHON_USE_PYLONG_INTERNALS
29738             const digit* digits = ((PyLongObject*)x)->ob_digit;
29739             switch (Py_SIZE(x)) {
29740                 case  0: return (unsigned int) 0;
29741                 case  1: __PYX_VERIFY_RETURN_INT(unsigned int, digit, digits[0])
29742                 case 2:
29743                     if (8 * sizeof(unsigned int) > 1 * PyLong_SHIFT) {
29744                         if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
29745                             __PYX_VERIFY_RETURN_INT(unsigned int, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
29746                         } else if (8 * sizeof(unsigned int) >= 2 * PyLong_SHIFT) {
29747                             return (unsigned int) (((((unsigned int)digits[1]) << PyLong_SHIFT) | (unsigned int)digits[0]));
29748                         }
29749                     }
29750                     break;
29751                 case 3:
29752                     if (8 * sizeof(unsigned int) > 2 * PyLong_SHIFT) {
29753                         if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
29754                             __PYX_VERIFY_RETURN_INT(unsigned int, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
29755                         } else if (8 * sizeof(unsigned int) >= 3 * PyLong_SHIFT) {
29756                             return (unsigned int) (((((((unsigned int)digits[2]) << PyLong_SHIFT) | (unsigned int)digits[1]) << PyLong_SHIFT) | (unsigned int)digits[0]));
29757                         }
29758                     }
29759                     break;
29760                 case 4:
29761                     if (8 * sizeof(unsigned int) > 3 * PyLong_SHIFT) {
29762                         if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
29763                             __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])))
29764                         } else if (8 * sizeof(unsigned int) >= 4 * PyLong_SHIFT) {
29765                             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]));
29766                         }
29767                     }
29768                     break;
29769             }
29770 #endif
29771 #if CYTHON_COMPILING_IN_CPYTHON
29772             if (unlikely(Py_SIZE(x) < 0)) {
29773                 goto raise_neg_overflow;
29774             }
29775 #else
29776             {
29777                 int result = PyObject_RichCompareBool(x, Py_False, Py_LT);
29778                 if (unlikely(result < 0))
29779                     return (unsigned int) -1;
29780                 if (unlikely(result == 1))
29781                     goto raise_neg_overflow;
29782             }
29783 #endif
29784             if (sizeof(unsigned int) <= sizeof(unsigned long)) {
29785                 __PYX_VERIFY_RETURN_INT_EXC(unsigned int, unsigned long, PyLong_AsUnsignedLong(x))
29786 #ifdef HAVE_LONG_LONG
29787             } else if (sizeof(unsigned int) <= sizeof(unsigned PY_LONG_LONG)) {
29788                 __PYX_VERIFY_RETURN_INT_EXC(unsigned int, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x))
29789 #endif
29790             }
29791         } else {
29792 #if CYTHON_USE_PYLONG_INTERNALS
29793             const digit* digits = ((PyLongObject*)x)->ob_digit;
29794             switch (Py_SIZE(x)) {
29795                 case  0: return (unsigned int) 0;
29796                 case -1: __PYX_VERIFY_RETURN_INT(unsigned int, sdigit, (sdigit) (-(sdigit)digits[0]))
29797                 case  1: __PYX_VERIFY_RETURN_INT(unsigned int,  digit, +digits[0])
29798                 case -2:
29799                     if (8 * sizeof(unsigned int) - 1 > 1 * PyLong_SHIFT) {
29800                         if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
29801                             __PYX_VERIFY_RETURN_INT(unsigned int, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
29802                         } else if (8 * sizeof(unsigned int) - 1 > 2 * PyLong_SHIFT) {
29803                             return (unsigned int) (((unsigned int)-1)*(((((unsigned int)digits[1]) << PyLong_SHIFT) | (unsigned int)digits[0])));
29804                         }
29805                     }
29806                     break;
29807                 case 2:
29808                     if (8 * sizeof(unsigned int) > 1 * PyLong_SHIFT) {
29809                         if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
29810                             __PYX_VERIFY_RETURN_INT(unsigned int, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
29811                         } else if (8 * sizeof(unsigned int) - 1 > 2 * PyLong_SHIFT) {
29812                             return (unsigned int) ((((((unsigned int)digits[1]) << PyLong_SHIFT) | (unsigned int)digits[0])));
29813                         }
29814                     }
29815                     break;
29816                 case -3:
29817                     if (8 * sizeof(unsigned int) - 1 > 2 * PyLong_SHIFT) {
29818                         if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
29819                             __PYX_VERIFY_RETURN_INT(unsigned int, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
29820                         } else if (8 * sizeof(unsigned int) - 1 > 3 * PyLong_SHIFT) {
29821                             return (unsigned int) (((unsigned int)-1)*(((((((unsigned int)digits[2]) << PyLong_SHIFT) | (unsigned int)digits[1]) << PyLong_SHIFT) | (unsigned int)digits[0])));
29822                         }
29823                     }
29824                     break;
29825                 case 3:
29826                     if (8 * sizeof(unsigned int) > 2 * PyLong_SHIFT) {
29827                         if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
29828                             __PYX_VERIFY_RETURN_INT(unsigned int, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
29829                         } else if (8 * sizeof(unsigned int) - 1 > 3 * PyLong_SHIFT) {
29830                             return (unsigned int) ((((((((unsigned int)digits[2]) << PyLong_SHIFT) | (unsigned int)digits[1]) << PyLong_SHIFT) | (unsigned int)digits[0])));
29831                         }
29832                     }
29833                     break;
29834                 case -4:
29835                     if (8 * sizeof(unsigned int) - 1 > 3 * PyLong_SHIFT) {
29836                         if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
29837                             __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])))
29838                         } else if (8 * sizeof(unsigned int) - 1 > 4 * PyLong_SHIFT) {
29839                             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])));
29840                         }
29841                     }
29842                     break;
29843                 case 4:
29844                     if (8 * sizeof(unsigned int) > 3 * PyLong_SHIFT) {
29845                         if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
29846                             __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])))
29847                         } else if (8 * sizeof(unsigned int) - 1 > 4 * PyLong_SHIFT) {
29848                             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])));
29849                         }
29850                     }
29851                     break;
29852             }
29853 #endif
29854             if (sizeof(unsigned int) <= sizeof(long)) {
29855                 __PYX_VERIFY_RETURN_INT_EXC(unsigned int, long, PyLong_AsLong(x))
29856 #ifdef HAVE_LONG_LONG
29857             } else if (sizeof(unsigned int) <= sizeof(PY_LONG_LONG)) {
29858                 __PYX_VERIFY_RETURN_INT_EXC(unsigned int, PY_LONG_LONG, PyLong_AsLongLong(x))
29859 #endif
29860             }
29861         }
29862         {
29863 #if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray)
29864             PyErr_SetString(PyExc_RuntimeError,
29865                             "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers");
29866 #else
29867             unsigned int val;
29868             PyObject *v = __Pyx_PyNumber_IntOrLong(x);
29869  #if PY_MAJOR_VERSION < 3
29870             if (likely(v) && !PyLong_Check(v)) {
29871                 PyObject *tmp = v;
29872                 v = PyNumber_Long(tmp);
29873                 Py_DECREF(tmp);
29874             }
29875  #endif
29876             if (likely(v)) {
29877                 int one = 1; int is_little = (int)*(unsigned char *)&one;
29878                 unsigned char *bytes = (unsigned char *)&val;
29879                 int ret = _PyLong_AsByteArray((PyLongObject *)v,
29880                                               bytes, sizeof(val),
29881                                               is_little, !is_unsigned);
29882                 Py_DECREF(v);
29883                 if (likely(!ret))
29884                     return val;
29885             }
29886 #endif
29887             return (unsigned int) -1;
29888         }
29889     } else {
29890         unsigned int val;
29891         PyObject *tmp = __Pyx_PyNumber_IntOrLong(x);
29892         if (!tmp) return (unsigned int) -1;
29893         val = __Pyx_PyInt_As_unsigned_int(tmp);
29894         Py_DECREF(tmp);
29895         return val;
29896     }
29897 raise_overflow:
29898     PyErr_SetString(PyExc_OverflowError,
29899         "value too large to convert to unsigned int");
29900     return (unsigned int) -1;
29901 raise_neg_overflow:
29902     PyErr_SetString(PyExc_OverflowError,
29903         "can't convert negative value to unsigned int");
29904     return (unsigned int) -1;
29905 }
29906 
29907 /* CIntFromPy */
__Pyx_PyInt_As_int(PyObject * x)29908   static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *x) {
29909 #ifdef __Pyx_HAS_GCC_DIAGNOSTIC
29910 #pragma GCC diagnostic push
29911 #pragma GCC diagnostic ignored "-Wconversion"
29912 #endif
29913     const int neg_one = (int) -1, const_zero = (int) 0;
29914 #ifdef __Pyx_HAS_GCC_DIAGNOSTIC
29915 #pragma GCC diagnostic pop
29916 #endif
29917     const int is_unsigned = neg_one > const_zero;
29918 #if PY_MAJOR_VERSION < 3
29919     if (likely(PyInt_Check(x))) {
29920         if (sizeof(int) < sizeof(long)) {
29921             __PYX_VERIFY_RETURN_INT(int, long, PyInt_AS_LONG(x))
29922         } else {
29923             long val = PyInt_AS_LONG(x);
29924             if (is_unsigned && unlikely(val < 0)) {
29925                 goto raise_neg_overflow;
29926             }
29927             return (int) val;
29928         }
29929     } else
29930 #endif
29931     if (likely(PyLong_Check(x))) {
29932         if (is_unsigned) {
29933 #if CYTHON_USE_PYLONG_INTERNALS
29934             const digit* digits = ((PyLongObject*)x)->ob_digit;
29935             switch (Py_SIZE(x)) {
29936                 case  0: return (int) 0;
29937                 case  1: __PYX_VERIFY_RETURN_INT(int, digit, digits[0])
29938                 case 2:
29939                     if (8 * sizeof(int) > 1 * PyLong_SHIFT) {
29940                         if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
29941                             __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
29942                         } else if (8 * sizeof(int) >= 2 * PyLong_SHIFT) {
29943                             return (int) (((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0]));
29944                         }
29945                     }
29946                     break;
29947                 case 3:
29948                     if (8 * sizeof(int) > 2 * PyLong_SHIFT) {
29949                         if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
29950                             __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
29951                         } else if (8 * sizeof(int) >= 3 * PyLong_SHIFT) {
29952                             return (int) (((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]));
29953                         }
29954                     }
29955                     break;
29956                 case 4:
29957                     if (8 * sizeof(int) > 3 * PyLong_SHIFT) {
29958                         if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
29959                             __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])))
29960                         } else if (8 * sizeof(int) >= 4 * PyLong_SHIFT) {
29961                             return (int) (((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]));
29962                         }
29963                     }
29964                     break;
29965             }
29966 #endif
29967 #if CYTHON_COMPILING_IN_CPYTHON
29968             if (unlikely(Py_SIZE(x) < 0)) {
29969                 goto raise_neg_overflow;
29970             }
29971 #else
29972             {
29973                 int result = PyObject_RichCompareBool(x, Py_False, Py_LT);
29974                 if (unlikely(result < 0))
29975                     return (int) -1;
29976                 if (unlikely(result == 1))
29977                     goto raise_neg_overflow;
29978             }
29979 #endif
29980             if (sizeof(int) <= sizeof(unsigned long)) {
29981                 __PYX_VERIFY_RETURN_INT_EXC(int, unsigned long, PyLong_AsUnsignedLong(x))
29982 #ifdef HAVE_LONG_LONG
29983             } else if (sizeof(int) <= sizeof(unsigned PY_LONG_LONG)) {
29984                 __PYX_VERIFY_RETURN_INT_EXC(int, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x))
29985 #endif
29986             }
29987         } else {
29988 #if CYTHON_USE_PYLONG_INTERNALS
29989             const digit* digits = ((PyLongObject*)x)->ob_digit;
29990             switch (Py_SIZE(x)) {
29991                 case  0: return (int) 0;
29992                 case -1: __PYX_VERIFY_RETURN_INT(int, sdigit, (sdigit) (-(sdigit)digits[0]))
29993                 case  1: __PYX_VERIFY_RETURN_INT(int,  digit, +digits[0])
29994                 case -2:
29995                     if (8 * sizeof(int) - 1 > 1 * PyLong_SHIFT) {
29996                         if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
29997                             __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
29998                         } else if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) {
29999                             return (int) (((int)-1)*(((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
30000                         }
30001                     }
30002                     break;
30003                 case 2:
30004                     if (8 * sizeof(int) > 1 * PyLong_SHIFT) {
30005                         if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
30006                             __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
30007                         } else if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) {
30008                             return (int) ((((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
30009                         }
30010                     }
30011                     break;
30012                 case -3:
30013                     if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) {
30014                         if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
30015                             __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
30016                         } else if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) {
30017                             return (int) (((int)-1)*(((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
30018                         }
30019                     }
30020                     break;
30021                 case 3:
30022                     if (8 * sizeof(int) > 2 * PyLong_SHIFT) {
30023                         if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
30024                             __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
30025                         } else if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) {
30026                             return (int) ((((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
30027                         }
30028                     }
30029                     break;
30030                 case -4:
30031                     if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) {
30032                         if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
30033                             __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])))
30034                         } else if (8 * sizeof(int) - 1 > 4 * PyLong_SHIFT) {
30035                             return (int) (((int)-1)*(((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
30036                         }
30037                     }
30038                     break;
30039                 case 4:
30040                     if (8 * sizeof(int) > 3 * PyLong_SHIFT) {
30041                         if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
30042                             __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])))
30043                         } else if (8 * sizeof(int) - 1 > 4 * PyLong_SHIFT) {
30044                             return (int) ((((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
30045                         }
30046                     }
30047                     break;
30048             }
30049 #endif
30050             if (sizeof(int) <= sizeof(long)) {
30051                 __PYX_VERIFY_RETURN_INT_EXC(int, long, PyLong_AsLong(x))
30052 #ifdef HAVE_LONG_LONG
30053             } else if (sizeof(int) <= sizeof(PY_LONG_LONG)) {
30054                 __PYX_VERIFY_RETURN_INT_EXC(int, PY_LONG_LONG, PyLong_AsLongLong(x))
30055 #endif
30056             }
30057         }
30058         {
30059 #if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray)
30060             PyErr_SetString(PyExc_RuntimeError,
30061                             "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers");
30062 #else
30063             int val;
30064             PyObject *v = __Pyx_PyNumber_IntOrLong(x);
30065  #if PY_MAJOR_VERSION < 3
30066             if (likely(v) && !PyLong_Check(v)) {
30067                 PyObject *tmp = v;
30068                 v = PyNumber_Long(tmp);
30069                 Py_DECREF(tmp);
30070             }
30071  #endif
30072             if (likely(v)) {
30073                 int one = 1; int is_little = (int)*(unsigned char *)&one;
30074                 unsigned char *bytes = (unsigned char *)&val;
30075                 int ret = _PyLong_AsByteArray((PyLongObject *)v,
30076                                               bytes, sizeof(val),
30077                                               is_little, !is_unsigned);
30078                 Py_DECREF(v);
30079                 if (likely(!ret))
30080                     return val;
30081             }
30082 #endif
30083             return (int) -1;
30084         }
30085     } else {
30086         int val;
30087         PyObject *tmp = __Pyx_PyNumber_IntOrLong(x);
30088         if (!tmp) return (int) -1;
30089         val = __Pyx_PyInt_As_int(tmp);
30090         Py_DECREF(tmp);
30091         return val;
30092     }
30093 raise_overflow:
30094     PyErr_SetString(PyExc_OverflowError,
30095         "value too large to convert to int");
30096     return (int) -1;
30097 raise_neg_overflow:
30098     PyErr_SetString(PyExc_OverflowError,
30099         "can't convert negative value to int");
30100     return (int) -1;
30101 }
30102 
30103 /* CIntToPy */
__Pyx_PyInt_From_int(int value)30104   static CYTHON_INLINE PyObject* __Pyx_PyInt_From_int(int value) {
30105 #ifdef __Pyx_HAS_GCC_DIAGNOSTIC
30106 #pragma GCC diagnostic push
30107 #pragma GCC diagnostic ignored "-Wconversion"
30108 #endif
30109     const int neg_one = (int) -1, const_zero = (int) 0;
30110 #ifdef __Pyx_HAS_GCC_DIAGNOSTIC
30111 #pragma GCC diagnostic pop
30112 #endif
30113     const int is_unsigned = neg_one > const_zero;
30114     if (is_unsigned) {
30115         if (sizeof(int) < sizeof(long)) {
30116             return PyInt_FromLong((long) value);
30117         } else if (sizeof(int) <= sizeof(unsigned long)) {
30118             return PyLong_FromUnsignedLong((unsigned long) value);
30119 #ifdef HAVE_LONG_LONG
30120         } else if (sizeof(int) <= sizeof(unsigned PY_LONG_LONG)) {
30121             return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value);
30122 #endif
30123         }
30124     } else {
30125         if (sizeof(int) <= sizeof(long)) {
30126             return PyInt_FromLong((long) value);
30127 #ifdef HAVE_LONG_LONG
30128         } else if (sizeof(int) <= sizeof(PY_LONG_LONG)) {
30129             return PyLong_FromLongLong((PY_LONG_LONG) value);
30130 #endif
30131         }
30132     }
30133     {
30134         int one = 1; int little = (int)*(unsigned char *)&one;
30135         unsigned char *bytes = (unsigned char *)&value;
30136         return _PyLong_FromByteArray(bytes, sizeof(int),
30137                                      little, !is_unsigned);
30138     }
30139 }
30140 
30141 /* CIntFromPy */
__Pyx_PyInt_As_size_t(PyObject * x)30142   static CYTHON_INLINE size_t __Pyx_PyInt_As_size_t(PyObject *x) {
30143 #ifdef __Pyx_HAS_GCC_DIAGNOSTIC
30144 #pragma GCC diagnostic push
30145 #pragma GCC diagnostic ignored "-Wconversion"
30146 #endif
30147     const size_t neg_one = (size_t) -1, const_zero = (size_t) 0;
30148 #ifdef __Pyx_HAS_GCC_DIAGNOSTIC
30149 #pragma GCC diagnostic pop
30150 #endif
30151     const int is_unsigned = neg_one > const_zero;
30152 #if PY_MAJOR_VERSION < 3
30153     if (likely(PyInt_Check(x))) {
30154         if (sizeof(size_t) < sizeof(long)) {
30155             __PYX_VERIFY_RETURN_INT(size_t, long, PyInt_AS_LONG(x))
30156         } else {
30157             long val = PyInt_AS_LONG(x);
30158             if (is_unsigned && unlikely(val < 0)) {
30159                 goto raise_neg_overflow;
30160             }
30161             return (size_t) val;
30162         }
30163     } else
30164 #endif
30165     if (likely(PyLong_Check(x))) {
30166         if (is_unsigned) {
30167 #if CYTHON_USE_PYLONG_INTERNALS
30168             const digit* digits = ((PyLongObject*)x)->ob_digit;
30169             switch (Py_SIZE(x)) {
30170                 case  0: return (size_t) 0;
30171                 case  1: __PYX_VERIFY_RETURN_INT(size_t, digit, digits[0])
30172                 case 2:
30173                     if (8 * sizeof(size_t) > 1 * PyLong_SHIFT) {
30174                         if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
30175                             __PYX_VERIFY_RETURN_INT(size_t, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
30176                         } else if (8 * sizeof(size_t) >= 2 * PyLong_SHIFT) {
30177                             return (size_t) (((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
30178                         }
30179                     }
30180                     break;
30181                 case 3:
30182                     if (8 * sizeof(size_t) > 2 * PyLong_SHIFT) {
30183                         if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
30184                             __PYX_VERIFY_RETURN_INT(size_t, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
30185                         } else if (8 * sizeof(size_t) >= 3 * PyLong_SHIFT) {
30186                             return (size_t) (((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
30187                         }
30188                     }
30189                     break;
30190                 case 4:
30191                     if (8 * sizeof(size_t) > 3 * PyLong_SHIFT) {
30192                         if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
30193                             __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])))
30194                         } else if (8 * sizeof(size_t) >= 4 * PyLong_SHIFT) {
30195                             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]));
30196                         }
30197                     }
30198                     break;
30199             }
30200 #endif
30201 #if CYTHON_COMPILING_IN_CPYTHON
30202             if (unlikely(Py_SIZE(x) < 0)) {
30203                 goto raise_neg_overflow;
30204             }
30205 #else
30206             {
30207                 int result = PyObject_RichCompareBool(x, Py_False, Py_LT);
30208                 if (unlikely(result < 0))
30209                     return (size_t) -1;
30210                 if (unlikely(result == 1))
30211                     goto raise_neg_overflow;
30212             }
30213 #endif
30214             if (sizeof(size_t) <= sizeof(unsigned long)) {
30215                 __PYX_VERIFY_RETURN_INT_EXC(size_t, unsigned long, PyLong_AsUnsignedLong(x))
30216 #ifdef HAVE_LONG_LONG
30217             } else if (sizeof(size_t) <= sizeof(unsigned PY_LONG_LONG)) {
30218                 __PYX_VERIFY_RETURN_INT_EXC(size_t, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x))
30219 #endif
30220             }
30221         } else {
30222 #if CYTHON_USE_PYLONG_INTERNALS
30223             const digit* digits = ((PyLongObject*)x)->ob_digit;
30224             switch (Py_SIZE(x)) {
30225                 case  0: return (size_t) 0;
30226                 case -1: __PYX_VERIFY_RETURN_INT(size_t, sdigit, (sdigit) (-(sdigit)digits[0]))
30227                 case  1: __PYX_VERIFY_RETURN_INT(size_t,  digit, +digits[0])
30228                 case -2:
30229                     if (8 * sizeof(size_t) - 1 > 1 * PyLong_SHIFT) {
30230                         if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
30231                             __PYX_VERIFY_RETURN_INT(size_t, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
30232                         } else if (8 * sizeof(size_t) - 1 > 2 * PyLong_SHIFT) {
30233                             return (size_t) (((size_t)-1)*(((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])));
30234                         }
30235                     }
30236                     break;
30237                 case 2:
30238                     if (8 * sizeof(size_t) > 1 * PyLong_SHIFT) {
30239                         if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
30240                             __PYX_VERIFY_RETURN_INT(size_t, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
30241                         } else if (8 * sizeof(size_t) - 1 > 2 * PyLong_SHIFT) {
30242                             return (size_t) ((((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])));
30243                         }
30244                     }
30245                     break;
30246                 case -3:
30247                     if (8 * sizeof(size_t) - 1 > 2 * PyLong_SHIFT) {
30248                         if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
30249                             __PYX_VERIFY_RETURN_INT(size_t, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
30250                         } else if (8 * sizeof(size_t) - 1 > 3 * PyLong_SHIFT) {
30251                             return (size_t) (((size_t)-1)*(((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])));
30252                         }
30253                     }
30254                     break;
30255                 case 3:
30256                     if (8 * sizeof(size_t) > 2 * PyLong_SHIFT) {
30257                         if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
30258                             __PYX_VERIFY_RETURN_INT(size_t, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
30259                         } else if (8 * sizeof(size_t) - 1 > 3 * PyLong_SHIFT) {
30260                             return (size_t) ((((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])));
30261                         }
30262                     }
30263                     break;
30264                 case -4:
30265                     if (8 * sizeof(size_t) - 1 > 3 * PyLong_SHIFT) {
30266                         if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
30267                             __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])))
30268                         } else if (8 * sizeof(size_t) - 1 > 4 * PyLong_SHIFT) {
30269                             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])));
30270                         }
30271                     }
30272                     break;
30273                 case 4:
30274                     if (8 * sizeof(size_t) > 3 * PyLong_SHIFT) {
30275                         if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
30276                             __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])))
30277                         } else if (8 * sizeof(size_t) - 1 > 4 * PyLong_SHIFT) {
30278                             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])));
30279                         }
30280                     }
30281                     break;
30282             }
30283 #endif
30284             if (sizeof(size_t) <= sizeof(long)) {
30285                 __PYX_VERIFY_RETURN_INT_EXC(size_t, long, PyLong_AsLong(x))
30286 #ifdef HAVE_LONG_LONG
30287             } else if (sizeof(size_t) <= sizeof(PY_LONG_LONG)) {
30288                 __PYX_VERIFY_RETURN_INT_EXC(size_t, PY_LONG_LONG, PyLong_AsLongLong(x))
30289 #endif
30290             }
30291         }
30292         {
30293 #if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray)
30294             PyErr_SetString(PyExc_RuntimeError,
30295                             "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers");
30296 #else
30297             size_t val;
30298             PyObject *v = __Pyx_PyNumber_IntOrLong(x);
30299  #if PY_MAJOR_VERSION < 3
30300             if (likely(v) && !PyLong_Check(v)) {
30301                 PyObject *tmp = v;
30302                 v = PyNumber_Long(tmp);
30303                 Py_DECREF(tmp);
30304             }
30305  #endif
30306             if (likely(v)) {
30307                 int one = 1; int is_little = (int)*(unsigned char *)&one;
30308                 unsigned char *bytes = (unsigned char *)&val;
30309                 int ret = _PyLong_AsByteArray((PyLongObject *)v,
30310                                               bytes, sizeof(val),
30311                                               is_little, !is_unsigned);
30312                 Py_DECREF(v);
30313                 if (likely(!ret))
30314                     return val;
30315             }
30316 #endif
30317             return (size_t) -1;
30318         }
30319     } else {
30320         size_t val;
30321         PyObject *tmp = __Pyx_PyNumber_IntOrLong(x);
30322         if (!tmp) return (size_t) -1;
30323         val = __Pyx_PyInt_As_size_t(tmp);
30324         Py_DECREF(tmp);
30325         return val;
30326     }
30327 raise_overflow:
30328     PyErr_SetString(PyExc_OverflowError,
30329         "value too large to convert to size_t");
30330     return (size_t) -1;
30331 raise_neg_overflow:
30332     PyErr_SetString(PyExc_OverflowError,
30333         "can't convert negative value to size_t");
30334     return (size_t) -1;
30335 }
30336 
30337 /* CIntToPy */
__Pyx_PyInt_From_long(long value)30338   static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value) {
30339 #ifdef __Pyx_HAS_GCC_DIAGNOSTIC
30340 #pragma GCC diagnostic push
30341 #pragma GCC diagnostic ignored "-Wconversion"
30342 #endif
30343     const long neg_one = (long) -1, const_zero = (long) 0;
30344 #ifdef __Pyx_HAS_GCC_DIAGNOSTIC
30345 #pragma GCC diagnostic pop
30346 #endif
30347     const int is_unsigned = neg_one > const_zero;
30348     if (is_unsigned) {
30349         if (sizeof(long) < sizeof(long)) {
30350             return PyInt_FromLong((long) value);
30351         } else if (sizeof(long) <= sizeof(unsigned long)) {
30352             return PyLong_FromUnsignedLong((unsigned long) value);
30353 #ifdef HAVE_LONG_LONG
30354         } else if (sizeof(long) <= sizeof(unsigned PY_LONG_LONG)) {
30355             return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value);
30356 #endif
30357         }
30358     } else {
30359         if (sizeof(long) <= sizeof(long)) {
30360             return PyInt_FromLong((long) value);
30361 #ifdef HAVE_LONG_LONG
30362         } else if (sizeof(long) <= sizeof(PY_LONG_LONG)) {
30363             return PyLong_FromLongLong((PY_LONG_LONG) value);
30364 #endif
30365         }
30366     }
30367     {
30368         int one = 1; int little = (int)*(unsigned char *)&one;
30369         unsigned char *bytes = (unsigned char *)&value;
30370         return _PyLong_FromByteArray(bytes, sizeof(long),
30371                                      little, !is_unsigned);
30372     }
30373 }
30374 
30375 /* CIntToPy */
__Pyx_PyInt_From_unsigned_int(unsigned int value)30376   static CYTHON_INLINE PyObject* __Pyx_PyInt_From_unsigned_int(unsigned int value) {
30377 #ifdef __Pyx_HAS_GCC_DIAGNOSTIC
30378 #pragma GCC diagnostic push
30379 #pragma GCC diagnostic ignored "-Wconversion"
30380 #endif
30381     const unsigned int neg_one = (unsigned int) -1, const_zero = (unsigned int) 0;
30382 #ifdef __Pyx_HAS_GCC_DIAGNOSTIC
30383 #pragma GCC diagnostic pop
30384 #endif
30385     const int is_unsigned = neg_one > const_zero;
30386     if (is_unsigned) {
30387         if (sizeof(unsigned int) < sizeof(long)) {
30388             return PyInt_FromLong((long) value);
30389         } else if (sizeof(unsigned int) <= sizeof(unsigned long)) {
30390             return PyLong_FromUnsignedLong((unsigned long) value);
30391 #ifdef HAVE_LONG_LONG
30392         } else if (sizeof(unsigned int) <= sizeof(unsigned PY_LONG_LONG)) {
30393             return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value);
30394 #endif
30395         }
30396     } else {
30397         if (sizeof(unsigned int) <= sizeof(long)) {
30398             return PyInt_FromLong((long) value);
30399 #ifdef HAVE_LONG_LONG
30400         } else if (sizeof(unsigned int) <= sizeof(PY_LONG_LONG)) {
30401             return PyLong_FromLongLong((PY_LONG_LONG) value);
30402 #endif
30403         }
30404     }
30405     {
30406         int one = 1; int little = (int)*(unsigned char *)&one;
30407         unsigned char *bytes = (unsigned char *)&value;
30408         return _PyLong_FromByteArray(bytes, sizeof(unsigned int),
30409                                      little, !is_unsigned);
30410     }
30411 }
30412 
30413 /* CIntFromPy */
__Pyx_PyInt_As_long(PyObject * x)30414   static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *x) {
30415 #ifdef __Pyx_HAS_GCC_DIAGNOSTIC
30416 #pragma GCC diagnostic push
30417 #pragma GCC diagnostic ignored "-Wconversion"
30418 #endif
30419     const long neg_one = (long) -1, const_zero = (long) 0;
30420 #ifdef __Pyx_HAS_GCC_DIAGNOSTIC
30421 #pragma GCC diagnostic pop
30422 #endif
30423     const int is_unsigned = neg_one > const_zero;
30424 #if PY_MAJOR_VERSION < 3
30425     if (likely(PyInt_Check(x))) {
30426         if (sizeof(long) < sizeof(long)) {
30427             __PYX_VERIFY_RETURN_INT(long, long, PyInt_AS_LONG(x))
30428         } else {
30429             long val = PyInt_AS_LONG(x);
30430             if (is_unsigned && unlikely(val < 0)) {
30431                 goto raise_neg_overflow;
30432             }
30433             return (long) val;
30434         }
30435     } else
30436 #endif
30437     if (likely(PyLong_Check(x))) {
30438         if (is_unsigned) {
30439 #if CYTHON_USE_PYLONG_INTERNALS
30440             const digit* digits = ((PyLongObject*)x)->ob_digit;
30441             switch (Py_SIZE(x)) {
30442                 case  0: return (long) 0;
30443                 case  1: __PYX_VERIFY_RETURN_INT(long, digit, digits[0])
30444                 case 2:
30445                     if (8 * sizeof(long) > 1 * PyLong_SHIFT) {
30446                         if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
30447                             __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
30448                         } else if (8 * sizeof(long) >= 2 * PyLong_SHIFT) {
30449                             return (long) (((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0]));
30450                         }
30451                     }
30452                     break;
30453                 case 3:
30454                     if (8 * sizeof(long) > 2 * PyLong_SHIFT) {
30455                         if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
30456                             __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
30457                         } else if (8 * sizeof(long) >= 3 * PyLong_SHIFT) {
30458                             return (long) (((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]));
30459                         }
30460                     }
30461                     break;
30462                 case 4:
30463                     if (8 * sizeof(long) > 3 * PyLong_SHIFT) {
30464                         if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
30465                             __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])))
30466                         } else if (8 * sizeof(long) >= 4 * PyLong_SHIFT) {
30467                             return (long) (((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]));
30468                         }
30469                     }
30470                     break;
30471             }
30472 #endif
30473 #if CYTHON_COMPILING_IN_CPYTHON
30474             if (unlikely(Py_SIZE(x) < 0)) {
30475                 goto raise_neg_overflow;
30476             }
30477 #else
30478             {
30479                 int result = PyObject_RichCompareBool(x, Py_False, Py_LT);
30480                 if (unlikely(result < 0))
30481                     return (long) -1;
30482                 if (unlikely(result == 1))
30483                     goto raise_neg_overflow;
30484             }
30485 #endif
30486             if (sizeof(long) <= sizeof(unsigned long)) {
30487                 __PYX_VERIFY_RETURN_INT_EXC(long, unsigned long, PyLong_AsUnsignedLong(x))
30488 #ifdef HAVE_LONG_LONG
30489             } else if (sizeof(long) <= sizeof(unsigned PY_LONG_LONG)) {
30490                 __PYX_VERIFY_RETURN_INT_EXC(long, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x))
30491 #endif
30492             }
30493         } else {
30494 #if CYTHON_USE_PYLONG_INTERNALS
30495             const digit* digits = ((PyLongObject*)x)->ob_digit;
30496             switch (Py_SIZE(x)) {
30497                 case  0: return (long) 0;
30498                 case -1: __PYX_VERIFY_RETURN_INT(long, sdigit, (sdigit) (-(sdigit)digits[0]))
30499                 case  1: __PYX_VERIFY_RETURN_INT(long,  digit, +digits[0])
30500                 case -2:
30501                     if (8 * sizeof(long) - 1 > 1 * PyLong_SHIFT) {
30502                         if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
30503                             __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
30504                         } else if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
30505                             return (long) (((long)-1)*(((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
30506                         }
30507                     }
30508                     break;
30509                 case 2:
30510                     if (8 * sizeof(long) > 1 * PyLong_SHIFT) {
30511                         if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
30512                             __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
30513                         } else if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
30514                             return (long) ((((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
30515                         }
30516                     }
30517                     break;
30518                 case -3:
30519                     if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
30520                         if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
30521                             __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
30522                         } else if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
30523                             return (long) (((long)-1)*(((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
30524                         }
30525                     }
30526                     break;
30527                 case 3:
30528                     if (8 * sizeof(long) > 2 * PyLong_SHIFT) {
30529                         if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
30530                             __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
30531                         } else if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
30532                             return (long) ((((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
30533                         }
30534                     }
30535                     break;
30536                 case -4:
30537                     if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
30538                         if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
30539                             __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])))
30540                         } else if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) {
30541                             return (long) (((long)-1)*(((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
30542                         }
30543                     }
30544                     break;
30545                 case 4:
30546                     if (8 * sizeof(long) > 3 * PyLong_SHIFT) {
30547                         if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
30548                             __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])))
30549                         } else if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) {
30550                             return (long) ((((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
30551                         }
30552                     }
30553                     break;
30554             }
30555 #endif
30556             if (sizeof(long) <= sizeof(long)) {
30557                 __PYX_VERIFY_RETURN_INT_EXC(long, long, PyLong_AsLong(x))
30558 #ifdef HAVE_LONG_LONG
30559             } else if (sizeof(long) <= sizeof(PY_LONG_LONG)) {
30560                 __PYX_VERIFY_RETURN_INT_EXC(long, PY_LONG_LONG, PyLong_AsLongLong(x))
30561 #endif
30562             }
30563         }
30564         {
30565 #if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray)
30566             PyErr_SetString(PyExc_RuntimeError,
30567                             "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers");
30568 #else
30569             long val;
30570             PyObject *v = __Pyx_PyNumber_IntOrLong(x);
30571  #if PY_MAJOR_VERSION < 3
30572             if (likely(v) && !PyLong_Check(v)) {
30573                 PyObject *tmp = v;
30574                 v = PyNumber_Long(tmp);
30575                 Py_DECREF(tmp);
30576             }
30577  #endif
30578             if (likely(v)) {
30579                 int one = 1; int is_little = (int)*(unsigned char *)&one;
30580                 unsigned char *bytes = (unsigned char *)&val;
30581                 int ret = _PyLong_AsByteArray((PyLongObject *)v,
30582                                               bytes, sizeof(val),
30583                                               is_little, !is_unsigned);
30584                 Py_DECREF(v);
30585                 if (likely(!ret))
30586                     return val;
30587             }
30588 #endif
30589             return (long) -1;
30590         }
30591     } else {
30592         long val;
30593         PyObject *tmp = __Pyx_PyNumber_IntOrLong(x);
30594         if (!tmp) return (long) -1;
30595         val = __Pyx_PyInt_As_long(tmp);
30596         Py_DECREF(tmp);
30597         return val;
30598     }
30599 raise_overflow:
30600     PyErr_SetString(PyExc_OverflowError,
30601         "value too large to convert to long");
30602     return (long) -1;
30603 raise_neg_overflow:
30604     PyErr_SetString(PyExc_OverflowError,
30605         "can't convert negative value to long");
30606     return (long) -1;
30607 }
30608 
30609 /* CIntFromPy */
__Pyx_PyInt_As_char(PyObject * x)30610   static CYTHON_INLINE char __Pyx_PyInt_As_char(PyObject *x) {
30611 #ifdef __Pyx_HAS_GCC_DIAGNOSTIC
30612 #pragma GCC diagnostic push
30613 #pragma GCC diagnostic ignored "-Wconversion"
30614 #endif
30615     const char neg_one = (char) -1, const_zero = (char) 0;
30616 #ifdef __Pyx_HAS_GCC_DIAGNOSTIC
30617 #pragma GCC diagnostic pop
30618 #endif
30619     const int is_unsigned = neg_one > const_zero;
30620 #if PY_MAJOR_VERSION < 3
30621     if (likely(PyInt_Check(x))) {
30622         if (sizeof(char) < sizeof(long)) {
30623             __PYX_VERIFY_RETURN_INT(char, long, PyInt_AS_LONG(x))
30624         } else {
30625             long val = PyInt_AS_LONG(x);
30626             if (is_unsigned && unlikely(val < 0)) {
30627                 goto raise_neg_overflow;
30628             }
30629             return (char) val;
30630         }
30631     } else
30632 #endif
30633     if (likely(PyLong_Check(x))) {
30634         if (is_unsigned) {
30635 #if CYTHON_USE_PYLONG_INTERNALS
30636             const digit* digits = ((PyLongObject*)x)->ob_digit;
30637             switch (Py_SIZE(x)) {
30638                 case  0: return (char) 0;
30639                 case  1: __PYX_VERIFY_RETURN_INT(char, digit, digits[0])
30640                 case 2:
30641                     if (8 * sizeof(char) > 1 * PyLong_SHIFT) {
30642                         if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
30643                             __PYX_VERIFY_RETURN_INT(char, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
30644                         } else if (8 * sizeof(char) >= 2 * PyLong_SHIFT) {
30645                             return (char) (((((char)digits[1]) << PyLong_SHIFT) | (char)digits[0]));
30646                         }
30647                     }
30648                     break;
30649                 case 3:
30650                     if (8 * sizeof(char) > 2 * PyLong_SHIFT) {
30651                         if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
30652                             __PYX_VERIFY_RETURN_INT(char, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
30653                         } else if (8 * sizeof(char) >= 3 * PyLong_SHIFT) {
30654                             return (char) (((((((char)digits[2]) << PyLong_SHIFT) | (char)digits[1]) << PyLong_SHIFT) | (char)digits[0]));
30655                         }
30656                     }
30657                     break;
30658                 case 4:
30659                     if (8 * sizeof(char) > 3 * PyLong_SHIFT) {
30660                         if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
30661                             __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])))
30662                         } else if (8 * sizeof(char) >= 4 * PyLong_SHIFT) {
30663                             return (char) (((((((((char)digits[3]) << PyLong_SHIFT) | (char)digits[2]) << PyLong_SHIFT) | (char)digits[1]) << PyLong_SHIFT) | (char)digits[0]));
30664                         }
30665                     }
30666                     break;
30667             }
30668 #endif
30669 #if CYTHON_COMPILING_IN_CPYTHON
30670             if (unlikely(Py_SIZE(x) < 0)) {
30671                 goto raise_neg_overflow;
30672             }
30673 #else
30674             {
30675                 int result = PyObject_RichCompareBool(x, Py_False, Py_LT);
30676                 if (unlikely(result < 0))
30677                     return (char) -1;
30678                 if (unlikely(result == 1))
30679                     goto raise_neg_overflow;
30680             }
30681 #endif
30682             if (sizeof(char) <= sizeof(unsigned long)) {
30683                 __PYX_VERIFY_RETURN_INT_EXC(char, unsigned long, PyLong_AsUnsignedLong(x))
30684 #ifdef HAVE_LONG_LONG
30685             } else if (sizeof(char) <= sizeof(unsigned PY_LONG_LONG)) {
30686                 __PYX_VERIFY_RETURN_INT_EXC(char, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x))
30687 #endif
30688             }
30689         } else {
30690 #if CYTHON_USE_PYLONG_INTERNALS
30691             const digit* digits = ((PyLongObject*)x)->ob_digit;
30692             switch (Py_SIZE(x)) {
30693                 case  0: return (char) 0;
30694                 case -1: __PYX_VERIFY_RETURN_INT(char, sdigit, (sdigit) (-(sdigit)digits[0]))
30695                 case  1: __PYX_VERIFY_RETURN_INT(char,  digit, +digits[0])
30696                 case -2:
30697                     if (8 * sizeof(char) - 1 > 1 * PyLong_SHIFT) {
30698                         if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
30699                             __PYX_VERIFY_RETURN_INT(char, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
30700                         } else if (8 * sizeof(char) - 1 > 2 * PyLong_SHIFT) {
30701                             return (char) (((char)-1)*(((((char)digits[1]) << PyLong_SHIFT) | (char)digits[0])));
30702                         }
30703                     }
30704                     break;
30705                 case 2:
30706                     if (8 * sizeof(char) > 1 * PyLong_SHIFT) {
30707                         if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
30708                             __PYX_VERIFY_RETURN_INT(char, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
30709                         } else if (8 * sizeof(char) - 1 > 2 * PyLong_SHIFT) {
30710                             return (char) ((((((char)digits[1]) << PyLong_SHIFT) | (char)digits[0])));
30711                         }
30712                     }
30713                     break;
30714                 case -3:
30715                     if (8 * sizeof(char) - 1 > 2 * PyLong_SHIFT) {
30716                         if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
30717                             __PYX_VERIFY_RETURN_INT(char, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
30718                         } else if (8 * sizeof(char) - 1 > 3 * PyLong_SHIFT) {
30719                             return (char) (((char)-1)*(((((((char)digits[2]) << PyLong_SHIFT) | (char)digits[1]) << PyLong_SHIFT) | (char)digits[0])));
30720                         }
30721                     }
30722                     break;
30723                 case 3:
30724                     if (8 * sizeof(char) > 2 * PyLong_SHIFT) {
30725                         if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
30726                             __PYX_VERIFY_RETURN_INT(char, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
30727                         } else if (8 * sizeof(char) - 1 > 3 * PyLong_SHIFT) {
30728                             return (char) ((((((((char)digits[2]) << PyLong_SHIFT) | (char)digits[1]) << PyLong_SHIFT) | (char)digits[0])));
30729                         }
30730                     }
30731                     break;
30732                 case -4:
30733                     if (8 * sizeof(char) - 1 > 3 * PyLong_SHIFT) {
30734                         if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
30735                             __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])))
30736                         } else if (8 * sizeof(char) - 1 > 4 * PyLong_SHIFT) {
30737                             return (char) (((char)-1)*(((((((((char)digits[3]) << PyLong_SHIFT) | (char)digits[2]) << PyLong_SHIFT) | (char)digits[1]) << PyLong_SHIFT) | (char)digits[0])));
30738                         }
30739                     }
30740                     break;
30741                 case 4:
30742                     if (8 * sizeof(char) > 3 * PyLong_SHIFT) {
30743                         if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
30744                             __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])))
30745                         } else if (8 * sizeof(char) - 1 > 4 * PyLong_SHIFT) {
30746                             return (char) ((((((((((char)digits[3]) << PyLong_SHIFT) | (char)digits[2]) << PyLong_SHIFT) | (char)digits[1]) << PyLong_SHIFT) | (char)digits[0])));
30747                         }
30748                     }
30749                     break;
30750             }
30751 #endif
30752             if (sizeof(char) <= sizeof(long)) {
30753                 __PYX_VERIFY_RETURN_INT_EXC(char, long, PyLong_AsLong(x))
30754 #ifdef HAVE_LONG_LONG
30755             } else if (sizeof(char) <= sizeof(PY_LONG_LONG)) {
30756                 __PYX_VERIFY_RETURN_INT_EXC(char, PY_LONG_LONG, PyLong_AsLongLong(x))
30757 #endif
30758             }
30759         }
30760         {
30761 #if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray)
30762             PyErr_SetString(PyExc_RuntimeError,
30763                             "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers");
30764 #else
30765             char val;
30766             PyObject *v = __Pyx_PyNumber_IntOrLong(x);
30767  #if PY_MAJOR_VERSION < 3
30768             if (likely(v) && !PyLong_Check(v)) {
30769                 PyObject *tmp = v;
30770                 v = PyNumber_Long(tmp);
30771                 Py_DECREF(tmp);
30772             }
30773  #endif
30774             if (likely(v)) {
30775                 int one = 1; int is_little = (int)*(unsigned char *)&one;
30776                 unsigned char *bytes = (unsigned char *)&val;
30777                 int ret = _PyLong_AsByteArray((PyLongObject *)v,
30778                                               bytes, sizeof(val),
30779                                               is_little, !is_unsigned);
30780                 Py_DECREF(v);
30781                 if (likely(!ret))
30782                     return val;
30783             }
30784 #endif
30785             return (char) -1;
30786         }
30787     } else {
30788         char val;
30789         PyObject *tmp = __Pyx_PyNumber_IntOrLong(x);
30790         if (!tmp) return (char) -1;
30791         val = __Pyx_PyInt_As_char(tmp);
30792         Py_DECREF(tmp);
30793         return val;
30794     }
30795 raise_overflow:
30796     PyErr_SetString(PyExc_OverflowError,
30797         "value too large to convert to char");
30798     return (char) -1;
30799 raise_neg_overflow:
30800     PyErr_SetString(PyExc_OverflowError,
30801         "can't convert negative value to char");
30802     return (char) -1;
30803 }
30804 
30805 /* ObjectToMemviewSlice */
__Pyx_PyObject_to_MemoryviewSlice_dc___pyx_t_double_complex(PyObject * obj,int writable_flag)30806   static CYTHON_INLINE __Pyx_memviewslice __Pyx_PyObject_to_MemoryviewSlice_dc___pyx_t_double_complex(PyObject *obj, int writable_flag) {
30807     __Pyx_memviewslice result = { 0, 0, { 0 }, { 0 }, { 0 } };
30808     __Pyx_BufFmt_StackElem stack[1];
30809     int axes_specs[] = { (__Pyx_MEMVIEW_DIRECT | __Pyx_MEMVIEW_CONTIG) };
30810     int retcode;
30811     if (obj == Py_None) {
30812         result.memview = (struct __pyx_memoryview_obj *) Py_None;
30813         return result;
30814     }
30815     retcode = __Pyx_ValidateAndInit_memviewslice(axes_specs, __Pyx_IS_C_CONTIG,
30816                                                  (PyBUF_C_CONTIGUOUS | PyBUF_FORMAT) | writable_flag, 1,
30817                                                  &__Pyx_TypeInfo___pyx_t_double_complex, stack,
30818                                                  &result, obj);
30819     if (unlikely(retcode == -1))
30820         goto __pyx_fail;
30821     return result;
30822 __pyx_fail:
30823     result.memview = NULL;
30824     result.data = NULL;
30825     return result;
30826 }
30827 
30828 /* ObjectToMemviewSlice */
__Pyx_PyObject_to_MemoryviewSlice_dc_int(PyObject * obj,int writable_flag)30829   static CYTHON_INLINE __Pyx_memviewslice __Pyx_PyObject_to_MemoryviewSlice_dc_int(PyObject *obj, int writable_flag) {
30830     __Pyx_memviewslice result = { 0, 0, { 0 }, { 0 }, { 0 } };
30831     __Pyx_BufFmt_StackElem stack[1];
30832     int axes_specs[] = { (__Pyx_MEMVIEW_DIRECT | __Pyx_MEMVIEW_CONTIG) };
30833     int retcode;
30834     if (obj == Py_None) {
30835         result.memview = (struct __pyx_memoryview_obj *) Py_None;
30836         return result;
30837     }
30838     retcode = __Pyx_ValidateAndInit_memviewslice(axes_specs, __Pyx_IS_C_CONTIG,
30839                                                  (PyBUF_C_CONTIGUOUS | PyBUF_FORMAT) | writable_flag, 1,
30840                                                  &__Pyx_TypeInfo_int, stack,
30841                                                  &result, obj);
30842     if (unlikely(retcode == -1))
30843         goto __pyx_fail;
30844     return result;
30845 __pyx_fail:
30846     result.memview = NULL;
30847     result.data = NULL;
30848     return result;
30849 }
30850 
30851 /* ObjectToMemviewSlice */
__Pyx_PyObject_to_MemoryviewSlice_dc_double(PyObject * obj,int writable_flag)30852   static CYTHON_INLINE __Pyx_memviewslice __Pyx_PyObject_to_MemoryviewSlice_dc_double(PyObject *obj, int writable_flag) {
30853     __Pyx_memviewslice result = { 0, 0, { 0 }, { 0 }, { 0 } };
30854     __Pyx_BufFmt_StackElem stack[1];
30855     int axes_specs[] = { (__Pyx_MEMVIEW_DIRECT | __Pyx_MEMVIEW_CONTIG) };
30856     int retcode;
30857     if (obj == Py_None) {
30858         result.memview = (struct __pyx_memoryview_obj *) Py_None;
30859         return result;
30860     }
30861     retcode = __Pyx_ValidateAndInit_memviewslice(axes_specs, __Pyx_IS_C_CONTIG,
30862                                                  (PyBUF_C_CONTIGUOUS | PyBUF_FORMAT) | writable_flag, 1,
30863                                                  &__Pyx_TypeInfo_double, stack,
30864                                                  &result, obj);
30865     if (unlikely(retcode == -1))
30866         goto __pyx_fail;
30867     return result;
30868 __pyx_fail:
30869     result.memview = NULL;
30870     result.data = NULL;
30871     return result;
30872 }
30873 
30874 /* CheckBinaryVersion */
__Pyx_check_binary_version(void)30875   static int __Pyx_check_binary_version(void) {
30876     char ctversion[4], rtversion[4];
30877     PyOS_snprintf(ctversion, 4, "%d.%d", PY_MAJOR_VERSION, PY_MINOR_VERSION);
30878     PyOS_snprintf(rtversion, 4, "%s", Py_GetVersion());
30879     if (ctversion[0] != rtversion[0] || ctversion[2] != rtversion[2]) {
30880         char message[200];
30881         PyOS_snprintf(message, sizeof(message),
30882                       "compiletime version %s of module '%.100s' "
30883                       "does not match runtime version %s",
30884                       ctversion, __Pyx_MODULE_NAME, rtversion);
30885         return PyErr_WarnEx(NULL, message, 1);
30886     }
30887     return 0;
30888 }
30889 
30890 /* FunctionImport */
30891   #ifndef __PYX_HAVE_RT_ImportFunction
30892 #define __PYX_HAVE_RT_ImportFunction
__Pyx_ImportFunction(PyObject * module,const char * funcname,void (** f)(void),const char * sig)30893 static int __Pyx_ImportFunction(PyObject *module, const char *funcname, void (**f)(void), const char *sig) {
30894     PyObject *d = 0;
30895     PyObject *cobj = 0;
30896     union {
30897         void (*fp)(void);
30898         void *p;
30899     } tmp;
30900     d = PyObject_GetAttrString(module, (char *)"__pyx_capi__");
30901     if (!d)
30902         goto bad;
30903     cobj = PyDict_GetItemString(d, funcname);
30904     if (!cobj) {
30905         PyErr_Format(PyExc_ImportError,
30906             "%.200s does not export expected C function %.200s",
30907                 PyModule_GetName(module), funcname);
30908         goto bad;
30909     }
30910 #if PY_VERSION_HEX >= 0x02070000
30911     if (!PyCapsule_IsValid(cobj, sig)) {
30912         PyErr_Format(PyExc_TypeError,
30913             "C function %.200s.%.200s has wrong signature (expected %.500s, got %.500s)",
30914              PyModule_GetName(module), funcname, sig, PyCapsule_GetName(cobj));
30915         goto bad;
30916     }
30917     tmp.p = PyCapsule_GetPointer(cobj, sig);
30918 #else
30919     {const char *desc, *s1, *s2;
30920     desc = (const char *)PyCObject_GetDesc(cobj);
30921     if (!desc)
30922         goto bad;
30923     s1 = desc; s2 = sig;
30924     while (*s1 != '\0' && *s1 == *s2) { s1++; s2++; }
30925     if (*s1 != *s2) {
30926         PyErr_Format(PyExc_TypeError,
30927             "C function %.200s.%.200s has wrong signature (expected %.500s, got %.500s)",
30928              PyModule_GetName(module), funcname, sig, desc);
30929         goto bad;
30930     }
30931     tmp.p = PyCObject_AsVoidPtr(cobj);}
30932 #endif
30933     *f = tmp.fp;
30934     if (!(*f))
30935         goto bad;
30936     Py_DECREF(d);
30937     return 0;
30938 bad:
30939     Py_XDECREF(d);
30940     return -1;
30941 }
30942 #endif
30943 
30944 /* InitStrings */
__Pyx_InitStrings(__Pyx_StringTabEntry * t)30945   static int __Pyx_InitStrings(__Pyx_StringTabEntry *t) {
30946     while (t->p) {
30947         #if PY_MAJOR_VERSION < 3
30948         if (t->is_unicode) {
30949             *t->p = PyUnicode_DecodeUTF8(t->s, t->n - 1, NULL);
30950         } else if (t->intern) {
30951             *t->p = PyString_InternFromString(t->s);
30952         } else {
30953             *t->p = PyString_FromStringAndSize(t->s, t->n - 1);
30954         }
30955         #else
30956         if (t->is_unicode | t->is_str) {
30957             if (t->intern) {
30958                 *t->p = PyUnicode_InternFromString(t->s);
30959             } else if (t->encoding) {
30960                 *t->p = PyUnicode_Decode(t->s, t->n - 1, t->encoding, NULL);
30961             } else {
30962                 *t->p = PyUnicode_FromStringAndSize(t->s, t->n - 1);
30963             }
30964         } else {
30965             *t->p = PyBytes_FromStringAndSize(t->s, t->n - 1);
30966         }
30967         #endif
30968         if (!*t->p)
30969             return -1;
30970         if (PyObject_Hash(*t->p) == -1)
30971             return -1;
30972         ++t;
30973     }
30974     return 0;
30975 }
30976 
__Pyx_PyUnicode_FromString(const char * c_str)30977 static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(const char* c_str) {
30978     return __Pyx_PyUnicode_FromStringAndSize(c_str, (Py_ssize_t)strlen(c_str));
30979 }
__Pyx_PyObject_AsString(PyObject * o)30980 static CYTHON_INLINE const char* __Pyx_PyObject_AsString(PyObject* o) {
30981     Py_ssize_t ignore;
30982     return __Pyx_PyObject_AsStringAndSize(o, &ignore);
30983 }
30984 #if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT
30985 #if !CYTHON_PEP393_ENABLED
__Pyx_PyUnicode_AsStringAndSize(PyObject * o,Py_ssize_t * length)30986 static const char* __Pyx_PyUnicode_AsStringAndSize(PyObject* o, Py_ssize_t *length) {
30987     char* defenc_c;
30988     PyObject* defenc = _PyUnicode_AsDefaultEncodedString(o, NULL);
30989     if (!defenc) return NULL;
30990     defenc_c = PyBytes_AS_STRING(defenc);
30991 #if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
30992     {
30993         char* end = defenc_c + PyBytes_GET_SIZE(defenc);
30994         char* c;
30995         for (c = defenc_c; c < end; c++) {
30996             if ((unsigned char) (*c) >= 128) {
30997                 PyUnicode_AsASCIIString(o);
30998                 return NULL;
30999             }
31000         }
31001     }
31002 #endif
31003     *length = PyBytes_GET_SIZE(defenc);
31004     return defenc_c;
31005 }
31006 #else
__Pyx_PyUnicode_AsStringAndSize(PyObject * o,Py_ssize_t * length)31007 static CYTHON_INLINE const char* __Pyx_PyUnicode_AsStringAndSize(PyObject* o, Py_ssize_t *length) {
31008     if (unlikely(__Pyx_PyUnicode_READY(o) == -1)) return NULL;
31009 #if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
31010     if (likely(PyUnicode_IS_ASCII(o))) {
31011         *length = PyUnicode_GET_LENGTH(o);
31012         return PyUnicode_AsUTF8(o);
31013     } else {
31014         PyUnicode_AsASCIIString(o);
31015         return NULL;
31016     }
31017 #else
31018     return PyUnicode_AsUTF8AndSize(o, length);
31019 #endif
31020 }
31021 #endif
31022 #endif
__Pyx_PyObject_AsStringAndSize(PyObject * o,Py_ssize_t * length)31023 static CYTHON_INLINE const char* __Pyx_PyObject_AsStringAndSize(PyObject* o, Py_ssize_t *length) {
31024 #if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT
31025     if (
31026 #if PY_MAJOR_VERSION < 3 && __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
31027             __Pyx_sys_getdefaultencoding_not_ascii &&
31028 #endif
31029             PyUnicode_Check(o)) {
31030         return __Pyx_PyUnicode_AsStringAndSize(o, length);
31031     } else
31032 #endif
31033 #if (!CYTHON_COMPILING_IN_PYPY) || (defined(PyByteArray_AS_STRING) && defined(PyByteArray_GET_SIZE))
31034     if (PyByteArray_Check(o)) {
31035         *length = PyByteArray_GET_SIZE(o);
31036         return PyByteArray_AS_STRING(o);
31037     } else
31038 #endif
31039     {
31040         char* result;
31041         int r = PyBytes_AsStringAndSize(o, &result, length);
31042         if (unlikely(r < 0)) {
31043             return NULL;
31044         } else {
31045             return result;
31046         }
31047     }
31048 }
__Pyx_PyObject_IsTrue(PyObject * x)31049 static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject* x) {
31050    int is_true = x == Py_True;
31051    if (is_true | (x == Py_False) | (x == Py_None)) return is_true;
31052    else return PyObject_IsTrue(x);
31053 }
__Pyx_PyObject_IsTrueAndDecref(PyObject * x)31054 static CYTHON_INLINE int __Pyx_PyObject_IsTrueAndDecref(PyObject* x) {
31055     int retval;
31056     if (unlikely(!x)) return -1;
31057     retval = __Pyx_PyObject_IsTrue(x);
31058     Py_DECREF(x);
31059     return retval;
31060 }
__Pyx_PyNumber_IntOrLongWrongResultType(PyObject * result,const char * type_name)31061 static PyObject* __Pyx_PyNumber_IntOrLongWrongResultType(PyObject* result, const char* type_name) {
31062 #if PY_MAJOR_VERSION >= 3
31063     if (PyLong_Check(result)) {
31064         if (PyErr_WarnFormat(PyExc_DeprecationWarning, 1,
31065                 "__int__ returned non-int (type %.200s).  "
31066                 "The ability to return an instance of a strict subclass of int "
31067                 "is deprecated, and may be removed in a future version of Python.",
31068                 Py_TYPE(result)->tp_name)) {
31069             Py_DECREF(result);
31070             return NULL;
31071         }
31072         return result;
31073     }
31074 #endif
31075     PyErr_Format(PyExc_TypeError,
31076                  "__%.4s__ returned non-%.4s (type %.200s)",
31077                  type_name, type_name, Py_TYPE(result)->tp_name);
31078     Py_DECREF(result);
31079     return NULL;
31080 }
__Pyx_PyNumber_IntOrLong(PyObject * x)31081 static CYTHON_INLINE PyObject* __Pyx_PyNumber_IntOrLong(PyObject* x) {
31082 #if CYTHON_USE_TYPE_SLOTS
31083   PyNumberMethods *m;
31084 #endif
31085   const char *name = NULL;
31086   PyObject *res = NULL;
31087 #if PY_MAJOR_VERSION < 3
31088   if (likely(PyInt_Check(x) || PyLong_Check(x)))
31089 #else
31090   if (likely(PyLong_Check(x)))
31091 #endif
31092     return __Pyx_NewRef(x);
31093 #if CYTHON_USE_TYPE_SLOTS
31094   m = Py_TYPE(x)->tp_as_number;
31095   #if PY_MAJOR_VERSION < 3
31096   if (m && m->nb_int) {
31097     name = "int";
31098     res = m->nb_int(x);
31099   }
31100   else if (m && m->nb_long) {
31101     name = "long";
31102     res = m->nb_long(x);
31103   }
31104   #else
31105   if (likely(m && m->nb_int)) {
31106     name = "int";
31107     res = m->nb_int(x);
31108   }
31109   #endif
31110 #else
31111   if (!PyBytes_CheckExact(x) && !PyUnicode_CheckExact(x)) {
31112     res = PyNumber_Int(x);
31113   }
31114 #endif
31115   if (likely(res)) {
31116 #if PY_MAJOR_VERSION < 3
31117     if (unlikely(!PyInt_Check(res) && !PyLong_Check(res))) {
31118 #else
31119     if (unlikely(!PyLong_CheckExact(res))) {
31120 #endif
31121         return __Pyx_PyNumber_IntOrLongWrongResultType(res, name);
31122     }
31123   }
31124   else if (!PyErr_Occurred()) {
31125     PyErr_SetString(PyExc_TypeError,
31126                     "an integer is required");
31127   }
31128   return res;
31129 }
31130 static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject* b) {
31131   Py_ssize_t ival;
31132   PyObject *x;
31133 #if PY_MAJOR_VERSION < 3
31134   if (likely(PyInt_CheckExact(b))) {
31135     if (sizeof(Py_ssize_t) >= sizeof(long))
31136         return PyInt_AS_LONG(b);
31137     else
31138         return PyInt_AsSsize_t(b);
31139   }
31140 #endif
31141   if (likely(PyLong_CheckExact(b))) {
31142     #if CYTHON_USE_PYLONG_INTERNALS
31143     const digit* digits = ((PyLongObject*)b)->ob_digit;
31144     const Py_ssize_t size = Py_SIZE(b);
31145     if (likely(__Pyx_sst_abs(size) <= 1)) {
31146         ival = likely(size) ? digits[0] : 0;
31147         if (size == -1) ival = -ival;
31148         return ival;
31149     } else {
31150       switch (size) {
31151          case 2:
31152            if (8 * sizeof(Py_ssize_t) > 2 * PyLong_SHIFT) {
31153              return (Py_ssize_t) (((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
31154            }
31155            break;
31156          case -2:
31157            if (8 * sizeof(Py_ssize_t) > 2 * PyLong_SHIFT) {
31158              return -(Py_ssize_t) (((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
31159            }
31160            break;
31161          case 3:
31162            if (8 * sizeof(Py_ssize_t) > 3 * PyLong_SHIFT) {
31163              return (Py_ssize_t) (((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
31164            }
31165            break;
31166          case -3:
31167            if (8 * sizeof(Py_ssize_t) > 3 * PyLong_SHIFT) {
31168              return -(Py_ssize_t) (((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
31169            }
31170            break;
31171          case 4:
31172            if (8 * sizeof(Py_ssize_t) > 4 * PyLong_SHIFT) {
31173              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]));
31174            }
31175            break;
31176          case -4:
31177            if (8 * sizeof(Py_ssize_t) > 4 * PyLong_SHIFT) {
31178              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]));
31179            }
31180            break;
31181       }
31182     }
31183     #endif
31184     return PyLong_AsSsize_t(b);
31185   }
31186   x = PyNumber_Index(b);
31187   if (!x) return -1;
31188   ival = PyInt_AsSsize_t(x);
31189   Py_DECREF(x);
31190   return ival;
31191 }
31192 static CYTHON_INLINE PyObject * __Pyx_PyBool_FromLong(long b) {
31193   return b ? __Pyx_NewRef(Py_True) : __Pyx_NewRef(Py_False);
31194 }
31195 static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t ival) {
31196     return PyInt_FromSize_t(ival);
31197 }
31198 
31199 
31200 #endif /* Py_PYTHON_H */
31201