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.ptrace",
20         "sources": [
21             "qutip/cy/ptrace.pyx"
22         ]
23     },
24     "module_name": "qutip.cy.ptrace"
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__ptrace
647 #define __PYX_HAVE_API__qutip__cy__ptrace
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 "pythread.h"
658 #include <stdlib.h>
659 #include "pystate.h"
660 #ifdef _OPENMP
661 #include <omp.h>
662 #endif /* _OPENMP */
663 
664 #if defined(PYREX_WITHOUT_ASSERTIONS) && !defined(CYTHON_WITHOUT_ASSERTIONS)
665 #define CYTHON_WITHOUT_ASSERTIONS
666 #endif
667 
668 typedef struct {PyObject **p; const char *s; const Py_ssize_t n; const char* encoding;
669                 const char is_unicode; const char is_str; const char intern; } __Pyx_StringTabEntry;
670 
671 #define __PYX_DEFAULT_STRING_ENCODING_IS_ASCII 0
672 #define __PYX_DEFAULT_STRING_ENCODING_IS_UTF8 0
673 #define __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT (PY_MAJOR_VERSION >= 3 && __PYX_DEFAULT_STRING_ENCODING_IS_UTF8)
674 #define __PYX_DEFAULT_STRING_ENCODING ""
675 #define __Pyx_PyObject_FromString __Pyx_PyBytes_FromString
676 #define __Pyx_PyObject_FromStringAndSize __Pyx_PyBytes_FromStringAndSize
677 #define __Pyx_uchar_cast(c) ((unsigned char)c)
678 #define __Pyx_long_cast(x) ((long)x)
679 #define __Pyx_fits_Py_ssize_t(v, type, is_signed)  (\
680     (sizeof(type) < sizeof(Py_ssize_t))  ||\
681     (sizeof(type) > sizeof(Py_ssize_t) &&\
682           likely(v < (type)PY_SSIZE_T_MAX ||\
683                  v == (type)PY_SSIZE_T_MAX)  &&\
684           (!is_signed || likely(v > (type)PY_SSIZE_T_MIN ||\
685                                 v == (type)PY_SSIZE_T_MIN)))  ||\
686     (sizeof(type) == sizeof(Py_ssize_t) &&\
687           (is_signed || likely(v < (type)PY_SSIZE_T_MAX ||\
688                                v == (type)PY_SSIZE_T_MAX)))  )
__Pyx_is_valid_index(Py_ssize_t i,Py_ssize_t limit)689 static CYTHON_INLINE int __Pyx_is_valid_index(Py_ssize_t i, Py_ssize_t limit) {
690     return (size_t) i < (size_t) limit;
691 }
692 #if defined (__cplusplus) && __cplusplus >= 201103L
693     #include <cstdlib>
694     #define __Pyx_sst_abs(value) std::abs(value)
695 #elif SIZEOF_INT >= SIZEOF_SIZE_T
696     #define __Pyx_sst_abs(value) abs(value)
697 #elif SIZEOF_LONG >= SIZEOF_SIZE_T
698     #define __Pyx_sst_abs(value) labs(value)
699 #elif defined (_MSC_VER)
700     #define __Pyx_sst_abs(value) ((Py_ssize_t)_abs64(value))
701 #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
702     #define __Pyx_sst_abs(value) llabs(value)
703 #elif defined (__GNUC__)
704     #define __Pyx_sst_abs(value) __builtin_llabs(value)
705 #else
706     #define __Pyx_sst_abs(value) ((value<0) ? -value : value)
707 #endif
708 static CYTHON_INLINE const char* __Pyx_PyObject_AsString(PyObject*);
709 static CYTHON_INLINE const char* __Pyx_PyObject_AsStringAndSize(PyObject*, Py_ssize_t* length);
710 #define __Pyx_PyByteArray_FromString(s) PyByteArray_FromStringAndSize((const char*)s, strlen((const char*)s))
711 #define __Pyx_PyByteArray_FromStringAndSize(s, l) PyByteArray_FromStringAndSize((const char*)s, l)
712 #define __Pyx_PyBytes_FromString        PyBytes_FromString
713 #define __Pyx_PyBytes_FromStringAndSize PyBytes_FromStringAndSize
714 static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(const char*);
715 #if PY_MAJOR_VERSION < 3
716     #define __Pyx_PyStr_FromString        __Pyx_PyBytes_FromString
717     #define __Pyx_PyStr_FromStringAndSize __Pyx_PyBytes_FromStringAndSize
718 #else
719     #define __Pyx_PyStr_FromString        __Pyx_PyUnicode_FromString
720     #define __Pyx_PyStr_FromStringAndSize __Pyx_PyUnicode_FromStringAndSize
721 #endif
722 #define __Pyx_PyBytes_AsWritableString(s)     ((char*) PyBytes_AS_STRING(s))
723 #define __Pyx_PyBytes_AsWritableSString(s)    ((signed char*) PyBytes_AS_STRING(s))
724 #define __Pyx_PyBytes_AsWritableUString(s)    ((unsigned char*) PyBytes_AS_STRING(s))
725 #define __Pyx_PyBytes_AsString(s)     ((const char*) PyBytes_AS_STRING(s))
726 #define __Pyx_PyBytes_AsSString(s)    ((const signed char*) PyBytes_AS_STRING(s))
727 #define __Pyx_PyBytes_AsUString(s)    ((const unsigned char*) PyBytes_AS_STRING(s))
728 #define __Pyx_PyObject_AsWritableString(s)    ((char*) __Pyx_PyObject_AsString(s))
729 #define __Pyx_PyObject_AsWritableSString(s)    ((signed char*) __Pyx_PyObject_AsString(s))
730 #define __Pyx_PyObject_AsWritableUString(s)    ((unsigned char*) __Pyx_PyObject_AsString(s))
731 #define __Pyx_PyObject_AsSString(s)    ((const signed char*) __Pyx_PyObject_AsString(s))
732 #define __Pyx_PyObject_AsUString(s)    ((const unsigned char*) __Pyx_PyObject_AsString(s))
733 #define __Pyx_PyObject_FromCString(s)  __Pyx_PyObject_FromString((const char*)s)
734 #define __Pyx_PyBytes_FromCString(s)   __Pyx_PyBytes_FromString((const char*)s)
735 #define __Pyx_PyByteArray_FromCString(s)   __Pyx_PyByteArray_FromString((const char*)s)
736 #define __Pyx_PyStr_FromCString(s)     __Pyx_PyStr_FromString((const char*)s)
737 #define __Pyx_PyUnicode_FromCString(s) __Pyx_PyUnicode_FromString((const char*)s)
__Pyx_Py_UNICODE_strlen(const Py_UNICODE * u)738 static CYTHON_INLINE size_t __Pyx_Py_UNICODE_strlen(const Py_UNICODE *u) {
739     const Py_UNICODE *u_end = u;
740     while (*u_end++) ;
741     return (size_t)(u_end - u - 1);
742 }
743 #define __Pyx_PyUnicode_FromUnicode(u)       PyUnicode_FromUnicode(u, __Pyx_Py_UNICODE_strlen(u))
744 #define __Pyx_PyUnicode_FromUnicodeAndLength PyUnicode_FromUnicode
745 #define __Pyx_PyUnicode_AsUnicode            PyUnicode_AsUnicode
746 #define __Pyx_NewRef(obj) (Py_INCREF(obj), obj)
747 #define __Pyx_Owned_Py_None(b) __Pyx_NewRef(Py_None)
748 static CYTHON_INLINE PyObject * __Pyx_PyBool_FromLong(long b);
749 static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject*);
750 static CYTHON_INLINE int __Pyx_PyObject_IsTrueAndDecref(PyObject*);
751 static CYTHON_INLINE PyObject* __Pyx_PyNumber_IntOrLong(PyObject* x);
752 #define __Pyx_PySequence_Tuple(obj)\
753     (likely(PyTuple_CheckExact(obj)) ? __Pyx_NewRef(obj) : PySequence_Tuple(obj))
754 static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject*);
755 static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t);
756 #if CYTHON_ASSUME_SAFE_MACROS
757 #define __pyx_PyFloat_AsDouble(x) (PyFloat_CheckExact(x) ? PyFloat_AS_DOUBLE(x) : PyFloat_AsDouble(x))
758 #else
759 #define __pyx_PyFloat_AsDouble(x) PyFloat_AsDouble(x)
760 #endif
761 #define __pyx_PyFloat_AsFloat(x) ((float) __pyx_PyFloat_AsDouble(x))
762 #if PY_MAJOR_VERSION >= 3
763 #define __Pyx_PyNumber_Int(x) (PyLong_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Long(x))
764 #else
765 #define __Pyx_PyNumber_Int(x) (PyInt_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Int(x))
766 #endif
767 #define __Pyx_PyNumber_Float(x) (PyFloat_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Float(x))
768 #if PY_MAJOR_VERSION < 3 && __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
769 static int __Pyx_sys_getdefaultencoding_not_ascii;
__Pyx_init_sys_getdefaultencoding_params(void)770 static int __Pyx_init_sys_getdefaultencoding_params(void) {
771     PyObject* sys;
772     PyObject* default_encoding = NULL;
773     PyObject* ascii_chars_u = NULL;
774     PyObject* ascii_chars_b = NULL;
775     const char* default_encoding_c;
776     sys = PyImport_ImportModule("sys");
777     if (!sys) goto bad;
778     default_encoding = PyObject_CallMethod(sys, (char*) "getdefaultencoding", NULL);
779     Py_DECREF(sys);
780     if (!default_encoding) goto bad;
781     default_encoding_c = PyBytes_AsString(default_encoding);
782     if (!default_encoding_c) goto bad;
783     if (strcmp(default_encoding_c, "ascii") == 0) {
784         __Pyx_sys_getdefaultencoding_not_ascii = 0;
785     } else {
786         char ascii_chars[128];
787         int c;
788         for (c = 0; c < 128; c++) {
789             ascii_chars[c] = c;
790         }
791         __Pyx_sys_getdefaultencoding_not_ascii = 1;
792         ascii_chars_u = PyUnicode_DecodeASCII(ascii_chars, 128, NULL);
793         if (!ascii_chars_u) goto bad;
794         ascii_chars_b = PyUnicode_AsEncodedString(ascii_chars_u, default_encoding_c, NULL);
795         if (!ascii_chars_b || !PyBytes_Check(ascii_chars_b) || memcmp(ascii_chars, PyBytes_AS_STRING(ascii_chars_b), 128) != 0) {
796             PyErr_Format(
797                 PyExc_ValueError,
798                 "This module compiled with c_string_encoding=ascii, but default encoding '%.200s' is not a superset of ascii.",
799                 default_encoding_c);
800             goto bad;
801         }
802         Py_DECREF(ascii_chars_u);
803         Py_DECREF(ascii_chars_b);
804     }
805     Py_DECREF(default_encoding);
806     return 0;
807 bad:
808     Py_XDECREF(default_encoding);
809     Py_XDECREF(ascii_chars_u);
810     Py_XDECREF(ascii_chars_b);
811     return -1;
812 }
813 #endif
814 #if __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT && PY_MAJOR_VERSION >= 3
815 #define __Pyx_PyUnicode_FromStringAndSize(c_str, size) PyUnicode_DecodeUTF8(c_str, size, NULL)
816 #else
817 #define __Pyx_PyUnicode_FromStringAndSize(c_str, size) PyUnicode_Decode(c_str, size, __PYX_DEFAULT_STRING_ENCODING, NULL)
818 #if __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT
819 static char* __PYX_DEFAULT_STRING_ENCODING;
__Pyx_init_sys_getdefaultencoding_params(void)820 static int __Pyx_init_sys_getdefaultencoding_params(void) {
821     PyObject* sys;
822     PyObject* default_encoding = NULL;
823     char* default_encoding_c;
824     sys = PyImport_ImportModule("sys");
825     if (!sys) goto bad;
826     default_encoding = PyObject_CallMethod(sys, (char*) (const char*) "getdefaultencoding", NULL);
827     Py_DECREF(sys);
828     if (!default_encoding) goto bad;
829     default_encoding_c = PyBytes_AsString(default_encoding);
830     if (!default_encoding_c) goto bad;
831     __PYX_DEFAULT_STRING_ENCODING = (char*) malloc(strlen(default_encoding_c) + 1);
832     if (!__PYX_DEFAULT_STRING_ENCODING) goto bad;
833     strcpy(__PYX_DEFAULT_STRING_ENCODING, default_encoding_c);
834     Py_DECREF(default_encoding);
835     return 0;
836 bad:
837     Py_XDECREF(default_encoding);
838     return -1;
839 }
840 #endif
841 #endif
842 
843 
844 /* Test for GCC > 2.95 */
845 #if defined(__GNUC__)     && (__GNUC__ > 2 || (__GNUC__ == 2 && (__GNUC_MINOR__ > 95)))
846   #define likely(x)   __builtin_expect(!!(x), 1)
847   #define unlikely(x) __builtin_expect(!!(x), 0)
848 #else /* !__GNUC__ or GCC < 2.95 */
849   #define likely(x)   (x)
850   #define unlikely(x) (x)
851 #endif /* __GNUC__ */
__Pyx_pretend_to_initialize(void * ptr)852 static CYTHON_INLINE void __Pyx_pretend_to_initialize(void* ptr) { (void)ptr; }
853 
854 static PyObject *__pyx_m = NULL;
855 static PyObject *__pyx_d;
856 static PyObject *__pyx_b;
857 static PyObject *__pyx_cython_runtime = NULL;
858 static PyObject *__pyx_empty_tuple;
859 static PyObject *__pyx_empty_bytes;
860 static PyObject *__pyx_empty_unicode;
861 static int __pyx_lineno;
862 static int __pyx_clineno = 0;
863 static const char * __pyx_cfilenm= __FILE__;
864 static const char *__pyx_filename;
865 
866 /* Header.proto */
867 #if !defined(CYTHON_CCOMPLEX)
868   #if defined(__cplusplus)
869     #define CYTHON_CCOMPLEX 1
870   #elif defined(_Complex_I)
871     #define CYTHON_CCOMPLEX 1
872   #else
873     #define CYTHON_CCOMPLEX 0
874   #endif
875 #endif
876 #if CYTHON_CCOMPLEX
877   #ifdef __cplusplus
878     #include <complex>
879   #else
880     #include <complex.h>
881   #endif
882 #endif
883 #if CYTHON_CCOMPLEX && !defined(__cplusplus) && defined(__sun__) && defined(__GNUC__)
884   #undef _Complex_I
885   #define _Complex_I 1.0fj
886 #endif
887 
888 
889 static const char *__pyx_f[] = {
890   "qutip/cy/ptrace.pyx",
891   "__init__.pxd",
892   "stringsource",
893   "type.pxd",
894 };
895 /* BufferFormatStructs.proto */
896 #define IS_UNSIGNED(type) (((type) -1) > 0)
897 struct __Pyx_StructField_;
898 #define __PYX_BUF_FLAGS_PACKED_STRUCT (1 << 0)
899 typedef struct {
900   const char* name;
901   struct __Pyx_StructField_* fields;
902   size_t size;
903   size_t arraysize[8];
904   int ndim;
905   char typegroup;
906   char is_unsigned;
907   int flags;
908 } __Pyx_TypeInfo;
909 typedef struct __Pyx_StructField_ {
910   __Pyx_TypeInfo* type;
911   const char* name;
912   size_t offset;
913 } __Pyx_StructField;
914 typedef struct {
915   __Pyx_StructField* field;
916   size_t parent_offset;
917 } __Pyx_BufFmt_StackElem;
918 typedef struct {
919   __Pyx_StructField root;
920   __Pyx_BufFmt_StackElem* head;
921   size_t fmt_offset;
922   size_t new_count, enc_count;
923   size_t struct_alignment;
924   int is_complex;
925   char enc_type;
926   char new_packmode;
927   char enc_packmode;
928   char is_valid_array;
929 } __Pyx_BufFmt_Context;
930 
931 /* MemviewSliceStruct.proto */
932 struct __pyx_memoryview_obj;
933 typedef struct {
934   struct __pyx_memoryview_obj *memview;
935   char *data;
936   Py_ssize_t shape[8];
937   Py_ssize_t strides[8];
938   Py_ssize_t suboffsets[8];
939 } __Pyx_memviewslice;
940 #define __Pyx_MemoryView_Len(m)  (m.shape[0])
941 
942 /* Atomics.proto */
943 #include <pythread.h>
944 #ifndef CYTHON_ATOMICS
945     #define CYTHON_ATOMICS 1
946 #endif
947 #define __pyx_atomic_int_type int
948 #if CYTHON_ATOMICS && __GNUC__ >= 4 && (__GNUC_MINOR__ > 1 ||\
949                     (__GNUC_MINOR__ == 1 && __GNUC_PATCHLEVEL >= 2)) &&\
950                     !defined(__i386__)
951     #define __pyx_atomic_incr_aligned(value, lock) __sync_fetch_and_add(value, 1)
952     #define __pyx_atomic_decr_aligned(value, lock) __sync_fetch_and_sub(value, 1)
953     #ifdef __PYX_DEBUG_ATOMICS
954         #warning "Using GNU atomics"
955     #endif
956 #elif CYTHON_ATOMICS && defined(_MSC_VER) && 0
957     #include <Windows.h>
958     #undef __pyx_atomic_int_type
959     #define __pyx_atomic_int_type LONG
960     #define __pyx_atomic_incr_aligned(value, lock) InterlockedIncrement(value)
961     #define __pyx_atomic_decr_aligned(value, lock) InterlockedDecrement(value)
962     #ifdef __PYX_DEBUG_ATOMICS
963         #pragma message ("Using MSVC atomics")
964     #endif
965 #elif CYTHON_ATOMICS && (defined(__ICC) || defined(__INTEL_COMPILER)) && 0
966     #define __pyx_atomic_incr_aligned(value, lock) _InterlockedIncrement(value)
967     #define __pyx_atomic_decr_aligned(value, lock) _InterlockedDecrement(value)
968     #ifdef __PYX_DEBUG_ATOMICS
969         #warning "Using Intel atomics"
970     #endif
971 #else
972     #undef CYTHON_ATOMICS
973     #define CYTHON_ATOMICS 0
974     #ifdef __PYX_DEBUG_ATOMICS
975         #warning "Not using atomics"
976     #endif
977 #endif
978 typedef volatile __pyx_atomic_int_type __pyx_atomic_int;
979 #if CYTHON_ATOMICS
980     #define __pyx_add_acquisition_count(memview)\
981              __pyx_atomic_incr_aligned(__pyx_get_slice_count_pointer(memview), memview->lock)
982     #define __pyx_sub_acquisition_count(memview)\
983             __pyx_atomic_decr_aligned(__pyx_get_slice_count_pointer(memview), memview->lock)
984 #else
985     #define __pyx_add_acquisition_count(memview)\
986             __pyx_add_acquisition_count_locked(__pyx_get_slice_count_pointer(memview), memview->lock)
987     #define __pyx_sub_acquisition_count(memview)\
988             __pyx_sub_acquisition_count_locked(__pyx_get_slice_count_pointer(memview), memview->lock)
989 #endif
990 
991 /* ForceInitThreads.proto */
992 #ifndef __PYX_FORCE_INIT_THREADS
993   #define __PYX_FORCE_INIT_THREADS 0
994 #endif
995 
996 /* NoFastGil.proto */
997 #define __Pyx_PyGILState_Ensure PyGILState_Ensure
998 #define __Pyx_PyGILState_Release PyGILState_Release
999 #define __Pyx_FastGIL_Remember()
1000 #define __Pyx_FastGIL_Forget()
1001 #define __Pyx_FastGilFuncInit()
1002 
1003 
1004 /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":689
1005  * # in Cython to enable them only on the right systems.
1006  *
1007  * ctypedef npy_int8       int8_t             # <<<<<<<<<<<<<<
1008  * ctypedef npy_int16      int16_t
1009  * ctypedef npy_int32      int32_t
1010  */
1011 typedef npy_int8 __pyx_t_5numpy_int8_t;
1012 
1013 /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":690
1014  *
1015  * ctypedef npy_int8       int8_t
1016  * ctypedef npy_int16      int16_t             # <<<<<<<<<<<<<<
1017  * ctypedef npy_int32      int32_t
1018  * ctypedef npy_int64      int64_t
1019  */
1020 typedef npy_int16 __pyx_t_5numpy_int16_t;
1021 
1022 /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":691
1023  * ctypedef npy_int8       int8_t
1024  * ctypedef npy_int16      int16_t
1025  * ctypedef npy_int32      int32_t             # <<<<<<<<<<<<<<
1026  * ctypedef npy_int64      int64_t
1027  * #ctypedef npy_int96      int96_t
1028  */
1029 typedef npy_int32 __pyx_t_5numpy_int32_t;
1030 
1031 /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":692
1032  * ctypedef npy_int16      int16_t
1033  * ctypedef npy_int32      int32_t
1034  * ctypedef npy_int64      int64_t             # <<<<<<<<<<<<<<
1035  * #ctypedef npy_int96      int96_t
1036  * #ctypedef npy_int128     int128_t
1037  */
1038 typedef npy_int64 __pyx_t_5numpy_int64_t;
1039 
1040 /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":696
1041  * #ctypedef npy_int128     int128_t
1042  *
1043  * ctypedef npy_uint8      uint8_t             # <<<<<<<<<<<<<<
1044  * ctypedef npy_uint16     uint16_t
1045  * ctypedef npy_uint32     uint32_t
1046  */
1047 typedef npy_uint8 __pyx_t_5numpy_uint8_t;
1048 
1049 /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":697
1050  *
1051  * ctypedef npy_uint8      uint8_t
1052  * ctypedef npy_uint16     uint16_t             # <<<<<<<<<<<<<<
1053  * ctypedef npy_uint32     uint32_t
1054  * ctypedef npy_uint64     uint64_t
1055  */
1056 typedef npy_uint16 __pyx_t_5numpy_uint16_t;
1057 
1058 /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":698
1059  * ctypedef npy_uint8      uint8_t
1060  * ctypedef npy_uint16     uint16_t
1061  * ctypedef npy_uint32     uint32_t             # <<<<<<<<<<<<<<
1062  * ctypedef npy_uint64     uint64_t
1063  * #ctypedef npy_uint96     uint96_t
1064  */
1065 typedef npy_uint32 __pyx_t_5numpy_uint32_t;
1066 
1067 /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":699
1068  * ctypedef npy_uint16     uint16_t
1069  * ctypedef npy_uint32     uint32_t
1070  * ctypedef npy_uint64     uint64_t             # <<<<<<<<<<<<<<
1071  * #ctypedef npy_uint96     uint96_t
1072  * #ctypedef npy_uint128    uint128_t
1073  */
1074 typedef npy_uint64 __pyx_t_5numpy_uint64_t;
1075 
1076 /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":703
1077  * #ctypedef npy_uint128    uint128_t
1078  *
1079  * ctypedef npy_float32    float32_t             # <<<<<<<<<<<<<<
1080  * ctypedef npy_float64    float64_t
1081  * #ctypedef npy_float80    float80_t
1082  */
1083 typedef npy_float32 __pyx_t_5numpy_float32_t;
1084 
1085 /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":704
1086  *
1087  * ctypedef npy_float32    float32_t
1088  * ctypedef npy_float64    float64_t             # <<<<<<<<<<<<<<
1089  * #ctypedef npy_float80    float80_t
1090  * #ctypedef npy_float128   float128_t
1091  */
1092 typedef npy_float64 __pyx_t_5numpy_float64_t;
1093 
1094 /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":713
1095  * # The int types are mapped a bit surprising --
1096  * # numpy.int corresponds to 'l' and numpy.long to 'q'
1097  * ctypedef npy_long       int_t             # <<<<<<<<<<<<<<
1098  * ctypedef npy_longlong   long_t
1099  * ctypedef npy_longlong   longlong_t
1100  */
1101 typedef npy_long __pyx_t_5numpy_int_t;
1102 
1103 /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":714
1104  * # numpy.int corresponds to 'l' and numpy.long to 'q'
1105  * ctypedef npy_long       int_t
1106  * ctypedef npy_longlong   long_t             # <<<<<<<<<<<<<<
1107  * ctypedef npy_longlong   longlong_t
1108  *
1109  */
1110 typedef npy_longlong __pyx_t_5numpy_long_t;
1111 
1112 /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":715
1113  * ctypedef npy_long       int_t
1114  * ctypedef npy_longlong   long_t
1115  * ctypedef npy_longlong   longlong_t             # <<<<<<<<<<<<<<
1116  *
1117  * ctypedef npy_ulong      uint_t
1118  */
1119 typedef npy_longlong __pyx_t_5numpy_longlong_t;
1120 
1121 /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":717
1122  * ctypedef npy_longlong   longlong_t
1123  *
1124  * ctypedef npy_ulong      uint_t             # <<<<<<<<<<<<<<
1125  * ctypedef npy_ulonglong  ulong_t
1126  * ctypedef npy_ulonglong  ulonglong_t
1127  */
1128 typedef npy_ulong __pyx_t_5numpy_uint_t;
1129 
1130 /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":718
1131  *
1132  * ctypedef npy_ulong      uint_t
1133  * ctypedef npy_ulonglong  ulong_t             # <<<<<<<<<<<<<<
1134  * ctypedef npy_ulonglong  ulonglong_t
1135  *
1136  */
1137 typedef npy_ulonglong __pyx_t_5numpy_ulong_t;
1138 
1139 /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":719
1140  * ctypedef npy_ulong      uint_t
1141  * ctypedef npy_ulonglong  ulong_t
1142  * ctypedef npy_ulonglong  ulonglong_t             # <<<<<<<<<<<<<<
1143  *
1144  * ctypedef npy_intp       intp_t
1145  */
1146 typedef npy_ulonglong __pyx_t_5numpy_ulonglong_t;
1147 
1148 /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":721
1149  * ctypedef npy_ulonglong  ulonglong_t
1150  *
1151  * ctypedef npy_intp       intp_t             # <<<<<<<<<<<<<<
1152  * ctypedef npy_uintp      uintp_t
1153  *
1154  */
1155 typedef npy_intp __pyx_t_5numpy_intp_t;
1156 
1157 /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":722
1158  *
1159  * ctypedef npy_intp       intp_t
1160  * ctypedef npy_uintp      uintp_t             # <<<<<<<<<<<<<<
1161  *
1162  * ctypedef npy_double     float_t
1163  */
1164 typedef npy_uintp __pyx_t_5numpy_uintp_t;
1165 
1166 /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":724
1167  * ctypedef npy_uintp      uintp_t
1168  *
1169  * ctypedef npy_double     float_t             # <<<<<<<<<<<<<<
1170  * ctypedef npy_double     double_t
1171  * ctypedef npy_longdouble longdouble_t
1172  */
1173 typedef npy_double __pyx_t_5numpy_float_t;
1174 
1175 /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":725
1176  *
1177  * ctypedef npy_double     float_t
1178  * ctypedef npy_double     double_t             # <<<<<<<<<<<<<<
1179  * ctypedef npy_longdouble longdouble_t
1180  *
1181  */
1182 typedef npy_double __pyx_t_5numpy_double_t;
1183 
1184 /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":726
1185  * ctypedef npy_double     float_t
1186  * ctypedef npy_double     double_t
1187  * ctypedef npy_longdouble longdouble_t             # <<<<<<<<<<<<<<
1188  *
1189  * ctypedef npy_cfloat      cfloat_t
1190  */
1191 typedef npy_longdouble __pyx_t_5numpy_longdouble_t;
1192 /* Declarations.proto */
1193 #if CYTHON_CCOMPLEX
1194   #ifdef __cplusplus
1195     typedef ::std::complex< double > __pyx_t_double_complex;
1196   #else
1197     typedef double _Complex __pyx_t_double_complex;
1198   #endif
1199 #else
1200     typedef struct { double real, imag; } __pyx_t_double_complex;
1201 #endif
1202 static CYTHON_INLINE __pyx_t_double_complex __pyx_t_double_complex_from_parts(double, double);
1203 
1204 /* Declarations.proto */
1205 #if CYTHON_CCOMPLEX
1206   #ifdef __cplusplus
1207     typedef ::std::complex< float > __pyx_t_float_complex;
1208   #else
1209     typedef float _Complex __pyx_t_float_complex;
1210   #endif
1211 #else
1212     typedef struct { float real, imag; } __pyx_t_float_complex;
1213 #endif
1214 static CYTHON_INLINE __pyx_t_float_complex __pyx_t_float_complex_from_parts(float, float);
1215 
1216 
1217 /*--- Type declarations ---*/
1218 struct __pyx_array_obj;
1219 struct __pyx_MemviewEnum_obj;
1220 struct __pyx_memoryview_obj;
1221 struct __pyx_memoryviewslice_obj;
1222 
1223 /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":728
1224  * ctypedef npy_longdouble longdouble_t
1225  *
1226  * ctypedef npy_cfloat      cfloat_t             # <<<<<<<<<<<<<<
1227  * ctypedef npy_cdouble     cdouble_t
1228  * ctypedef npy_clongdouble clongdouble_t
1229  */
1230 typedef npy_cfloat __pyx_t_5numpy_cfloat_t;
1231 
1232 /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":729
1233  *
1234  * ctypedef npy_cfloat      cfloat_t
1235  * ctypedef npy_cdouble     cdouble_t             # <<<<<<<<<<<<<<
1236  * ctypedef npy_clongdouble clongdouble_t
1237  *
1238  */
1239 typedef npy_cdouble __pyx_t_5numpy_cdouble_t;
1240 
1241 /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":730
1242  * ctypedef npy_cfloat      cfloat_t
1243  * ctypedef npy_cdouble     cdouble_t
1244  * ctypedef npy_clongdouble clongdouble_t             # <<<<<<<<<<<<<<
1245  *
1246  * ctypedef npy_cdouble     complex_t
1247  */
1248 typedef npy_clongdouble __pyx_t_5numpy_clongdouble_t;
1249 
1250 /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":732
1251  * ctypedef npy_clongdouble clongdouble_t
1252  *
1253  * ctypedef npy_cdouble     complex_t             # <<<<<<<<<<<<<<
1254  *
1255  * cdef inline object PyArray_MultiIterNew1(a):
1256  */
1257 typedef npy_cdouble __pyx_t_5numpy_complex_t;
1258 
1259 /* "View.MemoryView":105
1260  *
1261  * @cname("__pyx_array")
1262  * cdef class array:             # <<<<<<<<<<<<<<
1263  *
1264  *     cdef:
1265  */
1266 struct __pyx_array_obj {
1267   PyObject_HEAD
1268   struct __pyx_vtabstruct_array *__pyx_vtab;
1269   char *data;
1270   Py_ssize_t len;
1271   char *format;
1272   int ndim;
1273   Py_ssize_t *_shape;
1274   Py_ssize_t *_strides;
1275   Py_ssize_t itemsize;
1276   PyObject *mode;
1277   PyObject *_format;
1278   void (*callback_free_data)(void *);
1279   int free_data;
1280   int dtype_is_object;
1281 };
1282 
1283 
1284 /* "View.MemoryView":279
1285  *
1286  * @cname('__pyx_MemviewEnum')
1287  * cdef class Enum(object):             # <<<<<<<<<<<<<<
1288  *     cdef object name
1289  *     def __init__(self, name):
1290  */
1291 struct __pyx_MemviewEnum_obj {
1292   PyObject_HEAD
1293   PyObject *name;
1294 };
1295 
1296 
1297 /* "View.MemoryView":330
1298  *
1299  * @cname('__pyx_memoryview')
1300  * cdef class memoryview(object):             # <<<<<<<<<<<<<<
1301  *
1302  *     cdef object obj
1303  */
1304 struct __pyx_memoryview_obj {
1305   PyObject_HEAD
1306   struct __pyx_vtabstruct_memoryview *__pyx_vtab;
1307   PyObject *obj;
1308   PyObject *_size;
1309   PyObject *_array_interface;
1310   PyThread_type_lock lock;
1311   __pyx_atomic_int acquisition_count[2];
1312   __pyx_atomic_int *acquisition_count_aligned_p;
1313   Py_buffer view;
1314   int flags;
1315   int dtype_is_object;
1316   __Pyx_TypeInfo *typeinfo;
1317 };
1318 
1319 
1320 /* "View.MemoryView":965
1321  *
1322  * @cname('__pyx_memoryviewslice')
1323  * cdef class _memoryviewslice(memoryview):             # <<<<<<<<<<<<<<
1324  *     "Internal class for passing memoryview slices to Python"
1325  *
1326  */
1327 struct __pyx_memoryviewslice_obj {
1328   struct __pyx_memoryview_obj __pyx_base;
1329   __Pyx_memviewslice from_slice;
1330   PyObject *from_object;
1331   PyObject *(*to_object_func)(char *);
1332   int (*to_dtype_func)(char *, PyObject *);
1333 };
1334 
1335 
1336 
1337 /* "View.MemoryView":105
1338  *
1339  * @cname("__pyx_array")
1340  * cdef class array:             # <<<<<<<<<<<<<<
1341  *
1342  *     cdef:
1343  */
1344 
1345 struct __pyx_vtabstruct_array {
1346   PyObject *(*get_memview)(struct __pyx_array_obj *);
1347 };
1348 static struct __pyx_vtabstruct_array *__pyx_vtabptr_array;
1349 
1350 
1351 /* "View.MemoryView":330
1352  *
1353  * @cname('__pyx_memoryview')
1354  * cdef class memoryview(object):             # <<<<<<<<<<<<<<
1355  *
1356  *     cdef object obj
1357  */
1358 
1359 struct __pyx_vtabstruct_memoryview {
1360   char *(*get_item_pointer)(struct __pyx_memoryview_obj *, PyObject *);
1361   PyObject *(*is_slice)(struct __pyx_memoryview_obj *, PyObject *);
1362   PyObject *(*setitem_slice_assignment)(struct __pyx_memoryview_obj *, PyObject *, PyObject *);
1363   PyObject *(*setitem_slice_assign_scalar)(struct __pyx_memoryview_obj *, struct __pyx_memoryview_obj *, PyObject *);
1364   PyObject *(*setitem_indexed)(struct __pyx_memoryview_obj *, PyObject *, PyObject *);
1365   PyObject *(*convert_item_to_object)(struct __pyx_memoryview_obj *, char *);
1366   PyObject *(*assign_item_from_object)(struct __pyx_memoryview_obj *, char *, PyObject *);
1367 };
1368 static struct __pyx_vtabstruct_memoryview *__pyx_vtabptr_memoryview;
1369 
1370 
1371 /* "View.MemoryView":965
1372  *
1373  * @cname('__pyx_memoryviewslice')
1374  * cdef class _memoryviewslice(memoryview):             # <<<<<<<<<<<<<<
1375  *     "Internal class for passing memoryview slices to Python"
1376  *
1377  */
1378 
1379 struct __pyx_vtabstruct__memoryviewslice {
1380   struct __pyx_vtabstruct_memoryview __pyx_base;
1381 };
1382 static struct __pyx_vtabstruct__memoryviewslice *__pyx_vtabptr__memoryviewslice;
1383 
1384 /* --- Runtime support code (head) --- */
1385 /* Refnanny.proto */
1386 #ifndef CYTHON_REFNANNY
1387   #define CYTHON_REFNANNY 0
1388 #endif
1389 #if CYTHON_REFNANNY
1390   typedef struct {
1391     void (*INCREF)(void*, PyObject*, int);
1392     void (*DECREF)(void*, PyObject*, int);
1393     void (*GOTREF)(void*, PyObject*, int);
1394     void (*GIVEREF)(void*, PyObject*, int);
1395     void* (*SetupContext)(const char*, int, const char*);
1396     void (*FinishContext)(void**);
1397   } __Pyx_RefNannyAPIStruct;
1398   static __Pyx_RefNannyAPIStruct *__Pyx_RefNanny = NULL;
1399   static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname);
1400   #define __Pyx_RefNannyDeclarations void *__pyx_refnanny = NULL;
1401 #ifdef WITH_THREAD
1402   #define __Pyx_RefNannySetupContext(name, acquire_gil)\
1403           if (acquire_gil) {\
1404               PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure();\
1405               __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__);\
1406               PyGILState_Release(__pyx_gilstate_save);\
1407           } else {\
1408               __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__);\
1409           }
1410 #else
1411   #define __Pyx_RefNannySetupContext(name, acquire_gil)\
1412           __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__)
1413 #endif
1414   #define __Pyx_RefNannyFinishContext()\
1415           __Pyx_RefNanny->FinishContext(&__pyx_refnanny)
1416   #define __Pyx_INCREF(r)  __Pyx_RefNanny->INCREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
1417   #define __Pyx_DECREF(r)  __Pyx_RefNanny->DECREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
1418   #define __Pyx_GOTREF(r)  __Pyx_RefNanny->GOTREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
1419   #define __Pyx_GIVEREF(r) __Pyx_RefNanny->GIVEREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
1420   #define __Pyx_XINCREF(r)  do { if((r) != NULL) {__Pyx_INCREF(r); }} while(0)
1421   #define __Pyx_XDECREF(r)  do { if((r) != NULL) {__Pyx_DECREF(r); }} while(0)
1422   #define __Pyx_XGOTREF(r)  do { if((r) != NULL) {__Pyx_GOTREF(r); }} while(0)
1423   #define __Pyx_XGIVEREF(r) do { if((r) != NULL) {__Pyx_GIVEREF(r);}} while(0)
1424 #else
1425   #define __Pyx_RefNannyDeclarations
1426   #define __Pyx_RefNannySetupContext(name, acquire_gil)
1427   #define __Pyx_RefNannyFinishContext()
1428   #define __Pyx_INCREF(r) Py_INCREF(r)
1429   #define __Pyx_DECREF(r) Py_DECREF(r)
1430   #define __Pyx_GOTREF(r)
1431   #define __Pyx_GIVEREF(r)
1432   #define __Pyx_XINCREF(r) Py_XINCREF(r)
1433   #define __Pyx_XDECREF(r) Py_XDECREF(r)
1434   #define __Pyx_XGOTREF(r)
1435   #define __Pyx_XGIVEREF(r)
1436 #endif
1437 #define __Pyx_XDECREF_SET(r, v) do {\
1438         PyObject *tmp = (PyObject *) r;\
1439         r = v; __Pyx_XDECREF(tmp);\
1440     } while (0)
1441 #define __Pyx_DECREF_SET(r, v) do {\
1442         PyObject *tmp = (PyObject *) r;\
1443         r = v; __Pyx_DECREF(tmp);\
1444     } while (0)
1445 #define __Pyx_CLEAR(r)    do { PyObject* tmp = ((PyObject*)(r)); r = NULL; __Pyx_DECREF(tmp);} while(0)
1446 #define __Pyx_XCLEAR(r)   do { if((r) != NULL) {PyObject* tmp = ((PyObject*)(r)); r = NULL; __Pyx_DECREF(tmp);}} while(0)
1447 
1448 /* PyObjectGetAttrStr.proto */
1449 #if CYTHON_USE_TYPE_SLOTS
1450 static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStr(PyObject* obj, PyObject* attr_name);
1451 #else
1452 #define __Pyx_PyObject_GetAttrStr(o,n) PyObject_GetAttr(o,n)
1453 #endif
1454 
1455 /* GetBuiltinName.proto */
1456 static PyObject *__Pyx_GetBuiltinName(PyObject *name);
1457 
1458 /* RaiseArgTupleInvalid.proto */
1459 static void __Pyx_RaiseArgtupleInvalid(const char* func_name, int exact,
1460     Py_ssize_t num_min, Py_ssize_t num_max, Py_ssize_t num_found);
1461 
1462 /* RaiseDoubleKeywords.proto */
1463 static void __Pyx_RaiseDoubleKeywordsError(const char* func_name, PyObject* kw_name);
1464 
1465 /* ParseKeywords.proto */
1466 static int __Pyx_ParseOptionalKeywords(PyObject *kwds, PyObject **argnames[],\
1467     PyObject *kwds2, PyObject *values[], Py_ssize_t num_pos_args,\
1468     const char* function_name);
1469 
1470 /* PyIntCompare.proto */
1471 static CYTHON_INLINE PyObject* __Pyx_PyInt_EqObjC(PyObject *op1, PyObject *op2, long intval, long inplace);
1472 
1473 /* PyDictVersioning.proto */
1474 #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_TYPE_SLOTS
1475 #define __PYX_DICT_VERSION_INIT  ((PY_UINT64_T) -1)
1476 #define __PYX_GET_DICT_VERSION(dict)  (((PyDictObject*)(dict))->ma_version_tag)
1477 #define __PYX_UPDATE_DICT_CACHE(dict, value, cache_var, version_var)\
1478     (version_var) = __PYX_GET_DICT_VERSION(dict);\
1479     (cache_var) = (value);
1480 #define __PYX_PY_DICT_LOOKUP_IF_MODIFIED(VAR, DICT, LOOKUP) {\
1481     static PY_UINT64_T __pyx_dict_version = 0;\
1482     static PyObject *__pyx_dict_cached_value = NULL;\
1483     if (likely(__PYX_GET_DICT_VERSION(DICT) == __pyx_dict_version)) {\
1484         (VAR) = __pyx_dict_cached_value;\
1485     } else {\
1486         (VAR) = __pyx_dict_cached_value = (LOOKUP);\
1487         __pyx_dict_version = __PYX_GET_DICT_VERSION(DICT);\
1488     }\
1489 }
1490 static CYTHON_INLINE PY_UINT64_T __Pyx_get_tp_dict_version(PyObject *obj);
1491 static CYTHON_INLINE PY_UINT64_T __Pyx_get_object_dict_version(PyObject *obj);
1492 static CYTHON_INLINE int __Pyx_object_dict_version_matches(PyObject* obj, PY_UINT64_T tp_dict_version, PY_UINT64_T obj_dict_version);
1493 #else
1494 #define __PYX_GET_DICT_VERSION(dict)  (0)
1495 #define __PYX_UPDATE_DICT_CACHE(dict, value, cache_var, version_var)
1496 #define __PYX_PY_DICT_LOOKUP_IF_MODIFIED(VAR, DICT, LOOKUP)  (VAR) = (LOOKUP);
1497 #endif
1498 
1499 /* GetModuleGlobalName.proto */
1500 #if CYTHON_USE_DICT_VERSIONS
1501 #define __Pyx_GetModuleGlobalName(var, name)  {\
1502     static PY_UINT64_T __pyx_dict_version = 0;\
1503     static PyObject *__pyx_dict_cached_value = NULL;\
1504     (var) = (likely(__pyx_dict_version == __PYX_GET_DICT_VERSION(__pyx_d))) ?\
1505         (likely(__pyx_dict_cached_value) ? __Pyx_NewRef(__pyx_dict_cached_value) : __Pyx_GetBuiltinName(name)) :\
1506         __Pyx__GetModuleGlobalName(name, &__pyx_dict_version, &__pyx_dict_cached_value);\
1507 }
1508 #define __Pyx_GetModuleGlobalNameUncached(var, name)  {\
1509     PY_UINT64_T __pyx_dict_version;\
1510     PyObject *__pyx_dict_cached_value;\
1511     (var) = __Pyx__GetModuleGlobalName(name, &__pyx_dict_version, &__pyx_dict_cached_value);\
1512 }
1513 static PyObject *__Pyx__GetModuleGlobalName(PyObject *name, PY_UINT64_T *dict_version, PyObject **dict_cached_value);
1514 #else
1515 #define __Pyx_GetModuleGlobalName(var, name)  (var) = __Pyx__GetModuleGlobalName(name)
1516 #define __Pyx_GetModuleGlobalNameUncached(var, name)  (var) = __Pyx__GetModuleGlobalName(name)
1517 static CYTHON_INLINE PyObject *__Pyx__GetModuleGlobalName(PyObject *name);
1518 #endif
1519 
1520 /* GetItemInt.proto */
1521 #define __Pyx_GetItemInt(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck)\
1522     (__Pyx_fits_Py_ssize_t(i, type, is_signed) ?\
1523     __Pyx_GetItemInt_Fast(o, (Py_ssize_t)i, is_list, wraparound, boundscheck) :\
1524     (is_list ? (PyErr_SetString(PyExc_IndexError, "list index out of range"), (PyObject*)NULL) :\
1525                __Pyx_GetItemInt_Generic(o, to_py_func(i))))
1526 #define __Pyx_GetItemInt_List(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck)\
1527     (__Pyx_fits_Py_ssize_t(i, type, is_signed) ?\
1528     __Pyx_GetItemInt_List_Fast(o, (Py_ssize_t)i, wraparound, boundscheck) :\
1529     (PyErr_SetString(PyExc_IndexError, "list index out of range"), (PyObject*)NULL))
1530 static CYTHON_INLINE PyObject *__Pyx_GetItemInt_List_Fast(PyObject *o, Py_ssize_t i,
1531                                                               int wraparound, int boundscheck);
1532 #define __Pyx_GetItemInt_Tuple(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck)\
1533     (__Pyx_fits_Py_ssize_t(i, type, is_signed) ?\
1534     __Pyx_GetItemInt_Tuple_Fast(o, (Py_ssize_t)i, wraparound, boundscheck) :\
1535     (PyErr_SetString(PyExc_IndexError, "tuple index out of range"), (PyObject*)NULL))
1536 static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Tuple_Fast(PyObject *o, Py_ssize_t i,
1537                                                               int wraparound, int boundscheck);
1538 static PyObject *__Pyx_GetItemInt_Generic(PyObject *o, PyObject* j);
1539 static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Fast(PyObject *o, Py_ssize_t i,
1540                                                      int is_list, int wraparound, int boundscheck);
1541 
1542 /* PyCFunctionFastCall.proto */
1543 #if CYTHON_FAST_PYCCALL
1544 static CYTHON_INLINE PyObject *__Pyx_PyCFunction_FastCall(PyObject *func, PyObject **args, Py_ssize_t nargs);
1545 #else
1546 #define __Pyx_PyCFunction_FastCall(func, args, nargs)  (assert(0), NULL)
1547 #endif
1548 
1549 /* PyFunctionFastCall.proto */
1550 #if CYTHON_FAST_PYCALL
1551 #define __Pyx_PyFunction_FastCall(func, args, nargs)\
1552     __Pyx_PyFunction_FastCallDict((func), (args), (nargs), NULL)
1553 #if 1 || PY_VERSION_HEX < 0x030600B1
1554 static PyObject *__Pyx_PyFunction_FastCallDict(PyObject *func, PyObject **args, Py_ssize_t nargs, PyObject *kwargs);
1555 #else
1556 #define __Pyx_PyFunction_FastCallDict(func, args, nargs, kwargs) _PyFunction_FastCallDict(func, args, nargs, kwargs)
1557 #endif
1558 #define __Pyx_BUILD_ASSERT_EXPR(cond)\
1559     (sizeof(char [1 - 2*!(cond)]) - 1)
1560 #ifndef Py_MEMBER_SIZE
1561 #define Py_MEMBER_SIZE(type, member) sizeof(((type *)0)->member)
1562 #endif
1563   static size_t __pyx_pyframe_localsplus_offset = 0;
1564   #include "frameobject.h"
1565   #define __Pxy_PyFrame_Initialize_Offsets()\
1566     ((void)__Pyx_BUILD_ASSERT_EXPR(sizeof(PyFrameObject) == offsetof(PyFrameObject, f_localsplus) + Py_MEMBER_SIZE(PyFrameObject, f_localsplus)),\
1567      (void)(__pyx_pyframe_localsplus_offset = ((size_t)PyFrame_Type.tp_basicsize) - Py_MEMBER_SIZE(PyFrameObject, f_localsplus)))
1568   #define __Pyx_PyFrame_GetLocalsplus(frame)\
1569     (assert(__pyx_pyframe_localsplus_offset), (PyObject **)(((char *)(frame)) + __pyx_pyframe_localsplus_offset))
1570 #endif
1571 
1572 /* PyObjectCall.proto */
1573 #if CYTHON_COMPILING_IN_CPYTHON
1574 static CYTHON_INLINE PyObject* __Pyx_PyObject_Call(PyObject *func, PyObject *arg, PyObject *kw);
1575 #else
1576 #define __Pyx_PyObject_Call(func, arg, kw) PyObject_Call(func, arg, kw)
1577 #endif
1578 
1579 /* PyObjectCall2Args.proto */
1580 static CYTHON_UNUSED PyObject* __Pyx_PyObject_Call2Args(PyObject* function, PyObject* arg1, PyObject* arg2);
1581 
1582 /* PyObjectCallMethO.proto */
1583 #if CYTHON_COMPILING_IN_CPYTHON
1584 static CYTHON_INLINE PyObject* __Pyx_PyObject_CallMethO(PyObject *func, PyObject *arg);
1585 #endif
1586 
1587 /* PyObjectCallOneArg.proto */
1588 static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg);
1589 
1590 /* PyObjectCallNoArg.proto */
1591 #if CYTHON_COMPILING_IN_CPYTHON
1592 static CYTHON_INLINE PyObject* __Pyx_PyObject_CallNoArg(PyObject *func);
1593 #else
1594 #define __Pyx_PyObject_CallNoArg(func) __Pyx_PyObject_Call(func, __pyx_empty_tuple, NULL)
1595 #endif
1596 
1597 /* ExtTypeTest.proto */
1598 static CYTHON_INLINE int __Pyx_TypeTest(PyObject *obj, PyTypeObject *type);
1599 
1600 /* IsLittleEndian.proto */
1601 static CYTHON_INLINE int __Pyx_Is_Little_Endian(void);
1602 
1603 /* BufferFormatCheck.proto */
1604 static const char* __Pyx_BufFmt_CheckString(__Pyx_BufFmt_Context* ctx, const char* ts);
1605 static void __Pyx_BufFmt_Init(__Pyx_BufFmt_Context* ctx,
1606                               __Pyx_BufFmt_StackElem* stack,
1607                               __Pyx_TypeInfo* type);
1608 
1609 /* BufferGetAndValidate.proto */
1610 #define __Pyx_GetBufferAndValidate(buf, obj, dtype, flags, nd, cast, stack)\
1611     ((obj == Py_None || obj == NULL) ?\
1612     (__Pyx_ZeroBuffer(buf), 0) :\
1613     __Pyx__GetBufferAndValidate(buf, obj, dtype, flags, nd, cast, stack))
1614 static int  __Pyx__GetBufferAndValidate(Py_buffer* buf, PyObject* obj,
1615     __Pyx_TypeInfo* dtype, int flags, int nd, int cast, __Pyx_BufFmt_StackElem* stack);
1616 static void __Pyx_ZeroBuffer(Py_buffer* buf);
1617 static CYTHON_INLINE void __Pyx_SafeReleaseBuffer(Py_buffer* info);
1618 static Py_ssize_t __Pyx_minusones[] = { -1, -1, -1, -1, -1, -1, -1, -1 };
1619 static Py_ssize_t __Pyx_zeros[] = { 0, 0, 0, 0, 0, 0, 0, 0 };
1620 
1621 /* PyThreadStateGet.proto */
1622 #if CYTHON_FAST_THREAD_STATE
1623 #define __Pyx_PyThreadState_declare  PyThreadState *__pyx_tstate;
1624 #define __Pyx_PyThreadState_assign  __pyx_tstate = __Pyx_PyThreadState_Current;
1625 #define __Pyx_PyErr_Occurred()  __pyx_tstate->curexc_type
1626 #else
1627 #define __Pyx_PyThreadState_declare
1628 #define __Pyx_PyThreadState_assign
1629 #define __Pyx_PyErr_Occurred()  PyErr_Occurred()
1630 #endif
1631 
1632 /* PyErrFetchRestore.proto */
1633 #if CYTHON_FAST_THREAD_STATE
1634 #define __Pyx_PyErr_Clear() __Pyx_ErrRestore(NULL, NULL, NULL)
1635 #define __Pyx_ErrRestoreWithState(type, value, tb)  __Pyx_ErrRestoreInState(PyThreadState_GET(), type, value, tb)
1636 #define __Pyx_ErrFetchWithState(type, value, tb)    __Pyx_ErrFetchInState(PyThreadState_GET(), type, value, tb)
1637 #define __Pyx_ErrRestore(type, value, tb)  __Pyx_ErrRestoreInState(__pyx_tstate, type, value, tb)
1638 #define __Pyx_ErrFetch(type, value, tb)    __Pyx_ErrFetchInState(__pyx_tstate, type, value, tb)
1639 static CYTHON_INLINE void __Pyx_ErrRestoreInState(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb);
1640 static CYTHON_INLINE void __Pyx_ErrFetchInState(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb);
1641 #if CYTHON_COMPILING_IN_CPYTHON
1642 #define __Pyx_PyErr_SetNone(exc) (Py_INCREF(exc), __Pyx_ErrRestore((exc), NULL, NULL))
1643 #else
1644 #define __Pyx_PyErr_SetNone(exc) PyErr_SetNone(exc)
1645 #endif
1646 #else
1647 #define __Pyx_PyErr_Clear() PyErr_Clear()
1648 #define __Pyx_PyErr_SetNone(exc) PyErr_SetNone(exc)
1649 #define __Pyx_ErrRestoreWithState(type, value, tb)  PyErr_Restore(type, value, tb)
1650 #define __Pyx_ErrFetchWithState(type, value, tb)  PyErr_Fetch(type, value, tb)
1651 #define __Pyx_ErrRestoreInState(tstate, type, value, tb)  PyErr_Restore(type, value, tb)
1652 #define __Pyx_ErrFetchInState(tstate, type, value, tb)  PyErr_Fetch(type, value, tb)
1653 #define __Pyx_ErrRestore(type, value, tb)  PyErr_Restore(type, value, tb)
1654 #define __Pyx_ErrFetch(type, value, tb)  PyErr_Fetch(type, value, tb)
1655 #endif
1656 
1657 /* RaiseException.proto */
1658 static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause);
1659 
1660 /* MemviewSliceInit.proto */
1661 #define __Pyx_BUF_MAX_NDIMS %(BUF_MAX_NDIMS)d
1662 #define __Pyx_MEMVIEW_DIRECT   1
1663 #define __Pyx_MEMVIEW_PTR      2
1664 #define __Pyx_MEMVIEW_FULL     4
1665 #define __Pyx_MEMVIEW_CONTIG   8
1666 #define __Pyx_MEMVIEW_STRIDED  16
1667 #define __Pyx_MEMVIEW_FOLLOW   32
1668 #define __Pyx_IS_C_CONTIG 1
1669 #define __Pyx_IS_F_CONTIG 2
1670 static int __Pyx_init_memviewslice(
1671                 struct __pyx_memoryview_obj *memview,
1672                 int ndim,
1673                 __Pyx_memviewslice *memviewslice,
1674                 int memview_is_new_reference);
1675 static CYTHON_INLINE int __pyx_add_acquisition_count_locked(
1676     __pyx_atomic_int *acquisition_count, PyThread_type_lock lock);
1677 static CYTHON_INLINE int __pyx_sub_acquisition_count_locked(
1678     __pyx_atomic_int *acquisition_count, PyThread_type_lock lock);
1679 #define __pyx_get_slice_count_pointer(memview) (memview->acquisition_count_aligned_p)
1680 #define __pyx_get_slice_count(memview) (*__pyx_get_slice_count_pointer(memview))
1681 #define __PYX_INC_MEMVIEW(slice, have_gil) __Pyx_INC_MEMVIEW(slice, have_gil, __LINE__)
1682 #define __PYX_XDEC_MEMVIEW(slice, have_gil) __Pyx_XDEC_MEMVIEW(slice, have_gil, __LINE__)
1683 static CYTHON_INLINE void __Pyx_INC_MEMVIEW(__Pyx_memviewslice *, int, int);
1684 static CYTHON_INLINE void __Pyx_XDEC_MEMVIEW(__Pyx_memviewslice *, int, int);
1685 
1686 #define __Pyx_BufPtrCContig1d(type, buf, i0, s0) ((type)buf + i0)
1687 /* None.proto */
1688 static CYTHON_INLINE void __Pyx_RaiseUnboundLocalError(const char *varname);
1689 
1690 #define __Pyx_BufPtrCContig2d(type, buf, i0, s0, i1, s1) ((type)((char*)buf + i0 * s0) + i1)
1691 /* GetTopmostException.proto */
1692 #if CYTHON_USE_EXC_INFO_STACK
1693 static _PyErr_StackItem * __Pyx_PyErr_GetTopmostException(PyThreadState *tstate);
1694 #endif
1695 
1696 /* SaveResetException.proto */
1697 #if CYTHON_FAST_THREAD_STATE
1698 #define __Pyx_ExceptionSave(type, value, tb)  __Pyx__ExceptionSave(__pyx_tstate, type, value, tb)
1699 static CYTHON_INLINE void __Pyx__ExceptionSave(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb);
1700 #define __Pyx_ExceptionReset(type, value, tb)  __Pyx__ExceptionReset(__pyx_tstate, type, value, tb)
1701 static CYTHON_INLINE void __Pyx__ExceptionReset(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb);
1702 #else
1703 #define __Pyx_ExceptionSave(type, value, tb)   PyErr_GetExcInfo(type, value, tb)
1704 #define __Pyx_ExceptionReset(type, value, tb)  PyErr_SetExcInfo(type, value, tb)
1705 #endif
1706 
1707 /* PyErrExceptionMatches.proto */
1708 #if CYTHON_FAST_THREAD_STATE
1709 #define __Pyx_PyErr_ExceptionMatches(err) __Pyx_PyErr_ExceptionMatchesInState(__pyx_tstate, err)
1710 static CYTHON_INLINE int __Pyx_PyErr_ExceptionMatchesInState(PyThreadState* tstate, PyObject* err);
1711 #else
1712 #define __Pyx_PyErr_ExceptionMatches(err)  PyErr_ExceptionMatches(err)
1713 #endif
1714 
1715 /* GetException.proto */
1716 #if CYTHON_FAST_THREAD_STATE
1717 #define __Pyx_GetException(type, value, tb)  __Pyx__GetException(__pyx_tstate, type, value, tb)
1718 static int __Pyx__GetException(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb);
1719 #else
1720 static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb);
1721 #endif
1722 
1723 /* ArgTypeTest.proto */
1724 #define __Pyx_ArgTypeTest(obj, type, none_allowed, name, exact)\
1725     ((likely((Py_TYPE(obj) == type) | (none_allowed && (obj == Py_None)))) ? 1 :\
1726         __Pyx__ArgTypeTest(obj, type, name, exact))
1727 static int __Pyx__ArgTypeTest(PyObject *obj, PyTypeObject *type, const char *name, int exact);
1728 
1729 /* IncludeStringH.proto */
1730 #include <string.h>
1731 
1732 /* BytesEquals.proto */
1733 static CYTHON_INLINE int __Pyx_PyBytes_Equals(PyObject* s1, PyObject* s2, int equals);
1734 
1735 /* UnicodeEquals.proto */
1736 static CYTHON_INLINE int __Pyx_PyUnicode_Equals(PyObject* s1, PyObject* s2, int equals);
1737 
1738 /* StrEquals.proto */
1739 #if PY_MAJOR_VERSION >= 3
1740 #define __Pyx_PyString_Equals __Pyx_PyUnicode_Equals
1741 #else
1742 #define __Pyx_PyString_Equals __Pyx_PyBytes_Equals
1743 #endif
1744 
1745 /* None.proto */
1746 static CYTHON_INLINE Py_ssize_t __Pyx_div_Py_ssize_t(Py_ssize_t, Py_ssize_t);
1747 
1748 /* UnaryNegOverflows.proto */
1749 #define UNARY_NEG_WOULD_OVERFLOW(x)\
1750         (((x) < 0) & ((unsigned long)(x) == 0-(unsigned long)(x)))
1751 
1752 static CYTHON_UNUSED int __pyx_array_getbuffer(PyObject *__pyx_v_self, Py_buffer *__pyx_v_info, int __pyx_v_flags); /*proto*/
1753 static PyObject *__pyx_array_get_memview(struct __pyx_array_obj *); /*proto*/
1754 /* GetAttr.proto */
1755 static CYTHON_INLINE PyObject *__Pyx_GetAttr(PyObject *, PyObject *);
1756 
1757 /* ObjectGetItem.proto */
1758 #if CYTHON_USE_TYPE_SLOTS
1759 static CYTHON_INLINE PyObject *__Pyx_PyObject_GetItem(PyObject *obj, PyObject* key);
1760 #else
1761 #define __Pyx_PyObject_GetItem(obj, key)  PyObject_GetItem(obj, key)
1762 #endif
1763 
1764 /* decode_c_string_utf16.proto */
__Pyx_PyUnicode_DecodeUTF16(const char * s,Py_ssize_t size,const char * errors)1765 static CYTHON_INLINE PyObject *__Pyx_PyUnicode_DecodeUTF16(const char *s, Py_ssize_t size, const char *errors) {
1766     int byteorder = 0;
1767     return PyUnicode_DecodeUTF16(s, size, errors, &byteorder);
1768 }
__Pyx_PyUnicode_DecodeUTF16LE(const char * s,Py_ssize_t size,const char * errors)1769 static CYTHON_INLINE PyObject *__Pyx_PyUnicode_DecodeUTF16LE(const char *s, Py_ssize_t size, const char *errors) {
1770     int byteorder = -1;
1771     return PyUnicode_DecodeUTF16(s, size, errors, &byteorder);
1772 }
__Pyx_PyUnicode_DecodeUTF16BE(const char * s,Py_ssize_t size,const char * errors)1773 static CYTHON_INLINE PyObject *__Pyx_PyUnicode_DecodeUTF16BE(const char *s, Py_ssize_t size, const char *errors) {
1774     int byteorder = 1;
1775     return PyUnicode_DecodeUTF16(s, size, errors, &byteorder);
1776 }
1777 
1778 /* decode_c_string.proto */
1779 static CYTHON_INLINE PyObject* __Pyx_decode_c_string(
1780          const char* cstring, Py_ssize_t start, Py_ssize_t stop,
1781          const char* encoding, const char* errors,
1782          PyObject* (*decode_func)(const char *s, Py_ssize_t size, const char *errors));
1783 
1784 /* GetAttr3.proto */
1785 static CYTHON_INLINE PyObject *__Pyx_GetAttr3(PyObject *, PyObject *, PyObject *);
1786 
1787 /* RaiseTooManyValuesToUnpack.proto */
1788 static CYTHON_INLINE void __Pyx_RaiseTooManyValuesError(Py_ssize_t expected);
1789 
1790 /* RaiseNeedMoreValuesToUnpack.proto */
1791 static CYTHON_INLINE void __Pyx_RaiseNeedMoreValuesError(Py_ssize_t index);
1792 
1793 /* RaiseNoneIterError.proto */
1794 static CYTHON_INLINE void __Pyx_RaiseNoneNotIterableError(void);
1795 
1796 /* SwapException.proto */
1797 #if CYTHON_FAST_THREAD_STATE
1798 #define __Pyx_ExceptionSwap(type, value, tb)  __Pyx__ExceptionSwap(__pyx_tstate, type, value, tb)
1799 static CYTHON_INLINE void __Pyx__ExceptionSwap(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb);
1800 #else
1801 static CYTHON_INLINE void __Pyx_ExceptionSwap(PyObject **type, PyObject **value, PyObject **tb);
1802 #endif
1803 
1804 /* Import.proto */
1805 static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, int level);
1806 
1807 /* FastTypeChecks.proto */
1808 #if CYTHON_COMPILING_IN_CPYTHON
1809 #define __Pyx_TypeCheck(obj, type) __Pyx_IsSubtype(Py_TYPE(obj), (PyTypeObject *)type)
1810 static CYTHON_INLINE int __Pyx_IsSubtype(PyTypeObject *a, PyTypeObject *b);
1811 static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches(PyObject *err, PyObject *type);
1812 static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches2(PyObject *err, PyObject *type1, PyObject *type2);
1813 #else
1814 #define __Pyx_TypeCheck(obj, type) PyObject_TypeCheck(obj, (PyTypeObject *)type)
1815 #define __Pyx_PyErr_GivenExceptionMatches(err, type) PyErr_GivenExceptionMatches(err, type)
1816 #define __Pyx_PyErr_GivenExceptionMatches2(err, type1, type2) (PyErr_GivenExceptionMatches(err, type1) || PyErr_GivenExceptionMatches(err, type2))
1817 #endif
1818 #define __Pyx_PyException_Check(obj) __Pyx_TypeCheck(obj, PyExc_Exception)
1819 
1820 static CYTHON_UNUSED int __pyx_memoryview_getbuffer(PyObject *__pyx_v_self, Py_buffer *__pyx_v_info, int __pyx_v_flags); /*proto*/
1821 /* ListCompAppend.proto */
1822 #if CYTHON_USE_PYLIST_INTERNALS && CYTHON_ASSUME_SAFE_MACROS
__Pyx_ListComp_Append(PyObject * list,PyObject * x)1823 static CYTHON_INLINE int __Pyx_ListComp_Append(PyObject* list, PyObject* x) {
1824     PyListObject* L = (PyListObject*) list;
1825     Py_ssize_t len = Py_SIZE(list);
1826     if (likely(L->allocated > len)) {
1827         Py_INCREF(x);
1828         PyList_SET_ITEM(list, len, x);
1829         __Pyx_SET_SIZE(list, len + 1);
1830         return 0;
1831     }
1832     return PyList_Append(list, x);
1833 }
1834 #else
1835 #define __Pyx_ListComp_Append(L,x) PyList_Append(L,x)
1836 #endif
1837 
1838 /* PyIntBinop.proto */
1839 #if !CYTHON_COMPILING_IN_PYPY
1840 static PyObject* __Pyx_PyInt_AddObjC(PyObject *op1, PyObject *op2, long intval, int inplace, int zerodivision_check);
1841 #else
1842 #define __Pyx_PyInt_AddObjC(op1, op2, intval, inplace, zerodivision_check)\
1843     (inplace ? PyNumber_InPlaceAdd(op1, op2) : PyNumber_Add(op1, op2))
1844 #endif
1845 
1846 /* ListExtend.proto */
__Pyx_PyList_Extend(PyObject * L,PyObject * v)1847 static CYTHON_INLINE int __Pyx_PyList_Extend(PyObject* L, PyObject* v) {
1848 #if CYTHON_COMPILING_IN_CPYTHON
1849     PyObject* none = _PyList_Extend((PyListObject*)L, v);
1850     if (unlikely(!none))
1851         return -1;
1852     Py_DECREF(none);
1853     return 0;
1854 #else
1855     return PyList_SetSlice(L, PY_SSIZE_T_MAX, PY_SSIZE_T_MAX, v);
1856 #endif
1857 }
1858 
1859 /* ListAppend.proto */
1860 #if CYTHON_USE_PYLIST_INTERNALS && CYTHON_ASSUME_SAFE_MACROS
__Pyx_PyList_Append(PyObject * list,PyObject * x)1861 static CYTHON_INLINE int __Pyx_PyList_Append(PyObject* list, PyObject* x) {
1862     PyListObject* L = (PyListObject*) list;
1863     Py_ssize_t len = Py_SIZE(list);
1864     if (likely(L->allocated > len) & likely(len > (L->allocated >> 1))) {
1865         Py_INCREF(x);
1866         PyList_SET_ITEM(list, len, x);
1867         __Pyx_SET_SIZE(list, len + 1);
1868         return 0;
1869     }
1870     return PyList_Append(list, x);
1871 }
1872 #else
1873 #define __Pyx_PyList_Append(L,x) PyList_Append(L,x)
1874 #endif
1875 
1876 /* None.proto */
1877 static CYTHON_INLINE long __Pyx_div_long(long, long);
1878 
1879 /* ImportFrom.proto */
1880 static PyObject* __Pyx_ImportFrom(PyObject* module, PyObject* name);
1881 
1882 /* HasAttr.proto */
1883 static CYTHON_INLINE int __Pyx_HasAttr(PyObject *, PyObject *);
1884 
1885 /* PyObject_GenericGetAttrNoDict.proto */
1886 #if CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP && PY_VERSION_HEX < 0x03070000
1887 static CYTHON_INLINE PyObject* __Pyx_PyObject_GenericGetAttrNoDict(PyObject* obj, PyObject* attr_name);
1888 #else
1889 #define __Pyx_PyObject_GenericGetAttrNoDict PyObject_GenericGetAttr
1890 #endif
1891 
1892 /* PyObject_GenericGetAttr.proto */
1893 #if CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP && PY_VERSION_HEX < 0x03070000
1894 static PyObject* __Pyx_PyObject_GenericGetAttr(PyObject* obj, PyObject* attr_name);
1895 #else
1896 #define __Pyx_PyObject_GenericGetAttr PyObject_GenericGetAttr
1897 #endif
1898 
1899 /* SetVTable.proto */
1900 static int __Pyx_SetVtable(PyObject *dict, void *vtable);
1901 
1902 /* PyObjectGetAttrStrNoError.proto */
1903 static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStrNoError(PyObject* obj, PyObject* attr_name);
1904 
1905 /* SetupReduce.proto */
1906 static int __Pyx_setup_reduce(PyObject* type_obj);
1907 
1908 /* TypeImport.proto */
1909 #ifndef __PYX_HAVE_RT_ImportType_proto
1910 #define __PYX_HAVE_RT_ImportType_proto
1911 enum __Pyx_ImportType_CheckSize {
1912    __Pyx_ImportType_CheckSize_Error = 0,
1913    __Pyx_ImportType_CheckSize_Warn = 1,
1914    __Pyx_ImportType_CheckSize_Ignore = 2
1915 };
1916 static PyTypeObject *__Pyx_ImportType(PyObject* module, const char *module_name, const char *class_name, size_t size, enum __Pyx_ImportType_CheckSize check_size);
1917 #endif
1918 
1919 /* CLineInTraceback.proto */
1920 #ifdef CYTHON_CLINE_IN_TRACEBACK
1921 #define __Pyx_CLineForTraceback(tstate, c_line)  (((CYTHON_CLINE_IN_TRACEBACK)) ? c_line : 0)
1922 #else
1923 static int __Pyx_CLineForTraceback(PyThreadState *tstate, int c_line);
1924 #endif
1925 
1926 /* CodeObjectCache.proto */
1927 typedef struct {
1928     PyCodeObject* code_object;
1929     int code_line;
1930 } __Pyx_CodeObjectCacheEntry;
1931 struct __Pyx_CodeObjectCache {
1932     int count;
1933     int max_count;
1934     __Pyx_CodeObjectCacheEntry* entries;
1935 };
1936 static struct __Pyx_CodeObjectCache __pyx_code_cache = {0,0,NULL};
1937 static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line);
1938 static PyCodeObject *__pyx_find_code_object(int code_line);
1939 static void __pyx_insert_code_object(int code_line, PyCodeObject* code_object);
1940 
1941 /* AddTraceback.proto */
1942 static void __Pyx_AddTraceback(const char *funcname, int c_line,
1943                                int py_line, const char *filename);
1944 
1945 #if PY_MAJOR_VERSION < 3
1946     static int __Pyx_GetBuffer(PyObject *obj, Py_buffer *view, int flags);
1947     static void __Pyx_ReleaseBuffer(Py_buffer *view);
1948 #else
1949     #define __Pyx_GetBuffer PyObject_GetBuffer
1950     #define __Pyx_ReleaseBuffer PyBuffer_Release
1951 #endif
1952 
1953 
1954 /* BufferStructDeclare.proto */
1955 typedef struct {
1956   Py_ssize_t shape, strides, suboffsets;
1957 } __Pyx_Buf_DimInfo;
1958 typedef struct {
1959   size_t refcount;
1960   Py_buffer pybuffer;
1961 } __Pyx_Buffer;
1962 typedef struct {
1963   __Pyx_Buffer *rcbuffer;
1964   char *data;
1965   __Pyx_Buf_DimInfo diminfo[8];
1966 } __Pyx_LocalBuf_ND;
1967 
1968 /* MemviewSliceIsContig.proto */
1969 static int __pyx_memviewslice_is_contig(const __Pyx_memviewslice mvs, char order, int ndim);
1970 
1971 /* OverlappingSlices.proto */
1972 static int __pyx_slices_overlap(__Pyx_memviewslice *slice1,
1973                                 __Pyx_memviewslice *slice2,
1974                                 int ndim, size_t itemsize);
1975 
1976 /* Capsule.proto */
1977 static CYTHON_INLINE PyObject *__pyx_capsule_create(void *p, const char *sig);
1978 
1979 /* RealImag.proto */
1980 #if CYTHON_CCOMPLEX
1981   #ifdef __cplusplus
1982     #define __Pyx_CREAL(z) ((z).real())
1983     #define __Pyx_CIMAG(z) ((z).imag())
1984   #else
1985     #define __Pyx_CREAL(z) (__real__(z))
1986     #define __Pyx_CIMAG(z) (__imag__(z))
1987   #endif
1988 #else
1989     #define __Pyx_CREAL(z) ((z).real)
1990     #define __Pyx_CIMAG(z) ((z).imag)
1991 #endif
1992 #if defined(__cplusplus) && CYTHON_CCOMPLEX\
1993         && (defined(_WIN32) || defined(__clang__) || (defined(__GNUC__) && (__GNUC__ >= 5 || __GNUC__ == 4 && __GNUC_MINOR__ >= 4 )) || __cplusplus >= 201103)
1994     #define __Pyx_SET_CREAL(z,x) ((z).real(x))
1995     #define __Pyx_SET_CIMAG(z,y) ((z).imag(y))
1996 #else
1997     #define __Pyx_SET_CREAL(z,x) __Pyx_CREAL(z) = (x)
1998     #define __Pyx_SET_CIMAG(z,y) __Pyx_CIMAG(z) = (y)
1999 #endif
2000 
2001 /* Arithmetic.proto */
2002 #if CYTHON_CCOMPLEX
2003     #define __Pyx_c_eq_double(a, b)   ((a)==(b))
2004     #define __Pyx_c_sum_double(a, b)  ((a)+(b))
2005     #define __Pyx_c_diff_double(a, b) ((a)-(b))
2006     #define __Pyx_c_prod_double(a, b) ((a)*(b))
2007     #define __Pyx_c_quot_double(a, b) ((a)/(b))
2008     #define __Pyx_c_neg_double(a)     (-(a))
2009   #ifdef __cplusplus
2010     #define __Pyx_c_is_zero_double(z) ((z)==(double)0)
2011     #define __Pyx_c_conj_double(z)    (::std::conj(z))
2012     #if 1
2013         #define __Pyx_c_abs_double(z)     (::std::abs(z))
2014         #define __Pyx_c_pow_double(a, b)  (::std::pow(a, b))
2015     #endif
2016   #else
2017     #define __Pyx_c_is_zero_double(z) ((z)==0)
2018     #define __Pyx_c_conj_double(z)    (conj(z))
2019     #if 1
2020         #define __Pyx_c_abs_double(z)     (cabs(z))
2021         #define __Pyx_c_pow_double(a, b)  (cpow(a, b))
2022     #endif
2023  #endif
2024 #else
2025     static CYTHON_INLINE int __Pyx_c_eq_double(__pyx_t_double_complex, __pyx_t_double_complex);
2026     static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_sum_double(__pyx_t_double_complex, __pyx_t_double_complex);
2027     static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_diff_double(__pyx_t_double_complex, __pyx_t_double_complex);
2028     static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_prod_double(__pyx_t_double_complex, __pyx_t_double_complex);
2029     static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_quot_double(__pyx_t_double_complex, __pyx_t_double_complex);
2030     static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_neg_double(__pyx_t_double_complex);
2031     static CYTHON_INLINE int __Pyx_c_is_zero_double(__pyx_t_double_complex);
2032     static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_conj_double(__pyx_t_double_complex);
2033     #if 1
2034         static CYTHON_INLINE double __Pyx_c_abs_double(__pyx_t_double_complex);
2035         static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_pow_double(__pyx_t_double_complex, __pyx_t_double_complex);
2036     #endif
2037 #endif
2038 
2039 /* TypeInfoCompare.proto */
2040 static int __pyx_typeinfo_cmp(__Pyx_TypeInfo *a, __Pyx_TypeInfo *b);
2041 
2042 /* MemviewSliceValidateAndInit.proto */
2043 static int __Pyx_ValidateAndInit_memviewslice(
2044                 int *axes_specs,
2045                 int c_or_f_flag,
2046                 int buf_flags,
2047                 int ndim,
2048                 __Pyx_TypeInfo *dtype,
2049                 __Pyx_BufFmt_StackElem stack[],
2050                 __Pyx_memviewslice *memviewslice,
2051                 PyObject *original_obj);
2052 
2053 /* ObjectToMemviewSlice.proto */
2054 static CYTHON_INLINE __Pyx_memviewslice __Pyx_PyObject_to_MemoryviewSlice_d_dc_int(PyObject *, int writable_flag);
2055 
2056 /* ObjectToMemviewSlice.proto */
2057 static CYTHON_INLINE __Pyx_memviewslice __Pyx_PyObject_to_MemoryviewSlice_dc_int(PyObject *, int writable_flag);
2058 
2059 /* GCCDiagnostics.proto */
2060 #if defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6))
2061 #define __Pyx_HAS_GCC_DIAGNOSTIC
2062 #endif
2063 
2064 /* MemviewDtypeToObject.proto */
2065 static CYTHON_INLINE PyObject *__pyx_memview_get_int(const char *itemp);
2066 static CYTHON_INLINE int __pyx_memview_set_int(const char *itemp, PyObject *obj);
2067 
2068 /* None.proto */
2069 static CYTHON_INLINE long __Pyx_pow_long(long, long);
2070 
2071 /* ToPy.proto */
2072 #define __pyx_PyComplex_FromComplex(z)\
2073         PyComplex_FromDoubles((double)__Pyx_CREAL(z),\
2074                               (double)__Pyx_CIMAG(z))
2075 
2076 /* FromPy.proto */
2077 static __pyx_t_double_complex __Pyx_PyComplex_As___pyx_t_double_complex(PyObject*);
2078 
2079 /* MemviewDtypeToObject.proto */
2080 static CYTHON_INLINE PyObject *__pyx_memview_get___pyx_t_double_complex(const char *itemp);
2081 static CYTHON_INLINE int __pyx_memview_set___pyx_t_double_complex(const char *itemp, PyObject *obj);
2082 
2083 /* Arithmetic.proto */
2084 #if CYTHON_CCOMPLEX
2085     #define __Pyx_c_eq_float(a, b)   ((a)==(b))
2086     #define __Pyx_c_sum_float(a, b)  ((a)+(b))
2087     #define __Pyx_c_diff_float(a, b) ((a)-(b))
2088     #define __Pyx_c_prod_float(a, b) ((a)*(b))
2089     #define __Pyx_c_quot_float(a, b) ((a)/(b))
2090     #define __Pyx_c_neg_float(a)     (-(a))
2091   #ifdef __cplusplus
2092     #define __Pyx_c_is_zero_float(z) ((z)==(float)0)
2093     #define __Pyx_c_conj_float(z)    (::std::conj(z))
2094     #if 1
2095         #define __Pyx_c_abs_float(z)     (::std::abs(z))
2096         #define __Pyx_c_pow_float(a, b)  (::std::pow(a, b))
2097     #endif
2098   #else
2099     #define __Pyx_c_is_zero_float(z) ((z)==0)
2100     #define __Pyx_c_conj_float(z)    (conjf(z))
2101     #if 1
2102         #define __Pyx_c_abs_float(z)     (cabsf(z))
2103         #define __Pyx_c_pow_float(a, b)  (cpowf(a, b))
2104     #endif
2105  #endif
2106 #else
2107     static CYTHON_INLINE int __Pyx_c_eq_float(__pyx_t_float_complex, __pyx_t_float_complex);
2108     static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_sum_float(__pyx_t_float_complex, __pyx_t_float_complex);
2109     static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_diff_float(__pyx_t_float_complex, __pyx_t_float_complex);
2110     static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_prod_float(__pyx_t_float_complex, __pyx_t_float_complex);
2111     static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_quot_float(__pyx_t_float_complex, __pyx_t_float_complex);
2112     static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_neg_float(__pyx_t_float_complex);
2113     static CYTHON_INLINE int __Pyx_c_is_zero_float(__pyx_t_float_complex);
2114     static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_conj_float(__pyx_t_float_complex);
2115     #if 1
2116         static CYTHON_INLINE float __Pyx_c_abs_float(__pyx_t_float_complex);
2117         static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_pow_float(__pyx_t_float_complex, __pyx_t_float_complex);
2118     #endif
2119 #endif
2120 
2121 /* MemviewSliceCopyTemplate.proto */
2122 static __Pyx_memviewslice
2123 __pyx_memoryview_copy_new_contig(const __Pyx_memviewslice *from_mvs,
2124                                  const char *mode, int ndim,
2125                                  size_t sizeof_dtype, int contig_flag,
2126                                  int dtype_is_object);
2127 
2128 /* CIntFromPy.proto */
2129 static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *);
2130 
2131 /* CIntToPy.proto */
2132 static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value);
2133 
2134 /* CIntFromPy.proto */
2135 static CYTHON_INLINE size_t __Pyx_PyInt_As_size_t(PyObject *);
2136 
2137 /* CIntToPy.proto */
2138 static CYTHON_INLINE PyObject* __Pyx_PyInt_From_Py_intptr_t(Py_intptr_t value);
2139 
2140 /* CIntToPy.proto */
2141 static CYTHON_INLINE PyObject* __Pyx_PyInt_From_int(int value);
2142 
2143 /* CIntFromPy.proto */
2144 static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *);
2145 
2146 /* CIntFromPy.proto */
2147 static CYTHON_INLINE char __Pyx_PyInt_As_char(PyObject *);
2148 
2149 /* ObjectToMemviewSlice.proto */
2150 static CYTHON_INLINE __Pyx_memviewslice __Pyx_PyObject_to_MemoryviewSlice_d_dc___pyx_t_double_complex(PyObject *, int writable_flag);
2151 
2152 /* CheckBinaryVersion.proto */
2153 static int __Pyx_check_binary_version(void);
2154 
2155 /* InitStrings.proto */
2156 static int __Pyx_InitStrings(__Pyx_StringTabEntry *t);
2157 
2158 static PyObject *__pyx_array_get_memview(struct __pyx_array_obj *__pyx_v_self); /* proto*/
2159 static char *__pyx_memoryview_get_item_pointer(struct __pyx_memoryview_obj *__pyx_v_self, PyObject *__pyx_v_index); /* proto*/
2160 static PyObject *__pyx_memoryview_is_slice(struct __pyx_memoryview_obj *__pyx_v_self, PyObject *__pyx_v_obj); /* proto*/
2161 static PyObject *__pyx_memoryview_setitem_slice_assignment(struct __pyx_memoryview_obj *__pyx_v_self, PyObject *__pyx_v_dst, PyObject *__pyx_v_src); /* proto*/
2162 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*/
2163 static PyObject *__pyx_memoryview_setitem_indexed(struct __pyx_memoryview_obj *__pyx_v_self, PyObject *__pyx_v_index, PyObject *__pyx_v_value); /* proto*/
2164 static PyObject *__pyx_memoryview_convert_item_to_object(struct __pyx_memoryview_obj *__pyx_v_self, char *__pyx_v_itemp); /* proto*/
2165 static PyObject *__pyx_memoryview_assign_item_from_object(struct __pyx_memoryview_obj *__pyx_v_self, char *__pyx_v_itemp, PyObject *__pyx_v_value); /* proto*/
2166 static PyObject *__pyx_memoryviewslice_convert_item_to_object(struct __pyx_memoryviewslice_obj *__pyx_v_self, char *__pyx_v_itemp); /* proto*/
2167 static PyObject *__pyx_memoryviewslice_assign_item_from_object(struct __pyx_memoryviewslice_obj *__pyx_v_self, char *__pyx_v_itemp, PyObject *__pyx_v_value); /* proto*/
2168 
2169 /* Module declarations from 'cpython.buffer' */
2170 
2171 /* Module declarations from 'libc.string' */
2172 
2173 /* Module declarations from 'libc.stdio' */
2174 
2175 /* Module declarations from '__builtin__' */
2176 
2177 /* Module declarations from 'cpython.type' */
2178 static PyTypeObject *__pyx_ptype_7cpython_4type_type = 0;
2179 
2180 /* Module declarations from 'cpython' */
2181 
2182 /* Module declarations from 'cpython.object' */
2183 
2184 /* Module declarations from 'cpython.ref' */
2185 
2186 /* Module declarations from 'cpython.mem' */
2187 
2188 /* Module declarations from 'numpy' */
2189 
2190 /* Module declarations from 'numpy' */
2191 static PyTypeObject *__pyx_ptype_5numpy_dtype = 0;
2192 static PyTypeObject *__pyx_ptype_5numpy_flatiter = 0;
2193 static PyTypeObject *__pyx_ptype_5numpy_broadcast = 0;
2194 static PyTypeObject *__pyx_ptype_5numpy_ndarray = 0;
2195 static PyTypeObject *__pyx_ptype_5numpy_ufunc = 0;
2196 
2197 /* Module declarations from 'cython.view' */
2198 
2199 /* Module declarations from 'cython' */
2200 
2201 /* Module declarations from 'libc.math' */
2202 
2203 /* Module declarations from 'qutip.cy.ptrace' */
2204 static PyTypeObject *__pyx_array_type = 0;
2205 static PyTypeObject *__pyx_MemviewEnum_type = 0;
2206 static PyTypeObject *__pyx_memoryview_type = 0;
2207 static PyTypeObject *__pyx_memoryviewslice_type = 0;
2208 static PyObject *generic = 0;
2209 static PyObject *strided = 0;
2210 static PyObject *indirect = 0;
2211 static PyObject *contiguous = 0;
2212 static PyObject *indirect_contiguous = 0;
2213 static int __pyx_memoryview_thread_locks_used;
2214 static PyThread_type_lock __pyx_memoryview_thread_locks[8];
2215 static PyArrayObject *__pyx_f_5qutip_2cy_6ptrace__list2ind(__Pyx_memviewslice, __Pyx_memviewslice, int __pyx_skip_dispatch); /*proto*/
2216 static PyArrayObject *__pyx_f_5qutip_2cy_6ptrace__select(__Pyx_memviewslice, __Pyx_memviewslice, int, int __pyx_skip_dispatch); /*proto*/
2217 static int __pyx_f_5qutip_2cy_6ptrace__in(int, __Pyx_memviewslice); /*proto*/
2218 static void __pyx_f_5qutip_2cy_6ptrace__i2_k_t(int, __Pyx_memviewslice, __Pyx_memviewslice); /*proto*/
2219 static PyObject *__pyx_f_5qutip_2cy_6ptrace__ptrace_core_sp(PyObject *, __Pyx_memviewslice, int); /*proto*/
2220 static PyObject *__pyx_f_5qutip_2cy_6ptrace__ptrace_core_dense(PyObject *, __Pyx_memviewslice, int); /*proto*/
2221 static struct __pyx_array_obj *__pyx_array_new(PyObject *, Py_ssize_t, char *, char *, char *); /*proto*/
2222 static void *__pyx_align_pointer(void *, size_t); /*proto*/
2223 static PyObject *__pyx_memoryview_new(PyObject *, int, int, __Pyx_TypeInfo *); /*proto*/
2224 static CYTHON_INLINE int __pyx_memoryview_check(PyObject *); /*proto*/
2225 static PyObject *_unellipsify(PyObject *, int); /*proto*/
2226 static PyObject *assert_direct_dimensions(Py_ssize_t *, int); /*proto*/
2227 static struct __pyx_memoryview_obj *__pyx_memview_slice(struct __pyx_memoryview_obj *, PyObject *); /*proto*/
2228 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*/
2229 static char *__pyx_pybuffer_index(Py_buffer *, char *, Py_ssize_t, Py_ssize_t); /*proto*/
2230 static int __pyx_memslice_transpose(__Pyx_memviewslice *); /*proto*/
2231 static PyObject *__pyx_memoryview_fromslice(__Pyx_memviewslice, int, PyObject *(*)(char *), int (*)(char *, PyObject *), int); /*proto*/
2232 static __Pyx_memviewslice *__pyx_memoryview_get_slice_from_memoryview(struct __pyx_memoryview_obj *, __Pyx_memviewslice *); /*proto*/
2233 static void __pyx_memoryview_slice_copy(struct __pyx_memoryview_obj *, __Pyx_memviewslice *); /*proto*/
2234 static PyObject *__pyx_memoryview_copy_object(struct __pyx_memoryview_obj *); /*proto*/
2235 static PyObject *__pyx_memoryview_copy_object_from_slice(struct __pyx_memoryview_obj *, __Pyx_memviewslice *); /*proto*/
2236 static Py_ssize_t abs_py_ssize_t(Py_ssize_t); /*proto*/
2237 static char __pyx_get_best_slice_order(__Pyx_memviewslice *, int); /*proto*/
2238 static void _copy_strided_to_strided(char *, Py_ssize_t *, char *, Py_ssize_t *, Py_ssize_t *, Py_ssize_t *, int, size_t); /*proto*/
2239 static void copy_strided_to_strided(__Pyx_memviewslice *, __Pyx_memviewslice *, int, size_t); /*proto*/
2240 static Py_ssize_t __pyx_memoryview_slice_get_size(__Pyx_memviewslice *, int); /*proto*/
2241 static Py_ssize_t __pyx_fill_contig_strides_array(Py_ssize_t *, Py_ssize_t *, Py_ssize_t, int, char); /*proto*/
2242 static void *__pyx_memoryview_copy_data_to_temp(__Pyx_memviewslice *, __Pyx_memviewslice *, char, int); /*proto*/
2243 static int __pyx_memoryview_err_extents(int, Py_ssize_t, Py_ssize_t); /*proto*/
2244 static int __pyx_memoryview_err_dim(PyObject *, char *, int); /*proto*/
2245 static int __pyx_memoryview_err(PyObject *, char *); /*proto*/
2246 static int __pyx_memoryview_copy_contents(__Pyx_memviewslice, __Pyx_memviewslice, int, int, int); /*proto*/
2247 static void __pyx_memoryview_broadcast_leading(__Pyx_memviewslice *, int, int); /*proto*/
2248 static void __pyx_memoryview_refcount_copying(__Pyx_memviewslice *, int, int, int); /*proto*/
2249 static void __pyx_memoryview_refcount_objects_in_slice_with_gil(char *, Py_ssize_t *, Py_ssize_t *, int, int); /*proto*/
2250 static void __pyx_memoryview_refcount_objects_in_slice(char *, Py_ssize_t *, Py_ssize_t *, int, int); /*proto*/
2251 static void __pyx_memoryview_slice_assign_scalar(__Pyx_memviewslice *, int, size_t, void *, int); /*proto*/
2252 static void __pyx_memoryview__slice_assign_scalar(char *, Py_ssize_t *, Py_ssize_t *, int, size_t, void *); /*proto*/
2253 static PyObject *__pyx_unpickle_Enum__set_state(struct __pyx_MemviewEnum_obj *, PyObject *); /*proto*/
2254 static __Pyx_TypeInfo __Pyx_TypeInfo_int = { "int", NULL, sizeof(int), { 0 }, 0, IS_UNSIGNED(int) ? 'U' : 'I', IS_UNSIGNED(int), 0 };
2255 static __Pyx_TypeInfo __Pyx_TypeInfo___pyx_t_double_complex = { "double complex", NULL, sizeof(__pyx_t_double_complex), { 0 }, 0, 'C', 0, 0 };
2256 #define __Pyx_MODULE_NAME "qutip.cy.ptrace"
2257 extern int __pyx_module_is_main_qutip__cy__ptrace;
2258 int __pyx_module_is_main_qutip__cy__ptrace = 0;
2259 
2260 /* Implementation of 'qutip.cy.ptrace' */
2261 static PyObject *__pyx_builtin_range;
2262 static PyObject *__pyx_builtin_TypeError;
2263 static PyObject *__pyx_builtin_IndexError;
2264 static PyObject *__pyx_builtin_ValueError;
2265 static PyObject *__pyx_builtin_ImportError;
2266 static PyObject *__pyx_builtin_MemoryError;
2267 static PyObject *__pyx_builtin_enumerate;
2268 static PyObject *__pyx_builtin_Ellipsis;
2269 static PyObject *__pyx_builtin_id;
2270 static const char __pyx_k_M[] = "M";
2271 static const char __pyx_k_N[] = "N";
2272 static const char __pyx_k_O[] = "O";
2273 static const char __pyx_k_R[] = "R";
2274 static const char __pyx_k_c[] = "c";
2275 static const char __pyx_k_id[] = "id";
2276 static const char __pyx_k_ii[] = "ii";
2277 static const char __pyx_k_mm[] = "mm";
2278 static const char __pyx_k_np[] = "np";
2279 static const char __pyx_k_sp[] = "sp";
2280 static const char __pyx_k__24[] = "*";
2281 static const char __pyx_k_dag[] = "dag";
2282 static const char __pyx_k_dot[] = "dot";
2283 static const char __pyx_k_ind[] = "ind";
2284 static const char __pyx_k_new[] = "__new__";
2285 static const char __pyx_k_nnz[] = "nnz";
2286 static const char __pyx_k_obj[] = "obj";
2287 static const char __pyx_k_ptr[] = "ptr";
2288 static const char __pyx_k_rho[] = "rho";
2289 static const char __pyx_k_sel[] = "_sel";
2290 static const char __pyx_k_tmp[] = "_tmp";
2291 static const char __pyx_k_base[] = "base";
2292 static const char __pyx_k_copy[] = "copy";
2293 static const char __pyx_k_data[] = "data";
2294 static const char __pyx_k_dict[] = "__dict__";
2295 static const char __pyx_k_dims[] = "dims";
2296 static const char __pyx_k_drho[] = "drho";
2297 static const char __pyx_k_main[] = "__main__";
2298 static const char __pyx_k_mode[] = "mode";
2299 static const char __pyx_k_name[] = "name";
2300 static const char __pyx_k_ndim[] = "ndim";
2301 static const char __pyx_k_ones[] = "ones";
2302 static const char __pyx_k_oper[] = "_oper";
2303 static const char __pyx_k_pack[] = "pack";
2304 static const char __pyx_k_perm[] = "perm";
2305 static const char __pyx_k_prod[] = "prod";
2306 static const char __pyx_k_rest[] = "rest";
2307 static const char __pyx_k_size[] = "size";
2308 static const char __pyx_k_sort[] = "sort";
2309 static const char __pyx_k_step[] = "step";
2310 static const char __pyx_k_stop[] = "stop";
2311 static const char __pyx_k_take[] = "take";
2312 static const char __pyx_k_test[] = "__test__";
2313 static const char __pyx_k_ASCII[] = "ASCII";
2314 static const char __pyx_k_array[] = "array";
2315 static const char __pyx_k_class[] = "__class__";
2316 static const char __pyx_k_dtype[] = "dtype";
2317 static const char __pyx_k_empty[] = "empty";
2318 static const char __pyx_k_error[] = "error";
2319 static const char __pyx_k_flags[] = "flags";
2320 static const char __pyx_k_ilist[] = "ilist";
2321 static const char __pyx_k_int32[] = "int32";
2322 static const char __pyx_k_numpy[] = "numpy";
2323 static const char __pyx_k_range[] = "range";
2324 static const char __pyx_k_ravel[] = "ravel";
2325 static const char __pyx_k_sel_2[] = "sel";
2326 static const char __pyx_k_shape[] = "shape";
2327 static const char __pyx_k_start[] = "start";
2328 static const char __pyx_k_tocsr[] = "tocsr";
2329 static const char __pyx_k_zeros[] = "zeros";
2330 static const char __pyx_k_arange[] = "arange";
2331 static const char __pyx_k_delete[] = "delete";
2332 static const char __pyx_k_encode[] = "encode";
2333 static const char __pyx_k_format[] = "format";
2334 static const char __pyx_k_import[] = "__import__";
2335 static const char __pyx_k_indptr[] = "indptr";
2336 static const char __pyx_k_indsel[] = "indsel";
2337 static const char __pyx_k_name_2[] = "__name__";
2338 static const char __pyx_k_pickle[] = "pickle";
2339 static const char __pyx_k_ptrace[] = "_ptrace";
2340 static const char __pyx_k_reduce[] = "__reduce__";
2341 static const char __pyx_k_rhdata[] = "rhdata";
2342 static const char __pyx_k_sorted[] = "sorted";
2343 static const char __pyx_k_struct[] = "struct";
2344 static const char __pyx_k_tolist[] = "tolist";
2345 static const char __pyx_k_unpack[] = "unpack";
2346 static const char __pyx_k_update[] = "update";
2347 static const char __pyx_k_asarray[] = "asarray";
2348 static const char __pyx_k_fortran[] = "fortran";
2349 static const char __pyx_k_indices[] = "indices";
2350 static const char __pyx_k_indrest[] = "indrest";
2351 static const char __pyx_k_memview[] = "memview";
2352 static const char __pyx_k_Ellipsis[] = "Ellipsis";
2353 static const char __pyx_k_csr2fast[] = "csr2fast";
2354 static const char __pyx_k_getstate[] = "__getstate__";
2355 static const char __pyx_k_ilistsel[] = "ilistsel";
2356 static const char __pyx_k_itemsize[] = "itemsize";
2357 static const char __pyx_k_num_dims[] = "num_dims";
2358 static const char __pyx_k_pyx_type[] = "__pyx_type";
2359 static const char __pyx_k_setstate[] = "__setstate__";
2360 static const char __pyx_k_TypeError[] = "TypeError";
2361 static const char __pyx_k_enumerate[] = "enumerate";
2362 static const char __pyx_k_ilistrest[] = "ilistrest";
2363 static const char __pyx_k_ones_like[] = "ones_like";
2364 static const char __pyx_k_pyx_state[] = "__pyx_state";
2365 static const char __pyx_k_reduce_ex[] = "__reduce_ex__";
2366 static const char __pyx_k_rho1_data[] = "rho1_data";
2367 static const char __pyx_k_rho1_dims[] = "rho1_dims";
2368 static const char __pyx_k_zcsr_mult[] = "zcsr_mult";
2369 static const char __pyx_k_IndexError[] = "IndexError";
2370 static const char __pyx_k_ValueError[] = "ValueError";
2371 static const char __pyx_k_coo_matrix[] = "coo_matrix";
2372 static const char __pyx_k_dims_kept0[] = "dims_kept0";
2373 static const char __pyx_k_pyx_result[] = "__pyx_result";
2374 static const char __pyx_k_pyx_vtable[] = "__pyx_vtable__";
2375 static const char __pyx_k_rho1_shape[] = "rho1_shape";
2376 static const char __pyx_k_ImportError[] = "ImportError";
2377 static const char __pyx_k_MemoryError[] = "MemoryError";
2378 static const char __pyx_k_PickleError[] = "PickleError";
2379 static const char __pyx_k_factor_keep[] = "factor_keep";
2380 static const char __pyx_k_factor_trace[] = "factor_trace";
2381 static const char __pyx_k_pyx_checksum[] = "__pyx_checksum";
2382 static const char __pyx_k_scipy_sparse[] = "scipy.sparse";
2383 static const char __pyx_k_stringsource[] = "stringsource";
2384 static const char __pyx_k_tensor_table[] = "tensor_table";
2385 static const char __pyx_k_zcsr_reshape[] = "zcsr_reshape";
2386 static const char __pyx_k_factor_tensor[] = "factor_tensor";
2387 static const char __pyx_k_ptrace_legacy[] = "_ptrace_legacy";
2388 static const char __pyx_k_pyx_getbuffer[] = "__pyx_getbuffer";
2389 static const char __pyx_k_reduce_cython[] = "__reduce_cython__";
2390 static const char __pyx_k_View_MemoryView[] = "View.MemoryView";
2391 static const char __pyx_k_allocate_buffer[] = "allocate_buffer";
2392 static const char __pyx_k_dtype_is_object[] = "dtype_is_object";
2393 static const char __pyx_k_fast_csr_matrix[] = "fast_csr_matrix";
2394 static const char __pyx_k_pyx_PickleError[] = "__pyx_PickleError";
2395 static const char __pyx_k_qutip_cy_ptrace[] = "qutip.cy.ptrace";
2396 static const char __pyx_k_qutip_cy_spmath[] = "qutip.cy.spmath";
2397 static const char __pyx_k_setstate_cython[] = "__setstate_cython__";
2398 static const char __pyx_k_qutip_fastsparse[] = "qutip.fastsparse";
2399 static const char __pyx_k_pyx_unpickle_Enum[] = "__pyx_unpickle_Enum";
2400 static const char __pyx_k_cline_in_traceback[] = "cline_in_traceback";
2401 static const char __pyx_k_qutip_cy_spconvert[] = "qutip.cy.spconvert";
2402 static const char __pyx_k_strided_and_direct[] = "<strided and direct>";
2403 static const char __pyx_k_qutip_cy_ptrace_pyx[] = "qutip/cy/ptrace.pyx";
2404 static const char __pyx_k_strided_and_indirect[] = "<strided and indirect>";
2405 static const char __pyx_k_contiguous_and_direct[] = "<contiguous and direct>";
2406 static const char __pyx_k_MemoryView_of_r_object[] = "<MemoryView of %r object>";
2407 static const char __pyx_k_MemoryView_of_r_at_0x_x[] = "<MemoryView of %r at 0x%x>";
2408 static const char __pyx_k_contiguous_and_indirect[] = "<contiguous and indirect>";
2409 static const char __pyx_k_Cannot_index_with_type_s[] = "Cannot index with type '%s'";
2410 static const char __pyx_k_Invalid_shape_in_axis_d_d[] = "Invalid shape in axis %d: %d.";
2411 static const char __pyx_k_itemsize_0_for_cython_array[] = "itemsize <= 0 for cython.array";
2412 static const char __pyx_k_unable_to_allocate_array_data[] = "unable to allocate array data.";
2413 static const char __pyx_k_strided_and_direct_or_indirect[] = "<strided and direct or indirect>";
2414 static const char __pyx_k_numpy_core_multiarray_failed_to[] = "numpy.core.multiarray failed to import";
2415 static const char __pyx_k_Buffer_view_does_not_expose_stri[] = "Buffer view does not expose strides";
2416 static const char __pyx_k_Can_only_create_a_buffer_that_is[] = "Can only create a buffer that is contiguous in memory.";
2417 static const char __pyx_k_Cannot_assign_to_read_only_memor[] = "Cannot assign to read-only memoryview";
2418 static const char __pyx_k_Cannot_create_writable_memory_vi[] = "Cannot create writable memory view from read-only memoryview";
2419 static const char __pyx_k_Duplicate_selection_index_in_ptr[] = "Duplicate selection index in ptrace.";
2420 static const char __pyx_k_Empty_shape_tuple_for_cython_arr[] = "Empty shape tuple for cython.array";
2421 static const char __pyx_k_Incompatible_checksums_s_vs_0xb0[] = "Incompatible checksums (%s vs 0xb068931 = (name))";
2422 static const char __pyx_k_Indirect_dimensions_not_supporte[] = "Indirect dimensions not supported";
2423 static const char __pyx_k_Invalid_mode_expected_c_or_fortr[] = "Invalid mode, expected 'c' or 'fortran', got %s";
2424 static const char __pyx_k_Invalid_selection_index_in_ptrac[] = "Invalid selection index in ptrace.";
2425 static const char __pyx_k_Out_of_bounds_on_buffer_access_a[] = "Out of bounds on buffer access (axis %d)";
2426 static const char __pyx_k_Unable_to_convert_item_to_object[] = "Unable to convert item to object";
2427 static const char __pyx_k_got_differing_extents_in_dimensi[] = "got differing extents in dimension %d (got %d and %d)";
2428 static const char __pyx_k_no_default___reduce___due_to_non[] = "no default __reduce__ due to non-trivial __cinit__";
2429 static const char __pyx_k_numpy_core_umath_failed_to_impor[] = "numpy.core.umath failed to import";
2430 static const char __pyx_k_unable_to_allocate_shape_and_str[] = "unable to allocate shape and strides.";
2431 static PyObject *__pyx_n_s_ASCII;
2432 static PyObject *__pyx_kp_s_Buffer_view_does_not_expose_stri;
2433 static PyObject *__pyx_kp_s_Can_only_create_a_buffer_that_is;
2434 static PyObject *__pyx_kp_s_Cannot_assign_to_read_only_memor;
2435 static PyObject *__pyx_kp_s_Cannot_create_writable_memory_vi;
2436 static PyObject *__pyx_kp_s_Cannot_index_with_type_s;
2437 static PyObject *__pyx_kp_u_Duplicate_selection_index_in_ptr;
2438 static PyObject *__pyx_n_s_Ellipsis;
2439 static PyObject *__pyx_kp_s_Empty_shape_tuple_for_cython_arr;
2440 static PyObject *__pyx_n_s_ImportError;
2441 static PyObject *__pyx_kp_s_Incompatible_checksums_s_vs_0xb0;
2442 static PyObject *__pyx_n_s_IndexError;
2443 static PyObject *__pyx_kp_s_Indirect_dimensions_not_supporte;
2444 static PyObject *__pyx_kp_s_Invalid_mode_expected_c_or_fortr;
2445 static PyObject *__pyx_kp_u_Invalid_selection_index_in_ptrac;
2446 static PyObject *__pyx_kp_s_Invalid_shape_in_axis_d_d;
2447 static PyObject *__pyx_n_s_M;
2448 static PyObject *__pyx_n_s_MemoryError;
2449 static PyObject *__pyx_kp_s_MemoryView_of_r_at_0x_x;
2450 static PyObject *__pyx_kp_s_MemoryView_of_r_object;
2451 static PyObject *__pyx_n_s_N;
2452 static PyObject *__pyx_n_b_O;
2453 static PyObject *__pyx_kp_s_Out_of_bounds_on_buffer_access_a;
2454 static PyObject *__pyx_n_s_PickleError;
2455 static PyObject *__pyx_n_s_R;
2456 static PyObject *__pyx_n_s_TypeError;
2457 static PyObject *__pyx_kp_s_Unable_to_convert_item_to_object;
2458 static PyObject *__pyx_n_s_ValueError;
2459 static PyObject *__pyx_n_s_View_MemoryView;
2460 static PyObject *__pyx_n_s__24;
2461 static PyObject *__pyx_n_s_allocate_buffer;
2462 static PyObject *__pyx_n_s_arange;
2463 static PyObject *__pyx_n_s_array;
2464 static PyObject *__pyx_n_s_asarray;
2465 static PyObject *__pyx_n_s_base;
2466 static PyObject *__pyx_n_s_c;
2467 static PyObject *__pyx_n_u_c;
2468 static PyObject *__pyx_n_s_class;
2469 static PyObject *__pyx_n_s_cline_in_traceback;
2470 static PyObject *__pyx_kp_s_contiguous_and_direct;
2471 static PyObject *__pyx_kp_s_contiguous_and_indirect;
2472 static PyObject *__pyx_n_s_coo_matrix;
2473 static PyObject *__pyx_n_s_copy;
2474 static PyObject *__pyx_n_s_csr2fast;
2475 static PyObject *__pyx_n_s_dag;
2476 static PyObject *__pyx_n_s_data;
2477 static PyObject *__pyx_n_s_delete;
2478 static PyObject *__pyx_n_s_dict;
2479 static PyObject *__pyx_n_s_dims;
2480 static PyObject *__pyx_n_s_dims_kept0;
2481 static PyObject *__pyx_n_s_dot;
2482 static PyObject *__pyx_n_s_drho;
2483 static PyObject *__pyx_n_s_dtype;
2484 static PyObject *__pyx_n_s_dtype_is_object;
2485 static PyObject *__pyx_n_s_empty;
2486 static PyObject *__pyx_n_s_encode;
2487 static PyObject *__pyx_n_s_enumerate;
2488 static PyObject *__pyx_n_s_error;
2489 static PyObject *__pyx_n_s_factor_keep;
2490 static PyObject *__pyx_n_s_factor_tensor;
2491 static PyObject *__pyx_n_s_factor_trace;
2492 static PyObject *__pyx_n_s_fast_csr_matrix;
2493 static PyObject *__pyx_n_s_flags;
2494 static PyObject *__pyx_n_s_format;
2495 static PyObject *__pyx_n_s_fortran;
2496 static PyObject *__pyx_n_u_fortran;
2497 static PyObject *__pyx_n_s_getstate;
2498 static PyObject *__pyx_kp_s_got_differing_extents_in_dimensi;
2499 static PyObject *__pyx_n_s_id;
2500 static PyObject *__pyx_n_s_ii;
2501 static PyObject *__pyx_n_s_ilist;
2502 static PyObject *__pyx_n_s_ilistrest;
2503 static PyObject *__pyx_n_s_ilistsel;
2504 static PyObject *__pyx_n_s_import;
2505 static PyObject *__pyx_n_s_ind;
2506 static PyObject *__pyx_n_s_indices;
2507 static PyObject *__pyx_n_s_indptr;
2508 static PyObject *__pyx_n_s_indrest;
2509 static PyObject *__pyx_n_s_indsel;
2510 static PyObject *__pyx_n_s_int32;
2511 static PyObject *__pyx_n_s_itemsize;
2512 static PyObject *__pyx_kp_s_itemsize_0_for_cython_array;
2513 static PyObject *__pyx_n_s_main;
2514 static PyObject *__pyx_n_s_memview;
2515 static PyObject *__pyx_n_s_mm;
2516 static PyObject *__pyx_n_s_mode;
2517 static PyObject *__pyx_n_s_name;
2518 static PyObject *__pyx_n_s_name_2;
2519 static PyObject *__pyx_n_s_ndim;
2520 static PyObject *__pyx_n_s_new;
2521 static PyObject *__pyx_n_s_nnz;
2522 static PyObject *__pyx_kp_s_no_default___reduce___due_to_non;
2523 static PyObject *__pyx_n_s_np;
2524 static PyObject *__pyx_n_s_num_dims;
2525 static PyObject *__pyx_n_s_numpy;
2526 static PyObject *__pyx_kp_u_numpy_core_multiarray_failed_to;
2527 static PyObject *__pyx_kp_u_numpy_core_umath_failed_to_impor;
2528 static PyObject *__pyx_n_s_obj;
2529 static PyObject *__pyx_n_s_ones;
2530 static PyObject *__pyx_n_s_ones_like;
2531 static PyObject *__pyx_n_s_oper;
2532 static PyObject *__pyx_n_s_pack;
2533 static PyObject *__pyx_n_s_perm;
2534 static PyObject *__pyx_n_s_pickle;
2535 static PyObject *__pyx_n_s_prod;
2536 static PyObject *__pyx_n_s_ptr;
2537 static PyObject *__pyx_n_s_ptrace;
2538 static PyObject *__pyx_n_s_ptrace_legacy;
2539 static PyObject *__pyx_n_s_pyx_PickleError;
2540 static PyObject *__pyx_n_s_pyx_checksum;
2541 static PyObject *__pyx_n_s_pyx_getbuffer;
2542 static PyObject *__pyx_n_s_pyx_result;
2543 static PyObject *__pyx_n_s_pyx_state;
2544 static PyObject *__pyx_n_s_pyx_type;
2545 static PyObject *__pyx_n_s_pyx_unpickle_Enum;
2546 static PyObject *__pyx_n_s_pyx_vtable;
2547 static PyObject *__pyx_n_s_qutip_cy_ptrace;
2548 static PyObject *__pyx_kp_s_qutip_cy_ptrace_pyx;
2549 static PyObject *__pyx_n_s_qutip_cy_spconvert;
2550 static PyObject *__pyx_n_s_qutip_cy_spmath;
2551 static PyObject *__pyx_n_s_qutip_fastsparse;
2552 static PyObject *__pyx_n_s_range;
2553 static PyObject *__pyx_n_s_ravel;
2554 static PyObject *__pyx_n_s_reduce;
2555 static PyObject *__pyx_n_s_reduce_cython;
2556 static PyObject *__pyx_n_s_reduce_ex;
2557 static PyObject *__pyx_n_s_rest;
2558 static PyObject *__pyx_n_s_rhdata;
2559 static PyObject *__pyx_n_s_rho;
2560 static PyObject *__pyx_n_s_rho1_data;
2561 static PyObject *__pyx_n_s_rho1_dims;
2562 static PyObject *__pyx_n_s_rho1_shape;
2563 static PyObject *__pyx_n_s_scipy_sparse;
2564 static PyObject *__pyx_n_s_sel;
2565 static PyObject *__pyx_n_s_sel_2;
2566 static PyObject *__pyx_n_s_setstate;
2567 static PyObject *__pyx_n_s_setstate_cython;
2568 static PyObject *__pyx_n_s_shape;
2569 static PyObject *__pyx_n_s_size;
2570 static PyObject *__pyx_n_s_sort;
2571 static PyObject *__pyx_n_s_sorted;
2572 static PyObject *__pyx_n_s_sp;
2573 static PyObject *__pyx_n_s_start;
2574 static PyObject *__pyx_n_s_step;
2575 static PyObject *__pyx_n_s_stop;
2576 static PyObject *__pyx_kp_s_strided_and_direct;
2577 static PyObject *__pyx_kp_s_strided_and_direct_or_indirect;
2578 static PyObject *__pyx_kp_s_strided_and_indirect;
2579 static PyObject *__pyx_kp_s_stringsource;
2580 static PyObject *__pyx_n_s_struct;
2581 static PyObject *__pyx_n_s_take;
2582 static PyObject *__pyx_n_s_tensor_table;
2583 static PyObject *__pyx_n_s_test;
2584 static PyObject *__pyx_n_s_tmp;
2585 static PyObject *__pyx_n_s_tocsr;
2586 static PyObject *__pyx_n_s_tolist;
2587 static PyObject *__pyx_kp_s_unable_to_allocate_array_data;
2588 static PyObject *__pyx_kp_s_unable_to_allocate_shape_and_str;
2589 static PyObject *__pyx_n_s_unpack;
2590 static PyObject *__pyx_n_s_update;
2591 static PyObject *__pyx_n_s_zcsr_mult;
2592 static PyObject *__pyx_n_s_zcsr_reshape;
2593 static PyObject *__pyx_n_s_zeros;
2594 static PyObject *__pyx_pf_5qutip_2cy_6ptrace__ptrace_legacy(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_rho, PyObject *__pyx_v__sel); /* proto */
2595 static PyObject *__pyx_pf_5qutip_2cy_6ptrace_2_list2ind(CYTHON_UNUSED PyObject *__pyx_self, __Pyx_memviewslice __pyx_v_ilist, __Pyx_memviewslice __pyx_v_dims); /* proto */
2596 static PyObject *__pyx_pf_5qutip_2cy_6ptrace_4_select(CYTHON_UNUSED PyObject *__pyx_self, __Pyx_memviewslice __pyx_v_sel, __Pyx_memviewslice __pyx_v_dims, int __pyx_v_M); /* proto */
2597 static PyObject *__pyx_pf_5qutip_2cy_6ptrace_6_ptrace(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_rho, PyObject *__pyx_v_sel); /* proto */
2598 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 */
2599 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 */
2600 static void __pyx_array___pyx_pf_15View_dot_MemoryView_5array_4__dealloc__(struct __pyx_array_obj *__pyx_v_self); /* proto */
2601 static PyObject *__pyx_pf_15View_dot_MemoryView_5array_7memview___get__(struct __pyx_array_obj *__pyx_v_self); /* proto */
2602 static Py_ssize_t __pyx_array___pyx_pf_15View_dot_MemoryView_5array_6__len__(struct __pyx_array_obj *__pyx_v_self); /* proto */
2603 static PyObject *__pyx_array___pyx_pf_15View_dot_MemoryView_5array_8__getattr__(struct __pyx_array_obj *__pyx_v_self, PyObject *__pyx_v_attr); /* proto */
2604 static PyObject *__pyx_array___pyx_pf_15View_dot_MemoryView_5array_10__getitem__(struct __pyx_array_obj *__pyx_v_self, PyObject *__pyx_v_item); /* proto */
2605 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 */
2606 static PyObject *__pyx_pf___pyx_array___reduce_cython__(CYTHON_UNUSED struct __pyx_array_obj *__pyx_v_self); /* proto */
2607 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 */
2608 static int __pyx_MemviewEnum___pyx_pf_15View_dot_MemoryView_4Enum___init__(struct __pyx_MemviewEnum_obj *__pyx_v_self, PyObject *__pyx_v_name); /* proto */
2609 static PyObject *__pyx_MemviewEnum___pyx_pf_15View_dot_MemoryView_4Enum_2__repr__(struct __pyx_MemviewEnum_obj *__pyx_v_self); /* proto */
2610 static PyObject *__pyx_pf___pyx_MemviewEnum___reduce_cython__(struct __pyx_MemviewEnum_obj *__pyx_v_self); /* proto */
2611 static PyObject *__pyx_pf___pyx_MemviewEnum_2__setstate_cython__(struct __pyx_MemviewEnum_obj *__pyx_v_self, PyObject *__pyx_v___pyx_state); /* proto */
2612 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 */
2613 static void __pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_2__dealloc__(struct __pyx_memoryview_obj *__pyx_v_self); /* proto */
2614 static PyObject *__pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_4__getitem__(struct __pyx_memoryview_obj *__pyx_v_self, PyObject *__pyx_v_index); /* proto */
2615 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 */
2616 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 */
2617 static PyObject *__pyx_pf_15View_dot_MemoryView_10memoryview_1T___get__(struct __pyx_memoryview_obj *__pyx_v_self); /* proto */
2618 static PyObject *__pyx_pf_15View_dot_MemoryView_10memoryview_4base___get__(struct __pyx_memoryview_obj *__pyx_v_self); /* proto */
2619 static PyObject *__pyx_pf_15View_dot_MemoryView_10memoryview_5shape___get__(struct __pyx_memoryview_obj *__pyx_v_self); /* proto */
2620 static PyObject *__pyx_pf_15View_dot_MemoryView_10memoryview_7strides___get__(struct __pyx_memoryview_obj *__pyx_v_self); /* proto */
2621 static PyObject *__pyx_pf_15View_dot_MemoryView_10memoryview_10suboffsets___get__(struct __pyx_memoryview_obj *__pyx_v_self); /* proto */
2622 static PyObject *__pyx_pf_15View_dot_MemoryView_10memoryview_4ndim___get__(struct __pyx_memoryview_obj *__pyx_v_self); /* proto */
2623 static PyObject *__pyx_pf_15View_dot_MemoryView_10memoryview_8itemsize___get__(struct __pyx_memoryview_obj *__pyx_v_self); /* proto */
2624 static PyObject *__pyx_pf_15View_dot_MemoryView_10memoryview_6nbytes___get__(struct __pyx_memoryview_obj *__pyx_v_self); /* proto */
2625 static PyObject *__pyx_pf_15View_dot_MemoryView_10memoryview_4size___get__(struct __pyx_memoryview_obj *__pyx_v_self); /* proto */
2626 static Py_ssize_t __pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_10__len__(struct __pyx_memoryview_obj *__pyx_v_self); /* proto */
2627 static PyObject *__pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_12__repr__(struct __pyx_memoryview_obj *__pyx_v_self); /* proto */
2628 static PyObject *__pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_14__str__(struct __pyx_memoryview_obj *__pyx_v_self); /* proto */
2629 static PyObject *__pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_16is_c_contig(struct __pyx_memoryview_obj *__pyx_v_self); /* proto */
2630 static PyObject *__pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_18is_f_contig(struct __pyx_memoryview_obj *__pyx_v_self); /* proto */
2631 static PyObject *__pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_20copy(struct __pyx_memoryview_obj *__pyx_v_self); /* proto */
2632 static PyObject *__pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_22copy_fortran(struct __pyx_memoryview_obj *__pyx_v_self); /* proto */
2633 static PyObject *__pyx_pf___pyx_memoryview___reduce_cython__(CYTHON_UNUSED struct __pyx_memoryview_obj *__pyx_v_self); /* proto */
2634 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 */
2635 static void __pyx_memoryviewslice___pyx_pf_15View_dot_MemoryView_16_memoryviewslice___dealloc__(struct __pyx_memoryviewslice_obj *__pyx_v_self); /* proto */
2636 static PyObject *__pyx_pf_15View_dot_MemoryView_16_memoryviewslice_4base___get__(struct __pyx_memoryviewslice_obj *__pyx_v_self); /* proto */
2637 static PyObject *__pyx_pf___pyx_memoryviewslice___reduce_cython__(CYTHON_UNUSED struct __pyx_memoryviewslice_obj *__pyx_v_self); /* proto */
2638 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 */
2639 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 */
2640 static PyObject *__pyx_tp_new_array(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
2641 static PyObject *__pyx_tp_new_Enum(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
2642 static PyObject *__pyx_tp_new_memoryview(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
2643 static PyObject *__pyx_tp_new__memoryviewslice(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
2644 static PyObject *__pyx_int_0;
2645 static PyObject *__pyx_int_1;
2646 static PyObject *__pyx_int_2;
2647 static PyObject *__pyx_int_3;
2648 static PyObject *__pyx_int_184977713;
2649 static PyObject *__pyx_int_neg_1;
2650 static PyObject *__pyx_tuple_;
2651 static PyObject *__pyx_tuple__2;
2652 static PyObject *__pyx_tuple__3;
2653 static PyObject *__pyx_tuple__4;
2654 static PyObject *__pyx_tuple__5;
2655 static PyObject *__pyx_tuple__6;
2656 static PyObject *__pyx_tuple__7;
2657 static PyObject *__pyx_tuple__8;
2658 static PyObject *__pyx_tuple__9;
2659 static PyObject *__pyx_slice__20;
2660 static PyObject *__pyx_tuple__10;
2661 static PyObject *__pyx_tuple__11;
2662 static PyObject *__pyx_tuple__12;
2663 static PyObject *__pyx_tuple__13;
2664 static PyObject *__pyx_tuple__14;
2665 static PyObject *__pyx_tuple__15;
2666 static PyObject *__pyx_tuple__16;
2667 static PyObject *__pyx_tuple__17;
2668 static PyObject *__pyx_tuple__18;
2669 static PyObject *__pyx_tuple__19;
2670 static PyObject *__pyx_tuple__21;
2671 static PyObject *__pyx_tuple__22;
2672 static PyObject *__pyx_tuple__23;
2673 static PyObject *__pyx_tuple__25;
2674 static PyObject *__pyx_tuple__27;
2675 static PyObject *__pyx_tuple__29;
2676 static PyObject *__pyx_tuple__30;
2677 static PyObject *__pyx_tuple__31;
2678 static PyObject *__pyx_tuple__32;
2679 static PyObject *__pyx_tuple__33;
2680 static PyObject *__pyx_tuple__34;
2681 static PyObject *__pyx_codeobj__26;
2682 static PyObject *__pyx_codeobj__28;
2683 static PyObject *__pyx_codeobj__35;
2684 /* Late includes */
2685 
2686 /* "qutip/cy/ptrace.pyx":46
2687  * @cython.wraparound(False)
2688  * @cython.cdivision(True)
2689  * def _ptrace_legacy(object rho, _sel):             # <<<<<<<<<<<<<<
2690  *     """
2691  *     Private function calculating the partial trace.
2692  */
2693 
2694 /* Python wrapper */
2695 static PyObject *__pyx_pw_5qutip_2cy_6ptrace_1_ptrace_legacy(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
2696 static char __pyx_doc_5qutip_2cy_6ptrace__ptrace_legacy[] = "\n    Private function calculating the partial trace.\n    ";
2697 static PyMethodDef __pyx_mdef_5qutip_2cy_6ptrace_1_ptrace_legacy = {"_ptrace_legacy", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_5qutip_2cy_6ptrace_1_ptrace_legacy, METH_VARARGS|METH_KEYWORDS, __pyx_doc_5qutip_2cy_6ptrace__ptrace_legacy};
__pyx_pw_5qutip_2cy_6ptrace_1_ptrace_legacy(PyObject * __pyx_self,PyObject * __pyx_args,PyObject * __pyx_kwds)2698 static PyObject *__pyx_pw_5qutip_2cy_6ptrace_1_ptrace_legacy(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
2699   PyObject *__pyx_v_rho = 0;
2700   PyObject *__pyx_v__sel = 0;
2701   int __pyx_lineno = 0;
2702   const char *__pyx_filename = NULL;
2703   int __pyx_clineno = 0;
2704   PyObject *__pyx_r = 0;
2705   __Pyx_RefNannyDeclarations
2706   __Pyx_RefNannySetupContext("_ptrace_legacy (wrapper)", 0);
2707   {
2708     static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_rho,&__pyx_n_s_sel,0};
2709     PyObject* values[2] = {0,0};
2710     if (unlikely(__pyx_kwds)) {
2711       Py_ssize_t kw_args;
2712       const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
2713       switch (pos_args) {
2714         case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
2715         CYTHON_FALLTHROUGH;
2716         case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
2717         CYTHON_FALLTHROUGH;
2718         case  0: break;
2719         default: goto __pyx_L5_argtuple_error;
2720       }
2721       kw_args = PyDict_Size(__pyx_kwds);
2722       switch (pos_args) {
2723         case  0:
2724         if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_rho)) != 0)) kw_args--;
2725         else goto __pyx_L5_argtuple_error;
2726         CYTHON_FALLTHROUGH;
2727         case  1:
2728         if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_sel)) != 0)) kw_args--;
2729         else {
2730           __Pyx_RaiseArgtupleInvalid("_ptrace_legacy", 1, 2, 2, 1); __PYX_ERR(0, 46, __pyx_L3_error)
2731         }
2732       }
2733       if (unlikely(kw_args > 0)) {
2734         if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_ptrace_legacy") < 0)) __PYX_ERR(0, 46, __pyx_L3_error)
2735       }
2736     } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
2737       goto __pyx_L5_argtuple_error;
2738     } else {
2739       values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
2740       values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
2741     }
2742     __pyx_v_rho = values[0];
2743     __pyx_v__sel = values[1];
2744   }
2745   goto __pyx_L4_argument_unpacking_done;
2746   __pyx_L5_argtuple_error:;
2747   __Pyx_RaiseArgtupleInvalid("_ptrace_legacy", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 46, __pyx_L3_error)
2748   __pyx_L3_error:;
2749   __Pyx_AddTraceback("qutip.cy.ptrace._ptrace_legacy", __pyx_clineno, __pyx_lineno, __pyx_filename);
2750   __Pyx_RefNannyFinishContext();
2751   return NULL;
2752   __pyx_L4_argument_unpacking_done:;
2753   __pyx_r = __pyx_pf_5qutip_2cy_6ptrace__ptrace_legacy(__pyx_self, __pyx_v_rho, __pyx_v__sel);
2754 
2755   /* function exit code */
2756   __Pyx_RefNannyFinishContext();
2757   return __pyx_r;
2758 }
2759 
__pyx_pf_5qutip_2cy_6ptrace__ptrace_legacy(CYTHON_UNUSED PyObject * __pyx_self,PyObject * __pyx_v_rho,PyObject * __pyx_v__sel)2760 static PyObject *__pyx_pf_5qutip_2cy_6ptrace__ptrace_legacy(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_rho, PyObject *__pyx_v__sel) {
2761   size_t __pyx_v_mm;
2762   size_t __pyx_v_ii;
2763   int __pyx_v__tmp;
2764   PyArrayObject *__pyx_v_drho = 0;
2765   __Pyx_memviewslice __pyx_v_sel = { 0, 0, { 0 }, { 0 }, { 0 } };
2766   __Pyx_memviewslice __pyx_v_rest = { 0, 0, { 0 }, { 0 }, { 0 } };
2767   int __pyx_v_N;
2768   int __pyx_v_M;
2769   int __pyx_v_R;
2770   __Pyx_memviewslice __pyx_v_ilistsel = { 0, 0, { 0 }, { 0 }, { 0 } };
2771   __Pyx_memviewslice __pyx_v_indsel = { 0, 0, { 0 }, { 0 }, { 0 } };
2772   __Pyx_memviewslice __pyx_v_ilistrest = { 0, 0, { 0 }, { 0 }, { 0 } };
2773   __Pyx_memviewslice __pyx_v_indrest = { 0, 0, { 0 }, { 0 }, { 0 } };
2774   PyArrayObject *__pyx_v_ind = 0;
2775   PyObject *__pyx_v_data = NULL;
2776   PyObject *__pyx_v_ptr = NULL;
2777   PyObject *__pyx_v_perm = NULL;
2778   PyObject *__pyx_v_rhdata = NULL;
2779   PyObject *__pyx_v_rho1_data = NULL;
2780   PyObject *__pyx_v_dims_kept0 = NULL;
2781   PyObject *__pyx_v_rho1_dims = NULL;
2782   PyObject *__pyx_v_rho1_shape = NULL;
2783   __Pyx_LocalBuf_ND __pyx_pybuffernd_drho;
2784   __Pyx_Buffer __pyx_pybuffer_drho;
2785   __Pyx_LocalBuf_ND __pyx_pybuffernd_ind;
2786   __Pyx_Buffer __pyx_pybuffer_ind;
2787   PyObject *__pyx_r = NULL;
2788   __Pyx_RefNannyDeclarations
2789   PyObject *__pyx_t_1 = NULL;
2790   PyObject *__pyx_t_2 = NULL;
2791   PyObject *__pyx_t_3 = NULL;
2792   PyObject *__pyx_t_4 = NULL;
2793   int __pyx_t_5;
2794   PyObject *__pyx_t_6 = NULL;
2795   PyObject *__pyx_t_7 = NULL;
2796   PyArrayObject *__pyx_t_8 = NULL;
2797   int __pyx_t_9;
2798   __Pyx_memviewslice __pyx_t_10 = { 0, 0, { 0 }, { 0 }, { 0 } };
2799   Py_ssize_t __pyx_t_11;
2800   Py_ssize_t __pyx_t_12;
2801   size_t __pyx_t_13;
2802   size_t __pyx_t_14;
2803   PyObject *__pyx_t_15 = NULL;
2804   int __pyx_t_16;
2805   __Pyx_memviewslice __pyx_t_17 = { 0, 0, { 0 }, { 0 }, { 0 } };
2806   size_t __pyx_t_18;
2807   PyArrayObject *__pyx_t_19 = NULL;
2808   long __pyx_t_20;
2809   long __pyx_t_21;
2810   Py_ssize_t __pyx_t_22;
2811   Py_ssize_t __pyx_t_23;
2812   size_t __pyx_t_24;
2813   PyObject *__pyx_t_25 = NULL;
2814   int __pyx_lineno = 0;
2815   const char *__pyx_filename = NULL;
2816   int __pyx_clineno = 0;
2817   __Pyx_RefNannySetupContext("_ptrace_legacy", 0);
2818   __Pyx_INCREF(__pyx_v_rho);
2819   __Pyx_INCREF(__pyx_v__sel);
2820   __pyx_pybuffer_drho.pybuffer.buf = NULL;
2821   __pyx_pybuffer_drho.refcount = 0;
2822   __pyx_pybuffernd_drho.data = NULL;
2823   __pyx_pybuffernd_drho.rcbuffer = &__pyx_pybuffer_drho;
2824   __pyx_pybuffer_ind.pybuffer.buf = NULL;
2825   __pyx_pybuffer_ind.refcount = 0;
2826   __pyx_pybuffernd_ind.data = NULL;
2827   __pyx_pybuffernd_ind.rcbuffer = &__pyx_pybuffer_ind;
2828 
2829   /* "qutip/cy/ptrace.pyx":50
2830  *     Private function calculating the partial trace.
2831  *     """
2832  *     if np.prod(rho.dims[1]) == 1:             # <<<<<<<<<<<<<<
2833  *         rho = rho * rho.dag()
2834  *
2835  */
2836   __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_np); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 50, __pyx_L1_error)
2837   __Pyx_GOTREF(__pyx_t_2);
2838   __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_prod); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 50, __pyx_L1_error)
2839   __Pyx_GOTREF(__pyx_t_3);
2840   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
2841   __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_rho, __pyx_n_s_dims); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 50, __pyx_L1_error)
2842   __Pyx_GOTREF(__pyx_t_2);
2843   __pyx_t_4 = __Pyx_GetItemInt(__pyx_t_2, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 50, __pyx_L1_error)
2844   __Pyx_GOTREF(__pyx_t_4);
2845   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
2846   __pyx_t_2 = NULL;
2847   if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
2848     __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3);
2849     if (likely(__pyx_t_2)) {
2850       PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
2851       __Pyx_INCREF(__pyx_t_2);
2852       __Pyx_INCREF(function);
2853       __Pyx_DECREF_SET(__pyx_t_3, function);
2854     }
2855   }
2856   __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);
2857   __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
2858   __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
2859   if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 50, __pyx_L1_error)
2860   __Pyx_GOTREF(__pyx_t_1);
2861   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
2862   __pyx_t_3 = __Pyx_PyInt_EqObjC(__pyx_t_1, __pyx_int_1, 1, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 50, __pyx_L1_error)
2863   __Pyx_GOTREF(__pyx_t_3);
2864   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
2865   __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(0, 50, __pyx_L1_error)
2866   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
2867   if (__pyx_t_5) {
2868 
2869     /* "qutip/cy/ptrace.pyx":51
2870  *     """
2871  *     if np.prod(rho.dims[1]) == 1:
2872  *         rho = rho * rho.dag()             # <<<<<<<<<<<<<<
2873  *
2874  *     cdef size_t mm, ii
2875  */
2876     __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_rho, __pyx_n_s_dag); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 51, __pyx_L1_error)
2877     __Pyx_GOTREF(__pyx_t_1);
2878     __pyx_t_4 = NULL;
2879     if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_1))) {
2880       __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_1);
2881       if (likely(__pyx_t_4)) {
2882         PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
2883         __Pyx_INCREF(__pyx_t_4);
2884         __Pyx_INCREF(function);
2885         __Pyx_DECREF_SET(__pyx_t_1, function);
2886       }
2887     }
2888     __pyx_t_3 = (__pyx_t_4) ? __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_4) : __Pyx_PyObject_CallNoArg(__pyx_t_1);
2889     __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
2890     if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 51, __pyx_L1_error)
2891     __Pyx_GOTREF(__pyx_t_3);
2892     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
2893     __pyx_t_1 = PyNumber_Multiply(__pyx_v_rho, __pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 51, __pyx_L1_error)
2894     __Pyx_GOTREF(__pyx_t_1);
2895     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
2896     __Pyx_DECREF_SET(__pyx_v_rho, __pyx_t_1);
2897     __pyx_t_1 = 0;
2898 
2899     /* "qutip/cy/ptrace.pyx":50
2900  *     Private function calculating the partial trace.
2901  *     """
2902  *     if np.prod(rho.dims[1]) == 1:             # <<<<<<<<<<<<<<
2903  *         rho = rho * rho.dag()
2904  *
2905  */
2906   }
2907 
2908   /* "qutip/cy/ptrace.pyx":55
2909  *     cdef size_t mm, ii
2910  *     cdef int _tmp
2911  *     cdef cnp.ndarray[int, ndim=1, mode='c'] drho = np.asarray(rho.dims[0], dtype=np.int32).ravel()             # <<<<<<<<<<<<<<
2912  *
2913  *     if isinstance(_sel, int):
2914  */
2915   __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_np); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 55, __pyx_L1_error)
2916   __Pyx_GOTREF(__pyx_t_3);
2917   __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_asarray); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 55, __pyx_L1_error)
2918   __Pyx_GOTREF(__pyx_t_4);
2919   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
2920   __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_rho, __pyx_n_s_dims); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 55, __pyx_L1_error)
2921   __Pyx_GOTREF(__pyx_t_3);
2922   __pyx_t_2 = __Pyx_GetItemInt(__pyx_t_3, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 55, __pyx_L1_error)
2923   __Pyx_GOTREF(__pyx_t_2);
2924   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
2925   __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 55, __pyx_L1_error)
2926   __Pyx_GOTREF(__pyx_t_3);
2927   __Pyx_GIVEREF(__pyx_t_2);
2928   PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_2);
2929   __pyx_t_2 = 0;
2930   __pyx_t_2 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 55, __pyx_L1_error)
2931   __Pyx_GOTREF(__pyx_t_2);
2932   __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_n_s_np); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 55, __pyx_L1_error)
2933   __Pyx_GOTREF(__pyx_t_6);
2934   __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_int32); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 55, __pyx_L1_error)
2935   __Pyx_GOTREF(__pyx_t_7);
2936   __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
2937   if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_dtype, __pyx_t_7) < 0) __PYX_ERR(0, 55, __pyx_L1_error)
2938   __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
2939   __pyx_t_7 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_3, __pyx_t_2); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 55, __pyx_L1_error)
2940   __Pyx_GOTREF(__pyx_t_7);
2941   __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
2942   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
2943   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
2944   __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_n_s_ravel); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 55, __pyx_L1_error)
2945   __Pyx_GOTREF(__pyx_t_2);
2946   __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
2947   __pyx_t_7 = NULL;
2948   if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
2949     __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_2);
2950     if (likely(__pyx_t_7)) {
2951       PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
2952       __Pyx_INCREF(__pyx_t_7);
2953       __Pyx_INCREF(function);
2954       __Pyx_DECREF_SET(__pyx_t_2, function);
2955     }
2956   }
2957   __pyx_t_1 = (__pyx_t_7) ? __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_7) : __Pyx_PyObject_CallNoArg(__pyx_t_2);
2958   __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
2959   if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 55, __pyx_L1_error)
2960   __Pyx_GOTREF(__pyx_t_1);
2961   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
2962   if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 55, __pyx_L1_error)
2963   __pyx_t_8 = ((PyArrayObject *)__pyx_t_1);
2964   {
2965     __Pyx_BufFmt_StackElem __pyx_stack[1];
2966     if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_drho.rcbuffer->pybuffer, (PyObject*)__pyx_t_8, &__Pyx_TypeInfo_int, PyBUF_FORMAT| PyBUF_C_CONTIGUOUS, 1, 0, __pyx_stack) == -1)) {
2967       __pyx_v_drho = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_pybuffernd_drho.rcbuffer->pybuffer.buf = NULL;
2968       __PYX_ERR(0, 55, __pyx_L1_error)
2969     } else {__pyx_pybuffernd_drho.diminfo[0].strides = __pyx_pybuffernd_drho.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_drho.diminfo[0].shape = __pyx_pybuffernd_drho.rcbuffer->pybuffer.shape[0];
2970     }
2971   }
2972   __pyx_t_8 = 0;
2973   __pyx_v_drho = ((PyArrayObject *)__pyx_t_1);
2974   __pyx_t_1 = 0;
2975 
2976   /* "qutip/cy/ptrace.pyx":57
2977  *     cdef cnp.ndarray[int, ndim=1, mode='c'] drho = np.asarray(rho.dims[0], dtype=np.int32).ravel()
2978  *
2979  *     if isinstance(_sel, int):             # <<<<<<<<<<<<<<
2980  *         _sel = np.array([_sel], dtype=np.int32)
2981  *     else:
2982  */
2983   __pyx_t_5 = PyInt_Check(__pyx_v__sel);
2984   __pyx_t_9 = (__pyx_t_5 != 0);
2985   if (__pyx_t_9) {
2986 
2987     /* "qutip/cy/ptrace.pyx":58
2988  *
2989  *     if isinstance(_sel, int):
2990  *         _sel = np.array([_sel], dtype=np.int32)             # <<<<<<<<<<<<<<
2991  *     else:
2992  *         _sel = np.asarray(_sel, dtype = np.int32)
2993  */
2994     __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_np); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 58, __pyx_L1_error)
2995     __Pyx_GOTREF(__pyx_t_1);
2996     __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_array); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 58, __pyx_L1_error)
2997     __Pyx_GOTREF(__pyx_t_2);
2998     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
2999     __pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 58, __pyx_L1_error)
3000     __Pyx_GOTREF(__pyx_t_1);
3001     __Pyx_INCREF(__pyx_v__sel);
3002     __Pyx_GIVEREF(__pyx_v__sel);
3003     PyList_SET_ITEM(__pyx_t_1, 0, __pyx_v__sel);
3004     __pyx_t_7 = PyTuple_New(1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 58, __pyx_L1_error)
3005     __Pyx_GOTREF(__pyx_t_7);
3006     __Pyx_GIVEREF(__pyx_t_1);
3007     PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_1);
3008     __pyx_t_1 = 0;
3009     __pyx_t_1 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 58, __pyx_L1_error)
3010     __Pyx_GOTREF(__pyx_t_1);
3011     __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_np); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 58, __pyx_L1_error)
3012     __Pyx_GOTREF(__pyx_t_3);
3013     __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_int32); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 58, __pyx_L1_error)
3014     __Pyx_GOTREF(__pyx_t_4);
3015     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
3016     if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_dtype, __pyx_t_4) < 0) __PYX_ERR(0, 58, __pyx_L1_error)
3017     __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
3018     __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_7, __pyx_t_1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 58, __pyx_L1_error)
3019     __Pyx_GOTREF(__pyx_t_4);
3020     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
3021     __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
3022     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
3023     __Pyx_DECREF_SET(__pyx_v__sel, __pyx_t_4);
3024     __pyx_t_4 = 0;
3025 
3026     /* "qutip/cy/ptrace.pyx":57
3027  *     cdef cnp.ndarray[int, ndim=1, mode='c'] drho = np.asarray(rho.dims[0], dtype=np.int32).ravel()
3028  *
3029  *     if isinstance(_sel, int):             # <<<<<<<<<<<<<<
3030  *         _sel = np.array([_sel], dtype=np.int32)
3031  *     else:
3032  */
3033     goto __pyx_L4;
3034   }
3035 
3036   /* "qutip/cy/ptrace.pyx":60
3037  *         _sel = np.array([_sel], dtype=np.int32)
3038  *     else:
3039  *         _sel = np.asarray(_sel, dtype = np.int32)             # <<<<<<<<<<<<<<
3040  *
3041  *     cdef int[::1] sel = _sel
3042  */
3043   /*else*/ {
3044     __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_np); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 60, __pyx_L1_error)
3045     __Pyx_GOTREF(__pyx_t_4);
3046     __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_asarray); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 60, __pyx_L1_error)
3047     __Pyx_GOTREF(__pyx_t_1);
3048     __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
3049     __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 60, __pyx_L1_error)
3050     __Pyx_GOTREF(__pyx_t_4);
3051     __Pyx_INCREF(__pyx_v__sel);
3052     __Pyx_GIVEREF(__pyx_v__sel);
3053     PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_v__sel);
3054     __pyx_t_7 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 60, __pyx_L1_error)
3055     __Pyx_GOTREF(__pyx_t_7);
3056     __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_np); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 60, __pyx_L1_error)
3057     __Pyx_GOTREF(__pyx_t_2);
3058     __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_int32); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 60, __pyx_L1_error)
3059     __Pyx_GOTREF(__pyx_t_3);
3060     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
3061     if (PyDict_SetItem(__pyx_t_7, __pyx_n_s_dtype, __pyx_t_3) < 0) __PYX_ERR(0, 60, __pyx_L1_error)
3062     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
3063     __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_4, __pyx_t_7); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 60, __pyx_L1_error)
3064     __Pyx_GOTREF(__pyx_t_3);
3065     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
3066     __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
3067     __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
3068     __Pyx_DECREF_SET(__pyx_v__sel, __pyx_t_3);
3069     __pyx_t_3 = 0;
3070   }
3071   __pyx_L4:;
3072 
3073   /* "qutip/cy/ptrace.pyx":62
3074  *         _sel = np.asarray(_sel, dtype = np.int32)
3075  *
3076  *     cdef int[::1] sel = _sel             # <<<<<<<<<<<<<<
3077  *
3078  *     for mm in range(sel.shape[0]):
3079  */
3080   __pyx_t_10 = __Pyx_PyObject_to_MemoryviewSlice_dc_int(__pyx_v__sel, PyBUF_WRITABLE); if (unlikely(!__pyx_t_10.memview)) __PYX_ERR(0, 62, __pyx_L1_error)
3081   __pyx_v_sel = __pyx_t_10;
3082   __pyx_t_10.memview = NULL;
3083   __pyx_t_10.data = NULL;
3084 
3085   /* "qutip/cy/ptrace.pyx":64
3086  *     cdef int[::1] sel = _sel
3087  *
3088  *     for mm in range(sel.shape[0]):             # <<<<<<<<<<<<<<
3089  *         if (sel[mm] < 0) or (sel[mm] >= drho.shape[0]):
3090  *             raise TypeError("Invalid selection index in ptrace.")
3091  */
3092   __pyx_t_11 = (__pyx_v_sel.shape[0]);
3093   __pyx_t_12 = __pyx_t_11;
3094   for (__pyx_t_13 = 0; __pyx_t_13 < __pyx_t_12; __pyx_t_13+=1) {
3095     __pyx_v_mm = __pyx_t_13;
3096 
3097     /* "qutip/cy/ptrace.pyx":65
3098  *
3099  *     for mm in range(sel.shape[0]):
3100  *         if (sel[mm] < 0) or (sel[mm] >= drho.shape[0]):             # <<<<<<<<<<<<<<
3101  *             raise TypeError("Invalid selection index in ptrace.")
3102  *
3103  */
3104     __pyx_t_14 = __pyx_v_mm;
3105     __pyx_t_5 = (((*((int *) ( /* dim=0 */ ((char *) (((int *) __pyx_v_sel.data) + __pyx_t_14)) ))) < 0) != 0);
3106     if (!__pyx_t_5) {
3107     } else {
3108       __pyx_t_9 = __pyx_t_5;
3109       goto __pyx_L8_bool_binop_done;
3110     }
3111     __pyx_t_14 = __pyx_v_mm;
3112     __pyx_t_5 = (((*((int *) ( /* dim=0 */ ((char *) (((int *) __pyx_v_sel.data) + __pyx_t_14)) ))) >= (__pyx_v_drho->dimensions[0])) != 0);
3113     __pyx_t_9 = __pyx_t_5;
3114     __pyx_L8_bool_binop_done:;
3115     if (unlikely(__pyx_t_9)) {
3116 
3117       /* "qutip/cy/ptrace.pyx":66
3118  *     for mm in range(sel.shape[0]):
3119  *         if (sel[mm] < 0) or (sel[mm] >= drho.shape[0]):
3120  *             raise TypeError("Invalid selection index in ptrace.")             # <<<<<<<<<<<<<<
3121  *
3122  *     cdef int[::1] rest = np.delete(np.arange(drho.shape[0],dtype=np.int32),sel)
3123  */
3124       __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple_, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 66, __pyx_L1_error)
3125       __Pyx_GOTREF(__pyx_t_3);
3126       __Pyx_Raise(__pyx_t_3, 0, 0, 0);
3127       __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
3128       __PYX_ERR(0, 66, __pyx_L1_error)
3129 
3130       /* "qutip/cy/ptrace.pyx":65
3131  *
3132  *     for mm in range(sel.shape[0]):
3133  *         if (sel[mm] < 0) or (sel[mm] >= drho.shape[0]):             # <<<<<<<<<<<<<<
3134  *             raise TypeError("Invalid selection index in ptrace.")
3135  *
3136  */
3137     }
3138   }
3139 
3140   /* "qutip/cy/ptrace.pyx":68
3141  *             raise TypeError("Invalid selection index in ptrace.")
3142  *
3143  *     cdef int[::1] rest = np.delete(np.arange(drho.shape[0],dtype=np.int32),sel)             # <<<<<<<<<<<<<<
3144  *     cdef int N = np.prod(drho)
3145  *     cdef int M = np.prod(drho.take(sel))
3146  */
3147   __Pyx_GetModuleGlobalName(__pyx_t_7, __pyx_n_s_np); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 68, __pyx_L1_error)
3148   __Pyx_GOTREF(__pyx_t_7);
3149   __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_n_s_delete); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 68, __pyx_L1_error)
3150   __Pyx_GOTREF(__pyx_t_4);
3151   __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
3152   __Pyx_GetModuleGlobalName(__pyx_t_7, __pyx_n_s_np); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 68, __pyx_L1_error)
3153   __Pyx_GOTREF(__pyx_t_7);
3154   __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_n_s_arange); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 68, __pyx_L1_error)
3155   __Pyx_GOTREF(__pyx_t_1);
3156   __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
3157   __pyx_t_7 = __Pyx_PyInt_From_Py_intptr_t((__pyx_v_drho->dimensions[0])); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 68, __pyx_L1_error)
3158   __Pyx_GOTREF(__pyx_t_7);
3159   __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 68, __pyx_L1_error)
3160   __Pyx_GOTREF(__pyx_t_2);
3161   __Pyx_GIVEREF(__pyx_t_7);
3162   PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_7);
3163   __pyx_t_7 = 0;
3164   __pyx_t_7 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 68, __pyx_L1_error)
3165   __Pyx_GOTREF(__pyx_t_7);
3166   __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_n_s_np); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 68, __pyx_L1_error)
3167   __Pyx_GOTREF(__pyx_t_6);
3168   __pyx_t_15 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_int32); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 68, __pyx_L1_error)
3169   __Pyx_GOTREF(__pyx_t_15);
3170   __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
3171   if (PyDict_SetItem(__pyx_t_7, __pyx_n_s_dtype, __pyx_t_15) < 0) __PYX_ERR(0, 68, __pyx_L1_error)
3172   __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
3173   __pyx_t_15 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_2, __pyx_t_7); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 68, __pyx_L1_error)
3174   __Pyx_GOTREF(__pyx_t_15);
3175   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
3176   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
3177   __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
3178   __pyx_t_7 = __pyx_memoryview_fromslice(__pyx_v_sel, 1, (PyObject *(*)(char *)) __pyx_memview_get_int, (int (*)(char *, PyObject *)) __pyx_memview_set_int, 0);; if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 68, __pyx_L1_error)
3179   __Pyx_GOTREF(__pyx_t_7);
3180   __pyx_t_2 = NULL;
3181   __pyx_t_16 = 0;
3182   if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_4))) {
3183     __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_4);
3184     if (likely(__pyx_t_2)) {
3185       PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
3186       __Pyx_INCREF(__pyx_t_2);
3187       __Pyx_INCREF(function);
3188       __Pyx_DECREF_SET(__pyx_t_4, function);
3189       __pyx_t_16 = 1;
3190     }
3191   }
3192   #if CYTHON_FAST_PYCALL
3193   if (PyFunction_Check(__pyx_t_4)) {
3194     PyObject *__pyx_temp[3] = {__pyx_t_2, __pyx_t_15, __pyx_t_7};
3195     __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_16, 2+__pyx_t_16); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 68, __pyx_L1_error)
3196     __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
3197     __Pyx_GOTREF(__pyx_t_3);
3198     __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
3199     __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
3200   } else
3201   #endif
3202   #if CYTHON_FAST_PYCCALL
3203   if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) {
3204     PyObject *__pyx_temp[3] = {__pyx_t_2, __pyx_t_15, __pyx_t_7};
3205     __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_16, 2+__pyx_t_16); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 68, __pyx_L1_error)
3206     __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
3207     __Pyx_GOTREF(__pyx_t_3);
3208     __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
3209     __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
3210   } else
3211   #endif
3212   {
3213     __pyx_t_1 = PyTuple_New(2+__pyx_t_16); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 68, __pyx_L1_error)
3214     __Pyx_GOTREF(__pyx_t_1);
3215     if (__pyx_t_2) {
3216       __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_2); __pyx_t_2 = NULL;
3217     }
3218     __Pyx_GIVEREF(__pyx_t_15);
3219     PyTuple_SET_ITEM(__pyx_t_1, 0+__pyx_t_16, __pyx_t_15);
3220     __Pyx_GIVEREF(__pyx_t_7);
3221     PyTuple_SET_ITEM(__pyx_t_1, 1+__pyx_t_16, __pyx_t_7);
3222     __pyx_t_15 = 0;
3223     __pyx_t_7 = 0;
3224     __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_1, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 68, __pyx_L1_error)
3225     __Pyx_GOTREF(__pyx_t_3);
3226     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
3227   }
3228   __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
3229   __pyx_t_10 = __Pyx_PyObject_to_MemoryviewSlice_dc_int(__pyx_t_3, PyBUF_WRITABLE); if (unlikely(!__pyx_t_10.memview)) __PYX_ERR(0, 68, __pyx_L1_error)
3230   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
3231   __pyx_v_rest = __pyx_t_10;
3232   __pyx_t_10.memview = NULL;
3233   __pyx_t_10.data = NULL;
3234 
3235   /* "qutip/cy/ptrace.pyx":69
3236  *
3237  *     cdef int[::1] rest = np.delete(np.arange(drho.shape[0],dtype=np.int32),sel)
3238  *     cdef int N = np.prod(drho)             # <<<<<<<<<<<<<<
3239  *     cdef int M = np.prod(drho.take(sel))
3240  *     cdef int R = np.prod(drho.take(rest))
3241  */
3242   __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_np); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 69, __pyx_L1_error)
3243   __Pyx_GOTREF(__pyx_t_4);
3244   __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_prod); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 69, __pyx_L1_error)
3245   __Pyx_GOTREF(__pyx_t_1);
3246   __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
3247   __pyx_t_4 = NULL;
3248   if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_1))) {
3249     __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_1);
3250     if (likely(__pyx_t_4)) {
3251       PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
3252       __Pyx_INCREF(__pyx_t_4);
3253       __Pyx_INCREF(function);
3254       __Pyx_DECREF_SET(__pyx_t_1, function);
3255     }
3256   }
3257   __pyx_t_3 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_1, __pyx_t_4, ((PyObject *)__pyx_v_drho)) : __Pyx_PyObject_CallOneArg(__pyx_t_1, ((PyObject *)__pyx_v_drho));
3258   __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
3259   if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 69, __pyx_L1_error)
3260   __Pyx_GOTREF(__pyx_t_3);
3261   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
3262   __pyx_t_16 = __Pyx_PyInt_As_int(__pyx_t_3); if (unlikely((__pyx_t_16 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 69, __pyx_L1_error)
3263   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
3264   __pyx_v_N = __pyx_t_16;
3265 
3266   /* "qutip/cy/ptrace.pyx":70
3267  *     cdef int[::1] rest = np.delete(np.arange(drho.shape[0],dtype=np.int32),sel)
3268  *     cdef int N = np.prod(drho)
3269  *     cdef int M = np.prod(drho.take(sel))             # <<<<<<<<<<<<<<
3270  *     cdef int R = np.prod(drho.take(rest))
3271  *
3272  */
3273   __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_np); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 70, __pyx_L1_error)
3274   __Pyx_GOTREF(__pyx_t_1);
3275   __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_prod); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 70, __pyx_L1_error)
3276   __Pyx_GOTREF(__pyx_t_4);
3277   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
3278   __pyx_t_7 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_drho), __pyx_n_s_take); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 70, __pyx_L1_error)
3279   __Pyx_GOTREF(__pyx_t_7);
3280   __pyx_t_15 = __pyx_memoryview_fromslice(__pyx_v_sel, 1, (PyObject *(*)(char *)) __pyx_memview_get_int, (int (*)(char *, PyObject *)) __pyx_memview_set_int, 0);; if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 70, __pyx_L1_error)
3281   __Pyx_GOTREF(__pyx_t_15);
3282   __pyx_t_2 = NULL;
3283   if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_7))) {
3284     __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_7);
3285     if (likely(__pyx_t_2)) {
3286       PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7);
3287       __Pyx_INCREF(__pyx_t_2);
3288       __Pyx_INCREF(function);
3289       __Pyx_DECREF_SET(__pyx_t_7, function);
3290     }
3291   }
3292   __pyx_t_1 = (__pyx_t_2) ? __Pyx_PyObject_Call2Args(__pyx_t_7, __pyx_t_2, __pyx_t_15) : __Pyx_PyObject_CallOneArg(__pyx_t_7, __pyx_t_15);
3293   __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
3294   __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
3295   if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 70, __pyx_L1_error)
3296   __Pyx_GOTREF(__pyx_t_1);
3297   __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
3298   __pyx_t_7 = NULL;
3299   if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_4))) {
3300     __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_4);
3301     if (likely(__pyx_t_7)) {
3302       PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
3303       __Pyx_INCREF(__pyx_t_7);
3304       __Pyx_INCREF(function);
3305       __Pyx_DECREF_SET(__pyx_t_4, function);
3306     }
3307   }
3308   __pyx_t_3 = (__pyx_t_7) ? __Pyx_PyObject_Call2Args(__pyx_t_4, __pyx_t_7, __pyx_t_1) : __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_1);
3309   __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
3310   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
3311   if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 70, __pyx_L1_error)
3312   __Pyx_GOTREF(__pyx_t_3);
3313   __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
3314   __pyx_t_16 = __Pyx_PyInt_As_int(__pyx_t_3); if (unlikely((__pyx_t_16 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 70, __pyx_L1_error)
3315   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
3316   __pyx_v_M = __pyx_t_16;
3317 
3318   /* "qutip/cy/ptrace.pyx":71
3319  *     cdef int N = np.prod(drho)
3320  *     cdef int M = np.prod(drho.take(sel))
3321  *     cdef int R = np.prod(drho.take(rest))             # <<<<<<<<<<<<<<
3322  *
3323  *     cdef int[:,::1] ilistsel = _select(sel, drho, M)
3324  */
3325   __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_np); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 71, __pyx_L1_error)
3326   __Pyx_GOTREF(__pyx_t_4);
3327   __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_prod); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 71, __pyx_L1_error)
3328   __Pyx_GOTREF(__pyx_t_1);
3329   __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
3330   __pyx_t_7 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_drho), __pyx_n_s_take); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 71, __pyx_L1_error)
3331   __Pyx_GOTREF(__pyx_t_7);
3332   __pyx_t_15 = __pyx_memoryview_fromslice(__pyx_v_rest, 1, (PyObject *(*)(char *)) __pyx_memview_get_int, (int (*)(char *, PyObject *)) __pyx_memview_set_int, 0);; if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 71, __pyx_L1_error)
3333   __Pyx_GOTREF(__pyx_t_15);
3334   __pyx_t_2 = NULL;
3335   if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_7))) {
3336     __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_7);
3337     if (likely(__pyx_t_2)) {
3338       PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7);
3339       __Pyx_INCREF(__pyx_t_2);
3340       __Pyx_INCREF(function);
3341       __Pyx_DECREF_SET(__pyx_t_7, function);
3342     }
3343   }
3344   __pyx_t_4 = (__pyx_t_2) ? __Pyx_PyObject_Call2Args(__pyx_t_7, __pyx_t_2, __pyx_t_15) : __Pyx_PyObject_CallOneArg(__pyx_t_7, __pyx_t_15);
3345   __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
3346   __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
3347   if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 71, __pyx_L1_error)
3348   __Pyx_GOTREF(__pyx_t_4);
3349   __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
3350   __pyx_t_7 = NULL;
3351   if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_1))) {
3352     __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_1);
3353     if (likely(__pyx_t_7)) {
3354       PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
3355       __Pyx_INCREF(__pyx_t_7);
3356       __Pyx_INCREF(function);
3357       __Pyx_DECREF_SET(__pyx_t_1, function);
3358     }
3359   }
3360   __pyx_t_3 = (__pyx_t_7) ? __Pyx_PyObject_Call2Args(__pyx_t_1, __pyx_t_7, __pyx_t_4) : __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_4);
3361   __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
3362   __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
3363   if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 71, __pyx_L1_error)
3364   __Pyx_GOTREF(__pyx_t_3);
3365   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
3366   __pyx_t_16 = __Pyx_PyInt_As_int(__pyx_t_3); if (unlikely((__pyx_t_16 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 71, __pyx_L1_error)
3367   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
3368   __pyx_v_R = __pyx_t_16;
3369 
3370   /* "qutip/cy/ptrace.pyx":73
3371  *     cdef int R = np.prod(drho.take(rest))
3372  *
3373  *     cdef int[:,::1] ilistsel = _select(sel, drho, M)             # <<<<<<<<<<<<<<
3374  *     cdef int[::1] indsel = _list2ind(ilistsel, drho)
3375  *     cdef int[:,::1] ilistrest = _select(rest, drho, R)
3376  */
3377   __pyx_t_10 = __Pyx_PyObject_to_MemoryviewSlice_dc_int(((PyObject *)__pyx_v_drho), PyBUF_WRITABLE); if (unlikely(!__pyx_t_10.memview)) __PYX_ERR(0, 73, __pyx_L1_error)
3378   __pyx_t_3 = ((PyObject *)__pyx_f_5qutip_2cy_6ptrace__select(__pyx_v_sel, __pyx_t_10, __pyx_v_M, 0)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 73, __pyx_L1_error)
3379   __Pyx_GOTREF(__pyx_t_3);
3380   __PYX_XDEC_MEMVIEW(&__pyx_t_10, 1);
3381   __pyx_t_10.memview = NULL;
3382   __pyx_t_10.data = NULL;
3383   __pyx_t_17 = __Pyx_PyObject_to_MemoryviewSlice_d_dc_int(__pyx_t_3, PyBUF_WRITABLE); if (unlikely(!__pyx_t_17.memview)) __PYX_ERR(0, 73, __pyx_L1_error)
3384   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
3385   __pyx_v_ilistsel = __pyx_t_17;
3386   __pyx_t_17.memview = NULL;
3387   __pyx_t_17.data = NULL;
3388 
3389   /* "qutip/cy/ptrace.pyx":74
3390  *
3391  *     cdef int[:,::1] ilistsel = _select(sel, drho, M)
3392  *     cdef int[::1] indsel = _list2ind(ilistsel, drho)             # <<<<<<<<<<<<<<
3393  *     cdef int[:,::1] ilistrest = _select(rest, drho, R)
3394  *     cdef int[::1] indrest = _list2ind(ilistrest, drho)
3395  */
3396   __pyx_t_10 = __Pyx_PyObject_to_MemoryviewSlice_dc_int(((PyObject *)__pyx_v_drho), PyBUF_WRITABLE); if (unlikely(!__pyx_t_10.memview)) __PYX_ERR(0, 74, __pyx_L1_error)
3397   __pyx_t_3 = ((PyObject *)__pyx_f_5qutip_2cy_6ptrace__list2ind(__pyx_v_ilistsel, __pyx_t_10, 0)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 74, __pyx_L1_error)
3398   __Pyx_GOTREF(__pyx_t_3);
3399   __PYX_XDEC_MEMVIEW(&__pyx_t_10, 1);
3400   __pyx_t_10.memview = NULL;
3401   __pyx_t_10.data = NULL;
3402   __pyx_t_10 = __Pyx_PyObject_to_MemoryviewSlice_dc_int(__pyx_t_3, PyBUF_WRITABLE); if (unlikely(!__pyx_t_10.memview)) __PYX_ERR(0, 74, __pyx_L1_error)
3403   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
3404   __pyx_v_indsel = __pyx_t_10;
3405   __pyx_t_10.memview = NULL;
3406   __pyx_t_10.data = NULL;
3407 
3408   /* "qutip/cy/ptrace.pyx":75
3409  *     cdef int[:,::1] ilistsel = _select(sel, drho, M)
3410  *     cdef int[::1] indsel = _list2ind(ilistsel, drho)
3411  *     cdef int[:,::1] ilistrest = _select(rest, drho, R)             # <<<<<<<<<<<<<<
3412  *     cdef int[::1] indrest = _list2ind(ilistrest, drho)
3413  *
3414  */
3415   __pyx_t_10 = __Pyx_PyObject_to_MemoryviewSlice_dc_int(((PyObject *)__pyx_v_drho), PyBUF_WRITABLE); if (unlikely(!__pyx_t_10.memview)) __PYX_ERR(0, 75, __pyx_L1_error)
3416   __pyx_t_3 = ((PyObject *)__pyx_f_5qutip_2cy_6ptrace__select(__pyx_v_rest, __pyx_t_10, __pyx_v_R, 0)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 75, __pyx_L1_error)
3417   __Pyx_GOTREF(__pyx_t_3);
3418   __PYX_XDEC_MEMVIEW(&__pyx_t_10, 1);
3419   __pyx_t_10.memview = NULL;
3420   __pyx_t_10.data = NULL;
3421   __pyx_t_17 = __Pyx_PyObject_to_MemoryviewSlice_d_dc_int(__pyx_t_3, PyBUF_WRITABLE); if (unlikely(!__pyx_t_17.memview)) __PYX_ERR(0, 75, __pyx_L1_error)
3422   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
3423   __pyx_v_ilistrest = __pyx_t_17;
3424   __pyx_t_17.memview = NULL;
3425   __pyx_t_17.data = NULL;
3426 
3427   /* "qutip/cy/ptrace.pyx":76
3428  *     cdef int[::1] indsel = _list2ind(ilistsel, drho)
3429  *     cdef int[:,::1] ilistrest = _select(rest, drho, R)
3430  *     cdef int[::1] indrest = _list2ind(ilistrest, drho)             # <<<<<<<<<<<<<<
3431  *
3432  *     for mm in range(indrest.shape[0]):
3433  */
3434   __pyx_t_10 = __Pyx_PyObject_to_MemoryviewSlice_dc_int(((PyObject *)__pyx_v_drho), PyBUF_WRITABLE); if (unlikely(!__pyx_t_10.memview)) __PYX_ERR(0, 76, __pyx_L1_error)
3435   __pyx_t_3 = ((PyObject *)__pyx_f_5qutip_2cy_6ptrace__list2ind(__pyx_v_ilistrest, __pyx_t_10, 0)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 76, __pyx_L1_error)
3436   __Pyx_GOTREF(__pyx_t_3);
3437   __PYX_XDEC_MEMVIEW(&__pyx_t_10, 1);
3438   __pyx_t_10.memview = NULL;
3439   __pyx_t_10.data = NULL;
3440   __pyx_t_10 = __Pyx_PyObject_to_MemoryviewSlice_dc_int(__pyx_t_3, PyBUF_WRITABLE); if (unlikely(!__pyx_t_10.memview)) __PYX_ERR(0, 76, __pyx_L1_error)
3441   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
3442   __pyx_v_indrest = __pyx_t_10;
3443   __pyx_t_10.memview = NULL;
3444   __pyx_t_10.data = NULL;
3445 
3446   /* "qutip/cy/ptrace.pyx":78
3447  *     cdef int[::1] indrest = _list2ind(ilistrest, drho)
3448  *
3449  *     for mm in range(indrest.shape[0]):             # <<<<<<<<<<<<<<
3450  *         _tmp = indrest[mm] * N + indrest[mm]-1
3451  *         indrest[mm] = _tmp
3452  */
3453   __pyx_t_11 = (__pyx_v_indrest.shape[0]);
3454   __pyx_t_12 = __pyx_t_11;
3455   for (__pyx_t_13 = 0; __pyx_t_13 < __pyx_t_12; __pyx_t_13+=1) {
3456     __pyx_v_mm = __pyx_t_13;
3457 
3458     /* "qutip/cy/ptrace.pyx":79
3459  *
3460  *     for mm in range(indrest.shape[0]):
3461  *         _tmp = indrest[mm] * N + indrest[mm]-1             # <<<<<<<<<<<<<<
3462  *         indrest[mm] = _tmp
3463  *
3464  */
3465     __pyx_t_14 = __pyx_v_mm;
3466     __pyx_t_18 = __pyx_v_mm;
3467     __pyx_v__tmp = ((((*((int *) ( /* dim=0 */ ((char *) (((int *) __pyx_v_indrest.data) + __pyx_t_14)) ))) * __pyx_v_N) + (*((int *) ( /* dim=0 */ ((char *) (((int *) __pyx_v_indrest.data) + __pyx_t_18)) )))) - 1);
3468 
3469     /* "qutip/cy/ptrace.pyx":80
3470  *     for mm in range(indrest.shape[0]):
3471  *         _tmp = indrest[mm] * N + indrest[mm]-1
3472  *         indrest[mm] = _tmp             # <<<<<<<<<<<<<<
3473  *
3474  *     cdef cnp.ndarray[int, ndim=1, mode='c'] ind = np.zeros(M**2*indrest.shape[0],dtype=np.int32)
3475  */
3476     __pyx_t_18 = __pyx_v_mm;
3477     *((int *) ( /* dim=0 */ ((char *) (((int *) __pyx_v_indrest.data) + __pyx_t_18)) )) = __pyx_v__tmp;
3478   }
3479 
3480   /* "qutip/cy/ptrace.pyx":82
3481  *         indrest[mm] = _tmp
3482  *
3483  *     cdef cnp.ndarray[int, ndim=1, mode='c'] ind = np.zeros(M**2*indrest.shape[0],dtype=np.int32)             # <<<<<<<<<<<<<<
3484  *     for mm in range(M**2):
3485  *         for ii in range(indrest.shape[0]):
3486  */
3487   __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_np); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 82, __pyx_L1_error)
3488   __Pyx_GOTREF(__pyx_t_3);
3489   __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_zeros); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 82, __pyx_L1_error)
3490   __Pyx_GOTREF(__pyx_t_1);
3491   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
3492   __pyx_t_3 = PyInt_FromSsize_t((__Pyx_pow_long(((long)__pyx_v_M), 2) * (__pyx_v_indrest.shape[0]))); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 82, __pyx_L1_error)
3493   __Pyx_GOTREF(__pyx_t_3);
3494   __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 82, __pyx_L1_error)
3495   __Pyx_GOTREF(__pyx_t_4);
3496   __Pyx_GIVEREF(__pyx_t_3);
3497   PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_3);
3498   __pyx_t_3 = 0;
3499   __pyx_t_3 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 82, __pyx_L1_error)
3500   __Pyx_GOTREF(__pyx_t_3);
3501   __Pyx_GetModuleGlobalName(__pyx_t_7, __pyx_n_s_np); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 82, __pyx_L1_error)
3502   __Pyx_GOTREF(__pyx_t_7);
3503   __pyx_t_15 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_n_s_int32); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 82, __pyx_L1_error)
3504   __Pyx_GOTREF(__pyx_t_15);
3505   __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
3506   if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_dtype, __pyx_t_15) < 0) __PYX_ERR(0, 82, __pyx_L1_error)
3507   __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
3508   __pyx_t_15 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_4, __pyx_t_3); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 82, __pyx_L1_error)
3509   __Pyx_GOTREF(__pyx_t_15);
3510   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
3511   __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
3512   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
3513   if (!(likely(((__pyx_t_15) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_15, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 82, __pyx_L1_error)
3514   __pyx_t_19 = ((PyArrayObject *)__pyx_t_15);
3515   {
3516     __Pyx_BufFmt_StackElem __pyx_stack[1];
3517     if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_ind.rcbuffer->pybuffer, (PyObject*)__pyx_t_19, &__Pyx_TypeInfo_int, PyBUF_FORMAT| PyBUF_C_CONTIGUOUS| PyBUF_WRITABLE, 1, 0, __pyx_stack) == -1)) {
3518       __pyx_v_ind = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_pybuffernd_ind.rcbuffer->pybuffer.buf = NULL;
3519       __PYX_ERR(0, 82, __pyx_L1_error)
3520     } else {__pyx_pybuffernd_ind.diminfo[0].strides = __pyx_pybuffernd_ind.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_ind.diminfo[0].shape = __pyx_pybuffernd_ind.rcbuffer->pybuffer.shape[0];
3521     }
3522   }
3523   __pyx_t_19 = 0;
3524   __pyx_v_ind = ((PyArrayObject *)__pyx_t_15);
3525   __pyx_t_15 = 0;
3526 
3527   /* "qutip/cy/ptrace.pyx":83
3528  *
3529  *     cdef cnp.ndarray[int, ndim=1, mode='c'] ind = np.zeros(M**2*indrest.shape[0],dtype=np.int32)
3530  *     for mm in range(M**2):             # <<<<<<<<<<<<<<
3531  *         for ii in range(indrest.shape[0]):
3532  *             ind[mm*indrest.shape[0]+ii] = indrest[ii] + \
3533  */
3534   __pyx_t_20 = __Pyx_pow_long(((long)__pyx_v_M), 2);
3535   __pyx_t_21 = __pyx_t_20;
3536   for (__pyx_t_13 = 0; __pyx_t_13 < __pyx_t_21; __pyx_t_13+=1) {
3537     __pyx_v_mm = __pyx_t_13;
3538 
3539     /* "qutip/cy/ptrace.pyx":84
3540  *     cdef cnp.ndarray[int, ndim=1, mode='c'] ind = np.zeros(M**2*indrest.shape[0],dtype=np.int32)
3541  *     for mm in range(M**2):
3542  *         for ii in range(indrest.shape[0]):             # <<<<<<<<<<<<<<
3543  *             ind[mm*indrest.shape[0]+ii] = indrest[ii] + \
3544  *                     N*indsel[<int>floor(mm / M)] + \
3545  */
3546     __pyx_t_11 = (__pyx_v_indrest.shape[0]);
3547     __pyx_t_12 = __pyx_t_11;
3548     for (__pyx_t_18 = 0; __pyx_t_18 < __pyx_t_12; __pyx_t_18+=1) {
3549       __pyx_v_ii = __pyx_t_18;
3550 
3551       /* "qutip/cy/ptrace.pyx":85
3552  *     for mm in range(M**2):
3553  *         for ii in range(indrest.shape[0]):
3554  *             ind[mm*indrest.shape[0]+ii] = indrest[ii] + \             # <<<<<<<<<<<<<<
3555  *                     N*indsel[<int>floor(mm / M)] + \
3556  *                     indsel[<int>(mm % M)]+1
3557  */
3558       __pyx_t_14 = __pyx_v_ii;
3559 
3560       /* "qutip/cy/ptrace.pyx":86
3561  *         for ii in range(indrest.shape[0]):
3562  *             ind[mm*indrest.shape[0]+ii] = indrest[ii] + \
3563  *                     N*indsel[<int>floor(mm / M)] + \             # <<<<<<<<<<<<<<
3564  *                     indsel[<int>(mm % M)]+1
3565  *
3566  */
3567       __pyx_t_22 = ((int)floor((__pyx_v_mm / ((size_t)__pyx_v_M))));
3568 
3569       /* "qutip/cy/ptrace.pyx":87
3570  *             ind[mm*indrest.shape[0]+ii] = indrest[ii] + \
3571  *                     N*indsel[<int>floor(mm / M)] + \
3572  *                     indsel[<int>(mm % M)]+1             # <<<<<<<<<<<<<<
3573  *
3574  *     data = np.ones_like(ind,dtype=complex)
3575  */
3576       __pyx_t_23 = ((int)(__pyx_v_mm % __pyx_v_M));
3577 
3578       /* "qutip/cy/ptrace.pyx":85
3579  *     for mm in range(M**2):
3580  *         for ii in range(indrest.shape[0]):
3581  *             ind[mm*indrest.shape[0]+ii] = indrest[ii] + \             # <<<<<<<<<<<<<<
3582  *                     N*indsel[<int>floor(mm / M)] + \
3583  *                     indsel[<int>(mm % M)]+1
3584  */
3585       __pyx_t_24 = ((__pyx_v_mm * (__pyx_v_indrest.shape[0])) + __pyx_v_ii);
3586       *__Pyx_BufPtrCContig1d(int *, __pyx_pybuffernd_ind.rcbuffer->pybuffer.buf, __pyx_t_24, __pyx_pybuffernd_ind.diminfo[0].strides) = ((((*((int *) ( /* dim=0 */ ((char *) (((int *) __pyx_v_indrest.data) + __pyx_t_14)) ))) + (__pyx_v_N * (*((int *) ( /* dim=0 */ ((char *) (((int *) __pyx_v_indsel.data) + __pyx_t_22)) ))))) + (*((int *) ( /* dim=0 */ ((char *) (((int *) __pyx_v_indsel.data) + __pyx_t_23)) )))) + 1);
3587     }
3588   }
3589 
3590   /* "qutip/cy/ptrace.pyx":89
3591  *                     indsel[<int>(mm % M)]+1
3592  *
3593  *     data = np.ones_like(ind,dtype=complex)             # <<<<<<<<<<<<<<
3594  *     ptr = np.arange(0,(M**2+1)*indrest.shape[0],indrest.shape[0], dtype=np.int32)
3595  *     perm = fast_csr_matrix((data,ind,ptr),shape=(M * M, N * N))
3596  */
3597   __Pyx_GetModuleGlobalName(__pyx_t_15, __pyx_n_s_np); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 89, __pyx_L1_error)
3598   __Pyx_GOTREF(__pyx_t_15);
3599   __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_15, __pyx_n_s_ones_like); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 89, __pyx_L1_error)
3600   __Pyx_GOTREF(__pyx_t_3);
3601   __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
3602   __pyx_t_15 = PyTuple_New(1); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 89, __pyx_L1_error)
3603   __Pyx_GOTREF(__pyx_t_15);
3604   __Pyx_INCREF(((PyObject *)__pyx_v_ind));
3605   __Pyx_GIVEREF(((PyObject *)__pyx_v_ind));
3606   PyTuple_SET_ITEM(__pyx_t_15, 0, ((PyObject *)__pyx_v_ind));
3607   __pyx_t_4 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 89, __pyx_L1_error)
3608   __Pyx_GOTREF(__pyx_t_4);
3609   if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_dtype, ((PyObject *)(&PyComplex_Type))) < 0) __PYX_ERR(0, 89, __pyx_L1_error)
3610   __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_15, __pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 89, __pyx_L1_error)
3611   __Pyx_GOTREF(__pyx_t_1);
3612   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
3613   __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
3614   __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
3615   __pyx_v_data = __pyx_t_1;
3616   __pyx_t_1 = 0;
3617 
3618   /* "qutip/cy/ptrace.pyx":90
3619  *
3620  *     data = np.ones_like(ind,dtype=complex)
3621  *     ptr = np.arange(0,(M**2+1)*indrest.shape[0],indrest.shape[0], dtype=np.int32)             # <<<<<<<<<<<<<<
3622  *     perm = fast_csr_matrix((data,ind,ptr),shape=(M * M, N * N))
3623  *     # No need to sort here, will be sorted in reshape
3624  */
3625   __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_np); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 90, __pyx_L1_error)
3626   __Pyx_GOTREF(__pyx_t_1);
3627   __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_arange); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 90, __pyx_L1_error)
3628   __Pyx_GOTREF(__pyx_t_4);
3629   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
3630   __pyx_t_1 = PyInt_FromSsize_t(((__Pyx_pow_long(((long)__pyx_v_M), 2) + 1) * (__pyx_v_indrest.shape[0]))); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 90, __pyx_L1_error)
3631   __Pyx_GOTREF(__pyx_t_1);
3632   __pyx_t_15 = PyInt_FromSsize_t((__pyx_v_indrest.shape[0])); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 90, __pyx_L1_error)
3633   __Pyx_GOTREF(__pyx_t_15);
3634   __pyx_t_3 = PyTuple_New(3); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 90, __pyx_L1_error)
3635   __Pyx_GOTREF(__pyx_t_3);
3636   __Pyx_INCREF(__pyx_int_0);
3637   __Pyx_GIVEREF(__pyx_int_0);
3638   PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_int_0);
3639   __Pyx_GIVEREF(__pyx_t_1);
3640   PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_1);
3641   __Pyx_GIVEREF(__pyx_t_15);
3642   PyTuple_SET_ITEM(__pyx_t_3, 2, __pyx_t_15);
3643   __pyx_t_1 = 0;
3644   __pyx_t_15 = 0;
3645   __pyx_t_15 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 90, __pyx_L1_error)
3646   __Pyx_GOTREF(__pyx_t_15);
3647   __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_np); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 90, __pyx_L1_error)
3648   __Pyx_GOTREF(__pyx_t_1);
3649   __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_int32); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 90, __pyx_L1_error)
3650   __Pyx_GOTREF(__pyx_t_7);
3651   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
3652   if (PyDict_SetItem(__pyx_t_15, __pyx_n_s_dtype, __pyx_t_7) < 0) __PYX_ERR(0, 90, __pyx_L1_error)
3653   __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
3654   __pyx_t_7 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_3, __pyx_t_15); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 90, __pyx_L1_error)
3655   __Pyx_GOTREF(__pyx_t_7);
3656   __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
3657   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
3658   __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
3659   __pyx_v_ptr = __pyx_t_7;
3660   __pyx_t_7 = 0;
3661 
3662   /* "qutip/cy/ptrace.pyx":91
3663  *     data = np.ones_like(ind,dtype=complex)
3664  *     ptr = np.arange(0,(M**2+1)*indrest.shape[0],indrest.shape[0], dtype=np.int32)
3665  *     perm = fast_csr_matrix((data,ind,ptr),shape=(M * M, N * N))             # <<<<<<<<<<<<<<
3666  *     # No need to sort here, will be sorted in reshape
3667  *     rhdata = zcsr_mult(perm, zcsr_reshape(rho.data, np.prod(rho.shape), 1), sorted=0)
3668  */
3669   __Pyx_GetModuleGlobalName(__pyx_t_7, __pyx_n_s_fast_csr_matrix); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 91, __pyx_L1_error)
3670   __Pyx_GOTREF(__pyx_t_7);
3671   __pyx_t_15 = PyTuple_New(3); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 91, __pyx_L1_error)
3672   __Pyx_GOTREF(__pyx_t_15);
3673   __Pyx_INCREF(__pyx_v_data);
3674   __Pyx_GIVEREF(__pyx_v_data);
3675   PyTuple_SET_ITEM(__pyx_t_15, 0, __pyx_v_data);
3676   __Pyx_INCREF(((PyObject *)__pyx_v_ind));
3677   __Pyx_GIVEREF(((PyObject *)__pyx_v_ind));
3678   PyTuple_SET_ITEM(__pyx_t_15, 1, ((PyObject *)__pyx_v_ind));
3679   __Pyx_INCREF(__pyx_v_ptr);
3680   __Pyx_GIVEREF(__pyx_v_ptr);
3681   PyTuple_SET_ITEM(__pyx_t_15, 2, __pyx_v_ptr);
3682   __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 91, __pyx_L1_error)
3683   __Pyx_GOTREF(__pyx_t_3);
3684   __Pyx_GIVEREF(__pyx_t_15);
3685   PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_15);
3686   __pyx_t_15 = 0;
3687   __pyx_t_15 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 91, __pyx_L1_error)
3688   __Pyx_GOTREF(__pyx_t_15);
3689   __pyx_t_4 = __Pyx_PyInt_From_int((__pyx_v_M * __pyx_v_M)); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 91, __pyx_L1_error)
3690   __Pyx_GOTREF(__pyx_t_4);
3691   __pyx_t_1 = __Pyx_PyInt_From_int((__pyx_v_N * __pyx_v_N)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 91, __pyx_L1_error)
3692   __Pyx_GOTREF(__pyx_t_1);
3693   __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 91, __pyx_L1_error)
3694   __Pyx_GOTREF(__pyx_t_2);
3695   __Pyx_GIVEREF(__pyx_t_4);
3696   PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_4);
3697   __Pyx_GIVEREF(__pyx_t_1);
3698   PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_t_1);
3699   __pyx_t_4 = 0;
3700   __pyx_t_1 = 0;
3701   if (PyDict_SetItem(__pyx_t_15, __pyx_n_s_shape, __pyx_t_2) < 0) __PYX_ERR(0, 91, __pyx_L1_error)
3702   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
3703   __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_t_3, __pyx_t_15); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 91, __pyx_L1_error)
3704   __Pyx_GOTREF(__pyx_t_2);
3705   __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
3706   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
3707   __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
3708   __pyx_v_perm = __pyx_t_2;
3709   __pyx_t_2 = 0;
3710 
3711   /* "qutip/cy/ptrace.pyx":93
3712  *     perm = fast_csr_matrix((data,ind,ptr),shape=(M * M, N * N))
3713  *     # No need to sort here, will be sorted in reshape
3714  *     rhdata = zcsr_mult(perm, zcsr_reshape(rho.data, np.prod(rho.shape), 1), sorted=0)             # <<<<<<<<<<<<<<
3715  *     rho1_data = zcsr_reshape(rhdata, M, M)
3716  *     dims_kept0 = np.asarray(rho.dims[0], dtype=np.int32).take(sel)
3717  */
3718   __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_zcsr_mult); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 93, __pyx_L1_error)
3719   __Pyx_GOTREF(__pyx_t_2);
3720   __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_zcsr_reshape); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 93, __pyx_L1_error)
3721   __Pyx_GOTREF(__pyx_t_3);
3722   __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_v_rho, __pyx_n_s_data); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 93, __pyx_L1_error)
3723   __Pyx_GOTREF(__pyx_t_7);
3724   __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_np); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 93, __pyx_L1_error)
3725   __Pyx_GOTREF(__pyx_t_4);
3726   __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_prod); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 93, __pyx_L1_error)
3727   __Pyx_GOTREF(__pyx_t_6);
3728   __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
3729   __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_rho, __pyx_n_s_shape); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 93, __pyx_L1_error)
3730   __Pyx_GOTREF(__pyx_t_4);
3731   __pyx_t_25 = NULL;
3732   if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_6))) {
3733     __pyx_t_25 = PyMethod_GET_SELF(__pyx_t_6);
3734     if (likely(__pyx_t_25)) {
3735       PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
3736       __Pyx_INCREF(__pyx_t_25);
3737       __Pyx_INCREF(function);
3738       __Pyx_DECREF_SET(__pyx_t_6, function);
3739     }
3740   }
3741   __pyx_t_1 = (__pyx_t_25) ? __Pyx_PyObject_Call2Args(__pyx_t_6, __pyx_t_25, __pyx_t_4) : __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_t_4);
3742   __Pyx_XDECREF(__pyx_t_25); __pyx_t_25 = 0;
3743   __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
3744   if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 93, __pyx_L1_error)
3745   __Pyx_GOTREF(__pyx_t_1);
3746   __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
3747   __pyx_t_6 = NULL;
3748   __pyx_t_16 = 0;
3749   if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
3750     __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_3);
3751     if (likely(__pyx_t_6)) {
3752       PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
3753       __Pyx_INCREF(__pyx_t_6);
3754       __Pyx_INCREF(function);
3755       __Pyx_DECREF_SET(__pyx_t_3, function);
3756       __pyx_t_16 = 1;
3757     }
3758   }
3759   #if CYTHON_FAST_PYCALL
3760   if (PyFunction_Check(__pyx_t_3)) {
3761     PyObject *__pyx_temp[4] = {__pyx_t_6, __pyx_t_7, __pyx_t_1, __pyx_int_1};
3762     __pyx_t_15 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_16, 3+__pyx_t_16); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 93, __pyx_L1_error)
3763     __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
3764     __Pyx_GOTREF(__pyx_t_15);
3765     __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
3766     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
3767   } else
3768   #endif
3769   #if CYTHON_FAST_PYCCALL
3770   if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
3771     PyObject *__pyx_temp[4] = {__pyx_t_6, __pyx_t_7, __pyx_t_1, __pyx_int_1};
3772     __pyx_t_15 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_16, 3+__pyx_t_16); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 93, __pyx_L1_error)
3773     __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
3774     __Pyx_GOTREF(__pyx_t_15);
3775     __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
3776     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
3777   } else
3778   #endif
3779   {
3780     __pyx_t_4 = PyTuple_New(3+__pyx_t_16); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 93, __pyx_L1_error)
3781     __Pyx_GOTREF(__pyx_t_4);
3782     if (__pyx_t_6) {
3783       __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_6); __pyx_t_6 = NULL;
3784     }
3785     __Pyx_GIVEREF(__pyx_t_7);
3786     PyTuple_SET_ITEM(__pyx_t_4, 0+__pyx_t_16, __pyx_t_7);
3787     __Pyx_GIVEREF(__pyx_t_1);
3788     PyTuple_SET_ITEM(__pyx_t_4, 1+__pyx_t_16, __pyx_t_1);
3789     __Pyx_INCREF(__pyx_int_1);
3790     __Pyx_GIVEREF(__pyx_int_1);
3791     PyTuple_SET_ITEM(__pyx_t_4, 2+__pyx_t_16, __pyx_int_1);
3792     __pyx_t_7 = 0;
3793     __pyx_t_1 = 0;
3794     __pyx_t_15 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_4, NULL); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 93, __pyx_L1_error)
3795     __Pyx_GOTREF(__pyx_t_15);
3796     __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
3797   }
3798   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
3799   __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 93, __pyx_L1_error)
3800   __Pyx_GOTREF(__pyx_t_3);
3801   __Pyx_INCREF(__pyx_v_perm);
3802   __Pyx_GIVEREF(__pyx_v_perm);
3803   PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_perm);
3804   __Pyx_GIVEREF(__pyx_t_15);
3805   PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_15);
3806   __pyx_t_15 = 0;
3807   __pyx_t_15 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 93, __pyx_L1_error)
3808   __Pyx_GOTREF(__pyx_t_15);
3809   if (PyDict_SetItem(__pyx_t_15, __pyx_n_s_sorted, __pyx_int_0) < 0) __PYX_ERR(0, 93, __pyx_L1_error)
3810   __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_3, __pyx_t_15); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 93, __pyx_L1_error)
3811   __Pyx_GOTREF(__pyx_t_4);
3812   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
3813   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
3814   __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
3815   __pyx_v_rhdata = __pyx_t_4;
3816   __pyx_t_4 = 0;
3817 
3818   /* "qutip/cy/ptrace.pyx":94
3819  *     # No need to sort here, will be sorted in reshape
3820  *     rhdata = zcsr_mult(perm, zcsr_reshape(rho.data, np.prod(rho.shape), 1), sorted=0)
3821  *     rho1_data = zcsr_reshape(rhdata, M, M)             # <<<<<<<<<<<<<<
3822  *     dims_kept0 = np.asarray(rho.dims[0], dtype=np.int32).take(sel)
3823  *     rho1_dims = [dims_kept0.tolist(), dims_kept0.tolist()]
3824  */
3825   __Pyx_GetModuleGlobalName(__pyx_t_15, __pyx_n_s_zcsr_reshape); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 94, __pyx_L1_error)
3826   __Pyx_GOTREF(__pyx_t_15);
3827   __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_M); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 94, __pyx_L1_error)
3828   __Pyx_GOTREF(__pyx_t_3);
3829   __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_M); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 94, __pyx_L1_error)
3830   __Pyx_GOTREF(__pyx_t_2);
3831   __pyx_t_1 = NULL;
3832   __pyx_t_16 = 0;
3833   if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_15))) {
3834     __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_15);
3835     if (likely(__pyx_t_1)) {
3836       PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_15);
3837       __Pyx_INCREF(__pyx_t_1);
3838       __Pyx_INCREF(function);
3839       __Pyx_DECREF_SET(__pyx_t_15, function);
3840       __pyx_t_16 = 1;
3841     }
3842   }
3843   #if CYTHON_FAST_PYCALL
3844   if (PyFunction_Check(__pyx_t_15)) {
3845     PyObject *__pyx_temp[4] = {__pyx_t_1, __pyx_v_rhdata, __pyx_t_3, __pyx_t_2};
3846     __pyx_t_4 = __Pyx_PyFunction_FastCall(__pyx_t_15, __pyx_temp+1-__pyx_t_16, 3+__pyx_t_16); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 94, __pyx_L1_error)
3847     __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
3848     __Pyx_GOTREF(__pyx_t_4);
3849     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
3850     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
3851   } else
3852   #endif
3853   #if CYTHON_FAST_PYCCALL
3854   if (__Pyx_PyFastCFunction_Check(__pyx_t_15)) {
3855     PyObject *__pyx_temp[4] = {__pyx_t_1, __pyx_v_rhdata, __pyx_t_3, __pyx_t_2};
3856     __pyx_t_4 = __Pyx_PyCFunction_FastCall(__pyx_t_15, __pyx_temp+1-__pyx_t_16, 3+__pyx_t_16); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 94, __pyx_L1_error)
3857     __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
3858     __Pyx_GOTREF(__pyx_t_4);
3859     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
3860     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
3861   } else
3862   #endif
3863   {
3864     __pyx_t_7 = PyTuple_New(3+__pyx_t_16); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 94, __pyx_L1_error)
3865     __Pyx_GOTREF(__pyx_t_7);
3866     if (__pyx_t_1) {
3867       __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_1); __pyx_t_1 = NULL;
3868     }
3869     __Pyx_INCREF(__pyx_v_rhdata);
3870     __Pyx_GIVEREF(__pyx_v_rhdata);
3871     PyTuple_SET_ITEM(__pyx_t_7, 0+__pyx_t_16, __pyx_v_rhdata);
3872     __Pyx_GIVEREF(__pyx_t_3);
3873     PyTuple_SET_ITEM(__pyx_t_7, 1+__pyx_t_16, __pyx_t_3);
3874     __Pyx_GIVEREF(__pyx_t_2);
3875     PyTuple_SET_ITEM(__pyx_t_7, 2+__pyx_t_16, __pyx_t_2);
3876     __pyx_t_3 = 0;
3877     __pyx_t_2 = 0;
3878     __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_15, __pyx_t_7, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 94, __pyx_L1_error)
3879     __Pyx_GOTREF(__pyx_t_4);
3880     __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
3881   }
3882   __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
3883   __pyx_v_rho1_data = __pyx_t_4;
3884   __pyx_t_4 = 0;
3885 
3886   /* "qutip/cy/ptrace.pyx":95
3887  *     rhdata = zcsr_mult(perm, zcsr_reshape(rho.data, np.prod(rho.shape), 1), sorted=0)
3888  *     rho1_data = zcsr_reshape(rhdata, M, M)
3889  *     dims_kept0 = np.asarray(rho.dims[0], dtype=np.int32).take(sel)             # <<<<<<<<<<<<<<
3890  *     rho1_dims = [dims_kept0.tolist(), dims_kept0.tolist()]
3891  *     rho1_shape = [np.prod(dims_kept0), np.prod(dims_kept0)]
3892  */
3893   __Pyx_GetModuleGlobalName(__pyx_t_15, __pyx_n_s_np); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 95, __pyx_L1_error)
3894   __Pyx_GOTREF(__pyx_t_15);
3895   __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_15, __pyx_n_s_asarray); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 95, __pyx_L1_error)
3896   __Pyx_GOTREF(__pyx_t_7);
3897   __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
3898   __pyx_t_15 = __Pyx_PyObject_GetAttrStr(__pyx_v_rho, __pyx_n_s_dims); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 95, __pyx_L1_error)
3899   __Pyx_GOTREF(__pyx_t_15);
3900   __pyx_t_2 = __Pyx_GetItemInt(__pyx_t_15, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 95, __pyx_L1_error)
3901   __Pyx_GOTREF(__pyx_t_2);
3902   __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
3903   __pyx_t_15 = PyTuple_New(1); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 95, __pyx_L1_error)
3904   __Pyx_GOTREF(__pyx_t_15);
3905   __Pyx_GIVEREF(__pyx_t_2);
3906   PyTuple_SET_ITEM(__pyx_t_15, 0, __pyx_t_2);
3907   __pyx_t_2 = 0;
3908   __pyx_t_2 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 95, __pyx_L1_error)
3909   __Pyx_GOTREF(__pyx_t_2);
3910   __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_np); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 95, __pyx_L1_error)
3911   __Pyx_GOTREF(__pyx_t_3);
3912   __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_int32); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 95, __pyx_L1_error)
3913   __Pyx_GOTREF(__pyx_t_1);
3914   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
3915   if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_dtype, __pyx_t_1) < 0) __PYX_ERR(0, 95, __pyx_L1_error)
3916   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
3917   __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_t_15, __pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 95, __pyx_L1_error)
3918   __Pyx_GOTREF(__pyx_t_1);
3919   __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
3920   __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
3921   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
3922   __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_take); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 95, __pyx_L1_error)
3923   __Pyx_GOTREF(__pyx_t_2);
3924   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
3925   __pyx_t_1 = __pyx_memoryview_fromslice(__pyx_v_sel, 1, (PyObject *(*)(char *)) __pyx_memview_get_int, (int (*)(char *, PyObject *)) __pyx_memview_set_int, 0);; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 95, __pyx_L1_error)
3926   __Pyx_GOTREF(__pyx_t_1);
3927   __pyx_t_15 = NULL;
3928   if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
3929     __pyx_t_15 = PyMethod_GET_SELF(__pyx_t_2);
3930     if (likely(__pyx_t_15)) {
3931       PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
3932       __Pyx_INCREF(__pyx_t_15);
3933       __Pyx_INCREF(function);
3934       __Pyx_DECREF_SET(__pyx_t_2, function);
3935     }
3936   }
3937   __pyx_t_4 = (__pyx_t_15) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_15, __pyx_t_1) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_1);
3938   __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
3939   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
3940   if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 95, __pyx_L1_error)
3941   __Pyx_GOTREF(__pyx_t_4);
3942   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
3943   __pyx_v_dims_kept0 = __pyx_t_4;
3944   __pyx_t_4 = 0;
3945 
3946   /* "qutip/cy/ptrace.pyx":96
3947  *     rho1_data = zcsr_reshape(rhdata, M, M)
3948  *     dims_kept0 = np.asarray(rho.dims[0], dtype=np.int32).take(sel)
3949  *     rho1_dims = [dims_kept0.tolist(), dims_kept0.tolist()]             # <<<<<<<<<<<<<<
3950  *     rho1_shape = [np.prod(dims_kept0), np.prod(dims_kept0)]
3951  *     return rho1_data, rho1_dims, rho1_shape
3952  */
3953   __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_dims_kept0, __pyx_n_s_tolist); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 96, __pyx_L1_error)
3954   __Pyx_GOTREF(__pyx_t_2);
3955   __pyx_t_1 = NULL;
3956   if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
3957     __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_2);
3958     if (likely(__pyx_t_1)) {
3959       PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
3960       __Pyx_INCREF(__pyx_t_1);
3961       __Pyx_INCREF(function);
3962       __Pyx_DECREF_SET(__pyx_t_2, function);
3963     }
3964   }
3965   __pyx_t_4 = (__pyx_t_1) ? __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_1) : __Pyx_PyObject_CallNoArg(__pyx_t_2);
3966   __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
3967   if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 96, __pyx_L1_error)
3968   __Pyx_GOTREF(__pyx_t_4);
3969   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
3970   __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_dims_kept0, __pyx_n_s_tolist); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 96, __pyx_L1_error)
3971   __Pyx_GOTREF(__pyx_t_1);
3972   __pyx_t_15 = NULL;
3973   if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_1))) {
3974     __pyx_t_15 = PyMethod_GET_SELF(__pyx_t_1);
3975     if (likely(__pyx_t_15)) {
3976       PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
3977       __Pyx_INCREF(__pyx_t_15);
3978       __Pyx_INCREF(function);
3979       __Pyx_DECREF_SET(__pyx_t_1, function);
3980     }
3981   }
3982   __pyx_t_2 = (__pyx_t_15) ? __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_15) : __Pyx_PyObject_CallNoArg(__pyx_t_1);
3983   __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
3984   if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 96, __pyx_L1_error)
3985   __Pyx_GOTREF(__pyx_t_2);
3986   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
3987   __pyx_t_1 = PyList_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 96, __pyx_L1_error)
3988   __Pyx_GOTREF(__pyx_t_1);
3989   __Pyx_GIVEREF(__pyx_t_4);
3990   PyList_SET_ITEM(__pyx_t_1, 0, __pyx_t_4);
3991   __Pyx_GIVEREF(__pyx_t_2);
3992   PyList_SET_ITEM(__pyx_t_1, 1, __pyx_t_2);
3993   __pyx_t_4 = 0;
3994   __pyx_t_2 = 0;
3995   __pyx_v_rho1_dims = ((PyObject*)__pyx_t_1);
3996   __pyx_t_1 = 0;
3997 
3998   /* "qutip/cy/ptrace.pyx":97
3999  *     dims_kept0 = np.asarray(rho.dims[0], dtype=np.int32).take(sel)
4000  *     rho1_dims = [dims_kept0.tolist(), dims_kept0.tolist()]
4001  *     rho1_shape = [np.prod(dims_kept0), np.prod(dims_kept0)]             # <<<<<<<<<<<<<<
4002  *     return rho1_data, rho1_dims, rho1_shape
4003  *
4004  */
4005   __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_np); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 97, __pyx_L1_error)
4006   __Pyx_GOTREF(__pyx_t_2);
4007   __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_prod); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 97, __pyx_L1_error)
4008   __Pyx_GOTREF(__pyx_t_4);
4009   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
4010   __pyx_t_2 = NULL;
4011   if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_4))) {
4012     __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_4);
4013     if (likely(__pyx_t_2)) {
4014       PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
4015       __Pyx_INCREF(__pyx_t_2);
4016       __Pyx_INCREF(function);
4017       __Pyx_DECREF_SET(__pyx_t_4, function);
4018     }
4019   }
4020   __pyx_t_1 = (__pyx_t_2) ? __Pyx_PyObject_Call2Args(__pyx_t_4, __pyx_t_2, __pyx_v_dims_kept0) : __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_v_dims_kept0);
4021   __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
4022   if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 97, __pyx_L1_error)
4023   __Pyx_GOTREF(__pyx_t_1);
4024   __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
4025   __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_np); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 97, __pyx_L1_error)
4026   __Pyx_GOTREF(__pyx_t_2);
4027   __pyx_t_15 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_prod); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 97, __pyx_L1_error)
4028   __Pyx_GOTREF(__pyx_t_15);
4029   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
4030   __pyx_t_2 = NULL;
4031   if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_15))) {
4032     __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_15);
4033     if (likely(__pyx_t_2)) {
4034       PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_15);
4035       __Pyx_INCREF(__pyx_t_2);
4036       __Pyx_INCREF(function);
4037       __Pyx_DECREF_SET(__pyx_t_15, function);
4038     }
4039   }
4040   __pyx_t_4 = (__pyx_t_2) ? __Pyx_PyObject_Call2Args(__pyx_t_15, __pyx_t_2, __pyx_v_dims_kept0) : __Pyx_PyObject_CallOneArg(__pyx_t_15, __pyx_v_dims_kept0);
4041   __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
4042   if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 97, __pyx_L1_error)
4043   __Pyx_GOTREF(__pyx_t_4);
4044   __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
4045   __pyx_t_15 = PyList_New(2); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 97, __pyx_L1_error)
4046   __Pyx_GOTREF(__pyx_t_15);
4047   __Pyx_GIVEREF(__pyx_t_1);
4048   PyList_SET_ITEM(__pyx_t_15, 0, __pyx_t_1);
4049   __Pyx_GIVEREF(__pyx_t_4);
4050   PyList_SET_ITEM(__pyx_t_15, 1, __pyx_t_4);
4051   __pyx_t_1 = 0;
4052   __pyx_t_4 = 0;
4053   __pyx_v_rho1_shape = ((PyObject*)__pyx_t_15);
4054   __pyx_t_15 = 0;
4055 
4056   /* "qutip/cy/ptrace.pyx":98
4057  *     rho1_dims = [dims_kept0.tolist(), dims_kept0.tolist()]
4058  *     rho1_shape = [np.prod(dims_kept0), np.prod(dims_kept0)]
4059  *     return rho1_data, rho1_dims, rho1_shape             # <<<<<<<<<<<<<<
4060  *
4061  *
4062  */
4063   __Pyx_XDECREF(__pyx_r);
4064   __pyx_t_15 = PyTuple_New(3); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 98, __pyx_L1_error)
4065   __Pyx_GOTREF(__pyx_t_15);
4066   __Pyx_INCREF(__pyx_v_rho1_data);
4067   __Pyx_GIVEREF(__pyx_v_rho1_data);
4068   PyTuple_SET_ITEM(__pyx_t_15, 0, __pyx_v_rho1_data);
4069   __Pyx_INCREF(__pyx_v_rho1_dims);
4070   __Pyx_GIVEREF(__pyx_v_rho1_dims);
4071   PyTuple_SET_ITEM(__pyx_t_15, 1, __pyx_v_rho1_dims);
4072   __Pyx_INCREF(__pyx_v_rho1_shape);
4073   __Pyx_GIVEREF(__pyx_v_rho1_shape);
4074   PyTuple_SET_ITEM(__pyx_t_15, 2, __pyx_v_rho1_shape);
4075   __pyx_r = __pyx_t_15;
4076   __pyx_t_15 = 0;
4077   goto __pyx_L0;
4078 
4079   /* "qutip/cy/ptrace.pyx":46
4080  * @cython.wraparound(False)
4081  * @cython.cdivision(True)
4082  * def _ptrace_legacy(object rho, _sel):             # <<<<<<<<<<<<<<
4083  *     """
4084  *     Private function calculating the partial trace.
4085  */
4086 
4087   /* function exit code */
4088   __pyx_L1_error:;
4089   __Pyx_XDECREF(__pyx_t_1);
4090   __Pyx_XDECREF(__pyx_t_2);
4091   __Pyx_XDECREF(__pyx_t_3);
4092   __Pyx_XDECREF(__pyx_t_4);
4093   __Pyx_XDECREF(__pyx_t_6);
4094   __Pyx_XDECREF(__pyx_t_7);
4095   __PYX_XDEC_MEMVIEW(&__pyx_t_10, 1);
4096   __Pyx_XDECREF(__pyx_t_15);
4097   __PYX_XDEC_MEMVIEW(&__pyx_t_17, 1);
4098   __Pyx_XDECREF(__pyx_t_25);
4099   { PyObject *__pyx_type, *__pyx_value, *__pyx_tb;
4100     __Pyx_PyThreadState_declare
4101     __Pyx_PyThreadState_assign
4102     __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb);
4103     __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_drho.rcbuffer->pybuffer);
4104     __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_ind.rcbuffer->pybuffer);
4105   __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}
4106   __Pyx_AddTraceback("qutip.cy.ptrace._ptrace_legacy", __pyx_clineno, __pyx_lineno, __pyx_filename);
4107   __pyx_r = NULL;
4108   goto __pyx_L2;
4109   __pyx_L0:;
4110   __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_drho.rcbuffer->pybuffer);
4111   __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_ind.rcbuffer->pybuffer);
4112   __pyx_L2:;
4113   __Pyx_XDECREF((PyObject *)__pyx_v_drho);
4114   __PYX_XDEC_MEMVIEW(&__pyx_v_sel, 1);
4115   __PYX_XDEC_MEMVIEW(&__pyx_v_rest, 1);
4116   __PYX_XDEC_MEMVIEW(&__pyx_v_ilistsel, 1);
4117   __PYX_XDEC_MEMVIEW(&__pyx_v_indsel, 1);
4118   __PYX_XDEC_MEMVIEW(&__pyx_v_ilistrest, 1);
4119   __PYX_XDEC_MEMVIEW(&__pyx_v_indrest, 1);
4120   __Pyx_XDECREF((PyObject *)__pyx_v_ind);
4121   __Pyx_XDECREF(__pyx_v_data);
4122   __Pyx_XDECREF(__pyx_v_ptr);
4123   __Pyx_XDECREF(__pyx_v_perm);
4124   __Pyx_XDECREF(__pyx_v_rhdata);
4125   __Pyx_XDECREF(__pyx_v_rho1_data);
4126   __Pyx_XDECREF(__pyx_v_dims_kept0);
4127   __Pyx_XDECREF(__pyx_v_rho1_dims);
4128   __Pyx_XDECREF(__pyx_v_rho1_shape);
4129   __Pyx_XDECREF(__pyx_v_rho);
4130   __Pyx_XDECREF(__pyx_v__sel);
4131   __Pyx_XGIVEREF(__pyx_r);
4132   __Pyx_RefNannyFinishContext();
4133   return __pyx_r;
4134 }
4135 
4136 /* "qutip/cy/ptrace.pyx":104
4137  * @cython.wraparound(False)
4138  * @cython.cdivision(True)
4139  * cpdef cnp.ndarray[int, ndim=1, mode='c'] _list2ind(int[:,::1] ilist, int[::1] dims):             # <<<<<<<<<<<<<<
4140  *     """!
4141  *     Private function returning indicies
4142  */
4143 
4144 static PyObject *__pyx_pw_5qutip_2cy_6ptrace_3_list2ind(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
__pyx_f_5qutip_2cy_6ptrace__list2ind(__Pyx_memviewslice __pyx_v_ilist,__Pyx_memviewslice __pyx_v_dims,CYTHON_UNUSED int __pyx_skip_dispatch)4145 static PyArrayObject *__pyx_f_5qutip_2cy_6ptrace__list2ind(__Pyx_memviewslice __pyx_v_ilist, __Pyx_memviewslice __pyx_v_dims, CYTHON_UNUSED int __pyx_skip_dispatch) {
4146   size_t __pyx_v_kk;
4147   size_t __pyx_v_ll;
4148   __Pyx_memviewslice __pyx_v_fact = { 0, 0, { 0 }, { 0 }, { 0 } };
4149   PyArrayObject *__pyx_r = NULL;
4150   __Pyx_RefNannyDeclarations
4151   PyObject *__pyx_t_1 = NULL;
4152   PyObject *__pyx_t_2 = NULL;
4153   PyObject *__pyx_t_3 = NULL;
4154   PyObject *__pyx_t_4 = NULL;
4155   PyObject *__pyx_t_5 = NULL;
4156   __Pyx_memviewslice __pyx_t_6 = { 0, 0, { 0 }, { 0 }, { 0 } };
4157   Py_ssize_t __pyx_t_7;
4158   Py_ssize_t __pyx_t_8;
4159   size_t __pyx_t_9;
4160   Py_ssize_t __pyx_t_10;
4161   Py_ssize_t __pyx_t_11;
4162   size_t __pyx_t_12;
4163   size_t __pyx_t_13;
4164   size_t __pyx_t_14;
4165   PyObject *__pyx_t_15 = NULL;
4166   PyObject *__pyx_t_16 = NULL;
4167   int __pyx_t_17;
4168   PyObject *__pyx_t_18 = NULL;
4169   int __pyx_lineno = 0;
4170   const char *__pyx_filename = NULL;
4171   int __pyx_clineno = 0;
4172   __Pyx_RefNannySetupContext("_list2ind", 0);
4173 
4174   /* "qutip/cy/ptrace.pyx":109
4175  *     """
4176  *     cdef size_t kk, ll
4177  *     cdef int[::1] fact = np.ones(dims.shape[0],dtype=np.int32)             # <<<<<<<<<<<<<<
4178  *     for kk in range(dims.shape[0]):
4179  *         for ll in range(kk+1,dims.shape[0]):
4180  */
4181   __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_np); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 109, __pyx_L1_error)
4182   __Pyx_GOTREF(__pyx_t_1);
4183   __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_ones); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 109, __pyx_L1_error)
4184   __Pyx_GOTREF(__pyx_t_2);
4185   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
4186   __pyx_t_1 = PyInt_FromSsize_t((__pyx_v_dims.shape[0])); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 109, __pyx_L1_error)
4187   __Pyx_GOTREF(__pyx_t_1);
4188   __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 109, __pyx_L1_error)
4189   __Pyx_GOTREF(__pyx_t_3);
4190   __Pyx_GIVEREF(__pyx_t_1);
4191   PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_1);
4192   __pyx_t_1 = 0;
4193   __pyx_t_1 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 109, __pyx_L1_error)
4194   __Pyx_GOTREF(__pyx_t_1);
4195   __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_np); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 109, __pyx_L1_error)
4196   __Pyx_GOTREF(__pyx_t_4);
4197   __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_int32); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 109, __pyx_L1_error)
4198   __Pyx_GOTREF(__pyx_t_5);
4199   __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
4200   if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_dtype, __pyx_t_5) < 0) __PYX_ERR(0, 109, __pyx_L1_error)
4201   __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
4202   __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_3, __pyx_t_1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 109, __pyx_L1_error)
4203   __Pyx_GOTREF(__pyx_t_5);
4204   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
4205   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
4206   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
4207   __pyx_t_6 = __Pyx_PyObject_to_MemoryviewSlice_dc_int(__pyx_t_5, PyBUF_WRITABLE); if (unlikely(!__pyx_t_6.memview)) __PYX_ERR(0, 109, __pyx_L1_error)
4208   __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
4209   __pyx_v_fact = __pyx_t_6;
4210   __pyx_t_6.memview = NULL;
4211   __pyx_t_6.data = NULL;
4212 
4213   /* "qutip/cy/ptrace.pyx":110
4214  *     cdef size_t kk, ll
4215  *     cdef int[::1] fact = np.ones(dims.shape[0],dtype=np.int32)
4216  *     for kk in range(dims.shape[0]):             # <<<<<<<<<<<<<<
4217  *         for ll in range(kk+1,dims.shape[0]):
4218  *             fact[kk] *= dims[ll]
4219  */
4220   __pyx_t_7 = (__pyx_v_dims.shape[0]);
4221   __pyx_t_8 = __pyx_t_7;
4222   for (__pyx_t_9 = 0; __pyx_t_9 < __pyx_t_8; __pyx_t_9+=1) {
4223     __pyx_v_kk = __pyx_t_9;
4224 
4225     /* "qutip/cy/ptrace.pyx":111
4226  *     cdef int[::1] fact = np.ones(dims.shape[0],dtype=np.int32)
4227  *     for kk in range(dims.shape[0]):
4228  *         for ll in range(kk+1,dims.shape[0]):             # <<<<<<<<<<<<<<
4229  *             fact[kk] *= dims[ll]
4230  *     # If we make ilist a csr_matrix, then this is just spmv then sort
4231  */
4232     __pyx_t_10 = (__pyx_v_dims.shape[0]);
4233     __pyx_t_11 = __pyx_t_10;
4234     for (__pyx_t_12 = (__pyx_v_kk + 1); __pyx_t_12 < __pyx_t_11; __pyx_t_12+=1) {
4235       __pyx_v_ll = __pyx_t_12;
4236 
4237       /* "qutip/cy/ptrace.pyx":112
4238  *     for kk in range(dims.shape[0]):
4239  *         for ll in range(kk+1,dims.shape[0]):
4240  *             fact[kk] *= dims[ll]             # <<<<<<<<<<<<<<
4241  *     # If we make ilist a csr_matrix, then this is just spmv then sort
4242  *     return np.sort(np.dot(ilist, fact), 0)
4243  */
4244       __pyx_t_13 = __pyx_v_ll;
4245       __pyx_t_14 = __pyx_v_kk;
4246       *((int *) ( /* dim=0 */ ((char *) (((int *) __pyx_v_fact.data) + __pyx_t_14)) )) *= (*((int *) ( /* dim=0 */ ((char *) (((int *) __pyx_v_dims.data) + __pyx_t_13)) )));
4247     }
4248   }
4249 
4250   /* "qutip/cy/ptrace.pyx":114
4251  *             fact[kk] *= dims[ll]
4252  *     # If we make ilist a csr_matrix, then this is just spmv then sort
4253  *     return np.sort(np.dot(ilist, fact), 0)             # <<<<<<<<<<<<<<
4254  *
4255  *
4256  */
4257   __Pyx_XDECREF(((PyObject *)__pyx_r));
4258   __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_np); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 114, __pyx_L1_error)
4259   __Pyx_GOTREF(__pyx_t_1);
4260   __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_sort); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 114, __pyx_L1_error)
4261   __Pyx_GOTREF(__pyx_t_3);
4262   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
4263   __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_np); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 114, __pyx_L1_error)
4264   __Pyx_GOTREF(__pyx_t_2);
4265   __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_dot); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 114, __pyx_L1_error)
4266   __Pyx_GOTREF(__pyx_t_4);
4267   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
4268   __pyx_t_2 = __pyx_memoryview_fromslice(__pyx_v_ilist, 2, (PyObject *(*)(char *)) __pyx_memview_get_int, (int (*)(char *, PyObject *)) __pyx_memview_set_int, 0);; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 114, __pyx_L1_error)
4269   __Pyx_GOTREF(__pyx_t_2);
4270   __pyx_t_15 = __pyx_memoryview_fromslice(__pyx_v_fact, 1, (PyObject *(*)(char *)) __pyx_memview_get_int, (int (*)(char *, PyObject *)) __pyx_memview_set_int, 0);; if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 114, __pyx_L1_error)
4271   __Pyx_GOTREF(__pyx_t_15);
4272   __pyx_t_16 = NULL;
4273   __pyx_t_17 = 0;
4274   if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_4))) {
4275     __pyx_t_16 = PyMethod_GET_SELF(__pyx_t_4);
4276     if (likely(__pyx_t_16)) {
4277       PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
4278       __Pyx_INCREF(__pyx_t_16);
4279       __Pyx_INCREF(function);
4280       __Pyx_DECREF_SET(__pyx_t_4, function);
4281       __pyx_t_17 = 1;
4282     }
4283   }
4284   #if CYTHON_FAST_PYCALL
4285   if (PyFunction_Check(__pyx_t_4)) {
4286     PyObject *__pyx_temp[3] = {__pyx_t_16, __pyx_t_2, __pyx_t_15};
4287     __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_17, 2+__pyx_t_17); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 114, __pyx_L1_error)
4288     __Pyx_XDECREF(__pyx_t_16); __pyx_t_16 = 0;
4289     __Pyx_GOTREF(__pyx_t_1);
4290     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
4291     __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
4292   } else
4293   #endif
4294   #if CYTHON_FAST_PYCCALL
4295   if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) {
4296     PyObject *__pyx_temp[3] = {__pyx_t_16, __pyx_t_2, __pyx_t_15};
4297     __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_17, 2+__pyx_t_17); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 114, __pyx_L1_error)
4298     __Pyx_XDECREF(__pyx_t_16); __pyx_t_16 = 0;
4299     __Pyx_GOTREF(__pyx_t_1);
4300     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
4301     __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
4302   } else
4303   #endif
4304   {
4305     __pyx_t_18 = PyTuple_New(2+__pyx_t_17); if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 114, __pyx_L1_error)
4306     __Pyx_GOTREF(__pyx_t_18);
4307     if (__pyx_t_16) {
4308       __Pyx_GIVEREF(__pyx_t_16); PyTuple_SET_ITEM(__pyx_t_18, 0, __pyx_t_16); __pyx_t_16 = NULL;
4309     }
4310     __Pyx_GIVEREF(__pyx_t_2);
4311     PyTuple_SET_ITEM(__pyx_t_18, 0+__pyx_t_17, __pyx_t_2);
4312     __Pyx_GIVEREF(__pyx_t_15);
4313     PyTuple_SET_ITEM(__pyx_t_18, 1+__pyx_t_17, __pyx_t_15);
4314     __pyx_t_2 = 0;
4315     __pyx_t_15 = 0;
4316     __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_18, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 114, __pyx_L1_error)
4317     __Pyx_GOTREF(__pyx_t_1);
4318     __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
4319   }
4320   __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
4321   __pyx_t_4 = NULL;
4322   __pyx_t_17 = 0;
4323   if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
4324     __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
4325     if (likely(__pyx_t_4)) {
4326       PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
4327       __Pyx_INCREF(__pyx_t_4);
4328       __Pyx_INCREF(function);
4329       __Pyx_DECREF_SET(__pyx_t_3, function);
4330       __pyx_t_17 = 1;
4331     }
4332   }
4333   #if CYTHON_FAST_PYCALL
4334   if (PyFunction_Check(__pyx_t_3)) {
4335     PyObject *__pyx_temp[3] = {__pyx_t_4, __pyx_t_1, __pyx_int_0};
4336     __pyx_t_5 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_17, 2+__pyx_t_17); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 114, __pyx_L1_error)
4337     __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
4338     __Pyx_GOTREF(__pyx_t_5);
4339     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
4340   } else
4341   #endif
4342   #if CYTHON_FAST_PYCCALL
4343   if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
4344     PyObject *__pyx_temp[3] = {__pyx_t_4, __pyx_t_1, __pyx_int_0};
4345     __pyx_t_5 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_17, 2+__pyx_t_17); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 114, __pyx_L1_error)
4346     __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
4347     __Pyx_GOTREF(__pyx_t_5);
4348     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
4349   } else
4350   #endif
4351   {
4352     __pyx_t_18 = PyTuple_New(2+__pyx_t_17); if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 114, __pyx_L1_error)
4353     __Pyx_GOTREF(__pyx_t_18);
4354     if (__pyx_t_4) {
4355       __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_18, 0, __pyx_t_4); __pyx_t_4 = NULL;
4356     }
4357     __Pyx_GIVEREF(__pyx_t_1);
4358     PyTuple_SET_ITEM(__pyx_t_18, 0+__pyx_t_17, __pyx_t_1);
4359     __Pyx_INCREF(__pyx_int_0);
4360     __Pyx_GIVEREF(__pyx_int_0);
4361     PyTuple_SET_ITEM(__pyx_t_18, 1+__pyx_t_17, __pyx_int_0);
4362     __pyx_t_1 = 0;
4363     __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_18, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 114, __pyx_L1_error)
4364     __Pyx_GOTREF(__pyx_t_5);
4365     __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
4366   }
4367   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
4368   if (!(likely(((__pyx_t_5) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_5, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 114, __pyx_L1_error)
4369   __pyx_r = ((PyArrayObject *)__pyx_t_5);
4370   __pyx_t_5 = 0;
4371   goto __pyx_L0;
4372 
4373   /* "qutip/cy/ptrace.pyx":104
4374  * @cython.wraparound(False)
4375  * @cython.cdivision(True)
4376  * cpdef cnp.ndarray[int, ndim=1, mode='c'] _list2ind(int[:,::1] ilist, int[::1] dims):             # <<<<<<<<<<<<<<
4377  *     """!
4378  *     Private function returning indicies
4379  */
4380 
4381   /* function exit code */
4382   __pyx_L1_error:;
4383   __Pyx_XDECREF(__pyx_t_1);
4384   __Pyx_XDECREF(__pyx_t_2);
4385   __Pyx_XDECREF(__pyx_t_3);
4386   __Pyx_XDECREF(__pyx_t_4);
4387   __Pyx_XDECREF(__pyx_t_5);
4388   __PYX_XDEC_MEMVIEW(&__pyx_t_6, 1);
4389   __Pyx_XDECREF(__pyx_t_15);
4390   __Pyx_XDECREF(__pyx_t_16);
4391   __Pyx_XDECREF(__pyx_t_18);
4392   __Pyx_AddTraceback("qutip.cy.ptrace._list2ind", __pyx_clineno, __pyx_lineno, __pyx_filename);
4393   __pyx_r = 0;
4394   __pyx_L0:;
4395   __PYX_XDEC_MEMVIEW(&__pyx_v_fact, 1);
4396   __Pyx_XGIVEREF((PyObject *)__pyx_r);
4397   __Pyx_RefNannyFinishContext();
4398   return __pyx_r;
4399 }
4400 
4401 /* Python wrapper */
4402 static PyObject *__pyx_pw_5qutip_2cy_6ptrace_3_list2ind(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
4403 static char __pyx_doc_5qutip_2cy_6ptrace_2_list2ind[] = "!\n    Private function returning indicies\n    ";
__pyx_pw_5qutip_2cy_6ptrace_3_list2ind(PyObject * __pyx_self,PyObject * __pyx_args,PyObject * __pyx_kwds)4404 static PyObject *__pyx_pw_5qutip_2cy_6ptrace_3_list2ind(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
4405   __Pyx_memviewslice __pyx_v_ilist = { 0, 0, { 0 }, { 0 }, { 0 } };
4406   __Pyx_memviewslice __pyx_v_dims = { 0, 0, { 0 }, { 0 }, { 0 } };
4407   int __pyx_lineno = 0;
4408   const char *__pyx_filename = NULL;
4409   int __pyx_clineno = 0;
4410   PyObject *__pyx_r = 0;
4411   __Pyx_RefNannyDeclarations
4412   __Pyx_RefNannySetupContext("_list2ind (wrapper)", 0);
4413   {
4414     static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_ilist,&__pyx_n_s_dims,0};
4415     PyObject* values[2] = {0,0};
4416     if (unlikely(__pyx_kwds)) {
4417       Py_ssize_t kw_args;
4418       const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
4419       switch (pos_args) {
4420         case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
4421         CYTHON_FALLTHROUGH;
4422         case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
4423         CYTHON_FALLTHROUGH;
4424         case  0: break;
4425         default: goto __pyx_L5_argtuple_error;
4426       }
4427       kw_args = PyDict_Size(__pyx_kwds);
4428       switch (pos_args) {
4429         case  0:
4430         if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_ilist)) != 0)) kw_args--;
4431         else goto __pyx_L5_argtuple_error;
4432         CYTHON_FALLTHROUGH;
4433         case  1:
4434         if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_dims)) != 0)) kw_args--;
4435         else {
4436           __Pyx_RaiseArgtupleInvalid("_list2ind", 1, 2, 2, 1); __PYX_ERR(0, 104, __pyx_L3_error)
4437         }
4438       }
4439       if (unlikely(kw_args > 0)) {
4440         if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_list2ind") < 0)) __PYX_ERR(0, 104, __pyx_L3_error)
4441       }
4442     } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
4443       goto __pyx_L5_argtuple_error;
4444     } else {
4445       values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
4446       values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
4447     }
4448     __pyx_v_ilist = __Pyx_PyObject_to_MemoryviewSlice_d_dc_int(values[0], PyBUF_WRITABLE); if (unlikely(!__pyx_v_ilist.memview)) __PYX_ERR(0, 104, __pyx_L3_error)
4449     __pyx_v_dims = __Pyx_PyObject_to_MemoryviewSlice_dc_int(values[1], PyBUF_WRITABLE); if (unlikely(!__pyx_v_dims.memview)) __PYX_ERR(0, 104, __pyx_L3_error)
4450   }
4451   goto __pyx_L4_argument_unpacking_done;
4452   __pyx_L5_argtuple_error:;
4453   __Pyx_RaiseArgtupleInvalid("_list2ind", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 104, __pyx_L3_error)
4454   __pyx_L3_error:;
4455   __Pyx_AddTraceback("qutip.cy.ptrace._list2ind", __pyx_clineno, __pyx_lineno, __pyx_filename);
4456   __Pyx_RefNannyFinishContext();
4457   return NULL;
4458   __pyx_L4_argument_unpacking_done:;
4459   __pyx_r = __pyx_pf_5qutip_2cy_6ptrace_2_list2ind(__pyx_self, __pyx_v_ilist, __pyx_v_dims);
4460 
4461   /* function exit code */
4462   __Pyx_RefNannyFinishContext();
4463   return __pyx_r;
4464 }
4465 
__pyx_pf_5qutip_2cy_6ptrace_2_list2ind(CYTHON_UNUSED PyObject * __pyx_self,__Pyx_memviewslice __pyx_v_ilist,__Pyx_memviewslice __pyx_v_dims)4466 static PyObject *__pyx_pf_5qutip_2cy_6ptrace_2_list2ind(CYTHON_UNUSED PyObject *__pyx_self, __Pyx_memviewslice __pyx_v_ilist, __Pyx_memviewslice __pyx_v_dims) {
4467   PyObject *__pyx_r = NULL;
4468   __Pyx_RefNannyDeclarations
4469   PyObject *__pyx_t_1 = NULL;
4470   int __pyx_lineno = 0;
4471   const char *__pyx_filename = NULL;
4472   int __pyx_clineno = 0;
4473   __Pyx_RefNannySetupContext("_list2ind", 0);
4474   __Pyx_XDECREF(__pyx_r);
4475   if (unlikely(!__pyx_v_ilist.memview)) { __Pyx_RaiseUnboundLocalError("ilist"); __PYX_ERR(0, 104, __pyx_L1_error) }
4476   if (unlikely(!__pyx_v_dims.memview)) { __Pyx_RaiseUnboundLocalError("dims"); __PYX_ERR(0, 104, __pyx_L1_error) }
4477   __pyx_t_1 = ((PyObject *)__pyx_f_5qutip_2cy_6ptrace__list2ind(__pyx_v_ilist, __pyx_v_dims, 0)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 104, __pyx_L1_error)
4478   __Pyx_GOTREF(__pyx_t_1);
4479   __pyx_r = __pyx_t_1;
4480   __pyx_t_1 = 0;
4481   goto __pyx_L0;
4482 
4483   /* function exit code */
4484   __pyx_L1_error:;
4485   __Pyx_XDECREF(__pyx_t_1);
4486   __Pyx_AddTraceback("qutip.cy.ptrace._list2ind", __pyx_clineno, __pyx_lineno, __pyx_filename);
4487   __pyx_r = NULL;
4488   __pyx_L0:;
4489   __PYX_XDEC_MEMVIEW(&__pyx_v_ilist, 1);
4490   __PYX_XDEC_MEMVIEW(&__pyx_v_dims, 1);
4491   __Pyx_XGIVEREF(__pyx_r);
4492   __Pyx_RefNannyFinishContext();
4493   return __pyx_r;
4494 }
4495 
4496 /* "qutip/cy/ptrace.pyx":120
4497  * @cython.wraparound(False)
4498  * @cython.cdivision(True)
4499  * cpdef cnp.ndarray[int, ndim=2, mode='c'] _select(int[::1] sel, int[::1] dims, int M):             # <<<<<<<<<<<<<<
4500  *     """
4501  *     Private function finding selected components
4502  */
4503 
4504 static PyObject *__pyx_pw_5qutip_2cy_6ptrace_5_select(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
__pyx_f_5qutip_2cy_6ptrace__select(__Pyx_memviewslice __pyx_v_sel,__Pyx_memviewslice __pyx_v_dims,int __pyx_v_M,CYTHON_UNUSED int __pyx_skip_dispatch)4505 static PyArrayObject *__pyx_f_5qutip_2cy_6ptrace__select(__Pyx_memviewslice __pyx_v_sel, __Pyx_memviewslice __pyx_v_dims, int __pyx_v_M, CYTHON_UNUSED int __pyx_skip_dispatch) {
4506   size_t __pyx_v_ii;
4507   size_t __pyx_v_jj;
4508   size_t __pyx_v_kk;
4509   int __pyx_v__sel;
4510   int __pyx_v__prd;
4511   PyArrayObject *__pyx_v_ilist = 0;
4512   __Pyx_LocalBuf_ND __pyx_pybuffernd_ilist;
4513   __Pyx_Buffer __pyx_pybuffer_ilist;
4514   PyArrayObject *__pyx_r = NULL;
4515   __Pyx_RefNannyDeclarations
4516   PyObject *__pyx_t_1 = NULL;
4517   PyObject *__pyx_t_2 = NULL;
4518   PyObject *__pyx_t_3 = NULL;
4519   PyObject *__pyx_t_4 = NULL;
4520   PyObject *__pyx_t_5 = NULL;
4521   PyArrayObject *__pyx_t_6 = NULL;
4522   Py_ssize_t __pyx_t_7;
4523   Py_ssize_t __pyx_t_8;
4524   size_t __pyx_t_9;
4525   size_t __pyx_t_10;
4526   Py_ssize_t __pyx_t_11;
4527   Py_ssize_t __pyx_t_12;
4528   size_t __pyx_t_13;
4529   Py_ssize_t __pyx_t_14;
4530   int __pyx_t_15;
4531   int __pyx_t_16;
4532   Py_ssize_t __pyx_t_17;
4533   int __pyx_lineno = 0;
4534   const char *__pyx_filename = NULL;
4535   int __pyx_clineno = 0;
4536   __Pyx_RefNannySetupContext("_select", 0);
4537   __pyx_pybuffer_ilist.pybuffer.buf = NULL;
4538   __pyx_pybuffer_ilist.refcount = 0;
4539   __pyx_pybuffernd_ilist.data = NULL;
4540   __pyx_pybuffernd_ilist.rcbuffer = &__pyx_pybuffer_ilist;
4541 
4542   /* "qutip/cy/ptrace.pyx":126
4543  *     cdef size_t ii, jj, kk
4544  *     cdef int _sel, _prd
4545  *     cdef cnp.ndarray[int, ndim=2, mode='c'] ilist = np.zeros((M, dims.shape[0]), dtype=np.int32)             # <<<<<<<<<<<<<<
4546  *     for jj in range(sel.shape[0]):
4547  *         _sel =  sel[jj]
4548  */
4549   __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_np); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 126, __pyx_L1_error)
4550   __Pyx_GOTREF(__pyx_t_1);
4551   __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_zeros); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 126, __pyx_L1_error)
4552   __Pyx_GOTREF(__pyx_t_2);
4553   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
4554   __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_M); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 126, __pyx_L1_error)
4555   __Pyx_GOTREF(__pyx_t_1);
4556   __pyx_t_3 = PyInt_FromSsize_t((__pyx_v_dims.shape[0])); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 126, __pyx_L1_error)
4557   __Pyx_GOTREF(__pyx_t_3);
4558   __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 126, __pyx_L1_error)
4559   __Pyx_GOTREF(__pyx_t_4);
4560   __Pyx_GIVEREF(__pyx_t_1);
4561   PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_1);
4562   __Pyx_GIVEREF(__pyx_t_3);
4563   PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_3);
4564   __pyx_t_1 = 0;
4565   __pyx_t_3 = 0;
4566   __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 126, __pyx_L1_error)
4567   __Pyx_GOTREF(__pyx_t_3);
4568   __Pyx_GIVEREF(__pyx_t_4);
4569   PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_4);
4570   __pyx_t_4 = 0;
4571   __pyx_t_4 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 126, __pyx_L1_error)
4572   __Pyx_GOTREF(__pyx_t_4);
4573   __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_np); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 126, __pyx_L1_error)
4574   __Pyx_GOTREF(__pyx_t_1);
4575   __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_int32); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 126, __pyx_L1_error)
4576   __Pyx_GOTREF(__pyx_t_5);
4577   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
4578   if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_dtype, __pyx_t_5) < 0) __PYX_ERR(0, 126, __pyx_L1_error)
4579   __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
4580   __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 126, __pyx_L1_error)
4581   __Pyx_GOTREF(__pyx_t_5);
4582   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
4583   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
4584   __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
4585   if (!(likely(((__pyx_t_5) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_5, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 126, __pyx_L1_error)
4586   __pyx_t_6 = ((PyArrayObject *)__pyx_t_5);
4587   {
4588     __Pyx_BufFmt_StackElem __pyx_stack[1];
4589     if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_ilist.rcbuffer->pybuffer, (PyObject*)__pyx_t_6, &__Pyx_TypeInfo_int, PyBUF_FORMAT| PyBUF_C_CONTIGUOUS| PyBUF_WRITABLE, 2, 0, __pyx_stack) == -1)) {
4590       __pyx_v_ilist = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_pybuffernd_ilist.rcbuffer->pybuffer.buf = NULL;
4591       __PYX_ERR(0, 126, __pyx_L1_error)
4592     } else {__pyx_pybuffernd_ilist.diminfo[0].strides = __pyx_pybuffernd_ilist.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_ilist.diminfo[0].shape = __pyx_pybuffernd_ilist.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_ilist.diminfo[1].strides = __pyx_pybuffernd_ilist.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_ilist.diminfo[1].shape = __pyx_pybuffernd_ilist.rcbuffer->pybuffer.shape[1];
4593     }
4594   }
4595   __pyx_t_6 = 0;
4596   __pyx_v_ilist = ((PyArrayObject *)__pyx_t_5);
4597   __pyx_t_5 = 0;
4598 
4599   /* "qutip/cy/ptrace.pyx":127
4600  *     cdef int _sel, _prd
4601  *     cdef cnp.ndarray[int, ndim=2, mode='c'] ilist = np.zeros((M, dims.shape[0]), dtype=np.int32)
4602  *     for jj in range(sel.shape[0]):             # <<<<<<<<<<<<<<
4603  *         _sel =  sel[jj]
4604  *         _prd = 1
4605  */
4606   __pyx_t_7 = (__pyx_v_sel.shape[0]);
4607   __pyx_t_8 = __pyx_t_7;
4608   for (__pyx_t_9 = 0; __pyx_t_9 < __pyx_t_8; __pyx_t_9+=1) {
4609     __pyx_v_jj = __pyx_t_9;
4610 
4611     /* "qutip/cy/ptrace.pyx":128
4612  *     cdef cnp.ndarray[int, ndim=2, mode='c'] ilist = np.zeros((M, dims.shape[0]), dtype=np.int32)
4613  *     for jj in range(sel.shape[0]):
4614  *         _sel =  sel[jj]             # <<<<<<<<<<<<<<
4615  *         _prd = 1
4616  *         for kk in range(jj+1,sel.shape[0]):
4617  */
4618     __pyx_t_10 = __pyx_v_jj;
4619     __pyx_v__sel = (*((int *) ( /* dim=0 */ ((char *) (((int *) __pyx_v_sel.data) + __pyx_t_10)) )));
4620 
4621     /* "qutip/cy/ptrace.pyx":129
4622  *     for jj in range(sel.shape[0]):
4623  *         _sel =  sel[jj]
4624  *         _prd = 1             # <<<<<<<<<<<<<<
4625  *         for kk in range(jj+1,sel.shape[0]):
4626  *             _prd *= dims[sel[kk]]
4627  */
4628     __pyx_v__prd = 1;
4629 
4630     /* "qutip/cy/ptrace.pyx":130
4631  *         _sel =  sel[jj]
4632  *         _prd = 1
4633  *         for kk in range(jj+1,sel.shape[0]):             # <<<<<<<<<<<<<<
4634  *             _prd *= dims[sel[kk]]
4635  *         for ii in range(M):
4636  */
4637     __pyx_t_11 = (__pyx_v_sel.shape[0]);
4638     __pyx_t_12 = __pyx_t_11;
4639     for (__pyx_t_10 = (__pyx_v_jj + 1); __pyx_t_10 < __pyx_t_12; __pyx_t_10+=1) {
4640       __pyx_v_kk = __pyx_t_10;
4641 
4642       /* "qutip/cy/ptrace.pyx":131
4643  *         _prd = 1
4644  *         for kk in range(jj+1,sel.shape[0]):
4645  *             _prd *= dims[sel[kk]]             # <<<<<<<<<<<<<<
4646  *         for ii in range(M):
4647  *             ilist[ii, _sel] = <int>(trunc(ii / _prd) % dims[_sel])
4648  */
4649       __pyx_t_13 = __pyx_v_kk;
4650       __pyx_t_14 = (*((int *) ( /* dim=0 */ ((char *) (((int *) __pyx_v_sel.data) + __pyx_t_13)) )));
4651       __pyx_v__prd = (__pyx_v__prd * (*((int *) ( /* dim=0 */ ((char *) (((int *) __pyx_v_dims.data) + __pyx_t_14)) ))));
4652     }
4653 
4654     /* "qutip/cy/ptrace.pyx":132
4655  *         for kk in range(jj+1,sel.shape[0]):
4656  *             _prd *= dims[sel[kk]]
4657  *         for ii in range(M):             # <<<<<<<<<<<<<<
4658  *             ilist[ii, _sel] = <int>(trunc(ii / _prd) % dims[_sel])
4659  *     return ilist
4660  */
4661     __pyx_t_15 = __pyx_v_M;
4662     __pyx_t_16 = __pyx_t_15;
4663     for (__pyx_t_10 = 0; __pyx_t_10 < __pyx_t_16; __pyx_t_10+=1) {
4664       __pyx_v_ii = __pyx_t_10;
4665 
4666       /* "qutip/cy/ptrace.pyx":133
4667  *             _prd *= dims[sel[kk]]
4668  *         for ii in range(M):
4669  *             ilist[ii, _sel] = <int>(trunc(ii / _prd) % dims[_sel])             # <<<<<<<<<<<<<<
4670  *     return ilist
4671  *
4672  */
4673       __pyx_t_14 = __pyx_v__sel;
4674       __pyx_t_13 = __pyx_v_ii;
4675       __pyx_t_17 = __pyx_v__sel;
4676       *__Pyx_BufPtrCContig2d(int *, __pyx_pybuffernd_ilist.rcbuffer->pybuffer.buf, __pyx_t_13, __pyx_pybuffernd_ilist.diminfo[0].strides, __pyx_t_17, __pyx_pybuffernd_ilist.diminfo[1].strides) = ((int)fmod(trunc((__pyx_v_ii / ((size_t)__pyx_v__prd))), (*((int *) ( /* dim=0 */ ((char *) (((int *) __pyx_v_dims.data) + __pyx_t_14)) )))));
4677     }
4678   }
4679 
4680   /* "qutip/cy/ptrace.pyx":134
4681  *         for ii in range(M):
4682  *             ilist[ii, _sel] = <int>(trunc(ii / _prd) % dims[_sel])
4683  *     return ilist             # <<<<<<<<<<<<<<
4684  *
4685  *
4686  */
4687   __Pyx_XDECREF(((PyObject *)__pyx_r));
4688   __Pyx_INCREF(((PyObject *)__pyx_v_ilist));
4689   __pyx_r = ((PyArrayObject *)__pyx_v_ilist);
4690   goto __pyx_L0;
4691 
4692   /* "qutip/cy/ptrace.pyx":120
4693  * @cython.wraparound(False)
4694  * @cython.cdivision(True)
4695  * cpdef cnp.ndarray[int, ndim=2, mode='c'] _select(int[::1] sel, int[::1] dims, int M):             # <<<<<<<<<<<<<<
4696  *     """
4697  *     Private function finding selected components
4698  */
4699 
4700   /* function exit code */
4701   __pyx_L1_error:;
4702   __Pyx_XDECREF(__pyx_t_1);
4703   __Pyx_XDECREF(__pyx_t_2);
4704   __Pyx_XDECREF(__pyx_t_3);
4705   __Pyx_XDECREF(__pyx_t_4);
4706   __Pyx_XDECREF(__pyx_t_5);
4707   { PyObject *__pyx_type, *__pyx_value, *__pyx_tb;
4708     __Pyx_PyThreadState_declare
4709     __Pyx_PyThreadState_assign
4710     __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb);
4711     __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_ilist.rcbuffer->pybuffer);
4712   __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}
4713   __Pyx_AddTraceback("qutip.cy.ptrace._select", __pyx_clineno, __pyx_lineno, __pyx_filename);
4714   __pyx_r = 0;
4715   goto __pyx_L2;
4716   __pyx_L0:;
4717   __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_ilist.rcbuffer->pybuffer);
4718   __pyx_L2:;
4719   __Pyx_XDECREF((PyObject *)__pyx_v_ilist);
4720   __Pyx_XGIVEREF((PyObject *)__pyx_r);
4721   __Pyx_RefNannyFinishContext();
4722   return __pyx_r;
4723 }
4724 
4725 /* Python wrapper */
4726 static PyObject *__pyx_pw_5qutip_2cy_6ptrace_5_select(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
4727 static char __pyx_doc_5qutip_2cy_6ptrace_4_select[] = "\n    Private function finding selected components\n    ";
__pyx_pw_5qutip_2cy_6ptrace_5_select(PyObject * __pyx_self,PyObject * __pyx_args,PyObject * __pyx_kwds)4728 static PyObject *__pyx_pw_5qutip_2cy_6ptrace_5_select(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
4729   __Pyx_memviewslice __pyx_v_sel = { 0, 0, { 0 }, { 0 }, { 0 } };
4730   __Pyx_memviewslice __pyx_v_dims = { 0, 0, { 0 }, { 0 }, { 0 } };
4731   int __pyx_v_M;
4732   int __pyx_lineno = 0;
4733   const char *__pyx_filename = NULL;
4734   int __pyx_clineno = 0;
4735   PyObject *__pyx_r = 0;
4736   __Pyx_RefNannyDeclarations
4737   __Pyx_RefNannySetupContext("_select (wrapper)", 0);
4738   {
4739     static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_sel_2,&__pyx_n_s_dims,&__pyx_n_s_M,0};
4740     PyObject* values[3] = {0,0,0};
4741     if (unlikely(__pyx_kwds)) {
4742       Py_ssize_t kw_args;
4743       const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
4744       switch (pos_args) {
4745         case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
4746         CYTHON_FALLTHROUGH;
4747         case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
4748         CYTHON_FALLTHROUGH;
4749         case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
4750         CYTHON_FALLTHROUGH;
4751         case  0: break;
4752         default: goto __pyx_L5_argtuple_error;
4753       }
4754       kw_args = PyDict_Size(__pyx_kwds);
4755       switch (pos_args) {
4756         case  0:
4757         if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_sel_2)) != 0)) kw_args--;
4758         else goto __pyx_L5_argtuple_error;
4759         CYTHON_FALLTHROUGH;
4760         case  1:
4761         if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_dims)) != 0)) kw_args--;
4762         else {
4763           __Pyx_RaiseArgtupleInvalid("_select", 1, 3, 3, 1); __PYX_ERR(0, 120, __pyx_L3_error)
4764         }
4765         CYTHON_FALLTHROUGH;
4766         case  2:
4767         if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_M)) != 0)) kw_args--;
4768         else {
4769           __Pyx_RaiseArgtupleInvalid("_select", 1, 3, 3, 2); __PYX_ERR(0, 120, __pyx_L3_error)
4770         }
4771       }
4772       if (unlikely(kw_args > 0)) {
4773         if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_select") < 0)) __PYX_ERR(0, 120, __pyx_L3_error)
4774       }
4775     } else if (PyTuple_GET_SIZE(__pyx_args) != 3) {
4776       goto __pyx_L5_argtuple_error;
4777     } else {
4778       values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
4779       values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
4780       values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
4781     }
4782     __pyx_v_sel = __Pyx_PyObject_to_MemoryviewSlice_dc_int(values[0], PyBUF_WRITABLE); if (unlikely(!__pyx_v_sel.memview)) __PYX_ERR(0, 120, __pyx_L3_error)
4783     __pyx_v_dims = __Pyx_PyObject_to_MemoryviewSlice_dc_int(values[1], PyBUF_WRITABLE); if (unlikely(!__pyx_v_dims.memview)) __PYX_ERR(0, 120, __pyx_L3_error)
4784     __pyx_v_M = __Pyx_PyInt_As_int(values[2]); if (unlikely((__pyx_v_M == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 120, __pyx_L3_error)
4785   }
4786   goto __pyx_L4_argument_unpacking_done;
4787   __pyx_L5_argtuple_error:;
4788   __Pyx_RaiseArgtupleInvalid("_select", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 120, __pyx_L3_error)
4789   __pyx_L3_error:;
4790   __Pyx_AddTraceback("qutip.cy.ptrace._select", __pyx_clineno, __pyx_lineno, __pyx_filename);
4791   __Pyx_RefNannyFinishContext();
4792   return NULL;
4793   __pyx_L4_argument_unpacking_done:;
4794   __pyx_r = __pyx_pf_5qutip_2cy_6ptrace_4_select(__pyx_self, __pyx_v_sel, __pyx_v_dims, __pyx_v_M);
4795 
4796   /* function exit code */
4797   __Pyx_RefNannyFinishContext();
4798   return __pyx_r;
4799 }
4800 
__pyx_pf_5qutip_2cy_6ptrace_4_select(CYTHON_UNUSED PyObject * __pyx_self,__Pyx_memviewslice __pyx_v_sel,__Pyx_memviewslice __pyx_v_dims,int __pyx_v_M)4801 static PyObject *__pyx_pf_5qutip_2cy_6ptrace_4_select(CYTHON_UNUSED PyObject *__pyx_self, __Pyx_memviewslice __pyx_v_sel, __Pyx_memviewslice __pyx_v_dims, int __pyx_v_M) {
4802   PyObject *__pyx_r = NULL;
4803   __Pyx_RefNannyDeclarations
4804   PyObject *__pyx_t_1 = NULL;
4805   int __pyx_lineno = 0;
4806   const char *__pyx_filename = NULL;
4807   int __pyx_clineno = 0;
4808   __Pyx_RefNannySetupContext("_select", 0);
4809   __Pyx_XDECREF(__pyx_r);
4810   if (unlikely(!__pyx_v_sel.memview)) { __Pyx_RaiseUnboundLocalError("sel"); __PYX_ERR(0, 120, __pyx_L1_error) }
4811   if (unlikely(!__pyx_v_dims.memview)) { __Pyx_RaiseUnboundLocalError("dims"); __PYX_ERR(0, 120, __pyx_L1_error) }
4812   __pyx_t_1 = ((PyObject *)__pyx_f_5qutip_2cy_6ptrace__select(__pyx_v_sel, __pyx_v_dims, __pyx_v_M, 0)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 120, __pyx_L1_error)
4813   __Pyx_GOTREF(__pyx_t_1);
4814   __pyx_r = __pyx_t_1;
4815   __pyx_t_1 = 0;
4816   goto __pyx_L0;
4817 
4818   /* function exit code */
4819   __pyx_L1_error:;
4820   __Pyx_XDECREF(__pyx_t_1);
4821   __Pyx_AddTraceback("qutip.cy.ptrace._select", __pyx_clineno, __pyx_lineno, __pyx_filename);
4822   __pyx_r = NULL;
4823   __pyx_L0:;
4824   __PYX_XDEC_MEMVIEW(&__pyx_v_sel, 1);
4825   __PYX_XDEC_MEMVIEW(&__pyx_v_dims, 1);
4826   __Pyx_XGIVEREF(__pyx_r);
4827   __Pyx_RefNannyFinishContext();
4828   return __pyx_r;
4829 }
4830 
4831 /* "qutip/cy/ptrace.pyx":139
4832  * @cython.boundscheck(False)
4833  * @cython.wraparound(False)
4834  * cdef int _in(int val, int[::1] vec):             # <<<<<<<<<<<<<<
4835  *     # val in vec in pure cython
4836  *     cdef int ii
4837  */
4838 
__pyx_f_5qutip_2cy_6ptrace__in(int __pyx_v_val,__Pyx_memviewslice __pyx_v_vec)4839 static int __pyx_f_5qutip_2cy_6ptrace__in(int __pyx_v_val, __Pyx_memviewslice __pyx_v_vec) {
4840   int __pyx_v_ii;
4841   int __pyx_r;
4842   __Pyx_RefNannyDeclarations
4843   Py_ssize_t __pyx_t_1;
4844   Py_ssize_t __pyx_t_2;
4845   int __pyx_t_3;
4846   Py_ssize_t __pyx_t_4;
4847   int __pyx_t_5;
4848   __Pyx_RefNannySetupContext("_in", 0);
4849 
4850   /* "qutip/cy/ptrace.pyx":142
4851  *     # val in vec in pure cython
4852  *     cdef int ii
4853  *     for ii in range(vec.shape[0]):             # <<<<<<<<<<<<<<
4854  *         if val == vec[ii]:
4855  *             return 1
4856  */
4857   __pyx_t_1 = (__pyx_v_vec.shape[0]);
4858   __pyx_t_2 = __pyx_t_1;
4859   for (__pyx_t_3 = 0; __pyx_t_3 < __pyx_t_2; __pyx_t_3+=1) {
4860     __pyx_v_ii = __pyx_t_3;
4861 
4862     /* "qutip/cy/ptrace.pyx":143
4863  *     cdef int ii
4864  *     for ii in range(vec.shape[0]):
4865  *         if val == vec[ii]:             # <<<<<<<<<<<<<<
4866  *             return 1
4867  *     return 0
4868  */
4869     __pyx_t_4 = __pyx_v_ii;
4870     __pyx_t_5 = ((__pyx_v_val == (*((int *) ( /* dim=0 */ ((char *) (((int *) __pyx_v_vec.data) + __pyx_t_4)) )))) != 0);
4871     if (__pyx_t_5) {
4872 
4873       /* "qutip/cy/ptrace.pyx":144
4874  *     for ii in range(vec.shape[0]):
4875  *         if val == vec[ii]:
4876  *             return 1             # <<<<<<<<<<<<<<
4877  *     return 0
4878  *
4879  */
4880       __pyx_r = 1;
4881       goto __pyx_L0;
4882 
4883       /* "qutip/cy/ptrace.pyx":143
4884  *     cdef int ii
4885  *     for ii in range(vec.shape[0]):
4886  *         if val == vec[ii]:             # <<<<<<<<<<<<<<
4887  *             return 1
4888  *     return 0
4889  */
4890     }
4891   }
4892 
4893   /* "qutip/cy/ptrace.pyx":145
4894  *         if val == vec[ii]:
4895  *             return 1
4896  *     return 0             # <<<<<<<<<<<<<<
4897  *
4898  *
4899  */
4900   __pyx_r = 0;
4901   goto __pyx_L0;
4902 
4903   /* "qutip/cy/ptrace.pyx":139
4904  * @cython.boundscheck(False)
4905  * @cython.wraparound(False)
4906  * cdef int _in(int val, int[::1] vec):             # <<<<<<<<<<<<<<
4907  *     # val in vec in pure cython
4908  *     cdef int ii
4909  */
4910 
4911   /* function exit code */
4912   __pyx_L0:;
4913   __Pyx_RefNannyFinishContext();
4914   return __pyx_r;
4915 }
4916 
4917 /* "qutip/cy/ptrace.pyx":151
4918  * @cython.wraparound(False)
4919  * @cython.cdivision(True)
4920  * cdef void _i2_k_t(int N,             # <<<<<<<<<<<<<<
4921  *                  int[:, ::1] tensor_table,
4922  *                  int[::1] out):
4923  */
4924 
__pyx_f_5qutip_2cy_6ptrace__i2_k_t(int __pyx_v_N,__Pyx_memviewslice __pyx_v_tensor_table,__Pyx_memviewslice __pyx_v_out)4925 static void __pyx_f_5qutip_2cy_6ptrace__i2_k_t(int __pyx_v_N, __Pyx_memviewslice __pyx_v_tensor_table, __Pyx_memviewslice __pyx_v_out) {
4926   int __pyx_v_ii;
4927   int __pyx_v_t1;
4928   int __pyx_v_t2;
4929   __Pyx_RefNannyDeclarations
4930   Py_ssize_t __pyx_t_1;
4931   Py_ssize_t __pyx_t_2;
4932   Py_ssize_t __pyx_t_3;
4933   int __pyx_t_4;
4934   Py_ssize_t __pyx_t_5;
4935   Py_ssize_t __pyx_t_6;
4936   __Pyx_RefNannySetupContext("_i2_k_t", 0);
4937 
4938   /* "qutip/cy/ptrace.pyx":156
4939  *     # indices determining function for ptrace
4940  *     cdef int ii, t1, t2
4941  *     out[0] = 0             # <<<<<<<<<<<<<<
4942  *     out[1] = 0
4943  *     for ii in range(tensor_table.shape[1]):
4944  */
4945   __pyx_t_1 = 0;
4946   *((int *) ( /* dim=0 */ ((char *) (((int *) __pyx_v_out.data) + __pyx_t_1)) )) = 0;
4947 
4948   /* "qutip/cy/ptrace.pyx":157
4949  *     cdef int ii, t1, t2
4950  *     out[0] = 0
4951  *     out[1] = 0             # <<<<<<<<<<<<<<
4952  *     for ii in range(tensor_table.shape[1]):
4953  *         t1 = tensor_table[0, ii]
4954  */
4955   __pyx_t_1 = 1;
4956   *((int *) ( /* dim=0 */ ((char *) (((int *) __pyx_v_out.data) + __pyx_t_1)) )) = 0;
4957 
4958   /* "qutip/cy/ptrace.pyx":158
4959  *     out[0] = 0
4960  *     out[1] = 0
4961  *     for ii in range(tensor_table.shape[1]):             # <<<<<<<<<<<<<<
4962  *         t1 = tensor_table[0, ii]
4963  *         t2 = N / t1
4964  */
4965   __pyx_t_2 = (__pyx_v_tensor_table.shape[1]);
4966   __pyx_t_3 = __pyx_t_2;
4967   for (__pyx_t_4 = 0; __pyx_t_4 < __pyx_t_3; __pyx_t_4+=1) {
4968     __pyx_v_ii = __pyx_t_4;
4969 
4970     /* "qutip/cy/ptrace.pyx":159
4971  *     out[1] = 0
4972  *     for ii in range(tensor_table.shape[1]):
4973  *         t1 = tensor_table[0, ii]             # <<<<<<<<<<<<<<
4974  *         t2 = N / t1
4975  *         N = N % t1
4976  */
4977     __pyx_t_1 = 0;
4978     __pyx_t_5 = __pyx_v_ii;
4979     __pyx_v_t1 = (*((int *) ( /* dim=1 */ ((char *) (((int *) ( /* dim=0 */ (__pyx_v_tensor_table.data + __pyx_t_1 * __pyx_v_tensor_table.strides[0]) )) + __pyx_t_5)) )));
4980 
4981     /* "qutip/cy/ptrace.pyx":160
4982  *     for ii in range(tensor_table.shape[1]):
4983  *         t1 = tensor_table[0, ii]
4984  *         t2 = N / t1             # <<<<<<<<<<<<<<
4985  *         N = N % t1
4986  *         out[0] += tensor_table[1, ii] * t2
4987  */
4988     __pyx_v_t2 = (__pyx_v_N / __pyx_v_t1);
4989 
4990     /* "qutip/cy/ptrace.pyx":161
4991  *         t1 = tensor_table[0, ii]
4992  *         t2 = N / t1
4993  *         N = N % t1             # <<<<<<<<<<<<<<
4994  *         out[0] += tensor_table[1, ii] * t2
4995  *         out[1] += tensor_table[2, ii] * t2
4996  */
4997     __pyx_v_N = (__pyx_v_N % __pyx_v_t1);
4998 
4999     /* "qutip/cy/ptrace.pyx":162
5000  *         t2 = N / t1
5001  *         N = N % t1
5002  *         out[0] += tensor_table[1, ii] * t2             # <<<<<<<<<<<<<<
5003  *         out[1] += tensor_table[2, ii] * t2
5004  *
5005  */
5006     __pyx_t_5 = 1;
5007     __pyx_t_1 = __pyx_v_ii;
5008     __pyx_t_6 = 0;
5009     *((int *) ( /* dim=0 */ ((char *) (((int *) __pyx_v_out.data) + __pyx_t_6)) )) += ((*((int *) ( /* dim=1 */ ((char *) (((int *) ( /* dim=0 */ (__pyx_v_tensor_table.data + __pyx_t_5 * __pyx_v_tensor_table.strides[0]) )) + __pyx_t_1)) ))) * __pyx_v_t2);
5010 
5011     /* "qutip/cy/ptrace.pyx":163
5012  *         N = N % t1
5013  *         out[0] += tensor_table[1, ii] * t2
5014  *         out[1] += tensor_table[2, ii] * t2             # <<<<<<<<<<<<<<
5015  *
5016  *
5017  */
5018     __pyx_t_1 = 2;
5019     __pyx_t_5 = __pyx_v_ii;
5020     __pyx_t_6 = 1;
5021     *((int *) ( /* dim=0 */ ((char *) (((int *) __pyx_v_out.data) + __pyx_t_6)) )) += ((*((int *) ( /* dim=1 */ ((char *) (((int *) ( /* dim=0 */ (__pyx_v_tensor_table.data + __pyx_t_1 * __pyx_v_tensor_table.strides[0]) )) + __pyx_t_5)) ))) * __pyx_v_t2);
5022   }
5023 
5024   /* "qutip/cy/ptrace.pyx":151
5025  * @cython.wraparound(False)
5026  * @cython.cdivision(True)
5027  * cdef void _i2_k_t(int N,             # <<<<<<<<<<<<<<
5028  *                  int[:, ::1] tensor_table,
5029  *                  int[::1] out):
5030  */
5031 
5032   /* function exit code */
5033   __Pyx_RefNannyFinishContext();
5034 }
5035 
5036 /* "qutip/cy/ptrace.pyx":169
5037  * @cython.wraparound(False)
5038  * @cython.cdivision(True)
5039  * def _ptrace(object rho, sel): # work for N<= 26 on 16G Ram             # <<<<<<<<<<<<<<
5040  *     cdef int[::1] _sel
5041  *     cdef object _oper
5042  */
5043 
5044 /* Python wrapper */
5045 static PyObject *__pyx_pw_5qutip_2cy_6ptrace_7_ptrace(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
5046 static PyMethodDef __pyx_mdef_5qutip_2cy_6ptrace_7_ptrace = {"_ptrace", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_5qutip_2cy_6ptrace_7_ptrace, METH_VARARGS|METH_KEYWORDS, 0};
__pyx_pw_5qutip_2cy_6ptrace_7_ptrace(PyObject * __pyx_self,PyObject * __pyx_args,PyObject * __pyx_kwds)5047 static PyObject *__pyx_pw_5qutip_2cy_6ptrace_7_ptrace(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
5048   PyObject *__pyx_v_rho = 0;
5049   PyObject *__pyx_v_sel = 0;
5050   int __pyx_lineno = 0;
5051   const char *__pyx_filename = NULL;
5052   int __pyx_clineno = 0;
5053   PyObject *__pyx_r = 0;
5054   __Pyx_RefNannyDeclarations
5055   __Pyx_RefNannySetupContext("_ptrace (wrapper)", 0);
5056   {
5057     static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_rho,&__pyx_n_s_sel_2,0};
5058     PyObject* values[2] = {0,0};
5059     if (unlikely(__pyx_kwds)) {
5060       Py_ssize_t kw_args;
5061       const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
5062       switch (pos_args) {
5063         case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
5064         CYTHON_FALLTHROUGH;
5065         case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
5066         CYTHON_FALLTHROUGH;
5067         case  0: break;
5068         default: goto __pyx_L5_argtuple_error;
5069       }
5070       kw_args = PyDict_Size(__pyx_kwds);
5071       switch (pos_args) {
5072         case  0:
5073         if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_rho)) != 0)) kw_args--;
5074         else goto __pyx_L5_argtuple_error;
5075         CYTHON_FALLTHROUGH;
5076         case  1:
5077         if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_sel_2)) != 0)) kw_args--;
5078         else {
5079           __Pyx_RaiseArgtupleInvalid("_ptrace", 1, 2, 2, 1); __PYX_ERR(0, 169, __pyx_L3_error)
5080         }
5081       }
5082       if (unlikely(kw_args > 0)) {
5083         if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_ptrace") < 0)) __PYX_ERR(0, 169, __pyx_L3_error)
5084       }
5085     } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
5086       goto __pyx_L5_argtuple_error;
5087     } else {
5088       values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
5089       values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
5090     }
5091     __pyx_v_rho = values[0];
5092     __pyx_v_sel = values[1];
5093   }
5094   goto __pyx_L4_argument_unpacking_done;
5095   __pyx_L5_argtuple_error:;
5096   __Pyx_RaiseArgtupleInvalid("_ptrace", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 169, __pyx_L3_error)
5097   __pyx_L3_error:;
5098   __Pyx_AddTraceback("qutip.cy.ptrace._ptrace", __pyx_clineno, __pyx_lineno, __pyx_filename);
5099   __Pyx_RefNannyFinishContext();
5100   return NULL;
5101   __pyx_L4_argument_unpacking_done:;
5102   __pyx_r = __pyx_pf_5qutip_2cy_6ptrace_6_ptrace(__pyx_self, __pyx_v_rho, __pyx_v_sel);
5103 
5104   /* function exit code */
5105   __Pyx_RefNannyFinishContext();
5106   return __pyx_r;
5107 }
5108 
__pyx_pf_5qutip_2cy_6ptrace_6_ptrace(CYTHON_UNUSED PyObject * __pyx_self,PyObject * __pyx_v_rho,PyObject * __pyx_v_sel)5109 static PyObject *__pyx_pf_5qutip_2cy_6ptrace_6_ptrace(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_rho, PyObject *__pyx_v_sel) {
5110   __Pyx_memviewslice __pyx_v__sel = { 0, 0, { 0 }, { 0 }, { 0 } };
5111   PyObject *__pyx_v__oper = 0;
5112   size_t __pyx_v_ii;
5113   size_t __pyx_v_factor_keep;
5114   size_t __pyx_v_factor_trace;
5115   size_t __pyx_v_factor_tensor;
5116   PyArrayObject *__pyx_v_drho = 0;
5117   int __pyx_v_num_dims;
5118   __Pyx_memviewslice __pyx_v_tensor_table = { 0, 0, { 0 }, { 0 }, { 0 } };
5119   PyObject *__pyx_v_dims_kept0 = NULL;
5120   PyObject *__pyx_v_rho1_dims = NULL;
5121   PyObject *__pyx_v_rho1_shape = NULL;
5122   __Pyx_LocalBuf_ND __pyx_pybuffernd_drho;
5123   __Pyx_Buffer __pyx_pybuffer_drho;
5124   PyObject *__pyx_r = NULL;
5125   __Pyx_RefNannyDeclarations
5126   PyObject *__pyx_t_1 = NULL;
5127   PyObject *__pyx_t_2 = NULL;
5128   PyObject *__pyx_t_3 = NULL;
5129   PyObject *__pyx_t_4 = NULL;
5130   PyObject *__pyx_t_5 = NULL;
5131   PyObject *__pyx_t_6 = NULL;
5132   PyArrayObject *__pyx_t_7 = NULL;
5133   __Pyx_memviewslice __pyx_t_8 = { 0, 0, { 0 }, { 0 }, { 0 } };
5134   int __pyx_t_9;
5135   int __pyx_t_10;
5136   __Pyx_memviewslice __pyx_t_11 = { 0, 0, { 0 }, { 0 }, { 0 } };
5137   Py_ssize_t __pyx_t_12;
5138   Py_ssize_t __pyx_t_13;
5139   size_t __pyx_t_14;
5140   size_t __pyx_t_15;
5141   size_t __pyx_t_16;
5142   Py_ssize_t __pyx_t_17;
5143   int __pyx_lineno = 0;
5144   const char *__pyx_filename = NULL;
5145   int __pyx_clineno = 0;
5146   __Pyx_RefNannySetupContext("_ptrace", 0);
5147   __pyx_pybuffer_drho.pybuffer.buf = NULL;
5148   __pyx_pybuffer_drho.refcount = 0;
5149   __pyx_pybuffernd_drho.data = NULL;
5150   __pyx_pybuffernd_drho.rcbuffer = &__pyx_pybuffer_drho;
5151 
5152   /* "qutip/cy/ptrace.pyx":173
5153  *     cdef object _oper
5154  *     cdef size_t ii
5155  *     cdef size_t factor_keep = 1, factor_trace = 1, factor_tensor = 1             # <<<<<<<<<<<<<<
5156  *     cdef cnp.ndarray[int, ndim=1, mode='c'] drho = np.asarray(rho.dims[0], dtype=np.int32).ravel()
5157  *     cdef int num_dims = drho.shape[0]
5158  */
5159   __pyx_v_factor_keep = 1;
5160   __pyx_v_factor_trace = 1;
5161   __pyx_v_factor_tensor = 1;
5162 
5163   /* "qutip/cy/ptrace.pyx":174
5164  *     cdef size_t ii
5165  *     cdef size_t factor_keep = 1, factor_trace = 1, factor_tensor = 1
5166  *     cdef cnp.ndarray[int, ndim=1, mode='c'] drho = np.asarray(rho.dims[0], dtype=np.int32).ravel()             # <<<<<<<<<<<<<<
5167  *     cdef int num_dims = drho.shape[0]
5168  *     cdef int[:, ::1] tensor_table = np.zeros((3, num_dims), dtype=np.int32)
5169  */
5170   __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_np); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 174, __pyx_L1_error)
5171   __Pyx_GOTREF(__pyx_t_2);
5172   __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_asarray); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 174, __pyx_L1_error)
5173   __Pyx_GOTREF(__pyx_t_3);
5174   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
5175   __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_rho, __pyx_n_s_dims); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 174, __pyx_L1_error)
5176   __Pyx_GOTREF(__pyx_t_2);
5177   __pyx_t_4 = __Pyx_GetItemInt(__pyx_t_2, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 174, __pyx_L1_error)
5178   __Pyx_GOTREF(__pyx_t_4);
5179   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
5180   __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 174, __pyx_L1_error)
5181   __Pyx_GOTREF(__pyx_t_2);
5182   __Pyx_GIVEREF(__pyx_t_4);
5183   PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_4);
5184   __pyx_t_4 = 0;
5185   __pyx_t_4 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 174, __pyx_L1_error)
5186   __Pyx_GOTREF(__pyx_t_4);
5187   __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_n_s_np); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 174, __pyx_L1_error)
5188   __Pyx_GOTREF(__pyx_t_5);
5189   __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_int32); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 174, __pyx_L1_error)
5190   __Pyx_GOTREF(__pyx_t_6);
5191   __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
5192   if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_dtype, __pyx_t_6) < 0) __PYX_ERR(0, 174, __pyx_L1_error)
5193   __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
5194   __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_2, __pyx_t_4); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 174, __pyx_L1_error)
5195   __Pyx_GOTREF(__pyx_t_6);
5196   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
5197   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
5198   __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
5199   __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_ravel); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 174, __pyx_L1_error)
5200   __Pyx_GOTREF(__pyx_t_4);
5201   __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
5202   __pyx_t_6 = NULL;
5203   if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_4))) {
5204     __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_4);
5205     if (likely(__pyx_t_6)) {
5206       PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
5207       __Pyx_INCREF(__pyx_t_6);
5208       __Pyx_INCREF(function);
5209       __Pyx_DECREF_SET(__pyx_t_4, function);
5210     }
5211   }
5212   __pyx_t_1 = (__pyx_t_6) ? __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_6) : __Pyx_PyObject_CallNoArg(__pyx_t_4);
5213   __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
5214   if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 174, __pyx_L1_error)
5215   __Pyx_GOTREF(__pyx_t_1);
5216   __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
5217   if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 174, __pyx_L1_error)
5218   __pyx_t_7 = ((PyArrayObject *)__pyx_t_1);
5219   {
5220     __Pyx_BufFmt_StackElem __pyx_stack[1];
5221     if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_drho.rcbuffer->pybuffer, (PyObject*)__pyx_t_7, &__Pyx_TypeInfo_int, PyBUF_FORMAT| PyBUF_C_CONTIGUOUS, 1, 0, __pyx_stack) == -1)) {
5222       __pyx_v_drho = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_pybuffernd_drho.rcbuffer->pybuffer.buf = NULL;
5223       __PYX_ERR(0, 174, __pyx_L1_error)
5224     } else {__pyx_pybuffernd_drho.diminfo[0].strides = __pyx_pybuffernd_drho.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_drho.diminfo[0].shape = __pyx_pybuffernd_drho.rcbuffer->pybuffer.shape[0];
5225     }
5226   }
5227   __pyx_t_7 = 0;
5228   __pyx_v_drho = ((PyArrayObject *)__pyx_t_1);
5229   __pyx_t_1 = 0;
5230 
5231   /* "qutip/cy/ptrace.pyx":175
5232  *     cdef size_t factor_keep = 1, factor_trace = 1, factor_tensor = 1
5233  *     cdef cnp.ndarray[int, ndim=1, mode='c'] drho = np.asarray(rho.dims[0], dtype=np.int32).ravel()
5234  *     cdef int num_dims = drho.shape[0]             # <<<<<<<<<<<<<<
5235  *     cdef int[:, ::1] tensor_table = np.zeros((3, num_dims), dtype=np.int32)
5236  *
5237  */
5238   __pyx_v_num_dims = (__pyx_v_drho->dimensions[0]);
5239 
5240   /* "qutip/cy/ptrace.pyx":176
5241  *     cdef cnp.ndarray[int, ndim=1, mode='c'] drho = np.asarray(rho.dims[0], dtype=np.int32).ravel()
5242  *     cdef int num_dims = drho.shape[0]
5243  *     cdef int[:, ::1] tensor_table = np.zeros((3, num_dims), dtype=np.int32)             # <<<<<<<<<<<<<<
5244  *
5245  *     if isinstance(sel, int):
5246  */
5247   __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_np); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 176, __pyx_L1_error)
5248   __Pyx_GOTREF(__pyx_t_1);
5249   __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_zeros); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 176, __pyx_L1_error)
5250   __Pyx_GOTREF(__pyx_t_4);
5251   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
5252   __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_num_dims); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 176, __pyx_L1_error)
5253   __Pyx_GOTREF(__pyx_t_1);
5254   __pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 176, __pyx_L1_error)
5255   __Pyx_GOTREF(__pyx_t_6);
5256   __Pyx_INCREF(__pyx_int_3);
5257   __Pyx_GIVEREF(__pyx_int_3);
5258   PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_int_3);
5259   __Pyx_GIVEREF(__pyx_t_1);
5260   PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_t_1);
5261   __pyx_t_1 = 0;
5262   __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 176, __pyx_L1_error)
5263   __Pyx_GOTREF(__pyx_t_1);
5264   __Pyx_GIVEREF(__pyx_t_6);
5265   PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_6);
5266   __pyx_t_6 = 0;
5267   __pyx_t_6 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 176, __pyx_L1_error)
5268   __Pyx_GOTREF(__pyx_t_6);
5269   __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_np); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 176, __pyx_L1_error)
5270   __Pyx_GOTREF(__pyx_t_2);
5271   __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_int32); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 176, __pyx_L1_error)
5272   __Pyx_GOTREF(__pyx_t_3);
5273   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
5274   if (PyDict_SetItem(__pyx_t_6, __pyx_n_s_dtype, __pyx_t_3) < 0) __PYX_ERR(0, 176, __pyx_L1_error)
5275   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
5276   __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_1, __pyx_t_6); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 176, __pyx_L1_error)
5277   __Pyx_GOTREF(__pyx_t_3);
5278   __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
5279   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
5280   __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
5281   __pyx_t_8 = __Pyx_PyObject_to_MemoryviewSlice_d_dc_int(__pyx_t_3, PyBUF_WRITABLE); if (unlikely(!__pyx_t_8.memview)) __PYX_ERR(0, 176, __pyx_L1_error)
5282   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
5283   __pyx_v_tensor_table = __pyx_t_8;
5284   __pyx_t_8.memview = NULL;
5285   __pyx_t_8.data = NULL;
5286 
5287   /* "qutip/cy/ptrace.pyx":178
5288  *     cdef int[:, ::1] tensor_table = np.zeros((3, num_dims), dtype=np.int32)
5289  *
5290  *     if isinstance(sel, int):             # <<<<<<<<<<<<<<
5291  *         _sel = np.array([sel], dtype=np.int32)
5292  *     else:
5293  */
5294   __pyx_t_9 = PyInt_Check(__pyx_v_sel);
5295   __pyx_t_10 = (__pyx_t_9 != 0);
5296   if (__pyx_t_10) {
5297 
5298     /* "qutip/cy/ptrace.pyx":179
5299  *
5300  *     if isinstance(sel, int):
5301  *         _sel = np.array([sel], dtype=np.int32)             # <<<<<<<<<<<<<<
5302  *     else:
5303  *         _sel = np.asarray(sel, dtype=np.int32)
5304  */
5305     __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_np); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 179, __pyx_L1_error)
5306     __Pyx_GOTREF(__pyx_t_3);
5307     __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_array); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 179, __pyx_L1_error)
5308     __Pyx_GOTREF(__pyx_t_6);
5309     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
5310     __pyx_t_3 = PyList_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 179, __pyx_L1_error)
5311     __Pyx_GOTREF(__pyx_t_3);
5312     __Pyx_INCREF(__pyx_v_sel);
5313     __Pyx_GIVEREF(__pyx_v_sel);
5314     PyList_SET_ITEM(__pyx_t_3, 0, __pyx_v_sel);
5315     __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 179, __pyx_L1_error)
5316     __Pyx_GOTREF(__pyx_t_1);
5317     __Pyx_GIVEREF(__pyx_t_3);
5318     PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_3);
5319     __pyx_t_3 = 0;
5320     __pyx_t_3 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 179, __pyx_L1_error)
5321     __Pyx_GOTREF(__pyx_t_3);
5322     __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_np); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 179, __pyx_L1_error)
5323     __Pyx_GOTREF(__pyx_t_4);
5324     __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_int32); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 179, __pyx_L1_error)
5325     __Pyx_GOTREF(__pyx_t_2);
5326     __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
5327     if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_dtype, __pyx_t_2) < 0) __PYX_ERR(0, 179, __pyx_L1_error)
5328     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
5329     __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_1, __pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 179, __pyx_L1_error)
5330     __Pyx_GOTREF(__pyx_t_2);
5331     __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
5332     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
5333     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
5334     __pyx_t_11 = __Pyx_PyObject_to_MemoryviewSlice_dc_int(__pyx_t_2, PyBUF_WRITABLE); if (unlikely(!__pyx_t_11.memview)) __PYX_ERR(0, 179, __pyx_L1_error)
5335     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
5336     __pyx_v__sel = __pyx_t_11;
5337     __pyx_t_11.memview = NULL;
5338     __pyx_t_11.data = NULL;
5339 
5340     /* "qutip/cy/ptrace.pyx":178
5341  *     cdef int[:, ::1] tensor_table = np.zeros((3, num_dims), dtype=np.int32)
5342  *
5343  *     if isinstance(sel, int):             # <<<<<<<<<<<<<<
5344  *         _sel = np.array([sel], dtype=np.int32)
5345  *     else:
5346  */
5347     goto __pyx_L3;
5348   }
5349 
5350   /* "qutip/cy/ptrace.pyx":181
5351  *         _sel = np.array([sel], dtype=np.int32)
5352  *     else:
5353  *         _sel = np.asarray(sel, dtype=np.int32)             # <<<<<<<<<<<<<<
5354  *
5355  *     _sel = np.sort(_sel)
5356  */
5357   /*else*/ {
5358     __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_np); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 181, __pyx_L1_error)
5359     __Pyx_GOTREF(__pyx_t_2);
5360     __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_asarray); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 181, __pyx_L1_error)
5361     __Pyx_GOTREF(__pyx_t_3);
5362     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
5363     __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 181, __pyx_L1_error)
5364     __Pyx_GOTREF(__pyx_t_2);
5365     __Pyx_INCREF(__pyx_v_sel);
5366     __Pyx_GIVEREF(__pyx_v_sel);
5367     PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_sel);
5368     __pyx_t_1 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 181, __pyx_L1_error)
5369     __Pyx_GOTREF(__pyx_t_1);
5370     __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_n_s_np); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 181, __pyx_L1_error)
5371     __Pyx_GOTREF(__pyx_t_6);
5372     __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_int32); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 181, __pyx_L1_error)
5373     __Pyx_GOTREF(__pyx_t_4);
5374     __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
5375     if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_dtype, __pyx_t_4) < 0) __PYX_ERR(0, 181, __pyx_L1_error)
5376     __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
5377     __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_2, __pyx_t_1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 181, __pyx_L1_error)
5378     __Pyx_GOTREF(__pyx_t_4);
5379     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
5380     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
5381     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
5382     __pyx_t_11 = __Pyx_PyObject_to_MemoryviewSlice_dc_int(__pyx_t_4, PyBUF_WRITABLE); if (unlikely(!__pyx_t_11.memview)) __PYX_ERR(0, 181, __pyx_L1_error)
5383     __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
5384     __pyx_v__sel = __pyx_t_11;
5385     __pyx_t_11.memview = NULL;
5386     __pyx_t_11.data = NULL;
5387   }
5388   __pyx_L3:;
5389 
5390   /* "qutip/cy/ptrace.pyx":183
5391  *         _sel = np.asarray(sel, dtype=np.int32)
5392  *
5393  *     _sel = np.sort(_sel)             # <<<<<<<<<<<<<<
5394  *
5395  *     for ii in range(_sel.shape[0]):
5396  */
5397   __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_np); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 183, __pyx_L1_error)
5398   __Pyx_GOTREF(__pyx_t_1);
5399   __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_sort); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 183, __pyx_L1_error)
5400   __Pyx_GOTREF(__pyx_t_2);
5401   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
5402   __pyx_t_1 = __pyx_memoryview_fromslice(__pyx_v__sel, 1, (PyObject *(*)(char *)) __pyx_memview_get_int, (int (*)(char *, PyObject *)) __pyx_memview_set_int, 0);; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 183, __pyx_L1_error)
5403   __Pyx_GOTREF(__pyx_t_1);
5404   __pyx_t_3 = NULL;
5405   if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) {
5406     __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
5407     if (likely(__pyx_t_3)) {
5408       PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
5409       __Pyx_INCREF(__pyx_t_3);
5410       __Pyx_INCREF(function);
5411       __Pyx_DECREF_SET(__pyx_t_2, function);
5412     }
5413   }
5414   __pyx_t_4 = (__pyx_t_3) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_3, __pyx_t_1) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_1);
5415   __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
5416   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
5417   if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 183, __pyx_L1_error)
5418   __Pyx_GOTREF(__pyx_t_4);
5419   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
5420   __pyx_t_11 = __Pyx_PyObject_to_MemoryviewSlice_dc_int(__pyx_t_4, PyBUF_WRITABLE); if (unlikely(!__pyx_t_11.memview)) __PYX_ERR(0, 183, __pyx_L1_error)
5421   __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
5422   __PYX_XDEC_MEMVIEW(&__pyx_v__sel, 1);
5423   __pyx_v__sel = __pyx_t_11;
5424   __pyx_t_11.memview = NULL;
5425   __pyx_t_11.data = NULL;
5426 
5427   /* "qutip/cy/ptrace.pyx":185
5428  *     _sel = np.sort(_sel)
5429  *
5430  *     for ii in range(_sel.shape[0]):             # <<<<<<<<<<<<<<
5431  *         if _sel[ii] < 0 or _sel[ii] >= num_dims:
5432  *             raise IndexError("Invalid selection index in ptrace.")
5433  */
5434   __pyx_t_12 = (__pyx_v__sel.shape[0]);
5435   __pyx_t_13 = __pyx_t_12;
5436   for (__pyx_t_14 = 0; __pyx_t_14 < __pyx_t_13; __pyx_t_14+=1) {
5437     __pyx_v_ii = __pyx_t_14;
5438 
5439     /* "qutip/cy/ptrace.pyx":186
5440  *
5441  *     for ii in range(_sel.shape[0]):
5442  *         if _sel[ii] < 0 or _sel[ii] >= num_dims:             # <<<<<<<<<<<<<<
5443  *             raise IndexError("Invalid selection index in ptrace.")
5444  *         if ii > 0 and _sel[ii] == _sel[ii - 1]:
5445  */
5446     __pyx_t_15 = __pyx_v_ii;
5447     __pyx_t_9 = (((*((int *) ( /* dim=0 */ ((char *) (((int *) __pyx_v__sel.data) + __pyx_t_15)) ))) < 0) != 0);
5448     if (!__pyx_t_9) {
5449     } else {
5450       __pyx_t_10 = __pyx_t_9;
5451       goto __pyx_L7_bool_binop_done;
5452     }
5453     __pyx_t_15 = __pyx_v_ii;
5454     __pyx_t_9 = (((*((int *) ( /* dim=0 */ ((char *) (((int *) __pyx_v__sel.data) + __pyx_t_15)) ))) >= __pyx_v_num_dims) != 0);
5455     __pyx_t_10 = __pyx_t_9;
5456     __pyx_L7_bool_binop_done:;
5457     if (unlikely(__pyx_t_10)) {
5458 
5459       /* "qutip/cy/ptrace.pyx":187
5460  *     for ii in range(_sel.shape[0]):
5461  *         if _sel[ii] < 0 or _sel[ii] >= num_dims:
5462  *             raise IndexError("Invalid selection index in ptrace.")             # <<<<<<<<<<<<<<
5463  *         if ii > 0 and _sel[ii] == _sel[ii - 1]:
5464  *             raise ValueError("Duplicate selection index in ptrace.")
5465  */
5466       __pyx_t_4 = __Pyx_PyObject_Call(__pyx_builtin_IndexError, __pyx_tuple_, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 187, __pyx_L1_error)
5467       __Pyx_GOTREF(__pyx_t_4);
5468       __Pyx_Raise(__pyx_t_4, 0, 0, 0);
5469       __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
5470       __PYX_ERR(0, 187, __pyx_L1_error)
5471 
5472       /* "qutip/cy/ptrace.pyx":186
5473  *
5474  *     for ii in range(_sel.shape[0]):
5475  *         if _sel[ii] < 0 or _sel[ii] >= num_dims:             # <<<<<<<<<<<<<<
5476  *             raise IndexError("Invalid selection index in ptrace.")
5477  *         if ii > 0 and _sel[ii] == _sel[ii - 1]:
5478  */
5479     }
5480 
5481     /* "qutip/cy/ptrace.pyx":188
5482  *         if _sel[ii] < 0 or _sel[ii] >= num_dims:
5483  *             raise IndexError("Invalid selection index in ptrace.")
5484  *         if ii > 0 and _sel[ii] == _sel[ii - 1]:             # <<<<<<<<<<<<<<
5485  *             raise ValueError("Duplicate selection index in ptrace.")
5486  *
5487  */
5488     __pyx_t_9 = ((__pyx_v_ii > 0) != 0);
5489     if (__pyx_t_9) {
5490     } else {
5491       __pyx_t_10 = __pyx_t_9;
5492       goto __pyx_L10_bool_binop_done;
5493     }
5494     __pyx_t_15 = __pyx_v_ii;
5495     __pyx_t_16 = (__pyx_v_ii - 1);
5496     __pyx_t_9 = (((*((int *) ( /* dim=0 */ ((char *) (((int *) __pyx_v__sel.data) + __pyx_t_15)) ))) == (*((int *) ( /* dim=0 */ ((char *) (((int *) __pyx_v__sel.data) + __pyx_t_16)) )))) != 0);
5497     __pyx_t_10 = __pyx_t_9;
5498     __pyx_L10_bool_binop_done:;
5499     if (unlikely(__pyx_t_10)) {
5500 
5501       /* "qutip/cy/ptrace.pyx":189
5502  *             raise IndexError("Invalid selection index in ptrace.")
5503  *         if ii > 0 and _sel[ii] == _sel[ii - 1]:
5504  *             raise ValueError("Duplicate selection index in ptrace.")             # <<<<<<<<<<<<<<
5505  *
5506  *     if len(_sel) == num_dims:
5507  */
5508       __pyx_t_4 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__2, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 189, __pyx_L1_error)
5509       __Pyx_GOTREF(__pyx_t_4);
5510       __Pyx_Raise(__pyx_t_4, 0, 0, 0);
5511       __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
5512       __PYX_ERR(0, 189, __pyx_L1_error)
5513 
5514       /* "qutip/cy/ptrace.pyx":188
5515  *         if _sel[ii] < 0 or _sel[ii] >= num_dims:
5516  *             raise IndexError("Invalid selection index in ptrace.")
5517  *         if ii > 0 and _sel[ii] == _sel[ii - 1]:             # <<<<<<<<<<<<<<
5518  *             raise ValueError("Duplicate selection index in ptrace.")
5519  *
5520  */
5521     }
5522   }
5523 
5524   /* "qutip/cy/ptrace.pyx":191
5525  *             raise ValueError("Duplicate selection index in ptrace.")
5526  *
5527  *     if len(_sel) == num_dims:             # <<<<<<<<<<<<<<
5528  *         # If all dimensions are selected, just fast-path return a copy.
5529  *         return rho.data.copy(), rho.dims.copy(), rho.shape
5530  */
5531   __pyx_t_14 = __Pyx_MemoryView_Len(__pyx_v__sel);
5532   __pyx_t_10 = ((__pyx_t_14 == __pyx_v_num_dims) != 0);
5533   if (__pyx_t_10) {
5534 
5535     /* "qutip/cy/ptrace.pyx":193
5536  *     if len(_sel) == num_dims:
5537  *         # If all dimensions are selected, just fast-path return a copy.
5538  *         return rho.data.copy(), rho.dims.copy(), rho.shape             # <<<<<<<<<<<<<<
5539  *
5540  *     if np.prod(rho.shape[1]) == 1:
5541  */
5542     __Pyx_XDECREF(__pyx_r);
5543     __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_rho, __pyx_n_s_data); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 193, __pyx_L1_error)
5544     __Pyx_GOTREF(__pyx_t_2);
5545     __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_copy); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 193, __pyx_L1_error)
5546     __Pyx_GOTREF(__pyx_t_1);
5547     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
5548     __pyx_t_2 = NULL;
5549     if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_1))) {
5550       __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_1);
5551       if (likely(__pyx_t_2)) {
5552         PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
5553         __Pyx_INCREF(__pyx_t_2);
5554         __Pyx_INCREF(function);
5555         __Pyx_DECREF_SET(__pyx_t_1, function);
5556       }
5557     }
5558     __pyx_t_4 = (__pyx_t_2) ? __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_2) : __Pyx_PyObject_CallNoArg(__pyx_t_1);
5559     __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
5560     if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 193, __pyx_L1_error)
5561     __Pyx_GOTREF(__pyx_t_4);
5562     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
5563     __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_rho, __pyx_n_s_dims); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 193, __pyx_L1_error)
5564     __Pyx_GOTREF(__pyx_t_2);
5565     __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_copy); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 193, __pyx_L1_error)
5566     __Pyx_GOTREF(__pyx_t_3);
5567     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
5568     __pyx_t_2 = NULL;
5569     if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) {
5570       __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3);
5571       if (likely(__pyx_t_2)) {
5572         PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
5573         __Pyx_INCREF(__pyx_t_2);
5574         __Pyx_INCREF(function);
5575         __Pyx_DECREF_SET(__pyx_t_3, function);
5576       }
5577     }
5578     __pyx_t_1 = (__pyx_t_2) ? __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_2) : __Pyx_PyObject_CallNoArg(__pyx_t_3);
5579     __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
5580     if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 193, __pyx_L1_error)
5581     __Pyx_GOTREF(__pyx_t_1);
5582     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
5583     __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_rho, __pyx_n_s_shape); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 193, __pyx_L1_error)
5584     __Pyx_GOTREF(__pyx_t_3);
5585     __pyx_t_2 = PyTuple_New(3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 193, __pyx_L1_error)
5586     __Pyx_GOTREF(__pyx_t_2);
5587     __Pyx_GIVEREF(__pyx_t_4);
5588     PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_4);
5589     __Pyx_GIVEREF(__pyx_t_1);
5590     PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_t_1);
5591     __Pyx_GIVEREF(__pyx_t_3);
5592     PyTuple_SET_ITEM(__pyx_t_2, 2, __pyx_t_3);
5593     __pyx_t_4 = 0;
5594     __pyx_t_1 = 0;
5595     __pyx_t_3 = 0;
5596     __pyx_r = __pyx_t_2;
5597     __pyx_t_2 = 0;
5598     goto __pyx_L0;
5599 
5600     /* "qutip/cy/ptrace.pyx":191
5601  *             raise ValueError("Duplicate selection index in ptrace.")
5602  *
5603  *     if len(_sel) == num_dims:             # <<<<<<<<<<<<<<
5604  *         # If all dimensions are selected, just fast-path return a copy.
5605  *         return rho.data.copy(), rho.dims.copy(), rho.shape
5606  */
5607   }
5608 
5609   /* "qutip/cy/ptrace.pyx":195
5610  *         return rho.data.copy(), rho.dims.copy(), rho.shape
5611  *
5612  *     if np.prod(rho.shape[1]) == 1:             # <<<<<<<<<<<<<<
5613  *         _oper = (rho * rho.dag()).data
5614  *     else:
5615  */
5616   __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_np); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 195, __pyx_L1_error)
5617   __Pyx_GOTREF(__pyx_t_3);
5618   __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_prod); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 195, __pyx_L1_error)
5619   __Pyx_GOTREF(__pyx_t_1);
5620   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
5621   __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_rho, __pyx_n_s_shape); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 195, __pyx_L1_error)
5622   __Pyx_GOTREF(__pyx_t_3);
5623   __pyx_t_4 = __Pyx_GetItemInt(__pyx_t_3, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 195, __pyx_L1_error)
5624   __Pyx_GOTREF(__pyx_t_4);
5625   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
5626   __pyx_t_3 = NULL;
5627   if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_1))) {
5628     __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_1);
5629     if (likely(__pyx_t_3)) {
5630       PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
5631       __Pyx_INCREF(__pyx_t_3);
5632       __Pyx_INCREF(function);
5633       __Pyx_DECREF_SET(__pyx_t_1, function);
5634     }
5635   }
5636   __pyx_t_2 = (__pyx_t_3) ? __Pyx_PyObject_Call2Args(__pyx_t_1, __pyx_t_3, __pyx_t_4) : __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_4);
5637   __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
5638   __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
5639   if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 195, __pyx_L1_error)
5640   __Pyx_GOTREF(__pyx_t_2);
5641   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
5642   __pyx_t_1 = __Pyx_PyInt_EqObjC(__pyx_t_2, __pyx_int_1, 1, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 195, __pyx_L1_error)
5643   __Pyx_GOTREF(__pyx_t_1);
5644   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
5645   __pyx_t_10 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_10 < 0)) __PYX_ERR(0, 195, __pyx_L1_error)
5646   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
5647   if (__pyx_t_10) {
5648 
5649     /* "qutip/cy/ptrace.pyx":196
5650  *
5651  *     if np.prod(rho.shape[1]) == 1:
5652  *         _oper = (rho * rho.dag()).data             # <<<<<<<<<<<<<<
5653  *     else:
5654  *         _oper = rho.data
5655  */
5656     __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_rho, __pyx_n_s_dag); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 196, __pyx_L1_error)
5657     __Pyx_GOTREF(__pyx_t_2);
5658     __pyx_t_4 = NULL;
5659     if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
5660       __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_2);
5661       if (likely(__pyx_t_4)) {
5662         PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
5663         __Pyx_INCREF(__pyx_t_4);
5664         __Pyx_INCREF(function);
5665         __Pyx_DECREF_SET(__pyx_t_2, function);
5666       }
5667     }
5668     __pyx_t_1 = (__pyx_t_4) ? __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_4) : __Pyx_PyObject_CallNoArg(__pyx_t_2);
5669     __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
5670     if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 196, __pyx_L1_error)
5671     __Pyx_GOTREF(__pyx_t_1);
5672     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
5673     __pyx_t_2 = PyNumber_Multiply(__pyx_v_rho, __pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 196, __pyx_L1_error)
5674     __Pyx_GOTREF(__pyx_t_2);
5675     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
5676     __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_data); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 196, __pyx_L1_error)
5677     __Pyx_GOTREF(__pyx_t_1);
5678     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
5679     __pyx_v__oper = __pyx_t_1;
5680     __pyx_t_1 = 0;
5681 
5682     /* "qutip/cy/ptrace.pyx":195
5683  *         return rho.data.copy(), rho.dims.copy(), rho.shape
5684  *
5685  *     if np.prod(rho.shape[1]) == 1:             # <<<<<<<<<<<<<<
5686  *         _oper = (rho * rho.dag()).data
5687  *     else:
5688  */
5689     goto __pyx_L13;
5690   }
5691 
5692   /* "qutip/cy/ptrace.pyx":198
5693  *         _oper = (rho * rho.dag()).data
5694  *     else:
5695  *         _oper = rho.data             # <<<<<<<<<<<<<<
5696  *
5697  *     for ii in range(num_dims-1,-1,-1):
5698  */
5699   /*else*/ {
5700     __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_rho, __pyx_n_s_data); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 198, __pyx_L1_error)
5701     __Pyx_GOTREF(__pyx_t_1);
5702     __pyx_v__oper = __pyx_t_1;
5703     __pyx_t_1 = 0;
5704   }
5705   __pyx_L13:;
5706 
5707   /* "qutip/cy/ptrace.pyx":200
5708  *         _oper = rho.data
5709  *
5710  *     for ii in range(num_dims-1,-1,-1):             # <<<<<<<<<<<<<<
5711  *         tensor_table[0, ii] = factor_tensor
5712  *         factor_tensor *= drho[ii]
5713  */
5714   for (__pyx_t_14 = (__pyx_v_num_dims - 1) + 1; __pyx_t_14 > -1L + 1; ) { __pyx_t_14-=1;
5715     __pyx_v_ii = __pyx_t_14;
5716 
5717     /* "qutip/cy/ptrace.pyx":201
5718  *
5719  *     for ii in range(num_dims-1,-1,-1):
5720  *         tensor_table[0, ii] = factor_tensor             # <<<<<<<<<<<<<<
5721  *         factor_tensor *= drho[ii]
5722  *         if _in(ii, _sel):
5723  */
5724     __pyx_t_17 = 0;
5725     __pyx_t_16 = __pyx_v_ii;
5726     *((int *) ( /* dim=1 */ ((char *) (((int *) ( /* dim=0 */ (__pyx_v_tensor_table.data + __pyx_t_17 * __pyx_v_tensor_table.strides[0]) )) + __pyx_t_16)) )) = __pyx_v_factor_tensor;
5727 
5728     /* "qutip/cy/ptrace.pyx":202
5729  *     for ii in range(num_dims-1,-1,-1):
5730  *         tensor_table[0, ii] = factor_tensor
5731  *         factor_tensor *= drho[ii]             # <<<<<<<<<<<<<<
5732  *         if _in(ii, _sel):
5733  *             tensor_table[1, ii] = factor_keep
5734  */
5735     __pyx_t_16 = __pyx_v_ii;
5736     __pyx_v_factor_tensor = (__pyx_v_factor_tensor * (*__Pyx_BufPtrCContig1d(int *, __pyx_pybuffernd_drho.rcbuffer->pybuffer.buf, __pyx_t_16, __pyx_pybuffernd_drho.diminfo[0].strides)));
5737 
5738     /* "qutip/cy/ptrace.pyx":203
5739  *         tensor_table[0, ii] = factor_tensor
5740  *         factor_tensor *= drho[ii]
5741  *         if _in(ii, _sel):             # <<<<<<<<<<<<<<
5742  *             tensor_table[1, ii] = factor_keep
5743  *             factor_keep *= drho[ii]
5744  */
5745     __pyx_t_10 = (__pyx_f_5qutip_2cy_6ptrace__in(__pyx_v_ii, __pyx_v__sel) != 0);
5746     if (__pyx_t_10) {
5747 
5748       /* "qutip/cy/ptrace.pyx":204
5749  *         factor_tensor *= drho[ii]
5750  *         if _in(ii, _sel):
5751  *             tensor_table[1, ii] = factor_keep             # <<<<<<<<<<<<<<
5752  *             factor_keep *= drho[ii]
5753  *         else:
5754  */
5755       __pyx_t_17 = 1;
5756       __pyx_t_16 = __pyx_v_ii;
5757       *((int *) ( /* dim=1 */ ((char *) (((int *) ( /* dim=0 */ (__pyx_v_tensor_table.data + __pyx_t_17 * __pyx_v_tensor_table.strides[0]) )) + __pyx_t_16)) )) = __pyx_v_factor_keep;
5758 
5759       /* "qutip/cy/ptrace.pyx":205
5760  *         if _in(ii, _sel):
5761  *             tensor_table[1, ii] = factor_keep
5762  *             factor_keep *= drho[ii]             # <<<<<<<<<<<<<<
5763  *         else:
5764  *             tensor_table[2, ii] = factor_trace
5765  */
5766       __pyx_t_16 = __pyx_v_ii;
5767       __pyx_v_factor_keep = (__pyx_v_factor_keep * (*__Pyx_BufPtrCContig1d(int *, __pyx_pybuffernd_drho.rcbuffer->pybuffer.buf, __pyx_t_16, __pyx_pybuffernd_drho.diminfo[0].strides)));
5768 
5769       /* "qutip/cy/ptrace.pyx":203
5770  *         tensor_table[0, ii] = factor_tensor
5771  *         factor_tensor *= drho[ii]
5772  *         if _in(ii, _sel):             # <<<<<<<<<<<<<<
5773  *             tensor_table[1, ii] = factor_keep
5774  *             factor_keep *= drho[ii]
5775  */
5776       goto __pyx_L16;
5777     }
5778 
5779     /* "qutip/cy/ptrace.pyx":207
5780  *             factor_keep *= drho[ii]
5781  *         else:
5782  *             tensor_table[2, ii] = factor_trace             # <<<<<<<<<<<<<<
5783  *             factor_trace *= drho[ii]
5784  *
5785  */
5786     /*else*/ {
5787       __pyx_t_17 = 2;
5788       __pyx_t_16 = __pyx_v_ii;
5789       *((int *) ( /* dim=1 */ ((char *) (((int *) ( /* dim=0 */ (__pyx_v_tensor_table.data + __pyx_t_17 * __pyx_v_tensor_table.strides[0]) )) + __pyx_t_16)) )) = __pyx_v_factor_trace;
5790 
5791       /* "qutip/cy/ptrace.pyx":208
5792  *         else:
5793  *             tensor_table[2, ii] = factor_trace
5794  *             factor_trace *= drho[ii]             # <<<<<<<<<<<<<<
5795  *
5796  *     dims_kept0 = drho.take(_sel).tolist()
5797  */
5798       __pyx_t_16 = __pyx_v_ii;
5799       __pyx_v_factor_trace = (__pyx_v_factor_trace * (*__Pyx_BufPtrCContig1d(int *, __pyx_pybuffernd_drho.rcbuffer->pybuffer.buf, __pyx_t_16, __pyx_pybuffernd_drho.diminfo[0].strides)));
5800     }
5801     __pyx_L16:;
5802   }
5803 
5804   /* "qutip/cy/ptrace.pyx":210
5805  *             factor_trace *= drho[ii]
5806  *
5807  *     dims_kept0 = drho.take(_sel).tolist()             # <<<<<<<<<<<<<<
5808  *     rho1_dims = [dims_kept0, dims_kept0]
5809  *     rho1_shape = [np.prod(dims_kept0), np.prod(dims_kept0)]
5810  */
5811   __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_drho), __pyx_n_s_take); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 210, __pyx_L1_error)
5812   __Pyx_GOTREF(__pyx_t_4);
5813   __pyx_t_3 = __pyx_memoryview_fromslice(__pyx_v__sel, 1, (PyObject *(*)(char *)) __pyx_memview_get_int, (int (*)(char *, PyObject *)) __pyx_memview_set_int, 0);; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 210, __pyx_L1_error)
5814   __Pyx_GOTREF(__pyx_t_3);
5815   __pyx_t_6 = NULL;
5816   if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_4))) {
5817     __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_4);
5818     if (likely(__pyx_t_6)) {
5819       PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
5820       __Pyx_INCREF(__pyx_t_6);
5821       __Pyx_INCREF(function);
5822       __Pyx_DECREF_SET(__pyx_t_4, function);
5823     }
5824   }
5825   __pyx_t_2 = (__pyx_t_6) ? __Pyx_PyObject_Call2Args(__pyx_t_4, __pyx_t_6, __pyx_t_3) : __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_3);
5826   __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
5827   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
5828   if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 210, __pyx_L1_error)
5829   __Pyx_GOTREF(__pyx_t_2);
5830   __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
5831   __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_tolist); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 210, __pyx_L1_error)
5832   __Pyx_GOTREF(__pyx_t_4);
5833   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
5834   __pyx_t_2 = NULL;
5835   if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_4))) {
5836     __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_4);
5837     if (likely(__pyx_t_2)) {
5838       PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
5839       __Pyx_INCREF(__pyx_t_2);
5840       __Pyx_INCREF(function);
5841       __Pyx_DECREF_SET(__pyx_t_4, function);
5842     }
5843   }
5844   __pyx_t_1 = (__pyx_t_2) ? __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_2) : __Pyx_PyObject_CallNoArg(__pyx_t_4);
5845   __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
5846   if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 210, __pyx_L1_error)
5847   __Pyx_GOTREF(__pyx_t_1);
5848   __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
5849   __pyx_v_dims_kept0 = __pyx_t_1;
5850   __pyx_t_1 = 0;
5851 
5852   /* "qutip/cy/ptrace.pyx":211
5853  *
5854  *     dims_kept0 = drho.take(_sel).tolist()
5855  *     rho1_dims = [dims_kept0, dims_kept0]             # <<<<<<<<<<<<<<
5856  *     rho1_shape = [np.prod(dims_kept0), np.prod(dims_kept0)]
5857  *
5858  */
5859   __pyx_t_1 = PyList_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 211, __pyx_L1_error)
5860   __Pyx_GOTREF(__pyx_t_1);
5861   __Pyx_INCREF(__pyx_v_dims_kept0);
5862   __Pyx_GIVEREF(__pyx_v_dims_kept0);
5863   PyList_SET_ITEM(__pyx_t_1, 0, __pyx_v_dims_kept0);
5864   __Pyx_INCREF(__pyx_v_dims_kept0);
5865   __Pyx_GIVEREF(__pyx_v_dims_kept0);
5866   PyList_SET_ITEM(__pyx_t_1, 1, __pyx_v_dims_kept0);
5867   __pyx_v_rho1_dims = ((PyObject*)__pyx_t_1);
5868   __pyx_t_1 = 0;
5869 
5870   /* "qutip/cy/ptrace.pyx":212
5871  *     dims_kept0 = drho.take(_sel).tolist()
5872  *     rho1_dims = [dims_kept0, dims_kept0]
5873  *     rho1_shape = [np.prod(dims_kept0), np.prod(dims_kept0)]             # <<<<<<<<<<<<<<
5874  *
5875  *     # Try to evaluate how sparse the result will be.
5876  */
5877   __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_np); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 212, __pyx_L1_error)
5878   __Pyx_GOTREF(__pyx_t_4);
5879   __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_prod); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 212, __pyx_L1_error)
5880   __Pyx_GOTREF(__pyx_t_2);
5881   __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
5882   __pyx_t_4 = NULL;
5883   if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) {
5884     __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_2);
5885     if (likely(__pyx_t_4)) {
5886       PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
5887       __Pyx_INCREF(__pyx_t_4);
5888       __Pyx_INCREF(function);
5889       __Pyx_DECREF_SET(__pyx_t_2, function);
5890     }
5891   }
5892   __pyx_t_1 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_4, __pyx_v_dims_kept0) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_v_dims_kept0);
5893   __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
5894   if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 212, __pyx_L1_error)
5895   __Pyx_GOTREF(__pyx_t_1);
5896   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
5897   __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_np); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 212, __pyx_L1_error)
5898   __Pyx_GOTREF(__pyx_t_4);
5899   __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_prod); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 212, __pyx_L1_error)
5900   __Pyx_GOTREF(__pyx_t_3);
5901   __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
5902   __pyx_t_4 = NULL;
5903   if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
5904     __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
5905     if (likely(__pyx_t_4)) {
5906       PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
5907       __Pyx_INCREF(__pyx_t_4);
5908       __Pyx_INCREF(function);
5909       __Pyx_DECREF_SET(__pyx_t_3, function);
5910     }
5911   }
5912   __pyx_t_2 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_4, __pyx_v_dims_kept0) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_dims_kept0);
5913   __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
5914   if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 212, __pyx_L1_error)
5915   __Pyx_GOTREF(__pyx_t_2);
5916   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
5917   __pyx_t_3 = PyList_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 212, __pyx_L1_error)
5918   __Pyx_GOTREF(__pyx_t_3);
5919   __Pyx_GIVEREF(__pyx_t_1);
5920   PyList_SET_ITEM(__pyx_t_3, 0, __pyx_t_1);
5921   __Pyx_GIVEREF(__pyx_t_2);
5922   PyList_SET_ITEM(__pyx_t_3, 1, __pyx_t_2);
5923   __pyx_t_1 = 0;
5924   __pyx_t_2 = 0;
5925   __pyx_v_rho1_shape = ((PyObject*)__pyx_t_3);
5926   __pyx_t_3 = 0;
5927 
5928   /* "qutip/cy/ptrace.pyx":215
5929  *
5930  *     # Try to evaluate how sparse the result will be.
5931  *     if factor_keep*factor_keep > _oper.nnz:             # <<<<<<<<<<<<<<
5932  *         return csr2fast(_ptrace_core_sp(_oper, tensor_table, factor_keep)), rho1_dims, rho1_shape
5933  *     else:
5934  */
5935   __pyx_t_3 = __Pyx_PyInt_FromSize_t((__pyx_v_factor_keep * __pyx_v_factor_keep)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 215, __pyx_L1_error)
5936   __Pyx_GOTREF(__pyx_t_3);
5937   __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v__oper, __pyx_n_s_nnz); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 215, __pyx_L1_error)
5938   __Pyx_GOTREF(__pyx_t_2);
5939   __pyx_t_1 = PyObject_RichCompare(__pyx_t_3, __pyx_t_2, Py_GT); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 215, __pyx_L1_error)
5940   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
5941   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
5942   __pyx_t_10 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_10 < 0)) __PYX_ERR(0, 215, __pyx_L1_error)
5943   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
5944   if (__pyx_t_10) {
5945 
5946     /* "qutip/cy/ptrace.pyx":216
5947  *     # Try to evaluate how sparse the result will be.
5948  *     if factor_keep*factor_keep > _oper.nnz:
5949  *         return csr2fast(_ptrace_core_sp(_oper, tensor_table, factor_keep)), rho1_dims, rho1_shape             # <<<<<<<<<<<<<<
5950  *     else:
5951  *         return csr2fast(_ptrace_core_dense(_oper, tensor_table, factor_keep)), rho1_dims, rho1_shape
5952  */
5953     __Pyx_XDECREF(__pyx_r);
5954     __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_csr2fast); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 216, __pyx_L1_error)
5955     __Pyx_GOTREF(__pyx_t_2);
5956     __pyx_t_3 = __pyx_f_5qutip_2cy_6ptrace__ptrace_core_sp(__pyx_v__oper, __pyx_v_tensor_table, __pyx_v_factor_keep); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 216, __pyx_L1_error)
5957     __Pyx_GOTREF(__pyx_t_3);
5958     __pyx_t_4 = NULL;
5959     if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) {
5960       __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_2);
5961       if (likely(__pyx_t_4)) {
5962         PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
5963         __Pyx_INCREF(__pyx_t_4);
5964         __Pyx_INCREF(function);
5965         __Pyx_DECREF_SET(__pyx_t_2, function);
5966       }
5967     }
5968     __pyx_t_1 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_4, __pyx_t_3) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3);
5969     __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
5970     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
5971     if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 216, __pyx_L1_error)
5972     __Pyx_GOTREF(__pyx_t_1);
5973     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
5974     __pyx_t_2 = PyTuple_New(3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 216, __pyx_L1_error)
5975     __Pyx_GOTREF(__pyx_t_2);
5976     __Pyx_GIVEREF(__pyx_t_1);
5977     PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_1);
5978     __Pyx_INCREF(__pyx_v_rho1_dims);
5979     __Pyx_GIVEREF(__pyx_v_rho1_dims);
5980     PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_v_rho1_dims);
5981     __Pyx_INCREF(__pyx_v_rho1_shape);
5982     __Pyx_GIVEREF(__pyx_v_rho1_shape);
5983     PyTuple_SET_ITEM(__pyx_t_2, 2, __pyx_v_rho1_shape);
5984     __pyx_t_1 = 0;
5985     __pyx_r = __pyx_t_2;
5986     __pyx_t_2 = 0;
5987     goto __pyx_L0;
5988 
5989     /* "qutip/cy/ptrace.pyx":215
5990  *
5991  *     # Try to evaluate how sparse the result will be.
5992  *     if factor_keep*factor_keep > _oper.nnz:             # <<<<<<<<<<<<<<
5993  *         return csr2fast(_ptrace_core_sp(_oper, tensor_table, factor_keep)), rho1_dims, rho1_shape
5994  *     else:
5995  */
5996   }
5997 
5998   /* "qutip/cy/ptrace.pyx":218
5999  *         return csr2fast(_ptrace_core_sp(_oper, tensor_table, factor_keep)), rho1_dims, rho1_shape
6000  *     else:
6001  *         return csr2fast(_ptrace_core_dense(_oper, tensor_table, factor_keep)), rho1_dims, rho1_shape             # <<<<<<<<<<<<<<
6002  *
6003  *
6004  */
6005   /*else*/ {
6006     __Pyx_XDECREF(__pyx_r);
6007     __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_csr2fast); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 218, __pyx_L1_error)
6008     __Pyx_GOTREF(__pyx_t_1);
6009     __pyx_t_3 = __pyx_f_5qutip_2cy_6ptrace__ptrace_core_dense(__pyx_v__oper, __pyx_v_tensor_table, __pyx_v_factor_keep); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 218, __pyx_L1_error)
6010     __Pyx_GOTREF(__pyx_t_3);
6011     __pyx_t_4 = NULL;
6012     if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_1))) {
6013       __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_1);
6014       if (likely(__pyx_t_4)) {
6015         PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
6016         __Pyx_INCREF(__pyx_t_4);
6017         __Pyx_INCREF(function);
6018         __Pyx_DECREF_SET(__pyx_t_1, function);
6019       }
6020     }
6021     __pyx_t_2 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_1, __pyx_t_4, __pyx_t_3) : __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_3);
6022     __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
6023     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
6024     if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 218, __pyx_L1_error)
6025     __Pyx_GOTREF(__pyx_t_2);
6026     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
6027     __pyx_t_1 = PyTuple_New(3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 218, __pyx_L1_error)
6028     __Pyx_GOTREF(__pyx_t_1);
6029     __Pyx_GIVEREF(__pyx_t_2);
6030     PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_2);
6031     __Pyx_INCREF(__pyx_v_rho1_dims);
6032     __Pyx_GIVEREF(__pyx_v_rho1_dims);
6033     PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_v_rho1_dims);
6034     __Pyx_INCREF(__pyx_v_rho1_shape);
6035     __Pyx_GIVEREF(__pyx_v_rho1_shape);
6036     PyTuple_SET_ITEM(__pyx_t_1, 2, __pyx_v_rho1_shape);
6037     __pyx_t_2 = 0;
6038     __pyx_r = __pyx_t_1;
6039     __pyx_t_1 = 0;
6040     goto __pyx_L0;
6041   }
6042 
6043   /* "qutip/cy/ptrace.pyx":169
6044  * @cython.wraparound(False)
6045  * @cython.cdivision(True)
6046  * def _ptrace(object rho, sel): # work for N<= 26 on 16G Ram             # <<<<<<<<<<<<<<
6047  *     cdef int[::1] _sel
6048  *     cdef object _oper
6049  */
6050 
6051   /* function exit code */
6052   __pyx_L1_error:;
6053   __Pyx_XDECREF(__pyx_t_1);
6054   __Pyx_XDECREF(__pyx_t_2);
6055   __Pyx_XDECREF(__pyx_t_3);
6056   __Pyx_XDECREF(__pyx_t_4);
6057   __Pyx_XDECREF(__pyx_t_5);
6058   __Pyx_XDECREF(__pyx_t_6);
6059   __PYX_XDEC_MEMVIEW(&__pyx_t_8, 1);
6060   __PYX_XDEC_MEMVIEW(&__pyx_t_11, 1);
6061   { PyObject *__pyx_type, *__pyx_value, *__pyx_tb;
6062     __Pyx_PyThreadState_declare
6063     __Pyx_PyThreadState_assign
6064     __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb);
6065     __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_drho.rcbuffer->pybuffer);
6066   __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}
6067   __Pyx_AddTraceback("qutip.cy.ptrace._ptrace", __pyx_clineno, __pyx_lineno, __pyx_filename);
6068   __pyx_r = NULL;
6069   goto __pyx_L2;
6070   __pyx_L0:;
6071   __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_drho.rcbuffer->pybuffer);
6072   __pyx_L2:;
6073   __PYX_XDEC_MEMVIEW(&__pyx_v__sel, 1);
6074   __Pyx_XDECREF(__pyx_v__oper);
6075   __Pyx_XDECREF((PyObject *)__pyx_v_drho);
6076   __PYX_XDEC_MEMVIEW(&__pyx_v_tensor_table, 1);
6077   __Pyx_XDECREF(__pyx_v_dims_kept0);
6078   __Pyx_XDECREF(__pyx_v_rho1_dims);
6079   __Pyx_XDECREF(__pyx_v_rho1_shape);
6080   __Pyx_XGIVEREF(__pyx_r);
6081   __Pyx_RefNannyFinishContext();
6082   return __pyx_r;
6083 }
6084 
6085 /* "qutip/cy/ptrace.pyx":224
6086  * @cython.wraparound(False)
6087  * @cython.cdivision(True)
6088  * cdef object _ptrace_core_sp(rho, int[:, ::1] tensor_table, int num_sel_dims):             # <<<<<<<<<<<<<<
6089  *     cdef int p = 0, nnz = rho.nnz, ii, jj, nrow = rho.shape[0]
6090  *     cdef int[::1] pos_c = np.empty(2, dtype=np.int32)
6091  */
6092 
__pyx_f_5qutip_2cy_6ptrace__ptrace_core_sp(PyObject * __pyx_v_rho,__Pyx_memviewslice __pyx_v_tensor_table,int __pyx_v_num_sel_dims)6093 static PyObject *__pyx_f_5qutip_2cy_6ptrace__ptrace_core_sp(PyObject *__pyx_v_rho, __Pyx_memviewslice __pyx_v_tensor_table, int __pyx_v_num_sel_dims) {
6094   int __pyx_v_p;
6095   int __pyx_v_nnz;
6096   int __pyx_v_ii;
6097   int __pyx_v_jj;
6098   int __pyx_v_nrow;
6099   __Pyx_memviewslice __pyx_v_pos_c = { 0, 0, { 0 }, { 0 }, { 0 } };
6100   __Pyx_memviewslice __pyx_v_pos_r = { 0, 0, { 0 }, { 0 }, { 0 } };
6101   PyArrayObject *__pyx_v_new_data = 0;
6102   PyArrayObject *__pyx_v_new_col = 0;
6103   PyArrayObject *__pyx_v_new_row = 0;
6104   PyArrayObject *__pyx_v_data = 0;
6105   PyArrayObject *__pyx_v_ptr = 0;
6106   PyArrayObject *__pyx_v_ind = 0;
6107   __Pyx_LocalBuf_ND __pyx_pybuffernd_data;
6108   __Pyx_Buffer __pyx_pybuffer_data;
6109   __Pyx_LocalBuf_ND __pyx_pybuffernd_ind;
6110   __Pyx_Buffer __pyx_pybuffer_ind;
6111   __Pyx_LocalBuf_ND __pyx_pybuffernd_new_col;
6112   __Pyx_Buffer __pyx_pybuffer_new_col;
6113   __Pyx_LocalBuf_ND __pyx_pybuffernd_new_data;
6114   __Pyx_Buffer __pyx_pybuffer_new_data;
6115   __Pyx_LocalBuf_ND __pyx_pybuffernd_new_row;
6116   __Pyx_Buffer __pyx_pybuffer_new_row;
6117   __Pyx_LocalBuf_ND __pyx_pybuffernd_ptr;
6118   __Pyx_Buffer __pyx_pybuffer_ptr;
6119   PyObject *__pyx_r = NULL;
6120   __Pyx_RefNannyDeclarations
6121   PyObject *__pyx_t_1 = NULL;
6122   int __pyx_t_2;
6123   PyObject *__pyx_t_3 = NULL;
6124   PyObject *__pyx_t_4 = NULL;
6125   PyObject *__pyx_t_5 = NULL;
6126   __Pyx_memviewslice __pyx_t_6 = { 0, 0, { 0 }, { 0 }, { 0 } };
6127   PyArrayObject *__pyx_t_7 = NULL;
6128   PyObject *__pyx_t_8 = NULL;
6129   PyArrayObject *__pyx_t_9 = NULL;
6130   PyArrayObject *__pyx_t_10 = NULL;
6131   PyArrayObject *__pyx_t_11 = NULL;
6132   PyArrayObject *__pyx_t_12 = NULL;
6133   PyArrayObject *__pyx_t_13 = NULL;
6134   int __pyx_t_14;
6135   int __pyx_t_15;
6136   Py_ssize_t __pyx_t_16;
6137   int __pyx_t_17;
6138   int __pyx_t_18;
6139   int __pyx_t_19;
6140   Py_ssize_t __pyx_t_20;
6141   Py_ssize_t __pyx_t_21;
6142   int __pyx_t_22;
6143   PyObject *__pyx_t_23 = NULL;
6144   PyObject *__pyx_t_24 = NULL;
6145   int __pyx_lineno = 0;
6146   const char *__pyx_filename = NULL;
6147   int __pyx_clineno = 0;
6148   __Pyx_RefNannySetupContext("_ptrace_core_sp", 0);
6149   __pyx_pybuffer_new_data.pybuffer.buf = NULL;
6150   __pyx_pybuffer_new_data.refcount = 0;
6151   __pyx_pybuffernd_new_data.data = NULL;
6152   __pyx_pybuffernd_new_data.rcbuffer = &__pyx_pybuffer_new_data;
6153   __pyx_pybuffer_new_col.pybuffer.buf = NULL;
6154   __pyx_pybuffer_new_col.refcount = 0;
6155   __pyx_pybuffernd_new_col.data = NULL;
6156   __pyx_pybuffernd_new_col.rcbuffer = &__pyx_pybuffer_new_col;
6157   __pyx_pybuffer_new_row.pybuffer.buf = NULL;
6158   __pyx_pybuffer_new_row.refcount = 0;
6159   __pyx_pybuffernd_new_row.data = NULL;
6160   __pyx_pybuffernd_new_row.rcbuffer = &__pyx_pybuffer_new_row;
6161   __pyx_pybuffer_data.pybuffer.buf = NULL;
6162   __pyx_pybuffer_data.refcount = 0;
6163   __pyx_pybuffernd_data.data = NULL;
6164   __pyx_pybuffernd_data.rcbuffer = &__pyx_pybuffer_data;
6165   __pyx_pybuffer_ptr.pybuffer.buf = NULL;
6166   __pyx_pybuffer_ptr.refcount = 0;
6167   __pyx_pybuffernd_ptr.data = NULL;
6168   __pyx_pybuffernd_ptr.rcbuffer = &__pyx_pybuffer_ptr;
6169   __pyx_pybuffer_ind.pybuffer.buf = NULL;
6170   __pyx_pybuffer_ind.refcount = 0;
6171   __pyx_pybuffernd_ind.data = NULL;
6172   __pyx_pybuffernd_ind.rcbuffer = &__pyx_pybuffer_ind;
6173 
6174   /* "qutip/cy/ptrace.pyx":225
6175  * @cython.cdivision(True)
6176  * cdef object _ptrace_core_sp(rho, int[:, ::1] tensor_table, int num_sel_dims):
6177  *     cdef int p = 0, nnz = rho.nnz, ii, jj, nrow = rho.shape[0]             # <<<<<<<<<<<<<<
6178  *     cdef int[::1] pos_c = np.empty(2, dtype=np.int32)
6179  *     cdef int[::1] pos_r = np.empty(2, dtype=np.int32)
6180  */
6181   __pyx_v_p = 0;
6182   __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_rho, __pyx_n_s_nnz); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 225, __pyx_L1_error)
6183   __Pyx_GOTREF(__pyx_t_1);
6184   __pyx_t_2 = __Pyx_PyInt_As_int(__pyx_t_1); if (unlikely((__pyx_t_2 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 225, __pyx_L1_error)
6185   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
6186   __pyx_v_nnz = __pyx_t_2;
6187   __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_rho, __pyx_n_s_shape); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 225, __pyx_L1_error)
6188   __Pyx_GOTREF(__pyx_t_1);
6189   __pyx_t_3 = __Pyx_GetItemInt(__pyx_t_1, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 225, __pyx_L1_error)
6190   __Pyx_GOTREF(__pyx_t_3);
6191   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
6192   __pyx_t_2 = __Pyx_PyInt_As_int(__pyx_t_3); if (unlikely((__pyx_t_2 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 225, __pyx_L1_error)
6193   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
6194   __pyx_v_nrow = __pyx_t_2;
6195 
6196   /* "qutip/cy/ptrace.pyx":226
6197  * cdef object _ptrace_core_sp(rho, int[:, ::1] tensor_table, int num_sel_dims):
6198  *     cdef int p = 0, nnz = rho.nnz, ii, jj, nrow = rho.shape[0]
6199  *     cdef int[::1] pos_c = np.empty(2, dtype=np.int32)             # <<<<<<<<<<<<<<
6200  *     cdef int[::1] pos_r = np.empty(2, dtype=np.int32)
6201  *     cdef cnp.ndarray[complex, ndim=1, mode='c'] new_data = np.zeros(nnz, dtype=complex)
6202  */
6203   __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_np); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 226, __pyx_L1_error)
6204   __Pyx_GOTREF(__pyx_t_3);
6205   __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_empty); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 226, __pyx_L1_error)
6206   __Pyx_GOTREF(__pyx_t_1);
6207   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
6208   __pyx_t_3 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 226, __pyx_L1_error)
6209   __Pyx_GOTREF(__pyx_t_3);
6210   __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_np); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 226, __pyx_L1_error)
6211   __Pyx_GOTREF(__pyx_t_4);
6212   __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_int32); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 226, __pyx_L1_error)
6213   __Pyx_GOTREF(__pyx_t_5);
6214   __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
6215   if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_dtype, __pyx_t_5) < 0) __PYX_ERR(0, 226, __pyx_L1_error)
6216   __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
6217   __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_tuple__3, __pyx_t_3); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 226, __pyx_L1_error)
6218   __Pyx_GOTREF(__pyx_t_5);
6219   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
6220   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
6221   __pyx_t_6 = __Pyx_PyObject_to_MemoryviewSlice_dc_int(__pyx_t_5, PyBUF_WRITABLE); if (unlikely(!__pyx_t_6.memview)) __PYX_ERR(0, 226, __pyx_L1_error)
6222   __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
6223   __pyx_v_pos_c = __pyx_t_6;
6224   __pyx_t_6.memview = NULL;
6225   __pyx_t_6.data = NULL;
6226 
6227   /* "qutip/cy/ptrace.pyx":227
6228  *     cdef int p = 0, nnz = rho.nnz, ii, jj, nrow = rho.shape[0]
6229  *     cdef int[::1] pos_c = np.empty(2, dtype=np.int32)
6230  *     cdef int[::1] pos_r = np.empty(2, dtype=np.int32)             # <<<<<<<<<<<<<<
6231  *     cdef cnp.ndarray[complex, ndim=1, mode='c'] new_data = np.zeros(nnz, dtype=complex)
6232  *     cdef cnp.ndarray[int, ndim=1, mode='c'] new_col = np.zeros(nnz, dtype=np.int32)
6233  */
6234   __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_n_s_np); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 227, __pyx_L1_error)
6235   __Pyx_GOTREF(__pyx_t_5);
6236   __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_empty); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 227, __pyx_L1_error)
6237   __Pyx_GOTREF(__pyx_t_3);
6238   __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
6239   __pyx_t_5 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 227, __pyx_L1_error)
6240   __Pyx_GOTREF(__pyx_t_5);
6241   __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_np); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 227, __pyx_L1_error)
6242   __Pyx_GOTREF(__pyx_t_1);
6243   __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_int32); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 227, __pyx_L1_error)
6244   __Pyx_GOTREF(__pyx_t_4);
6245   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
6246   if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_dtype, __pyx_t_4) < 0) __PYX_ERR(0, 227, __pyx_L1_error)
6247   __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
6248   __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_tuple__3, __pyx_t_5); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 227, __pyx_L1_error)
6249   __Pyx_GOTREF(__pyx_t_4);
6250   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
6251   __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
6252   __pyx_t_6 = __Pyx_PyObject_to_MemoryviewSlice_dc_int(__pyx_t_4, PyBUF_WRITABLE); if (unlikely(!__pyx_t_6.memview)) __PYX_ERR(0, 227, __pyx_L1_error)
6253   __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
6254   __pyx_v_pos_r = __pyx_t_6;
6255   __pyx_t_6.memview = NULL;
6256   __pyx_t_6.data = NULL;
6257 
6258   /* "qutip/cy/ptrace.pyx":228
6259  *     cdef int[::1] pos_c = np.empty(2, dtype=np.int32)
6260  *     cdef int[::1] pos_r = np.empty(2, dtype=np.int32)
6261  *     cdef cnp.ndarray[complex, ndim=1, mode='c'] new_data = np.zeros(nnz, dtype=complex)             # <<<<<<<<<<<<<<
6262  *     cdef cnp.ndarray[int, ndim=1, mode='c'] new_col = np.zeros(nnz, dtype=np.int32)
6263  *     cdef cnp.ndarray[int, ndim=1, mode='c'] new_row = np.zeros(nnz, dtype=np.int32)
6264  */
6265   __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_np); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 228, __pyx_L1_error)
6266   __Pyx_GOTREF(__pyx_t_4);
6267   __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_zeros); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 228, __pyx_L1_error)
6268   __Pyx_GOTREF(__pyx_t_5);
6269   __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
6270   __pyx_t_4 = __Pyx_PyInt_From_int(__pyx_v_nnz); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 228, __pyx_L1_error)
6271   __Pyx_GOTREF(__pyx_t_4);
6272   __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 228, __pyx_L1_error)
6273   __Pyx_GOTREF(__pyx_t_3);
6274   __Pyx_GIVEREF(__pyx_t_4);
6275   PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_4);
6276   __pyx_t_4 = 0;
6277   __pyx_t_4 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 228, __pyx_L1_error)
6278   __Pyx_GOTREF(__pyx_t_4);
6279   if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_dtype, ((PyObject *)(&PyComplex_Type))) < 0) __PYX_ERR(0, 228, __pyx_L1_error)
6280   __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 228, __pyx_L1_error)
6281   __Pyx_GOTREF(__pyx_t_1);
6282   __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
6283   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
6284   __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
6285   if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 228, __pyx_L1_error)
6286   __pyx_t_7 = ((PyArrayObject *)__pyx_t_1);
6287   {
6288     __Pyx_BufFmt_StackElem __pyx_stack[1];
6289     if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_new_data.rcbuffer->pybuffer, (PyObject*)__pyx_t_7, &__Pyx_TypeInfo___pyx_t_double_complex, PyBUF_FORMAT| PyBUF_C_CONTIGUOUS| PyBUF_WRITABLE, 1, 0, __pyx_stack) == -1)) {
6290       __pyx_v_new_data = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_pybuffernd_new_data.rcbuffer->pybuffer.buf = NULL;
6291       __PYX_ERR(0, 228, __pyx_L1_error)
6292     } else {__pyx_pybuffernd_new_data.diminfo[0].strides = __pyx_pybuffernd_new_data.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_new_data.diminfo[0].shape = __pyx_pybuffernd_new_data.rcbuffer->pybuffer.shape[0];
6293     }
6294   }
6295   __pyx_t_7 = 0;
6296   __pyx_v_new_data = ((PyArrayObject *)__pyx_t_1);
6297   __pyx_t_1 = 0;
6298 
6299   /* "qutip/cy/ptrace.pyx":229
6300  *     cdef int[::1] pos_r = np.empty(2, dtype=np.int32)
6301  *     cdef cnp.ndarray[complex, ndim=1, mode='c'] new_data = np.zeros(nnz, dtype=complex)
6302  *     cdef cnp.ndarray[int, ndim=1, mode='c'] new_col = np.zeros(nnz, dtype=np.int32)             # <<<<<<<<<<<<<<
6303  *     cdef cnp.ndarray[int, ndim=1, mode='c'] new_row = np.zeros(nnz, dtype=np.int32)
6304  *     cdef cnp.ndarray[complex, ndim=1, mode='c'] data = rho.data
6305  */
6306   __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_np); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 229, __pyx_L1_error)
6307   __Pyx_GOTREF(__pyx_t_1);
6308   __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_zeros); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 229, __pyx_L1_error)
6309   __Pyx_GOTREF(__pyx_t_4);
6310   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
6311   __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_nnz); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 229, __pyx_L1_error)
6312   __Pyx_GOTREF(__pyx_t_1);
6313   __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 229, __pyx_L1_error)
6314   __Pyx_GOTREF(__pyx_t_3);
6315   __Pyx_GIVEREF(__pyx_t_1);
6316   PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_1);
6317   __pyx_t_1 = 0;
6318   __pyx_t_1 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 229, __pyx_L1_error)
6319   __Pyx_GOTREF(__pyx_t_1);
6320   __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_n_s_np); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 229, __pyx_L1_error)
6321   __Pyx_GOTREF(__pyx_t_5);
6322   __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_int32); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 229, __pyx_L1_error)
6323   __Pyx_GOTREF(__pyx_t_8);
6324   __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
6325   if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_dtype, __pyx_t_8) < 0) __PYX_ERR(0, 229, __pyx_L1_error)
6326   __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
6327   __pyx_t_8 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_3, __pyx_t_1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 229, __pyx_L1_error)
6328   __Pyx_GOTREF(__pyx_t_8);
6329   __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
6330   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
6331   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
6332   if (!(likely(((__pyx_t_8) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_8, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 229, __pyx_L1_error)
6333   __pyx_t_9 = ((PyArrayObject *)__pyx_t_8);
6334   {
6335     __Pyx_BufFmt_StackElem __pyx_stack[1];
6336     if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_new_col.rcbuffer->pybuffer, (PyObject*)__pyx_t_9, &__Pyx_TypeInfo_int, PyBUF_FORMAT| PyBUF_C_CONTIGUOUS| PyBUF_WRITABLE, 1, 0, __pyx_stack) == -1)) {
6337       __pyx_v_new_col = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_pybuffernd_new_col.rcbuffer->pybuffer.buf = NULL;
6338       __PYX_ERR(0, 229, __pyx_L1_error)
6339     } else {__pyx_pybuffernd_new_col.diminfo[0].strides = __pyx_pybuffernd_new_col.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_new_col.diminfo[0].shape = __pyx_pybuffernd_new_col.rcbuffer->pybuffer.shape[0];
6340     }
6341   }
6342   __pyx_t_9 = 0;
6343   __pyx_v_new_col = ((PyArrayObject *)__pyx_t_8);
6344   __pyx_t_8 = 0;
6345 
6346   /* "qutip/cy/ptrace.pyx":230
6347  *     cdef cnp.ndarray[complex, ndim=1, mode='c'] new_data = np.zeros(nnz, dtype=complex)
6348  *     cdef cnp.ndarray[int, ndim=1, mode='c'] new_col = np.zeros(nnz, dtype=np.int32)
6349  *     cdef cnp.ndarray[int, ndim=1, mode='c'] new_row = np.zeros(nnz, dtype=np.int32)             # <<<<<<<<<<<<<<
6350  *     cdef cnp.ndarray[complex, ndim=1, mode='c'] data = rho.data
6351  *     cdef cnp.ndarray[int, ndim=1, mode='c'] ptr = rho.indptr
6352  */
6353   __Pyx_GetModuleGlobalName(__pyx_t_8, __pyx_n_s_np); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 230, __pyx_L1_error)
6354   __Pyx_GOTREF(__pyx_t_8);
6355   __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_8, __pyx_n_s_zeros); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 230, __pyx_L1_error)
6356   __Pyx_GOTREF(__pyx_t_1);
6357   __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
6358   __pyx_t_8 = __Pyx_PyInt_From_int(__pyx_v_nnz); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 230, __pyx_L1_error)
6359   __Pyx_GOTREF(__pyx_t_8);
6360   __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 230, __pyx_L1_error)
6361   __Pyx_GOTREF(__pyx_t_3);
6362   __Pyx_GIVEREF(__pyx_t_8);
6363   PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_8);
6364   __pyx_t_8 = 0;
6365   __pyx_t_8 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 230, __pyx_L1_error)
6366   __Pyx_GOTREF(__pyx_t_8);
6367   __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_np); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 230, __pyx_L1_error)
6368   __Pyx_GOTREF(__pyx_t_4);
6369   __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_int32); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 230, __pyx_L1_error)
6370   __Pyx_GOTREF(__pyx_t_5);
6371   __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
6372   if (PyDict_SetItem(__pyx_t_8, __pyx_n_s_dtype, __pyx_t_5) < 0) __PYX_ERR(0, 230, __pyx_L1_error)
6373   __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
6374   __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_3, __pyx_t_8); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 230, __pyx_L1_error)
6375   __Pyx_GOTREF(__pyx_t_5);
6376   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
6377   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
6378   __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
6379   if (!(likely(((__pyx_t_5) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_5, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 230, __pyx_L1_error)
6380   __pyx_t_10 = ((PyArrayObject *)__pyx_t_5);
6381   {
6382     __Pyx_BufFmt_StackElem __pyx_stack[1];
6383     if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_new_row.rcbuffer->pybuffer, (PyObject*)__pyx_t_10, &__Pyx_TypeInfo_int, PyBUF_FORMAT| PyBUF_C_CONTIGUOUS| PyBUF_WRITABLE, 1, 0, __pyx_stack) == -1)) {
6384       __pyx_v_new_row = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_pybuffernd_new_row.rcbuffer->pybuffer.buf = NULL;
6385       __PYX_ERR(0, 230, __pyx_L1_error)
6386     } else {__pyx_pybuffernd_new_row.diminfo[0].strides = __pyx_pybuffernd_new_row.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_new_row.diminfo[0].shape = __pyx_pybuffernd_new_row.rcbuffer->pybuffer.shape[0];
6387     }
6388   }
6389   __pyx_t_10 = 0;
6390   __pyx_v_new_row = ((PyArrayObject *)__pyx_t_5);
6391   __pyx_t_5 = 0;
6392 
6393   /* "qutip/cy/ptrace.pyx":231
6394  *     cdef cnp.ndarray[int, ndim=1, mode='c'] new_col = np.zeros(nnz, dtype=np.int32)
6395  *     cdef cnp.ndarray[int, ndim=1, mode='c'] new_row = np.zeros(nnz, dtype=np.int32)
6396  *     cdef cnp.ndarray[complex, ndim=1, mode='c'] data = rho.data             # <<<<<<<<<<<<<<
6397  *     cdef cnp.ndarray[int, ndim=1, mode='c'] ptr = rho.indptr
6398  *     cdef cnp.ndarray[int, ndim=1, mode='c'] ind = rho.indices
6399  */
6400   __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_rho, __pyx_n_s_data); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 231, __pyx_L1_error)
6401   __Pyx_GOTREF(__pyx_t_5);
6402   if (!(likely(((__pyx_t_5) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_5, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 231, __pyx_L1_error)
6403   __pyx_t_11 = ((PyArrayObject *)__pyx_t_5);
6404   {
6405     __Pyx_BufFmt_StackElem __pyx_stack[1];
6406     if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_data.rcbuffer->pybuffer, (PyObject*)__pyx_t_11, &__Pyx_TypeInfo___pyx_t_double_complex, PyBUF_FORMAT| PyBUF_C_CONTIGUOUS, 1, 0, __pyx_stack) == -1)) {
6407       __pyx_v_data = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_pybuffernd_data.rcbuffer->pybuffer.buf = NULL;
6408       __PYX_ERR(0, 231, __pyx_L1_error)
6409     } else {__pyx_pybuffernd_data.diminfo[0].strides = __pyx_pybuffernd_data.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_data.diminfo[0].shape = __pyx_pybuffernd_data.rcbuffer->pybuffer.shape[0];
6410     }
6411   }
6412   __pyx_t_11 = 0;
6413   __pyx_v_data = ((PyArrayObject *)__pyx_t_5);
6414   __pyx_t_5 = 0;
6415 
6416   /* "qutip/cy/ptrace.pyx":232
6417  *     cdef cnp.ndarray[int, ndim=1, mode='c'] new_row = np.zeros(nnz, dtype=np.int32)
6418  *     cdef cnp.ndarray[complex, ndim=1, mode='c'] data = rho.data
6419  *     cdef cnp.ndarray[int, ndim=1, mode='c'] ptr = rho.indptr             # <<<<<<<<<<<<<<
6420  *     cdef cnp.ndarray[int, ndim=1, mode='c'] ind = rho.indices
6421  *
6422  */
6423   __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_rho, __pyx_n_s_indptr); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 232, __pyx_L1_error)
6424   __Pyx_GOTREF(__pyx_t_5);
6425   if (!(likely(((__pyx_t_5) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_5, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 232, __pyx_L1_error)
6426   __pyx_t_12 = ((PyArrayObject *)__pyx_t_5);
6427   {
6428     __Pyx_BufFmt_StackElem __pyx_stack[1];
6429     if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_ptr.rcbuffer->pybuffer, (PyObject*)__pyx_t_12, &__Pyx_TypeInfo_int, PyBUF_FORMAT| PyBUF_C_CONTIGUOUS, 1, 0, __pyx_stack) == -1)) {
6430       __pyx_v_ptr = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_pybuffernd_ptr.rcbuffer->pybuffer.buf = NULL;
6431       __PYX_ERR(0, 232, __pyx_L1_error)
6432     } else {__pyx_pybuffernd_ptr.diminfo[0].strides = __pyx_pybuffernd_ptr.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_ptr.diminfo[0].shape = __pyx_pybuffernd_ptr.rcbuffer->pybuffer.shape[0];
6433     }
6434   }
6435   __pyx_t_12 = 0;
6436   __pyx_v_ptr = ((PyArrayObject *)__pyx_t_5);
6437   __pyx_t_5 = 0;
6438 
6439   /* "qutip/cy/ptrace.pyx":233
6440  *     cdef cnp.ndarray[complex, ndim=1, mode='c'] data = rho.data
6441  *     cdef cnp.ndarray[int, ndim=1, mode='c'] ptr = rho.indptr
6442  *     cdef cnp.ndarray[int, ndim=1, mode='c'] ind = rho.indices             # <<<<<<<<<<<<<<
6443  *
6444  *     for ii in range(nrow):
6445  */
6446   __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_rho, __pyx_n_s_indices); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 233, __pyx_L1_error)
6447   __Pyx_GOTREF(__pyx_t_5);
6448   if (!(likely(((__pyx_t_5) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_5, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 233, __pyx_L1_error)
6449   __pyx_t_13 = ((PyArrayObject *)__pyx_t_5);
6450   {
6451     __Pyx_BufFmt_StackElem __pyx_stack[1];
6452     if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_ind.rcbuffer->pybuffer, (PyObject*)__pyx_t_13, &__Pyx_TypeInfo_int, PyBUF_FORMAT| PyBUF_C_CONTIGUOUS, 1, 0, __pyx_stack) == -1)) {
6453       __pyx_v_ind = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_pybuffernd_ind.rcbuffer->pybuffer.buf = NULL;
6454       __PYX_ERR(0, 233, __pyx_L1_error)
6455     } else {__pyx_pybuffernd_ind.diminfo[0].strides = __pyx_pybuffernd_ind.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_ind.diminfo[0].shape = __pyx_pybuffernd_ind.rcbuffer->pybuffer.shape[0];
6456     }
6457   }
6458   __pyx_t_13 = 0;
6459   __pyx_v_ind = ((PyArrayObject *)__pyx_t_5);
6460   __pyx_t_5 = 0;
6461 
6462   /* "qutip/cy/ptrace.pyx":235
6463  *     cdef cnp.ndarray[int, ndim=1, mode='c'] ind = rho.indices
6464  *
6465  *     for ii in range(nrow):             # <<<<<<<<<<<<<<
6466  *         for jj in range(ptr[ii], ptr[ii+1]):
6467  *             _i2_k_t(ind[jj], tensor_table, pos_c)
6468  */
6469   __pyx_t_2 = __pyx_v_nrow;
6470   __pyx_t_14 = __pyx_t_2;
6471   for (__pyx_t_15 = 0; __pyx_t_15 < __pyx_t_14; __pyx_t_15+=1) {
6472     __pyx_v_ii = __pyx_t_15;
6473 
6474     /* "qutip/cy/ptrace.pyx":236
6475  *
6476  *     for ii in range(nrow):
6477  *         for jj in range(ptr[ii], ptr[ii+1]):             # <<<<<<<<<<<<<<
6478  *             _i2_k_t(ind[jj], tensor_table, pos_c)
6479  *             _i2_k_t(ii, tensor_table, pos_r)
6480  */
6481     __pyx_t_16 = (__pyx_v_ii + 1);
6482     __pyx_t_17 = (*__Pyx_BufPtrCContig1d(int *, __pyx_pybuffernd_ptr.rcbuffer->pybuffer.buf, __pyx_t_16, __pyx_pybuffernd_ptr.diminfo[0].strides));
6483     __pyx_t_16 = __pyx_v_ii;
6484     __pyx_t_18 = __pyx_t_17;
6485     for (__pyx_t_19 = (*__Pyx_BufPtrCContig1d(int *, __pyx_pybuffernd_ptr.rcbuffer->pybuffer.buf, __pyx_t_16, __pyx_pybuffernd_ptr.diminfo[0].strides)); __pyx_t_19 < __pyx_t_18; __pyx_t_19+=1) {
6486       __pyx_v_jj = __pyx_t_19;
6487 
6488       /* "qutip/cy/ptrace.pyx":237
6489  *     for ii in range(nrow):
6490  *         for jj in range(ptr[ii], ptr[ii+1]):
6491  *             _i2_k_t(ind[jj], tensor_table, pos_c)             # <<<<<<<<<<<<<<
6492  *             _i2_k_t(ii, tensor_table, pos_r)
6493  *             if pos_c[1] == pos_r[1]:
6494  */
6495       __pyx_t_20 = __pyx_v_jj;
6496       __pyx_f_5qutip_2cy_6ptrace__i2_k_t((*__Pyx_BufPtrCContig1d(int *, __pyx_pybuffernd_ind.rcbuffer->pybuffer.buf, __pyx_t_20, __pyx_pybuffernd_ind.diminfo[0].strides)), __pyx_v_tensor_table, __pyx_v_pos_c);
6497 
6498       /* "qutip/cy/ptrace.pyx":238
6499  *         for jj in range(ptr[ii], ptr[ii+1]):
6500  *             _i2_k_t(ind[jj], tensor_table, pos_c)
6501  *             _i2_k_t(ii, tensor_table, pos_r)             # <<<<<<<<<<<<<<
6502  *             if pos_c[1] == pos_r[1]:
6503  *                 new_data[p] = data[jj]
6504  */
6505       __pyx_f_5qutip_2cy_6ptrace__i2_k_t(__pyx_v_ii, __pyx_v_tensor_table, __pyx_v_pos_r);
6506 
6507       /* "qutip/cy/ptrace.pyx":239
6508  *             _i2_k_t(ind[jj], tensor_table, pos_c)
6509  *             _i2_k_t(ii, tensor_table, pos_r)
6510  *             if pos_c[1] == pos_r[1]:             # <<<<<<<<<<<<<<
6511  *                 new_data[p] = data[jj]
6512  *                 new_row[p] = (pos_r[0])
6513  */
6514       __pyx_t_20 = 1;
6515       __pyx_t_21 = 1;
6516       __pyx_t_22 = (((*((int *) ( /* dim=0 */ ((char *) (((int *) __pyx_v_pos_c.data) + __pyx_t_20)) ))) == (*((int *) ( /* dim=0 */ ((char *) (((int *) __pyx_v_pos_r.data) + __pyx_t_21)) )))) != 0);
6517       if (__pyx_t_22) {
6518 
6519         /* "qutip/cy/ptrace.pyx":240
6520  *             _i2_k_t(ii, tensor_table, pos_r)
6521  *             if pos_c[1] == pos_r[1]:
6522  *                 new_data[p] = data[jj]             # <<<<<<<<<<<<<<
6523  *                 new_row[p] = (pos_r[0])
6524  *                 new_col[p] = (pos_c[0])
6525  */
6526         __pyx_t_21 = __pyx_v_jj;
6527         __pyx_t_20 = __pyx_v_p;
6528         *__Pyx_BufPtrCContig1d(__pyx_t_double_complex *, __pyx_pybuffernd_new_data.rcbuffer->pybuffer.buf, __pyx_t_20, __pyx_pybuffernd_new_data.diminfo[0].strides) = (*__Pyx_BufPtrCContig1d(__pyx_t_double_complex *, __pyx_pybuffernd_data.rcbuffer->pybuffer.buf, __pyx_t_21, __pyx_pybuffernd_data.diminfo[0].strides));
6529 
6530         /* "qutip/cy/ptrace.pyx":241
6531  *             if pos_c[1] == pos_r[1]:
6532  *                 new_data[p] = data[jj]
6533  *                 new_row[p] = (pos_r[0])             # <<<<<<<<<<<<<<
6534  *                 new_col[p] = (pos_c[0])
6535  *                 p += 1
6536  */
6537         __pyx_t_21 = 0;
6538         __pyx_t_20 = __pyx_v_p;
6539         *__Pyx_BufPtrCContig1d(int *, __pyx_pybuffernd_new_row.rcbuffer->pybuffer.buf, __pyx_t_20, __pyx_pybuffernd_new_row.diminfo[0].strides) = (*((int *) ( /* dim=0 */ ((char *) (((int *) __pyx_v_pos_r.data) + __pyx_t_21)) )));
6540 
6541         /* "qutip/cy/ptrace.pyx":242
6542  *                 new_data[p] = data[jj]
6543  *                 new_row[p] = (pos_r[0])
6544  *                 new_col[p] = (pos_c[0])             # <<<<<<<<<<<<<<
6545  *                 p += 1
6546  *
6547  */
6548         __pyx_t_21 = 0;
6549         __pyx_t_20 = __pyx_v_p;
6550         *__Pyx_BufPtrCContig1d(int *, __pyx_pybuffernd_new_col.rcbuffer->pybuffer.buf, __pyx_t_20, __pyx_pybuffernd_new_col.diminfo[0].strides) = (*((int *) ( /* dim=0 */ ((char *) (((int *) __pyx_v_pos_c.data) + __pyx_t_21)) )));
6551 
6552         /* "qutip/cy/ptrace.pyx":243
6553  *                 new_row[p] = (pos_r[0])
6554  *                 new_col[p] = (pos_c[0])
6555  *                 p += 1             # <<<<<<<<<<<<<<
6556  *
6557  *     return sp.coo_matrix((new_data, [new_row, new_col]),
6558  */
6559         __pyx_v_p = (__pyx_v_p + 1);
6560 
6561         /* "qutip/cy/ptrace.pyx":239
6562  *             _i2_k_t(ind[jj], tensor_table, pos_c)
6563  *             _i2_k_t(ii, tensor_table, pos_r)
6564  *             if pos_c[1] == pos_r[1]:             # <<<<<<<<<<<<<<
6565  *                 new_data[p] = data[jj]
6566  *                 new_row[p] = (pos_r[0])
6567  */
6568       }
6569     }
6570   }
6571 
6572   /* "qutip/cy/ptrace.pyx":245
6573  *                 p += 1
6574  *
6575  *     return sp.coo_matrix((new_data, [new_row, new_col]),             # <<<<<<<<<<<<<<
6576  *                          shape=(num_sel_dims,num_sel_dims)).tocsr()
6577  *
6578  */
6579   __Pyx_XDECREF(__pyx_r);
6580 
6581   /* "qutip/cy/ptrace.pyx":246
6582  *
6583  *     return sp.coo_matrix((new_data, [new_row, new_col]),
6584  *                          shape=(num_sel_dims,num_sel_dims)).tocsr()             # <<<<<<<<<<<<<<
6585  *
6586  *
6587  */
6588   __Pyx_GetModuleGlobalName(__pyx_t_8, __pyx_n_s_sp); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 245, __pyx_L1_error)
6589   __Pyx_GOTREF(__pyx_t_8);
6590 
6591   /* "qutip/cy/ptrace.pyx":245
6592  *                 p += 1
6593  *
6594  *     return sp.coo_matrix((new_data, [new_row, new_col]),             # <<<<<<<<<<<<<<
6595  *                          shape=(num_sel_dims,num_sel_dims)).tocsr()
6596  *
6597  */
6598   __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_8, __pyx_n_s_coo_matrix); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 245, __pyx_L1_error)
6599   __Pyx_GOTREF(__pyx_t_3);
6600   __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
6601   __pyx_t_8 = PyList_New(2); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 245, __pyx_L1_error)
6602   __Pyx_GOTREF(__pyx_t_8);
6603   __Pyx_INCREF(((PyObject *)__pyx_v_new_row));
6604   __Pyx_GIVEREF(((PyObject *)__pyx_v_new_row));
6605   PyList_SET_ITEM(__pyx_t_8, 0, ((PyObject *)__pyx_v_new_row));
6606   __Pyx_INCREF(((PyObject *)__pyx_v_new_col));
6607   __Pyx_GIVEREF(((PyObject *)__pyx_v_new_col));
6608   PyList_SET_ITEM(__pyx_t_8, 1, ((PyObject *)__pyx_v_new_col));
6609   __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 245, __pyx_L1_error)
6610   __Pyx_GOTREF(__pyx_t_1);
6611   __Pyx_INCREF(((PyObject *)__pyx_v_new_data));
6612   __Pyx_GIVEREF(((PyObject *)__pyx_v_new_data));
6613   PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_v_new_data));
6614   __Pyx_GIVEREF(__pyx_t_8);
6615   PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_t_8);
6616   __pyx_t_8 = 0;
6617   __pyx_t_8 = PyTuple_New(1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 245, __pyx_L1_error)
6618   __Pyx_GOTREF(__pyx_t_8);
6619   __Pyx_GIVEREF(__pyx_t_1);
6620   PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_1);
6621   __pyx_t_1 = 0;
6622 
6623   /* "qutip/cy/ptrace.pyx":246
6624  *
6625  *     return sp.coo_matrix((new_data, [new_row, new_col]),
6626  *                          shape=(num_sel_dims,num_sel_dims)).tocsr()             # <<<<<<<<<<<<<<
6627  *
6628  *
6629  */
6630   __pyx_t_1 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 246, __pyx_L1_error)
6631   __Pyx_GOTREF(__pyx_t_1);
6632   __pyx_t_4 = __Pyx_PyInt_From_int(__pyx_v_num_sel_dims); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 246, __pyx_L1_error)
6633   __Pyx_GOTREF(__pyx_t_4);
6634   __pyx_t_23 = __Pyx_PyInt_From_int(__pyx_v_num_sel_dims); if (unlikely(!__pyx_t_23)) __PYX_ERR(0, 246, __pyx_L1_error)
6635   __Pyx_GOTREF(__pyx_t_23);
6636   __pyx_t_24 = PyTuple_New(2); if (unlikely(!__pyx_t_24)) __PYX_ERR(0, 246, __pyx_L1_error)
6637   __Pyx_GOTREF(__pyx_t_24);
6638   __Pyx_GIVEREF(__pyx_t_4);
6639   PyTuple_SET_ITEM(__pyx_t_24, 0, __pyx_t_4);
6640   __Pyx_GIVEREF(__pyx_t_23);
6641   PyTuple_SET_ITEM(__pyx_t_24, 1, __pyx_t_23);
6642   __pyx_t_4 = 0;
6643   __pyx_t_23 = 0;
6644   if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_shape, __pyx_t_24) < 0) __PYX_ERR(0, 246, __pyx_L1_error)
6645   __Pyx_DECREF(__pyx_t_24); __pyx_t_24 = 0;
6646 
6647   /* "qutip/cy/ptrace.pyx":245
6648  *                 p += 1
6649  *
6650  *     return sp.coo_matrix((new_data, [new_row, new_col]),             # <<<<<<<<<<<<<<
6651  *                          shape=(num_sel_dims,num_sel_dims)).tocsr()
6652  *
6653  */
6654   __pyx_t_24 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_8, __pyx_t_1); if (unlikely(!__pyx_t_24)) __PYX_ERR(0, 245, __pyx_L1_error)
6655   __Pyx_GOTREF(__pyx_t_24);
6656   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
6657   __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
6658   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
6659 
6660   /* "qutip/cy/ptrace.pyx":246
6661  *
6662  *     return sp.coo_matrix((new_data, [new_row, new_col]),
6663  *                          shape=(num_sel_dims,num_sel_dims)).tocsr()             # <<<<<<<<<<<<<<
6664  *
6665  *
6666  */
6667   __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_24, __pyx_n_s_tocsr); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 246, __pyx_L1_error)
6668   __Pyx_GOTREF(__pyx_t_1);
6669   __Pyx_DECREF(__pyx_t_24); __pyx_t_24 = 0;
6670   __pyx_t_24 = NULL;
6671   if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_1))) {
6672     __pyx_t_24 = PyMethod_GET_SELF(__pyx_t_1);
6673     if (likely(__pyx_t_24)) {
6674       PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
6675       __Pyx_INCREF(__pyx_t_24);
6676       __Pyx_INCREF(function);
6677       __Pyx_DECREF_SET(__pyx_t_1, function);
6678     }
6679   }
6680   __pyx_t_5 = (__pyx_t_24) ? __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_24) : __Pyx_PyObject_CallNoArg(__pyx_t_1);
6681   __Pyx_XDECREF(__pyx_t_24); __pyx_t_24 = 0;
6682   if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 246, __pyx_L1_error)
6683   __Pyx_GOTREF(__pyx_t_5);
6684   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
6685   __pyx_r = __pyx_t_5;
6686   __pyx_t_5 = 0;
6687   goto __pyx_L0;
6688 
6689   /* "qutip/cy/ptrace.pyx":224
6690  * @cython.wraparound(False)
6691  * @cython.cdivision(True)
6692  * cdef object _ptrace_core_sp(rho, int[:, ::1] tensor_table, int num_sel_dims):             # <<<<<<<<<<<<<<
6693  *     cdef int p = 0, nnz = rho.nnz, ii, jj, nrow = rho.shape[0]
6694  *     cdef int[::1] pos_c = np.empty(2, dtype=np.int32)
6695  */
6696 
6697   /* function exit code */
6698   __pyx_L1_error:;
6699   __Pyx_XDECREF(__pyx_t_1);
6700   __Pyx_XDECREF(__pyx_t_3);
6701   __Pyx_XDECREF(__pyx_t_4);
6702   __Pyx_XDECREF(__pyx_t_5);
6703   __PYX_XDEC_MEMVIEW(&__pyx_t_6, 1);
6704   __Pyx_XDECREF(__pyx_t_8);
6705   __Pyx_XDECREF(__pyx_t_23);
6706   __Pyx_XDECREF(__pyx_t_24);
6707   { PyObject *__pyx_type, *__pyx_value, *__pyx_tb;
6708     __Pyx_PyThreadState_declare
6709     __Pyx_PyThreadState_assign
6710     __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb);
6711     __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_data.rcbuffer->pybuffer);
6712     __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_ind.rcbuffer->pybuffer);
6713     __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_new_col.rcbuffer->pybuffer);
6714     __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_new_data.rcbuffer->pybuffer);
6715     __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_new_row.rcbuffer->pybuffer);
6716     __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_ptr.rcbuffer->pybuffer);
6717   __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}
6718   __Pyx_AddTraceback("qutip.cy.ptrace._ptrace_core_sp", __pyx_clineno, __pyx_lineno, __pyx_filename);
6719   __pyx_r = 0;
6720   goto __pyx_L2;
6721   __pyx_L0:;
6722   __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_data.rcbuffer->pybuffer);
6723   __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_ind.rcbuffer->pybuffer);
6724   __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_new_col.rcbuffer->pybuffer);
6725   __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_new_data.rcbuffer->pybuffer);
6726   __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_new_row.rcbuffer->pybuffer);
6727   __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_ptr.rcbuffer->pybuffer);
6728   __pyx_L2:;
6729   __PYX_XDEC_MEMVIEW(&__pyx_v_pos_c, 1);
6730   __PYX_XDEC_MEMVIEW(&__pyx_v_pos_r, 1);
6731   __Pyx_XDECREF((PyObject *)__pyx_v_new_data);
6732   __Pyx_XDECREF((PyObject *)__pyx_v_new_col);
6733   __Pyx_XDECREF((PyObject *)__pyx_v_new_row);
6734   __Pyx_XDECREF((PyObject *)__pyx_v_data);
6735   __Pyx_XDECREF((PyObject *)__pyx_v_ptr);
6736   __Pyx_XDECREF((PyObject *)__pyx_v_ind);
6737   __Pyx_XGIVEREF(__pyx_r);
6738   __Pyx_RefNannyFinishContext();
6739   return __pyx_r;
6740 }
6741 
6742 /* "qutip/cy/ptrace.pyx":252
6743  * @cython.wraparound(False)
6744  * @cython.cdivision(True)
6745  * cdef object _ptrace_core_dense(rho, int[:, ::1] tensor_table, int num_sel_dims):             # <<<<<<<<<<<<<<
6746  *     cdef int nnz = rho.nnz, ii, jj, nrow = rho.shape[0]
6747  *     cdef int[::1] pos_c = np.empty(2, dtype=np.int32)
6748  */
6749 
__pyx_f_5qutip_2cy_6ptrace__ptrace_core_dense(PyObject * __pyx_v_rho,__Pyx_memviewslice __pyx_v_tensor_table,int __pyx_v_num_sel_dims)6750 static PyObject *__pyx_f_5qutip_2cy_6ptrace__ptrace_core_dense(PyObject *__pyx_v_rho, __Pyx_memviewslice __pyx_v_tensor_table, int __pyx_v_num_sel_dims) {
6751   CYTHON_UNUSED int __pyx_v_nnz;
6752   int __pyx_v_ii;
6753   int __pyx_v_jj;
6754   int __pyx_v_nrow;
6755   __Pyx_memviewslice __pyx_v_pos_c = { 0, 0, { 0 }, { 0 }, { 0 } };
6756   __Pyx_memviewslice __pyx_v_pos_r = { 0, 0, { 0 }, { 0 }, { 0 } };
6757   PyArrayObject *__pyx_v_data = 0;
6758   PyArrayObject *__pyx_v_ptr = 0;
6759   PyArrayObject *__pyx_v_ind = 0;
6760   __Pyx_memviewslice __pyx_v_data_mat = { 0, 0, { 0 }, { 0 }, { 0 } };
6761   __Pyx_LocalBuf_ND __pyx_pybuffernd_data;
6762   __Pyx_Buffer __pyx_pybuffer_data;
6763   __Pyx_LocalBuf_ND __pyx_pybuffernd_ind;
6764   __Pyx_Buffer __pyx_pybuffer_ind;
6765   __Pyx_LocalBuf_ND __pyx_pybuffernd_ptr;
6766   __Pyx_Buffer __pyx_pybuffer_ptr;
6767   PyObject *__pyx_r = NULL;
6768   __Pyx_RefNannyDeclarations
6769   PyObject *__pyx_t_1 = NULL;
6770   int __pyx_t_2;
6771   PyObject *__pyx_t_3 = NULL;
6772   PyObject *__pyx_t_4 = NULL;
6773   PyObject *__pyx_t_5 = NULL;
6774   __Pyx_memviewslice __pyx_t_6 = { 0, 0, { 0 }, { 0 }, { 0 } };
6775   PyArrayObject *__pyx_t_7 = NULL;
6776   PyArrayObject *__pyx_t_8 = NULL;
6777   PyArrayObject *__pyx_t_9 = NULL;
6778   __Pyx_memviewslice __pyx_t_10 = { 0, 0, { 0 }, { 0 }, { 0 } };
6779   int __pyx_t_11;
6780   int __pyx_t_12;
6781   Py_ssize_t __pyx_t_13;
6782   int __pyx_t_14;
6783   int __pyx_t_15;
6784   int __pyx_t_16;
6785   Py_ssize_t __pyx_t_17;
6786   Py_ssize_t __pyx_t_18;
6787   int __pyx_t_19;
6788   Py_ssize_t __pyx_t_20;
6789   Py_ssize_t __pyx_t_21;
6790   Py_ssize_t __pyx_t_22;
6791   PyObject *__pyx_t_23 = NULL;
6792   int __pyx_lineno = 0;
6793   const char *__pyx_filename = NULL;
6794   int __pyx_clineno = 0;
6795   __Pyx_RefNannySetupContext("_ptrace_core_dense", 0);
6796   __pyx_pybuffer_data.pybuffer.buf = NULL;
6797   __pyx_pybuffer_data.refcount = 0;
6798   __pyx_pybuffernd_data.data = NULL;
6799   __pyx_pybuffernd_data.rcbuffer = &__pyx_pybuffer_data;
6800   __pyx_pybuffer_ptr.pybuffer.buf = NULL;
6801   __pyx_pybuffer_ptr.refcount = 0;
6802   __pyx_pybuffernd_ptr.data = NULL;
6803   __pyx_pybuffernd_ptr.rcbuffer = &__pyx_pybuffer_ptr;
6804   __pyx_pybuffer_ind.pybuffer.buf = NULL;
6805   __pyx_pybuffer_ind.refcount = 0;
6806   __pyx_pybuffernd_ind.data = NULL;
6807   __pyx_pybuffernd_ind.rcbuffer = &__pyx_pybuffer_ind;
6808 
6809   /* "qutip/cy/ptrace.pyx":253
6810  * @cython.cdivision(True)
6811  * cdef object _ptrace_core_dense(rho, int[:, ::1] tensor_table, int num_sel_dims):
6812  *     cdef int nnz = rho.nnz, ii, jj, nrow = rho.shape[0]             # <<<<<<<<<<<<<<
6813  *     cdef int[::1] pos_c = np.empty(2, dtype=np.int32)
6814  *     cdef int[::1] pos_r = np.empty(2, dtype=np.int32)
6815  */
6816   __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_rho, __pyx_n_s_nnz); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 253, __pyx_L1_error)
6817   __Pyx_GOTREF(__pyx_t_1);
6818   __pyx_t_2 = __Pyx_PyInt_As_int(__pyx_t_1); if (unlikely((__pyx_t_2 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 253, __pyx_L1_error)
6819   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
6820   __pyx_v_nnz = __pyx_t_2;
6821   __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_rho, __pyx_n_s_shape); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 253, __pyx_L1_error)
6822   __Pyx_GOTREF(__pyx_t_1);
6823   __pyx_t_3 = __Pyx_GetItemInt(__pyx_t_1, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 253, __pyx_L1_error)
6824   __Pyx_GOTREF(__pyx_t_3);
6825   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
6826   __pyx_t_2 = __Pyx_PyInt_As_int(__pyx_t_3); if (unlikely((__pyx_t_2 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 253, __pyx_L1_error)
6827   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
6828   __pyx_v_nrow = __pyx_t_2;
6829 
6830   /* "qutip/cy/ptrace.pyx":254
6831  * cdef object _ptrace_core_dense(rho, int[:, ::1] tensor_table, int num_sel_dims):
6832  *     cdef int nnz = rho.nnz, ii, jj, nrow = rho.shape[0]
6833  *     cdef int[::1] pos_c = np.empty(2, dtype=np.int32)             # <<<<<<<<<<<<<<
6834  *     cdef int[::1] pos_r = np.empty(2, dtype=np.int32)
6835  *     cdef cnp.ndarray[complex, ndim=1, mode='c'] data = rho.data
6836  */
6837   __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_np); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 254, __pyx_L1_error)
6838   __Pyx_GOTREF(__pyx_t_3);
6839   __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_empty); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 254, __pyx_L1_error)
6840   __Pyx_GOTREF(__pyx_t_1);
6841   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
6842   __pyx_t_3 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 254, __pyx_L1_error)
6843   __Pyx_GOTREF(__pyx_t_3);
6844   __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_np); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 254, __pyx_L1_error)
6845   __Pyx_GOTREF(__pyx_t_4);
6846   __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_int32); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 254, __pyx_L1_error)
6847   __Pyx_GOTREF(__pyx_t_5);
6848   __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
6849   if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_dtype, __pyx_t_5) < 0) __PYX_ERR(0, 254, __pyx_L1_error)
6850   __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
6851   __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_tuple__3, __pyx_t_3); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 254, __pyx_L1_error)
6852   __Pyx_GOTREF(__pyx_t_5);
6853   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
6854   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
6855   __pyx_t_6 = __Pyx_PyObject_to_MemoryviewSlice_dc_int(__pyx_t_5, PyBUF_WRITABLE); if (unlikely(!__pyx_t_6.memview)) __PYX_ERR(0, 254, __pyx_L1_error)
6856   __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
6857   __pyx_v_pos_c = __pyx_t_6;
6858   __pyx_t_6.memview = NULL;
6859   __pyx_t_6.data = NULL;
6860 
6861   /* "qutip/cy/ptrace.pyx":255
6862  *     cdef int nnz = rho.nnz, ii, jj, nrow = rho.shape[0]
6863  *     cdef int[::1] pos_c = np.empty(2, dtype=np.int32)
6864  *     cdef int[::1] pos_r = np.empty(2, dtype=np.int32)             # <<<<<<<<<<<<<<
6865  *     cdef cnp.ndarray[complex, ndim=1, mode='c'] data = rho.data
6866  *     cdef cnp.ndarray[int, ndim=1, mode='c'] ptr = rho.indptr
6867  */
6868   __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_n_s_np); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 255, __pyx_L1_error)
6869   __Pyx_GOTREF(__pyx_t_5);
6870   __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_empty); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 255, __pyx_L1_error)
6871   __Pyx_GOTREF(__pyx_t_3);
6872   __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
6873   __pyx_t_5 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 255, __pyx_L1_error)
6874   __Pyx_GOTREF(__pyx_t_5);
6875   __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_np); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 255, __pyx_L1_error)
6876   __Pyx_GOTREF(__pyx_t_1);
6877   __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_int32); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 255, __pyx_L1_error)
6878   __Pyx_GOTREF(__pyx_t_4);
6879   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
6880   if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_dtype, __pyx_t_4) < 0) __PYX_ERR(0, 255, __pyx_L1_error)
6881   __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
6882   __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_tuple__3, __pyx_t_5); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 255, __pyx_L1_error)
6883   __Pyx_GOTREF(__pyx_t_4);
6884   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
6885   __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
6886   __pyx_t_6 = __Pyx_PyObject_to_MemoryviewSlice_dc_int(__pyx_t_4, PyBUF_WRITABLE); if (unlikely(!__pyx_t_6.memview)) __PYX_ERR(0, 255, __pyx_L1_error)
6887   __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
6888   __pyx_v_pos_r = __pyx_t_6;
6889   __pyx_t_6.memview = NULL;
6890   __pyx_t_6.data = NULL;
6891 
6892   /* "qutip/cy/ptrace.pyx":256
6893  *     cdef int[::1] pos_c = np.empty(2, dtype=np.int32)
6894  *     cdef int[::1] pos_r = np.empty(2, dtype=np.int32)
6895  *     cdef cnp.ndarray[complex, ndim=1, mode='c'] data = rho.data             # <<<<<<<<<<<<<<
6896  *     cdef cnp.ndarray[int, ndim=1, mode='c'] ptr = rho.indptr
6897  *     cdef cnp.ndarray[int, ndim=1, mode='c'] ind = rho.indices
6898  */
6899   __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_rho, __pyx_n_s_data); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 256, __pyx_L1_error)
6900   __Pyx_GOTREF(__pyx_t_4);
6901   if (!(likely(((__pyx_t_4) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_4, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 256, __pyx_L1_error)
6902   __pyx_t_7 = ((PyArrayObject *)__pyx_t_4);
6903   {
6904     __Pyx_BufFmt_StackElem __pyx_stack[1];
6905     if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_data.rcbuffer->pybuffer, (PyObject*)__pyx_t_7, &__Pyx_TypeInfo___pyx_t_double_complex, PyBUF_FORMAT| PyBUF_C_CONTIGUOUS, 1, 0, __pyx_stack) == -1)) {
6906       __pyx_v_data = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_pybuffernd_data.rcbuffer->pybuffer.buf = NULL;
6907       __PYX_ERR(0, 256, __pyx_L1_error)
6908     } else {__pyx_pybuffernd_data.diminfo[0].strides = __pyx_pybuffernd_data.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_data.diminfo[0].shape = __pyx_pybuffernd_data.rcbuffer->pybuffer.shape[0];
6909     }
6910   }
6911   __pyx_t_7 = 0;
6912   __pyx_v_data = ((PyArrayObject *)__pyx_t_4);
6913   __pyx_t_4 = 0;
6914 
6915   /* "qutip/cy/ptrace.pyx":257
6916  *     cdef int[::1] pos_r = np.empty(2, dtype=np.int32)
6917  *     cdef cnp.ndarray[complex, ndim=1, mode='c'] data = rho.data
6918  *     cdef cnp.ndarray[int, ndim=1, mode='c'] ptr = rho.indptr             # <<<<<<<<<<<<<<
6919  *     cdef cnp.ndarray[int, ndim=1, mode='c'] ind = rho.indices
6920  *     cdef complex[:, ::1] data_mat = np.zeros((num_sel_dims, num_sel_dims),
6921  */
6922   __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_rho, __pyx_n_s_indptr); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 257, __pyx_L1_error)
6923   __Pyx_GOTREF(__pyx_t_4);
6924   if (!(likely(((__pyx_t_4) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_4, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 257, __pyx_L1_error)
6925   __pyx_t_8 = ((PyArrayObject *)__pyx_t_4);
6926   {
6927     __Pyx_BufFmt_StackElem __pyx_stack[1];
6928     if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_ptr.rcbuffer->pybuffer, (PyObject*)__pyx_t_8, &__Pyx_TypeInfo_int, PyBUF_FORMAT| PyBUF_C_CONTIGUOUS, 1, 0, __pyx_stack) == -1)) {
6929       __pyx_v_ptr = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_pybuffernd_ptr.rcbuffer->pybuffer.buf = NULL;
6930       __PYX_ERR(0, 257, __pyx_L1_error)
6931     } else {__pyx_pybuffernd_ptr.diminfo[0].strides = __pyx_pybuffernd_ptr.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_ptr.diminfo[0].shape = __pyx_pybuffernd_ptr.rcbuffer->pybuffer.shape[0];
6932     }
6933   }
6934   __pyx_t_8 = 0;
6935   __pyx_v_ptr = ((PyArrayObject *)__pyx_t_4);
6936   __pyx_t_4 = 0;
6937 
6938   /* "qutip/cy/ptrace.pyx":258
6939  *     cdef cnp.ndarray[complex, ndim=1, mode='c'] data = rho.data
6940  *     cdef cnp.ndarray[int, ndim=1, mode='c'] ptr = rho.indptr
6941  *     cdef cnp.ndarray[int, ndim=1, mode='c'] ind = rho.indices             # <<<<<<<<<<<<<<
6942  *     cdef complex[:, ::1] data_mat = np.zeros((num_sel_dims, num_sel_dims),
6943  *                                           dtype=complex)
6944  */
6945   __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_rho, __pyx_n_s_indices); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 258, __pyx_L1_error)
6946   __Pyx_GOTREF(__pyx_t_4);
6947   if (!(likely(((__pyx_t_4) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_4, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 258, __pyx_L1_error)
6948   __pyx_t_9 = ((PyArrayObject *)__pyx_t_4);
6949   {
6950     __Pyx_BufFmt_StackElem __pyx_stack[1];
6951     if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_ind.rcbuffer->pybuffer, (PyObject*)__pyx_t_9, &__Pyx_TypeInfo_int, PyBUF_FORMAT| PyBUF_C_CONTIGUOUS, 1, 0, __pyx_stack) == -1)) {
6952       __pyx_v_ind = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_pybuffernd_ind.rcbuffer->pybuffer.buf = NULL;
6953       __PYX_ERR(0, 258, __pyx_L1_error)
6954     } else {__pyx_pybuffernd_ind.diminfo[0].strides = __pyx_pybuffernd_ind.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_ind.diminfo[0].shape = __pyx_pybuffernd_ind.rcbuffer->pybuffer.shape[0];
6955     }
6956   }
6957   __pyx_t_9 = 0;
6958   __pyx_v_ind = ((PyArrayObject *)__pyx_t_4);
6959   __pyx_t_4 = 0;
6960 
6961   /* "qutip/cy/ptrace.pyx":259
6962  *     cdef cnp.ndarray[int, ndim=1, mode='c'] ptr = rho.indptr
6963  *     cdef cnp.ndarray[int, ndim=1, mode='c'] ind = rho.indices
6964  *     cdef complex[:, ::1] data_mat = np.zeros((num_sel_dims, num_sel_dims),             # <<<<<<<<<<<<<<
6965  *                                           dtype=complex)
6966  *
6967  */
6968   __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_np); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 259, __pyx_L1_error)
6969   __Pyx_GOTREF(__pyx_t_4);
6970   __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_zeros); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 259, __pyx_L1_error)
6971   __Pyx_GOTREF(__pyx_t_5);
6972   __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
6973   __pyx_t_4 = __Pyx_PyInt_From_int(__pyx_v_num_sel_dims); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 259, __pyx_L1_error)
6974   __Pyx_GOTREF(__pyx_t_4);
6975   __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_num_sel_dims); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 259, __pyx_L1_error)
6976   __Pyx_GOTREF(__pyx_t_3);
6977   __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 259, __pyx_L1_error)
6978   __Pyx_GOTREF(__pyx_t_1);
6979   __Pyx_GIVEREF(__pyx_t_4);
6980   PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_4);
6981   __Pyx_GIVEREF(__pyx_t_3);
6982   PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_t_3);
6983   __pyx_t_4 = 0;
6984   __pyx_t_3 = 0;
6985   __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 259, __pyx_L1_error)
6986   __Pyx_GOTREF(__pyx_t_3);
6987   __Pyx_GIVEREF(__pyx_t_1);
6988   PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_1);
6989   __pyx_t_1 = 0;
6990 
6991   /* "qutip/cy/ptrace.pyx":260
6992  *     cdef cnp.ndarray[int, ndim=1, mode='c'] ind = rho.indices
6993  *     cdef complex[:, ::1] data_mat = np.zeros((num_sel_dims, num_sel_dims),
6994  *                                           dtype=complex)             # <<<<<<<<<<<<<<
6995  *
6996  *     for ii in range(nrow):
6997  */
6998   __pyx_t_1 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 260, __pyx_L1_error)
6999   __Pyx_GOTREF(__pyx_t_1);
7000   if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_dtype, ((PyObject *)(&PyComplex_Type))) < 0) __PYX_ERR(0, 260, __pyx_L1_error)
7001 
7002   /* "qutip/cy/ptrace.pyx":259
7003  *     cdef cnp.ndarray[int, ndim=1, mode='c'] ptr = rho.indptr
7004  *     cdef cnp.ndarray[int, ndim=1, mode='c'] ind = rho.indices
7005  *     cdef complex[:, ::1] data_mat = np.zeros((num_sel_dims, num_sel_dims),             # <<<<<<<<<<<<<<
7006  *                                           dtype=complex)
7007  *
7008  */
7009   __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_3, __pyx_t_1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 259, __pyx_L1_error)
7010   __Pyx_GOTREF(__pyx_t_4);
7011   __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
7012   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
7013   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
7014   __pyx_t_10 = __Pyx_PyObject_to_MemoryviewSlice_d_dc___pyx_t_double_complex(__pyx_t_4, PyBUF_WRITABLE); if (unlikely(!__pyx_t_10.memview)) __PYX_ERR(0, 259, __pyx_L1_error)
7015   __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
7016   __pyx_v_data_mat = __pyx_t_10;
7017   __pyx_t_10.memview = NULL;
7018   __pyx_t_10.data = NULL;
7019 
7020   /* "qutip/cy/ptrace.pyx":262
7021  *                                           dtype=complex)
7022  *
7023  *     for ii in range(nrow):             # <<<<<<<<<<<<<<
7024  *         for jj in range(ptr[ii], ptr[ii+1]):
7025  *             _i2_k_t(ind[jj], tensor_table, pos_c)
7026  */
7027   __pyx_t_2 = __pyx_v_nrow;
7028   __pyx_t_11 = __pyx_t_2;
7029   for (__pyx_t_12 = 0; __pyx_t_12 < __pyx_t_11; __pyx_t_12+=1) {
7030     __pyx_v_ii = __pyx_t_12;
7031 
7032     /* "qutip/cy/ptrace.pyx":263
7033  *
7034  *     for ii in range(nrow):
7035  *         for jj in range(ptr[ii], ptr[ii+1]):             # <<<<<<<<<<<<<<
7036  *             _i2_k_t(ind[jj], tensor_table, pos_c)
7037  *             _i2_k_t(ii, tensor_table, pos_r)
7038  */
7039     __pyx_t_13 = (__pyx_v_ii + 1);
7040     __pyx_t_14 = (*__Pyx_BufPtrCContig1d(int *, __pyx_pybuffernd_ptr.rcbuffer->pybuffer.buf, __pyx_t_13, __pyx_pybuffernd_ptr.diminfo[0].strides));
7041     __pyx_t_13 = __pyx_v_ii;
7042     __pyx_t_15 = __pyx_t_14;
7043     for (__pyx_t_16 = (*__Pyx_BufPtrCContig1d(int *, __pyx_pybuffernd_ptr.rcbuffer->pybuffer.buf, __pyx_t_13, __pyx_pybuffernd_ptr.diminfo[0].strides)); __pyx_t_16 < __pyx_t_15; __pyx_t_16+=1) {
7044       __pyx_v_jj = __pyx_t_16;
7045 
7046       /* "qutip/cy/ptrace.pyx":264
7047  *     for ii in range(nrow):
7048  *         for jj in range(ptr[ii], ptr[ii+1]):
7049  *             _i2_k_t(ind[jj], tensor_table, pos_c)             # <<<<<<<<<<<<<<
7050  *             _i2_k_t(ii, tensor_table, pos_r)
7051  *             if pos_c[1] == pos_r[1]:
7052  */
7053       __pyx_t_17 = __pyx_v_jj;
7054       __pyx_f_5qutip_2cy_6ptrace__i2_k_t((*__Pyx_BufPtrCContig1d(int *, __pyx_pybuffernd_ind.rcbuffer->pybuffer.buf, __pyx_t_17, __pyx_pybuffernd_ind.diminfo[0].strides)), __pyx_v_tensor_table, __pyx_v_pos_c);
7055 
7056       /* "qutip/cy/ptrace.pyx":265
7057  *         for jj in range(ptr[ii], ptr[ii+1]):
7058  *             _i2_k_t(ind[jj], tensor_table, pos_c)
7059  *             _i2_k_t(ii, tensor_table, pos_r)             # <<<<<<<<<<<<<<
7060  *             if pos_c[1] == pos_r[1]:
7061  *                 data_mat[pos_r[0], pos_c[0]] += data[jj]
7062  */
7063       __pyx_f_5qutip_2cy_6ptrace__i2_k_t(__pyx_v_ii, __pyx_v_tensor_table, __pyx_v_pos_r);
7064 
7065       /* "qutip/cy/ptrace.pyx":266
7066  *             _i2_k_t(ind[jj], tensor_table, pos_c)
7067  *             _i2_k_t(ii, tensor_table, pos_r)
7068  *             if pos_c[1] == pos_r[1]:             # <<<<<<<<<<<<<<
7069  *                 data_mat[pos_r[0], pos_c[0]] += data[jj]
7070  *
7071  */
7072       __pyx_t_17 = 1;
7073       __pyx_t_18 = 1;
7074       __pyx_t_19 = (((*((int *) ( /* dim=0 */ ((char *) (((int *) __pyx_v_pos_c.data) + __pyx_t_17)) ))) == (*((int *) ( /* dim=0 */ ((char *) (((int *) __pyx_v_pos_r.data) + __pyx_t_18)) )))) != 0);
7075       if (__pyx_t_19) {
7076 
7077         /* "qutip/cy/ptrace.pyx":267
7078  *             _i2_k_t(ii, tensor_table, pos_r)
7079  *             if pos_c[1] == pos_r[1]:
7080  *                 data_mat[pos_r[0], pos_c[0]] += data[jj]             # <<<<<<<<<<<<<<
7081  *
7082  *     return sp.coo_matrix(data_mat).tocsr()
7083  */
7084         __pyx_t_18 = __pyx_v_jj;
7085         __pyx_t_17 = 0;
7086         __pyx_t_20 = 0;
7087         __pyx_t_21 = (*((int *) ( /* dim=0 */ ((char *) (((int *) __pyx_v_pos_r.data) + __pyx_t_17)) )));
7088         __pyx_t_22 = (*((int *) ( /* dim=0 */ ((char *) (((int *) __pyx_v_pos_c.data) + __pyx_t_20)) )));
7089         *((__pyx_t_double_complex *) ( /* dim=1 */ ((char *) (((__pyx_t_double_complex *) ( /* dim=0 */ (__pyx_v_data_mat.data + __pyx_t_21 * __pyx_v_data_mat.strides[0]) )) + __pyx_t_22)) )) += (*__Pyx_BufPtrCContig1d(__pyx_t_double_complex *, __pyx_pybuffernd_data.rcbuffer->pybuffer.buf, __pyx_t_18, __pyx_pybuffernd_data.diminfo[0].strides));
7090 
7091         /* "qutip/cy/ptrace.pyx":266
7092  *             _i2_k_t(ind[jj], tensor_table, pos_c)
7093  *             _i2_k_t(ii, tensor_table, pos_r)
7094  *             if pos_c[1] == pos_r[1]:             # <<<<<<<<<<<<<<
7095  *                 data_mat[pos_r[0], pos_c[0]] += data[jj]
7096  *
7097  */
7098       }
7099     }
7100   }
7101 
7102   /* "qutip/cy/ptrace.pyx":269
7103  *                 data_mat[pos_r[0], pos_c[0]] += data[jj]
7104  *
7105  *     return sp.coo_matrix(data_mat).tocsr()             # <<<<<<<<<<<<<<
7106  */
7107   __Pyx_XDECREF(__pyx_r);
7108   __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_sp); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 269, __pyx_L1_error)
7109   __Pyx_GOTREF(__pyx_t_3);
7110   __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_coo_matrix); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 269, __pyx_L1_error)
7111   __Pyx_GOTREF(__pyx_t_5);
7112   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
7113   __pyx_t_3 = __pyx_memoryview_fromslice(__pyx_v_data_mat, 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_3)) __PYX_ERR(0, 269, __pyx_L1_error)
7114   __Pyx_GOTREF(__pyx_t_3);
7115   __pyx_t_23 = NULL;
7116   if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_5))) {
7117     __pyx_t_23 = PyMethod_GET_SELF(__pyx_t_5);
7118     if (likely(__pyx_t_23)) {
7119       PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
7120       __Pyx_INCREF(__pyx_t_23);
7121       __Pyx_INCREF(function);
7122       __Pyx_DECREF_SET(__pyx_t_5, function);
7123     }
7124   }
7125   __pyx_t_1 = (__pyx_t_23) ? __Pyx_PyObject_Call2Args(__pyx_t_5, __pyx_t_23, __pyx_t_3) : __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_t_3);
7126   __Pyx_XDECREF(__pyx_t_23); __pyx_t_23 = 0;
7127   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
7128   if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 269, __pyx_L1_error)
7129   __Pyx_GOTREF(__pyx_t_1);
7130   __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
7131   __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_tocsr); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 269, __pyx_L1_error)
7132   __Pyx_GOTREF(__pyx_t_5);
7133   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
7134   __pyx_t_1 = NULL;
7135   if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_5))) {
7136     __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_5);
7137     if (likely(__pyx_t_1)) {
7138       PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
7139       __Pyx_INCREF(__pyx_t_1);
7140       __Pyx_INCREF(function);
7141       __Pyx_DECREF_SET(__pyx_t_5, function);
7142     }
7143   }
7144   __pyx_t_4 = (__pyx_t_1) ? __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_t_1) : __Pyx_PyObject_CallNoArg(__pyx_t_5);
7145   __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
7146   if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 269, __pyx_L1_error)
7147   __Pyx_GOTREF(__pyx_t_4);
7148   __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
7149   __pyx_r = __pyx_t_4;
7150   __pyx_t_4 = 0;
7151   goto __pyx_L0;
7152 
7153   /* "qutip/cy/ptrace.pyx":252
7154  * @cython.wraparound(False)
7155  * @cython.cdivision(True)
7156  * cdef object _ptrace_core_dense(rho, int[:, ::1] tensor_table, int num_sel_dims):             # <<<<<<<<<<<<<<
7157  *     cdef int nnz = rho.nnz, ii, jj, nrow = rho.shape[0]
7158  *     cdef int[::1] pos_c = np.empty(2, dtype=np.int32)
7159  */
7160 
7161   /* function exit code */
7162   __pyx_L1_error:;
7163   __Pyx_XDECREF(__pyx_t_1);
7164   __Pyx_XDECREF(__pyx_t_3);
7165   __Pyx_XDECREF(__pyx_t_4);
7166   __Pyx_XDECREF(__pyx_t_5);
7167   __PYX_XDEC_MEMVIEW(&__pyx_t_6, 1);
7168   __PYX_XDEC_MEMVIEW(&__pyx_t_10, 1);
7169   __Pyx_XDECREF(__pyx_t_23);
7170   { PyObject *__pyx_type, *__pyx_value, *__pyx_tb;
7171     __Pyx_PyThreadState_declare
7172     __Pyx_PyThreadState_assign
7173     __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb);
7174     __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_data.rcbuffer->pybuffer);
7175     __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_ind.rcbuffer->pybuffer);
7176     __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_ptr.rcbuffer->pybuffer);
7177   __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}
7178   __Pyx_AddTraceback("qutip.cy.ptrace._ptrace_core_dense", __pyx_clineno, __pyx_lineno, __pyx_filename);
7179   __pyx_r = 0;
7180   goto __pyx_L2;
7181   __pyx_L0:;
7182   __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_data.rcbuffer->pybuffer);
7183   __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_ind.rcbuffer->pybuffer);
7184   __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_ptr.rcbuffer->pybuffer);
7185   __pyx_L2:;
7186   __PYX_XDEC_MEMVIEW(&__pyx_v_pos_c, 1);
7187   __PYX_XDEC_MEMVIEW(&__pyx_v_pos_r, 1);
7188   __Pyx_XDECREF((PyObject *)__pyx_v_data);
7189   __Pyx_XDECREF((PyObject *)__pyx_v_ptr);
7190   __Pyx_XDECREF((PyObject *)__pyx_v_ind);
7191   __PYX_XDEC_MEMVIEW(&__pyx_v_data_mat, 1);
7192   __Pyx_XGIVEREF(__pyx_r);
7193   __Pyx_RefNannyFinishContext();
7194   return __pyx_r;
7195 }
7196 
7197 /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":734
7198  * ctypedef npy_cdouble     complex_t
7199  *
7200  * cdef inline object PyArray_MultiIterNew1(a):             # <<<<<<<<<<<<<<
7201  *     return PyArray_MultiIterNew(1, <void*>a)
7202  *
7203  */
7204 
__pyx_f_5numpy_PyArray_MultiIterNew1(PyObject * __pyx_v_a)7205 static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew1(PyObject *__pyx_v_a) {
7206   PyObject *__pyx_r = NULL;
7207   __Pyx_RefNannyDeclarations
7208   PyObject *__pyx_t_1 = NULL;
7209   int __pyx_lineno = 0;
7210   const char *__pyx_filename = NULL;
7211   int __pyx_clineno = 0;
7212   __Pyx_RefNannySetupContext("PyArray_MultiIterNew1", 0);
7213 
7214   /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":735
7215  *
7216  * cdef inline object PyArray_MultiIterNew1(a):
7217  *     return PyArray_MultiIterNew(1, <void*>a)             # <<<<<<<<<<<<<<
7218  *
7219  * cdef inline object PyArray_MultiIterNew2(a, b):
7220  */
7221   __Pyx_XDECREF(__pyx_r);
7222   __pyx_t_1 = PyArray_MultiIterNew(1, ((void *)__pyx_v_a)); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 735, __pyx_L1_error)
7223   __Pyx_GOTREF(__pyx_t_1);
7224   __pyx_r = __pyx_t_1;
7225   __pyx_t_1 = 0;
7226   goto __pyx_L0;
7227 
7228   /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":734
7229  * ctypedef npy_cdouble     complex_t
7230  *
7231  * cdef inline object PyArray_MultiIterNew1(a):             # <<<<<<<<<<<<<<
7232  *     return PyArray_MultiIterNew(1, <void*>a)
7233  *
7234  */
7235 
7236   /* function exit code */
7237   __pyx_L1_error:;
7238   __Pyx_XDECREF(__pyx_t_1);
7239   __Pyx_AddTraceback("numpy.PyArray_MultiIterNew1", __pyx_clineno, __pyx_lineno, __pyx_filename);
7240   __pyx_r = 0;
7241   __pyx_L0:;
7242   __Pyx_XGIVEREF(__pyx_r);
7243   __Pyx_RefNannyFinishContext();
7244   return __pyx_r;
7245 }
7246 
7247 /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":737
7248  *     return PyArray_MultiIterNew(1, <void*>a)
7249  *
7250  * cdef inline object PyArray_MultiIterNew2(a, b):             # <<<<<<<<<<<<<<
7251  *     return PyArray_MultiIterNew(2, <void*>a, <void*>b)
7252  *
7253  */
7254 
__pyx_f_5numpy_PyArray_MultiIterNew2(PyObject * __pyx_v_a,PyObject * __pyx_v_b)7255 static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew2(PyObject *__pyx_v_a, PyObject *__pyx_v_b) {
7256   PyObject *__pyx_r = NULL;
7257   __Pyx_RefNannyDeclarations
7258   PyObject *__pyx_t_1 = NULL;
7259   int __pyx_lineno = 0;
7260   const char *__pyx_filename = NULL;
7261   int __pyx_clineno = 0;
7262   __Pyx_RefNannySetupContext("PyArray_MultiIterNew2", 0);
7263 
7264   /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":738
7265  *
7266  * cdef inline object PyArray_MultiIterNew2(a, b):
7267  *     return PyArray_MultiIterNew(2, <void*>a, <void*>b)             # <<<<<<<<<<<<<<
7268  *
7269  * cdef inline object PyArray_MultiIterNew3(a, b, c):
7270  */
7271   __Pyx_XDECREF(__pyx_r);
7272   __pyx_t_1 = PyArray_MultiIterNew(2, ((void *)__pyx_v_a), ((void *)__pyx_v_b)); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 738, __pyx_L1_error)
7273   __Pyx_GOTREF(__pyx_t_1);
7274   __pyx_r = __pyx_t_1;
7275   __pyx_t_1 = 0;
7276   goto __pyx_L0;
7277 
7278   /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":737
7279  *     return PyArray_MultiIterNew(1, <void*>a)
7280  *
7281  * cdef inline object PyArray_MultiIterNew2(a, b):             # <<<<<<<<<<<<<<
7282  *     return PyArray_MultiIterNew(2, <void*>a, <void*>b)
7283  *
7284  */
7285 
7286   /* function exit code */
7287   __pyx_L1_error:;
7288   __Pyx_XDECREF(__pyx_t_1);
7289   __Pyx_AddTraceback("numpy.PyArray_MultiIterNew2", __pyx_clineno, __pyx_lineno, __pyx_filename);
7290   __pyx_r = 0;
7291   __pyx_L0:;
7292   __Pyx_XGIVEREF(__pyx_r);
7293   __Pyx_RefNannyFinishContext();
7294   return __pyx_r;
7295 }
7296 
7297 /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":740
7298  *     return PyArray_MultiIterNew(2, <void*>a, <void*>b)
7299  *
7300  * cdef inline object PyArray_MultiIterNew3(a, b, c):             # <<<<<<<<<<<<<<
7301  *     return PyArray_MultiIterNew(3, <void*>a, <void*>b, <void*> c)
7302  *
7303  */
7304 
__pyx_f_5numpy_PyArray_MultiIterNew3(PyObject * __pyx_v_a,PyObject * __pyx_v_b,PyObject * __pyx_v_c)7305 static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew3(PyObject *__pyx_v_a, PyObject *__pyx_v_b, PyObject *__pyx_v_c) {
7306   PyObject *__pyx_r = NULL;
7307   __Pyx_RefNannyDeclarations
7308   PyObject *__pyx_t_1 = NULL;
7309   int __pyx_lineno = 0;
7310   const char *__pyx_filename = NULL;
7311   int __pyx_clineno = 0;
7312   __Pyx_RefNannySetupContext("PyArray_MultiIterNew3", 0);
7313 
7314   /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":741
7315  *
7316  * cdef inline object PyArray_MultiIterNew3(a, b, c):
7317  *     return PyArray_MultiIterNew(3, <void*>a, <void*>b, <void*> c)             # <<<<<<<<<<<<<<
7318  *
7319  * cdef inline object PyArray_MultiIterNew4(a, b, c, d):
7320  */
7321   __Pyx_XDECREF(__pyx_r);
7322   __pyx_t_1 = PyArray_MultiIterNew(3, ((void *)__pyx_v_a), ((void *)__pyx_v_b), ((void *)__pyx_v_c)); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 741, __pyx_L1_error)
7323   __Pyx_GOTREF(__pyx_t_1);
7324   __pyx_r = __pyx_t_1;
7325   __pyx_t_1 = 0;
7326   goto __pyx_L0;
7327 
7328   /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":740
7329  *     return PyArray_MultiIterNew(2, <void*>a, <void*>b)
7330  *
7331  * cdef inline object PyArray_MultiIterNew3(a, b, c):             # <<<<<<<<<<<<<<
7332  *     return PyArray_MultiIterNew(3, <void*>a, <void*>b, <void*> c)
7333  *
7334  */
7335 
7336   /* function exit code */
7337   __pyx_L1_error:;
7338   __Pyx_XDECREF(__pyx_t_1);
7339   __Pyx_AddTraceback("numpy.PyArray_MultiIterNew3", __pyx_clineno, __pyx_lineno, __pyx_filename);
7340   __pyx_r = 0;
7341   __pyx_L0:;
7342   __Pyx_XGIVEREF(__pyx_r);
7343   __Pyx_RefNannyFinishContext();
7344   return __pyx_r;
7345 }
7346 
7347 /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":743
7348  *     return PyArray_MultiIterNew(3, <void*>a, <void*>b, <void*> c)
7349  *
7350  * cdef inline object PyArray_MultiIterNew4(a, b, c, d):             # <<<<<<<<<<<<<<
7351  *     return PyArray_MultiIterNew(4, <void*>a, <void*>b, <void*>c, <void*> d)
7352  *
7353  */
7354 
__pyx_f_5numpy_PyArray_MultiIterNew4(PyObject * __pyx_v_a,PyObject * __pyx_v_b,PyObject * __pyx_v_c,PyObject * __pyx_v_d)7355 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) {
7356   PyObject *__pyx_r = NULL;
7357   __Pyx_RefNannyDeclarations
7358   PyObject *__pyx_t_1 = NULL;
7359   int __pyx_lineno = 0;
7360   const char *__pyx_filename = NULL;
7361   int __pyx_clineno = 0;
7362   __Pyx_RefNannySetupContext("PyArray_MultiIterNew4", 0);
7363 
7364   /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":744
7365  *
7366  * cdef inline object PyArray_MultiIterNew4(a, b, c, d):
7367  *     return PyArray_MultiIterNew(4, <void*>a, <void*>b, <void*>c, <void*> d)             # <<<<<<<<<<<<<<
7368  *
7369  * cdef inline object PyArray_MultiIterNew5(a, b, c, d, e):
7370  */
7371   __Pyx_XDECREF(__pyx_r);
7372   __pyx_t_1 = PyArray_MultiIterNew(4, ((void *)__pyx_v_a), ((void *)__pyx_v_b), ((void *)__pyx_v_c), ((void *)__pyx_v_d)); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 744, __pyx_L1_error)
7373   __Pyx_GOTREF(__pyx_t_1);
7374   __pyx_r = __pyx_t_1;
7375   __pyx_t_1 = 0;
7376   goto __pyx_L0;
7377 
7378   /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":743
7379  *     return PyArray_MultiIterNew(3, <void*>a, <void*>b, <void*> c)
7380  *
7381  * cdef inline object PyArray_MultiIterNew4(a, b, c, d):             # <<<<<<<<<<<<<<
7382  *     return PyArray_MultiIterNew(4, <void*>a, <void*>b, <void*>c, <void*> d)
7383  *
7384  */
7385 
7386   /* function exit code */
7387   __pyx_L1_error:;
7388   __Pyx_XDECREF(__pyx_t_1);
7389   __Pyx_AddTraceback("numpy.PyArray_MultiIterNew4", __pyx_clineno, __pyx_lineno, __pyx_filename);
7390   __pyx_r = 0;
7391   __pyx_L0:;
7392   __Pyx_XGIVEREF(__pyx_r);
7393   __Pyx_RefNannyFinishContext();
7394   return __pyx_r;
7395 }
7396 
7397 /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":746
7398  *     return PyArray_MultiIterNew(4, <void*>a, <void*>b, <void*>c, <void*> d)
7399  *
7400  * cdef inline object PyArray_MultiIterNew5(a, b, c, d, e):             # <<<<<<<<<<<<<<
7401  *     return PyArray_MultiIterNew(5, <void*>a, <void*>b, <void*>c, <void*> d, <void*> e)
7402  *
7403  */
7404 
__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)7405 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) {
7406   PyObject *__pyx_r = NULL;
7407   __Pyx_RefNannyDeclarations
7408   PyObject *__pyx_t_1 = NULL;
7409   int __pyx_lineno = 0;
7410   const char *__pyx_filename = NULL;
7411   int __pyx_clineno = 0;
7412   __Pyx_RefNannySetupContext("PyArray_MultiIterNew5", 0);
7413 
7414   /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":747
7415  *
7416  * cdef inline object PyArray_MultiIterNew5(a, b, c, d, e):
7417  *     return PyArray_MultiIterNew(5, <void*>a, <void*>b, <void*>c, <void*> d, <void*> e)             # <<<<<<<<<<<<<<
7418  *
7419  * cdef inline tuple PyDataType_SHAPE(dtype d):
7420  */
7421   __Pyx_XDECREF(__pyx_r);
7422   __pyx_t_1 = PyArray_MultiIterNew(5, ((void *)__pyx_v_a), ((void *)__pyx_v_b), ((void *)__pyx_v_c), ((void *)__pyx_v_d), ((void *)__pyx_v_e)); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 747, __pyx_L1_error)
7423   __Pyx_GOTREF(__pyx_t_1);
7424   __pyx_r = __pyx_t_1;
7425   __pyx_t_1 = 0;
7426   goto __pyx_L0;
7427 
7428   /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":746
7429  *     return PyArray_MultiIterNew(4, <void*>a, <void*>b, <void*>c, <void*> d)
7430  *
7431  * cdef inline object PyArray_MultiIterNew5(a, b, c, d, e):             # <<<<<<<<<<<<<<
7432  *     return PyArray_MultiIterNew(5, <void*>a, <void*>b, <void*>c, <void*> d, <void*> e)
7433  *
7434  */
7435 
7436   /* function exit code */
7437   __pyx_L1_error:;
7438   __Pyx_XDECREF(__pyx_t_1);
7439   __Pyx_AddTraceback("numpy.PyArray_MultiIterNew5", __pyx_clineno, __pyx_lineno, __pyx_filename);
7440   __pyx_r = 0;
7441   __pyx_L0:;
7442   __Pyx_XGIVEREF(__pyx_r);
7443   __Pyx_RefNannyFinishContext();
7444   return __pyx_r;
7445 }
7446 
7447 /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":749
7448  *     return PyArray_MultiIterNew(5, <void*>a, <void*>b, <void*>c, <void*> d, <void*> e)
7449  *
7450  * cdef inline tuple PyDataType_SHAPE(dtype d):             # <<<<<<<<<<<<<<
7451  *     if PyDataType_HASSUBARRAY(d):
7452  *         return <tuple>d.subarray.shape
7453  */
7454 
__pyx_f_5numpy_PyDataType_SHAPE(PyArray_Descr * __pyx_v_d)7455 static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyDataType_SHAPE(PyArray_Descr *__pyx_v_d) {
7456   PyObject *__pyx_r = NULL;
7457   __Pyx_RefNannyDeclarations
7458   int __pyx_t_1;
7459   __Pyx_RefNannySetupContext("PyDataType_SHAPE", 0);
7460 
7461   /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":750
7462  *
7463  * cdef inline tuple PyDataType_SHAPE(dtype d):
7464  *     if PyDataType_HASSUBARRAY(d):             # <<<<<<<<<<<<<<
7465  *         return <tuple>d.subarray.shape
7466  *     else:
7467  */
7468   __pyx_t_1 = (PyDataType_HASSUBARRAY(__pyx_v_d) != 0);
7469   if (__pyx_t_1) {
7470 
7471     /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":751
7472  * cdef inline tuple PyDataType_SHAPE(dtype d):
7473  *     if PyDataType_HASSUBARRAY(d):
7474  *         return <tuple>d.subarray.shape             # <<<<<<<<<<<<<<
7475  *     else:
7476  *         return ()
7477  */
7478     __Pyx_XDECREF(__pyx_r);
7479     __Pyx_INCREF(((PyObject*)__pyx_v_d->subarray->shape));
7480     __pyx_r = ((PyObject*)__pyx_v_d->subarray->shape);
7481     goto __pyx_L0;
7482 
7483     /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":750
7484  *
7485  * cdef inline tuple PyDataType_SHAPE(dtype d):
7486  *     if PyDataType_HASSUBARRAY(d):             # <<<<<<<<<<<<<<
7487  *         return <tuple>d.subarray.shape
7488  *     else:
7489  */
7490   }
7491 
7492   /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":753
7493  *         return <tuple>d.subarray.shape
7494  *     else:
7495  *         return ()             # <<<<<<<<<<<<<<
7496  *
7497  *
7498  */
7499   /*else*/ {
7500     __Pyx_XDECREF(__pyx_r);
7501     __Pyx_INCREF(__pyx_empty_tuple);
7502     __pyx_r = __pyx_empty_tuple;
7503     goto __pyx_L0;
7504   }
7505 
7506   /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":749
7507  *     return PyArray_MultiIterNew(5, <void*>a, <void*>b, <void*>c, <void*> d, <void*> e)
7508  *
7509  * cdef inline tuple PyDataType_SHAPE(dtype d):             # <<<<<<<<<<<<<<
7510  *     if PyDataType_HASSUBARRAY(d):
7511  *         return <tuple>d.subarray.shape
7512  */
7513 
7514   /* function exit code */
7515   __pyx_L0:;
7516   __Pyx_XGIVEREF(__pyx_r);
7517   __Pyx_RefNannyFinishContext();
7518   return __pyx_r;
7519 }
7520 
7521 /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":868
7522  *     int _import_umath() except -1
7523  *
7524  * cdef inline void set_array_base(ndarray arr, object base):             # <<<<<<<<<<<<<<
7525  *     Py_INCREF(base) # important to do this before stealing the reference below!
7526  *     PyArray_SetBaseObject(arr, base)
7527  */
7528 
__pyx_f_5numpy_set_array_base(PyArrayObject * __pyx_v_arr,PyObject * __pyx_v_base)7529 static CYTHON_INLINE void __pyx_f_5numpy_set_array_base(PyArrayObject *__pyx_v_arr, PyObject *__pyx_v_base) {
7530   __Pyx_RefNannyDeclarations
7531   __Pyx_RefNannySetupContext("set_array_base", 0);
7532 
7533   /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":869
7534  *
7535  * cdef inline void set_array_base(ndarray arr, object base):
7536  *     Py_INCREF(base) # important to do this before stealing the reference below!             # <<<<<<<<<<<<<<
7537  *     PyArray_SetBaseObject(arr, base)
7538  *
7539  */
7540   Py_INCREF(__pyx_v_base);
7541 
7542   /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":870
7543  * cdef inline void set_array_base(ndarray arr, object base):
7544  *     Py_INCREF(base) # important to do this before stealing the reference below!
7545  *     PyArray_SetBaseObject(arr, base)             # <<<<<<<<<<<<<<
7546  *
7547  * cdef inline object get_array_base(ndarray arr):
7548  */
7549   (void)(PyArray_SetBaseObject(__pyx_v_arr, __pyx_v_base));
7550 
7551   /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":868
7552  *     int _import_umath() except -1
7553  *
7554  * cdef inline void set_array_base(ndarray arr, object base):             # <<<<<<<<<<<<<<
7555  *     Py_INCREF(base) # important to do this before stealing the reference below!
7556  *     PyArray_SetBaseObject(arr, base)
7557  */
7558 
7559   /* function exit code */
7560   __Pyx_RefNannyFinishContext();
7561 }
7562 
7563 /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":872
7564  *     PyArray_SetBaseObject(arr, base)
7565  *
7566  * cdef inline object get_array_base(ndarray arr):             # <<<<<<<<<<<<<<
7567  *     base = PyArray_BASE(arr)
7568  *     if base is NULL:
7569  */
7570 
__pyx_f_5numpy_get_array_base(PyArrayObject * __pyx_v_arr)7571 static CYTHON_INLINE PyObject *__pyx_f_5numpy_get_array_base(PyArrayObject *__pyx_v_arr) {
7572   PyObject *__pyx_v_base;
7573   PyObject *__pyx_r = NULL;
7574   __Pyx_RefNannyDeclarations
7575   int __pyx_t_1;
7576   __Pyx_RefNannySetupContext("get_array_base", 0);
7577 
7578   /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":873
7579  *
7580  * cdef inline object get_array_base(ndarray arr):
7581  *     base = PyArray_BASE(arr)             # <<<<<<<<<<<<<<
7582  *     if base is NULL:
7583  *         return None
7584  */
7585   __pyx_v_base = PyArray_BASE(__pyx_v_arr);
7586 
7587   /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":874
7588  * cdef inline object get_array_base(ndarray arr):
7589  *     base = PyArray_BASE(arr)
7590  *     if base is NULL:             # <<<<<<<<<<<<<<
7591  *         return None
7592  *     return <object>base
7593  */
7594   __pyx_t_1 = ((__pyx_v_base == NULL) != 0);
7595   if (__pyx_t_1) {
7596 
7597     /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":875
7598  *     base = PyArray_BASE(arr)
7599  *     if base is NULL:
7600  *         return None             # <<<<<<<<<<<<<<
7601  *     return <object>base
7602  *
7603  */
7604     __Pyx_XDECREF(__pyx_r);
7605     __pyx_r = Py_None; __Pyx_INCREF(Py_None);
7606     goto __pyx_L0;
7607 
7608     /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":874
7609  * cdef inline object get_array_base(ndarray arr):
7610  *     base = PyArray_BASE(arr)
7611  *     if base is NULL:             # <<<<<<<<<<<<<<
7612  *         return None
7613  *     return <object>base
7614  */
7615   }
7616 
7617   /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":876
7618  *     if base is NULL:
7619  *         return None
7620  *     return <object>base             # <<<<<<<<<<<<<<
7621  *
7622  * # Versions of the import_* functions which are more suitable for
7623  */
7624   __Pyx_XDECREF(__pyx_r);
7625   __Pyx_INCREF(((PyObject *)__pyx_v_base));
7626   __pyx_r = ((PyObject *)__pyx_v_base);
7627   goto __pyx_L0;
7628 
7629   /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":872
7630  *     PyArray_SetBaseObject(arr, base)
7631  *
7632  * cdef inline object get_array_base(ndarray arr):             # <<<<<<<<<<<<<<
7633  *     base = PyArray_BASE(arr)
7634  *     if base is NULL:
7635  */
7636 
7637   /* function exit code */
7638   __pyx_L0:;
7639   __Pyx_XGIVEREF(__pyx_r);
7640   __Pyx_RefNannyFinishContext();
7641   return __pyx_r;
7642 }
7643 
7644 /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":880
7645  * # Versions of the import_* functions which are more suitable for
7646  * # Cython code.
7647  * cdef inline int import_array() except -1:             # <<<<<<<<<<<<<<
7648  *     try:
7649  *         __pyx_import_array()
7650  */
7651 
__pyx_f_5numpy_import_array(void)7652 static CYTHON_INLINE int __pyx_f_5numpy_import_array(void) {
7653   int __pyx_r;
7654   __Pyx_RefNannyDeclarations
7655   PyObject *__pyx_t_1 = NULL;
7656   PyObject *__pyx_t_2 = NULL;
7657   PyObject *__pyx_t_3 = NULL;
7658   int __pyx_t_4;
7659   PyObject *__pyx_t_5 = NULL;
7660   PyObject *__pyx_t_6 = NULL;
7661   PyObject *__pyx_t_7 = NULL;
7662   PyObject *__pyx_t_8 = NULL;
7663   int __pyx_lineno = 0;
7664   const char *__pyx_filename = NULL;
7665   int __pyx_clineno = 0;
7666   __Pyx_RefNannySetupContext("import_array", 0);
7667 
7668   /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":881
7669  * # Cython code.
7670  * cdef inline int import_array() except -1:
7671  *     try:             # <<<<<<<<<<<<<<
7672  *         __pyx_import_array()
7673  *     except Exception:
7674  */
7675   {
7676     __Pyx_PyThreadState_declare
7677     __Pyx_PyThreadState_assign
7678     __Pyx_ExceptionSave(&__pyx_t_1, &__pyx_t_2, &__pyx_t_3);
7679     __Pyx_XGOTREF(__pyx_t_1);
7680     __Pyx_XGOTREF(__pyx_t_2);
7681     __Pyx_XGOTREF(__pyx_t_3);
7682     /*try:*/ {
7683 
7684       /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":882
7685  * cdef inline int import_array() except -1:
7686  *     try:
7687  *         __pyx_import_array()             # <<<<<<<<<<<<<<
7688  *     except Exception:
7689  *         raise ImportError("numpy.core.multiarray failed to import")
7690  */
7691       __pyx_t_4 = _import_array(); if (unlikely(__pyx_t_4 == ((int)-1))) __PYX_ERR(1, 882, __pyx_L3_error)
7692 
7693       /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":881
7694  * # Cython code.
7695  * cdef inline int import_array() except -1:
7696  *     try:             # <<<<<<<<<<<<<<
7697  *         __pyx_import_array()
7698  *     except Exception:
7699  */
7700     }
7701     __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
7702     __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
7703     __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
7704     goto __pyx_L8_try_end;
7705     __pyx_L3_error:;
7706 
7707     /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":883
7708  *     try:
7709  *         __pyx_import_array()
7710  *     except Exception:             # <<<<<<<<<<<<<<
7711  *         raise ImportError("numpy.core.multiarray failed to import")
7712  *
7713  */
7714     __pyx_t_4 = __Pyx_PyErr_ExceptionMatches(((PyObject *)(&((PyTypeObject*)PyExc_Exception)[0])));
7715     if (__pyx_t_4) {
7716       __Pyx_AddTraceback("numpy.import_array", __pyx_clineno, __pyx_lineno, __pyx_filename);
7717       if (__Pyx_GetException(&__pyx_t_5, &__pyx_t_6, &__pyx_t_7) < 0) __PYX_ERR(1, 883, __pyx_L5_except_error)
7718       __Pyx_GOTREF(__pyx_t_5);
7719       __Pyx_GOTREF(__pyx_t_6);
7720       __Pyx_GOTREF(__pyx_t_7);
7721 
7722       /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":884
7723  *         __pyx_import_array()
7724  *     except Exception:
7725  *         raise ImportError("numpy.core.multiarray failed to import")             # <<<<<<<<<<<<<<
7726  *
7727  * cdef inline int import_umath() except -1:
7728  */
7729       __pyx_t_8 = __Pyx_PyObject_Call(__pyx_builtin_ImportError, __pyx_tuple__4, NULL); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 884, __pyx_L5_except_error)
7730       __Pyx_GOTREF(__pyx_t_8);
7731       __Pyx_Raise(__pyx_t_8, 0, 0, 0);
7732       __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
7733       __PYX_ERR(1, 884, __pyx_L5_except_error)
7734     }
7735     goto __pyx_L5_except_error;
7736     __pyx_L5_except_error:;
7737 
7738     /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":881
7739  * # Cython code.
7740  * cdef inline int import_array() except -1:
7741  *     try:             # <<<<<<<<<<<<<<
7742  *         __pyx_import_array()
7743  *     except Exception:
7744  */
7745     __Pyx_XGIVEREF(__pyx_t_1);
7746     __Pyx_XGIVEREF(__pyx_t_2);
7747     __Pyx_XGIVEREF(__pyx_t_3);
7748     __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3);
7749     goto __pyx_L1_error;
7750     __pyx_L8_try_end:;
7751   }
7752 
7753   /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":880
7754  * # Versions of the import_* functions which are more suitable for
7755  * # Cython code.
7756  * cdef inline int import_array() except -1:             # <<<<<<<<<<<<<<
7757  *     try:
7758  *         __pyx_import_array()
7759  */
7760 
7761   /* function exit code */
7762   __pyx_r = 0;
7763   goto __pyx_L0;
7764   __pyx_L1_error:;
7765   __Pyx_XDECREF(__pyx_t_5);
7766   __Pyx_XDECREF(__pyx_t_6);
7767   __Pyx_XDECREF(__pyx_t_7);
7768   __Pyx_XDECREF(__pyx_t_8);
7769   __Pyx_AddTraceback("numpy.import_array", __pyx_clineno, __pyx_lineno, __pyx_filename);
7770   __pyx_r = -1;
7771   __pyx_L0:;
7772   __Pyx_RefNannyFinishContext();
7773   return __pyx_r;
7774 }
7775 
7776 /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":886
7777  *         raise ImportError("numpy.core.multiarray failed to import")
7778  *
7779  * cdef inline int import_umath() except -1:             # <<<<<<<<<<<<<<
7780  *     try:
7781  *         _import_umath()
7782  */
7783 
__pyx_f_5numpy_import_umath(void)7784 static CYTHON_INLINE int __pyx_f_5numpy_import_umath(void) {
7785   int __pyx_r;
7786   __Pyx_RefNannyDeclarations
7787   PyObject *__pyx_t_1 = NULL;
7788   PyObject *__pyx_t_2 = NULL;
7789   PyObject *__pyx_t_3 = NULL;
7790   int __pyx_t_4;
7791   PyObject *__pyx_t_5 = NULL;
7792   PyObject *__pyx_t_6 = NULL;
7793   PyObject *__pyx_t_7 = NULL;
7794   PyObject *__pyx_t_8 = NULL;
7795   int __pyx_lineno = 0;
7796   const char *__pyx_filename = NULL;
7797   int __pyx_clineno = 0;
7798   __Pyx_RefNannySetupContext("import_umath", 0);
7799 
7800   /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":887
7801  *
7802  * cdef inline int import_umath() except -1:
7803  *     try:             # <<<<<<<<<<<<<<
7804  *         _import_umath()
7805  *     except Exception:
7806  */
7807   {
7808     __Pyx_PyThreadState_declare
7809     __Pyx_PyThreadState_assign
7810     __Pyx_ExceptionSave(&__pyx_t_1, &__pyx_t_2, &__pyx_t_3);
7811     __Pyx_XGOTREF(__pyx_t_1);
7812     __Pyx_XGOTREF(__pyx_t_2);
7813     __Pyx_XGOTREF(__pyx_t_3);
7814     /*try:*/ {
7815 
7816       /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":888
7817  * cdef inline int import_umath() except -1:
7818  *     try:
7819  *         _import_umath()             # <<<<<<<<<<<<<<
7820  *     except Exception:
7821  *         raise ImportError("numpy.core.umath failed to import")
7822  */
7823       __pyx_t_4 = _import_umath(); if (unlikely(__pyx_t_4 == ((int)-1))) __PYX_ERR(1, 888, __pyx_L3_error)
7824 
7825       /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":887
7826  *
7827  * cdef inline int import_umath() except -1:
7828  *     try:             # <<<<<<<<<<<<<<
7829  *         _import_umath()
7830  *     except Exception:
7831  */
7832     }
7833     __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
7834     __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
7835     __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
7836     goto __pyx_L8_try_end;
7837     __pyx_L3_error:;
7838 
7839     /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":889
7840  *     try:
7841  *         _import_umath()
7842  *     except Exception:             # <<<<<<<<<<<<<<
7843  *         raise ImportError("numpy.core.umath failed to import")
7844  *
7845  */
7846     __pyx_t_4 = __Pyx_PyErr_ExceptionMatches(((PyObject *)(&((PyTypeObject*)PyExc_Exception)[0])));
7847     if (__pyx_t_4) {
7848       __Pyx_AddTraceback("numpy.import_umath", __pyx_clineno, __pyx_lineno, __pyx_filename);
7849       if (__Pyx_GetException(&__pyx_t_5, &__pyx_t_6, &__pyx_t_7) < 0) __PYX_ERR(1, 889, __pyx_L5_except_error)
7850       __Pyx_GOTREF(__pyx_t_5);
7851       __Pyx_GOTREF(__pyx_t_6);
7852       __Pyx_GOTREF(__pyx_t_7);
7853 
7854       /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":890
7855  *         _import_umath()
7856  *     except Exception:
7857  *         raise ImportError("numpy.core.umath failed to import")             # <<<<<<<<<<<<<<
7858  *
7859  * cdef inline int import_ufunc() except -1:
7860  */
7861       __pyx_t_8 = __Pyx_PyObject_Call(__pyx_builtin_ImportError, __pyx_tuple__5, NULL); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 890, __pyx_L5_except_error)
7862       __Pyx_GOTREF(__pyx_t_8);
7863       __Pyx_Raise(__pyx_t_8, 0, 0, 0);
7864       __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
7865       __PYX_ERR(1, 890, __pyx_L5_except_error)
7866     }
7867     goto __pyx_L5_except_error;
7868     __pyx_L5_except_error:;
7869 
7870     /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":887
7871  *
7872  * cdef inline int import_umath() except -1:
7873  *     try:             # <<<<<<<<<<<<<<
7874  *         _import_umath()
7875  *     except Exception:
7876  */
7877     __Pyx_XGIVEREF(__pyx_t_1);
7878     __Pyx_XGIVEREF(__pyx_t_2);
7879     __Pyx_XGIVEREF(__pyx_t_3);
7880     __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3);
7881     goto __pyx_L1_error;
7882     __pyx_L8_try_end:;
7883   }
7884 
7885   /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":886
7886  *         raise ImportError("numpy.core.multiarray failed to import")
7887  *
7888  * cdef inline int import_umath() except -1:             # <<<<<<<<<<<<<<
7889  *     try:
7890  *         _import_umath()
7891  */
7892 
7893   /* function exit code */
7894   __pyx_r = 0;
7895   goto __pyx_L0;
7896   __pyx_L1_error:;
7897   __Pyx_XDECREF(__pyx_t_5);
7898   __Pyx_XDECREF(__pyx_t_6);
7899   __Pyx_XDECREF(__pyx_t_7);
7900   __Pyx_XDECREF(__pyx_t_8);
7901   __Pyx_AddTraceback("numpy.import_umath", __pyx_clineno, __pyx_lineno, __pyx_filename);
7902   __pyx_r = -1;
7903   __pyx_L0:;
7904   __Pyx_RefNannyFinishContext();
7905   return __pyx_r;
7906 }
7907 
7908 /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":892
7909  *         raise ImportError("numpy.core.umath failed to import")
7910  *
7911  * cdef inline int import_ufunc() except -1:             # <<<<<<<<<<<<<<
7912  *     try:
7913  *         _import_umath()
7914  */
7915 
__pyx_f_5numpy_import_ufunc(void)7916 static CYTHON_INLINE int __pyx_f_5numpy_import_ufunc(void) {
7917   int __pyx_r;
7918   __Pyx_RefNannyDeclarations
7919   PyObject *__pyx_t_1 = NULL;
7920   PyObject *__pyx_t_2 = NULL;
7921   PyObject *__pyx_t_3 = NULL;
7922   int __pyx_t_4;
7923   PyObject *__pyx_t_5 = NULL;
7924   PyObject *__pyx_t_6 = NULL;
7925   PyObject *__pyx_t_7 = NULL;
7926   PyObject *__pyx_t_8 = NULL;
7927   int __pyx_lineno = 0;
7928   const char *__pyx_filename = NULL;
7929   int __pyx_clineno = 0;
7930   __Pyx_RefNannySetupContext("import_ufunc", 0);
7931 
7932   /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":893
7933  *
7934  * cdef inline int import_ufunc() except -1:
7935  *     try:             # <<<<<<<<<<<<<<
7936  *         _import_umath()
7937  *     except Exception:
7938  */
7939   {
7940     __Pyx_PyThreadState_declare
7941     __Pyx_PyThreadState_assign
7942     __Pyx_ExceptionSave(&__pyx_t_1, &__pyx_t_2, &__pyx_t_3);
7943     __Pyx_XGOTREF(__pyx_t_1);
7944     __Pyx_XGOTREF(__pyx_t_2);
7945     __Pyx_XGOTREF(__pyx_t_3);
7946     /*try:*/ {
7947 
7948       /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":894
7949  * cdef inline int import_ufunc() except -1:
7950  *     try:
7951  *         _import_umath()             # <<<<<<<<<<<<<<
7952  *     except Exception:
7953  *         raise ImportError("numpy.core.umath failed to import")
7954  */
7955       __pyx_t_4 = _import_umath(); if (unlikely(__pyx_t_4 == ((int)-1))) __PYX_ERR(1, 894, __pyx_L3_error)
7956 
7957       /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":893
7958  *
7959  * cdef inline int import_ufunc() except -1:
7960  *     try:             # <<<<<<<<<<<<<<
7961  *         _import_umath()
7962  *     except Exception:
7963  */
7964     }
7965     __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
7966     __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
7967     __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
7968     goto __pyx_L8_try_end;
7969     __pyx_L3_error:;
7970 
7971     /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":895
7972  *     try:
7973  *         _import_umath()
7974  *     except Exception:             # <<<<<<<<<<<<<<
7975  *         raise ImportError("numpy.core.umath failed to import")
7976  *
7977  */
7978     __pyx_t_4 = __Pyx_PyErr_ExceptionMatches(((PyObject *)(&((PyTypeObject*)PyExc_Exception)[0])));
7979     if (__pyx_t_4) {
7980       __Pyx_AddTraceback("numpy.import_ufunc", __pyx_clineno, __pyx_lineno, __pyx_filename);
7981       if (__Pyx_GetException(&__pyx_t_5, &__pyx_t_6, &__pyx_t_7) < 0) __PYX_ERR(1, 895, __pyx_L5_except_error)
7982       __Pyx_GOTREF(__pyx_t_5);
7983       __Pyx_GOTREF(__pyx_t_6);
7984       __Pyx_GOTREF(__pyx_t_7);
7985 
7986       /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":896
7987  *         _import_umath()
7988  *     except Exception:
7989  *         raise ImportError("numpy.core.umath failed to import")             # <<<<<<<<<<<<<<
7990  *
7991  * cdef extern from *:
7992  */
7993       __pyx_t_8 = __Pyx_PyObject_Call(__pyx_builtin_ImportError, __pyx_tuple__5, NULL); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 896, __pyx_L5_except_error)
7994       __Pyx_GOTREF(__pyx_t_8);
7995       __Pyx_Raise(__pyx_t_8, 0, 0, 0);
7996       __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
7997       __PYX_ERR(1, 896, __pyx_L5_except_error)
7998     }
7999     goto __pyx_L5_except_error;
8000     __pyx_L5_except_error:;
8001 
8002     /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":893
8003  *
8004  * cdef inline int import_ufunc() except -1:
8005  *     try:             # <<<<<<<<<<<<<<
8006  *         _import_umath()
8007  *     except Exception:
8008  */
8009     __Pyx_XGIVEREF(__pyx_t_1);
8010     __Pyx_XGIVEREF(__pyx_t_2);
8011     __Pyx_XGIVEREF(__pyx_t_3);
8012     __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3);
8013     goto __pyx_L1_error;
8014     __pyx_L8_try_end:;
8015   }
8016 
8017   /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":892
8018  *         raise ImportError("numpy.core.umath failed to import")
8019  *
8020  * cdef inline int import_ufunc() except -1:             # <<<<<<<<<<<<<<
8021  *     try:
8022  *         _import_umath()
8023  */
8024 
8025   /* function exit code */
8026   __pyx_r = 0;
8027   goto __pyx_L0;
8028   __pyx_L1_error:;
8029   __Pyx_XDECREF(__pyx_t_5);
8030   __Pyx_XDECREF(__pyx_t_6);
8031   __Pyx_XDECREF(__pyx_t_7);
8032   __Pyx_XDECREF(__pyx_t_8);
8033   __Pyx_AddTraceback("numpy.import_ufunc", __pyx_clineno, __pyx_lineno, __pyx_filename);
8034   __pyx_r = -1;
8035   __pyx_L0:;
8036   __Pyx_RefNannyFinishContext();
8037   return __pyx_r;
8038 }
8039 
8040 /* "View.MemoryView":122
8041  *         cdef bint dtype_is_object
8042  *
8043  *     def __cinit__(array self, tuple shape, Py_ssize_t itemsize, format not None,             # <<<<<<<<<<<<<<
8044  *                   mode="c", bint allocate_buffer=True):
8045  *
8046  */
8047 
8048 /* Python wrapper */
8049 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)8050 static int __pyx_array___cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
8051   PyObject *__pyx_v_shape = 0;
8052   Py_ssize_t __pyx_v_itemsize;
8053   PyObject *__pyx_v_format = 0;
8054   PyObject *__pyx_v_mode = 0;
8055   int __pyx_v_allocate_buffer;
8056   int __pyx_lineno = 0;
8057   const char *__pyx_filename = NULL;
8058   int __pyx_clineno = 0;
8059   int __pyx_r;
8060   __Pyx_RefNannyDeclarations
8061   __Pyx_RefNannySetupContext("__cinit__ (wrapper)", 0);
8062   {
8063     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};
8064     PyObject* values[5] = {0,0,0,0,0};
8065     values[3] = ((PyObject *)__pyx_n_s_c);
8066     if (unlikely(__pyx_kwds)) {
8067       Py_ssize_t kw_args;
8068       const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
8069       switch (pos_args) {
8070         case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
8071         CYTHON_FALLTHROUGH;
8072         case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
8073         CYTHON_FALLTHROUGH;
8074         case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
8075         CYTHON_FALLTHROUGH;
8076         case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
8077         CYTHON_FALLTHROUGH;
8078         case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
8079         CYTHON_FALLTHROUGH;
8080         case  0: break;
8081         default: goto __pyx_L5_argtuple_error;
8082       }
8083       kw_args = PyDict_Size(__pyx_kwds);
8084       switch (pos_args) {
8085         case  0:
8086         if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_shape)) != 0)) kw_args--;
8087         else goto __pyx_L5_argtuple_error;
8088         CYTHON_FALLTHROUGH;
8089         case  1:
8090         if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_itemsize)) != 0)) kw_args--;
8091         else {
8092           __Pyx_RaiseArgtupleInvalid("__cinit__", 0, 3, 5, 1); __PYX_ERR(2, 122, __pyx_L3_error)
8093         }
8094         CYTHON_FALLTHROUGH;
8095         case  2:
8096         if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_format)) != 0)) kw_args--;
8097         else {
8098           __Pyx_RaiseArgtupleInvalid("__cinit__", 0, 3, 5, 2); __PYX_ERR(2, 122, __pyx_L3_error)
8099         }
8100         CYTHON_FALLTHROUGH;
8101         case  3:
8102         if (kw_args > 0) {
8103           PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_mode);
8104           if (value) { values[3] = value; kw_args--; }
8105         }
8106         CYTHON_FALLTHROUGH;
8107         case  4:
8108         if (kw_args > 0) {
8109           PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_allocate_buffer);
8110           if (value) { values[4] = value; kw_args--; }
8111         }
8112       }
8113       if (unlikely(kw_args > 0)) {
8114         if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__cinit__") < 0)) __PYX_ERR(2, 122, __pyx_L3_error)
8115       }
8116     } else {
8117       switch (PyTuple_GET_SIZE(__pyx_args)) {
8118         case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
8119         CYTHON_FALLTHROUGH;
8120         case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
8121         CYTHON_FALLTHROUGH;
8122         case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
8123         values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
8124         values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
8125         break;
8126         default: goto __pyx_L5_argtuple_error;
8127       }
8128     }
8129     __pyx_v_shape = ((PyObject*)values[0]);
8130     __pyx_v_itemsize = __Pyx_PyIndex_AsSsize_t(values[1]); if (unlikely((__pyx_v_itemsize == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(2, 122, __pyx_L3_error)
8131     __pyx_v_format = values[2];
8132     __pyx_v_mode = values[3];
8133     if (values[4]) {
8134       __pyx_v_allocate_buffer = __Pyx_PyObject_IsTrue(values[4]); if (unlikely((__pyx_v_allocate_buffer == (int)-1) && PyErr_Occurred())) __PYX_ERR(2, 123, __pyx_L3_error)
8135     } else {
8136 
8137       /* "View.MemoryView":123
8138  *
8139  *     def __cinit__(array self, tuple shape, Py_ssize_t itemsize, format not None,
8140  *                   mode="c", bint allocate_buffer=True):             # <<<<<<<<<<<<<<
8141  *
8142  *         cdef int idx
8143  */
8144       __pyx_v_allocate_buffer = ((int)1);
8145     }
8146   }
8147   goto __pyx_L4_argument_unpacking_done;
8148   __pyx_L5_argtuple_error:;
8149   __Pyx_RaiseArgtupleInvalid("__cinit__", 0, 3, 5, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(2, 122, __pyx_L3_error)
8150   __pyx_L3_error:;
8151   __Pyx_AddTraceback("View.MemoryView.array.__cinit__", __pyx_clineno, __pyx_lineno, __pyx_filename);
8152   __Pyx_RefNannyFinishContext();
8153   return -1;
8154   __pyx_L4_argument_unpacking_done:;
8155   if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_shape), (&PyTuple_Type), 1, "shape", 1))) __PYX_ERR(2, 122, __pyx_L1_error)
8156   if (unlikely(((PyObject *)__pyx_v_format) == Py_None)) {
8157     PyErr_Format(PyExc_TypeError, "Argument '%.200s' must not be None", "format"); __PYX_ERR(2, 122, __pyx_L1_error)
8158   }
8159   __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);
8160 
8161   /* "View.MemoryView":122
8162  *         cdef bint dtype_is_object
8163  *
8164  *     def __cinit__(array self, tuple shape, Py_ssize_t itemsize, format not None,             # <<<<<<<<<<<<<<
8165  *                   mode="c", bint allocate_buffer=True):
8166  *
8167  */
8168 
8169   /* function exit code */
8170   goto __pyx_L0;
8171   __pyx_L1_error:;
8172   __pyx_r = -1;
8173   __pyx_L0:;
8174   __Pyx_RefNannyFinishContext();
8175   return __pyx_r;
8176 }
8177 
__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)8178 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) {
8179   int __pyx_v_idx;
8180   Py_ssize_t __pyx_v_i;
8181   Py_ssize_t __pyx_v_dim;
8182   PyObject **__pyx_v_p;
8183   char __pyx_v_order;
8184   int __pyx_r;
8185   __Pyx_RefNannyDeclarations
8186   Py_ssize_t __pyx_t_1;
8187   int __pyx_t_2;
8188   PyObject *__pyx_t_3 = NULL;
8189   int __pyx_t_4;
8190   PyObject *__pyx_t_5 = NULL;
8191   PyObject *__pyx_t_6 = NULL;
8192   char *__pyx_t_7;
8193   int __pyx_t_8;
8194   Py_ssize_t __pyx_t_9;
8195   PyObject *__pyx_t_10 = NULL;
8196   Py_ssize_t __pyx_t_11;
8197   int __pyx_lineno = 0;
8198   const char *__pyx_filename = NULL;
8199   int __pyx_clineno = 0;
8200   __Pyx_RefNannySetupContext("__cinit__", 0);
8201   __Pyx_INCREF(__pyx_v_format);
8202 
8203   /* "View.MemoryView":129
8204  *         cdef PyObject **p
8205  *
8206  *         self.ndim = <int> len(shape)             # <<<<<<<<<<<<<<
8207  *         self.itemsize = itemsize
8208  *
8209  */
8210   if (unlikely(__pyx_v_shape == Py_None)) {
8211     PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
8212     __PYX_ERR(2, 129, __pyx_L1_error)
8213   }
8214   __pyx_t_1 = PyTuple_GET_SIZE(__pyx_v_shape); if (unlikely(__pyx_t_1 == ((Py_ssize_t)-1))) __PYX_ERR(2, 129, __pyx_L1_error)
8215   __pyx_v_self->ndim = ((int)__pyx_t_1);
8216 
8217   /* "View.MemoryView":130
8218  *
8219  *         self.ndim = <int> len(shape)
8220  *         self.itemsize = itemsize             # <<<<<<<<<<<<<<
8221  *
8222  *         if not self.ndim:
8223  */
8224   __pyx_v_self->itemsize = __pyx_v_itemsize;
8225 
8226   /* "View.MemoryView":132
8227  *         self.itemsize = itemsize
8228  *
8229  *         if not self.ndim:             # <<<<<<<<<<<<<<
8230  *             raise ValueError("Empty shape tuple for cython.array")
8231  *
8232  */
8233   __pyx_t_2 = ((!(__pyx_v_self->ndim != 0)) != 0);
8234   if (unlikely(__pyx_t_2)) {
8235 
8236     /* "View.MemoryView":133
8237  *
8238  *         if not self.ndim:
8239  *             raise ValueError("Empty shape tuple for cython.array")             # <<<<<<<<<<<<<<
8240  *
8241  *         if itemsize <= 0:
8242  */
8243     __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__6, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 133, __pyx_L1_error)
8244     __Pyx_GOTREF(__pyx_t_3);
8245     __Pyx_Raise(__pyx_t_3, 0, 0, 0);
8246     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
8247     __PYX_ERR(2, 133, __pyx_L1_error)
8248 
8249     /* "View.MemoryView":132
8250  *         self.itemsize = itemsize
8251  *
8252  *         if not self.ndim:             # <<<<<<<<<<<<<<
8253  *             raise ValueError("Empty shape tuple for cython.array")
8254  *
8255  */
8256   }
8257 
8258   /* "View.MemoryView":135
8259  *             raise ValueError("Empty shape tuple for cython.array")
8260  *
8261  *         if itemsize <= 0:             # <<<<<<<<<<<<<<
8262  *             raise ValueError("itemsize <= 0 for cython.array")
8263  *
8264  */
8265   __pyx_t_2 = ((__pyx_v_itemsize <= 0) != 0);
8266   if (unlikely(__pyx_t_2)) {
8267 
8268     /* "View.MemoryView":136
8269  *
8270  *         if itemsize <= 0:
8271  *             raise ValueError("itemsize <= 0 for cython.array")             # <<<<<<<<<<<<<<
8272  *
8273  *         if not isinstance(format, bytes):
8274  */
8275     __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__7, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 136, __pyx_L1_error)
8276     __Pyx_GOTREF(__pyx_t_3);
8277     __Pyx_Raise(__pyx_t_3, 0, 0, 0);
8278     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
8279     __PYX_ERR(2, 136, __pyx_L1_error)
8280 
8281     /* "View.MemoryView":135
8282  *             raise ValueError("Empty shape tuple for cython.array")
8283  *
8284  *         if itemsize <= 0:             # <<<<<<<<<<<<<<
8285  *             raise ValueError("itemsize <= 0 for cython.array")
8286  *
8287  */
8288   }
8289 
8290   /* "View.MemoryView":138
8291  *             raise ValueError("itemsize <= 0 for cython.array")
8292  *
8293  *         if not isinstance(format, bytes):             # <<<<<<<<<<<<<<
8294  *             format = format.encode('ASCII')
8295  *         self._format = format  # keep a reference to the byte string
8296  */
8297   __pyx_t_2 = PyBytes_Check(__pyx_v_format);
8298   __pyx_t_4 = ((!(__pyx_t_2 != 0)) != 0);
8299   if (__pyx_t_4) {
8300 
8301     /* "View.MemoryView":139
8302  *
8303  *         if not isinstance(format, bytes):
8304  *             format = format.encode('ASCII')             # <<<<<<<<<<<<<<
8305  *         self._format = format  # keep a reference to the byte string
8306  *         self.format = self._format
8307  */
8308     __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_format, __pyx_n_s_encode); if (unlikely(!__pyx_t_5)) __PYX_ERR(2, 139, __pyx_L1_error)
8309     __Pyx_GOTREF(__pyx_t_5);
8310     __pyx_t_6 = NULL;
8311     if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_5))) {
8312       __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_5);
8313       if (likely(__pyx_t_6)) {
8314         PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
8315         __Pyx_INCREF(__pyx_t_6);
8316         __Pyx_INCREF(function);
8317         __Pyx_DECREF_SET(__pyx_t_5, function);
8318       }
8319     }
8320     __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);
8321     __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
8322     if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 139, __pyx_L1_error)
8323     __Pyx_GOTREF(__pyx_t_3);
8324     __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
8325     __Pyx_DECREF_SET(__pyx_v_format, __pyx_t_3);
8326     __pyx_t_3 = 0;
8327 
8328     /* "View.MemoryView":138
8329  *             raise ValueError("itemsize <= 0 for cython.array")
8330  *
8331  *         if not isinstance(format, bytes):             # <<<<<<<<<<<<<<
8332  *             format = format.encode('ASCII')
8333  *         self._format = format  # keep a reference to the byte string
8334  */
8335   }
8336 
8337   /* "View.MemoryView":140
8338  *         if not isinstance(format, bytes):
8339  *             format = format.encode('ASCII')
8340  *         self._format = format  # keep a reference to the byte string             # <<<<<<<<<<<<<<
8341  *         self.format = self._format
8342  *
8343  */
8344   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(2, 140, __pyx_L1_error)
8345   __pyx_t_3 = __pyx_v_format;
8346   __Pyx_INCREF(__pyx_t_3);
8347   __Pyx_GIVEREF(__pyx_t_3);
8348   __Pyx_GOTREF(__pyx_v_self->_format);
8349   __Pyx_DECREF(__pyx_v_self->_format);
8350   __pyx_v_self->_format = ((PyObject*)__pyx_t_3);
8351   __pyx_t_3 = 0;
8352 
8353   /* "View.MemoryView":141
8354  *             format = format.encode('ASCII')
8355  *         self._format = format  # keep a reference to the byte string
8356  *         self.format = self._format             # <<<<<<<<<<<<<<
8357  *
8358  *
8359  */
8360   if (unlikely(__pyx_v_self->_format == Py_None)) {
8361     PyErr_SetString(PyExc_TypeError, "expected bytes, NoneType found");
8362     __PYX_ERR(2, 141, __pyx_L1_error)
8363   }
8364   __pyx_t_7 = __Pyx_PyBytes_AsWritableString(__pyx_v_self->_format); if (unlikely((!__pyx_t_7) && PyErr_Occurred())) __PYX_ERR(2, 141, __pyx_L1_error)
8365   __pyx_v_self->format = __pyx_t_7;
8366 
8367   /* "View.MemoryView":144
8368  *
8369  *
8370  *         self._shape = <Py_ssize_t *> PyObject_Malloc(sizeof(Py_ssize_t)*self.ndim*2)             # <<<<<<<<<<<<<<
8371  *         self._strides = self._shape + self.ndim
8372  *
8373  */
8374   __pyx_v_self->_shape = ((Py_ssize_t *)PyObject_Malloc((((sizeof(Py_ssize_t)) * __pyx_v_self->ndim) * 2)));
8375 
8376   /* "View.MemoryView":145
8377  *
8378  *         self._shape = <Py_ssize_t *> PyObject_Malloc(sizeof(Py_ssize_t)*self.ndim*2)
8379  *         self._strides = self._shape + self.ndim             # <<<<<<<<<<<<<<
8380  *
8381  *         if not self._shape:
8382  */
8383   __pyx_v_self->_strides = (__pyx_v_self->_shape + __pyx_v_self->ndim);
8384 
8385   /* "View.MemoryView":147
8386  *         self._strides = self._shape + self.ndim
8387  *
8388  *         if not self._shape:             # <<<<<<<<<<<<<<
8389  *             raise MemoryError("unable to allocate shape and strides.")
8390  *
8391  */
8392   __pyx_t_4 = ((!(__pyx_v_self->_shape != 0)) != 0);
8393   if (unlikely(__pyx_t_4)) {
8394 
8395     /* "View.MemoryView":148
8396  *
8397  *         if not self._shape:
8398  *             raise MemoryError("unable to allocate shape and strides.")             # <<<<<<<<<<<<<<
8399  *
8400  *
8401  */
8402     __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_MemoryError, __pyx_tuple__8, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 148, __pyx_L1_error)
8403     __Pyx_GOTREF(__pyx_t_3);
8404     __Pyx_Raise(__pyx_t_3, 0, 0, 0);
8405     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
8406     __PYX_ERR(2, 148, __pyx_L1_error)
8407 
8408     /* "View.MemoryView":147
8409  *         self._strides = self._shape + self.ndim
8410  *
8411  *         if not self._shape:             # <<<<<<<<<<<<<<
8412  *             raise MemoryError("unable to allocate shape and strides.")
8413  *
8414  */
8415   }
8416 
8417   /* "View.MemoryView":151
8418  *
8419  *
8420  *         for idx, dim in enumerate(shape):             # <<<<<<<<<<<<<<
8421  *             if dim <= 0:
8422  *                 raise ValueError("Invalid shape in axis %d: %d." % (idx, dim))
8423  */
8424   __pyx_t_8 = 0;
8425   __pyx_t_3 = __pyx_v_shape; __Pyx_INCREF(__pyx_t_3); __pyx_t_1 = 0;
8426   for (;;) {
8427     if (__pyx_t_1 >= PyTuple_GET_SIZE(__pyx_t_3)) break;
8428     #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
8429     __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(2, 151, __pyx_L1_error)
8430     #else
8431     __pyx_t_5 = PySequence_ITEM(__pyx_t_3, __pyx_t_1); __pyx_t_1++; if (unlikely(!__pyx_t_5)) __PYX_ERR(2, 151, __pyx_L1_error)
8432     __Pyx_GOTREF(__pyx_t_5);
8433     #endif
8434     __pyx_t_9 = __Pyx_PyIndex_AsSsize_t(__pyx_t_5); if (unlikely((__pyx_t_9 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(2, 151, __pyx_L1_error)
8435     __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
8436     __pyx_v_dim = __pyx_t_9;
8437     __pyx_v_idx = __pyx_t_8;
8438     __pyx_t_8 = (__pyx_t_8 + 1);
8439 
8440     /* "View.MemoryView":152
8441  *
8442  *         for idx, dim in enumerate(shape):
8443  *             if dim <= 0:             # <<<<<<<<<<<<<<
8444  *                 raise ValueError("Invalid shape in axis %d: %d." % (idx, dim))
8445  *             self._shape[idx] = dim
8446  */
8447     __pyx_t_4 = ((__pyx_v_dim <= 0) != 0);
8448     if (unlikely(__pyx_t_4)) {
8449 
8450       /* "View.MemoryView":153
8451  *         for idx, dim in enumerate(shape):
8452  *             if dim <= 0:
8453  *                 raise ValueError("Invalid shape in axis %d: %d." % (idx, dim))             # <<<<<<<<<<<<<<
8454  *             self._shape[idx] = dim
8455  *
8456  */
8457       __pyx_t_5 = __Pyx_PyInt_From_int(__pyx_v_idx); if (unlikely(!__pyx_t_5)) __PYX_ERR(2, 153, __pyx_L1_error)
8458       __Pyx_GOTREF(__pyx_t_5);
8459       __pyx_t_6 = PyInt_FromSsize_t(__pyx_v_dim); if (unlikely(!__pyx_t_6)) __PYX_ERR(2, 153, __pyx_L1_error)
8460       __Pyx_GOTREF(__pyx_t_6);
8461       __pyx_t_10 = PyTuple_New(2); if (unlikely(!__pyx_t_10)) __PYX_ERR(2, 153, __pyx_L1_error)
8462       __Pyx_GOTREF(__pyx_t_10);
8463       __Pyx_GIVEREF(__pyx_t_5);
8464       PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_5);
8465       __Pyx_GIVEREF(__pyx_t_6);
8466       PyTuple_SET_ITEM(__pyx_t_10, 1, __pyx_t_6);
8467       __pyx_t_5 = 0;
8468       __pyx_t_6 = 0;
8469       __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(2, 153, __pyx_L1_error)
8470       __Pyx_GOTREF(__pyx_t_6);
8471       __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
8472       __pyx_t_10 = __Pyx_PyObject_CallOneArg(__pyx_builtin_ValueError, __pyx_t_6); if (unlikely(!__pyx_t_10)) __PYX_ERR(2, 153, __pyx_L1_error)
8473       __Pyx_GOTREF(__pyx_t_10);
8474       __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
8475       __Pyx_Raise(__pyx_t_10, 0, 0, 0);
8476       __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
8477       __PYX_ERR(2, 153, __pyx_L1_error)
8478 
8479       /* "View.MemoryView":152
8480  *
8481  *         for idx, dim in enumerate(shape):
8482  *             if dim <= 0:             # <<<<<<<<<<<<<<
8483  *                 raise ValueError("Invalid shape in axis %d: %d." % (idx, dim))
8484  *             self._shape[idx] = dim
8485  */
8486     }
8487 
8488     /* "View.MemoryView":154
8489  *             if dim <= 0:
8490  *                 raise ValueError("Invalid shape in axis %d: %d." % (idx, dim))
8491  *             self._shape[idx] = dim             # <<<<<<<<<<<<<<
8492  *
8493  *         cdef char order
8494  */
8495     (__pyx_v_self->_shape[__pyx_v_idx]) = __pyx_v_dim;
8496 
8497     /* "View.MemoryView":151
8498  *
8499  *
8500  *         for idx, dim in enumerate(shape):             # <<<<<<<<<<<<<<
8501  *             if dim <= 0:
8502  *                 raise ValueError("Invalid shape in axis %d: %d." % (idx, dim))
8503  */
8504   }
8505   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
8506 
8507   /* "View.MemoryView":157
8508  *
8509  *         cdef char order
8510  *         if mode == 'fortran':             # <<<<<<<<<<<<<<
8511  *             order = b'F'
8512  *             self.mode = u'fortran'
8513  */
8514   __pyx_t_4 = (__Pyx_PyString_Equals(__pyx_v_mode, __pyx_n_s_fortran, Py_EQ)); if (unlikely(__pyx_t_4 < 0)) __PYX_ERR(2, 157, __pyx_L1_error)
8515   if (__pyx_t_4) {
8516 
8517     /* "View.MemoryView":158
8518  *         cdef char order
8519  *         if mode == 'fortran':
8520  *             order = b'F'             # <<<<<<<<<<<<<<
8521  *             self.mode = u'fortran'
8522  *         elif mode == 'c':
8523  */
8524     __pyx_v_order = 'F';
8525 
8526     /* "View.MemoryView":159
8527  *         if mode == 'fortran':
8528  *             order = b'F'
8529  *             self.mode = u'fortran'             # <<<<<<<<<<<<<<
8530  *         elif mode == 'c':
8531  *             order = b'C'
8532  */
8533     __Pyx_INCREF(__pyx_n_u_fortran);
8534     __Pyx_GIVEREF(__pyx_n_u_fortran);
8535     __Pyx_GOTREF(__pyx_v_self->mode);
8536     __Pyx_DECREF(__pyx_v_self->mode);
8537     __pyx_v_self->mode = __pyx_n_u_fortran;
8538 
8539     /* "View.MemoryView":157
8540  *
8541  *         cdef char order
8542  *         if mode == 'fortran':             # <<<<<<<<<<<<<<
8543  *             order = b'F'
8544  *             self.mode = u'fortran'
8545  */
8546     goto __pyx_L10;
8547   }
8548 
8549   /* "View.MemoryView":160
8550  *             order = b'F'
8551  *             self.mode = u'fortran'
8552  *         elif mode == 'c':             # <<<<<<<<<<<<<<
8553  *             order = b'C'
8554  *             self.mode = u'c'
8555  */
8556   __pyx_t_4 = (__Pyx_PyString_Equals(__pyx_v_mode, __pyx_n_s_c, Py_EQ)); if (unlikely(__pyx_t_4 < 0)) __PYX_ERR(2, 160, __pyx_L1_error)
8557   if (likely(__pyx_t_4)) {
8558 
8559     /* "View.MemoryView":161
8560  *             self.mode = u'fortran'
8561  *         elif mode == 'c':
8562  *             order = b'C'             # <<<<<<<<<<<<<<
8563  *             self.mode = u'c'
8564  *         else:
8565  */
8566     __pyx_v_order = 'C';
8567 
8568     /* "View.MemoryView":162
8569  *         elif mode == 'c':
8570  *             order = b'C'
8571  *             self.mode = u'c'             # <<<<<<<<<<<<<<
8572  *         else:
8573  *             raise ValueError("Invalid mode, expected 'c' or 'fortran', got %s" % mode)
8574  */
8575     __Pyx_INCREF(__pyx_n_u_c);
8576     __Pyx_GIVEREF(__pyx_n_u_c);
8577     __Pyx_GOTREF(__pyx_v_self->mode);
8578     __Pyx_DECREF(__pyx_v_self->mode);
8579     __pyx_v_self->mode = __pyx_n_u_c;
8580 
8581     /* "View.MemoryView":160
8582  *             order = b'F'
8583  *             self.mode = u'fortran'
8584  *         elif mode == 'c':             # <<<<<<<<<<<<<<
8585  *             order = b'C'
8586  *             self.mode = u'c'
8587  */
8588     goto __pyx_L10;
8589   }
8590 
8591   /* "View.MemoryView":164
8592  *             self.mode = u'c'
8593  *         else:
8594  *             raise ValueError("Invalid mode, expected 'c' or 'fortran', got %s" % mode)             # <<<<<<<<<<<<<<
8595  *
8596  *         self.len = fill_contig_strides_array(self._shape, self._strides,
8597  */
8598   /*else*/ {
8599     __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(2, 164, __pyx_L1_error)
8600     __Pyx_GOTREF(__pyx_t_3);
8601     __pyx_t_10 = __Pyx_PyObject_CallOneArg(__pyx_builtin_ValueError, __pyx_t_3); if (unlikely(!__pyx_t_10)) __PYX_ERR(2, 164, __pyx_L1_error)
8602     __Pyx_GOTREF(__pyx_t_10);
8603     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
8604     __Pyx_Raise(__pyx_t_10, 0, 0, 0);
8605     __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
8606     __PYX_ERR(2, 164, __pyx_L1_error)
8607   }
8608   __pyx_L10:;
8609 
8610   /* "View.MemoryView":166
8611  *             raise ValueError("Invalid mode, expected 'c' or 'fortran', got %s" % mode)
8612  *
8613  *         self.len = fill_contig_strides_array(self._shape, self._strides,             # <<<<<<<<<<<<<<
8614  *                                              itemsize, self.ndim, order)
8615  *
8616  */
8617   __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);
8618 
8619   /* "View.MemoryView":169
8620  *                                              itemsize, self.ndim, order)
8621  *
8622  *         self.free_data = allocate_buffer             # <<<<<<<<<<<<<<
8623  *         self.dtype_is_object = format == b'O'
8624  *         if allocate_buffer:
8625  */
8626   __pyx_v_self->free_data = __pyx_v_allocate_buffer;
8627 
8628   /* "View.MemoryView":170
8629  *
8630  *         self.free_data = allocate_buffer
8631  *         self.dtype_is_object = format == b'O'             # <<<<<<<<<<<<<<
8632  *         if allocate_buffer:
8633  *
8634  */
8635   __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(2, 170, __pyx_L1_error)
8636   __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_10); if (unlikely((__pyx_t_4 == (int)-1) && PyErr_Occurred())) __PYX_ERR(2, 170, __pyx_L1_error)
8637   __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
8638   __pyx_v_self->dtype_is_object = __pyx_t_4;
8639 
8640   /* "View.MemoryView":171
8641  *         self.free_data = allocate_buffer
8642  *         self.dtype_is_object = format == b'O'
8643  *         if allocate_buffer:             # <<<<<<<<<<<<<<
8644  *
8645  *
8646  */
8647   __pyx_t_4 = (__pyx_v_allocate_buffer != 0);
8648   if (__pyx_t_4) {
8649 
8650     /* "View.MemoryView":174
8651  *
8652  *
8653  *             self.data = <char *>malloc(self.len)             # <<<<<<<<<<<<<<
8654  *             if not self.data:
8655  *                 raise MemoryError("unable to allocate array data.")
8656  */
8657     __pyx_v_self->data = ((char *)malloc(__pyx_v_self->len));
8658 
8659     /* "View.MemoryView":175
8660  *
8661  *             self.data = <char *>malloc(self.len)
8662  *             if not self.data:             # <<<<<<<<<<<<<<
8663  *                 raise MemoryError("unable to allocate array data.")
8664  *
8665  */
8666     __pyx_t_4 = ((!(__pyx_v_self->data != 0)) != 0);
8667     if (unlikely(__pyx_t_4)) {
8668 
8669       /* "View.MemoryView":176
8670  *             self.data = <char *>malloc(self.len)
8671  *             if not self.data:
8672  *                 raise MemoryError("unable to allocate array data.")             # <<<<<<<<<<<<<<
8673  *
8674  *             if self.dtype_is_object:
8675  */
8676       __pyx_t_10 = __Pyx_PyObject_Call(__pyx_builtin_MemoryError, __pyx_tuple__9, NULL); if (unlikely(!__pyx_t_10)) __PYX_ERR(2, 176, __pyx_L1_error)
8677       __Pyx_GOTREF(__pyx_t_10);
8678       __Pyx_Raise(__pyx_t_10, 0, 0, 0);
8679       __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
8680       __PYX_ERR(2, 176, __pyx_L1_error)
8681 
8682       /* "View.MemoryView":175
8683  *
8684  *             self.data = <char *>malloc(self.len)
8685  *             if not self.data:             # <<<<<<<<<<<<<<
8686  *                 raise MemoryError("unable to allocate array data.")
8687  *
8688  */
8689     }
8690 
8691     /* "View.MemoryView":178
8692  *                 raise MemoryError("unable to allocate array data.")
8693  *
8694  *             if self.dtype_is_object:             # <<<<<<<<<<<<<<
8695  *                 p = <PyObject **> self.data
8696  *                 for i in range(self.len / itemsize):
8697  */
8698     __pyx_t_4 = (__pyx_v_self->dtype_is_object != 0);
8699     if (__pyx_t_4) {
8700 
8701       /* "View.MemoryView":179
8702  *
8703  *             if self.dtype_is_object:
8704  *                 p = <PyObject **> self.data             # <<<<<<<<<<<<<<
8705  *                 for i in range(self.len / itemsize):
8706  *                     p[i] = Py_None
8707  */
8708       __pyx_v_p = ((PyObject **)__pyx_v_self->data);
8709 
8710       /* "View.MemoryView":180
8711  *             if self.dtype_is_object:
8712  *                 p = <PyObject **> self.data
8713  *                 for i in range(self.len / itemsize):             # <<<<<<<<<<<<<<
8714  *                     p[i] = Py_None
8715  *                     Py_INCREF(Py_None)
8716  */
8717       if (unlikely(__pyx_v_itemsize == 0)) {
8718         PyErr_SetString(PyExc_ZeroDivisionError, "integer division or modulo by zero");
8719         __PYX_ERR(2, 180, __pyx_L1_error)
8720       }
8721       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))) {
8722         PyErr_SetString(PyExc_OverflowError, "value too large to perform division");
8723         __PYX_ERR(2, 180, __pyx_L1_error)
8724       }
8725       __pyx_t_1 = __Pyx_div_Py_ssize_t(__pyx_v_self->len, __pyx_v_itemsize);
8726       __pyx_t_9 = __pyx_t_1;
8727       for (__pyx_t_11 = 0; __pyx_t_11 < __pyx_t_9; __pyx_t_11+=1) {
8728         __pyx_v_i = __pyx_t_11;
8729 
8730         /* "View.MemoryView":181
8731  *                 p = <PyObject **> self.data
8732  *                 for i in range(self.len / itemsize):
8733  *                     p[i] = Py_None             # <<<<<<<<<<<<<<
8734  *                     Py_INCREF(Py_None)
8735  *
8736  */
8737         (__pyx_v_p[__pyx_v_i]) = Py_None;
8738 
8739         /* "View.MemoryView":182
8740  *                 for i in range(self.len / itemsize):
8741  *                     p[i] = Py_None
8742  *                     Py_INCREF(Py_None)             # <<<<<<<<<<<<<<
8743  *
8744  *     @cname('getbuffer')
8745  */
8746         Py_INCREF(Py_None);
8747       }
8748 
8749       /* "View.MemoryView":178
8750  *                 raise MemoryError("unable to allocate array data.")
8751  *
8752  *             if self.dtype_is_object:             # <<<<<<<<<<<<<<
8753  *                 p = <PyObject **> self.data
8754  *                 for i in range(self.len / itemsize):
8755  */
8756     }
8757 
8758     /* "View.MemoryView":171
8759  *         self.free_data = allocate_buffer
8760  *         self.dtype_is_object = format == b'O'
8761  *         if allocate_buffer:             # <<<<<<<<<<<<<<
8762  *
8763  *
8764  */
8765   }
8766 
8767   /* "View.MemoryView":122
8768  *         cdef bint dtype_is_object
8769  *
8770  *     def __cinit__(array self, tuple shape, Py_ssize_t itemsize, format not None,             # <<<<<<<<<<<<<<
8771  *                   mode="c", bint allocate_buffer=True):
8772  *
8773  */
8774 
8775   /* function exit code */
8776   __pyx_r = 0;
8777   goto __pyx_L0;
8778   __pyx_L1_error:;
8779   __Pyx_XDECREF(__pyx_t_3);
8780   __Pyx_XDECREF(__pyx_t_5);
8781   __Pyx_XDECREF(__pyx_t_6);
8782   __Pyx_XDECREF(__pyx_t_10);
8783   __Pyx_AddTraceback("View.MemoryView.array.__cinit__", __pyx_clineno, __pyx_lineno, __pyx_filename);
8784   __pyx_r = -1;
8785   __pyx_L0:;
8786   __Pyx_XDECREF(__pyx_v_format);
8787   __Pyx_RefNannyFinishContext();
8788   return __pyx_r;
8789 }
8790 
8791 /* "View.MemoryView":185
8792  *
8793  *     @cname('getbuffer')
8794  *     def __getbuffer__(self, Py_buffer *info, int flags):             # <<<<<<<<<<<<<<
8795  *         cdef int bufmode = -1
8796  *         if self.mode == u"c":
8797  */
8798 
8799 /* Python wrapper */
8800 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)8801 static CYTHON_UNUSED int __pyx_array_getbuffer(PyObject *__pyx_v_self, Py_buffer *__pyx_v_info, int __pyx_v_flags) {
8802   int __pyx_r;
8803   __Pyx_RefNannyDeclarations
8804   __Pyx_RefNannySetupContext("__getbuffer__ (wrapper)", 0);
8805   __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));
8806 
8807   /* function exit code */
8808   __Pyx_RefNannyFinishContext();
8809   return __pyx_r;
8810 }
8811 
__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)8812 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) {
8813   int __pyx_v_bufmode;
8814   int __pyx_r;
8815   __Pyx_RefNannyDeclarations
8816   int __pyx_t_1;
8817   int __pyx_t_2;
8818   PyObject *__pyx_t_3 = NULL;
8819   char *__pyx_t_4;
8820   Py_ssize_t __pyx_t_5;
8821   int __pyx_t_6;
8822   Py_ssize_t *__pyx_t_7;
8823   int __pyx_lineno = 0;
8824   const char *__pyx_filename = NULL;
8825   int __pyx_clineno = 0;
8826   if (__pyx_v_info == NULL) {
8827     PyErr_SetString(PyExc_BufferError, "PyObject_GetBuffer: view==NULL argument is obsolete");
8828     return -1;
8829   }
8830   __Pyx_RefNannySetupContext("__getbuffer__", 0);
8831   __pyx_v_info->obj = Py_None; __Pyx_INCREF(Py_None);
8832   __Pyx_GIVEREF(__pyx_v_info->obj);
8833 
8834   /* "View.MemoryView":186
8835  *     @cname('getbuffer')
8836  *     def __getbuffer__(self, Py_buffer *info, int flags):
8837  *         cdef int bufmode = -1             # <<<<<<<<<<<<<<
8838  *         if self.mode == u"c":
8839  *             bufmode = PyBUF_C_CONTIGUOUS | PyBUF_ANY_CONTIGUOUS
8840  */
8841   __pyx_v_bufmode = -1;
8842 
8843   /* "View.MemoryView":187
8844  *     def __getbuffer__(self, Py_buffer *info, int flags):
8845  *         cdef int bufmode = -1
8846  *         if self.mode == u"c":             # <<<<<<<<<<<<<<
8847  *             bufmode = PyBUF_C_CONTIGUOUS | PyBUF_ANY_CONTIGUOUS
8848  *         elif self.mode == u"fortran":
8849  */
8850   __pyx_t_1 = (__Pyx_PyUnicode_Equals(__pyx_v_self->mode, __pyx_n_u_c, Py_EQ)); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(2, 187, __pyx_L1_error)
8851   __pyx_t_2 = (__pyx_t_1 != 0);
8852   if (__pyx_t_2) {
8853 
8854     /* "View.MemoryView":188
8855  *         cdef int bufmode = -1
8856  *         if self.mode == u"c":
8857  *             bufmode = PyBUF_C_CONTIGUOUS | PyBUF_ANY_CONTIGUOUS             # <<<<<<<<<<<<<<
8858  *         elif self.mode == u"fortran":
8859  *             bufmode = PyBUF_F_CONTIGUOUS | PyBUF_ANY_CONTIGUOUS
8860  */
8861     __pyx_v_bufmode = (PyBUF_C_CONTIGUOUS | PyBUF_ANY_CONTIGUOUS);
8862 
8863     /* "View.MemoryView":187
8864  *     def __getbuffer__(self, Py_buffer *info, int flags):
8865  *         cdef int bufmode = -1
8866  *         if self.mode == u"c":             # <<<<<<<<<<<<<<
8867  *             bufmode = PyBUF_C_CONTIGUOUS | PyBUF_ANY_CONTIGUOUS
8868  *         elif self.mode == u"fortran":
8869  */
8870     goto __pyx_L3;
8871   }
8872 
8873   /* "View.MemoryView":189
8874  *         if self.mode == u"c":
8875  *             bufmode = PyBUF_C_CONTIGUOUS | PyBUF_ANY_CONTIGUOUS
8876  *         elif self.mode == u"fortran":             # <<<<<<<<<<<<<<
8877  *             bufmode = PyBUF_F_CONTIGUOUS | PyBUF_ANY_CONTIGUOUS
8878  *         if not (flags & bufmode):
8879  */
8880   __pyx_t_2 = (__Pyx_PyUnicode_Equals(__pyx_v_self->mode, __pyx_n_u_fortran, Py_EQ)); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(2, 189, __pyx_L1_error)
8881   __pyx_t_1 = (__pyx_t_2 != 0);
8882   if (__pyx_t_1) {
8883 
8884     /* "View.MemoryView":190
8885  *             bufmode = PyBUF_C_CONTIGUOUS | PyBUF_ANY_CONTIGUOUS
8886  *         elif self.mode == u"fortran":
8887  *             bufmode = PyBUF_F_CONTIGUOUS | PyBUF_ANY_CONTIGUOUS             # <<<<<<<<<<<<<<
8888  *         if not (flags & bufmode):
8889  *             raise ValueError("Can only create a buffer that is contiguous in memory.")
8890  */
8891     __pyx_v_bufmode = (PyBUF_F_CONTIGUOUS | PyBUF_ANY_CONTIGUOUS);
8892 
8893     /* "View.MemoryView":189
8894  *         if self.mode == u"c":
8895  *             bufmode = PyBUF_C_CONTIGUOUS | PyBUF_ANY_CONTIGUOUS
8896  *         elif self.mode == u"fortran":             # <<<<<<<<<<<<<<
8897  *             bufmode = PyBUF_F_CONTIGUOUS | PyBUF_ANY_CONTIGUOUS
8898  *         if not (flags & bufmode):
8899  */
8900   }
8901   __pyx_L3:;
8902 
8903   /* "View.MemoryView":191
8904  *         elif self.mode == u"fortran":
8905  *             bufmode = PyBUF_F_CONTIGUOUS | PyBUF_ANY_CONTIGUOUS
8906  *         if not (flags & bufmode):             # <<<<<<<<<<<<<<
8907  *             raise ValueError("Can only create a buffer that is contiguous in memory.")
8908  *         info.buf = self.data
8909  */
8910   __pyx_t_1 = ((!((__pyx_v_flags & __pyx_v_bufmode) != 0)) != 0);
8911   if (unlikely(__pyx_t_1)) {
8912 
8913     /* "View.MemoryView":192
8914  *             bufmode = PyBUF_F_CONTIGUOUS | PyBUF_ANY_CONTIGUOUS
8915  *         if not (flags & bufmode):
8916  *             raise ValueError("Can only create a buffer that is contiguous in memory.")             # <<<<<<<<<<<<<<
8917  *         info.buf = self.data
8918  *         info.len = self.len
8919  */
8920     __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__10, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 192, __pyx_L1_error)
8921     __Pyx_GOTREF(__pyx_t_3);
8922     __Pyx_Raise(__pyx_t_3, 0, 0, 0);
8923     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
8924     __PYX_ERR(2, 192, __pyx_L1_error)
8925 
8926     /* "View.MemoryView":191
8927  *         elif self.mode == u"fortran":
8928  *             bufmode = PyBUF_F_CONTIGUOUS | PyBUF_ANY_CONTIGUOUS
8929  *         if not (flags & bufmode):             # <<<<<<<<<<<<<<
8930  *             raise ValueError("Can only create a buffer that is contiguous in memory.")
8931  *         info.buf = self.data
8932  */
8933   }
8934 
8935   /* "View.MemoryView":193
8936  *         if not (flags & bufmode):
8937  *             raise ValueError("Can only create a buffer that is contiguous in memory.")
8938  *         info.buf = self.data             # <<<<<<<<<<<<<<
8939  *         info.len = self.len
8940  *         info.ndim = self.ndim
8941  */
8942   __pyx_t_4 = __pyx_v_self->data;
8943   __pyx_v_info->buf = __pyx_t_4;
8944 
8945   /* "View.MemoryView":194
8946  *             raise ValueError("Can only create a buffer that is contiguous in memory.")
8947  *         info.buf = self.data
8948  *         info.len = self.len             # <<<<<<<<<<<<<<
8949  *         info.ndim = self.ndim
8950  *         info.shape = self._shape
8951  */
8952   __pyx_t_5 = __pyx_v_self->len;
8953   __pyx_v_info->len = __pyx_t_5;
8954 
8955   /* "View.MemoryView":195
8956  *         info.buf = self.data
8957  *         info.len = self.len
8958  *         info.ndim = self.ndim             # <<<<<<<<<<<<<<
8959  *         info.shape = self._shape
8960  *         info.strides = self._strides
8961  */
8962   __pyx_t_6 = __pyx_v_self->ndim;
8963   __pyx_v_info->ndim = __pyx_t_6;
8964 
8965   /* "View.MemoryView":196
8966  *         info.len = self.len
8967  *         info.ndim = self.ndim
8968  *         info.shape = self._shape             # <<<<<<<<<<<<<<
8969  *         info.strides = self._strides
8970  *         info.suboffsets = NULL
8971  */
8972   __pyx_t_7 = __pyx_v_self->_shape;
8973   __pyx_v_info->shape = __pyx_t_7;
8974 
8975   /* "View.MemoryView":197
8976  *         info.ndim = self.ndim
8977  *         info.shape = self._shape
8978  *         info.strides = self._strides             # <<<<<<<<<<<<<<
8979  *         info.suboffsets = NULL
8980  *         info.itemsize = self.itemsize
8981  */
8982   __pyx_t_7 = __pyx_v_self->_strides;
8983   __pyx_v_info->strides = __pyx_t_7;
8984 
8985   /* "View.MemoryView":198
8986  *         info.shape = self._shape
8987  *         info.strides = self._strides
8988  *         info.suboffsets = NULL             # <<<<<<<<<<<<<<
8989  *         info.itemsize = self.itemsize
8990  *         info.readonly = 0
8991  */
8992   __pyx_v_info->suboffsets = NULL;
8993 
8994   /* "View.MemoryView":199
8995  *         info.strides = self._strides
8996  *         info.suboffsets = NULL
8997  *         info.itemsize = self.itemsize             # <<<<<<<<<<<<<<
8998  *         info.readonly = 0
8999  *
9000  */
9001   __pyx_t_5 = __pyx_v_self->itemsize;
9002   __pyx_v_info->itemsize = __pyx_t_5;
9003 
9004   /* "View.MemoryView":200
9005  *         info.suboffsets = NULL
9006  *         info.itemsize = self.itemsize
9007  *         info.readonly = 0             # <<<<<<<<<<<<<<
9008  *
9009  *         if flags & PyBUF_FORMAT:
9010  */
9011   __pyx_v_info->readonly = 0;
9012 
9013   /* "View.MemoryView":202
9014  *         info.readonly = 0
9015  *
9016  *         if flags & PyBUF_FORMAT:             # <<<<<<<<<<<<<<
9017  *             info.format = self.format
9018  *         else:
9019  */
9020   __pyx_t_1 = ((__pyx_v_flags & PyBUF_FORMAT) != 0);
9021   if (__pyx_t_1) {
9022 
9023     /* "View.MemoryView":203
9024  *
9025  *         if flags & PyBUF_FORMAT:
9026  *             info.format = self.format             # <<<<<<<<<<<<<<
9027  *         else:
9028  *             info.format = NULL
9029  */
9030     __pyx_t_4 = __pyx_v_self->format;
9031     __pyx_v_info->format = __pyx_t_4;
9032 
9033     /* "View.MemoryView":202
9034  *         info.readonly = 0
9035  *
9036  *         if flags & PyBUF_FORMAT:             # <<<<<<<<<<<<<<
9037  *             info.format = self.format
9038  *         else:
9039  */
9040     goto __pyx_L5;
9041   }
9042 
9043   /* "View.MemoryView":205
9044  *             info.format = self.format
9045  *         else:
9046  *             info.format = NULL             # <<<<<<<<<<<<<<
9047  *
9048  *         info.obj = self
9049  */
9050   /*else*/ {
9051     __pyx_v_info->format = NULL;
9052   }
9053   __pyx_L5:;
9054 
9055   /* "View.MemoryView":207
9056  *             info.format = NULL
9057  *
9058  *         info.obj = self             # <<<<<<<<<<<<<<
9059  *
9060  *     __pyx_getbuffer = capsule(<void *> &__pyx_array_getbuffer, "getbuffer(obj, view, flags)")
9061  */
9062   __Pyx_INCREF(((PyObject *)__pyx_v_self));
9063   __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
9064   __Pyx_GOTREF(__pyx_v_info->obj);
9065   __Pyx_DECREF(__pyx_v_info->obj);
9066   __pyx_v_info->obj = ((PyObject *)__pyx_v_self);
9067 
9068   /* "View.MemoryView":185
9069  *
9070  *     @cname('getbuffer')
9071  *     def __getbuffer__(self, Py_buffer *info, int flags):             # <<<<<<<<<<<<<<
9072  *         cdef int bufmode = -1
9073  *         if self.mode == u"c":
9074  */
9075 
9076   /* function exit code */
9077   __pyx_r = 0;
9078   goto __pyx_L0;
9079   __pyx_L1_error:;
9080   __Pyx_XDECREF(__pyx_t_3);
9081   __Pyx_AddTraceback("View.MemoryView.array.__getbuffer__", __pyx_clineno, __pyx_lineno, __pyx_filename);
9082   __pyx_r = -1;
9083   if (__pyx_v_info->obj != NULL) {
9084     __Pyx_GOTREF(__pyx_v_info->obj);
9085     __Pyx_DECREF(__pyx_v_info->obj); __pyx_v_info->obj = 0;
9086   }
9087   goto __pyx_L2;
9088   __pyx_L0:;
9089   if (__pyx_v_info->obj == Py_None) {
9090     __Pyx_GOTREF(__pyx_v_info->obj);
9091     __Pyx_DECREF(__pyx_v_info->obj); __pyx_v_info->obj = 0;
9092   }
9093   __pyx_L2:;
9094   __Pyx_RefNannyFinishContext();
9095   return __pyx_r;
9096 }
9097 
9098 /* "View.MemoryView":211
9099  *     __pyx_getbuffer = capsule(<void *> &__pyx_array_getbuffer, "getbuffer(obj, view, flags)")
9100  *
9101  *     def __dealloc__(array self):             # <<<<<<<<<<<<<<
9102  *         if self.callback_free_data != NULL:
9103  *             self.callback_free_data(self.data)
9104  */
9105 
9106 /* Python wrapper */
9107 static void __pyx_array___dealloc__(PyObject *__pyx_v_self); /*proto*/
__pyx_array___dealloc__(PyObject * __pyx_v_self)9108 static void __pyx_array___dealloc__(PyObject *__pyx_v_self) {
9109   __Pyx_RefNannyDeclarations
9110   __Pyx_RefNannySetupContext("__dealloc__ (wrapper)", 0);
9111   __pyx_array___pyx_pf_15View_dot_MemoryView_5array_4__dealloc__(((struct __pyx_array_obj *)__pyx_v_self));
9112 
9113   /* function exit code */
9114   __Pyx_RefNannyFinishContext();
9115 }
9116 
__pyx_array___pyx_pf_15View_dot_MemoryView_5array_4__dealloc__(struct __pyx_array_obj * __pyx_v_self)9117 static void __pyx_array___pyx_pf_15View_dot_MemoryView_5array_4__dealloc__(struct __pyx_array_obj *__pyx_v_self) {
9118   __Pyx_RefNannyDeclarations
9119   int __pyx_t_1;
9120   __Pyx_RefNannySetupContext("__dealloc__", 0);
9121 
9122   /* "View.MemoryView":212
9123  *
9124  *     def __dealloc__(array self):
9125  *         if self.callback_free_data != NULL:             # <<<<<<<<<<<<<<
9126  *             self.callback_free_data(self.data)
9127  *         elif self.free_data:
9128  */
9129   __pyx_t_1 = ((__pyx_v_self->callback_free_data != NULL) != 0);
9130   if (__pyx_t_1) {
9131 
9132     /* "View.MemoryView":213
9133  *     def __dealloc__(array self):
9134  *         if self.callback_free_data != NULL:
9135  *             self.callback_free_data(self.data)             # <<<<<<<<<<<<<<
9136  *         elif self.free_data:
9137  *             if self.dtype_is_object:
9138  */
9139     __pyx_v_self->callback_free_data(__pyx_v_self->data);
9140 
9141     /* "View.MemoryView":212
9142  *
9143  *     def __dealloc__(array self):
9144  *         if self.callback_free_data != NULL:             # <<<<<<<<<<<<<<
9145  *             self.callback_free_data(self.data)
9146  *         elif self.free_data:
9147  */
9148     goto __pyx_L3;
9149   }
9150 
9151   /* "View.MemoryView":214
9152  *         if self.callback_free_data != NULL:
9153  *             self.callback_free_data(self.data)
9154  *         elif self.free_data:             # <<<<<<<<<<<<<<
9155  *             if self.dtype_is_object:
9156  *                 refcount_objects_in_slice(self.data, self._shape,
9157  */
9158   __pyx_t_1 = (__pyx_v_self->free_data != 0);
9159   if (__pyx_t_1) {
9160 
9161     /* "View.MemoryView":215
9162  *             self.callback_free_data(self.data)
9163  *         elif self.free_data:
9164  *             if self.dtype_is_object:             # <<<<<<<<<<<<<<
9165  *                 refcount_objects_in_slice(self.data, self._shape,
9166  *                                           self._strides, self.ndim, False)
9167  */
9168     __pyx_t_1 = (__pyx_v_self->dtype_is_object != 0);
9169     if (__pyx_t_1) {
9170 
9171       /* "View.MemoryView":216
9172  *         elif self.free_data:
9173  *             if self.dtype_is_object:
9174  *                 refcount_objects_in_slice(self.data, self._shape,             # <<<<<<<<<<<<<<
9175  *                                           self._strides, self.ndim, False)
9176  *             free(self.data)
9177  */
9178       __pyx_memoryview_refcount_objects_in_slice(__pyx_v_self->data, __pyx_v_self->_shape, __pyx_v_self->_strides, __pyx_v_self->ndim, 0);
9179 
9180       /* "View.MemoryView":215
9181  *             self.callback_free_data(self.data)
9182  *         elif self.free_data:
9183  *             if self.dtype_is_object:             # <<<<<<<<<<<<<<
9184  *                 refcount_objects_in_slice(self.data, self._shape,
9185  *                                           self._strides, self.ndim, False)
9186  */
9187     }
9188 
9189     /* "View.MemoryView":218
9190  *                 refcount_objects_in_slice(self.data, self._shape,
9191  *                                           self._strides, self.ndim, False)
9192  *             free(self.data)             # <<<<<<<<<<<<<<
9193  *         PyObject_Free(self._shape)
9194  *
9195  */
9196     free(__pyx_v_self->data);
9197 
9198     /* "View.MemoryView":214
9199  *         if self.callback_free_data != NULL:
9200  *             self.callback_free_data(self.data)
9201  *         elif self.free_data:             # <<<<<<<<<<<<<<
9202  *             if self.dtype_is_object:
9203  *                 refcount_objects_in_slice(self.data, self._shape,
9204  */
9205   }
9206   __pyx_L3:;
9207 
9208   /* "View.MemoryView":219
9209  *                                           self._strides, self.ndim, False)
9210  *             free(self.data)
9211  *         PyObject_Free(self._shape)             # <<<<<<<<<<<<<<
9212  *
9213  *     @property
9214  */
9215   PyObject_Free(__pyx_v_self->_shape);
9216 
9217   /* "View.MemoryView":211
9218  *     __pyx_getbuffer = capsule(<void *> &__pyx_array_getbuffer, "getbuffer(obj, view, flags)")
9219  *
9220  *     def __dealloc__(array self):             # <<<<<<<<<<<<<<
9221  *         if self.callback_free_data != NULL:
9222  *             self.callback_free_data(self.data)
9223  */
9224 
9225   /* function exit code */
9226   __Pyx_RefNannyFinishContext();
9227 }
9228 
9229 /* "View.MemoryView":222
9230  *
9231  *     @property
9232  *     def memview(self):             # <<<<<<<<<<<<<<
9233  *         return self.get_memview()
9234  *
9235  */
9236 
9237 /* Python wrapper */
9238 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)9239 static PyObject *__pyx_pw_15View_dot_MemoryView_5array_7memview_1__get__(PyObject *__pyx_v_self) {
9240   PyObject *__pyx_r = 0;
9241   __Pyx_RefNannyDeclarations
9242   __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
9243   __pyx_r = __pyx_pf_15View_dot_MemoryView_5array_7memview___get__(((struct __pyx_array_obj *)__pyx_v_self));
9244 
9245   /* function exit code */
9246   __Pyx_RefNannyFinishContext();
9247   return __pyx_r;
9248 }
9249 
__pyx_pf_15View_dot_MemoryView_5array_7memview___get__(struct __pyx_array_obj * __pyx_v_self)9250 static PyObject *__pyx_pf_15View_dot_MemoryView_5array_7memview___get__(struct __pyx_array_obj *__pyx_v_self) {
9251   PyObject *__pyx_r = NULL;
9252   __Pyx_RefNannyDeclarations
9253   PyObject *__pyx_t_1 = NULL;
9254   int __pyx_lineno = 0;
9255   const char *__pyx_filename = NULL;
9256   int __pyx_clineno = 0;
9257   __Pyx_RefNannySetupContext("__get__", 0);
9258 
9259   /* "View.MemoryView":223
9260  *     @property
9261  *     def memview(self):
9262  *         return self.get_memview()             # <<<<<<<<<<<<<<
9263  *
9264  *     @cname('get_memview')
9265  */
9266   __Pyx_XDECREF(__pyx_r);
9267   __pyx_t_1 = ((struct __pyx_vtabstruct_array *)__pyx_v_self->__pyx_vtab)->get_memview(__pyx_v_self); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 223, __pyx_L1_error)
9268   __Pyx_GOTREF(__pyx_t_1);
9269   __pyx_r = __pyx_t_1;
9270   __pyx_t_1 = 0;
9271   goto __pyx_L0;
9272 
9273   /* "View.MemoryView":222
9274  *
9275  *     @property
9276  *     def memview(self):             # <<<<<<<<<<<<<<
9277  *         return self.get_memview()
9278  *
9279  */
9280 
9281   /* function exit code */
9282   __pyx_L1_error:;
9283   __Pyx_XDECREF(__pyx_t_1);
9284   __Pyx_AddTraceback("View.MemoryView.array.memview.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
9285   __pyx_r = NULL;
9286   __pyx_L0:;
9287   __Pyx_XGIVEREF(__pyx_r);
9288   __Pyx_RefNannyFinishContext();
9289   return __pyx_r;
9290 }
9291 
9292 /* "View.MemoryView":226
9293  *
9294  *     @cname('get_memview')
9295  *     cdef get_memview(self):             # <<<<<<<<<<<<<<
9296  *         flags =  PyBUF_ANY_CONTIGUOUS|PyBUF_FORMAT|PyBUF_WRITABLE
9297  *         return  memoryview(self, flags, self.dtype_is_object)
9298  */
9299 
__pyx_array_get_memview(struct __pyx_array_obj * __pyx_v_self)9300 static PyObject *__pyx_array_get_memview(struct __pyx_array_obj *__pyx_v_self) {
9301   int __pyx_v_flags;
9302   PyObject *__pyx_r = NULL;
9303   __Pyx_RefNannyDeclarations
9304   PyObject *__pyx_t_1 = NULL;
9305   PyObject *__pyx_t_2 = NULL;
9306   PyObject *__pyx_t_3 = NULL;
9307   int __pyx_lineno = 0;
9308   const char *__pyx_filename = NULL;
9309   int __pyx_clineno = 0;
9310   __Pyx_RefNannySetupContext("get_memview", 0);
9311 
9312   /* "View.MemoryView":227
9313  *     @cname('get_memview')
9314  *     cdef get_memview(self):
9315  *         flags =  PyBUF_ANY_CONTIGUOUS|PyBUF_FORMAT|PyBUF_WRITABLE             # <<<<<<<<<<<<<<
9316  *         return  memoryview(self, flags, self.dtype_is_object)
9317  *
9318  */
9319   __pyx_v_flags = ((PyBUF_ANY_CONTIGUOUS | PyBUF_FORMAT) | PyBUF_WRITABLE);
9320 
9321   /* "View.MemoryView":228
9322  *     cdef get_memview(self):
9323  *         flags =  PyBUF_ANY_CONTIGUOUS|PyBUF_FORMAT|PyBUF_WRITABLE
9324  *         return  memoryview(self, flags, self.dtype_is_object)             # <<<<<<<<<<<<<<
9325  *
9326  *     def __len__(self):
9327  */
9328   __Pyx_XDECREF(__pyx_r);
9329   __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_flags); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 228, __pyx_L1_error)
9330   __Pyx_GOTREF(__pyx_t_1);
9331   __pyx_t_2 = __Pyx_PyBool_FromLong(__pyx_v_self->dtype_is_object); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 228, __pyx_L1_error)
9332   __Pyx_GOTREF(__pyx_t_2);
9333   __pyx_t_3 = PyTuple_New(3); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 228, __pyx_L1_error)
9334   __Pyx_GOTREF(__pyx_t_3);
9335   __Pyx_INCREF(((PyObject *)__pyx_v_self));
9336   __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
9337   PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)__pyx_v_self));
9338   __Pyx_GIVEREF(__pyx_t_1);
9339   PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_1);
9340   __Pyx_GIVEREF(__pyx_t_2);
9341   PyTuple_SET_ITEM(__pyx_t_3, 2, __pyx_t_2);
9342   __pyx_t_1 = 0;
9343   __pyx_t_2 = 0;
9344   __pyx_t_2 = __Pyx_PyObject_Call(((PyObject *)__pyx_memoryview_type), __pyx_t_3, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 228, __pyx_L1_error)
9345   __Pyx_GOTREF(__pyx_t_2);
9346   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
9347   __pyx_r = __pyx_t_2;
9348   __pyx_t_2 = 0;
9349   goto __pyx_L0;
9350 
9351   /* "View.MemoryView":226
9352  *
9353  *     @cname('get_memview')
9354  *     cdef get_memview(self):             # <<<<<<<<<<<<<<
9355  *         flags =  PyBUF_ANY_CONTIGUOUS|PyBUF_FORMAT|PyBUF_WRITABLE
9356  *         return  memoryview(self, flags, self.dtype_is_object)
9357  */
9358 
9359   /* function exit code */
9360   __pyx_L1_error:;
9361   __Pyx_XDECREF(__pyx_t_1);
9362   __Pyx_XDECREF(__pyx_t_2);
9363   __Pyx_XDECREF(__pyx_t_3);
9364   __Pyx_AddTraceback("View.MemoryView.array.get_memview", __pyx_clineno, __pyx_lineno, __pyx_filename);
9365   __pyx_r = 0;
9366   __pyx_L0:;
9367   __Pyx_XGIVEREF(__pyx_r);
9368   __Pyx_RefNannyFinishContext();
9369   return __pyx_r;
9370 }
9371 
9372 /* "View.MemoryView":230
9373  *         return  memoryview(self, flags, self.dtype_is_object)
9374  *
9375  *     def __len__(self):             # <<<<<<<<<<<<<<
9376  *         return self._shape[0]
9377  *
9378  */
9379 
9380 /* Python wrapper */
9381 static Py_ssize_t __pyx_array___len__(PyObject *__pyx_v_self); /*proto*/
__pyx_array___len__(PyObject * __pyx_v_self)9382 static Py_ssize_t __pyx_array___len__(PyObject *__pyx_v_self) {
9383   Py_ssize_t __pyx_r;
9384   __Pyx_RefNannyDeclarations
9385   __Pyx_RefNannySetupContext("__len__ (wrapper)", 0);
9386   __pyx_r = __pyx_array___pyx_pf_15View_dot_MemoryView_5array_6__len__(((struct __pyx_array_obj *)__pyx_v_self));
9387 
9388   /* function exit code */
9389   __Pyx_RefNannyFinishContext();
9390   return __pyx_r;
9391 }
9392 
__pyx_array___pyx_pf_15View_dot_MemoryView_5array_6__len__(struct __pyx_array_obj * __pyx_v_self)9393 static Py_ssize_t __pyx_array___pyx_pf_15View_dot_MemoryView_5array_6__len__(struct __pyx_array_obj *__pyx_v_self) {
9394   Py_ssize_t __pyx_r;
9395   __Pyx_RefNannyDeclarations
9396   __Pyx_RefNannySetupContext("__len__", 0);
9397 
9398   /* "View.MemoryView":231
9399  *
9400  *     def __len__(self):
9401  *         return self._shape[0]             # <<<<<<<<<<<<<<
9402  *
9403  *     def __getattr__(self, attr):
9404  */
9405   __pyx_r = (__pyx_v_self->_shape[0]);
9406   goto __pyx_L0;
9407 
9408   /* "View.MemoryView":230
9409  *         return  memoryview(self, flags, self.dtype_is_object)
9410  *
9411  *     def __len__(self):             # <<<<<<<<<<<<<<
9412  *         return self._shape[0]
9413  *
9414  */
9415 
9416   /* function exit code */
9417   __pyx_L0:;
9418   __Pyx_RefNannyFinishContext();
9419   return __pyx_r;
9420 }
9421 
9422 /* "View.MemoryView":233
9423  *         return self._shape[0]
9424  *
9425  *     def __getattr__(self, attr):             # <<<<<<<<<<<<<<
9426  *         return getattr(self.memview, attr)
9427  *
9428  */
9429 
9430 /* Python wrapper */
9431 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)9432 static PyObject *__pyx_array___getattr__(PyObject *__pyx_v_self, PyObject *__pyx_v_attr) {
9433   PyObject *__pyx_r = 0;
9434   __Pyx_RefNannyDeclarations
9435   __Pyx_RefNannySetupContext("__getattr__ (wrapper)", 0);
9436   __pyx_r = __pyx_array___pyx_pf_15View_dot_MemoryView_5array_8__getattr__(((struct __pyx_array_obj *)__pyx_v_self), ((PyObject *)__pyx_v_attr));
9437 
9438   /* function exit code */
9439   __Pyx_RefNannyFinishContext();
9440   return __pyx_r;
9441 }
9442 
__pyx_array___pyx_pf_15View_dot_MemoryView_5array_8__getattr__(struct __pyx_array_obj * __pyx_v_self,PyObject * __pyx_v_attr)9443 static PyObject *__pyx_array___pyx_pf_15View_dot_MemoryView_5array_8__getattr__(struct __pyx_array_obj *__pyx_v_self, PyObject *__pyx_v_attr) {
9444   PyObject *__pyx_r = NULL;
9445   __Pyx_RefNannyDeclarations
9446   PyObject *__pyx_t_1 = NULL;
9447   PyObject *__pyx_t_2 = NULL;
9448   int __pyx_lineno = 0;
9449   const char *__pyx_filename = NULL;
9450   int __pyx_clineno = 0;
9451   __Pyx_RefNannySetupContext("__getattr__", 0);
9452 
9453   /* "View.MemoryView":234
9454  *
9455  *     def __getattr__(self, attr):
9456  *         return getattr(self.memview, attr)             # <<<<<<<<<<<<<<
9457  *
9458  *     def __getitem__(self, item):
9459  */
9460   __Pyx_XDECREF(__pyx_r);
9461   __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_memview); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 234, __pyx_L1_error)
9462   __Pyx_GOTREF(__pyx_t_1);
9463   __pyx_t_2 = __Pyx_GetAttr(__pyx_t_1, __pyx_v_attr); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 234, __pyx_L1_error)
9464   __Pyx_GOTREF(__pyx_t_2);
9465   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
9466   __pyx_r = __pyx_t_2;
9467   __pyx_t_2 = 0;
9468   goto __pyx_L0;
9469 
9470   /* "View.MemoryView":233
9471  *         return self._shape[0]
9472  *
9473  *     def __getattr__(self, attr):             # <<<<<<<<<<<<<<
9474  *         return getattr(self.memview, attr)
9475  *
9476  */
9477 
9478   /* function exit code */
9479   __pyx_L1_error:;
9480   __Pyx_XDECREF(__pyx_t_1);
9481   __Pyx_XDECREF(__pyx_t_2);
9482   __Pyx_AddTraceback("View.MemoryView.array.__getattr__", __pyx_clineno, __pyx_lineno, __pyx_filename);
9483   __pyx_r = NULL;
9484   __pyx_L0:;
9485   __Pyx_XGIVEREF(__pyx_r);
9486   __Pyx_RefNannyFinishContext();
9487   return __pyx_r;
9488 }
9489 
9490 /* "View.MemoryView":236
9491  *         return getattr(self.memview, attr)
9492  *
9493  *     def __getitem__(self, item):             # <<<<<<<<<<<<<<
9494  *         return self.memview[item]
9495  *
9496  */
9497 
9498 /* Python wrapper */
9499 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)9500 static PyObject *__pyx_array___getitem__(PyObject *__pyx_v_self, PyObject *__pyx_v_item) {
9501   PyObject *__pyx_r = 0;
9502   __Pyx_RefNannyDeclarations
9503   __Pyx_RefNannySetupContext("__getitem__ (wrapper)", 0);
9504   __pyx_r = __pyx_array___pyx_pf_15View_dot_MemoryView_5array_10__getitem__(((struct __pyx_array_obj *)__pyx_v_self), ((PyObject *)__pyx_v_item));
9505 
9506   /* function exit code */
9507   __Pyx_RefNannyFinishContext();
9508   return __pyx_r;
9509 }
9510 
__pyx_array___pyx_pf_15View_dot_MemoryView_5array_10__getitem__(struct __pyx_array_obj * __pyx_v_self,PyObject * __pyx_v_item)9511 static PyObject *__pyx_array___pyx_pf_15View_dot_MemoryView_5array_10__getitem__(struct __pyx_array_obj *__pyx_v_self, PyObject *__pyx_v_item) {
9512   PyObject *__pyx_r = NULL;
9513   __Pyx_RefNannyDeclarations
9514   PyObject *__pyx_t_1 = NULL;
9515   PyObject *__pyx_t_2 = NULL;
9516   int __pyx_lineno = 0;
9517   const char *__pyx_filename = NULL;
9518   int __pyx_clineno = 0;
9519   __Pyx_RefNannySetupContext("__getitem__", 0);
9520 
9521   /* "View.MemoryView":237
9522  *
9523  *     def __getitem__(self, item):
9524  *         return self.memview[item]             # <<<<<<<<<<<<<<
9525  *
9526  *     def __setitem__(self, item, value):
9527  */
9528   __Pyx_XDECREF(__pyx_r);
9529   __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_memview); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 237, __pyx_L1_error)
9530   __Pyx_GOTREF(__pyx_t_1);
9531   __pyx_t_2 = __Pyx_PyObject_GetItem(__pyx_t_1, __pyx_v_item); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 237, __pyx_L1_error)
9532   __Pyx_GOTREF(__pyx_t_2);
9533   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
9534   __pyx_r = __pyx_t_2;
9535   __pyx_t_2 = 0;
9536   goto __pyx_L0;
9537 
9538   /* "View.MemoryView":236
9539  *         return getattr(self.memview, attr)
9540  *
9541  *     def __getitem__(self, item):             # <<<<<<<<<<<<<<
9542  *         return self.memview[item]
9543  *
9544  */
9545 
9546   /* function exit code */
9547   __pyx_L1_error:;
9548   __Pyx_XDECREF(__pyx_t_1);
9549   __Pyx_XDECREF(__pyx_t_2);
9550   __Pyx_AddTraceback("View.MemoryView.array.__getitem__", __pyx_clineno, __pyx_lineno, __pyx_filename);
9551   __pyx_r = NULL;
9552   __pyx_L0:;
9553   __Pyx_XGIVEREF(__pyx_r);
9554   __Pyx_RefNannyFinishContext();
9555   return __pyx_r;
9556 }
9557 
9558 /* "View.MemoryView":239
9559  *         return self.memview[item]
9560  *
9561  *     def __setitem__(self, item, value):             # <<<<<<<<<<<<<<
9562  *         self.memview[item] = value
9563  *
9564  */
9565 
9566 /* Python wrapper */
9567 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)9568 static int __pyx_array___setitem__(PyObject *__pyx_v_self, PyObject *__pyx_v_item, PyObject *__pyx_v_value) {
9569   int __pyx_r;
9570   __Pyx_RefNannyDeclarations
9571   __Pyx_RefNannySetupContext("__setitem__ (wrapper)", 0);
9572   __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));
9573 
9574   /* function exit code */
9575   __Pyx_RefNannyFinishContext();
9576   return __pyx_r;
9577 }
9578 
__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)9579 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) {
9580   int __pyx_r;
9581   __Pyx_RefNannyDeclarations
9582   PyObject *__pyx_t_1 = NULL;
9583   int __pyx_lineno = 0;
9584   const char *__pyx_filename = NULL;
9585   int __pyx_clineno = 0;
9586   __Pyx_RefNannySetupContext("__setitem__", 0);
9587 
9588   /* "View.MemoryView":240
9589  *
9590  *     def __setitem__(self, item, value):
9591  *         self.memview[item] = value             # <<<<<<<<<<<<<<
9592  *
9593  *
9594  */
9595   __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_memview); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 240, __pyx_L1_error)
9596   __Pyx_GOTREF(__pyx_t_1);
9597   if (unlikely(PyObject_SetItem(__pyx_t_1, __pyx_v_item, __pyx_v_value) < 0)) __PYX_ERR(2, 240, __pyx_L1_error)
9598   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
9599 
9600   /* "View.MemoryView":239
9601  *         return self.memview[item]
9602  *
9603  *     def __setitem__(self, item, value):             # <<<<<<<<<<<<<<
9604  *         self.memview[item] = value
9605  *
9606  */
9607 
9608   /* function exit code */
9609   __pyx_r = 0;
9610   goto __pyx_L0;
9611   __pyx_L1_error:;
9612   __Pyx_XDECREF(__pyx_t_1);
9613   __Pyx_AddTraceback("View.MemoryView.array.__setitem__", __pyx_clineno, __pyx_lineno, __pyx_filename);
9614   __pyx_r = -1;
9615   __pyx_L0:;
9616   __Pyx_RefNannyFinishContext();
9617   return __pyx_r;
9618 }
9619 
9620 /* "(tree fragment)":1
9621  * def __reduce_cython__(self):             # <<<<<<<<<<<<<<
9622  *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
9623  * def __setstate_cython__(self, __pyx_state):
9624  */
9625 
9626 /* Python wrapper */
9627 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)9628 static PyObject *__pyx_pw___pyx_array_1__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
9629   PyObject *__pyx_r = 0;
9630   __Pyx_RefNannyDeclarations
9631   __Pyx_RefNannySetupContext("__reduce_cython__ (wrapper)", 0);
9632   __pyx_r = __pyx_pf___pyx_array___reduce_cython__(((struct __pyx_array_obj *)__pyx_v_self));
9633 
9634   /* function exit code */
9635   __Pyx_RefNannyFinishContext();
9636   return __pyx_r;
9637 }
9638 
__pyx_pf___pyx_array___reduce_cython__(CYTHON_UNUSED struct __pyx_array_obj * __pyx_v_self)9639 static PyObject *__pyx_pf___pyx_array___reduce_cython__(CYTHON_UNUSED struct __pyx_array_obj *__pyx_v_self) {
9640   PyObject *__pyx_r = NULL;
9641   __Pyx_RefNannyDeclarations
9642   PyObject *__pyx_t_1 = NULL;
9643   int __pyx_lineno = 0;
9644   const char *__pyx_filename = NULL;
9645   int __pyx_clineno = 0;
9646   __Pyx_RefNannySetupContext("__reduce_cython__", 0);
9647 
9648   /* "(tree fragment)":2
9649  * def __reduce_cython__(self):
9650  *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")             # <<<<<<<<<<<<<<
9651  * def __setstate_cython__(self, __pyx_state):
9652  *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
9653  */
9654   __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__11, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 2, __pyx_L1_error)
9655   __Pyx_GOTREF(__pyx_t_1);
9656   __Pyx_Raise(__pyx_t_1, 0, 0, 0);
9657   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
9658   __PYX_ERR(2, 2, __pyx_L1_error)
9659 
9660   /* "(tree fragment)":1
9661  * def __reduce_cython__(self):             # <<<<<<<<<<<<<<
9662  *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
9663  * def __setstate_cython__(self, __pyx_state):
9664  */
9665 
9666   /* function exit code */
9667   __pyx_L1_error:;
9668   __Pyx_XDECREF(__pyx_t_1);
9669   __Pyx_AddTraceback("View.MemoryView.array.__reduce_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename);
9670   __pyx_r = NULL;
9671   __Pyx_XGIVEREF(__pyx_r);
9672   __Pyx_RefNannyFinishContext();
9673   return __pyx_r;
9674 }
9675 
9676 /* "(tree fragment)":3
9677  * def __reduce_cython__(self):
9678  *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
9679  * def __setstate_cython__(self, __pyx_state):             # <<<<<<<<<<<<<<
9680  *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
9681  */
9682 
9683 /* Python wrapper */
9684 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)9685 static PyObject *__pyx_pw___pyx_array_3__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state) {
9686   PyObject *__pyx_r = 0;
9687   __Pyx_RefNannyDeclarations
9688   __Pyx_RefNannySetupContext("__setstate_cython__ (wrapper)", 0);
9689   __pyx_r = __pyx_pf___pyx_array_2__setstate_cython__(((struct __pyx_array_obj *)__pyx_v_self), ((PyObject *)__pyx_v___pyx_state));
9690 
9691   /* function exit code */
9692   __Pyx_RefNannyFinishContext();
9693   return __pyx_r;
9694 }
9695 
__pyx_pf___pyx_array_2__setstate_cython__(CYTHON_UNUSED struct __pyx_array_obj * __pyx_v_self,CYTHON_UNUSED PyObject * __pyx_v___pyx_state)9696 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) {
9697   PyObject *__pyx_r = NULL;
9698   __Pyx_RefNannyDeclarations
9699   PyObject *__pyx_t_1 = NULL;
9700   int __pyx_lineno = 0;
9701   const char *__pyx_filename = NULL;
9702   int __pyx_clineno = 0;
9703   __Pyx_RefNannySetupContext("__setstate_cython__", 0);
9704 
9705   /* "(tree fragment)":4
9706  *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
9707  * def __setstate_cython__(self, __pyx_state):
9708  *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")             # <<<<<<<<<<<<<<
9709  */
9710   __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__12, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 4, __pyx_L1_error)
9711   __Pyx_GOTREF(__pyx_t_1);
9712   __Pyx_Raise(__pyx_t_1, 0, 0, 0);
9713   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
9714   __PYX_ERR(2, 4, __pyx_L1_error)
9715 
9716   /* "(tree fragment)":3
9717  * def __reduce_cython__(self):
9718  *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
9719  * def __setstate_cython__(self, __pyx_state):             # <<<<<<<<<<<<<<
9720  *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
9721  */
9722 
9723   /* function exit code */
9724   __pyx_L1_error:;
9725   __Pyx_XDECREF(__pyx_t_1);
9726   __Pyx_AddTraceback("View.MemoryView.array.__setstate_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename);
9727   __pyx_r = NULL;
9728   __Pyx_XGIVEREF(__pyx_r);
9729   __Pyx_RefNannyFinishContext();
9730   return __pyx_r;
9731 }
9732 
9733 /* "View.MemoryView":244
9734  *
9735  * @cname("__pyx_array_new")
9736  * cdef array array_cwrapper(tuple shape, Py_ssize_t itemsize, char *format,             # <<<<<<<<<<<<<<
9737  *                           char *mode, char *buf):
9738  *     cdef array result
9739  */
9740 
__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)9741 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) {
9742   struct __pyx_array_obj *__pyx_v_result = 0;
9743   struct __pyx_array_obj *__pyx_r = NULL;
9744   __Pyx_RefNannyDeclarations
9745   int __pyx_t_1;
9746   PyObject *__pyx_t_2 = NULL;
9747   PyObject *__pyx_t_3 = NULL;
9748   PyObject *__pyx_t_4 = NULL;
9749   PyObject *__pyx_t_5 = NULL;
9750   int __pyx_lineno = 0;
9751   const char *__pyx_filename = NULL;
9752   int __pyx_clineno = 0;
9753   __Pyx_RefNannySetupContext("array_cwrapper", 0);
9754 
9755   /* "View.MemoryView":248
9756  *     cdef array result
9757  *
9758  *     if buf == NULL:             # <<<<<<<<<<<<<<
9759  *         result = array(shape, itemsize, format, mode.decode('ASCII'))
9760  *     else:
9761  */
9762   __pyx_t_1 = ((__pyx_v_buf == NULL) != 0);
9763   if (__pyx_t_1) {
9764 
9765     /* "View.MemoryView":249
9766  *
9767  *     if buf == NULL:
9768  *         result = array(shape, itemsize, format, mode.decode('ASCII'))             # <<<<<<<<<<<<<<
9769  *     else:
9770  *         result = array(shape, itemsize, format, mode.decode('ASCII'),
9771  */
9772     __pyx_t_2 = PyInt_FromSsize_t(__pyx_v_itemsize); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 249, __pyx_L1_error)
9773     __Pyx_GOTREF(__pyx_t_2);
9774     __pyx_t_3 = __Pyx_PyBytes_FromString(__pyx_v_format); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 249, __pyx_L1_error)
9775     __Pyx_GOTREF(__pyx_t_3);
9776     __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(2, 249, __pyx_L1_error)
9777     __Pyx_GOTREF(__pyx_t_4);
9778     __pyx_t_5 = PyTuple_New(4); if (unlikely(!__pyx_t_5)) __PYX_ERR(2, 249, __pyx_L1_error)
9779     __Pyx_GOTREF(__pyx_t_5);
9780     __Pyx_INCREF(__pyx_v_shape);
9781     __Pyx_GIVEREF(__pyx_v_shape);
9782     PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_v_shape);
9783     __Pyx_GIVEREF(__pyx_t_2);
9784     PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_t_2);
9785     __Pyx_GIVEREF(__pyx_t_3);
9786     PyTuple_SET_ITEM(__pyx_t_5, 2, __pyx_t_3);
9787     __Pyx_GIVEREF(__pyx_t_4);
9788     PyTuple_SET_ITEM(__pyx_t_5, 3, __pyx_t_4);
9789     __pyx_t_2 = 0;
9790     __pyx_t_3 = 0;
9791     __pyx_t_4 = 0;
9792     __pyx_t_4 = __Pyx_PyObject_Call(((PyObject *)__pyx_array_type), __pyx_t_5, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 249, __pyx_L1_error)
9793     __Pyx_GOTREF(__pyx_t_4);
9794     __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
9795     __pyx_v_result = ((struct __pyx_array_obj *)__pyx_t_4);
9796     __pyx_t_4 = 0;
9797 
9798     /* "View.MemoryView":248
9799  *     cdef array result
9800  *
9801  *     if buf == NULL:             # <<<<<<<<<<<<<<
9802  *         result = array(shape, itemsize, format, mode.decode('ASCII'))
9803  *     else:
9804  */
9805     goto __pyx_L3;
9806   }
9807 
9808   /* "View.MemoryView":251
9809  *         result = array(shape, itemsize, format, mode.decode('ASCII'))
9810  *     else:
9811  *         result = array(shape, itemsize, format, mode.decode('ASCII'),             # <<<<<<<<<<<<<<
9812  *                        allocate_buffer=False)
9813  *         result.data = buf
9814  */
9815   /*else*/ {
9816     __pyx_t_4 = PyInt_FromSsize_t(__pyx_v_itemsize); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 251, __pyx_L1_error)
9817     __Pyx_GOTREF(__pyx_t_4);
9818     __pyx_t_5 = __Pyx_PyBytes_FromString(__pyx_v_format); if (unlikely(!__pyx_t_5)) __PYX_ERR(2, 251, __pyx_L1_error)
9819     __Pyx_GOTREF(__pyx_t_5);
9820     __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(2, 251, __pyx_L1_error)
9821     __Pyx_GOTREF(__pyx_t_3);
9822     __pyx_t_2 = PyTuple_New(4); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 251, __pyx_L1_error)
9823     __Pyx_GOTREF(__pyx_t_2);
9824     __Pyx_INCREF(__pyx_v_shape);
9825     __Pyx_GIVEREF(__pyx_v_shape);
9826     PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_shape);
9827     __Pyx_GIVEREF(__pyx_t_4);
9828     PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_t_4);
9829     __Pyx_GIVEREF(__pyx_t_5);
9830     PyTuple_SET_ITEM(__pyx_t_2, 2, __pyx_t_5);
9831     __Pyx_GIVEREF(__pyx_t_3);
9832     PyTuple_SET_ITEM(__pyx_t_2, 3, __pyx_t_3);
9833     __pyx_t_4 = 0;
9834     __pyx_t_5 = 0;
9835     __pyx_t_3 = 0;
9836 
9837     /* "View.MemoryView":252
9838  *     else:
9839  *         result = array(shape, itemsize, format, mode.decode('ASCII'),
9840  *                        allocate_buffer=False)             # <<<<<<<<<<<<<<
9841  *         result.data = buf
9842  *
9843  */
9844     __pyx_t_3 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 252, __pyx_L1_error)
9845     __Pyx_GOTREF(__pyx_t_3);
9846     if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_allocate_buffer, Py_False) < 0) __PYX_ERR(2, 252, __pyx_L1_error)
9847 
9848     /* "View.MemoryView":251
9849  *         result = array(shape, itemsize, format, mode.decode('ASCII'))
9850  *     else:
9851  *         result = array(shape, itemsize, format, mode.decode('ASCII'),             # <<<<<<<<<<<<<<
9852  *                        allocate_buffer=False)
9853  *         result.data = buf
9854  */
9855     __pyx_t_5 = __Pyx_PyObject_Call(((PyObject *)__pyx_array_type), __pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_5)) __PYX_ERR(2, 251, __pyx_L1_error)
9856     __Pyx_GOTREF(__pyx_t_5);
9857     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
9858     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
9859     __pyx_v_result = ((struct __pyx_array_obj *)__pyx_t_5);
9860     __pyx_t_5 = 0;
9861 
9862     /* "View.MemoryView":253
9863  *         result = array(shape, itemsize, format, mode.decode('ASCII'),
9864  *                        allocate_buffer=False)
9865  *         result.data = buf             # <<<<<<<<<<<<<<
9866  *
9867  *     return result
9868  */
9869     __pyx_v_result->data = __pyx_v_buf;
9870   }
9871   __pyx_L3:;
9872 
9873   /* "View.MemoryView":255
9874  *         result.data = buf
9875  *
9876  *     return result             # <<<<<<<<<<<<<<
9877  *
9878  *
9879  */
9880   __Pyx_XDECREF(((PyObject *)__pyx_r));
9881   __Pyx_INCREF(((PyObject *)__pyx_v_result));
9882   __pyx_r = __pyx_v_result;
9883   goto __pyx_L0;
9884 
9885   /* "View.MemoryView":244
9886  *
9887  * @cname("__pyx_array_new")
9888  * cdef array array_cwrapper(tuple shape, Py_ssize_t itemsize, char *format,             # <<<<<<<<<<<<<<
9889  *                           char *mode, char *buf):
9890  *     cdef array result
9891  */
9892 
9893   /* function exit code */
9894   __pyx_L1_error:;
9895   __Pyx_XDECREF(__pyx_t_2);
9896   __Pyx_XDECREF(__pyx_t_3);
9897   __Pyx_XDECREF(__pyx_t_4);
9898   __Pyx_XDECREF(__pyx_t_5);
9899   __Pyx_AddTraceback("View.MemoryView.array_cwrapper", __pyx_clineno, __pyx_lineno, __pyx_filename);
9900   __pyx_r = 0;
9901   __pyx_L0:;
9902   __Pyx_XDECREF((PyObject *)__pyx_v_result);
9903   __Pyx_XGIVEREF((PyObject *)__pyx_r);
9904   __Pyx_RefNannyFinishContext();
9905   return __pyx_r;
9906 }
9907 
9908 /* "View.MemoryView":281
9909  * cdef class Enum(object):
9910  *     cdef object name
9911  *     def __init__(self, name):             # <<<<<<<<<<<<<<
9912  *         self.name = name
9913  *     def __repr__(self):
9914  */
9915 
9916 /* Python wrapper */
9917 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)9918 static int __pyx_MemviewEnum___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
9919   PyObject *__pyx_v_name = 0;
9920   int __pyx_lineno = 0;
9921   const char *__pyx_filename = NULL;
9922   int __pyx_clineno = 0;
9923   int __pyx_r;
9924   __Pyx_RefNannyDeclarations
9925   __Pyx_RefNannySetupContext("__init__ (wrapper)", 0);
9926   {
9927     static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_name,0};
9928     PyObject* values[1] = {0};
9929     if (unlikely(__pyx_kwds)) {
9930       Py_ssize_t kw_args;
9931       const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
9932       switch (pos_args) {
9933         case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
9934         CYTHON_FALLTHROUGH;
9935         case  0: break;
9936         default: goto __pyx_L5_argtuple_error;
9937       }
9938       kw_args = PyDict_Size(__pyx_kwds);
9939       switch (pos_args) {
9940         case  0:
9941         if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_name)) != 0)) kw_args--;
9942         else goto __pyx_L5_argtuple_error;
9943       }
9944       if (unlikely(kw_args > 0)) {
9945         if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__init__") < 0)) __PYX_ERR(2, 281, __pyx_L3_error)
9946       }
9947     } else if (PyTuple_GET_SIZE(__pyx_args) != 1) {
9948       goto __pyx_L5_argtuple_error;
9949     } else {
9950       values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
9951     }
9952     __pyx_v_name = values[0];
9953   }
9954   goto __pyx_L4_argument_unpacking_done;
9955   __pyx_L5_argtuple_error:;
9956   __Pyx_RaiseArgtupleInvalid("__init__", 1, 1, 1, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(2, 281, __pyx_L3_error)
9957   __pyx_L3_error:;
9958   __Pyx_AddTraceback("View.MemoryView.Enum.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
9959   __Pyx_RefNannyFinishContext();
9960   return -1;
9961   __pyx_L4_argument_unpacking_done:;
9962   __pyx_r = __pyx_MemviewEnum___pyx_pf_15View_dot_MemoryView_4Enum___init__(((struct __pyx_MemviewEnum_obj *)__pyx_v_self), __pyx_v_name);
9963 
9964   /* function exit code */
9965   __Pyx_RefNannyFinishContext();
9966   return __pyx_r;
9967 }
9968 
__pyx_MemviewEnum___pyx_pf_15View_dot_MemoryView_4Enum___init__(struct __pyx_MemviewEnum_obj * __pyx_v_self,PyObject * __pyx_v_name)9969 static int __pyx_MemviewEnum___pyx_pf_15View_dot_MemoryView_4Enum___init__(struct __pyx_MemviewEnum_obj *__pyx_v_self, PyObject *__pyx_v_name) {
9970   int __pyx_r;
9971   __Pyx_RefNannyDeclarations
9972   __Pyx_RefNannySetupContext("__init__", 0);
9973 
9974   /* "View.MemoryView":282
9975  *     cdef object name
9976  *     def __init__(self, name):
9977  *         self.name = name             # <<<<<<<<<<<<<<
9978  *     def __repr__(self):
9979  *         return self.name
9980  */
9981   __Pyx_INCREF(__pyx_v_name);
9982   __Pyx_GIVEREF(__pyx_v_name);
9983   __Pyx_GOTREF(__pyx_v_self->name);
9984   __Pyx_DECREF(__pyx_v_self->name);
9985   __pyx_v_self->name = __pyx_v_name;
9986 
9987   /* "View.MemoryView":281
9988  * cdef class Enum(object):
9989  *     cdef object name
9990  *     def __init__(self, name):             # <<<<<<<<<<<<<<
9991  *         self.name = name
9992  *     def __repr__(self):
9993  */
9994 
9995   /* function exit code */
9996   __pyx_r = 0;
9997   __Pyx_RefNannyFinishContext();
9998   return __pyx_r;
9999 }
10000 
10001 /* "View.MemoryView":283
10002  *     def __init__(self, name):
10003  *         self.name = name
10004  *     def __repr__(self):             # <<<<<<<<<<<<<<
10005  *         return self.name
10006  *
10007  */
10008 
10009 /* Python wrapper */
10010 static PyObject *__pyx_MemviewEnum___repr__(PyObject *__pyx_v_self); /*proto*/
__pyx_MemviewEnum___repr__(PyObject * __pyx_v_self)10011 static PyObject *__pyx_MemviewEnum___repr__(PyObject *__pyx_v_self) {
10012   PyObject *__pyx_r = 0;
10013   __Pyx_RefNannyDeclarations
10014   __Pyx_RefNannySetupContext("__repr__ (wrapper)", 0);
10015   __pyx_r = __pyx_MemviewEnum___pyx_pf_15View_dot_MemoryView_4Enum_2__repr__(((struct __pyx_MemviewEnum_obj *)__pyx_v_self));
10016 
10017   /* function exit code */
10018   __Pyx_RefNannyFinishContext();
10019   return __pyx_r;
10020 }
10021 
__pyx_MemviewEnum___pyx_pf_15View_dot_MemoryView_4Enum_2__repr__(struct __pyx_MemviewEnum_obj * __pyx_v_self)10022 static PyObject *__pyx_MemviewEnum___pyx_pf_15View_dot_MemoryView_4Enum_2__repr__(struct __pyx_MemviewEnum_obj *__pyx_v_self) {
10023   PyObject *__pyx_r = NULL;
10024   __Pyx_RefNannyDeclarations
10025   __Pyx_RefNannySetupContext("__repr__", 0);
10026 
10027   /* "View.MemoryView":284
10028  *         self.name = name
10029  *     def __repr__(self):
10030  *         return self.name             # <<<<<<<<<<<<<<
10031  *
10032  * cdef generic = Enum("<strided and direct or indirect>")
10033  */
10034   __Pyx_XDECREF(__pyx_r);
10035   __Pyx_INCREF(__pyx_v_self->name);
10036   __pyx_r = __pyx_v_self->name;
10037   goto __pyx_L0;
10038 
10039   /* "View.MemoryView":283
10040  *     def __init__(self, name):
10041  *         self.name = name
10042  *     def __repr__(self):             # <<<<<<<<<<<<<<
10043  *         return self.name
10044  *
10045  */
10046 
10047   /* function exit code */
10048   __pyx_L0:;
10049   __Pyx_XGIVEREF(__pyx_r);
10050   __Pyx_RefNannyFinishContext();
10051   return __pyx_r;
10052 }
10053 
10054 /* "(tree fragment)":1
10055  * def __reduce_cython__(self):             # <<<<<<<<<<<<<<
10056  *     cdef tuple state
10057  *     cdef object _dict
10058  */
10059 
10060 /* Python wrapper */
10061 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)10062 static PyObject *__pyx_pw___pyx_MemviewEnum_1__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
10063   PyObject *__pyx_r = 0;
10064   __Pyx_RefNannyDeclarations
10065   __Pyx_RefNannySetupContext("__reduce_cython__ (wrapper)", 0);
10066   __pyx_r = __pyx_pf___pyx_MemviewEnum___reduce_cython__(((struct __pyx_MemviewEnum_obj *)__pyx_v_self));
10067 
10068   /* function exit code */
10069   __Pyx_RefNannyFinishContext();
10070   return __pyx_r;
10071 }
10072 
__pyx_pf___pyx_MemviewEnum___reduce_cython__(struct __pyx_MemviewEnum_obj * __pyx_v_self)10073 static PyObject *__pyx_pf___pyx_MemviewEnum___reduce_cython__(struct __pyx_MemviewEnum_obj *__pyx_v_self) {
10074   PyObject *__pyx_v_state = 0;
10075   PyObject *__pyx_v__dict = 0;
10076   int __pyx_v_use_setstate;
10077   PyObject *__pyx_r = NULL;
10078   __Pyx_RefNannyDeclarations
10079   PyObject *__pyx_t_1 = NULL;
10080   int __pyx_t_2;
10081   int __pyx_t_3;
10082   PyObject *__pyx_t_4 = NULL;
10083   PyObject *__pyx_t_5 = NULL;
10084   int __pyx_lineno = 0;
10085   const char *__pyx_filename = NULL;
10086   int __pyx_clineno = 0;
10087   __Pyx_RefNannySetupContext("__reduce_cython__", 0);
10088 
10089   /* "(tree fragment)":5
10090  *     cdef object _dict
10091  *     cdef bint use_setstate
10092  *     state = (self.name,)             # <<<<<<<<<<<<<<
10093  *     _dict = getattr(self, '__dict__', None)
10094  *     if _dict is not None:
10095  */
10096   __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 5, __pyx_L1_error)
10097   __Pyx_GOTREF(__pyx_t_1);
10098   __Pyx_INCREF(__pyx_v_self->name);
10099   __Pyx_GIVEREF(__pyx_v_self->name);
10100   PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_self->name);
10101   __pyx_v_state = ((PyObject*)__pyx_t_1);
10102   __pyx_t_1 = 0;
10103 
10104   /* "(tree fragment)":6
10105  *     cdef bint use_setstate
10106  *     state = (self.name,)
10107  *     _dict = getattr(self, '__dict__', None)             # <<<<<<<<<<<<<<
10108  *     if _dict is not None:
10109  *         state += (_dict,)
10110  */
10111   __pyx_t_1 = __Pyx_GetAttr3(((PyObject *)__pyx_v_self), __pyx_n_s_dict, Py_None); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 6, __pyx_L1_error)
10112   __Pyx_GOTREF(__pyx_t_1);
10113   __pyx_v__dict = __pyx_t_1;
10114   __pyx_t_1 = 0;
10115 
10116   /* "(tree fragment)":7
10117  *     state = (self.name,)
10118  *     _dict = getattr(self, '__dict__', None)
10119  *     if _dict is not None:             # <<<<<<<<<<<<<<
10120  *         state += (_dict,)
10121  *         use_setstate = True
10122  */
10123   __pyx_t_2 = (__pyx_v__dict != Py_None);
10124   __pyx_t_3 = (__pyx_t_2 != 0);
10125   if (__pyx_t_3) {
10126 
10127     /* "(tree fragment)":8
10128  *     _dict = getattr(self, '__dict__', None)
10129  *     if _dict is not None:
10130  *         state += (_dict,)             # <<<<<<<<<<<<<<
10131  *         use_setstate = True
10132  *     else:
10133  */
10134     __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 8, __pyx_L1_error)
10135     __Pyx_GOTREF(__pyx_t_1);
10136     __Pyx_INCREF(__pyx_v__dict);
10137     __Pyx_GIVEREF(__pyx_v__dict);
10138     PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v__dict);
10139     __pyx_t_4 = PyNumber_InPlaceAdd(__pyx_v_state, __pyx_t_1); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 8, __pyx_L1_error)
10140     __Pyx_GOTREF(__pyx_t_4);
10141     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
10142     __Pyx_DECREF_SET(__pyx_v_state, ((PyObject*)__pyx_t_4));
10143     __pyx_t_4 = 0;
10144 
10145     /* "(tree fragment)":9
10146  *     if _dict is not None:
10147  *         state += (_dict,)
10148  *         use_setstate = True             # <<<<<<<<<<<<<<
10149  *     else:
10150  *         use_setstate = self.name is not None
10151  */
10152     __pyx_v_use_setstate = 1;
10153 
10154     /* "(tree fragment)":7
10155  *     state = (self.name,)
10156  *     _dict = getattr(self, '__dict__', None)
10157  *     if _dict is not None:             # <<<<<<<<<<<<<<
10158  *         state += (_dict,)
10159  *         use_setstate = True
10160  */
10161     goto __pyx_L3;
10162   }
10163 
10164   /* "(tree fragment)":11
10165  *         use_setstate = True
10166  *     else:
10167  *         use_setstate = self.name is not None             # <<<<<<<<<<<<<<
10168  *     if use_setstate:
10169  *         return __pyx_unpickle_Enum, (type(self), 0xb068931, None), state
10170  */
10171   /*else*/ {
10172     __pyx_t_3 = (__pyx_v_self->name != Py_None);
10173     __pyx_v_use_setstate = __pyx_t_3;
10174   }
10175   __pyx_L3:;
10176 
10177   /* "(tree fragment)":12
10178  *     else:
10179  *         use_setstate = self.name is not None
10180  *     if use_setstate:             # <<<<<<<<<<<<<<
10181  *         return __pyx_unpickle_Enum, (type(self), 0xb068931, None), state
10182  *     else:
10183  */
10184   __pyx_t_3 = (__pyx_v_use_setstate != 0);
10185   if (__pyx_t_3) {
10186 
10187     /* "(tree fragment)":13
10188  *         use_setstate = self.name is not None
10189  *     if use_setstate:
10190  *         return __pyx_unpickle_Enum, (type(self), 0xb068931, None), state             # <<<<<<<<<<<<<<
10191  *     else:
10192  *         return __pyx_unpickle_Enum, (type(self), 0xb068931, state)
10193  */
10194     __Pyx_XDECREF(__pyx_r);
10195     __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_pyx_unpickle_Enum); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 13, __pyx_L1_error)
10196     __Pyx_GOTREF(__pyx_t_4);
10197     __pyx_t_1 = PyTuple_New(3); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 13, __pyx_L1_error)
10198     __Pyx_GOTREF(__pyx_t_1);
10199     __Pyx_INCREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
10200     __Pyx_GIVEREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
10201     PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
10202     __Pyx_INCREF(__pyx_int_184977713);
10203     __Pyx_GIVEREF(__pyx_int_184977713);
10204     PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_int_184977713);
10205     __Pyx_INCREF(Py_None);
10206     __Pyx_GIVEREF(Py_None);
10207     PyTuple_SET_ITEM(__pyx_t_1, 2, Py_None);
10208     __pyx_t_5 = PyTuple_New(3); if (unlikely(!__pyx_t_5)) __PYX_ERR(2, 13, __pyx_L1_error)
10209     __Pyx_GOTREF(__pyx_t_5);
10210     __Pyx_GIVEREF(__pyx_t_4);
10211     PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_4);
10212     __Pyx_GIVEREF(__pyx_t_1);
10213     PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_t_1);
10214     __Pyx_INCREF(__pyx_v_state);
10215     __Pyx_GIVEREF(__pyx_v_state);
10216     PyTuple_SET_ITEM(__pyx_t_5, 2, __pyx_v_state);
10217     __pyx_t_4 = 0;
10218     __pyx_t_1 = 0;
10219     __pyx_r = __pyx_t_5;
10220     __pyx_t_5 = 0;
10221     goto __pyx_L0;
10222 
10223     /* "(tree fragment)":12
10224  *     else:
10225  *         use_setstate = self.name is not None
10226  *     if use_setstate:             # <<<<<<<<<<<<<<
10227  *         return __pyx_unpickle_Enum, (type(self), 0xb068931, None), state
10228  *     else:
10229  */
10230   }
10231 
10232   /* "(tree fragment)":15
10233  *         return __pyx_unpickle_Enum, (type(self), 0xb068931, None), state
10234  *     else:
10235  *         return __pyx_unpickle_Enum, (type(self), 0xb068931, state)             # <<<<<<<<<<<<<<
10236  * def __setstate_cython__(self, __pyx_state):
10237  *     __pyx_unpickle_Enum__set_state(self, __pyx_state)
10238  */
10239   /*else*/ {
10240     __Pyx_XDECREF(__pyx_r);
10241     __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_n_s_pyx_unpickle_Enum); if (unlikely(!__pyx_t_5)) __PYX_ERR(2, 15, __pyx_L1_error)
10242     __Pyx_GOTREF(__pyx_t_5);
10243     __pyx_t_1 = PyTuple_New(3); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 15, __pyx_L1_error)
10244     __Pyx_GOTREF(__pyx_t_1);
10245     __Pyx_INCREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
10246     __Pyx_GIVEREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
10247     PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
10248     __Pyx_INCREF(__pyx_int_184977713);
10249     __Pyx_GIVEREF(__pyx_int_184977713);
10250     PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_int_184977713);
10251     __Pyx_INCREF(__pyx_v_state);
10252     __Pyx_GIVEREF(__pyx_v_state);
10253     PyTuple_SET_ITEM(__pyx_t_1, 2, __pyx_v_state);
10254     __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 15, __pyx_L1_error)
10255     __Pyx_GOTREF(__pyx_t_4);
10256     __Pyx_GIVEREF(__pyx_t_5);
10257     PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_5);
10258     __Pyx_GIVEREF(__pyx_t_1);
10259     PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_1);
10260     __pyx_t_5 = 0;
10261     __pyx_t_1 = 0;
10262     __pyx_r = __pyx_t_4;
10263     __pyx_t_4 = 0;
10264     goto __pyx_L0;
10265   }
10266 
10267   /* "(tree fragment)":1
10268  * def __reduce_cython__(self):             # <<<<<<<<<<<<<<
10269  *     cdef tuple state
10270  *     cdef object _dict
10271  */
10272 
10273   /* function exit code */
10274   __pyx_L1_error:;
10275   __Pyx_XDECREF(__pyx_t_1);
10276   __Pyx_XDECREF(__pyx_t_4);
10277   __Pyx_XDECREF(__pyx_t_5);
10278   __Pyx_AddTraceback("View.MemoryView.Enum.__reduce_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename);
10279   __pyx_r = NULL;
10280   __pyx_L0:;
10281   __Pyx_XDECREF(__pyx_v_state);
10282   __Pyx_XDECREF(__pyx_v__dict);
10283   __Pyx_XGIVEREF(__pyx_r);
10284   __Pyx_RefNannyFinishContext();
10285   return __pyx_r;
10286 }
10287 
10288 /* "(tree fragment)":16
10289  *     else:
10290  *         return __pyx_unpickle_Enum, (type(self), 0xb068931, state)
10291  * def __setstate_cython__(self, __pyx_state):             # <<<<<<<<<<<<<<
10292  *     __pyx_unpickle_Enum__set_state(self, __pyx_state)
10293  */
10294 
10295 /* Python wrapper */
10296 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)10297 static PyObject *__pyx_pw___pyx_MemviewEnum_3__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state) {
10298   PyObject *__pyx_r = 0;
10299   __Pyx_RefNannyDeclarations
10300   __Pyx_RefNannySetupContext("__setstate_cython__ (wrapper)", 0);
10301   __pyx_r = __pyx_pf___pyx_MemviewEnum_2__setstate_cython__(((struct __pyx_MemviewEnum_obj *)__pyx_v_self), ((PyObject *)__pyx_v___pyx_state));
10302 
10303   /* function exit code */
10304   __Pyx_RefNannyFinishContext();
10305   return __pyx_r;
10306 }
10307 
__pyx_pf___pyx_MemviewEnum_2__setstate_cython__(struct __pyx_MemviewEnum_obj * __pyx_v_self,PyObject * __pyx_v___pyx_state)10308 static PyObject *__pyx_pf___pyx_MemviewEnum_2__setstate_cython__(struct __pyx_MemviewEnum_obj *__pyx_v_self, PyObject *__pyx_v___pyx_state) {
10309   PyObject *__pyx_r = NULL;
10310   __Pyx_RefNannyDeclarations
10311   PyObject *__pyx_t_1 = NULL;
10312   int __pyx_lineno = 0;
10313   const char *__pyx_filename = NULL;
10314   int __pyx_clineno = 0;
10315   __Pyx_RefNannySetupContext("__setstate_cython__", 0);
10316 
10317   /* "(tree fragment)":17
10318  *         return __pyx_unpickle_Enum, (type(self), 0xb068931, state)
10319  * def __setstate_cython__(self, __pyx_state):
10320  *     __pyx_unpickle_Enum__set_state(self, __pyx_state)             # <<<<<<<<<<<<<<
10321  */
10322   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(2, 17, __pyx_L1_error)
10323   __pyx_t_1 = __pyx_unpickle_Enum__set_state(__pyx_v_self, ((PyObject*)__pyx_v___pyx_state)); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 17, __pyx_L1_error)
10324   __Pyx_GOTREF(__pyx_t_1);
10325   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
10326 
10327   /* "(tree fragment)":16
10328  *     else:
10329  *         return __pyx_unpickle_Enum, (type(self), 0xb068931, state)
10330  * def __setstate_cython__(self, __pyx_state):             # <<<<<<<<<<<<<<
10331  *     __pyx_unpickle_Enum__set_state(self, __pyx_state)
10332  */
10333 
10334   /* function exit code */
10335   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
10336   goto __pyx_L0;
10337   __pyx_L1_error:;
10338   __Pyx_XDECREF(__pyx_t_1);
10339   __Pyx_AddTraceback("View.MemoryView.Enum.__setstate_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename);
10340   __pyx_r = NULL;
10341   __pyx_L0:;
10342   __Pyx_XGIVEREF(__pyx_r);
10343   __Pyx_RefNannyFinishContext();
10344   return __pyx_r;
10345 }
10346 
10347 /* "View.MemoryView":298
10348  *
10349  * @cname('__pyx_align_pointer')
10350  * cdef void *align_pointer(void *memory, size_t alignment) nogil:             # <<<<<<<<<<<<<<
10351  *     "Align pointer memory on a given boundary"
10352  *     cdef Py_intptr_t aligned_p = <Py_intptr_t> memory
10353  */
10354 
__pyx_align_pointer(void * __pyx_v_memory,size_t __pyx_v_alignment)10355 static void *__pyx_align_pointer(void *__pyx_v_memory, size_t __pyx_v_alignment) {
10356   Py_intptr_t __pyx_v_aligned_p;
10357   size_t __pyx_v_offset;
10358   void *__pyx_r;
10359   int __pyx_t_1;
10360 
10361   /* "View.MemoryView":300
10362  * cdef void *align_pointer(void *memory, size_t alignment) nogil:
10363  *     "Align pointer memory on a given boundary"
10364  *     cdef Py_intptr_t aligned_p = <Py_intptr_t> memory             # <<<<<<<<<<<<<<
10365  *     cdef size_t offset
10366  *
10367  */
10368   __pyx_v_aligned_p = ((Py_intptr_t)__pyx_v_memory);
10369 
10370   /* "View.MemoryView":304
10371  *
10372  *     with cython.cdivision(True):
10373  *         offset = aligned_p % alignment             # <<<<<<<<<<<<<<
10374  *
10375  *     if offset > 0:
10376  */
10377   __pyx_v_offset = (__pyx_v_aligned_p % __pyx_v_alignment);
10378 
10379   /* "View.MemoryView":306
10380  *         offset = aligned_p % alignment
10381  *
10382  *     if offset > 0:             # <<<<<<<<<<<<<<
10383  *         aligned_p += alignment - offset
10384  *
10385  */
10386   __pyx_t_1 = ((__pyx_v_offset > 0) != 0);
10387   if (__pyx_t_1) {
10388 
10389     /* "View.MemoryView":307
10390  *
10391  *     if offset > 0:
10392  *         aligned_p += alignment - offset             # <<<<<<<<<<<<<<
10393  *
10394  *     return <void *> aligned_p
10395  */
10396     __pyx_v_aligned_p = (__pyx_v_aligned_p + (__pyx_v_alignment - __pyx_v_offset));
10397 
10398     /* "View.MemoryView":306
10399  *         offset = aligned_p % alignment
10400  *
10401  *     if offset > 0:             # <<<<<<<<<<<<<<
10402  *         aligned_p += alignment - offset
10403  *
10404  */
10405   }
10406 
10407   /* "View.MemoryView":309
10408  *         aligned_p += alignment - offset
10409  *
10410  *     return <void *> aligned_p             # <<<<<<<<<<<<<<
10411  *
10412  *
10413  */
10414   __pyx_r = ((void *)__pyx_v_aligned_p);
10415   goto __pyx_L0;
10416 
10417   /* "View.MemoryView":298
10418  *
10419  * @cname('__pyx_align_pointer')
10420  * cdef void *align_pointer(void *memory, size_t alignment) nogil:             # <<<<<<<<<<<<<<
10421  *     "Align pointer memory on a given boundary"
10422  *     cdef Py_intptr_t aligned_p = <Py_intptr_t> memory
10423  */
10424 
10425   /* function exit code */
10426   __pyx_L0:;
10427   return __pyx_r;
10428 }
10429 
10430 /* "View.MemoryView":345
10431  *     cdef __Pyx_TypeInfo *typeinfo
10432  *
10433  *     def __cinit__(memoryview self, object obj, int flags, bint dtype_is_object=False):             # <<<<<<<<<<<<<<
10434  *         self.obj = obj
10435  *         self.flags = flags
10436  */
10437 
10438 /* Python wrapper */
10439 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)10440 static int __pyx_memoryview___cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
10441   PyObject *__pyx_v_obj = 0;
10442   int __pyx_v_flags;
10443   int __pyx_v_dtype_is_object;
10444   int __pyx_lineno = 0;
10445   const char *__pyx_filename = NULL;
10446   int __pyx_clineno = 0;
10447   int __pyx_r;
10448   __Pyx_RefNannyDeclarations
10449   __Pyx_RefNannySetupContext("__cinit__ (wrapper)", 0);
10450   {
10451     static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_obj,&__pyx_n_s_flags,&__pyx_n_s_dtype_is_object,0};
10452     PyObject* values[3] = {0,0,0};
10453     if (unlikely(__pyx_kwds)) {
10454       Py_ssize_t kw_args;
10455       const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
10456       switch (pos_args) {
10457         case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
10458         CYTHON_FALLTHROUGH;
10459         case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
10460         CYTHON_FALLTHROUGH;
10461         case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
10462         CYTHON_FALLTHROUGH;
10463         case  0: break;
10464         default: goto __pyx_L5_argtuple_error;
10465       }
10466       kw_args = PyDict_Size(__pyx_kwds);
10467       switch (pos_args) {
10468         case  0:
10469         if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_obj)) != 0)) kw_args--;
10470         else goto __pyx_L5_argtuple_error;
10471         CYTHON_FALLTHROUGH;
10472         case  1:
10473         if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_flags)) != 0)) kw_args--;
10474         else {
10475           __Pyx_RaiseArgtupleInvalid("__cinit__", 0, 2, 3, 1); __PYX_ERR(2, 345, __pyx_L3_error)
10476         }
10477         CYTHON_FALLTHROUGH;
10478         case  2:
10479         if (kw_args > 0) {
10480           PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_dtype_is_object);
10481           if (value) { values[2] = value; kw_args--; }
10482         }
10483       }
10484       if (unlikely(kw_args > 0)) {
10485         if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__cinit__") < 0)) __PYX_ERR(2, 345, __pyx_L3_error)
10486       }
10487     } else {
10488       switch (PyTuple_GET_SIZE(__pyx_args)) {
10489         case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
10490         CYTHON_FALLTHROUGH;
10491         case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
10492         values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
10493         break;
10494         default: goto __pyx_L5_argtuple_error;
10495       }
10496     }
10497     __pyx_v_obj = values[0];
10498     __pyx_v_flags = __Pyx_PyInt_As_int(values[1]); if (unlikely((__pyx_v_flags == (int)-1) && PyErr_Occurred())) __PYX_ERR(2, 345, __pyx_L3_error)
10499     if (values[2]) {
10500       __pyx_v_dtype_is_object = __Pyx_PyObject_IsTrue(values[2]); if (unlikely((__pyx_v_dtype_is_object == (int)-1) && PyErr_Occurred())) __PYX_ERR(2, 345, __pyx_L3_error)
10501     } else {
10502       __pyx_v_dtype_is_object = ((int)0);
10503     }
10504   }
10505   goto __pyx_L4_argument_unpacking_done;
10506   __pyx_L5_argtuple_error:;
10507   __Pyx_RaiseArgtupleInvalid("__cinit__", 0, 2, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(2, 345, __pyx_L3_error)
10508   __pyx_L3_error:;
10509   __Pyx_AddTraceback("View.MemoryView.memoryview.__cinit__", __pyx_clineno, __pyx_lineno, __pyx_filename);
10510   __Pyx_RefNannyFinishContext();
10511   return -1;
10512   __pyx_L4_argument_unpacking_done:;
10513   __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);
10514 
10515   /* function exit code */
10516   __Pyx_RefNannyFinishContext();
10517   return __pyx_r;
10518 }
10519 
__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)10520 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) {
10521   int __pyx_r;
10522   __Pyx_RefNannyDeclarations
10523   int __pyx_t_1;
10524   int __pyx_t_2;
10525   int __pyx_t_3;
10526   int __pyx_t_4;
10527   int __pyx_lineno = 0;
10528   const char *__pyx_filename = NULL;
10529   int __pyx_clineno = 0;
10530   __Pyx_RefNannySetupContext("__cinit__", 0);
10531 
10532   /* "View.MemoryView":346
10533  *
10534  *     def __cinit__(memoryview self, object obj, int flags, bint dtype_is_object=False):
10535  *         self.obj = obj             # <<<<<<<<<<<<<<
10536  *         self.flags = flags
10537  *         if type(self) is memoryview or obj is not None:
10538  */
10539   __Pyx_INCREF(__pyx_v_obj);
10540   __Pyx_GIVEREF(__pyx_v_obj);
10541   __Pyx_GOTREF(__pyx_v_self->obj);
10542   __Pyx_DECREF(__pyx_v_self->obj);
10543   __pyx_v_self->obj = __pyx_v_obj;
10544 
10545   /* "View.MemoryView":347
10546  *     def __cinit__(memoryview self, object obj, int flags, bint dtype_is_object=False):
10547  *         self.obj = obj
10548  *         self.flags = flags             # <<<<<<<<<<<<<<
10549  *         if type(self) is memoryview or obj is not None:
10550  *             __Pyx_GetBuffer(obj, &self.view, flags)
10551  */
10552   __pyx_v_self->flags = __pyx_v_flags;
10553 
10554   /* "View.MemoryView":348
10555  *         self.obj = obj
10556  *         self.flags = flags
10557  *         if type(self) is memoryview or obj is not None:             # <<<<<<<<<<<<<<
10558  *             __Pyx_GetBuffer(obj, &self.view, flags)
10559  *             if <PyObject *> self.view.obj == NULL:
10560  */
10561   __pyx_t_2 = (((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))) == ((PyObject *)__pyx_memoryview_type));
10562   __pyx_t_3 = (__pyx_t_2 != 0);
10563   if (!__pyx_t_3) {
10564   } else {
10565     __pyx_t_1 = __pyx_t_3;
10566     goto __pyx_L4_bool_binop_done;
10567   }
10568   __pyx_t_3 = (__pyx_v_obj != Py_None);
10569   __pyx_t_2 = (__pyx_t_3 != 0);
10570   __pyx_t_1 = __pyx_t_2;
10571   __pyx_L4_bool_binop_done:;
10572   if (__pyx_t_1) {
10573 
10574     /* "View.MemoryView":349
10575  *         self.flags = flags
10576  *         if type(self) is memoryview or obj is not None:
10577  *             __Pyx_GetBuffer(obj, &self.view, flags)             # <<<<<<<<<<<<<<
10578  *             if <PyObject *> self.view.obj == NULL:
10579  *                 (<__pyx_buffer *> &self.view).obj = Py_None
10580  */
10581     __pyx_t_4 = __Pyx_GetBuffer(__pyx_v_obj, (&__pyx_v_self->view), __pyx_v_flags); if (unlikely(__pyx_t_4 == ((int)-1))) __PYX_ERR(2, 349, __pyx_L1_error)
10582 
10583     /* "View.MemoryView":350
10584  *         if type(self) is memoryview or obj is not None:
10585  *             __Pyx_GetBuffer(obj, &self.view, flags)
10586  *             if <PyObject *> self.view.obj == NULL:             # <<<<<<<<<<<<<<
10587  *                 (<__pyx_buffer *> &self.view).obj = Py_None
10588  *                 Py_INCREF(Py_None)
10589  */
10590     __pyx_t_1 = ((((PyObject *)__pyx_v_self->view.obj) == NULL) != 0);
10591     if (__pyx_t_1) {
10592 
10593       /* "View.MemoryView":351
10594  *             __Pyx_GetBuffer(obj, &self.view, flags)
10595  *             if <PyObject *> self.view.obj == NULL:
10596  *                 (<__pyx_buffer *> &self.view).obj = Py_None             # <<<<<<<<<<<<<<
10597  *                 Py_INCREF(Py_None)
10598  *
10599  */
10600       ((Py_buffer *)(&__pyx_v_self->view))->obj = Py_None;
10601 
10602       /* "View.MemoryView":352
10603  *             if <PyObject *> self.view.obj == NULL:
10604  *                 (<__pyx_buffer *> &self.view).obj = Py_None
10605  *                 Py_INCREF(Py_None)             # <<<<<<<<<<<<<<
10606  *
10607  *         global __pyx_memoryview_thread_locks_used
10608  */
10609       Py_INCREF(Py_None);
10610 
10611       /* "View.MemoryView":350
10612  *         if type(self) is memoryview or obj is not None:
10613  *             __Pyx_GetBuffer(obj, &self.view, flags)
10614  *             if <PyObject *> self.view.obj == NULL:             # <<<<<<<<<<<<<<
10615  *                 (<__pyx_buffer *> &self.view).obj = Py_None
10616  *                 Py_INCREF(Py_None)
10617  */
10618     }
10619 
10620     /* "View.MemoryView":348
10621  *         self.obj = obj
10622  *         self.flags = flags
10623  *         if type(self) is memoryview or obj is not None:             # <<<<<<<<<<<<<<
10624  *             __Pyx_GetBuffer(obj, &self.view, flags)
10625  *             if <PyObject *> self.view.obj == NULL:
10626  */
10627   }
10628 
10629   /* "View.MemoryView":355
10630  *
10631  *         global __pyx_memoryview_thread_locks_used
10632  *         if __pyx_memoryview_thread_locks_used < THREAD_LOCKS_PREALLOCATED:             # <<<<<<<<<<<<<<
10633  *             self.lock = __pyx_memoryview_thread_locks[__pyx_memoryview_thread_locks_used]
10634  *             __pyx_memoryview_thread_locks_used += 1
10635  */
10636   __pyx_t_1 = ((__pyx_memoryview_thread_locks_used < 8) != 0);
10637   if (__pyx_t_1) {
10638 
10639     /* "View.MemoryView":356
10640  *         global __pyx_memoryview_thread_locks_used
10641  *         if __pyx_memoryview_thread_locks_used < THREAD_LOCKS_PREALLOCATED:
10642  *             self.lock = __pyx_memoryview_thread_locks[__pyx_memoryview_thread_locks_used]             # <<<<<<<<<<<<<<
10643  *             __pyx_memoryview_thread_locks_used += 1
10644  *         if self.lock is NULL:
10645  */
10646     __pyx_v_self->lock = (__pyx_memoryview_thread_locks[__pyx_memoryview_thread_locks_used]);
10647 
10648     /* "View.MemoryView":357
10649  *         if __pyx_memoryview_thread_locks_used < THREAD_LOCKS_PREALLOCATED:
10650  *             self.lock = __pyx_memoryview_thread_locks[__pyx_memoryview_thread_locks_used]
10651  *             __pyx_memoryview_thread_locks_used += 1             # <<<<<<<<<<<<<<
10652  *         if self.lock is NULL:
10653  *             self.lock = PyThread_allocate_lock()
10654  */
10655     __pyx_memoryview_thread_locks_used = (__pyx_memoryview_thread_locks_used + 1);
10656 
10657     /* "View.MemoryView":355
10658  *
10659  *         global __pyx_memoryview_thread_locks_used
10660  *         if __pyx_memoryview_thread_locks_used < THREAD_LOCKS_PREALLOCATED:             # <<<<<<<<<<<<<<
10661  *             self.lock = __pyx_memoryview_thread_locks[__pyx_memoryview_thread_locks_used]
10662  *             __pyx_memoryview_thread_locks_used += 1
10663  */
10664   }
10665 
10666   /* "View.MemoryView":358
10667  *             self.lock = __pyx_memoryview_thread_locks[__pyx_memoryview_thread_locks_used]
10668  *             __pyx_memoryview_thread_locks_used += 1
10669  *         if self.lock is NULL:             # <<<<<<<<<<<<<<
10670  *             self.lock = PyThread_allocate_lock()
10671  *             if self.lock is NULL:
10672  */
10673   __pyx_t_1 = ((__pyx_v_self->lock == NULL) != 0);
10674   if (__pyx_t_1) {
10675 
10676     /* "View.MemoryView":359
10677  *             __pyx_memoryview_thread_locks_used += 1
10678  *         if self.lock is NULL:
10679  *             self.lock = PyThread_allocate_lock()             # <<<<<<<<<<<<<<
10680  *             if self.lock is NULL:
10681  *                 raise MemoryError
10682  */
10683     __pyx_v_self->lock = PyThread_allocate_lock();
10684 
10685     /* "View.MemoryView":360
10686  *         if self.lock is NULL:
10687  *             self.lock = PyThread_allocate_lock()
10688  *             if self.lock is NULL:             # <<<<<<<<<<<<<<
10689  *                 raise MemoryError
10690  *
10691  */
10692     __pyx_t_1 = ((__pyx_v_self->lock == NULL) != 0);
10693     if (unlikely(__pyx_t_1)) {
10694 
10695       /* "View.MemoryView":361
10696  *             self.lock = PyThread_allocate_lock()
10697  *             if self.lock is NULL:
10698  *                 raise MemoryError             # <<<<<<<<<<<<<<
10699  *
10700  *         if flags & PyBUF_FORMAT:
10701  */
10702       PyErr_NoMemory(); __PYX_ERR(2, 361, __pyx_L1_error)
10703 
10704       /* "View.MemoryView":360
10705  *         if self.lock is NULL:
10706  *             self.lock = PyThread_allocate_lock()
10707  *             if self.lock is NULL:             # <<<<<<<<<<<<<<
10708  *                 raise MemoryError
10709  *
10710  */
10711     }
10712 
10713     /* "View.MemoryView":358
10714  *             self.lock = __pyx_memoryview_thread_locks[__pyx_memoryview_thread_locks_used]
10715  *             __pyx_memoryview_thread_locks_used += 1
10716  *         if self.lock is NULL:             # <<<<<<<<<<<<<<
10717  *             self.lock = PyThread_allocate_lock()
10718  *             if self.lock is NULL:
10719  */
10720   }
10721 
10722   /* "View.MemoryView":363
10723  *                 raise MemoryError
10724  *
10725  *         if flags & PyBUF_FORMAT:             # <<<<<<<<<<<<<<
10726  *             self.dtype_is_object = (self.view.format[0] == b'O' and self.view.format[1] == b'\0')
10727  *         else:
10728  */
10729   __pyx_t_1 = ((__pyx_v_flags & PyBUF_FORMAT) != 0);
10730   if (__pyx_t_1) {
10731 
10732     /* "View.MemoryView":364
10733  *
10734  *         if flags & PyBUF_FORMAT:
10735  *             self.dtype_is_object = (self.view.format[0] == b'O' and self.view.format[1] == b'\0')             # <<<<<<<<<<<<<<
10736  *         else:
10737  *             self.dtype_is_object = dtype_is_object
10738  */
10739     __pyx_t_2 = (((__pyx_v_self->view.format[0]) == 'O') != 0);
10740     if (__pyx_t_2) {
10741     } else {
10742       __pyx_t_1 = __pyx_t_2;
10743       goto __pyx_L11_bool_binop_done;
10744     }
10745     __pyx_t_2 = (((__pyx_v_self->view.format[1]) == '\x00') != 0);
10746     __pyx_t_1 = __pyx_t_2;
10747     __pyx_L11_bool_binop_done:;
10748     __pyx_v_self->dtype_is_object = __pyx_t_1;
10749 
10750     /* "View.MemoryView":363
10751  *                 raise MemoryError
10752  *
10753  *         if flags & PyBUF_FORMAT:             # <<<<<<<<<<<<<<
10754  *             self.dtype_is_object = (self.view.format[0] == b'O' and self.view.format[1] == b'\0')
10755  *         else:
10756  */
10757     goto __pyx_L10;
10758   }
10759 
10760   /* "View.MemoryView":366
10761  *             self.dtype_is_object = (self.view.format[0] == b'O' and self.view.format[1] == b'\0')
10762  *         else:
10763  *             self.dtype_is_object = dtype_is_object             # <<<<<<<<<<<<<<
10764  *
10765  *         self.acquisition_count_aligned_p = <__pyx_atomic_int *> align_pointer(
10766  */
10767   /*else*/ {
10768     __pyx_v_self->dtype_is_object = __pyx_v_dtype_is_object;
10769   }
10770   __pyx_L10:;
10771 
10772   /* "View.MemoryView":368
10773  *             self.dtype_is_object = dtype_is_object
10774  *
10775  *         self.acquisition_count_aligned_p = <__pyx_atomic_int *> align_pointer(             # <<<<<<<<<<<<<<
10776  *                   <void *> &self.acquisition_count[0], sizeof(__pyx_atomic_int))
10777  *         self.typeinfo = NULL
10778  */
10779   __pyx_v_self->acquisition_count_aligned_p = ((__pyx_atomic_int *)__pyx_align_pointer(((void *)(&(__pyx_v_self->acquisition_count[0]))), (sizeof(__pyx_atomic_int))));
10780 
10781   /* "View.MemoryView":370
10782  *         self.acquisition_count_aligned_p = <__pyx_atomic_int *> align_pointer(
10783  *                   <void *> &self.acquisition_count[0], sizeof(__pyx_atomic_int))
10784  *         self.typeinfo = NULL             # <<<<<<<<<<<<<<
10785  *
10786  *     def __dealloc__(memoryview self):
10787  */
10788   __pyx_v_self->typeinfo = NULL;
10789 
10790   /* "View.MemoryView":345
10791  *     cdef __Pyx_TypeInfo *typeinfo
10792  *
10793  *     def __cinit__(memoryview self, object obj, int flags, bint dtype_is_object=False):             # <<<<<<<<<<<<<<
10794  *         self.obj = obj
10795  *         self.flags = flags
10796  */
10797 
10798   /* function exit code */
10799   __pyx_r = 0;
10800   goto __pyx_L0;
10801   __pyx_L1_error:;
10802   __Pyx_AddTraceback("View.MemoryView.memoryview.__cinit__", __pyx_clineno, __pyx_lineno, __pyx_filename);
10803   __pyx_r = -1;
10804   __pyx_L0:;
10805   __Pyx_RefNannyFinishContext();
10806   return __pyx_r;
10807 }
10808 
10809 /* "View.MemoryView":372
10810  *         self.typeinfo = NULL
10811  *
10812  *     def __dealloc__(memoryview self):             # <<<<<<<<<<<<<<
10813  *         if self.obj is not None:
10814  *             __Pyx_ReleaseBuffer(&self.view)
10815  */
10816 
10817 /* Python wrapper */
10818 static void __pyx_memoryview___dealloc__(PyObject *__pyx_v_self); /*proto*/
__pyx_memoryview___dealloc__(PyObject * __pyx_v_self)10819 static void __pyx_memoryview___dealloc__(PyObject *__pyx_v_self) {
10820   __Pyx_RefNannyDeclarations
10821   __Pyx_RefNannySetupContext("__dealloc__ (wrapper)", 0);
10822   __pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_2__dealloc__(((struct __pyx_memoryview_obj *)__pyx_v_self));
10823 
10824   /* function exit code */
10825   __Pyx_RefNannyFinishContext();
10826 }
10827 
__pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_2__dealloc__(struct __pyx_memoryview_obj * __pyx_v_self)10828 static void __pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_2__dealloc__(struct __pyx_memoryview_obj *__pyx_v_self) {
10829   int __pyx_v_i;
10830   __Pyx_RefNannyDeclarations
10831   int __pyx_t_1;
10832   int __pyx_t_2;
10833   int __pyx_t_3;
10834   int __pyx_t_4;
10835   int __pyx_t_5;
10836   PyThread_type_lock __pyx_t_6;
10837   PyThread_type_lock __pyx_t_7;
10838   __Pyx_RefNannySetupContext("__dealloc__", 0);
10839 
10840   /* "View.MemoryView":373
10841  *
10842  *     def __dealloc__(memoryview self):
10843  *         if self.obj is not None:             # <<<<<<<<<<<<<<
10844  *             __Pyx_ReleaseBuffer(&self.view)
10845  *         elif (<__pyx_buffer *> &self.view).obj == Py_None:
10846  */
10847   __pyx_t_1 = (__pyx_v_self->obj != Py_None);
10848   __pyx_t_2 = (__pyx_t_1 != 0);
10849   if (__pyx_t_2) {
10850 
10851     /* "View.MemoryView":374
10852  *     def __dealloc__(memoryview self):
10853  *         if self.obj is not None:
10854  *             __Pyx_ReleaseBuffer(&self.view)             # <<<<<<<<<<<<<<
10855  *         elif (<__pyx_buffer *> &self.view).obj == Py_None:
10856  *
10857  */
10858     __Pyx_ReleaseBuffer((&__pyx_v_self->view));
10859 
10860     /* "View.MemoryView":373
10861  *
10862  *     def __dealloc__(memoryview self):
10863  *         if self.obj is not None:             # <<<<<<<<<<<<<<
10864  *             __Pyx_ReleaseBuffer(&self.view)
10865  *         elif (<__pyx_buffer *> &self.view).obj == Py_None:
10866  */
10867     goto __pyx_L3;
10868   }
10869 
10870   /* "View.MemoryView":375
10871  *         if self.obj is not None:
10872  *             __Pyx_ReleaseBuffer(&self.view)
10873  *         elif (<__pyx_buffer *> &self.view).obj == Py_None:             # <<<<<<<<<<<<<<
10874  *
10875  *             (<__pyx_buffer *> &self.view).obj = NULL
10876  */
10877   __pyx_t_2 = ((((Py_buffer *)(&__pyx_v_self->view))->obj == Py_None) != 0);
10878   if (__pyx_t_2) {
10879 
10880     /* "View.MemoryView":377
10881  *         elif (<__pyx_buffer *> &self.view).obj == Py_None:
10882  *
10883  *             (<__pyx_buffer *> &self.view).obj = NULL             # <<<<<<<<<<<<<<
10884  *             Py_DECREF(Py_None)
10885  *
10886  */
10887     ((Py_buffer *)(&__pyx_v_self->view))->obj = NULL;
10888 
10889     /* "View.MemoryView":378
10890  *
10891  *             (<__pyx_buffer *> &self.view).obj = NULL
10892  *             Py_DECREF(Py_None)             # <<<<<<<<<<<<<<
10893  *
10894  *         cdef int i
10895  */
10896     Py_DECREF(Py_None);
10897 
10898     /* "View.MemoryView":375
10899  *         if self.obj is not None:
10900  *             __Pyx_ReleaseBuffer(&self.view)
10901  *         elif (<__pyx_buffer *> &self.view).obj == Py_None:             # <<<<<<<<<<<<<<
10902  *
10903  *             (<__pyx_buffer *> &self.view).obj = NULL
10904  */
10905   }
10906   __pyx_L3:;
10907 
10908   /* "View.MemoryView":382
10909  *         cdef int i
10910  *         global __pyx_memoryview_thread_locks_used
10911  *         if self.lock != NULL:             # <<<<<<<<<<<<<<
10912  *             for i in range(__pyx_memoryview_thread_locks_used):
10913  *                 if __pyx_memoryview_thread_locks[i] is self.lock:
10914  */
10915   __pyx_t_2 = ((__pyx_v_self->lock != NULL) != 0);
10916   if (__pyx_t_2) {
10917 
10918     /* "View.MemoryView":383
10919  *         global __pyx_memoryview_thread_locks_used
10920  *         if self.lock != NULL:
10921  *             for i in range(__pyx_memoryview_thread_locks_used):             # <<<<<<<<<<<<<<
10922  *                 if __pyx_memoryview_thread_locks[i] is self.lock:
10923  *                     __pyx_memoryview_thread_locks_used -= 1
10924  */
10925     __pyx_t_3 = __pyx_memoryview_thread_locks_used;
10926     __pyx_t_4 = __pyx_t_3;
10927     for (__pyx_t_5 = 0; __pyx_t_5 < __pyx_t_4; __pyx_t_5+=1) {
10928       __pyx_v_i = __pyx_t_5;
10929 
10930       /* "View.MemoryView":384
10931  *         if self.lock != NULL:
10932  *             for i in range(__pyx_memoryview_thread_locks_used):
10933  *                 if __pyx_memoryview_thread_locks[i] is self.lock:             # <<<<<<<<<<<<<<
10934  *                     __pyx_memoryview_thread_locks_used -= 1
10935  *                     if i != __pyx_memoryview_thread_locks_used:
10936  */
10937       __pyx_t_2 = (((__pyx_memoryview_thread_locks[__pyx_v_i]) == __pyx_v_self->lock) != 0);
10938       if (__pyx_t_2) {
10939 
10940         /* "View.MemoryView":385
10941  *             for i in range(__pyx_memoryview_thread_locks_used):
10942  *                 if __pyx_memoryview_thread_locks[i] is self.lock:
10943  *                     __pyx_memoryview_thread_locks_used -= 1             # <<<<<<<<<<<<<<
10944  *                     if i != __pyx_memoryview_thread_locks_used:
10945  *                         __pyx_memoryview_thread_locks[i], __pyx_memoryview_thread_locks[__pyx_memoryview_thread_locks_used] = (
10946  */
10947         __pyx_memoryview_thread_locks_used = (__pyx_memoryview_thread_locks_used - 1);
10948 
10949         /* "View.MemoryView":386
10950  *                 if __pyx_memoryview_thread_locks[i] is self.lock:
10951  *                     __pyx_memoryview_thread_locks_used -= 1
10952  *                     if i != __pyx_memoryview_thread_locks_used:             # <<<<<<<<<<<<<<
10953  *                         __pyx_memoryview_thread_locks[i], __pyx_memoryview_thread_locks[__pyx_memoryview_thread_locks_used] = (
10954  *                             __pyx_memoryview_thread_locks[__pyx_memoryview_thread_locks_used], __pyx_memoryview_thread_locks[i])
10955  */
10956         __pyx_t_2 = ((__pyx_v_i != __pyx_memoryview_thread_locks_used) != 0);
10957         if (__pyx_t_2) {
10958 
10959           /* "View.MemoryView":388
10960  *                     if i != __pyx_memoryview_thread_locks_used:
10961  *                         __pyx_memoryview_thread_locks[i], __pyx_memoryview_thread_locks[__pyx_memoryview_thread_locks_used] = (
10962  *                             __pyx_memoryview_thread_locks[__pyx_memoryview_thread_locks_used], __pyx_memoryview_thread_locks[i])             # <<<<<<<<<<<<<<
10963  *                     break
10964  *             else:
10965  */
10966           __pyx_t_6 = (__pyx_memoryview_thread_locks[__pyx_memoryview_thread_locks_used]);
10967           __pyx_t_7 = (__pyx_memoryview_thread_locks[__pyx_v_i]);
10968 
10969           /* "View.MemoryView":387
10970  *                     __pyx_memoryview_thread_locks_used -= 1
10971  *                     if i != __pyx_memoryview_thread_locks_used:
10972  *                         __pyx_memoryview_thread_locks[i], __pyx_memoryview_thread_locks[__pyx_memoryview_thread_locks_used] = (             # <<<<<<<<<<<<<<
10973  *                             __pyx_memoryview_thread_locks[__pyx_memoryview_thread_locks_used], __pyx_memoryview_thread_locks[i])
10974  *                     break
10975  */
10976           (__pyx_memoryview_thread_locks[__pyx_v_i]) = __pyx_t_6;
10977           (__pyx_memoryview_thread_locks[__pyx_memoryview_thread_locks_used]) = __pyx_t_7;
10978 
10979           /* "View.MemoryView":386
10980  *                 if __pyx_memoryview_thread_locks[i] is self.lock:
10981  *                     __pyx_memoryview_thread_locks_used -= 1
10982  *                     if i != __pyx_memoryview_thread_locks_used:             # <<<<<<<<<<<<<<
10983  *                         __pyx_memoryview_thread_locks[i], __pyx_memoryview_thread_locks[__pyx_memoryview_thread_locks_used] = (
10984  *                             __pyx_memoryview_thread_locks[__pyx_memoryview_thread_locks_used], __pyx_memoryview_thread_locks[i])
10985  */
10986         }
10987 
10988         /* "View.MemoryView":389
10989  *                         __pyx_memoryview_thread_locks[i], __pyx_memoryview_thread_locks[__pyx_memoryview_thread_locks_used] = (
10990  *                             __pyx_memoryview_thread_locks[__pyx_memoryview_thread_locks_used], __pyx_memoryview_thread_locks[i])
10991  *                     break             # <<<<<<<<<<<<<<
10992  *             else:
10993  *                 PyThread_free_lock(self.lock)
10994  */
10995         goto __pyx_L6_break;
10996 
10997         /* "View.MemoryView":384
10998  *         if self.lock != NULL:
10999  *             for i in range(__pyx_memoryview_thread_locks_used):
11000  *                 if __pyx_memoryview_thread_locks[i] is self.lock:             # <<<<<<<<<<<<<<
11001  *                     __pyx_memoryview_thread_locks_used -= 1
11002  *                     if i != __pyx_memoryview_thread_locks_used:
11003  */
11004       }
11005     }
11006     /*else*/ {
11007 
11008       /* "View.MemoryView":391
11009  *                     break
11010  *             else:
11011  *                 PyThread_free_lock(self.lock)             # <<<<<<<<<<<<<<
11012  *
11013  *     cdef char *get_item_pointer(memoryview self, object index) except NULL:
11014  */
11015       PyThread_free_lock(__pyx_v_self->lock);
11016     }
11017     __pyx_L6_break:;
11018 
11019     /* "View.MemoryView":382
11020  *         cdef int i
11021  *         global __pyx_memoryview_thread_locks_used
11022  *         if self.lock != NULL:             # <<<<<<<<<<<<<<
11023  *             for i in range(__pyx_memoryview_thread_locks_used):
11024  *                 if __pyx_memoryview_thread_locks[i] is self.lock:
11025  */
11026   }
11027 
11028   /* "View.MemoryView":372
11029  *         self.typeinfo = NULL
11030  *
11031  *     def __dealloc__(memoryview self):             # <<<<<<<<<<<<<<
11032  *         if self.obj is not None:
11033  *             __Pyx_ReleaseBuffer(&self.view)
11034  */
11035 
11036   /* function exit code */
11037   __Pyx_RefNannyFinishContext();
11038 }
11039 
11040 /* "View.MemoryView":393
11041  *                 PyThread_free_lock(self.lock)
11042  *
11043  *     cdef char *get_item_pointer(memoryview self, object index) except NULL:             # <<<<<<<<<<<<<<
11044  *         cdef Py_ssize_t dim
11045  *         cdef char *itemp = <char *> self.view.buf
11046  */
11047 
__pyx_memoryview_get_item_pointer(struct __pyx_memoryview_obj * __pyx_v_self,PyObject * __pyx_v_index)11048 static char *__pyx_memoryview_get_item_pointer(struct __pyx_memoryview_obj *__pyx_v_self, PyObject *__pyx_v_index) {
11049   Py_ssize_t __pyx_v_dim;
11050   char *__pyx_v_itemp;
11051   PyObject *__pyx_v_idx = NULL;
11052   char *__pyx_r;
11053   __Pyx_RefNannyDeclarations
11054   Py_ssize_t __pyx_t_1;
11055   PyObject *__pyx_t_2 = NULL;
11056   Py_ssize_t __pyx_t_3;
11057   PyObject *(*__pyx_t_4)(PyObject *);
11058   PyObject *__pyx_t_5 = NULL;
11059   Py_ssize_t __pyx_t_6;
11060   char *__pyx_t_7;
11061   int __pyx_lineno = 0;
11062   const char *__pyx_filename = NULL;
11063   int __pyx_clineno = 0;
11064   __Pyx_RefNannySetupContext("get_item_pointer", 0);
11065 
11066   /* "View.MemoryView":395
11067  *     cdef char *get_item_pointer(memoryview self, object index) except NULL:
11068  *         cdef Py_ssize_t dim
11069  *         cdef char *itemp = <char *> self.view.buf             # <<<<<<<<<<<<<<
11070  *
11071  *         for dim, idx in enumerate(index):
11072  */
11073   __pyx_v_itemp = ((char *)__pyx_v_self->view.buf);
11074 
11075   /* "View.MemoryView":397
11076  *         cdef char *itemp = <char *> self.view.buf
11077  *
11078  *         for dim, idx in enumerate(index):             # <<<<<<<<<<<<<<
11079  *             itemp = pybuffer_index(&self.view, itemp, idx, dim)
11080  *
11081  */
11082   __pyx_t_1 = 0;
11083   if (likely(PyList_CheckExact(__pyx_v_index)) || PyTuple_CheckExact(__pyx_v_index)) {
11084     __pyx_t_2 = __pyx_v_index; __Pyx_INCREF(__pyx_t_2); __pyx_t_3 = 0;
11085     __pyx_t_4 = NULL;
11086   } else {
11087     __pyx_t_3 = -1; __pyx_t_2 = PyObject_GetIter(__pyx_v_index); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 397, __pyx_L1_error)
11088     __Pyx_GOTREF(__pyx_t_2);
11089     __pyx_t_4 = Py_TYPE(__pyx_t_2)->tp_iternext; if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 397, __pyx_L1_error)
11090   }
11091   for (;;) {
11092     if (likely(!__pyx_t_4)) {
11093       if (likely(PyList_CheckExact(__pyx_t_2))) {
11094         if (__pyx_t_3 >= PyList_GET_SIZE(__pyx_t_2)) break;
11095         #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
11096         __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(2, 397, __pyx_L1_error)
11097         #else
11098         __pyx_t_5 = PySequence_ITEM(__pyx_t_2, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_5)) __PYX_ERR(2, 397, __pyx_L1_error)
11099         __Pyx_GOTREF(__pyx_t_5);
11100         #endif
11101       } else {
11102         if (__pyx_t_3 >= PyTuple_GET_SIZE(__pyx_t_2)) break;
11103         #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
11104         __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(2, 397, __pyx_L1_error)
11105         #else
11106         __pyx_t_5 = PySequence_ITEM(__pyx_t_2, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_5)) __PYX_ERR(2, 397, __pyx_L1_error)
11107         __Pyx_GOTREF(__pyx_t_5);
11108         #endif
11109       }
11110     } else {
11111       __pyx_t_5 = __pyx_t_4(__pyx_t_2);
11112       if (unlikely(!__pyx_t_5)) {
11113         PyObject* exc_type = PyErr_Occurred();
11114         if (exc_type) {
11115           if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
11116           else __PYX_ERR(2, 397, __pyx_L1_error)
11117         }
11118         break;
11119       }
11120       __Pyx_GOTREF(__pyx_t_5);
11121     }
11122     __Pyx_XDECREF_SET(__pyx_v_idx, __pyx_t_5);
11123     __pyx_t_5 = 0;
11124     __pyx_v_dim = __pyx_t_1;
11125     __pyx_t_1 = (__pyx_t_1 + 1);
11126 
11127     /* "View.MemoryView":398
11128  *
11129  *         for dim, idx in enumerate(index):
11130  *             itemp = pybuffer_index(&self.view, itemp, idx, dim)             # <<<<<<<<<<<<<<
11131  *
11132  *         return itemp
11133  */
11134     __pyx_t_6 = __Pyx_PyIndex_AsSsize_t(__pyx_v_idx); if (unlikely((__pyx_t_6 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(2, 398, __pyx_L1_error)
11135     __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(2, 398, __pyx_L1_error)
11136     __pyx_v_itemp = __pyx_t_7;
11137 
11138     /* "View.MemoryView":397
11139  *         cdef char *itemp = <char *> self.view.buf
11140  *
11141  *         for dim, idx in enumerate(index):             # <<<<<<<<<<<<<<
11142  *             itemp = pybuffer_index(&self.view, itemp, idx, dim)
11143  *
11144  */
11145   }
11146   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
11147 
11148   /* "View.MemoryView":400
11149  *             itemp = pybuffer_index(&self.view, itemp, idx, dim)
11150  *
11151  *         return itemp             # <<<<<<<<<<<<<<
11152  *
11153  *
11154  */
11155   __pyx_r = __pyx_v_itemp;
11156   goto __pyx_L0;
11157 
11158   /* "View.MemoryView":393
11159  *                 PyThread_free_lock(self.lock)
11160  *
11161  *     cdef char *get_item_pointer(memoryview self, object index) except NULL:             # <<<<<<<<<<<<<<
11162  *         cdef Py_ssize_t dim
11163  *         cdef char *itemp = <char *> self.view.buf
11164  */
11165 
11166   /* function exit code */
11167   __pyx_L1_error:;
11168   __Pyx_XDECREF(__pyx_t_2);
11169   __Pyx_XDECREF(__pyx_t_5);
11170   __Pyx_AddTraceback("View.MemoryView.memoryview.get_item_pointer", __pyx_clineno, __pyx_lineno, __pyx_filename);
11171   __pyx_r = NULL;
11172   __pyx_L0:;
11173   __Pyx_XDECREF(__pyx_v_idx);
11174   __Pyx_RefNannyFinishContext();
11175   return __pyx_r;
11176 }
11177 
11178 /* "View.MemoryView":403
11179  *
11180  *
11181  *     def __getitem__(memoryview self, object index):             # <<<<<<<<<<<<<<
11182  *         if index is Ellipsis:
11183  *             return self
11184  */
11185 
11186 /* Python wrapper */
11187 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)11188 static PyObject *__pyx_memoryview___getitem__(PyObject *__pyx_v_self, PyObject *__pyx_v_index) {
11189   PyObject *__pyx_r = 0;
11190   __Pyx_RefNannyDeclarations
11191   __Pyx_RefNannySetupContext("__getitem__ (wrapper)", 0);
11192   __pyx_r = __pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_4__getitem__(((struct __pyx_memoryview_obj *)__pyx_v_self), ((PyObject *)__pyx_v_index));
11193 
11194   /* function exit code */
11195   __Pyx_RefNannyFinishContext();
11196   return __pyx_r;
11197 }
11198 
__pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_4__getitem__(struct __pyx_memoryview_obj * __pyx_v_self,PyObject * __pyx_v_index)11199 static PyObject *__pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_4__getitem__(struct __pyx_memoryview_obj *__pyx_v_self, PyObject *__pyx_v_index) {
11200   PyObject *__pyx_v_have_slices = NULL;
11201   PyObject *__pyx_v_indices = NULL;
11202   char *__pyx_v_itemp;
11203   PyObject *__pyx_r = NULL;
11204   __Pyx_RefNannyDeclarations
11205   int __pyx_t_1;
11206   int __pyx_t_2;
11207   PyObject *__pyx_t_3 = NULL;
11208   PyObject *__pyx_t_4 = NULL;
11209   PyObject *__pyx_t_5 = NULL;
11210   char *__pyx_t_6;
11211   int __pyx_lineno = 0;
11212   const char *__pyx_filename = NULL;
11213   int __pyx_clineno = 0;
11214   __Pyx_RefNannySetupContext("__getitem__", 0);
11215 
11216   /* "View.MemoryView":404
11217  *
11218  *     def __getitem__(memoryview self, object index):
11219  *         if index is Ellipsis:             # <<<<<<<<<<<<<<
11220  *             return self
11221  *
11222  */
11223   __pyx_t_1 = (__pyx_v_index == __pyx_builtin_Ellipsis);
11224   __pyx_t_2 = (__pyx_t_1 != 0);
11225   if (__pyx_t_2) {
11226 
11227     /* "View.MemoryView":405
11228  *     def __getitem__(memoryview self, object index):
11229  *         if index is Ellipsis:
11230  *             return self             # <<<<<<<<<<<<<<
11231  *
11232  *         have_slices, indices = _unellipsify(index, self.view.ndim)
11233  */
11234     __Pyx_XDECREF(__pyx_r);
11235     __Pyx_INCREF(((PyObject *)__pyx_v_self));
11236     __pyx_r = ((PyObject *)__pyx_v_self);
11237     goto __pyx_L0;
11238 
11239     /* "View.MemoryView":404
11240  *
11241  *     def __getitem__(memoryview self, object index):
11242  *         if index is Ellipsis:             # <<<<<<<<<<<<<<
11243  *             return self
11244  *
11245  */
11246   }
11247 
11248   /* "View.MemoryView":407
11249  *             return self
11250  *
11251  *         have_slices, indices = _unellipsify(index, self.view.ndim)             # <<<<<<<<<<<<<<
11252  *
11253  *         cdef char *itemp
11254  */
11255   __pyx_t_3 = _unellipsify(__pyx_v_index, __pyx_v_self->view.ndim); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 407, __pyx_L1_error)
11256   __Pyx_GOTREF(__pyx_t_3);
11257   if (likely(__pyx_t_3 != Py_None)) {
11258     PyObject* sequence = __pyx_t_3;
11259     Py_ssize_t size = __Pyx_PySequence_SIZE(sequence);
11260     if (unlikely(size != 2)) {
11261       if (size > 2) __Pyx_RaiseTooManyValuesError(2);
11262       else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
11263       __PYX_ERR(2, 407, __pyx_L1_error)
11264     }
11265     #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
11266     __pyx_t_4 = PyTuple_GET_ITEM(sequence, 0);
11267     __pyx_t_5 = PyTuple_GET_ITEM(sequence, 1);
11268     __Pyx_INCREF(__pyx_t_4);
11269     __Pyx_INCREF(__pyx_t_5);
11270     #else
11271     __pyx_t_4 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 407, __pyx_L1_error)
11272     __Pyx_GOTREF(__pyx_t_4);
11273     __pyx_t_5 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_5)) __PYX_ERR(2, 407, __pyx_L1_error)
11274     __Pyx_GOTREF(__pyx_t_5);
11275     #endif
11276     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
11277   } else {
11278     __Pyx_RaiseNoneNotIterableError(); __PYX_ERR(2, 407, __pyx_L1_error)
11279   }
11280   __pyx_v_have_slices = __pyx_t_4;
11281   __pyx_t_4 = 0;
11282   __pyx_v_indices = __pyx_t_5;
11283   __pyx_t_5 = 0;
11284 
11285   /* "View.MemoryView":410
11286  *
11287  *         cdef char *itemp
11288  *         if have_slices:             # <<<<<<<<<<<<<<
11289  *             return memview_slice(self, indices)
11290  *         else:
11291  */
11292   __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_v_have_slices); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(2, 410, __pyx_L1_error)
11293   if (__pyx_t_2) {
11294 
11295     /* "View.MemoryView":411
11296  *         cdef char *itemp
11297  *         if have_slices:
11298  *             return memview_slice(self, indices)             # <<<<<<<<<<<<<<
11299  *         else:
11300  *             itemp = self.get_item_pointer(indices)
11301  */
11302     __Pyx_XDECREF(__pyx_r);
11303     __pyx_t_3 = ((PyObject *)__pyx_memview_slice(__pyx_v_self, __pyx_v_indices)); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 411, __pyx_L1_error)
11304     __Pyx_GOTREF(__pyx_t_3);
11305     __pyx_r = __pyx_t_3;
11306     __pyx_t_3 = 0;
11307     goto __pyx_L0;
11308 
11309     /* "View.MemoryView":410
11310  *
11311  *         cdef char *itemp
11312  *         if have_slices:             # <<<<<<<<<<<<<<
11313  *             return memview_slice(self, indices)
11314  *         else:
11315  */
11316   }
11317 
11318   /* "View.MemoryView":413
11319  *             return memview_slice(self, indices)
11320  *         else:
11321  *             itemp = self.get_item_pointer(indices)             # <<<<<<<<<<<<<<
11322  *             return self.convert_item_to_object(itemp)
11323  *
11324  */
11325   /*else*/ {
11326     __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(2, 413, __pyx_L1_error)
11327     __pyx_v_itemp = __pyx_t_6;
11328 
11329     /* "View.MemoryView":414
11330  *         else:
11331  *             itemp = self.get_item_pointer(indices)
11332  *             return self.convert_item_to_object(itemp)             # <<<<<<<<<<<<<<
11333  *
11334  *     def __setitem__(memoryview self, object index, object value):
11335  */
11336     __Pyx_XDECREF(__pyx_r);
11337     __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(2, 414, __pyx_L1_error)
11338     __Pyx_GOTREF(__pyx_t_3);
11339     __pyx_r = __pyx_t_3;
11340     __pyx_t_3 = 0;
11341     goto __pyx_L0;
11342   }
11343 
11344   /* "View.MemoryView":403
11345  *
11346  *
11347  *     def __getitem__(memoryview self, object index):             # <<<<<<<<<<<<<<
11348  *         if index is Ellipsis:
11349  *             return self
11350  */
11351 
11352   /* function exit code */
11353   __pyx_L1_error:;
11354   __Pyx_XDECREF(__pyx_t_3);
11355   __Pyx_XDECREF(__pyx_t_4);
11356   __Pyx_XDECREF(__pyx_t_5);
11357   __Pyx_AddTraceback("View.MemoryView.memoryview.__getitem__", __pyx_clineno, __pyx_lineno, __pyx_filename);
11358   __pyx_r = NULL;
11359   __pyx_L0:;
11360   __Pyx_XDECREF(__pyx_v_have_slices);
11361   __Pyx_XDECREF(__pyx_v_indices);
11362   __Pyx_XGIVEREF(__pyx_r);
11363   __Pyx_RefNannyFinishContext();
11364   return __pyx_r;
11365 }
11366 
11367 /* "View.MemoryView":416
11368  *             return self.convert_item_to_object(itemp)
11369  *
11370  *     def __setitem__(memoryview self, object index, object value):             # <<<<<<<<<<<<<<
11371  *         if self.view.readonly:
11372  *             raise TypeError("Cannot assign to read-only memoryview")
11373  */
11374 
11375 /* Python wrapper */
11376 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)11377 static int __pyx_memoryview___setitem__(PyObject *__pyx_v_self, PyObject *__pyx_v_index, PyObject *__pyx_v_value) {
11378   int __pyx_r;
11379   __Pyx_RefNannyDeclarations
11380   __Pyx_RefNannySetupContext("__setitem__ (wrapper)", 0);
11381   __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));
11382 
11383   /* function exit code */
11384   __Pyx_RefNannyFinishContext();
11385   return __pyx_r;
11386 }
11387 
__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)11388 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) {
11389   PyObject *__pyx_v_have_slices = NULL;
11390   PyObject *__pyx_v_obj = NULL;
11391   int __pyx_r;
11392   __Pyx_RefNannyDeclarations
11393   int __pyx_t_1;
11394   PyObject *__pyx_t_2 = NULL;
11395   PyObject *__pyx_t_3 = NULL;
11396   PyObject *__pyx_t_4 = NULL;
11397   int __pyx_lineno = 0;
11398   const char *__pyx_filename = NULL;
11399   int __pyx_clineno = 0;
11400   __Pyx_RefNannySetupContext("__setitem__", 0);
11401   __Pyx_INCREF(__pyx_v_index);
11402 
11403   /* "View.MemoryView":417
11404  *
11405  *     def __setitem__(memoryview self, object index, object value):
11406  *         if self.view.readonly:             # <<<<<<<<<<<<<<
11407  *             raise TypeError("Cannot assign to read-only memoryview")
11408  *
11409  */
11410   __pyx_t_1 = (__pyx_v_self->view.readonly != 0);
11411   if (unlikely(__pyx_t_1)) {
11412 
11413     /* "View.MemoryView":418
11414  *     def __setitem__(memoryview self, object index, object value):
11415  *         if self.view.readonly:
11416  *             raise TypeError("Cannot assign to read-only memoryview")             # <<<<<<<<<<<<<<
11417  *
11418  *         have_slices, index = _unellipsify(index, self.view.ndim)
11419  */
11420     __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__13, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 418, __pyx_L1_error)
11421     __Pyx_GOTREF(__pyx_t_2);
11422     __Pyx_Raise(__pyx_t_2, 0, 0, 0);
11423     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
11424     __PYX_ERR(2, 418, __pyx_L1_error)
11425 
11426     /* "View.MemoryView":417
11427  *
11428  *     def __setitem__(memoryview self, object index, object value):
11429  *         if self.view.readonly:             # <<<<<<<<<<<<<<
11430  *             raise TypeError("Cannot assign to read-only memoryview")
11431  *
11432  */
11433   }
11434 
11435   /* "View.MemoryView":420
11436  *             raise TypeError("Cannot assign to read-only memoryview")
11437  *
11438  *         have_slices, index = _unellipsify(index, self.view.ndim)             # <<<<<<<<<<<<<<
11439  *
11440  *         if have_slices:
11441  */
11442   __pyx_t_2 = _unellipsify(__pyx_v_index, __pyx_v_self->view.ndim); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 420, __pyx_L1_error)
11443   __Pyx_GOTREF(__pyx_t_2);
11444   if (likely(__pyx_t_2 != Py_None)) {
11445     PyObject* sequence = __pyx_t_2;
11446     Py_ssize_t size = __Pyx_PySequence_SIZE(sequence);
11447     if (unlikely(size != 2)) {
11448       if (size > 2) __Pyx_RaiseTooManyValuesError(2);
11449       else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
11450       __PYX_ERR(2, 420, __pyx_L1_error)
11451     }
11452     #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
11453     __pyx_t_3 = PyTuple_GET_ITEM(sequence, 0);
11454     __pyx_t_4 = PyTuple_GET_ITEM(sequence, 1);
11455     __Pyx_INCREF(__pyx_t_3);
11456     __Pyx_INCREF(__pyx_t_4);
11457     #else
11458     __pyx_t_3 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 420, __pyx_L1_error)
11459     __Pyx_GOTREF(__pyx_t_3);
11460     __pyx_t_4 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 420, __pyx_L1_error)
11461     __Pyx_GOTREF(__pyx_t_4);
11462     #endif
11463     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
11464   } else {
11465     __Pyx_RaiseNoneNotIterableError(); __PYX_ERR(2, 420, __pyx_L1_error)
11466   }
11467   __pyx_v_have_slices = __pyx_t_3;
11468   __pyx_t_3 = 0;
11469   __Pyx_DECREF_SET(__pyx_v_index, __pyx_t_4);
11470   __pyx_t_4 = 0;
11471 
11472   /* "View.MemoryView":422
11473  *         have_slices, index = _unellipsify(index, self.view.ndim)
11474  *
11475  *         if have_slices:             # <<<<<<<<<<<<<<
11476  *             obj = self.is_slice(value)
11477  *             if obj:
11478  */
11479   __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_have_slices); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(2, 422, __pyx_L1_error)
11480   if (__pyx_t_1) {
11481 
11482     /* "View.MemoryView":423
11483  *
11484  *         if have_slices:
11485  *             obj = self.is_slice(value)             # <<<<<<<<<<<<<<
11486  *             if obj:
11487  *                 self.setitem_slice_assignment(self[index], obj)
11488  */
11489     __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(2, 423, __pyx_L1_error)
11490     __Pyx_GOTREF(__pyx_t_2);
11491     __pyx_v_obj = __pyx_t_2;
11492     __pyx_t_2 = 0;
11493 
11494     /* "View.MemoryView":424
11495  *         if have_slices:
11496  *             obj = self.is_slice(value)
11497  *             if obj:             # <<<<<<<<<<<<<<
11498  *                 self.setitem_slice_assignment(self[index], obj)
11499  *             else:
11500  */
11501     __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_obj); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(2, 424, __pyx_L1_error)
11502     if (__pyx_t_1) {
11503 
11504       /* "View.MemoryView":425
11505  *             obj = self.is_slice(value)
11506  *             if obj:
11507  *                 self.setitem_slice_assignment(self[index], obj)             # <<<<<<<<<<<<<<
11508  *             else:
11509  *                 self.setitem_slice_assign_scalar(self[index], value)
11510  */
11511       __pyx_t_2 = __Pyx_PyObject_GetItem(((PyObject *)__pyx_v_self), __pyx_v_index); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 425, __pyx_L1_error)
11512       __Pyx_GOTREF(__pyx_t_2);
11513       __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(2, 425, __pyx_L1_error)
11514       __Pyx_GOTREF(__pyx_t_4);
11515       __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
11516       __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
11517 
11518       /* "View.MemoryView":424
11519  *         if have_slices:
11520  *             obj = self.is_slice(value)
11521  *             if obj:             # <<<<<<<<<<<<<<
11522  *                 self.setitem_slice_assignment(self[index], obj)
11523  *             else:
11524  */
11525       goto __pyx_L5;
11526     }
11527 
11528     /* "View.MemoryView":427
11529  *                 self.setitem_slice_assignment(self[index], obj)
11530  *             else:
11531  *                 self.setitem_slice_assign_scalar(self[index], value)             # <<<<<<<<<<<<<<
11532  *         else:
11533  *             self.setitem_indexed(index, value)
11534  */
11535     /*else*/ {
11536       __pyx_t_4 = __Pyx_PyObject_GetItem(((PyObject *)__pyx_v_self), __pyx_v_index); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 427, __pyx_L1_error)
11537       __Pyx_GOTREF(__pyx_t_4);
11538       if (!(likely(((__pyx_t_4) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_4, __pyx_memoryview_type))))) __PYX_ERR(2, 427, __pyx_L1_error)
11539       __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(2, 427, __pyx_L1_error)
11540       __Pyx_GOTREF(__pyx_t_2);
11541       __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
11542       __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
11543     }
11544     __pyx_L5:;
11545 
11546     /* "View.MemoryView":422
11547  *         have_slices, index = _unellipsify(index, self.view.ndim)
11548  *
11549  *         if have_slices:             # <<<<<<<<<<<<<<
11550  *             obj = self.is_slice(value)
11551  *             if obj:
11552  */
11553     goto __pyx_L4;
11554   }
11555 
11556   /* "View.MemoryView":429
11557  *                 self.setitem_slice_assign_scalar(self[index], value)
11558  *         else:
11559  *             self.setitem_indexed(index, value)             # <<<<<<<<<<<<<<
11560  *
11561  *     cdef is_slice(self, obj):
11562  */
11563   /*else*/ {
11564     __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(2, 429, __pyx_L1_error)
11565     __Pyx_GOTREF(__pyx_t_2);
11566     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
11567   }
11568   __pyx_L4:;
11569 
11570   /* "View.MemoryView":416
11571  *             return self.convert_item_to_object(itemp)
11572  *
11573  *     def __setitem__(memoryview self, object index, object value):             # <<<<<<<<<<<<<<
11574  *         if self.view.readonly:
11575  *             raise TypeError("Cannot assign to read-only memoryview")
11576  */
11577 
11578   /* function exit code */
11579   __pyx_r = 0;
11580   goto __pyx_L0;
11581   __pyx_L1_error:;
11582   __Pyx_XDECREF(__pyx_t_2);
11583   __Pyx_XDECREF(__pyx_t_3);
11584   __Pyx_XDECREF(__pyx_t_4);
11585   __Pyx_AddTraceback("View.MemoryView.memoryview.__setitem__", __pyx_clineno, __pyx_lineno, __pyx_filename);
11586   __pyx_r = -1;
11587   __pyx_L0:;
11588   __Pyx_XDECREF(__pyx_v_have_slices);
11589   __Pyx_XDECREF(__pyx_v_obj);
11590   __Pyx_XDECREF(__pyx_v_index);
11591   __Pyx_RefNannyFinishContext();
11592   return __pyx_r;
11593 }
11594 
11595 /* "View.MemoryView":431
11596  *             self.setitem_indexed(index, value)
11597  *
11598  *     cdef is_slice(self, obj):             # <<<<<<<<<<<<<<
11599  *         if not isinstance(obj, memoryview):
11600  *             try:
11601  */
11602 
__pyx_memoryview_is_slice(struct __pyx_memoryview_obj * __pyx_v_self,PyObject * __pyx_v_obj)11603 static PyObject *__pyx_memoryview_is_slice(struct __pyx_memoryview_obj *__pyx_v_self, PyObject *__pyx_v_obj) {
11604   PyObject *__pyx_r = NULL;
11605   __Pyx_RefNannyDeclarations
11606   int __pyx_t_1;
11607   int __pyx_t_2;
11608   PyObject *__pyx_t_3 = NULL;
11609   PyObject *__pyx_t_4 = NULL;
11610   PyObject *__pyx_t_5 = NULL;
11611   PyObject *__pyx_t_6 = NULL;
11612   PyObject *__pyx_t_7 = NULL;
11613   PyObject *__pyx_t_8 = NULL;
11614   int __pyx_t_9;
11615   int __pyx_lineno = 0;
11616   const char *__pyx_filename = NULL;
11617   int __pyx_clineno = 0;
11618   __Pyx_RefNannySetupContext("is_slice", 0);
11619   __Pyx_INCREF(__pyx_v_obj);
11620 
11621   /* "View.MemoryView":432
11622  *
11623  *     cdef is_slice(self, obj):
11624  *         if not isinstance(obj, memoryview):             # <<<<<<<<<<<<<<
11625  *             try:
11626  *                 obj = memoryview(obj, self.flags & ~PyBUF_WRITABLE | PyBUF_ANY_CONTIGUOUS,
11627  */
11628   __pyx_t_1 = __Pyx_TypeCheck(__pyx_v_obj, __pyx_memoryview_type);
11629   __pyx_t_2 = ((!(__pyx_t_1 != 0)) != 0);
11630   if (__pyx_t_2) {
11631 
11632     /* "View.MemoryView":433
11633  *     cdef is_slice(self, obj):
11634  *         if not isinstance(obj, memoryview):
11635  *             try:             # <<<<<<<<<<<<<<
11636  *                 obj = memoryview(obj, self.flags & ~PyBUF_WRITABLE | PyBUF_ANY_CONTIGUOUS,
11637  *                                  self.dtype_is_object)
11638  */
11639     {
11640       __Pyx_PyThreadState_declare
11641       __Pyx_PyThreadState_assign
11642       __Pyx_ExceptionSave(&__pyx_t_3, &__pyx_t_4, &__pyx_t_5);
11643       __Pyx_XGOTREF(__pyx_t_3);
11644       __Pyx_XGOTREF(__pyx_t_4);
11645       __Pyx_XGOTREF(__pyx_t_5);
11646       /*try:*/ {
11647 
11648         /* "View.MemoryView":434
11649  *         if not isinstance(obj, memoryview):
11650  *             try:
11651  *                 obj = memoryview(obj, self.flags & ~PyBUF_WRITABLE | PyBUF_ANY_CONTIGUOUS,             # <<<<<<<<<<<<<<
11652  *                                  self.dtype_is_object)
11653  *             except TypeError:
11654  */
11655         __pyx_t_6 = __Pyx_PyInt_From_int(((__pyx_v_self->flags & (~PyBUF_WRITABLE)) | PyBUF_ANY_CONTIGUOUS)); if (unlikely(!__pyx_t_6)) __PYX_ERR(2, 434, __pyx_L4_error)
11656         __Pyx_GOTREF(__pyx_t_6);
11657 
11658         /* "View.MemoryView":435
11659  *             try:
11660  *                 obj = memoryview(obj, self.flags & ~PyBUF_WRITABLE | PyBUF_ANY_CONTIGUOUS,
11661  *                                  self.dtype_is_object)             # <<<<<<<<<<<<<<
11662  *             except TypeError:
11663  *                 return None
11664  */
11665         __pyx_t_7 = __Pyx_PyBool_FromLong(__pyx_v_self->dtype_is_object); if (unlikely(!__pyx_t_7)) __PYX_ERR(2, 435, __pyx_L4_error)
11666         __Pyx_GOTREF(__pyx_t_7);
11667 
11668         /* "View.MemoryView":434
11669  *         if not isinstance(obj, memoryview):
11670  *             try:
11671  *                 obj = memoryview(obj, self.flags & ~PyBUF_WRITABLE | PyBUF_ANY_CONTIGUOUS,             # <<<<<<<<<<<<<<
11672  *                                  self.dtype_is_object)
11673  *             except TypeError:
11674  */
11675         __pyx_t_8 = PyTuple_New(3); if (unlikely(!__pyx_t_8)) __PYX_ERR(2, 434, __pyx_L4_error)
11676         __Pyx_GOTREF(__pyx_t_8);
11677         __Pyx_INCREF(__pyx_v_obj);
11678         __Pyx_GIVEREF(__pyx_v_obj);
11679         PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_v_obj);
11680         __Pyx_GIVEREF(__pyx_t_6);
11681         PyTuple_SET_ITEM(__pyx_t_8, 1, __pyx_t_6);
11682         __Pyx_GIVEREF(__pyx_t_7);
11683         PyTuple_SET_ITEM(__pyx_t_8, 2, __pyx_t_7);
11684         __pyx_t_6 = 0;
11685         __pyx_t_7 = 0;
11686         __pyx_t_7 = __Pyx_PyObject_Call(((PyObject *)__pyx_memoryview_type), __pyx_t_8, NULL); if (unlikely(!__pyx_t_7)) __PYX_ERR(2, 434, __pyx_L4_error)
11687         __Pyx_GOTREF(__pyx_t_7);
11688         __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
11689         __Pyx_DECREF_SET(__pyx_v_obj, __pyx_t_7);
11690         __pyx_t_7 = 0;
11691 
11692         /* "View.MemoryView":433
11693  *     cdef is_slice(self, obj):
11694  *         if not isinstance(obj, memoryview):
11695  *             try:             # <<<<<<<<<<<<<<
11696  *                 obj = memoryview(obj, self.flags & ~PyBUF_WRITABLE | PyBUF_ANY_CONTIGUOUS,
11697  *                                  self.dtype_is_object)
11698  */
11699       }
11700       __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
11701       __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
11702       __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
11703       goto __pyx_L9_try_end;
11704       __pyx_L4_error:;
11705       __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
11706       __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
11707       __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
11708 
11709       /* "View.MemoryView":436
11710  *                 obj = memoryview(obj, self.flags & ~PyBUF_WRITABLE | PyBUF_ANY_CONTIGUOUS,
11711  *                                  self.dtype_is_object)
11712  *             except TypeError:             # <<<<<<<<<<<<<<
11713  *                 return None
11714  *
11715  */
11716       __pyx_t_9 = __Pyx_PyErr_ExceptionMatches(__pyx_builtin_TypeError);
11717       if (__pyx_t_9) {
11718         __Pyx_AddTraceback("View.MemoryView.memoryview.is_slice", __pyx_clineno, __pyx_lineno, __pyx_filename);
11719         if (__Pyx_GetException(&__pyx_t_7, &__pyx_t_8, &__pyx_t_6) < 0) __PYX_ERR(2, 436, __pyx_L6_except_error)
11720         __Pyx_GOTREF(__pyx_t_7);
11721         __Pyx_GOTREF(__pyx_t_8);
11722         __Pyx_GOTREF(__pyx_t_6);
11723 
11724         /* "View.MemoryView":437
11725  *                                  self.dtype_is_object)
11726  *             except TypeError:
11727  *                 return None             # <<<<<<<<<<<<<<
11728  *
11729  *         return obj
11730  */
11731         __Pyx_XDECREF(__pyx_r);
11732         __pyx_r = Py_None; __Pyx_INCREF(Py_None);
11733         __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
11734         __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
11735         __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
11736         goto __pyx_L7_except_return;
11737       }
11738       goto __pyx_L6_except_error;
11739       __pyx_L6_except_error:;
11740 
11741       /* "View.MemoryView":433
11742  *     cdef is_slice(self, obj):
11743  *         if not isinstance(obj, memoryview):
11744  *             try:             # <<<<<<<<<<<<<<
11745  *                 obj = memoryview(obj, self.flags & ~PyBUF_WRITABLE | PyBUF_ANY_CONTIGUOUS,
11746  *                                  self.dtype_is_object)
11747  */
11748       __Pyx_XGIVEREF(__pyx_t_3);
11749       __Pyx_XGIVEREF(__pyx_t_4);
11750       __Pyx_XGIVEREF(__pyx_t_5);
11751       __Pyx_ExceptionReset(__pyx_t_3, __pyx_t_4, __pyx_t_5);
11752       goto __pyx_L1_error;
11753       __pyx_L7_except_return:;
11754       __Pyx_XGIVEREF(__pyx_t_3);
11755       __Pyx_XGIVEREF(__pyx_t_4);
11756       __Pyx_XGIVEREF(__pyx_t_5);
11757       __Pyx_ExceptionReset(__pyx_t_3, __pyx_t_4, __pyx_t_5);
11758       goto __pyx_L0;
11759       __pyx_L9_try_end:;
11760     }
11761 
11762     /* "View.MemoryView":432
11763  *
11764  *     cdef is_slice(self, obj):
11765  *         if not isinstance(obj, memoryview):             # <<<<<<<<<<<<<<
11766  *             try:
11767  *                 obj = memoryview(obj, self.flags & ~PyBUF_WRITABLE | PyBUF_ANY_CONTIGUOUS,
11768  */
11769   }
11770 
11771   /* "View.MemoryView":439
11772  *                 return None
11773  *
11774  *         return obj             # <<<<<<<<<<<<<<
11775  *
11776  *     cdef setitem_slice_assignment(self, dst, src):
11777  */
11778   __Pyx_XDECREF(__pyx_r);
11779   __Pyx_INCREF(__pyx_v_obj);
11780   __pyx_r = __pyx_v_obj;
11781   goto __pyx_L0;
11782 
11783   /* "View.MemoryView":431
11784  *             self.setitem_indexed(index, value)
11785  *
11786  *     cdef is_slice(self, obj):             # <<<<<<<<<<<<<<
11787  *         if not isinstance(obj, memoryview):
11788  *             try:
11789  */
11790 
11791   /* function exit code */
11792   __pyx_L1_error:;
11793   __Pyx_XDECREF(__pyx_t_6);
11794   __Pyx_XDECREF(__pyx_t_7);
11795   __Pyx_XDECREF(__pyx_t_8);
11796   __Pyx_AddTraceback("View.MemoryView.memoryview.is_slice", __pyx_clineno, __pyx_lineno, __pyx_filename);
11797   __pyx_r = 0;
11798   __pyx_L0:;
11799   __Pyx_XDECREF(__pyx_v_obj);
11800   __Pyx_XGIVEREF(__pyx_r);
11801   __Pyx_RefNannyFinishContext();
11802   return __pyx_r;
11803 }
11804 
11805 /* "View.MemoryView":441
11806  *         return obj
11807  *
11808  *     cdef setitem_slice_assignment(self, dst, src):             # <<<<<<<<<<<<<<
11809  *         cdef __Pyx_memviewslice dst_slice
11810  *         cdef __Pyx_memviewslice src_slice
11811  */
11812 
__pyx_memoryview_setitem_slice_assignment(struct __pyx_memoryview_obj * __pyx_v_self,PyObject * __pyx_v_dst,PyObject * __pyx_v_src)11813 static PyObject *__pyx_memoryview_setitem_slice_assignment(struct __pyx_memoryview_obj *__pyx_v_self, PyObject *__pyx_v_dst, PyObject *__pyx_v_src) {
11814   __Pyx_memviewslice __pyx_v_dst_slice;
11815   __Pyx_memviewslice __pyx_v_src_slice;
11816   PyObject *__pyx_r = NULL;
11817   __Pyx_RefNannyDeclarations
11818   __Pyx_memviewslice *__pyx_t_1;
11819   __Pyx_memviewslice *__pyx_t_2;
11820   PyObject *__pyx_t_3 = NULL;
11821   int __pyx_t_4;
11822   int __pyx_t_5;
11823   int __pyx_t_6;
11824   int __pyx_lineno = 0;
11825   const char *__pyx_filename = NULL;
11826   int __pyx_clineno = 0;
11827   __Pyx_RefNannySetupContext("setitem_slice_assignment", 0);
11828 
11829   /* "View.MemoryView":445
11830  *         cdef __Pyx_memviewslice src_slice
11831  *
11832  *         memoryview_copy_contents(get_slice_from_memview(src, &src_slice)[0],             # <<<<<<<<<<<<<<
11833  *                                  get_slice_from_memview(dst, &dst_slice)[0],
11834  *                                  src.ndim, dst.ndim, self.dtype_is_object)
11835  */
11836   if (!(likely(((__pyx_v_src) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_src, __pyx_memoryview_type))))) __PYX_ERR(2, 445, __pyx_L1_error)
11837   __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(2, 445, __pyx_L1_error)
11838 
11839   /* "View.MemoryView":446
11840  *
11841  *         memoryview_copy_contents(get_slice_from_memview(src, &src_slice)[0],
11842  *                                  get_slice_from_memview(dst, &dst_slice)[0],             # <<<<<<<<<<<<<<
11843  *                                  src.ndim, dst.ndim, self.dtype_is_object)
11844  *
11845  */
11846   if (!(likely(((__pyx_v_dst) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_dst, __pyx_memoryview_type))))) __PYX_ERR(2, 446, __pyx_L1_error)
11847   __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(2, 446, __pyx_L1_error)
11848 
11849   /* "View.MemoryView":447
11850  *         memoryview_copy_contents(get_slice_from_memview(src, &src_slice)[0],
11851  *                                  get_slice_from_memview(dst, &dst_slice)[0],
11852  *                                  src.ndim, dst.ndim, self.dtype_is_object)             # <<<<<<<<<<<<<<
11853  *
11854  *     cdef setitem_slice_assign_scalar(self, memoryview dst, value):
11855  */
11856   __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_src, __pyx_n_s_ndim); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 447, __pyx_L1_error)
11857   __Pyx_GOTREF(__pyx_t_3);
11858   __pyx_t_4 = __Pyx_PyInt_As_int(__pyx_t_3); if (unlikely((__pyx_t_4 == (int)-1) && PyErr_Occurred())) __PYX_ERR(2, 447, __pyx_L1_error)
11859   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
11860   __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_dst, __pyx_n_s_ndim); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 447, __pyx_L1_error)
11861   __Pyx_GOTREF(__pyx_t_3);
11862   __pyx_t_5 = __Pyx_PyInt_As_int(__pyx_t_3); if (unlikely((__pyx_t_5 == (int)-1) && PyErr_Occurred())) __PYX_ERR(2, 447, __pyx_L1_error)
11863   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
11864 
11865   /* "View.MemoryView":445
11866  *         cdef __Pyx_memviewslice src_slice
11867  *
11868  *         memoryview_copy_contents(get_slice_from_memview(src, &src_slice)[0],             # <<<<<<<<<<<<<<
11869  *                                  get_slice_from_memview(dst, &dst_slice)[0],
11870  *                                  src.ndim, dst.ndim, self.dtype_is_object)
11871  */
11872   __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(2, 445, __pyx_L1_error)
11873 
11874   /* "View.MemoryView":441
11875  *         return obj
11876  *
11877  *     cdef setitem_slice_assignment(self, dst, src):             # <<<<<<<<<<<<<<
11878  *         cdef __Pyx_memviewslice dst_slice
11879  *         cdef __Pyx_memviewslice src_slice
11880  */
11881 
11882   /* function exit code */
11883   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
11884   goto __pyx_L0;
11885   __pyx_L1_error:;
11886   __Pyx_XDECREF(__pyx_t_3);
11887   __Pyx_AddTraceback("View.MemoryView.memoryview.setitem_slice_assignment", __pyx_clineno, __pyx_lineno, __pyx_filename);
11888   __pyx_r = 0;
11889   __pyx_L0:;
11890   __Pyx_XGIVEREF(__pyx_r);
11891   __Pyx_RefNannyFinishContext();
11892   return __pyx_r;
11893 }
11894 
11895 /* "View.MemoryView":449
11896  *                                  src.ndim, dst.ndim, self.dtype_is_object)
11897  *
11898  *     cdef setitem_slice_assign_scalar(self, memoryview dst, value):             # <<<<<<<<<<<<<<
11899  *         cdef int array[128]
11900  *         cdef void *tmp = NULL
11901  */
11902 
__pyx_memoryview_setitem_slice_assign_scalar(struct __pyx_memoryview_obj * __pyx_v_self,struct __pyx_memoryview_obj * __pyx_v_dst,PyObject * __pyx_v_value)11903 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) {
11904   int __pyx_v_array[0x80];
11905   void *__pyx_v_tmp;
11906   void *__pyx_v_item;
11907   __Pyx_memviewslice *__pyx_v_dst_slice;
11908   __Pyx_memviewslice __pyx_v_tmp_slice;
11909   PyObject *__pyx_r = NULL;
11910   __Pyx_RefNannyDeclarations
11911   __Pyx_memviewslice *__pyx_t_1;
11912   int __pyx_t_2;
11913   PyObject *__pyx_t_3 = NULL;
11914   int __pyx_t_4;
11915   int __pyx_t_5;
11916   char const *__pyx_t_6;
11917   PyObject *__pyx_t_7 = NULL;
11918   PyObject *__pyx_t_8 = NULL;
11919   PyObject *__pyx_t_9 = NULL;
11920   PyObject *__pyx_t_10 = NULL;
11921   PyObject *__pyx_t_11 = NULL;
11922   PyObject *__pyx_t_12 = NULL;
11923   int __pyx_lineno = 0;
11924   const char *__pyx_filename = NULL;
11925   int __pyx_clineno = 0;
11926   __Pyx_RefNannySetupContext("setitem_slice_assign_scalar", 0);
11927 
11928   /* "View.MemoryView":451
11929  *     cdef setitem_slice_assign_scalar(self, memoryview dst, value):
11930  *         cdef int array[128]
11931  *         cdef void *tmp = NULL             # <<<<<<<<<<<<<<
11932  *         cdef void *item
11933  *
11934  */
11935   __pyx_v_tmp = NULL;
11936 
11937   /* "View.MemoryView":456
11938  *         cdef __Pyx_memviewslice *dst_slice
11939  *         cdef __Pyx_memviewslice tmp_slice
11940  *         dst_slice = get_slice_from_memview(dst, &tmp_slice)             # <<<<<<<<<<<<<<
11941  *
11942  *         if <size_t>self.view.itemsize > sizeof(array):
11943  */
11944   __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(2, 456, __pyx_L1_error)
11945   __pyx_v_dst_slice = __pyx_t_1;
11946 
11947   /* "View.MemoryView":458
11948  *         dst_slice = get_slice_from_memview(dst, &tmp_slice)
11949  *
11950  *         if <size_t>self.view.itemsize > sizeof(array):             # <<<<<<<<<<<<<<
11951  *             tmp = PyMem_Malloc(self.view.itemsize)
11952  *             if tmp == NULL:
11953  */
11954   __pyx_t_2 = ((((size_t)__pyx_v_self->view.itemsize) > (sizeof(__pyx_v_array))) != 0);
11955   if (__pyx_t_2) {
11956 
11957     /* "View.MemoryView":459
11958  *
11959  *         if <size_t>self.view.itemsize > sizeof(array):
11960  *             tmp = PyMem_Malloc(self.view.itemsize)             # <<<<<<<<<<<<<<
11961  *             if tmp == NULL:
11962  *                 raise MemoryError
11963  */
11964     __pyx_v_tmp = PyMem_Malloc(__pyx_v_self->view.itemsize);
11965 
11966     /* "View.MemoryView":460
11967  *         if <size_t>self.view.itemsize > sizeof(array):
11968  *             tmp = PyMem_Malloc(self.view.itemsize)
11969  *             if tmp == NULL:             # <<<<<<<<<<<<<<
11970  *                 raise MemoryError
11971  *             item = tmp
11972  */
11973     __pyx_t_2 = ((__pyx_v_tmp == NULL) != 0);
11974     if (unlikely(__pyx_t_2)) {
11975 
11976       /* "View.MemoryView":461
11977  *             tmp = PyMem_Malloc(self.view.itemsize)
11978  *             if tmp == NULL:
11979  *                 raise MemoryError             # <<<<<<<<<<<<<<
11980  *             item = tmp
11981  *         else:
11982  */
11983       PyErr_NoMemory(); __PYX_ERR(2, 461, __pyx_L1_error)
11984 
11985       /* "View.MemoryView":460
11986  *         if <size_t>self.view.itemsize > sizeof(array):
11987  *             tmp = PyMem_Malloc(self.view.itemsize)
11988  *             if tmp == NULL:             # <<<<<<<<<<<<<<
11989  *                 raise MemoryError
11990  *             item = tmp
11991  */
11992     }
11993 
11994     /* "View.MemoryView":462
11995  *             if tmp == NULL:
11996  *                 raise MemoryError
11997  *             item = tmp             # <<<<<<<<<<<<<<
11998  *         else:
11999  *             item = <void *> array
12000  */
12001     __pyx_v_item = __pyx_v_tmp;
12002 
12003     /* "View.MemoryView":458
12004  *         dst_slice = get_slice_from_memview(dst, &tmp_slice)
12005  *
12006  *         if <size_t>self.view.itemsize > sizeof(array):             # <<<<<<<<<<<<<<
12007  *             tmp = PyMem_Malloc(self.view.itemsize)
12008  *             if tmp == NULL:
12009  */
12010     goto __pyx_L3;
12011   }
12012 
12013   /* "View.MemoryView":464
12014  *             item = tmp
12015  *         else:
12016  *             item = <void *> array             # <<<<<<<<<<<<<<
12017  *
12018  *         try:
12019  */
12020   /*else*/ {
12021     __pyx_v_item = ((void *)__pyx_v_array);
12022   }
12023   __pyx_L3:;
12024 
12025   /* "View.MemoryView":466
12026  *             item = <void *> array
12027  *
12028  *         try:             # <<<<<<<<<<<<<<
12029  *             if self.dtype_is_object:
12030  *                 (<PyObject **> item)[0] = <PyObject *> value
12031  */
12032   /*try:*/ {
12033 
12034     /* "View.MemoryView":467
12035  *
12036  *         try:
12037  *             if self.dtype_is_object:             # <<<<<<<<<<<<<<
12038  *                 (<PyObject **> item)[0] = <PyObject *> value
12039  *             else:
12040  */
12041     __pyx_t_2 = (__pyx_v_self->dtype_is_object != 0);
12042     if (__pyx_t_2) {
12043 
12044       /* "View.MemoryView":468
12045  *         try:
12046  *             if self.dtype_is_object:
12047  *                 (<PyObject **> item)[0] = <PyObject *> value             # <<<<<<<<<<<<<<
12048  *             else:
12049  *                 self.assign_item_from_object(<char *> item, value)
12050  */
12051       (((PyObject **)__pyx_v_item)[0]) = ((PyObject *)__pyx_v_value);
12052 
12053       /* "View.MemoryView":467
12054  *
12055  *         try:
12056  *             if self.dtype_is_object:             # <<<<<<<<<<<<<<
12057  *                 (<PyObject **> item)[0] = <PyObject *> value
12058  *             else:
12059  */
12060       goto __pyx_L8;
12061     }
12062 
12063     /* "View.MemoryView":470
12064  *                 (<PyObject **> item)[0] = <PyObject *> value
12065  *             else:
12066  *                 self.assign_item_from_object(<char *> item, value)             # <<<<<<<<<<<<<<
12067  *
12068  *
12069  */
12070     /*else*/ {
12071       __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(2, 470, __pyx_L6_error)
12072       __Pyx_GOTREF(__pyx_t_3);
12073       __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
12074     }
12075     __pyx_L8:;
12076 
12077     /* "View.MemoryView":474
12078  *
12079  *
12080  *             if self.view.suboffsets != NULL:             # <<<<<<<<<<<<<<
12081  *                 assert_direct_dimensions(self.view.suboffsets, self.view.ndim)
12082  *             slice_assign_scalar(dst_slice, dst.view.ndim, self.view.itemsize,
12083  */
12084     __pyx_t_2 = ((__pyx_v_self->view.suboffsets != NULL) != 0);
12085     if (__pyx_t_2) {
12086 
12087       /* "View.MemoryView":475
12088  *
12089  *             if self.view.suboffsets != NULL:
12090  *                 assert_direct_dimensions(self.view.suboffsets, self.view.ndim)             # <<<<<<<<<<<<<<
12091  *             slice_assign_scalar(dst_slice, dst.view.ndim, self.view.itemsize,
12092  *                                 item, self.dtype_is_object)
12093  */
12094       __pyx_t_3 = assert_direct_dimensions(__pyx_v_self->view.suboffsets, __pyx_v_self->view.ndim); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 475, __pyx_L6_error)
12095       __Pyx_GOTREF(__pyx_t_3);
12096       __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
12097 
12098       /* "View.MemoryView":474
12099  *
12100  *
12101  *             if self.view.suboffsets != NULL:             # <<<<<<<<<<<<<<
12102  *                 assert_direct_dimensions(self.view.suboffsets, self.view.ndim)
12103  *             slice_assign_scalar(dst_slice, dst.view.ndim, self.view.itemsize,
12104  */
12105     }
12106 
12107     /* "View.MemoryView":476
12108  *             if self.view.suboffsets != NULL:
12109  *                 assert_direct_dimensions(self.view.suboffsets, self.view.ndim)
12110  *             slice_assign_scalar(dst_slice, dst.view.ndim, self.view.itemsize,             # <<<<<<<<<<<<<<
12111  *                                 item, self.dtype_is_object)
12112  *         finally:
12113  */
12114     __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);
12115   }
12116 
12117   /* "View.MemoryView":479
12118  *                                 item, self.dtype_is_object)
12119  *         finally:
12120  *             PyMem_Free(tmp)             # <<<<<<<<<<<<<<
12121  *
12122  *     cdef setitem_indexed(self, index, value):
12123  */
12124   /*finally:*/ {
12125     /*normal exit:*/{
12126       PyMem_Free(__pyx_v_tmp);
12127       goto __pyx_L7;
12128     }
12129     __pyx_L6_error:;
12130     /*exception exit:*/{
12131       __Pyx_PyThreadState_declare
12132       __Pyx_PyThreadState_assign
12133       __pyx_t_7 = 0; __pyx_t_8 = 0; __pyx_t_9 = 0; __pyx_t_10 = 0; __pyx_t_11 = 0; __pyx_t_12 = 0;
12134       __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
12135       if (PY_MAJOR_VERSION >= 3) __Pyx_ExceptionSwap(&__pyx_t_10, &__pyx_t_11, &__pyx_t_12);
12136       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);
12137       __Pyx_XGOTREF(__pyx_t_7);
12138       __Pyx_XGOTREF(__pyx_t_8);
12139       __Pyx_XGOTREF(__pyx_t_9);
12140       __Pyx_XGOTREF(__pyx_t_10);
12141       __Pyx_XGOTREF(__pyx_t_11);
12142       __Pyx_XGOTREF(__pyx_t_12);
12143       __pyx_t_4 = __pyx_lineno; __pyx_t_5 = __pyx_clineno; __pyx_t_6 = __pyx_filename;
12144       {
12145         PyMem_Free(__pyx_v_tmp);
12146       }
12147       if (PY_MAJOR_VERSION >= 3) {
12148         __Pyx_XGIVEREF(__pyx_t_10);
12149         __Pyx_XGIVEREF(__pyx_t_11);
12150         __Pyx_XGIVEREF(__pyx_t_12);
12151         __Pyx_ExceptionReset(__pyx_t_10, __pyx_t_11, __pyx_t_12);
12152       }
12153       __Pyx_XGIVEREF(__pyx_t_7);
12154       __Pyx_XGIVEREF(__pyx_t_8);
12155       __Pyx_XGIVEREF(__pyx_t_9);
12156       __Pyx_ErrRestore(__pyx_t_7, __pyx_t_8, __pyx_t_9);
12157       __pyx_t_7 = 0; __pyx_t_8 = 0; __pyx_t_9 = 0; __pyx_t_10 = 0; __pyx_t_11 = 0; __pyx_t_12 = 0;
12158       __pyx_lineno = __pyx_t_4; __pyx_clineno = __pyx_t_5; __pyx_filename = __pyx_t_6;
12159       goto __pyx_L1_error;
12160     }
12161     __pyx_L7:;
12162   }
12163 
12164   /* "View.MemoryView":449
12165  *                                  src.ndim, dst.ndim, self.dtype_is_object)
12166  *
12167  *     cdef setitem_slice_assign_scalar(self, memoryview dst, value):             # <<<<<<<<<<<<<<
12168  *         cdef int array[128]
12169  *         cdef void *tmp = NULL
12170  */
12171 
12172   /* function exit code */
12173   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
12174   goto __pyx_L0;
12175   __pyx_L1_error:;
12176   __Pyx_XDECREF(__pyx_t_3);
12177   __Pyx_AddTraceback("View.MemoryView.memoryview.setitem_slice_assign_scalar", __pyx_clineno, __pyx_lineno, __pyx_filename);
12178   __pyx_r = 0;
12179   __pyx_L0:;
12180   __Pyx_XGIVEREF(__pyx_r);
12181   __Pyx_RefNannyFinishContext();
12182   return __pyx_r;
12183 }
12184 
12185 /* "View.MemoryView":481
12186  *             PyMem_Free(tmp)
12187  *
12188  *     cdef setitem_indexed(self, index, value):             # <<<<<<<<<<<<<<
12189  *         cdef char *itemp = self.get_item_pointer(index)
12190  *         self.assign_item_from_object(itemp, value)
12191  */
12192 
__pyx_memoryview_setitem_indexed(struct __pyx_memoryview_obj * __pyx_v_self,PyObject * __pyx_v_index,PyObject * __pyx_v_value)12193 static PyObject *__pyx_memoryview_setitem_indexed(struct __pyx_memoryview_obj *__pyx_v_self, PyObject *__pyx_v_index, PyObject *__pyx_v_value) {
12194   char *__pyx_v_itemp;
12195   PyObject *__pyx_r = NULL;
12196   __Pyx_RefNannyDeclarations
12197   char *__pyx_t_1;
12198   PyObject *__pyx_t_2 = NULL;
12199   int __pyx_lineno = 0;
12200   const char *__pyx_filename = NULL;
12201   int __pyx_clineno = 0;
12202   __Pyx_RefNannySetupContext("setitem_indexed", 0);
12203 
12204   /* "View.MemoryView":482
12205  *
12206  *     cdef setitem_indexed(self, index, value):
12207  *         cdef char *itemp = self.get_item_pointer(index)             # <<<<<<<<<<<<<<
12208  *         self.assign_item_from_object(itemp, value)
12209  *
12210  */
12211   __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(2, 482, __pyx_L1_error)
12212   __pyx_v_itemp = __pyx_t_1;
12213 
12214   /* "View.MemoryView":483
12215  *     cdef setitem_indexed(self, index, value):
12216  *         cdef char *itemp = self.get_item_pointer(index)
12217  *         self.assign_item_from_object(itemp, value)             # <<<<<<<<<<<<<<
12218  *
12219  *     cdef convert_item_to_object(self, char *itemp):
12220  */
12221   __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(2, 483, __pyx_L1_error)
12222   __Pyx_GOTREF(__pyx_t_2);
12223   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
12224 
12225   /* "View.MemoryView":481
12226  *             PyMem_Free(tmp)
12227  *
12228  *     cdef setitem_indexed(self, index, value):             # <<<<<<<<<<<<<<
12229  *         cdef char *itemp = self.get_item_pointer(index)
12230  *         self.assign_item_from_object(itemp, value)
12231  */
12232 
12233   /* function exit code */
12234   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
12235   goto __pyx_L0;
12236   __pyx_L1_error:;
12237   __Pyx_XDECREF(__pyx_t_2);
12238   __Pyx_AddTraceback("View.MemoryView.memoryview.setitem_indexed", __pyx_clineno, __pyx_lineno, __pyx_filename);
12239   __pyx_r = 0;
12240   __pyx_L0:;
12241   __Pyx_XGIVEREF(__pyx_r);
12242   __Pyx_RefNannyFinishContext();
12243   return __pyx_r;
12244 }
12245 
12246 /* "View.MemoryView":485
12247  *         self.assign_item_from_object(itemp, value)
12248  *
12249  *     cdef convert_item_to_object(self, char *itemp):             # <<<<<<<<<<<<<<
12250  *         """Only used if instantiated manually by the user, or if Cython doesn't
12251  *         know how to convert the type"""
12252  */
12253 
__pyx_memoryview_convert_item_to_object(struct __pyx_memoryview_obj * __pyx_v_self,char * __pyx_v_itemp)12254 static PyObject *__pyx_memoryview_convert_item_to_object(struct __pyx_memoryview_obj *__pyx_v_self, char *__pyx_v_itemp) {
12255   PyObject *__pyx_v_struct = NULL;
12256   PyObject *__pyx_v_bytesitem = 0;
12257   PyObject *__pyx_v_result = NULL;
12258   PyObject *__pyx_r = NULL;
12259   __Pyx_RefNannyDeclarations
12260   PyObject *__pyx_t_1 = NULL;
12261   PyObject *__pyx_t_2 = NULL;
12262   PyObject *__pyx_t_3 = NULL;
12263   PyObject *__pyx_t_4 = NULL;
12264   PyObject *__pyx_t_5 = NULL;
12265   PyObject *__pyx_t_6 = NULL;
12266   PyObject *__pyx_t_7 = NULL;
12267   int __pyx_t_8;
12268   PyObject *__pyx_t_9 = NULL;
12269   size_t __pyx_t_10;
12270   int __pyx_t_11;
12271   int __pyx_lineno = 0;
12272   const char *__pyx_filename = NULL;
12273   int __pyx_clineno = 0;
12274   __Pyx_RefNannySetupContext("convert_item_to_object", 0);
12275 
12276   /* "View.MemoryView":488
12277  *         """Only used if instantiated manually by the user, or if Cython doesn't
12278  *         know how to convert the type"""
12279  *         import struct             # <<<<<<<<<<<<<<
12280  *         cdef bytes bytesitem
12281  *
12282  */
12283   __pyx_t_1 = __Pyx_Import(__pyx_n_s_struct, 0, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 488, __pyx_L1_error)
12284   __Pyx_GOTREF(__pyx_t_1);
12285   __pyx_v_struct = __pyx_t_1;
12286   __pyx_t_1 = 0;
12287 
12288   /* "View.MemoryView":491
12289  *         cdef bytes bytesitem
12290  *
12291  *         bytesitem = itemp[:self.view.itemsize]             # <<<<<<<<<<<<<<
12292  *         try:
12293  *             result = struct.unpack(self.view.format, bytesitem)
12294  */
12295   __pyx_t_1 = __Pyx_PyBytes_FromStringAndSize(__pyx_v_itemp + 0, __pyx_v_self->view.itemsize - 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 491, __pyx_L1_error)
12296   __Pyx_GOTREF(__pyx_t_1);
12297   __pyx_v_bytesitem = ((PyObject*)__pyx_t_1);
12298   __pyx_t_1 = 0;
12299 
12300   /* "View.MemoryView":492
12301  *
12302  *         bytesitem = itemp[:self.view.itemsize]
12303  *         try:             # <<<<<<<<<<<<<<
12304  *             result = struct.unpack(self.view.format, bytesitem)
12305  *         except struct.error:
12306  */
12307   {
12308     __Pyx_PyThreadState_declare
12309     __Pyx_PyThreadState_assign
12310     __Pyx_ExceptionSave(&__pyx_t_2, &__pyx_t_3, &__pyx_t_4);
12311     __Pyx_XGOTREF(__pyx_t_2);
12312     __Pyx_XGOTREF(__pyx_t_3);
12313     __Pyx_XGOTREF(__pyx_t_4);
12314     /*try:*/ {
12315 
12316       /* "View.MemoryView":493
12317  *         bytesitem = itemp[:self.view.itemsize]
12318  *         try:
12319  *             result = struct.unpack(self.view.format, bytesitem)             # <<<<<<<<<<<<<<
12320  *         except struct.error:
12321  *             raise ValueError("Unable to convert item to object")
12322  */
12323       __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_struct, __pyx_n_s_unpack); if (unlikely(!__pyx_t_5)) __PYX_ERR(2, 493, __pyx_L3_error)
12324       __Pyx_GOTREF(__pyx_t_5);
12325       __pyx_t_6 = __Pyx_PyBytes_FromString(__pyx_v_self->view.format); if (unlikely(!__pyx_t_6)) __PYX_ERR(2, 493, __pyx_L3_error)
12326       __Pyx_GOTREF(__pyx_t_6);
12327       __pyx_t_7 = NULL;
12328       __pyx_t_8 = 0;
12329       if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_5))) {
12330         __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_5);
12331         if (likely(__pyx_t_7)) {
12332           PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
12333           __Pyx_INCREF(__pyx_t_7);
12334           __Pyx_INCREF(function);
12335           __Pyx_DECREF_SET(__pyx_t_5, function);
12336           __pyx_t_8 = 1;
12337         }
12338       }
12339       #if CYTHON_FAST_PYCALL
12340       if (PyFunction_Check(__pyx_t_5)) {
12341         PyObject *__pyx_temp[3] = {__pyx_t_7, __pyx_t_6, __pyx_v_bytesitem};
12342         __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(2, 493, __pyx_L3_error)
12343         __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
12344         __Pyx_GOTREF(__pyx_t_1);
12345         __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
12346       } else
12347       #endif
12348       #if CYTHON_FAST_PYCCALL
12349       if (__Pyx_PyFastCFunction_Check(__pyx_t_5)) {
12350         PyObject *__pyx_temp[3] = {__pyx_t_7, __pyx_t_6, __pyx_v_bytesitem};
12351         __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(2, 493, __pyx_L3_error)
12352         __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
12353         __Pyx_GOTREF(__pyx_t_1);
12354         __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
12355       } else
12356       #endif
12357       {
12358         __pyx_t_9 = PyTuple_New(2+__pyx_t_8); if (unlikely(!__pyx_t_9)) __PYX_ERR(2, 493, __pyx_L3_error)
12359         __Pyx_GOTREF(__pyx_t_9);
12360         if (__pyx_t_7) {
12361           __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_7); __pyx_t_7 = NULL;
12362         }
12363         __Pyx_GIVEREF(__pyx_t_6);
12364         PyTuple_SET_ITEM(__pyx_t_9, 0+__pyx_t_8, __pyx_t_6);
12365         __Pyx_INCREF(__pyx_v_bytesitem);
12366         __Pyx_GIVEREF(__pyx_v_bytesitem);
12367         PyTuple_SET_ITEM(__pyx_t_9, 1+__pyx_t_8, __pyx_v_bytesitem);
12368         __pyx_t_6 = 0;
12369         __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_9, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 493, __pyx_L3_error)
12370         __Pyx_GOTREF(__pyx_t_1);
12371         __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
12372       }
12373       __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
12374       __pyx_v_result = __pyx_t_1;
12375       __pyx_t_1 = 0;
12376 
12377       /* "View.MemoryView":492
12378  *
12379  *         bytesitem = itemp[:self.view.itemsize]
12380  *         try:             # <<<<<<<<<<<<<<
12381  *             result = struct.unpack(self.view.format, bytesitem)
12382  *         except struct.error:
12383  */
12384     }
12385 
12386     /* "View.MemoryView":497
12387  *             raise ValueError("Unable to convert item to object")
12388  *         else:
12389  *             if len(self.view.format) == 1:             # <<<<<<<<<<<<<<
12390  *                 return result[0]
12391  *             return result
12392  */
12393     /*else:*/ {
12394       __pyx_t_10 = strlen(__pyx_v_self->view.format);
12395       __pyx_t_11 = ((__pyx_t_10 == 1) != 0);
12396       if (__pyx_t_11) {
12397 
12398         /* "View.MemoryView":498
12399  *         else:
12400  *             if len(self.view.format) == 1:
12401  *                 return result[0]             # <<<<<<<<<<<<<<
12402  *             return result
12403  *
12404  */
12405         __Pyx_XDECREF(__pyx_r);
12406         __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(2, 498, __pyx_L5_except_error)
12407         __Pyx_GOTREF(__pyx_t_1);
12408         __pyx_r = __pyx_t_1;
12409         __pyx_t_1 = 0;
12410         goto __pyx_L6_except_return;
12411 
12412         /* "View.MemoryView":497
12413  *             raise ValueError("Unable to convert item to object")
12414  *         else:
12415  *             if len(self.view.format) == 1:             # <<<<<<<<<<<<<<
12416  *                 return result[0]
12417  *             return result
12418  */
12419       }
12420 
12421       /* "View.MemoryView":499
12422  *             if len(self.view.format) == 1:
12423  *                 return result[0]
12424  *             return result             # <<<<<<<<<<<<<<
12425  *
12426  *     cdef assign_item_from_object(self, char *itemp, object value):
12427  */
12428       __Pyx_XDECREF(__pyx_r);
12429       __Pyx_INCREF(__pyx_v_result);
12430       __pyx_r = __pyx_v_result;
12431       goto __pyx_L6_except_return;
12432     }
12433     __pyx_L3_error:;
12434     __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
12435     __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
12436     __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
12437     __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
12438     __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
12439 
12440     /* "View.MemoryView":494
12441  *         try:
12442  *             result = struct.unpack(self.view.format, bytesitem)
12443  *         except struct.error:             # <<<<<<<<<<<<<<
12444  *             raise ValueError("Unable to convert item to object")
12445  *         else:
12446  */
12447     __Pyx_ErrFetch(&__pyx_t_1, &__pyx_t_5, &__pyx_t_9);
12448     __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_struct, __pyx_n_s_error); if (unlikely(!__pyx_t_6)) __PYX_ERR(2, 494, __pyx_L5_except_error)
12449     __Pyx_GOTREF(__pyx_t_6);
12450     __pyx_t_8 = __Pyx_PyErr_GivenExceptionMatches(__pyx_t_1, __pyx_t_6);
12451     __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
12452     __Pyx_ErrRestore(__pyx_t_1, __pyx_t_5, __pyx_t_9);
12453     __pyx_t_1 = 0; __pyx_t_5 = 0; __pyx_t_9 = 0;
12454     if (__pyx_t_8) {
12455       __Pyx_AddTraceback("View.MemoryView.memoryview.convert_item_to_object", __pyx_clineno, __pyx_lineno, __pyx_filename);
12456       if (__Pyx_GetException(&__pyx_t_9, &__pyx_t_5, &__pyx_t_1) < 0) __PYX_ERR(2, 494, __pyx_L5_except_error)
12457       __Pyx_GOTREF(__pyx_t_9);
12458       __Pyx_GOTREF(__pyx_t_5);
12459       __Pyx_GOTREF(__pyx_t_1);
12460 
12461       /* "View.MemoryView":495
12462  *             result = struct.unpack(self.view.format, bytesitem)
12463  *         except struct.error:
12464  *             raise ValueError("Unable to convert item to object")             # <<<<<<<<<<<<<<
12465  *         else:
12466  *             if len(self.view.format) == 1:
12467  */
12468       __pyx_t_6 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__14, NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(2, 495, __pyx_L5_except_error)
12469       __Pyx_GOTREF(__pyx_t_6);
12470       __Pyx_Raise(__pyx_t_6, 0, 0, 0);
12471       __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
12472       __PYX_ERR(2, 495, __pyx_L5_except_error)
12473     }
12474     goto __pyx_L5_except_error;
12475     __pyx_L5_except_error:;
12476 
12477     /* "View.MemoryView":492
12478  *
12479  *         bytesitem = itemp[:self.view.itemsize]
12480  *         try:             # <<<<<<<<<<<<<<
12481  *             result = struct.unpack(self.view.format, bytesitem)
12482  *         except struct.error:
12483  */
12484     __Pyx_XGIVEREF(__pyx_t_2);
12485     __Pyx_XGIVEREF(__pyx_t_3);
12486     __Pyx_XGIVEREF(__pyx_t_4);
12487     __Pyx_ExceptionReset(__pyx_t_2, __pyx_t_3, __pyx_t_4);
12488     goto __pyx_L1_error;
12489     __pyx_L6_except_return:;
12490     __Pyx_XGIVEREF(__pyx_t_2);
12491     __Pyx_XGIVEREF(__pyx_t_3);
12492     __Pyx_XGIVEREF(__pyx_t_4);
12493     __Pyx_ExceptionReset(__pyx_t_2, __pyx_t_3, __pyx_t_4);
12494     goto __pyx_L0;
12495   }
12496 
12497   /* "View.MemoryView":485
12498  *         self.assign_item_from_object(itemp, value)
12499  *
12500  *     cdef convert_item_to_object(self, char *itemp):             # <<<<<<<<<<<<<<
12501  *         """Only used if instantiated manually by the user, or if Cython doesn't
12502  *         know how to convert the type"""
12503  */
12504 
12505   /* function exit code */
12506   __pyx_L1_error:;
12507   __Pyx_XDECREF(__pyx_t_1);
12508   __Pyx_XDECREF(__pyx_t_5);
12509   __Pyx_XDECREF(__pyx_t_6);
12510   __Pyx_XDECREF(__pyx_t_7);
12511   __Pyx_XDECREF(__pyx_t_9);
12512   __Pyx_AddTraceback("View.MemoryView.memoryview.convert_item_to_object", __pyx_clineno, __pyx_lineno, __pyx_filename);
12513   __pyx_r = 0;
12514   __pyx_L0:;
12515   __Pyx_XDECREF(__pyx_v_struct);
12516   __Pyx_XDECREF(__pyx_v_bytesitem);
12517   __Pyx_XDECREF(__pyx_v_result);
12518   __Pyx_XGIVEREF(__pyx_r);
12519   __Pyx_RefNannyFinishContext();
12520   return __pyx_r;
12521 }
12522 
12523 /* "View.MemoryView":501
12524  *             return result
12525  *
12526  *     cdef assign_item_from_object(self, char *itemp, object value):             # <<<<<<<<<<<<<<
12527  *         """Only used if instantiated manually by the user, or if Cython doesn't
12528  *         know how to convert the type"""
12529  */
12530 
__pyx_memoryview_assign_item_from_object(struct __pyx_memoryview_obj * __pyx_v_self,char * __pyx_v_itemp,PyObject * __pyx_v_value)12531 static PyObject *__pyx_memoryview_assign_item_from_object(struct __pyx_memoryview_obj *__pyx_v_self, char *__pyx_v_itemp, PyObject *__pyx_v_value) {
12532   PyObject *__pyx_v_struct = NULL;
12533   char __pyx_v_c;
12534   PyObject *__pyx_v_bytesvalue = 0;
12535   Py_ssize_t __pyx_v_i;
12536   PyObject *__pyx_r = NULL;
12537   __Pyx_RefNannyDeclarations
12538   PyObject *__pyx_t_1 = NULL;
12539   int __pyx_t_2;
12540   int __pyx_t_3;
12541   PyObject *__pyx_t_4 = NULL;
12542   PyObject *__pyx_t_5 = NULL;
12543   PyObject *__pyx_t_6 = NULL;
12544   int __pyx_t_7;
12545   PyObject *__pyx_t_8 = NULL;
12546   Py_ssize_t __pyx_t_9;
12547   PyObject *__pyx_t_10 = NULL;
12548   char *__pyx_t_11;
12549   char *__pyx_t_12;
12550   char *__pyx_t_13;
12551   char *__pyx_t_14;
12552   int __pyx_lineno = 0;
12553   const char *__pyx_filename = NULL;
12554   int __pyx_clineno = 0;
12555   __Pyx_RefNannySetupContext("assign_item_from_object", 0);
12556 
12557   /* "View.MemoryView":504
12558  *         """Only used if instantiated manually by the user, or if Cython doesn't
12559  *         know how to convert the type"""
12560  *         import struct             # <<<<<<<<<<<<<<
12561  *         cdef char c
12562  *         cdef bytes bytesvalue
12563  */
12564   __pyx_t_1 = __Pyx_Import(__pyx_n_s_struct, 0, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 504, __pyx_L1_error)
12565   __Pyx_GOTREF(__pyx_t_1);
12566   __pyx_v_struct = __pyx_t_1;
12567   __pyx_t_1 = 0;
12568 
12569   /* "View.MemoryView":509
12570  *         cdef Py_ssize_t i
12571  *
12572  *         if isinstance(value, tuple):             # <<<<<<<<<<<<<<
12573  *             bytesvalue = struct.pack(self.view.format, *value)
12574  *         else:
12575  */
12576   __pyx_t_2 = PyTuple_Check(__pyx_v_value);
12577   __pyx_t_3 = (__pyx_t_2 != 0);
12578   if (__pyx_t_3) {
12579 
12580     /* "View.MemoryView":510
12581  *
12582  *         if isinstance(value, tuple):
12583  *             bytesvalue = struct.pack(self.view.format, *value)             # <<<<<<<<<<<<<<
12584  *         else:
12585  *             bytesvalue = struct.pack(self.view.format, value)
12586  */
12587     __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_struct, __pyx_n_s_pack); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 510, __pyx_L1_error)
12588     __Pyx_GOTREF(__pyx_t_1);
12589     __pyx_t_4 = __Pyx_PyBytes_FromString(__pyx_v_self->view.format); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 510, __pyx_L1_error)
12590     __Pyx_GOTREF(__pyx_t_4);
12591     __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) __PYX_ERR(2, 510, __pyx_L1_error)
12592     __Pyx_GOTREF(__pyx_t_5);
12593     __Pyx_GIVEREF(__pyx_t_4);
12594     PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_4);
12595     __pyx_t_4 = 0;
12596     __pyx_t_4 = __Pyx_PySequence_Tuple(__pyx_v_value); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 510, __pyx_L1_error)
12597     __Pyx_GOTREF(__pyx_t_4);
12598     __pyx_t_6 = PyNumber_Add(__pyx_t_5, __pyx_t_4); if (unlikely(!__pyx_t_6)) __PYX_ERR(2, 510, __pyx_L1_error)
12599     __Pyx_GOTREF(__pyx_t_6);
12600     __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
12601     __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
12602     __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_6, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 510, __pyx_L1_error)
12603     __Pyx_GOTREF(__pyx_t_4);
12604     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
12605     __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
12606     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(2, 510, __pyx_L1_error)
12607     __pyx_v_bytesvalue = ((PyObject*)__pyx_t_4);
12608     __pyx_t_4 = 0;
12609 
12610     /* "View.MemoryView":509
12611  *         cdef Py_ssize_t i
12612  *
12613  *         if isinstance(value, tuple):             # <<<<<<<<<<<<<<
12614  *             bytesvalue = struct.pack(self.view.format, *value)
12615  *         else:
12616  */
12617     goto __pyx_L3;
12618   }
12619 
12620   /* "View.MemoryView":512
12621  *             bytesvalue = struct.pack(self.view.format, *value)
12622  *         else:
12623  *             bytesvalue = struct.pack(self.view.format, value)             # <<<<<<<<<<<<<<
12624  *
12625  *         for i, c in enumerate(bytesvalue):
12626  */
12627   /*else*/ {
12628     __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_struct, __pyx_n_s_pack); if (unlikely(!__pyx_t_6)) __PYX_ERR(2, 512, __pyx_L1_error)
12629     __Pyx_GOTREF(__pyx_t_6);
12630     __pyx_t_1 = __Pyx_PyBytes_FromString(__pyx_v_self->view.format); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 512, __pyx_L1_error)
12631     __Pyx_GOTREF(__pyx_t_1);
12632     __pyx_t_5 = NULL;
12633     __pyx_t_7 = 0;
12634     if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_6))) {
12635       __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_6);
12636       if (likely(__pyx_t_5)) {
12637         PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
12638         __Pyx_INCREF(__pyx_t_5);
12639         __Pyx_INCREF(function);
12640         __Pyx_DECREF_SET(__pyx_t_6, function);
12641         __pyx_t_7 = 1;
12642       }
12643     }
12644     #if CYTHON_FAST_PYCALL
12645     if (PyFunction_Check(__pyx_t_6)) {
12646       PyObject *__pyx_temp[3] = {__pyx_t_5, __pyx_t_1, __pyx_v_value};
12647       __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(2, 512, __pyx_L1_error)
12648       __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
12649       __Pyx_GOTREF(__pyx_t_4);
12650       __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
12651     } else
12652     #endif
12653     #if CYTHON_FAST_PYCCALL
12654     if (__Pyx_PyFastCFunction_Check(__pyx_t_6)) {
12655       PyObject *__pyx_temp[3] = {__pyx_t_5, __pyx_t_1, __pyx_v_value};
12656       __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(2, 512, __pyx_L1_error)
12657       __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
12658       __Pyx_GOTREF(__pyx_t_4);
12659       __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
12660     } else
12661     #endif
12662     {
12663       __pyx_t_8 = PyTuple_New(2+__pyx_t_7); if (unlikely(!__pyx_t_8)) __PYX_ERR(2, 512, __pyx_L1_error)
12664       __Pyx_GOTREF(__pyx_t_8);
12665       if (__pyx_t_5) {
12666         __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_5); __pyx_t_5 = NULL;
12667       }
12668       __Pyx_GIVEREF(__pyx_t_1);
12669       PyTuple_SET_ITEM(__pyx_t_8, 0+__pyx_t_7, __pyx_t_1);
12670       __Pyx_INCREF(__pyx_v_value);
12671       __Pyx_GIVEREF(__pyx_v_value);
12672       PyTuple_SET_ITEM(__pyx_t_8, 1+__pyx_t_7, __pyx_v_value);
12673       __pyx_t_1 = 0;
12674       __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_8, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 512, __pyx_L1_error)
12675       __Pyx_GOTREF(__pyx_t_4);
12676       __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
12677     }
12678     __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
12679     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(2, 512, __pyx_L1_error)
12680     __pyx_v_bytesvalue = ((PyObject*)__pyx_t_4);
12681     __pyx_t_4 = 0;
12682   }
12683   __pyx_L3:;
12684 
12685   /* "View.MemoryView":514
12686  *             bytesvalue = struct.pack(self.view.format, value)
12687  *
12688  *         for i, c in enumerate(bytesvalue):             # <<<<<<<<<<<<<<
12689  *             itemp[i] = c
12690  *
12691  */
12692   __pyx_t_9 = 0;
12693   if (unlikely(__pyx_v_bytesvalue == Py_None)) {
12694     PyErr_SetString(PyExc_TypeError, "'NoneType' is not iterable");
12695     __PYX_ERR(2, 514, __pyx_L1_error)
12696   }
12697   __Pyx_INCREF(__pyx_v_bytesvalue);
12698   __pyx_t_10 = __pyx_v_bytesvalue;
12699   __pyx_t_12 = PyBytes_AS_STRING(__pyx_t_10);
12700   __pyx_t_13 = (__pyx_t_12 + PyBytes_GET_SIZE(__pyx_t_10));
12701   for (__pyx_t_14 = __pyx_t_12; __pyx_t_14 < __pyx_t_13; __pyx_t_14++) {
12702     __pyx_t_11 = __pyx_t_14;
12703     __pyx_v_c = (__pyx_t_11[0]);
12704 
12705     /* "View.MemoryView":515
12706  *
12707  *         for i, c in enumerate(bytesvalue):
12708  *             itemp[i] = c             # <<<<<<<<<<<<<<
12709  *
12710  *     @cname('getbuffer')
12711  */
12712     __pyx_v_i = __pyx_t_9;
12713 
12714     /* "View.MemoryView":514
12715  *             bytesvalue = struct.pack(self.view.format, value)
12716  *
12717  *         for i, c in enumerate(bytesvalue):             # <<<<<<<<<<<<<<
12718  *             itemp[i] = c
12719  *
12720  */
12721     __pyx_t_9 = (__pyx_t_9 + 1);
12722 
12723     /* "View.MemoryView":515
12724  *
12725  *         for i, c in enumerate(bytesvalue):
12726  *             itemp[i] = c             # <<<<<<<<<<<<<<
12727  *
12728  *     @cname('getbuffer')
12729  */
12730     (__pyx_v_itemp[__pyx_v_i]) = __pyx_v_c;
12731   }
12732   __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
12733 
12734   /* "View.MemoryView":501
12735  *             return result
12736  *
12737  *     cdef assign_item_from_object(self, char *itemp, object value):             # <<<<<<<<<<<<<<
12738  *         """Only used if instantiated manually by the user, or if Cython doesn't
12739  *         know how to convert the type"""
12740  */
12741 
12742   /* function exit code */
12743   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
12744   goto __pyx_L0;
12745   __pyx_L1_error:;
12746   __Pyx_XDECREF(__pyx_t_1);
12747   __Pyx_XDECREF(__pyx_t_4);
12748   __Pyx_XDECREF(__pyx_t_5);
12749   __Pyx_XDECREF(__pyx_t_6);
12750   __Pyx_XDECREF(__pyx_t_8);
12751   __Pyx_XDECREF(__pyx_t_10);
12752   __Pyx_AddTraceback("View.MemoryView.memoryview.assign_item_from_object", __pyx_clineno, __pyx_lineno, __pyx_filename);
12753   __pyx_r = 0;
12754   __pyx_L0:;
12755   __Pyx_XDECREF(__pyx_v_struct);
12756   __Pyx_XDECREF(__pyx_v_bytesvalue);
12757   __Pyx_XGIVEREF(__pyx_r);
12758   __Pyx_RefNannyFinishContext();
12759   return __pyx_r;
12760 }
12761 
12762 /* "View.MemoryView":518
12763  *
12764  *     @cname('getbuffer')
12765  *     def __getbuffer__(self, Py_buffer *info, int flags):             # <<<<<<<<<<<<<<
12766  *         if flags & PyBUF_WRITABLE and self.view.readonly:
12767  *             raise ValueError("Cannot create writable memory view from read-only memoryview")
12768  */
12769 
12770 /* Python wrapper */
12771 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)12772 static CYTHON_UNUSED int __pyx_memoryview_getbuffer(PyObject *__pyx_v_self, Py_buffer *__pyx_v_info, int __pyx_v_flags) {
12773   int __pyx_r;
12774   __Pyx_RefNannyDeclarations
12775   __Pyx_RefNannySetupContext("__getbuffer__ (wrapper)", 0);
12776   __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));
12777 
12778   /* function exit code */
12779   __Pyx_RefNannyFinishContext();
12780   return __pyx_r;
12781 }
12782 
__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)12783 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) {
12784   int __pyx_r;
12785   __Pyx_RefNannyDeclarations
12786   int __pyx_t_1;
12787   int __pyx_t_2;
12788   PyObject *__pyx_t_3 = NULL;
12789   Py_ssize_t *__pyx_t_4;
12790   char *__pyx_t_5;
12791   void *__pyx_t_6;
12792   int __pyx_t_7;
12793   Py_ssize_t __pyx_t_8;
12794   int __pyx_lineno = 0;
12795   const char *__pyx_filename = NULL;
12796   int __pyx_clineno = 0;
12797   if (__pyx_v_info == NULL) {
12798     PyErr_SetString(PyExc_BufferError, "PyObject_GetBuffer: view==NULL argument is obsolete");
12799     return -1;
12800   }
12801   __Pyx_RefNannySetupContext("__getbuffer__", 0);
12802   __pyx_v_info->obj = Py_None; __Pyx_INCREF(Py_None);
12803   __Pyx_GIVEREF(__pyx_v_info->obj);
12804 
12805   /* "View.MemoryView":519
12806  *     @cname('getbuffer')
12807  *     def __getbuffer__(self, Py_buffer *info, int flags):
12808  *         if flags & PyBUF_WRITABLE and self.view.readonly:             # <<<<<<<<<<<<<<
12809  *             raise ValueError("Cannot create writable memory view from read-only memoryview")
12810  *
12811  */
12812   __pyx_t_2 = ((__pyx_v_flags & PyBUF_WRITABLE) != 0);
12813   if (__pyx_t_2) {
12814   } else {
12815     __pyx_t_1 = __pyx_t_2;
12816     goto __pyx_L4_bool_binop_done;
12817   }
12818   __pyx_t_2 = (__pyx_v_self->view.readonly != 0);
12819   __pyx_t_1 = __pyx_t_2;
12820   __pyx_L4_bool_binop_done:;
12821   if (unlikely(__pyx_t_1)) {
12822 
12823     /* "View.MemoryView":520
12824  *     def __getbuffer__(self, Py_buffer *info, int flags):
12825  *         if flags & PyBUF_WRITABLE and self.view.readonly:
12826  *             raise ValueError("Cannot create writable memory view from read-only memoryview")             # <<<<<<<<<<<<<<
12827  *
12828  *         if flags & PyBUF_ND:
12829  */
12830     __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__15, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 520, __pyx_L1_error)
12831     __Pyx_GOTREF(__pyx_t_3);
12832     __Pyx_Raise(__pyx_t_3, 0, 0, 0);
12833     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
12834     __PYX_ERR(2, 520, __pyx_L1_error)
12835 
12836     /* "View.MemoryView":519
12837  *     @cname('getbuffer')
12838  *     def __getbuffer__(self, Py_buffer *info, int flags):
12839  *         if flags & PyBUF_WRITABLE and self.view.readonly:             # <<<<<<<<<<<<<<
12840  *             raise ValueError("Cannot create writable memory view from read-only memoryview")
12841  *
12842  */
12843   }
12844 
12845   /* "View.MemoryView":522
12846  *             raise ValueError("Cannot create writable memory view from read-only memoryview")
12847  *
12848  *         if flags & PyBUF_ND:             # <<<<<<<<<<<<<<
12849  *             info.shape = self.view.shape
12850  *         else:
12851  */
12852   __pyx_t_1 = ((__pyx_v_flags & PyBUF_ND) != 0);
12853   if (__pyx_t_1) {
12854 
12855     /* "View.MemoryView":523
12856  *
12857  *         if flags & PyBUF_ND:
12858  *             info.shape = self.view.shape             # <<<<<<<<<<<<<<
12859  *         else:
12860  *             info.shape = NULL
12861  */
12862     __pyx_t_4 = __pyx_v_self->view.shape;
12863     __pyx_v_info->shape = __pyx_t_4;
12864 
12865     /* "View.MemoryView":522
12866  *             raise ValueError("Cannot create writable memory view from read-only memoryview")
12867  *
12868  *         if flags & PyBUF_ND:             # <<<<<<<<<<<<<<
12869  *             info.shape = self.view.shape
12870  *         else:
12871  */
12872     goto __pyx_L6;
12873   }
12874 
12875   /* "View.MemoryView":525
12876  *             info.shape = self.view.shape
12877  *         else:
12878  *             info.shape = NULL             # <<<<<<<<<<<<<<
12879  *
12880  *         if flags & PyBUF_STRIDES:
12881  */
12882   /*else*/ {
12883     __pyx_v_info->shape = NULL;
12884   }
12885   __pyx_L6:;
12886 
12887   /* "View.MemoryView":527
12888  *             info.shape = NULL
12889  *
12890  *         if flags & PyBUF_STRIDES:             # <<<<<<<<<<<<<<
12891  *             info.strides = self.view.strides
12892  *         else:
12893  */
12894   __pyx_t_1 = ((__pyx_v_flags & PyBUF_STRIDES) != 0);
12895   if (__pyx_t_1) {
12896 
12897     /* "View.MemoryView":528
12898  *
12899  *         if flags & PyBUF_STRIDES:
12900  *             info.strides = self.view.strides             # <<<<<<<<<<<<<<
12901  *         else:
12902  *             info.strides = NULL
12903  */
12904     __pyx_t_4 = __pyx_v_self->view.strides;
12905     __pyx_v_info->strides = __pyx_t_4;
12906 
12907     /* "View.MemoryView":527
12908  *             info.shape = NULL
12909  *
12910  *         if flags & PyBUF_STRIDES:             # <<<<<<<<<<<<<<
12911  *             info.strides = self.view.strides
12912  *         else:
12913  */
12914     goto __pyx_L7;
12915   }
12916 
12917   /* "View.MemoryView":530
12918  *             info.strides = self.view.strides
12919  *         else:
12920  *             info.strides = NULL             # <<<<<<<<<<<<<<
12921  *
12922  *         if flags & PyBUF_INDIRECT:
12923  */
12924   /*else*/ {
12925     __pyx_v_info->strides = NULL;
12926   }
12927   __pyx_L7:;
12928 
12929   /* "View.MemoryView":532
12930  *             info.strides = NULL
12931  *
12932  *         if flags & PyBUF_INDIRECT:             # <<<<<<<<<<<<<<
12933  *             info.suboffsets = self.view.suboffsets
12934  *         else:
12935  */
12936   __pyx_t_1 = ((__pyx_v_flags & PyBUF_INDIRECT) != 0);
12937   if (__pyx_t_1) {
12938 
12939     /* "View.MemoryView":533
12940  *
12941  *         if flags & PyBUF_INDIRECT:
12942  *             info.suboffsets = self.view.suboffsets             # <<<<<<<<<<<<<<
12943  *         else:
12944  *             info.suboffsets = NULL
12945  */
12946     __pyx_t_4 = __pyx_v_self->view.suboffsets;
12947     __pyx_v_info->suboffsets = __pyx_t_4;
12948 
12949     /* "View.MemoryView":532
12950  *             info.strides = NULL
12951  *
12952  *         if flags & PyBUF_INDIRECT:             # <<<<<<<<<<<<<<
12953  *             info.suboffsets = self.view.suboffsets
12954  *         else:
12955  */
12956     goto __pyx_L8;
12957   }
12958 
12959   /* "View.MemoryView":535
12960  *             info.suboffsets = self.view.suboffsets
12961  *         else:
12962  *             info.suboffsets = NULL             # <<<<<<<<<<<<<<
12963  *
12964  *         if flags & PyBUF_FORMAT:
12965  */
12966   /*else*/ {
12967     __pyx_v_info->suboffsets = NULL;
12968   }
12969   __pyx_L8:;
12970 
12971   /* "View.MemoryView":537
12972  *             info.suboffsets = NULL
12973  *
12974  *         if flags & PyBUF_FORMAT:             # <<<<<<<<<<<<<<
12975  *             info.format = self.view.format
12976  *         else:
12977  */
12978   __pyx_t_1 = ((__pyx_v_flags & PyBUF_FORMAT) != 0);
12979   if (__pyx_t_1) {
12980 
12981     /* "View.MemoryView":538
12982  *
12983  *         if flags & PyBUF_FORMAT:
12984  *             info.format = self.view.format             # <<<<<<<<<<<<<<
12985  *         else:
12986  *             info.format = NULL
12987  */
12988     __pyx_t_5 = __pyx_v_self->view.format;
12989     __pyx_v_info->format = __pyx_t_5;
12990 
12991     /* "View.MemoryView":537
12992  *             info.suboffsets = NULL
12993  *
12994  *         if flags & PyBUF_FORMAT:             # <<<<<<<<<<<<<<
12995  *             info.format = self.view.format
12996  *         else:
12997  */
12998     goto __pyx_L9;
12999   }
13000 
13001   /* "View.MemoryView":540
13002  *             info.format = self.view.format
13003  *         else:
13004  *             info.format = NULL             # <<<<<<<<<<<<<<
13005  *
13006  *         info.buf = self.view.buf
13007  */
13008   /*else*/ {
13009     __pyx_v_info->format = NULL;
13010   }
13011   __pyx_L9:;
13012 
13013   /* "View.MemoryView":542
13014  *             info.format = NULL
13015  *
13016  *         info.buf = self.view.buf             # <<<<<<<<<<<<<<
13017  *         info.ndim = self.view.ndim
13018  *         info.itemsize = self.view.itemsize
13019  */
13020   __pyx_t_6 = __pyx_v_self->view.buf;
13021   __pyx_v_info->buf = __pyx_t_6;
13022 
13023   /* "View.MemoryView":543
13024  *
13025  *         info.buf = self.view.buf
13026  *         info.ndim = self.view.ndim             # <<<<<<<<<<<<<<
13027  *         info.itemsize = self.view.itemsize
13028  *         info.len = self.view.len
13029  */
13030   __pyx_t_7 = __pyx_v_self->view.ndim;
13031   __pyx_v_info->ndim = __pyx_t_7;
13032 
13033   /* "View.MemoryView":544
13034  *         info.buf = self.view.buf
13035  *         info.ndim = self.view.ndim
13036  *         info.itemsize = self.view.itemsize             # <<<<<<<<<<<<<<
13037  *         info.len = self.view.len
13038  *         info.readonly = self.view.readonly
13039  */
13040   __pyx_t_8 = __pyx_v_self->view.itemsize;
13041   __pyx_v_info->itemsize = __pyx_t_8;
13042 
13043   /* "View.MemoryView":545
13044  *         info.ndim = self.view.ndim
13045  *         info.itemsize = self.view.itemsize
13046  *         info.len = self.view.len             # <<<<<<<<<<<<<<
13047  *         info.readonly = self.view.readonly
13048  *         info.obj = self
13049  */
13050   __pyx_t_8 = __pyx_v_self->view.len;
13051   __pyx_v_info->len = __pyx_t_8;
13052 
13053   /* "View.MemoryView":546
13054  *         info.itemsize = self.view.itemsize
13055  *         info.len = self.view.len
13056  *         info.readonly = self.view.readonly             # <<<<<<<<<<<<<<
13057  *         info.obj = self
13058  *
13059  */
13060   __pyx_t_1 = __pyx_v_self->view.readonly;
13061   __pyx_v_info->readonly = __pyx_t_1;
13062 
13063   /* "View.MemoryView":547
13064  *         info.len = self.view.len
13065  *         info.readonly = self.view.readonly
13066  *         info.obj = self             # <<<<<<<<<<<<<<
13067  *
13068  *     __pyx_getbuffer = capsule(<void *> &__pyx_memoryview_getbuffer, "getbuffer(obj, view, flags)")
13069  */
13070   __Pyx_INCREF(((PyObject *)__pyx_v_self));
13071   __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
13072   __Pyx_GOTREF(__pyx_v_info->obj);
13073   __Pyx_DECREF(__pyx_v_info->obj);
13074   __pyx_v_info->obj = ((PyObject *)__pyx_v_self);
13075 
13076   /* "View.MemoryView":518
13077  *
13078  *     @cname('getbuffer')
13079  *     def __getbuffer__(self, Py_buffer *info, int flags):             # <<<<<<<<<<<<<<
13080  *         if flags & PyBUF_WRITABLE and self.view.readonly:
13081  *             raise ValueError("Cannot create writable memory view from read-only memoryview")
13082  */
13083 
13084   /* function exit code */
13085   __pyx_r = 0;
13086   goto __pyx_L0;
13087   __pyx_L1_error:;
13088   __Pyx_XDECREF(__pyx_t_3);
13089   __Pyx_AddTraceback("View.MemoryView.memoryview.__getbuffer__", __pyx_clineno, __pyx_lineno, __pyx_filename);
13090   __pyx_r = -1;
13091   if (__pyx_v_info->obj != NULL) {
13092     __Pyx_GOTREF(__pyx_v_info->obj);
13093     __Pyx_DECREF(__pyx_v_info->obj); __pyx_v_info->obj = 0;
13094   }
13095   goto __pyx_L2;
13096   __pyx_L0:;
13097   if (__pyx_v_info->obj == Py_None) {
13098     __Pyx_GOTREF(__pyx_v_info->obj);
13099     __Pyx_DECREF(__pyx_v_info->obj); __pyx_v_info->obj = 0;
13100   }
13101   __pyx_L2:;
13102   __Pyx_RefNannyFinishContext();
13103   return __pyx_r;
13104 }
13105 
13106 /* "View.MemoryView":553
13107  *
13108  *     @property
13109  *     def T(self):             # <<<<<<<<<<<<<<
13110  *         cdef _memoryviewslice result = memoryview_copy(self)
13111  *         transpose_memslice(&result.from_slice)
13112  */
13113 
13114 /* Python wrapper */
13115 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)13116 static PyObject *__pyx_pw_15View_dot_MemoryView_10memoryview_1T_1__get__(PyObject *__pyx_v_self) {
13117   PyObject *__pyx_r = 0;
13118   __Pyx_RefNannyDeclarations
13119   __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
13120   __pyx_r = __pyx_pf_15View_dot_MemoryView_10memoryview_1T___get__(((struct __pyx_memoryview_obj *)__pyx_v_self));
13121 
13122   /* function exit code */
13123   __Pyx_RefNannyFinishContext();
13124   return __pyx_r;
13125 }
13126 
__pyx_pf_15View_dot_MemoryView_10memoryview_1T___get__(struct __pyx_memoryview_obj * __pyx_v_self)13127 static PyObject *__pyx_pf_15View_dot_MemoryView_10memoryview_1T___get__(struct __pyx_memoryview_obj *__pyx_v_self) {
13128   struct __pyx_memoryviewslice_obj *__pyx_v_result = 0;
13129   PyObject *__pyx_r = NULL;
13130   __Pyx_RefNannyDeclarations
13131   PyObject *__pyx_t_1 = NULL;
13132   int __pyx_t_2;
13133   int __pyx_lineno = 0;
13134   const char *__pyx_filename = NULL;
13135   int __pyx_clineno = 0;
13136   __Pyx_RefNannySetupContext("__get__", 0);
13137 
13138   /* "View.MemoryView":554
13139  *     @property
13140  *     def T(self):
13141  *         cdef _memoryviewslice result = memoryview_copy(self)             # <<<<<<<<<<<<<<
13142  *         transpose_memslice(&result.from_slice)
13143  *         return result
13144  */
13145   __pyx_t_1 = __pyx_memoryview_copy_object(__pyx_v_self); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 554, __pyx_L1_error)
13146   __Pyx_GOTREF(__pyx_t_1);
13147   if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_memoryviewslice_type))))) __PYX_ERR(2, 554, __pyx_L1_error)
13148   __pyx_v_result = ((struct __pyx_memoryviewslice_obj *)__pyx_t_1);
13149   __pyx_t_1 = 0;
13150 
13151   /* "View.MemoryView":555
13152  *     def T(self):
13153  *         cdef _memoryviewslice result = memoryview_copy(self)
13154  *         transpose_memslice(&result.from_slice)             # <<<<<<<<<<<<<<
13155  *         return result
13156  *
13157  */
13158   __pyx_t_2 = __pyx_memslice_transpose((&__pyx_v_result->from_slice)); if (unlikely(__pyx_t_2 == ((int)0))) __PYX_ERR(2, 555, __pyx_L1_error)
13159 
13160   /* "View.MemoryView":556
13161  *         cdef _memoryviewslice result = memoryview_copy(self)
13162  *         transpose_memslice(&result.from_slice)
13163  *         return result             # <<<<<<<<<<<<<<
13164  *
13165  *     @property
13166  */
13167   __Pyx_XDECREF(__pyx_r);
13168   __Pyx_INCREF(((PyObject *)__pyx_v_result));
13169   __pyx_r = ((PyObject *)__pyx_v_result);
13170   goto __pyx_L0;
13171 
13172   /* "View.MemoryView":553
13173  *
13174  *     @property
13175  *     def T(self):             # <<<<<<<<<<<<<<
13176  *         cdef _memoryviewslice result = memoryview_copy(self)
13177  *         transpose_memslice(&result.from_slice)
13178  */
13179 
13180   /* function exit code */
13181   __pyx_L1_error:;
13182   __Pyx_XDECREF(__pyx_t_1);
13183   __Pyx_AddTraceback("View.MemoryView.memoryview.T.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
13184   __pyx_r = NULL;
13185   __pyx_L0:;
13186   __Pyx_XDECREF((PyObject *)__pyx_v_result);
13187   __Pyx_XGIVEREF(__pyx_r);
13188   __Pyx_RefNannyFinishContext();
13189   return __pyx_r;
13190 }
13191 
13192 /* "View.MemoryView":559
13193  *
13194  *     @property
13195  *     def base(self):             # <<<<<<<<<<<<<<
13196  *         return self.obj
13197  *
13198  */
13199 
13200 /* Python wrapper */
13201 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)13202 static PyObject *__pyx_pw_15View_dot_MemoryView_10memoryview_4base_1__get__(PyObject *__pyx_v_self) {
13203   PyObject *__pyx_r = 0;
13204   __Pyx_RefNannyDeclarations
13205   __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
13206   __pyx_r = __pyx_pf_15View_dot_MemoryView_10memoryview_4base___get__(((struct __pyx_memoryview_obj *)__pyx_v_self));
13207 
13208   /* function exit code */
13209   __Pyx_RefNannyFinishContext();
13210   return __pyx_r;
13211 }
13212 
__pyx_pf_15View_dot_MemoryView_10memoryview_4base___get__(struct __pyx_memoryview_obj * __pyx_v_self)13213 static PyObject *__pyx_pf_15View_dot_MemoryView_10memoryview_4base___get__(struct __pyx_memoryview_obj *__pyx_v_self) {
13214   PyObject *__pyx_r = NULL;
13215   __Pyx_RefNannyDeclarations
13216   __Pyx_RefNannySetupContext("__get__", 0);
13217 
13218   /* "View.MemoryView":560
13219  *     @property
13220  *     def base(self):
13221  *         return self.obj             # <<<<<<<<<<<<<<
13222  *
13223  *     @property
13224  */
13225   __Pyx_XDECREF(__pyx_r);
13226   __Pyx_INCREF(__pyx_v_self->obj);
13227   __pyx_r = __pyx_v_self->obj;
13228   goto __pyx_L0;
13229 
13230   /* "View.MemoryView":559
13231  *
13232  *     @property
13233  *     def base(self):             # <<<<<<<<<<<<<<
13234  *         return self.obj
13235  *
13236  */
13237 
13238   /* function exit code */
13239   __pyx_L0:;
13240   __Pyx_XGIVEREF(__pyx_r);
13241   __Pyx_RefNannyFinishContext();
13242   return __pyx_r;
13243 }
13244 
13245 /* "View.MemoryView":563
13246  *
13247  *     @property
13248  *     def shape(self):             # <<<<<<<<<<<<<<
13249  *         return tuple([length for length in self.view.shape[:self.view.ndim]])
13250  *
13251  */
13252 
13253 /* Python wrapper */
13254 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)13255 static PyObject *__pyx_pw_15View_dot_MemoryView_10memoryview_5shape_1__get__(PyObject *__pyx_v_self) {
13256   PyObject *__pyx_r = 0;
13257   __Pyx_RefNannyDeclarations
13258   __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
13259   __pyx_r = __pyx_pf_15View_dot_MemoryView_10memoryview_5shape___get__(((struct __pyx_memoryview_obj *)__pyx_v_self));
13260 
13261   /* function exit code */
13262   __Pyx_RefNannyFinishContext();
13263   return __pyx_r;
13264 }
13265 
__pyx_pf_15View_dot_MemoryView_10memoryview_5shape___get__(struct __pyx_memoryview_obj * __pyx_v_self)13266 static PyObject *__pyx_pf_15View_dot_MemoryView_10memoryview_5shape___get__(struct __pyx_memoryview_obj *__pyx_v_self) {
13267   Py_ssize_t __pyx_v_length;
13268   PyObject *__pyx_r = NULL;
13269   __Pyx_RefNannyDeclarations
13270   PyObject *__pyx_t_1 = NULL;
13271   Py_ssize_t *__pyx_t_2;
13272   Py_ssize_t *__pyx_t_3;
13273   Py_ssize_t *__pyx_t_4;
13274   PyObject *__pyx_t_5 = NULL;
13275   int __pyx_lineno = 0;
13276   const char *__pyx_filename = NULL;
13277   int __pyx_clineno = 0;
13278   __Pyx_RefNannySetupContext("__get__", 0);
13279 
13280   /* "View.MemoryView":564
13281  *     @property
13282  *     def shape(self):
13283  *         return tuple([length for length in self.view.shape[:self.view.ndim]])             # <<<<<<<<<<<<<<
13284  *
13285  *     @property
13286  */
13287   __Pyx_XDECREF(__pyx_r);
13288   __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 564, __pyx_L1_error)
13289   __Pyx_GOTREF(__pyx_t_1);
13290   __pyx_t_3 = (__pyx_v_self->view.shape + __pyx_v_self->view.ndim);
13291   for (__pyx_t_4 = __pyx_v_self->view.shape; __pyx_t_4 < __pyx_t_3; __pyx_t_4++) {
13292     __pyx_t_2 = __pyx_t_4;
13293     __pyx_v_length = (__pyx_t_2[0]);
13294     __pyx_t_5 = PyInt_FromSsize_t(__pyx_v_length); if (unlikely(!__pyx_t_5)) __PYX_ERR(2, 564, __pyx_L1_error)
13295     __Pyx_GOTREF(__pyx_t_5);
13296     if (unlikely(__Pyx_ListComp_Append(__pyx_t_1, (PyObject*)__pyx_t_5))) __PYX_ERR(2, 564, __pyx_L1_error)
13297     __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
13298   }
13299   __pyx_t_5 = PyList_AsTuple(((PyObject*)__pyx_t_1)); if (unlikely(!__pyx_t_5)) __PYX_ERR(2, 564, __pyx_L1_error)
13300   __Pyx_GOTREF(__pyx_t_5);
13301   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
13302   __pyx_r = __pyx_t_5;
13303   __pyx_t_5 = 0;
13304   goto __pyx_L0;
13305 
13306   /* "View.MemoryView":563
13307  *
13308  *     @property
13309  *     def shape(self):             # <<<<<<<<<<<<<<
13310  *         return tuple([length for length in self.view.shape[:self.view.ndim]])
13311  *
13312  */
13313 
13314   /* function exit code */
13315   __pyx_L1_error:;
13316   __Pyx_XDECREF(__pyx_t_1);
13317   __Pyx_XDECREF(__pyx_t_5);
13318   __Pyx_AddTraceback("View.MemoryView.memoryview.shape.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
13319   __pyx_r = NULL;
13320   __pyx_L0:;
13321   __Pyx_XGIVEREF(__pyx_r);
13322   __Pyx_RefNannyFinishContext();
13323   return __pyx_r;
13324 }
13325 
13326 /* "View.MemoryView":567
13327  *
13328  *     @property
13329  *     def strides(self):             # <<<<<<<<<<<<<<
13330  *         if self.view.strides == NULL:
13331  *
13332  */
13333 
13334 /* Python wrapper */
13335 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)13336 static PyObject *__pyx_pw_15View_dot_MemoryView_10memoryview_7strides_1__get__(PyObject *__pyx_v_self) {
13337   PyObject *__pyx_r = 0;
13338   __Pyx_RefNannyDeclarations
13339   __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
13340   __pyx_r = __pyx_pf_15View_dot_MemoryView_10memoryview_7strides___get__(((struct __pyx_memoryview_obj *)__pyx_v_self));
13341 
13342   /* function exit code */
13343   __Pyx_RefNannyFinishContext();
13344   return __pyx_r;
13345 }
13346 
__pyx_pf_15View_dot_MemoryView_10memoryview_7strides___get__(struct __pyx_memoryview_obj * __pyx_v_self)13347 static PyObject *__pyx_pf_15View_dot_MemoryView_10memoryview_7strides___get__(struct __pyx_memoryview_obj *__pyx_v_self) {
13348   Py_ssize_t __pyx_v_stride;
13349   PyObject *__pyx_r = NULL;
13350   __Pyx_RefNannyDeclarations
13351   int __pyx_t_1;
13352   PyObject *__pyx_t_2 = NULL;
13353   Py_ssize_t *__pyx_t_3;
13354   Py_ssize_t *__pyx_t_4;
13355   Py_ssize_t *__pyx_t_5;
13356   PyObject *__pyx_t_6 = NULL;
13357   int __pyx_lineno = 0;
13358   const char *__pyx_filename = NULL;
13359   int __pyx_clineno = 0;
13360   __Pyx_RefNannySetupContext("__get__", 0);
13361 
13362   /* "View.MemoryView":568
13363  *     @property
13364  *     def strides(self):
13365  *         if self.view.strides == NULL:             # <<<<<<<<<<<<<<
13366  *
13367  *             raise ValueError("Buffer view does not expose strides")
13368  */
13369   __pyx_t_1 = ((__pyx_v_self->view.strides == NULL) != 0);
13370   if (unlikely(__pyx_t_1)) {
13371 
13372     /* "View.MemoryView":570
13373  *         if self.view.strides == NULL:
13374  *
13375  *             raise ValueError("Buffer view does not expose strides")             # <<<<<<<<<<<<<<
13376  *
13377  *         return tuple([stride for stride in self.view.strides[:self.view.ndim]])
13378  */
13379     __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__16, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 570, __pyx_L1_error)
13380     __Pyx_GOTREF(__pyx_t_2);
13381     __Pyx_Raise(__pyx_t_2, 0, 0, 0);
13382     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
13383     __PYX_ERR(2, 570, __pyx_L1_error)
13384 
13385     /* "View.MemoryView":568
13386  *     @property
13387  *     def strides(self):
13388  *         if self.view.strides == NULL:             # <<<<<<<<<<<<<<
13389  *
13390  *             raise ValueError("Buffer view does not expose strides")
13391  */
13392   }
13393 
13394   /* "View.MemoryView":572
13395  *             raise ValueError("Buffer view does not expose strides")
13396  *
13397  *         return tuple([stride for stride in self.view.strides[:self.view.ndim]])             # <<<<<<<<<<<<<<
13398  *
13399  *     @property
13400  */
13401   __Pyx_XDECREF(__pyx_r);
13402   __pyx_t_2 = PyList_New(0); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 572, __pyx_L1_error)
13403   __Pyx_GOTREF(__pyx_t_2);
13404   __pyx_t_4 = (__pyx_v_self->view.strides + __pyx_v_self->view.ndim);
13405   for (__pyx_t_5 = __pyx_v_self->view.strides; __pyx_t_5 < __pyx_t_4; __pyx_t_5++) {
13406     __pyx_t_3 = __pyx_t_5;
13407     __pyx_v_stride = (__pyx_t_3[0]);
13408     __pyx_t_6 = PyInt_FromSsize_t(__pyx_v_stride); if (unlikely(!__pyx_t_6)) __PYX_ERR(2, 572, __pyx_L1_error)
13409     __Pyx_GOTREF(__pyx_t_6);
13410     if (unlikely(__Pyx_ListComp_Append(__pyx_t_2, (PyObject*)__pyx_t_6))) __PYX_ERR(2, 572, __pyx_L1_error)
13411     __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
13412   }
13413   __pyx_t_6 = PyList_AsTuple(((PyObject*)__pyx_t_2)); if (unlikely(!__pyx_t_6)) __PYX_ERR(2, 572, __pyx_L1_error)
13414   __Pyx_GOTREF(__pyx_t_6);
13415   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
13416   __pyx_r = __pyx_t_6;
13417   __pyx_t_6 = 0;
13418   goto __pyx_L0;
13419 
13420   /* "View.MemoryView":567
13421  *
13422  *     @property
13423  *     def strides(self):             # <<<<<<<<<<<<<<
13424  *         if self.view.strides == NULL:
13425  *
13426  */
13427 
13428   /* function exit code */
13429   __pyx_L1_error:;
13430   __Pyx_XDECREF(__pyx_t_2);
13431   __Pyx_XDECREF(__pyx_t_6);
13432   __Pyx_AddTraceback("View.MemoryView.memoryview.strides.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
13433   __pyx_r = NULL;
13434   __pyx_L0:;
13435   __Pyx_XGIVEREF(__pyx_r);
13436   __Pyx_RefNannyFinishContext();
13437   return __pyx_r;
13438 }
13439 
13440 /* "View.MemoryView":575
13441  *
13442  *     @property
13443  *     def suboffsets(self):             # <<<<<<<<<<<<<<
13444  *         if self.view.suboffsets == NULL:
13445  *             return (-1,) * self.view.ndim
13446  */
13447 
13448 /* Python wrapper */
13449 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)13450 static PyObject *__pyx_pw_15View_dot_MemoryView_10memoryview_10suboffsets_1__get__(PyObject *__pyx_v_self) {
13451   PyObject *__pyx_r = 0;
13452   __Pyx_RefNannyDeclarations
13453   __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
13454   __pyx_r = __pyx_pf_15View_dot_MemoryView_10memoryview_10suboffsets___get__(((struct __pyx_memoryview_obj *)__pyx_v_self));
13455 
13456   /* function exit code */
13457   __Pyx_RefNannyFinishContext();
13458   return __pyx_r;
13459 }
13460 
__pyx_pf_15View_dot_MemoryView_10memoryview_10suboffsets___get__(struct __pyx_memoryview_obj * __pyx_v_self)13461 static PyObject *__pyx_pf_15View_dot_MemoryView_10memoryview_10suboffsets___get__(struct __pyx_memoryview_obj *__pyx_v_self) {
13462   Py_ssize_t __pyx_v_suboffset;
13463   PyObject *__pyx_r = NULL;
13464   __Pyx_RefNannyDeclarations
13465   int __pyx_t_1;
13466   PyObject *__pyx_t_2 = NULL;
13467   PyObject *__pyx_t_3 = NULL;
13468   Py_ssize_t *__pyx_t_4;
13469   Py_ssize_t *__pyx_t_5;
13470   Py_ssize_t *__pyx_t_6;
13471   int __pyx_lineno = 0;
13472   const char *__pyx_filename = NULL;
13473   int __pyx_clineno = 0;
13474   __Pyx_RefNannySetupContext("__get__", 0);
13475 
13476   /* "View.MemoryView":576
13477  *     @property
13478  *     def suboffsets(self):
13479  *         if self.view.suboffsets == NULL:             # <<<<<<<<<<<<<<
13480  *             return (-1,) * self.view.ndim
13481  *
13482  */
13483   __pyx_t_1 = ((__pyx_v_self->view.suboffsets == NULL) != 0);
13484   if (__pyx_t_1) {
13485 
13486     /* "View.MemoryView":577
13487  *     def suboffsets(self):
13488  *         if self.view.suboffsets == NULL:
13489  *             return (-1,) * self.view.ndim             # <<<<<<<<<<<<<<
13490  *
13491  *         return tuple([suboffset for suboffset in self.view.suboffsets[:self.view.ndim]])
13492  */
13493     __Pyx_XDECREF(__pyx_r);
13494     __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_self->view.ndim); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 577, __pyx_L1_error)
13495     __Pyx_GOTREF(__pyx_t_2);
13496     __pyx_t_3 = PyNumber_Multiply(__pyx_tuple__17, __pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 577, __pyx_L1_error)
13497     __Pyx_GOTREF(__pyx_t_3);
13498     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
13499     __pyx_r = __pyx_t_3;
13500     __pyx_t_3 = 0;
13501     goto __pyx_L0;
13502 
13503     /* "View.MemoryView":576
13504  *     @property
13505  *     def suboffsets(self):
13506  *         if self.view.suboffsets == NULL:             # <<<<<<<<<<<<<<
13507  *             return (-1,) * self.view.ndim
13508  *
13509  */
13510   }
13511 
13512   /* "View.MemoryView":579
13513  *             return (-1,) * self.view.ndim
13514  *
13515  *         return tuple([suboffset for suboffset in self.view.suboffsets[:self.view.ndim]])             # <<<<<<<<<<<<<<
13516  *
13517  *     @property
13518  */
13519   __Pyx_XDECREF(__pyx_r);
13520   __pyx_t_3 = PyList_New(0); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 579, __pyx_L1_error)
13521   __Pyx_GOTREF(__pyx_t_3);
13522   __pyx_t_5 = (__pyx_v_self->view.suboffsets + __pyx_v_self->view.ndim);
13523   for (__pyx_t_6 = __pyx_v_self->view.suboffsets; __pyx_t_6 < __pyx_t_5; __pyx_t_6++) {
13524     __pyx_t_4 = __pyx_t_6;
13525     __pyx_v_suboffset = (__pyx_t_4[0]);
13526     __pyx_t_2 = PyInt_FromSsize_t(__pyx_v_suboffset); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 579, __pyx_L1_error)
13527     __Pyx_GOTREF(__pyx_t_2);
13528     if (unlikely(__Pyx_ListComp_Append(__pyx_t_3, (PyObject*)__pyx_t_2))) __PYX_ERR(2, 579, __pyx_L1_error)
13529     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
13530   }
13531   __pyx_t_2 = PyList_AsTuple(((PyObject*)__pyx_t_3)); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 579, __pyx_L1_error)
13532   __Pyx_GOTREF(__pyx_t_2);
13533   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
13534   __pyx_r = __pyx_t_2;
13535   __pyx_t_2 = 0;
13536   goto __pyx_L0;
13537 
13538   /* "View.MemoryView":575
13539  *
13540  *     @property
13541  *     def suboffsets(self):             # <<<<<<<<<<<<<<
13542  *         if self.view.suboffsets == NULL:
13543  *             return (-1,) * self.view.ndim
13544  */
13545 
13546   /* function exit code */
13547   __pyx_L1_error:;
13548   __Pyx_XDECREF(__pyx_t_2);
13549   __Pyx_XDECREF(__pyx_t_3);
13550   __Pyx_AddTraceback("View.MemoryView.memoryview.suboffsets.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
13551   __pyx_r = NULL;
13552   __pyx_L0:;
13553   __Pyx_XGIVEREF(__pyx_r);
13554   __Pyx_RefNannyFinishContext();
13555   return __pyx_r;
13556 }
13557 
13558 /* "View.MemoryView":582
13559  *
13560  *     @property
13561  *     def ndim(self):             # <<<<<<<<<<<<<<
13562  *         return self.view.ndim
13563  *
13564  */
13565 
13566 /* Python wrapper */
13567 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)13568 static PyObject *__pyx_pw_15View_dot_MemoryView_10memoryview_4ndim_1__get__(PyObject *__pyx_v_self) {
13569   PyObject *__pyx_r = 0;
13570   __Pyx_RefNannyDeclarations
13571   __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
13572   __pyx_r = __pyx_pf_15View_dot_MemoryView_10memoryview_4ndim___get__(((struct __pyx_memoryview_obj *)__pyx_v_self));
13573 
13574   /* function exit code */
13575   __Pyx_RefNannyFinishContext();
13576   return __pyx_r;
13577 }
13578 
__pyx_pf_15View_dot_MemoryView_10memoryview_4ndim___get__(struct __pyx_memoryview_obj * __pyx_v_self)13579 static PyObject *__pyx_pf_15View_dot_MemoryView_10memoryview_4ndim___get__(struct __pyx_memoryview_obj *__pyx_v_self) {
13580   PyObject *__pyx_r = NULL;
13581   __Pyx_RefNannyDeclarations
13582   PyObject *__pyx_t_1 = NULL;
13583   int __pyx_lineno = 0;
13584   const char *__pyx_filename = NULL;
13585   int __pyx_clineno = 0;
13586   __Pyx_RefNannySetupContext("__get__", 0);
13587 
13588   /* "View.MemoryView":583
13589  *     @property
13590  *     def ndim(self):
13591  *         return self.view.ndim             # <<<<<<<<<<<<<<
13592  *
13593  *     @property
13594  */
13595   __Pyx_XDECREF(__pyx_r);
13596   __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_self->view.ndim); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 583, __pyx_L1_error)
13597   __Pyx_GOTREF(__pyx_t_1);
13598   __pyx_r = __pyx_t_1;
13599   __pyx_t_1 = 0;
13600   goto __pyx_L0;
13601 
13602   /* "View.MemoryView":582
13603  *
13604  *     @property
13605  *     def ndim(self):             # <<<<<<<<<<<<<<
13606  *         return self.view.ndim
13607  *
13608  */
13609 
13610   /* function exit code */
13611   __pyx_L1_error:;
13612   __Pyx_XDECREF(__pyx_t_1);
13613   __Pyx_AddTraceback("View.MemoryView.memoryview.ndim.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
13614   __pyx_r = NULL;
13615   __pyx_L0:;
13616   __Pyx_XGIVEREF(__pyx_r);
13617   __Pyx_RefNannyFinishContext();
13618   return __pyx_r;
13619 }
13620 
13621 /* "View.MemoryView":586
13622  *
13623  *     @property
13624  *     def itemsize(self):             # <<<<<<<<<<<<<<
13625  *         return self.view.itemsize
13626  *
13627  */
13628 
13629 /* Python wrapper */
13630 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)13631 static PyObject *__pyx_pw_15View_dot_MemoryView_10memoryview_8itemsize_1__get__(PyObject *__pyx_v_self) {
13632   PyObject *__pyx_r = 0;
13633   __Pyx_RefNannyDeclarations
13634   __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
13635   __pyx_r = __pyx_pf_15View_dot_MemoryView_10memoryview_8itemsize___get__(((struct __pyx_memoryview_obj *)__pyx_v_self));
13636 
13637   /* function exit code */
13638   __Pyx_RefNannyFinishContext();
13639   return __pyx_r;
13640 }
13641 
__pyx_pf_15View_dot_MemoryView_10memoryview_8itemsize___get__(struct __pyx_memoryview_obj * __pyx_v_self)13642 static PyObject *__pyx_pf_15View_dot_MemoryView_10memoryview_8itemsize___get__(struct __pyx_memoryview_obj *__pyx_v_self) {
13643   PyObject *__pyx_r = NULL;
13644   __Pyx_RefNannyDeclarations
13645   PyObject *__pyx_t_1 = NULL;
13646   int __pyx_lineno = 0;
13647   const char *__pyx_filename = NULL;
13648   int __pyx_clineno = 0;
13649   __Pyx_RefNannySetupContext("__get__", 0);
13650 
13651   /* "View.MemoryView":587
13652  *     @property
13653  *     def itemsize(self):
13654  *         return self.view.itemsize             # <<<<<<<<<<<<<<
13655  *
13656  *     @property
13657  */
13658   __Pyx_XDECREF(__pyx_r);
13659   __pyx_t_1 = PyInt_FromSsize_t(__pyx_v_self->view.itemsize); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 587, __pyx_L1_error)
13660   __Pyx_GOTREF(__pyx_t_1);
13661   __pyx_r = __pyx_t_1;
13662   __pyx_t_1 = 0;
13663   goto __pyx_L0;
13664 
13665   /* "View.MemoryView":586
13666  *
13667  *     @property
13668  *     def itemsize(self):             # <<<<<<<<<<<<<<
13669  *         return self.view.itemsize
13670  *
13671  */
13672 
13673   /* function exit code */
13674   __pyx_L1_error:;
13675   __Pyx_XDECREF(__pyx_t_1);
13676   __Pyx_AddTraceback("View.MemoryView.memoryview.itemsize.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
13677   __pyx_r = NULL;
13678   __pyx_L0:;
13679   __Pyx_XGIVEREF(__pyx_r);
13680   __Pyx_RefNannyFinishContext();
13681   return __pyx_r;
13682 }
13683 
13684 /* "View.MemoryView":590
13685  *
13686  *     @property
13687  *     def nbytes(self):             # <<<<<<<<<<<<<<
13688  *         return self.size * self.view.itemsize
13689  *
13690  */
13691 
13692 /* Python wrapper */
13693 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)13694 static PyObject *__pyx_pw_15View_dot_MemoryView_10memoryview_6nbytes_1__get__(PyObject *__pyx_v_self) {
13695   PyObject *__pyx_r = 0;
13696   __Pyx_RefNannyDeclarations
13697   __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
13698   __pyx_r = __pyx_pf_15View_dot_MemoryView_10memoryview_6nbytes___get__(((struct __pyx_memoryview_obj *)__pyx_v_self));
13699 
13700   /* function exit code */
13701   __Pyx_RefNannyFinishContext();
13702   return __pyx_r;
13703 }
13704 
__pyx_pf_15View_dot_MemoryView_10memoryview_6nbytes___get__(struct __pyx_memoryview_obj * __pyx_v_self)13705 static PyObject *__pyx_pf_15View_dot_MemoryView_10memoryview_6nbytes___get__(struct __pyx_memoryview_obj *__pyx_v_self) {
13706   PyObject *__pyx_r = NULL;
13707   __Pyx_RefNannyDeclarations
13708   PyObject *__pyx_t_1 = NULL;
13709   PyObject *__pyx_t_2 = NULL;
13710   PyObject *__pyx_t_3 = NULL;
13711   int __pyx_lineno = 0;
13712   const char *__pyx_filename = NULL;
13713   int __pyx_clineno = 0;
13714   __Pyx_RefNannySetupContext("__get__", 0);
13715 
13716   /* "View.MemoryView":591
13717  *     @property
13718  *     def nbytes(self):
13719  *         return self.size * self.view.itemsize             # <<<<<<<<<<<<<<
13720  *
13721  *     @property
13722  */
13723   __Pyx_XDECREF(__pyx_r);
13724   __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_size); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 591, __pyx_L1_error)
13725   __Pyx_GOTREF(__pyx_t_1);
13726   __pyx_t_2 = PyInt_FromSsize_t(__pyx_v_self->view.itemsize); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 591, __pyx_L1_error)
13727   __Pyx_GOTREF(__pyx_t_2);
13728   __pyx_t_3 = PyNumber_Multiply(__pyx_t_1, __pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 591, __pyx_L1_error)
13729   __Pyx_GOTREF(__pyx_t_3);
13730   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
13731   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
13732   __pyx_r = __pyx_t_3;
13733   __pyx_t_3 = 0;
13734   goto __pyx_L0;
13735 
13736   /* "View.MemoryView":590
13737  *
13738  *     @property
13739  *     def nbytes(self):             # <<<<<<<<<<<<<<
13740  *         return self.size * self.view.itemsize
13741  *
13742  */
13743 
13744   /* function exit code */
13745   __pyx_L1_error:;
13746   __Pyx_XDECREF(__pyx_t_1);
13747   __Pyx_XDECREF(__pyx_t_2);
13748   __Pyx_XDECREF(__pyx_t_3);
13749   __Pyx_AddTraceback("View.MemoryView.memoryview.nbytes.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
13750   __pyx_r = NULL;
13751   __pyx_L0:;
13752   __Pyx_XGIVEREF(__pyx_r);
13753   __Pyx_RefNannyFinishContext();
13754   return __pyx_r;
13755 }
13756 
13757 /* "View.MemoryView":594
13758  *
13759  *     @property
13760  *     def size(self):             # <<<<<<<<<<<<<<
13761  *         if self._size is None:
13762  *             result = 1
13763  */
13764 
13765 /* Python wrapper */
13766 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)13767 static PyObject *__pyx_pw_15View_dot_MemoryView_10memoryview_4size_1__get__(PyObject *__pyx_v_self) {
13768   PyObject *__pyx_r = 0;
13769   __Pyx_RefNannyDeclarations
13770   __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
13771   __pyx_r = __pyx_pf_15View_dot_MemoryView_10memoryview_4size___get__(((struct __pyx_memoryview_obj *)__pyx_v_self));
13772 
13773   /* function exit code */
13774   __Pyx_RefNannyFinishContext();
13775   return __pyx_r;
13776 }
13777 
__pyx_pf_15View_dot_MemoryView_10memoryview_4size___get__(struct __pyx_memoryview_obj * __pyx_v_self)13778 static PyObject *__pyx_pf_15View_dot_MemoryView_10memoryview_4size___get__(struct __pyx_memoryview_obj *__pyx_v_self) {
13779   PyObject *__pyx_v_result = NULL;
13780   PyObject *__pyx_v_length = NULL;
13781   PyObject *__pyx_r = NULL;
13782   __Pyx_RefNannyDeclarations
13783   int __pyx_t_1;
13784   int __pyx_t_2;
13785   Py_ssize_t *__pyx_t_3;
13786   Py_ssize_t *__pyx_t_4;
13787   Py_ssize_t *__pyx_t_5;
13788   PyObject *__pyx_t_6 = NULL;
13789   int __pyx_lineno = 0;
13790   const char *__pyx_filename = NULL;
13791   int __pyx_clineno = 0;
13792   __Pyx_RefNannySetupContext("__get__", 0);
13793 
13794   /* "View.MemoryView":595
13795  *     @property
13796  *     def size(self):
13797  *         if self._size is None:             # <<<<<<<<<<<<<<
13798  *             result = 1
13799  *
13800  */
13801   __pyx_t_1 = (__pyx_v_self->_size == Py_None);
13802   __pyx_t_2 = (__pyx_t_1 != 0);
13803   if (__pyx_t_2) {
13804 
13805     /* "View.MemoryView":596
13806  *     def size(self):
13807  *         if self._size is None:
13808  *             result = 1             # <<<<<<<<<<<<<<
13809  *
13810  *             for length in self.view.shape[:self.view.ndim]:
13811  */
13812     __Pyx_INCREF(__pyx_int_1);
13813     __pyx_v_result = __pyx_int_1;
13814 
13815     /* "View.MemoryView":598
13816  *             result = 1
13817  *
13818  *             for length in self.view.shape[:self.view.ndim]:             # <<<<<<<<<<<<<<
13819  *                 result *= length
13820  *
13821  */
13822     __pyx_t_4 = (__pyx_v_self->view.shape + __pyx_v_self->view.ndim);
13823     for (__pyx_t_5 = __pyx_v_self->view.shape; __pyx_t_5 < __pyx_t_4; __pyx_t_5++) {
13824       __pyx_t_3 = __pyx_t_5;
13825       __pyx_t_6 = PyInt_FromSsize_t((__pyx_t_3[0])); if (unlikely(!__pyx_t_6)) __PYX_ERR(2, 598, __pyx_L1_error)
13826       __Pyx_GOTREF(__pyx_t_6);
13827       __Pyx_XDECREF_SET(__pyx_v_length, __pyx_t_6);
13828       __pyx_t_6 = 0;
13829 
13830       /* "View.MemoryView":599
13831  *
13832  *             for length in self.view.shape[:self.view.ndim]:
13833  *                 result *= length             # <<<<<<<<<<<<<<
13834  *
13835  *             self._size = result
13836  */
13837       __pyx_t_6 = PyNumber_InPlaceMultiply(__pyx_v_result, __pyx_v_length); if (unlikely(!__pyx_t_6)) __PYX_ERR(2, 599, __pyx_L1_error)
13838       __Pyx_GOTREF(__pyx_t_6);
13839       __Pyx_DECREF_SET(__pyx_v_result, __pyx_t_6);
13840       __pyx_t_6 = 0;
13841     }
13842 
13843     /* "View.MemoryView":601
13844  *                 result *= length
13845  *
13846  *             self._size = result             # <<<<<<<<<<<<<<
13847  *
13848  *         return self._size
13849  */
13850     __Pyx_INCREF(__pyx_v_result);
13851     __Pyx_GIVEREF(__pyx_v_result);
13852     __Pyx_GOTREF(__pyx_v_self->_size);
13853     __Pyx_DECREF(__pyx_v_self->_size);
13854     __pyx_v_self->_size = __pyx_v_result;
13855 
13856     /* "View.MemoryView":595
13857  *     @property
13858  *     def size(self):
13859  *         if self._size is None:             # <<<<<<<<<<<<<<
13860  *             result = 1
13861  *
13862  */
13863   }
13864 
13865   /* "View.MemoryView":603
13866  *             self._size = result
13867  *
13868  *         return self._size             # <<<<<<<<<<<<<<
13869  *
13870  *     def __len__(self):
13871  */
13872   __Pyx_XDECREF(__pyx_r);
13873   __Pyx_INCREF(__pyx_v_self->_size);
13874   __pyx_r = __pyx_v_self->_size;
13875   goto __pyx_L0;
13876 
13877   /* "View.MemoryView":594
13878  *
13879  *     @property
13880  *     def size(self):             # <<<<<<<<<<<<<<
13881  *         if self._size is None:
13882  *             result = 1
13883  */
13884 
13885   /* function exit code */
13886   __pyx_L1_error:;
13887   __Pyx_XDECREF(__pyx_t_6);
13888   __Pyx_AddTraceback("View.MemoryView.memoryview.size.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
13889   __pyx_r = NULL;
13890   __pyx_L0:;
13891   __Pyx_XDECREF(__pyx_v_result);
13892   __Pyx_XDECREF(__pyx_v_length);
13893   __Pyx_XGIVEREF(__pyx_r);
13894   __Pyx_RefNannyFinishContext();
13895   return __pyx_r;
13896 }
13897 
13898 /* "View.MemoryView":605
13899  *         return self._size
13900  *
13901  *     def __len__(self):             # <<<<<<<<<<<<<<
13902  *         if self.view.ndim >= 1:
13903  *             return self.view.shape[0]
13904  */
13905 
13906 /* Python wrapper */
13907 static Py_ssize_t __pyx_memoryview___len__(PyObject *__pyx_v_self); /*proto*/
__pyx_memoryview___len__(PyObject * __pyx_v_self)13908 static Py_ssize_t __pyx_memoryview___len__(PyObject *__pyx_v_self) {
13909   Py_ssize_t __pyx_r;
13910   __Pyx_RefNannyDeclarations
13911   __Pyx_RefNannySetupContext("__len__ (wrapper)", 0);
13912   __pyx_r = __pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_10__len__(((struct __pyx_memoryview_obj *)__pyx_v_self));
13913 
13914   /* function exit code */
13915   __Pyx_RefNannyFinishContext();
13916   return __pyx_r;
13917 }
13918 
__pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_10__len__(struct __pyx_memoryview_obj * __pyx_v_self)13919 static Py_ssize_t __pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_10__len__(struct __pyx_memoryview_obj *__pyx_v_self) {
13920   Py_ssize_t __pyx_r;
13921   __Pyx_RefNannyDeclarations
13922   int __pyx_t_1;
13923   __Pyx_RefNannySetupContext("__len__", 0);
13924 
13925   /* "View.MemoryView":606
13926  *
13927  *     def __len__(self):
13928  *         if self.view.ndim >= 1:             # <<<<<<<<<<<<<<
13929  *             return self.view.shape[0]
13930  *
13931  */
13932   __pyx_t_1 = ((__pyx_v_self->view.ndim >= 1) != 0);
13933   if (__pyx_t_1) {
13934 
13935     /* "View.MemoryView":607
13936  *     def __len__(self):
13937  *         if self.view.ndim >= 1:
13938  *             return self.view.shape[0]             # <<<<<<<<<<<<<<
13939  *
13940  *         return 0
13941  */
13942     __pyx_r = (__pyx_v_self->view.shape[0]);
13943     goto __pyx_L0;
13944 
13945     /* "View.MemoryView":606
13946  *
13947  *     def __len__(self):
13948  *         if self.view.ndim >= 1:             # <<<<<<<<<<<<<<
13949  *             return self.view.shape[0]
13950  *
13951  */
13952   }
13953 
13954   /* "View.MemoryView":609
13955  *             return self.view.shape[0]
13956  *
13957  *         return 0             # <<<<<<<<<<<<<<
13958  *
13959  *     def __repr__(self):
13960  */
13961   __pyx_r = 0;
13962   goto __pyx_L0;
13963 
13964   /* "View.MemoryView":605
13965  *         return self._size
13966  *
13967  *     def __len__(self):             # <<<<<<<<<<<<<<
13968  *         if self.view.ndim >= 1:
13969  *             return self.view.shape[0]
13970  */
13971 
13972   /* function exit code */
13973   __pyx_L0:;
13974   __Pyx_RefNannyFinishContext();
13975   return __pyx_r;
13976 }
13977 
13978 /* "View.MemoryView":611
13979  *         return 0
13980  *
13981  *     def __repr__(self):             # <<<<<<<<<<<<<<
13982  *         return "<MemoryView of %r at 0x%x>" % (self.base.__class__.__name__,
13983  *                                                id(self))
13984  */
13985 
13986 /* Python wrapper */
13987 static PyObject *__pyx_memoryview___repr__(PyObject *__pyx_v_self); /*proto*/
__pyx_memoryview___repr__(PyObject * __pyx_v_self)13988 static PyObject *__pyx_memoryview___repr__(PyObject *__pyx_v_self) {
13989   PyObject *__pyx_r = 0;
13990   __Pyx_RefNannyDeclarations
13991   __Pyx_RefNannySetupContext("__repr__ (wrapper)", 0);
13992   __pyx_r = __pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_12__repr__(((struct __pyx_memoryview_obj *)__pyx_v_self));
13993 
13994   /* function exit code */
13995   __Pyx_RefNannyFinishContext();
13996   return __pyx_r;
13997 }
13998 
__pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_12__repr__(struct __pyx_memoryview_obj * __pyx_v_self)13999 static PyObject *__pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_12__repr__(struct __pyx_memoryview_obj *__pyx_v_self) {
14000   PyObject *__pyx_r = NULL;
14001   __Pyx_RefNannyDeclarations
14002   PyObject *__pyx_t_1 = NULL;
14003   PyObject *__pyx_t_2 = NULL;
14004   PyObject *__pyx_t_3 = NULL;
14005   int __pyx_lineno = 0;
14006   const char *__pyx_filename = NULL;
14007   int __pyx_clineno = 0;
14008   __Pyx_RefNannySetupContext("__repr__", 0);
14009 
14010   /* "View.MemoryView":612
14011  *
14012  *     def __repr__(self):
14013  *         return "<MemoryView of %r at 0x%x>" % (self.base.__class__.__name__,             # <<<<<<<<<<<<<<
14014  *                                                id(self))
14015  *
14016  */
14017   __Pyx_XDECREF(__pyx_r);
14018   __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_base); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 612, __pyx_L1_error)
14019   __Pyx_GOTREF(__pyx_t_1);
14020   __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_class); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 612, __pyx_L1_error)
14021   __Pyx_GOTREF(__pyx_t_2);
14022   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
14023   __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_name_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 612, __pyx_L1_error)
14024   __Pyx_GOTREF(__pyx_t_1);
14025   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
14026 
14027   /* "View.MemoryView":613
14028  *     def __repr__(self):
14029  *         return "<MemoryView of %r at 0x%x>" % (self.base.__class__.__name__,
14030  *                                                id(self))             # <<<<<<<<<<<<<<
14031  *
14032  *     def __str__(self):
14033  */
14034   __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_builtin_id, ((PyObject *)__pyx_v_self)); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 613, __pyx_L1_error)
14035   __Pyx_GOTREF(__pyx_t_2);
14036 
14037   /* "View.MemoryView":612
14038  *
14039  *     def __repr__(self):
14040  *         return "<MemoryView of %r at 0x%x>" % (self.base.__class__.__name__,             # <<<<<<<<<<<<<<
14041  *                                                id(self))
14042  *
14043  */
14044   __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 612, __pyx_L1_error)
14045   __Pyx_GOTREF(__pyx_t_3);
14046   __Pyx_GIVEREF(__pyx_t_1);
14047   PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_1);
14048   __Pyx_GIVEREF(__pyx_t_2);
14049   PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_2);
14050   __pyx_t_1 = 0;
14051   __pyx_t_2 = 0;
14052   __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(2, 612, __pyx_L1_error)
14053   __Pyx_GOTREF(__pyx_t_2);
14054   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
14055   __pyx_r = __pyx_t_2;
14056   __pyx_t_2 = 0;
14057   goto __pyx_L0;
14058 
14059   /* "View.MemoryView":611
14060  *         return 0
14061  *
14062  *     def __repr__(self):             # <<<<<<<<<<<<<<
14063  *         return "<MemoryView of %r at 0x%x>" % (self.base.__class__.__name__,
14064  *                                                id(self))
14065  */
14066 
14067   /* function exit code */
14068   __pyx_L1_error:;
14069   __Pyx_XDECREF(__pyx_t_1);
14070   __Pyx_XDECREF(__pyx_t_2);
14071   __Pyx_XDECREF(__pyx_t_3);
14072   __Pyx_AddTraceback("View.MemoryView.memoryview.__repr__", __pyx_clineno, __pyx_lineno, __pyx_filename);
14073   __pyx_r = NULL;
14074   __pyx_L0:;
14075   __Pyx_XGIVEREF(__pyx_r);
14076   __Pyx_RefNannyFinishContext();
14077   return __pyx_r;
14078 }
14079 
14080 /* "View.MemoryView":615
14081  *                                                id(self))
14082  *
14083  *     def __str__(self):             # <<<<<<<<<<<<<<
14084  *         return "<MemoryView of %r object>" % (self.base.__class__.__name__,)
14085  *
14086  */
14087 
14088 /* Python wrapper */
14089 static PyObject *__pyx_memoryview___str__(PyObject *__pyx_v_self); /*proto*/
__pyx_memoryview___str__(PyObject * __pyx_v_self)14090 static PyObject *__pyx_memoryview___str__(PyObject *__pyx_v_self) {
14091   PyObject *__pyx_r = 0;
14092   __Pyx_RefNannyDeclarations
14093   __Pyx_RefNannySetupContext("__str__ (wrapper)", 0);
14094   __pyx_r = __pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_14__str__(((struct __pyx_memoryview_obj *)__pyx_v_self));
14095 
14096   /* function exit code */
14097   __Pyx_RefNannyFinishContext();
14098   return __pyx_r;
14099 }
14100 
__pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_14__str__(struct __pyx_memoryview_obj * __pyx_v_self)14101 static PyObject *__pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_14__str__(struct __pyx_memoryview_obj *__pyx_v_self) {
14102   PyObject *__pyx_r = NULL;
14103   __Pyx_RefNannyDeclarations
14104   PyObject *__pyx_t_1 = NULL;
14105   PyObject *__pyx_t_2 = NULL;
14106   int __pyx_lineno = 0;
14107   const char *__pyx_filename = NULL;
14108   int __pyx_clineno = 0;
14109   __Pyx_RefNannySetupContext("__str__", 0);
14110 
14111   /* "View.MemoryView":616
14112  *
14113  *     def __str__(self):
14114  *         return "<MemoryView of %r object>" % (self.base.__class__.__name__,)             # <<<<<<<<<<<<<<
14115  *
14116  *
14117  */
14118   __Pyx_XDECREF(__pyx_r);
14119   __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_base); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 616, __pyx_L1_error)
14120   __Pyx_GOTREF(__pyx_t_1);
14121   __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_class); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 616, __pyx_L1_error)
14122   __Pyx_GOTREF(__pyx_t_2);
14123   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
14124   __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_name_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 616, __pyx_L1_error)
14125   __Pyx_GOTREF(__pyx_t_1);
14126   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
14127   __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 616, __pyx_L1_error)
14128   __Pyx_GOTREF(__pyx_t_2);
14129   __Pyx_GIVEREF(__pyx_t_1);
14130   PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_1);
14131   __pyx_t_1 = 0;
14132   __pyx_t_1 = __Pyx_PyString_Format(__pyx_kp_s_MemoryView_of_r_object, __pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 616, __pyx_L1_error)
14133   __Pyx_GOTREF(__pyx_t_1);
14134   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
14135   __pyx_r = __pyx_t_1;
14136   __pyx_t_1 = 0;
14137   goto __pyx_L0;
14138 
14139   /* "View.MemoryView":615
14140  *                                                id(self))
14141  *
14142  *     def __str__(self):             # <<<<<<<<<<<<<<
14143  *         return "<MemoryView of %r object>" % (self.base.__class__.__name__,)
14144  *
14145  */
14146 
14147   /* function exit code */
14148   __pyx_L1_error:;
14149   __Pyx_XDECREF(__pyx_t_1);
14150   __Pyx_XDECREF(__pyx_t_2);
14151   __Pyx_AddTraceback("View.MemoryView.memoryview.__str__", __pyx_clineno, __pyx_lineno, __pyx_filename);
14152   __pyx_r = NULL;
14153   __pyx_L0:;
14154   __Pyx_XGIVEREF(__pyx_r);
14155   __Pyx_RefNannyFinishContext();
14156   return __pyx_r;
14157 }
14158 
14159 /* "View.MemoryView":619
14160  *
14161  *
14162  *     def is_c_contig(self):             # <<<<<<<<<<<<<<
14163  *         cdef __Pyx_memviewslice *mslice
14164  *         cdef __Pyx_memviewslice tmp
14165  */
14166 
14167 /* Python wrapper */
14168 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)14169 static PyObject *__pyx_memoryview_is_c_contig(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
14170   PyObject *__pyx_r = 0;
14171   __Pyx_RefNannyDeclarations
14172   __Pyx_RefNannySetupContext("is_c_contig (wrapper)", 0);
14173   __pyx_r = __pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_16is_c_contig(((struct __pyx_memoryview_obj *)__pyx_v_self));
14174 
14175   /* function exit code */
14176   __Pyx_RefNannyFinishContext();
14177   return __pyx_r;
14178 }
14179 
__pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_16is_c_contig(struct __pyx_memoryview_obj * __pyx_v_self)14180 static PyObject *__pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_16is_c_contig(struct __pyx_memoryview_obj *__pyx_v_self) {
14181   __Pyx_memviewslice *__pyx_v_mslice;
14182   __Pyx_memviewslice __pyx_v_tmp;
14183   PyObject *__pyx_r = NULL;
14184   __Pyx_RefNannyDeclarations
14185   __Pyx_memviewslice *__pyx_t_1;
14186   PyObject *__pyx_t_2 = NULL;
14187   int __pyx_lineno = 0;
14188   const char *__pyx_filename = NULL;
14189   int __pyx_clineno = 0;
14190   __Pyx_RefNannySetupContext("is_c_contig", 0);
14191 
14192   /* "View.MemoryView":622
14193  *         cdef __Pyx_memviewslice *mslice
14194  *         cdef __Pyx_memviewslice tmp
14195  *         mslice = get_slice_from_memview(self, &tmp)             # <<<<<<<<<<<<<<
14196  *         return slice_is_contig(mslice[0], 'C', self.view.ndim)
14197  *
14198  */
14199   __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(2, 622, __pyx_L1_error)
14200   __pyx_v_mslice = __pyx_t_1;
14201 
14202   /* "View.MemoryView":623
14203  *         cdef __Pyx_memviewslice tmp
14204  *         mslice = get_slice_from_memview(self, &tmp)
14205  *         return slice_is_contig(mslice[0], 'C', self.view.ndim)             # <<<<<<<<<<<<<<
14206  *
14207  *     def is_f_contig(self):
14208  */
14209   __Pyx_XDECREF(__pyx_r);
14210   __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(2, 623, __pyx_L1_error)
14211   __Pyx_GOTREF(__pyx_t_2);
14212   __pyx_r = __pyx_t_2;
14213   __pyx_t_2 = 0;
14214   goto __pyx_L0;
14215 
14216   /* "View.MemoryView":619
14217  *
14218  *
14219  *     def is_c_contig(self):             # <<<<<<<<<<<<<<
14220  *         cdef __Pyx_memviewslice *mslice
14221  *         cdef __Pyx_memviewslice tmp
14222  */
14223 
14224   /* function exit code */
14225   __pyx_L1_error:;
14226   __Pyx_XDECREF(__pyx_t_2);
14227   __Pyx_AddTraceback("View.MemoryView.memoryview.is_c_contig", __pyx_clineno, __pyx_lineno, __pyx_filename);
14228   __pyx_r = NULL;
14229   __pyx_L0:;
14230   __Pyx_XGIVEREF(__pyx_r);
14231   __Pyx_RefNannyFinishContext();
14232   return __pyx_r;
14233 }
14234 
14235 /* "View.MemoryView":625
14236  *         return slice_is_contig(mslice[0], 'C', self.view.ndim)
14237  *
14238  *     def is_f_contig(self):             # <<<<<<<<<<<<<<
14239  *         cdef __Pyx_memviewslice *mslice
14240  *         cdef __Pyx_memviewslice tmp
14241  */
14242 
14243 /* Python wrapper */
14244 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)14245 static PyObject *__pyx_memoryview_is_f_contig(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
14246   PyObject *__pyx_r = 0;
14247   __Pyx_RefNannyDeclarations
14248   __Pyx_RefNannySetupContext("is_f_contig (wrapper)", 0);
14249   __pyx_r = __pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_18is_f_contig(((struct __pyx_memoryview_obj *)__pyx_v_self));
14250 
14251   /* function exit code */
14252   __Pyx_RefNannyFinishContext();
14253   return __pyx_r;
14254 }
14255 
__pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_18is_f_contig(struct __pyx_memoryview_obj * __pyx_v_self)14256 static PyObject *__pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_18is_f_contig(struct __pyx_memoryview_obj *__pyx_v_self) {
14257   __Pyx_memviewslice *__pyx_v_mslice;
14258   __Pyx_memviewslice __pyx_v_tmp;
14259   PyObject *__pyx_r = NULL;
14260   __Pyx_RefNannyDeclarations
14261   __Pyx_memviewslice *__pyx_t_1;
14262   PyObject *__pyx_t_2 = NULL;
14263   int __pyx_lineno = 0;
14264   const char *__pyx_filename = NULL;
14265   int __pyx_clineno = 0;
14266   __Pyx_RefNannySetupContext("is_f_contig", 0);
14267 
14268   /* "View.MemoryView":628
14269  *         cdef __Pyx_memviewslice *mslice
14270  *         cdef __Pyx_memviewslice tmp
14271  *         mslice = get_slice_from_memview(self, &tmp)             # <<<<<<<<<<<<<<
14272  *         return slice_is_contig(mslice[0], 'F', self.view.ndim)
14273  *
14274  */
14275   __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(2, 628, __pyx_L1_error)
14276   __pyx_v_mslice = __pyx_t_1;
14277 
14278   /* "View.MemoryView":629
14279  *         cdef __Pyx_memviewslice tmp
14280  *         mslice = get_slice_from_memview(self, &tmp)
14281  *         return slice_is_contig(mslice[0], 'F', self.view.ndim)             # <<<<<<<<<<<<<<
14282  *
14283  *     def copy(self):
14284  */
14285   __Pyx_XDECREF(__pyx_r);
14286   __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(2, 629, __pyx_L1_error)
14287   __Pyx_GOTREF(__pyx_t_2);
14288   __pyx_r = __pyx_t_2;
14289   __pyx_t_2 = 0;
14290   goto __pyx_L0;
14291 
14292   /* "View.MemoryView":625
14293  *         return slice_is_contig(mslice[0], 'C', self.view.ndim)
14294  *
14295  *     def is_f_contig(self):             # <<<<<<<<<<<<<<
14296  *         cdef __Pyx_memviewslice *mslice
14297  *         cdef __Pyx_memviewslice tmp
14298  */
14299 
14300   /* function exit code */
14301   __pyx_L1_error:;
14302   __Pyx_XDECREF(__pyx_t_2);
14303   __Pyx_AddTraceback("View.MemoryView.memoryview.is_f_contig", __pyx_clineno, __pyx_lineno, __pyx_filename);
14304   __pyx_r = NULL;
14305   __pyx_L0:;
14306   __Pyx_XGIVEREF(__pyx_r);
14307   __Pyx_RefNannyFinishContext();
14308   return __pyx_r;
14309 }
14310 
14311 /* "View.MemoryView":631
14312  *         return slice_is_contig(mslice[0], 'F', self.view.ndim)
14313  *
14314  *     def copy(self):             # <<<<<<<<<<<<<<
14315  *         cdef __Pyx_memviewslice mslice
14316  *         cdef int flags = self.flags & ~PyBUF_F_CONTIGUOUS
14317  */
14318 
14319 /* Python wrapper */
14320 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)14321 static PyObject *__pyx_memoryview_copy(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
14322   PyObject *__pyx_r = 0;
14323   __Pyx_RefNannyDeclarations
14324   __Pyx_RefNannySetupContext("copy (wrapper)", 0);
14325   __pyx_r = __pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_20copy(((struct __pyx_memoryview_obj *)__pyx_v_self));
14326 
14327   /* function exit code */
14328   __Pyx_RefNannyFinishContext();
14329   return __pyx_r;
14330 }
14331 
__pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_20copy(struct __pyx_memoryview_obj * __pyx_v_self)14332 static PyObject *__pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_20copy(struct __pyx_memoryview_obj *__pyx_v_self) {
14333   __Pyx_memviewslice __pyx_v_mslice;
14334   int __pyx_v_flags;
14335   PyObject *__pyx_r = NULL;
14336   __Pyx_RefNannyDeclarations
14337   __Pyx_memviewslice __pyx_t_1;
14338   PyObject *__pyx_t_2 = NULL;
14339   int __pyx_lineno = 0;
14340   const char *__pyx_filename = NULL;
14341   int __pyx_clineno = 0;
14342   __Pyx_RefNannySetupContext("copy", 0);
14343 
14344   /* "View.MemoryView":633
14345  *     def copy(self):
14346  *         cdef __Pyx_memviewslice mslice
14347  *         cdef int flags = self.flags & ~PyBUF_F_CONTIGUOUS             # <<<<<<<<<<<<<<
14348  *
14349  *         slice_copy(self, &mslice)
14350  */
14351   __pyx_v_flags = (__pyx_v_self->flags & (~PyBUF_F_CONTIGUOUS));
14352 
14353   /* "View.MemoryView":635
14354  *         cdef int flags = self.flags & ~PyBUF_F_CONTIGUOUS
14355  *
14356  *         slice_copy(self, &mslice)             # <<<<<<<<<<<<<<
14357  *         mslice = slice_copy_contig(&mslice, "c", self.view.ndim,
14358  *                                    self.view.itemsize,
14359  */
14360   __pyx_memoryview_slice_copy(__pyx_v_self, (&__pyx_v_mslice));
14361 
14362   /* "View.MemoryView":636
14363  *
14364  *         slice_copy(self, &mslice)
14365  *         mslice = slice_copy_contig(&mslice, "c", self.view.ndim,             # <<<<<<<<<<<<<<
14366  *                                    self.view.itemsize,
14367  *                                    flags|PyBUF_C_CONTIGUOUS,
14368  */
14369   __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(2, 636, __pyx_L1_error)
14370   __pyx_v_mslice = __pyx_t_1;
14371 
14372   /* "View.MemoryView":641
14373  *                                    self.dtype_is_object)
14374  *
14375  *         return memoryview_copy_from_slice(self, &mslice)             # <<<<<<<<<<<<<<
14376  *
14377  *     def copy_fortran(self):
14378  */
14379   __Pyx_XDECREF(__pyx_r);
14380   __pyx_t_2 = __pyx_memoryview_copy_object_from_slice(__pyx_v_self, (&__pyx_v_mslice)); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 641, __pyx_L1_error)
14381   __Pyx_GOTREF(__pyx_t_2);
14382   __pyx_r = __pyx_t_2;
14383   __pyx_t_2 = 0;
14384   goto __pyx_L0;
14385 
14386   /* "View.MemoryView":631
14387  *         return slice_is_contig(mslice[0], 'F', self.view.ndim)
14388  *
14389  *     def copy(self):             # <<<<<<<<<<<<<<
14390  *         cdef __Pyx_memviewslice mslice
14391  *         cdef int flags = self.flags & ~PyBUF_F_CONTIGUOUS
14392  */
14393 
14394   /* function exit code */
14395   __pyx_L1_error:;
14396   __Pyx_XDECREF(__pyx_t_2);
14397   __Pyx_AddTraceback("View.MemoryView.memoryview.copy", __pyx_clineno, __pyx_lineno, __pyx_filename);
14398   __pyx_r = NULL;
14399   __pyx_L0:;
14400   __Pyx_XGIVEREF(__pyx_r);
14401   __Pyx_RefNannyFinishContext();
14402   return __pyx_r;
14403 }
14404 
14405 /* "View.MemoryView":643
14406  *         return memoryview_copy_from_slice(self, &mslice)
14407  *
14408  *     def copy_fortran(self):             # <<<<<<<<<<<<<<
14409  *         cdef __Pyx_memviewslice src, dst
14410  *         cdef int flags = self.flags & ~PyBUF_C_CONTIGUOUS
14411  */
14412 
14413 /* Python wrapper */
14414 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)14415 static PyObject *__pyx_memoryview_copy_fortran(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
14416   PyObject *__pyx_r = 0;
14417   __Pyx_RefNannyDeclarations
14418   __Pyx_RefNannySetupContext("copy_fortran (wrapper)", 0);
14419   __pyx_r = __pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_22copy_fortran(((struct __pyx_memoryview_obj *)__pyx_v_self));
14420 
14421   /* function exit code */
14422   __Pyx_RefNannyFinishContext();
14423   return __pyx_r;
14424 }
14425 
__pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_22copy_fortran(struct __pyx_memoryview_obj * __pyx_v_self)14426 static PyObject *__pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_22copy_fortran(struct __pyx_memoryview_obj *__pyx_v_self) {
14427   __Pyx_memviewslice __pyx_v_src;
14428   __Pyx_memviewslice __pyx_v_dst;
14429   int __pyx_v_flags;
14430   PyObject *__pyx_r = NULL;
14431   __Pyx_RefNannyDeclarations
14432   __Pyx_memviewslice __pyx_t_1;
14433   PyObject *__pyx_t_2 = NULL;
14434   int __pyx_lineno = 0;
14435   const char *__pyx_filename = NULL;
14436   int __pyx_clineno = 0;
14437   __Pyx_RefNannySetupContext("copy_fortran", 0);
14438 
14439   /* "View.MemoryView":645
14440  *     def copy_fortran(self):
14441  *         cdef __Pyx_memviewslice src, dst
14442  *         cdef int flags = self.flags & ~PyBUF_C_CONTIGUOUS             # <<<<<<<<<<<<<<
14443  *
14444  *         slice_copy(self, &src)
14445  */
14446   __pyx_v_flags = (__pyx_v_self->flags & (~PyBUF_C_CONTIGUOUS));
14447 
14448   /* "View.MemoryView":647
14449  *         cdef int flags = self.flags & ~PyBUF_C_CONTIGUOUS
14450  *
14451  *         slice_copy(self, &src)             # <<<<<<<<<<<<<<
14452  *         dst = slice_copy_contig(&src, "fortran", self.view.ndim,
14453  *                                 self.view.itemsize,
14454  */
14455   __pyx_memoryview_slice_copy(__pyx_v_self, (&__pyx_v_src));
14456 
14457   /* "View.MemoryView":648
14458  *
14459  *         slice_copy(self, &src)
14460  *         dst = slice_copy_contig(&src, "fortran", self.view.ndim,             # <<<<<<<<<<<<<<
14461  *                                 self.view.itemsize,
14462  *                                 flags|PyBUF_F_CONTIGUOUS,
14463  */
14464   __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(2, 648, __pyx_L1_error)
14465   __pyx_v_dst = __pyx_t_1;
14466 
14467   /* "View.MemoryView":653
14468  *                                 self.dtype_is_object)
14469  *
14470  *         return memoryview_copy_from_slice(self, &dst)             # <<<<<<<<<<<<<<
14471  *
14472  *
14473  */
14474   __Pyx_XDECREF(__pyx_r);
14475   __pyx_t_2 = __pyx_memoryview_copy_object_from_slice(__pyx_v_self, (&__pyx_v_dst)); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 653, __pyx_L1_error)
14476   __Pyx_GOTREF(__pyx_t_2);
14477   __pyx_r = __pyx_t_2;
14478   __pyx_t_2 = 0;
14479   goto __pyx_L0;
14480 
14481   /* "View.MemoryView":643
14482  *         return memoryview_copy_from_slice(self, &mslice)
14483  *
14484  *     def copy_fortran(self):             # <<<<<<<<<<<<<<
14485  *         cdef __Pyx_memviewslice src, dst
14486  *         cdef int flags = self.flags & ~PyBUF_C_CONTIGUOUS
14487  */
14488 
14489   /* function exit code */
14490   __pyx_L1_error:;
14491   __Pyx_XDECREF(__pyx_t_2);
14492   __Pyx_AddTraceback("View.MemoryView.memoryview.copy_fortran", __pyx_clineno, __pyx_lineno, __pyx_filename);
14493   __pyx_r = NULL;
14494   __pyx_L0:;
14495   __Pyx_XGIVEREF(__pyx_r);
14496   __Pyx_RefNannyFinishContext();
14497   return __pyx_r;
14498 }
14499 
14500 /* "(tree fragment)":1
14501  * def __reduce_cython__(self):             # <<<<<<<<<<<<<<
14502  *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
14503  * def __setstate_cython__(self, __pyx_state):
14504  */
14505 
14506 /* Python wrapper */
14507 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)14508 static PyObject *__pyx_pw___pyx_memoryview_1__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
14509   PyObject *__pyx_r = 0;
14510   __Pyx_RefNannyDeclarations
14511   __Pyx_RefNannySetupContext("__reduce_cython__ (wrapper)", 0);
14512   __pyx_r = __pyx_pf___pyx_memoryview___reduce_cython__(((struct __pyx_memoryview_obj *)__pyx_v_self));
14513 
14514   /* function exit code */
14515   __Pyx_RefNannyFinishContext();
14516   return __pyx_r;
14517 }
14518 
__pyx_pf___pyx_memoryview___reduce_cython__(CYTHON_UNUSED struct __pyx_memoryview_obj * __pyx_v_self)14519 static PyObject *__pyx_pf___pyx_memoryview___reduce_cython__(CYTHON_UNUSED struct __pyx_memoryview_obj *__pyx_v_self) {
14520   PyObject *__pyx_r = NULL;
14521   __Pyx_RefNannyDeclarations
14522   PyObject *__pyx_t_1 = NULL;
14523   int __pyx_lineno = 0;
14524   const char *__pyx_filename = NULL;
14525   int __pyx_clineno = 0;
14526   __Pyx_RefNannySetupContext("__reduce_cython__", 0);
14527 
14528   /* "(tree fragment)":2
14529  * def __reduce_cython__(self):
14530  *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")             # <<<<<<<<<<<<<<
14531  * def __setstate_cython__(self, __pyx_state):
14532  *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
14533  */
14534   __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__18, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 2, __pyx_L1_error)
14535   __Pyx_GOTREF(__pyx_t_1);
14536   __Pyx_Raise(__pyx_t_1, 0, 0, 0);
14537   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
14538   __PYX_ERR(2, 2, __pyx_L1_error)
14539 
14540   /* "(tree fragment)":1
14541  * def __reduce_cython__(self):             # <<<<<<<<<<<<<<
14542  *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
14543  * def __setstate_cython__(self, __pyx_state):
14544  */
14545 
14546   /* function exit code */
14547   __pyx_L1_error:;
14548   __Pyx_XDECREF(__pyx_t_1);
14549   __Pyx_AddTraceback("View.MemoryView.memoryview.__reduce_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename);
14550   __pyx_r = NULL;
14551   __Pyx_XGIVEREF(__pyx_r);
14552   __Pyx_RefNannyFinishContext();
14553   return __pyx_r;
14554 }
14555 
14556 /* "(tree fragment)":3
14557  * def __reduce_cython__(self):
14558  *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
14559  * def __setstate_cython__(self, __pyx_state):             # <<<<<<<<<<<<<<
14560  *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
14561  */
14562 
14563 /* Python wrapper */
14564 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)14565 static PyObject *__pyx_pw___pyx_memoryview_3__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state) {
14566   PyObject *__pyx_r = 0;
14567   __Pyx_RefNannyDeclarations
14568   __Pyx_RefNannySetupContext("__setstate_cython__ (wrapper)", 0);
14569   __pyx_r = __pyx_pf___pyx_memoryview_2__setstate_cython__(((struct __pyx_memoryview_obj *)__pyx_v_self), ((PyObject *)__pyx_v___pyx_state));
14570 
14571   /* function exit code */
14572   __Pyx_RefNannyFinishContext();
14573   return __pyx_r;
14574 }
14575 
__pyx_pf___pyx_memoryview_2__setstate_cython__(CYTHON_UNUSED struct __pyx_memoryview_obj * __pyx_v_self,CYTHON_UNUSED PyObject * __pyx_v___pyx_state)14576 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) {
14577   PyObject *__pyx_r = NULL;
14578   __Pyx_RefNannyDeclarations
14579   PyObject *__pyx_t_1 = NULL;
14580   int __pyx_lineno = 0;
14581   const char *__pyx_filename = NULL;
14582   int __pyx_clineno = 0;
14583   __Pyx_RefNannySetupContext("__setstate_cython__", 0);
14584 
14585   /* "(tree fragment)":4
14586  *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
14587  * def __setstate_cython__(self, __pyx_state):
14588  *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")             # <<<<<<<<<<<<<<
14589  */
14590   __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__19, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 4, __pyx_L1_error)
14591   __Pyx_GOTREF(__pyx_t_1);
14592   __Pyx_Raise(__pyx_t_1, 0, 0, 0);
14593   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
14594   __PYX_ERR(2, 4, __pyx_L1_error)
14595 
14596   /* "(tree fragment)":3
14597  * def __reduce_cython__(self):
14598  *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
14599  * def __setstate_cython__(self, __pyx_state):             # <<<<<<<<<<<<<<
14600  *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
14601  */
14602 
14603   /* function exit code */
14604   __pyx_L1_error:;
14605   __Pyx_XDECREF(__pyx_t_1);
14606   __Pyx_AddTraceback("View.MemoryView.memoryview.__setstate_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename);
14607   __pyx_r = NULL;
14608   __Pyx_XGIVEREF(__pyx_r);
14609   __Pyx_RefNannyFinishContext();
14610   return __pyx_r;
14611 }
14612 
14613 /* "View.MemoryView":657
14614  *
14615  * @cname('__pyx_memoryview_new')
14616  * cdef memoryview_cwrapper(object o, int flags, bint dtype_is_object, __Pyx_TypeInfo *typeinfo):             # <<<<<<<<<<<<<<
14617  *     cdef memoryview result = memoryview(o, flags, dtype_is_object)
14618  *     result.typeinfo = typeinfo
14619  */
14620 
__pyx_memoryview_new(PyObject * __pyx_v_o,int __pyx_v_flags,int __pyx_v_dtype_is_object,__Pyx_TypeInfo * __pyx_v_typeinfo)14621 static PyObject *__pyx_memoryview_new(PyObject *__pyx_v_o, int __pyx_v_flags, int __pyx_v_dtype_is_object, __Pyx_TypeInfo *__pyx_v_typeinfo) {
14622   struct __pyx_memoryview_obj *__pyx_v_result = 0;
14623   PyObject *__pyx_r = NULL;
14624   __Pyx_RefNannyDeclarations
14625   PyObject *__pyx_t_1 = NULL;
14626   PyObject *__pyx_t_2 = NULL;
14627   PyObject *__pyx_t_3 = NULL;
14628   int __pyx_lineno = 0;
14629   const char *__pyx_filename = NULL;
14630   int __pyx_clineno = 0;
14631   __Pyx_RefNannySetupContext("memoryview_cwrapper", 0);
14632 
14633   /* "View.MemoryView":658
14634  * @cname('__pyx_memoryview_new')
14635  * cdef memoryview_cwrapper(object o, int flags, bint dtype_is_object, __Pyx_TypeInfo *typeinfo):
14636  *     cdef memoryview result = memoryview(o, flags, dtype_is_object)             # <<<<<<<<<<<<<<
14637  *     result.typeinfo = typeinfo
14638  *     return result
14639  */
14640   __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_flags); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 658, __pyx_L1_error)
14641   __Pyx_GOTREF(__pyx_t_1);
14642   __pyx_t_2 = __Pyx_PyBool_FromLong(__pyx_v_dtype_is_object); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 658, __pyx_L1_error)
14643   __Pyx_GOTREF(__pyx_t_2);
14644   __pyx_t_3 = PyTuple_New(3); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 658, __pyx_L1_error)
14645   __Pyx_GOTREF(__pyx_t_3);
14646   __Pyx_INCREF(__pyx_v_o);
14647   __Pyx_GIVEREF(__pyx_v_o);
14648   PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_o);
14649   __Pyx_GIVEREF(__pyx_t_1);
14650   PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_1);
14651   __Pyx_GIVEREF(__pyx_t_2);
14652   PyTuple_SET_ITEM(__pyx_t_3, 2, __pyx_t_2);
14653   __pyx_t_1 = 0;
14654   __pyx_t_2 = 0;
14655   __pyx_t_2 = __Pyx_PyObject_Call(((PyObject *)__pyx_memoryview_type), __pyx_t_3, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 658, __pyx_L1_error)
14656   __Pyx_GOTREF(__pyx_t_2);
14657   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
14658   __pyx_v_result = ((struct __pyx_memoryview_obj *)__pyx_t_2);
14659   __pyx_t_2 = 0;
14660 
14661   /* "View.MemoryView":659
14662  * cdef memoryview_cwrapper(object o, int flags, bint dtype_is_object, __Pyx_TypeInfo *typeinfo):
14663  *     cdef memoryview result = memoryview(o, flags, dtype_is_object)
14664  *     result.typeinfo = typeinfo             # <<<<<<<<<<<<<<
14665  *     return result
14666  *
14667  */
14668   __pyx_v_result->typeinfo = __pyx_v_typeinfo;
14669 
14670   /* "View.MemoryView":660
14671  *     cdef memoryview result = memoryview(o, flags, dtype_is_object)
14672  *     result.typeinfo = typeinfo
14673  *     return result             # <<<<<<<<<<<<<<
14674  *
14675  * @cname('__pyx_memoryview_check')
14676  */
14677   __Pyx_XDECREF(__pyx_r);
14678   __Pyx_INCREF(((PyObject *)__pyx_v_result));
14679   __pyx_r = ((PyObject *)__pyx_v_result);
14680   goto __pyx_L0;
14681 
14682   /* "View.MemoryView":657
14683  *
14684  * @cname('__pyx_memoryview_new')
14685  * cdef memoryview_cwrapper(object o, int flags, bint dtype_is_object, __Pyx_TypeInfo *typeinfo):             # <<<<<<<<<<<<<<
14686  *     cdef memoryview result = memoryview(o, flags, dtype_is_object)
14687  *     result.typeinfo = typeinfo
14688  */
14689 
14690   /* function exit code */
14691   __pyx_L1_error:;
14692   __Pyx_XDECREF(__pyx_t_1);
14693   __Pyx_XDECREF(__pyx_t_2);
14694   __Pyx_XDECREF(__pyx_t_3);
14695   __Pyx_AddTraceback("View.MemoryView.memoryview_cwrapper", __pyx_clineno, __pyx_lineno, __pyx_filename);
14696   __pyx_r = 0;
14697   __pyx_L0:;
14698   __Pyx_XDECREF((PyObject *)__pyx_v_result);
14699   __Pyx_XGIVEREF(__pyx_r);
14700   __Pyx_RefNannyFinishContext();
14701   return __pyx_r;
14702 }
14703 
14704 /* "View.MemoryView":663
14705  *
14706  * @cname('__pyx_memoryview_check')
14707  * cdef inline bint memoryview_check(object o):             # <<<<<<<<<<<<<<
14708  *     return isinstance(o, memoryview)
14709  *
14710  */
14711 
__pyx_memoryview_check(PyObject * __pyx_v_o)14712 static CYTHON_INLINE int __pyx_memoryview_check(PyObject *__pyx_v_o) {
14713   int __pyx_r;
14714   __Pyx_RefNannyDeclarations
14715   int __pyx_t_1;
14716   __Pyx_RefNannySetupContext("memoryview_check", 0);
14717 
14718   /* "View.MemoryView":664
14719  * @cname('__pyx_memoryview_check')
14720  * cdef inline bint memoryview_check(object o):
14721  *     return isinstance(o, memoryview)             # <<<<<<<<<<<<<<
14722  *
14723  * cdef tuple _unellipsify(object index, int ndim):
14724  */
14725   __pyx_t_1 = __Pyx_TypeCheck(__pyx_v_o, __pyx_memoryview_type);
14726   __pyx_r = __pyx_t_1;
14727   goto __pyx_L0;
14728 
14729   /* "View.MemoryView":663
14730  *
14731  * @cname('__pyx_memoryview_check')
14732  * cdef inline bint memoryview_check(object o):             # <<<<<<<<<<<<<<
14733  *     return isinstance(o, memoryview)
14734  *
14735  */
14736 
14737   /* function exit code */
14738   __pyx_L0:;
14739   __Pyx_RefNannyFinishContext();
14740   return __pyx_r;
14741 }
14742 
14743 /* "View.MemoryView":666
14744  *     return isinstance(o, memoryview)
14745  *
14746  * cdef tuple _unellipsify(object index, int ndim):             # <<<<<<<<<<<<<<
14747  *     """
14748  *     Replace all ellipses with full slices and fill incomplete indices with
14749  */
14750 
_unellipsify(PyObject * __pyx_v_index,int __pyx_v_ndim)14751 static PyObject *_unellipsify(PyObject *__pyx_v_index, int __pyx_v_ndim) {
14752   PyObject *__pyx_v_tup = NULL;
14753   PyObject *__pyx_v_result = NULL;
14754   int __pyx_v_have_slices;
14755   int __pyx_v_seen_ellipsis;
14756   CYTHON_UNUSED PyObject *__pyx_v_idx = NULL;
14757   PyObject *__pyx_v_item = NULL;
14758   Py_ssize_t __pyx_v_nslices;
14759   PyObject *__pyx_r = NULL;
14760   __Pyx_RefNannyDeclarations
14761   int __pyx_t_1;
14762   int __pyx_t_2;
14763   PyObject *__pyx_t_3 = NULL;
14764   PyObject *__pyx_t_4 = NULL;
14765   Py_ssize_t __pyx_t_5;
14766   PyObject *(*__pyx_t_6)(PyObject *);
14767   PyObject *__pyx_t_7 = NULL;
14768   Py_ssize_t __pyx_t_8;
14769   int __pyx_t_9;
14770   int __pyx_t_10;
14771   PyObject *__pyx_t_11 = NULL;
14772   int __pyx_lineno = 0;
14773   const char *__pyx_filename = NULL;
14774   int __pyx_clineno = 0;
14775   __Pyx_RefNannySetupContext("_unellipsify", 0);
14776 
14777   /* "View.MemoryView":671
14778  *     full slices.
14779  *     """
14780  *     if not isinstance(index, tuple):             # <<<<<<<<<<<<<<
14781  *         tup = (index,)
14782  *     else:
14783  */
14784   __pyx_t_1 = PyTuple_Check(__pyx_v_index);
14785   __pyx_t_2 = ((!(__pyx_t_1 != 0)) != 0);
14786   if (__pyx_t_2) {
14787 
14788     /* "View.MemoryView":672
14789  *     """
14790  *     if not isinstance(index, tuple):
14791  *         tup = (index,)             # <<<<<<<<<<<<<<
14792  *     else:
14793  *         tup = index
14794  */
14795     __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 672, __pyx_L1_error)
14796     __Pyx_GOTREF(__pyx_t_3);
14797     __Pyx_INCREF(__pyx_v_index);
14798     __Pyx_GIVEREF(__pyx_v_index);
14799     PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_index);
14800     __pyx_v_tup = __pyx_t_3;
14801     __pyx_t_3 = 0;
14802 
14803     /* "View.MemoryView":671
14804  *     full slices.
14805  *     """
14806  *     if not isinstance(index, tuple):             # <<<<<<<<<<<<<<
14807  *         tup = (index,)
14808  *     else:
14809  */
14810     goto __pyx_L3;
14811   }
14812 
14813   /* "View.MemoryView":674
14814  *         tup = (index,)
14815  *     else:
14816  *         tup = index             # <<<<<<<<<<<<<<
14817  *
14818  *     result = []
14819  */
14820   /*else*/ {
14821     __Pyx_INCREF(__pyx_v_index);
14822     __pyx_v_tup = __pyx_v_index;
14823   }
14824   __pyx_L3:;
14825 
14826   /* "View.MemoryView":676
14827  *         tup = index
14828  *
14829  *     result = []             # <<<<<<<<<<<<<<
14830  *     have_slices = False
14831  *     seen_ellipsis = False
14832  */
14833   __pyx_t_3 = PyList_New(0); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 676, __pyx_L1_error)
14834   __Pyx_GOTREF(__pyx_t_3);
14835   __pyx_v_result = ((PyObject*)__pyx_t_3);
14836   __pyx_t_3 = 0;
14837 
14838   /* "View.MemoryView":677
14839  *
14840  *     result = []
14841  *     have_slices = False             # <<<<<<<<<<<<<<
14842  *     seen_ellipsis = False
14843  *     for idx, item in enumerate(tup):
14844  */
14845   __pyx_v_have_slices = 0;
14846 
14847   /* "View.MemoryView":678
14848  *     result = []
14849  *     have_slices = False
14850  *     seen_ellipsis = False             # <<<<<<<<<<<<<<
14851  *     for idx, item in enumerate(tup):
14852  *         if item is Ellipsis:
14853  */
14854   __pyx_v_seen_ellipsis = 0;
14855 
14856   /* "View.MemoryView":679
14857  *     have_slices = False
14858  *     seen_ellipsis = False
14859  *     for idx, item in enumerate(tup):             # <<<<<<<<<<<<<<
14860  *         if item is Ellipsis:
14861  *             if not seen_ellipsis:
14862  */
14863   __Pyx_INCREF(__pyx_int_0);
14864   __pyx_t_3 = __pyx_int_0;
14865   if (likely(PyList_CheckExact(__pyx_v_tup)) || PyTuple_CheckExact(__pyx_v_tup)) {
14866     __pyx_t_4 = __pyx_v_tup; __Pyx_INCREF(__pyx_t_4); __pyx_t_5 = 0;
14867     __pyx_t_6 = NULL;
14868   } else {
14869     __pyx_t_5 = -1; __pyx_t_4 = PyObject_GetIter(__pyx_v_tup); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 679, __pyx_L1_error)
14870     __Pyx_GOTREF(__pyx_t_4);
14871     __pyx_t_6 = Py_TYPE(__pyx_t_4)->tp_iternext; if (unlikely(!__pyx_t_6)) __PYX_ERR(2, 679, __pyx_L1_error)
14872   }
14873   for (;;) {
14874     if (likely(!__pyx_t_6)) {
14875       if (likely(PyList_CheckExact(__pyx_t_4))) {
14876         if (__pyx_t_5 >= PyList_GET_SIZE(__pyx_t_4)) break;
14877         #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
14878         __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(2, 679, __pyx_L1_error)
14879         #else
14880         __pyx_t_7 = PySequence_ITEM(__pyx_t_4, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_7)) __PYX_ERR(2, 679, __pyx_L1_error)
14881         __Pyx_GOTREF(__pyx_t_7);
14882         #endif
14883       } else {
14884         if (__pyx_t_5 >= PyTuple_GET_SIZE(__pyx_t_4)) break;
14885         #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
14886         __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(2, 679, __pyx_L1_error)
14887         #else
14888         __pyx_t_7 = PySequence_ITEM(__pyx_t_4, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_7)) __PYX_ERR(2, 679, __pyx_L1_error)
14889         __Pyx_GOTREF(__pyx_t_7);
14890         #endif
14891       }
14892     } else {
14893       __pyx_t_7 = __pyx_t_6(__pyx_t_4);
14894       if (unlikely(!__pyx_t_7)) {
14895         PyObject* exc_type = PyErr_Occurred();
14896         if (exc_type) {
14897           if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
14898           else __PYX_ERR(2, 679, __pyx_L1_error)
14899         }
14900         break;
14901       }
14902       __Pyx_GOTREF(__pyx_t_7);
14903     }
14904     __Pyx_XDECREF_SET(__pyx_v_item, __pyx_t_7);
14905     __pyx_t_7 = 0;
14906     __Pyx_INCREF(__pyx_t_3);
14907     __Pyx_XDECREF_SET(__pyx_v_idx, __pyx_t_3);
14908     __pyx_t_7 = __Pyx_PyInt_AddObjC(__pyx_t_3, __pyx_int_1, 1, 0, 0); if (unlikely(!__pyx_t_7)) __PYX_ERR(2, 679, __pyx_L1_error)
14909     __Pyx_GOTREF(__pyx_t_7);
14910     __Pyx_DECREF(__pyx_t_3);
14911     __pyx_t_3 = __pyx_t_7;
14912     __pyx_t_7 = 0;
14913 
14914     /* "View.MemoryView":680
14915  *     seen_ellipsis = False
14916  *     for idx, item in enumerate(tup):
14917  *         if item is Ellipsis:             # <<<<<<<<<<<<<<
14918  *             if not seen_ellipsis:
14919  *                 result.extend([slice(None)] * (ndim - len(tup) + 1))
14920  */
14921     __pyx_t_2 = (__pyx_v_item == __pyx_builtin_Ellipsis);
14922     __pyx_t_1 = (__pyx_t_2 != 0);
14923     if (__pyx_t_1) {
14924 
14925       /* "View.MemoryView":681
14926  *     for idx, item in enumerate(tup):
14927  *         if item is Ellipsis:
14928  *             if not seen_ellipsis:             # <<<<<<<<<<<<<<
14929  *                 result.extend([slice(None)] * (ndim - len(tup) + 1))
14930  *                 seen_ellipsis = True
14931  */
14932       __pyx_t_1 = ((!(__pyx_v_seen_ellipsis != 0)) != 0);
14933       if (__pyx_t_1) {
14934 
14935         /* "View.MemoryView":682
14936  *         if item is Ellipsis:
14937  *             if not seen_ellipsis:
14938  *                 result.extend([slice(None)] * (ndim - len(tup) + 1))             # <<<<<<<<<<<<<<
14939  *                 seen_ellipsis = True
14940  *             else:
14941  */
14942         __pyx_t_8 = PyObject_Length(__pyx_v_tup); if (unlikely(__pyx_t_8 == ((Py_ssize_t)-1))) __PYX_ERR(2, 682, __pyx_L1_error)
14943         __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(2, 682, __pyx_L1_error)
14944         __Pyx_GOTREF(__pyx_t_7);
14945         { Py_ssize_t __pyx_temp;
14946           for (__pyx_temp=0; __pyx_temp < ((__pyx_v_ndim - __pyx_t_8) + 1); __pyx_temp++) {
14947             __Pyx_INCREF(__pyx_slice__20);
14948             __Pyx_GIVEREF(__pyx_slice__20);
14949             PyList_SET_ITEM(__pyx_t_7, __pyx_temp, __pyx_slice__20);
14950           }
14951         }
14952         __pyx_t_9 = __Pyx_PyList_Extend(__pyx_v_result, __pyx_t_7); if (unlikely(__pyx_t_9 == ((int)-1))) __PYX_ERR(2, 682, __pyx_L1_error)
14953         __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
14954 
14955         /* "View.MemoryView":683
14956  *             if not seen_ellipsis:
14957  *                 result.extend([slice(None)] * (ndim - len(tup) + 1))
14958  *                 seen_ellipsis = True             # <<<<<<<<<<<<<<
14959  *             else:
14960  *                 result.append(slice(None))
14961  */
14962         __pyx_v_seen_ellipsis = 1;
14963 
14964         /* "View.MemoryView":681
14965  *     for idx, item in enumerate(tup):
14966  *         if item is Ellipsis:
14967  *             if not seen_ellipsis:             # <<<<<<<<<<<<<<
14968  *                 result.extend([slice(None)] * (ndim - len(tup) + 1))
14969  *                 seen_ellipsis = True
14970  */
14971         goto __pyx_L7;
14972       }
14973 
14974       /* "View.MemoryView":685
14975  *                 seen_ellipsis = True
14976  *             else:
14977  *                 result.append(slice(None))             # <<<<<<<<<<<<<<
14978  *             have_slices = True
14979  *         else:
14980  */
14981       /*else*/ {
14982         __pyx_t_9 = __Pyx_PyList_Append(__pyx_v_result, __pyx_slice__20); if (unlikely(__pyx_t_9 == ((int)-1))) __PYX_ERR(2, 685, __pyx_L1_error)
14983       }
14984       __pyx_L7:;
14985 
14986       /* "View.MemoryView":686
14987  *             else:
14988  *                 result.append(slice(None))
14989  *             have_slices = True             # <<<<<<<<<<<<<<
14990  *         else:
14991  *             if not isinstance(item, slice) and not PyIndex_Check(item):
14992  */
14993       __pyx_v_have_slices = 1;
14994 
14995       /* "View.MemoryView":680
14996  *     seen_ellipsis = False
14997  *     for idx, item in enumerate(tup):
14998  *         if item is Ellipsis:             # <<<<<<<<<<<<<<
14999  *             if not seen_ellipsis:
15000  *                 result.extend([slice(None)] * (ndim - len(tup) + 1))
15001  */
15002       goto __pyx_L6;
15003     }
15004 
15005     /* "View.MemoryView":688
15006  *             have_slices = True
15007  *         else:
15008  *             if not isinstance(item, slice) and not PyIndex_Check(item):             # <<<<<<<<<<<<<<
15009  *                 raise TypeError("Cannot index with type '%s'" % type(item))
15010  *
15011  */
15012     /*else*/ {
15013       __pyx_t_2 = PySlice_Check(__pyx_v_item);
15014       __pyx_t_10 = ((!(__pyx_t_2 != 0)) != 0);
15015       if (__pyx_t_10) {
15016       } else {
15017         __pyx_t_1 = __pyx_t_10;
15018         goto __pyx_L9_bool_binop_done;
15019       }
15020       __pyx_t_10 = ((!(PyIndex_Check(__pyx_v_item) != 0)) != 0);
15021       __pyx_t_1 = __pyx_t_10;
15022       __pyx_L9_bool_binop_done:;
15023       if (unlikely(__pyx_t_1)) {
15024 
15025         /* "View.MemoryView":689
15026  *         else:
15027  *             if not isinstance(item, slice) and not PyIndex_Check(item):
15028  *                 raise TypeError("Cannot index with type '%s'" % type(item))             # <<<<<<<<<<<<<<
15029  *
15030  *             have_slices = have_slices or isinstance(item, slice)
15031  */
15032         __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(2, 689, __pyx_L1_error)
15033         __Pyx_GOTREF(__pyx_t_7);
15034         __pyx_t_11 = __Pyx_PyObject_CallOneArg(__pyx_builtin_TypeError, __pyx_t_7); if (unlikely(!__pyx_t_11)) __PYX_ERR(2, 689, __pyx_L1_error)
15035         __Pyx_GOTREF(__pyx_t_11);
15036         __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
15037         __Pyx_Raise(__pyx_t_11, 0, 0, 0);
15038         __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
15039         __PYX_ERR(2, 689, __pyx_L1_error)
15040 
15041         /* "View.MemoryView":688
15042  *             have_slices = True
15043  *         else:
15044  *             if not isinstance(item, slice) and not PyIndex_Check(item):             # <<<<<<<<<<<<<<
15045  *                 raise TypeError("Cannot index with type '%s'" % type(item))
15046  *
15047  */
15048       }
15049 
15050       /* "View.MemoryView":691
15051  *                 raise TypeError("Cannot index with type '%s'" % type(item))
15052  *
15053  *             have_slices = have_slices or isinstance(item, slice)             # <<<<<<<<<<<<<<
15054  *             result.append(item)
15055  *
15056  */
15057       __pyx_t_10 = (__pyx_v_have_slices != 0);
15058       if (!__pyx_t_10) {
15059       } else {
15060         __pyx_t_1 = __pyx_t_10;
15061         goto __pyx_L11_bool_binop_done;
15062       }
15063       __pyx_t_10 = PySlice_Check(__pyx_v_item);
15064       __pyx_t_2 = (__pyx_t_10 != 0);
15065       __pyx_t_1 = __pyx_t_2;
15066       __pyx_L11_bool_binop_done:;
15067       __pyx_v_have_slices = __pyx_t_1;
15068 
15069       /* "View.MemoryView":692
15070  *
15071  *             have_slices = have_slices or isinstance(item, slice)
15072  *             result.append(item)             # <<<<<<<<<<<<<<
15073  *
15074  *     nslices = ndim - len(result)
15075  */
15076       __pyx_t_9 = __Pyx_PyList_Append(__pyx_v_result, __pyx_v_item); if (unlikely(__pyx_t_9 == ((int)-1))) __PYX_ERR(2, 692, __pyx_L1_error)
15077     }
15078     __pyx_L6:;
15079 
15080     /* "View.MemoryView":679
15081  *     have_slices = False
15082  *     seen_ellipsis = False
15083  *     for idx, item in enumerate(tup):             # <<<<<<<<<<<<<<
15084  *         if item is Ellipsis:
15085  *             if not seen_ellipsis:
15086  */
15087   }
15088   __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
15089   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
15090 
15091   /* "View.MemoryView":694
15092  *             result.append(item)
15093  *
15094  *     nslices = ndim - len(result)             # <<<<<<<<<<<<<<
15095  *     if nslices:
15096  *         result.extend([slice(None)] * nslices)
15097  */
15098   __pyx_t_5 = PyList_GET_SIZE(__pyx_v_result); if (unlikely(__pyx_t_5 == ((Py_ssize_t)-1))) __PYX_ERR(2, 694, __pyx_L1_error)
15099   __pyx_v_nslices = (__pyx_v_ndim - __pyx_t_5);
15100 
15101   /* "View.MemoryView":695
15102  *
15103  *     nslices = ndim - len(result)
15104  *     if nslices:             # <<<<<<<<<<<<<<
15105  *         result.extend([slice(None)] * nslices)
15106  *
15107  */
15108   __pyx_t_1 = (__pyx_v_nslices != 0);
15109   if (__pyx_t_1) {
15110 
15111     /* "View.MemoryView":696
15112  *     nslices = ndim - len(result)
15113  *     if nslices:
15114  *         result.extend([slice(None)] * nslices)             # <<<<<<<<<<<<<<
15115  *
15116  *     return have_slices or nslices, tuple(result)
15117  */
15118     __pyx_t_3 = PyList_New(1 * ((__pyx_v_nslices<0) ? 0:__pyx_v_nslices)); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 696, __pyx_L1_error)
15119     __Pyx_GOTREF(__pyx_t_3);
15120     { Py_ssize_t __pyx_temp;
15121       for (__pyx_temp=0; __pyx_temp < __pyx_v_nslices; __pyx_temp++) {
15122         __Pyx_INCREF(__pyx_slice__20);
15123         __Pyx_GIVEREF(__pyx_slice__20);
15124         PyList_SET_ITEM(__pyx_t_3, __pyx_temp, __pyx_slice__20);
15125       }
15126     }
15127     __pyx_t_9 = __Pyx_PyList_Extend(__pyx_v_result, __pyx_t_3); if (unlikely(__pyx_t_9 == ((int)-1))) __PYX_ERR(2, 696, __pyx_L1_error)
15128     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
15129 
15130     /* "View.MemoryView":695
15131  *
15132  *     nslices = ndim - len(result)
15133  *     if nslices:             # <<<<<<<<<<<<<<
15134  *         result.extend([slice(None)] * nslices)
15135  *
15136  */
15137   }
15138 
15139   /* "View.MemoryView":698
15140  *         result.extend([slice(None)] * nslices)
15141  *
15142  *     return have_slices or nslices, tuple(result)             # <<<<<<<<<<<<<<
15143  *
15144  * cdef assert_direct_dimensions(Py_ssize_t *suboffsets, int ndim):
15145  */
15146   __Pyx_XDECREF(__pyx_r);
15147   if (!__pyx_v_have_slices) {
15148   } else {
15149     __pyx_t_4 = __Pyx_PyBool_FromLong(__pyx_v_have_slices); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 698, __pyx_L1_error)
15150     __Pyx_GOTREF(__pyx_t_4);
15151     __pyx_t_3 = __pyx_t_4;
15152     __pyx_t_4 = 0;
15153     goto __pyx_L14_bool_binop_done;
15154   }
15155   __pyx_t_4 = PyInt_FromSsize_t(__pyx_v_nslices); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 698, __pyx_L1_error)
15156   __Pyx_GOTREF(__pyx_t_4);
15157   __pyx_t_3 = __pyx_t_4;
15158   __pyx_t_4 = 0;
15159   __pyx_L14_bool_binop_done:;
15160   __pyx_t_4 = PyList_AsTuple(__pyx_v_result); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 698, __pyx_L1_error)
15161   __Pyx_GOTREF(__pyx_t_4);
15162   __pyx_t_11 = PyTuple_New(2); if (unlikely(!__pyx_t_11)) __PYX_ERR(2, 698, __pyx_L1_error)
15163   __Pyx_GOTREF(__pyx_t_11);
15164   __Pyx_GIVEREF(__pyx_t_3);
15165   PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_t_3);
15166   __Pyx_GIVEREF(__pyx_t_4);
15167   PyTuple_SET_ITEM(__pyx_t_11, 1, __pyx_t_4);
15168   __pyx_t_3 = 0;
15169   __pyx_t_4 = 0;
15170   __pyx_r = ((PyObject*)__pyx_t_11);
15171   __pyx_t_11 = 0;
15172   goto __pyx_L0;
15173 
15174   /* "View.MemoryView":666
15175  *     return isinstance(o, memoryview)
15176  *
15177  * cdef tuple _unellipsify(object index, int ndim):             # <<<<<<<<<<<<<<
15178  *     """
15179  *     Replace all ellipses with full slices and fill incomplete indices with
15180  */
15181 
15182   /* function exit code */
15183   __pyx_L1_error:;
15184   __Pyx_XDECREF(__pyx_t_3);
15185   __Pyx_XDECREF(__pyx_t_4);
15186   __Pyx_XDECREF(__pyx_t_7);
15187   __Pyx_XDECREF(__pyx_t_11);
15188   __Pyx_AddTraceback("View.MemoryView._unellipsify", __pyx_clineno, __pyx_lineno, __pyx_filename);
15189   __pyx_r = 0;
15190   __pyx_L0:;
15191   __Pyx_XDECREF(__pyx_v_tup);
15192   __Pyx_XDECREF(__pyx_v_result);
15193   __Pyx_XDECREF(__pyx_v_idx);
15194   __Pyx_XDECREF(__pyx_v_item);
15195   __Pyx_XGIVEREF(__pyx_r);
15196   __Pyx_RefNannyFinishContext();
15197   return __pyx_r;
15198 }
15199 
15200 /* "View.MemoryView":700
15201  *     return have_slices or nslices, tuple(result)
15202  *
15203  * cdef assert_direct_dimensions(Py_ssize_t *suboffsets, int ndim):             # <<<<<<<<<<<<<<
15204  *     for suboffset in suboffsets[:ndim]:
15205  *         if suboffset >= 0:
15206  */
15207 
assert_direct_dimensions(Py_ssize_t * __pyx_v_suboffsets,int __pyx_v_ndim)15208 static PyObject *assert_direct_dimensions(Py_ssize_t *__pyx_v_suboffsets, int __pyx_v_ndim) {
15209   Py_ssize_t __pyx_v_suboffset;
15210   PyObject *__pyx_r = NULL;
15211   __Pyx_RefNannyDeclarations
15212   Py_ssize_t *__pyx_t_1;
15213   Py_ssize_t *__pyx_t_2;
15214   Py_ssize_t *__pyx_t_3;
15215   int __pyx_t_4;
15216   PyObject *__pyx_t_5 = NULL;
15217   int __pyx_lineno = 0;
15218   const char *__pyx_filename = NULL;
15219   int __pyx_clineno = 0;
15220   __Pyx_RefNannySetupContext("assert_direct_dimensions", 0);
15221 
15222   /* "View.MemoryView":701
15223  *
15224  * cdef assert_direct_dimensions(Py_ssize_t *suboffsets, int ndim):
15225  *     for suboffset in suboffsets[:ndim]:             # <<<<<<<<<<<<<<
15226  *         if suboffset >= 0:
15227  *             raise ValueError("Indirect dimensions not supported")
15228  */
15229   __pyx_t_2 = (__pyx_v_suboffsets + __pyx_v_ndim);
15230   for (__pyx_t_3 = __pyx_v_suboffsets; __pyx_t_3 < __pyx_t_2; __pyx_t_3++) {
15231     __pyx_t_1 = __pyx_t_3;
15232     __pyx_v_suboffset = (__pyx_t_1[0]);
15233 
15234     /* "View.MemoryView":702
15235  * cdef assert_direct_dimensions(Py_ssize_t *suboffsets, int ndim):
15236  *     for suboffset in suboffsets[:ndim]:
15237  *         if suboffset >= 0:             # <<<<<<<<<<<<<<
15238  *             raise ValueError("Indirect dimensions not supported")
15239  *
15240  */
15241     __pyx_t_4 = ((__pyx_v_suboffset >= 0) != 0);
15242     if (unlikely(__pyx_t_4)) {
15243 
15244       /* "View.MemoryView":703
15245  *     for suboffset in suboffsets[:ndim]:
15246  *         if suboffset >= 0:
15247  *             raise ValueError("Indirect dimensions not supported")             # <<<<<<<<<<<<<<
15248  *
15249  *
15250  */
15251       __pyx_t_5 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__21, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(2, 703, __pyx_L1_error)
15252       __Pyx_GOTREF(__pyx_t_5);
15253       __Pyx_Raise(__pyx_t_5, 0, 0, 0);
15254       __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
15255       __PYX_ERR(2, 703, __pyx_L1_error)
15256 
15257       /* "View.MemoryView":702
15258  * cdef assert_direct_dimensions(Py_ssize_t *suboffsets, int ndim):
15259  *     for suboffset in suboffsets[:ndim]:
15260  *         if suboffset >= 0:             # <<<<<<<<<<<<<<
15261  *             raise ValueError("Indirect dimensions not supported")
15262  *
15263  */
15264     }
15265   }
15266 
15267   /* "View.MemoryView":700
15268  *     return have_slices or nslices, tuple(result)
15269  *
15270  * cdef assert_direct_dimensions(Py_ssize_t *suboffsets, int ndim):             # <<<<<<<<<<<<<<
15271  *     for suboffset in suboffsets[:ndim]:
15272  *         if suboffset >= 0:
15273  */
15274 
15275   /* function exit code */
15276   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
15277   goto __pyx_L0;
15278   __pyx_L1_error:;
15279   __Pyx_XDECREF(__pyx_t_5);
15280   __Pyx_AddTraceback("View.MemoryView.assert_direct_dimensions", __pyx_clineno, __pyx_lineno, __pyx_filename);
15281   __pyx_r = 0;
15282   __pyx_L0:;
15283   __Pyx_XGIVEREF(__pyx_r);
15284   __Pyx_RefNannyFinishContext();
15285   return __pyx_r;
15286 }
15287 
15288 /* "View.MemoryView":710
15289  *
15290  * @cname('__pyx_memview_slice')
15291  * cdef memoryview memview_slice(memoryview memview, object indices):             # <<<<<<<<<<<<<<
15292  *     cdef int new_ndim = 0, suboffset_dim = -1, dim
15293  *     cdef bint negative_step
15294  */
15295 
__pyx_memview_slice(struct __pyx_memoryview_obj * __pyx_v_memview,PyObject * __pyx_v_indices)15296 static struct __pyx_memoryview_obj *__pyx_memview_slice(struct __pyx_memoryview_obj *__pyx_v_memview, PyObject *__pyx_v_indices) {
15297   int __pyx_v_new_ndim;
15298   int __pyx_v_suboffset_dim;
15299   int __pyx_v_dim;
15300   __Pyx_memviewslice __pyx_v_src;
15301   __Pyx_memviewslice __pyx_v_dst;
15302   __Pyx_memviewslice *__pyx_v_p_src;
15303   struct __pyx_memoryviewslice_obj *__pyx_v_memviewsliceobj = 0;
15304   __Pyx_memviewslice *__pyx_v_p_dst;
15305   int *__pyx_v_p_suboffset_dim;
15306   Py_ssize_t __pyx_v_start;
15307   Py_ssize_t __pyx_v_stop;
15308   Py_ssize_t __pyx_v_step;
15309   int __pyx_v_have_start;
15310   int __pyx_v_have_stop;
15311   int __pyx_v_have_step;
15312   PyObject *__pyx_v_index = NULL;
15313   struct __pyx_memoryview_obj *__pyx_r = NULL;
15314   __Pyx_RefNannyDeclarations
15315   int __pyx_t_1;
15316   int __pyx_t_2;
15317   PyObject *__pyx_t_3 = NULL;
15318   struct __pyx_memoryview_obj *__pyx_t_4;
15319   char *__pyx_t_5;
15320   int __pyx_t_6;
15321   Py_ssize_t __pyx_t_7;
15322   PyObject *(*__pyx_t_8)(PyObject *);
15323   PyObject *__pyx_t_9 = NULL;
15324   Py_ssize_t __pyx_t_10;
15325   int __pyx_t_11;
15326   Py_ssize_t __pyx_t_12;
15327   int __pyx_lineno = 0;
15328   const char *__pyx_filename = NULL;
15329   int __pyx_clineno = 0;
15330   __Pyx_RefNannySetupContext("memview_slice", 0);
15331 
15332   /* "View.MemoryView":711
15333  * @cname('__pyx_memview_slice')
15334  * cdef memoryview memview_slice(memoryview memview, object indices):
15335  *     cdef int new_ndim = 0, suboffset_dim = -1, dim             # <<<<<<<<<<<<<<
15336  *     cdef bint negative_step
15337  *     cdef __Pyx_memviewslice src, dst
15338  */
15339   __pyx_v_new_ndim = 0;
15340   __pyx_v_suboffset_dim = -1;
15341 
15342   /* "View.MemoryView":718
15343  *
15344  *
15345  *     memset(&dst, 0, sizeof(dst))             # <<<<<<<<<<<<<<
15346  *
15347  *     cdef _memoryviewslice memviewsliceobj
15348  */
15349   (void)(memset((&__pyx_v_dst), 0, (sizeof(__pyx_v_dst))));
15350 
15351   /* "View.MemoryView":722
15352  *     cdef _memoryviewslice memviewsliceobj
15353  *
15354  *     assert memview.view.ndim > 0             # <<<<<<<<<<<<<<
15355  *
15356  *     if isinstance(memview, _memoryviewslice):
15357  */
15358   #ifndef CYTHON_WITHOUT_ASSERTIONS
15359   if (unlikely(!Py_OptimizeFlag)) {
15360     if (unlikely(!((__pyx_v_memview->view.ndim > 0) != 0))) {
15361       PyErr_SetNone(PyExc_AssertionError);
15362       __PYX_ERR(2, 722, __pyx_L1_error)
15363     }
15364   }
15365   #endif
15366 
15367   /* "View.MemoryView":724
15368  *     assert memview.view.ndim > 0
15369  *
15370  *     if isinstance(memview, _memoryviewslice):             # <<<<<<<<<<<<<<
15371  *         memviewsliceobj = memview
15372  *         p_src = &memviewsliceobj.from_slice
15373  */
15374   __pyx_t_1 = __Pyx_TypeCheck(((PyObject *)__pyx_v_memview), __pyx_memoryviewslice_type);
15375   __pyx_t_2 = (__pyx_t_1 != 0);
15376   if (__pyx_t_2) {
15377 
15378     /* "View.MemoryView":725
15379  *
15380  *     if isinstance(memview, _memoryviewslice):
15381  *         memviewsliceobj = memview             # <<<<<<<<<<<<<<
15382  *         p_src = &memviewsliceobj.from_slice
15383  *     else:
15384  */
15385     if (!(likely(((((PyObject *)__pyx_v_memview)) == Py_None) || likely(__Pyx_TypeTest(((PyObject *)__pyx_v_memview), __pyx_memoryviewslice_type))))) __PYX_ERR(2, 725, __pyx_L1_error)
15386     __pyx_t_3 = ((PyObject *)__pyx_v_memview);
15387     __Pyx_INCREF(__pyx_t_3);
15388     __pyx_v_memviewsliceobj = ((struct __pyx_memoryviewslice_obj *)__pyx_t_3);
15389     __pyx_t_3 = 0;
15390 
15391     /* "View.MemoryView":726
15392  *     if isinstance(memview, _memoryviewslice):
15393  *         memviewsliceobj = memview
15394  *         p_src = &memviewsliceobj.from_slice             # <<<<<<<<<<<<<<
15395  *     else:
15396  *         slice_copy(memview, &src)
15397  */
15398     __pyx_v_p_src = (&__pyx_v_memviewsliceobj->from_slice);
15399 
15400     /* "View.MemoryView":724
15401  *     assert memview.view.ndim > 0
15402  *
15403  *     if isinstance(memview, _memoryviewslice):             # <<<<<<<<<<<<<<
15404  *         memviewsliceobj = memview
15405  *         p_src = &memviewsliceobj.from_slice
15406  */
15407     goto __pyx_L3;
15408   }
15409 
15410   /* "View.MemoryView":728
15411  *         p_src = &memviewsliceobj.from_slice
15412  *     else:
15413  *         slice_copy(memview, &src)             # <<<<<<<<<<<<<<
15414  *         p_src = &src
15415  *
15416  */
15417   /*else*/ {
15418     __pyx_memoryview_slice_copy(__pyx_v_memview, (&__pyx_v_src));
15419 
15420     /* "View.MemoryView":729
15421  *     else:
15422  *         slice_copy(memview, &src)
15423  *         p_src = &src             # <<<<<<<<<<<<<<
15424  *
15425  *
15426  */
15427     __pyx_v_p_src = (&__pyx_v_src);
15428   }
15429   __pyx_L3:;
15430 
15431   /* "View.MemoryView":735
15432  *
15433  *
15434  *     dst.memview = p_src.memview             # <<<<<<<<<<<<<<
15435  *     dst.data = p_src.data
15436  *
15437  */
15438   __pyx_t_4 = __pyx_v_p_src->memview;
15439   __pyx_v_dst.memview = __pyx_t_4;
15440 
15441   /* "View.MemoryView":736
15442  *
15443  *     dst.memview = p_src.memview
15444  *     dst.data = p_src.data             # <<<<<<<<<<<<<<
15445  *
15446  *
15447  */
15448   __pyx_t_5 = __pyx_v_p_src->data;
15449   __pyx_v_dst.data = __pyx_t_5;
15450 
15451   /* "View.MemoryView":741
15452  *
15453  *
15454  *     cdef __Pyx_memviewslice *p_dst = &dst             # <<<<<<<<<<<<<<
15455  *     cdef int *p_suboffset_dim = &suboffset_dim
15456  *     cdef Py_ssize_t start, stop, step
15457  */
15458   __pyx_v_p_dst = (&__pyx_v_dst);
15459 
15460   /* "View.MemoryView":742
15461  *
15462  *     cdef __Pyx_memviewslice *p_dst = &dst
15463  *     cdef int *p_suboffset_dim = &suboffset_dim             # <<<<<<<<<<<<<<
15464  *     cdef Py_ssize_t start, stop, step
15465  *     cdef bint have_start, have_stop, have_step
15466  */
15467   __pyx_v_p_suboffset_dim = (&__pyx_v_suboffset_dim);
15468 
15469   /* "View.MemoryView":746
15470  *     cdef bint have_start, have_stop, have_step
15471  *
15472  *     for dim, index in enumerate(indices):             # <<<<<<<<<<<<<<
15473  *         if PyIndex_Check(index):
15474  *             slice_memviewslice(
15475  */
15476   __pyx_t_6 = 0;
15477   if (likely(PyList_CheckExact(__pyx_v_indices)) || PyTuple_CheckExact(__pyx_v_indices)) {
15478     __pyx_t_3 = __pyx_v_indices; __Pyx_INCREF(__pyx_t_3); __pyx_t_7 = 0;
15479     __pyx_t_8 = NULL;
15480   } else {
15481     __pyx_t_7 = -1; __pyx_t_3 = PyObject_GetIter(__pyx_v_indices); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 746, __pyx_L1_error)
15482     __Pyx_GOTREF(__pyx_t_3);
15483     __pyx_t_8 = Py_TYPE(__pyx_t_3)->tp_iternext; if (unlikely(!__pyx_t_8)) __PYX_ERR(2, 746, __pyx_L1_error)
15484   }
15485   for (;;) {
15486     if (likely(!__pyx_t_8)) {
15487       if (likely(PyList_CheckExact(__pyx_t_3))) {
15488         if (__pyx_t_7 >= PyList_GET_SIZE(__pyx_t_3)) break;
15489         #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
15490         __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(2, 746, __pyx_L1_error)
15491         #else
15492         __pyx_t_9 = PySequence_ITEM(__pyx_t_3, __pyx_t_7); __pyx_t_7++; if (unlikely(!__pyx_t_9)) __PYX_ERR(2, 746, __pyx_L1_error)
15493         __Pyx_GOTREF(__pyx_t_9);
15494         #endif
15495       } else {
15496         if (__pyx_t_7 >= PyTuple_GET_SIZE(__pyx_t_3)) break;
15497         #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
15498         __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(2, 746, __pyx_L1_error)
15499         #else
15500         __pyx_t_9 = PySequence_ITEM(__pyx_t_3, __pyx_t_7); __pyx_t_7++; if (unlikely(!__pyx_t_9)) __PYX_ERR(2, 746, __pyx_L1_error)
15501         __Pyx_GOTREF(__pyx_t_9);
15502         #endif
15503       }
15504     } else {
15505       __pyx_t_9 = __pyx_t_8(__pyx_t_3);
15506       if (unlikely(!__pyx_t_9)) {
15507         PyObject* exc_type = PyErr_Occurred();
15508         if (exc_type) {
15509           if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
15510           else __PYX_ERR(2, 746, __pyx_L1_error)
15511         }
15512         break;
15513       }
15514       __Pyx_GOTREF(__pyx_t_9);
15515     }
15516     __Pyx_XDECREF_SET(__pyx_v_index, __pyx_t_9);
15517     __pyx_t_9 = 0;
15518     __pyx_v_dim = __pyx_t_6;
15519     __pyx_t_6 = (__pyx_t_6 + 1);
15520 
15521     /* "View.MemoryView":747
15522  *
15523  *     for dim, index in enumerate(indices):
15524  *         if PyIndex_Check(index):             # <<<<<<<<<<<<<<
15525  *             slice_memviewslice(
15526  *                 p_dst, p_src.shape[dim], p_src.strides[dim], p_src.suboffsets[dim],
15527  */
15528     __pyx_t_2 = (PyIndex_Check(__pyx_v_index) != 0);
15529     if (__pyx_t_2) {
15530 
15531       /* "View.MemoryView":751
15532  *                 p_dst, p_src.shape[dim], p_src.strides[dim], p_src.suboffsets[dim],
15533  *                 dim, new_ndim, p_suboffset_dim,
15534  *                 index, 0, 0, # start, stop, step             # <<<<<<<<<<<<<<
15535  *                 0, 0, 0, # have_{start,stop,step}
15536  *                 False)
15537  */
15538       __pyx_t_10 = __Pyx_PyIndex_AsSsize_t(__pyx_v_index); if (unlikely((__pyx_t_10 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(2, 751, __pyx_L1_error)
15539 
15540       /* "View.MemoryView":748
15541  *     for dim, index in enumerate(indices):
15542  *         if PyIndex_Check(index):
15543  *             slice_memviewslice(             # <<<<<<<<<<<<<<
15544  *                 p_dst, p_src.shape[dim], p_src.strides[dim], p_src.suboffsets[dim],
15545  *                 dim, new_ndim, p_suboffset_dim,
15546  */
15547       __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(2, 748, __pyx_L1_error)
15548 
15549       /* "View.MemoryView":747
15550  *
15551  *     for dim, index in enumerate(indices):
15552  *         if PyIndex_Check(index):             # <<<<<<<<<<<<<<
15553  *             slice_memviewslice(
15554  *                 p_dst, p_src.shape[dim], p_src.strides[dim], p_src.suboffsets[dim],
15555  */
15556       goto __pyx_L6;
15557     }
15558 
15559     /* "View.MemoryView":754
15560  *                 0, 0, 0, # have_{start,stop,step}
15561  *                 False)
15562  *         elif index is None:             # <<<<<<<<<<<<<<
15563  *             p_dst.shape[new_ndim] = 1
15564  *             p_dst.strides[new_ndim] = 0
15565  */
15566     __pyx_t_2 = (__pyx_v_index == Py_None);
15567     __pyx_t_1 = (__pyx_t_2 != 0);
15568     if (__pyx_t_1) {
15569 
15570       /* "View.MemoryView":755
15571  *                 False)
15572  *         elif index is None:
15573  *             p_dst.shape[new_ndim] = 1             # <<<<<<<<<<<<<<
15574  *             p_dst.strides[new_ndim] = 0
15575  *             p_dst.suboffsets[new_ndim] = -1
15576  */
15577       (__pyx_v_p_dst->shape[__pyx_v_new_ndim]) = 1;
15578 
15579       /* "View.MemoryView":756
15580  *         elif index is None:
15581  *             p_dst.shape[new_ndim] = 1
15582  *             p_dst.strides[new_ndim] = 0             # <<<<<<<<<<<<<<
15583  *             p_dst.suboffsets[new_ndim] = -1
15584  *             new_ndim += 1
15585  */
15586       (__pyx_v_p_dst->strides[__pyx_v_new_ndim]) = 0;
15587 
15588       /* "View.MemoryView":757
15589  *             p_dst.shape[new_ndim] = 1
15590  *             p_dst.strides[new_ndim] = 0
15591  *             p_dst.suboffsets[new_ndim] = -1             # <<<<<<<<<<<<<<
15592  *             new_ndim += 1
15593  *         else:
15594  */
15595       (__pyx_v_p_dst->suboffsets[__pyx_v_new_ndim]) = -1L;
15596 
15597       /* "View.MemoryView":758
15598  *             p_dst.strides[new_ndim] = 0
15599  *             p_dst.suboffsets[new_ndim] = -1
15600  *             new_ndim += 1             # <<<<<<<<<<<<<<
15601  *         else:
15602  *             start = index.start or 0
15603  */
15604       __pyx_v_new_ndim = (__pyx_v_new_ndim + 1);
15605 
15606       /* "View.MemoryView":754
15607  *                 0, 0, 0, # have_{start,stop,step}
15608  *                 False)
15609  *         elif index is None:             # <<<<<<<<<<<<<<
15610  *             p_dst.shape[new_ndim] = 1
15611  *             p_dst.strides[new_ndim] = 0
15612  */
15613       goto __pyx_L6;
15614     }
15615 
15616     /* "View.MemoryView":760
15617  *             new_ndim += 1
15618  *         else:
15619  *             start = index.start or 0             # <<<<<<<<<<<<<<
15620  *             stop = index.stop or 0
15621  *             step = index.step or 0
15622  */
15623     /*else*/ {
15624       __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_v_index, __pyx_n_s_start); if (unlikely(!__pyx_t_9)) __PYX_ERR(2, 760, __pyx_L1_error)
15625       __Pyx_GOTREF(__pyx_t_9);
15626       __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_9); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(2, 760, __pyx_L1_error)
15627       if (!__pyx_t_1) {
15628         __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
15629       } else {
15630         __pyx_t_12 = __Pyx_PyIndex_AsSsize_t(__pyx_t_9); if (unlikely((__pyx_t_12 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(2, 760, __pyx_L1_error)
15631         __pyx_t_10 = __pyx_t_12;
15632         __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
15633         goto __pyx_L7_bool_binop_done;
15634       }
15635       __pyx_t_10 = 0;
15636       __pyx_L7_bool_binop_done:;
15637       __pyx_v_start = __pyx_t_10;
15638 
15639       /* "View.MemoryView":761
15640  *         else:
15641  *             start = index.start or 0
15642  *             stop = index.stop or 0             # <<<<<<<<<<<<<<
15643  *             step = index.step or 0
15644  *
15645  */
15646       __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_v_index, __pyx_n_s_stop); if (unlikely(!__pyx_t_9)) __PYX_ERR(2, 761, __pyx_L1_error)
15647       __Pyx_GOTREF(__pyx_t_9);
15648       __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_9); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(2, 761, __pyx_L1_error)
15649       if (!__pyx_t_1) {
15650         __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
15651       } else {
15652         __pyx_t_12 = __Pyx_PyIndex_AsSsize_t(__pyx_t_9); if (unlikely((__pyx_t_12 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(2, 761, __pyx_L1_error)
15653         __pyx_t_10 = __pyx_t_12;
15654         __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
15655         goto __pyx_L9_bool_binop_done;
15656       }
15657       __pyx_t_10 = 0;
15658       __pyx_L9_bool_binop_done:;
15659       __pyx_v_stop = __pyx_t_10;
15660 
15661       /* "View.MemoryView":762
15662  *             start = index.start or 0
15663  *             stop = index.stop or 0
15664  *             step = index.step or 0             # <<<<<<<<<<<<<<
15665  *
15666  *             have_start = index.start is not None
15667  */
15668       __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_v_index, __pyx_n_s_step); if (unlikely(!__pyx_t_9)) __PYX_ERR(2, 762, __pyx_L1_error)
15669       __Pyx_GOTREF(__pyx_t_9);
15670       __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_9); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(2, 762, __pyx_L1_error)
15671       if (!__pyx_t_1) {
15672         __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
15673       } else {
15674         __pyx_t_12 = __Pyx_PyIndex_AsSsize_t(__pyx_t_9); if (unlikely((__pyx_t_12 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(2, 762, __pyx_L1_error)
15675         __pyx_t_10 = __pyx_t_12;
15676         __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
15677         goto __pyx_L11_bool_binop_done;
15678       }
15679       __pyx_t_10 = 0;
15680       __pyx_L11_bool_binop_done:;
15681       __pyx_v_step = __pyx_t_10;
15682 
15683       /* "View.MemoryView":764
15684  *             step = index.step or 0
15685  *
15686  *             have_start = index.start is not None             # <<<<<<<<<<<<<<
15687  *             have_stop = index.stop is not None
15688  *             have_step = index.step is not None
15689  */
15690       __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_v_index, __pyx_n_s_start); if (unlikely(!__pyx_t_9)) __PYX_ERR(2, 764, __pyx_L1_error)
15691       __Pyx_GOTREF(__pyx_t_9);
15692       __pyx_t_1 = (__pyx_t_9 != Py_None);
15693       __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
15694       __pyx_v_have_start = __pyx_t_1;
15695 
15696       /* "View.MemoryView":765
15697  *
15698  *             have_start = index.start is not None
15699  *             have_stop = index.stop is not None             # <<<<<<<<<<<<<<
15700  *             have_step = index.step is not None
15701  *
15702  */
15703       __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_v_index, __pyx_n_s_stop); if (unlikely(!__pyx_t_9)) __PYX_ERR(2, 765, __pyx_L1_error)
15704       __Pyx_GOTREF(__pyx_t_9);
15705       __pyx_t_1 = (__pyx_t_9 != Py_None);
15706       __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
15707       __pyx_v_have_stop = __pyx_t_1;
15708 
15709       /* "View.MemoryView":766
15710  *             have_start = index.start is not None
15711  *             have_stop = index.stop is not None
15712  *             have_step = index.step is not None             # <<<<<<<<<<<<<<
15713  *
15714  *             slice_memviewslice(
15715  */
15716       __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_v_index, __pyx_n_s_step); if (unlikely(!__pyx_t_9)) __PYX_ERR(2, 766, __pyx_L1_error)
15717       __Pyx_GOTREF(__pyx_t_9);
15718       __pyx_t_1 = (__pyx_t_9 != Py_None);
15719       __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
15720       __pyx_v_have_step = __pyx_t_1;
15721 
15722       /* "View.MemoryView":768
15723  *             have_step = index.step is not None
15724  *
15725  *             slice_memviewslice(             # <<<<<<<<<<<<<<
15726  *                 p_dst, p_src.shape[dim], p_src.strides[dim], p_src.suboffsets[dim],
15727  *                 dim, new_ndim, p_suboffset_dim,
15728  */
15729       __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(2, 768, __pyx_L1_error)
15730 
15731       /* "View.MemoryView":774
15732  *                 have_start, have_stop, have_step,
15733  *                 True)
15734  *             new_ndim += 1             # <<<<<<<<<<<<<<
15735  *
15736  *     if isinstance(memview, _memoryviewslice):
15737  */
15738       __pyx_v_new_ndim = (__pyx_v_new_ndim + 1);
15739     }
15740     __pyx_L6:;
15741 
15742     /* "View.MemoryView":746
15743  *     cdef bint have_start, have_stop, have_step
15744  *
15745  *     for dim, index in enumerate(indices):             # <<<<<<<<<<<<<<
15746  *         if PyIndex_Check(index):
15747  *             slice_memviewslice(
15748  */
15749   }
15750   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
15751 
15752   /* "View.MemoryView":776
15753  *             new_ndim += 1
15754  *
15755  *     if isinstance(memview, _memoryviewslice):             # <<<<<<<<<<<<<<
15756  *         return memoryview_fromslice(dst, new_ndim,
15757  *                                     memviewsliceobj.to_object_func,
15758  */
15759   __pyx_t_1 = __Pyx_TypeCheck(((PyObject *)__pyx_v_memview), __pyx_memoryviewslice_type);
15760   __pyx_t_2 = (__pyx_t_1 != 0);
15761   if (__pyx_t_2) {
15762 
15763     /* "View.MemoryView":777
15764  *
15765  *     if isinstance(memview, _memoryviewslice):
15766  *         return memoryview_fromslice(dst, new_ndim,             # <<<<<<<<<<<<<<
15767  *                                     memviewsliceobj.to_object_func,
15768  *                                     memviewsliceobj.to_dtype_func,
15769  */
15770     __Pyx_XDECREF(((PyObject *)__pyx_r));
15771 
15772     /* "View.MemoryView":778
15773  *     if isinstance(memview, _memoryviewslice):
15774  *         return memoryview_fromslice(dst, new_ndim,
15775  *                                     memviewsliceobj.to_object_func,             # <<<<<<<<<<<<<<
15776  *                                     memviewsliceobj.to_dtype_func,
15777  *                                     memview.dtype_is_object)
15778  */
15779     if (unlikely(!__pyx_v_memviewsliceobj)) { __Pyx_RaiseUnboundLocalError("memviewsliceobj"); __PYX_ERR(2, 778, __pyx_L1_error) }
15780 
15781     /* "View.MemoryView":779
15782  *         return memoryview_fromslice(dst, new_ndim,
15783  *                                     memviewsliceobj.to_object_func,
15784  *                                     memviewsliceobj.to_dtype_func,             # <<<<<<<<<<<<<<
15785  *                                     memview.dtype_is_object)
15786  *     else:
15787  */
15788     if (unlikely(!__pyx_v_memviewsliceobj)) { __Pyx_RaiseUnboundLocalError("memviewsliceobj"); __PYX_ERR(2, 779, __pyx_L1_error) }
15789 
15790     /* "View.MemoryView":777
15791  *
15792  *     if isinstance(memview, _memoryviewslice):
15793  *         return memoryview_fromslice(dst, new_ndim,             # <<<<<<<<<<<<<<
15794  *                                     memviewsliceobj.to_object_func,
15795  *                                     memviewsliceobj.to_dtype_func,
15796  */
15797     __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(2, 777, __pyx_L1_error)
15798     __Pyx_GOTREF(__pyx_t_3);
15799     if (!(likely(((__pyx_t_3) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_3, __pyx_memoryview_type))))) __PYX_ERR(2, 777, __pyx_L1_error)
15800     __pyx_r = ((struct __pyx_memoryview_obj *)__pyx_t_3);
15801     __pyx_t_3 = 0;
15802     goto __pyx_L0;
15803 
15804     /* "View.MemoryView":776
15805  *             new_ndim += 1
15806  *
15807  *     if isinstance(memview, _memoryviewslice):             # <<<<<<<<<<<<<<
15808  *         return memoryview_fromslice(dst, new_ndim,
15809  *                                     memviewsliceobj.to_object_func,
15810  */
15811   }
15812 
15813   /* "View.MemoryView":782
15814  *                                     memview.dtype_is_object)
15815  *     else:
15816  *         return memoryview_fromslice(dst, new_ndim, NULL, NULL,             # <<<<<<<<<<<<<<
15817  *                                     memview.dtype_is_object)
15818  *
15819  */
15820   /*else*/ {
15821     __Pyx_XDECREF(((PyObject *)__pyx_r));
15822 
15823     /* "View.MemoryView":783
15824  *     else:
15825  *         return memoryview_fromslice(dst, new_ndim, NULL, NULL,
15826  *                                     memview.dtype_is_object)             # <<<<<<<<<<<<<<
15827  *
15828  *
15829  */
15830     __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(2, 782, __pyx_L1_error)
15831     __Pyx_GOTREF(__pyx_t_3);
15832 
15833     /* "View.MemoryView":782
15834  *                                     memview.dtype_is_object)
15835  *     else:
15836  *         return memoryview_fromslice(dst, new_ndim, NULL, NULL,             # <<<<<<<<<<<<<<
15837  *                                     memview.dtype_is_object)
15838  *
15839  */
15840     if (!(likely(((__pyx_t_3) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_3, __pyx_memoryview_type))))) __PYX_ERR(2, 782, __pyx_L1_error)
15841     __pyx_r = ((struct __pyx_memoryview_obj *)__pyx_t_3);
15842     __pyx_t_3 = 0;
15843     goto __pyx_L0;
15844   }
15845 
15846   /* "View.MemoryView":710
15847  *
15848  * @cname('__pyx_memview_slice')
15849  * cdef memoryview memview_slice(memoryview memview, object indices):             # <<<<<<<<<<<<<<
15850  *     cdef int new_ndim = 0, suboffset_dim = -1, dim
15851  *     cdef bint negative_step
15852  */
15853 
15854   /* function exit code */
15855   __pyx_L1_error:;
15856   __Pyx_XDECREF(__pyx_t_3);
15857   __Pyx_XDECREF(__pyx_t_9);
15858   __Pyx_AddTraceback("View.MemoryView.memview_slice", __pyx_clineno, __pyx_lineno, __pyx_filename);
15859   __pyx_r = 0;
15860   __pyx_L0:;
15861   __Pyx_XDECREF((PyObject *)__pyx_v_memviewsliceobj);
15862   __Pyx_XDECREF(__pyx_v_index);
15863   __Pyx_XGIVEREF((PyObject *)__pyx_r);
15864   __Pyx_RefNannyFinishContext();
15865   return __pyx_r;
15866 }
15867 
15868 /* "View.MemoryView":807
15869  *
15870  * @cname('__pyx_memoryview_slice_memviewslice')
15871  * cdef int slice_memviewslice(             # <<<<<<<<<<<<<<
15872  *         __Pyx_memviewslice *dst,
15873  *         Py_ssize_t shape, Py_ssize_t stride, Py_ssize_t suboffset,
15874  */
15875 
__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)15876 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) {
15877   Py_ssize_t __pyx_v_new_shape;
15878   int __pyx_v_negative_step;
15879   int __pyx_r;
15880   int __pyx_t_1;
15881   int __pyx_t_2;
15882   int __pyx_t_3;
15883   int __pyx_lineno = 0;
15884   const char *__pyx_filename = NULL;
15885   int __pyx_clineno = 0;
15886 
15887   /* "View.MemoryView":827
15888  *     cdef bint negative_step
15889  *
15890  *     if not is_slice:             # <<<<<<<<<<<<<<
15891  *
15892  *         if start < 0:
15893  */
15894   __pyx_t_1 = ((!(__pyx_v_is_slice != 0)) != 0);
15895   if (__pyx_t_1) {
15896 
15897     /* "View.MemoryView":829
15898  *     if not is_slice:
15899  *
15900  *         if start < 0:             # <<<<<<<<<<<<<<
15901  *             start += shape
15902  *         if not 0 <= start < shape:
15903  */
15904     __pyx_t_1 = ((__pyx_v_start < 0) != 0);
15905     if (__pyx_t_1) {
15906 
15907       /* "View.MemoryView":830
15908  *
15909  *         if start < 0:
15910  *             start += shape             # <<<<<<<<<<<<<<
15911  *         if not 0 <= start < shape:
15912  *             _err_dim(IndexError, "Index out of bounds (axis %d)", dim)
15913  */
15914       __pyx_v_start = (__pyx_v_start + __pyx_v_shape);
15915 
15916       /* "View.MemoryView":829
15917  *     if not is_slice:
15918  *
15919  *         if start < 0:             # <<<<<<<<<<<<<<
15920  *             start += shape
15921  *         if not 0 <= start < shape:
15922  */
15923     }
15924 
15925     /* "View.MemoryView":831
15926  *         if start < 0:
15927  *             start += shape
15928  *         if not 0 <= start < shape:             # <<<<<<<<<<<<<<
15929  *             _err_dim(IndexError, "Index out of bounds (axis %d)", dim)
15930  *     else:
15931  */
15932     __pyx_t_1 = (0 <= __pyx_v_start);
15933     if (__pyx_t_1) {
15934       __pyx_t_1 = (__pyx_v_start < __pyx_v_shape);
15935     }
15936     __pyx_t_2 = ((!(__pyx_t_1 != 0)) != 0);
15937     if (__pyx_t_2) {
15938 
15939       /* "View.MemoryView":832
15940  *             start += shape
15941  *         if not 0 <= start < shape:
15942  *             _err_dim(IndexError, "Index out of bounds (axis %d)", dim)             # <<<<<<<<<<<<<<
15943  *     else:
15944  *
15945  */
15946       __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(2, 832, __pyx_L1_error)
15947 
15948       /* "View.MemoryView":831
15949  *         if start < 0:
15950  *             start += shape
15951  *         if not 0 <= start < shape:             # <<<<<<<<<<<<<<
15952  *             _err_dim(IndexError, "Index out of bounds (axis %d)", dim)
15953  *     else:
15954  */
15955     }
15956 
15957     /* "View.MemoryView":827
15958  *     cdef bint negative_step
15959  *
15960  *     if not is_slice:             # <<<<<<<<<<<<<<
15961  *
15962  *         if start < 0:
15963  */
15964     goto __pyx_L3;
15965   }
15966 
15967   /* "View.MemoryView":835
15968  *     else:
15969  *
15970  *         negative_step = have_step != 0 and step < 0             # <<<<<<<<<<<<<<
15971  *
15972  *         if have_step and step == 0:
15973  */
15974   /*else*/ {
15975     __pyx_t_1 = ((__pyx_v_have_step != 0) != 0);
15976     if (__pyx_t_1) {
15977     } else {
15978       __pyx_t_2 = __pyx_t_1;
15979       goto __pyx_L6_bool_binop_done;
15980     }
15981     __pyx_t_1 = ((__pyx_v_step < 0) != 0);
15982     __pyx_t_2 = __pyx_t_1;
15983     __pyx_L6_bool_binop_done:;
15984     __pyx_v_negative_step = __pyx_t_2;
15985 
15986     /* "View.MemoryView":837
15987  *         negative_step = have_step != 0 and step < 0
15988  *
15989  *         if have_step and step == 0:             # <<<<<<<<<<<<<<
15990  *             _err_dim(ValueError, "Step may not be zero (axis %d)", dim)
15991  *
15992  */
15993     __pyx_t_1 = (__pyx_v_have_step != 0);
15994     if (__pyx_t_1) {
15995     } else {
15996       __pyx_t_2 = __pyx_t_1;
15997       goto __pyx_L9_bool_binop_done;
15998     }
15999     __pyx_t_1 = ((__pyx_v_step == 0) != 0);
16000     __pyx_t_2 = __pyx_t_1;
16001     __pyx_L9_bool_binop_done:;
16002     if (__pyx_t_2) {
16003 
16004       /* "View.MemoryView":838
16005  *
16006  *         if have_step and step == 0:
16007  *             _err_dim(ValueError, "Step may not be zero (axis %d)", dim)             # <<<<<<<<<<<<<<
16008  *
16009  *
16010  */
16011       __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(2, 838, __pyx_L1_error)
16012 
16013       /* "View.MemoryView":837
16014  *         negative_step = have_step != 0 and step < 0
16015  *
16016  *         if have_step and step == 0:             # <<<<<<<<<<<<<<
16017  *             _err_dim(ValueError, "Step may not be zero (axis %d)", dim)
16018  *
16019  */
16020     }
16021 
16022     /* "View.MemoryView":841
16023  *
16024  *
16025  *         if have_start:             # <<<<<<<<<<<<<<
16026  *             if start < 0:
16027  *                 start += shape
16028  */
16029     __pyx_t_2 = (__pyx_v_have_start != 0);
16030     if (__pyx_t_2) {
16031 
16032       /* "View.MemoryView":842
16033  *
16034  *         if have_start:
16035  *             if start < 0:             # <<<<<<<<<<<<<<
16036  *                 start += shape
16037  *                 if start < 0:
16038  */
16039       __pyx_t_2 = ((__pyx_v_start < 0) != 0);
16040       if (__pyx_t_2) {
16041 
16042         /* "View.MemoryView":843
16043  *         if have_start:
16044  *             if start < 0:
16045  *                 start += shape             # <<<<<<<<<<<<<<
16046  *                 if start < 0:
16047  *                     start = 0
16048  */
16049         __pyx_v_start = (__pyx_v_start + __pyx_v_shape);
16050 
16051         /* "View.MemoryView":844
16052  *             if start < 0:
16053  *                 start += shape
16054  *                 if start < 0:             # <<<<<<<<<<<<<<
16055  *                     start = 0
16056  *             elif start >= shape:
16057  */
16058         __pyx_t_2 = ((__pyx_v_start < 0) != 0);
16059         if (__pyx_t_2) {
16060 
16061           /* "View.MemoryView":845
16062  *                 start += shape
16063  *                 if start < 0:
16064  *                     start = 0             # <<<<<<<<<<<<<<
16065  *             elif start >= shape:
16066  *                 if negative_step:
16067  */
16068           __pyx_v_start = 0;
16069 
16070           /* "View.MemoryView":844
16071  *             if start < 0:
16072  *                 start += shape
16073  *                 if start < 0:             # <<<<<<<<<<<<<<
16074  *                     start = 0
16075  *             elif start >= shape:
16076  */
16077         }
16078 
16079         /* "View.MemoryView":842
16080  *
16081  *         if have_start:
16082  *             if start < 0:             # <<<<<<<<<<<<<<
16083  *                 start += shape
16084  *                 if start < 0:
16085  */
16086         goto __pyx_L12;
16087       }
16088 
16089       /* "View.MemoryView":846
16090  *                 if start < 0:
16091  *                     start = 0
16092  *             elif start >= shape:             # <<<<<<<<<<<<<<
16093  *                 if negative_step:
16094  *                     start = shape - 1
16095  */
16096       __pyx_t_2 = ((__pyx_v_start >= __pyx_v_shape) != 0);
16097       if (__pyx_t_2) {
16098 
16099         /* "View.MemoryView":847
16100  *                     start = 0
16101  *             elif start >= shape:
16102  *                 if negative_step:             # <<<<<<<<<<<<<<
16103  *                     start = shape - 1
16104  *                 else:
16105  */
16106         __pyx_t_2 = (__pyx_v_negative_step != 0);
16107         if (__pyx_t_2) {
16108 
16109           /* "View.MemoryView":848
16110  *             elif start >= shape:
16111  *                 if negative_step:
16112  *                     start = shape - 1             # <<<<<<<<<<<<<<
16113  *                 else:
16114  *                     start = shape
16115  */
16116           __pyx_v_start = (__pyx_v_shape - 1);
16117 
16118           /* "View.MemoryView":847
16119  *                     start = 0
16120  *             elif start >= shape:
16121  *                 if negative_step:             # <<<<<<<<<<<<<<
16122  *                     start = shape - 1
16123  *                 else:
16124  */
16125           goto __pyx_L14;
16126         }
16127 
16128         /* "View.MemoryView":850
16129  *                     start = shape - 1
16130  *                 else:
16131  *                     start = shape             # <<<<<<<<<<<<<<
16132  *         else:
16133  *             if negative_step:
16134  */
16135         /*else*/ {
16136           __pyx_v_start = __pyx_v_shape;
16137         }
16138         __pyx_L14:;
16139 
16140         /* "View.MemoryView":846
16141  *                 if start < 0:
16142  *                     start = 0
16143  *             elif start >= shape:             # <<<<<<<<<<<<<<
16144  *                 if negative_step:
16145  *                     start = shape - 1
16146  */
16147       }
16148       __pyx_L12:;
16149 
16150       /* "View.MemoryView":841
16151  *
16152  *
16153  *         if have_start:             # <<<<<<<<<<<<<<
16154  *             if start < 0:
16155  *                 start += shape
16156  */
16157       goto __pyx_L11;
16158     }
16159 
16160     /* "View.MemoryView":852
16161  *                     start = shape
16162  *         else:
16163  *             if negative_step:             # <<<<<<<<<<<<<<
16164  *                 start = shape - 1
16165  *             else:
16166  */
16167     /*else*/ {
16168       __pyx_t_2 = (__pyx_v_negative_step != 0);
16169       if (__pyx_t_2) {
16170 
16171         /* "View.MemoryView":853
16172  *         else:
16173  *             if negative_step:
16174  *                 start = shape - 1             # <<<<<<<<<<<<<<
16175  *             else:
16176  *                 start = 0
16177  */
16178         __pyx_v_start = (__pyx_v_shape - 1);
16179 
16180         /* "View.MemoryView":852
16181  *                     start = shape
16182  *         else:
16183  *             if negative_step:             # <<<<<<<<<<<<<<
16184  *                 start = shape - 1
16185  *             else:
16186  */
16187         goto __pyx_L15;
16188       }
16189 
16190       /* "View.MemoryView":855
16191  *                 start = shape - 1
16192  *             else:
16193  *                 start = 0             # <<<<<<<<<<<<<<
16194  *
16195  *         if have_stop:
16196  */
16197       /*else*/ {
16198         __pyx_v_start = 0;
16199       }
16200       __pyx_L15:;
16201     }
16202     __pyx_L11:;
16203 
16204     /* "View.MemoryView":857
16205  *                 start = 0
16206  *
16207  *         if have_stop:             # <<<<<<<<<<<<<<
16208  *             if stop < 0:
16209  *                 stop += shape
16210  */
16211     __pyx_t_2 = (__pyx_v_have_stop != 0);
16212     if (__pyx_t_2) {
16213 
16214       /* "View.MemoryView":858
16215  *
16216  *         if have_stop:
16217  *             if stop < 0:             # <<<<<<<<<<<<<<
16218  *                 stop += shape
16219  *                 if stop < 0:
16220  */
16221       __pyx_t_2 = ((__pyx_v_stop < 0) != 0);
16222       if (__pyx_t_2) {
16223 
16224         /* "View.MemoryView":859
16225  *         if have_stop:
16226  *             if stop < 0:
16227  *                 stop += shape             # <<<<<<<<<<<<<<
16228  *                 if stop < 0:
16229  *                     stop = 0
16230  */
16231         __pyx_v_stop = (__pyx_v_stop + __pyx_v_shape);
16232 
16233         /* "View.MemoryView":860
16234  *             if stop < 0:
16235  *                 stop += shape
16236  *                 if stop < 0:             # <<<<<<<<<<<<<<
16237  *                     stop = 0
16238  *             elif stop > shape:
16239  */
16240         __pyx_t_2 = ((__pyx_v_stop < 0) != 0);
16241         if (__pyx_t_2) {
16242 
16243           /* "View.MemoryView":861
16244  *                 stop += shape
16245  *                 if stop < 0:
16246  *                     stop = 0             # <<<<<<<<<<<<<<
16247  *             elif stop > shape:
16248  *                 stop = shape
16249  */
16250           __pyx_v_stop = 0;
16251 
16252           /* "View.MemoryView":860
16253  *             if stop < 0:
16254  *                 stop += shape
16255  *                 if stop < 0:             # <<<<<<<<<<<<<<
16256  *                     stop = 0
16257  *             elif stop > shape:
16258  */
16259         }
16260 
16261         /* "View.MemoryView":858
16262  *
16263  *         if have_stop:
16264  *             if stop < 0:             # <<<<<<<<<<<<<<
16265  *                 stop += shape
16266  *                 if stop < 0:
16267  */
16268         goto __pyx_L17;
16269       }
16270 
16271       /* "View.MemoryView":862
16272  *                 if stop < 0:
16273  *                     stop = 0
16274  *             elif stop > shape:             # <<<<<<<<<<<<<<
16275  *                 stop = shape
16276  *         else:
16277  */
16278       __pyx_t_2 = ((__pyx_v_stop > __pyx_v_shape) != 0);
16279       if (__pyx_t_2) {
16280 
16281         /* "View.MemoryView":863
16282  *                     stop = 0
16283  *             elif stop > shape:
16284  *                 stop = shape             # <<<<<<<<<<<<<<
16285  *         else:
16286  *             if negative_step:
16287  */
16288         __pyx_v_stop = __pyx_v_shape;
16289 
16290         /* "View.MemoryView":862
16291  *                 if stop < 0:
16292  *                     stop = 0
16293  *             elif stop > shape:             # <<<<<<<<<<<<<<
16294  *                 stop = shape
16295  *         else:
16296  */
16297       }
16298       __pyx_L17:;
16299 
16300       /* "View.MemoryView":857
16301  *                 start = 0
16302  *
16303  *         if have_stop:             # <<<<<<<<<<<<<<
16304  *             if stop < 0:
16305  *                 stop += shape
16306  */
16307       goto __pyx_L16;
16308     }
16309 
16310     /* "View.MemoryView":865
16311  *                 stop = shape
16312  *         else:
16313  *             if negative_step:             # <<<<<<<<<<<<<<
16314  *                 stop = -1
16315  *             else:
16316  */
16317     /*else*/ {
16318       __pyx_t_2 = (__pyx_v_negative_step != 0);
16319       if (__pyx_t_2) {
16320 
16321         /* "View.MemoryView":866
16322  *         else:
16323  *             if negative_step:
16324  *                 stop = -1             # <<<<<<<<<<<<<<
16325  *             else:
16326  *                 stop = shape
16327  */
16328         __pyx_v_stop = -1L;
16329 
16330         /* "View.MemoryView":865
16331  *                 stop = shape
16332  *         else:
16333  *             if negative_step:             # <<<<<<<<<<<<<<
16334  *                 stop = -1
16335  *             else:
16336  */
16337         goto __pyx_L19;
16338       }
16339 
16340       /* "View.MemoryView":868
16341  *                 stop = -1
16342  *             else:
16343  *                 stop = shape             # <<<<<<<<<<<<<<
16344  *
16345  *         if not have_step:
16346  */
16347       /*else*/ {
16348         __pyx_v_stop = __pyx_v_shape;
16349       }
16350       __pyx_L19:;
16351     }
16352     __pyx_L16:;
16353 
16354     /* "View.MemoryView":870
16355  *                 stop = shape
16356  *
16357  *         if not have_step:             # <<<<<<<<<<<<<<
16358  *             step = 1
16359  *
16360  */
16361     __pyx_t_2 = ((!(__pyx_v_have_step != 0)) != 0);
16362     if (__pyx_t_2) {
16363 
16364       /* "View.MemoryView":871
16365  *
16366  *         if not have_step:
16367  *             step = 1             # <<<<<<<<<<<<<<
16368  *
16369  *
16370  */
16371       __pyx_v_step = 1;
16372 
16373       /* "View.MemoryView":870
16374  *                 stop = shape
16375  *
16376  *         if not have_step:             # <<<<<<<<<<<<<<
16377  *             step = 1
16378  *
16379  */
16380     }
16381 
16382     /* "View.MemoryView":875
16383  *
16384  *         with cython.cdivision(True):
16385  *             new_shape = (stop - start) // step             # <<<<<<<<<<<<<<
16386  *
16387  *             if (stop - start) - step * new_shape:
16388  */
16389     __pyx_v_new_shape = ((__pyx_v_stop - __pyx_v_start) / __pyx_v_step);
16390 
16391     /* "View.MemoryView":877
16392  *             new_shape = (stop - start) // step
16393  *
16394  *             if (stop - start) - step * new_shape:             # <<<<<<<<<<<<<<
16395  *                 new_shape += 1
16396  *
16397  */
16398     __pyx_t_2 = (((__pyx_v_stop - __pyx_v_start) - (__pyx_v_step * __pyx_v_new_shape)) != 0);
16399     if (__pyx_t_2) {
16400 
16401       /* "View.MemoryView":878
16402  *
16403  *             if (stop - start) - step * new_shape:
16404  *                 new_shape += 1             # <<<<<<<<<<<<<<
16405  *
16406  *         if new_shape < 0:
16407  */
16408       __pyx_v_new_shape = (__pyx_v_new_shape + 1);
16409 
16410       /* "View.MemoryView":877
16411  *             new_shape = (stop - start) // step
16412  *
16413  *             if (stop - start) - step * new_shape:             # <<<<<<<<<<<<<<
16414  *                 new_shape += 1
16415  *
16416  */
16417     }
16418 
16419     /* "View.MemoryView":880
16420  *                 new_shape += 1
16421  *
16422  *         if new_shape < 0:             # <<<<<<<<<<<<<<
16423  *             new_shape = 0
16424  *
16425  */
16426     __pyx_t_2 = ((__pyx_v_new_shape < 0) != 0);
16427     if (__pyx_t_2) {
16428 
16429       /* "View.MemoryView":881
16430  *
16431  *         if new_shape < 0:
16432  *             new_shape = 0             # <<<<<<<<<<<<<<
16433  *
16434  *
16435  */
16436       __pyx_v_new_shape = 0;
16437 
16438       /* "View.MemoryView":880
16439  *                 new_shape += 1
16440  *
16441  *         if new_shape < 0:             # <<<<<<<<<<<<<<
16442  *             new_shape = 0
16443  *
16444  */
16445     }
16446 
16447     /* "View.MemoryView":884
16448  *
16449  *
16450  *         dst.strides[new_ndim] = stride * step             # <<<<<<<<<<<<<<
16451  *         dst.shape[new_ndim] = new_shape
16452  *         dst.suboffsets[new_ndim] = suboffset
16453  */
16454     (__pyx_v_dst->strides[__pyx_v_new_ndim]) = (__pyx_v_stride * __pyx_v_step);
16455 
16456     /* "View.MemoryView":885
16457  *
16458  *         dst.strides[new_ndim] = stride * step
16459  *         dst.shape[new_ndim] = new_shape             # <<<<<<<<<<<<<<
16460  *         dst.suboffsets[new_ndim] = suboffset
16461  *
16462  */
16463     (__pyx_v_dst->shape[__pyx_v_new_ndim]) = __pyx_v_new_shape;
16464 
16465     /* "View.MemoryView":886
16466  *         dst.strides[new_ndim] = stride * step
16467  *         dst.shape[new_ndim] = new_shape
16468  *         dst.suboffsets[new_ndim] = suboffset             # <<<<<<<<<<<<<<
16469  *
16470  *
16471  */
16472     (__pyx_v_dst->suboffsets[__pyx_v_new_ndim]) = __pyx_v_suboffset;
16473   }
16474   __pyx_L3:;
16475 
16476   /* "View.MemoryView":889
16477  *
16478  *
16479  *     if suboffset_dim[0] < 0:             # <<<<<<<<<<<<<<
16480  *         dst.data += start * stride
16481  *     else:
16482  */
16483   __pyx_t_2 = (((__pyx_v_suboffset_dim[0]) < 0) != 0);
16484   if (__pyx_t_2) {
16485 
16486     /* "View.MemoryView":890
16487  *
16488  *     if suboffset_dim[0] < 0:
16489  *         dst.data += start * stride             # <<<<<<<<<<<<<<
16490  *     else:
16491  *         dst.suboffsets[suboffset_dim[0]] += start * stride
16492  */
16493     __pyx_v_dst->data = (__pyx_v_dst->data + (__pyx_v_start * __pyx_v_stride));
16494 
16495     /* "View.MemoryView":889
16496  *
16497  *
16498  *     if suboffset_dim[0] < 0:             # <<<<<<<<<<<<<<
16499  *         dst.data += start * stride
16500  *     else:
16501  */
16502     goto __pyx_L23;
16503   }
16504 
16505   /* "View.MemoryView":892
16506  *         dst.data += start * stride
16507  *     else:
16508  *         dst.suboffsets[suboffset_dim[0]] += start * stride             # <<<<<<<<<<<<<<
16509  *
16510  *     if suboffset >= 0:
16511  */
16512   /*else*/ {
16513     __pyx_t_3 = (__pyx_v_suboffset_dim[0]);
16514     (__pyx_v_dst->suboffsets[__pyx_t_3]) = ((__pyx_v_dst->suboffsets[__pyx_t_3]) + (__pyx_v_start * __pyx_v_stride));
16515   }
16516   __pyx_L23:;
16517 
16518   /* "View.MemoryView":894
16519  *         dst.suboffsets[suboffset_dim[0]] += start * stride
16520  *
16521  *     if suboffset >= 0:             # <<<<<<<<<<<<<<
16522  *         if not is_slice:
16523  *             if new_ndim == 0:
16524  */
16525   __pyx_t_2 = ((__pyx_v_suboffset >= 0) != 0);
16526   if (__pyx_t_2) {
16527 
16528     /* "View.MemoryView":895
16529  *
16530  *     if suboffset >= 0:
16531  *         if not is_slice:             # <<<<<<<<<<<<<<
16532  *             if new_ndim == 0:
16533  *                 dst.data = (<char **> dst.data)[0] + suboffset
16534  */
16535     __pyx_t_2 = ((!(__pyx_v_is_slice != 0)) != 0);
16536     if (__pyx_t_2) {
16537 
16538       /* "View.MemoryView":896
16539  *     if suboffset >= 0:
16540  *         if not is_slice:
16541  *             if new_ndim == 0:             # <<<<<<<<<<<<<<
16542  *                 dst.data = (<char **> dst.data)[0] + suboffset
16543  *             else:
16544  */
16545       __pyx_t_2 = ((__pyx_v_new_ndim == 0) != 0);
16546       if (__pyx_t_2) {
16547 
16548         /* "View.MemoryView":897
16549  *         if not is_slice:
16550  *             if new_ndim == 0:
16551  *                 dst.data = (<char **> dst.data)[0] + suboffset             # <<<<<<<<<<<<<<
16552  *             else:
16553  *                 _err_dim(IndexError, "All dimensions preceding dimension %d "
16554  */
16555         __pyx_v_dst->data = ((((char **)__pyx_v_dst->data)[0]) + __pyx_v_suboffset);
16556 
16557         /* "View.MemoryView":896
16558  *     if suboffset >= 0:
16559  *         if not is_slice:
16560  *             if new_ndim == 0:             # <<<<<<<<<<<<<<
16561  *                 dst.data = (<char **> dst.data)[0] + suboffset
16562  *             else:
16563  */
16564         goto __pyx_L26;
16565       }
16566 
16567       /* "View.MemoryView":899
16568  *                 dst.data = (<char **> dst.data)[0] + suboffset
16569  *             else:
16570  *                 _err_dim(IndexError, "All dimensions preceding dimension %d "             # <<<<<<<<<<<<<<
16571  *                                      "must be indexed and not sliced", dim)
16572  *         else:
16573  */
16574       /*else*/ {
16575 
16576         /* "View.MemoryView":900
16577  *             else:
16578  *                 _err_dim(IndexError, "All dimensions preceding dimension %d "
16579  *                                      "must be indexed and not sliced", dim)             # <<<<<<<<<<<<<<
16580  *         else:
16581  *             suboffset_dim[0] = new_ndim
16582  */
16583         __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(2, 899, __pyx_L1_error)
16584       }
16585       __pyx_L26:;
16586 
16587       /* "View.MemoryView":895
16588  *
16589  *     if suboffset >= 0:
16590  *         if not is_slice:             # <<<<<<<<<<<<<<
16591  *             if new_ndim == 0:
16592  *                 dst.data = (<char **> dst.data)[0] + suboffset
16593  */
16594       goto __pyx_L25;
16595     }
16596 
16597     /* "View.MemoryView":902
16598  *                                      "must be indexed and not sliced", dim)
16599  *         else:
16600  *             suboffset_dim[0] = new_ndim             # <<<<<<<<<<<<<<
16601  *
16602  *     return 0
16603  */
16604     /*else*/ {
16605       (__pyx_v_suboffset_dim[0]) = __pyx_v_new_ndim;
16606     }
16607     __pyx_L25:;
16608 
16609     /* "View.MemoryView":894
16610  *         dst.suboffsets[suboffset_dim[0]] += start * stride
16611  *
16612  *     if suboffset >= 0:             # <<<<<<<<<<<<<<
16613  *         if not is_slice:
16614  *             if new_ndim == 0:
16615  */
16616   }
16617 
16618   /* "View.MemoryView":904
16619  *             suboffset_dim[0] = new_ndim
16620  *
16621  *     return 0             # <<<<<<<<<<<<<<
16622  *
16623  *
16624  */
16625   __pyx_r = 0;
16626   goto __pyx_L0;
16627 
16628   /* "View.MemoryView":807
16629  *
16630  * @cname('__pyx_memoryview_slice_memviewslice')
16631  * cdef int slice_memviewslice(             # <<<<<<<<<<<<<<
16632  *         __Pyx_memviewslice *dst,
16633  *         Py_ssize_t shape, Py_ssize_t stride, Py_ssize_t suboffset,
16634  */
16635 
16636   /* function exit code */
16637   __pyx_L1_error:;
16638   {
16639     #ifdef WITH_THREAD
16640     PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure();
16641     #endif
16642     __Pyx_AddTraceback("View.MemoryView.slice_memviewslice", __pyx_clineno, __pyx_lineno, __pyx_filename);
16643     #ifdef WITH_THREAD
16644     __Pyx_PyGILState_Release(__pyx_gilstate_save);
16645     #endif
16646   }
16647   __pyx_r = -1;
16648   __pyx_L0:;
16649   return __pyx_r;
16650 }
16651 
16652 /* "View.MemoryView":910
16653  *
16654  * @cname('__pyx_pybuffer_index')
16655  * cdef char *pybuffer_index(Py_buffer *view, char *bufp, Py_ssize_t index,             # <<<<<<<<<<<<<<
16656  *                           Py_ssize_t dim) except NULL:
16657  *     cdef Py_ssize_t shape, stride, suboffset = -1
16658  */
16659 
__pyx_pybuffer_index(Py_buffer * __pyx_v_view,char * __pyx_v_bufp,Py_ssize_t __pyx_v_index,Py_ssize_t __pyx_v_dim)16660 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) {
16661   Py_ssize_t __pyx_v_shape;
16662   Py_ssize_t __pyx_v_stride;
16663   Py_ssize_t __pyx_v_suboffset;
16664   Py_ssize_t __pyx_v_itemsize;
16665   char *__pyx_v_resultp;
16666   char *__pyx_r;
16667   __Pyx_RefNannyDeclarations
16668   Py_ssize_t __pyx_t_1;
16669   int __pyx_t_2;
16670   PyObject *__pyx_t_3 = NULL;
16671   PyObject *__pyx_t_4 = NULL;
16672   int __pyx_lineno = 0;
16673   const char *__pyx_filename = NULL;
16674   int __pyx_clineno = 0;
16675   __Pyx_RefNannySetupContext("pybuffer_index", 0);
16676 
16677   /* "View.MemoryView":912
16678  * cdef char *pybuffer_index(Py_buffer *view, char *bufp, Py_ssize_t index,
16679  *                           Py_ssize_t dim) except NULL:
16680  *     cdef Py_ssize_t shape, stride, suboffset = -1             # <<<<<<<<<<<<<<
16681  *     cdef Py_ssize_t itemsize = view.itemsize
16682  *     cdef char *resultp
16683  */
16684   __pyx_v_suboffset = -1L;
16685 
16686   /* "View.MemoryView":913
16687  *                           Py_ssize_t dim) except NULL:
16688  *     cdef Py_ssize_t shape, stride, suboffset = -1
16689  *     cdef Py_ssize_t itemsize = view.itemsize             # <<<<<<<<<<<<<<
16690  *     cdef char *resultp
16691  *
16692  */
16693   __pyx_t_1 = __pyx_v_view->itemsize;
16694   __pyx_v_itemsize = __pyx_t_1;
16695 
16696   /* "View.MemoryView":916
16697  *     cdef char *resultp
16698  *
16699  *     if view.ndim == 0:             # <<<<<<<<<<<<<<
16700  *         shape = view.len / itemsize
16701  *         stride = itemsize
16702  */
16703   __pyx_t_2 = ((__pyx_v_view->ndim == 0) != 0);
16704   if (__pyx_t_2) {
16705 
16706     /* "View.MemoryView":917
16707  *
16708  *     if view.ndim == 0:
16709  *         shape = view.len / itemsize             # <<<<<<<<<<<<<<
16710  *         stride = itemsize
16711  *     else:
16712  */
16713     if (unlikely(__pyx_v_itemsize == 0)) {
16714       PyErr_SetString(PyExc_ZeroDivisionError, "integer division or modulo by zero");
16715       __PYX_ERR(2, 917, __pyx_L1_error)
16716     }
16717     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))) {
16718       PyErr_SetString(PyExc_OverflowError, "value too large to perform division");
16719       __PYX_ERR(2, 917, __pyx_L1_error)
16720     }
16721     __pyx_v_shape = __Pyx_div_Py_ssize_t(__pyx_v_view->len, __pyx_v_itemsize);
16722 
16723     /* "View.MemoryView":918
16724  *     if view.ndim == 0:
16725  *         shape = view.len / itemsize
16726  *         stride = itemsize             # <<<<<<<<<<<<<<
16727  *     else:
16728  *         shape = view.shape[dim]
16729  */
16730     __pyx_v_stride = __pyx_v_itemsize;
16731 
16732     /* "View.MemoryView":916
16733  *     cdef char *resultp
16734  *
16735  *     if view.ndim == 0:             # <<<<<<<<<<<<<<
16736  *         shape = view.len / itemsize
16737  *         stride = itemsize
16738  */
16739     goto __pyx_L3;
16740   }
16741 
16742   /* "View.MemoryView":920
16743  *         stride = itemsize
16744  *     else:
16745  *         shape = view.shape[dim]             # <<<<<<<<<<<<<<
16746  *         stride = view.strides[dim]
16747  *         if view.suboffsets != NULL:
16748  */
16749   /*else*/ {
16750     __pyx_v_shape = (__pyx_v_view->shape[__pyx_v_dim]);
16751 
16752     /* "View.MemoryView":921
16753  *     else:
16754  *         shape = view.shape[dim]
16755  *         stride = view.strides[dim]             # <<<<<<<<<<<<<<
16756  *         if view.suboffsets != NULL:
16757  *             suboffset = view.suboffsets[dim]
16758  */
16759     __pyx_v_stride = (__pyx_v_view->strides[__pyx_v_dim]);
16760 
16761     /* "View.MemoryView":922
16762  *         shape = view.shape[dim]
16763  *         stride = view.strides[dim]
16764  *         if view.suboffsets != NULL:             # <<<<<<<<<<<<<<
16765  *             suboffset = view.suboffsets[dim]
16766  *
16767  */
16768     __pyx_t_2 = ((__pyx_v_view->suboffsets != NULL) != 0);
16769     if (__pyx_t_2) {
16770 
16771       /* "View.MemoryView":923
16772  *         stride = view.strides[dim]
16773  *         if view.suboffsets != NULL:
16774  *             suboffset = view.suboffsets[dim]             # <<<<<<<<<<<<<<
16775  *
16776  *     if index < 0:
16777  */
16778       __pyx_v_suboffset = (__pyx_v_view->suboffsets[__pyx_v_dim]);
16779 
16780       /* "View.MemoryView":922
16781  *         shape = view.shape[dim]
16782  *         stride = view.strides[dim]
16783  *         if view.suboffsets != NULL:             # <<<<<<<<<<<<<<
16784  *             suboffset = view.suboffsets[dim]
16785  *
16786  */
16787     }
16788   }
16789   __pyx_L3:;
16790 
16791   /* "View.MemoryView":925
16792  *             suboffset = view.suboffsets[dim]
16793  *
16794  *     if index < 0:             # <<<<<<<<<<<<<<
16795  *         index += view.shape[dim]
16796  *         if index < 0:
16797  */
16798   __pyx_t_2 = ((__pyx_v_index < 0) != 0);
16799   if (__pyx_t_2) {
16800 
16801     /* "View.MemoryView":926
16802  *
16803  *     if index < 0:
16804  *         index += view.shape[dim]             # <<<<<<<<<<<<<<
16805  *         if index < 0:
16806  *             raise IndexError("Out of bounds on buffer access (axis %d)" % dim)
16807  */
16808     __pyx_v_index = (__pyx_v_index + (__pyx_v_view->shape[__pyx_v_dim]));
16809 
16810     /* "View.MemoryView":927
16811  *     if index < 0:
16812  *         index += view.shape[dim]
16813  *         if index < 0:             # <<<<<<<<<<<<<<
16814  *             raise IndexError("Out of bounds on buffer access (axis %d)" % dim)
16815  *
16816  */
16817     __pyx_t_2 = ((__pyx_v_index < 0) != 0);
16818     if (unlikely(__pyx_t_2)) {
16819 
16820       /* "View.MemoryView":928
16821  *         index += view.shape[dim]
16822  *         if index < 0:
16823  *             raise IndexError("Out of bounds on buffer access (axis %d)" % dim)             # <<<<<<<<<<<<<<
16824  *
16825  *     if index >= shape:
16826  */
16827       __pyx_t_3 = PyInt_FromSsize_t(__pyx_v_dim); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 928, __pyx_L1_error)
16828       __Pyx_GOTREF(__pyx_t_3);
16829       __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(2, 928, __pyx_L1_error)
16830       __Pyx_GOTREF(__pyx_t_4);
16831       __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
16832       __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_builtin_IndexError, __pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 928, __pyx_L1_error)
16833       __Pyx_GOTREF(__pyx_t_3);
16834       __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
16835       __Pyx_Raise(__pyx_t_3, 0, 0, 0);
16836       __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
16837       __PYX_ERR(2, 928, __pyx_L1_error)
16838 
16839       /* "View.MemoryView":927
16840  *     if index < 0:
16841  *         index += view.shape[dim]
16842  *         if index < 0:             # <<<<<<<<<<<<<<
16843  *             raise IndexError("Out of bounds on buffer access (axis %d)" % dim)
16844  *
16845  */
16846     }
16847 
16848     /* "View.MemoryView":925
16849  *             suboffset = view.suboffsets[dim]
16850  *
16851  *     if index < 0:             # <<<<<<<<<<<<<<
16852  *         index += view.shape[dim]
16853  *         if index < 0:
16854  */
16855   }
16856 
16857   /* "View.MemoryView":930
16858  *             raise IndexError("Out of bounds on buffer access (axis %d)" % dim)
16859  *
16860  *     if index >= shape:             # <<<<<<<<<<<<<<
16861  *         raise IndexError("Out of bounds on buffer access (axis %d)" % dim)
16862  *
16863  */
16864   __pyx_t_2 = ((__pyx_v_index >= __pyx_v_shape) != 0);
16865   if (unlikely(__pyx_t_2)) {
16866 
16867     /* "View.MemoryView":931
16868  *
16869  *     if index >= shape:
16870  *         raise IndexError("Out of bounds on buffer access (axis %d)" % dim)             # <<<<<<<<<<<<<<
16871  *
16872  *     resultp = bufp + index * stride
16873  */
16874     __pyx_t_3 = PyInt_FromSsize_t(__pyx_v_dim); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 931, __pyx_L1_error)
16875     __Pyx_GOTREF(__pyx_t_3);
16876     __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(2, 931, __pyx_L1_error)
16877     __Pyx_GOTREF(__pyx_t_4);
16878     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
16879     __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_builtin_IndexError, __pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 931, __pyx_L1_error)
16880     __Pyx_GOTREF(__pyx_t_3);
16881     __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
16882     __Pyx_Raise(__pyx_t_3, 0, 0, 0);
16883     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
16884     __PYX_ERR(2, 931, __pyx_L1_error)
16885 
16886     /* "View.MemoryView":930
16887  *             raise IndexError("Out of bounds on buffer access (axis %d)" % dim)
16888  *
16889  *     if index >= shape:             # <<<<<<<<<<<<<<
16890  *         raise IndexError("Out of bounds on buffer access (axis %d)" % dim)
16891  *
16892  */
16893   }
16894 
16895   /* "View.MemoryView":933
16896  *         raise IndexError("Out of bounds on buffer access (axis %d)" % dim)
16897  *
16898  *     resultp = bufp + index * stride             # <<<<<<<<<<<<<<
16899  *     if suboffset >= 0:
16900  *         resultp = (<char **> resultp)[0] + suboffset
16901  */
16902   __pyx_v_resultp = (__pyx_v_bufp + (__pyx_v_index * __pyx_v_stride));
16903 
16904   /* "View.MemoryView":934
16905  *
16906  *     resultp = bufp + index * stride
16907  *     if suboffset >= 0:             # <<<<<<<<<<<<<<
16908  *         resultp = (<char **> resultp)[0] + suboffset
16909  *
16910  */
16911   __pyx_t_2 = ((__pyx_v_suboffset >= 0) != 0);
16912   if (__pyx_t_2) {
16913 
16914     /* "View.MemoryView":935
16915  *     resultp = bufp + index * stride
16916  *     if suboffset >= 0:
16917  *         resultp = (<char **> resultp)[0] + suboffset             # <<<<<<<<<<<<<<
16918  *
16919  *     return resultp
16920  */
16921     __pyx_v_resultp = ((((char **)__pyx_v_resultp)[0]) + __pyx_v_suboffset);
16922 
16923     /* "View.MemoryView":934
16924  *
16925  *     resultp = bufp + index * stride
16926  *     if suboffset >= 0:             # <<<<<<<<<<<<<<
16927  *         resultp = (<char **> resultp)[0] + suboffset
16928  *
16929  */
16930   }
16931 
16932   /* "View.MemoryView":937
16933  *         resultp = (<char **> resultp)[0] + suboffset
16934  *
16935  *     return resultp             # <<<<<<<<<<<<<<
16936  *
16937  *
16938  */
16939   __pyx_r = __pyx_v_resultp;
16940   goto __pyx_L0;
16941 
16942   /* "View.MemoryView":910
16943  *
16944  * @cname('__pyx_pybuffer_index')
16945  * cdef char *pybuffer_index(Py_buffer *view, char *bufp, Py_ssize_t index,             # <<<<<<<<<<<<<<
16946  *                           Py_ssize_t dim) except NULL:
16947  *     cdef Py_ssize_t shape, stride, suboffset = -1
16948  */
16949 
16950   /* function exit code */
16951   __pyx_L1_error:;
16952   __Pyx_XDECREF(__pyx_t_3);
16953   __Pyx_XDECREF(__pyx_t_4);
16954   __Pyx_AddTraceback("View.MemoryView.pybuffer_index", __pyx_clineno, __pyx_lineno, __pyx_filename);
16955   __pyx_r = NULL;
16956   __pyx_L0:;
16957   __Pyx_RefNannyFinishContext();
16958   return __pyx_r;
16959 }
16960 
16961 /* "View.MemoryView":943
16962  *
16963  * @cname('__pyx_memslice_transpose')
16964  * cdef int transpose_memslice(__Pyx_memviewslice *memslice) nogil except 0:             # <<<<<<<<<<<<<<
16965  *     cdef int ndim = memslice.memview.view.ndim
16966  *
16967  */
16968 
__pyx_memslice_transpose(__Pyx_memviewslice * __pyx_v_memslice)16969 static int __pyx_memslice_transpose(__Pyx_memviewslice *__pyx_v_memslice) {
16970   int __pyx_v_ndim;
16971   Py_ssize_t *__pyx_v_shape;
16972   Py_ssize_t *__pyx_v_strides;
16973   int __pyx_v_i;
16974   int __pyx_v_j;
16975   int __pyx_r;
16976   int __pyx_t_1;
16977   Py_ssize_t *__pyx_t_2;
16978   long __pyx_t_3;
16979   long __pyx_t_4;
16980   Py_ssize_t __pyx_t_5;
16981   Py_ssize_t __pyx_t_6;
16982   int __pyx_t_7;
16983   int __pyx_t_8;
16984   int __pyx_t_9;
16985   int __pyx_lineno = 0;
16986   const char *__pyx_filename = NULL;
16987   int __pyx_clineno = 0;
16988 
16989   /* "View.MemoryView":944
16990  * @cname('__pyx_memslice_transpose')
16991  * cdef int transpose_memslice(__Pyx_memviewslice *memslice) nogil except 0:
16992  *     cdef int ndim = memslice.memview.view.ndim             # <<<<<<<<<<<<<<
16993  *
16994  *     cdef Py_ssize_t *shape = memslice.shape
16995  */
16996   __pyx_t_1 = __pyx_v_memslice->memview->view.ndim;
16997   __pyx_v_ndim = __pyx_t_1;
16998 
16999   /* "View.MemoryView":946
17000  *     cdef int ndim = memslice.memview.view.ndim
17001  *
17002  *     cdef Py_ssize_t *shape = memslice.shape             # <<<<<<<<<<<<<<
17003  *     cdef Py_ssize_t *strides = memslice.strides
17004  *
17005  */
17006   __pyx_t_2 = __pyx_v_memslice->shape;
17007   __pyx_v_shape = __pyx_t_2;
17008 
17009   /* "View.MemoryView":947
17010  *
17011  *     cdef Py_ssize_t *shape = memslice.shape
17012  *     cdef Py_ssize_t *strides = memslice.strides             # <<<<<<<<<<<<<<
17013  *
17014  *
17015  */
17016   __pyx_t_2 = __pyx_v_memslice->strides;
17017   __pyx_v_strides = __pyx_t_2;
17018 
17019   /* "View.MemoryView":951
17020  *
17021  *     cdef int i, j
17022  *     for i in range(ndim / 2):             # <<<<<<<<<<<<<<
17023  *         j = ndim - 1 - i
17024  *         strides[i], strides[j] = strides[j], strides[i]
17025  */
17026   __pyx_t_3 = __Pyx_div_long(__pyx_v_ndim, 2);
17027   __pyx_t_4 = __pyx_t_3;
17028   for (__pyx_t_1 = 0; __pyx_t_1 < __pyx_t_4; __pyx_t_1+=1) {
17029     __pyx_v_i = __pyx_t_1;
17030 
17031     /* "View.MemoryView":952
17032  *     cdef int i, j
17033  *     for i in range(ndim / 2):
17034  *         j = ndim - 1 - i             # <<<<<<<<<<<<<<
17035  *         strides[i], strides[j] = strides[j], strides[i]
17036  *         shape[i], shape[j] = shape[j], shape[i]
17037  */
17038     __pyx_v_j = ((__pyx_v_ndim - 1) - __pyx_v_i);
17039 
17040     /* "View.MemoryView":953
17041  *     for i in range(ndim / 2):
17042  *         j = ndim - 1 - i
17043  *         strides[i], strides[j] = strides[j], strides[i]             # <<<<<<<<<<<<<<
17044  *         shape[i], shape[j] = shape[j], shape[i]
17045  *
17046  */
17047     __pyx_t_5 = (__pyx_v_strides[__pyx_v_j]);
17048     __pyx_t_6 = (__pyx_v_strides[__pyx_v_i]);
17049     (__pyx_v_strides[__pyx_v_i]) = __pyx_t_5;
17050     (__pyx_v_strides[__pyx_v_j]) = __pyx_t_6;
17051 
17052     /* "View.MemoryView":954
17053  *         j = ndim - 1 - i
17054  *         strides[i], strides[j] = strides[j], strides[i]
17055  *         shape[i], shape[j] = shape[j], shape[i]             # <<<<<<<<<<<<<<
17056  *
17057  *         if memslice.suboffsets[i] >= 0 or memslice.suboffsets[j] >= 0:
17058  */
17059     __pyx_t_6 = (__pyx_v_shape[__pyx_v_j]);
17060     __pyx_t_5 = (__pyx_v_shape[__pyx_v_i]);
17061     (__pyx_v_shape[__pyx_v_i]) = __pyx_t_6;
17062     (__pyx_v_shape[__pyx_v_j]) = __pyx_t_5;
17063 
17064     /* "View.MemoryView":956
17065  *         shape[i], shape[j] = shape[j], shape[i]
17066  *
17067  *         if memslice.suboffsets[i] >= 0 or memslice.suboffsets[j] >= 0:             # <<<<<<<<<<<<<<
17068  *             _err(ValueError, "Cannot transpose memoryview with indirect dimensions")
17069  *
17070  */
17071     __pyx_t_8 = (((__pyx_v_memslice->suboffsets[__pyx_v_i]) >= 0) != 0);
17072     if (!__pyx_t_8) {
17073     } else {
17074       __pyx_t_7 = __pyx_t_8;
17075       goto __pyx_L6_bool_binop_done;
17076     }
17077     __pyx_t_8 = (((__pyx_v_memslice->suboffsets[__pyx_v_j]) >= 0) != 0);
17078     __pyx_t_7 = __pyx_t_8;
17079     __pyx_L6_bool_binop_done:;
17080     if (__pyx_t_7) {
17081 
17082       /* "View.MemoryView":957
17083  *
17084  *         if memslice.suboffsets[i] >= 0 or memslice.suboffsets[j] >= 0:
17085  *             _err(ValueError, "Cannot transpose memoryview with indirect dimensions")             # <<<<<<<<<<<<<<
17086  *
17087  *     return 1
17088  */
17089       __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(2, 957, __pyx_L1_error)
17090 
17091       /* "View.MemoryView":956
17092  *         shape[i], shape[j] = shape[j], shape[i]
17093  *
17094  *         if memslice.suboffsets[i] >= 0 or memslice.suboffsets[j] >= 0:             # <<<<<<<<<<<<<<
17095  *             _err(ValueError, "Cannot transpose memoryview with indirect dimensions")
17096  *
17097  */
17098     }
17099   }
17100 
17101   /* "View.MemoryView":959
17102  *             _err(ValueError, "Cannot transpose memoryview with indirect dimensions")
17103  *
17104  *     return 1             # <<<<<<<<<<<<<<
17105  *
17106  *
17107  */
17108   __pyx_r = 1;
17109   goto __pyx_L0;
17110 
17111   /* "View.MemoryView":943
17112  *
17113  * @cname('__pyx_memslice_transpose')
17114  * cdef int transpose_memslice(__Pyx_memviewslice *memslice) nogil except 0:             # <<<<<<<<<<<<<<
17115  *     cdef int ndim = memslice.memview.view.ndim
17116  *
17117  */
17118 
17119   /* function exit code */
17120   __pyx_L1_error:;
17121   {
17122     #ifdef WITH_THREAD
17123     PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure();
17124     #endif
17125     __Pyx_AddTraceback("View.MemoryView.transpose_memslice", __pyx_clineno, __pyx_lineno, __pyx_filename);
17126     #ifdef WITH_THREAD
17127     __Pyx_PyGILState_Release(__pyx_gilstate_save);
17128     #endif
17129   }
17130   __pyx_r = 0;
17131   __pyx_L0:;
17132   return __pyx_r;
17133 }
17134 
17135 /* "View.MemoryView":976
17136  *     cdef int (*to_dtype_func)(char *, object) except 0
17137  *
17138  *     def __dealloc__(self):             # <<<<<<<<<<<<<<
17139  *         __PYX_XDEC_MEMVIEW(&self.from_slice, 1)
17140  *
17141  */
17142 
17143 /* Python wrapper */
17144 static void __pyx_memoryviewslice___dealloc__(PyObject *__pyx_v_self); /*proto*/
__pyx_memoryviewslice___dealloc__(PyObject * __pyx_v_self)17145 static void __pyx_memoryviewslice___dealloc__(PyObject *__pyx_v_self) {
17146   __Pyx_RefNannyDeclarations
17147   __Pyx_RefNannySetupContext("__dealloc__ (wrapper)", 0);
17148   __pyx_memoryviewslice___pyx_pf_15View_dot_MemoryView_16_memoryviewslice___dealloc__(((struct __pyx_memoryviewslice_obj *)__pyx_v_self));
17149 
17150   /* function exit code */
17151   __Pyx_RefNannyFinishContext();
17152 }
17153 
__pyx_memoryviewslice___pyx_pf_15View_dot_MemoryView_16_memoryviewslice___dealloc__(struct __pyx_memoryviewslice_obj * __pyx_v_self)17154 static void __pyx_memoryviewslice___pyx_pf_15View_dot_MemoryView_16_memoryviewslice___dealloc__(struct __pyx_memoryviewslice_obj *__pyx_v_self) {
17155   __Pyx_RefNannyDeclarations
17156   __Pyx_RefNannySetupContext("__dealloc__", 0);
17157 
17158   /* "View.MemoryView":977
17159  *
17160  *     def __dealloc__(self):
17161  *         __PYX_XDEC_MEMVIEW(&self.from_slice, 1)             # <<<<<<<<<<<<<<
17162  *
17163  *     cdef convert_item_to_object(self, char *itemp):
17164  */
17165   __PYX_XDEC_MEMVIEW((&__pyx_v_self->from_slice), 1);
17166 
17167   /* "View.MemoryView":976
17168  *     cdef int (*to_dtype_func)(char *, object) except 0
17169  *
17170  *     def __dealloc__(self):             # <<<<<<<<<<<<<<
17171  *         __PYX_XDEC_MEMVIEW(&self.from_slice, 1)
17172  *
17173  */
17174 
17175   /* function exit code */
17176   __Pyx_RefNannyFinishContext();
17177 }
17178 
17179 /* "View.MemoryView":979
17180  *         __PYX_XDEC_MEMVIEW(&self.from_slice, 1)
17181  *
17182  *     cdef convert_item_to_object(self, char *itemp):             # <<<<<<<<<<<<<<
17183  *         if self.to_object_func != NULL:
17184  *             return self.to_object_func(itemp)
17185  */
17186 
__pyx_memoryviewslice_convert_item_to_object(struct __pyx_memoryviewslice_obj * __pyx_v_self,char * __pyx_v_itemp)17187 static PyObject *__pyx_memoryviewslice_convert_item_to_object(struct __pyx_memoryviewslice_obj *__pyx_v_self, char *__pyx_v_itemp) {
17188   PyObject *__pyx_r = NULL;
17189   __Pyx_RefNannyDeclarations
17190   int __pyx_t_1;
17191   PyObject *__pyx_t_2 = NULL;
17192   int __pyx_lineno = 0;
17193   const char *__pyx_filename = NULL;
17194   int __pyx_clineno = 0;
17195   __Pyx_RefNannySetupContext("convert_item_to_object", 0);
17196 
17197   /* "View.MemoryView":980
17198  *
17199  *     cdef convert_item_to_object(self, char *itemp):
17200  *         if self.to_object_func != NULL:             # <<<<<<<<<<<<<<
17201  *             return self.to_object_func(itemp)
17202  *         else:
17203  */
17204   __pyx_t_1 = ((__pyx_v_self->to_object_func != NULL) != 0);
17205   if (__pyx_t_1) {
17206 
17207     /* "View.MemoryView":981
17208  *     cdef convert_item_to_object(self, char *itemp):
17209  *         if self.to_object_func != NULL:
17210  *             return self.to_object_func(itemp)             # <<<<<<<<<<<<<<
17211  *         else:
17212  *             return memoryview.convert_item_to_object(self, itemp)
17213  */
17214     __Pyx_XDECREF(__pyx_r);
17215     __pyx_t_2 = __pyx_v_self->to_object_func(__pyx_v_itemp); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 981, __pyx_L1_error)
17216     __Pyx_GOTREF(__pyx_t_2);
17217     __pyx_r = __pyx_t_2;
17218     __pyx_t_2 = 0;
17219     goto __pyx_L0;
17220 
17221     /* "View.MemoryView":980
17222  *
17223  *     cdef convert_item_to_object(self, char *itemp):
17224  *         if self.to_object_func != NULL:             # <<<<<<<<<<<<<<
17225  *             return self.to_object_func(itemp)
17226  *         else:
17227  */
17228   }
17229 
17230   /* "View.MemoryView":983
17231  *             return self.to_object_func(itemp)
17232  *         else:
17233  *             return memoryview.convert_item_to_object(self, itemp)             # <<<<<<<<<<<<<<
17234  *
17235  *     cdef assign_item_from_object(self, char *itemp, object value):
17236  */
17237   /*else*/ {
17238     __Pyx_XDECREF(__pyx_r);
17239     __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(2, 983, __pyx_L1_error)
17240     __Pyx_GOTREF(__pyx_t_2);
17241     __pyx_r = __pyx_t_2;
17242     __pyx_t_2 = 0;
17243     goto __pyx_L0;
17244   }
17245 
17246   /* "View.MemoryView":979
17247  *         __PYX_XDEC_MEMVIEW(&self.from_slice, 1)
17248  *
17249  *     cdef convert_item_to_object(self, char *itemp):             # <<<<<<<<<<<<<<
17250  *         if self.to_object_func != NULL:
17251  *             return self.to_object_func(itemp)
17252  */
17253 
17254   /* function exit code */
17255   __pyx_L1_error:;
17256   __Pyx_XDECREF(__pyx_t_2);
17257   __Pyx_AddTraceback("View.MemoryView._memoryviewslice.convert_item_to_object", __pyx_clineno, __pyx_lineno, __pyx_filename);
17258   __pyx_r = 0;
17259   __pyx_L0:;
17260   __Pyx_XGIVEREF(__pyx_r);
17261   __Pyx_RefNannyFinishContext();
17262   return __pyx_r;
17263 }
17264 
17265 /* "View.MemoryView":985
17266  *             return memoryview.convert_item_to_object(self, itemp)
17267  *
17268  *     cdef assign_item_from_object(self, char *itemp, object value):             # <<<<<<<<<<<<<<
17269  *         if self.to_dtype_func != NULL:
17270  *             self.to_dtype_func(itemp, value)
17271  */
17272 
__pyx_memoryviewslice_assign_item_from_object(struct __pyx_memoryviewslice_obj * __pyx_v_self,char * __pyx_v_itemp,PyObject * __pyx_v_value)17273 static PyObject *__pyx_memoryviewslice_assign_item_from_object(struct __pyx_memoryviewslice_obj *__pyx_v_self, char *__pyx_v_itemp, PyObject *__pyx_v_value) {
17274   PyObject *__pyx_r = NULL;
17275   __Pyx_RefNannyDeclarations
17276   int __pyx_t_1;
17277   int __pyx_t_2;
17278   PyObject *__pyx_t_3 = NULL;
17279   int __pyx_lineno = 0;
17280   const char *__pyx_filename = NULL;
17281   int __pyx_clineno = 0;
17282   __Pyx_RefNannySetupContext("assign_item_from_object", 0);
17283 
17284   /* "View.MemoryView":986
17285  *
17286  *     cdef assign_item_from_object(self, char *itemp, object value):
17287  *         if self.to_dtype_func != NULL:             # <<<<<<<<<<<<<<
17288  *             self.to_dtype_func(itemp, value)
17289  *         else:
17290  */
17291   __pyx_t_1 = ((__pyx_v_self->to_dtype_func != NULL) != 0);
17292   if (__pyx_t_1) {
17293 
17294     /* "View.MemoryView":987
17295  *     cdef assign_item_from_object(self, char *itemp, object value):
17296  *         if self.to_dtype_func != NULL:
17297  *             self.to_dtype_func(itemp, value)             # <<<<<<<<<<<<<<
17298  *         else:
17299  *             memoryview.assign_item_from_object(self, itemp, value)
17300  */
17301     __pyx_t_2 = __pyx_v_self->to_dtype_func(__pyx_v_itemp, __pyx_v_value); if (unlikely(__pyx_t_2 == ((int)0))) __PYX_ERR(2, 987, __pyx_L1_error)
17302 
17303     /* "View.MemoryView":986
17304  *
17305  *     cdef assign_item_from_object(self, char *itemp, object value):
17306  *         if self.to_dtype_func != NULL:             # <<<<<<<<<<<<<<
17307  *             self.to_dtype_func(itemp, value)
17308  *         else:
17309  */
17310     goto __pyx_L3;
17311   }
17312 
17313   /* "View.MemoryView":989
17314  *             self.to_dtype_func(itemp, value)
17315  *         else:
17316  *             memoryview.assign_item_from_object(self, itemp, value)             # <<<<<<<<<<<<<<
17317  *
17318  *     @property
17319  */
17320   /*else*/ {
17321     __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(2, 989, __pyx_L1_error)
17322     __Pyx_GOTREF(__pyx_t_3);
17323     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
17324   }
17325   __pyx_L3:;
17326 
17327   /* "View.MemoryView":985
17328  *             return memoryview.convert_item_to_object(self, itemp)
17329  *
17330  *     cdef assign_item_from_object(self, char *itemp, object value):             # <<<<<<<<<<<<<<
17331  *         if self.to_dtype_func != NULL:
17332  *             self.to_dtype_func(itemp, value)
17333  */
17334 
17335   /* function exit code */
17336   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
17337   goto __pyx_L0;
17338   __pyx_L1_error:;
17339   __Pyx_XDECREF(__pyx_t_3);
17340   __Pyx_AddTraceback("View.MemoryView._memoryviewslice.assign_item_from_object", __pyx_clineno, __pyx_lineno, __pyx_filename);
17341   __pyx_r = 0;
17342   __pyx_L0:;
17343   __Pyx_XGIVEREF(__pyx_r);
17344   __Pyx_RefNannyFinishContext();
17345   return __pyx_r;
17346 }
17347 
17348 /* "View.MemoryView":992
17349  *
17350  *     @property
17351  *     def base(self):             # <<<<<<<<<<<<<<
17352  *         return self.from_object
17353  *
17354  */
17355 
17356 /* Python wrapper */
17357 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)17358 static PyObject *__pyx_pw_15View_dot_MemoryView_16_memoryviewslice_4base_1__get__(PyObject *__pyx_v_self) {
17359   PyObject *__pyx_r = 0;
17360   __Pyx_RefNannyDeclarations
17361   __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
17362   __pyx_r = __pyx_pf_15View_dot_MemoryView_16_memoryviewslice_4base___get__(((struct __pyx_memoryviewslice_obj *)__pyx_v_self));
17363 
17364   /* function exit code */
17365   __Pyx_RefNannyFinishContext();
17366   return __pyx_r;
17367 }
17368 
__pyx_pf_15View_dot_MemoryView_16_memoryviewslice_4base___get__(struct __pyx_memoryviewslice_obj * __pyx_v_self)17369 static PyObject *__pyx_pf_15View_dot_MemoryView_16_memoryviewslice_4base___get__(struct __pyx_memoryviewslice_obj *__pyx_v_self) {
17370   PyObject *__pyx_r = NULL;
17371   __Pyx_RefNannyDeclarations
17372   __Pyx_RefNannySetupContext("__get__", 0);
17373 
17374   /* "View.MemoryView":993
17375  *     @property
17376  *     def base(self):
17377  *         return self.from_object             # <<<<<<<<<<<<<<
17378  *
17379  *     __pyx_getbuffer = capsule(<void *> &__pyx_memoryview_getbuffer, "getbuffer(obj, view, flags)")
17380  */
17381   __Pyx_XDECREF(__pyx_r);
17382   __Pyx_INCREF(__pyx_v_self->from_object);
17383   __pyx_r = __pyx_v_self->from_object;
17384   goto __pyx_L0;
17385 
17386   /* "View.MemoryView":992
17387  *
17388  *     @property
17389  *     def base(self):             # <<<<<<<<<<<<<<
17390  *         return self.from_object
17391  *
17392  */
17393 
17394   /* function exit code */
17395   __pyx_L0:;
17396   __Pyx_XGIVEREF(__pyx_r);
17397   __Pyx_RefNannyFinishContext();
17398   return __pyx_r;
17399 }
17400 
17401 /* "(tree fragment)":1
17402  * def __reduce_cython__(self):             # <<<<<<<<<<<<<<
17403  *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
17404  * def __setstate_cython__(self, __pyx_state):
17405  */
17406 
17407 /* Python wrapper */
17408 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)17409 static PyObject *__pyx_pw___pyx_memoryviewslice_1__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
17410   PyObject *__pyx_r = 0;
17411   __Pyx_RefNannyDeclarations
17412   __Pyx_RefNannySetupContext("__reduce_cython__ (wrapper)", 0);
17413   __pyx_r = __pyx_pf___pyx_memoryviewslice___reduce_cython__(((struct __pyx_memoryviewslice_obj *)__pyx_v_self));
17414 
17415   /* function exit code */
17416   __Pyx_RefNannyFinishContext();
17417   return __pyx_r;
17418 }
17419 
__pyx_pf___pyx_memoryviewslice___reduce_cython__(CYTHON_UNUSED struct __pyx_memoryviewslice_obj * __pyx_v_self)17420 static PyObject *__pyx_pf___pyx_memoryviewslice___reduce_cython__(CYTHON_UNUSED struct __pyx_memoryviewslice_obj *__pyx_v_self) {
17421   PyObject *__pyx_r = NULL;
17422   __Pyx_RefNannyDeclarations
17423   PyObject *__pyx_t_1 = NULL;
17424   int __pyx_lineno = 0;
17425   const char *__pyx_filename = NULL;
17426   int __pyx_clineno = 0;
17427   __Pyx_RefNannySetupContext("__reduce_cython__", 0);
17428 
17429   /* "(tree fragment)":2
17430  * def __reduce_cython__(self):
17431  *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")             # <<<<<<<<<<<<<<
17432  * def __setstate_cython__(self, __pyx_state):
17433  *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
17434  */
17435   __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__22, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 2, __pyx_L1_error)
17436   __Pyx_GOTREF(__pyx_t_1);
17437   __Pyx_Raise(__pyx_t_1, 0, 0, 0);
17438   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
17439   __PYX_ERR(2, 2, __pyx_L1_error)
17440 
17441   /* "(tree fragment)":1
17442  * def __reduce_cython__(self):             # <<<<<<<<<<<<<<
17443  *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
17444  * def __setstate_cython__(self, __pyx_state):
17445  */
17446 
17447   /* function exit code */
17448   __pyx_L1_error:;
17449   __Pyx_XDECREF(__pyx_t_1);
17450   __Pyx_AddTraceback("View.MemoryView._memoryviewslice.__reduce_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename);
17451   __pyx_r = NULL;
17452   __Pyx_XGIVEREF(__pyx_r);
17453   __Pyx_RefNannyFinishContext();
17454   return __pyx_r;
17455 }
17456 
17457 /* "(tree fragment)":3
17458  * def __reduce_cython__(self):
17459  *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
17460  * def __setstate_cython__(self, __pyx_state):             # <<<<<<<<<<<<<<
17461  *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
17462  */
17463 
17464 /* Python wrapper */
17465 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)17466 static PyObject *__pyx_pw___pyx_memoryviewslice_3__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state) {
17467   PyObject *__pyx_r = 0;
17468   __Pyx_RefNannyDeclarations
17469   __Pyx_RefNannySetupContext("__setstate_cython__ (wrapper)", 0);
17470   __pyx_r = __pyx_pf___pyx_memoryviewslice_2__setstate_cython__(((struct __pyx_memoryviewslice_obj *)__pyx_v_self), ((PyObject *)__pyx_v___pyx_state));
17471 
17472   /* function exit code */
17473   __Pyx_RefNannyFinishContext();
17474   return __pyx_r;
17475 }
17476 
__pyx_pf___pyx_memoryviewslice_2__setstate_cython__(CYTHON_UNUSED struct __pyx_memoryviewslice_obj * __pyx_v_self,CYTHON_UNUSED PyObject * __pyx_v___pyx_state)17477 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) {
17478   PyObject *__pyx_r = NULL;
17479   __Pyx_RefNannyDeclarations
17480   PyObject *__pyx_t_1 = NULL;
17481   int __pyx_lineno = 0;
17482   const char *__pyx_filename = NULL;
17483   int __pyx_clineno = 0;
17484   __Pyx_RefNannySetupContext("__setstate_cython__", 0);
17485 
17486   /* "(tree fragment)":4
17487  *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
17488  * def __setstate_cython__(self, __pyx_state):
17489  *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")             # <<<<<<<<<<<<<<
17490  */
17491   __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__23, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 4, __pyx_L1_error)
17492   __Pyx_GOTREF(__pyx_t_1);
17493   __Pyx_Raise(__pyx_t_1, 0, 0, 0);
17494   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
17495   __PYX_ERR(2, 4, __pyx_L1_error)
17496 
17497   /* "(tree fragment)":3
17498  * def __reduce_cython__(self):
17499  *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
17500  * def __setstate_cython__(self, __pyx_state):             # <<<<<<<<<<<<<<
17501  *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
17502  */
17503 
17504   /* function exit code */
17505   __pyx_L1_error:;
17506   __Pyx_XDECREF(__pyx_t_1);
17507   __Pyx_AddTraceback("View.MemoryView._memoryviewslice.__setstate_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename);
17508   __pyx_r = NULL;
17509   __Pyx_XGIVEREF(__pyx_r);
17510   __Pyx_RefNannyFinishContext();
17511   return __pyx_r;
17512 }
17513 
17514 /* "View.MemoryView":999
17515  *
17516  * @cname('__pyx_memoryview_fromslice')
17517  * cdef memoryview_fromslice(__Pyx_memviewslice memviewslice,             # <<<<<<<<<<<<<<
17518  *                           int ndim,
17519  *                           object (*to_object_func)(char *),
17520  */
17521 
__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)17522 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) {
17523   struct __pyx_memoryviewslice_obj *__pyx_v_result = 0;
17524   Py_ssize_t __pyx_v_suboffset;
17525   PyObject *__pyx_v_length = NULL;
17526   PyObject *__pyx_r = NULL;
17527   __Pyx_RefNannyDeclarations
17528   int __pyx_t_1;
17529   PyObject *__pyx_t_2 = NULL;
17530   PyObject *__pyx_t_3 = NULL;
17531   __Pyx_TypeInfo *__pyx_t_4;
17532   Py_buffer __pyx_t_5;
17533   Py_ssize_t *__pyx_t_6;
17534   Py_ssize_t *__pyx_t_7;
17535   Py_ssize_t *__pyx_t_8;
17536   Py_ssize_t __pyx_t_9;
17537   int __pyx_lineno = 0;
17538   const char *__pyx_filename = NULL;
17539   int __pyx_clineno = 0;
17540   __Pyx_RefNannySetupContext("memoryview_fromslice", 0);
17541 
17542   /* "View.MemoryView":1007
17543  *     cdef _memoryviewslice result
17544  *
17545  *     if <PyObject *> memviewslice.memview == Py_None:             # <<<<<<<<<<<<<<
17546  *         return None
17547  *
17548  */
17549   __pyx_t_1 = ((((PyObject *)__pyx_v_memviewslice.memview) == Py_None) != 0);
17550   if (__pyx_t_1) {
17551 
17552     /* "View.MemoryView":1008
17553  *
17554  *     if <PyObject *> memviewslice.memview == Py_None:
17555  *         return None             # <<<<<<<<<<<<<<
17556  *
17557  *
17558  */
17559     __Pyx_XDECREF(__pyx_r);
17560     __pyx_r = Py_None; __Pyx_INCREF(Py_None);
17561     goto __pyx_L0;
17562 
17563     /* "View.MemoryView":1007
17564  *     cdef _memoryviewslice result
17565  *
17566  *     if <PyObject *> memviewslice.memview == Py_None:             # <<<<<<<<<<<<<<
17567  *         return None
17568  *
17569  */
17570   }
17571 
17572   /* "View.MemoryView":1013
17573  *
17574  *
17575  *     result = _memoryviewslice(None, 0, dtype_is_object)             # <<<<<<<<<<<<<<
17576  *
17577  *     result.from_slice = memviewslice
17578  */
17579   __pyx_t_2 = __Pyx_PyBool_FromLong(__pyx_v_dtype_is_object); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 1013, __pyx_L1_error)
17580   __Pyx_GOTREF(__pyx_t_2);
17581   __pyx_t_3 = PyTuple_New(3); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 1013, __pyx_L1_error)
17582   __Pyx_GOTREF(__pyx_t_3);
17583   __Pyx_INCREF(Py_None);
17584   __Pyx_GIVEREF(Py_None);
17585   PyTuple_SET_ITEM(__pyx_t_3, 0, Py_None);
17586   __Pyx_INCREF(__pyx_int_0);
17587   __Pyx_GIVEREF(__pyx_int_0);
17588   PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_int_0);
17589   __Pyx_GIVEREF(__pyx_t_2);
17590   PyTuple_SET_ITEM(__pyx_t_3, 2, __pyx_t_2);
17591   __pyx_t_2 = 0;
17592   __pyx_t_2 = __Pyx_PyObject_Call(((PyObject *)__pyx_memoryviewslice_type), __pyx_t_3, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 1013, __pyx_L1_error)
17593   __Pyx_GOTREF(__pyx_t_2);
17594   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
17595   __pyx_v_result = ((struct __pyx_memoryviewslice_obj *)__pyx_t_2);
17596   __pyx_t_2 = 0;
17597 
17598   /* "View.MemoryView":1015
17599  *     result = _memoryviewslice(None, 0, dtype_is_object)
17600  *
17601  *     result.from_slice = memviewslice             # <<<<<<<<<<<<<<
17602  *     __PYX_INC_MEMVIEW(&memviewslice, 1)
17603  *
17604  */
17605   __pyx_v_result->from_slice = __pyx_v_memviewslice;
17606 
17607   /* "View.MemoryView":1016
17608  *
17609  *     result.from_slice = memviewslice
17610  *     __PYX_INC_MEMVIEW(&memviewslice, 1)             # <<<<<<<<<<<<<<
17611  *
17612  *     result.from_object = (<memoryview> memviewslice.memview).base
17613  */
17614   __PYX_INC_MEMVIEW((&__pyx_v_memviewslice), 1);
17615 
17616   /* "View.MemoryView":1018
17617  *     __PYX_INC_MEMVIEW(&memviewslice, 1)
17618  *
17619  *     result.from_object = (<memoryview> memviewslice.memview).base             # <<<<<<<<<<<<<<
17620  *     result.typeinfo = memviewslice.memview.typeinfo
17621  *
17622  */
17623   __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_memviewslice.memview), __pyx_n_s_base); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 1018, __pyx_L1_error)
17624   __Pyx_GOTREF(__pyx_t_2);
17625   __Pyx_GIVEREF(__pyx_t_2);
17626   __Pyx_GOTREF(__pyx_v_result->from_object);
17627   __Pyx_DECREF(__pyx_v_result->from_object);
17628   __pyx_v_result->from_object = __pyx_t_2;
17629   __pyx_t_2 = 0;
17630 
17631   /* "View.MemoryView":1019
17632  *
17633  *     result.from_object = (<memoryview> memviewslice.memview).base
17634  *     result.typeinfo = memviewslice.memview.typeinfo             # <<<<<<<<<<<<<<
17635  *
17636  *     result.view = memviewslice.memview.view
17637  */
17638   __pyx_t_4 = __pyx_v_memviewslice.memview->typeinfo;
17639   __pyx_v_result->__pyx_base.typeinfo = __pyx_t_4;
17640 
17641   /* "View.MemoryView":1021
17642  *     result.typeinfo = memviewslice.memview.typeinfo
17643  *
17644  *     result.view = memviewslice.memview.view             # <<<<<<<<<<<<<<
17645  *     result.view.buf = <void *> memviewslice.data
17646  *     result.view.ndim = ndim
17647  */
17648   __pyx_t_5 = __pyx_v_memviewslice.memview->view;
17649   __pyx_v_result->__pyx_base.view = __pyx_t_5;
17650 
17651   /* "View.MemoryView":1022
17652  *
17653  *     result.view = memviewslice.memview.view
17654  *     result.view.buf = <void *> memviewslice.data             # <<<<<<<<<<<<<<
17655  *     result.view.ndim = ndim
17656  *     (<__pyx_buffer *> &result.view).obj = Py_None
17657  */
17658   __pyx_v_result->__pyx_base.view.buf = ((void *)__pyx_v_memviewslice.data);
17659 
17660   /* "View.MemoryView":1023
17661  *     result.view = memviewslice.memview.view
17662  *     result.view.buf = <void *> memviewslice.data
17663  *     result.view.ndim = ndim             # <<<<<<<<<<<<<<
17664  *     (<__pyx_buffer *> &result.view).obj = Py_None
17665  *     Py_INCREF(Py_None)
17666  */
17667   __pyx_v_result->__pyx_base.view.ndim = __pyx_v_ndim;
17668 
17669   /* "View.MemoryView":1024
17670  *     result.view.buf = <void *> memviewslice.data
17671  *     result.view.ndim = ndim
17672  *     (<__pyx_buffer *> &result.view).obj = Py_None             # <<<<<<<<<<<<<<
17673  *     Py_INCREF(Py_None)
17674  *
17675  */
17676   ((Py_buffer *)(&__pyx_v_result->__pyx_base.view))->obj = Py_None;
17677 
17678   /* "View.MemoryView":1025
17679  *     result.view.ndim = ndim
17680  *     (<__pyx_buffer *> &result.view).obj = Py_None
17681  *     Py_INCREF(Py_None)             # <<<<<<<<<<<<<<
17682  *
17683  *     if (<memoryview>memviewslice.memview).flags & PyBUF_WRITABLE:
17684  */
17685   Py_INCREF(Py_None);
17686 
17687   /* "View.MemoryView":1027
17688  *     Py_INCREF(Py_None)
17689  *
17690  *     if (<memoryview>memviewslice.memview).flags & PyBUF_WRITABLE:             # <<<<<<<<<<<<<<
17691  *         result.flags = PyBUF_RECORDS
17692  *     else:
17693  */
17694   __pyx_t_1 = ((((struct __pyx_memoryview_obj *)__pyx_v_memviewslice.memview)->flags & PyBUF_WRITABLE) != 0);
17695   if (__pyx_t_1) {
17696 
17697     /* "View.MemoryView":1028
17698  *
17699  *     if (<memoryview>memviewslice.memview).flags & PyBUF_WRITABLE:
17700  *         result.flags = PyBUF_RECORDS             # <<<<<<<<<<<<<<
17701  *     else:
17702  *         result.flags = PyBUF_RECORDS_RO
17703  */
17704     __pyx_v_result->__pyx_base.flags = PyBUF_RECORDS;
17705 
17706     /* "View.MemoryView":1027
17707  *     Py_INCREF(Py_None)
17708  *
17709  *     if (<memoryview>memviewslice.memview).flags & PyBUF_WRITABLE:             # <<<<<<<<<<<<<<
17710  *         result.flags = PyBUF_RECORDS
17711  *     else:
17712  */
17713     goto __pyx_L4;
17714   }
17715 
17716   /* "View.MemoryView":1030
17717  *         result.flags = PyBUF_RECORDS
17718  *     else:
17719  *         result.flags = PyBUF_RECORDS_RO             # <<<<<<<<<<<<<<
17720  *
17721  *     result.view.shape = <Py_ssize_t *> result.from_slice.shape
17722  */
17723   /*else*/ {
17724     __pyx_v_result->__pyx_base.flags = PyBUF_RECORDS_RO;
17725   }
17726   __pyx_L4:;
17727 
17728   /* "View.MemoryView":1032
17729  *         result.flags = PyBUF_RECORDS_RO
17730  *
17731  *     result.view.shape = <Py_ssize_t *> result.from_slice.shape             # <<<<<<<<<<<<<<
17732  *     result.view.strides = <Py_ssize_t *> result.from_slice.strides
17733  *
17734  */
17735   __pyx_v_result->__pyx_base.view.shape = ((Py_ssize_t *)__pyx_v_result->from_slice.shape);
17736 
17737   /* "View.MemoryView":1033
17738  *
17739  *     result.view.shape = <Py_ssize_t *> result.from_slice.shape
17740  *     result.view.strides = <Py_ssize_t *> result.from_slice.strides             # <<<<<<<<<<<<<<
17741  *
17742  *
17743  */
17744   __pyx_v_result->__pyx_base.view.strides = ((Py_ssize_t *)__pyx_v_result->from_slice.strides);
17745 
17746   /* "View.MemoryView":1036
17747  *
17748  *
17749  *     result.view.suboffsets = NULL             # <<<<<<<<<<<<<<
17750  *     for suboffset in result.from_slice.suboffsets[:ndim]:
17751  *         if suboffset >= 0:
17752  */
17753   __pyx_v_result->__pyx_base.view.suboffsets = NULL;
17754 
17755   /* "View.MemoryView":1037
17756  *
17757  *     result.view.suboffsets = NULL
17758  *     for suboffset in result.from_slice.suboffsets[:ndim]:             # <<<<<<<<<<<<<<
17759  *         if suboffset >= 0:
17760  *             result.view.suboffsets = <Py_ssize_t *> result.from_slice.suboffsets
17761  */
17762   __pyx_t_7 = (__pyx_v_result->from_slice.suboffsets + __pyx_v_ndim);
17763   for (__pyx_t_8 = __pyx_v_result->from_slice.suboffsets; __pyx_t_8 < __pyx_t_7; __pyx_t_8++) {
17764     __pyx_t_6 = __pyx_t_8;
17765     __pyx_v_suboffset = (__pyx_t_6[0]);
17766 
17767     /* "View.MemoryView":1038
17768  *     result.view.suboffsets = NULL
17769  *     for suboffset in result.from_slice.suboffsets[:ndim]:
17770  *         if suboffset >= 0:             # <<<<<<<<<<<<<<
17771  *             result.view.suboffsets = <Py_ssize_t *> result.from_slice.suboffsets
17772  *             break
17773  */
17774     __pyx_t_1 = ((__pyx_v_suboffset >= 0) != 0);
17775     if (__pyx_t_1) {
17776 
17777       /* "View.MemoryView":1039
17778  *     for suboffset in result.from_slice.suboffsets[:ndim]:
17779  *         if suboffset >= 0:
17780  *             result.view.suboffsets = <Py_ssize_t *> result.from_slice.suboffsets             # <<<<<<<<<<<<<<
17781  *             break
17782  *
17783  */
17784       __pyx_v_result->__pyx_base.view.suboffsets = ((Py_ssize_t *)__pyx_v_result->from_slice.suboffsets);
17785 
17786       /* "View.MemoryView":1040
17787  *         if suboffset >= 0:
17788  *             result.view.suboffsets = <Py_ssize_t *> result.from_slice.suboffsets
17789  *             break             # <<<<<<<<<<<<<<
17790  *
17791  *     result.view.len = result.view.itemsize
17792  */
17793       goto __pyx_L6_break;
17794 
17795       /* "View.MemoryView":1038
17796  *     result.view.suboffsets = NULL
17797  *     for suboffset in result.from_slice.suboffsets[:ndim]:
17798  *         if suboffset >= 0:             # <<<<<<<<<<<<<<
17799  *             result.view.suboffsets = <Py_ssize_t *> result.from_slice.suboffsets
17800  *             break
17801  */
17802     }
17803   }
17804   __pyx_L6_break:;
17805 
17806   /* "View.MemoryView":1042
17807  *             break
17808  *
17809  *     result.view.len = result.view.itemsize             # <<<<<<<<<<<<<<
17810  *     for length in result.view.shape[:ndim]:
17811  *         result.view.len *= length
17812  */
17813   __pyx_t_9 = __pyx_v_result->__pyx_base.view.itemsize;
17814   __pyx_v_result->__pyx_base.view.len = __pyx_t_9;
17815 
17816   /* "View.MemoryView":1043
17817  *
17818  *     result.view.len = result.view.itemsize
17819  *     for length in result.view.shape[:ndim]:             # <<<<<<<<<<<<<<
17820  *         result.view.len *= length
17821  *
17822  */
17823   __pyx_t_7 = (__pyx_v_result->__pyx_base.view.shape + __pyx_v_ndim);
17824   for (__pyx_t_8 = __pyx_v_result->__pyx_base.view.shape; __pyx_t_8 < __pyx_t_7; __pyx_t_8++) {
17825     __pyx_t_6 = __pyx_t_8;
17826     __pyx_t_2 = PyInt_FromSsize_t((__pyx_t_6[0])); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 1043, __pyx_L1_error)
17827     __Pyx_GOTREF(__pyx_t_2);
17828     __Pyx_XDECREF_SET(__pyx_v_length, __pyx_t_2);
17829     __pyx_t_2 = 0;
17830 
17831     /* "View.MemoryView":1044
17832  *     result.view.len = result.view.itemsize
17833  *     for length in result.view.shape[:ndim]:
17834  *         result.view.len *= length             # <<<<<<<<<<<<<<
17835  *
17836  *     result.to_object_func = to_object_func
17837  */
17838     __pyx_t_2 = PyInt_FromSsize_t(__pyx_v_result->__pyx_base.view.len); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 1044, __pyx_L1_error)
17839     __Pyx_GOTREF(__pyx_t_2);
17840     __pyx_t_3 = PyNumber_InPlaceMultiply(__pyx_t_2, __pyx_v_length); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 1044, __pyx_L1_error)
17841     __Pyx_GOTREF(__pyx_t_3);
17842     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
17843     __pyx_t_9 = __Pyx_PyIndex_AsSsize_t(__pyx_t_3); if (unlikely((__pyx_t_9 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(2, 1044, __pyx_L1_error)
17844     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
17845     __pyx_v_result->__pyx_base.view.len = __pyx_t_9;
17846   }
17847 
17848   /* "View.MemoryView":1046
17849  *         result.view.len *= length
17850  *
17851  *     result.to_object_func = to_object_func             # <<<<<<<<<<<<<<
17852  *     result.to_dtype_func = to_dtype_func
17853  *
17854  */
17855   __pyx_v_result->to_object_func = __pyx_v_to_object_func;
17856 
17857   /* "View.MemoryView":1047
17858  *
17859  *     result.to_object_func = to_object_func
17860  *     result.to_dtype_func = to_dtype_func             # <<<<<<<<<<<<<<
17861  *
17862  *     return result
17863  */
17864   __pyx_v_result->to_dtype_func = __pyx_v_to_dtype_func;
17865 
17866   /* "View.MemoryView":1049
17867  *     result.to_dtype_func = to_dtype_func
17868  *
17869  *     return result             # <<<<<<<<<<<<<<
17870  *
17871  * @cname('__pyx_memoryview_get_slice_from_memoryview')
17872  */
17873   __Pyx_XDECREF(__pyx_r);
17874   __Pyx_INCREF(((PyObject *)__pyx_v_result));
17875   __pyx_r = ((PyObject *)__pyx_v_result);
17876   goto __pyx_L0;
17877 
17878   /* "View.MemoryView":999
17879  *
17880  * @cname('__pyx_memoryview_fromslice')
17881  * cdef memoryview_fromslice(__Pyx_memviewslice memviewslice,             # <<<<<<<<<<<<<<
17882  *                           int ndim,
17883  *                           object (*to_object_func)(char *),
17884  */
17885 
17886   /* function exit code */
17887   __pyx_L1_error:;
17888   __Pyx_XDECREF(__pyx_t_2);
17889   __Pyx_XDECREF(__pyx_t_3);
17890   __Pyx_AddTraceback("View.MemoryView.memoryview_fromslice", __pyx_clineno, __pyx_lineno, __pyx_filename);
17891   __pyx_r = 0;
17892   __pyx_L0:;
17893   __Pyx_XDECREF((PyObject *)__pyx_v_result);
17894   __Pyx_XDECREF(__pyx_v_length);
17895   __Pyx_XGIVEREF(__pyx_r);
17896   __Pyx_RefNannyFinishContext();
17897   return __pyx_r;
17898 }
17899 
17900 /* "View.MemoryView":1052
17901  *
17902  * @cname('__pyx_memoryview_get_slice_from_memoryview')
17903  * cdef __Pyx_memviewslice *get_slice_from_memview(memoryview memview,             # <<<<<<<<<<<<<<
17904  *                                                    __Pyx_memviewslice *mslice) except NULL:
17905  *     cdef _memoryviewslice obj
17906  */
17907 
__pyx_memoryview_get_slice_from_memoryview(struct __pyx_memoryview_obj * __pyx_v_memview,__Pyx_memviewslice * __pyx_v_mslice)17908 static __Pyx_memviewslice *__pyx_memoryview_get_slice_from_memoryview(struct __pyx_memoryview_obj *__pyx_v_memview, __Pyx_memviewslice *__pyx_v_mslice) {
17909   struct __pyx_memoryviewslice_obj *__pyx_v_obj = 0;
17910   __Pyx_memviewslice *__pyx_r;
17911   __Pyx_RefNannyDeclarations
17912   int __pyx_t_1;
17913   int __pyx_t_2;
17914   PyObject *__pyx_t_3 = NULL;
17915   int __pyx_lineno = 0;
17916   const char *__pyx_filename = NULL;
17917   int __pyx_clineno = 0;
17918   __Pyx_RefNannySetupContext("get_slice_from_memview", 0);
17919 
17920   /* "View.MemoryView":1055
17921  *                                                    __Pyx_memviewslice *mslice) except NULL:
17922  *     cdef _memoryviewslice obj
17923  *     if isinstance(memview, _memoryviewslice):             # <<<<<<<<<<<<<<
17924  *         obj = memview
17925  *         return &obj.from_slice
17926  */
17927   __pyx_t_1 = __Pyx_TypeCheck(((PyObject *)__pyx_v_memview), __pyx_memoryviewslice_type);
17928   __pyx_t_2 = (__pyx_t_1 != 0);
17929   if (__pyx_t_2) {
17930 
17931     /* "View.MemoryView":1056
17932  *     cdef _memoryviewslice obj
17933  *     if isinstance(memview, _memoryviewslice):
17934  *         obj = memview             # <<<<<<<<<<<<<<
17935  *         return &obj.from_slice
17936  *     else:
17937  */
17938     if (!(likely(((((PyObject *)__pyx_v_memview)) == Py_None) || likely(__Pyx_TypeTest(((PyObject *)__pyx_v_memview), __pyx_memoryviewslice_type))))) __PYX_ERR(2, 1056, __pyx_L1_error)
17939     __pyx_t_3 = ((PyObject *)__pyx_v_memview);
17940     __Pyx_INCREF(__pyx_t_3);
17941     __pyx_v_obj = ((struct __pyx_memoryviewslice_obj *)__pyx_t_3);
17942     __pyx_t_3 = 0;
17943 
17944     /* "View.MemoryView":1057
17945  *     if isinstance(memview, _memoryviewslice):
17946  *         obj = memview
17947  *         return &obj.from_slice             # <<<<<<<<<<<<<<
17948  *     else:
17949  *         slice_copy(memview, mslice)
17950  */
17951     __pyx_r = (&__pyx_v_obj->from_slice);
17952     goto __pyx_L0;
17953 
17954     /* "View.MemoryView":1055
17955  *                                                    __Pyx_memviewslice *mslice) except NULL:
17956  *     cdef _memoryviewslice obj
17957  *     if isinstance(memview, _memoryviewslice):             # <<<<<<<<<<<<<<
17958  *         obj = memview
17959  *         return &obj.from_slice
17960  */
17961   }
17962 
17963   /* "View.MemoryView":1059
17964  *         return &obj.from_slice
17965  *     else:
17966  *         slice_copy(memview, mslice)             # <<<<<<<<<<<<<<
17967  *         return mslice
17968  *
17969  */
17970   /*else*/ {
17971     __pyx_memoryview_slice_copy(__pyx_v_memview, __pyx_v_mslice);
17972 
17973     /* "View.MemoryView":1060
17974  *     else:
17975  *         slice_copy(memview, mslice)
17976  *         return mslice             # <<<<<<<<<<<<<<
17977  *
17978  * @cname('__pyx_memoryview_slice_copy')
17979  */
17980     __pyx_r = __pyx_v_mslice;
17981     goto __pyx_L0;
17982   }
17983 
17984   /* "View.MemoryView":1052
17985  *
17986  * @cname('__pyx_memoryview_get_slice_from_memoryview')
17987  * cdef __Pyx_memviewslice *get_slice_from_memview(memoryview memview,             # <<<<<<<<<<<<<<
17988  *                                                    __Pyx_memviewslice *mslice) except NULL:
17989  *     cdef _memoryviewslice obj
17990  */
17991 
17992   /* function exit code */
17993   __pyx_L1_error:;
17994   __Pyx_XDECREF(__pyx_t_3);
17995   __Pyx_AddTraceback("View.MemoryView.get_slice_from_memview", __pyx_clineno, __pyx_lineno, __pyx_filename);
17996   __pyx_r = NULL;
17997   __pyx_L0:;
17998   __Pyx_XDECREF((PyObject *)__pyx_v_obj);
17999   __Pyx_RefNannyFinishContext();
18000   return __pyx_r;
18001 }
18002 
18003 /* "View.MemoryView":1063
18004  *
18005  * @cname('__pyx_memoryview_slice_copy')
18006  * cdef void slice_copy(memoryview memview, __Pyx_memviewslice *dst):             # <<<<<<<<<<<<<<
18007  *     cdef int dim
18008  *     cdef (Py_ssize_t*) shape, strides, suboffsets
18009  */
18010 
__pyx_memoryview_slice_copy(struct __pyx_memoryview_obj * __pyx_v_memview,__Pyx_memviewslice * __pyx_v_dst)18011 static void __pyx_memoryview_slice_copy(struct __pyx_memoryview_obj *__pyx_v_memview, __Pyx_memviewslice *__pyx_v_dst) {
18012   int __pyx_v_dim;
18013   Py_ssize_t *__pyx_v_shape;
18014   Py_ssize_t *__pyx_v_strides;
18015   Py_ssize_t *__pyx_v_suboffsets;
18016   __Pyx_RefNannyDeclarations
18017   Py_ssize_t *__pyx_t_1;
18018   int __pyx_t_2;
18019   int __pyx_t_3;
18020   int __pyx_t_4;
18021   Py_ssize_t __pyx_t_5;
18022   __Pyx_RefNannySetupContext("slice_copy", 0);
18023 
18024   /* "View.MemoryView":1067
18025  *     cdef (Py_ssize_t*) shape, strides, suboffsets
18026  *
18027  *     shape = memview.view.shape             # <<<<<<<<<<<<<<
18028  *     strides = memview.view.strides
18029  *     suboffsets = memview.view.suboffsets
18030  */
18031   __pyx_t_1 = __pyx_v_memview->view.shape;
18032   __pyx_v_shape = __pyx_t_1;
18033 
18034   /* "View.MemoryView":1068
18035  *
18036  *     shape = memview.view.shape
18037  *     strides = memview.view.strides             # <<<<<<<<<<<<<<
18038  *     suboffsets = memview.view.suboffsets
18039  *
18040  */
18041   __pyx_t_1 = __pyx_v_memview->view.strides;
18042   __pyx_v_strides = __pyx_t_1;
18043 
18044   /* "View.MemoryView":1069
18045  *     shape = memview.view.shape
18046  *     strides = memview.view.strides
18047  *     suboffsets = memview.view.suboffsets             # <<<<<<<<<<<<<<
18048  *
18049  *     dst.memview = <__pyx_memoryview *> memview
18050  */
18051   __pyx_t_1 = __pyx_v_memview->view.suboffsets;
18052   __pyx_v_suboffsets = __pyx_t_1;
18053 
18054   /* "View.MemoryView":1071
18055  *     suboffsets = memview.view.suboffsets
18056  *
18057  *     dst.memview = <__pyx_memoryview *> memview             # <<<<<<<<<<<<<<
18058  *     dst.data = <char *> memview.view.buf
18059  *
18060  */
18061   __pyx_v_dst->memview = ((struct __pyx_memoryview_obj *)__pyx_v_memview);
18062 
18063   /* "View.MemoryView":1072
18064  *
18065  *     dst.memview = <__pyx_memoryview *> memview
18066  *     dst.data = <char *> memview.view.buf             # <<<<<<<<<<<<<<
18067  *
18068  *     for dim in range(memview.view.ndim):
18069  */
18070   __pyx_v_dst->data = ((char *)__pyx_v_memview->view.buf);
18071 
18072   /* "View.MemoryView":1074
18073  *     dst.data = <char *> memview.view.buf
18074  *
18075  *     for dim in range(memview.view.ndim):             # <<<<<<<<<<<<<<
18076  *         dst.shape[dim] = shape[dim]
18077  *         dst.strides[dim] = strides[dim]
18078  */
18079   __pyx_t_2 = __pyx_v_memview->view.ndim;
18080   __pyx_t_3 = __pyx_t_2;
18081   for (__pyx_t_4 = 0; __pyx_t_4 < __pyx_t_3; __pyx_t_4+=1) {
18082     __pyx_v_dim = __pyx_t_4;
18083 
18084     /* "View.MemoryView":1075
18085  *
18086  *     for dim in range(memview.view.ndim):
18087  *         dst.shape[dim] = shape[dim]             # <<<<<<<<<<<<<<
18088  *         dst.strides[dim] = strides[dim]
18089  *         dst.suboffsets[dim] = suboffsets[dim] if suboffsets else -1
18090  */
18091     (__pyx_v_dst->shape[__pyx_v_dim]) = (__pyx_v_shape[__pyx_v_dim]);
18092 
18093     /* "View.MemoryView":1076
18094  *     for dim in range(memview.view.ndim):
18095  *         dst.shape[dim] = shape[dim]
18096  *         dst.strides[dim] = strides[dim]             # <<<<<<<<<<<<<<
18097  *         dst.suboffsets[dim] = suboffsets[dim] if suboffsets else -1
18098  *
18099  */
18100     (__pyx_v_dst->strides[__pyx_v_dim]) = (__pyx_v_strides[__pyx_v_dim]);
18101 
18102     /* "View.MemoryView":1077
18103  *         dst.shape[dim] = shape[dim]
18104  *         dst.strides[dim] = strides[dim]
18105  *         dst.suboffsets[dim] = suboffsets[dim] if suboffsets else -1             # <<<<<<<<<<<<<<
18106  *
18107  * @cname('__pyx_memoryview_copy_object')
18108  */
18109     if ((__pyx_v_suboffsets != 0)) {
18110       __pyx_t_5 = (__pyx_v_suboffsets[__pyx_v_dim]);
18111     } else {
18112       __pyx_t_5 = -1L;
18113     }
18114     (__pyx_v_dst->suboffsets[__pyx_v_dim]) = __pyx_t_5;
18115   }
18116 
18117   /* "View.MemoryView":1063
18118  *
18119  * @cname('__pyx_memoryview_slice_copy')
18120  * cdef void slice_copy(memoryview memview, __Pyx_memviewslice *dst):             # <<<<<<<<<<<<<<
18121  *     cdef int dim
18122  *     cdef (Py_ssize_t*) shape, strides, suboffsets
18123  */
18124 
18125   /* function exit code */
18126   __Pyx_RefNannyFinishContext();
18127 }
18128 
18129 /* "View.MemoryView":1080
18130  *
18131  * @cname('__pyx_memoryview_copy_object')
18132  * cdef memoryview_copy(memoryview memview):             # <<<<<<<<<<<<<<
18133  *     "Create a new memoryview object"
18134  *     cdef __Pyx_memviewslice memviewslice
18135  */
18136 
__pyx_memoryview_copy_object(struct __pyx_memoryview_obj * __pyx_v_memview)18137 static PyObject *__pyx_memoryview_copy_object(struct __pyx_memoryview_obj *__pyx_v_memview) {
18138   __Pyx_memviewslice __pyx_v_memviewslice;
18139   PyObject *__pyx_r = NULL;
18140   __Pyx_RefNannyDeclarations
18141   PyObject *__pyx_t_1 = NULL;
18142   int __pyx_lineno = 0;
18143   const char *__pyx_filename = NULL;
18144   int __pyx_clineno = 0;
18145   __Pyx_RefNannySetupContext("memoryview_copy", 0);
18146 
18147   /* "View.MemoryView":1083
18148  *     "Create a new memoryview object"
18149  *     cdef __Pyx_memviewslice memviewslice
18150  *     slice_copy(memview, &memviewslice)             # <<<<<<<<<<<<<<
18151  *     return memoryview_copy_from_slice(memview, &memviewslice)
18152  *
18153  */
18154   __pyx_memoryview_slice_copy(__pyx_v_memview, (&__pyx_v_memviewslice));
18155 
18156   /* "View.MemoryView":1084
18157  *     cdef __Pyx_memviewslice memviewslice
18158  *     slice_copy(memview, &memviewslice)
18159  *     return memoryview_copy_from_slice(memview, &memviewslice)             # <<<<<<<<<<<<<<
18160  *
18161  * @cname('__pyx_memoryview_copy_object_from_slice')
18162  */
18163   __Pyx_XDECREF(__pyx_r);
18164   __pyx_t_1 = __pyx_memoryview_copy_object_from_slice(__pyx_v_memview, (&__pyx_v_memviewslice)); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 1084, __pyx_L1_error)
18165   __Pyx_GOTREF(__pyx_t_1);
18166   __pyx_r = __pyx_t_1;
18167   __pyx_t_1 = 0;
18168   goto __pyx_L0;
18169 
18170   /* "View.MemoryView":1080
18171  *
18172  * @cname('__pyx_memoryview_copy_object')
18173  * cdef memoryview_copy(memoryview memview):             # <<<<<<<<<<<<<<
18174  *     "Create a new memoryview object"
18175  *     cdef __Pyx_memviewslice memviewslice
18176  */
18177 
18178   /* function exit code */
18179   __pyx_L1_error:;
18180   __Pyx_XDECREF(__pyx_t_1);
18181   __Pyx_AddTraceback("View.MemoryView.memoryview_copy", __pyx_clineno, __pyx_lineno, __pyx_filename);
18182   __pyx_r = 0;
18183   __pyx_L0:;
18184   __Pyx_XGIVEREF(__pyx_r);
18185   __Pyx_RefNannyFinishContext();
18186   return __pyx_r;
18187 }
18188 
18189 /* "View.MemoryView":1087
18190  *
18191  * @cname('__pyx_memoryview_copy_object_from_slice')
18192  * cdef memoryview_copy_from_slice(memoryview memview, __Pyx_memviewslice *memviewslice):             # <<<<<<<<<<<<<<
18193  *     """
18194  *     Create a new memoryview object from a given memoryview object and slice.
18195  */
18196 
__pyx_memoryview_copy_object_from_slice(struct __pyx_memoryview_obj * __pyx_v_memview,__Pyx_memviewslice * __pyx_v_memviewslice)18197 static PyObject *__pyx_memoryview_copy_object_from_slice(struct __pyx_memoryview_obj *__pyx_v_memview, __Pyx_memviewslice *__pyx_v_memviewslice) {
18198   PyObject *(*__pyx_v_to_object_func)(char *);
18199   int (*__pyx_v_to_dtype_func)(char *, PyObject *);
18200   PyObject *__pyx_r = NULL;
18201   __Pyx_RefNannyDeclarations
18202   int __pyx_t_1;
18203   int __pyx_t_2;
18204   PyObject *(*__pyx_t_3)(char *);
18205   int (*__pyx_t_4)(char *, PyObject *);
18206   PyObject *__pyx_t_5 = NULL;
18207   int __pyx_lineno = 0;
18208   const char *__pyx_filename = NULL;
18209   int __pyx_clineno = 0;
18210   __Pyx_RefNannySetupContext("memoryview_copy_from_slice", 0);
18211 
18212   /* "View.MemoryView":1094
18213  *     cdef int (*to_dtype_func)(char *, object) except 0
18214  *
18215  *     if isinstance(memview, _memoryviewslice):             # <<<<<<<<<<<<<<
18216  *         to_object_func = (<_memoryviewslice> memview).to_object_func
18217  *         to_dtype_func = (<_memoryviewslice> memview).to_dtype_func
18218  */
18219   __pyx_t_1 = __Pyx_TypeCheck(((PyObject *)__pyx_v_memview), __pyx_memoryviewslice_type);
18220   __pyx_t_2 = (__pyx_t_1 != 0);
18221   if (__pyx_t_2) {
18222 
18223     /* "View.MemoryView":1095
18224  *
18225  *     if isinstance(memview, _memoryviewslice):
18226  *         to_object_func = (<_memoryviewslice> memview).to_object_func             # <<<<<<<<<<<<<<
18227  *         to_dtype_func = (<_memoryviewslice> memview).to_dtype_func
18228  *     else:
18229  */
18230     __pyx_t_3 = ((struct __pyx_memoryviewslice_obj *)__pyx_v_memview)->to_object_func;
18231     __pyx_v_to_object_func = __pyx_t_3;
18232 
18233     /* "View.MemoryView":1096
18234  *     if isinstance(memview, _memoryviewslice):
18235  *         to_object_func = (<_memoryviewslice> memview).to_object_func
18236  *         to_dtype_func = (<_memoryviewslice> memview).to_dtype_func             # <<<<<<<<<<<<<<
18237  *     else:
18238  *         to_object_func = NULL
18239  */
18240     __pyx_t_4 = ((struct __pyx_memoryviewslice_obj *)__pyx_v_memview)->to_dtype_func;
18241     __pyx_v_to_dtype_func = __pyx_t_4;
18242 
18243     /* "View.MemoryView":1094
18244  *     cdef int (*to_dtype_func)(char *, object) except 0
18245  *
18246  *     if isinstance(memview, _memoryviewslice):             # <<<<<<<<<<<<<<
18247  *         to_object_func = (<_memoryviewslice> memview).to_object_func
18248  *         to_dtype_func = (<_memoryviewslice> memview).to_dtype_func
18249  */
18250     goto __pyx_L3;
18251   }
18252 
18253   /* "View.MemoryView":1098
18254  *         to_dtype_func = (<_memoryviewslice> memview).to_dtype_func
18255  *     else:
18256  *         to_object_func = NULL             # <<<<<<<<<<<<<<
18257  *         to_dtype_func = NULL
18258  *
18259  */
18260   /*else*/ {
18261     __pyx_v_to_object_func = NULL;
18262 
18263     /* "View.MemoryView":1099
18264  *     else:
18265  *         to_object_func = NULL
18266  *         to_dtype_func = NULL             # <<<<<<<<<<<<<<
18267  *
18268  *     return memoryview_fromslice(memviewslice[0], memview.view.ndim,
18269  */
18270     __pyx_v_to_dtype_func = NULL;
18271   }
18272   __pyx_L3:;
18273 
18274   /* "View.MemoryView":1101
18275  *         to_dtype_func = NULL
18276  *
18277  *     return memoryview_fromslice(memviewslice[0], memview.view.ndim,             # <<<<<<<<<<<<<<
18278  *                                 to_object_func, to_dtype_func,
18279  *                                 memview.dtype_is_object)
18280  */
18281   __Pyx_XDECREF(__pyx_r);
18282 
18283   /* "View.MemoryView":1103
18284  *     return memoryview_fromslice(memviewslice[0], memview.view.ndim,
18285  *                                 to_object_func, to_dtype_func,
18286  *                                 memview.dtype_is_object)             # <<<<<<<<<<<<<<
18287  *
18288  *
18289  */
18290   __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(2, 1101, __pyx_L1_error)
18291   __Pyx_GOTREF(__pyx_t_5);
18292   __pyx_r = __pyx_t_5;
18293   __pyx_t_5 = 0;
18294   goto __pyx_L0;
18295 
18296   /* "View.MemoryView":1087
18297  *
18298  * @cname('__pyx_memoryview_copy_object_from_slice')
18299  * cdef memoryview_copy_from_slice(memoryview memview, __Pyx_memviewslice *memviewslice):             # <<<<<<<<<<<<<<
18300  *     """
18301  *     Create a new memoryview object from a given memoryview object and slice.
18302  */
18303 
18304   /* function exit code */
18305   __pyx_L1_error:;
18306   __Pyx_XDECREF(__pyx_t_5);
18307   __Pyx_AddTraceback("View.MemoryView.memoryview_copy_from_slice", __pyx_clineno, __pyx_lineno, __pyx_filename);
18308   __pyx_r = 0;
18309   __pyx_L0:;
18310   __Pyx_XGIVEREF(__pyx_r);
18311   __Pyx_RefNannyFinishContext();
18312   return __pyx_r;
18313 }
18314 
18315 /* "View.MemoryView":1109
18316  *
18317  *
18318  * cdef Py_ssize_t abs_py_ssize_t(Py_ssize_t arg) nogil:             # <<<<<<<<<<<<<<
18319  *     if arg < 0:
18320  *         return -arg
18321  */
18322 
abs_py_ssize_t(Py_ssize_t __pyx_v_arg)18323 static Py_ssize_t abs_py_ssize_t(Py_ssize_t __pyx_v_arg) {
18324   Py_ssize_t __pyx_r;
18325   int __pyx_t_1;
18326 
18327   /* "View.MemoryView":1110
18328  *
18329  * cdef Py_ssize_t abs_py_ssize_t(Py_ssize_t arg) nogil:
18330  *     if arg < 0:             # <<<<<<<<<<<<<<
18331  *         return -arg
18332  *     else:
18333  */
18334   __pyx_t_1 = ((__pyx_v_arg < 0) != 0);
18335   if (__pyx_t_1) {
18336 
18337     /* "View.MemoryView":1111
18338  * cdef Py_ssize_t abs_py_ssize_t(Py_ssize_t arg) nogil:
18339  *     if arg < 0:
18340  *         return -arg             # <<<<<<<<<<<<<<
18341  *     else:
18342  *         return arg
18343  */
18344     __pyx_r = (-__pyx_v_arg);
18345     goto __pyx_L0;
18346 
18347     /* "View.MemoryView":1110
18348  *
18349  * cdef Py_ssize_t abs_py_ssize_t(Py_ssize_t arg) nogil:
18350  *     if arg < 0:             # <<<<<<<<<<<<<<
18351  *         return -arg
18352  *     else:
18353  */
18354   }
18355 
18356   /* "View.MemoryView":1113
18357  *         return -arg
18358  *     else:
18359  *         return arg             # <<<<<<<<<<<<<<
18360  *
18361  * @cname('__pyx_get_best_slice_order')
18362  */
18363   /*else*/ {
18364     __pyx_r = __pyx_v_arg;
18365     goto __pyx_L0;
18366   }
18367 
18368   /* "View.MemoryView":1109
18369  *
18370  *
18371  * cdef Py_ssize_t abs_py_ssize_t(Py_ssize_t arg) nogil:             # <<<<<<<<<<<<<<
18372  *     if arg < 0:
18373  *         return -arg
18374  */
18375 
18376   /* function exit code */
18377   __pyx_L0:;
18378   return __pyx_r;
18379 }
18380 
18381 /* "View.MemoryView":1116
18382  *
18383  * @cname('__pyx_get_best_slice_order')
18384  * cdef char get_best_order(__Pyx_memviewslice *mslice, int ndim) nogil:             # <<<<<<<<<<<<<<
18385  *     """
18386  *     Figure out the best memory access order for a given slice.
18387  */
18388 
__pyx_get_best_slice_order(__Pyx_memviewslice * __pyx_v_mslice,int __pyx_v_ndim)18389 static char __pyx_get_best_slice_order(__Pyx_memviewslice *__pyx_v_mslice, int __pyx_v_ndim) {
18390   int __pyx_v_i;
18391   Py_ssize_t __pyx_v_c_stride;
18392   Py_ssize_t __pyx_v_f_stride;
18393   char __pyx_r;
18394   int __pyx_t_1;
18395   int __pyx_t_2;
18396   int __pyx_t_3;
18397   int __pyx_t_4;
18398 
18399   /* "View.MemoryView":1121
18400  *     """
18401  *     cdef int i
18402  *     cdef Py_ssize_t c_stride = 0             # <<<<<<<<<<<<<<
18403  *     cdef Py_ssize_t f_stride = 0
18404  *
18405  */
18406   __pyx_v_c_stride = 0;
18407 
18408   /* "View.MemoryView":1122
18409  *     cdef int i
18410  *     cdef Py_ssize_t c_stride = 0
18411  *     cdef Py_ssize_t f_stride = 0             # <<<<<<<<<<<<<<
18412  *
18413  *     for i in range(ndim - 1, -1, -1):
18414  */
18415   __pyx_v_f_stride = 0;
18416 
18417   /* "View.MemoryView":1124
18418  *     cdef Py_ssize_t f_stride = 0
18419  *
18420  *     for i in range(ndim - 1, -1, -1):             # <<<<<<<<<<<<<<
18421  *         if mslice.shape[i] > 1:
18422  *             c_stride = mslice.strides[i]
18423  */
18424   for (__pyx_t_1 = (__pyx_v_ndim - 1); __pyx_t_1 > -1; __pyx_t_1-=1) {
18425     __pyx_v_i = __pyx_t_1;
18426 
18427     /* "View.MemoryView":1125
18428  *
18429  *     for i in range(ndim - 1, -1, -1):
18430  *         if mslice.shape[i] > 1:             # <<<<<<<<<<<<<<
18431  *             c_stride = mslice.strides[i]
18432  *             break
18433  */
18434     __pyx_t_2 = (((__pyx_v_mslice->shape[__pyx_v_i]) > 1) != 0);
18435     if (__pyx_t_2) {
18436 
18437       /* "View.MemoryView":1126
18438  *     for i in range(ndim - 1, -1, -1):
18439  *         if mslice.shape[i] > 1:
18440  *             c_stride = mslice.strides[i]             # <<<<<<<<<<<<<<
18441  *             break
18442  *
18443  */
18444       __pyx_v_c_stride = (__pyx_v_mslice->strides[__pyx_v_i]);
18445 
18446       /* "View.MemoryView":1127
18447  *         if mslice.shape[i] > 1:
18448  *             c_stride = mslice.strides[i]
18449  *             break             # <<<<<<<<<<<<<<
18450  *
18451  *     for i in range(ndim):
18452  */
18453       goto __pyx_L4_break;
18454 
18455       /* "View.MemoryView":1125
18456  *
18457  *     for i in range(ndim - 1, -1, -1):
18458  *         if mslice.shape[i] > 1:             # <<<<<<<<<<<<<<
18459  *             c_stride = mslice.strides[i]
18460  *             break
18461  */
18462     }
18463   }
18464   __pyx_L4_break:;
18465 
18466   /* "View.MemoryView":1129
18467  *             break
18468  *
18469  *     for i in range(ndim):             # <<<<<<<<<<<<<<
18470  *         if mslice.shape[i] > 1:
18471  *             f_stride = mslice.strides[i]
18472  */
18473   __pyx_t_1 = __pyx_v_ndim;
18474   __pyx_t_3 = __pyx_t_1;
18475   for (__pyx_t_4 = 0; __pyx_t_4 < __pyx_t_3; __pyx_t_4+=1) {
18476     __pyx_v_i = __pyx_t_4;
18477 
18478     /* "View.MemoryView":1130
18479  *
18480  *     for i in range(ndim):
18481  *         if mslice.shape[i] > 1:             # <<<<<<<<<<<<<<
18482  *             f_stride = mslice.strides[i]
18483  *             break
18484  */
18485     __pyx_t_2 = (((__pyx_v_mslice->shape[__pyx_v_i]) > 1) != 0);
18486     if (__pyx_t_2) {
18487 
18488       /* "View.MemoryView":1131
18489  *     for i in range(ndim):
18490  *         if mslice.shape[i] > 1:
18491  *             f_stride = mslice.strides[i]             # <<<<<<<<<<<<<<
18492  *             break
18493  *
18494  */
18495       __pyx_v_f_stride = (__pyx_v_mslice->strides[__pyx_v_i]);
18496 
18497       /* "View.MemoryView":1132
18498  *         if mslice.shape[i] > 1:
18499  *             f_stride = mslice.strides[i]
18500  *             break             # <<<<<<<<<<<<<<
18501  *
18502  *     if abs_py_ssize_t(c_stride) <= abs_py_ssize_t(f_stride):
18503  */
18504       goto __pyx_L7_break;
18505 
18506       /* "View.MemoryView":1130
18507  *
18508  *     for i in range(ndim):
18509  *         if mslice.shape[i] > 1:             # <<<<<<<<<<<<<<
18510  *             f_stride = mslice.strides[i]
18511  *             break
18512  */
18513     }
18514   }
18515   __pyx_L7_break:;
18516 
18517   /* "View.MemoryView":1134
18518  *             break
18519  *
18520  *     if abs_py_ssize_t(c_stride) <= abs_py_ssize_t(f_stride):             # <<<<<<<<<<<<<<
18521  *         return 'C'
18522  *     else:
18523  */
18524   __pyx_t_2 = ((abs_py_ssize_t(__pyx_v_c_stride) <= abs_py_ssize_t(__pyx_v_f_stride)) != 0);
18525   if (__pyx_t_2) {
18526 
18527     /* "View.MemoryView":1135
18528  *
18529  *     if abs_py_ssize_t(c_stride) <= abs_py_ssize_t(f_stride):
18530  *         return 'C'             # <<<<<<<<<<<<<<
18531  *     else:
18532  *         return 'F'
18533  */
18534     __pyx_r = 'C';
18535     goto __pyx_L0;
18536 
18537     /* "View.MemoryView":1134
18538  *             break
18539  *
18540  *     if abs_py_ssize_t(c_stride) <= abs_py_ssize_t(f_stride):             # <<<<<<<<<<<<<<
18541  *         return 'C'
18542  *     else:
18543  */
18544   }
18545 
18546   /* "View.MemoryView":1137
18547  *         return 'C'
18548  *     else:
18549  *         return 'F'             # <<<<<<<<<<<<<<
18550  *
18551  * @cython.cdivision(True)
18552  */
18553   /*else*/ {
18554     __pyx_r = 'F';
18555     goto __pyx_L0;
18556   }
18557 
18558   /* "View.MemoryView":1116
18559  *
18560  * @cname('__pyx_get_best_slice_order')
18561  * cdef char get_best_order(__Pyx_memviewslice *mslice, int ndim) nogil:             # <<<<<<<<<<<<<<
18562  *     """
18563  *     Figure out the best memory access order for a given slice.
18564  */
18565 
18566   /* function exit code */
18567   __pyx_L0:;
18568   return __pyx_r;
18569 }
18570 
18571 /* "View.MemoryView":1140
18572  *
18573  * @cython.cdivision(True)
18574  * cdef void _copy_strided_to_strided(char *src_data, Py_ssize_t *src_strides,             # <<<<<<<<<<<<<<
18575  *                                    char *dst_data, Py_ssize_t *dst_strides,
18576  *                                    Py_ssize_t *src_shape, Py_ssize_t *dst_shape,
18577  */
18578 
_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)18579 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) {
18580   CYTHON_UNUSED Py_ssize_t __pyx_v_i;
18581   CYTHON_UNUSED Py_ssize_t __pyx_v_src_extent;
18582   Py_ssize_t __pyx_v_dst_extent;
18583   Py_ssize_t __pyx_v_src_stride;
18584   Py_ssize_t __pyx_v_dst_stride;
18585   int __pyx_t_1;
18586   int __pyx_t_2;
18587   int __pyx_t_3;
18588   Py_ssize_t __pyx_t_4;
18589   Py_ssize_t __pyx_t_5;
18590   Py_ssize_t __pyx_t_6;
18591 
18592   /* "View.MemoryView":1147
18593  *
18594  *     cdef Py_ssize_t i
18595  *     cdef Py_ssize_t src_extent = src_shape[0]             # <<<<<<<<<<<<<<
18596  *     cdef Py_ssize_t dst_extent = dst_shape[0]
18597  *     cdef Py_ssize_t src_stride = src_strides[0]
18598  */
18599   __pyx_v_src_extent = (__pyx_v_src_shape[0]);
18600 
18601   /* "View.MemoryView":1148
18602  *     cdef Py_ssize_t i
18603  *     cdef Py_ssize_t src_extent = src_shape[0]
18604  *     cdef Py_ssize_t dst_extent = dst_shape[0]             # <<<<<<<<<<<<<<
18605  *     cdef Py_ssize_t src_stride = src_strides[0]
18606  *     cdef Py_ssize_t dst_stride = dst_strides[0]
18607  */
18608   __pyx_v_dst_extent = (__pyx_v_dst_shape[0]);
18609 
18610   /* "View.MemoryView":1149
18611  *     cdef Py_ssize_t src_extent = src_shape[0]
18612  *     cdef Py_ssize_t dst_extent = dst_shape[0]
18613  *     cdef Py_ssize_t src_stride = src_strides[0]             # <<<<<<<<<<<<<<
18614  *     cdef Py_ssize_t dst_stride = dst_strides[0]
18615  *
18616  */
18617   __pyx_v_src_stride = (__pyx_v_src_strides[0]);
18618 
18619   /* "View.MemoryView":1150
18620  *     cdef Py_ssize_t dst_extent = dst_shape[0]
18621  *     cdef Py_ssize_t src_stride = src_strides[0]
18622  *     cdef Py_ssize_t dst_stride = dst_strides[0]             # <<<<<<<<<<<<<<
18623  *
18624  *     if ndim == 1:
18625  */
18626   __pyx_v_dst_stride = (__pyx_v_dst_strides[0]);
18627 
18628   /* "View.MemoryView":1152
18629  *     cdef Py_ssize_t dst_stride = dst_strides[0]
18630  *
18631  *     if ndim == 1:             # <<<<<<<<<<<<<<
18632  *        if (src_stride > 0 and dst_stride > 0 and
18633  *            <size_t> src_stride == itemsize == <size_t> dst_stride):
18634  */
18635   __pyx_t_1 = ((__pyx_v_ndim == 1) != 0);
18636   if (__pyx_t_1) {
18637 
18638     /* "View.MemoryView":1153
18639  *
18640  *     if ndim == 1:
18641  *        if (src_stride > 0 and dst_stride > 0 and             # <<<<<<<<<<<<<<
18642  *            <size_t> src_stride == itemsize == <size_t> dst_stride):
18643  *            memcpy(dst_data, src_data, itemsize * dst_extent)
18644  */
18645     __pyx_t_2 = ((__pyx_v_src_stride > 0) != 0);
18646     if (__pyx_t_2) {
18647     } else {
18648       __pyx_t_1 = __pyx_t_2;
18649       goto __pyx_L5_bool_binop_done;
18650     }
18651     __pyx_t_2 = ((__pyx_v_dst_stride > 0) != 0);
18652     if (__pyx_t_2) {
18653     } else {
18654       __pyx_t_1 = __pyx_t_2;
18655       goto __pyx_L5_bool_binop_done;
18656     }
18657 
18658     /* "View.MemoryView":1154
18659  *     if ndim == 1:
18660  *        if (src_stride > 0 and dst_stride > 0 and
18661  *            <size_t> src_stride == itemsize == <size_t> dst_stride):             # <<<<<<<<<<<<<<
18662  *            memcpy(dst_data, src_data, itemsize * dst_extent)
18663  *        else:
18664  */
18665     __pyx_t_2 = (((size_t)__pyx_v_src_stride) == __pyx_v_itemsize);
18666     if (__pyx_t_2) {
18667       __pyx_t_2 = (__pyx_v_itemsize == ((size_t)__pyx_v_dst_stride));
18668     }
18669     __pyx_t_3 = (__pyx_t_2 != 0);
18670     __pyx_t_1 = __pyx_t_3;
18671     __pyx_L5_bool_binop_done:;
18672 
18673     /* "View.MemoryView":1153
18674  *
18675  *     if ndim == 1:
18676  *        if (src_stride > 0 and dst_stride > 0 and             # <<<<<<<<<<<<<<
18677  *            <size_t> src_stride == itemsize == <size_t> dst_stride):
18678  *            memcpy(dst_data, src_data, itemsize * dst_extent)
18679  */
18680     if (__pyx_t_1) {
18681 
18682       /* "View.MemoryView":1155
18683  *        if (src_stride > 0 and dst_stride > 0 and
18684  *            <size_t> src_stride == itemsize == <size_t> dst_stride):
18685  *            memcpy(dst_data, src_data, itemsize * dst_extent)             # <<<<<<<<<<<<<<
18686  *        else:
18687  *            for i in range(dst_extent):
18688  */
18689       (void)(memcpy(__pyx_v_dst_data, __pyx_v_src_data, (__pyx_v_itemsize * __pyx_v_dst_extent)));
18690 
18691       /* "View.MemoryView":1153
18692  *
18693  *     if ndim == 1:
18694  *        if (src_stride > 0 and dst_stride > 0 and             # <<<<<<<<<<<<<<
18695  *            <size_t> src_stride == itemsize == <size_t> dst_stride):
18696  *            memcpy(dst_data, src_data, itemsize * dst_extent)
18697  */
18698       goto __pyx_L4;
18699     }
18700 
18701     /* "View.MemoryView":1157
18702  *            memcpy(dst_data, src_data, itemsize * dst_extent)
18703  *        else:
18704  *            for i in range(dst_extent):             # <<<<<<<<<<<<<<
18705  *                memcpy(dst_data, src_data, itemsize)
18706  *                src_data += src_stride
18707  */
18708     /*else*/ {
18709       __pyx_t_4 = __pyx_v_dst_extent;
18710       __pyx_t_5 = __pyx_t_4;
18711       for (__pyx_t_6 = 0; __pyx_t_6 < __pyx_t_5; __pyx_t_6+=1) {
18712         __pyx_v_i = __pyx_t_6;
18713 
18714         /* "View.MemoryView":1158
18715  *        else:
18716  *            for i in range(dst_extent):
18717  *                memcpy(dst_data, src_data, itemsize)             # <<<<<<<<<<<<<<
18718  *                src_data += src_stride
18719  *                dst_data += dst_stride
18720  */
18721         (void)(memcpy(__pyx_v_dst_data, __pyx_v_src_data, __pyx_v_itemsize));
18722 
18723         /* "View.MemoryView":1159
18724  *            for i in range(dst_extent):
18725  *                memcpy(dst_data, src_data, itemsize)
18726  *                src_data += src_stride             # <<<<<<<<<<<<<<
18727  *                dst_data += dst_stride
18728  *     else:
18729  */
18730         __pyx_v_src_data = (__pyx_v_src_data + __pyx_v_src_stride);
18731 
18732         /* "View.MemoryView":1160
18733  *                memcpy(dst_data, src_data, itemsize)
18734  *                src_data += src_stride
18735  *                dst_data += dst_stride             # <<<<<<<<<<<<<<
18736  *     else:
18737  *         for i in range(dst_extent):
18738  */
18739         __pyx_v_dst_data = (__pyx_v_dst_data + __pyx_v_dst_stride);
18740       }
18741     }
18742     __pyx_L4:;
18743 
18744     /* "View.MemoryView":1152
18745  *     cdef Py_ssize_t dst_stride = dst_strides[0]
18746  *
18747  *     if ndim == 1:             # <<<<<<<<<<<<<<
18748  *        if (src_stride > 0 and dst_stride > 0 and
18749  *            <size_t> src_stride == itemsize == <size_t> dst_stride):
18750  */
18751     goto __pyx_L3;
18752   }
18753 
18754   /* "View.MemoryView":1162
18755  *                dst_data += dst_stride
18756  *     else:
18757  *         for i in range(dst_extent):             # <<<<<<<<<<<<<<
18758  *             _copy_strided_to_strided(src_data, src_strides + 1,
18759  *                                      dst_data, dst_strides + 1,
18760  */
18761   /*else*/ {
18762     __pyx_t_4 = __pyx_v_dst_extent;
18763     __pyx_t_5 = __pyx_t_4;
18764     for (__pyx_t_6 = 0; __pyx_t_6 < __pyx_t_5; __pyx_t_6+=1) {
18765       __pyx_v_i = __pyx_t_6;
18766 
18767       /* "View.MemoryView":1163
18768  *     else:
18769  *         for i in range(dst_extent):
18770  *             _copy_strided_to_strided(src_data, src_strides + 1,             # <<<<<<<<<<<<<<
18771  *                                      dst_data, dst_strides + 1,
18772  *                                      src_shape + 1, dst_shape + 1,
18773  */
18774       _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);
18775 
18776       /* "View.MemoryView":1167
18777  *                                      src_shape + 1, dst_shape + 1,
18778  *                                      ndim - 1, itemsize)
18779  *             src_data += src_stride             # <<<<<<<<<<<<<<
18780  *             dst_data += dst_stride
18781  *
18782  */
18783       __pyx_v_src_data = (__pyx_v_src_data + __pyx_v_src_stride);
18784 
18785       /* "View.MemoryView":1168
18786  *                                      ndim - 1, itemsize)
18787  *             src_data += src_stride
18788  *             dst_data += dst_stride             # <<<<<<<<<<<<<<
18789  *
18790  * cdef void copy_strided_to_strided(__Pyx_memviewslice *src,
18791  */
18792       __pyx_v_dst_data = (__pyx_v_dst_data + __pyx_v_dst_stride);
18793     }
18794   }
18795   __pyx_L3:;
18796 
18797   /* "View.MemoryView":1140
18798  *
18799  * @cython.cdivision(True)
18800  * cdef void _copy_strided_to_strided(char *src_data, Py_ssize_t *src_strides,             # <<<<<<<<<<<<<<
18801  *                                    char *dst_data, Py_ssize_t *dst_strides,
18802  *                                    Py_ssize_t *src_shape, Py_ssize_t *dst_shape,
18803  */
18804 
18805   /* function exit code */
18806 }
18807 
18808 /* "View.MemoryView":1170
18809  *             dst_data += dst_stride
18810  *
18811  * cdef void copy_strided_to_strided(__Pyx_memviewslice *src,             # <<<<<<<<<<<<<<
18812  *                                   __Pyx_memviewslice *dst,
18813  *                                   int ndim, size_t itemsize) nogil:
18814  */
18815 
copy_strided_to_strided(__Pyx_memviewslice * __pyx_v_src,__Pyx_memviewslice * __pyx_v_dst,int __pyx_v_ndim,size_t __pyx_v_itemsize)18816 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) {
18817 
18818   /* "View.MemoryView":1173
18819  *                                   __Pyx_memviewslice *dst,
18820  *                                   int ndim, size_t itemsize) nogil:
18821  *     _copy_strided_to_strided(src.data, src.strides, dst.data, dst.strides,             # <<<<<<<<<<<<<<
18822  *                              src.shape, dst.shape, ndim, itemsize)
18823  *
18824  */
18825   _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);
18826 
18827   /* "View.MemoryView":1170
18828  *             dst_data += dst_stride
18829  *
18830  * cdef void copy_strided_to_strided(__Pyx_memviewslice *src,             # <<<<<<<<<<<<<<
18831  *                                   __Pyx_memviewslice *dst,
18832  *                                   int ndim, size_t itemsize) nogil:
18833  */
18834 
18835   /* function exit code */
18836 }
18837 
18838 /* "View.MemoryView":1177
18839  *
18840  * @cname('__pyx_memoryview_slice_get_size')
18841  * cdef Py_ssize_t slice_get_size(__Pyx_memviewslice *src, int ndim) nogil:             # <<<<<<<<<<<<<<
18842  *     "Return the size of the memory occupied by the slice in number of bytes"
18843  *     cdef Py_ssize_t shape, size = src.memview.view.itemsize
18844  */
18845 
__pyx_memoryview_slice_get_size(__Pyx_memviewslice * __pyx_v_src,int __pyx_v_ndim)18846 static Py_ssize_t __pyx_memoryview_slice_get_size(__Pyx_memviewslice *__pyx_v_src, int __pyx_v_ndim) {
18847   Py_ssize_t __pyx_v_shape;
18848   Py_ssize_t __pyx_v_size;
18849   Py_ssize_t __pyx_r;
18850   Py_ssize_t __pyx_t_1;
18851   Py_ssize_t *__pyx_t_2;
18852   Py_ssize_t *__pyx_t_3;
18853   Py_ssize_t *__pyx_t_4;
18854 
18855   /* "View.MemoryView":1179
18856  * cdef Py_ssize_t slice_get_size(__Pyx_memviewslice *src, int ndim) nogil:
18857  *     "Return the size of the memory occupied by the slice in number of bytes"
18858  *     cdef Py_ssize_t shape, size = src.memview.view.itemsize             # <<<<<<<<<<<<<<
18859  *
18860  *     for shape in src.shape[:ndim]:
18861  */
18862   __pyx_t_1 = __pyx_v_src->memview->view.itemsize;
18863   __pyx_v_size = __pyx_t_1;
18864 
18865   /* "View.MemoryView":1181
18866  *     cdef Py_ssize_t shape, size = src.memview.view.itemsize
18867  *
18868  *     for shape in src.shape[:ndim]:             # <<<<<<<<<<<<<<
18869  *         size *= shape
18870  *
18871  */
18872   __pyx_t_3 = (__pyx_v_src->shape + __pyx_v_ndim);
18873   for (__pyx_t_4 = __pyx_v_src->shape; __pyx_t_4 < __pyx_t_3; __pyx_t_4++) {
18874     __pyx_t_2 = __pyx_t_4;
18875     __pyx_v_shape = (__pyx_t_2[0]);
18876 
18877     /* "View.MemoryView":1182
18878  *
18879  *     for shape in src.shape[:ndim]:
18880  *         size *= shape             # <<<<<<<<<<<<<<
18881  *
18882  *     return size
18883  */
18884     __pyx_v_size = (__pyx_v_size * __pyx_v_shape);
18885   }
18886 
18887   /* "View.MemoryView":1184
18888  *         size *= shape
18889  *
18890  *     return size             # <<<<<<<<<<<<<<
18891  *
18892  * @cname('__pyx_fill_contig_strides_array')
18893  */
18894   __pyx_r = __pyx_v_size;
18895   goto __pyx_L0;
18896 
18897   /* "View.MemoryView":1177
18898  *
18899  * @cname('__pyx_memoryview_slice_get_size')
18900  * cdef Py_ssize_t slice_get_size(__Pyx_memviewslice *src, int ndim) nogil:             # <<<<<<<<<<<<<<
18901  *     "Return the size of the memory occupied by the slice in number of bytes"
18902  *     cdef Py_ssize_t shape, size = src.memview.view.itemsize
18903  */
18904 
18905   /* function exit code */
18906   __pyx_L0:;
18907   return __pyx_r;
18908 }
18909 
18910 /* "View.MemoryView":1187
18911  *
18912  * @cname('__pyx_fill_contig_strides_array')
18913  * cdef Py_ssize_t fill_contig_strides_array(             # <<<<<<<<<<<<<<
18914  *                 Py_ssize_t *shape, Py_ssize_t *strides, Py_ssize_t stride,
18915  *                 int ndim, char order) nogil:
18916  */
18917 
__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)18918 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) {
18919   int __pyx_v_idx;
18920   Py_ssize_t __pyx_r;
18921   int __pyx_t_1;
18922   int __pyx_t_2;
18923   int __pyx_t_3;
18924   int __pyx_t_4;
18925 
18926   /* "View.MemoryView":1196
18927  *     cdef int idx
18928  *
18929  *     if order == 'F':             # <<<<<<<<<<<<<<
18930  *         for idx in range(ndim):
18931  *             strides[idx] = stride
18932  */
18933   __pyx_t_1 = ((__pyx_v_order == 'F') != 0);
18934   if (__pyx_t_1) {
18935 
18936     /* "View.MemoryView":1197
18937  *
18938  *     if order == 'F':
18939  *         for idx in range(ndim):             # <<<<<<<<<<<<<<
18940  *             strides[idx] = stride
18941  *             stride *= shape[idx]
18942  */
18943     __pyx_t_2 = __pyx_v_ndim;
18944     __pyx_t_3 = __pyx_t_2;
18945     for (__pyx_t_4 = 0; __pyx_t_4 < __pyx_t_3; __pyx_t_4+=1) {
18946       __pyx_v_idx = __pyx_t_4;
18947 
18948       /* "View.MemoryView":1198
18949  *     if order == 'F':
18950  *         for idx in range(ndim):
18951  *             strides[idx] = stride             # <<<<<<<<<<<<<<
18952  *             stride *= shape[idx]
18953  *     else:
18954  */
18955       (__pyx_v_strides[__pyx_v_idx]) = __pyx_v_stride;
18956 
18957       /* "View.MemoryView":1199
18958  *         for idx in range(ndim):
18959  *             strides[idx] = stride
18960  *             stride *= shape[idx]             # <<<<<<<<<<<<<<
18961  *     else:
18962  *         for idx in range(ndim - 1, -1, -1):
18963  */
18964       __pyx_v_stride = (__pyx_v_stride * (__pyx_v_shape[__pyx_v_idx]));
18965     }
18966 
18967     /* "View.MemoryView":1196
18968  *     cdef int idx
18969  *
18970  *     if order == 'F':             # <<<<<<<<<<<<<<
18971  *         for idx in range(ndim):
18972  *             strides[idx] = stride
18973  */
18974     goto __pyx_L3;
18975   }
18976 
18977   /* "View.MemoryView":1201
18978  *             stride *= shape[idx]
18979  *     else:
18980  *         for idx in range(ndim - 1, -1, -1):             # <<<<<<<<<<<<<<
18981  *             strides[idx] = stride
18982  *             stride *= shape[idx]
18983  */
18984   /*else*/ {
18985     for (__pyx_t_2 = (__pyx_v_ndim - 1); __pyx_t_2 > -1; __pyx_t_2-=1) {
18986       __pyx_v_idx = __pyx_t_2;
18987 
18988       /* "View.MemoryView":1202
18989  *     else:
18990  *         for idx in range(ndim - 1, -1, -1):
18991  *             strides[idx] = stride             # <<<<<<<<<<<<<<
18992  *             stride *= shape[idx]
18993  *
18994  */
18995       (__pyx_v_strides[__pyx_v_idx]) = __pyx_v_stride;
18996 
18997       /* "View.MemoryView":1203
18998  *         for idx in range(ndim - 1, -1, -1):
18999  *             strides[idx] = stride
19000  *             stride *= shape[idx]             # <<<<<<<<<<<<<<
19001  *
19002  *     return stride
19003  */
19004       __pyx_v_stride = (__pyx_v_stride * (__pyx_v_shape[__pyx_v_idx]));
19005     }
19006   }
19007   __pyx_L3:;
19008 
19009   /* "View.MemoryView":1205
19010  *             stride *= shape[idx]
19011  *
19012  *     return stride             # <<<<<<<<<<<<<<
19013  *
19014  * @cname('__pyx_memoryview_copy_data_to_temp')
19015  */
19016   __pyx_r = __pyx_v_stride;
19017   goto __pyx_L0;
19018 
19019   /* "View.MemoryView":1187
19020  *
19021  * @cname('__pyx_fill_contig_strides_array')
19022  * cdef Py_ssize_t fill_contig_strides_array(             # <<<<<<<<<<<<<<
19023  *                 Py_ssize_t *shape, Py_ssize_t *strides, Py_ssize_t stride,
19024  *                 int ndim, char order) nogil:
19025  */
19026 
19027   /* function exit code */
19028   __pyx_L0:;
19029   return __pyx_r;
19030 }
19031 
19032 /* "View.MemoryView":1208
19033  *
19034  * @cname('__pyx_memoryview_copy_data_to_temp')
19035  * cdef void *copy_data_to_temp(__Pyx_memviewslice *src,             # <<<<<<<<<<<<<<
19036  *                              __Pyx_memviewslice *tmpslice,
19037  *                              char order,
19038  */
19039 
__pyx_memoryview_copy_data_to_temp(__Pyx_memviewslice * __pyx_v_src,__Pyx_memviewslice * __pyx_v_tmpslice,char __pyx_v_order,int __pyx_v_ndim)19040 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) {
19041   int __pyx_v_i;
19042   void *__pyx_v_result;
19043   size_t __pyx_v_itemsize;
19044   size_t __pyx_v_size;
19045   void *__pyx_r;
19046   Py_ssize_t __pyx_t_1;
19047   int __pyx_t_2;
19048   int __pyx_t_3;
19049   struct __pyx_memoryview_obj *__pyx_t_4;
19050   int __pyx_t_5;
19051   int __pyx_t_6;
19052   int __pyx_lineno = 0;
19053   const char *__pyx_filename = NULL;
19054   int __pyx_clineno = 0;
19055 
19056   /* "View.MemoryView":1219
19057  *     cdef void *result
19058  *
19059  *     cdef size_t itemsize = src.memview.view.itemsize             # <<<<<<<<<<<<<<
19060  *     cdef size_t size = slice_get_size(src, ndim)
19061  *
19062  */
19063   __pyx_t_1 = __pyx_v_src->memview->view.itemsize;
19064   __pyx_v_itemsize = __pyx_t_1;
19065 
19066   /* "View.MemoryView":1220
19067  *
19068  *     cdef size_t itemsize = src.memview.view.itemsize
19069  *     cdef size_t size = slice_get_size(src, ndim)             # <<<<<<<<<<<<<<
19070  *
19071  *     result = malloc(size)
19072  */
19073   __pyx_v_size = __pyx_memoryview_slice_get_size(__pyx_v_src, __pyx_v_ndim);
19074 
19075   /* "View.MemoryView":1222
19076  *     cdef size_t size = slice_get_size(src, ndim)
19077  *
19078  *     result = malloc(size)             # <<<<<<<<<<<<<<
19079  *     if not result:
19080  *         _err(MemoryError, NULL)
19081  */
19082   __pyx_v_result = malloc(__pyx_v_size);
19083 
19084   /* "View.MemoryView":1223
19085  *
19086  *     result = malloc(size)
19087  *     if not result:             # <<<<<<<<<<<<<<
19088  *         _err(MemoryError, NULL)
19089  *
19090  */
19091   __pyx_t_2 = ((!(__pyx_v_result != 0)) != 0);
19092   if (__pyx_t_2) {
19093 
19094     /* "View.MemoryView":1224
19095  *     result = malloc(size)
19096  *     if not result:
19097  *         _err(MemoryError, NULL)             # <<<<<<<<<<<<<<
19098  *
19099  *
19100  */
19101     __pyx_t_3 = __pyx_memoryview_err(__pyx_builtin_MemoryError, NULL); if (unlikely(__pyx_t_3 == ((int)-1))) __PYX_ERR(2, 1224, __pyx_L1_error)
19102 
19103     /* "View.MemoryView":1223
19104  *
19105  *     result = malloc(size)
19106  *     if not result:             # <<<<<<<<<<<<<<
19107  *         _err(MemoryError, NULL)
19108  *
19109  */
19110   }
19111 
19112   /* "View.MemoryView":1227
19113  *
19114  *
19115  *     tmpslice.data = <char *> result             # <<<<<<<<<<<<<<
19116  *     tmpslice.memview = src.memview
19117  *     for i in range(ndim):
19118  */
19119   __pyx_v_tmpslice->data = ((char *)__pyx_v_result);
19120 
19121   /* "View.MemoryView":1228
19122  *
19123  *     tmpslice.data = <char *> result
19124  *     tmpslice.memview = src.memview             # <<<<<<<<<<<<<<
19125  *     for i in range(ndim):
19126  *         tmpslice.shape[i] = src.shape[i]
19127  */
19128   __pyx_t_4 = __pyx_v_src->memview;
19129   __pyx_v_tmpslice->memview = __pyx_t_4;
19130 
19131   /* "View.MemoryView":1229
19132  *     tmpslice.data = <char *> result
19133  *     tmpslice.memview = src.memview
19134  *     for i in range(ndim):             # <<<<<<<<<<<<<<
19135  *         tmpslice.shape[i] = src.shape[i]
19136  *         tmpslice.suboffsets[i] = -1
19137  */
19138   __pyx_t_3 = __pyx_v_ndim;
19139   __pyx_t_5 = __pyx_t_3;
19140   for (__pyx_t_6 = 0; __pyx_t_6 < __pyx_t_5; __pyx_t_6+=1) {
19141     __pyx_v_i = __pyx_t_6;
19142 
19143     /* "View.MemoryView":1230
19144  *     tmpslice.memview = src.memview
19145  *     for i in range(ndim):
19146  *         tmpslice.shape[i] = src.shape[i]             # <<<<<<<<<<<<<<
19147  *         tmpslice.suboffsets[i] = -1
19148  *
19149  */
19150     (__pyx_v_tmpslice->shape[__pyx_v_i]) = (__pyx_v_src->shape[__pyx_v_i]);
19151 
19152     /* "View.MemoryView":1231
19153  *     for i in range(ndim):
19154  *         tmpslice.shape[i] = src.shape[i]
19155  *         tmpslice.suboffsets[i] = -1             # <<<<<<<<<<<<<<
19156  *
19157  *     fill_contig_strides_array(&tmpslice.shape[0], &tmpslice.strides[0], itemsize,
19158  */
19159     (__pyx_v_tmpslice->suboffsets[__pyx_v_i]) = -1L;
19160   }
19161 
19162   /* "View.MemoryView":1233
19163  *         tmpslice.suboffsets[i] = -1
19164  *
19165  *     fill_contig_strides_array(&tmpslice.shape[0], &tmpslice.strides[0], itemsize,             # <<<<<<<<<<<<<<
19166  *                               ndim, order)
19167  *
19168  */
19169   (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));
19170 
19171   /* "View.MemoryView":1237
19172  *
19173  *
19174  *     for i in range(ndim):             # <<<<<<<<<<<<<<
19175  *         if tmpslice.shape[i] == 1:
19176  *             tmpslice.strides[i] = 0
19177  */
19178   __pyx_t_3 = __pyx_v_ndim;
19179   __pyx_t_5 = __pyx_t_3;
19180   for (__pyx_t_6 = 0; __pyx_t_6 < __pyx_t_5; __pyx_t_6+=1) {
19181     __pyx_v_i = __pyx_t_6;
19182 
19183     /* "View.MemoryView":1238
19184  *
19185  *     for i in range(ndim):
19186  *         if tmpslice.shape[i] == 1:             # <<<<<<<<<<<<<<
19187  *             tmpslice.strides[i] = 0
19188  *
19189  */
19190     __pyx_t_2 = (((__pyx_v_tmpslice->shape[__pyx_v_i]) == 1) != 0);
19191     if (__pyx_t_2) {
19192 
19193       /* "View.MemoryView":1239
19194  *     for i in range(ndim):
19195  *         if tmpslice.shape[i] == 1:
19196  *             tmpslice.strides[i] = 0             # <<<<<<<<<<<<<<
19197  *
19198  *     if slice_is_contig(src[0], order, ndim):
19199  */
19200       (__pyx_v_tmpslice->strides[__pyx_v_i]) = 0;
19201 
19202       /* "View.MemoryView":1238
19203  *
19204  *     for i in range(ndim):
19205  *         if tmpslice.shape[i] == 1:             # <<<<<<<<<<<<<<
19206  *             tmpslice.strides[i] = 0
19207  *
19208  */
19209     }
19210   }
19211 
19212   /* "View.MemoryView":1241
19213  *             tmpslice.strides[i] = 0
19214  *
19215  *     if slice_is_contig(src[0], order, ndim):             # <<<<<<<<<<<<<<
19216  *         memcpy(result, src.data, size)
19217  *     else:
19218  */
19219   __pyx_t_2 = (__pyx_memviewslice_is_contig((__pyx_v_src[0]), __pyx_v_order, __pyx_v_ndim) != 0);
19220   if (__pyx_t_2) {
19221 
19222     /* "View.MemoryView":1242
19223  *
19224  *     if slice_is_contig(src[0], order, ndim):
19225  *         memcpy(result, src.data, size)             # <<<<<<<<<<<<<<
19226  *     else:
19227  *         copy_strided_to_strided(src, tmpslice, ndim, itemsize)
19228  */
19229     (void)(memcpy(__pyx_v_result, __pyx_v_src->data, __pyx_v_size));
19230 
19231     /* "View.MemoryView":1241
19232  *             tmpslice.strides[i] = 0
19233  *
19234  *     if slice_is_contig(src[0], order, ndim):             # <<<<<<<<<<<<<<
19235  *         memcpy(result, src.data, size)
19236  *     else:
19237  */
19238     goto __pyx_L9;
19239   }
19240 
19241   /* "View.MemoryView":1244
19242  *         memcpy(result, src.data, size)
19243  *     else:
19244  *         copy_strided_to_strided(src, tmpslice, ndim, itemsize)             # <<<<<<<<<<<<<<
19245  *
19246  *     return result
19247  */
19248   /*else*/ {
19249     copy_strided_to_strided(__pyx_v_src, __pyx_v_tmpslice, __pyx_v_ndim, __pyx_v_itemsize);
19250   }
19251   __pyx_L9:;
19252 
19253   /* "View.MemoryView":1246
19254  *         copy_strided_to_strided(src, tmpslice, ndim, itemsize)
19255  *
19256  *     return result             # <<<<<<<<<<<<<<
19257  *
19258  *
19259  */
19260   __pyx_r = __pyx_v_result;
19261   goto __pyx_L0;
19262 
19263   /* "View.MemoryView":1208
19264  *
19265  * @cname('__pyx_memoryview_copy_data_to_temp')
19266  * cdef void *copy_data_to_temp(__Pyx_memviewslice *src,             # <<<<<<<<<<<<<<
19267  *                              __Pyx_memviewslice *tmpslice,
19268  *                              char order,
19269  */
19270 
19271   /* function exit code */
19272   __pyx_L1_error:;
19273   {
19274     #ifdef WITH_THREAD
19275     PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure();
19276     #endif
19277     __Pyx_AddTraceback("View.MemoryView.copy_data_to_temp", __pyx_clineno, __pyx_lineno, __pyx_filename);
19278     #ifdef WITH_THREAD
19279     __Pyx_PyGILState_Release(__pyx_gilstate_save);
19280     #endif
19281   }
19282   __pyx_r = NULL;
19283   __pyx_L0:;
19284   return __pyx_r;
19285 }
19286 
19287 /* "View.MemoryView":1251
19288  *
19289  * @cname('__pyx_memoryview_err_extents')
19290  * cdef int _err_extents(int i, Py_ssize_t extent1,             # <<<<<<<<<<<<<<
19291  *                              Py_ssize_t extent2) except -1 with gil:
19292  *     raise ValueError("got differing extents in dimension %d (got %d and %d)" %
19293  */
19294 
__pyx_memoryview_err_extents(int __pyx_v_i,Py_ssize_t __pyx_v_extent1,Py_ssize_t __pyx_v_extent2)19295 static int __pyx_memoryview_err_extents(int __pyx_v_i, Py_ssize_t __pyx_v_extent1, Py_ssize_t __pyx_v_extent2) {
19296   int __pyx_r;
19297   __Pyx_RefNannyDeclarations
19298   PyObject *__pyx_t_1 = NULL;
19299   PyObject *__pyx_t_2 = NULL;
19300   PyObject *__pyx_t_3 = NULL;
19301   PyObject *__pyx_t_4 = NULL;
19302   int __pyx_lineno = 0;
19303   const char *__pyx_filename = NULL;
19304   int __pyx_clineno = 0;
19305   #ifdef WITH_THREAD
19306   PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure();
19307   #endif
19308   __Pyx_RefNannySetupContext("_err_extents", 0);
19309 
19310   /* "View.MemoryView":1254
19311  *                              Py_ssize_t extent2) except -1 with gil:
19312  *     raise ValueError("got differing extents in dimension %d (got %d and %d)" %
19313  *                                                         (i, extent1, extent2))             # <<<<<<<<<<<<<<
19314  *
19315  * @cname('__pyx_memoryview_err_dim')
19316  */
19317   __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_i); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 1254, __pyx_L1_error)
19318   __Pyx_GOTREF(__pyx_t_1);
19319   __pyx_t_2 = PyInt_FromSsize_t(__pyx_v_extent1); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 1254, __pyx_L1_error)
19320   __Pyx_GOTREF(__pyx_t_2);
19321   __pyx_t_3 = PyInt_FromSsize_t(__pyx_v_extent2); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 1254, __pyx_L1_error)
19322   __Pyx_GOTREF(__pyx_t_3);
19323   __pyx_t_4 = PyTuple_New(3); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 1254, __pyx_L1_error)
19324   __Pyx_GOTREF(__pyx_t_4);
19325   __Pyx_GIVEREF(__pyx_t_1);
19326   PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_1);
19327   __Pyx_GIVEREF(__pyx_t_2);
19328   PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_2);
19329   __Pyx_GIVEREF(__pyx_t_3);
19330   PyTuple_SET_ITEM(__pyx_t_4, 2, __pyx_t_3);
19331   __pyx_t_1 = 0;
19332   __pyx_t_2 = 0;
19333   __pyx_t_3 = 0;
19334 
19335   /* "View.MemoryView":1253
19336  * cdef int _err_extents(int i, Py_ssize_t extent1,
19337  *                              Py_ssize_t extent2) except -1 with gil:
19338  *     raise ValueError("got differing extents in dimension %d (got %d and %d)" %             # <<<<<<<<<<<<<<
19339  *                                                         (i, extent1, extent2))
19340  *
19341  */
19342   __pyx_t_3 = __Pyx_PyString_Format(__pyx_kp_s_got_differing_extents_in_dimensi, __pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 1253, __pyx_L1_error)
19343   __Pyx_GOTREF(__pyx_t_3);
19344   __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
19345   __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_builtin_ValueError, __pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 1253, __pyx_L1_error)
19346   __Pyx_GOTREF(__pyx_t_4);
19347   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
19348   __Pyx_Raise(__pyx_t_4, 0, 0, 0);
19349   __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
19350   __PYX_ERR(2, 1253, __pyx_L1_error)
19351 
19352   /* "View.MemoryView":1251
19353  *
19354  * @cname('__pyx_memoryview_err_extents')
19355  * cdef int _err_extents(int i, Py_ssize_t extent1,             # <<<<<<<<<<<<<<
19356  *                              Py_ssize_t extent2) except -1 with gil:
19357  *     raise ValueError("got differing extents in dimension %d (got %d and %d)" %
19358  */
19359 
19360   /* function exit code */
19361   __pyx_L1_error:;
19362   __Pyx_XDECREF(__pyx_t_1);
19363   __Pyx_XDECREF(__pyx_t_2);
19364   __Pyx_XDECREF(__pyx_t_3);
19365   __Pyx_XDECREF(__pyx_t_4);
19366   __Pyx_AddTraceback("View.MemoryView._err_extents", __pyx_clineno, __pyx_lineno, __pyx_filename);
19367   __pyx_r = -1;
19368   __Pyx_RefNannyFinishContext();
19369   #ifdef WITH_THREAD
19370   __Pyx_PyGILState_Release(__pyx_gilstate_save);
19371   #endif
19372   return __pyx_r;
19373 }
19374 
19375 /* "View.MemoryView":1257
19376  *
19377  * @cname('__pyx_memoryview_err_dim')
19378  * cdef int _err_dim(object error, char *msg, int dim) except -1 with gil:             # <<<<<<<<<<<<<<
19379  *     raise error(msg.decode('ascii') % dim)
19380  *
19381  */
19382 
__pyx_memoryview_err_dim(PyObject * __pyx_v_error,char * __pyx_v_msg,int __pyx_v_dim)19383 static int __pyx_memoryview_err_dim(PyObject *__pyx_v_error, char *__pyx_v_msg, int __pyx_v_dim) {
19384   int __pyx_r;
19385   __Pyx_RefNannyDeclarations
19386   PyObject *__pyx_t_1 = NULL;
19387   PyObject *__pyx_t_2 = NULL;
19388   PyObject *__pyx_t_3 = NULL;
19389   PyObject *__pyx_t_4 = NULL;
19390   int __pyx_lineno = 0;
19391   const char *__pyx_filename = NULL;
19392   int __pyx_clineno = 0;
19393   #ifdef WITH_THREAD
19394   PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure();
19395   #endif
19396   __Pyx_RefNannySetupContext("_err_dim", 0);
19397   __Pyx_INCREF(__pyx_v_error);
19398 
19399   /* "View.MemoryView":1258
19400  * @cname('__pyx_memoryview_err_dim')
19401  * cdef int _err_dim(object error, char *msg, int dim) except -1 with gil:
19402  *     raise error(msg.decode('ascii') % dim)             # <<<<<<<<<<<<<<
19403  *
19404  * @cname('__pyx_memoryview_err')
19405  */
19406   __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(2, 1258, __pyx_L1_error)
19407   __Pyx_GOTREF(__pyx_t_2);
19408   __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_dim); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 1258, __pyx_L1_error)
19409   __Pyx_GOTREF(__pyx_t_3);
19410   __pyx_t_4 = PyUnicode_Format(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 1258, __pyx_L1_error)
19411   __Pyx_GOTREF(__pyx_t_4);
19412   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
19413   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
19414   __Pyx_INCREF(__pyx_v_error);
19415   __pyx_t_3 = __pyx_v_error; __pyx_t_2 = NULL;
19416   if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
19417     __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3);
19418     if (likely(__pyx_t_2)) {
19419       PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
19420       __Pyx_INCREF(__pyx_t_2);
19421       __Pyx_INCREF(function);
19422       __Pyx_DECREF_SET(__pyx_t_3, function);
19423     }
19424   }
19425   __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);
19426   __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
19427   __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
19428   if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 1258, __pyx_L1_error)
19429   __Pyx_GOTREF(__pyx_t_1);
19430   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
19431   __Pyx_Raise(__pyx_t_1, 0, 0, 0);
19432   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
19433   __PYX_ERR(2, 1258, __pyx_L1_error)
19434 
19435   /* "View.MemoryView":1257
19436  *
19437  * @cname('__pyx_memoryview_err_dim')
19438  * cdef int _err_dim(object error, char *msg, int dim) except -1 with gil:             # <<<<<<<<<<<<<<
19439  *     raise error(msg.decode('ascii') % dim)
19440  *
19441  */
19442 
19443   /* function exit code */
19444   __pyx_L1_error:;
19445   __Pyx_XDECREF(__pyx_t_1);
19446   __Pyx_XDECREF(__pyx_t_2);
19447   __Pyx_XDECREF(__pyx_t_3);
19448   __Pyx_XDECREF(__pyx_t_4);
19449   __Pyx_AddTraceback("View.MemoryView._err_dim", __pyx_clineno, __pyx_lineno, __pyx_filename);
19450   __pyx_r = -1;
19451   __Pyx_XDECREF(__pyx_v_error);
19452   __Pyx_RefNannyFinishContext();
19453   #ifdef WITH_THREAD
19454   __Pyx_PyGILState_Release(__pyx_gilstate_save);
19455   #endif
19456   return __pyx_r;
19457 }
19458 
19459 /* "View.MemoryView":1261
19460  *
19461  * @cname('__pyx_memoryview_err')
19462  * cdef int _err(object error, char *msg) except -1 with gil:             # <<<<<<<<<<<<<<
19463  *     if msg != NULL:
19464  *         raise error(msg.decode('ascii'))
19465  */
19466 
__pyx_memoryview_err(PyObject * __pyx_v_error,char * __pyx_v_msg)19467 static int __pyx_memoryview_err(PyObject *__pyx_v_error, char *__pyx_v_msg) {
19468   int __pyx_r;
19469   __Pyx_RefNannyDeclarations
19470   int __pyx_t_1;
19471   PyObject *__pyx_t_2 = NULL;
19472   PyObject *__pyx_t_3 = NULL;
19473   PyObject *__pyx_t_4 = NULL;
19474   PyObject *__pyx_t_5 = NULL;
19475   int __pyx_lineno = 0;
19476   const char *__pyx_filename = NULL;
19477   int __pyx_clineno = 0;
19478   #ifdef WITH_THREAD
19479   PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure();
19480   #endif
19481   __Pyx_RefNannySetupContext("_err", 0);
19482   __Pyx_INCREF(__pyx_v_error);
19483 
19484   /* "View.MemoryView":1262
19485  * @cname('__pyx_memoryview_err')
19486  * cdef int _err(object error, char *msg) except -1 with gil:
19487  *     if msg != NULL:             # <<<<<<<<<<<<<<
19488  *         raise error(msg.decode('ascii'))
19489  *     else:
19490  */
19491   __pyx_t_1 = ((__pyx_v_msg != NULL) != 0);
19492   if (unlikely(__pyx_t_1)) {
19493 
19494     /* "View.MemoryView":1263
19495  * cdef int _err(object error, char *msg) except -1 with gil:
19496  *     if msg != NULL:
19497  *         raise error(msg.decode('ascii'))             # <<<<<<<<<<<<<<
19498  *     else:
19499  *         raise error
19500  */
19501     __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(2, 1263, __pyx_L1_error)
19502     __Pyx_GOTREF(__pyx_t_3);
19503     __Pyx_INCREF(__pyx_v_error);
19504     __pyx_t_4 = __pyx_v_error; __pyx_t_5 = NULL;
19505     if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_4))) {
19506       __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4);
19507       if (likely(__pyx_t_5)) {
19508         PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
19509         __Pyx_INCREF(__pyx_t_5);
19510         __Pyx_INCREF(function);
19511         __Pyx_DECREF_SET(__pyx_t_4, function);
19512       }
19513     }
19514     __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);
19515     __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
19516     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
19517     if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 1263, __pyx_L1_error)
19518     __Pyx_GOTREF(__pyx_t_2);
19519     __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
19520     __Pyx_Raise(__pyx_t_2, 0, 0, 0);
19521     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
19522     __PYX_ERR(2, 1263, __pyx_L1_error)
19523 
19524     /* "View.MemoryView":1262
19525  * @cname('__pyx_memoryview_err')
19526  * cdef int _err(object error, char *msg) except -1 with gil:
19527  *     if msg != NULL:             # <<<<<<<<<<<<<<
19528  *         raise error(msg.decode('ascii'))
19529  *     else:
19530  */
19531   }
19532 
19533   /* "View.MemoryView":1265
19534  *         raise error(msg.decode('ascii'))
19535  *     else:
19536  *         raise error             # <<<<<<<<<<<<<<
19537  *
19538  * @cname('__pyx_memoryview_copy_contents')
19539  */
19540   /*else*/ {
19541     __Pyx_Raise(__pyx_v_error, 0, 0, 0);
19542     __PYX_ERR(2, 1265, __pyx_L1_error)
19543   }
19544 
19545   /* "View.MemoryView":1261
19546  *
19547  * @cname('__pyx_memoryview_err')
19548  * cdef int _err(object error, char *msg) except -1 with gil:             # <<<<<<<<<<<<<<
19549  *     if msg != NULL:
19550  *         raise error(msg.decode('ascii'))
19551  */
19552 
19553   /* function exit code */
19554   __pyx_L1_error:;
19555   __Pyx_XDECREF(__pyx_t_2);
19556   __Pyx_XDECREF(__pyx_t_3);
19557   __Pyx_XDECREF(__pyx_t_4);
19558   __Pyx_XDECREF(__pyx_t_5);
19559   __Pyx_AddTraceback("View.MemoryView._err", __pyx_clineno, __pyx_lineno, __pyx_filename);
19560   __pyx_r = -1;
19561   __Pyx_XDECREF(__pyx_v_error);
19562   __Pyx_RefNannyFinishContext();
19563   #ifdef WITH_THREAD
19564   __Pyx_PyGILState_Release(__pyx_gilstate_save);
19565   #endif
19566   return __pyx_r;
19567 }
19568 
19569 /* "View.MemoryView":1268
19570  *
19571  * @cname('__pyx_memoryview_copy_contents')
19572  * cdef int memoryview_copy_contents(__Pyx_memviewslice src,             # <<<<<<<<<<<<<<
19573  *                                   __Pyx_memviewslice dst,
19574  *                                   int src_ndim, int dst_ndim,
19575  */
19576 
__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)19577 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) {
19578   void *__pyx_v_tmpdata;
19579   size_t __pyx_v_itemsize;
19580   int __pyx_v_i;
19581   char __pyx_v_order;
19582   int __pyx_v_broadcasting;
19583   int __pyx_v_direct_copy;
19584   __Pyx_memviewslice __pyx_v_tmp;
19585   int __pyx_v_ndim;
19586   int __pyx_r;
19587   Py_ssize_t __pyx_t_1;
19588   int __pyx_t_2;
19589   int __pyx_t_3;
19590   int __pyx_t_4;
19591   int __pyx_t_5;
19592   int __pyx_t_6;
19593   void *__pyx_t_7;
19594   int __pyx_t_8;
19595   int __pyx_lineno = 0;
19596   const char *__pyx_filename = NULL;
19597   int __pyx_clineno = 0;
19598 
19599   /* "View.MemoryView":1276
19600  *     Check for overlapping memory and verify the shapes.
19601  *     """
19602  *     cdef void *tmpdata = NULL             # <<<<<<<<<<<<<<
19603  *     cdef size_t itemsize = src.memview.view.itemsize
19604  *     cdef int i
19605  */
19606   __pyx_v_tmpdata = NULL;
19607 
19608   /* "View.MemoryView":1277
19609  *     """
19610  *     cdef void *tmpdata = NULL
19611  *     cdef size_t itemsize = src.memview.view.itemsize             # <<<<<<<<<<<<<<
19612  *     cdef int i
19613  *     cdef char order = get_best_order(&src, src_ndim)
19614  */
19615   __pyx_t_1 = __pyx_v_src.memview->view.itemsize;
19616   __pyx_v_itemsize = __pyx_t_1;
19617 
19618   /* "View.MemoryView":1279
19619  *     cdef size_t itemsize = src.memview.view.itemsize
19620  *     cdef int i
19621  *     cdef char order = get_best_order(&src, src_ndim)             # <<<<<<<<<<<<<<
19622  *     cdef bint broadcasting = False
19623  *     cdef bint direct_copy = False
19624  */
19625   __pyx_v_order = __pyx_get_best_slice_order((&__pyx_v_src), __pyx_v_src_ndim);
19626 
19627   /* "View.MemoryView":1280
19628  *     cdef int i
19629  *     cdef char order = get_best_order(&src, src_ndim)
19630  *     cdef bint broadcasting = False             # <<<<<<<<<<<<<<
19631  *     cdef bint direct_copy = False
19632  *     cdef __Pyx_memviewslice tmp
19633  */
19634   __pyx_v_broadcasting = 0;
19635 
19636   /* "View.MemoryView":1281
19637  *     cdef char order = get_best_order(&src, src_ndim)
19638  *     cdef bint broadcasting = False
19639  *     cdef bint direct_copy = False             # <<<<<<<<<<<<<<
19640  *     cdef __Pyx_memviewslice tmp
19641  *
19642  */
19643   __pyx_v_direct_copy = 0;
19644 
19645   /* "View.MemoryView":1284
19646  *     cdef __Pyx_memviewslice tmp
19647  *
19648  *     if src_ndim < dst_ndim:             # <<<<<<<<<<<<<<
19649  *         broadcast_leading(&src, src_ndim, dst_ndim)
19650  *     elif dst_ndim < src_ndim:
19651  */
19652   __pyx_t_2 = ((__pyx_v_src_ndim < __pyx_v_dst_ndim) != 0);
19653   if (__pyx_t_2) {
19654 
19655     /* "View.MemoryView":1285
19656  *
19657  *     if src_ndim < dst_ndim:
19658  *         broadcast_leading(&src, src_ndim, dst_ndim)             # <<<<<<<<<<<<<<
19659  *     elif dst_ndim < src_ndim:
19660  *         broadcast_leading(&dst, dst_ndim, src_ndim)
19661  */
19662     __pyx_memoryview_broadcast_leading((&__pyx_v_src), __pyx_v_src_ndim, __pyx_v_dst_ndim);
19663 
19664     /* "View.MemoryView":1284
19665  *     cdef __Pyx_memviewslice tmp
19666  *
19667  *     if src_ndim < dst_ndim:             # <<<<<<<<<<<<<<
19668  *         broadcast_leading(&src, src_ndim, dst_ndim)
19669  *     elif dst_ndim < src_ndim:
19670  */
19671     goto __pyx_L3;
19672   }
19673 
19674   /* "View.MemoryView":1286
19675  *     if src_ndim < dst_ndim:
19676  *         broadcast_leading(&src, src_ndim, dst_ndim)
19677  *     elif dst_ndim < src_ndim:             # <<<<<<<<<<<<<<
19678  *         broadcast_leading(&dst, dst_ndim, src_ndim)
19679  *
19680  */
19681   __pyx_t_2 = ((__pyx_v_dst_ndim < __pyx_v_src_ndim) != 0);
19682   if (__pyx_t_2) {
19683 
19684     /* "View.MemoryView":1287
19685  *         broadcast_leading(&src, src_ndim, dst_ndim)
19686  *     elif dst_ndim < src_ndim:
19687  *         broadcast_leading(&dst, dst_ndim, src_ndim)             # <<<<<<<<<<<<<<
19688  *
19689  *     cdef int ndim = max(src_ndim, dst_ndim)
19690  */
19691     __pyx_memoryview_broadcast_leading((&__pyx_v_dst), __pyx_v_dst_ndim, __pyx_v_src_ndim);
19692 
19693     /* "View.MemoryView":1286
19694  *     if src_ndim < dst_ndim:
19695  *         broadcast_leading(&src, src_ndim, dst_ndim)
19696  *     elif dst_ndim < src_ndim:             # <<<<<<<<<<<<<<
19697  *         broadcast_leading(&dst, dst_ndim, src_ndim)
19698  *
19699  */
19700   }
19701   __pyx_L3:;
19702 
19703   /* "View.MemoryView":1289
19704  *         broadcast_leading(&dst, dst_ndim, src_ndim)
19705  *
19706  *     cdef int ndim = max(src_ndim, dst_ndim)             # <<<<<<<<<<<<<<
19707  *
19708  *     for i in range(ndim):
19709  */
19710   __pyx_t_3 = __pyx_v_dst_ndim;
19711   __pyx_t_4 = __pyx_v_src_ndim;
19712   if (((__pyx_t_3 > __pyx_t_4) != 0)) {
19713     __pyx_t_5 = __pyx_t_3;
19714   } else {
19715     __pyx_t_5 = __pyx_t_4;
19716   }
19717   __pyx_v_ndim = __pyx_t_5;
19718 
19719   /* "View.MemoryView":1291
19720  *     cdef int ndim = max(src_ndim, dst_ndim)
19721  *
19722  *     for i in range(ndim):             # <<<<<<<<<<<<<<
19723  *         if src.shape[i] != dst.shape[i]:
19724  *             if src.shape[i] == 1:
19725  */
19726   __pyx_t_5 = __pyx_v_ndim;
19727   __pyx_t_3 = __pyx_t_5;
19728   for (__pyx_t_4 = 0; __pyx_t_4 < __pyx_t_3; __pyx_t_4+=1) {
19729     __pyx_v_i = __pyx_t_4;
19730 
19731     /* "View.MemoryView":1292
19732  *
19733  *     for i in range(ndim):
19734  *         if src.shape[i] != dst.shape[i]:             # <<<<<<<<<<<<<<
19735  *             if src.shape[i] == 1:
19736  *                 broadcasting = True
19737  */
19738     __pyx_t_2 = (((__pyx_v_src.shape[__pyx_v_i]) != (__pyx_v_dst.shape[__pyx_v_i])) != 0);
19739     if (__pyx_t_2) {
19740 
19741       /* "View.MemoryView":1293
19742  *     for i in range(ndim):
19743  *         if src.shape[i] != dst.shape[i]:
19744  *             if src.shape[i] == 1:             # <<<<<<<<<<<<<<
19745  *                 broadcasting = True
19746  *                 src.strides[i] = 0
19747  */
19748       __pyx_t_2 = (((__pyx_v_src.shape[__pyx_v_i]) == 1) != 0);
19749       if (__pyx_t_2) {
19750 
19751         /* "View.MemoryView":1294
19752  *         if src.shape[i] != dst.shape[i]:
19753  *             if src.shape[i] == 1:
19754  *                 broadcasting = True             # <<<<<<<<<<<<<<
19755  *                 src.strides[i] = 0
19756  *             else:
19757  */
19758         __pyx_v_broadcasting = 1;
19759 
19760         /* "View.MemoryView":1295
19761  *             if src.shape[i] == 1:
19762  *                 broadcasting = True
19763  *                 src.strides[i] = 0             # <<<<<<<<<<<<<<
19764  *             else:
19765  *                 _err_extents(i, dst.shape[i], src.shape[i])
19766  */
19767         (__pyx_v_src.strides[__pyx_v_i]) = 0;
19768 
19769         /* "View.MemoryView":1293
19770  *     for i in range(ndim):
19771  *         if src.shape[i] != dst.shape[i]:
19772  *             if src.shape[i] == 1:             # <<<<<<<<<<<<<<
19773  *                 broadcasting = True
19774  *                 src.strides[i] = 0
19775  */
19776         goto __pyx_L7;
19777       }
19778 
19779       /* "View.MemoryView":1297
19780  *                 src.strides[i] = 0
19781  *             else:
19782  *                 _err_extents(i, dst.shape[i], src.shape[i])             # <<<<<<<<<<<<<<
19783  *
19784  *         if src.suboffsets[i] >= 0:
19785  */
19786       /*else*/ {
19787         __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(2, 1297, __pyx_L1_error)
19788       }
19789       __pyx_L7:;
19790 
19791       /* "View.MemoryView":1292
19792  *
19793  *     for i in range(ndim):
19794  *         if src.shape[i] != dst.shape[i]:             # <<<<<<<<<<<<<<
19795  *             if src.shape[i] == 1:
19796  *                 broadcasting = True
19797  */
19798     }
19799 
19800     /* "View.MemoryView":1299
19801  *                 _err_extents(i, dst.shape[i], src.shape[i])
19802  *
19803  *         if src.suboffsets[i] >= 0:             # <<<<<<<<<<<<<<
19804  *             _err_dim(ValueError, "Dimension %d is not direct", i)
19805  *
19806  */
19807     __pyx_t_2 = (((__pyx_v_src.suboffsets[__pyx_v_i]) >= 0) != 0);
19808     if (__pyx_t_2) {
19809 
19810       /* "View.MemoryView":1300
19811  *
19812  *         if src.suboffsets[i] >= 0:
19813  *             _err_dim(ValueError, "Dimension %d is not direct", i)             # <<<<<<<<<<<<<<
19814  *
19815  *     if slices_overlap(&src, &dst, ndim, itemsize):
19816  */
19817       __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(2, 1300, __pyx_L1_error)
19818 
19819       /* "View.MemoryView":1299
19820  *                 _err_extents(i, dst.shape[i], src.shape[i])
19821  *
19822  *         if src.suboffsets[i] >= 0:             # <<<<<<<<<<<<<<
19823  *             _err_dim(ValueError, "Dimension %d is not direct", i)
19824  *
19825  */
19826     }
19827   }
19828 
19829   /* "View.MemoryView":1302
19830  *             _err_dim(ValueError, "Dimension %d is not direct", i)
19831  *
19832  *     if slices_overlap(&src, &dst, ndim, itemsize):             # <<<<<<<<<<<<<<
19833  *
19834  *         if not slice_is_contig(src, order, ndim):
19835  */
19836   __pyx_t_2 = (__pyx_slices_overlap((&__pyx_v_src), (&__pyx_v_dst), __pyx_v_ndim, __pyx_v_itemsize) != 0);
19837   if (__pyx_t_2) {
19838 
19839     /* "View.MemoryView":1304
19840  *     if slices_overlap(&src, &dst, ndim, itemsize):
19841  *
19842  *         if not slice_is_contig(src, order, ndim):             # <<<<<<<<<<<<<<
19843  *             order = get_best_order(&dst, ndim)
19844  *
19845  */
19846     __pyx_t_2 = ((!(__pyx_memviewslice_is_contig(__pyx_v_src, __pyx_v_order, __pyx_v_ndim) != 0)) != 0);
19847     if (__pyx_t_2) {
19848 
19849       /* "View.MemoryView":1305
19850  *
19851  *         if not slice_is_contig(src, order, ndim):
19852  *             order = get_best_order(&dst, ndim)             # <<<<<<<<<<<<<<
19853  *
19854  *         tmpdata = copy_data_to_temp(&src, &tmp, order, ndim)
19855  */
19856       __pyx_v_order = __pyx_get_best_slice_order((&__pyx_v_dst), __pyx_v_ndim);
19857 
19858       /* "View.MemoryView":1304
19859  *     if slices_overlap(&src, &dst, ndim, itemsize):
19860  *
19861  *         if not slice_is_contig(src, order, ndim):             # <<<<<<<<<<<<<<
19862  *             order = get_best_order(&dst, ndim)
19863  *
19864  */
19865     }
19866 
19867     /* "View.MemoryView":1307
19868  *             order = get_best_order(&dst, ndim)
19869  *
19870  *         tmpdata = copy_data_to_temp(&src, &tmp, order, ndim)             # <<<<<<<<<<<<<<
19871  *         src = tmp
19872  *
19873  */
19874     __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(2, 1307, __pyx_L1_error)
19875     __pyx_v_tmpdata = __pyx_t_7;
19876 
19877     /* "View.MemoryView":1308
19878  *
19879  *         tmpdata = copy_data_to_temp(&src, &tmp, order, ndim)
19880  *         src = tmp             # <<<<<<<<<<<<<<
19881  *
19882  *     if not broadcasting:
19883  */
19884     __pyx_v_src = __pyx_v_tmp;
19885 
19886     /* "View.MemoryView":1302
19887  *             _err_dim(ValueError, "Dimension %d is not direct", i)
19888  *
19889  *     if slices_overlap(&src, &dst, ndim, itemsize):             # <<<<<<<<<<<<<<
19890  *
19891  *         if not slice_is_contig(src, order, ndim):
19892  */
19893   }
19894 
19895   /* "View.MemoryView":1310
19896  *         src = tmp
19897  *
19898  *     if not broadcasting:             # <<<<<<<<<<<<<<
19899  *
19900  *
19901  */
19902   __pyx_t_2 = ((!(__pyx_v_broadcasting != 0)) != 0);
19903   if (__pyx_t_2) {
19904 
19905     /* "View.MemoryView":1313
19906  *
19907  *
19908  *         if slice_is_contig(src, 'C', ndim):             # <<<<<<<<<<<<<<
19909  *             direct_copy = slice_is_contig(dst, 'C', ndim)
19910  *         elif slice_is_contig(src, 'F', ndim):
19911  */
19912     __pyx_t_2 = (__pyx_memviewslice_is_contig(__pyx_v_src, 'C', __pyx_v_ndim) != 0);
19913     if (__pyx_t_2) {
19914 
19915       /* "View.MemoryView":1314
19916  *
19917  *         if slice_is_contig(src, 'C', ndim):
19918  *             direct_copy = slice_is_contig(dst, 'C', ndim)             # <<<<<<<<<<<<<<
19919  *         elif slice_is_contig(src, 'F', ndim):
19920  *             direct_copy = slice_is_contig(dst, 'F', ndim)
19921  */
19922       __pyx_v_direct_copy = __pyx_memviewslice_is_contig(__pyx_v_dst, 'C', __pyx_v_ndim);
19923 
19924       /* "View.MemoryView":1313
19925  *
19926  *
19927  *         if slice_is_contig(src, 'C', ndim):             # <<<<<<<<<<<<<<
19928  *             direct_copy = slice_is_contig(dst, 'C', ndim)
19929  *         elif slice_is_contig(src, 'F', ndim):
19930  */
19931       goto __pyx_L12;
19932     }
19933 
19934     /* "View.MemoryView":1315
19935  *         if slice_is_contig(src, 'C', ndim):
19936  *             direct_copy = slice_is_contig(dst, 'C', ndim)
19937  *         elif slice_is_contig(src, 'F', ndim):             # <<<<<<<<<<<<<<
19938  *             direct_copy = slice_is_contig(dst, 'F', ndim)
19939  *
19940  */
19941     __pyx_t_2 = (__pyx_memviewslice_is_contig(__pyx_v_src, 'F', __pyx_v_ndim) != 0);
19942     if (__pyx_t_2) {
19943 
19944       /* "View.MemoryView":1316
19945  *             direct_copy = slice_is_contig(dst, 'C', ndim)
19946  *         elif slice_is_contig(src, 'F', ndim):
19947  *             direct_copy = slice_is_contig(dst, 'F', ndim)             # <<<<<<<<<<<<<<
19948  *
19949  *         if direct_copy:
19950  */
19951       __pyx_v_direct_copy = __pyx_memviewslice_is_contig(__pyx_v_dst, 'F', __pyx_v_ndim);
19952 
19953       /* "View.MemoryView":1315
19954  *         if slice_is_contig(src, 'C', ndim):
19955  *             direct_copy = slice_is_contig(dst, 'C', ndim)
19956  *         elif slice_is_contig(src, 'F', ndim):             # <<<<<<<<<<<<<<
19957  *             direct_copy = slice_is_contig(dst, 'F', ndim)
19958  *
19959  */
19960     }
19961     __pyx_L12:;
19962 
19963     /* "View.MemoryView":1318
19964  *             direct_copy = slice_is_contig(dst, 'F', ndim)
19965  *
19966  *         if direct_copy:             # <<<<<<<<<<<<<<
19967  *
19968  *             refcount_copying(&dst, dtype_is_object, ndim, False)
19969  */
19970     __pyx_t_2 = (__pyx_v_direct_copy != 0);
19971     if (__pyx_t_2) {
19972 
19973       /* "View.MemoryView":1320
19974  *         if direct_copy:
19975  *
19976  *             refcount_copying(&dst, dtype_is_object, ndim, False)             # <<<<<<<<<<<<<<
19977  *             memcpy(dst.data, src.data, slice_get_size(&src, ndim))
19978  *             refcount_copying(&dst, dtype_is_object, ndim, True)
19979  */
19980       __pyx_memoryview_refcount_copying((&__pyx_v_dst), __pyx_v_dtype_is_object, __pyx_v_ndim, 0);
19981 
19982       /* "View.MemoryView":1321
19983  *
19984  *             refcount_copying(&dst, dtype_is_object, ndim, False)
19985  *             memcpy(dst.data, src.data, slice_get_size(&src, ndim))             # <<<<<<<<<<<<<<
19986  *             refcount_copying(&dst, dtype_is_object, ndim, True)
19987  *             free(tmpdata)
19988  */
19989       (void)(memcpy(__pyx_v_dst.data, __pyx_v_src.data, __pyx_memoryview_slice_get_size((&__pyx_v_src), __pyx_v_ndim)));
19990 
19991       /* "View.MemoryView":1322
19992  *             refcount_copying(&dst, dtype_is_object, ndim, False)
19993  *             memcpy(dst.data, src.data, slice_get_size(&src, ndim))
19994  *             refcount_copying(&dst, dtype_is_object, ndim, True)             # <<<<<<<<<<<<<<
19995  *             free(tmpdata)
19996  *             return 0
19997  */
19998       __pyx_memoryview_refcount_copying((&__pyx_v_dst), __pyx_v_dtype_is_object, __pyx_v_ndim, 1);
19999 
20000       /* "View.MemoryView":1323
20001  *             memcpy(dst.data, src.data, slice_get_size(&src, ndim))
20002  *             refcount_copying(&dst, dtype_is_object, ndim, True)
20003  *             free(tmpdata)             # <<<<<<<<<<<<<<
20004  *             return 0
20005  *
20006  */
20007       free(__pyx_v_tmpdata);
20008 
20009       /* "View.MemoryView":1324
20010  *             refcount_copying(&dst, dtype_is_object, ndim, True)
20011  *             free(tmpdata)
20012  *             return 0             # <<<<<<<<<<<<<<
20013  *
20014  *     if order == 'F' == get_best_order(&dst, ndim):
20015  */
20016       __pyx_r = 0;
20017       goto __pyx_L0;
20018 
20019       /* "View.MemoryView":1318
20020  *             direct_copy = slice_is_contig(dst, 'F', ndim)
20021  *
20022  *         if direct_copy:             # <<<<<<<<<<<<<<
20023  *
20024  *             refcount_copying(&dst, dtype_is_object, ndim, False)
20025  */
20026     }
20027 
20028     /* "View.MemoryView":1310
20029  *         src = tmp
20030  *
20031  *     if not broadcasting:             # <<<<<<<<<<<<<<
20032  *
20033  *
20034  */
20035   }
20036 
20037   /* "View.MemoryView":1326
20038  *             return 0
20039  *
20040  *     if order == 'F' == get_best_order(&dst, ndim):             # <<<<<<<<<<<<<<
20041  *
20042  *
20043  */
20044   __pyx_t_2 = (__pyx_v_order == 'F');
20045   if (__pyx_t_2) {
20046     __pyx_t_2 = ('F' == __pyx_get_best_slice_order((&__pyx_v_dst), __pyx_v_ndim));
20047   }
20048   __pyx_t_8 = (__pyx_t_2 != 0);
20049   if (__pyx_t_8) {
20050 
20051     /* "View.MemoryView":1329
20052  *
20053  *
20054  *         transpose_memslice(&src)             # <<<<<<<<<<<<<<
20055  *         transpose_memslice(&dst)
20056  *
20057  */
20058     __pyx_t_5 = __pyx_memslice_transpose((&__pyx_v_src)); if (unlikely(__pyx_t_5 == ((int)0))) __PYX_ERR(2, 1329, __pyx_L1_error)
20059 
20060     /* "View.MemoryView":1330
20061  *
20062  *         transpose_memslice(&src)
20063  *         transpose_memslice(&dst)             # <<<<<<<<<<<<<<
20064  *
20065  *     refcount_copying(&dst, dtype_is_object, ndim, False)
20066  */
20067     __pyx_t_5 = __pyx_memslice_transpose((&__pyx_v_dst)); if (unlikely(__pyx_t_5 == ((int)0))) __PYX_ERR(2, 1330, __pyx_L1_error)
20068 
20069     /* "View.MemoryView":1326
20070  *             return 0
20071  *
20072  *     if order == 'F' == get_best_order(&dst, ndim):             # <<<<<<<<<<<<<<
20073  *
20074  *
20075  */
20076   }
20077 
20078   /* "View.MemoryView":1332
20079  *         transpose_memslice(&dst)
20080  *
20081  *     refcount_copying(&dst, dtype_is_object, ndim, False)             # <<<<<<<<<<<<<<
20082  *     copy_strided_to_strided(&src, &dst, ndim, itemsize)
20083  *     refcount_copying(&dst, dtype_is_object, ndim, True)
20084  */
20085   __pyx_memoryview_refcount_copying((&__pyx_v_dst), __pyx_v_dtype_is_object, __pyx_v_ndim, 0);
20086 
20087   /* "View.MemoryView":1333
20088  *
20089  *     refcount_copying(&dst, dtype_is_object, ndim, False)
20090  *     copy_strided_to_strided(&src, &dst, ndim, itemsize)             # <<<<<<<<<<<<<<
20091  *     refcount_copying(&dst, dtype_is_object, ndim, True)
20092  *
20093  */
20094   copy_strided_to_strided((&__pyx_v_src), (&__pyx_v_dst), __pyx_v_ndim, __pyx_v_itemsize);
20095 
20096   /* "View.MemoryView":1334
20097  *     refcount_copying(&dst, dtype_is_object, ndim, False)
20098  *     copy_strided_to_strided(&src, &dst, ndim, itemsize)
20099  *     refcount_copying(&dst, dtype_is_object, ndim, True)             # <<<<<<<<<<<<<<
20100  *
20101  *     free(tmpdata)
20102  */
20103   __pyx_memoryview_refcount_copying((&__pyx_v_dst), __pyx_v_dtype_is_object, __pyx_v_ndim, 1);
20104 
20105   /* "View.MemoryView":1336
20106  *     refcount_copying(&dst, dtype_is_object, ndim, True)
20107  *
20108  *     free(tmpdata)             # <<<<<<<<<<<<<<
20109  *     return 0
20110  *
20111  */
20112   free(__pyx_v_tmpdata);
20113 
20114   /* "View.MemoryView":1337
20115  *
20116  *     free(tmpdata)
20117  *     return 0             # <<<<<<<<<<<<<<
20118  *
20119  * @cname('__pyx_memoryview_broadcast_leading')
20120  */
20121   __pyx_r = 0;
20122   goto __pyx_L0;
20123 
20124   /* "View.MemoryView":1268
20125  *
20126  * @cname('__pyx_memoryview_copy_contents')
20127  * cdef int memoryview_copy_contents(__Pyx_memviewslice src,             # <<<<<<<<<<<<<<
20128  *                                   __Pyx_memviewslice dst,
20129  *                                   int src_ndim, int dst_ndim,
20130  */
20131 
20132   /* function exit code */
20133   __pyx_L1_error:;
20134   {
20135     #ifdef WITH_THREAD
20136     PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure();
20137     #endif
20138     __Pyx_AddTraceback("View.MemoryView.memoryview_copy_contents", __pyx_clineno, __pyx_lineno, __pyx_filename);
20139     #ifdef WITH_THREAD
20140     __Pyx_PyGILState_Release(__pyx_gilstate_save);
20141     #endif
20142   }
20143   __pyx_r = -1;
20144   __pyx_L0:;
20145   return __pyx_r;
20146 }
20147 
20148 /* "View.MemoryView":1340
20149  *
20150  * @cname('__pyx_memoryview_broadcast_leading')
20151  * cdef void broadcast_leading(__Pyx_memviewslice *mslice,             # <<<<<<<<<<<<<<
20152  *                             int ndim,
20153  *                             int ndim_other) nogil:
20154  */
20155 
__pyx_memoryview_broadcast_leading(__Pyx_memviewslice * __pyx_v_mslice,int __pyx_v_ndim,int __pyx_v_ndim_other)20156 static void __pyx_memoryview_broadcast_leading(__Pyx_memviewslice *__pyx_v_mslice, int __pyx_v_ndim, int __pyx_v_ndim_other) {
20157   int __pyx_v_i;
20158   int __pyx_v_offset;
20159   int __pyx_t_1;
20160   int __pyx_t_2;
20161   int __pyx_t_3;
20162 
20163   /* "View.MemoryView":1344
20164  *                             int ndim_other) nogil:
20165  *     cdef int i
20166  *     cdef int offset = ndim_other - ndim             # <<<<<<<<<<<<<<
20167  *
20168  *     for i in range(ndim - 1, -1, -1):
20169  */
20170   __pyx_v_offset = (__pyx_v_ndim_other - __pyx_v_ndim);
20171 
20172   /* "View.MemoryView":1346
20173  *     cdef int offset = ndim_other - ndim
20174  *
20175  *     for i in range(ndim - 1, -1, -1):             # <<<<<<<<<<<<<<
20176  *         mslice.shape[i + offset] = mslice.shape[i]
20177  *         mslice.strides[i + offset] = mslice.strides[i]
20178  */
20179   for (__pyx_t_1 = (__pyx_v_ndim - 1); __pyx_t_1 > -1; __pyx_t_1-=1) {
20180     __pyx_v_i = __pyx_t_1;
20181 
20182     /* "View.MemoryView":1347
20183  *
20184  *     for i in range(ndim - 1, -1, -1):
20185  *         mslice.shape[i + offset] = mslice.shape[i]             # <<<<<<<<<<<<<<
20186  *         mslice.strides[i + offset] = mslice.strides[i]
20187  *         mslice.suboffsets[i + offset] = mslice.suboffsets[i]
20188  */
20189     (__pyx_v_mslice->shape[(__pyx_v_i + __pyx_v_offset)]) = (__pyx_v_mslice->shape[__pyx_v_i]);
20190 
20191     /* "View.MemoryView":1348
20192  *     for i in range(ndim - 1, -1, -1):
20193  *         mslice.shape[i + offset] = mslice.shape[i]
20194  *         mslice.strides[i + offset] = mslice.strides[i]             # <<<<<<<<<<<<<<
20195  *         mslice.suboffsets[i + offset] = mslice.suboffsets[i]
20196  *
20197  */
20198     (__pyx_v_mslice->strides[(__pyx_v_i + __pyx_v_offset)]) = (__pyx_v_mslice->strides[__pyx_v_i]);
20199 
20200     /* "View.MemoryView":1349
20201  *         mslice.shape[i + offset] = mslice.shape[i]
20202  *         mslice.strides[i + offset] = mslice.strides[i]
20203  *         mslice.suboffsets[i + offset] = mslice.suboffsets[i]             # <<<<<<<<<<<<<<
20204  *
20205  *     for i in range(offset):
20206  */
20207     (__pyx_v_mslice->suboffsets[(__pyx_v_i + __pyx_v_offset)]) = (__pyx_v_mslice->suboffsets[__pyx_v_i]);
20208   }
20209 
20210   /* "View.MemoryView":1351
20211  *         mslice.suboffsets[i + offset] = mslice.suboffsets[i]
20212  *
20213  *     for i in range(offset):             # <<<<<<<<<<<<<<
20214  *         mslice.shape[i] = 1
20215  *         mslice.strides[i] = mslice.strides[0]
20216  */
20217   __pyx_t_1 = __pyx_v_offset;
20218   __pyx_t_2 = __pyx_t_1;
20219   for (__pyx_t_3 = 0; __pyx_t_3 < __pyx_t_2; __pyx_t_3+=1) {
20220     __pyx_v_i = __pyx_t_3;
20221 
20222     /* "View.MemoryView":1352
20223  *
20224  *     for i in range(offset):
20225  *         mslice.shape[i] = 1             # <<<<<<<<<<<<<<
20226  *         mslice.strides[i] = mslice.strides[0]
20227  *         mslice.suboffsets[i] = -1
20228  */
20229     (__pyx_v_mslice->shape[__pyx_v_i]) = 1;
20230 
20231     /* "View.MemoryView":1353
20232  *     for i in range(offset):
20233  *         mslice.shape[i] = 1
20234  *         mslice.strides[i] = mslice.strides[0]             # <<<<<<<<<<<<<<
20235  *         mslice.suboffsets[i] = -1
20236  *
20237  */
20238     (__pyx_v_mslice->strides[__pyx_v_i]) = (__pyx_v_mslice->strides[0]);
20239 
20240     /* "View.MemoryView":1354
20241  *         mslice.shape[i] = 1
20242  *         mslice.strides[i] = mslice.strides[0]
20243  *         mslice.suboffsets[i] = -1             # <<<<<<<<<<<<<<
20244  *
20245  *
20246  */
20247     (__pyx_v_mslice->suboffsets[__pyx_v_i]) = -1L;
20248   }
20249 
20250   /* "View.MemoryView":1340
20251  *
20252  * @cname('__pyx_memoryview_broadcast_leading')
20253  * cdef void broadcast_leading(__Pyx_memviewslice *mslice,             # <<<<<<<<<<<<<<
20254  *                             int ndim,
20255  *                             int ndim_other) nogil:
20256  */
20257 
20258   /* function exit code */
20259 }
20260 
20261 /* "View.MemoryView":1362
20262  *
20263  * @cname('__pyx_memoryview_refcount_copying')
20264  * cdef void refcount_copying(__Pyx_memviewslice *dst, bint dtype_is_object,             # <<<<<<<<<<<<<<
20265  *                            int ndim, bint inc) nogil:
20266  *
20267  */
20268 
__pyx_memoryview_refcount_copying(__Pyx_memviewslice * __pyx_v_dst,int __pyx_v_dtype_is_object,int __pyx_v_ndim,int __pyx_v_inc)20269 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) {
20270   int __pyx_t_1;
20271 
20272   /* "View.MemoryView":1366
20273  *
20274  *
20275  *     if dtype_is_object:             # <<<<<<<<<<<<<<
20276  *         refcount_objects_in_slice_with_gil(dst.data, dst.shape,
20277  *                                            dst.strides, ndim, inc)
20278  */
20279   __pyx_t_1 = (__pyx_v_dtype_is_object != 0);
20280   if (__pyx_t_1) {
20281 
20282     /* "View.MemoryView":1367
20283  *
20284  *     if dtype_is_object:
20285  *         refcount_objects_in_slice_with_gil(dst.data, dst.shape,             # <<<<<<<<<<<<<<
20286  *                                            dst.strides, ndim, inc)
20287  *
20288  */
20289     __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);
20290 
20291     /* "View.MemoryView":1366
20292  *
20293  *
20294  *     if dtype_is_object:             # <<<<<<<<<<<<<<
20295  *         refcount_objects_in_slice_with_gil(dst.data, dst.shape,
20296  *                                            dst.strides, ndim, inc)
20297  */
20298   }
20299 
20300   /* "View.MemoryView":1362
20301  *
20302  * @cname('__pyx_memoryview_refcount_copying')
20303  * cdef void refcount_copying(__Pyx_memviewslice *dst, bint dtype_is_object,             # <<<<<<<<<<<<<<
20304  *                            int ndim, bint inc) nogil:
20305  *
20306  */
20307 
20308   /* function exit code */
20309 }
20310 
20311 /* "View.MemoryView":1371
20312  *
20313  * @cname('__pyx_memoryview_refcount_objects_in_slice_with_gil')
20314  * cdef void refcount_objects_in_slice_with_gil(char *data, Py_ssize_t *shape,             # <<<<<<<<<<<<<<
20315  *                                              Py_ssize_t *strides, int ndim,
20316  *                                              bint inc) with gil:
20317  */
20318 
__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)20319 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) {
20320   __Pyx_RefNannyDeclarations
20321   #ifdef WITH_THREAD
20322   PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure();
20323   #endif
20324   __Pyx_RefNannySetupContext("refcount_objects_in_slice_with_gil", 0);
20325 
20326   /* "View.MemoryView":1374
20327  *                                              Py_ssize_t *strides, int ndim,
20328  *                                              bint inc) with gil:
20329  *     refcount_objects_in_slice(data, shape, strides, ndim, inc)             # <<<<<<<<<<<<<<
20330  *
20331  * @cname('__pyx_memoryview_refcount_objects_in_slice')
20332  */
20333   __pyx_memoryview_refcount_objects_in_slice(__pyx_v_data, __pyx_v_shape, __pyx_v_strides, __pyx_v_ndim, __pyx_v_inc);
20334 
20335   /* "View.MemoryView":1371
20336  *
20337  * @cname('__pyx_memoryview_refcount_objects_in_slice_with_gil')
20338  * cdef void refcount_objects_in_slice_with_gil(char *data, Py_ssize_t *shape,             # <<<<<<<<<<<<<<
20339  *                                              Py_ssize_t *strides, int ndim,
20340  *                                              bint inc) with gil:
20341  */
20342 
20343   /* function exit code */
20344   __Pyx_RefNannyFinishContext();
20345   #ifdef WITH_THREAD
20346   __Pyx_PyGILState_Release(__pyx_gilstate_save);
20347   #endif
20348 }
20349 
20350 /* "View.MemoryView":1377
20351  *
20352  * @cname('__pyx_memoryview_refcount_objects_in_slice')
20353  * cdef void refcount_objects_in_slice(char *data, Py_ssize_t *shape,             # <<<<<<<<<<<<<<
20354  *                                     Py_ssize_t *strides, int ndim, bint inc):
20355  *     cdef Py_ssize_t i
20356  */
20357 
__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)20358 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) {
20359   CYTHON_UNUSED Py_ssize_t __pyx_v_i;
20360   __Pyx_RefNannyDeclarations
20361   Py_ssize_t __pyx_t_1;
20362   Py_ssize_t __pyx_t_2;
20363   Py_ssize_t __pyx_t_3;
20364   int __pyx_t_4;
20365   __Pyx_RefNannySetupContext("refcount_objects_in_slice", 0);
20366 
20367   /* "View.MemoryView":1381
20368  *     cdef Py_ssize_t i
20369  *
20370  *     for i in range(shape[0]):             # <<<<<<<<<<<<<<
20371  *         if ndim == 1:
20372  *             if inc:
20373  */
20374   __pyx_t_1 = (__pyx_v_shape[0]);
20375   __pyx_t_2 = __pyx_t_1;
20376   for (__pyx_t_3 = 0; __pyx_t_3 < __pyx_t_2; __pyx_t_3+=1) {
20377     __pyx_v_i = __pyx_t_3;
20378 
20379     /* "View.MemoryView":1382
20380  *
20381  *     for i in range(shape[0]):
20382  *         if ndim == 1:             # <<<<<<<<<<<<<<
20383  *             if inc:
20384  *                 Py_INCREF((<PyObject **> data)[0])
20385  */
20386     __pyx_t_4 = ((__pyx_v_ndim == 1) != 0);
20387     if (__pyx_t_4) {
20388 
20389       /* "View.MemoryView":1383
20390  *     for i in range(shape[0]):
20391  *         if ndim == 1:
20392  *             if inc:             # <<<<<<<<<<<<<<
20393  *                 Py_INCREF((<PyObject **> data)[0])
20394  *             else:
20395  */
20396       __pyx_t_4 = (__pyx_v_inc != 0);
20397       if (__pyx_t_4) {
20398 
20399         /* "View.MemoryView":1384
20400  *         if ndim == 1:
20401  *             if inc:
20402  *                 Py_INCREF((<PyObject **> data)[0])             # <<<<<<<<<<<<<<
20403  *             else:
20404  *                 Py_DECREF((<PyObject **> data)[0])
20405  */
20406         Py_INCREF((((PyObject **)__pyx_v_data)[0]));
20407 
20408         /* "View.MemoryView":1383
20409  *     for i in range(shape[0]):
20410  *         if ndim == 1:
20411  *             if inc:             # <<<<<<<<<<<<<<
20412  *                 Py_INCREF((<PyObject **> data)[0])
20413  *             else:
20414  */
20415         goto __pyx_L6;
20416       }
20417 
20418       /* "View.MemoryView":1386
20419  *                 Py_INCREF((<PyObject **> data)[0])
20420  *             else:
20421  *                 Py_DECREF((<PyObject **> data)[0])             # <<<<<<<<<<<<<<
20422  *         else:
20423  *             refcount_objects_in_slice(data, shape + 1, strides + 1,
20424  */
20425       /*else*/ {
20426         Py_DECREF((((PyObject **)__pyx_v_data)[0]));
20427       }
20428       __pyx_L6:;
20429 
20430       /* "View.MemoryView":1382
20431  *
20432  *     for i in range(shape[0]):
20433  *         if ndim == 1:             # <<<<<<<<<<<<<<
20434  *             if inc:
20435  *                 Py_INCREF((<PyObject **> data)[0])
20436  */
20437       goto __pyx_L5;
20438     }
20439 
20440     /* "View.MemoryView":1388
20441  *                 Py_DECREF((<PyObject **> data)[0])
20442  *         else:
20443  *             refcount_objects_in_slice(data, shape + 1, strides + 1,             # <<<<<<<<<<<<<<
20444  *                                       ndim - 1, inc)
20445  *
20446  */
20447     /*else*/ {
20448 
20449       /* "View.MemoryView":1389
20450  *         else:
20451  *             refcount_objects_in_slice(data, shape + 1, strides + 1,
20452  *                                       ndim - 1, inc)             # <<<<<<<<<<<<<<
20453  *
20454  *         data += strides[0]
20455  */
20456       __pyx_memoryview_refcount_objects_in_slice(__pyx_v_data, (__pyx_v_shape + 1), (__pyx_v_strides + 1), (__pyx_v_ndim - 1), __pyx_v_inc);
20457     }
20458     __pyx_L5:;
20459 
20460     /* "View.MemoryView":1391
20461  *                                       ndim - 1, inc)
20462  *
20463  *         data += strides[0]             # <<<<<<<<<<<<<<
20464  *
20465  *
20466  */
20467     __pyx_v_data = (__pyx_v_data + (__pyx_v_strides[0]));
20468   }
20469 
20470   /* "View.MemoryView":1377
20471  *
20472  * @cname('__pyx_memoryview_refcount_objects_in_slice')
20473  * cdef void refcount_objects_in_slice(char *data, Py_ssize_t *shape,             # <<<<<<<<<<<<<<
20474  *                                     Py_ssize_t *strides, int ndim, bint inc):
20475  *     cdef Py_ssize_t i
20476  */
20477 
20478   /* function exit code */
20479   __Pyx_RefNannyFinishContext();
20480 }
20481 
20482 /* "View.MemoryView":1397
20483  *
20484  * @cname('__pyx_memoryview_slice_assign_scalar')
20485  * cdef void slice_assign_scalar(__Pyx_memviewslice *dst, int ndim,             # <<<<<<<<<<<<<<
20486  *                               size_t itemsize, void *item,
20487  *                               bint dtype_is_object) nogil:
20488  */
20489 
__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)20490 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) {
20491 
20492   /* "View.MemoryView":1400
20493  *                               size_t itemsize, void *item,
20494  *                               bint dtype_is_object) nogil:
20495  *     refcount_copying(dst, dtype_is_object, ndim, False)             # <<<<<<<<<<<<<<
20496  *     _slice_assign_scalar(dst.data, dst.shape, dst.strides, ndim,
20497  *                          itemsize, item)
20498  */
20499   __pyx_memoryview_refcount_copying(__pyx_v_dst, __pyx_v_dtype_is_object, __pyx_v_ndim, 0);
20500 
20501   /* "View.MemoryView":1401
20502  *                               bint dtype_is_object) nogil:
20503  *     refcount_copying(dst, dtype_is_object, ndim, False)
20504  *     _slice_assign_scalar(dst.data, dst.shape, dst.strides, ndim,             # <<<<<<<<<<<<<<
20505  *                          itemsize, item)
20506  *     refcount_copying(dst, dtype_is_object, ndim, True)
20507  */
20508   __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);
20509 
20510   /* "View.MemoryView":1403
20511  *     _slice_assign_scalar(dst.data, dst.shape, dst.strides, ndim,
20512  *                          itemsize, item)
20513  *     refcount_copying(dst, dtype_is_object, ndim, True)             # <<<<<<<<<<<<<<
20514  *
20515  *
20516  */
20517   __pyx_memoryview_refcount_copying(__pyx_v_dst, __pyx_v_dtype_is_object, __pyx_v_ndim, 1);
20518 
20519   /* "View.MemoryView":1397
20520  *
20521  * @cname('__pyx_memoryview_slice_assign_scalar')
20522  * cdef void slice_assign_scalar(__Pyx_memviewslice *dst, int ndim,             # <<<<<<<<<<<<<<
20523  *                               size_t itemsize, void *item,
20524  *                               bint dtype_is_object) nogil:
20525  */
20526 
20527   /* function exit code */
20528 }
20529 
20530 /* "View.MemoryView":1407
20531  *
20532  * @cname('__pyx_memoryview__slice_assign_scalar')
20533  * cdef void _slice_assign_scalar(char *data, Py_ssize_t *shape,             # <<<<<<<<<<<<<<
20534  *                               Py_ssize_t *strides, int ndim,
20535  *                               size_t itemsize, void *item) nogil:
20536  */
20537 
__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)20538 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) {
20539   CYTHON_UNUSED Py_ssize_t __pyx_v_i;
20540   Py_ssize_t __pyx_v_stride;
20541   Py_ssize_t __pyx_v_extent;
20542   int __pyx_t_1;
20543   Py_ssize_t __pyx_t_2;
20544   Py_ssize_t __pyx_t_3;
20545   Py_ssize_t __pyx_t_4;
20546 
20547   /* "View.MemoryView":1411
20548  *                               size_t itemsize, void *item) nogil:
20549  *     cdef Py_ssize_t i
20550  *     cdef Py_ssize_t stride = strides[0]             # <<<<<<<<<<<<<<
20551  *     cdef Py_ssize_t extent = shape[0]
20552  *
20553  */
20554   __pyx_v_stride = (__pyx_v_strides[0]);
20555 
20556   /* "View.MemoryView":1412
20557  *     cdef Py_ssize_t i
20558  *     cdef Py_ssize_t stride = strides[0]
20559  *     cdef Py_ssize_t extent = shape[0]             # <<<<<<<<<<<<<<
20560  *
20561  *     if ndim == 1:
20562  */
20563   __pyx_v_extent = (__pyx_v_shape[0]);
20564 
20565   /* "View.MemoryView":1414
20566  *     cdef Py_ssize_t extent = shape[0]
20567  *
20568  *     if ndim == 1:             # <<<<<<<<<<<<<<
20569  *         for i in range(extent):
20570  *             memcpy(data, item, itemsize)
20571  */
20572   __pyx_t_1 = ((__pyx_v_ndim == 1) != 0);
20573   if (__pyx_t_1) {
20574 
20575     /* "View.MemoryView":1415
20576  *
20577  *     if ndim == 1:
20578  *         for i in range(extent):             # <<<<<<<<<<<<<<
20579  *             memcpy(data, item, itemsize)
20580  *             data += stride
20581  */
20582     __pyx_t_2 = __pyx_v_extent;
20583     __pyx_t_3 = __pyx_t_2;
20584     for (__pyx_t_4 = 0; __pyx_t_4 < __pyx_t_3; __pyx_t_4+=1) {
20585       __pyx_v_i = __pyx_t_4;
20586 
20587       /* "View.MemoryView":1416
20588  *     if ndim == 1:
20589  *         for i in range(extent):
20590  *             memcpy(data, item, itemsize)             # <<<<<<<<<<<<<<
20591  *             data += stride
20592  *     else:
20593  */
20594       (void)(memcpy(__pyx_v_data, __pyx_v_item, __pyx_v_itemsize));
20595 
20596       /* "View.MemoryView":1417
20597  *         for i in range(extent):
20598  *             memcpy(data, item, itemsize)
20599  *             data += stride             # <<<<<<<<<<<<<<
20600  *     else:
20601  *         for i in range(extent):
20602  */
20603       __pyx_v_data = (__pyx_v_data + __pyx_v_stride);
20604     }
20605 
20606     /* "View.MemoryView":1414
20607  *     cdef Py_ssize_t extent = shape[0]
20608  *
20609  *     if ndim == 1:             # <<<<<<<<<<<<<<
20610  *         for i in range(extent):
20611  *             memcpy(data, item, itemsize)
20612  */
20613     goto __pyx_L3;
20614   }
20615 
20616   /* "View.MemoryView":1419
20617  *             data += stride
20618  *     else:
20619  *         for i in range(extent):             # <<<<<<<<<<<<<<
20620  *             _slice_assign_scalar(data, shape + 1, strides + 1,
20621  *                                 ndim - 1, itemsize, item)
20622  */
20623   /*else*/ {
20624     __pyx_t_2 = __pyx_v_extent;
20625     __pyx_t_3 = __pyx_t_2;
20626     for (__pyx_t_4 = 0; __pyx_t_4 < __pyx_t_3; __pyx_t_4+=1) {
20627       __pyx_v_i = __pyx_t_4;
20628 
20629       /* "View.MemoryView":1420
20630  *     else:
20631  *         for i in range(extent):
20632  *             _slice_assign_scalar(data, shape + 1, strides + 1,             # <<<<<<<<<<<<<<
20633  *                                 ndim - 1, itemsize, item)
20634  *             data += stride
20635  */
20636       __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);
20637 
20638       /* "View.MemoryView":1422
20639  *             _slice_assign_scalar(data, shape + 1, strides + 1,
20640  *                                 ndim - 1, itemsize, item)
20641  *             data += stride             # <<<<<<<<<<<<<<
20642  *
20643  *
20644  */
20645       __pyx_v_data = (__pyx_v_data + __pyx_v_stride);
20646     }
20647   }
20648   __pyx_L3:;
20649 
20650   /* "View.MemoryView":1407
20651  *
20652  * @cname('__pyx_memoryview__slice_assign_scalar')
20653  * cdef void _slice_assign_scalar(char *data, Py_ssize_t *shape,             # <<<<<<<<<<<<<<
20654  *                               Py_ssize_t *strides, int ndim,
20655  *                               size_t itemsize, void *item) nogil:
20656  */
20657 
20658   /* function exit code */
20659 }
20660 
20661 /* "(tree fragment)":1
20662  * def __pyx_unpickle_Enum(__pyx_type, long __pyx_checksum, __pyx_state):             # <<<<<<<<<<<<<<
20663  *     cdef object __pyx_PickleError
20664  *     cdef object __pyx_result
20665  */
20666 
20667 /* Python wrapper */
20668 static PyObject *__pyx_pw_15View_dot_MemoryView_1__pyx_unpickle_Enum(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
20669 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)20670 static PyObject *__pyx_pw_15View_dot_MemoryView_1__pyx_unpickle_Enum(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
20671   PyObject *__pyx_v___pyx_type = 0;
20672   long __pyx_v___pyx_checksum;
20673   PyObject *__pyx_v___pyx_state = 0;
20674   int __pyx_lineno = 0;
20675   const char *__pyx_filename = NULL;
20676   int __pyx_clineno = 0;
20677   PyObject *__pyx_r = 0;
20678   __Pyx_RefNannyDeclarations
20679   __Pyx_RefNannySetupContext("__pyx_unpickle_Enum (wrapper)", 0);
20680   {
20681     static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_pyx_type,&__pyx_n_s_pyx_checksum,&__pyx_n_s_pyx_state,0};
20682     PyObject* values[3] = {0,0,0};
20683     if (unlikely(__pyx_kwds)) {
20684       Py_ssize_t kw_args;
20685       const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
20686       switch (pos_args) {
20687         case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
20688         CYTHON_FALLTHROUGH;
20689         case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
20690         CYTHON_FALLTHROUGH;
20691         case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
20692         CYTHON_FALLTHROUGH;
20693         case  0: break;
20694         default: goto __pyx_L5_argtuple_error;
20695       }
20696       kw_args = PyDict_Size(__pyx_kwds);
20697       switch (pos_args) {
20698         case  0:
20699         if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_pyx_type)) != 0)) kw_args--;
20700         else goto __pyx_L5_argtuple_error;
20701         CYTHON_FALLTHROUGH;
20702         case  1:
20703         if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_pyx_checksum)) != 0)) kw_args--;
20704         else {
20705           __Pyx_RaiseArgtupleInvalid("__pyx_unpickle_Enum", 1, 3, 3, 1); __PYX_ERR(2, 1, __pyx_L3_error)
20706         }
20707         CYTHON_FALLTHROUGH;
20708         case  2:
20709         if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_pyx_state)) != 0)) kw_args--;
20710         else {
20711           __Pyx_RaiseArgtupleInvalid("__pyx_unpickle_Enum", 1, 3, 3, 2); __PYX_ERR(2, 1, __pyx_L3_error)
20712         }
20713       }
20714       if (unlikely(kw_args > 0)) {
20715         if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__pyx_unpickle_Enum") < 0)) __PYX_ERR(2, 1, __pyx_L3_error)
20716       }
20717     } else if (PyTuple_GET_SIZE(__pyx_args) != 3) {
20718       goto __pyx_L5_argtuple_error;
20719     } else {
20720       values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
20721       values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
20722       values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
20723     }
20724     __pyx_v___pyx_type = values[0];
20725     __pyx_v___pyx_checksum = __Pyx_PyInt_As_long(values[1]); if (unlikely((__pyx_v___pyx_checksum == (long)-1) && PyErr_Occurred())) __PYX_ERR(2, 1, __pyx_L3_error)
20726     __pyx_v___pyx_state = values[2];
20727   }
20728   goto __pyx_L4_argument_unpacking_done;
20729   __pyx_L5_argtuple_error:;
20730   __Pyx_RaiseArgtupleInvalid("__pyx_unpickle_Enum", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(2, 1, __pyx_L3_error)
20731   __pyx_L3_error:;
20732   __Pyx_AddTraceback("View.MemoryView.__pyx_unpickle_Enum", __pyx_clineno, __pyx_lineno, __pyx_filename);
20733   __Pyx_RefNannyFinishContext();
20734   return NULL;
20735   __pyx_L4_argument_unpacking_done:;
20736   __pyx_r = __pyx_pf_15View_dot_MemoryView___pyx_unpickle_Enum(__pyx_self, __pyx_v___pyx_type, __pyx_v___pyx_checksum, __pyx_v___pyx_state);
20737 
20738   /* function exit code */
20739   __Pyx_RefNannyFinishContext();
20740   return __pyx_r;
20741 }
20742 
__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)20743 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) {
20744   PyObject *__pyx_v___pyx_PickleError = 0;
20745   PyObject *__pyx_v___pyx_result = 0;
20746   PyObject *__pyx_r = NULL;
20747   __Pyx_RefNannyDeclarations
20748   int __pyx_t_1;
20749   PyObject *__pyx_t_2 = NULL;
20750   PyObject *__pyx_t_3 = NULL;
20751   PyObject *__pyx_t_4 = NULL;
20752   PyObject *__pyx_t_5 = NULL;
20753   int __pyx_t_6;
20754   int __pyx_lineno = 0;
20755   const char *__pyx_filename = NULL;
20756   int __pyx_clineno = 0;
20757   __Pyx_RefNannySetupContext("__pyx_unpickle_Enum", 0);
20758 
20759   /* "(tree fragment)":4
20760  *     cdef object __pyx_PickleError
20761  *     cdef object __pyx_result
20762  *     if __pyx_checksum != 0xb068931:             # <<<<<<<<<<<<<<
20763  *         from pickle import PickleError as __pyx_PickleError
20764  *         raise __pyx_PickleError("Incompatible checksums (%s vs 0xb068931 = (name))" % __pyx_checksum)
20765  */
20766   __pyx_t_1 = ((__pyx_v___pyx_checksum != 0xb068931) != 0);
20767   if (__pyx_t_1) {
20768 
20769     /* "(tree fragment)":5
20770  *     cdef object __pyx_result
20771  *     if __pyx_checksum != 0xb068931:
20772  *         from pickle import PickleError as __pyx_PickleError             # <<<<<<<<<<<<<<
20773  *         raise __pyx_PickleError("Incompatible checksums (%s vs 0xb068931 = (name))" % __pyx_checksum)
20774  *     __pyx_result = Enum.__new__(__pyx_type)
20775  */
20776     __pyx_t_2 = PyList_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 5, __pyx_L1_error)
20777     __Pyx_GOTREF(__pyx_t_2);
20778     __Pyx_INCREF(__pyx_n_s_PickleError);
20779     __Pyx_GIVEREF(__pyx_n_s_PickleError);
20780     PyList_SET_ITEM(__pyx_t_2, 0, __pyx_n_s_PickleError);
20781     __pyx_t_3 = __Pyx_Import(__pyx_n_s_pickle, __pyx_t_2, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 5, __pyx_L1_error)
20782     __Pyx_GOTREF(__pyx_t_3);
20783     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
20784     __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_3, __pyx_n_s_PickleError); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 5, __pyx_L1_error)
20785     __Pyx_GOTREF(__pyx_t_2);
20786     __Pyx_INCREF(__pyx_t_2);
20787     __pyx_v___pyx_PickleError = __pyx_t_2;
20788     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
20789     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
20790 
20791     /* "(tree fragment)":6
20792  *     if __pyx_checksum != 0xb068931:
20793  *         from pickle import PickleError as __pyx_PickleError
20794  *         raise __pyx_PickleError("Incompatible checksums (%s vs 0xb068931 = (name))" % __pyx_checksum)             # <<<<<<<<<<<<<<
20795  *     __pyx_result = Enum.__new__(__pyx_type)
20796  *     if __pyx_state is not None:
20797  */
20798     __pyx_t_2 = __Pyx_PyInt_From_long(__pyx_v___pyx_checksum); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 6, __pyx_L1_error)
20799     __Pyx_GOTREF(__pyx_t_2);
20800     __pyx_t_4 = __Pyx_PyString_Format(__pyx_kp_s_Incompatible_checksums_s_vs_0xb0, __pyx_t_2); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 6, __pyx_L1_error)
20801     __Pyx_GOTREF(__pyx_t_4);
20802     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
20803     __Pyx_INCREF(__pyx_v___pyx_PickleError);
20804     __pyx_t_2 = __pyx_v___pyx_PickleError; __pyx_t_5 = NULL;
20805     if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) {
20806       __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_2);
20807       if (likely(__pyx_t_5)) {
20808         PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
20809         __Pyx_INCREF(__pyx_t_5);
20810         __Pyx_INCREF(function);
20811         __Pyx_DECREF_SET(__pyx_t_2, function);
20812       }
20813     }
20814     __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);
20815     __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
20816     __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
20817     if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 6, __pyx_L1_error)
20818     __Pyx_GOTREF(__pyx_t_3);
20819     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
20820     __Pyx_Raise(__pyx_t_3, 0, 0, 0);
20821     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
20822     __PYX_ERR(2, 6, __pyx_L1_error)
20823 
20824     /* "(tree fragment)":4
20825  *     cdef object __pyx_PickleError
20826  *     cdef object __pyx_result
20827  *     if __pyx_checksum != 0xb068931:             # <<<<<<<<<<<<<<
20828  *         from pickle import PickleError as __pyx_PickleError
20829  *         raise __pyx_PickleError("Incompatible checksums (%s vs 0xb068931 = (name))" % __pyx_checksum)
20830  */
20831   }
20832 
20833   /* "(tree fragment)":7
20834  *         from pickle import PickleError as __pyx_PickleError
20835  *         raise __pyx_PickleError("Incompatible checksums (%s vs 0xb068931 = (name))" % __pyx_checksum)
20836  *     __pyx_result = Enum.__new__(__pyx_type)             # <<<<<<<<<<<<<<
20837  *     if __pyx_state is not None:
20838  *         __pyx_unpickle_Enum__set_state(<Enum> __pyx_result, __pyx_state)
20839  */
20840   __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_MemviewEnum_type), __pyx_n_s_new); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 7, __pyx_L1_error)
20841   __Pyx_GOTREF(__pyx_t_2);
20842   __pyx_t_4 = NULL;
20843   if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
20844     __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_2);
20845     if (likely(__pyx_t_4)) {
20846       PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
20847       __Pyx_INCREF(__pyx_t_4);
20848       __Pyx_INCREF(function);
20849       __Pyx_DECREF_SET(__pyx_t_2, function);
20850     }
20851   }
20852   __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);
20853   __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
20854   if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 7, __pyx_L1_error)
20855   __Pyx_GOTREF(__pyx_t_3);
20856   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
20857   __pyx_v___pyx_result = __pyx_t_3;
20858   __pyx_t_3 = 0;
20859 
20860   /* "(tree fragment)":8
20861  *         raise __pyx_PickleError("Incompatible checksums (%s vs 0xb068931 = (name))" % __pyx_checksum)
20862  *     __pyx_result = Enum.__new__(__pyx_type)
20863  *     if __pyx_state is not None:             # <<<<<<<<<<<<<<
20864  *         __pyx_unpickle_Enum__set_state(<Enum> __pyx_result, __pyx_state)
20865  *     return __pyx_result
20866  */
20867   __pyx_t_1 = (__pyx_v___pyx_state != Py_None);
20868   __pyx_t_6 = (__pyx_t_1 != 0);
20869   if (__pyx_t_6) {
20870 
20871     /* "(tree fragment)":9
20872  *     __pyx_result = Enum.__new__(__pyx_type)
20873  *     if __pyx_state is not None:
20874  *         __pyx_unpickle_Enum__set_state(<Enum> __pyx_result, __pyx_state)             # <<<<<<<<<<<<<<
20875  *     return __pyx_result
20876  * cdef __pyx_unpickle_Enum__set_state(Enum __pyx_result, tuple __pyx_state):
20877  */
20878     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(2, 9, __pyx_L1_error)
20879     __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(2, 9, __pyx_L1_error)
20880     __Pyx_GOTREF(__pyx_t_3);
20881     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
20882 
20883     /* "(tree fragment)":8
20884  *         raise __pyx_PickleError("Incompatible checksums (%s vs 0xb068931 = (name))" % __pyx_checksum)
20885  *     __pyx_result = Enum.__new__(__pyx_type)
20886  *     if __pyx_state is not None:             # <<<<<<<<<<<<<<
20887  *         __pyx_unpickle_Enum__set_state(<Enum> __pyx_result, __pyx_state)
20888  *     return __pyx_result
20889  */
20890   }
20891 
20892   /* "(tree fragment)":10
20893  *     if __pyx_state is not None:
20894  *         __pyx_unpickle_Enum__set_state(<Enum> __pyx_result, __pyx_state)
20895  *     return __pyx_result             # <<<<<<<<<<<<<<
20896  * cdef __pyx_unpickle_Enum__set_state(Enum __pyx_result, tuple __pyx_state):
20897  *     __pyx_result.name = __pyx_state[0]
20898  */
20899   __Pyx_XDECREF(__pyx_r);
20900   __Pyx_INCREF(__pyx_v___pyx_result);
20901   __pyx_r = __pyx_v___pyx_result;
20902   goto __pyx_L0;
20903 
20904   /* "(tree fragment)":1
20905  * def __pyx_unpickle_Enum(__pyx_type, long __pyx_checksum, __pyx_state):             # <<<<<<<<<<<<<<
20906  *     cdef object __pyx_PickleError
20907  *     cdef object __pyx_result
20908  */
20909 
20910   /* function exit code */
20911   __pyx_L1_error:;
20912   __Pyx_XDECREF(__pyx_t_2);
20913   __Pyx_XDECREF(__pyx_t_3);
20914   __Pyx_XDECREF(__pyx_t_4);
20915   __Pyx_XDECREF(__pyx_t_5);
20916   __Pyx_AddTraceback("View.MemoryView.__pyx_unpickle_Enum", __pyx_clineno, __pyx_lineno, __pyx_filename);
20917   __pyx_r = NULL;
20918   __pyx_L0:;
20919   __Pyx_XDECREF(__pyx_v___pyx_PickleError);
20920   __Pyx_XDECREF(__pyx_v___pyx_result);
20921   __Pyx_XGIVEREF(__pyx_r);
20922   __Pyx_RefNannyFinishContext();
20923   return __pyx_r;
20924 }
20925 
20926 /* "(tree fragment)":11
20927  *         __pyx_unpickle_Enum__set_state(<Enum> __pyx_result, __pyx_state)
20928  *     return __pyx_result
20929  * cdef __pyx_unpickle_Enum__set_state(Enum __pyx_result, tuple __pyx_state):             # <<<<<<<<<<<<<<
20930  *     __pyx_result.name = __pyx_state[0]
20931  *     if len(__pyx_state) > 1 and hasattr(__pyx_result, '__dict__'):
20932  */
20933 
__pyx_unpickle_Enum__set_state(struct __pyx_MemviewEnum_obj * __pyx_v___pyx_result,PyObject * __pyx_v___pyx_state)20934 static PyObject *__pyx_unpickle_Enum__set_state(struct __pyx_MemviewEnum_obj *__pyx_v___pyx_result, PyObject *__pyx_v___pyx_state) {
20935   PyObject *__pyx_r = NULL;
20936   __Pyx_RefNannyDeclarations
20937   PyObject *__pyx_t_1 = NULL;
20938   int __pyx_t_2;
20939   Py_ssize_t __pyx_t_3;
20940   int __pyx_t_4;
20941   int __pyx_t_5;
20942   PyObject *__pyx_t_6 = NULL;
20943   PyObject *__pyx_t_7 = NULL;
20944   PyObject *__pyx_t_8 = NULL;
20945   int __pyx_lineno = 0;
20946   const char *__pyx_filename = NULL;
20947   int __pyx_clineno = 0;
20948   __Pyx_RefNannySetupContext("__pyx_unpickle_Enum__set_state", 0);
20949 
20950   /* "(tree fragment)":12
20951  *     return __pyx_result
20952  * cdef __pyx_unpickle_Enum__set_state(Enum __pyx_result, tuple __pyx_state):
20953  *     __pyx_result.name = __pyx_state[0]             # <<<<<<<<<<<<<<
20954  *     if len(__pyx_state) > 1 and hasattr(__pyx_result, '__dict__'):
20955  *         __pyx_result.__dict__.update(__pyx_state[1])
20956  */
20957   if (unlikely(__pyx_v___pyx_state == Py_None)) {
20958     PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
20959     __PYX_ERR(2, 12, __pyx_L1_error)
20960   }
20961   __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(2, 12, __pyx_L1_error)
20962   __Pyx_GOTREF(__pyx_t_1);
20963   __Pyx_GIVEREF(__pyx_t_1);
20964   __Pyx_GOTREF(__pyx_v___pyx_result->name);
20965   __Pyx_DECREF(__pyx_v___pyx_result->name);
20966   __pyx_v___pyx_result->name = __pyx_t_1;
20967   __pyx_t_1 = 0;
20968 
20969   /* "(tree fragment)":13
20970  * cdef __pyx_unpickle_Enum__set_state(Enum __pyx_result, tuple __pyx_state):
20971  *     __pyx_result.name = __pyx_state[0]
20972  *     if len(__pyx_state) > 1 and hasattr(__pyx_result, '__dict__'):             # <<<<<<<<<<<<<<
20973  *         __pyx_result.__dict__.update(__pyx_state[1])
20974  */
20975   if (unlikely(__pyx_v___pyx_state == Py_None)) {
20976     PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
20977     __PYX_ERR(2, 13, __pyx_L1_error)
20978   }
20979   __pyx_t_3 = PyTuple_GET_SIZE(__pyx_v___pyx_state); if (unlikely(__pyx_t_3 == ((Py_ssize_t)-1))) __PYX_ERR(2, 13, __pyx_L1_error)
20980   __pyx_t_4 = ((__pyx_t_3 > 1) != 0);
20981   if (__pyx_t_4) {
20982   } else {
20983     __pyx_t_2 = __pyx_t_4;
20984     goto __pyx_L4_bool_binop_done;
20985   }
20986   __pyx_t_4 = __Pyx_HasAttr(((PyObject *)__pyx_v___pyx_result), __pyx_n_s_dict); if (unlikely(__pyx_t_4 == ((int)-1))) __PYX_ERR(2, 13, __pyx_L1_error)
20987   __pyx_t_5 = (__pyx_t_4 != 0);
20988   __pyx_t_2 = __pyx_t_5;
20989   __pyx_L4_bool_binop_done:;
20990   if (__pyx_t_2) {
20991 
20992     /* "(tree fragment)":14
20993  *     __pyx_result.name = __pyx_state[0]
20994  *     if len(__pyx_state) > 1 and hasattr(__pyx_result, '__dict__'):
20995  *         __pyx_result.__dict__.update(__pyx_state[1])             # <<<<<<<<<<<<<<
20996  */
20997     __pyx_t_6 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v___pyx_result), __pyx_n_s_dict); if (unlikely(!__pyx_t_6)) __PYX_ERR(2, 14, __pyx_L1_error)
20998     __Pyx_GOTREF(__pyx_t_6);
20999     __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_update); if (unlikely(!__pyx_t_7)) __PYX_ERR(2, 14, __pyx_L1_error)
21000     __Pyx_GOTREF(__pyx_t_7);
21001     __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
21002     if (unlikely(__pyx_v___pyx_state == Py_None)) {
21003       PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
21004       __PYX_ERR(2, 14, __pyx_L1_error)
21005     }
21006     __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(2, 14, __pyx_L1_error)
21007     __Pyx_GOTREF(__pyx_t_6);
21008     __pyx_t_8 = NULL;
21009     if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_7))) {
21010       __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_7);
21011       if (likely(__pyx_t_8)) {
21012         PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7);
21013         __Pyx_INCREF(__pyx_t_8);
21014         __Pyx_INCREF(function);
21015         __Pyx_DECREF_SET(__pyx_t_7, function);
21016       }
21017     }
21018     __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);
21019     __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
21020     __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
21021     if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 14, __pyx_L1_error)
21022     __Pyx_GOTREF(__pyx_t_1);
21023     __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
21024     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
21025 
21026     /* "(tree fragment)":13
21027  * cdef __pyx_unpickle_Enum__set_state(Enum __pyx_result, tuple __pyx_state):
21028  *     __pyx_result.name = __pyx_state[0]
21029  *     if len(__pyx_state) > 1 and hasattr(__pyx_result, '__dict__'):             # <<<<<<<<<<<<<<
21030  *         __pyx_result.__dict__.update(__pyx_state[1])
21031  */
21032   }
21033 
21034   /* "(tree fragment)":11
21035  *         __pyx_unpickle_Enum__set_state(<Enum> __pyx_result, __pyx_state)
21036  *     return __pyx_result
21037  * cdef __pyx_unpickle_Enum__set_state(Enum __pyx_result, tuple __pyx_state):             # <<<<<<<<<<<<<<
21038  *     __pyx_result.name = __pyx_state[0]
21039  *     if len(__pyx_state) > 1 and hasattr(__pyx_result, '__dict__'):
21040  */
21041 
21042   /* function exit code */
21043   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
21044   goto __pyx_L0;
21045   __pyx_L1_error:;
21046   __Pyx_XDECREF(__pyx_t_1);
21047   __Pyx_XDECREF(__pyx_t_6);
21048   __Pyx_XDECREF(__pyx_t_7);
21049   __Pyx_XDECREF(__pyx_t_8);
21050   __Pyx_AddTraceback("View.MemoryView.__pyx_unpickle_Enum__set_state", __pyx_clineno, __pyx_lineno, __pyx_filename);
21051   __pyx_r = 0;
21052   __pyx_L0:;
21053   __Pyx_XGIVEREF(__pyx_r);
21054   __Pyx_RefNannyFinishContext();
21055   return __pyx_r;
21056 }
21057 static struct __pyx_vtabstruct_array __pyx_vtable_array;
21058 
__pyx_tp_new_array(PyTypeObject * t,PyObject * a,PyObject * k)21059 static PyObject *__pyx_tp_new_array(PyTypeObject *t, PyObject *a, PyObject *k) {
21060   struct __pyx_array_obj *p;
21061   PyObject *o;
21062   if (likely((t->tp_flags & Py_TPFLAGS_IS_ABSTRACT) == 0)) {
21063     o = (*t->tp_alloc)(t, 0);
21064   } else {
21065     o = (PyObject *) PyBaseObject_Type.tp_new(t, __pyx_empty_tuple, 0);
21066   }
21067   if (unlikely(!o)) return 0;
21068   p = ((struct __pyx_array_obj *)o);
21069   p->__pyx_vtab = __pyx_vtabptr_array;
21070   p->mode = ((PyObject*)Py_None); Py_INCREF(Py_None);
21071   p->_format = ((PyObject*)Py_None); Py_INCREF(Py_None);
21072   if (unlikely(__pyx_array___cinit__(o, a, k) < 0)) goto bad;
21073   return o;
21074   bad:
21075   Py_DECREF(o); o = 0;
21076   return NULL;
21077 }
21078 
__pyx_tp_dealloc_array(PyObject * o)21079 static void __pyx_tp_dealloc_array(PyObject *o) {
21080   struct __pyx_array_obj *p = (struct __pyx_array_obj *)o;
21081   #if CYTHON_USE_TP_FINALIZE
21082   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))) {
21083     if (PyObject_CallFinalizerFromDealloc(o)) return;
21084   }
21085   #endif
21086   {
21087     PyObject *etype, *eval, *etb;
21088     PyErr_Fetch(&etype, &eval, &etb);
21089     __Pyx_SET_REFCNT(o, Py_REFCNT(o) + 1);
21090     __pyx_array___dealloc__(o);
21091     __Pyx_SET_REFCNT(o, Py_REFCNT(o) - 1);
21092     PyErr_Restore(etype, eval, etb);
21093   }
21094   Py_CLEAR(p->mode);
21095   Py_CLEAR(p->_format);
21096   (*Py_TYPE(o)->tp_free)(o);
21097 }
__pyx_sq_item_array(PyObject * o,Py_ssize_t i)21098 static PyObject *__pyx_sq_item_array(PyObject *o, Py_ssize_t i) {
21099   PyObject *r;
21100   PyObject *x = PyInt_FromSsize_t(i); if(!x) return 0;
21101   r = Py_TYPE(o)->tp_as_mapping->mp_subscript(o, x);
21102   Py_DECREF(x);
21103   return r;
21104 }
21105 
__pyx_mp_ass_subscript_array(PyObject * o,PyObject * i,PyObject * v)21106 static int __pyx_mp_ass_subscript_array(PyObject *o, PyObject *i, PyObject *v) {
21107   if (v) {
21108     return __pyx_array___setitem__(o, i, v);
21109   }
21110   else {
21111     PyErr_Format(PyExc_NotImplementedError,
21112       "Subscript deletion not supported by %.200s", Py_TYPE(o)->tp_name);
21113     return -1;
21114   }
21115 }
21116 
__pyx_tp_getattro_array(PyObject * o,PyObject * n)21117 static PyObject *__pyx_tp_getattro_array(PyObject *o, PyObject *n) {
21118   PyObject *v = __Pyx_PyObject_GenericGetAttr(o, n);
21119   if (!v && PyErr_ExceptionMatches(PyExc_AttributeError)) {
21120     PyErr_Clear();
21121     v = __pyx_array___getattr__(o, n);
21122   }
21123   return v;
21124 }
21125 
__pyx_getprop___pyx_array_memview(PyObject * o,CYTHON_UNUSED void * x)21126 static PyObject *__pyx_getprop___pyx_array_memview(PyObject *o, CYTHON_UNUSED void *x) {
21127   return __pyx_pw_15View_dot_MemoryView_5array_7memview_1__get__(o);
21128 }
21129 
21130 static PyMethodDef __pyx_methods_array[] = {
21131   {"__getattr__", (PyCFunction)__pyx_array___getattr__, METH_O|METH_COEXIST, 0},
21132   {"__reduce_cython__", (PyCFunction)__pyx_pw___pyx_array_1__reduce_cython__, METH_NOARGS, 0},
21133   {"__setstate_cython__", (PyCFunction)__pyx_pw___pyx_array_3__setstate_cython__, METH_O, 0},
21134   {0, 0, 0, 0}
21135 };
21136 
21137 static struct PyGetSetDef __pyx_getsets_array[] = {
21138   {(char *)"memview", __pyx_getprop___pyx_array_memview, 0, (char *)0, 0},
21139   {0, 0, 0, 0, 0}
21140 };
21141 
21142 static PySequenceMethods __pyx_tp_as_sequence_array = {
21143   __pyx_array___len__, /*sq_length*/
21144   0, /*sq_concat*/
21145   0, /*sq_repeat*/
21146   __pyx_sq_item_array, /*sq_item*/
21147   0, /*sq_slice*/
21148   0, /*sq_ass_item*/
21149   0, /*sq_ass_slice*/
21150   0, /*sq_contains*/
21151   0, /*sq_inplace_concat*/
21152   0, /*sq_inplace_repeat*/
21153 };
21154 
21155 static PyMappingMethods __pyx_tp_as_mapping_array = {
21156   __pyx_array___len__, /*mp_length*/
21157   __pyx_array___getitem__, /*mp_subscript*/
21158   __pyx_mp_ass_subscript_array, /*mp_ass_subscript*/
21159 };
21160 
21161 static PyBufferProcs __pyx_tp_as_buffer_array = {
21162   #if PY_MAJOR_VERSION < 3
21163   0, /*bf_getreadbuffer*/
21164   #endif
21165   #if PY_MAJOR_VERSION < 3
21166   0, /*bf_getwritebuffer*/
21167   #endif
21168   #if PY_MAJOR_VERSION < 3
21169   0, /*bf_getsegcount*/
21170   #endif
21171   #if PY_MAJOR_VERSION < 3
21172   0, /*bf_getcharbuffer*/
21173   #endif
21174   __pyx_array_getbuffer, /*bf_getbuffer*/
21175   0, /*bf_releasebuffer*/
21176 };
21177 
21178 static PyTypeObject __pyx_type___pyx_array = {
21179   PyVarObject_HEAD_INIT(0, 0)
21180   "qutip.cy.ptrace.array", /*tp_name*/
21181   sizeof(struct __pyx_array_obj), /*tp_basicsize*/
21182   0, /*tp_itemsize*/
21183   __pyx_tp_dealloc_array, /*tp_dealloc*/
21184   #if PY_VERSION_HEX < 0x030800b4
21185   0, /*tp_print*/
21186   #endif
21187   #if PY_VERSION_HEX >= 0x030800b4
21188   0, /*tp_vectorcall_offset*/
21189   #endif
21190   0, /*tp_getattr*/
21191   0, /*tp_setattr*/
21192   #if PY_MAJOR_VERSION < 3
21193   0, /*tp_compare*/
21194   #endif
21195   #if PY_MAJOR_VERSION >= 3
21196   0, /*tp_as_async*/
21197   #endif
21198   0, /*tp_repr*/
21199   0, /*tp_as_number*/
21200   &__pyx_tp_as_sequence_array, /*tp_as_sequence*/
21201   &__pyx_tp_as_mapping_array, /*tp_as_mapping*/
21202   0, /*tp_hash*/
21203   0, /*tp_call*/
21204   0, /*tp_str*/
21205   __pyx_tp_getattro_array, /*tp_getattro*/
21206   0, /*tp_setattro*/
21207   &__pyx_tp_as_buffer_array, /*tp_as_buffer*/
21208   Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE, /*tp_flags*/
21209   0, /*tp_doc*/
21210   0, /*tp_traverse*/
21211   0, /*tp_clear*/
21212   0, /*tp_richcompare*/
21213   0, /*tp_weaklistoffset*/
21214   0, /*tp_iter*/
21215   0, /*tp_iternext*/
21216   __pyx_methods_array, /*tp_methods*/
21217   0, /*tp_members*/
21218   __pyx_getsets_array, /*tp_getset*/
21219   0, /*tp_base*/
21220   0, /*tp_dict*/
21221   0, /*tp_descr_get*/
21222   0, /*tp_descr_set*/
21223   0, /*tp_dictoffset*/
21224   0, /*tp_init*/
21225   0, /*tp_alloc*/
21226   __pyx_tp_new_array, /*tp_new*/
21227   0, /*tp_free*/
21228   0, /*tp_is_gc*/
21229   0, /*tp_bases*/
21230   0, /*tp_mro*/
21231   0, /*tp_cache*/
21232   0, /*tp_subclasses*/
21233   0, /*tp_weaklist*/
21234   0, /*tp_del*/
21235   0, /*tp_version_tag*/
21236   #if PY_VERSION_HEX >= 0x030400a1
21237   0, /*tp_finalize*/
21238   #endif
21239   #if PY_VERSION_HEX >= 0x030800b1
21240   0, /*tp_vectorcall*/
21241   #endif
21242   #if PY_VERSION_HEX >= 0x030800b4 && PY_VERSION_HEX < 0x03090000
21243   0, /*tp_print*/
21244   #endif
21245 };
21246 
__pyx_tp_new_Enum(PyTypeObject * t,CYTHON_UNUSED PyObject * a,CYTHON_UNUSED PyObject * k)21247 static PyObject *__pyx_tp_new_Enum(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
21248   struct __pyx_MemviewEnum_obj *p;
21249   PyObject *o;
21250   if (likely((t->tp_flags & Py_TPFLAGS_IS_ABSTRACT) == 0)) {
21251     o = (*t->tp_alloc)(t, 0);
21252   } else {
21253     o = (PyObject *) PyBaseObject_Type.tp_new(t, __pyx_empty_tuple, 0);
21254   }
21255   if (unlikely(!o)) return 0;
21256   p = ((struct __pyx_MemviewEnum_obj *)o);
21257   p->name = Py_None; Py_INCREF(Py_None);
21258   return o;
21259 }
21260 
__pyx_tp_dealloc_Enum(PyObject * o)21261 static void __pyx_tp_dealloc_Enum(PyObject *o) {
21262   struct __pyx_MemviewEnum_obj *p = (struct __pyx_MemviewEnum_obj *)o;
21263   #if CYTHON_USE_TP_FINALIZE
21264   if (unlikely(PyType_HasFeature(Py_TYPE(o), Py_TPFLAGS_HAVE_FINALIZE) && Py_TYPE(o)->tp_finalize) && !_PyGC_FINALIZED(o)) {
21265     if (PyObject_CallFinalizerFromDealloc(o)) return;
21266   }
21267   #endif
21268   PyObject_GC_UnTrack(o);
21269   Py_CLEAR(p->name);
21270   (*Py_TYPE(o)->tp_free)(o);
21271 }
21272 
__pyx_tp_traverse_Enum(PyObject * o,visitproc v,void * a)21273 static int __pyx_tp_traverse_Enum(PyObject *o, visitproc v, void *a) {
21274   int e;
21275   struct __pyx_MemviewEnum_obj *p = (struct __pyx_MemviewEnum_obj *)o;
21276   if (p->name) {
21277     e = (*v)(p->name, a); if (e) return e;
21278   }
21279   return 0;
21280 }
21281 
__pyx_tp_clear_Enum(PyObject * o)21282 static int __pyx_tp_clear_Enum(PyObject *o) {
21283   PyObject* tmp;
21284   struct __pyx_MemviewEnum_obj *p = (struct __pyx_MemviewEnum_obj *)o;
21285   tmp = ((PyObject*)p->name);
21286   p->name = Py_None; Py_INCREF(Py_None);
21287   Py_XDECREF(tmp);
21288   return 0;
21289 }
21290 
21291 static PyMethodDef __pyx_methods_Enum[] = {
21292   {"__reduce_cython__", (PyCFunction)__pyx_pw___pyx_MemviewEnum_1__reduce_cython__, METH_NOARGS, 0},
21293   {"__setstate_cython__", (PyCFunction)__pyx_pw___pyx_MemviewEnum_3__setstate_cython__, METH_O, 0},
21294   {0, 0, 0, 0}
21295 };
21296 
21297 static PyTypeObject __pyx_type___pyx_MemviewEnum = {
21298   PyVarObject_HEAD_INIT(0, 0)
21299   "qutip.cy.ptrace.Enum", /*tp_name*/
21300   sizeof(struct __pyx_MemviewEnum_obj), /*tp_basicsize*/
21301   0, /*tp_itemsize*/
21302   __pyx_tp_dealloc_Enum, /*tp_dealloc*/
21303   #if PY_VERSION_HEX < 0x030800b4
21304   0, /*tp_print*/
21305   #endif
21306   #if PY_VERSION_HEX >= 0x030800b4
21307   0, /*tp_vectorcall_offset*/
21308   #endif
21309   0, /*tp_getattr*/
21310   0, /*tp_setattr*/
21311   #if PY_MAJOR_VERSION < 3
21312   0, /*tp_compare*/
21313   #endif
21314   #if PY_MAJOR_VERSION >= 3
21315   0, /*tp_as_async*/
21316   #endif
21317   __pyx_MemviewEnum___repr__, /*tp_repr*/
21318   0, /*tp_as_number*/
21319   0, /*tp_as_sequence*/
21320   0, /*tp_as_mapping*/
21321   0, /*tp_hash*/
21322   0, /*tp_call*/
21323   0, /*tp_str*/
21324   0, /*tp_getattro*/
21325   0, /*tp_setattro*/
21326   0, /*tp_as_buffer*/
21327   Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
21328   0, /*tp_doc*/
21329   __pyx_tp_traverse_Enum, /*tp_traverse*/
21330   __pyx_tp_clear_Enum, /*tp_clear*/
21331   0, /*tp_richcompare*/
21332   0, /*tp_weaklistoffset*/
21333   0, /*tp_iter*/
21334   0, /*tp_iternext*/
21335   __pyx_methods_Enum, /*tp_methods*/
21336   0, /*tp_members*/
21337   0, /*tp_getset*/
21338   0, /*tp_base*/
21339   0, /*tp_dict*/
21340   0, /*tp_descr_get*/
21341   0, /*tp_descr_set*/
21342   0, /*tp_dictoffset*/
21343   __pyx_MemviewEnum___init__, /*tp_init*/
21344   0, /*tp_alloc*/
21345   __pyx_tp_new_Enum, /*tp_new*/
21346   0, /*tp_free*/
21347   0, /*tp_is_gc*/
21348   0, /*tp_bases*/
21349   0, /*tp_mro*/
21350   0, /*tp_cache*/
21351   0, /*tp_subclasses*/
21352   0, /*tp_weaklist*/
21353   0, /*tp_del*/
21354   0, /*tp_version_tag*/
21355   #if PY_VERSION_HEX >= 0x030400a1
21356   0, /*tp_finalize*/
21357   #endif
21358   #if PY_VERSION_HEX >= 0x030800b1
21359   0, /*tp_vectorcall*/
21360   #endif
21361   #if PY_VERSION_HEX >= 0x030800b4 && PY_VERSION_HEX < 0x03090000
21362   0, /*tp_print*/
21363   #endif
21364 };
21365 static struct __pyx_vtabstruct_memoryview __pyx_vtable_memoryview;
21366 
__pyx_tp_new_memoryview(PyTypeObject * t,PyObject * a,PyObject * k)21367 static PyObject *__pyx_tp_new_memoryview(PyTypeObject *t, PyObject *a, PyObject *k) {
21368   struct __pyx_memoryview_obj *p;
21369   PyObject *o;
21370   if (likely((t->tp_flags & Py_TPFLAGS_IS_ABSTRACT) == 0)) {
21371     o = (*t->tp_alloc)(t, 0);
21372   } else {
21373     o = (PyObject *) PyBaseObject_Type.tp_new(t, __pyx_empty_tuple, 0);
21374   }
21375   if (unlikely(!o)) return 0;
21376   p = ((struct __pyx_memoryview_obj *)o);
21377   p->__pyx_vtab = __pyx_vtabptr_memoryview;
21378   p->obj = Py_None; Py_INCREF(Py_None);
21379   p->_size = Py_None; Py_INCREF(Py_None);
21380   p->_array_interface = Py_None; Py_INCREF(Py_None);
21381   p->view.obj = NULL;
21382   if (unlikely(__pyx_memoryview___cinit__(o, a, k) < 0)) goto bad;
21383   return o;
21384   bad:
21385   Py_DECREF(o); o = 0;
21386   return NULL;
21387 }
21388 
__pyx_tp_dealloc_memoryview(PyObject * o)21389 static void __pyx_tp_dealloc_memoryview(PyObject *o) {
21390   struct __pyx_memoryview_obj *p = (struct __pyx_memoryview_obj *)o;
21391   #if CYTHON_USE_TP_FINALIZE
21392   if (unlikely(PyType_HasFeature(Py_TYPE(o), Py_TPFLAGS_HAVE_FINALIZE) && Py_TYPE(o)->tp_finalize) && !_PyGC_FINALIZED(o)) {
21393     if (PyObject_CallFinalizerFromDealloc(o)) return;
21394   }
21395   #endif
21396   PyObject_GC_UnTrack(o);
21397   {
21398     PyObject *etype, *eval, *etb;
21399     PyErr_Fetch(&etype, &eval, &etb);
21400     __Pyx_SET_REFCNT(o, Py_REFCNT(o) + 1);
21401     __pyx_memoryview___dealloc__(o);
21402     __Pyx_SET_REFCNT(o, Py_REFCNT(o) - 1);
21403     PyErr_Restore(etype, eval, etb);
21404   }
21405   Py_CLEAR(p->obj);
21406   Py_CLEAR(p->_size);
21407   Py_CLEAR(p->_array_interface);
21408   (*Py_TYPE(o)->tp_free)(o);
21409 }
21410 
__pyx_tp_traverse_memoryview(PyObject * o,visitproc v,void * a)21411 static int __pyx_tp_traverse_memoryview(PyObject *o, visitproc v, void *a) {
21412   int e;
21413   struct __pyx_memoryview_obj *p = (struct __pyx_memoryview_obj *)o;
21414   if (p->obj) {
21415     e = (*v)(p->obj, a); if (e) return e;
21416   }
21417   if (p->_size) {
21418     e = (*v)(p->_size, a); if (e) return e;
21419   }
21420   if (p->_array_interface) {
21421     e = (*v)(p->_array_interface, a); if (e) return e;
21422   }
21423   if (p->view.obj) {
21424     e = (*v)(p->view.obj, a); if (e) return e;
21425   }
21426   return 0;
21427 }
21428 
__pyx_tp_clear_memoryview(PyObject * o)21429 static int __pyx_tp_clear_memoryview(PyObject *o) {
21430   PyObject* tmp;
21431   struct __pyx_memoryview_obj *p = (struct __pyx_memoryview_obj *)o;
21432   tmp = ((PyObject*)p->obj);
21433   p->obj = Py_None; Py_INCREF(Py_None);
21434   Py_XDECREF(tmp);
21435   tmp = ((PyObject*)p->_size);
21436   p->_size = Py_None; Py_INCREF(Py_None);
21437   Py_XDECREF(tmp);
21438   tmp = ((PyObject*)p->_array_interface);
21439   p->_array_interface = Py_None; Py_INCREF(Py_None);
21440   Py_XDECREF(tmp);
21441   Py_CLEAR(p->view.obj);
21442   return 0;
21443 }
__pyx_sq_item_memoryview(PyObject * o,Py_ssize_t i)21444 static PyObject *__pyx_sq_item_memoryview(PyObject *o, Py_ssize_t i) {
21445   PyObject *r;
21446   PyObject *x = PyInt_FromSsize_t(i); if(!x) return 0;
21447   r = Py_TYPE(o)->tp_as_mapping->mp_subscript(o, x);
21448   Py_DECREF(x);
21449   return r;
21450 }
21451 
__pyx_mp_ass_subscript_memoryview(PyObject * o,PyObject * i,PyObject * v)21452 static int __pyx_mp_ass_subscript_memoryview(PyObject *o, PyObject *i, PyObject *v) {
21453   if (v) {
21454     return __pyx_memoryview___setitem__(o, i, v);
21455   }
21456   else {
21457     PyErr_Format(PyExc_NotImplementedError,
21458       "Subscript deletion not supported by %.200s", Py_TYPE(o)->tp_name);
21459     return -1;
21460   }
21461 }
21462 
__pyx_getprop___pyx_memoryview_T(PyObject * o,CYTHON_UNUSED void * x)21463 static PyObject *__pyx_getprop___pyx_memoryview_T(PyObject *o, CYTHON_UNUSED void *x) {
21464   return __pyx_pw_15View_dot_MemoryView_10memoryview_1T_1__get__(o);
21465 }
21466 
__pyx_getprop___pyx_memoryview_base(PyObject * o,CYTHON_UNUSED void * x)21467 static PyObject *__pyx_getprop___pyx_memoryview_base(PyObject *o, CYTHON_UNUSED void *x) {
21468   return __pyx_pw_15View_dot_MemoryView_10memoryview_4base_1__get__(o);
21469 }
21470 
__pyx_getprop___pyx_memoryview_shape(PyObject * o,CYTHON_UNUSED void * x)21471 static PyObject *__pyx_getprop___pyx_memoryview_shape(PyObject *o, CYTHON_UNUSED void *x) {
21472   return __pyx_pw_15View_dot_MemoryView_10memoryview_5shape_1__get__(o);
21473 }
21474 
__pyx_getprop___pyx_memoryview_strides(PyObject * o,CYTHON_UNUSED void * x)21475 static PyObject *__pyx_getprop___pyx_memoryview_strides(PyObject *o, CYTHON_UNUSED void *x) {
21476   return __pyx_pw_15View_dot_MemoryView_10memoryview_7strides_1__get__(o);
21477 }
21478 
__pyx_getprop___pyx_memoryview_suboffsets(PyObject * o,CYTHON_UNUSED void * x)21479 static PyObject *__pyx_getprop___pyx_memoryview_suboffsets(PyObject *o, CYTHON_UNUSED void *x) {
21480   return __pyx_pw_15View_dot_MemoryView_10memoryview_10suboffsets_1__get__(o);
21481 }
21482 
__pyx_getprop___pyx_memoryview_ndim(PyObject * o,CYTHON_UNUSED void * x)21483 static PyObject *__pyx_getprop___pyx_memoryview_ndim(PyObject *o, CYTHON_UNUSED void *x) {
21484   return __pyx_pw_15View_dot_MemoryView_10memoryview_4ndim_1__get__(o);
21485 }
21486 
__pyx_getprop___pyx_memoryview_itemsize(PyObject * o,CYTHON_UNUSED void * x)21487 static PyObject *__pyx_getprop___pyx_memoryview_itemsize(PyObject *o, CYTHON_UNUSED void *x) {
21488   return __pyx_pw_15View_dot_MemoryView_10memoryview_8itemsize_1__get__(o);
21489 }
21490 
__pyx_getprop___pyx_memoryview_nbytes(PyObject * o,CYTHON_UNUSED void * x)21491 static PyObject *__pyx_getprop___pyx_memoryview_nbytes(PyObject *o, CYTHON_UNUSED void *x) {
21492   return __pyx_pw_15View_dot_MemoryView_10memoryview_6nbytes_1__get__(o);
21493 }
21494 
__pyx_getprop___pyx_memoryview_size(PyObject * o,CYTHON_UNUSED void * x)21495 static PyObject *__pyx_getprop___pyx_memoryview_size(PyObject *o, CYTHON_UNUSED void *x) {
21496   return __pyx_pw_15View_dot_MemoryView_10memoryview_4size_1__get__(o);
21497 }
21498 
21499 static PyMethodDef __pyx_methods_memoryview[] = {
21500   {"is_c_contig", (PyCFunction)__pyx_memoryview_is_c_contig, METH_NOARGS, 0},
21501   {"is_f_contig", (PyCFunction)__pyx_memoryview_is_f_contig, METH_NOARGS, 0},
21502   {"copy", (PyCFunction)__pyx_memoryview_copy, METH_NOARGS, 0},
21503   {"copy_fortran", (PyCFunction)__pyx_memoryview_copy_fortran, METH_NOARGS, 0},
21504   {"__reduce_cython__", (PyCFunction)__pyx_pw___pyx_memoryview_1__reduce_cython__, METH_NOARGS, 0},
21505   {"__setstate_cython__", (PyCFunction)__pyx_pw___pyx_memoryview_3__setstate_cython__, METH_O, 0},
21506   {0, 0, 0, 0}
21507 };
21508 
21509 static struct PyGetSetDef __pyx_getsets_memoryview[] = {
21510   {(char *)"T", __pyx_getprop___pyx_memoryview_T, 0, (char *)0, 0},
21511   {(char *)"base", __pyx_getprop___pyx_memoryview_base, 0, (char *)0, 0},
21512   {(char *)"shape", __pyx_getprop___pyx_memoryview_shape, 0, (char *)0, 0},
21513   {(char *)"strides", __pyx_getprop___pyx_memoryview_strides, 0, (char *)0, 0},
21514   {(char *)"suboffsets", __pyx_getprop___pyx_memoryview_suboffsets, 0, (char *)0, 0},
21515   {(char *)"ndim", __pyx_getprop___pyx_memoryview_ndim, 0, (char *)0, 0},
21516   {(char *)"itemsize", __pyx_getprop___pyx_memoryview_itemsize, 0, (char *)0, 0},
21517   {(char *)"nbytes", __pyx_getprop___pyx_memoryview_nbytes, 0, (char *)0, 0},
21518   {(char *)"size", __pyx_getprop___pyx_memoryview_size, 0, (char *)0, 0},
21519   {0, 0, 0, 0, 0}
21520 };
21521 
21522 static PySequenceMethods __pyx_tp_as_sequence_memoryview = {
21523   __pyx_memoryview___len__, /*sq_length*/
21524   0, /*sq_concat*/
21525   0, /*sq_repeat*/
21526   __pyx_sq_item_memoryview, /*sq_item*/
21527   0, /*sq_slice*/
21528   0, /*sq_ass_item*/
21529   0, /*sq_ass_slice*/
21530   0, /*sq_contains*/
21531   0, /*sq_inplace_concat*/
21532   0, /*sq_inplace_repeat*/
21533 };
21534 
21535 static PyMappingMethods __pyx_tp_as_mapping_memoryview = {
21536   __pyx_memoryview___len__, /*mp_length*/
21537   __pyx_memoryview___getitem__, /*mp_subscript*/
21538   __pyx_mp_ass_subscript_memoryview, /*mp_ass_subscript*/
21539 };
21540 
21541 static PyBufferProcs __pyx_tp_as_buffer_memoryview = {
21542   #if PY_MAJOR_VERSION < 3
21543   0, /*bf_getreadbuffer*/
21544   #endif
21545   #if PY_MAJOR_VERSION < 3
21546   0, /*bf_getwritebuffer*/
21547   #endif
21548   #if PY_MAJOR_VERSION < 3
21549   0, /*bf_getsegcount*/
21550   #endif
21551   #if PY_MAJOR_VERSION < 3
21552   0, /*bf_getcharbuffer*/
21553   #endif
21554   __pyx_memoryview_getbuffer, /*bf_getbuffer*/
21555   0, /*bf_releasebuffer*/
21556 };
21557 
21558 static PyTypeObject __pyx_type___pyx_memoryview = {
21559   PyVarObject_HEAD_INIT(0, 0)
21560   "qutip.cy.ptrace.memoryview", /*tp_name*/
21561   sizeof(struct __pyx_memoryview_obj), /*tp_basicsize*/
21562   0, /*tp_itemsize*/
21563   __pyx_tp_dealloc_memoryview, /*tp_dealloc*/
21564   #if PY_VERSION_HEX < 0x030800b4
21565   0, /*tp_print*/
21566   #endif
21567   #if PY_VERSION_HEX >= 0x030800b4
21568   0, /*tp_vectorcall_offset*/
21569   #endif
21570   0, /*tp_getattr*/
21571   0, /*tp_setattr*/
21572   #if PY_MAJOR_VERSION < 3
21573   0, /*tp_compare*/
21574   #endif
21575   #if PY_MAJOR_VERSION >= 3
21576   0, /*tp_as_async*/
21577   #endif
21578   __pyx_memoryview___repr__, /*tp_repr*/
21579   0, /*tp_as_number*/
21580   &__pyx_tp_as_sequence_memoryview, /*tp_as_sequence*/
21581   &__pyx_tp_as_mapping_memoryview, /*tp_as_mapping*/
21582   0, /*tp_hash*/
21583   0, /*tp_call*/
21584   __pyx_memoryview___str__, /*tp_str*/
21585   0, /*tp_getattro*/
21586   0, /*tp_setattro*/
21587   &__pyx_tp_as_buffer_memoryview, /*tp_as_buffer*/
21588   Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
21589   0, /*tp_doc*/
21590   __pyx_tp_traverse_memoryview, /*tp_traverse*/
21591   __pyx_tp_clear_memoryview, /*tp_clear*/
21592   0, /*tp_richcompare*/
21593   0, /*tp_weaklistoffset*/
21594   0, /*tp_iter*/
21595   0, /*tp_iternext*/
21596   __pyx_methods_memoryview, /*tp_methods*/
21597   0, /*tp_members*/
21598   __pyx_getsets_memoryview, /*tp_getset*/
21599   0, /*tp_base*/
21600   0, /*tp_dict*/
21601   0, /*tp_descr_get*/
21602   0, /*tp_descr_set*/
21603   0, /*tp_dictoffset*/
21604   0, /*tp_init*/
21605   0, /*tp_alloc*/
21606   __pyx_tp_new_memoryview, /*tp_new*/
21607   0, /*tp_free*/
21608   0, /*tp_is_gc*/
21609   0, /*tp_bases*/
21610   0, /*tp_mro*/
21611   0, /*tp_cache*/
21612   0, /*tp_subclasses*/
21613   0, /*tp_weaklist*/
21614   0, /*tp_del*/
21615   0, /*tp_version_tag*/
21616   #if PY_VERSION_HEX >= 0x030400a1
21617   0, /*tp_finalize*/
21618   #endif
21619   #if PY_VERSION_HEX >= 0x030800b1
21620   0, /*tp_vectorcall*/
21621   #endif
21622   #if PY_VERSION_HEX >= 0x030800b4 && PY_VERSION_HEX < 0x03090000
21623   0, /*tp_print*/
21624   #endif
21625 };
21626 static struct __pyx_vtabstruct__memoryviewslice __pyx_vtable__memoryviewslice;
21627 
__pyx_tp_new__memoryviewslice(PyTypeObject * t,PyObject * a,PyObject * k)21628 static PyObject *__pyx_tp_new__memoryviewslice(PyTypeObject *t, PyObject *a, PyObject *k) {
21629   struct __pyx_memoryviewslice_obj *p;
21630   PyObject *o = __pyx_tp_new_memoryview(t, a, k);
21631   if (unlikely(!o)) return 0;
21632   p = ((struct __pyx_memoryviewslice_obj *)o);
21633   p->__pyx_base.__pyx_vtab = (struct __pyx_vtabstruct_memoryview*)__pyx_vtabptr__memoryviewslice;
21634   p->from_object = Py_None; Py_INCREF(Py_None);
21635   p->from_slice.memview = NULL;
21636   return o;
21637 }
21638 
__pyx_tp_dealloc__memoryviewslice(PyObject * o)21639 static void __pyx_tp_dealloc__memoryviewslice(PyObject *o) {
21640   struct __pyx_memoryviewslice_obj *p = (struct __pyx_memoryviewslice_obj *)o;
21641   #if CYTHON_USE_TP_FINALIZE
21642   if (unlikely(PyType_HasFeature(Py_TYPE(o), Py_TPFLAGS_HAVE_FINALIZE) && Py_TYPE(o)->tp_finalize) && !_PyGC_FINALIZED(o)) {
21643     if (PyObject_CallFinalizerFromDealloc(o)) return;
21644   }
21645   #endif
21646   PyObject_GC_UnTrack(o);
21647   {
21648     PyObject *etype, *eval, *etb;
21649     PyErr_Fetch(&etype, &eval, &etb);
21650     __Pyx_SET_REFCNT(o, Py_REFCNT(o) + 1);
21651     __pyx_memoryviewslice___dealloc__(o);
21652     __Pyx_SET_REFCNT(o, Py_REFCNT(o) - 1);
21653     PyErr_Restore(etype, eval, etb);
21654   }
21655   Py_CLEAR(p->from_object);
21656   PyObject_GC_Track(o);
21657   __pyx_tp_dealloc_memoryview(o);
21658 }
21659 
__pyx_tp_traverse__memoryviewslice(PyObject * o,visitproc v,void * a)21660 static int __pyx_tp_traverse__memoryviewslice(PyObject *o, visitproc v, void *a) {
21661   int e;
21662   struct __pyx_memoryviewslice_obj *p = (struct __pyx_memoryviewslice_obj *)o;
21663   e = __pyx_tp_traverse_memoryview(o, v, a); if (e) return e;
21664   if (p->from_object) {
21665     e = (*v)(p->from_object, a); if (e) return e;
21666   }
21667   return 0;
21668 }
21669 
__pyx_tp_clear__memoryviewslice(PyObject * o)21670 static int __pyx_tp_clear__memoryviewslice(PyObject *o) {
21671   PyObject* tmp;
21672   struct __pyx_memoryviewslice_obj *p = (struct __pyx_memoryviewslice_obj *)o;
21673   __pyx_tp_clear_memoryview(o);
21674   tmp = ((PyObject*)p->from_object);
21675   p->from_object = Py_None; Py_INCREF(Py_None);
21676   Py_XDECREF(tmp);
21677   __PYX_XDEC_MEMVIEW(&p->from_slice, 1);
21678   return 0;
21679 }
21680 
__pyx_getprop___pyx_memoryviewslice_base(PyObject * o,CYTHON_UNUSED void * x)21681 static PyObject *__pyx_getprop___pyx_memoryviewslice_base(PyObject *o, CYTHON_UNUSED void *x) {
21682   return __pyx_pw_15View_dot_MemoryView_16_memoryviewslice_4base_1__get__(o);
21683 }
21684 
21685 static PyMethodDef __pyx_methods__memoryviewslice[] = {
21686   {"__reduce_cython__", (PyCFunction)__pyx_pw___pyx_memoryviewslice_1__reduce_cython__, METH_NOARGS, 0},
21687   {"__setstate_cython__", (PyCFunction)__pyx_pw___pyx_memoryviewslice_3__setstate_cython__, METH_O, 0},
21688   {0, 0, 0, 0}
21689 };
21690 
21691 static struct PyGetSetDef __pyx_getsets__memoryviewslice[] = {
21692   {(char *)"base", __pyx_getprop___pyx_memoryviewslice_base, 0, (char *)0, 0},
21693   {0, 0, 0, 0, 0}
21694 };
21695 
21696 static PyTypeObject __pyx_type___pyx_memoryviewslice = {
21697   PyVarObject_HEAD_INIT(0, 0)
21698   "qutip.cy.ptrace._memoryviewslice", /*tp_name*/
21699   sizeof(struct __pyx_memoryviewslice_obj), /*tp_basicsize*/
21700   0, /*tp_itemsize*/
21701   __pyx_tp_dealloc__memoryviewslice, /*tp_dealloc*/
21702   #if PY_VERSION_HEX < 0x030800b4
21703   0, /*tp_print*/
21704   #endif
21705   #if PY_VERSION_HEX >= 0x030800b4
21706   0, /*tp_vectorcall_offset*/
21707   #endif
21708   0, /*tp_getattr*/
21709   0, /*tp_setattr*/
21710   #if PY_MAJOR_VERSION < 3
21711   0, /*tp_compare*/
21712   #endif
21713   #if PY_MAJOR_VERSION >= 3
21714   0, /*tp_as_async*/
21715   #endif
21716   #if CYTHON_COMPILING_IN_PYPY
21717   __pyx_memoryview___repr__, /*tp_repr*/
21718   #else
21719   0, /*tp_repr*/
21720   #endif
21721   0, /*tp_as_number*/
21722   0, /*tp_as_sequence*/
21723   0, /*tp_as_mapping*/
21724   0, /*tp_hash*/
21725   0, /*tp_call*/
21726   #if CYTHON_COMPILING_IN_PYPY
21727   __pyx_memoryview___str__, /*tp_str*/
21728   #else
21729   0, /*tp_str*/
21730   #endif
21731   0, /*tp_getattro*/
21732   0, /*tp_setattro*/
21733   0, /*tp_as_buffer*/
21734   Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
21735   "Internal class for passing memoryview slices to Python", /*tp_doc*/
21736   __pyx_tp_traverse__memoryviewslice, /*tp_traverse*/
21737   __pyx_tp_clear__memoryviewslice, /*tp_clear*/
21738   0, /*tp_richcompare*/
21739   0, /*tp_weaklistoffset*/
21740   0, /*tp_iter*/
21741   0, /*tp_iternext*/
21742   __pyx_methods__memoryviewslice, /*tp_methods*/
21743   0, /*tp_members*/
21744   __pyx_getsets__memoryviewslice, /*tp_getset*/
21745   0, /*tp_base*/
21746   0, /*tp_dict*/
21747   0, /*tp_descr_get*/
21748   0, /*tp_descr_set*/
21749   0, /*tp_dictoffset*/
21750   0, /*tp_init*/
21751   0, /*tp_alloc*/
21752   __pyx_tp_new__memoryviewslice, /*tp_new*/
21753   0, /*tp_free*/
21754   0, /*tp_is_gc*/
21755   0, /*tp_bases*/
21756   0, /*tp_mro*/
21757   0, /*tp_cache*/
21758   0, /*tp_subclasses*/
21759   0, /*tp_weaklist*/
21760   0, /*tp_del*/
21761   0, /*tp_version_tag*/
21762   #if PY_VERSION_HEX >= 0x030400a1
21763   0, /*tp_finalize*/
21764   #endif
21765   #if PY_VERSION_HEX >= 0x030800b1
21766   0, /*tp_vectorcall*/
21767   #endif
21768   #if PY_VERSION_HEX >= 0x030800b4 && PY_VERSION_HEX < 0x03090000
21769   0, /*tp_print*/
21770   #endif
21771 };
21772 
21773 static PyMethodDef __pyx_methods[] = {
21774   {"_list2ind", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_5qutip_2cy_6ptrace_3_list2ind, METH_VARARGS|METH_KEYWORDS, __pyx_doc_5qutip_2cy_6ptrace_2_list2ind},
21775   {"_select", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_5qutip_2cy_6ptrace_5_select, METH_VARARGS|METH_KEYWORDS, __pyx_doc_5qutip_2cy_6ptrace_4_select},
21776   {0, 0, 0, 0}
21777 };
21778 
21779 #if PY_MAJOR_VERSION >= 3
21780 #if CYTHON_PEP489_MULTI_PHASE_INIT
21781 static PyObject* __pyx_pymod_create(PyObject *spec, PyModuleDef *def); /*proto*/
21782 static int __pyx_pymod_exec_ptrace(PyObject* module); /*proto*/
21783 static PyModuleDef_Slot __pyx_moduledef_slots[] = {
21784   {Py_mod_create, (void*)__pyx_pymod_create},
21785   {Py_mod_exec, (void*)__pyx_pymod_exec_ptrace},
21786   {0, NULL}
21787 };
21788 #endif
21789 
21790 static struct PyModuleDef __pyx_moduledef = {
21791     PyModuleDef_HEAD_INIT,
21792     "ptrace",
21793     0, /* m_doc */
21794   #if CYTHON_PEP489_MULTI_PHASE_INIT
21795     0, /* m_size */
21796   #else
21797     -1, /* m_size */
21798   #endif
21799     __pyx_methods /* m_methods */,
21800   #if CYTHON_PEP489_MULTI_PHASE_INIT
21801     __pyx_moduledef_slots, /* m_slots */
21802   #else
21803     NULL, /* m_reload */
21804   #endif
21805     NULL, /* m_traverse */
21806     NULL, /* m_clear */
21807     NULL /* m_free */
21808 };
21809 #endif
21810 #ifndef CYTHON_SMALL_CODE
21811 #if defined(__clang__)
21812     #define CYTHON_SMALL_CODE
21813 #elif defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3))
21814     #define CYTHON_SMALL_CODE __attribute__((cold))
21815 #else
21816     #define CYTHON_SMALL_CODE
21817 #endif
21818 #endif
21819 
21820 static __Pyx_StringTabEntry __pyx_string_tab[] = {
21821   {&__pyx_n_s_ASCII, __pyx_k_ASCII, sizeof(__pyx_k_ASCII), 0, 0, 1, 1},
21822   {&__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},
21823   {&__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},
21824   {&__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},
21825   {&__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},
21826   {&__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},
21827   {&__pyx_kp_u_Duplicate_selection_index_in_ptr, __pyx_k_Duplicate_selection_index_in_ptr, sizeof(__pyx_k_Duplicate_selection_index_in_ptr), 0, 1, 0, 0},
21828   {&__pyx_n_s_Ellipsis, __pyx_k_Ellipsis, sizeof(__pyx_k_Ellipsis), 0, 0, 1, 1},
21829   {&__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},
21830   {&__pyx_n_s_ImportError, __pyx_k_ImportError, sizeof(__pyx_k_ImportError), 0, 0, 1, 1},
21831   {&__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},
21832   {&__pyx_n_s_IndexError, __pyx_k_IndexError, sizeof(__pyx_k_IndexError), 0, 0, 1, 1},
21833   {&__pyx_kp_s_Indirect_dimensions_not_supporte, __pyx_k_Indirect_dimensions_not_supporte, sizeof(__pyx_k_Indirect_dimensions_not_supporte), 0, 0, 1, 0},
21834   {&__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},
21835   {&__pyx_kp_u_Invalid_selection_index_in_ptrac, __pyx_k_Invalid_selection_index_in_ptrac, sizeof(__pyx_k_Invalid_selection_index_in_ptrac), 0, 1, 0, 0},
21836   {&__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},
21837   {&__pyx_n_s_M, __pyx_k_M, sizeof(__pyx_k_M), 0, 0, 1, 1},
21838   {&__pyx_n_s_MemoryError, __pyx_k_MemoryError, sizeof(__pyx_k_MemoryError), 0, 0, 1, 1},
21839   {&__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},
21840   {&__pyx_kp_s_MemoryView_of_r_object, __pyx_k_MemoryView_of_r_object, sizeof(__pyx_k_MemoryView_of_r_object), 0, 0, 1, 0},
21841   {&__pyx_n_s_N, __pyx_k_N, sizeof(__pyx_k_N), 0, 0, 1, 1},
21842   {&__pyx_n_b_O, __pyx_k_O, sizeof(__pyx_k_O), 0, 0, 0, 1},
21843   {&__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},
21844   {&__pyx_n_s_PickleError, __pyx_k_PickleError, sizeof(__pyx_k_PickleError), 0, 0, 1, 1},
21845   {&__pyx_n_s_R, __pyx_k_R, sizeof(__pyx_k_R), 0, 0, 1, 1},
21846   {&__pyx_n_s_TypeError, __pyx_k_TypeError, sizeof(__pyx_k_TypeError), 0, 0, 1, 1},
21847   {&__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},
21848   {&__pyx_n_s_ValueError, __pyx_k_ValueError, sizeof(__pyx_k_ValueError), 0, 0, 1, 1},
21849   {&__pyx_n_s_View_MemoryView, __pyx_k_View_MemoryView, sizeof(__pyx_k_View_MemoryView), 0, 0, 1, 1},
21850   {&__pyx_n_s__24, __pyx_k__24, sizeof(__pyx_k__24), 0, 0, 1, 1},
21851   {&__pyx_n_s_allocate_buffer, __pyx_k_allocate_buffer, sizeof(__pyx_k_allocate_buffer), 0, 0, 1, 1},
21852   {&__pyx_n_s_arange, __pyx_k_arange, sizeof(__pyx_k_arange), 0, 0, 1, 1},
21853   {&__pyx_n_s_array, __pyx_k_array, sizeof(__pyx_k_array), 0, 0, 1, 1},
21854   {&__pyx_n_s_asarray, __pyx_k_asarray, sizeof(__pyx_k_asarray), 0, 0, 1, 1},
21855   {&__pyx_n_s_base, __pyx_k_base, sizeof(__pyx_k_base), 0, 0, 1, 1},
21856   {&__pyx_n_s_c, __pyx_k_c, sizeof(__pyx_k_c), 0, 0, 1, 1},
21857   {&__pyx_n_u_c, __pyx_k_c, sizeof(__pyx_k_c), 0, 1, 0, 1},
21858   {&__pyx_n_s_class, __pyx_k_class, sizeof(__pyx_k_class), 0, 0, 1, 1},
21859   {&__pyx_n_s_cline_in_traceback, __pyx_k_cline_in_traceback, sizeof(__pyx_k_cline_in_traceback), 0, 0, 1, 1},
21860   {&__pyx_kp_s_contiguous_and_direct, __pyx_k_contiguous_and_direct, sizeof(__pyx_k_contiguous_and_direct), 0, 0, 1, 0},
21861   {&__pyx_kp_s_contiguous_and_indirect, __pyx_k_contiguous_and_indirect, sizeof(__pyx_k_contiguous_and_indirect), 0, 0, 1, 0},
21862   {&__pyx_n_s_coo_matrix, __pyx_k_coo_matrix, sizeof(__pyx_k_coo_matrix), 0, 0, 1, 1},
21863   {&__pyx_n_s_copy, __pyx_k_copy, sizeof(__pyx_k_copy), 0, 0, 1, 1},
21864   {&__pyx_n_s_csr2fast, __pyx_k_csr2fast, sizeof(__pyx_k_csr2fast), 0, 0, 1, 1},
21865   {&__pyx_n_s_dag, __pyx_k_dag, sizeof(__pyx_k_dag), 0, 0, 1, 1},
21866   {&__pyx_n_s_data, __pyx_k_data, sizeof(__pyx_k_data), 0, 0, 1, 1},
21867   {&__pyx_n_s_delete, __pyx_k_delete, sizeof(__pyx_k_delete), 0, 0, 1, 1},
21868   {&__pyx_n_s_dict, __pyx_k_dict, sizeof(__pyx_k_dict), 0, 0, 1, 1},
21869   {&__pyx_n_s_dims, __pyx_k_dims, sizeof(__pyx_k_dims), 0, 0, 1, 1},
21870   {&__pyx_n_s_dims_kept0, __pyx_k_dims_kept0, sizeof(__pyx_k_dims_kept0), 0, 0, 1, 1},
21871   {&__pyx_n_s_dot, __pyx_k_dot, sizeof(__pyx_k_dot), 0, 0, 1, 1},
21872   {&__pyx_n_s_drho, __pyx_k_drho, sizeof(__pyx_k_drho), 0, 0, 1, 1},
21873   {&__pyx_n_s_dtype, __pyx_k_dtype, sizeof(__pyx_k_dtype), 0, 0, 1, 1},
21874   {&__pyx_n_s_dtype_is_object, __pyx_k_dtype_is_object, sizeof(__pyx_k_dtype_is_object), 0, 0, 1, 1},
21875   {&__pyx_n_s_empty, __pyx_k_empty, sizeof(__pyx_k_empty), 0, 0, 1, 1},
21876   {&__pyx_n_s_encode, __pyx_k_encode, sizeof(__pyx_k_encode), 0, 0, 1, 1},
21877   {&__pyx_n_s_enumerate, __pyx_k_enumerate, sizeof(__pyx_k_enumerate), 0, 0, 1, 1},
21878   {&__pyx_n_s_error, __pyx_k_error, sizeof(__pyx_k_error), 0, 0, 1, 1},
21879   {&__pyx_n_s_factor_keep, __pyx_k_factor_keep, sizeof(__pyx_k_factor_keep), 0, 0, 1, 1},
21880   {&__pyx_n_s_factor_tensor, __pyx_k_factor_tensor, sizeof(__pyx_k_factor_tensor), 0, 0, 1, 1},
21881   {&__pyx_n_s_factor_trace, __pyx_k_factor_trace, sizeof(__pyx_k_factor_trace), 0, 0, 1, 1},
21882   {&__pyx_n_s_fast_csr_matrix, __pyx_k_fast_csr_matrix, sizeof(__pyx_k_fast_csr_matrix), 0, 0, 1, 1},
21883   {&__pyx_n_s_flags, __pyx_k_flags, sizeof(__pyx_k_flags), 0, 0, 1, 1},
21884   {&__pyx_n_s_format, __pyx_k_format, sizeof(__pyx_k_format), 0, 0, 1, 1},
21885   {&__pyx_n_s_fortran, __pyx_k_fortran, sizeof(__pyx_k_fortran), 0, 0, 1, 1},
21886   {&__pyx_n_u_fortran, __pyx_k_fortran, sizeof(__pyx_k_fortran), 0, 1, 0, 1},
21887   {&__pyx_n_s_getstate, __pyx_k_getstate, sizeof(__pyx_k_getstate), 0, 0, 1, 1},
21888   {&__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},
21889   {&__pyx_n_s_id, __pyx_k_id, sizeof(__pyx_k_id), 0, 0, 1, 1},
21890   {&__pyx_n_s_ii, __pyx_k_ii, sizeof(__pyx_k_ii), 0, 0, 1, 1},
21891   {&__pyx_n_s_ilist, __pyx_k_ilist, sizeof(__pyx_k_ilist), 0, 0, 1, 1},
21892   {&__pyx_n_s_ilistrest, __pyx_k_ilistrest, sizeof(__pyx_k_ilistrest), 0, 0, 1, 1},
21893   {&__pyx_n_s_ilistsel, __pyx_k_ilistsel, sizeof(__pyx_k_ilistsel), 0, 0, 1, 1},
21894   {&__pyx_n_s_import, __pyx_k_import, sizeof(__pyx_k_import), 0, 0, 1, 1},
21895   {&__pyx_n_s_ind, __pyx_k_ind, sizeof(__pyx_k_ind), 0, 0, 1, 1},
21896   {&__pyx_n_s_indices, __pyx_k_indices, sizeof(__pyx_k_indices), 0, 0, 1, 1},
21897   {&__pyx_n_s_indptr, __pyx_k_indptr, sizeof(__pyx_k_indptr), 0, 0, 1, 1},
21898   {&__pyx_n_s_indrest, __pyx_k_indrest, sizeof(__pyx_k_indrest), 0, 0, 1, 1},
21899   {&__pyx_n_s_indsel, __pyx_k_indsel, sizeof(__pyx_k_indsel), 0, 0, 1, 1},
21900   {&__pyx_n_s_int32, __pyx_k_int32, sizeof(__pyx_k_int32), 0, 0, 1, 1},
21901   {&__pyx_n_s_itemsize, __pyx_k_itemsize, sizeof(__pyx_k_itemsize), 0, 0, 1, 1},
21902   {&__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},
21903   {&__pyx_n_s_main, __pyx_k_main, sizeof(__pyx_k_main), 0, 0, 1, 1},
21904   {&__pyx_n_s_memview, __pyx_k_memview, sizeof(__pyx_k_memview), 0, 0, 1, 1},
21905   {&__pyx_n_s_mm, __pyx_k_mm, sizeof(__pyx_k_mm), 0, 0, 1, 1},
21906   {&__pyx_n_s_mode, __pyx_k_mode, sizeof(__pyx_k_mode), 0, 0, 1, 1},
21907   {&__pyx_n_s_name, __pyx_k_name, sizeof(__pyx_k_name), 0, 0, 1, 1},
21908   {&__pyx_n_s_name_2, __pyx_k_name_2, sizeof(__pyx_k_name_2), 0, 0, 1, 1},
21909   {&__pyx_n_s_ndim, __pyx_k_ndim, sizeof(__pyx_k_ndim), 0, 0, 1, 1},
21910   {&__pyx_n_s_new, __pyx_k_new, sizeof(__pyx_k_new), 0, 0, 1, 1},
21911   {&__pyx_n_s_nnz, __pyx_k_nnz, sizeof(__pyx_k_nnz), 0, 0, 1, 1},
21912   {&__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},
21913   {&__pyx_n_s_np, __pyx_k_np, sizeof(__pyx_k_np), 0, 0, 1, 1},
21914   {&__pyx_n_s_num_dims, __pyx_k_num_dims, sizeof(__pyx_k_num_dims), 0, 0, 1, 1},
21915   {&__pyx_n_s_numpy, __pyx_k_numpy, sizeof(__pyx_k_numpy), 0, 0, 1, 1},
21916   {&__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},
21917   {&__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},
21918   {&__pyx_n_s_obj, __pyx_k_obj, sizeof(__pyx_k_obj), 0, 0, 1, 1},
21919   {&__pyx_n_s_ones, __pyx_k_ones, sizeof(__pyx_k_ones), 0, 0, 1, 1},
21920   {&__pyx_n_s_ones_like, __pyx_k_ones_like, sizeof(__pyx_k_ones_like), 0, 0, 1, 1},
21921   {&__pyx_n_s_oper, __pyx_k_oper, sizeof(__pyx_k_oper), 0, 0, 1, 1},
21922   {&__pyx_n_s_pack, __pyx_k_pack, sizeof(__pyx_k_pack), 0, 0, 1, 1},
21923   {&__pyx_n_s_perm, __pyx_k_perm, sizeof(__pyx_k_perm), 0, 0, 1, 1},
21924   {&__pyx_n_s_pickle, __pyx_k_pickle, sizeof(__pyx_k_pickle), 0, 0, 1, 1},
21925   {&__pyx_n_s_prod, __pyx_k_prod, sizeof(__pyx_k_prod), 0, 0, 1, 1},
21926   {&__pyx_n_s_ptr, __pyx_k_ptr, sizeof(__pyx_k_ptr), 0, 0, 1, 1},
21927   {&__pyx_n_s_ptrace, __pyx_k_ptrace, sizeof(__pyx_k_ptrace), 0, 0, 1, 1},
21928   {&__pyx_n_s_ptrace_legacy, __pyx_k_ptrace_legacy, sizeof(__pyx_k_ptrace_legacy), 0, 0, 1, 1},
21929   {&__pyx_n_s_pyx_PickleError, __pyx_k_pyx_PickleError, sizeof(__pyx_k_pyx_PickleError), 0, 0, 1, 1},
21930   {&__pyx_n_s_pyx_checksum, __pyx_k_pyx_checksum, sizeof(__pyx_k_pyx_checksum), 0, 0, 1, 1},
21931   {&__pyx_n_s_pyx_getbuffer, __pyx_k_pyx_getbuffer, sizeof(__pyx_k_pyx_getbuffer), 0, 0, 1, 1},
21932   {&__pyx_n_s_pyx_result, __pyx_k_pyx_result, sizeof(__pyx_k_pyx_result), 0, 0, 1, 1},
21933   {&__pyx_n_s_pyx_state, __pyx_k_pyx_state, sizeof(__pyx_k_pyx_state), 0, 0, 1, 1},
21934   {&__pyx_n_s_pyx_type, __pyx_k_pyx_type, sizeof(__pyx_k_pyx_type), 0, 0, 1, 1},
21935   {&__pyx_n_s_pyx_unpickle_Enum, __pyx_k_pyx_unpickle_Enum, sizeof(__pyx_k_pyx_unpickle_Enum), 0, 0, 1, 1},
21936   {&__pyx_n_s_pyx_vtable, __pyx_k_pyx_vtable, sizeof(__pyx_k_pyx_vtable), 0, 0, 1, 1},
21937   {&__pyx_n_s_qutip_cy_ptrace, __pyx_k_qutip_cy_ptrace, sizeof(__pyx_k_qutip_cy_ptrace), 0, 0, 1, 1},
21938   {&__pyx_kp_s_qutip_cy_ptrace_pyx, __pyx_k_qutip_cy_ptrace_pyx, sizeof(__pyx_k_qutip_cy_ptrace_pyx), 0, 0, 1, 0},
21939   {&__pyx_n_s_qutip_cy_spconvert, __pyx_k_qutip_cy_spconvert, sizeof(__pyx_k_qutip_cy_spconvert), 0, 0, 1, 1},
21940   {&__pyx_n_s_qutip_cy_spmath, __pyx_k_qutip_cy_spmath, sizeof(__pyx_k_qutip_cy_spmath), 0, 0, 1, 1},
21941   {&__pyx_n_s_qutip_fastsparse, __pyx_k_qutip_fastsparse, sizeof(__pyx_k_qutip_fastsparse), 0, 0, 1, 1},
21942   {&__pyx_n_s_range, __pyx_k_range, sizeof(__pyx_k_range), 0, 0, 1, 1},
21943   {&__pyx_n_s_ravel, __pyx_k_ravel, sizeof(__pyx_k_ravel), 0, 0, 1, 1},
21944   {&__pyx_n_s_reduce, __pyx_k_reduce, sizeof(__pyx_k_reduce), 0, 0, 1, 1},
21945   {&__pyx_n_s_reduce_cython, __pyx_k_reduce_cython, sizeof(__pyx_k_reduce_cython), 0, 0, 1, 1},
21946   {&__pyx_n_s_reduce_ex, __pyx_k_reduce_ex, sizeof(__pyx_k_reduce_ex), 0, 0, 1, 1},
21947   {&__pyx_n_s_rest, __pyx_k_rest, sizeof(__pyx_k_rest), 0, 0, 1, 1},
21948   {&__pyx_n_s_rhdata, __pyx_k_rhdata, sizeof(__pyx_k_rhdata), 0, 0, 1, 1},
21949   {&__pyx_n_s_rho, __pyx_k_rho, sizeof(__pyx_k_rho), 0, 0, 1, 1},
21950   {&__pyx_n_s_rho1_data, __pyx_k_rho1_data, sizeof(__pyx_k_rho1_data), 0, 0, 1, 1},
21951   {&__pyx_n_s_rho1_dims, __pyx_k_rho1_dims, sizeof(__pyx_k_rho1_dims), 0, 0, 1, 1},
21952   {&__pyx_n_s_rho1_shape, __pyx_k_rho1_shape, sizeof(__pyx_k_rho1_shape), 0, 0, 1, 1},
21953   {&__pyx_n_s_scipy_sparse, __pyx_k_scipy_sparse, sizeof(__pyx_k_scipy_sparse), 0, 0, 1, 1},
21954   {&__pyx_n_s_sel, __pyx_k_sel, sizeof(__pyx_k_sel), 0, 0, 1, 1},
21955   {&__pyx_n_s_sel_2, __pyx_k_sel_2, sizeof(__pyx_k_sel_2), 0, 0, 1, 1},
21956   {&__pyx_n_s_setstate, __pyx_k_setstate, sizeof(__pyx_k_setstate), 0, 0, 1, 1},
21957   {&__pyx_n_s_setstate_cython, __pyx_k_setstate_cython, sizeof(__pyx_k_setstate_cython), 0, 0, 1, 1},
21958   {&__pyx_n_s_shape, __pyx_k_shape, sizeof(__pyx_k_shape), 0, 0, 1, 1},
21959   {&__pyx_n_s_size, __pyx_k_size, sizeof(__pyx_k_size), 0, 0, 1, 1},
21960   {&__pyx_n_s_sort, __pyx_k_sort, sizeof(__pyx_k_sort), 0, 0, 1, 1},
21961   {&__pyx_n_s_sorted, __pyx_k_sorted, sizeof(__pyx_k_sorted), 0, 0, 1, 1},
21962   {&__pyx_n_s_sp, __pyx_k_sp, sizeof(__pyx_k_sp), 0, 0, 1, 1},
21963   {&__pyx_n_s_start, __pyx_k_start, sizeof(__pyx_k_start), 0, 0, 1, 1},
21964   {&__pyx_n_s_step, __pyx_k_step, sizeof(__pyx_k_step), 0, 0, 1, 1},
21965   {&__pyx_n_s_stop, __pyx_k_stop, sizeof(__pyx_k_stop), 0, 0, 1, 1},
21966   {&__pyx_kp_s_strided_and_direct, __pyx_k_strided_and_direct, sizeof(__pyx_k_strided_and_direct), 0, 0, 1, 0},
21967   {&__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},
21968   {&__pyx_kp_s_strided_and_indirect, __pyx_k_strided_and_indirect, sizeof(__pyx_k_strided_and_indirect), 0, 0, 1, 0},
21969   {&__pyx_kp_s_stringsource, __pyx_k_stringsource, sizeof(__pyx_k_stringsource), 0, 0, 1, 0},
21970   {&__pyx_n_s_struct, __pyx_k_struct, sizeof(__pyx_k_struct), 0, 0, 1, 1},
21971   {&__pyx_n_s_take, __pyx_k_take, sizeof(__pyx_k_take), 0, 0, 1, 1},
21972   {&__pyx_n_s_tensor_table, __pyx_k_tensor_table, sizeof(__pyx_k_tensor_table), 0, 0, 1, 1},
21973   {&__pyx_n_s_test, __pyx_k_test, sizeof(__pyx_k_test), 0, 0, 1, 1},
21974   {&__pyx_n_s_tmp, __pyx_k_tmp, sizeof(__pyx_k_tmp), 0, 0, 1, 1},
21975   {&__pyx_n_s_tocsr, __pyx_k_tocsr, sizeof(__pyx_k_tocsr), 0, 0, 1, 1},
21976   {&__pyx_n_s_tolist, __pyx_k_tolist, sizeof(__pyx_k_tolist), 0, 0, 1, 1},
21977   {&__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},
21978   {&__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},
21979   {&__pyx_n_s_unpack, __pyx_k_unpack, sizeof(__pyx_k_unpack), 0, 0, 1, 1},
21980   {&__pyx_n_s_update, __pyx_k_update, sizeof(__pyx_k_update), 0, 0, 1, 1},
21981   {&__pyx_n_s_zcsr_mult, __pyx_k_zcsr_mult, sizeof(__pyx_k_zcsr_mult), 0, 0, 1, 1},
21982   {&__pyx_n_s_zcsr_reshape, __pyx_k_zcsr_reshape, sizeof(__pyx_k_zcsr_reshape), 0, 0, 1, 1},
21983   {&__pyx_n_s_zeros, __pyx_k_zeros, sizeof(__pyx_k_zeros), 0, 0, 1, 1},
21984   {0, 0, 0, 0, 0, 0, 0}
21985 };
__Pyx_InitCachedBuiltins(void)21986 static CYTHON_SMALL_CODE int __Pyx_InitCachedBuiltins(void) {
21987   __pyx_builtin_range = __Pyx_GetBuiltinName(__pyx_n_s_range); if (!__pyx_builtin_range) __PYX_ERR(0, 64, __pyx_L1_error)
21988   __pyx_builtin_TypeError = __Pyx_GetBuiltinName(__pyx_n_s_TypeError); if (!__pyx_builtin_TypeError) __PYX_ERR(0, 66, __pyx_L1_error)
21989   __pyx_builtin_IndexError = __Pyx_GetBuiltinName(__pyx_n_s_IndexError); if (!__pyx_builtin_IndexError) __PYX_ERR(0, 187, __pyx_L1_error)
21990   __pyx_builtin_ValueError = __Pyx_GetBuiltinName(__pyx_n_s_ValueError); if (!__pyx_builtin_ValueError) __PYX_ERR(0, 189, __pyx_L1_error)
21991   __pyx_builtin_ImportError = __Pyx_GetBuiltinName(__pyx_n_s_ImportError); if (!__pyx_builtin_ImportError) __PYX_ERR(1, 884, __pyx_L1_error)
21992   __pyx_builtin_MemoryError = __Pyx_GetBuiltinName(__pyx_n_s_MemoryError); if (!__pyx_builtin_MemoryError) __PYX_ERR(2, 148, __pyx_L1_error)
21993   __pyx_builtin_enumerate = __Pyx_GetBuiltinName(__pyx_n_s_enumerate); if (!__pyx_builtin_enumerate) __PYX_ERR(2, 151, __pyx_L1_error)
21994   __pyx_builtin_Ellipsis = __Pyx_GetBuiltinName(__pyx_n_s_Ellipsis); if (!__pyx_builtin_Ellipsis) __PYX_ERR(2, 404, __pyx_L1_error)
21995   __pyx_builtin_id = __Pyx_GetBuiltinName(__pyx_n_s_id); if (!__pyx_builtin_id) __PYX_ERR(2, 613, __pyx_L1_error)
21996   return 0;
21997   __pyx_L1_error:;
21998   return -1;
21999 }
22000 
__Pyx_InitCachedConstants(void)22001 static CYTHON_SMALL_CODE int __Pyx_InitCachedConstants(void) {
22002   __Pyx_RefNannyDeclarations
22003   __Pyx_RefNannySetupContext("__Pyx_InitCachedConstants", 0);
22004 
22005   /* "qutip/cy/ptrace.pyx":66
22006  *     for mm in range(sel.shape[0]):
22007  *         if (sel[mm] < 0) or (sel[mm] >= drho.shape[0]):
22008  *             raise TypeError("Invalid selection index in ptrace.")             # <<<<<<<<<<<<<<
22009  *
22010  *     cdef int[::1] rest = np.delete(np.arange(drho.shape[0],dtype=np.int32),sel)
22011  */
22012   __pyx_tuple_ = PyTuple_Pack(1, __pyx_kp_u_Invalid_selection_index_in_ptrac); if (unlikely(!__pyx_tuple_)) __PYX_ERR(0, 66, __pyx_L1_error)
22013   __Pyx_GOTREF(__pyx_tuple_);
22014   __Pyx_GIVEREF(__pyx_tuple_);
22015 
22016   /* "qutip/cy/ptrace.pyx":189
22017  *             raise IndexError("Invalid selection index in ptrace.")
22018  *         if ii > 0 and _sel[ii] == _sel[ii - 1]:
22019  *             raise ValueError("Duplicate selection index in ptrace.")             # <<<<<<<<<<<<<<
22020  *
22021  *     if len(_sel) == num_dims:
22022  */
22023   __pyx_tuple__2 = PyTuple_Pack(1, __pyx_kp_u_Duplicate_selection_index_in_ptr); if (unlikely(!__pyx_tuple__2)) __PYX_ERR(0, 189, __pyx_L1_error)
22024   __Pyx_GOTREF(__pyx_tuple__2);
22025   __Pyx_GIVEREF(__pyx_tuple__2);
22026 
22027   /* "qutip/cy/ptrace.pyx":226
22028  * cdef object _ptrace_core_sp(rho, int[:, ::1] tensor_table, int num_sel_dims):
22029  *     cdef int p = 0, nnz = rho.nnz, ii, jj, nrow = rho.shape[0]
22030  *     cdef int[::1] pos_c = np.empty(2, dtype=np.int32)             # <<<<<<<<<<<<<<
22031  *     cdef int[::1] pos_r = np.empty(2, dtype=np.int32)
22032  *     cdef cnp.ndarray[complex, ndim=1, mode='c'] new_data = np.zeros(nnz, dtype=complex)
22033  */
22034   __pyx_tuple__3 = PyTuple_Pack(1, __pyx_int_2); if (unlikely(!__pyx_tuple__3)) __PYX_ERR(0, 226, __pyx_L1_error)
22035   __Pyx_GOTREF(__pyx_tuple__3);
22036   __Pyx_GIVEREF(__pyx_tuple__3);
22037 
22038   /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":884
22039  *         __pyx_import_array()
22040  *     except Exception:
22041  *         raise ImportError("numpy.core.multiarray failed to import")             # <<<<<<<<<<<<<<
22042  *
22043  * cdef inline int import_umath() except -1:
22044  */
22045   __pyx_tuple__4 = PyTuple_Pack(1, __pyx_kp_u_numpy_core_multiarray_failed_to); if (unlikely(!__pyx_tuple__4)) __PYX_ERR(1, 884, __pyx_L1_error)
22046   __Pyx_GOTREF(__pyx_tuple__4);
22047   __Pyx_GIVEREF(__pyx_tuple__4);
22048 
22049   /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":890
22050  *         _import_umath()
22051  *     except Exception:
22052  *         raise ImportError("numpy.core.umath failed to import")             # <<<<<<<<<<<<<<
22053  *
22054  * cdef inline int import_ufunc() except -1:
22055  */
22056   __pyx_tuple__5 = PyTuple_Pack(1, __pyx_kp_u_numpy_core_umath_failed_to_impor); if (unlikely(!__pyx_tuple__5)) __PYX_ERR(1, 890, __pyx_L1_error)
22057   __Pyx_GOTREF(__pyx_tuple__5);
22058   __Pyx_GIVEREF(__pyx_tuple__5);
22059 
22060   /* "View.MemoryView":133
22061  *
22062  *         if not self.ndim:
22063  *             raise ValueError("Empty shape tuple for cython.array")             # <<<<<<<<<<<<<<
22064  *
22065  *         if itemsize <= 0:
22066  */
22067   __pyx_tuple__6 = PyTuple_Pack(1, __pyx_kp_s_Empty_shape_tuple_for_cython_arr); if (unlikely(!__pyx_tuple__6)) __PYX_ERR(2, 133, __pyx_L1_error)
22068   __Pyx_GOTREF(__pyx_tuple__6);
22069   __Pyx_GIVEREF(__pyx_tuple__6);
22070 
22071   /* "View.MemoryView":136
22072  *
22073  *         if itemsize <= 0:
22074  *             raise ValueError("itemsize <= 0 for cython.array")             # <<<<<<<<<<<<<<
22075  *
22076  *         if not isinstance(format, bytes):
22077  */
22078   __pyx_tuple__7 = PyTuple_Pack(1, __pyx_kp_s_itemsize_0_for_cython_array); if (unlikely(!__pyx_tuple__7)) __PYX_ERR(2, 136, __pyx_L1_error)
22079   __Pyx_GOTREF(__pyx_tuple__7);
22080   __Pyx_GIVEREF(__pyx_tuple__7);
22081 
22082   /* "View.MemoryView":148
22083  *
22084  *         if not self._shape:
22085  *             raise MemoryError("unable to allocate shape and strides.")             # <<<<<<<<<<<<<<
22086  *
22087  *
22088  */
22089   __pyx_tuple__8 = PyTuple_Pack(1, __pyx_kp_s_unable_to_allocate_shape_and_str); if (unlikely(!__pyx_tuple__8)) __PYX_ERR(2, 148, __pyx_L1_error)
22090   __Pyx_GOTREF(__pyx_tuple__8);
22091   __Pyx_GIVEREF(__pyx_tuple__8);
22092 
22093   /* "View.MemoryView":176
22094  *             self.data = <char *>malloc(self.len)
22095  *             if not self.data:
22096  *                 raise MemoryError("unable to allocate array data.")             # <<<<<<<<<<<<<<
22097  *
22098  *             if self.dtype_is_object:
22099  */
22100   __pyx_tuple__9 = PyTuple_Pack(1, __pyx_kp_s_unable_to_allocate_array_data); if (unlikely(!__pyx_tuple__9)) __PYX_ERR(2, 176, __pyx_L1_error)
22101   __Pyx_GOTREF(__pyx_tuple__9);
22102   __Pyx_GIVEREF(__pyx_tuple__9);
22103 
22104   /* "View.MemoryView":192
22105  *             bufmode = PyBUF_F_CONTIGUOUS | PyBUF_ANY_CONTIGUOUS
22106  *         if not (flags & bufmode):
22107  *             raise ValueError("Can only create a buffer that is contiguous in memory.")             # <<<<<<<<<<<<<<
22108  *         info.buf = self.data
22109  *         info.len = self.len
22110  */
22111   __pyx_tuple__10 = PyTuple_Pack(1, __pyx_kp_s_Can_only_create_a_buffer_that_is); if (unlikely(!__pyx_tuple__10)) __PYX_ERR(2, 192, __pyx_L1_error)
22112   __Pyx_GOTREF(__pyx_tuple__10);
22113   __Pyx_GIVEREF(__pyx_tuple__10);
22114 
22115   /* "(tree fragment)":2
22116  * def __reduce_cython__(self):
22117  *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")             # <<<<<<<<<<<<<<
22118  * def __setstate_cython__(self, __pyx_state):
22119  *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
22120  */
22121   __pyx_tuple__11 = PyTuple_Pack(1, __pyx_kp_s_no_default___reduce___due_to_non); if (unlikely(!__pyx_tuple__11)) __PYX_ERR(2, 2, __pyx_L1_error)
22122   __Pyx_GOTREF(__pyx_tuple__11);
22123   __Pyx_GIVEREF(__pyx_tuple__11);
22124 
22125   /* "(tree fragment)":4
22126  *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
22127  * def __setstate_cython__(self, __pyx_state):
22128  *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")             # <<<<<<<<<<<<<<
22129  */
22130   __pyx_tuple__12 = PyTuple_Pack(1, __pyx_kp_s_no_default___reduce___due_to_non); if (unlikely(!__pyx_tuple__12)) __PYX_ERR(2, 4, __pyx_L1_error)
22131   __Pyx_GOTREF(__pyx_tuple__12);
22132   __Pyx_GIVEREF(__pyx_tuple__12);
22133 
22134   /* "View.MemoryView":418
22135  *     def __setitem__(memoryview self, object index, object value):
22136  *         if self.view.readonly:
22137  *             raise TypeError("Cannot assign to read-only memoryview")             # <<<<<<<<<<<<<<
22138  *
22139  *         have_slices, index = _unellipsify(index, self.view.ndim)
22140  */
22141   __pyx_tuple__13 = PyTuple_Pack(1, __pyx_kp_s_Cannot_assign_to_read_only_memor); if (unlikely(!__pyx_tuple__13)) __PYX_ERR(2, 418, __pyx_L1_error)
22142   __Pyx_GOTREF(__pyx_tuple__13);
22143   __Pyx_GIVEREF(__pyx_tuple__13);
22144 
22145   /* "View.MemoryView":495
22146  *             result = struct.unpack(self.view.format, bytesitem)
22147  *         except struct.error:
22148  *             raise ValueError("Unable to convert item to object")             # <<<<<<<<<<<<<<
22149  *         else:
22150  *             if len(self.view.format) == 1:
22151  */
22152   __pyx_tuple__14 = PyTuple_Pack(1, __pyx_kp_s_Unable_to_convert_item_to_object); if (unlikely(!__pyx_tuple__14)) __PYX_ERR(2, 495, __pyx_L1_error)
22153   __Pyx_GOTREF(__pyx_tuple__14);
22154   __Pyx_GIVEREF(__pyx_tuple__14);
22155 
22156   /* "View.MemoryView":520
22157  *     def __getbuffer__(self, Py_buffer *info, int flags):
22158  *         if flags & PyBUF_WRITABLE and self.view.readonly:
22159  *             raise ValueError("Cannot create writable memory view from read-only memoryview")             # <<<<<<<<<<<<<<
22160  *
22161  *         if flags & PyBUF_ND:
22162  */
22163   __pyx_tuple__15 = PyTuple_Pack(1, __pyx_kp_s_Cannot_create_writable_memory_vi); if (unlikely(!__pyx_tuple__15)) __PYX_ERR(2, 520, __pyx_L1_error)
22164   __Pyx_GOTREF(__pyx_tuple__15);
22165   __Pyx_GIVEREF(__pyx_tuple__15);
22166 
22167   /* "View.MemoryView":570
22168  *         if self.view.strides == NULL:
22169  *
22170  *             raise ValueError("Buffer view does not expose strides")             # <<<<<<<<<<<<<<
22171  *
22172  *         return tuple([stride for stride in self.view.strides[:self.view.ndim]])
22173  */
22174   __pyx_tuple__16 = PyTuple_Pack(1, __pyx_kp_s_Buffer_view_does_not_expose_stri); if (unlikely(!__pyx_tuple__16)) __PYX_ERR(2, 570, __pyx_L1_error)
22175   __Pyx_GOTREF(__pyx_tuple__16);
22176   __Pyx_GIVEREF(__pyx_tuple__16);
22177 
22178   /* "View.MemoryView":577
22179  *     def suboffsets(self):
22180  *         if self.view.suboffsets == NULL:
22181  *             return (-1,) * self.view.ndim             # <<<<<<<<<<<<<<
22182  *
22183  *         return tuple([suboffset for suboffset in self.view.suboffsets[:self.view.ndim]])
22184  */
22185   __pyx_tuple__17 = PyTuple_New(1); if (unlikely(!__pyx_tuple__17)) __PYX_ERR(2, 577, __pyx_L1_error)
22186   __Pyx_GOTREF(__pyx_tuple__17);
22187   __Pyx_INCREF(__pyx_int_neg_1);
22188   __Pyx_GIVEREF(__pyx_int_neg_1);
22189   PyTuple_SET_ITEM(__pyx_tuple__17, 0, __pyx_int_neg_1);
22190   __Pyx_GIVEREF(__pyx_tuple__17);
22191 
22192   /* "(tree fragment)":2
22193  * def __reduce_cython__(self):
22194  *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")             # <<<<<<<<<<<<<<
22195  * def __setstate_cython__(self, __pyx_state):
22196  *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
22197  */
22198   __pyx_tuple__18 = PyTuple_Pack(1, __pyx_kp_s_no_default___reduce___due_to_non); if (unlikely(!__pyx_tuple__18)) __PYX_ERR(2, 2, __pyx_L1_error)
22199   __Pyx_GOTREF(__pyx_tuple__18);
22200   __Pyx_GIVEREF(__pyx_tuple__18);
22201 
22202   /* "(tree fragment)":4
22203  *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
22204  * def __setstate_cython__(self, __pyx_state):
22205  *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")             # <<<<<<<<<<<<<<
22206  */
22207   __pyx_tuple__19 = PyTuple_Pack(1, __pyx_kp_s_no_default___reduce___due_to_non); if (unlikely(!__pyx_tuple__19)) __PYX_ERR(2, 4, __pyx_L1_error)
22208   __Pyx_GOTREF(__pyx_tuple__19);
22209   __Pyx_GIVEREF(__pyx_tuple__19);
22210 
22211   /* "View.MemoryView":682
22212  *         if item is Ellipsis:
22213  *             if not seen_ellipsis:
22214  *                 result.extend([slice(None)] * (ndim - len(tup) + 1))             # <<<<<<<<<<<<<<
22215  *                 seen_ellipsis = True
22216  *             else:
22217  */
22218   __pyx_slice__20 = PySlice_New(Py_None, Py_None, Py_None); if (unlikely(!__pyx_slice__20)) __PYX_ERR(2, 682, __pyx_L1_error)
22219   __Pyx_GOTREF(__pyx_slice__20);
22220   __Pyx_GIVEREF(__pyx_slice__20);
22221 
22222   /* "View.MemoryView":703
22223  *     for suboffset in suboffsets[:ndim]:
22224  *         if suboffset >= 0:
22225  *             raise ValueError("Indirect dimensions not supported")             # <<<<<<<<<<<<<<
22226  *
22227  *
22228  */
22229   __pyx_tuple__21 = PyTuple_Pack(1, __pyx_kp_s_Indirect_dimensions_not_supporte); if (unlikely(!__pyx_tuple__21)) __PYX_ERR(2, 703, __pyx_L1_error)
22230   __Pyx_GOTREF(__pyx_tuple__21);
22231   __Pyx_GIVEREF(__pyx_tuple__21);
22232 
22233   /* "(tree fragment)":2
22234  * def __reduce_cython__(self):
22235  *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")             # <<<<<<<<<<<<<<
22236  * def __setstate_cython__(self, __pyx_state):
22237  *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
22238  */
22239   __pyx_tuple__22 = PyTuple_Pack(1, __pyx_kp_s_no_default___reduce___due_to_non); if (unlikely(!__pyx_tuple__22)) __PYX_ERR(2, 2, __pyx_L1_error)
22240   __Pyx_GOTREF(__pyx_tuple__22);
22241   __Pyx_GIVEREF(__pyx_tuple__22);
22242 
22243   /* "(tree fragment)":4
22244  *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
22245  * def __setstate_cython__(self, __pyx_state):
22246  *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")             # <<<<<<<<<<<<<<
22247  */
22248   __pyx_tuple__23 = PyTuple_Pack(1, __pyx_kp_s_no_default___reduce___due_to_non); if (unlikely(!__pyx_tuple__23)) __PYX_ERR(2, 4, __pyx_L1_error)
22249   __Pyx_GOTREF(__pyx_tuple__23);
22250   __Pyx_GIVEREF(__pyx_tuple__23);
22251 
22252   /* "qutip/cy/ptrace.pyx":46
22253  * @cython.wraparound(False)
22254  * @cython.cdivision(True)
22255  * def _ptrace_legacy(object rho, _sel):             # <<<<<<<<<<<<<<
22256  *     """
22257  *     Private function calculating the partial trace.
22258  */
22259   __pyx_tuple__25 = PyTuple_Pack(24, __pyx_n_s_rho, __pyx_n_s_sel, __pyx_n_s_mm, __pyx_n_s_ii, __pyx_n_s_tmp, __pyx_n_s_drho, __pyx_n_s_sel_2, __pyx_n_s_rest, __pyx_n_s_N, __pyx_n_s_M, __pyx_n_s_R, __pyx_n_s_ilistsel, __pyx_n_s_indsel, __pyx_n_s_ilistrest, __pyx_n_s_indrest, __pyx_n_s_ind, __pyx_n_s_data, __pyx_n_s_ptr, __pyx_n_s_perm, __pyx_n_s_rhdata, __pyx_n_s_rho1_data, __pyx_n_s_dims_kept0, __pyx_n_s_rho1_dims, __pyx_n_s_rho1_shape); if (unlikely(!__pyx_tuple__25)) __PYX_ERR(0, 46, __pyx_L1_error)
22260   __Pyx_GOTREF(__pyx_tuple__25);
22261   __Pyx_GIVEREF(__pyx_tuple__25);
22262   __pyx_codeobj__26 = (PyObject*)__Pyx_PyCode_New(2, 0, 24, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__25, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_qutip_cy_ptrace_pyx, __pyx_n_s_ptrace_legacy, 46, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__26)) __PYX_ERR(0, 46, __pyx_L1_error)
22263 
22264   /* "qutip/cy/ptrace.pyx":169
22265  * @cython.wraparound(False)
22266  * @cython.cdivision(True)
22267  * def _ptrace(object rho, sel): # work for N<= 26 on 16G Ram             # <<<<<<<<<<<<<<
22268  *     cdef int[::1] _sel
22269  *     cdef object _oper
22270  */
22271   __pyx_tuple__27 = PyTuple_Pack(14, __pyx_n_s_rho, __pyx_n_s_sel_2, __pyx_n_s_sel, __pyx_n_s_oper, __pyx_n_s_ii, __pyx_n_s_factor_keep, __pyx_n_s_factor_trace, __pyx_n_s_factor_tensor, __pyx_n_s_drho, __pyx_n_s_num_dims, __pyx_n_s_tensor_table, __pyx_n_s_dims_kept0, __pyx_n_s_rho1_dims, __pyx_n_s_rho1_shape); if (unlikely(!__pyx_tuple__27)) __PYX_ERR(0, 169, __pyx_L1_error)
22272   __Pyx_GOTREF(__pyx_tuple__27);
22273   __Pyx_GIVEREF(__pyx_tuple__27);
22274   __pyx_codeobj__28 = (PyObject*)__Pyx_PyCode_New(2, 0, 14, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__27, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_qutip_cy_ptrace_pyx, __pyx_n_s_ptrace, 169, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__28)) __PYX_ERR(0, 169, __pyx_L1_error)
22275 
22276   /* "View.MemoryView":286
22277  *         return self.name
22278  *
22279  * cdef generic = Enum("<strided and direct or indirect>")             # <<<<<<<<<<<<<<
22280  * cdef strided = Enum("<strided and direct>") # default
22281  * cdef indirect = Enum("<strided and indirect>")
22282  */
22283   __pyx_tuple__29 = PyTuple_Pack(1, __pyx_kp_s_strided_and_direct_or_indirect); if (unlikely(!__pyx_tuple__29)) __PYX_ERR(2, 286, __pyx_L1_error)
22284   __Pyx_GOTREF(__pyx_tuple__29);
22285   __Pyx_GIVEREF(__pyx_tuple__29);
22286 
22287   /* "View.MemoryView":287
22288  *
22289  * cdef generic = Enum("<strided and direct or indirect>")
22290  * cdef strided = Enum("<strided and direct>") # default             # <<<<<<<<<<<<<<
22291  * cdef indirect = Enum("<strided and indirect>")
22292  *
22293  */
22294   __pyx_tuple__30 = PyTuple_Pack(1, __pyx_kp_s_strided_and_direct); if (unlikely(!__pyx_tuple__30)) __PYX_ERR(2, 287, __pyx_L1_error)
22295   __Pyx_GOTREF(__pyx_tuple__30);
22296   __Pyx_GIVEREF(__pyx_tuple__30);
22297 
22298   /* "View.MemoryView":288
22299  * cdef generic = Enum("<strided and direct or indirect>")
22300  * cdef strided = Enum("<strided and direct>") # default
22301  * cdef indirect = Enum("<strided and indirect>")             # <<<<<<<<<<<<<<
22302  *
22303  *
22304  */
22305   __pyx_tuple__31 = PyTuple_Pack(1, __pyx_kp_s_strided_and_indirect); if (unlikely(!__pyx_tuple__31)) __PYX_ERR(2, 288, __pyx_L1_error)
22306   __Pyx_GOTREF(__pyx_tuple__31);
22307   __Pyx_GIVEREF(__pyx_tuple__31);
22308 
22309   /* "View.MemoryView":291
22310  *
22311  *
22312  * cdef contiguous = Enum("<contiguous and direct>")             # <<<<<<<<<<<<<<
22313  * cdef indirect_contiguous = Enum("<contiguous and indirect>")
22314  *
22315  */
22316   __pyx_tuple__32 = PyTuple_Pack(1, __pyx_kp_s_contiguous_and_direct); if (unlikely(!__pyx_tuple__32)) __PYX_ERR(2, 291, __pyx_L1_error)
22317   __Pyx_GOTREF(__pyx_tuple__32);
22318   __Pyx_GIVEREF(__pyx_tuple__32);
22319 
22320   /* "View.MemoryView":292
22321  *
22322  * cdef contiguous = Enum("<contiguous and direct>")
22323  * cdef indirect_contiguous = Enum("<contiguous and indirect>")             # <<<<<<<<<<<<<<
22324  *
22325  *
22326  */
22327   __pyx_tuple__33 = PyTuple_Pack(1, __pyx_kp_s_contiguous_and_indirect); if (unlikely(!__pyx_tuple__33)) __PYX_ERR(2, 292, __pyx_L1_error)
22328   __Pyx_GOTREF(__pyx_tuple__33);
22329   __Pyx_GIVEREF(__pyx_tuple__33);
22330 
22331   /* "(tree fragment)":1
22332  * def __pyx_unpickle_Enum(__pyx_type, long __pyx_checksum, __pyx_state):             # <<<<<<<<<<<<<<
22333  *     cdef object __pyx_PickleError
22334  *     cdef object __pyx_result
22335  */
22336   __pyx_tuple__34 = 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__34)) __PYX_ERR(2, 1, __pyx_L1_error)
22337   __Pyx_GOTREF(__pyx_tuple__34);
22338   __Pyx_GIVEREF(__pyx_tuple__34);
22339   __pyx_codeobj__35 = (PyObject*)__Pyx_PyCode_New(3, 0, 5, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__34, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_stringsource, __pyx_n_s_pyx_unpickle_Enum, 1, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__35)) __PYX_ERR(2, 1, __pyx_L1_error)
22340   __Pyx_RefNannyFinishContext();
22341   return 0;
22342   __pyx_L1_error:;
22343   __Pyx_RefNannyFinishContext();
22344   return -1;
22345 }
22346 
__Pyx_InitGlobals(void)22347 static CYTHON_SMALL_CODE int __Pyx_InitGlobals(void) {
22348   if (__Pyx_InitStrings(__pyx_string_tab) < 0) __PYX_ERR(0, 1, __pyx_L1_error);
22349   __pyx_int_0 = PyInt_FromLong(0); if (unlikely(!__pyx_int_0)) __PYX_ERR(0, 1, __pyx_L1_error)
22350   __pyx_int_1 = PyInt_FromLong(1); if (unlikely(!__pyx_int_1)) __PYX_ERR(0, 1, __pyx_L1_error)
22351   __pyx_int_2 = PyInt_FromLong(2); if (unlikely(!__pyx_int_2)) __PYX_ERR(0, 1, __pyx_L1_error)
22352   __pyx_int_3 = PyInt_FromLong(3); if (unlikely(!__pyx_int_3)) __PYX_ERR(0, 1, __pyx_L1_error)
22353   __pyx_int_184977713 = PyInt_FromLong(184977713L); if (unlikely(!__pyx_int_184977713)) __PYX_ERR(0, 1, __pyx_L1_error)
22354   __pyx_int_neg_1 = PyInt_FromLong(-1); if (unlikely(!__pyx_int_neg_1)) __PYX_ERR(0, 1, __pyx_L1_error)
22355   return 0;
22356   __pyx_L1_error:;
22357   return -1;
22358 }
22359 
22360 static CYTHON_SMALL_CODE int __Pyx_modinit_global_init_code(void); /*proto*/
22361 static CYTHON_SMALL_CODE int __Pyx_modinit_variable_export_code(void); /*proto*/
22362 static CYTHON_SMALL_CODE int __Pyx_modinit_function_export_code(void); /*proto*/
22363 static CYTHON_SMALL_CODE int __Pyx_modinit_type_init_code(void); /*proto*/
22364 static CYTHON_SMALL_CODE int __Pyx_modinit_type_import_code(void); /*proto*/
22365 static CYTHON_SMALL_CODE int __Pyx_modinit_variable_import_code(void); /*proto*/
22366 static CYTHON_SMALL_CODE int __Pyx_modinit_function_import_code(void); /*proto*/
22367 
__Pyx_modinit_global_init_code(void)22368 static int __Pyx_modinit_global_init_code(void) {
22369   __Pyx_RefNannyDeclarations
22370   __Pyx_RefNannySetupContext("__Pyx_modinit_global_init_code", 0);
22371   /*--- Global init code ---*/
22372   generic = Py_None; Py_INCREF(Py_None);
22373   strided = Py_None; Py_INCREF(Py_None);
22374   indirect = Py_None; Py_INCREF(Py_None);
22375   contiguous = Py_None; Py_INCREF(Py_None);
22376   indirect_contiguous = Py_None; Py_INCREF(Py_None);
22377   __Pyx_RefNannyFinishContext();
22378   return 0;
22379 }
22380 
__Pyx_modinit_variable_export_code(void)22381 static int __Pyx_modinit_variable_export_code(void) {
22382   __Pyx_RefNannyDeclarations
22383   __Pyx_RefNannySetupContext("__Pyx_modinit_variable_export_code", 0);
22384   /*--- Variable export code ---*/
22385   __Pyx_RefNannyFinishContext();
22386   return 0;
22387 }
22388 
__Pyx_modinit_function_export_code(void)22389 static int __Pyx_modinit_function_export_code(void) {
22390   __Pyx_RefNannyDeclarations
22391   __Pyx_RefNannySetupContext("__Pyx_modinit_function_export_code", 0);
22392   /*--- Function export code ---*/
22393   __Pyx_RefNannyFinishContext();
22394   return 0;
22395 }
22396 
__Pyx_modinit_type_init_code(void)22397 static int __Pyx_modinit_type_init_code(void) {
22398   __Pyx_RefNannyDeclarations
22399   int __pyx_lineno = 0;
22400   const char *__pyx_filename = NULL;
22401   int __pyx_clineno = 0;
22402   __Pyx_RefNannySetupContext("__Pyx_modinit_type_init_code", 0);
22403   /*--- Type init code ---*/
22404   __pyx_vtabptr_array = &__pyx_vtable_array;
22405   __pyx_vtable_array.get_memview = (PyObject *(*)(struct __pyx_array_obj *))__pyx_array_get_memview;
22406   if (PyType_Ready(&__pyx_type___pyx_array) < 0) __PYX_ERR(2, 105, __pyx_L1_error)
22407   #if PY_VERSION_HEX < 0x030800B1
22408   __pyx_type___pyx_array.tp_print = 0;
22409   #endif
22410   if (__Pyx_SetVtable(__pyx_type___pyx_array.tp_dict, __pyx_vtabptr_array) < 0) __PYX_ERR(2, 105, __pyx_L1_error)
22411   if (__Pyx_setup_reduce((PyObject*)&__pyx_type___pyx_array) < 0) __PYX_ERR(2, 105, __pyx_L1_error)
22412   __pyx_array_type = &__pyx_type___pyx_array;
22413   if (PyType_Ready(&__pyx_type___pyx_MemviewEnum) < 0) __PYX_ERR(2, 279, __pyx_L1_error)
22414   #if PY_VERSION_HEX < 0x030800B1
22415   __pyx_type___pyx_MemviewEnum.tp_print = 0;
22416   #endif
22417   if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type___pyx_MemviewEnum.tp_dictoffset && __pyx_type___pyx_MemviewEnum.tp_getattro == PyObject_GenericGetAttr)) {
22418     __pyx_type___pyx_MemviewEnum.tp_getattro = __Pyx_PyObject_GenericGetAttr;
22419   }
22420   if (__Pyx_setup_reduce((PyObject*)&__pyx_type___pyx_MemviewEnum) < 0) __PYX_ERR(2, 279, __pyx_L1_error)
22421   __pyx_MemviewEnum_type = &__pyx_type___pyx_MemviewEnum;
22422   __pyx_vtabptr_memoryview = &__pyx_vtable_memoryview;
22423   __pyx_vtable_memoryview.get_item_pointer = (char *(*)(struct __pyx_memoryview_obj *, PyObject *))__pyx_memoryview_get_item_pointer;
22424   __pyx_vtable_memoryview.is_slice = (PyObject *(*)(struct __pyx_memoryview_obj *, PyObject *))__pyx_memoryview_is_slice;
22425   __pyx_vtable_memoryview.setitem_slice_assignment = (PyObject *(*)(struct __pyx_memoryview_obj *, PyObject *, PyObject *))__pyx_memoryview_setitem_slice_assignment;
22426   __pyx_vtable_memoryview.setitem_slice_assign_scalar = (PyObject *(*)(struct __pyx_memoryview_obj *, struct __pyx_memoryview_obj *, PyObject *))__pyx_memoryview_setitem_slice_assign_scalar;
22427   __pyx_vtable_memoryview.setitem_indexed = (PyObject *(*)(struct __pyx_memoryview_obj *, PyObject *, PyObject *))__pyx_memoryview_setitem_indexed;
22428   __pyx_vtable_memoryview.convert_item_to_object = (PyObject *(*)(struct __pyx_memoryview_obj *, char *))__pyx_memoryview_convert_item_to_object;
22429   __pyx_vtable_memoryview.assign_item_from_object = (PyObject *(*)(struct __pyx_memoryview_obj *, char *, PyObject *))__pyx_memoryview_assign_item_from_object;
22430   if (PyType_Ready(&__pyx_type___pyx_memoryview) < 0) __PYX_ERR(2, 330, __pyx_L1_error)
22431   #if PY_VERSION_HEX < 0x030800B1
22432   __pyx_type___pyx_memoryview.tp_print = 0;
22433   #endif
22434   if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type___pyx_memoryview.tp_dictoffset && __pyx_type___pyx_memoryview.tp_getattro == PyObject_GenericGetAttr)) {
22435     __pyx_type___pyx_memoryview.tp_getattro = __Pyx_PyObject_GenericGetAttr;
22436   }
22437   if (__Pyx_SetVtable(__pyx_type___pyx_memoryview.tp_dict, __pyx_vtabptr_memoryview) < 0) __PYX_ERR(2, 330, __pyx_L1_error)
22438   if (__Pyx_setup_reduce((PyObject*)&__pyx_type___pyx_memoryview) < 0) __PYX_ERR(2, 330, __pyx_L1_error)
22439   __pyx_memoryview_type = &__pyx_type___pyx_memoryview;
22440   __pyx_vtabptr__memoryviewslice = &__pyx_vtable__memoryviewslice;
22441   __pyx_vtable__memoryviewslice.__pyx_base = *__pyx_vtabptr_memoryview;
22442   __pyx_vtable__memoryviewslice.__pyx_base.convert_item_to_object = (PyObject *(*)(struct __pyx_memoryview_obj *, char *))__pyx_memoryviewslice_convert_item_to_object;
22443   __pyx_vtable__memoryviewslice.__pyx_base.assign_item_from_object = (PyObject *(*)(struct __pyx_memoryview_obj *, char *, PyObject *))__pyx_memoryviewslice_assign_item_from_object;
22444   __pyx_type___pyx_memoryviewslice.tp_base = __pyx_memoryview_type;
22445   if (PyType_Ready(&__pyx_type___pyx_memoryviewslice) < 0) __PYX_ERR(2, 965, __pyx_L1_error)
22446   #if PY_VERSION_HEX < 0x030800B1
22447   __pyx_type___pyx_memoryviewslice.tp_print = 0;
22448   #endif
22449   if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type___pyx_memoryviewslice.tp_dictoffset && __pyx_type___pyx_memoryviewslice.tp_getattro == PyObject_GenericGetAttr)) {
22450     __pyx_type___pyx_memoryviewslice.tp_getattro = __Pyx_PyObject_GenericGetAttr;
22451   }
22452   if (__Pyx_SetVtable(__pyx_type___pyx_memoryviewslice.tp_dict, __pyx_vtabptr__memoryviewslice) < 0) __PYX_ERR(2, 965, __pyx_L1_error)
22453   if (__Pyx_setup_reduce((PyObject*)&__pyx_type___pyx_memoryviewslice) < 0) __PYX_ERR(2, 965, __pyx_L1_error)
22454   __pyx_memoryviewslice_type = &__pyx_type___pyx_memoryviewslice;
22455   __Pyx_RefNannyFinishContext();
22456   return 0;
22457   __pyx_L1_error:;
22458   __Pyx_RefNannyFinishContext();
22459   return -1;
22460 }
22461 
__Pyx_modinit_type_import_code(void)22462 static int __Pyx_modinit_type_import_code(void) {
22463   __Pyx_RefNannyDeclarations
22464   PyObject *__pyx_t_1 = NULL;
22465   int __pyx_lineno = 0;
22466   const char *__pyx_filename = NULL;
22467   int __pyx_clineno = 0;
22468   __Pyx_RefNannySetupContext("__Pyx_modinit_type_import_code", 0);
22469   /*--- Type import code ---*/
22470   __pyx_t_1 = PyImport_ImportModule(__Pyx_BUILTIN_MODULE_NAME); if (unlikely(!__pyx_t_1)) __PYX_ERR(3, 9, __pyx_L1_error)
22471   __Pyx_GOTREF(__pyx_t_1);
22472   __pyx_ptype_7cpython_4type_type = __Pyx_ImportType(__pyx_t_1, __Pyx_BUILTIN_MODULE_NAME, "type",
22473   #if defined(PYPY_VERSION_NUM) && PYPY_VERSION_NUM < 0x050B0000
22474   sizeof(PyTypeObject),
22475   #else
22476   sizeof(PyHeapTypeObject),
22477   #endif
22478   __Pyx_ImportType_CheckSize_Warn);
22479    if (!__pyx_ptype_7cpython_4type_type) __PYX_ERR(3, 9, __pyx_L1_error)
22480   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
22481   __pyx_t_1 = PyImport_ImportModule("numpy"); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 199, __pyx_L1_error)
22482   __Pyx_GOTREF(__pyx_t_1);
22483   __pyx_ptype_5numpy_dtype = __Pyx_ImportType(__pyx_t_1, "numpy", "dtype", sizeof(PyArray_Descr), __Pyx_ImportType_CheckSize_Ignore);
22484    if (!__pyx_ptype_5numpy_dtype) __PYX_ERR(1, 199, __pyx_L1_error)
22485   __pyx_ptype_5numpy_flatiter = __Pyx_ImportType(__pyx_t_1, "numpy", "flatiter", sizeof(PyArrayIterObject), __Pyx_ImportType_CheckSize_Ignore);
22486    if (!__pyx_ptype_5numpy_flatiter) __PYX_ERR(1, 222, __pyx_L1_error)
22487   __pyx_ptype_5numpy_broadcast = __Pyx_ImportType(__pyx_t_1, "numpy", "broadcast", sizeof(PyArrayMultiIterObject), __Pyx_ImportType_CheckSize_Ignore);
22488    if (!__pyx_ptype_5numpy_broadcast) __PYX_ERR(1, 226, __pyx_L1_error)
22489   __pyx_ptype_5numpy_ndarray = __Pyx_ImportType(__pyx_t_1, "numpy", "ndarray", sizeof(PyArrayObject), __Pyx_ImportType_CheckSize_Ignore);
22490    if (!__pyx_ptype_5numpy_ndarray) __PYX_ERR(1, 238, __pyx_L1_error)
22491   __pyx_ptype_5numpy_ufunc = __Pyx_ImportType(__pyx_t_1, "numpy", "ufunc", sizeof(PyUFuncObject), __Pyx_ImportType_CheckSize_Ignore);
22492    if (!__pyx_ptype_5numpy_ufunc) __PYX_ERR(1, 764, __pyx_L1_error)
22493   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
22494   __Pyx_RefNannyFinishContext();
22495   return 0;
22496   __pyx_L1_error:;
22497   __Pyx_XDECREF(__pyx_t_1);
22498   __Pyx_RefNannyFinishContext();
22499   return -1;
22500 }
22501 
__Pyx_modinit_variable_import_code(void)22502 static int __Pyx_modinit_variable_import_code(void) {
22503   __Pyx_RefNannyDeclarations
22504   __Pyx_RefNannySetupContext("__Pyx_modinit_variable_import_code", 0);
22505   /*--- Variable import code ---*/
22506   __Pyx_RefNannyFinishContext();
22507   return 0;
22508 }
22509 
__Pyx_modinit_function_import_code(void)22510 static int __Pyx_modinit_function_import_code(void) {
22511   __Pyx_RefNannyDeclarations
22512   __Pyx_RefNannySetupContext("__Pyx_modinit_function_import_code", 0);
22513   /*--- Function import code ---*/
22514   __Pyx_RefNannyFinishContext();
22515   return 0;
22516 }
22517 
22518 
22519 #ifndef CYTHON_NO_PYINIT_EXPORT
22520 #define __Pyx_PyMODINIT_FUNC PyMODINIT_FUNC
22521 #elif PY_MAJOR_VERSION < 3
22522 #ifdef __cplusplus
22523 #define __Pyx_PyMODINIT_FUNC extern "C" void
22524 #else
22525 #define __Pyx_PyMODINIT_FUNC void
22526 #endif
22527 #else
22528 #ifdef __cplusplus
22529 #define __Pyx_PyMODINIT_FUNC extern "C" PyObject *
22530 #else
22531 #define __Pyx_PyMODINIT_FUNC PyObject *
22532 #endif
22533 #endif
22534 
22535 
22536 #if PY_MAJOR_VERSION < 3
22537 __Pyx_PyMODINIT_FUNC initptrace(void) CYTHON_SMALL_CODE; /*proto*/
initptrace(void)22538 __Pyx_PyMODINIT_FUNC initptrace(void)
22539 #else
22540 __Pyx_PyMODINIT_FUNC PyInit_ptrace(void) CYTHON_SMALL_CODE; /*proto*/
22541 __Pyx_PyMODINIT_FUNC PyInit_ptrace(void)
22542 #if CYTHON_PEP489_MULTI_PHASE_INIT
22543 {
22544   return PyModuleDef_Init(&__pyx_moduledef);
22545 }
22546 static CYTHON_SMALL_CODE int __Pyx_check_single_interpreter(void) {
22547     #if PY_VERSION_HEX >= 0x030700A1
22548     static PY_INT64_T main_interpreter_id = -1;
22549     PY_INT64_T current_id = PyInterpreterState_GetID(PyThreadState_Get()->interp);
22550     if (main_interpreter_id == -1) {
22551         main_interpreter_id = current_id;
22552         return (unlikely(current_id == -1)) ? -1 : 0;
22553     } else if (unlikely(main_interpreter_id != current_id))
22554     #else
22555     static PyInterpreterState *main_interpreter = NULL;
22556     PyInterpreterState *current_interpreter = PyThreadState_Get()->interp;
22557     if (!main_interpreter) {
22558         main_interpreter = current_interpreter;
22559     } else if (unlikely(main_interpreter != current_interpreter))
22560     #endif
22561     {
22562         PyErr_SetString(
22563             PyExc_ImportError,
22564             "Interpreter change detected - this module can only be loaded into one interpreter per process.");
22565         return -1;
22566     }
22567     return 0;
22568 }
22569 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) {
22570     PyObject *value = PyObject_GetAttrString(spec, from_name);
22571     int result = 0;
22572     if (likely(value)) {
22573         if (allow_none || value != Py_None) {
22574             result = PyDict_SetItemString(moddict, to_name, value);
22575         }
22576         Py_DECREF(value);
22577     } else if (PyErr_ExceptionMatches(PyExc_AttributeError)) {
22578         PyErr_Clear();
22579     } else {
22580         result = -1;
22581     }
22582     return result;
22583 }
22584 static CYTHON_SMALL_CODE PyObject* __pyx_pymod_create(PyObject *spec, CYTHON_UNUSED PyModuleDef *def) {
22585     PyObject *module = NULL, *moddict, *modname;
22586     if (__Pyx_check_single_interpreter())
22587         return NULL;
22588     if (__pyx_m)
22589         return __Pyx_NewRef(__pyx_m);
22590     modname = PyObject_GetAttrString(spec, "name");
22591     if (unlikely(!modname)) goto bad;
22592     module = PyModule_NewObject(modname);
22593     Py_DECREF(modname);
22594     if (unlikely(!module)) goto bad;
22595     moddict = PyModule_GetDict(module);
22596     if (unlikely(!moddict)) goto bad;
22597     if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "loader", "__loader__", 1) < 0)) goto bad;
22598     if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "origin", "__file__", 1) < 0)) goto bad;
22599     if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "parent", "__package__", 1) < 0)) goto bad;
22600     if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "submodule_search_locations", "__path__", 0) < 0)) goto bad;
22601     return module;
22602 bad:
22603     Py_XDECREF(module);
22604     return NULL;
22605 }
22606 
22607 
22608 static CYTHON_SMALL_CODE int __pyx_pymod_exec_ptrace(PyObject *__pyx_pyinit_module)
22609 #endif
22610 #endif
22611 {
22612   PyObject *__pyx_t_1 = NULL;
22613   PyObject *__pyx_t_2 = NULL;
22614   static PyThread_type_lock __pyx_t_3[8];
22615   int __pyx_lineno = 0;
22616   const char *__pyx_filename = NULL;
22617   int __pyx_clineno = 0;
22618   __Pyx_RefNannyDeclarations
22619   #if CYTHON_PEP489_MULTI_PHASE_INIT
22620   if (__pyx_m) {
22621     if (__pyx_m == __pyx_pyinit_module) return 0;
22622     PyErr_SetString(PyExc_RuntimeError, "Module 'ptrace' has already been imported. Re-initialisation is not supported.");
22623     return -1;
22624   }
22625   #elif PY_MAJOR_VERSION >= 3
22626   if (__pyx_m) return __Pyx_NewRef(__pyx_m);
22627   #endif
22628   #if CYTHON_REFNANNY
22629 __Pyx_RefNanny = __Pyx_RefNannyImportAPI("refnanny");
22630 if (!__Pyx_RefNanny) {
22631   PyErr_Clear();
22632   __Pyx_RefNanny = __Pyx_RefNannyImportAPI("Cython.Runtime.refnanny");
22633   if (!__Pyx_RefNanny)
22634       Py_FatalError("failed to import 'refnanny' module");
22635 }
22636 #endif
22637   __Pyx_RefNannySetupContext("__Pyx_PyMODINIT_FUNC PyInit_ptrace(void)", 0);
22638   if (__Pyx_check_binary_version() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
22639   #ifdef __Pxy_PyFrame_Initialize_Offsets
22640   __Pxy_PyFrame_Initialize_Offsets();
22641   #endif
22642   __pyx_empty_tuple = PyTuple_New(0); if (unlikely(!__pyx_empty_tuple)) __PYX_ERR(0, 1, __pyx_L1_error)
22643   __pyx_empty_bytes = PyBytes_FromStringAndSize("", 0); if (unlikely(!__pyx_empty_bytes)) __PYX_ERR(0, 1, __pyx_L1_error)
22644   __pyx_empty_unicode = PyUnicode_FromStringAndSize("", 0); if (unlikely(!__pyx_empty_unicode)) __PYX_ERR(0, 1, __pyx_L1_error)
22645   #ifdef __Pyx_CyFunction_USED
22646   if (__pyx_CyFunction_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
22647   #endif
22648   #ifdef __Pyx_FusedFunction_USED
22649   if (__pyx_FusedFunction_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
22650   #endif
22651   #ifdef __Pyx_Coroutine_USED
22652   if (__pyx_Coroutine_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
22653   #endif
22654   #ifdef __Pyx_Generator_USED
22655   if (__pyx_Generator_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
22656   #endif
22657   #ifdef __Pyx_AsyncGen_USED
22658   if (__pyx_AsyncGen_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
22659   #endif
22660   #ifdef __Pyx_StopAsyncIteration_USED
22661   if (__pyx_StopAsyncIteration_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
22662   #endif
22663   /*--- Library function declarations ---*/
22664   /*--- Threads initialization code ---*/
22665   #if defined(__PYX_FORCE_INIT_THREADS) && __PYX_FORCE_INIT_THREADS
22666   #ifdef WITH_THREAD /* Python build with threading support? */
22667   PyEval_InitThreads();
22668   #endif
22669   #endif
22670   /*--- Module creation code ---*/
22671   #if CYTHON_PEP489_MULTI_PHASE_INIT
22672   __pyx_m = __pyx_pyinit_module;
22673   Py_INCREF(__pyx_m);
22674   #else
22675   #if PY_MAJOR_VERSION < 3
22676   __pyx_m = Py_InitModule4("ptrace", __pyx_methods, 0, 0, PYTHON_API_VERSION); Py_XINCREF(__pyx_m);
22677   #else
22678   __pyx_m = PyModule_Create(&__pyx_moduledef);
22679   #endif
22680   if (unlikely(!__pyx_m)) __PYX_ERR(0, 1, __pyx_L1_error)
22681   #endif
22682   __pyx_d = PyModule_GetDict(__pyx_m); if (unlikely(!__pyx_d)) __PYX_ERR(0, 1, __pyx_L1_error)
22683   Py_INCREF(__pyx_d);
22684   __pyx_b = PyImport_AddModule(__Pyx_BUILTIN_MODULE_NAME); if (unlikely(!__pyx_b)) __PYX_ERR(0, 1, __pyx_L1_error)
22685   Py_INCREF(__pyx_b);
22686   __pyx_cython_runtime = PyImport_AddModule((char *) "cython_runtime"); if (unlikely(!__pyx_cython_runtime)) __PYX_ERR(0, 1, __pyx_L1_error)
22687   Py_INCREF(__pyx_cython_runtime);
22688   if (PyObject_SetAttrString(__pyx_m, "__builtins__", __pyx_b) < 0) __PYX_ERR(0, 1, __pyx_L1_error);
22689   /*--- Initialize various global constants etc. ---*/
22690   if (__Pyx_InitGlobals() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
22691   #if PY_MAJOR_VERSION < 3 && (__PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT)
22692   if (__Pyx_init_sys_getdefaultencoding_params() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
22693   #endif
22694   if (__pyx_module_is_main_qutip__cy__ptrace) {
22695     if (PyObject_SetAttr(__pyx_m, __pyx_n_s_name_2, __pyx_n_s_main) < 0) __PYX_ERR(0, 1, __pyx_L1_error)
22696   }
22697   #if PY_MAJOR_VERSION >= 3
22698   {
22699     PyObject *modules = PyImport_GetModuleDict(); if (unlikely(!modules)) __PYX_ERR(0, 1, __pyx_L1_error)
22700     if (!PyDict_GetItemString(modules, "qutip.cy.ptrace")) {
22701       if (unlikely(PyDict_SetItemString(modules, "qutip.cy.ptrace", __pyx_m) < 0)) __PYX_ERR(0, 1, __pyx_L1_error)
22702     }
22703   }
22704   #endif
22705   /*--- Builtin init code ---*/
22706   if (__Pyx_InitCachedBuiltins() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
22707   /*--- Constants init code ---*/
22708   if (__Pyx_InitCachedConstants() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
22709   /*--- Global type/function init code ---*/
22710   (void)__Pyx_modinit_global_init_code();
22711   (void)__Pyx_modinit_variable_export_code();
22712   (void)__Pyx_modinit_function_export_code();
22713   if (unlikely(__Pyx_modinit_type_init_code() < 0)) __PYX_ERR(0, 1, __pyx_L1_error)
22714   if (unlikely(__Pyx_modinit_type_import_code() < 0)) __PYX_ERR(0, 1, __pyx_L1_error)
22715   (void)__Pyx_modinit_variable_import_code();
22716   (void)__Pyx_modinit_function_import_code();
22717   /*--- Execution code ---*/
22718   #if defined(__Pyx_Generator_USED) || defined(__Pyx_Coroutine_USED)
22719   if (__Pyx_patch_abc() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
22720   #endif
22721 
22722   /* "qutip/cy/ptrace.pyx":34
22723  * #    OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
22724  * ###############################################################################
22725  * import numpy as np             # <<<<<<<<<<<<<<
22726  * from qutip.cy.spconvert import zcsr_reshape
22727  * from qutip.cy.spmath import zcsr_mult
22728  */
22729   __pyx_t_1 = __Pyx_Import(__pyx_n_s_numpy, 0, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 34, __pyx_L1_error)
22730   __Pyx_GOTREF(__pyx_t_1);
22731   if (PyDict_SetItem(__pyx_d, __pyx_n_s_np, __pyx_t_1) < 0) __PYX_ERR(0, 34, __pyx_L1_error)
22732   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
22733 
22734   /* "qutip/cy/ptrace.pyx":35
22735  * ###############################################################################
22736  * import numpy as np
22737  * from qutip.cy.spconvert import zcsr_reshape             # <<<<<<<<<<<<<<
22738  * from qutip.cy.spmath import zcsr_mult
22739  * from qutip.fastsparse import fast_csr_matrix, csr2fast
22740  */
22741   __pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 35, __pyx_L1_error)
22742   __Pyx_GOTREF(__pyx_t_1);
22743   __Pyx_INCREF(__pyx_n_s_zcsr_reshape);
22744   __Pyx_GIVEREF(__pyx_n_s_zcsr_reshape);
22745   PyList_SET_ITEM(__pyx_t_1, 0, __pyx_n_s_zcsr_reshape);
22746   __pyx_t_2 = __Pyx_Import(__pyx_n_s_qutip_cy_spconvert, __pyx_t_1, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 35, __pyx_L1_error)
22747   __Pyx_GOTREF(__pyx_t_2);
22748   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
22749   __pyx_t_1 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_zcsr_reshape); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 35, __pyx_L1_error)
22750   __Pyx_GOTREF(__pyx_t_1);
22751   if (PyDict_SetItem(__pyx_d, __pyx_n_s_zcsr_reshape, __pyx_t_1) < 0) __PYX_ERR(0, 35, __pyx_L1_error)
22752   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
22753   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
22754 
22755   /* "qutip/cy/ptrace.pyx":36
22756  * import numpy as np
22757  * from qutip.cy.spconvert import zcsr_reshape
22758  * from qutip.cy.spmath import zcsr_mult             # <<<<<<<<<<<<<<
22759  * from qutip.fastsparse import fast_csr_matrix, csr2fast
22760  * cimport numpy as cnp
22761  */
22762   __pyx_t_2 = PyList_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 36, __pyx_L1_error)
22763   __Pyx_GOTREF(__pyx_t_2);
22764   __Pyx_INCREF(__pyx_n_s_zcsr_mult);
22765   __Pyx_GIVEREF(__pyx_n_s_zcsr_mult);
22766   PyList_SET_ITEM(__pyx_t_2, 0, __pyx_n_s_zcsr_mult);
22767   __pyx_t_1 = __Pyx_Import(__pyx_n_s_qutip_cy_spmath, __pyx_t_2, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 36, __pyx_L1_error)
22768   __Pyx_GOTREF(__pyx_t_1);
22769   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
22770   __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_1, __pyx_n_s_zcsr_mult); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 36, __pyx_L1_error)
22771   __Pyx_GOTREF(__pyx_t_2);
22772   if (PyDict_SetItem(__pyx_d, __pyx_n_s_zcsr_mult, __pyx_t_2) < 0) __PYX_ERR(0, 36, __pyx_L1_error)
22773   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
22774   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
22775 
22776   /* "qutip/cy/ptrace.pyx":37
22777  * from qutip.cy.spconvert import zcsr_reshape
22778  * from qutip.cy.spmath import zcsr_mult
22779  * from qutip.fastsparse import fast_csr_matrix, csr2fast             # <<<<<<<<<<<<<<
22780  * cimport numpy as cnp
22781  * cimport cython
22782  */
22783   __pyx_t_1 = PyList_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 37, __pyx_L1_error)
22784   __Pyx_GOTREF(__pyx_t_1);
22785   __Pyx_INCREF(__pyx_n_s_fast_csr_matrix);
22786   __Pyx_GIVEREF(__pyx_n_s_fast_csr_matrix);
22787   PyList_SET_ITEM(__pyx_t_1, 0, __pyx_n_s_fast_csr_matrix);
22788   __Pyx_INCREF(__pyx_n_s_csr2fast);
22789   __Pyx_GIVEREF(__pyx_n_s_csr2fast);
22790   PyList_SET_ITEM(__pyx_t_1, 1, __pyx_n_s_csr2fast);
22791   __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)
22792   __Pyx_GOTREF(__pyx_t_2);
22793   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
22794   __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)
22795   __Pyx_GOTREF(__pyx_t_1);
22796   if (PyDict_SetItem(__pyx_d, __pyx_n_s_fast_csr_matrix, __pyx_t_1) < 0) __PYX_ERR(0, 37, __pyx_L1_error)
22797   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
22798   __pyx_t_1 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_csr2fast); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 37, __pyx_L1_error)
22799   __Pyx_GOTREF(__pyx_t_1);
22800   if (PyDict_SetItem(__pyx_d, __pyx_n_s_csr2fast, __pyx_t_1) < 0) __PYX_ERR(0, 37, __pyx_L1_error)
22801   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
22802   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
22803 
22804   /* "qutip/cy/ptrace.pyx":41
22805  * cimport cython
22806  * from libc.math cimport floor, trunc
22807  * import scipy.sparse as sp             # <<<<<<<<<<<<<<
22808  *
22809  * @cython.boundscheck(False)
22810  */
22811   __pyx_t_2 = PyList_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 41, __pyx_L1_error)
22812   __Pyx_GOTREF(__pyx_t_2);
22813   __Pyx_INCREF(__pyx_n_s__24);
22814   __Pyx_GIVEREF(__pyx_n_s__24);
22815   PyList_SET_ITEM(__pyx_t_2, 0, __pyx_n_s__24);
22816   __pyx_t_1 = __Pyx_Import(__pyx_n_s_scipy_sparse, __pyx_t_2, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 41, __pyx_L1_error)
22817   __Pyx_GOTREF(__pyx_t_1);
22818   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
22819   if (PyDict_SetItem(__pyx_d, __pyx_n_s_sp, __pyx_t_1) < 0) __PYX_ERR(0, 41, __pyx_L1_error)
22820   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
22821 
22822   /* "qutip/cy/ptrace.pyx":46
22823  * @cython.wraparound(False)
22824  * @cython.cdivision(True)
22825  * def _ptrace_legacy(object rho, _sel):             # <<<<<<<<<<<<<<
22826  *     """
22827  *     Private function calculating the partial trace.
22828  */
22829   __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_5qutip_2cy_6ptrace_1_ptrace_legacy, NULL, __pyx_n_s_qutip_cy_ptrace); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 46, __pyx_L1_error)
22830   __Pyx_GOTREF(__pyx_t_1);
22831   if (PyDict_SetItem(__pyx_d, __pyx_n_s_ptrace_legacy, __pyx_t_1) < 0) __PYX_ERR(0, 46, __pyx_L1_error)
22832   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
22833 
22834   /* "qutip/cy/ptrace.pyx":169
22835  * @cython.wraparound(False)
22836  * @cython.cdivision(True)
22837  * def _ptrace(object rho, sel): # work for N<= 26 on 16G Ram             # <<<<<<<<<<<<<<
22838  *     cdef int[::1] _sel
22839  *     cdef object _oper
22840  */
22841   __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_5qutip_2cy_6ptrace_7_ptrace, NULL, __pyx_n_s_qutip_cy_ptrace); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 169, __pyx_L1_error)
22842   __Pyx_GOTREF(__pyx_t_1);
22843   if (PyDict_SetItem(__pyx_d, __pyx_n_s_ptrace, __pyx_t_1) < 0) __PYX_ERR(0, 169, __pyx_L1_error)
22844   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
22845 
22846   /* "qutip/cy/ptrace.pyx":1
22847  * #cython: language_level=3             # <<<<<<<<<<<<<<
22848  * # This file is part of QuTiP: Quantum Toolbox in Python.
22849  * #
22850  */
22851   __pyx_t_1 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1, __pyx_L1_error)
22852   __Pyx_GOTREF(__pyx_t_1);
22853   if (PyDict_SetItem(__pyx_d, __pyx_n_s_test, __pyx_t_1) < 0) __PYX_ERR(0, 1, __pyx_L1_error)
22854   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
22855 
22856   /* "View.MemoryView":209
22857  *         info.obj = self
22858  *
22859  *     __pyx_getbuffer = capsule(<void *> &__pyx_array_getbuffer, "getbuffer(obj, view, flags)")             # <<<<<<<<<<<<<<
22860  *
22861  *     def __dealloc__(array self):
22862  */
22863   __pyx_t_1 = __pyx_capsule_create(((void *)(&__pyx_array_getbuffer)), ((char *)"getbuffer(obj, view, flags)")); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 209, __pyx_L1_error)
22864   __Pyx_GOTREF(__pyx_t_1);
22865   if (PyDict_SetItem((PyObject *)__pyx_array_type->tp_dict, __pyx_n_s_pyx_getbuffer, __pyx_t_1) < 0) __PYX_ERR(2, 209, __pyx_L1_error)
22866   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
22867   PyType_Modified(__pyx_array_type);
22868 
22869   /* "View.MemoryView":286
22870  *         return self.name
22871  *
22872  * cdef generic = Enum("<strided and direct or indirect>")             # <<<<<<<<<<<<<<
22873  * cdef strided = Enum("<strided and direct>") # default
22874  * cdef indirect = Enum("<strided and indirect>")
22875  */
22876   __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)__pyx_MemviewEnum_type), __pyx_tuple__29, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 286, __pyx_L1_error)
22877   __Pyx_GOTREF(__pyx_t_1);
22878   __Pyx_XGOTREF(generic);
22879   __Pyx_DECREF_SET(generic, __pyx_t_1);
22880   __Pyx_GIVEREF(__pyx_t_1);
22881   __pyx_t_1 = 0;
22882 
22883   /* "View.MemoryView":287
22884  *
22885  * cdef generic = Enum("<strided and direct or indirect>")
22886  * cdef strided = Enum("<strided and direct>") # default             # <<<<<<<<<<<<<<
22887  * cdef indirect = Enum("<strided and indirect>")
22888  *
22889  */
22890   __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)__pyx_MemviewEnum_type), __pyx_tuple__30, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 287, __pyx_L1_error)
22891   __Pyx_GOTREF(__pyx_t_1);
22892   __Pyx_XGOTREF(strided);
22893   __Pyx_DECREF_SET(strided, __pyx_t_1);
22894   __Pyx_GIVEREF(__pyx_t_1);
22895   __pyx_t_1 = 0;
22896 
22897   /* "View.MemoryView":288
22898  * cdef generic = Enum("<strided and direct or indirect>")
22899  * cdef strided = Enum("<strided and direct>") # default
22900  * cdef indirect = Enum("<strided and indirect>")             # <<<<<<<<<<<<<<
22901  *
22902  *
22903  */
22904   __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)__pyx_MemviewEnum_type), __pyx_tuple__31, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 288, __pyx_L1_error)
22905   __Pyx_GOTREF(__pyx_t_1);
22906   __Pyx_XGOTREF(indirect);
22907   __Pyx_DECREF_SET(indirect, __pyx_t_1);
22908   __Pyx_GIVEREF(__pyx_t_1);
22909   __pyx_t_1 = 0;
22910 
22911   /* "View.MemoryView":291
22912  *
22913  *
22914  * cdef contiguous = Enum("<contiguous and direct>")             # <<<<<<<<<<<<<<
22915  * cdef indirect_contiguous = Enum("<contiguous and indirect>")
22916  *
22917  */
22918   __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)__pyx_MemviewEnum_type), __pyx_tuple__32, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 291, __pyx_L1_error)
22919   __Pyx_GOTREF(__pyx_t_1);
22920   __Pyx_XGOTREF(contiguous);
22921   __Pyx_DECREF_SET(contiguous, __pyx_t_1);
22922   __Pyx_GIVEREF(__pyx_t_1);
22923   __pyx_t_1 = 0;
22924 
22925   /* "View.MemoryView":292
22926  *
22927  * cdef contiguous = Enum("<contiguous and direct>")
22928  * cdef indirect_contiguous = Enum("<contiguous and indirect>")             # <<<<<<<<<<<<<<
22929  *
22930  *
22931  */
22932   __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)__pyx_MemviewEnum_type), __pyx_tuple__33, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 292, __pyx_L1_error)
22933   __Pyx_GOTREF(__pyx_t_1);
22934   __Pyx_XGOTREF(indirect_contiguous);
22935   __Pyx_DECREF_SET(indirect_contiguous, __pyx_t_1);
22936   __Pyx_GIVEREF(__pyx_t_1);
22937   __pyx_t_1 = 0;
22938 
22939   /* "View.MemoryView":316
22940  *
22941  * DEF THREAD_LOCKS_PREALLOCATED = 8
22942  * cdef int __pyx_memoryview_thread_locks_used = 0             # <<<<<<<<<<<<<<
22943  * cdef PyThread_type_lock[THREAD_LOCKS_PREALLOCATED] __pyx_memoryview_thread_locks = [
22944  *     PyThread_allocate_lock(),
22945  */
22946   __pyx_memoryview_thread_locks_used = 0;
22947 
22948   /* "View.MemoryView":317
22949  * DEF THREAD_LOCKS_PREALLOCATED = 8
22950  * cdef int __pyx_memoryview_thread_locks_used = 0
22951  * cdef PyThread_type_lock[THREAD_LOCKS_PREALLOCATED] __pyx_memoryview_thread_locks = [             # <<<<<<<<<<<<<<
22952  *     PyThread_allocate_lock(),
22953  *     PyThread_allocate_lock(),
22954  */
22955   __pyx_t_3[0] = PyThread_allocate_lock();
22956   __pyx_t_3[1] = PyThread_allocate_lock();
22957   __pyx_t_3[2] = PyThread_allocate_lock();
22958   __pyx_t_3[3] = PyThread_allocate_lock();
22959   __pyx_t_3[4] = PyThread_allocate_lock();
22960   __pyx_t_3[5] = PyThread_allocate_lock();
22961   __pyx_t_3[6] = PyThread_allocate_lock();
22962   __pyx_t_3[7] = PyThread_allocate_lock();
22963   memcpy(&(__pyx_memoryview_thread_locks[0]), __pyx_t_3, sizeof(__pyx_memoryview_thread_locks[0]) * (8));
22964 
22965   /* "View.MemoryView":549
22966  *         info.obj = self
22967  *
22968  *     __pyx_getbuffer = capsule(<void *> &__pyx_memoryview_getbuffer, "getbuffer(obj, view, flags)")             # <<<<<<<<<<<<<<
22969  *
22970  *
22971  */
22972   __pyx_t_1 = __pyx_capsule_create(((void *)(&__pyx_memoryview_getbuffer)), ((char *)"getbuffer(obj, view, flags)")); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 549, __pyx_L1_error)
22973   __Pyx_GOTREF(__pyx_t_1);
22974   if (PyDict_SetItem((PyObject *)__pyx_memoryview_type->tp_dict, __pyx_n_s_pyx_getbuffer, __pyx_t_1) < 0) __PYX_ERR(2, 549, __pyx_L1_error)
22975   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
22976   PyType_Modified(__pyx_memoryview_type);
22977 
22978   /* "View.MemoryView":995
22979  *         return self.from_object
22980  *
22981  *     __pyx_getbuffer = capsule(<void *> &__pyx_memoryview_getbuffer, "getbuffer(obj, view, flags)")             # <<<<<<<<<<<<<<
22982  *
22983  *
22984  */
22985   __pyx_t_1 = __pyx_capsule_create(((void *)(&__pyx_memoryview_getbuffer)), ((char *)"getbuffer(obj, view, flags)")); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 995, __pyx_L1_error)
22986   __Pyx_GOTREF(__pyx_t_1);
22987   if (PyDict_SetItem((PyObject *)__pyx_memoryviewslice_type->tp_dict, __pyx_n_s_pyx_getbuffer, __pyx_t_1) < 0) __PYX_ERR(2, 995, __pyx_L1_error)
22988   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
22989   PyType_Modified(__pyx_memoryviewslice_type);
22990 
22991   /* "(tree fragment)":1
22992  * def __pyx_unpickle_Enum(__pyx_type, long __pyx_checksum, __pyx_state):             # <<<<<<<<<<<<<<
22993  *     cdef object __pyx_PickleError
22994  *     cdef object __pyx_result
22995  */
22996   __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(2, 1, __pyx_L1_error)
22997   __Pyx_GOTREF(__pyx_t_1);
22998   if (PyDict_SetItem(__pyx_d, __pyx_n_s_pyx_unpickle_Enum, __pyx_t_1) < 0) __PYX_ERR(2, 1, __pyx_L1_error)
22999   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
23000 
23001   /* "(tree fragment)":11
23002  *         __pyx_unpickle_Enum__set_state(<Enum> __pyx_result, __pyx_state)
23003  *     return __pyx_result
23004  * cdef __pyx_unpickle_Enum__set_state(Enum __pyx_result, tuple __pyx_state):             # <<<<<<<<<<<<<<
23005  *     __pyx_result.name = __pyx_state[0]
23006  *     if len(__pyx_state) > 1 and hasattr(__pyx_result, '__dict__'):
23007  */
23008 
23009   /*--- Wrapped vars code ---*/
23010 
23011   goto __pyx_L0;
23012   __pyx_L1_error:;
23013   __Pyx_XDECREF(__pyx_t_1);
23014   __Pyx_XDECREF(__pyx_t_2);
23015   if (__pyx_m) {
23016     if (__pyx_d) {
23017       __Pyx_AddTraceback("init qutip.cy.ptrace", __pyx_clineno, __pyx_lineno, __pyx_filename);
23018     }
23019     Py_CLEAR(__pyx_m);
23020   } else if (!PyErr_Occurred()) {
23021     PyErr_SetString(PyExc_ImportError, "init qutip.cy.ptrace");
23022   }
23023   __pyx_L0:;
23024   __Pyx_RefNannyFinishContext();
23025   #if CYTHON_PEP489_MULTI_PHASE_INIT
23026   return (__pyx_m != NULL) ? 0 : -1;
23027   #elif PY_MAJOR_VERSION >= 3
23028   return __pyx_m;
23029   #else
23030   return;
23031   #endif
23032 }
23033 
23034 /* --- Runtime support code --- */
23035 /* Refnanny */
23036 #if CYTHON_REFNANNY
__Pyx_RefNannyImportAPI(const char * modname)23037 static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname) {
23038     PyObject *m = NULL, *p = NULL;
23039     void *r = NULL;
23040     m = PyImport_ImportModule(modname);
23041     if (!m) goto end;
23042     p = PyObject_GetAttrString(m, "RefNannyAPI");
23043     if (!p) goto end;
23044     r = PyLong_AsVoidPtr(p);
23045 end:
23046     Py_XDECREF(p);
23047     Py_XDECREF(m);
23048     return (__Pyx_RefNannyAPIStruct *)r;
23049 }
23050 #endif
23051 
23052 /* PyObjectGetAttrStr */
23053 #if CYTHON_USE_TYPE_SLOTS
__Pyx_PyObject_GetAttrStr(PyObject * obj,PyObject * attr_name)23054 static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStr(PyObject* obj, PyObject* attr_name) {
23055     PyTypeObject* tp = Py_TYPE(obj);
23056     if (likely(tp->tp_getattro))
23057         return tp->tp_getattro(obj, attr_name);
23058 #if PY_MAJOR_VERSION < 3
23059     if (likely(tp->tp_getattr))
23060         return tp->tp_getattr(obj, PyString_AS_STRING(attr_name));
23061 #endif
23062     return PyObject_GetAttr(obj, attr_name);
23063 }
23064 #endif
23065 
23066 /* GetBuiltinName */
__Pyx_GetBuiltinName(PyObject * name)23067 static PyObject *__Pyx_GetBuiltinName(PyObject *name) {
23068     PyObject* result = __Pyx_PyObject_GetAttrStr(__pyx_b, name);
23069     if (unlikely(!result)) {
23070         PyErr_Format(PyExc_NameError,
23071 #if PY_MAJOR_VERSION >= 3
23072             "name '%U' is not defined", name);
23073 #else
23074             "name '%.200s' is not defined", PyString_AS_STRING(name));
23075 #endif
23076     }
23077     return result;
23078 }
23079 
23080 /* RaiseArgTupleInvalid */
__Pyx_RaiseArgtupleInvalid(const char * func_name,int exact,Py_ssize_t num_min,Py_ssize_t num_max,Py_ssize_t num_found)23081 static void __Pyx_RaiseArgtupleInvalid(
23082     const char* func_name,
23083     int exact,
23084     Py_ssize_t num_min,
23085     Py_ssize_t num_max,
23086     Py_ssize_t num_found)
23087 {
23088     Py_ssize_t num_expected;
23089     const char *more_or_less;
23090     if (num_found < num_min) {
23091         num_expected = num_min;
23092         more_or_less = "at least";
23093     } else {
23094         num_expected = num_max;
23095         more_or_less = "at most";
23096     }
23097     if (exact) {
23098         more_or_less = "exactly";
23099     }
23100     PyErr_Format(PyExc_TypeError,
23101                  "%.200s() takes %.8s %" CYTHON_FORMAT_SSIZE_T "d positional argument%.1s (%" CYTHON_FORMAT_SSIZE_T "d given)",
23102                  func_name, more_or_less, num_expected,
23103                  (num_expected == 1) ? "" : "s", num_found);
23104 }
23105 
23106 /* RaiseDoubleKeywords */
__Pyx_RaiseDoubleKeywordsError(const char * func_name,PyObject * kw_name)23107 static void __Pyx_RaiseDoubleKeywordsError(
23108     const char* func_name,
23109     PyObject* kw_name)
23110 {
23111     PyErr_Format(PyExc_TypeError,
23112         #if PY_MAJOR_VERSION >= 3
23113         "%s() got multiple values for keyword argument '%U'", func_name, kw_name);
23114         #else
23115         "%s() got multiple values for keyword argument '%s'", func_name,
23116         PyString_AsString(kw_name));
23117         #endif
23118 }
23119 
23120 /* ParseKeywords */
__Pyx_ParseOptionalKeywords(PyObject * kwds,PyObject ** argnames[],PyObject * kwds2,PyObject * values[],Py_ssize_t num_pos_args,const char * function_name)23121 static int __Pyx_ParseOptionalKeywords(
23122     PyObject *kwds,
23123     PyObject **argnames[],
23124     PyObject *kwds2,
23125     PyObject *values[],
23126     Py_ssize_t num_pos_args,
23127     const char* function_name)
23128 {
23129     PyObject *key = 0, *value = 0;
23130     Py_ssize_t pos = 0;
23131     PyObject*** name;
23132     PyObject*** first_kw_arg = argnames + num_pos_args;
23133     while (PyDict_Next(kwds, &pos, &key, &value)) {
23134         name = first_kw_arg;
23135         while (*name && (**name != key)) name++;
23136         if (*name) {
23137             values[name-argnames] = value;
23138             continue;
23139         }
23140         name = first_kw_arg;
23141         #if PY_MAJOR_VERSION < 3
23142         if (likely(PyString_Check(key))) {
23143             while (*name) {
23144                 if ((CYTHON_COMPILING_IN_PYPY || PyString_GET_SIZE(**name) == PyString_GET_SIZE(key))
23145                         && _PyString_Eq(**name, key)) {
23146                     values[name-argnames] = value;
23147                     break;
23148                 }
23149                 name++;
23150             }
23151             if (*name) continue;
23152             else {
23153                 PyObject*** argname = argnames;
23154                 while (argname != first_kw_arg) {
23155                     if ((**argname == key) || (
23156                             (CYTHON_COMPILING_IN_PYPY || PyString_GET_SIZE(**argname) == PyString_GET_SIZE(key))
23157                              && _PyString_Eq(**argname, key))) {
23158                         goto arg_passed_twice;
23159                     }
23160                     argname++;
23161                 }
23162             }
23163         } else
23164         #endif
23165         if (likely(PyUnicode_Check(key))) {
23166             while (*name) {
23167                 int cmp = (**name == key) ? 0 :
23168                 #if !CYTHON_COMPILING_IN_PYPY && PY_MAJOR_VERSION >= 3
23169                     (__Pyx_PyUnicode_GET_LENGTH(**name) != __Pyx_PyUnicode_GET_LENGTH(key)) ? 1 :
23170                 #endif
23171                     PyUnicode_Compare(**name, key);
23172                 if (cmp < 0 && unlikely(PyErr_Occurred())) goto bad;
23173                 if (cmp == 0) {
23174                     values[name-argnames] = value;
23175                     break;
23176                 }
23177                 name++;
23178             }
23179             if (*name) continue;
23180             else {
23181                 PyObject*** argname = argnames;
23182                 while (argname != first_kw_arg) {
23183                     int cmp = (**argname == key) ? 0 :
23184                     #if !CYTHON_COMPILING_IN_PYPY && PY_MAJOR_VERSION >= 3
23185                         (__Pyx_PyUnicode_GET_LENGTH(**argname) != __Pyx_PyUnicode_GET_LENGTH(key)) ? 1 :
23186                     #endif
23187                         PyUnicode_Compare(**argname, key);
23188                     if (cmp < 0 && unlikely(PyErr_Occurred())) goto bad;
23189                     if (cmp == 0) goto arg_passed_twice;
23190                     argname++;
23191                 }
23192             }
23193         } else
23194             goto invalid_keyword_type;
23195         if (kwds2) {
23196             if (unlikely(PyDict_SetItem(kwds2, key, value))) goto bad;
23197         } else {
23198             goto invalid_keyword;
23199         }
23200     }
23201     return 0;
23202 arg_passed_twice:
23203     __Pyx_RaiseDoubleKeywordsError(function_name, key);
23204     goto bad;
23205 invalid_keyword_type:
23206     PyErr_Format(PyExc_TypeError,
23207         "%.200s() keywords must be strings", function_name);
23208     goto bad;
23209 invalid_keyword:
23210     PyErr_Format(PyExc_TypeError,
23211     #if PY_MAJOR_VERSION < 3
23212         "%.200s() got an unexpected keyword argument '%.200s'",
23213         function_name, PyString_AsString(key));
23214     #else
23215         "%s() got an unexpected keyword argument '%U'",
23216         function_name, key);
23217     #endif
23218 bad:
23219     return -1;
23220 }
23221 
23222 /* PyIntCompare */
__Pyx_PyInt_EqObjC(PyObject * op1,PyObject * op2,CYTHON_UNUSED long intval,CYTHON_UNUSED long inplace)23223 static CYTHON_INLINE PyObject* __Pyx_PyInt_EqObjC(PyObject *op1, PyObject *op2, CYTHON_UNUSED long intval, CYTHON_UNUSED long inplace) {
23224     if (op1 == op2) {
23225         Py_RETURN_TRUE;
23226     }
23227     #if PY_MAJOR_VERSION < 3
23228     if (likely(PyInt_CheckExact(op1))) {
23229         const long b = intval;
23230         long a = PyInt_AS_LONG(op1);
23231         if (a == b) Py_RETURN_TRUE; else Py_RETURN_FALSE;
23232     }
23233     #endif
23234     #if CYTHON_USE_PYLONG_INTERNALS
23235     if (likely(PyLong_CheckExact(op1))) {
23236         int unequal;
23237         unsigned long uintval;
23238         Py_ssize_t size = Py_SIZE(op1);
23239         const digit* digits = ((PyLongObject*)op1)->ob_digit;
23240         if (intval == 0) {
23241             if (size == 0) Py_RETURN_TRUE; else Py_RETURN_FALSE;
23242         } else if (intval < 0) {
23243             if (size >= 0)
23244                 Py_RETURN_FALSE;
23245             intval = -intval;
23246             size = -size;
23247         } else {
23248             if (size <= 0)
23249                 Py_RETURN_FALSE;
23250         }
23251         uintval = (unsigned long) intval;
23252 #if PyLong_SHIFT * 4 < SIZEOF_LONG*8
23253         if (uintval >> (PyLong_SHIFT * 4)) {
23254             unequal = (size != 5) || (digits[0] != (uintval & (unsigned long) PyLong_MASK))
23255                  | (digits[1] != ((uintval >> (1 * PyLong_SHIFT)) & (unsigned long) PyLong_MASK)) | (digits[2] != ((uintval >> (2 * PyLong_SHIFT)) & (unsigned long) PyLong_MASK)) | (digits[3] != ((uintval >> (3 * PyLong_SHIFT)) & (unsigned long) PyLong_MASK)) | (digits[4] != ((uintval >> (4 * PyLong_SHIFT)) & (unsigned long) PyLong_MASK));
23256         } else
23257 #endif
23258 #if PyLong_SHIFT * 3 < SIZEOF_LONG*8
23259         if (uintval >> (PyLong_SHIFT * 3)) {
23260             unequal = (size != 4) || (digits[0] != (uintval & (unsigned long) PyLong_MASK))
23261                  | (digits[1] != ((uintval >> (1 * PyLong_SHIFT)) & (unsigned long) PyLong_MASK)) | (digits[2] != ((uintval >> (2 * PyLong_SHIFT)) & (unsigned long) PyLong_MASK)) | (digits[3] != ((uintval >> (3 * PyLong_SHIFT)) & (unsigned long) PyLong_MASK));
23262         } else
23263 #endif
23264 #if PyLong_SHIFT * 2 < SIZEOF_LONG*8
23265         if (uintval >> (PyLong_SHIFT * 2)) {
23266             unequal = (size != 3) || (digits[0] != (uintval & (unsigned long) PyLong_MASK))
23267                  | (digits[1] != ((uintval >> (1 * PyLong_SHIFT)) & (unsigned long) PyLong_MASK)) | (digits[2] != ((uintval >> (2 * PyLong_SHIFT)) & (unsigned long) PyLong_MASK));
23268         } else
23269 #endif
23270 #if PyLong_SHIFT * 1 < SIZEOF_LONG*8
23271         if (uintval >> (PyLong_SHIFT * 1)) {
23272             unequal = (size != 2) || (digits[0] != (uintval & (unsigned long) PyLong_MASK))
23273                  | (digits[1] != ((uintval >> (1 * PyLong_SHIFT)) & (unsigned long) PyLong_MASK));
23274         } else
23275 #endif
23276             unequal = (size != 1) || (((unsigned long) digits[0]) != (uintval & (unsigned long) PyLong_MASK));
23277         if (unequal == 0) Py_RETURN_TRUE; else Py_RETURN_FALSE;
23278     }
23279     #endif
23280     if (PyFloat_CheckExact(op1)) {
23281         const long b = intval;
23282         double a = PyFloat_AS_DOUBLE(op1);
23283         if ((double)a == (double)b) Py_RETURN_TRUE; else Py_RETURN_FALSE;
23284     }
23285     return (
23286         PyObject_RichCompare(op1, op2, Py_EQ));
23287 }
23288 
23289 /* PyDictVersioning */
23290 #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_TYPE_SLOTS
__Pyx_get_tp_dict_version(PyObject * obj)23291 static CYTHON_INLINE PY_UINT64_T __Pyx_get_tp_dict_version(PyObject *obj) {
23292     PyObject *dict = Py_TYPE(obj)->tp_dict;
23293     return likely(dict) ? __PYX_GET_DICT_VERSION(dict) : 0;
23294 }
__Pyx_get_object_dict_version(PyObject * obj)23295 static CYTHON_INLINE PY_UINT64_T __Pyx_get_object_dict_version(PyObject *obj) {
23296     PyObject **dictptr = NULL;
23297     Py_ssize_t offset = Py_TYPE(obj)->tp_dictoffset;
23298     if (offset) {
23299 #if CYTHON_COMPILING_IN_CPYTHON
23300         dictptr = (likely(offset > 0)) ? (PyObject **) ((char *)obj + offset) : _PyObject_GetDictPtr(obj);
23301 #else
23302         dictptr = _PyObject_GetDictPtr(obj);
23303 #endif
23304     }
23305     return (dictptr && *dictptr) ? __PYX_GET_DICT_VERSION(*dictptr) : 0;
23306 }
__Pyx_object_dict_version_matches(PyObject * obj,PY_UINT64_T tp_dict_version,PY_UINT64_T obj_dict_version)23307 static CYTHON_INLINE int __Pyx_object_dict_version_matches(PyObject* obj, PY_UINT64_T tp_dict_version, PY_UINT64_T obj_dict_version) {
23308     PyObject *dict = Py_TYPE(obj)->tp_dict;
23309     if (unlikely(!dict) || unlikely(tp_dict_version != __PYX_GET_DICT_VERSION(dict)))
23310         return 0;
23311     return obj_dict_version == __Pyx_get_object_dict_version(obj);
23312 }
23313 #endif
23314 
23315 /* GetModuleGlobalName */
23316 #if CYTHON_USE_DICT_VERSIONS
__Pyx__GetModuleGlobalName(PyObject * name,PY_UINT64_T * dict_version,PyObject ** dict_cached_value)23317 static PyObject *__Pyx__GetModuleGlobalName(PyObject *name, PY_UINT64_T *dict_version, PyObject **dict_cached_value)
23318 #else
23319 static CYTHON_INLINE PyObject *__Pyx__GetModuleGlobalName(PyObject *name)
23320 #endif
23321 {
23322     PyObject *result;
23323 #if !CYTHON_AVOID_BORROWED_REFS
23324 #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030500A1
23325     result = _PyDict_GetItem_KnownHash(__pyx_d, name, ((PyASCIIObject *) name)->hash);
23326     __PYX_UPDATE_DICT_CACHE(__pyx_d, result, *dict_cached_value, *dict_version)
23327     if (likely(result)) {
23328         return __Pyx_NewRef(result);
23329     } else if (unlikely(PyErr_Occurred())) {
23330         return NULL;
23331     }
23332 #else
23333     result = PyDict_GetItem(__pyx_d, name);
23334     __PYX_UPDATE_DICT_CACHE(__pyx_d, result, *dict_cached_value, *dict_version)
23335     if (likely(result)) {
23336         return __Pyx_NewRef(result);
23337     }
23338 #endif
23339 #else
23340     result = PyObject_GetItem(__pyx_d, name);
23341     __PYX_UPDATE_DICT_CACHE(__pyx_d, result, *dict_cached_value, *dict_version)
23342     if (likely(result)) {
23343         return __Pyx_NewRef(result);
23344     }
23345     PyErr_Clear();
23346 #endif
23347     return __Pyx_GetBuiltinName(name);
23348 }
23349 
23350 /* GetItemInt */
__Pyx_GetItemInt_Generic(PyObject * o,PyObject * j)23351 static PyObject *__Pyx_GetItemInt_Generic(PyObject *o, PyObject* j) {
23352     PyObject *r;
23353     if (!j) return NULL;
23354     r = PyObject_GetItem(o, j);
23355     Py_DECREF(j);
23356     return r;
23357 }
__Pyx_GetItemInt_List_Fast(PyObject * o,Py_ssize_t i,CYTHON_NCP_UNUSED int wraparound,CYTHON_NCP_UNUSED int boundscheck)23358 static CYTHON_INLINE PyObject *__Pyx_GetItemInt_List_Fast(PyObject *o, Py_ssize_t i,
23359                                                               CYTHON_NCP_UNUSED int wraparound,
23360                                                               CYTHON_NCP_UNUSED int boundscheck) {
23361 #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
23362     Py_ssize_t wrapped_i = i;
23363     if (wraparound & unlikely(i < 0)) {
23364         wrapped_i += PyList_GET_SIZE(o);
23365     }
23366     if ((!boundscheck) || likely(__Pyx_is_valid_index(wrapped_i, PyList_GET_SIZE(o)))) {
23367         PyObject *r = PyList_GET_ITEM(o, wrapped_i);
23368         Py_INCREF(r);
23369         return r;
23370     }
23371     return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i));
23372 #else
23373     return PySequence_GetItem(o, i);
23374 #endif
23375 }
__Pyx_GetItemInt_Tuple_Fast(PyObject * o,Py_ssize_t i,CYTHON_NCP_UNUSED int wraparound,CYTHON_NCP_UNUSED int boundscheck)23376 static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Tuple_Fast(PyObject *o, Py_ssize_t i,
23377                                                               CYTHON_NCP_UNUSED int wraparound,
23378                                                               CYTHON_NCP_UNUSED int boundscheck) {
23379 #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
23380     Py_ssize_t wrapped_i = i;
23381     if (wraparound & unlikely(i < 0)) {
23382         wrapped_i += PyTuple_GET_SIZE(o);
23383     }
23384     if ((!boundscheck) || likely(__Pyx_is_valid_index(wrapped_i, PyTuple_GET_SIZE(o)))) {
23385         PyObject *r = PyTuple_GET_ITEM(o, wrapped_i);
23386         Py_INCREF(r);
23387         return r;
23388     }
23389     return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i));
23390 #else
23391     return PySequence_GetItem(o, i);
23392 #endif
23393 }
__Pyx_GetItemInt_Fast(PyObject * o,Py_ssize_t i,int is_list,CYTHON_NCP_UNUSED int wraparound,CYTHON_NCP_UNUSED int boundscheck)23394 static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Fast(PyObject *o, Py_ssize_t i, int is_list,
23395                                                      CYTHON_NCP_UNUSED int wraparound,
23396                                                      CYTHON_NCP_UNUSED int boundscheck) {
23397 #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS && CYTHON_USE_TYPE_SLOTS
23398     if (is_list || PyList_CheckExact(o)) {
23399         Py_ssize_t n = ((!wraparound) | likely(i >= 0)) ? i : i + PyList_GET_SIZE(o);
23400         if ((!boundscheck) || (likely(__Pyx_is_valid_index(n, PyList_GET_SIZE(o))))) {
23401             PyObject *r = PyList_GET_ITEM(o, n);
23402             Py_INCREF(r);
23403             return r;
23404         }
23405     }
23406     else if (PyTuple_CheckExact(o)) {
23407         Py_ssize_t n = ((!wraparound) | likely(i >= 0)) ? i : i + PyTuple_GET_SIZE(o);
23408         if ((!boundscheck) || likely(__Pyx_is_valid_index(n, PyTuple_GET_SIZE(o)))) {
23409             PyObject *r = PyTuple_GET_ITEM(o, n);
23410             Py_INCREF(r);
23411             return r;
23412         }
23413     } else {
23414         PySequenceMethods *m = Py_TYPE(o)->tp_as_sequence;
23415         if (likely(m && m->sq_item)) {
23416             if (wraparound && unlikely(i < 0) && likely(m->sq_length)) {
23417                 Py_ssize_t l = m->sq_length(o);
23418                 if (likely(l >= 0)) {
23419                     i += l;
23420                 } else {
23421                     if (!PyErr_ExceptionMatches(PyExc_OverflowError))
23422                         return NULL;
23423                     PyErr_Clear();
23424                 }
23425             }
23426             return m->sq_item(o, i);
23427         }
23428     }
23429 #else
23430     if (is_list || PySequence_Check(o)) {
23431         return PySequence_GetItem(o, i);
23432     }
23433 #endif
23434     return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i));
23435 }
23436 
23437 /* PyCFunctionFastCall */
23438 #if CYTHON_FAST_PYCCALL
__Pyx_PyCFunction_FastCall(PyObject * func_obj,PyObject ** args,Py_ssize_t nargs)23439 static CYTHON_INLINE PyObject * __Pyx_PyCFunction_FastCall(PyObject *func_obj, PyObject **args, Py_ssize_t nargs) {
23440     PyCFunctionObject *func = (PyCFunctionObject*)func_obj;
23441     PyCFunction meth = PyCFunction_GET_FUNCTION(func);
23442     PyObject *self = PyCFunction_GET_SELF(func);
23443     int flags = PyCFunction_GET_FLAGS(func);
23444     assert(PyCFunction_Check(func));
23445     assert(METH_FASTCALL == (flags & ~(METH_CLASS | METH_STATIC | METH_COEXIST | METH_KEYWORDS | METH_STACKLESS)));
23446     assert(nargs >= 0);
23447     assert(nargs == 0 || args != NULL);
23448     /* _PyCFunction_FastCallDict() must not be called with an exception set,
23449        because it may clear it (directly or indirectly) and so the
23450        caller loses its exception */
23451     assert(!PyErr_Occurred());
23452     if ((PY_VERSION_HEX < 0x030700A0) || unlikely(flags & METH_KEYWORDS)) {
23453         return (*((__Pyx_PyCFunctionFastWithKeywords)(void*)meth)) (self, args, nargs, NULL);
23454     } else {
23455         return (*((__Pyx_PyCFunctionFast)(void*)meth)) (self, args, nargs);
23456     }
23457 }
23458 #endif
23459 
23460 /* PyFunctionFastCall */
23461 #if CYTHON_FAST_PYCALL
__Pyx_PyFunction_FastCallNoKw(PyCodeObject * co,PyObject ** args,Py_ssize_t na,PyObject * globals)23462 static PyObject* __Pyx_PyFunction_FastCallNoKw(PyCodeObject *co, PyObject **args, Py_ssize_t na,
23463                                                PyObject *globals) {
23464     PyFrameObject *f;
23465     PyThreadState *tstate = __Pyx_PyThreadState_Current;
23466     PyObject **fastlocals;
23467     Py_ssize_t i;
23468     PyObject *result;
23469     assert(globals != NULL);
23470     /* XXX Perhaps we should create a specialized
23471        PyFrame_New() that doesn't take locals, but does
23472        take builtins without sanity checking them.
23473        */
23474     assert(tstate != NULL);
23475     f = PyFrame_New(tstate, co, globals, NULL);
23476     if (f == NULL) {
23477         return NULL;
23478     }
23479     fastlocals = __Pyx_PyFrame_GetLocalsplus(f);
23480     for (i = 0; i < na; i++) {
23481         Py_INCREF(*args);
23482         fastlocals[i] = *args++;
23483     }
23484     result = PyEval_EvalFrameEx(f,0);
23485     ++tstate->recursion_depth;
23486     Py_DECREF(f);
23487     --tstate->recursion_depth;
23488     return result;
23489 }
23490 #if 1 || PY_VERSION_HEX < 0x030600B1
__Pyx_PyFunction_FastCallDict(PyObject * func,PyObject ** args,Py_ssize_t nargs,PyObject * kwargs)23491 static PyObject *__Pyx_PyFunction_FastCallDict(PyObject *func, PyObject **args, Py_ssize_t nargs, PyObject *kwargs) {
23492     PyCodeObject *co = (PyCodeObject *)PyFunction_GET_CODE(func);
23493     PyObject *globals = PyFunction_GET_GLOBALS(func);
23494     PyObject *argdefs = PyFunction_GET_DEFAULTS(func);
23495     PyObject *closure;
23496 #if PY_MAJOR_VERSION >= 3
23497     PyObject *kwdefs;
23498 #endif
23499     PyObject *kwtuple, **k;
23500     PyObject **d;
23501     Py_ssize_t nd;
23502     Py_ssize_t nk;
23503     PyObject *result;
23504     assert(kwargs == NULL || PyDict_Check(kwargs));
23505     nk = kwargs ? PyDict_Size(kwargs) : 0;
23506     if (Py_EnterRecursiveCall((char*)" while calling a Python object")) {
23507         return NULL;
23508     }
23509     if (
23510 #if PY_MAJOR_VERSION >= 3
23511             co->co_kwonlyargcount == 0 &&
23512 #endif
23513             likely(kwargs == NULL || nk == 0) &&
23514             co->co_flags == (CO_OPTIMIZED | CO_NEWLOCALS | CO_NOFREE)) {
23515         if (argdefs == NULL && co->co_argcount == nargs) {
23516             result = __Pyx_PyFunction_FastCallNoKw(co, args, nargs, globals);
23517             goto done;
23518         }
23519         else if (nargs == 0 && argdefs != NULL
23520                  && co->co_argcount == Py_SIZE(argdefs)) {
23521             /* function called with no arguments, but all parameters have
23522                a default value: use default values as arguments .*/
23523             args = &PyTuple_GET_ITEM(argdefs, 0);
23524             result =__Pyx_PyFunction_FastCallNoKw(co, args, Py_SIZE(argdefs), globals);
23525             goto done;
23526         }
23527     }
23528     if (kwargs != NULL) {
23529         Py_ssize_t pos, i;
23530         kwtuple = PyTuple_New(2 * nk);
23531         if (kwtuple == NULL) {
23532             result = NULL;
23533             goto done;
23534         }
23535         k = &PyTuple_GET_ITEM(kwtuple, 0);
23536         pos = i = 0;
23537         while (PyDict_Next(kwargs, &pos, &k[i], &k[i+1])) {
23538             Py_INCREF(k[i]);
23539             Py_INCREF(k[i+1]);
23540             i += 2;
23541         }
23542         nk = i / 2;
23543     }
23544     else {
23545         kwtuple = NULL;
23546         k = NULL;
23547     }
23548     closure = PyFunction_GET_CLOSURE(func);
23549 #if PY_MAJOR_VERSION >= 3
23550     kwdefs = PyFunction_GET_KW_DEFAULTS(func);
23551 #endif
23552     if (argdefs != NULL) {
23553         d = &PyTuple_GET_ITEM(argdefs, 0);
23554         nd = Py_SIZE(argdefs);
23555     }
23556     else {
23557         d = NULL;
23558         nd = 0;
23559     }
23560 #if PY_MAJOR_VERSION >= 3
23561     result = PyEval_EvalCodeEx((PyObject*)co, globals, (PyObject *)NULL,
23562                                args, (int)nargs,
23563                                k, (int)nk,
23564                                d, (int)nd, kwdefs, closure);
23565 #else
23566     result = PyEval_EvalCodeEx(co, globals, (PyObject *)NULL,
23567                                args, (int)nargs,
23568                                k, (int)nk,
23569                                d, (int)nd, closure);
23570 #endif
23571     Py_XDECREF(kwtuple);
23572 done:
23573     Py_LeaveRecursiveCall();
23574     return result;
23575 }
23576 #endif
23577 #endif
23578 
23579 /* PyObjectCall */
23580 #if CYTHON_COMPILING_IN_CPYTHON
__Pyx_PyObject_Call(PyObject * func,PyObject * arg,PyObject * kw)23581 static CYTHON_INLINE PyObject* __Pyx_PyObject_Call(PyObject *func, PyObject *arg, PyObject *kw) {
23582     PyObject *result;
23583     ternaryfunc call = func->ob_type->tp_call;
23584     if (unlikely(!call))
23585         return PyObject_Call(func, arg, kw);
23586     if (unlikely(Py_EnterRecursiveCall((char*)" while calling a Python object")))
23587         return NULL;
23588     result = (*call)(func, arg, kw);
23589     Py_LeaveRecursiveCall();
23590     if (unlikely(!result) && unlikely(!PyErr_Occurred())) {
23591         PyErr_SetString(
23592             PyExc_SystemError,
23593             "NULL result without error in PyObject_Call");
23594     }
23595     return result;
23596 }
23597 #endif
23598 
23599 /* PyObjectCall2Args */
__Pyx_PyObject_Call2Args(PyObject * function,PyObject * arg1,PyObject * arg2)23600 static CYTHON_UNUSED PyObject* __Pyx_PyObject_Call2Args(PyObject* function, PyObject* arg1, PyObject* arg2) {
23601     PyObject *args, *result = NULL;
23602     #if CYTHON_FAST_PYCALL
23603     if (PyFunction_Check(function)) {
23604         PyObject *args[2] = {arg1, arg2};
23605         return __Pyx_PyFunction_FastCall(function, args, 2);
23606     }
23607     #endif
23608     #if CYTHON_FAST_PYCCALL
23609     if (__Pyx_PyFastCFunction_Check(function)) {
23610         PyObject *args[2] = {arg1, arg2};
23611         return __Pyx_PyCFunction_FastCall(function, args, 2);
23612     }
23613     #endif
23614     args = PyTuple_New(2);
23615     if (unlikely(!args)) goto done;
23616     Py_INCREF(arg1);
23617     PyTuple_SET_ITEM(args, 0, arg1);
23618     Py_INCREF(arg2);
23619     PyTuple_SET_ITEM(args, 1, arg2);
23620     Py_INCREF(function);
23621     result = __Pyx_PyObject_Call(function, args, NULL);
23622     Py_DECREF(args);
23623     Py_DECREF(function);
23624 done:
23625     return result;
23626 }
23627 
23628 /* PyObjectCallMethO */
23629 #if CYTHON_COMPILING_IN_CPYTHON
__Pyx_PyObject_CallMethO(PyObject * func,PyObject * arg)23630 static CYTHON_INLINE PyObject* __Pyx_PyObject_CallMethO(PyObject *func, PyObject *arg) {
23631     PyObject *self, *result;
23632     PyCFunction cfunc;
23633     cfunc = PyCFunction_GET_FUNCTION(func);
23634     self = PyCFunction_GET_SELF(func);
23635     if (unlikely(Py_EnterRecursiveCall((char*)" while calling a Python object")))
23636         return NULL;
23637     result = cfunc(self, arg);
23638     Py_LeaveRecursiveCall();
23639     if (unlikely(!result) && unlikely(!PyErr_Occurred())) {
23640         PyErr_SetString(
23641             PyExc_SystemError,
23642             "NULL result without error in PyObject_Call");
23643     }
23644     return result;
23645 }
23646 #endif
23647 
23648 /* PyObjectCallOneArg */
23649 #if CYTHON_COMPILING_IN_CPYTHON
__Pyx__PyObject_CallOneArg(PyObject * func,PyObject * arg)23650 static PyObject* __Pyx__PyObject_CallOneArg(PyObject *func, PyObject *arg) {
23651     PyObject *result;
23652     PyObject *args = PyTuple_New(1);
23653     if (unlikely(!args)) return NULL;
23654     Py_INCREF(arg);
23655     PyTuple_SET_ITEM(args, 0, arg);
23656     result = __Pyx_PyObject_Call(func, args, NULL);
23657     Py_DECREF(args);
23658     return result;
23659 }
__Pyx_PyObject_CallOneArg(PyObject * func,PyObject * arg)23660 static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg) {
23661 #if CYTHON_FAST_PYCALL
23662     if (PyFunction_Check(func)) {
23663         return __Pyx_PyFunction_FastCall(func, &arg, 1);
23664     }
23665 #endif
23666     if (likely(PyCFunction_Check(func))) {
23667         if (likely(PyCFunction_GET_FLAGS(func) & METH_O)) {
23668             return __Pyx_PyObject_CallMethO(func, arg);
23669 #if CYTHON_FAST_PYCCALL
23670         } else if (__Pyx_PyFastCFunction_Check(func)) {
23671             return __Pyx_PyCFunction_FastCall(func, &arg, 1);
23672 #endif
23673         }
23674     }
23675     return __Pyx__PyObject_CallOneArg(func, arg);
23676 }
23677 #else
__Pyx_PyObject_CallOneArg(PyObject * func,PyObject * arg)23678 static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg) {
23679     PyObject *result;
23680     PyObject *args = PyTuple_Pack(1, arg);
23681     if (unlikely(!args)) return NULL;
23682     result = __Pyx_PyObject_Call(func, args, NULL);
23683     Py_DECREF(args);
23684     return result;
23685 }
23686 #endif
23687 
23688 /* PyObjectCallNoArg */
23689 #if CYTHON_COMPILING_IN_CPYTHON
__Pyx_PyObject_CallNoArg(PyObject * func)23690 static CYTHON_INLINE PyObject* __Pyx_PyObject_CallNoArg(PyObject *func) {
23691 #if CYTHON_FAST_PYCALL
23692     if (PyFunction_Check(func)) {
23693         return __Pyx_PyFunction_FastCall(func, NULL, 0);
23694     }
23695 #endif
23696 #ifdef __Pyx_CyFunction_USED
23697     if (likely(PyCFunction_Check(func) || __Pyx_CyFunction_Check(func)))
23698 #else
23699     if (likely(PyCFunction_Check(func)))
23700 #endif
23701     {
23702         if (likely(PyCFunction_GET_FLAGS(func) & METH_NOARGS)) {
23703             return __Pyx_PyObject_CallMethO(func, NULL);
23704         }
23705     }
23706     return __Pyx_PyObject_Call(func, __pyx_empty_tuple, NULL);
23707 }
23708 #endif
23709 
23710 /* ExtTypeTest */
__Pyx_TypeTest(PyObject * obj,PyTypeObject * type)23711 static CYTHON_INLINE int __Pyx_TypeTest(PyObject *obj, PyTypeObject *type) {
23712     if (unlikely(!type)) {
23713         PyErr_SetString(PyExc_SystemError, "Missing type object");
23714         return 0;
23715     }
23716     if (likely(__Pyx_TypeCheck(obj, type)))
23717         return 1;
23718     PyErr_Format(PyExc_TypeError, "Cannot convert %.200s to %.200s",
23719                  Py_TYPE(obj)->tp_name, type->tp_name);
23720     return 0;
23721 }
23722 
23723 /* IsLittleEndian */
__Pyx_Is_Little_Endian(void)23724 static CYTHON_INLINE int __Pyx_Is_Little_Endian(void)
23725 {
23726   union {
23727     uint32_t u32;
23728     uint8_t u8[4];
23729   } S;
23730   S.u32 = 0x01020304;
23731   return S.u8[0] == 4;
23732 }
23733 
23734 /* BufferFormatCheck */
__Pyx_BufFmt_Init(__Pyx_BufFmt_Context * ctx,__Pyx_BufFmt_StackElem * stack,__Pyx_TypeInfo * type)23735 static void __Pyx_BufFmt_Init(__Pyx_BufFmt_Context* ctx,
23736                               __Pyx_BufFmt_StackElem* stack,
23737                               __Pyx_TypeInfo* type) {
23738   stack[0].field = &ctx->root;
23739   stack[0].parent_offset = 0;
23740   ctx->root.type = type;
23741   ctx->root.name = "buffer dtype";
23742   ctx->root.offset = 0;
23743   ctx->head = stack;
23744   ctx->head->field = &ctx->root;
23745   ctx->fmt_offset = 0;
23746   ctx->head->parent_offset = 0;
23747   ctx->new_packmode = '@';
23748   ctx->enc_packmode = '@';
23749   ctx->new_count = 1;
23750   ctx->enc_count = 0;
23751   ctx->enc_type = 0;
23752   ctx->is_complex = 0;
23753   ctx->is_valid_array = 0;
23754   ctx->struct_alignment = 0;
23755   while (type->typegroup == 'S') {
23756     ++ctx->head;
23757     ctx->head->field = type->fields;
23758     ctx->head->parent_offset = 0;
23759     type = type->fields->type;
23760   }
23761 }
__Pyx_BufFmt_ParseNumber(const char ** ts)23762 static int __Pyx_BufFmt_ParseNumber(const char** ts) {
23763     int count;
23764     const char* t = *ts;
23765     if (*t < '0' || *t > '9') {
23766       return -1;
23767     } else {
23768         count = *t++ - '0';
23769         while (*t >= '0' && *t <= '9') {
23770             count *= 10;
23771             count += *t++ - '0';
23772         }
23773     }
23774     *ts = t;
23775     return count;
23776 }
__Pyx_BufFmt_ExpectNumber(const char ** ts)23777 static int __Pyx_BufFmt_ExpectNumber(const char **ts) {
23778     int number = __Pyx_BufFmt_ParseNumber(ts);
23779     if (number == -1)
23780         PyErr_Format(PyExc_ValueError,\
23781                      "Does not understand character buffer dtype format string ('%c')", **ts);
23782     return number;
23783 }
__Pyx_BufFmt_RaiseUnexpectedChar(char ch)23784 static void __Pyx_BufFmt_RaiseUnexpectedChar(char ch) {
23785   PyErr_Format(PyExc_ValueError,
23786                "Unexpected format string character: '%c'", ch);
23787 }
__Pyx_BufFmt_DescribeTypeChar(char ch,int is_complex)23788 static const char* __Pyx_BufFmt_DescribeTypeChar(char ch, int is_complex) {
23789   switch (ch) {
23790     case '?': return "'bool'";
23791     case 'c': return "'char'";
23792     case 'b': return "'signed char'";
23793     case 'B': return "'unsigned char'";
23794     case 'h': return "'short'";
23795     case 'H': return "'unsigned short'";
23796     case 'i': return "'int'";
23797     case 'I': return "'unsigned int'";
23798     case 'l': return "'long'";
23799     case 'L': return "'unsigned long'";
23800     case 'q': return "'long long'";
23801     case 'Q': return "'unsigned long long'";
23802     case 'f': return (is_complex ? "'complex float'" : "'float'");
23803     case 'd': return (is_complex ? "'complex double'" : "'double'");
23804     case 'g': return (is_complex ? "'complex long double'" : "'long double'");
23805     case 'T': return "a struct";
23806     case 'O': return "Python object";
23807     case 'P': return "a pointer";
23808     case 's': case 'p': return "a string";
23809     case 0: return "end";
23810     default: return "unparseable format string";
23811   }
23812 }
__Pyx_BufFmt_TypeCharToStandardSize(char ch,int is_complex)23813 static size_t __Pyx_BufFmt_TypeCharToStandardSize(char ch, int is_complex) {
23814   switch (ch) {
23815     case '?': case 'c': case 'b': case 'B': case 's': case 'p': return 1;
23816     case 'h': case 'H': return 2;
23817     case 'i': case 'I': case 'l': case 'L': return 4;
23818     case 'q': case 'Q': return 8;
23819     case 'f': return (is_complex ? 8 : 4);
23820     case 'd': return (is_complex ? 16 : 8);
23821     case 'g': {
23822       PyErr_SetString(PyExc_ValueError, "Python does not define a standard format string size for long double ('g')..");
23823       return 0;
23824     }
23825     case 'O': case 'P': return sizeof(void*);
23826     default:
23827       __Pyx_BufFmt_RaiseUnexpectedChar(ch);
23828       return 0;
23829     }
23830 }
__Pyx_BufFmt_TypeCharToNativeSize(char ch,int is_complex)23831 static size_t __Pyx_BufFmt_TypeCharToNativeSize(char ch, int is_complex) {
23832   switch (ch) {
23833     case '?': case 'c': case 'b': case 'B': case 's': case 'p': return 1;
23834     case 'h': case 'H': return sizeof(short);
23835     case 'i': case 'I': return sizeof(int);
23836     case 'l': case 'L': return sizeof(long);
23837     #ifdef HAVE_LONG_LONG
23838     case 'q': case 'Q': return sizeof(PY_LONG_LONG);
23839     #endif
23840     case 'f': return sizeof(float) * (is_complex ? 2 : 1);
23841     case 'd': return sizeof(double) * (is_complex ? 2 : 1);
23842     case 'g': return sizeof(long double) * (is_complex ? 2 : 1);
23843     case 'O': case 'P': return sizeof(void*);
23844     default: {
23845       __Pyx_BufFmt_RaiseUnexpectedChar(ch);
23846       return 0;
23847     }
23848   }
23849 }
23850 typedef struct { char c; short x; } __Pyx_st_short;
23851 typedef struct { char c; int x; } __Pyx_st_int;
23852 typedef struct { char c; long x; } __Pyx_st_long;
23853 typedef struct { char c; float x; } __Pyx_st_float;
23854 typedef struct { char c; double x; } __Pyx_st_double;
23855 typedef struct { char c; long double x; } __Pyx_st_longdouble;
23856 typedef struct { char c; void *x; } __Pyx_st_void_p;
23857 #ifdef HAVE_LONG_LONG
23858 typedef struct { char c; PY_LONG_LONG x; } __Pyx_st_longlong;
23859 #endif
__Pyx_BufFmt_TypeCharToAlignment(char ch,CYTHON_UNUSED int is_complex)23860 static size_t __Pyx_BufFmt_TypeCharToAlignment(char ch, CYTHON_UNUSED int is_complex) {
23861   switch (ch) {
23862     case '?': case 'c': case 'b': case 'B': case 's': case 'p': return 1;
23863     case 'h': case 'H': return sizeof(__Pyx_st_short) - sizeof(short);
23864     case 'i': case 'I': return sizeof(__Pyx_st_int) - sizeof(int);
23865     case 'l': case 'L': return sizeof(__Pyx_st_long) - sizeof(long);
23866 #ifdef HAVE_LONG_LONG
23867     case 'q': case 'Q': return sizeof(__Pyx_st_longlong) - sizeof(PY_LONG_LONG);
23868 #endif
23869     case 'f': return sizeof(__Pyx_st_float) - sizeof(float);
23870     case 'd': return sizeof(__Pyx_st_double) - sizeof(double);
23871     case 'g': return sizeof(__Pyx_st_longdouble) - sizeof(long double);
23872     case 'P': case 'O': return sizeof(__Pyx_st_void_p) - sizeof(void*);
23873     default:
23874       __Pyx_BufFmt_RaiseUnexpectedChar(ch);
23875       return 0;
23876     }
23877 }
23878 /* These are for computing the padding at the end of the struct to align
23879    on the first member of the struct. This will probably the same as above,
23880    but we don't have any guarantees.
23881  */
23882 typedef struct { short x; char c; } __Pyx_pad_short;
23883 typedef struct { int x; char c; } __Pyx_pad_int;
23884 typedef struct { long x; char c; } __Pyx_pad_long;
23885 typedef struct { float x; char c; } __Pyx_pad_float;
23886 typedef struct { double x; char c; } __Pyx_pad_double;
23887 typedef struct { long double x; char c; } __Pyx_pad_longdouble;
23888 typedef struct { void *x; char c; } __Pyx_pad_void_p;
23889 #ifdef HAVE_LONG_LONG
23890 typedef struct { PY_LONG_LONG x; char c; } __Pyx_pad_longlong;
23891 #endif
__Pyx_BufFmt_TypeCharToPadding(char ch,CYTHON_UNUSED int is_complex)23892 static size_t __Pyx_BufFmt_TypeCharToPadding(char ch, CYTHON_UNUSED int is_complex) {
23893   switch (ch) {
23894     case '?': case 'c': case 'b': case 'B': case 's': case 'p': return 1;
23895     case 'h': case 'H': return sizeof(__Pyx_pad_short) - sizeof(short);
23896     case 'i': case 'I': return sizeof(__Pyx_pad_int) - sizeof(int);
23897     case 'l': case 'L': return sizeof(__Pyx_pad_long) - sizeof(long);
23898 #ifdef HAVE_LONG_LONG
23899     case 'q': case 'Q': return sizeof(__Pyx_pad_longlong) - sizeof(PY_LONG_LONG);
23900 #endif
23901     case 'f': return sizeof(__Pyx_pad_float) - sizeof(float);
23902     case 'd': return sizeof(__Pyx_pad_double) - sizeof(double);
23903     case 'g': return sizeof(__Pyx_pad_longdouble) - sizeof(long double);
23904     case 'P': case 'O': return sizeof(__Pyx_pad_void_p) - sizeof(void*);
23905     default:
23906       __Pyx_BufFmt_RaiseUnexpectedChar(ch);
23907       return 0;
23908     }
23909 }
__Pyx_BufFmt_TypeCharToGroup(char ch,int is_complex)23910 static char __Pyx_BufFmt_TypeCharToGroup(char ch, int is_complex) {
23911   switch (ch) {
23912     case 'c':
23913         return 'H';
23914     case 'b': case 'h': case 'i':
23915     case 'l': case 'q': case 's': case 'p':
23916         return 'I';
23917     case '?': case 'B': case 'H': case 'I': case 'L': case 'Q':
23918         return 'U';
23919     case 'f': case 'd': case 'g':
23920         return (is_complex ? 'C' : 'R');
23921     case 'O':
23922         return 'O';
23923     case 'P':
23924         return 'P';
23925     default: {
23926       __Pyx_BufFmt_RaiseUnexpectedChar(ch);
23927       return 0;
23928     }
23929   }
23930 }
__Pyx_BufFmt_RaiseExpected(__Pyx_BufFmt_Context * ctx)23931 static void __Pyx_BufFmt_RaiseExpected(__Pyx_BufFmt_Context* ctx) {
23932   if (ctx->head == NULL || ctx->head->field == &ctx->root) {
23933     const char* expected;
23934     const char* quote;
23935     if (ctx->head == NULL) {
23936       expected = "end";
23937       quote = "";
23938     } else {
23939       expected = ctx->head->field->type->name;
23940       quote = "'";
23941     }
23942     PyErr_Format(PyExc_ValueError,
23943                  "Buffer dtype mismatch, expected %s%s%s but got %s",
23944                  quote, expected, quote,
23945                  __Pyx_BufFmt_DescribeTypeChar(ctx->enc_type, ctx->is_complex));
23946   } else {
23947     __Pyx_StructField* field = ctx->head->field;
23948     __Pyx_StructField* parent = (ctx->head - 1)->field;
23949     PyErr_Format(PyExc_ValueError,
23950                  "Buffer dtype mismatch, expected '%s' but got %s in '%s.%s'",
23951                  field->type->name, __Pyx_BufFmt_DescribeTypeChar(ctx->enc_type, ctx->is_complex),
23952                  parent->type->name, field->name);
23953   }
23954 }
__Pyx_BufFmt_ProcessTypeChunk(__Pyx_BufFmt_Context * ctx)23955 static int __Pyx_BufFmt_ProcessTypeChunk(__Pyx_BufFmt_Context* ctx) {
23956   char group;
23957   size_t size, offset, arraysize = 1;
23958   if (ctx->enc_type == 0) return 0;
23959   if (ctx->head->field->type->arraysize[0]) {
23960     int i, ndim = 0;
23961     if (ctx->enc_type == 's' || ctx->enc_type == 'p') {
23962         ctx->is_valid_array = ctx->head->field->type->ndim == 1;
23963         ndim = 1;
23964         if (ctx->enc_count != ctx->head->field->type->arraysize[0]) {
23965             PyErr_Format(PyExc_ValueError,
23966                          "Expected a dimension of size %zu, got %zu",
23967                          ctx->head->field->type->arraysize[0], ctx->enc_count);
23968             return -1;
23969         }
23970     }
23971     if (!ctx->is_valid_array) {
23972       PyErr_Format(PyExc_ValueError, "Expected %d dimensions, got %d",
23973                    ctx->head->field->type->ndim, ndim);
23974       return -1;
23975     }
23976     for (i = 0; i < ctx->head->field->type->ndim; i++) {
23977       arraysize *= ctx->head->field->type->arraysize[i];
23978     }
23979     ctx->is_valid_array = 0;
23980     ctx->enc_count = 1;
23981   }
23982   group = __Pyx_BufFmt_TypeCharToGroup(ctx->enc_type, ctx->is_complex);
23983   do {
23984     __Pyx_StructField* field = ctx->head->field;
23985     __Pyx_TypeInfo* type = field->type;
23986     if (ctx->enc_packmode == '@' || ctx->enc_packmode == '^') {
23987       size = __Pyx_BufFmt_TypeCharToNativeSize(ctx->enc_type, ctx->is_complex);
23988     } else {
23989       size = __Pyx_BufFmt_TypeCharToStandardSize(ctx->enc_type, ctx->is_complex);
23990     }
23991     if (ctx->enc_packmode == '@') {
23992       size_t align_at = __Pyx_BufFmt_TypeCharToAlignment(ctx->enc_type, ctx->is_complex);
23993       size_t align_mod_offset;
23994       if (align_at == 0) return -1;
23995       align_mod_offset = ctx->fmt_offset % align_at;
23996       if (align_mod_offset > 0) ctx->fmt_offset += align_at - align_mod_offset;
23997       if (ctx->struct_alignment == 0)
23998           ctx->struct_alignment = __Pyx_BufFmt_TypeCharToPadding(ctx->enc_type,
23999                                                                  ctx->is_complex);
24000     }
24001     if (type->size != size || type->typegroup != group) {
24002       if (type->typegroup == 'C' && type->fields != NULL) {
24003         size_t parent_offset = ctx->head->parent_offset + field->offset;
24004         ++ctx->head;
24005         ctx->head->field = type->fields;
24006         ctx->head->parent_offset = parent_offset;
24007         continue;
24008       }
24009       if ((type->typegroup == 'H' || group == 'H') && type->size == size) {
24010       } else {
24011           __Pyx_BufFmt_RaiseExpected(ctx);
24012           return -1;
24013       }
24014     }
24015     offset = ctx->head->parent_offset + field->offset;
24016     if (ctx->fmt_offset != offset) {
24017       PyErr_Format(PyExc_ValueError,
24018                    "Buffer dtype mismatch; next field is at offset %" CYTHON_FORMAT_SSIZE_T "d but %" CYTHON_FORMAT_SSIZE_T "d expected",
24019                    (Py_ssize_t)ctx->fmt_offset, (Py_ssize_t)offset);
24020       return -1;
24021     }
24022     ctx->fmt_offset += size;
24023     if (arraysize)
24024       ctx->fmt_offset += (arraysize - 1) * size;
24025     --ctx->enc_count;
24026     while (1) {
24027       if (field == &ctx->root) {
24028         ctx->head = NULL;
24029         if (ctx->enc_count != 0) {
24030           __Pyx_BufFmt_RaiseExpected(ctx);
24031           return -1;
24032         }
24033         break;
24034       }
24035       ctx->head->field = ++field;
24036       if (field->type == NULL) {
24037         --ctx->head;
24038         field = ctx->head->field;
24039         continue;
24040       } else if (field->type->typegroup == 'S') {
24041         size_t parent_offset = ctx->head->parent_offset + field->offset;
24042         if (field->type->fields->type == NULL) continue;
24043         field = field->type->fields;
24044         ++ctx->head;
24045         ctx->head->field = field;
24046         ctx->head->parent_offset = parent_offset;
24047         break;
24048       } else {
24049         break;
24050       }
24051     }
24052   } while (ctx->enc_count);
24053   ctx->enc_type = 0;
24054   ctx->is_complex = 0;
24055   return 0;
24056 }
24057 static PyObject *
__pyx_buffmt_parse_array(__Pyx_BufFmt_Context * ctx,const char ** tsp)24058 __pyx_buffmt_parse_array(__Pyx_BufFmt_Context* ctx, const char** tsp)
24059 {
24060     const char *ts = *tsp;
24061     int i = 0, number, ndim;
24062     ++ts;
24063     if (ctx->new_count != 1) {
24064         PyErr_SetString(PyExc_ValueError,
24065                         "Cannot handle repeated arrays in format string");
24066         return NULL;
24067     }
24068     if (__Pyx_BufFmt_ProcessTypeChunk(ctx) == -1) return NULL;
24069     ndim = ctx->head->field->type->ndim;
24070     while (*ts && *ts != ')') {
24071         switch (*ts) {
24072             case ' ': case '\f': case '\r': case '\n': case '\t': case '\v':  continue;
24073             default:  break;
24074         }
24075         number = __Pyx_BufFmt_ExpectNumber(&ts);
24076         if (number == -1) return NULL;
24077         if (i < ndim && (size_t) number != ctx->head->field->type->arraysize[i])
24078             return PyErr_Format(PyExc_ValueError,
24079                         "Expected a dimension of size %zu, got %d",
24080                         ctx->head->field->type->arraysize[i], number);
24081         if (*ts != ',' && *ts != ')')
24082             return PyErr_Format(PyExc_ValueError,
24083                                 "Expected a comma in format string, got '%c'", *ts);
24084         if (*ts == ',') ts++;
24085         i++;
24086     }
24087     if (i != ndim)
24088         return PyErr_Format(PyExc_ValueError, "Expected %d dimension(s), got %d",
24089                             ctx->head->field->type->ndim, i);
24090     if (!*ts) {
24091         PyErr_SetString(PyExc_ValueError,
24092                         "Unexpected end of format string, expected ')'");
24093         return NULL;
24094     }
24095     ctx->is_valid_array = 1;
24096     ctx->new_count = 1;
24097     *tsp = ++ts;
24098     return Py_None;
24099 }
__Pyx_BufFmt_CheckString(__Pyx_BufFmt_Context * ctx,const char * ts)24100 static const char* __Pyx_BufFmt_CheckString(__Pyx_BufFmt_Context* ctx, const char* ts) {
24101   int got_Z = 0;
24102   while (1) {
24103     switch(*ts) {
24104       case 0:
24105         if (ctx->enc_type != 0 && ctx->head == NULL) {
24106           __Pyx_BufFmt_RaiseExpected(ctx);
24107           return NULL;
24108         }
24109         if (__Pyx_BufFmt_ProcessTypeChunk(ctx) == -1) return NULL;
24110         if (ctx->head != NULL) {
24111           __Pyx_BufFmt_RaiseExpected(ctx);
24112           return NULL;
24113         }
24114         return ts;
24115       case ' ':
24116       case '\r':
24117       case '\n':
24118         ++ts;
24119         break;
24120       case '<':
24121         if (!__Pyx_Is_Little_Endian()) {
24122           PyErr_SetString(PyExc_ValueError, "Little-endian buffer not supported on big-endian compiler");
24123           return NULL;
24124         }
24125         ctx->new_packmode = '=';
24126         ++ts;
24127         break;
24128       case '>':
24129       case '!':
24130         if (__Pyx_Is_Little_Endian()) {
24131           PyErr_SetString(PyExc_ValueError, "Big-endian buffer not supported on little-endian compiler");
24132           return NULL;
24133         }
24134         ctx->new_packmode = '=';
24135         ++ts;
24136         break;
24137       case '=':
24138       case '@':
24139       case '^':
24140         ctx->new_packmode = *ts++;
24141         break;
24142       case 'T':
24143         {
24144           const char* ts_after_sub;
24145           size_t i, struct_count = ctx->new_count;
24146           size_t struct_alignment = ctx->struct_alignment;
24147           ctx->new_count = 1;
24148           ++ts;
24149           if (*ts != '{') {
24150             PyErr_SetString(PyExc_ValueError, "Buffer acquisition: Expected '{' after 'T'");
24151             return NULL;
24152           }
24153           if (__Pyx_BufFmt_ProcessTypeChunk(ctx) == -1) return NULL;
24154           ctx->enc_type = 0;
24155           ctx->enc_count = 0;
24156           ctx->struct_alignment = 0;
24157           ++ts;
24158           ts_after_sub = ts;
24159           for (i = 0; i != struct_count; ++i) {
24160             ts_after_sub = __Pyx_BufFmt_CheckString(ctx, ts);
24161             if (!ts_after_sub) return NULL;
24162           }
24163           ts = ts_after_sub;
24164           if (struct_alignment) ctx->struct_alignment = struct_alignment;
24165         }
24166         break;
24167       case '}':
24168         {
24169           size_t alignment = ctx->struct_alignment;
24170           ++ts;
24171           if (__Pyx_BufFmt_ProcessTypeChunk(ctx) == -1) return NULL;
24172           ctx->enc_type = 0;
24173           if (alignment && ctx->fmt_offset % alignment) {
24174             ctx->fmt_offset += alignment - (ctx->fmt_offset % alignment);
24175           }
24176         }
24177         return ts;
24178       case 'x':
24179         if (__Pyx_BufFmt_ProcessTypeChunk(ctx) == -1) return NULL;
24180         ctx->fmt_offset += ctx->new_count;
24181         ctx->new_count = 1;
24182         ctx->enc_count = 0;
24183         ctx->enc_type = 0;
24184         ctx->enc_packmode = ctx->new_packmode;
24185         ++ts;
24186         break;
24187       case 'Z':
24188         got_Z = 1;
24189         ++ts;
24190         if (*ts != 'f' && *ts != 'd' && *ts != 'g') {
24191           __Pyx_BufFmt_RaiseUnexpectedChar('Z');
24192           return NULL;
24193         }
24194         CYTHON_FALLTHROUGH;
24195       case '?': case 'c': case 'b': case 'B': case 'h': case 'H': case 'i': case 'I':
24196       case 'l': case 'L': case 'q': case 'Q':
24197       case 'f': case 'd': case 'g':
24198       case 'O': case 'p':
24199         if ((ctx->enc_type == *ts) && (got_Z == ctx->is_complex) &&
24200             (ctx->enc_packmode == ctx->new_packmode) && (!ctx->is_valid_array)) {
24201           ctx->enc_count += ctx->new_count;
24202           ctx->new_count = 1;
24203           got_Z = 0;
24204           ++ts;
24205           break;
24206         }
24207         CYTHON_FALLTHROUGH;
24208       case 's':
24209         if (__Pyx_BufFmt_ProcessTypeChunk(ctx) == -1) return NULL;
24210         ctx->enc_count = ctx->new_count;
24211         ctx->enc_packmode = ctx->new_packmode;
24212         ctx->enc_type = *ts;
24213         ctx->is_complex = got_Z;
24214         ++ts;
24215         ctx->new_count = 1;
24216         got_Z = 0;
24217         break;
24218       case ':':
24219         ++ts;
24220         while(*ts != ':') ++ts;
24221         ++ts;
24222         break;
24223       case '(':
24224         if (!__pyx_buffmt_parse_array(ctx, &ts)) return NULL;
24225         break;
24226       default:
24227         {
24228           int number = __Pyx_BufFmt_ExpectNumber(&ts);
24229           if (number == -1) return NULL;
24230           ctx->new_count = (size_t)number;
24231         }
24232     }
24233   }
24234 }
24235 
24236 /* BufferGetAndValidate */
__Pyx_SafeReleaseBuffer(Py_buffer * info)24237   static CYTHON_INLINE void __Pyx_SafeReleaseBuffer(Py_buffer* info) {
24238   if (unlikely(info->buf == NULL)) return;
24239   if (info->suboffsets == __Pyx_minusones) info->suboffsets = NULL;
24240   __Pyx_ReleaseBuffer(info);
24241 }
__Pyx_ZeroBuffer(Py_buffer * buf)24242 static void __Pyx_ZeroBuffer(Py_buffer* buf) {
24243   buf->buf = NULL;
24244   buf->obj = NULL;
24245   buf->strides = __Pyx_zeros;
24246   buf->shape = __Pyx_zeros;
24247   buf->suboffsets = __Pyx_minusones;
24248 }
__Pyx__GetBufferAndValidate(Py_buffer * buf,PyObject * obj,__Pyx_TypeInfo * dtype,int flags,int nd,int cast,__Pyx_BufFmt_StackElem * stack)24249 static int __Pyx__GetBufferAndValidate(
24250         Py_buffer* buf, PyObject* obj,  __Pyx_TypeInfo* dtype, int flags,
24251         int nd, int cast, __Pyx_BufFmt_StackElem* stack)
24252 {
24253   buf->buf = NULL;
24254   if (unlikely(__Pyx_GetBuffer(obj, buf, flags) == -1)) {
24255     __Pyx_ZeroBuffer(buf);
24256     return -1;
24257   }
24258   if (unlikely(buf->ndim != nd)) {
24259     PyErr_Format(PyExc_ValueError,
24260                  "Buffer has wrong number of dimensions (expected %d, got %d)",
24261                  nd, buf->ndim);
24262     goto fail;
24263   }
24264   if (!cast) {
24265     __Pyx_BufFmt_Context ctx;
24266     __Pyx_BufFmt_Init(&ctx, stack, dtype);
24267     if (!__Pyx_BufFmt_CheckString(&ctx, buf->format)) goto fail;
24268   }
24269   if (unlikely((size_t)buf->itemsize != dtype->size)) {
24270     PyErr_Format(PyExc_ValueError,
24271       "Item size of buffer (%" CYTHON_FORMAT_SSIZE_T "d byte%s) does not match size of '%s' (%" CYTHON_FORMAT_SSIZE_T "d byte%s)",
24272       buf->itemsize, (buf->itemsize > 1) ? "s" : "",
24273       dtype->name, (Py_ssize_t)dtype->size, (dtype->size > 1) ? "s" : "");
24274     goto fail;
24275   }
24276   if (buf->suboffsets == NULL) buf->suboffsets = __Pyx_minusones;
24277   return 0;
24278 fail:;
24279   __Pyx_SafeReleaseBuffer(buf);
24280   return -1;
24281 }
24282 
24283 /* PyErrFetchRestore */
24284   #if CYTHON_FAST_THREAD_STATE
__Pyx_ErrRestoreInState(PyThreadState * tstate,PyObject * type,PyObject * value,PyObject * tb)24285 static CYTHON_INLINE void __Pyx_ErrRestoreInState(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb) {
24286     PyObject *tmp_type, *tmp_value, *tmp_tb;
24287     tmp_type = tstate->curexc_type;
24288     tmp_value = tstate->curexc_value;
24289     tmp_tb = tstate->curexc_traceback;
24290     tstate->curexc_type = type;
24291     tstate->curexc_value = value;
24292     tstate->curexc_traceback = tb;
24293     Py_XDECREF(tmp_type);
24294     Py_XDECREF(tmp_value);
24295     Py_XDECREF(tmp_tb);
24296 }
__Pyx_ErrFetchInState(PyThreadState * tstate,PyObject ** type,PyObject ** value,PyObject ** tb)24297 static CYTHON_INLINE void __Pyx_ErrFetchInState(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) {
24298     *type = tstate->curexc_type;
24299     *value = tstate->curexc_value;
24300     *tb = tstate->curexc_traceback;
24301     tstate->curexc_type = 0;
24302     tstate->curexc_value = 0;
24303     tstate->curexc_traceback = 0;
24304 }
24305 #endif
24306 
24307 /* RaiseException */
24308   #if PY_MAJOR_VERSION < 3
__Pyx_Raise(PyObject * type,PyObject * value,PyObject * tb,CYTHON_UNUSED PyObject * cause)24309 static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb,
24310                         CYTHON_UNUSED PyObject *cause) {
24311     __Pyx_PyThreadState_declare
24312     Py_XINCREF(type);
24313     if (!value || value == Py_None)
24314         value = NULL;
24315     else
24316         Py_INCREF(value);
24317     if (!tb || tb == Py_None)
24318         tb = NULL;
24319     else {
24320         Py_INCREF(tb);
24321         if (!PyTraceBack_Check(tb)) {
24322             PyErr_SetString(PyExc_TypeError,
24323                 "raise: arg 3 must be a traceback or None");
24324             goto raise_error;
24325         }
24326     }
24327     if (PyType_Check(type)) {
24328 #if CYTHON_COMPILING_IN_PYPY
24329         if (!value) {
24330             Py_INCREF(Py_None);
24331             value = Py_None;
24332         }
24333 #endif
24334         PyErr_NormalizeException(&type, &value, &tb);
24335     } else {
24336         if (value) {
24337             PyErr_SetString(PyExc_TypeError,
24338                 "instance exception may not have a separate value");
24339             goto raise_error;
24340         }
24341         value = type;
24342         type = (PyObject*) Py_TYPE(type);
24343         Py_INCREF(type);
24344         if (!PyType_IsSubtype((PyTypeObject *)type, (PyTypeObject *)PyExc_BaseException)) {
24345             PyErr_SetString(PyExc_TypeError,
24346                 "raise: exception class must be a subclass of BaseException");
24347             goto raise_error;
24348         }
24349     }
24350     __Pyx_PyThreadState_assign
24351     __Pyx_ErrRestore(type, value, tb);
24352     return;
24353 raise_error:
24354     Py_XDECREF(value);
24355     Py_XDECREF(type);
24356     Py_XDECREF(tb);
24357     return;
24358 }
24359 #else
__Pyx_Raise(PyObject * type,PyObject * value,PyObject * tb,PyObject * cause)24360 static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause) {
24361     PyObject* owned_instance = NULL;
24362     if (tb == Py_None) {
24363         tb = 0;
24364     } else if (tb && !PyTraceBack_Check(tb)) {
24365         PyErr_SetString(PyExc_TypeError,
24366             "raise: arg 3 must be a traceback or None");
24367         goto bad;
24368     }
24369     if (value == Py_None)
24370         value = 0;
24371     if (PyExceptionInstance_Check(type)) {
24372         if (value) {
24373             PyErr_SetString(PyExc_TypeError,
24374                 "instance exception may not have a separate value");
24375             goto bad;
24376         }
24377         value = type;
24378         type = (PyObject*) Py_TYPE(value);
24379     } else if (PyExceptionClass_Check(type)) {
24380         PyObject *instance_class = NULL;
24381         if (value && PyExceptionInstance_Check(value)) {
24382             instance_class = (PyObject*) Py_TYPE(value);
24383             if (instance_class != type) {
24384                 int is_subclass = PyObject_IsSubclass(instance_class, type);
24385                 if (!is_subclass) {
24386                     instance_class = NULL;
24387                 } else if (unlikely(is_subclass == -1)) {
24388                     goto bad;
24389                 } else {
24390                     type = instance_class;
24391                 }
24392             }
24393         }
24394         if (!instance_class) {
24395             PyObject *args;
24396             if (!value)
24397                 args = PyTuple_New(0);
24398             else if (PyTuple_Check(value)) {
24399                 Py_INCREF(value);
24400                 args = value;
24401             } else
24402                 args = PyTuple_Pack(1, value);
24403             if (!args)
24404                 goto bad;
24405             owned_instance = PyObject_Call(type, args, NULL);
24406             Py_DECREF(args);
24407             if (!owned_instance)
24408                 goto bad;
24409             value = owned_instance;
24410             if (!PyExceptionInstance_Check(value)) {
24411                 PyErr_Format(PyExc_TypeError,
24412                              "calling %R should have returned an instance of "
24413                              "BaseException, not %R",
24414                              type, Py_TYPE(value));
24415                 goto bad;
24416             }
24417         }
24418     } else {
24419         PyErr_SetString(PyExc_TypeError,
24420             "raise: exception class must be a subclass of BaseException");
24421         goto bad;
24422     }
24423     if (cause) {
24424         PyObject *fixed_cause;
24425         if (cause == Py_None) {
24426             fixed_cause = NULL;
24427         } else if (PyExceptionClass_Check(cause)) {
24428             fixed_cause = PyObject_CallObject(cause, NULL);
24429             if (fixed_cause == NULL)
24430                 goto bad;
24431         } else if (PyExceptionInstance_Check(cause)) {
24432             fixed_cause = cause;
24433             Py_INCREF(fixed_cause);
24434         } else {
24435             PyErr_SetString(PyExc_TypeError,
24436                             "exception causes must derive from "
24437                             "BaseException");
24438             goto bad;
24439         }
24440         PyException_SetCause(value, fixed_cause);
24441     }
24442     PyErr_SetObject(type, value);
24443     if (tb) {
24444 #if CYTHON_COMPILING_IN_PYPY
24445         PyObject *tmp_type, *tmp_value, *tmp_tb;
24446         PyErr_Fetch(&tmp_type, &tmp_value, &tmp_tb);
24447         Py_INCREF(tb);
24448         PyErr_Restore(tmp_type, tmp_value, tb);
24449         Py_XDECREF(tmp_tb);
24450 #else
24451         PyThreadState *tstate = __Pyx_PyThreadState_Current;
24452         PyObject* tmp_tb = tstate->curexc_traceback;
24453         if (tb != tmp_tb) {
24454             Py_INCREF(tb);
24455             tstate->curexc_traceback = tb;
24456             Py_XDECREF(tmp_tb);
24457         }
24458 #endif
24459     }
24460 bad:
24461     Py_XDECREF(owned_instance);
24462     return;
24463 }
24464 #endif
24465 
24466 /* MemviewSliceInit */
24467   static int
__Pyx_init_memviewslice(struct __pyx_memoryview_obj * memview,int ndim,__Pyx_memviewslice * memviewslice,int memview_is_new_reference)24468 __Pyx_init_memviewslice(struct __pyx_memoryview_obj *memview,
24469                         int ndim,
24470                         __Pyx_memviewslice *memviewslice,
24471                         int memview_is_new_reference)
24472 {
24473     __Pyx_RefNannyDeclarations
24474     int i, retval=-1;
24475     Py_buffer *buf = &memview->view;
24476     __Pyx_RefNannySetupContext("init_memviewslice", 0);
24477     if (unlikely(memviewslice->memview || memviewslice->data)) {
24478         PyErr_SetString(PyExc_ValueError,
24479             "memviewslice is already initialized!");
24480         goto fail;
24481     }
24482     if (buf->strides) {
24483         for (i = 0; i < ndim; i++) {
24484             memviewslice->strides[i] = buf->strides[i];
24485         }
24486     } else {
24487         Py_ssize_t stride = buf->itemsize;
24488         for (i = ndim - 1; i >= 0; i--) {
24489             memviewslice->strides[i] = stride;
24490             stride *= buf->shape[i];
24491         }
24492     }
24493     for (i = 0; i < ndim; i++) {
24494         memviewslice->shape[i]   = buf->shape[i];
24495         if (buf->suboffsets) {
24496             memviewslice->suboffsets[i] = buf->suboffsets[i];
24497         } else {
24498             memviewslice->suboffsets[i] = -1;
24499         }
24500     }
24501     memviewslice->memview = memview;
24502     memviewslice->data = (char *)buf->buf;
24503     if (__pyx_add_acquisition_count(memview) == 0 && !memview_is_new_reference) {
24504         Py_INCREF(memview);
24505     }
24506     retval = 0;
24507     goto no_fail;
24508 fail:
24509     memviewslice->memview = 0;
24510     memviewslice->data = 0;
24511     retval = -1;
24512 no_fail:
24513     __Pyx_RefNannyFinishContext();
24514     return retval;
24515 }
24516 #ifndef Py_NO_RETURN
24517 #define Py_NO_RETURN
24518 #endif
__pyx_fatalerror(const char * fmt,...)24519 static void __pyx_fatalerror(const char *fmt, ...) Py_NO_RETURN {
24520     va_list vargs;
24521     char msg[200];
24522 #ifdef HAVE_STDARG_PROTOTYPES
24523     va_start(vargs, fmt);
24524 #else
24525     va_start(vargs);
24526 #endif
24527     vsnprintf(msg, 200, fmt, vargs);
24528     va_end(vargs);
24529     Py_FatalError(msg);
24530 }
24531 static CYTHON_INLINE int
__pyx_add_acquisition_count_locked(__pyx_atomic_int * acquisition_count,PyThread_type_lock lock)24532 __pyx_add_acquisition_count_locked(__pyx_atomic_int *acquisition_count,
24533                                    PyThread_type_lock lock)
24534 {
24535     int result;
24536     PyThread_acquire_lock(lock, 1);
24537     result = (*acquisition_count)++;
24538     PyThread_release_lock(lock);
24539     return result;
24540 }
24541 static CYTHON_INLINE int
__pyx_sub_acquisition_count_locked(__pyx_atomic_int * acquisition_count,PyThread_type_lock lock)24542 __pyx_sub_acquisition_count_locked(__pyx_atomic_int *acquisition_count,
24543                                    PyThread_type_lock lock)
24544 {
24545     int result;
24546     PyThread_acquire_lock(lock, 1);
24547     result = (*acquisition_count)--;
24548     PyThread_release_lock(lock);
24549     return result;
24550 }
24551 static CYTHON_INLINE void
__Pyx_INC_MEMVIEW(__Pyx_memviewslice * memslice,int have_gil,int lineno)24552 __Pyx_INC_MEMVIEW(__Pyx_memviewslice *memslice, int have_gil, int lineno)
24553 {
24554     int first_time;
24555     struct __pyx_memoryview_obj *memview = memslice->memview;
24556     if (unlikely(!memview || (PyObject *) memview == Py_None))
24557         return;
24558     if (unlikely(__pyx_get_slice_count(memview) < 0))
24559         __pyx_fatalerror("Acquisition count is %d (line %d)",
24560                          __pyx_get_slice_count(memview), lineno);
24561     first_time = __pyx_add_acquisition_count(memview) == 0;
24562     if (unlikely(first_time)) {
24563         if (have_gil) {
24564             Py_INCREF((PyObject *) memview);
24565         } else {
24566             PyGILState_STATE _gilstate = PyGILState_Ensure();
24567             Py_INCREF((PyObject *) memview);
24568             PyGILState_Release(_gilstate);
24569         }
24570     }
24571 }
__Pyx_XDEC_MEMVIEW(__Pyx_memviewslice * memslice,int have_gil,int lineno)24572 static CYTHON_INLINE void __Pyx_XDEC_MEMVIEW(__Pyx_memviewslice *memslice,
24573                                              int have_gil, int lineno) {
24574     int last_time;
24575     struct __pyx_memoryview_obj *memview = memslice->memview;
24576     if (unlikely(!memview || (PyObject *) memview == Py_None)) {
24577         memslice->memview = NULL;
24578         return;
24579     }
24580     if (unlikely(__pyx_get_slice_count(memview) <= 0))
24581         __pyx_fatalerror("Acquisition count is %d (line %d)",
24582                          __pyx_get_slice_count(memview), lineno);
24583     last_time = __pyx_sub_acquisition_count(memview) == 1;
24584     memslice->data = NULL;
24585     if (unlikely(last_time)) {
24586         if (have_gil) {
24587             Py_CLEAR(memslice->memview);
24588         } else {
24589             PyGILState_STATE _gilstate = PyGILState_Ensure();
24590             Py_CLEAR(memslice->memview);
24591             PyGILState_Release(_gilstate);
24592         }
24593     } else {
24594         memslice->memview = NULL;
24595     }
24596 }
24597 
24598 /* None */
__Pyx_RaiseUnboundLocalError(const char * varname)24599   static CYTHON_INLINE void __Pyx_RaiseUnboundLocalError(const char *varname) {
24600     PyErr_Format(PyExc_UnboundLocalError, "local variable '%s' referenced before assignment", varname);
24601 }
24602 
24603 /* GetTopmostException */
24604   #if CYTHON_USE_EXC_INFO_STACK
24605 static _PyErr_StackItem *
__Pyx_PyErr_GetTopmostException(PyThreadState * tstate)24606 __Pyx_PyErr_GetTopmostException(PyThreadState *tstate)
24607 {
24608     _PyErr_StackItem *exc_info = tstate->exc_info;
24609     while ((exc_info->exc_type == NULL || exc_info->exc_type == Py_None) &&
24610            exc_info->previous_item != NULL)
24611     {
24612         exc_info = exc_info->previous_item;
24613     }
24614     return exc_info;
24615 }
24616 #endif
24617 
24618 /* SaveResetException */
24619   #if CYTHON_FAST_THREAD_STATE
__Pyx__ExceptionSave(PyThreadState * tstate,PyObject ** type,PyObject ** value,PyObject ** tb)24620 static CYTHON_INLINE void __Pyx__ExceptionSave(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) {
24621     #if CYTHON_USE_EXC_INFO_STACK
24622     _PyErr_StackItem *exc_info = __Pyx_PyErr_GetTopmostException(tstate);
24623     *type = exc_info->exc_type;
24624     *value = exc_info->exc_value;
24625     *tb = exc_info->exc_traceback;
24626     #else
24627     *type = tstate->exc_type;
24628     *value = tstate->exc_value;
24629     *tb = tstate->exc_traceback;
24630     #endif
24631     Py_XINCREF(*type);
24632     Py_XINCREF(*value);
24633     Py_XINCREF(*tb);
24634 }
__Pyx__ExceptionReset(PyThreadState * tstate,PyObject * type,PyObject * value,PyObject * tb)24635 static CYTHON_INLINE void __Pyx__ExceptionReset(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb) {
24636     PyObject *tmp_type, *tmp_value, *tmp_tb;
24637     #if CYTHON_USE_EXC_INFO_STACK
24638     _PyErr_StackItem *exc_info = tstate->exc_info;
24639     tmp_type = exc_info->exc_type;
24640     tmp_value = exc_info->exc_value;
24641     tmp_tb = exc_info->exc_traceback;
24642     exc_info->exc_type = type;
24643     exc_info->exc_value = value;
24644     exc_info->exc_traceback = tb;
24645     #else
24646     tmp_type = tstate->exc_type;
24647     tmp_value = tstate->exc_value;
24648     tmp_tb = tstate->exc_traceback;
24649     tstate->exc_type = type;
24650     tstate->exc_value = value;
24651     tstate->exc_traceback = tb;
24652     #endif
24653     Py_XDECREF(tmp_type);
24654     Py_XDECREF(tmp_value);
24655     Py_XDECREF(tmp_tb);
24656 }
24657 #endif
24658 
24659 /* PyErrExceptionMatches */
24660   #if CYTHON_FAST_THREAD_STATE
__Pyx_PyErr_ExceptionMatchesTuple(PyObject * exc_type,PyObject * tuple)24661 static int __Pyx_PyErr_ExceptionMatchesTuple(PyObject *exc_type, PyObject *tuple) {
24662     Py_ssize_t i, n;
24663     n = PyTuple_GET_SIZE(tuple);
24664 #if PY_MAJOR_VERSION >= 3
24665     for (i=0; i<n; i++) {
24666         if (exc_type == PyTuple_GET_ITEM(tuple, i)) return 1;
24667     }
24668 #endif
24669     for (i=0; i<n; i++) {
24670         if (__Pyx_PyErr_GivenExceptionMatches(exc_type, PyTuple_GET_ITEM(tuple, i))) return 1;
24671     }
24672     return 0;
24673 }
__Pyx_PyErr_ExceptionMatchesInState(PyThreadState * tstate,PyObject * err)24674 static CYTHON_INLINE int __Pyx_PyErr_ExceptionMatchesInState(PyThreadState* tstate, PyObject* err) {
24675     PyObject *exc_type = tstate->curexc_type;
24676     if (exc_type == err) return 1;
24677     if (unlikely(!exc_type)) return 0;
24678     if (unlikely(PyTuple_Check(err)))
24679         return __Pyx_PyErr_ExceptionMatchesTuple(exc_type, err);
24680     return __Pyx_PyErr_GivenExceptionMatches(exc_type, err);
24681 }
24682 #endif
24683 
24684 /* GetException */
24685   #if CYTHON_FAST_THREAD_STATE
__Pyx__GetException(PyThreadState * tstate,PyObject ** type,PyObject ** value,PyObject ** tb)24686 static int __Pyx__GetException(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb)
24687 #else
24688 static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb)
24689 #endif
24690 {
24691     PyObject *local_type, *local_value, *local_tb;
24692 #if CYTHON_FAST_THREAD_STATE
24693     PyObject *tmp_type, *tmp_value, *tmp_tb;
24694     local_type = tstate->curexc_type;
24695     local_value = tstate->curexc_value;
24696     local_tb = tstate->curexc_traceback;
24697     tstate->curexc_type = 0;
24698     tstate->curexc_value = 0;
24699     tstate->curexc_traceback = 0;
24700 #else
24701     PyErr_Fetch(&local_type, &local_value, &local_tb);
24702 #endif
24703     PyErr_NormalizeException(&local_type, &local_value, &local_tb);
24704 #if CYTHON_FAST_THREAD_STATE
24705     if (unlikely(tstate->curexc_type))
24706 #else
24707     if (unlikely(PyErr_Occurred()))
24708 #endif
24709         goto bad;
24710     #if PY_MAJOR_VERSION >= 3
24711     if (local_tb) {
24712         if (unlikely(PyException_SetTraceback(local_value, local_tb) < 0))
24713             goto bad;
24714     }
24715     #endif
24716     Py_XINCREF(local_tb);
24717     Py_XINCREF(local_type);
24718     Py_XINCREF(local_value);
24719     *type = local_type;
24720     *value = local_value;
24721     *tb = local_tb;
24722 #if CYTHON_FAST_THREAD_STATE
24723     #if CYTHON_USE_EXC_INFO_STACK
24724     {
24725         _PyErr_StackItem *exc_info = tstate->exc_info;
24726         tmp_type = exc_info->exc_type;
24727         tmp_value = exc_info->exc_value;
24728         tmp_tb = exc_info->exc_traceback;
24729         exc_info->exc_type = local_type;
24730         exc_info->exc_value = local_value;
24731         exc_info->exc_traceback = local_tb;
24732     }
24733     #else
24734     tmp_type = tstate->exc_type;
24735     tmp_value = tstate->exc_value;
24736     tmp_tb = tstate->exc_traceback;
24737     tstate->exc_type = local_type;
24738     tstate->exc_value = local_value;
24739     tstate->exc_traceback = local_tb;
24740     #endif
24741     Py_XDECREF(tmp_type);
24742     Py_XDECREF(tmp_value);
24743     Py_XDECREF(tmp_tb);
24744 #else
24745     PyErr_SetExcInfo(local_type, local_value, local_tb);
24746 #endif
24747     return 0;
24748 bad:
24749     *type = 0;
24750     *value = 0;
24751     *tb = 0;
24752     Py_XDECREF(local_type);
24753     Py_XDECREF(local_value);
24754     Py_XDECREF(local_tb);
24755     return -1;
24756 }
24757 
24758 /* ArgTypeTest */
__Pyx__ArgTypeTest(PyObject * obj,PyTypeObject * type,const char * name,int exact)24759   static int __Pyx__ArgTypeTest(PyObject *obj, PyTypeObject *type, const char *name, int exact)
24760 {
24761     if (unlikely(!type)) {
24762         PyErr_SetString(PyExc_SystemError, "Missing type object");
24763         return 0;
24764     }
24765     else if (exact) {
24766         #if PY_MAJOR_VERSION == 2
24767         if ((type == &PyBaseString_Type) && likely(__Pyx_PyBaseString_CheckExact(obj))) return 1;
24768         #endif
24769     }
24770     else {
24771         if (likely(__Pyx_TypeCheck(obj, type))) return 1;
24772     }
24773     PyErr_Format(PyExc_TypeError,
24774         "Argument '%.200s' has incorrect type (expected %.200s, got %.200s)",
24775         name, type->tp_name, Py_TYPE(obj)->tp_name);
24776     return 0;
24777 }
24778 
24779 /* BytesEquals */
__Pyx_PyBytes_Equals(PyObject * s1,PyObject * s2,int equals)24780   static CYTHON_INLINE int __Pyx_PyBytes_Equals(PyObject* s1, PyObject* s2, int equals) {
24781 #if CYTHON_COMPILING_IN_PYPY
24782     return PyObject_RichCompareBool(s1, s2, equals);
24783 #else
24784     if (s1 == s2) {
24785         return (equals == Py_EQ);
24786     } else if (PyBytes_CheckExact(s1) & PyBytes_CheckExact(s2)) {
24787         const char *ps1, *ps2;
24788         Py_ssize_t length = PyBytes_GET_SIZE(s1);
24789         if (length != PyBytes_GET_SIZE(s2))
24790             return (equals == Py_NE);
24791         ps1 = PyBytes_AS_STRING(s1);
24792         ps2 = PyBytes_AS_STRING(s2);
24793         if (ps1[0] != ps2[0]) {
24794             return (equals == Py_NE);
24795         } else if (length == 1) {
24796             return (equals == Py_EQ);
24797         } else {
24798             int result;
24799 #if CYTHON_USE_UNICODE_INTERNALS
24800             Py_hash_t hash1, hash2;
24801             hash1 = ((PyBytesObject*)s1)->ob_shash;
24802             hash2 = ((PyBytesObject*)s2)->ob_shash;
24803             if (hash1 != hash2 && hash1 != -1 && hash2 != -1) {
24804                 return (equals == Py_NE);
24805             }
24806 #endif
24807             result = memcmp(ps1, ps2, (size_t)length);
24808             return (equals == Py_EQ) ? (result == 0) : (result != 0);
24809         }
24810     } else if ((s1 == Py_None) & PyBytes_CheckExact(s2)) {
24811         return (equals == Py_NE);
24812     } else if ((s2 == Py_None) & PyBytes_CheckExact(s1)) {
24813         return (equals == Py_NE);
24814     } else {
24815         int result;
24816         PyObject* py_result = PyObject_RichCompare(s1, s2, equals);
24817         if (!py_result)
24818             return -1;
24819         result = __Pyx_PyObject_IsTrue(py_result);
24820         Py_DECREF(py_result);
24821         return result;
24822     }
24823 #endif
24824 }
24825 
24826 /* UnicodeEquals */
__Pyx_PyUnicode_Equals(PyObject * s1,PyObject * s2,int equals)24827   static CYTHON_INLINE int __Pyx_PyUnicode_Equals(PyObject* s1, PyObject* s2, int equals) {
24828 #if CYTHON_COMPILING_IN_PYPY
24829     return PyObject_RichCompareBool(s1, s2, equals);
24830 #else
24831 #if PY_MAJOR_VERSION < 3
24832     PyObject* owned_ref = NULL;
24833 #endif
24834     int s1_is_unicode, s2_is_unicode;
24835     if (s1 == s2) {
24836         goto return_eq;
24837     }
24838     s1_is_unicode = PyUnicode_CheckExact(s1);
24839     s2_is_unicode = PyUnicode_CheckExact(s2);
24840 #if PY_MAJOR_VERSION < 3
24841     if ((s1_is_unicode & (!s2_is_unicode)) && PyString_CheckExact(s2)) {
24842         owned_ref = PyUnicode_FromObject(s2);
24843         if (unlikely(!owned_ref))
24844             return -1;
24845         s2 = owned_ref;
24846         s2_is_unicode = 1;
24847     } else if ((s2_is_unicode & (!s1_is_unicode)) && PyString_CheckExact(s1)) {
24848         owned_ref = PyUnicode_FromObject(s1);
24849         if (unlikely(!owned_ref))
24850             return -1;
24851         s1 = owned_ref;
24852         s1_is_unicode = 1;
24853     } else if (((!s2_is_unicode) & (!s1_is_unicode))) {
24854         return __Pyx_PyBytes_Equals(s1, s2, equals);
24855     }
24856 #endif
24857     if (s1_is_unicode & s2_is_unicode) {
24858         Py_ssize_t length;
24859         int kind;
24860         void *data1, *data2;
24861         if (unlikely(__Pyx_PyUnicode_READY(s1) < 0) || unlikely(__Pyx_PyUnicode_READY(s2) < 0))
24862             return -1;
24863         length = __Pyx_PyUnicode_GET_LENGTH(s1);
24864         if (length != __Pyx_PyUnicode_GET_LENGTH(s2)) {
24865             goto return_ne;
24866         }
24867 #if CYTHON_USE_UNICODE_INTERNALS
24868         {
24869             Py_hash_t hash1, hash2;
24870         #if CYTHON_PEP393_ENABLED
24871             hash1 = ((PyASCIIObject*)s1)->hash;
24872             hash2 = ((PyASCIIObject*)s2)->hash;
24873         #else
24874             hash1 = ((PyUnicodeObject*)s1)->hash;
24875             hash2 = ((PyUnicodeObject*)s2)->hash;
24876         #endif
24877             if (hash1 != hash2 && hash1 != -1 && hash2 != -1) {
24878                 goto return_ne;
24879             }
24880         }
24881 #endif
24882         kind = __Pyx_PyUnicode_KIND(s1);
24883         if (kind != __Pyx_PyUnicode_KIND(s2)) {
24884             goto return_ne;
24885         }
24886         data1 = __Pyx_PyUnicode_DATA(s1);
24887         data2 = __Pyx_PyUnicode_DATA(s2);
24888         if (__Pyx_PyUnicode_READ(kind, data1, 0) != __Pyx_PyUnicode_READ(kind, data2, 0)) {
24889             goto return_ne;
24890         } else if (length == 1) {
24891             goto return_eq;
24892         } else {
24893             int result = memcmp(data1, data2, (size_t)(length * kind));
24894             #if PY_MAJOR_VERSION < 3
24895             Py_XDECREF(owned_ref);
24896             #endif
24897             return (equals == Py_EQ) ? (result == 0) : (result != 0);
24898         }
24899     } else if ((s1 == Py_None) & s2_is_unicode) {
24900         goto return_ne;
24901     } else if ((s2 == Py_None) & s1_is_unicode) {
24902         goto return_ne;
24903     } else {
24904         int result;
24905         PyObject* py_result = PyObject_RichCompare(s1, s2, equals);
24906         #if PY_MAJOR_VERSION < 3
24907         Py_XDECREF(owned_ref);
24908         #endif
24909         if (!py_result)
24910             return -1;
24911         result = __Pyx_PyObject_IsTrue(py_result);
24912         Py_DECREF(py_result);
24913         return result;
24914     }
24915 return_eq:
24916     #if PY_MAJOR_VERSION < 3
24917     Py_XDECREF(owned_ref);
24918     #endif
24919     return (equals == Py_EQ);
24920 return_ne:
24921     #if PY_MAJOR_VERSION < 3
24922     Py_XDECREF(owned_ref);
24923     #endif
24924     return (equals == Py_NE);
24925 #endif
24926 }
24927 
24928 /* None */
__Pyx_div_Py_ssize_t(Py_ssize_t a,Py_ssize_t b)24929   static CYTHON_INLINE Py_ssize_t __Pyx_div_Py_ssize_t(Py_ssize_t a, Py_ssize_t b) {
24930     Py_ssize_t q = a / b;
24931     Py_ssize_t r = a - q*b;
24932     q -= ((r != 0) & ((r ^ b) < 0));
24933     return q;
24934 }
24935 
24936 /* GetAttr */
__Pyx_GetAttr(PyObject * o,PyObject * n)24937   static CYTHON_INLINE PyObject *__Pyx_GetAttr(PyObject *o, PyObject *n) {
24938 #if CYTHON_USE_TYPE_SLOTS
24939 #if PY_MAJOR_VERSION >= 3
24940     if (likely(PyUnicode_Check(n)))
24941 #else
24942     if (likely(PyString_Check(n)))
24943 #endif
24944         return __Pyx_PyObject_GetAttrStr(o, n);
24945 #endif
24946     return PyObject_GetAttr(o, n);
24947 }
24948 
24949 /* ObjectGetItem */
24950   #if CYTHON_USE_TYPE_SLOTS
__Pyx_PyObject_GetIndex(PyObject * obj,PyObject * index)24951 static PyObject *__Pyx_PyObject_GetIndex(PyObject *obj, PyObject* index) {
24952     PyObject *runerr;
24953     Py_ssize_t key_value;
24954     PySequenceMethods *m = Py_TYPE(obj)->tp_as_sequence;
24955     if (unlikely(!(m && m->sq_item))) {
24956         PyErr_Format(PyExc_TypeError, "'%.200s' object is not subscriptable", Py_TYPE(obj)->tp_name);
24957         return NULL;
24958     }
24959     key_value = __Pyx_PyIndex_AsSsize_t(index);
24960     if (likely(key_value != -1 || !(runerr = PyErr_Occurred()))) {
24961         return __Pyx_GetItemInt_Fast(obj, key_value, 0, 1, 1);
24962     }
24963     if (PyErr_GivenExceptionMatches(runerr, PyExc_OverflowError)) {
24964         PyErr_Clear();
24965         PyErr_Format(PyExc_IndexError, "cannot fit '%.200s' into an index-sized integer", Py_TYPE(index)->tp_name);
24966     }
24967     return NULL;
24968 }
__Pyx_PyObject_GetItem(PyObject * obj,PyObject * key)24969 static PyObject *__Pyx_PyObject_GetItem(PyObject *obj, PyObject* key) {
24970     PyMappingMethods *m = Py_TYPE(obj)->tp_as_mapping;
24971     if (likely(m && m->mp_subscript)) {
24972         return m->mp_subscript(obj, key);
24973     }
24974     return __Pyx_PyObject_GetIndex(obj, key);
24975 }
24976 #endif
24977 
24978 /* 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))24979   static CYTHON_INLINE PyObject* __Pyx_decode_c_string(
24980          const char* cstring, Py_ssize_t start, Py_ssize_t stop,
24981          const char* encoding, const char* errors,
24982          PyObject* (*decode_func)(const char *s, Py_ssize_t size, const char *errors)) {
24983     Py_ssize_t length;
24984     if (unlikely((start < 0) | (stop < 0))) {
24985         size_t slen = strlen(cstring);
24986         if (unlikely(slen > (size_t) PY_SSIZE_T_MAX)) {
24987             PyErr_SetString(PyExc_OverflowError,
24988                             "c-string too long to convert to Python");
24989             return NULL;
24990         }
24991         length = (Py_ssize_t) slen;
24992         if (start < 0) {
24993             start += length;
24994             if (start < 0)
24995                 start = 0;
24996         }
24997         if (stop < 0)
24998             stop += length;
24999     }
25000     if (unlikely(stop <= start))
25001         return __Pyx_NewRef(__pyx_empty_unicode);
25002     length = stop - start;
25003     cstring += start;
25004     if (decode_func) {
25005         return decode_func(cstring, length, errors);
25006     } else {
25007         return PyUnicode_Decode(cstring, length, encoding, errors);
25008     }
25009 }
25010 
25011 /* GetAttr3 */
__Pyx_GetAttr3Default(PyObject * d)25012   static PyObject *__Pyx_GetAttr3Default(PyObject *d) {
25013     __Pyx_PyThreadState_declare
25014     __Pyx_PyThreadState_assign
25015     if (unlikely(!__Pyx_PyErr_ExceptionMatches(PyExc_AttributeError)))
25016         return NULL;
25017     __Pyx_PyErr_Clear();
25018     Py_INCREF(d);
25019     return d;
25020 }
__Pyx_GetAttr3(PyObject * o,PyObject * n,PyObject * d)25021 static CYTHON_INLINE PyObject *__Pyx_GetAttr3(PyObject *o, PyObject *n, PyObject *d) {
25022     PyObject *r = __Pyx_GetAttr(o, n);
25023     return (likely(r)) ? r : __Pyx_GetAttr3Default(d);
25024 }
25025 
25026 /* RaiseTooManyValuesToUnpack */
__Pyx_RaiseTooManyValuesError(Py_ssize_t expected)25027   static CYTHON_INLINE void __Pyx_RaiseTooManyValuesError(Py_ssize_t expected) {
25028     PyErr_Format(PyExc_ValueError,
25029                  "too many values to unpack (expected %" CYTHON_FORMAT_SSIZE_T "d)", expected);
25030 }
25031 
25032 /* RaiseNeedMoreValuesToUnpack */
__Pyx_RaiseNeedMoreValuesError(Py_ssize_t index)25033   static CYTHON_INLINE void __Pyx_RaiseNeedMoreValuesError(Py_ssize_t index) {
25034     PyErr_Format(PyExc_ValueError,
25035                  "need more than %" CYTHON_FORMAT_SSIZE_T "d value%.1s to unpack",
25036                  index, (index == 1) ? "" : "s");
25037 }
25038 
25039 /* RaiseNoneIterError */
__Pyx_RaiseNoneNotIterableError(void)25040   static CYTHON_INLINE void __Pyx_RaiseNoneNotIterableError(void) {
25041     PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable");
25042 }
25043 
25044 /* SwapException */
25045   #if CYTHON_FAST_THREAD_STATE
__Pyx__ExceptionSwap(PyThreadState * tstate,PyObject ** type,PyObject ** value,PyObject ** tb)25046 static CYTHON_INLINE void __Pyx__ExceptionSwap(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) {
25047     PyObject *tmp_type, *tmp_value, *tmp_tb;
25048     #if CYTHON_USE_EXC_INFO_STACK
25049     _PyErr_StackItem *exc_info = tstate->exc_info;
25050     tmp_type = exc_info->exc_type;
25051     tmp_value = exc_info->exc_value;
25052     tmp_tb = exc_info->exc_traceback;
25053     exc_info->exc_type = *type;
25054     exc_info->exc_value = *value;
25055     exc_info->exc_traceback = *tb;
25056     #else
25057     tmp_type = tstate->exc_type;
25058     tmp_value = tstate->exc_value;
25059     tmp_tb = tstate->exc_traceback;
25060     tstate->exc_type = *type;
25061     tstate->exc_value = *value;
25062     tstate->exc_traceback = *tb;
25063     #endif
25064     *type = tmp_type;
25065     *value = tmp_value;
25066     *tb = tmp_tb;
25067 }
25068 #else
__Pyx_ExceptionSwap(PyObject ** type,PyObject ** value,PyObject ** tb)25069 static CYTHON_INLINE void __Pyx_ExceptionSwap(PyObject **type, PyObject **value, PyObject **tb) {
25070     PyObject *tmp_type, *tmp_value, *tmp_tb;
25071     PyErr_GetExcInfo(&tmp_type, &tmp_value, &tmp_tb);
25072     PyErr_SetExcInfo(*type, *value, *tb);
25073     *type = tmp_type;
25074     *value = tmp_value;
25075     *tb = tmp_tb;
25076 }
25077 #endif
25078 
25079 /* Import */
__Pyx_Import(PyObject * name,PyObject * from_list,int level)25080   static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, int level) {
25081     PyObject *empty_list = 0;
25082     PyObject *module = 0;
25083     PyObject *global_dict = 0;
25084     PyObject *empty_dict = 0;
25085     PyObject *list;
25086     #if PY_MAJOR_VERSION < 3
25087     PyObject *py_import;
25088     py_import = __Pyx_PyObject_GetAttrStr(__pyx_b, __pyx_n_s_import);
25089     if (!py_import)
25090         goto bad;
25091     #endif
25092     if (from_list)
25093         list = from_list;
25094     else {
25095         empty_list = PyList_New(0);
25096         if (!empty_list)
25097             goto bad;
25098         list = empty_list;
25099     }
25100     global_dict = PyModule_GetDict(__pyx_m);
25101     if (!global_dict)
25102         goto bad;
25103     empty_dict = PyDict_New();
25104     if (!empty_dict)
25105         goto bad;
25106     {
25107         #if PY_MAJOR_VERSION >= 3
25108         if (level == -1) {
25109             if ((1) && (strchr(__Pyx_MODULE_NAME, '.'))) {
25110                 module = PyImport_ImportModuleLevelObject(
25111                     name, global_dict, empty_dict, list, 1);
25112                 if (!module) {
25113                     if (!PyErr_ExceptionMatches(PyExc_ImportError))
25114                         goto bad;
25115                     PyErr_Clear();
25116                 }
25117             }
25118             level = 0;
25119         }
25120         #endif
25121         if (!module) {
25122             #if PY_MAJOR_VERSION < 3
25123             PyObject *py_level = PyInt_FromLong(level);
25124             if (!py_level)
25125                 goto bad;
25126             module = PyObject_CallFunctionObjArgs(py_import,
25127                 name, global_dict, empty_dict, list, py_level, (PyObject *)NULL);
25128             Py_DECREF(py_level);
25129             #else
25130             module = PyImport_ImportModuleLevelObject(
25131                 name, global_dict, empty_dict, list, level);
25132             #endif
25133         }
25134     }
25135 bad:
25136     #if PY_MAJOR_VERSION < 3
25137     Py_XDECREF(py_import);
25138     #endif
25139     Py_XDECREF(empty_list);
25140     Py_XDECREF(empty_dict);
25141     return module;
25142 }
25143 
25144 /* FastTypeChecks */
25145   #if CYTHON_COMPILING_IN_CPYTHON
__Pyx_InBases(PyTypeObject * a,PyTypeObject * b)25146 static int __Pyx_InBases(PyTypeObject *a, PyTypeObject *b) {
25147     while (a) {
25148         a = a->tp_base;
25149         if (a == b)
25150             return 1;
25151     }
25152     return b == &PyBaseObject_Type;
25153 }
__Pyx_IsSubtype(PyTypeObject * a,PyTypeObject * b)25154 static CYTHON_INLINE int __Pyx_IsSubtype(PyTypeObject *a, PyTypeObject *b) {
25155     PyObject *mro;
25156     if (a == b) return 1;
25157     mro = a->tp_mro;
25158     if (likely(mro)) {
25159         Py_ssize_t i, n;
25160         n = PyTuple_GET_SIZE(mro);
25161         for (i = 0; i < n; i++) {
25162             if (PyTuple_GET_ITEM(mro, i) == (PyObject *)b)
25163                 return 1;
25164         }
25165         return 0;
25166     }
25167     return __Pyx_InBases(a, b);
25168 }
25169 #if PY_MAJOR_VERSION == 2
__Pyx_inner_PyErr_GivenExceptionMatches2(PyObject * err,PyObject * exc_type1,PyObject * exc_type2)25170 static int __Pyx_inner_PyErr_GivenExceptionMatches2(PyObject *err, PyObject* exc_type1, PyObject* exc_type2) {
25171     PyObject *exception, *value, *tb;
25172     int res;
25173     __Pyx_PyThreadState_declare
25174     __Pyx_PyThreadState_assign
25175     __Pyx_ErrFetch(&exception, &value, &tb);
25176     res = exc_type1 ? PyObject_IsSubclass(err, exc_type1) : 0;
25177     if (unlikely(res == -1)) {
25178         PyErr_WriteUnraisable(err);
25179         res = 0;
25180     }
25181     if (!res) {
25182         res = PyObject_IsSubclass(err, exc_type2);
25183         if (unlikely(res == -1)) {
25184             PyErr_WriteUnraisable(err);
25185             res = 0;
25186         }
25187     }
25188     __Pyx_ErrRestore(exception, value, tb);
25189     return res;
25190 }
25191 #else
__Pyx_inner_PyErr_GivenExceptionMatches2(PyObject * err,PyObject * exc_type1,PyObject * exc_type2)25192 static CYTHON_INLINE int __Pyx_inner_PyErr_GivenExceptionMatches2(PyObject *err, PyObject* exc_type1, PyObject *exc_type2) {
25193     int res = exc_type1 ? __Pyx_IsSubtype((PyTypeObject*)err, (PyTypeObject*)exc_type1) : 0;
25194     if (!res) {
25195         res = __Pyx_IsSubtype((PyTypeObject*)err, (PyTypeObject*)exc_type2);
25196     }
25197     return res;
25198 }
25199 #endif
__Pyx_PyErr_GivenExceptionMatchesTuple(PyObject * exc_type,PyObject * tuple)25200 static int __Pyx_PyErr_GivenExceptionMatchesTuple(PyObject *exc_type, PyObject *tuple) {
25201     Py_ssize_t i, n;
25202     assert(PyExceptionClass_Check(exc_type));
25203     n = PyTuple_GET_SIZE(tuple);
25204 #if PY_MAJOR_VERSION >= 3
25205     for (i=0; i<n; i++) {
25206         if (exc_type == PyTuple_GET_ITEM(tuple, i)) return 1;
25207     }
25208 #endif
25209     for (i=0; i<n; i++) {
25210         PyObject *t = PyTuple_GET_ITEM(tuple, i);
25211         #if PY_MAJOR_VERSION < 3
25212         if (likely(exc_type == t)) return 1;
25213         #endif
25214         if (likely(PyExceptionClass_Check(t))) {
25215             if (__Pyx_inner_PyErr_GivenExceptionMatches2(exc_type, NULL, t)) return 1;
25216         } else {
25217         }
25218     }
25219     return 0;
25220 }
__Pyx_PyErr_GivenExceptionMatches(PyObject * err,PyObject * exc_type)25221 static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches(PyObject *err, PyObject* exc_type) {
25222     if (likely(err == exc_type)) return 1;
25223     if (likely(PyExceptionClass_Check(err))) {
25224         if (likely(PyExceptionClass_Check(exc_type))) {
25225             return __Pyx_inner_PyErr_GivenExceptionMatches2(err, NULL, exc_type);
25226         } else if (likely(PyTuple_Check(exc_type))) {
25227             return __Pyx_PyErr_GivenExceptionMatchesTuple(err, exc_type);
25228         } else {
25229         }
25230     }
25231     return PyErr_GivenExceptionMatches(err, exc_type);
25232 }
__Pyx_PyErr_GivenExceptionMatches2(PyObject * err,PyObject * exc_type1,PyObject * exc_type2)25233 static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches2(PyObject *err, PyObject *exc_type1, PyObject *exc_type2) {
25234     assert(PyExceptionClass_Check(exc_type1));
25235     assert(PyExceptionClass_Check(exc_type2));
25236     if (likely(err == exc_type1 || err == exc_type2)) return 1;
25237     if (likely(PyExceptionClass_Check(err))) {
25238         return __Pyx_inner_PyErr_GivenExceptionMatches2(err, exc_type1, exc_type2);
25239     }
25240     return (PyErr_GivenExceptionMatches(err, exc_type1) || PyErr_GivenExceptionMatches(err, exc_type2));
25241 }
25242 #endif
25243 
25244 /* PyIntBinop */
25245   #if !CYTHON_COMPILING_IN_PYPY
__Pyx_PyInt_AddObjC(PyObject * op1,PyObject * op2,CYTHON_UNUSED long intval,int inplace,int zerodivision_check)25246 static PyObject* __Pyx_PyInt_AddObjC(PyObject *op1, PyObject *op2, CYTHON_UNUSED long intval, int inplace, int zerodivision_check) {
25247     (void)inplace;
25248     (void)zerodivision_check;
25249     #if PY_MAJOR_VERSION < 3
25250     if (likely(PyInt_CheckExact(op1))) {
25251         const long b = intval;
25252         long x;
25253         long a = PyInt_AS_LONG(op1);
25254             x = (long)((unsigned long)a + b);
25255             if (likely((x^a) >= 0 || (x^b) >= 0))
25256                 return PyInt_FromLong(x);
25257             return PyLong_Type.tp_as_number->nb_add(op1, op2);
25258     }
25259     #endif
25260     #if CYTHON_USE_PYLONG_INTERNALS
25261     if (likely(PyLong_CheckExact(op1))) {
25262         const long b = intval;
25263         long a, x;
25264 #ifdef HAVE_LONG_LONG
25265         const PY_LONG_LONG llb = intval;
25266         PY_LONG_LONG lla, llx;
25267 #endif
25268         const digit* digits = ((PyLongObject*)op1)->ob_digit;
25269         const Py_ssize_t size = Py_SIZE(op1);
25270         if (likely(__Pyx_sst_abs(size) <= 1)) {
25271             a = likely(size) ? digits[0] : 0;
25272             if (size == -1) a = -a;
25273         } else {
25274             switch (size) {
25275                 case -2:
25276                     if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
25277                         a = -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
25278                         break;
25279 #ifdef HAVE_LONG_LONG
25280                     } else if (8 * sizeof(PY_LONG_LONG) - 1 > 2 * PyLong_SHIFT) {
25281                         lla = -(PY_LONG_LONG) (((((unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
25282                         goto long_long;
25283 #endif
25284                     }
25285                     CYTHON_FALLTHROUGH;
25286                 case 2:
25287                     if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
25288                         a = (long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
25289                         break;
25290 #ifdef HAVE_LONG_LONG
25291                     } else if (8 * sizeof(PY_LONG_LONG) - 1 > 2 * PyLong_SHIFT) {
25292                         lla = (PY_LONG_LONG) (((((unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
25293                         goto long_long;
25294 #endif
25295                     }
25296                     CYTHON_FALLTHROUGH;
25297                 case -3:
25298                     if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
25299                         a = -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
25300                         break;
25301 #ifdef HAVE_LONG_LONG
25302                     } else if (8 * sizeof(PY_LONG_LONG) - 1 > 3 * PyLong_SHIFT) {
25303                         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]));
25304                         goto long_long;
25305 #endif
25306                     }
25307                     CYTHON_FALLTHROUGH;
25308                 case 3:
25309                     if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
25310                         a = (long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
25311                         break;
25312 #ifdef HAVE_LONG_LONG
25313                     } else if (8 * sizeof(PY_LONG_LONG) - 1 > 3 * PyLong_SHIFT) {
25314                         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]));
25315                         goto long_long;
25316 #endif
25317                     }
25318                     CYTHON_FALLTHROUGH;
25319                 case -4:
25320                     if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) {
25321                         a = -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
25322                         break;
25323 #ifdef HAVE_LONG_LONG
25324                     } else if (8 * sizeof(PY_LONG_LONG) - 1 > 4 * PyLong_SHIFT) {
25325                         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]));
25326                         goto long_long;
25327 #endif
25328                     }
25329                     CYTHON_FALLTHROUGH;
25330                 case 4:
25331                     if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) {
25332                         a = (long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
25333                         break;
25334 #ifdef HAVE_LONG_LONG
25335                     } else if (8 * sizeof(PY_LONG_LONG) - 1 > 4 * PyLong_SHIFT) {
25336                         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]));
25337                         goto long_long;
25338 #endif
25339                     }
25340                     CYTHON_FALLTHROUGH;
25341                 default: return PyLong_Type.tp_as_number->nb_add(op1, op2);
25342             }
25343         }
25344                 x = a + b;
25345             return PyLong_FromLong(x);
25346 #ifdef HAVE_LONG_LONG
25347         long_long:
25348                 llx = lla + llb;
25349             return PyLong_FromLongLong(llx);
25350 #endif
25351 
25352 
25353     }
25354     #endif
25355     if (PyFloat_CheckExact(op1)) {
25356         const long b = intval;
25357         double a = PyFloat_AS_DOUBLE(op1);
25358             double result;
25359             PyFPE_START_PROTECT("add", return NULL)
25360             result = ((double)a) + (double)b;
25361             PyFPE_END_PROTECT(result)
25362             return PyFloat_FromDouble(result);
25363     }
25364     return (inplace ? PyNumber_InPlaceAdd : PyNumber_Add)(op1, op2);
25365 }
25366 #endif
25367 
25368 /* None */
__Pyx_div_long(long a,long b)25369   static CYTHON_INLINE long __Pyx_div_long(long a, long b) {
25370     long q = a / b;
25371     long r = a - q*b;
25372     q -= ((r != 0) & ((r ^ b) < 0));
25373     return q;
25374 }
25375 
25376 /* ImportFrom */
__Pyx_ImportFrom(PyObject * module,PyObject * name)25377   static PyObject* __Pyx_ImportFrom(PyObject* module, PyObject* name) {
25378     PyObject* value = __Pyx_PyObject_GetAttrStr(module, name);
25379     if (unlikely(!value) && PyErr_ExceptionMatches(PyExc_AttributeError)) {
25380         PyErr_Format(PyExc_ImportError,
25381         #if PY_MAJOR_VERSION < 3
25382             "cannot import name %.230s", PyString_AS_STRING(name));
25383         #else
25384             "cannot import name %S", name);
25385         #endif
25386     }
25387     return value;
25388 }
25389 
25390 /* HasAttr */
__Pyx_HasAttr(PyObject * o,PyObject * n)25391   static CYTHON_INLINE int __Pyx_HasAttr(PyObject *o, PyObject *n) {
25392     PyObject *r;
25393     if (unlikely(!__Pyx_PyBaseString_Check(n))) {
25394         PyErr_SetString(PyExc_TypeError,
25395                         "hasattr(): attribute name must be string");
25396         return -1;
25397     }
25398     r = __Pyx_GetAttr(o, n);
25399     if (unlikely(!r)) {
25400         PyErr_Clear();
25401         return 0;
25402     } else {
25403         Py_DECREF(r);
25404         return 1;
25405     }
25406 }
25407 
25408 /* PyObject_GenericGetAttrNoDict */
25409   #if CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP && PY_VERSION_HEX < 0x03070000
__Pyx_RaiseGenericGetAttributeError(PyTypeObject * tp,PyObject * attr_name)25410 static PyObject *__Pyx_RaiseGenericGetAttributeError(PyTypeObject *tp, PyObject *attr_name) {
25411     PyErr_Format(PyExc_AttributeError,
25412 #if PY_MAJOR_VERSION >= 3
25413                  "'%.50s' object has no attribute '%U'",
25414                  tp->tp_name, attr_name);
25415 #else
25416                  "'%.50s' object has no attribute '%.400s'",
25417                  tp->tp_name, PyString_AS_STRING(attr_name));
25418 #endif
25419     return NULL;
25420 }
__Pyx_PyObject_GenericGetAttrNoDict(PyObject * obj,PyObject * attr_name)25421 static CYTHON_INLINE PyObject* __Pyx_PyObject_GenericGetAttrNoDict(PyObject* obj, PyObject* attr_name) {
25422     PyObject *descr;
25423     PyTypeObject *tp = Py_TYPE(obj);
25424     if (unlikely(!PyString_Check(attr_name))) {
25425         return PyObject_GenericGetAttr(obj, attr_name);
25426     }
25427     assert(!tp->tp_dictoffset);
25428     descr = _PyType_Lookup(tp, attr_name);
25429     if (unlikely(!descr)) {
25430         return __Pyx_RaiseGenericGetAttributeError(tp, attr_name);
25431     }
25432     Py_INCREF(descr);
25433     #if PY_MAJOR_VERSION < 3
25434     if (likely(PyType_HasFeature(Py_TYPE(descr), Py_TPFLAGS_HAVE_CLASS)))
25435     #endif
25436     {
25437         descrgetfunc f = Py_TYPE(descr)->tp_descr_get;
25438         if (unlikely(f)) {
25439             PyObject *res = f(descr, obj, (PyObject *)tp);
25440             Py_DECREF(descr);
25441             return res;
25442         }
25443     }
25444     return descr;
25445 }
25446 #endif
25447 
25448 /* PyObject_GenericGetAttr */
25449   #if CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP && PY_VERSION_HEX < 0x03070000
__Pyx_PyObject_GenericGetAttr(PyObject * obj,PyObject * attr_name)25450 static PyObject* __Pyx_PyObject_GenericGetAttr(PyObject* obj, PyObject* attr_name) {
25451     if (unlikely(Py_TYPE(obj)->tp_dictoffset)) {
25452         return PyObject_GenericGetAttr(obj, attr_name);
25453     }
25454     return __Pyx_PyObject_GenericGetAttrNoDict(obj, attr_name);
25455 }
25456 #endif
25457 
25458 /* SetVTable */
__Pyx_SetVtable(PyObject * dict,void * vtable)25459   static int __Pyx_SetVtable(PyObject *dict, void *vtable) {
25460 #if PY_VERSION_HEX >= 0x02070000
25461     PyObject *ob = PyCapsule_New(vtable, 0, 0);
25462 #else
25463     PyObject *ob = PyCObject_FromVoidPtr(vtable, 0);
25464 #endif
25465     if (!ob)
25466         goto bad;
25467     if (PyDict_SetItem(dict, __pyx_n_s_pyx_vtable, ob) < 0)
25468         goto bad;
25469     Py_DECREF(ob);
25470     return 0;
25471 bad:
25472     Py_XDECREF(ob);
25473     return -1;
25474 }
25475 
25476 /* PyObjectGetAttrStrNoError */
__Pyx_PyObject_GetAttrStr_ClearAttributeError(void)25477   static void __Pyx_PyObject_GetAttrStr_ClearAttributeError(void) {
25478     __Pyx_PyThreadState_declare
25479     __Pyx_PyThreadState_assign
25480     if (likely(__Pyx_PyErr_ExceptionMatches(PyExc_AttributeError)))
25481         __Pyx_PyErr_Clear();
25482 }
__Pyx_PyObject_GetAttrStrNoError(PyObject * obj,PyObject * attr_name)25483 static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStrNoError(PyObject* obj, PyObject* attr_name) {
25484     PyObject *result;
25485 #if CYTHON_COMPILING_IN_CPYTHON && CYTHON_USE_TYPE_SLOTS && PY_VERSION_HEX >= 0x030700B1
25486     PyTypeObject* tp = Py_TYPE(obj);
25487     if (likely(tp->tp_getattro == PyObject_GenericGetAttr)) {
25488         return _PyObject_GenericGetAttrWithDict(obj, attr_name, NULL, 1);
25489     }
25490 #endif
25491     result = __Pyx_PyObject_GetAttrStr(obj, attr_name);
25492     if (unlikely(!result)) {
25493         __Pyx_PyObject_GetAttrStr_ClearAttributeError();
25494     }
25495     return result;
25496 }
25497 
25498 /* SetupReduce */
__Pyx_setup_reduce_is_named(PyObject * meth,PyObject * name)25499   static int __Pyx_setup_reduce_is_named(PyObject* meth, PyObject* name) {
25500   int ret;
25501   PyObject *name_attr;
25502   name_attr = __Pyx_PyObject_GetAttrStr(meth, __pyx_n_s_name_2);
25503   if (likely(name_attr)) {
25504       ret = PyObject_RichCompareBool(name_attr, name, Py_EQ);
25505   } else {
25506       ret = -1;
25507   }
25508   if (unlikely(ret < 0)) {
25509       PyErr_Clear();
25510       ret = 0;
25511   }
25512   Py_XDECREF(name_attr);
25513   return ret;
25514 }
__Pyx_setup_reduce(PyObject * type_obj)25515 static int __Pyx_setup_reduce(PyObject* type_obj) {
25516     int ret = 0;
25517     PyObject *object_reduce = NULL;
25518     PyObject *object_reduce_ex = NULL;
25519     PyObject *reduce = NULL;
25520     PyObject *reduce_ex = NULL;
25521     PyObject *reduce_cython = NULL;
25522     PyObject *setstate = NULL;
25523     PyObject *setstate_cython = NULL;
25524 #if CYTHON_USE_PYTYPE_LOOKUP
25525     if (_PyType_Lookup((PyTypeObject*)type_obj, __pyx_n_s_getstate)) goto __PYX_GOOD;
25526 #else
25527     if (PyObject_HasAttr(type_obj, __pyx_n_s_getstate)) goto __PYX_GOOD;
25528 #endif
25529 #if CYTHON_USE_PYTYPE_LOOKUP
25530     object_reduce_ex = _PyType_Lookup(&PyBaseObject_Type, __pyx_n_s_reduce_ex); if (!object_reduce_ex) goto __PYX_BAD;
25531 #else
25532     object_reduce_ex = __Pyx_PyObject_GetAttrStr((PyObject*)&PyBaseObject_Type, __pyx_n_s_reduce_ex); if (!object_reduce_ex) goto __PYX_BAD;
25533 #endif
25534     reduce_ex = __Pyx_PyObject_GetAttrStr(type_obj, __pyx_n_s_reduce_ex); if (unlikely(!reduce_ex)) goto __PYX_BAD;
25535     if (reduce_ex == object_reduce_ex) {
25536 #if CYTHON_USE_PYTYPE_LOOKUP
25537         object_reduce = _PyType_Lookup(&PyBaseObject_Type, __pyx_n_s_reduce); if (!object_reduce) goto __PYX_BAD;
25538 #else
25539         object_reduce = __Pyx_PyObject_GetAttrStr((PyObject*)&PyBaseObject_Type, __pyx_n_s_reduce); if (!object_reduce) goto __PYX_BAD;
25540 #endif
25541         reduce = __Pyx_PyObject_GetAttrStr(type_obj, __pyx_n_s_reduce); if (unlikely(!reduce)) goto __PYX_BAD;
25542         if (reduce == object_reduce || __Pyx_setup_reduce_is_named(reduce, __pyx_n_s_reduce_cython)) {
25543             reduce_cython = __Pyx_PyObject_GetAttrStrNoError(type_obj, __pyx_n_s_reduce_cython);
25544             if (likely(reduce_cython)) {
25545                 ret = PyDict_SetItem(((PyTypeObject*)type_obj)->tp_dict, __pyx_n_s_reduce, reduce_cython); if (unlikely(ret < 0)) goto __PYX_BAD;
25546                 ret = PyDict_DelItem(((PyTypeObject*)type_obj)->tp_dict, __pyx_n_s_reduce_cython); if (unlikely(ret < 0)) goto __PYX_BAD;
25547             } else if (reduce == object_reduce || PyErr_Occurred()) {
25548                 goto __PYX_BAD;
25549             }
25550             setstate = __Pyx_PyObject_GetAttrStr(type_obj, __pyx_n_s_setstate);
25551             if (!setstate) PyErr_Clear();
25552             if (!setstate || __Pyx_setup_reduce_is_named(setstate, __pyx_n_s_setstate_cython)) {
25553                 setstate_cython = __Pyx_PyObject_GetAttrStrNoError(type_obj, __pyx_n_s_setstate_cython);
25554                 if (likely(setstate_cython)) {
25555                     ret = PyDict_SetItem(((PyTypeObject*)type_obj)->tp_dict, __pyx_n_s_setstate, setstate_cython); if (unlikely(ret < 0)) goto __PYX_BAD;
25556                     ret = PyDict_DelItem(((PyTypeObject*)type_obj)->tp_dict, __pyx_n_s_setstate_cython); if (unlikely(ret < 0)) goto __PYX_BAD;
25557                 } else if (!setstate || PyErr_Occurred()) {
25558                     goto __PYX_BAD;
25559                 }
25560             }
25561             PyType_Modified((PyTypeObject*)type_obj);
25562         }
25563     }
25564     goto __PYX_GOOD;
25565 __PYX_BAD:
25566     if (!PyErr_Occurred())
25567         PyErr_Format(PyExc_RuntimeError, "Unable to initialize pickling for %s", ((PyTypeObject*)type_obj)->tp_name);
25568     ret = -1;
25569 __PYX_GOOD:
25570 #if !CYTHON_USE_PYTYPE_LOOKUP
25571     Py_XDECREF(object_reduce);
25572     Py_XDECREF(object_reduce_ex);
25573 #endif
25574     Py_XDECREF(reduce);
25575     Py_XDECREF(reduce_ex);
25576     Py_XDECREF(reduce_cython);
25577     Py_XDECREF(setstate);
25578     Py_XDECREF(setstate_cython);
25579     return ret;
25580 }
25581 
25582 /* TypeImport */
25583   #ifndef __PYX_HAVE_RT_ImportType
25584 #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)25585 static PyTypeObject *__Pyx_ImportType(PyObject *module, const char *module_name, const char *class_name,
25586     size_t size, enum __Pyx_ImportType_CheckSize check_size)
25587 {
25588     PyObject *result = 0;
25589     char warning[200];
25590     Py_ssize_t basicsize;
25591 #ifdef Py_LIMITED_API
25592     PyObject *py_basicsize;
25593 #endif
25594     result = PyObject_GetAttrString(module, class_name);
25595     if (!result)
25596         goto bad;
25597     if (!PyType_Check(result)) {
25598         PyErr_Format(PyExc_TypeError,
25599             "%.200s.%.200s is not a type object",
25600             module_name, class_name);
25601         goto bad;
25602     }
25603 #ifndef Py_LIMITED_API
25604     basicsize = ((PyTypeObject *)result)->tp_basicsize;
25605 #else
25606     py_basicsize = PyObject_GetAttrString(result, "__basicsize__");
25607     if (!py_basicsize)
25608         goto bad;
25609     basicsize = PyLong_AsSsize_t(py_basicsize);
25610     Py_DECREF(py_basicsize);
25611     py_basicsize = 0;
25612     if (basicsize == (Py_ssize_t)-1 && PyErr_Occurred())
25613         goto bad;
25614 #endif
25615     if ((size_t)basicsize < size) {
25616         PyErr_Format(PyExc_ValueError,
25617             "%.200s.%.200s size changed, may indicate binary incompatibility. "
25618             "Expected %zd from C header, got %zd from PyObject",
25619             module_name, class_name, size, basicsize);
25620         goto bad;
25621     }
25622     if (check_size == __Pyx_ImportType_CheckSize_Error && (size_t)basicsize != size) {
25623         PyErr_Format(PyExc_ValueError,
25624             "%.200s.%.200s size changed, may indicate binary incompatibility. "
25625             "Expected %zd from C header, got %zd from PyObject",
25626             module_name, class_name, size, basicsize);
25627         goto bad;
25628     }
25629     else if (check_size == __Pyx_ImportType_CheckSize_Warn && (size_t)basicsize > size) {
25630         PyOS_snprintf(warning, sizeof(warning),
25631             "%s.%s size changed, may indicate binary incompatibility. "
25632             "Expected %zd from C header, got %zd from PyObject",
25633             module_name, class_name, size, basicsize);
25634         if (PyErr_WarnEx(NULL, warning, 0) < 0) goto bad;
25635     }
25636     return (PyTypeObject *)result;
25637 bad:
25638     Py_XDECREF(result);
25639     return NULL;
25640 }
25641 #endif
25642 
25643 /* CLineInTraceback */
25644   #ifndef CYTHON_CLINE_IN_TRACEBACK
__Pyx_CLineForTraceback(CYTHON_NCP_UNUSED PyThreadState * tstate,int c_line)25645 static int __Pyx_CLineForTraceback(CYTHON_NCP_UNUSED PyThreadState *tstate, int c_line) {
25646     PyObject *use_cline;
25647     PyObject *ptype, *pvalue, *ptraceback;
25648 #if CYTHON_COMPILING_IN_CPYTHON
25649     PyObject **cython_runtime_dict;
25650 #endif
25651     if (unlikely(!__pyx_cython_runtime)) {
25652         return c_line;
25653     }
25654     __Pyx_ErrFetchInState(tstate, &ptype, &pvalue, &ptraceback);
25655 #if CYTHON_COMPILING_IN_CPYTHON
25656     cython_runtime_dict = _PyObject_GetDictPtr(__pyx_cython_runtime);
25657     if (likely(cython_runtime_dict)) {
25658         __PYX_PY_DICT_LOOKUP_IF_MODIFIED(
25659             use_cline, *cython_runtime_dict,
25660             __Pyx_PyDict_GetItemStr(*cython_runtime_dict, __pyx_n_s_cline_in_traceback))
25661     } else
25662 #endif
25663     {
25664       PyObject *use_cline_obj = __Pyx_PyObject_GetAttrStr(__pyx_cython_runtime, __pyx_n_s_cline_in_traceback);
25665       if (use_cline_obj) {
25666         use_cline = PyObject_Not(use_cline_obj) ? Py_False : Py_True;
25667         Py_DECREF(use_cline_obj);
25668       } else {
25669         PyErr_Clear();
25670         use_cline = NULL;
25671       }
25672     }
25673     if (!use_cline) {
25674         c_line = 0;
25675         PyObject_SetAttr(__pyx_cython_runtime, __pyx_n_s_cline_in_traceback, Py_False);
25676     }
25677     else if (use_cline == Py_False || (use_cline != Py_True && PyObject_Not(use_cline) != 0)) {
25678         c_line = 0;
25679     }
25680     __Pyx_ErrRestoreInState(tstate, ptype, pvalue, ptraceback);
25681     return c_line;
25682 }
25683 #endif
25684 
25685 /* CodeObjectCache */
__pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry * entries,int count,int code_line)25686   static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line) {
25687     int start = 0, mid = 0, end = count - 1;
25688     if (end >= 0 && code_line > entries[end].code_line) {
25689         return count;
25690     }
25691     while (start < end) {
25692         mid = start + (end - start) / 2;
25693         if (code_line < entries[mid].code_line) {
25694             end = mid;
25695         } else if (code_line > entries[mid].code_line) {
25696              start = mid + 1;
25697         } else {
25698             return mid;
25699         }
25700     }
25701     if (code_line <= entries[mid].code_line) {
25702         return mid;
25703     } else {
25704         return mid + 1;
25705     }
25706 }
__pyx_find_code_object(int code_line)25707 static PyCodeObject *__pyx_find_code_object(int code_line) {
25708     PyCodeObject* code_object;
25709     int pos;
25710     if (unlikely(!code_line) || unlikely(!__pyx_code_cache.entries)) {
25711         return NULL;
25712     }
25713     pos = __pyx_bisect_code_objects(__pyx_code_cache.entries, __pyx_code_cache.count, code_line);
25714     if (unlikely(pos >= __pyx_code_cache.count) || unlikely(__pyx_code_cache.entries[pos].code_line != code_line)) {
25715         return NULL;
25716     }
25717     code_object = __pyx_code_cache.entries[pos].code_object;
25718     Py_INCREF(code_object);
25719     return code_object;
25720 }
__pyx_insert_code_object(int code_line,PyCodeObject * code_object)25721 static void __pyx_insert_code_object(int code_line, PyCodeObject* code_object) {
25722     int pos, i;
25723     __Pyx_CodeObjectCacheEntry* entries = __pyx_code_cache.entries;
25724     if (unlikely(!code_line)) {
25725         return;
25726     }
25727     if (unlikely(!entries)) {
25728         entries = (__Pyx_CodeObjectCacheEntry*)PyMem_Malloc(64*sizeof(__Pyx_CodeObjectCacheEntry));
25729         if (likely(entries)) {
25730             __pyx_code_cache.entries = entries;
25731             __pyx_code_cache.max_count = 64;
25732             __pyx_code_cache.count = 1;
25733             entries[0].code_line = code_line;
25734             entries[0].code_object = code_object;
25735             Py_INCREF(code_object);
25736         }
25737         return;
25738     }
25739     pos = __pyx_bisect_code_objects(__pyx_code_cache.entries, __pyx_code_cache.count, code_line);
25740     if ((pos < __pyx_code_cache.count) && unlikely(__pyx_code_cache.entries[pos].code_line == code_line)) {
25741         PyCodeObject* tmp = entries[pos].code_object;
25742         entries[pos].code_object = code_object;
25743         Py_DECREF(tmp);
25744         return;
25745     }
25746     if (__pyx_code_cache.count == __pyx_code_cache.max_count) {
25747         int new_max = __pyx_code_cache.max_count + 64;
25748         entries = (__Pyx_CodeObjectCacheEntry*)PyMem_Realloc(
25749             __pyx_code_cache.entries, ((size_t)new_max) * sizeof(__Pyx_CodeObjectCacheEntry));
25750         if (unlikely(!entries)) {
25751             return;
25752         }
25753         __pyx_code_cache.entries = entries;
25754         __pyx_code_cache.max_count = new_max;
25755     }
25756     for (i=__pyx_code_cache.count; i>pos; i--) {
25757         entries[i] = entries[i-1];
25758     }
25759     entries[pos].code_line = code_line;
25760     entries[pos].code_object = code_object;
25761     __pyx_code_cache.count++;
25762     Py_INCREF(code_object);
25763 }
25764 
25765 /* AddTraceback */
25766   #include "compile.h"
25767 #include "frameobject.h"
25768 #include "traceback.h"
__Pyx_CreateCodeObjectForTraceback(const char * funcname,int c_line,int py_line,const char * filename)25769 static PyCodeObject* __Pyx_CreateCodeObjectForTraceback(
25770             const char *funcname, int c_line,
25771             int py_line, const char *filename) {
25772     PyCodeObject *py_code = 0;
25773     PyObject *py_srcfile = 0;
25774     PyObject *py_funcname = 0;
25775     #if PY_MAJOR_VERSION < 3
25776     py_srcfile = PyString_FromString(filename);
25777     #else
25778     py_srcfile = PyUnicode_FromString(filename);
25779     #endif
25780     if (!py_srcfile) goto bad;
25781     if (c_line) {
25782         #if PY_MAJOR_VERSION < 3
25783         py_funcname = PyString_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, c_line);
25784         #else
25785         py_funcname = PyUnicode_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, c_line);
25786         #endif
25787     }
25788     else {
25789         #if PY_MAJOR_VERSION < 3
25790         py_funcname = PyString_FromString(funcname);
25791         #else
25792         py_funcname = PyUnicode_FromString(funcname);
25793         #endif
25794     }
25795     if (!py_funcname) goto bad;
25796     py_code = __Pyx_PyCode_New(
25797         0,
25798         0,
25799         0,
25800         0,
25801         0,
25802         __pyx_empty_bytes, /*PyObject *code,*/
25803         __pyx_empty_tuple, /*PyObject *consts,*/
25804         __pyx_empty_tuple, /*PyObject *names,*/
25805         __pyx_empty_tuple, /*PyObject *varnames,*/
25806         __pyx_empty_tuple, /*PyObject *freevars,*/
25807         __pyx_empty_tuple, /*PyObject *cellvars,*/
25808         py_srcfile,   /*PyObject *filename,*/
25809         py_funcname,  /*PyObject *name,*/
25810         py_line,
25811         __pyx_empty_bytes  /*PyObject *lnotab*/
25812     );
25813     Py_DECREF(py_srcfile);
25814     Py_DECREF(py_funcname);
25815     return py_code;
25816 bad:
25817     Py_XDECREF(py_srcfile);
25818     Py_XDECREF(py_funcname);
25819     return NULL;
25820 }
__Pyx_AddTraceback(const char * funcname,int c_line,int py_line,const char * filename)25821 static void __Pyx_AddTraceback(const char *funcname, int c_line,
25822                                int py_line, const char *filename) {
25823     PyCodeObject *py_code = 0;
25824     PyFrameObject *py_frame = 0;
25825     PyThreadState *tstate = __Pyx_PyThreadState_Current;
25826     if (c_line) {
25827         c_line = __Pyx_CLineForTraceback(tstate, c_line);
25828     }
25829     py_code = __pyx_find_code_object(c_line ? -c_line : py_line);
25830     if (!py_code) {
25831         py_code = __Pyx_CreateCodeObjectForTraceback(
25832             funcname, c_line, py_line, filename);
25833         if (!py_code) goto bad;
25834         __pyx_insert_code_object(c_line ? -c_line : py_line, py_code);
25835     }
25836     py_frame = PyFrame_New(
25837         tstate,            /*PyThreadState *tstate,*/
25838         py_code,           /*PyCodeObject *code,*/
25839         __pyx_d,    /*PyObject *globals,*/
25840         0                  /*PyObject *locals*/
25841     );
25842     if (!py_frame) goto bad;
25843     __Pyx_PyFrame_SetLineNumber(py_frame, py_line);
25844     PyTraceBack_Here(py_frame);
25845 bad:
25846     Py_XDECREF(py_code);
25847     Py_XDECREF(py_frame);
25848 }
25849 
25850 #if PY_MAJOR_VERSION < 3
__Pyx_GetBuffer(PyObject * obj,Py_buffer * view,int flags)25851 static int __Pyx_GetBuffer(PyObject *obj, Py_buffer *view, int flags) {
25852     if (PyObject_CheckBuffer(obj)) return PyObject_GetBuffer(obj, view, flags);
25853         if (__Pyx_TypeCheck(obj, __pyx_array_type)) return __pyx_array_getbuffer(obj, view, flags);
25854         if (__Pyx_TypeCheck(obj, __pyx_memoryview_type)) return __pyx_memoryview_getbuffer(obj, view, flags);
25855     PyErr_Format(PyExc_TypeError, "'%.200s' does not have the buffer interface", Py_TYPE(obj)->tp_name);
25856     return -1;
25857 }
__Pyx_ReleaseBuffer(Py_buffer * view)25858 static void __Pyx_ReleaseBuffer(Py_buffer *view) {
25859     PyObject *obj = view->obj;
25860     if (!obj) return;
25861     if (PyObject_CheckBuffer(obj)) {
25862         PyBuffer_Release(view);
25863         return;
25864     }
25865     if ((0)) {}
25866     view->obj = NULL;
25867     Py_DECREF(obj);
25868 }
25869 #endif
25870 
25871 
25872   /* MemviewSliceIsContig */
25873   static int
__pyx_memviewslice_is_contig(const __Pyx_memviewslice mvs,char order,int ndim)25874 __pyx_memviewslice_is_contig(const __Pyx_memviewslice mvs, char order, int ndim)
25875 {
25876     int i, index, step, start;
25877     Py_ssize_t itemsize = mvs.memview->view.itemsize;
25878     if (order == 'F') {
25879         step = 1;
25880         start = 0;
25881     } else {
25882         step = -1;
25883         start = ndim - 1;
25884     }
25885     for (i = 0; i < ndim; i++) {
25886         index = start + step * i;
25887         if (mvs.suboffsets[index] >= 0 || mvs.strides[index] != itemsize)
25888             return 0;
25889         itemsize *= mvs.shape[index];
25890     }
25891     return 1;
25892 }
25893 
25894 /* OverlappingSlices */
25895   static void
__pyx_get_array_memory_extents(__Pyx_memviewslice * slice,void ** out_start,void ** out_end,int ndim,size_t itemsize)25896 __pyx_get_array_memory_extents(__Pyx_memviewslice *slice,
25897                                void **out_start, void **out_end,
25898                                int ndim, size_t itemsize)
25899 {
25900     char *start, *end;
25901     int i;
25902     start = end = slice->data;
25903     for (i = 0; i < ndim; i++) {
25904         Py_ssize_t stride = slice->strides[i];
25905         Py_ssize_t extent = slice->shape[i];
25906         if (extent == 0) {
25907             *out_start = *out_end = start;
25908             return;
25909         } else {
25910             if (stride > 0)
25911                 end += stride * (extent - 1);
25912             else
25913                 start += stride * (extent - 1);
25914         }
25915     }
25916     *out_start = start;
25917     *out_end = end + itemsize;
25918 }
25919 static int
__pyx_slices_overlap(__Pyx_memviewslice * slice1,__Pyx_memviewslice * slice2,int ndim,size_t itemsize)25920 __pyx_slices_overlap(__Pyx_memviewslice *slice1,
25921                      __Pyx_memviewslice *slice2,
25922                      int ndim, size_t itemsize)
25923 {
25924     void *start1, *end1, *start2, *end2;
25925     __pyx_get_array_memory_extents(slice1, &start1, &end1, ndim, itemsize);
25926     __pyx_get_array_memory_extents(slice2, &start2, &end2, ndim, itemsize);
25927     return (start1 < end2) && (start2 < end1);
25928 }
25929 
25930 /* Capsule */
25931   static CYTHON_INLINE PyObject *
__pyx_capsule_create(void * p,CYTHON_UNUSED const char * sig)25932 __pyx_capsule_create(void *p, CYTHON_UNUSED const char *sig)
25933 {
25934     PyObject *cobj;
25935 #if PY_VERSION_HEX >= 0x02070000
25936     cobj = PyCapsule_New(p, sig, NULL);
25937 #else
25938     cobj = PyCObject_FromVoidPtr(p, NULL);
25939 #endif
25940     return cobj;
25941 }
25942 
25943 /* Declarations */
25944   #if CYTHON_CCOMPLEX
25945   #ifdef __cplusplus
__pyx_t_double_complex_from_parts(double x,double y)25946     static CYTHON_INLINE __pyx_t_double_complex __pyx_t_double_complex_from_parts(double x, double y) {
25947       return ::std::complex< double >(x, y);
25948     }
25949   #else
__pyx_t_double_complex_from_parts(double x,double y)25950     static CYTHON_INLINE __pyx_t_double_complex __pyx_t_double_complex_from_parts(double x, double y) {
25951       return x + y*(__pyx_t_double_complex)_Complex_I;
25952     }
25953   #endif
25954 #else
__pyx_t_double_complex_from_parts(double x,double y)25955     static CYTHON_INLINE __pyx_t_double_complex __pyx_t_double_complex_from_parts(double x, double y) {
25956       __pyx_t_double_complex z;
25957       z.real = x;
25958       z.imag = y;
25959       return z;
25960     }
25961 #endif
25962 
25963 /* Arithmetic */
25964   #if CYTHON_CCOMPLEX
25965 #else
__Pyx_c_eq_double(__pyx_t_double_complex a,__pyx_t_double_complex b)25966     static CYTHON_INLINE int __Pyx_c_eq_double(__pyx_t_double_complex a, __pyx_t_double_complex b) {
25967        return (a.real == b.real) && (a.imag == b.imag);
25968     }
__Pyx_c_sum_double(__pyx_t_double_complex a,__pyx_t_double_complex b)25969     static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_sum_double(__pyx_t_double_complex a, __pyx_t_double_complex b) {
25970         __pyx_t_double_complex z;
25971         z.real = a.real + b.real;
25972         z.imag = a.imag + b.imag;
25973         return z;
25974     }
__Pyx_c_diff_double(__pyx_t_double_complex a,__pyx_t_double_complex b)25975     static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_diff_double(__pyx_t_double_complex a, __pyx_t_double_complex b) {
25976         __pyx_t_double_complex z;
25977         z.real = a.real - b.real;
25978         z.imag = a.imag - b.imag;
25979         return z;
25980     }
__Pyx_c_prod_double(__pyx_t_double_complex a,__pyx_t_double_complex b)25981     static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_prod_double(__pyx_t_double_complex a, __pyx_t_double_complex b) {
25982         __pyx_t_double_complex z;
25983         z.real = a.real * b.real - a.imag * b.imag;
25984         z.imag = a.real * b.imag + a.imag * b.real;
25985         return z;
25986     }
25987     #if 1
__Pyx_c_quot_double(__pyx_t_double_complex a,__pyx_t_double_complex b)25988     static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_quot_double(__pyx_t_double_complex a, __pyx_t_double_complex b) {
25989         if (b.imag == 0) {
25990             return __pyx_t_double_complex_from_parts(a.real / b.real, a.imag / b.real);
25991         } else if (fabs(b.real) >= fabs(b.imag)) {
25992             if (b.real == 0 && b.imag == 0) {
25993                 return __pyx_t_double_complex_from_parts(a.real / b.real, a.imag / b.imag);
25994             } else {
25995                 double r = b.imag / b.real;
25996                 double s = (double)(1.0) / (b.real + b.imag * r);
25997                 return __pyx_t_double_complex_from_parts(
25998                     (a.real + a.imag * r) * s, (a.imag - a.real * r) * s);
25999             }
26000         } else {
26001             double r = b.real / b.imag;
26002             double s = (double)(1.0) / (b.imag + b.real * r);
26003             return __pyx_t_double_complex_from_parts(
26004                 (a.real * r + a.imag) * s, (a.imag * r - a.real) * s);
26005         }
26006     }
26007     #else
__Pyx_c_quot_double(__pyx_t_double_complex a,__pyx_t_double_complex b)26008     static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_quot_double(__pyx_t_double_complex a, __pyx_t_double_complex b) {
26009         if (b.imag == 0) {
26010             return __pyx_t_double_complex_from_parts(a.real / b.real, a.imag / b.real);
26011         } else {
26012             double denom = b.real * b.real + b.imag * b.imag;
26013             return __pyx_t_double_complex_from_parts(
26014                 (a.real * b.real + a.imag * b.imag) / denom,
26015                 (a.imag * b.real - a.real * b.imag) / denom);
26016         }
26017     }
26018     #endif
__Pyx_c_neg_double(__pyx_t_double_complex a)26019     static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_neg_double(__pyx_t_double_complex a) {
26020         __pyx_t_double_complex z;
26021         z.real = -a.real;
26022         z.imag = -a.imag;
26023         return z;
26024     }
__Pyx_c_is_zero_double(__pyx_t_double_complex a)26025     static CYTHON_INLINE int __Pyx_c_is_zero_double(__pyx_t_double_complex a) {
26026        return (a.real == 0) && (a.imag == 0);
26027     }
__Pyx_c_conj_double(__pyx_t_double_complex a)26028     static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_conj_double(__pyx_t_double_complex a) {
26029         __pyx_t_double_complex z;
26030         z.real =  a.real;
26031         z.imag = -a.imag;
26032         return z;
26033     }
26034     #if 1
__Pyx_c_abs_double(__pyx_t_double_complex z)26035         static CYTHON_INLINE double __Pyx_c_abs_double(__pyx_t_double_complex z) {
26036           #if !defined(HAVE_HYPOT) || defined(_MSC_VER)
26037             return sqrt(z.real*z.real + z.imag*z.imag);
26038           #else
26039             return hypot(z.real, z.imag);
26040           #endif
26041         }
__Pyx_c_pow_double(__pyx_t_double_complex a,__pyx_t_double_complex b)26042         static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_pow_double(__pyx_t_double_complex a, __pyx_t_double_complex b) {
26043             __pyx_t_double_complex z;
26044             double r, lnr, theta, z_r, z_theta;
26045             if (b.imag == 0 && b.real == (int)b.real) {
26046                 if (b.real < 0) {
26047                     double denom = a.real * a.real + a.imag * a.imag;
26048                     a.real = a.real / denom;
26049                     a.imag = -a.imag / denom;
26050                     b.real = -b.real;
26051                 }
26052                 switch ((int)b.real) {
26053                     case 0:
26054                         z.real = 1;
26055                         z.imag = 0;
26056                         return z;
26057                     case 1:
26058                         return a;
26059                     case 2:
26060                         return __Pyx_c_prod_double(a, a);
26061                     case 3:
26062                         z = __Pyx_c_prod_double(a, a);
26063                         return __Pyx_c_prod_double(z, a);
26064                     case 4:
26065                         z = __Pyx_c_prod_double(a, a);
26066                         return __Pyx_c_prod_double(z, z);
26067                 }
26068             }
26069             if (a.imag == 0) {
26070                 if (a.real == 0) {
26071                     return a;
26072                 } else if (b.imag == 0) {
26073                     z.real = pow(a.real, b.real);
26074                     z.imag = 0;
26075                     return z;
26076                 } else if (a.real > 0) {
26077                     r = a.real;
26078                     theta = 0;
26079                 } else {
26080                     r = -a.real;
26081                     theta = atan2(0.0, -1.0);
26082                 }
26083             } else {
26084                 r = __Pyx_c_abs_double(a);
26085                 theta = atan2(a.imag, a.real);
26086             }
26087             lnr = log(r);
26088             z_r = exp(lnr * b.real - theta * b.imag);
26089             z_theta = theta * b.real + lnr * b.imag;
26090             z.real = z_r * cos(z_theta);
26091             z.imag = z_r * sin(z_theta);
26092             return z;
26093         }
26094     #endif
26095 #endif
26096 
26097 /* TypeInfoCompare */
26098   static int
__pyx_typeinfo_cmp(__Pyx_TypeInfo * a,__Pyx_TypeInfo * b)26099 __pyx_typeinfo_cmp(__Pyx_TypeInfo *a, __Pyx_TypeInfo *b)
26100 {
26101     int i;
26102     if (!a || !b)
26103         return 0;
26104     if (a == b)
26105         return 1;
26106     if (a->size != b->size || a->typegroup != b->typegroup ||
26107             a->is_unsigned != b->is_unsigned || a->ndim != b->ndim) {
26108         if (a->typegroup == 'H' || b->typegroup == 'H') {
26109             return a->size == b->size;
26110         } else {
26111             return 0;
26112         }
26113     }
26114     if (a->ndim) {
26115         for (i = 0; i < a->ndim; i++)
26116             if (a->arraysize[i] != b->arraysize[i])
26117                 return 0;
26118     }
26119     if (a->typegroup == 'S') {
26120         if (a->flags != b->flags)
26121             return 0;
26122         if (a->fields || b->fields) {
26123             if (!(a->fields && b->fields))
26124                 return 0;
26125             for (i = 0; a->fields[i].type && b->fields[i].type; i++) {
26126                 __Pyx_StructField *field_a = a->fields + i;
26127                 __Pyx_StructField *field_b = b->fields + i;
26128                 if (field_a->offset != field_b->offset ||
26129                     !__pyx_typeinfo_cmp(field_a->type, field_b->type))
26130                     return 0;
26131             }
26132             return !a->fields[i].type && !b->fields[i].type;
26133         }
26134     }
26135     return 1;
26136 }
26137 
26138 /* MemviewSliceValidateAndInit */
26139   static int
__pyx_check_strides(Py_buffer * buf,int dim,int ndim,int spec)26140 __pyx_check_strides(Py_buffer *buf, int dim, int ndim, int spec)
26141 {
26142     if (buf->shape[dim] <= 1)
26143         return 1;
26144     if (buf->strides) {
26145         if (spec & __Pyx_MEMVIEW_CONTIG) {
26146             if (spec & (__Pyx_MEMVIEW_PTR|__Pyx_MEMVIEW_FULL)) {
26147                 if (unlikely(buf->strides[dim] != sizeof(void *))) {
26148                     PyErr_Format(PyExc_ValueError,
26149                                  "Buffer is not indirectly contiguous "
26150                                  "in dimension %d.", dim);
26151                     goto fail;
26152                 }
26153             } else if (unlikely(buf->strides[dim] != buf->itemsize)) {
26154                 PyErr_SetString(PyExc_ValueError,
26155                                 "Buffer and memoryview are not contiguous "
26156                                 "in the same dimension.");
26157                 goto fail;
26158             }
26159         }
26160         if (spec & __Pyx_MEMVIEW_FOLLOW) {
26161             Py_ssize_t stride = buf->strides[dim];
26162             if (stride < 0)
26163                 stride = -stride;
26164             if (unlikely(stride < buf->itemsize)) {
26165                 PyErr_SetString(PyExc_ValueError,
26166                                 "Buffer and memoryview are not contiguous "
26167                                 "in the same dimension.");
26168                 goto fail;
26169             }
26170         }
26171     } else {
26172         if (unlikely(spec & __Pyx_MEMVIEW_CONTIG && dim != ndim - 1)) {
26173             PyErr_Format(PyExc_ValueError,
26174                          "C-contiguous buffer is not contiguous in "
26175                          "dimension %d", dim);
26176             goto fail;
26177         } else if (unlikely(spec & (__Pyx_MEMVIEW_PTR))) {
26178             PyErr_Format(PyExc_ValueError,
26179                          "C-contiguous buffer is not indirect in "
26180                          "dimension %d", dim);
26181             goto fail;
26182         } else if (unlikely(buf->suboffsets)) {
26183             PyErr_SetString(PyExc_ValueError,
26184                             "Buffer exposes suboffsets but no strides");
26185             goto fail;
26186         }
26187     }
26188     return 1;
26189 fail:
26190     return 0;
26191 }
26192 static int
__pyx_check_suboffsets(Py_buffer * buf,int dim,CYTHON_UNUSED int ndim,int spec)26193 __pyx_check_suboffsets(Py_buffer *buf, int dim, CYTHON_UNUSED int ndim, int spec)
26194 {
26195     if (spec & __Pyx_MEMVIEW_DIRECT) {
26196         if (unlikely(buf->suboffsets && buf->suboffsets[dim] >= 0)) {
26197             PyErr_Format(PyExc_ValueError,
26198                          "Buffer not compatible with direct access "
26199                          "in dimension %d.", dim);
26200             goto fail;
26201         }
26202     }
26203     if (spec & __Pyx_MEMVIEW_PTR) {
26204         if (unlikely(!buf->suboffsets || (buf->suboffsets[dim] < 0))) {
26205             PyErr_Format(PyExc_ValueError,
26206                          "Buffer is not indirectly accessible "
26207                          "in dimension %d.", dim);
26208             goto fail;
26209         }
26210     }
26211     return 1;
26212 fail:
26213     return 0;
26214 }
26215 static int
__pyx_verify_contig(Py_buffer * buf,int ndim,int c_or_f_flag)26216 __pyx_verify_contig(Py_buffer *buf, int ndim, int c_or_f_flag)
26217 {
26218     int i;
26219     if (c_or_f_flag & __Pyx_IS_F_CONTIG) {
26220         Py_ssize_t stride = 1;
26221         for (i = 0; i < ndim; i++) {
26222             if (unlikely(stride * buf->itemsize != buf->strides[i]  &&  buf->shape[i] > 1)) {
26223                 PyErr_SetString(PyExc_ValueError,
26224                     "Buffer not fortran contiguous.");
26225                 goto fail;
26226             }
26227             stride = stride * buf->shape[i];
26228         }
26229     } else if (c_or_f_flag & __Pyx_IS_C_CONTIG) {
26230         Py_ssize_t stride = 1;
26231         for (i = ndim - 1; i >- 1; i--) {
26232             if (unlikely(stride * buf->itemsize != buf->strides[i]  &&  buf->shape[i] > 1)) {
26233                 PyErr_SetString(PyExc_ValueError,
26234                     "Buffer not C contiguous.");
26235                 goto fail;
26236             }
26237             stride = stride * buf->shape[i];
26238         }
26239     }
26240     return 1;
26241 fail:
26242     return 0;
26243 }
__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)26244 static int __Pyx_ValidateAndInit_memviewslice(
26245                 int *axes_specs,
26246                 int c_or_f_flag,
26247                 int buf_flags,
26248                 int ndim,
26249                 __Pyx_TypeInfo *dtype,
26250                 __Pyx_BufFmt_StackElem stack[],
26251                 __Pyx_memviewslice *memviewslice,
26252                 PyObject *original_obj)
26253 {
26254     struct __pyx_memoryview_obj *memview, *new_memview;
26255     __Pyx_RefNannyDeclarations
26256     Py_buffer *buf;
26257     int i, spec = 0, retval = -1;
26258     __Pyx_BufFmt_Context ctx;
26259     int from_memoryview = __pyx_memoryview_check(original_obj);
26260     __Pyx_RefNannySetupContext("ValidateAndInit_memviewslice", 0);
26261     if (from_memoryview && __pyx_typeinfo_cmp(dtype, ((struct __pyx_memoryview_obj *)
26262                                                             original_obj)->typeinfo)) {
26263         memview = (struct __pyx_memoryview_obj *) original_obj;
26264         new_memview = NULL;
26265     } else {
26266         memview = (struct __pyx_memoryview_obj *) __pyx_memoryview_new(
26267                                             original_obj, buf_flags, 0, dtype);
26268         new_memview = memview;
26269         if (unlikely(!memview))
26270             goto fail;
26271     }
26272     buf = &memview->view;
26273     if (unlikely(buf->ndim != ndim)) {
26274         PyErr_Format(PyExc_ValueError,
26275                 "Buffer has wrong number of dimensions (expected %d, got %d)",
26276                 ndim, buf->ndim);
26277         goto fail;
26278     }
26279     if (new_memview) {
26280         __Pyx_BufFmt_Init(&ctx, stack, dtype);
26281         if (unlikely(!__Pyx_BufFmt_CheckString(&ctx, buf->format))) goto fail;
26282     }
26283     if (unlikely((unsigned) buf->itemsize != dtype->size)) {
26284         PyErr_Format(PyExc_ValueError,
26285                      "Item size of buffer (%" CYTHON_FORMAT_SSIZE_T "u byte%s) "
26286                      "does not match size of '%s' (%" CYTHON_FORMAT_SSIZE_T "u byte%s)",
26287                      buf->itemsize,
26288                      (buf->itemsize > 1) ? "s" : "",
26289                      dtype->name,
26290                      dtype->size,
26291                      (dtype->size > 1) ? "s" : "");
26292         goto fail;
26293     }
26294     if (buf->len > 0) {
26295         for (i = 0; i < ndim; i++) {
26296             spec = axes_specs[i];
26297             if (unlikely(!__pyx_check_strides(buf, i, ndim, spec)))
26298                 goto fail;
26299             if (unlikely(!__pyx_check_suboffsets(buf, i, ndim, spec)))
26300                 goto fail;
26301         }
26302         if (unlikely(buf->strides && !__pyx_verify_contig(buf, ndim, c_or_f_flag)))
26303             goto fail;
26304     }
26305     if (unlikely(__Pyx_init_memviewslice(memview, ndim, memviewslice,
26306                                          new_memview != NULL) == -1)) {
26307         goto fail;
26308     }
26309     retval = 0;
26310     goto no_fail;
26311 fail:
26312     Py_XDECREF(new_memview);
26313     retval = -1;
26314 no_fail:
26315     __Pyx_RefNannyFinishContext();
26316     return retval;
26317 }
26318 
26319 /* ObjectToMemviewSlice */
__Pyx_PyObject_to_MemoryviewSlice_d_dc_int(PyObject * obj,int writable_flag)26320   static CYTHON_INLINE __Pyx_memviewslice __Pyx_PyObject_to_MemoryviewSlice_d_dc_int(PyObject *obj, int writable_flag) {
26321     __Pyx_memviewslice result = { 0, 0, { 0 }, { 0 }, { 0 } };
26322     __Pyx_BufFmt_StackElem stack[1];
26323     int axes_specs[] = { (__Pyx_MEMVIEW_DIRECT | __Pyx_MEMVIEW_FOLLOW), (__Pyx_MEMVIEW_DIRECT | __Pyx_MEMVIEW_CONTIG) };
26324     int retcode;
26325     if (obj == Py_None) {
26326         result.memview = (struct __pyx_memoryview_obj *) Py_None;
26327         return result;
26328     }
26329     retcode = __Pyx_ValidateAndInit_memviewslice(axes_specs, __Pyx_IS_C_CONTIG,
26330                                                  (PyBUF_C_CONTIGUOUS | PyBUF_FORMAT) | writable_flag, 2,
26331                                                  &__Pyx_TypeInfo_int, stack,
26332                                                  &result, obj);
26333     if (unlikely(retcode == -1))
26334         goto __pyx_fail;
26335     return result;
26336 __pyx_fail:
26337     result.memview = NULL;
26338     result.data = NULL;
26339     return result;
26340 }
26341 
26342 /* ObjectToMemviewSlice */
__Pyx_PyObject_to_MemoryviewSlice_dc_int(PyObject * obj,int writable_flag)26343   static CYTHON_INLINE __Pyx_memviewslice __Pyx_PyObject_to_MemoryviewSlice_dc_int(PyObject *obj, int writable_flag) {
26344     __Pyx_memviewslice result = { 0, 0, { 0 }, { 0 }, { 0 } };
26345     __Pyx_BufFmt_StackElem stack[1];
26346     int axes_specs[] = { (__Pyx_MEMVIEW_DIRECT | __Pyx_MEMVIEW_CONTIG) };
26347     int retcode;
26348     if (obj == Py_None) {
26349         result.memview = (struct __pyx_memoryview_obj *) Py_None;
26350         return result;
26351     }
26352     retcode = __Pyx_ValidateAndInit_memviewslice(axes_specs, __Pyx_IS_C_CONTIG,
26353                                                  (PyBUF_C_CONTIGUOUS | PyBUF_FORMAT) | writable_flag, 1,
26354                                                  &__Pyx_TypeInfo_int, stack,
26355                                                  &result, obj);
26356     if (unlikely(retcode == -1))
26357         goto __pyx_fail;
26358     return result;
26359 __pyx_fail:
26360     result.memview = NULL;
26361     result.data = NULL;
26362     return result;
26363 }
26364 
26365 /* CIntFromPyVerify */
26366   #define __PYX_VERIFY_RETURN_INT(target_type, func_type, func_value)\
26367     __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, 0)
26368 #define __PYX_VERIFY_RETURN_INT_EXC(target_type, func_type, func_value)\
26369     __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, 1)
26370 #define __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, exc)\
26371     {\
26372         func_type value = func_value;\
26373         if (sizeof(target_type) < sizeof(func_type)) {\
26374             if (unlikely(value != (func_type) (target_type) value)) {\
26375                 func_type zero = 0;\
26376                 if (exc && unlikely(value == (func_type)-1 && PyErr_Occurred()))\
26377                     return (target_type) -1;\
26378                 if (is_unsigned && unlikely(value < zero))\
26379                     goto raise_neg_overflow;\
26380                 else\
26381                     goto raise_overflow;\
26382             }\
26383         }\
26384         return (target_type) value;\
26385     }
26386 
26387 /* MemviewDtypeToObject */
__pyx_memview_get_int(const char * itemp)26388   static CYTHON_INLINE PyObject *__pyx_memview_get_int(const char *itemp) {
26389     return (PyObject *) __Pyx_PyInt_From_int(*(int *) itemp);
26390 }
__pyx_memview_set_int(const char * itemp,PyObject * obj)26391 static CYTHON_INLINE int __pyx_memview_set_int(const char *itemp, PyObject *obj) {
26392     int value = __Pyx_PyInt_As_int(obj);
26393     if ((value == (int)-1) && PyErr_Occurred())
26394         return 0;
26395     *(int *) itemp = value;
26396     return 1;
26397 }
26398 
26399 /* None */
__Pyx_pow_long(long b,long e)26400   static CYTHON_INLINE long __Pyx_pow_long(long b, long e) {
26401     long t = b;
26402     switch (e) {
26403         case 3:
26404             t *= b;
26405         CYTHON_FALLTHROUGH;
26406         case 2:
26407             t *= b;
26408         CYTHON_FALLTHROUGH;
26409         case 1:
26410             return t;
26411         case 0:
26412             return 1;
26413     }
26414     #if 1
26415     if (unlikely(e<0)) return 0;
26416     #endif
26417     t = 1;
26418     while (likely(e)) {
26419         t *= (b * (e&1)) | ((~e)&1);
26420         b *= b;
26421         e >>= 1;
26422     }
26423     return t;
26424 }
26425 
26426 /* FromPy */
__Pyx_PyComplex_As___pyx_t_double_complex(PyObject * o)26427   static __pyx_t_double_complex __Pyx_PyComplex_As___pyx_t_double_complex(PyObject* o) {
26428     Py_complex cval;
26429 #if !CYTHON_COMPILING_IN_PYPY
26430     if (PyComplex_CheckExact(o))
26431         cval = ((PyComplexObject *)o)->cval;
26432     else
26433 #endif
26434         cval = PyComplex_AsCComplex(o);
26435     return __pyx_t_double_complex_from_parts(
26436                (double)cval.real,
26437                (double)cval.imag);
26438 }
26439 
26440 /* MemviewDtypeToObject */
__pyx_memview_get___pyx_t_double_complex(const char * itemp)26441   static CYTHON_INLINE PyObject *__pyx_memview_get___pyx_t_double_complex(const char *itemp) {
26442     return (PyObject *) __pyx_PyComplex_FromComplex(*(__pyx_t_double_complex *) itemp);
26443 }
__pyx_memview_set___pyx_t_double_complex(const char * itemp,PyObject * obj)26444 static CYTHON_INLINE int __pyx_memview_set___pyx_t_double_complex(const char *itemp, PyObject *obj) {
26445     __pyx_t_double_complex value = __Pyx_PyComplex_As___pyx_t_double_complex(obj);
26446     if (PyErr_Occurred())
26447         return 0;
26448     *(__pyx_t_double_complex *) itemp = value;
26449     return 1;
26450 }
26451 
26452 /* Declarations */
26453   #if CYTHON_CCOMPLEX
26454   #ifdef __cplusplus
__pyx_t_float_complex_from_parts(float x,float y)26455     static CYTHON_INLINE __pyx_t_float_complex __pyx_t_float_complex_from_parts(float x, float y) {
26456       return ::std::complex< float >(x, y);
26457     }
26458   #else
__pyx_t_float_complex_from_parts(float x,float y)26459     static CYTHON_INLINE __pyx_t_float_complex __pyx_t_float_complex_from_parts(float x, float y) {
26460       return x + y*(__pyx_t_float_complex)_Complex_I;
26461     }
26462   #endif
26463 #else
__pyx_t_float_complex_from_parts(float x,float y)26464     static CYTHON_INLINE __pyx_t_float_complex __pyx_t_float_complex_from_parts(float x, float y) {
26465       __pyx_t_float_complex z;
26466       z.real = x;
26467       z.imag = y;
26468       return z;
26469     }
26470 #endif
26471 
26472 /* Arithmetic */
26473   #if CYTHON_CCOMPLEX
26474 #else
__Pyx_c_eq_float(__pyx_t_float_complex a,__pyx_t_float_complex b)26475     static CYTHON_INLINE int __Pyx_c_eq_float(__pyx_t_float_complex a, __pyx_t_float_complex b) {
26476        return (a.real == b.real) && (a.imag == b.imag);
26477     }
__Pyx_c_sum_float(__pyx_t_float_complex a,__pyx_t_float_complex b)26478     static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_sum_float(__pyx_t_float_complex a, __pyx_t_float_complex b) {
26479         __pyx_t_float_complex z;
26480         z.real = a.real + b.real;
26481         z.imag = a.imag + b.imag;
26482         return z;
26483     }
__Pyx_c_diff_float(__pyx_t_float_complex a,__pyx_t_float_complex b)26484     static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_diff_float(__pyx_t_float_complex a, __pyx_t_float_complex b) {
26485         __pyx_t_float_complex z;
26486         z.real = a.real - b.real;
26487         z.imag = a.imag - b.imag;
26488         return z;
26489     }
__Pyx_c_prod_float(__pyx_t_float_complex a,__pyx_t_float_complex b)26490     static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_prod_float(__pyx_t_float_complex a, __pyx_t_float_complex b) {
26491         __pyx_t_float_complex z;
26492         z.real = a.real * b.real - a.imag * b.imag;
26493         z.imag = a.real * b.imag + a.imag * b.real;
26494         return z;
26495     }
26496     #if 1
__Pyx_c_quot_float(__pyx_t_float_complex a,__pyx_t_float_complex b)26497     static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_quot_float(__pyx_t_float_complex a, __pyx_t_float_complex b) {
26498         if (b.imag == 0) {
26499             return __pyx_t_float_complex_from_parts(a.real / b.real, a.imag / b.real);
26500         } else if (fabsf(b.real) >= fabsf(b.imag)) {
26501             if (b.real == 0 && b.imag == 0) {
26502                 return __pyx_t_float_complex_from_parts(a.real / b.real, a.imag / b.imag);
26503             } else {
26504                 float r = b.imag / b.real;
26505                 float s = (float)(1.0) / (b.real + b.imag * r);
26506                 return __pyx_t_float_complex_from_parts(
26507                     (a.real + a.imag * r) * s, (a.imag - a.real * r) * s);
26508             }
26509         } else {
26510             float r = b.real / b.imag;
26511             float s = (float)(1.0) / (b.imag + b.real * r);
26512             return __pyx_t_float_complex_from_parts(
26513                 (a.real * r + a.imag) * s, (a.imag * r - a.real) * s);
26514         }
26515     }
26516     #else
__Pyx_c_quot_float(__pyx_t_float_complex a,__pyx_t_float_complex b)26517     static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_quot_float(__pyx_t_float_complex a, __pyx_t_float_complex b) {
26518         if (b.imag == 0) {
26519             return __pyx_t_float_complex_from_parts(a.real / b.real, a.imag / b.real);
26520         } else {
26521             float denom = b.real * b.real + b.imag * b.imag;
26522             return __pyx_t_float_complex_from_parts(
26523                 (a.real * b.real + a.imag * b.imag) / denom,
26524                 (a.imag * b.real - a.real * b.imag) / denom);
26525         }
26526     }
26527     #endif
__Pyx_c_neg_float(__pyx_t_float_complex a)26528     static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_neg_float(__pyx_t_float_complex a) {
26529         __pyx_t_float_complex z;
26530         z.real = -a.real;
26531         z.imag = -a.imag;
26532         return z;
26533     }
__Pyx_c_is_zero_float(__pyx_t_float_complex a)26534     static CYTHON_INLINE int __Pyx_c_is_zero_float(__pyx_t_float_complex a) {
26535        return (a.real == 0) && (a.imag == 0);
26536     }
__Pyx_c_conj_float(__pyx_t_float_complex a)26537     static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_conj_float(__pyx_t_float_complex a) {
26538         __pyx_t_float_complex z;
26539         z.real =  a.real;
26540         z.imag = -a.imag;
26541         return z;
26542     }
26543     #if 1
__Pyx_c_abs_float(__pyx_t_float_complex z)26544         static CYTHON_INLINE float __Pyx_c_abs_float(__pyx_t_float_complex z) {
26545           #if !defined(HAVE_HYPOT) || defined(_MSC_VER)
26546             return sqrtf(z.real*z.real + z.imag*z.imag);
26547           #else
26548             return hypotf(z.real, z.imag);
26549           #endif
26550         }
__Pyx_c_pow_float(__pyx_t_float_complex a,__pyx_t_float_complex b)26551         static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_pow_float(__pyx_t_float_complex a, __pyx_t_float_complex b) {
26552             __pyx_t_float_complex z;
26553             float r, lnr, theta, z_r, z_theta;
26554             if (b.imag == 0 && b.real == (int)b.real) {
26555                 if (b.real < 0) {
26556                     float denom = a.real * a.real + a.imag * a.imag;
26557                     a.real = a.real / denom;
26558                     a.imag = -a.imag / denom;
26559                     b.real = -b.real;
26560                 }
26561                 switch ((int)b.real) {
26562                     case 0:
26563                         z.real = 1;
26564                         z.imag = 0;
26565                         return z;
26566                     case 1:
26567                         return a;
26568                     case 2:
26569                         return __Pyx_c_prod_float(a, a);
26570                     case 3:
26571                         z = __Pyx_c_prod_float(a, a);
26572                         return __Pyx_c_prod_float(z, a);
26573                     case 4:
26574                         z = __Pyx_c_prod_float(a, a);
26575                         return __Pyx_c_prod_float(z, z);
26576                 }
26577             }
26578             if (a.imag == 0) {
26579                 if (a.real == 0) {
26580                     return a;
26581                 } else if (b.imag == 0) {
26582                     z.real = powf(a.real, b.real);
26583                     z.imag = 0;
26584                     return z;
26585                 } else if (a.real > 0) {
26586                     r = a.real;
26587                     theta = 0;
26588                 } else {
26589                     r = -a.real;
26590                     theta = atan2f(0.0, -1.0);
26591                 }
26592             } else {
26593                 r = __Pyx_c_abs_float(a);
26594                 theta = atan2f(a.imag, a.real);
26595             }
26596             lnr = logf(r);
26597             z_r = expf(lnr * b.real - theta * b.imag);
26598             z_theta = theta * b.real + lnr * b.imag;
26599             z.real = z_r * cosf(z_theta);
26600             z.imag = z_r * sinf(z_theta);
26601             return z;
26602         }
26603     #endif
26604 #endif
26605 
26606 /* MemviewSliceCopyTemplate */
26607   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)26608 __pyx_memoryview_copy_new_contig(const __Pyx_memviewslice *from_mvs,
26609                                  const char *mode, int ndim,
26610                                  size_t sizeof_dtype, int contig_flag,
26611                                  int dtype_is_object)
26612 {
26613     __Pyx_RefNannyDeclarations
26614     int i;
26615     __Pyx_memviewslice new_mvs = { 0, 0, { 0 }, { 0 }, { 0 } };
26616     struct __pyx_memoryview_obj *from_memview = from_mvs->memview;
26617     Py_buffer *buf = &from_memview->view;
26618     PyObject *shape_tuple = NULL;
26619     PyObject *temp_int = NULL;
26620     struct __pyx_array_obj *array_obj = NULL;
26621     struct __pyx_memoryview_obj *memview_obj = NULL;
26622     __Pyx_RefNannySetupContext("__pyx_memoryview_copy_new_contig", 0);
26623     for (i = 0; i < ndim; i++) {
26624         if (unlikely(from_mvs->suboffsets[i] >= 0)) {
26625             PyErr_Format(PyExc_ValueError, "Cannot copy memoryview slice with "
26626                                            "indirect dimensions (axis %d)", i);
26627             goto fail;
26628         }
26629     }
26630     shape_tuple = PyTuple_New(ndim);
26631     if (unlikely(!shape_tuple)) {
26632         goto fail;
26633     }
26634     __Pyx_GOTREF(shape_tuple);
26635     for(i = 0; i < ndim; i++) {
26636         temp_int = PyInt_FromSsize_t(from_mvs->shape[i]);
26637         if(unlikely(!temp_int)) {
26638             goto fail;
26639         } else {
26640             PyTuple_SET_ITEM(shape_tuple, i, temp_int);
26641             temp_int = NULL;
26642         }
26643     }
26644     array_obj = __pyx_array_new(shape_tuple, sizeof_dtype, buf->format, (char *) mode, NULL);
26645     if (unlikely(!array_obj)) {
26646         goto fail;
26647     }
26648     __Pyx_GOTREF(array_obj);
26649     memview_obj = (struct __pyx_memoryview_obj *) __pyx_memoryview_new(
26650                                     (PyObject *) array_obj, contig_flag,
26651                                     dtype_is_object,
26652                                     from_mvs->memview->typeinfo);
26653     if (unlikely(!memview_obj))
26654         goto fail;
26655     if (unlikely(__Pyx_init_memviewslice(memview_obj, ndim, &new_mvs, 1) < 0))
26656         goto fail;
26657     if (unlikely(__pyx_memoryview_copy_contents(*from_mvs, new_mvs, ndim, ndim,
26658                                                 dtype_is_object) < 0))
26659         goto fail;
26660     goto no_fail;
26661 fail:
26662     __Pyx_XDECREF(new_mvs.memview);
26663     new_mvs.memview = NULL;
26664     new_mvs.data = NULL;
26665 no_fail:
26666     __Pyx_XDECREF(shape_tuple);
26667     __Pyx_XDECREF(temp_int);
26668     __Pyx_XDECREF(array_obj);
26669     __Pyx_RefNannyFinishContext();
26670     return new_mvs;
26671 }
26672 
26673 /* CIntFromPy */
__Pyx_PyInt_As_int(PyObject * x)26674   static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *x) {
26675 #ifdef __Pyx_HAS_GCC_DIAGNOSTIC
26676 #pragma GCC diagnostic push
26677 #pragma GCC diagnostic ignored "-Wconversion"
26678 #endif
26679     const int neg_one = (int) -1, const_zero = (int) 0;
26680 #ifdef __Pyx_HAS_GCC_DIAGNOSTIC
26681 #pragma GCC diagnostic pop
26682 #endif
26683     const int is_unsigned = neg_one > const_zero;
26684 #if PY_MAJOR_VERSION < 3
26685     if (likely(PyInt_Check(x))) {
26686         if (sizeof(int) < sizeof(long)) {
26687             __PYX_VERIFY_RETURN_INT(int, long, PyInt_AS_LONG(x))
26688         } else {
26689             long val = PyInt_AS_LONG(x);
26690             if (is_unsigned && unlikely(val < 0)) {
26691                 goto raise_neg_overflow;
26692             }
26693             return (int) val;
26694         }
26695     } else
26696 #endif
26697     if (likely(PyLong_Check(x))) {
26698         if (is_unsigned) {
26699 #if CYTHON_USE_PYLONG_INTERNALS
26700             const digit* digits = ((PyLongObject*)x)->ob_digit;
26701             switch (Py_SIZE(x)) {
26702                 case  0: return (int) 0;
26703                 case  1: __PYX_VERIFY_RETURN_INT(int, digit, digits[0])
26704                 case 2:
26705                     if (8 * sizeof(int) > 1 * PyLong_SHIFT) {
26706                         if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
26707                             __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
26708                         } else if (8 * sizeof(int) >= 2 * PyLong_SHIFT) {
26709                             return (int) (((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0]));
26710                         }
26711                     }
26712                     break;
26713                 case 3:
26714                     if (8 * sizeof(int) > 2 * PyLong_SHIFT) {
26715                         if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
26716                             __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
26717                         } else if (8 * sizeof(int) >= 3 * PyLong_SHIFT) {
26718                             return (int) (((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]));
26719                         }
26720                     }
26721                     break;
26722                 case 4:
26723                     if (8 * sizeof(int) > 3 * PyLong_SHIFT) {
26724                         if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
26725                             __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])))
26726                         } else if (8 * sizeof(int) >= 4 * PyLong_SHIFT) {
26727                             return (int) (((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]));
26728                         }
26729                     }
26730                     break;
26731             }
26732 #endif
26733 #if CYTHON_COMPILING_IN_CPYTHON
26734             if (unlikely(Py_SIZE(x) < 0)) {
26735                 goto raise_neg_overflow;
26736             }
26737 #else
26738             {
26739                 int result = PyObject_RichCompareBool(x, Py_False, Py_LT);
26740                 if (unlikely(result < 0))
26741                     return (int) -1;
26742                 if (unlikely(result == 1))
26743                     goto raise_neg_overflow;
26744             }
26745 #endif
26746             if (sizeof(int) <= sizeof(unsigned long)) {
26747                 __PYX_VERIFY_RETURN_INT_EXC(int, unsigned long, PyLong_AsUnsignedLong(x))
26748 #ifdef HAVE_LONG_LONG
26749             } else if (sizeof(int) <= sizeof(unsigned PY_LONG_LONG)) {
26750                 __PYX_VERIFY_RETURN_INT_EXC(int, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x))
26751 #endif
26752             }
26753         } else {
26754 #if CYTHON_USE_PYLONG_INTERNALS
26755             const digit* digits = ((PyLongObject*)x)->ob_digit;
26756             switch (Py_SIZE(x)) {
26757                 case  0: return (int) 0;
26758                 case -1: __PYX_VERIFY_RETURN_INT(int, sdigit, (sdigit) (-(sdigit)digits[0]))
26759                 case  1: __PYX_VERIFY_RETURN_INT(int,  digit, +digits[0])
26760                 case -2:
26761                     if (8 * sizeof(int) - 1 > 1 * PyLong_SHIFT) {
26762                         if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
26763                             __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
26764                         } else if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) {
26765                             return (int) (((int)-1)*(((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
26766                         }
26767                     }
26768                     break;
26769                 case 2:
26770                     if (8 * sizeof(int) > 1 * PyLong_SHIFT) {
26771                         if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
26772                             __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
26773                         } else if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) {
26774                             return (int) ((((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
26775                         }
26776                     }
26777                     break;
26778                 case -3:
26779                     if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) {
26780                         if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
26781                             __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
26782                         } else if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) {
26783                             return (int) (((int)-1)*(((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
26784                         }
26785                     }
26786                     break;
26787                 case 3:
26788                     if (8 * sizeof(int) > 2 * PyLong_SHIFT) {
26789                         if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
26790                             __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
26791                         } else if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) {
26792                             return (int) ((((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
26793                         }
26794                     }
26795                     break;
26796                 case -4:
26797                     if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) {
26798                         if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
26799                             __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])))
26800                         } else if (8 * sizeof(int) - 1 > 4 * PyLong_SHIFT) {
26801                             return (int) (((int)-1)*(((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
26802                         }
26803                     }
26804                     break;
26805                 case 4:
26806                     if (8 * sizeof(int) > 3 * PyLong_SHIFT) {
26807                         if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
26808                             __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])))
26809                         } else if (8 * sizeof(int) - 1 > 4 * PyLong_SHIFT) {
26810                             return (int) ((((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
26811                         }
26812                     }
26813                     break;
26814             }
26815 #endif
26816             if (sizeof(int) <= sizeof(long)) {
26817                 __PYX_VERIFY_RETURN_INT_EXC(int, long, PyLong_AsLong(x))
26818 #ifdef HAVE_LONG_LONG
26819             } else if (sizeof(int) <= sizeof(PY_LONG_LONG)) {
26820                 __PYX_VERIFY_RETURN_INT_EXC(int, PY_LONG_LONG, PyLong_AsLongLong(x))
26821 #endif
26822             }
26823         }
26824         {
26825 #if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray)
26826             PyErr_SetString(PyExc_RuntimeError,
26827                             "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers");
26828 #else
26829             int val;
26830             PyObject *v = __Pyx_PyNumber_IntOrLong(x);
26831  #if PY_MAJOR_VERSION < 3
26832             if (likely(v) && !PyLong_Check(v)) {
26833                 PyObject *tmp = v;
26834                 v = PyNumber_Long(tmp);
26835                 Py_DECREF(tmp);
26836             }
26837  #endif
26838             if (likely(v)) {
26839                 int one = 1; int is_little = (int)*(unsigned char *)&one;
26840                 unsigned char *bytes = (unsigned char *)&val;
26841                 int ret = _PyLong_AsByteArray((PyLongObject *)v,
26842                                               bytes, sizeof(val),
26843                                               is_little, !is_unsigned);
26844                 Py_DECREF(v);
26845                 if (likely(!ret))
26846                     return val;
26847             }
26848 #endif
26849             return (int) -1;
26850         }
26851     } else {
26852         int val;
26853         PyObject *tmp = __Pyx_PyNumber_IntOrLong(x);
26854         if (!tmp) return (int) -1;
26855         val = __Pyx_PyInt_As_int(tmp);
26856         Py_DECREF(tmp);
26857         return val;
26858     }
26859 raise_overflow:
26860     PyErr_SetString(PyExc_OverflowError,
26861         "value too large to convert to int");
26862     return (int) -1;
26863 raise_neg_overflow:
26864     PyErr_SetString(PyExc_OverflowError,
26865         "can't convert negative value to int");
26866     return (int) -1;
26867 }
26868 
26869 /* CIntToPy */
__Pyx_PyInt_From_long(long value)26870   static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value) {
26871 #ifdef __Pyx_HAS_GCC_DIAGNOSTIC
26872 #pragma GCC diagnostic push
26873 #pragma GCC diagnostic ignored "-Wconversion"
26874 #endif
26875     const long neg_one = (long) -1, const_zero = (long) 0;
26876 #ifdef __Pyx_HAS_GCC_DIAGNOSTIC
26877 #pragma GCC diagnostic pop
26878 #endif
26879     const int is_unsigned = neg_one > const_zero;
26880     if (is_unsigned) {
26881         if (sizeof(long) < sizeof(long)) {
26882             return PyInt_FromLong((long) value);
26883         } else if (sizeof(long) <= sizeof(unsigned long)) {
26884             return PyLong_FromUnsignedLong((unsigned long) value);
26885 #ifdef HAVE_LONG_LONG
26886         } else if (sizeof(long) <= sizeof(unsigned PY_LONG_LONG)) {
26887             return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value);
26888 #endif
26889         }
26890     } else {
26891         if (sizeof(long) <= sizeof(long)) {
26892             return PyInt_FromLong((long) value);
26893 #ifdef HAVE_LONG_LONG
26894         } else if (sizeof(long) <= sizeof(PY_LONG_LONG)) {
26895             return PyLong_FromLongLong((PY_LONG_LONG) value);
26896 #endif
26897         }
26898     }
26899     {
26900         int one = 1; int little = (int)*(unsigned char *)&one;
26901         unsigned char *bytes = (unsigned char *)&value;
26902         return _PyLong_FromByteArray(bytes, sizeof(long),
26903                                      little, !is_unsigned);
26904     }
26905 }
26906 
26907 /* CIntFromPy */
__Pyx_PyInt_As_size_t(PyObject * x)26908   static CYTHON_INLINE size_t __Pyx_PyInt_As_size_t(PyObject *x) {
26909 #ifdef __Pyx_HAS_GCC_DIAGNOSTIC
26910 #pragma GCC diagnostic push
26911 #pragma GCC diagnostic ignored "-Wconversion"
26912 #endif
26913     const size_t neg_one = (size_t) -1, const_zero = (size_t) 0;
26914 #ifdef __Pyx_HAS_GCC_DIAGNOSTIC
26915 #pragma GCC diagnostic pop
26916 #endif
26917     const int is_unsigned = neg_one > const_zero;
26918 #if PY_MAJOR_VERSION < 3
26919     if (likely(PyInt_Check(x))) {
26920         if (sizeof(size_t) < sizeof(long)) {
26921             __PYX_VERIFY_RETURN_INT(size_t, long, PyInt_AS_LONG(x))
26922         } else {
26923             long val = PyInt_AS_LONG(x);
26924             if (is_unsigned && unlikely(val < 0)) {
26925                 goto raise_neg_overflow;
26926             }
26927             return (size_t) val;
26928         }
26929     } else
26930 #endif
26931     if (likely(PyLong_Check(x))) {
26932         if (is_unsigned) {
26933 #if CYTHON_USE_PYLONG_INTERNALS
26934             const digit* digits = ((PyLongObject*)x)->ob_digit;
26935             switch (Py_SIZE(x)) {
26936                 case  0: return (size_t) 0;
26937                 case  1: __PYX_VERIFY_RETURN_INT(size_t, digit, digits[0])
26938                 case 2:
26939                     if (8 * sizeof(size_t) > 1 * PyLong_SHIFT) {
26940                         if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
26941                             __PYX_VERIFY_RETURN_INT(size_t, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
26942                         } else if (8 * sizeof(size_t) >= 2 * PyLong_SHIFT) {
26943                             return (size_t) (((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
26944                         }
26945                     }
26946                     break;
26947                 case 3:
26948                     if (8 * sizeof(size_t) > 2 * PyLong_SHIFT) {
26949                         if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
26950                             __PYX_VERIFY_RETURN_INT(size_t, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
26951                         } else if (8 * sizeof(size_t) >= 3 * PyLong_SHIFT) {
26952                             return (size_t) (((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
26953                         }
26954                     }
26955                     break;
26956                 case 4:
26957                     if (8 * sizeof(size_t) > 3 * PyLong_SHIFT) {
26958                         if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
26959                             __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])))
26960                         } else if (8 * sizeof(size_t) >= 4 * PyLong_SHIFT) {
26961                             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]));
26962                         }
26963                     }
26964                     break;
26965             }
26966 #endif
26967 #if CYTHON_COMPILING_IN_CPYTHON
26968             if (unlikely(Py_SIZE(x) < 0)) {
26969                 goto raise_neg_overflow;
26970             }
26971 #else
26972             {
26973                 int result = PyObject_RichCompareBool(x, Py_False, Py_LT);
26974                 if (unlikely(result < 0))
26975                     return (size_t) -1;
26976                 if (unlikely(result == 1))
26977                     goto raise_neg_overflow;
26978             }
26979 #endif
26980             if (sizeof(size_t) <= sizeof(unsigned long)) {
26981                 __PYX_VERIFY_RETURN_INT_EXC(size_t, unsigned long, PyLong_AsUnsignedLong(x))
26982 #ifdef HAVE_LONG_LONG
26983             } else if (sizeof(size_t) <= sizeof(unsigned PY_LONG_LONG)) {
26984                 __PYX_VERIFY_RETURN_INT_EXC(size_t, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x))
26985 #endif
26986             }
26987         } else {
26988 #if CYTHON_USE_PYLONG_INTERNALS
26989             const digit* digits = ((PyLongObject*)x)->ob_digit;
26990             switch (Py_SIZE(x)) {
26991                 case  0: return (size_t) 0;
26992                 case -1: __PYX_VERIFY_RETURN_INT(size_t, sdigit, (sdigit) (-(sdigit)digits[0]))
26993                 case  1: __PYX_VERIFY_RETURN_INT(size_t,  digit, +digits[0])
26994                 case -2:
26995                     if (8 * sizeof(size_t) - 1 > 1 * PyLong_SHIFT) {
26996                         if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
26997                             __PYX_VERIFY_RETURN_INT(size_t, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
26998                         } else if (8 * sizeof(size_t) - 1 > 2 * PyLong_SHIFT) {
26999                             return (size_t) (((size_t)-1)*(((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])));
27000                         }
27001                     }
27002                     break;
27003                 case 2:
27004                     if (8 * sizeof(size_t) > 1 * PyLong_SHIFT) {
27005                         if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
27006                             __PYX_VERIFY_RETURN_INT(size_t, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
27007                         } else if (8 * sizeof(size_t) - 1 > 2 * PyLong_SHIFT) {
27008                             return (size_t) ((((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])));
27009                         }
27010                     }
27011                     break;
27012                 case -3:
27013                     if (8 * sizeof(size_t) - 1 > 2 * PyLong_SHIFT) {
27014                         if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
27015                             __PYX_VERIFY_RETURN_INT(size_t, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
27016                         } else if (8 * sizeof(size_t) - 1 > 3 * PyLong_SHIFT) {
27017                             return (size_t) (((size_t)-1)*(((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])));
27018                         }
27019                     }
27020                     break;
27021                 case 3:
27022                     if (8 * sizeof(size_t) > 2 * PyLong_SHIFT) {
27023                         if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
27024                             __PYX_VERIFY_RETURN_INT(size_t, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
27025                         } else if (8 * sizeof(size_t) - 1 > 3 * PyLong_SHIFT) {
27026                             return (size_t) ((((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])));
27027                         }
27028                     }
27029                     break;
27030                 case -4:
27031                     if (8 * sizeof(size_t) - 1 > 3 * PyLong_SHIFT) {
27032                         if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
27033                             __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])))
27034                         } else if (8 * sizeof(size_t) - 1 > 4 * PyLong_SHIFT) {
27035                             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])));
27036                         }
27037                     }
27038                     break;
27039                 case 4:
27040                     if (8 * sizeof(size_t) > 3 * PyLong_SHIFT) {
27041                         if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
27042                             __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])))
27043                         } else if (8 * sizeof(size_t) - 1 > 4 * PyLong_SHIFT) {
27044                             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])));
27045                         }
27046                     }
27047                     break;
27048             }
27049 #endif
27050             if (sizeof(size_t) <= sizeof(long)) {
27051                 __PYX_VERIFY_RETURN_INT_EXC(size_t, long, PyLong_AsLong(x))
27052 #ifdef HAVE_LONG_LONG
27053             } else if (sizeof(size_t) <= sizeof(PY_LONG_LONG)) {
27054                 __PYX_VERIFY_RETURN_INT_EXC(size_t, PY_LONG_LONG, PyLong_AsLongLong(x))
27055 #endif
27056             }
27057         }
27058         {
27059 #if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray)
27060             PyErr_SetString(PyExc_RuntimeError,
27061                             "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers");
27062 #else
27063             size_t val;
27064             PyObject *v = __Pyx_PyNumber_IntOrLong(x);
27065  #if PY_MAJOR_VERSION < 3
27066             if (likely(v) && !PyLong_Check(v)) {
27067                 PyObject *tmp = v;
27068                 v = PyNumber_Long(tmp);
27069                 Py_DECREF(tmp);
27070             }
27071  #endif
27072             if (likely(v)) {
27073                 int one = 1; int is_little = (int)*(unsigned char *)&one;
27074                 unsigned char *bytes = (unsigned char *)&val;
27075                 int ret = _PyLong_AsByteArray((PyLongObject *)v,
27076                                               bytes, sizeof(val),
27077                                               is_little, !is_unsigned);
27078                 Py_DECREF(v);
27079                 if (likely(!ret))
27080                     return val;
27081             }
27082 #endif
27083             return (size_t) -1;
27084         }
27085     } else {
27086         size_t val;
27087         PyObject *tmp = __Pyx_PyNumber_IntOrLong(x);
27088         if (!tmp) return (size_t) -1;
27089         val = __Pyx_PyInt_As_size_t(tmp);
27090         Py_DECREF(tmp);
27091         return val;
27092     }
27093 raise_overflow:
27094     PyErr_SetString(PyExc_OverflowError,
27095         "value too large to convert to size_t");
27096     return (size_t) -1;
27097 raise_neg_overflow:
27098     PyErr_SetString(PyExc_OverflowError,
27099         "can't convert negative value to size_t");
27100     return (size_t) -1;
27101 }
27102 
27103 /* CIntToPy */
__Pyx_PyInt_From_Py_intptr_t(Py_intptr_t value)27104   static CYTHON_INLINE PyObject* __Pyx_PyInt_From_Py_intptr_t(Py_intptr_t value) {
27105 #ifdef __Pyx_HAS_GCC_DIAGNOSTIC
27106 #pragma GCC diagnostic push
27107 #pragma GCC diagnostic ignored "-Wconversion"
27108 #endif
27109     const Py_intptr_t neg_one = (Py_intptr_t) -1, const_zero = (Py_intptr_t) 0;
27110 #ifdef __Pyx_HAS_GCC_DIAGNOSTIC
27111 #pragma GCC diagnostic pop
27112 #endif
27113     const int is_unsigned = neg_one > const_zero;
27114     if (is_unsigned) {
27115         if (sizeof(Py_intptr_t) < sizeof(long)) {
27116             return PyInt_FromLong((long) value);
27117         } else if (sizeof(Py_intptr_t) <= sizeof(unsigned long)) {
27118             return PyLong_FromUnsignedLong((unsigned long) value);
27119 #ifdef HAVE_LONG_LONG
27120         } else if (sizeof(Py_intptr_t) <= sizeof(unsigned PY_LONG_LONG)) {
27121             return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value);
27122 #endif
27123         }
27124     } else {
27125         if (sizeof(Py_intptr_t) <= sizeof(long)) {
27126             return PyInt_FromLong((long) value);
27127 #ifdef HAVE_LONG_LONG
27128         } else if (sizeof(Py_intptr_t) <= sizeof(PY_LONG_LONG)) {
27129             return PyLong_FromLongLong((PY_LONG_LONG) value);
27130 #endif
27131         }
27132     }
27133     {
27134         int one = 1; int little = (int)*(unsigned char *)&one;
27135         unsigned char *bytes = (unsigned char *)&value;
27136         return _PyLong_FromByteArray(bytes, sizeof(Py_intptr_t),
27137                                      little, !is_unsigned);
27138     }
27139 }
27140 
27141 /* CIntToPy */
__Pyx_PyInt_From_int(int value)27142   static CYTHON_INLINE PyObject* __Pyx_PyInt_From_int(int value) {
27143 #ifdef __Pyx_HAS_GCC_DIAGNOSTIC
27144 #pragma GCC diagnostic push
27145 #pragma GCC diagnostic ignored "-Wconversion"
27146 #endif
27147     const int neg_one = (int) -1, const_zero = (int) 0;
27148 #ifdef __Pyx_HAS_GCC_DIAGNOSTIC
27149 #pragma GCC diagnostic pop
27150 #endif
27151     const int is_unsigned = neg_one > const_zero;
27152     if (is_unsigned) {
27153         if (sizeof(int) < sizeof(long)) {
27154             return PyInt_FromLong((long) value);
27155         } else if (sizeof(int) <= sizeof(unsigned long)) {
27156             return PyLong_FromUnsignedLong((unsigned long) value);
27157 #ifdef HAVE_LONG_LONG
27158         } else if (sizeof(int) <= sizeof(unsigned PY_LONG_LONG)) {
27159             return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value);
27160 #endif
27161         }
27162     } else {
27163         if (sizeof(int) <= sizeof(long)) {
27164             return PyInt_FromLong((long) value);
27165 #ifdef HAVE_LONG_LONG
27166         } else if (sizeof(int) <= sizeof(PY_LONG_LONG)) {
27167             return PyLong_FromLongLong((PY_LONG_LONG) value);
27168 #endif
27169         }
27170     }
27171     {
27172         int one = 1; int little = (int)*(unsigned char *)&one;
27173         unsigned char *bytes = (unsigned char *)&value;
27174         return _PyLong_FromByteArray(bytes, sizeof(int),
27175                                      little, !is_unsigned);
27176     }
27177 }
27178 
27179 /* CIntFromPy */
__Pyx_PyInt_As_long(PyObject * x)27180   static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *x) {
27181 #ifdef __Pyx_HAS_GCC_DIAGNOSTIC
27182 #pragma GCC diagnostic push
27183 #pragma GCC diagnostic ignored "-Wconversion"
27184 #endif
27185     const long neg_one = (long) -1, const_zero = (long) 0;
27186 #ifdef __Pyx_HAS_GCC_DIAGNOSTIC
27187 #pragma GCC diagnostic pop
27188 #endif
27189     const int is_unsigned = neg_one > const_zero;
27190 #if PY_MAJOR_VERSION < 3
27191     if (likely(PyInt_Check(x))) {
27192         if (sizeof(long) < sizeof(long)) {
27193             __PYX_VERIFY_RETURN_INT(long, long, PyInt_AS_LONG(x))
27194         } else {
27195             long val = PyInt_AS_LONG(x);
27196             if (is_unsigned && unlikely(val < 0)) {
27197                 goto raise_neg_overflow;
27198             }
27199             return (long) val;
27200         }
27201     } else
27202 #endif
27203     if (likely(PyLong_Check(x))) {
27204         if (is_unsigned) {
27205 #if CYTHON_USE_PYLONG_INTERNALS
27206             const digit* digits = ((PyLongObject*)x)->ob_digit;
27207             switch (Py_SIZE(x)) {
27208                 case  0: return (long) 0;
27209                 case  1: __PYX_VERIFY_RETURN_INT(long, digit, digits[0])
27210                 case 2:
27211                     if (8 * sizeof(long) > 1 * PyLong_SHIFT) {
27212                         if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
27213                             __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
27214                         } else if (8 * sizeof(long) >= 2 * PyLong_SHIFT) {
27215                             return (long) (((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0]));
27216                         }
27217                     }
27218                     break;
27219                 case 3:
27220                     if (8 * sizeof(long) > 2 * PyLong_SHIFT) {
27221                         if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
27222                             __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
27223                         } else if (8 * sizeof(long) >= 3 * PyLong_SHIFT) {
27224                             return (long) (((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]));
27225                         }
27226                     }
27227                     break;
27228                 case 4:
27229                     if (8 * sizeof(long) > 3 * PyLong_SHIFT) {
27230                         if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
27231                             __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])))
27232                         } else if (8 * sizeof(long) >= 4 * PyLong_SHIFT) {
27233                             return (long) (((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]));
27234                         }
27235                     }
27236                     break;
27237             }
27238 #endif
27239 #if CYTHON_COMPILING_IN_CPYTHON
27240             if (unlikely(Py_SIZE(x) < 0)) {
27241                 goto raise_neg_overflow;
27242             }
27243 #else
27244             {
27245                 int result = PyObject_RichCompareBool(x, Py_False, Py_LT);
27246                 if (unlikely(result < 0))
27247                     return (long) -1;
27248                 if (unlikely(result == 1))
27249                     goto raise_neg_overflow;
27250             }
27251 #endif
27252             if (sizeof(long) <= sizeof(unsigned long)) {
27253                 __PYX_VERIFY_RETURN_INT_EXC(long, unsigned long, PyLong_AsUnsignedLong(x))
27254 #ifdef HAVE_LONG_LONG
27255             } else if (sizeof(long) <= sizeof(unsigned PY_LONG_LONG)) {
27256                 __PYX_VERIFY_RETURN_INT_EXC(long, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x))
27257 #endif
27258             }
27259         } else {
27260 #if CYTHON_USE_PYLONG_INTERNALS
27261             const digit* digits = ((PyLongObject*)x)->ob_digit;
27262             switch (Py_SIZE(x)) {
27263                 case  0: return (long) 0;
27264                 case -1: __PYX_VERIFY_RETURN_INT(long, sdigit, (sdigit) (-(sdigit)digits[0]))
27265                 case  1: __PYX_VERIFY_RETURN_INT(long,  digit, +digits[0])
27266                 case -2:
27267                     if (8 * sizeof(long) - 1 > 1 * PyLong_SHIFT) {
27268                         if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
27269                             __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
27270                         } else if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
27271                             return (long) (((long)-1)*(((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
27272                         }
27273                     }
27274                     break;
27275                 case 2:
27276                     if (8 * sizeof(long) > 1 * PyLong_SHIFT) {
27277                         if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
27278                             __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
27279                         } else if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
27280                             return (long) ((((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
27281                         }
27282                     }
27283                     break;
27284                 case -3:
27285                     if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
27286                         if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
27287                             __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
27288                         } else if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
27289                             return (long) (((long)-1)*(((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
27290                         }
27291                     }
27292                     break;
27293                 case 3:
27294                     if (8 * sizeof(long) > 2 * PyLong_SHIFT) {
27295                         if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
27296                             __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
27297                         } else if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
27298                             return (long) ((((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
27299                         }
27300                     }
27301                     break;
27302                 case -4:
27303                     if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
27304                         if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
27305                             __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])))
27306                         } else if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) {
27307                             return (long) (((long)-1)*(((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
27308                         }
27309                     }
27310                     break;
27311                 case 4:
27312                     if (8 * sizeof(long) > 3 * PyLong_SHIFT) {
27313                         if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
27314                             __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])))
27315                         } else if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) {
27316                             return (long) ((((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
27317                         }
27318                     }
27319                     break;
27320             }
27321 #endif
27322             if (sizeof(long) <= sizeof(long)) {
27323                 __PYX_VERIFY_RETURN_INT_EXC(long, long, PyLong_AsLong(x))
27324 #ifdef HAVE_LONG_LONG
27325             } else if (sizeof(long) <= sizeof(PY_LONG_LONG)) {
27326                 __PYX_VERIFY_RETURN_INT_EXC(long, PY_LONG_LONG, PyLong_AsLongLong(x))
27327 #endif
27328             }
27329         }
27330         {
27331 #if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray)
27332             PyErr_SetString(PyExc_RuntimeError,
27333                             "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers");
27334 #else
27335             long val;
27336             PyObject *v = __Pyx_PyNumber_IntOrLong(x);
27337  #if PY_MAJOR_VERSION < 3
27338             if (likely(v) && !PyLong_Check(v)) {
27339                 PyObject *tmp = v;
27340                 v = PyNumber_Long(tmp);
27341                 Py_DECREF(tmp);
27342             }
27343  #endif
27344             if (likely(v)) {
27345                 int one = 1; int is_little = (int)*(unsigned char *)&one;
27346                 unsigned char *bytes = (unsigned char *)&val;
27347                 int ret = _PyLong_AsByteArray((PyLongObject *)v,
27348                                               bytes, sizeof(val),
27349                                               is_little, !is_unsigned);
27350                 Py_DECREF(v);
27351                 if (likely(!ret))
27352                     return val;
27353             }
27354 #endif
27355             return (long) -1;
27356         }
27357     } else {
27358         long val;
27359         PyObject *tmp = __Pyx_PyNumber_IntOrLong(x);
27360         if (!tmp) return (long) -1;
27361         val = __Pyx_PyInt_As_long(tmp);
27362         Py_DECREF(tmp);
27363         return val;
27364     }
27365 raise_overflow:
27366     PyErr_SetString(PyExc_OverflowError,
27367         "value too large to convert to long");
27368     return (long) -1;
27369 raise_neg_overflow:
27370     PyErr_SetString(PyExc_OverflowError,
27371         "can't convert negative value to long");
27372     return (long) -1;
27373 }
27374 
27375 /* CIntFromPy */
__Pyx_PyInt_As_char(PyObject * x)27376   static CYTHON_INLINE char __Pyx_PyInt_As_char(PyObject *x) {
27377 #ifdef __Pyx_HAS_GCC_DIAGNOSTIC
27378 #pragma GCC diagnostic push
27379 #pragma GCC diagnostic ignored "-Wconversion"
27380 #endif
27381     const char neg_one = (char) -1, const_zero = (char) 0;
27382 #ifdef __Pyx_HAS_GCC_DIAGNOSTIC
27383 #pragma GCC diagnostic pop
27384 #endif
27385     const int is_unsigned = neg_one > const_zero;
27386 #if PY_MAJOR_VERSION < 3
27387     if (likely(PyInt_Check(x))) {
27388         if (sizeof(char) < sizeof(long)) {
27389             __PYX_VERIFY_RETURN_INT(char, long, PyInt_AS_LONG(x))
27390         } else {
27391             long val = PyInt_AS_LONG(x);
27392             if (is_unsigned && unlikely(val < 0)) {
27393                 goto raise_neg_overflow;
27394             }
27395             return (char) val;
27396         }
27397     } else
27398 #endif
27399     if (likely(PyLong_Check(x))) {
27400         if (is_unsigned) {
27401 #if CYTHON_USE_PYLONG_INTERNALS
27402             const digit* digits = ((PyLongObject*)x)->ob_digit;
27403             switch (Py_SIZE(x)) {
27404                 case  0: return (char) 0;
27405                 case  1: __PYX_VERIFY_RETURN_INT(char, digit, digits[0])
27406                 case 2:
27407                     if (8 * sizeof(char) > 1 * PyLong_SHIFT) {
27408                         if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
27409                             __PYX_VERIFY_RETURN_INT(char, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
27410                         } else if (8 * sizeof(char) >= 2 * PyLong_SHIFT) {
27411                             return (char) (((((char)digits[1]) << PyLong_SHIFT) | (char)digits[0]));
27412                         }
27413                     }
27414                     break;
27415                 case 3:
27416                     if (8 * sizeof(char) > 2 * PyLong_SHIFT) {
27417                         if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
27418                             __PYX_VERIFY_RETURN_INT(char, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
27419                         } else if (8 * sizeof(char) >= 3 * PyLong_SHIFT) {
27420                             return (char) (((((((char)digits[2]) << PyLong_SHIFT) | (char)digits[1]) << PyLong_SHIFT) | (char)digits[0]));
27421                         }
27422                     }
27423                     break;
27424                 case 4:
27425                     if (8 * sizeof(char) > 3 * PyLong_SHIFT) {
27426                         if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
27427                             __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])))
27428                         } else if (8 * sizeof(char) >= 4 * PyLong_SHIFT) {
27429                             return (char) (((((((((char)digits[3]) << PyLong_SHIFT) | (char)digits[2]) << PyLong_SHIFT) | (char)digits[1]) << PyLong_SHIFT) | (char)digits[0]));
27430                         }
27431                     }
27432                     break;
27433             }
27434 #endif
27435 #if CYTHON_COMPILING_IN_CPYTHON
27436             if (unlikely(Py_SIZE(x) < 0)) {
27437                 goto raise_neg_overflow;
27438             }
27439 #else
27440             {
27441                 int result = PyObject_RichCompareBool(x, Py_False, Py_LT);
27442                 if (unlikely(result < 0))
27443                     return (char) -1;
27444                 if (unlikely(result == 1))
27445                     goto raise_neg_overflow;
27446             }
27447 #endif
27448             if (sizeof(char) <= sizeof(unsigned long)) {
27449                 __PYX_VERIFY_RETURN_INT_EXC(char, unsigned long, PyLong_AsUnsignedLong(x))
27450 #ifdef HAVE_LONG_LONG
27451             } else if (sizeof(char) <= sizeof(unsigned PY_LONG_LONG)) {
27452                 __PYX_VERIFY_RETURN_INT_EXC(char, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x))
27453 #endif
27454             }
27455         } else {
27456 #if CYTHON_USE_PYLONG_INTERNALS
27457             const digit* digits = ((PyLongObject*)x)->ob_digit;
27458             switch (Py_SIZE(x)) {
27459                 case  0: return (char) 0;
27460                 case -1: __PYX_VERIFY_RETURN_INT(char, sdigit, (sdigit) (-(sdigit)digits[0]))
27461                 case  1: __PYX_VERIFY_RETURN_INT(char,  digit, +digits[0])
27462                 case -2:
27463                     if (8 * sizeof(char) - 1 > 1 * PyLong_SHIFT) {
27464                         if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
27465                             __PYX_VERIFY_RETURN_INT(char, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
27466                         } else if (8 * sizeof(char) - 1 > 2 * PyLong_SHIFT) {
27467                             return (char) (((char)-1)*(((((char)digits[1]) << PyLong_SHIFT) | (char)digits[0])));
27468                         }
27469                     }
27470                     break;
27471                 case 2:
27472                     if (8 * sizeof(char) > 1 * PyLong_SHIFT) {
27473                         if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
27474                             __PYX_VERIFY_RETURN_INT(char, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
27475                         } else if (8 * sizeof(char) - 1 > 2 * PyLong_SHIFT) {
27476                             return (char) ((((((char)digits[1]) << PyLong_SHIFT) | (char)digits[0])));
27477                         }
27478                     }
27479                     break;
27480                 case -3:
27481                     if (8 * sizeof(char) - 1 > 2 * PyLong_SHIFT) {
27482                         if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
27483                             __PYX_VERIFY_RETURN_INT(char, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
27484                         } else if (8 * sizeof(char) - 1 > 3 * PyLong_SHIFT) {
27485                             return (char) (((char)-1)*(((((((char)digits[2]) << PyLong_SHIFT) | (char)digits[1]) << PyLong_SHIFT) | (char)digits[0])));
27486                         }
27487                     }
27488                     break;
27489                 case 3:
27490                     if (8 * sizeof(char) > 2 * PyLong_SHIFT) {
27491                         if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
27492                             __PYX_VERIFY_RETURN_INT(char, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
27493                         } else if (8 * sizeof(char) - 1 > 3 * PyLong_SHIFT) {
27494                             return (char) ((((((((char)digits[2]) << PyLong_SHIFT) | (char)digits[1]) << PyLong_SHIFT) | (char)digits[0])));
27495                         }
27496                     }
27497                     break;
27498                 case -4:
27499                     if (8 * sizeof(char) - 1 > 3 * PyLong_SHIFT) {
27500                         if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
27501                             __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])))
27502                         } else if (8 * sizeof(char) - 1 > 4 * PyLong_SHIFT) {
27503                             return (char) (((char)-1)*(((((((((char)digits[3]) << PyLong_SHIFT) | (char)digits[2]) << PyLong_SHIFT) | (char)digits[1]) << PyLong_SHIFT) | (char)digits[0])));
27504                         }
27505                     }
27506                     break;
27507                 case 4:
27508                     if (8 * sizeof(char) > 3 * PyLong_SHIFT) {
27509                         if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
27510                             __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])))
27511                         } else if (8 * sizeof(char) - 1 > 4 * PyLong_SHIFT) {
27512                             return (char) ((((((((((char)digits[3]) << PyLong_SHIFT) | (char)digits[2]) << PyLong_SHIFT) | (char)digits[1]) << PyLong_SHIFT) | (char)digits[0])));
27513                         }
27514                     }
27515                     break;
27516             }
27517 #endif
27518             if (sizeof(char) <= sizeof(long)) {
27519                 __PYX_VERIFY_RETURN_INT_EXC(char, long, PyLong_AsLong(x))
27520 #ifdef HAVE_LONG_LONG
27521             } else if (sizeof(char) <= sizeof(PY_LONG_LONG)) {
27522                 __PYX_VERIFY_RETURN_INT_EXC(char, PY_LONG_LONG, PyLong_AsLongLong(x))
27523 #endif
27524             }
27525         }
27526         {
27527 #if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray)
27528             PyErr_SetString(PyExc_RuntimeError,
27529                             "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers");
27530 #else
27531             char val;
27532             PyObject *v = __Pyx_PyNumber_IntOrLong(x);
27533  #if PY_MAJOR_VERSION < 3
27534             if (likely(v) && !PyLong_Check(v)) {
27535                 PyObject *tmp = v;
27536                 v = PyNumber_Long(tmp);
27537                 Py_DECREF(tmp);
27538             }
27539  #endif
27540             if (likely(v)) {
27541                 int one = 1; int is_little = (int)*(unsigned char *)&one;
27542                 unsigned char *bytes = (unsigned char *)&val;
27543                 int ret = _PyLong_AsByteArray((PyLongObject *)v,
27544                                               bytes, sizeof(val),
27545                                               is_little, !is_unsigned);
27546                 Py_DECREF(v);
27547                 if (likely(!ret))
27548                     return val;
27549             }
27550 #endif
27551             return (char) -1;
27552         }
27553     } else {
27554         char val;
27555         PyObject *tmp = __Pyx_PyNumber_IntOrLong(x);
27556         if (!tmp) return (char) -1;
27557         val = __Pyx_PyInt_As_char(tmp);
27558         Py_DECREF(tmp);
27559         return val;
27560     }
27561 raise_overflow:
27562     PyErr_SetString(PyExc_OverflowError,
27563         "value too large to convert to char");
27564     return (char) -1;
27565 raise_neg_overflow:
27566     PyErr_SetString(PyExc_OverflowError,
27567         "can't convert negative value to char");
27568     return (char) -1;
27569 }
27570 
27571 /* ObjectToMemviewSlice */
__Pyx_PyObject_to_MemoryviewSlice_d_dc___pyx_t_double_complex(PyObject * obj,int writable_flag)27572   static CYTHON_INLINE __Pyx_memviewslice __Pyx_PyObject_to_MemoryviewSlice_d_dc___pyx_t_double_complex(PyObject *obj, int writable_flag) {
27573     __Pyx_memviewslice result = { 0, 0, { 0 }, { 0 }, { 0 } };
27574     __Pyx_BufFmt_StackElem stack[1];
27575     int axes_specs[] = { (__Pyx_MEMVIEW_DIRECT | __Pyx_MEMVIEW_FOLLOW), (__Pyx_MEMVIEW_DIRECT | __Pyx_MEMVIEW_CONTIG) };
27576     int retcode;
27577     if (obj == Py_None) {
27578         result.memview = (struct __pyx_memoryview_obj *) Py_None;
27579         return result;
27580     }
27581     retcode = __Pyx_ValidateAndInit_memviewslice(axes_specs, __Pyx_IS_C_CONTIG,
27582                                                  (PyBUF_C_CONTIGUOUS | PyBUF_FORMAT) | writable_flag, 2,
27583                                                  &__Pyx_TypeInfo___pyx_t_double_complex, stack,
27584                                                  &result, obj);
27585     if (unlikely(retcode == -1))
27586         goto __pyx_fail;
27587     return result;
27588 __pyx_fail:
27589     result.memview = NULL;
27590     result.data = NULL;
27591     return result;
27592 }
27593 
27594 /* CheckBinaryVersion */
__Pyx_check_binary_version(void)27595   static int __Pyx_check_binary_version(void) {
27596     char ctversion[4], rtversion[4];
27597     PyOS_snprintf(ctversion, 4, "%d.%d", PY_MAJOR_VERSION, PY_MINOR_VERSION);
27598     PyOS_snprintf(rtversion, 4, "%s", Py_GetVersion());
27599     if (ctversion[0] != rtversion[0] || ctversion[2] != rtversion[2]) {
27600         char message[200];
27601         PyOS_snprintf(message, sizeof(message),
27602                       "compiletime version %s of module '%.100s' "
27603                       "does not match runtime version %s",
27604                       ctversion, __Pyx_MODULE_NAME, rtversion);
27605         return PyErr_WarnEx(NULL, message, 1);
27606     }
27607     return 0;
27608 }
27609 
27610 /* InitStrings */
__Pyx_InitStrings(__Pyx_StringTabEntry * t)27611   static int __Pyx_InitStrings(__Pyx_StringTabEntry *t) {
27612     while (t->p) {
27613         #if PY_MAJOR_VERSION < 3
27614         if (t->is_unicode) {
27615             *t->p = PyUnicode_DecodeUTF8(t->s, t->n - 1, NULL);
27616         } else if (t->intern) {
27617             *t->p = PyString_InternFromString(t->s);
27618         } else {
27619             *t->p = PyString_FromStringAndSize(t->s, t->n - 1);
27620         }
27621         #else
27622         if (t->is_unicode | t->is_str) {
27623             if (t->intern) {
27624                 *t->p = PyUnicode_InternFromString(t->s);
27625             } else if (t->encoding) {
27626                 *t->p = PyUnicode_Decode(t->s, t->n - 1, t->encoding, NULL);
27627             } else {
27628                 *t->p = PyUnicode_FromStringAndSize(t->s, t->n - 1);
27629             }
27630         } else {
27631             *t->p = PyBytes_FromStringAndSize(t->s, t->n - 1);
27632         }
27633         #endif
27634         if (!*t->p)
27635             return -1;
27636         if (PyObject_Hash(*t->p) == -1)
27637             return -1;
27638         ++t;
27639     }
27640     return 0;
27641 }
27642 
__Pyx_PyUnicode_FromString(const char * c_str)27643 static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(const char* c_str) {
27644     return __Pyx_PyUnicode_FromStringAndSize(c_str, (Py_ssize_t)strlen(c_str));
27645 }
__Pyx_PyObject_AsString(PyObject * o)27646 static CYTHON_INLINE const char* __Pyx_PyObject_AsString(PyObject* o) {
27647     Py_ssize_t ignore;
27648     return __Pyx_PyObject_AsStringAndSize(o, &ignore);
27649 }
27650 #if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT
27651 #if !CYTHON_PEP393_ENABLED
__Pyx_PyUnicode_AsStringAndSize(PyObject * o,Py_ssize_t * length)27652 static const char* __Pyx_PyUnicode_AsStringAndSize(PyObject* o, Py_ssize_t *length) {
27653     char* defenc_c;
27654     PyObject* defenc = _PyUnicode_AsDefaultEncodedString(o, NULL);
27655     if (!defenc) return NULL;
27656     defenc_c = PyBytes_AS_STRING(defenc);
27657 #if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
27658     {
27659         char* end = defenc_c + PyBytes_GET_SIZE(defenc);
27660         char* c;
27661         for (c = defenc_c; c < end; c++) {
27662             if ((unsigned char) (*c) >= 128) {
27663                 PyUnicode_AsASCIIString(o);
27664                 return NULL;
27665             }
27666         }
27667     }
27668 #endif
27669     *length = PyBytes_GET_SIZE(defenc);
27670     return defenc_c;
27671 }
27672 #else
__Pyx_PyUnicode_AsStringAndSize(PyObject * o,Py_ssize_t * length)27673 static CYTHON_INLINE const char* __Pyx_PyUnicode_AsStringAndSize(PyObject* o, Py_ssize_t *length) {
27674     if (unlikely(__Pyx_PyUnicode_READY(o) == -1)) return NULL;
27675 #if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
27676     if (likely(PyUnicode_IS_ASCII(o))) {
27677         *length = PyUnicode_GET_LENGTH(o);
27678         return PyUnicode_AsUTF8(o);
27679     } else {
27680         PyUnicode_AsASCIIString(o);
27681         return NULL;
27682     }
27683 #else
27684     return PyUnicode_AsUTF8AndSize(o, length);
27685 #endif
27686 }
27687 #endif
27688 #endif
__Pyx_PyObject_AsStringAndSize(PyObject * o,Py_ssize_t * length)27689 static CYTHON_INLINE const char* __Pyx_PyObject_AsStringAndSize(PyObject* o, Py_ssize_t *length) {
27690 #if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT
27691     if (
27692 #if PY_MAJOR_VERSION < 3 && __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
27693             __Pyx_sys_getdefaultencoding_not_ascii &&
27694 #endif
27695             PyUnicode_Check(o)) {
27696         return __Pyx_PyUnicode_AsStringAndSize(o, length);
27697     } else
27698 #endif
27699 #if (!CYTHON_COMPILING_IN_PYPY) || (defined(PyByteArray_AS_STRING) && defined(PyByteArray_GET_SIZE))
27700     if (PyByteArray_Check(o)) {
27701         *length = PyByteArray_GET_SIZE(o);
27702         return PyByteArray_AS_STRING(o);
27703     } else
27704 #endif
27705     {
27706         char* result;
27707         int r = PyBytes_AsStringAndSize(o, &result, length);
27708         if (unlikely(r < 0)) {
27709             return NULL;
27710         } else {
27711             return result;
27712         }
27713     }
27714 }
__Pyx_PyObject_IsTrue(PyObject * x)27715 static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject* x) {
27716    int is_true = x == Py_True;
27717    if (is_true | (x == Py_False) | (x == Py_None)) return is_true;
27718    else return PyObject_IsTrue(x);
27719 }
__Pyx_PyObject_IsTrueAndDecref(PyObject * x)27720 static CYTHON_INLINE int __Pyx_PyObject_IsTrueAndDecref(PyObject* x) {
27721     int retval;
27722     if (unlikely(!x)) return -1;
27723     retval = __Pyx_PyObject_IsTrue(x);
27724     Py_DECREF(x);
27725     return retval;
27726 }
__Pyx_PyNumber_IntOrLongWrongResultType(PyObject * result,const char * type_name)27727 static PyObject* __Pyx_PyNumber_IntOrLongWrongResultType(PyObject* result, const char* type_name) {
27728 #if PY_MAJOR_VERSION >= 3
27729     if (PyLong_Check(result)) {
27730         if (PyErr_WarnFormat(PyExc_DeprecationWarning, 1,
27731                 "__int__ returned non-int (type %.200s).  "
27732                 "The ability to return an instance of a strict subclass of int "
27733                 "is deprecated, and may be removed in a future version of Python.",
27734                 Py_TYPE(result)->tp_name)) {
27735             Py_DECREF(result);
27736             return NULL;
27737         }
27738         return result;
27739     }
27740 #endif
27741     PyErr_Format(PyExc_TypeError,
27742                  "__%.4s__ returned non-%.4s (type %.200s)",
27743                  type_name, type_name, Py_TYPE(result)->tp_name);
27744     Py_DECREF(result);
27745     return NULL;
27746 }
__Pyx_PyNumber_IntOrLong(PyObject * x)27747 static CYTHON_INLINE PyObject* __Pyx_PyNumber_IntOrLong(PyObject* x) {
27748 #if CYTHON_USE_TYPE_SLOTS
27749   PyNumberMethods *m;
27750 #endif
27751   const char *name = NULL;
27752   PyObject *res = NULL;
27753 #if PY_MAJOR_VERSION < 3
27754   if (likely(PyInt_Check(x) || PyLong_Check(x)))
27755 #else
27756   if (likely(PyLong_Check(x)))
27757 #endif
27758     return __Pyx_NewRef(x);
27759 #if CYTHON_USE_TYPE_SLOTS
27760   m = Py_TYPE(x)->tp_as_number;
27761   #if PY_MAJOR_VERSION < 3
27762   if (m && m->nb_int) {
27763     name = "int";
27764     res = m->nb_int(x);
27765   }
27766   else if (m && m->nb_long) {
27767     name = "long";
27768     res = m->nb_long(x);
27769   }
27770   #else
27771   if (likely(m && m->nb_int)) {
27772     name = "int";
27773     res = m->nb_int(x);
27774   }
27775   #endif
27776 #else
27777   if (!PyBytes_CheckExact(x) && !PyUnicode_CheckExact(x)) {
27778     res = PyNumber_Int(x);
27779   }
27780 #endif
27781   if (likely(res)) {
27782 #if PY_MAJOR_VERSION < 3
27783     if (unlikely(!PyInt_Check(res) && !PyLong_Check(res))) {
27784 #else
27785     if (unlikely(!PyLong_CheckExact(res))) {
27786 #endif
27787         return __Pyx_PyNumber_IntOrLongWrongResultType(res, name);
27788     }
27789   }
27790   else if (!PyErr_Occurred()) {
27791     PyErr_SetString(PyExc_TypeError,
27792                     "an integer is required");
27793   }
27794   return res;
27795 }
27796 static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject* b) {
27797   Py_ssize_t ival;
27798   PyObject *x;
27799 #if PY_MAJOR_VERSION < 3
27800   if (likely(PyInt_CheckExact(b))) {
27801     if (sizeof(Py_ssize_t) >= sizeof(long))
27802         return PyInt_AS_LONG(b);
27803     else
27804         return PyInt_AsSsize_t(b);
27805   }
27806 #endif
27807   if (likely(PyLong_CheckExact(b))) {
27808     #if CYTHON_USE_PYLONG_INTERNALS
27809     const digit* digits = ((PyLongObject*)b)->ob_digit;
27810     const Py_ssize_t size = Py_SIZE(b);
27811     if (likely(__Pyx_sst_abs(size) <= 1)) {
27812         ival = likely(size) ? digits[0] : 0;
27813         if (size == -1) ival = -ival;
27814         return ival;
27815     } else {
27816       switch (size) {
27817          case 2:
27818            if (8 * sizeof(Py_ssize_t) > 2 * PyLong_SHIFT) {
27819              return (Py_ssize_t) (((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
27820            }
27821            break;
27822          case -2:
27823            if (8 * sizeof(Py_ssize_t) > 2 * PyLong_SHIFT) {
27824              return -(Py_ssize_t) (((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
27825            }
27826            break;
27827          case 3:
27828            if (8 * sizeof(Py_ssize_t) > 3 * PyLong_SHIFT) {
27829              return (Py_ssize_t) (((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
27830            }
27831            break;
27832          case -3:
27833            if (8 * sizeof(Py_ssize_t) > 3 * PyLong_SHIFT) {
27834              return -(Py_ssize_t) (((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
27835            }
27836            break;
27837          case 4:
27838            if (8 * sizeof(Py_ssize_t) > 4 * PyLong_SHIFT) {
27839              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]));
27840            }
27841            break;
27842          case -4:
27843            if (8 * sizeof(Py_ssize_t) > 4 * PyLong_SHIFT) {
27844              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]));
27845            }
27846            break;
27847       }
27848     }
27849     #endif
27850     return PyLong_AsSsize_t(b);
27851   }
27852   x = PyNumber_Index(b);
27853   if (!x) return -1;
27854   ival = PyInt_AsSsize_t(x);
27855   Py_DECREF(x);
27856   return ival;
27857 }
27858 static CYTHON_INLINE PyObject * __Pyx_PyBool_FromLong(long b) {
27859   return b ? __Pyx_NewRef(Py_True) : __Pyx_NewRef(Py_False);
27860 }
27861 static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t ival) {
27862     return PyInt_FromSize_t(ival);
27863 }
27864 
27865 
27866 #endif /* Py_PYTHON_H */
27867