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             "qutip/cy/src/zspmv.hpp"
10         ],
11         "extra_compile_args": [
12             "-w",
13             "-O3",
14             "-funroll-loops"
15         ],
16         "include_dirs": [
17             "qutip/cy",
18             "/tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/core/include"
19         ],
20         "language": "c++",
21         "name": "qutip.cy.spmatfuncs",
22         "sources": [
23             "qutip/cy/spmatfuncs.pyx",
24             "qutip/cy/src/zspmv.cpp"
25         ]
26     },
27     "module_name": "qutip.cy.spmatfuncs"
28 }
29 END: Cython Metadata */
30 
31 #ifndef PY_SSIZE_T_CLEAN
32 #define PY_SSIZE_T_CLEAN
33 #endif /* PY_SSIZE_T_CLEAN */
34 #include "Python.h"
35 #ifndef Py_PYTHON_H
36     #error Python headers needed to compile C extensions, please install development version of Python.
37 #elif PY_VERSION_HEX < 0x02060000 || (0x03000000 <= PY_VERSION_HEX && PY_VERSION_HEX < 0x03030000)
38     #error Cython requires Python 2.6+ or Python 3.3+.
39 #else
40 #define CYTHON_ABI "0_29_23"
41 #define CYTHON_HEX_VERSION 0x001D17F0
42 #define CYTHON_FUTURE_DIVISION 1
43 #include <stddef.h>
44 #ifndef offsetof
45   #define offsetof(type, member) ( (size_t) & ((type*)0) -> member )
46 #endif
47 #if !defined(WIN32) && !defined(MS_WINDOWS)
48   #ifndef __stdcall
49     #define __stdcall
50   #endif
51   #ifndef __cdecl
52     #define __cdecl
53   #endif
54   #ifndef __fastcall
55     #define __fastcall
56   #endif
57 #endif
58 #ifndef DL_IMPORT
59   #define DL_IMPORT(t) t
60 #endif
61 #ifndef DL_EXPORT
62   #define DL_EXPORT(t) t
63 #endif
64 #define __PYX_COMMA ,
65 #ifndef HAVE_LONG_LONG
66   #if PY_VERSION_HEX >= 0x02070000
67     #define HAVE_LONG_LONG
68   #endif
69 #endif
70 #ifndef PY_LONG_LONG
71   #define PY_LONG_LONG LONG_LONG
72 #endif
73 #ifndef Py_HUGE_VAL
74   #define Py_HUGE_VAL HUGE_VAL
75 #endif
76 #ifdef PYPY_VERSION
77   #define CYTHON_COMPILING_IN_PYPY 1
78   #define CYTHON_COMPILING_IN_PYSTON 0
79   #define CYTHON_COMPILING_IN_CPYTHON 0
80   #undef CYTHON_USE_TYPE_SLOTS
81   #define CYTHON_USE_TYPE_SLOTS 0
82   #undef CYTHON_USE_PYTYPE_LOOKUP
83   #define CYTHON_USE_PYTYPE_LOOKUP 0
84   #if PY_VERSION_HEX < 0x03050000
85     #undef CYTHON_USE_ASYNC_SLOTS
86     #define CYTHON_USE_ASYNC_SLOTS 0
87   #elif !defined(CYTHON_USE_ASYNC_SLOTS)
88     #define CYTHON_USE_ASYNC_SLOTS 1
89   #endif
90   #undef CYTHON_USE_PYLIST_INTERNALS
91   #define CYTHON_USE_PYLIST_INTERNALS 0
92   #undef CYTHON_USE_UNICODE_INTERNALS
93   #define CYTHON_USE_UNICODE_INTERNALS 0
94   #undef CYTHON_USE_UNICODE_WRITER
95   #define CYTHON_USE_UNICODE_WRITER 0
96   #undef CYTHON_USE_PYLONG_INTERNALS
97   #define CYTHON_USE_PYLONG_INTERNALS 0
98   #undef CYTHON_AVOID_BORROWED_REFS
99   #define CYTHON_AVOID_BORROWED_REFS 1
100   #undef CYTHON_ASSUME_SAFE_MACROS
101   #define CYTHON_ASSUME_SAFE_MACROS 0
102   #undef CYTHON_UNPACK_METHODS
103   #define CYTHON_UNPACK_METHODS 0
104   #undef CYTHON_FAST_THREAD_STATE
105   #define CYTHON_FAST_THREAD_STATE 0
106   #undef CYTHON_FAST_PYCALL
107   #define CYTHON_FAST_PYCALL 0
108   #undef CYTHON_PEP489_MULTI_PHASE_INIT
109   #define CYTHON_PEP489_MULTI_PHASE_INIT 0
110   #undef CYTHON_USE_TP_FINALIZE
111   #define CYTHON_USE_TP_FINALIZE 0
112   #undef CYTHON_USE_DICT_VERSIONS
113   #define CYTHON_USE_DICT_VERSIONS 0
114   #undef CYTHON_USE_EXC_INFO_STACK
115   #define CYTHON_USE_EXC_INFO_STACK 0
116 #elif defined(PYSTON_VERSION)
117   #define CYTHON_COMPILING_IN_PYPY 0
118   #define CYTHON_COMPILING_IN_PYSTON 1
119   #define CYTHON_COMPILING_IN_CPYTHON 0
120   #ifndef CYTHON_USE_TYPE_SLOTS
121     #define CYTHON_USE_TYPE_SLOTS 1
122   #endif
123   #undef CYTHON_USE_PYTYPE_LOOKUP
124   #define CYTHON_USE_PYTYPE_LOOKUP 0
125   #undef CYTHON_USE_ASYNC_SLOTS
126   #define CYTHON_USE_ASYNC_SLOTS 0
127   #undef CYTHON_USE_PYLIST_INTERNALS
128   #define CYTHON_USE_PYLIST_INTERNALS 0
129   #ifndef CYTHON_USE_UNICODE_INTERNALS
130     #define CYTHON_USE_UNICODE_INTERNALS 1
131   #endif
132   #undef CYTHON_USE_UNICODE_WRITER
133   #define CYTHON_USE_UNICODE_WRITER 0
134   #undef CYTHON_USE_PYLONG_INTERNALS
135   #define CYTHON_USE_PYLONG_INTERNALS 0
136   #ifndef CYTHON_AVOID_BORROWED_REFS
137     #define CYTHON_AVOID_BORROWED_REFS 0
138   #endif
139   #ifndef CYTHON_ASSUME_SAFE_MACROS
140     #define CYTHON_ASSUME_SAFE_MACROS 1
141   #endif
142   #ifndef CYTHON_UNPACK_METHODS
143     #define CYTHON_UNPACK_METHODS 1
144   #endif
145   #undef CYTHON_FAST_THREAD_STATE
146   #define CYTHON_FAST_THREAD_STATE 0
147   #undef CYTHON_FAST_PYCALL
148   #define CYTHON_FAST_PYCALL 0
149   #undef CYTHON_PEP489_MULTI_PHASE_INIT
150   #define CYTHON_PEP489_MULTI_PHASE_INIT 0
151   #undef CYTHON_USE_TP_FINALIZE
152   #define CYTHON_USE_TP_FINALIZE 0
153   #undef CYTHON_USE_DICT_VERSIONS
154   #define CYTHON_USE_DICT_VERSIONS 0
155   #undef CYTHON_USE_EXC_INFO_STACK
156   #define CYTHON_USE_EXC_INFO_STACK 0
157 #else
158   #define CYTHON_COMPILING_IN_PYPY 0
159   #define CYTHON_COMPILING_IN_PYSTON 0
160   #define CYTHON_COMPILING_IN_CPYTHON 1
161   #ifndef CYTHON_USE_TYPE_SLOTS
162     #define CYTHON_USE_TYPE_SLOTS 1
163   #endif
164   #if PY_VERSION_HEX < 0x02070000
165     #undef CYTHON_USE_PYTYPE_LOOKUP
166     #define CYTHON_USE_PYTYPE_LOOKUP 0
167   #elif !defined(CYTHON_USE_PYTYPE_LOOKUP)
168     #define CYTHON_USE_PYTYPE_LOOKUP 1
169   #endif
170   #if PY_MAJOR_VERSION < 3
171     #undef CYTHON_USE_ASYNC_SLOTS
172     #define CYTHON_USE_ASYNC_SLOTS 0
173   #elif !defined(CYTHON_USE_ASYNC_SLOTS)
174     #define CYTHON_USE_ASYNC_SLOTS 1
175   #endif
176   #if PY_VERSION_HEX < 0x02070000
177     #undef CYTHON_USE_PYLONG_INTERNALS
178     #define CYTHON_USE_PYLONG_INTERNALS 0
179   #elif !defined(CYTHON_USE_PYLONG_INTERNALS)
180     #define CYTHON_USE_PYLONG_INTERNALS 1
181   #endif
182   #ifndef CYTHON_USE_PYLIST_INTERNALS
183     #define CYTHON_USE_PYLIST_INTERNALS 1
184   #endif
185   #ifndef CYTHON_USE_UNICODE_INTERNALS
186     #define CYTHON_USE_UNICODE_INTERNALS 1
187   #endif
188   #if PY_VERSION_HEX < 0x030300F0
189     #undef CYTHON_USE_UNICODE_WRITER
190     #define CYTHON_USE_UNICODE_WRITER 0
191   #elif !defined(CYTHON_USE_UNICODE_WRITER)
192     #define CYTHON_USE_UNICODE_WRITER 1
193   #endif
194   #ifndef CYTHON_AVOID_BORROWED_REFS
195     #define CYTHON_AVOID_BORROWED_REFS 0
196   #endif
197   #ifndef CYTHON_ASSUME_SAFE_MACROS
198     #define CYTHON_ASSUME_SAFE_MACROS 1
199   #endif
200   #ifndef CYTHON_UNPACK_METHODS
201     #define CYTHON_UNPACK_METHODS 1
202   #endif
203   #ifndef CYTHON_FAST_THREAD_STATE
204     #define CYTHON_FAST_THREAD_STATE 1
205   #endif
206   #ifndef CYTHON_FAST_PYCALL
207     #define CYTHON_FAST_PYCALL 1
208   #endif
209   #ifndef CYTHON_PEP489_MULTI_PHASE_INIT
210     #define CYTHON_PEP489_MULTI_PHASE_INIT (PY_VERSION_HEX >= 0x03050000)
211   #endif
212   #ifndef CYTHON_USE_TP_FINALIZE
213     #define CYTHON_USE_TP_FINALIZE (PY_VERSION_HEX >= 0x030400a1)
214   #endif
215   #ifndef CYTHON_USE_DICT_VERSIONS
216     #define CYTHON_USE_DICT_VERSIONS (PY_VERSION_HEX >= 0x030600B1)
217   #endif
218   #ifndef CYTHON_USE_EXC_INFO_STACK
219     #define CYTHON_USE_EXC_INFO_STACK (PY_VERSION_HEX >= 0x030700A3)
220   #endif
221 #endif
222 #if !defined(CYTHON_FAST_PYCCALL)
223 #define CYTHON_FAST_PYCCALL  (CYTHON_FAST_PYCALL && PY_VERSION_HEX >= 0x030600B1)
224 #endif
225 #if CYTHON_USE_PYLONG_INTERNALS
226   #include "longintrepr.h"
227   #undef SHIFT
228   #undef BASE
229   #undef MASK
230   #ifdef SIZEOF_VOID_P
231     enum { __pyx_check_sizeof_voidp = 1 / (int)(SIZEOF_VOID_P == sizeof(void*)) };
232   #endif
233 #endif
234 #ifndef __has_attribute
235   #define __has_attribute(x) 0
236 #endif
237 #ifndef __has_cpp_attribute
238   #define __has_cpp_attribute(x) 0
239 #endif
240 #ifndef CYTHON_RESTRICT
241   #if defined(__GNUC__)
242     #define CYTHON_RESTRICT __restrict__
243   #elif defined(_MSC_VER) && _MSC_VER >= 1400
244     #define CYTHON_RESTRICT __restrict
245   #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
246     #define CYTHON_RESTRICT restrict
247   #else
248     #define CYTHON_RESTRICT
249   #endif
250 #endif
251 #ifndef CYTHON_UNUSED
252 # if defined(__GNUC__)
253 #   if !(defined(__cplusplus)) || (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4))
254 #     define CYTHON_UNUSED __attribute__ ((__unused__))
255 #   else
256 #     define CYTHON_UNUSED
257 #   endif
258 # elif defined(__ICC) || (defined(__INTEL_COMPILER) && !defined(_MSC_VER))
259 #   define CYTHON_UNUSED __attribute__ ((__unused__))
260 # else
261 #   define CYTHON_UNUSED
262 # endif
263 #endif
264 #ifndef CYTHON_MAYBE_UNUSED_VAR
265 #  if defined(__cplusplus)
CYTHON_MAYBE_UNUSED_VAR(const T &)266      template<class T> void CYTHON_MAYBE_UNUSED_VAR( const T& ) { }
267 #  else
268 #    define CYTHON_MAYBE_UNUSED_VAR(x) (void)(x)
269 #  endif
270 #endif
271 #ifndef CYTHON_NCP_UNUSED
272 # if CYTHON_COMPILING_IN_CPYTHON
273 #  define CYTHON_NCP_UNUSED
274 # else
275 #  define CYTHON_NCP_UNUSED CYTHON_UNUSED
276 # endif
277 #endif
278 #define __Pyx_void_to_None(void_result) ((void)(void_result), Py_INCREF(Py_None), Py_None)
279 #ifdef _MSC_VER
280     #ifndef _MSC_STDINT_H_
281         #if _MSC_VER < 1300
282            typedef unsigned char     uint8_t;
283            typedef unsigned int      uint32_t;
284         #else
285            typedef unsigned __int8   uint8_t;
286            typedef unsigned __int32  uint32_t;
287         #endif
288     #endif
289 #else
290    #include <stdint.h>
291 #endif
292 #ifndef CYTHON_FALLTHROUGH
293   #if defined(__cplusplus) && __cplusplus >= 201103L
294     #if __has_cpp_attribute(fallthrough)
295       #define CYTHON_FALLTHROUGH [[fallthrough]]
296     #elif __has_cpp_attribute(clang::fallthrough)
297       #define CYTHON_FALLTHROUGH [[clang::fallthrough]]
298     #elif __has_cpp_attribute(gnu::fallthrough)
299       #define CYTHON_FALLTHROUGH [[gnu::fallthrough]]
300     #endif
301   #endif
302   #ifndef CYTHON_FALLTHROUGH
303     #if __has_attribute(fallthrough)
304       #define CYTHON_FALLTHROUGH __attribute__((fallthrough))
305     #else
306       #define CYTHON_FALLTHROUGH
307     #endif
308   #endif
309   #if defined(__clang__ ) && defined(__apple_build_version__)
310     #if __apple_build_version__ < 7000000
311       #undef  CYTHON_FALLTHROUGH
312       #define CYTHON_FALLTHROUGH
313     #endif
314   #endif
315 #endif
316 
317 #ifndef __cplusplus
318   #error "Cython files generated with the C++ option must be compiled with a C++ compiler."
319 #endif
320 #ifndef CYTHON_INLINE
321   #if defined(__clang__)
322     #define CYTHON_INLINE __inline__ __attribute__ ((__unused__))
323   #else
324     #define CYTHON_INLINE inline
325   #endif
326 #endif
327 template<typename T>
__Pyx_call_destructor(T & x)328 void __Pyx_call_destructor(T& x) {
329     x.~T();
330 }
331 template<typename T>
332 class __Pyx_FakeReference {
333   public:
__Pyx_FakeReference()334     __Pyx_FakeReference() : ptr(NULL) { }
__Pyx_FakeReference(const T & ref)335     __Pyx_FakeReference(const T& ref) : ptr(const_cast<T*>(&ref)) { }
operator ->()336     T *operator->() { return ptr; }
operator &()337     T *operator&() { return ptr; }
operator T&()338     operator T&() { return *ptr; }
operator ==(U other)339     template<typename U> bool operator ==(U other) { return *ptr == other; }
operator !=(U other)340     template<typename U> bool operator !=(U other) { return *ptr != other; }
341   private:
342     T *ptr;
343 };
344 
345 #if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX < 0x02070600 && !defined(Py_OptimizeFlag)
346   #define Py_OptimizeFlag 0
347 #endif
348 #define __PYX_BUILD_PY_SSIZE_T "n"
349 #define CYTHON_FORMAT_SSIZE_T "z"
350 #if PY_MAJOR_VERSION < 3
351   #define __Pyx_BUILTIN_MODULE_NAME "__builtin__"
352   #define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)\
353           PyCode_New(a+k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)
354   #define __Pyx_DefaultClassType PyClass_Type
355 #else
356   #define __Pyx_BUILTIN_MODULE_NAME "builtins"
357 #if PY_VERSION_HEX >= 0x030800A4 && PY_VERSION_HEX < 0x030800B2
358   #define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)\
359           PyCode_New(a, 0, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)
360 #else
361   #define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)\
362           PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)
363 #endif
364   #define __Pyx_DefaultClassType PyType_Type
365 #endif
366 #ifndef Py_TPFLAGS_CHECKTYPES
367   #define Py_TPFLAGS_CHECKTYPES 0
368 #endif
369 #ifndef Py_TPFLAGS_HAVE_INDEX
370   #define Py_TPFLAGS_HAVE_INDEX 0
371 #endif
372 #ifndef Py_TPFLAGS_HAVE_NEWBUFFER
373   #define Py_TPFLAGS_HAVE_NEWBUFFER 0
374 #endif
375 #ifndef Py_TPFLAGS_HAVE_FINALIZE
376   #define Py_TPFLAGS_HAVE_FINALIZE 0
377 #endif
378 #ifndef METH_STACKLESS
379   #define METH_STACKLESS 0
380 #endif
381 #if PY_VERSION_HEX <= 0x030700A3 || !defined(METH_FASTCALL)
382   #ifndef METH_FASTCALL
383      #define METH_FASTCALL 0x80
384   #endif
385   typedef PyObject *(*__Pyx_PyCFunctionFast) (PyObject *self, PyObject *const *args, Py_ssize_t nargs);
386   typedef PyObject *(*__Pyx_PyCFunctionFastWithKeywords) (PyObject *self, PyObject *const *args,
387                                                           Py_ssize_t nargs, PyObject *kwnames);
388 #else
389   #define __Pyx_PyCFunctionFast _PyCFunctionFast
390   #define __Pyx_PyCFunctionFastWithKeywords _PyCFunctionFastWithKeywords
391 #endif
392 #if CYTHON_FAST_PYCCALL
393 #define __Pyx_PyFastCFunction_Check(func)\
394     ((PyCFunction_Check(func) && (METH_FASTCALL == (PyCFunction_GET_FLAGS(func) & ~(METH_CLASS | METH_STATIC | METH_COEXIST | METH_KEYWORDS | METH_STACKLESS)))))
395 #else
396 #define __Pyx_PyFastCFunction_Check(func) 0
397 #endif
398 #if CYTHON_COMPILING_IN_PYPY && !defined(PyObject_Malloc)
399   #define PyObject_Malloc(s)   PyMem_Malloc(s)
400   #define PyObject_Free(p)     PyMem_Free(p)
401   #define PyObject_Realloc(p)  PyMem_Realloc(p)
402 #endif
403 #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX < 0x030400A1
404   #define PyMem_RawMalloc(n)           PyMem_Malloc(n)
405   #define PyMem_RawRealloc(p, n)       PyMem_Realloc(p, n)
406   #define PyMem_RawFree(p)             PyMem_Free(p)
407 #endif
408 #if CYTHON_COMPILING_IN_PYSTON
409   #define __Pyx_PyCode_HasFreeVars(co)  PyCode_HasFreeVars(co)
410   #define __Pyx_PyFrame_SetLineNumber(frame, lineno) PyFrame_SetLineNumber(frame, lineno)
411 #else
412   #define __Pyx_PyCode_HasFreeVars(co)  (PyCode_GetNumFree(co) > 0)
413   #define __Pyx_PyFrame_SetLineNumber(frame, lineno)  (frame)->f_lineno = (lineno)
414 #endif
415 #if !CYTHON_FAST_THREAD_STATE || PY_VERSION_HEX < 0x02070000
416   #define __Pyx_PyThreadState_Current PyThreadState_GET()
417 #elif PY_VERSION_HEX >= 0x03060000
418   #define __Pyx_PyThreadState_Current _PyThreadState_UncheckedGet()
419 #elif PY_VERSION_HEX >= 0x03000000
420   #define __Pyx_PyThreadState_Current PyThreadState_GET()
421 #else
422   #define __Pyx_PyThreadState_Current _PyThreadState_Current
423 #endif
424 #if PY_VERSION_HEX < 0x030700A2 && !defined(PyThread_tss_create) && !defined(Py_tss_NEEDS_INIT)
425 #include "pythread.h"
426 #define Py_tss_NEEDS_INIT 0
427 typedef int Py_tss_t;
PyThread_tss_create(Py_tss_t * key)428 static CYTHON_INLINE int PyThread_tss_create(Py_tss_t *key) {
429   *key = PyThread_create_key();
430   return 0;
431 }
PyThread_tss_alloc(void)432 static CYTHON_INLINE Py_tss_t * PyThread_tss_alloc(void) {
433   Py_tss_t *key = (Py_tss_t *)PyObject_Malloc(sizeof(Py_tss_t));
434   *key = Py_tss_NEEDS_INIT;
435   return key;
436 }
PyThread_tss_free(Py_tss_t * key)437 static CYTHON_INLINE void PyThread_tss_free(Py_tss_t *key) {
438   PyObject_Free(key);
439 }
PyThread_tss_is_created(Py_tss_t * key)440 static CYTHON_INLINE int PyThread_tss_is_created(Py_tss_t *key) {
441   return *key != Py_tss_NEEDS_INIT;
442 }
PyThread_tss_delete(Py_tss_t * key)443 static CYTHON_INLINE void PyThread_tss_delete(Py_tss_t *key) {
444   PyThread_delete_key(*key);
445   *key = Py_tss_NEEDS_INIT;
446 }
PyThread_tss_set(Py_tss_t * key,void * value)447 static CYTHON_INLINE int PyThread_tss_set(Py_tss_t *key, void *value) {
448   return PyThread_set_key_value(*key, value);
449 }
PyThread_tss_get(Py_tss_t * key)450 static CYTHON_INLINE void * PyThread_tss_get(Py_tss_t *key) {
451   return PyThread_get_key_value(*key);
452 }
453 #endif
454 #if CYTHON_COMPILING_IN_CPYTHON || defined(_PyDict_NewPresized)
455 #define __Pyx_PyDict_NewPresized(n)  ((n <= 8) ? PyDict_New() : _PyDict_NewPresized(n))
456 #else
457 #define __Pyx_PyDict_NewPresized(n)  PyDict_New()
458 #endif
459 #if PY_MAJOR_VERSION >= 3 || CYTHON_FUTURE_DIVISION
460   #define __Pyx_PyNumber_Divide(x,y)         PyNumber_TrueDivide(x,y)
461   #define __Pyx_PyNumber_InPlaceDivide(x,y)  PyNumber_InPlaceTrueDivide(x,y)
462 #else
463   #define __Pyx_PyNumber_Divide(x,y)         PyNumber_Divide(x,y)
464   #define __Pyx_PyNumber_InPlaceDivide(x,y)  PyNumber_InPlaceDivide(x,y)
465 #endif
466 #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030500A1 && CYTHON_USE_UNICODE_INTERNALS
467 #define __Pyx_PyDict_GetItemStr(dict, name)  _PyDict_GetItem_KnownHash(dict, name, ((PyASCIIObject *) name)->hash)
468 #else
469 #define __Pyx_PyDict_GetItemStr(dict, name)  PyDict_GetItem(dict, name)
470 #endif
471 #if PY_VERSION_HEX > 0x03030000 && defined(PyUnicode_KIND)
472   #define CYTHON_PEP393_ENABLED 1
473   #define __Pyx_PyUnicode_READY(op)       (likely(PyUnicode_IS_READY(op)) ?\
474                                               0 : _PyUnicode_Ready((PyObject *)(op)))
475   #define __Pyx_PyUnicode_GET_LENGTH(u)   PyUnicode_GET_LENGTH(u)
476   #define __Pyx_PyUnicode_READ_CHAR(u, i) PyUnicode_READ_CHAR(u, i)
477   #define __Pyx_PyUnicode_MAX_CHAR_VALUE(u)   PyUnicode_MAX_CHAR_VALUE(u)
478   #define __Pyx_PyUnicode_KIND(u)         PyUnicode_KIND(u)
479   #define __Pyx_PyUnicode_DATA(u)         PyUnicode_DATA(u)
480   #define __Pyx_PyUnicode_READ(k, d, i)   PyUnicode_READ(k, d, i)
481   #define __Pyx_PyUnicode_WRITE(k, d, i, ch)  PyUnicode_WRITE(k, d, i, ch)
482   #if defined(PyUnicode_IS_READY) && defined(PyUnicode_GET_SIZE)
483   #define __Pyx_PyUnicode_IS_TRUE(u)      (0 != (likely(PyUnicode_IS_READY(u)) ? PyUnicode_GET_LENGTH(u) : PyUnicode_GET_SIZE(u)))
484   #else
485   #define __Pyx_PyUnicode_IS_TRUE(u)      (0 != PyUnicode_GET_LENGTH(u))
486   #endif
487 #else
488   #define CYTHON_PEP393_ENABLED 0
489   #define PyUnicode_1BYTE_KIND  1
490   #define PyUnicode_2BYTE_KIND  2
491   #define PyUnicode_4BYTE_KIND  4
492   #define __Pyx_PyUnicode_READY(op)       (0)
493   #define __Pyx_PyUnicode_GET_LENGTH(u)   PyUnicode_GET_SIZE(u)
494   #define __Pyx_PyUnicode_READ_CHAR(u, i) ((Py_UCS4)(PyUnicode_AS_UNICODE(u)[i]))
495   #define __Pyx_PyUnicode_MAX_CHAR_VALUE(u)   ((sizeof(Py_UNICODE) == 2) ? 65535 : 1114111)
496   #define __Pyx_PyUnicode_KIND(u)         (sizeof(Py_UNICODE))
497   #define __Pyx_PyUnicode_DATA(u)         ((void*)PyUnicode_AS_UNICODE(u))
498   #define __Pyx_PyUnicode_READ(k, d, i)   ((void)(k), (Py_UCS4)(((Py_UNICODE*)d)[i]))
499   #define __Pyx_PyUnicode_WRITE(k, d, i, ch)  (((void)(k)), ((Py_UNICODE*)d)[i] = ch)
500   #define __Pyx_PyUnicode_IS_TRUE(u)      (0 != PyUnicode_GET_SIZE(u))
501 #endif
502 #if CYTHON_COMPILING_IN_PYPY
503   #define __Pyx_PyUnicode_Concat(a, b)      PyNumber_Add(a, b)
504   #define __Pyx_PyUnicode_ConcatSafe(a, b)  PyNumber_Add(a, b)
505 #else
506   #define __Pyx_PyUnicode_Concat(a, b)      PyUnicode_Concat(a, b)
507   #define __Pyx_PyUnicode_ConcatSafe(a, b)  ((unlikely((a) == Py_None) || unlikely((b) == Py_None)) ?\
508       PyNumber_Add(a, b) : __Pyx_PyUnicode_Concat(a, b))
509 #endif
510 #if CYTHON_COMPILING_IN_PYPY && !defined(PyUnicode_Contains)
511   #define PyUnicode_Contains(u, s)  PySequence_Contains(u, s)
512 #endif
513 #if CYTHON_COMPILING_IN_PYPY && !defined(PyByteArray_Check)
514   #define PyByteArray_Check(obj)  PyObject_TypeCheck(obj, &PyByteArray_Type)
515 #endif
516 #if CYTHON_COMPILING_IN_PYPY && !defined(PyObject_Format)
517   #define PyObject_Format(obj, fmt)  PyObject_CallMethod(obj, "__format__", "O", fmt)
518 #endif
519 #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))
520 #define __Pyx_PyUnicode_FormatSafe(a, b)  ((unlikely((a) == Py_None || (PyUnicode_Check(b) && !PyUnicode_CheckExact(b)))) ? PyNumber_Remainder(a, b) : PyUnicode_Format(a, b))
521 #if PY_MAJOR_VERSION >= 3
522   #define __Pyx_PyString_Format(a, b)  PyUnicode_Format(a, b)
523 #else
524   #define __Pyx_PyString_Format(a, b)  PyString_Format(a, b)
525 #endif
526 #if PY_MAJOR_VERSION < 3 && !defined(PyObject_ASCII)
527   #define PyObject_ASCII(o)            PyObject_Repr(o)
528 #endif
529 #if PY_MAJOR_VERSION >= 3
530   #define PyBaseString_Type            PyUnicode_Type
531   #define PyStringObject               PyUnicodeObject
532   #define PyString_Type                PyUnicode_Type
533   #define PyString_Check               PyUnicode_Check
534   #define PyString_CheckExact          PyUnicode_CheckExact
535 #ifndef PyObject_Unicode
536   #define PyObject_Unicode             PyObject_Str
537 #endif
538 #endif
539 #if PY_MAJOR_VERSION >= 3
540   #define __Pyx_PyBaseString_Check(obj) PyUnicode_Check(obj)
541   #define __Pyx_PyBaseString_CheckExact(obj) PyUnicode_CheckExact(obj)
542 #else
543   #define __Pyx_PyBaseString_Check(obj) (PyString_Check(obj) || PyUnicode_Check(obj))
544   #define __Pyx_PyBaseString_CheckExact(obj) (PyString_CheckExact(obj) || PyUnicode_CheckExact(obj))
545 #endif
546 #ifndef PySet_CheckExact
547   #define PySet_CheckExact(obj)        (Py_TYPE(obj) == &PySet_Type)
548 #endif
549 #if PY_VERSION_HEX >= 0x030900A4
550   #define __Pyx_SET_REFCNT(obj, refcnt) Py_SET_REFCNT(obj, refcnt)
551   #define __Pyx_SET_SIZE(obj, size) Py_SET_SIZE(obj, size)
552 #else
553   #define __Pyx_SET_REFCNT(obj, refcnt) Py_REFCNT(obj) = (refcnt)
554   #define __Pyx_SET_SIZE(obj, size) Py_SIZE(obj) = (size)
555 #endif
556 #if CYTHON_ASSUME_SAFE_MACROS
557   #define __Pyx_PySequence_SIZE(seq)  Py_SIZE(seq)
558 #else
559   #define __Pyx_PySequence_SIZE(seq)  PySequence_Size(seq)
560 #endif
561 #if PY_MAJOR_VERSION >= 3
562   #define PyIntObject                  PyLongObject
563   #define PyInt_Type                   PyLong_Type
564   #define PyInt_Check(op)              PyLong_Check(op)
565   #define PyInt_CheckExact(op)         PyLong_CheckExact(op)
566   #define PyInt_FromString             PyLong_FromString
567   #define PyInt_FromUnicode            PyLong_FromUnicode
568   #define PyInt_FromLong               PyLong_FromLong
569   #define PyInt_FromSize_t             PyLong_FromSize_t
570   #define PyInt_FromSsize_t            PyLong_FromSsize_t
571   #define PyInt_AsLong                 PyLong_AsLong
572   #define PyInt_AS_LONG                PyLong_AS_LONG
573   #define PyInt_AsSsize_t              PyLong_AsSsize_t
574   #define PyInt_AsUnsignedLongMask     PyLong_AsUnsignedLongMask
575   #define PyInt_AsUnsignedLongLongMask PyLong_AsUnsignedLongLongMask
576   #define PyNumber_Int                 PyNumber_Long
577 #endif
578 #if PY_MAJOR_VERSION >= 3
579   #define PyBoolObject                 PyLongObject
580 #endif
581 #if PY_MAJOR_VERSION >= 3 && CYTHON_COMPILING_IN_PYPY
582   #ifndef PyUnicode_InternFromString
583     #define PyUnicode_InternFromString(s) PyUnicode_FromString(s)
584   #endif
585 #endif
586 #if PY_VERSION_HEX < 0x030200A4
587   typedef long Py_hash_t;
588   #define __Pyx_PyInt_FromHash_t PyInt_FromLong
589   #define __Pyx_PyInt_AsHash_t   PyInt_AsLong
590 #else
591   #define __Pyx_PyInt_FromHash_t PyInt_FromSsize_t
592   #define __Pyx_PyInt_AsHash_t   PyInt_AsSsize_t
593 #endif
594 #if PY_MAJOR_VERSION >= 3
595   #define __Pyx_PyMethod_New(func, self, klass) ((self) ? ((void)(klass), PyMethod_New(func, self)) : __Pyx_NewRef(func))
596 #else
597   #define __Pyx_PyMethod_New(func, self, klass) PyMethod_New(func, self, klass)
598 #endif
599 #if CYTHON_USE_ASYNC_SLOTS
600   #if PY_VERSION_HEX >= 0x030500B1
601     #define __Pyx_PyAsyncMethodsStruct PyAsyncMethods
602     #define __Pyx_PyType_AsAsync(obj) (Py_TYPE(obj)->tp_as_async)
603   #else
604     #define __Pyx_PyType_AsAsync(obj) ((__Pyx_PyAsyncMethodsStruct*) (Py_TYPE(obj)->tp_reserved))
605   #endif
606 #else
607   #define __Pyx_PyType_AsAsync(obj) NULL
608 #endif
609 #ifndef __Pyx_PyAsyncMethodsStruct
610     typedef struct {
611         unaryfunc am_await;
612         unaryfunc am_aiter;
613         unaryfunc am_anext;
614     } __Pyx_PyAsyncMethodsStruct;
615 #endif
616 
617 #if defined(WIN32) || defined(MS_WINDOWS)
618   #define _USE_MATH_DEFINES
619 #endif
620 #include <math.h>
621 #ifdef NAN
622 #define __PYX_NAN() ((float) NAN)
623 #else
__PYX_NAN()624 static CYTHON_INLINE float __PYX_NAN() {
625   float value;
626   memset(&value, 0xFF, sizeof(value));
627   return value;
628 }
629 #endif
630 #if defined(__CYGWIN__) && defined(_LDBL_EQ_DBL)
631 #define __Pyx_truncl trunc
632 #else
633 #define __Pyx_truncl truncl
634 #endif
635 
636 #define __PYX_MARK_ERR_POS(f_index, lineno) \
637     { __pyx_filename = __pyx_f[f_index]; (void)__pyx_filename; __pyx_lineno = lineno; (void)__pyx_lineno; __pyx_clineno = __LINE__; (void)__pyx_clineno; }
638 #define __PYX_ERR(f_index, lineno, Ln_error) \
639     { __PYX_MARK_ERR_POS(f_index, lineno) goto Ln_error; }
640 
641 #ifndef __PYX_EXTERN_C
642   #ifdef __cplusplus
643     #define __PYX_EXTERN_C extern "C"
644   #else
645     #define __PYX_EXTERN_C extern
646   #endif
647 #endif
648 
649 #define __PYX_HAVE__qutip__cy__spmatfuncs
650 #define __PYX_HAVE_API__qutip__cy__spmatfuncs
651 /* Early includes */
652 #include <string.h>
653 #include <stdio.h>
654 #include "numpy/arrayobject.h"
655 #include "numpy/ufuncobject.h"
656 
657     /* NumPy API declarations from "numpy/__init__.pxd" */
658 
659 #include <math.h>
660 #include "src/zspmv.hpp"
661 #include <complex>
662 #include "pythread.h"
663 #include <stdlib.h>
664 #include "pystate.h"
665 #ifdef _OPENMP
666 #include <omp.h>
667 #endif /* _OPENMP */
668 
669 #if defined(PYREX_WITHOUT_ASSERTIONS) && !defined(CYTHON_WITHOUT_ASSERTIONS)
670 #define CYTHON_WITHOUT_ASSERTIONS
671 #endif
672 
673 typedef struct {PyObject **p; const char *s; const Py_ssize_t n; const char* encoding;
674                 const char is_unicode; const char is_str; const char intern; } __Pyx_StringTabEntry;
675 
676 #define __PYX_DEFAULT_STRING_ENCODING_IS_ASCII 0
677 #define __PYX_DEFAULT_STRING_ENCODING_IS_UTF8 0
678 #define __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT (PY_MAJOR_VERSION >= 3 && __PYX_DEFAULT_STRING_ENCODING_IS_UTF8)
679 #define __PYX_DEFAULT_STRING_ENCODING ""
680 #define __Pyx_PyObject_FromString __Pyx_PyBytes_FromString
681 #define __Pyx_PyObject_FromStringAndSize __Pyx_PyBytes_FromStringAndSize
682 #define __Pyx_uchar_cast(c) ((unsigned char)c)
683 #define __Pyx_long_cast(x) ((long)x)
684 #define __Pyx_fits_Py_ssize_t(v, type, is_signed)  (\
685     (sizeof(type) < sizeof(Py_ssize_t))  ||\
686     (sizeof(type) > sizeof(Py_ssize_t) &&\
687           likely(v < (type)PY_SSIZE_T_MAX ||\
688                  v == (type)PY_SSIZE_T_MAX)  &&\
689           (!is_signed || likely(v > (type)PY_SSIZE_T_MIN ||\
690                                 v == (type)PY_SSIZE_T_MIN)))  ||\
691     (sizeof(type) == sizeof(Py_ssize_t) &&\
692           (is_signed || likely(v < (type)PY_SSIZE_T_MAX ||\
693                                v == (type)PY_SSIZE_T_MAX)))  )
__Pyx_is_valid_index(Py_ssize_t i,Py_ssize_t limit)694 static CYTHON_INLINE int __Pyx_is_valid_index(Py_ssize_t i, Py_ssize_t limit) {
695     return (size_t) i < (size_t) limit;
696 }
697 #if defined (__cplusplus) && __cplusplus >= 201103L
698     #include <cstdlib>
699     #define __Pyx_sst_abs(value) std::abs(value)
700 #elif SIZEOF_INT >= SIZEOF_SIZE_T
701     #define __Pyx_sst_abs(value) abs(value)
702 #elif SIZEOF_LONG >= SIZEOF_SIZE_T
703     #define __Pyx_sst_abs(value) labs(value)
704 #elif defined (_MSC_VER)
705     #define __Pyx_sst_abs(value) ((Py_ssize_t)_abs64(value))
706 #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
707     #define __Pyx_sst_abs(value) llabs(value)
708 #elif defined (__GNUC__)
709     #define __Pyx_sst_abs(value) __builtin_llabs(value)
710 #else
711     #define __Pyx_sst_abs(value) ((value<0) ? -value : value)
712 #endif
713 static CYTHON_INLINE const char* __Pyx_PyObject_AsString(PyObject*);
714 static CYTHON_INLINE const char* __Pyx_PyObject_AsStringAndSize(PyObject*, Py_ssize_t* length);
715 #define __Pyx_PyByteArray_FromString(s) PyByteArray_FromStringAndSize((const char*)s, strlen((const char*)s))
716 #define __Pyx_PyByteArray_FromStringAndSize(s, l) PyByteArray_FromStringAndSize((const char*)s, l)
717 #define __Pyx_PyBytes_FromString        PyBytes_FromString
718 #define __Pyx_PyBytes_FromStringAndSize PyBytes_FromStringAndSize
719 static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(const char*);
720 #if PY_MAJOR_VERSION < 3
721     #define __Pyx_PyStr_FromString        __Pyx_PyBytes_FromString
722     #define __Pyx_PyStr_FromStringAndSize __Pyx_PyBytes_FromStringAndSize
723 #else
724     #define __Pyx_PyStr_FromString        __Pyx_PyUnicode_FromString
725     #define __Pyx_PyStr_FromStringAndSize __Pyx_PyUnicode_FromStringAndSize
726 #endif
727 #define __Pyx_PyBytes_AsWritableString(s)     ((char*) PyBytes_AS_STRING(s))
728 #define __Pyx_PyBytes_AsWritableSString(s)    ((signed char*) PyBytes_AS_STRING(s))
729 #define __Pyx_PyBytes_AsWritableUString(s)    ((unsigned char*) PyBytes_AS_STRING(s))
730 #define __Pyx_PyBytes_AsString(s)     ((const char*) PyBytes_AS_STRING(s))
731 #define __Pyx_PyBytes_AsSString(s)    ((const signed char*) PyBytes_AS_STRING(s))
732 #define __Pyx_PyBytes_AsUString(s)    ((const unsigned char*) PyBytes_AS_STRING(s))
733 #define __Pyx_PyObject_AsWritableString(s)    ((char*) __Pyx_PyObject_AsString(s))
734 #define __Pyx_PyObject_AsWritableSString(s)    ((signed char*) __Pyx_PyObject_AsString(s))
735 #define __Pyx_PyObject_AsWritableUString(s)    ((unsigned char*) __Pyx_PyObject_AsString(s))
736 #define __Pyx_PyObject_AsSString(s)    ((const signed char*) __Pyx_PyObject_AsString(s))
737 #define __Pyx_PyObject_AsUString(s)    ((const unsigned char*) __Pyx_PyObject_AsString(s))
738 #define __Pyx_PyObject_FromCString(s)  __Pyx_PyObject_FromString((const char*)s)
739 #define __Pyx_PyBytes_FromCString(s)   __Pyx_PyBytes_FromString((const char*)s)
740 #define __Pyx_PyByteArray_FromCString(s)   __Pyx_PyByteArray_FromString((const char*)s)
741 #define __Pyx_PyStr_FromCString(s)     __Pyx_PyStr_FromString((const char*)s)
742 #define __Pyx_PyUnicode_FromCString(s) __Pyx_PyUnicode_FromString((const char*)s)
__Pyx_Py_UNICODE_strlen(const Py_UNICODE * u)743 static CYTHON_INLINE size_t __Pyx_Py_UNICODE_strlen(const Py_UNICODE *u) {
744     const Py_UNICODE *u_end = u;
745     while (*u_end++) ;
746     return (size_t)(u_end - u - 1);
747 }
748 #define __Pyx_PyUnicode_FromUnicode(u)       PyUnicode_FromUnicode(u, __Pyx_Py_UNICODE_strlen(u))
749 #define __Pyx_PyUnicode_FromUnicodeAndLength PyUnicode_FromUnicode
750 #define __Pyx_PyUnicode_AsUnicode            PyUnicode_AsUnicode
751 #define __Pyx_NewRef(obj) (Py_INCREF(obj), obj)
752 #define __Pyx_Owned_Py_None(b) __Pyx_NewRef(Py_None)
753 static CYTHON_INLINE PyObject * __Pyx_PyBool_FromLong(long b);
754 static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject*);
755 static CYTHON_INLINE int __Pyx_PyObject_IsTrueAndDecref(PyObject*);
756 static CYTHON_INLINE PyObject* __Pyx_PyNumber_IntOrLong(PyObject* x);
757 #define __Pyx_PySequence_Tuple(obj)\
758     (likely(PyTuple_CheckExact(obj)) ? __Pyx_NewRef(obj) : PySequence_Tuple(obj))
759 static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject*);
760 static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t);
761 #if CYTHON_ASSUME_SAFE_MACROS
762 #define __pyx_PyFloat_AsDouble(x) (PyFloat_CheckExact(x) ? PyFloat_AS_DOUBLE(x) : PyFloat_AsDouble(x))
763 #else
764 #define __pyx_PyFloat_AsDouble(x) PyFloat_AsDouble(x)
765 #endif
766 #define __pyx_PyFloat_AsFloat(x) ((float) __pyx_PyFloat_AsDouble(x))
767 #if PY_MAJOR_VERSION >= 3
768 #define __Pyx_PyNumber_Int(x) (PyLong_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Long(x))
769 #else
770 #define __Pyx_PyNumber_Int(x) (PyInt_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Int(x))
771 #endif
772 #define __Pyx_PyNumber_Float(x) (PyFloat_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Float(x))
773 #if PY_MAJOR_VERSION < 3 && __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
774 static int __Pyx_sys_getdefaultencoding_not_ascii;
__Pyx_init_sys_getdefaultencoding_params(void)775 static int __Pyx_init_sys_getdefaultencoding_params(void) {
776     PyObject* sys;
777     PyObject* default_encoding = NULL;
778     PyObject* ascii_chars_u = NULL;
779     PyObject* ascii_chars_b = NULL;
780     const char* default_encoding_c;
781     sys = PyImport_ImportModule("sys");
782     if (!sys) goto bad;
783     default_encoding = PyObject_CallMethod(sys, (char*) "getdefaultencoding", NULL);
784     Py_DECREF(sys);
785     if (!default_encoding) goto bad;
786     default_encoding_c = PyBytes_AsString(default_encoding);
787     if (!default_encoding_c) goto bad;
788     if (strcmp(default_encoding_c, "ascii") == 0) {
789         __Pyx_sys_getdefaultencoding_not_ascii = 0;
790     } else {
791         char ascii_chars[128];
792         int c;
793         for (c = 0; c < 128; c++) {
794             ascii_chars[c] = c;
795         }
796         __Pyx_sys_getdefaultencoding_not_ascii = 1;
797         ascii_chars_u = PyUnicode_DecodeASCII(ascii_chars, 128, NULL);
798         if (!ascii_chars_u) goto bad;
799         ascii_chars_b = PyUnicode_AsEncodedString(ascii_chars_u, default_encoding_c, NULL);
800         if (!ascii_chars_b || !PyBytes_Check(ascii_chars_b) || memcmp(ascii_chars, PyBytes_AS_STRING(ascii_chars_b), 128) != 0) {
801             PyErr_Format(
802                 PyExc_ValueError,
803                 "This module compiled with c_string_encoding=ascii, but default encoding '%.200s' is not a superset of ascii.",
804                 default_encoding_c);
805             goto bad;
806         }
807         Py_DECREF(ascii_chars_u);
808         Py_DECREF(ascii_chars_b);
809     }
810     Py_DECREF(default_encoding);
811     return 0;
812 bad:
813     Py_XDECREF(default_encoding);
814     Py_XDECREF(ascii_chars_u);
815     Py_XDECREF(ascii_chars_b);
816     return -1;
817 }
818 #endif
819 #if __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT && PY_MAJOR_VERSION >= 3
820 #define __Pyx_PyUnicode_FromStringAndSize(c_str, size) PyUnicode_DecodeUTF8(c_str, size, NULL)
821 #else
822 #define __Pyx_PyUnicode_FromStringAndSize(c_str, size) PyUnicode_Decode(c_str, size, __PYX_DEFAULT_STRING_ENCODING, NULL)
823 #if __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT
824 static char* __PYX_DEFAULT_STRING_ENCODING;
__Pyx_init_sys_getdefaultencoding_params(void)825 static int __Pyx_init_sys_getdefaultencoding_params(void) {
826     PyObject* sys;
827     PyObject* default_encoding = NULL;
828     char* default_encoding_c;
829     sys = PyImport_ImportModule("sys");
830     if (!sys) goto bad;
831     default_encoding = PyObject_CallMethod(sys, (char*) (const char*) "getdefaultencoding", NULL);
832     Py_DECREF(sys);
833     if (!default_encoding) goto bad;
834     default_encoding_c = PyBytes_AsString(default_encoding);
835     if (!default_encoding_c) goto bad;
836     __PYX_DEFAULT_STRING_ENCODING = (char*) malloc(strlen(default_encoding_c) + 1);
837     if (!__PYX_DEFAULT_STRING_ENCODING) goto bad;
838     strcpy(__PYX_DEFAULT_STRING_ENCODING, default_encoding_c);
839     Py_DECREF(default_encoding);
840     return 0;
841 bad:
842     Py_XDECREF(default_encoding);
843     return -1;
844 }
845 #endif
846 #endif
847 
848 
849 /* Test for GCC > 2.95 */
850 #if defined(__GNUC__)     && (__GNUC__ > 2 || (__GNUC__ == 2 && (__GNUC_MINOR__ > 95)))
851   #define likely(x)   __builtin_expect(!!(x), 1)
852   #define unlikely(x) __builtin_expect(!!(x), 0)
853 #else /* !__GNUC__ or GCC < 2.95 */
854   #define likely(x)   (x)
855   #define unlikely(x) (x)
856 #endif /* __GNUC__ */
__Pyx_pretend_to_initialize(void * ptr)857 static CYTHON_INLINE void __Pyx_pretend_to_initialize(void* ptr) { (void)ptr; }
858 
859 static PyObject *__pyx_m = NULL;
860 static PyObject *__pyx_d;
861 static PyObject *__pyx_b;
862 static PyObject *__pyx_cython_runtime = NULL;
863 static PyObject *__pyx_empty_tuple;
864 static PyObject *__pyx_empty_bytes;
865 static PyObject *__pyx_empty_unicode;
866 static int __pyx_lineno;
867 static int __pyx_clineno = 0;
868 static const char * __pyx_cfilenm= __FILE__;
869 static const char *__pyx_filename;
870 
871 /* Header.proto */
872 #if !defined(CYTHON_CCOMPLEX)
873   #if defined(__cplusplus)
874     #define CYTHON_CCOMPLEX 1
875   #elif defined(_Complex_I)
876     #define CYTHON_CCOMPLEX 1
877   #else
878     #define CYTHON_CCOMPLEX 0
879   #endif
880 #endif
881 #if CYTHON_CCOMPLEX
882   #ifdef __cplusplus
883     #include <complex>
884   #else
885     #include <complex.h>
886   #endif
887 #endif
888 #if CYTHON_CCOMPLEX && !defined(__cplusplus) && defined(__sun__) && defined(__GNUC__)
889   #undef _Complex_I
890   #define _Complex_I 1.0fj
891 #endif
892 
893 
894 static const char *__pyx_f[] = {
895   "qutip/cy/spmatfuncs.pyx",
896   "__init__.pxd",
897   "stringsource",
898   "type.pxd",
899 };
900 /* MemviewSliceStruct.proto */
901 struct __pyx_memoryview_obj;
902 typedef struct {
903   struct __pyx_memoryview_obj *memview;
904   char *data;
905   Py_ssize_t shape[8];
906   Py_ssize_t strides[8];
907   Py_ssize_t suboffsets[8];
908 } __Pyx_memviewslice;
909 #define __Pyx_MemoryView_Len(m)  (m.shape[0])
910 
911 /* Atomics.proto */
912 #include <pythread.h>
913 #ifndef CYTHON_ATOMICS
914     #define CYTHON_ATOMICS 1
915 #endif
916 #define __pyx_atomic_int_type int
917 #if CYTHON_ATOMICS && __GNUC__ >= 4 && (__GNUC_MINOR__ > 1 ||\
918                     (__GNUC_MINOR__ == 1 && __GNUC_PATCHLEVEL >= 2)) &&\
919                     !defined(__i386__)
920     #define __pyx_atomic_incr_aligned(value, lock) __sync_fetch_and_add(value, 1)
921     #define __pyx_atomic_decr_aligned(value, lock) __sync_fetch_and_sub(value, 1)
922     #ifdef __PYX_DEBUG_ATOMICS
923         #warning "Using GNU atomics"
924     #endif
925 #elif CYTHON_ATOMICS && defined(_MSC_VER) && 0
926     #include <Windows.h>
927     #undef __pyx_atomic_int_type
928     #define __pyx_atomic_int_type LONG
929     #define __pyx_atomic_incr_aligned(value, lock) InterlockedIncrement(value)
930     #define __pyx_atomic_decr_aligned(value, lock) InterlockedDecrement(value)
931     #ifdef __PYX_DEBUG_ATOMICS
932         #pragma message ("Using MSVC atomics")
933     #endif
934 #elif CYTHON_ATOMICS && (defined(__ICC) || defined(__INTEL_COMPILER)) && 0
935     #define __pyx_atomic_incr_aligned(value, lock) _InterlockedIncrement(value)
936     #define __pyx_atomic_decr_aligned(value, lock) _InterlockedDecrement(value)
937     #ifdef __PYX_DEBUG_ATOMICS
938         #warning "Using Intel atomics"
939     #endif
940 #else
941     #undef CYTHON_ATOMICS
942     #define CYTHON_ATOMICS 0
943     #ifdef __PYX_DEBUG_ATOMICS
944         #warning "Not using atomics"
945     #endif
946 #endif
947 typedef volatile __pyx_atomic_int_type __pyx_atomic_int;
948 #if CYTHON_ATOMICS
949     #define __pyx_add_acquisition_count(memview)\
950              __pyx_atomic_incr_aligned(__pyx_get_slice_count_pointer(memview), memview->lock)
951     #define __pyx_sub_acquisition_count(memview)\
952             __pyx_atomic_decr_aligned(__pyx_get_slice_count_pointer(memview), memview->lock)
953 #else
954     #define __pyx_add_acquisition_count(memview)\
955             __pyx_add_acquisition_count_locked(__pyx_get_slice_count_pointer(memview), memview->lock)
956     #define __pyx_sub_acquisition_count(memview)\
957             __pyx_sub_acquisition_count_locked(__pyx_get_slice_count_pointer(memview), memview->lock)
958 #endif
959 
960 /* BufferFormatStructs.proto */
961 #define IS_UNSIGNED(type) (((type) -1) > 0)
962 struct __Pyx_StructField_;
963 #define __PYX_BUF_FLAGS_PACKED_STRUCT (1 << 0)
964 typedef struct {
965   const char* name;
966   struct __Pyx_StructField_* fields;
967   size_t size;
968   size_t arraysize[8];
969   int ndim;
970   char typegroup;
971   char is_unsigned;
972   int flags;
973 } __Pyx_TypeInfo;
974 typedef struct __Pyx_StructField_ {
975   __Pyx_TypeInfo* type;
976   const char* name;
977   size_t offset;
978 } __Pyx_StructField;
979 typedef struct {
980   __Pyx_StructField* field;
981   size_t parent_offset;
982 } __Pyx_BufFmt_StackElem;
983 typedef struct {
984   __Pyx_StructField root;
985   __Pyx_BufFmt_StackElem* head;
986   size_t fmt_offset;
987   size_t new_count, enc_count;
988   size_t struct_alignment;
989   int is_complex;
990   char enc_type;
991   char new_packmode;
992   char enc_packmode;
993   char is_valid_array;
994 } __Pyx_BufFmt_Context;
995 
996 /* ForceInitThreads.proto */
997 #ifndef __PYX_FORCE_INIT_THREADS
998   #define __PYX_FORCE_INIT_THREADS 0
999 #endif
1000 
1001 /* NoFastGil.proto */
1002 #define __Pyx_PyGILState_Ensure PyGILState_Ensure
1003 #define __Pyx_PyGILState_Release PyGILState_Release
1004 #define __Pyx_FastGIL_Remember()
1005 #define __Pyx_FastGIL_Forget()
1006 #define __Pyx_FastGilFuncInit()
1007 
1008 
1009 /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":689
1010  * # in Cython to enable them only on the right systems.
1011  *
1012  * ctypedef npy_int8       int8_t             # <<<<<<<<<<<<<<
1013  * ctypedef npy_int16      int16_t
1014  * ctypedef npy_int32      int32_t
1015  */
1016 typedef npy_int8 __pyx_t_5numpy_int8_t;
1017 
1018 /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":690
1019  *
1020  * ctypedef npy_int8       int8_t
1021  * ctypedef npy_int16      int16_t             # <<<<<<<<<<<<<<
1022  * ctypedef npy_int32      int32_t
1023  * ctypedef npy_int64      int64_t
1024  */
1025 typedef npy_int16 __pyx_t_5numpy_int16_t;
1026 
1027 /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":691
1028  * ctypedef npy_int8       int8_t
1029  * ctypedef npy_int16      int16_t
1030  * ctypedef npy_int32      int32_t             # <<<<<<<<<<<<<<
1031  * ctypedef npy_int64      int64_t
1032  * #ctypedef npy_int96      int96_t
1033  */
1034 typedef npy_int32 __pyx_t_5numpy_int32_t;
1035 
1036 /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":692
1037  * ctypedef npy_int16      int16_t
1038  * ctypedef npy_int32      int32_t
1039  * ctypedef npy_int64      int64_t             # <<<<<<<<<<<<<<
1040  * #ctypedef npy_int96      int96_t
1041  * #ctypedef npy_int128     int128_t
1042  */
1043 typedef npy_int64 __pyx_t_5numpy_int64_t;
1044 
1045 /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":696
1046  * #ctypedef npy_int128     int128_t
1047  *
1048  * ctypedef npy_uint8      uint8_t             # <<<<<<<<<<<<<<
1049  * ctypedef npy_uint16     uint16_t
1050  * ctypedef npy_uint32     uint32_t
1051  */
1052 typedef npy_uint8 __pyx_t_5numpy_uint8_t;
1053 
1054 /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":697
1055  *
1056  * ctypedef npy_uint8      uint8_t
1057  * ctypedef npy_uint16     uint16_t             # <<<<<<<<<<<<<<
1058  * ctypedef npy_uint32     uint32_t
1059  * ctypedef npy_uint64     uint64_t
1060  */
1061 typedef npy_uint16 __pyx_t_5numpy_uint16_t;
1062 
1063 /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":698
1064  * ctypedef npy_uint8      uint8_t
1065  * ctypedef npy_uint16     uint16_t
1066  * ctypedef npy_uint32     uint32_t             # <<<<<<<<<<<<<<
1067  * ctypedef npy_uint64     uint64_t
1068  * #ctypedef npy_uint96     uint96_t
1069  */
1070 typedef npy_uint32 __pyx_t_5numpy_uint32_t;
1071 
1072 /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":699
1073  * ctypedef npy_uint16     uint16_t
1074  * ctypedef npy_uint32     uint32_t
1075  * ctypedef npy_uint64     uint64_t             # <<<<<<<<<<<<<<
1076  * #ctypedef npy_uint96     uint96_t
1077  * #ctypedef npy_uint128    uint128_t
1078  */
1079 typedef npy_uint64 __pyx_t_5numpy_uint64_t;
1080 
1081 /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":703
1082  * #ctypedef npy_uint128    uint128_t
1083  *
1084  * ctypedef npy_float32    float32_t             # <<<<<<<<<<<<<<
1085  * ctypedef npy_float64    float64_t
1086  * #ctypedef npy_float80    float80_t
1087  */
1088 typedef npy_float32 __pyx_t_5numpy_float32_t;
1089 
1090 /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":704
1091  *
1092  * ctypedef npy_float32    float32_t
1093  * ctypedef npy_float64    float64_t             # <<<<<<<<<<<<<<
1094  * #ctypedef npy_float80    float80_t
1095  * #ctypedef npy_float128   float128_t
1096  */
1097 typedef npy_float64 __pyx_t_5numpy_float64_t;
1098 
1099 /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":713
1100  * # The int types are mapped a bit surprising --
1101  * # numpy.int corresponds to 'l' and numpy.long to 'q'
1102  * ctypedef npy_long       int_t             # <<<<<<<<<<<<<<
1103  * ctypedef npy_longlong   long_t
1104  * ctypedef npy_longlong   longlong_t
1105  */
1106 typedef npy_long __pyx_t_5numpy_int_t;
1107 
1108 /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":714
1109  * # numpy.int corresponds to 'l' and numpy.long to 'q'
1110  * ctypedef npy_long       int_t
1111  * ctypedef npy_longlong   long_t             # <<<<<<<<<<<<<<
1112  * ctypedef npy_longlong   longlong_t
1113  *
1114  */
1115 typedef npy_longlong __pyx_t_5numpy_long_t;
1116 
1117 /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":715
1118  * ctypedef npy_long       int_t
1119  * ctypedef npy_longlong   long_t
1120  * ctypedef npy_longlong   longlong_t             # <<<<<<<<<<<<<<
1121  *
1122  * ctypedef npy_ulong      uint_t
1123  */
1124 typedef npy_longlong __pyx_t_5numpy_longlong_t;
1125 
1126 /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":717
1127  * ctypedef npy_longlong   longlong_t
1128  *
1129  * ctypedef npy_ulong      uint_t             # <<<<<<<<<<<<<<
1130  * ctypedef npy_ulonglong  ulong_t
1131  * ctypedef npy_ulonglong  ulonglong_t
1132  */
1133 typedef npy_ulong __pyx_t_5numpy_uint_t;
1134 
1135 /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":718
1136  *
1137  * ctypedef npy_ulong      uint_t
1138  * ctypedef npy_ulonglong  ulong_t             # <<<<<<<<<<<<<<
1139  * ctypedef npy_ulonglong  ulonglong_t
1140  *
1141  */
1142 typedef npy_ulonglong __pyx_t_5numpy_ulong_t;
1143 
1144 /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":719
1145  * ctypedef npy_ulong      uint_t
1146  * ctypedef npy_ulonglong  ulong_t
1147  * ctypedef npy_ulonglong  ulonglong_t             # <<<<<<<<<<<<<<
1148  *
1149  * ctypedef npy_intp       intp_t
1150  */
1151 typedef npy_ulonglong __pyx_t_5numpy_ulonglong_t;
1152 
1153 /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":721
1154  * ctypedef npy_ulonglong  ulonglong_t
1155  *
1156  * ctypedef npy_intp       intp_t             # <<<<<<<<<<<<<<
1157  * ctypedef npy_uintp      uintp_t
1158  *
1159  */
1160 typedef npy_intp __pyx_t_5numpy_intp_t;
1161 
1162 /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":722
1163  *
1164  * ctypedef npy_intp       intp_t
1165  * ctypedef npy_uintp      uintp_t             # <<<<<<<<<<<<<<
1166  *
1167  * ctypedef npy_double     float_t
1168  */
1169 typedef npy_uintp __pyx_t_5numpy_uintp_t;
1170 
1171 /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":724
1172  * ctypedef npy_uintp      uintp_t
1173  *
1174  * ctypedef npy_double     float_t             # <<<<<<<<<<<<<<
1175  * ctypedef npy_double     double_t
1176  * ctypedef npy_longdouble longdouble_t
1177  */
1178 typedef npy_double __pyx_t_5numpy_float_t;
1179 
1180 /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":725
1181  *
1182  * ctypedef npy_double     float_t
1183  * ctypedef npy_double     double_t             # <<<<<<<<<<<<<<
1184  * ctypedef npy_longdouble longdouble_t
1185  *
1186  */
1187 typedef npy_double __pyx_t_5numpy_double_t;
1188 
1189 /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":726
1190  * ctypedef npy_double     float_t
1191  * ctypedef npy_double     double_t
1192  * ctypedef npy_longdouble longdouble_t             # <<<<<<<<<<<<<<
1193  *
1194  * ctypedef npy_cfloat      cfloat_t
1195  */
1196 typedef npy_longdouble __pyx_t_5numpy_longdouble_t;
1197 
1198 /* "qutip/cy/parameters.pxi":5
1199  *
1200  * DTYPE = np.float64
1201  * ctypedef cnp.float64_t DTYPE_t             # <<<<<<<<<<<<<<
1202  *
1203  * ITYPE = np.int32
1204  */
1205 typedef __pyx_t_5numpy_float64_t __pyx_t_5qutip_2cy_10spmatfuncs_DTYPE_t;
1206 
1207 /* "qutip/cy/parameters.pxi":8
1208  *
1209  * ITYPE = np.int32
1210  * ctypedef cnp.int32_t ITYPE_t             # <<<<<<<<<<<<<<
1211  *
1212  * CTYPE = np.complex128
1213  */
1214 typedef __pyx_t_5numpy_int32_t __pyx_t_5qutip_2cy_10spmatfuncs_ITYPE_t;
1215 
1216 /* "qutip/cy/parameters.pxi":14
1217  *
1218  * CTYPE = np.int64
1219  * ctypedef cnp.int64_t LTYPE_t             # <<<<<<<<<<<<<<
1220  */
1221 typedef __pyx_t_5numpy_int64_t __pyx_t_5qutip_2cy_10spmatfuncs_LTYPE_t;
1222 /* Declarations.proto */
1223 #if CYTHON_CCOMPLEX
1224   #ifdef __cplusplus
1225     typedef ::std::complex< double > __pyx_t_double_complex;
1226   #else
1227     typedef double _Complex __pyx_t_double_complex;
1228   #endif
1229 #else
1230     typedef struct { double real, imag; } __pyx_t_double_complex;
1231 #endif
1232 static CYTHON_INLINE __pyx_t_double_complex __pyx_t_double_complex_from_parts(double, double);
1233 
1234 /* Declarations.proto */
1235 #if CYTHON_CCOMPLEX
1236   #ifdef __cplusplus
1237     typedef ::std::complex< float > __pyx_t_float_complex;
1238   #else
1239     typedef float _Complex __pyx_t_float_complex;
1240   #endif
1241 #else
1242     typedef struct { float real, imag; } __pyx_t_float_complex;
1243 #endif
1244 static CYTHON_INLINE __pyx_t_float_complex __pyx_t_float_complex_from_parts(float, float);
1245 
1246 
1247 /*--- Type declarations ---*/
1248 struct __pyx_array_obj;
1249 struct __pyx_MemviewEnum_obj;
1250 struct __pyx_memoryview_obj;
1251 struct __pyx_memoryviewslice_obj;
1252 
1253 /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":728
1254  * ctypedef npy_longdouble longdouble_t
1255  *
1256  * ctypedef npy_cfloat      cfloat_t             # <<<<<<<<<<<<<<
1257  * ctypedef npy_cdouble     cdouble_t
1258  * ctypedef npy_clongdouble clongdouble_t
1259  */
1260 typedef npy_cfloat __pyx_t_5numpy_cfloat_t;
1261 
1262 /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":729
1263  *
1264  * ctypedef npy_cfloat      cfloat_t
1265  * ctypedef npy_cdouble     cdouble_t             # <<<<<<<<<<<<<<
1266  * ctypedef npy_clongdouble clongdouble_t
1267  *
1268  */
1269 typedef npy_cdouble __pyx_t_5numpy_cdouble_t;
1270 
1271 /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":730
1272  * ctypedef npy_cfloat      cfloat_t
1273  * ctypedef npy_cdouble     cdouble_t
1274  * ctypedef npy_clongdouble clongdouble_t             # <<<<<<<<<<<<<<
1275  *
1276  * ctypedef npy_cdouble     complex_t
1277  */
1278 typedef npy_clongdouble __pyx_t_5numpy_clongdouble_t;
1279 
1280 /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":732
1281  * ctypedef npy_clongdouble clongdouble_t
1282  *
1283  * ctypedef npy_cdouble     complex_t             # <<<<<<<<<<<<<<
1284  *
1285  * cdef inline object PyArray_MultiIterNew1(a):
1286  */
1287 typedef npy_cdouble __pyx_t_5numpy_complex_t;
1288 struct __pyx_opt_args_5qutip_2cy_10spmatfuncs_zcsr_mat_elem;
1289 
1290 /* "qutip/cy/spmatfuncs.pyx":526
1291  * @cython.boundscheck(False)
1292  * @cython.wraparound(False)
1293  * cpdef double complex zcsr_mat_elem(object A, object left, object right, bool bra_ket=1):             # <<<<<<<<<<<<<<
1294  *     """
1295  *     Computes the matrix element for an operator A and left and right vectors.
1296  */
1297 struct __pyx_opt_args_5qutip_2cy_10spmatfuncs_zcsr_mat_elem {
1298   int __pyx_n;
1299   bool bra_ket;
1300 };
1301 
1302 /* "View.MemoryView":105
1303  *
1304  * @cname("__pyx_array")
1305  * cdef class array:             # <<<<<<<<<<<<<<
1306  *
1307  *     cdef:
1308  */
1309 struct __pyx_array_obj {
1310   PyObject_HEAD
1311   struct __pyx_vtabstruct_array *__pyx_vtab;
1312   char *data;
1313   Py_ssize_t len;
1314   char *format;
1315   int ndim;
1316   Py_ssize_t *_shape;
1317   Py_ssize_t *_strides;
1318   Py_ssize_t itemsize;
1319   PyObject *mode;
1320   PyObject *_format;
1321   void (*callback_free_data)(void *);
1322   int free_data;
1323   int dtype_is_object;
1324 };
1325 
1326 
1327 /* "View.MemoryView":279
1328  *
1329  * @cname('__pyx_MemviewEnum')
1330  * cdef class Enum(object):             # <<<<<<<<<<<<<<
1331  *     cdef object name
1332  *     def __init__(self, name):
1333  */
1334 struct __pyx_MemviewEnum_obj {
1335   PyObject_HEAD
1336   PyObject *name;
1337 };
1338 
1339 
1340 /* "View.MemoryView":330
1341  *
1342  * @cname('__pyx_memoryview')
1343  * cdef class memoryview(object):             # <<<<<<<<<<<<<<
1344  *
1345  *     cdef object obj
1346  */
1347 struct __pyx_memoryview_obj {
1348   PyObject_HEAD
1349   struct __pyx_vtabstruct_memoryview *__pyx_vtab;
1350   PyObject *obj;
1351   PyObject *_size;
1352   PyObject *_array_interface;
1353   PyThread_type_lock lock;
1354   __pyx_atomic_int acquisition_count[2];
1355   __pyx_atomic_int *acquisition_count_aligned_p;
1356   Py_buffer view;
1357   int flags;
1358   int dtype_is_object;
1359   __Pyx_TypeInfo *typeinfo;
1360 };
1361 
1362 
1363 /* "View.MemoryView":965
1364  *
1365  * @cname('__pyx_memoryviewslice')
1366  * cdef class _memoryviewslice(memoryview):             # <<<<<<<<<<<<<<
1367  *     "Internal class for passing memoryview slices to Python"
1368  *
1369  */
1370 struct __pyx_memoryviewslice_obj {
1371   struct __pyx_memoryview_obj __pyx_base;
1372   __Pyx_memviewslice from_slice;
1373   PyObject *from_object;
1374   PyObject *(*to_object_func)(char *);
1375   int (*to_dtype_func)(char *, PyObject *);
1376 };
1377 
1378 
1379 
1380 /* "View.MemoryView":105
1381  *
1382  * @cname("__pyx_array")
1383  * cdef class array:             # <<<<<<<<<<<<<<
1384  *
1385  *     cdef:
1386  */
1387 
1388 struct __pyx_vtabstruct_array {
1389   PyObject *(*get_memview)(struct __pyx_array_obj *);
1390 };
1391 static struct __pyx_vtabstruct_array *__pyx_vtabptr_array;
1392 
1393 
1394 /* "View.MemoryView":330
1395  *
1396  * @cname('__pyx_memoryview')
1397  * cdef class memoryview(object):             # <<<<<<<<<<<<<<
1398  *
1399  *     cdef object obj
1400  */
1401 
1402 struct __pyx_vtabstruct_memoryview {
1403   char *(*get_item_pointer)(struct __pyx_memoryview_obj *, PyObject *);
1404   PyObject *(*is_slice)(struct __pyx_memoryview_obj *, PyObject *);
1405   PyObject *(*setitem_slice_assignment)(struct __pyx_memoryview_obj *, PyObject *, PyObject *);
1406   PyObject *(*setitem_slice_assign_scalar)(struct __pyx_memoryview_obj *, struct __pyx_memoryview_obj *, PyObject *);
1407   PyObject *(*setitem_indexed)(struct __pyx_memoryview_obj *, PyObject *, PyObject *);
1408   PyObject *(*convert_item_to_object)(struct __pyx_memoryview_obj *, char *);
1409   PyObject *(*assign_item_from_object)(struct __pyx_memoryview_obj *, char *, PyObject *);
1410 };
1411 static struct __pyx_vtabstruct_memoryview *__pyx_vtabptr_memoryview;
1412 
1413 
1414 /* "View.MemoryView":965
1415  *
1416  * @cname('__pyx_memoryviewslice')
1417  * cdef class _memoryviewslice(memoryview):             # <<<<<<<<<<<<<<
1418  *     "Internal class for passing memoryview slices to Python"
1419  *
1420  */
1421 
1422 struct __pyx_vtabstruct__memoryviewslice {
1423   struct __pyx_vtabstruct_memoryview __pyx_base;
1424 };
1425 static struct __pyx_vtabstruct__memoryviewslice *__pyx_vtabptr__memoryviewslice;
1426 
1427 /* --- Runtime support code (head) --- */
1428 /* Refnanny.proto */
1429 #ifndef CYTHON_REFNANNY
1430   #define CYTHON_REFNANNY 0
1431 #endif
1432 #if CYTHON_REFNANNY
1433   typedef struct {
1434     void (*INCREF)(void*, PyObject*, int);
1435     void (*DECREF)(void*, PyObject*, int);
1436     void (*GOTREF)(void*, PyObject*, int);
1437     void (*GIVEREF)(void*, PyObject*, int);
1438     void* (*SetupContext)(const char*, int, const char*);
1439     void (*FinishContext)(void**);
1440   } __Pyx_RefNannyAPIStruct;
1441   static __Pyx_RefNannyAPIStruct *__Pyx_RefNanny = NULL;
1442   static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname);
1443   #define __Pyx_RefNannyDeclarations void *__pyx_refnanny = NULL;
1444 #ifdef WITH_THREAD
1445   #define __Pyx_RefNannySetupContext(name, acquire_gil)\
1446           if (acquire_gil) {\
1447               PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure();\
1448               __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__);\
1449               PyGILState_Release(__pyx_gilstate_save);\
1450           } else {\
1451               __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__);\
1452           }
1453 #else
1454   #define __Pyx_RefNannySetupContext(name, acquire_gil)\
1455           __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__)
1456 #endif
1457   #define __Pyx_RefNannyFinishContext()\
1458           __Pyx_RefNanny->FinishContext(&__pyx_refnanny)
1459   #define __Pyx_INCREF(r)  __Pyx_RefNanny->INCREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
1460   #define __Pyx_DECREF(r)  __Pyx_RefNanny->DECREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
1461   #define __Pyx_GOTREF(r)  __Pyx_RefNanny->GOTREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
1462   #define __Pyx_GIVEREF(r) __Pyx_RefNanny->GIVEREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
1463   #define __Pyx_XINCREF(r)  do { if((r) != NULL) {__Pyx_INCREF(r); }} while(0)
1464   #define __Pyx_XDECREF(r)  do { if((r) != NULL) {__Pyx_DECREF(r); }} while(0)
1465   #define __Pyx_XGOTREF(r)  do { if((r) != NULL) {__Pyx_GOTREF(r); }} while(0)
1466   #define __Pyx_XGIVEREF(r) do { if((r) != NULL) {__Pyx_GIVEREF(r);}} while(0)
1467 #else
1468   #define __Pyx_RefNannyDeclarations
1469   #define __Pyx_RefNannySetupContext(name, acquire_gil)
1470   #define __Pyx_RefNannyFinishContext()
1471   #define __Pyx_INCREF(r) Py_INCREF(r)
1472   #define __Pyx_DECREF(r) Py_DECREF(r)
1473   #define __Pyx_GOTREF(r)
1474   #define __Pyx_GIVEREF(r)
1475   #define __Pyx_XINCREF(r) Py_XINCREF(r)
1476   #define __Pyx_XDECREF(r) Py_XDECREF(r)
1477   #define __Pyx_XGOTREF(r)
1478   #define __Pyx_XGIVEREF(r)
1479 #endif
1480 #define __Pyx_XDECREF_SET(r, v) do {\
1481         PyObject *tmp = (PyObject *) r;\
1482         r = v; __Pyx_XDECREF(tmp);\
1483     } while (0)
1484 #define __Pyx_DECREF_SET(r, v) do {\
1485         PyObject *tmp = (PyObject *) r;\
1486         r = v; __Pyx_DECREF(tmp);\
1487     } while (0)
1488 #define __Pyx_CLEAR(r)    do { PyObject* tmp = ((PyObject*)(r)); r = NULL; __Pyx_DECREF(tmp);} while(0)
1489 #define __Pyx_XCLEAR(r)   do { if((r) != NULL) {PyObject* tmp = ((PyObject*)(r)); r = NULL; __Pyx_DECREF(tmp);}} while(0)
1490 
1491 /* PyObjectGetAttrStr.proto */
1492 #if CYTHON_USE_TYPE_SLOTS
1493 static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStr(PyObject* obj, PyObject* attr_name);
1494 #else
1495 #define __Pyx_PyObject_GetAttrStr(o,n) PyObject_GetAttr(o,n)
1496 #endif
1497 
1498 /* GetBuiltinName.proto */
1499 static PyObject *__Pyx_GetBuiltinName(PyObject *name);
1500 
1501 /* MemviewSliceInit.proto */
1502 #define __Pyx_BUF_MAX_NDIMS %(BUF_MAX_NDIMS)d
1503 #define __Pyx_MEMVIEW_DIRECT   1
1504 #define __Pyx_MEMVIEW_PTR      2
1505 #define __Pyx_MEMVIEW_FULL     4
1506 #define __Pyx_MEMVIEW_CONTIG   8
1507 #define __Pyx_MEMVIEW_STRIDED  16
1508 #define __Pyx_MEMVIEW_FOLLOW   32
1509 #define __Pyx_IS_C_CONTIG 1
1510 #define __Pyx_IS_F_CONTIG 2
1511 static int __Pyx_init_memviewslice(
1512                 struct __pyx_memoryview_obj *memview,
1513                 int ndim,
1514                 __Pyx_memviewslice *memviewslice,
1515                 int memview_is_new_reference);
1516 static CYTHON_INLINE int __pyx_add_acquisition_count_locked(
1517     __pyx_atomic_int *acquisition_count, PyThread_type_lock lock);
1518 static CYTHON_INLINE int __pyx_sub_acquisition_count_locked(
1519     __pyx_atomic_int *acquisition_count, PyThread_type_lock lock);
1520 #define __pyx_get_slice_count_pointer(memview) (memview->acquisition_count_aligned_p)
1521 #define __pyx_get_slice_count(memview) (*__pyx_get_slice_count_pointer(memview))
1522 #define __PYX_INC_MEMVIEW(slice, have_gil) __Pyx_INC_MEMVIEW(slice, have_gil, __LINE__)
1523 #define __PYX_XDEC_MEMVIEW(slice, have_gil) __Pyx_XDEC_MEMVIEW(slice, have_gil, __LINE__)
1524 static CYTHON_INLINE void __Pyx_INC_MEMVIEW(__Pyx_memviewslice *, int, int);
1525 static CYTHON_INLINE void __Pyx_XDEC_MEMVIEW(__Pyx_memviewslice *, int, int);
1526 
1527 /* RaiseArgTupleInvalid.proto */
1528 static void __Pyx_RaiseArgtupleInvalid(const char* func_name, int exact,
1529     Py_ssize_t num_min, Py_ssize_t num_max, Py_ssize_t num_found);
1530 
1531 /* RaiseDoubleKeywords.proto */
1532 static void __Pyx_RaiseDoubleKeywordsError(const char* func_name, PyObject* kw_name);
1533 
1534 /* ParseKeywords.proto */
1535 static int __Pyx_ParseOptionalKeywords(PyObject *kwds, PyObject **argnames[],\
1536     PyObject *kwds2, PyObject *values[], Py_ssize_t num_pos_args,\
1537     const char* function_name);
1538 
1539 /* None.proto */
1540 static CYTHON_INLINE void __Pyx_RaiseUnboundLocalError(const char *varname);
1541 
1542 /* PyDictVersioning.proto */
1543 #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_TYPE_SLOTS
1544 #define __PYX_DICT_VERSION_INIT  ((PY_UINT64_T) -1)
1545 #define __PYX_GET_DICT_VERSION(dict)  (((PyDictObject*)(dict))->ma_version_tag)
1546 #define __PYX_UPDATE_DICT_CACHE(dict, value, cache_var, version_var)\
1547     (version_var) = __PYX_GET_DICT_VERSION(dict);\
1548     (cache_var) = (value);
1549 #define __PYX_PY_DICT_LOOKUP_IF_MODIFIED(VAR, DICT, LOOKUP) {\
1550     static PY_UINT64_T __pyx_dict_version = 0;\
1551     static PyObject *__pyx_dict_cached_value = NULL;\
1552     if (likely(__PYX_GET_DICT_VERSION(DICT) == __pyx_dict_version)) {\
1553         (VAR) = __pyx_dict_cached_value;\
1554     } else {\
1555         (VAR) = __pyx_dict_cached_value = (LOOKUP);\
1556         __pyx_dict_version = __PYX_GET_DICT_VERSION(DICT);\
1557     }\
1558 }
1559 static CYTHON_INLINE PY_UINT64_T __Pyx_get_tp_dict_version(PyObject *obj);
1560 static CYTHON_INLINE PY_UINT64_T __Pyx_get_object_dict_version(PyObject *obj);
1561 static CYTHON_INLINE int __Pyx_object_dict_version_matches(PyObject* obj, PY_UINT64_T tp_dict_version, PY_UINT64_T obj_dict_version);
1562 #else
1563 #define __PYX_GET_DICT_VERSION(dict)  (0)
1564 #define __PYX_UPDATE_DICT_CACHE(dict, value, cache_var, version_var)
1565 #define __PYX_PY_DICT_LOOKUP_IF_MODIFIED(VAR, DICT, LOOKUP)  (VAR) = (LOOKUP);
1566 #endif
1567 
1568 /* GetModuleGlobalName.proto */
1569 #if CYTHON_USE_DICT_VERSIONS
1570 #define __Pyx_GetModuleGlobalName(var, name)  {\
1571     static PY_UINT64_T __pyx_dict_version = 0;\
1572     static PyObject *__pyx_dict_cached_value = NULL;\
1573     (var) = (likely(__pyx_dict_version == __PYX_GET_DICT_VERSION(__pyx_d))) ?\
1574         (likely(__pyx_dict_cached_value) ? __Pyx_NewRef(__pyx_dict_cached_value) : __Pyx_GetBuiltinName(name)) :\
1575         __Pyx__GetModuleGlobalName(name, &__pyx_dict_version, &__pyx_dict_cached_value);\
1576 }
1577 #define __Pyx_GetModuleGlobalNameUncached(var, name)  {\
1578     PY_UINT64_T __pyx_dict_version;\
1579     PyObject *__pyx_dict_cached_value;\
1580     (var) = __Pyx__GetModuleGlobalName(name, &__pyx_dict_version, &__pyx_dict_cached_value);\
1581 }
1582 static PyObject *__Pyx__GetModuleGlobalName(PyObject *name, PY_UINT64_T *dict_version, PyObject **dict_cached_value);
1583 #else
1584 #define __Pyx_GetModuleGlobalName(var, name)  (var) = __Pyx__GetModuleGlobalName(name)
1585 #define __Pyx_GetModuleGlobalNameUncached(var, name)  (var) = __Pyx__GetModuleGlobalName(name)
1586 static CYTHON_INLINE PyObject *__Pyx__GetModuleGlobalName(PyObject *name);
1587 #endif
1588 
1589 /* PyObjectCall.proto */
1590 #if CYTHON_COMPILING_IN_CPYTHON
1591 static CYTHON_INLINE PyObject* __Pyx_PyObject_Call(PyObject *func, PyObject *arg, PyObject *kw);
1592 #else
1593 #define __Pyx_PyObject_Call(func, arg, kw) PyObject_Call(func, arg, kw)
1594 #endif
1595 
1596 /* ExtTypeTest.proto */
1597 static CYTHON_INLINE int __Pyx_TypeTest(PyObject *obj, PyTypeObject *type);
1598 
1599 /* IsLittleEndian.proto */
1600 static CYTHON_INLINE int __Pyx_Is_Little_Endian(void);
1601 
1602 /* BufferFormatCheck.proto */
1603 static const char* __Pyx_BufFmt_CheckString(__Pyx_BufFmt_Context* ctx, const char* ts);
1604 static void __Pyx_BufFmt_Init(__Pyx_BufFmt_Context* ctx,
1605                               __Pyx_BufFmt_StackElem* stack,
1606                               __Pyx_TypeInfo* type);
1607 
1608 /* BufferGetAndValidate.proto */
1609 #define __Pyx_GetBufferAndValidate(buf, obj, dtype, flags, nd, cast, stack)\
1610     ((obj == Py_None || obj == NULL) ?\
1611     (__Pyx_ZeroBuffer(buf), 0) :\
1612     __Pyx__GetBufferAndValidate(buf, obj, dtype, flags, nd, cast, stack))
1613 static int  __Pyx__GetBufferAndValidate(Py_buffer* buf, PyObject* obj,
1614     __Pyx_TypeInfo* dtype, int flags, int nd, int cast, __Pyx_BufFmt_StackElem* stack);
1615 static void __Pyx_ZeroBuffer(Py_buffer* buf);
1616 static CYTHON_INLINE void __Pyx_SafeReleaseBuffer(Py_buffer* info);
1617 static Py_ssize_t __Pyx_minusones[] = { -1, -1, -1, -1, -1, -1, -1, -1 };
1618 static Py_ssize_t __Pyx_zeros[] = { 0, 0, 0, 0, 0, 0, 0, 0 };
1619 
1620 #define __Pyx_BufPtrCContig1d(type, buf, i0, s0) ((type)buf + i0)
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 /* BufferIndexError.proto */
1658 static void __Pyx_RaiseBufferIndexError(int axis);
1659 
1660 /* WriteUnraisableException.proto */
1661 static void __Pyx_WriteUnraisable(const char *name, int clineno,
1662                                   int lineno, const char *filename,
1663                                   int full_traceback, int nogil);
1664 
1665 /* PyIntBinop.proto */
1666 #if !CYTHON_COMPILING_IN_PYPY
1667 static PyObject* __Pyx_PyInt_SubtractObjC(PyObject *op1, PyObject *op2, long intval, int inplace, int zerodivision_check);
1668 #else
1669 #define __Pyx_PyInt_SubtractObjC(op1, op2, intval, inplace, zerodivision_check)\
1670     (inplace ? PyNumber_InPlaceSubtract(op1, op2) : PyNumber_Subtract(op1, op2))
1671 #endif
1672 
1673 /* GetItemInt.proto */
1674 #define __Pyx_GetItemInt(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck)\
1675     (__Pyx_fits_Py_ssize_t(i, type, is_signed) ?\
1676     __Pyx_GetItemInt_Fast(o, (Py_ssize_t)i, is_list, wraparound, boundscheck) :\
1677     (is_list ? (PyErr_SetString(PyExc_IndexError, "list index out of range"), (PyObject*)NULL) :\
1678                __Pyx_GetItemInt_Generic(o, to_py_func(i))))
1679 #define __Pyx_GetItemInt_List(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck)\
1680     (__Pyx_fits_Py_ssize_t(i, type, is_signed) ?\
1681     __Pyx_GetItemInt_List_Fast(o, (Py_ssize_t)i, wraparound, boundscheck) :\
1682     (PyErr_SetString(PyExc_IndexError, "list index out of range"), (PyObject*)NULL))
1683 static CYTHON_INLINE PyObject *__Pyx_GetItemInt_List_Fast(PyObject *o, Py_ssize_t i,
1684                                                               int wraparound, int boundscheck);
1685 #define __Pyx_GetItemInt_Tuple(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck)\
1686     (__Pyx_fits_Py_ssize_t(i, type, is_signed) ?\
1687     __Pyx_GetItemInt_Tuple_Fast(o, (Py_ssize_t)i, wraparound, boundscheck) :\
1688     (PyErr_SetString(PyExc_IndexError, "tuple index out of range"), (PyObject*)NULL))
1689 static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Tuple_Fast(PyObject *o, Py_ssize_t i,
1690                                                               int wraparound, int boundscheck);
1691 static PyObject *__Pyx_GetItemInt_Generic(PyObject *o, PyObject* j);
1692 static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Fast(PyObject *o, Py_ssize_t i,
1693                                                      int is_list, int wraparound, int boundscheck);
1694 
1695 /* DictGetItem.proto */
1696 #if PY_MAJOR_VERSION >= 3 && !CYTHON_COMPILING_IN_PYPY
1697 static PyObject *__Pyx_PyDict_GetItem(PyObject *d, PyObject* key);
1698 #define __Pyx_PyObject_Dict_GetItem(obj, name)\
1699     (likely(PyDict_CheckExact(obj)) ?\
1700      __Pyx_PyDict_GetItem(obj, name) : PyObject_GetItem(obj, name))
1701 #else
1702 #define __Pyx_PyDict_GetItem(d, key) PyObject_GetItem(d, key)
1703 #define __Pyx_PyObject_Dict_GetItem(obj, name)  PyObject_GetItem(obj, name)
1704 #endif
1705 
1706 /* ArgTypeTest.proto */
1707 #define __Pyx_ArgTypeTest(obj, type, none_allowed, name, exact)\
1708     ((likely((Py_TYPE(obj) == type) | (none_allowed && (obj == Py_None)))) ? 1 :\
1709         __Pyx__ArgTypeTest(obj, type, name, exact))
1710 static int __Pyx__ArgTypeTest(PyObject *obj, PyTypeObject *type, const char *name, int exact);
1711 
1712 /* PyFunctionFastCall.proto */
1713 #if CYTHON_FAST_PYCALL
1714 #define __Pyx_PyFunction_FastCall(func, args, nargs)\
1715     __Pyx_PyFunction_FastCallDict((func), (args), (nargs), NULL)
1716 #if 1 || PY_VERSION_HEX < 0x030600B1
1717 static PyObject *__Pyx_PyFunction_FastCallDict(PyObject *func, PyObject **args, Py_ssize_t nargs, PyObject *kwargs);
1718 #else
1719 #define __Pyx_PyFunction_FastCallDict(func, args, nargs, kwargs) _PyFunction_FastCallDict(func, args, nargs, kwargs)
1720 #endif
1721 #define __Pyx_BUILD_ASSERT_EXPR(cond)\
1722     (sizeof(char [1 - 2*!(cond)]) - 1)
1723 #ifndef Py_MEMBER_SIZE
1724 #define Py_MEMBER_SIZE(type, member) sizeof(((type *)0)->member)
1725 #endif
1726   static size_t __pyx_pyframe_localsplus_offset = 0;
1727   #include "frameobject.h"
1728   #define __Pxy_PyFrame_Initialize_Offsets()\
1729     ((void)__Pyx_BUILD_ASSERT_EXPR(sizeof(PyFrameObject) == offsetof(PyFrameObject, f_localsplus) + Py_MEMBER_SIZE(PyFrameObject, f_localsplus)),\
1730      (void)(__pyx_pyframe_localsplus_offset = ((size_t)PyFrame_Type.tp_basicsize) - Py_MEMBER_SIZE(PyFrameObject, f_localsplus)))
1731   #define __Pyx_PyFrame_GetLocalsplus(frame)\
1732     (assert(__pyx_pyframe_localsplus_offset), (PyObject **)(((char *)(frame)) + __pyx_pyframe_localsplus_offset))
1733 #endif
1734 
1735 /* PyCFunctionFastCall.proto */
1736 #if CYTHON_FAST_PYCCALL
1737 static CYTHON_INLINE PyObject *__Pyx_PyCFunction_FastCall(PyObject *func, PyObject **args, Py_ssize_t nargs);
1738 #else
1739 #define __Pyx_PyCFunction_FastCall(func, args, nargs)  (assert(0), NULL)
1740 #endif
1741 
1742 /* GetTopmostException.proto */
1743 #if CYTHON_USE_EXC_INFO_STACK
1744 static _PyErr_StackItem * __Pyx_PyErr_GetTopmostException(PyThreadState *tstate);
1745 #endif
1746 
1747 /* SaveResetException.proto */
1748 #if CYTHON_FAST_THREAD_STATE
1749 #define __Pyx_ExceptionSave(type, value, tb)  __Pyx__ExceptionSave(__pyx_tstate, type, value, tb)
1750 static CYTHON_INLINE void __Pyx__ExceptionSave(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb);
1751 #define __Pyx_ExceptionReset(type, value, tb)  __Pyx__ExceptionReset(__pyx_tstate, type, value, tb)
1752 static CYTHON_INLINE void __Pyx__ExceptionReset(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb);
1753 #else
1754 #define __Pyx_ExceptionSave(type, value, tb)   PyErr_GetExcInfo(type, value, tb)
1755 #define __Pyx_ExceptionReset(type, value, tb)  PyErr_SetExcInfo(type, value, tb)
1756 #endif
1757 
1758 /* PyErrExceptionMatches.proto */
1759 #if CYTHON_FAST_THREAD_STATE
1760 #define __Pyx_PyErr_ExceptionMatches(err) __Pyx_PyErr_ExceptionMatchesInState(__pyx_tstate, err)
1761 static CYTHON_INLINE int __Pyx_PyErr_ExceptionMatchesInState(PyThreadState* tstate, PyObject* err);
1762 #else
1763 #define __Pyx_PyErr_ExceptionMatches(err)  PyErr_ExceptionMatches(err)
1764 #endif
1765 
1766 /* GetException.proto */
1767 #if CYTHON_FAST_THREAD_STATE
1768 #define __Pyx_GetException(type, value, tb)  __Pyx__GetException(__pyx_tstate, type, value, tb)
1769 static int __Pyx__GetException(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb);
1770 #else
1771 static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb);
1772 #endif
1773 
1774 /* RaiseException.proto */
1775 static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause);
1776 
1777 /* PyObjectCall2Args.proto */
1778 static CYTHON_UNUSED PyObject* __Pyx_PyObject_Call2Args(PyObject* function, PyObject* arg1, PyObject* arg2);
1779 
1780 /* PyObjectCallMethO.proto */
1781 #if CYTHON_COMPILING_IN_CPYTHON
1782 static CYTHON_INLINE PyObject* __Pyx_PyObject_CallMethO(PyObject *func, PyObject *arg);
1783 #endif
1784 
1785 /* PyObjectCallOneArg.proto */
1786 static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg);
1787 
1788 /* IncludeStringH.proto */
1789 #include <string.h>
1790 
1791 /* BytesEquals.proto */
1792 static CYTHON_INLINE int __Pyx_PyBytes_Equals(PyObject* s1, PyObject* s2, int equals);
1793 
1794 /* UnicodeEquals.proto */
1795 static CYTHON_INLINE int __Pyx_PyUnicode_Equals(PyObject* s1, PyObject* s2, int equals);
1796 
1797 /* StrEquals.proto */
1798 #if PY_MAJOR_VERSION >= 3
1799 #define __Pyx_PyString_Equals __Pyx_PyUnicode_Equals
1800 #else
1801 #define __Pyx_PyString_Equals __Pyx_PyBytes_Equals
1802 #endif
1803 
1804 /* None.proto */
1805 static CYTHON_INLINE Py_ssize_t __Pyx_div_Py_ssize_t(Py_ssize_t, Py_ssize_t);
1806 
1807 /* UnaryNegOverflows.proto */
1808 #define UNARY_NEG_WOULD_OVERFLOW(x)\
1809         (((x) < 0) & ((unsigned long)(x) == 0-(unsigned long)(x)))
1810 
1811 static CYTHON_UNUSED int __pyx_array_getbuffer(PyObject *__pyx_v_self, Py_buffer *__pyx_v_info, int __pyx_v_flags); /*proto*/
1812 static PyObject *__pyx_array_get_memview(struct __pyx_array_obj *); /*proto*/
1813 /* GetAttr.proto */
1814 static CYTHON_INLINE PyObject *__Pyx_GetAttr(PyObject *, PyObject *);
1815 
1816 /* ObjectGetItem.proto */
1817 #if CYTHON_USE_TYPE_SLOTS
1818 static CYTHON_INLINE PyObject *__Pyx_PyObject_GetItem(PyObject *obj, PyObject* key);
1819 #else
1820 #define __Pyx_PyObject_GetItem(obj, key)  PyObject_GetItem(obj, key)
1821 #endif
1822 
1823 /* decode_c_string_utf16.proto */
__Pyx_PyUnicode_DecodeUTF16(const char * s,Py_ssize_t size,const char * errors)1824 static CYTHON_INLINE PyObject *__Pyx_PyUnicode_DecodeUTF16(const char *s, Py_ssize_t size, const char *errors) {
1825     int byteorder = 0;
1826     return PyUnicode_DecodeUTF16(s, size, errors, &byteorder);
1827 }
__Pyx_PyUnicode_DecodeUTF16LE(const char * s,Py_ssize_t size,const char * errors)1828 static CYTHON_INLINE PyObject *__Pyx_PyUnicode_DecodeUTF16LE(const char *s, Py_ssize_t size, const char *errors) {
1829     int byteorder = -1;
1830     return PyUnicode_DecodeUTF16(s, size, errors, &byteorder);
1831 }
__Pyx_PyUnicode_DecodeUTF16BE(const char * s,Py_ssize_t size,const char * errors)1832 static CYTHON_INLINE PyObject *__Pyx_PyUnicode_DecodeUTF16BE(const char *s, Py_ssize_t size, const char *errors) {
1833     int byteorder = 1;
1834     return PyUnicode_DecodeUTF16(s, size, errors, &byteorder);
1835 }
1836 
1837 /* decode_c_string.proto */
1838 static CYTHON_INLINE PyObject* __Pyx_decode_c_string(
1839          const char* cstring, Py_ssize_t start, Py_ssize_t stop,
1840          const char* encoding, const char* errors,
1841          PyObject* (*decode_func)(const char *s, Py_ssize_t size, const char *errors));
1842 
1843 /* GetAttr3.proto */
1844 static CYTHON_INLINE PyObject *__Pyx_GetAttr3(PyObject *, PyObject *, PyObject *);
1845 
1846 /* RaiseTooManyValuesToUnpack.proto */
1847 static CYTHON_INLINE void __Pyx_RaiseTooManyValuesError(Py_ssize_t expected);
1848 
1849 /* RaiseNeedMoreValuesToUnpack.proto */
1850 static CYTHON_INLINE void __Pyx_RaiseNeedMoreValuesError(Py_ssize_t index);
1851 
1852 /* RaiseNoneIterError.proto */
1853 static CYTHON_INLINE void __Pyx_RaiseNoneNotIterableError(void);
1854 
1855 /* SwapException.proto */
1856 #if CYTHON_FAST_THREAD_STATE
1857 #define __Pyx_ExceptionSwap(type, value, tb)  __Pyx__ExceptionSwap(__pyx_tstate, type, value, tb)
1858 static CYTHON_INLINE void __Pyx__ExceptionSwap(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb);
1859 #else
1860 static CYTHON_INLINE void __Pyx_ExceptionSwap(PyObject **type, PyObject **value, PyObject **tb);
1861 #endif
1862 
1863 /* Import.proto */
1864 static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, int level);
1865 
1866 /* FastTypeChecks.proto */
1867 #if CYTHON_COMPILING_IN_CPYTHON
1868 #define __Pyx_TypeCheck(obj, type) __Pyx_IsSubtype(Py_TYPE(obj), (PyTypeObject *)type)
1869 static CYTHON_INLINE int __Pyx_IsSubtype(PyTypeObject *a, PyTypeObject *b);
1870 static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches(PyObject *err, PyObject *type);
1871 static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches2(PyObject *err, PyObject *type1, PyObject *type2);
1872 #else
1873 #define __Pyx_TypeCheck(obj, type) PyObject_TypeCheck(obj, (PyTypeObject *)type)
1874 #define __Pyx_PyErr_GivenExceptionMatches(err, type) PyErr_GivenExceptionMatches(err, type)
1875 #define __Pyx_PyErr_GivenExceptionMatches2(err, type1, type2) (PyErr_GivenExceptionMatches(err, type1) || PyErr_GivenExceptionMatches(err, type2))
1876 #endif
1877 #define __Pyx_PyException_Check(obj) __Pyx_TypeCheck(obj, PyExc_Exception)
1878 
1879 static CYTHON_UNUSED int __pyx_memoryview_getbuffer(PyObject *__pyx_v_self, Py_buffer *__pyx_v_info, int __pyx_v_flags); /*proto*/
1880 /* ListCompAppend.proto */
1881 #if CYTHON_USE_PYLIST_INTERNALS && CYTHON_ASSUME_SAFE_MACROS
__Pyx_ListComp_Append(PyObject * list,PyObject * x)1882 static CYTHON_INLINE int __Pyx_ListComp_Append(PyObject* list, PyObject* x) {
1883     PyListObject* L = (PyListObject*) list;
1884     Py_ssize_t len = Py_SIZE(list);
1885     if (likely(L->allocated > len)) {
1886         Py_INCREF(x);
1887         PyList_SET_ITEM(list, len, x);
1888         __Pyx_SET_SIZE(list, len + 1);
1889         return 0;
1890     }
1891     return PyList_Append(list, x);
1892 }
1893 #else
1894 #define __Pyx_ListComp_Append(L,x) PyList_Append(L,x)
1895 #endif
1896 
1897 /* PyIntBinop.proto */
1898 #if !CYTHON_COMPILING_IN_PYPY
1899 static PyObject* __Pyx_PyInt_AddObjC(PyObject *op1, PyObject *op2, long intval, int inplace, int zerodivision_check);
1900 #else
1901 #define __Pyx_PyInt_AddObjC(op1, op2, intval, inplace, zerodivision_check)\
1902     (inplace ? PyNumber_InPlaceAdd(op1, op2) : PyNumber_Add(op1, op2))
1903 #endif
1904 
1905 /* ListExtend.proto */
__Pyx_PyList_Extend(PyObject * L,PyObject * v)1906 static CYTHON_INLINE int __Pyx_PyList_Extend(PyObject* L, PyObject* v) {
1907 #if CYTHON_COMPILING_IN_CPYTHON
1908     PyObject* none = _PyList_Extend((PyListObject*)L, v);
1909     if (unlikely(!none))
1910         return -1;
1911     Py_DECREF(none);
1912     return 0;
1913 #else
1914     return PyList_SetSlice(L, PY_SSIZE_T_MAX, PY_SSIZE_T_MAX, v);
1915 #endif
1916 }
1917 
1918 /* ListAppend.proto */
1919 #if CYTHON_USE_PYLIST_INTERNALS && CYTHON_ASSUME_SAFE_MACROS
__Pyx_PyList_Append(PyObject * list,PyObject * x)1920 static CYTHON_INLINE int __Pyx_PyList_Append(PyObject* list, PyObject* x) {
1921     PyListObject* L = (PyListObject*) list;
1922     Py_ssize_t len = Py_SIZE(list);
1923     if (likely(L->allocated > len) & likely(len > (L->allocated >> 1))) {
1924         Py_INCREF(x);
1925         PyList_SET_ITEM(list, len, x);
1926         __Pyx_SET_SIZE(list, len + 1);
1927         return 0;
1928     }
1929     return PyList_Append(list, x);
1930 }
1931 #else
1932 #define __Pyx_PyList_Append(L,x) PyList_Append(L,x)
1933 #endif
1934 
1935 /* None.proto */
1936 static CYTHON_INLINE long __Pyx_div_long(long, long);
1937 
1938 /* ImportFrom.proto */
1939 static PyObject* __Pyx_ImportFrom(PyObject* module, PyObject* name);
1940 
1941 /* HasAttr.proto */
1942 static CYTHON_INLINE int __Pyx_HasAttr(PyObject *, PyObject *);
1943 
1944 /* PyObject_GenericGetAttrNoDict.proto */
1945 #if CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP && PY_VERSION_HEX < 0x03070000
1946 static CYTHON_INLINE PyObject* __Pyx_PyObject_GenericGetAttrNoDict(PyObject* obj, PyObject* attr_name);
1947 #else
1948 #define __Pyx_PyObject_GenericGetAttrNoDict PyObject_GenericGetAttr
1949 #endif
1950 
1951 /* PyObject_GenericGetAttr.proto */
1952 #if CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP && PY_VERSION_HEX < 0x03070000
1953 static PyObject* __Pyx_PyObject_GenericGetAttr(PyObject* obj, PyObject* attr_name);
1954 #else
1955 #define __Pyx_PyObject_GenericGetAttr PyObject_GenericGetAttr
1956 #endif
1957 
1958 /* SetVTable.proto */
1959 static int __Pyx_SetVtable(PyObject *dict, void *vtable);
1960 
1961 /* PyObjectGetAttrStrNoError.proto */
1962 static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStrNoError(PyObject* obj, PyObject* attr_name);
1963 
1964 /* SetupReduce.proto */
1965 static int __Pyx_setup_reduce(PyObject* type_obj);
1966 
1967 /* TypeImport.proto */
1968 #ifndef __PYX_HAVE_RT_ImportType_proto
1969 #define __PYX_HAVE_RT_ImportType_proto
1970 enum __Pyx_ImportType_CheckSize {
1971    __Pyx_ImportType_CheckSize_Error = 0,
1972    __Pyx_ImportType_CheckSize_Warn = 1,
1973    __Pyx_ImportType_CheckSize_Ignore = 2
1974 };
1975 static PyTypeObject *__Pyx_ImportType(PyObject* module, const char *module_name, const char *class_name, size_t size, enum __Pyx_ImportType_CheckSize check_size);
1976 #endif
1977 
1978 /* CLineInTraceback.proto */
1979 #ifdef CYTHON_CLINE_IN_TRACEBACK
1980 #define __Pyx_CLineForTraceback(tstate, c_line)  (((CYTHON_CLINE_IN_TRACEBACK)) ? c_line : 0)
1981 #else
1982 static int __Pyx_CLineForTraceback(PyThreadState *tstate, int c_line);
1983 #endif
1984 
1985 /* CodeObjectCache.proto */
1986 typedef struct {
1987     PyCodeObject* code_object;
1988     int code_line;
1989 } __Pyx_CodeObjectCacheEntry;
1990 struct __Pyx_CodeObjectCache {
1991     int count;
1992     int max_count;
1993     __Pyx_CodeObjectCacheEntry* entries;
1994 };
1995 static struct __Pyx_CodeObjectCache __pyx_code_cache = {0,0,NULL};
1996 static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line);
1997 static PyCodeObject *__pyx_find_code_object(int code_line);
1998 static void __pyx_insert_code_object(int code_line, PyCodeObject* code_object);
1999 
2000 /* AddTraceback.proto */
2001 static void __Pyx_AddTraceback(const char *funcname, int c_line,
2002                                int py_line, const char *filename);
2003 
2004 /* RealImag.proto */
2005 #if CYTHON_CCOMPLEX
2006   #ifdef __cplusplus
2007     #define __Pyx_CREAL(z) ((z).real())
2008     #define __Pyx_CIMAG(z) ((z).imag())
2009   #else
2010     #define __Pyx_CREAL(z) (__real__(z))
2011     #define __Pyx_CIMAG(z) (__imag__(z))
2012   #endif
2013 #else
2014     #define __Pyx_CREAL(z) ((z).real)
2015     #define __Pyx_CIMAG(z) ((z).imag)
2016 #endif
2017 #if defined(__cplusplus) && CYTHON_CCOMPLEX\
2018         && (defined(_WIN32) || defined(__clang__) || (defined(__GNUC__) && (__GNUC__ >= 5 || __GNUC__ == 4 && __GNUC_MINOR__ >= 4 )) || __cplusplus >= 201103)
2019     #define __Pyx_SET_CREAL(z,x) ((z).real(x))
2020     #define __Pyx_SET_CIMAG(z,y) ((z).imag(y))
2021 #else
2022     #define __Pyx_SET_CREAL(z,x) __Pyx_CREAL(z) = (x)
2023     #define __Pyx_SET_CIMAG(z,y) __Pyx_CIMAG(z) = (y)
2024 #endif
2025 
2026 /* Arithmetic.proto */
2027 #if CYTHON_CCOMPLEX
2028     #define __Pyx_c_eq_double(a, b)   ((a)==(b))
2029     #define __Pyx_c_sum_double(a, b)  ((a)+(b))
2030     #define __Pyx_c_diff_double(a, b) ((a)-(b))
2031     #define __Pyx_c_prod_double(a, b) ((a)*(b))
2032     #define __Pyx_c_quot_double(a, b) ((a)/(b))
2033     #define __Pyx_c_neg_double(a)     (-(a))
2034   #ifdef __cplusplus
2035     #define __Pyx_c_is_zero_double(z) ((z)==(double)0)
2036     #define __Pyx_c_conj_double(z)    (::std::conj(z))
2037     #if 1
2038         #define __Pyx_c_abs_double(z)     (::std::abs(z))
2039         #define __Pyx_c_pow_double(a, b)  (::std::pow(a, b))
2040     #endif
2041   #else
2042     #define __Pyx_c_is_zero_double(z) ((z)==0)
2043     #define __Pyx_c_conj_double(z)    (conj(z))
2044     #if 1
2045         #define __Pyx_c_abs_double(z)     (cabs(z))
2046         #define __Pyx_c_pow_double(a, b)  (cpow(a, b))
2047     #endif
2048  #endif
2049 #else
2050     static CYTHON_INLINE int __Pyx_c_eq_double(__pyx_t_double_complex, __pyx_t_double_complex);
2051     static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_sum_double(__pyx_t_double_complex, __pyx_t_double_complex);
2052     static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_diff_double(__pyx_t_double_complex, __pyx_t_double_complex);
2053     static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_prod_double(__pyx_t_double_complex, __pyx_t_double_complex);
2054     static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_quot_double(__pyx_t_double_complex, __pyx_t_double_complex);
2055     static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_neg_double(__pyx_t_double_complex);
2056     static CYTHON_INLINE int __Pyx_c_is_zero_double(__pyx_t_double_complex);
2057     static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_conj_double(__pyx_t_double_complex);
2058     #if 1
2059         static CYTHON_INLINE double __Pyx_c_abs_double(__pyx_t_double_complex);
2060         static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_pow_double(__pyx_t_double_complex, __pyx_t_double_complex);
2061     #endif
2062 #endif
2063 
2064 #if PY_MAJOR_VERSION < 3
2065     static int __Pyx_GetBuffer(PyObject *obj, Py_buffer *view, int flags);
2066     static void __Pyx_ReleaseBuffer(Py_buffer *view);
2067 #else
2068     #define __Pyx_GetBuffer PyObject_GetBuffer
2069     #define __Pyx_ReleaseBuffer PyBuffer_Release
2070 #endif
2071 
2072 
2073 /* BufferStructDeclare.proto */
2074 typedef struct {
2075   Py_ssize_t shape, strides, suboffsets;
2076 } __Pyx_Buf_DimInfo;
2077 typedef struct {
2078   size_t refcount;
2079   Py_buffer pybuffer;
2080 } __Pyx_Buffer;
2081 typedef struct {
2082   __Pyx_Buffer *rcbuffer;
2083   char *data;
2084   __Pyx_Buf_DimInfo diminfo[8];
2085 } __Pyx_LocalBuf_ND;
2086 
2087 /* MemviewSliceIsContig.proto */
2088 static int __pyx_memviewslice_is_contig(const __Pyx_memviewslice mvs, char order, int ndim);
2089 
2090 /* OverlappingSlices.proto */
2091 static int __pyx_slices_overlap(__Pyx_memviewslice *slice1,
2092                                 __Pyx_memviewslice *slice2,
2093                                 int ndim, size_t itemsize);
2094 
2095 /* Capsule.proto */
2096 static CYTHON_INLINE PyObject *__pyx_capsule_create(void *p, const char *sig);
2097 
2098 /* TypeInfoCompare.proto */
2099 static int __pyx_typeinfo_cmp(__Pyx_TypeInfo *a, __Pyx_TypeInfo *b);
2100 
2101 /* MemviewSliceValidateAndInit.proto */
2102 static int __Pyx_ValidateAndInit_memviewslice(
2103                 int *axes_specs,
2104                 int c_or_f_flag,
2105                 int buf_flags,
2106                 int ndim,
2107                 __Pyx_TypeInfo *dtype,
2108                 __Pyx_BufFmt_StackElem stack[],
2109                 __Pyx_memviewslice *memviewslice,
2110                 PyObject *original_obj);
2111 
2112 /* ObjectToMemviewSlice.proto */
2113 static CYTHON_INLINE __Pyx_memviewslice __Pyx_PyObject_to_MemoryviewSlice_dc___pyx_t_double_complex(PyObject *, int writable_flag);
2114 
2115 /* ObjectToMemviewSlice.proto */
2116 static CYTHON_INLINE __Pyx_memviewslice __Pyx_PyObject_to_MemoryviewSlice_dc_int(PyObject *, int writable_flag);
2117 
2118 /* FromPy.proto */
2119 static __pyx_t_double_complex __Pyx_PyComplex_As___pyx_t_double_complex(PyObject*);
2120 
2121 /* ObjectToMemviewSlice.proto */
2122 static CYTHON_INLINE __Pyx_memviewslice __Pyx_PyObject_to_MemoryviewSlice_d_dc___pyx_t_double_complex(PyObject *, int writable_flag);
2123 
2124 /* ObjectToMemviewSlice.proto */
2125 static CYTHON_INLINE __Pyx_memviewslice __Pyx_PyObject_to_MemoryviewSlice_dcd____pyx_t_double_complex(PyObject *, int writable_flag);
2126 
2127 /* GCCDiagnostics.proto */
2128 #if defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6))
2129 #define __Pyx_HAS_GCC_DIAGNOSTIC
2130 #endif
2131 
2132 /* ToPy.proto */
2133 #define __pyx_PyComplex_FromComplex(z)\
2134         PyComplex_FromDoubles((double)__Pyx_CREAL(z),\
2135                               (double)__Pyx_CIMAG(z))
2136 
2137 /* Arithmetic.proto */
2138 #if CYTHON_CCOMPLEX
2139     #define __Pyx_c_eq_float(a, b)   ((a)==(b))
2140     #define __Pyx_c_sum_float(a, b)  ((a)+(b))
2141     #define __Pyx_c_diff_float(a, b) ((a)-(b))
2142     #define __Pyx_c_prod_float(a, b) ((a)*(b))
2143     #define __Pyx_c_quot_float(a, b) ((a)/(b))
2144     #define __Pyx_c_neg_float(a)     (-(a))
2145   #ifdef __cplusplus
2146     #define __Pyx_c_is_zero_float(z) ((z)==(float)0)
2147     #define __Pyx_c_conj_float(z)    (::std::conj(z))
2148     #if 1
2149         #define __Pyx_c_abs_float(z)     (::std::abs(z))
2150         #define __Pyx_c_pow_float(a, b)  (::std::pow(a, b))
2151     #endif
2152   #else
2153     #define __Pyx_c_is_zero_float(z) ((z)==0)
2154     #define __Pyx_c_conj_float(z)    (conjf(z))
2155     #if 1
2156         #define __Pyx_c_abs_float(z)     (cabsf(z))
2157         #define __Pyx_c_pow_float(a, b)  (cpowf(a, b))
2158     #endif
2159  #endif
2160 #else
2161     static CYTHON_INLINE int __Pyx_c_eq_float(__pyx_t_float_complex, __pyx_t_float_complex);
2162     static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_sum_float(__pyx_t_float_complex, __pyx_t_float_complex);
2163     static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_diff_float(__pyx_t_float_complex, __pyx_t_float_complex);
2164     static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_prod_float(__pyx_t_float_complex, __pyx_t_float_complex);
2165     static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_quot_float(__pyx_t_float_complex, __pyx_t_float_complex);
2166     static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_neg_float(__pyx_t_float_complex);
2167     static CYTHON_INLINE int __Pyx_c_is_zero_float(__pyx_t_float_complex);
2168     static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_conj_float(__pyx_t_float_complex);
2169     #if 1
2170         static CYTHON_INLINE float __Pyx_c_abs_float(__pyx_t_float_complex);
2171         static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_pow_float(__pyx_t_float_complex, __pyx_t_float_complex);
2172     #endif
2173 #endif
2174 
2175 /* MemviewSliceCopyTemplate.proto */
2176 static __Pyx_memviewslice
2177 __pyx_memoryview_copy_new_contig(const __Pyx_memviewslice *from_mvs,
2178                                  const char *mode, int ndim,
2179                                  size_t sizeof_dtype, int contig_flag,
2180                                  int dtype_is_object);
2181 
2182 /* CIntFromPy.proto */
2183 static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *);
2184 
2185 /* CIntToPy.proto */
2186 static CYTHON_INLINE PyObject* __Pyx_PyInt_From_unsigned_int(unsigned int value);
2187 
2188 /* CIntToPy.proto */
2189 static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value);
2190 
2191 /* CIntFromPy.proto */
2192 static CYTHON_INLINE unsigned int __Pyx_PyInt_As_unsigned_int(PyObject *);
2193 
2194 /* CIntToPy.proto */
2195 static CYTHON_INLINE PyObject* __Pyx_PyInt_From_int(int value);
2196 
2197 /* CIntFromPy.proto */
2198 static CYTHON_INLINE size_t __Pyx_PyInt_As_size_t(PyObject *);
2199 
2200 /* CIntFromPy.proto */
2201 static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *);
2202 
2203 /* CIntFromPy.proto */
2204 static CYTHON_INLINE char __Pyx_PyInt_As_char(PyObject *);
2205 
2206 /* CheckBinaryVersion.proto */
2207 static int __Pyx_check_binary_version(void);
2208 
2209 /* FunctionExport.proto */
2210 static int __Pyx_ExportFunction(const char *name, void (*f)(void), const char *sig);
2211 
2212 /* InitStrings.proto */
2213 static int __Pyx_InitStrings(__Pyx_StringTabEntry *t);
2214 
2215 static PyObject *__pyx_array_get_memview(struct __pyx_array_obj *__pyx_v_self); /* proto*/
2216 static char *__pyx_memoryview_get_item_pointer(struct __pyx_memoryview_obj *__pyx_v_self, PyObject *__pyx_v_index); /* proto*/
2217 static PyObject *__pyx_memoryview_is_slice(struct __pyx_memoryview_obj *__pyx_v_self, PyObject *__pyx_v_obj); /* proto*/
2218 static PyObject *__pyx_memoryview_setitem_slice_assignment(struct __pyx_memoryview_obj *__pyx_v_self, PyObject *__pyx_v_dst, PyObject *__pyx_v_src); /* proto*/
2219 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*/
2220 static PyObject *__pyx_memoryview_setitem_indexed(struct __pyx_memoryview_obj *__pyx_v_self, PyObject *__pyx_v_index, PyObject *__pyx_v_value); /* proto*/
2221 static PyObject *__pyx_memoryview_convert_item_to_object(struct __pyx_memoryview_obj *__pyx_v_self, char *__pyx_v_itemp); /* proto*/
2222 static PyObject *__pyx_memoryview_assign_item_from_object(struct __pyx_memoryview_obj *__pyx_v_self, char *__pyx_v_itemp, PyObject *__pyx_v_value); /* proto*/
2223 static PyObject *__pyx_memoryviewslice_convert_item_to_object(struct __pyx_memoryviewslice_obj *__pyx_v_self, char *__pyx_v_itemp); /* proto*/
2224 static PyObject *__pyx_memoryviewslice_assign_item_from_object(struct __pyx_memoryviewslice_obj *__pyx_v_self, char *__pyx_v_itemp, PyObject *__pyx_v_value); /* proto*/
2225 
2226 /* Module declarations from 'cpython.buffer' */
2227 
2228 /* Module declarations from 'libc.string' */
2229 
2230 /* Module declarations from 'libc.stdio' */
2231 
2232 /* Module declarations from '__builtin__' */
2233 
2234 /* Module declarations from 'cpython.type' */
2235 static PyTypeObject *__pyx_ptype_7cpython_4type_type = 0;
2236 
2237 /* Module declarations from 'cpython' */
2238 
2239 /* Module declarations from 'cpython.object' */
2240 
2241 /* Module declarations from 'cpython.ref' */
2242 
2243 /* Module declarations from 'cpython.mem' */
2244 
2245 /* Module declarations from 'numpy' */
2246 
2247 /* Module declarations from 'numpy' */
2248 static PyTypeObject *__pyx_ptype_5numpy_dtype = 0;
2249 static PyTypeObject *__pyx_ptype_5numpy_flatiter = 0;
2250 static PyTypeObject *__pyx_ptype_5numpy_broadcast = 0;
2251 static PyTypeObject *__pyx_ptype_5numpy_ndarray = 0;
2252 static PyTypeObject *__pyx_ptype_5numpy_ufunc = 0;
2253 
2254 /* Module declarations from 'cython.view' */
2255 
2256 /* Module declarations from 'cython' */
2257 
2258 /* Module declarations from 'libcpp' */
2259 
2260 /* Module declarations from 'libc.math' */
2261 
2262 /* Module declarations from 'libc' */
2263 
2264 /* Module declarations from 'qutip.cy.spmatfuncs' */
2265 static PyTypeObject *__pyx_array_type = 0;
2266 static PyTypeObject *__pyx_MemviewEnum_type = 0;
2267 static PyTypeObject *__pyx_memoryview_type = 0;
2268 static PyTypeObject *__pyx_memoryviewslice_type = 0;
2269 static PyObject *generic = 0;
2270 static PyObject *strided = 0;
2271 static PyObject *indirect = 0;
2272 static PyObject *contiguous = 0;
2273 static PyObject *indirect_contiguous = 0;
2274 static int __pyx_memoryview_thread_locks_used;
2275 static PyThread_type_lock __pyx_memoryview_thread_locks[8];
2276 static PyArrayObject *__pyx_f_5qutip_2cy_10spmatfuncs_spmv_csr(__Pyx_memviewslice, __Pyx_memviewslice, __Pyx_memviewslice, __Pyx_memviewslice, int __pyx_skip_dispatch); /*proto*/
2277 static CYTHON_INLINE void __pyx_f_5qutip_2cy_10spmatfuncs_spmvpy(__pyx_t_double_complex *, int *, int *, __pyx_t_double_complex *, __pyx_t_double_complex, __pyx_t_double_complex *, unsigned int); /*proto*/
2278 static PyObject *__pyx_f_5qutip_2cy_10spmatfuncs_cy_expect_rho_vec_csr(__Pyx_memviewslice, __Pyx_memviewslice, __Pyx_memviewslice, __Pyx_memviewslice, int, int __pyx_skip_dispatch); /*proto*/
2279 static PyObject *__pyx_f_5qutip_2cy_10spmatfuncs_cy_expect_psi(PyObject *, __Pyx_memviewslice, bool, int __pyx_skip_dispatch); /*proto*/
2280 static PyObject *__pyx_f_5qutip_2cy_10spmatfuncs_cy_expect_psi_csr(__Pyx_memviewslice, __Pyx_memviewslice, __Pyx_memviewslice, __Pyx_memviewslice, bool, int __pyx_skip_dispatch); /*proto*/
2281 static void __pyx_f_5qutip_2cy_10spmatfuncs__spmm_c_py(__pyx_t_double_complex *, int *, int *, __pyx_t_double_complex *, __pyx_t_double_complex, __pyx_t_double_complex *, unsigned int, unsigned int, unsigned int); /*proto*/
2282 static void __pyx_f_5qutip_2cy_10spmatfuncs_spmmpy_c(__Pyx_memviewslice, __Pyx_memviewslice, __Pyx_memviewslice, __Pyx_memviewslice, __pyx_t_double_complex, __Pyx_memviewslice, int __pyx_skip_dispatch); /*proto*/
2283 static PyArrayObject *__pyx_f_5qutip_2cy_10spmatfuncs_spmmc(PyObject *, __Pyx_memviewslice, int __pyx_skip_dispatch); /*proto*/
2284 static void __pyx_f_5qutip_2cy_10spmatfuncs__spmm_f_py(__pyx_t_double_complex *, int *, int *, __pyx_t_double_complex *, __pyx_t_double_complex, __pyx_t_double_complex *, unsigned int, unsigned int, unsigned int); /*proto*/
2285 static void __pyx_f_5qutip_2cy_10spmatfuncs_spmmpy_f(__Pyx_memviewslice, __Pyx_memviewslice, __Pyx_memviewslice, __Pyx_memviewslice, __pyx_t_double_complex, __Pyx_memviewslice, int __pyx_skip_dispatch); /*proto*/
2286 static PyArrayObject *__pyx_f_5qutip_2cy_10spmatfuncs_spmmf(PyObject *, __Pyx_memviewslice, int __pyx_skip_dispatch); /*proto*/
2287 static PyArrayObject *__pyx_f_5qutip_2cy_10spmatfuncs_spmm(PyObject *, PyArrayObject *, int __pyx_skip_dispatch); /*proto*/
2288 static PyArrayObject *__pyx_f_5qutip_2cy_10spmatfuncs_spmv(PyObject *, __Pyx_memviewslice, int __pyx_skip_dispatch); /*proto*/
2289 static PyArrayObject *__pyx_f_5qutip_2cy_10spmatfuncs_cy_ode_rhs(double, __Pyx_memviewslice, __Pyx_memviewslice, __Pyx_memviewslice, __Pyx_memviewslice, int __pyx_skip_dispatch); /*proto*/
2290 static PyArrayObject *__pyx_f_5qutip_2cy_10spmatfuncs_cy_ode_psi_func_td(double, PyArrayObject *, PyObject *, PyObject *, int __pyx_skip_dispatch); /*proto*/
2291 static PyArrayObject *__pyx_f_5qutip_2cy_10spmatfuncs_cy_ode_psi_func_td_with_state(double, PyArrayObject *, PyObject *, PyObject *, int __pyx_skip_dispatch); /*proto*/
2292 static PyArrayObject *__pyx_f_5qutip_2cy_10spmatfuncs_cy_ode_rho_func_td(double, PyArrayObject *, PyObject *, PyObject *, PyObject *, int __pyx_skip_dispatch); /*proto*/
2293 static PyObject *__pyx_f_5qutip_2cy_10spmatfuncs_cy_expect_rho_vec(PyObject *, __Pyx_memviewslice, int, int __pyx_skip_dispatch); /*proto*/
2294 static PyObject *__pyx_f_5qutip_2cy_10spmatfuncs_cy_spmm_tr(PyObject *, PyObject *, int, int __pyx_skip_dispatch); /*proto*/
2295 static __pyx_t_double_complex __pyx_f_5qutip_2cy_10spmatfuncs_zcsr_mat_elem(PyObject *, PyObject *, PyObject *, int __pyx_skip_dispatch, struct __pyx_opt_args_5qutip_2cy_10spmatfuncs_zcsr_mat_elem *__pyx_optional_args); /*proto*/
2296 static struct __pyx_array_obj *__pyx_array_new(PyObject *, Py_ssize_t, char *, char *, char *); /*proto*/
2297 static void *__pyx_align_pointer(void *, size_t); /*proto*/
2298 static PyObject *__pyx_memoryview_new(PyObject *, int, int, __Pyx_TypeInfo *); /*proto*/
2299 static CYTHON_INLINE int __pyx_memoryview_check(PyObject *); /*proto*/
2300 static PyObject *_unellipsify(PyObject *, int); /*proto*/
2301 static PyObject *assert_direct_dimensions(Py_ssize_t *, int); /*proto*/
2302 static struct __pyx_memoryview_obj *__pyx_memview_slice(struct __pyx_memoryview_obj *, PyObject *); /*proto*/
2303 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*/
2304 static char *__pyx_pybuffer_index(Py_buffer *, char *, Py_ssize_t, Py_ssize_t); /*proto*/
2305 static int __pyx_memslice_transpose(__Pyx_memviewslice *); /*proto*/
2306 static PyObject *__pyx_memoryview_fromslice(__Pyx_memviewslice, int, PyObject *(*)(char *), int (*)(char *, PyObject *), int); /*proto*/
2307 static __Pyx_memviewslice *__pyx_memoryview_get_slice_from_memoryview(struct __pyx_memoryview_obj *, __Pyx_memviewslice *); /*proto*/
2308 static void __pyx_memoryview_slice_copy(struct __pyx_memoryview_obj *, __Pyx_memviewslice *); /*proto*/
2309 static PyObject *__pyx_memoryview_copy_object(struct __pyx_memoryview_obj *); /*proto*/
2310 static PyObject *__pyx_memoryview_copy_object_from_slice(struct __pyx_memoryview_obj *, __Pyx_memviewslice *); /*proto*/
2311 static Py_ssize_t abs_py_ssize_t(Py_ssize_t); /*proto*/
2312 static char __pyx_get_best_slice_order(__Pyx_memviewslice *, int); /*proto*/
2313 static void _copy_strided_to_strided(char *, Py_ssize_t *, char *, Py_ssize_t *, Py_ssize_t *, Py_ssize_t *, int, size_t); /*proto*/
2314 static void copy_strided_to_strided(__Pyx_memviewslice *, __Pyx_memviewslice *, int, size_t); /*proto*/
2315 static Py_ssize_t __pyx_memoryview_slice_get_size(__Pyx_memviewslice *, int); /*proto*/
2316 static Py_ssize_t __pyx_fill_contig_strides_array(Py_ssize_t *, Py_ssize_t *, Py_ssize_t, int, char); /*proto*/
2317 static void *__pyx_memoryview_copy_data_to_temp(__Pyx_memviewslice *, __Pyx_memviewslice *, char, int); /*proto*/
2318 static int __pyx_memoryview_err_extents(int, Py_ssize_t, Py_ssize_t); /*proto*/
2319 static int __pyx_memoryview_err_dim(PyObject *, char *, int); /*proto*/
2320 static int __pyx_memoryview_err(PyObject *, char *); /*proto*/
2321 static int __pyx_memoryview_copy_contents(__Pyx_memviewslice, __Pyx_memviewslice, int, int, int); /*proto*/
2322 static void __pyx_memoryview_broadcast_leading(__Pyx_memviewslice *, int, int); /*proto*/
2323 static void __pyx_memoryview_refcount_copying(__Pyx_memviewslice *, int, int, int); /*proto*/
2324 static void __pyx_memoryview_refcount_objects_in_slice_with_gil(char *, Py_ssize_t *, Py_ssize_t *, int, int); /*proto*/
2325 static void __pyx_memoryview_refcount_objects_in_slice(char *, Py_ssize_t *, Py_ssize_t *, int, int); /*proto*/
2326 static void __pyx_memoryview_slice_assign_scalar(__Pyx_memviewslice *, int, size_t, void *, int); /*proto*/
2327 static void __pyx_memoryview__slice_assign_scalar(char *, Py_ssize_t *, Py_ssize_t *, int, size_t, void *); /*proto*/
2328 static PyObject *__pyx_unpickle_Enum__set_state(struct __pyx_MemviewEnum_obj *, PyObject *); /*proto*/
2329 static __Pyx_TypeInfo __Pyx_TypeInfo___pyx_t_double_complex = { "double complex", NULL, sizeof(__pyx_t_double_complex), { 0 }, 0, 'C', 0, 0 };
2330 static __Pyx_TypeInfo __Pyx_TypeInfo_int = { "int", NULL, sizeof(int), { 0 }, 0, IS_UNSIGNED(int) ? 'U' : 'I', IS_UNSIGNED(int), 0 };
2331 #define __Pyx_MODULE_NAME "qutip.cy.spmatfuncs"
2332 extern int __pyx_module_is_main_qutip__cy__spmatfuncs;
2333 int __pyx_module_is_main_qutip__cy__spmatfuncs = 0;
2334 
2335 /* Implementation of 'qutip.cy.spmatfuncs' */
2336 static PyObject *__pyx_builtin_range;
2337 static PyObject *__pyx_builtin_ImportError;
2338 static PyObject *__pyx_builtin_ValueError;
2339 static PyObject *__pyx_builtin_MemoryError;
2340 static PyObject *__pyx_builtin_enumerate;
2341 static PyObject *__pyx_builtin_TypeError;
2342 static PyObject *__pyx_builtin_Ellipsis;
2343 static PyObject *__pyx_builtin_id;
2344 static PyObject *__pyx_builtin_IndexError;
2345 static const char __pyx_k_A[] = "A";
2346 static const char __pyx_k_B[] = "B";
2347 static const char __pyx_k_F[] = "F";
2348 static const char __pyx_k_M[] = "M";
2349 static const char __pyx_k_O[] = "O";
2350 static const char __pyx_k_a[] = "a";
2351 static const char __pyx_k_c[] = "c";
2352 static const char __pyx_k_j[] = "j";
2353 static const char __pyx_k_t[] = "t";
2354 static const char __pyx_k_L0[] = "L0";
2355 static const char __pyx_k_id[] = "id";
2356 static const char __pyx_k_ii[] = "ii";
2357 static const char __pyx_k_jj[] = "jj";
2358 static const char __pyx_k_np[] = "np";
2359 static const char __pyx_k_idx[] = "idx";
2360 static const char __pyx_k_ind[] = "ind";
2361 static const char __pyx_k_mat[] = "mat";
2362 static const char __pyx_k_new[] = "__new__";
2363 static const char __pyx_k_obj[] = "obj";
2364 static const char __pyx_k_op1[] = "op1";
2365 static const char __pyx_k_op2[] = "op2";
2366 static const char __pyx_k_out[] = "out";
2367 static const char __pyx_k_psi[] = "psi";
2368 static const char __pyx_k_ptr[] = "ptr";
2369 static const char __pyx_k_rho[] = "rho";
2370 static const char __pyx_k_vec[] = "vec";
2371 static const char __pyx_k_Aind[] = "Aind";
2372 static const char __pyx_k_Aptr[] = "Aptr";
2373 static const char __pyx_k_Bptr[] = "Bptr";
2374 static const char __pyx_k_args[] = "args";
2375 static const char __pyx_k_base[] = "base";
2376 static const char __pyx_k_cval[] = "cval";
2377 static const char __pyx_k_data[] = "data";
2378 static const char __pyx_k_dict[] = "__dict__";
2379 static const char __pyx_k_expt[] = "expt";
2380 static const char __pyx_k_herm[] = "herm";
2381 static const char __pyx_k_left[] = "left";
2382 static const char __pyx_k_main[] = "__main__";
2383 static const char __pyx_k_mode[] = "mode";
2384 static const char __pyx_k_name[] = "name";
2385 static const char __pyx_k_ndim[] = "ndim";
2386 static const char __pyx_k_pack[] = "pack";
2387 static const char __pyx_k_size[] = "size";
2388 static const char __pyx_k_step[] = "step";
2389 static const char __pyx_k_stop[] = "stop";
2390 static const char __pyx_k_test[] = "__test__";
2391 static const char __pyx_k_ASCII[] = "ASCII";
2392 static const char __pyx_k_Adata[] = "Adata";
2393 static const char __pyx_k_Bdata[] = "Bdata";
2394 static const char __pyx_k_alpha[] = "alpha";
2395 static const char __pyx_k_class[] = "__class__";
2396 static const char __pyx_k_dtype[] = "dtype";
2397 static const char __pyx_k_error[] = "error";
2398 static const char __pyx_k_flags[] = "flags";
2399 static const char __pyx_k_nrows[] = "nrows";
2400 static const char __pyx_k_numpy[] = "numpy";
2401 static const char __pyx_k_order[] = "order";
2402 static const char __pyx_k_range[] = "range";
2403 static const char __pyx_k_right[] = "right";
2404 static const char __pyx_k_shape[] = "shape";
2405 static const char __pyx_k_start[] = "start";
2406 static const char __pyx_k_zeros[] = "zeros";
2407 static const char __pyx_k_H_func[] = "H_func";
2408 static const char __pyx_k_L_func[] = "L_func";
2409 static const char __pyx_k_encode[] = "encode";
2410 static const char __pyx_k_format[] = "format";
2411 static const char __pyx_k_import[] = "__import__";
2412 static const char __pyx_k_indptr[] = "indptr";
2413 static const char __pyx_k_isherm[] = "isherm";
2414 static const char __pyx_k_name_2[] = "__name__";
2415 static const char __pyx_k_pickle[] = "pickle";
2416 static const char __pyx_k_reduce[] = "__reduce__";
2417 static const char __pyx_k_sparse[] = "sparse";
2418 static const char __pyx_k_struct[] = "struct";
2419 static const char __pyx_k_unpack[] = "unpack";
2420 static const char __pyx_k_update[] = "update";
2421 static const char __pyx_k_bra_ket[] = "bra_ket";
2422 static const char __pyx_k_fortran[] = "fortran";
2423 static const char __pyx_k_indices[] = "indices";
2424 static const char __pyx_k_memview[] = "memview";
2425 static const char __pyx_k_rho_vec[] = "rho_vec";
2426 static const char __pyx_k_row_sum[] = "row_sum";
2427 static const char __pyx_k_Ellipsis[] = "Ellipsis";
2428 static const char __pyx_k_getstate[] = "__getstate__";
2429 static const char __pyx_k_itemsize[] = "itemsize";
2430 static const char __pyx_k_num_rows[] = "num_rows";
2431 static const char __pyx_k_pyx_type[] = "__pyx_type";
2432 static const char __pyx_k_setstate[] = "__setstate__";
2433 static const char __pyx_k_super_op[] = "super_op";
2434 static const char __pyx_k_TypeError[] = "TypeError";
2435 static const char __pyx_k_enumerate[] = "enumerate";
2436 static const char __pyx_k_pyx_state[] = "__pyx_state";
2437 static const char __pyx_k_reduce_ex[] = "__reduce_ex__";
2438 static const char __pyx_k_IndexError[] = "IndexError";
2439 static const char __pyx_k_ValueError[] = "ValueError";
2440 static const char __pyx_k_complex128[] = "complex128";
2441 static const char __pyx_k_pyx_result[] = "__pyx_result";
2442 static const char __pyx_k_pyx_vtable[] = "__pyx_vtable__";
2443 static const char __pyx_k_spmvpy_csr[] = "spmvpy_csr";
2444 static const char __pyx_k_ImportError[] = "ImportError";
2445 static const char __pyx_k_MemoryError[] = "MemoryError";
2446 static const char __pyx_k_PickleError[] = "PickleError";
2447 static const char __pyx_k_F_CONTIGUOUS[] = "F_CONTIGUOUS";
2448 static const char __pyx_k_pyx_checksum[] = "__pyx_checksum";
2449 static const char __pyx_k_stringsource[] = "stringsource";
2450 static const char __pyx_k_pyx_getbuffer[] = "__pyx_getbuffer";
2451 static const char __pyx_k_reduce_cython[] = "__reduce_cython__";
2452 static const char __pyx_k_expect_csr_ket[] = "expect_csr_ket";
2453 static const char __pyx_k_View_MemoryView[] = "View.MemoryView";
2454 static const char __pyx_k_allocate_buffer[] = "allocate_buffer";
2455 static const char __pyx_k_dtype_is_object[] = "dtype_is_object";
2456 static const char __pyx_k_pyx_PickleError[] = "__pyx_PickleError";
2457 static const char __pyx_k_setstate_cython[] = "__setstate_cython__";
2458 static const char __pyx_k_pyx_unpickle_Enum[] = "__pyx_unpickle_Enum";
2459 static const char __pyx_k_cline_in_traceback[] = "cline_in_traceback";
2460 static const char __pyx_k_strided_and_direct[] = "<strided and direct>";
2461 static const char __pyx_k_qutip_cy_spmatfuncs[] = "qutip.cy.spmatfuncs";
2462 static const char __pyx_k_strided_and_indirect[] = "<strided and indirect>";
2463 static const char __pyx_k_contiguous_and_direct[] = "<contiguous and direct>";
2464 static const char __pyx_k_MemoryView_of_r_object[] = "<MemoryView of %r object>";
2465 static const char __pyx_k_MemoryView_of_r_at_0x_x[] = "<MemoryView of %r at 0x%x>";
2466 static const char __pyx_k_contiguous_and_indirect[] = "<contiguous and indirect>";
2467 static const char __pyx_k_qutip_cy_spmatfuncs_pyx[] = "qutip/cy/spmatfuncs.pyx";
2468 static const char __pyx_k_Cannot_index_with_type_s[] = "Cannot index with type '%s'";
2469 static const char __pyx_k_Invalid_shape_in_axis_d_d[] = "Invalid shape in axis %d: %d.";
2470 static const char __pyx_k_itemsize_0_for_cython_array[] = "itemsize <= 0 for cython.array";
2471 static const char __pyx_k_unable_to_allocate_array_data[] = "unable to allocate array data.";
2472 static const char __pyx_k_strided_and_direct_or_indirect[] = "<strided and direct or indirect>";
2473 static const char __pyx_k_numpy_core_multiarray_failed_to[] = "numpy.core.multiarray failed to import";
2474 static const char __pyx_k_Buffer_view_does_not_expose_stri[] = "Buffer view does not expose strides";
2475 static const char __pyx_k_Can_only_create_a_buffer_that_is[] = "Can only create a buffer that is contiguous in memory.";
2476 static const char __pyx_k_Cannot_assign_to_read_only_memor[] = "Cannot assign to read-only memoryview";
2477 static const char __pyx_k_Cannot_create_writable_memory_vi[] = "Cannot create writable memory view from read-only memoryview";
2478 static const char __pyx_k_Empty_shape_tuple_for_cython_arr[] = "Empty shape tuple for cython.array";
2479 static const char __pyx_k_Incompatible_checksums_s_vs_0xb0[] = "Incompatible checksums (%s vs 0xb068931 = (name))";
2480 static const char __pyx_k_Indirect_dimensions_not_supporte[] = "Indirect dimensions not supported";
2481 static const char __pyx_k_Invalid_mode_expected_c_or_fortr[] = "Invalid mode, expected 'c' or 'fortran', got %s";
2482 static const char __pyx_k_Out_of_bounds_on_buffer_access_a[] = "Out of bounds on buffer access (axis %d)";
2483 static const char __pyx_k_Unable_to_convert_item_to_object[] = "Unable to convert item to object";
2484 static const char __pyx_k_got_differing_extents_in_dimensi[] = "got differing extents in dimension %d (got %d and %d)";
2485 static const char __pyx_k_no_default___reduce___due_to_non[] = "no default __reduce__ due to non-trivial __cinit__";
2486 static const char __pyx_k_numpy_core_umath_failed_to_impor[] = "numpy.core.umath failed to import";
2487 static const char __pyx_k_unable_to_allocate_shape_and_str[] = "unable to allocate shape and strides.";
2488 static PyObject *__pyx_n_s_A;
2489 static PyObject *__pyx_n_s_ASCII;
2490 static PyObject *__pyx_n_s_Adata;
2491 static PyObject *__pyx_n_s_Aind;
2492 static PyObject *__pyx_n_s_Aptr;
2493 static PyObject *__pyx_n_s_B;
2494 static PyObject *__pyx_n_s_Bdata;
2495 static PyObject *__pyx_n_s_Bptr;
2496 static PyObject *__pyx_kp_s_Buffer_view_does_not_expose_stri;
2497 static PyObject *__pyx_kp_s_Can_only_create_a_buffer_that_is;
2498 static PyObject *__pyx_kp_s_Cannot_assign_to_read_only_memor;
2499 static PyObject *__pyx_kp_s_Cannot_create_writable_memory_vi;
2500 static PyObject *__pyx_kp_s_Cannot_index_with_type_s;
2501 static PyObject *__pyx_n_s_Ellipsis;
2502 static PyObject *__pyx_kp_s_Empty_shape_tuple_for_cython_arr;
2503 static PyObject *__pyx_n_u_F;
2504 static PyObject *__pyx_n_u_F_CONTIGUOUS;
2505 static PyObject *__pyx_n_s_H_func;
2506 static PyObject *__pyx_n_s_ImportError;
2507 static PyObject *__pyx_kp_s_Incompatible_checksums_s_vs_0xb0;
2508 static PyObject *__pyx_n_s_IndexError;
2509 static PyObject *__pyx_kp_s_Indirect_dimensions_not_supporte;
2510 static PyObject *__pyx_kp_s_Invalid_mode_expected_c_or_fortr;
2511 static PyObject *__pyx_kp_s_Invalid_shape_in_axis_d_d;
2512 static PyObject *__pyx_n_s_L0;
2513 static PyObject *__pyx_n_s_L_func;
2514 static PyObject *__pyx_n_s_M;
2515 static PyObject *__pyx_n_s_MemoryError;
2516 static PyObject *__pyx_kp_s_MemoryView_of_r_at_0x_x;
2517 static PyObject *__pyx_kp_s_MemoryView_of_r_object;
2518 static PyObject *__pyx_n_b_O;
2519 static PyObject *__pyx_kp_s_Out_of_bounds_on_buffer_access_a;
2520 static PyObject *__pyx_n_s_PickleError;
2521 static PyObject *__pyx_n_s_TypeError;
2522 static PyObject *__pyx_kp_s_Unable_to_convert_item_to_object;
2523 static PyObject *__pyx_n_s_ValueError;
2524 static PyObject *__pyx_n_s_View_MemoryView;
2525 static PyObject *__pyx_n_s_a;
2526 static PyObject *__pyx_n_s_allocate_buffer;
2527 static PyObject *__pyx_n_s_alpha;
2528 static PyObject *__pyx_n_s_args;
2529 static PyObject *__pyx_n_s_base;
2530 static PyObject *__pyx_n_s_bra_ket;
2531 static PyObject *__pyx_n_s_c;
2532 static PyObject *__pyx_n_u_c;
2533 static PyObject *__pyx_n_s_class;
2534 static PyObject *__pyx_n_s_cline_in_traceback;
2535 static PyObject *__pyx_n_s_complex128;
2536 static PyObject *__pyx_kp_s_contiguous_and_direct;
2537 static PyObject *__pyx_kp_s_contiguous_and_indirect;
2538 static PyObject *__pyx_n_s_cval;
2539 static PyObject *__pyx_n_s_data;
2540 static PyObject *__pyx_n_s_dict;
2541 static PyObject *__pyx_n_s_dtype;
2542 static PyObject *__pyx_n_s_dtype_is_object;
2543 static PyObject *__pyx_n_s_encode;
2544 static PyObject *__pyx_n_s_enumerate;
2545 static PyObject *__pyx_n_s_error;
2546 static PyObject *__pyx_n_s_expect_csr_ket;
2547 static PyObject *__pyx_n_s_expt;
2548 static PyObject *__pyx_n_s_flags;
2549 static PyObject *__pyx_n_s_format;
2550 static PyObject *__pyx_n_s_fortran;
2551 static PyObject *__pyx_n_u_fortran;
2552 static PyObject *__pyx_n_s_getstate;
2553 static PyObject *__pyx_kp_s_got_differing_extents_in_dimensi;
2554 static PyObject *__pyx_n_s_herm;
2555 static PyObject *__pyx_n_s_id;
2556 static PyObject *__pyx_n_s_idx;
2557 static PyObject *__pyx_n_s_ii;
2558 static PyObject *__pyx_n_s_import;
2559 static PyObject *__pyx_n_s_ind;
2560 static PyObject *__pyx_n_s_indices;
2561 static PyObject *__pyx_n_s_indptr;
2562 static PyObject *__pyx_n_s_isherm;
2563 static PyObject *__pyx_n_s_itemsize;
2564 static PyObject *__pyx_kp_s_itemsize_0_for_cython_array;
2565 static PyObject *__pyx_n_s_j;
2566 static PyObject *__pyx_n_s_jj;
2567 static PyObject *__pyx_n_s_left;
2568 static PyObject *__pyx_n_s_main;
2569 static PyObject *__pyx_n_s_mat;
2570 static PyObject *__pyx_n_s_memview;
2571 static PyObject *__pyx_n_s_mode;
2572 static PyObject *__pyx_n_s_name;
2573 static PyObject *__pyx_n_s_name_2;
2574 static PyObject *__pyx_n_s_ndim;
2575 static PyObject *__pyx_n_s_new;
2576 static PyObject *__pyx_kp_s_no_default___reduce___due_to_non;
2577 static PyObject *__pyx_n_s_np;
2578 static PyObject *__pyx_n_s_nrows;
2579 static PyObject *__pyx_n_s_num_rows;
2580 static PyObject *__pyx_n_s_numpy;
2581 static PyObject *__pyx_kp_u_numpy_core_multiarray_failed_to;
2582 static PyObject *__pyx_kp_u_numpy_core_umath_failed_to_impor;
2583 static PyObject *__pyx_n_s_obj;
2584 static PyObject *__pyx_n_s_op1;
2585 static PyObject *__pyx_n_s_op2;
2586 static PyObject *__pyx_n_s_order;
2587 static PyObject *__pyx_n_s_out;
2588 static PyObject *__pyx_n_s_pack;
2589 static PyObject *__pyx_n_s_pickle;
2590 static PyObject *__pyx_n_s_psi;
2591 static PyObject *__pyx_n_s_ptr;
2592 static PyObject *__pyx_n_s_pyx_PickleError;
2593 static PyObject *__pyx_n_s_pyx_checksum;
2594 static PyObject *__pyx_n_s_pyx_getbuffer;
2595 static PyObject *__pyx_n_s_pyx_result;
2596 static PyObject *__pyx_n_s_pyx_state;
2597 static PyObject *__pyx_n_s_pyx_type;
2598 static PyObject *__pyx_n_s_pyx_unpickle_Enum;
2599 static PyObject *__pyx_n_s_pyx_vtable;
2600 static PyObject *__pyx_n_s_qutip_cy_spmatfuncs;
2601 static PyObject *__pyx_kp_s_qutip_cy_spmatfuncs_pyx;
2602 static PyObject *__pyx_n_s_range;
2603 static PyObject *__pyx_n_s_reduce;
2604 static PyObject *__pyx_n_s_reduce_cython;
2605 static PyObject *__pyx_n_s_reduce_ex;
2606 static PyObject *__pyx_n_s_rho;
2607 static PyObject *__pyx_n_s_rho_vec;
2608 static PyObject *__pyx_n_s_right;
2609 static PyObject *__pyx_n_s_row_sum;
2610 static PyObject *__pyx_n_s_setstate;
2611 static PyObject *__pyx_n_s_setstate_cython;
2612 static PyObject *__pyx_n_s_shape;
2613 static PyObject *__pyx_n_s_size;
2614 static PyObject *__pyx_n_s_sparse;
2615 static PyObject *__pyx_n_s_spmvpy_csr;
2616 static PyObject *__pyx_n_s_start;
2617 static PyObject *__pyx_n_s_step;
2618 static PyObject *__pyx_n_s_stop;
2619 static PyObject *__pyx_kp_s_strided_and_direct;
2620 static PyObject *__pyx_kp_s_strided_and_direct_or_indirect;
2621 static PyObject *__pyx_kp_s_strided_and_indirect;
2622 static PyObject *__pyx_kp_s_stringsource;
2623 static PyObject *__pyx_n_s_struct;
2624 static PyObject *__pyx_n_s_super_op;
2625 static PyObject *__pyx_n_s_t;
2626 static PyObject *__pyx_n_s_test;
2627 static PyObject *__pyx_kp_s_unable_to_allocate_array_data;
2628 static PyObject *__pyx_kp_s_unable_to_allocate_shape_and_str;
2629 static PyObject *__pyx_n_s_unpack;
2630 static PyObject *__pyx_n_s_update;
2631 static PyObject *__pyx_n_s_vec;
2632 static PyObject *__pyx_n_s_zeros;
2633 static PyObject *__pyx_pf_5qutip_2cy_10spmatfuncs_spmv(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_super_op, __Pyx_memviewslice __pyx_v_vec); /* proto */
2634 static PyObject *__pyx_pf_5qutip_2cy_10spmatfuncs_2spmv_csr(CYTHON_UNUSED PyObject *__pyx_self, __Pyx_memviewslice __pyx_v_data, __Pyx_memviewslice __pyx_v_ind, __Pyx_memviewslice __pyx_v_ptr, __Pyx_memviewslice __pyx_v_vec); /* proto */
2635 static PyObject *__pyx_pf_5qutip_2cy_10spmatfuncs_4spmvpy_csr(CYTHON_UNUSED PyObject *__pyx_self, __Pyx_memviewslice __pyx_v_data, __Pyx_memviewslice __pyx_v_ind, __Pyx_memviewslice __pyx_v_ptr, __Pyx_memviewslice __pyx_v_vec, __pyx_t_double_complex __pyx_v_alpha, __Pyx_memviewslice __pyx_v_out); /* proto */
2636 static PyObject *__pyx_pf_5qutip_2cy_10spmatfuncs_6spmmpy_c(CYTHON_UNUSED PyObject *__pyx_self, __Pyx_memviewslice __pyx_v_data, __Pyx_memviewslice __pyx_v_ind, __Pyx_memviewslice __pyx_v_ptr, __Pyx_memviewslice __pyx_v_M, __pyx_t_double_complex __pyx_v_a, __Pyx_memviewslice __pyx_v_out); /* proto */
2637 static PyObject *__pyx_pf_5qutip_2cy_10spmatfuncs_8spmmc(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_sparse, __Pyx_memviewslice __pyx_v_mat); /* proto */
2638 static PyObject *__pyx_pf_5qutip_2cy_10spmatfuncs_10spmmpy_f(CYTHON_UNUSED PyObject *__pyx_self, __Pyx_memviewslice __pyx_v_data, __Pyx_memviewslice __pyx_v_ind, __Pyx_memviewslice __pyx_v_ptr, __Pyx_memviewslice __pyx_v_mat, __pyx_t_double_complex __pyx_v_a, __Pyx_memviewslice __pyx_v_out); /* proto */
2639 static PyObject *__pyx_pf_5qutip_2cy_10spmatfuncs_12spmmf(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_sparse, __Pyx_memviewslice __pyx_v_mat); /* proto */
2640 static PyObject *__pyx_pf_5qutip_2cy_10spmatfuncs_14spmm(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_sparse, PyArrayObject *__pyx_v_mat); /* proto */
2641 static PyObject *__pyx_pf_5qutip_2cy_10spmatfuncs_16cy_ode_rhs(CYTHON_UNUSED PyObject *__pyx_self, double __pyx_v_t, __Pyx_memviewslice __pyx_v_rho, __Pyx_memviewslice __pyx_v_data, __Pyx_memviewslice __pyx_v_ind, __Pyx_memviewslice __pyx_v_ptr); /* proto */
2642 static PyObject *__pyx_pf_5qutip_2cy_10spmatfuncs_18cy_ode_psi_func_td(CYTHON_UNUSED PyObject *__pyx_self, double __pyx_v_t, PyArrayObject *__pyx_v_psi, PyObject *__pyx_v_H_func, PyObject *__pyx_v_args); /* proto */
2643 static PyObject *__pyx_pf_5qutip_2cy_10spmatfuncs_20cy_ode_psi_func_td_with_state(CYTHON_UNUSED PyObject *__pyx_self, double __pyx_v_t, PyArrayObject *__pyx_v_psi, PyObject *__pyx_v_H_func, PyObject *__pyx_v_args); /* proto */
2644 static PyObject *__pyx_pf_5qutip_2cy_10spmatfuncs_22cy_ode_rho_func_td(CYTHON_UNUSED PyObject *__pyx_self, double __pyx_v_t, PyArrayObject *__pyx_v_rho, PyObject *__pyx_v_L0, PyObject *__pyx_v_L_func, PyObject *__pyx_v_args); /* proto */
2645 static PyObject *__pyx_pf_5qutip_2cy_10spmatfuncs_24cy_expect_psi(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_A, __Pyx_memviewslice __pyx_v_vec, bool __pyx_v_isherm); /* proto */
2646 static PyObject *__pyx_pf_5qutip_2cy_10spmatfuncs_26cy_expect_psi_csr(CYTHON_UNUSED PyObject *__pyx_self, __Pyx_memviewslice __pyx_v_data, __Pyx_memviewslice __pyx_v_ind, __Pyx_memviewslice __pyx_v_ptr, __Pyx_memviewslice __pyx_v_vec, bool __pyx_v_isherm); /* proto */
2647 static PyObject *__pyx_pf_5qutip_2cy_10spmatfuncs_28cy_expect_rho_vec(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_super_op, __Pyx_memviewslice __pyx_v_rho_vec, int __pyx_v_herm); /* proto */
2648 static PyObject *__pyx_pf_5qutip_2cy_10spmatfuncs_30cy_expect_rho_vec_csr(CYTHON_UNUSED PyObject *__pyx_self, __Pyx_memviewslice __pyx_v_data, __Pyx_memviewslice __pyx_v_idx, __Pyx_memviewslice __pyx_v_ptr, __Pyx_memviewslice __pyx_v_rho_vec, int __pyx_v_herm); /* proto */
2649 static PyObject *__pyx_pf_5qutip_2cy_10spmatfuncs_32cy_spmm_tr(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_op1, PyObject *__pyx_v_op2, int __pyx_v_herm); /* proto */
2650 static PyObject *__pyx_pf_5qutip_2cy_10spmatfuncs_34expect_csr_ket(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_A, PyObject *__pyx_v_B, int __pyx_v_isherm); /* proto */
2651 static PyObject *__pyx_pf_5qutip_2cy_10spmatfuncs_36zcsr_mat_elem(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_A, PyObject *__pyx_v_left, PyObject *__pyx_v_right, bool __pyx_v_bra_ket); /* proto */
2652 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 */
2653 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 */
2654 static void __pyx_array___pyx_pf_15View_dot_MemoryView_5array_4__dealloc__(struct __pyx_array_obj *__pyx_v_self); /* proto */
2655 static PyObject *__pyx_pf_15View_dot_MemoryView_5array_7memview___get__(struct __pyx_array_obj *__pyx_v_self); /* proto */
2656 static Py_ssize_t __pyx_array___pyx_pf_15View_dot_MemoryView_5array_6__len__(struct __pyx_array_obj *__pyx_v_self); /* proto */
2657 static PyObject *__pyx_array___pyx_pf_15View_dot_MemoryView_5array_8__getattr__(struct __pyx_array_obj *__pyx_v_self, PyObject *__pyx_v_attr); /* proto */
2658 static PyObject *__pyx_array___pyx_pf_15View_dot_MemoryView_5array_10__getitem__(struct __pyx_array_obj *__pyx_v_self, PyObject *__pyx_v_item); /* proto */
2659 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 */
2660 static PyObject *__pyx_pf___pyx_array___reduce_cython__(CYTHON_UNUSED struct __pyx_array_obj *__pyx_v_self); /* proto */
2661 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 */
2662 static int __pyx_MemviewEnum___pyx_pf_15View_dot_MemoryView_4Enum___init__(struct __pyx_MemviewEnum_obj *__pyx_v_self, PyObject *__pyx_v_name); /* proto */
2663 static PyObject *__pyx_MemviewEnum___pyx_pf_15View_dot_MemoryView_4Enum_2__repr__(struct __pyx_MemviewEnum_obj *__pyx_v_self); /* proto */
2664 static PyObject *__pyx_pf___pyx_MemviewEnum___reduce_cython__(struct __pyx_MemviewEnum_obj *__pyx_v_self); /* proto */
2665 static PyObject *__pyx_pf___pyx_MemviewEnum_2__setstate_cython__(struct __pyx_MemviewEnum_obj *__pyx_v_self, PyObject *__pyx_v___pyx_state); /* proto */
2666 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 */
2667 static void __pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_2__dealloc__(struct __pyx_memoryview_obj *__pyx_v_self); /* proto */
2668 static PyObject *__pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_4__getitem__(struct __pyx_memoryview_obj *__pyx_v_self, PyObject *__pyx_v_index); /* proto */
2669 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 */
2670 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 */
2671 static PyObject *__pyx_pf_15View_dot_MemoryView_10memoryview_1T___get__(struct __pyx_memoryview_obj *__pyx_v_self); /* proto */
2672 static PyObject *__pyx_pf_15View_dot_MemoryView_10memoryview_4base___get__(struct __pyx_memoryview_obj *__pyx_v_self); /* proto */
2673 static PyObject *__pyx_pf_15View_dot_MemoryView_10memoryview_5shape___get__(struct __pyx_memoryview_obj *__pyx_v_self); /* proto */
2674 static PyObject *__pyx_pf_15View_dot_MemoryView_10memoryview_7strides___get__(struct __pyx_memoryview_obj *__pyx_v_self); /* proto */
2675 static PyObject *__pyx_pf_15View_dot_MemoryView_10memoryview_10suboffsets___get__(struct __pyx_memoryview_obj *__pyx_v_self); /* proto */
2676 static PyObject *__pyx_pf_15View_dot_MemoryView_10memoryview_4ndim___get__(struct __pyx_memoryview_obj *__pyx_v_self); /* proto */
2677 static PyObject *__pyx_pf_15View_dot_MemoryView_10memoryview_8itemsize___get__(struct __pyx_memoryview_obj *__pyx_v_self); /* proto */
2678 static PyObject *__pyx_pf_15View_dot_MemoryView_10memoryview_6nbytes___get__(struct __pyx_memoryview_obj *__pyx_v_self); /* proto */
2679 static PyObject *__pyx_pf_15View_dot_MemoryView_10memoryview_4size___get__(struct __pyx_memoryview_obj *__pyx_v_self); /* proto */
2680 static Py_ssize_t __pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_10__len__(struct __pyx_memoryview_obj *__pyx_v_self); /* proto */
2681 static PyObject *__pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_12__repr__(struct __pyx_memoryview_obj *__pyx_v_self); /* proto */
2682 static PyObject *__pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_14__str__(struct __pyx_memoryview_obj *__pyx_v_self); /* proto */
2683 static PyObject *__pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_16is_c_contig(struct __pyx_memoryview_obj *__pyx_v_self); /* proto */
2684 static PyObject *__pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_18is_f_contig(struct __pyx_memoryview_obj *__pyx_v_self); /* proto */
2685 static PyObject *__pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_20copy(struct __pyx_memoryview_obj *__pyx_v_self); /* proto */
2686 static PyObject *__pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_22copy_fortran(struct __pyx_memoryview_obj *__pyx_v_self); /* proto */
2687 static PyObject *__pyx_pf___pyx_memoryview___reduce_cython__(CYTHON_UNUSED struct __pyx_memoryview_obj *__pyx_v_self); /* proto */
2688 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 */
2689 static void __pyx_memoryviewslice___pyx_pf_15View_dot_MemoryView_16_memoryviewslice___dealloc__(struct __pyx_memoryviewslice_obj *__pyx_v_self); /* proto */
2690 static PyObject *__pyx_pf_15View_dot_MemoryView_16_memoryviewslice_4base___get__(struct __pyx_memoryviewslice_obj *__pyx_v_self); /* proto */
2691 static PyObject *__pyx_pf___pyx_memoryviewslice___reduce_cython__(CYTHON_UNUSED struct __pyx_memoryviewslice_obj *__pyx_v_self); /* proto */
2692 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 */
2693 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 */
2694 static PyObject *__pyx_tp_new_array(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
2695 static PyObject *__pyx_tp_new_Enum(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
2696 static PyObject *__pyx_tp_new_memoryview(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
2697 static PyObject *__pyx_tp_new__memoryviewslice(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
2698 static PyObject *__pyx_int_0;
2699 static PyObject *__pyx_int_1;
2700 static PyObject *__pyx_int_184977713;
2701 static PyObject *__pyx_int_neg_1;
2702 static PyObject *__pyx_tuple_;
2703 static PyObject *__pyx_tuple__2;
2704 static PyObject *__pyx_tuple__3;
2705 static PyObject *__pyx_tuple__4;
2706 static PyObject *__pyx_tuple__5;
2707 static PyObject *__pyx_tuple__6;
2708 static PyObject *__pyx_tuple__7;
2709 static PyObject *__pyx_tuple__8;
2710 static PyObject *__pyx_tuple__9;
2711 static PyObject *__pyx_slice__17;
2712 static PyObject *__pyx_tuple__10;
2713 static PyObject *__pyx_tuple__11;
2714 static PyObject *__pyx_tuple__12;
2715 static PyObject *__pyx_tuple__13;
2716 static PyObject *__pyx_tuple__14;
2717 static PyObject *__pyx_tuple__15;
2718 static PyObject *__pyx_tuple__16;
2719 static PyObject *__pyx_tuple__18;
2720 static PyObject *__pyx_tuple__19;
2721 static PyObject *__pyx_tuple__20;
2722 static PyObject *__pyx_tuple__21;
2723 static PyObject *__pyx_tuple__23;
2724 static PyObject *__pyx_tuple__25;
2725 static PyObject *__pyx_tuple__26;
2726 static PyObject *__pyx_tuple__27;
2727 static PyObject *__pyx_tuple__28;
2728 static PyObject *__pyx_tuple__29;
2729 static PyObject *__pyx_tuple__30;
2730 static PyObject *__pyx_codeobj__22;
2731 static PyObject *__pyx_codeobj__24;
2732 static PyObject *__pyx_codeobj__31;
2733 /* Late includes */
2734 
2735 /* "qutip/cy/spmatfuncs.pyx":48
2736  * @cython.boundscheck(False)
2737  * @cython.wraparound(False)
2738  * cpdef cnp.ndarray[complex, ndim=1, mode="c"] spmv(             # <<<<<<<<<<<<<<
2739  *         object super_op,
2740  *         complex[::1] vec):
2741  */
2742 
2743 static PyObject *__pyx_pw_5qutip_2cy_10spmatfuncs_1spmv(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
__pyx_f_5qutip_2cy_10spmatfuncs_spmv(PyObject * __pyx_v_super_op,__Pyx_memviewslice __pyx_v_vec,CYTHON_UNUSED int __pyx_skip_dispatch)2744 static PyArrayObject *__pyx_f_5qutip_2cy_10spmatfuncs_spmv(PyObject *__pyx_v_super_op, __Pyx_memviewslice __pyx_v_vec, CYTHON_UNUSED int __pyx_skip_dispatch) {
2745   PyArrayObject *__pyx_r = NULL;
2746   __Pyx_RefNannyDeclarations
2747   PyObject *__pyx_t_1 = NULL;
2748   __Pyx_memviewslice __pyx_t_2 = { 0, 0, { 0 }, { 0 }, { 0 } };
2749   __Pyx_memviewslice __pyx_t_3 = { 0, 0, { 0 }, { 0 }, { 0 } };
2750   __Pyx_memviewslice __pyx_t_4 = { 0, 0, { 0 }, { 0 }, { 0 } };
2751   int __pyx_lineno = 0;
2752   const char *__pyx_filename = NULL;
2753   int __pyx_clineno = 0;
2754   __Pyx_RefNannySetupContext("spmv", 0);
2755 
2756   /* "qutip/cy/spmatfuncs.pyx":68
2757  *
2758  *     """
2759  *     return spmv_csr(super_op.data, super_op.indices, super_op.indptr, vec)             # <<<<<<<<<<<<<<
2760  *
2761  *
2762  */
2763   __Pyx_XDECREF(((PyObject *)__pyx_r));
2764   __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_super_op, __pyx_n_s_data); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 68, __pyx_L1_error)
2765   __Pyx_GOTREF(__pyx_t_1);
2766   __pyx_t_2 = __Pyx_PyObject_to_MemoryviewSlice_dc___pyx_t_double_complex(__pyx_t_1, PyBUF_WRITABLE); if (unlikely(!__pyx_t_2.memview)) __PYX_ERR(0, 68, __pyx_L1_error)
2767   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
2768   __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_super_op, __pyx_n_s_indices); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 68, __pyx_L1_error)
2769   __Pyx_GOTREF(__pyx_t_1);
2770   __pyx_t_3 = __Pyx_PyObject_to_MemoryviewSlice_dc_int(__pyx_t_1, PyBUF_WRITABLE); if (unlikely(!__pyx_t_3.memview)) __PYX_ERR(0, 68, __pyx_L1_error)
2771   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
2772   __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_super_op, __pyx_n_s_indptr); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 68, __pyx_L1_error)
2773   __Pyx_GOTREF(__pyx_t_1);
2774   __pyx_t_4 = __Pyx_PyObject_to_MemoryviewSlice_dc_int(__pyx_t_1, PyBUF_WRITABLE); if (unlikely(!__pyx_t_4.memview)) __PYX_ERR(0, 68, __pyx_L1_error)
2775   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
2776   __pyx_t_1 = ((PyObject *)__pyx_f_5qutip_2cy_10spmatfuncs_spmv_csr(__pyx_t_2, __pyx_t_3, __pyx_t_4, __pyx_v_vec, 0)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 68, __pyx_L1_error)
2777   __Pyx_GOTREF(__pyx_t_1);
2778   __PYX_XDEC_MEMVIEW(&__pyx_t_2, 1);
2779   __pyx_t_2.memview = NULL;
2780   __pyx_t_2.data = NULL;
2781   __PYX_XDEC_MEMVIEW(&__pyx_t_3, 1);
2782   __pyx_t_3.memview = NULL;
2783   __pyx_t_3.data = NULL;
2784   __PYX_XDEC_MEMVIEW(&__pyx_t_4, 1);
2785   __pyx_t_4.memview = NULL;
2786   __pyx_t_4.data = NULL;
2787   __pyx_r = ((PyArrayObject *)__pyx_t_1);
2788   __pyx_t_1 = 0;
2789   goto __pyx_L0;
2790 
2791   /* "qutip/cy/spmatfuncs.pyx":48
2792  * @cython.boundscheck(False)
2793  * @cython.wraparound(False)
2794  * cpdef cnp.ndarray[complex, ndim=1, mode="c"] spmv(             # <<<<<<<<<<<<<<
2795  *         object super_op,
2796  *         complex[::1] vec):
2797  */
2798 
2799   /* function exit code */
2800   __pyx_L1_error:;
2801   __Pyx_XDECREF(__pyx_t_1);
2802   __PYX_XDEC_MEMVIEW(&__pyx_t_2, 1);
2803   __PYX_XDEC_MEMVIEW(&__pyx_t_3, 1);
2804   __PYX_XDEC_MEMVIEW(&__pyx_t_4, 1);
2805   __Pyx_AddTraceback("qutip.cy.spmatfuncs.spmv", __pyx_clineno, __pyx_lineno, __pyx_filename);
2806   __pyx_r = 0;
2807   __pyx_L0:;
2808   __Pyx_XGIVEREF((PyObject *)__pyx_r);
2809   __Pyx_RefNannyFinishContext();
2810   return __pyx_r;
2811 }
2812 
2813 /* Python wrapper */
2814 static PyObject *__pyx_pw_5qutip_2cy_10spmatfuncs_1spmv(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
2815 static char __pyx_doc_5qutip_2cy_10spmatfuncs_spmv[] = "\n    Sparse matrix, dense vector multiplication.\n    Here the vector is assumed to have one-dimension.\n    Matrix must be in CSR format and have complex entries.\n\n    Parameters\n    ----------\n    super_op : csr matrix\n    vec : array\n        Dense vector for multiplication.  Must be one-dimensional.\n\n    Returns\n    -------\n    out : array\n        Returns dense array.\n\n    ";
__pyx_pw_5qutip_2cy_10spmatfuncs_1spmv(PyObject * __pyx_self,PyObject * __pyx_args,PyObject * __pyx_kwds)2816 static PyObject *__pyx_pw_5qutip_2cy_10spmatfuncs_1spmv(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
2817   PyObject *__pyx_v_super_op = 0;
2818   __Pyx_memviewslice __pyx_v_vec = { 0, 0, { 0 }, { 0 }, { 0 } };
2819   int __pyx_lineno = 0;
2820   const char *__pyx_filename = NULL;
2821   int __pyx_clineno = 0;
2822   PyObject *__pyx_r = 0;
2823   __Pyx_RefNannyDeclarations
2824   __Pyx_RefNannySetupContext("spmv (wrapper)", 0);
2825   {
2826     static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_super_op,&__pyx_n_s_vec,0};
2827     PyObject* values[2] = {0,0};
2828     if (unlikely(__pyx_kwds)) {
2829       Py_ssize_t kw_args;
2830       const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
2831       switch (pos_args) {
2832         case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
2833         CYTHON_FALLTHROUGH;
2834         case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
2835         CYTHON_FALLTHROUGH;
2836         case  0: break;
2837         default: goto __pyx_L5_argtuple_error;
2838       }
2839       kw_args = PyDict_Size(__pyx_kwds);
2840       switch (pos_args) {
2841         case  0:
2842         if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_super_op)) != 0)) kw_args--;
2843         else goto __pyx_L5_argtuple_error;
2844         CYTHON_FALLTHROUGH;
2845         case  1:
2846         if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_vec)) != 0)) kw_args--;
2847         else {
2848           __Pyx_RaiseArgtupleInvalid("spmv", 1, 2, 2, 1); __PYX_ERR(0, 48, __pyx_L3_error)
2849         }
2850       }
2851       if (unlikely(kw_args > 0)) {
2852         if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "spmv") < 0)) __PYX_ERR(0, 48, __pyx_L3_error)
2853       }
2854     } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
2855       goto __pyx_L5_argtuple_error;
2856     } else {
2857       values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
2858       values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
2859     }
2860     __pyx_v_super_op = values[0];
2861     __pyx_v_vec = __Pyx_PyObject_to_MemoryviewSlice_dc___pyx_t_double_complex(values[1], PyBUF_WRITABLE); if (unlikely(!__pyx_v_vec.memview)) __PYX_ERR(0, 50, __pyx_L3_error)
2862   }
2863   goto __pyx_L4_argument_unpacking_done;
2864   __pyx_L5_argtuple_error:;
2865   __Pyx_RaiseArgtupleInvalid("spmv", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 48, __pyx_L3_error)
2866   __pyx_L3_error:;
2867   __Pyx_AddTraceback("qutip.cy.spmatfuncs.spmv", __pyx_clineno, __pyx_lineno, __pyx_filename);
2868   __Pyx_RefNannyFinishContext();
2869   return NULL;
2870   __pyx_L4_argument_unpacking_done:;
2871   __pyx_r = __pyx_pf_5qutip_2cy_10spmatfuncs_spmv(__pyx_self, __pyx_v_super_op, __pyx_v_vec);
2872 
2873   /* function exit code */
2874   __Pyx_RefNannyFinishContext();
2875   return __pyx_r;
2876 }
2877 
__pyx_pf_5qutip_2cy_10spmatfuncs_spmv(CYTHON_UNUSED PyObject * __pyx_self,PyObject * __pyx_v_super_op,__Pyx_memviewslice __pyx_v_vec)2878 static PyObject *__pyx_pf_5qutip_2cy_10spmatfuncs_spmv(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_super_op, __Pyx_memviewslice __pyx_v_vec) {
2879   PyObject *__pyx_r = NULL;
2880   __Pyx_RefNannyDeclarations
2881   PyObject *__pyx_t_1 = NULL;
2882   int __pyx_lineno = 0;
2883   const char *__pyx_filename = NULL;
2884   int __pyx_clineno = 0;
2885   __Pyx_RefNannySetupContext("spmv", 0);
2886   __Pyx_XDECREF(__pyx_r);
2887   if (unlikely(!__pyx_v_vec.memview)) { __Pyx_RaiseUnboundLocalError("vec"); __PYX_ERR(0, 48, __pyx_L1_error) }
2888   __pyx_t_1 = ((PyObject *)__pyx_f_5qutip_2cy_10spmatfuncs_spmv(__pyx_v_super_op, __pyx_v_vec, 0)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 48, __pyx_L1_error)
2889   __Pyx_GOTREF(__pyx_t_1);
2890   __pyx_r = __pyx_t_1;
2891   __pyx_t_1 = 0;
2892   goto __pyx_L0;
2893 
2894   /* function exit code */
2895   __pyx_L1_error:;
2896   __Pyx_XDECREF(__pyx_t_1);
2897   __Pyx_AddTraceback("qutip.cy.spmatfuncs.spmv", __pyx_clineno, __pyx_lineno, __pyx_filename);
2898   __pyx_r = NULL;
2899   __pyx_L0:;
2900   __PYX_XDEC_MEMVIEW(&__pyx_v_vec, 1);
2901   __Pyx_XGIVEREF(__pyx_r);
2902   __Pyx_RefNannyFinishContext();
2903   return __pyx_r;
2904 }
2905 
2906 /* "qutip/cy/spmatfuncs.pyx":73
2907  * @cython.boundscheck(False)
2908  * @cython.wraparound(False)
2909  * cpdef cnp.ndarray[complex, ndim=1, mode="c"] spmv_csr(complex[::1] data,             # <<<<<<<<<<<<<<
2910  *             int[::1] ind, int[::1] ptr, complex[::1] vec):
2911  *     """
2912  */
2913 
2914 static PyObject *__pyx_pw_5qutip_2cy_10spmatfuncs_3spmv_csr(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
__pyx_f_5qutip_2cy_10spmatfuncs_spmv_csr(__Pyx_memviewslice __pyx_v_data,__Pyx_memviewslice __pyx_v_ind,__Pyx_memviewslice __pyx_v_ptr,__Pyx_memviewslice __pyx_v_vec,CYTHON_UNUSED int __pyx_skip_dispatch)2915 static PyArrayObject *__pyx_f_5qutip_2cy_10spmatfuncs_spmv_csr(__Pyx_memviewslice __pyx_v_data, __Pyx_memviewslice __pyx_v_ind, __Pyx_memviewslice __pyx_v_ptr, __Pyx_memviewslice __pyx_v_vec, CYTHON_UNUSED int __pyx_skip_dispatch) {
2916   unsigned int __pyx_v_num_rows;
2917   PyArrayObject *__pyx_v_out = 0;
2918   __Pyx_LocalBuf_ND __pyx_pybuffernd_out;
2919   __Pyx_Buffer __pyx_pybuffer_out;
2920   PyArrayObject *__pyx_r = NULL;
2921   __Pyx_RefNannyDeclarations
2922   PyObject *__pyx_t_1 = NULL;
2923   PyObject *__pyx_t_2 = NULL;
2924   PyObject *__pyx_t_3 = NULL;
2925   PyObject *__pyx_t_4 = NULL;
2926   PyObject *__pyx_t_5 = NULL;
2927   PyArrayObject *__pyx_t_6 = NULL;
2928   Py_ssize_t __pyx_t_7;
2929   Py_ssize_t __pyx_t_8;
2930   Py_ssize_t __pyx_t_9;
2931   Py_ssize_t __pyx_t_10;
2932   Py_ssize_t __pyx_t_11;
2933   int __pyx_lineno = 0;
2934   const char *__pyx_filename = NULL;
2935   int __pyx_clineno = 0;
2936   __Pyx_RefNannySetupContext("spmv_csr", 0);
2937   __pyx_pybuffer_out.pybuffer.buf = NULL;
2938   __pyx_pybuffer_out.refcount = 0;
2939   __pyx_pybuffernd_out.data = NULL;
2940   __pyx_pybuffernd_out.rcbuffer = &__pyx_pybuffer_out;
2941 
2942   /* "qutip/cy/spmatfuncs.pyx":97
2943  *
2944  *     """
2945  *     cdef unsigned int num_rows = ptr.shape[0] - 1             # <<<<<<<<<<<<<<
2946  *     cdef cnp.ndarray[complex, ndim=1, mode="c"] out = np.zeros((num_rows), dtype=np.complex128)
2947  *     zspmvpy(&data[0], &ind[0], &ptr[0], &vec[0], 1.0, &out[0], num_rows)
2948  */
2949   __pyx_v_num_rows = ((__pyx_v_ptr.shape[0]) - 1);
2950 
2951   /* "qutip/cy/spmatfuncs.pyx":98
2952  *     """
2953  *     cdef unsigned int num_rows = ptr.shape[0] - 1
2954  *     cdef cnp.ndarray[complex, ndim=1, mode="c"] out = np.zeros((num_rows), dtype=np.complex128)             # <<<<<<<<<<<<<<
2955  *     zspmvpy(&data[0], &ind[0], &ptr[0], &vec[0], 1.0, &out[0], num_rows)
2956  *     return out
2957  */
2958   __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_np); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 98, __pyx_L1_error)
2959   __Pyx_GOTREF(__pyx_t_1);
2960   __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_zeros); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 98, __pyx_L1_error)
2961   __Pyx_GOTREF(__pyx_t_2);
2962   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
2963   __pyx_t_1 = __Pyx_PyInt_From_unsigned_int(__pyx_v_num_rows); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 98, __pyx_L1_error)
2964   __Pyx_GOTREF(__pyx_t_1);
2965   __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 98, __pyx_L1_error)
2966   __Pyx_GOTREF(__pyx_t_3);
2967   __Pyx_GIVEREF(__pyx_t_1);
2968   PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_1);
2969   __pyx_t_1 = 0;
2970   __pyx_t_1 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 98, __pyx_L1_error)
2971   __Pyx_GOTREF(__pyx_t_1);
2972   __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_np); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 98, __pyx_L1_error)
2973   __Pyx_GOTREF(__pyx_t_4);
2974   __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_complex128); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 98, __pyx_L1_error)
2975   __Pyx_GOTREF(__pyx_t_5);
2976   __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
2977   if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_dtype, __pyx_t_5) < 0) __PYX_ERR(0, 98, __pyx_L1_error)
2978   __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
2979   __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_3, __pyx_t_1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 98, __pyx_L1_error)
2980   __Pyx_GOTREF(__pyx_t_5);
2981   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
2982   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
2983   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
2984   if (!(likely(((__pyx_t_5) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_5, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 98, __pyx_L1_error)
2985   __pyx_t_6 = ((PyArrayObject *)__pyx_t_5);
2986   {
2987     __Pyx_BufFmt_StackElem __pyx_stack[1];
2988     if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_out.rcbuffer->pybuffer, (PyObject*)__pyx_t_6, &__Pyx_TypeInfo___pyx_t_double_complex, PyBUF_FORMAT| PyBUF_C_CONTIGUOUS, 1, 0, __pyx_stack) == -1)) {
2989       __pyx_v_out = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_pybuffernd_out.rcbuffer->pybuffer.buf = NULL;
2990       __PYX_ERR(0, 98, __pyx_L1_error)
2991     } else {__pyx_pybuffernd_out.diminfo[0].strides = __pyx_pybuffernd_out.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_out.diminfo[0].shape = __pyx_pybuffernd_out.rcbuffer->pybuffer.shape[0];
2992     }
2993   }
2994   __pyx_t_6 = 0;
2995   __pyx_v_out = ((PyArrayObject *)__pyx_t_5);
2996   __pyx_t_5 = 0;
2997 
2998   /* "qutip/cy/spmatfuncs.pyx":99
2999  *     cdef unsigned int num_rows = ptr.shape[0] - 1
3000  *     cdef cnp.ndarray[complex, ndim=1, mode="c"] out = np.zeros((num_rows), dtype=np.complex128)
3001  *     zspmvpy(&data[0], &ind[0], &ptr[0], &vec[0], 1.0, &out[0], num_rows)             # <<<<<<<<<<<<<<
3002  *     return out
3003  *
3004  */
3005   __pyx_t_7 = 0;
3006   __pyx_t_8 = 0;
3007   __pyx_t_9 = 0;
3008   __pyx_t_10 = 0;
3009   __pyx_t_11 = 0;
3010   zspmvpy((&(*((__pyx_t_double_complex *) ( /* dim=0 */ ((char *) (((__pyx_t_double_complex *) __pyx_v_data.data) + __pyx_t_7)) )))), (&(*((int *) ( /* dim=0 */ ((char *) (((int *) __pyx_v_ind.data) + __pyx_t_8)) )))), (&(*((int *) ( /* dim=0 */ ((char *) (((int *) __pyx_v_ptr.data) + __pyx_t_9)) )))), (&(*((__pyx_t_double_complex *) ( /* dim=0 */ ((char *) (((__pyx_t_double_complex *) __pyx_v_vec.data) + __pyx_t_10)) )))), __pyx_t_double_complex_from_parts(1.0, 0), (&(*__Pyx_BufPtrCContig1d(__pyx_t_double_complex *, __pyx_pybuffernd_out.rcbuffer->pybuffer.buf, __pyx_t_11, __pyx_pybuffernd_out.diminfo[0].strides))), __pyx_v_num_rows);
3011 
3012   /* "qutip/cy/spmatfuncs.pyx":100
3013  *     cdef cnp.ndarray[complex, ndim=1, mode="c"] out = np.zeros((num_rows), dtype=np.complex128)
3014  *     zspmvpy(&data[0], &ind[0], &ptr[0], &vec[0], 1.0, &out[0], num_rows)
3015  *     return out             # <<<<<<<<<<<<<<
3016  *
3017  *
3018  */
3019   __Pyx_XDECREF(((PyObject *)__pyx_r));
3020   __Pyx_INCREF(((PyObject *)__pyx_v_out));
3021   __pyx_r = ((PyArrayObject *)__pyx_v_out);
3022   goto __pyx_L0;
3023 
3024   /* "qutip/cy/spmatfuncs.pyx":73
3025  * @cython.boundscheck(False)
3026  * @cython.wraparound(False)
3027  * cpdef cnp.ndarray[complex, ndim=1, mode="c"] spmv_csr(complex[::1] data,             # <<<<<<<<<<<<<<
3028  *             int[::1] ind, int[::1] ptr, complex[::1] vec):
3029  *     """
3030  */
3031 
3032   /* function exit code */
3033   __pyx_L1_error:;
3034   __Pyx_XDECREF(__pyx_t_1);
3035   __Pyx_XDECREF(__pyx_t_2);
3036   __Pyx_XDECREF(__pyx_t_3);
3037   __Pyx_XDECREF(__pyx_t_4);
3038   __Pyx_XDECREF(__pyx_t_5);
3039   { PyObject *__pyx_type, *__pyx_value, *__pyx_tb;
3040     __Pyx_PyThreadState_declare
3041     __Pyx_PyThreadState_assign
3042     __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb);
3043     __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_out.rcbuffer->pybuffer);
3044   __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}
3045   __Pyx_AddTraceback("qutip.cy.spmatfuncs.spmv_csr", __pyx_clineno, __pyx_lineno, __pyx_filename);
3046   __pyx_r = 0;
3047   goto __pyx_L2;
3048   __pyx_L0:;
3049   __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_out.rcbuffer->pybuffer);
3050   __pyx_L2:;
3051   __Pyx_XDECREF((PyObject *)__pyx_v_out);
3052   __Pyx_XGIVEREF((PyObject *)__pyx_r);
3053   __Pyx_RefNannyFinishContext();
3054   return __pyx_r;
3055 }
3056 
3057 /* Python wrapper */
3058 static PyObject *__pyx_pw_5qutip_2cy_10spmatfuncs_3spmv_csr(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
3059 static char __pyx_doc_5qutip_2cy_10spmatfuncs_2spmv_csr[] = "\n    Sparse matrix, dense vector multiplication.\n    Here the vector is assumed to have one-dimension.\n    Matrix must be in CSR format and have complex entries.\n\n    Parameters\n    ----------\n    data : array\n        Data for sparse matrix.\n    idx : array\n        Indices for sparse matrix data.\n    ptr : array\n        Pointers for sparse matrix data.\n    vec : array\n        Dense vector for multiplication.  Must be one-dimensional.\n\n    Returns\n    -------\n    out : array\n        Returns dense array.\n\n    ";
__pyx_pw_5qutip_2cy_10spmatfuncs_3spmv_csr(PyObject * __pyx_self,PyObject * __pyx_args,PyObject * __pyx_kwds)3060 static PyObject *__pyx_pw_5qutip_2cy_10spmatfuncs_3spmv_csr(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
3061   __Pyx_memviewslice __pyx_v_data = { 0, 0, { 0 }, { 0 }, { 0 } };
3062   __Pyx_memviewslice __pyx_v_ind = { 0, 0, { 0 }, { 0 }, { 0 } };
3063   __Pyx_memviewslice __pyx_v_ptr = { 0, 0, { 0 }, { 0 }, { 0 } };
3064   __Pyx_memviewslice __pyx_v_vec = { 0, 0, { 0 }, { 0 }, { 0 } };
3065   int __pyx_lineno = 0;
3066   const char *__pyx_filename = NULL;
3067   int __pyx_clineno = 0;
3068   PyObject *__pyx_r = 0;
3069   __Pyx_RefNannyDeclarations
3070   __Pyx_RefNannySetupContext("spmv_csr (wrapper)", 0);
3071   {
3072     static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_data,&__pyx_n_s_ind,&__pyx_n_s_ptr,&__pyx_n_s_vec,0};
3073     PyObject* values[4] = {0,0,0,0};
3074     if (unlikely(__pyx_kwds)) {
3075       Py_ssize_t kw_args;
3076       const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
3077       switch (pos_args) {
3078         case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
3079         CYTHON_FALLTHROUGH;
3080         case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
3081         CYTHON_FALLTHROUGH;
3082         case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
3083         CYTHON_FALLTHROUGH;
3084         case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
3085         CYTHON_FALLTHROUGH;
3086         case  0: break;
3087         default: goto __pyx_L5_argtuple_error;
3088       }
3089       kw_args = PyDict_Size(__pyx_kwds);
3090       switch (pos_args) {
3091         case  0:
3092         if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_data)) != 0)) kw_args--;
3093         else goto __pyx_L5_argtuple_error;
3094         CYTHON_FALLTHROUGH;
3095         case  1:
3096         if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_ind)) != 0)) kw_args--;
3097         else {
3098           __Pyx_RaiseArgtupleInvalid("spmv_csr", 1, 4, 4, 1); __PYX_ERR(0, 73, __pyx_L3_error)
3099         }
3100         CYTHON_FALLTHROUGH;
3101         case  2:
3102         if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_ptr)) != 0)) kw_args--;
3103         else {
3104           __Pyx_RaiseArgtupleInvalid("spmv_csr", 1, 4, 4, 2); __PYX_ERR(0, 73, __pyx_L3_error)
3105         }
3106         CYTHON_FALLTHROUGH;
3107         case  3:
3108         if (likely((values[3] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_vec)) != 0)) kw_args--;
3109         else {
3110           __Pyx_RaiseArgtupleInvalid("spmv_csr", 1, 4, 4, 3); __PYX_ERR(0, 73, __pyx_L3_error)
3111         }
3112       }
3113       if (unlikely(kw_args > 0)) {
3114         if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "spmv_csr") < 0)) __PYX_ERR(0, 73, __pyx_L3_error)
3115       }
3116     } else if (PyTuple_GET_SIZE(__pyx_args) != 4) {
3117       goto __pyx_L5_argtuple_error;
3118     } else {
3119       values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
3120       values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
3121       values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
3122       values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
3123     }
3124     __pyx_v_data = __Pyx_PyObject_to_MemoryviewSlice_dc___pyx_t_double_complex(values[0], PyBUF_WRITABLE); if (unlikely(!__pyx_v_data.memview)) __PYX_ERR(0, 73, __pyx_L3_error)
3125     __pyx_v_ind = __Pyx_PyObject_to_MemoryviewSlice_dc_int(values[1], PyBUF_WRITABLE); if (unlikely(!__pyx_v_ind.memview)) __PYX_ERR(0, 74, __pyx_L3_error)
3126     __pyx_v_ptr = __Pyx_PyObject_to_MemoryviewSlice_dc_int(values[2], PyBUF_WRITABLE); if (unlikely(!__pyx_v_ptr.memview)) __PYX_ERR(0, 74, __pyx_L3_error)
3127     __pyx_v_vec = __Pyx_PyObject_to_MemoryviewSlice_dc___pyx_t_double_complex(values[3], PyBUF_WRITABLE); if (unlikely(!__pyx_v_vec.memview)) __PYX_ERR(0, 74, __pyx_L3_error)
3128   }
3129   goto __pyx_L4_argument_unpacking_done;
3130   __pyx_L5_argtuple_error:;
3131   __Pyx_RaiseArgtupleInvalid("spmv_csr", 1, 4, 4, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 73, __pyx_L3_error)
3132   __pyx_L3_error:;
3133   __Pyx_AddTraceback("qutip.cy.spmatfuncs.spmv_csr", __pyx_clineno, __pyx_lineno, __pyx_filename);
3134   __Pyx_RefNannyFinishContext();
3135   return NULL;
3136   __pyx_L4_argument_unpacking_done:;
3137   __pyx_r = __pyx_pf_5qutip_2cy_10spmatfuncs_2spmv_csr(__pyx_self, __pyx_v_data, __pyx_v_ind, __pyx_v_ptr, __pyx_v_vec);
3138 
3139   /* function exit code */
3140   __Pyx_RefNannyFinishContext();
3141   return __pyx_r;
3142 }
3143 
__pyx_pf_5qutip_2cy_10spmatfuncs_2spmv_csr(CYTHON_UNUSED PyObject * __pyx_self,__Pyx_memviewslice __pyx_v_data,__Pyx_memviewslice __pyx_v_ind,__Pyx_memviewslice __pyx_v_ptr,__Pyx_memviewslice __pyx_v_vec)3144 static PyObject *__pyx_pf_5qutip_2cy_10spmatfuncs_2spmv_csr(CYTHON_UNUSED PyObject *__pyx_self, __Pyx_memviewslice __pyx_v_data, __Pyx_memviewslice __pyx_v_ind, __Pyx_memviewslice __pyx_v_ptr, __Pyx_memviewslice __pyx_v_vec) {
3145   PyObject *__pyx_r = NULL;
3146   __Pyx_RefNannyDeclarations
3147   PyObject *__pyx_t_1 = NULL;
3148   int __pyx_lineno = 0;
3149   const char *__pyx_filename = NULL;
3150   int __pyx_clineno = 0;
3151   __Pyx_RefNannySetupContext("spmv_csr", 0);
3152   __Pyx_XDECREF(__pyx_r);
3153   if (unlikely(!__pyx_v_data.memview)) { __Pyx_RaiseUnboundLocalError("data"); __PYX_ERR(0, 73, __pyx_L1_error) }
3154   if (unlikely(!__pyx_v_ind.memview)) { __Pyx_RaiseUnboundLocalError("ind"); __PYX_ERR(0, 73, __pyx_L1_error) }
3155   if (unlikely(!__pyx_v_ptr.memview)) { __Pyx_RaiseUnboundLocalError("ptr"); __PYX_ERR(0, 73, __pyx_L1_error) }
3156   if (unlikely(!__pyx_v_vec.memview)) { __Pyx_RaiseUnboundLocalError("vec"); __PYX_ERR(0, 73, __pyx_L1_error) }
3157   __pyx_t_1 = ((PyObject *)__pyx_f_5qutip_2cy_10spmatfuncs_spmv_csr(__pyx_v_data, __pyx_v_ind, __pyx_v_ptr, __pyx_v_vec, 0)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 73, __pyx_L1_error)
3158   __Pyx_GOTREF(__pyx_t_1);
3159   __pyx_r = __pyx_t_1;
3160   __pyx_t_1 = 0;
3161   goto __pyx_L0;
3162 
3163   /* function exit code */
3164   __pyx_L1_error:;
3165   __Pyx_XDECREF(__pyx_t_1);
3166   __Pyx_AddTraceback("qutip.cy.spmatfuncs.spmv_csr", __pyx_clineno, __pyx_lineno, __pyx_filename);
3167   __pyx_r = NULL;
3168   __pyx_L0:;
3169   __PYX_XDEC_MEMVIEW(&__pyx_v_data, 1);
3170   __PYX_XDEC_MEMVIEW(&__pyx_v_ind, 1);
3171   __PYX_XDEC_MEMVIEW(&__pyx_v_ptr, 1);
3172   __PYX_XDEC_MEMVIEW(&__pyx_v_vec, 1);
3173   __Pyx_XGIVEREF(__pyx_r);
3174   __Pyx_RefNannyFinishContext();
3175   return __pyx_r;
3176 }
3177 
3178 /* "qutip/cy/spmatfuncs.pyx":105
3179  * @cython.boundscheck(False)
3180  * @cython.wraparound(False)
3181  * def spmvpy_csr(complex[::1] data,             # <<<<<<<<<<<<<<
3182  *             int[::1] ind, int[::1] ptr, complex[::1] vec,
3183  *             complex alpha, complex[::1] out):
3184  */
3185 
3186 /* Python wrapper */
3187 static PyObject *__pyx_pw_5qutip_2cy_10spmatfuncs_5spmvpy_csr(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
3188 static char __pyx_doc_5qutip_2cy_10spmatfuncs_4spmvpy_csr[] = "\n    Sparse matrix, dense vector multiplication.\n    Here the vector is assumed to have one-dimension.\n    Matrix must be in CSR format and have complex entries.\n\n    Parameters\n    ----------\n    data : array\n        Data for sparse matrix.\n    idx : array\n        Indices for sparse matrix data.\n    ptr : array\n        Pointers for sparse matrix data.\n    vec : array\n        Dense vector for multiplication.  Must be one-dimensional.\n    alpha : complex\n        Numerical coefficient for sparse matrix.\n    out: array\n        Output array\n\n    ";
3189 static PyMethodDef __pyx_mdef_5qutip_2cy_10spmatfuncs_5spmvpy_csr = {"spmvpy_csr", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_5qutip_2cy_10spmatfuncs_5spmvpy_csr, METH_VARARGS|METH_KEYWORDS, __pyx_doc_5qutip_2cy_10spmatfuncs_4spmvpy_csr};
__pyx_pw_5qutip_2cy_10spmatfuncs_5spmvpy_csr(PyObject * __pyx_self,PyObject * __pyx_args,PyObject * __pyx_kwds)3190 static PyObject *__pyx_pw_5qutip_2cy_10spmatfuncs_5spmvpy_csr(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
3191   __Pyx_memviewslice __pyx_v_data = { 0, 0, { 0 }, { 0 }, { 0 } };
3192   __Pyx_memviewslice __pyx_v_ind = { 0, 0, { 0 }, { 0 }, { 0 } };
3193   __Pyx_memviewslice __pyx_v_ptr = { 0, 0, { 0 }, { 0 }, { 0 } };
3194   __Pyx_memviewslice __pyx_v_vec = { 0, 0, { 0 }, { 0 }, { 0 } };
3195   __pyx_t_double_complex __pyx_v_alpha;
3196   __Pyx_memviewslice __pyx_v_out = { 0, 0, { 0 }, { 0 }, { 0 } };
3197   int __pyx_lineno = 0;
3198   const char *__pyx_filename = NULL;
3199   int __pyx_clineno = 0;
3200   PyObject *__pyx_r = 0;
3201   __Pyx_RefNannyDeclarations
3202   __Pyx_RefNannySetupContext("spmvpy_csr (wrapper)", 0);
3203   {
3204     static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_data,&__pyx_n_s_ind,&__pyx_n_s_ptr,&__pyx_n_s_vec,&__pyx_n_s_alpha,&__pyx_n_s_out,0};
3205     PyObject* values[6] = {0,0,0,0,0,0};
3206     if (unlikely(__pyx_kwds)) {
3207       Py_ssize_t kw_args;
3208       const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
3209       switch (pos_args) {
3210         case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
3211         CYTHON_FALLTHROUGH;
3212         case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
3213         CYTHON_FALLTHROUGH;
3214         case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
3215         CYTHON_FALLTHROUGH;
3216         case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
3217         CYTHON_FALLTHROUGH;
3218         case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
3219         CYTHON_FALLTHROUGH;
3220         case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
3221         CYTHON_FALLTHROUGH;
3222         case  0: break;
3223         default: goto __pyx_L5_argtuple_error;
3224       }
3225       kw_args = PyDict_Size(__pyx_kwds);
3226       switch (pos_args) {
3227         case  0:
3228         if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_data)) != 0)) kw_args--;
3229         else goto __pyx_L5_argtuple_error;
3230         CYTHON_FALLTHROUGH;
3231         case  1:
3232         if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_ind)) != 0)) kw_args--;
3233         else {
3234           __Pyx_RaiseArgtupleInvalid("spmvpy_csr", 1, 6, 6, 1); __PYX_ERR(0, 105, __pyx_L3_error)
3235         }
3236         CYTHON_FALLTHROUGH;
3237         case  2:
3238         if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_ptr)) != 0)) kw_args--;
3239         else {
3240           __Pyx_RaiseArgtupleInvalid("spmvpy_csr", 1, 6, 6, 2); __PYX_ERR(0, 105, __pyx_L3_error)
3241         }
3242         CYTHON_FALLTHROUGH;
3243         case  3:
3244         if (likely((values[3] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_vec)) != 0)) kw_args--;
3245         else {
3246           __Pyx_RaiseArgtupleInvalid("spmvpy_csr", 1, 6, 6, 3); __PYX_ERR(0, 105, __pyx_L3_error)
3247         }
3248         CYTHON_FALLTHROUGH;
3249         case  4:
3250         if (likely((values[4] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_alpha)) != 0)) kw_args--;
3251         else {
3252           __Pyx_RaiseArgtupleInvalid("spmvpy_csr", 1, 6, 6, 4); __PYX_ERR(0, 105, __pyx_L3_error)
3253         }
3254         CYTHON_FALLTHROUGH;
3255         case  5:
3256         if (likely((values[5] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_out)) != 0)) kw_args--;
3257         else {
3258           __Pyx_RaiseArgtupleInvalid("spmvpy_csr", 1, 6, 6, 5); __PYX_ERR(0, 105, __pyx_L3_error)
3259         }
3260       }
3261       if (unlikely(kw_args > 0)) {
3262         if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "spmvpy_csr") < 0)) __PYX_ERR(0, 105, __pyx_L3_error)
3263       }
3264     } else if (PyTuple_GET_SIZE(__pyx_args) != 6) {
3265       goto __pyx_L5_argtuple_error;
3266     } else {
3267       values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
3268       values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
3269       values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
3270       values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
3271       values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
3272       values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
3273     }
3274     __pyx_v_data = __Pyx_PyObject_to_MemoryviewSlice_dc___pyx_t_double_complex(values[0], PyBUF_WRITABLE); if (unlikely(!__pyx_v_data.memview)) __PYX_ERR(0, 105, __pyx_L3_error)
3275     __pyx_v_ind = __Pyx_PyObject_to_MemoryviewSlice_dc_int(values[1], PyBUF_WRITABLE); if (unlikely(!__pyx_v_ind.memview)) __PYX_ERR(0, 106, __pyx_L3_error)
3276     __pyx_v_ptr = __Pyx_PyObject_to_MemoryviewSlice_dc_int(values[2], PyBUF_WRITABLE); if (unlikely(!__pyx_v_ptr.memview)) __PYX_ERR(0, 106, __pyx_L3_error)
3277     __pyx_v_vec = __Pyx_PyObject_to_MemoryviewSlice_dc___pyx_t_double_complex(values[3], PyBUF_WRITABLE); if (unlikely(!__pyx_v_vec.memview)) __PYX_ERR(0, 106, __pyx_L3_error)
3278     __pyx_v_alpha = __Pyx_PyComplex_As___pyx_t_double_complex(values[4]); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 107, __pyx_L3_error)
3279     __pyx_v_out = __Pyx_PyObject_to_MemoryviewSlice_dc___pyx_t_double_complex(values[5], PyBUF_WRITABLE); if (unlikely(!__pyx_v_out.memview)) __PYX_ERR(0, 107, __pyx_L3_error)
3280   }
3281   goto __pyx_L4_argument_unpacking_done;
3282   __pyx_L5_argtuple_error:;
3283   __Pyx_RaiseArgtupleInvalid("spmvpy_csr", 1, 6, 6, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 105, __pyx_L3_error)
3284   __pyx_L3_error:;
3285   __Pyx_AddTraceback("qutip.cy.spmatfuncs.spmvpy_csr", __pyx_clineno, __pyx_lineno, __pyx_filename);
3286   __Pyx_RefNannyFinishContext();
3287   return NULL;
3288   __pyx_L4_argument_unpacking_done:;
3289   __pyx_r = __pyx_pf_5qutip_2cy_10spmatfuncs_4spmvpy_csr(__pyx_self, __pyx_v_data, __pyx_v_ind, __pyx_v_ptr, __pyx_v_vec, __pyx_v_alpha, __pyx_v_out);
3290 
3291   /* function exit code */
3292   __Pyx_RefNannyFinishContext();
3293   return __pyx_r;
3294 }
3295 
__pyx_pf_5qutip_2cy_10spmatfuncs_4spmvpy_csr(CYTHON_UNUSED PyObject * __pyx_self,__Pyx_memviewslice __pyx_v_data,__Pyx_memviewslice __pyx_v_ind,__Pyx_memviewslice __pyx_v_ptr,__Pyx_memviewslice __pyx_v_vec,__pyx_t_double_complex __pyx_v_alpha,__Pyx_memviewslice __pyx_v_out)3296 static PyObject *__pyx_pf_5qutip_2cy_10spmatfuncs_4spmvpy_csr(CYTHON_UNUSED PyObject *__pyx_self, __Pyx_memviewslice __pyx_v_data, __Pyx_memviewslice __pyx_v_ind, __Pyx_memviewslice __pyx_v_ptr, __Pyx_memviewslice __pyx_v_vec, __pyx_t_double_complex __pyx_v_alpha, __Pyx_memviewslice __pyx_v_out) {
3297   unsigned int __pyx_v_num_rows;
3298   PyObject *__pyx_r = NULL;
3299   __Pyx_RefNannyDeclarations
3300   Py_ssize_t __pyx_t_1;
3301   Py_ssize_t __pyx_t_2;
3302   Py_ssize_t __pyx_t_3;
3303   Py_ssize_t __pyx_t_4;
3304   Py_ssize_t __pyx_t_5;
3305   __Pyx_RefNannySetupContext("spmvpy_csr", 0);
3306 
3307   /* "qutip/cy/spmatfuncs.pyx":129
3308  *
3309  *     """
3310  *     cdef unsigned int num_rows = vec.shape[0]             # <<<<<<<<<<<<<<
3311  *     zspmvpy(&data[0], &ind[0], &ptr[0], &vec[0], alpha, &out[0], num_rows)
3312  *
3313  */
3314   __pyx_v_num_rows = (__pyx_v_vec.shape[0]);
3315 
3316   /* "qutip/cy/spmatfuncs.pyx":130
3317  *     """
3318  *     cdef unsigned int num_rows = vec.shape[0]
3319  *     zspmvpy(&data[0], &ind[0], &ptr[0], &vec[0], alpha, &out[0], num_rows)             # <<<<<<<<<<<<<<
3320  *
3321  *
3322  */
3323   __pyx_t_1 = 0;
3324   __pyx_t_2 = 0;
3325   __pyx_t_3 = 0;
3326   __pyx_t_4 = 0;
3327   __pyx_t_5 = 0;
3328   zspmvpy((&(*((__pyx_t_double_complex *) ( /* dim=0 */ ((char *) (((__pyx_t_double_complex *) __pyx_v_data.data) + __pyx_t_1)) )))), (&(*((int *) ( /* dim=0 */ ((char *) (((int *) __pyx_v_ind.data) + __pyx_t_2)) )))), (&(*((int *) ( /* dim=0 */ ((char *) (((int *) __pyx_v_ptr.data) + __pyx_t_3)) )))), (&(*((__pyx_t_double_complex *) ( /* dim=0 */ ((char *) (((__pyx_t_double_complex *) __pyx_v_vec.data) + __pyx_t_4)) )))), __pyx_v_alpha, (&(*((__pyx_t_double_complex *) ( /* dim=0 */ ((char *) (((__pyx_t_double_complex *) __pyx_v_out.data) + __pyx_t_5)) )))), __pyx_v_num_rows);
3329 
3330   /* "qutip/cy/spmatfuncs.pyx":105
3331  * @cython.boundscheck(False)
3332  * @cython.wraparound(False)
3333  * def spmvpy_csr(complex[::1] data,             # <<<<<<<<<<<<<<
3334  *             int[::1] ind, int[::1] ptr, complex[::1] vec,
3335  *             complex alpha, complex[::1] out):
3336  */
3337 
3338   /* function exit code */
3339   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
3340   __PYX_XDEC_MEMVIEW(&__pyx_v_data, 1);
3341   __PYX_XDEC_MEMVIEW(&__pyx_v_ind, 1);
3342   __PYX_XDEC_MEMVIEW(&__pyx_v_ptr, 1);
3343   __PYX_XDEC_MEMVIEW(&__pyx_v_vec, 1);
3344   __PYX_XDEC_MEMVIEW(&__pyx_v_out, 1);
3345   __Pyx_XGIVEREF(__pyx_r);
3346   __Pyx_RefNannyFinishContext();
3347   return __pyx_r;
3348 }
3349 
3350 /* "qutip/cy/spmatfuncs.pyx":135
3351  * @cython.boundscheck(False)
3352  * @cython.wraparound(False)
3353  * cdef inline void spmvpy(complex* data, int* ind, int* ptr,             # <<<<<<<<<<<<<<
3354  *             complex* vec,
3355  *             complex a,
3356  */
3357 
__pyx_f_5qutip_2cy_10spmatfuncs_spmvpy(__pyx_t_double_complex * __pyx_v_data,int * __pyx_v_ind,int * __pyx_v_ptr,__pyx_t_double_complex * __pyx_v_vec,__pyx_t_double_complex __pyx_v_a,__pyx_t_double_complex * __pyx_v_out,unsigned int __pyx_v_nrows)3358 static CYTHON_INLINE void __pyx_f_5qutip_2cy_10spmatfuncs_spmvpy(__pyx_t_double_complex *__pyx_v_data, int *__pyx_v_ind, int *__pyx_v_ptr, __pyx_t_double_complex *__pyx_v_vec, __pyx_t_double_complex __pyx_v_a, __pyx_t_double_complex *__pyx_v_out, unsigned int __pyx_v_nrows) {
3359   __Pyx_RefNannyDeclarations
3360   __Pyx_RefNannySetupContext("spmvpy", 0);
3361 
3362   /* "qutip/cy/spmatfuncs.pyx":141
3363  *             unsigned int nrows):
3364  *
3365  *     zspmvpy(data, ind, ptr, vec, a, out, nrows)             # <<<<<<<<<<<<<<
3366  *
3367  *
3368  */
3369   zspmvpy(__pyx_v_data, __pyx_v_ind, __pyx_v_ptr, __pyx_v_vec, __pyx_v_a, __pyx_v_out, __pyx_v_nrows);
3370 
3371   /* "qutip/cy/spmatfuncs.pyx":135
3372  * @cython.boundscheck(False)
3373  * @cython.wraparound(False)
3374  * cdef inline void spmvpy(complex* data, int* ind, int* ptr,             # <<<<<<<<<<<<<<
3375  *             complex* vec,
3376  *             complex a,
3377  */
3378 
3379   /* function exit code */
3380   __Pyx_RefNannyFinishContext();
3381 }
3382 
3383 /* "qutip/cy/spmatfuncs.pyx":146
3384  * @cython.boundscheck(False)
3385  * @cython.wraparound(False)
3386  * cdef void _spmm_c_py(complex* data, int* ind, int* ptr,             # <<<<<<<<<<<<<<
3387  *             complex* mat, complex a, complex* out,
3388  *             unsigned int sp_rows, unsigned int nrows, unsigned int ncols):
3389  */
3390 
__pyx_f_5qutip_2cy_10spmatfuncs__spmm_c_py(__pyx_t_double_complex * __pyx_v_data,int * __pyx_v_ind,int * __pyx_v_ptr,__pyx_t_double_complex * __pyx_v_mat,__pyx_t_double_complex __pyx_v_a,__pyx_t_double_complex * __pyx_v_out,unsigned int __pyx_v_sp_rows,CYTHON_UNUSED unsigned int __pyx_v_nrows,unsigned int __pyx_v_ncols)3391 static void __pyx_f_5qutip_2cy_10spmatfuncs__spmm_c_py(__pyx_t_double_complex *__pyx_v_data, int *__pyx_v_ind, int *__pyx_v_ptr, __pyx_t_double_complex *__pyx_v_mat, __pyx_t_double_complex __pyx_v_a, __pyx_t_double_complex *__pyx_v_out, unsigned int __pyx_v_sp_rows, CYTHON_UNUSED unsigned int __pyx_v_nrows, unsigned int __pyx_v_ncols) {
3392   int __pyx_v_row;
3393   int __pyx_v_col;
3394   int __pyx_v_jj;
3395   int __pyx_v_row_start;
3396   int __pyx_v_row_end;
3397   __Pyx_RefNannyDeclarations
3398   unsigned int __pyx_t_1;
3399   int __pyx_t_2;
3400   unsigned int __pyx_t_3;
3401   unsigned int __pyx_t_4;
3402   int __pyx_t_5;
3403   unsigned int __pyx_t_6;
3404   __Pyx_RefNannySetupContext("_spmm_c_py", 0);
3405 
3406   /* "qutip/cy/spmatfuncs.pyx":153
3407  *     """
3408  *     cdef int row, col, ii, jj, row_start, row_end
3409  *     for row from 0 <= row < sp_rows :             # <<<<<<<<<<<<<<
3410  *         row_start = ptr[row]
3411  *         row_end = ptr[row+1]
3412  */
3413   __pyx_t_1 = __pyx_v_sp_rows;
3414   for (__pyx_v_row = 0; __pyx_v_row < __pyx_t_1; __pyx_v_row++) {
3415 
3416     /* "qutip/cy/spmatfuncs.pyx":154
3417  *     cdef int row, col, ii, jj, row_start, row_end
3418  *     for row from 0 <= row < sp_rows :
3419  *         row_start = ptr[row]             # <<<<<<<<<<<<<<
3420  *         row_end = ptr[row+1]
3421  *         for jj from row_start <= jj < row_end:
3422  */
3423     __pyx_v_row_start = (__pyx_v_ptr[__pyx_v_row]);
3424 
3425     /* "qutip/cy/spmatfuncs.pyx":155
3426  *     for row from 0 <= row < sp_rows :
3427  *         row_start = ptr[row]
3428  *         row_end = ptr[row+1]             # <<<<<<<<<<<<<<
3429  *         for jj from row_start <= jj < row_end:
3430  *             for col in range(ncols):
3431  */
3432     __pyx_v_row_end = (__pyx_v_ptr[(__pyx_v_row + 1)]);
3433 
3434     /* "qutip/cy/spmatfuncs.pyx":156
3435  *         row_start = ptr[row]
3436  *         row_end = ptr[row+1]
3437  *         for jj from row_start <= jj < row_end:             # <<<<<<<<<<<<<<
3438  *             for col in range(ncols):
3439  *                 out[row * ncols + col] += a*data[jj]*mat[ind[jj] * ncols + col]
3440  */
3441     __pyx_t_2 = __pyx_v_row_end;
3442     for (__pyx_v_jj = __pyx_v_row_start; __pyx_v_jj < __pyx_t_2; __pyx_v_jj++) {
3443 
3444       /* "qutip/cy/spmatfuncs.pyx":157
3445  *         row_end = ptr[row+1]
3446  *         for jj from row_start <= jj < row_end:
3447  *             for col in range(ncols):             # <<<<<<<<<<<<<<
3448  *                 out[row * ncols + col] += a*data[jj]*mat[ind[jj] * ncols + col]
3449  *
3450  */
3451       __pyx_t_3 = __pyx_v_ncols;
3452       __pyx_t_4 = __pyx_t_3;
3453       for (__pyx_t_5 = 0; __pyx_t_5 < __pyx_t_4; __pyx_t_5+=1) {
3454         __pyx_v_col = __pyx_t_5;
3455 
3456         /* "qutip/cy/spmatfuncs.pyx":158
3457  *         for jj from row_start <= jj < row_end:
3458  *             for col in range(ncols):
3459  *                 out[row * ncols + col] += a*data[jj]*mat[ind[jj] * ncols + col]             # <<<<<<<<<<<<<<
3460  *
3461  *
3462  */
3463         __pyx_t_6 = ((__pyx_v_row * __pyx_v_ncols) + __pyx_v_col);
3464         (__pyx_v_out[__pyx_t_6]) = __Pyx_c_sum_double((__pyx_v_out[__pyx_t_6]), __Pyx_c_prod_double(__Pyx_c_prod_double(__pyx_v_a, (__pyx_v_data[__pyx_v_jj])), (__pyx_v_mat[(((__pyx_v_ind[__pyx_v_jj]) * __pyx_v_ncols) + __pyx_v_col)])));
3465       }
3466     }
3467   }
3468 
3469   /* "qutip/cy/spmatfuncs.pyx":146
3470  * @cython.boundscheck(False)
3471  * @cython.wraparound(False)
3472  * cdef void _spmm_c_py(complex* data, int* ind, int* ptr,             # <<<<<<<<<<<<<<
3473  *             complex* mat, complex a, complex* out,
3474  *             unsigned int sp_rows, unsigned int nrows, unsigned int ncols):
3475  */
3476 
3477   /* function exit code */
3478   __Pyx_RefNannyFinishContext();
3479 }
3480 
3481 /* "qutip/cy/spmatfuncs.pyx":161
3482  *
3483  *
3484  * cpdef void spmmpy_c(complex[::1] data, int[::1] ind, int[::1] ptr,             # <<<<<<<<<<<<<<
3485  *              complex[:,::1] M, complex a, complex[:,::1] out):
3486  *     """
3487  */
3488 
3489 static PyObject *__pyx_pw_5qutip_2cy_10spmatfuncs_7spmmpy_c(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
__pyx_f_5qutip_2cy_10spmatfuncs_spmmpy_c(__Pyx_memviewslice __pyx_v_data,__Pyx_memviewslice __pyx_v_ind,__Pyx_memviewslice __pyx_v_ptr,__Pyx_memviewslice __pyx_v_M,CYTHON_UNUSED __pyx_t_double_complex __pyx_v_a,__Pyx_memviewslice __pyx_v_out,CYTHON_UNUSED int __pyx_skip_dispatch)3490 static void __pyx_f_5qutip_2cy_10spmatfuncs_spmmpy_c(__Pyx_memviewslice __pyx_v_data, __Pyx_memviewslice __pyx_v_ind, __Pyx_memviewslice __pyx_v_ptr, __Pyx_memviewslice __pyx_v_M, CYTHON_UNUSED __pyx_t_double_complex __pyx_v_a, __Pyx_memviewslice __pyx_v_out, CYTHON_UNUSED int __pyx_skip_dispatch) {
3491   unsigned int __pyx_v_sp_rows;
3492   unsigned int __pyx_v_nrows;
3493   unsigned int __pyx_v_ncols;
3494   __Pyx_RefNannyDeclarations
3495   Py_ssize_t __pyx_t_1;
3496   int __pyx_t_2;
3497   Py_ssize_t __pyx_t_3;
3498   Py_ssize_t __pyx_t_4;
3499   Py_ssize_t __pyx_t_5;
3500   Py_ssize_t __pyx_t_6;
3501   Py_ssize_t __pyx_t_7;
3502   Py_ssize_t __pyx_t_8;
3503   int __pyx_lineno = 0;
3504   const char *__pyx_filename = NULL;
3505   int __pyx_clineno = 0;
3506   __Pyx_RefNannySetupContext("spmmpy_c", 0);
3507 
3508   /* "qutip/cy/spmatfuncs.pyx":183
3509  *
3510  *     """
3511  *     cdef unsigned int sp_rows = ptr.shape[0]-1             # <<<<<<<<<<<<<<
3512  *     cdef unsigned int nrows = M.shape[0]
3513  *     cdef unsigned int ncols = M.shape[1]
3514  */
3515   __pyx_v_sp_rows = ((__pyx_v_ptr.shape[0]) - 1);
3516 
3517   /* "qutip/cy/spmatfuncs.pyx":184
3518  *     """
3519  *     cdef unsigned int sp_rows = ptr.shape[0]-1
3520  *     cdef unsigned int nrows = M.shape[0]             # <<<<<<<<<<<<<<
3521  *     cdef unsigned int ncols = M.shape[1]
3522  *     _spmm_c_py(&data[0], &ind[0], &ptr[0], &M[0,0], 1.,
3523  */
3524   __pyx_v_nrows = (__pyx_v_M.shape[0]);
3525 
3526   /* "qutip/cy/spmatfuncs.pyx":185
3527  *     cdef unsigned int sp_rows = ptr.shape[0]-1
3528  *     cdef unsigned int nrows = M.shape[0]
3529  *     cdef unsigned int ncols = M.shape[1]             # <<<<<<<<<<<<<<
3530  *     _spmm_c_py(&data[0], &ind[0], &ptr[0], &M[0,0], 1.,
3531  *                &out[0,0], sp_rows, nrows, ncols)
3532  */
3533   __pyx_v_ncols = (__pyx_v_M.shape[1]);
3534 
3535   /* "qutip/cy/spmatfuncs.pyx":186
3536  *     cdef unsigned int nrows = M.shape[0]
3537  *     cdef unsigned int ncols = M.shape[1]
3538  *     _spmm_c_py(&data[0], &ind[0], &ptr[0], &M[0,0], 1.,             # <<<<<<<<<<<<<<
3539  *                &out[0,0], sp_rows, nrows, ncols)
3540  *
3541  */
3542   __pyx_t_1 = 0;
3543   __pyx_t_2 = -1;
3544   if (__pyx_t_1 < 0) {
3545     __pyx_t_1 += __pyx_v_data.shape[0];
3546     if (unlikely(__pyx_t_1 < 0)) __pyx_t_2 = 0;
3547   } else if (unlikely(__pyx_t_1 >= __pyx_v_data.shape[0])) __pyx_t_2 = 0;
3548   if (unlikely(__pyx_t_2 != -1)) {
3549     __Pyx_RaiseBufferIndexError(__pyx_t_2);
3550     __PYX_ERR(0, 186, __pyx_L1_error)
3551   }
3552   __pyx_t_3 = 0;
3553   __pyx_t_2 = -1;
3554   if (__pyx_t_3 < 0) {
3555     __pyx_t_3 += __pyx_v_ind.shape[0];
3556     if (unlikely(__pyx_t_3 < 0)) __pyx_t_2 = 0;
3557   } else if (unlikely(__pyx_t_3 >= __pyx_v_ind.shape[0])) __pyx_t_2 = 0;
3558   if (unlikely(__pyx_t_2 != -1)) {
3559     __Pyx_RaiseBufferIndexError(__pyx_t_2);
3560     __PYX_ERR(0, 186, __pyx_L1_error)
3561   }
3562   __pyx_t_4 = 0;
3563   __pyx_t_2 = -1;
3564   if (__pyx_t_4 < 0) {
3565     __pyx_t_4 += __pyx_v_ptr.shape[0];
3566     if (unlikely(__pyx_t_4 < 0)) __pyx_t_2 = 0;
3567   } else if (unlikely(__pyx_t_4 >= __pyx_v_ptr.shape[0])) __pyx_t_2 = 0;
3568   if (unlikely(__pyx_t_2 != -1)) {
3569     __Pyx_RaiseBufferIndexError(__pyx_t_2);
3570     __PYX_ERR(0, 186, __pyx_L1_error)
3571   }
3572   __pyx_t_5 = 0;
3573   __pyx_t_6 = 0;
3574   __pyx_t_2 = -1;
3575   if (__pyx_t_5 < 0) {
3576     __pyx_t_5 += __pyx_v_M.shape[0];
3577     if (unlikely(__pyx_t_5 < 0)) __pyx_t_2 = 0;
3578   } else if (unlikely(__pyx_t_5 >= __pyx_v_M.shape[0])) __pyx_t_2 = 0;
3579   if (__pyx_t_6 < 0) {
3580     __pyx_t_6 += __pyx_v_M.shape[1];
3581     if (unlikely(__pyx_t_6 < 0)) __pyx_t_2 = 1;
3582   } else if (unlikely(__pyx_t_6 >= __pyx_v_M.shape[1])) __pyx_t_2 = 1;
3583   if (unlikely(__pyx_t_2 != -1)) {
3584     __Pyx_RaiseBufferIndexError(__pyx_t_2);
3585     __PYX_ERR(0, 186, __pyx_L1_error)
3586   }
3587 
3588   /* "qutip/cy/spmatfuncs.pyx":187
3589  *     cdef unsigned int ncols = M.shape[1]
3590  *     _spmm_c_py(&data[0], &ind[0], &ptr[0], &M[0,0], 1.,
3591  *                &out[0,0], sp_rows, nrows, ncols)             # <<<<<<<<<<<<<<
3592  *
3593  *
3594  */
3595   __pyx_t_7 = 0;
3596   __pyx_t_8 = 0;
3597   __pyx_t_2 = -1;
3598   if (__pyx_t_7 < 0) {
3599     __pyx_t_7 += __pyx_v_out.shape[0];
3600     if (unlikely(__pyx_t_7 < 0)) __pyx_t_2 = 0;
3601   } else if (unlikely(__pyx_t_7 >= __pyx_v_out.shape[0])) __pyx_t_2 = 0;
3602   if (__pyx_t_8 < 0) {
3603     __pyx_t_8 += __pyx_v_out.shape[1];
3604     if (unlikely(__pyx_t_8 < 0)) __pyx_t_2 = 1;
3605   } else if (unlikely(__pyx_t_8 >= __pyx_v_out.shape[1])) __pyx_t_2 = 1;
3606   if (unlikely(__pyx_t_2 != -1)) {
3607     __Pyx_RaiseBufferIndexError(__pyx_t_2);
3608     __PYX_ERR(0, 187, __pyx_L1_error)
3609   }
3610 
3611   /* "qutip/cy/spmatfuncs.pyx":186
3612  *     cdef unsigned int nrows = M.shape[0]
3613  *     cdef unsigned int ncols = M.shape[1]
3614  *     _spmm_c_py(&data[0], &ind[0], &ptr[0], &M[0,0], 1.,             # <<<<<<<<<<<<<<
3615  *                &out[0,0], sp_rows, nrows, ncols)
3616  *
3617  */
3618   __pyx_f_5qutip_2cy_10spmatfuncs__spmm_c_py((&(*((__pyx_t_double_complex *) ( /* dim=0 */ ((char *) (((__pyx_t_double_complex *) __pyx_v_data.data) + __pyx_t_1)) )))), (&(*((int *) ( /* dim=0 */ ((char *) (((int *) __pyx_v_ind.data) + __pyx_t_3)) )))), (&(*((int *) ( /* dim=0 */ ((char *) (((int *) __pyx_v_ptr.data) + __pyx_t_4)) )))), (&(*((__pyx_t_double_complex *) ( /* dim=1 */ ((char *) (((__pyx_t_double_complex *) ( /* dim=0 */ (__pyx_v_M.data + __pyx_t_5 * __pyx_v_M.strides[0]) )) + __pyx_t_6)) )))), __pyx_t_double_complex_from_parts(1., 0), (&(*((__pyx_t_double_complex *) ( /* dim=1 */ ((char *) (((__pyx_t_double_complex *) ( /* dim=0 */ (__pyx_v_out.data + __pyx_t_7 * __pyx_v_out.strides[0]) )) + __pyx_t_8)) )))), __pyx_v_sp_rows, __pyx_v_nrows, __pyx_v_ncols);
3619 
3620   /* "qutip/cy/spmatfuncs.pyx":161
3621  *
3622  *
3623  * cpdef void spmmpy_c(complex[::1] data, int[::1] ind, int[::1] ptr,             # <<<<<<<<<<<<<<
3624  *              complex[:,::1] M, complex a, complex[:,::1] out):
3625  *     """
3626  */
3627 
3628   /* function exit code */
3629   goto __pyx_L0;
3630   __pyx_L1_error:;
3631   __Pyx_WriteUnraisable("qutip.cy.spmatfuncs.spmmpy_c", __pyx_clineno, __pyx_lineno, __pyx_filename, 1, 0);
3632   __pyx_L0:;
3633   __Pyx_RefNannyFinishContext();
3634 }
3635 
3636 /* Python wrapper */
3637 static PyObject *__pyx_pw_5qutip_2cy_10spmatfuncs_7spmmpy_c(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
3638 static char __pyx_doc_5qutip_2cy_10spmatfuncs_6spmmpy_c[] = "\n    Sparse matrix, c ordered dense matrix multiplication.\n    The sparse matrix must be in CSR format and have complex entries.\n\n    Parameters\n    ----------\n    data : array\n        Data for sparse matrix.\n    idx : array\n        Indices for sparse matrix data.\n    ptr : array\n        Pointers for sparse matrix data.\n    mat : array 2d\n        Dense matrix for multiplication.  Must be in c mode.\n    alpha : complex\n        Numerical coefficient for sparse matrix.\n    out: array\n        Output array. Must be in c mode.\n\n    ";
__pyx_pw_5qutip_2cy_10spmatfuncs_7spmmpy_c(PyObject * __pyx_self,PyObject * __pyx_args,PyObject * __pyx_kwds)3639 static PyObject *__pyx_pw_5qutip_2cy_10spmatfuncs_7spmmpy_c(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
3640   __Pyx_memviewslice __pyx_v_data = { 0, 0, { 0 }, { 0 }, { 0 } };
3641   __Pyx_memviewslice __pyx_v_ind = { 0, 0, { 0 }, { 0 }, { 0 } };
3642   __Pyx_memviewslice __pyx_v_ptr = { 0, 0, { 0 }, { 0 }, { 0 } };
3643   __Pyx_memviewslice __pyx_v_M = { 0, 0, { 0 }, { 0 }, { 0 } };
3644   __pyx_t_double_complex __pyx_v_a;
3645   __Pyx_memviewslice __pyx_v_out = { 0, 0, { 0 }, { 0 }, { 0 } };
3646   int __pyx_lineno = 0;
3647   const char *__pyx_filename = NULL;
3648   int __pyx_clineno = 0;
3649   PyObject *__pyx_r = 0;
3650   __Pyx_RefNannyDeclarations
3651   __Pyx_RefNannySetupContext("spmmpy_c (wrapper)", 0);
3652   {
3653     static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_data,&__pyx_n_s_ind,&__pyx_n_s_ptr,&__pyx_n_s_M,&__pyx_n_s_a,&__pyx_n_s_out,0};
3654     PyObject* values[6] = {0,0,0,0,0,0};
3655     if (unlikely(__pyx_kwds)) {
3656       Py_ssize_t kw_args;
3657       const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
3658       switch (pos_args) {
3659         case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
3660         CYTHON_FALLTHROUGH;
3661         case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
3662         CYTHON_FALLTHROUGH;
3663         case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
3664         CYTHON_FALLTHROUGH;
3665         case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
3666         CYTHON_FALLTHROUGH;
3667         case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
3668         CYTHON_FALLTHROUGH;
3669         case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
3670         CYTHON_FALLTHROUGH;
3671         case  0: break;
3672         default: goto __pyx_L5_argtuple_error;
3673       }
3674       kw_args = PyDict_Size(__pyx_kwds);
3675       switch (pos_args) {
3676         case  0:
3677         if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_data)) != 0)) kw_args--;
3678         else goto __pyx_L5_argtuple_error;
3679         CYTHON_FALLTHROUGH;
3680         case  1:
3681         if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_ind)) != 0)) kw_args--;
3682         else {
3683           __Pyx_RaiseArgtupleInvalid("spmmpy_c", 1, 6, 6, 1); __PYX_ERR(0, 161, __pyx_L3_error)
3684         }
3685         CYTHON_FALLTHROUGH;
3686         case  2:
3687         if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_ptr)) != 0)) kw_args--;
3688         else {
3689           __Pyx_RaiseArgtupleInvalid("spmmpy_c", 1, 6, 6, 2); __PYX_ERR(0, 161, __pyx_L3_error)
3690         }
3691         CYTHON_FALLTHROUGH;
3692         case  3:
3693         if (likely((values[3] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_M)) != 0)) kw_args--;
3694         else {
3695           __Pyx_RaiseArgtupleInvalid("spmmpy_c", 1, 6, 6, 3); __PYX_ERR(0, 161, __pyx_L3_error)
3696         }
3697         CYTHON_FALLTHROUGH;
3698         case  4:
3699         if (likely((values[4] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_a)) != 0)) kw_args--;
3700         else {
3701           __Pyx_RaiseArgtupleInvalid("spmmpy_c", 1, 6, 6, 4); __PYX_ERR(0, 161, __pyx_L3_error)
3702         }
3703         CYTHON_FALLTHROUGH;
3704         case  5:
3705         if (likely((values[5] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_out)) != 0)) kw_args--;
3706         else {
3707           __Pyx_RaiseArgtupleInvalid("spmmpy_c", 1, 6, 6, 5); __PYX_ERR(0, 161, __pyx_L3_error)
3708         }
3709       }
3710       if (unlikely(kw_args > 0)) {
3711         if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "spmmpy_c") < 0)) __PYX_ERR(0, 161, __pyx_L3_error)
3712       }
3713     } else if (PyTuple_GET_SIZE(__pyx_args) != 6) {
3714       goto __pyx_L5_argtuple_error;
3715     } else {
3716       values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
3717       values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
3718       values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
3719       values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
3720       values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
3721       values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
3722     }
3723     __pyx_v_data = __Pyx_PyObject_to_MemoryviewSlice_dc___pyx_t_double_complex(values[0], PyBUF_WRITABLE); if (unlikely(!__pyx_v_data.memview)) __PYX_ERR(0, 161, __pyx_L3_error)
3724     __pyx_v_ind = __Pyx_PyObject_to_MemoryviewSlice_dc_int(values[1], PyBUF_WRITABLE); if (unlikely(!__pyx_v_ind.memview)) __PYX_ERR(0, 161, __pyx_L3_error)
3725     __pyx_v_ptr = __Pyx_PyObject_to_MemoryviewSlice_dc_int(values[2], PyBUF_WRITABLE); if (unlikely(!__pyx_v_ptr.memview)) __PYX_ERR(0, 161, __pyx_L3_error)
3726     __pyx_v_M = __Pyx_PyObject_to_MemoryviewSlice_d_dc___pyx_t_double_complex(values[3], PyBUF_WRITABLE); if (unlikely(!__pyx_v_M.memview)) __PYX_ERR(0, 162, __pyx_L3_error)
3727     __pyx_v_a = __Pyx_PyComplex_As___pyx_t_double_complex(values[4]); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 162, __pyx_L3_error)
3728     __pyx_v_out = __Pyx_PyObject_to_MemoryviewSlice_d_dc___pyx_t_double_complex(values[5], PyBUF_WRITABLE); if (unlikely(!__pyx_v_out.memview)) __PYX_ERR(0, 162, __pyx_L3_error)
3729   }
3730   goto __pyx_L4_argument_unpacking_done;
3731   __pyx_L5_argtuple_error:;
3732   __Pyx_RaiseArgtupleInvalid("spmmpy_c", 1, 6, 6, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 161, __pyx_L3_error)
3733   __pyx_L3_error:;
3734   __Pyx_AddTraceback("qutip.cy.spmatfuncs.spmmpy_c", __pyx_clineno, __pyx_lineno, __pyx_filename);
3735   __Pyx_RefNannyFinishContext();
3736   return NULL;
3737   __pyx_L4_argument_unpacking_done:;
3738   __pyx_r = __pyx_pf_5qutip_2cy_10spmatfuncs_6spmmpy_c(__pyx_self, __pyx_v_data, __pyx_v_ind, __pyx_v_ptr, __pyx_v_M, __pyx_v_a, __pyx_v_out);
3739 
3740   /* function exit code */
3741   __Pyx_RefNannyFinishContext();
3742   return __pyx_r;
3743 }
3744 
__pyx_pf_5qutip_2cy_10spmatfuncs_6spmmpy_c(CYTHON_UNUSED PyObject * __pyx_self,__Pyx_memviewslice __pyx_v_data,__Pyx_memviewslice __pyx_v_ind,__Pyx_memviewslice __pyx_v_ptr,__Pyx_memviewslice __pyx_v_M,__pyx_t_double_complex __pyx_v_a,__Pyx_memviewslice __pyx_v_out)3745 static PyObject *__pyx_pf_5qutip_2cy_10spmatfuncs_6spmmpy_c(CYTHON_UNUSED PyObject *__pyx_self, __Pyx_memviewslice __pyx_v_data, __Pyx_memviewslice __pyx_v_ind, __Pyx_memviewslice __pyx_v_ptr, __Pyx_memviewslice __pyx_v_M, __pyx_t_double_complex __pyx_v_a, __Pyx_memviewslice __pyx_v_out) {
3746   PyObject *__pyx_r = NULL;
3747   __Pyx_RefNannyDeclarations
3748   PyObject *__pyx_t_1 = NULL;
3749   int __pyx_lineno = 0;
3750   const char *__pyx_filename = NULL;
3751   int __pyx_clineno = 0;
3752   __Pyx_RefNannySetupContext("spmmpy_c", 0);
3753   __Pyx_XDECREF(__pyx_r);
3754   if (unlikely(!__pyx_v_data.memview)) { __Pyx_RaiseUnboundLocalError("data"); __PYX_ERR(0, 161, __pyx_L1_error) }
3755   if (unlikely(!__pyx_v_ind.memview)) { __Pyx_RaiseUnboundLocalError("ind"); __PYX_ERR(0, 161, __pyx_L1_error) }
3756   if (unlikely(!__pyx_v_ptr.memview)) { __Pyx_RaiseUnboundLocalError("ptr"); __PYX_ERR(0, 161, __pyx_L1_error) }
3757   if (unlikely(!__pyx_v_M.memview)) { __Pyx_RaiseUnboundLocalError("M"); __PYX_ERR(0, 161, __pyx_L1_error) }
3758   if (unlikely(!__pyx_v_out.memview)) { __Pyx_RaiseUnboundLocalError("out"); __PYX_ERR(0, 161, __pyx_L1_error) }
3759   __pyx_t_1 = __Pyx_void_to_None(__pyx_f_5qutip_2cy_10spmatfuncs_spmmpy_c(__pyx_v_data, __pyx_v_ind, __pyx_v_ptr, __pyx_v_M, __pyx_v_a, __pyx_v_out, 0)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 161, __pyx_L1_error)
3760   __Pyx_GOTREF(__pyx_t_1);
3761   __pyx_r = __pyx_t_1;
3762   __pyx_t_1 = 0;
3763   goto __pyx_L0;
3764 
3765   /* function exit code */
3766   __pyx_L1_error:;
3767   __Pyx_XDECREF(__pyx_t_1);
3768   __Pyx_AddTraceback("qutip.cy.spmatfuncs.spmmpy_c", __pyx_clineno, __pyx_lineno, __pyx_filename);
3769   __pyx_r = NULL;
3770   __pyx_L0:;
3771   __PYX_XDEC_MEMVIEW(&__pyx_v_data, 1);
3772   __PYX_XDEC_MEMVIEW(&__pyx_v_ind, 1);
3773   __PYX_XDEC_MEMVIEW(&__pyx_v_ptr, 1);
3774   __PYX_XDEC_MEMVIEW(&__pyx_v_M, 1);
3775   __PYX_XDEC_MEMVIEW(&__pyx_v_out, 1);
3776   __Pyx_XGIVEREF(__pyx_r);
3777   __Pyx_RefNannyFinishContext();
3778   return __pyx_r;
3779 }
3780 
3781 /* "qutip/cy/spmatfuncs.pyx":190
3782  *
3783  *
3784  * cpdef cnp.ndarray[complex, ndim=1, mode="c"] spmmc(object sparse,             # <<<<<<<<<<<<<<
3785  *                                                    complex[:,::1] mat):
3786  *     """
3787  */
3788 
3789 static PyObject *__pyx_pw_5qutip_2cy_10spmatfuncs_9spmmc(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
__pyx_f_5qutip_2cy_10spmatfuncs_spmmc(PyObject * __pyx_v_sparse,__Pyx_memviewslice __pyx_v_mat,CYTHON_UNUSED int __pyx_skip_dispatch)3790 static PyArrayObject *__pyx_f_5qutip_2cy_10spmatfuncs_spmmc(PyObject *__pyx_v_sparse, __Pyx_memviewslice __pyx_v_mat, CYTHON_UNUSED int __pyx_skip_dispatch) {
3791   unsigned int __pyx_v_sp_rows;
3792   unsigned int __pyx_v_ncols;
3793   PyArrayObject *__pyx_v_out = 0;
3794   __Pyx_LocalBuf_ND __pyx_pybuffernd_out;
3795   __Pyx_Buffer __pyx_pybuffer_out;
3796   PyArrayObject *__pyx_r = NULL;
3797   __Pyx_RefNannyDeclarations
3798   PyObject *__pyx_t_1 = NULL;
3799   PyObject *__pyx_t_2 = NULL;
3800   unsigned int __pyx_t_3;
3801   PyObject *__pyx_t_4 = NULL;
3802   PyObject *__pyx_t_5 = NULL;
3803   PyArrayObject *__pyx_t_6 = NULL;
3804   __Pyx_memviewslice __pyx_t_7 = { 0, 0, { 0 }, { 0 }, { 0 } };
3805   __Pyx_memviewslice __pyx_t_8 = { 0, 0, { 0 }, { 0 }, { 0 } };
3806   __Pyx_memviewslice __pyx_t_9 = { 0, 0, { 0 }, { 0 }, { 0 } };
3807   __Pyx_memviewslice __pyx_t_10 = { 0, 0, { 0 }, { 0 }, { 0 } };
3808   int __pyx_lineno = 0;
3809   const char *__pyx_filename = NULL;
3810   int __pyx_clineno = 0;
3811   __Pyx_RefNannySetupContext("spmmc", 0);
3812   __pyx_pybuffer_out.pybuffer.buf = NULL;
3813   __pyx_pybuffer_out.refcount = 0;
3814   __pyx_pybuffernd_out.data = NULL;
3815   __pyx_pybuffernd_out.rcbuffer = &__pyx_pybuffer_out;
3816 
3817   /* "qutip/cy/spmatfuncs.pyx":207
3818  *          Keep input ordering
3819  *     """
3820  *     cdef unsigned int sp_rows = sparse.indptr.shape[0]-1             # <<<<<<<<<<<<<<
3821  *     cdef unsigned int ncols = mat.shape[1]
3822  *     cdef cnp.ndarray[complex, ndim=2, mode="c"] out = \
3823  */
3824   __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_sparse, __pyx_n_s_indptr); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 207, __pyx_L1_error)
3825   __Pyx_GOTREF(__pyx_t_1);
3826   __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_shape); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 207, __pyx_L1_error)
3827   __Pyx_GOTREF(__pyx_t_2);
3828   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
3829   __pyx_t_1 = __Pyx_GetItemInt(__pyx_t_2, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 207, __pyx_L1_error)
3830   __Pyx_GOTREF(__pyx_t_1);
3831   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
3832   __pyx_t_2 = __Pyx_PyInt_SubtractObjC(__pyx_t_1, __pyx_int_1, 1, 0, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 207, __pyx_L1_error)
3833   __Pyx_GOTREF(__pyx_t_2);
3834   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
3835   __pyx_t_3 = __Pyx_PyInt_As_unsigned_int(__pyx_t_2); if (unlikely((__pyx_t_3 == (unsigned int)-1) && PyErr_Occurred())) __PYX_ERR(0, 207, __pyx_L1_error)
3836   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
3837   __pyx_v_sp_rows = __pyx_t_3;
3838 
3839   /* "qutip/cy/spmatfuncs.pyx":208
3840  *     """
3841  *     cdef unsigned int sp_rows = sparse.indptr.shape[0]-1
3842  *     cdef unsigned int ncols = mat.shape[1]             # <<<<<<<<<<<<<<
3843  *     cdef cnp.ndarray[complex, ndim=2, mode="c"] out = \
3844  *                      np.zeros((sp_rows, ncols), dtype=complex)
3845  */
3846   __pyx_v_ncols = (__pyx_v_mat.shape[1]);
3847 
3848   /* "qutip/cy/spmatfuncs.pyx":210
3849  *     cdef unsigned int ncols = mat.shape[1]
3850  *     cdef cnp.ndarray[complex, ndim=2, mode="c"] out = \
3851  *                      np.zeros((sp_rows, ncols), dtype=complex)             # <<<<<<<<<<<<<<
3852  *     spmmpy_c(sparse.data, sparse.indices, sparse.indptr,
3853  *              mat, 1., out)
3854  */
3855   __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_np); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 210, __pyx_L1_error)
3856   __Pyx_GOTREF(__pyx_t_2);
3857   __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_zeros); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 210, __pyx_L1_error)
3858   __Pyx_GOTREF(__pyx_t_1);
3859   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
3860   __pyx_t_2 = __Pyx_PyInt_From_unsigned_int(__pyx_v_sp_rows); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 210, __pyx_L1_error)
3861   __Pyx_GOTREF(__pyx_t_2);
3862   __pyx_t_4 = __Pyx_PyInt_From_unsigned_int(__pyx_v_ncols); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 210, __pyx_L1_error)
3863   __Pyx_GOTREF(__pyx_t_4);
3864   __pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 210, __pyx_L1_error)
3865   __Pyx_GOTREF(__pyx_t_5);
3866   __Pyx_GIVEREF(__pyx_t_2);
3867   PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_2);
3868   __Pyx_GIVEREF(__pyx_t_4);
3869   PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_t_4);
3870   __pyx_t_2 = 0;
3871   __pyx_t_4 = 0;
3872   __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 210, __pyx_L1_error)
3873   __Pyx_GOTREF(__pyx_t_4);
3874   __Pyx_GIVEREF(__pyx_t_5);
3875   PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_5);
3876   __pyx_t_5 = 0;
3877   __pyx_t_5 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 210, __pyx_L1_error)
3878   __Pyx_GOTREF(__pyx_t_5);
3879   if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_dtype, ((PyObject *)(&PyComplex_Type))) < 0) __PYX_ERR(0, 210, __pyx_L1_error)
3880   __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_4, __pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 210, __pyx_L1_error)
3881   __Pyx_GOTREF(__pyx_t_2);
3882   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
3883   __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
3884   __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
3885   if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 210, __pyx_L1_error)
3886   __pyx_t_6 = ((PyArrayObject *)__pyx_t_2);
3887   {
3888     __Pyx_BufFmt_StackElem __pyx_stack[1];
3889     if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_out.rcbuffer->pybuffer, (PyObject*)__pyx_t_6, &__Pyx_TypeInfo___pyx_t_double_complex, PyBUF_FORMAT| PyBUF_C_CONTIGUOUS, 2, 0, __pyx_stack) == -1)) {
3890       __pyx_v_out = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_pybuffernd_out.rcbuffer->pybuffer.buf = NULL;
3891       __PYX_ERR(0, 209, __pyx_L1_error)
3892     } else {__pyx_pybuffernd_out.diminfo[0].strides = __pyx_pybuffernd_out.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_out.diminfo[0].shape = __pyx_pybuffernd_out.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_out.diminfo[1].strides = __pyx_pybuffernd_out.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_out.diminfo[1].shape = __pyx_pybuffernd_out.rcbuffer->pybuffer.shape[1];
3893     }
3894   }
3895   __pyx_t_6 = 0;
3896   __pyx_v_out = ((PyArrayObject *)__pyx_t_2);
3897   __pyx_t_2 = 0;
3898 
3899   /* "qutip/cy/spmatfuncs.pyx":211
3900  *     cdef cnp.ndarray[complex, ndim=2, mode="c"] out = \
3901  *                      np.zeros((sp_rows, ncols), dtype=complex)
3902  *     spmmpy_c(sparse.data, sparse.indices, sparse.indptr,             # <<<<<<<<<<<<<<
3903  *              mat, 1., out)
3904  *     return out
3905  */
3906   __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_sparse, __pyx_n_s_data); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 211, __pyx_L1_error)
3907   __Pyx_GOTREF(__pyx_t_2);
3908   __pyx_t_7 = __Pyx_PyObject_to_MemoryviewSlice_dc___pyx_t_double_complex(__pyx_t_2, PyBUF_WRITABLE); if (unlikely(!__pyx_t_7.memview)) __PYX_ERR(0, 211, __pyx_L1_error)
3909   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
3910   __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_sparse, __pyx_n_s_indices); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 211, __pyx_L1_error)
3911   __Pyx_GOTREF(__pyx_t_2);
3912   __pyx_t_8 = __Pyx_PyObject_to_MemoryviewSlice_dc_int(__pyx_t_2, PyBUF_WRITABLE); if (unlikely(!__pyx_t_8.memview)) __PYX_ERR(0, 211, __pyx_L1_error)
3913   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
3914   __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_sparse, __pyx_n_s_indptr); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 211, __pyx_L1_error)
3915   __Pyx_GOTREF(__pyx_t_2);
3916   __pyx_t_9 = __Pyx_PyObject_to_MemoryviewSlice_dc_int(__pyx_t_2, PyBUF_WRITABLE); if (unlikely(!__pyx_t_9.memview)) __PYX_ERR(0, 211, __pyx_L1_error)
3917   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
3918 
3919   /* "qutip/cy/spmatfuncs.pyx":212
3920  *                      np.zeros((sp_rows, ncols), dtype=complex)
3921  *     spmmpy_c(sparse.data, sparse.indices, sparse.indptr,
3922  *              mat, 1., out)             # <<<<<<<<<<<<<<
3923  *     return out
3924  *
3925  */
3926   __pyx_t_10 = __Pyx_PyObject_to_MemoryviewSlice_d_dc___pyx_t_double_complex(((PyObject *)__pyx_v_out), PyBUF_WRITABLE); if (unlikely(!__pyx_t_10.memview)) __PYX_ERR(0, 212, __pyx_L1_error)
3927 
3928   /* "qutip/cy/spmatfuncs.pyx":211
3929  *     cdef cnp.ndarray[complex, ndim=2, mode="c"] out = \
3930  *                      np.zeros((sp_rows, ncols), dtype=complex)
3931  *     spmmpy_c(sparse.data, sparse.indices, sparse.indptr,             # <<<<<<<<<<<<<<
3932  *              mat, 1., out)
3933  *     return out
3934  */
3935   __pyx_f_5qutip_2cy_10spmatfuncs_spmmpy_c(__pyx_t_7, __pyx_t_8, __pyx_t_9, __pyx_v_mat, __pyx_t_double_complex_from_parts(1., 0), __pyx_t_10, 0);
3936   __PYX_XDEC_MEMVIEW(&__pyx_t_7, 1);
3937   __pyx_t_7.memview = NULL;
3938   __pyx_t_7.data = NULL;
3939   __PYX_XDEC_MEMVIEW(&__pyx_t_8, 1);
3940   __pyx_t_8.memview = NULL;
3941   __pyx_t_8.data = NULL;
3942   __PYX_XDEC_MEMVIEW(&__pyx_t_9, 1);
3943   __pyx_t_9.memview = NULL;
3944   __pyx_t_9.data = NULL;
3945   __PYX_XDEC_MEMVIEW(&__pyx_t_10, 1);
3946   __pyx_t_10.memview = NULL;
3947   __pyx_t_10.data = NULL;
3948 
3949   /* "qutip/cy/spmatfuncs.pyx":213
3950  *     spmmpy_c(sparse.data, sparse.indices, sparse.indptr,
3951  *              mat, 1., out)
3952  *     return out             # <<<<<<<<<<<<<<
3953  *
3954  *
3955  */
3956   __Pyx_XDECREF(((PyObject *)__pyx_r));
3957   __Pyx_INCREF(((PyObject *)__pyx_v_out));
3958   __pyx_r = ((PyArrayObject *)__pyx_v_out);
3959   goto __pyx_L0;
3960 
3961   /* "qutip/cy/spmatfuncs.pyx":190
3962  *
3963  *
3964  * cpdef cnp.ndarray[complex, ndim=1, mode="c"] spmmc(object sparse,             # <<<<<<<<<<<<<<
3965  *                                                    complex[:,::1] mat):
3966  *     """
3967  */
3968 
3969   /* function exit code */
3970   __pyx_L1_error:;
3971   __Pyx_XDECREF(__pyx_t_1);
3972   __Pyx_XDECREF(__pyx_t_2);
3973   __Pyx_XDECREF(__pyx_t_4);
3974   __Pyx_XDECREF(__pyx_t_5);
3975   __PYX_XDEC_MEMVIEW(&__pyx_t_7, 1);
3976   __PYX_XDEC_MEMVIEW(&__pyx_t_8, 1);
3977   __PYX_XDEC_MEMVIEW(&__pyx_t_9, 1);
3978   __PYX_XDEC_MEMVIEW(&__pyx_t_10, 1);
3979   { PyObject *__pyx_type, *__pyx_value, *__pyx_tb;
3980     __Pyx_PyThreadState_declare
3981     __Pyx_PyThreadState_assign
3982     __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb);
3983     __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_out.rcbuffer->pybuffer);
3984   __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}
3985   __Pyx_AddTraceback("qutip.cy.spmatfuncs.spmmc", __pyx_clineno, __pyx_lineno, __pyx_filename);
3986   __pyx_r = 0;
3987   goto __pyx_L2;
3988   __pyx_L0:;
3989   __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_out.rcbuffer->pybuffer);
3990   __pyx_L2:;
3991   __Pyx_XDECREF((PyObject *)__pyx_v_out);
3992   __Pyx_XGIVEREF((PyObject *)__pyx_r);
3993   __Pyx_RefNannyFinishContext();
3994   return __pyx_r;
3995 }
3996 
3997 /* Python wrapper */
3998 static PyObject *__pyx_pw_5qutip_2cy_10spmatfuncs_9spmmc(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
3999 static char __pyx_doc_5qutip_2cy_10spmatfuncs_8spmmc[] = "\n    Sparse matrix, c ordered dense matrix multiplication.\n    The sparse matrix must be in CSR format and have complex entries.\n\n    Parameters\n    ----------\n    sparse : csr matrix\n    mat : array 2d\n        Dense matrix for multiplication. Must be in c mode.\n\n    Returns\n    -------\n    out : array\n         Keep input ordering\n    ";
__pyx_pw_5qutip_2cy_10spmatfuncs_9spmmc(PyObject * __pyx_self,PyObject * __pyx_args,PyObject * __pyx_kwds)4000 static PyObject *__pyx_pw_5qutip_2cy_10spmatfuncs_9spmmc(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
4001   PyObject *__pyx_v_sparse = 0;
4002   __Pyx_memviewslice __pyx_v_mat = { 0, 0, { 0 }, { 0 }, { 0 } };
4003   int __pyx_lineno = 0;
4004   const char *__pyx_filename = NULL;
4005   int __pyx_clineno = 0;
4006   PyObject *__pyx_r = 0;
4007   __Pyx_RefNannyDeclarations
4008   __Pyx_RefNannySetupContext("spmmc (wrapper)", 0);
4009   {
4010     static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_sparse,&__pyx_n_s_mat,0};
4011     PyObject* values[2] = {0,0};
4012     if (unlikely(__pyx_kwds)) {
4013       Py_ssize_t kw_args;
4014       const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
4015       switch (pos_args) {
4016         case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
4017         CYTHON_FALLTHROUGH;
4018         case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
4019         CYTHON_FALLTHROUGH;
4020         case  0: break;
4021         default: goto __pyx_L5_argtuple_error;
4022       }
4023       kw_args = PyDict_Size(__pyx_kwds);
4024       switch (pos_args) {
4025         case  0:
4026         if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_sparse)) != 0)) kw_args--;
4027         else goto __pyx_L5_argtuple_error;
4028         CYTHON_FALLTHROUGH;
4029         case  1:
4030         if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_mat)) != 0)) kw_args--;
4031         else {
4032           __Pyx_RaiseArgtupleInvalid("spmmc", 1, 2, 2, 1); __PYX_ERR(0, 190, __pyx_L3_error)
4033         }
4034       }
4035       if (unlikely(kw_args > 0)) {
4036         if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "spmmc") < 0)) __PYX_ERR(0, 190, __pyx_L3_error)
4037       }
4038     } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
4039       goto __pyx_L5_argtuple_error;
4040     } else {
4041       values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
4042       values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
4043     }
4044     __pyx_v_sparse = values[0];
4045     __pyx_v_mat = __Pyx_PyObject_to_MemoryviewSlice_d_dc___pyx_t_double_complex(values[1], PyBUF_WRITABLE); if (unlikely(!__pyx_v_mat.memview)) __PYX_ERR(0, 191, __pyx_L3_error)
4046   }
4047   goto __pyx_L4_argument_unpacking_done;
4048   __pyx_L5_argtuple_error:;
4049   __Pyx_RaiseArgtupleInvalid("spmmc", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 190, __pyx_L3_error)
4050   __pyx_L3_error:;
4051   __Pyx_AddTraceback("qutip.cy.spmatfuncs.spmmc", __pyx_clineno, __pyx_lineno, __pyx_filename);
4052   __Pyx_RefNannyFinishContext();
4053   return NULL;
4054   __pyx_L4_argument_unpacking_done:;
4055   __pyx_r = __pyx_pf_5qutip_2cy_10spmatfuncs_8spmmc(__pyx_self, __pyx_v_sparse, __pyx_v_mat);
4056 
4057   /* function exit code */
4058   __Pyx_RefNannyFinishContext();
4059   return __pyx_r;
4060 }
4061 
__pyx_pf_5qutip_2cy_10spmatfuncs_8spmmc(CYTHON_UNUSED PyObject * __pyx_self,PyObject * __pyx_v_sparse,__Pyx_memviewslice __pyx_v_mat)4062 static PyObject *__pyx_pf_5qutip_2cy_10spmatfuncs_8spmmc(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_sparse, __Pyx_memviewslice __pyx_v_mat) {
4063   PyObject *__pyx_r = NULL;
4064   __Pyx_RefNannyDeclarations
4065   PyObject *__pyx_t_1 = NULL;
4066   int __pyx_lineno = 0;
4067   const char *__pyx_filename = NULL;
4068   int __pyx_clineno = 0;
4069   __Pyx_RefNannySetupContext("spmmc", 0);
4070   __Pyx_XDECREF(__pyx_r);
4071   if (unlikely(!__pyx_v_mat.memview)) { __Pyx_RaiseUnboundLocalError("mat"); __PYX_ERR(0, 190, __pyx_L1_error) }
4072   __pyx_t_1 = ((PyObject *)__pyx_f_5qutip_2cy_10spmatfuncs_spmmc(__pyx_v_sparse, __pyx_v_mat, 0)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 190, __pyx_L1_error)
4073   __Pyx_GOTREF(__pyx_t_1);
4074   __pyx_r = __pyx_t_1;
4075   __pyx_t_1 = 0;
4076   goto __pyx_L0;
4077 
4078   /* function exit code */
4079   __pyx_L1_error:;
4080   __Pyx_XDECREF(__pyx_t_1);
4081   __Pyx_AddTraceback("qutip.cy.spmatfuncs.spmmc", __pyx_clineno, __pyx_lineno, __pyx_filename);
4082   __pyx_r = NULL;
4083   __pyx_L0:;
4084   __PYX_XDEC_MEMVIEW(&__pyx_v_mat, 1);
4085   __Pyx_XGIVEREF(__pyx_r);
4086   __Pyx_RefNannyFinishContext();
4087   return __pyx_r;
4088 }
4089 
4090 /* "qutip/cy/spmatfuncs.pyx":218
4091  * @cython.boundscheck(False)
4092  * @cython.wraparound(False)
4093  * cdef void _spmm_f_py(complex* data, int* ind, int* ptr,             # <<<<<<<<<<<<<<
4094  *             complex* mat, complex a, complex* out,
4095  *             unsigned int sp_rows, unsigned int nrows, unsigned int ncols):
4096  */
4097 
__pyx_f_5qutip_2cy_10spmatfuncs__spmm_f_py(__pyx_t_double_complex * __pyx_v_data,int * __pyx_v_ind,int * __pyx_v_ptr,__pyx_t_double_complex * __pyx_v_mat,__pyx_t_double_complex __pyx_v_a,__pyx_t_double_complex * __pyx_v_out,unsigned int __pyx_v_sp_rows,unsigned int __pyx_v_nrows,unsigned int __pyx_v_ncols)4098 static void __pyx_f_5qutip_2cy_10spmatfuncs__spmm_f_py(__pyx_t_double_complex *__pyx_v_data, int *__pyx_v_ind, int *__pyx_v_ptr, __pyx_t_double_complex *__pyx_v_mat, __pyx_t_double_complex __pyx_v_a, __pyx_t_double_complex *__pyx_v_out, unsigned int __pyx_v_sp_rows, unsigned int __pyx_v_nrows, unsigned int __pyx_v_ncols) {
4099   int __pyx_v_col;
4100   __Pyx_RefNannyDeclarations
4101   unsigned int __pyx_t_1;
4102   unsigned int __pyx_t_2;
4103   int __pyx_t_3;
4104   __Pyx_RefNannySetupContext("_spmm_f_py", 0);
4105 
4106   /* "qutip/cy/spmatfuncs.pyx":225
4107  *     """
4108  *     cdef int col
4109  *     for col in range(ncols):             # <<<<<<<<<<<<<<
4110  *         spmvpy(data, ind, ptr, mat+nrows*col, a, out+sp_rows*col, sp_rows)
4111  *
4112  */
4113   __pyx_t_1 = __pyx_v_ncols;
4114   __pyx_t_2 = __pyx_t_1;
4115   for (__pyx_t_3 = 0; __pyx_t_3 < __pyx_t_2; __pyx_t_3+=1) {
4116     __pyx_v_col = __pyx_t_3;
4117 
4118     /* "qutip/cy/spmatfuncs.pyx":226
4119  *     cdef int col
4120  *     for col in range(ncols):
4121  *         spmvpy(data, ind, ptr, mat+nrows*col, a, out+sp_rows*col, sp_rows)             # <<<<<<<<<<<<<<
4122  *
4123  *
4124  */
4125     __pyx_f_5qutip_2cy_10spmatfuncs_spmvpy(__pyx_v_data, __pyx_v_ind, __pyx_v_ptr, (__pyx_v_mat + (__pyx_v_nrows * __pyx_v_col)), __pyx_v_a, (__pyx_v_out + (__pyx_v_sp_rows * __pyx_v_col)), __pyx_v_sp_rows);
4126   }
4127 
4128   /* "qutip/cy/spmatfuncs.pyx":218
4129  * @cython.boundscheck(False)
4130  * @cython.wraparound(False)
4131  * cdef void _spmm_f_py(complex* data, int* ind, int* ptr,             # <<<<<<<<<<<<<<
4132  *             complex* mat, complex a, complex* out,
4133  *             unsigned int sp_rows, unsigned int nrows, unsigned int ncols):
4134  */
4135 
4136   /* function exit code */
4137   __Pyx_RefNannyFinishContext();
4138 }
4139 
4140 /* "qutip/cy/spmatfuncs.pyx":229
4141  *
4142  *
4143  * cpdef void spmmpy_f(complex[::1] data, int[::1] ind, int[::1] ptr,             # <<<<<<<<<<<<<<
4144  *          complex[::1,:] mat, complex a, complex[::1,:] out):
4145  *     """
4146  */
4147 
4148 static PyObject *__pyx_pw_5qutip_2cy_10spmatfuncs_11spmmpy_f(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
__pyx_f_5qutip_2cy_10spmatfuncs_spmmpy_f(__Pyx_memviewslice __pyx_v_data,__Pyx_memviewslice __pyx_v_ind,__Pyx_memviewslice __pyx_v_ptr,__Pyx_memviewslice __pyx_v_mat,CYTHON_UNUSED __pyx_t_double_complex __pyx_v_a,__Pyx_memviewslice __pyx_v_out,CYTHON_UNUSED int __pyx_skip_dispatch)4149 static void __pyx_f_5qutip_2cy_10spmatfuncs_spmmpy_f(__Pyx_memviewslice __pyx_v_data, __Pyx_memviewslice __pyx_v_ind, __Pyx_memviewslice __pyx_v_ptr, __Pyx_memviewslice __pyx_v_mat, CYTHON_UNUSED __pyx_t_double_complex __pyx_v_a, __Pyx_memviewslice __pyx_v_out, CYTHON_UNUSED int __pyx_skip_dispatch) {
4150   unsigned int __pyx_v_sp_rows;
4151   unsigned int __pyx_v_nrows;
4152   unsigned int __pyx_v_ncols;
4153   __Pyx_RefNannyDeclarations
4154   Py_ssize_t __pyx_t_1;
4155   int __pyx_t_2;
4156   Py_ssize_t __pyx_t_3;
4157   Py_ssize_t __pyx_t_4;
4158   Py_ssize_t __pyx_t_5;
4159   Py_ssize_t __pyx_t_6;
4160   Py_ssize_t __pyx_t_7;
4161   Py_ssize_t __pyx_t_8;
4162   int __pyx_lineno = 0;
4163   const char *__pyx_filename = NULL;
4164   int __pyx_clineno = 0;
4165   __Pyx_RefNannySetupContext("spmmpy_f", 0);
4166 
4167   /* "qutip/cy/spmatfuncs.pyx":251
4168  *
4169  *     """
4170  *     cdef unsigned int sp_rows = ptr.shape[0]-1             # <<<<<<<<<<<<<<
4171  *     cdef unsigned int nrows = mat.shape[0]
4172  *     cdef unsigned int ncols = mat.shape[1]
4173  */
4174   __pyx_v_sp_rows = ((__pyx_v_ptr.shape[0]) - 1);
4175 
4176   /* "qutip/cy/spmatfuncs.pyx":252
4177  *     """
4178  *     cdef unsigned int sp_rows = ptr.shape[0]-1
4179  *     cdef unsigned int nrows = mat.shape[0]             # <<<<<<<<<<<<<<
4180  *     cdef unsigned int ncols = mat.shape[1]
4181  *     _spmm_f_py(&data[0], &ind[0], &ptr[0], &mat[0,0], 1.,
4182  */
4183   __pyx_v_nrows = (__pyx_v_mat.shape[0]);
4184 
4185   /* "qutip/cy/spmatfuncs.pyx":253
4186  *     cdef unsigned int sp_rows = ptr.shape[0]-1
4187  *     cdef unsigned int nrows = mat.shape[0]
4188  *     cdef unsigned int ncols = mat.shape[1]             # <<<<<<<<<<<<<<
4189  *     _spmm_f_py(&data[0], &ind[0], &ptr[0], &mat[0,0], 1.,
4190  *                &out[0,0], sp_rows, nrows, ncols)
4191  */
4192   __pyx_v_ncols = (__pyx_v_mat.shape[1]);
4193 
4194   /* "qutip/cy/spmatfuncs.pyx":254
4195  *     cdef unsigned int nrows = mat.shape[0]
4196  *     cdef unsigned int ncols = mat.shape[1]
4197  *     _spmm_f_py(&data[0], &ind[0], &ptr[0], &mat[0,0], 1.,             # <<<<<<<<<<<<<<
4198  *                &out[0,0], sp_rows, nrows, ncols)
4199  *
4200  */
4201   __pyx_t_1 = 0;
4202   __pyx_t_2 = -1;
4203   if (__pyx_t_1 < 0) {
4204     __pyx_t_1 += __pyx_v_data.shape[0];
4205     if (unlikely(__pyx_t_1 < 0)) __pyx_t_2 = 0;
4206   } else if (unlikely(__pyx_t_1 >= __pyx_v_data.shape[0])) __pyx_t_2 = 0;
4207   if (unlikely(__pyx_t_2 != -1)) {
4208     __Pyx_RaiseBufferIndexError(__pyx_t_2);
4209     __PYX_ERR(0, 254, __pyx_L1_error)
4210   }
4211   __pyx_t_3 = 0;
4212   __pyx_t_2 = -1;
4213   if (__pyx_t_3 < 0) {
4214     __pyx_t_3 += __pyx_v_ind.shape[0];
4215     if (unlikely(__pyx_t_3 < 0)) __pyx_t_2 = 0;
4216   } else if (unlikely(__pyx_t_3 >= __pyx_v_ind.shape[0])) __pyx_t_2 = 0;
4217   if (unlikely(__pyx_t_2 != -1)) {
4218     __Pyx_RaiseBufferIndexError(__pyx_t_2);
4219     __PYX_ERR(0, 254, __pyx_L1_error)
4220   }
4221   __pyx_t_4 = 0;
4222   __pyx_t_2 = -1;
4223   if (__pyx_t_4 < 0) {
4224     __pyx_t_4 += __pyx_v_ptr.shape[0];
4225     if (unlikely(__pyx_t_4 < 0)) __pyx_t_2 = 0;
4226   } else if (unlikely(__pyx_t_4 >= __pyx_v_ptr.shape[0])) __pyx_t_2 = 0;
4227   if (unlikely(__pyx_t_2 != -1)) {
4228     __Pyx_RaiseBufferIndexError(__pyx_t_2);
4229     __PYX_ERR(0, 254, __pyx_L1_error)
4230   }
4231   __pyx_t_5 = 0;
4232   __pyx_t_6 = 0;
4233   __pyx_t_2 = -1;
4234   if (__pyx_t_5 < 0) {
4235     __pyx_t_5 += __pyx_v_mat.shape[0];
4236     if (unlikely(__pyx_t_5 < 0)) __pyx_t_2 = 0;
4237   } else if (unlikely(__pyx_t_5 >= __pyx_v_mat.shape[0])) __pyx_t_2 = 0;
4238   if (__pyx_t_6 < 0) {
4239     __pyx_t_6 += __pyx_v_mat.shape[1];
4240     if (unlikely(__pyx_t_6 < 0)) __pyx_t_2 = 1;
4241   } else if (unlikely(__pyx_t_6 >= __pyx_v_mat.shape[1])) __pyx_t_2 = 1;
4242   if (unlikely(__pyx_t_2 != -1)) {
4243     __Pyx_RaiseBufferIndexError(__pyx_t_2);
4244     __PYX_ERR(0, 254, __pyx_L1_error)
4245   }
4246 
4247   /* "qutip/cy/spmatfuncs.pyx":255
4248  *     cdef unsigned int ncols = mat.shape[1]
4249  *     _spmm_f_py(&data[0], &ind[0], &ptr[0], &mat[0,0], 1.,
4250  *                &out[0,0], sp_rows, nrows, ncols)             # <<<<<<<<<<<<<<
4251  *
4252  *
4253  */
4254   __pyx_t_7 = 0;
4255   __pyx_t_8 = 0;
4256   __pyx_t_2 = -1;
4257   if (__pyx_t_7 < 0) {
4258     __pyx_t_7 += __pyx_v_out.shape[0];
4259     if (unlikely(__pyx_t_7 < 0)) __pyx_t_2 = 0;
4260   } else if (unlikely(__pyx_t_7 >= __pyx_v_out.shape[0])) __pyx_t_2 = 0;
4261   if (__pyx_t_8 < 0) {
4262     __pyx_t_8 += __pyx_v_out.shape[1];
4263     if (unlikely(__pyx_t_8 < 0)) __pyx_t_2 = 1;
4264   } else if (unlikely(__pyx_t_8 >= __pyx_v_out.shape[1])) __pyx_t_2 = 1;
4265   if (unlikely(__pyx_t_2 != -1)) {
4266     __Pyx_RaiseBufferIndexError(__pyx_t_2);
4267     __PYX_ERR(0, 255, __pyx_L1_error)
4268   }
4269 
4270   /* "qutip/cy/spmatfuncs.pyx":254
4271  *     cdef unsigned int nrows = mat.shape[0]
4272  *     cdef unsigned int ncols = mat.shape[1]
4273  *     _spmm_f_py(&data[0], &ind[0], &ptr[0], &mat[0,0], 1.,             # <<<<<<<<<<<<<<
4274  *                &out[0,0], sp_rows, nrows, ncols)
4275  *
4276  */
4277   __pyx_f_5qutip_2cy_10spmatfuncs__spmm_f_py((&(*((__pyx_t_double_complex *) ( /* dim=0 */ ((char *) (((__pyx_t_double_complex *) __pyx_v_data.data) + __pyx_t_1)) )))), (&(*((int *) ( /* dim=0 */ ((char *) (((int *) __pyx_v_ind.data) + __pyx_t_3)) )))), (&(*((int *) ( /* dim=0 */ ((char *) (((int *) __pyx_v_ptr.data) + __pyx_t_4)) )))), (&(*((__pyx_t_double_complex *) ( /* dim=1 */ (( /* dim=0 */ ((char *) (((__pyx_t_double_complex *) __pyx_v_mat.data) + __pyx_t_5)) ) + __pyx_t_6 * __pyx_v_mat.strides[1]) )))), __pyx_t_double_complex_from_parts(1., 0), (&(*((__pyx_t_double_complex *) ( /* dim=1 */ (( /* dim=0 */ ((char *) (((__pyx_t_double_complex *) __pyx_v_out.data) + __pyx_t_7)) ) + __pyx_t_8 * __pyx_v_out.strides[1]) )))), __pyx_v_sp_rows, __pyx_v_nrows, __pyx_v_ncols);
4278 
4279   /* "qutip/cy/spmatfuncs.pyx":229
4280  *
4281  *
4282  * cpdef void spmmpy_f(complex[::1] data, int[::1] ind, int[::1] ptr,             # <<<<<<<<<<<<<<
4283  *          complex[::1,:] mat, complex a, complex[::1,:] out):
4284  *     """
4285  */
4286 
4287   /* function exit code */
4288   goto __pyx_L0;
4289   __pyx_L1_error:;
4290   __Pyx_WriteUnraisable("qutip.cy.spmatfuncs.spmmpy_f", __pyx_clineno, __pyx_lineno, __pyx_filename, 1, 0);
4291   __pyx_L0:;
4292   __Pyx_RefNannyFinishContext();
4293 }
4294 
4295 /* Python wrapper */
4296 static PyObject *__pyx_pw_5qutip_2cy_10spmatfuncs_11spmmpy_f(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
4297 static char __pyx_doc_5qutip_2cy_10spmatfuncs_10spmmpy_f[] = "\n    Sparse matrix, fortran ordered dense matrix multiplication.\n    The sparse matrix must be in CSR format and have complex entries.\n\n    Parameters\n    ----------\n    data : array\n        Data for sparse matrix.\n    idx : array\n        Indices for sparse matrix data.\n    ptr : array\n        Pointers for sparse matrix data.\n    mat : array 2d\n        Dense matrix for multiplication.  Must be in fortran mode.\n    alpha : complex\n        Numerical coefficient for sparse matrix.\n    out: array\n        Output array. Must be in fortran mode.\n\n    ";
__pyx_pw_5qutip_2cy_10spmatfuncs_11spmmpy_f(PyObject * __pyx_self,PyObject * __pyx_args,PyObject * __pyx_kwds)4298 static PyObject *__pyx_pw_5qutip_2cy_10spmatfuncs_11spmmpy_f(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
4299   __Pyx_memviewslice __pyx_v_data = { 0, 0, { 0 }, { 0 }, { 0 } };
4300   __Pyx_memviewslice __pyx_v_ind = { 0, 0, { 0 }, { 0 }, { 0 } };
4301   __Pyx_memviewslice __pyx_v_ptr = { 0, 0, { 0 }, { 0 }, { 0 } };
4302   __Pyx_memviewslice __pyx_v_mat = { 0, 0, { 0 }, { 0 }, { 0 } };
4303   __pyx_t_double_complex __pyx_v_a;
4304   __Pyx_memviewslice __pyx_v_out = { 0, 0, { 0 }, { 0 }, { 0 } };
4305   int __pyx_lineno = 0;
4306   const char *__pyx_filename = NULL;
4307   int __pyx_clineno = 0;
4308   PyObject *__pyx_r = 0;
4309   __Pyx_RefNannyDeclarations
4310   __Pyx_RefNannySetupContext("spmmpy_f (wrapper)", 0);
4311   {
4312     static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_data,&__pyx_n_s_ind,&__pyx_n_s_ptr,&__pyx_n_s_mat,&__pyx_n_s_a,&__pyx_n_s_out,0};
4313     PyObject* values[6] = {0,0,0,0,0,0};
4314     if (unlikely(__pyx_kwds)) {
4315       Py_ssize_t kw_args;
4316       const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
4317       switch (pos_args) {
4318         case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
4319         CYTHON_FALLTHROUGH;
4320         case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
4321         CYTHON_FALLTHROUGH;
4322         case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
4323         CYTHON_FALLTHROUGH;
4324         case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
4325         CYTHON_FALLTHROUGH;
4326         case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
4327         CYTHON_FALLTHROUGH;
4328         case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
4329         CYTHON_FALLTHROUGH;
4330         case  0: break;
4331         default: goto __pyx_L5_argtuple_error;
4332       }
4333       kw_args = PyDict_Size(__pyx_kwds);
4334       switch (pos_args) {
4335         case  0:
4336         if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_data)) != 0)) kw_args--;
4337         else goto __pyx_L5_argtuple_error;
4338         CYTHON_FALLTHROUGH;
4339         case  1:
4340         if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_ind)) != 0)) kw_args--;
4341         else {
4342           __Pyx_RaiseArgtupleInvalid("spmmpy_f", 1, 6, 6, 1); __PYX_ERR(0, 229, __pyx_L3_error)
4343         }
4344         CYTHON_FALLTHROUGH;
4345         case  2:
4346         if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_ptr)) != 0)) kw_args--;
4347         else {
4348           __Pyx_RaiseArgtupleInvalid("spmmpy_f", 1, 6, 6, 2); __PYX_ERR(0, 229, __pyx_L3_error)
4349         }
4350         CYTHON_FALLTHROUGH;
4351         case  3:
4352         if (likely((values[3] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_mat)) != 0)) kw_args--;
4353         else {
4354           __Pyx_RaiseArgtupleInvalid("spmmpy_f", 1, 6, 6, 3); __PYX_ERR(0, 229, __pyx_L3_error)
4355         }
4356         CYTHON_FALLTHROUGH;
4357         case  4:
4358         if (likely((values[4] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_a)) != 0)) kw_args--;
4359         else {
4360           __Pyx_RaiseArgtupleInvalid("spmmpy_f", 1, 6, 6, 4); __PYX_ERR(0, 229, __pyx_L3_error)
4361         }
4362         CYTHON_FALLTHROUGH;
4363         case  5:
4364         if (likely((values[5] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_out)) != 0)) kw_args--;
4365         else {
4366           __Pyx_RaiseArgtupleInvalid("spmmpy_f", 1, 6, 6, 5); __PYX_ERR(0, 229, __pyx_L3_error)
4367         }
4368       }
4369       if (unlikely(kw_args > 0)) {
4370         if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "spmmpy_f") < 0)) __PYX_ERR(0, 229, __pyx_L3_error)
4371       }
4372     } else if (PyTuple_GET_SIZE(__pyx_args) != 6) {
4373       goto __pyx_L5_argtuple_error;
4374     } else {
4375       values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
4376       values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
4377       values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
4378       values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
4379       values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
4380       values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
4381     }
4382     __pyx_v_data = __Pyx_PyObject_to_MemoryviewSlice_dc___pyx_t_double_complex(values[0], PyBUF_WRITABLE); if (unlikely(!__pyx_v_data.memview)) __PYX_ERR(0, 229, __pyx_L3_error)
4383     __pyx_v_ind = __Pyx_PyObject_to_MemoryviewSlice_dc_int(values[1], PyBUF_WRITABLE); if (unlikely(!__pyx_v_ind.memview)) __PYX_ERR(0, 229, __pyx_L3_error)
4384     __pyx_v_ptr = __Pyx_PyObject_to_MemoryviewSlice_dc_int(values[2], PyBUF_WRITABLE); if (unlikely(!__pyx_v_ptr.memview)) __PYX_ERR(0, 229, __pyx_L3_error)
4385     __pyx_v_mat = __Pyx_PyObject_to_MemoryviewSlice_dcd____pyx_t_double_complex(values[3], PyBUF_WRITABLE); if (unlikely(!__pyx_v_mat.memview)) __PYX_ERR(0, 230, __pyx_L3_error)
4386     __pyx_v_a = __Pyx_PyComplex_As___pyx_t_double_complex(values[4]); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 230, __pyx_L3_error)
4387     __pyx_v_out = __Pyx_PyObject_to_MemoryviewSlice_dcd____pyx_t_double_complex(values[5], PyBUF_WRITABLE); if (unlikely(!__pyx_v_out.memview)) __PYX_ERR(0, 230, __pyx_L3_error)
4388   }
4389   goto __pyx_L4_argument_unpacking_done;
4390   __pyx_L5_argtuple_error:;
4391   __Pyx_RaiseArgtupleInvalid("spmmpy_f", 1, 6, 6, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 229, __pyx_L3_error)
4392   __pyx_L3_error:;
4393   __Pyx_AddTraceback("qutip.cy.spmatfuncs.spmmpy_f", __pyx_clineno, __pyx_lineno, __pyx_filename);
4394   __Pyx_RefNannyFinishContext();
4395   return NULL;
4396   __pyx_L4_argument_unpacking_done:;
4397   __pyx_r = __pyx_pf_5qutip_2cy_10spmatfuncs_10spmmpy_f(__pyx_self, __pyx_v_data, __pyx_v_ind, __pyx_v_ptr, __pyx_v_mat, __pyx_v_a, __pyx_v_out);
4398 
4399   /* function exit code */
4400   __Pyx_RefNannyFinishContext();
4401   return __pyx_r;
4402 }
4403 
__pyx_pf_5qutip_2cy_10spmatfuncs_10spmmpy_f(CYTHON_UNUSED PyObject * __pyx_self,__Pyx_memviewslice __pyx_v_data,__Pyx_memviewslice __pyx_v_ind,__Pyx_memviewslice __pyx_v_ptr,__Pyx_memviewslice __pyx_v_mat,__pyx_t_double_complex __pyx_v_a,__Pyx_memviewslice __pyx_v_out)4404 static PyObject *__pyx_pf_5qutip_2cy_10spmatfuncs_10spmmpy_f(CYTHON_UNUSED PyObject *__pyx_self, __Pyx_memviewslice __pyx_v_data, __Pyx_memviewslice __pyx_v_ind, __Pyx_memviewslice __pyx_v_ptr, __Pyx_memviewslice __pyx_v_mat, __pyx_t_double_complex __pyx_v_a, __Pyx_memviewslice __pyx_v_out) {
4405   PyObject *__pyx_r = NULL;
4406   __Pyx_RefNannyDeclarations
4407   PyObject *__pyx_t_1 = NULL;
4408   int __pyx_lineno = 0;
4409   const char *__pyx_filename = NULL;
4410   int __pyx_clineno = 0;
4411   __Pyx_RefNannySetupContext("spmmpy_f", 0);
4412   __Pyx_XDECREF(__pyx_r);
4413   if (unlikely(!__pyx_v_data.memview)) { __Pyx_RaiseUnboundLocalError("data"); __PYX_ERR(0, 229, __pyx_L1_error) }
4414   if (unlikely(!__pyx_v_ind.memview)) { __Pyx_RaiseUnboundLocalError("ind"); __PYX_ERR(0, 229, __pyx_L1_error) }
4415   if (unlikely(!__pyx_v_ptr.memview)) { __Pyx_RaiseUnboundLocalError("ptr"); __PYX_ERR(0, 229, __pyx_L1_error) }
4416   if (unlikely(!__pyx_v_mat.memview)) { __Pyx_RaiseUnboundLocalError("mat"); __PYX_ERR(0, 229, __pyx_L1_error) }
4417   if (unlikely(!__pyx_v_out.memview)) { __Pyx_RaiseUnboundLocalError("out"); __PYX_ERR(0, 229, __pyx_L1_error) }
4418   __pyx_t_1 = __Pyx_void_to_None(__pyx_f_5qutip_2cy_10spmatfuncs_spmmpy_f(__pyx_v_data, __pyx_v_ind, __pyx_v_ptr, __pyx_v_mat, __pyx_v_a, __pyx_v_out, 0)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 229, __pyx_L1_error)
4419   __Pyx_GOTREF(__pyx_t_1);
4420   __pyx_r = __pyx_t_1;
4421   __pyx_t_1 = 0;
4422   goto __pyx_L0;
4423 
4424   /* function exit code */
4425   __pyx_L1_error:;
4426   __Pyx_XDECREF(__pyx_t_1);
4427   __Pyx_AddTraceback("qutip.cy.spmatfuncs.spmmpy_f", __pyx_clineno, __pyx_lineno, __pyx_filename);
4428   __pyx_r = NULL;
4429   __pyx_L0:;
4430   __PYX_XDEC_MEMVIEW(&__pyx_v_data, 1);
4431   __PYX_XDEC_MEMVIEW(&__pyx_v_ind, 1);
4432   __PYX_XDEC_MEMVIEW(&__pyx_v_ptr, 1);
4433   __PYX_XDEC_MEMVIEW(&__pyx_v_mat, 1);
4434   __PYX_XDEC_MEMVIEW(&__pyx_v_out, 1);
4435   __Pyx_XGIVEREF(__pyx_r);
4436   __Pyx_RefNannyFinishContext();
4437   return __pyx_r;
4438 }
4439 
4440 /* "qutip/cy/spmatfuncs.pyx":258
4441  *
4442  *
4443  * cpdef cnp.ndarray[complex, ndim=1, mode="c"] spmmf(object sparse,             # <<<<<<<<<<<<<<
4444  *                                                    complex[::1,:] mat):
4445  *     """
4446  */
4447 
4448 static PyObject *__pyx_pw_5qutip_2cy_10spmatfuncs_13spmmf(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
__pyx_f_5qutip_2cy_10spmatfuncs_spmmf(PyObject * __pyx_v_sparse,__Pyx_memviewslice __pyx_v_mat,CYTHON_UNUSED int __pyx_skip_dispatch)4449 static PyArrayObject *__pyx_f_5qutip_2cy_10spmatfuncs_spmmf(PyObject *__pyx_v_sparse, __Pyx_memviewslice __pyx_v_mat, CYTHON_UNUSED int __pyx_skip_dispatch) {
4450   unsigned int __pyx_v_sp_rows;
4451   unsigned int __pyx_v_ncols;
4452   PyArrayObject *__pyx_v_out = 0;
4453   __Pyx_LocalBuf_ND __pyx_pybuffernd_out;
4454   __Pyx_Buffer __pyx_pybuffer_out;
4455   PyArrayObject *__pyx_r = NULL;
4456   __Pyx_RefNannyDeclarations
4457   PyObject *__pyx_t_1 = NULL;
4458   PyObject *__pyx_t_2 = NULL;
4459   unsigned int __pyx_t_3;
4460   PyObject *__pyx_t_4 = NULL;
4461   PyObject *__pyx_t_5 = NULL;
4462   PyArrayObject *__pyx_t_6 = NULL;
4463   __Pyx_memviewslice __pyx_t_7 = { 0, 0, { 0 }, { 0 }, { 0 } };
4464   __Pyx_memviewslice __pyx_t_8 = { 0, 0, { 0 }, { 0 }, { 0 } };
4465   __Pyx_memviewslice __pyx_t_9 = { 0, 0, { 0 }, { 0 }, { 0 } };
4466   __Pyx_memviewslice __pyx_t_10 = { 0, 0, { 0 }, { 0 }, { 0 } };
4467   int __pyx_lineno = 0;
4468   const char *__pyx_filename = NULL;
4469   int __pyx_clineno = 0;
4470   __Pyx_RefNannySetupContext("spmmf", 0);
4471   __pyx_pybuffer_out.pybuffer.buf = NULL;
4472   __pyx_pybuffer_out.refcount = 0;
4473   __pyx_pybuffernd_out.data = NULL;
4474   __pyx_pybuffernd_out.rcbuffer = &__pyx_pybuffer_out;
4475 
4476   /* "qutip/cy/spmatfuncs.pyx":275
4477  *     Keep input ordering
4478  *     """
4479  *     cdef unsigned int sp_rows = sparse.indptr.shape[0]-1             # <<<<<<<<<<<<<<
4480  *     cdef unsigned int ncols = mat.shape[1]
4481  *     cdef cnp.ndarray[complex, ndim=2, mode="fortran"] out = \
4482  */
4483   __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_sparse, __pyx_n_s_indptr); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 275, __pyx_L1_error)
4484   __Pyx_GOTREF(__pyx_t_1);
4485   __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_shape); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 275, __pyx_L1_error)
4486   __Pyx_GOTREF(__pyx_t_2);
4487   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
4488   __pyx_t_1 = __Pyx_GetItemInt(__pyx_t_2, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 275, __pyx_L1_error)
4489   __Pyx_GOTREF(__pyx_t_1);
4490   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
4491   __pyx_t_2 = __Pyx_PyInt_SubtractObjC(__pyx_t_1, __pyx_int_1, 1, 0, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 275, __pyx_L1_error)
4492   __Pyx_GOTREF(__pyx_t_2);
4493   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
4494   __pyx_t_3 = __Pyx_PyInt_As_unsigned_int(__pyx_t_2); if (unlikely((__pyx_t_3 == (unsigned int)-1) && PyErr_Occurred())) __PYX_ERR(0, 275, __pyx_L1_error)
4495   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
4496   __pyx_v_sp_rows = __pyx_t_3;
4497 
4498   /* "qutip/cy/spmatfuncs.pyx":276
4499  *     """
4500  *     cdef unsigned int sp_rows = sparse.indptr.shape[0]-1
4501  *     cdef unsigned int ncols = mat.shape[1]             # <<<<<<<<<<<<<<
4502  *     cdef cnp.ndarray[complex, ndim=2, mode="fortran"] out = \
4503  *                      np.zeros((sp_rows, ncols), dtype=complex, order="F")
4504  */
4505   __pyx_v_ncols = (__pyx_v_mat.shape[1]);
4506 
4507   /* "qutip/cy/spmatfuncs.pyx":278
4508  *     cdef unsigned int ncols = mat.shape[1]
4509  *     cdef cnp.ndarray[complex, ndim=2, mode="fortran"] out = \
4510  *                      np.zeros((sp_rows, ncols), dtype=complex, order="F")             # <<<<<<<<<<<<<<
4511  *     spmmpy_f(sparse.data, sparse.indices, sparse.indptr,
4512  *              mat, 1., out)
4513  */
4514   __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_np); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 278, __pyx_L1_error)
4515   __Pyx_GOTREF(__pyx_t_2);
4516   __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_zeros); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 278, __pyx_L1_error)
4517   __Pyx_GOTREF(__pyx_t_1);
4518   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
4519   __pyx_t_2 = __Pyx_PyInt_From_unsigned_int(__pyx_v_sp_rows); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 278, __pyx_L1_error)
4520   __Pyx_GOTREF(__pyx_t_2);
4521   __pyx_t_4 = __Pyx_PyInt_From_unsigned_int(__pyx_v_ncols); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 278, __pyx_L1_error)
4522   __Pyx_GOTREF(__pyx_t_4);
4523   __pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 278, __pyx_L1_error)
4524   __Pyx_GOTREF(__pyx_t_5);
4525   __Pyx_GIVEREF(__pyx_t_2);
4526   PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_2);
4527   __Pyx_GIVEREF(__pyx_t_4);
4528   PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_t_4);
4529   __pyx_t_2 = 0;
4530   __pyx_t_4 = 0;
4531   __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 278, __pyx_L1_error)
4532   __Pyx_GOTREF(__pyx_t_4);
4533   __Pyx_GIVEREF(__pyx_t_5);
4534   PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_5);
4535   __pyx_t_5 = 0;
4536   __pyx_t_5 = __Pyx_PyDict_NewPresized(2); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 278, __pyx_L1_error)
4537   __Pyx_GOTREF(__pyx_t_5);
4538   if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_dtype, ((PyObject *)(&PyComplex_Type))) < 0) __PYX_ERR(0, 278, __pyx_L1_error)
4539   if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_order, __pyx_n_u_F) < 0) __PYX_ERR(0, 278, __pyx_L1_error)
4540   __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_4, __pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 278, __pyx_L1_error)
4541   __Pyx_GOTREF(__pyx_t_2);
4542   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
4543   __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
4544   __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
4545   if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 278, __pyx_L1_error)
4546   __pyx_t_6 = ((PyArrayObject *)__pyx_t_2);
4547   {
4548     __Pyx_BufFmt_StackElem __pyx_stack[1];
4549     if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_out.rcbuffer->pybuffer, (PyObject*)__pyx_t_6, &__Pyx_TypeInfo___pyx_t_double_complex, PyBUF_FORMAT| PyBUF_F_CONTIGUOUS, 2, 0, __pyx_stack) == -1)) {
4550       __pyx_v_out = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_pybuffernd_out.rcbuffer->pybuffer.buf = NULL;
4551       __PYX_ERR(0, 277, __pyx_L1_error)
4552     } else {__pyx_pybuffernd_out.diminfo[0].strides = __pyx_pybuffernd_out.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_out.diminfo[0].shape = __pyx_pybuffernd_out.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_out.diminfo[1].strides = __pyx_pybuffernd_out.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_out.diminfo[1].shape = __pyx_pybuffernd_out.rcbuffer->pybuffer.shape[1];
4553     }
4554   }
4555   __pyx_t_6 = 0;
4556   __pyx_v_out = ((PyArrayObject *)__pyx_t_2);
4557   __pyx_t_2 = 0;
4558 
4559   /* "qutip/cy/spmatfuncs.pyx":279
4560  *     cdef cnp.ndarray[complex, ndim=2, mode="fortran"] out = \
4561  *                      np.zeros((sp_rows, ncols), dtype=complex, order="F")
4562  *     spmmpy_f(sparse.data, sparse.indices, sparse.indptr,             # <<<<<<<<<<<<<<
4563  *              mat, 1., out)
4564  *     return out
4565  */
4566   __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_sparse, __pyx_n_s_data); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 279, __pyx_L1_error)
4567   __Pyx_GOTREF(__pyx_t_2);
4568   __pyx_t_7 = __Pyx_PyObject_to_MemoryviewSlice_dc___pyx_t_double_complex(__pyx_t_2, PyBUF_WRITABLE); if (unlikely(!__pyx_t_7.memview)) __PYX_ERR(0, 279, __pyx_L1_error)
4569   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
4570   __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_sparse, __pyx_n_s_indices); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 279, __pyx_L1_error)
4571   __Pyx_GOTREF(__pyx_t_2);
4572   __pyx_t_8 = __Pyx_PyObject_to_MemoryviewSlice_dc_int(__pyx_t_2, PyBUF_WRITABLE); if (unlikely(!__pyx_t_8.memview)) __PYX_ERR(0, 279, __pyx_L1_error)
4573   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
4574   __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_sparse, __pyx_n_s_indptr); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 279, __pyx_L1_error)
4575   __Pyx_GOTREF(__pyx_t_2);
4576   __pyx_t_9 = __Pyx_PyObject_to_MemoryviewSlice_dc_int(__pyx_t_2, PyBUF_WRITABLE); if (unlikely(!__pyx_t_9.memview)) __PYX_ERR(0, 279, __pyx_L1_error)
4577   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
4578 
4579   /* "qutip/cy/spmatfuncs.pyx":280
4580  *                      np.zeros((sp_rows, ncols), dtype=complex, order="F")
4581  *     spmmpy_f(sparse.data, sparse.indices, sparse.indptr,
4582  *              mat, 1., out)             # <<<<<<<<<<<<<<
4583  *     return out
4584  *
4585  */
4586   __pyx_t_10 = __Pyx_PyObject_to_MemoryviewSlice_dcd____pyx_t_double_complex(((PyObject *)__pyx_v_out), PyBUF_WRITABLE); if (unlikely(!__pyx_t_10.memview)) __PYX_ERR(0, 280, __pyx_L1_error)
4587 
4588   /* "qutip/cy/spmatfuncs.pyx":279
4589  *     cdef cnp.ndarray[complex, ndim=2, mode="fortran"] out = \
4590  *                      np.zeros((sp_rows, ncols), dtype=complex, order="F")
4591  *     spmmpy_f(sparse.data, sparse.indices, sparse.indptr,             # <<<<<<<<<<<<<<
4592  *              mat, 1., out)
4593  *     return out
4594  */
4595   __pyx_f_5qutip_2cy_10spmatfuncs_spmmpy_f(__pyx_t_7, __pyx_t_8, __pyx_t_9, __pyx_v_mat, __pyx_t_double_complex_from_parts(1., 0), __pyx_t_10, 0);
4596   __PYX_XDEC_MEMVIEW(&__pyx_t_7, 1);
4597   __pyx_t_7.memview = NULL;
4598   __pyx_t_7.data = NULL;
4599   __PYX_XDEC_MEMVIEW(&__pyx_t_8, 1);
4600   __pyx_t_8.memview = NULL;
4601   __pyx_t_8.data = NULL;
4602   __PYX_XDEC_MEMVIEW(&__pyx_t_9, 1);
4603   __pyx_t_9.memview = NULL;
4604   __pyx_t_9.data = NULL;
4605   __PYX_XDEC_MEMVIEW(&__pyx_t_10, 1);
4606   __pyx_t_10.memview = NULL;
4607   __pyx_t_10.data = NULL;
4608 
4609   /* "qutip/cy/spmatfuncs.pyx":281
4610  *     spmmpy_f(sparse.data, sparse.indices, sparse.indptr,
4611  *              mat, 1., out)
4612  *     return out             # <<<<<<<<<<<<<<
4613  *
4614  *
4615  */
4616   __Pyx_XDECREF(((PyObject *)__pyx_r));
4617   __Pyx_INCREF(((PyObject *)__pyx_v_out));
4618   __pyx_r = ((PyArrayObject *)__pyx_v_out);
4619   goto __pyx_L0;
4620 
4621   /* "qutip/cy/spmatfuncs.pyx":258
4622  *
4623  *
4624  * cpdef cnp.ndarray[complex, ndim=1, mode="c"] spmmf(object sparse,             # <<<<<<<<<<<<<<
4625  *                                                    complex[::1,:] mat):
4626  *     """
4627  */
4628 
4629   /* function exit code */
4630   __pyx_L1_error:;
4631   __Pyx_XDECREF(__pyx_t_1);
4632   __Pyx_XDECREF(__pyx_t_2);
4633   __Pyx_XDECREF(__pyx_t_4);
4634   __Pyx_XDECREF(__pyx_t_5);
4635   __PYX_XDEC_MEMVIEW(&__pyx_t_7, 1);
4636   __PYX_XDEC_MEMVIEW(&__pyx_t_8, 1);
4637   __PYX_XDEC_MEMVIEW(&__pyx_t_9, 1);
4638   __PYX_XDEC_MEMVIEW(&__pyx_t_10, 1);
4639   { PyObject *__pyx_type, *__pyx_value, *__pyx_tb;
4640     __Pyx_PyThreadState_declare
4641     __Pyx_PyThreadState_assign
4642     __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb);
4643     __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_out.rcbuffer->pybuffer);
4644   __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}
4645   __Pyx_AddTraceback("qutip.cy.spmatfuncs.spmmf", __pyx_clineno, __pyx_lineno, __pyx_filename);
4646   __pyx_r = 0;
4647   goto __pyx_L2;
4648   __pyx_L0:;
4649   __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_out.rcbuffer->pybuffer);
4650   __pyx_L2:;
4651   __Pyx_XDECREF((PyObject *)__pyx_v_out);
4652   __Pyx_XGIVEREF((PyObject *)__pyx_r);
4653   __Pyx_RefNannyFinishContext();
4654   return __pyx_r;
4655 }
4656 
4657 /* Python wrapper */
4658 static PyObject *__pyx_pw_5qutip_2cy_10spmatfuncs_13spmmf(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
4659 static char __pyx_doc_5qutip_2cy_10spmatfuncs_12spmmf[] = "\n    Sparse matrix, fortran ordered dense matrix multiplication.\n    The sparse matrix must be in CSR format and have complex entries.\n\n    Parameters\n    ----------\n    sparse : csr matrix\n    mat : array 2d\n        Dense matrix for multiplication. Must be in fortran mode.\n\n    Returns\n    -------\n    out : array\n    Keep input ordering\n    ";
__pyx_pw_5qutip_2cy_10spmatfuncs_13spmmf(PyObject * __pyx_self,PyObject * __pyx_args,PyObject * __pyx_kwds)4660 static PyObject *__pyx_pw_5qutip_2cy_10spmatfuncs_13spmmf(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
4661   PyObject *__pyx_v_sparse = 0;
4662   __Pyx_memviewslice __pyx_v_mat = { 0, 0, { 0 }, { 0 }, { 0 } };
4663   int __pyx_lineno = 0;
4664   const char *__pyx_filename = NULL;
4665   int __pyx_clineno = 0;
4666   PyObject *__pyx_r = 0;
4667   __Pyx_RefNannyDeclarations
4668   __Pyx_RefNannySetupContext("spmmf (wrapper)", 0);
4669   {
4670     static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_sparse,&__pyx_n_s_mat,0};
4671     PyObject* values[2] = {0,0};
4672     if (unlikely(__pyx_kwds)) {
4673       Py_ssize_t kw_args;
4674       const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
4675       switch (pos_args) {
4676         case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
4677         CYTHON_FALLTHROUGH;
4678         case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
4679         CYTHON_FALLTHROUGH;
4680         case  0: break;
4681         default: goto __pyx_L5_argtuple_error;
4682       }
4683       kw_args = PyDict_Size(__pyx_kwds);
4684       switch (pos_args) {
4685         case  0:
4686         if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_sparse)) != 0)) kw_args--;
4687         else goto __pyx_L5_argtuple_error;
4688         CYTHON_FALLTHROUGH;
4689         case  1:
4690         if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_mat)) != 0)) kw_args--;
4691         else {
4692           __Pyx_RaiseArgtupleInvalid("spmmf", 1, 2, 2, 1); __PYX_ERR(0, 258, __pyx_L3_error)
4693         }
4694       }
4695       if (unlikely(kw_args > 0)) {
4696         if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "spmmf") < 0)) __PYX_ERR(0, 258, __pyx_L3_error)
4697       }
4698     } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
4699       goto __pyx_L5_argtuple_error;
4700     } else {
4701       values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
4702       values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
4703     }
4704     __pyx_v_sparse = values[0];
4705     __pyx_v_mat = __Pyx_PyObject_to_MemoryviewSlice_dcd____pyx_t_double_complex(values[1], PyBUF_WRITABLE); if (unlikely(!__pyx_v_mat.memview)) __PYX_ERR(0, 259, __pyx_L3_error)
4706   }
4707   goto __pyx_L4_argument_unpacking_done;
4708   __pyx_L5_argtuple_error:;
4709   __Pyx_RaiseArgtupleInvalid("spmmf", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 258, __pyx_L3_error)
4710   __pyx_L3_error:;
4711   __Pyx_AddTraceback("qutip.cy.spmatfuncs.spmmf", __pyx_clineno, __pyx_lineno, __pyx_filename);
4712   __Pyx_RefNannyFinishContext();
4713   return NULL;
4714   __pyx_L4_argument_unpacking_done:;
4715   __pyx_r = __pyx_pf_5qutip_2cy_10spmatfuncs_12spmmf(__pyx_self, __pyx_v_sparse, __pyx_v_mat);
4716 
4717   /* function exit code */
4718   __Pyx_RefNannyFinishContext();
4719   return __pyx_r;
4720 }
4721 
__pyx_pf_5qutip_2cy_10spmatfuncs_12spmmf(CYTHON_UNUSED PyObject * __pyx_self,PyObject * __pyx_v_sparse,__Pyx_memviewslice __pyx_v_mat)4722 static PyObject *__pyx_pf_5qutip_2cy_10spmatfuncs_12spmmf(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_sparse, __Pyx_memviewslice __pyx_v_mat) {
4723   PyObject *__pyx_r = NULL;
4724   __Pyx_RefNannyDeclarations
4725   PyObject *__pyx_t_1 = NULL;
4726   int __pyx_lineno = 0;
4727   const char *__pyx_filename = NULL;
4728   int __pyx_clineno = 0;
4729   __Pyx_RefNannySetupContext("spmmf", 0);
4730   __Pyx_XDECREF(__pyx_r);
4731   if (unlikely(!__pyx_v_mat.memview)) { __Pyx_RaiseUnboundLocalError("mat"); __PYX_ERR(0, 258, __pyx_L1_error) }
4732   __pyx_t_1 = ((PyObject *)__pyx_f_5qutip_2cy_10spmatfuncs_spmmf(__pyx_v_sparse, __pyx_v_mat, 0)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 258, __pyx_L1_error)
4733   __Pyx_GOTREF(__pyx_t_1);
4734   __pyx_r = __pyx_t_1;
4735   __pyx_t_1 = 0;
4736   goto __pyx_L0;
4737 
4738   /* function exit code */
4739   __pyx_L1_error:;
4740   __Pyx_XDECREF(__pyx_t_1);
4741   __Pyx_AddTraceback("qutip.cy.spmatfuncs.spmmf", __pyx_clineno, __pyx_lineno, __pyx_filename);
4742   __pyx_r = NULL;
4743   __pyx_L0:;
4744   __PYX_XDEC_MEMVIEW(&__pyx_v_mat, 1);
4745   __Pyx_XGIVEREF(__pyx_r);
4746   __Pyx_RefNannyFinishContext();
4747   return __pyx_r;
4748 }
4749 
4750 /* "qutip/cy/spmatfuncs.pyx":284
4751  *
4752  *
4753  * cpdef cnp.ndarray[complex, ndim=1, mode="c"] spmm(object sparse,             # <<<<<<<<<<<<<<
4754  *                                             cnp.ndarray[complex, ndim=2] mat):
4755  *     """
4756  */
4757 
4758 static PyObject *__pyx_pw_5qutip_2cy_10spmatfuncs_15spmm(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
__pyx_f_5qutip_2cy_10spmatfuncs_spmm(PyObject * __pyx_v_sparse,PyArrayObject * __pyx_v_mat,CYTHON_UNUSED int __pyx_skip_dispatch)4759 static PyArrayObject *__pyx_f_5qutip_2cy_10spmatfuncs_spmm(PyObject *__pyx_v_sparse, PyArrayObject *__pyx_v_mat, CYTHON_UNUSED int __pyx_skip_dispatch) {
4760   __Pyx_LocalBuf_ND __pyx_pybuffernd_mat;
4761   __Pyx_Buffer __pyx_pybuffer_mat;
4762   PyArrayObject *__pyx_r = NULL;
4763   __Pyx_RefNannyDeclarations
4764   PyObject *__pyx_t_1 = NULL;
4765   PyObject *__pyx_t_2 = NULL;
4766   int __pyx_t_3;
4767   __Pyx_memviewslice __pyx_t_4 = { 0, 0, { 0 }, { 0 }, { 0 } };
4768   __Pyx_memviewslice __pyx_t_5 = { 0, 0, { 0 }, { 0 }, { 0 } };
4769   int __pyx_lineno = 0;
4770   const char *__pyx_filename = NULL;
4771   int __pyx_clineno = 0;
4772   __Pyx_RefNannySetupContext("spmm", 0);
4773   __pyx_pybuffer_mat.pybuffer.buf = NULL;
4774   __pyx_pybuffer_mat.refcount = 0;
4775   __pyx_pybuffernd_mat.data = NULL;
4776   __pyx_pybuffernd_mat.rcbuffer = &__pyx_pybuffer_mat;
4777   {
4778     __Pyx_BufFmt_StackElem __pyx_stack[1];
4779     if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_mat.rcbuffer->pybuffer, (PyObject*)__pyx_v_mat, &__Pyx_TypeInfo___pyx_t_double_complex, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) __PYX_ERR(0, 284, __pyx_L1_error)
4780   }
4781   __pyx_pybuffernd_mat.diminfo[0].strides = __pyx_pybuffernd_mat.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_mat.diminfo[0].shape = __pyx_pybuffernd_mat.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_mat.diminfo[1].strides = __pyx_pybuffernd_mat.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_mat.diminfo[1].shape = __pyx_pybuffernd_mat.rcbuffer->pybuffer.shape[1];
4782 
4783   /* "qutip/cy/spmatfuncs.pyx":301
4784  *     Keep input ordering
4785  *     """
4786  *     if mat.flags["F_CONTIGUOUS"]:             # <<<<<<<<<<<<<<
4787  *         return spmmf(sparse, mat)
4788  *     else:
4789  */
4790   __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_mat), __pyx_n_s_flags); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 301, __pyx_L1_error)
4791   __Pyx_GOTREF(__pyx_t_1);
4792   __pyx_t_2 = __Pyx_PyObject_Dict_GetItem(__pyx_t_1, __pyx_n_u_F_CONTIGUOUS); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 301, __pyx_L1_error)
4793   __Pyx_GOTREF(__pyx_t_2);
4794   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
4795   __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(0, 301, __pyx_L1_error)
4796   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
4797   if (__pyx_t_3) {
4798 
4799     /* "qutip/cy/spmatfuncs.pyx":302
4800  *     """
4801  *     if mat.flags["F_CONTIGUOUS"]:
4802  *         return spmmf(sparse, mat)             # <<<<<<<<<<<<<<
4803  *     else:
4804  *         return spmmc(sparse, mat)
4805  */
4806     __Pyx_XDECREF(((PyObject *)__pyx_r));
4807     __pyx_t_4 = __Pyx_PyObject_to_MemoryviewSlice_dcd____pyx_t_double_complex(((PyObject *)__pyx_v_mat), PyBUF_WRITABLE); if (unlikely(!__pyx_t_4.memview)) __PYX_ERR(0, 302, __pyx_L1_error)
4808     __pyx_t_2 = ((PyObject *)__pyx_f_5qutip_2cy_10spmatfuncs_spmmf(__pyx_v_sparse, __pyx_t_4, 0)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 302, __pyx_L1_error)
4809     __Pyx_GOTREF(__pyx_t_2);
4810     __PYX_XDEC_MEMVIEW(&__pyx_t_4, 1);
4811     __pyx_t_4.memview = NULL;
4812     __pyx_t_4.data = NULL;
4813     __pyx_r = ((PyArrayObject *)__pyx_t_2);
4814     __pyx_t_2 = 0;
4815     goto __pyx_L0;
4816 
4817     /* "qutip/cy/spmatfuncs.pyx":301
4818  *     Keep input ordering
4819  *     """
4820  *     if mat.flags["F_CONTIGUOUS"]:             # <<<<<<<<<<<<<<
4821  *         return spmmf(sparse, mat)
4822  *     else:
4823  */
4824   }
4825 
4826   /* "qutip/cy/spmatfuncs.pyx":304
4827  *         return spmmf(sparse, mat)
4828  *     else:
4829  *         return spmmc(sparse, mat)             # <<<<<<<<<<<<<<
4830  *
4831  *
4832  */
4833   /*else*/ {
4834     __Pyx_XDECREF(((PyObject *)__pyx_r));
4835     __pyx_t_5 = __Pyx_PyObject_to_MemoryviewSlice_d_dc___pyx_t_double_complex(((PyObject *)__pyx_v_mat), PyBUF_WRITABLE); if (unlikely(!__pyx_t_5.memview)) __PYX_ERR(0, 304, __pyx_L1_error)
4836     __pyx_t_2 = ((PyObject *)__pyx_f_5qutip_2cy_10spmatfuncs_spmmc(__pyx_v_sparse, __pyx_t_5, 0)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 304, __pyx_L1_error)
4837     __Pyx_GOTREF(__pyx_t_2);
4838     __PYX_XDEC_MEMVIEW(&__pyx_t_5, 1);
4839     __pyx_t_5.memview = NULL;
4840     __pyx_t_5.data = NULL;
4841     __pyx_r = ((PyArrayObject *)__pyx_t_2);
4842     __pyx_t_2 = 0;
4843     goto __pyx_L0;
4844   }
4845 
4846   /* "qutip/cy/spmatfuncs.pyx":284
4847  *
4848  *
4849  * cpdef cnp.ndarray[complex, ndim=1, mode="c"] spmm(object sparse,             # <<<<<<<<<<<<<<
4850  *                                             cnp.ndarray[complex, ndim=2] mat):
4851  *     """
4852  */
4853 
4854   /* function exit code */
4855   __pyx_L1_error:;
4856   __Pyx_XDECREF(__pyx_t_1);
4857   __Pyx_XDECREF(__pyx_t_2);
4858   __PYX_XDEC_MEMVIEW(&__pyx_t_4, 1);
4859   __PYX_XDEC_MEMVIEW(&__pyx_t_5, 1);
4860   { PyObject *__pyx_type, *__pyx_value, *__pyx_tb;
4861     __Pyx_PyThreadState_declare
4862     __Pyx_PyThreadState_assign
4863     __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb);
4864     __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_mat.rcbuffer->pybuffer);
4865   __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}
4866   __Pyx_AddTraceback("qutip.cy.spmatfuncs.spmm", __pyx_clineno, __pyx_lineno, __pyx_filename);
4867   __pyx_r = 0;
4868   goto __pyx_L2;
4869   __pyx_L0:;
4870   __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_mat.rcbuffer->pybuffer);
4871   __pyx_L2:;
4872   __Pyx_XGIVEREF((PyObject *)__pyx_r);
4873   __Pyx_RefNannyFinishContext();
4874   return __pyx_r;
4875 }
4876 
4877 /* Python wrapper */
4878 static PyObject *__pyx_pw_5qutip_2cy_10spmatfuncs_15spmm(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
4879 static char __pyx_doc_5qutip_2cy_10spmatfuncs_14spmm[] = "\n    Sparse matrix, dense matrix multiplication.\n    The sparse matrix must be in CSR format and have complex entries.\n\n    Parameters\n    ----------\n    sparse : csr matrix\n    mat : array 2d\n    Dense matrix for multiplication. Can be in c or fortran mode.\n\n    Returns\n    -------\n    out : array\n    Keep input ordering\n    ";
__pyx_pw_5qutip_2cy_10spmatfuncs_15spmm(PyObject * __pyx_self,PyObject * __pyx_args,PyObject * __pyx_kwds)4880 static PyObject *__pyx_pw_5qutip_2cy_10spmatfuncs_15spmm(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
4881   PyObject *__pyx_v_sparse = 0;
4882   PyArrayObject *__pyx_v_mat = 0;
4883   int __pyx_lineno = 0;
4884   const char *__pyx_filename = NULL;
4885   int __pyx_clineno = 0;
4886   PyObject *__pyx_r = 0;
4887   __Pyx_RefNannyDeclarations
4888   __Pyx_RefNannySetupContext("spmm (wrapper)", 0);
4889   {
4890     static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_sparse,&__pyx_n_s_mat,0};
4891     PyObject* values[2] = {0,0};
4892     if (unlikely(__pyx_kwds)) {
4893       Py_ssize_t kw_args;
4894       const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
4895       switch (pos_args) {
4896         case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
4897         CYTHON_FALLTHROUGH;
4898         case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
4899         CYTHON_FALLTHROUGH;
4900         case  0: break;
4901         default: goto __pyx_L5_argtuple_error;
4902       }
4903       kw_args = PyDict_Size(__pyx_kwds);
4904       switch (pos_args) {
4905         case  0:
4906         if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_sparse)) != 0)) kw_args--;
4907         else goto __pyx_L5_argtuple_error;
4908         CYTHON_FALLTHROUGH;
4909         case  1:
4910         if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_mat)) != 0)) kw_args--;
4911         else {
4912           __Pyx_RaiseArgtupleInvalid("spmm", 1, 2, 2, 1); __PYX_ERR(0, 284, __pyx_L3_error)
4913         }
4914       }
4915       if (unlikely(kw_args > 0)) {
4916         if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "spmm") < 0)) __PYX_ERR(0, 284, __pyx_L3_error)
4917       }
4918     } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
4919       goto __pyx_L5_argtuple_error;
4920     } else {
4921       values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
4922       values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
4923     }
4924     __pyx_v_sparse = values[0];
4925     __pyx_v_mat = ((PyArrayObject *)values[1]);
4926   }
4927   goto __pyx_L4_argument_unpacking_done;
4928   __pyx_L5_argtuple_error:;
4929   __Pyx_RaiseArgtupleInvalid("spmm", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 284, __pyx_L3_error)
4930   __pyx_L3_error:;
4931   __Pyx_AddTraceback("qutip.cy.spmatfuncs.spmm", __pyx_clineno, __pyx_lineno, __pyx_filename);
4932   __Pyx_RefNannyFinishContext();
4933   return NULL;
4934   __pyx_L4_argument_unpacking_done:;
4935   if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_mat), __pyx_ptype_5numpy_ndarray, 1, "mat", 0))) __PYX_ERR(0, 285, __pyx_L1_error)
4936   __pyx_r = __pyx_pf_5qutip_2cy_10spmatfuncs_14spmm(__pyx_self, __pyx_v_sparse, __pyx_v_mat);
4937 
4938   /* function exit code */
4939   goto __pyx_L0;
4940   __pyx_L1_error:;
4941   __pyx_r = NULL;
4942   __pyx_L0:;
4943   __Pyx_RefNannyFinishContext();
4944   return __pyx_r;
4945 }
4946 
__pyx_pf_5qutip_2cy_10spmatfuncs_14spmm(CYTHON_UNUSED PyObject * __pyx_self,PyObject * __pyx_v_sparse,PyArrayObject * __pyx_v_mat)4947 static PyObject *__pyx_pf_5qutip_2cy_10spmatfuncs_14spmm(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_sparse, PyArrayObject *__pyx_v_mat) {
4948   __Pyx_LocalBuf_ND __pyx_pybuffernd_mat;
4949   __Pyx_Buffer __pyx_pybuffer_mat;
4950   PyObject *__pyx_r = NULL;
4951   __Pyx_RefNannyDeclarations
4952   PyObject *__pyx_t_1 = NULL;
4953   int __pyx_lineno = 0;
4954   const char *__pyx_filename = NULL;
4955   int __pyx_clineno = 0;
4956   __Pyx_RefNannySetupContext("spmm", 0);
4957   __pyx_pybuffer_mat.pybuffer.buf = NULL;
4958   __pyx_pybuffer_mat.refcount = 0;
4959   __pyx_pybuffernd_mat.data = NULL;
4960   __pyx_pybuffernd_mat.rcbuffer = &__pyx_pybuffer_mat;
4961   {
4962     __Pyx_BufFmt_StackElem __pyx_stack[1];
4963     if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_mat.rcbuffer->pybuffer, (PyObject*)__pyx_v_mat, &__Pyx_TypeInfo___pyx_t_double_complex, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) __PYX_ERR(0, 284, __pyx_L1_error)
4964   }
4965   __pyx_pybuffernd_mat.diminfo[0].strides = __pyx_pybuffernd_mat.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_mat.diminfo[0].shape = __pyx_pybuffernd_mat.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_mat.diminfo[1].strides = __pyx_pybuffernd_mat.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_mat.diminfo[1].shape = __pyx_pybuffernd_mat.rcbuffer->pybuffer.shape[1];
4966   __Pyx_XDECREF(__pyx_r);
4967   __pyx_t_1 = ((PyObject *)__pyx_f_5qutip_2cy_10spmatfuncs_spmm(__pyx_v_sparse, ((PyArrayObject *)__pyx_v_mat), 0)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 284, __pyx_L1_error)
4968   __Pyx_GOTREF(__pyx_t_1);
4969   __pyx_r = __pyx_t_1;
4970   __pyx_t_1 = 0;
4971   goto __pyx_L0;
4972 
4973   /* function exit code */
4974   __pyx_L1_error:;
4975   __Pyx_XDECREF(__pyx_t_1);
4976   { PyObject *__pyx_type, *__pyx_value, *__pyx_tb;
4977     __Pyx_PyThreadState_declare
4978     __Pyx_PyThreadState_assign
4979     __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb);
4980     __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_mat.rcbuffer->pybuffer);
4981   __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}
4982   __Pyx_AddTraceback("qutip.cy.spmatfuncs.spmm", __pyx_clineno, __pyx_lineno, __pyx_filename);
4983   __pyx_r = NULL;
4984   goto __pyx_L2;
4985   __pyx_L0:;
4986   __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_mat.rcbuffer->pybuffer);
4987   __pyx_L2:;
4988   __Pyx_XGIVEREF(__pyx_r);
4989   __Pyx_RefNannyFinishContext();
4990   return __pyx_r;
4991 }
4992 
4993 /* "qutip/cy/spmatfuncs.pyx":309
4994  * @cython.boundscheck(False)
4995  * @cython.wraparound(False)
4996  * cpdef cnp.ndarray[complex, ndim=1, mode="c"] cy_ode_rhs(             # <<<<<<<<<<<<<<
4997  *         double t,
4998  *         complex[::1] rho,
4999  */
5000 
5001 static PyObject *__pyx_pw_5qutip_2cy_10spmatfuncs_17cy_ode_rhs(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
__pyx_f_5qutip_2cy_10spmatfuncs_cy_ode_rhs(CYTHON_UNUSED double __pyx_v_t,__Pyx_memviewslice __pyx_v_rho,__Pyx_memviewslice __pyx_v_data,__Pyx_memviewslice __pyx_v_ind,__Pyx_memviewslice __pyx_v_ptr,CYTHON_UNUSED int __pyx_skip_dispatch)5002 static PyArrayObject *__pyx_f_5qutip_2cy_10spmatfuncs_cy_ode_rhs(CYTHON_UNUSED double __pyx_v_t, __Pyx_memviewslice __pyx_v_rho, __Pyx_memviewslice __pyx_v_data, __Pyx_memviewslice __pyx_v_ind, __Pyx_memviewslice __pyx_v_ptr, CYTHON_UNUSED int __pyx_skip_dispatch) {
5003   unsigned int __pyx_v_nrows;
5004   PyArrayObject *__pyx_v_out = 0;
5005   __Pyx_LocalBuf_ND __pyx_pybuffernd_out;
5006   __Pyx_Buffer __pyx_pybuffer_out;
5007   PyArrayObject *__pyx_r = NULL;
5008   __Pyx_RefNannyDeclarations
5009   PyObject *__pyx_t_1 = NULL;
5010   PyObject *__pyx_t_2 = NULL;
5011   PyObject *__pyx_t_3 = NULL;
5012   PyObject *__pyx_t_4 = NULL;
5013   PyArrayObject *__pyx_t_5 = NULL;
5014   Py_ssize_t __pyx_t_6;
5015   Py_ssize_t __pyx_t_7;
5016   Py_ssize_t __pyx_t_8;
5017   Py_ssize_t __pyx_t_9;
5018   Py_ssize_t __pyx_t_10;
5019   int __pyx_lineno = 0;
5020   const char *__pyx_filename = NULL;
5021   int __pyx_clineno = 0;
5022   __Pyx_RefNannySetupContext("cy_ode_rhs", 0);
5023   __pyx_pybuffer_out.pybuffer.buf = NULL;
5024   __pyx_pybuffer_out.refcount = 0;
5025   __pyx_pybuffernd_out.data = NULL;
5026   __pyx_pybuffernd_out.rcbuffer = &__pyx_pybuffer_out;
5027 
5028   /* "qutip/cy/spmatfuncs.pyx":316
5029  *         int[::1] ptr):
5030  *
5031  *     cdef unsigned int nrows = rho.shape[0]             # <<<<<<<<<<<<<<
5032  *     cdef cnp.ndarray[complex, ndim=1, mode="c"] out = \
5033  *         np.zeros(nrows, dtype=complex)
5034  */
5035   __pyx_v_nrows = (__pyx_v_rho.shape[0]);
5036 
5037   /* "qutip/cy/spmatfuncs.pyx":318
5038  *     cdef unsigned int nrows = rho.shape[0]
5039  *     cdef cnp.ndarray[complex, ndim=1, mode="c"] out = \
5040  *         np.zeros(nrows, dtype=complex)             # <<<<<<<<<<<<<<
5041  *     zspmvpy(&data[0], &ind[0], &ptr[0], &rho[0], 1.0, &out[0], nrows)
5042  *
5043  */
5044   __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_np); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 318, __pyx_L1_error)
5045   __Pyx_GOTREF(__pyx_t_1);
5046   __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_zeros); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 318, __pyx_L1_error)
5047   __Pyx_GOTREF(__pyx_t_2);
5048   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
5049   __pyx_t_1 = __Pyx_PyInt_From_unsigned_int(__pyx_v_nrows); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 318, __pyx_L1_error)
5050   __Pyx_GOTREF(__pyx_t_1);
5051   __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 318, __pyx_L1_error)
5052   __Pyx_GOTREF(__pyx_t_3);
5053   __Pyx_GIVEREF(__pyx_t_1);
5054   PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_1);
5055   __pyx_t_1 = 0;
5056   __pyx_t_1 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 318, __pyx_L1_error)
5057   __Pyx_GOTREF(__pyx_t_1);
5058   if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_dtype, ((PyObject *)(&PyComplex_Type))) < 0) __PYX_ERR(0, 318, __pyx_L1_error)
5059   __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_3, __pyx_t_1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 318, __pyx_L1_error)
5060   __Pyx_GOTREF(__pyx_t_4);
5061   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
5062   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
5063   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
5064   if (!(likely(((__pyx_t_4) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_4, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 318, __pyx_L1_error)
5065   __pyx_t_5 = ((PyArrayObject *)__pyx_t_4);
5066   {
5067     __Pyx_BufFmt_StackElem __pyx_stack[1];
5068     if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_out.rcbuffer->pybuffer, (PyObject*)__pyx_t_5, &__Pyx_TypeInfo___pyx_t_double_complex, PyBUF_FORMAT| PyBUF_C_CONTIGUOUS, 1, 0, __pyx_stack) == -1)) {
5069       __pyx_v_out = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_pybuffernd_out.rcbuffer->pybuffer.buf = NULL;
5070       __PYX_ERR(0, 317, __pyx_L1_error)
5071     } else {__pyx_pybuffernd_out.diminfo[0].strides = __pyx_pybuffernd_out.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_out.diminfo[0].shape = __pyx_pybuffernd_out.rcbuffer->pybuffer.shape[0];
5072     }
5073   }
5074   __pyx_t_5 = 0;
5075   __pyx_v_out = ((PyArrayObject *)__pyx_t_4);
5076   __pyx_t_4 = 0;
5077 
5078   /* "qutip/cy/spmatfuncs.pyx":319
5079  *     cdef cnp.ndarray[complex, ndim=1, mode="c"] out = \
5080  *         np.zeros(nrows, dtype=complex)
5081  *     zspmvpy(&data[0], &ind[0], &ptr[0], &rho[0], 1.0, &out[0], nrows)             # <<<<<<<<<<<<<<
5082  *
5083  *     return out
5084  */
5085   __pyx_t_6 = 0;
5086   __pyx_t_7 = 0;
5087   __pyx_t_8 = 0;
5088   __pyx_t_9 = 0;
5089   __pyx_t_10 = 0;
5090   zspmvpy((&(*((__pyx_t_double_complex *) ( /* dim=0 */ ((char *) (((__pyx_t_double_complex *) __pyx_v_data.data) + __pyx_t_6)) )))), (&(*((int *) ( /* dim=0 */ ((char *) (((int *) __pyx_v_ind.data) + __pyx_t_7)) )))), (&(*((int *) ( /* dim=0 */ ((char *) (((int *) __pyx_v_ptr.data) + __pyx_t_8)) )))), (&(*((__pyx_t_double_complex *) ( /* dim=0 */ ((char *) (((__pyx_t_double_complex *) __pyx_v_rho.data) + __pyx_t_9)) )))), __pyx_t_double_complex_from_parts(1.0, 0), (&(*__Pyx_BufPtrCContig1d(__pyx_t_double_complex *, __pyx_pybuffernd_out.rcbuffer->pybuffer.buf, __pyx_t_10, __pyx_pybuffernd_out.diminfo[0].strides))), __pyx_v_nrows);
5091 
5092   /* "qutip/cy/spmatfuncs.pyx":321
5093  *     zspmvpy(&data[0], &ind[0], &ptr[0], &rho[0], 1.0, &out[0], nrows)
5094  *
5095  *     return out             # <<<<<<<<<<<<<<
5096  *
5097  *
5098  */
5099   __Pyx_XDECREF(((PyObject *)__pyx_r));
5100   __Pyx_INCREF(((PyObject *)__pyx_v_out));
5101   __pyx_r = ((PyArrayObject *)__pyx_v_out);
5102   goto __pyx_L0;
5103 
5104   /* "qutip/cy/spmatfuncs.pyx":309
5105  * @cython.boundscheck(False)
5106  * @cython.wraparound(False)
5107  * cpdef cnp.ndarray[complex, ndim=1, mode="c"] cy_ode_rhs(             # <<<<<<<<<<<<<<
5108  *         double t,
5109  *         complex[::1] rho,
5110  */
5111 
5112   /* function exit code */
5113   __pyx_L1_error:;
5114   __Pyx_XDECREF(__pyx_t_1);
5115   __Pyx_XDECREF(__pyx_t_2);
5116   __Pyx_XDECREF(__pyx_t_3);
5117   __Pyx_XDECREF(__pyx_t_4);
5118   { PyObject *__pyx_type, *__pyx_value, *__pyx_tb;
5119     __Pyx_PyThreadState_declare
5120     __Pyx_PyThreadState_assign
5121     __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb);
5122     __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_out.rcbuffer->pybuffer);
5123   __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}
5124   __Pyx_AddTraceback("qutip.cy.spmatfuncs.cy_ode_rhs", __pyx_clineno, __pyx_lineno, __pyx_filename);
5125   __pyx_r = 0;
5126   goto __pyx_L2;
5127   __pyx_L0:;
5128   __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_out.rcbuffer->pybuffer);
5129   __pyx_L2:;
5130   __Pyx_XDECREF((PyObject *)__pyx_v_out);
5131   __Pyx_XGIVEREF((PyObject *)__pyx_r);
5132   __Pyx_RefNannyFinishContext();
5133   return __pyx_r;
5134 }
5135 
5136 /* Python wrapper */
5137 static PyObject *__pyx_pw_5qutip_2cy_10spmatfuncs_17cy_ode_rhs(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
__pyx_pw_5qutip_2cy_10spmatfuncs_17cy_ode_rhs(PyObject * __pyx_self,PyObject * __pyx_args,PyObject * __pyx_kwds)5138 static PyObject *__pyx_pw_5qutip_2cy_10spmatfuncs_17cy_ode_rhs(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
5139   double __pyx_v_t;
5140   __Pyx_memviewslice __pyx_v_rho = { 0, 0, { 0 }, { 0 }, { 0 } };
5141   __Pyx_memviewslice __pyx_v_data = { 0, 0, { 0 }, { 0 }, { 0 } };
5142   __Pyx_memviewslice __pyx_v_ind = { 0, 0, { 0 }, { 0 }, { 0 } };
5143   __Pyx_memviewslice __pyx_v_ptr = { 0, 0, { 0 }, { 0 }, { 0 } };
5144   int __pyx_lineno = 0;
5145   const char *__pyx_filename = NULL;
5146   int __pyx_clineno = 0;
5147   PyObject *__pyx_r = 0;
5148   __Pyx_RefNannyDeclarations
5149   __Pyx_RefNannySetupContext("cy_ode_rhs (wrapper)", 0);
5150   {
5151     static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_t,&__pyx_n_s_rho,&__pyx_n_s_data,&__pyx_n_s_ind,&__pyx_n_s_ptr,0};
5152     PyObject* values[5] = {0,0,0,0,0};
5153     if (unlikely(__pyx_kwds)) {
5154       Py_ssize_t kw_args;
5155       const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
5156       switch (pos_args) {
5157         case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
5158         CYTHON_FALLTHROUGH;
5159         case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
5160         CYTHON_FALLTHROUGH;
5161         case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
5162         CYTHON_FALLTHROUGH;
5163         case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
5164         CYTHON_FALLTHROUGH;
5165         case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
5166         CYTHON_FALLTHROUGH;
5167         case  0: break;
5168         default: goto __pyx_L5_argtuple_error;
5169       }
5170       kw_args = PyDict_Size(__pyx_kwds);
5171       switch (pos_args) {
5172         case  0:
5173         if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_t)) != 0)) kw_args--;
5174         else goto __pyx_L5_argtuple_error;
5175         CYTHON_FALLTHROUGH;
5176         case  1:
5177         if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_rho)) != 0)) kw_args--;
5178         else {
5179           __Pyx_RaiseArgtupleInvalid("cy_ode_rhs", 1, 5, 5, 1); __PYX_ERR(0, 309, __pyx_L3_error)
5180         }
5181         CYTHON_FALLTHROUGH;
5182         case  2:
5183         if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_data)) != 0)) kw_args--;
5184         else {
5185           __Pyx_RaiseArgtupleInvalid("cy_ode_rhs", 1, 5, 5, 2); __PYX_ERR(0, 309, __pyx_L3_error)
5186         }
5187         CYTHON_FALLTHROUGH;
5188         case  3:
5189         if (likely((values[3] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_ind)) != 0)) kw_args--;
5190         else {
5191           __Pyx_RaiseArgtupleInvalid("cy_ode_rhs", 1, 5, 5, 3); __PYX_ERR(0, 309, __pyx_L3_error)
5192         }
5193         CYTHON_FALLTHROUGH;
5194         case  4:
5195         if (likely((values[4] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_ptr)) != 0)) kw_args--;
5196         else {
5197           __Pyx_RaiseArgtupleInvalid("cy_ode_rhs", 1, 5, 5, 4); __PYX_ERR(0, 309, __pyx_L3_error)
5198         }
5199       }
5200       if (unlikely(kw_args > 0)) {
5201         if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "cy_ode_rhs") < 0)) __PYX_ERR(0, 309, __pyx_L3_error)
5202       }
5203     } else if (PyTuple_GET_SIZE(__pyx_args) != 5) {
5204       goto __pyx_L5_argtuple_error;
5205     } else {
5206       values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
5207       values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
5208       values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
5209       values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
5210       values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
5211     }
5212     __pyx_v_t = __pyx_PyFloat_AsDouble(values[0]); if (unlikely((__pyx_v_t == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 310, __pyx_L3_error)
5213     __pyx_v_rho = __Pyx_PyObject_to_MemoryviewSlice_dc___pyx_t_double_complex(values[1], PyBUF_WRITABLE); if (unlikely(!__pyx_v_rho.memview)) __PYX_ERR(0, 311, __pyx_L3_error)
5214     __pyx_v_data = __Pyx_PyObject_to_MemoryviewSlice_dc___pyx_t_double_complex(values[2], PyBUF_WRITABLE); if (unlikely(!__pyx_v_data.memview)) __PYX_ERR(0, 312, __pyx_L3_error)
5215     __pyx_v_ind = __Pyx_PyObject_to_MemoryviewSlice_dc_int(values[3], PyBUF_WRITABLE); if (unlikely(!__pyx_v_ind.memview)) __PYX_ERR(0, 313, __pyx_L3_error)
5216     __pyx_v_ptr = __Pyx_PyObject_to_MemoryviewSlice_dc_int(values[4], PyBUF_WRITABLE); if (unlikely(!__pyx_v_ptr.memview)) __PYX_ERR(0, 314, __pyx_L3_error)
5217   }
5218   goto __pyx_L4_argument_unpacking_done;
5219   __pyx_L5_argtuple_error:;
5220   __Pyx_RaiseArgtupleInvalid("cy_ode_rhs", 1, 5, 5, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 309, __pyx_L3_error)
5221   __pyx_L3_error:;
5222   __Pyx_AddTraceback("qutip.cy.spmatfuncs.cy_ode_rhs", __pyx_clineno, __pyx_lineno, __pyx_filename);
5223   __Pyx_RefNannyFinishContext();
5224   return NULL;
5225   __pyx_L4_argument_unpacking_done:;
5226   __pyx_r = __pyx_pf_5qutip_2cy_10spmatfuncs_16cy_ode_rhs(__pyx_self, __pyx_v_t, __pyx_v_rho, __pyx_v_data, __pyx_v_ind, __pyx_v_ptr);
5227 
5228   /* function exit code */
5229   __Pyx_RefNannyFinishContext();
5230   return __pyx_r;
5231 }
5232 
__pyx_pf_5qutip_2cy_10spmatfuncs_16cy_ode_rhs(CYTHON_UNUSED PyObject * __pyx_self,double __pyx_v_t,__Pyx_memviewslice __pyx_v_rho,__Pyx_memviewslice __pyx_v_data,__Pyx_memviewslice __pyx_v_ind,__Pyx_memviewslice __pyx_v_ptr)5233 static PyObject *__pyx_pf_5qutip_2cy_10spmatfuncs_16cy_ode_rhs(CYTHON_UNUSED PyObject *__pyx_self, double __pyx_v_t, __Pyx_memviewslice __pyx_v_rho, __Pyx_memviewslice __pyx_v_data, __Pyx_memviewslice __pyx_v_ind, __Pyx_memviewslice __pyx_v_ptr) {
5234   PyObject *__pyx_r = NULL;
5235   __Pyx_RefNannyDeclarations
5236   PyObject *__pyx_t_1 = NULL;
5237   int __pyx_lineno = 0;
5238   const char *__pyx_filename = NULL;
5239   int __pyx_clineno = 0;
5240   __Pyx_RefNannySetupContext("cy_ode_rhs", 0);
5241   __Pyx_XDECREF(__pyx_r);
5242   if (unlikely(!__pyx_v_rho.memview)) { __Pyx_RaiseUnboundLocalError("rho"); __PYX_ERR(0, 309, __pyx_L1_error) }
5243   if (unlikely(!__pyx_v_data.memview)) { __Pyx_RaiseUnboundLocalError("data"); __PYX_ERR(0, 309, __pyx_L1_error) }
5244   if (unlikely(!__pyx_v_ind.memview)) { __Pyx_RaiseUnboundLocalError("ind"); __PYX_ERR(0, 309, __pyx_L1_error) }
5245   if (unlikely(!__pyx_v_ptr.memview)) { __Pyx_RaiseUnboundLocalError("ptr"); __PYX_ERR(0, 309, __pyx_L1_error) }
5246   __pyx_t_1 = ((PyObject *)__pyx_f_5qutip_2cy_10spmatfuncs_cy_ode_rhs(__pyx_v_t, __pyx_v_rho, __pyx_v_data, __pyx_v_ind, __pyx_v_ptr, 0)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 309, __pyx_L1_error)
5247   __Pyx_GOTREF(__pyx_t_1);
5248   __pyx_r = __pyx_t_1;
5249   __pyx_t_1 = 0;
5250   goto __pyx_L0;
5251 
5252   /* function exit code */
5253   __pyx_L1_error:;
5254   __Pyx_XDECREF(__pyx_t_1);
5255   __Pyx_AddTraceback("qutip.cy.spmatfuncs.cy_ode_rhs", __pyx_clineno, __pyx_lineno, __pyx_filename);
5256   __pyx_r = NULL;
5257   __pyx_L0:;
5258   __PYX_XDEC_MEMVIEW(&__pyx_v_rho, 1);
5259   __PYX_XDEC_MEMVIEW(&__pyx_v_data, 1);
5260   __PYX_XDEC_MEMVIEW(&__pyx_v_ind, 1);
5261   __PYX_XDEC_MEMVIEW(&__pyx_v_ptr, 1);
5262   __Pyx_XGIVEREF(__pyx_r);
5263   __Pyx_RefNannyFinishContext();
5264   return __pyx_r;
5265 }
5266 
5267 /* "qutip/cy/spmatfuncs.pyx":326
5268  * @cython.boundscheck(False)
5269  * @cython.wraparound(False)
5270  * cpdef cnp.ndarray[complex, ndim=1, mode="c"] cy_ode_psi_func_td(             # <<<<<<<<<<<<<<
5271  *         double t,
5272  *         cnp.ndarray[complex, ndim=1, mode="c"] psi,
5273  */
5274 
5275 static PyObject *__pyx_pw_5qutip_2cy_10spmatfuncs_19cy_ode_psi_func_td(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
__pyx_f_5qutip_2cy_10spmatfuncs_cy_ode_psi_func_td(double __pyx_v_t,PyArrayObject * __pyx_v_psi,PyObject * __pyx_v_H_func,PyObject * __pyx_v_args,CYTHON_UNUSED int __pyx_skip_dispatch)5276 static PyArrayObject *__pyx_f_5qutip_2cy_10spmatfuncs_cy_ode_psi_func_td(double __pyx_v_t, PyArrayObject *__pyx_v_psi, PyObject *__pyx_v_H_func, PyObject *__pyx_v_args, CYTHON_UNUSED int __pyx_skip_dispatch) {
5277   PyObject *__pyx_v_H = NULL;
5278   __Pyx_LocalBuf_ND __pyx_pybuffernd_psi;
5279   __Pyx_Buffer __pyx_pybuffer_psi;
5280   PyArrayObject *__pyx_r = NULL;
5281   __Pyx_RefNannyDeclarations
5282   PyObject *__pyx_t_1 = NULL;
5283   PyObject *__pyx_t_2 = NULL;
5284   PyObject *__pyx_t_3 = NULL;
5285   PyObject *__pyx_t_4 = NULL;
5286   int __pyx_t_5;
5287   PyObject *__pyx_t_6 = NULL;
5288   __pyx_t_double_complex __pyx_t_7;
5289   __Pyx_memviewslice __pyx_t_8 = { 0, 0, { 0 }, { 0 }, { 0 } };
5290   __Pyx_memviewslice __pyx_t_9 = { 0, 0, { 0 }, { 0 }, { 0 } };
5291   __Pyx_memviewslice __pyx_t_10 = { 0, 0, { 0 }, { 0 }, { 0 } };
5292   __Pyx_memviewslice __pyx_t_11 = { 0, 0, { 0 }, { 0 }, { 0 } };
5293   int __pyx_lineno = 0;
5294   const char *__pyx_filename = NULL;
5295   int __pyx_clineno = 0;
5296   __Pyx_RefNannySetupContext("cy_ode_psi_func_td", 0);
5297   __pyx_pybuffer_psi.pybuffer.buf = NULL;
5298   __pyx_pybuffer_psi.refcount = 0;
5299   __pyx_pybuffernd_psi.data = NULL;
5300   __pyx_pybuffernd_psi.rcbuffer = &__pyx_pybuffer_psi;
5301   {
5302     __Pyx_BufFmt_StackElem __pyx_stack[1];
5303     if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_psi.rcbuffer->pybuffer, (PyObject*)__pyx_v_psi, &__Pyx_TypeInfo___pyx_t_double_complex, PyBUF_FORMAT| PyBUF_C_CONTIGUOUS, 1, 0, __pyx_stack) == -1)) __PYX_ERR(0, 326, __pyx_L1_error)
5304   }
5305   __pyx_pybuffernd_psi.diminfo[0].strides = __pyx_pybuffernd_psi.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_psi.diminfo[0].shape = __pyx_pybuffernd_psi.rcbuffer->pybuffer.shape[0];
5306 
5307   /* "qutip/cy/spmatfuncs.pyx":332
5308  *         object args):
5309  *
5310  *     H = H_func(t, args).data             # <<<<<<<<<<<<<<
5311  *     return -1j * spmv_csr(H.data, H.indices, H.indptr, psi)
5312  *
5313  */
5314   __pyx_t_2 = PyFloat_FromDouble(__pyx_v_t); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 332, __pyx_L1_error)
5315   __Pyx_GOTREF(__pyx_t_2);
5316   __Pyx_INCREF(__pyx_v_H_func);
5317   __pyx_t_3 = __pyx_v_H_func; __pyx_t_4 = NULL;
5318   __pyx_t_5 = 0;
5319   if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
5320     __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
5321     if (likely(__pyx_t_4)) {
5322       PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
5323       __Pyx_INCREF(__pyx_t_4);
5324       __Pyx_INCREF(function);
5325       __Pyx_DECREF_SET(__pyx_t_3, function);
5326       __pyx_t_5 = 1;
5327     }
5328   }
5329   #if CYTHON_FAST_PYCALL
5330   if (PyFunction_Check(__pyx_t_3)) {
5331     PyObject *__pyx_temp[3] = {__pyx_t_4, __pyx_t_2, __pyx_v_args};
5332     __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_5, 2+__pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 332, __pyx_L1_error)
5333     __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
5334     __Pyx_GOTREF(__pyx_t_1);
5335     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
5336   } else
5337   #endif
5338   #if CYTHON_FAST_PYCCALL
5339   if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
5340     PyObject *__pyx_temp[3] = {__pyx_t_4, __pyx_t_2, __pyx_v_args};
5341     __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_5, 2+__pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 332, __pyx_L1_error)
5342     __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
5343     __Pyx_GOTREF(__pyx_t_1);
5344     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
5345   } else
5346   #endif
5347   {
5348     __pyx_t_6 = PyTuple_New(2+__pyx_t_5); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 332, __pyx_L1_error)
5349     __Pyx_GOTREF(__pyx_t_6);
5350     if (__pyx_t_4) {
5351       __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_4); __pyx_t_4 = NULL;
5352     }
5353     __Pyx_GIVEREF(__pyx_t_2);
5354     PyTuple_SET_ITEM(__pyx_t_6, 0+__pyx_t_5, __pyx_t_2);
5355     __Pyx_INCREF(__pyx_v_args);
5356     __Pyx_GIVEREF(__pyx_v_args);
5357     PyTuple_SET_ITEM(__pyx_t_6, 1+__pyx_t_5, __pyx_v_args);
5358     __pyx_t_2 = 0;
5359     __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_6, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 332, __pyx_L1_error)
5360     __Pyx_GOTREF(__pyx_t_1);
5361     __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
5362   }
5363   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
5364   __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_data); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 332, __pyx_L1_error)
5365   __Pyx_GOTREF(__pyx_t_3);
5366   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
5367   __pyx_v_H = __pyx_t_3;
5368   __pyx_t_3 = 0;
5369 
5370   /* "qutip/cy/spmatfuncs.pyx":333
5371  *
5372  *     H = H_func(t, args).data
5373  *     return -1j * spmv_csr(H.data, H.indices, H.indptr, psi)             # <<<<<<<<<<<<<<
5374  *
5375  *
5376  */
5377   __Pyx_XDECREF(((PyObject *)__pyx_r));
5378   __pyx_t_7 = __Pyx_c_neg_double(__pyx_t_double_complex_from_parts(0, 1.0));
5379   __pyx_t_3 = __pyx_PyComplex_FromComplex(__pyx_t_7); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 333, __pyx_L1_error)
5380   __Pyx_GOTREF(__pyx_t_3);
5381   __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_H, __pyx_n_s_data); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 333, __pyx_L1_error)
5382   __Pyx_GOTREF(__pyx_t_1);
5383   __pyx_t_8 = __Pyx_PyObject_to_MemoryviewSlice_dc___pyx_t_double_complex(__pyx_t_1, PyBUF_WRITABLE); if (unlikely(!__pyx_t_8.memview)) __PYX_ERR(0, 333, __pyx_L1_error)
5384   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
5385   __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_H, __pyx_n_s_indices); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 333, __pyx_L1_error)
5386   __Pyx_GOTREF(__pyx_t_1);
5387   __pyx_t_9 = __Pyx_PyObject_to_MemoryviewSlice_dc_int(__pyx_t_1, PyBUF_WRITABLE); if (unlikely(!__pyx_t_9.memview)) __PYX_ERR(0, 333, __pyx_L1_error)
5388   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
5389   __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_H, __pyx_n_s_indptr); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 333, __pyx_L1_error)
5390   __Pyx_GOTREF(__pyx_t_1);
5391   __pyx_t_10 = __Pyx_PyObject_to_MemoryviewSlice_dc_int(__pyx_t_1, PyBUF_WRITABLE); if (unlikely(!__pyx_t_10.memview)) __PYX_ERR(0, 333, __pyx_L1_error)
5392   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
5393   __pyx_t_11 = __Pyx_PyObject_to_MemoryviewSlice_dc___pyx_t_double_complex(((PyObject *)__pyx_v_psi), PyBUF_WRITABLE); if (unlikely(!__pyx_t_11.memview)) __PYX_ERR(0, 333, __pyx_L1_error)
5394   __pyx_t_1 = ((PyObject *)__pyx_f_5qutip_2cy_10spmatfuncs_spmv_csr(__pyx_t_8, __pyx_t_9, __pyx_t_10, __pyx_t_11, 0)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 333, __pyx_L1_error)
5395   __Pyx_GOTREF(__pyx_t_1);
5396   __PYX_XDEC_MEMVIEW(&__pyx_t_8, 1);
5397   __pyx_t_8.memview = NULL;
5398   __pyx_t_8.data = NULL;
5399   __PYX_XDEC_MEMVIEW(&__pyx_t_9, 1);
5400   __pyx_t_9.memview = NULL;
5401   __pyx_t_9.data = NULL;
5402   __PYX_XDEC_MEMVIEW(&__pyx_t_10, 1);
5403   __pyx_t_10.memview = NULL;
5404   __pyx_t_10.data = NULL;
5405   __PYX_XDEC_MEMVIEW(&__pyx_t_11, 1);
5406   __pyx_t_11.memview = NULL;
5407   __pyx_t_11.data = NULL;
5408   __pyx_t_6 = PyNumber_Multiply(__pyx_t_3, __pyx_t_1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 333, __pyx_L1_error)
5409   __Pyx_GOTREF(__pyx_t_6);
5410   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
5411   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
5412   if (!(likely(((__pyx_t_6) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_6, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 333, __pyx_L1_error)
5413   __pyx_r = ((PyArrayObject *)__pyx_t_6);
5414   __pyx_t_6 = 0;
5415   goto __pyx_L0;
5416 
5417   /* "qutip/cy/spmatfuncs.pyx":326
5418  * @cython.boundscheck(False)
5419  * @cython.wraparound(False)
5420  * cpdef cnp.ndarray[complex, ndim=1, mode="c"] cy_ode_psi_func_td(             # <<<<<<<<<<<<<<
5421  *         double t,
5422  *         cnp.ndarray[complex, ndim=1, mode="c"] psi,
5423  */
5424 
5425   /* function exit code */
5426   __pyx_L1_error:;
5427   __Pyx_XDECREF(__pyx_t_1);
5428   __Pyx_XDECREF(__pyx_t_2);
5429   __Pyx_XDECREF(__pyx_t_3);
5430   __Pyx_XDECREF(__pyx_t_4);
5431   __Pyx_XDECREF(__pyx_t_6);
5432   __PYX_XDEC_MEMVIEW(&__pyx_t_8, 1);
5433   __PYX_XDEC_MEMVIEW(&__pyx_t_9, 1);
5434   __PYX_XDEC_MEMVIEW(&__pyx_t_10, 1);
5435   __PYX_XDEC_MEMVIEW(&__pyx_t_11, 1);
5436   { PyObject *__pyx_type, *__pyx_value, *__pyx_tb;
5437     __Pyx_PyThreadState_declare
5438     __Pyx_PyThreadState_assign
5439     __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb);
5440     __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_psi.rcbuffer->pybuffer);
5441   __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}
5442   __Pyx_AddTraceback("qutip.cy.spmatfuncs.cy_ode_psi_func_td", __pyx_clineno, __pyx_lineno, __pyx_filename);
5443   __pyx_r = 0;
5444   goto __pyx_L2;
5445   __pyx_L0:;
5446   __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_psi.rcbuffer->pybuffer);
5447   __pyx_L2:;
5448   __Pyx_XDECREF(__pyx_v_H);
5449   __Pyx_XGIVEREF((PyObject *)__pyx_r);
5450   __Pyx_RefNannyFinishContext();
5451   return __pyx_r;
5452 }
5453 
5454 /* Python wrapper */
5455 static PyObject *__pyx_pw_5qutip_2cy_10spmatfuncs_19cy_ode_psi_func_td(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
__pyx_pw_5qutip_2cy_10spmatfuncs_19cy_ode_psi_func_td(PyObject * __pyx_self,PyObject * __pyx_args,PyObject * __pyx_kwds)5456 static PyObject *__pyx_pw_5qutip_2cy_10spmatfuncs_19cy_ode_psi_func_td(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
5457   double __pyx_v_t;
5458   PyArrayObject *__pyx_v_psi = 0;
5459   PyObject *__pyx_v_H_func = 0;
5460   PyObject *__pyx_v_args = 0;
5461   int __pyx_lineno = 0;
5462   const char *__pyx_filename = NULL;
5463   int __pyx_clineno = 0;
5464   PyObject *__pyx_r = 0;
5465   __Pyx_RefNannyDeclarations
5466   __Pyx_RefNannySetupContext("cy_ode_psi_func_td (wrapper)", 0);
5467   {
5468     static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_t,&__pyx_n_s_psi,&__pyx_n_s_H_func,&__pyx_n_s_args,0};
5469     PyObject* values[4] = {0,0,0,0};
5470     if (unlikely(__pyx_kwds)) {
5471       Py_ssize_t kw_args;
5472       const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
5473       switch (pos_args) {
5474         case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
5475         CYTHON_FALLTHROUGH;
5476         case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
5477         CYTHON_FALLTHROUGH;
5478         case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
5479         CYTHON_FALLTHROUGH;
5480         case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
5481         CYTHON_FALLTHROUGH;
5482         case  0: break;
5483         default: goto __pyx_L5_argtuple_error;
5484       }
5485       kw_args = PyDict_Size(__pyx_kwds);
5486       switch (pos_args) {
5487         case  0:
5488         if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_t)) != 0)) kw_args--;
5489         else goto __pyx_L5_argtuple_error;
5490         CYTHON_FALLTHROUGH;
5491         case  1:
5492         if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_psi)) != 0)) kw_args--;
5493         else {
5494           __Pyx_RaiseArgtupleInvalid("cy_ode_psi_func_td", 1, 4, 4, 1); __PYX_ERR(0, 326, __pyx_L3_error)
5495         }
5496         CYTHON_FALLTHROUGH;
5497         case  2:
5498         if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_H_func)) != 0)) kw_args--;
5499         else {
5500           __Pyx_RaiseArgtupleInvalid("cy_ode_psi_func_td", 1, 4, 4, 2); __PYX_ERR(0, 326, __pyx_L3_error)
5501         }
5502         CYTHON_FALLTHROUGH;
5503         case  3:
5504         if (likely((values[3] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_args)) != 0)) kw_args--;
5505         else {
5506           __Pyx_RaiseArgtupleInvalid("cy_ode_psi_func_td", 1, 4, 4, 3); __PYX_ERR(0, 326, __pyx_L3_error)
5507         }
5508       }
5509       if (unlikely(kw_args > 0)) {
5510         if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "cy_ode_psi_func_td") < 0)) __PYX_ERR(0, 326, __pyx_L3_error)
5511       }
5512     } else if (PyTuple_GET_SIZE(__pyx_args) != 4) {
5513       goto __pyx_L5_argtuple_error;
5514     } else {
5515       values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
5516       values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
5517       values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
5518       values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
5519     }
5520     __pyx_v_t = __pyx_PyFloat_AsDouble(values[0]); if (unlikely((__pyx_v_t == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 327, __pyx_L3_error)
5521     __pyx_v_psi = ((PyArrayObject *)values[1]);
5522     __pyx_v_H_func = values[2];
5523     __pyx_v_args = values[3];
5524   }
5525   goto __pyx_L4_argument_unpacking_done;
5526   __pyx_L5_argtuple_error:;
5527   __Pyx_RaiseArgtupleInvalid("cy_ode_psi_func_td", 1, 4, 4, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 326, __pyx_L3_error)
5528   __pyx_L3_error:;
5529   __Pyx_AddTraceback("qutip.cy.spmatfuncs.cy_ode_psi_func_td", __pyx_clineno, __pyx_lineno, __pyx_filename);
5530   __Pyx_RefNannyFinishContext();
5531   return NULL;
5532   __pyx_L4_argument_unpacking_done:;
5533   if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_psi), __pyx_ptype_5numpy_ndarray, 1, "psi", 0))) __PYX_ERR(0, 328, __pyx_L1_error)
5534   __pyx_r = __pyx_pf_5qutip_2cy_10spmatfuncs_18cy_ode_psi_func_td(__pyx_self, __pyx_v_t, __pyx_v_psi, __pyx_v_H_func, __pyx_v_args);
5535 
5536   /* function exit code */
5537   goto __pyx_L0;
5538   __pyx_L1_error:;
5539   __pyx_r = NULL;
5540   __pyx_L0:;
5541   __Pyx_RefNannyFinishContext();
5542   return __pyx_r;
5543 }
5544 
__pyx_pf_5qutip_2cy_10spmatfuncs_18cy_ode_psi_func_td(CYTHON_UNUSED PyObject * __pyx_self,double __pyx_v_t,PyArrayObject * __pyx_v_psi,PyObject * __pyx_v_H_func,PyObject * __pyx_v_args)5545 static PyObject *__pyx_pf_5qutip_2cy_10spmatfuncs_18cy_ode_psi_func_td(CYTHON_UNUSED PyObject *__pyx_self, double __pyx_v_t, PyArrayObject *__pyx_v_psi, PyObject *__pyx_v_H_func, PyObject *__pyx_v_args) {
5546   __Pyx_LocalBuf_ND __pyx_pybuffernd_psi;
5547   __Pyx_Buffer __pyx_pybuffer_psi;
5548   PyObject *__pyx_r = NULL;
5549   __Pyx_RefNannyDeclarations
5550   PyObject *__pyx_t_1 = NULL;
5551   int __pyx_lineno = 0;
5552   const char *__pyx_filename = NULL;
5553   int __pyx_clineno = 0;
5554   __Pyx_RefNannySetupContext("cy_ode_psi_func_td", 0);
5555   __pyx_pybuffer_psi.pybuffer.buf = NULL;
5556   __pyx_pybuffer_psi.refcount = 0;
5557   __pyx_pybuffernd_psi.data = NULL;
5558   __pyx_pybuffernd_psi.rcbuffer = &__pyx_pybuffer_psi;
5559   {
5560     __Pyx_BufFmt_StackElem __pyx_stack[1];
5561     if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_psi.rcbuffer->pybuffer, (PyObject*)__pyx_v_psi, &__Pyx_TypeInfo___pyx_t_double_complex, PyBUF_FORMAT| PyBUF_C_CONTIGUOUS, 1, 0, __pyx_stack) == -1)) __PYX_ERR(0, 326, __pyx_L1_error)
5562   }
5563   __pyx_pybuffernd_psi.diminfo[0].strides = __pyx_pybuffernd_psi.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_psi.diminfo[0].shape = __pyx_pybuffernd_psi.rcbuffer->pybuffer.shape[0];
5564   __Pyx_XDECREF(__pyx_r);
5565   __pyx_t_1 = ((PyObject *)__pyx_f_5qutip_2cy_10spmatfuncs_cy_ode_psi_func_td(__pyx_v_t, __pyx_v_psi, __pyx_v_H_func, __pyx_v_args, 0)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 326, __pyx_L1_error)
5566   __Pyx_GOTREF(__pyx_t_1);
5567   __pyx_r = __pyx_t_1;
5568   __pyx_t_1 = 0;
5569   goto __pyx_L0;
5570 
5571   /* function exit code */
5572   __pyx_L1_error:;
5573   __Pyx_XDECREF(__pyx_t_1);
5574   { PyObject *__pyx_type, *__pyx_value, *__pyx_tb;
5575     __Pyx_PyThreadState_declare
5576     __Pyx_PyThreadState_assign
5577     __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb);
5578     __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_psi.rcbuffer->pybuffer);
5579   __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}
5580   __Pyx_AddTraceback("qutip.cy.spmatfuncs.cy_ode_psi_func_td", __pyx_clineno, __pyx_lineno, __pyx_filename);
5581   __pyx_r = NULL;
5582   goto __pyx_L2;
5583   __pyx_L0:;
5584   __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_psi.rcbuffer->pybuffer);
5585   __pyx_L2:;
5586   __Pyx_XGIVEREF(__pyx_r);
5587   __Pyx_RefNannyFinishContext();
5588   return __pyx_r;
5589 }
5590 
5591 /* "qutip/cy/spmatfuncs.pyx":338
5592  * @cython.boundscheck(False)
5593  * @cython.wraparound(False)
5594  * cpdef cnp.ndarray[complex, ndim=1, mode="c"] cy_ode_psi_func_td_with_state(             # <<<<<<<<<<<<<<
5595  *         double t,
5596  *         cnp.ndarray[complex, ndim=1, mode="c"] psi,
5597  */
5598 
5599 static PyObject *__pyx_pw_5qutip_2cy_10spmatfuncs_21cy_ode_psi_func_td_with_state(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
__pyx_f_5qutip_2cy_10spmatfuncs_cy_ode_psi_func_td_with_state(double __pyx_v_t,PyArrayObject * __pyx_v_psi,PyObject * __pyx_v_H_func,PyObject * __pyx_v_args,CYTHON_UNUSED int __pyx_skip_dispatch)5600 static PyArrayObject *__pyx_f_5qutip_2cy_10spmatfuncs_cy_ode_psi_func_td_with_state(double __pyx_v_t, PyArrayObject *__pyx_v_psi, PyObject *__pyx_v_H_func, PyObject *__pyx_v_args, CYTHON_UNUSED int __pyx_skip_dispatch) {
5601   PyObject *__pyx_v_H = NULL;
5602   __Pyx_LocalBuf_ND __pyx_pybuffernd_psi;
5603   __Pyx_Buffer __pyx_pybuffer_psi;
5604   PyArrayObject *__pyx_r = NULL;
5605   __Pyx_RefNannyDeclarations
5606   PyObject *__pyx_t_1 = NULL;
5607   PyObject *__pyx_t_2 = NULL;
5608   PyObject *__pyx_t_3 = NULL;
5609   PyObject *__pyx_t_4 = NULL;
5610   int __pyx_t_5;
5611   PyObject *__pyx_t_6 = NULL;
5612   __pyx_t_double_complex __pyx_t_7;
5613   __Pyx_memviewslice __pyx_t_8 = { 0, 0, { 0 }, { 0 }, { 0 } };
5614   __Pyx_memviewslice __pyx_t_9 = { 0, 0, { 0 }, { 0 }, { 0 } };
5615   __Pyx_memviewslice __pyx_t_10 = { 0, 0, { 0 }, { 0 }, { 0 } };
5616   __Pyx_memviewslice __pyx_t_11 = { 0, 0, { 0 }, { 0 }, { 0 } };
5617   int __pyx_lineno = 0;
5618   const char *__pyx_filename = NULL;
5619   int __pyx_clineno = 0;
5620   __Pyx_RefNannySetupContext("cy_ode_psi_func_td_with_state", 0);
5621   __pyx_pybuffer_psi.pybuffer.buf = NULL;
5622   __pyx_pybuffer_psi.refcount = 0;
5623   __pyx_pybuffernd_psi.data = NULL;
5624   __pyx_pybuffernd_psi.rcbuffer = &__pyx_pybuffer_psi;
5625   {
5626     __Pyx_BufFmt_StackElem __pyx_stack[1];
5627     if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_psi.rcbuffer->pybuffer, (PyObject*)__pyx_v_psi, &__Pyx_TypeInfo___pyx_t_double_complex, PyBUF_FORMAT| PyBUF_C_CONTIGUOUS, 1, 0, __pyx_stack) == -1)) __PYX_ERR(0, 338, __pyx_L1_error)
5628   }
5629   __pyx_pybuffernd_psi.diminfo[0].strides = __pyx_pybuffernd_psi.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_psi.diminfo[0].shape = __pyx_pybuffernd_psi.rcbuffer->pybuffer.shape[0];
5630 
5631   /* "qutip/cy/spmatfuncs.pyx":344
5632  *         object args):
5633  *
5634  *     H = H_func(t, psi, args)             # <<<<<<<<<<<<<<
5635  *     return -1j * spmv_csr(H.data, H.indices, H.indptr, psi)
5636  *
5637  */
5638   __pyx_t_2 = PyFloat_FromDouble(__pyx_v_t); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 344, __pyx_L1_error)
5639   __Pyx_GOTREF(__pyx_t_2);
5640   __Pyx_INCREF(__pyx_v_H_func);
5641   __pyx_t_3 = __pyx_v_H_func; __pyx_t_4 = NULL;
5642   __pyx_t_5 = 0;
5643   if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
5644     __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
5645     if (likely(__pyx_t_4)) {
5646       PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
5647       __Pyx_INCREF(__pyx_t_4);
5648       __Pyx_INCREF(function);
5649       __Pyx_DECREF_SET(__pyx_t_3, function);
5650       __pyx_t_5 = 1;
5651     }
5652   }
5653   #if CYTHON_FAST_PYCALL
5654   if (PyFunction_Check(__pyx_t_3)) {
5655     PyObject *__pyx_temp[4] = {__pyx_t_4, __pyx_t_2, ((PyObject *)__pyx_v_psi), __pyx_v_args};
5656     __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_5, 3+__pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 344, __pyx_L1_error)
5657     __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
5658     __Pyx_GOTREF(__pyx_t_1);
5659     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
5660   } else
5661   #endif
5662   #if CYTHON_FAST_PYCCALL
5663   if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
5664     PyObject *__pyx_temp[4] = {__pyx_t_4, __pyx_t_2, ((PyObject *)__pyx_v_psi), __pyx_v_args};
5665     __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_5, 3+__pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 344, __pyx_L1_error)
5666     __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
5667     __Pyx_GOTREF(__pyx_t_1);
5668     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
5669   } else
5670   #endif
5671   {
5672     __pyx_t_6 = PyTuple_New(3+__pyx_t_5); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 344, __pyx_L1_error)
5673     __Pyx_GOTREF(__pyx_t_6);
5674     if (__pyx_t_4) {
5675       __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_4); __pyx_t_4 = NULL;
5676     }
5677     __Pyx_GIVEREF(__pyx_t_2);
5678     PyTuple_SET_ITEM(__pyx_t_6, 0+__pyx_t_5, __pyx_t_2);
5679     __Pyx_INCREF(((PyObject *)__pyx_v_psi));
5680     __Pyx_GIVEREF(((PyObject *)__pyx_v_psi));
5681     PyTuple_SET_ITEM(__pyx_t_6, 1+__pyx_t_5, ((PyObject *)__pyx_v_psi));
5682     __Pyx_INCREF(__pyx_v_args);
5683     __Pyx_GIVEREF(__pyx_v_args);
5684     PyTuple_SET_ITEM(__pyx_t_6, 2+__pyx_t_5, __pyx_v_args);
5685     __pyx_t_2 = 0;
5686     __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_6, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 344, __pyx_L1_error)
5687     __Pyx_GOTREF(__pyx_t_1);
5688     __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
5689   }
5690   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
5691   __pyx_v_H = __pyx_t_1;
5692   __pyx_t_1 = 0;
5693 
5694   /* "qutip/cy/spmatfuncs.pyx":345
5695  *
5696  *     H = H_func(t, psi, args)
5697  *     return -1j * spmv_csr(H.data, H.indices, H.indptr, psi)             # <<<<<<<<<<<<<<
5698  *
5699  *
5700  */
5701   __Pyx_XDECREF(((PyObject *)__pyx_r));
5702   __pyx_t_7 = __Pyx_c_neg_double(__pyx_t_double_complex_from_parts(0, 1.0));
5703   __pyx_t_1 = __pyx_PyComplex_FromComplex(__pyx_t_7); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 345, __pyx_L1_error)
5704   __Pyx_GOTREF(__pyx_t_1);
5705   __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_H, __pyx_n_s_data); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 345, __pyx_L1_error)
5706   __Pyx_GOTREF(__pyx_t_3);
5707   __pyx_t_8 = __Pyx_PyObject_to_MemoryviewSlice_dc___pyx_t_double_complex(__pyx_t_3, PyBUF_WRITABLE); if (unlikely(!__pyx_t_8.memview)) __PYX_ERR(0, 345, __pyx_L1_error)
5708   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
5709   __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_H, __pyx_n_s_indices); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 345, __pyx_L1_error)
5710   __Pyx_GOTREF(__pyx_t_3);
5711   __pyx_t_9 = __Pyx_PyObject_to_MemoryviewSlice_dc_int(__pyx_t_3, PyBUF_WRITABLE); if (unlikely(!__pyx_t_9.memview)) __PYX_ERR(0, 345, __pyx_L1_error)
5712   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
5713   __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_H, __pyx_n_s_indptr); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 345, __pyx_L1_error)
5714   __Pyx_GOTREF(__pyx_t_3);
5715   __pyx_t_10 = __Pyx_PyObject_to_MemoryviewSlice_dc_int(__pyx_t_3, PyBUF_WRITABLE); if (unlikely(!__pyx_t_10.memview)) __PYX_ERR(0, 345, __pyx_L1_error)
5716   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
5717   __pyx_t_11 = __Pyx_PyObject_to_MemoryviewSlice_dc___pyx_t_double_complex(((PyObject *)__pyx_v_psi), PyBUF_WRITABLE); if (unlikely(!__pyx_t_11.memview)) __PYX_ERR(0, 345, __pyx_L1_error)
5718   __pyx_t_3 = ((PyObject *)__pyx_f_5qutip_2cy_10spmatfuncs_spmv_csr(__pyx_t_8, __pyx_t_9, __pyx_t_10, __pyx_t_11, 0)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 345, __pyx_L1_error)
5719   __Pyx_GOTREF(__pyx_t_3);
5720   __PYX_XDEC_MEMVIEW(&__pyx_t_8, 1);
5721   __pyx_t_8.memview = NULL;
5722   __pyx_t_8.data = NULL;
5723   __PYX_XDEC_MEMVIEW(&__pyx_t_9, 1);
5724   __pyx_t_9.memview = NULL;
5725   __pyx_t_9.data = NULL;
5726   __PYX_XDEC_MEMVIEW(&__pyx_t_10, 1);
5727   __pyx_t_10.memview = NULL;
5728   __pyx_t_10.data = NULL;
5729   __PYX_XDEC_MEMVIEW(&__pyx_t_11, 1);
5730   __pyx_t_11.memview = NULL;
5731   __pyx_t_11.data = NULL;
5732   __pyx_t_6 = PyNumber_Multiply(__pyx_t_1, __pyx_t_3); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 345, __pyx_L1_error)
5733   __Pyx_GOTREF(__pyx_t_6);
5734   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
5735   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
5736   if (!(likely(((__pyx_t_6) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_6, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 345, __pyx_L1_error)
5737   __pyx_r = ((PyArrayObject *)__pyx_t_6);
5738   __pyx_t_6 = 0;
5739   goto __pyx_L0;
5740 
5741   /* "qutip/cy/spmatfuncs.pyx":338
5742  * @cython.boundscheck(False)
5743  * @cython.wraparound(False)
5744  * cpdef cnp.ndarray[complex, ndim=1, mode="c"] cy_ode_psi_func_td_with_state(             # <<<<<<<<<<<<<<
5745  *         double t,
5746  *         cnp.ndarray[complex, ndim=1, mode="c"] psi,
5747  */
5748 
5749   /* function exit code */
5750   __pyx_L1_error:;
5751   __Pyx_XDECREF(__pyx_t_1);
5752   __Pyx_XDECREF(__pyx_t_2);
5753   __Pyx_XDECREF(__pyx_t_3);
5754   __Pyx_XDECREF(__pyx_t_4);
5755   __Pyx_XDECREF(__pyx_t_6);
5756   __PYX_XDEC_MEMVIEW(&__pyx_t_8, 1);
5757   __PYX_XDEC_MEMVIEW(&__pyx_t_9, 1);
5758   __PYX_XDEC_MEMVIEW(&__pyx_t_10, 1);
5759   __PYX_XDEC_MEMVIEW(&__pyx_t_11, 1);
5760   { PyObject *__pyx_type, *__pyx_value, *__pyx_tb;
5761     __Pyx_PyThreadState_declare
5762     __Pyx_PyThreadState_assign
5763     __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb);
5764     __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_psi.rcbuffer->pybuffer);
5765   __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}
5766   __Pyx_AddTraceback("qutip.cy.spmatfuncs.cy_ode_psi_func_td_with_state", __pyx_clineno, __pyx_lineno, __pyx_filename);
5767   __pyx_r = 0;
5768   goto __pyx_L2;
5769   __pyx_L0:;
5770   __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_psi.rcbuffer->pybuffer);
5771   __pyx_L2:;
5772   __Pyx_XDECREF(__pyx_v_H);
5773   __Pyx_XGIVEREF((PyObject *)__pyx_r);
5774   __Pyx_RefNannyFinishContext();
5775   return __pyx_r;
5776 }
5777 
5778 /* Python wrapper */
5779 static PyObject *__pyx_pw_5qutip_2cy_10spmatfuncs_21cy_ode_psi_func_td_with_state(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
__pyx_pw_5qutip_2cy_10spmatfuncs_21cy_ode_psi_func_td_with_state(PyObject * __pyx_self,PyObject * __pyx_args,PyObject * __pyx_kwds)5780 static PyObject *__pyx_pw_5qutip_2cy_10spmatfuncs_21cy_ode_psi_func_td_with_state(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
5781   double __pyx_v_t;
5782   PyArrayObject *__pyx_v_psi = 0;
5783   PyObject *__pyx_v_H_func = 0;
5784   PyObject *__pyx_v_args = 0;
5785   int __pyx_lineno = 0;
5786   const char *__pyx_filename = NULL;
5787   int __pyx_clineno = 0;
5788   PyObject *__pyx_r = 0;
5789   __Pyx_RefNannyDeclarations
5790   __Pyx_RefNannySetupContext("cy_ode_psi_func_td_with_state (wrapper)", 0);
5791   {
5792     static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_t,&__pyx_n_s_psi,&__pyx_n_s_H_func,&__pyx_n_s_args,0};
5793     PyObject* values[4] = {0,0,0,0};
5794     if (unlikely(__pyx_kwds)) {
5795       Py_ssize_t kw_args;
5796       const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
5797       switch (pos_args) {
5798         case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
5799         CYTHON_FALLTHROUGH;
5800         case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
5801         CYTHON_FALLTHROUGH;
5802         case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
5803         CYTHON_FALLTHROUGH;
5804         case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
5805         CYTHON_FALLTHROUGH;
5806         case  0: break;
5807         default: goto __pyx_L5_argtuple_error;
5808       }
5809       kw_args = PyDict_Size(__pyx_kwds);
5810       switch (pos_args) {
5811         case  0:
5812         if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_t)) != 0)) kw_args--;
5813         else goto __pyx_L5_argtuple_error;
5814         CYTHON_FALLTHROUGH;
5815         case  1:
5816         if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_psi)) != 0)) kw_args--;
5817         else {
5818           __Pyx_RaiseArgtupleInvalid("cy_ode_psi_func_td_with_state", 1, 4, 4, 1); __PYX_ERR(0, 338, __pyx_L3_error)
5819         }
5820         CYTHON_FALLTHROUGH;
5821         case  2:
5822         if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_H_func)) != 0)) kw_args--;
5823         else {
5824           __Pyx_RaiseArgtupleInvalid("cy_ode_psi_func_td_with_state", 1, 4, 4, 2); __PYX_ERR(0, 338, __pyx_L3_error)
5825         }
5826         CYTHON_FALLTHROUGH;
5827         case  3:
5828         if (likely((values[3] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_args)) != 0)) kw_args--;
5829         else {
5830           __Pyx_RaiseArgtupleInvalid("cy_ode_psi_func_td_with_state", 1, 4, 4, 3); __PYX_ERR(0, 338, __pyx_L3_error)
5831         }
5832       }
5833       if (unlikely(kw_args > 0)) {
5834         if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "cy_ode_psi_func_td_with_state") < 0)) __PYX_ERR(0, 338, __pyx_L3_error)
5835       }
5836     } else if (PyTuple_GET_SIZE(__pyx_args) != 4) {
5837       goto __pyx_L5_argtuple_error;
5838     } else {
5839       values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
5840       values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
5841       values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
5842       values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
5843     }
5844     __pyx_v_t = __pyx_PyFloat_AsDouble(values[0]); if (unlikely((__pyx_v_t == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 339, __pyx_L3_error)
5845     __pyx_v_psi = ((PyArrayObject *)values[1]);
5846     __pyx_v_H_func = values[2];
5847     __pyx_v_args = values[3];
5848   }
5849   goto __pyx_L4_argument_unpacking_done;
5850   __pyx_L5_argtuple_error:;
5851   __Pyx_RaiseArgtupleInvalid("cy_ode_psi_func_td_with_state", 1, 4, 4, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 338, __pyx_L3_error)
5852   __pyx_L3_error:;
5853   __Pyx_AddTraceback("qutip.cy.spmatfuncs.cy_ode_psi_func_td_with_state", __pyx_clineno, __pyx_lineno, __pyx_filename);
5854   __Pyx_RefNannyFinishContext();
5855   return NULL;
5856   __pyx_L4_argument_unpacking_done:;
5857   if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_psi), __pyx_ptype_5numpy_ndarray, 1, "psi", 0))) __PYX_ERR(0, 340, __pyx_L1_error)
5858   __pyx_r = __pyx_pf_5qutip_2cy_10spmatfuncs_20cy_ode_psi_func_td_with_state(__pyx_self, __pyx_v_t, __pyx_v_psi, __pyx_v_H_func, __pyx_v_args);
5859 
5860   /* function exit code */
5861   goto __pyx_L0;
5862   __pyx_L1_error:;
5863   __pyx_r = NULL;
5864   __pyx_L0:;
5865   __Pyx_RefNannyFinishContext();
5866   return __pyx_r;
5867 }
5868 
__pyx_pf_5qutip_2cy_10spmatfuncs_20cy_ode_psi_func_td_with_state(CYTHON_UNUSED PyObject * __pyx_self,double __pyx_v_t,PyArrayObject * __pyx_v_psi,PyObject * __pyx_v_H_func,PyObject * __pyx_v_args)5869 static PyObject *__pyx_pf_5qutip_2cy_10spmatfuncs_20cy_ode_psi_func_td_with_state(CYTHON_UNUSED PyObject *__pyx_self, double __pyx_v_t, PyArrayObject *__pyx_v_psi, PyObject *__pyx_v_H_func, PyObject *__pyx_v_args) {
5870   __Pyx_LocalBuf_ND __pyx_pybuffernd_psi;
5871   __Pyx_Buffer __pyx_pybuffer_psi;
5872   PyObject *__pyx_r = NULL;
5873   __Pyx_RefNannyDeclarations
5874   PyObject *__pyx_t_1 = NULL;
5875   int __pyx_lineno = 0;
5876   const char *__pyx_filename = NULL;
5877   int __pyx_clineno = 0;
5878   __Pyx_RefNannySetupContext("cy_ode_psi_func_td_with_state", 0);
5879   __pyx_pybuffer_psi.pybuffer.buf = NULL;
5880   __pyx_pybuffer_psi.refcount = 0;
5881   __pyx_pybuffernd_psi.data = NULL;
5882   __pyx_pybuffernd_psi.rcbuffer = &__pyx_pybuffer_psi;
5883   {
5884     __Pyx_BufFmt_StackElem __pyx_stack[1];
5885     if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_psi.rcbuffer->pybuffer, (PyObject*)__pyx_v_psi, &__Pyx_TypeInfo___pyx_t_double_complex, PyBUF_FORMAT| PyBUF_C_CONTIGUOUS, 1, 0, __pyx_stack) == -1)) __PYX_ERR(0, 338, __pyx_L1_error)
5886   }
5887   __pyx_pybuffernd_psi.diminfo[0].strides = __pyx_pybuffernd_psi.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_psi.diminfo[0].shape = __pyx_pybuffernd_psi.rcbuffer->pybuffer.shape[0];
5888   __Pyx_XDECREF(__pyx_r);
5889   __pyx_t_1 = ((PyObject *)__pyx_f_5qutip_2cy_10spmatfuncs_cy_ode_psi_func_td_with_state(__pyx_v_t, __pyx_v_psi, __pyx_v_H_func, __pyx_v_args, 0)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 338, __pyx_L1_error)
5890   __Pyx_GOTREF(__pyx_t_1);
5891   __pyx_r = __pyx_t_1;
5892   __pyx_t_1 = 0;
5893   goto __pyx_L0;
5894 
5895   /* function exit code */
5896   __pyx_L1_error:;
5897   __Pyx_XDECREF(__pyx_t_1);
5898   { PyObject *__pyx_type, *__pyx_value, *__pyx_tb;
5899     __Pyx_PyThreadState_declare
5900     __Pyx_PyThreadState_assign
5901     __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb);
5902     __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_psi.rcbuffer->pybuffer);
5903   __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}
5904   __Pyx_AddTraceback("qutip.cy.spmatfuncs.cy_ode_psi_func_td_with_state", __pyx_clineno, __pyx_lineno, __pyx_filename);
5905   __pyx_r = NULL;
5906   goto __pyx_L2;
5907   __pyx_L0:;
5908   __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_psi.rcbuffer->pybuffer);
5909   __pyx_L2:;
5910   __Pyx_XGIVEREF(__pyx_r);
5911   __Pyx_RefNannyFinishContext();
5912   return __pyx_r;
5913 }
5914 
5915 /* "qutip/cy/spmatfuncs.pyx":350
5916  * @cython.boundscheck(False)
5917  * @cython.wraparound(False)
5918  * cpdef cnp.ndarray[complex, ndim=1, mode="c"] cy_ode_rho_func_td(             # <<<<<<<<<<<<<<
5919  *         double t,
5920  *         cnp.ndarray[complex, ndim=1, mode="c"] rho,
5921  */
5922 
5923 static PyObject *__pyx_pw_5qutip_2cy_10spmatfuncs_23cy_ode_rho_func_td(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
__pyx_f_5qutip_2cy_10spmatfuncs_cy_ode_rho_func_td(double __pyx_v_t,PyArrayObject * __pyx_v_rho,PyObject * __pyx_v_L0,PyObject * __pyx_v_L_func,PyObject * __pyx_v_args,CYTHON_UNUSED int __pyx_skip_dispatch)5924 static PyArrayObject *__pyx_f_5qutip_2cy_10spmatfuncs_cy_ode_rho_func_td(double __pyx_v_t, PyArrayObject *__pyx_v_rho, PyObject *__pyx_v_L0, PyObject *__pyx_v_L_func, PyObject *__pyx_v_args, CYTHON_UNUSED int __pyx_skip_dispatch) {
5925   PyObject *__pyx_v_L = 0;
5926   __Pyx_LocalBuf_ND __pyx_pybuffernd_rho;
5927   __Pyx_Buffer __pyx_pybuffer_rho;
5928   PyArrayObject *__pyx_r = NULL;
5929   __Pyx_RefNannyDeclarations
5930   PyObject *__pyx_t_1 = NULL;
5931   PyObject *__pyx_t_2 = NULL;
5932   PyObject *__pyx_t_3 = NULL;
5933   PyObject *__pyx_t_4 = NULL;
5934   int __pyx_t_5;
5935   PyObject *__pyx_t_6 = NULL;
5936   __Pyx_memviewslice __pyx_t_7 = { 0, 0, { 0 }, { 0 }, { 0 } };
5937   __Pyx_memviewslice __pyx_t_8 = { 0, 0, { 0 }, { 0 }, { 0 } };
5938   __Pyx_memviewslice __pyx_t_9 = { 0, 0, { 0 }, { 0 }, { 0 } };
5939   __Pyx_memviewslice __pyx_t_10 = { 0, 0, { 0 }, { 0 }, { 0 } };
5940   int __pyx_lineno = 0;
5941   const char *__pyx_filename = NULL;
5942   int __pyx_clineno = 0;
5943   __Pyx_RefNannySetupContext("cy_ode_rho_func_td", 0);
5944   __pyx_pybuffer_rho.pybuffer.buf = NULL;
5945   __pyx_pybuffer_rho.refcount = 0;
5946   __pyx_pybuffernd_rho.data = NULL;
5947   __pyx_pybuffernd_rho.rcbuffer = &__pyx_pybuffer_rho;
5948   {
5949     __Pyx_BufFmt_StackElem __pyx_stack[1];
5950     if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_rho.rcbuffer->pybuffer, (PyObject*)__pyx_v_rho, &__Pyx_TypeInfo___pyx_t_double_complex, PyBUF_FORMAT| PyBUF_C_CONTIGUOUS, 1, 0, __pyx_stack) == -1)) __PYX_ERR(0, 350, __pyx_L1_error)
5951   }
5952   __pyx_pybuffernd_rho.diminfo[0].strides = __pyx_pybuffernd_rho.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_rho.diminfo[0].shape = __pyx_pybuffernd_rho.rcbuffer->pybuffer.shape[0];
5953 
5954   /* "qutip/cy/spmatfuncs.pyx":357
5955  *         object args):
5956  *     cdef object L
5957  *     L = L0 + L_func(t, args).data             # <<<<<<<<<<<<<<
5958  *     return spmv_csr(L.data, L.indices, L.indptr, rho)
5959  *
5960  */
5961   __pyx_t_2 = PyFloat_FromDouble(__pyx_v_t); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 357, __pyx_L1_error)
5962   __Pyx_GOTREF(__pyx_t_2);
5963   __Pyx_INCREF(__pyx_v_L_func);
5964   __pyx_t_3 = __pyx_v_L_func; __pyx_t_4 = NULL;
5965   __pyx_t_5 = 0;
5966   if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
5967     __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
5968     if (likely(__pyx_t_4)) {
5969       PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
5970       __Pyx_INCREF(__pyx_t_4);
5971       __Pyx_INCREF(function);
5972       __Pyx_DECREF_SET(__pyx_t_3, function);
5973       __pyx_t_5 = 1;
5974     }
5975   }
5976   #if CYTHON_FAST_PYCALL
5977   if (PyFunction_Check(__pyx_t_3)) {
5978     PyObject *__pyx_temp[3] = {__pyx_t_4, __pyx_t_2, __pyx_v_args};
5979     __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_5, 2+__pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 357, __pyx_L1_error)
5980     __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
5981     __Pyx_GOTREF(__pyx_t_1);
5982     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
5983   } else
5984   #endif
5985   #if CYTHON_FAST_PYCCALL
5986   if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
5987     PyObject *__pyx_temp[3] = {__pyx_t_4, __pyx_t_2, __pyx_v_args};
5988     __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_5, 2+__pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 357, __pyx_L1_error)
5989     __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
5990     __Pyx_GOTREF(__pyx_t_1);
5991     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
5992   } else
5993   #endif
5994   {
5995     __pyx_t_6 = PyTuple_New(2+__pyx_t_5); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 357, __pyx_L1_error)
5996     __Pyx_GOTREF(__pyx_t_6);
5997     if (__pyx_t_4) {
5998       __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_4); __pyx_t_4 = NULL;
5999     }
6000     __Pyx_GIVEREF(__pyx_t_2);
6001     PyTuple_SET_ITEM(__pyx_t_6, 0+__pyx_t_5, __pyx_t_2);
6002     __Pyx_INCREF(__pyx_v_args);
6003     __Pyx_GIVEREF(__pyx_v_args);
6004     PyTuple_SET_ITEM(__pyx_t_6, 1+__pyx_t_5, __pyx_v_args);
6005     __pyx_t_2 = 0;
6006     __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_6, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 357, __pyx_L1_error)
6007     __Pyx_GOTREF(__pyx_t_1);
6008     __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
6009   }
6010   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
6011   __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_data); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 357, __pyx_L1_error)
6012   __Pyx_GOTREF(__pyx_t_3);
6013   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
6014   __pyx_t_1 = PyNumber_Add(__pyx_v_L0, __pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 357, __pyx_L1_error)
6015   __Pyx_GOTREF(__pyx_t_1);
6016   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
6017   __pyx_v_L = __pyx_t_1;
6018   __pyx_t_1 = 0;
6019 
6020   /* "qutip/cy/spmatfuncs.pyx":358
6021  *     cdef object L
6022  *     L = L0 + L_func(t, args).data
6023  *     return spmv_csr(L.data, L.indices, L.indptr, rho)             # <<<<<<<<<<<<<<
6024  *
6025  *
6026  */
6027   __Pyx_XDECREF(((PyObject *)__pyx_r));
6028   __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_L, __pyx_n_s_data); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 358, __pyx_L1_error)
6029   __Pyx_GOTREF(__pyx_t_1);
6030   __pyx_t_7 = __Pyx_PyObject_to_MemoryviewSlice_dc___pyx_t_double_complex(__pyx_t_1, PyBUF_WRITABLE); if (unlikely(!__pyx_t_7.memview)) __PYX_ERR(0, 358, __pyx_L1_error)
6031   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
6032   __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_L, __pyx_n_s_indices); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 358, __pyx_L1_error)
6033   __Pyx_GOTREF(__pyx_t_1);
6034   __pyx_t_8 = __Pyx_PyObject_to_MemoryviewSlice_dc_int(__pyx_t_1, PyBUF_WRITABLE); if (unlikely(!__pyx_t_8.memview)) __PYX_ERR(0, 358, __pyx_L1_error)
6035   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
6036   __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_L, __pyx_n_s_indptr); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 358, __pyx_L1_error)
6037   __Pyx_GOTREF(__pyx_t_1);
6038   __pyx_t_9 = __Pyx_PyObject_to_MemoryviewSlice_dc_int(__pyx_t_1, PyBUF_WRITABLE); if (unlikely(!__pyx_t_9.memview)) __PYX_ERR(0, 358, __pyx_L1_error)
6039   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
6040   __pyx_t_10 = __Pyx_PyObject_to_MemoryviewSlice_dc___pyx_t_double_complex(((PyObject *)__pyx_v_rho), PyBUF_WRITABLE); if (unlikely(!__pyx_t_10.memview)) __PYX_ERR(0, 358, __pyx_L1_error)
6041   __pyx_t_1 = ((PyObject *)__pyx_f_5qutip_2cy_10spmatfuncs_spmv_csr(__pyx_t_7, __pyx_t_8, __pyx_t_9, __pyx_t_10, 0)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 358, __pyx_L1_error)
6042   __Pyx_GOTREF(__pyx_t_1);
6043   __PYX_XDEC_MEMVIEW(&__pyx_t_7, 1);
6044   __pyx_t_7.memview = NULL;
6045   __pyx_t_7.data = NULL;
6046   __PYX_XDEC_MEMVIEW(&__pyx_t_8, 1);
6047   __pyx_t_8.memview = NULL;
6048   __pyx_t_8.data = NULL;
6049   __PYX_XDEC_MEMVIEW(&__pyx_t_9, 1);
6050   __pyx_t_9.memview = NULL;
6051   __pyx_t_9.data = NULL;
6052   __PYX_XDEC_MEMVIEW(&__pyx_t_10, 1);
6053   __pyx_t_10.memview = NULL;
6054   __pyx_t_10.data = NULL;
6055   __pyx_r = ((PyArrayObject *)__pyx_t_1);
6056   __pyx_t_1 = 0;
6057   goto __pyx_L0;
6058 
6059   /* "qutip/cy/spmatfuncs.pyx":350
6060  * @cython.boundscheck(False)
6061  * @cython.wraparound(False)
6062  * cpdef cnp.ndarray[complex, ndim=1, mode="c"] cy_ode_rho_func_td(             # <<<<<<<<<<<<<<
6063  *         double t,
6064  *         cnp.ndarray[complex, ndim=1, mode="c"] rho,
6065  */
6066 
6067   /* function exit code */
6068   __pyx_L1_error:;
6069   __Pyx_XDECREF(__pyx_t_1);
6070   __Pyx_XDECREF(__pyx_t_2);
6071   __Pyx_XDECREF(__pyx_t_3);
6072   __Pyx_XDECREF(__pyx_t_4);
6073   __Pyx_XDECREF(__pyx_t_6);
6074   __PYX_XDEC_MEMVIEW(&__pyx_t_7, 1);
6075   __PYX_XDEC_MEMVIEW(&__pyx_t_8, 1);
6076   __PYX_XDEC_MEMVIEW(&__pyx_t_9, 1);
6077   __PYX_XDEC_MEMVIEW(&__pyx_t_10, 1);
6078   { PyObject *__pyx_type, *__pyx_value, *__pyx_tb;
6079     __Pyx_PyThreadState_declare
6080     __Pyx_PyThreadState_assign
6081     __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb);
6082     __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_rho.rcbuffer->pybuffer);
6083   __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}
6084   __Pyx_AddTraceback("qutip.cy.spmatfuncs.cy_ode_rho_func_td", __pyx_clineno, __pyx_lineno, __pyx_filename);
6085   __pyx_r = 0;
6086   goto __pyx_L2;
6087   __pyx_L0:;
6088   __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_rho.rcbuffer->pybuffer);
6089   __pyx_L2:;
6090   __Pyx_XDECREF(__pyx_v_L);
6091   __Pyx_XGIVEREF((PyObject *)__pyx_r);
6092   __Pyx_RefNannyFinishContext();
6093   return __pyx_r;
6094 }
6095 
6096 /* Python wrapper */
6097 static PyObject *__pyx_pw_5qutip_2cy_10spmatfuncs_23cy_ode_rho_func_td(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
__pyx_pw_5qutip_2cy_10spmatfuncs_23cy_ode_rho_func_td(PyObject * __pyx_self,PyObject * __pyx_args,PyObject * __pyx_kwds)6098 static PyObject *__pyx_pw_5qutip_2cy_10spmatfuncs_23cy_ode_rho_func_td(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
6099   double __pyx_v_t;
6100   PyArrayObject *__pyx_v_rho = 0;
6101   PyObject *__pyx_v_L0 = 0;
6102   PyObject *__pyx_v_L_func = 0;
6103   PyObject *__pyx_v_args = 0;
6104   int __pyx_lineno = 0;
6105   const char *__pyx_filename = NULL;
6106   int __pyx_clineno = 0;
6107   PyObject *__pyx_r = 0;
6108   __Pyx_RefNannyDeclarations
6109   __Pyx_RefNannySetupContext("cy_ode_rho_func_td (wrapper)", 0);
6110   {
6111     static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_t,&__pyx_n_s_rho,&__pyx_n_s_L0,&__pyx_n_s_L_func,&__pyx_n_s_args,0};
6112     PyObject* values[5] = {0,0,0,0,0};
6113     if (unlikely(__pyx_kwds)) {
6114       Py_ssize_t kw_args;
6115       const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
6116       switch (pos_args) {
6117         case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
6118         CYTHON_FALLTHROUGH;
6119         case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
6120         CYTHON_FALLTHROUGH;
6121         case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
6122         CYTHON_FALLTHROUGH;
6123         case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
6124         CYTHON_FALLTHROUGH;
6125         case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
6126         CYTHON_FALLTHROUGH;
6127         case  0: break;
6128         default: goto __pyx_L5_argtuple_error;
6129       }
6130       kw_args = PyDict_Size(__pyx_kwds);
6131       switch (pos_args) {
6132         case  0:
6133         if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_t)) != 0)) kw_args--;
6134         else goto __pyx_L5_argtuple_error;
6135         CYTHON_FALLTHROUGH;
6136         case  1:
6137         if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_rho)) != 0)) kw_args--;
6138         else {
6139           __Pyx_RaiseArgtupleInvalid("cy_ode_rho_func_td", 1, 5, 5, 1); __PYX_ERR(0, 350, __pyx_L3_error)
6140         }
6141         CYTHON_FALLTHROUGH;
6142         case  2:
6143         if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_L0)) != 0)) kw_args--;
6144         else {
6145           __Pyx_RaiseArgtupleInvalid("cy_ode_rho_func_td", 1, 5, 5, 2); __PYX_ERR(0, 350, __pyx_L3_error)
6146         }
6147         CYTHON_FALLTHROUGH;
6148         case  3:
6149         if (likely((values[3] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_L_func)) != 0)) kw_args--;
6150         else {
6151           __Pyx_RaiseArgtupleInvalid("cy_ode_rho_func_td", 1, 5, 5, 3); __PYX_ERR(0, 350, __pyx_L3_error)
6152         }
6153         CYTHON_FALLTHROUGH;
6154         case  4:
6155         if (likely((values[4] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_args)) != 0)) kw_args--;
6156         else {
6157           __Pyx_RaiseArgtupleInvalid("cy_ode_rho_func_td", 1, 5, 5, 4); __PYX_ERR(0, 350, __pyx_L3_error)
6158         }
6159       }
6160       if (unlikely(kw_args > 0)) {
6161         if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "cy_ode_rho_func_td") < 0)) __PYX_ERR(0, 350, __pyx_L3_error)
6162       }
6163     } else if (PyTuple_GET_SIZE(__pyx_args) != 5) {
6164       goto __pyx_L5_argtuple_error;
6165     } else {
6166       values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
6167       values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
6168       values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
6169       values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
6170       values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
6171     }
6172     __pyx_v_t = __pyx_PyFloat_AsDouble(values[0]); if (unlikely((__pyx_v_t == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 351, __pyx_L3_error)
6173     __pyx_v_rho = ((PyArrayObject *)values[1]);
6174     __pyx_v_L0 = values[2];
6175     __pyx_v_L_func = values[3];
6176     __pyx_v_args = values[4];
6177   }
6178   goto __pyx_L4_argument_unpacking_done;
6179   __pyx_L5_argtuple_error:;
6180   __Pyx_RaiseArgtupleInvalid("cy_ode_rho_func_td", 1, 5, 5, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 350, __pyx_L3_error)
6181   __pyx_L3_error:;
6182   __Pyx_AddTraceback("qutip.cy.spmatfuncs.cy_ode_rho_func_td", __pyx_clineno, __pyx_lineno, __pyx_filename);
6183   __Pyx_RefNannyFinishContext();
6184   return NULL;
6185   __pyx_L4_argument_unpacking_done:;
6186   if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_rho), __pyx_ptype_5numpy_ndarray, 1, "rho", 0))) __PYX_ERR(0, 352, __pyx_L1_error)
6187   __pyx_r = __pyx_pf_5qutip_2cy_10spmatfuncs_22cy_ode_rho_func_td(__pyx_self, __pyx_v_t, __pyx_v_rho, __pyx_v_L0, __pyx_v_L_func, __pyx_v_args);
6188 
6189   /* function exit code */
6190   goto __pyx_L0;
6191   __pyx_L1_error:;
6192   __pyx_r = NULL;
6193   __pyx_L0:;
6194   __Pyx_RefNannyFinishContext();
6195   return __pyx_r;
6196 }
6197 
__pyx_pf_5qutip_2cy_10spmatfuncs_22cy_ode_rho_func_td(CYTHON_UNUSED PyObject * __pyx_self,double __pyx_v_t,PyArrayObject * __pyx_v_rho,PyObject * __pyx_v_L0,PyObject * __pyx_v_L_func,PyObject * __pyx_v_args)6198 static PyObject *__pyx_pf_5qutip_2cy_10spmatfuncs_22cy_ode_rho_func_td(CYTHON_UNUSED PyObject *__pyx_self, double __pyx_v_t, PyArrayObject *__pyx_v_rho, PyObject *__pyx_v_L0, PyObject *__pyx_v_L_func, PyObject *__pyx_v_args) {
6199   __Pyx_LocalBuf_ND __pyx_pybuffernd_rho;
6200   __Pyx_Buffer __pyx_pybuffer_rho;
6201   PyObject *__pyx_r = NULL;
6202   __Pyx_RefNannyDeclarations
6203   PyObject *__pyx_t_1 = NULL;
6204   int __pyx_lineno = 0;
6205   const char *__pyx_filename = NULL;
6206   int __pyx_clineno = 0;
6207   __Pyx_RefNannySetupContext("cy_ode_rho_func_td", 0);
6208   __pyx_pybuffer_rho.pybuffer.buf = NULL;
6209   __pyx_pybuffer_rho.refcount = 0;
6210   __pyx_pybuffernd_rho.data = NULL;
6211   __pyx_pybuffernd_rho.rcbuffer = &__pyx_pybuffer_rho;
6212   {
6213     __Pyx_BufFmt_StackElem __pyx_stack[1];
6214     if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_rho.rcbuffer->pybuffer, (PyObject*)__pyx_v_rho, &__Pyx_TypeInfo___pyx_t_double_complex, PyBUF_FORMAT| PyBUF_C_CONTIGUOUS, 1, 0, __pyx_stack) == -1)) __PYX_ERR(0, 350, __pyx_L1_error)
6215   }
6216   __pyx_pybuffernd_rho.diminfo[0].strides = __pyx_pybuffernd_rho.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_rho.diminfo[0].shape = __pyx_pybuffernd_rho.rcbuffer->pybuffer.shape[0];
6217   __Pyx_XDECREF(__pyx_r);
6218   __pyx_t_1 = ((PyObject *)__pyx_f_5qutip_2cy_10spmatfuncs_cy_ode_rho_func_td(__pyx_v_t, __pyx_v_rho, __pyx_v_L0, __pyx_v_L_func, __pyx_v_args, 0)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 350, __pyx_L1_error)
6219   __Pyx_GOTREF(__pyx_t_1);
6220   __pyx_r = __pyx_t_1;
6221   __pyx_t_1 = 0;
6222   goto __pyx_L0;
6223 
6224   /* function exit code */
6225   __pyx_L1_error:;
6226   __Pyx_XDECREF(__pyx_t_1);
6227   { PyObject *__pyx_type, *__pyx_value, *__pyx_tb;
6228     __Pyx_PyThreadState_declare
6229     __Pyx_PyThreadState_assign
6230     __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb);
6231     __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_rho.rcbuffer->pybuffer);
6232   __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}
6233   __Pyx_AddTraceback("qutip.cy.spmatfuncs.cy_ode_rho_func_td", __pyx_clineno, __pyx_lineno, __pyx_filename);
6234   __pyx_r = NULL;
6235   goto __pyx_L2;
6236   __pyx_L0:;
6237   __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_rho.rcbuffer->pybuffer);
6238   __pyx_L2:;
6239   __Pyx_XGIVEREF(__pyx_r);
6240   __Pyx_RefNannyFinishContext();
6241   return __pyx_r;
6242 }
6243 
6244 /* "qutip/cy/spmatfuncs.pyx":363
6245  * @cython.boundscheck(False)
6246  * @cython.wraparound(False)
6247  * cpdef cy_expect_psi(object A, complex[::1] vec, bool isherm):             # <<<<<<<<<<<<<<
6248  *
6249  *     cdef complex[::1] data = A.data
6250  */
6251 
6252 static PyObject *__pyx_pw_5qutip_2cy_10spmatfuncs_25cy_expect_psi(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
__pyx_f_5qutip_2cy_10spmatfuncs_cy_expect_psi(PyObject * __pyx_v_A,__Pyx_memviewslice __pyx_v_vec,bool __pyx_v_isherm,CYTHON_UNUSED int __pyx_skip_dispatch)6253 static PyObject *__pyx_f_5qutip_2cy_10spmatfuncs_cy_expect_psi(PyObject *__pyx_v_A, __Pyx_memviewslice __pyx_v_vec, bool __pyx_v_isherm, CYTHON_UNUSED int __pyx_skip_dispatch) {
6254   __Pyx_memviewslice __pyx_v_data = { 0, 0, { 0 }, { 0 }, { 0 } };
6255   __Pyx_memviewslice __pyx_v_ind = { 0, 0, { 0 }, { 0 }, { 0 } };
6256   __Pyx_memviewslice __pyx_v_ptr = { 0, 0, { 0 }, { 0 }, { 0 } };
6257   size_t __pyx_v_row;
6258   size_t __pyx_v_jj;
6259   int __pyx_v_nrows;
6260   __pyx_t_double_complex __pyx_v_expt;
6261   __pyx_t_double_complex __pyx_v_temp;
6262   __pyx_t_double_complex __pyx_v_cval;
6263   PyObject *__pyx_r = NULL;
6264   __Pyx_RefNannyDeclarations
6265   PyObject *__pyx_t_1 = NULL;
6266   __Pyx_memviewslice __pyx_t_2 = { 0, 0, { 0 }, { 0 }, { 0 } };
6267   __Pyx_memviewslice __pyx_t_3 = { 0, 0, { 0 }, { 0 }, { 0 } };
6268   int __pyx_t_4;
6269   int __pyx_t_5;
6270   size_t __pyx_t_6;
6271   size_t __pyx_t_7;
6272   int __pyx_t_8;
6273   int __pyx_t_9;
6274   size_t __pyx_t_10;
6275   size_t __pyx_t_11;
6276   size_t __pyx_t_12;
6277   Py_ssize_t __pyx_t_13;
6278   int __pyx_t_14;
6279   int __pyx_lineno = 0;
6280   const char *__pyx_filename = NULL;
6281   int __pyx_clineno = 0;
6282   __Pyx_RefNannySetupContext("cy_expect_psi", 0);
6283 
6284   /* "qutip/cy/spmatfuncs.pyx":365
6285  * cpdef cy_expect_psi(object A, complex[::1] vec, bool isherm):
6286  *
6287  *     cdef complex[::1] data = A.data             # <<<<<<<<<<<<<<
6288  *     cdef int[::1] ind = A.indices
6289  *     cdef int[::1] ptr = A.indptr
6290  */
6291   __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_A, __pyx_n_s_data); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 365, __pyx_L1_error)
6292   __Pyx_GOTREF(__pyx_t_1);
6293   __pyx_t_2 = __Pyx_PyObject_to_MemoryviewSlice_dc___pyx_t_double_complex(__pyx_t_1, PyBUF_WRITABLE); if (unlikely(!__pyx_t_2.memview)) __PYX_ERR(0, 365, __pyx_L1_error)
6294   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
6295   __pyx_v_data = __pyx_t_2;
6296   __pyx_t_2.memview = NULL;
6297   __pyx_t_2.data = NULL;
6298 
6299   /* "qutip/cy/spmatfuncs.pyx":366
6300  *
6301  *     cdef complex[::1] data = A.data
6302  *     cdef int[::1] ind = A.indices             # <<<<<<<<<<<<<<
6303  *     cdef int[::1] ptr = A.indptr
6304  *
6305  */
6306   __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_A, __pyx_n_s_indices); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 366, __pyx_L1_error)
6307   __Pyx_GOTREF(__pyx_t_1);
6308   __pyx_t_3 = __Pyx_PyObject_to_MemoryviewSlice_dc_int(__pyx_t_1, PyBUF_WRITABLE); if (unlikely(!__pyx_t_3.memview)) __PYX_ERR(0, 366, __pyx_L1_error)
6309   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
6310   __pyx_v_ind = __pyx_t_3;
6311   __pyx_t_3.memview = NULL;
6312   __pyx_t_3.data = NULL;
6313 
6314   /* "qutip/cy/spmatfuncs.pyx":367
6315  *     cdef complex[::1] data = A.data
6316  *     cdef int[::1] ind = A.indices
6317  *     cdef int[::1] ptr = A.indptr             # <<<<<<<<<<<<<<
6318  *
6319  *     cdef size_t row, jj
6320  */
6321   __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_A, __pyx_n_s_indptr); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 367, __pyx_L1_error)
6322   __Pyx_GOTREF(__pyx_t_1);
6323   __pyx_t_3 = __Pyx_PyObject_to_MemoryviewSlice_dc_int(__pyx_t_1, PyBUF_WRITABLE); if (unlikely(!__pyx_t_3.memview)) __PYX_ERR(0, 367, __pyx_L1_error)
6324   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
6325   __pyx_v_ptr = __pyx_t_3;
6326   __pyx_t_3.memview = NULL;
6327   __pyx_t_3.data = NULL;
6328 
6329   /* "qutip/cy/spmatfuncs.pyx":370
6330  *
6331  *     cdef size_t row, jj
6332  *     cdef int nrows = vec.shape[0]             # <<<<<<<<<<<<<<
6333  *     cdef complex expt = 0, temp, cval
6334  *
6335  */
6336   __pyx_v_nrows = (__pyx_v_vec.shape[0]);
6337 
6338   /* "qutip/cy/spmatfuncs.pyx":371
6339  *     cdef size_t row, jj
6340  *     cdef int nrows = vec.shape[0]
6341  *     cdef complex expt = 0, temp, cval             # <<<<<<<<<<<<<<
6342  *
6343  *     for row in range(nrows):
6344  */
6345   __pyx_v_expt = __pyx_t_double_complex_from_parts(0, 0);
6346 
6347   /* "qutip/cy/spmatfuncs.pyx":373
6348  *     cdef complex expt = 0, temp, cval
6349  *
6350  *     for row in range(nrows):             # <<<<<<<<<<<<<<
6351  *         cval = conj(vec[row])
6352  *         temp = 0
6353  */
6354   __pyx_t_4 = __pyx_v_nrows;
6355   __pyx_t_5 = __pyx_t_4;
6356   for (__pyx_t_6 = 0; __pyx_t_6 < __pyx_t_5; __pyx_t_6+=1) {
6357     __pyx_v_row = __pyx_t_6;
6358 
6359     /* "qutip/cy/spmatfuncs.pyx":374
6360  *
6361  *     for row in range(nrows):
6362  *         cval = conj(vec[row])             # <<<<<<<<<<<<<<
6363  *         temp = 0
6364  *         for jj in range(ptr[row], ptr[row+1]):
6365  */
6366     __pyx_t_7 = __pyx_v_row;
6367     __pyx_v_cval = std::conj((*((__pyx_t_double_complex *) ( /* dim=0 */ ((char *) (((__pyx_t_double_complex *) __pyx_v_vec.data) + __pyx_t_7)) ))));
6368 
6369     /* "qutip/cy/spmatfuncs.pyx":375
6370  *     for row in range(nrows):
6371  *         cval = conj(vec[row])
6372  *         temp = 0             # <<<<<<<<<<<<<<
6373  *         for jj in range(ptr[row], ptr[row+1]):
6374  *             temp += data[jj]*vec[ind[jj]]
6375  */
6376     __pyx_v_temp = __pyx_t_double_complex_from_parts(0, 0);
6377 
6378     /* "qutip/cy/spmatfuncs.pyx":376
6379  *         cval = conj(vec[row])
6380  *         temp = 0
6381  *         for jj in range(ptr[row], ptr[row+1]):             # <<<<<<<<<<<<<<
6382  *             temp += data[jj]*vec[ind[jj]]
6383  *         expt += cval*temp
6384  */
6385     __pyx_t_7 = (__pyx_v_row + 1);
6386     __pyx_t_8 = (*((int *) ( /* dim=0 */ ((char *) (((int *) __pyx_v_ptr.data) + __pyx_t_7)) )));
6387     __pyx_t_7 = __pyx_v_row;
6388     __pyx_t_9 = __pyx_t_8;
6389     for (__pyx_t_10 = (*((int *) ( /* dim=0 */ ((char *) (((int *) __pyx_v_ptr.data) + __pyx_t_7)) ))); __pyx_t_10 < __pyx_t_9; __pyx_t_10+=1) {
6390       __pyx_v_jj = __pyx_t_10;
6391 
6392       /* "qutip/cy/spmatfuncs.pyx":377
6393  *         temp = 0
6394  *         for jj in range(ptr[row], ptr[row+1]):
6395  *             temp += data[jj]*vec[ind[jj]]             # <<<<<<<<<<<<<<
6396  *         expt += cval*temp
6397  *
6398  */
6399       __pyx_t_11 = __pyx_v_jj;
6400       __pyx_t_12 = __pyx_v_jj;
6401       __pyx_t_13 = (*((int *) ( /* dim=0 */ ((char *) (((int *) __pyx_v_ind.data) + __pyx_t_12)) )));
6402       __pyx_v_temp = __Pyx_c_sum_double(__pyx_v_temp, __Pyx_c_prod_double((*((__pyx_t_double_complex *) ( /* dim=0 */ ((char *) (((__pyx_t_double_complex *) __pyx_v_data.data) + __pyx_t_11)) ))), (*((__pyx_t_double_complex *) ( /* dim=0 */ ((char *) (((__pyx_t_double_complex *) __pyx_v_vec.data) + __pyx_t_13)) )))));
6403     }
6404 
6405     /* "qutip/cy/spmatfuncs.pyx":378
6406  *         for jj in range(ptr[row], ptr[row+1]):
6407  *             temp += data[jj]*vec[ind[jj]]
6408  *         expt += cval*temp             # <<<<<<<<<<<<<<
6409  *
6410  *     if isherm :
6411  */
6412     __pyx_v_expt = __Pyx_c_sum_double(__pyx_v_expt, __Pyx_c_prod_double(__pyx_v_cval, __pyx_v_temp));
6413   }
6414 
6415   /* "qutip/cy/spmatfuncs.pyx":380
6416  *         expt += cval*temp
6417  *
6418  *     if isherm :             # <<<<<<<<<<<<<<
6419  *         return real(expt)
6420  *     else:
6421  */
6422   __pyx_t_14 = (__pyx_v_isherm != 0);
6423   if (__pyx_t_14) {
6424 
6425     /* "qutip/cy/spmatfuncs.pyx":381
6426  *
6427  *     if isherm :
6428  *         return real(expt)             # <<<<<<<<<<<<<<
6429  *     else:
6430  *         return expt
6431  */
6432     __Pyx_XDECREF(__pyx_r);
6433     __pyx_t_1 = PyFloat_FromDouble(std::real(__pyx_v_expt)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 381, __pyx_L1_error)
6434     __Pyx_GOTREF(__pyx_t_1);
6435     __pyx_r = __pyx_t_1;
6436     __pyx_t_1 = 0;
6437     goto __pyx_L0;
6438 
6439     /* "qutip/cy/spmatfuncs.pyx":380
6440  *         expt += cval*temp
6441  *
6442  *     if isherm :             # <<<<<<<<<<<<<<
6443  *         return real(expt)
6444  *     else:
6445  */
6446   }
6447 
6448   /* "qutip/cy/spmatfuncs.pyx":383
6449  *         return real(expt)
6450  *     else:
6451  *         return expt             # <<<<<<<<<<<<<<
6452  *
6453  *
6454  */
6455   /*else*/ {
6456     __Pyx_XDECREF(__pyx_r);
6457     __pyx_t_1 = __pyx_PyComplex_FromComplex(__pyx_v_expt); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 383, __pyx_L1_error)
6458     __Pyx_GOTREF(__pyx_t_1);
6459     __pyx_r = __pyx_t_1;
6460     __pyx_t_1 = 0;
6461     goto __pyx_L0;
6462   }
6463 
6464   /* "qutip/cy/spmatfuncs.pyx":363
6465  * @cython.boundscheck(False)
6466  * @cython.wraparound(False)
6467  * cpdef cy_expect_psi(object A, complex[::1] vec, bool isherm):             # <<<<<<<<<<<<<<
6468  *
6469  *     cdef complex[::1] data = A.data
6470  */
6471 
6472   /* function exit code */
6473   __pyx_L1_error:;
6474   __Pyx_XDECREF(__pyx_t_1);
6475   __PYX_XDEC_MEMVIEW(&__pyx_t_2, 1);
6476   __PYX_XDEC_MEMVIEW(&__pyx_t_3, 1);
6477   __Pyx_AddTraceback("qutip.cy.spmatfuncs.cy_expect_psi", __pyx_clineno, __pyx_lineno, __pyx_filename);
6478   __pyx_r = 0;
6479   __pyx_L0:;
6480   __PYX_XDEC_MEMVIEW(&__pyx_v_data, 1);
6481   __PYX_XDEC_MEMVIEW(&__pyx_v_ind, 1);
6482   __PYX_XDEC_MEMVIEW(&__pyx_v_ptr, 1);
6483   __Pyx_XGIVEREF(__pyx_r);
6484   __Pyx_RefNannyFinishContext();
6485   return __pyx_r;
6486 }
6487 
6488 /* Python wrapper */
6489 static PyObject *__pyx_pw_5qutip_2cy_10spmatfuncs_25cy_expect_psi(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
__pyx_pw_5qutip_2cy_10spmatfuncs_25cy_expect_psi(PyObject * __pyx_self,PyObject * __pyx_args,PyObject * __pyx_kwds)6490 static PyObject *__pyx_pw_5qutip_2cy_10spmatfuncs_25cy_expect_psi(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
6491   PyObject *__pyx_v_A = 0;
6492   __Pyx_memviewslice __pyx_v_vec = { 0, 0, { 0 }, { 0 }, { 0 } };
6493   bool __pyx_v_isherm;
6494   int __pyx_lineno = 0;
6495   const char *__pyx_filename = NULL;
6496   int __pyx_clineno = 0;
6497   PyObject *__pyx_r = 0;
6498   __Pyx_RefNannyDeclarations
6499   __Pyx_RefNannySetupContext("cy_expect_psi (wrapper)", 0);
6500   {
6501     static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_A,&__pyx_n_s_vec,&__pyx_n_s_isherm,0};
6502     PyObject* values[3] = {0,0,0};
6503     if (unlikely(__pyx_kwds)) {
6504       Py_ssize_t kw_args;
6505       const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
6506       switch (pos_args) {
6507         case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
6508         CYTHON_FALLTHROUGH;
6509         case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
6510         CYTHON_FALLTHROUGH;
6511         case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
6512         CYTHON_FALLTHROUGH;
6513         case  0: break;
6514         default: goto __pyx_L5_argtuple_error;
6515       }
6516       kw_args = PyDict_Size(__pyx_kwds);
6517       switch (pos_args) {
6518         case  0:
6519         if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_A)) != 0)) kw_args--;
6520         else goto __pyx_L5_argtuple_error;
6521         CYTHON_FALLTHROUGH;
6522         case  1:
6523         if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_vec)) != 0)) kw_args--;
6524         else {
6525           __Pyx_RaiseArgtupleInvalid("cy_expect_psi", 1, 3, 3, 1); __PYX_ERR(0, 363, __pyx_L3_error)
6526         }
6527         CYTHON_FALLTHROUGH;
6528         case  2:
6529         if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_isherm)) != 0)) kw_args--;
6530         else {
6531           __Pyx_RaiseArgtupleInvalid("cy_expect_psi", 1, 3, 3, 2); __PYX_ERR(0, 363, __pyx_L3_error)
6532         }
6533       }
6534       if (unlikely(kw_args > 0)) {
6535         if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "cy_expect_psi") < 0)) __PYX_ERR(0, 363, __pyx_L3_error)
6536       }
6537     } else if (PyTuple_GET_SIZE(__pyx_args) != 3) {
6538       goto __pyx_L5_argtuple_error;
6539     } else {
6540       values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
6541       values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
6542       values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
6543     }
6544     __pyx_v_A = values[0];
6545     __pyx_v_vec = __Pyx_PyObject_to_MemoryviewSlice_dc___pyx_t_double_complex(values[1], PyBUF_WRITABLE); if (unlikely(!__pyx_v_vec.memview)) __PYX_ERR(0, 363, __pyx_L3_error)
6546     __pyx_v_isherm = __Pyx_PyObject_IsTrue(values[2]); if (unlikely((__pyx_v_isherm == ((bool)-1)) && PyErr_Occurred())) __PYX_ERR(0, 363, __pyx_L3_error)
6547   }
6548   goto __pyx_L4_argument_unpacking_done;
6549   __pyx_L5_argtuple_error:;
6550   __Pyx_RaiseArgtupleInvalid("cy_expect_psi", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 363, __pyx_L3_error)
6551   __pyx_L3_error:;
6552   __Pyx_AddTraceback("qutip.cy.spmatfuncs.cy_expect_psi", __pyx_clineno, __pyx_lineno, __pyx_filename);
6553   __Pyx_RefNannyFinishContext();
6554   return NULL;
6555   __pyx_L4_argument_unpacking_done:;
6556   __pyx_r = __pyx_pf_5qutip_2cy_10spmatfuncs_24cy_expect_psi(__pyx_self, __pyx_v_A, __pyx_v_vec, __pyx_v_isherm);
6557 
6558   /* function exit code */
6559   __Pyx_RefNannyFinishContext();
6560   return __pyx_r;
6561 }
6562 
__pyx_pf_5qutip_2cy_10spmatfuncs_24cy_expect_psi(CYTHON_UNUSED PyObject * __pyx_self,PyObject * __pyx_v_A,__Pyx_memviewslice __pyx_v_vec,bool __pyx_v_isherm)6563 static PyObject *__pyx_pf_5qutip_2cy_10spmatfuncs_24cy_expect_psi(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_A, __Pyx_memviewslice __pyx_v_vec, bool __pyx_v_isherm) {
6564   PyObject *__pyx_r = NULL;
6565   __Pyx_RefNannyDeclarations
6566   PyObject *__pyx_t_1 = NULL;
6567   int __pyx_lineno = 0;
6568   const char *__pyx_filename = NULL;
6569   int __pyx_clineno = 0;
6570   __Pyx_RefNannySetupContext("cy_expect_psi", 0);
6571   __Pyx_XDECREF(__pyx_r);
6572   if (unlikely(!__pyx_v_vec.memview)) { __Pyx_RaiseUnboundLocalError("vec"); __PYX_ERR(0, 363, __pyx_L1_error) }
6573   __pyx_t_1 = __pyx_f_5qutip_2cy_10spmatfuncs_cy_expect_psi(__pyx_v_A, __pyx_v_vec, __pyx_v_isherm, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 363, __pyx_L1_error)
6574   __Pyx_GOTREF(__pyx_t_1);
6575   __pyx_r = __pyx_t_1;
6576   __pyx_t_1 = 0;
6577   goto __pyx_L0;
6578 
6579   /* function exit code */
6580   __pyx_L1_error:;
6581   __Pyx_XDECREF(__pyx_t_1);
6582   __Pyx_AddTraceback("qutip.cy.spmatfuncs.cy_expect_psi", __pyx_clineno, __pyx_lineno, __pyx_filename);
6583   __pyx_r = NULL;
6584   __pyx_L0:;
6585   __PYX_XDEC_MEMVIEW(&__pyx_v_vec, 1);
6586   __Pyx_XGIVEREF(__pyx_r);
6587   __Pyx_RefNannyFinishContext();
6588   return __pyx_r;
6589 }
6590 
6591 /* "qutip/cy/spmatfuncs.pyx":388
6592  * @cython.boundscheck(False)
6593  * @cython.wraparound(False)
6594  * cpdef cy_expect_psi_csr(complex[::1] data,             # <<<<<<<<<<<<<<
6595  *                         int[::1] ind,
6596  *                         int[::1] ptr,
6597  */
6598 
6599 static PyObject *__pyx_pw_5qutip_2cy_10spmatfuncs_27cy_expect_psi_csr(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
__pyx_f_5qutip_2cy_10spmatfuncs_cy_expect_psi_csr(__Pyx_memviewslice __pyx_v_data,__Pyx_memviewslice __pyx_v_ind,__Pyx_memviewslice __pyx_v_ptr,__Pyx_memviewslice __pyx_v_vec,bool __pyx_v_isherm,CYTHON_UNUSED int __pyx_skip_dispatch)6600 static PyObject *__pyx_f_5qutip_2cy_10spmatfuncs_cy_expect_psi_csr(__Pyx_memviewslice __pyx_v_data, __Pyx_memviewslice __pyx_v_ind, __Pyx_memviewslice __pyx_v_ptr, __Pyx_memviewslice __pyx_v_vec, bool __pyx_v_isherm, CYTHON_UNUSED int __pyx_skip_dispatch) {
6601   size_t __pyx_v_row;
6602   size_t __pyx_v_jj;
6603   int __pyx_v_nrows;
6604   __pyx_t_double_complex __pyx_v_expt;
6605   __pyx_t_double_complex __pyx_v_temp;
6606   __pyx_t_double_complex __pyx_v_cval;
6607   PyObject *__pyx_r = NULL;
6608   __Pyx_RefNannyDeclarations
6609   int __pyx_t_1;
6610   int __pyx_t_2;
6611   size_t __pyx_t_3;
6612   size_t __pyx_t_4;
6613   int __pyx_t_5;
6614   int __pyx_t_6;
6615   size_t __pyx_t_7;
6616   size_t __pyx_t_8;
6617   size_t __pyx_t_9;
6618   Py_ssize_t __pyx_t_10;
6619   int __pyx_t_11;
6620   PyObject *__pyx_t_12 = NULL;
6621   int __pyx_lineno = 0;
6622   const char *__pyx_filename = NULL;
6623   int __pyx_clineno = 0;
6624   __Pyx_RefNannySetupContext("cy_expect_psi_csr", 0);
6625 
6626   /* "qutip/cy/spmatfuncs.pyx":395
6627  *
6628  *     cdef size_t row, jj
6629  *     cdef int nrows = vec.shape[0]             # <<<<<<<<<<<<<<
6630  *     cdef complex expt = 0, temp, cval
6631  *
6632  */
6633   __pyx_v_nrows = (__pyx_v_vec.shape[0]);
6634 
6635   /* "qutip/cy/spmatfuncs.pyx":396
6636  *     cdef size_t row, jj
6637  *     cdef int nrows = vec.shape[0]
6638  *     cdef complex expt = 0, temp, cval             # <<<<<<<<<<<<<<
6639  *
6640  *     for row in range(nrows):
6641  */
6642   __pyx_v_expt = __pyx_t_double_complex_from_parts(0, 0);
6643 
6644   /* "qutip/cy/spmatfuncs.pyx":398
6645  *     cdef complex expt = 0, temp, cval
6646  *
6647  *     for row in range(nrows):             # <<<<<<<<<<<<<<
6648  *         cval = conj(vec[row])
6649  *         temp = 0
6650  */
6651   __pyx_t_1 = __pyx_v_nrows;
6652   __pyx_t_2 = __pyx_t_1;
6653   for (__pyx_t_3 = 0; __pyx_t_3 < __pyx_t_2; __pyx_t_3+=1) {
6654     __pyx_v_row = __pyx_t_3;
6655 
6656     /* "qutip/cy/spmatfuncs.pyx":399
6657  *
6658  *     for row in range(nrows):
6659  *         cval = conj(vec[row])             # <<<<<<<<<<<<<<
6660  *         temp = 0
6661  *         for jj in range(ptr[row], ptr[row+1]):
6662  */
6663     __pyx_t_4 = __pyx_v_row;
6664     __pyx_v_cval = std::conj((*((__pyx_t_double_complex *) ( /* dim=0 */ ((char *) (((__pyx_t_double_complex *) __pyx_v_vec.data) + __pyx_t_4)) ))));
6665 
6666     /* "qutip/cy/spmatfuncs.pyx":400
6667  *     for row in range(nrows):
6668  *         cval = conj(vec[row])
6669  *         temp = 0             # <<<<<<<<<<<<<<
6670  *         for jj in range(ptr[row], ptr[row+1]):
6671  *             temp += data[jj]*vec[ind[jj]]
6672  */
6673     __pyx_v_temp = __pyx_t_double_complex_from_parts(0, 0);
6674 
6675     /* "qutip/cy/spmatfuncs.pyx":401
6676  *         cval = conj(vec[row])
6677  *         temp = 0
6678  *         for jj in range(ptr[row], ptr[row+1]):             # <<<<<<<<<<<<<<
6679  *             temp += data[jj]*vec[ind[jj]]
6680  *         expt += cval*temp
6681  */
6682     __pyx_t_4 = (__pyx_v_row + 1);
6683     __pyx_t_5 = (*((int *) ( /* dim=0 */ ((char *) (((int *) __pyx_v_ptr.data) + __pyx_t_4)) )));
6684     __pyx_t_4 = __pyx_v_row;
6685     __pyx_t_6 = __pyx_t_5;
6686     for (__pyx_t_7 = (*((int *) ( /* dim=0 */ ((char *) (((int *) __pyx_v_ptr.data) + __pyx_t_4)) ))); __pyx_t_7 < __pyx_t_6; __pyx_t_7+=1) {
6687       __pyx_v_jj = __pyx_t_7;
6688 
6689       /* "qutip/cy/spmatfuncs.pyx":402
6690  *         temp = 0
6691  *         for jj in range(ptr[row], ptr[row+1]):
6692  *             temp += data[jj]*vec[ind[jj]]             # <<<<<<<<<<<<<<
6693  *         expt += cval*temp
6694  *
6695  */
6696       __pyx_t_8 = __pyx_v_jj;
6697       __pyx_t_9 = __pyx_v_jj;
6698       __pyx_t_10 = (*((int *) ( /* dim=0 */ ((char *) (((int *) __pyx_v_ind.data) + __pyx_t_9)) )));
6699       __pyx_v_temp = __Pyx_c_sum_double(__pyx_v_temp, __Pyx_c_prod_double((*((__pyx_t_double_complex *) ( /* dim=0 */ ((char *) (((__pyx_t_double_complex *) __pyx_v_data.data) + __pyx_t_8)) ))), (*((__pyx_t_double_complex *) ( /* dim=0 */ ((char *) (((__pyx_t_double_complex *) __pyx_v_vec.data) + __pyx_t_10)) )))));
6700     }
6701 
6702     /* "qutip/cy/spmatfuncs.pyx":403
6703  *         for jj in range(ptr[row], ptr[row+1]):
6704  *             temp += data[jj]*vec[ind[jj]]
6705  *         expt += cval*temp             # <<<<<<<<<<<<<<
6706  *
6707  *     if isherm :
6708  */
6709     __pyx_v_expt = __Pyx_c_sum_double(__pyx_v_expt, __Pyx_c_prod_double(__pyx_v_cval, __pyx_v_temp));
6710   }
6711 
6712   /* "qutip/cy/spmatfuncs.pyx":405
6713  *         expt += cval*temp
6714  *
6715  *     if isherm :             # <<<<<<<<<<<<<<
6716  *         return real(expt)
6717  *     else:
6718  */
6719   __pyx_t_11 = (__pyx_v_isherm != 0);
6720   if (__pyx_t_11) {
6721 
6722     /* "qutip/cy/spmatfuncs.pyx":406
6723  *
6724  *     if isherm :
6725  *         return real(expt)             # <<<<<<<<<<<<<<
6726  *     else:
6727  *         return expt
6728  */
6729     __Pyx_XDECREF(__pyx_r);
6730     __pyx_t_12 = PyFloat_FromDouble(std::real(__pyx_v_expt)); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 406, __pyx_L1_error)
6731     __Pyx_GOTREF(__pyx_t_12);
6732     __pyx_r = __pyx_t_12;
6733     __pyx_t_12 = 0;
6734     goto __pyx_L0;
6735 
6736     /* "qutip/cy/spmatfuncs.pyx":405
6737  *         expt += cval*temp
6738  *
6739  *     if isherm :             # <<<<<<<<<<<<<<
6740  *         return real(expt)
6741  *     else:
6742  */
6743   }
6744 
6745   /* "qutip/cy/spmatfuncs.pyx":408
6746  *         return real(expt)
6747  *     else:
6748  *         return expt             # <<<<<<<<<<<<<<
6749  *
6750  *
6751  */
6752   /*else*/ {
6753     __Pyx_XDECREF(__pyx_r);
6754     __pyx_t_12 = __pyx_PyComplex_FromComplex(__pyx_v_expt); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 408, __pyx_L1_error)
6755     __Pyx_GOTREF(__pyx_t_12);
6756     __pyx_r = __pyx_t_12;
6757     __pyx_t_12 = 0;
6758     goto __pyx_L0;
6759   }
6760 
6761   /* "qutip/cy/spmatfuncs.pyx":388
6762  * @cython.boundscheck(False)
6763  * @cython.wraparound(False)
6764  * cpdef cy_expect_psi_csr(complex[::1] data,             # <<<<<<<<<<<<<<
6765  *                         int[::1] ind,
6766  *                         int[::1] ptr,
6767  */
6768 
6769   /* function exit code */
6770   __pyx_L1_error:;
6771   __Pyx_XDECREF(__pyx_t_12);
6772   __Pyx_AddTraceback("qutip.cy.spmatfuncs.cy_expect_psi_csr", __pyx_clineno, __pyx_lineno, __pyx_filename);
6773   __pyx_r = 0;
6774   __pyx_L0:;
6775   __Pyx_XGIVEREF(__pyx_r);
6776   __Pyx_RefNannyFinishContext();
6777   return __pyx_r;
6778 }
6779 
6780 /* Python wrapper */
6781 static PyObject *__pyx_pw_5qutip_2cy_10spmatfuncs_27cy_expect_psi_csr(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
__pyx_pw_5qutip_2cy_10spmatfuncs_27cy_expect_psi_csr(PyObject * __pyx_self,PyObject * __pyx_args,PyObject * __pyx_kwds)6782 static PyObject *__pyx_pw_5qutip_2cy_10spmatfuncs_27cy_expect_psi_csr(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
6783   __Pyx_memviewslice __pyx_v_data = { 0, 0, { 0 }, { 0 }, { 0 } };
6784   __Pyx_memviewslice __pyx_v_ind = { 0, 0, { 0 }, { 0 }, { 0 } };
6785   __Pyx_memviewslice __pyx_v_ptr = { 0, 0, { 0 }, { 0 }, { 0 } };
6786   __Pyx_memviewslice __pyx_v_vec = { 0, 0, { 0 }, { 0 }, { 0 } };
6787   bool __pyx_v_isherm;
6788   int __pyx_lineno = 0;
6789   const char *__pyx_filename = NULL;
6790   int __pyx_clineno = 0;
6791   PyObject *__pyx_r = 0;
6792   __Pyx_RefNannyDeclarations
6793   __Pyx_RefNannySetupContext("cy_expect_psi_csr (wrapper)", 0);
6794   {
6795     static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_data,&__pyx_n_s_ind,&__pyx_n_s_ptr,&__pyx_n_s_vec,&__pyx_n_s_isherm,0};
6796     PyObject* values[5] = {0,0,0,0,0};
6797     if (unlikely(__pyx_kwds)) {
6798       Py_ssize_t kw_args;
6799       const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
6800       switch (pos_args) {
6801         case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
6802         CYTHON_FALLTHROUGH;
6803         case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
6804         CYTHON_FALLTHROUGH;
6805         case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
6806         CYTHON_FALLTHROUGH;
6807         case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
6808         CYTHON_FALLTHROUGH;
6809         case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
6810         CYTHON_FALLTHROUGH;
6811         case  0: break;
6812         default: goto __pyx_L5_argtuple_error;
6813       }
6814       kw_args = PyDict_Size(__pyx_kwds);
6815       switch (pos_args) {
6816         case  0:
6817         if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_data)) != 0)) kw_args--;
6818         else goto __pyx_L5_argtuple_error;
6819         CYTHON_FALLTHROUGH;
6820         case  1:
6821         if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_ind)) != 0)) kw_args--;
6822         else {
6823           __Pyx_RaiseArgtupleInvalid("cy_expect_psi_csr", 1, 5, 5, 1); __PYX_ERR(0, 388, __pyx_L3_error)
6824         }
6825         CYTHON_FALLTHROUGH;
6826         case  2:
6827         if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_ptr)) != 0)) kw_args--;
6828         else {
6829           __Pyx_RaiseArgtupleInvalid("cy_expect_psi_csr", 1, 5, 5, 2); __PYX_ERR(0, 388, __pyx_L3_error)
6830         }
6831         CYTHON_FALLTHROUGH;
6832         case  3:
6833         if (likely((values[3] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_vec)) != 0)) kw_args--;
6834         else {
6835           __Pyx_RaiseArgtupleInvalid("cy_expect_psi_csr", 1, 5, 5, 3); __PYX_ERR(0, 388, __pyx_L3_error)
6836         }
6837         CYTHON_FALLTHROUGH;
6838         case  4:
6839         if (likely((values[4] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_isherm)) != 0)) kw_args--;
6840         else {
6841           __Pyx_RaiseArgtupleInvalid("cy_expect_psi_csr", 1, 5, 5, 4); __PYX_ERR(0, 388, __pyx_L3_error)
6842         }
6843       }
6844       if (unlikely(kw_args > 0)) {
6845         if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "cy_expect_psi_csr") < 0)) __PYX_ERR(0, 388, __pyx_L3_error)
6846       }
6847     } else if (PyTuple_GET_SIZE(__pyx_args) != 5) {
6848       goto __pyx_L5_argtuple_error;
6849     } else {
6850       values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
6851       values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
6852       values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
6853       values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
6854       values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
6855     }
6856     __pyx_v_data = __Pyx_PyObject_to_MemoryviewSlice_dc___pyx_t_double_complex(values[0], PyBUF_WRITABLE); if (unlikely(!__pyx_v_data.memview)) __PYX_ERR(0, 388, __pyx_L3_error)
6857     __pyx_v_ind = __Pyx_PyObject_to_MemoryviewSlice_dc_int(values[1], PyBUF_WRITABLE); if (unlikely(!__pyx_v_ind.memview)) __PYX_ERR(0, 389, __pyx_L3_error)
6858     __pyx_v_ptr = __Pyx_PyObject_to_MemoryviewSlice_dc_int(values[2], PyBUF_WRITABLE); if (unlikely(!__pyx_v_ptr.memview)) __PYX_ERR(0, 390, __pyx_L3_error)
6859     __pyx_v_vec = __Pyx_PyObject_to_MemoryviewSlice_dc___pyx_t_double_complex(values[3], PyBUF_WRITABLE); if (unlikely(!__pyx_v_vec.memview)) __PYX_ERR(0, 391, __pyx_L3_error)
6860     __pyx_v_isherm = __Pyx_PyObject_IsTrue(values[4]); if (unlikely((__pyx_v_isherm == ((bool)-1)) && PyErr_Occurred())) __PYX_ERR(0, 392, __pyx_L3_error)
6861   }
6862   goto __pyx_L4_argument_unpacking_done;
6863   __pyx_L5_argtuple_error:;
6864   __Pyx_RaiseArgtupleInvalid("cy_expect_psi_csr", 1, 5, 5, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 388, __pyx_L3_error)
6865   __pyx_L3_error:;
6866   __Pyx_AddTraceback("qutip.cy.spmatfuncs.cy_expect_psi_csr", __pyx_clineno, __pyx_lineno, __pyx_filename);
6867   __Pyx_RefNannyFinishContext();
6868   return NULL;
6869   __pyx_L4_argument_unpacking_done:;
6870   __pyx_r = __pyx_pf_5qutip_2cy_10spmatfuncs_26cy_expect_psi_csr(__pyx_self, __pyx_v_data, __pyx_v_ind, __pyx_v_ptr, __pyx_v_vec, __pyx_v_isherm);
6871 
6872   /* function exit code */
6873   __Pyx_RefNannyFinishContext();
6874   return __pyx_r;
6875 }
6876 
__pyx_pf_5qutip_2cy_10spmatfuncs_26cy_expect_psi_csr(CYTHON_UNUSED PyObject * __pyx_self,__Pyx_memviewslice __pyx_v_data,__Pyx_memviewslice __pyx_v_ind,__Pyx_memviewslice __pyx_v_ptr,__Pyx_memviewslice __pyx_v_vec,bool __pyx_v_isherm)6877 static PyObject *__pyx_pf_5qutip_2cy_10spmatfuncs_26cy_expect_psi_csr(CYTHON_UNUSED PyObject *__pyx_self, __Pyx_memviewslice __pyx_v_data, __Pyx_memviewslice __pyx_v_ind, __Pyx_memviewslice __pyx_v_ptr, __Pyx_memviewslice __pyx_v_vec, bool __pyx_v_isherm) {
6878   PyObject *__pyx_r = NULL;
6879   __Pyx_RefNannyDeclarations
6880   PyObject *__pyx_t_1 = NULL;
6881   int __pyx_lineno = 0;
6882   const char *__pyx_filename = NULL;
6883   int __pyx_clineno = 0;
6884   __Pyx_RefNannySetupContext("cy_expect_psi_csr", 0);
6885   __Pyx_XDECREF(__pyx_r);
6886   if (unlikely(!__pyx_v_data.memview)) { __Pyx_RaiseUnboundLocalError("data"); __PYX_ERR(0, 388, __pyx_L1_error) }
6887   if (unlikely(!__pyx_v_ind.memview)) { __Pyx_RaiseUnboundLocalError("ind"); __PYX_ERR(0, 388, __pyx_L1_error) }
6888   if (unlikely(!__pyx_v_ptr.memview)) { __Pyx_RaiseUnboundLocalError("ptr"); __PYX_ERR(0, 388, __pyx_L1_error) }
6889   if (unlikely(!__pyx_v_vec.memview)) { __Pyx_RaiseUnboundLocalError("vec"); __PYX_ERR(0, 388, __pyx_L1_error) }
6890   __pyx_t_1 = __pyx_f_5qutip_2cy_10spmatfuncs_cy_expect_psi_csr(__pyx_v_data, __pyx_v_ind, __pyx_v_ptr, __pyx_v_vec, __pyx_v_isherm, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 388, __pyx_L1_error)
6891   __Pyx_GOTREF(__pyx_t_1);
6892   __pyx_r = __pyx_t_1;
6893   __pyx_t_1 = 0;
6894   goto __pyx_L0;
6895 
6896   /* function exit code */
6897   __pyx_L1_error:;
6898   __Pyx_XDECREF(__pyx_t_1);
6899   __Pyx_AddTraceback("qutip.cy.spmatfuncs.cy_expect_psi_csr", __pyx_clineno, __pyx_lineno, __pyx_filename);
6900   __pyx_r = NULL;
6901   __pyx_L0:;
6902   __PYX_XDEC_MEMVIEW(&__pyx_v_data, 1);
6903   __PYX_XDEC_MEMVIEW(&__pyx_v_ind, 1);
6904   __PYX_XDEC_MEMVIEW(&__pyx_v_ptr, 1);
6905   __PYX_XDEC_MEMVIEW(&__pyx_v_vec, 1);
6906   __Pyx_XGIVEREF(__pyx_r);
6907   __Pyx_RefNannyFinishContext();
6908   return __pyx_r;
6909 }
6910 
6911 /* "qutip/cy/spmatfuncs.pyx":413
6912  * @cython.boundscheck(False)
6913  * @cython.wraparound(False)
6914  * cpdef cy_expect_rho_vec(object super_op,             # <<<<<<<<<<<<<<
6915  *                         complex[::1] rho_vec,
6916  *                         int herm):
6917  */
6918 
6919 static PyObject *__pyx_pw_5qutip_2cy_10spmatfuncs_29cy_expect_rho_vec(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
__pyx_f_5qutip_2cy_10spmatfuncs_cy_expect_rho_vec(PyObject * __pyx_v_super_op,__Pyx_memviewslice __pyx_v_rho_vec,int __pyx_v_herm,CYTHON_UNUSED int __pyx_skip_dispatch)6920 static PyObject *__pyx_f_5qutip_2cy_10spmatfuncs_cy_expect_rho_vec(PyObject *__pyx_v_super_op, __Pyx_memviewslice __pyx_v_rho_vec, int __pyx_v_herm, CYTHON_UNUSED int __pyx_skip_dispatch) {
6921   PyObject *__pyx_r = NULL;
6922   __Pyx_RefNannyDeclarations
6923   PyObject *__pyx_t_1 = NULL;
6924   __Pyx_memviewslice __pyx_t_2 = { 0, 0, { 0 }, { 0 }, { 0 } };
6925   __Pyx_memviewslice __pyx_t_3 = { 0, 0, { 0 }, { 0 }, { 0 } };
6926   __Pyx_memviewslice __pyx_t_4 = { 0, 0, { 0 }, { 0 }, { 0 } };
6927   int __pyx_lineno = 0;
6928   const char *__pyx_filename = NULL;
6929   int __pyx_clineno = 0;
6930   __Pyx_RefNannySetupContext("cy_expect_rho_vec", 0);
6931 
6932   /* "qutip/cy/spmatfuncs.pyx":417
6933  *                         int herm):
6934  *
6935  *     return cy_expect_rho_vec_csr(super_op.data,             # <<<<<<<<<<<<<<
6936  *                                  super_op.indices,
6937  *                                  super_op.indptr,
6938  */
6939   __Pyx_XDECREF(__pyx_r);
6940   __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_super_op, __pyx_n_s_data); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 417, __pyx_L1_error)
6941   __Pyx_GOTREF(__pyx_t_1);
6942   __pyx_t_2 = __Pyx_PyObject_to_MemoryviewSlice_dc___pyx_t_double_complex(__pyx_t_1, PyBUF_WRITABLE); if (unlikely(!__pyx_t_2.memview)) __PYX_ERR(0, 417, __pyx_L1_error)
6943   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
6944 
6945   /* "qutip/cy/spmatfuncs.pyx":418
6946  *
6947  *     return cy_expect_rho_vec_csr(super_op.data,
6948  *                                  super_op.indices,             # <<<<<<<<<<<<<<
6949  *                                  super_op.indptr,
6950  *                                  rho_vec,
6951  */
6952   __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_super_op, __pyx_n_s_indices); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 418, __pyx_L1_error)
6953   __Pyx_GOTREF(__pyx_t_1);
6954   __pyx_t_3 = __Pyx_PyObject_to_MemoryviewSlice_dc_int(__pyx_t_1, PyBUF_WRITABLE); if (unlikely(!__pyx_t_3.memview)) __PYX_ERR(0, 418, __pyx_L1_error)
6955   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
6956 
6957   /* "qutip/cy/spmatfuncs.pyx":419
6958  *     return cy_expect_rho_vec_csr(super_op.data,
6959  *                                  super_op.indices,
6960  *                                  super_op.indptr,             # <<<<<<<<<<<<<<
6961  *                                  rho_vec,
6962  *                                  herm)
6963  */
6964   __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_super_op, __pyx_n_s_indptr); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 419, __pyx_L1_error)
6965   __Pyx_GOTREF(__pyx_t_1);
6966   __pyx_t_4 = __Pyx_PyObject_to_MemoryviewSlice_dc_int(__pyx_t_1, PyBUF_WRITABLE); if (unlikely(!__pyx_t_4.memview)) __PYX_ERR(0, 419, __pyx_L1_error)
6967   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
6968 
6969   /* "qutip/cy/spmatfuncs.pyx":417
6970  *                         int herm):
6971  *
6972  *     return cy_expect_rho_vec_csr(super_op.data,             # <<<<<<<<<<<<<<
6973  *                                  super_op.indices,
6974  *                                  super_op.indptr,
6975  */
6976   __pyx_t_1 = __pyx_f_5qutip_2cy_10spmatfuncs_cy_expect_rho_vec_csr(__pyx_t_2, __pyx_t_3, __pyx_t_4, __pyx_v_rho_vec, __pyx_v_herm, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 417, __pyx_L1_error)
6977   __Pyx_GOTREF(__pyx_t_1);
6978   __PYX_XDEC_MEMVIEW(&__pyx_t_2, 1);
6979   __pyx_t_2.memview = NULL;
6980   __pyx_t_2.data = NULL;
6981   __PYX_XDEC_MEMVIEW(&__pyx_t_3, 1);
6982   __pyx_t_3.memview = NULL;
6983   __pyx_t_3.data = NULL;
6984   __PYX_XDEC_MEMVIEW(&__pyx_t_4, 1);
6985   __pyx_t_4.memview = NULL;
6986   __pyx_t_4.data = NULL;
6987   __pyx_r = __pyx_t_1;
6988   __pyx_t_1 = 0;
6989   goto __pyx_L0;
6990 
6991   /* "qutip/cy/spmatfuncs.pyx":413
6992  * @cython.boundscheck(False)
6993  * @cython.wraparound(False)
6994  * cpdef cy_expect_rho_vec(object super_op,             # <<<<<<<<<<<<<<
6995  *                         complex[::1] rho_vec,
6996  *                         int herm):
6997  */
6998 
6999   /* function exit code */
7000   __pyx_L1_error:;
7001   __Pyx_XDECREF(__pyx_t_1);
7002   __PYX_XDEC_MEMVIEW(&__pyx_t_2, 1);
7003   __PYX_XDEC_MEMVIEW(&__pyx_t_3, 1);
7004   __PYX_XDEC_MEMVIEW(&__pyx_t_4, 1);
7005   __Pyx_AddTraceback("qutip.cy.spmatfuncs.cy_expect_rho_vec", __pyx_clineno, __pyx_lineno, __pyx_filename);
7006   __pyx_r = 0;
7007   __pyx_L0:;
7008   __Pyx_XGIVEREF(__pyx_r);
7009   __Pyx_RefNannyFinishContext();
7010   return __pyx_r;
7011 }
7012 
7013 /* Python wrapper */
7014 static PyObject *__pyx_pw_5qutip_2cy_10spmatfuncs_29cy_expect_rho_vec(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
__pyx_pw_5qutip_2cy_10spmatfuncs_29cy_expect_rho_vec(PyObject * __pyx_self,PyObject * __pyx_args,PyObject * __pyx_kwds)7015 static PyObject *__pyx_pw_5qutip_2cy_10spmatfuncs_29cy_expect_rho_vec(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
7016   PyObject *__pyx_v_super_op = 0;
7017   __Pyx_memviewslice __pyx_v_rho_vec = { 0, 0, { 0 }, { 0 }, { 0 } };
7018   int __pyx_v_herm;
7019   int __pyx_lineno = 0;
7020   const char *__pyx_filename = NULL;
7021   int __pyx_clineno = 0;
7022   PyObject *__pyx_r = 0;
7023   __Pyx_RefNannyDeclarations
7024   __Pyx_RefNannySetupContext("cy_expect_rho_vec (wrapper)", 0);
7025   {
7026     static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_super_op,&__pyx_n_s_rho_vec,&__pyx_n_s_herm,0};
7027     PyObject* values[3] = {0,0,0};
7028     if (unlikely(__pyx_kwds)) {
7029       Py_ssize_t kw_args;
7030       const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
7031       switch (pos_args) {
7032         case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
7033         CYTHON_FALLTHROUGH;
7034         case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
7035         CYTHON_FALLTHROUGH;
7036         case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
7037         CYTHON_FALLTHROUGH;
7038         case  0: break;
7039         default: goto __pyx_L5_argtuple_error;
7040       }
7041       kw_args = PyDict_Size(__pyx_kwds);
7042       switch (pos_args) {
7043         case  0:
7044         if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_super_op)) != 0)) kw_args--;
7045         else goto __pyx_L5_argtuple_error;
7046         CYTHON_FALLTHROUGH;
7047         case  1:
7048         if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_rho_vec)) != 0)) kw_args--;
7049         else {
7050           __Pyx_RaiseArgtupleInvalid("cy_expect_rho_vec", 1, 3, 3, 1); __PYX_ERR(0, 413, __pyx_L3_error)
7051         }
7052         CYTHON_FALLTHROUGH;
7053         case  2:
7054         if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_herm)) != 0)) kw_args--;
7055         else {
7056           __Pyx_RaiseArgtupleInvalid("cy_expect_rho_vec", 1, 3, 3, 2); __PYX_ERR(0, 413, __pyx_L3_error)
7057         }
7058       }
7059       if (unlikely(kw_args > 0)) {
7060         if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "cy_expect_rho_vec") < 0)) __PYX_ERR(0, 413, __pyx_L3_error)
7061       }
7062     } else if (PyTuple_GET_SIZE(__pyx_args) != 3) {
7063       goto __pyx_L5_argtuple_error;
7064     } else {
7065       values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
7066       values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
7067       values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
7068     }
7069     __pyx_v_super_op = values[0];
7070     __pyx_v_rho_vec = __Pyx_PyObject_to_MemoryviewSlice_dc___pyx_t_double_complex(values[1], PyBUF_WRITABLE); if (unlikely(!__pyx_v_rho_vec.memview)) __PYX_ERR(0, 414, __pyx_L3_error)
7071     __pyx_v_herm = __Pyx_PyInt_As_int(values[2]); if (unlikely((__pyx_v_herm == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 415, __pyx_L3_error)
7072   }
7073   goto __pyx_L4_argument_unpacking_done;
7074   __pyx_L5_argtuple_error:;
7075   __Pyx_RaiseArgtupleInvalid("cy_expect_rho_vec", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 413, __pyx_L3_error)
7076   __pyx_L3_error:;
7077   __Pyx_AddTraceback("qutip.cy.spmatfuncs.cy_expect_rho_vec", __pyx_clineno, __pyx_lineno, __pyx_filename);
7078   __Pyx_RefNannyFinishContext();
7079   return NULL;
7080   __pyx_L4_argument_unpacking_done:;
7081   __pyx_r = __pyx_pf_5qutip_2cy_10spmatfuncs_28cy_expect_rho_vec(__pyx_self, __pyx_v_super_op, __pyx_v_rho_vec, __pyx_v_herm);
7082 
7083   /* function exit code */
7084   __Pyx_RefNannyFinishContext();
7085   return __pyx_r;
7086 }
7087 
__pyx_pf_5qutip_2cy_10spmatfuncs_28cy_expect_rho_vec(CYTHON_UNUSED PyObject * __pyx_self,PyObject * __pyx_v_super_op,__Pyx_memviewslice __pyx_v_rho_vec,int __pyx_v_herm)7088 static PyObject *__pyx_pf_5qutip_2cy_10spmatfuncs_28cy_expect_rho_vec(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_super_op, __Pyx_memviewslice __pyx_v_rho_vec, int __pyx_v_herm) {
7089   PyObject *__pyx_r = NULL;
7090   __Pyx_RefNannyDeclarations
7091   PyObject *__pyx_t_1 = NULL;
7092   int __pyx_lineno = 0;
7093   const char *__pyx_filename = NULL;
7094   int __pyx_clineno = 0;
7095   __Pyx_RefNannySetupContext("cy_expect_rho_vec", 0);
7096   __Pyx_XDECREF(__pyx_r);
7097   if (unlikely(!__pyx_v_rho_vec.memview)) { __Pyx_RaiseUnboundLocalError("rho_vec"); __PYX_ERR(0, 413, __pyx_L1_error) }
7098   __pyx_t_1 = __pyx_f_5qutip_2cy_10spmatfuncs_cy_expect_rho_vec(__pyx_v_super_op, __pyx_v_rho_vec, __pyx_v_herm, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 413, __pyx_L1_error)
7099   __Pyx_GOTREF(__pyx_t_1);
7100   __pyx_r = __pyx_t_1;
7101   __pyx_t_1 = 0;
7102   goto __pyx_L0;
7103 
7104   /* function exit code */
7105   __pyx_L1_error:;
7106   __Pyx_XDECREF(__pyx_t_1);
7107   __Pyx_AddTraceback("qutip.cy.spmatfuncs.cy_expect_rho_vec", __pyx_clineno, __pyx_lineno, __pyx_filename);
7108   __pyx_r = NULL;
7109   __pyx_L0:;
7110   __PYX_XDEC_MEMVIEW(&__pyx_v_rho_vec, 1);
7111   __Pyx_XGIVEREF(__pyx_r);
7112   __Pyx_RefNannyFinishContext();
7113   return __pyx_r;
7114 }
7115 
7116 /* "qutip/cy/spmatfuncs.pyx":426
7117  * @cython.boundscheck(False)
7118  * @cython.wraparound(False)
7119  * cpdef cy_expect_rho_vec_csr(complex[::1] data,             # <<<<<<<<<<<<<<
7120  *                              int[::1] idx,
7121  *                              int[::1] ptr,
7122  */
7123 
7124 static PyObject *__pyx_pw_5qutip_2cy_10spmatfuncs_31cy_expect_rho_vec_csr(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
__pyx_f_5qutip_2cy_10spmatfuncs_cy_expect_rho_vec_csr(__Pyx_memviewslice __pyx_v_data,__Pyx_memviewslice __pyx_v_idx,__Pyx_memviewslice __pyx_v_ptr,__Pyx_memviewslice __pyx_v_rho_vec,int __pyx_v_herm,CYTHON_UNUSED int __pyx_skip_dispatch)7125 static PyObject *__pyx_f_5qutip_2cy_10spmatfuncs_cy_expect_rho_vec_csr(__Pyx_memviewslice __pyx_v_data, __Pyx_memviewslice __pyx_v_idx, __Pyx_memviewslice __pyx_v_ptr, __Pyx_memviewslice __pyx_v_rho_vec, int __pyx_v_herm, CYTHON_UNUSED int __pyx_skip_dispatch) {
7126   size_t __pyx_v_row;
7127   int __pyx_v_jj;
7128   int __pyx_v_row_start;
7129   int __pyx_v_row_end;
7130   int __pyx_v_num_rows;
7131   int __pyx_v_n;
7132   __pyx_t_double_complex __pyx_v_dot;
7133   PyObject *__pyx_r = NULL;
7134   __Pyx_RefNannyDeclarations
7135   int __pyx_t_1;
7136   long __pyx_t_2;
7137   size_t __pyx_t_3;
7138   int __pyx_t_4;
7139   Py_ssize_t __pyx_t_5;
7140   Py_ssize_t __pyx_t_6;
7141   Py_ssize_t __pyx_t_7;
7142   int __pyx_t_8;
7143   PyObject *__pyx_t_9 = NULL;
7144   int __pyx_lineno = 0;
7145   const char *__pyx_filename = NULL;
7146   int __pyx_clineno = 0;
7147   __Pyx_RefNannySetupContext("cy_expect_rho_vec_csr", 0);
7148 
7149   /* "qutip/cy/spmatfuncs.pyx":434
7150  *     cdef size_t row
7151  *     cdef int jj,row_start,row_end
7152  *     cdef int num_rows = rho_vec.shape[0]             # <<<<<<<<<<<<<<
7153  *     cdef int n = <int>libc.math.sqrt(num_rows)
7154  *     cdef complex dot = 0.0
7155  */
7156   __pyx_v_num_rows = (__pyx_v_rho_vec.shape[0]);
7157 
7158   /* "qutip/cy/spmatfuncs.pyx":435
7159  *     cdef int jj,row_start,row_end
7160  *     cdef int num_rows = rho_vec.shape[0]
7161  *     cdef int n = <int>libc.math.sqrt(num_rows)             # <<<<<<<<<<<<<<
7162  *     cdef complex dot = 0.0
7163  *
7164  */
7165   __pyx_v_n = ((int)sqrt(__pyx_v_num_rows));
7166 
7167   /* "qutip/cy/spmatfuncs.pyx":436
7168  *     cdef int num_rows = rho_vec.shape[0]
7169  *     cdef int n = <int>libc.math.sqrt(num_rows)
7170  *     cdef complex dot = 0.0             # <<<<<<<<<<<<<<
7171  *
7172  *     for row from 0 <= row < num_rows by n+1:
7173  */
7174   __pyx_v_dot = __pyx_t_double_complex_from_parts(0.0, 0);
7175 
7176   /* "qutip/cy/spmatfuncs.pyx":438
7177  *     cdef complex dot = 0.0
7178  *
7179  *     for row from 0 <= row < num_rows by n+1:             # <<<<<<<<<<<<<<
7180  *         row_start = ptr[row]
7181  *         row_end = ptr[row+1]
7182  */
7183   __pyx_t_1 = __pyx_v_num_rows;
7184   __pyx_t_2 = (__pyx_v_n + 1);
7185   for (__pyx_v_row = 0; __pyx_v_row < __pyx_t_1; __pyx_v_row+=__pyx_t_2) {
7186 
7187     /* "qutip/cy/spmatfuncs.pyx":439
7188  *
7189  *     for row from 0 <= row < num_rows by n+1:
7190  *         row_start = ptr[row]             # <<<<<<<<<<<<<<
7191  *         row_end = ptr[row+1]
7192  *         for jj from row_start <= jj < row_end:
7193  */
7194     __pyx_t_3 = __pyx_v_row;
7195     __pyx_v_row_start = (*((int *) ( /* dim=0 */ ((char *) (((int *) __pyx_v_ptr.data) + __pyx_t_3)) )));
7196 
7197     /* "qutip/cy/spmatfuncs.pyx":440
7198  *     for row from 0 <= row < num_rows by n+1:
7199  *         row_start = ptr[row]
7200  *         row_end = ptr[row+1]             # <<<<<<<<<<<<<<
7201  *         for jj from row_start <= jj < row_end:
7202  *             dot += data[jj]*rho_vec[idx[jj]]
7203  */
7204     __pyx_t_3 = (__pyx_v_row + 1);
7205     __pyx_v_row_end = (*((int *) ( /* dim=0 */ ((char *) (((int *) __pyx_v_ptr.data) + __pyx_t_3)) )));
7206 
7207     /* "qutip/cy/spmatfuncs.pyx":441
7208  *         row_start = ptr[row]
7209  *         row_end = ptr[row+1]
7210  *         for jj from row_start <= jj < row_end:             # <<<<<<<<<<<<<<
7211  *             dot += data[jj]*rho_vec[idx[jj]]
7212  *
7213  */
7214     __pyx_t_4 = __pyx_v_row_end;
7215     for (__pyx_v_jj = __pyx_v_row_start; __pyx_v_jj < __pyx_t_4; __pyx_v_jj++) {
7216 
7217       /* "qutip/cy/spmatfuncs.pyx":442
7218  *         row_end = ptr[row+1]
7219  *         for jj from row_start <= jj < row_end:
7220  *             dot += data[jj]*rho_vec[idx[jj]]             # <<<<<<<<<<<<<<
7221  *
7222  *     if herm == 0:
7223  */
7224       __pyx_t_5 = __pyx_v_jj;
7225       __pyx_t_6 = __pyx_v_jj;
7226       __pyx_t_7 = (*((int *) ( /* dim=0 */ ((char *) (((int *) __pyx_v_idx.data) + __pyx_t_6)) )));
7227       __pyx_v_dot = __Pyx_c_sum_double(__pyx_v_dot, __Pyx_c_prod_double((*((__pyx_t_double_complex *) ( /* dim=0 */ ((char *) (((__pyx_t_double_complex *) __pyx_v_data.data) + __pyx_t_5)) ))), (*((__pyx_t_double_complex *) ( /* dim=0 */ ((char *) (((__pyx_t_double_complex *) __pyx_v_rho_vec.data) + __pyx_t_7)) )))));
7228     }
7229   }
7230 
7231   /* "qutip/cy/spmatfuncs.pyx":444
7232  *             dot += data[jj]*rho_vec[idx[jj]]
7233  *
7234  *     if herm == 0:             # <<<<<<<<<<<<<<
7235  *         return dot
7236  *     else:
7237  */
7238   __pyx_t_8 = ((__pyx_v_herm == 0) != 0);
7239   if (__pyx_t_8) {
7240 
7241     /* "qutip/cy/spmatfuncs.pyx":445
7242  *
7243  *     if herm == 0:
7244  *         return dot             # <<<<<<<<<<<<<<
7245  *     else:
7246  *         return real(dot)
7247  */
7248     __Pyx_XDECREF(__pyx_r);
7249     __pyx_t_9 = __pyx_PyComplex_FromComplex(__pyx_v_dot); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 445, __pyx_L1_error)
7250     __Pyx_GOTREF(__pyx_t_9);
7251     __pyx_r = __pyx_t_9;
7252     __pyx_t_9 = 0;
7253     goto __pyx_L0;
7254 
7255     /* "qutip/cy/spmatfuncs.pyx":444
7256  *             dot += data[jj]*rho_vec[idx[jj]]
7257  *
7258  *     if herm == 0:             # <<<<<<<<<<<<<<
7259  *         return dot
7260  *     else:
7261  */
7262   }
7263 
7264   /* "qutip/cy/spmatfuncs.pyx":447
7265  *         return dot
7266  *     else:
7267  *         return real(dot)             # <<<<<<<<<<<<<<
7268  *
7269  *
7270  */
7271   /*else*/ {
7272     __Pyx_XDECREF(__pyx_r);
7273     __pyx_t_9 = PyFloat_FromDouble(std::real(__pyx_v_dot)); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 447, __pyx_L1_error)
7274     __Pyx_GOTREF(__pyx_t_9);
7275     __pyx_r = __pyx_t_9;
7276     __pyx_t_9 = 0;
7277     goto __pyx_L0;
7278   }
7279 
7280   /* "qutip/cy/spmatfuncs.pyx":426
7281  * @cython.boundscheck(False)
7282  * @cython.wraparound(False)
7283  * cpdef cy_expect_rho_vec_csr(complex[::1] data,             # <<<<<<<<<<<<<<
7284  *                              int[::1] idx,
7285  *                              int[::1] ptr,
7286  */
7287 
7288   /* function exit code */
7289   __pyx_L1_error:;
7290   __Pyx_XDECREF(__pyx_t_9);
7291   __Pyx_AddTraceback("qutip.cy.spmatfuncs.cy_expect_rho_vec_csr", __pyx_clineno, __pyx_lineno, __pyx_filename);
7292   __pyx_r = 0;
7293   __pyx_L0:;
7294   __Pyx_XGIVEREF(__pyx_r);
7295   __Pyx_RefNannyFinishContext();
7296   return __pyx_r;
7297 }
7298 
7299 /* Python wrapper */
7300 static PyObject *__pyx_pw_5qutip_2cy_10spmatfuncs_31cy_expect_rho_vec_csr(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
__pyx_pw_5qutip_2cy_10spmatfuncs_31cy_expect_rho_vec_csr(PyObject * __pyx_self,PyObject * __pyx_args,PyObject * __pyx_kwds)7301 static PyObject *__pyx_pw_5qutip_2cy_10spmatfuncs_31cy_expect_rho_vec_csr(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
7302   __Pyx_memviewslice __pyx_v_data = { 0, 0, { 0 }, { 0 }, { 0 } };
7303   __Pyx_memviewslice __pyx_v_idx = { 0, 0, { 0 }, { 0 }, { 0 } };
7304   __Pyx_memviewslice __pyx_v_ptr = { 0, 0, { 0 }, { 0 }, { 0 } };
7305   __Pyx_memviewslice __pyx_v_rho_vec = { 0, 0, { 0 }, { 0 }, { 0 } };
7306   int __pyx_v_herm;
7307   int __pyx_lineno = 0;
7308   const char *__pyx_filename = NULL;
7309   int __pyx_clineno = 0;
7310   PyObject *__pyx_r = 0;
7311   __Pyx_RefNannyDeclarations
7312   __Pyx_RefNannySetupContext("cy_expect_rho_vec_csr (wrapper)", 0);
7313   {
7314     static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_data,&__pyx_n_s_idx,&__pyx_n_s_ptr,&__pyx_n_s_rho_vec,&__pyx_n_s_herm,0};
7315     PyObject* values[5] = {0,0,0,0,0};
7316     if (unlikely(__pyx_kwds)) {
7317       Py_ssize_t kw_args;
7318       const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
7319       switch (pos_args) {
7320         case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
7321         CYTHON_FALLTHROUGH;
7322         case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
7323         CYTHON_FALLTHROUGH;
7324         case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
7325         CYTHON_FALLTHROUGH;
7326         case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
7327         CYTHON_FALLTHROUGH;
7328         case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
7329         CYTHON_FALLTHROUGH;
7330         case  0: break;
7331         default: goto __pyx_L5_argtuple_error;
7332       }
7333       kw_args = PyDict_Size(__pyx_kwds);
7334       switch (pos_args) {
7335         case  0:
7336         if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_data)) != 0)) kw_args--;
7337         else goto __pyx_L5_argtuple_error;
7338         CYTHON_FALLTHROUGH;
7339         case  1:
7340         if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_idx)) != 0)) kw_args--;
7341         else {
7342           __Pyx_RaiseArgtupleInvalid("cy_expect_rho_vec_csr", 1, 5, 5, 1); __PYX_ERR(0, 426, __pyx_L3_error)
7343         }
7344         CYTHON_FALLTHROUGH;
7345         case  2:
7346         if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_ptr)) != 0)) kw_args--;
7347         else {
7348           __Pyx_RaiseArgtupleInvalid("cy_expect_rho_vec_csr", 1, 5, 5, 2); __PYX_ERR(0, 426, __pyx_L3_error)
7349         }
7350         CYTHON_FALLTHROUGH;
7351         case  3:
7352         if (likely((values[3] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_rho_vec)) != 0)) kw_args--;
7353         else {
7354           __Pyx_RaiseArgtupleInvalid("cy_expect_rho_vec_csr", 1, 5, 5, 3); __PYX_ERR(0, 426, __pyx_L3_error)
7355         }
7356         CYTHON_FALLTHROUGH;
7357         case  4:
7358         if (likely((values[4] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_herm)) != 0)) kw_args--;
7359         else {
7360           __Pyx_RaiseArgtupleInvalid("cy_expect_rho_vec_csr", 1, 5, 5, 4); __PYX_ERR(0, 426, __pyx_L3_error)
7361         }
7362       }
7363       if (unlikely(kw_args > 0)) {
7364         if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "cy_expect_rho_vec_csr") < 0)) __PYX_ERR(0, 426, __pyx_L3_error)
7365       }
7366     } else if (PyTuple_GET_SIZE(__pyx_args) != 5) {
7367       goto __pyx_L5_argtuple_error;
7368     } else {
7369       values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
7370       values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
7371       values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
7372       values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
7373       values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
7374     }
7375     __pyx_v_data = __Pyx_PyObject_to_MemoryviewSlice_dc___pyx_t_double_complex(values[0], PyBUF_WRITABLE); if (unlikely(!__pyx_v_data.memview)) __PYX_ERR(0, 426, __pyx_L3_error)
7376     __pyx_v_idx = __Pyx_PyObject_to_MemoryviewSlice_dc_int(values[1], PyBUF_WRITABLE); if (unlikely(!__pyx_v_idx.memview)) __PYX_ERR(0, 427, __pyx_L3_error)
7377     __pyx_v_ptr = __Pyx_PyObject_to_MemoryviewSlice_dc_int(values[2], PyBUF_WRITABLE); if (unlikely(!__pyx_v_ptr.memview)) __PYX_ERR(0, 428, __pyx_L3_error)
7378     __pyx_v_rho_vec = __Pyx_PyObject_to_MemoryviewSlice_dc___pyx_t_double_complex(values[3], PyBUF_WRITABLE); if (unlikely(!__pyx_v_rho_vec.memview)) __PYX_ERR(0, 429, __pyx_L3_error)
7379     __pyx_v_herm = __Pyx_PyInt_As_int(values[4]); if (unlikely((__pyx_v_herm == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 430, __pyx_L3_error)
7380   }
7381   goto __pyx_L4_argument_unpacking_done;
7382   __pyx_L5_argtuple_error:;
7383   __Pyx_RaiseArgtupleInvalid("cy_expect_rho_vec_csr", 1, 5, 5, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 426, __pyx_L3_error)
7384   __pyx_L3_error:;
7385   __Pyx_AddTraceback("qutip.cy.spmatfuncs.cy_expect_rho_vec_csr", __pyx_clineno, __pyx_lineno, __pyx_filename);
7386   __Pyx_RefNannyFinishContext();
7387   return NULL;
7388   __pyx_L4_argument_unpacking_done:;
7389   __pyx_r = __pyx_pf_5qutip_2cy_10spmatfuncs_30cy_expect_rho_vec_csr(__pyx_self, __pyx_v_data, __pyx_v_idx, __pyx_v_ptr, __pyx_v_rho_vec, __pyx_v_herm);
7390 
7391   /* function exit code */
7392   __Pyx_RefNannyFinishContext();
7393   return __pyx_r;
7394 }
7395 
__pyx_pf_5qutip_2cy_10spmatfuncs_30cy_expect_rho_vec_csr(CYTHON_UNUSED PyObject * __pyx_self,__Pyx_memviewslice __pyx_v_data,__Pyx_memviewslice __pyx_v_idx,__Pyx_memviewslice __pyx_v_ptr,__Pyx_memviewslice __pyx_v_rho_vec,int __pyx_v_herm)7396 static PyObject *__pyx_pf_5qutip_2cy_10spmatfuncs_30cy_expect_rho_vec_csr(CYTHON_UNUSED PyObject *__pyx_self, __Pyx_memviewslice __pyx_v_data, __Pyx_memviewslice __pyx_v_idx, __Pyx_memviewslice __pyx_v_ptr, __Pyx_memviewslice __pyx_v_rho_vec, int __pyx_v_herm) {
7397   PyObject *__pyx_r = NULL;
7398   __Pyx_RefNannyDeclarations
7399   PyObject *__pyx_t_1 = NULL;
7400   int __pyx_lineno = 0;
7401   const char *__pyx_filename = NULL;
7402   int __pyx_clineno = 0;
7403   __Pyx_RefNannySetupContext("cy_expect_rho_vec_csr", 0);
7404   __Pyx_XDECREF(__pyx_r);
7405   if (unlikely(!__pyx_v_data.memview)) { __Pyx_RaiseUnboundLocalError("data"); __PYX_ERR(0, 426, __pyx_L1_error) }
7406   if (unlikely(!__pyx_v_idx.memview)) { __Pyx_RaiseUnboundLocalError("idx"); __PYX_ERR(0, 426, __pyx_L1_error) }
7407   if (unlikely(!__pyx_v_ptr.memview)) { __Pyx_RaiseUnboundLocalError("ptr"); __PYX_ERR(0, 426, __pyx_L1_error) }
7408   if (unlikely(!__pyx_v_rho_vec.memview)) { __Pyx_RaiseUnboundLocalError("rho_vec"); __PYX_ERR(0, 426, __pyx_L1_error) }
7409   __pyx_t_1 = __pyx_f_5qutip_2cy_10spmatfuncs_cy_expect_rho_vec_csr(__pyx_v_data, __pyx_v_idx, __pyx_v_ptr, __pyx_v_rho_vec, __pyx_v_herm, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 426, __pyx_L1_error)
7410   __Pyx_GOTREF(__pyx_t_1);
7411   __pyx_r = __pyx_t_1;
7412   __pyx_t_1 = 0;
7413   goto __pyx_L0;
7414 
7415   /* function exit code */
7416   __pyx_L1_error:;
7417   __Pyx_XDECREF(__pyx_t_1);
7418   __Pyx_AddTraceback("qutip.cy.spmatfuncs.cy_expect_rho_vec_csr", __pyx_clineno, __pyx_lineno, __pyx_filename);
7419   __pyx_r = NULL;
7420   __pyx_L0:;
7421   __PYX_XDEC_MEMVIEW(&__pyx_v_data, 1);
7422   __PYX_XDEC_MEMVIEW(&__pyx_v_idx, 1);
7423   __PYX_XDEC_MEMVIEW(&__pyx_v_ptr, 1);
7424   __PYX_XDEC_MEMVIEW(&__pyx_v_rho_vec, 1);
7425   __Pyx_XGIVEREF(__pyx_r);
7426   __Pyx_RefNannyFinishContext();
7427   return __pyx_r;
7428 }
7429 
7430 /* "qutip/cy/spmatfuncs.pyx":453
7431  * @cython.boundscheck(False)
7432  * @cython.wraparound(False)
7433  * cpdef cy_spmm_tr(object op1, object op2, int herm):             # <<<<<<<<<<<<<<
7434  *
7435  *     cdef size_t row
7436  */
7437 
7438 static PyObject *__pyx_pw_5qutip_2cy_10spmatfuncs_33cy_spmm_tr(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
__pyx_f_5qutip_2cy_10spmatfuncs_cy_spmm_tr(PyObject * __pyx_v_op1,PyObject * __pyx_v_op2,int __pyx_v_herm,CYTHON_UNUSED int __pyx_skip_dispatch)7439 static PyObject *__pyx_f_5qutip_2cy_10spmatfuncs_cy_spmm_tr(PyObject *__pyx_v_op1, PyObject *__pyx_v_op2, int __pyx_v_herm, CYTHON_UNUSED int __pyx_skip_dispatch) {
7440   size_t __pyx_v_row;
7441   __pyx_t_double_complex __pyx_v_tr;
7442   int __pyx_v_col1;
7443   int __pyx_v_row1_idx_start;
7444   int __pyx_v_row1_idx_end;
7445   __Pyx_memviewslice __pyx_v_data1 = { 0, 0, { 0 }, { 0 }, { 0 } };
7446   __Pyx_memviewslice __pyx_v_idx1 = { 0, 0, { 0 }, { 0 }, { 0 } };
7447   __Pyx_memviewslice __pyx_v_ptr1 = { 0, 0, { 0 }, { 0 }, { 0 } };
7448   int __pyx_v_col2;
7449   int __pyx_v_row2_idx_start;
7450   int __pyx_v_row2_idx_end;
7451   __Pyx_memviewslice __pyx_v_data2 = { 0, 0, { 0 }, { 0 }, { 0 } };
7452   __Pyx_memviewslice __pyx_v_idx2 = { 0, 0, { 0 }, { 0 }, { 0 } };
7453   __Pyx_memviewslice __pyx_v_ptr2 = { 0, 0, { 0 }, { 0 }, { 0 } };
7454   int __pyx_v_num_rows;
7455   int __pyx_v_row1_idx;
7456   int __pyx_v_row2_idx;
7457   PyObject *__pyx_r = NULL;
7458   __Pyx_RefNannyDeclarations
7459   PyObject *__pyx_t_1 = NULL;
7460   __Pyx_memviewslice __pyx_t_2 = { 0, 0, { 0 }, { 0 }, { 0 } };
7461   __Pyx_memviewslice __pyx_t_3 = { 0, 0, { 0 }, { 0 }, { 0 } };
7462   int __pyx_t_4;
7463   int __pyx_t_5;
7464   size_t __pyx_t_6;
7465   size_t __pyx_t_7;
7466   int __pyx_t_8;
7467   Py_ssize_t __pyx_t_9;
7468   int __pyx_t_10;
7469   int __pyx_t_11;
7470   Py_ssize_t __pyx_t_12;
7471   int __pyx_lineno = 0;
7472   const char *__pyx_filename = NULL;
7473   int __pyx_clineno = 0;
7474   __Pyx_RefNannySetupContext("cy_spmm_tr", 0);
7475 
7476   /* "qutip/cy/spmatfuncs.pyx":456
7477  *
7478  *     cdef size_t row
7479  *     cdef complex tr = 0.0             # <<<<<<<<<<<<<<
7480  *
7481  *     cdef int col1, row1_idx_start, row1_idx_end
7482  */
7483   __pyx_v_tr = __pyx_t_double_complex_from_parts(0.0, 0);
7484 
7485   /* "qutip/cy/spmatfuncs.pyx":459
7486  *
7487  *     cdef int col1, row1_idx_start, row1_idx_end
7488  *     cdef complex[::1] data1 = op1.data             # <<<<<<<<<<<<<<
7489  *     cdef int[::1] idx1 = op1.indices
7490  *     cdef int[::1] ptr1 = op1.indptr
7491  */
7492   __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_op1, __pyx_n_s_data); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 459, __pyx_L1_error)
7493   __Pyx_GOTREF(__pyx_t_1);
7494   __pyx_t_2 = __Pyx_PyObject_to_MemoryviewSlice_dc___pyx_t_double_complex(__pyx_t_1, PyBUF_WRITABLE); if (unlikely(!__pyx_t_2.memview)) __PYX_ERR(0, 459, __pyx_L1_error)
7495   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
7496   __pyx_v_data1 = __pyx_t_2;
7497   __pyx_t_2.memview = NULL;
7498   __pyx_t_2.data = NULL;
7499 
7500   /* "qutip/cy/spmatfuncs.pyx":460
7501  *     cdef int col1, row1_idx_start, row1_idx_end
7502  *     cdef complex[::1] data1 = op1.data
7503  *     cdef int[::1] idx1 = op1.indices             # <<<<<<<<<<<<<<
7504  *     cdef int[::1] ptr1 = op1.indptr
7505  *
7506  */
7507   __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_op1, __pyx_n_s_indices); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 460, __pyx_L1_error)
7508   __Pyx_GOTREF(__pyx_t_1);
7509   __pyx_t_3 = __Pyx_PyObject_to_MemoryviewSlice_dc_int(__pyx_t_1, PyBUF_WRITABLE); if (unlikely(!__pyx_t_3.memview)) __PYX_ERR(0, 460, __pyx_L1_error)
7510   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
7511   __pyx_v_idx1 = __pyx_t_3;
7512   __pyx_t_3.memview = NULL;
7513   __pyx_t_3.data = NULL;
7514 
7515   /* "qutip/cy/spmatfuncs.pyx":461
7516  *     cdef complex[::1] data1 = op1.data
7517  *     cdef int[::1] idx1 = op1.indices
7518  *     cdef int[::1] ptr1 = op1.indptr             # <<<<<<<<<<<<<<
7519  *
7520  *     cdef int col2, row2_idx_start, row2_idx_end
7521  */
7522   __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_op1, __pyx_n_s_indptr); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 461, __pyx_L1_error)
7523   __Pyx_GOTREF(__pyx_t_1);
7524   __pyx_t_3 = __Pyx_PyObject_to_MemoryviewSlice_dc_int(__pyx_t_1, PyBUF_WRITABLE); if (unlikely(!__pyx_t_3.memview)) __PYX_ERR(0, 461, __pyx_L1_error)
7525   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
7526   __pyx_v_ptr1 = __pyx_t_3;
7527   __pyx_t_3.memview = NULL;
7528   __pyx_t_3.data = NULL;
7529 
7530   /* "qutip/cy/spmatfuncs.pyx":464
7531  *
7532  *     cdef int col2, row2_idx_start, row2_idx_end
7533  *     cdef complex[::1] data2 = op2.data             # <<<<<<<<<<<<<<
7534  *     cdef int[::1] idx2 = op2.indices
7535  *     cdef int[::1] ptr2 = op2.indptr
7536  */
7537   __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_op2, __pyx_n_s_data); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 464, __pyx_L1_error)
7538   __Pyx_GOTREF(__pyx_t_1);
7539   __pyx_t_2 = __Pyx_PyObject_to_MemoryviewSlice_dc___pyx_t_double_complex(__pyx_t_1, PyBUF_WRITABLE); if (unlikely(!__pyx_t_2.memview)) __PYX_ERR(0, 464, __pyx_L1_error)
7540   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
7541   __pyx_v_data2 = __pyx_t_2;
7542   __pyx_t_2.memview = NULL;
7543   __pyx_t_2.data = NULL;
7544 
7545   /* "qutip/cy/spmatfuncs.pyx":465
7546  *     cdef int col2, row2_idx_start, row2_idx_end
7547  *     cdef complex[::1] data2 = op2.data
7548  *     cdef int[::1] idx2 = op2.indices             # <<<<<<<<<<<<<<
7549  *     cdef int[::1] ptr2 = op2.indptr
7550  *
7551  */
7552   __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_op2, __pyx_n_s_indices); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 465, __pyx_L1_error)
7553   __Pyx_GOTREF(__pyx_t_1);
7554   __pyx_t_3 = __Pyx_PyObject_to_MemoryviewSlice_dc_int(__pyx_t_1, PyBUF_WRITABLE); if (unlikely(!__pyx_t_3.memview)) __PYX_ERR(0, 465, __pyx_L1_error)
7555   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
7556   __pyx_v_idx2 = __pyx_t_3;
7557   __pyx_t_3.memview = NULL;
7558   __pyx_t_3.data = NULL;
7559 
7560   /* "qutip/cy/spmatfuncs.pyx":466
7561  *     cdef complex[::1] data2 = op2.data
7562  *     cdef int[::1] idx2 = op2.indices
7563  *     cdef int[::1] ptr2 = op2.indptr             # <<<<<<<<<<<<<<
7564  *
7565  *     cdef int num_rows = ptr1.shape[0]-1
7566  */
7567   __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_op2, __pyx_n_s_indptr); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 466, __pyx_L1_error)
7568   __Pyx_GOTREF(__pyx_t_1);
7569   __pyx_t_3 = __Pyx_PyObject_to_MemoryviewSlice_dc_int(__pyx_t_1, PyBUF_WRITABLE); if (unlikely(!__pyx_t_3.memview)) __PYX_ERR(0, 466, __pyx_L1_error)
7570   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
7571   __pyx_v_ptr2 = __pyx_t_3;
7572   __pyx_t_3.memview = NULL;
7573   __pyx_t_3.data = NULL;
7574 
7575   /* "qutip/cy/spmatfuncs.pyx":468
7576  *     cdef int[::1] ptr2 = op2.indptr
7577  *
7578  *     cdef int num_rows = ptr1.shape[0]-1             # <<<<<<<<<<<<<<
7579  *
7580  *     for row in range(num_rows):
7581  */
7582   __pyx_v_num_rows = ((__pyx_v_ptr1.shape[0]) - 1);
7583 
7584   /* "qutip/cy/spmatfuncs.pyx":470
7585  *     cdef int num_rows = ptr1.shape[0]-1
7586  *
7587  *     for row in range(num_rows):             # <<<<<<<<<<<<<<
7588  *
7589  *         row1_idx_start = ptr1[row]
7590  */
7591   __pyx_t_4 = __pyx_v_num_rows;
7592   __pyx_t_5 = __pyx_t_4;
7593   for (__pyx_t_6 = 0; __pyx_t_6 < __pyx_t_5; __pyx_t_6+=1) {
7594     __pyx_v_row = __pyx_t_6;
7595 
7596     /* "qutip/cy/spmatfuncs.pyx":472
7597  *     for row in range(num_rows):
7598  *
7599  *         row1_idx_start = ptr1[row]             # <<<<<<<<<<<<<<
7600  *         row1_idx_end = ptr1[row + 1]
7601  *         for row1_idx from row1_idx_start <= row1_idx < row1_idx_end:
7602  */
7603     __pyx_t_7 = __pyx_v_row;
7604     __pyx_v_row1_idx_start = (*((int *) ( /* dim=0 */ ((char *) (((int *) __pyx_v_ptr1.data) + __pyx_t_7)) )));
7605 
7606     /* "qutip/cy/spmatfuncs.pyx":473
7607  *
7608  *         row1_idx_start = ptr1[row]
7609  *         row1_idx_end = ptr1[row + 1]             # <<<<<<<<<<<<<<
7610  *         for row1_idx from row1_idx_start <= row1_idx < row1_idx_end:
7611  *             col1 = idx1[row1_idx]
7612  */
7613     __pyx_t_7 = (__pyx_v_row + 1);
7614     __pyx_v_row1_idx_end = (*((int *) ( /* dim=0 */ ((char *) (((int *) __pyx_v_ptr1.data) + __pyx_t_7)) )));
7615 
7616     /* "qutip/cy/spmatfuncs.pyx":474
7617  *         row1_idx_start = ptr1[row]
7618  *         row1_idx_end = ptr1[row + 1]
7619  *         for row1_idx from row1_idx_start <= row1_idx < row1_idx_end:             # <<<<<<<<<<<<<<
7620  *             col1 = idx1[row1_idx]
7621  *
7622  */
7623     __pyx_t_8 = __pyx_v_row1_idx_end;
7624     for (__pyx_v_row1_idx = __pyx_v_row1_idx_start; __pyx_v_row1_idx < __pyx_t_8; __pyx_v_row1_idx++) {
7625 
7626       /* "qutip/cy/spmatfuncs.pyx":475
7627  *         row1_idx_end = ptr1[row + 1]
7628  *         for row1_idx from row1_idx_start <= row1_idx < row1_idx_end:
7629  *             col1 = idx1[row1_idx]             # <<<<<<<<<<<<<<
7630  *
7631  *             row2_idx_start = ptr2[col1]
7632  */
7633       __pyx_t_9 = __pyx_v_row1_idx;
7634       __pyx_v_col1 = (*((int *) ( /* dim=0 */ ((char *) (((int *) __pyx_v_idx1.data) + __pyx_t_9)) )));
7635 
7636       /* "qutip/cy/spmatfuncs.pyx":477
7637  *             col1 = idx1[row1_idx]
7638  *
7639  *             row2_idx_start = ptr2[col1]             # <<<<<<<<<<<<<<
7640  *             row2_idx_end = ptr2[col1 + 1]
7641  *             for row2_idx from row2_idx_start <= row2_idx < row2_idx_end:
7642  */
7643       __pyx_t_9 = __pyx_v_col1;
7644       __pyx_v_row2_idx_start = (*((int *) ( /* dim=0 */ ((char *) (((int *) __pyx_v_ptr2.data) + __pyx_t_9)) )));
7645 
7646       /* "qutip/cy/spmatfuncs.pyx":478
7647  *
7648  *             row2_idx_start = ptr2[col1]
7649  *             row2_idx_end = ptr2[col1 + 1]             # <<<<<<<<<<<<<<
7650  *             for row2_idx from row2_idx_start <= row2_idx < row2_idx_end:
7651  *                 col2 = idx2[row2_idx]
7652  */
7653       __pyx_t_9 = (__pyx_v_col1 + 1);
7654       __pyx_v_row2_idx_end = (*((int *) ( /* dim=0 */ ((char *) (((int *) __pyx_v_ptr2.data) + __pyx_t_9)) )));
7655 
7656       /* "qutip/cy/spmatfuncs.pyx":479
7657  *             row2_idx_start = ptr2[col1]
7658  *             row2_idx_end = ptr2[col1 + 1]
7659  *             for row2_idx from row2_idx_start <= row2_idx < row2_idx_end:             # <<<<<<<<<<<<<<
7660  *                 col2 = idx2[row2_idx]
7661  *
7662  */
7663       __pyx_t_10 = __pyx_v_row2_idx_end;
7664       for (__pyx_v_row2_idx = __pyx_v_row2_idx_start; __pyx_v_row2_idx < __pyx_t_10; __pyx_v_row2_idx++) {
7665 
7666         /* "qutip/cy/spmatfuncs.pyx":480
7667  *             row2_idx_end = ptr2[col1 + 1]
7668  *             for row2_idx from row2_idx_start <= row2_idx < row2_idx_end:
7669  *                 col2 = idx2[row2_idx]             # <<<<<<<<<<<<<<
7670  *
7671  *                 if col2 == row:
7672  */
7673         __pyx_t_9 = __pyx_v_row2_idx;
7674         __pyx_v_col2 = (*((int *) ( /* dim=0 */ ((char *) (((int *) __pyx_v_idx2.data) + __pyx_t_9)) )));
7675 
7676         /* "qutip/cy/spmatfuncs.pyx":482
7677  *                 col2 = idx2[row2_idx]
7678  *
7679  *                 if col2 == row:             # <<<<<<<<<<<<<<
7680  *                     tr += data1[row1_idx] * data2[row2_idx]
7681  *                     break
7682  */
7683         __pyx_t_11 = ((__pyx_v_col2 == __pyx_v_row) != 0);
7684         if (__pyx_t_11) {
7685 
7686           /* "qutip/cy/spmatfuncs.pyx":483
7687  *
7688  *                 if col2 == row:
7689  *                     tr += data1[row1_idx] * data2[row2_idx]             # <<<<<<<<<<<<<<
7690  *                     break
7691  *
7692  */
7693           __pyx_t_9 = __pyx_v_row1_idx;
7694           __pyx_t_12 = __pyx_v_row2_idx;
7695           __pyx_v_tr = __Pyx_c_sum_double(__pyx_v_tr, __Pyx_c_prod_double((*((__pyx_t_double_complex *) ( /* dim=0 */ ((char *) (((__pyx_t_double_complex *) __pyx_v_data1.data) + __pyx_t_9)) ))), (*((__pyx_t_double_complex *) ( /* dim=0 */ ((char *) (((__pyx_t_double_complex *) __pyx_v_data2.data) + __pyx_t_12)) )))));
7696 
7697           /* "qutip/cy/spmatfuncs.pyx":484
7698  *                 if col2 == row:
7699  *                     tr += data1[row1_idx] * data2[row2_idx]
7700  *                     break             # <<<<<<<<<<<<<<
7701  *
7702  *     if herm == 0:
7703  */
7704           goto __pyx_L8_break;
7705 
7706           /* "qutip/cy/spmatfuncs.pyx":482
7707  *                 col2 = idx2[row2_idx]
7708  *
7709  *                 if col2 == row:             # <<<<<<<<<<<<<<
7710  *                     tr += data1[row1_idx] * data2[row2_idx]
7711  *                     break
7712  */
7713         }
7714       }
7715       __pyx_L8_break:;
7716     }
7717   }
7718 
7719   /* "qutip/cy/spmatfuncs.pyx":486
7720  *                     break
7721  *
7722  *     if herm == 0:             # <<<<<<<<<<<<<<
7723  *         return tr
7724  *     else:
7725  */
7726   __pyx_t_11 = ((__pyx_v_herm == 0) != 0);
7727   if (__pyx_t_11) {
7728 
7729     /* "qutip/cy/spmatfuncs.pyx":487
7730  *
7731  *     if herm == 0:
7732  *         return tr             # <<<<<<<<<<<<<<
7733  *     else:
7734  *         return real(tr)
7735  */
7736     __Pyx_XDECREF(__pyx_r);
7737     __pyx_t_1 = __pyx_PyComplex_FromComplex(__pyx_v_tr); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 487, __pyx_L1_error)
7738     __Pyx_GOTREF(__pyx_t_1);
7739     __pyx_r = __pyx_t_1;
7740     __pyx_t_1 = 0;
7741     goto __pyx_L0;
7742 
7743     /* "qutip/cy/spmatfuncs.pyx":486
7744  *                     break
7745  *
7746  *     if herm == 0:             # <<<<<<<<<<<<<<
7747  *         return tr
7748  *     else:
7749  */
7750   }
7751 
7752   /* "qutip/cy/spmatfuncs.pyx":489
7753  *         return tr
7754  *     else:
7755  *         return real(tr)             # <<<<<<<<<<<<<<
7756  *
7757  *
7758  */
7759   /*else*/ {
7760     __Pyx_XDECREF(__pyx_r);
7761     __pyx_t_1 = PyFloat_FromDouble(std::real(__pyx_v_tr)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 489, __pyx_L1_error)
7762     __Pyx_GOTREF(__pyx_t_1);
7763     __pyx_r = __pyx_t_1;
7764     __pyx_t_1 = 0;
7765     goto __pyx_L0;
7766   }
7767 
7768   /* "qutip/cy/spmatfuncs.pyx":453
7769  * @cython.boundscheck(False)
7770  * @cython.wraparound(False)
7771  * cpdef cy_spmm_tr(object op1, object op2, int herm):             # <<<<<<<<<<<<<<
7772  *
7773  *     cdef size_t row
7774  */
7775 
7776   /* function exit code */
7777   __pyx_L1_error:;
7778   __Pyx_XDECREF(__pyx_t_1);
7779   __PYX_XDEC_MEMVIEW(&__pyx_t_2, 1);
7780   __PYX_XDEC_MEMVIEW(&__pyx_t_3, 1);
7781   __Pyx_AddTraceback("qutip.cy.spmatfuncs.cy_spmm_tr", __pyx_clineno, __pyx_lineno, __pyx_filename);
7782   __pyx_r = 0;
7783   __pyx_L0:;
7784   __PYX_XDEC_MEMVIEW(&__pyx_v_data1, 1);
7785   __PYX_XDEC_MEMVIEW(&__pyx_v_idx1, 1);
7786   __PYX_XDEC_MEMVIEW(&__pyx_v_ptr1, 1);
7787   __PYX_XDEC_MEMVIEW(&__pyx_v_data2, 1);
7788   __PYX_XDEC_MEMVIEW(&__pyx_v_idx2, 1);
7789   __PYX_XDEC_MEMVIEW(&__pyx_v_ptr2, 1);
7790   __Pyx_XGIVEREF(__pyx_r);
7791   __Pyx_RefNannyFinishContext();
7792   return __pyx_r;
7793 }
7794 
7795 /* Python wrapper */
7796 static PyObject *__pyx_pw_5qutip_2cy_10spmatfuncs_33cy_spmm_tr(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
__pyx_pw_5qutip_2cy_10spmatfuncs_33cy_spmm_tr(PyObject * __pyx_self,PyObject * __pyx_args,PyObject * __pyx_kwds)7797 static PyObject *__pyx_pw_5qutip_2cy_10spmatfuncs_33cy_spmm_tr(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
7798   PyObject *__pyx_v_op1 = 0;
7799   PyObject *__pyx_v_op2 = 0;
7800   int __pyx_v_herm;
7801   int __pyx_lineno = 0;
7802   const char *__pyx_filename = NULL;
7803   int __pyx_clineno = 0;
7804   PyObject *__pyx_r = 0;
7805   __Pyx_RefNannyDeclarations
7806   __Pyx_RefNannySetupContext("cy_spmm_tr (wrapper)", 0);
7807   {
7808     static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_op1,&__pyx_n_s_op2,&__pyx_n_s_herm,0};
7809     PyObject* values[3] = {0,0,0};
7810     if (unlikely(__pyx_kwds)) {
7811       Py_ssize_t kw_args;
7812       const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
7813       switch (pos_args) {
7814         case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
7815         CYTHON_FALLTHROUGH;
7816         case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
7817         CYTHON_FALLTHROUGH;
7818         case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
7819         CYTHON_FALLTHROUGH;
7820         case  0: break;
7821         default: goto __pyx_L5_argtuple_error;
7822       }
7823       kw_args = PyDict_Size(__pyx_kwds);
7824       switch (pos_args) {
7825         case  0:
7826         if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_op1)) != 0)) kw_args--;
7827         else goto __pyx_L5_argtuple_error;
7828         CYTHON_FALLTHROUGH;
7829         case  1:
7830         if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_op2)) != 0)) kw_args--;
7831         else {
7832           __Pyx_RaiseArgtupleInvalid("cy_spmm_tr", 1, 3, 3, 1); __PYX_ERR(0, 453, __pyx_L3_error)
7833         }
7834         CYTHON_FALLTHROUGH;
7835         case  2:
7836         if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_herm)) != 0)) kw_args--;
7837         else {
7838           __Pyx_RaiseArgtupleInvalid("cy_spmm_tr", 1, 3, 3, 2); __PYX_ERR(0, 453, __pyx_L3_error)
7839         }
7840       }
7841       if (unlikely(kw_args > 0)) {
7842         if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "cy_spmm_tr") < 0)) __PYX_ERR(0, 453, __pyx_L3_error)
7843       }
7844     } else if (PyTuple_GET_SIZE(__pyx_args) != 3) {
7845       goto __pyx_L5_argtuple_error;
7846     } else {
7847       values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
7848       values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
7849       values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
7850     }
7851     __pyx_v_op1 = values[0];
7852     __pyx_v_op2 = values[1];
7853     __pyx_v_herm = __Pyx_PyInt_As_int(values[2]); if (unlikely((__pyx_v_herm == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 453, __pyx_L3_error)
7854   }
7855   goto __pyx_L4_argument_unpacking_done;
7856   __pyx_L5_argtuple_error:;
7857   __Pyx_RaiseArgtupleInvalid("cy_spmm_tr", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 453, __pyx_L3_error)
7858   __pyx_L3_error:;
7859   __Pyx_AddTraceback("qutip.cy.spmatfuncs.cy_spmm_tr", __pyx_clineno, __pyx_lineno, __pyx_filename);
7860   __Pyx_RefNannyFinishContext();
7861   return NULL;
7862   __pyx_L4_argument_unpacking_done:;
7863   __pyx_r = __pyx_pf_5qutip_2cy_10spmatfuncs_32cy_spmm_tr(__pyx_self, __pyx_v_op1, __pyx_v_op2, __pyx_v_herm);
7864 
7865   /* function exit code */
7866   __Pyx_RefNannyFinishContext();
7867   return __pyx_r;
7868 }
7869 
__pyx_pf_5qutip_2cy_10spmatfuncs_32cy_spmm_tr(CYTHON_UNUSED PyObject * __pyx_self,PyObject * __pyx_v_op1,PyObject * __pyx_v_op2,int __pyx_v_herm)7870 static PyObject *__pyx_pf_5qutip_2cy_10spmatfuncs_32cy_spmm_tr(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_op1, PyObject *__pyx_v_op2, int __pyx_v_herm) {
7871   PyObject *__pyx_r = NULL;
7872   __Pyx_RefNannyDeclarations
7873   PyObject *__pyx_t_1 = NULL;
7874   int __pyx_lineno = 0;
7875   const char *__pyx_filename = NULL;
7876   int __pyx_clineno = 0;
7877   __Pyx_RefNannySetupContext("cy_spmm_tr", 0);
7878   __Pyx_XDECREF(__pyx_r);
7879   __pyx_t_1 = __pyx_f_5qutip_2cy_10spmatfuncs_cy_spmm_tr(__pyx_v_op1, __pyx_v_op2, __pyx_v_herm, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 453, __pyx_L1_error)
7880   __Pyx_GOTREF(__pyx_t_1);
7881   __pyx_r = __pyx_t_1;
7882   __pyx_t_1 = 0;
7883   goto __pyx_L0;
7884 
7885   /* function exit code */
7886   __pyx_L1_error:;
7887   __Pyx_XDECREF(__pyx_t_1);
7888   __Pyx_AddTraceback("qutip.cy.spmatfuncs.cy_spmm_tr", __pyx_clineno, __pyx_lineno, __pyx_filename);
7889   __pyx_r = NULL;
7890   __pyx_L0:;
7891   __Pyx_XGIVEREF(__pyx_r);
7892   __Pyx_RefNannyFinishContext();
7893   return __pyx_r;
7894 }
7895 
7896 /* "qutip/cy/spmatfuncs.pyx":495
7897  * @cython.boundscheck(False)
7898  * @cython.wraparound(False)
7899  * def expect_csr_ket(object A, object B, int isherm):             # <<<<<<<<<<<<<<
7900  *
7901  *     cdef complex[::1] Adata = A.data
7902  */
7903 
7904 /* Python wrapper */
7905 static PyObject *__pyx_pw_5qutip_2cy_10spmatfuncs_35expect_csr_ket(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
7906 static PyMethodDef __pyx_mdef_5qutip_2cy_10spmatfuncs_35expect_csr_ket = {"expect_csr_ket", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_5qutip_2cy_10spmatfuncs_35expect_csr_ket, METH_VARARGS|METH_KEYWORDS, 0};
__pyx_pw_5qutip_2cy_10spmatfuncs_35expect_csr_ket(PyObject * __pyx_self,PyObject * __pyx_args,PyObject * __pyx_kwds)7907 static PyObject *__pyx_pw_5qutip_2cy_10spmatfuncs_35expect_csr_ket(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
7908   PyObject *__pyx_v_A = 0;
7909   PyObject *__pyx_v_B = 0;
7910   int __pyx_v_isherm;
7911   int __pyx_lineno = 0;
7912   const char *__pyx_filename = NULL;
7913   int __pyx_clineno = 0;
7914   PyObject *__pyx_r = 0;
7915   __Pyx_RefNannyDeclarations
7916   __Pyx_RefNannySetupContext("expect_csr_ket (wrapper)", 0);
7917   {
7918     static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_A,&__pyx_n_s_B,&__pyx_n_s_isherm,0};
7919     PyObject* values[3] = {0,0,0};
7920     if (unlikely(__pyx_kwds)) {
7921       Py_ssize_t kw_args;
7922       const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
7923       switch (pos_args) {
7924         case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
7925         CYTHON_FALLTHROUGH;
7926         case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
7927         CYTHON_FALLTHROUGH;
7928         case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
7929         CYTHON_FALLTHROUGH;
7930         case  0: break;
7931         default: goto __pyx_L5_argtuple_error;
7932       }
7933       kw_args = PyDict_Size(__pyx_kwds);
7934       switch (pos_args) {
7935         case  0:
7936         if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_A)) != 0)) kw_args--;
7937         else goto __pyx_L5_argtuple_error;
7938         CYTHON_FALLTHROUGH;
7939         case  1:
7940         if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_B)) != 0)) kw_args--;
7941         else {
7942           __Pyx_RaiseArgtupleInvalid("expect_csr_ket", 1, 3, 3, 1); __PYX_ERR(0, 495, __pyx_L3_error)
7943         }
7944         CYTHON_FALLTHROUGH;
7945         case  2:
7946         if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_isherm)) != 0)) kw_args--;
7947         else {
7948           __Pyx_RaiseArgtupleInvalid("expect_csr_ket", 1, 3, 3, 2); __PYX_ERR(0, 495, __pyx_L3_error)
7949         }
7950       }
7951       if (unlikely(kw_args > 0)) {
7952         if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "expect_csr_ket") < 0)) __PYX_ERR(0, 495, __pyx_L3_error)
7953       }
7954     } else if (PyTuple_GET_SIZE(__pyx_args) != 3) {
7955       goto __pyx_L5_argtuple_error;
7956     } else {
7957       values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
7958       values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
7959       values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
7960     }
7961     __pyx_v_A = values[0];
7962     __pyx_v_B = values[1];
7963     __pyx_v_isherm = __Pyx_PyInt_As_int(values[2]); if (unlikely((__pyx_v_isherm == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 495, __pyx_L3_error)
7964   }
7965   goto __pyx_L4_argument_unpacking_done;
7966   __pyx_L5_argtuple_error:;
7967   __Pyx_RaiseArgtupleInvalid("expect_csr_ket", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 495, __pyx_L3_error)
7968   __pyx_L3_error:;
7969   __Pyx_AddTraceback("qutip.cy.spmatfuncs.expect_csr_ket", __pyx_clineno, __pyx_lineno, __pyx_filename);
7970   __Pyx_RefNannyFinishContext();
7971   return NULL;
7972   __pyx_L4_argument_unpacking_done:;
7973   __pyx_r = __pyx_pf_5qutip_2cy_10spmatfuncs_34expect_csr_ket(__pyx_self, __pyx_v_A, __pyx_v_B, __pyx_v_isherm);
7974 
7975   /* function exit code */
7976   __Pyx_RefNannyFinishContext();
7977   return __pyx_r;
7978 }
7979 
__pyx_pf_5qutip_2cy_10spmatfuncs_34expect_csr_ket(CYTHON_UNUSED PyObject * __pyx_self,PyObject * __pyx_v_A,PyObject * __pyx_v_B,int __pyx_v_isherm)7980 static PyObject *__pyx_pf_5qutip_2cy_10spmatfuncs_34expect_csr_ket(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_A, PyObject *__pyx_v_B, int __pyx_v_isherm) {
7981   __Pyx_memviewslice __pyx_v_Adata = { 0, 0, { 0 }, { 0 }, { 0 } };
7982   __Pyx_memviewslice __pyx_v_Aind = { 0, 0, { 0 }, { 0 }, { 0 } };
7983   __Pyx_memviewslice __pyx_v_Aptr = { 0, 0, { 0 }, { 0 }, { 0 } };
7984   __Pyx_memviewslice __pyx_v_Bdata = { 0, 0, { 0 }, { 0 }, { 0 } };
7985   __Pyx_memviewslice __pyx_v_Bptr = { 0, 0, { 0 }, { 0 }, { 0 } };
7986   int __pyx_v_nrows;
7987   int __pyx_v_j;
7988   size_t __pyx_v_ii;
7989   size_t __pyx_v_jj;
7990   __pyx_t_double_complex __pyx_v_cval;
7991   __pyx_t_double_complex __pyx_v_row_sum;
7992   __pyx_t_double_complex __pyx_v_expt;
7993   PyObject *__pyx_r = NULL;
7994   __Pyx_RefNannyDeclarations
7995   PyObject *__pyx_t_1 = NULL;
7996   __Pyx_memviewslice __pyx_t_2 = { 0, 0, { 0 }, { 0 }, { 0 } };
7997   __Pyx_memviewslice __pyx_t_3 = { 0, 0, { 0 }, { 0 }, { 0 } };
7998   PyObject *__pyx_t_4 = NULL;
7999   int __pyx_t_5;
8000   int __pyx_t_6;
8001   size_t __pyx_t_7;
8002   size_t __pyx_t_8;
8003   size_t __pyx_t_9;
8004   int __pyx_t_10;
8005   Py_ssize_t __pyx_t_11;
8006   int __pyx_t_12;
8007   int __pyx_t_13;
8008   size_t __pyx_t_14;
8009   Py_ssize_t __pyx_t_15;
8010   int __pyx_lineno = 0;
8011   const char *__pyx_filename = NULL;
8012   int __pyx_clineno = 0;
8013   __Pyx_RefNannySetupContext("expect_csr_ket", 0);
8014 
8015   /* "qutip/cy/spmatfuncs.pyx":497
8016  * def expect_csr_ket(object A, object B, int isherm):
8017  *
8018  *     cdef complex[::1] Adata = A.data             # <<<<<<<<<<<<<<
8019  *     cdef int[::1] Aind = A.indices
8020  *     cdef int[::1] Aptr = A.indptr
8021  */
8022   __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_A, __pyx_n_s_data); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 497, __pyx_L1_error)
8023   __Pyx_GOTREF(__pyx_t_1);
8024   __pyx_t_2 = __Pyx_PyObject_to_MemoryviewSlice_dc___pyx_t_double_complex(__pyx_t_1, PyBUF_WRITABLE); if (unlikely(!__pyx_t_2.memview)) __PYX_ERR(0, 497, __pyx_L1_error)
8025   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
8026   __pyx_v_Adata = __pyx_t_2;
8027   __pyx_t_2.memview = NULL;
8028   __pyx_t_2.data = NULL;
8029 
8030   /* "qutip/cy/spmatfuncs.pyx":498
8031  *
8032  *     cdef complex[::1] Adata = A.data
8033  *     cdef int[::1] Aind = A.indices             # <<<<<<<<<<<<<<
8034  *     cdef int[::1] Aptr = A.indptr
8035  *     cdef complex[::1] Bdata = B.data
8036  */
8037   __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_A, __pyx_n_s_indices); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 498, __pyx_L1_error)
8038   __Pyx_GOTREF(__pyx_t_1);
8039   __pyx_t_3 = __Pyx_PyObject_to_MemoryviewSlice_dc_int(__pyx_t_1, PyBUF_WRITABLE); if (unlikely(!__pyx_t_3.memview)) __PYX_ERR(0, 498, __pyx_L1_error)
8040   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
8041   __pyx_v_Aind = __pyx_t_3;
8042   __pyx_t_3.memview = NULL;
8043   __pyx_t_3.data = NULL;
8044 
8045   /* "qutip/cy/spmatfuncs.pyx":499
8046  *     cdef complex[::1] Adata = A.data
8047  *     cdef int[::1] Aind = A.indices
8048  *     cdef int[::1] Aptr = A.indptr             # <<<<<<<<<<<<<<
8049  *     cdef complex[::1] Bdata = B.data
8050  *     cdef int[::1] Bptr = B.indptr
8051  */
8052   __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_A, __pyx_n_s_indptr); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 499, __pyx_L1_error)
8053   __Pyx_GOTREF(__pyx_t_1);
8054   __pyx_t_3 = __Pyx_PyObject_to_MemoryviewSlice_dc_int(__pyx_t_1, PyBUF_WRITABLE); if (unlikely(!__pyx_t_3.memview)) __PYX_ERR(0, 499, __pyx_L1_error)
8055   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
8056   __pyx_v_Aptr = __pyx_t_3;
8057   __pyx_t_3.memview = NULL;
8058   __pyx_t_3.data = NULL;
8059 
8060   /* "qutip/cy/spmatfuncs.pyx":500
8061  *     cdef int[::1] Aind = A.indices
8062  *     cdef int[::1] Aptr = A.indptr
8063  *     cdef complex[::1] Bdata = B.data             # <<<<<<<<<<<<<<
8064  *     cdef int[::1] Bptr = B.indptr
8065  *     cdef int nrows = A.shape[0]
8066  */
8067   __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_B, __pyx_n_s_data); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 500, __pyx_L1_error)
8068   __Pyx_GOTREF(__pyx_t_1);
8069   __pyx_t_2 = __Pyx_PyObject_to_MemoryviewSlice_dc___pyx_t_double_complex(__pyx_t_1, PyBUF_WRITABLE); if (unlikely(!__pyx_t_2.memview)) __PYX_ERR(0, 500, __pyx_L1_error)
8070   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
8071   __pyx_v_Bdata = __pyx_t_2;
8072   __pyx_t_2.memview = NULL;
8073   __pyx_t_2.data = NULL;
8074 
8075   /* "qutip/cy/spmatfuncs.pyx":501
8076  *     cdef int[::1] Aptr = A.indptr
8077  *     cdef complex[::1] Bdata = B.data
8078  *     cdef int[::1] Bptr = B.indptr             # <<<<<<<<<<<<<<
8079  *     cdef int nrows = A.shape[0]
8080  *
8081  */
8082   __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_B, __pyx_n_s_indptr); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 501, __pyx_L1_error)
8083   __Pyx_GOTREF(__pyx_t_1);
8084   __pyx_t_3 = __Pyx_PyObject_to_MemoryviewSlice_dc_int(__pyx_t_1, PyBUF_WRITABLE); if (unlikely(!__pyx_t_3.memview)) __PYX_ERR(0, 501, __pyx_L1_error)
8085   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
8086   __pyx_v_Bptr = __pyx_t_3;
8087   __pyx_t_3.memview = NULL;
8088   __pyx_t_3.data = NULL;
8089 
8090   /* "qutip/cy/spmatfuncs.pyx":502
8091  *     cdef complex[::1] Bdata = B.data
8092  *     cdef int[::1] Bptr = B.indptr
8093  *     cdef int nrows = A.shape[0]             # <<<<<<<<<<<<<<
8094  *
8095  *     cdef int j
8096  */
8097   __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_A, __pyx_n_s_shape); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 502, __pyx_L1_error)
8098   __Pyx_GOTREF(__pyx_t_1);
8099   __pyx_t_4 = __Pyx_GetItemInt(__pyx_t_1, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 502, __pyx_L1_error)
8100   __Pyx_GOTREF(__pyx_t_4);
8101   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
8102   __pyx_t_5 = __Pyx_PyInt_As_int(__pyx_t_4); if (unlikely((__pyx_t_5 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 502, __pyx_L1_error)
8103   __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
8104   __pyx_v_nrows = __pyx_t_5;
8105 
8106   /* "qutip/cy/spmatfuncs.pyx":506
8107  *     cdef int j
8108  *     cdef size_t ii, jj
8109  *     cdef double complex cval=0, row_sum, expt = 0             # <<<<<<<<<<<<<<
8110  *
8111  *     for ii in range(nrows):
8112  */
8113   __pyx_v_cval = __pyx_t_double_complex_from_parts(0, 0);
8114   __pyx_v_expt = __pyx_t_double_complex_from_parts(0, 0);
8115 
8116   /* "qutip/cy/spmatfuncs.pyx":508
8117  *     cdef double complex cval=0, row_sum, expt = 0
8118  *
8119  *     for ii in range(nrows):             # <<<<<<<<<<<<<<
8120  *         if (Bptr[ii+1] - Bptr[ii]) != 0:
8121  *             cval = conj(Bdata[Bptr[ii]])
8122  */
8123   __pyx_t_5 = __pyx_v_nrows;
8124   __pyx_t_6 = __pyx_t_5;
8125   for (__pyx_t_7 = 0; __pyx_t_7 < __pyx_t_6; __pyx_t_7+=1) {
8126     __pyx_v_ii = __pyx_t_7;
8127 
8128     /* "qutip/cy/spmatfuncs.pyx":509
8129  *
8130  *     for ii in range(nrows):
8131  *         if (Bptr[ii+1] - Bptr[ii]) != 0:             # <<<<<<<<<<<<<<
8132  *             cval = conj(Bdata[Bptr[ii]])
8133  *             row_sum = 0
8134  */
8135     __pyx_t_8 = (__pyx_v_ii + 1);
8136     __pyx_t_9 = __pyx_v_ii;
8137     __pyx_t_10 = ((((*((int *) ( /* dim=0 */ ((char *) (((int *) __pyx_v_Bptr.data) + __pyx_t_8)) ))) - (*((int *) ( /* dim=0 */ ((char *) (((int *) __pyx_v_Bptr.data) + __pyx_t_9)) )))) != 0) != 0);
8138     if (__pyx_t_10) {
8139 
8140       /* "qutip/cy/spmatfuncs.pyx":510
8141  *     for ii in range(nrows):
8142  *         if (Bptr[ii+1] - Bptr[ii]) != 0:
8143  *             cval = conj(Bdata[Bptr[ii]])             # <<<<<<<<<<<<<<
8144  *             row_sum = 0
8145  *             for jj in range(Aptr[ii], Aptr[ii+1]):
8146  */
8147       __pyx_t_9 = __pyx_v_ii;
8148       __pyx_t_11 = (*((int *) ( /* dim=0 */ ((char *) (((int *) __pyx_v_Bptr.data) + __pyx_t_9)) )));
8149       __pyx_v_cval = std::conj((*((__pyx_t_double_complex *) ( /* dim=0 */ ((char *) (((__pyx_t_double_complex *) __pyx_v_Bdata.data) + __pyx_t_11)) ))));
8150 
8151       /* "qutip/cy/spmatfuncs.pyx":511
8152  *         if (Bptr[ii+1] - Bptr[ii]) != 0:
8153  *             cval = conj(Bdata[Bptr[ii]])
8154  *             row_sum = 0             # <<<<<<<<<<<<<<
8155  *             for jj in range(Aptr[ii], Aptr[ii+1]):
8156  *                 j = Aind[jj]
8157  */
8158       __pyx_v_row_sum = __pyx_t_double_complex_from_parts(0, 0);
8159 
8160       /* "qutip/cy/spmatfuncs.pyx":512
8161  *             cval = conj(Bdata[Bptr[ii]])
8162  *             row_sum = 0
8163  *             for jj in range(Aptr[ii], Aptr[ii+1]):             # <<<<<<<<<<<<<<
8164  *                 j = Aind[jj]
8165  *                 if (Bptr[j+1] - Bptr[j]) != 0:
8166  */
8167       __pyx_t_9 = (__pyx_v_ii + 1);
8168       __pyx_t_12 = (*((int *) ( /* dim=0 */ ((char *) (((int *) __pyx_v_Aptr.data) + __pyx_t_9)) )));
8169       __pyx_t_9 = __pyx_v_ii;
8170       __pyx_t_13 = __pyx_t_12;
8171       for (__pyx_t_8 = (*((int *) ( /* dim=0 */ ((char *) (((int *) __pyx_v_Aptr.data) + __pyx_t_9)) ))); __pyx_t_8 < __pyx_t_13; __pyx_t_8+=1) {
8172         __pyx_v_jj = __pyx_t_8;
8173 
8174         /* "qutip/cy/spmatfuncs.pyx":513
8175  *             row_sum = 0
8176  *             for jj in range(Aptr[ii], Aptr[ii+1]):
8177  *                 j = Aind[jj]             # <<<<<<<<<<<<<<
8178  *                 if (Bptr[j+1] - Bptr[j]) != 0:
8179  *                     row_sum += Adata[jj]*Bdata[Bptr[j]]
8180  */
8181         __pyx_t_14 = __pyx_v_jj;
8182         __pyx_v_j = (*((int *) ( /* dim=0 */ ((char *) (((int *) __pyx_v_Aind.data) + __pyx_t_14)) )));
8183 
8184         /* "qutip/cy/spmatfuncs.pyx":514
8185  *             for jj in range(Aptr[ii], Aptr[ii+1]):
8186  *                 j = Aind[jj]
8187  *                 if (Bptr[j+1] - Bptr[j]) != 0:             # <<<<<<<<<<<<<<
8188  *                     row_sum += Adata[jj]*Bdata[Bptr[j]]
8189  *             expt += cval*row_sum
8190  */
8191         __pyx_t_11 = (__pyx_v_j + 1);
8192         __pyx_t_15 = __pyx_v_j;
8193         __pyx_t_10 = ((((*((int *) ( /* dim=0 */ ((char *) (((int *) __pyx_v_Bptr.data) + __pyx_t_11)) ))) - (*((int *) ( /* dim=0 */ ((char *) (((int *) __pyx_v_Bptr.data) + __pyx_t_15)) )))) != 0) != 0);
8194         if (__pyx_t_10) {
8195 
8196           /* "qutip/cy/spmatfuncs.pyx":515
8197  *                 j = Aind[jj]
8198  *                 if (Bptr[j+1] - Bptr[j]) != 0:
8199  *                     row_sum += Adata[jj]*Bdata[Bptr[j]]             # <<<<<<<<<<<<<<
8200  *             expt += cval*row_sum
8201  *     if isherm:
8202  */
8203           __pyx_t_14 = __pyx_v_jj;
8204           __pyx_t_15 = __pyx_v_j;
8205           __pyx_t_11 = (*((int *) ( /* dim=0 */ ((char *) (((int *) __pyx_v_Bptr.data) + __pyx_t_15)) )));
8206           __pyx_v_row_sum = __Pyx_c_sum_double(__pyx_v_row_sum, __Pyx_c_prod_double((*((__pyx_t_double_complex *) ( /* dim=0 */ ((char *) (((__pyx_t_double_complex *) __pyx_v_Adata.data) + __pyx_t_14)) ))), (*((__pyx_t_double_complex *) ( /* dim=0 */ ((char *) (((__pyx_t_double_complex *) __pyx_v_Bdata.data) + __pyx_t_11)) )))));
8207 
8208           /* "qutip/cy/spmatfuncs.pyx":514
8209  *             for jj in range(Aptr[ii], Aptr[ii+1]):
8210  *                 j = Aind[jj]
8211  *                 if (Bptr[j+1] - Bptr[j]) != 0:             # <<<<<<<<<<<<<<
8212  *                     row_sum += Adata[jj]*Bdata[Bptr[j]]
8213  *             expt += cval*row_sum
8214  */
8215         }
8216       }
8217 
8218       /* "qutip/cy/spmatfuncs.pyx":516
8219  *                 if (Bptr[j+1] - Bptr[j]) != 0:
8220  *                     row_sum += Adata[jj]*Bdata[Bptr[j]]
8221  *             expt += cval*row_sum             # <<<<<<<<<<<<<<
8222  *     if isherm:
8223  *         return real(expt)
8224  */
8225       __pyx_v_expt = __Pyx_c_sum_double(__pyx_v_expt, __Pyx_c_prod_double(__pyx_v_cval, __pyx_v_row_sum));
8226 
8227       /* "qutip/cy/spmatfuncs.pyx":509
8228  *
8229  *     for ii in range(nrows):
8230  *         if (Bptr[ii+1] - Bptr[ii]) != 0:             # <<<<<<<<<<<<<<
8231  *             cval = conj(Bdata[Bptr[ii]])
8232  *             row_sum = 0
8233  */
8234     }
8235   }
8236 
8237   /* "qutip/cy/spmatfuncs.pyx":517
8238  *                     row_sum += Adata[jj]*Bdata[Bptr[j]]
8239  *             expt += cval*row_sum
8240  *     if isherm:             # <<<<<<<<<<<<<<
8241  *         return real(expt)
8242  *     else:
8243  */
8244   __pyx_t_10 = (__pyx_v_isherm != 0);
8245   if (__pyx_t_10) {
8246 
8247     /* "qutip/cy/spmatfuncs.pyx":518
8248  *             expt += cval*row_sum
8249  *     if isherm:
8250  *         return real(expt)             # <<<<<<<<<<<<<<
8251  *     else:
8252  *         return expt
8253  */
8254     __Pyx_XDECREF(__pyx_r);
8255     __pyx_t_4 = PyFloat_FromDouble(std::real(__pyx_v_expt)); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 518, __pyx_L1_error)
8256     __Pyx_GOTREF(__pyx_t_4);
8257     __pyx_r = __pyx_t_4;
8258     __pyx_t_4 = 0;
8259     goto __pyx_L0;
8260 
8261     /* "qutip/cy/spmatfuncs.pyx":517
8262  *                     row_sum += Adata[jj]*Bdata[Bptr[j]]
8263  *             expt += cval*row_sum
8264  *     if isherm:             # <<<<<<<<<<<<<<
8265  *         return real(expt)
8266  *     else:
8267  */
8268   }
8269 
8270   /* "qutip/cy/spmatfuncs.pyx":520
8271  *         return real(expt)
8272  *     else:
8273  *         return expt             # <<<<<<<<<<<<<<
8274  *
8275  *
8276  */
8277   /*else*/ {
8278     __Pyx_XDECREF(__pyx_r);
8279     __pyx_t_4 = __pyx_PyComplex_FromComplex(__pyx_v_expt); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 520, __pyx_L1_error)
8280     __Pyx_GOTREF(__pyx_t_4);
8281     __pyx_r = __pyx_t_4;
8282     __pyx_t_4 = 0;
8283     goto __pyx_L0;
8284   }
8285 
8286   /* "qutip/cy/spmatfuncs.pyx":495
8287  * @cython.boundscheck(False)
8288  * @cython.wraparound(False)
8289  * def expect_csr_ket(object A, object B, int isherm):             # <<<<<<<<<<<<<<
8290  *
8291  *     cdef complex[::1] Adata = A.data
8292  */
8293 
8294   /* function exit code */
8295   __pyx_L1_error:;
8296   __Pyx_XDECREF(__pyx_t_1);
8297   __PYX_XDEC_MEMVIEW(&__pyx_t_2, 1);
8298   __PYX_XDEC_MEMVIEW(&__pyx_t_3, 1);
8299   __Pyx_XDECREF(__pyx_t_4);
8300   __Pyx_AddTraceback("qutip.cy.spmatfuncs.expect_csr_ket", __pyx_clineno, __pyx_lineno, __pyx_filename);
8301   __pyx_r = NULL;
8302   __pyx_L0:;
8303   __PYX_XDEC_MEMVIEW(&__pyx_v_Adata, 1);
8304   __PYX_XDEC_MEMVIEW(&__pyx_v_Aind, 1);
8305   __PYX_XDEC_MEMVIEW(&__pyx_v_Aptr, 1);
8306   __PYX_XDEC_MEMVIEW(&__pyx_v_Bdata, 1);
8307   __PYX_XDEC_MEMVIEW(&__pyx_v_Bptr, 1);
8308   __Pyx_XGIVEREF(__pyx_r);
8309   __Pyx_RefNannyFinishContext();
8310   return __pyx_r;
8311 }
8312 
8313 /* "qutip/cy/spmatfuncs.pyx":526
8314  * @cython.boundscheck(False)
8315  * @cython.wraparound(False)
8316  * cpdef double complex zcsr_mat_elem(object A, object left, object right, bool bra_ket=1):             # <<<<<<<<<<<<<<
8317  *     """
8318  *     Computes the matrix element for an operator A and left and right vectors.
8319  */
8320 
8321 static PyObject *__pyx_pw_5qutip_2cy_10spmatfuncs_37zcsr_mat_elem(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
__pyx_f_5qutip_2cy_10spmatfuncs_zcsr_mat_elem(PyObject * __pyx_v_A,PyObject * __pyx_v_left,PyObject * __pyx_v_right,CYTHON_UNUSED int __pyx_skip_dispatch,struct __pyx_opt_args_5qutip_2cy_10spmatfuncs_zcsr_mat_elem * __pyx_optional_args)8322 static __pyx_t_double_complex __pyx_f_5qutip_2cy_10spmatfuncs_zcsr_mat_elem(PyObject *__pyx_v_A, PyObject *__pyx_v_left, PyObject *__pyx_v_right, CYTHON_UNUSED int __pyx_skip_dispatch, struct __pyx_opt_args_5qutip_2cy_10spmatfuncs_zcsr_mat_elem *__pyx_optional_args) {
8323   bool __pyx_v_bra_ket = ((bool)1);
8324   __Pyx_memviewslice __pyx_v_Adata = { 0, 0, { 0 }, { 0 }, { 0 } };
8325   __Pyx_memviewslice __pyx_v_Aind = { 0, 0, { 0 }, { 0 }, { 0 } };
8326   __Pyx_memviewslice __pyx_v_Aptr = { 0, 0, { 0 }, { 0 }, { 0 } };
8327   int __pyx_v_nrows;
8328   __Pyx_memviewslice __pyx_v_Ldata = { 0, 0, { 0 }, { 0 }, { 0 } };
8329   __Pyx_memviewslice __pyx_v_Lind = { 0, 0, { 0 }, { 0 }, { 0 } };
8330   __Pyx_memviewslice __pyx_v_Lptr = { 0, 0, { 0 }, { 0 }, { 0 } };
8331   int __pyx_v_Lnnz;
8332   __Pyx_memviewslice __pyx_v_Rdata = { 0, 0, { 0 }, { 0 }, { 0 } };
8333   CYTHON_UNUSED __Pyx_memviewslice __pyx_v_Rind = { 0, 0, { 0 }, { 0 }, { 0 } };
8334   __Pyx_memviewslice __pyx_v_Rptr = { 0, 0, { 0 }, { 0 }, { 0 } };
8335   int __pyx_v_j;
8336   int __pyx_v_go;
8337   int __pyx_v_head;
8338   size_t __pyx_v_ii;
8339   size_t __pyx_v_jj;
8340   size_t __pyx_v_kk;
8341   __pyx_t_double_complex __pyx_v_cval;
8342   __pyx_t_double_complex __pyx_v_row_sum;
8343   __pyx_t_double_complex __pyx_v_mat_elem;
8344   __pyx_t_double_complex __pyx_r;
8345   __Pyx_RefNannyDeclarations
8346   PyObject *__pyx_t_1 = NULL;
8347   __Pyx_memviewslice __pyx_t_2 = { 0, 0, { 0 }, { 0 }, { 0 } };
8348   __Pyx_memviewslice __pyx_t_3 = { 0, 0, { 0 }, { 0 }, { 0 } };
8349   PyObject *__pyx_t_4 = NULL;
8350   int __pyx_t_5;
8351   int __pyx_t_6;
8352   size_t __pyx_t_7;
8353   int __pyx_t_8;
8354   int __pyx_t_9;
8355   int __pyx_t_10;
8356   size_t __pyx_t_11;
8357   size_t __pyx_t_12;
8358   Py_ssize_t __pyx_t_13;
8359   size_t __pyx_t_14;
8360   Py_ssize_t __pyx_t_15;
8361   int __pyx_lineno = 0;
8362   const char *__pyx_filename = NULL;
8363   int __pyx_clineno = 0;
8364   __Pyx_RefNannySetupContext("zcsr_mat_elem", 0);
8365   if (__pyx_optional_args) {
8366     if (__pyx_optional_args->__pyx_n > 0) {
8367       __pyx_v_bra_ket = __pyx_optional_args->bra_ket;
8368     }
8369   }
8370 
8371   /* "qutip/cy/spmatfuncs.pyx":532
8372  *     is bra then bra_ket = 1, else set bra_ket = 0.
8373  *     """
8374  *     cdef complex[::1] Adata = A.data             # <<<<<<<<<<<<<<
8375  *     cdef int[::1] Aind = A.indices
8376  *     cdef int[::1] Aptr = A.indptr
8377  */
8378   __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_A, __pyx_n_s_data); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 532, __pyx_L1_error)
8379   __Pyx_GOTREF(__pyx_t_1);
8380   __pyx_t_2 = __Pyx_PyObject_to_MemoryviewSlice_dc___pyx_t_double_complex(__pyx_t_1, PyBUF_WRITABLE); if (unlikely(!__pyx_t_2.memview)) __PYX_ERR(0, 532, __pyx_L1_error)
8381   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
8382   __pyx_v_Adata = __pyx_t_2;
8383   __pyx_t_2.memview = NULL;
8384   __pyx_t_2.data = NULL;
8385 
8386   /* "qutip/cy/spmatfuncs.pyx":533
8387  *     """
8388  *     cdef complex[::1] Adata = A.data
8389  *     cdef int[::1] Aind = A.indices             # <<<<<<<<<<<<<<
8390  *     cdef int[::1] Aptr = A.indptr
8391  *     cdef int nrows = A.shape[0]
8392  */
8393   __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_A, __pyx_n_s_indices); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 533, __pyx_L1_error)
8394   __Pyx_GOTREF(__pyx_t_1);
8395   __pyx_t_3 = __Pyx_PyObject_to_MemoryviewSlice_dc_int(__pyx_t_1, PyBUF_WRITABLE); if (unlikely(!__pyx_t_3.memview)) __PYX_ERR(0, 533, __pyx_L1_error)
8396   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
8397   __pyx_v_Aind = __pyx_t_3;
8398   __pyx_t_3.memview = NULL;
8399   __pyx_t_3.data = NULL;
8400 
8401   /* "qutip/cy/spmatfuncs.pyx":534
8402  *     cdef complex[::1] Adata = A.data
8403  *     cdef int[::1] Aind = A.indices
8404  *     cdef int[::1] Aptr = A.indptr             # <<<<<<<<<<<<<<
8405  *     cdef int nrows = A.shape[0]
8406  *
8407  */
8408   __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_A, __pyx_n_s_indptr); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 534, __pyx_L1_error)
8409   __Pyx_GOTREF(__pyx_t_1);
8410   __pyx_t_3 = __Pyx_PyObject_to_MemoryviewSlice_dc_int(__pyx_t_1, PyBUF_WRITABLE); if (unlikely(!__pyx_t_3.memview)) __PYX_ERR(0, 534, __pyx_L1_error)
8411   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
8412   __pyx_v_Aptr = __pyx_t_3;
8413   __pyx_t_3.memview = NULL;
8414   __pyx_t_3.data = NULL;
8415 
8416   /* "qutip/cy/spmatfuncs.pyx":535
8417  *     cdef int[::1] Aind = A.indices
8418  *     cdef int[::1] Aptr = A.indptr
8419  *     cdef int nrows = A.shape[0]             # <<<<<<<<<<<<<<
8420  *
8421  *     cdef complex[::1] Ldata = left.data
8422  */
8423   __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_A, __pyx_n_s_shape); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 535, __pyx_L1_error)
8424   __Pyx_GOTREF(__pyx_t_1);
8425   __pyx_t_4 = __Pyx_GetItemInt(__pyx_t_1, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 535, __pyx_L1_error)
8426   __Pyx_GOTREF(__pyx_t_4);
8427   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
8428   __pyx_t_5 = __Pyx_PyInt_As_int(__pyx_t_4); if (unlikely((__pyx_t_5 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 535, __pyx_L1_error)
8429   __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
8430   __pyx_v_nrows = __pyx_t_5;
8431 
8432   /* "qutip/cy/spmatfuncs.pyx":537
8433  *     cdef int nrows = A.shape[0]
8434  *
8435  *     cdef complex[::1] Ldata = left.data             # <<<<<<<<<<<<<<
8436  *     cdef int[::1] Lind = left.indices
8437  *     cdef int[::1] Lptr = left.indptr
8438  */
8439   __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_left, __pyx_n_s_data); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 537, __pyx_L1_error)
8440   __Pyx_GOTREF(__pyx_t_4);
8441   __pyx_t_2 = __Pyx_PyObject_to_MemoryviewSlice_dc___pyx_t_double_complex(__pyx_t_4, PyBUF_WRITABLE); if (unlikely(!__pyx_t_2.memview)) __PYX_ERR(0, 537, __pyx_L1_error)
8442   __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
8443   __pyx_v_Ldata = __pyx_t_2;
8444   __pyx_t_2.memview = NULL;
8445   __pyx_t_2.data = NULL;
8446 
8447   /* "qutip/cy/spmatfuncs.pyx":538
8448  *
8449  *     cdef complex[::1] Ldata = left.data
8450  *     cdef int[::1] Lind = left.indices             # <<<<<<<<<<<<<<
8451  *     cdef int[::1] Lptr = left.indptr
8452  *     cdef int Lnnz = Lind.shape[0]
8453  */
8454   __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_left, __pyx_n_s_indices); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 538, __pyx_L1_error)
8455   __Pyx_GOTREF(__pyx_t_4);
8456   __pyx_t_3 = __Pyx_PyObject_to_MemoryviewSlice_dc_int(__pyx_t_4, PyBUF_WRITABLE); if (unlikely(!__pyx_t_3.memview)) __PYX_ERR(0, 538, __pyx_L1_error)
8457   __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
8458   __pyx_v_Lind = __pyx_t_3;
8459   __pyx_t_3.memview = NULL;
8460   __pyx_t_3.data = NULL;
8461 
8462   /* "qutip/cy/spmatfuncs.pyx":539
8463  *     cdef complex[::1] Ldata = left.data
8464  *     cdef int[::1] Lind = left.indices
8465  *     cdef int[::1] Lptr = left.indptr             # <<<<<<<<<<<<<<
8466  *     cdef int Lnnz = Lind.shape[0]
8467  *
8468  */
8469   __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_left, __pyx_n_s_indptr); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 539, __pyx_L1_error)
8470   __Pyx_GOTREF(__pyx_t_4);
8471   __pyx_t_3 = __Pyx_PyObject_to_MemoryviewSlice_dc_int(__pyx_t_4, PyBUF_WRITABLE); if (unlikely(!__pyx_t_3.memview)) __PYX_ERR(0, 539, __pyx_L1_error)
8472   __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
8473   __pyx_v_Lptr = __pyx_t_3;
8474   __pyx_t_3.memview = NULL;
8475   __pyx_t_3.data = NULL;
8476 
8477   /* "qutip/cy/spmatfuncs.pyx":540
8478  *     cdef int[::1] Lind = left.indices
8479  *     cdef int[::1] Lptr = left.indptr
8480  *     cdef int Lnnz = Lind.shape[0]             # <<<<<<<<<<<<<<
8481  *
8482  *     cdef complex[::1] Rdata = right.data
8483  */
8484   __pyx_v_Lnnz = (__pyx_v_Lind.shape[0]);
8485 
8486   /* "qutip/cy/spmatfuncs.pyx":542
8487  *     cdef int Lnnz = Lind.shape[0]
8488  *
8489  *     cdef complex[::1] Rdata = right.data             # <<<<<<<<<<<<<<
8490  *     cdef int[::1] Rind = right.indices
8491  *     cdef int[::1] Rptr = right.indptr
8492  */
8493   __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_right, __pyx_n_s_data); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 542, __pyx_L1_error)
8494   __Pyx_GOTREF(__pyx_t_4);
8495   __pyx_t_2 = __Pyx_PyObject_to_MemoryviewSlice_dc___pyx_t_double_complex(__pyx_t_4, PyBUF_WRITABLE); if (unlikely(!__pyx_t_2.memview)) __PYX_ERR(0, 542, __pyx_L1_error)
8496   __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
8497   __pyx_v_Rdata = __pyx_t_2;
8498   __pyx_t_2.memview = NULL;
8499   __pyx_t_2.data = NULL;
8500 
8501   /* "qutip/cy/spmatfuncs.pyx":543
8502  *
8503  *     cdef complex[::1] Rdata = right.data
8504  *     cdef int[::1] Rind = right.indices             # <<<<<<<<<<<<<<
8505  *     cdef int[::1] Rptr = right.indptr
8506  *
8507  */
8508   __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_right, __pyx_n_s_indices); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 543, __pyx_L1_error)
8509   __Pyx_GOTREF(__pyx_t_4);
8510   __pyx_t_3 = __Pyx_PyObject_to_MemoryviewSlice_dc_int(__pyx_t_4, PyBUF_WRITABLE); if (unlikely(!__pyx_t_3.memview)) __PYX_ERR(0, 543, __pyx_L1_error)
8511   __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
8512   __pyx_v_Rind = __pyx_t_3;
8513   __pyx_t_3.memview = NULL;
8514   __pyx_t_3.data = NULL;
8515 
8516   /* "qutip/cy/spmatfuncs.pyx":544
8517  *     cdef complex[::1] Rdata = right.data
8518  *     cdef int[::1] Rind = right.indices
8519  *     cdef int[::1] Rptr = right.indptr             # <<<<<<<<<<<<<<
8520  *
8521  *     cdef int j, go, head=0
8522  */
8523   __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_right, __pyx_n_s_indptr); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 544, __pyx_L1_error)
8524   __Pyx_GOTREF(__pyx_t_4);
8525   __pyx_t_3 = __Pyx_PyObject_to_MemoryviewSlice_dc_int(__pyx_t_4, PyBUF_WRITABLE); if (unlikely(!__pyx_t_3.memview)) __PYX_ERR(0, 544, __pyx_L1_error)
8526   __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
8527   __pyx_v_Rptr = __pyx_t_3;
8528   __pyx_t_3.memview = NULL;
8529   __pyx_t_3.data = NULL;
8530 
8531   /* "qutip/cy/spmatfuncs.pyx":546
8532  *     cdef int[::1] Rptr = right.indptr
8533  *
8534  *     cdef int j, go, head=0             # <<<<<<<<<<<<<<
8535  *     cdef size_t ii, jj, kk
8536  *     cdef double complex cval=0, row_sum, mat_elem=0
8537  */
8538   __pyx_v_head = 0;
8539 
8540   /* "qutip/cy/spmatfuncs.pyx":548
8541  *     cdef int j, go, head=0
8542  *     cdef size_t ii, jj, kk
8543  *     cdef double complex cval=0, row_sum, mat_elem=0             # <<<<<<<<<<<<<<
8544  *
8545  *     for ii in range(nrows):
8546  */
8547   __pyx_v_cval = __pyx_t_double_complex_from_parts(0, 0);
8548   __pyx_v_mat_elem = __pyx_t_double_complex_from_parts(0, 0);
8549 
8550   /* "qutip/cy/spmatfuncs.pyx":550
8551  *     cdef double complex cval=0, row_sum, mat_elem=0
8552  *
8553  *     for ii in range(nrows):             # <<<<<<<<<<<<<<
8554  *         row_sum = 0
8555  *         go = 0
8556  */
8557   __pyx_t_5 = __pyx_v_nrows;
8558   __pyx_t_6 = __pyx_t_5;
8559   for (__pyx_t_7 = 0; __pyx_t_7 < __pyx_t_6; __pyx_t_7+=1) {
8560     __pyx_v_ii = __pyx_t_7;
8561 
8562     /* "qutip/cy/spmatfuncs.pyx":551
8563  *
8564  *     for ii in range(nrows):
8565  *         row_sum = 0             # <<<<<<<<<<<<<<
8566  *         go = 0
8567  *         if bra_ket:
8568  */
8569     __pyx_v_row_sum = __pyx_t_double_complex_from_parts(0, 0);
8570 
8571     /* "qutip/cy/spmatfuncs.pyx":552
8572  *     for ii in range(nrows):
8573  *         row_sum = 0
8574  *         go = 0             # <<<<<<<<<<<<<<
8575  *         if bra_ket:
8576  *             for kk in range(head, Lnnz):
8577  */
8578     __pyx_v_go = 0;
8579 
8580     /* "qutip/cy/spmatfuncs.pyx":553
8581  *         row_sum = 0
8582  *         go = 0
8583  *         if bra_ket:             # <<<<<<<<<<<<<<
8584  *             for kk in range(head, Lnnz):
8585  *                 if Lind[kk] == ii:
8586  */
8587     __pyx_t_8 = (__pyx_v_bra_ket != 0);
8588     if (__pyx_t_8) {
8589 
8590       /* "qutip/cy/spmatfuncs.pyx":554
8591  *         go = 0
8592  *         if bra_ket:
8593  *             for kk in range(head, Lnnz):             # <<<<<<<<<<<<<<
8594  *                 if Lind[kk] == ii:
8595  *                     cval = Ldata[kk]
8596  */
8597       __pyx_t_9 = __pyx_v_Lnnz;
8598       __pyx_t_10 = __pyx_t_9;
8599       for (__pyx_t_11 = __pyx_v_head; __pyx_t_11 < __pyx_t_10; __pyx_t_11+=1) {
8600         __pyx_v_kk = __pyx_t_11;
8601 
8602         /* "qutip/cy/spmatfuncs.pyx":555
8603  *         if bra_ket:
8604  *             for kk in range(head, Lnnz):
8605  *                 if Lind[kk] == ii:             # <<<<<<<<<<<<<<
8606  *                     cval = Ldata[kk]
8607  *                     head = kk
8608  */
8609         __pyx_t_12 = __pyx_v_kk;
8610         __pyx_t_8 = (((*((int *) ( /* dim=0 */ ((char *) (((int *) __pyx_v_Lind.data) + __pyx_t_12)) ))) == __pyx_v_ii) != 0);
8611         if (__pyx_t_8) {
8612 
8613           /* "qutip/cy/spmatfuncs.pyx":556
8614  *             for kk in range(head, Lnnz):
8615  *                 if Lind[kk] == ii:
8616  *                     cval = Ldata[kk]             # <<<<<<<<<<<<<<
8617  *                     head = kk
8618  *                     go = 1
8619  */
8620           __pyx_t_12 = __pyx_v_kk;
8621           __pyx_v_cval = (*((__pyx_t_double_complex *) ( /* dim=0 */ ((char *) (((__pyx_t_double_complex *) __pyx_v_Ldata.data) + __pyx_t_12)) )));
8622 
8623           /* "qutip/cy/spmatfuncs.pyx":557
8624  *                 if Lind[kk] == ii:
8625  *                     cval = Ldata[kk]
8626  *                     head = kk             # <<<<<<<<<<<<<<
8627  *                     go = 1
8628  *         else:
8629  */
8630           __pyx_v_head = __pyx_v_kk;
8631 
8632           /* "qutip/cy/spmatfuncs.pyx":558
8633  *                     cval = Ldata[kk]
8634  *                     head = kk
8635  *                     go = 1             # <<<<<<<<<<<<<<
8636  *         else:
8637  *             if (Lptr[ii] - Lptr[ii+1]) != 0:
8638  */
8639           __pyx_v_go = 1;
8640 
8641           /* "qutip/cy/spmatfuncs.pyx":555
8642  *         if bra_ket:
8643  *             for kk in range(head, Lnnz):
8644  *                 if Lind[kk] == ii:             # <<<<<<<<<<<<<<
8645  *                     cval = Ldata[kk]
8646  *                     head = kk
8647  */
8648         }
8649       }
8650 
8651       /* "qutip/cy/spmatfuncs.pyx":553
8652  *         row_sum = 0
8653  *         go = 0
8654  *         if bra_ket:             # <<<<<<<<<<<<<<
8655  *             for kk in range(head, Lnnz):
8656  *                 if Lind[kk] == ii:
8657  */
8658       goto __pyx_L5;
8659     }
8660 
8661     /* "qutip/cy/spmatfuncs.pyx":560
8662  *                     go = 1
8663  *         else:
8664  *             if (Lptr[ii] - Lptr[ii+1]) != 0:             # <<<<<<<<<<<<<<
8665  *                 cval = conj(Ldata[Lptr[ii]])
8666  *                 go = 1
8667  */
8668     /*else*/ {
8669       __pyx_t_11 = __pyx_v_ii;
8670       __pyx_t_12 = (__pyx_v_ii + 1);
8671       __pyx_t_8 = ((((*((int *) ( /* dim=0 */ ((char *) (((int *) __pyx_v_Lptr.data) + __pyx_t_11)) ))) - (*((int *) ( /* dim=0 */ ((char *) (((int *) __pyx_v_Lptr.data) + __pyx_t_12)) )))) != 0) != 0);
8672       if (__pyx_t_8) {
8673 
8674         /* "qutip/cy/spmatfuncs.pyx":561
8675  *         else:
8676  *             if (Lptr[ii] - Lptr[ii+1]) != 0:
8677  *                 cval = conj(Ldata[Lptr[ii]])             # <<<<<<<<<<<<<<
8678  *                 go = 1
8679  *
8680  */
8681         __pyx_t_12 = __pyx_v_ii;
8682         __pyx_t_13 = (*((int *) ( /* dim=0 */ ((char *) (((int *) __pyx_v_Lptr.data) + __pyx_t_12)) )));
8683         __pyx_v_cval = std::conj((*((__pyx_t_double_complex *) ( /* dim=0 */ ((char *) (((__pyx_t_double_complex *) __pyx_v_Ldata.data) + __pyx_t_13)) ))));
8684 
8685         /* "qutip/cy/spmatfuncs.pyx":562
8686  *             if (Lptr[ii] - Lptr[ii+1]) != 0:
8687  *                 cval = conj(Ldata[Lptr[ii]])
8688  *                 go = 1             # <<<<<<<<<<<<<<
8689  *
8690  *         if go:
8691  */
8692         __pyx_v_go = 1;
8693 
8694         /* "qutip/cy/spmatfuncs.pyx":560
8695  *                     go = 1
8696  *         else:
8697  *             if (Lptr[ii] - Lptr[ii+1]) != 0:             # <<<<<<<<<<<<<<
8698  *                 cval = conj(Ldata[Lptr[ii]])
8699  *                 go = 1
8700  */
8701       }
8702     }
8703     __pyx_L5:;
8704 
8705     /* "qutip/cy/spmatfuncs.pyx":564
8706  *                 go = 1
8707  *
8708  *         if go:             # <<<<<<<<<<<<<<
8709  *             for jj in range(Aptr[ii], Aptr[ii+1]):
8710  *                 j = Aind[jj]
8711  */
8712     __pyx_t_8 = (__pyx_v_go != 0);
8713     if (__pyx_t_8) {
8714 
8715       /* "qutip/cy/spmatfuncs.pyx":565
8716  *
8717  *         if go:
8718  *             for jj in range(Aptr[ii], Aptr[ii+1]):             # <<<<<<<<<<<<<<
8719  *                 j = Aind[jj]
8720  *                 if (Rptr[j] - Rptr[j+1]) != 0:
8721  */
8722       __pyx_t_12 = (__pyx_v_ii + 1);
8723       __pyx_t_9 = (*((int *) ( /* dim=0 */ ((char *) (((int *) __pyx_v_Aptr.data) + __pyx_t_12)) )));
8724       __pyx_t_12 = __pyx_v_ii;
8725       __pyx_t_10 = __pyx_t_9;
8726       for (__pyx_t_11 = (*((int *) ( /* dim=0 */ ((char *) (((int *) __pyx_v_Aptr.data) + __pyx_t_12)) ))); __pyx_t_11 < __pyx_t_10; __pyx_t_11+=1) {
8727         __pyx_v_jj = __pyx_t_11;
8728 
8729         /* "qutip/cy/spmatfuncs.pyx":566
8730  *         if go:
8731  *             for jj in range(Aptr[ii], Aptr[ii+1]):
8732  *                 j = Aind[jj]             # <<<<<<<<<<<<<<
8733  *                 if (Rptr[j] - Rptr[j+1]) != 0:
8734  *                     row_sum += Adata[jj]*Rdata[Rptr[j]]
8735  */
8736         __pyx_t_14 = __pyx_v_jj;
8737         __pyx_v_j = (*((int *) ( /* dim=0 */ ((char *) (((int *) __pyx_v_Aind.data) + __pyx_t_14)) )));
8738 
8739         /* "qutip/cy/spmatfuncs.pyx":567
8740  *             for jj in range(Aptr[ii], Aptr[ii+1]):
8741  *                 j = Aind[jj]
8742  *                 if (Rptr[j] - Rptr[j+1]) != 0:             # <<<<<<<<<<<<<<
8743  *                     row_sum += Adata[jj]*Rdata[Rptr[j]]
8744  *             mat_elem += cval*row_sum
8745  */
8746         __pyx_t_13 = __pyx_v_j;
8747         __pyx_t_15 = (__pyx_v_j + 1);
8748         __pyx_t_8 = ((((*((int *) ( /* dim=0 */ ((char *) (((int *) __pyx_v_Rptr.data) + __pyx_t_13)) ))) - (*((int *) ( /* dim=0 */ ((char *) (((int *) __pyx_v_Rptr.data) + __pyx_t_15)) )))) != 0) != 0);
8749         if (__pyx_t_8) {
8750 
8751           /* "qutip/cy/spmatfuncs.pyx":568
8752  *                 j = Aind[jj]
8753  *                 if (Rptr[j] - Rptr[j+1]) != 0:
8754  *                     row_sum += Adata[jj]*Rdata[Rptr[j]]             # <<<<<<<<<<<<<<
8755  *             mat_elem += cval*row_sum
8756  *
8757  */
8758           __pyx_t_14 = __pyx_v_jj;
8759           __pyx_t_15 = __pyx_v_j;
8760           __pyx_t_13 = (*((int *) ( /* dim=0 */ ((char *) (((int *) __pyx_v_Rptr.data) + __pyx_t_15)) )));
8761           __pyx_v_row_sum = __Pyx_c_sum_double(__pyx_v_row_sum, __Pyx_c_prod_double((*((__pyx_t_double_complex *) ( /* dim=0 */ ((char *) (((__pyx_t_double_complex *) __pyx_v_Adata.data) + __pyx_t_14)) ))), (*((__pyx_t_double_complex *) ( /* dim=0 */ ((char *) (((__pyx_t_double_complex *) __pyx_v_Rdata.data) + __pyx_t_13)) )))));
8762 
8763           /* "qutip/cy/spmatfuncs.pyx":567
8764  *             for jj in range(Aptr[ii], Aptr[ii+1]):
8765  *                 j = Aind[jj]
8766  *                 if (Rptr[j] - Rptr[j+1]) != 0:             # <<<<<<<<<<<<<<
8767  *                     row_sum += Adata[jj]*Rdata[Rptr[j]]
8768  *             mat_elem += cval*row_sum
8769  */
8770         }
8771       }
8772 
8773       /* "qutip/cy/spmatfuncs.pyx":569
8774  *                 if (Rptr[j] - Rptr[j+1]) != 0:
8775  *                     row_sum += Adata[jj]*Rdata[Rptr[j]]
8776  *             mat_elem += cval*row_sum             # <<<<<<<<<<<<<<
8777  *
8778  *     return mat_elem
8779  */
8780       __pyx_v_mat_elem = __Pyx_c_sum_double(__pyx_v_mat_elem, __Pyx_c_prod_double(__pyx_v_cval, __pyx_v_row_sum));
8781 
8782       /* "qutip/cy/spmatfuncs.pyx":564
8783  *                 go = 1
8784  *
8785  *         if go:             # <<<<<<<<<<<<<<
8786  *             for jj in range(Aptr[ii], Aptr[ii+1]):
8787  *                 j = Aind[jj]
8788  */
8789     }
8790   }
8791 
8792   /* "qutip/cy/spmatfuncs.pyx":571
8793  *             mat_elem += cval*row_sum
8794  *
8795  *     return mat_elem             # <<<<<<<<<<<<<<
8796  */
8797   __pyx_r = __pyx_v_mat_elem;
8798   goto __pyx_L0;
8799 
8800   /* "qutip/cy/spmatfuncs.pyx":526
8801  * @cython.boundscheck(False)
8802  * @cython.wraparound(False)
8803  * cpdef double complex zcsr_mat_elem(object A, object left, object right, bool bra_ket=1):             # <<<<<<<<<<<<<<
8804  *     """
8805  *     Computes the matrix element for an operator A and left and right vectors.
8806  */
8807 
8808   /* function exit code */
8809   __pyx_L1_error:;
8810   __Pyx_XDECREF(__pyx_t_1);
8811   __PYX_XDEC_MEMVIEW(&__pyx_t_2, 1);
8812   __PYX_XDEC_MEMVIEW(&__pyx_t_3, 1);
8813   __Pyx_XDECREF(__pyx_t_4);
8814   __Pyx_WriteUnraisable("qutip.cy.spmatfuncs.zcsr_mat_elem", __pyx_clineno, __pyx_lineno, __pyx_filename, 1, 0);
8815   __pyx_r = __pyx_t_double_complex_from_parts(0, 0);
8816   __pyx_L0:;
8817   __PYX_XDEC_MEMVIEW(&__pyx_v_Adata, 1);
8818   __PYX_XDEC_MEMVIEW(&__pyx_v_Aind, 1);
8819   __PYX_XDEC_MEMVIEW(&__pyx_v_Aptr, 1);
8820   __PYX_XDEC_MEMVIEW(&__pyx_v_Ldata, 1);
8821   __PYX_XDEC_MEMVIEW(&__pyx_v_Lind, 1);
8822   __PYX_XDEC_MEMVIEW(&__pyx_v_Lptr, 1);
8823   __PYX_XDEC_MEMVIEW(&__pyx_v_Rdata, 1);
8824   __PYX_XDEC_MEMVIEW(&__pyx_v_Rind, 1);
8825   __PYX_XDEC_MEMVIEW(&__pyx_v_Rptr, 1);
8826   __Pyx_RefNannyFinishContext();
8827   return __pyx_r;
8828 }
8829 
8830 /* Python wrapper */
8831 static PyObject *__pyx_pw_5qutip_2cy_10spmatfuncs_37zcsr_mat_elem(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
8832 static char __pyx_doc_5qutip_2cy_10spmatfuncs_36zcsr_mat_elem[] = "\n    Computes the matrix element for an operator A and left and right vectors.\n    right must be a ket, but left can be a ket or bra vector.  If left\n    is bra then bra_ket = 1, else set bra_ket = 0.\n    ";
__pyx_pw_5qutip_2cy_10spmatfuncs_37zcsr_mat_elem(PyObject * __pyx_self,PyObject * __pyx_args,PyObject * __pyx_kwds)8833 static PyObject *__pyx_pw_5qutip_2cy_10spmatfuncs_37zcsr_mat_elem(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
8834   PyObject *__pyx_v_A = 0;
8835   PyObject *__pyx_v_left = 0;
8836   PyObject *__pyx_v_right = 0;
8837   bool __pyx_v_bra_ket;
8838   int __pyx_lineno = 0;
8839   const char *__pyx_filename = NULL;
8840   int __pyx_clineno = 0;
8841   PyObject *__pyx_r = 0;
8842   __Pyx_RefNannyDeclarations
8843   __Pyx_RefNannySetupContext("zcsr_mat_elem (wrapper)", 0);
8844   {
8845     static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_A,&__pyx_n_s_left,&__pyx_n_s_right,&__pyx_n_s_bra_ket,0};
8846     PyObject* values[4] = {0,0,0,0};
8847     if (unlikely(__pyx_kwds)) {
8848       Py_ssize_t kw_args;
8849       const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
8850       switch (pos_args) {
8851         case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
8852         CYTHON_FALLTHROUGH;
8853         case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
8854         CYTHON_FALLTHROUGH;
8855         case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
8856         CYTHON_FALLTHROUGH;
8857         case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
8858         CYTHON_FALLTHROUGH;
8859         case  0: break;
8860         default: goto __pyx_L5_argtuple_error;
8861       }
8862       kw_args = PyDict_Size(__pyx_kwds);
8863       switch (pos_args) {
8864         case  0:
8865         if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_A)) != 0)) kw_args--;
8866         else goto __pyx_L5_argtuple_error;
8867         CYTHON_FALLTHROUGH;
8868         case  1:
8869         if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_left)) != 0)) kw_args--;
8870         else {
8871           __Pyx_RaiseArgtupleInvalid("zcsr_mat_elem", 0, 3, 4, 1); __PYX_ERR(0, 526, __pyx_L3_error)
8872         }
8873         CYTHON_FALLTHROUGH;
8874         case  2:
8875         if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_right)) != 0)) kw_args--;
8876         else {
8877           __Pyx_RaiseArgtupleInvalid("zcsr_mat_elem", 0, 3, 4, 2); __PYX_ERR(0, 526, __pyx_L3_error)
8878         }
8879         CYTHON_FALLTHROUGH;
8880         case  3:
8881         if (kw_args > 0) {
8882           PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_bra_ket);
8883           if (value) { values[3] = value; kw_args--; }
8884         }
8885       }
8886       if (unlikely(kw_args > 0)) {
8887         if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "zcsr_mat_elem") < 0)) __PYX_ERR(0, 526, __pyx_L3_error)
8888       }
8889     } else {
8890       switch (PyTuple_GET_SIZE(__pyx_args)) {
8891         case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
8892         CYTHON_FALLTHROUGH;
8893         case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
8894         values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
8895         values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
8896         break;
8897         default: goto __pyx_L5_argtuple_error;
8898       }
8899     }
8900     __pyx_v_A = values[0];
8901     __pyx_v_left = values[1];
8902     __pyx_v_right = values[2];
8903     if (values[3]) {
8904       __pyx_v_bra_ket = __Pyx_PyObject_IsTrue(values[3]); if (unlikely((__pyx_v_bra_ket == ((bool)-1)) && PyErr_Occurred())) __PYX_ERR(0, 526, __pyx_L3_error)
8905     } else {
8906       __pyx_v_bra_ket = ((bool)1);
8907     }
8908   }
8909   goto __pyx_L4_argument_unpacking_done;
8910   __pyx_L5_argtuple_error:;
8911   __Pyx_RaiseArgtupleInvalid("zcsr_mat_elem", 0, 3, 4, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 526, __pyx_L3_error)
8912   __pyx_L3_error:;
8913   __Pyx_AddTraceback("qutip.cy.spmatfuncs.zcsr_mat_elem", __pyx_clineno, __pyx_lineno, __pyx_filename);
8914   __Pyx_RefNannyFinishContext();
8915   return NULL;
8916   __pyx_L4_argument_unpacking_done:;
8917   __pyx_r = __pyx_pf_5qutip_2cy_10spmatfuncs_36zcsr_mat_elem(__pyx_self, __pyx_v_A, __pyx_v_left, __pyx_v_right, __pyx_v_bra_ket);
8918 
8919   /* function exit code */
8920   __Pyx_RefNannyFinishContext();
8921   return __pyx_r;
8922 }
8923 
__pyx_pf_5qutip_2cy_10spmatfuncs_36zcsr_mat_elem(CYTHON_UNUSED PyObject * __pyx_self,PyObject * __pyx_v_A,PyObject * __pyx_v_left,PyObject * __pyx_v_right,bool __pyx_v_bra_ket)8924 static PyObject *__pyx_pf_5qutip_2cy_10spmatfuncs_36zcsr_mat_elem(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_A, PyObject *__pyx_v_left, PyObject *__pyx_v_right, bool __pyx_v_bra_ket) {
8925   PyObject *__pyx_r = NULL;
8926   __Pyx_RefNannyDeclarations
8927   __pyx_t_double_complex __pyx_t_1;
8928   struct __pyx_opt_args_5qutip_2cy_10spmatfuncs_zcsr_mat_elem __pyx_t_2;
8929   PyObject *__pyx_t_3 = NULL;
8930   int __pyx_lineno = 0;
8931   const char *__pyx_filename = NULL;
8932   int __pyx_clineno = 0;
8933   __Pyx_RefNannySetupContext("zcsr_mat_elem", 0);
8934   __Pyx_XDECREF(__pyx_r);
8935   __pyx_t_2.__pyx_n = 1;
8936   __pyx_t_2.bra_ket = __pyx_v_bra_ket;
8937   __pyx_t_1 = __pyx_f_5qutip_2cy_10spmatfuncs_zcsr_mat_elem(__pyx_v_A, __pyx_v_left, __pyx_v_right, 0, &__pyx_t_2);
8938   __pyx_t_3 = __pyx_PyComplex_FromComplex(__pyx_t_1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 526, __pyx_L1_error)
8939   __Pyx_GOTREF(__pyx_t_3);
8940   __pyx_r = __pyx_t_3;
8941   __pyx_t_3 = 0;
8942   goto __pyx_L0;
8943 
8944   /* function exit code */
8945   __pyx_L1_error:;
8946   __Pyx_XDECREF(__pyx_t_3);
8947   __Pyx_AddTraceback("qutip.cy.spmatfuncs.zcsr_mat_elem", __pyx_clineno, __pyx_lineno, __pyx_filename);
8948   __pyx_r = NULL;
8949   __pyx_L0:;
8950   __Pyx_XGIVEREF(__pyx_r);
8951   __Pyx_RefNannyFinishContext();
8952   return __pyx_r;
8953 }
8954 
8955 /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":734
8956  * ctypedef npy_cdouble     complex_t
8957  *
8958  * cdef inline object PyArray_MultiIterNew1(a):             # <<<<<<<<<<<<<<
8959  *     return PyArray_MultiIterNew(1, <void*>a)
8960  *
8961  */
8962 
__pyx_f_5numpy_PyArray_MultiIterNew1(PyObject * __pyx_v_a)8963 static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew1(PyObject *__pyx_v_a) {
8964   PyObject *__pyx_r = NULL;
8965   __Pyx_RefNannyDeclarations
8966   PyObject *__pyx_t_1 = NULL;
8967   int __pyx_lineno = 0;
8968   const char *__pyx_filename = NULL;
8969   int __pyx_clineno = 0;
8970   __Pyx_RefNannySetupContext("PyArray_MultiIterNew1", 0);
8971 
8972   /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":735
8973  *
8974  * cdef inline object PyArray_MultiIterNew1(a):
8975  *     return PyArray_MultiIterNew(1, <void*>a)             # <<<<<<<<<<<<<<
8976  *
8977  * cdef inline object PyArray_MultiIterNew2(a, b):
8978  */
8979   __Pyx_XDECREF(__pyx_r);
8980   __pyx_t_1 = PyArray_MultiIterNew(1, ((void *)__pyx_v_a)); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 735, __pyx_L1_error)
8981   __Pyx_GOTREF(__pyx_t_1);
8982   __pyx_r = __pyx_t_1;
8983   __pyx_t_1 = 0;
8984   goto __pyx_L0;
8985 
8986   /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":734
8987  * ctypedef npy_cdouble     complex_t
8988  *
8989  * cdef inline object PyArray_MultiIterNew1(a):             # <<<<<<<<<<<<<<
8990  *     return PyArray_MultiIterNew(1, <void*>a)
8991  *
8992  */
8993 
8994   /* function exit code */
8995   __pyx_L1_error:;
8996   __Pyx_XDECREF(__pyx_t_1);
8997   __Pyx_AddTraceback("numpy.PyArray_MultiIterNew1", __pyx_clineno, __pyx_lineno, __pyx_filename);
8998   __pyx_r = 0;
8999   __pyx_L0:;
9000   __Pyx_XGIVEREF(__pyx_r);
9001   __Pyx_RefNannyFinishContext();
9002   return __pyx_r;
9003 }
9004 
9005 /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":737
9006  *     return PyArray_MultiIterNew(1, <void*>a)
9007  *
9008  * cdef inline object PyArray_MultiIterNew2(a, b):             # <<<<<<<<<<<<<<
9009  *     return PyArray_MultiIterNew(2, <void*>a, <void*>b)
9010  *
9011  */
9012 
__pyx_f_5numpy_PyArray_MultiIterNew2(PyObject * __pyx_v_a,PyObject * __pyx_v_b)9013 static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew2(PyObject *__pyx_v_a, PyObject *__pyx_v_b) {
9014   PyObject *__pyx_r = NULL;
9015   __Pyx_RefNannyDeclarations
9016   PyObject *__pyx_t_1 = NULL;
9017   int __pyx_lineno = 0;
9018   const char *__pyx_filename = NULL;
9019   int __pyx_clineno = 0;
9020   __Pyx_RefNannySetupContext("PyArray_MultiIterNew2", 0);
9021 
9022   /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":738
9023  *
9024  * cdef inline object PyArray_MultiIterNew2(a, b):
9025  *     return PyArray_MultiIterNew(2, <void*>a, <void*>b)             # <<<<<<<<<<<<<<
9026  *
9027  * cdef inline object PyArray_MultiIterNew3(a, b, c):
9028  */
9029   __Pyx_XDECREF(__pyx_r);
9030   __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)
9031   __Pyx_GOTREF(__pyx_t_1);
9032   __pyx_r = __pyx_t_1;
9033   __pyx_t_1 = 0;
9034   goto __pyx_L0;
9035 
9036   /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":737
9037  *     return PyArray_MultiIterNew(1, <void*>a)
9038  *
9039  * cdef inline object PyArray_MultiIterNew2(a, b):             # <<<<<<<<<<<<<<
9040  *     return PyArray_MultiIterNew(2, <void*>a, <void*>b)
9041  *
9042  */
9043 
9044   /* function exit code */
9045   __pyx_L1_error:;
9046   __Pyx_XDECREF(__pyx_t_1);
9047   __Pyx_AddTraceback("numpy.PyArray_MultiIterNew2", __pyx_clineno, __pyx_lineno, __pyx_filename);
9048   __pyx_r = 0;
9049   __pyx_L0:;
9050   __Pyx_XGIVEREF(__pyx_r);
9051   __Pyx_RefNannyFinishContext();
9052   return __pyx_r;
9053 }
9054 
9055 /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":740
9056  *     return PyArray_MultiIterNew(2, <void*>a, <void*>b)
9057  *
9058  * cdef inline object PyArray_MultiIterNew3(a, b, c):             # <<<<<<<<<<<<<<
9059  *     return PyArray_MultiIterNew(3, <void*>a, <void*>b, <void*> c)
9060  *
9061  */
9062 
__pyx_f_5numpy_PyArray_MultiIterNew3(PyObject * __pyx_v_a,PyObject * __pyx_v_b,PyObject * __pyx_v_c)9063 static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew3(PyObject *__pyx_v_a, PyObject *__pyx_v_b, PyObject *__pyx_v_c) {
9064   PyObject *__pyx_r = NULL;
9065   __Pyx_RefNannyDeclarations
9066   PyObject *__pyx_t_1 = NULL;
9067   int __pyx_lineno = 0;
9068   const char *__pyx_filename = NULL;
9069   int __pyx_clineno = 0;
9070   __Pyx_RefNannySetupContext("PyArray_MultiIterNew3", 0);
9071 
9072   /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":741
9073  *
9074  * cdef inline object PyArray_MultiIterNew3(a, b, c):
9075  *     return PyArray_MultiIterNew(3, <void*>a, <void*>b, <void*> c)             # <<<<<<<<<<<<<<
9076  *
9077  * cdef inline object PyArray_MultiIterNew4(a, b, c, d):
9078  */
9079   __Pyx_XDECREF(__pyx_r);
9080   __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)
9081   __Pyx_GOTREF(__pyx_t_1);
9082   __pyx_r = __pyx_t_1;
9083   __pyx_t_1 = 0;
9084   goto __pyx_L0;
9085 
9086   /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":740
9087  *     return PyArray_MultiIterNew(2, <void*>a, <void*>b)
9088  *
9089  * cdef inline object PyArray_MultiIterNew3(a, b, c):             # <<<<<<<<<<<<<<
9090  *     return PyArray_MultiIterNew(3, <void*>a, <void*>b, <void*> c)
9091  *
9092  */
9093 
9094   /* function exit code */
9095   __pyx_L1_error:;
9096   __Pyx_XDECREF(__pyx_t_1);
9097   __Pyx_AddTraceback("numpy.PyArray_MultiIterNew3", __pyx_clineno, __pyx_lineno, __pyx_filename);
9098   __pyx_r = 0;
9099   __pyx_L0:;
9100   __Pyx_XGIVEREF(__pyx_r);
9101   __Pyx_RefNannyFinishContext();
9102   return __pyx_r;
9103 }
9104 
9105 /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":743
9106  *     return PyArray_MultiIterNew(3, <void*>a, <void*>b, <void*> c)
9107  *
9108  * cdef inline object PyArray_MultiIterNew4(a, b, c, d):             # <<<<<<<<<<<<<<
9109  *     return PyArray_MultiIterNew(4, <void*>a, <void*>b, <void*>c, <void*> d)
9110  *
9111  */
9112 
__pyx_f_5numpy_PyArray_MultiIterNew4(PyObject * __pyx_v_a,PyObject * __pyx_v_b,PyObject * __pyx_v_c,PyObject * __pyx_v_d)9113 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) {
9114   PyObject *__pyx_r = NULL;
9115   __Pyx_RefNannyDeclarations
9116   PyObject *__pyx_t_1 = NULL;
9117   int __pyx_lineno = 0;
9118   const char *__pyx_filename = NULL;
9119   int __pyx_clineno = 0;
9120   __Pyx_RefNannySetupContext("PyArray_MultiIterNew4", 0);
9121 
9122   /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":744
9123  *
9124  * cdef inline object PyArray_MultiIterNew4(a, b, c, d):
9125  *     return PyArray_MultiIterNew(4, <void*>a, <void*>b, <void*>c, <void*> d)             # <<<<<<<<<<<<<<
9126  *
9127  * cdef inline object PyArray_MultiIterNew5(a, b, c, d, e):
9128  */
9129   __Pyx_XDECREF(__pyx_r);
9130   __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)
9131   __Pyx_GOTREF(__pyx_t_1);
9132   __pyx_r = __pyx_t_1;
9133   __pyx_t_1 = 0;
9134   goto __pyx_L0;
9135 
9136   /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":743
9137  *     return PyArray_MultiIterNew(3, <void*>a, <void*>b, <void*> c)
9138  *
9139  * cdef inline object PyArray_MultiIterNew4(a, b, c, d):             # <<<<<<<<<<<<<<
9140  *     return PyArray_MultiIterNew(4, <void*>a, <void*>b, <void*>c, <void*> d)
9141  *
9142  */
9143 
9144   /* function exit code */
9145   __pyx_L1_error:;
9146   __Pyx_XDECREF(__pyx_t_1);
9147   __Pyx_AddTraceback("numpy.PyArray_MultiIterNew4", __pyx_clineno, __pyx_lineno, __pyx_filename);
9148   __pyx_r = 0;
9149   __pyx_L0:;
9150   __Pyx_XGIVEREF(__pyx_r);
9151   __Pyx_RefNannyFinishContext();
9152   return __pyx_r;
9153 }
9154 
9155 /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":746
9156  *     return PyArray_MultiIterNew(4, <void*>a, <void*>b, <void*>c, <void*> d)
9157  *
9158  * cdef inline object PyArray_MultiIterNew5(a, b, c, d, e):             # <<<<<<<<<<<<<<
9159  *     return PyArray_MultiIterNew(5, <void*>a, <void*>b, <void*>c, <void*> d, <void*> e)
9160  *
9161  */
9162 
__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)9163 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) {
9164   PyObject *__pyx_r = NULL;
9165   __Pyx_RefNannyDeclarations
9166   PyObject *__pyx_t_1 = NULL;
9167   int __pyx_lineno = 0;
9168   const char *__pyx_filename = NULL;
9169   int __pyx_clineno = 0;
9170   __Pyx_RefNannySetupContext("PyArray_MultiIterNew5", 0);
9171 
9172   /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":747
9173  *
9174  * cdef inline object PyArray_MultiIterNew5(a, b, c, d, e):
9175  *     return PyArray_MultiIterNew(5, <void*>a, <void*>b, <void*>c, <void*> d, <void*> e)             # <<<<<<<<<<<<<<
9176  *
9177  * cdef inline tuple PyDataType_SHAPE(dtype d):
9178  */
9179   __Pyx_XDECREF(__pyx_r);
9180   __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)
9181   __Pyx_GOTREF(__pyx_t_1);
9182   __pyx_r = __pyx_t_1;
9183   __pyx_t_1 = 0;
9184   goto __pyx_L0;
9185 
9186   /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":746
9187  *     return PyArray_MultiIterNew(4, <void*>a, <void*>b, <void*>c, <void*> d)
9188  *
9189  * cdef inline object PyArray_MultiIterNew5(a, b, c, d, e):             # <<<<<<<<<<<<<<
9190  *     return PyArray_MultiIterNew(5, <void*>a, <void*>b, <void*>c, <void*> d, <void*> e)
9191  *
9192  */
9193 
9194   /* function exit code */
9195   __pyx_L1_error:;
9196   __Pyx_XDECREF(__pyx_t_1);
9197   __Pyx_AddTraceback("numpy.PyArray_MultiIterNew5", __pyx_clineno, __pyx_lineno, __pyx_filename);
9198   __pyx_r = 0;
9199   __pyx_L0:;
9200   __Pyx_XGIVEREF(__pyx_r);
9201   __Pyx_RefNannyFinishContext();
9202   return __pyx_r;
9203 }
9204 
9205 /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":749
9206  *     return PyArray_MultiIterNew(5, <void*>a, <void*>b, <void*>c, <void*> d, <void*> e)
9207  *
9208  * cdef inline tuple PyDataType_SHAPE(dtype d):             # <<<<<<<<<<<<<<
9209  *     if PyDataType_HASSUBARRAY(d):
9210  *         return <tuple>d.subarray.shape
9211  */
9212 
__pyx_f_5numpy_PyDataType_SHAPE(PyArray_Descr * __pyx_v_d)9213 static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyDataType_SHAPE(PyArray_Descr *__pyx_v_d) {
9214   PyObject *__pyx_r = NULL;
9215   __Pyx_RefNannyDeclarations
9216   int __pyx_t_1;
9217   __Pyx_RefNannySetupContext("PyDataType_SHAPE", 0);
9218 
9219   /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":750
9220  *
9221  * cdef inline tuple PyDataType_SHAPE(dtype d):
9222  *     if PyDataType_HASSUBARRAY(d):             # <<<<<<<<<<<<<<
9223  *         return <tuple>d.subarray.shape
9224  *     else:
9225  */
9226   __pyx_t_1 = (PyDataType_HASSUBARRAY(__pyx_v_d) != 0);
9227   if (__pyx_t_1) {
9228 
9229     /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":751
9230  * cdef inline tuple PyDataType_SHAPE(dtype d):
9231  *     if PyDataType_HASSUBARRAY(d):
9232  *         return <tuple>d.subarray.shape             # <<<<<<<<<<<<<<
9233  *     else:
9234  *         return ()
9235  */
9236     __Pyx_XDECREF(__pyx_r);
9237     __Pyx_INCREF(((PyObject*)__pyx_v_d->subarray->shape));
9238     __pyx_r = ((PyObject*)__pyx_v_d->subarray->shape);
9239     goto __pyx_L0;
9240 
9241     /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":750
9242  *
9243  * cdef inline tuple PyDataType_SHAPE(dtype d):
9244  *     if PyDataType_HASSUBARRAY(d):             # <<<<<<<<<<<<<<
9245  *         return <tuple>d.subarray.shape
9246  *     else:
9247  */
9248   }
9249 
9250   /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":753
9251  *         return <tuple>d.subarray.shape
9252  *     else:
9253  *         return ()             # <<<<<<<<<<<<<<
9254  *
9255  *
9256  */
9257   /*else*/ {
9258     __Pyx_XDECREF(__pyx_r);
9259     __Pyx_INCREF(__pyx_empty_tuple);
9260     __pyx_r = __pyx_empty_tuple;
9261     goto __pyx_L0;
9262   }
9263 
9264   /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":749
9265  *     return PyArray_MultiIterNew(5, <void*>a, <void*>b, <void*>c, <void*> d, <void*> e)
9266  *
9267  * cdef inline tuple PyDataType_SHAPE(dtype d):             # <<<<<<<<<<<<<<
9268  *     if PyDataType_HASSUBARRAY(d):
9269  *         return <tuple>d.subarray.shape
9270  */
9271 
9272   /* function exit code */
9273   __pyx_L0:;
9274   __Pyx_XGIVEREF(__pyx_r);
9275   __Pyx_RefNannyFinishContext();
9276   return __pyx_r;
9277 }
9278 
9279 /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":868
9280  *     int _import_umath() except -1
9281  *
9282  * cdef inline void set_array_base(ndarray arr, object base):             # <<<<<<<<<<<<<<
9283  *     Py_INCREF(base) # important to do this before stealing the reference below!
9284  *     PyArray_SetBaseObject(arr, base)
9285  */
9286 
__pyx_f_5numpy_set_array_base(PyArrayObject * __pyx_v_arr,PyObject * __pyx_v_base)9287 static CYTHON_INLINE void __pyx_f_5numpy_set_array_base(PyArrayObject *__pyx_v_arr, PyObject *__pyx_v_base) {
9288   __Pyx_RefNannyDeclarations
9289   __Pyx_RefNannySetupContext("set_array_base", 0);
9290 
9291   /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":869
9292  *
9293  * cdef inline void set_array_base(ndarray arr, object base):
9294  *     Py_INCREF(base) # important to do this before stealing the reference below!             # <<<<<<<<<<<<<<
9295  *     PyArray_SetBaseObject(arr, base)
9296  *
9297  */
9298   Py_INCREF(__pyx_v_base);
9299 
9300   /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":870
9301  * cdef inline void set_array_base(ndarray arr, object base):
9302  *     Py_INCREF(base) # important to do this before stealing the reference below!
9303  *     PyArray_SetBaseObject(arr, base)             # <<<<<<<<<<<<<<
9304  *
9305  * cdef inline object get_array_base(ndarray arr):
9306  */
9307   (void)(PyArray_SetBaseObject(__pyx_v_arr, __pyx_v_base));
9308 
9309   /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":868
9310  *     int _import_umath() except -1
9311  *
9312  * cdef inline void set_array_base(ndarray arr, object base):             # <<<<<<<<<<<<<<
9313  *     Py_INCREF(base) # important to do this before stealing the reference below!
9314  *     PyArray_SetBaseObject(arr, base)
9315  */
9316 
9317   /* function exit code */
9318   __Pyx_RefNannyFinishContext();
9319 }
9320 
9321 /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":872
9322  *     PyArray_SetBaseObject(arr, base)
9323  *
9324  * cdef inline object get_array_base(ndarray arr):             # <<<<<<<<<<<<<<
9325  *     base = PyArray_BASE(arr)
9326  *     if base is NULL:
9327  */
9328 
__pyx_f_5numpy_get_array_base(PyArrayObject * __pyx_v_arr)9329 static CYTHON_INLINE PyObject *__pyx_f_5numpy_get_array_base(PyArrayObject *__pyx_v_arr) {
9330   PyObject *__pyx_v_base;
9331   PyObject *__pyx_r = NULL;
9332   __Pyx_RefNannyDeclarations
9333   int __pyx_t_1;
9334   __Pyx_RefNannySetupContext("get_array_base", 0);
9335 
9336   /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":873
9337  *
9338  * cdef inline object get_array_base(ndarray arr):
9339  *     base = PyArray_BASE(arr)             # <<<<<<<<<<<<<<
9340  *     if base is NULL:
9341  *         return None
9342  */
9343   __pyx_v_base = PyArray_BASE(__pyx_v_arr);
9344 
9345   /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":874
9346  * cdef inline object get_array_base(ndarray arr):
9347  *     base = PyArray_BASE(arr)
9348  *     if base is NULL:             # <<<<<<<<<<<<<<
9349  *         return None
9350  *     return <object>base
9351  */
9352   __pyx_t_1 = ((__pyx_v_base == NULL) != 0);
9353   if (__pyx_t_1) {
9354 
9355     /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":875
9356  *     base = PyArray_BASE(arr)
9357  *     if base is NULL:
9358  *         return None             # <<<<<<<<<<<<<<
9359  *     return <object>base
9360  *
9361  */
9362     __Pyx_XDECREF(__pyx_r);
9363     __pyx_r = Py_None; __Pyx_INCREF(Py_None);
9364     goto __pyx_L0;
9365 
9366     /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":874
9367  * cdef inline object get_array_base(ndarray arr):
9368  *     base = PyArray_BASE(arr)
9369  *     if base is NULL:             # <<<<<<<<<<<<<<
9370  *         return None
9371  *     return <object>base
9372  */
9373   }
9374 
9375   /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":876
9376  *     if base is NULL:
9377  *         return None
9378  *     return <object>base             # <<<<<<<<<<<<<<
9379  *
9380  * # Versions of the import_* functions which are more suitable for
9381  */
9382   __Pyx_XDECREF(__pyx_r);
9383   __Pyx_INCREF(((PyObject *)__pyx_v_base));
9384   __pyx_r = ((PyObject *)__pyx_v_base);
9385   goto __pyx_L0;
9386 
9387   /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":872
9388  *     PyArray_SetBaseObject(arr, base)
9389  *
9390  * cdef inline object get_array_base(ndarray arr):             # <<<<<<<<<<<<<<
9391  *     base = PyArray_BASE(arr)
9392  *     if base is NULL:
9393  */
9394 
9395   /* function exit code */
9396   __pyx_L0:;
9397   __Pyx_XGIVEREF(__pyx_r);
9398   __Pyx_RefNannyFinishContext();
9399   return __pyx_r;
9400 }
9401 
9402 /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":880
9403  * # Versions of the import_* functions which are more suitable for
9404  * # Cython code.
9405  * cdef inline int import_array() except -1:             # <<<<<<<<<<<<<<
9406  *     try:
9407  *         __pyx_import_array()
9408  */
9409 
__pyx_f_5numpy_import_array(void)9410 static CYTHON_INLINE int __pyx_f_5numpy_import_array(void) {
9411   int __pyx_r;
9412   __Pyx_RefNannyDeclarations
9413   PyObject *__pyx_t_1 = NULL;
9414   PyObject *__pyx_t_2 = NULL;
9415   PyObject *__pyx_t_3 = NULL;
9416   int __pyx_t_4;
9417   PyObject *__pyx_t_5 = NULL;
9418   PyObject *__pyx_t_6 = NULL;
9419   PyObject *__pyx_t_7 = NULL;
9420   PyObject *__pyx_t_8 = NULL;
9421   int __pyx_lineno = 0;
9422   const char *__pyx_filename = NULL;
9423   int __pyx_clineno = 0;
9424   __Pyx_RefNannySetupContext("import_array", 0);
9425 
9426   /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":881
9427  * # Cython code.
9428  * cdef inline int import_array() except -1:
9429  *     try:             # <<<<<<<<<<<<<<
9430  *         __pyx_import_array()
9431  *     except Exception:
9432  */
9433   {
9434     __Pyx_PyThreadState_declare
9435     __Pyx_PyThreadState_assign
9436     __Pyx_ExceptionSave(&__pyx_t_1, &__pyx_t_2, &__pyx_t_3);
9437     __Pyx_XGOTREF(__pyx_t_1);
9438     __Pyx_XGOTREF(__pyx_t_2);
9439     __Pyx_XGOTREF(__pyx_t_3);
9440     /*try:*/ {
9441 
9442       /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":882
9443  * cdef inline int import_array() except -1:
9444  *     try:
9445  *         __pyx_import_array()             # <<<<<<<<<<<<<<
9446  *     except Exception:
9447  *         raise ImportError("numpy.core.multiarray failed to import")
9448  */
9449       __pyx_t_4 = _import_array(); if (unlikely(__pyx_t_4 == ((int)-1))) __PYX_ERR(1, 882, __pyx_L3_error)
9450 
9451       /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":881
9452  * # Cython code.
9453  * cdef inline int import_array() except -1:
9454  *     try:             # <<<<<<<<<<<<<<
9455  *         __pyx_import_array()
9456  *     except Exception:
9457  */
9458     }
9459     __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
9460     __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
9461     __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
9462     goto __pyx_L8_try_end;
9463     __pyx_L3_error:;
9464 
9465     /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":883
9466  *     try:
9467  *         __pyx_import_array()
9468  *     except Exception:             # <<<<<<<<<<<<<<
9469  *         raise ImportError("numpy.core.multiarray failed to import")
9470  *
9471  */
9472     __pyx_t_4 = __Pyx_PyErr_ExceptionMatches(((PyObject *)(&((PyTypeObject*)PyExc_Exception)[0])));
9473     if (__pyx_t_4) {
9474       __Pyx_AddTraceback("numpy.import_array", __pyx_clineno, __pyx_lineno, __pyx_filename);
9475       if (__Pyx_GetException(&__pyx_t_5, &__pyx_t_6, &__pyx_t_7) < 0) __PYX_ERR(1, 883, __pyx_L5_except_error)
9476       __Pyx_GOTREF(__pyx_t_5);
9477       __Pyx_GOTREF(__pyx_t_6);
9478       __Pyx_GOTREF(__pyx_t_7);
9479 
9480       /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":884
9481  *         __pyx_import_array()
9482  *     except Exception:
9483  *         raise ImportError("numpy.core.multiarray failed to import")             # <<<<<<<<<<<<<<
9484  *
9485  * cdef inline int import_umath() except -1:
9486  */
9487       __pyx_t_8 = __Pyx_PyObject_Call(__pyx_builtin_ImportError, __pyx_tuple_, NULL); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 884, __pyx_L5_except_error)
9488       __Pyx_GOTREF(__pyx_t_8);
9489       __Pyx_Raise(__pyx_t_8, 0, 0, 0);
9490       __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
9491       __PYX_ERR(1, 884, __pyx_L5_except_error)
9492     }
9493     goto __pyx_L5_except_error;
9494     __pyx_L5_except_error:;
9495 
9496     /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":881
9497  * # Cython code.
9498  * cdef inline int import_array() except -1:
9499  *     try:             # <<<<<<<<<<<<<<
9500  *         __pyx_import_array()
9501  *     except Exception:
9502  */
9503     __Pyx_XGIVEREF(__pyx_t_1);
9504     __Pyx_XGIVEREF(__pyx_t_2);
9505     __Pyx_XGIVEREF(__pyx_t_3);
9506     __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3);
9507     goto __pyx_L1_error;
9508     __pyx_L8_try_end:;
9509   }
9510 
9511   /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":880
9512  * # Versions of the import_* functions which are more suitable for
9513  * # Cython code.
9514  * cdef inline int import_array() except -1:             # <<<<<<<<<<<<<<
9515  *     try:
9516  *         __pyx_import_array()
9517  */
9518 
9519   /* function exit code */
9520   __pyx_r = 0;
9521   goto __pyx_L0;
9522   __pyx_L1_error:;
9523   __Pyx_XDECREF(__pyx_t_5);
9524   __Pyx_XDECREF(__pyx_t_6);
9525   __Pyx_XDECREF(__pyx_t_7);
9526   __Pyx_XDECREF(__pyx_t_8);
9527   __Pyx_AddTraceback("numpy.import_array", __pyx_clineno, __pyx_lineno, __pyx_filename);
9528   __pyx_r = -1;
9529   __pyx_L0:;
9530   __Pyx_RefNannyFinishContext();
9531   return __pyx_r;
9532 }
9533 
9534 /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":886
9535  *         raise ImportError("numpy.core.multiarray failed to import")
9536  *
9537  * cdef inline int import_umath() except -1:             # <<<<<<<<<<<<<<
9538  *     try:
9539  *         _import_umath()
9540  */
9541 
__pyx_f_5numpy_import_umath(void)9542 static CYTHON_INLINE int __pyx_f_5numpy_import_umath(void) {
9543   int __pyx_r;
9544   __Pyx_RefNannyDeclarations
9545   PyObject *__pyx_t_1 = NULL;
9546   PyObject *__pyx_t_2 = NULL;
9547   PyObject *__pyx_t_3 = NULL;
9548   int __pyx_t_4;
9549   PyObject *__pyx_t_5 = NULL;
9550   PyObject *__pyx_t_6 = NULL;
9551   PyObject *__pyx_t_7 = NULL;
9552   PyObject *__pyx_t_8 = NULL;
9553   int __pyx_lineno = 0;
9554   const char *__pyx_filename = NULL;
9555   int __pyx_clineno = 0;
9556   __Pyx_RefNannySetupContext("import_umath", 0);
9557 
9558   /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":887
9559  *
9560  * cdef inline int import_umath() except -1:
9561  *     try:             # <<<<<<<<<<<<<<
9562  *         _import_umath()
9563  *     except Exception:
9564  */
9565   {
9566     __Pyx_PyThreadState_declare
9567     __Pyx_PyThreadState_assign
9568     __Pyx_ExceptionSave(&__pyx_t_1, &__pyx_t_2, &__pyx_t_3);
9569     __Pyx_XGOTREF(__pyx_t_1);
9570     __Pyx_XGOTREF(__pyx_t_2);
9571     __Pyx_XGOTREF(__pyx_t_3);
9572     /*try:*/ {
9573 
9574       /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":888
9575  * cdef inline int import_umath() except -1:
9576  *     try:
9577  *         _import_umath()             # <<<<<<<<<<<<<<
9578  *     except Exception:
9579  *         raise ImportError("numpy.core.umath failed to import")
9580  */
9581       __pyx_t_4 = _import_umath(); if (unlikely(__pyx_t_4 == ((int)-1))) __PYX_ERR(1, 888, __pyx_L3_error)
9582 
9583       /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":887
9584  *
9585  * cdef inline int import_umath() except -1:
9586  *     try:             # <<<<<<<<<<<<<<
9587  *         _import_umath()
9588  *     except Exception:
9589  */
9590     }
9591     __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
9592     __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
9593     __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
9594     goto __pyx_L8_try_end;
9595     __pyx_L3_error:;
9596 
9597     /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":889
9598  *     try:
9599  *         _import_umath()
9600  *     except Exception:             # <<<<<<<<<<<<<<
9601  *         raise ImportError("numpy.core.umath failed to import")
9602  *
9603  */
9604     __pyx_t_4 = __Pyx_PyErr_ExceptionMatches(((PyObject *)(&((PyTypeObject*)PyExc_Exception)[0])));
9605     if (__pyx_t_4) {
9606       __Pyx_AddTraceback("numpy.import_umath", __pyx_clineno, __pyx_lineno, __pyx_filename);
9607       if (__Pyx_GetException(&__pyx_t_5, &__pyx_t_6, &__pyx_t_7) < 0) __PYX_ERR(1, 889, __pyx_L5_except_error)
9608       __Pyx_GOTREF(__pyx_t_5);
9609       __Pyx_GOTREF(__pyx_t_6);
9610       __Pyx_GOTREF(__pyx_t_7);
9611 
9612       /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":890
9613  *         _import_umath()
9614  *     except Exception:
9615  *         raise ImportError("numpy.core.umath failed to import")             # <<<<<<<<<<<<<<
9616  *
9617  * cdef inline int import_ufunc() except -1:
9618  */
9619       __pyx_t_8 = __Pyx_PyObject_Call(__pyx_builtin_ImportError, __pyx_tuple__2, NULL); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 890, __pyx_L5_except_error)
9620       __Pyx_GOTREF(__pyx_t_8);
9621       __Pyx_Raise(__pyx_t_8, 0, 0, 0);
9622       __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
9623       __PYX_ERR(1, 890, __pyx_L5_except_error)
9624     }
9625     goto __pyx_L5_except_error;
9626     __pyx_L5_except_error:;
9627 
9628     /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":887
9629  *
9630  * cdef inline int import_umath() except -1:
9631  *     try:             # <<<<<<<<<<<<<<
9632  *         _import_umath()
9633  *     except Exception:
9634  */
9635     __Pyx_XGIVEREF(__pyx_t_1);
9636     __Pyx_XGIVEREF(__pyx_t_2);
9637     __Pyx_XGIVEREF(__pyx_t_3);
9638     __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3);
9639     goto __pyx_L1_error;
9640     __pyx_L8_try_end:;
9641   }
9642 
9643   /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":886
9644  *         raise ImportError("numpy.core.multiarray failed to import")
9645  *
9646  * cdef inline int import_umath() except -1:             # <<<<<<<<<<<<<<
9647  *     try:
9648  *         _import_umath()
9649  */
9650 
9651   /* function exit code */
9652   __pyx_r = 0;
9653   goto __pyx_L0;
9654   __pyx_L1_error:;
9655   __Pyx_XDECREF(__pyx_t_5);
9656   __Pyx_XDECREF(__pyx_t_6);
9657   __Pyx_XDECREF(__pyx_t_7);
9658   __Pyx_XDECREF(__pyx_t_8);
9659   __Pyx_AddTraceback("numpy.import_umath", __pyx_clineno, __pyx_lineno, __pyx_filename);
9660   __pyx_r = -1;
9661   __pyx_L0:;
9662   __Pyx_RefNannyFinishContext();
9663   return __pyx_r;
9664 }
9665 
9666 /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":892
9667  *         raise ImportError("numpy.core.umath failed to import")
9668  *
9669  * cdef inline int import_ufunc() except -1:             # <<<<<<<<<<<<<<
9670  *     try:
9671  *         _import_umath()
9672  */
9673 
__pyx_f_5numpy_import_ufunc(void)9674 static CYTHON_INLINE int __pyx_f_5numpy_import_ufunc(void) {
9675   int __pyx_r;
9676   __Pyx_RefNannyDeclarations
9677   PyObject *__pyx_t_1 = NULL;
9678   PyObject *__pyx_t_2 = NULL;
9679   PyObject *__pyx_t_3 = NULL;
9680   int __pyx_t_4;
9681   PyObject *__pyx_t_5 = NULL;
9682   PyObject *__pyx_t_6 = NULL;
9683   PyObject *__pyx_t_7 = NULL;
9684   PyObject *__pyx_t_8 = NULL;
9685   int __pyx_lineno = 0;
9686   const char *__pyx_filename = NULL;
9687   int __pyx_clineno = 0;
9688   __Pyx_RefNannySetupContext("import_ufunc", 0);
9689 
9690   /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":893
9691  *
9692  * cdef inline int import_ufunc() except -1:
9693  *     try:             # <<<<<<<<<<<<<<
9694  *         _import_umath()
9695  *     except Exception:
9696  */
9697   {
9698     __Pyx_PyThreadState_declare
9699     __Pyx_PyThreadState_assign
9700     __Pyx_ExceptionSave(&__pyx_t_1, &__pyx_t_2, &__pyx_t_3);
9701     __Pyx_XGOTREF(__pyx_t_1);
9702     __Pyx_XGOTREF(__pyx_t_2);
9703     __Pyx_XGOTREF(__pyx_t_3);
9704     /*try:*/ {
9705 
9706       /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":894
9707  * cdef inline int import_ufunc() except -1:
9708  *     try:
9709  *         _import_umath()             # <<<<<<<<<<<<<<
9710  *     except Exception:
9711  *         raise ImportError("numpy.core.umath failed to import")
9712  */
9713       __pyx_t_4 = _import_umath(); if (unlikely(__pyx_t_4 == ((int)-1))) __PYX_ERR(1, 894, __pyx_L3_error)
9714 
9715       /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":893
9716  *
9717  * cdef inline int import_ufunc() except -1:
9718  *     try:             # <<<<<<<<<<<<<<
9719  *         _import_umath()
9720  *     except Exception:
9721  */
9722     }
9723     __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
9724     __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
9725     __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
9726     goto __pyx_L8_try_end;
9727     __pyx_L3_error:;
9728 
9729     /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":895
9730  *     try:
9731  *         _import_umath()
9732  *     except Exception:             # <<<<<<<<<<<<<<
9733  *         raise ImportError("numpy.core.umath failed to import")
9734  *
9735  */
9736     __pyx_t_4 = __Pyx_PyErr_ExceptionMatches(((PyObject *)(&((PyTypeObject*)PyExc_Exception)[0])));
9737     if (__pyx_t_4) {
9738       __Pyx_AddTraceback("numpy.import_ufunc", __pyx_clineno, __pyx_lineno, __pyx_filename);
9739       if (__Pyx_GetException(&__pyx_t_5, &__pyx_t_6, &__pyx_t_7) < 0) __PYX_ERR(1, 895, __pyx_L5_except_error)
9740       __Pyx_GOTREF(__pyx_t_5);
9741       __Pyx_GOTREF(__pyx_t_6);
9742       __Pyx_GOTREF(__pyx_t_7);
9743 
9744       /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":896
9745  *         _import_umath()
9746  *     except Exception:
9747  *         raise ImportError("numpy.core.umath failed to import")             # <<<<<<<<<<<<<<
9748  *
9749  * cdef extern from *:
9750  */
9751       __pyx_t_8 = __Pyx_PyObject_Call(__pyx_builtin_ImportError, __pyx_tuple__2, NULL); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 896, __pyx_L5_except_error)
9752       __Pyx_GOTREF(__pyx_t_8);
9753       __Pyx_Raise(__pyx_t_8, 0, 0, 0);
9754       __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
9755       __PYX_ERR(1, 896, __pyx_L5_except_error)
9756     }
9757     goto __pyx_L5_except_error;
9758     __pyx_L5_except_error:;
9759 
9760     /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":893
9761  *
9762  * cdef inline int import_ufunc() except -1:
9763  *     try:             # <<<<<<<<<<<<<<
9764  *         _import_umath()
9765  *     except Exception:
9766  */
9767     __Pyx_XGIVEREF(__pyx_t_1);
9768     __Pyx_XGIVEREF(__pyx_t_2);
9769     __Pyx_XGIVEREF(__pyx_t_3);
9770     __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3);
9771     goto __pyx_L1_error;
9772     __pyx_L8_try_end:;
9773   }
9774 
9775   /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":892
9776  *         raise ImportError("numpy.core.umath failed to import")
9777  *
9778  * cdef inline int import_ufunc() except -1:             # <<<<<<<<<<<<<<
9779  *     try:
9780  *         _import_umath()
9781  */
9782 
9783   /* function exit code */
9784   __pyx_r = 0;
9785   goto __pyx_L0;
9786   __pyx_L1_error:;
9787   __Pyx_XDECREF(__pyx_t_5);
9788   __Pyx_XDECREF(__pyx_t_6);
9789   __Pyx_XDECREF(__pyx_t_7);
9790   __Pyx_XDECREF(__pyx_t_8);
9791   __Pyx_AddTraceback("numpy.import_ufunc", __pyx_clineno, __pyx_lineno, __pyx_filename);
9792   __pyx_r = -1;
9793   __pyx_L0:;
9794   __Pyx_RefNannyFinishContext();
9795   return __pyx_r;
9796 }
9797 
9798 /* "View.MemoryView":122
9799  *         cdef bint dtype_is_object
9800  *
9801  *     def __cinit__(array self, tuple shape, Py_ssize_t itemsize, format not None,             # <<<<<<<<<<<<<<
9802  *                   mode="c", bint allocate_buffer=True):
9803  *
9804  */
9805 
9806 /* Python wrapper */
9807 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)9808 static int __pyx_array___cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
9809   PyObject *__pyx_v_shape = 0;
9810   Py_ssize_t __pyx_v_itemsize;
9811   PyObject *__pyx_v_format = 0;
9812   PyObject *__pyx_v_mode = 0;
9813   int __pyx_v_allocate_buffer;
9814   int __pyx_lineno = 0;
9815   const char *__pyx_filename = NULL;
9816   int __pyx_clineno = 0;
9817   int __pyx_r;
9818   __Pyx_RefNannyDeclarations
9819   __Pyx_RefNannySetupContext("__cinit__ (wrapper)", 0);
9820   {
9821     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};
9822     PyObject* values[5] = {0,0,0,0,0};
9823     values[3] = ((PyObject *)__pyx_n_s_c);
9824     if (unlikely(__pyx_kwds)) {
9825       Py_ssize_t kw_args;
9826       const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
9827       switch (pos_args) {
9828         case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
9829         CYTHON_FALLTHROUGH;
9830         case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
9831         CYTHON_FALLTHROUGH;
9832         case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
9833         CYTHON_FALLTHROUGH;
9834         case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
9835         CYTHON_FALLTHROUGH;
9836         case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
9837         CYTHON_FALLTHROUGH;
9838         case  0: break;
9839         default: goto __pyx_L5_argtuple_error;
9840       }
9841       kw_args = PyDict_Size(__pyx_kwds);
9842       switch (pos_args) {
9843         case  0:
9844         if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_shape)) != 0)) kw_args--;
9845         else goto __pyx_L5_argtuple_error;
9846         CYTHON_FALLTHROUGH;
9847         case  1:
9848         if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_itemsize)) != 0)) kw_args--;
9849         else {
9850           __Pyx_RaiseArgtupleInvalid("__cinit__", 0, 3, 5, 1); __PYX_ERR(2, 122, __pyx_L3_error)
9851         }
9852         CYTHON_FALLTHROUGH;
9853         case  2:
9854         if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_format)) != 0)) kw_args--;
9855         else {
9856           __Pyx_RaiseArgtupleInvalid("__cinit__", 0, 3, 5, 2); __PYX_ERR(2, 122, __pyx_L3_error)
9857         }
9858         CYTHON_FALLTHROUGH;
9859         case  3:
9860         if (kw_args > 0) {
9861           PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_mode);
9862           if (value) { values[3] = value; kw_args--; }
9863         }
9864         CYTHON_FALLTHROUGH;
9865         case  4:
9866         if (kw_args > 0) {
9867           PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_allocate_buffer);
9868           if (value) { values[4] = value; kw_args--; }
9869         }
9870       }
9871       if (unlikely(kw_args > 0)) {
9872         if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__cinit__") < 0)) __PYX_ERR(2, 122, __pyx_L3_error)
9873       }
9874     } else {
9875       switch (PyTuple_GET_SIZE(__pyx_args)) {
9876         case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
9877         CYTHON_FALLTHROUGH;
9878         case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
9879         CYTHON_FALLTHROUGH;
9880         case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
9881         values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
9882         values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
9883         break;
9884         default: goto __pyx_L5_argtuple_error;
9885       }
9886     }
9887     __pyx_v_shape = ((PyObject*)values[0]);
9888     __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)
9889     __pyx_v_format = values[2];
9890     __pyx_v_mode = values[3];
9891     if (values[4]) {
9892       __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)
9893     } else {
9894 
9895       /* "View.MemoryView":123
9896  *
9897  *     def __cinit__(array self, tuple shape, Py_ssize_t itemsize, format not None,
9898  *                   mode="c", bint allocate_buffer=True):             # <<<<<<<<<<<<<<
9899  *
9900  *         cdef int idx
9901  */
9902       __pyx_v_allocate_buffer = ((int)1);
9903     }
9904   }
9905   goto __pyx_L4_argument_unpacking_done;
9906   __pyx_L5_argtuple_error:;
9907   __Pyx_RaiseArgtupleInvalid("__cinit__", 0, 3, 5, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(2, 122, __pyx_L3_error)
9908   __pyx_L3_error:;
9909   __Pyx_AddTraceback("View.MemoryView.array.__cinit__", __pyx_clineno, __pyx_lineno, __pyx_filename);
9910   __Pyx_RefNannyFinishContext();
9911   return -1;
9912   __pyx_L4_argument_unpacking_done:;
9913   if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_shape), (&PyTuple_Type), 1, "shape", 1))) __PYX_ERR(2, 122, __pyx_L1_error)
9914   if (unlikely(((PyObject *)__pyx_v_format) == Py_None)) {
9915     PyErr_Format(PyExc_TypeError, "Argument '%.200s' must not be None", "format"); __PYX_ERR(2, 122, __pyx_L1_error)
9916   }
9917   __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);
9918 
9919   /* "View.MemoryView":122
9920  *         cdef bint dtype_is_object
9921  *
9922  *     def __cinit__(array self, tuple shape, Py_ssize_t itemsize, format not None,             # <<<<<<<<<<<<<<
9923  *                   mode="c", bint allocate_buffer=True):
9924  *
9925  */
9926 
9927   /* function exit code */
9928   goto __pyx_L0;
9929   __pyx_L1_error:;
9930   __pyx_r = -1;
9931   __pyx_L0:;
9932   __Pyx_RefNannyFinishContext();
9933   return __pyx_r;
9934 }
9935 
__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)9936 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) {
9937   int __pyx_v_idx;
9938   Py_ssize_t __pyx_v_i;
9939   Py_ssize_t __pyx_v_dim;
9940   PyObject **__pyx_v_p;
9941   char __pyx_v_order;
9942   int __pyx_r;
9943   __Pyx_RefNannyDeclarations
9944   Py_ssize_t __pyx_t_1;
9945   int __pyx_t_2;
9946   PyObject *__pyx_t_3 = NULL;
9947   int __pyx_t_4;
9948   PyObject *__pyx_t_5 = NULL;
9949   PyObject *__pyx_t_6 = NULL;
9950   char *__pyx_t_7;
9951   int __pyx_t_8;
9952   Py_ssize_t __pyx_t_9;
9953   PyObject *__pyx_t_10 = NULL;
9954   Py_ssize_t __pyx_t_11;
9955   int __pyx_lineno = 0;
9956   const char *__pyx_filename = NULL;
9957   int __pyx_clineno = 0;
9958   __Pyx_RefNannySetupContext("__cinit__", 0);
9959   __Pyx_INCREF(__pyx_v_format);
9960 
9961   /* "View.MemoryView":129
9962  *         cdef PyObject **p
9963  *
9964  *         self.ndim = <int> len(shape)             # <<<<<<<<<<<<<<
9965  *         self.itemsize = itemsize
9966  *
9967  */
9968   if (unlikely(__pyx_v_shape == Py_None)) {
9969     PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
9970     __PYX_ERR(2, 129, __pyx_L1_error)
9971   }
9972   __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)
9973   __pyx_v_self->ndim = ((int)__pyx_t_1);
9974 
9975   /* "View.MemoryView":130
9976  *
9977  *         self.ndim = <int> len(shape)
9978  *         self.itemsize = itemsize             # <<<<<<<<<<<<<<
9979  *
9980  *         if not self.ndim:
9981  */
9982   __pyx_v_self->itemsize = __pyx_v_itemsize;
9983 
9984   /* "View.MemoryView":132
9985  *         self.itemsize = itemsize
9986  *
9987  *         if not self.ndim:             # <<<<<<<<<<<<<<
9988  *             raise ValueError("Empty shape tuple for cython.array")
9989  *
9990  */
9991   __pyx_t_2 = ((!(__pyx_v_self->ndim != 0)) != 0);
9992   if (unlikely(__pyx_t_2)) {
9993 
9994     /* "View.MemoryView":133
9995  *
9996  *         if not self.ndim:
9997  *             raise ValueError("Empty shape tuple for cython.array")             # <<<<<<<<<<<<<<
9998  *
9999  *         if itemsize <= 0:
10000  */
10001     __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__3, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 133, __pyx_L1_error)
10002     __Pyx_GOTREF(__pyx_t_3);
10003     __Pyx_Raise(__pyx_t_3, 0, 0, 0);
10004     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
10005     __PYX_ERR(2, 133, __pyx_L1_error)
10006 
10007     /* "View.MemoryView":132
10008  *         self.itemsize = itemsize
10009  *
10010  *         if not self.ndim:             # <<<<<<<<<<<<<<
10011  *             raise ValueError("Empty shape tuple for cython.array")
10012  *
10013  */
10014   }
10015 
10016   /* "View.MemoryView":135
10017  *             raise ValueError("Empty shape tuple for cython.array")
10018  *
10019  *         if itemsize <= 0:             # <<<<<<<<<<<<<<
10020  *             raise ValueError("itemsize <= 0 for cython.array")
10021  *
10022  */
10023   __pyx_t_2 = ((__pyx_v_itemsize <= 0) != 0);
10024   if (unlikely(__pyx_t_2)) {
10025 
10026     /* "View.MemoryView":136
10027  *
10028  *         if itemsize <= 0:
10029  *             raise ValueError("itemsize <= 0 for cython.array")             # <<<<<<<<<<<<<<
10030  *
10031  *         if not isinstance(format, bytes):
10032  */
10033     __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__4, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 136, __pyx_L1_error)
10034     __Pyx_GOTREF(__pyx_t_3);
10035     __Pyx_Raise(__pyx_t_3, 0, 0, 0);
10036     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
10037     __PYX_ERR(2, 136, __pyx_L1_error)
10038 
10039     /* "View.MemoryView":135
10040  *             raise ValueError("Empty shape tuple for cython.array")
10041  *
10042  *         if itemsize <= 0:             # <<<<<<<<<<<<<<
10043  *             raise ValueError("itemsize <= 0 for cython.array")
10044  *
10045  */
10046   }
10047 
10048   /* "View.MemoryView":138
10049  *             raise ValueError("itemsize <= 0 for cython.array")
10050  *
10051  *         if not isinstance(format, bytes):             # <<<<<<<<<<<<<<
10052  *             format = format.encode('ASCII')
10053  *         self._format = format  # keep a reference to the byte string
10054  */
10055   __pyx_t_2 = PyBytes_Check(__pyx_v_format);
10056   __pyx_t_4 = ((!(__pyx_t_2 != 0)) != 0);
10057   if (__pyx_t_4) {
10058 
10059     /* "View.MemoryView":139
10060  *
10061  *         if not isinstance(format, bytes):
10062  *             format = format.encode('ASCII')             # <<<<<<<<<<<<<<
10063  *         self._format = format  # keep a reference to the byte string
10064  *         self.format = self._format
10065  */
10066     __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)
10067     __Pyx_GOTREF(__pyx_t_5);
10068     __pyx_t_6 = NULL;
10069     if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_5))) {
10070       __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_5);
10071       if (likely(__pyx_t_6)) {
10072         PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
10073         __Pyx_INCREF(__pyx_t_6);
10074         __Pyx_INCREF(function);
10075         __Pyx_DECREF_SET(__pyx_t_5, function);
10076       }
10077     }
10078     __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);
10079     __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
10080     if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 139, __pyx_L1_error)
10081     __Pyx_GOTREF(__pyx_t_3);
10082     __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
10083     __Pyx_DECREF_SET(__pyx_v_format, __pyx_t_3);
10084     __pyx_t_3 = 0;
10085 
10086     /* "View.MemoryView":138
10087  *             raise ValueError("itemsize <= 0 for cython.array")
10088  *
10089  *         if not isinstance(format, bytes):             # <<<<<<<<<<<<<<
10090  *             format = format.encode('ASCII')
10091  *         self._format = format  # keep a reference to the byte string
10092  */
10093   }
10094 
10095   /* "View.MemoryView":140
10096  *         if not isinstance(format, bytes):
10097  *             format = format.encode('ASCII')
10098  *         self._format = format  # keep a reference to the byte string             # <<<<<<<<<<<<<<
10099  *         self.format = self._format
10100  *
10101  */
10102   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)
10103   __pyx_t_3 = __pyx_v_format;
10104   __Pyx_INCREF(__pyx_t_3);
10105   __Pyx_GIVEREF(__pyx_t_3);
10106   __Pyx_GOTREF(__pyx_v_self->_format);
10107   __Pyx_DECREF(__pyx_v_self->_format);
10108   __pyx_v_self->_format = ((PyObject*)__pyx_t_3);
10109   __pyx_t_3 = 0;
10110 
10111   /* "View.MemoryView":141
10112  *             format = format.encode('ASCII')
10113  *         self._format = format  # keep a reference to the byte string
10114  *         self.format = self._format             # <<<<<<<<<<<<<<
10115  *
10116  *
10117  */
10118   if (unlikely(__pyx_v_self->_format == Py_None)) {
10119     PyErr_SetString(PyExc_TypeError, "expected bytes, NoneType found");
10120     __PYX_ERR(2, 141, __pyx_L1_error)
10121   }
10122   __pyx_t_7 = __Pyx_PyBytes_AsWritableString(__pyx_v_self->_format); if (unlikely((!__pyx_t_7) && PyErr_Occurred())) __PYX_ERR(2, 141, __pyx_L1_error)
10123   __pyx_v_self->format = __pyx_t_7;
10124 
10125   /* "View.MemoryView":144
10126  *
10127  *
10128  *         self._shape = <Py_ssize_t *> PyObject_Malloc(sizeof(Py_ssize_t)*self.ndim*2)             # <<<<<<<<<<<<<<
10129  *         self._strides = self._shape + self.ndim
10130  *
10131  */
10132   __pyx_v_self->_shape = ((Py_ssize_t *)PyObject_Malloc((((sizeof(Py_ssize_t)) * __pyx_v_self->ndim) * 2)));
10133 
10134   /* "View.MemoryView":145
10135  *
10136  *         self._shape = <Py_ssize_t *> PyObject_Malloc(sizeof(Py_ssize_t)*self.ndim*2)
10137  *         self._strides = self._shape + self.ndim             # <<<<<<<<<<<<<<
10138  *
10139  *         if not self._shape:
10140  */
10141   __pyx_v_self->_strides = (__pyx_v_self->_shape + __pyx_v_self->ndim);
10142 
10143   /* "View.MemoryView":147
10144  *         self._strides = self._shape + self.ndim
10145  *
10146  *         if not self._shape:             # <<<<<<<<<<<<<<
10147  *             raise MemoryError("unable to allocate shape and strides.")
10148  *
10149  */
10150   __pyx_t_4 = ((!(__pyx_v_self->_shape != 0)) != 0);
10151   if (unlikely(__pyx_t_4)) {
10152 
10153     /* "View.MemoryView":148
10154  *
10155  *         if not self._shape:
10156  *             raise MemoryError("unable to allocate shape and strides.")             # <<<<<<<<<<<<<<
10157  *
10158  *
10159  */
10160     __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_MemoryError, __pyx_tuple__5, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 148, __pyx_L1_error)
10161     __Pyx_GOTREF(__pyx_t_3);
10162     __Pyx_Raise(__pyx_t_3, 0, 0, 0);
10163     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
10164     __PYX_ERR(2, 148, __pyx_L1_error)
10165 
10166     /* "View.MemoryView":147
10167  *         self._strides = self._shape + self.ndim
10168  *
10169  *         if not self._shape:             # <<<<<<<<<<<<<<
10170  *             raise MemoryError("unable to allocate shape and strides.")
10171  *
10172  */
10173   }
10174 
10175   /* "View.MemoryView":151
10176  *
10177  *
10178  *         for idx, dim in enumerate(shape):             # <<<<<<<<<<<<<<
10179  *             if dim <= 0:
10180  *                 raise ValueError("Invalid shape in axis %d: %d." % (idx, dim))
10181  */
10182   __pyx_t_8 = 0;
10183   __pyx_t_3 = __pyx_v_shape; __Pyx_INCREF(__pyx_t_3); __pyx_t_1 = 0;
10184   for (;;) {
10185     if (__pyx_t_1 >= PyTuple_GET_SIZE(__pyx_t_3)) break;
10186     #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
10187     __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)
10188     #else
10189     __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)
10190     __Pyx_GOTREF(__pyx_t_5);
10191     #endif
10192     __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)
10193     __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
10194     __pyx_v_dim = __pyx_t_9;
10195     __pyx_v_idx = __pyx_t_8;
10196     __pyx_t_8 = (__pyx_t_8 + 1);
10197 
10198     /* "View.MemoryView":152
10199  *
10200  *         for idx, dim in enumerate(shape):
10201  *             if dim <= 0:             # <<<<<<<<<<<<<<
10202  *                 raise ValueError("Invalid shape in axis %d: %d." % (idx, dim))
10203  *             self._shape[idx] = dim
10204  */
10205     __pyx_t_4 = ((__pyx_v_dim <= 0) != 0);
10206     if (unlikely(__pyx_t_4)) {
10207 
10208       /* "View.MemoryView":153
10209  *         for idx, dim in enumerate(shape):
10210  *             if dim <= 0:
10211  *                 raise ValueError("Invalid shape in axis %d: %d." % (idx, dim))             # <<<<<<<<<<<<<<
10212  *             self._shape[idx] = dim
10213  *
10214  */
10215       __pyx_t_5 = __Pyx_PyInt_From_int(__pyx_v_idx); if (unlikely(!__pyx_t_5)) __PYX_ERR(2, 153, __pyx_L1_error)
10216       __Pyx_GOTREF(__pyx_t_5);
10217       __pyx_t_6 = PyInt_FromSsize_t(__pyx_v_dim); if (unlikely(!__pyx_t_6)) __PYX_ERR(2, 153, __pyx_L1_error)
10218       __Pyx_GOTREF(__pyx_t_6);
10219       __pyx_t_10 = PyTuple_New(2); if (unlikely(!__pyx_t_10)) __PYX_ERR(2, 153, __pyx_L1_error)
10220       __Pyx_GOTREF(__pyx_t_10);
10221       __Pyx_GIVEREF(__pyx_t_5);
10222       PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_5);
10223       __Pyx_GIVEREF(__pyx_t_6);
10224       PyTuple_SET_ITEM(__pyx_t_10, 1, __pyx_t_6);
10225       __pyx_t_5 = 0;
10226       __pyx_t_6 = 0;
10227       __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)
10228       __Pyx_GOTREF(__pyx_t_6);
10229       __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
10230       __pyx_t_10 = __Pyx_PyObject_CallOneArg(__pyx_builtin_ValueError, __pyx_t_6); if (unlikely(!__pyx_t_10)) __PYX_ERR(2, 153, __pyx_L1_error)
10231       __Pyx_GOTREF(__pyx_t_10);
10232       __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
10233       __Pyx_Raise(__pyx_t_10, 0, 0, 0);
10234       __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
10235       __PYX_ERR(2, 153, __pyx_L1_error)
10236 
10237       /* "View.MemoryView":152
10238  *
10239  *         for idx, dim in enumerate(shape):
10240  *             if dim <= 0:             # <<<<<<<<<<<<<<
10241  *                 raise ValueError("Invalid shape in axis %d: %d." % (idx, dim))
10242  *             self._shape[idx] = dim
10243  */
10244     }
10245 
10246     /* "View.MemoryView":154
10247  *             if dim <= 0:
10248  *                 raise ValueError("Invalid shape in axis %d: %d." % (idx, dim))
10249  *             self._shape[idx] = dim             # <<<<<<<<<<<<<<
10250  *
10251  *         cdef char order
10252  */
10253     (__pyx_v_self->_shape[__pyx_v_idx]) = __pyx_v_dim;
10254 
10255     /* "View.MemoryView":151
10256  *
10257  *
10258  *         for idx, dim in enumerate(shape):             # <<<<<<<<<<<<<<
10259  *             if dim <= 0:
10260  *                 raise ValueError("Invalid shape in axis %d: %d." % (idx, dim))
10261  */
10262   }
10263   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
10264 
10265   /* "View.MemoryView":157
10266  *
10267  *         cdef char order
10268  *         if mode == 'fortran':             # <<<<<<<<<<<<<<
10269  *             order = b'F'
10270  *             self.mode = u'fortran'
10271  */
10272   __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)
10273   if (__pyx_t_4) {
10274 
10275     /* "View.MemoryView":158
10276  *         cdef char order
10277  *         if mode == 'fortran':
10278  *             order = b'F'             # <<<<<<<<<<<<<<
10279  *             self.mode = u'fortran'
10280  *         elif mode == 'c':
10281  */
10282     __pyx_v_order = 'F';
10283 
10284     /* "View.MemoryView":159
10285  *         if mode == 'fortran':
10286  *             order = b'F'
10287  *             self.mode = u'fortran'             # <<<<<<<<<<<<<<
10288  *         elif mode == 'c':
10289  *             order = b'C'
10290  */
10291     __Pyx_INCREF(__pyx_n_u_fortran);
10292     __Pyx_GIVEREF(__pyx_n_u_fortran);
10293     __Pyx_GOTREF(__pyx_v_self->mode);
10294     __Pyx_DECREF(__pyx_v_self->mode);
10295     __pyx_v_self->mode = __pyx_n_u_fortran;
10296 
10297     /* "View.MemoryView":157
10298  *
10299  *         cdef char order
10300  *         if mode == 'fortran':             # <<<<<<<<<<<<<<
10301  *             order = b'F'
10302  *             self.mode = u'fortran'
10303  */
10304     goto __pyx_L10;
10305   }
10306 
10307   /* "View.MemoryView":160
10308  *             order = b'F'
10309  *             self.mode = u'fortran'
10310  *         elif mode == 'c':             # <<<<<<<<<<<<<<
10311  *             order = b'C'
10312  *             self.mode = u'c'
10313  */
10314   __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)
10315   if (likely(__pyx_t_4)) {
10316 
10317     /* "View.MemoryView":161
10318  *             self.mode = u'fortran'
10319  *         elif mode == 'c':
10320  *             order = b'C'             # <<<<<<<<<<<<<<
10321  *             self.mode = u'c'
10322  *         else:
10323  */
10324     __pyx_v_order = 'C';
10325 
10326     /* "View.MemoryView":162
10327  *         elif mode == 'c':
10328  *             order = b'C'
10329  *             self.mode = u'c'             # <<<<<<<<<<<<<<
10330  *         else:
10331  *             raise ValueError("Invalid mode, expected 'c' or 'fortran', got %s" % mode)
10332  */
10333     __Pyx_INCREF(__pyx_n_u_c);
10334     __Pyx_GIVEREF(__pyx_n_u_c);
10335     __Pyx_GOTREF(__pyx_v_self->mode);
10336     __Pyx_DECREF(__pyx_v_self->mode);
10337     __pyx_v_self->mode = __pyx_n_u_c;
10338 
10339     /* "View.MemoryView":160
10340  *             order = b'F'
10341  *             self.mode = u'fortran'
10342  *         elif mode == 'c':             # <<<<<<<<<<<<<<
10343  *             order = b'C'
10344  *             self.mode = u'c'
10345  */
10346     goto __pyx_L10;
10347   }
10348 
10349   /* "View.MemoryView":164
10350  *             self.mode = u'c'
10351  *         else:
10352  *             raise ValueError("Invalid mode, expected 'c' or 'fortran', got %s" % mode)             # <<<<<<<<<<<<<<
10353  *
10354  *         self.len = fill_contig_strides_array(self._shape, self._strides,
10355  */
10356   /*else*/ {
10357     __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)
10358     __Pyx_GOTREF(__pyx_t_3);
10359     __pyx_t_10 = __Pyx_PyObject_CallOneArg(__pyx_builtin_ValueError, __pyx_t_3); if (unlikely(!__pyx_t_10)) __PYX_ERR(2, 164, __pyx_L1_error)
10360     __Pyx_GOTREF(__pyx_t_10);
10361     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
10362     __Pyx_Raise(__pyx_t_10, 0, 0, 0);
10363     __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
10364     __PYX_ERR(2, 164, __pyx_L1_error)
10365   }
10366   __pyx_L10:;
10367 
10368   /* "View.MemoryView":166
10369  *             raise ValueError("Invalid mode, expected 'c' or 'fortran', got %s" % mode)
10370  *
10371  *         self.len = fill_contig_strides_array(self._shape, self._strides,             # <<<<<<<<<<<<<<
10372  *                                              itemsize, self.ndim, order)
10373  *
10374  */
10375   __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);
10376 
10377   /* "View.MemoryView":169
10378  *                                              itemsize, self.ndim, order)
10379  *
10380  *         self.free_data = allocate_buffer             # <<<<<<<<<<<<<<
10381  *         self.dtype_is_object = format == b'O'
10382  *         if allocate_buffer:
10383  */
10384   __pyx_v_self->free_data = __pyx_v_allocate_buffer;
10385 
10386   /* "View.MemoryView":170
10387  *
10388  *         self.free_data = allocate_buffer
10389  *         self.dtype_is_object = format == b'O'             # <<<<<<<<<<<<<<
10390  *         if allocate_buffer:
10391  *
10392  */
10393   __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)
10394   __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)
10395   __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
10396   __pyx_v_self->dtype_is_object = __pyx_t_4;
10397 
10398   /* "View.MemoryView":171
10399  *         self.free_data = allocate_buffer
10400  *         self.dtype_is_object = format == b'O'
10401  *         if allocate_buffer:             # <<<<<<<<<<<<<<
10402  *
10403  *
10404  */
10405   __pyx_t_4 = (__pyx_v_allocate_buffer != 0);
10406   if (__pyx_t_4) {
10407 
10408     /* "View.MemoryView":174
10409  *
10410  *
10411  *             self.data = <char *>malloc(self.len)             # <<<<<<<<<<<<<<
10412  *             if not self.data:
10413  *                 raise MemoryError("unable to allocate array data.")
10414  */
10415     __pyx_v_self->data = ((char *)malloc(__pyx_v_self->len));
10416 
10417     /* "View.MemoryView":175
10418  *
10419  *             self.data = <char *>malloc(self.len)
10420  *             if not self.data:             # <<<<<<<<<<<<<<
10421  *                 raise MemoryError("unable to allocate array data.")
10422  *
10423  */
10424     __pyx_t_4 = ((!(__pyx_v_self->data != 0)) != 0);
10425     if (unlikely(__pyx_t_4)) {
10426 
10427       /* "View.MemoryView":176
10428  *             self.data = <char *>malloc(self.len)
10429  *             if not self.data:
10430  *                 raise MemoryError("unable to allocate array data.")             # <<<<<<<<<<<<<<
10431  *
10432  *             if self.dtype_is_object:
10433  */
10434       __pyx_t_10 = __Pyx_PyObject_Call(__pyx_builtin_MemoryError, __pyx_tuple__6, NULL); if (unlikely(!__pyx_t_10)) __PYX_ERR(2, 176, __pyx_L1_error)
10435       __Pyx_GOTREF(__pyx_t_10);
10436       __Pyx_Raise(__pyx_t_10, 0, 0, 0);
10437       __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
10438       __PYX_ERR(2, 176, __pyx_L1_error)
10439 
10440       /* "View.MemoryView":175
10441  *
10442  *             self.data = <char *>malloc(self.len)
10443  *             if not self.data:             # <<<<<<<<<<<<<<
10444  *                 raise MemoryError("unable to allocate array data.")
10445  *
10446  */
10447     }
10448 
10449     /* "View.MemoryView":178
10450  *                 raise MemoryError("unable to allocate array data.")
10451  *
10452  *             if self.dtype_is_object:             # <<<<<<<<<<<<<<
10453  *                 p = <PyObject **> self.data
10454  *                 for i in range(self.len / itemsize):
10455  */
10456     __pyx_t_4 = (__pyx_v_self->dtype_is_object != 0);
10457     if (__pyx_t_4) {
10458 
10459       /* "View.MemoryView":179
10460  *
10461  *             if self.dtype_is_object:
10462  *                 p = <PyObject **> self.data             # <<<<<<<<<<<<<<
10463  *                 for i in range(self.len / itemsize):
10464  *                     p[i] = Py_None
10465  */
10466       __pyx_v_p = ((PyObject **)__pyx_v_self->data);
10467 
10468       /* "View.MemoryView":180
10469  *             if self.dtype_is_object:
10470  *                 p = <PyObject **> self.data
10471  *                 for i in range(self.len / itemsize):             # <<<<<<<<<<<<<<
10472  *                     p[i] = Py_None
10473  *                     Py_INCREF(Py_None)
10474  */
10475       if (unlikely(__pyx_v_itemsize == 0)) {
10476         PyErr_SetString(PyExc_ZeroDivisionError, "integer division or modulo by zero");
10477         __PYX_ERR(2, 180, __pyx_L1_error)
10478       }
10479       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))) {
10480         PyErr_SetString(PyExc_OverflowError, "value too large to perform division");
10481         __PYX_ERR(2, 180, __pyx_L1_error)
10482       }
10483       __pyx_t_1 = __Pyx_div_Py_ssize_t(__pyx_v_self->len, __pyx_v_itemsize);
10484       __pyx_t_9 = __pyx_t_1;
10485       for (__pyx_t_11 = 0; __pyx_t_11 < __pyx_t_9; __pyx_t_11+=1) {
10486         __pyx_v_i = __pyx_t_11;
10487 
10488         /* "View.MemoryView":181
10489  *                 p = <PyObject **> self.data
10490  *                 for i in range(self.len / itemsize):
10491  *                     p[i] = Py_None             # <<<<<<<<<<<<<<
10492  *                     Py_INCREF(Py_None)
10493  *
10494  */
10495         (__pyx_v_p[__pyx_v_i]) = Py_None;
10496 
10497         /* "View.MemoryView":182
10498  *                 for i in range(self.len / itemsize):
10499  *                     p[i] = Py_None
10500  *                     Py_INCREF(Py_None)             # <<<<<<<<<<<<<<
10501  *
10502  *     @cname('getbuffer')
10503  */
10504         Py_INCREF(Py_None);
10505       }
10506 
10507       /* "View.MemoryView":178
10508  *                 raise MemoryError("unable to allocate array data.")
10509  *
10510  *             if self.dtype_is_object:             # <<<<<<<<<<<<<<
10511  *                 p = <PyObject **> self.data
10512  *                 for i in range(self.len / itemsize):
10513  */
10514     }
10515 
10516     /* "View.MemoryView":171
10517  *         self.free_data = allocate_buffer
10518  *         self.dtype_is_object = format == b'O'
10519  *         if allocate_buffer:             # <<<<<<<<<<<<<<
10520  *
10521  *
10522  */
10523   }
10524 
10525   /* "View.MemoryView":122
10526  *         cdef bint dtype_is_object
10527  *
10528  *     def __cinit__(array self, tuple shape, Py_ssize_t itemsize, format not None,             # <<<<<<<<<<<<<<
10529  *                   mode="c", bint allocate_buffer=True):
10530  *
10531  */
10532 
10533   /* function exit code */
10534   __pyx_r = 0;
10535   goto __pyx_L0;
10536   __pyx_L1_error:;
10537   __Pyx_XDECREF(__pyx_t_3);
10538   __Pyx_XDECREF(__pyx_t_5);
10539   __Pyx_XDECREF(__pyx_t_6);
10540   __Pyx_XDECREF(__pyx_t_10);
10541   __Pyx_AddTraceback("View.MemoryView.array.__cinit__", __pyx_clineno, __pyx_lineno, __pyx_filename);
10542   __pyx_r = -1;
10543   __pyx_L0:;
10544   __Pyx_XDECREF(__pyx_v_format);
10545   __Pyx_RefNannyFinishContext();
10546   return __pyx_r;
10547 }
10548 
10549 /* "View.MemoryView":185
10550  *
10551  *     @cname('getbuffer')
10552  *     def __getbuffer__(self, Py_buffer *info, int flags):             # <<<<<<<<<<<<<<
10553  *         cdef int bufmode = -1
10554  *         if self.mode == u"c":
10555  */
10556 
10557 /* Python wrapper */
10558 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)10559 static CYTHON_UNUSED int __pyx_array_getbuffer(PyObject *__pyx_v_self, Py_buffer *__pyx_v_info, int __pyx_v_flags) {
10560   int __pyx_r;
10561   __Pyx_RefNannyDeclarations
10562   __Pyx_RefNannySetupContext("__getbuffer__ (wrapper)", 0);
10563   __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));
10564 
10565   /* function exit code */
10566   __Pyx_RefNannyFinishContext();
10567   return __pyx_r;
10568 }
10569 
__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)10570 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) {
10571   int __pyx_v_bufmode;
10572   int __pyx_r;
10573   __Pyx_RefNannyDeclarations
10574   int __pyx_t_1;
10575   int __pyx_t_2;
10576   PyObject *__pyx_t_3 = NULL;
10577   char *__pyx_t_4;
10578   Py_ssize_t __pyx_t_5;
10579   int __pyx_t_6;
10580   Py_ssize_t *__pyx_t_7;
10581   int __pyx_lineno = 0;
10582   const char *__pyx_filename = NULL;
10583   int __pyx_clineno = 0;
10584   if (__pyx_v_info == NULL) {
10585     PyErr_SetString(PyExc_BufferError, "PyObject_GetBuffer: view==NULL argument is obsolete");
10586     return -1;
10587   }
10588   __Pyx_RefNannySetupContext("__getbuffer__", 0);
10589   __pyx_v_info->obj = Py_None; __Pyx_INCREF(Py_None);
10590   __Pyx_GIVEREF(__pyx_v_info->obj);
10591 
10592   /* "View.MemoryView":186
10593  *     @cname('getbuffer')
10594  *     def __getbuffer__(self, Py_buffer *info, int flags):
10595  *         cdef int bufmode = -1             # <<<<<<<<<<<<<<
10596  *         if self.mode == u"c":
10597  *             bufmode = PyBUF_C_CONTIGUOUS | PyBUF_ANY_CONTIGUOUS
10598  */
10599   __pyx_v_bufmode = -1;
10600 
10601   /* "View.MemoryView":187
10602  *     def __getbuffer__(self, Py_buffer *info, int flags):
10603  *         cdef int bufmode = -1
10604  *         if self.mode == u"c":             # <<<<<<<<<<<<<<
10605  *             bufmode = PyBUF_C_CONTIGUOUS | PyBUF_ANY_CONTIGUOUS
10606  *         elif self.mode == u"fortran":
10607  */
10608   __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)
10609   __pyx_t_2 = (__pyx_t_1 != 0);
10610   if (__pyx_t_2) {
10611 
10612     /* "View.MemoryView":188
10613  *         cdef int bufmode = -1
10614  *         if self.mode == u"c":
10615  *             bufmode = PyBUF_C_CONTIGUOUS | PyBUF_ANY_CONTIGUOUS             # <<<<<<<<<<<<<<
10616  *         elif self.mode == u"fortran":
10617  *             bufmode = PyBUF_F_CONTIGUOUS | PyBUF_ANY_CONTIGUOUS
10618  */
10619     __pyx_v_bufmode = (PyBUF_C_CONTIGUOUS | PyBUF_ANY_CONTIGUOUS);
10620 
10621     /* "View.MemoryView":187
10622  *     def __getbuffer__(self, Py_buffer *info, int flags):
10623  *         cdef int bufmode = -1
10624  *         if self.mode == u"c":             # <<<<<<<<<<<<<<
10625  *             bufmode = PyBUF_C_CONTIGUOUS | PyBUF_ANY_CONTIGUOUS
10626  *         elif self.mode == u"fortran":
10627  */
10628     goto __pyx_L3;
10629   }
10630 
10631   /* "View.MemoryView":189
10632  *         if self.mode == u"c":
10633  *             bufmode = PyBUF_C_CONTIGUOUS | PyBUF_ANY_CONTIGUOUS
10634  *         elif self.mode == u"fortran":             # <<<<<<<<<<<<<<
10635  *             bufmode = PyBUF_F_CONTIGUOUS | PyBUF_ANY_CONTIGUOUS
10636  *         if not (flags & bufmode):
10637  */
10638   __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)
10639   __pyx_t_1 = (__pyx_t_2 != 0);
10640   if (__pyx_t_1) {
10641 
10642     /* "View.MemoryView":190
10643  *             bufmode = PyBUF_C_CONTIGUOUS | PyBUF_ANY_CONTIGUOUS
10644  *         elif self.mode == u"fortran":
10645  *             bufmode = PyBUF_F_CONTIGUOUS | PyBUF_ANY_CONTIGUOUS             # <<<<<<<<<<<<<<
10646  *         if not (flags & bufmode):
10647  *             raise ValueError("Can only create a buffer that is contiguous in memory.")
10648  */
10649     __pyx_v_bufmode = (PyBUF_F_CONTIGUOUS | PyBUF_ANY_CONTIGUOUS);
10650 
10651     /* "View.MemoryView":189
10652  *         if self.mode == u"c":
10653  *             bufmode = PyBUF_C_CONTIGUOUS | PyBUF_ANY_CONTIGUOUS
10654  *         elif self.mode == u"fortran":             # <<<<<<<<<<<<<<
10655  *             bufmode = PyBUF_F_CONTIGUOUS | PyBUF_ANY_CONTIGUOUS
10656  *         if not (flags & bufmode):
10657  */
10658   }
10659   __pyx_L3:;
10660 
10661   /* "View.MemoryView":191
10662  *         elif self.mode == u"fortran":
10663  *             bufmode = PyBUF_F_CONTIGUOUS | PyBUF_ANY_CONTIGUOUS
10664  *         if not (flags & bufmode):             # <<<<<<<<<<<<<<
10665  *             raise ValueError("Can only create a buffer that is contiguous in memory.")
10666  *         info.buf = self.data
10667  */
10668   __pyx_t_1 = ((!((__pyx_v_flags & __pyx_v_bufmode) != 0)) != 0);
10669   if (unlikely(__pyx_t_1)) {
10670 
10671     /* "View.MemoryView":192
10672  *             bufmode = PyBUF_F_CONTIGUOUS | PyBUF_ANY_CONTIGUOUS
10673  *         if not (flags & bufmode):
10674  *             raise ValueError("Can only create a buffer that is contiguous in memory.")             # <<<<<<<<<<<<<<
10675  *         info.buf = self.data
10676  *         info.len = self.len
10677  */
10678     __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__7, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 192, __pyx_L1_error)
10679     __Pyx_GOTREF(__pyx_t_3);
10680     __Pyx_Raise(__pyx_t_3, 0, 0, 0);
10681     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
10682     __PYX_ERR(2, 192, __pyx_L1_error)
10683 
10684     /* "View.MemoryView":191
10685  *         elif self.mode == u"fortran":
10686  *             bufmode = PyBUF_F_CONTIGUOUS | PyBUF_ANY_CONTIGUOUS
10687  *         if not (flags & bufmode):             # <<<<<<<<<<<<<<
10688  *             raise ValueError("Can only create a buffer that is contiguous in memory.")
10689  *         info.buf = self.data
10690  */
10691   }
10692 
10693   /* "View.MemoryView":193
10694  *         if not (flags & bufmode):
10695  *             raise ValueError("Can only create a buffer that is contiguous in memory.")
10696  *         info.buf = self.data             # <<<<<<<<<<<<<<
10697  *         info.len = self.len
10698  *         info.ndim = self.ndim
10699  */
10700   __pyx_t_4 = __pyx_v_self->data;
10701   __pyx_v_info->buf = __pyx_t_4;
10702 
10703   /* "View.MemoryView":194
10704  *             raise ValueError("Can only create a buffer that is contiguous in memory.")
10705  *         info.buf = self.data
10706  *         info.len = self.len             # <<<<<<<<<<<<<<
10707  *         info.ndim = self.ndim
10708  *         info.shape = self._shape
10709  */
10710   __pyx_t_5 = __pyx_v_self->len;
10711   __pyx_v_info->len = __pyx_t_5;
10712 
10713   /* "View.MemoryView":195
10714  *         info.buf = self.data
10715  *         info.len = self.len
10716  *         info.ndim = self.ndim             # <<<<<<<<<<<<<<
10717  *         info.shape = self._shape
10718  *         info.strides = self._strides
10719  */
10720   __pyx_t_6 = __pyx_v_self->ndim;
10721   __pyx_v_info->ndim = __pyx_t_6;
10722 
10723   /* "View.MemoryView":196
10724  *         info.len = self.len
10725  *         info.ndim = self.ndim
10726  *         info.shape = self._shape             # <<<<<<<<<<<<<<
10727  *         info.strides = self._strides
10728  *         info.suboffsets = NULL
10729  */
10730   __pyx_t_7 = __pyx_v_self->_shape;
10731   __pyx_v_info->shape = __pyx_t_7;
10732 
10733   /* "View.MemoryView":197
10734  *         info.ndim = self.ndim
10735  *         info.shape = self._shape
10736  *         info.strides = self._strides             # <<<<<<<<<<<<<<
10737  *         info.suboffsets = NULL
10738  *         info.itemsize = self.itemsize
10739  */
10740   __pyx_t_7 = __pyx_v_self->_strides;
10741   __pyx_v_info->strides = __pyx_t_7;
10742 
10743   /* "View.MemoryView":198
10744  *         info.shape = self._shape
10745  *         info.strides = self._strides
10746  *         info.suboffsets = NULL             # <<<<<<<<<<<<<<
10747  *         info.itemsize = self.itemsize
10748  *         info.readonly = 0
10749  */
10750   __pyx_v_info->suboffsets = NULL;
10751 
10752   /* "View.MemoryView":199
10753  *         info.strides = self._strides
10754  *         info.suboffsets = NULL
10755  *         info.itemsize = self.itemsize             # <<<<<<<<<<<<<<
10756  *         info.readonly = 0
10757  *
10758  */
10759   __pyx_t_5 = __pyx_v_self->itemsize;
10760   __pyx_v_info->itemsize = __pyx_t_5;
10761 
10762   /* "View.MemoryView":200
10763  *         info.suboffsets = NULL
10764  *         info.itemsize = self.itemsize
10765  *         info.readonly = 0             # <<<<<<<<<<<<<<
10766  *
10767  *         if flags & PyBUF_FORMAT:
10768  */
10769   __pyx_v_info->readonly = 0;
10770 
10771   /* "View.MemoryView":202
10772  *         info.readonly = 0
10773  *
10774  *         if flags & PyBUF_FORMAT:             # <<<<<<<<<<<<<<
10775  *             info.format = self.format
10776  *         else:
10777  */
10778   __pyx_t_1 = ((__pyx_v_flags & PyBUF_FORMAT) != 0);
10779   if (__pyx_t_1) {
10780 
10781     /* "View.MemoryView":203
10782  *
10783  *         if flags & PyBUF_FORMAT:
10784  *             info.format = self.format             # <<<<<<<<<<<<<<
10785  *         else:
10786  *             info.format = NULL
10787  */
10788     __pyx_t_4 = __pyx_v_self->format;
10789     __pyx_v_info->format = __pyx_t_4;
10790 
10791     /* "View.MemoryView":202
10792  *         info.readonly = 0
10793  *
10794  *         if flags & PyBUF_FORMAT:             # <<<<<<<<<<<<<<
10795  *             info.format = self.format
10796  *         else:
10797  */
10798     goto __pyx_L5;
10799   }
10800 
10801   /* "View.MemoryView":205
10802  *             info.format = self.format
10803  *         else:
10804  *             info.format = NULL             # <<<<<<<<<<<<<<
10805  *
10806  *         info.obj = self
10807  */
10808   /*else*/ {
10809     __pyx_v_info->format = NULL;
10810   }
10811   __pyx_L5:;
10812 
10813   /* "View.MemoryView":207
10814  *             info.format = NULL
10815  *
10816  *         info.obj = self             # <<<<<<<<<<<<<<
10817  *
10818  *     __pyx_getbuffer = capsule(<void *> &__pyx_array_getbuffer, "getbuffer(obj, view, flags)")
10819  */
10820   __Pyx_INCREF(((PyObject *)__pyx_v_self));
10821   __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
10822   __Pyx_GOTREF(__pyx_v_info->obj);
10823   __Pyx_DECREF(__pyx_v_info->obj);
10824   __pyx_v_info->obj = ((PyObject *)__pyx_v_self);
10825 
10826   /* "View.MemoryView":185
10827  *
10828  *     @cname('getbuffer')
10829  *     def __getbuffer__(self, Py_buffer *info, int flags):             # <<<<<<<<<<<<<<
10830  *         cdef int bufmode = -1
10831  *         if self.mode == u"c":
10832  */
10833 
10834   /* function exit code */
10835   __pyx_r = 0;
10836   goto __pyx_L0;
10837   __pyx_L1_error:;
10838   __Pyx_XDECREF(__pyx_t_3);
10839   __Pyx_AddTraceback("View.MemoryView.array.__getbuffer__", __pyx_clineno, __pyx_lineno, __pyx_filename);
10840   __pyx_r = -1;
10841   if (__pyx_v_info->obj != NULL) {
10842     __Pyx_GOTREF(__pyx_v_info->obj);
10843     __Pyx_DECREF(__pyx_v_info->obj); __pyx_v_info->obj = 0;
10844   }
10845   goto __pyx_L2;
10846   __pyx_L0:;
10847   if (__pyx_v_info->obj == Py_None) {
10848     __Pyx_GOTREF(__pyx_v_info->obj);
10849     __Pyx_DECREF(__pyx_v_info->obj); __pyx_v_info->obj = 0;
10850   }
10851   __pyx_L2:;
10852   __Pyx_RefNannyFinishContext();
10853   return __pyx_r;
10854 }
10855 
10856 /* "View.MemoryView":211
10857  *     __pyx_getbuffer = capsule(<void *> &__pyx_array_getbuffer, "getbuffer(obj, view, flags)")
10858  *
10859  *     def __dealloc__(array self):             # <<<<<<<<<<<<<<
10860  *         if self.callback_free_data != NULL:
10861  *             self.callback_free_data(self.data)
10862  */
10863 
10864 /* Python wrapper */
10865 static void __pyx_array___dealloc__(PyObject *__pyx_v_self); /*proto*/
__pyx_array___dealloc__(PyObject * __pyx_v_self)10866 static void __pyx_array___dealloc__(PyObject *__pyx_v_self) {
10867   __Pyx_RefNannyDeclarations
10868   __Pyx_RefNannySetupContext("__dealloc__ (wrapper)", 0);
10869   __pyx_array___pyx_pf_15View_dot_MemoryView_5array_4__dealloc__(((struct __pyx_array_obj *)__pyx_v_self));
10870 
10871   /* function exit code */
10872   __Pyx_RefNannyFinishContext();
10873 }
10874 
__pyx_array___pyx_pf_15View_dot_MemoryView_5array_4__dealloc__(struct __pyx_array_obj * __pyx_v_self)10875 static void __pyx_array___pyx_pf_15View_dot_MemoryView_5array_4__dealloc__(struct __pyx_array_obj *__pyx_v_self) {
10876   __Pyx_RefNannyDeclarations
10877   int __pyx_t_1;
10878   __Pyx_RefNannySetupContext("__dealloc__", 0);
10879 
10880   /* "View.MemoryView":212
10881  *
10882  *     def __dealloc__(array self):
10883  *         if self.callback_free_data != NULL:             # <<<<<<<<<<<<<<
10884  *             self.callback_free_data(self.data)
10885  *         elif self.free_data:
10886  */
10887   __pyx_t_1 = ((__pyx_v_self->callback_free_data != NULL) != 0);
10888   if (__pyx_t_1) {
10889 
10890     /* "View.MemoryView":213
10891  *     def __dealloc__(array self):
10892  *         if self.callback_free_data != NULL:
10893  *             self.callback_free_data(self.data)             # <<<<<<<<<<<<<<
10894  *         elif self.free_data:
10895  *             if self.dtype_is_object:
10896  */
10897     __pyx_v_self->callback_free_data(__pyx_v_self->data);
10898 
10899     /* "View.MemoryView":212
10900  *
10901  *     def __dealloc__(array self):
10902  *         if self.callback_free_data != NULL:             # <<<<<<<<<<<<<<
10903  *             self.callback_free_data(self.data)
10904  *         elif self.free_data:
10905  */
10906     goto __pyx_L3;
10907   }
10908 
10909   /* "View.MemoryView":214
10910  *         if self.callback_free_data != NULL:
10911  *             self.callback_free_data(self.data)
10912  *         elif self.free_data:             # <<<<<<<<<<<<<<
10913  *             if self.dtype_is_object:
10914  *                 refcount_objects_in_slice(self.data, self._shape,
10915  */
10916   __pyx_t_1 = (__pyx_v_self->free_data != 0);
10917   if (__pyx_t_1) {
10918 
10919     /* "View.MemoryView":215
10920  *             self.callback_free_data(self.data)
10921  *         elif self.free_data:
10922  *             if self.dtype_is_object:             # <<<<<<<<<<<<<<
10923  *                 refcount_objects_in_slice(self.data, self._shape,
10924  *                                           self._strides, self.ndim, False)
10925  */
10926     __pyx_t_1 = (__pyx_v_self->dtype_is_object != 0);
10927     if (__pyx_t_1) {
10928 
10929       /* "View.MemoryView":216
10930  *         elif self.free_data:
10931  *             if self.dtype_is_object:
10932  *                 refcount_objects_in_slice(self.data, self._shape,             # <<<<<<<<<<<<<<
10933  *                                           self._strides, self.ndim, False)
10934  *             free(self.data)
10935  */
10936       __pyx_memoryview_refcount_objects_in_slice(__pyx_v_self->data, __pyx_v_self->_shape, __pyx_v_self->_strides, __pyx_v_self->ndim, 0);
10937 
10938       /* "View.MemoryView":215
10939  *             self.callback_free_data(self.data)
10940  *         elif self.free_data:
10941  *             if self.dtype_is_object:             # <<<<<<<<<<<<<<
10942  *                 refcount_objects_in_slice(self.data, self._shape,
10943  *                                           self._strides, self.ndim, False)
10944  */
10945     }
10946 
10947     /* "View.MemoryView":218
10948  *                 refcount_objects_in_slice(self.data, self._shape,
10949  *                                           self._strides, self.ndim, False)
10950  *             free(self.data)             # <<<<<<<<<<<<<<
10951  *         PyObject_Free(self._shape)
10952  *
10953  */
10954     free(__pyx_v_self->data);
10955 
10956     /* "View.MemoryView":214
10957  *         if self.callback_free_data != NULL:
10958  *             self.callback_free_data(self.data)
10959  *         elif self.free_data:             # <<<<<<<<<<<<<<
10960  *             if self.dtype_is_object:
10961  *                 refcount_objects_in_slice(self.data, self._shape,
10962  */
10963   }
10964   __pyx_L3:;
10965 
10966   /* "View.MemoryView":219
10967  *                                           self._strides, self.ndim, False)
10968  *             free(self.data)
10969  *         PyObject_Free(self._shape)             # <<<<<<<<<<<<<<
10970  *
10971  *     @property
10972  */
10973   PyObject_Free(__pyx_v_self->_shape);
10974 
10975   /* "View.MemoryView":211
10976  *     __pyx_getbuffer = capsule(<void *> &__pyx_array_getbuffer, "getbuffer(obj, view, flags)")
10977  *
10978  *     def __dealloc__(array self):             # <<<<<<<<<<<<<<
10979  *         if self.callback_free_data != NULL:
10980  *             self.callback_free_data(self.data)
10981  */
10982 
10983   /* function exit code */
10984   __Pyx_RefNannyFinishContext();
10985 }
10986 
10987 /* "View.MemoryView":222
10988  *
10989  *     @property
10990  *     def memview(self):             # <<<<<<<<<<<<<<
10991  *         return self.get_memview()
10992  *
10993  */
10994 
10995 /* Python wrapper */
10996 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)10997 static PyObject *__pyx_pw_15View_dot_MemoryView_5array_7memview_1__get__(PyObject *__pyx_v_self) {
10998   PyObject *__pyx_r = 0;
10999   __Pyx_RefNannyDeclarations
11000   __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
11001   __pyx_r = __pyx_pf_15View_dot_MemoryView_5array_7memview___get__(((struct __pyx_array_obj *)__pyx_v_self));
11002 
11003   /* function exit code */
11004   __Pyx_RefNannyFinishContext();
11005   return __pyx_r;
11006 }
11007 
__pyx_pf_15View_dot_MemoryView_5array_7memview___get__(struct __pyx_array_obj * __pyx_v_self)11008 static PyObject *__pyx_pf_15View_dot_MemoryView_5array_7memview___get__(struct __pyx_array_obj *__pyx_v_self) {
11009   PyObject *__pyx_r = NULL;
11010   __Pyx_RefNannyDeclarations
11011   PyObject *__pyx_t_1 = NULL;
11012   int __pyx_lineno = 0;
11013   const char *__pyx_filename = NULL;
11014   int __pyx_clineno = 0;
11015   __Pyx_RefNannySetupContext("__get__", 0);
11016 
11017   /* "View.MemoryView":223
11018  *     @property
11019  *     def memview(self):
11020  *         return self.get_memview()             # <<<<<<<<<<<<<<
11021  *
11022  *     @cname('get_memview')
11023  */
11024   __Pyx_XDECREF(__pyx_r);
11025   __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)
11026   __Pyx_GOTREF(__pyx_t_1);
11027   __pyx_r = __pyx_t_1;
11028   __pyx_t_1 = 0;
11029   goto __pyx_L0;
11030 
11031   /* "View.MemoryView":222
11032  *
11033  *     @property
11034  *     def memview(self):             # <<<<<<<<<<<<<<
11035  *         return self.get_memview()
11036  *
11037  */
11038 
11039   /* function exit code */
11040   __pyx_L1_error:;
11041   __Pyx_XDECREF(__pyx_t_1);
11042   __Pyx_AddTraceback("View.MemoryView.array.memview.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
11043   __pyx_r = NULL;
11044   __pyx_L0:;
11045   __Pyx_XGIVEREF(__pyx_r);
11046   __Pyx_RefNannyFinishContext();
11047   return __pyx_r;
11048 }
11049 
11050 /* "View.MemoryView":226
11051  *
11052  *     @cname('get_memview')
11053  *     cdef get_memview(self):             # <<<<<<<<<<<<<<
11054  *         flags =  PyBUF_ANY_CONTIGUOUS|PyBUF_FORMAT|PyBUF_WRITABLE
11055  *         return  memoryview(self, flags, self.dtype_is_object)
11056  */
11057 
__pyx_array_get_memview(struct __pyx_array_obj * __pyx_v_self)11058 static PyObject *__pyx_array_get_memview(struct __pyx_array_obj *__pyx_v_self) {
11059   int __pyx_v_flags;
11060   PyObject *__pyx_r = NULL;
11061   __Pyx_RefNannyDeclarations
11062   PyObject *__pyx_t_1 = NULL;
11063   PyObject *__pyx_t_2 = NULL;
11064   PyObject *__pyx_t_3 = NULL;
11065   int __pyx_lineno = 0;
11066   const char *__pyx_filename = NULL;
11067   int __pyx_clineno = 0;
11068   __Pyx_RefNannySetupContext("get_memview", 0);
11069 
11070   /* "View.MemoryView":227
11071  *     @cname('get_memview')
11072  *     cdef get_memview(self):
11073  *         flags =  PyBUF_ANY_CONTIGUOUS|PyBUF_FORMAT|PyBUF_WRITABLE             # <<<<<<<<<<<<<<
11074  *         return  memoryview(self, flags, self.dtype_is_object)
11075  *
11076  */
11077   __pyx_v_flags = ((PyBUF_ANY_CONTIGUOUS | PyBUF_FORMAT) | PyBUF_WRITABLE);
11078 
11079   /* "View.MemoryView":228
11080  *     cdef get_memview(self):
11081  *         flags =  PyBUF_ANY_CONTIGUOUS|PyBUF_FORMAT|PyBUF_WRITABLE
11082  *         return  memoryview(self, flags, self.dtype_is_object)             # <<<<<<<<<<<<<<
11083  *
11084  *     def __len__(self):
11085  */
11086   __Pyx_XDECREF(__pyx_r);
11087   __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_flags); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 228, __pyx_L1_error)
11088   __Pyx_GOTREF(__pyx_t_1);
11089   __pyx_t_2 = __Pyx_PyBool_FromLong(__pyx_v_self->dtype_is_object); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 228, __pyx_L1_error)
11090   __Pyx_GOTREF(__pyx_t_2);
11091   __pyx_t_3 = PyTuple_New(3); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 228, __pyx_L1_error)
11092   __Pyx_GOTREF(__pyx_t_3);
11093   __Pyx_INCREF(((PyObject *)__pyx_v_self));
11094   __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
11095   PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)__pyx_v_self));
11096   __Pyx_GIVEREF(__pyx_t_1);
11097   PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_1);
11098   __Pyx_GIVEREF(__pyx_t_2);
11099   PyTuple_SET_ITEM(__pyx_t_3, 2, __pyx_t_2);
11100   __pyx_t_1 = 0;
11101   __pyx_t_2 = 0;
11102   __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)
11103   __Pyx_GOTREF(__pyx_t_2);
11104   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
11105   __pyx_r = __pyx_t_2;
11106   __pyx_t_2 = 0;
11107   goto __pyx_L0;
11108 
11109   /* "View.MemoryView":226
11110  *
11111  *     @cname('get_memview')
11112  *     cdef get_memview(self):             # <<<<<<<<<<<<<<
11113  *         flags =  PyBUF_ANY_CONTIGUOUS|PyBUF_FORMAT|PyBUF_WRITABLE
11114  *         return  memoryview(self, flags, self.dtype_is_object)
11115  */
11116 
11117   /* function exit code */
11118   __pyx_L1_error:;
11119   __Pyx_XDECREF(__pyx_t_1);
11120   __Pyx_XDECREF(__pyx_t_2);
11121   __Pyx_XDECREF(__pyx_t_3);
11122   __Pyx_AddTraceback("View.MemoryView.array.get_memview", __pyx_clineno, __pyx_lineno, __pyx_filename);
11123   __pyx_r = 0;
11124   __pyx_L0:;
11125   __Pyx_XGIVEREF(__pyx_r);
11126   __Pyx_RefNannyFinishContext();
11127   return __pyx_r;
11128 }
11129 
11130 /* "View.MemoryView":230
11131  *         return  memoryview(self, flags, self.dtype_is_object)
11132  *
11133  *     def __len__(self):             # <<<<<<<<<<<<<<
11134  *         return self._shape[0]
11135  *
11136  */
11137 
11138 /* Python wrapper */
11139 static Py_ssize_t __pyx_array___len__(PyObject *__pyx_v_self); /*proto*/
__pyx_array___len__(PyObject * __pyx_v_self)11140 static Py_ssize_t __pyx_array___len__(PyObject *__pyx_v_self) {
11141   Py_ssize_t __pyx_r;
11142   __Pyx_RefNannyDeclarations
11143   __Pyx_RefNannySetupContext("__len__ (wrapper)", 0);
11144   __pyx_r = __pyx_array___pyx_pf_15View_dot_MemoryView_5array_6__len__(((struct __pyx_array_obj *)__pyx_v_self));
11145 
11146   /* function exit code */
11147   __Pyx_RefNannyFinishContext();
11148   return __pyx_r;
11149 }
11150 
__pyx_array___pyx_pf_15View_dot_MemoryView_5array_6__len__(struct __pyx_array_obj * __pyx_v_self)11151 static Py_ssize_t __pyx_array___pyx_pf_15View_dot_MemoryView_5array_6__len__(struct __pyx_array_obj *__pyx_v_self) {
11152   Py_ssize_t __pyx_r;
11153   __Pyx_RefNannyDeclarations
11154   __Pyx_RefNannySetupContext("__len__", 0);
11155 
11156   /* "View.MemoryView":231
11157  *
11158  *     def __len__(self):
11159  *         return self._shape[0]             # <<<<<<<<<<<<<<
11160  *
11161  *     def __getattr__(self, attr):
11162  */
11163   __pyx_r = (__pyx_v_self->_shape[0]);
11164   goto __pyx_L0;
11165 
11166   /* "View.MemoryView":230
11167  *         return  memoryview(self, flags, self.dtype_is_object)
11168  *
11169  *     def __len__(self):             # <<<<<<<<<<<<<<
11170  *         return self._shape[0]
11171  *
11172  */
11173 
11174   /* function exit code */
11175   __pyx_L0:;
11176   __Pyx_RefNannyFinishContext();
11177   return __pyx_r;
11178 }
11179 
11180 /* "View.MemoryView":233
11181  *         return self._shape[0]
11182  *
11183  *     def __getattr__(self, attr):             # <<<<<<<<<<<<<<
11184  *         return getattr(self.memview, attr)
11185  *
11186  */
11187 
11188 /* Python wrapper */
11189 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)11190 static PyObject *__pyx_array___getattr__(PyObject *__pyx_v_self, PyObject *__pyx_v_attr) {
11191   PyObject *__pyx_r = 0;
11192   __Pyx_RefNannyDeclarations
11193   __Pyx_RefNannySetupContext("__getattr__ (wrapper)", 0);
11194   __pyx_r = __pyx_array___pyx_pf_15View_dot_MemoryView_5array_8__getattr__(((struct __pyx_array_obj *)__pyx_v_self), ((PyObject *)__pyx_v_attr));
11195 
11196   /* function exit code */
11197   __Pyx_RefNannyFinishContext();
11198   return __pyx_r;
11199 }
11200 
__pyx_array___pyx_pf_15View_dot_MemoryView_5array_8__getattr__(struct __pyx_array_obj * __pyx_v_self,PyObject * __pyx_v_attr)11201 static PyObject *__pyx_array___pyx_pf_15View_dot_MemoryView_5array_8__getattr__(struct __pyx_array_obj *__pyx_v_self, PyObject *__pyx_v_attr) {
11202   PyObject *__pyx_r = NULL;
11203   __Pyx_RefNannyDeclarations
11204   PyObject *__pyx_t_1 = NULL;
11205   PyObject *__pyx_t_2 = NULL;
11206   int __pyx_lineno = 0;
11207   const char *__pyx_filename = NULL;
11208   int __pyx_clineno = 0;
11209   __Pyx_RefNannySetupContext("__getattr__", 0);
11210 
11211   /* "View.MemoryView":234
11212  *
11213  *     def __getattr__(self, attr):
11214  *         return getattr(self.memview, attr)             # <<<<<<<<<<<<<<
11215  *
11216  *     def __getitem__(self, item):
11217  */
11218   __Pyx_XDECREF(__pyx_r);
11219   __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)
11220   __Pyx_GOTREF(__pyx_t_1);
11221   __pyx_t_2 = __Pyx_GetAttr(__pyx_t_1, __pyx_v_attr); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 234, __pyx_L1_error)
11222   __Pyx_GOTREF(__pyx_t_2);
11223   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
11224   __pyx_r = __pyx_t_2;
11225   __pyx_t_2 = 0;
11226   goto __pyx_L0;
11227 
11228   /* "View.MemoryView":233
11229  *         return self._shape[0]
11230  *
11231  *     def __getattr__(self, attr):             # <<<<<<<<<<<<<<
11232  *         return getattr(self.memview, attr)
11233  *
11234  */
11235 
11236   /* function exit code */
11237   __pyx_L1_error:;
11238   __Pyx_XDECREF(__pyx_t_1);
11239   __Pyx_XDECREF(__pyx_t_2);
11240   __Pyx_AddTraceback("View.MemoryView.array.__getattr__", __pyx_clineno, __pyx_lineno, __pyx_filename);
11241   __pyx_r = NULL;
11242   __pyx_L0:;
11243   __Pyx_XGIVEREF(__pyx_r);
11244   __Pyx_RefNannyFinishContext();
11245   return __pyx_r;
11246 }
11247 
11248 /* "View.MemoryView":236
11249  *         return getattr(self.memview, attr)
11250  *
11251  *     def __getitem__(self, item):             # <<<<<<<<<<<<<<
11252  *         return self.memview[item]
11253  *
11254  */
11255 
11256 /* Python wrapper */
11257 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)11258 static PyObject *__pyx_array___getitem__(PyObject *__pyx_v_self, PyObject *__pyx_v_item) {
11259   PyObject *__pyx_r = 0;
11260   __Pyx_RefNannyDeclarations
11261   __Pyx_RefNannySetupContext("__getitem__ (wrapper)", 0);
11262   __pyx_r = __pyx_array___pyx_pf_15View_dot_MemoryView_5array_10__getitem__(((struct __pyx_array_obj *)__pyx_v_self), ((PyObject *)__pyx_v_item));
11263 
11264   /* function exit code */
11265   __Pyx_RefNannyFinishContext();
11266   return __pyx_r;
11267 }
11268 
__pyx_array___pyx_pf_15View_dot_MemoryView_5array_10__getitem__(struct __pyx_array_obj * __pyx_v_self,PyObject * __pyx_v_item)11269 static PyObject *__pyx_array___pyx_pf_15View_dot_MemoryView_5array_10__getitem__(struct __pyx_array_obj *__pyx_v_self, PyObject *__pyx_v_item) {
11270   PyObject *__pyx_r = NULL;
11271   __Pyx_RefNannyDeclarations
11272   PyObject *__pyx_t_1 = NULL;
11273   PyObject *__pyx_t_2 = NULL;
11274   int __pyx_lineno = 0;
11275   const char *__pyx_filename = NULL;
11276   int __pyx_clineno = 0;
11277   __Pyx_RefNannySetupContext("__getitem__", 0);
11278 
11279   /* "View.MemoryView":237
11280  *
11281  *     def __getitem__(self, item):
11282  *         return self.memview[item]             # <<<<<<<<<<<<<<
11283  *
11284  *     def __setitem__(self, item, value):
11285  */
11286   __Pyx_XDECREF(__pyx_r);
11287   __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)
11288   __Pyx_GOTREF(__pyx_t_1);
11289   __pyx_t_2 = __Pyx_PyObject_GetItem(__pyx_t_1, __pyx_v_item); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 237, __pyx_L1_error)
11290   __Pyx_GOTREF(__pyx_t_2);
11291   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
11292   __pyx_r = __pyx_t_2;
11293   __pyx_t_2 = 0;
11294   goto __pyx_L0;
11295 
11296   /* "View.MemoryView":236
11297  *         return getattr(self.memview, attr)
11298  *
11299  *     def __getitem__(self, item):             # <<<<<<<<<<<<<<
11300  *         return self.memview[item]
11301  *
11302  */
11303 
11304   /* function exit code */
11305   __pyx_L1_error:;
11306   __Pyx_XDECREF(__pyx_t_1);
11307   __Pyx_XDECREF(__pyx_t_2);
11308   __Pyx_AddTraceback("View.MemoryView.array.__getitem__", __pyx_clineno, __pyx_lineno, __pyx_filename);
11309   __pyx_r = NULL;
11310   __pyx_L0:;
11311   __Pyx_XGIVEREF(__pyx_r);
11312   __Pyx_RefNannyFinishContext();
11313   return __pyx_r;
11314 }
11315 
11316 /* "View.MemoryView":239
11317  *         return self.memview[item]
11318  *
11319  *     def __setitem__(self, item, value):             # <<<<<<<<<<<<<<
11320  *         self.memview[item] = value
11321  *
11322  */
11323 
11324 /* Python wrapper */
11325 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)11326 static int __pyx_array___setitem__(PyObject *__pyx_v_self, PyObject *__pyx_v_item, PyObject *__pyx_v_value) {
11327   int __pyx_r;
11328   __Pyx_RefNannyDeclarations
11329   __Pyx_RefNannySetupContext("__setitem__ (wrapper)", 0);
11330   __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));
11331 
11332   /* function exit code */
11333   __Pyx_RefNannyFinishContext();
11334   return __pyx_r;
11335 }
11336 
__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)11337 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) {
11338   int __pyx_r;
11339   __Pyx_RefNannyDeclarations
11340   PyObject *__pyx_t_1 = NULL;
11341   int __pyx_lineno = 0;
11342   const char *__pyx_filename = NULL;
11343   int __pyx_clineno = 0;
11344   __Pyx_RefNannySetupContext("__setitem__", 0);
11345 
11346   /* "View.MemoryView":240
11347  *
11348  *     def __setitem__(self, item, value):
11349  *         self.memview[item] = value             # <<<<<<<<<<<<<<
11350  *
11351  *
11352  */
11353   __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)
11354   __Pyx_GOTREF(__pyx_t_1);
11355   if (unlikely(PyObject_SetItem(__pyx_t_1, __pyx_v_item, __pyx_v_value) < 0)) __PYX_ERR(2, 240, __pyx_L1_error)
11356   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
11357 
11358   /* "View.MemoryView":239
11359  *         return self.memview[item]
11360  *
11361  *     def __setitem__(self, item, value):             # <<<<<<<<<<<<<<
11362  *         self.memview[item] = value
11363  *
11364  */
11365 
11366   /* function exit code */
11367   __pyx_r = 0;
11368   goto __pyx_L0;
11369   __pyx_L1_error:;
11370   __Pyx_XDECREF(__pyx_t_1);
11371   __Pyx_AddTraceback("View.MemoryView.array.__setitem__", __pyx_clineno, __pyx_lineno, __pyx_filename);
11372   __pyx_r = -1;
11373   __pyx_L0:;
11374   __Pyx_RefNannyFinishContext();
11375   return __pyx_r;
11376 }
11377 
11378 /* "(tree fragment)":1
11379  * def __reduce_cython__(self):             # <<<<<<<<<<<<<<
11380  *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
11381  * def __setstate_cython__(self, __pyx_state):
11382  */
11383 
11384 /* Python wrapper */
11385 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)11386 static PyObject *__pyx_pw___pyx_array_1__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
11387   PyObject *__pyx_r = 0;
11388   __Pyx_RefNannyDeclarations
11389   __Pyx_RefNannySetupContext("__reduce_cython__ (wrapper)", 0);
11390   __pyx_r = __pyx_pf___pyx_array___reduce_cython__(((struct __pyx_array_obj *)__pyx_v_self));
11391 
11392   /* function exit code */
11393   __Pyx_RefNannyFinishContext();
11394   return __pyx_r;
11395 }
11396 
__pyx_pf___pyx_array___reduce_cython__(CYTHON_UNUSED struct __pyx_array_obj * __pyx_v_self)11397 static PyObject *__pyx_pf___pyx_array___reduce_cython__(CYTHON_UNUSED struct __pyx_array_obj *__pyx_v_self) {
11398   PyObject *__pyx_r = NULL;
11399   __Pyx_RefNannyDeclarations
11400   PyObject *__pyx_t_1 = NULL;
11401   int __pyx_lineno = 0;
11402   const char *__pyx_filename = NULL;
11403   int __pyx_clineno = 0;
11404   __Pyx_RefNannySetupContext("__reduce_cython__", 0);
11405 
11406   /* "(tree fragment)":2
11407  * def __reduce_cython__(self):
11408  *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")             # <<<<<<<<<<<<<<
11409  * def __setstate_cython__(self, __pyx_state):
11410  *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
11411  */
11412   __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__8, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 2, __pyx_L1_error)
11413   __Pyx_GOTREF(__pyx_t_1);
11414   __Pyx_Raise(__pyx_t_1, 0, 0, 0);
11415   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
11416   __PYX_ERR(2, 2, __pyx_L1_error)
11417 
11418   /* "(tree fragment)":1
11419  * def __reduce_cython__(self):             # <<<<<<<<<<<<<<
11420  *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
11421  * def __setstate_cython__(self, __pyx_state):
11422  */
11423 
11424   /* function exit code */
11425   __pyx_L1_error:;
11426   __Pyx_XDECREF(__pyx_t_1);
11427   __Pyx_AddTraceback("View.MemoryView.array.__reduce_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename);
11428   __pyx_r = NULL;
11429   __Pyx_XGIVEREF(__pyx_r);
11430   __Pyx_RefNannyFinishContext();
11431   return __pyx_r;
11432 }
11433 
11434 /* "(tree fragment)":3
11435  * def __reduce_cython__(self):
11436  *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
11437  * def __setstate_cython__(self, __pyx_state):             # <<<<<<<<<<<<<<
11438  *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
11439  */
11440 
11441 /* Python wrapper */
11442 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)11443 static PyObject *__pyx_pw___pyx_array_3__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state) {
11444   PyObject *__pyx_r = 0;
11445   __Pyx_RefNannyDeclarations
11446   __Pyx_RefNannySetupContext("__setstate_cython__ (wrapper)", 0);
11447   __pyx_r = __pyx_pf___pyx_array_2__setstate_cython__(((struct __pyx_array_obj *)__pyx_v_self), ((PyObject *)__pyx_v___pyx_state));
11448 
11449   /* function exit code */
11450   __Pyx_RefNannyFinishContext();
11451   return __pyx_r;
11452 }
11453 
__pyx_pf___pyx_array_2__setstate_cython__(CYTHON_UNUSED struct __pyx_array_obj * __pyx_v_self,CYTHON_UNUSED PyObject * __pyx_v___pyx_state)11454 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) {
11455   PyObject *__pyx_r = NULL;
11456   __Pyx_RefNannyDeclarations
11457   PyObject *__pyx_t_1 = NULL;
11458   int __pyx_lineno = 0;
11459   const char *__pyx_filename = NULL;
11460   int __pyx_clineno = 0;
11461   __Pyx_RefNannySetupContext("__setstate_cython__", 0);
11462 
11463   /* "(tree fragment)":4
11464  *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
11465  * def __setstate_cython__(self, __pyx_state):
11466  *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")             # <<<<<<<<<<<<<<
11467  */
11468   __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__9, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 4, __pyx_L1_error)
11469   __Pyx_GOTREF(__pyx_t_1);
11470   __Pyx_Raise(__pyx_t_1, 0, 0, 0);
11471   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
11472   __PYX_ERR(2, 4, __pyx_L1_error)
11473 
11474   /* "(tree fragment)":3
11475  * def __reduce_cython__(self):
11476  *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
11477  * def __setstate_cython__(self, __pyx_state):             # <<<<<<<<<<<<<<
11478  *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
11479  */
11480 
11481   /* function exit code */
11482   __pyx_L1_error:;
11483   __Pyx_XDECREF(__pyx_t_1);
11484   __Pyx_AddTraceback("View.MemoryView.array.__setstate_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename);
11485   __pyx_r = NULL;
11486   __Pyx_XGIVEREF(__pyx_r);
11487   __Pyx_RefNannyFinishContext();
11488   return __pyx_r;
11489 }
11490 
11491 /* "View.MemoryView":244
11492  *
11493  * @cname("__pyx_array_new")
11494  * cdef array array_cwrapper(tuple shape, Py_ssize_t itemsize, char *format,             # <<<<<<<<<<<<<<
11495  *                           char *mode, char *buf):
11496  *     cdef array result
11497  */
11498 
__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)11499 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) {
11500   struct __pyx_array_obj *__pyx_v_result = 0;
11501   struct __pyx_array_obj *__pyx_r = NULL;
11502   __Pyx_RefNannyDeclarations
11503   int __pyx_t_1;
11504   PyObject *__pyx_t_2 = NULL;
11505   PyObject *__pyx_t_3 = NULL;
11506   PyObject *__pyx_t_4 = NULL;
11507   PyObject *__pyx_t_5 = NULL;
11508   int __pyx_lineno = 0;
11509   const char *__pyx_filename = NULL;
11510   int __pyx_clineno = 0;
11511   __Pyx_RefNannySetupContext("array_cwrapper", 0);
11512 
11513   /* "View.MemoryView":248
11514  *     cdef array result
11515  *
11516  *     if buf == NULL:             # <<<<<<<<<<<<<<
11517  *         result = array(shape, itemsize, format, mode.decode('ASCII'))
11518  *     else:
11519  */
11520   __pyx_t_1 = ((__pyx_v_buf == NULL) != 0);
11521   if (__pyx_t_1) {
11522 
11523     /* "View.MemoryView":249
11524  *
11525  *     if buf == NULL:
11526  *         result = array(shape, itemsize, format, mode.decode('ASCII'))             # <<<<<<<<<<<<<<
11527  *     else:
11528  *         result = array(shape, itemsize, format, mode.decode('ASCII'),
11529  */
11530     __pyx_t_2 = PyInt_FromSsize_t(__pyx_v_itemsize); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 249, __pyx_L1_error)
11531     __Pyx_GOTREF(__pyx_t_2);
11532     __pyx_t_3 = __Pyx_PyBytes_FromString(__pyx_v_format); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 249, __pyx_L1_error)
11533     __Pyx_GOTREF(__pyx_t_3);
11534     __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)
11535     __Pyx_GOTREF(__pyx_t_4);
11536     __pyx_t_5 = PyTuple_New(4); if (unlikely(!__pyx_t_5)) __PYX_ERR(2, 249, __pyx_L1_error)
11537     __Pyx_GOTREF(__pyx_t_5);
11538     __Pyx_INCREF(__pyx_v_shape);
11539     __Pyx_GIVEREF(__pyx_v_shape);
11540     PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_v_shape);
11541     __Pyx_GIVEREF(__pyx_t_2);
11542     PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_t_2);
11543     __Pyx_GIVEREF(__pyx_t_3);
11544     PyTuple_SET_ITEM(__pyx_t_5, 2, __pyx_t_3);
11545     __Pyx_GIVEREF(__pyx_t_4);
11546     PyTuple_SET_ITEM(__pyx_t_5, 3, __pyx_t_4);
11547     __pyx_t_2 = 0;
11548     __pyx_t_3 = 0;
11549     __pyx_t_4 = 0;
11550     __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)
11551     __Pyx_GOTREF(__pyx_t_4);
11552     __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
11553     __pyx_v_result = ((struct __pyx_array_obj *)__pyx_t_4);
11554     __pyx_t_4 = 0;
11555 
11556     /* "View.MemoryView":248
11557  *     cdef array result
11558  *
11559  *     if buf == NULL:             # <<<<<<<<<<<<<<
11560  *         result = array(shape, itemsize, format, mode.decode('ASCII'))
11561  *     else:
11562  */
11563     goto __pyx_L3;
11564   }
11565 
11566   /* "View.MemoryView":251
11567  *         result = array(shape, itemsize, format, mode.decode('ASCII'))
11568  *     else:
11569  *         result = array(shape, itemsize, format, mode.decode('ASCII'),             # <<<<<<<<<<<<<<
11570  *                        allocate_buffer=False)
11571  *         result.data = buf
11572  */
11573   /*else*/ {
11574     __pyx_t_4 = PyInt_FromSsize_t(__pyx_v_itemsize); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 251, __pyx_L1_error)
11575     __Pyx_GOTREF(__pyx_t_4);
11576     __pyx_t_5 = __Pyx_PyBytes_FromString(__pyx_v_format); if (unlikely(!__pyx_t_5)) __PYX_ERR(2, 251, __pyx_L1_error)
11577     __Pyx_GOTREF(__pyx_t_5);
11578     __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)
11579     __Pyx_GOTREF(__pyx_t_3);
11580     __pyx_t_2 = PyTuple_New(4); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 251, __pyx_L1_error)
11581     __Pyx_GOTREF(__pyx_t_2);
11582     __Pyx_INCREF(__pyx_v_shape);
11583     __Pyx_GIVEREF(__pyx_v_shape);
11584     PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_shape);
11585     __Pyx_GIVEREF(__pyx_t_4);
11586     PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_t_4);
11587     __Pyx_GIVEREF(__pyx_t_5);
11588     PyTuple_SET_ITEM(__pyx_t_2, 2, __pyx_t_5);
11589     __Pyx_GIVEREF(__pyx_t_3);
11590     PyTuple_SET_ITEM(__pyx_t_2, 3, __pyx_t_3);
11591     __pyx_t_4 = 0;
11592     __pyx_t_5 = 0;
11593     __pyx_t_3 = 0;
11594 
11595     /* "View.MemoryView":252
11596  *     else:
11597  *         result = array(shape, itemsize, format, mode.decode('ASCII'),
11598  *                        allocate_buffer=False)             # <<<<<<<<<<<<<<
11599  *         result.data = buf
11600  *
11601  */
11602     __pyx_t_3 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 252, __pyx_L1_error)
11603     __Pyx_GOTREF(__pyx_t_3);
11604     if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_allocate_buffer, Py_False) < 0) __PYX_ERR(2, 252, __pyx_L1_error)
11605 
11606     /* "View.MemoryView":251
11607  *         result = array(shape, itemsize, format, mode.decode('ASCII'))
11608  *     else:
11609  *         result = array(shape, itemsize, format, mode.decode('ASCII'),             # <<<<<<<<<<<<<<
11610  *                        allocate_buffer=False)
11611  *         result.data = buf
11612  */
11613     __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)
11614     __Pyx_GOTREF(__pyx_t_5);
11615     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
11616     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
11617     __pyx_v_result = ((struct __pyx_array_obj *)__pyx_t_5);
11618     __pyx_t_5 = 0;
11619 
11620     /* "View.MemoryView":253
11621  *         result = array(shape, itemsize, format, mode.decode('ASCII'),
11622  *                        allocate_buffer=False)
11623  *         result.data = buf             # <<<<<<<<<<<<<<
11624  *
11625  *     return result
11626  */
11627     __pyx_v_result->data = __pyx_v_buf;
11628   }
11629   __pyx_L3:;
11630 
11631   /* "View.MemoryView":255
11632  *         result.data = buf
11633  *
11634  *     return result             # <<<<<<<<<<<<<<
11635  *
11636  *
11637  */
11638   __Pyx_XDECREF(((PyObject *)__pyx_r));
11639   __Pyx_INCREF(((PyObject *)__pyx_v_result));
11640   __pyx_r = __pyx_v_result;
11641   goto __pyx_L0;
11642 
11643   /* "View.MemoryView":244
11644  *
11645  * @cname("__pyx_array_new")
11646  * cdef array array_cwrapper(tuple shape, Py_ssize_t itemsize, char *format,             # <<<<<<<<<<<<<<
11647  *                           char *mode, char *buf):
11648  *     cdef array result
11649  */
11650 
11651   /* function exit code */
11652   __pyx_L1_error:;
11653   __Pyx_XDECREF(__pyx_t_2);
11654   __Pyx_XDECREF(__pyx_t_3);
11655   __Pyx_XDECREF(__pyx_t_4);
11656   __Pyx_XDECREF(__pyx_t_5);
11657   __Pyx_AddTraceback("View.MemoryView.array_cwrapper", __pyx_clineno, __pyx_lineno, __pyx_filename);
11658   __pyx_r = 0;
11659   __pyx_L0:;
11660   __Pyx_XDECREF((PyObject *)__pyx_v_result);
11661   __Pyx_XGIVEREF((PyObject *)__pyx_r);
11662   __Pyx_RefNannyFinishContext();
11663   return __pyx_r;
11664 }
11665 
11666 /* "View.MemoryView":281
11667  * cdef class Enum(object):
11668  *     cdef object name
11669  *     def __init__(self, name):             # <<<<<<<<<<<<<<
11670  *         self.name = name
11671  *     def __repr__(self):
11672  */
11673 
11674 /* Python wrapper */
11675 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)11676 static int __pyx_MemviewEnum___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
11677   PyObject *__pyx_v_name = 0;
11678   int __pyx_lineno = 0;
11679   const char *__pyx_filename = NULL;
11680   int __pyx_clineno = 0;
11681   int __pyx_r;
11682   __Pyx_RefNannyDeclarations
11683   __Pyx_RefNannySetupContext("__init__ (wrapper)", 0);
11684   {
11685     static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_name,0};
11686     PyObject* values[1] = {0};
11687     if (unlikely(__pyx_kwds)) {
11688       Py_ssize_t kw_args;
11689       const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
11690       switch (pos_args) {
11691         case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
11692         CYTHON_FALLTHROUGH;
11693         case  0: break;
11694         default: goto __pyx_L5_argtuple_error;
11695       }
11696       kw_args = PyDict_Size(__pyx_kwds);
11697       switch (pos_args) {
11698         case  0:
11699         if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_name)) != 0)) kw_args--;
11700         else goto __pyx_L5_argtuple_error;
11701       }
11702       if (unlikely(kw_args > 0)) {
11703         if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__init__") < 0)) __PYX_ERR(2, 281, __pyx_L3_error)
11704       }
11705     } else if (PyTuple_GET_SIZE(__pyx_args) != 1) {
11706       goto __pyx_L5_argtuple_error;
11707     } else {
11708       values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
11709     }
11710     __pyx_v_name = values[0];
11711   }
11712   goto __pyx_L4_argument_unpacking_done;
11713   __pyx_L5_argtuple_error:;
11714   __Pyx_RaiseArgtupleInvalid("__init__", 1, 1, 1, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(2, 281, __pyx_L3_error)
11715   __pyx_L3_error:;
11716   __Pyx_AddTraceback("View.MemoryView.Enum.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
11717   __Pyx_RefNannyFinishContext();
11718   return -1;
11719   __pyx_L4_argument_unpacking_done:;
11720   __pyx_r = __pyx_MemviewEnum___pyx_pf_15View_dot_MemoryView_4Enum___init__(((struct __pyx_MemviewEnum_obj *)__pyx_v_self), __pyx_v_name);
11721 
11722   /* function exit code */
11723   __Pyx_RefNannyFinishContext();
11724   return __pyx_r;
11725 }
11726 
__pyx_MemviewEnum___pyx_pf_15View_dot_MemoryView_4Enum___init__(struct __pyx_MemviewEnum_obj * __pyx_v_self,PyObject * __pyx_v_name)11727 static int __pyx_MemviewEnum___pyx_pf_15View_dot_MemoryView_4Enum___init__(struct __pyx_MemviewEnum_obj *__pyx_v_self, PyObject *__pyx_v_name) {
11728   int __pyx_r;
11729   __Pyx_RefNannyDeclarations
11730   __Pyx_RefNannySetupContext("__init__", 0);
11731 
11732   /* "View.MemoryView":282
11733  *     cdef object name
11734  *     def __init__(self, name):
11735  *         self.name = name             # <<<<<<<<<<<<<<
11736  *     def __repr__(self):
11737  *         return self.name
11738  */
11739   __Pyx_INCREF(__pyx_v_name);
11740   __Pyx_GIVEREF(__pyx_v_name);
11741   __Pyx_GOTREF(__pyx_v_self->name);
11742   __Pyx_DECREF(__pyx_v_self->name);
11743   __pyx_v_self->name = __pyx_v_name;
11744 
11745   /* "View.MemoryView":281
11746  * cdef class Enum(object):
11747  *     cdef object name
11748  *     def __init__(self, name):             # <<<<<<<<<<<<<<
11749  *         self.name = name
11750  *     def __repr__(self):
11751  */
11752 
11753   /* function exit code */
11754   __pyx_r = 0;
11755   __Pyx_RefNannyFinishContext();
11756   return __pyx_r;
11757 }
11758 
11759 /* "View.MemoryView":283
11760  *     def __init__(self, name):
11761  *         self.name = name
11762  *     def __repr__(self):             # <<<<<<<<<<<<<<
11763  *         return self.name
11764  *
11765  */
11766 
11767 /* Python wrapper */
11768 static PyObject *__pyx_MemviewEnum___repr__(PyObject *__pyx_v_self); /*proto*/
__pyx_MemviewEnum___repr__(PyObject * __pyx_v_self)11769 static PyObject *__pyx_MemviewEnum___repr__(PyObject *__pyx_v_self) {
11770   PyObject *__pyx_r = 0;
11771   __Pyx_RefNannyDeclarations
11772   __Pyx_RefNannySetupContext("__repr__ (wrapper)", 0);
11773   __pyx_r = __pyx_MemviewEnum___pyx_pf_15View_dot_MemoryView_4Enum_2__repr__(((struct __pyx_MemviewEnum_obj *)__pyx_v_self));
11774 
11775   /* function exit code */
11776   __Pyx_RefNannyFinishContext();
11777   return __pyx_r;
11778 }
11779 
__pyx_MemviewEnum___pyx_pf_15View_dot_MemoryView_4Enum_2__repr__(struct __pyx_MemviewEnum_obj * __pyx_v_self)11780 static PyObject *__pyx_MemviewEnum___pyx_pf_15View_dot_MemoryView_4Enum_2__repr__(struct __pyx_MemviewEnum_obj *__pyx_v_self) {
11781   PyObject *__pyx_r = NULL;
11782   __Pyx_RefNannyDeclarations
11783   __Pyx_RefNannySetupContext("__repr__", 0);
11784 
11785   /* "View.MemoryView":284
11786  *         self.name = name
11787  *     def __repr__(self):
11788  *         return self.name             # <<<<<<<<<<<<<<
11789  *
11790  * cdef generic = Enum("<strided and direct or indirect>")
11791  */
11792   __Pyx_XDECREF(__pyx_r);
11793   __Pyx_INCREF(__pyx_v_self->name);
11794   __pyx_r = __pyx_v_self->name;
11795   goto __pyx_L0;
11796 
11797   /* "View.MemoryView":283
11798  *     def __init__(self, name):
11799  *         self.name = name
11800  *     def __repr__(self):             # <<<<<<<<<<<<<<
11801  *         return self.name
11802  *
11803  */
11804 
11805   /* function exit code */
11806   __pyx_L0:;
11807   __Pyx_XGIVEREF(__pyx_r);
11808   __Pyx_RefNannyFinishContext();
11809   return __pyx_r;
11810 }
11811 
11812 /* "(tree fragment)":1
11813  * def __reduce_cython__(self):             # <<<<<<<<<<<<<<
11814  *     cdef tuple state
11815  *     cdef object _dict
11816  */
11817 
11818 /* Python wrapper */
11819 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)11820 static PyObject *__pyx_pw___pyx_MemviewEnum_1__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
11821   PyObject *__pyx_r = 0;
11822   __Pyx_RefNannyDeclarations
11823   __Pyx_RefNannySetupContext("__reduce_cython__ (wrapper)", 0);
11824   __pyx_r = __pyx_pf___pyx_MemviewEnum___reduce_cython__(((struct __pyx_MemviewEnum_obj *)__pyx_v_self));
11825 
11826   /* function exit code */
11827   __Pyx_RefNannyFinishContext();
11828   return __pyx_r;
11829 }
11830 
__pyx_pf___pyx_MemviewEnum___reduce_cython__(struct __pyx_MemviewEnum_obj * __pyx_v_self)11831 static PyObject *__pyx_pf___pyx_MemviewEnum___reduce_cython__(struct __pyx_MemviewEnum_obj *__pyx_v_self) {
11832   PyObject *__pyx_v_state = 0;
11833   PyObject *__pyx_v__dict = 0;
11834   int __pyx_v_use_setstate;
11835   PyObject *__pyx_r = NULL;
11836   __Pyx_RefNannyDeclarations
11837   PyObject *__pyx_t_1 = NULL;
11838   int __pyx_t_2;
11839   int __pyx_t_3;
11840   PyObject *__pyx_t_4 = NULL;
11841   PyObject *__pyx_t_5 = NULL;
11842   int __pyx_lineno = 0;
11843   const char *__pyx_filename = NULL;
11844   int __pyx_clineno = 0;
11845   __Pyx_RefNannySetupContext("__reduce_cython__", 0);
11846 
11847   /* "(tree fragment)":5
11848  *     cdef object _dict
11849  *     cdef bint use_setstate
11850  *     state = (self.name,)             # <<<<<<<<<<<<<<
11851  *     _dict = getattr(self, '__dict__', None)
11852  *     if _dict is not None:
11853  */
11854   __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 5, __pyx_L1_error)
11855   __Pyx_GOTREF(__pyx_t_1);
11856   __Pyx_INCREF(__pyx_v_self->name);
11857   __Pyx_GIVEREF(__pyx_v_self->name);
11858   PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_self->name);
11859   __pyx_v_state = ((PyObject*)__pyx_t_1);
11860   __pyx_t_1 = 0;
11861 
11862   /* "(tree fragment)":6
11863  *     cdef bint use_setstate
11864  *     state = (self.name,)
11865  *     _dict = getattr(self, '__dict__', None)             # <<<<<<<<<<<<<<
11866  *     if _dict is not None:
11867  *         state += (_dict,)
11868  */
11869   __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)
11870   __Pyx_GOTREF(__pyx_t_1);
11871   __pyx_v__dict = __pyx_t_1;
11872   __pyx_t_1 = 0;
11873 
11874   /* "(tree fragment)":7
11875  *     state = (self.name,)
11876  *     _dict = getattr(self, '__dict__', None)
11877  *     if _dict is not None:             # <<<<<<<<<<<<<<
11878  *         state += (_dict,)
11879  *         use_setstate = True
11880  */
11881   __pyx_t_2 = (__pyx_v__dict != Py_None);
11882   __pyx_t_3 = (__pyx_t_2 != 0);
11883   if (__pyx_t_3) {
11884 
11885     /* "(tree fragment)":8
11886  *     _dict = getattr(self, '__dict__', None)
11887  *     if _dict is not None:
11888  *         state += (_dict,)             # <<<<<<<<<<<<<<
11889  *         use_setstate = True
11890  *     else:
11891  */
11892     __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 8, __pyx_L1_error)
11893     __Pyx_GOTREF(__pyx_t_1);
11894     __Pyx_INCREF(__pyx_v__dict);
11895     __Pyx_GIVEREF(__pyx_v__dict);
11896     PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v__dict);
11897     __pyx_t_4 = PyNumber_InPlaceAdd(__pyx_v_state, __pyx_t_1); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 8, __pyx_L1_error)
11898     __Pyx_GOTREF(__pyx_t_4);
11899     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
11900     __Pyx_DECREF_SET(__pyx_v_state, ((PyObject*)__pyx_t_4));
11901     __pyx_t_4 = 0;
11902 
11903     /* "(tree fragment)":9
11904  *     if _dict is not None:
11905  *         state += (_dict,)
11906  *         use_setstate = True             # <<<<<<<<<<<<<<
11907  *     else:
11908  *         use_setstate = self.name is not None
11909  */
11910     __pyx_v_use_setstate = 1;
11911 
11912     /* "(tree fragment)":7
11913  *     state = (self.name,)
11914  *     _dict = getattr(self, '__dict__', None)
11915  *     if _dict is not None:             # <<<<<<<<<<<<<<
11916  *         state += (_dict,)
11917  *         use_setstate = True
11918  */
11919     goto __pyx_L3;
11920   }
11921 
11922   /* "(tree fragment)":11
11923  *         use_setstate = True
11924  *     else:
11925  *         use_setstate = self.name is not None             # <<<<<<<<<<<<<<
11926  *     if use_setstate:
11927  *         return __pyx_unpickle_Enum, (type(self), 0xb068931, None), state
11928  */
11929   /*else*/ {
11930     __pyx_t_3 = (__pyx_v_self->name != Py_None);
11931     __pyx_v_use_setstate = __pyx_t_3;
11932   }
11933   __pyx_L3:;
11934 
11935   /* "(tree fragment)":12
11936  *     else:
11937  *         use_setstate = self.name is not None
11938  *     if use_setstate:             # <<<<<<<<<<<<<<
11939  *         return __pyx_unpickle_Enum, (type(self), 0xb068931, None), state
11940  *     else:
11941  */
11942   __pyx_t_3 = (__pyx_v_use_setstate != 0);
11943   if (__pyx_t_3) {
11944 
11945     /* "(tree fragment)":13
11946  *         use_setstate = self.name is not None
11947  *     if use_setstate:
11948  *         return __pyx_unpickle_Enum, (type(self), 0xb068931, None), state             # <<<<<<<<<<<<<<
11949  *     else:
11950  *         return __pyx_unpickle_Enum, (type(self), 0xb068931, state)
11951  */
11952     __Pyx_XDECREF(__pyx_r);
11953     __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_pyx_unpickle_Enum); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 13, __pyx_L1_error)
11954     __Pyx_GOTREF(__pyx_t_4);
11955     __pyx_t_1 = PyTuple_New(3); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 13, __pyx_L1_error)
11956     __Pyx_GOTREF(__pyx_t_1);
11957     __Pyx_INCREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
11958     __Pyx_GIVEREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
11959     PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
11960     __Pyx_INCREF(__pyx_int_184977713);
11961     __Pyx_GIVEREF(__pyx_int_184977713);
11962     PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_int_184977713);
11963     __Pyx_INCREF(Py_None);
11964     __Pyx_GIVEREF(Py_None);
11965     PyTuple_SET_ITEM(__pyx_t_1, 2, Py_None);
11966     __pyx_t_5 = PyTuple_New(3); if (unlikely(!__pyx_t_5)) __PYX_ERR(2, 13, __pyx_L1_error)
11967     __Pyx_GOTREF(__pyx_t_5);
11968     __Pyx_GIVEREF(__pyx_t_4);
11969     PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_4);
11970     __Pyx_GIVEREF(__pyx_t_1);
11971     PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_t_1);
11972     __Pyx_INCREF(__pyx_v_state);
11973     __Pyx_GIVEREF(__pyx_v_state);
11974     PyTuple_SET_ITEM(__pyx_t_5, 2, __pyx_v_state);
11975     __pyx_t_4 = 0;
11976     __pyx_t_1 = 0;
11977     __pyx_r = __pyx_t_5;
11978     __pyx_t_5 = 0;
11979     goto __pyx_L0;
11980 
11981     /* "(tree fragment)":12
11982  *     else:
11983  *         use_setstate = self.name is not None
11984  *     if use_setstate:             # <<<<<<<<<<<<<<
11985  *         return __pyx_unpickle_Enum, (type(self), 0xb068931, None), state
11986  *     else:
11987  */
11988   }
11989 
11990   /* "(tree fragment)":15
11991  *         return __pyx_unpickle_Enum, (type(self), 0xb068931, None), state
11992  *     else:
11993  *         return __pyx_unpickle_Enum, (type(self), 0xb068931, state)             # <<<<<<<<<<<<<<
11994  * def __setstate_cython__(self, __pyx_state):
11995  *     __pyx_unpickle_Enum__set_state(self, __pyx_state)
11996  */
11997   /*else*/ {
11998     __Pyx_XDECREF(__pyx_r);
11999     __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_n_s_pyx_unpickle_Enum); if (unlikely(!__pyx_t_5)) __PYX_ERR(2, 15, __pyx_L1_error)
12000     __Pyx_GOTREF(__pyx_t_5);
12001     __pyx_t_1 = PyTuple_New(3); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 15, __pyx_L1_error)
12002     __Pyx_GOTREF(__pyx_t_1);
12003     __Pyx_INCREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
12004     __Pyx_GIVEREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
12005     PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
12006     __Pyx_INCREF(__pyx_int_184977713);
12007     __Pyx_GIVEREF(__pyx_int_184977713);
12008     PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_int_184977713);
12009     __Pyx_INCREF(__pyx_v_state);
12010     __Pyx_GIVEREF(__pyx_v_state);
12011     PyTuple_SET_ITEM(__pyx_t_1, 2, __pyx_v_state);
12012     __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 15, __pyx_L1_error)
12013     __Pyx_GOTREF(__pyx_t_4);
12014     __Pyx_GIVEREF(__pyx_t_5);
12015     PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_5);
12016     __Pyx_GIVEREF(__pyx_t_1);
12017     PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_1);
12018     __pyx_t_5 = 0;
12019     __pyx_t_1 = 0;
12020     __pyx_r = __pyx_t_4;
12021     __pyx_t_4 = 0;
12022     goto __pyx_L0;
12023   }
12024 
12025   /* "(tree fragment)":1
12026  * def __reduce_cython__(self):             # <<<<<<<<<<<<<<
12027  *     cdef tuple state
12028  *     cdef object _dict
12029  */
12030 
12031   /* function exit code */
12032   __pyx_L1_error:;
12033   __Pyx_XDECREF(__pyx_t_1);
12034   __Pyx_XDECREF(__pyx_t_4);
12035   __Pyx_XDECREF(__pyx_t_5);
12036   __Pyx_AddTraceback("View.MemoryView.Enum.__reduce_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename);
12037   __pyx_r = NULL;
12038   __pyx_L0:;
12039   __Pyx_XDECREF(__pyx_v_state);
12040   __Pyx_XDECREF(__pyx_v__dict);
12041   __Pyx_XGIVEREF(__pyx_r);
12042   __Pyx_RefNannyFinishContext();
12043   return __pyx_r;
12044 }
12045 
12046 /* "(tree fragment)":16
12047  *     else:
12048  *         return __pyx_unpickle_Enum, (type(self), 0xb068931, state)
12049  * def __setstate_cython__(self, __pyx_state):             # <<<<<<<<<<<<<<
12050  *     __pyx_unpickle_Enum__set_state(self, __pyx_state)
12051  */
12052 
12053 /* Python wrapper */
12054 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)12055 static PyObject *__pyx_pw___pyx_MemviewEnum_3__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state) {
12056   PyObject *__pyx_r = 0;
12057   __Pyx_RefNannyDeclarations
12058   __Pyx_RefNannySetupContext("__setstate_cython__ (wrapper)", 0);
12059   __pyx_r = __pyx_pf___pyx_MemviewEnum_2__setstate_cython__(((struct __pyx_MemviewEnum_obj *)__pyx_v_self), ((PyObject *)__pyx_v___pyx_state));
12060 
12061   /* function exit code */
12062   __Pyx_RefNannyFinishContext();
12063   return __pyx_r;
12064 }
12065 
__pyx_pf___pyx_MemviewEnum_2__setstate_cython__(struct __pyx_MemviewEnum_obj * __pyx_v_self,PyObject * __pyx_v___pyx_state)12066 static PyObject *__pyx_pf___pyx_MemviewEnum_2__setstate_cython__(struct __pyx_MemviewEnum_obj *__pyx_v_self, PyObject *__pyx_v___pyx_state) {
12067   PyObject *__pyx_r = NULL;
12068   __Pyx_RefNannyDeclarations
12069   PyObject *__pyx_t_1 = NULL;
12070   int __pyx_lineno = 0;
12071   const char *__pyx_filename = NULL;
12072   int __pyx_clineno = 0;
12073   __Pyx_RefNannySetupContext("__setstate_cython__", 0);
12074 
12075   /* "(tree fragment)":17
12076  *         return __pyx_unpickle_Enum, (type(self), 0xb068931, state)
12077  * def __setstate_cython__(self, __pyx_state):
12078  *     __pyx_unpickle_Enum__set_state(self, __pyx_state)             # <<<<<<<<<<<<<<
12079  */
12080   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)
12081   __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)
12082   __Pyx_GOTREF(__pyx_t_1);
12083   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
12084 
12085   /* "(tree fragment)":16
12086  *     else:
12087  *         return __pyx_unpickle_Enum, (type(self), 0xb068931, state)
12088  * def __setstate_cython__(self, __pyx_state):             # <<<<<<<<<<<<<<
12089  *     __pyx_unpickle_Enum__set_state(self, __pyx_state)
12090  */
12091 
12092   /* function exit code */
12093   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
12094   goto __pyx_L0;
12095   __pyx_L1_error:;
12096   __Pyx_XDECREF(__pyx_t_1);
12097   __Pyx_AddTraceback("View.MemoryView.Enum.__setstate_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename);
12098   __pyx_r = NULL;
12099   __pyx_L0:;
12100   __Pyx_XGIVEREF(__pyx_r);
12101   __Pyx_RefNannyFinishContext();
12102   return __pyx_r;
12103 }
12104 
12105 /* "View.MemoryView":298
12106  *
12107  * @cname('__pyx_align_pointer')
12108  * cdef void *align_pointer(void *memory, size_t alignment) nogil:             # <<<<<<<<<<<<<<
12109  *     "Align pointer memory on a given boundary"
12110  *     cdef Py_intptr_t aligned_p = <Py_intptr_t> memory
12111  */
12112 
__pyx_align_pointer(void * __pyx_v_memory,size_t __pyx_v_alignment)12113 static void *__pyx_align_pointer(void *__pyx_v_memory, size_t __pyx_v_alignment) {
12114   Py_intptr_t __pyx_v_aligned_p;
12115   size_t __pyx_v_offset;
12116   void *__pyx_r;
12117   int __pyx_t_1;
12118 
12119   /* "View.MemoryView":300
12120  * cdef void *align_pointer(void *memory, size_t alignment) nogil:
12121  *     "Align pointer memory on a given boundary"
12122  *     cdef Py_intptr_t aligned_p = <Py_intptr_t> memory             # <<<<<<<<<<<<<<
12123  *     cdef size_t offset
12124  *
12125  */
12126   __pyx_v_aligned_p = ((Py_intptr_t)__pyx_v_memory);
12127 
12128   /* "View.MemoryView":304
12129  *
12130  *     with cython.cdivision(True):
12131  *         offset = aligned_p % alignment             # <<<<<<<<<<<<<<
12132  *
12133  *     if offset > 0:
12134  */
12135   __pyx_v_offset = (__pyx_v_aligned_p % __pyx_v_alignment);
12136 
12137   /* "View.MemoryView":306
12138  *         offset = aligned_p % alignment
12139  *
12140  *     if offset > 0:             # <<<<<<<<<<<<<<
12141  *         aligned_p += alignment - offset
12142  *
12143  */
12144   __pyx_t_1 = ((__pyx_v_offset > 0) != 0);
12145   if (__pyx_t_1) {
12146 
12147     /* "View.MemoryView":307
12148  *
12149  *     if offset > 0:
12150  *         aligned_p += alignment - offset             # <<<<<<<<<<<<<<
12151  *
12152  *     return <void *> aligned_p
12153  */
12154     __pyx_v_aligned_p = (__pyx_v_aligned_p + (__pyx_v_alignment - __pyx_v_offset));
12155 
12156     /* "View.MemoryView":306
12157  *         offset = aligned_p % alignment
12158  *
12159  *     if offset > 0:             # <<<<<<<<<<<<<<
12160  *         aligned_p += alignment - offset
12161  *
12162  */
12163   }
12164 
12165   /* "View.MemoryView":309
12166  *         aligned_p += alignment - offset
12167  *
12168  *     return <void *> aligned_p             # <<<<<<<<<<<<<<
12169  *
12170  *
12171  */
12172   __pyx_r = ((void *)__pyx_v_aligned_p);
12173   goto __pyx_L0;
12174 
12175   /* "View.MemoryView":298
12176  *
12177  * @cname('__pyx_align_pointer')
12178  * cdef void *align_pointer(void *memory, size_t alignment) nogil:             # <<<<<<<<<<<<<<
12179  *     "Align pointer memory on a given boundary"
12180  *     cdef Py_intptr_t aligned_p = <Py_intptr_t> memory
12181  */
12182 
12183   /* function exit code */
12184   __pyx_L0:;
12185   return __pyx_r;
12186 }
12187 
12188 /* "View.MemoryView":345
12189  *     cdef __Pyx_TypeInfo *typeinfo
12190  *
12191  *     def __cinit__(memoryview self, object obj, int flags, bint dtype_is_object=False):             # <<<<<<<<<<<<<<
12192  *         self.obj = obj
12193  *         self.flags = flags
12194  */
12195 
12196 /* Python wrapper */
12197 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)12198 static int __pyx_memoryview___cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
12199   PyObject *__pyx_v_obj = 0;
12200   int __pyx_v_flags;
12201   int __pyx_v_dtype_is_object;
12202   int __pyx_lineno = 0;
12203   const char *__pyx_filename = NULL;
12204   int __pyx_clineno = 0;
12205   int __pyx_r;
12206   __Pyx_RefNannyDeclarations
12207   __Pyx_RefNannySetupContext("__cinit__ (wrapper)", 0);
12208   {
12209     static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_obj,&__pyx_n_s_flags,&__pyx_n_s_dtype_is_object,0};
12210     PyObject* values[3] = {0,0,0};
12211     if (unlikely(__pyx_kwds)) {
12212       Py_ssize_t kw_args;
12213       const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
12214       switch (pos_args) {
12215         case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
12216         CYTHON_FALLTHROUGH;
12217         case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
12218         CYTHON_FALLTHROUGH;
12219         case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
12220         CYTHON_FALLTHROUGH;
12221         case  0: break;
12222         default: goto __pyx_L5_argtuple_error;
12223       }
12224       kw_args = PyDict_Size(__pyx_kwds);
12225       switch (pos_args) {
12226         case  0:
12227         if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_obj)) != 0)) kw_args--;
12228         else goto __pyx_L5_argtuple_error;
12229         CYTHON_FALLTHROUGH;
12230         case  1:
12231         if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_flags)) != 0)) kw_args--;
12232         else {
12233           __Pyx_RaiseArgtupleInvalid("__cinit__", 0, 2, 3, 1); __PYX_ERR(2, 345, __pyx_L3_error)
12234         }
12235         CYTHON_FALLTHROUGH;
12236         case  2:
12237         if (kw_args > 0) {
12238           PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_dtype_is_object);
12239           if (value) { values[2] = value; kw_args--; }
12240         }
12241       }
12242       if (unlikely(kw_args > 0)) {
12243         if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__cinit__") < 0)) __PYX_ERR(2, 345, __pyx_L3_error)
12244       }
12245     } else {
12246       switch (PyTuple_GET_SIZE(__pyx_args)) {
12247         case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
12248         CYTHON_FALLTHROUGH;
12249         case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
12250         values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
12251         break;
12252         default: goto __pyx_L5_argtuple_error;
12253       }
12254     }
12255     __pyx_v_obj = values[0];
12256     __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)
12257     if (values[2]) {
12258       __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)
12259     } else {
12260       __pyx_v_dtype_is_object = ((int)0);
12261     }
12262   }
12263   goto __pyx_L4_argument_unpacking_done;
12264   __pyx_L5_argtuple_error:;
12265   __Pyx_RaiseArgtupleInvalid("__cinit__", 0, 2, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(2, 345, __pyx_L3_error)
12266   __pyx_L3_error:;
12267   __Pyx_AddTraceback("View.MemoryView.memoryview.__cinit__", __pyx_clineno, __pyx_lineno, __pyx_filename);
12268   __Pyx_RefNannyFinishContext();
12269   return -1;
12270   __pyx_L4_argument_unpacking_done:;
12271   __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);
12272 
12273   /* function exit code */
12274   __Pyx_RefNannyFinishContext();
12275   return __pyx_r;
12276 }
12277 
__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)12278 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) {
12279   int __pyx_r;
12280   __Pyx_RefNannyDeclarations
12281   int __pyx_t_1;
12282   int __pyx_t_2;
12283   int __pyx_t_3;
12284   int __pyx_t_4;
12285   int __pyx_lineno = 0;
12286   const char *__pyx_filename = NULL;
12287   int __pyx_clineno = 0;
12288   __Pyx_RefNannySetupContext("__cinit__", 0);
12289 
12290   /* "View.MemoryView":346
12291  *
12292  *     def __cinit__(memoryview self, object obj, int flags, bint dtype_is_object=False):
12293  *         self.obj = obj             # <<<<<<<<<<<<<<
12294  *         self.flags = flags
12295  *         if type(self) is memoryview or obj is not None:
12296  */
12297   __Pyx_INCREF(__pyx_v_obj);
12298   __Pyx_GIVEREF(__pyx_v_obj);
12299   __Pyx_GOTREF(__pyx_v_self->obj);
12300   __Pyx_DECREF(__pyx_v_self->obj);
12301   __pyx_v_self->obj = __pyx_v_obj;
12302 
12303   /* "View.MemoryView":347
12304  *     def __cinit__(memoryview self, object obj, int flags, bint dtype_is_object=False):
12305  *         self.obj = obj
12306  *         self.flags = flags             # <<<<<<<<<<<<<<
12307  *         if type(self) is memoryview or obj is not None:
12308  *             __Pyx_GetBuffer(obj, &self.view, flags)
12309  */
12310   __pyx_v_self->flags = __pyx_v_flags;
12311 
12312   /* "View.MemoryView":348
12313  *         self.obj = obj
12314  *         self.flags = flags
12315  *         if type(self) is memoryview or obj is not None:             # <<<<<<<<<<<<<<
12316  *             __Pyx_GetBuffer(obj, &self.view, flags)
12317  *             if <PyObject *> self.view.obj == NULL:
12318  */
12319   __pyx_t_2 = (((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))) == ((PyObject *)__pyx_memoryview_type));
12320   __pyx_t_3 = (__pyx_t_2 != 0);
12321   if (!__pyx_t_3) {
12322   } else {
12323     __pyx_t_1 = __pyx_t_3;
12324     goto __pyx_L4_bool_binop_done;
12325   }
12326   __pyx_t_3 = (__pyx_v_obj != Py_None);
12327   __pyx_t_2 = (__pyx_t_3 != 0);
12328   __pyx_t_1 = __pyx_t_2;
12329   __pyx_L4_bool_binop_done:;
12330   if (__pyx_t_1) {
12331 
12332     /* "View.MemoryView":349
12333  *         self.flags = flags
12334  *         if type(self) is memoryview or obj is not None:
12335  *             __Pyx_GetBuffer(obj, &self.view, flags)             # <<<<<<<<<<<<<<
12336  *             if <PyObject *> self.view.obj == NULL:
12337  *                 (<__pyx_buffer *> &self.view).obj = Py_None
12338  */
12339     __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)
12340 
12341     /* "View.MemoryView":350
12342  *         if type(self) is memoryview or obj is not None:
12343  *             __Pyx_GetBuffer(obj, &self.view, flags)
12344  *             if <PyObject *> self.view.obj == NULL:             # <<<<<<<<<<<<<<
12345  *                 (<__pyx_buffer *> &self.view).obj = Py_None
12346  *                 Py_INCREF(Py_None)
12347  */
12348     __pyx_t_1 = ((((PyObject *)__pyx_v_self->view.obj) == NULL) != 0);
12349     if (__pyx_t_1) {
12350 
12351       /* "View.MemoryView":351
12352  *             __Pyx_GetBuffer(obj, &self.view, flags)
12353  *             if <PyObject *> self.view.obj == NULL:
12354  *                 (<__pyx_buffer *> &self.view).obj = Py_None             # <<<<<<<<<<<<<<
12355  *                 Py_INCREF(Py_None)
12356  *
12357  */
12358       ((Py_buffer *)(&__pyx_v_self->view))->obj = Py_None;
12359 
12360       /* "View.MemoryView":352
12361  *             if <PyObject *> self.view.obj == NULL:
12362  *                 (<__pyx_buffer *> &self.view).obj = Py_None
12363  *                 Py_INCREF(Py_None)             # <<<<<<<<<<<<<<
12364  *
12365  *         global __pyx_memoryview_thread_locks_used
12366  */
12367       Py_INCREF(Py_None);
12368 
12369       /* "View.MemoryView":350
12370  *         if type(self) is memoryview or obj is not None:
12371  *             __Pyx_GetBuffer(obj, &self.view, flags)
12372  *             if <PyObject *> self.view.obj == NULL:             # <<<<<<<<<<<<<<
12373  *                 (<__pyx_buffer *> &self.view).obj = Py_None
12374  *                 Py_INCREF(Py_None)
12375  */
12376     }
12377 
12378     /* "View.MemoryView":348
12379  *         self.obj = obj
12380  *         self.flags = flags
12381  *         if type(self) is memoryview or obj is not None:             # <<<<<<<<<<<<<<
12382  *             __Pyx_GetBuffer(obj, &self.view, flags)
12383  *             if <PyObject *> self.view.obj == NULL:
12384  */
12385   }
12386 
12387   /* "View.MemoryView":355
12388  *
12389  *         global __pyx_memoryview_thread_locks_used
12390  *         if __pyx_memoryview_thread_locks_used < THREAD_LOCKS_PREALLOCATED:             # <<<<<<<<<<<<<<
12391  *             self.lock = __pyx_memoryview_thread_locks[__pyx_memoryview_thread_locks_used]
12392  *             __pyx_memoryview_thread_locks_used += 1
12393  */
12394   __pyx_t_1 = ((__pyx_memoryview_thread_locks_used < 8) != 0);
12395   if (__pyx_t_1) {
12396 
12397     /* "View.MemoryView":356
12398  *         global __pyx_memoryview_thread_locks_used
12399  *         if __pyx_memoryview_thread_locks_used < THREAD_LOCKS_PREALLOCATED:
12400  *             self.lock = __pyx_memoryview_thread_locks[__pyx_memoryview_thread_locks_used]             # <<<<<<<<<<<<<<
12401  *             __pyx_memoryview_thread_locks_used += 1
12402  *         if self.lock is NULL:
12403  */
12404     __pyx_v_self->lock = (__pyx_memoryview_thread_locks[__pyx_memoryview_thread_locks_used]);
12405 
12406     /* "View.MemoryView":357
12407  *         if __pyx_memoryview_thread_locks_used < THREAD_LOCKS_PREALLOCATED:
12408  *             self.lock = __pyx_memoryview_thread_locks[__pyx_memoryview_thread_locks_used]
12409  *             __pyx_memoryview_thread_locks_used += 1             # <<<<<<<<<<<<<<
12410  *         if self.lock is NULL:
12411  *             self.lock = PyThread_allocate_lock()
12412  */
12413     __pyx_memoryview_thread_locks_used = (__pyx_memoryview_thread_locks_used + 1);
12414 
12415     /* "View.MemoryView":355
12416  *
12417  *         global __pyx_memoryview_thread_locks_used
12418  *         if __pyx_memoryview_thread_locks_used < THREAD_LOCKS_PREALLOCATED:             # <<<<<<<<<<<<<<
12419  *             self.lock = __pyx_memoryview_thread_locks[__pyx_memoryview_thread_locks_used]
12420  *             __pyx_memoryview_thread_locks_used += 1
12421  */
12422   }
12423 
12424   /* "View.MemoryView":358
12425  *             self.lock = __pyx_memoryview_thread_locks[__pyx_memoryview_thread_locks_used]
12426  *             __pyx_memoryview_thread_locks_used += 1
12427  *         if self.lock is NULL:             # <<<<<<<<<<<<<<
12428  *             self.lock = PyThread_allocate_lock()
12429  *             if self.lock is NULL:
12430  */
12431   __pyx_t_1 = ((__pyx_v_self->lock == NULL) != 0);
12432   if (__pyx_t_1) {
12433 
12434     /* "View.MemoryView":359
12435  *             __pyx_memoryview_thread_locks_used += 1
12436  *         if self.lock is NULL:
12437  *             self.lock = PyThread_allocate_lock()             # <<<<<<<<<<<<<<
12438  *             if self.lock is NULL:
12439  *                 raise MemoryError
12440  */
12441     __pyx_v_self->lock = PyThread_allocate_lock();
12442 
12443     /* "View.MemoryView":360
12444  *         if self.lock is NULL:
12445  *             self.lock = PyThread_allocate_lock()
12446  *             if self.lock is NULL:             # <<<<<<<<<<<<<<
12447  *                 raise MemoryError
12448  *
12449  */
12450     __pyx_t_1 = ((__pyx_v_self->lock == NULL) != 0);
12451     if (unlikely(__pyx_t_1)) {
12452 
12453       /* "View.MemoryView":361
12454  *             self.lock = PyThread_allocate_lock()
12455  *             if self.lock is NULL:
12456  *                 raise MemoryError             # <<<<<<<<<<<<<<
12457  *
12458  *         if flags & PyBUF_FORMAT:
12459  */
12460       PyErr_NoMemory(); __PYX_ERR(2, 361, __pyx_L1_error)
12461 
12462       /* "View.MemoryView":360
12463  *         if self.lock is NULL:
12464  *             self.lock = PyThread_allocate_lock()
12465  *             if self.lock is NULL:             # <<<<<<<<<<<<<<
12466  *                 raise MemoryError
12467  *
12468  */
12469     }
12470 
12471     /* "View.MemoryView":358
12472  *             self.lock = __pyx_memoryview_thread_locks[__pyx_memoryview_thread_locks_used]
12473  *             __pyx_memoryview_thread_locks_used += 1
12474  *         if self.lock is NULL:             # <<<<<<<<<<<<<<
12475  *             self.lock = PyThread_allocate_lock()
12476  *             if self.lock is NULL:
12477  */
12478   }
12479 
12480   /* "View.MemoryView":363
12481  *                 raise MemoryError
12482  *
12483  *         if flags & PyBUF_FORMAT:             # <<<<<<<<<<<<<<
12484  *             self.dtype_is_object = (self.view.format[0] == b'O' and self.view.format[1] == b'\0')
12485  *         else:
12486  */
12487   __pyx_t_1 = ((__pyx_v_flags & PyBUF_FORMAT) != 0);
12488   if (__pyx_t_1) {
12489 
12490     /* "View.MemoryView":364
12491  *
12492  *         if flags & PyBUF_FORMAT:
12493  *             self.dtype_is_object = (self.view.format[0] == b'O' and self.view.format[1] == b'\0')             # <<<<<<<<<<<<<<
12494  *         else:
12495  *             self.dtype_is_object = dtype_is_object
12496  */
12497     __pyx_t_2 = (((__pyx_v_self->view.format[0]) == 'O') != 0);
12498     if (__pyx_t_2) {
12499     } else {
12500       __pyx_t_1 = __pyx_t_2;
12501       goto __pyx_L11_bool_binop_done;
12502     }
12503     __pyx_t_2 = (((__pyx_v_self->view.format[1]) == '\x00') != 0);
12504     __pyx_t_1 = __pyx_t_2;
12505     __pyx_L11_bool_binop_done:;
12506     __pyx_v_self->dtype_is_object = __pyx_t_1;
12507 
12508     /* "View.MemoryView":363
12509  *                 raise MemoryError
12510  *
12511  *         if flags & PyBUF_FORMAT:             # <<<<<<<<<<<<<<
12512  *             self.dtype_is_object = (self.view.format[0] == b'O' and self.view.format[1] == b'\0')
12513  *         else:
12514  */
12515     goto __pyx_L10;
12516   }
12517 
12518   /* "View.MemoryView":366
12519  *             self.dtype_is_object = (self.view.format[0] == b'O' and self.view.format[1] == b'\0')
12520  *         else:
12521  *             self.dtype_is_object = dtype_is_object             # <<<<<<<<<<<<<<
12522  *
12523  *         self.acquisition_count_aligned_p = <__pyx_atomic_int *> align_pointer(
12524  */
12525   /*else*/ {
12526     __pyx_v_self->dtype_is_object = __pyx_v_dtype_is_object;
12527   }
12528   __pyx_L10:;
12529 
12530   /* "View.MemoryView":368
12531  *             self.dtype_is_object = dtype_is_object
12532  *
12533  *         self.acquisition_count_aligned_p = <__pyx_atomic_int *> align_pointer(             # <<<<<<<<<<<<<<
12534  *                   <void *> &self.acquisition_count[0], sizeof(__pyx_atomic_int))
12535  *         self.typeinfo = NULL
12536  */
12537   __pyx_v_self->acquisition_count_aligned_p = ((__pyx_atomic_int *)__pyx_align_pointer(((void *)(&(__pyx_v_self->acquisition_count[0]))), (sizeof(__pyx_atomic_int))));
12538 
12539   /* "View.MemoryView":370
12540  *         self.acquisition_count_aligned_p = <__pyx_atomic_int *> align_pointer(
12541  *                   <void *> &self.acquisition_count[0], sizeof(__pyx_atomic_int))
12542  *         self.typeinfo = NULL             # <<<<<<<<<<<<<<
12543  *
12544  *     def __dealloc__(memoryview self):
12545  */
12546   __pyx_v_self->typeinfo = NULL;
12547 
12548   /* "View.MemoryView":345
12549  *     cdef __Pyx_TypeInfo *typeinfo
12550  *
12551  *     def __cinit__(memoryview self, object obj, int flags, bint dtype_is_object=False):             # <<<<<<<<<<<<<<
12552  *         self.obj = obj
12553  *         self.flags = flags
12554  */
12555 
12556   /* function exit code */
12557   __pyx_r = 0;
12558   goto __pyx_L0;
12559   __pyx_L1_error:;
12560   __Pyx_AddTraceback("View.MemoryView.memoryview.__cinit__", __pyx_clineno, __pyx_lineno, __pyx_filename);
12561   __pyx_r = -1;
12562   __pyx_L0:;
12563   __Pyx_RefNannyFinishContext();
12564   return __pyx_r;
12565 }
12566 
12567 /* "View.MemoryView":372
12568  *         self.typeinfo = NULL
12569  *
12570  *     def __dealloc__(memoryview self):             # <<<<<<<<<<<<<<
12571  *         if self.obj is not None:
12572  *             __Pyx_ReleaseBuffer(&self.view)
12573  */
12574 
12575 /* Python wrapper */
12576 static void __pyx_memoryview___dealloc__(PyObject *__pyx_v_self); /*proto*/
__pyx_memoryview___dealloc__(PyObject * __pyx_v_self)12577 static void __pyx_memoryview___dealloc__(PyObject *__pyx_v_self) {
12578   __Pyx_RefNannyDeclarations
12579   __Pyx_RefNannySetupContext("__dealloc__ (wrapper)", 0);
12580   __pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_2__dealloc__(((struct __pyx_memoryview_obj *)__pyx_v_self));
12581 
12582   /* function exit code */
12583   __Pyx_RefNannyFinishContext();
12584 }
12585 
__pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_2__dealloc__(struct __pyx_memoryview_obj * __pyx_v_self)12586 static void __pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_2__dealloc__(struct __pyx_memoryview_obj *__pyx_v_self) {
12587   int __pyx_v_i;
12588   __Pyx_RefNannyDeclarations
12589   int __pyx_t_1;
12590   int __pyx_t_2;
12591   int __pyx_t_3;
12592   int __pyx_t_4;
12593   int __pyx_t_5;
12594   PyThread_type_lock __pyx_t_6;
12595   PyThread_type_lock __pyx_t_7;
12596   __Pyx_RefNannySetupContext("__dealloc__", 0);
12597 
12598   /* "View.MemoryView":373
12599  *
12600  *     def __dealloc__(memoryview self):
12601  *         if self.obj is not None:             # <<<<<<<<<<<<<<
12602  *             __Pyx_ReleaseBuffer(&self.view)
12603  *         elif (<__pyx_buffer *> &self.view).obj == Py_None:
12604  */
12605   __pyx_t_1 = (__pyx_v_self->obj != Py_None);
12606   __pyx_t_2 = (__pyx_t_1 != 0);
12607   if (__pyx_t_2) {
12608 
12609     /* "View.MemoryView":374
12610  *     def __dealloc__(memoryview self):
12611  *         if self.obj is not None:
12612  *             __Pyx_ReleaseBuffer(&self.view)             # <<<<<<<<<<<<<<
12613  *         elif (<__pyx_buffer *> &self.view).obj == Py_None:
12614  *
12615  */
12616     __Pyx_ReleaseBuffer((&__pyx_v_self->view));
12617 
12618     /* "View.MemoryView":373
12619  *
12620  *     def __dealloc__(memoryview self):
12621  *         if self.obj is not None:             # <<<<<<<<<<<<<<
12622  *             __Pyx_ReleaseBuffer(&self.view)
12623  *         elif (<__pyx_buffer *> &self.view).obj == Py_None:
12624  */
12625     goto __pyx_L3;
12626   }
12627 
12628   /* "View.MemoryView":375
12629  *         if self.obj is not None:
12630  *             __Pyx_ReleaseBuffer(&self.view)
12631  *         elif (<__pyx_buffer *> &self.view).obj == Py_None:             # <<<<<<<<<<<<<<
12632  *
12633  *             (<__pyx_buffer *> &self.view).obj = NULL
12634  */
12635   __pyx_t_2 = ((((Py_buffer *)(&__pyx_v_self->view))->obj == Py_None) != 0);
12636   if (__pyx_t_2) {
12637 
12638     /* "View.MemoryView":377
12639  *         elif (<__pyx_buffer *> &self.view).obj == Py_None:
12640  *
12641  *             (<__pyx_buffer *> &self.view).obj = NULL             # <<<<<<<<<<<<<<
12642  *             Py_DECREF(Py_None)
12643  *
12644  */
12645     ((Py_buffer *)(&__pyx_v_self->view))->obj = NULL;
12646 
12647     /* "View.MemoryView":378
12648  *
12649  *             (<__pyx_buffer *> &self.view).obj = NULL
12650  *             Py_DECREF(Py_None)             # <<<<<<<<<<<<<<
12651  *
12652  *         cdef int i
12653  */
12654     Py_DECREF(Py_None);
12655 
12656     /* "View.MemoryView":375
12657  *         if self.obj is not None:
12658  *             __Pyx_ReleaseBuffer(&self.view)
12659  *         elif (<__pyx_buffer *> &self.view).obj == Py_None:             # <<<<<<<<<<<<<<
12660  *
12661  *             (<__pyx_buffer *> &self.view).obj = NULL
12662  */
12663   }
12664   __pyx_L3:;
12665 
12666   /* "View.MemoryView":382
12667  *         cdef int i
12668  *         global __pyx_memoryview_thread_locks_used
12669  *         if self.lock != NULL:             # <<<<<<<<<<<<<<
12670  *             for i in range(__pyx_memoryview_thread_locks_used):
12671  *                 if __pyx_memoryview_thread_locks[i] is self.lock:
12672  */
12673   __pyx_t_2 = ((__pyx_v_self->lock != NULL) != 0);
12674   if (__pyx_t_2) {
12675 
12676     /* "View.MemoryView":383
12677  *         global __pyx_memoryview_thread_locks_used
12678  *         if self.lock != NULL:
12679  *             for i in range(__pyx_memoryview_thread_locks_used):             # <<<<<<<<<<<<<<
12680  *                 if __pyx_memoryview_thread_locks[i] is self.lock:
12681  *                     __pyx_memoryview_thread_locks_used -= 1
12682  */
12683     __pyx_t_3 = __pyx_memoryview_thread_locks_used;
12684     __pyx_t_4 = __pyx_t_3;
12685     for (__pyx_t_5 = 0; __pyx_t_5 < __pyx_t_4; __pyx_t_5+=1) {
12686       __pyx_v_i = __pyx_t_5;
12687 
12688       /* "View.MemoryView":384
12689  *         if self.lock != NULL:
12690  *             for i in range(__pyx_memoryview_thread_locks_used):
12691  *                 if __pyx_memoryview_thread_locks[i] is self.lock:             # <<<<<<<<<<<<<<
12692  *                     __pyx_memoryview_thread_locks_used -= 1
12693  *                     if i != __pyx_memoryview_thread_locks_used:
12694  */
12695       __pyx_t_2 = (((__pyx_memoryview_thread_locks[__pyx_v_i]) == __pyx_v_self->lock) != 0);
12696       if (__pyx_t_2) {
12697 
12698         /* "View.MemoryView":385
12699  *             for i in range(__pyx_memoryview_thread_locks_used):
12700  *                 if __pyx_memoryview_thread_locks[i] is self.lock:
12701  *                     __pyx_memoryview_thread_locks_used -= 1             # <<<<<<<<<<<<<<
12702  *                     if i != __pyx_memoryview_thread_locks_used:
12703  *                         __pyx_memoryview_thread_locks[i], __pyx_memoryview_thread_locks[__pyx_memoryview_thread_locks_used] = (
12704  */
12705         __pyx_memoryview_thread_locks_used = (__pyx_memoryview_thread_locks_used - 1);
12706 
12707         /* "View.MemoryView":386
12708  *                 if __pyx_memoryview_thread_locks[i] is self.lock:
12709  *                     __pyx_memoryview_thread_locks_used -= 1
12710  *                     if i != __pyx_memoryview_thread_locks_used:             # <<<<<<<<<<<<<<
12711  *                         __pyx_memoryview_thread_locks[i], __pyx_memoryview_thread_locks[__pyx_memoryview_thread_locks_used] = (
12712  *                             __pyx_memoryview_thread_locks[__pyx_memoryview_thread_locks_used], __pyx_memoryview_thread_locks[i])
12713  */
12714         __pyx_t_2 = ((__pyx_v_i != __pyx_memoryview_thread_locks_used) != 0);
12715         if (__pyx_t_2) {
12716 
12717           /* "View.MemoryView":388
12718  *                     if i != __pyx_memoryview_thread_locks_used:
12719  *                         __pyx_memoryview_thread_locks[i], __pyx_memoryview_thread_locks[__pyx_memoryview_thread_locks_used] = (
12720  *                             __pyx_memoryview_thread_locks[__pyx_memoryview_thread_locks_used], __pyx_memoryview_thread_locks[i])             # <<<<<<<<<<<<<<
12721  *                     break
12722  *             else:
12723  */
12724           __pyx_t_6 = (__pyx_memoryview_thread_locks[__pyx_memoryview_thread_locks_used]);
12725           __pyx_t_7 = (__pyx_memoryview_thread_locks[__pyx_v_i]);
12726 
12727           /* "View.MemoryView":387
12728  *                     __pyx_memoryview_thread_locks_used -= 1
12729  *                     if i != __pyx_memoryview_thread_locks_used:
12730  *                         __pyx_memoryview_thread_locks[i], __pyx_memoryview_thread_locks[__pyx_memoryview_thread_locks_used] = (             # <<<<<<<<<<<<<<
12731  *                             __pyx_memoryview_thread_locks[__pyx_memoryview_thread_locks_used], __pyx_memoryview_thread_locks[i])
12732  *                     break
12733  */
12734           (__pyx_memoryview_thread_locks[__pyx_v_i]) = __pyx_t_6;
12735           (__pyx_memoryview_thread_locks[__pyx_memoryview_thread_locks_used]) = __pyx_t_7;
12736 
12737           /* "View.MemoryView":386
12738  *                 if __pyx_memoryview_thread_locks[i] is self.lock:
12739  *                     __pyx_memoryview_thread_locks_used -= 1
12740  *                     if i != __pyx_memoryview_thread_locks_used:             # <<<<<<<<<<<<<<
12741  *                         __pyx_memoryview_thread_locks[i], __pyx_memoryview_thread_locks[__pyx_memoryview_thread_locks_used] = (
12742  *                             __pyx_memoryview_thread_locks[__pyx_memoryview_thread_locks_used], __pyx_memoryview_thread_locks[i])
12743  */
12744         }
12745 
12746         /* "View.MemoryView":389
12747  *                         __pyx_memoryview_thread_locks[i], __pyx_memoryview_thread_locks[__pyx_memoryview_thread_locks_used] = (
12748  *                             __pyx_memoryview_thread_locks[__pyx_memoryview_thread_locks_used], __pyx_memoryview_thread_locks[i])
12749  *                     break             # <<<<<<<<<<<<<<
12750  *             else:
12751  *                 PyThread_free_lock(self.lock)
12752  */
12753         goto __pyx_L6_break;
12754 
12755         /* "View.MemoryView":384
12756  *         if self.lock != NULL:
12757  *             for i in range(__pyx_memoryview_thread_locks_used):
12758  *                 if __pyx_memoryview_thread_locks[i] is self.lock:             # <<<<<<<<<<<<<<
12759  *                     __pyx_memoryview_thread_locks_used -= 1
12760  *                     if i != __pyx_memoryview_thread_locks_used:
12761  */
12762       }
12763     }
12764     /*else*/ {
12765 
12766       /* "View.MemoryView":391
12767  *                     break
12768  *             else:
12769  *                 PyThread_free_lock(self.lock)             # <<<<<<<<<<<<<<
12770  *
12771  *     cdef char *get_item_pointer(memoryview self, object index) except NULL:
12772  */
12773       PyThread_free_lock(__pyx_v_self->lock);
12774     }
12775     __pyx_L6_break:;
12776 
12777     /* "View.MemoryView":382
12778  *         cdef int i
12779  *         global __pyx_memoryview_thread_locks_used
12780  *         if self.lock != NULL:             # <<<<<<<<<<<<<<
12781  *             for i in range(__pyx_memoryview_thread_locks_used):
12782  *                 if __pyx_memoryview_thread_locks[i] is self.lock:
12783  */
12784   }
12785 
12786   /* "View.MemoryView":372
12787  *         self.typeinfo = NULL
12788  *
12789  *     def __dealloc__(memoryview self):             # <<<<<<<<<<<<<<
12790  *         if self.obj is not None:
12791  *             __Pyx_ReleaseBuffer(&self.view)
12792  */
12793 
12794   /* function exit code */
12795   __Pyx_RefNannyFinishContext();
12796 }
12797 
12798 /* "View.MemoryView":393
12799  *                 PyThread_free_lock(self.lock)
12800  *
12801  *     cdef char *get_item_pointer(memoryview self, object index) except NULL:             # <<<<<<<<<<<<<<
12802  *         cdef Py_ssize_t dim
12803  *         cdef char *itemp = <char *> self.view.buf
12804  */
12805 
__pyx_memoryview_get_item_pointer(struct __pyx_memoryview_obj * __pyx_v_self,PyObject * __pyx_v_index)12806 static char *__pyx_memoryview_get_item_pointer(struct __pyx_memoryview_obj *__pyx_v_self, PyObject *__pyx_v_index) {
12807   Py_ssize_t __pyx_v_dim;
12808   char *__pyx_v_itemp;
12809   PyObject *__pyx_v_idx = NULL;
12810   char *__pyx_r;
12811   __Pyx_RefNannyDeclarations
12812   Py_ssize_t __pyx_t_1;
12813   PyObject *__pyx_t_2 = NULL;
12814   Py_ssize_t __pyx_t_3;
12815   PyObject *(*__pyx_t_4)(PyObject *);
12816   PyObject *__pyx_t_5 = NULL;
12817   Py_ssize_t __pyx_t_6;
12818   char *__pyx_t_7;
12819   int __pyx_lineno = 0;
12820   const char *__pyx_filename = NULL;
12821   int __pyx_clineno = 0;
12822   __Pyx_RefNannySetupContext("get_item_pointer", 0);
12823 
12824   /* "View.MemoryView":395
12825  *     cdef char *get_item_pointer(memoryview self, object index) except NULL:
12826  *         cdef Py_ssize_t dim
12827  *         cdef char *itemp = <char *> self.view.buf             # <<<<<<<<<<<<<<
12828  *
12829  *         for dim, idx in enumerate(index):
12830  */
12831   __pyx_v_itemp = ((char *)__pyx_v_self->view.buf);
12832 
12833   /* "View.MemoryView":397
12834  *         cdef char *itemp = <char *> self.view.buf
12835  *
12836  *         for dim, idx in enumerate(index):             # <<<<<<<<<<<<<<
12837  *             itemp = pybuffer_index(&self.view, itemp, idx, dim)
12838  *
12839  */
12840   __pyx_t_1 = 0;
12841   if (likely(PyList_CheckExact(__pyx_v_index)) || PyTuple_CheckExact(__pyx_v_index)) {
12842     __pyx_t_2 = __pyx_v_index; __Pyx_INCREF(__pyx_t_2); __pyx_t_3 = 0;
12843     __pyx_t_4 = NULL;
12844   } else {
12845     __pyx_t_3 = -1; __pyx_t_2 = PyObject_GetIter(__pyx_v_index); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 397, __pyx_L1_error)
12846     __Pyx_GOTREF(__pyx_t_2);
12847     __pyx_t_4 = Py_TYPE(__pyx_t_2)->tp_iternext; if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 397, __pyx_L1_error)
12848   }
12849   for (;;) {
12850     if (likely(!__pyx_t_4)) {
12851       if (likely(PyList_CheckExact(__pyx_t_2))) {
12852         if (__pyx_t_3 >= PyList_GET_SIZE(__pyx_t_2)) break;
12853         #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
12854         __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)
12855         #else
12856         __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)
12857         __Pyx_GOTREF(__pyx_t_5);
12858         #endif
12859       } else {
12860         if (__pyx_t_3 >= PyTuple_GET_SIZE(__pyx_t_2)) break;
12861         #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
12862         __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)
12863         #else
12864         __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)
12865         __Pyx_GOTREF(__pyx_t_5);
12866         #endif
12867       }
12868     } else {
12869       __pyx_t_5 = __pyx_t_4(__pyx_t_2);
12870       if (unlikely(!__pyx_t_5)) {
12871         PyObject* exc_type = PyErr_Occurred();
12872         if (exc_type) {
12873           if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
12874           else __PYX_ERR(2, 397, __pyx_L1_error)
12875         }
12876         break;
12877       }
12878       __Pyx_GOTREF(__pyx_t_5);
12879     }
12880     __Pyx_XDECREF_SET(__pyx_v_idx, __pyx_t_5);
12881     __pyx_t_5 = 0;
12882     __pyx_v_dim = __pyx_t_1;
12883     __pyx_t_1 = (__pyx_t_1 + 1);
12884 
12885     /* "View.MemoryView":398
12886  *
12887  *         for dim, idx in enumerate(index):
12888  *             itemp = pybuffer_index(&self.view, itemp, idx, dim)             # <<<<<<<<<<<<<<
12889  *
12890  *         return itemp
12891  */
12892     __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)
12893     __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)
12894     __pyx_v_itemp = __pyx_t_7;
12895 
12896     /* "View.MemoryView":397
12897  *         cdef char *itemp = <char *> self.view.buf
12898  *
12899  *         for dim, idx in enumerate(index):             # <<<<<<<<<<<<<<
12900  *             itemp = pybuffer_index(&self.view, itemp, idx, dim)
12901  *
12902  */
12903   }
12904   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
12905 
12906   /* "View.MemoryView":400
12907  *             itemp = pybuffer_index(&self.view, itemp, idx, dim)
12908  *
12909  *         return itemp             # <<<<<<<<<<<<<<
12910  *
12911  *
12912  */
12913   __pyx_r = __pyx_v_itemp;
12914   goto __pyx_L0;
12915 
12916   /* "View.MemoryView":393
12917  *                 PyThread_free_lock(self.lock)
12918  *
12919  *     cdef char *get_item_pointer(memoryview self, object index) except NULL:             # <<<<<<<<<<<<<<
12920  *         cdef Py_ssize_t dim
12921  *         cdef char *itemp = <char *> self.view.buf
12922  */
12923 
12924   /* function exit code */
12925   __pyx_L1_error:;
12926   __Pyx_XDECREF(__pyx_t_2);
12927   __Pyx_XDECREF(__pyx_t_5);
12928   __Pyx_AddTraceback("View.MemoryView.memoryview.get_item_pointer", __pyx_clineno, __pyx_lineno, __pyx_filename);
12929   __pyx_r = NULL;
12930   __pyx_L0:;
12931   __Pyx_XDECREF(__pyx_v_idx);
12932   __Pyx_RefNannyFinishContext();
12933   return __pyx_r;
12934 }
12935 
12936 /* "View.MemoryView":403
12937  *
12938  *
12939  *     def __getitem__(memoryview self, object index):             # <<<<<<<<<<<<<<
12940  *         if index is Ellipsis:
12941  *             return self
12942  */
12943 
12944 /* Python wrapper */
12945 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)12946 static PyObject *__pyx_memoryview___getitem__(PyObject *__pyx_v_self, PyObject *__pyx_v_index) {
12947   PyObject *__pyx_r = 0;
12948   __Pyx_RefNannyDeclarations
12949   __Pyx_RefNannySetupContext("__getitem__ (wrapper)", 0);
12950   __pyx_r = __pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_4__getitem__(((struct __pyx_memoryview_obj *)__pyx_v_self), ((PyObject *)__pyx_v_index));
12951 
12952   /* function exit code */
12953   __Pyx_RefNannyFinishContext();
12954   return __pyx_r;
12955 }
12956 
__pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_4__getitem__(struct __pyx_memoryview_obj * __pyx_v_self,PyObject * __pyx_v_index)12957 static PyObject *__pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_4__getitem__(struct __pyx_memoryview_obj *__pyx_v_self, PyObject *__pyx_v_index) {
12958   PyObject *__pyx_v_have_slices = NULL;
12959   PyObject *__pyx_v_indices = NULL;
12960   char *__pyx_v_itemp;
12961   PyObject *__pyx_r = NULL;
12962   __Pyx_RefNannyDeclarations
12963   int __pyx_t_1;
12964   int __pyx_t_2;
12965   PyObject *__pyx_t_3 = NULL;
12966   PyObject *__pyx_t_4 = NULL;
12967   PyObject *__pyx_t_5 = NULL;
12968   char *__pyx_t_6;
12969   int __pyx_lineno = 0;
12970   const char *__pyx_filename = NULL;
12971   int __pyx_clineno = 0;
12972   __Pyx_RefNannySetupContext("__getitem__", 0);
12973 
12974   /* "View.MemoryView":404
12975  *
12976  *     def __getitem__(memoryview self, object index):
12977  *         if index is Ellipsis:             # <<<<<<<<<<<<<<
12978  *             return self
12979  *
12980  */
12981   __pyx_t_1 = (__pyx_v_index == __pyx_builtin_Ellipsis);
12982   __pyx_t_2 = (__pyx_t_1 != 0);
12983   if (__pyx_t_2) {
12984 
12985     /* "View.MemoryView":405
12986  *     def __getitem__(memoryview self, object index):
12987  *         if index is Ellipsis:
12988  *             return self             # <<<<<<<<<<<<<<
12989  *
12990  *         have_slices, indices = _unellipsify(index, self.view.ndim)
12991  */
12992     __Pyx_XDECREF(__pyx_r);
12993     __Pyx_INCREF(((PyObject *)__pyx_v_self));
12994     __pyx_r = ((PyObject *)__pyx_v_self);
12995     goto __pyx_L0;
12996 
12997     /* "View.MemoryView":404
12998  *
12999  *     def __getitem__(memoryview self, object index):
13000  *         if index is Ellipsis:             # <<<<<<<<<<<<<<
13001  *             return self
13002  *
13003  */
13004   }
13005 
13006   /* "View.MemoryView":407
13007  *             return self
13008  *
13009  *         have_slices, indices = _unellipsify(index, self.view.ndim)             # <<<<<<<<<<<<<<
13010  *
13011  *         cdef char *itemp
13012  */
13013   __pyx_t_3 = _unellipsify(__pyx_v_index, __pyx_v_self->view.ndim); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 407, __pyx_L1_error)
13014   __Pyx_GOTREF(__pyx_t_3);
13015   if (likely(__pyx_t_3 != Py_None)) {
13016     PyObject* sequence = __pyx_t_3;
13017     Py_ssize_t size = __Pyx_PySequence_SIZE(sequence);
13018     if (unlikely(size != 2)) {
13019       if (size > 2) __Pyx_RaiseTooManyValuesError(2);
13020       else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
13021       __PYX_ERR(2, 407, __pyx_L1_error)
13022     }
13023     #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
13024     __pyx_t_4 = PyTuple_GET_ITEM(sequence, 0);
13025     __pyx_t_5 = PyTuple_GET_ITEM(sequence, 1);
13026     __Pyx_INCREF(__pyx_t_4);
13027     __Pyx_INCREF(__pyx_t_5);
13028     #else
13029     __pyx_t_4 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 407, __pyx_L1_error)
13030     __Pyx_GOTREF(__pyx_t_4);
13031     __pyx_t_5 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_5)) __PYX_ERR(2, 407, __pyx_L1_error)
13032     __Pyx_GOTREF(__pyx_t_5);
13033     #endif
13034     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
13035   } else {
13036     __Pyx_RaiseNoneNotIterableError(); __PYX_ERR(2, 407, __pyx_L1_error)
13037   }
13038   __pyx_v_have_slices = __pyx_t_4;
13039   __pyx_t_4 = 0;
13040   __pyx_v_indices = __pyx_t_5;
13041   __pyx_t_5 = 0;
13042 
13043   /* "View.MemoryView":410
13044  *
13045  *         cdef char *itemp
13046  *         if have_slices:             # <<<<<<<<<<<<<<
13047  *             return memview_slice(self, indices)
13048  *         else:
13049  */
13050   __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_v_have_slices); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(2, 410, __pyx_L1_error)
13051   if (__pyx_t_2) {
13052 
13053     /* "View.MemoryView":411
13054  *         cdef char *itemp
13055  *         if have_slices:
13056  *             return memview_slice(self, indices)             # <<<<<<<<<<<<<<
13057  *         else:
13058  *             itemp = self.get_item_pointer(indices)
13059  */
13060     __Pyx_XDECREF(__pyx_r);
13061     __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)
13062     __Pyx_GOTREF(__pyx_t_3);
13063     __pyx_r = __pyx_t_3;
13064     __pyx_t_3 = 0;
13065     goto __pyx_L0;
13066 
13067     /* "View.MemoryView":410
13068  *
13069  *         cdef char *itemp
13070  *         if have_slices:             # <<<<<<<<<<<<<<
13071  *             return memview_slice(self, indices)
13072  *         else:
13073  */
13074   }
13075 
13076   /* "View.MemoryView":413
13077  *             return memview_slice(self, indices)
13078  *         else:
13079  *             itemp = self.get_item_pointer(indices)             # <<<<<<<<<<<<<<
13080  *             return self.convert_item_to_object(itemp)
13081  *
13082  */
13083   /*else*/ {
13084     __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)
13085     __pyx_v_itemp = __pyx_t_6;
13086 
13087     /* "View.MemoryView":414
13088  *         else:
13089  *             itemp = self.get_item_pointer(indices)
13090  *             return self.convert_item_to_object(itemp)             # <<<<<<<<<<<<<<
13091  *
13092  *     def __setitem__(memoryview self, object index, object value):
13093  */
13094     __Pyx_XDECREF(__pyx_r);
13095     __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)
13096     __Pyx_GOTREF(__pyx_t_3);
13097     __pyx_r = __pyx_t_3;
13098     __pyx_t_3 = 0;
13099     goto __pyx_L0;
13100   }
13101 
13102   /* "View.MemoryView":403
13103  *
13104  *
13105  *     def __getitem__(memoryview self, object index):             # <<<<<<<<<<<<<<
13106  *         if index is Ellipsis:
13107  *             return self
13108  */
13109 
13110   /* function exit code */
13111   __pyx_L1_error:;
13112   __Pyx_XDECREF(__pyx_t_3);
13113   __Pyx_XDECREF(__pyx_t_4);
13114   __Pyx_XDECREF(__pyx_t_5);
13115   __Pyx_AddTraceback("View.MemoryView.memoryview.__getitem__", __pyx_clineno, __pyx_lineno, __pyx_filename);
13116   __pyx_r = NULL;
13117   __pyx_L0:;
13118   __Pyx_XDECREF(__pyx_v_have_slices);
13119   __Pyx_XDECREF(__pyx_v_indices);
13120   __Pyx_XGIVEREF(__pyx_r);
13121   __Pyx_RefNannyFinishContext();
13122   return __pyx_r;
13123 }
13124 
13125 /* "View.MemoryView":416
13126  *             return self.convert_item_to_object(itemp)
13127  *
13128  *     def __setitem__(memoryview self, object index, object value):             # <<<<<<<<<<<<<<
13129  *         if self.view.readonly:
13130  *             raise TypeError("Cannot assign to read-only memoryview")
13131  */
13132 
13133 /* Python wrapper */
13134 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)13135 static int __pyx_memoryview___setitem__(PyObject *__pyx_v_self, PyObject *__pyx_v_index, PyObject *__pyx_v_value) {
13136   int __pyx_r;
13137   __Pyx_RefNannyDeclarations
13138   __Pyx_RefNannySetupContext("__setitem__ (wrapper)", 0);
13139   __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));
13140 
13141   /* function exit code */
13142   __Pyx_RefNannyFinishContext();
13143   return __pyx_r;
13144 }
13145 
__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)13146 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) {
13147   PyObject *__pyx_v_have_slices = NULL;
13148   PyObject *__pyx_v_obj = NULL;
13149   int __pyx_r;
13150   __Pyx_RefNannyDeclarations
13151   int __pyx_t_1;
13152   PyObject *__pyx_t_2 = NULL;
13153   PyObject *__pyx_t_3 = NULL;
13154   PyObject *__pyx_t_4 = NULL;
13155   int __pyx_lineno = 0;
13156   const char *__pyx_filename = NULL;
13157   int __pyx_clineno = 0;
13158   __Pyx_RefNannySetupContext("__setitem__", 0);
13159   __Pyx_INCREF(__pyx_v_index);
13160 
13161   /* "View.MemoryView":417
13162  *
13163  *     def __setitem__(memoryview self, object index, object value):
13164  *         if self.view.readonly:             # <<<<<<<<<<<<<<
13165  *             raise TypeError("Cannot assign to read-only memoryview")
13166  *
13167  */
13168   __pyx_t_1 = (__pyx_v_self->view.readonly != 0);
13169   if (unlikely(__pyx_t_1)) {
13170 
13171     /* "View.MemoryView":418
13172  *     def __setitem__(memoryview self, object index, object value):
13173  *         if self.view.readonly:
13174  *             raise TypeError("Cannot assign to read-only memoryview")             # <<<<<<<<<<<<<<
13175  *
13176  *         have_slices, index = _unellipsify(index, self.view.ndim)
13177  */
13178     __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__10, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 418, __pyx_L1_error)
13179     __Pyx_GOTREF(__pyx_t_2);
13180     __Pyx_Raise(__pyx_t_2, 0, 0, 0);
13181     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
13182     __PYX_ERR(2, 418, __pyx_L1_error)
13183 
13184     /* "View.MemoryView":417
13185  *
13186  *     def __setitem__(memoryview self, object index, object value):
13187  *         if self.view.readonly:             # <<<<<<<<<<<<<<
13188  *             raise TypeError("Cannot assign to read-only memoryview")
13189  *
13190  */
13191   }
13192 
13193   /* "View.MemoryView":420
13194  *             raise TypeError("Cannot assign to read-only memoryview")
13195  *
13196  *         have_slices, index = _unellipsify(index, self.view.ndim)             # <<<<<<<<<<<<<<
13197  *
13198  *         if have_slices:
13199  */
13200   __pyx_t_2 = _unellipsify(__pyx_v_index, __pyx_v_self->view.ndim); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 420, __pyx_L1_error)
13201   __Pyx_GOTREF(__pyx_t_2);
13202   if (likely(__pyx_t_2 != Py_None)) {
13203     PyObject* sequence = __pyx_t_2;
13204     Py_ssize_t size = __Pyx_PySequence_SIZE(sequence);
13205     if (unlikely(size != 2)) {
13206       if (size > 2) __Pyx_RaiseTooManyValuesError(2);
13207       else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
13208       __PYX_ERR(2, 420, __pyx_L1_error)
13209     }
13210     #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
13211     __pyx_t_3 = PyTuple_GET_ITEM(sequence, 0);
13212     __pyx_t_4 = PyTuple_GET_ITEM(sequence, 1);
13213     __Pyx_INCREF(__pyx_t_3);
13214     __Pyx_INCREF(__pyx_t_4);
13215     #else
13216     __pyx_t_3 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 420, __pyx_L1_error)
13217     __Pyx_GOTREF(__pyx_t_3);
13218     __pyx_t_4 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 420, __pyx_L1_error)
13219     __Pyx_GOTREF(__pyx_t_4);
13220     #endif
13221     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
13222   } else {
13223     __Pyx_RaiseNoneNotIterableError(); __PYX_ERR(2, 420, __pyx_L1_error)
13224   }
13225   __pyx_v_have_slices = __pyx_t_3;
13226   __pyx_t_3 = 0;
13227   __Pyx_DECREF_SET(__pyx_v_index, __pyx_t_4);
13228   __pyx_t_4 = 0;
13229 
13230   /* "View.MemoryView":422
13231  *         have_slices, index = _unellipsify(index, self.view.ndim)
13232  *
13233  *         if have_slices:             # <<<<<<<<<<<<<<
13234  *             obj = self.is_slice(value)
13235  *             if obj:
13236  */
13237   __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_have_slices); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(2, 422, __pyx_L1_error)
13238   if (__pyx_t_1) {
13239 
13240     /* "View.MemoryView":423
13241  *
13242  *         if have_slices:
13243  *             obj = self.is_slice(value)             # <<<<<<<<<<<<<<
13244  *             if obj:
13245  *                 self.setitem_slice_assignment(self[index], obj)
13246  */
13247     __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)
13248     __Pyx_GOTREF(__pyx_t_2);
13249     __pyx_v_obj = __pyx_t_2;
13250     __pyx_t_2 = 0;
13251 
13252     /* "View.MemoryView":424
13253  *         if have_slices:
13254  *             obj = self.is_slice(value)
13255  *             if obj:             # <<<<<<<<<<<<<<
13256  *                 self.setitem_slice_assignment(self[index], obj)
13257  *             else:
13258  */
13259     __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_obj); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(2, 424, __pyx_L1_error)
13260     if (__pyx_t_1) {
13261 
13262       /* "View.MemoryView":425
13263  *             obj = self.is_slice(value)
13264  *             if obj:
13265  *                 self.setitem_slice_assignment(self[index], obj)             # <<<<<<<<<<<<<<
13266  *             else:
13267  *                 self.setitem_slice_assign_scalar(self[index], value)
13268  */
13269       __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)
13270       __Pyx_GOTREF(__pyx_t_2);
13271       __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)
13272       __Pyx_GOTREF(__pyx_t_4);
13273       __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
13274       __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
13275 
13276       /* "View.MemoryView":424
13277  *         if have_slices:
13278  *             obj = self.is_slice(value)
13279  *             if obj:             # <<<<<<<<<<<<<<
13280  *                 self.setitem_slice_assignment(self[index], obj)
13281  *             else:
13282  */
13283       goto __pyx_L5;
13284     }
13285 
13286     /* "View.MemoryView":427
13287  *                 self.setitem_slice_assignment(self[index], obj)
13288  *             else:
13289  *                 self.setitem_slice_assign_scalar(self[index], value)             # <<<<<<<<<<<<<<
13290  *         else:
13291  *             self.setitem_indexed(index, value)
13292  */
13293     /*else*/ {
13294       __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)
13295       __Pyx_GOTREF(__pyx_t_4);
13296       if (!(likely(((__pyx_t_4) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_4, __pyx_memoryview_type))))) __PYX_ERR(2, 427, __pyx_L1_error)
13297       __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)
13298       __Pyx_GOTREF(__pyx_t_2);
13299       __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
13300       __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
13301     }
13302     __pyx_L5:;
13303 
13304     /* "View.MemoryView":422
13305  *         have_slices, index = _unellipsify(index, self.view.ndim)
13306  *
13307  *         if have_slices:             # <<<<<<<<<<<<<<
13308  *             obj = self.is_slice(value)
13309  *             if obj:
13310  */
13311     goto __pyx_L4;
13312   }
13313 
13314   /* "View.MemoryView":429
13315  *                 self.setitem_slice_assign_scalar(self[index], value)
13316  *         else:
13317  *             self.setitem_indexed(index, value)             # <<<<<<<<<<<<<<
13318  *
13319  *     cdef is_slice(self, obj):
13320  */
13321   /*else*/ {
13322     __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)
13323     __Pyx_GOTREF(__pyx_t_2);
13324     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
13325   }
13326   __pyx_L4:;
13327 
13328   /* "View.MemoryView":416
13329  *             return self.convert_item_to_object(itemp)
13330  *
13331  *     def __setitem__(memoryview self, object index, object value):             # <<<<<<<<<<<<<<
13332  *         if self.view.readonly:
13333  *             raise TypeError("Cannot assign to read-only memoryview")
13334  */
13335 
13336   /* function exit code */
13337   __pyx_r = 0;
13338   goto __pyx_L0;
13339   __pyx_L1_error:;
13340   __Pyx_XDECREF(__pyx_t_2);
13341   __Pyx_XDECREF(__pyx_t_3);
13342   __Pyx_XDECREF(__pyx_t_4);
13343   __Pyx_AddTraceback("View.MemoryView.memoryview.__setitem__", __pyx_clineno, __pyx_lineno, __pyx_filename);
13344   __pyx_r = -1;
13345   __pyx_L0:;
13346   __Pyx_XDECREF(__pyx_v_have_slices);
13347   __Pyx_XDECREF(__pyx_v_obj);
13348   __Pyx_XDECREF(__pyx_v_index);
13349   __Pyx_RefNannyFinishContext();
13350   return __pyx_r;
13351 }
13352 
13353 /* "View.MemoryView":431
13354  *             self.setitem_indexed(index, value)
13355  *
13356  *     cdef is_slice(self, obj):             # <<<<<<<<<<<<<<
13357  *         if not isinstance(obj, memoryview):
13358  *             try:
13359  */
13360 
__pyx_memoryview_is_slice(struct __pyx_memoryview_obj * __pyx_v_self,PyObject * __pyx_v_obj)13361 static PyObject *__pyx_memoryview_is_slice(struct __pyx_memoryview_obj *__pyx_v_self, PyObject *__pyx_v_obj) {
13362   PyObject *__pyx_r = NULL;
13363   __Pyx_RefNannyDeclarations
13364   int __pyx_t_1;
13365   int __pyx_t_2;
13366   PyObject *__pyx_t_3 = NULL;
13367   PyObject *__pyx_t_4 = NULL;
13368   PyObject *__pyx_t_5 = NULL;
13369   PyObject *__pyx_t_6 = NULL;
13370   PyObject *__pyx_t_7 = NULL;
13371   PyObject *__pyx_t_8 = NULL;
13372   int __pyx_t_9;
13373   int __pyx_lineno = 0;
13374   const char *__pyx_filename = NULL;
13375   int __pyx_clineno = 0;
13376   __Pyx_RefNannySetupContext("is_slice", 0);
13377   __Pyx_INCREF(__pyx_v_obj);
13378 
13379   /* "View.MemoryView":432
13380  *
13381  *     cdef is_slice(self, obj):
13382  *         if not isinstance(obj, memoryview):             # <<<<<<<<<<<<<<
13383  *             try:
13384  *                 obj = memoryview(obj, self.flags & ~PyBUF_WRITABLE | PyBUF_ANY_CONTIGUOUS,
13385  */
13386   __pyx_t_1 = __Pyx_TypeCheck(__pyx_v_obj, __pyx_memoryview_type);
13387   __pyx_t_2 = ((!(__pyx_t_1 != 0)) != 0);
13388   if (__pyx_t_2) {
13389 
13390     /* "View.MemoryView":433
13391  *     cdef is_slice(self, obj):
13392  *         if not isinstance(obj, memoryview):
13393  *             try:             # <<<<<<<<<<<<<<
13394  *                 obj = memoryview(obj, self.flags & ~PyBUF_WRITABLE | PyBUF_ANY_CONTIGUOUS,
13395  *                                  self.dtype_is_object)
13396  */
13397     {
13398       __Pyx_PyThreadState_declare
13399       __Pyx_PyThreadState_assign
13400       __Pyx_ExceptionSave(&__pyx_t_3, &__pyx_t_4, &__pyx_t_5);
13401       __Pyx_XGOTREF(__pyx_t_3);
13402       __Pyx_XGOTREF(__pyx_t_4);
13403       __Pyx_XGOTREF(__pyx_t_5);
13404       /*try:*/ {
13405 
13406         /* "View.MemoryView":434
13407  *         if not isinstance(obj, memoryview):
13408  *             try:
13409  *                 obj = memoryview(obj, self.flags & ~PyBUF_WRITABLE | PyBUF_ANY_CONTIGUOUS,             # <<<<<<<<<<<<<<
13410  *                                  self.dtype_is_object)
13411  *             except TypeError:
13412  */
13413         __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)
13414         __Pyx_GOTREF(__pyx_t_6);
13415 
13416         /* "View.MemoryView":435
13417  *             try:
13418  *                 obj = memoryview(obj, self.flags & ~PyBUF_WRITABLE | PyBUF_ANY_CONTIGUOUS,
13419  *                                  self.dtype_is_object)             # <<<<<<<<<<<<<<
13420  *             except TypeError:
13421  *                 return None
13422  */
13423         __pyx_t_7 = __Pyx_PyBool_FromLong(__pyx_v_self->dtype_is_object); if (unlikely(!__pyx_t_7)) __PYX_ERR(2, 435, __pyx_L4_error)
13424         __Pyx_GOTREF(__pyx_t_7);
13425 
13426         /* "View.MemoryView":434
13427  *         if not isinstance(obj, memoryview):
13428  *             try:
13429  *                 obj = memoryview(obj, self.flags & ~PyBUF_WRITABLE | PyBUF_ANY_CONTIGUOUS,             # <<<<<<<<<<<<<<
13430  *                                  self.dtype_is_object)
13431  *             except TypeError:
13432  */
13433         __pyx_t_8 = PyTuple_New(3); if (unlikely(!__pyx_t_8)) __PYX_ERR(2, 434, __pyx_L4_error)
13434         __Pyx_GOTREF(__pyx_t_8);
13435         __Pyx_INCREF(__pyx_v_obj);
13436         __Pyx_GIVEREF(__pyx_v_obj);
13437         PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_v_obj);
13438         __Pyx_GIVEREF(__pyx_t_6);
13439         PyTuple_SET_ITEM(__pyx_t_8, 1, __pyx_t_6);
13440         __Pyx_GIVEREF(__pyx_t_7);
13441         PyTuple_SET_ITEM(__pyx_t_8, 2, __pyx_t_7);
13442         __pyx_t_6 = 0;
13443         __pyx_t_7 = 0;
13444         __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)
13445         __Pyx_GOTREF(__pyx_t_7);
13446         __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
13447         __Pyx_DECREF_SET(__pyx_v_obj, __pyx_t_7);
13448         __pyx_t_7 = 0;
13449 
13450         /* "View.MemoryView":433
13451  *     cdef is_slice(self, obj):
13452  *         if not isinstance(obj, memoryview):
13453  *             try:             # <<<<<<<<<<<<<<
13454  *                 obj = memoryview(obj, self.flags & ~PyBUF_WRITABLE | PyBUF_ANY_CONTIGUOUS,
13455  *                                  self.dtype_is_object)
13456  */
13457       }
13458       __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
13459       __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
13460       __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
13461       goto __pyx_L9_try_end;
13462       __pyx_L4_error:;
13463       __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
13464       __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
13465       __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
13466 
13467       /* "View.MemoryView":436
13468  *                 obj = memoryview(obj, self.flags & ~PyBUF_WRITABLE | PyBUF_ANY_CONTIGUOUS,
13469  *                                  self.dtype_is_object)
13470  *             except TypeError:             # <<<<<<<<<<<<<<
13471  *                 return None
13472  *
13473  */
13474       __pyx_t_9 = __Pyx_PyErr_ExceptionMatches(__pyx_builtin_TypeError);
13475       if (__pyx_t_9) {
13476         __Pyx_AddTraceback("View.MemoryView.memoryview.is_slice", __pyx_clineno, __pyx_lineno, __pyx_filename);
13477         if (__Pyx_GetException(&__pyx_t_7, &__pyx_t_8, &__pyx_t_6) < 0) __PYX_ERR(2, 436, __pyx_L6_except_error)
13478         __Pyx_GOTREF(__pyx_t_7);
13479         __Pyx_GOTREF(__pyx_t_8);
13480         __Pyx_GOTREF(__pyx_t_6);
13481 
13482         /* "View.MemoryView":437
13483  *                                  self.dtype_is_object)
13484  *             except TypeError:
13485  *                 return None             # <<<<<<<<<<<<<<
13486  *
13487  *         return obj
13488  */
13489         __Pyx_XDECREF(__pyx_r);
13490         __pyx_r = Py_None; __Pyx_INCREF(Py_None);
13491         __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
13492         __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
13493         __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
13494         goto __pyx_L7_except_return;
13495       }
13496       goto __pyx_L6_except_error;
13497       __pyx_L6_except_error:;
13498 
13499       /* "View.MemoryView":433
13500  *     cdef is_slice(self, obj):
13501  *         if not isinstance(obj, memoryview):
13502  *             try:             # <<<<<<<<<<<<<<
13503  *                 obj = memoryview(obj, self.flags & ~PyBUF_WRITABLE | PyBUF_ANY_CONTIGUOUS,
13504  *                                  self.dtype_is_object)
13505  */
13506       __Pyx_XGIVEREF(__pyx_t_3);
13507       __Pyx_XGIVEREF(__pyx_t_4);
13508       __Pyx_XGIVEREF(__pyx_t_5);
13509       __Pyx_ExceptionReset(__pyx_t_3, __pyx_t_4, __pyx_t_5);
13510       goto __pyx_L1_error;
13511       __pyx_L7_except_return:;
13512       __Pyx_XGIVEREF(__pyx_t_3);
13513       __Pyx_XGIVEREF(__pyx_t_4);
13514       __Pyx_XGIVEREF(__pyx_t_5);
13515       __Pyx_ExceptionReset(__pyx_t_3, __pyx_t_4, __pyx_t_5);
13516       goto __pyx_L0;
13517       __pyx_L9_try_end:;
13518     }
13519 
13520     /* "View.MemoryView":432
13521  *
13522  *     cdef is_slice(self, obj):
13523  *         if not isinstance(obj, memoryview):             # <<<<<<<<<<<<<<
13524  *             try:
13525  *                 obj = memoryview(obj, self.flags & ~PyBUF_WRITABLE | PyBUF_ANY_CONTIGUOUS,
13526  */
13527   }
13528 
13529   /* "View.MemoryView":439
13530  *                 return None
13531  *
13532  *         return obj             # <<<<<<<<<<<<<<
13533  *
13534  *     cdef setitem_slice_assignment(self, dst, src):
13535  */
13536   __Pyx_XDECREF(__pyx_r);
13537   __Pyx_INCREF(__pyx_v_obj);
13538   __pyx_r = __pyx_v_obj;
13539   goto __pyx_L0;
13540 
13541   /* "View.MemoryView":431
13542  *             self.setitem_indexed(index, value)
13543  *
13544  *     cdef is_slice(self, obj):             # <<<<<<<<<<<<<<
13545  *         if not isinstance(obj, memoryview):
13546  *             try:
13547  */
13548 
13549   /* function exit code */
13550   __pyx_L1_error:;
13551   __Pyx_XDECREF(__pyx_t_6);
13552   __Pyx_XDECREF(__pyx_t_7);
13553   __Pyx_XDECREF(__pyx_t_8);
13554   __Pyx_AddTraceback("View.MemoryView.memoryview.is_slice", __pyx_clineno, __pyx_lineno, __pyx_filename);
13555   __pyx_r = 0;
13556   __pyx_L0:;
13557   __Pyx_XDECREF(__pyx_v_obj);
13558   __Pyx_XGIVEREF(__pyx_r);
13559   __Pyx_RefNannyFinishContext();
13560   return __pyx_r;
13561 }
13562 
13563 /* "View.MemoryView":441
13564  *         return obj
13565  *
13566  *     cdef setitem_slice_assignment(self, dst, src):             # <<<<<<<<<<<<<<
13567  *         cdef __Pyx_memviewslice dst_slice
13568  *         cdef __Pyx_memviewslice src_slice
13569  */
13570 
__pyx_memoryview_setitem_slice_assignment(struct __pyx_memoryview_obj * __pyx_v_self,PyObject * __pyx_v_dst,PyObject * __pyx_v_src)13571 static PyObject *__pyx_memoryview_setitem_slice_assignment(struct __pyx_memoryview_obj *__pyx_v_self, PyObject *__pyx_v_dst, PyObject *__pyx_v_src) {
13572   __Pyx_memviewslice __pyx_v_dst_slice;
13573   __Pyx_memviewslice __pyx_v_src_slice;
13574   PyObject *__pyx_r = NULL;
13575   __Pyx_RefNannyDeclarations
13576   __Pyx_memviewslice *__pyx_t_1;
13577   __Pyx_memviewslice *__pyx_t_2;
13578   PyObject *__pyx_t_3 = NULL;
13579   int __pyx_t_4;
13580   int __pyx_t_5;
13581   int __pyx_t_6;
13582   int __pyx_lineno = 0;
13583   const char *__pyx_filename = NULL;
13584   int __pyx_clineno = 0;
13585   __Pyx_RefNannySetupContext("setitem_slice_assignment", 0);
13586 
13587   /* "View.MemoryView":445
13588  *         cdef __Pyx_memviewslice src_slice
13589  *
13590  *         memoryview_copy_contents(get_slice_from_memview(src, &src_slice)[0],             # <<<<<<<<<<<<<<
13591  *                                  get_slice_from_memview(dst, &dst_slice)[0],
13592  *                                  src.ndim, dst.ndim, self.dtype_is_object)
13593  */
13594   if (!(likely(((__pyx_v_src) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_src, __pyx_memoryview_type))))) __PYX_ERR(2, 445, __pyx_L1_error)
13595   __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)
13596 
13597   /* "View.MemoryView":446
13598  *
13599  *         memoryview_copy_contents(get_slice_from_memview(src, &src_slice)[0],
13600  *                                  get_slice_from_memview(dst, &dst_slice)[0],             # <<<<<<<<<<<<<<
13601  *                                  src.ndim, dst.ndim, self.dtype_is_object)
13602  *
13603  */
13604   if (!(likely(((__pyx_v_dst) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_dst, __pyx_memoryview_type))))) __PYX_ERR(2, 446, __pyx_L1_error)
13605   __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)
13606 
13607   /* "View.MemoryView":447
13608  *         memoryview_copy_contents(get_slice_from_memview(src, &src_slice)[0],
13609  *                                  get_slice_from_memview(dst, &dst_slice)[0],
13610  *                                  src.ndim, dst.ndim, self.dtype_is_object)             # <<<<<<<<<<<<<<
13611  *
13612  *     cdef setitem_slice_assign_scalar(self, memoryview dst, value):
13613  */
13614   __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)
13615   __Pyx_GOTREF(__pyx_t_3);
13616   __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)
13617   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
13618   __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)
13619   __Pyx_GOTREF(__pyx_t_3);
13620   __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)
13621   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
13622 
13623   /* "View.MemoryView":445
13624  *         cdef __Pyx_memviewslice src_slice
13625  *
13626  *         memoryview_copy_contents(get_slice_from_memview(src, &src_slice)[0],             # <<<<<<<<<<<<<<
13627  *                                  get_slice_from_memview(dst, &dst_slice)[0],
13628  *                                  src.ndim, dst.ndim, self.dtype_is_object)
13629  */
13630   __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)
13631 
13632   /* "View.MemoryView":441
13633  *         return obj
13634  *
13635  *     cdef setitem_slice_assignment(self, dst, src):             # <<<<<<<<<<<<<<
13636  *         cdef __Pyx_memviewslice dst_slice
13637  *         cdef __Pyx_memviewslice src_slice
13638  */
13639 
13640   /* function exit code */
13641   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
13642   goto __pyx_L0;
13643   __pyx_L1_error:;
13644   __Pyx_XDECREF(__pyx_t_3);
13645   __Pyx_AddTraceback("View.MemoryView.memoryview.setitem_slice_assignment", __pyx_clineno, __pyx_lineno, __pyx_filename);
13646   __pyx_r = 0;
13647   __pyx_L0:;
13648   __Pyx_XGIVEREF(__pyx_r);
13649   __Pyx_RefNannyFinishContext();
13650   return __pyx_r;
13651 }
13652 
13653 /* "View.MemoryView":449
13654  *                                  src.ndim, dst.ndim, self.dtype_is_object)
13655  *
13656  *     cdef setitem_slice_assign_scalar(self, memoryview dst, value):             # <<<<<<<<<<<<<<
13657  *         cdef int array[128]
13658  *         cdef void *tmp = NULL
13659  */
13660 
__pyx_memoryview_setitem_slice_assign_scalar(struct __pyx_memoryview_obj * __pyx_v_self,struct __pyx_memoryview_obj * __pyx_v_dst,PyObject * __pyx_v_value)13661 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) {
13662   int __pyx_v_array[0x80];
13663   void *__pyx_v_tmp;
13664   void *__pyx_v_item;
13665   __Pyx_memviewslice *__pyx_v_dst_slice;
13666   __Pyx_memviewslice __pyx_v_tmp_slice;
13667   PyObject *__pyx_r = NULL;
13668   __Pyx_RefNannyDeclarations
13669   __Pyx_memviewslice *__pyx_t_1;
13670   int __pyx_t_2;
13671   PyObject *__pyx_t_3 = NULL;
13672   int __pyx_t_4;
13673   int __pyx_t_5;
13674   char const *__pyx_t_6;
13675   PyObject *__pyx_t_7 = NULL;
13676   PyObject *__pyx_t_8 = NULL;
13677   PyObject *__pyx_t_9 = NULL;
13678   PyObject *__pyx_t_10 = NULL;
13679   PyObject *__pyx_t_11 = NULL;
13680   PyObject *__pyx_t_12 = NULL;
13681   int __pyx_lineno = 0;
13682   const char *__pyx_filename = NULL;
13683   int __pyx_clineno = 0;
13684   __Pyx_RefNannySetupContext("setitem_slice_assign_scalar", 0);
13685 
13686   /* "View.MemoryView":451
13687  *     cdef setitem_slice_assign_scalar(self, memoryview dst, value):
13688  *         cdef int array[128]
13689  *         cdef void *tmp = NULL             # <<<<<<<<<<<<<<
13690  *         cdef void *item
13691  *
13692  */
13693   __pyx_v_tmp = NULL;
13694 
13695   /* "View.MemoryView":456
13696  *         cdef __Pyx_memviewslice *dst_slice
13697  *         cdef __Pyx_memviewslice tmp_slice
13698  *         dst_slice = get_slice_from_memview(dst, &tmp_slice)             # <<<<<<<<<<<<<<
13699  *
13700  *         if <size_t>self.view.itemsize > sizeof(array):
13701  */
13702   __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)
13703   __pyx_v_dst_slice = __pyx_t_1;
13704 
13705   /* "View.MemoryView":458
13706  *         dst_slice = get_slice_from_memview(dst, &tmp_slice)
13707  *
13708  *         if <size_t>self.view.itemsize > sizeof(array):             # <<<<<<<<<<<<<<
13709  *             tmp = PyMem_Malloc(self.view.itemsize)
13710  *             if tmp == NULL:
13711  */
13712   __pyx_t_2 = ((((size_t)__pyx_v_self->view.itemsize) > (sizeof(__pyx_v_array))) != 0);
13713   if (__pyx_t_2) {
13714 
13715     /* "View.MemoryView":459
13716  *
13717  *         if <size_t>self.view.itemsize > sizeof(array):
13718  *             tmp = PyMem_Malloc(self.view.itemsize)             # <<<<<<<<<<<<<<
13719  *             if tmp == NULL:
13720  *                 raise MemoryError
13721  */
13722     __pyx_v_tmp = PyMem_Malloc(__pyx_v_self->view.itemsize);
13723 
13724     /* "View.MemoryView":460
13725  *         if <size_t>self.view.itemsize > sizeof(array):
13726  *             tmp = PyMem_Malloc(self.view.itemsize)
13727  *             if tmp == NULL:             # <<<<<<<<<<<<<<
13728  *                 raise MemoryError
13729  *             item = tmp
13730  */
13731     __pyx_t_2 = ((__pyx_v_tmp == NULL) != 0);
13732     if (unlikely(__pyx_t_2)) {
13733 
13734       /* "View.MemoryView":461
13735  *             tmp = PyMem_Malloc(self.view.itemsize)
13736  *             if tmp == NULL:
13737  *                 raise MemoryError             # <<<<<<<<<<<<<<
13738  *             item = tmp
13739  *         else:
13740  */
13741       PyErr_NoMemory(); __PYX_ERR(2, 461, __pyx_L1_error)
13742 
13743       /* "View.MemoryView":460
13744  *         if <size_t>self.view.itemsize > sizeof(array):
13745  *             tmp = PyMem_Malloc(self.view.itemsize)
13746  *             if tmp == NULL:             # <<<<<<<<<<<<<<
13747  *                 raise MemoryError
13748  *             item = tmp
13749  */
13750     }
13751 
13752     /* "View.MemoryView":462
13753  *             if tmp == NULL:
13754  *                 raise MemoryError
13755  *             item = tmp             # <<<<<<<<<<<<<<
13756  *         else:
13757  *             item = <void *> array
13758  */
13759     __pyx_v_item = __pyx_v_tmp;
13760 
13761     /* "View.MemoryView":458
13762  *         dst_slice = get_slice_from_memview(dst, &tmp_slice)
13763  *
13764  *         if <size_t>self.view.itemsize > sizeof(array):             # <<<<<<<<<<<<<<
13765  *             tmp = PyMem_Malloc(self.view.itemsize)
13766  *             if tmp == NULL:
13767  */
13768     goto __pyx_L3;
13769   }
13770 
13771   /* "View.MemoryView":464
13772  *             item = tmp
13773  *         else:
13774  *             item = <void *> array             # <<<<<<<<<<<<<<
13775  *
13776  *         try:
13777  */
13778   /*else*/ {
13779     __pyx_v_item = ((void *)__pyx_v_array);
13780   }
13781   __pyx_L3:;
13782 
13783   /* "View.MemoryView":466
13784  *             item = <void *> array
13785  *
13786  *         try:             # <<<<<<<<<<<<<<
13787  *             if self.dtype_is_object:
13788  *                 (<PyObject **> item)[0] = <PyObject *> value
13789  */
13790   /*try:*/ {
13791 
13792     /* "View.MemoryView":467
13793  *
13794  *         try:
13795  *             if self.dtype_is_object:             # <<<<<<<<<<<<<<
13796  *                 (<PyObject **> item)[0] = <PyObject *> value
13797  *             else:
13798  */
13799     __pyx_t_2 = (__pyx_v_self->dtype_is_object != 0);
13800     if (__pyx_t_2) {
13801 
13802       /* "View.MemoryView":468
13803  *         try:
13804  *             if self.dtype_is_object:
13805  *                 (<PyObject **> item)[0] = <PyObject *> value             # <<<<<<<<<<<<<<
13806  *             else:
13807  *                 self.assign_item_from_object(<char *> item, value)
13808  */
13809       (((PyObject **)__pyx_v_item)[0]) = ((PyObject *)__pyx_v_value);
13810 
13811       /* "View.MemoryView":467
13812  *
13813  *         try:
13814  *             if self.dtype_is_object:             # <<<<<<<<<<<<<<
13815  *                 (<PyObject **> item)[0] = <PyObject *> value
13816  *             else:
13817  */
13818       goto __pyx_L8;
13819     }
13820 
13821     /* "View.MemoryView":470
13822  *                 (<PyObject **> item)[0] = <PyObject *> value
13823  *             else:
13824  *                 self.assign_item_from_object(<char *> item, value)             # <<<<<<<<<<<<<<
13825  *
13826  *
13827  */
13828     /*else*/ {
13829       __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)
13830       __Pyx_GOTREF(__pyx_t_3);
13831       __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
13832     }
13833     __pyx_L8:;
13834 
13835     /* "View.MemoryView":474
13836  *
13837  *
13838  *             if self.view.suboffsets != NULL:             # <<<<<<<<<<<<<<
13839  *                 assert_direct_dimensions(self.view.suboffsets, self.view.ndim)
13840  *             slice_assign_scalar(dst_slice, dst.view.ndim, self.view.itemsize,
13841  */
13842     __pyx_t_2 = ((__pyx_v_self->view.suboffsets != NULL) != 0);
13843     if (__pyx_t_2) {
13844 
13845       /* "View.MemoryView":475
13846  *
13847  *             if self.view.suboffsets != NULL:
13848  *                 assert_direct_dimensions(self.view.suboffsets, self.view.ndim)             # <<<<<<<<<<<<<<
13849  *             slice_assign_scalar(dst_slice, dst.view.ndim, self.view.itemsize,
13850  *                                 item, self.dtype_is_object)
13851  */
13852       __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)
13853       __Pyx_GOTREF(__pyx_t_3);
13854       __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
13855 
13856       /* "View.MemoryView":474
13857  *
13858  *
13859  *             if self.view.suboffsets != NULL:             # <<<<<<<<<<<<<<
13860  *                 assert_direct_dimensions(self.view.suboffsets, self.view.ndim)
13861  *             slice_assign_scalar(dst_slice, dst.view.ndim, self.view.itemsize,
13862  */
13863     }
13864 
13865     /* "View.MemoryView":476
13866  *             if self.view.suboffsets != NULL:
13867  *                 assert_direct_dimensions(self.view.suboffsets, self.view.ndim)
13868  *             slice_assign_scalar(dst_slice, dst.view.ndim, self.view.itemsize,             # <<<<<<<<<<<<<<
13869  *                                 item, self.dtype_is_object)
13870  *         finally:
13871  */
13872     __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);
13873   }
13874 
13875   /* "View.MemoryView":479
13876  *                                 item, self.dtype_is_object)
13877  *         finally:
13878  *             PyMem_Free(tmp)             # <<<<<<<<<<<<<<
13879  *
13880  *     cdef setitem_indexed(self, index, value):
13881  */
13882   /*finally:*/ {
13883     /*normal exit:*/{
13884       PyMem_Free(__pyx_v_tmp);
13885       goto __pyx_L7;
13886     }
13887     __pyx_L6_error:;
13888     /*exception exit:*/{
13889       __Pyx_PyThreadState_declare
13890       __Pyx_PyThreadState_assign
13891       __pyx_t_7 = 0; __pyx_t_8 = 0; __pyx_t_9 = 0; __pyx_t_10 = 0; __pyx_t_11 = 0; __pyx_t_12 = 0;
13892       __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
13893       if (PY_MAJOR_VERSION >= 3) __Pyx_ExceptionSwap(&__pyx_t_10, &__pyx_t_11, &__pyx_t_12);
13894       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);
13895       __Pyx_XGOTREF(__pyx_t_7);
13896       __Pyx_XGOTREF(__pyx_t_8);
13897       __Pyx_XGOTREF(__pyx_t_9);
13898       __Pyx_XGOTREF(__pyx_t_10);
13899       __Pyx_XGOTREF(__pyx_t_11);
13900       __Pyx_XGOTREF(__pyx_t_12);
13901       __pyx_t_4 = __pyx_lineno; __pyx_t_5 = __pyx_clineno; __pyx_t_6 = __pyx_filename;
13902       {
13903         PyMem_Free(__pyx_v_tmp);
13904       }
13905       if (PY_MAJOR_VERSION >= 3) {
13906         __Pyx_XGIVEREF(__pyx_t_10);
13907         __Pyx_XGIVEREF(__pyx_t_11);
13908         __Pyx_XGIVEREF(__pyx_t_12);
13909         __Pyx_ExceptionReset(__pyx_t_10, __pyx_t_11, __pyx_t_12);
13910       }
13911       __Pyx_XGIVEREF(__pyx_t_7);
13912       __Pyx_XGIVEREF(__pyx_t_8);
13913       __Pyx_XGIVEREF(__pyx_t_9);
13914       __Pyx_ErrRestore(__pyx_t_7, __pyx_t_8, __pyx_t_9);
13915       __pyx_t_7 = 0; __pyx_t_8 = 0; __pyx_t_9 = 0; __pyx_t_10 = 0; __pyx_t_11 = 0; __pyx_t_12 = 0;
13916       __pyx_lineno = __pyx_t_4; __pyx_clineno = __pyx_t_5; __pyx_filename = __pyx_t_6;
13917       goto __pyx_L1_error;
13918     }
13919     __pyx_L7:;
13920   }
13921 
13922   /* "View.MemoryView":449
13923  *                                  src.ndim, dst.ndim, self.dtype_is_object)
13924  *
13925  *     cdef setitem_slice_assign_scalar(self, memoryview dst, value):             # <<<<<<<<<<<<<<
13926  *         cdef int array[128]
13927  *         cdef void *tmp = NULL
13928  */
13929 
13930   /* function exit code */
13931   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
13932   goto __pyx_L0;
13933   __pyx_L1_error:;
13934   __Pyx_XDECREF(__pyx_t_3);
13935   __Pyx_AddTraceback("View.MemoryView.memoryview.setitem_slice_assign_scalar", __pyx_clineno, __pyx_lineno, __pyx_filename);
13936   __pyx_r = 0;
13937   __pyx_L0:;
13938   __Pyx_XGIVEREF(__pyx_r);
13939   __Pyx_RefNannyFinishContext();
13940   return __pyx_r;
13941 }
13942 
13943 /* "View.MemoryView":481
13944  *             PyMem_Free(tmp)
13945  *
13946  *     cdef setitem_indexed(self, index, value):             # <<<<<<<<<<<<<<
13947  *         cdef char *itemp = self.get_item_pointer(index)
13948  *         self.assign_item_from_object(itemp, value)
13949  */
13950 
__pyx_memoryview_setitem_indexed(struct __pyx_memoryview_obj * __pyx_v_self,PyObject * __pyx_v_index,PyObject * __pyx_v_value)13951 static PyObject *__pyx_memoryview_setitem_indexed(struct __pyx_memoryview_obj *__pyx_v_self, PyObject *__pyx_v_index, PyObject *__pyx_v_value) {
13952   char *__pyx_v_itemp;
13953   PyObject *__pyx_r = NULL;
13954   __Pyx_RefNannyDeclarations
13955   char *__pyx_t_1;
13956   PyObject *__pyx_t_2 = NULL;
13957   int __pyx_lineno = 0;
13958   const char *__pyx_filename = NULL;
13959   int __pyx_clineno = 0;
13960   __Pyx_RefNannySetupContext("setitem_indexed", 0);
13961 
13962   /* "View.MemoryView":482
13963  *
13964  *     cdef setitem_indexed(self, index, value):
13965  *         cdef char *itemp = self.get_item_pointer(index)             # <<<<<<<<<<<<<<
13966  *         self.assign_item_from_object(itemp, value)
13967  *
13968  */
13969   __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)
13970   __pyx_v_itemp = __pyx_t_1;
13971 
13972   /* "View.MemoryView":483
13973  *     cdef setitem_indexed(self, index, value):
13974  *         cdef char *itemp = self.get_item_pointer(index)
13975  *         self.assign_item_from_object(itemp, value)             # <<<<<<<<<<<<<<
13976  *
13977  *     cdef convert_item_to_object(self, char *itemp):
13978  */
13979   __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)
13980   __Pyx_GOTREF(__pyx_t_2);
13981   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
13982 
13983   /* "View.MemoryView":481
13984  *             PyMem_Free(tmp)
13985  *
13986  *     cdef setitem_indexed(self, index, value):             # <<<<<<<<<<<<<<
13987  *         cdef char *itemp = self.get_item_pointer(index)
13988  *         self.assign_item_from_object(itemp, value)
13989  */
13990 
13991   /* function exit code */
13992   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
13993   goto __pyx_L0;
13994   __pyx_L1_error:;
13995   __Pyx_XDECREF(__pyx_t_2);
13996   __Pyx_AddTraceback("View.MemoryView.memoryview.setitem_indexed", __pyx_clineno, __pyx_lineno, __pyx_filename);
13997   __pyx_r = 0;
13998   __pyx_L0:;
13999   __Pyx_XGIVEREF(__pyx_r);
14000   __Pyx_RefNannyFinishContext();
14001   return __pyx_r;
14002 }
14003 
14004 /* "View.MemoryView":485
14005  *         self.assign_item_from_object(itemp, value)
14006  *
14007  *     cdef convert_item_to_object(self, char *itemp):             # <<<<<<<<<<<<<<
14008  *         """Only used if instantiated manually by the user, or if Cython doesn't
14009  *         know how to convert the type"""
14010  */
14011 
__pyx_memoryview_convert_item_to_object(struct __pyx_memoryview_obj * __pyx_v_self,char * __pyx_v_itemp)14012 static PyObject *__pyx_memoryview_convert_item_to_object(struct __pyx_memoryview_obj *__pyx_v_self, char *__pyx_v_itemp) {
14013   PyObject *__pyx_v_struct = NULL;
14014   PyObject *__pyx_v_bytesitem = 0;
14015   PyObject *__pyx_v_result = NULL;
14016   PyObject *__pyx_r = NULL;
14017   __Pyx_RefNannyDeclarations
14018   PyObject *__pyx_t_1 = NULL;
14019   PyObject *__pyx_t_2 = NULL;
14020   PyObject *__pyx_t_3 = NULL;
14021   PyObject *__pyx_t_4 = NULL;
14022   PyObject *__pyx_t_5 = NULL;
14023   PyObject *__pyx_t_6 = NULL;
14024   PyObject *__pyx_t_7 = NULL;
14025   int __pyx_t_8;
14026   PyObject *__pyx_t_9 = NULL;
14027   size_t __pyx_t_10;
14028   int __pyx_t_11;
14029   int __pyx_lineno = 0;
14030   const char *__pyx_filename = NULL;
14031   int __pyx_clineno = 0;
14032   __Pyx_RefNannySetupContext("convert_item_to_object", 0);
14033 
14034   /* "View.MemoryView":488
14035  *         """Only used if instantiated manually by the user, or if Cython doesn't
14036  *         know how to convert the type"""
14037  *         import struct             # <<<<<<<<<<<<<<
14038  *         cdef bytes bytesitem
14039  *
14040  */
14041   __pyx_t_1 = __Pyx_Import(__pyx_n_s_struct, 0, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 488, __pyx_L1_error)
14042   __Pyx_GOTREF(__pyx_t_1);
14043   __pyx_v_struct = __pyx_t_1;
14044   __pyx_t_1 = 0;
14045 
14046   /* "View.MemoryView":491
14047  *         cdef bytes bytesitem
14048  *
14049  *         bytesitem = itemp[:self.view.itemsize]             # <<<<<<<<<<<<<<
14050  *         try:
14051  *             result = struct.unpack(self.view.format, bytesitem)
14052  */
14053   __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)
14054   __Pyx_GOTREF(__pyx_t_1);
14055   __pyx_v_bytesitem = ((PyObject*)__pyx_t_1);
14056   __pyx_t_1 = 0;
14057 
14058   /* "View.MemoryView":492
14059  *
14060  *         bytesitem = itemp[:self.view.itemsize]
14061  *         try:             # <<<<<<<<<<<<<<
14062  *             result = struct.unpack(self.view.format, bytesitem)
14063  *         except struct.error:
14064  */
14065   {
14066     __Pyx_PyThreadState_declare
14067     __Pyx_PyThreadState_assign
14068     __Pyx_ExceptionSave(&__pyx_t_2, &__pyx_t_3, &__pyx_t_4);
14069     __Pyx_XGOTREF(__pyx_t_2);
14070     __Pyx_XGOTREF(__pyx_t_3);
14071     __Pyx_XGOTREF(__pyx_t_4);
14072     /*try:*/ {
14073 
14074       /* "View.MemoryView":493
14075  *         bytesitem = itemp[:self.view.itemsize]
14076  *         try:
14077  *             result = struct.unpack(self.view.format, bytesitem)             # <<<<<<<<<<<<<<
14078  *         except struct.error:
14079  *             raise ValueError("Unable to convert item to object")
14080  */
14081       __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)
14082       __Pyx_GOTREF(__pyx_t_5);
14083       __pyx_t_6 = __Pyx_PyBytes_FromString(__pyx_v_self->view.format); if (unlikely(!__pyx_t_6)) __PYX_ERR(2, 493, __pyx_L3_error)
14084       __Pyx_GOTREF(__pyx_t_6);
14085       __pyx_t_7 = NULL;
14086       __pyx_t_8 = 0;
14087       if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_5))) {
14088         __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_5);
14089         if (likely(__pyx_t_7)) {
14090           PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
14091           __Pyx_INCREF(__pyx_t_7);
14092           __Pyx_INCREF(function);
14093           __Pyx_DECREF_SET(__pyx_t_5, function);
14094           __pyx_t_8 = 1;
14095         }
14096       }
14097       #if CYTHON_FAST_PYCALL
14098       if (PyFunction_Check(__pyx_t_5)) {
14099         PyObject *__pyx_temp[3] = {__pyx_t_7, __pyx_t_6, __pyx_v_bytesitem};
14100         __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)
14101         __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
14102         __Pyx_GOTREF(__pyx_t_1);
14103         __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
14104       } else
14105       #endif
14106       #if CYTHON_FAST_PYCCALL
14107       if (__Pyx_PyFastCFunction_Check(__pyx_t_5)) {
14108         PyObject *__pyx_temp[3] = {__pyx_t_7, __pyx_t_6, __pyx_v_bytesitem};
14109         __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)
14110         __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
14111         __Pyx_GOTREF(__pyx_t_1);
14112         __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
14113       } else
14114       #endif
14115       {
14116         __pyx_t_9 = PyTuple_New(2+__pyx_t_8); if (unlikely(!__pyx_t_9)) __PYX_ERR(2, 493, __pyx_L3_error)
14117         __Pyx_GOTREF(__pyx_t_9);
14118         if (__pyx_t_7) {
14119           __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_7); __pyx_t_7 = NULL;
14120         }
14121         __Pyx_GIVEREF(__pyx_t_6);
14122         PyTuple_SET_ITEM(__pyx_t_9, 0+__pyx_t_8, __pyx_t_6);
14123         __Pyx_INCREF(__pyx_v_bytesitem);
14124         __Pyx_GIVEREF(__pyx_v_bytesitem);
14125         PyTuple_SET_ITEM(__pyx_t_9, 1+__pyx_t_8, __pyx_v_bytesitem);
14126         __pyx_t_6 = 0;
14127         __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)
14128         __Pyx_GOTREF(__pyx_t_1);
14129         __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
14130       }
14131       __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
14132       __pyx_v_result = __pyx_t_1;
14133       __pyx_t_1 = 0;
14134 
14135       /* "View.MemoryView":492
14136  *
14137  *         bytesitem = itemp[:self.view.itemsize]
14138  *         try:             # <<<<<<<<<<<<<<
14139  *             result = struct.unpack(self.view.format, bytesitem)
14140  *         except struct.error:
14141  */
14142     }
14143 
14144     /* "View.MemoryView":497
14145  *             raise ValueError("Unable to convert item to object")
14146  *         else:
14147  *             if len(self.view.format) == 1:             # <<<<<<<<<<<<<<
14148  *                 return result[0]
14149  *             return result
14150  */
14151     /*else:*/ {
14152       __pyx_t_10 = strlen(__pyx_v_self->view.format);
14153       __pyx_t_11 = ((__pyx_t_10 == 1) != 0);
14154       if (__pyx_t_11) {
14155 
14156         /* "View.MemoryView":498
14157  *         else:
14158  *             if len(self.view.format) == 1:
14159  *                 return result[0]             # <<<<<<<<<<<<<<
14160  *             return result
14161  *
14162  */
14163         __Pyx_XDECREF(__pyx_r);
14164         __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)
14165         __Pyx_GOTREF(__pyx_t_1);
14166         __pyx_r = __pyx_t_1;
14167         __pyx_t_1 = 0;
14168         goto __pyx_L6_except_return;
14169 
14170         /* "View.MemoryView":497
14171  *             raise ValueError("Unable to convert item to object")
14172  *         else:
14173  *             if len(self.view.format) == 1:             # <<<<<<<<<<<<<<
14174  *                 return result[0]
14175  *             return result
14176  */
14177       }
14178 
14179       /* "View.MemoryView":499
14180  *             if len(self.view.format) == 1:
14181  *                 return result[0]
14182  *             return result             # <<<<<<<<<<<<<<
14183  *
14184  *     cdef assign_item_from_object(self, char *itemp, object value):
14185  */
14186       __Pyx_XDECREF(__pyx_r);
14187       __Pyx_INCREF(__pyx_v_result);
14188       __pyx_r = __pyx_v_result;
14189       goto __pyx_L6_except_return;
14190     }
14191     __pyx_L3_error:;
14192     __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
14193     __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
14194     __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
14195     __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
14196     __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
14197 
14198     /* "View.MemoryView":494
14199  *         try:
14200  *             result = struct.unpack(self.view.format, bytesitem)
14201  *         except struct.error:             # <<<<<<<<<<<<<<
14202  *             raise ValueError("Unable to convert item to object")
14203  *         else:
14204  */
14205     __Pyx_ErrFetch(&__pyx_t_1, &__pyx_t_5, &__pyx_t_9);
14206     __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)
14207     __Pyx_GOTREF(__pyx_t_6);
14208     __pyx_t_8 = __Pyx_PyErr_GivenExceptionMatches(__pyx_t_1, __pyx_t_6);
14209     __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
14210     __Pyx_ErrRestore(__pyx_t_1, __pyx_t_5, __pyx_t_9);
14211     __pyx_t_1 = 0; __pyx_t_5 = 0; __pyx_t_9 = 0;
14212     if (__pyx_t_8) {
14213       __Pyx_AddTraceback("View.MemoryView.memoryview.convert_item_to_object", __pyx_clineno, __pyx_lineno, __pyx_filename);
14214       if (__Pyx_GetException(&__pyx_t_9, &__pyx_t_5, &__pyx_t_1) < 0) __PYX_ERR(2, 494, __pyx_L5_except_error)
14215       __Pyx_GOTREF(__pyx_t_9);
14216       __Pyx_GOTREF(__pyx_t_5);
14217       __Pyx_GOTREF(__pyx_t_1);
14218 
14219       /* "View.MemoryView":495
14220  *             result = struct.unpack(self.view.format, bytesitem)
14221  *         except struct.error:
14222  *             raise ValueError("Unable to convert item to object")             # <<<<<<<<<<<<<<
14223  *         else:
14224  *             if len(self.view.format) == 1:
14225  */
14226       __pyx_t_6 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__11, NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(2, 495, __pyx_L5_except_error)
14227       __Pyx_GOTREF(__pyx_t_6);
14228       __Pyx_Raise(__pyx_t_6, 0, 0, 0);
14229       __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
14230       __PYX_ERR(2, 495, __pyx_L5_except_error)
14231     }
14232     goto __pyx_L5_except_error;
14233     __pyx_L5_except_error:;
14234 
14235     /* "View.MemoryView":492
14236  *
14237  *         bytesitem = itemp[:self.view.itemsize]
14238  *         try:             # <<<<<<<<<<<<<<
14239  *             result = struct.unpack(self.view.format, bytesitem)
14240  *         except struct.error:
14241  */
14242     __Pyx_XGIVEREF(__pyx_t_2);
14243     __Pyx_XGIVEREF(__pyx_t_3);
14244     __Pyx_XGIVEREF(__pyx_t_4);
14245     __Pyx_ExceptionReset(__pyx_t_2, __pyx_t_3, __pyx_t_4);
14246     goto __pyx_L1_error;
14247     __pyx_L6_except_return:;
14248     __Pyx_XGIVEREF(__pyx_t_2);
14249     __Pyx_XGIVEREF(__pyx_t_3);
14250     __Pyx_XGIVEREF(__pyx_t_4);
14251     __Pyx_ExceptionReset(__pyx_t_2, __pyx_t_3, __pyx_t_4);
14252     goto __pyx_L0;
14253   }
14254 
14255   /* "View.MemoryView":485
14256  *         self.assign_item_from_object(itemp, value)
14257  *
14258  *     cdef convert_item_to_object(self, char *itemp):             # <<<<<<<<<<<<<<
14259  *         """Only used if instantiated manually by the user, or if Cython doesn't
14260  *         know how to convert the type"""
14261  */
14262 
14263   /* function exit code */
14264   __pyx_L1_error:;
14265   __Pyx_XDECREF(__pyx_t_1);
14266   __Pyx_XDECREF(__pyx_t_5);
14267   __Pyx_XDECREF(__pyx_t_6);
14268   __Pyx_XDECREF(__pyx_t_7);
14269   __Pyx_XDECREF(__pyx_t_9);
14270   __Pyx_AddTraceback("View.MemoryView.memoryview.convert_item_to_object", __pyx_clineno, __pyx_lineno, __pyx_filename);
14271   __pyx_r = 0;
14272   __pyx_L0:;
14273   __Pyx_XDECREF(__pyx_v_struct);
14274   __Pyx_XDECREF(__pyx_v_bytesitem);
14275   __Pyx_XDECREF(__pyx_v_result);
14276   __Pyx_XGIVEREF(__pyx_r);
14277   __Pyx_RefNannyFinishContext();
14278   return __pyx_r;
14279 }
14280 
14281 /* "View.MemoryView":501
14282  *             return result
14283  *
14284  *     cdef assign_item_from_object(self, char *itemp, object value):             # <<<<<<<<<<<<<<
14285  *         """Only used if instantiated manually by the user, or if Cython doesn't
14286  *         know how to convert the type"""
14287  */
14288 
__pyx_memoryview_assign_item_from_object(struct __pyx_memoryview_obj * __pyx_v_self,char * __pyx_v_itemp,PyObject * __pyx_v_value)14289 static PyObject *__pyx_memoryview_assign_item_from_object(struct __pyx_memoryview_obj *__pyx_v_self, char *__pyx_v_itemp, PyObject *__pyx_v_value) {
14290   PyObject *__pyx_v_struct = NULL;
14291   char __pyx_v_c;
14292   PyObject *__pyx_v_bytesvalue = 0;
14293   Py_ssize_t __pyx_v_i;
14294   PyObject *__pyx_r = NULL;
14295   __Pyx_RefNannyDeclarations
14296   PyObject *__pyx_t_1 = NULL;
14297   int __pyx_t_2;
14298   int __pyx_t_3;
14299   PyObject *__pyx_t_4 = NULL;
14300   PyObject *__pyx_t_5 = NULL;
14301   PyObject *__pyx_t_6 = NULL;
14302   int __pyx_t_7;
14303   PyObject *__pyx_t_8 = NULL;
14304   Py_ssize_t __pyx_t_9;
14305   PyObject *__pyx_t_10 = NULL;
14306   char *__pyx_t_11;
14307   char *__pyx_t_12;
14308   char *__pyx_t_13;
14309   char *__pyx_t_14;
14310   int __pyx_lineno = 0;
14311   const char *__pyx_filename = NULL;
14312   int __pyx_clineno = 0;
14313   __Pyx_RefNannySetupContext("assign_item_from_object", 0);
14314 
14315   /* "View.MemoryView":504
14316  *         """Only used if instantiated manually by the user, or if Cython doesn't
14317  *         know how to convert the type"""
14318  *         import struct             # <<<<<<<<<<<<<<
14319  *         cdef char c
14320  *         cdef bytes bytesvalue
14321  */
14322   __pyx_t_1 = __Pyx_Import(__pyx_n_s_struct, 0, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 504, __pyx_L1_error)
14323   __Pyx_GOTREF(__pyx_t_1);
14324   __pyx_v_struct = __pyx_t_1;
14325   __pyx_t_1 = 0;
14326 
14327   /* "View.MemoryView":509
14328  *         cdef Py_ssize_t i
14329  *
14330  *         if isinstance(value, tuple):             # <<<<<<<<<<<<<<
14331  *             bytesvalue = struct.pack(self.view.format, *value)
14332  *         else:
14333  */
14334   __pyx_t_2 = PyTuple_Check(__pyx_v_value);
14335   __pyx_t_3 = (__pyx_t_2 != 0);
14336   if (__pyx_t_3) {
14337 
14338     /* "View.MemoryView":510
14339  *
14340  *         if isinstance(value, tuple):
14341  *             bytesvalue = struct.pack(self.view.format, *value)             # <<<<<<<<<<<<<<
14342  *         else:
14343  *             bytesvalue = struct.pack(self.view.format, value)
14344  */
14345     __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)
14346     __Pyx_GOTREF(__pyx_t_1);
14347     __pyx_t_4 = __Pyx_PyBytes_FromString(__pyx_v_self->view.format); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 510, __pyx_L1_error)
14348     __Pyx_GOTREF(__pyx_t_4);
14349     __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) __PYX_ERR(2, 510, __pyx_L1_error)
14350     __Pyx_GOTREF(__pyx_t_5);
14351     __Pyx_GIVEREF(__pyx_t_4);
14352     PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_4);
14353     __pyx_t_4 = 0;
14354     __pyx_t_4 = __Pyx_PySequence_Tuple(__pyx_v_value); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 510, __pyx_L1_error)
14355     __Pyx_GOTREF(__pyx_t_4);
14356     __pyx_t_6 = PyNumber_Add(__pyx_t_5, __pyx_t_4); if (unlikely(!__pyx_t_6)) __PYX_ERR(2, 510, __pyx_L1_error)
14357     __Pyx_GOTREF(__pyx_t_6);
14358     __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
14359     __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
14360     __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)
14361     __Pyx_GOTREF(__pyx_t_4);
14362     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
14363     __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
14364     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)
14365     __pyx_v_bytesvalue = ((PyObject*)__pyx_t_4);
14366     __pyx_t_4 = 0;
14367 
14368     /* "View.MemoryView":509
14369  *         cdef Py_ssize_t i
14370  *
14371  *         if isinstance(value, tuple):             # <<<<<<<<<<<<<<
14372  *             bytesvalue = struct.pack(self.view.format, *value)
14373  *         else:
14374  */
14375     goto __pyx_L3;
14376   }
14377 
14378   /* "View.MemoryView":512
14379  *             bytesvalue = struct.pack(self.view.format, *value)
14380  *         else:
14381  *             bytesvalue = struct.pack(self.view.format, value)             # <<<<<<<<<<<<<<
14382  *
14383  *         for i, c in enumerate(bytesvalue):
14384  */
14385   /*else*/ {
14386     __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)
14387     __Pyx_GOTREF(__pyx_t_6);
14388     __pyx_t_1 = __Pyx_PyBytes_FromString(__pyx_v_self->view.format); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 512, __pyx_L1_error)
14389     __Pyx_GOTREF(__pyx_t_1);
14390     __pyx_t_5 = NULL;
14391     __pyx_t_7 = 0;
14392     if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_6))) {
14393       __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_6);
14394       if (likely(__pyx_t_5)) {
14395         PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
14396         __Pyx_INCREF(__pyx_t_5);
14397         __Pyx_INCREF(function);
14398         __Pyx_DECREF_SET(__pyx_t_6, function);
14399         __pyx_t_7 = 1;
14400       }
14401     }
14402     #if CYTHON_FAST_PYCALL
14403     if (PyFunction_Check(__pyx_t_6)) {
14404       PyObject *__pyx_temp[3] = {__pyx_t_5, __pyx_t_1, __pyx_v_value};
14405       __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)
14406       __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
14407       __Pyx_GOTREF(__pyx_t_4);
14408       __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
14409     } else
14410     #endif
14411     #if CYTHON_FAST_PYCCALL
14412     if (__Pyx_PyFastCFunction_Check(__pyx_t_6)) {
14413       PyObject *__pyx_temp[3] = {__pyx_t_5, __pyx_t_1, __pyx_v_value};
14414       __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)
14415       __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
14416       __Pyx_GOTREF(__pyx_t_4);
14417       __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
14418     } else
14419     #endif
14420     {
14421       __pyx_t_8 = PyTuple_New(2+__pyx_t_7); if (unlikely(!__pyx_t_8)) __PYX_ERR(2, 512, __pyx_L1_error)
14422       __Pyx_GOTREF(__pyx_t_8);
14423       if (__pyx_t_5) {
14424         __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_5); __pyx_t_5 = NULL;
14425       }
14426       __Pyx_GIVEREF(__pyx_t_1);
14427       PyTuple_SET_ITEM(__pyx_t_8, 0+__pyx_t_7, __pyx_t_1);
14428       __Pyx_INCREF(__pyx_v_value);
14429       __Pyx_GIVEREF(__pyx_v_value);
14430       PyTuple_SET_ITEM(__pyx_t_8, 1+__pyx_t_7, __pyx_v_value);
14431       __pyx_t_1 = 0;
14432       __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)
14433       __Pyx_GOTREF(__pyx_t_4);
14434       __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
14435     }
14436     __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
14437     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)
14438     __pyx_v_bytesvalue = ((PyObject*)__pyx_t_4);
14439     __pyx_t_4 = 0;
14440   }
14441   __pyx_L3:;
14442 
14443   /* "View.MemoryView":514
14444  *             bytesvalue = struct.pack(self.view.format, value)
14445  *
14446  *         for i, c in enumerate(bytesvalue):             # <<<<<<<<<<<<<<
14447  *             itemp[i] = c
14448  *
14449  */
14450   __pyx_t_9 = 0;
14451   if (unlikely(__pyx_v_bytesvalue == Py_None)) {
14452     PyErr_SetString(PyExc_TypeError, "'NoneType' is not iterable");
14453     __PYX_ERR(2, 514, __pyx_L1_error)
14454   }
14455   __Pyx_INCREF(__pyx_v_bytesvalue);
14456   __pyx_t_10 = __pyx_v_bytesvalue;
14457   __pyx_t_12 = PyBytes_AS_STRING(__pyx_t_10);
14458   __pyx_t_13 = (__pyx_t_12 + PyBytes_GET_SIZE(__pyx_t_10));
14459   for (__pyx_t_14 = __pyx_t_12; __pyx_t_14 < __pyx_t_13; __pyx_t_14++) {
14460     __pyx_t_11 = __pyx_t_14;
14461     __pyx_v_c = (__pyx_t_11[0]);
14462 
14463     /* "View.MemoryView":515
14464  *
14465  *         for i, c in enumerate(bytesvalue):
14466  *             itemp[i] = c             # <<<<<<<<<<<<<<
14467  *
14468  *     @cname('getbuffer')
14469  */
14470     __pyx_v_i = __pyx_t_9;
14471 
14472     /* "View.MemoryView":514
14473  *             bytesvalue = struct.pack(self.view.format, value)
14474  *
14475  *         for i, c in enumerate(bytesvalue):             # <<<<<<<<<<<<<<
14476  *             itemp[i] = c
14477  *
14478  */
14479     __pyx_t_9 = (__pyx_t_9 + 1);
14480 
14481     /* "View.MemoryView":515
14482  *
14483  *         for i, c in enumerate(bytesvalue):
14484  *             itemp[i] = c             # <<<<<<<<<<<<<<
14485  *
14486  *     @cname('getbuffer')
14487  */
14488     (__pyx_v_itemp[__pyx_v_i]) = __pyx_v_c;
14489   }
14490   __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
14491 
14492   /* "View.MemoryView":501
14493  *             return result
14494  *
14495  *     cdef assign_item_from_object(self, char *itemp, object value):             # <<<<<<<<<<<<<<
14496  *         """Only used if instantiated manually by the user, or if Cython doesn't
14497  *         know how to convert the type"""
14498  */
14499 
14500   /* function exit code */
14501   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
14502   goto __pyx_L0;
14503   __pyx_L1_error:;
14504   __Pyx_XDECREF(__pyx_t_1);
14505   __Pyx_XDECREF(__pyx_t_4);
14506   __Pyx_XDECREF(__pyx_t_5);
14507   __Pyx_XDECREF(__pyx_t_6);
14508   __Pyx_XDECREF(__pyx_t_8);
14509   __Pyx_XDECREF(__pyx_t_10);
14510   __Pyx_AddTraceback("View.MemoryView.memoryview.assign_item_from_object", __pyx_clineno, __pyx_lineno, __pyx_filename);
14511   __pyx_r = 0;
14512   __pyx_L0:;
14513   __Pyx_XDECREF(__pyx_v_struct);
14514   __Pyx_XDECREF(__pyx_v_bytesvalue);
14515   __Pyx_XGIVEREF(__pyx_r);
14516   __Pyx_RefNannyFinishContext();
14517   return __pyx_r;
14518 }
14519 
14520 /* "View.MemoryView":518
14521  *
14522  *     @cname('getbuffer')
14523  *     def __getbuffer__(self, Py_buffer *info, int flags):             # <<<<<<<<<<<<<<
14524  *         if flags & PyBUF_WRITABLE and self.view.readonly:
14525  *             raise ValueError("Cannot create writable memory view from read-only memoryview")
14526  */
14527 
14528 /* Python wrapper */
14529 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)14530 static CYTHON_UNUSED int __pyx_memoryview_getbuffer(PyObject *__pyx_v_self, Py_buffer *__pyx_v_info, int __pyx_v_flags) {
14531   int __pyx_r;
14532   __Pyx_RefNannyDeclarations
14533   __Pyx_RefNannySetupContext("__getbuffer__ (wrapper)", 0);
14534   __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));
14535 
14536   /* function exit code */
14537   __Pyx_RefNannyFinishContext();
14538   return __pyx_r;
14539 }
14540 
__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)14541 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) {
14542   int __pyx_r;
14543   __Pyx_RefNannyDeclarations
14544   int __pyx_t_1;
14545   int __pyx_t_2;
14546   PyObject *__pyx_t_3 = NULL;
14547   Py_ssize_t *__pyx_t_4;
14548   char *__pyx_t_5;
14549   void *__pyx_t_6;
14550   int __pyx_t_7;
14551   Py_ssize_t __pyx_t_8;
14552   int __pyx_lineno = 0;
14553   const char *__pyx_filename = NULL;
14554   int __pyx_clineno = 0;
14555   if (__pyx_v_info == NULL) {
14556     PyErr_SetString(PyExc_BufferError, "PyObject_GetBuffer: view==NULL argument is obsolete");
14557     return -1;
14558   }
14559   __Pyx_RefNannySetupContext("__getbuffer__", 0);
14560   __pyx_v_info->obj = Py_None; __Pyx_INCREF(Py_None);
14561   __Pyx_GIVEREF(__pyx_v_info->obj);
14562 
14563   /* "View.MemoryView":519
14564  *     @cname('getbuffer')
14565  *     def __getbuffer__(self, Py_buffer *info, int flags):
14566  *         if flags & PyBUF_WRITABLE and self.view.readonly:             # <<<<<<<<<<<<<<
14567  *             raise ValueError("Cannot create writable memory view from read-only memoryview")
14568  *
14569  */
14570   __pyx_t_2 = ((__pyx_v_flags & PyBUF_WRITABLE) != 0);
14571   if (__pyx_t_2) {
14572   } else {
14573     __pyx_t_1 = __pyx_t_2;
14574     goto __pyx_L4_bool_binop_done;
14575   }
14576   __pyx_t_2 = (__pyx_v_self->view.readonly != 0);
14577   __pyx_t_1 = __pyx_t_2;
14578   __pyx_L4_bool_binop_done:;
14579   if (unlikely(__pyx_t_1)) {
14580 
14581     /* "View.MemoryView":520
14582  *     def __getbuffer__(self, Py_buffer *info, int flags):
14583  *         if flags & PyBUF_WRITABLE and self.view.readonly:
14584  *             raise ValueError("Cannot create writable memory view from read-only memoryview")             # <<<<<<<<<<<<<<
14585  *
14586  *         if flags & PyBUF_ND:
14587  */
14588     __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__12, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 520, __pyx_L1_error)
14589     __Pyx_GOTREF(__pyx_t_3);
14590     __Pyx_Raise(__pyx_t_3, 0, 0, 0);
14591     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
14592     __PYX_ERR(2, 520, __pyx_L1_error)
14593 
14594     /* "View.MemoryView":519
14595  *     @cname('getbuffer')
14596  *     def __getbuffer__(self, Py_buffer *info, int flags):
14597  *         if flags & PyBUF_WRITABLE and self.view.readonly:             # <<<<<<<<<<<<<<
14598  *             raise ValueError("Cannot create writable memory view from read-only memoryview")
14599  *
14600  */
14601   }
14602 
14603   /* "View.MemoryView":522
14604  *             raise ValueError("Cannot create writable memory view from read-only memoryview")
14605  *
14606  *         if flags & PyBUF_ND:             # <<<<<<<<<<<<<<
14607  *             info.shape = self.view.shape
14608  *         else:
14609  */
14610   __pyx_t_1 = ((__pyx_v_flags & PyBUF_ND) != 0);
14611   if (__pyx_t_1) {
14612 
14613     /* "View.MemoryView":523
14614  *
14615  *         if flags & PyBUF_ND:
14616  *             info.shape = self.view.shape             # <<<<<<<<<<<<<<
14617  *         else:
14618  *             info.shape = NULL
14619  */
14620     __pyx_t_4 = __pyx_v_self->view.shape;
14621     __pyx_v_info->shape = __pyx_t_4;
14622 
14623     /* "View.MemoryView":522
14624  *             raise ValueError("Cannot create writable memory view from read-only memoryview")
14625  *
14626  *         if flags & PyBUF_ND:             # <<<<<<<<<<<<<<
14627  *             info.shape = self.view.shape
14628  *         else:
14629  */
14630     goto __pyx_L6;
14631   }
14632 
14633   /* "View.MemoryView":525
14634  *             info.shape = self.view.shape
14635  *         else:
14636  *             info.shape = NULL             # <<<<<<<<<<<<<<
14637  *
14638  *         if flags & PyBUF_STRIDES:
14639  */
14640   /*else*/ {
14641     __pyx_v_info->shape = NULL;
14642   }
14643   __pyx_L6:;
14644 
14645   /* "View.MemoryView":527
14646  *             info.shape = NULL
14647  *
14648  *         if flags & PyBUF_STRIDES:             # <<<<<<<<<<<<<<
14649  *             info.strides = self.view.strides
14650  *         else:
14651  */
14652   __pyx_t_1 = ((__pyx_v_flags & PyBUF_STRIDES) != 0);
14653   if (__pyx_t_1) {
14654 
14655     /* "View.MemoryView":528
14656  *
14657  *         if flags & PyBUF_STRIDES:
14658  *             info.strides = self.view.strides             # <<<<<<<<<<<<<<
14659  *         else:
14660  *             info.strides = NULL
14661  */
14662     __pyx_t_4 = __pyx_v_self->view.strides;
14663     __pyx_v_info->strides = __pyx_t_4;
14664 
14665     /* "View.MemoryView":527
14666  *             info.shape = NULL
14667  *
14668  *         if flags & PyBUF_STRIDES:             # <<<<<<<<<<<<<<
14669  *             info.strides = self.view.strides
14670  *         else:
14671  */
14672     goto __pyx_L7;
14673   }
14674 
14675   /* "View.MemoryView":530
14676  *             info.strides = self.view.strides
14677  *         else:
14678  *             info.strides = NULL             # <<<<<<<<<<<<<<
14679  *
14680  *         if flags & PyBUF_INDIRECT:
14681  */
14682   /*else*/ {
14683     __pyx_v_info->strides = NULL;
14684   }
14685   __pyx_L7:;
14686 
14687   /* "View.MemoryView":532
14688  *             info.strides = NULL
14689  *
14690  *         if flags & PyBUF_INDIRECT:             # <<<<<<<<<<<<<<
14691  *             info.suboffsets = self.view.suboffsets
14692  *         else:
14693  */
14694   __pyx_t_1 = ((__pyx_v_flags & PyBUF_INDIRECT) != 0);
14695   if (__pyx_t_1) {
14696 
14697     /* "View.MemoryView":533
14698  *
14699  *         if flags & PyBUF_INDIRECT:
14700  *             info.suboffsets = self.view.suboffsets             # <<<<<<<<<<<<<<
14701  *         else:
14702  *             info.suboffsets = NULL
14703  */
14704     __pyx_t_4 = __pyx_v_self->view.suboffsets;
14705     __pyx_v_info->suboffsets = __pyx_t_4;
14706 
14707     /* "View.MemoryView":532
14708  *             info.strides = NULL
14709  *
14710  *         if flags & PyBUF_INDIRECT:             # <<<<<<<<<<<<<<
14711  *             info.suboffsets = self.view.suboffsets
14712  *         else:
14713  */
14714     goto __pyx_L8;
14715   }
14716 
14717   /* "View.MemoryView":535
14718  *             info.suboffsets = self.view.suboffsets
14719  *         else:
14720  *             info.suboffsets = NULL             # <<<<<<<<<<<<<<
14721  *
14722  *         if flags & PyBUF_FORMAT:
14723  */
14724   /*else*/ {
14725     __pyx_v_info->suboffsets = NULL;
14726   }
14727   __pyx_L8:;
14728 
14729   /* "View.MemoryView":537
14730  *             info.suboffsets = NULL
14731  *
14732  *         if flags & PyBUF_FORMAT:             # <<<<<<<<<<<<<<
14733  *             info.format = self.view.format
14734  *         else:
14735  */
14736   __pyx_t_1 = ((__pyx_v_flags & PyBUF_FORMAT) != 0);
14737   if (__pyx_t_1) {
14738 
14739     /* "View.MemoryView":538
14740  *
14741  *         if flags & PyBUF_FORMAT:
14742  *             info.format = self.view.format             # <<<<<<<<<<<<<<
14743  *         else:
14744  *             info.format = NULL
14745  */
14746     __pyx_t_5 = __pyx_v_self->view.format;
14747     __pyx_v_info->format = __pyx_t_5;
14748 
14749     /* "View.MemoryView":537
14750  *             info.suboffsets = NULL
14751  *
14752  *         if flags & PyBUF_FORMAT:             # <<<<<<<<<<<<<<
14753  *             info.format = self.view.format
14754  *         else:
14755  */
14756     goto __pyx_L9;
14757   }
14758 
14759   /* "View.MemoryView":540
14760  *             info.format = self.view.format
14761  *         else:
14762  *             info.format = NULL             # <<<<<<<<<<<<<<
14763  *
14764  *         info.buf = self.view.buf
14765  */
14766   /*else*/ {
14767     __pyx_v_info->format = NULL;
14768   }
14769   __pyx_L9:;
14770 
14771   /* "View.MemoryView":542
14772  *             info.format = NULL
14773  *
14774  *         info.buf = self.view.buf             # <<<<<<<<<<<<<<
14775  *         info.ndim = self.view.ndim
14776  *         info.itemsize = self.view.itemsize
14777  */
14778   __pyx_t_6 = __pyx_v_self->view.buf;
14779   __pyx_v_info->buf = __pyx_t_6;
14780 
14781   /* "View.MemoryView":543
14782  *
14783  *         info.buf = self.view.buf
14784  *         info.ndim = self.view.ndim             # <<<<<<<<<<<<<<
14785  *         info.itemsize = self.view.itemsize
14786  *         info.len = self.view.len
14787  */
14788   __pyx_t_7 = __pyx_v_self->view.ndim;
14789   __pyx_v_info->ndim = __pyx_t_7;
14790 
14791   /* "View.MemoryView":544
14792  *         info.buf = self.view.buf
14793  *         info.ndim = self.view.ndim
14794  *         info.itemsize = self.view.itemsize             # <<<<<<<<<<<<<<
14795  *         info.len = self.view.len
14796  *         info.readonly = self.view.readonly
14797  */
14798   __pyx_t_8 = __pyx_v_self->view.itemsize;
14799   __pyx_v_info->itemsize = __pyx_t_8;
14800 
14801   /* "View.MemoryView":545
14802  *         info.ndim = self.view.ndim
14803  *         info.itemsize = self.view.itemsize
14804  *         info.len = self.view.len             # <<<<<<<<<<<<<<
14805  *         info.readonly = self.view.readonly
14806  *         info.obj = self
14807  */
14808   __pyx_t_8 = __pyx_v_self->view.len;
14809   __pyx_v_info->len = __pyx_t_8;
14810 
14811   /* "View.MemoryView":546
14812  *         info.itemsize = self.view.itemsize
14813  *         info.len = self.view.len
14814  *         info.readonly = self.view.readonly             # <<<<<<<<<<<<<<
14815  *         info.obj = self
14816  *
14817  */
14818   __pyx_t_1 = __pyx_v_self->view.readonly;
14819   __pyx_v_info->readonly = __pyx_t_1;
14820 
14821   /* "View.MemoryView":547
14822  *         info.len = self.view.len
14823  *         info.readonly = self.view.readonly
14824  *         info.obj = self             # <<<<<<<<<<<<<<
14825  *
14826  *     __pyx_getbuffer = capsule(<void *> &__pyx_memoryview_getbuffer, "getbuffer(obj, view, flags)")
14827  */
14828   __Pyx_INCREF(((PyObject *)__pyx_v_self));
14829   __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
14830   __Pyx_GOTREF(__pyx_v_info->obj);
14831   __Pyx_DECREF(__pyx_v_info->obj);
14832   __pyx_v_info->obj = ((PyObject *)__pyx_v_self);
14833 
14834   /* "View.MemoryView":518
14835  *
14836  *     @cname('getbuffer')
14837  *     def __getbuffer__(self, Py_buffer *info, int flags):             # <<<<<<<<<<<<<<
14838  *         if flags & PyBUF_WRITABLE and self.view.readonly:
14839  *             raise ValueError("Cannot create writable memory view from read-only memoryview")
14840  */
14841 
14842   /* function exit code */
14843   __pyx_r = 0;
14844   goto __pyx_L0;
14845   __pyx_L1_error:;
14846   __Pyx_XDECREF(__pyx_t_3);
14847   __Pyx_AddTraceback("View.MemoryView.memoryview.__getbuffer__", __pyx_clineno, __pyx_lineno, __pyx_filename);
14848   __pyx_r = -1;
14849   if (__pyx_v_info->obj != NULL) {
14850     __Pyx_GOTREF(__pyx_v_info->obj);
14851     __Pyx_DECREF(__pyx_v_info->obj); __pyx_v_info->obj = 0;
14852   }
14853   goto __pyx_L2;
14854   __pyx_L0:;
14855   if (__pyx_v_info->obj == Py_None) {
14856     __Pyx_GOTREF(__pyx_v_info->obj);
14857     __Pyx_DECREF(__pyx_v_info->obj); __pyx_v_info->obj = 0;
14858   }
14859   __pyx_L2:;
14860   __Pyx_RefNannyFinishContext();
14861   return __pyx_r;
14862 }
14863 
14864 /* "View.MemoryView":553
14865  *
14866  *     @property
14867  *     def T(self):             # <<<<<<<<<<<<<<
14868  *         cdef _memoryviewslice result = memoryview_copy(self)
14869  *         transpose_memslice(&result.from_slice)
14870  */
14871 
14872 /* Python wrapper */
14873 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)14874 static PyObject *__pyx_pw_15View_dot_MemoryView_10memoryview_1T_1__get__(PyObject *__pyx_v_self) {
14875   PyObject *__pyx_r = 0;
14876   __Pyx_RefNannyDeclarations
14877   __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
14878   __pyx_r = __pyx_pf_15View_dot_MemoryView_10memoryview_1T___get__(((struct __pyx_memoryview_obj *)__pyx_v_self));
14879 
14880   /* function exit code */
14881   __Pyx_RefNannyFinishContext();
14882   return __pyx_r;
14883 }
14884 
__pyx_pf_15View_dot_MemoryView_10memoryview_1T___get__(struct __pyx_memoryview_obj * __pyx_v_self)14885 static PyObject *__pyx_pf_15View_dot_MemoryView_10memoryview_1T___get__(struct __pyx_memoryview_obj *__pyx_v_self) {
14886   struct __pyx_memoryviewslice_obj *__pyx_v_result = 0;
14887   PyObject *__pyx_r = NULL;
14888   __Pyx_RefNannyDeclarations
14889   PyObject *__pyx_t_1 = NULL;
14890   int __pyx_t_2;
14891   int __pyx_lineno = 0;
14892   const char *__pyx_filename = NULL;
14893   int __pyx_clineno = 0;
14894   __Pyx_RefNannySetupContext("__get__", 0);
14895 
14896   /* "View.MemoryView":554
14897  *     @property
14898  *     def T(self):
14899  *         cdef _memoryviewslice result = memoryview_copy(self)             # <<<<<<<<<<<<<<
14900  *         transpose_memslice(&result.from_slice)
14901  *         return result
14902  */
14903   __pyx_t_1 = __pyx_memoryview_copy_object(__pyx_v_self); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 554, __pyx_L1_error)
14904   __Pyx_GOTREF(__pyx_t_1);
14905   if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_memoryviewslice_type))))) __PYX_ERR(2, 554, __pyx_L1_error)
14906   __pyx_v_result = ((struct __pyx_memoryviewslice_obj *)__pyx_t_1);
14907   __pyx_t_1 = 0;
14908 
14909   /* "View.MemoryView":555
14910  *     def T(self):
14911  *         cdef _memoryviewslice result = memoryview_copy(self)
14912  *         transpose_memslice(&result.from_slice)             # <<<<<<<<<<<<<<
14913  *         return result
14914  *
14915  */
14916   __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)
14917 
14918   /* "View.MemoryView":556
14919  *         cdef _memoryviewslice result = memoryview_copy(self)
14920  *         transpose_memslice(&result.from_slice)
14921  *         return result             # <<<<<<<<<<<<<<
14922  *
14923  *     @property
14924  */
14925   __Pyx_XDECREF(__pyx_r);
14926   __Pyx_INCREF(((PyObject *)__pyx_v_result));
14927   __pyx_r = ((PyObject *)__pyx_v_result);
14928   goto __pyx_L0;
14929 
14930   /* "View.MemoryView":553
14931  *
14932  *     @property
14933  *     def T(self):             # <<<<<<<<<<<<<<
14934  *         cdef _memoryviewslice result = memoryview_copy(self)
14935  *         transpose_memslice(&result.from_slice)
14936  */
14937 
14938   /* function exit code */
14939   __pyx_L1_error:;
14940   __Pyx_XDECREF(__pyx_t_1);
14941   __Pyx_AddTraceback("View.MemoryView.memoryview.T.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
14942   __pyx_r = NULL;
14943   __pyx_L0:;
14944   __Pyx_XDECREF((PyObject *)__pyx_v_result);
14945   __Pyx_XGIVEREF(__pyx_r);
14946   __Pyx_RefNannyFinishContext();
14947   return __pyx_r;
14948 }
14949 
14950 /* "View.MemoryView":559
14951  *
14952  *     @property
14953  *     def base(self):             # <<<<<<<<<<<<<<
14954  *         return self.obj
14955  *
14956  */
14957 
14958 /* Python wrapper */
14959 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)14960 static PyObject *__pyx_pw_15View_dot_MemoryView_10memoryview_4base_1__get__(PyObject *__pyx_v_self) {
14961   PyObject *__pyx_r = 0;
14962   __Pyx_RefNannyDeclarations
14963   __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
14964   __pyx_r = __pyx_pf_15View_dot_MemoryView_10memoryview_4base___get__(((struct __pyx_memoryview_obj *)__pyx_v_self));
14965 
14966   /* function exit code */
14967   __Pyx_RefNannyFinishContext();
14968   return __pyx_r;
14969 }
14970 
__pyx_pf_15View_dot_MemoryView_10memoryview_4base___get__(struct __pyx_memoryview_obj * __pyx_v_self)14971 static PyObject *__pyx_pf_15View_dot_MemoryView_10memoryview_4base___get__(struct __pyx_memoryview_obj *__pyx_v_self) {
14972   PyObject *__pyx_r = NULL;
14973   __Pyx_RefNannyDeclarations
14974   __Pyx_RefNannySetupContext("__get__", 0);
14975 
14976   /* "View.MemoryView":560
14977  *     @property
14978  *     def base(self):
14979  *         return self.obj             # <<<<<<<<<<<<<<
14980  *
14981  *     @property
14982  */
14983   __Pyx_XDECREF(__pyx_r);
14984   __Pyx_INCREF(__pyx_v_self->obj);
14985   __pyx_r = __pyx_v_self->obj;
14986   goto __pyx_L0;
14987 
14988   /* "View.MemoryView":559
14989  *
14990  *     @property
14991  *     def base(self):             # <<<<<<<<<<<<<<
14992  *         return self.obj
14993  *
14994  */
14995 
14996   /* function exit code */
14997   __pyx_L0:;
14998   __Pyx_XGIVEREF(__pyx_r);
14999   __Pyx_RefNannyFinishContext();
15000   return __pyx_r;
15001 }
15002 
15003 /* "View.MemoryView":563
15004  *
15005  *     @property
15006  *     def shape(self):             # <<<<<<<<<<<<<<
15007  *         return tuple([length for length in self.view.shape[:self.view.ndim]])
15008  *
15009  */
15010 
15011 /* Python wrapper */
15012 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)15013 static PyObject *__pyx_pw_15View_dot_MemoryView_10memoryview_5shape_1__get__(PyObject *__pyx_v_self) {
15014   PyObject *__pyx_r = 0;
15015   __Pyx_RefNannyDeclarations
15016   __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
15017   __pyx_r = __pyx_pf_15View_dot_MemoryView_10memoryview_5shape___get__(((struct __pyx_memoryview_obj *)__pyx_v_self));
15018 
15019   /* function exit code */
15020   __Pyx_RefNannyFinishContext();
15021   return __pyx_r;
15022 }
15023 
__pyx_pf_15View_dot_MemoryView_10memoryview_5shape___get__(struct __pyx_memoryview_obj * __pyx_v_self)15024 static PyObject *__pyx_pf_15View_dot_MemoryView_10memoryview_5shape___get__(struct __pyx_memoryview_obj *__pyx_v_self) {
15025   Py_ssize_t __pyx_v_length;
15026   PyObject *__pyx_r = NULL;
15027   __Pyx_RefNannyDeclarations
15028   PyObject *__pyx_t_1 = NULL;
15029   Py_ssize_t *__pyx_t_2;
15030   Py_ssize_t *__pyx_t_3;
15031   Py_ssize_t *__pyx_t_4;
15032   PyObject *__pyx_t_5 = NULL;
15033   int __pyx_lineno = 0;
15034   const char *__pyx_filename = NULL;
15035   int __pyx_clineno = 0;
15036   __Pyx_RefNannySetupContext("__get__", 0);
15037 
15038   /* "View.MemoryView":564
15039  *     @property
15040  *     def shape(self):
15041  *         return tuple([length for length in self.view.shape[:self.view.ndim]])             # <<<<<<<<<<<<<<
15042  *
15043  *     @property
15044  */
15045   __Pyx_XDECREF(__pyx_r);
15046   __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 564, __pyx_L1_error)
15047   __Pyx_GOTREF(__pyx_t_1);
15048   __pyx_t_3 = (__pyx_v_self->view.shape + __pyx_v_self->view.ndim);
15049   for (__pyx_t_4 = __pyx_v_self->view.shape; __pyx_t_4 < __pyx_t_3; __pyx_t_4++) {
15050     __pyx_t_2 = __pyx_t_4;
15051     __pyx_v_length = (__pyx_t_2[0]);
15052     __pyx_t_5 = PyInt_FromSsize_t(__pyx_v_length); if (unlikely(!__pyx_t_5)) __PYX_ERR(2, 564, __pyx_L1_error)
15053     __Pyx_GOTREF(__pyx_t_5);
15054     if (unlikely(__Pyx_ListComp_Append(__pyx_t_1, (PyObject*)__pyx_t_5))) __PYX_ERR(2, 564, __pyx_L1_error)
15055     __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
15056   }
15057   __pyx_t_5 = PyList_AsTuple(((PyObject*)__pyx_t_1)); if (unlikely(!__pyx_t_5)) __PYX_ERR(2, 564, __pyx_L1_error)
15058   __Pyx_GOTREF(__pyx_t_5);
15059   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
15060   __pyx_r = __pyx_t_5;
15061   __pyx_t_5 = 0;
15062   goto __pyx_L0;
15063 
15064   /* "View.MemoryView":563
15065  *
15066  *     @property
15067  *     def shape(self):             # <<<<<<<<<<<<<<
15068  *         return tuple([length for length in self.view.shape[:self.view.ndim]])
15069  *
15070  */
15071 
15072   /* function exit code */
15073   __pyx_L1_error:;
15074   __Pyx_XDECREF(__pyx_t_1);
15075   __Pyx_XDECREF(__pyx_t_5);
15076   __Pyx_AddTraceback("View.MemoryView.memoryview.shape.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
15077   __pyx_r = NULL;
15078   __pyx_L0:;
15079   __Pyx_XGIVEREF(__pyx_r);
15080   __Pyx_RefNannyFinishContext();
15081   return __pyx_r;
15082 }
15083 
15084 /* "View.MemoryView":567
15085  *
15086  *     @property
15087  *     def strides(self):             # <<<<<<<<<<<<<<
15088  *         if self.view.strides == NULL:
15089  *
15090  */
15091 
15092 /* Python wrapper */
15093 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)15094 static PyObject *__pyx_pw_15View_dot_MemoryView_10memoryview_7strides_1__get__(PyObject *__pyx_v_self) {
15095   PyObject *__pyx_r = 0;
15096   __Pyx_RefNannyDeclarations
15097   __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
15098   __pyx_r = __pyx_pf_15View_dot_MemoryView_10memoryview_7strides___get__(((struct __pyx_memoryview_obj *)__pyx_v_self));
15099 
15100   /* function exit code */
15101   __Pyx_RefNannyFinishContext();
15102   return __pyx_r;
15103 }
15104 
__pyx_pf_15View_dot_MemoryView_10memoryview_7strides___get__(struct __pyx_memoryview_obj * __pyx_v_self)15105 static PyObject *__pyx_pf_15View_dot_MemoryView_10memoryview_7strides___get__(struct __pyx_memoryview_obj *__pyx_v_self) {
15106   Py_ssize_t __pyx_v_stride;
15107   PyObject *__pyx_r = NULL;
15108   __Pyx_RefNannyDeclarations
15109   int __pyx_t_1;
15110   PyObject *__pyx_t_2 = NULL;
15111   Py_ssize_t *__pyx_t_3;
15112   Py_ssize_t *__pyx_t_4;
15113   Py_ssize_t *__pyx_t_5;
15114   PyObject *__pyx_t_6 = NULL;
15115   int __pyx_lineno = 0;
15116   const char *__pyx_filename = NULL;
15117   int __pyx_clineno = 0;
15118   __Pyx_RefNannySetupContext("__get__", 0);
15119 
15120   /* "View.MemoryView":568
15121  *     @property
15122  *     def strides(self):
15123  *         if self.view.strides == NULL:             # <<<<<<<<<<<<<<
15124  *
15125  *             raise ValueError("Buffer view does not expose strides")
15126  */
15127   __pyx_t_1 = ((__pyx_v_self->view.strides == NULL) != 0);
15128   if (unlikely(__pyx_t_1)) {
15129 
15130     /* "View.MemoryView":570
15131  *         if self.view.strides == NULL:
15132  *
15133  *             raise ValueError("Buffer view does not expose strides")             # <<<<<<<<<<<<<<
15134  *
15135  *         return tuple([stride for stride in self.view.strides[:self.view.ndim]])
15136  */
15137     __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__13, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 570, __pyx_L1_error)
15138     __Pyx_GOTREF(__pyx_t_2);
15139     __Pyx_Raise(__pyx_t_2, 0, 0, 0);
15140     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
15141     __PYX_ERR(2, 570, __pyx_L1_error)
15142 
15143     /* "View.MemoryView":568
15144  *     @property
15145  *     def strides(self):
15146  *         if self.view.strides == NULL:             # <<<<<<<<<<<<<<
15147  *
15148  *             raise ValueError("Buffer view does not expose strides")
15149  */
15150   }
15151 
15152   /* "View.MemoryView":572
15153  *             raise ValueError("Buffer view does not expose strides")
15154  *
15155  *         return tuple([stride for stride in self.view.strides[:self.view.ndim]])             # <<<<<<<<<<<<<<
15156  *
15157  *     @property
15158  */
15159   __Pyx_XDECREF(__pyx_r);
15160   __pyx_t_2 = PyList_New(0); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 572, __pyx_L1_error)
15161   __Pyx_GOTREF(__pyx_t_2);
15162   __pyx_t_4 = (__pyx_v_self->view.strides + __pyx_v_self->view.ndim);
15163   for (__pyx_t_5 = __pyx_v_self->view.strides; __pyx_t_5 < __pyx_t_4; __pyx_t_5++) {
15164     __pyx_t_3 = __pyx_t_5;
15165     __pyx_v_stride = (__pyx_t_3[0]);
15166     __pyx_t_6 = PyInt_FromSsize_t(__pyx_v_stride); if (unlikely(!__pyx_t_6)) __PYX_ERR(2, 572, __pyx_L1_error)
15167     __Pyx_GOTREF(__pyx_t_6);
15168     if (unlikely(__Pyx_ListComp_Append(__pyx_t_2, (PyObject*)__pyx_t_6))) __PYX_ERR(2, 572, __pyx_L1_error)
15169     __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
15170   }
15171   __pyx_t_6 = PyList_AsTuple(((PyObject*)__pyx_t_2)); if (unlikely(!__pyx_t_6)) __PYX_ERR(2, 572, __pyx_L1_error)
15172   __Pyx_GOTREF(__pyx_t_6);
15173   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
15174   __pyx_r = __pyx_t_6;
15175   __pyx_t_6 = 0;
15176   goto __pyx_L0;
15177 
15178   /* "View.MemoryView":567
15179  *
15180  *     @property
15181  *     def strides(self):             # <<<<<<<<<<<<<<
15182  *         if self.view.strides == NULL:
15183  *
15184  */
15185 
15186   /* function exit code */
15187   __pyx_L1_error:;
15188   __Pyx_XDECREF(__pyx_t_2);
15189   __Pyx_XDECREF(__pyx_t_6);
15190   __Pyx_AddTraceback("View.MemoryView.memoryview.strides.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
15191   __pyx_r = NULL;
15192   __pyx_L0:;
15193   __Pyx_XGIVEREF(__pyx_r);
15194   __Pyx_RefNannyFinishContext();
15195   return __pyx_r;
15196 }
15197 
15198 /* "View.MemoryView":575
15199  *
15200  *     @property
15201  *     def suboffsets(self):             # <<<<<<<<<<<<<<
15202  *         if self.view.suboffsets == NULL:
15203  *             return (-1,) * self.view.ndim
15204  */
15205 
15206 /* Python wrapper */
15207 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)15208 static PyObject *__pyx_pw_15View_dot_MemoryView_10memoryview_10suboffsets_1__get__(PyObject *__pyx_v_self) {
15209   PyObject *__pyx_r = 0;
15210   __Pyx_RefNannyDeclarations
15211   __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
15212   __pyx_r = __pyx_pf_15View_dot_MemoryView_10memoryview_10suboffsets___get__(((struct __pyx_memoryview_obj *)__pyx_v_self));
15213 
15214   /* function exit code */
15215   __Pyx_RefNannyFinishContext();
15216   return __pyx_r;
15217 }
15218 
__pyx_pf_15View_dot_MemoryView_10memoryview_10suboffsets___get__(struct __pyx_memoryview_obj * __pyx_v_self)15219 static PyObject *__pyx_pf_15View_dot_MemoryView_10memoryview_10suboffsets___get__(struct __pyx_memoryview_obj *__pyx_v_self) {
15220   Py_ssize_t __pyx_v_suboffset;
15221   PyObject *__pyx_r = NULL;
15222   __Pyx_RefNannyDeclarations
15223   int __pyx_t_1;
15224   PyObject *__pyx_t_2 = NULL;
15225   PyObject *__pyx_t_3 = NULL;
15226   Py_ssize_t *__pyx_t_4;
15227   Py_ssize_t *__pyx_t_5;
15228   Py_ssize_t *__pyx_t_6;
15229   int __pyx_lineno = 0;
15230   const char *__pyx_filename = NULL;
15231   int __pyx_clineno = 0;
15232   __Pyx_RefNannySetupContext("__get__", 0);
15233 
15234   /* "View.MemoryView":576
15235  *     @property
15236  *     def suboffsets(self):
15237  *         if self.view.suboffsets == NULL:             # <<<<<<<<<<<<<<
15238  *             return (-1,) * self.view.ndim
15239  *
15240  */
15241   __pyx_t_1 = ((__pyx_v_self->view.suboffsets == NULL) != 0);
15242   if (__pyx_t_1) {
15243 
15244     /* "View.MemoryView":577
15245  *     def suboffsets(self):
15246  *         if self.view.suboffsets == NULL:
15247  *             return (-1,) * self.view.ndim             # <<<<<<<<<<<<<<
15248  *
15249  *         return tuple([suboffset for suboffset in self.view.suboffsets[:self.view.ndim]])
15250  */
15251     __Pyx_XDECREF(__pyx_r);
15252     __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_self->view.ndim); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 577, __pyx_L1_error)
15253     __Pyx_GOTREF(__pyx_t_2);
15254     __pyx_t_3 = PyNumber_Multiply(__pyx_tuple__14, __pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 577, __pyx_L1_error)
15255     __Pyx_GOTREF(__pyx_t_3);
15256     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
15257     __pyx_r = __pyx_t_3;
15258     __pyx_t_3 = 0;
15259     goto __pyx_L0;
15260 
15261     /* "View.MemoryView":576
15262  *     @property
15263  *     def suboffsets(self):
15264  *         if self.view.suboffsets == NULL:             # <<<<<<<<<<<<<<
15265  *             return (-1,) * self.view.ndim
15266  *
15267  */
15268   }
15269 
15270   /* "View.MemoryView":579
15271  *             return (-1,) * self.view.ndim
15272  *
15273  *         return tuple([suboffset for suboffset in self.view.suboffsets[:self.view.ndim]])             # <<<<<<<<<<<<<<
15274  *
15275  *     @property
15276  */
15277   __Pyx_XDECREF(__pyx_r);
15278   __pyx_t_3 = PyList_New(0); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 579, __pyx_L1_error)
15279   __Pyx_GOTREF(__pyx_t_3);
15280   __pyx_t_5 = (__pyx_v_self->view.suboffsets + __pyx_v_self->view.ndim);
15281   for (__pyx_t_6 = __pyx_v_self->view.suboffsets; __pyx_t_6 < __pyx_t_5; __pyx_t_6++) {
15282     __pyx_t_4 = __pyx_t_6;
15283     __pyx_v_suboffset = (__pyx_t_4[0]);
15284     __pyx_t_2 = PyInt_FromSsize_t(__pyx_v_suboffset); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 579, __pyx_L1_error)
15285     __Pyx_GOTREF(__pyx_t_2);
15286     if (unlikely(__Pyx_ListComp_Append(__pyx_t_3, (PyObject*)__pyx_t_2))) __PYX_ERR(2, 579, __pyx_L1_error)
15287     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
15288   }
15289   __pyx_t_2 = PyList_AsTuple(((PyObject*)__pyx_t_3)); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 579, __pyx_L1_error)
15290   __Pyx_GOTREF(__pyx_t_2);
15291   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
15292   __pyx_r = __pyx_t_2;
15293   __pyx_t_2 = 0;
15294   goto __pyx_L0;
15295 
15296   /* "View.MemoryView":575
15297  *
15298  *     @property
15299  *     def suboffsets(self):             # <<<<<<<<<<<<<<
15300  *         if self.view.suboffsets == NULL:
15301  *             return (-1,) * self.view.ndim
15302  */
15303 
15304   /* function exit code */
15305   __pyx_L1_error:;
15306   __Pyx_XDECREF(__pyx_t_2);
15307   __Pyx_XDECREF(__pyx_t_3);
15308   __Pyx_AddTraceback("View.MemoryView.memoryview.suboffsets.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
15309   __pyx_r = NULL;
15310   __pyx_L0:;
15311   __Pyx_XGIVEREF(__pyx_r);
15312   __Pyx_RefNannyFinishContext();
15313   return __pyx_r;
15314 }
15315 
15316 /* "View.MemoryView":582
15317  *
15318  *     @property
15319  *     def ndim(self):             # <<<<<<<<<<<<<<
15320  *         return self.view.ndim
15321  *
15322  */
15323 
15324 /* Python wrapper */
15325 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)15326 static PyObject *__pyx_pw_15View_dot_MemoryView_10memoryview_4ndim_1__get__(PyObject *__pyx_v_self) {
15327   PyObject *__pyx_r = 0;
15328   __Pyx_RefNannyDeclarations
15329   __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
15330   __pyx_r = __pyx_pf_15View_dot_MemoryView_10memoryview_4ndim___get__(((struct __pyx_memoryview_obj *)__pyx_v_self));
15331 
15332   /* function exit code */
15333   __Pyx_RefNannyFinishContext();
15334   return __pyx_r;
15335 }
15336 
__pyx_pf_15View_dot_MemoryView_10memoryview_4ndim___get__(struct __pyx_memoryview_obj * __pyx_v_self)15337 static PyObject *__pyx_pf_15View_dot_MemoryView_10memoryview_4ndim___get__(struct __pyx_memoryview_obj *__pyx_v_self) {
15338   PyObject *__pyx_r = NULL;
15339   __Pyx_RefNannyDeclarations
15340   PyObject *__pyx_t_1 = NULL;
15341   int __pyx_lineno = 0;
15342   const char *__pyx_filename = NULL;
15343   int __pyx_clineno = 0;
15344   __Pyx_RefNannySetupContext("__get__", 0);
15345 
15346   /* "View.MemoryView":583
15347  *     @property
15348  *     def ndim(self):
15349  *         return self.view.ndim             # <<<<<<<<<<<<<<
15350  *
15351  *     @property
15352  */
15353   __Pyx_XDECREF(__pyx_r);
15354   __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_self->view.ndim); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 583, __pyx_L1_error)
15355   __Pyx_GOTREF(__pyx_t_1);
15356   __pyx_r = __pyx_t_1;
15357   __pyx_t_1 = 0;
15358   goto __pyx_L0;
15359 
15360   /* "View.MemoryView":582
15361  *
15362  *     @property
15363  *     def ndim(self):             # <<<<<<<<<<<<<<
15364  *         return self.view.ndim
15365  *
15366  */
15367 
15368   /* function exit code */
15369   __pyx_L1_error:;
15370   __Pyx_XDECREF(__pyx_t_1);
15371   __Pyx_AddTraceback("View.MemoryView.memoryview.ndim.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
15372   __pyx_r = NULL;
15373   __pyx_L0:;
15374   __Pyx_XGIVEREF(__pyx_r);
15375   __Pyx_RefNannyFinishContext();
15376   return __pyx_r;
15377 }
15378 
15379 /* "View.MemoryView":586
15380  *
15381  *     @property
15382  *     def itemsize(self):             # <<<<<<<<<<<<<<
15383  *         return self.view.itemsize
15384  *
15385  */
15386 
15387 /* Python wrapper */
15388 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)15389 static PyObject *__pyx_pw_15View_dot_MemoryView_10memoryview_8itemsize_1__get__(PyObject *__pyx_v_self) {
15390   PyObject *__pyx_r = 0;
15391   __Pyx_RefNannyDeclarations
15392   __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
15393   __pyx_r = __pyx_pf_15View_dot_MemoryView_10memoryview_8itemsize___get__(((struct __pyx_memoryview_obj *)__pyx_v_self));
15394 
15395   /* function exit code */
15396   __Pyx_RefNannyFinishContext();
15397   return __pyx_r;
15398 }
15399 
__pyx_pf_15View_dot_MemoryView_10memoryview_8itemsize___get__(struct __pyx_memoryview_obj * __pyx_v_self)15400 static PyObject *__pyx_pf_15View_dot_MemoryView_10memoryview_8itemsize___get__(struct __pyx_memoryview_obj *__pyx_v_self) {
15401   PyObject *__pyx_r = NULL;
15402   __Pyx_RefNannyDeclarations
15403   PyObject *__pyx_t_1 = NULL;
15404   int __pyx_lineno = 0;
15405   const char *__pyx_filename = NULL;
15406   int __pyx_clineno = 0;
15407   __Pyx_RefNannySetupContext("__get__", 0);
15408 
15409   /* "View.MemoryView":587
15410  *     @property
15411  *     def itemsize(self):
15412  *         return self.view.itemsize             # <<<<<<<<<<<<<<
15413  *
15414  *     @property
15415  */
15416   __Pyx_XDECREF(__pyx_r);
15417   __pyx_t_1 = PyInt_FromSsize_t(__pyx_v_self->view.itemsize); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 587, __pyx_L1_error)
15418   __Pyx_GOTREF(__pyx_t_1);
15419   __pyx_r = __pyx_t_1;
15420   __pyx_t_1 = 0;
15421   goto __pyx_L0;
15422 
15423   /* "View.MemoryView":586
15424  *
15425  *     @property
15426  *     def itemsize(self):             # <<<<<<<<<<<<<<
15427  *         return self.view.itemsize
15428  *
15429  */
15430 
15431   /* function exit code */
15432   __pyx_L1_error:;
15433   __Pyx_XDECREF(__pyx_t_1);
15434   __Pyx_AddTraceback("View.MemoryView.memoryview.itemsize.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
15435   __pyx_r = NULL;
15436   __pyx_L0:;
15437   __Pyx_XGIVEREF(__pyx_r);
15438   __Pyx_RefNannyFinishContext();
15439   return __pyx_r;
15440 }
15441 
15442 /* "View.MemoryView":590
15443  *
15444  *     @property
15445  *     def nbytes(self):             # <<<<<<<<<<<<<<
15446  *         return self.size * self.view.itemsize
15447  *
15448  */
15449 
15450 /* Python wrapper */
15451 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)15452 static PyObject *__pyx_pw_15View_dot_MemoryView_10memoryview_6nbytes_1__get__(PyObject *__pyx_v_self) {
15453   PyObject *__pyx_r = 0;
15454   __Pyx_RefNannyDeclarations
15455   __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
15456   __pyx_r = __pyx_pf_15View_dot_MemoryView_10memoryview_6nbytes___get__(((struct __pyx_memoryview_obj *)__pyx_v_self));
15457 
15458   /* function exit code */
15459   __Pyx_RefNannyFinishContext();
15460   return __pyx_r;
15461 }
15462 
__pyx_pf_15View_dot_MemoryView_10memoryview_6nbytes___get__(struct __pyx_memoryview_obj * __pyx_v_self)15463 static PyObject *__pyx_pf_15View_dot_MemoryView_10memoryview_6nbytes___get__(struct __pyx_memoryview_obj *__pyx_v_self) {
15464   PyObject *__pyx_r = NULL;
15465   __Pyx_RefNannyDeclarations
15466   PyObject *__pyx_t_1 = NULL;
15467   PyObject *__pyx_t_2 = NULL;
15468   PyObject *__pyx_t_3 = NULL;
15469   int __pyx_lineno = 0;
15470   const char *__pyx_filename = NULL;
15471   int __pyx_clineno = 0;
15472   __Pyx_RefNannySetupContext("__get__", 0);
15473 
15474   /* "View.MemoryView":591
15475  *     @property
15476  *     def nbytes(self):
15477  *         return self.size * self.view.itemsize             # <<<<<<<<<<<<<<
15478  *
15479  *     @property
15480  */
15481   __Pyx_XDECREF(__pyx_r);
15482   __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)
15483   __Pyx_GOTREF(__pyx_t_1);
15484   __pyx_t_2 = PyInt_FromSsize_t(__pyx_v_self->view.itemsize); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 591, __pyx_L1_error)
15485   __Pyx_GOTREF(__pyx_t_2);
15486   __pyx_t_3 = PyNumber_Multiply(__pyx_t_1, __pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 591, __pyx_L1_error)
15487   __Pyx_GOTREF(__pyx_t_3);
15488   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
15489   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
15490   __pyx_r = __pyx_t_3;
15491   __pyx_t_3 = 0;
15492   goto __pyx_L0;
15493 
15494   /* "View.MemoryView":590
15495  *
15496  *     @property
15497  *     def nbytes(self):             # <<<<<<<<<<<<<<
15498  *         return self.size * self.view.itemsize
15499  *
15500  */
15501 
15502   /* function exit code */
15503   __pyx_L1_error:;
15504   __Pyx_XDECREF(__pyx_t_1);
15505   __Pyx_XDECREF(__pyx_t_2);
15506   __Pyx_XDECREF(__pyx_t_3);
15507   __Pyx_AddTraceback("View.MemoryView.memoryview.nbytes.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
15508   __pyx_r = NULL;
15509   __pyx_L0:;
15510   __Pyx_XGIVEREF(__pyx_r);
15511   __Pyx_RefNannyFinishContext();
15512   return __pyx_r;
15513 }
15514 
15515 /* "View.MemoryView":594
15516  *
15517  *     @property
15518  *     def size(self):             # <<<<<<<<<<<<<<
15519  *         if self._size is None:
15520  *             result = 1
15521  */
15522 
15523 /* Python wrapper */
15524 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)15525 static PyObject *__pyx_pw_15View_dot_MemoryView_10memoryview_4size_1__get__(PyObject *__pyx_v_self) {
15526   PyObject *__pyx_r = 0;
15527   __Pyx_RefNannyDeclarations
15528   __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
15529   __pyx_r = __pyx_pf_15View_dot_MemoryView_10memoryview_4size___get__(((struct __pyx_memoryview_obj *)__pyx_v_self));
15530 
15531   /* function exit code */
15532   __Pyx_RefNannyFinishContext();
15533   return __pyx_r;
15534 }
15535 
__pyx_pf_15View_dot_MemoryView_10memoryview_4size___get__(struct __pyx_memoryview_obj * __pyx_v_self)15536 static PyObject *__pyx_pf_15View_dot_MemoryView_10memoryview_4size___get__(struct __pyx_memoryview_obj *__pyx_v_self) {
15537   PyObject *__pyx_v_result = NULL;
15538   PyObject *__pyx_v_length = NULL;
15539   PyObject *__pyx_r = NULL;
15540   __Pyx_RefNannyDeclarations
15541   int __pyx_t_1;
15542   int __pyx_t_2;
15543   Py_ssize_t *__pyx_t_3;
15544   Py_ssize_t *__pyx_t_4;
15545   Py_ssize_t *__pyx_t_5;
15546   PyObject *__pyx_t_6 = NULL;
15547   int __pyx_lineno = 0;
15548   const char *__pyx_filename = NULL;
15549   int __pyx_clineno = 0;
15550   __Pyx_RefNannySetupContext("__get__", 0);
15551 
15552   /* "View.MemoryView":595
15553  *     @property
15554  *     def size(self):
15555  *         if self._size is None:             # <<<<<<<<<<<<<<
15556  *             result = 1
15557  *
15558  */
15559   __pyx_t_1 = (__pyx_v_self->_size == Py_None);
15560   __pyx_t_2 = (__pyx_t_1 != 0);
15561   if (__pyx_t_2) {
15562 
15563     /* "View.MemoryView":596
15564  *     def size(self):
15565  *         if self._size is None:
15566  *             result = 1             # <<<<<<<<<<<<<<
15567  *
15568  *             for length in self.view.shape[:self.view.ndim]:
15569  */
15570     __Pyx_INCREF(__pyx_int_1);
15571     __pyx_v_result = __pyx_int_1;
15572 
15573     /* "View.MemoryView":598
15574  *             result = 1
15575  *
15576  *             for length in self.view.shape[:self.view.ndim]:             # <<<<<<<<<<<<<<
15577  *                 result *= length
15578  *
15579  */
15580     __pyx_t_4 = (__pyx_v_self->view.shape + __pyx_v_self->view.ndim);
15581     for (__pyx_t_5 = __pyx_v_self->view.shape; __pyx_t_5 < __pyx_t_4; __pyx_t_5++) {
15582       __pyx_t_3 = __pyx_t_5;
15583       __pyx_t_6 = PyInt_FromSsize_t((__pyx_t_3[0])); if (unlikely(!__pyx_t_6)) __PYX_ERR(2, 598, __pyx_L1_error)
15584       __Pyx_GOTREF(__pyx_t_6);
15585       __Pyx_XDECREF_SET(__pyx_v_length, __pyx_t_6);
15586       __pyx_t_6 = 0;
15587 
15588       /* "View.MemoryView":599
15589  *
15590  *             for length in self.view.shape[:self.view.ndim]:
15591  *                 result *= length             # <<<<<<<<<<<<<<
15592  *
15593  *             self._size = result
15594  */
15595       __pyx_t_6 = PyNumber_InPlaceMultiply(__pyx_v_result, __pyx_v_length); if (unlikely(!__pyx_t_6)) __PYX_ERR(2, 599, __pyx_L1_error)
15596       __Pyx_GOTREF(__pyx_t_6);
15597       __Pyx_DECREF_SET(__pyx_v_result, __pyx_t_6);
15598       __pyx_t_6 = 0;
15599     }
15600 
15601     /* "View.MemoryView":601
15602  *                 result *= length
15603  *
15604  *             self._size = result             # <<<<<<<<<<<<<<
15605  *
15606  *         return self._size
15607  */
15608     __Pyx_INCREF(__pyx_v_result);
15609     __Pyx_GIVEREF(__pyx_v_result);
15610     __Pyx_GOTREF(__pyx_v_self->_size);
15611     __Pyx_DECREF(__pyx_v_self->_size);
15612     __pyx_v_self->_size = __pyx_v_result;
15613 
15614     /* "View.MemoryView":595
15615  *     @property
15616  *     def size(self):
15617  *         if self._size is None:             # <<<<<<<<<<<<<<
15618  *             result = 1
15619  *
15620  */
15621   }
15622 
15623   /* "View.MemoryView":603
15624  *             self._size = result
15625  *
15626  *         return self._size             # <<<<<<<<<<<<<<
15627  *
15628  *     def __len__(self):
15629  */
15630   __Pyx_XDECREF(__pyx_r);
15631   __Pyx_INCREF(__pyx_v_self->_size);
15632   __pyx_r = __pyx_v_self->_size;
15633   goto __pyx_L0;
15634 
15635   /* "View.MemoryView":594
15636  *
15637  *     @property
15638  *     def size(self):             # <<<<<<<<<<<<<<
15639  *         if self._size is None:
15640  *             result = 1
15641  */
15642 
15643   /* function exit code */
15644   __pyx_L1_error:;
15645   __Pyx_XDECREF(__pyx_t_6);
15646   __Pyx_AddTraceback("View.MemoryView.memoryview.size.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
15647   __pyx_r = NULL;
15648   __pyx_L0:;
15649   __Pyx_XDECREF(__pyx_v_result);
15650   __Pyx_XDECREF(__pyx_v_length);
15651   __Pyx_XGIVEREF(__pyx_r);
15652   __Pyx_RefNannyFinishContext();
15653   return __pyx_r;
15654 }
15655 
15656 /* "View.MemoryView":605
15657  *         return self._size
15658  *
15659  *     def __len__(self):             # <<<<<<<<<<<<<<
15660  *         if self.view.ndim >= 1:
15661  *             return self.view.shape[0]
15662  */
15663 
15664 /* Python wrapper */
15665 static Py_ssize_t __pyx_memoryview___len__(PyObject *__pyx_v_self); /*proto*/
__pyx_memoryview___len__(PyObject * __pyx_v_self)15666 static Py_ssize_t __pyx_memoryview___len__(PyObject *__pyx_v_self) {
15667   Py_ssize_t __pyx_r;
15668   __Pyx_RefNannyDeclarations
15669   __Pyx_RefNannySetupContext("__len__ (wrapper)", 0);
15670   __pyx_r = __pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_10__len__(((struct __pyx_memoryview_obj *)__pyx_v_self));
15671 
15672   /* function exit code */
15673   __Pyx_RefNannyFinishContext();
15674   return __pyx_r;
15675 }
15676 
__pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_10__len__(struct __pyx_memoryview_obj * __pyx_v_self)15677 static Py_ssize_t __pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_10__len__(struct __pyx_memoryview_obj *__pyx_v_self) {
15678   Py_ssize_t __pyx_r;
15679   __Pyx_RefNannyDeclarations
15680   int __pyx_t_1;
15681   __Pyx_RefNannySetupContext("__len__", 0);
15682 
15683   /* "View.MemoryView":606
15684  *
15685  *     def __len__(self):
15686  *         if self.view.ndim >= 1:             # <<<<<<<<<<<<<<
15687  *             return self.view.shape[0]
15688  *
15689  */
15690   __pyx_t_1 = ((__pyx_v_self->view.ndim >= 1) != 0);
15691   if (__pyx_t_1) {
15692 
15693     /* "View.MemoryView":607
15694  *     def __len__(self):
15695  *         if self.view.ndim >= 1:
15696  *             return self.view.shape[0]             # <<<<<<<<<<<<<<
15697  *
15698  *         return 0
15699  */
15700     __pyx_r = (__pyx_v_self->view.shape[0]);
15701     goto __pyx_L0;
15702 
15703     /* "View.MemoryView":606
15704  *
15705  *     def __len__(self):
15706  *         if self.view.ndim >= 1:             # <<<<<<<<<<<<<<
15707  *             return self.view.shape[0]
15708  *
15709  */
15710   }
15711 
15712   /* "View.MemoryView":609
15713  *             return self.view.shape[0]
15714  *
15715  *         return 0             # <<<<<<<<<<<<<<
15716  *
15717  *     def __repr__(self):
15718  */
15719   __pyx_r = 0;
15720   goto __pyx_L0;
15721 
15722   /* "View.MemoryView":605
15723  *         return self._size
15724  *
15725  *     def __len__(self):             # <<<<<<<<<<<<<<
15726  *         if self.view.ndim >= 1:
15727  *             return self.view.shape[0]
15728  */
15729 
15730   /* function exit code */
15731   __pyx_L0:;
15732   __Pyx_RefNannyFinishContext();
15733   return __pyx_r;
15734 }
15735 
15736 /* "View.MemoryView":611
15737  *         return 0
15738  *
15739  *     def __repr__(self):             # <<<<<<<<<<<<<<
15740  *         return "<MemoryView of %r at 0x%x>" % (self.base.__class__.__name__,
15741  *                                                id(self))
15742  */
15743 
15744 /* Python wrapper */
15745 static PyObject *__pyx_memoryview___repr__(PyObject *__pyx_v_self); /*proto*/
__pyx_memoryview___repr__(PyObject * __pyx_v_self)15746 static PyObject *__pyx_memoryview___repr__(PyObject *__pyx_v_self) {
15747   PyObject *__pyx_r = 0;
15748   __Pyx_RefNannyDeclarations
15749   __Pyx_RefNannySetupContext("__repr__ (wrapper)", 0);
15750   __pyx_r = __pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_12__repr__(((struct __pyx_memoryview_obj *)__pyx_v_self));
15751 
15752   /* function exit code */
15753   __Pyx_RefNannyFinishContext();
15754   return __pyx_r;
15755 }
15756 
__pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_12__repr__(struct __pyx_memoryview_obj * __pyx_v_self)15757 static PyObject *__pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_12__repr__(struct __pyx_memoryview_obj *__pyx_v_self) {
15758   PyObject *__pyx_r = NULL;
15759   __Pyx_RefNannyDeclarations
15760   PyObject *__pyx_t_1 = NULL;
15761   PyObject *__pyx_t_2 = NULL;
15762   PyObject *__pyx_t_3 = NULL;
15763   int __pyx_lineno = 0;
15764   const char *__pyx_filename = NULL;
15765   int __pyx_clineno = 0;
15766   __Pyx_RefNannySetupContext("__repr__", 0);
15767 
15768   /* "View.MemoryView":612
15769  *
15770  *     def __repr__(self):
15771  *         return "<MemoryView of %r at 0x%x>" % (self.base.__class__.__name__,             # <<<<<<<<<<<<<<
15772  *                                                id(self))
15773  *
15774  */
15775   __Pyx_XDECREF(__pyx_r);
15776   __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)
15777   __Pyx_GOTREF(__pyx_t_1);
15778   __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)
15779   __Pyx_GOTREF(__pyx_t_2);
15780   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
15781   __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)
15782   __Pyx_GOTREF(__pyx_t_1);
15783   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
15784 
15785   /* "View.MemoryView":613
15786  *     def __repr__(self):
15787  *         return "<MemoryView of %r at 0x%x>" % (self.base.__class__.__name__,
15788  *                                                id(self))             # <<<<<<<<<<<<<<
15789  *
15790  *     def __str__(self):
15791  */
15792   __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)
15793   __Pyx_GOTREF(__pyx_t_2);
15794 
15795   /* "View.MemoryView":612
15796  *
15797  *     def __repr__(self):
15798  *         return "<MemoryView of %r at 0x%x>" % (self.base.__class__.__name__,             # <<<<<<<<<<<<<<
15799  *                                                id(self))
15800  *
15801  */
15802   __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 612, __pyx_L1_error)
15803   __Pyx_GOTREF(__pyx_t_3);
15804   __Pyx_GIVEREF(__pyx_t_1);
15805   PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_1);
15806   __Pyx_GIVEREF(__pyx_t_2);
15807   PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_2);
15808   __pyx_t_1 = 0;
15809   __pyx_t_2 = 0;
15810   __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)
15811   __Pyx_GOTREF(__pyx_t_2);
15812   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
15813   __pyx_r = __pyx_t_2;
15814   __pyx_t_2 = 0;
15815   goto __pyx_L0;
15816 
15817   /* "View.MemoryView":611
15818  *         return 0
15819  *
15820  *     def __repr__(self):             # <<<<<<<<<<<<<<
15821  *         return "<MemoryView of %r at 0x%x>" % (self.base.__class__.__name__,
15822  *                                                id(self))
15823  */
15824 
15825   /* function exit code */
15826   __pyx_L1_error:;
15827   __Pyx_XDECREF(__pyx_t_1);
15828   __Pyx_XDECREF(__pyx_t_2);
15829   __Pyx_XDECREF(__pyx_t_3);
15830   __Pyx_AddTraceback("View.MemoryView.memoryview.__repr__", __pyx_clineno, __pyx_lineno, __pyx_filename);
15831   __pyx_r = NULL;
15832   __pyx_L0:;
15833   __Pyx_XGIVEREF(__pyx_r);
15834   __Pyx_RefNannyFinishContext();
15835   return __pyx_r;
15836 }
15837 
15838 /* "View.MemoryView":615
15839  *                                                id(self))
15840  *
15841  *     def __str__(self):             # <<<<<<<<<<<<<<
15842  *         return "<MemoryView of %r object>" % (self.base.__class__.__name__,)
15843  *
15844  */
15845 
15846 /* Python wrapper */
15847 static PyObject *__pyx_memoryview___str__(PyObject *__pyx_v_self); /*proto*/
__pyx_memoryview___str__(PyObject * __pyx_v_self)15848 static PyObject *__pyx_memoryview___str__(PyObject *__pyx_v_self) {
15849   PyObject *__pyx_r = 0;
15850   __Pyx_RefNannyDeclarations
15851   __Pyx_RefNannySetupContext("__str__ (wrapper)", 0);
15852   __pyx_r = __pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_14__str__(((struct __pyx_memoryview_obj *)__pyx_v_self));
15853 
15854   /* function exit code */
15855   __Pyx_RefNannyFinishContext();
15856   return __pyx_r;
15857 }
15858 
__pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_14__str__(struct __pyx_memoryview_obj * __pyx_v_self)15859 static PyObject *__pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_14__str__(struct __pyx_memoryview_obj *__pyx_v_self) {
15860   PyObject *__pyx_r = NULL;
15861   __Pyx_RefNannyDeclarations
15862   PyObject *__pyx_t_1 = NULL;
15863   PyObject *__pyx_t_2 = NULL;
15864   int __pyx_lineno = 0;
15865   const char *__pyx_filename = NULL;
15866   int __pyx_clineno = 0;
15867   __Pyx_RefNannySetupContext("__str__", 0);
15868 
15869   /* "View.MemoryView":616
15870  *
15871  *     def __str__(self):
15872  *         return "<MemoryView of %r object>" % (self.base.__class__.__name__,)             # <<<<<<<<<<<<<<
15873  *
15874  *
15875  */
15876   __Pyx_XDECREF(__pyx_r);
15877   __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)
15878   __Pyx_GOTREF(__pyx_t_1);
15879   __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)
15880   __Pyx_GOTREF(__pyx_t_2);
15881   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
15882   __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)
15883   __Pyx_GOTREF(__pyx_t_1);
15884   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
15885   __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 616, __pyx_L1_error)
15886   __Pyx_GOTREF(__pyx_t_2);
15887   __Pyx_GIVEREF(__pyx_t_1);
15888   PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_1);
15889   __pyx_t_1 = 0;
15890   __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)
15891   __Pyx_GOTREF(__pyx_t_1);
15892   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
15893   __pyx_r = __pyx_t_1;
15894   __pyx_t_1 = 0;
15895   goto __pyx_L0;
15896 
15897   /* "View.MemoryView":615
15898  *                                                id(self))
15899  *
15900  *     def __str__(self):             # <<<<<<<<<<<<<<
15901  *         return "<MemoryView of %r object>" % (self.base.__class__.__name__,)
15902  *
15903  */
15904 
15905   /* function exit code */
15906   __pyx_L1_error:;
15907   __Pyx_XDECREF(__pyx_t_1);
15908   __Pyx_XDECREF(__pyx_t_2);
15909   __Pyx_AddTraceback("View.MemoryView.memoryview.__str__", __pyx_clineno, __pyx_lineno, __pyx_filename);
15910   __pyx_r = NULL;
15911   __pyx_L0:;
15912   __Pyx_XGIVEREF(__pyx_r);
15913   __Pyx_RefNannyFinishContext();
15914   return __pyx_r;
15915 }
15916 
15917 /* "View.MemoryView":619
15918  *
15919  *
15920  *     def is_c_contig(self):             # <<<<<<<<<<<<<<
15921  *         cdef __Pyx_memviewslice *mslice
15922  *         cdef __Pyx_memviewslice tmp
15923  */
15924 
15925 /* Python wrapper */
15926 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)15927 static PyObject *__pyx_memoryview_is_c_contig(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
15928   PyObject *__pyx_r = 0;
15929   __Pyx_RefNannyDeclarations
15930   __Pyx_RefNannySetupContext("is_c_contig (wrapper)", 0);
15931   __pyx_r = __pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_16is_c_contig(((struct __pyx_memoryview_obj *)__pyx_v_self));
15932 
15933   /* function exit code */
15934   __Pyx_RefNannyFinishContext();
15935   return __pyx_r;
15936 }
15937 
__pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_16is_c_contig(struct __pyx_memoryview_obj * __pyx_v_self)15938 static PyObject *__pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_16is_c_contig(struct __pyx_memoryview_obj *__pyx_v_self) {
15939   __Pyx_memviewslice *__pyx_v_mslice;
15940   __Pyx_memviewslice __pyx_v_tmp;
15941   PyObject *__pyx_r = NULL;
15942   __Pyx_RefNannyDeclarations
15943   __Pyx_memviewslice *__pyx_t_1;
15944   PyObject *__pyx_t_2 = NULL;
15945   int __pyx_lineno = 0;
15946   const char *__pyx_filename = NULL;
15947   int __pyx_clineno = 0;
15948   __Pyx_RefNannySetupContext("is_c_contig", 0);
15949 
15950   /* "View.MemoryView":622
15951  *         cdef __Pyx_memviewslice *mslice
15952  *         cdef __Pyx_memviewslice tmp
15953  *         mslice = get_slice_from_memview(self, &tmp)             # <<<<<<<<<<<<<<
15954  *         return slice_is_contig(mslice[0], 'C', self.view.ndim)
15955  *
15956  */
15957   __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)
15958   __pyx_v_mslice = __pyx_t_1;
15959 
15960   /* "View.MemoryView":623
15961  *         cdef __Pyx_memviewslice tmp
15962  *         mslice = get_slice_from_memview(self, &tmp)
15963  *         return slice_is_contig(mslice[0], 'C', self.view.ndim)             # <<<<<<<<<<<<<<
15964  *
15965  *     def is_f_contig(self):
15966  */
15967   __Pyx_XDECREF(__pyx_r);
15968   __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)
15969   __Pyx_GOTREF(__pyx_t_2);
15970   __pyx_r = __pyx_t_2;
15971   __pyx_t_2 = 0;
15972   goto __pyx_L0;
15973 
15974   /* "View.MemoryView":619
15975  *
15976  *
15977  *     def is_c_contig(self):             # <<<<<<<<<<<<<<
15978  *         cdef __Pyx_memviewslice *mslice
15979  *         cdef __Pyx_memviewslice tmp
15980  */
15981 
15982   /* function exit code */
15983   __pyx_L1_error:;
15984   __Pyx_XDECREF(__pyx_t_2);
15985   __Pyx_AddTraceback("View.MemoryView.memoryview.is_c_contig", __pyx_clineno, __pyx_lineno, __pyx_filename);
15986   __pyx_r = NULL;
15987   __pyx_L0:;
15988   __Pyx_XGIVEREF(__pyx_r);
15989   __Pyx_RefNannyFinishContext();
15990   return __pyx_r;
15991 }
15992 
15993 /* "View.MemoryView":625
15994  *         return slice_is_contig(mslice[0], 'C', self.view.ndim)
15995  *
15996  *     def is_f_contig(self):             # <<<<<<<<<<<<<<
15997  *         cdef __Pyx_memviewslice *mslice
15998  *         cdef __Pyx_memviewslice tmp
15999  */
16000 
16001 /* Python wrapper */
16002 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)16003 static PyObject *__pyx_memoryview_is_f_contig(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
16004   PyObject *__pyx_r = 0;
16005   __Pyx_RefNannyDeclarations
16006   __Pyx_RefNannySetupContext("is_f_contig (wrapper)", 0);
16007   __pyx_r = __pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_18is_f_contig(((struct __pyx_memoryview_obj *)__pyx_v_self));
16008 
16009   /* function exit code */
16010   __Pyx_RefNannyFinishContext();
16011   return __pyx_r;
16012 }
16013 
__pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_18is_f_contig(struct __pyx_memoryview_obj * __pyx_v_self)16014 static PyObject *__pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_18is_f_contig(struct __pyx_memoryview_obj *__pyx_v_self) {
16015   __Pyx_memviewslice *__pyx_v_mslice;
16016   __Pyx_memviewslice __pyx_v_tmp;
16017   PyObject *__pyx_r = NULL;
16018   __Pyx_RefNannyDeclarations
16019   __Pyx_memviewslice *__pyx_t_1;
16020   PyObject *__pyx_t_2 = NULL;
16021   int __pyx_lineno = 0;
16022   const char *__pyx_filename = NULL;
16023   int __pyx_clineno = 0;
16024   __Pyx_RefNannySetupContext("is_f_contig", 0);
16025 
16026   /* "View.MemoryView":628
16027  *         cdef __Pyx_memviewslice *mslice
16028  *         cdef __Pyx_memviewslice tmp
16029  *         mslice = get_slice_from_memview(self, &tmp)             # <<<<<<<<<<<<<<
16030  *         return slice_is_contig(mslice[0], 'F', self.view.ndim)
16031  *
16032  */
16033   __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)
16034   __pyx_v_mslice = __pyx_t_1;
16035 
16036   /* "View.MemoryView":629
16037  *         cdef __Pyx_memviewslice tmp
16038  *         mslice = get_slice_from_memview(self, &tmp)
16039  *         return slice_is_contig(mslice[0], 'F', self.view.ndim)             # <<<<<<<<<<<<<<
16040  *
16041  *     def copy(self):
16042  */
16043   __Pyx_XDECREF(__pyx_r);
16044   __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)
16045   __Pyx_GOTREF(__pyx_t_2);
16046   __pyx_r = __pyx_t_2;
16047   __pyx_t_2 = 0;
16048   goto __pyx_L0;
16049 
16050   /* "View.MemoryView":625
16051  *         return slice_is_contig(mslice[0], 'C', self.view.ndim)
16052  *
16053  *     def is_f_contig(self):             # <<<<<<<<<<<<<<
16054  *         cdef __Pyx_memviewslice *mslice
16055  *         cdef __Pyx_memviewslice tmp
16056  */
16057 
16058   /* function exit code */
16059   __pyx_L1_error:;
16060   __Pyx_XDECREF(__pyx_t_2);
16061   __Pyx_AddTraceback("View.MemoryView.memoryview.is_f_contig", __pyx_clineno, __pyx_lineno, __pyx_filename);
16062   __pyx_r = NULL;
16063   __pyx_L0:;
16064   __Pyx_XGIVEREF(__pyx_r);
16065   __Pyx_RefNannyFinishContext();
16066   return __pyx_r;
16067 }
16068 
16069 /* "View.MemoryView":631
16070  *         return slice_is_contig(mslice[0], 'F', self.view.ndim)
16071  *
16072  *     def copy(self):             # <<<<<<<<<<<<<<
16073  *         cdef __Pyx_memviewslice mslice
16074  *         cdef int flags = self.flags & ~PyBUF_F_CONTIGUOUS
16075  */
16076 
16077 /* Python wrapper */
16078 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)16079 static PyObject *__pyx_memoryview_copy(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
16080   PyObject *__pyx_r = 0;
16081   __Pyx_RefNannyDeclarations
16082   __Pyx_RefNannySetupContext("copy (wrapper)", 0);
16083   __pyx_r = __pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_20copy(((struct __pyx_memoryview_obj *)__pyx_v_self));
16084 
16085   /* function exit code */
16086   __Pyx_RefNannyFinishContext();
16087   return __pyx_r;
16088 }
16089 
__pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_20copy(struct __pyx_memoryview_obj * __pyx_v_self)16090 static PyObject *__pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_20copy(struct __pyx_memoryview_obj *__pyx_v_self) {
16091   __Pyx_memviewslice __pyx_v_mslice;
16092   int __pyx_v_flags;
16093   PyObject *__pyx_r = NULL;
16094   __Pyx_RefNannyDeclarations
16095   __Pyx_memviewslice __pyx_t_1;
16096   PyObject *__pyx_t_2 = NULL;
16097   int __pyx_lineno = 0;
16098   const char *__pyx_filename = NULL;
16099   int __pyx_clineno = 0;
16100   __Pyx_RefNannySetupContext("copy", 0);
16101 
16102   /* "View.MemoryView":633
16103  *     def copy(self):
16104  *         cdef __Pyx_memviewslice mslice
16105  *         cdef int flags = self.flags & ~PyBUF_F_CONTIGUOUS             # <<<<<<<<<<<<<<
16106  *
16107  *         slice_copy(self, &mslice)
16108  */
16109   __pyx_v_flags = (__pyx_v_self->flags & (~PyBUF_F_CONTIGUOUS));
16110 
16111   /* "View.MemoryView":635
16112  *         cdef int flags = self.flags & ~PyBUF_F_CONTIGUOUS
16113  *
16114  *         slice_copy(self, &mslice)             # <<<<<<<<<<<<<<
16115  *         mslice = slice_copy_contig(&mslice, "c", self.view.ndim,
16116  *                                    self.view.itemsize,
16117  */
16118   __pyx_memoryview_slice_copy(__pyx_v_self, (&__pyx_v_mslice));
16119 
16120   /* "View.MemoryView":636
16121  *
16122  *         slice_copy(self, &mslice)
16123  *         mslice = slice_copy_contig(&mslice, "c", self.view.ndim,             # <<<<<<<<<<<<<<
16124  *                                    self.view.itemsize,
16125  *                                    flags|PyBUF_C_CONTIGUOUS,
16126  */
16127   __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)
16128   __pyx_v_mslice = __pyx_t_1;
16129 
16130   /* "View.MemoryView":641
16131  *                                    self.dtype_is_object)
16132  *
16133  *         return memoryview_copy_from_slice(self, &mslice)             # <<<<<<<<<<<<<<
16134  *
16135  *     def copy_fortran(self):
16136  */
16137   __Pyx_XDECREF(__pyx_r);
16138   __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)
16139   __Pyx_GOTREF(__pyx_t_2);
16140   __pyx_r = __pyx_t_2;
16141   __pyx_t_2 = 0;
16142   goto __pyx_L0;
16143 
16144   /* "View.MemoryView":631
16145  *         return slice_is_contig(mslice[0], 'F', self.view.ndim)
16146  *
16147  *     def copy(self):             # <<<<<<<<<<<<<<
16148  *         cdef __Pyx_memviewslice mslice
16149  *         cdef int flags = self.flags & ~PyBUF_F_CONTIGUOUS
16150  */
16151 
16152   /* function exit code */
16153   __pyx_L1_error:;
16154   __Pyx_XDECREF(__pyx_t_2);
16155   __Pyx_AddTraceback("View.MemoryView.memoryview.copy", __pyx_clineno, __pyx_lineno, __pyx_filename);
16156   __pyx_r = NULL;
16157   __pyx_L0:;
16158   __Pyx_XGIVEREF(__pyx_r);
16159   __Pyx_RefNannyFinishContext();
16160   return __pyx_r;
16161 }
16162 
16163 /* "View.MemoryView":643
16164  *         return memoryview_copy_from_slice(self, &mslice)
16165  *
16166  *     def copy_fortran(self):             # <<<<<<<<<<<<<<
16167  *         cdef __Pyx_memviewslice src, dst
16168  *         cdef int flags = self.flags & ~PyBUF_C_CONTIGUOUS
16169  */
16170 
16171 /* Python wrapper */
16172 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)16173 static PyObject *__pyx_memoryview_copy_fortran(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
16174   PyObject *__pyx_r = 0;
16175   __Pyx_RefNannyDeclarations
16176   __Pyx_RefNannySetupContext("copy_fortran (wrapper)", 0);
16177   __pyx_r = __pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_22copy_fortran(((struct __pyx_memoryview_obj *)__pyx_v_self));
16178 
16179   /* function exit code */
16180   __Pyx_RefNannyFinishContext();
16181   return __pyx_r;
16182 }
16183 
__pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_22copy_fortran(struct __pyx_memoryview_obj * __pyx_v_self)16184 static PyObject *__pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_22copy_fortran(struct __pyx_memoryview_obj *__pyx_v_self) {
16185   __Pyx_memviewslice __pyx_v_src;
16186   __Pyx_memviewslice __pyx_v_dst;
16187   int __pyx_v_flags;
16188   PyObject *__pyx_r = NULL;
16189   __Pyx_RefNannyDeclarations
16190   __Pyx_memviewslice __pyx_t_1;
16191   PyObject *__pyx_t_2 = NULL;
16192   int __pyx_lineno = 0;
16193   const char *__pyx_filename = NULL;
16194   int __pyx_clineno = 0;
16195   __Pyx_RefNannySetupContext("copy_fortran", 0);
16196 
16197   /* "View.MemoryView":645
16198  *     def copy_fortran(self):
16199  *         cdef __Pyx_memviewslice src, dst
16200  *         cdef int flags = self.flags & ~PyBUF_C_CONTIGUOUS             # <<<<<<<<<<<<<<
16201  *
16202  *         slice_copy(self, &src)
16203  */
16204   __pyx_v_flags = (__pyx_v_self->flags & (~PyBUF_C_CONTIGUOUS));
16205 
16206   /* "View.MemoryView":647
16207  *         cdef int flags = self.flags & ~PyBUF_C_CONTIGUOUS
16208  *
16209  *         slice_copy(self, &src)             # <<<<<<<<<<<<<<
16210  *         dst = slice_copy_contig(&src, "fortran", self.view.ndim,
16211  *                                 self.view.itemsize,
16212  */
16213   __pyx_memoryview_slice_copy(__pyx_v_self, (&__pyx_v_src));
16214 
16215   /* "View.MemoryView":648
16216  *
16217  *         slice_copy(self, &src)
16218  *         dst = slice_copy_contig(&src, "fortran", self.view.ndim,             # <<<<<<<<<<<<<<
16219  *                                 self.view.itemsize,
16220  *                                 flags|PyBUF_F_CONTIGUOUS,
16221  */
16222   __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)
16223   __pyx_v_dst = __pyx_t_1;
16224 
16225   /* "View.MemoryView":653
16226  *                                 self.dtype_is_object)
16227  *
16228  *         return memoryview_copy_from_slice(self, &dst)             # <<<<<<<<<<<<<<
16229  *
16230  *
16231  */
16232   __Pyx_XDECREF(__pyx_r);
16233   __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)
16234   __Pyx_GOTREF(__pyx_t_2);
16235   __pyx_r = __pyx_t_2;
16236   __pyx_t_2 = 0;
16237   goto __pyx_L0;
16238 
16239   /* "View.MemoryView":643
16240  *         return memoryview_copy_from_slice(self, &mslice)
16241  *
16242  *     def copy_fortran(self):             # <<<<<<<<<<<<<<
16243  *         cdef __Pyx_memviewslice src, dst
16244  *         cdef int flags = self.flags & ~PyBUF_C_CONTIGUOUS
16245  */
16246 
16247   /* function exit code */
16248   __pyx_L1_error:;
16249   __Pyx_XDECREF(__pyx_t_2);
16250   __Pyx_AddTraceback("View.MemoryView.memoryview.copy_fortran", __pyx_clineno, __pyx_lineno, __pyx_filename);
16251   __pyx_r = NULL;
16252   __pyx_L0:;
16253   __Pyx_XGIVEREF(__pyx_r);
16254   __Pyx_RefNannyFinishContext();
16255   return __pyx_r;
16256 }
16257 
16258 /* "(tree fragment)":1
16259  * def __reduce_cython__(self):             # <<<<<<<<<<<<<<
16260  *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
16261  * def __setstate_cython__(self, __pyx_state):
16262  */
16263 
16264 /* Python wrapper */
16265 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)16266 static PyObject *__pyx_pw___pyx_memoryview_1__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
16267   PyObject *__pyx_r = 0;
16268   __Pyx_RefNannyDeclarations
16269   __Pyx_RefNannySetupContext("__reduce_cython__ (wrapper)", 0);
16270   __pyx_r = __pyx_pf___pyx_memoryview___reduce_cython__(((struct __pyx_memoryview_obj *)__pyx_v_self));
16271 
16272   /* function exit code */
16273   __Pyx_RefNannyFinishContext();
16274   return __pyx_r;
16275 }
16276 
__pyx_pf___pyx_memoryview___reduce_cython__(CYTHON_UNUSED struct __pyx_memoryview_obj * __pyx_v_self)16277 static PyObject *__pyx_pf___pyx_memoryview___reduce_cython__(CYTHON_UNUSED struct __pyx_memoryview_obj *__pyx_v_self) {
16278   PyObject *__pyx_r = NULL;
16279   __Pyx_RefNannyDeclarations
16280   PyObject *__pyx_t_1 = NULL;
16281   int __pyx_lineno = 0;
16282   const char *__pyx_filename = NULL;
16283   int __pyx_clineno = 0;
16284   __Pyx_RefNannySetupContext("__reduce_cython__", 0);
16285 
16286   /* "(tree fragment)":2
16287  * def __reduce_cython__(self):
16288  *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")             # <<<<<<<<<<<<<<
16289  * def __setstate_cython__(self, __pyx_state):
16290  *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
16291  */
16292   __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__15, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 2, __pyx_L1_error)
16293   __Pyx_GOTREF(__pyx_t_1);
16294   __Pyx_Raise(__pyx_t_1, 0, 0, 0);
16295   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
16296   __PYX_ERR(2, 2, __pyx_L1_error)
16297 
16298   /* "(tree fragment)":1
16299  * def __reduce_cython__(self):             # <<<<<<<<<<<<<<
16300  *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
16301  * def __setstate_cython__(self, __pyx_state):
16302  */
16303 
16304   /* function exit code */
16305   __pyx_L1_error:;
16306   __Pyx_XDECREF(__pyx_t_1);
16307   __Pyx_AddTraceback("View.MemoryView.memoryview.__reduce_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename);
16308   __pyx_r = NULL;
16309   __Pyx_XGIVEREF(__pyx_r);
16310   __Pyx_RefNannyFinishContext();
16311   return __pyx_r;
16312 }
16313 
16314 /* "(tree fragment)":3
16315  * def __reduce_cython__(self):
16316  *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
16317  * def __setstate_cython__(self, __pyx_state):             # <<<<<<<<<<<<<<
16318  *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
16319  */
16320 
16321 /* Python wrapper */
16322 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)16323 static PyObject *__pyx_pw___pyx_memoryview_3__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state) {
16324   PyObject *__pyx_r = 0;
16325   __Pyx_RefNannyDeclarations
16326   __Pyx_RefNannySetupContext("__setstate_cython__ (wrapper)", 0);
16327   __pyx_r = __pyx_pf___pyx_memoryview_2__setstate_cython__(((struct __pyx_memoryview_obj *)__pyx_v_self), ((PyObject *)__pyx_v___pyx_state));
16328 
16329   /* function exit code */
16330   __Pyx_RefNannyFinishContext();
16331   return __pyx_r;
16332 }
16333 
__pyx_pf___pyx_memoryview_2__setstate_cython__(CYTHON_UNUSED struct __pyx_memoryview_obj * __pyx_v_self,CYTHON_UNUSED PyObject * __pyx_v___pyx_state)16334 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) {
16335   PyObject *__pyx_r = NULL;
16336   __Pyx_RefNannyDeclarations
16337   PyObject *__pyx_t_1 = NULL;
16338   int __pyx_lineno = 0;
16339   const char *__pyx_filename = NULL;
16340   int __pyx_clineno = 0;
16341   __Pyx_RefNannySetupContext("__setstate_cython__", 0);
16342 
16343   /* "(tree fragment)":4
16344  *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
16345  * def __setstate_cython__(self, __pyx_state):
16346  *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")             # <<<<<<<<<<<<<<
16347  */
16348   __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__16, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 4, __pyx_L1_error)
16349   __Pyx_GOTREF(__pyx_t_1);
16350   __Pyx_Raise(__pyx_t_1, 0, 0, 0);
16351   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
16352   __PYX_ERR(2, 4, __pyx_L1_error)
16353 
16354   /* "(tree fragment)":3
16355  * def __reduce_cython__(self):
16356  *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
16357  * def __setstate_cython__(self, __pyx_state):             # <<<<<<<<<<<<<<
16358  *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
16359  */
16360 
16361   /* function exit code */
16362   __pyx_L1_error:;
16363   __Pyx_XDECREF(__pyx_t_1);
16364   __Pyx_AddTraceback("View.MemoryView.memoryview.__setstate_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename);
16365   __pyx_r = NULL;
16366   __Pyx_XGIVEREF(__pyx_r);
16367   __Pyx_RefNannyFinishContext();
16368   return __pyx_r;
16369 }
16370 
16371 /* "View.MemoryView":657
16372  *
16373  * @cname('__pyx_memoryview_new')
16374  * cdef memoryview_cwrapper(object o, int flags, bint dtype_is_object, __Pyx_TypeInfo *typeinfo):             # <<<<<<<<<<<<<<
16375  *     cdef memoryview result = memoryview(o, flags, dtype_is_object)
16376  *     result.typeinfo = typeinfo
16377  */
16378 
__pyx_memoryview_new(PyObject * __pyx_v_o,int __pyx_v_flags,int __pyx_v_dtype_is_object,__Pyx_TypeInfo * __pyx_v_typeinfo)16379 static PyObject *__pyx_memoryview_new(PyObject *__pyx_v_o, int __pyx_v_flags, int __pyx_v_dtype_is_object, __Pyx_TypeInfo *__pyx_v_typeinfo) {
16380   struct __pyx_memoryview_obj *__pyx_v_result = 0;
16381   PyObject *__pyx_r = NULL;
16382   __Pyx_RefNannyDeclarations
16383   PyObject *__pyx_t_1 = NULL;
16384   PyObject *__pyx_t_2 = NULL;
16385   PyObject *__pyx_t_3 = NULL;
16386   int __pyx_lineno = 0;
16387   const char *__pyx_filename = NULL;
16388   int __pyx_clineno = 0;
16389   __Pyx_RefNannySetupContext("memoryview_cwrapper", 0);
16390 
16391   /* "View.MemoryView":658
16392  * @cname('__pyx_memoryview_new')
16393  * cdef memoryview_cwrapper(object o, int flags, bint dtype_is_object, __Pyx_TypeInfo *typeinfo):
16394  *     cdef memoryview result = memoryview(o, flags, dtype_is_object)             # <<<<<<<<<<<<<<
16395  *     result.typeinfo = typeinfo
16396  *     return result
16397  */
16398   __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_flags); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 658, __pyx_L1_error)
16399   __Pyx_GOTREF(__pyx_t_1);
16400   __pyx_t_2 = __Pyx_PyBool_FromLong(__pyx_v_dtype_is_object); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 658, __pyx_L1_error)
16401   __Pyx_GOTREF(__pyx_t_2);
16402   __pyx_t_3 = PyTuple_New(3); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 658, __pyx_L1_error)
16403   __Pyx_GOTREF(__pyx_t_3);
16404   __Pyx_INCREF(__pyx_v_o);
16405   __Pyx_GIVEREF(__pyx_v_o);
16406   PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_o);
16407   __Pyx_GIVEREF(__pyx_t_1);
16408   PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_1);
16409   __Pyx_GIVEREF(__pyx_t_2);
16410   PyTuple_SET_ITEM(__pyx_t_3, 2, __pyx_t_2);
16411   __pyx_t_1 = 0;
16412   __pyx_t_2 = 0;
16413   __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)
16414   __Pyx_GOTREF(__pyx_t_2);
16415   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
16416   __pyx_v_result = ((struct __pyx_memoryview_obj *)__pyx_t_2);
16417   __pyx_t_2 = 0;
16418 
16419   /* "View.MemoryView":659
16420  * cdef memoryview_cwrapper(object o, int flags, bint dtype_is_object, __Pyx_TypeInfo *typeinfo):
16421  *     cdef memoryview result = memoryview(o, flags, dtype_is_object)
16422  *     result.typeinfo = typeinfo             # <<<<<<<<<<<<<<
16423  *     return result
16424  *
16425  */
16426   __pyx_v_result->typeinfo = __pyx_v_typeinfo;
16427 
16428   /* "View.MemoryView":660
16429  *     cdef memoryview result = memoryview(o, flags, dtype_is_object)
16430  *     result.typeinfo = typeinfo
16431  *     return result             # <<<<<<<<<<<<<<
16432  *
16433  * @cname('__pyx_memoryview_check')
16434  */
16435   __Pyx_XDECREF(__pyx_r);
16436   __Pyx_INCREF(((PyObject *)__pyx_v_result));
16437   __pyx_r = ((PyObject *)__pyx_v_result);
16438   goto __pyx_L0;
16439 
16440   /* "View.MemoryView":657
16441  *
16442  * @cname('__pyx_memoryview_new')
16443  * cdef memoryview_cwrapper(object o, int flags, bint dtype_is_object, __Pyx_TypeInfo *typeinfo):             # <<<<<<<<<<<<<<
16444  *     cdef memoryview result = memoryview(o, flags, dtype_is_object)
16445  *     result.typeinfo = typeinfo
16446  */
16447 
16448   /* function exit code */
16449   __pyx_L1_error:;
16450   __Pyx_XDECREF(__pyx_t_1);
16451   __Pyx_XDECREF(__pyx_t_2);
16452   __Pyx_XDECREF(__pyx_t_3);
16453   __Pyx_AddTraceback("View.MemoryView.memoryview_cwrapper", __pyx_clineno, __pyx_lineno, __pyx_filename);
16454   __pyx_r = 0;
16455   __pyx_L0:;
16456   __Pyx_XDECREF((PyObject *)__pyx_v_result);
16457   __Pyx_XGIVEREF(__pyx_r);
16458   __Pyx_RefNannyFinishContext();
16459   return __pyx_r;
16460 }
16461 
16462 /* "View.MemoryView":663
16463  *
16464  * @cname('__pyx_memoryview_check')
16465  * cdef inline bint memoryview_check(object o):             # <<<<<<<<<<<<<<
16466  *     return isinstance(o, memoryview)
16467  *
16468  */
16469 
__pyx_memoryview_check(PyObject * __pyx_v_o)16470 static CYTHON_INLINE int __pyx_memoryview_check(PyObject *__pyx_v_o) {
16471   int __pyx_r;
16472   __Pyx_RefNannyDeclarations
16473   int __pyx_t_1;
16474   __Pyx_RefNannySetupContext("memoryview_check", 0);
16475 
16476   /* "View.MemoryView":664
16477  * @cname('__pyx_memoryview_check')
16478  * cdef inline bint memoryview_check(object o):
16479  *     return isinstance(o, memoryview)             # <<<<<<<<<<<<<<
16480  *
16481  * cdef tuple _unellipsify(object index, int ndim):
16482  */
16483   __pyx_t_1 = __Pyx_TypeCheck(__pyx_v_o, __pyx_memoryview_type);
16484   __pyx_r = __pyx_t_1;
16485   goto __pyx_L0;
16486 
16487   /* "View.MemoryView":663
16488  *
16489  * @cname('__pyx_memoryview_check')
16490  * cdef inline bint memoryview_check(object o):             # <<<<<<<<<<<<<<
16491  *     return isinstance(o, memoryview)
16492  *
16493  */
16494 
16495   /* function exit code */
16496   __pyx_L0:;
16497   __Pyx_RefNannyFinishContext();
16498   return __pyx_r;
16499 }
16500 
16501 /* "View.MemoryView":666
16502  *     return isinstance(o, memoryview)
16503  *
16504  * cdef tuple _unellipsify(object index, int ndim):             # <<<<<<<<<<<<<<
16505  *     """
16506  *     Replace all ellipses with full slices and fill incomplete indices with
16507  */
16508 
_unellipsify(PyObject * __pyx_v_index,int __pyx_v_ndim)16509 static PyObject *_unellipsify(PyObject *__pyx_v_index, int __pyx_v_ndim) {
16510   PyObject *__pyx_v_tup = NULL;
16511   PyObject *__pyx_v_result = NULL;
16512   int __pyx_v_have_slices;
16513   int __pyx_v_seen_ellipsis;
16514   CYTHON_UNUSED PyObject *__pyx_v_idx = NULL;
16515   PyObject *__pyx_v_item = NULL;
16516   Py_ssize_t __pyx_v_nslices;
16517   PyObject *__pyx_r = NULL;
16518   __Pyx_RefNannyDeclarations
16519   int __pyx_t_1;
16520   int __pyx_t_2;
16521   PyObject *__pyx_t_3 = NULL;
16522   PyObject *__pyx_t_4 = NULL;
16523   Py_ssize_t __pyx_t_5;
16524   PyObject *(*__pyx_t_6)(PyObject *);
16525   PyObject *__pyx_t_7 = NULL;
16526   Py_ssize_t __pyx_t_8;
16527   int __pyx_t_9;
16528   int __pyx_t_10;
16529   PyObject *__pyx_t_11 = NULL;
16530   int __pyx_lineno = 0;
16531   const char *__pyx_filename = NULL;
16532   int __pyx_clineno = 0;
16533   __Pyx_RefNannySetupContext("_unellipsify", 0);
16534 
16535   /* "View.MemoryView":671
16536  *     full slices.
16537  *     """
16538  *     if not isinstance(index, tuple):             # <<<<<<<<<<<<<<
16539  *         tup = (index,)
16540  *     else:
16541  */
16542   __pyx_t_1 = PyTuple_Check(__pyx_v_index);
16543   __pyx_t_2 = ((!(__pyx_t_1 != 0)) != 0);
16544   if (__pyx_t_2) {
16545 
16546     /* "View.MemoryView":672
16547  *     """
16548  *     if not isinstance(index, tuple):
16549  *         tup = (index,)             # <<<<<<<<<<<<<<
16550  *     else:
16551  *         tup = index
16552  */
16553     __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 672, __pyx_L1_error)
16554     __Pyx_GOTREF(__pyx_t_3);
16555     __Pyx_INCREF(__pyx_v_index);
16556     __Pyx_GIVEREF(__pyx_v_index);
16557     PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_index);
16558     __pyx_v_tup = __pyx_t_3;
16559     __pyx_t_3 = 0;
16560 
16561     /* "View.MemoryView":671
16562  *     full slices.
16563  *     """
16564  *     if not isinstance(index, tuple):             # <<<<<<<<<<<<<<
16565  *         tup = (index,)
16566  *     else:
16567  */
16568     goto __pyx_L3;
16569   }
16570 
16571   /* "View.MemoryView":674
16572  *         tup = (index,)
16573  *     else:
16574  *         tup = index             # <<<<<<<<<<<<<<
16575  *
16576  *     result = []
16577  */
16578   /*else*/ {
16579     __Pyx_INCREF(__pyx_v_index);
16580     __pyx_v_tup = __pyx_v_index;
16581   }
16582   __pyx_L3:;
16583 
16584   /* "View.MemoryView":676
16585  *         tup = index
16586  *
16587  *     result = []             # <<<<<<<<<<<<<<
16588  *     have_slices = False
16589  *     seen_ellipsis = False
16590  */
16591   __pyx_t_3 = PyList_New(0); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 676, __pyx_L1_error)
16592   __Pyx_GOTREF(__pyx_t_3);
16593   __pyx_v_result = ((PyObject*)__pyx_t_3);
16594   __pyx_t_3 = 0;
16595 
16596   /* "View.MemoryView":677
16597  *
16598  *     result = []
16599  *     have_slices = False             # <<<<<<<<<<<<<<
16600  *     seen_ellipsis = False
16601  *     for idx, item in enumerate(tup):
16602  */
16603   __pyx_v_have_slices = 0;
16604 
16605   /* "View.MemoryView":678
16606  *     result = []
16607  *     have_slices = False
16608  *     seen_ellipsis = False             # <<<<<<<<<<<<<<
16609  *     for idx, item in enumerate(tup):
16610  *         if item is Ellipsis:
16611  */
16612   __pyx_v_seen_ellipsis = 0;
16613 
16614   /* "View.MemoryView":679
16615  *     have_slices = False
16616  *     seen_ellipsis = False
16617  *     for idx, item in enumerate(tup):             # <<<<<<<<<<<<<<
16618  *         if item is Ellipsis:
16619  *             if not seen_ellipsis:
16620  */
16621   __Pyx_INCREF(__pyx_int_0);
16622   __pyx_t_3 = __pyx_int_0;
16623   if (likely(PyList_CheckExact(__pyx_v_tup)) || PyTuple_CheckExact(__pyx_v_tup)) {
16624     __pyx_t_4 = __pyx_v_tup; __Pyx_INCREF(__pyx_t_4); __pyx_t_5 = 0;
16625     __pyx_t_6 = NULL;
16626   } else {
16627     __pyx_t_5 = -1; __pyx_t_4 = PyObject_GetIter(__pyx_v_tup); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 679, __pyx_L1_error)
16628     __Pyx_GOTREF(__pyx_t_4);
16629     __pyx_t_6 = Py_TYPE(__pyx_t_4)->tp_iternext; if (unlikely(!__pyx_t_6)) __PYX_ERR(2, 679, __pyx_L1_error)
16630   }
16631   for (;;) {
16632     if (likely(!__pyx_t_6)) {
16633       if (likely(PyList_CheckExact(__pyx_t_4))) {
16634         if (__pyx_t_5 >= PyList_GET_SIZE(__pyx_t_4)) break;
16635         #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
16636         __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)
16637         #else
16638         __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)
16639         __Pyx_GOTREF(__pyx_t_7);
16640         #endif
16641       } else {
16642         if (__pyx_t_5 >= PyTuple_GET_SIZE(__pyx_t_4)) break;
16643         #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
16644         __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)
16645         #else
16646         __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)
16647         __Pyx_GOTREF(__pyx_t_7);
16648         #endif
16649       }
16650     } else {
16651       __pyx_t_7 = __pyx_t_6(__pyx_t_4);
16652       if (unlikely(!__pyx_t_7)) {
16653         PyObject* exc_type = PyErr_Occurred();
16654         if (exc_type) {
16655           if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
16656           else __PYX_ERR(2, 679, __pyx_L1_error)
16657         }
16658         break;
16659       }
16660       __Pyx_GOTREF(__pyx_t_7);
16661     }
16662     __Pyx_XDECREF_SET(__pyx_v_item, __pyx_t_7);
16663     __pyx_t_7 = 0;
16664     __Pyx_INCREF(__pyx_t_3);
16665     __Pyx_XDECREF_SET(__pyx_v_idx, __pyx_t_3);
16666     __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)
16667     __Pyx_GOTREF(__pyx_t_7);
16668     __Pyx_DECREF(__pyx_t_3);
16669     __pyx_t_3 = __pyx_t_7;
16670     __pyx_t_7 = 0;
16671 
16672     /* "View.MemoryView":680
16673  *     seen_ellipsis = False
16674  *     for idx, item in enumerate(tup):
16675  *         if item is Ellipsis:             # <<<<<<<<<<<<<<
16676  *             if not seen_ellipsis:
16677  *                 result.extend([slice(None)] * (ndim - len(tup) + 1))
16678  */
16679     __pyx_t_2 = (__pyx_v_item == __pyx_builtin_Ellipsis);
16680     __pyx_t_1 = (__pyx_t_2 != 0);
16681     if (__pyx_t_1) {
16682 
16683       /* "View.MemoryView":681
16684  *     for idx, item in enumerate(tup):
16685  *         if item is Ellipsis:
16686  *             if not seen_ellipsis:             # <<<<<<<<<<<<<<
16687  *                 result.extend([slice(None)] * (ndim - len(tup) + 1))
16688  *                 seen_ellipsis = True
16689  */
16690       __pyx_t_1 = ((!(__pyx_v_seen_ellipsis != 0)) != 0);
16691       if (__pyx_t_1) {
16692 
16693         /* "View.MemoryView":682
16694  *         if item is Ellipsis:
16695  *             if not seen_ellipsis:
16696  *                 result.extend([slice(None)] * (ndim - len(tup) + 1))             # <<<<<<<<<<<<<<
16697  *                 seen_ellipsis = True
16698  *             else:
16699  */
16700         __pyx_t_8 = PyObject_Length(__pyx_v_tup); if (unlikely(__pyx_t_8 == ((Py_ssize_t)-1))) __PYX_ERR(2, 682, __pyx_L1_error)
16701         __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)
16702         __Pyx_GOTREF(__pyx_t_7);
16703         { Py_ssize_t __pyx_temp;
16704           for (__pyx_temp=0; __pyx_temp < ((__pyx_v_ndim - __pyx_t_8) + 1); __pyx_temp++) {
16705             __Pyx_INCREF(__pyx_slice__17);
16706             __Pyx_GIVEREF(__pyx_slice__17);
16707             PyList_SET_ITEM(__pyx_t_7, __pyx_temp, __pyx_slice__17);
16708           }
16709         }
16710         __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)
16711         __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
16712 
16713         /* "View.MemoryView":683
16714  *             if not seen_ellipsis:
16715  *                 result.extend([slice(None)] * (ndim - len(tup) + 1))
16716  *                 seen_ellipsis = True             # <<<<<<<<<<<<<<
16717  *             else:
16718  *                 result.append(slice(None))
16719  */
16720         __pyx_v_seen_ellipsis = 1;
16721 
16722         /* "View.MemoryView":681
16723  *     for idx, item in enumerate(tup):
16724  *         if item is Ellipsis:
16725  *             if not seen_ellipsis:             # <<<<<<<<<<<<<<
16726  *                 result.extend([slice(None)] * (ndim - len(tup) + 1))
16727  *                 seen_ellipsis = True
16728  */
16729         goto __pyx_L7;
16730       }
16731 
16732       /* "View.MemoryView":685
16733  *                 seen_ellipsis = True
16734  *             else:
16735  *                 result.append(slice(None))             # <<<<<<<<<<<<<<
16736  *             have_slices = True
16737  *         else:
16738  */
16739       /*else*/ {
16740         __pyx_t_9 = __Pyx_PyList_Append(__pyx_v_result, __pyx_slice__17); if (unlikely(__pyx_t_9 == ((int)-1))) __PYX_ERR(2, 685, __pyx_L1_error)
16741       }
16742       __pyx_L7:;
16743 
16744       /* "View.MemoryView":686
16745  *             else:
16746  *                 result.append(slice(None))
16747  *             have_slices = True             # <<<<<<<<<<<<<<
16748  *         else:
16749  *             if not isinstance(item, slice) and not PyIndex_Check(item):
16750  */
16751       __pyx_v_have_slices = 1;
16752 
16753       /* "View.MemoryView":680
16754  *     seen_ellipsis = False
16755  *     for idx, item in enumerate(tup):
16756  *         if item is Ellipsis:             # <<<<<<<<<<<<<<
16757  *             if not seen_ellipsis:
16758  *                 result.extend([slice(None)] * (ndim - len(tup) + 1))
16759  */
16760       goto __pyx_L6;
16761     }
16762 
16763     /* "View.MemoryView":688
16764  *             have_slices = True
16765  *         else:
16766  *             if not isinstance(item, slice) and not PyIndex_Check(item):             # <<<<<<<<<<<<<<
16767  *                 raise TypeError("Cannot index with type '%s'" % type(item))
16768  *
16769  */
16770     /*else*/ {
16771       __pyx_t_2 = PySlice_Check(__pyx_v_item);
16772       __pyx_t_10 = ((!(__pyx_t_2 != 0)) != 0);
16773       if (__pyx_t_10) {
16774       } else {
16775         __pyx_t_1 = __pyx_t_10;
16776         goto __pyx_L9_bool_binop_done;
16777       }
16778       __pyx_t_10 = ((!(PyIndex_Check(__pyx_v_item) != 0)) != 0);
16779       __pyx_t_1 = __pyx_t_10;
16780       __pyx_L9_bool_binop_done:;
16781       if (unlikely(__pyx_t_1)) {
16782 
16783         /* "View.MemoryView":689
16784  *         else:
16785  *             if not isinstance(item, slice) and not PyIndex_Check(item):
16786  *                 raise TypeError("Cannot index with type '%s'" % type(item))             # <<<<<<<<<<<<<<
16787  *
16788  *             have_slices = have_slices or isinstance(item, slice)
16789  */
16790         __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)
16791         __Pyx_GOTREF(__pyx_t_7);
16792         __pyx_t_11 = __Pyx_PyObject_CallOneArg(__pyx_builtin_TypeError, __pyx_t_7); if (unlikely(!__pyx_t_11)) __PYX_ERR(2, 689, __pyx_L1_error)
16793         __Pyx_GOTREF(__pyx_t_11);
16794         __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
16795         __Pyx_Raise(__pyx_t_11, 0, 0, 0);
16796         __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
16797         __PYX_ERR(2, 689, __pyx_L1_error)
16798 
16799         /* "View.MemoryView":688
16800  *             have_slices = True
16801  *         else:
16802  *             if not isinstance(item, slice) and not PyIndex_Check(item):             # <<<<<<<<<<<<<<
16803  *                 raise TypeError("Cannot index with type '%s'" % type(item))
16804  *
16805  */
16806       }
16807 
16808       /* "View.MemoryView":691
16809  *                 raise TypeError("Cannot index with type '%s'" % type(item))
16810  *
16811  *             have_slices = have_slices or isinstance(item, slice)             # <<<<<<<<<<<<<<
16812  *             result.append(item)
16813  *
16814  */
16815       __pyx_t_10 = (__pyx_v_have_slices != 0);
16816       if (!__pyx_t_10) {
16817       } else {
16818         __pyx_t_1 = __pyx_t_10;
16819         goto __pyx_L11_bool_binop_done;
16820       }
16821       __pyx_t_10 = PySlice_Check(__pyx_v_item);
16822       __pyx_t_2 = (__pyx_t_10 != 0);
16823       __pyx_t_1 = __pyx_t_2;
16824       __pyx_L11_bool_binop_done:;
16825       __pyx_v_have_slices = __pyx_t_1;
16826 
16827       /* "View.MemoryView":692
16828  *
16829  *             have_slices = have_slices or isinstance(item, slice)
16830  *             result.append(item)             # <<<<<<<<<<<<<<
16831  *
16832  *     nslices = ndim - len(result)
16833  */
16834       __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)
16835     }
16836     __pyx_L6:;
16837 
16838     /* "View.MemoryView":679
16839  *     have_slices = False
16840  *     seen_ellipsis = False
16841  *     for idx, item in enumerate(tup):             # <<<<<<<<<<<<<<
16842  *         if item is Ellipsis:
16843  *             if not seen_ellipsis:
16844  */
16845   }
16846   __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
16847   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
16848 
16849   /* "View.MemoryView":694
16850  *             result.append(item)
16851  *
16852  *     nslices = ndim - len(result)             # <<<<<<<<<<<<<<
16853  *     if nslices:
16854  *         result.extend([slice(None)] * nslices)
16855  */
16856   __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)
16857   __pyx_v_nslices = (__pyx_v_ndim - __pyx_t_5);
16858 
16859   /* "View.MemoryView":695
16860  *
16861  *     nslices = ndim - len(result)
16862  *     if nslices:             # <<<<<<<<<<<<<<
16863  *         result.extend([slice(None)] * nslices)
16864  *
16865  */
16866   __pyx_t_1 = (__pyx_v_nslices != 0);
16867   if (__pyx_t_1) {
16868 
16869     /* "View.MemoryView":696
16870  *     nslices = ndim - len(result)
16871  *     if nslices:
16872  *         result.extend([slice(None)] * nslices)             # <<<<<<<<<<<<<<
16873  *
16874  *     return have_slices or nslices, tuple(result)
16875  */
16876     __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)
16877     __Pyx_GOTREF(__pyx_t_3);
16878     { Py_ssize_t __pyx_temp;
16879       for (__pyx_temp=0; __pyx_temp < __pyx_v_nslices; __pyx_temp++) {
16880         __Pyx_INCREF(__pyx_slice__17);
16881         __Pyx_GIVEREF(__pyx_slice__17);
16882         PyList_SET_ITEM(__pyx_t_3, __pyx_temp, __pyx_slice__17);
16883       }
16884     }
16885     __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)
16886     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
16887 
16888     /* "View.MemoryView":695
16889  *
16890  *     nslices = ndim - len(result)
16891  *     if nslices:             # <<<<<<<<<<<<<<
16892  *         result.extend([slice(None)] * nslices)
16893  *
16894  */
16895   }
16896 
16897   /* "View.MemoryView":698
16898  *         result.extend([slice(None)] * nslices)
16899  *
16900  *     return have_slices or nslices, tuple(result)             # <<<<<<<<<<<<<<
16901  *
16902  * cdef assert_direct_dimensions(Py_ssize_t *suboffsets, int ndim):
16903  */
16904   __Pyx_XDECREF(__pyx_r);
16905   if (!__pyx_v_have_slices) {
16906   } else {
16907     __pyx_t_4 = __Pyx_PyBool_FromLong(__pyx_v_have_slices); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 698, __pyx_L1_error)
16908     __Pyx_GOTREF(__pyx_t_4);
16909     __pyx_t_3 = __pyx_t_4;
16910     __pyx_t_4 = 0;
16911     goto __pyx_L14_bool_binop_done;
16912   }
16913   __pyx_t_4 = PyInt_FromSsize_t(__pyx_v_nslices); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 698, __pyx_L1_error)
16914   __Pyx_GOTREF(__pyx_t_4);
16915   __pyx_t_3 = __pyx_t_4;
16916   __pyx_t_4 = 0;
16917   __pyx_L14_bool_binop_done:;
16918   __pyx_t_4 = PyList_AsTuple(__pyx_v_result); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 698, __pyx_L1_error)
16919   __Pyx_GOTREF(__pyx_t_4);
16920   __pyx_t_11 = PyTuple_New(2); if (unlikely(!__pyx_t_11)) __PYX_ERR(2, 698, __pyx_L1_error)
16921   __Pyx_GOTREF(__pyx_t_11);
16922   __Pyx_GIVEREF(__pyx_t_3);
16923   PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_t_3);
16924   __Pyx_GIVEREF(__pyx_t_4);
16925   PyTuple_SET_ITEM(__pyx_t_11, 1, __pyx_t_4);
16926   __pyx_t_3 = 0;
16927   __pyx_t_4 = 0;
16928   __pyx_r = ((PyObject*)__pyx_t_11);
16929   __pyx_t_11 = 0;
16930   goto __pyx_L0;
16931 
16932   /* "View.MemoryView":666
16933  *     return isinstance(o, memoryview)
16934  *
16935  * cdef tuple _unellipsify(object index, int ndim):             # <<<<<<<<<<<<<<
16936  *     """
16937  *     Replace all ellipses with full slices and fill incomplete indices with
16938  */
16939 
16940   /* function exit code */
16941   __pyx_L1_error:;
16942   __Pyx_XDECREF(__pyx_t_3);
16943   __Pyx_XDECREF(__pyx_t_4);
16944   __Pyx_XDECREF(__pyx_t_7);
16945   __Pyx_XDECREF(__pyx_t_11);
16946   __Pyx_AddTraceback("View.MemoryView._unellipsify", __pyx_clineno, __pyx_lineno, __pyx_filename);
16947   __pyx_r = 0;
16948   __pyx_L0:;
16949   __Pyx_XDECREF(__pyx_v_tup);
16950   __Pyx_XDECREF(__pyx_v_result);
16951   __Pyx_XDECREF(__pyx_v_idx);
16952   __Pyx_XDECREF(__pyx_v_item);
16953   __Pyx_XGIVEREF(__pyx_r);
16954   __Pyx_RefNannyFinishContext();
16955   return __pyx_r;
16956 }
16957 
16958 /* "View.MemoryView":700
16959  *     return have_slices or nslices, tuple(result)
16960  *
16961  * cdef assert_direct_dimensions(Py_ssize_t *suboffsets, int ndim):             # <<<<<<<<<<<<<<
16962  *     for suboffset in suboffsets[:ndim]:
16963  *         if suboffset >= 0:
16964  */
16965 
assert_direct_dimensions(Py_ssize_t * __pyx_v_suboffsets,int __pyx_v_ndim)16966 static PyObject *assert_direct_dimensions(Py_ssize_t *__pyx_v_suboffsets, int __pyx_v_ndim) {
16967   Py_ssize_t __pyx_v_suboffset;
16968   PyObject *__pyx_r = NULL;
16969   __Pyx_RefNannyDeclarations
16970   Py_ssize_t *__pyx_t_1;
16971   Py_ssize_t *__pyx_t_2;
16972   Py_ssize_t *__pyx_t_3;
16973   int __pyx_t_4;
16974   PyObject *__pyx_t_5 = NULL;
16975   int __pyx_lineno = 0;
16976   const char *__pyx_filename = NULL;
16977   int __pyx_clineno = 0;
16978   __Pyx_RefNannySetupContext("assert_direct_dimensions", 0);
16979 
16980   /* "View.MemoryView":701
16981  *
16982  * cdef assert_direct_dimensions(Py_ssize_t *suboffsets, int ndim):
16983  *     for suboffset in suboffsets[:ndim]:             # <<<<<<<<<<<<<<
16984  *         if suboffset >= 0:
16985  *             raise ValueError("Indirect dimensions not supported")
16986  */
16987   __pyx_t_2 = (__pyx_v_suboffsets + __pyx_v_ndim);
16988   for (__pyx_t_3 = __pyx_v_suboffsets; __pyx_t_3 < __pyx_t_2; __pyx_t_3++) {
16989     __pyx_t_1 = __pyx_t_3;
16990     __pyx_v_suboffset = (__pyx_t_1[0]);
16991 
16992     /* "View.MemoryView":702
16993  * cdef assert_direct_dimensions(Py_ssize_t *suboffsets, int ndim):
16994  *     for suboffset in suboffsets[:ndim]:
16995  *         if suboffset >= 0:             # <<<<<<<<<<<<<<
16996  *             raise ValueError("Indirect dimensions not supported")
16997  *
16998  */
16999     __pyx_t_4 = ((__pyx_v_suboffset >= 0) != 0);
17000     if (unlikely(__pyx_t_4)) {
17001 
17002       /* "View.MemoryView":703
17003  *     for suboffset in suboffsets[:ndim]:
17004  *         if suboffset >= 0:
17005  *             raise ValueError("Indirect dimensions not supported")             # <<<<<<<<<<<<<<
17006  *
17007  *
17008  */
17009       __pyx_t_5 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__18, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(2, 703, __pyx_L1_error)
17010       __Pyx_GOTREF(__pyx_t_5);
17011       __Pyx_Raise(__pyx_t_5, 0, 0, 0);
17012       __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
17013       __PYX_ERR(2, 703, __pyx_L1_error)
17014 
17015       /* "View.MemoryView":702
17016  * cdef assert_direct_dimensions(Py_ssize_t *suboffsets, int ndim):
17017  *     for suboffset in suboffsets[:ndim]:
17018  *         if suboffset >= 0:             # <<<<<<<<<<<<<<
17019  *             raise ValueError("Indirect dimensions not supported")
17020  *
17021  */
17022     }
17023   }
17024 
17025   /* "View.MemoryView":700
17026  *     return have_slices or nslices, tuple(result)
17027  *
17028  * cdef assert_direct_dimensions(Py_ssize_t *suboffsets, int ndim):             # <<<<<<<<<<<<<<
17029  *     for suboffset in suboffsets[:ndim]:
17030  *         if suboffset >= 0:
17031  */
17032 
17033   /* function exit code */
17034   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
17035   goto __pyx_L0;
17036   __pyx_L1_error:;
17037   __Pyx_XDECREF(__pyx_t_5);
17038   __Pyx_AddTraceback("View.MemoryView.assert_direct_dimensions", __pyx_clineno, __pyx_lineno, __pyx_filename);
17039   __pyx_r = 0;
17040   __pyx_L0:;
17041   __Pyx_XGIVEREF(__pyx_r);
17042   __Pyx_RefNannyFinishContext();
17043   return __pyx_r;
17044 }
17045 
17046 /* "View.MemoryView":710
17047  *
17048  * @cname('__pyx_memview_slice')
17049  * cdef memoryview memview_slice(memoryview memview, object indices):             # <<<<<<<<<<<<<<
17050  *     cdef int new_ndim = 0, suboffset_dim = -1, dim
17051  *     cdef bint negative_step
17052  */
17053 
__pyx_memview_slice(struct __pyx_memoryview_obj * __pyx_v_memview,PyObject * __pyx_v_indices)17054 static struct __pyx_memoryview_obj *__pyx_memview_slice(struct __pyx_memoryview_obj *__pyx_v_memview, PyObject *__pyx_v_indices) {
17055   int __pyx_v_new_ndim;
17056   int __pyx_v_suboffset_dim;
17057   int __pyx_v_dim;
17058   __Pyx_memviewslice __pyx_v_src;
17059   __Pyx_memviewslice __pyx_v_dst;
17060   __Pyx_memviewslice *__pyx_v_p_src;
17061   struct __pyx_memoryviewslice_obj *__pyx_v_memviewsliceobj = 0;
17062   __Pyx_memviewslice *__pyx_v_p_dst;
17063   int *__pyx_v_p_suboffset_dim;
17064   Py_ssize_t __pyx_v_start;
17065   Py_ssize_t __pyx_v_stop;
17066   Py_ssize_t __pyx_v_step;
17067   int __pyx_v_have_start;
17068   int __pyx_v_have_stop;
17069   int __pyx_v_have_step;
17070   PyObject *__pyx_v_index = NULL;
17071   struct __pyx_memoryview_obj *__pyx_r = NULL;
17072   __Pyx_RefNannyDeclarations
17073   int __pyx_t_1;
17074   int __pyx_t_2;
17075   PyObject *__pyx_t_3 = NULL;
17076   struct __pyx_memoryview_obj *__pyx_t_4;
17077   char *__pyx_t_5;
17078   int __pyx_t_6;
17079   Py_ssize_t __pyx_t_7;
17080   PyObject *(*__pyx_t_8)(PyObject *);
17081   PyObject *__pyx_t_9 = NULL;
17082   Py_ssize_t __pyx_t_10;
17083   int __pyx_t_11;
17084   Py_ssize_t __pyx_t_12;
17085   int __pyx_lineno = 0;
17086   const char *__pyx_filename = NULL;
17087   int __pyx_clineno = 0;
17088   __Pyx_RefNannySetupContext("memview_slice", 0);
17089 
17090   /* "View.MemoryView":711
17091  * @cname('__pyx_memview_slice')
17092  * cdef memoryview memview_slice(memoryview memview, object indices):
17093  *     cdef int new_ndim = 0, suboffset_dim = -1, dim             # <<<<<<<<<<<<<<
17094  *     cdef bint negative_step
17095  *     cdef __Pyx_memviewslice src, dst
17096  */
17097   __pyx_v_new_ndim = 0;
17098   __pyx_v_suboffset_dim = -1;
17099 
17100   /* "View.MemoryView":718
17101  *
17102  *
17103  *     memset(&dst, 0, sizeof(dst))             # <<<<<<<<<<<<<<
17104  *
17105  *     cdef _memoryviewslice memviewsliceobj
17106  */
17107   (void)(memset((&__pyx_v_dst), 0, (sizeof(__pyx_v_dst))));
17108 
17109   /* "View.MemoryView":722
17110  *     cdef _memoryviewslice memviewsliceobj
17111  *
17112  *     assert memview.view.ndim > 0             # <<<<<<<<<<<<<<
17113  *
17114  *     if isinstance(memview, _memoryviewslice):
17115  */
17116   #ifndef CYTHON_WITHOUT_ASSERTIONS
17117   if (unlikely(!Py_OptimizeFlag)) {
17118     if (unlikely(!((__pyx_v_memview->view.ndim > 0) != 0))) {
17119       PyErr_SetNone(PyExc_AssertionError);
17120       __PYX_ERR(2, 722, __pyx_L1_error)
17121     }
17122   }
17123   #endif
17124 
17125   /* "View.MemoryView":724
17126  *     assert memview.view.ndim > 0
17127  *
17128  *     if isinstance(memview, _memoryviewslice):             # <<<<<<<<<<<<<<
17129  *         memviewsliceobj = memview
17130  *         p_src = &memviewsliceobj.from_slice
17131  */
17132   __pyx_t_1 = __Pyx_TypeCheck(((PyObject *)__pyx_v_memview), __pyx_memoryviewslice_type);
17133   __pyx_t_2 = (__pyx_t_1 != 0);
17134   if (__pyx_t_2) {
17135 
17136     /* "View.MemoryView":725
17137  *
17138  *     if isinstance(memview, _memoryviewslice):
17139  *         memviewsliceobj = memview             # <<<<<<<<<<<<<<
17140  *         p_src = &memviewsliceobj.from_slice
17141  *     else:
17142  */
17143     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)
17144     __pyx_t_3 = ((PyObject *)__pyx_v_memview);
17145     __Pyx_INCREF(__pyx_t_3);
17146     __pyx_v_memviewsliceobj = ((struct __pyx_memoryviewslice_obj *)__pyx_t_3);
17147     __pyx_t_3 = 0;
17148 
17149     /* "View.MemoryView":726
17150  *     if isinstance(memview, _memoryviewslice):
17151  *         memviewsliceobj = memview
17152  *         p_src = &memviewsliceobj.from_slice             # <<<<<<<<<<<<<<
17153  *     else:
17154  *         slice_copy(memview, &src)
17155  */
17156     __pyx_v_p_src = (&__pyx_v_memviewsliceobj->from_slice);
17157 
17158     /* "View.MemoryView":724
17159  *     assert memview.view.ndim > 0
17160  *
17161  *     if isinstance(memview, _memoryviewslice):             # <<<<<<<<<<<<<<
17162  *         memviewsliceobj = memview
17163  *         p_src = &memviewsliceobj.from_slice
17164  */
17165     goto __pyx_L3;
17166   }
17167 
17168   /* "View.MemoryView":728
17169  *         p_src = &memviewsliceobj.from_slice
17170  *     else:
17171  *         slice_copy(memview, &src)             # <<<<<<<<<<<<<<
17172  *         p_src = &src
17173  *
17174  */
17175   /*else*/ {
17176     __pyx_memoryview_slice_copy(__pyx_v_memview, (&__pyx_v_src));
17177 
17178     /* "View.MemoryView":729
17179  *     else:
17180  *         slice_copy(memview, &src)
17181  *         p_src = &src             # <<<<<<<<<<<<<<
17182  *
17183  *
17184  */
17185     __pyx_v_p_src = (&__pyx_v_src);
17186   }
17187   __pyx_L3:;
17188 
17189   /* "View.MemoryView":735
17190  *
17191  *
17192  *     dst.memview = p_src.memview             # <<<<<<<<<<<<<<
17193  *     dst.data = p_src.data
17194  *
17195  */
17196   __pyx_t_4 = __pyx_v_p_src->memview;
17197   __pyx_v_dst.memview = __pyx_t_4;
17198 
17199   /* "View.MemoryView":736
17200  *
17201  *     dst.memview = p_src.memview
17202  *     dst.data = p_src.data             # <<<<<<<<<<<<<<
17203  *
17204  *
17205  */
17206   __pyx_t_5 = __pyx_v_p_src->data;
17207   __pyx_v_dst.data = __pyx_t_5;
17208 
17209   /* "View.MemoryView":741
17210  *
17211  *
17212  *     cdef __Pyx_memviewslice *p_dst = &dst             # <<<<<<<<<<<<<<
17213  *     cdef int *p_suboffset_dim = &suboffset_dim
17214  *     cdef Py_ssize_t start, stop, step
17215  */
17216   __pyx_v_p_dst = (&__pyx_v_dst);
17217 
17218   /* "View.MemoryView":742
17219  *
17220  *     cdef __Pyx_memviewslice *p_dst = &dst
17221  *     cdef int *p_suboffset_dim = &suboffset_dim             # <<<<<<<<<<<<<<
17222  *     cdef Py_ssize_t start, stop, step
17223  *     cdef bint have_start, have_stop, have_step
17224  */
17225   __pyx_v_p_suboffset_dim = (&__pyx_v_suboffset_dim);
17226 
17227   /* "View.MemoryView":746
17228  *     cdef bint have_start, have_stop, have_step
17229  *
17230  *     for dim, index in enumerate(indices):             # <<<<<<<<<<<<<<
17231  *         if PyIndex_Check(index):
17232  *             slice_memviewslice(
17233  */
17234   __pyx_t_6 = 0;
17235   if (likely(PyList_CheckExact(__pyx_v_indices)) || PyTuple_CheckExact(__pyx_v_indices)) {
17236     __pyx_t_3 = __pyx_v_indices; __Pyx_INCREF(__pyx_t_3); __pyx_t_7 = 0;
17237     __pyx_t_8 = NULL;
17238   } else {
17239     __pyx_t_7 = -1; __pyx_t_3 = PyObject_GetIter(__pyx_v_indices); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 746, __pyx_L1_error)
17240     __Pyx_GOTREF(__pyx_t_3);
17241     __pyx_t_8 = Py_TYPE(__pyx_t_3)->tp_iternext; if (unlikely(!__pyx_t_8)) __PYX_ERR(2, 746, __pyx_L1_error)
17242   }
17243   for (;;) {
17244     if (likely(!__pyx_t_8)) {
17245       if (likely(PyList_CheckExact(__pyx_t_3))) {
17246         if (__pyx_t_7 >= PyList_GET_SIZE(__pyx_t_3)) break;
17247         #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
17248         __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)
17249         #else
17250         __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)
17251         __Pyx_GOTREF(__pyx_t_9);
17252         #endif
17253       } else {
17254         if (__pyx_t_7 >= PyTuple_GET_SIZE(__pyx_t_3)) break;
17255         #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
17256         __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)
17257         #else
17258         __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)
17259         __Pyx_GOTREF(__pyx_t_9);
17260         #endif
17261       }
17262     } else {
17263       __pyx_t_9 = __pyx_t_8(__pyx_t_3);
17264       if (unlikely(!__pyx_t_9)) {
17265         PyObject* exc_type = PyErr_Occurred();
17266         if (exc_type) {
17267           if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
17268           else __PYX_ERR(2, 746, __pyx_L1_error)
17269         }
17270         break;
17271       }
17272       __Pyx_GOTREF(__pyx_t_9);
17273     }
17274     __Pyx_XDECREF_SET(__pyx_v_index, __pyx_t_9);
17275     __pyx_t_9 = 0;
17276     __pyx_v_dim = __pyx_t_6;
17277     __pyx_t_6 = (__pyx_t_6 + 1);
17278 
17279     /* "View.MemoryView":747
17280  *
17281  *     for dim, index in enumerate(indices):
17282  *         if PyIndex_Check(index):             # <<<<<<<<<<<<<<
17283  *             slice_memviewslice(
17284  *                 p_dst, p_src.shape[dim], p_src.strides[dim], p_src.suboffsets[dim],
17285  */
17286     __pyx_t_2 = (PyIndex_Check(__pyx_v_index) != 0);
17287     if (__pyx_t_2) {
17288 
17289       /* "View.MemoryView":751
17290  *                 p_dst, p_src.shape[dim], p_src.strides[dim], p_src.suboffsets[dim],
17291  *                 dim, new_ndim, p_suboffset_dim,
17292  *                 index, 0, 0, # start, stop, step             # <<<<<<<<<<<<<<
17293  *                 0, 0, 0, # have_{start,stop,step}
17294  *                 False)
17295  */
17296       __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)
17297 
17298       /* "View.MemoryView":748
17299  *     for dim, index in enumerate(indices):
17300  *         if PyIndex_Check(index):
17301  *             slice_memviewslice(             # <<<<<<<<<<<<<<
17302  *                 p_dst, p_src.shape[dim], p_src.strides[dim], p_src.suboffsets[dim],
17303  *                 dim, new_ndim, p_suboffset_dim,
17304  */
17305       __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)
17306 
17307       /* "View.MemoryView":747
17308  *
17309  *     for dim, index in enumerate(indices):
17310  *         if PyIndex_Check(index):             # <<<<<<<<<<<<<<
17311  *             slice_memviewslice(
17312  *                 p_dst, p_src.shape[dim], p_src.strides[dim], p_src.suboffsets[dim],
17313  */
17314       goto __pyx_L6;
17315     }
17316 
17317     /* "View.MemoryView":754
17318  *                 0, 0, 0, # have_{start,stop,step}
17319  *                 False)
17320  *         elif index is None:             # <<<<<<<<<<<<<<
17321  *             p_dst.shape[new_ndim] = 1
17322  *             p_dst.strides[new_ndim] = 0
17323  */
17324     __pyx_t_2 = (__pyx_v_index == Py_None);
17325     __pyx_t_1 = (__pyx_t_2 != 0);
17326     if (__pyx_t_1) {
17327 
17328       /* "View.MemoryView":755
17329  *                 False)
17330  *         elif index is None:
17331  *             p_dst.shape[new_ndim] = 1             # <<<<<<<<<<<<<<
17332  *             p_dst.strides[new_ndim] = 0
17333  *             p_dst.suboffsets[new_ndim] = -1
17334  */
17335       (__pyx_v_p_dst->shape[__pyx_v_new_ndim]) = 1;
17336 
17337       /* "View.MemoryView":756
17338  *         elif index is None:
17339  *             p_dst.shape[new_ndim] = 1
17340  *             p_dst.strides[new_ndim] = 0             # <<<<<<<<<<<<<<
17341  *             p_dst.suboffsets[new_ndim] = -1
17342  *             new_ndim += 1
17343  */
17344       (__pyx_v_p_dst->strides[__pyx_v_new_ndim]) = 0;
17345 
17346       /* "View.MemoryView":757
17347  *             p_dst.shape[new_ndim] = 1
17348  *             p_dst.strides[new_ndim] = 0
17349  *             p_dst.suboffsets[new_ndim] = -1             # <<<<<<<<<<<<<<
17350  *             new_ndim += 1
17351  *         else:
17352  */
17353       (__pyx_v_p_dst->suboffsets[__pyx_v_new_ndim]) = -1L;
17354 
17355       /* "View.MemoryView":758
17356  *             p_dst.strides[new_ndim] = 0
17357  *             p_dst.suboffsets[new_ndim] = -1
17358  *             new_ndim += 1             # <<<<<<<<<<<<<<
17359  *         else:
17360  *             start = index.start or 0
17361  */
17362       __pyx_v_new_ndim = (__pyx_v_new_ndim + 1);
17363 
17364       /* "View.MemoryView":754
17365  *                 0, 0, 0, # have_{start,stop,step}
17366  *                 False)
17367  *         elif index is None:             # <<<<<<<<<<<<<<
17368  *             p_dst.shape[new_ndim] = 1
17369  *             p_dst.strides[new_ndim] = 0
17370  */
17371       goto __pyx_L6;
17372     }
17373 
17374     /* "View.MemoryView":760
17375  *             new_ndim += 1
17376  *         else:
17377  *             start = index.start or 0             # <<<<<<<<<<<<<<
17378  *             stop = index.stop or 0
17379  *             step = index.step or 0
17380  */
17381     /*else*/ {
17382       __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)
17383       __Pyx_GOTREF(__pyx_t_9);
17384       __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_9); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(2, 760, __pyx_L1_error)
17385       if (!__pyx_t_1) {
17386         __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
17387       } else {
17388         __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)
17389         __pyx_t_10 = __pyx_t_12;
17390         __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
17391         goto __pyx_L7_bool_binop_done;
17392       }
17393       __pyx_t_10 = 0;
17394       __pyx_L7_bool_binop_done:;
17395       __pyx_v_start = __pyx_t_10;
17396 
17397       /* "View.MemoryView":761
17398  *         else:
17399  *             start = index.start or 0
17400  *             stop = index.stop or 0             # <<<<<<<<<<<<<<
17401  *             step = index.step or 0
17402  *
17403  */
17404       __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)
17405       __Pyx_GOTREF(__pyx_t_9);
17406       __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_9); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(2, 761, __pyx_L1_error)
17407       if (!__pyx_t_1) {
17408         __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
17409       } else {
17410         __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)
17411         __pyx_t_10 = __pyx_t_12;
17412         __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
17413         goto __pyx_L9_bool_binop_done;
17414       }
17415       __pyx_t_10 = 0;
17416       __pyx_L9_bool_binop_done:;
17417       __pyx_v_stop = __pyx_t_10;
17418 
17419       /* "View.MemoryView":762
17420  *             start = index.start or 0
17421  *             stop = index.stop or 0
17422  *             step = index.step or 0             # <<<<<<<<<<<<<<
17423  *
17424  *             have_start = index.start is not None
17425  */
17426       __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)
17427       __Pyx_GOTREF(__pyx_t_9);
17428       __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_9); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(2, 762, __pyx_L1_error)
17429       if (!__pyx_t_1) {
17430         __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
17431       } else {
17432         __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)
17433         __pyx_t_10 = __pyx_t_12;
17434         __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
17435         goto __pyx_L11_bool_binop_done;
17436       }
17437       __pyx_t_10 = 0;
17438       __pyx_L11_bool_binop_done:;
17439       __pyx_v_step = __pyx_t_10;
17440 
17441       /* "View.MemoryView":764
17442  *             step = index.step or 0
17443  *
17444  *             have_start = index.start is not None             # <<<<<<<<<<<<<<
17445  *             have_stop = index.stop is not None
17446  *             have_step = index.step is not None
17447  */
17448       __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)
17449       __Pyx_GOTREF(__pyx_t_9);
17450       __pyx_t_1 = (__pyx_t_9 != Py_None);
17451       __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
17452       __pyx_v_have_start = __pyx_t_1;
17453 
17454       /* "View.MemoryView":765
17455  *
17456  *             have_start = index.start is not None
17457  *             have_stop = index.stop is not None             # <<<<<<<<<<<<<<
17458  *             have_step = index.step is not None
17459  *
17460  */
17461       __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)
17462       __Pyx_GOTREF(__pyx_t_9);
17463       __pyx_t_1 = (__pyx_t_9 != Py_None);
17464       __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
17465       __pyx_v_have_stop = __pyx_t_1;
17466 
17467       /* "View.MemoryView":766
17468  *             have_start = index.start is not None
17469  *             have_stop = index.stop is not None
17470  *             have_step = index.step is not None             # <<<<<<<<<<<<<<
17471  *
17472  *             slice_memviewslice(
17473  */
17474       __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)
17475       __Pyx_GOTREF(__pyx_t_9);
17476       __pyx_t_1 = (__pyx_t_9 != Py_None);
17477       __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
17478       __pyx_v_have_step = __pyx_t_1;
17479 
17480       /* "View.MemoryView":768
17481  *             have_step = index.step is not None
17482  *
17483  *             slice_memviewslice(             # <<<<<<<<<<<<<<
17484  *                 p_dst, p_src.shape[dim], p_src.strides[dim], p_src.suboffsets[dim],
17485  *                 dim, new_ndim, p_suboffset_dim,
17486  */
17487       __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)
17488 
17489       /* "View.MemoryView":774
17490  *                 have_start, have_stop, have_step,
17491  *                 True)
17492  *             new_ndim += 1             # <<<<<<<<<<<<<<
17493  *
17494  *     if isinstance(memview, _memoryviewslice):
17495  */
17496       __pyx_v_new_ndim = (__pyx_v_new_ndim + 1);
17497     }
17498     __pyx_L6:;
17499 
17500     /* "View.MemoryView":746
17501  *     cdef bint have_start, have_stop, have_step
17502  *
17503  *     for dim, index in enumerate(indices):             # <<<<<<<<<<<<<<
17504  *         if PyIndex_Check(index):
17505  *             slice_memviewslice(
17506  */
17507   }
17508   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
17509 
17510   /* "View.MemoryView":776
17511  *             new_ndim += 1
17512  *
17513  *     if isinstance(memview, _memoryviewslice):             # <<<<<<<<<<<<<<
17514  *         return memoryview_fromslice(dst, new_ndim,
17515  *                                     memviewsliceobj.to_object_func,
17516  */
17517   __pyx_t_1 = __Pyx_TypeCheck(((PyObject *)__pyx_v_memview), __pyx_memoryviewslice_type);
17518   __pyx_t_2 = (__pyx_t_1 != 0);
17519   if (__pyx_t_2) {
17520 
17521     /* "View.MemoryView":777
17522  *
17523  *     if isinstance(memview, _memoryviewslice):
17524  *         return memoryview_fromslice(dst, new_ndim,             # <<<<<<<<<<<<<<
17525  *                                     memviewsliceobj.to_object_func,
17526  *                                     memviewsliceobj.to_dtype_func,
17527  */
17528     __Pyx_XDECREF(((PyObject *)__pyx_r));
17529 
17530     /* "View.MemoryView":778
17531  *     if isinstance(memview, _memoryviewslice):
17532  *         return memoryview_fromslice(dst, new_ndim,
17533  *                                     memviewsliceobj.to_object_func,             # <<<<<<<<<<<<<<
17534  *                                     memviewsliceobj.to_dtype_func,
17535  *                                     memview.dtype_is_object)
17536  */
17537     if (unlikely(!__pyx_v_memviewsliceobj)) { __Pyx_RaiseUnboundLocalError("memviewsliceobj"); __PYX_ERR(2, 778, __pyx_L1_error) }
17538 
17539     /* "View.MemoryView":779
17540  *         return memoryview_fromslice(dst, new_ndim,
17541  *                                     memviewsliceobj.to_object_func,
17542  *                                     memviewsliceobj.to_dtype_func,             # <<<<<<<<<<<<<<
17543  *                                     memview.dtype_is_object)
17544  *     else:
17545  */
17546     if (unlikely(!__pyx_v_memviewsliceobj)) { __Pyx_RaiseUnboundLocalError("memviewsliceobj"); __PYX_ERR(2, 779, __pyx_L1_error) }
17547 
17548     /* "View.MemoryView":777
17549  *
17550  *     if isinstance(memview, _memoryviewslice):
17551  *         return memoryview_fromslice(dst, new_ndim,             # <<<<<<<<<<<<<<
17552  *                                     memviewsliceobj.to_object_func,
17553  *                                     memviewsliceobj.to_dtype_func,
17554  */
17555     __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)
17556     __Pyx_GOTREF(__pyx_t_3);
17557     if (!(likely(((__pyx_t_3) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_3, __pyx_memoryview_type))))) __PYX_ERR(2, 777, __pyx_L1_error)
17558     __pyx_r = ((struct __pyx_memoryview_obj *)__pyx_t_3);
17559     __pyx_t_3 = 0;
17560     goto __pyx_L0;
17561 
17562     /* "View.MemoryView":776
17563  *             new_ndim += 1
17564  *
17565  *     if isinstance(memview, _memoryviewslice):             # <<<<<<<<<<<<<<
17566  *         return memoryview_fromslice(dst, new_ndim,
17567  *                                     memviewsliceobj.to_object_func,
17568  */
17569   }
17570 
17571   /* "View.MemoryView":782
17572  *                                     memview.dtype_is_object)
17573  *     else:
17574  *         return memoryview_fromslice(dst, new_ndim, NULL, NULL,             # <<<<<<<<<<<<<<
17575  *                                     memview.dtype_is_object)
17576  *
17577  */
17578   /*else*/ {
17579     __Pyx_XDECREF(((PyObject *)__pyx_r));
17580 
17581     /* "View.MemoryView":783
17582  *     else:
17583  *         return memoryview_fromslice(dst, new_ndim, NULL, NULL,
17584  *                                     memview.dtype_is_object)             # <<<<<<<<<<<<<<
17585  *
17586  *
17587  */
17588     __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)
17589     __Pyx_GOTREF(__pyx_t_3);
17590 
17591     /* "View.MemoryView":782
17592  *                                     memview.dtype_is_object)
17593  *     else:
17594  *         return memoryview_fromslice(dst, new_ndim, NULL, NULL,             # <<<<<<<<<<<<<<
17595  *                                     memview.dtype_is_object)
17596  *
17597  */
17598     if (!(likely(((__pyx_t_3) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_3, __pyx_memoryview_type))))) __PYX_ERR(2, 782, __pyx_L1_error)
17599     __pyx_r = ((struct __pyx_memoryview_obj *)__pyx_t_3);
17600     __pyx_t_3 = 0;
17601     goto __pyx_L0;
17602   }
17603 
17604   /* "View.MemoryView":710
17605  *
17606  * @cname('__pyx_memview_slice')
17607  * cdef memoryview memview_slice(memoryview memview, object indices):             # <<<<<<<<<<<<<<
17608  *     cdef int new_ndim = 0, suboffset_dim = -1, dim
17609  *     cdef bint negative_step
17610  */
17611 
17612   /* function exit code */
17613   __pyx_L1_error:;
17614   __Pyx_XDECREF(__pyx_t_3);
17615   __Pyx_XDECREF(__pyx_t_9);
17616   __Pyx_AddTraceback("View.MemoryView.memview_slice", __pyx_clineno, __pyx_lineno, __pyx_filename);
17617   __pyx_r = 0;
17618   __pyx_L0:;
17619   __Pyx_XDECREF((PyObject *)__pyx_v_memviewsliceobj);
17620   __Pyx_XDECREF(__pyx_v_index);
17621   __Pyx_XGIVEREF((PyObject *)__pyx_r);
17622   __Pyx_RefNannyFinishContext();
17623   return __pyx_r;
17624 }
17625 
17626 /* "View.MemoryView":807
17627  *
17628  * @cname('__pyx_memoryview_slice_memviewslice')
17629  * cdef int slice_memviewslice(             # <<<<<<<<<<<<<<
17630  *         __Pyx_memviewslice *dst,
17631  *         Py_ssize_t shape, Py_ssize_t stride, Py_ssize_t suboffset,
17632  */
17633 
__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)17634 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) {
17635   Py_ssize_t __pyx_v_new_shape;
17636   int __pyx_v_negative_step;
17637   int __pyx_r;
17638   int __pyx_t_1;
17639   int __pyx_t_2;
17640   int __pyx_t_3;
17641   int __pyx_lineno = 0;
17642   const char *__pyx_filename = NULL;
17643   int __pyx_clineno = 0;
17644 
17645   /* "View.MemoryView":827
17646  *     cdef bint negative_step
17647  *
17648  *     if not is_slice:             # <<<<<<<<<<<<<<
17649  *
17650  *         if start < 0:
17651  */
17652   __pyx_t_1 = ((!(__pyx_v_is_slice != 0)) != 0);
17653   if (__pyx_t_1) {
17654 
17655     /* "View.MemoryView":829
17656  *     if not is_slice:
17657  *
17658  *         if start < 0:             # <<<<<<<<<<<<<<
17659  *             start += shape
17660  *         if not 0 <= start < shape:
17661  */
17662     __pyx_t_1 = ((__pyx_v_start < 0) != 0);
17663     if (__pyx_t_1) {
17664 
17665       /* "View.MemoryView":830
17666  *
17667  *         if start < 0:
17668  *             start += shape             # <<<<<<<<<<<<<<
17669  *         if not 0 <= start < shape:
17670  *             _err_dim(IndexError, "Index out of bounds (axis %d)", dim)
17671  */
17672       __pyx_v_start = (__pyx_v_start + __pyx_v_shape);
17673 
17674       /* "View.MemoryView":829
17675  *     if not is_slice:
17676  *
17677  *         if start < 0:             # <<<<<<<<<<<<<<
17678  *             start += shape
17679  *         if not 0 <= start < shape:
17680  */
17681     }
17682 
17683     /* "View.MemoryView":831
17684  *         if start < 0:
17685  *             start += shape
17686  *         if not 0 <= start < shape:             # <<<<<<<<<<<<<<
17687  *             _err_dim(IndexError, "Index out of bounds (axis %d)", dim)
17688  *     else:
17689  */
17690     __pyx_t_1 = (0 <= __pyx_v_start);
17691     if (__pyx_t_1) {
17692       __pyx_t_1 = (__pyx_v_start < __pyx_v_shape);
17693     }
17694     __pyx_t_2 = ((!(__pyx_t_1 != 0)) != 0);
17695     if (__pyx_t_2) {
17696 
17697       /* "View.MemoryView":832
17698  *             start += shape
17699  *         if not 0 <= start < shape:
17700  *             _err_dim(IndexError, "Index out of bounds (axis %d)", dim)             # <<<<<<<<<<<<<<
17701  *     else:
17702  *
17703  */
17704       __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)
17705 
17706       /* "View.MemoryView":831
17707  *         if start < 0:
17708  *             start += shape
17709  *         if not 0 <= start < shape:             # <<<<<<<<<<<<<<
17710  *             _err_dim(IndexError, "Index out of bounds (axis %d)", dim)
17711  *     else:
17712  */
17713     }
17714 
17715     /* "View.MemoryView":827
17716  *     cdef bint negative_step
17717  *
17718  *     if not is_slice:             # <<<<<<<<<<<<<<
17719  *
17720  *         if start < 0:
17721  */
17722     goto __pyx_L3;
17723   }
17724 
17725   /* "View.MemoryView":835
17726  *     else:
17727  *
17728  *         negative_step = have_step != 0 and step < 0             # <<<<<<<<<<<<<<
17729  *
17730  *         if have_step and step == 0:
17731  */
17732   /*else*/ {
17733     __pyx_t_1 = ((__pyx_v_have_step != 0) != 0);
17734     if (__pyx_t_1) {
17735     } else {
17736       __pyx_t_2 = __pyx_t_1;
17737       goto __pyx_L6_bool_binop_done;
17738     }
17739     __pyx_t_1 = ((__pyx_v_step < 0) != 0);
17740     __pyx_t_2 = __pyx_t_1;
17741     __pyx_L6_bool_binop_done:;
17742     __pyx_v_negative_step = __pyx_t_2;
17743 
17744     /* "View.MemoryView":837
17745  *         negative_step = have_step != 0 and step < 0
17746  *
17747  *         if have_step and step == 0:             # <<<<<<<<<<<<<<
17748  *             _err_dim(ValueError, "Step may not be zero (axis %d)", dim)
17749  *
17750  */
17751     __pyx_t_1 = (__pyx_v_have_step != 0);
17752     if (__pyx_t_1) {
17753     } else {
17754       __pyx_t_2 = __pyx_t_1;
17755       goto __pyx_L9_bool_binop_done;
17756     }
17757     __pyx_t_1 = ((__pyx_v_step == 0) != 0);
17758     __pyx_t_2 = __pyx_t_1;
17759     __pyx_L9_bool_binop_done:;
17760     if (__pyx_t_2) {
17761 
17762       /* "View.MemoryView":838
17763  *
17764  *         if have_step and step == 0:
17765  *             _err_dim(ValueError, "Step may not be zero (axis %d)", dim)             # <<<<<<<<<<<<<<
17766  *
17767  *
17768  */
17769       __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)
17770 
17771       /* "View.MemoryView":837
17772  *         negative_step = have_step != 0 and step < 0
17773  *
17774  *         if have_step and step == 0:             # <<<<<<<<<<<<<<
17775  *             _err_dim(ValueError, "Step may not be zero (axis %d)", dim)
17776  *
17777  */
17778     }
17779 
17780     /* "View.MemoryView":841
17781  *
17782  *
17783  *         if have_start:             # <<<<<<<<<<<<<<
17784  *             if start < 0:
17785  *                 start += shape
17786  */
17787     __pyx_t_2 = (__pyx_v_have_start != 0);
17788     if (__pyx_t_2) {
17789 
17790       /* "View.MemoryView":842
17791  *
17792  *         if have_start:
17793  *             if start < 0:             # <<<<<<<<<<<<<<
17794  *                 start += shape
17795  *                 if start < 0:
17796  */
17797       __pyx_t_2 = ((__pyx_v_start < 0) != 0);
17798       if (__pyx_t_2) {
17799 
17800         /* "View.MemoryView":843
17801  *         if have_start:
17802  *             if start < 0:
17803  *                 start += shape             # <<<<<<<<<<<<<<
17804  *                 if start < 0:
17805  *                     start = 0
17806  */
17807         __pyx_v_start = (__pyx_v_start + __pyx_v_shape);
17808 
17809         /* "View.MemoryView":844
17810  *             if start < 0:
17811  *                 start += shape
17812  *                 if start < 0:             # <<<<<<<<<<<<<<
17813  *                     start = 0
17814  *             elif start >= shape:
17815  */
17816         __pyx_t_2 = ((__pyx_v_start < 0) != 0);
17817         if (__pyx_t_2) {
17818 
17819           /* "View.MemoryView":845
17820  *                 start += shape
17821  *                 if start < 0:
17822  *                     start = 0             # <<<<<<<<<<<<<<
17823  *             elif start >= shape:
17824  *                 if negative_step:
17825  */
17826           __pyx_v_start = 0;
17827 
17828           /* "View.MemoryView":844
17829  *             if start < 0:
17830  *                 start += shape
17831  *                 if start < 0:             # <<<<<<<<<<<<<<
17832  *                     start = 0
17833  *             elif start >= shape:
17834  */
17835         }
17836 
17837         /* "View.MemoryView":842
17838  *
17839  *         if have_start:
17840  *             if start < 0:             # <<<<<<<<<<<<<<
17841  *                 start += shape
17842  *                 if start < 0:
17843  */
17844         goto __pyx_L12;
17845       }
17846 
17847       /* "View.MemoryView":846
17848  *                 if start < 0:
17849  *                     start = 0
17850  *             elif start >= shape:             # <<<<<<<<<<<<<<
17851  *                 if negative_step:
17852  *                     start = shape - 1
17853  */
17854       __pyx_t_2 = ((__pyx_v_start >= __pyx_v_shape) != 0);
17855       if (__pyx_t_2) {
17856 
17857         /* "View.MemoryView":847
17858  *                     start = 0
17859  *             elif start >= shape:
17860  *                 if negative_step:             # <<<<<<<<<<<<<<
17861  *                     start = shape - 1
17862  *                 else:
17863  */
17864         __pyx_t_2 = (__pyx_v_negative_step != 0);
17865         if (__pyx_t_2) {
17866 
17867           /* "View.MemoryView":848
17868  *             elif start >= shape:
17869  *                 if negative_step:
17870  *                     start = shape - 1             # <<<<<<<<<<<<<<
17871  *                 else:
17872  *                     start = shape
17873  */
17874           __pyx_v_start = (__pyx_v_shape - 1);
17875 
17876           /* "View.MemoryView":847
17877  *                     start = 0
17878  *             elif start >= shape:
17879  *                 if negative_step:             # <<<<<<<<<<<<<<
17880  *                     start = shape - 1
17881  *                 else:
17882  */
17883           goto __pyx_L14;
17884         }
17885 
17886         /* "View.MemoryView":850
17887  *                     start = shape - 1
17888  *                 else:
17889  *                     start = shape             # <<<<<<<<<<<<<<
17890  *         else:
17891  *             if negative_step:
17892  */
17893         /*else*/ {
17894           __pyx_v_start = __pyx_v_shape;
17895         }
17896         __pyx_L14:;
17897 
17898         /* "View.MemoryView":846
17899  *                 if start < 0:
17900  *                     start = 0
17901  *             elif start >= shape:             # <<<<<<<<<<<<<<
17902  *                 if negative_step:
17903  *                     start = shape - 1
17904  */
17905       }
17906       __pyx_L12:;
17907 
17908       /* "View.MemoryView":841
17909  *
17910  *
17911  *         if have_start:             # <<<<<<<<<<<<<<
17912  *             if start < 0:
17913  *                 start += shape
17914  */
17915       goto __pyx_L11;
17916     }
17917 
17918     /* "View.MemoryView":852
17919  *                     start = shape
17920  *         else:
17921  *             if negative_step:             # <<<<<<<<<<<<<<
17922  *                 start = shape - 1
17923  *             else:
17924  */
17925     /*else*/ {
17926       __pyx_t_2 = (__pyx_v_negative_step != 0);
17927       if (__pyx_t_2) {
17928 
17929         /* "View.MemoryView":853
17930  *         else:
17931  *             if negative_step:
17932  *                 start = shape - 1             # <<<<<<<<<<<<<<
17933  *             else:
17934  *                 start = 0
17935  */
17936         __pyx_v_start = (__pyx_v_shape - 1);
17937 
17938         /* "View.MemoryView":852
17939  *                     start = shape
17940  *         else:
17941  *             if negative_step:             # <<<<<<<<<<<<<<
17942  *                 start = shape - 1
17943  *             else:
17944  */
17945         goto __pyx_L15;
17946       }
17947 
17948       /* "View.MemoryView":855
17949  *                 start = shape - 1
17950  *             else:
17951  *                 start = 0             # <<<<<<<<<<<<<<
17952  *
17953  *         if have_stop:
17954  */
17955       /*else*/ {
17956         __pyx_v_start = 0;
17957       }
17958       __pyx_L15:;
17959     }
17960     __pyx_L11:;
17961 
17962     /* "View.MemoryView":857
17963  *                 start = 0
17964  *
17965  *         if have_stop:             # <<<<<<<<<<<<<<
17966  *             if stop < 0:
17967  *                 stop += shape
17968  */
17969     __pyx_t_2 = (__pyx_v_have_stop != 0);
17970     if (__pyx_t_2) {
17971 
17972       /* "View.MemoryView":858
17973  *
17974  *         if have_stop:
17975  *             if stop < 0:             # <<<<<<<<<<<<<<
17976  *                 stop += shape
17977  *                 if stop < 0:
17978  */
17979       __pyx_t_2 = ((__pyx_v_stop < 0) != 0);
17980       if (__pyx_t_2) {
17981 
17982         /* "View.MemoryView":859
17983  *         if have_stop:
17984  *             if stop < 0:
17985  *                 stop += shape             # <<<<<<<<<<<<<<
17986  *                 if stop < 0:
17987  *                     stop = 0
17988  */
17989         __pyx_v_stop = (__pyx_v_stop + __pyx_v_shape);
17990 
17991         /* "View.MemoryView":860
17992  *             if stop < 0:
17993  *                 stop += shape
17994  *                 if stop < 0:             # <<<<<<<<<<<<<<
17995  *                     stop = 0
17996  *             elif stop > shape:
17997  */
17998         __pyx_t_2 = ((__pyx_v_stop < 0) != 0);
17999         if (__pyx_t_2) {
18000 
18001           /* "View.MemoryView":861
18002  *                 stop += shape
18003  *                 if stop < 0:
18004  *                     stop = 0             # <<<<<<<<<<<<<<
18005  *             elif stop > shape:
18006  *                 stop = shape
18007  */
18008           __pyx_v_stop = 0;
18009 
18010           /* "View.MemoryView":860
18011  *             if stop < 0:
18012  *                 stop += shape
18013  *                 if stop < 0:             # <<<<<<<<<<<<<<
18014  *                     stop = 0
18015  *             elif stop > shape:
18016  */
18017         }
18018 
18019         /* "View.MemoryView":858
18020  *
18021  *         if have_stop:
18022  *             if stop < 0:             # <<<<<<<<<<<<<<
18023  *                 stop += shape
18024  *                 if stop < 0:
18025  */
18026         goto __pyx_L17;
18027       }
18028 
18029       /* "View.MemoryView":862
18030  *                 if stop < 0:
18031  *                     stop = 0
18032  *             elif stop > shape:             # <<<<<<<<<<<<<<
18033  *                 stop = shape
18034  *         else:
18035  */
18036       __pyx_t_2 = ((__pyx_v_stop > __pyx_v_shape) != 0);
18037       if (__pyx_t_2) {
18038 
18039         /* "View.MemoryView":863
18040  *                     stop = 0
18041  *             elif stop > shape:
18042  *                 stop = shape             # <<<<<<<<<<<<<<
18043  *         else:
18044  *             if negative_step:
18045  */
18046         __pyx_v_stop = __pyx_v_shape;
18047 
18048         /* "View.MemoryView":862
18049  *                 if stop < 0:
18050  *                     stop = 0
18051  *             elif stop > shape:             # <<<<<<<<<<<<<<
18052  *                 stop = shape
18053  *         else:
18054  */
18055       }
18056       __pyx_L17:;
18057 
18058       /* "View.MemoryView":857
18059  *                 start = 0
18060  *
18061  *         if have_stop:             # <<<<<<<<<<<<<<
18062  *             if stop < 0:
18063  *                 stop += shape
18064  */
18065       goto __pyx_L16;
18066     }
18067 
18068     /* "View.MemoryView":865
18069  *                 stop = shape
18070  *         else:
18071  *             if negative_step:             # <<<<<<<<<<<<<<
18072  *                 stop = -1
18073  *             else:
18074  */
18075     /*else*/ {
18076       __pyx_t_2 = (__pyx_v_negative_step != 0);
18077       if (__pyx_t_2) {
18078 
18079         /* "View.MemoryView":866
18080  *         else:
18081  *             if negative_step:
18082  *                 stop = -1             # <<<<<<<<<<<<<<
18083  *             else:
18084  *                 stop = shape
18085  */
18086         __pyx_v_stop = -1L;
18087 
18088         /* "View.MemoryView":865
18089  *                 stop = shape
18090  *         else:
18091  *             if negative_step:             # <<<<<<<<<<<<<<
18092  *                 stop = -1
18093  *             else:
18094  */
18095         goto __pyx_L19;
18096       }
18097 
18098       /* "View.MemoryView":868
18099  *                 stop = -1
18100  *             else:
18101  *                 stop = shape             # <<<<<<<<<<<<<<
18102  *
18103  *         if not have_step:
18104  */
18105       /*else*/ {
18106         __pyx_v_stop = __pyx_v_shape;
18107       }
18108       __pyx_L19:;
18109     }
18110     __pyx_L16:;
18111 
18112     /* "View.MemoryView":870
18113  *                 stop = shape
18114  *
18115  *         if not have_step:             # <<<<<<<<<<<<<<
18116  *             step = 1
18117  *
18118  */
18119     __pyx_t_2 = ((!(__pyx_v_have_step != 0)) != 0);
18120     if (__pyx_t_2) {
18121 
18122       /* "View.MemoryView":871
18123  *
18124  *         if not have_step:
18125  *             step = 1             # <<<<<<<<<<<<<<
18126  *
18127  *
18128  */
18129       __pyx_v_step = 1;
18130 
18131       /* "View.MemoryView":870
18132  *                 stop = shape
18133  *
18134  *         if not have_step:             # <<<<<<<<<<<<<<
18135  *             step = 1
18136  *
18137  */
18138     }
18139 
18140     /* "View.MemoryView":875
18141  *
18142  *         with cython.cdivision(True):
18143  *             new_shape = (stop - start) // step             # <<<<<<<<<<<<<<
18144  *
18145  *             if (stop - start) - step * new_shape:
18146  */
18147     __pyx_v_new_shape = ((__pyx_v_stop - __pyx_v_start) / __pyx_v_step);
18148 
18149     /* "View.MemoryView":877
18150  *             new_shape = (stop - start) // step
18151  *
18152  *             if (stop - start) - step * new_shape:             # <<<<<<<<<<<<<<
18153  *                 new_shape += 1
18154  *
18155  */
18156     __pyx_t_2 = (((__pyx_v_stop - __pyx_v_start) - (__pyx_v_step * __pyx_v_new_shape)) != 0);
18157     if (__pyx_t_2) {
18158 
18159       /* "View.MemoryView":878
18160  *
18161  *             if (stop - start) - step * new_shape:
18162  *                 new_shape += 1             # <<<<<<<<<<<<<<
18163  *
18164  *         if new_shape < 0:
18165  */
18166       __pyx_v_new_shape = (__pyx_v_new_shape + 1);
18167 
18168       /* "View.MemoryView":877
18169  *             new_shape = (stop - start) // step
18170  *
18171  *             if (stop - start) - step * new_shape:             # <<<<<<<<<<<<<<
18172  *                 new_shape += 1
18173  *
18174  */
18175     }
18176 
18177     /* "View.MemoryView":880
18178  *                 new_shape += 1
18179  *
18180  *         if new_shape < 0:             # <<<<<<<<<<<<<<
18181  *             new_shape = 0
18182  *
18183  */
18184     __pyx_t_2 = ((__pyx_v_new_shape < 0) != 0);
18185     if (__pyx_t_2) {
18186 
18187       /* "View.MemoryView":881
18188  *
18189  *         if new_shape < 0:
18190  *             new_shape = 0             # <<<<<<<<<<<<<<
18191  *
18192  *
18193  */
18194       __pyx_v_new_shape = 0;
18195 
18196       /* "View.MemoryView":880
18197  *                 new_shape += 1
18198  *
18199  *         if new_shape < 0:             # <<<<<<<<<<<<<<
18200  *             new_shape = 0
18201  *
18202  */
18203     }
18204 
18205     /* "View.MemoryView":884
18206  *
18207  *
18208  *         dst.strides[new_ndim] = stride * step             # <<<<<<<<<<<<<<
18209  *         dst.shape[new_ndim] = new_shape
18210  *         dst.suboffsets[new_ndim] = suboffset
18211  */
18212     (__pyx_v_dst->strides[__pyx_v_new_ndim]) = (__pyx_v_stride * __pyx_v_step);
18213 
18214     /* "View.MemoryView":885
18215  *
18216  *         dst.strides[new_ndim] = stride * step
18217  *         dst.shape[new_ndim] = new_shape             # <<<<<<<<<<<<<<
18218  *         dst.suboffsets[new_ndim] = suboffset
18219  *
18220  */
18221     (__pyx_v_dst->shape[__pyx_v_new_ndim]) = __pyx_v_new_shape;
18222 
18223     /* "View.MemoryView":886
18224  *         dst.strides[new_ndim] = stride * step
18225  *         dst.shape[new_ndim] = new_shape
18226  *         dst.suboffsets[new_ndim] = suboffset             # <<<<<<<<<<<<<<
18227  *
18228  *
18229  */
18230     (__pyx_v_dst->suboffsets[__pyx_v_new_ndim]) = __pyx_v_suboffset;
18231   }
18232   __pyx_L3:;
18233 
18234   /* "View.MemoryView":889
18235  *
18236  *
18237  *     if suboffset_dim[0] < 0:             # <<<<<<<<<<<<<<
18238  *         dst.data += start * stride
18239  *     else:
18240  */
18241   __pyx_t_2 = (((__pyx_v_suboffset_dim[0]) < 0) != 0);
18242   if (__pyx_t_2) {
18243 
18244     /* "View.MemoryView":890
18245  *
18246  *     if suboffset_dim[0] < 0:
18247  *         dst.data += start * stride             # <<<<<<<<<<<<<<
18248  *     else:
18249  *         dst.suboffsets[suboffset_dim[0]] += start * stride
18250  */
18251     __pyx_v_dst->data = (__pyx_v_dst->data + (__pyx_v_start * __pyx_v_stride));
18252 
18253     /* "View.MemoryView":889
18254  *
18255  *
18256  *     if suboffset_dim[0] < 0:             # <<<<<<<<<<<<<<
18257  *         dst.data += start * stride
18258  *     else:
18259  */
18260     goto __pyx_L23;
18261   }
18262 
18263   /* "View.MemoryView":892
18264  *         dst.data += start * stride
18265  *     else:
18266  *         dst.suboffsets[suboffset_dim[0]] += start * stride             # <<<<<<<<<<<<<<
18267  *
18268  *     if suboffset >= 0:
18269  */
18270   /*else*/ {
18271     __pyx_t_3 = (__pyx_v_suboffset_dim[0]);
18272     (__pyx_v_dst->suboffsets[__pyx_t_3]) = ((__pyx_v_dst->suboffsets[__pyx_t_3]) + (__pyx_v_start * __pyx_v_stride));
18273   }
18274   __pyx_L23:;
18275 
18276   /* "View.MemoryView":894
18277  *         dst.suboffsets[suboffset_dim[0]] += start * stride
18278  *
18279  *     if suboffset >= 0:             # <<<<<<<<<<<<<<
18280  *         if not is_slice:
18281  *             if new_ndim == 0:
18282  */
18283   __pyx_t_2 = ((__pyx_v_suboffset >= 0) != 0);
18284   if (__pyx_t_2) {
18285 
18286     /* "View.MemoryView":895
18287  *
18288  *     if suboffset >= 0:
18289  *         if not is_slice:             # <<<<<<<<<<<<<<
18290  *             if new_ndim == 0:
18291  *                 dst.data = (<char **> dst.data)[0] + suboffset
18292  */
18293     __pyx_t_2 = ((!(__pyx_v_is_slice != 0)) != 0);
18294     if (__pyx_t_2) {
18295 
18296       /* "View.MemoryView":896
18297  *     if suboffset >= 0:
18298  *         if not is_slice:
18299  *             if new_ndim == 0:             # <<<<<<<<<<<<<<
18300  *                 dst.data = (<char **> dst.data)[0] + suboffset
18301  *             else:
18302  */
18303       __pyx_t_2 = ((__pyx_v_new_ndim == 0) != 0);
18304       if (__pyx_t_2) {
18305 
18306         /* "View.MemoryView":897
18307  *         if not is_slice:
18308  *             if new_ndim == 0:
18309  *                 dst.data = (<char **> dst.data)[0] + suboffset             # <<<<<<<<<<<<<<
18310  *             else:
18311  *                 _err_dim(IndexError, "All dimensions preceding dimension %d "
18312  */
18313         __pyx_v_dst->data = ((((char **)__pyx_v_dst->data)[0]) + __pyx_v_suboffset);
18314 
18315         /* "View.MemoryView":896
18316  *     if suboffset >= 0:
18317  *         if not is_slice:
18318  *             if new_ndim == 0:             # <<<<<<<<<<<<<<
18319  *                 dst.data = (<char **> dst.data)[0] + suboffset
18320  *             else:
18321  */
18322         goto __pyx_L26;
18323       }
18324 
18325       /* "View.MemoryView":899
18326  *                 dst.data = (<char **> dst.data)[0] + suboffset
18327  *             else:
18328  *                 _err_dim(IndexError, "All dimensions preceding dimension %d "             # <<<<<<<<<<<<<<
18329  *                                      "must be indexed and not sliced", dim)
18330  *         else:
18331  */
18332       /*else*/ {
18333 
18334         /* "View.MemoryView":900
18335  *             else:
18336  *                 _err_dim(IndexError, "All dimensions preceding dimension %d "
18337  *                                      "must be indexed and not sliced", dim)             # <<<<<<<<<<<<<<
18338  *         else:
18339  *             suboffset_dim[0] = new_ndim
18340  */
18341         __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)
18342       }
18343       __pyx_L26:;
18344 
18345       /* "View.MemoryView":895
18346  *
18347  *     if suboffset >= 0:
18348  *         if not is_slice:             # <<<<<<<<<<<<<<
18349  *             if new_ndim == 0:
18350  *                 dst.data = (<char **> dst.data)[0] + suboffset
18351  */
18352       goto __pyx_L25;
18353     }
18354 
18355     /* "View.MemoryView":902
18356  *                                      "must be indexed and not sliced", dim)
18357  *         else:
18358  *             suboffset_dim[0] = new_ndim             # <<<<<<<<<<<<<<
18359  *
18360  *     return 0
18361  */
18362     /*else*/ {
18363       (__pyx_v_suboffset_dim[0]) = __pyx_v_new_ndim;
18364     }
18365     __pyx_L25:;
18366 
18367     /* "View.MemoryView":894
18368  *         dst.suboffsets[suboffset_dim[0]] += start * stride
18369  *
18370  *     if suboffset >= 0:             # <<<<<<<<<<<<<<
18371  *         if not is_slice:
18372  *             if new_ndim == 0:
18373  */
18374   }
18375 
18376   /* "View.MemoryView":904
18377  *             suboffset_dim[0] = new_ndim
18378  *
18379  *     return 0             # <<<<<<<<<<<<<<
18380  *
18381  *
18382  */
18383   __pyx_r = 0;
18384   goto __pyx_L0;
18385 
18386   /* "View.MemoryView":807
18387  *
18388  * @cname('__pyx_memoryview_slice_memviewslice')
18389  * cdef int slice_memviewslice(             # <<<<<<<<<<<<<<
18390  *         __Pyx_memviewslice *dst,
18391  *         Py_ssize_t shape, Py_ssize_t stride, Py_ssize_t suboffset,
18392  */
18393 
18394   /* function exit code */
18395   __pyx_L1_error:;
18396   {
18397     #ifdef WITH_THREAD
18398     PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure();
18399     #endif
18400     __Pyx_AddTraceback("View.MemoryView.slice_memviewslice", __pyx_clineno, __pyx_lineno, __pyx_filename);
18401     #ifdef WITH_THREAD
18402     __Pyx_PyGILState_Release(__pyx_gilstate_save);
18403     #endif
18404   }
18405   __pyx_r = -1;
18406   __pyx_L0:;
18407   return __pyx_r;
18408 }
18409 
18410 /* "View.MemoryView":910
18411  *
18412  * @cname('__pyx_pybuffer_index')
18413  * cdef char *pybuffer_index(Py_buffer *view, char *bufp, Py_ssize_t index,             # <<<<<<<<<<<<<<
18414  *                           Py_ssize_t dim) except NULL:
18415  *     cdef Py_ssize_t shape, stride, suboffset = -1
18416  */
18417 
__pyx_pybuffer_index(Py_buffer * __pyx_v_view,char * __pyx_v_bufp,Py_ssize_t __pyx_v_index,Py_ssize_t __pyx_v_dim)18418 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) {
18419   Py_ssize_t __pyx_v_shape;
18420   Py_ssize_t __pyx_v_stride;
18421   Py_ssize_t __pyx_v_suboffset;
18422   Py_ssize_t __pyx_v_itemsize;
18423   char *__pyx_v_resultp;
18424   char *__pyx_r;
18425   __Pyx_RefNannyDeclarations
18426   Py_ssize_t __pyx_t_1;
18427   int __pyx_t_2;
18428   PyObject *__pyx_t_3 = NULL;
18429   PyObject *__pyx_t_4 = NULL;
18430   int __pyx_lineno = 0;
18431   const char *__pyx_filename = NULL;
18432   int __pyx_clineno = 0;
18433   __Pyx_RefNannySetupContext("pybuffer_index", 0);
18434 
18435   /* "View.MemoryView":912
18436  * cdef char *pybuffer_index(Py_buffer *view, char *bufp, Py_ssize_t index,
18437  *                           Py_ssize_t dim) except NULL:
18438  *     cdef Py_ssize_t shape, stride, suboffset = -1             # <<<<<<<<<<<<<<
18439  *     cdef Py_ssize_t itemsize = view.itemsize
18440  *     cdef char *resultp
18441  */
18442   __pyx_v_suboffset = -1L;
18443 
18444   /* "View.MemoryView":913
18445  *                           Py_ssize_t dim) except NULL:
18446  *     cdef Py_ssize_t shape, stride, suboffset = -1
18447  *     cdef Py_ssize_t itemsize = view.itemsize             # <<<<<<<<<<<<<<
18448  *     cdef char *resultp
18449  *
18450  */
18451   __pyx_t_1 = __pyx_v_view->itemsize;
18452   __pyx_v_itemsize = __pyx_t_1;
18453 
18454   /* "View.MemoryView":916
18455  *     cdef char *resultp
18456  *
18457  *     if view.ndim == 0:             # <<<<<<<<<<<<<<
18458  *         shape = view.len / itemsize
18459  *         stride = itemsize
18460  */
18461   __pyx_t_2 = ((__pyx_v_view->ndim == 0) != 0);
18462   if (__pyx_t_2) {
18463 
18464     /* "View.MemoryView":917
18465  *
18466  *     if view.ndim == 0:
18467  *         shape = view.len / itemsize             # <<<<<<<<<<<<<<
18468  *         stride = itemsize
18469  *     else:
18470  */
18471     if (unlikely(__pyx_v_itemsize == 0)) {
18472       PyErr_SetString(PyExc_ZeroDivisionError, "integer division or modulo by zero");
18473       __PYX_ERR(2, 917, __pyx_L1_error)
18474     }
18475     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))) {
18476       PyErr_SetString(PyExc_OverflowError, "value too large to perform division");
18477       __PYX_ERR(2, 917, __pyx_L1_error)
18478     }
18479     __pyx_v_shape = __Pyx_div_Py_ssize_t(__pyx_v_view->len, __pyx_v_itemsize);
18480 
18481     /* "View.MemoryView":918
18482  *     if view.ndim == 0:
18483  *         shape = view.len / itemsize
18484  *         stride = itemsize             # <<<<<<<<<<<<<<
18485  *     else:
18486  *         shape = view.shape[dim]
18487  */
18488     __pyx_v_stride = __pyx_v_itemsize;
18489 
18490     /* "View.MemoryView":916
18491  *     cdef char *resultp
18492  *
18493  *     if view.ndim == 0:             # <<<<<<<<<<<<<<
18494  *         shape = view.len / itemsize
18495  *         stride = itemsize
18496  */
18497     goto __pyx_L3;
18498   }
18499 
18500   /* "View.MemoryView":920
18501  *         stride = itemsize
18502  *     else:
18503  *         shape = view.shape[dim]             # <<<<<<<<<<<<<<
18504  *         stride = view.strides[dim]
18505  *         if view.suboffsets != NULL:
18506  */
18507   /*else*/ {
18508     __pyx_v_shape = (__pyx_v_view->shape[__pyx_v_dim]);
18509 
18510     /* "View.MemoryView":921
18511  *     else:
18512  *         shape = view.shape[dim]
18513  *         stride = view.strides[dim]             # <<<<<<<<<<<<<<
18514  *         if view.suboffsets != NULL:
18515  *             suboffset = view.suboffsets[dim]
18516  */
18517     __pyx_v_stride = (__pyx_v_view->strides[__pyx_v_dim]);
18518 
18519     /* "View.MemoryView":922
18520  *         shape = view.shape[dim]
18521  *         stride = view.strides[dim]
18522  *         if view.suboffsets != NULL:             # <<<<<<<<<<<<<<
18523  *             suboffset = view.suboffsets[dim]
18524  *
18525  */
18526     __pyx_t_2 = ((__pyx_v_view->suboffsets != NULL) != 0);
18527     if (__pyx_t_2) {
18528 
18529       /* "View.MemoryView":923
18530  *         stride = view.strides[dim]
18531  *         if view.suboffsets != NULL:
18532  *             suboffset = view.suboffsets[dim]             # <<<<<<<<<<<<<<
18533  *
18534  *     if index < 0:
18535  */
18536       __pyx_v_suboffset = (__pyx_v_view->suboffsets[__pyx_v_dim]);
18537 
18538       /* "View.MemoryView":922
18539  *         shape = view.shape[dim]
18540  *         stride = view.strides[dim]
18541  *         if view.suboffsets != NULL:             # <<<<<<<<<<<<<<
18542  *             suboffset = view.suboffsets[dim]
18543  *
18544  */
18545     }
18546   }
18547   __pyx_L3:;
18548 
18549   /* "View.MemoryView":925
18550  *             suboffset = view.suboffsets[dim]
18551  *
18552  *     if index < 0:             # <<<<<<<<<<<<<<
18553  *         index += view.shape[dim]
18554  *         if index < 0:
18555  */
18556   __pyx_t_2 = ((__pyx_v_index < 0) != 0);
18557   if (__pyx_t_2) {
18558 
18559     /* "View.MemoryView":926
18560  *
18561  *     if index < 0:
18562  *         index += view.shape[dim]             # <<<<<<<<<<<<<<
18563  *         if index < 0:
18564  *             raise IndexError("Out of bounds on buffer access (axis %d)" % dim)
18565  */
18566     __pyx_v_index = (__pyx_v_index + (__pyx_v_view->shape[__pyx_v_dim]));
18567 
18568     /* "View.MemoryView":927
18569  *     if index < 0:
18570  *         index += view.shape[dim]
18571  *         if index < 0:             # <<<<<<<<<<<<<<
18572  *             raise IndexError("Out of bounds on buffer access (axis %d)" % dim)
18573  *
18574  */
18575     __pyx_t_2 = ((__pyx_v_index < 0) != 0);
18576     if (unlikely(__pyx_t_2)) {
18577 
18578       /* "View.MemoryView":928
18579  *         index += view.shape[dim]
18580  *         if index < 0:
18581  *             raise IndexError("Out of bounds on buffer access (axis %d)" % dim)             # <<<<<<<<<<<<<<
18582  *
18583  *     if index >= shape:
18584  */
18585       __pyx_t_3 = PyInt_FromSsize_t(__pyx_v_dim); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 928, __pyx_L1_error)
18586       __Pyx_GOTREF(__pyx_t_3);
18587       __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)
18588       __Pyx_GOTREF(__pyx_t_4);
18589       __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
18590       __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_builtin_IndexError, __pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 928, __pyx_L1_error)
18591       __Pyx_GOTREF(__pyx_t_3);
18592       __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
18593       __Pyx_Raise(__pyx_t_3, 0, 0, 0);
18594       __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
18595       __PYX_ERR(2, 928, __pyx_L1_error)
18596 
18597       /* "View.MemoryView":927
18598  *     if index < 0:
18599  *         index += view.shape[dim]
18600  *         if index < 0:             # <<<<<<<<<<<<<<
18601  *             raise IndexError("Out of bounds on buffer access (axis %d)" % dim)
18602  *
18603  */
18604     }
18605 
18606     /* "View.MemoryView":925
18607  *             suboffset = view.suboffsets[dim]
18608  *
18609  *     if index < 0:             # <<<<<<<<<<<<<<
18610  *         index += view.shape[dim]
18611  *         if index < 0:
18612  */
18613   }
18614 
18615   /* "View.MemoryView":930
18616  *             raise IndexError("Out of bounds on buffer access (axis %d)" % dim)
18617  *
18618  *     if index >= shape:             # <<<<<<<<<<<<<<
18619  *         raise IndexError("Out of bounds on buffer access (axis %d)" % dim)
18620  *
18621  */
18622   __pyx_t_2 = ((__pyx_v_index >= __pyx_v_shape) != 0);
18623   if (unlikely(__pyx_t_2)) {
18624 
18625     /* "View.MemoryView":931
18626  *
18627  *     if index >= shape:
18628  *         raise IndexError("Out of bounds on buffer access (axis %d)" % dim)             # <<<<<<<<<<<<<<
18629  *
18630  *     resultp = bufp + index * stride
18631  */
18632     __pyx_t_3 = PyInt_FromSsize_t(__pyx_v_dim); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 931, __pyx_L1_error)
18633     __Pyx_GOTREF(__pyx_t_3);
18634     __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)
18635     __Pyx_GOTREF(__pyx_t_4);
18636     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
18637     __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_builtin_IndexError, __pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 931, __pyx_L1_error)
18638     __Pyx_GOTREF(__pyx_t_3);
18639     __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
18640     __Pyx_Raise(__pyx_t_3, 0, 0, 0);
18641     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
18642     __PYX_ERR(2, 931, __pyx_L1_error)
18643 
18644     /* "View.MemoryView":930
18645  *             raise IndexError("Out of bounds on buffer access (axis %d)" % dim)
18646  *
18647  *     if index >= shape:             # <<<<<<<<<<<<<<
18648  *         raise IndexError("Out of bounds on buffer access (axis %d)" % dim)
18649  *
18650  */
18651   }
18652 
18653   /* "View.MemoryView":933
18654  *         raise IndexError("Out of bounds on buffer access (axis %d)" % dim)
18655  *
18656  *     resultp = bufp + index * stride             # <<<<<<<<<<<<<<
18657  *     if suboffset >= 0:
18658  *         resultp = (<char **> resultp)[0] + suboffset
18659  */
18660   __pyx_v_resultp = (__pyx_v_bufp + (__pyx_v_index * __pyx_v_stride));
18661 
18662   /* "View.MemoryView":934
18663  *
18664  *     resultp = bufp + index * stride
18665  *     if suboffset >= 0:             # <<<<<<<<<<<<<<
18666  *         resultp = (<char **> resultp)[0] + suboffset
18667  *
18668  */
18669   __pyx_t_2 = ((__pyx_v_suboffset >= 0) != 0);
18670   if (__pyx_t_2) {
18671 
18672     /* "View.MemoryView":935
18673  *     resultp = bufp + index * stride
18674  *     if suboffset >= 0:
18675  *         resultp = (<char **> resultp)[0] + suboffset             # <<<<<<<<<<<<<<
18676  *
18677  *     return resultp
18678  */
18679     __pyx_v_resultp = ((((char **)__pyx_v_resultp)[0]) + __pyx_v_suboffset);
18680 
18681     /* "View.MemoryView":934
18682  *
18683  *     resultp = bufp + index * stride
18684  *     if suboffset >= 0:             # <<<<<<<<<<<<<<
18685  *         resultp = (<char **> resultp)[0] + suboffset
18686  *
18687  */
18688   }
18689 
18690   /* "View.MemoryView":937
18691  *         resultp = (<char **> resultp)[0] + suboffset
18692  *
18693  *     return resultp             # <<<<<<<<<<<<<<
18694  *
18695  *
18696  */
18697   __pyx_r = __pyx_v_resultp;
18698   goto __pyx_L0;
18699 
18700   /* "View.MemoryView":910
18701  *
18702  * @cname('__pyx_pybuffer_index')
18703  * cdef char *pybuffer_index(Py_buffer *view, char *bufp, Py_ssize_t index,             # <<<<<<<<<<<<<<
18704  *                           Py_ssize_t dim) except NULL:
18705  *     cdef Py_ssize_t shape, stride, suboffset = -1
18706  */
18707 
18708   /* function exit code */
18709   __pyx_L1_error:;
18710   __Pyx_XDECREF(__pyx_t_3);
18711   __Pyx_XDECREF(__pyx_t_4);
18712   __Pyx_AddTraceback("View.MemoryView.pybuffer_index", __pyx_clineno, __pyx_lineno, __pyx_filename);
18713   __pyx_r = NULL;
18714   __pyx_L0:;
18715   __Pyx_RefNannyFinishContext();
18716   return __pyx_r;
18717 }
18718 
18719 /* "View.MemoryView":943
18720  *
18721  * @cname('__pyx_memslice_transpose')
18722  * cdef int transpose_memslice(__Pyx_memviewslice *memslice) nogil except 0:             # <<<<<<<<<<<<<<
18723  *     cdef int ndim = memslice.memview.view.ndim
18724  *
18725  */
18726 
__pyx_memslice_transpose(__Pyx_memviewslice * __pyx_v_memslice)18727 static int __pyx_memslice_transpose(__Pyx_memviewslice *__pyx_v_memslice) {
18728   int __pyx_v_ndim;
18729   Py_ssize_t *__pyx_v_shape;
18730   Py_ssize_t *__pyx_v_strides;
18731   int __pyx_v_i;
18732   int __pyx_v_j;
18733   int __pyx_r;
18734   int __pyx_t_1;
18735   Py_ssize_t *__pyx_t_2;
18736   long __pyx_t_3;
18737   long __pyx_t_4;
18738   Py_ssize_t __pyx_t_5;
18739   Py_ssize_t __pyx_t_6;
18740   int __pyx_t_7;
18741   int __pyx_t_8;
18742   int __pyx_t_9;
18743   int __pyx_lineno = 0;
18744   const char *__pyx_filename = NULL;
18745   int __pyx_clineno = 0;
18746 
18747   /* "View.MemoryView":944
18748  * @cname('__pyx_memslice_transpose')
18749  * cdef int transpose_memslice(__Pyx_memviewslice *memslice) nogil except 0:
18750  *     cdef int ndim = memslice.memview.view.ndim             # <<<<<<<<<<<<<<
18751  *
18752  *     cdef Py_ssize_t *shape = memslice.shape
18753  */
18754   __pyx_t_1 = __pyx_v_memslice->memview->view.ndim;
18755   __pyx_v_ndim = __pyx_t_1;
18756 
18757   /* "View.MemoryView":946
18758  *     cdef int ndim = memslice.memview.view.ndim
18759  *
18760  *     cdef Py_ssize_t *shape = memslice.shape             # <<<<<<<<<<<<<<
18761  *     cdef Py_ssize_t *strides = memslice.strides
18762  *
18763  */
18764   __pyx_t_2 = __pyx_v_memslice->shape;
18765   __pyx_v_shape = __pyx_t_2;
18766 
18767   /* "View.MemoryView":947
18768  *
18769  *     cdef Py_ssize_t *shape = memslice.shape
18770  *     cdef Py_ssize_t *strides = memslice.strides             # <<<<<<<<<<<<<<
18771  *
18772  *
18773  */
18774   __pyx_t_2 = __pyx_v_memslice->strides;
18775   __pyx_v_strides = __pyx_t_2;
18776 
18777   /* "View.MemoryView":951
18778  *
18779  *     cdef int i, j
18780  *     for i in range(ndim / 2):             # <<<<<<<<<<<<<<
18781  *         j = ndim - 1 - i
18782  *         strides[i], strides[j] = strides[j], strides[i]
18783  */
18784   __pyx_t_3 = __Pyx_div_long(__pyx_v_ndim, 2);
18785   __pyx_t_4 = __pyx_t_3;
18786   for (__pyx_t_1 = 0; __pyx_t_1 < __pyx_t_4; __pyx_t_1+=1) {
18787     __pyx_v_i = __pyx_t_1;
18788 
18789     /* "View.MemoryView":952
18790  *     cdef int i, j
18791  *     for i in range(ndim / 2):
18792  *         j = ndim - 1 - i             # <<<<<<<<<<<<<<
18793  *         strides[i], strides[j] = strides[j], strides[i]
18794  *         shape[i], shape[j] = shape[j], shape[i]
18795  */
18796     __pyx_v_j = ((__pyx_v_ndim - 1) - __pyx_v_i);
18797 
18798     /* "View.MemoryView":953
18799  *     for i in range(ndim / 2):
18800  *         j = ndim - 1 - i
18801  *         strides[i], strides[j] = strides[j], strides[i]             # <<<<<<<<<<<<<<
18802  *         shape[i], shape[j] = shape[j], shape[i]
18803  *
18804  */
18805     __pyx_t_5 = (__pyx_v_strides[__pyx_v_j]);
18806     __pyx_t_6 = (__pyx_v_strides[__pyx_v_i]);
18807     (__pyx_v_strides[__pyx_v_i]) = __pyx_t_5;
18808     (__pyx_v_strides[__pyx_v_j]) = __pyx_t_6;
18809 
18810     /* "View.MemoryView":954
18811  *         j = ndim - 1 - i
18812  *         strides[i], strides[j] = strides[j], strides[i]
18813  *         shape[i], shape[j] = shape[j], shape[i]             # <<<<<<<<<<<<<<
18814  *
18815  *         if memslice.suboffsets[i] >= 0 or memslice.suboffsets[j] >= 0:
18816  */
18817     __pyx_t_6 = (__pyx_v_shape[__pyx_v_j]);
18818     __pyx_t_5 = (__pyx_v_shape[__pyx_v_i]);
18819     (__pyx_v_shape[__pyx_v_i]) = __pyx_t_6;
18820     (__pyx_v_shape[__pyx_v_j]) = __pyx_t_5;
18821 
18822     /* "View.MemoryView":956
18823  *         shape[i], shape[j] = shape[j], shape[i]
18824  *
18825  *         if memslice.suboffsets[i] >= 0 or memslice.suboffsets[j] >= 0:             # <<<<<<<<<<<<<<
18826  *             _err(ValueError, "Cannot transpose memoryview with indirect dimensions")
18827  *
18828  */
18829     __pyx_t_8 = (((__pyx_v_memslice->suboffsets[__pyx_v_i]) >= 0) != 0);
18830     if (!__pyx_t_8) {
18831     } else {
18832       __pyx_t_7 = __pyx_t_8;
18833       goto __pyx_L6_bool_binop_done;
18834     }
18835     __pyx_t_8 = (((__pyx_v_memslice->suboffsets[__pyx_v_j]) >= 0) != 0);
18836     __pyx_t_7 = __pyx_t_8;
18837     __pyx_L6_bool_binop_done:;
18838     if (__pyx_t_7) {
18839 
18840       /* "View.MemoryView":957
18841  *
18842  *         if memslice.suboffsets[i] >= 0 or memslice.suboffsets[j] >= 0:
18843  *             _err(ValueError, "Cannot transpose memoryview with indirect dimensions")             # <<<<<<<<<<<<<<
18844  *
18845  *     return 1
18846  */
18847       __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)
18848 
18849       /* "View.MemoryView":956
18850  *         shape[i], shape[j] = shape[j], shape[i]
18851  *
18852  *         if memslice.suboffsets[i] >= 0 or memslice.suboffsets[j] >= 0:             # <<<<<<<<<<<<<<
18853  *             _err(ValueError, "Cannot transpose memoryview with indirect dimensions")
18854  *
18855  */
18856     }
18857   }
18858 
18859   /* "View.MemoryView":959
18860  *             _err(ValueError, "Cannot transpose memoryview with indirect dimensions")
18861  *
18862  *     return 1             # <<<<<<<<<<<<<<
18863  *
18864  *
18865  */
18866   __pyx_r = 1;
18867   goto __pyx_L0;
18868 
18869   /* "View.MemoryView":943
18870  *
18871  * @cname('__pyx_memslice_transpose')
18872  * cdef int transpose_memslice(__Pyx_memviewslice *memslice) nogil except 0:             # <<<<<<<<<<<<<<
18873  *     cdef int ndim = memslice.memview.view.ndim
18874  *
18875  */
18876 
18877   /* function exit code */
18878   __pyx_L1_error:;
18879   {
18880     #ifdef WITH_THREAD
18881     PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure();
18882     #endif
18883     __Pyx_AddTraceback("View.MemoryView.transpose_memslice", __pyx_clineno, __pyx_lineno, __pyx_filename);
18884     #ifdef WITH_THREAD
18885     __Pyx_PyGILState_Release(__pyx_gilstate_save);
18886     #endif
18887   }
18888   __pyx_r = 0;
18889   __pyx_L0:;
18890   return __pyx_r;
18891 }
18892 
18893 /* "View.MemoryView":976
18894  *     cdef int (*to_dtype_func)(char *, object) except 0
18895  *
18896  *     def __dealloc__(self):             # <<<<<<<<<<<<<<
18897  *         __PYX_XDEC_MEMVIEW(&self.from_slice, 1)
18898  *
18899  */
18900 
18901 /* Python wrapper */
18902 static void __pyx_memoryviewslice___dealloc__(PyObject *__pyx_v_self); /*proto*/
__pyx_memoryviewslice___dealloc__(PyObject * __pyx_v_self)18903 static void __pyx_memoryviewslice___dealloc__(PyObject *__pyx_v_self) {
18904   __Pyx_RefNannyDeclarations
18905   __Pyx_RefNannySetupContext("__dealloc__ (wrapper)", 0);
18906   __pyx_memoryviewslice___pyx_pf_15View_dot_MemoryView_16_memoryviewslice___dealloc__(((struct __pyx_memoryviewslice_obj *)__pyx_v_self));
18907 
18908   /* function exit code */
18909   __Pyx_RefNannyFinishContext();
18910 }
18911 
__pyx_memoryviewslice___pyx_pf_15View_dot_MemoryView_16_memoryviewslice___dealloc__(struct __pyx_memoryviewslice_obj * __pyx_v_self)18912 static void __pyx_memoryviewslice___pyx_pf_15View_dot_MemoryView_16_memoryviewslice___dealloc__(struct __pyx_memoryviewslice_obj *__pyx_v_self) {
18913   __Pyx_RefNannyDeclarations
18914   __Pyx_RefNannySetupContext("__dealloc__", 0);
18915 
18916   /* "View.MemoryView":977
18917  *
18918  *     def __dealloc__(self):
18919  *         __PYX_XDEC_MEMVIEW(&self.from_slice, 1)             # <<<<<<<<<<<<<<
18920  *
18921  *     cdef convert_item_to_object(self, char *itemp):
18922  */
18923   __PYX_XDEC_MEMVIEW((&__pyx_v_self->from_slice), 1);
18924 
18925   /* "View.MemoryView":976
18926  *     cdef int (*to_dtype_func)(char *, object) except 0
18927  *
18928  *     def __dealloc__(self):             # <<<<<<<<<<<<<<
18929  *         __PYX_XDEC_MEMVIEW(&self.from_slice, 1)
18930  *
18931  */
18932 
18933   /* function exit code */
18934   __Pyx_RefNannyFinishContext();
18935 }
18936 
18937 /* "View.MemoryView":979
18938  *         __PYX_XDEC_MEMVIEW(&self.from_slice, 1)
18939  *
18940  *     cdef convert_item_to_object(self, char *itemp):             # <<<<<<<<<<<<<<
18941  *         if self.to_object_func != NULL:
18942  *             return self.to_object_func(itemp)
18943  */
18944 
__pyx_memoryviewslice_convert_item_to_object(struct __pyx_memoryviewslice_obj * __pyx_v_self,char * __pyx_v_itemp)18945 static PyObject *__pyx_memoryviewslice_convert_item_to_object(struct __pyx_memoryviewslice_obj *__pyx_v_self, char *__pyx_v_itemp) {
18946   PyObject *__pyx_r = NULL;
18947   __Pyx_RefNannyDeclarations
18948   int __pyx_t_1;
18949   PyObject *__pyx_t_2 = NULL;
18950   int __pyx_lineno = 0;
18951   const char *__pyx_filename = NULL;
18952   int __pyx_clineno = 0;
18953   __Pyx_RefNannySetupContext("convert_item_to_object", 0);
18954 
18955   /* "View.MemoryView":980
18956  *
18957  *     cdef convert_item_to_object(self, char *itemp):
18958  *         if self.to_object_func != NULL:             # <<<<<<<<<<<<<<
18959  *             return self.to_object_func(itemp)
18960  *         else:
18961  */
18962   __pyx_t_1 = ((__pyx_v_self->to_object_func != NULL) != 0);
18963   if (__pyx_t_1) {
18964 
18965     /* "View.MemoryView":981
18966  *     cdef convert_item_to_object(self, char *itemp):
18967  *         if self.to_object_func != NULL:
18968  *             return self.to_object_func(itemp)             # <<<<<<<<<<<<<<
18969  *         else:
18970  *             return memoryview.convert_item_to_object(self, itemp)
18971  */
18972     __Pyx_XDECREF(__pyx_r);
18973     __pyx_t_2 = __pyx_v_self->to_object_func(__pyx_v_itemp); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 981, __pyx_L1_error)
18974     __Pyx_GOTREF(__pyx_t_2);
18975     __pyx_r = __pyx_t_2;
18976     __pyx_t_2 = 0;
18977     goto __pyx_L0;
18978 
18979     /* "View.MemoryView":980
18980  *
18981  *     cdef convert_item_to_object(self, char *itemp):
18982  *         if self.to_object_func != NULL:             # <<<<<<<<<<<<<<
18983  *             return self.to_object_func(itemp)
18984  *         else:
18985  */
18986   }
18987 
18988   /* "View.MemoryView":983
18989  *             return self.to_object_func(itemp)
18990  *         else:
18991  *             return memoryview.convert_item_to_object(self, itemp)             # <<<<<<<<<<<<<<
18992  *
18993  *     cdef assign_item_from_object(self, char *itemp, object value):
18994  */
18995   /*else*/ {
18996     __Pyx_XDECREF(__pyx_r);
18997     __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)
18998     __Pyx_GOTREF(__pyx_t_2);
18999     __pyx_r = __pyx_t_2;
19000     __pyx_t_2 = 0;
19001     goto __pyx_L0;
19002   }
19003 
19004   /* "View.MemoryView":979
19005  *         __PYX_XDEC_MEMVIEW(&self.from_slice, 1)
19006  *
19007  *     cdef convert_item_to_object(self, char *itemp):             # <<<<<<<<<<<<<<
19008  *         if self.to_object_func != NULL:
19009  *             return self.to_object_func(itemp)
19010  */
19011 
19012   /* function exit code */
19013   __pyx_L1_error:;
19014   __Pyx_XDECREF(__pyx_t_2);
19015   __Pyx_AddTraceback("View.MemoryView._memoryviewslice.convert_item_to_object", __pyx_clineno, __pyx_lineno, __pyx_filename);
19016   __pyx_r = 0;
19017   __pyx_L0:;
19018   __Pyx_XGIVEREF(__pyx_r);
19019   __Pyx_RefNannyFinishContext();
19020   return __pyx_r;
19021 }
19022 
19023 /* "View.MemoryView":985
19024  *             return memoryview.convert_item_to_object(self, itemp)
19025  *
19026  *     cdef assign_item_from_object(self, char *itemp, object value):             # <<<<<<<<<<<<<<
19027  *         if self.to_dtype_func != NULL:
19028  *             self.to_dtype_func(itemp, value)
19029  */
19030 
__pyx_memoryviewslice_assign_item_from_object(struct __pyx_memoryviewslice_obj * __pyx_v_self,char * __pyx_v_itemp,PyObject * __pyx_v_value)19031 static PyObject *__pyx_memoryviewslice_assign_item_from_object(struct __pyx_memoryviewslice_obj *__pyx_v_self, char *__pyx_v_itemp, PyObject *__pyx_v_value) {
19032   PyObject *__pyx_r = NULL;
19033   __Pyx_RefNannyDeclarations
19034   int __pyx_t_1;
19035   int __pyx_t_2;
19036   PyObject *__pyx_t_3 = NULL;
19037   int __pyx_lineno = 0;
19038   const char *__pyx_filename = NULL;
19039   int __pyx_clineno = 0;
19040   __Pyx_RefNannySetupContext("assign_item_from_object", 0);
19041 
19042   /* "View.MemoryView":986
19043  *
19044  *     cdef assign_item_from_object(self, char *itemp, object value):
19045  *         if self.to_dtype_func != NULL:             # <<<<<<<<<<<<<<
19046  *             self.to_dtype_func(itemp, value)
19047  *         else:
19048  */
19049   __pyx_t_1 = ((__pyx_v_self->to_dtype_func != NULL) != 0);
19050   if (__pyx_t_1) {
19051 
19052     /* "View.MemoryView":987
19053  *     cdef assign_item_from_object(self, char *itemp, object value):
19054  *         if self.to_dtype_func != NULL:
19055  *             self.to_dtype_func(itemp, value)             # <<<<<<<<<<<<<<
19056  *         else:
19057  *             memoryview.assign_item_from_object(self, itemp, value)
19058  */
19059     __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)
19060 
19061     /* "View.MemoryView":986
19062  *
19063  *     cdef assign_item_from_object(self, char *itemp, object value):
19064  *         if self.to_dtype_func != NULL:             # <<<<<<<<<<<<<<
19065  *             self.to_dtype_func(itemp, value)
19066  *         else:
19067  */
19068     goto __pyx_L3;
19069   }
19070 
19071   /* "View.MemoryView":989
19072  *             self.to_dtype_func(itemp, value)
19073  *         else:
19074  *             memoryview.assign_item_from_object(self, itemp, value)             # <<<<<<<<<<<<<<
19075  *
19076  *     @property
19077  */
19078   /*else*/ {
19079     __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)
19080     __Pyx_GOTREF(__pyx_t_3);
19081     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
19082   }
19083   __pyx_L3:;
19084 
19085   /* "View.MemoryView":985
19086  *             return memoryview.convert_item_to_object(self, itemp)
19087  *
19088  *     cdef assign_item_from_object(self, char *itemp, object value):             # <<<<<<<<<<<<<<
19089  *         if self.to_dtype_func != NULL:
19090  *             self.to_dtype_func(itemp, value)
19091  */
19092 
19093   /* function exit code */
19094   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
19095   goto __pyx_L0;
19096   __pyx_L1_error:;
19097   __Pyx_XDECREF(__pyx_t_3);
19098   __Pyx_AddTraceback("View.MemoryView._memoryviewslice.assign_item_from_object", __pyx_clineno, __pyx_lineno, __pyx_filename);
19099   __pyx_r = 0;
19100   __pyx_L0:;
19101   __Pyx_XGIVEREF(__pyx_r);
19102   __Pyx_RefNannyFinishContext();
19103   return __pyx_r;
19104 }
19105 
19106 /* "View.MemoryView":992
19107  *
19108  *     @property
19109  *     def base(self):             # <<<<<<<<<<<<<<
19110  *         return self.from_object
19111  *
19112  */
19113 
19114 /* Python wrapper */
19115 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)19116 static PyObject *__pyx_pw_15View_dot_MemoryView_16_memoryviewslice_4base_1__get__(PyObject *__pyx_v_self) {
19117   PyObject *__pyx_r = 0;
19118   __Pyx_RefNannyDeclarations
19119   __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
19120   __pyx_r = __pyx_pf_15View_dot_MemoryView_16_memoryviewslice_4base___get__(((struct __pyx_memoryviewslice_obj *)__pyx_v_self));
19121 
19122   /* function exit code */
19123   __Pyx_RefNannyFinishContext();
19124   return __pyx_r;
19125 }
19126 
__pyx_pf_15View_dot_MemoryView_16_memoryviewslice_4base___get__(struct __pyx_memoryviewslice_obj * __pyx_v_self)19127 static PyObject *__pyx_pf_15View_dot_MemoryView_16_memoryviewslice_4base___get__(struct __pyx_memoryviewslice_obj *__pyx_v_self) {
19128   PyObject *__pyx_r = NULL;
19129   __Pyx_RefNannyDeclarations
19130   __Pyx_RefNannySetupContext("__get__", 0);
19131 
19132   /* "View.MemoryView":993
19133  *     @property
19134  *     def base(self):
19135  *         return self.from_object             # <<<<<<<<<<<<<<
19136  *
19137  *     __pyx_getbuffer = capsule(<void *> &__pyx_memoryview_getbuffer, "getbuffer(obj, view, flags)")
19138  */
19139   __Pyx_XDECREF(__pyx_r);
19140   __Pyx_INCREF(__pyx_v_self->from_object);
19141   __pyx_r = __pyx_v_self->from_object;
19142   goto __pyx_L0;
19143 
19144   /* "View.MemoryView":992
19145  *
19146  *     @property
19147  *     def base(self):             # <<<<<<<<<<<<<<
19148  *         return self.from_object
19149  *
19150  */
19151 
19152   /* function exit code */
19153   __pyx_L0:;
19154   __Pyx_XGIVEREF(__pyx_r);
19155   __Pyx_RefNannyFinishContext();
19156   return __pyx_r;
19157 }
19158 
19159 /* "(tree fragment)":1
19160  * def __reduce_cython__(self):             # <<<<<<<<<<<<<<
19161  *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
19162  * def __setstate_cython__(self, __pyx_state):
19163  */
19164 
19165 /* Python wrapper */
19166 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)19167 static PyObject *__pyx_pw___pyx_memoryviewslice_1__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
19168   PyObject *__pyx_r = 0;
19169   __Pyx_RefNannyDeclarations
19170   __Pyx_RefNannySetupContext("__reduce_cython__ (wrapper)", 0);
19171   __pyx_r = __pyx_pf___pyx_memoryviewslice___reduce_cython__(((struct __pyx_memoryviewslice_obj *)__pyx_v_self));
19172 
19173   /* function exit code */
19174   __Pyx_RefNannyFinishContext();
19175   return __pyx_r;
19176 }
19177 
__pyx_pf___pyx_memoryviewslice___reduce_cython__(CYTHON_UNUSED struct __pyx_memoryviewslice_obj * __pyx_v_self)19178 static PyObject *__pyx_pf___pyx_memoryviewslice___reduce_cython__(CYTHON_UNUSED struct __pyx_memoryviewslice_obj *__pyx_v_self) {
19179   PyObject *__pyx_r = NULL;
19180   __Pyx_RefNannyDeclarations
19181   PyObject *__pyx_t_1 = NULL;
19182   int __pyx_lineno = 0;
19183   const char *__pyx_filename = NULL;
19184   int __pyx_clineno = 0;
19185   __Pyx_RefNannySetupContext("__reduce_cython__", 0);
19186 
19187   /* "(tree fragment)":2
19188  * def __reduce_cython__(self):
19189  *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")             # <<<<<<<<<<<<<<
19190  * def __setstate_cython__(self, __pyx_state):
19191  *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
19192  */
19193   __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__19, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 2, __pyx_L1_error)
19194   __Pyx_GOTREF(__pyx_t_1);
19195   __Pyx_Raise(__pyx_t_1, 0, 0, 0);
19196   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
19197   __PYX_ERR(2, 2, __pyx_L1_error)
19198 
19199   /* "(tree fragment)":1
19200  * def __reduce_cython__(self):             # <<<<<<<<<<<<<<
19201  *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
19202  * def __setstate_cython__(self, __pyx_state):
19203  */
19204 
19205   /* function exit code */
19206   __pyx_L1_error:;
19207   __Pyx_XDECREF(__pyx_t_1);
19208   __Pyx_AddTraceback("View.MemoryView._memoryviewslice.__reduce_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename);
19209   __pyx_r = NULL;
19210   __Pyx_XGIVEREF(__pyx_r);
19211   __Pyx_RefNannyFinishContext();
19212   return __pyx_r;
19213 }
19214 
19215 /* "(tree fragment)":3
19216  * def __reduce_cython__(self):
19217  *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
19218  * def __setstate_cython__(self, __pyx_state):             # <<<<<<<<<<<<<<
19219  *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
19220  */
19221 
19222 /* Python wrapper */
19223 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)19224 static PyObject *__pyx_pw___pyx_memoryviewslice_3__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state) {
19225   PyObject *__pyx_r = 0;
19226   __Pyx_RefNannyDeclarations
19227   __Pyx_RefNannySetupContext("__setstate_cython__ (wrapper)", 0);
19228   __pyx_r = __pyx_pf___pyx_memoryviewslice_2__setstate_cython__(((struct __pyx_memoryviewslice_obj *)__pyx_v_self), ((PyObject *)__pyx_v___pyx_state));
19229 
19230   /* function exit code */
19231   __Pyx_RefNannyFinishContext();
19232   return __pyx_r;
19233 }
19234 
__pyx_pf___pyx_memoryviewslice_2__setstate_cython__(CYTHON_UNUSED struct __pyx_memoryviewslice_obj * __pyx_v_self,CYTHON_UNUSED PyObject * __pyx_v___pyx_state)19235 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) {
19236   PyObject *__pyx_r = NULL;
19237   __Pyx_RefNannyDeclarations
19238   PyObject *__pyx_t_1 = NULL;
19239   int __pyx_lineno = 0;
19240   const char *__pyx_filename = NULL;
19241   int __pyx_clineno = 0;
19242   __Pyx_RefNannySetupContext("__setstate_cython__", 0);
19243 
19244   /* "(tree fragment)":4
19245  *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
19246  * def __setstate_cython__(self, __pyx_state):
19247  *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")             # <<<<<<<<<<<<<<
19248  */
19249   __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__20, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 4, __pyx_L1_error)
19250   __Pyx_GOTREF(__pyx_t_1);
19251   __Pyx_Raise(__pyx_t_1, 0, 0, 0);
19252   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
19253   __PYX_ERR(2, 4, __pyx_L1_error)
19254 
19255   /* "(tree fragment)":3
19256  * def __reduce_cython__(self):
19257  *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
19258  * def __setstate_cython__(self, __pyx_state):             # <<<<<<<<<<<<<<
19259  *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
19260  */
19261 
19262   /* function exit code */
19263   __pyx_L1_error:;
19264   __Pyx_XDECREF(__pyx_t_1);
19265   __Pyx_AddTraceback("View.MemoryView._memoryviewslice.__setstate_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename);
19266   __pyx_r = NULL;
19267   __Pyx_XGIVEREF(__pyx_r);
19268   __Pyx_RefNannyFinishContext();
19269   return __pyx_r;
19270 }
19271 
19272 /* "View.MemoryView":999
19273  *
19274  * @cname('__pyx_memoryview_fromslice')
19275  * cdef memoryview_fromslice(__Pyx_memviewslice memviewslice,             # <<<<<<<<<<<<<<
19276  *                           int ndim,
19277  *                           object (*to_object_func)(char *),
19278  */
19279 
__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)19280 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) {
19281   struct __pyx_memoryviewslice_obj *__pyx_v_result = 0;
19282   Py_ssize_t __pyx_v_suboffset;
19283   PyObject *__pyx_v_length = NULL;
19284   PyObject *__pyx_r = NULL;
19285   __Pyx_RefNannyDeclarations
19286   int __pyx_t_1;
19287   PyObject *__pyx_t_2 = NULL;
19288   PyObject *__pyx_t_3 = NULL;
19289   __Pyx_TypeInfo *__pyx_t_4;
19290   Py_buffer __pyx_t_5;
19291   Py_ssize_t *__pyx_t_6;
19292   Py_ssize_t *__pyx_t_7;
19293   Py_ssize_t *__pyx_t_8;
19294   Py_ssize_t __pyx_t_9;
19295   int __pyx_lineno = 0;
19296   const char *__pyx_filename = NULL;
19297   int __pyx_clineno = 0;
19298   __Pyx_RefNannySetupContext("memoryview_fromslice", 0);
19299 
19300   /* "View.MemoryView":1007
19301  *     cdef _memoryviewslice result
19302  *
19303  *     if <PyObject *> memviewslice.memview == Py_None:             # <<<<<<<<<<<<<<
19304  *         return None
19305  *
19306  */
19307   __pyx_t_1 = ((((PyObject *)__pyx_v_memviewslice.memview) == Py_None) != 0);
19308   if (__pyx_t_1) {
19309 
19310     /* "View.MemoryView":1008
19311  *
19312  *     if <PyObject *> memviewslice.memview == Py_None:
19313  *         return None             # <<<<<<<<<<<<<<
19314  *
19315  *
19316  */
19317     __Pyx_XDECREF(__pyx_r);
19318     __pyx_r = Py_None; __Pyx_INCREF(Py_None);
19319     goto __pyx_L0;
19320 
19321     /* "View.MemoryView":1007
19322  *     cdef _memoryviewslice result
19323  *
19324  *     if <PyObject *> memviewslice.memview == Py_None:             # <<<<<<<<<<<<<<
19325  *         return None
19326  *
19327  */
19328   }
19329 
19330   /* "View.MemoryView":1013
19331  *
19332  *
19333  *     result = _memoryviewslice(None, 0, dtype_is_object)             # <<<<<<<<<<<<<<
19334  *
19335  *     result.from_slice = memviewslice
19336  */
19337   __pyx_t_2 = __Pyx_PyBool_FromLong(__pyx_v_dtype_is_object); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 1013, __pyx_L1_error)
19338   __Pyx_GOTREF(__pyx_t_2);
19339   __pyx_t_3 = PyTuple_New(3); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 1013, __pyx_L1_error)
19340   __Pyx_GOTREF(__pyx_t_3);
19341   __Pyx_INCREF(Py_None);
19342   __Pyx_GIVEREF(Py_None);
19343   PyTuple_SET_ITEM(__pyx_t_3, 0, Py_None);
19344   __Pyx_INCREF(__pyx_int_0);
19345   __Pyx_GIVEREF(__pyx_int_0);
19346   PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_int_0);
19347   __Pyx_GIVEREF(__pyx_t_2);
19348   PyTuple_SET_ITEM(__pyx_t_3, 2, __pyx_t_2);
19349   __pyx_t_2 = 0;
19350   __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)
19351   __Pyx_GOTREF(__pyx_t_2);
19352   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
19353   __pyx_v_result = ((struct __pyx_memoryviewslice_obj *)__pyx_t_2);
19354   __pyx_t_2 = 0;
19355 
19356   /* "View.MemoryView":1015
19357  *     result = _memoryviewslice(None, 0, dtype_is_object)
19358  *
19359  *     result.from_slice = memviewslice             # <<<<<<<<<<<<<<
19360  *     __PYX_INC_MEMVIEW(&memviewslice, 1)
19361  *
19362  */
19363   __pyx_v_result->from_slice = __pyx_v_memviewslice;
19364 
19365   /* "View.MemoryView":1016
19366  *
19367  *     result.from_slice = memviewslice
19368  *     __PYX_INC_MEMVIEW(&memviewslice, 1)             # <<<<<<<<<<<<<<
19369  *
19370  *     result.from_object = (<memoryview> memviewslice.memview).base
19371  */
19372   __PYX_INC_MEMVIEW((&__pyx_v_memviewslice), 1);
19373 
19374   /* "View.MemoryView":1018
19375  *     __PYX_INC_MEMVIEW(&memviewslice, 1)
19376  *
19377  *     result.from_object = (<memoryview> memviewslice.memview).base             # <<<<<<<<<<<<<<
19378  *     result.typeinfo = memviewslice.memview.typeinfo
19379  *
19380  */
19381   __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)
19382   __Pyx_GOTREF(__pyx_t_2);
19383   __Pyx_GIVEREF(__pyx_t_2);
19384   __Pyx_GOTREF(__pyx_v_result->from_object);
19385   __Pyx_DECREF(__pyx_v_result->from_object);
19386   __pyx_v_result->from_object = __pyx_t_2;
19387   __pyx_t_2 = 0;
19388 
19389   /* "View.MemoryView":1019
19390  *
19391  *     result.from_object = (<memoryview> memviewslice.memview).base
19392  *     result.typeinfo = memviewslice.memview.typeinfo             # <<<<<<<<<<<<<<
19393  *
19394  *     result.view = memviewslice.memview.view
19395  */
19396   __pyx_t_4 = __pyx_v_memviewslice.memview->typeinfo;
19397   __pyx_v_result->__pyx_base.typeinfo = __pyx_t_4;
19398 
19399   /* "View.MemoryView":1021
19400  *     result.typeinfo = memviewslice.memview.typeinfo
19401  *
19402  *     result.view = memviewslice.memview.view             # <<<<<<<<<<<<<<
19403  *     result.view.buf = <void *> memviewslice.data
19404  *     result.view.ndim = ndim
19405  */
19406   __pyx_t_5 = __pyx_v_memviewslice.memview->view;
19407   __pyx_v_result->__pyx_base.view = __pyx_t_5;
19408 
19409   /* "View.MemoryView":1022
19410  *
19411  *     result.view = memviewslice.memview.view
19412  *     result.view.buf = <void *> memviewslice.data             # <<<<<<<<<<<<<<
19413  *     result.view.ndim = ndim
19414  *     (<__pyx_buffer *> &result.view).obj = Py_None
19415  */
19416   __pyx_v_result->__pyx_base.view.buf = ((void *)__pyx_v_memviewslice.data);
19417 
19418   /* "View.MemoryView":1023
19419  *     result.view = memviewslice.memview.view
19420  *     result.view.buf = <void *> memviewslice.data
19421  *     result.view.ndim = ndim             # <<<<<<<<<<<<<<
19422  *     (<__pyx_buffer *> &result.view).obj = Py_None
19423  *     Py_INCREF(Py_None)
19424  */
19425   __pyx_v_result->__pyx_base.view.ndim = __pyx_v_ndim;
19426 
19427   /* "View.MemoryView":1024
19428  *     result.view.buf = <void *> memviewslice.data
19429  *     result.view.ndim = ndim
19430  *     (<__pyx_buffer *> &result.view).obj = Py_None             # <<<<<<<<<<<<<<
19431  *     Py_INCREF(Py_None)
19432  *
19433  */
19434   ((Py_buffer *)(&__pyx_v_result->__pyx_base.view))->obj = Py_None;
19435 
19436   /* "View.MemoryView":1025
19437  *     result.view.ndim = ndim
19438  *     (<__pyx_buffer *> &result.view).obj = Py_None
19439  *     Py_INCREF(Py_None)             # <<<<<<<<<<<<<<
19440  *
19441  *     if (<memoryview>memviewslice.memview).flags & PyBUF_WRITABLE:
19442  */
19443   Py_INCREF(Py_None);
19444 
19445   /* "View.MemoryView":1027
19446  *     Py_INCREF(Py_None)
19447  *
19448  *     if (<memoryview>memviewslice.memview).flags & PyBUF_WRITABLE:             # <<<<<<<<<<<<<<
19449  *         result.flags = PyBUF_RECORDS
19450  *     else:
19451  */
19452   __pyx_t_1 = ((((struct __pyx_memoryview_obj *)__pyx_v_memviewslice.memview)->flags & PyBUF_WRITABLE) != 0);
19453   if (__pyx_t_1) {
19454 
19455     /* "View.MemoryView":1028
19456  *
19457  *     if (<memoryview>memviewslice.memview).flags & PyBUF_WRITABLE:
19458  *         result.flags = PyBUF_RECORDS             # <<<<<<<<<<<<<<
19459  *     else:
19460  *         result.flags = PyBUF_RECORDS_RO
19461  */
19462     __pyx_v_result->__pyx_base.flags = PyBUF_RECORDS;
19463 
19464     /* "View.MemoryView":1027
19465  *     Py_INCREF(Py_None)
19466  *
19467  *     if (<memoryview>memviewslice.memview).flags & PyBUF_WRITABLE:             # <<<<<<<<<<<<<<
19468  *         result.flags = PyBUF_RECORDS
19469  *     else:
19470  */
19471     goto __pyx_L4;
19472   }
19473 
19474   /* "View.MemoryView":1030
19475  *         result.flags = PyBUF_RECORDS
19476  *     else:
19477  *         result.flags = PyBUF_RECORDS_RO             # <<<<<<<<<<<<<<
19478  *
19479  *     result.view.shape = <Py_ssize_t *> result.from_slice.shape
19480  */
19481   /*else*/ {
19482     __pyx_v_result->__pyx_base.flags = PyBUF_RECORDS_RO;
19483   }
19484   __pyx_L4:;
19485 
19486   /* "View.MemoryView":1032
19487  *         result.flags = PyBUF_RECORDS_RO
19488  *
19489  *     result.view.shape = <Py_ssize_t *> result.from_slice.shape             # <<<<<<<<<<<<<<
19490  *     result.view.strides = <Py_ssize_t *> result.from_slice.strides
19491  *
19492  */
19493   __pyx_v_result->__pyx_base.view.shape = ((Py_ssize_t *)__pyx_v_result->from_slice.shape);
19494 
19495   /* "View.MemoryView":1033
19496  *
19497  *     result.view.shape = <Py_ssize_t *> result.from_slice.shape
19498  *     result.view.strides = <Py_ssize_t *> result.from_slice.strides             # <<<<<<<<<<<<<<
19499  *
19500  *
19501  */
19502   __pyx_v_result->__pyx_base.view.strides = ((Py_ssize_t *)__pyx_v_result->from_slice.strides);
19503 
19504   /* "View.MemoryView":1036
19505  *
19506  *
19507  *     result.view.suboffsets = NULL             # <<<<<<<<<<<<<<
19508  *     for suboffset in result.from_slice.suboffsets[:ndim]:
19509  *         if suboffset >= 0:
19510  */
19511   __pyx_v_result->__pyx_base.view.suboffsets = NULL;
19512 
19513   /* "View.MemoryView":1037
19514  *
19515  *     result.view.suboffsets = NULL
19516  *     for suboffset in result.from_slice.suboffsets[:ndim]:             # <<<<<<<<<<<<<<
19517  *         if suboffset >= 0:
19518  *             result.view.suboffsets = <Py_ssize_t *> result.from_slice.suboffsets
19519  */
19520   __pyx_t_7 = (__pyx_v_result->from_slice.suboffsets + __pyx_v_ndim);
19521   for (__pyx_t_8 = __pyx_v_result->from_slice.suboffsets; __pyx_t_8 < __pyx_t_7; __pyx_t_8++) {
19522     __pyx_t_6 = __pyx_t_8;
19523     __pyx_v_suboffset = (__pyx_t_6[0]);
19524 
19525     /* "View.MemoryView":1038
19526  *     result.view.suboffsets = NULL
19527  *     for suboffset in result.from_slice.suboffsets[:ndim]:
19528  *         if suboffset >= 0:             # <<<<<<<<<<<<<<
19529  *             result.view.suboffsets = <Py_ssize_t *> result.from_slice.suboffsets
19530  *             break
19531  */
19532     __pyx_t_1 = ((__pyx_v_suboffset >= 0) != 0);
19533     if (__pyx_t_1) {
19534 
19535       /* "View.MemoryView":1039
19536  *     for suboffset in result.from_slice.suboffsets[:ndim]:
19537  *         if suboffset >= 0:
19538  *             result.view.suboffsets = <Py_ssize_t *> result.from_slice.suboffsets             # <<<<<<<<<<<<<<
19539  *             break
19540  *
19541  */
19542       __pyx_v_result->__pyx_base.view.suboffsets = ((Py_ssize_t *)__pyx_v_result->from_slice.suboffsets);
19543 
19544       /* "View.MemoryView":1040
19545  *         if suboffset >= 0:
19546  *             result.view.suboffsets = <Py_ssize_t *> result.from_slice.suboffsets
19547  *             break             # <<<<<<<<<<<<<<
19548  *
19549  *     result.view.len = result.view.itemsize
19550  */
19551       goto __pyx_L6_break;
19552 
19553       /* "View.MemoryView":1038
19554  *     result.view.suboffsets = NULL
19555  *     for suboffset in result.from_slice.suboffsets[:ndim]:
19556  *         if suboffset >= 0:             # <<<<<<<<<<<<<<
19557  *             result.view.suboffsets = <Py_ssize_t *> result.from_slice.suboffsets
19558  *             break
19559  */
19560     }
19561   }
19562   __pyx_L6_break:;
19563 
19564   /* "View.MemoryView":1042
19565  *             break
19566  *
19567  *     result.view.len = result.view.itemsize             # <<<<<<<<<<<<<<
19568  *     for length in result.view.shape[:ndim]:
19569  *         result.view.len *= length
19570  */
19571   __pyx_t_9 = __pyx_v_result->__pyx_base.view.itemsize;
19572   __pyx_v_result->__pyx_base.view.len = __pyx_t_9;
19573 
19574   /* "View.MemoryView":1043
19575  *
19576  *     result.view.len = result.view.itemsize
19577  *     for length in result.view.shape[:ndim]:             # <<<<<<<<<<<<<<
19578  *         result.view.len *= length
19579  *
19580  */
19581   __pyx_t_7 = (__pyx_v_result->__pyx_base.view.shape + __pyx_v_ndim);
19582   for (__pyx_t_8 = __pyx_v_result->__pyx_base.view.shape; __pyx_t_8 < __pyx_t_7; __pyx_t_8++) {
19583     __pyx_t_6 = __pyx_t_8;
19584     __pyx_t_2 = PyInt_FromSsize_t((__pyx_t_6[0])); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 1043, __pyx_L1_error)
19585     __Pyx_GOTREF(__pyx_t_2);
19586     __Pyx_XDECREF_SET(__pyx_v_length, __pyx_t_2);
19587     __pyx_t_2 = 0;
19588 
19589     /* "View.MemoryView":1044
19590  *     result.view.len = result.view.itemsize
19591  *     for length in result.view.shape[:ndim]:
19592  *         result.view.len *= length             # <<<<<<<<<<<<<<
19593  *
19594  *     result.to_object_func = to_object_func
19595  */
19596     __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)
19597     __Pyx_GOTREF(__pyx_t_2);
19598     __pyx_t_3 = PyNumber_InPlaceMultiply(__pyx_t_2, __pyx_v_length); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 1044, __pyx_L1_error)
19599     __Pyx_GOTREF(__pyx_t_3);
19600     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
19601     __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)
19602     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
19603     __pyx_v_result->__pyx_base.view.len = __pyx_t_9;
19604   }
19605 
19606   /* "View.MemoryView":1046
19607  *         result.view.len *= length
19608  *
19609  *     result.to_object_func = to_object_func             # <<<<<<<<<<<<<<
19610  *     result.to_dtype_func = to_dtype_func
19611  *
19612  */
19613   __pyx_v_result->to_object_func = __pyx_v_to_object_func;
19614 
19615   /* "View.MemoryView":1047
19616  *
19617  *     result.to_object_func = to_object_func
19618  *     result.to_dtype_func = to_dtype_func             # <<<<<<<<<<<<<<
19619  *
19620  *     return result
19621  */
19622   __pyx_v_result->to_dtype_func = __pyx_v_to_dtype_func;
19623 
19624   /* "View.MemoryView":1049
19625  *     result.to_dtype_func = to_dtype_func
19626  *
19627  *     return result             # <<<<<<<<<<<<<<
19628  *
19629  * @cname('__pyx_memoryview_get_slice_from_memoryview')
19630  */
19631   __Pyx_XDECREF(__pyx_r);
19632   __Pyx_INCREF(((PyObject *)__pyx_v_result));
19633   __pyx_r = ((PyObject *)__pyx_v_result);
19634   goto __pyx_L0;
19635 
19636   /* "View.MemoryView":999
19637  *
19638  * @cname('__pyx_memoryview_fromslice')
19639  * cdef memoryview_fromslice(__Pyx_memviewslice memviewslice,             # <<<<<<<<<<<<<<
19640  *                           int ndim,
19641  *                           object (*to_object_func)(char *),
19642  */
19643 
19644   /* function exit code */
19645   __pyx_L1_error:;
19646   __Pyx_XDECREF(__pyx_t_2);
19647   __Pyx_XDECREF(__pyx_t_3);
19648   __Pyx_AddTraceback("View.MemoryView.memoryview_fromslice", __pyx_clineno, __pyx_lineno, __pyx_filename);
19649   __pyx_r = 0;
19650   __pyx_L0:;
19651   __Pyx_XDECREF((PyObject *)__pyx_v_result);
19652   __Pyx_XDECREF(__pyx_v_length);
19653   __Pyx_XGIVEREF(__pyx_r);
19654   __Pyx_RefNannyFinishContext();
19655   return __pyx_r;
19656 }
19657 
19658 /* "View.MemoryView":1052
19659  *
19660  * @cname('__pyx_memoryview_get_slice_from_memoryview')
19661  * cdef __Pyx_memviewslice *get_slice_from_memview(memoryview memview,             # <<<<<<<<<<<<<<
19662  *                                                    __Pyx_memviewslice *mslice) except NULL:
19663  *     cdef _memoryviewslice obj
19664  */
19665 
__pyx_memoryview_get_slice_from_memoryview(struct __pyx_memoryview_obj * __pyx_v_memview,__Pyx_memviewslice * __pyx_v_mslice)19666 static __Pyx_memviewslice *__pyx_memoryview_get_slice_from_memoryview(struct __pyx_memoryview_obj *__pyx_v_memview, __Pyx_memviewslice *__pyx_v_mslice) {
19667   struct __pyx_memoryviewslice_obj *__pyx_v_obj = 0;
19668   __Pyx_memviewslice *__pyx_r;
19669   __Pyx_RefNannyDeclarations
19670   int __pyx_t_1;
19671   int __pyx_t_2;
19672   PyObject *__pyx_t_3 = NULL;
19673   int __pyx_lineno = 0;
19674   const char *__pyx_filename = NULL;
19675   int __pyx_clineno = 0;
19676   __Pyx_RefNannySetupContext("get_slice_from_memview", 0);
19677 
19678   /* "View.MemoryView":1055
19679  *                                                    __Pyx_memviewslice *mslice) except NULL:
19680  *     cdef _memoryviewslice obj
19681  *     if isinstance(memview, _memoryviewslice):             # <<<<<<<<<<<<<<
19682  *         obj = memview
19683  *         return &obj.from_slice
19684  */
19685   __pyx_t_1 = __Pyx_TypeCheck(((PyObject *)__pyx_v_memview), __pyx_memoryviewslice_type);
19686   __pyx_t_2 = (__pyx_t_1 != 0);
19687   if (__pyx_t_2) {
19688 
19689     /* "View.MemoryView":1056
19690  *     cdef _memoryviewslice obj
19691  *     if isinstance(memview, _memoryviewslice):
19692  *         obj = memview             # <<<<<<<<<<<<<<
19693  *         return &obj.from_slice
19694  *     else:
19695  */
19696     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)
19697     __pyx_t_3 = ((PyObject *)__pyx_v_memview);
19698     __Pyx_INCREF(__pyx_t_3);
19699     __pyx_v_obj = ((struct __pyx_memoryviewslice_obj *)__pyx_t_3);
19700     __pyx_t_3 = 0;
19701 
19702     /* "View.MemoryView":1057
19703  *     if isinstance(memview, _memoryviewslice):
19704  *         obj = memview
19705  *         return &obj.from_slice             # <<<<<<<<<<<<<<
19706  *     else:
19707  *         slice_copy(memview, mslice)
19708  */
19709     __pyx_r = (&__pyx_v_obj->from_slice);
19710     goto __pyx_L0;
19711 
19712     /* "View.MemoryView":1055
19713  *                                                    __Pyx_memviewslice *mslice) except NULL:
19714  *     cdef _memoryviewslice obj
19715  *     if isinstance(memview, _memoryviewslice):             # <<<<<<<<<<<<<<
19716  *         obj = memview
19717  *         return &obj.from_slice
19718  */
19719   }
19720 
19721   /* "View.MemoryView":1059
19722  *         return &obj.from_slice
19723  *     else:
19724  *         slice_copy(memview, mslice)             # <<<<<<<<<<<<<<
19725  *         return mslice
19726  *
19727  */
19728   /*else*/ {
19729     __pyx_memoryview_slice_copy(__pyx_v_memview, __pyx_v_mslice);
19730 
19731     /* "View.MemoryView":1060
19732  *     else:
19733  *         slice_copy(memview, mslice)
19734  *         return mslice             # <<<<<<<<<<<<<<
19735  *
19736  * @cname('__pyx_memoryview_slice_copy')
19737  */
19738     __pyx_r = __pyx_v_mslice;
19739     goto __pyx_L0;
19740   }
19741 
19742   /* "View.MemoryView":1052
19743  *
19744  * @cname('__pyx_memoryview_get_slice_from_memoryview')
19745  * cdef __Pyx_memviewslice *get_slice_from_memview(memoryview memview,             # <<<<<<<<<<<<<<
19746  *                                                    __Pyx_memviewslice *mslice) except NULL:
19747  *     cdef _memoryviewslice obj
19748  */
19749 
19750   /* function exit code */
19751   __pyx_L1_error:;
19752   __Pyx_XDECREF(__pyx_t_3);
19753   __Pyx_AddTraceback("View.MemoryView.get_slice_from_memview", __pyx_clineno, __pyx_lineno, __pyx_filename);
19754   __pyx_r = NULL;
19755   __pyx_L0:;
19756   __Pyx_XDECREF((PyObject *)__pyx_v_obj);
19757   __Pyx_RefNannyFinishContext();
19758   return __pyx_r;
19759 }
19760 
19761 /* "View.MemoryView":1063
19762  *
19763  * @cname('__pyx_memoryview_slice_copy')
19764  * cdef void slice_copy(memoryview memview, __Pyx_memviewslice *dst):             # <<<<<<<<<<<<<<
19765  *     cdef int dim
19766  *     cdef (Py_ssize_t*) shape, strides, suboffsets
19767  */
19768 
__pyx_memoryview_slice_copy(struct __pyx_memoryview_obj * __pyx_v_memview,__Pyx_memviewslice * __pyx_v_dst)19769 static void __pyx_memoryview_slice_copy(struct __pyx_memoryview_obj *__pyx_v_memview, __Pyx_memviewslice *__pyx_v_dst) {
19770   int __pyx_v_dim;
19771   Py_ssize_t *__pyx_v_shape;
19772   Py_ssize_t *__pyx_v_strides;
19773   Py_ssize_t *__pyx_v_suboffsets;
19774   __Pyx_RefNannyDeclarations
19775   Py_ssize_t *__pyx_t_1;
19776   int __pyx_t_2;
19777   int __pyx_t_3;
19778   int __pyx_t_4;
19779   Py_ssize_t __pyx_t_5;
19780   __Pyx_RefNannySetupContext("slice_copy", 0);
19781 
19782   /* "View.MemoryView":1067
19783  *     cdef (Py_ssize_t*) shape, strides, suboffsets
19784  *
19785  *     shape = memview.view.shape             # <<<<<<<<<<<<<<
19786  *     strides = memview.view.strides
19787  *     suboffsets = memview.view.suboffsets
19788  */
19789   __pyx_t_1 = __pyx_v_memview->view.shape;
19790   __pyx_v_shape = __pyx_t_1;
19791 
19792   /* "View.MemoryView":1068
19793  *
19794  *     shape = memview.view.shape
19795  *     strides = memview.view.strides             # <<<<<<<<<<<<<<
19796  *     suboffsets = memview.view.suboffsets
19797  *
19798  */
19799   __pyx_t_1 = __pyx_v_memview->view.strides;
19800   __pyx_v_strides = __pyx_t_1;
19801 
19802   /* "View.MemoryView":1069
19803  *     shape = memview.view.shape
19804  *     strides = memview.view.strides
19805  *     suboffsets = memview.view.suboffsets             # <<<<<<<<<<<<<<
19806  *
19807  *     dst.memview = <__pyx_memoryview *> memview
19808  */
19809   __pyx_t_1 = __pyx_v_memview->view.suboffsets;
19810   __pyx_v_suboffsets = __pyx_t_1;
19811 
19812   /* "View.MemoryView":1071
19813  *     suboffsets = memview.view.suboffsets
19814  *
19815  *     dst.memview = <__pyx_memoryview *> memview             # <<<<<<<<<<<<<<
19816  *     dst.data = <char *> memview.view.buf
19817  *
19818  */
19819   __pyx_v_dst->memview = ((struct __pyx_memoryview_obj *)__pyx_v_memview);
19820 
19821   /* "View.MemoryView":1072
19822  *
19823  *     dst.memview = <__pyx_memoryview *> memview
19824  *     dst.data = <char *> memview.view.buf             # <<<<<<<<<<<<<<
19825  *
19826  *     for dim in range(memview.view.ndim):
19827  */
19828   __pyx_v_dst->data = ((char *)__pyx_v_memview->view.buf);
19829 
19830   /* "View.MemoryView":1074
19831  *     dst.data = <char *> memview.view.buf
19832  *
19833  *     for dim in range(memview.view.ndim):             # <<<<<<<<<<<<<<
19834  *         dst.shape[dim] = shape[dim]
19835  *         dst.strides[dim] = strides[dim]
19836  */
19837   __pyx_t_2 = __pyx_v_memview->view.ndim;
19838   __pyx_t_3 = __pyx_t_2;
19839   for (__pyx_t_4 = 0; __pyx_t_4 < __pyx_t_3; __pyx_t_4+=1) {
19840     __pyx_v_dim = __pyx_t_4;
19841 
19842     /* "View.MemoryView":1075
19843  *
19844  *     for dim in range(memview.view.ndim):
19845  *         dst.shape[dim] = shape[dim]             # <<<<<<<<<<<<<<
19846  *         dst.strides[dim] = strides[dim]
19847  *         dst.suboffsets[dim] = suboffsets[dim] if suboffsets else -1
19848  */
19849     (__pyx_v_dst->shape[__pyx_v_dim]) = (__pyx_v_shape[__pyx_v_dim]);
19850 
19851     /* "View.MemoryView":1076
19852  *     for dim in range(memview.view.ndim):
19853  *         dst.shape[dim] = shape[dim]
19854  *         dst.strides[dim] = strides[dim]             # <<<<<<<<<<<<<<
19855  *         dst.suboffsets[dim] = suboffsets[dim] if suboffsets else -1
19856  *
19857  */
19858     (__pyx_v_dst->strides[__pyx_v_dim]) = (__pyx_v_strides[__pyx_v_dim]);
19859 
19860     /* "View.MemoryView":1077
19861  *         dst.shape[dim] = shape[dim]
19862  *         dst.strides[dim] = strides[dim]
19863  *         dst.suboffsets[dim] = suboffsets[dim] if suboffsets else -1             # <<<<<<<<<<<<<<
19864  *
19865  * @cname('__pyx_memoryview_copy_object')
19866  */
19867     if ((__pyx_v_suboffsets != 0)) {
19868       __pyx_t_5 = (__pyx_v_suboffsets[__pyx_v_dim]);
19869     } else {
19870       __pyx_t_5 = -1L;
19871     }
19872     (__pyx_v_dst->suboffsets[__pyx_v_dim]) = __pyx_t_5;
19873   }
19874 
19875   /* "View.MemoryView":1063
19876  *
19877  * @cname('__pyx_memoryview_slice_copy')
19878  * cdef void slice_copy(memoryview memview, __Pyx_memviewslice *dst):             # <<<<<<<<<<<<<<
19879  *     cdef int dim
19880  *     cdef (Py_ssize_t*) shape, strides, suboffsets
19881  */
19882 
19883   /* function exit code */
19884   __Pyx_RefNannyFinishContext();
19885 }
19886 
19887 /* "View.MemoryView":1080
19888  *
19889  * @cname('__pyx_memoryview_copy_object')
19890  * cdef memoryview_copy(memoryview memview):             # <<<<<<<<<<<<<<
19891  *     "Create a new memoryview object"
19892  *     cdef __Pyx_memviewslice memviewslice
19893  */
19894 
__pyx_memoryview_copy_object(struct __pyx_memoryview_obj * __pyx_v_memview)19895 static PyObject *__pyx_memoryview_copy_object(struct __pyx_memoryview_obj *__pyx_v_memview) {
19896   __Pyx_memviewslice __pyx_v_memviewslice;
19897   PyObject *__pyx_r = NULL;
19898   __Pyx_RefNannyDeclarations
19899   PyObject *__pyx_t_1 = NULL;
19900   int __pyx_lineno = 0;
19901   const char *__pyx_filename = NULL;
19902   int __pyx_clineno = 0;
19903   __Pyx_RefNannySetupContext("memoryview_copy", 0);
19904 
19905   /* "View.MemoryView":1083
19906  *     "Create a new memoryview object"
19907  *     cdef __Pyx_memviewslice memviewslice
19908  *     slice_copy(memview, &memviewslice)             # <<<<<<<<<<<<<<
19909  *     return memoryview_copy_from_slice(memview, &memviewslice)
19910  *
19911  */
19912   __pyx_memoryview_slice_copy(__pyx_v_memview, (&__pyx_v_memviewslice));
19913 
19914   /* "View.MemoryView":1084
19915  *     cdef __Pyx_memviewslice memviewslice
19916  *     slice_copy(memview, &memviewslice)
19917  *     return memoryview_copy_from_slice(memview, &memviewslice)             # <<<<<<<<<<<<<<
19918  *
19919  * @cname('__pyx_memoryview_copy_object_from_slice')
19920  */
19921   __Pyx_XDECREF(__pyx_r);
19922   __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)
19923   __Pyx_GOTREF(__pyx_t_1);
19924   __pyx_r = __pyx_t_1;
19925   __pyx_t_1 = 0;
19926   goto __pyx_L0;
19927 
19928   /* "View.MemoryView":1080
19929  *
19930  * @cname('__pyx_memoryview_copy_object')
19931  * cdef memoryview_copy(memoryview memview):             # <<<<<<<<<<<<<<
19932  *     "Create a new memoryview object"
19933  *     cdef __Pyx_memviewslice memviewslice
19934  */
19935 
19936   /* function exit code */
19937   __pyx_L1_error:;
19938   __Pyx_XDECREF(__pyx_t_1);
19939   __Pyx_AddTraceback("View.MemoryView.memoryview_copy", __pyx_clineno, __pyx_lineno, __pyx_filename);
19940   __pyx_r = 0;
19941   __pyx_L0:;
19942   __Pyx_XGIVEREF(__pyx_r);
19943   __Pyx_RefNannyFinishContext();
19944   return __pyx_r;
19945 }
19946 
19947 /* "View.MemoryView":1087
19948  *
19949  * @cname('__pyx_memoryview_copy_object_from_slice')
19950  * cdef memoryview_copy_from_slice(memoryview memview, __Pyx_memviewslice *memviewslice):             # <<<<<<<<<<<<<<
19951  *     """
19952  *     Create a new memoryview object from a given memoryview object and slice.
19953  */
19954 
__pyx_memoryview_copy_object_from_slice(struct __pyx_memoryview_obj * __pyx_v_memview,__Pyx_memviewslice * __pyx_v_memviewslice)19955 static PyObject *__pyx_memoryview_copy_object_from_slice(struct __pyx_memoryview_obj *__pyx_v_memview, __Pyx_memviewslice *__pyx_v_memviewslice) {
19956   PyObject *(*__pyx_v_to_object_func)(char *);
19957   int (*__pyx_v_to_dtype_func)(char *, PyObject *);
19958   PyObject *__pyx_r = NULL;
19959   __Pyx_RefNannyDeclarations
19960   int __pyx_t_1;
19961   int __pyx_t_2;
19962   PyObject *(*__pyx_t_3)(char *);
19963   int (*__pyx_t_4)(char *, PyObject *);
19964   PyObject *__pyx_t_5 = NULL;
19965   int __pyx_lineno = 0;
19966   const char *__pyx_filename = NULL;
19967   int __pyx_clineno = 0;
19968   __Pyx_RefNannySetupContext("memoryview_copy_from_slice", 0);
19969 
19970   /* "View.MemoryView":1094
19971  *     cdef int (*to_dtype_func)(char *, object) except 0
19972  *
19973  *     if isinstance(memview, _memoryviewslice):             # <<<<<<<<<<<<<<
19974  *         to_object_func = (<_memoryviewslice> memview).to_object_func
19975  *         to_dtype_func = (<_memoryviewslice> memview).to_dtype_func
19976  */
19977   __pyx_t_1 = __Pyx_TypeCheck(((PyObject *)__pyx_v_memview), __pyx_memoryviewslice_type);
19978   __pyx_t_2 = (__pyx_t_1 != 0);
19979   if (__pyx_t_2) {
19980 
19981     /* "View.MemoryView":1095
19982  *
19983  *     if isinstance(memview, _memoryviewslice):
19984  *         to_object_func = (<_memoryviewslice> memview).to_object_func             # <<<<<<<<<<<<<<
19985  *         to_dtype_func = (<_memoryviewslice> memview).to_dtype_func
19986  *     else:
19987  */
19988     __pyx_t_3 = ((struct __pyx_memoryviewslice_obj *)__pyx_v_memview)->to_object_func;
19989     __pyx_v_to_object_func = __pyx_t_3;
19990 
19991     /* "View.MemoryView":1096
19992  *     if isinstance(memview, _memoryviewslice):
19993  *         to_object_func = (<_memoryviewslice> memview).to_object_func
19994  *         to_dtype_func = (<_memoryviewslice> memview).to_dtype_func             # <<<<<<<<<<<<<<
19995  *     else:
19996  *         to_object_func = NULL
19997  */
19998     __pyx_t_4 = ((struct __pyx_memoryviewslice_obj *)__pyx_v_memview)->to_dtype_func;
19999     __pyx_v_to_dtype_func = __pyx_t_4;
20000 
20001     /* "View.MemoryView":1094
20002  *     cdef int (*to_dtype_func)(char *, object) except 0
20003  *
20004  *     if isinstance(memview, _memoryviewslice):             # <<<<<<<<<<<<<<
20005  *         to_object_func = (<_memoryviewslice> memview).to_object_func
20006  *         to_dtype_func = (<_memoryviewslice> memview).to_dtype_func
20007  */
20008     goto __pyx_L3;
20009   }
20010 
20011   /* "View.MemoryView":1098
20012  *         to_dtype_func = (<_memoryviewslice> memview).to_dtype_func
20013  *     else:
20014  *         to_object_func = NULL             # <<<<<<<<<<<<<<
20015  *         to_dtype_func = NULL
20016  *
20017  */
20018   /*else*/ {
20019     __pyx_v_to_object_func = NULL;
20020 
20021     /* "View.MemoryView":1099
20022  *     else:
20023  *         to_object_func = NULL
20024  *         to_dtype_func = NULL             # <<<<<<<<<<<<<<
20025  *
20026  *     return memoryview_fromslice(memviewslice[0], memview.view.ndim,
20027  */
20028     __pyx_v_to_dtype_func = NULL;
20029   }
20030   __pyx_L3:;
20031 
20032   /* "View.MemoryView":1101
20033  *         to_dtype_func = NULL
20034  *
20035  *     return memoryview_fromslice(memviewslice[0], memview.view.ndim,             # <<<<<<<<<<<<<<
20036  *                                 to_object_func, to_dtype_func,
20037  *                                 memview.dtype_is_object)
20038  */
20039   __Pyx_XDECREF(__pyx_r);
20040 
20041   /* "View.MemoryView":1103
20042  *     return memoryview_fromslice(memviewslice[0], memview.view.ndim,
20043  *                                 to_object_func, to_dtype_func,
20044  *                                 memview.dtype_is_object)             # <<<<<<<<<<<<<<
20045  *
20046  *
20047  */
20048   __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)
20049   __Pyx_GOTREF(__pyx_t_5);
20050   __pyx_r = __pyx_t_5;
20051   __pyx_t_5 = 0;
20052   goto __pyx_L0;
20053 
20054   /* "View.MemoryView":1087
20055  *
20056  * @cname('__pyx_memoryview_copy_object_from_slice')
20057  * cdef memoryview_copy_from_slice(memoryview memview, __Pyx_memviewslice *memviewslice):             # <<<<<<<<<<<<<<
20058  *     """
20059  *     Create a new memoryview object from a given memoryview object and slice.
20060  */
20061 
20062   /* function exit code */
20063   __pyx_L1_error:;
20064   __Pyx_XDECREF(__pyx_t_5);
20065   __Pyx_AddTraceback("View.MemoryView.memoryview_copy_from_slice", __pyx_clineno, __pyx_lineno, __pyx_filename);
20066   __pyx_r = 0;
20067   __pyx_L0:;
20068   __Pyx_XGIVEREF(__pyx_r);
20069   __Pyx_RefNannyFinishContext();
20070   return __pyx_r;
20071 }
20072 
20073 /* "View.MemoryView":1109
20074  *
20075  *
20076  * cdef Py_ssize_t abs_py_ssize_t(Py_ssize_t arg) nogil:             # <<<<<<<<<<<<<<
20077  *     if arg < 0:
20078  *         return -arg
20079  */
20080 
abs_py_ssize_t(Py_ssize_t __pyx_v_arg)20081 static Py_ssize_t abs_py_ssize_t(Py_ssize_t __pyx_v_arg) {
20082   Py_ssize_t __pyx_r;
20083   int __pyx_t_1;
20084 
20085   /* "View.MemoryView":1110
20086  *
20087  * cdef Py_ssize_t abs_py_ssize_t(Py_ssize_t arg) nogil:
20088  *     if arg < 0:             # <<<<<<<<<<<<<<
20089  *         return -arg
20090  *     else:
20091  */
20092   __pyx_t_1 = ((__pyx_v_arg < 0) != 0);
20093   if (__pyx_t_1) {
20094 
20095     /* "View.MemoryView":1111
20096  * cdef Py_ssize_t abs_py_ssize_t(Py_ssize_t arg) nogil:
20097  *     if arg < 0:
20098  *         return -arg             # <<<<<<<<<<<<<<
20099  *     else:
20100  *         return arg
20101  */
20102     __pyx_r = (-__pyx_v_arg);
20103     goto __pyx_L0;
20104 
20105     /* "View.MemoryView":1110
20106  *
20107  * cdef Py_ssize_t abs_py_ssize_t(Py_ssize_t arg) nogil:
20108  *     if arg < 0:             # <<<<<<<<<<<<<<
20109  *         return -arg
20110  *     else:
20111  */
20112   }
20113 
20114   /* "View.MemoryView":1113
20115  *         return -arg
20116  *     else:
20117  *         return arg             # <<<<<<<<<<<<<<
20118  *
20119  * @cname('__pyx_get_best_slice_order')
20120  */
20121   /*else*/ {
20122     __pyx_r = __pyx_v_arg;
20123     goto __pyx_L0;
20124   }
20125 
20126   /* "View.MemoryView":1109
20127  *
20128  *
20129  * cdef Py_ssize_t abs_py_ssize_t(Py_ssize_t arg) nogil:             # <<<<<<<<<<<<<<
20130  *     if arg < 0:
20131  *         return -arg
20132  */
20133 
20134   /* function exit code */
20135   __pyx_L0:;
20136   return __pyx_r;
20137 }
20138 
20139 /* "View.MemoryView":1116
20140  *
20141  * @cname('__pyx_get_best_slice_order')
20142  * cdef char get_best_order(__Pyx_memviewslice *mslice, int ndim) nogil:             # <<<<<<<<<<<<<<
20143  *     """
20144  *     Figure out the best memory access order for a given slice.
20145  */
20146 
__pyx_get_best_slice_order(__Pyx_memviewslice * __pyx_v_mslice,int __pyx_v_ndim)20147 static char __pyx_get_best_slice_order(__Pyx_memviewslice *__pyx_v_mslice, int __pyx_v_ndim) {
20148   int __pyx_v_i;
20149   Py_ssize_t __pyx_v_c_stride;
20150   Py_ssize_t __pyx_v_f_stride;
20151   char __pyx_r;
20152   int __pyx_t_1;
20153   int __pyx_t_2;
20154   int __pyx_t_3;
20155   int __pyx_t_4;
20156 
20157   /* "View.MemoryView":1121
20158  *     """
20159  *     cdef int i
20160  *     cdef Py_ssize_t c_stride = 0             # <<<<<<<<<<<<<<
20161  *     cdef Py_ssize_t f_stride = 0
20162  *
20163  */
20164   __pyx_v_c_stride = 0;
20165 
20166   /* "View.MemoryView":1122
20167  *     cdef int i
20168  *     cdef Py_ssize_t c_stride = 0
20169  *     cdef Py_ssize_t f_stride = 0             # <<<<<<<<<<<<<<
20170  *
20171  *     for i in range(ndim - 1, -1, -1):
20172  */
20173   __pyx_v_f_stride = 0;
20174 
20175   /* "View.MemoryView":1124
20176  *     cdef Py_ssize_t f_stride = 0
20177  *
20178  *     for i in range(ndim - 1, -1, -1):             # <<<<<<<<<<<<<<
20179  *         if mslice.shape[i] > 1:
20180  *             c_stride = mslice.strides[i]
20181  */
20182   for (__pyx_t_1 = (__pyx_v_ndim - 1); __pyx_t_1 > -1; __pyx_t_1-=1) {
20183     __pyx_v_i = __pyx_t_1;
20184 
20185     /* "View.MemoryView":1125
20186  *
20187  *     for i in range(ndim - 1, -1, -1):
20188  *         if mslice.shape[i] > 1:             # <<<<<<<<<<<<<<
20189  *             c_stride = mslice.strides[i]
20190  *             break
20191  */
20192     __pyx_t_2 = (((__pyx_v_mslice->shape[__pyx_v_i]) > 1) != 0);
20193     if (__pyx_t_2) {
20194 
20195       /* "View.MemoryView":1126
20196  *     for i in range(ndim - 1, -1, -1):
20197  *         if mslice.shape[i] > 1:
20198  *             c_stride = mslice.strides[i]             # <<<<<<<<<<<<<<
20199  *             break
20200  *
20201  */
20202       __pyx_v_c_stride = (__pyx_v_mslice->strides[__pyx_v_i]);
20203 
20204       /* "View.MemoryView":1127
20205  *         if mslice.shape[i] > 1:
20206  *             c_stride = mslice.strides[i]
20207  *             break             # <<<<<<<<<<<<<<
20208  *
20209  *     for i in range(ndim):
20210  */
20211       goto __pyx_L4_break;
20212 
20213       /* "View.MemoryView":1125
20214  *
20215  *     for i in range(ndim - 1, -1, -1):
20216  *         if mslice.shape[i] > 1:             # <<<<<<<<<<<<<<
20217  *             c_stride = mslice.strides[i]
20218  *             break
20219  */
20220     }
20221   }
20222   __pyx_L4_break:;
20223 
20224   /* "View.MemoryView":1129
20225  *             break
20226  *
20227  *     for i in range(ndim):             # <<<<<<<<<<<<<<
20228  *         if mslice.shape[i] > 1:
20229  *             f_stride = mslice.strides[i]
20230  */
20231   __pyx_t_1 = __pyx_v_ndim;
20232   __pyx_t_3 = __pyx_t_1;
20233   for (__pyx_t_4 = 0; __pyx_t_4 < __pyx_t_3; __pyx_t_4+=1) {
20234     __pyx_v_i = __pyx_t_4;
20235 
20236     /* "View.MemoryView":1130
20237  *
20238  *     for i in range(ndim):
20239  *         if mslice.shape[i] > 1:             # <<<<<<<<<<<<<<
20240  *             f_stride = mslice.strides[i]
20241  *             break
20242  */
20243     __pyx_t_2 = (((__pyx_v_mslice->shape[__pyx_v_i]) > 1) != 0);
20244     if (__pyx_t_2) {
20245 
20246       /* "View.MemoryView":1131
20247  *     for i in range(ndim):
20248  *         if mslice.shape[i] > 1:
20249  *             f_stride = mslice.strides[i]             # <<<<<<<<<<<<<<
20250  *             break
20251  *
20252  */
20253       __pyx_v_f_stride = (__pyx_v_mslice->strides[__pyx_v_i]);
20254 
20255       /* "View.MemoryView":1132
20256  *         if mslice.shape[i] > 1:
20257  *             f_stride = mslice.strides[i]
20258  *             break             # <<<<<<<<<<<<<<
20259  *
20260  *     if abs_py_ssize_t(c_stride) <= abs_py_ssize_t(f_stride):
20261  */
20262       goto __pyx_L7_break;
20263 
20264       /* "View.MemoryView":1130
20265  *
20266  *     for i in range(ndim):
20267  *         if mslice.shape[i] > 1:             # <<<<<<<<<<<<<<
20268  *             f_stride = mslice.strides[i]
20269  *             break
20270  */
20271     }
20272   }
20273   __pyx_L7_break:;
20274 
20275   /* "View.MemoryView":1134
20276  *             break
20277  *
20278  *     if abs_py_ssize_t(c_stride) <= abs_py_ssize_t(f_stride):             # <<<<<<<<<<<<<<
20279  *         return 'C'
20280  *     else:
20281  */
20282   __pyx_t_2 = ((abs_py_ssize_t(__pyx_v_c_stride) <= abs_py_ssize_t(__pyx_v_f_stride)) != 0);
20283   if (__pyx_t_2) {
20284 
20285     /* "View.MemoryView":1135
20286  *
20287  *     if abs_py_ssize_t(c_stride) <= abs_py_ssize_t(f_stride):
20288  *         return 'C'             # <<<<<<<<<<<<<<
20289  *     else:
20290  *         return 'F'
20291  */
20292     __pyx_r = 'C';
20293     goto __pyx_L0;
20294 
20295     /* "View.MemoryView":1134
20296  *             break
20297  *
20298  *     if abs_py_ssize_t(c_stride) <= abs_py_ssize_t(f_stride):             # <<<<<<<<<<<<<<
20299  *         return 'C'
20300  *     else:
20301  */
20302   }
20303 
20304   /* "View.MemoryView":1137
20305  *         return 'C'
20306  *     else:
20307  *         return 'F'             # <<<<<<<<<<<<<<
20308  *
20309  * @cython.cdivision(True)
20310  */
20311   /*else*/ {
20312     __pyx_r = 'F';
20313     goto __pyx_L0;
20314   }
20315 
20316   /* "View.MemoryView":1116
20317  *
20318  * @cname('__pyx_get_best_slice_order')
20319  * cdef char get_best_order(__Pyx_memviewslice *mslice, int ndim) nogil:             # <<<<<<<<<<<<<<
20320  *     """
20321  *     Figure out the best memory access order for a given slice.
20322  */
20323 
20324   /* function exit code */
20325   __pyx_L0:;
20326   return __pyx_r;
20327 }
20328 
20329 /* "View.MemoryView":1140
20330  *
20331  * @cython.cdivision(True)
20332  * cdef void _copy_strided_to_strided(char *src_data, Py_ssize_t *src_strides,             # <<<<<<<<<<<<<<
20333  *                                    char *dst_data, Py_ssize_t *dst_strides,
20334  *                                    Py_ssize_t *src_shape, Py_ssize_t *dst_shape,
20335  */
20336 
_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)20337 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) {
20338   CYTHON_UNUSED Py_ssize_t __pyx_v_i;
20339   CYTHON_UNUSED Py_ssize_t __pyx_v_src_extent;
20340   Py_ssize_t __pyx_v_dst_extent;
20341   Py_ssize_t __pyx_v_src_stride;
20342   Py_ssize_t __pyx_v_dst_stride;
20343   int __pyx_t_1;
20344   int __pyx_t_2;
20345   int __pyx_t_3;
20346   Py_ssize_t __pyx_t_4;
20347   Py_ssize_t __pyx_t_5;
20348   Py_ssize_t __pyx_t_6;
20349 
20350   /* "View.MemoryView":1147
20351  *
20352  *     cdef Py_ssize_t i
20353  *     cdef Py_ssize_t src_extent = src_shape[0]             # <<<<<<<<<<<<<<
20354  *     cdef Py_ssize_t dst_extent = dst_shape[0]
20355  *     cdef Py_ssize_t src_stride = src_strides[0]
20356  */
20357   __pyx_v_src_extent = (__pyx_v_src_shape[0]);
20358 
20359   /* "View.MemoryView":1148
20360  *     cdef Py_ssize_t i
20361  *     cdef Py_ssize_t src_extent = src_shape[0]
20362  *     cdef Py_ssize_t dst_extent = dst_shape[0]             # <<<<<<<<<<<<<<
20363  *     cdef Py_ssize_t src_stride = src_strides[0]
20364  *     cdef Py_ssize_t dst_stride = dst_strides[0]
20365  */
20366   __pyx_v_dst_extent = (__pyx_v_dst_shape[0]);
20367 
20368   /* "View.MemoryView":1149
20369  *     cdef Py_ssize_t src_extent = src_shape[0]
20370  *     cdef Py_ssize_t dst_extent = dst_shape[0]
20371  *     cdef Py_ssize_t src_stride = src_strides[0]             # <<<<<<<<<<<<<<
20372  *     cdef Py_ssize_t dst_stride = dst_strides[0]
20373  *
20374  */
20375   __pyx_v_src_stride = (__pyx_v_src_strides[0]);
20376 
20377   /* "View.MemoryView":1150
20378  *     cdef Py_ssize_t dst_extent = dst_shape[0]
20379  *     cdef Py_ssize_t src_stride = src_strides[0]
20380  *     cdef Py_ssize_t dst_stride = dst_strides[0]             # <<<<<<<<<<<<<<
20381  *
20382  *     if ndim == 1:
20383  */
20384   __pyx_v_dst_stride = (__pyx_v_dst_strides[0]);
20385 
20386   /* "View.MemoryView":1152
20387  *     cdef Py_ssize_t dst_stride = dst_strides[0]
20388  *
20389  *     if ndim == 1:             # <<<<<<<<<<<<<<
20390  *        if (src_stride > 0 and dst_stride > 0 and
20391  *            <size_t> src_stride == itemsize == <size_t> dst_stride):
20392  */
20393   __pyx_t_1 = ((__pyx_v_ndim == 1) != 0);
20394   if (__pyx_t_1) {
20395 
20396     /* "View.MemoryView":1153
20397  *
20398  *     if ndim == 1:
20399  *        if (src_stride > 0 and dst_stride > 0 and             # <<<<<<<<<<<<<<
20400  *            <size_t> src_stride == itemsize == <size_t> dst_stride):
20401  *            memcpy(dst_data, src_data, itemsize * dst_extent)
20402  */
20403     __pyx_t_2 = ((__pyx_v_src_stride > 0) != 0);
20404     if (__pyx_t_2) {
20405     } else {
20406       __pyx_t_1 = __pyx_t_2;
20407       goto __pyx_L5_bool_binop_done;
20408     }
20409     __pyx_t_2 = ((__pyx_v_dst_stride > 0) != 0);
20410     if (__pyx_t_2) {
20411     } else {
20412       __pyx_t_1 = __pyx_t_2;
20413       goto __pyx_L5_bool_binop_done;
20414     }
20415 
20416     /* "View.MemoryView":1154
20417  *     if ndim == 1:
20418  *        if (src_stride > 0 and dst_stride > 0 and
20419  *            <size_t> src_stride == itemsize == <size_t> dst_stride):             # <<<<<<<<<<<<<<
20420  *            memcpy(dst_data, src_data, itemsize * dst_extent)
20421  *        else:
20422  */
20423     __pyx_t_2 = (((size_t)__pyx_v_src_stride) == __pyx_v_itemsize);
20424     if (__pyx_t_2) {
20425       __pyx_t_2 = (__pyx_v_itemsize == ((size_t)__pyx_v_dst_stride));
20426     }
20427     __pyx_t_3 = (__pyx_t_2 != 0);
20428     __pyx_t_1 = __pyx_t_3;
20429     __pyx_L5_bool_binop_done:;
20430 
20431     /* "View.MemoryView":1153
20432  *
20433  *     if ndim == 1:
20434  *        if (src_stride > 0 and dst_stride > 0 and             # <<<<<<<<<<<<<<
20435  *            <size_t> src_stride == itemsize == <size_t> dst_stride):
20436  *            memcpy(dst_data, src_data, itemsize * dst_extent)
20437  */
20438     if (__pyx_t_1) {
20439 
20440       /* "View.MemoryView":1155
20441  *        if (src_stride > 0 and dst_stride > 0 and
20442  *            <size_t> src_stride == itemsize == <size_t> dst_stride):
20443  *            memcpy(dst_data, src_data, itemsize * dst_extent)             # <<<<<<<<<<<<<<
20444  *        else:
20445  *            for i in range(dst_extent):
20446  */
20447       (void)(memcpy(__pyx_v_dst_data, __pyx_v_src_data, (__pyx_v_itemsize * __pyx_v_dst_extent)));
20448 
20449       /* "View.MemoryView":1153
20450  *
20451  *     if ndim == 1:
20452  *        if (src_stride > 0 and dst_stride > 0 and             # <<<<<<<<<<<<<<
20453  *            <size_t> src_stride == itemsize == <size_t> dst_stride):
20454  *            memcpy(dst_data, src_data, itemsize * dst_extent)
20455  */
20456       goto __pyx_L4;
20457     }
20458 
20459     /* "View.MemoryView":1157
20460  *            memcpy(dst_data, src_data, itemsize * dst_extent)
20461  *        else:
20462  *            for i in range(dst_extent):             # <<<<<<<<<<<<<<
20463  *                memcpy(dst_data, src_data, itemsize)
20464  *                src_data += src_stride
20465  */
20466     /*else*/ {
20467       __pyx_t_4 = __pyx_v_dst_extent;
20468       __pyx_t_5 = __pyx_t_4;
20469       for (__pyx_t_6 = 0; __pyx_t_6 < __pyx_t_5; __pyx_t_6+=1) {
20470         __pyx_v_i = __pyx_t_6;
20471 
20472         /* "View.MemoryView":1158
20473  *        else:
20474  *            for i in range(dst_extent):
20475  *                memcpy(dst_data, src_data, itemsize)             # <<<<<<<<<<<<<<
20476  *                src_data += src_stride
20477  *                dst_data += dst_stride
20478  */
20479         (void)(memcpy(__pyx_v_dst_data, __pyx_v_src_data, __pyx_v_itemsize));
20480 
20481         /* "View.MemoryView":1159
20482  *            for i in range(dst_extent):
20483  *                memcpy(dst_data, src_data, itemsize)
20484  *                src_data += src_stride             # <<<<<<<<<<<<<<
20485  *                dst_data += dst_stride
20486  *     else:
20487  */
20488         __pyx_v_src_data = (__pyx_v_src_data + __pyx_v_src_stride);
20489 
20490         /* "View.MemoryView":1160
20491  *                memcpy(dst_data, src_data, itemsize)
20492  *                src_data += src_stride
20493  *                dst_data += dst_stride             # <<<<<<<<<<<<<<
20494  *     else:
20495  *         for i in range(dst_extent):
20496  */
20497         __pyx_v_dst_data = (__pyx_v_dst_data + __pyx_v_dst_stride);
20498       }
20499     }
20500     __pyx_L4:;
20501 
20502     /* "View.MemoryView":1152
20503  *     cdef Py_ssize_t dst_stride = dst_strides[0]
20504  *
20505  *     if ndim == 1:             # <<<<<<<<<<<<<<
20506  *        if (src_stride > 0 and dst_stride > 0 and
20507  *            <size_t> src_stride == itemsize == <size_t> dst_stride):
20508  */
20509     goto __pyx_L3;
20510   }
20511 
20512   /* "View.MemoryView":1162
20513  *                dst_data += dst_stride
20514  *     else:
20515  *         for i in range(dst_extent):             # <<<<<<<<<<<<<<
20516  *             _copy_strided_to_strided(src_data, src_strides + 1,
20517  *                                      dst_data, dst_strides + 1,
20518  */
20519   /*else*/ {
20520     __pyx_t_4 = __pyx_v_dst_extent;
20521     __pyx_t_5 = __pyx_t_4;
20522     for (__pyx_t_6 = 0; __pyx_t_6 < __pyx_t_5; __pyx_t_6+=1) {
20523       __pyx_v_i = __pyx_t_6;
20524 
20525       /* "View.MemoryView":1163
20526  *     else:
20527  *         for i in range(dst_extent):
20528  *             _copy_strided_to_strided(src_data, src_strides + 1,             # <<<<<<<<<<<<<<
20529  *                                      dst_data, dst_strides + 1,
20530  *                                      src_shape + 1, dst_shape + 1,
20531  */
20532       _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);
20533 
20534       /* "View.MemoryView":1167
20535  *                                      src_shape + 1, dst_shape + 1,
20536  *                                      ndim - 1, itemsize)
20537  *             src_data += src_stride             # <<<<<<<<<<<<<<
20538  *             dst_data += dst_stride
20539  *
20540  */
20541       __pyx_v_src_data = (__pyx_v_src_data + __pyx_v_src_stride);
20542 
20543       /* "View.MemoryView":1168
20544  *                                      ndim - 1, itemsize)
20545  *             src_data += src_stride
20546  *             dst_data += dst_stride             # <<<<<<<<<<<<<<
20547  *
20548  * cdef void copy_strided_to_strided(__Pyx_memviewslice *src,
20549  */
20550       __pyx_v_dst_data = (__pyx_v_dst_data + __pyx_v_dst_stride);
20551     }
20552   }
20553   __pyx_L3:;
20554 
20555   /* "View.MemoryView":1140
20556  *
20557  * @cython.cdivision(True)
20558  * cdef void _copy_strided_to_strided(char *src_data, Py_ssize_t *src_strides,             # <<<<<<<<<<<<<<
20559  *                                    char *dst_data, Py_ssize_t *dst_strides,
20560  *                                    Py_ssize_t *src_shape, Py_ssize_t *dst_shape,
20561  */
20562 
20563   /* function exit code */
20564 }
20565 
20566 /* "View.MemoryView":1170
20567  *             dst_data += dst_stride
20568  *
20569  * cdef void copy_strided_to_strided(__Pyx_memviewslice *src,             # <<<<<<<<<<<<<<
20570  *                                   __Pyx_memviewslice *dst,
20571  *                                   int ndim, size_t itemsize) nogil:
20572  */
20573 
copy_strided_to_strided(__Pyx_memviewslice * __pyx_v_src,__Pyx_memviewslice * __pyx_v_dst,int __pyx_v_ndim,size_t __pyx_v_itemsize)20574 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) {
20575 
20576   /* "View.MemoryView":1173
20577  *                                   __Pyx_memviewslice *dst,
20578  *                                   int ndim, size_t itemsize) nogil:
20579  *     _copy_strided_to_strided(src.data, src.strides, dst.data, dst.strides,             # <<<<<<<<<<<<<<
20580  *                              src.shape, dst.shape, ndim, itemsize)
20581  *
20582  */
20583   _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);
20584 
20585   /* "View.MemoryView":1170
20586  *             dst_data += dst_stride
20587  *
20588  * cdef void copy_strided_to_strided(__Pyx_memviewslice *src,             # <<<<<<<<<<<<<<
20589  *                                   __Pyx_memviewslice *dst,
20590  *                                   int ndim, size_t itemsize) nogil:
20591  */
20592 
20593   /* function exit code */
20594 }
20595 
20596 /* "View.MemoryView":1177
20597  *
20598  * @cname('__pyx_memoryview_slice_get_size')
20599  * cdef Py_ssize_t slice_get_size(__Pyx_memviewslice *src, int ndim) nogil:             # <<<<<<<<<<<<<<
20600  *     "Return the size of the memory occupied by the slice in number of bytes"
20601  *     cdef Py_ssize_t shape, size = src.memview.view.itemsize
20602  */
20603 
__pyx_memoryview_slice_get_size(__Pyx_memviewslice * __pyx_v_src,int __pyx_v_ndim)20604 static Py_ssize_t __pyx_memoryview_slice_get_size(__Pyx_memviewslice *__pyx_v_src, int __pyx_v_ndim) {
20605   Py_ssize_t __pyx_v_shape;
20606   Py_ssize_t __pyx_v_size;
20607   Py_ssize_t __pyx_r;
20608   Py_ssize_t __pyx_t_1;
20609   Py_ssize_t *__pyx_t_2;
20610   Py_ssize_t *__pyx_t_3;
20611   Py_ssize_t *__pyx_t_4;
20612 
20613   /* "View.MemoryView":1179
20614  * cdef Py_ssize_t slice_get_size(__Pyx_memviewslice *src, int ndim) nogil:
20615  *     "Return the size of the memory occupied by the slice in number of bytes"
20616  *     cdef Py_ssize_t shape, size = src.memview.view.itemsize             # <<<<<<<<<<<<<<
20617  *
20618  *     for shape in src.shape[:ndim]:
20619  */
20620   __pyx_t_1 = __pyx_v_src->memview->view.itemsize;
20621   __pyx_v_size = __pyx_t_1;
20622 
20623   /* "View.MemoryView":1181
20624  *     cdef Py_ssize_t shape, size = src.memview.view.itemsize
20625  *
20626  *     for shape in src.shape[:ndim]:             # <<<<<<<<<<<<<<
20627  *         size *= shape
20628  *
20629  */
20630   __pyx_t_3 = (__pyx_v_src->shape + __pyx_v_ndim);
20631   for (__pyx_t_4 = __pyx_v_src->shape; __pyx_t_4 < __pyx_t_3; __pyx_t_4++) {
20632     __pyx_t_2 = __pyx_t_4;
20633     __pyx_v_shape = (__pyx_t_2[0]);
20634 
20635     /* "View.MemoryView":1182
20636  *
20637  *     for shape in src.shape[:ndim]:
20638  *         size *= shape             # <<<<<<<<<<<<<<
20639  *
20640  *     return size
20641  */
20642     __pyx_v_size = (__pyx_v_size * __pyx_v_shape);
20643   }
20644 
20645   /* "View.MemoryView":1184
20646  *         size *= shape
20647  *
20648  *     return size             # <<<<<<<<<<<<<<
20649  *
20650  * @cname('__pyx_fill_contig_strides_array')
20651  */
20652   __pyx_r = __pyx_v_size;
20653   goto __pyx_L0;
20654 
20655   /* "View.MemoryView":1177
20656  *
20657  * @cname('__pyx_memoryview_slice_get_size')
20658  * cdef Py_ssize_t slice_get_size(__Pyx_memviewslice *src, int ndim) nogil:             # <<<<<<<<<<<<<<
20659  *     "Return the size of the memory occupied by the slice in number of bytes"
20660  *     cdef Py_ssize_t shape, size = src.memview.view.itemsize
20661  */
20662 
20663   /* function exit code */
20664   __pyx_L0:;
20665   return __pyx_r;
20666 }
20667 
20668 /* "View.MemoryView":1187
20669  *
20670  * @cname('__pyx_fill_contig_strides_array')
20671  * cdef Py_ssize_t fill_contig_strides_array(             # <<<<<<<<<<<<<<
20672  *                 Py_ssize_t *shape, Py_ssize_t *strides, Py_ssize_t stride,
20673  *                 int ndim, char order) nogil:
20674  */
20675 
__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)20676 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) {
20677   int __pyx_v_idx;
20678   Py_ssize_t __pyx_r;
20679   int __pyx_t_1;
20680   int __pyx_t_2;
20681   int __pyx_t_3;
20682   int __pyx_t_4;
20683 
20684   /* "View.MemoryView":1196
20685  *     cdef int idx
20686  *
20687  *     if order == 'F':             # <<<<<<<<<<<<<<
20688  *         for idx in range(ndim):
20689  *             strides[idx] = stride
20690  */
20691   __pyx_t_1 = ((__pyx_v_order == 'F') != 0);
20692   if (__pyx_t_1) {
20693 
20694     /* "View.MemoryView":1197
20695  *
20696  *     if order == 'F':
20697  *         for idx in range(ndim):             # <<<<<<<<<<<<<<
20698  *             strides[idx] = stride
20699  *             stride *= shape[idx]
20700  */
20701     __pyx_t_2 = __pyx_v_ndim;
20702     __pyx_t_3 = __pyx_t_2;
20703     for (__pyx_t_4 = 0; __pyx_t_4 < __pyx_t_3; __pyx_t_4+=1) {
20704       __pyx_v_idx = __pyx_t_4;
20705 
20706       /* "View.MemoryView":1198
20707  *     if order == 'F':
20708  *         for idx in range(ndim):
20709  *             strides[idx] = stride             # <<<<<<<<<<<<<<
20710  *             stride *= shape[idx]
20711  *     else:
20712  */
20713       (__pyx_v_strides[__pyx_v_idx]) = __pyx_v_stride;
20714 
20715       /* "View.MemoryView":1199
20716  *         for idx in range(ndim):
20717  *             strides[idx] = stride
20718  *             stride *= shape[idx]             # <<<<<<<<<<<<<<
20719  *     else:
20720  *         for idx in range(ndim - 1, -1, -1):
20721  */
20722       __pyx_v_stride = (__pyx_v_stride * (__pyx_v_shape[__pyx_v_idx]));
20723     }
20724 
20725     /* "View.MemoryView":1196
20726  *     cdef int idx
20727  *
20728  *     if order == 'F':             # <<<<<<<<<<<<<<
20729  *         for idx in range(ndim):
20730  *             strides[idx] = stride
20731  */
20732     goto __pyx_L3;
20733   }
20734 
20735   /* "View.MemoryView":1201
20736  *             stride *= shape[idx]
20737  *     else:
20738  *         for idx in range(ndim - 1, -1, -1):             # <<<<<<<<<<<<<<
20739  *             strides[idx] = stride
20740  *             stride *= shape[idx]
20741  */
20742   /*else*/ {
20743     for (__pyx_t_2 = (__pyx_v_ndim - 1); __pyx_t_2 > -1; __pyx_t_2-=1) {
20744       __pyx_v_idx = __pyx_t_2;
20745 
20746       /* "View.MemoryView":1202
20747  *     else:
20748  *         for idx in range(ndim - 1, -1, -1):
20749  *             strides[idx] = stride             # <<<<<<<<<<<<<<
20750  *             stride *= shape[idx]
20751  *
20752  */
20753       (__pyx_v_strides[__pyx_v_idx]) = __pyx_v_stride;
20754 
20755       /* "View.MemoryView":1203
20756  *         for idx in range(ndim - 1, -1, -1):
20757  *             strides[idx] = stride
20758  *             stride *= shape[idx]             # <<<<<<<<<<<<<<
20759  *
20760  *     return stride
20761  */
20762       __pyx_v_stride = (__pyx_v_stride * (__pyx_v_shape[__pyx_v_idx]));
20763     }
20764   }
20765   __pyx_L3:;
20766 
20767   /* "View.MemoryView":1205
20768  *             stride *= shape[idx]
20769  *
20770  *     return stride             # <<<<<<<<<<<<<<
20771  *
20772  * @cname('__pyx_memoryview_copy_data_to_temp')
20773  */
20774   __pyx_r = __pyx_v_stride;
20775   goto __pyx_L0;
20776 
20777   /* "View.MemoryView":1187
20778  *
20779  * @cname('__pyx_fill_contig_strides_array')
20780  * cdef Py_ssize_t fill_contig_strides_array(             # <<<<<<<<<<<<<<
20781  *                 Py_ssize_t *shape, Py_ssize_t *strides, Py_ssize_t stride,
20782  *                 int ndim, char order) nogil:
20783  */
20784 
20785   /* function exit code */
20786   __pyx_L0:;
20787   return __pyx_r;
20788 }
20789 
20790 /* "View.MemoryView":1208
20791  *
20792  * @cname('__pyx_memoryview_copy_data_to_temp')
20793  * cdef void *copy_data_to_temp(__Pyx_memviewslice *src,             # <<<<<<<<<<<<<<
20794  *                              __Pyx_memviewslice *tmpslice,
20795  *                              char order,
20796  */
20797 
__pyx_memoryview_copy_data_to_temp(__Pyx_memviewslice * __pyx_v_src,__Pyx_memviewslice * __pyx_v_tmpslice,char __pyx_v_order,int __pyx_v_ndim)20798 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) {
20799   int __pyx_v_i;
20800   void *__pyx_v_result;
20801   size_t __pyx_v_itemsize;
20802   size_t __pyx_v_size;
20803   void *__pyx_r;
20804   Py_ssize_t __pyx_t_1;
20805   int __pyx_t_2;
20806   int __pyx_t_3;
20807   struct __pyx_memoryview_obj *__pyx_t_4;
20808   int __pyx_t_5;
20809   int __pyx_t_6;
20810   int __pyx_lineno = 0;
20811   const char *__pyx_filename = NULL;
20812   int __pyx_clineno = 0;
20813 
20814   /* "View.MemoryView":1219
20815  *     cdef void *result
20816  *
20817  *     cdef size_t itemsize = src.memview.view.itemsize             # <<<<<<<<<<<<<<
20818  *     cdef size_t size = slice_get_size(src, ndim)
20819  *
20820  */
20821   __pyx_t_1 = __pyx_v_src->memview->view.itemsize;
20822   __pyx_v_itemsize = __pyx_t_1;
20823 
20824   /* "View.MemoryView":1220
20825  *
20826  *     cdef size_t itemsize = src.memview.view.itemsize
20827  *     cdef size_t size = slice_get_size(src, ndim)             # <<<<<<<<<<<<<<
20828  *
20829  *     result = malloc(size)
20830  */
20831   __pyx_v_size = __pyx_memoryview_slice_get_size(__pyx_v_src, __pyx_v_ndim);
20832 
20833   /* "View.MemoryView":1222
20834  *     cdef size_t size = slice_get_size(src, ndim)
20835  *
20836  *     result = malloc(size)             # <<<<<<<<<<<<<<
20837  *     if not result:
20838  *         _err(MemoryError, NULL)
20839  */
20840   __pyx_v_result = malloc(__pyx_v_size);
20841 
20842   /* "View.MemoryView":1223
20843  *
20844  *     result = malloc(size)
20845  *     if not result:             # <<<<<<<<<<<<<<
20846  *         _err(MemoryError, NULL)
20847  *
20848  */
20849   __pyx_t_2 = ((!(__pyx_v_result != 0)) != 0);
20850   if (__pyx_t_2) {
20851 
20852     /* "View.MemoryView":1224
20853  *     result = malloc(size)
20854  *     if not result:
20855  *         _err(MemoryError, NULL)             # <<<<<<<<<<<<<<
20856  *
20857  *
20858  */
20859     __pyx_t_3 = __pyx_memoryview_err(__pyx_builtin_MemoryError, NULL); if (unlikely(__pyx_t_3 == ((int)-1))) __PYX_ERR(2, 1224, __pyx_L1_error)
20860 
20861     /* "View.MemoryView":1223
20862  *
20863  *     result = malloc(size)
20864  *     if not result:             # <<<<<<<<<<<<<<
20865  *         _err(MemoryError, NULL)
20866  *
20867  */
20868   }
20869 
20870   /* "View.MemoryView":1227
20871  *
20872  *
20873  *     tmpslice.data = <char *> result             # <<<<<<<<<<<<<<
20874  *     tmpslice.memview = src.memview
20875  *     for i in range(ndim):
20876  */
20877   __pyx_v_tmpslice->data = ((char *)__pyx_v_result);
20878 
20879   /* "View.MemoryView":1228
20880  *
20881  *     tmpslice.data = <char *> result
20882  *     tmpslice.memview = src.memview             # <<<<<<<<<<<<<<
20883  *     for i in range(ndim):
20884  *         tmpslice.shape[i] = src.shape[i]
20885  */
20886   __pyx_t_4 = __pyx_v_src->memview;
20887   __pyx_v_tmpslice->memview = __pyx_t_4;
20888 
20889   /* "View.MemoryView":1229
20890  *     tmpslice.data = <char *> result
20891  *     tmpslice.memview = src.memview
20892  *     for i in range(ndim):             # <<<<<<<<<<<<<<
20893  *         tmpslice.shape[i] = src.shape[i]
20894  *         tmpslice.suboffsets[i] = -1
20895  */
20896   __pyx_t_3 = __pyx_v_ndim;
20897   __pyx_t_5 = __pyx_t_3;
20898   for (__pyx_t_6 = 0; __pyx_t_6 < __pyx_t_5; __pyx_t_6+=1) {
20899     __pyx_v_i = __pyx_t_6;
20900 
20901     /* "View.MemoryView":1230
20902  *     tmpslice.memview = src.memview
20903  *     for i in range(ndim):
20904  *         tmpslice.shape[i] = src.shape[i]             # <<<<<<<<<<<<<<
20905  *         tmpslice.suboffsets[i] = -1
20906  *
20907  */
20908     (__pyx_v_tmpslice->shape[__pyx_v_i]) = (__pyx_v_src->shape[__pyx_v_i]);
20909 
20910     /* "View.MemoryView":1231
20911  *     for i in range(ndim):
20912  *         tmpslice.shape[i] = src.shape[i]
20913  *         tmpslice.suboffsets[i] = -1             # <<<<<<<<<<<<<<
20914  *
20915  *     fill_contig_strides_array(&tmpslice.shape[0], &tmpslice.strides[0], itemsize,
20916  */
20917     (__pyx_v_tmpslice->suboffsets[__pyx_v_i]) = -1L;
20918   }
20919 
20920   /* "View.MemoryView":1233
20921  *         tmpslice.suboffsets[i] = -1
20922  *
20923  *     fill_contig_strides_array(&tmpslice.shape[0], &tmpslice.strides[0], itemsize,             # <<<<<<<<<<<<<<
20924  *                               ndim, order)
20925  *
20926  */
20927   (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));
20928 
20929   /* "View.MemoryView":1237
20930  *
20931  *
20932  *     for i in range(ndim):             # <<<<<<<<<<<<<<
20933  *         if tmpslice.shape[i] == 1:
20934  *             tmpslice.strides[i] = 0
20935  */
20936   __pyx_t_3 = __pyx_v_ndim;
20937   __pyx_t_5 = __pyx_t_3;
20938   for (__pyx_t_6 = 0; __pyx_t_6 < __pyx_t_5; __pyx_t_6+=1) {
20939     __pyx_v_i = __pyx_t_6;
20940 
20941     /* "View.MemoryView":1238
20942  *
20943  *     for i in range(ndim):
20944  *         if tmpslice.shape[i] == 1:             # <<<<<<<<<<<<<<
20945  *             tmpslice.strides[i] = 0
20946  *
20947  */
20948     __pyx_t_2 = (((__pyx_v_tmpslice->shape[__pyx_v_i]) == 1) != 0);
20949     if (__pyx_t_2) {
20950 
20951       /* "View.MemoryView":1239
20952  *     for i in range(ndim):
20953  *         if tmpslice.shape[i] == 1:
20954  *             tmpslice.strides[i] = 0             # <<<<<<<<<<<<<<
20955  *
20956  *     if slice_is_contig(src[0], order, ndim):
20957  */
20958       (__pyx_v_tmpslice->strides[__pyx_v_i]) = 0;
20959 
20960       /* "View.MemoryView":1238
20961  *
20962  *     for i in range(ndim):
20963  *         if tmpslice.shape[i] == 1:             # <<<<<<<<<<<<<<
20964  *             tmpslice.strides[i] = 0
20965  *
20966  */
20967     }
20968   }
20969 
20970   /* "View.MemoryView":1241
20971  *             tmpslice.strides[i] = 0
20972  *
20973  *     if slice_is_contig(src[0], order, ndim):             # <<<<<<<<<<<<<<
20974  *         memcpy(result, src.data, size)
20975  *     else:
20976  */
20977   __pyx_t_2 = (__pyx_memviewslice_is_contig((__pyx_v_src[0]), __pyx_v_order, __pyx_v_ndim) != 0);
20978   if (__pyx_t_2) {
20979 
20980     /* "View.MemoryView":1242
20981  *
20982  *     if slice_is_contig(src[0], order, ndim):
20983  *         memcpy(result, src.data, size)             # <<<<<<<<<<<<<<
20984  *     else:
20985  *         copy_strided_to_strided(src, tmpslice, ndim, itemsize)
20986  */
20987     (void)(memcpy(__pyx_v_result, __pyx_v_src->data, __pyx_v_size));
20988 
20989     /* "View.MemoryView":1241
20990  *             tmpslice.strides[i] = 0
20991  *
20992  *     if slice_is_contig(src[0], order, ndim):             # <<<<<<<<<<<<<<
20993  *         memcpy(result, src.data, size)
20994  *     else:
20995  */
20996     goto __pyx_L9;
20997   }
20998 
20999   /* "View.MemoryView":1244
21000  *         memcpy(result, src.data, size)
21001  *     else:
21002  *         copy_strided_to_strided(src, tmpslice, ndim, itemsize)             # <<<<<<<<<<<<<<
21003  *
21004  *     return result
21005  */
21006   /*else*/ {
21007     copy_strided_to_strided(__pyx_v_src, __pyx_v_tmpslice, __pyx_v_ndim, __pyx_v_itemsize);
21008   }
21009   __pyx_L9:;
21010 
21011   /* "View.MemoryView":1246
21012  *         copy_strided_to_strided(src, tmpslice, ndim, itemsize)
21013  *
21014  *     return result             # <<<<<<<<<<<<<<
21015  *
21016  *
21017  */
21018   __pyx_r = __pyx_v_result;
21019   goto __pyx_L0;
21020 
21021   /* "View.MemoryView":1208
21022  *
21023  * @cname('__pyx_memoryview_copy_data_to_temp')
21024  * cdef void *copy_data_to_temp(__Pyx_memviewslice *src,             # <<<<<<<<<<<<<<
21025  *                              __Pyx_memviewslice *tmpslice,
21026  *                              char order,
21027  */
21028 
21029   /* function exit code */
21030   __pyx_L1_error:;
21031   {
21032     #ifdef WITH_THREAD
21033     PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure();
21034     #endif
21035     __Pyx_AddTraceback("View.MemoryView.copy_data_to_temp", __pyx_clineno, __pyx_lineno, __pyx_filename);
21036     #ifdef WITH_THREAD
21037     __Pyx_PyGILState_Release(__pyx_gilstate_save);
21038     #endif
21039   }
21040   __pyx_r = NULL;
21041   __pyx_L0:;
21042   return __pyx_r;
21043 }
21044 
21045 /* "View.MemoryView":1251
21046  *
21047  * @cname('__pyx_memoryview_err_extents')
21048  * cdef int _err_extents(int i, Py_ssize_t extent1,             # <<<<<<<<<<<<<<
21049  *                              Py_ssize_t extent2) except -1 with gil:
21050  *     raise ValueError("got differing extents in dimension %d (got %d and %d)" %
21051  */
21052 
__pyx_memoryview_err_extents(int __pyx_v_i,Py_ssize_t __pyx_v_extent1,Py_ssize_t __pyx_v_extent2)21053 static int __pyx_memoryview_err_extents(int __pyx_v_i, Py_ssize_t __pyx_v_extent1, Py_ssize_t __pyx_v_extent2) {
21054   int __pyx_r;
21055   __Pyx_RefNannyDeclarations
21056   PyObject *__pyx_t_1 = NULL;
21057   PyObject *__pyx_t_2 = NULL;
21058   PyObject *__pyx_t_3 = NULL;
21059   PyObject *__pyx_t_4 = NULL;
21060   int __pyx_lineno = 0;
21061   const char *__pyx_filename = NULL;
21062   int __pyx_clineno = 0;
21063   #ifdef WITH_THREAD
21064   PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure();
21065   #endif
21066   __Pyx_RefNannySetupContext("_err_extents", 0);
21067 
21068   /* "View.MemoryView":1254
21069  *                              Py_ssize_t extent2) except -1 with gil:
21070  *     raise ValueError("got differing extents in dimension %d (got %d and %d)" %
21071  *                                                         (i, extent1, extent2))             # <<<<<<<<<<<<<<
21072  *
21073  * @cname('__pyx_memoryview_err_dim')
21074  */
21075   __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_i); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 1254, __pyx_L1_error)
21076   __Pyx_GOTREF(__pyx_t_1);
21077   __pyx_t_2 = PyInt_FromSsize_t(__pyx_v_extent1); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 1254, __pyx_L1_error)
21078   __Pyx_GOTREF(__pyx_t_2);
21079   __pyx_t_3 = PyInt_FromSsize_t(__pyx_v_extent2); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 1254, __pyx_L1_error)
21080   __Pyx_GOTREF(__pyx_t_3);
21081   __pyx_t_4 = PyTuple_New(3); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 1254, __pyx_L1_error)
21082   __Pyx_GOTREF(__pyx_t_4);
21083   __Pyx_GIVEREF(__pyx_t_1);
21084   PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_1);
21085   __Pyx_GIVEREF(__pyx_t_2);
21086   PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_2);
21087   __Pyx_GIVEREF(__pyx_t_3);
21088   PyTuple_SET_ITEM(__pyx_t_4, 2, __pyx_t_3);
21089   __pyx_t_1 = 0;
21090   __pyx_t_2 = 0;
21091   __pyx_t_3 = 0;
21092 
21093   /* "View.MemoryView":1253
21094  * cdef int _err_extents(int i, Py_ssize_t extent1,
21095  *                              Py_ssize_t extent2) except -1 with gil:
21096  *     raise ValueError("got differing extents in dimension %d (got %d and %d)" %             # <<<<<<<<<<<<<<
21097  *                                                         (i, extent1, extent2))
21098  *
21099  */
21100   __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)
21101   __Pyx_GOTREF(__pyx_t_3);
21102   __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
21103   __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_builtin_ValueError, __pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 1253, __pyx_L1_error)
21104   __Pyx_GOTREF(__pyx_t_4);
21105   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
21106   __Pyx_Raise(__pyx_t_4, 0, 0, 0);
21107   __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
21108   __PYX_ERR(2, 1253, __pyx_L1_error)
21109 
21110   /* "View.MemoryView":1251
21111  *
21112  * @cname('__pyx_memoryview_err_extents')
21113  * cdef int _err_extents(int i, Py_ssize_t extent1,             # <<<<<<<<<<<<<<
21114  *                              Py_ssize_t extent2) except -1 with gil:
21115  *     raise ValueError("got differing extents in dimension %d (got %d and %d)" %
21116  */
21117 
21118   /* function exit code */
21119   __pyx_L1_error:;
21120   __Pyx_XDECREF(__pyx_t_1);
21121   __Pyx_XDECREF(__pyx_t_2);
21122   __Pyx_XDECREF(__pyx_t_3);
21123   __Pyx_XDECREF(__pyx_t_4);
21124   __Pyx_AddTraceback("View.MemoryView._err_extents", __pyx_clineno, __pyx_lineno, __pyx_filename);
21125   __pyx_r = -1;
21126   __Pyx_RefNannyFinishContext();
21127   #ifdef WITH_THREAD
21128   __Pyx_PyGILState_Release(__pyx_gilstate_save);
21129   #endif
21130   return __pyx_r;
21131 }
21132 
21133 /* "View.MemoryView":1257
21134  *
21135  * @cname('__pyx_memoryview_err_dim')
21136  * cdef int _err_dim(object error, char *msg, int dim) except -1 with gil:             # <<<<<<<<<<<<<<
21137  *     raise error(msg.decode('ascii') % dim)
21138  *
21139  */
21140 
__pyx_memoryview_err_dim(PyObject * __pyx_v_error,char * __pyx_v_msg,int __pyx_v_dim)21141 static int __pyx_memoryview_err_dim(PyObject *__pyx_v_error, char *__pyx_v_msg, int __pyx_v_dim) {
21142   int __pyx_r;
21143   __Pyx_RefNannyDeclarations
21144   PyObject *__pyx_t_1 = NULL;
21145   PyObject *__pyx_t_2 = NULL;
21146   PyObject *__pyx_t_3 = NULL;
21147   PyObject *__pyx_t_4 = NULL;
21148   int __pyx_lineno = 0;
21149   const char *__pyx_filename = NULL;
21150   int __pyx_clineno = 0;
21151   #ifdef WITH_THREAD
21152   PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure();
21153   #endif
21154   __Pyx_RefNannySetupContext("_err_dim", 0);
21155   __Pyx_INCREF(__pyx_v_error);
21156 
21157   /* "View.MemoryView":1258
21158  * @cname('__pyx_memoryview_err_dim')
21159  * cdef int _err_dim(object error, char *msg, int dim) except -1 with gil:
21160  *     raise error(msg.decode('ascii') % dim)             # <<<<<<<<<<<<<<
21161  *
21162  * @cname('__pyx_memoryview_err')
21163  */
21164   __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)
21165   __Pyx_GOTREF(__pyx_t_2);
21166   __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_dim); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 1258, __pyx_L1_error)
21167   __Pyx_GOTREF(__pyx_t_3);
21168   __pyx_t_4 = PyUnicode_Format(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 1258, __pyx_L1_error)
21169   __Pyx_GOTREF(__pyx_t_4);
21170   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
21171   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
21172   __Pyx_INCREF(__pyx_v_error);
21173   __pyx_t_3 = __pyx_v_error; __pyx_t_2 = NULL;
21174   if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
21175     __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3);
21176     if (likely(__pyx_t_2)) {
21177       PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
21178       __Pyx_INCREF(__pyx_t_2);
21179       __Pyx_INCREF(function);
21180       __Pyx_DECREF_SET(__pyx_t_3, function);
21181     }
21182   }
21183   __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);
21184   __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
21185   __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
21186   if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 1258, __pyx_L1_error)
21187   __Pyx_GOTREF(__pyx_t_1);
21188   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
21189   __Pyx_Raise(__pyx_t_1, 0, 0, 0);
21190   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
21191   __PYX_ERR(2, 1258, __pyx_L1_error)
21192 
21193   /* "View.MemoryView":1257
21194  *
21195  * @cname('__pyx_memoryview_err_dim')
21196  * cdef int _err_dim(object error, char *msg, int dim) except -1 with gil:             # <<<<<<<<<<<<<<
21197  *     raise error(msg.decode('ascii') % dim)
21198  *
21199  */
21200 
21201   /* function exit code */
21202   __pyx_L1_error:;
21203   __Pyx_XDECREF(__pyx_t_1);
21204   __Pyx_XDECREF(__pyx_t_2);
21205   __Pyx_XDECREF(__pyx_t_3);
21206   __Pyx_XDECREF(__pyx_t_4);
21207   __Pyx_AddTraceback("View.MemoryView._err_dim", __pyx_clineno, __pyx_lineno, __pyx_filename);
21208   __pyx_r = -1;
21209   __Pyx_XDECREF(__pyx_v_error);
21210   __Pyx_RefNannyFinishContext();
21211   #ifdef WITH_THREAD
21212   __Pyx_PyGILState_Release(__pyx_gilstate_save);
21213   #endif
21214   return __pyx_r;
21215 }
21216 
21217 /* "View.MemoryView":1261
21218  *
21219  * @cname('__pyx_memoryview_err')
21220  * cdef int _err(object error, char *msg) except -1 with gil:             # <<<<<<<<<<<<<<
21221  *     if msg != NULL:
21222  *         raise error(msg.decode('ascii'))
21223  */
21224 
__pyx_memoryview_err(PyObject * __pyx_v_error,char * __pyx_v_msg)21225 static int __pyx_memoryview_err(PyObject *__pyx_v_error, char *__pyx_v_msg) {
21226   int __pyx_r;
21227   __Pyx_RefNannyDeclarations
21228   int __pyx_t_1;
21229   PyObject *__pyx_t_2 = NULL;
21230   PyObject *__pyx_t_3 = NULL;
21231   PyObject *__pyx_t_4 = NULL;
21232   PyObject *__pyx_t_5 = NULL;
21233   int __pyx_lineno = 0;
21234   const char *__pyx_filename = NULL;
21235   int __pyx_clineno = 0;
21236   #ifdef WITH_THREAD
21237   PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure();
21238   #endif
21239   __Pyx_RefNannySetupContext("_err", 0);
21240   __Pyx_INCREF(__pyx_v_error);
21241 
21242   /* "View.MemoryView":1262
21243  * @cname('__pyx_memoryview_err')
21244  * cdef int _err(object error, char *msg) except -1 with gil:
21245  *     if msg != NULL:             # <<<<<<<<<<<<<<
21246  *         raise error(msg.decode('ascii'))
21247  *     else:
21248  */
21249   __pyx_t_1 = ((__pyx_v_msg != NULL) != 0);
21250   if (unlikely(__pyx_t_1)) {
21251 
21252     /* "View.MemoryView":1263
21253  * cdef int _err(object error, char *msg) except -1 with gil:
21254  *     if msg != NULL:
21255  *         raise error(msg.decode('ascii'))             # <<<<<<<<<<<<<<
21256  *     else:
21257  *         raise error
21258  */
21259     __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)
21260     __Pyx_GOTREF(__pyx_t_3);
21261     __Pyx_INCREF(__pyx_v_error);
21262     __pyx_t_4 = __pyx_v_error; __pyx_t_5 = NULL;
21263     if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_4))) {
21264       __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4);
21265       if (likely(__pyx_t_5)) {
21266         PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
21267         __Pyx_INCREF(__pyx_t_5);
21268         __Pyx_INCREF(function);
21269         __Pyx_DECREF_SET(__pyx_t_4, function);
21270       }
21271     }
21272     __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);
21273     __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
21274     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
21275     if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 1263, __pyx_L1_error)
21276     __Pyx_GOTREF(__pyx_t_2);
21277     __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
21278     __Pyx_Raise(__pyx_t_2, 0, 0, 0);
21279     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
21280     __PYX_ERR(2, 1263, __pyx_L1_error)
21281 
21282     /* "View.MemoryView":1262
21283  * @cname('__pyx_memoryview_err')
21284  * cdef int _err(object error, char *msg) except -1 with gil:
21285  *     if msg != NULL:             # <<<<<<<<<<<<<<
21286  *         raise error(msg.decode('ascii'))
21287  *     else:
21288  */
21289   }
21290 
21291   /* "View.MemoryView":1265
21292  *         raise error(msg.decode('ascii'))
21293  *     else:
21294  *         raise error             # <<<<<<<<<<<<<<
21295  *
21296  * @cname('__pyx_memoryview_copy_contents')
21297  */
21298   /*else*/ {
21299     __Pyx_Raise(__pyx_v_error, 0, 0, 0);
21300     __PYX_ERR(2, 1265, __pyx_L1_error)
21301   }
21302 
21303   /* "View.MemoryView":1261
21304  *
21305  * @cname('__pyx_memoryview_err')
21306  * cdef int _err(object error, char *msg) except -1 with gil:             # <<<<<<<<<<<<<<
21307  *     if msg != NULL:
21308  *         raise error(msg.decode('ascii'))
21309  */
21310 
21311   /* function exit code */
21312   __pyx_L1_error:;
21313   __Pyx_XDECREF(__pyx_t_2);
21314   __Pyx_XDECREF(__pyx_t_3);
21315   __Pyx_XDECREF(__pyx_t_4);
21316   __Pyx_XDECREF(__pyx_t_5);
21317   __Pyx_AddTraceback("View.MemoryView._err", __pyx_clineno, __pyx_lineno, __pyx_filename);
21318   __pyx_r = -1;
21319   __Pyx_XDECREF(__pyx_v_error);
21320   __Pyx_RefNannyFinishContext();
21321   #ifdef WITH_THREAD
21322   __Pyx_PyGILState_Release(__pyx_gilstate_save);
21323   #endif
21324   return __pyx_r;
21325 }
21326 
21327 /* "View.MemoryView":1268
21328  *
21329  * @cname('__pyx_memoryview_copy_contents')
21330  * cdef int memoryview_copy_contents(__Pyx_memviewslice src,             # <<<<<<<<<<<<<<
21331  *                                   __Pyx_memviewslice dst,
21332  *                                   int src_ndim, int dst_ndim,
21333  */
21334 
__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)21335 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) {
21336   void *__pyx_v_tmpdata;
21337   size_t __pyx_v_itemsize;
21338   int __pyx_v_i;
21339   char __pyx_v_order;
21340   int __pyx_v_broadcasting;
21341   int __pyx_v_direct_copy;
21342   __Pyx_memviewslice __pyx_v_tmp;
21343   int __pyx_v_ndim;
21344   int __pyx_r;
21345   Py_ssize_t __pyx_t_1;
21346   int __pyx_t_2;
21347   int __pyx_t_3;
21348   int __pyx_t_4;
21349   int __pyx_t_5;
21350   int __pyx_t_6;
21351   void *__pyx_t_7;
21352   int __pyx_t_8;
21353   int __pyx_lineno = 0;
21354   const char *__pyx_filename = NULL;
21355   int __pyx_clineno = 0;
21356 
21357   /* "View.MemoryView":1276
21358  *     Check for overlapping memory and verify the shapes.
21359  *     """
21360  *     cdef void *tmpdata = NULL             # <<<<<<<<<<<<<<
21361  *     cdef size_t itemsize = src.memview.view.itemsize
21362  *     cdef int i
21363  */
21364   __pyx_v_tmpdata = NULL;
21365 
21366   /* "View.MemoryView":1277
21367  *     """
21368  *     cdef void *tmpdata = NULL
21369  *     cdef size_t itemsize = src.memview.view.itemsize             # <<<<<<<<<<<<<<
21370  *     cdef int i
21371  *     cdef char order = get_best_order(&src, src_ndim)
21372  */
21373   __pyx_t_1 = __pyx_v_src.memview->view.itemsize;
21374   __pyx_v_itemsize = __pyx_t_1;
21375 
21376   /* "View.MemoryView":1279
21377  *     cdef size_t itemsize = src.memview.view.itemsize
21378  *     cdef int i
21379  *     cdef char order = get_best_order(&src, src_ndim)             # <<<<<<<<<<<<<<
21380  *     cdef bint broadcasting = False
21381  *     cdef bint direct_copy = False
21382  */
21383   __pyx_v_order = __pyx_get_best_slice_order((&__pyx_v_src), __pyx_v_src_ndim);
21384 
21385   /* "View.MemoryView":1280
21386  *     cdef int i
21387  *     cdef char order = get_best_order(&src, src_ndim)
21388  *     cdef bint broadcasting = False             # <<<<<<<<<<<<<<
21389  *     cdef bint direct_copy = False
21390  *     cdef __Pyx_memviewslice tmp
21391  */
21392   __pyx_v_broadcasting = 0;
21393 
21394   /* "View.MemoryView":1281
21395  *     cdef char order = get_best_order(&src, src_ndim)
21396  *     cdef bint broadcasting = False
21397  *     cdef bint direct_copy = False             # <<<<<<<<<<<<<<
21398  *     cdef __Pyx_memviewslice tmp
21399  *
21400  */
21401   __pyx_v_direct_copy = 0;
21402 
21403   /* "View.MemoryView":1284
21404  *     cdef __Pyx_memviewslice tmp
21405  *
21406  *     if src_ndim < dst_ndim:             # <<<<<<<<<<<<<<
21407  *         broadcast_leading(&src, src_ndim, dst_ndim)
21408  *     elif dst_ndim < src_ndim:
21409  */
21410   __pyx_t_2 = ((__pyx_v_src_ndim < __pyx_v_dst_ndim) != 0);
21411   if (__pyx_t_2) {
21412 
21413     /* "View.MemoryView":1285
21414  *
21415  *     if src_ndim < dst_ndim:
21416  *         broadcast_leading(&src, src_ndim, dst_ndim)             # <<<<<<<<<<<<<<
21417  *     elif dst_ndim < src_ndim:
21418  *         broadcast_leading(&dst, dst_ndim, src_ndim)
21419  */
21420     __pyx_memoryview_broadcast_leading((&__pyx_v_src), __pyx_v_src_ndim, __pyx_v_dst_ndim);
21421 
21422     /* "View.MemoryView":1284
21423  *     cdef __Pyx_memviewslice tmp
21424  *
21425  *     if src_ndim < dst_ndim:             # <<<<<<<<<<<<<<
21426  *         broadcast_leading(&src, src_ndim, dst_ndim)
21427  *     elif dst_ndim < src_ndim:
21428  */
21429     goto __pyx_L3;
21430   }
21431 
21432   /* "View.MemoryView":1286
21433  *     if src_ndim < dst_ndim:
21434  *         broadcast_leading(&src, src_ndim, dst_ndim)
21435  *     elif dst_ndim < src_ndim:             # <<<<<<<<<<<<<<
21436  *         broadcast_leading(&dst, dst_ndim, src_ndim)
21437  *
21438  */
21439   __pyx_t_2 = ((__pyx_v_dst_ndim < __pyx_v_src_ndim) != 0);
21440   if (__pyx_t_2) {
21441 
21442     /* "View.MemoryView":1287
21443  *         broadcast_leading(&src, src_ndim, dst_ndim)
21444  *     elif dst_ndim < src_ndim:
21445  *         broadcast_leading(&dst, dst_ndim, src_ndim)             # <<<<<<<<<<<<<<
21446  *
21447  *     cdef int ndim = max(src_ndim, dst_ndim)
21448  */
21449     __pyx_memoryview_broadcast_leading((&__pyx_v_dst), __pyx_v_dst_ndim, __pyx_v_src_ndim);
21450 
21451     /* "View.MemoryView":1286
21452  *     if src_ndim < dst_ndim:
21453  *         broadcast_leading(&src, src_ndim, dst_ndim)
21454  *     elif dst_ndim < src_ndim:             # <<<<<<<<<<<<<<
21455  *         broadcast_leading(&dst, dst_ndim, src_ndim)
21456  *
21457  */
21458   }
21459   __pyx_L3:;
21460 
21461   /* "View.MemoryView":1289
21462  *         broadcast_leading(&dst, dst_ndim, src_ndim)
21463  *
21464  *     cdef int ndim = max(src_ndim, dst_ndim)             # <<<<<<<<<<<<<<
21465  *
21466  *     for i in range(ndim):
21467  */
21468   __pyx_t_3 = __pyx_v_dst_ndim;
21469   __pyx_t_4 = __pyx_v_src_ndim;
21470   if (((__pyx_t_3 > __pyx_t_4) != 0)) {
21471     __pyx_t_5 = __pyx_t_3;
21472   } else {
21473     __pyx_t_5 = __pyx_t_4;
21474   }
21475   __pyx_v_ndim = __pyx_t_5;
21476 
21477   /* "View.MemoryView":1291
21478  *     cdef int ndim = max(src_ndim, dst_ndim)
21479  *
21480  *     for i in range(ndim):             # <<<<<<<<<<<<<<
21481  *         if src.shape[i] != dst.shape[i]:
21482  *             if src.shape[i] == 1:
21483  */
21484   __pyx_t_5 = __pyx_v_ndim;
21485   __pyx_t_3 = __pyx_t_5;
21486   for (__pyx_t_4 = 0; __pyx_t_4 < __pyx_t_3; __pyx_t_4+=1) {
21487     __pyx_v_i = __pyx_t_4;
21488 
21489     /* "View.MemoryView":1292
21490  *
21491  *     for i in range(ndim):
21492  *         if src.shape[i] != dst.shape[i]:             # <<<<<<<<<<<<<<
21493  *             if src.shape[i] == 1:
21494  *                 broadcasting = True
21495  */
21496     __pyx_t_2 = (((__pyx_v_src.shape[__pyx_v_i]) != (__pyx_v_dst.shape[__pyx_v_i])) != 0);
21497     if (__pyx_t_2) {
21498 
21499       /* "View.MemoryView":1293
21500  *     for i in range(ndim):
21501  *         if src.shape[i] != dst.shape[i]:
21502  *             if src.shape[i] == 1:             # <<<<<<<<<<<<<<
21503  *                 broadcasting = True
21504  *                 src.strides[i] = 0
21505  */
21506       __pyx_t_2 = (((__pyx_v_src.shape[__pyx_v_i]) == 1) != 0);
21507       if (__pyx_t_2) {
21508 
21509         /* "View.MemoryView":1294
21510  *         if src.shape[i] != dst.shape[i]:
21511  *             if src.shape[i] == 1:
21512  *                 broadcasting = True             # <<<<<<<<<<<<<<
21513  *                 src.strides[i] = 0
21514  *             else:
21515  */
21516         __pyx_v_broadcasting = 1;
21517 
21518         /* "View.MemoryView":1295
21519  *             if src.shape[i] == 1:
21520  *                 broadcasting = True
21521  *                 src.strides[i] = 0             # <<<<<<<<<<<<<<
21522  *             else:
21523  *                 _err_extents(i, dst.shape[i], src.shape[i])
21524  */
21525         (__pyx_v_src.strides[__pyx_v_i]) = 0;
21526 
21527         /* "View.MemoryView":1293
21528  *     for i in range(ndim):
21529  *         if src.shape[i] != dst.shape[i]:
21530  *             if src.shape[i] == 1:             # <<<<<<<<<<<<<<
21531  *                 broadcasting = True
21532  *                 src.strides[i] = 0
21533  */
21534         goto __pyx_L7;
21535       }
21536 
21537       /* "View.MemoryView":1297
21538  *                 src.strides[i] = 0
21539  *             else:
21540  *                 _err_extents(i, dst.shape[i], src.shape[i])             # <<<<<<<<<<<<<<
21541  *
21542  *         if src.suboffsets[i] >= 0:
21543  */
21544       /*else*/ {
21545         __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)
21546       }
21547       __pyx_L7:;
21548 
21549       /* "View.MemoryView":1292
21550  *
21551  *     for i in range(ndim):
21552  *         if src.shape[i] != dst.shape[i]:             # <<<<<<<<<<<<<<
21553  *             if src.shape[i] == 1:
21554  *                 broadcasting = True
21555  */
21556     }
21557 
21558     /* "View.MemoryView":1299
21559  *                 _err_extents(i, dst.shape[i], src.shape[i])
21560  *
21561  *         if src.suboffsets[i] >= 0:             # <<<<<<<<<<<<<<
21562  *             _err_dim(ValueError, "Dimension %d is not direct", i)
21563  *
21564  */
21565     __pyx_t_2 = (((__pyx_v_src.suboffsets[__pyx_v_i]) >= 0) != 0);
21566     if (__pyx_t_2) {
21567 
21568       /* "View.MemoryView":1300
21569  *
21570  *         if src.suboffsets[i] >= 0:
21571  *             _err_dim(ValueError, "Dimension %d is not direct", i)             # <<<<<<<<<<<<<<
21572  *
21573  *     if slices_overlap(&src, &dst, ndim, itemsize):
21574  */
21575       __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)
21576 
21577       /* "View.MemoryView":1299
21578  *                 _err_extents(i, dst.shape[i], src.shape[i])
21579  *
21580  *         if src.suboffsets[i] >= 0:             # <<<<<<<<<<<<<<
21581  *             _err_dim(ValueError, "Dimension %d is not direct", i)
21582  *
21583  */
21584     }
21585   }
21586 
21587   /* "View.MemoryView":1302
21588  *             _err_dim(ValueError, "Dimension %d is not direct", i)
21589  *
21590  *     if slices_overlap(&src, &dst, ndim, itemsize):             # <<<<<<<<<<<<<<
21591  *
21592  *         if not slice_is_contig(src, order, ndim):
21593  */
21594   __pyx_t_2 = (__pyx_slices_overlap((&__pyx_v_src), (&__pyx_v_dst), __pyx_v_ndim, __pyx_v_itemsize) != 0);
21595   if (__pyx_t_2) {
21596 
21597     /* "View.MemoryView":1304
21598  *     if slices_overlap(&src, &dst, ndim, itemsize):
21599  *
21600  *         if not slice_is_contig(src, order, ndim):             # <<<<<<<<<<<<<<
21601  *             order = get_best_order(&dst, ndim)
21602  *
21603  */
21604     __pyx_t_2 = ((!(__pyx_memviewslice_is_contig(__pyx_v_src, __pyx_v_order, __pyx_v_ndim) != 0)) != 0);
21605     if (__pyx_t_2) {
21606 
21607       /* "View.MemoryView":1305
21608  *
21609  *         if not slice_is_contig(src, order, ndim):
21610  *             order = get_best_order(&dst, ndim)             # <<<<<<<<<<<<<<
21611  *
21612  *         tmpdata = copy_data_to_temp(&src, &tmp, order, ndim)
21613  */
21614       __pyx_v_order = __pyx_get_best_slice_order((&__pyx_v_dst), __pyx_v_ndim);
21615 
21616       /* "View.MemoryView":1304
21617  *     if slices_overlap(&src, &dst, ndim, itemsize):
21618  *
21619  *         if not slice_is_contig(src, order, ndim):             # <<<<<<<<<<<<<<
21620  *             order = get_best_order(&dst, ndim)
21621  *
21622  */
21623     }
21624 
21625     /* "View.MemoryView":1307
21626  *             order = get_best_order(&dst, ndim)
21627  *
21628  *         tmpdata = copy_data_to_temp(&src, &tmp, order, ndim)             # <<<<<<<<<<<<<<
21629  *         src = tmp
21630  *
21631  */
21632     __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)
21633     __pyx_v_tmpdata = __pyx_t_7;
21634 
21635     /* "View.MemoryView":1308
21636  *
21637  *         tmpdata = copy_data_to_temp(&src, &tmp, order, ndim)
21638  *         src = tmp             # <<<<<<<<<<<<<<
21639  *
21640  *     if not broadcasting:
21641  */
21642     __pyx_v_src = __pyx_v_tmp;
21643 
21644     /* "View.MemoryView":1302
21645  *             _err_dim(ValueError, "Dimension %d is not direct", i)
21646  *
21647  *     if slices_overlap(&src, &dst, ndim, itemsize):             # <<<<<<<<<<<<<<
21648  *
21649  *         if not slice_is_contig(src, order, ndim):
21650  */
21651   }
21652 
21653   /* "View.MemoryView":1310
21654  *         src = tmp
21655  *
21656  *     if not broadcasting:             # <<<<<<<<<<<<<<
21657  *
21658  *
21659  */
21660   __pyx_t_2 = ((!(__pyx_v_broadcasting != 0)) != 0);
21661   if (__pyx_t_2) {
21662 
21663     /* "View.MemoryView":1313
21664  *
21665  *
21666  *         if slice_is_contig(src, 'C', ndim):             # <<<<<<<<<<<<<<
21667  *             direct_copy = slice_is_contig(dst, 'C', ndim)
21668  *         elif slice_is_contig(src, 'F', ndim):
21669  */
21670     __pyx_t_2 = (__pyx_memviewslice_is_contig(__pyx_v_src, 'C', __pyx_v_ndim) != 0);
21671     if (__pyx_t_2) {
21672 
21673       /* "View.MemoryView":1314
21674  *
21675  *         if slice_is_contig(src, 'C', ndim):
21676  *             direct_copy = slice_is_contig(dst, 'C', ndim)             # <<<<<<<<<<<<<<
21677  *         elif slice_is_contig(src, 'F', ndim):
21678  *             direct_copy = slice_is_contig(dst, 'F', ndim)
21679  */
21680       __pyx_v_direct_copy = __pyx_memviewslice_is_contig(__pyx_v_dst, 'C', __pyx_v_ndim);
21681 
21682       /* "View.MemoryView":1313
21683  *
21684  *
21685  *         if slice_is_contig(src, 'C', ndim):             # <<<<<<<<<<<<<<
21686  *             direct_copy = slice_is_contig(dst, 'C', ndim)
21687  *         elif slice_is_contig(src, 'F', ndim):
21688  */
21689       goto __pyx_L12;
21690     }
21691 
21692     /* "View.MemoryView":1315
21693  *         if slice_is_contig(src, 'C', ndim):
21694  *             direct_copy = slice_is_contig(dst, 'C', ndim)
21695  *         elif slice_is_contig(src, 'F', ndim):             # <<<<<<<<<<<<<<
21696  *             direct_copy = slice_is_contig(dst, 'F', ndim)
21697  *
21698  */
21699     __pyx_t_2 = (__pyx_memviewslice_is_contig(__pyx_v_src, 'F', __pyx_v_ndim) != 0);
21700     if (__pyx_t_2) {
21701 
21702       /* "View.MemoryView":1316
21703  *             direct_copy = slice_is_contig(dst, 'C', ndim)
21704  *         elif slice_is_contig(src, 'F', ndim):
21705  *             direct_copy = slice_is_contig(dst, 'F', ndim)             # <<<<<<<<<<<<<<
21706  *
21707  *         if direct_copy:
21708  */
21709       __pyx_v_direct_copy = __pyx_memviewslice_is_contig(__pyx_v_dst, 'F', __pyx_v_ndim);
21710 
21711       /* "View.MemoryView":1315
21712  *         if slice_is_contig(src, 'C', ndim):
21713  *             direct_copy = slice_is_contig(dst, 'C', ndim)
21714  *         elif slice_is_contig(src, 'F', ndim):             # <<<<<<<<<<<<<<
21715  *             direct_copy = slice_is_contig(dst, 'F', ndim)
21716  *
21717  */
21718     }
21719     __pyx_L12:;
21720 
21721     /* "View.MemoryView":1318
21722  *             direct_copy = slice_is_contig(dst, 'F', ndim)
21723  *
21724  *         if direct_copy:             # <<<<<<<<<<<<<<
21725  *
21726  *             refcount_copying(&dst, dtype_is_object, ndim, False)
21727  */
21728     __pyx_t_2 = (__pyx_v_direct_copy != 0);
21729     if (__pyx_t_2) {
21730 
21731       /* "View.MemoryView":1320
21732  *         if direct_copy:
21733  *
21734  *             refcount_copying(&dst, dtype_is_object, ndim, False)             # <<<<<<<<<<<<<<
21735  *             memcpy(dst.data, src.data, slice_get_size(&src, ndim))
21736  *             refcount_copying(&dst, dtype_is_object, ndim, True)
21737  */
21738       __pyx_memoryview_refcount_copying((&__pyx_v_dst), __pyx_v_dtype_is_object, __pyx_v_ndim, 0);
21739 
21740       /* "View.MemoryView":1321
21741  *
21742  *             refcount_copying(&dst, dtype_is_object, ndim, False)
21743  *             memcpy(dst.data, src.data, slice_get_size(&src, ndim))             # <<<<<<<<<<<<<<
21744  *             refcount_copying(&dst, dtype_is_object, ndim, True)
21745  *             free(tmpdata)
21746  */
21747       (void)(memcpy(__pyx_v_dst.data, __pyx_v_src.data, __pyx_memoryview_slice_get_size((&__pyx_v_src), __pyx_v_ndim)));
21748 
21749       /* "View.MemoryView":1322
21750  *             refcount_copying(&dst, dtype_is_object, ndim, False)
21751  *             memcpy(dst.data, src.data, slice_get_size(&src, ndim))
21752  *             refcount_copying(&dst, dtype_is_object, ndim, True)             # <<<<<<<<<<<<<<
21753  *             free(tmpdata)
21754  *             return 0
21755  */
21756       __pyx_memoryview_refcount_copying((&__pyx_v_dst), __pyx_v_dtype_is_object, __pyx_v_ndim, 1);
21757 
21758       /* "View.MemoryView":1323
21759  *             memcpy(dst.data, src.data, slice_get_size(&src, ndim))
21760  *             refcount_copying(&dst, dtype_is_object, ndim, True)
21761  *             free(tmpdata)             # <<<<<<<<<<<<<<
21762  *             return 0
21763  *
21764  */
21765       free(__pyx_v_tmpdata);
21766 
21767       /* "View.MemoryView":1324
21768  *             refcount_copying(&dst, dtype_is_object, ndim, True)
21769  *             free(tmpdata)
21770  *             return 0             # <<<<<<<<<<<<<<
21771  *
21772  *     if order == 'F' == get_best_order(&dst, ndim):
21773  */
21774       __pyx_r = 0;
21775       goto __pyx_L0;
21776 
21777       /* "View.MemoryView":1318
21778  *             direct_copy = slice_is_contig(dst, 'F', ndim)
21779  *
21780  *         if direct_copy:             # <<<<<<<<<<<<<<
21781  *
21782  *             refcount_copying(&dst, dtype_is_object, ndim, False)
21783  */
21784     }
21785 
21786     /* "View.MemoryView":1310
21787  *         src = tmp
21788  *
21789  *     if not broadcasting:             # <<<<<<<<<<<<<<
21790  *
21791  *
21792  */
21793   }
21794 
21795   /* "View.MemoryView":1326
21796  *             return 0
21797  *
21798  *     if order == 'F' == get_best_order(&dst, ndim):             # <<<<<<<<<<<<<<
21799  *
21800  *
21801  */
21802   __pyx_t_2 = (__pyx_v_order == 'F');
21803   if (__pyx_t_2) {
21804     __pyx_t_2 = ('F' == __pyx_get_best_slice_order((&__pyx_v_dst), __pyx_v_ndim));
21805   }
21806   __pyx_t_8 = (__pyx_t_2 != 0);
21807   if (__pyx_t_8) {
21808 
21809     /* "View.MemoryView":1329
21810  *
21811  *
21812  *         transpose_memslice(&src)             # <<<<<<<<<<<<<<
21813  *         transpose_memslice(&dst)
21814  *
21815  */
21816     __pyx_t_5 = __pyx_memslice_transpose((&__pyx_v_src)); if (unlikely(__pyx_t_5 == ((int)0))) __PYX_ERR(2, 1329, __pyx_L1_error)
21817 
21818     /* "View.MemoryView":1330
21819  *
21820  *         transpose_memslice(&src)
21821  *         transpose_memslice(&dst)             # <<<<<<<<<<<<<<
21822  *
21823  *     refcount_copying(&dst, dtype_is_object, ndim, False)
21824  */
21825     __pyx_t_5 = __pyx_memslice_transpose((&__pyx_v_dst)); if (unlikely(__pyx_t_5 == ((int)0))) __PYX_ERR(2, 1330, __pyx_L1_error)
21826 
21827     /* "View.MemoryView":1326
21828  *             return 0
21829  *
21830  *     if order == 'F' == get_best_order(&dst, ndim):             # <<<<<<<<<<<<<<
21831  *
21832  *
21833  */
21834   }
21835 
21836   /* "View.MemoryView":1332
21837  *         transpose_memslice(&dst)
21838  *
21839  *     refcount_copying(&dst, dtype_is_object, ndim, False)             # <<<<<<<<<<<<<<
21840  *     copy_strided_to_strided(&src, &dst, ndim, itemsize)
21841  *     refcount_copying(&dst, dtype_is_object, ndim, True)
21842  */
21843   __pyx_memoryview_refcount_copying((&__pyx_v_dst), __pyx_v_dtype_is_object, __pyx_v_ndim, 0);
21844 
21845   /* "View.MemoryView":1333
21846  *
21847  *     refcount_copying(&dst, dtype_is_object, ndim, False)
21848  *     copy_strided_to_strided(&src, &dst, ndim, itemsize)             # <<<<<<<<<<<<<<
21849  *     refcount_copying(&dst, dtype_is_object, ndim, True)
21850  *
21851  */
21852   copy_strided_to_strided((&__pyx_v_src), (&__pyx_v_dst), __pyx_v_ndim, __pyx_v_itemsize);
21853 
21854   /* "View.MemoryView":1334
21855  *     refcount_copying(&dst, dtype_is_object, ndim, False)
21856  *     copy_strided_to_strided(&src, &dst, ndim, itemsize)
21857  *     refcount_copying(&dst, dtype_is_object, ndim, True)             # <<<<<<<<<<<<<<
21858  *
21859  *     free(tmpdata)
21860  */
21861   __pyx_memoryview_refcount_copying((&__pyx_v_dst), __pyx_v_dtype_is_object, __pyx_v_ndim, 1);
21862 
21863   /* "View.MemoryView":1336
21864  *     refcount_copying(&dst, dtype_is_object, ndim, True)
21865  *
21866  *     free(tmpdata)             # <<<<<<<<<<<<<<
21867  *     return 0
21868  *
21869  */
21870   free(__pyx_v_tmpdata);
21871 
21872   /* "View.MemoryView":1337
21873  *
21874  *     free(tmpdata)
21875  *     return 0             # <<<<<<<<<<<<<<
21876  *
21877  * @cname('__pyx_memoryview_broadcast_leading')
21878  */
21879   __pyx_r = 0;
21880   goto __pyx_L0;
21881 
21882   /* "View.MemoryView":1268
21883  *
21884  * @cname('__pyx_memoryview_copy_contents')
21885  * cdef int memoryview_copy_contents(__Pyx_memviewslice src,             # <<<<<<<<<<<<<<
21886  *                                   __Pyx_memviewslice dst,
21887  *                                   int src_ndim, int dst_ndim,
21888  */
21889 
21890   /* function exit code */
21891   __pyx_L1_error:;
21892   {
21893     #ifdef WITH_THREAD
21894     PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure();
21895     #endif
21896     __Pyx_AddTraceback("View.MemoryView.memoryview_copy_contents", __pyx_clineno, __pyx_lineno, __pyx_filename);
21897     #ifdef WITH_THREAD
21898     __Pyx_PyGILState_Release(__pyx_gilstate_save);
21899     #endif
21900   }
21901   __pyx_r = -1;
21902   __pyx_L0:;
21903   return __pyx_r;
21904 }
21905 
21906 /* "View.MemoryView":1340
21907  *
21908  * @cname('__pyx_memoryview_broadcast_leading')
21909  * cdef void broadcast_leading(__Pyx_memviewslice *mslice,             # <<<<<<<<<<<<<<
21910  *                             int ndim,
21911  *                             int ndim_other) nogil:
21912  */
21913 
__pyx_memoryview_broadcast_leading(__Pyx_memviewslice * __pyx_v_mslice,int __pyx_v_ndim,int __pyx_v_ndim_other)21914 static void __pyx_memoryview_broadcast_leading(__Pyx_memviewslice *__pyx_v_mslice, int __pyx_v_ndim, int __pyx_v_ndim_other) {
21915   int __pyx_v_i;
21916   int __pyx_v_offset;
21917   int __pyx_t_1;
21918   int __pyx_t_2;
21919   int __pyx_t_3;
21920 
21921   /* "View.MemoryView":1344
21922  *                             int ndim_other) nogil:
21923  *     cdef int i
21924  *     cdef int offset = ndim_other - ndim             # <<<<<<<<<<<<<<
21925  *
21926  *     for i in range(ndim - 1, -1, -1):
21927  */
21928   __pyx_v_offset = (__pyx_v_ndim_other - __pyx_v_ndim);
21929 
21930   /* "View.MemoryView":1346
21931  *     cdef int offset = ndim_other - ndim
21932  *
21933  *     for i in range(ndim - 1, -1, -1):             # <<<<<<<<<<<<<<
21934  *         mslice.shape[i + offset] = mslice.shape[i]
21935  *         mslice.strides[i + offset] = mslice.strides[i]
21936  */
21937   for (__pyx_t_1 = (__pyx_v_ndim - 1); __pyx_t_1 > -1; __pyx_t_1-=1) {
21938     __pyx_v_i = __pyx_t_1;
21939 
21940     /* "View.MemoryView":1347
21941  *
21942  *     for i in range(ndim - 1, -1, -1):
21943  *         mslice.shape[i + offset] = mslice.shape[i]             # <<<<<<<<<<<<<<
21944  *         mslice.strides[i + offset] = mslice.strides[i]
21945  *         mslice.suboffsets[i + offset] = mslice.suboffsets[i]
21946  */
21947     (__pyx_v_mslice->shape[(__pyx_v_i + __pyx_v_offset)]) = (__pyx_v_mslice->shape[__pyx_v_i]);
21948 
21949     /* "View.MemoryView":1348
21950  *     for i in range(ndim - 1, -1, -1):
21951  *         mslice.shape[i + offset] = mslice.shape[i]
21952  *         mslice.strides[i + offset] = mslice.strides[i]             # <<<<<<<<<<<<<<
21953  *         mslice.suboffsets[i + offset] = mslice.suboffsets[i]
21954  *
21955  */
21956     (__pyx_v_mslice->strides[(__pyx_v_i + __pyx_v_offset)]) = (__pyx_v_mslice->strides[__pyx_v_i]);
21957 
21958     /* "View.MemoryView":1349
21959  *         mslice.shape[i + offset] = mslice.shape[i]
21960  *         mslice.strides[i + offset] = mslice.strides[i]
21961  *         mslice.suboffsets[i + offset] = mslice.suboffsets[i]             # <<<<<<<<<<<<<<
21962  *
21963  *     for i in range(offset):
21964  */
21965     (__pyx_v_mslice->suboffsets[(__pyx_v_i + __pyx_v_offset)]) = (__pyx_v_mslice->suboffsets[__pyx_v_i]);
21966   }
21967 
21968   /* "View.MemoryView":1351
21969  *         mslice.suboffsets[i + offset] = mslice.suboffsets[i]
21970  *
21971  *     for i in range(offset):             # <<<<<<<<<<<<<<
21972  *         mslice.shape[i] = 1
21973  *         mslice.strides[i] = mslice.strides[0]
21974  */
21975   __pyx_t_1 = __pyx_v_offset;
21976   __pyx_t_2 = __pyx_t_1;
21977   for (__pyx_t_3 = 0; __pyx_t_3 < __pyx_t_2; __pyx_t_3+=1) {
21978     __pyx_v_i = __pyx_t_3;
21979 
21980     /* "View.MemoryView":1352
21981  *
21982  *     for i in range(offset):
21983  *         mslice.shape[i] = 1             # <<<<<<<<<<<<<<
21984  *         mslice.strides[i] = mslice.strides[0]
21985  *         mslice.suboffsets[i] = -1
21986  */
21987     (__pyx_v_mslice->shape[__pyx_v_i]) = 1;
21988 
21989     /* "View.MemoryView":1353
21990  *     for i in range(offset):
21991  *         mslice.shape[i] = 1
21992  *         mslice.strides[i] = mslice.strides[0]             # <<<<<<<<<<<<<<
21993  *         mslice.suboffsets[i] = -1
21994  *
21995  */
21996     (__pyx_v_mslice->strides[__pyx_v_i]) = (__pyx_v_mslice->strides[0]);
21997 
21998     /* "View.MemoryView":1354
21999  *         mslice.shape[i] = 1
22000  *         mslice.strides[i] = mslice.strides[0]
22001  *         mslice.suboffsets[i] = -1             # <<<<<<<<<<<<<<
22002  *
22003  *
22004  */
22005     (__pyx_v_mslice->suboffsets[__pyx_v_i]) = -1L;
22006   }
22007 
22008   /* "View.MemoryView":1340
22009  *
22010  * @cname('__pyx_memoryview_broadcast_leading')
22011  * cdef void broadcast_leading(__Pyx_memviewslice *mslice,             # <<<<<<<<<<<<<<
22012  *                             int ndim,
22013  *                             int ndim_other) nogil:
22014  */
22015 
22016   /* function exit code */
22017 }
22018 
22019 /* "View.MemoryView":1362
22020  *
22021  * @cname('__pyx_memoryview_refcount_copying')
22022  * cdef void refcount_copying(__Pyx_memviewslice *dst, bint dtype_is_object,             # <<<<<<<<<<<<<<
22023  *                            int ndim, bint inc) nogil:
22024  *
22025  */
22026 
__pyx_memoryview_refcount_copying(__Pyx_memviewslice * __pyx_v_dst,int __pyx_v_dtype_is_object,int __pyx_v_ndim,int __pyx_v_inc)22027 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) {
22028   int __pyx_t_1;
22029 
22030   /* "View.MemoryView":1366
22031  *
22032  *
22033  *     if dtype_is_object:             # <<<<<<<<<<<<<<
22034  *         refcount_objects_in_slice_with_gil(dst.data, dst.shape,
22035  *                                            dst.strides, ndim, inc)
22036  */
22037   __pyx_t_1 = (__pyx_v_dtype_is_object != 0);
22038   if (__pyx_t_1) {
22039 
22040     /* "View.MemoryView":1367
22041  *
22042  *     if dtype_is_object:
22043  *         refcount_objects_in_slice_with_gil(dst.data, dst.shape,             # <<<<<<<<<<<<<<
22044  *                                            dst.strides, ndim, inc)
22045  *
22046  */
22047     __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);
22048 
22049     /* "View.MemoryView":1366
22050  *
22051  *
22052  *     if dtype_is_object:             # <<<<<<<<<<<<<<
22053  *         refcount_objects_in_slice_with_gil(dst.data, dst.shape,
22054  *                                            dst.strides, ndim, inc)
22055  */
22056   }
22057 
22058   /* "View.MemoryView":1362
22059  *
22060  * @cname('__pyx_memoryview_refcount_copying')
22061  * cdef void refcount_copying(__Pyx_memviewslice *dst, bint dtype_is_object,             # <<<<<<<<<<<<<<
22062  *                            int ndim, bint inc) nogil:
22063  *
22064  */
22065 
22066   /* function exit code */
22067 }
22068 
22069 /* "View.MemoryView":1371
22070  *
22071  * @cname('__pyx_memoryview_refcount_objects_in_slice_with_gil')
22072  * cdef void refcount_objects_in_slice_with_gil(char *data, Py_ssize_t *shape,             # <<<<<<<<<<<<<<
22073  *                                              Py_ssize_t *strides, int ndim,
22074  *                                              bint inc) with gil:
22075  */
22076 
__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)22077 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) {
22078   __Pyx_RefNannyDeclarations
22079   #ifdef WITH_THREAD
22080   PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure();
22081   #endif
22082   __Pyx_RefNannySetupContext("refcount_objects_in_slice_with_gil", 0);
22083 
22084   /* "View.MemoryView":1374
22085  *                                              Py_ssize_t *strides, int ndim,
22086  *                                              bint inc) with gil:
22087  *     refcount_objects_in_slice(data, shape, strides, ndim, inc)             # <<<<<<<<<<<<<<
22088  *
22089  * @cname('__pyx_memoryview_refcount_objects_in_slice')
22090  */
22091   __pyx_memoryview_refcount_objects_in_slice(__pyx_v_data, __pyx_v_shape, __pyx_v_strides, __pyx_v_ndim, __pyx_v_inc);
22092 
22093   /* "View.MemoryView":1371
22094  *
22095  * @cname('__pyx_memoryview_refcount_objects_in_slice_with_gil')
22096  * cdef void refcount_objects_in_slice_with_gil(char *data, Py_ssize_t *shape,             # <<<<<<<<<<<<<<
22097  *                                              Py_ssize_t *strides, int ndim,
22098  *                                              bint inc) with gil:
22099  */
22100 
22101   /* function exit code */
22102   __Pyx_RefNannyFinishContext();
22103   #ifdef WITH_THREAD
22104   __Pyx_PyGILState_Release(__pyx_gilstate_save);
22105   #endif
22106 }
22107 
22108 /* "View.MemoryView":1377
22109  *
22110  * @cname('__pyx_memoryview_refcount_objects_in_slice')
22111  * cdef void refcount_objects_in_slice(char *data, Py_ssize_t *shape,             # <<<<<<<<<<<<<<
22112  *                                     Py_ssize_t *strides, int ndim, bint inc):
22113  *     cdef Py_ssize_t i
22114  */
22115 
__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)22116 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) {
22117   CYTHON_UNUSED Py_ssize_t __pyx_v_i;
22118   __Pyx_RefNannyDeclarations
22119   Py_ssize_t __pyx_t_1;
22120   Py_ssize_t __pyx_t_2;
22121   Py_ssize_t __pyx_t_3;
22122   int __pyx_t_4;
22123   __Pyx_RefNannySetupContext("refcount_objects_in_slice", 0);
22124 
22125   /* "View.MemoryView":1381
22126  *     cdef Py_ssize_t i
22127  *
22128  *     for i in range(shape[0]):             # <<<<<<<<<<<<<<
22129  *         if ndim == 1:
22130  *             if inc:
22131  */
22132   __pyx_t_1 = (__pyx_v_shape[0]);
22133   __pyx_t_2 = __pyx_t_1;
22134   for (__pyx_t_3 = 0; __pyx_t_3 < __pyx_t_2; __pyx_t_3+=1) {
22135     __pyx_v_i = __pyx_t_3;
22136 
22137     /* "View.MemoryView":1382
22138  *
22139  *     for i in range(shape[0]):
22140  *         if ndim == 1:             # <<<<<<<<<<<<<<
22141  *             if inc:
22142  *                 Py_INCREF((<PyObject **> data)[0])
22143  */
22144     __pyx_t_4 = ((__pyx_v_ndim == 1) != 0);
22145     if (__pyx_t_4) {
22146 
22147       /* "View.MemoryView":1383
22148  *     for i in range(shape[0]):
22149  *         if ndim == 1:
22150  *             if inc:             # <<<<<<<<<<<<<<
22151  *                 Py_INCREF((<PyObject **> data)[0])
22152  *             else:
22153  */
22154       __pyx_t_4 = (__pyx_v_inc != 0);
22155       if (__pyx_t_4) {
22156 
22157         /* "View.MemoryView":1384
22158  *         if ndim == 1:
22159  *             if inc:
22160  *                 Py_INCREF((<PyObject **> data)[0])             # <<<<<<<<<<<<<<
22161  *             else:
22162  *                 Py_DECREF((<PyObject **> data)[0])
22163  */
22164         Py_INCREF((((PyObject **)__pyx_v_data)[0]));
22165 
22166         /* "View.MemoryView":1383
22167  *     for i in range(shape[0]):
22168  *         if ndim == 1:
22169  *             if inc:             # <<<<<<<<<<<<<<
22170  *                 Py_INCREF((<PyObject **> data)[0])
22171  *             else:
22172  */
22173         goto __pyx_L6;
22174       }
22175 
22176       /* "View.MemoryView":1386
22177  *                 Py_INCREF((<PyObject **> data)[0])
22178  *             else:
22179  *                 Py_DECREF((<PyObject **> data)[0])             # <<<<<<<<<<<<<<
22180  *         else:
22181  *             refcount_objects_in_slice(data, shape + 1, strides + 1,
22182  */
22183       /*else*/ {
22184         Py_DECREF((((PyObject **)__pyx_v_data)[0]));
22185       }
22186       __pyx_L6:;
22187 
22188       /* "View.MemoryView":1382
22189  *
22190  *     for i in range(shape[0]):
22191  *         if ndim == 1:             # <<<<<<<<<<<<<<
22192  *             if inc:
22193  *                 Py_INCREF((<PyObject **> data)[0])
22194  */
22195       goto __pyx_L5;
22196     }
22197 
22198     /* "View.MemoryView":1388
22199  *                 Py_DECREF((<PyObject **> data)[0])
22200  *         else:
22201  *             refcount_objects_in_slice(data, shape + 1, strides + 1,             # <<<<<<<<<<<<<<
22202  *                                       ndim - 1, inc)
22203  *
22204  */
22205     /*else*/ {
22206 
22207       /* "View.MemoryView":1389
22208  *         else:
22209  *             refcount_objects_in_slice(data, shape + 1, strides + 1,
22210  *                                       ndim - 1, inc)             # <<<<<<<<<<<<<<
22211  *
22212  *         data += strides[0]
22213  */
22214       __pyx_memoryview_refcount_objects_in_slice(__pyx_v_data, (__pyx_v_shape + 1), (__pyx_v_strides + 1), (__pyx_v_ndim - 1), __pyx_v_inc);
22215     }
22216     __pyx_L5:;
22217 
22218     /* "View.MemoryView":1391
22219  *                                       ndim - 1, inc)
22220  *
22221  *         data += strides[0]             # <<<<<<<<<<<<<<
22222  *
22223  *
22224  */
22225     __pyx_v_data = (__pyx_v_data + (__pyx_v_strides[0]));
22226   }
22227 
22228   /* "View.MemoryView":1377
22229  *
22230  * @cname('__pyx_memoryview_refcount_objects_in_slice')
22231  * cdef void refcount_objects_in_slice(char *data, Py_ssize_t *shape,             # <<<<<<<<<<<<<<
22232  *                                     Py_ssize_t *strides, int ndim, bint inc):
22233  *     cdef Py_ssize_t i
22234  */
22235 
22236   /* function exit code */
22237   __Pyx_RefNannyFinishContext();
22238 }
22239 
22240 /* "View.MemoryView":1397
22241  *
22242  * @cname('__pyx_memoryview_slice_assign_scalar')
22243  * cdef void slice_assign_scalar(__Pyx_memviewslice *dst, int ndim,             # <<<<<<<<<<<<<<
22244  *                               size_t itemsize, void *item,
22245  *                               bint dtype_is_object) nogil:
22246  */
22247 
__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)22248 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) {
22249 
22250   /* "View.MemoryView":1400
22251  *                               size_t itemsize, void *item,
22252  *                               bint dtype_is_object) nogil:
22253  *     refcount_copying(dst, dtype_is_object, ndim, False)             # <<<<<<<<<<<<<<
22254  *     _slice_assign_scalar(dst.data, dst.shape, dst.strides, ndim,
22255  *                          itemsize, item)
22256  */
22257   __pyx_memoryview_refcount_copying(__pyx_v_dst, __pyx_v_dtype_is_object, __pyx_v_ndim, 0);
22258 
22259   /* "View.MemoryView":1401
22260  *                               bint dtype_is_object) nogil:
22261  *     refcount_copying(dst, dtype_is_object, ndim, False)
22262  *     _slice_assign_scalar(dst.data, dst.shape, dst.strides, ndim,             # <<<<<<<<<<<<<<
22263  *                          itemsize, item)
22264  *     refcount_copying(dst, dtype_is_object, ndim, True)
22265  */
22266   __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);
22267 
22268   /* "View.MemoryView":1403
22269  *     _slice_assign_scalar(dst.data, dst.shape, dst.strides, ndim,
22270  *                          itemsize, item)
22271  *     refcount_copying(dst, dtype_is_object, ndim, True)             # <<<<<<<<<<<<<<
22272  *
22273  *
22274  */
22275   __pyx_memoryview_refcount_copying(__pyx_v_dst, __pyx_v_dtype_is_object, __pyx_v_ndim, 1);
22276 
22277   /* "View.MemoryView":1397
22278  *
22279  * @cname('__pyx_memoryview_slice_assign_scalar')
22280  * cdef void slice_assign_scalar(__Pyx_memviewslice *dst, int ndim,             # <<<<<<<<<<<<<<
22281  *                               size_t itemsize, void *item,
22282  *                               bint dtype_is_object) nogil:
22283  */
22284 
22285   /* function exit code */
22286 }
22287 
22288 /* "View.MemoryView":1407
22289  *
22290  * @cname('__pyx_memoryview__slice_assign_scalar')
22291  * cdef void _slice_assign_scalar(char *data, Py_ssize_t *shape,             # <<<<<<<<<<<<<<
22292  *                               Py_ssize_t *strides, int ndim,
22293  *                               size_t itemsize, void *item) nogil:
22294  */
22295 
__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)22296 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) {
22297   CYTHON_UNUSED Py_ssize_t __pyx_v_i;
22298   Py_ssize_t __pyx_v_stride;
22299   Py_ssize_t __pyx_v_extent;
22300   int __pyx_t_1;
22301   Py_ssize_t __pyx_t_2;
22302   Py_ssize_t __pyx_t_3;
22303   Py_ssize_t __pyx_t_4;
22304 
22305   /* "View.MemoryView":1411
22306  *                               size_t itemsize, void *item) nogil:
22307  *     cdef Py_ssize_t i
22308  *     cdef Py_ssize_t stride = strides[0]             # <<<<<<<<<<<<<<
22309  *     cdef Py_ssize_t extent = shape[0]
22310  *
22311  */
22312   __pyx_v_stride = (__pyx_v_strides[0]);
22313 
22314   /* "View.MemoryView":1412
22315  *     cdef Py_ssize_t i
22316  *     cdef Py_ssize_t stride = strides[0]
22317  *     cdef Py_ssize_t extent = shape[0]             # <<<<<<<<<<<<<<
22318  *
22319  *     if ndim == 1:
22320  */
22321   __pyx_v_extent = (__pyx_v_shape[0]);
22322 
22323   /* "View.MemoryView":1414
22324  *     cdef Py_ssize_t extent = shape[0]
22325  *
22326  *     if ndim == 1:             # <<<<<<<<<<<<<<
22327  *         for i in range(extent):
22328  *             memcpy(data, item, itemsize)
22329  */
22330   __pyx_t_1 = ((__pyx_v_ndim == 1) != 0);
22331   if (__pyx_t_1) {
22332 
22333     /* "View.MemoryView":1415
22334  *
22335  *     if ndim == 1:
22336  *         for i in range(extent):             # <<<<<<<<<<<<<<
22337  *             memcpy(data, item, itemsize)
22338  *             data += stride
22339  */
22340     __pyx_t_2 = __pyx_v_extent;
22341     __pyx_t_3 = __pyx_t_2;
22342     for (__pyx_t_4 = 0; __pyx_t_4 < __pyx_t_3; __pyx_t_4+=1) {
22343       __pyx_v_i = __pyx_t_4;
22344 
22345       /* "View.MemoryView":1416
22346  *     if ndim == 1:
22347  *         for i in range(extent):
22348  *             memcpy(data, item, itemsize)             # <<<<<<<<<<<<<<
22349  *             data += stride
22350  *     else:
22351  */
22352       (void)(memcpy(__pyx_v_data, __pyx_v_item, __pyx_v_itemsize));
22353 
22354       /* "View.MemoryView":1417
22355  *         for i in range(extent):
22356  *             memcpy(data, item, itemsize)
22357  *             data += stride             # <<<<<<<<<<<<<<
22358  *     else:
22359  *         for i in range(extent):
22360  */
22361       __pyx_v_data = (__pyx_v_data + __pyx_v_stride);
22362     }
22363 
22364     /* "View.MemoryView":1414
22365  *     cdef Py_ssize_t extent = shape[0]
22366  *
22367  *     if ndim == 1:             # <<<<<<<<<<<<<<
22368  *         for i in range(extent):
22369  *             memcpy(data, item, itemsize)
22370  */
22371     goto __pyx_L3;
22372   }
22373 
22374   /* "View.MemoryView":1419
22375  *             data += stride
22376  *     else:
22377  *         for i in range(extent):             # <<<<<<<<<<<<<<
22378  *             _slice_assign_scalar(data, shape + 1, strides + 1,
22379  *                                 ndim - 1, itemsize, item)
22380  */
22381   /*else*/ {
22382     __pyx_t_2 = __pyx_v_extent;
22383     __pyx_t_3 = __pyx_t_2;
22384     for (__pyx_t_4 = 0; __pyx_t_4 < __pyx_t_3; __pyx_t_4+=1) {
22385       __pyx_v_i = __pyx_t_4;
22386 
22387       /* "View.MemoryView":1420
22388  *     else:
22389  *         for i in range(extent):
22390  *             _slice_assign_scalar(data, shape + 1, strides + 1,             # <<<<<<<<<<<<<<
22391  *                                 ndim - 1, itemsize, item)
22392  *             data += stride
22393  */
22394       __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);
22395 
22396       /* "View.MemoryView":1422
22397  *             _slice_assign_scalar(data, shape + 1, strides + 1,
22398  *                                 ndim - 1, itemsize, item)
22399  *             data += stride             # <<<<<<<<<<<<<<
22400  *
22401  *
22402  */
22403       __pyx_v_data = (__pyx_v_data + __pyx_v_stride);
22404     }
22405   }
22406   __pyx_L3:;
22407 
22408   /* "View.MemoryView":1407
22409  *
22410  * @cname('__pyx_memoryview__slice_assign_scalar')
22411  * cdef void _slice_assign_scalar(char *data, Py_ssize_t *shape,             # <<<<<<<<<<<<<<
22412  *                               Py_ssize_t *strides, int ndim,
22413  *                               size_t itemsize, void *item) nogil:
22414  */
22415 
22416   /* function exit code */
22417 }
22418 
22419 /* "(tree fragment)":1
22420  * def __pyx_unpickle_Enum(__pyx_type, long __pyx_checksum, __pyx_state):             # <<<<<<<<<<<<<<
22421  *     cdef object __pyx_PickleError
22422  *     cdef object __pyx_result
22423  */
22424 
22425 /* Python wrapper */
22426 static PyObject *__pyx_pw_15View_dot_MemoryView_1__pyx_unpickle_Enum(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
22427 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)22428 static PyObject *__pyx_pw_15View_dot_MemoryView_1__pyx_unpickle_Enum(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
22429   PyObject *__pyx_v___pyx_type = 0;
22430   long __pyx_v___pyx_checksum;
22431   PyObject *__pyx_v___pyx_state = 0;
22432   int __pyx_lineno = 0;
22433   const char *__pyx_filename = NULL;
22434   int __pyx_clineno = 0;
22435   PyObject *__pyx_r = 0;
22436   __Pyx_RefNannyDeclarations
22437   __Pyx_RefNannySetupContext("__pyx_unpickle_Enum (wrapper)", 0);
22438   {
22439     static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_pyx_type,&__pyx_n_s_pyx_checksum,&__pyx_n_s_pyx_state,0};
22440     PyObject* values[3] = {0,0,0};
22441     if (unlikely(__pyx_kwds)) {
22442       Py_ssize_t kw_args;
22443       const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
22444       switch (pos_args) {
22445         case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
22446         CYTHON_FALLTHROUGH;
22447         case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
22448         CYTHON_FALLTHROUGH;
22449         case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
22450         CYTHON_FALLTHROUGH;
22451         case  0: break;
22452         default: goto __pyx_L5_argtuple_error;
22453       }
22454       kw_args = PyDict_Size(__pyx_kwds);
22455       switch (pos_args) {
22456         case  0:
22457         if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_pyx_type)) != 0)) kw_args--;
22458         else goto __pyx_L5_argtuple_error;
22459         CYTHON_FALLTHROUGH;
22460         case  1:
22461         if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_pyx_checksum)) != 0)) kw_args--;
22462         else {
22463           __Pyx_RaiseArgtupleInvalid("__pyx_unpickle_Enum", 1, 3, 3, 1); __PYX_ERR(2, 1, __pyx_L3_error)
22464         }
22465         CYTHON_FALLTHROUGH;
22466         case  2:
22467         if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_pyx_state)) != 0)) kw_args--;
22468         else {
22469           __Pyx_RaiseArgtupleInvalid("__pyx_unpickle_Enum", 1, 3, 3, 2); __PYX_ERR(2, 1, __pyx_L3_error)
22470         }
22471       }
22472       if (unlikely(kw_args > 0)) {
22473         if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__pyx_unpickle_Enum") < 0)) __PYX_ERR(2, 1, __pyx_L3_error)
22474       }
22475     } else if (PyTuple_GET_SIZE(__pyx_args) != 3) {
22476       goto __pyx_L5_argtuple_error;
22477     } else {
22478       values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
22479       values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
22480       values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
22481     }
22482     __pyx_v___pyx_type = values[0];
22483     __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)
22484     __pyx_v___pyx_state = values[2];
22485   }
22486   goto __pyx_L4_argument_unpacking_done;
22487   __pyx_L5_argtuple_error:;
22488   __Pyx_RaiseArgtupleInvalid("__pyx_unpickle_Enum", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(2, 1, __pyx_L3_error)
22489   __pyx_L3_error:;
22490   __Pyx_AddTraceback("View.MemoryView.__pyx_unpickle_Enum", __pyx_clineno, __pyx_lineno, __pyx_filename);
22491   __Pyx_RefNannyFinishContext();
22492   return NULL;
22493   __pyx_L4_argument_unpacking_done:;
22494   __pyx_r = __pyx_pf_15View_dot_MemoryView___pyx_unpickle_Enum(__pyx_self, __pyx_v___pyx_type, __pyx_v___pyx_checksum, __pyx_v___pyx_state);
22495 
22496   /* function exit code */
22497   __Pyx_RefNannyFinishContext();
22498   return __pyx_r;
22499 }
22500 
__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)22501 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) {
22502   PyObject *__pyx_v___pyx_PickleError = 0;
22503   PyObject *__pyx_v___pyx_result = 0;
22504   PyObject *__pyx_r = NULL;
22505   __Pyx_RefNannyDeclarations
22506   int __pyx_t_1;
22507   PyObject *__pyx_t_2 = NULL;
22508   PyObject *__pyx_t_3 = NULL;
22509   PyObject *__pyx_t_4 = NULL;
22510   PyObject *__pyx_t_5 = NULL;
22511   int __pyx_t_6;
22512   int __pyx_lineno = 0;
22513   const char *__pyx_filename = NULL;
22514   int __pyx_clineno = 0;
22515   __Pyx_RefNannySetupContext("__pyx_unpickle_Enum", 0);
22516 
22517   /* "(tree fragment)":4
22518  *     cdef object __pyx_PickleError
22519  *     cdef object __pyx_result
22520  *     if __pyx_checksum != 0xb068931:             # <<<<<<<<<<<<<<
22521  *         from pickle import PickleError as __pyx_PickleError
22522  *         raise __pyx_PickleError("Incompatible checksums (%s vs 0xb068931 = (name))" % __pyx_checksum)
22523  */
22524   __pyx_t_1 = ((__pyx_v___pyx_checksum != 0xb068931) != 0);
22525   if (__pyx_t_1) {
22526 
22527     /* "(tree fragment)":5
22528  *     cdef object __pyx_result
22529  *     if __pyx_checksum != 0xb068931:
22530  *         from pickle import PickleError as __pyx_PickleError             # <<<<<<<<<<<<<<
22531  *         raise __pyx_PickleError("Incompatible checksums (%s vs 0xb068931 = (name))" % __pyx_checksum)
22532  *     __pyx_result = Enum.__new__(__pyx_type)
22533  */
22534     __pyx_t_2 = PyList_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 5, __pyx_L1_error)
22535     __Pyx_GOTREF(__pyx_t_2);
22536     __Pyx_INCREF(__pyx_n_s_PickleError);
22537     __Pyx_GIVEREF(__pyx_n_s_PickleError);
22538     PyList_SET_ITEM(__pyx_t_2, 0, __pyx_n_s_PickleError);
22539     __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)
22540     __Pyx_GOTREF(__pyx_t_3);
22541     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
22542     __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_3, __pyx_n_s_PickleError); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 5, __pyx_L1_error)
22543     __Pyx_GOTREF(__pyx_t_2);
22544     __Pyx_INCREF(__pyx_t_2);
22545     __pyx_v___pyx_PickleError = __pyx_t_2;
22546     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
22547     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
22548 
22549     /* "(tree fragment)":6
22550  *     if __pyx_checksum != 0xb068931:
22551  *         from pickle import PickleError as __pyx_PickleError
22552  *         raise __pyx_PickleError("Incompatible checksums (%s vs 0xb068931 = (name))" % __pyx_checksum)             # <<<<<<<<<<<<<<
22553  *     __pyx_result = Enum.__new__(__pyx_type)
22554  *     if __pyx_state is not None:
22555  */
22556     __pyx_t_2 = __Pyx_PyInt_From_long(__pyx_v___pyx_checksum); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 6, __pyx_L1_error)
22557     __Pyx_GOTREF(__pyx_t_2);
22558     __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)
22559     __Pyx_GOTREF(__pyx_t_4);
22560     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
22561     __Pyx_INCREF(__pyx_v___pyx_PickleError);
22562     __pyx_t_2 = __pyx_v___pyx_PickleError; __pyx_t_5 = NULL;
22563     if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) {
22564       __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_2);
22565       if (likely(__pyx_t_5)) {
22566         PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
22567         __Pyx_INCREF(__pyx_t_5);
22568         __Pyx_INCREF(function);
22569         __Pyx_DECREF_SET(__pyx_t_2, function);
22570       }
22571     }
22572     __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);
22573     __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
22574     __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
22575     if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 6, __pyx_L1_error)
22576     __Pyx_GOTREF(__pyx_t_3);
22577     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
22578     __Pyx_Raise(__pyx_t_3, 0, 0, 0);
22579     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
22580     __PYX_ERR(2, 6, __pyx_L1_error)
22581 
22582     /* "(tree fragment)":4
22583  *     cdef object __pyx_PickleError
22584  *     cdef object __pyx_result
22585  *     if __pyx_checksum != 0xb068931:             # <<<<<<<<<<<<<<
22586  *         from pickle import PickleError as __pyx_PickleError
22587  *         raise __pyx_PickleError("Incompatible checksums (%s vs 0xb068931 = (name))" % __pyx_checksum)
22588  */
22589   }
22590 
22591   /* "(tree fragment)":7
22592  *         from pickle import PickleError as __pyx_PickleError
22593  *         raise __pyx_PickleError("Incompatible checksums (%s vs 0xb068931 = (name))" % __pyx_checksum)
22594  *     __pyx_result = Enum.__new__(__pyx_type)             # <<<<<<<<<<<<<<
22595  *     if __pyx_state is not None:
22596  *         __pyx_unpickle_Enum__set_state(<Enum> __pyx_result, __pyx_state)
22597  */
22598   __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)
22599   __Pyx_GOTREF(__pyx_t_2);
22600   __pyx_t_4 = NULL;
22601   if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
22602     __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_2);
22603     if (likely(__pyx_t_4)) {
22604       PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
22605       __Pyx_INCREF(__pyx_t_4);
22606       __Pyx_INCREF(function);
22607       __Pyx_DECREF_SET(__pyx_t_2, function);
22608     }
22609   }
22610   __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);
22611   __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
22612   if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 7, __pyx_L1_error)
22613   __Pyx_GOTREF(__pyx_t_3);
22614   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
22615   __pyx_v___pyx_result = __pyx_t_3;
22616   __pyx_t_3 = 0;
22617 
22618   /* "(tree fragment)":8
22619  *         raise __pyx_PickleError("Incompatible checksums (%s vs 0xb068931 = (name))" % __pyx_checksum)
22620  *     __pyx_result = Enum.__new__(__pyx_type)
22621  *     if __pyx_state is not None:             # <<<<<<<<<<<<<<
22622  *         __pyx_unpickle_Enum__set_state(<Enum> __pyx_result, __pyx_state)
22623  *     return __pyx_result
22624  */
22625   __pyx_t_1 = (__pyx_v___pyx_state != Py_None);
22626   __pyx_t_6 = (__pyx_t_1 != 0);
22627   if (__pyx_t_6) {
22628 
22629     /* "(tree fragment)":9
22630  *     __pyx_result = Enum.__new__(__pyx_type)
22631  *     if __pyx_state is not None:
22632  *         __pyx_unpickle_Enum__set_state(<Enum> __pyx_result, __pyx_state)             # <<<<<<<<<<<<<<
22633  *     return __pyx_result
22634  * cdef __pyx_unpickle_Enum__set_state(Enum __pyx_result, tuple __pyx_state):
22635  */
22636     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)
22637     __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)
22638     __Pyx_GOTREF(__pyx_t_3);
22639     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
22640 
22641     /* "(tree fragment)":8
22642  *         raise __pyx_PickleError("Incompatible checksums (%s vs 0xb068931 = (name))" % __pyx_checksum)
22643  *     __pyx_result = Enum.__new__(__pyx_type)
22644  *     if __pyx_state is not None:             # <<<<<<<<<<<<<<
22645  *         __pyx_unpickle_Enum__set_state(<Enum> __pyx_result, __pyx_state)
22646  *     return __pyx_result
22647  */
22648   }
22649 
22650   /* "(tree fragment)":10
22651  *     if __pyx_state is not None:
22652  *         __pyx_unpickle_Enum__set_state(<Enum> __pyx_result, __pyx_state)
22653  *     return __pyx_result             # <<<<<<<<<<<<<<
22654  * cdef __pyx_unpickle_Enum__set_state(Enum __pyx_result, tuple __pyx_state):
22655  *     __pyx_result.name = __pyx_state[0]
22656  */
22657   __Pyx_XDECREF(__pyx_r);
22658   __Pyx_INCREF(__pyx_v___pyx_result);
22659   __pyx_r = __pyx_v___pyx_result;
22660   goto __pyx_L0;
22661 
22662   /* "(tree fragment)":1
22663  * def __pyx_unpickle_Enum(__pyx_type, long __pyx_checksum, __pyx_state):             # <<<<<<<<<<<<<<
22664  *     cdef object __pyx_PickleError
22665  *     cdef object __pyx_result
22666  */
22667 
22668   /* function exit code */
22669   __pyx_L1_error:;
22670   __Pyx_XDECREF(__pyx_t_2);
22671   __Pyx_XDECREF(__pyx_t_3);
22672   __Pyx_XDECREF(__pyx_t_4);
22673   __Pyx_XDECREF(__pyx_t_5);
22674   __Pyx_AddTraceback("View.MemoryView.__pyx_unpickle_Enum", __pyx_clineno, __pyx_lineno, __pyx_filename);
22675   __pyx_r = NULL;
22676   __pyx_L0:;
22677   __Pyx_XDECREF(__pyx_v___pyx_PickleError);
22678   __Pyx_XDECREF(__pyx_v___pyx_result);
22679   __Pyx_XGIVEREF(__pyx_r);
22680   __Pyx_RefNannyFinishContext();
22681   return __pyx_r;
22682 }
22683 
22684 /* "(tree fragment)":11
22685  *         __pyx_unpickle_Enum__set_state(<Enum> __pyx_result, __pyx_state)
22686  *     return __pyx_result
22687  * cdef __pyx_unpickle_Enum__set_state(Enum __pyx_result, tuple __pyx_state):             # <<<<<<<<<<<<<<
22688  *     __pyx_result.name = __pyx_state[0]
22689  *     if len(__pyx_state) > 1 and hasattr(__pyx_result, '__dict__'):
22690  */
22691 
__pyx_unpickle_Enum__set_state(struct __pyx_MemviewEnum_obj * __pyx_v___pyx_result,PyObject * __pyx_v___pyx_state)22692 static PyObject *__pyx_unpickle_Enum__set_state(struct __pyx_MemviewEnum_obj *__pyx_v___pyx_result, PyObject *__pyx_v___pyx_state) {
22693   PyObject *__pyx_r = NULL;
22694   __Pyx_RefNannyDeclarations
22695   PyObject *__pyx_t_1 = NULL;
22696   int __pyx_t_2;
22697   Py_ssize_t __pyx_t_3;
22698   int __pyx_t_4;
22699   int __pyx_t_5;
22700   PyObject *__pyx_t_6 = NULL;
22701   PyObject *__pyx_t_7 = NULL;
22702   PyObject *__pyx_t_8 = NULL;
22703   int __pyx_lineno = 0;
22704   const char *__pyx_filename = NULL;
22705   int __pyx_clineno = 0;
22706   __Pyx_RefNannySetupContext("__pyx_unpickle_Enum__set_state", 0);
22707 
22708   /* "(tree fragment)":12
22709  *     return __pyx_result
22710  * cdef __pyx_unpickle_Enum__set_state(Enum __pyx_result, tuple __pyx_state):
22711  *     __pyx_result.name = __pyx_state[0]             # <<<<<<<<<<<<<<
22712  *     if len(__pyx_state) > 1 and hasattr(__pyx_result, '__dict__'):
22713  *         __pyx_result.__dict__.update(__pyx_state[1])
22714  */
22715   if (unlikely(__pyx_v___pyx_state == Py_None)) {
22716     PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
22717     __PYX_ERR(2, 12, __pyx_L1_error)
22718   }
22719   __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)
22720   __Pyx_GOTREF(__pyx_t_1);
22721   __Pyx_GIVEREF(__pyx_t_1);
22722   __Pyx_GOTREF(__pyx_v___pyx_result->name);
22723   __Pyx_DECREF(__pyx_v___pyx_result->name);
22724   __pyx_v___pyx_result->name = __pyx_t_1;
22725   __pyx_t_1 = 0;
22726 
22727   /* "(tree fragment)":13
22728  * cdef __pyx_unpickle_Enum__set_state(Enum __pyx_result, tuple __pyx_state):
22729  *     __pyx_result.name = __pyx_state[0]
22730  *     if len(__pyx_state) > 1 and hasattr(__pyx_result, '__dict__'):             # <<<<<<<<<<<<<<
22731  *         __pyx_result.__dict__.update(__pyx_state[1])
22732  */
22733   if (unlikely(__pyx_v___pyx_state == Py_None)) {
22734     PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
22735     __PYX_ERR(2, 13, __pyx_L1_error)
22736   }
22737   __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)
22738   __pyx_t_4 = ((__pyx_t_3 > 1) != 0);
22739   if (__pyx_t_4) {
22740   } else {
22741     __pyx_t_2 = __pyx_t_4;
22742     goto __pyx_L4_bool_binop_done;
22743   }
22744   __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)
22745   __pyx_t_5 = (__pyx_t_4 != 0);
22746   __pyx_t_2 = __pyx_t_5;
22747   __pyx_L4_bool_binop_done:;
22748   if (__pyx_t_2) {
22749 
22750     /* "(tree fragment)":14
22751  *     __pyx_result.name = __pyx_state[0]
22752  *     if len(__pyx_state) > 1 and hasattr(__pyx_result, '__dict__'):
22753  *         __pyx_result.__dict__.update(__pyx_state[1])             # <<<<<<<<<<<<<<
22754  */
22755     __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)
22756     __Pyx_GOTREF(__pyx_t_6);
22757     __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)
22758     __Pyx_GOTREF(__pyx_t_7);
22759     __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
22760     if (unlikely(__pyx_v___pyx_state == Py_None)) {
22761       PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
22762       __PYX_ERR(2, 14, __pyx_L1_error)
22763     }
22764     __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)
22765     __Pyx_GOTREF(__pyx_t_6);
22766     __pyx_t_8 = NULL;
22767     if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_7))) {
22768       __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_7);
22769       if (likely(__pyx_t_8)) {
22770         PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7);
22771         __Pyx_INCREF(__pyx_t_8);
22772         __Pyx_INCREF(function);
22773         __Pyx_DECREF_SET(__pyx_t_7, function);
22774       }
22775     }
22776     __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);
22777     __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
22778     __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
22779     if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 14, __pyx_L1_error)
22780     __Pyx_GOTREF(__pyx_t_1);
22781     __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
22782     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
22783 
22784     /* "(tree fragment)":13
22785  * cdef __pyx_unpickle_Enum__set_state(Enum __pyx_result, tuple __pyx_state):
22786  *     __pyx_result.name = __pyx_state[0]
22787  *     if len(__pyx_state) > 1 and hasattr(__pyx_result, '__dict__'):             # <<<<<<<<<<<<<<
22788  *         __pyx_result.__dict__.update(__pyx_state[1])
22789  */
22790   }
22791 
22792   /* "(tree fragment)":11
22793  *         __pyx_unpickle_Enum__set_state(<Enum> __pyx_result, __pyx_state)
22794  *     return __pyx_result
22795  * cdef __pyx_unpickle_Enum__set_state(Enum __pyx_result, tuple __pyx_state):             # <<<<<<<<<<<<<<
22796  *     __pyx_result.name = __pyx_state[0]
22797  *     if len(__pyx_state) > 1 and hasattr(__pyx_result, '__dict__'):
22798  */
22799 
22800   /* function exit code */
22801   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
22802   goto __pyx_L0;
22803   __pyx_L1_error:;
22804   __Pyx_XDECREF(__pyx_t_1);
22805   __Pyx_XDECREF(__pyx_t_6);
22806   __Pyx_XDECREF(__pyx_t_7);
22807   __Pyx_XDECREF(__pyx_t_8);
22808   __Pyx_AddTraceback("View.MemoryView.__pyx_unpickle_Enum__set_state", __pyx_clineno, __pyx_lineno, __pyx_filename);
22809   __pyx_r = 0;
22810   __pyx_L0:;
22811   __Pyx_XGIVEREF(__pyx_r);
22812   __Pyx_RefNannyFinishContext();
22813   return __pyx_r;
22814 }
22815 static struct __pyx_vtabstruct_array __pyx_vtable_array;
22816 
__pyx_tp_new_array(PyTypeObject * t,PyObject * a,PyObject * k)22817 static PyObject *__pyx_tp_new_array(PyTypeObject *t, PyObject *a, PyObject *k) {
22818   struct __pyx_array_obj *p;
22819   PyObject *o;
22820   if (likely((t->tp_flags & Py_TPFLAGS_IS_ABSTRACT) == 0)) {
22821     o = (*t->tp_alloc)(t, 0);
22822   } else {
22823     o = (PyObject *) PyBaseObject_Type.tp_new(t, __pyx_empty_tuple, 0);
22824   }
22825   if (unlikely(!o)) return 0;
22826   p = ((struct __pyx_array_obj *)o);
22827   p->__pyx_vtab = __pyx_vtabptr_array;
22828   p->mode = ((PyObject*)Py_None); Py_INCREF(Py_None);
22829   p->_format = ((PyObject*)Py_None); Py_INCREF(Py_None);
22830   if (unlikely(__pyx_array___cinit__(o, a, k) < 0)) goto bad;
22831   return o;
22832   bad:
22833   Py_DECREF(o); o = 0;
22834   return NULL;
22835 }
22836 
__pyx_tp_dealloc_array(PyObject * o)22837 static void __pyx_tp_dealloc_array(PyObject *o) {
22838   struct __pyx_array_obj *p = (struct __pyx_array_obj *)o;
22839   #if CYTHON_USE_TP_FINALIZE
22840   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))) {
22841     if (PyObject_CallFinalizerFromDealloc(o)) return;
22842   }
22843   #endif
22844   {
22845     PyObject *etype, *eval, *etb;
22846     PyErr_Fetch(&etype, &eval, &etb);
22847     __Pyx_SET_REFCNT(o, Py_REFCNT(o) + 1);
22848     __pyx_array___dealloc__(o);
22849     __Pyx_SET_REFCNT(o, Py_REFCNT(o) - 1);
22850     PyErr_Restore(etype, eval, etb);
22851   }
22852   Py_CLEAR(p->mode);
22853   Py_CLEAR(p->_format);
22854   (*Py_TYPE(o)->tp_free)(o);
22855 }
__pyx_sq_item_array(PyObject * o,Py_ssize_t i)22856 static PyObject *__pyx_sq_item_array(PyObject *o, Py_ssize_t i) {
22857   PyObject *r;
22858   PyObject *x = PyInt_FromSsize_t(i); if(!x) return 0;
22859   r = Py_TYPE(o)->tp_as_mapping->mp_subscript(o, x);
22860   Py_DECREF(x);
22861   return r;
22862 }
22863 
__pyx_mp_ass_subscript_array(PyObject * o,PyObject * i,PyObject * v)22864 static int __pyx_mp_ass_subscript_array(PyObject *o, PyObject *i, PyObject *v) {
22865   if (v) {
22866     return __pyx_array___setitem__(o, i, v);
22867   }
22868   else {
22869     PyErr_Format(PyExc_NotImplementedError,
22870       "Subscript deletion not supported by %.200s", Py_TYPE(o)->tp_name);
22871     return -1;
22872   }
22873 }
22874 
__pyx_tp_getattro_array(PyObject * o,PyObject * n)22875 static PyObject *__pyx_tp_getattro_array(PyObject *o, PyObject *n) {
22876   PyObject *v = __Pyx_PyObject_GenericGetAttr(o, n);
22877   if (!v && PyErr_ExceptionMatches(PyExc_AttributeError)) {
22878     PyErr_Clear();
22879     v = __pyx_array___getattr__(o, n);
22880   }
22881   return v;
22882 }
22883 
__pyx_getprop___pyx_array_memview(PyObject * o,CYTHON_UNUSED void * x)22884 static PyObject *__pyx_getprop___pyx_array_memview(PyObject *o, CYTHON_UNUSED void *x) {
22885   return __pyx_pw_15View_dot_MemoryView_5array_7memview_1__get__(o);
22886 }
22887 
22888 static PyMethodDef __pyx_methods_array[] = {
22889   {"__getattr__", (PyCFunction)__pyx_array___getattr__, METH_O|METH_COEXIST, 0},
22890   {"__reduce_cython__", (PyCFunction)__pyx_pw___pyx_array_1__reduce_cython__, METH_NOARGS, 0},
22891   {"__setstate_cython__", (PyCFunction)__pyx_pw___pyx_array_3__setstate_cython__, METH_O, 0},
22892   {0, 0, 0, 0}
22893 };
22894 
22895 static struct PyGetSetDef __pyx_getsets_array[] = {
22896   {(char *)"memview", __pyx_getprop___pyx_array_memview, 0, (char *)0, 0},
22897   {0, 0, 0, 0, 0}
22898 };
22899 
22900 static PySequenceMethods __pyx_tp_as_sequence_array = {
22901   __pyx_array___len__, /*sq_length*/
22902   0, /*sq_concat*/
22903   0, /*sq_repeat*/
22904   __pyx_sq_item_array, /*sq_item*/
22905   0, /*sq_slice*/
22906   0, /*sq_ass_item*/
22907   0, /*sq_ass_slice*/
22908   0, /*sq_contains*/
22909   0, /*sq_inplace_concat*/
22910   0, /*sq_inplace_repeat*/
22911 };
22912 
22913 static PyMappingMethods __pyx_tp_as_mapping_array = {
22914   __pyx_array___len__, /*mp_length*/
22915   __pyx_array___getitem__, /*mp_subscript*/
22916   __pyx_mp_ass_subscript_array, /*mp_ass_subscript*/
22917 };
22918 
22919 static PyBufferProcs __pyx_tp_as_buffer_array = {
22920   #if PY_MAJOR_VERSION < 3
22921   0, /*bf_getreadbuffer*/
22922   #endif
22923   #if PY_MAJOR_VERSION < 3
22924   0, /*bf_getwritebuffer*/
22925   #endif
22926   #if PY_MAJOR_VERSION < 3
22927   0, /*bf_getsegcount*/
22928   #endif
22929   #if PY_MAJOR_VERSION < 3
22930   0, /*bf_getcharbuffer*/
22931   #endif
22932   __pyx_array_getbuffer, /*bf_getbuffer*/
22933   0, /*bf_releasebuffer*/
22934 };
22935 
22936 static PyTypeObject __pyx_type___pyx_array = {
22937   PyVarObject_HEAD_INIT(0, 0)
22938   "qutip.cy.spmatfuncs.array", /*tp_name*/
22939   sizeof(struct __pyx_array_obj), /*tp_basicsize*/
22940   0, /*tp_itemsize*/
22941   __pyx_tp_dealloc_array, /*tp_dealloc*/
22942   #if PY_VERSION_HEX < 0x030800b4
22943   0, /*tp_print*/
22944   #endif
22945   #if PY_VERSION_HEX >= 0x030800b4
22946   0, /*tp_vectorcall_offset*/
22947   #endif
22948   0, /*tp_getattr*/
22949   0, /*tp_setattr*/
22950   #if PY_MAJOR_VERSION < 3
22951   0, /*tp_compare*/
22952   #endif
22953   #if PY_MAJOR_VERSION >= 3
22954   0, /*tp_as_async*/
22955   #endif
22956   0, /*tp_repr*/
22957   0, /*tp_as_number*/
22958   &__pyx_tp_as_sequence_array, /*tp_as_sequence*/
22959   &__pyx_tp_as_mapping_array, /*tp_as_mapping*/
22960   0, /*tp_hash*/
22961   0, /*tp_call*/
22962   0, /*tp_str*/
22963   __pyx_tp_getattro_array, /*tp_getattro*/
22964   0, /*tp_setattro*/
22965   &__pyx_tp_as_buffer_array, /*tp_as_buffer*/
22966   Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE, /*tp_flags*/
22967   0, /*tp_doc*/
22968   0, /*tp_traverse*/
22969   0, /*tp_clear*/
22970   0, /*tp_richcompare*/
22971   0, /*tp_weaklistoffset*/
22972   0, /*tp_iter*/
22973   0, /*tp_iternext*/
22974   __pyx_methods_array, /*tp_methods*/
22975   0, /*tp_members*/
22976   __pyx_getsets_array, /*tp_getset*/
22977   0, /*tp_base*/
22978   0, /*tp_dict*/
22979   0, /*tp_descr_get*/
22980   0, /*tp_descr_set*/
22981   0, /*tp_dictoffset*/
22982   0, /*tp_init*/
22983   0, /*tp_alloc*/
22984   __pyx_tp_new_array, /*tp_new*/
22985   0, /*tp_free*/
22986   0, /*tp_is_gc*/
22987   0, /*tp_bases*/
22988   0, /*tp_mro*/
22989   0, /*tp_cache*/
22990   0, /*tp_subclasses*/
22991   0, /*tp_weaklist*/
22992   0, /*tp_del*/
22993   0, /*tp_version_tag*/
22994   #if PY_VERSION_HEX >= 0x030400a1
22995   0, /*tp_finalize*/
22996   #endif
22997   #if PY_VERSION_HEX >= 0x030800b1
22998   0, /*tp_vectorcall*/
22999   #endif
23000   #if PY_VERSION_HEX >= 0x030800b4 && PY_VERSION_HEX < 0x03090000
23001   0, /*tp_print*/
23002   #endif
23003 };
23004 
__pyx_tp_new_Enum(PyTypeObject * t,CYTHON_UNUSED PyObject * a,CYTHON_UNUSED PyObject * k)23005 static PyObject *__pyx_tp_new_Enum(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
23006   struct __pyx_MemviewEnum_obj *p;
23007   PyObject *o;
23008   if (likely((t->tp_flags & Py_TPFLAGS_IS_ABSTRACT) == 0)) {
23009     o = (*t->tp_alloc)(t, 0);
23010   } else {
23011     o = (PyObject *) PyBaseObject_Type.tp_new(t, __pyx_empty_tuple, 0);
23012   }
23013   if (unlikely(!o)) return 0;
23014   p = ((struct __pyx_MemviewEnum_obj *)o);
23015   p->name = Py_None; Py_INCREF(Py_None);
23016   return o;
23017 }
23018 
__pyx_tp_dealloc_Enum(PyObject * o)23019 static void __pyx_tp_dealloc_Enum(PyObject *o) {
23020   struct __pyx_MemviewEnum_obj *p = (struct __pyx_MemviewEnum_obj *)o;
23021   #if CYTHON_USE_TP_FINALIZE
23022   if (unlikely(PyType_HasFeature(Py_TYPE(o), Py_TPFLAGS_HAVE_FINALIZE) && Py_TYPE(o)->tp_finalize) && !_PyGC_FINALIZED(o)) {
23023     if (PyObject_CallFinalizerFromDealloc(o)) return;
23024   }
23025   #endif
23026   PyObject_GC_UnTrack(o);
23027   Py_CLEAR(p->name);
23028   (*Py_TYPE(o)->tp_free)(o);
23029 }
23030 
__pyx_tp_traverse_Enum(PyObject * o,visitproc v,void * a)23031 static int __pyx_tp_traverse_Enum(PyObject *o, visitproc v, void *a) {
23032   int e;
23033   struct __pyx_MemviewEnum_obj *p = (struct __pyx_MemviewEnum_obj *)o;
23034   if (p->name) {
23035     e = (*v)(p->name, a); if (e) return e;
23036   }
23037   return 0;
23038 }
23039 
__pyx_tp_clear_Enum(PyObject * o)23040 static int __pyx_tp_clear_Enum(PyObject *o) {
23041   PyObject* tmp;
23042   struct __pyx_MemviewEnum_obj *p = (struct __pyx_MemviewEnum_obj *)o;
23043   tmp = ((PyObject*)p->name);
23044   p->name = Py_None; Py_INCREF(Py_None);
23045   Py_XDECREF(tmp);
23046   return 0;
23047 }
23048 
23049 static PyMethodDef __pyx_methods_Enum[] = {
23050   {"__reduce_cython__", (PyCFunction)__pyx_pw___pyx_MemviewEnum_1__reduce_cython__, METH_NOARGS, 0},
23051   {"__setstate_cython__", (PyCFunction)__pyx_pw___pyx_MemviewEnum_3__setstate_cython__, METH_O, 0},
23052   {0, 0, 0, 0}
23053 };
23054 
23055 static PyTypeObject __pyx_type___pyx_MemviewEnum = {
23056   PyVarObject_HEAD_INIT(0, 0)
23057   "qutip.cy.spmatfuncs.Enum", /*tp_name*/
23058   sizeof(struct __pyx_MemviewEnum_obj), /*tp_basicsize*/
23059   0, /*tp_itemsize*/
23060   __pyx_tp_dealloc_Enum, /*tp_dealloc*/
23061   #if PY_VERSION_HEX < 0x030800b4
23062   0, /*tp_print*/
23063   #endif
23064   #if PY_VERSION_HEX >= 0x030800b4
23065   0, /*tp_vectorcall_offset*/
23066   #endif
23067   0, /*tp_getattr*/
23068   0, /*tp_setattr*/
23069   #if PY_MAJOR_VERSION < 3
23070   0, /*tp_compare*/
23071   #endif
23072   #if PY_MAJOR_VERSION >= 3
23073   0, /*tp_as_async*/
23074   #endif
23075   __pyx_MemviewEnum___repr__, /*tp_repr*/
23076   0, /*tp_as_number*/
23077   0, /*tp_as_sequence*/
23078   0, /*tp_as_mapping*/
23079   0, /*tp_hash*/
23080   0, /*tp_call*/
23081   0, /*tp_str*/
23082   0, /*tp_getattro*/
23083   0, /*tp_setattro*/
23084   0, /*tp_as_buffer*/
23085   Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
23086   0, /*tp_doc*/
23087   __pyx_tp_traverse_Enum, /*tp_traverse*/
23088   __pyx_tp_clear_Enum, /*tp_clear*/
23089   0, /*tp_richcompare*/
23090   0, /*tp_weaklistoffset*/
23091   0, /*tp_iter*/
23092   0, /*tp_iternext*/
23093   __pyx_methods_Enum, /*tp_methods*/
23094   0, /*tp_members*/
23095   0, /*tp_getset*/
23096   0, /*tp_base*/
23097   0, /*tp_dict*/
23098   0, /*tp_descr_get*/
23099   0, /*tp_descr_set*/
23100   0, /*tp_dictoffset*/
23101   __pyx_MemviewEnum___init__, /*tp_init*/
23102   0, /*tp_alloc*/
23103   __pyx_tp_new_Enum, /*tp_new*/
23104   0, /*tp_free*/
23105   0, /*tp_is_gc*/
23106   0, /*tp_bases*/
23107   0, /*tp_mro*/
23108   0, /*tp_cache*/
23109   0, /*tp_subclasses*/
23110   0, /*tp_weaklist*/
23111   0, /*tp_del*/
23112   0, /*tp_version_tag*/
23113   #if PY_VERSION_HEX >= 0x030400a1
23114   0, /*tp_finalize*/
23115   #endif
23116   #if PY_VERSION_HEX >= 0x030800b1
23117   0, /*tp_vectorcall*/
23118   #endif
23119   #if PY_VERSION_HEX >= 0x030800b4 && PY_VERSION_HEX < 0x03090000
23120   0, /*tp_print*/
23121   #endif
23122 };
23123 static struct __pyx_vtabstruct_memoryview __pyx_vtable_memoryview;
23124 
__pyx_tp_new_memoryview(PyTypeObject * t,PyObject * a,PyObject * k)23125 static PyObject *__pyx_tp_new_memoryview(PyTypeObject *t, PyObject *a, PyObject *k) {
23126   struct __pyx_memoryview_obj *p;
23127   PyObject *o;
23128   if (likely((t->tp_flags & Py_TPFLAGS_IS_ABSTRACT) == 0)) {
23129     o = (*t->tp_alloc)(t, 0);
23130   } else {
23131     o = (PyObject *) PyBaseObject_Type.tp_new(t, __pyx_empty_tuple, 0);
23132   }
23133   if (unlikely(!o)) return 0;
23134   p = ((struct __pyx_memoryview_obj *)o);
23135   p->__pyx_vtab = __pyx_vtabptr_memoryview;
23136   p->obj = Py_None; Py_INCREF(Py_None);
23137   p->_size = Py_None; Py_INCREF(Py_None);
23138   p->_array_interface = Py_None; Py_INCREF(Py_None);
23139   p->view.obj = NULL;
23140   if (unlikely(__pyx_memoryview___cinit__(o, a, k) < 0)) goto bad;
23141   return o;
23142   bad:
23143   Py_DECREF(o); o = 0;
23144   return NULL;
23145 }
23146 
__pyx_tp_dealloc_memoryview(PyObject * o)23147 static void __pyx_tp_dealloc_memoryview(PyObject *o) {
23148   struct __pyx_memoryview_obj *p = (struct __pyx_memoryview_obj *)o;
23149   #if CYTHON_USE_TP_FINALIZE
23150   if (unlikely(PyType_HasFeature(Py_TYPE(o), Py_TPFLAGS_HAVE_FINALIZE) && Py_TYPE(o)->tp_finalize) && !_PyGC_FINALIZED(o)) {
23151     if (PyObject_CallFinalizerFromDealloc(o)) return;
23152   }
23153   #endif
23154   PyObject_GC_UnTrack(o);
23155   {
23156     PyObject *etype, *eval, *etb;
23157     PyErr_Fetch(&etype, &eval, &etb);
23158     __Pyx_SET_REFCNT(o, Py_REFCNT(o) + 1);
23159     __pyx_memoryview___dealloc__(o);
23160     __Pyx_SET_REFCNT(o, Py_REFCNT(o) - 1);
23161     PyErr_Restore(etype, eval, etb);
23162   }
23163   Py_CLEAR(p->obj);
23164   Py_CLEAR(p->_size);
23165   Py_CLEAR(p->_array_interface);
23166   (*Py_TYPE(o)->tp_free)(o);
23167 }
23168 
__pyx_tp_traverse_memoryview(PyObject * o,visitproc v,void * a)23169 static int __pyx_tp_traverse_memoryview(PyObject *o, visitproc v, void *a) {
23170   int e;
23171   struct __pyx_memoryview_obj *p = (struct __pyx_memoryview_obj *)o;
23172   if (p->obj) {
23173     e = (*v)(p->obj, a); if (e) return e;
23174   }
23175   if (p->_size) {
23176     e = (*v)(p->_size, a); if (e) return e;
23177   }
23178   if (p->_array_interface) {
23179     e = (*v)(p->_array_interface, a); if (e) return e;
23180   }
23181   if (p->view.obj) {
23182     e = (*v)(p->view.obj, a); if (e) return e;
23183   }
23184   return 0;
23185 }
23186 
__pyx_tp_clear_memoryview(PyObject * o)23187 static int __pyx_tp_clear_memoryview(PyObject *o) {
23188   PyObject* tmp;
23189   struct __pyx_memoryview_obj *p = (struct __pyx_memoryview_obj *)o;
23190   tmp = ((PyObject*)p->obj);
23191   p->obj = Py_None; Py_INCREF(Py_None);
23192   Py_XDECREF(tmp);
23193   tmp = ((PyObject*)p->_size);
23194   p->_size = Py_None; Py_INCREF(Py_None);
23195   Py_XDECREF(tmp);
23196   tmp = ((PyObject*)p->_array_interface);
23197   p->_array_interface = Py_None; Py_INCREF(Py_None);
23198   Py_XDECREF(tmp);
23199   Py_CLEAR(p->view.obj);
23200   return 0;
23201 }
__pyx_sq_item_memoryview(PyObject * o,Py_ssize_t i)23202 static PyObject *__pyx_sq_item_memoryview(PyObject *o, Py_ssize_t i) {
23203   PyObject *r;
23204   PyObject *x = PyInt_FromSsize_t(i); if(!x) return 0;
23205   r = Py_TYPE(o)->tp_as_mapping->mp_subscript(o, x);
23206   Py_DECREF(x);
23207   return r;
23208 }
23209 
__pyx_mp_ass_subscript_memoryview(PyObject * o,PyObject * i,PyObject * v)23210 static int __pyx_mp_ass_subscript_memoryview(PyObject *o, PyObject *i, PyObject *v) {
23211   if (v) {
23212     return __pyx_memoryview___setitem__(o, i, v);
23213   }
23214   else {
23215     PyErr_Format(PyExc_NotImplementedError,
23216       "Subscript deletion not supported by %.200s", Py_TYPE(o)->tp_name);
23217     return -1;
23218   }
23219 }
23220 
__pyx_getprop___pyx_memoryview_T(PyObject * o,CYTHON_UNUSED void * x)23221 static PyObject *__pyx_getprop___pyx_memoryview_T(PyObject *o, CYTHON_UNUSED void *x) {
23222   return __pyx_pw_15View_dot_MemoryView_10memoryview_1T_1__get__(o);
23223 }
23224 
__pyx_getprop___pyx_memoryview_base(PyObject * o,CYTHON_UNUSED void * x)23225 static PyObject *__pyx_getprop___pyx_memoryview_base(PyObject *o, CYTHON_UNUSED void *x) {
23226   return __pyx_pw_15View_dot_MemoryView_10memoryview_4base_1__get__(o);
23227 }
23228 
__pyx_getprop___pyx_memoryview_shape(PyObject * o,CYTHON_UNUSED void * x)23229 static PyObject *__pyx_getprop___pyx_memoryview_shape(PyObject *o, CYTHON_UNUSED void *x) {
23230   return __pyx_pw_15View_dot_MemoryView_10memoryview_5shape_1__get__(o);
23231 }
23232 
__pyx_getprop___pyx_memoryview_strides(PyObject * o,CYTHON_UNUSED void * x)23233 static PyObject *__pyx_getprop___pyx_memoryview_strides(PyObject *o, CYTHON_UNUSED void *x) {
23234   return __pyx_pw_15View_dot_MemoryView_10memoryview_7strides_1__get__(o);
23235 }
23236 
__pyx_getprop___pyx_memoryview_suboffsets(PyObject * o,CYTHON_UNUSED void * x)23237 static PyObject *__pyx_getprop___pyx_memoryview_suboffsets(PyObject *o, CYTHON_UNUSED void *x) {
23238   return __pyx_pw_15View_dot_MemoryView_10memoryview_10suboffsets_1__get__(o);
23239 }
23240 
__pyx_getprop___pyx_memoryview_ndim(PyObject * o,CYTHON_UNUSED void * x)23241 static PyObject *__pyx_getprop___pyx_memoryview_ndim(PyObject *o, CYTHON_UNUSED void *x) {
23242   return __pyx_pw_15View_dot_MemoryView_10memoryview_4ndim_1__get__(o);
23243 }
23244 
__pyx_getprop___pyx_memoryview_itemsize(PyObject * o,CYTHON_UNUSED void * x)23245 static PyObject *__pyx_getprop___pyx_memoryview_itemsize(PyObject *o, CYTHON_UNUSED void *x) {
23246   return __pyx_pw_15View_dot_MemoryView_10memoryview_8itemsize_1__get__(o);
23247 }
23248 
__pyx_getprop___pyx_memoryview_nbytes(PyObject * o,CYTHON_UNUSED void * x)23249 static PyObject *__pyx_getprop___pyx_memoryview_nbytes(PyObject *o, CYTHON_UNUSED void *x) {
23250   return __pyx_pw_15View_dot_MemoryView_10memoryview_6nbytes_1__get__(o);
23251 }
23252 
__pyx_getprop___pyx_memoryview_size(PyObject * o,CYTHON_UNUSED void * x)23253 static PyObject *__pyx_getprop___pyx_memoryview_size(PyObject *o, CYTHON_UNUSED void *x) {
23254   return __pyx_pw_15View_dot_MemoryView_10memoryview_4size_1__get__(o);
23255 }
23256 
23257 static PyMethodDef __pyx_methods_memoryview[] = {
23258   {"is_c_contig", (PyCFunction)__pyx_memoryview_is_c_contig, METH_NOARGS, 0},
23259   {"is_f_contig", (PyCFunction)__pyx_memoryview_is_f_contig, METH_NOARGS, 0},
23260   {"copy", (PyCFunction)__pyx_memoryview_copy, METH_NOARGS, 0},
23261   {"copy_fortran", (PyCFunction)__pyx_memoryview_copy_fortran, METH_NOARGS, 0},
23262   {"__reduce_cython__", (PyCFunction)__pyx_pw___pyx_memoryview_1__reduce_cython__, METH_NOARGS, 0},
23263   {"__setstate_cython__", (PyCFunction)__pyx_pw___pyx_memoryview_3__setstate_cython__, METH_O, 0},
23264   {0, 0, 0, 0}
23265 };
23266 
23267 static struct PyGetSetDef __pyx_getsets_memoryview[] = {
23268   {(char *)"T", __pyx_getprop___pyx_memoryview_T, 0, (char *)0, 0},
23269   {(char *)"base", __pyx_getprop___pyx_memoryview_base, 0, (char *)0, 0},
23270   {(char *)"shape", __pyx_getprop___pyx_memoryview_shape, 0, (char *)0, 0},
23271   {(char *)"strides", __pyx_getprop___pyx_memoryview_strides, 0, (char *)0, 0},
23272   {(char *)"suboffsets", __pyx_getprop___pyx_memoryview_suboffsets, 0, (char *)0, 0},
23273   {(char *)"ndim", __pyx_getprop___pyx_memoryview_ndim, 0, (char *)0, 0},
23274   {(char *)"itemsize", __pyx_getprop___pyx_memoryview_itemsize, 0, (char *)0, 0},
23275   {(char *)"nbytes", __pyx_getprop___pyx_memoryview_nbytes, 0, (char *)0, 0},
23276   {(char *)"size", __pyx_getprop___pyx_memoryview_size, 0, (char *)0, 0},
23277   {0, 0, 0, 0, 0}
23278 };
23279 
23280 static PySequenceMethods __pyx_tp_as_sequence_memoryview = {
23281   __pyx_memoryview___len__, /*sq_length*/
23282   0, /*sq_concat*/
23283   0, /*sq_repeat*/
23284   __pyx_sq_item_memoryview, /*sq_item*/
23285   0, /*sq_slice*/
23286   0, /*sq_ass_item*/
23287   0, /*sq_ass_slice*/
23288   0, /*sq_contains*/
23289   0, /*sq_inplace_concat*/
23290   0, /*sq_inplace_repeat*/
23291 };
23292 
23293 static PyMappingMethods __pyx_tp_as_mapping_memoryview = {
23294   __pyx_memoryview___len__, /*mp_length*/
23295   __pyx_memoryview___getitem__, /*mp_subscript*/
23296   __pyx_mp_ass_subscript_memoryview, /*mp_ass_subscript*/
23297 };
23298 
23299 static PyBufferProcs __pyx_tp_as_buffer_memoryview = {
23300   #if PY_MAJOR_VERSION < 3
23301   0, /*bf_getreadbuffer*/
23302   #endif
23303   #if PY_MAJOR_VERSION < 3
23304   0, /*bf_getwritebuffer*/
23305   #endif
23306   #if PY_MAJOR_VERSION < 3
23307   0, /*bf_getsegcount*/
23308   #endif
23309   #if PY_MAJOR_VERSION < 3
23310   0, /*bf_getcharbuffer*/
23311   #endif
23312   __pyx_memoryview_getbuffer, /*bf_getbuffer*/
23313   0, /*bf_releasebuffer*/
23314 };
23315 
23316 static PyTypeObject __pyx_type___pyx_memoryview = {
23317   PyVarObject_HEAD_INIT(0, 0)
23318   "qutip.cy.spmatfuncs.memoryview", /*tp_name*/
23319   sizeof(struct __pyx_memoryview_obj), /*tp_basicsize*/
23320   0, /*tp_itemsize*/
23321   __pyx_tp_dealloc_memoryview, /*tp_dealloc*/
23322   #if PY_VERSION_HEX < 0x030800b4
23323   0, /*tp_print*/
23324   #endif
23325   #if PY_VERSION_HEX >= 0x030800b4
23326   0, /*tp_vectorcall_offset*/
23327   #endif
23328   0, /*tp_getattr*/
23329   0, /*tp_setattr*/
23330   #if PY_MAJOR_VERSION < 3
23331   0, /*tp_compare*/
23332   #endif
23333   #if PY_MAJOR_VERSION >= 3
23334   0, /*tp_as_async*/
23335   #endif
23336   __pyx_memoryview___repr__, /*tp_repr*/
23337   0, /*tp_as_number*/
23338   &__pyx_tp_as_sequence_memoryview, /*tp_as_sequence*/
23339   &__pyx_tp_as_mapping_memoryview, /*tp_as_mapping*/
23340   0, /*tp_hash*/
23341   0, /*tp_call*/
23342   __pyx_memoryview___str__, /*tp_str*/
23343   0, /*tp_getattro*/
23344   0, /*tp_setattro*/
23345   &__pyx_tp_as_buffer_memoryview, /*tp_as_buffer*/
23346   Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
23347   0, /*tp_doc*/
23348   __pyx_tp_traverse_memoryview, /*tp_traverse*/
23349   __pyx_tp_clear_memoryview, /*tp_clear*/
23350   0, /*tp_richcompare*/
23351   0, /*tp_weaklistoffset*/
23352   0, /*tp_iter*/
23353   0, /*tp_iternext*/
23354   __pyx_methods_memoryview, /*tp_methods*/
23355   0, /*tp_members*/
23356   __pyx_getsets_memoryview, /*tp_getset*/
23357   0, /*tp_base*/
23358   0, /*tp_dict*/
23359   0, /*tp_descr_get*/
23360   0, /*tp_descr_set*/
23361   0, /*tp_dictoffset*/
23362   0, /*tp_init*/
23363   0, /*tp_alloc*/
23364   __pyx_tp_new_memoryview, /*tp_new*/
23365   0, /*tp_free*/
23366   0, /*tp_is_gc*/
23367   0, /*tp_bases*/
23368   0, /*tp_mro*/
23369   0, /*tp_cache*/
23370   0, /*tp_subclasses*/
23371   0, /*tp_weaklist*/
23372   0, /*tp_del*/
23373   0, /*tp_version_tag*/
23374   #if PY_VERSION_HEX >= 0x030400a1
23375   0, /*tp_finalize*/
23376   #endif
23377   #if PY_VERSION_HEX >= 0x030800b1
23378   0, /*tp_vectorcall*/
23379   #endif
23380   #if PY_VERSION_HEX >= 0x030800b4 && PY_VERSION_HEX < 0x03090000
23381   0, /*tp_print*/
23382   #endif
23383 };
23384 static struct __pyx_vtabstruct__memoryviewslice __pyx_vtable__memoryviewslice;
23385 
__pyx_tp_new__memoryviewslice(PyTypeObject * t,PyObject * a,PyObject * k)23386 static PyObject *__pyx_tp_new__memoryviewslice(PyTypeObject *t, PyObject *a, PyObject *k) {
23387   struct __pyx_memoryviewslice_obj *p;
23388   PyObject *o = __pyx_tp_new_memoryview(t, a, k);
23389   if (unlikely(!o)) return 0;
23390   p = ((struct __pyx_memoryviewslice_obj *)o);
23391   p->__pyx_base.__pyx_vtab = (struct __pyx_vtabstruct_memoryview*)__pyx_vtabptr__memoryviewslice;
23392   p->from_object = Py_None; Py_INCREF(Py_None);
23393   p->from_slice.memview = NULL;
23394   return o;
23395 }
23396 
__pyx_tp_dealloc__memoryviewslice(PyObject * o)23397 static void __pyx_tp_dealloc__memoryviewslice(PyObject *o) {
23398   struct __pyx_memoryviewslice_obj *p = (struct __pyx_memoryviewslice_obj *)o;
23399   #if CYTHON_USE_TP_FINALIZE
23400   if (unlikely(PyType_HasFeature(Py_TYPE(o), Py_TPFLAGS_HAVE_FINALIZE) && Py_TYPE(o)->tp_finalize) && !_PyGC_FINALIZED(o)) {
23401     if (PyObject_CallFinalizerFromDealloc(o)) return;
23402   }
23403   #endif
23404   PyObject_GC_UnTrack(o);
23405   {
23406     PyObject *etype, *eval, *etb;
23407     PyErr_Fetch(&etype, &eval, &etb);
23408     __Pyx_SET_REFCNT(o, Py_REFCNT(o) + 1);
23409     __pyx_memoryviewslice___dealloc__(o);
23410     __Pyx_SET_REFCNT(o, Py_REFCNT(o) - 1);
23411     PyErr_Restore(etype, eval, etb);
23412   }
23413   Py_CLEAR(p->from_object);
23414   PyObject_GC_Track(o);
23415   __pyx_tp_dealloc_memoryview(o);
23416 }
23417 
__pyx_tp_traverse__memoryviewslice(PyObject * o,visitproc v,void * a)23418 static int __pyx_tp_traverse__memoryviewslice(PyObject *o, visitproc v, void *a) {
23419   int e;
23420   struct __pyx_memoryviewslice_obj *p = (struct __pyx_memoryviewslice_obj *)o;
23421   e = __pyx_tp_traverse_memoryview(o, v, a); if (e) return e;
23422   if (p->from_object) {
23423     e = (*v)(p->from_object, a); if (e) return e;
23424   }
23425   return 0;
23426 }
23427 
__pyx_tp_clear__memoryviewslice(PyObject * o)23428 static int __pyx_tp_clear__memoryviewslice(PyObject *o) {
23429   PyObject* tmp;
23430   struct __pyx_memoryviewslice_obj *p = (struct __pyx_memoryviewslice_obj *)o;
23431   __pyx_tp_clear_memoryview(o);
23432   tmp = ((PyObject*)p->from_object);
23433   p->from_object = Py_None; Py_INCREF(Py_None);
23434   Py_XDECREF(tmp);
23435   __PYX_XDEC_MEMVIEW(&p->from_slice, 1);
23436   return 0;
23437 }
23438 
__pyx_getprop___pyx_memoryviewslice_base(PyObject * o,CYTHON_UNUSED void * x)23439 static PyObject *__pyx_getprop___pyx_memoryviewslice_base(PyObject *o, CYTHON_UNUSED void *x) {
23440   return __pyx_pw_15View_dot_MemoryView_16_memoryviewslice_4base_1__get__(o);
23441 }
23442 
23443 static PyMethodDef __pyx_methods__memoryviewslice[] = {
23444   {"__reduce_cython__", (PyCFunction)__pyx_pw___pyx_memoryviewslice_1__reduce_cython__, METH_NOARGS, 0},
23445   {"__setstate_cython__", (PyCFunction)__pyx_pw___pyx_memoryviewslice_3__setstate_cython__, METH_O, 0},
23446   {0, 0, 0, 0}
23447 };
23448 
23449 static struct PyGetSetDef __pyx_getsets__memoryviewslice[] = {
23450   {(char *)"base", __pyx_getprop___pyx_memoryviewslice_base, 0, (char *)0, 0},
23451   {0, 0, 0, 0, 0}
23452 };
23453 
23454 static PyTypeObject __pyx_type___pyx_memoryviewslice = {
23455   PyVarObject_HEAD_INIT(0, 0)
23456   "qutip.cy.spmatfuncs._memoryviewslice", /*tp_name*/
23457   sizeof(struct __pyx_memoryviewslice_obj), /*tp_basicsize*/
23458   0, /*tp_itemsize*/
23459   __pyx_tp_dealloc__memoryviewslice, /*tp_dealloc*/
23460   #if PY_VERSION_HEX < 0x030800b4
23461   0, /*tp_print*/
23462   #endif
23463   #if PY_VERSION_HEX >= 0x030800b4
23464   0, /*tp_vectorcall_offset*/
23465   #endif
23466   0, /*tp_getattr*/
23467   0, /*tp_setattr*/
23468   #if PY_MAJOR_VERSION < 3
23469   0, /*tp_compare*/
23470   #endif
23471   #if PY_MAJOR_VERSION >= 3
23472   0, /*tp_as_async*/
23473   #endif
23474   #if CYTHON_COMPILING_IN_PYPY
23475   __pyx_memoryview___repr__, /*tp_repr*/
23476   #else
23477   0, /*tp_repr*/
23478   #endif
23479   0, /*tp_as_number*/
23480   0, /*tp_as_sequence*/
23481   0, /*tp_as_mapping*/
23482   0, /*tp_hash*/
23483   0, /*tp_call*/
23484   #if CYTHON_COMPILING_IN_PYPY
23485   __pyx_memoryview___str__, /*tp_str*/
23486   #else
23487   0, /*tp_str*/
23488   #endif
23489   0, /*tp_getattro*/
23490   0, /*tp_setattro*/
23491   0, /*tp_as_buffer*/
23492   Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
23493   "Internal class for passing memoryview slices to Python", /*tp_doc*/
23494   __pyx_tp_traverse__memoryviewslice, /*tp_traverse*/
23495   __pyx_tp_clear__memoryviewslice, /*tp_clear*/
23496   0, /*tp_richcompare*/
23497   0, /*tp_weaklistoffset*/
23498   0, /*tp_iter*/
23499   0, /*tp_iternext*/
23500   __pyx_methods__memoryviewslice, /*tp_methods*/
23501   0, /*tp_members*/
23502   __pyx_getsets__memoryviewslice, /*tp_getset*/
23503   0, /*tp_base*/
23504   0, /*tp_dict*/
23505   0, /*tp_descr_get*/
23506   0, /*tp_descr_set*/
23507   0, /*tp_dictoffset*/
23508   0, /*tp_init*/
23509   0, /*tp_alloc*/
23510   __pyx_tp_new__memoryviewslice, /*tp_new*/
23511   0, /*tp_free*/
23512   0, /*tp_is_gc*/
23513   0, /*tp_bases*/
23514   0, /*tp_mro*/
23515   0, /*tp_cache*/
23516   0, /*tp_subclasses*/
23517   0, /*tp_weaklist*/
23518   0, /*tp_del*/
23519   0, /*tp_version_tag*/
23520   #if PY_VERSION_HEX >= 0x030400a1
23521   0, /*tp_finalize*/
23522   #endif
23523   #if PY_VERSION_HEX >= 0x030800b1
23524   0, /*tp_vectorcall*/
23525   #endif
23526   #if PY_VERSION_HEX >= 0x030800b4 && PY_VERSION_HEX < 0x03090000
23527   0, /*tp_print*/
23528   #endif
23529 };
23530 
23531 static PyMethodDef __pyx_methods[] = {
23532   {"spmv", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_5qutip_2cy_10spmatfuncs_1spmv, METH_VARARGS|METH_KEYWORDS, __pyx_doc_5qutip_2cy_10spmatfuncs_spmv},
23533   {"spmv_csr", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_5qutip_2cy_10spmatfuncs_3spmv_csr, METH_VARARGS|METH_KEYWORDS, __pyx_doc_5qutip_2cy_10spmatfuncs_2spmv_csr},
23534   {"spmmpy_c", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_5qutip_2cy_10spmatfuncs_7spmmpy_c, METH_VARARGS|METH_KEYWORDS, __pyx_doc_5qutip_2cy_10spmatfuncs_6spmmpy_c},
23535   {"spmmc", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_5qutip_2cy_10spmatfuncs_9spmmc, METH_VARARGS|METH_KEYWORDS, __pyx_doc_5qutip_2cy_10spmatfuncs_8spmmc},
23536   {"spmmpy_f", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_5qutip_2cy_10spmatfuncs_11spmmpy_f, METH_VARARGS|METH_KEYWORDS, __pyx_doc_5qutip_2cy_10spmatfuncs_10spmmpy_f},
23537   {"spmmf", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_5qutip_2cy_10spmatfuncs_13spmmf, METH_VARARGS|METH_KEYWORDS, __pyx_doc_5qutip_2cy_10spmatfuncs_12spmmf},
23538   {"spmm", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_5qutip_2cy_10spmatfuncs_15spmm, METH_VARARGS|METH_KEYWORDS, __pyx_doc_5qutip_2cy_10spmatfuncs_14spmm},
23539   {"cy_ode_rhs", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_5qutip_2cy_10spmatfuncs_17cy_ode_rhs, METH_VARARGS|METH_KEYWORDS, 0},
23540   {"cy_ode_psi_func_td", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_5qutip_2cy_10spmatfuncs_19cy_ode_psi_func_td, METH_VARARGS|METH_KEYWORDS, 0},
23541   {"cy_ode_psi_func_td_with_state", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_5qutip_2cy_10spmatfuncs_21cy_ode_psi_func_td_with_state, METH_VARARGS|METH_KEYWORDS, 0},
23542   {"cy_ode_rho_func_td", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_5qutip_2cy_10spmatfuncs_23cy_ode_rho_func_td, METH_VARARGS|METH_KEYWORDS, 0},
23543   {"cy_expect_psi", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_5qutip_2cy_10spmatfuncs_25cy_expect_psi, METH_VARARGS|METH_KEYWORDS, 0},
23544   {"cy_expect_psi_csr", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_5qutip_2cy_10spmatfuncs_27cy_expect_psi_csr, METH_VARARGS|METH_KEYWORDS, 0},
23545   {"cy_expect_rho_vec", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_5qutip_2cy_10spmatfuncs_29cy_expect_rho_vec, METH_VARARGS|METH_KEYWORDS, 0},
23546   {"cy_expect_rho_vec_csr", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_5qutip_2cy_10spmatfuncs_31cy_expect_rho_vec_csr, METH_VARARGS|METH_KEYWORDS, 0},
23547   {"cy_spmm_tr", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_5qutip_2cy_10spmatfuncs_33cy_spmm_tr, METH_VARARGS|METH_KEYWORDS, 0},
23548   {"zcsr_mat_elem", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_5qutip_2cy_10spmatfuncs_37zcsr_mat_elem, METH_VARARGS|METH_KEYWORDS, __pyx_doc_5qutip_2cy_10spmatfuncs_36zcsr_mat_elem},
23549   {0, 0, 0, 0}
23550 };
23551 
23552 #if PY_MAJOR_VERSION >= 3
23553 #if CYTHON_PEP489_MULTI_PHASE_INIT
23554 static PyObject* __pyx_pymod_create(PyObject *spec, PyModuleDef *def); /*proto*/
23555 static int __pyx_pymod_exec_spmatfuncs(PyObject* module); /*proto*/
23556 static PyModuleDef_Slot __pyx_moduledef_slots[] = {
23557   {Py_mod_create, (void*)__pyx_pymod_create},
23558   {Py_mod_exec, (void*)__pyx_pymod_exec_spmatfuncs},
23559   {0, NULL}
23560 };
23561 #endif
23562 
23563 static struct PyModuleDef __pyx_moduledef = {
23564     PyModuleDef_HEAD_INIT,
23565     "spmatfuncs",
23566     0, /* m_doc */
23567   #if CYTHON_PEP489_MULTI_PHASE_INIT
23568     0, /* m_size */
23569   #else
23570     -1, /* m_size */
23571   #endif
23572     __pyx_methods /* m_methods */,
23573   #if CYTHON_PEP489_MULTI_PHASE_INIT
23574     __pyx_moduledef_slots, /* m_slots */
23575   #else
23576     NULL, /* m_reload */
23577   #endif
23578     NULL, /* m_traverse */
23579     NULL, /* m_clear */
23580     NULL /* m_free */
23581 };
23582 #endif
23583 #ifndef CYTHON_SMALL_CODE
23584 #if defined(__clang__)
23585     #define CYTHON_SMALL_CODE
23586 #elif defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3))
23587     #define CYTHON_SMALL_CODE __attribute__((cold))
23588 #else
23589     #define CYTHON_SMALL_CODE
23590 #endif
23591 #endif
23592 
23593 static __Pyx_StringTabEntry __pyx_string_tab[] = {
23594   {&__pyx_n_s_A, __pyx_k_A, sizeof(__pyx_k_A), 0, 0, 1, 1},
23595   {&__pyx_n_s_ASCII, __pyx_k_ASCII, sizeof(__pyx_k_ASCII), 0, 0, 1, 1},
23596   {&__pyx_n_s_Adata, __pyx_k_Adata, sizeof(__pyx_k_Adata), 0, 0, 1, 1},
23597   {&__pyx_n_s_Aind, __pyx_k_Aind, sizeof(__pyx_k_Aind), 0, 0, 1, 1},
23598   {&__pyx_n_s_Aptr, __pyx_k_Aptr, sizeof(__pyx_k_Aptr), 0, 0, 1, 1},
23599   {&__pyx_n_s_B, __pyx_k_B, sizeof(__pyx_k_B), 0, 0, 1, 1},
23600   {&__pyx_n_s_Bdata, __pyx_k_Bdata, sizeof(__pyx_k_Bdata), 0, 0, 1, 1},
23601   {&__pyx_n_s_Bptr, __pyx_k_Bptr, sizeof(__pyx_k_Bptr), 0, 0, 1, 1},
23602   {&__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},
23603   {&__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},
23604   {&__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},
23605   {&__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},
23606   {&__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},
23607   {&__pyx_n_s_Ellipsis, __pyx_k_Ellipsis, sizeof(__pyx_k_Ellipsis), 0, 0, 1, 1},
23608   {&__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},
23609   {&__pyx_n_u_F, __pyx_k_F, sizeof(__pyx_k_F), 0, 1, 0, 1},
23610   {&__pyx_n_u_F_CONTIGUOUS, __pyx_k_F_CONTIGUOUS, sizeof(__pyx_k_F_CONTIGUOUS), 0, 1, 0, 1},
23611   {&__pyx_n_s_H_func, __pyx_k_H_func, sizeof(__pyx_k_H_func), 0, 0, 1, 1},
23612   {&__pyx_n_s_ImportError, __pyx_k_ImportError, sizeof(__pyx_k_ImportError), 0, 0, 1, 1},
23613   {&__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},
23614   {&__pyx_n_s_IndexError, __pyx_k_IndexError, sizeof(__pyx_k_IndexError), 0, 0, 1, 1},
23615   {&__pyx_kp_s_Indirect_dimensions_not_supporte, __pyx_k_Indirect_dimensions_not_supporte, sizeof(__pyx_k_Indirect_dimensions_not_supporte), 0, 0, 1, 0},
23616   {&__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},
23617   {&__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},
23618   {&__pyx_n_s_L0, __pyx_k_L0, sizeof(__pyx_k_L0), 0, 0, 1, 1},
23619   {&__pyx_n_s_L_func, __pyx_k_L_func, sizeof(__pyx_k_L_func), 0, 0, 1, 1},
23620   {&__pyx_n_s_M, __pyx_k_M, sizeof(__pyx_k_M), 0, 0, 1, 1},
23621   {&__pyx_n_s_MemoryError, __pyx_k_MemoryError, sizeof(__pyx_k_MemoryError), 0, 0, 1, 1},
23622   {&__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},
23623   {&__pyx_kp_s_MemoryView_of_r_object, __pyx_k_MemoryView_of_r_object, sizeof(__pyx_k_MemoryView_of_r_object), 0, 0, 1, 0},
23624   {&__pyx_n_b_O, __pyx_k_O, sizeof(__pyx_k_O), 0, 0, 0, 1},
23625   {&__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},
23626   {&__pyx_n_s_PickleError, __pyx_k_PickleError, sizeof(__pyx_k_PickleError), 0, 0, 1, 1},
23627   {&__pyx_n_s_TypeError, __pyx_k_TypeError, sizeof(__pyx_k_TypeError), 0, 0, 1, 1},
23628   {&__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},
23629   {&__pyx_n_s_ValueError, __pyx_k_ValueError, sizeof(__pyx_k_ValueError), 0, 0, 1, 1},
23630   {&__pyx_n_s_View_MemoryView, __pyx_k_View_MemoryView, sizeof(__pyx_k_View_MemoryView), 0, 0, 1, 1},
23631   {&__pyx_n_s_a, __pyx_k_a, sizeof(__pyx_k_a), 0, 0, 1, 1},
23632   {&__pyx_n_s_allocate_buffer, __pyx_k_allocate_buffer, sizeof(__pyx_k_allocate_buffer), 0, 0, 1, 1},
23633   {&__pyx_n_s_alpha, __pyx_k_alpha, sizeof(__pyx_k_alpha), 0, 0, 1, 1},
23634   {&__pyx_n_s_args, __pyx_k_args, sizeof(__pyx_k_args), 0, 0, 1, 1},
23635   {&__pyx_n_s_base, __pyx_k_base, sizeof(__pyx_k_base), 0, 0, 1, 1},
23636   {&__pyx_n_s_bra_ket, __pyx_k_bra_ket, sizeof(__pyx_k_bra_ket), 0, 0, 1, 1},
23637   {&__pyx_n_s_c, __pyx_k_c, sizeof(__pyx_k_c), 0, 0, 1, 1},
23638   {&__pyx_n_u_c, __pyx_k_c, sizeof(__pyx_k_c), 0, 1, 0, 1},
23639   {&__pyx_n_s_class, __pyx_k_class, sizeof(__pyx_k_class), 0, 0, 1, 1},
23640   {&__pyx_n_s_cline_in_traceback, __pyx_k_cline_in_traceback, sizeof(__pyx_k_cline_in_traceback), 0, 0, 1, 1},
23641   {&__pyx_n_s_complex128, __pyx_k_complex128, sizeof(__pyx_k_complex128), 0, 0, 1, 1},
23642   {&__pyx_kp_s_contiguous_and_direct, __pyx_k_contiguous_and_direct, sizeof(__pyx_k_contiguous_and_direct), 0, 0, 1, 0},
23643   {&__pyx_kp_s_contiguous_and_indirect, __pyx_k_contiguous_and_indirect, sizeof(__pyx_k_contiguous_and_indirect), 0, 0, 1, 0},
23644   {&__pyx_n_s_cval, __pyx_k_cval, sizeof(__pyx_k_cval), 0, 0, 1, 1},
23645   {&__pyx_n_s_data, __pyx_k_data, sizeof(__pyx_k_data), 0, 0, 1, 1},
23646   {&__pyx_n_s_dict, __pyx_k_dict, sizeof(__pyx_k_dict), 0, 0, 1, 1},
23647   {&__pyx_n_s_dtype, __pyx_k_dtype, sizeof(__pyx_k_dtype), 0, 0, 1, 1},
23648   {&__pyx_n_s_dtype_is_object, __pyx_k_dtype_is_object, sizeof(__pyx_k_dtype_is_object), 0, 0, 1, 1},
23649   {&__pyx_n_s_encode, __pyx_k_encode, sizeof(__pyx_k_encode), 0, 0, 1, 1},
23650   {&__pyx_n_s_enumerate, __pyx_k_enumerate, sizeof(__pyx_k_enumerate), 0, 0, 1, 1},
23651   {&__pyx_n_s_error, __pyx_k_error, sizeof(__pyx_k_error), 0, 0, 1, 1},
23652   {&__pyx_n_s_expect_csr_ket, __pyx_k_expect_csr_ket, sizeof(__pyx_k_expect_csr_ket), 0, 0, 1, 1},
23653   {&__pyx_n_s_expt, __pyx_k_expt, sizeof(__pyx_k_expt), 0, 0, 1, 1},
23654   {&__pyx_n_s_flags, __pyx_k_flags, sizeof(__pyx_k_flags), 0, 0, 1, 1},
23655   {&__pyx_n_s_format, __pyx_k_format, sizeof(__pyx_k_format), 0, 0, 1, 1},
23656   {&__pyx_n_s_fortran, __pyx_k_fortran, sizeof(__pyx_k_fortran), 0, 0, 1, 1},
23657   {&__pyx_n_u_fortran, __pyx_k_fortran, sizeof(__pyx_k_fortran), 0, 1, 0, 1},
23658   {&__pyx_n_s_getstate, __pyx_k_getstate, sizeof(__pyx_k_getstate), 0, 0, 1, 1},
23659   {&__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},
23660   {&__pyx_n_s_herm, __pyx_k_herm, sizeof(__pyx_k_herm), 0, 0, 1, 1},
23661   {&__pyx_n_s_id, __pyx_k_id, sizeof(__pyx_k_id), 0, 0, 1, 1},
23662   {&__pyx_n_s_idx, __pyx_k_idx, sizeof(__pyx_k_idx), 0, 0, 1, 1},
23663   {&__pyx_n_s_ii, __pyx_k_ii, sizeof(__pyx_k_ii), 0, 0, 1, 1},
23664   {&__pyx_n_s_import, __pyx_k_import, sizeof(__pyx_k_import), 0, 0, 1, 1},
23665   {&__pyx_n_s_ind, __pyx_k_ind, sizeof(__pyx_k_ind), 0, 0, 1, 1},
23666   {&__pyx_n_s_indices, __pyx_k_indices, sizeof(__pyx_k_indices), 0, 0, 1, 1},
23667   {&__pyx_n_s_indptr, __pyx_k_indptr, sizeof(__pyx_k_indptr), 0, 0, 1, 1},
23668   {&__pyx_n_s_isherm, __pyx_k_isherm, sizeof(__pyx_k_isherm), 0, 0, 1, 1},
23669   {&__pyx_n_s_itemsize, __pyx_k_itemsize, sizeof(__pyx_k_itemsize), 0, 0, 1, 1},
23670   {&__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},
23671   {&__pyx_n_s_j, __pyx_k_j, sizeof(__pyx_k_j), 0, 0, 1, 1},
23672   {&__pyx_n_s_jj, __pyx_k_jj, sizeof(__pyx_k_jj), 0, 0, 1, 1},
23673   {&__pyx_n_s_left, __pyx_k_left, sizeof(__pyx_k_left), 0, 0, 1, 1},
23674   {&__pyx_n_s_main, __pyx_k_main, sizeof(__pyx_k_main), 0, 0, 1, 1},
23675   {&__pyx_n_s_mat, __pyx_k_mat, sizeof(__pyx_k_mat), 0, 0, 1, 1},
23676   {&__pyx_n_s_memview, __pyx_k_memview, sizeof(__pyx_k_memview), 0, 0, 1, 1},
23677   {&__pyx_n_s_mode, __pyx_k_mode, sizeof(__pyx_k_mode), 0, 0, 1, 1},
23678   {&__pyx_n_s_name, __pyx_k_name, sizeof(__pyx_k_name), 0, 0, 1, 1},
23679   {&__pyx_n_s_name_2, __pyx_k_name_2, sizeof(__pyx_k_name_2), 0, 0, 1, 1},
23680   {&__pyx_n_s_ndim, __pyx_k_ndim, sizeof(__pyx_k_ndim), 0, 0, 1, 1},
23681   {&__pyx_n_s_new, __pyx_k_new, sizeof(__pyx_k_new), 0, 0, 1, 1},
23682   {&__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},
23683   {&__pyx_n_s_np, __pyx_k_np, sizeof(__pyx_k_np), 0, 0, 1, 1},
23684   {&__pyx_n_s_nrows, __pyx_k_nrows, sizeof(__pyx_k_nrows), 0, 0, 1, 1},
23685   {&__pyx_n_s_num_rows, __pyx_k_num_rows, sizeof(__pyx_k_num_rows), 0, 0, 1, 1},
23686   {&__pyx_n_s_numpy, __pyx_k_numpy, sizeof(__pyx_k_numpy), 0, 0, 1, 1},
23687   {&__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},
23688   {&__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},
23689   {&__pyx_n_s_obj, __pyx_k_obj, sizeof(__pyx_k_obj), 0, 0, 1, 1},
23690   {&__pyx_n_s_op1, __pyx_k_op1, sizeof(__pyx_k_op1), 0, 0, 1, 1},
23691   {&__pyx_n_s_op2, __pyx_k_op2, sizeof(__pyx_k_op2), 0, 0, 1, 1},
23692   {&__pyx_n_s_order, __pyx_k_order, sizeof(__pyx_k_order), 0, 0, 1, 1},
23693   {&__pyx_n_s_out, __pyx_k_out, sizeof(__pyx_k_out), 0, 0, 1, 1},
23694   {&__pyx_n_s_pack, __pyx_k_pack, sizeof(__pyx_k_pack), 0, 0, 1, 1},
23695   {&__pyx_n_s_pickle, __pyx_k_pickle, sizeof(__pyx_k_pickle), 0, 0, 1, 1},
23696   {&__pyx_n_s_psi, __pyx_k_psi, sizeof(__pyx_k_psi), 0, 0, 1, 1},
23697   {&__pyx_n_s_ptr, __pyx_k_ptr, sizeof(__pyx_k_ptr), 0, 0, 1, 1},
23698   {&__pyx_n_s_pyx_PickleError, __pyx_k_pyx_PickleError, sizeof(__pyx_k_pyx_PickleError), 0, 0, 1, 1},
23699   {&__pyx_n_s_pyx_checksum, __pyx_k_pyx_checksum, sizeof(__pyx_k_pyx_checksum), 0, 0, 1, 1},
23700   {&__pyx_n_s_pyx_getbuffer, __pyx_k_pyx_getbuffer, sizeof(__pyx_k_pyx_getbuffer), 0, 0, 1, 1},
23701   {&__pyx_n_s_pyx_result, __pyx_k_pyx_result, sizeof(__pyx_k_pyx_result), 0, 0, 1, 1},
23702   {&__pyx_n_s_pyx_state, __pyx_k_pyx_state, sizeof(__pyx_k_pyx_state), 0, 0, 1, 1},
23703   {&__pyx_n_s_pyx_type, __pyx_k_pyx_type, sizeof(__pyx_k_pyx_type), 0, 0, 1, 1},
23704   {&__pyx_n_s_pyx_unpickle_Enum, __pyx_k_pyx_unpickle_Enum, sizeof(__pyx_k_pyx_unpickle_Enum), 0, 0, 1, 1},
23705   {&__pyx_n_s_pyx_vtable, __pyx_k_pyx_vtable, sizeof(__pyx_k_pyx_vtable), 0, 0, 1, 1},
23706   {&__pyx_n_s_qutip_cy_spmatfuncs, __pyx_k_qutip_cy_spmatfuncs, sizeof(__pyx_k_qutip_cy_spmatfuncs), 0, 0, 1, 1},
23707   {&__pyx_kp_s_qutip_cy_spmatfuncs_pyx, __pyx_k_qutip_cy_spmatfuncs_pyx, sizeof(__pyx_k_qutip_cy_spmatfuncs_pyx), 0, 0, 1, 0},
23708   {&__pyx_n_s_range, __pyx_k_range, sizeof(__pyx_k_range), 0, 0, 1, 1},
23709   {&__pyx_n_s_reduce, __pyx_k_reduce, sizeof(__pyx_k_reduce), 0, 0, 1, 1},
23710   {&__pyx_n_s_reduce_cython, __pyx_k_reduce_cython, sizeof(__pyx_k_reduce_cython), 0, 0, 1, 1},
23711   {&__pyx_n_s_reduce_ex, __pyx_k_reduce_ex, sizeof(__pyx_k_reduce_ex), 0, 0, 1, 1},
23712   {&__pyx_n_s_rho, __pyx_k_rho, sizeof(__pyx_k_rho), 0, 0, 1, 1},
23713   {&__pyx_n_s_rho_vec, __pyx_k_rho_vec, sizeof(__pyx_k_rho_vec), 0, 0, 1, 1},
23714   {&__pyx_n_s_right, __pyx_k_right, sizeof(__pyx_k_right), 0, 0, 1, 1},
23715   {&__pyx_n_s_row_sum, __pyx_k_row_sum, sizeof(__pyx_k_row_sum), 0, 0, 1, 1},
23716   {&__pyx_n_s_setstate, __pyx_k_setstate, sizeof(__pyx_k_setstate), 0, 0, 1, 1},
23717   {&__pyx_n_s_setstate_cython, __pyx_k_setstate_cython, sizeof(__pyx_k_setstate_cython), 0, 0, 1, 1},
23718   {&__pyx_n_s_shape, __pyx_k_shape, sizeof(__pyx_k_shape), 0, 0, 1, 1},
23719   {&__pyx_n_s_size, __pyx_k_size, sizeof(__pyx_k_size), 0, 0, 1, 1},
23720   {&__pyx_n_s_sparse, __pyx_k_sparse, sizeof(__pyx_k_sparse), 0, 0, 1, 1},
23721   {&__pyx_n_s_spmvpy_csr, __pyx_k_spmvpy_csr, sizeof(__pyx_k_spmvpy_csr), 0, 0, 1, 1},
23722   {&__pyx_n_s_start, __pyx_k_start, sizeof(__pyx_k_start), 0, 0, 1, 1},
23723   {&__pyx_n_s_step, __pyx_k_step, sizeof(__pyx_k_step), 0, 0, 1, 1},
23724   {&__pyx_n_s_stop, __pyx_k_stop, sizeof(__pyx_k_stop), 0, 0, 1, 1},
23725   {&__pyx_kp_s_strided_and_direct, __pyx_k_strided_and_direct, sizeof(__pyx_k_strided_and_direct), 0, 0, 1, 0},
23726   {&__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},
23727   {&__pyx_kp_s_strided_and_indirect, __pyx_k_strided_and_indirect, sizeof(__pyx_k_strided_and_indirect), 0, 0, 1, 0},
23728   {&__pyx_kp_s_stringsource, __pyx_k_stringsource, sizeof(__pyx_k_stringsource), 0, 0, 1, 0},
23729   {&__pyx_n_s_struct, __pyx_k_struct, sizeof(__pyx_k_struct), 0, 0, 1, 1},
23730   {&__pyx_n_s_super_op, __pyx_k_super_op, sizeof(__pyx_k_super_op), 0, 0, 1, 1},
23731   {&__pyx_n_s_t, __pyx_k_t, sizeof(__pyx_k_t), 0, 0, 1, 1},
23732   {&__pyx_n_s_test, __pyx_k_test, sizeof(__pyx_k_test), 0, 0, 1, 1},
23733   {&__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},
23734   {&__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},
23735   {&__pyx_n_s_unpack, __pyx_k_unpack, sizeof(__pyx_k_unpack), 0, 0, 1, 1},
23736   {&__pyx_n_s_update, __pyx_k_update, sizeof(__pyx_k_update), 0, 0, 1, 1},
23737   {&__pyx_n_s_vec, __pyx_k_vec, sizeof(__pyx_k_vec), 0, 0, 1, 1},
23738   {&__pyx_n_s_zeros, __pyx_k_zeros, sizeof(__pyx_k_zeros), 0, 0, 1, 1},
23739   {0, 0, 0, 0, 0, 0, 0}
23740 };
__Pyx_InitCachedBuiltins(void)23741 static CYTHON_SMALL_CODE int __Pyx_InitCachedBuiltins(void) {
23742   __pyx_builtin_range = __Pyx_GetBuiltinName(__pyx_n_s_range); if (!__pyx_builtin_range) __PYX_ERR(0, 157, __pyx_L1_error)
23743   __pyx_builtin_ImportError = __Pyx_GetBuiltinName(__pyx_n_s_ImportError); if (!__pyx_builtin_ImportError) __PYX_ERR(1, 884, __pyx_L1_error)
23744   __pyx_builtin_ValueError = __Pyx_GetBuiltinName(__pyx_n_s_ValueError); if (!__pyx_builtin_ValueError) __PYX_ERR(2, 133, __pyx_L1_error)
23745   __pyx_builtin_MemoryError = __Pyx_GetBuiltinName(__pyx_n_s_MemoryError); if (!__pyx_builtin_MemoryError) __PYX_ERR(2, 148, __pyx_L1_error)
23746   __pyx_builtin_enumerate = __Pyx_GetBuiltinName(__pyx_n_s_enumerate); if (!__pyx_builtin_enumerate) __PYX_ERR(2, 151, __pyx_L1_error)
23747   __pyx_builtin_TypeError = __Pyx_GetBuiltinName(__pyx_n_s_TypeError); if (!__pyx_builtin_TypeError) __PYX_ERR(2, 2, __pyx_L1_error)
23748   __pyx_builtin_Ellipsis = __Pyx_GetBuiltinName(__pyx_n_s_Ellipsis); if (!__pyx_builtin_Ellipsis) __PYX_ERR(2, 404, __pyx_L1_error)
23749   __pyx_builtin_id = __Pyx_GetBuiltinName(__pyx_n_s_id); if (!__pyx_builtin_id) __PYX_ERR(2, 613, __pyx_L1_error)
23750   __pyx_builtin_IndexError = __Pyx_GetBuiltinName(__pyx_n_s_IndexError); if (!__pyx_builtin_IndexError) __PYX_ERR(2, 832, __pyx_L1_error)
23751   return 0;
23752   __pyx_L1_error:;
23753   return -1;
23754 }
23755 
__Pyx_InitCachedConstants(void)23756 static CYTHON_SMALL_CODE int __Pyx_InitCachedConstants(void) {
23757   __Pyx_RefNannyDeclarations
23758   __Pyx_RefNannySetupContext("__Pyx_InitCachedConstants", 0);
23759 
23760   /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":884
23761  *         __pyx_import_array()
23762  *     except Exception:
23763  *         raise ImportError("numpy.core.multiarray failed to import")             # <<<<<<<<<<<<<<
23764  *
23765  * cdef inline int import_umath() except -1:
23766  */
23767   __pyx_tuple_ = PyTuple_Pack(1, __pyx_kp_u_numpy_core_multiarray_failed_to); if (unlikely(!__pyx_tuple_)) __PYX_ERR(1, 884, __pyx_L1_error)
23768   __Pyx_GOTREF(__pyx_tuple_);
23769   __Pyx_GIVEREF(__pyx_tuple_);
23770 
23771   /* "../../../../../tmp/build-env-hoit1hud/lib/python3.6/site-packages/numpy/__init__.pxd":890
23772  *         _import_umath()
23773  *     except Exception:
23774  *         raise ImportError("numpy.core.umath failed to import")             # <<<<<<<<<<<<<<
23775  *
23776  * cdef inline int import_ufunc() except -1:
23777  */
23778   __pyx_tuple__2 = PyTuple_Pack(1, __pyx_kp_u_numpy_core_umath_failed_to_impor); if (unlikely(!__pyx_tuple__2)) __PYX_ERR(1, 890, __pyx_L1_error)
23779   __Pyx_GOTREF(__pyx_tuple__2);
23780   __Pyx_GIVEREF(__pyx_tuple__2);
23781 
23782   /* "View.MemoryView":133
23783  *
23784  *         if not self.ndim:
23785  *             raise ValueError("Empty shape tuple for cython.array")             # <<<<<<<<<<<<<<
23786  *
23787  *         if itemsize <= 0:
23788  */
23789   __pyx_tuple__3 = PyTuple_Pack(1, __pyx_kp_s_Empty_shape_tuple_for_cython_arr); if (unlikely(!__pyx_tuple__3)) __PYX_ERR(2, 133, __pyx_L1_error)
23790   __Pyx_GOTREF(__pyx_tuple__3);
23791   __Pyx_GIVEREF(__pyx_tuple__3);
23792 
23793   /* "View.MemoryView":136
23794  *
23795  *         if itemsize <= 0:
23796  *             raise ValueError("itemsize <= 0 for cython.array")             # <<<<<<<<<<<<<<
23797  *
23798  *         if not isinstance(format, bytes):
23799  */
23800   __pyx_tuple__4 = PyTuple_Pack(1, __pyx_kp_s_itemsize_0_for_cython_array); if (unlikely(!__pyx_tuple__4)) __PYX_ERR(2, 136, __pyx_L1_error)
23801   __Pyx_GOTREF(__pyx_tuple__4);
23802   __Pyx_GIVEREF(__pyx_tuple__4);
23803 
23804   /* "View.MemoryView":148
23805  *
23806  *         if not self._shape:
23807  *             raise MemoryError("unable to allocate shape and strides.")             # <<<<<<<<<<<<<<
23808  *
23809  *
23810  */
23811   __pyx_tuple__5 = PyTuple_Pack(1, __pyx_kp_s_unable_to_allocate_shape_and_str); if (unlikely(!__pyx_tuple__5)) __PYX_ERR(2, 148, __pyx_L1_error)
23812   __Pyx_GOTREF(__pyx_tuple__5);
23813   __Pyx_GIVEREF(__pyx_tuple__5);
23814 
23815   /* "View.MemoryView":176
23816  *             self.data = <char *>malloc(self.len)
23817  *             if not self.data:
23818  *                 raise MemoryError("unable to allocate array data.")             # <<<<<<<<<<<<<<
23819  *
23820  *             if self.dtype_is_object:
23821  */
23822   __pyx_tuple__6 = PyTuple_Pack(1, __pyx_kp_s_unable_to_allocate_array_data); if (unlikely(!__pyx_tuple__6)) __PYX_ERR(2, 176, __pyx_L1_error)
23823   __Pyx_GOTREF(__pyx_tuple__6);
23824   __Pyx_GIVEREF(__pyx_tuple__6);
23825 
23826   /* "View.MemoryView":192
23827  *             bufmode = PyBUF_F_CONTIGUOUS | PyBUF_ANY_CONTIGUOUS
23828  *         if not (flags & bufmode):
23829  *             raise ValueError("Can only create a buffer that is contiguous in memory.")             # <<<<<<<<<<<<<<
23830  *         info.buf = self.data
23831  *         info.len = self.len
23832  */
23833   __pyx_tuple__7 = PyTuple_Pack(1, __pyx_kp_s_Can_only_create_a_buffer_that_is); if (unlikely(!__pyx_tuple__7)) __PYX_ERR(2, 192, __pyx_L1_error)
23834   __Pyx_GOTREF(__pyx_tuple__7);
23835   __Pyx_GIVEREF(__pyx_tuple__7);
23836 
23837   /* "(tree fragment)":2
23838  * def __reduce_cython__(self):
23839  *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")             # <<<<<<<<<<<<<<
23840  * def __setstate_cython__(self, __pyx_state):
23841  *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
23842  */
23843   __pyx_tuple__8 = PyTuple_Pack(1, __pyx_kp_s_no_default___reduce___due_to_non); if (unlikely(!__pyx_tuple__8)) __PYX_ERR(2, 2, __pyx_L1_error)
23844   __Pyx_GOTREF(__pyx_tuple__8);
23845   __Pyx_GIVEREF(__pyx_tuple__8);
23846 
23847   /* "(tree fragment)":4
23848  *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
23849  * def __setstate_cython__(self, __pyx_state):
23850  *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")             # <<<<<<<<<<<<<<
23851  */
23852   __pyx_tuple__9 = PyTuple_Pack(1, __pyx_kp_s_no_default___reduce___due_to_non); if (unlikely(!__pyx_tuple__9)) __PYX_ERR(2, 4, __pyx_L1_error)
23853   __Pyx_GOTREF(__pyx_tuple__9);
23854   __Pyx_GIVEREF(__pyx_tuple__9);
23855 
23856   /* "View.MemoryView":418
23857  *     def __setitem__(memoryview self, object index, object value):
23858  *         if self.view.readonly:
23859  *             raise TypeError("Cannot assign to read-only memoryview")             # <<<<<<<<<<<<<<
23860  *
23861  *         have_slices, index = _unellipsify(index, self.view.ndim)
23862  */
23863   __pyx_tuple__10 = PyTuple_Pack(1, __pyx_kp_s_Cannot_assign_to_read_only_memor); if (unlikely(!__pyx_tuple__10)) __PYX_ERR(2, 418, __pyx_L1_error)
23864   __Pyx_GOTREF(__pyx_tuple__10);
23865   __Pyx_GIVEREF(__pyx_tuple__10);
23866 
23867   /* "View.MemoryView":495
23868  *             result = struct.unpack(self.view.format, bytesitem)
23869  *         except struct.error:
23870  *             raise ValueError("Unable to convert item to object")             # <<<<<<<<<<<<<<
23871  *         else:
23872  *             if len(self.view.format) == 1:
23873  */
23874   __pyx_tuple__11 = PyTuple_Pack(1, __pyx_kp_s_Unable_to_convert_item_to_object); if (unlikely(!__pyx_tuple__11)) __PYX_ERR(2, 495, __pyx_L1_error)
23875   __Pyx_GOTREF(__pyx_tuple__11);
23876   __Pyx_GIVEREF(__pyx_tuple__11);
23877 
23878   /* "View.MemoryView":520
23879  *     def __getbuffer__(self, Py_buffer *info, int flags):
23880  *         if flags & PyBUF_WRITABLE and self.view.readonly:
23881  *             raise ValueError("Cannot create writable memory view from read-only memoryview")             # <<<<<<<<<<<<<<
23882  *
23883  *         if flags & PyBUF_ND:
23884  */
23885   __pyx_tuple__12 = PyTuple_Pack(1, __pyx_kp_s_Cannot_create_writable_memory_vi); if (unlikely(!__pyx_tuple__12)) __PYX_ERR(2, 520, __pyx_L1_error)
23886   __Pyx_GOTREF(__pyx_tuple__12);
23887   __Pyx_GIVEREF(__pyx_tuple__12);
23888 
23889   /* "View.MemoryView":570
23890  *         if self.view.strides == NULL:
23891  *
23892  *             raise ValueError("Buffer view does not expose strides")             # <<<<<<<<<<<<<<
23893  *
23894  *         return tuple([stride for stride in self.view.strides[:self.view.ndim]])
23895  */
23896   __pyx_tuple__13 = PyTuple_Pack(1, __pyx_kp_s_Buffer_view_does_not_expose_stri); if (unlikely(!__pyx_tuple__13)) __PYX_ERR(2, 570, __pyx_L1_error)
23897   __Pyx_GOTREF(__pyx_tuple__13);
23898   __Pyx_GIVEREF(__pyx_tuple__13);
23899 
23900   /* "View.MemoryView":577
23901  *     def suboffsets(self):
23902  *         if self.view.suboffsets == NULL:
23903  *             return (-1,) * self.view.ndim             # <<<<<<<<<<<<<<
23904  *
23905  *         return tuple([suboffset for suboffset in self.view.suboffsets[:self.view.ndim]])
23906  */
23907   __pyx_tuple__14 = PyTuple_New(1); if (unlikely(!__pyx_tuple__14)) __PYX_ERR(2, 577, __pyx_L1_error)
23908   __Pyx_GOTREF(__pyx_tuple__14);
23909   __Pyx_INCREF(__pyx_int_neg_1);
23910   __Pyx_GIVEREF(__pyx_int_neg_1);
23911   PyTuple_SET_ITEM(__pyx_tuple__14, 0, __pyx_int_neg_1);
23912   __Pyx_GIVEREF(__pyx_tuple__14);
23913 
23914   /* "(tree fragment)":2
23915  * def __reduce_cython__(self):
23916  *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")             # <<<<<<<<<<<<<<
23917  * def __setstate_cython__(self, __pyx_state):
23918  *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
23919  */
23920   __pyx_tuple__15 = PyTuple_Pack(1, __pyx_kp_s_no_default___reduce___due_to_non); if (unlikely(!__pyx_tuple__15)) __PYX_ERR(2, 2, __pyx_L1_error)
23921   __Pyx_GOTREF(__pyx_tuple__15);
23922   __Pyx_GIVEREF(__pyx_tuple__15);
23923 
23924   /* "(tree fragment)":4
23925  *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
23926  * def __setstate_cython__(self, __pyx_state):
23927  *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")             # <<<<<<<<<<<<<<
23928  */
23929   __pyx_tuple__16 = PyTuple_Pack(1, __pyx_kp_s_no_default___reduce___due_to_non); if (unlikely(!__pyx_tuple__16)) __PYX_ERR(2, 4, __pyx_L1_error)
23930   __Pyx_GOTREF(__pyx_tuple__16);
23931   __Pyx_GIVEREF(__pyx_tuple__16);
23932 
23933   /* "View.MemoryView":682
23934  *         if item is Ellipsis:
23935  *             if not seen_ellipsis:
23936  *                 result.extend([slice(None)] * (ndim - len(tup) + 1))             # <<<<<<<<<<<<<<
23937  *                 seen_ellipsis = True
23938  *             else:
23939  */
23940   __pyx_slice__17 = PySlice_New(Py_None, Py_None, Py_None); if (unlikely(!__pyx_slice__17)) __PYX_ERR(2, 682, __pyx_L1_error)
23941   __Pyx_GOTREF(__pyx_slice__17);
23942   __Pyx_GIVEREF(__pyx_slice__17);
23943 
23944   /* "View.MemoryView":703
23945  *     for suboffset in suboffsets[:ndim]:
23946  *         if suboffset >= 0:
23947  *             raise ValueError("Indirect dimensions not supported")             # <<<<<<<<<<<<<<
23948  *
23949  *
23950  */
23951   __pyx_tuple__18 = PyTuple_Pack(1, __pyx_kp_s_Indirect_dimensions_not_supporte); if (unlikely(!__pyx_tuple__18)) __PYX_ERR(2, 703, __pyx_L1_error)
23952   __Pyx_GOTREF(__pyx_tuple__18);
23953   __Pyx_GIVEREF(__pyx_tuple__18);
23954 
23955   /* "(tree fragment)":2
23956  * def __reduce_cython__(self):
23957  *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")             # <<<<<<<<<<<<<<
23958  * def __setstate_cython__(self, __pyx_state):
23959  *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
23960  */
23961   __pyx_tuple__19 = PyTuple_Pack(1, __pyx_kp_s_no_default___reduce___due_to_non); if (unlikely(!__pyx_tuple__19)) __PYX_ERR(2, 2, __pyx_L1_error)
23962   __Pyx_GOTREF(__pyx_tuple__19);
23963   __Pyx_GIVEREF(__pyx_tuple__19);
23964 
23965   /* "(tree fragment)":4
23966  *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
23967  * def __setstate_cython__(self, __pyx_state):
23968  *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")             # <<<<<<<<<<<<<<
23969  */
23970   __pyx_tuple__20 = PyTuple_Pack(1, __pyx_kp_s_no_default___reduce___due_to_non); if (unlikely(!__pyx_tuple__20)) __PYX_ERR(2, 4, __pyx_L1_error)
23971   __Pyx_GOTREF(__pyx_tuple__20);
23972   __Pyx_GIVEREF(__pyx_tuple__20);
23973 
23974   /* "qutip/cy/spmatfuncs.pyx":105
23975  * @cython.boundscheck(False)
23976  * @cython.wraparound(False)
23977  * def spmvpy_csr(complex[::1] data,             # <<<<<<<<<<<<<<
23978  *             int[::1] ind, int[::1] ptr, complex[::1] vec,
23979  *             complex alpha, complex[::1] out):
23980  */
23981   __pyx_tuple__21 = PyTuple_Pack(7, __pyx_n_s_data, __pyx_n_s_ind, __pyx_n_s_ptr, __pyx_n_s_vec, __pyx_n_s_alpha, __pyx_n_s_out, __pyx_n_s_num_rows); if (unlikely(!__pyx_tuple__21)) __PYX_ERR(0, 105, __pyx_L1_error)
23982   __Pyx_GOTREF(__pyx_tuple__21);
23983   __Pyx_GIVEREF(__pyx_tuple__21);
23984   __pyx_codeobj__22 = (PyObject*)__Pyx_PyCode_New(6, 0, 7, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__21, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_qutip_cy_spmatfuncs_pyx, __pyx_n_s_spmvpy_csr, 105, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__22)) __PYX_ERR(0, 105, __pyx_L1_error)
23985 
23986   /* "qutip/cy/spmatfuncs.pyx":495
23987  * @cython.boundscheck(False)
23988  * @cython.wraparound(False)
23989  * def expect_csr_ket(object A, object B, int isherm):             # <<<<<<<<<<<<<<
23990  *
23991  *     cdef complex[::1] Adata = A.data
23992  */
23993   __pyx_tuple__23 = PyTuple_Pack(15, __pyx_n_s_A, __pyx_n_s_B, __pyx_n_s_isherm, __pyx_n_s_Adata, __pyx_n_s_Aind, __pyx_n_s_Aptr, __pyx_n_s_Bdata, __pyx_n_s_Bptr, __pyx_n_s_nrows, __pyx_n_s_j, __pyx_n_s_ii, __pyx_n_s_jj, __pyx_n_s_cval, __pyx_n_s_row_sum, __pyx_n_s_expt); if (unlikely(!__pyx_tuple__23)) __PYX_ERR(0, 495, __pyx_L1_error)
23994   __Pyx_GOTREF(__pyx_tuple__23);
23995   __Pyx_GIVEREF(__pyx_tuple__23);
23996   __pyx_codeobj__24 = (PyObject*)__Pyx_PyCode_New(3, 0, 15, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__23, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_qutip_cy_spmatfuncs_pyx, __pyx_n_s_expect_csr_ket, 495, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__24)) __PYX_ERR(0, 495, __pyx_L1_error)
23997 
23998   /* "View.MemoryView":286
23999  *         return self.name
24000  *
24001  * cdef generic = Enum("<strided and direct or indirect>")             # <<<<<<<<<<<<<<
24002  * cdef strided = Enum("<strided and direct>") # default
24003  * cdef indirect = Enum("<strided and indirect>")
24004  */
24005   __pyx_tuple__25 = PyTuple_Pack(1, __pyx_kp_s_strided_and_direct_or_indirect); if (unlikely(!__pyx_tuple__25)) __PYX_ERR(2, 286, __pyx_L1_error)
24006   __Pyx_GOTREF(__pyx_tuple__25);
24007   __Pyx_GIVEREF(__pyx_tuple__25);
24008 
24009   /* "View.MemoryView":287
24010  *
24011  * cdef generic = Enum("<strided and direct or indirect>")
24012  * cdef strided = Enum("<strided and direct>") # default             # <<<<<<<<<<<<<<
24013  * cdef indirect = Enum("<strided and indirect>")
24014  *
24015  */
24016   __pyx_tuple__26 = PyTuple_Pack(1, __pyx_kp_s_strided_and_direct); if (unlikely(!__pyx_tuple__26)) __PYX_ERR(2, 287, __pyx_L1_error)
24017   __Pyx_GOTREF(__pyx_tuple__26);
24018   __Pyx_GIVEREF(__pyx_tuple__26);
24019 
24020   /* "View.MemoryView":288
24021  * cdef generic = Enum("<strided and direct or indirect>")
24022  * cdef strided = Enum("<strided and direct>") # default
24023  * cdef indirect = Enum("<strided and indirect>")             # <<<<<<<<<<<<<<
24024  *
24025  *
24026  */
24027   __pyx_tuple__27 = PyTuple_Pack(1, __pyx_kp_s_strided_and_indirect); if (unlikely(!__pyx_tuple__27)) __PYX_ERR(2, 288, __pyx_L1_error)
24028   __Pyx_GOTREF(__pyx_tuple__27);
24029   __Pyx_GIVEREF(__pyx_tuple__27);
24030 
24031   /* "View.MemoryView":291
24032  *
24033  *
24034  * cdef contiguous = Enum("<contiguous and direct>")             # <<<<<<<<<<<<<<
24035  * cdef indirect_contiguous = Enum("<contiguous and indirect>")
24036  *
24037  */
24038   __pyx_tuple__28 = PyTuple_Pack(1, __pyx_kp_s_contiguous_and_direct); if (unlikely(!__pyx_tuple__28)) __PYX_ERR(2, 291, __pyx_L1_error)
24039   __Pyx_GOTREF(__pyx_tuple__28);
24040   __Pyx_GIVEREF(__pyx_tuple__28);
24041 
24042   /* "View.MemoryView":292
24043  *
24044  * cdef contiguous = Enum("<contiguous and direct>")
24045  * cdef indirect_contiguous = Enum("<contiguous and indirect>")             # <<<<<<<<<<<<<<
24046  *
24047  *
24048  */
24049   __pyx_tuple__29 = PyTuple_Pack(1, __pyx_kp_s_contiguous_and_indirect); if (unlikely(!__pyx_tuple__29)) __PYX_ERR(2, 292, __pyx_L1_error)
24050   __Pyx_GOTREF(__pyx_tuple__29);
24051   __Pyx_GIVEREF(__pyx_tuple__29);
24052 
24053   /* "(tree fragment)":1
24054  * def __pyx_unpickle_Enum(__pyx_type, long __pyx_checksum, __pyx_state):             # <<<<<<<<<<<<<<
24055  *     cdef object __pyx_PickleError
24056  *     cdef object __pyx_result
24057  */
24058   __pyx_tuple__30 = 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__30)) __PYX_ERR(2, 1, __pyx_L1_error)
24059   __Pyx_GOTREF(__pyx_tuple__30);
24060   __Pyx_GIVEREF(__pyx_tuple__30);
24061   __pyx_codeobj__31 = (PyObject*)__Pyx_PyCode_New(3, 0, 5, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__30, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_stringsource, __pyx_n_s_pyx_unpickle_Enum, 1, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__31)) __PYX_ERR(2, 1, __pyx_L1_error)
24062   __Pyx_RefNannyFinishContext();
24063   return 0;
24064   __pyx_L1_error:;
24065   __Pyx_RefNannyFinishContext();
24066   return -1;
24067 }
24068 
__Pyx_InitGlobals(void)24069 static CYTHON_SMALL_CODE int __Pyx_InitGlobals(void) {
24070   if (__Pyx_InitStrings(__pyx_string_tab) < 0) __PYX_ERR(0, 1, __pyx_L1_error);
24071   __pyx_int_0 = PyInt_FromLong(0); if (unlikely(!__pyx_int_0)) __PYX_ERR(0, 1, __pyx_L1_error)
24072   __pyx_int_1 = PyInt_FromLong(1); if (unlikely(!__pyx_int_1)) __PYX_ERR(0, 1, __pyx_L1_error)
24073   __pyx_int_184977713 = PyInt_FromLong(184977713L); if (unlikely(!__pyx_int_184977713)) __PYX_ERR(0, 1, __pyx_L1_error)
24074   __pyx_int_neg_1 = PyInt_FromLong(-1); if (unlikely(!__pyx_int_neg_1)) __PYX_ERR(0, 1, __pyx_L1_error)
24075   return 0;
24076   __pyx_L1_error:;
24077   return -1;
24078 }
24079 
24080 static CYTHON_SMALL_CODE int __Pyx_modinit_global_init_code(void); /*proto*/
24081 static CYTHON_SMALL_CODE int __Pyx_modinit_variable_export_code(void); /*proto*/
24082 static CYTHON_SMALL_CODE int __Pyx_modinit_function_export_code(void); /*proto*/
24083 static CYTHON_SMALL_CODE int __Pyx_modinit_type_init_code(void); /*proto*/
24084 static CYTHON_SMALL_CODE int __Pyx_modinit_type_import_code(void); /*proto*/
24085 static CYTHON_SMALL_CODE int __Pyx_modinit_variable_import_code(void); /*proto*/
24086 static CYTHON_SMALL_CODE int __Pyx_modinit_function_import_code(void); /*proto*/
24087 
__Pyx_modinit_global_init_code(void)24088 static int __Pyx_modinit_global_init_code(void) {
24089   __Pyx_RefNannyDeclarations
24090   __Pyx_RefNannySetupContext("__Pyx_modinit_global_init_code", 0);
24091   /*--- Global init code ---*/
24092   generic = Py_None; Py_INCREF(Py_None);
24093   strided = Py_None; Py_INCREF(Py_None);
24094   indirect = Py_None; Py_INCREF(Py_None);
24095   contiguous = Py_None; Py_INCREF(Py_None);
24096   indirect_contiguous = Py_None; Py_INCREF(Py_None);
24097   __Pyx_RefNannyFinishContext();
24098   return 0;
24099 }
24100 
__Pyx_modinit_variable_export_code(void)24101 static int __Pyx_modinit_variable_export_code(void) {
24102   __Pyx_RefNannyDeclarations
24103   __Pyx_RefNannySetupContext("__Pyx_modinit_variable_export_code", 0);
24104   /*--- Variable export code ---*/
24105   __Pyx_RefNannyFinishContext();
24106   return 0;
24107 }
24108 
__Pyx_modinit_function_export_code(void)24109 static int __Pyx_modinit_function_export_code(void) {
24110   __Pyx_RefNannyDeclarations
24111   int __pyx_lineno = 0;
24112   const char *__pyx_filename = NULL;
24113   int __pyx_clineno = 0;
24114   __Pyx_RefNannySetupContext("__Pyx_modinit_function_export_code", 0);
24115   /*--- Function export code ---*/
24116   if (__Pyx_ExportFunction("spmv_csr", (void (*)(void))__pyx_f_5qutip_2cy_10spmatfuncs_spmv_csr, "PyArrayObject *(__Pyx_memviewslice, __Pyx_memviewslice, __Pyx_memviewslice, __Pyx_memviewslice, int __pyx_skip_dispatch)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
24117   if (__Pyx_ExportFunction("spmvpy", (void (*)(void))__pyx_f_5qutip_2cy_10spmatfuncs_spmvpy, "void (__pyx_t_double_complex *, int *, int *, __pyx_t_double_complex *, __pyx_t_double_complex, __pyx_t_double_complex *, unsigned int)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
24118   if (__Pyx_ExportFunction("cy_expect_rho_vec_csr", (void (*)(void))__pyx_f_5qutip_2cy_10spmatfuncs_cy_expect_rho_vec_csr, "PyObject *(__Pyx_memviewslice, __Pyx_memviewslice, __Pyx_memviewslice, __Pyx_memviewslice, int, int __pyx_skip_dispatch)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
24119   if (__Pyx_ExportFunction("cy_expect_psi", (void (*)(void))__pyx_f_5qutip_2cy_10spmatfuncs_cy_expect_psi, "PyObject *(PyObject *, __Pyx_memviewslice, bool, int __pyx_skip_dispatch)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
24120   if (__Pyx_ExportFunction("cy_expect_psi_csr", (void (*)(void))__pyx_f_5qutip_2cy_10spmatfuncs_cy_expect_psi_csr, "PyObject *(__Pyx_memviewslice, __Pyx_memviewslice, __Pyx_memviewslice, __Pyx_memviewslice, bool, int __pyx_skip_dispatch)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
24121   if (__Pyx_ExportFunction("_spmm_c_py", (void (*)(void))__pyx_f_5qutip_2cy_10spmatfuncs__spmm_c_py, "void (__pyx_t_double_complex *, int *, int *, __pyx_t_double_complex *, __pyx_t_double_complex, __pyx_t_double_complex *, unsigned int, unsigned int, unsigned int)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
24122   if (__Pyx_ExportFunction("spmmpy_c", (void (*)(void))__pyx_f_5qutip_2cy_10spmatfuncs_spmmpy_c, "void (__Pyx_memviewslice, __Pyx_memviewslice, __Pyx_memviewslice, __Pyx_memviewslice, __pyx_t_double_complex, __Pyx_memviewslice, int __pyx_skip_dispatch)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
24123   if (__Pyx_ExportFunction("spmmc", (void (*)(void))__pyx_f_5qutip_2cy_10spmatfuncs_spmmc, "PyArrayObject *(PyObject *, __Pyx_memviewslice, int __pyx_skip_dispatch)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
24124   if (__Pyx_ExportFunction("_spmm_f_py", (void (*)(void))__pyx_f_5qutip_2cy_10spmatfuncs__spmm_f_py, "void (__pyx_t_double_complex *, int *, int *, __pyx_t_double_complex *, __pyx_t_double_complex, __pyx_t_double_complex *, unsigned int, unsigned int, unsigned int)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
24125   if (__Pyx_ExportFunction("spmmpy_f", (void (*)(void))__pyx_f_5qutip_2cy_10spmatfuncs_spmmpy_f, "void (__Pyx_memviewslice, __Pyx_memviewslice, __Pyx_memviewslice, __Pyx_memviewslice, __pyx_t_double_complex, __Pyx_memviewslice, int __pyx_skip_dispatch)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
24126   if (__Pyx_ExportFunction("spmmf", (void (*)(void))__pyx_f_5qutip_2cy_10spmatfuncs_spmmf, "PyArrayObject *(PyObject *, __Pyx_memviewslice, int __pyx_skip_dispatch)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
24127   if (__Pyx_ExportFunction("spmm", (void (*)(void))__pyx_f_5qutip_2cy_10spmatfuncs_spmm, "PyArrayObject *(PyObject *, PyArrayObject *, int __pyx_skip_dispatch)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
24128   __Pyx_RefNannyFinishContext();
24129   return 0;
24130   __pyx_L1_error:;
24131   __Pyx_RefNannyFinishContext();
24132   return -1;
24133 }
24134 
__Pyx_modinit_type_init_code(void)24135 static int __Pyx_modinit_type_init_code(void) {
24136   __Pyx_RefNannyDeclarations
24137   int __pyx_lineno = 0;
24138   const char *__pyx_filename = NULL;
24139   int __pyx_clineno = 0;
24140   __Pyx_RefNannySetupContext("__Pyx_modinit_type_init_code", 0);
24141   /*--- Type init code ---*/
24142   __pyx_vtabptr_array = &__pyx_vtable_array;
24143   __pyx_vtable_array.get_memview = (PyObject *(*)(struct __pyx_array_obj *))__pyx_array_get_memview;
24144   if (PyType_Ready(&__pyx_type___pyx_array) < 0) __PYX_ERR(2, 105, __pyx_L1_error)
24145   #if PY_VERSION_HEX < 0x030800B1
24146   __pyx_type___pyx_array.tp_print = 0;
24147   #endif
24148   if (__Pyx_SetVtable(__pyx_type___pyx_array.tp_dict, __pyx_vtabptr_array) < 0) __PYX_ERR(2, 105, __pyx_L1_error)
24149   if (__Pyx_setup_reduce((PyObject*)&__pyx_type___pyx_array) < 0) __PYX_ERR(2, 105, __pyx_L1_error)
24150   __pyx_array_type = &__pyx_type___pyx_array;
24151   if (PyType_Ready(&__pyx_type___pyx_MemviewEnum) < 0) __PYX_ERR(2, 279, __pyx_L1_error)
24152   #if PY_VERSION_HEX < 0x030800B1
24153   __pyx_type___pyx_MemviewEnum.tp_print = 0;
24154   #endif
24155   if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type___pyx_MemviewEnum.tp_dictoffset && __pyx_type___pyx_MemviewEnum.tp_getattro == PyObject_GenericGetAttr)) {
24156     __pyx_type___pyx_MemviewEnum.tp_getattro = __Pyx_PyObject_GenericGetAttr;
24157   }
24158   if (__Pyx_setup_reduce((PyObject*)&__pyx_type___pyx_MemviewEnum) < 0) __PYX_ERR(2, 279, __pyx_L1_error)
24159   __pyx_MemviewEnum_type = &__pyx_type___pyx_MemviewEnum;
24160   __pyx_vtabptr_memoryview = &__pyx_vtable_memoryview;
24161   __pyx_vtable_memoryview.get_item_pointer = (char *(*)(struct __pyx_memoryview_obj *, PyObject *))__pyx_memoryview_get_item_pointer;
24162   __pyx_vtable_memoryview.is_slice = (PyObject *(*)(struct __pyx_memoryview_obj *, PyObject *))__pyx_memoryview_is_slice;
24163   __pyx_vtable_memoryview.setitem_slice_assignment = (PyObject *(*)(struct __pyx_memoryview_obj *, PyObject *, PyObject *))__pyx_memoryview_setitem_slice_assignment;
24164   __pyx_vtable_memoryview.setitem_slice_assign_scalar = (PyObject *(*)(struct __pyx_memoryview_obj *, struct __pyx_memoryview_obj *, PyObject *))__pyx_memoryview_setitem_slice_assign_scalar;
24165   __pyx_vtable_memoryview.setitem_indexed = (PyObject *(*)(struct __pyx_memoryview_obj *, PyObject *, PyObject *))__pyx_memoryview_setitem_indexed;
24166   __pyx_vtable_memoryview.convert_item_to_object = (PyObject *(*)(struct __pyx_memoryview_obj *, char *))__pyx_memoryview_convert_item_to_object;
24167   __pyx_vtable_memoryview.assign_item_from_object = (PyObject *(*)(struct __pyx_memoryview_obj *, char *, PyObject *))__pyx_memoryview_assign_item_from_object;
24168   if (PyType_Ready(&__pyx_type___pyx_memoryview) < 0) __PYX_ERR(2, 330, __pyx_L1_error)
24169   #if PY_VERSION_HEX < 0x030800B1
24170   __pyx_type___pyx_memoryview.tp_print = 0;
24171   #endif
24172   if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type___pyx_memoryview.tp_dictoffset && __pyx_type___pyx_memoryview.tp_getattro == PyObject_GenericGetAttr)) {
24173     __pyx_type___pyx_memoryview.tp_getattro = __Pyx_PyObject_GenericGetAttr;
24174   }
24175   if (__Pyx_SetVtable(__pyx_type___pyx_memoryview.tp_dict, __pyx_vtabptr_memoryview) < 0) __PYX_ERR(2, 330, __pyx_L1_error)
24176   if (__Pyx_setup_reduce((PyObject*)&__pyx_type___pyx_memoryview) < 0) __PYX_ERR(2, 330, __pyx_L1_error)
24177   __pyx_memoryview_type = &__pyx_type___pyx_memoryview;
24178   __pyx_vtabptr__memoryviewslice = &__pyx_vtable__memoryviewslice;
24179   __pyx_vtable__memoryviewslice.__pyx_base = *__pyx_vtabptr_memoryview;
24180   __pyx_vtable__memoryviewslice.__pyx_base.convert_item_to_object = (PyObject *(*)(struct __pyx_memoryview_obj *, char *))__pyx_memoryviewslice_convert_item_to_object;
24181   __pyx_vtable__memoryviewslice.__pyx_base.assign_item_from_object = (PyObject *(*)(struct __pyx_memoryview_obj *, char *, PyObject *))__pyx_memoryviewslice_assign_item_from_object;
24182   __pyx_type___pyx_memoryviewslice.tp_base = __pyx_memoryview_type;
24183   if (PyType_Ready(&__pyx_type___pyx_memoryviewslice) < 0) __PYX_ERR(2, 965, __pyx_L1_error)
24184   #if PY_VERSION_HEX < 0x030800B1
24185   __pyx_type___pyx_memoryviewslice.tp_print = 0;
24186   #endif
24187   if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type___pyx_memoryviewslice.tp_dictoffset && __pyx_type___pyx_memoryviewslice.tp_getattro == PyObject_GenericGetAttr)) {
24188     __pyx_type___pyx_memoryviewslice.tp_getattro = __Pyx_PyObject_GenericGetAttr;
24189   }
24190   if (__Pyx_SetVtable(__pyx_type___pyx_memoryviewslice.tp_dict, __pyx_vtabptr__memoryviewslice) < 0) __PYX_ERR(2, 965, __pyx_L1_error)
24191   if (__Pyx_setup_reduce((PyObject*)&__pyx_type___pyx_memoryviewslice) < 0) __PYX_ERR(2, 965, __pyx_L1_error)
24192   __pyx_memoryviewslice_type = &__pyx_type___pyx_memoryviewslice;
24193   __Pyx_RefNannyFinishContext();
24194   return 0;
24195   __pyx_L1_error:;
24196   __Pyx_RefNannyFinishContext();
24197   return -1;
24198 }
24199 
__Pyx_modinit_type_import_code(void)24200 static int __Pyx_modinit_type_import_code(void) {
24201   __Pyx_RefNannyDeclarations
24202   PyObject *__pyx_t_1 = NULL;
24203   int __pyx_lineno = 0;
24204   const char *__pyx_filename = NULL;
24205   int __pyx_clineno = 0;
24206   __Pyx_RefNannySetupContext("__Pyx_modinit_type_import_code", 0);
24207   /*--- Type import code ---*/
24208   __pyx_t_1 = PyImport_ImportModule(__Pyx_BUILTIN_MODULE_NAME); if (unlikely(!__pyx_t_1)) __PYX_ERR(3, 9, __pyx_L1_error)
24209   __Pyx_GOTREF(__pyx_t_1);
24210   __pyx_ptype_7cpython_4type_type = __Pyx_ImportType(__pyx_t_1, __Pyx_BUILTIN_MODULE_NAME, "type",
24211   #if defined(PYPY_VERSION_NUM) && PYPY_VERSION_NUM < 0x050B0000
24212   sizeof(PyTypeObject),
24213   #else
24214   sizeof(PyHeapTypeObject),
24215   #endif
24216   __Pyx_ImportType_CheckSize_Warn);
24217    if (!__pyx_ptype_7cpython_4type_type) __PYX_ERR(3, 9, __pyx_L1_error)
24218   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
24219   __pyx_t_1 = PyImport_ImportModule("numpy"); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 199, __pyx_L1_error)
24220   __Pyx_GOTREF(__pyx_t_1);
24221   __pyx_ptype_5numpy_dtype = __Pyx_ImportType(__pyx_t_1, "numpy", "dtype", sizeof(PyArray_Descr), __Pyx_ImportType_CheckSize_Ignore);
24222    if (!__pyx_ptype_5numpy_dtype) __PYX_ERR(1, 199, __pyx_L1_error)
24223   __pyx_ptype_5numpy_flatiter = __Pyx_ImportType(__pyx_t_1, "numpy", "flatiter", sizeof(PyArrayIterObject), __Pyx_ImportType_CheckSize_Ignore);
24224    if (!__pyx_ptype_5numpy_flatiter) __PYX_ERR(1, 222, __pyx_L1_error)
24225   __pyx_ptype_5numpy_broadcast = __Pyx_ImportType(__pyx_t_1, "numpy", "broadcast", sizeof(PyArrayMultiIterObject), __Pyx_ImportType_CheckSize_Ignore);
24226    if (!__pyx_ptype_5numpy_broadcast) __PYX_ERR(1, 226, __pyx_L1_error)
24227   __pyx_ptype_5numpy_ndarray = __Pyx_ImportType(__pyx_t_1, "numpy", "ndarray", sizeof(PyArrayObject), __Pyx_ImportType_CheckSize_Ignore);
24228    if (!__pyx_ptype_5numpy_ndarray) __PYX_ERR(1, 238, __pyx_L1_error)
24229   __pyx_ptype_5numpy_ufunc = __Pyx_ImportType(__pyx_t_1, "numpy", "ufunc", sizeof(PyUFuncObject), __Pyx_ImportType_CheckSize_Ignore);
24230    if (!__pyx_ptype_5numpy_ufunc) __PYX_ERR(1, 764, __pyx_L1_error)
24231   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
24232   __Pyx_RefNannyFinishContext();
24233   return 0;
24234   __pyx_L1_error:;
24235   __Pyx_XDECREF(__pyx_t_1);
24236   __Pyx_RefNannyFinishContext();
24237   return -1;
24238 }
24239 
__Pyx_modinit_variable_import_code(void)24240 static int __Pyx_modinit_variable_import_code(void) {
24241   __Pyx_RefNannyDeclarations
24242   __Pyx_RefNannySetupContext("__Pyx_modinit_variable_import_code", 0);
24243   /*--- Variable import code ---*/
24244   __Pyx_RefNannyFinishContext();
24245   return 0;
24246 }
24247 
__Pyx_modinit_function_import_code(void)24248 static int __Pyx_modinit_function_import_code(void) {
24249   __Pyx_RefNannyDeclarations
24250   __Pyx_RefNannySetupContext("__Pyx_modinit_function_import_code", 0);
24251   /*--- Function import code ---*/
24252   __Pyx_RefNannyFinishContext();
24253   return 0;
24254 }
24255 
24256 
24257 #ifndef CYTHON_NO_PYINIT_EXPORT
24258 #define __Pyx_PyMODINIT_FUNC PyMODINIT_FUNC
24259 #elif PY_MAJOR_VERSION < 3
24260 #ifdef __cplusplus
24261 #define __Pyx_PyMODINIT_FUNC extern "C" void
24262 #else
24263 #define __Pyx_PyMODINIT_FUNC void
24264 #endif
24265 #else
24266 #ifdef __cplusplus
24267 #define __Pyx_PyMODINIT_FUNC extern "C" PyObject *
24268 #else
24269 #define __Pyx_PyMODINIT_FUNC PyObject *
24270 #endif
24271 #endif
24272 
24273 
24274 #if PY_MAJOR_VERSION < 3
24275 __Pyx_PyMODINIT_FUNC initspmatfuncs(void) CYTHON_SMALL_CODE; /*proto*/
initspmatfuncs(void)24276 __Pyx_PyMODINIT_FUNC initspmatfuncs(void)
24277 #else
24278 __Pyx_PyMODINIT_FUNC PyInit_spmatfuncs(void) CYTHON_SMALL_CODE; /*proto*/
24279 __Pyx_PyMODINIT_FUNC PyInit_spmatfuncs(void)
24280 #if CYTHON_PEP489_MULTI_PHASE_INIT
24281 {
24282   return PyModuleDef_Init(&__pyx_moduledef);
24283 }
24284 static CYTHON_SMALL_CODE int __Pyx_check_single_interpreter(void) {
24285     #if PY_VERSION_HEX >= 0x030700A1
24286     static PY_INT64_T main_interpreter_id = -1;
24287     PY_INT64_T current_id = PyInterpreterState_GetID(PyThreadState_Get()->interp);
24288     if (main_interpreter_id == -1) {
24289         main_interpreter_id = current_id;
24290         return (unlikely(current_id == -1)) ? -1 : 0;
24291     } else if (unlikely(main_interpreter_id != current_id))
24292     #else
24293     static PyInterpreterState *main_interpreter = NULL;
24294     PyInterpreterState *current_interpreter = PyThreadState_Get()->interp;
24295     if (!main_interpreter) {
24296         main_interpreter = current_interpreter;
24297     } else if (unlikely(main_interpreter != current_interpreter))
24298     #endif
24299     {
24300         PyErr_SetString(
24301             PyExc_ImportError,
24302             "Interpreter change detected - this module can only be loaded into one interpreter per process.");
24303         return -1;
24304     }
24305     return 0;
24306 }
24307 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) {
24308     PyObject *value = PyObject_GetAttrString(spec, from_name);
24309     int result = 0;
24310     if (likely(value)) {
24311         if (allow_none || value != Py_None) {
24312             result = PyDict_SetItemString(moddict, to_name, value);
24313         }
24314         Py_DECREF(value);
24315     } else if (PyErr_ExceptionMatches(PyExc_AttributeError)) {
24316         PyErr_Clear();
24317     } else {
24318         result = -1;
24319     }
24320     return result;
24321 }
24322 static CYTHON_SMALL_CODE PyObject* __pyx_pymod_create(PyObject *spec, CYTHON_UNUSED PyModuleDef *def) {
24323     PyObject *module = NULL, *moddict, *modname;
24324     if (__Pyx_check_single_interpreter())
24325         return NULL;
24326     if (__pyx_m)
24327         return __Pyx_NewRef(__pyx_m);
24328     modname = PyObject_GetAttrString(spec, "name");
24329     if (unlikely(!modname)) goto bad;
24330     module = PyModule_NewObject(modname);
24331     Py_DECREF(modname);
24332     if (unlikely(!module)) goto bad;
24333     moddict = PyModule_GetDict(module);
24334     if (unlikely(!moddict)) goto bad;
24335     if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "loader", "__loader__", 1) < 0)) goto bad;
24336     if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "origin", "__file__", 1) < 0)) goto bad;
24337     if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "parent", "__package__", 1) < 0)) goto bad;
24338     if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "submodule_search_locations", "__path__", 0) < 0)) goto bad;
24339     return module;
24340 bad:
24341     Py_XDECREF(module);
24342     return NULL;
24343 }
24344 
24345 
24346 static CYTHON_SMALL_CODE int __pyx_pymod_exec_spmatfuncs(PyObject *__pyx_pyinit_module)
24347 #endif
24348 #endif
24349 {
24350   PyObject *__pyx_t_1 = NULL;
24351   static PyThread_type_lock __pyx_t_2[8];
24352   int __pyx_lineno = 0;
24353   const char *__pyx_filename = NULL;
24354   int __pyx_clineno = 0;
24355   __Pyx_RefNannyDeclarations
24356   #if CYTHON_PEP489_MULTI_PHASE_INIT
24357   if (__pyx_m) {
24358     if (__pyx_m == __pyx_pyinit_module) return 0;
24359     PyErr_SetString(PyExc_RuntimeError, "Module 'spmatfuncs' has already been imported. Re-initialisation is not supported.");
24360     return -1;
24361   }
24362   #elif PY_MAJOR_VERSION >= 3
24363   if (__pyx_m) return __Pyx_NewRef(__pyx_m);
24364   #endif
24365   #if CYTHON_REFNANNY
24366 __Pyx_RefNanny = __Pyx_RefNannyImportAPI("refnanny");
24367 if (!__Pyx_RefNanny) {
24368   PyErr_Clear();
24369   __Pyx_RefNanny = __Pyx_RefNannyImportAPI("Cython.Runtime.refnanny");
24370   if (!__Pyx_RefNanny)
24371       Py_FatalError("failed to import 'refnanny' module");
24372 }
24373 #endif
24374   __Pyx_RefNannySetupContext("__Pyx_PyMODINIT_FUNC PyInit_spmatfuncs(void)", 0);
24375   if (__Pyx_check_binary_version() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
24376   #ifdef __Pxy_PyFrame_Initialize_Offsets
24377   __Pxy_PyFrame_Initialize_Offsets();
24378   #endif
24379   __pyx_empty_tuple = PyTuple_New(0); if (unlikely(!__pyx_empty_tuple)) __PYX_ERR(0, 1, __pyx_L1_error)
24380   __pyx_empty_bytes = PyBytes_FromStringAndSize("", 0); if (unlikely(!__pyx_empty_bytes)) __PYX_ERR(0, 1, __pyx_L1_error)
24381   __pyx_empty_unicode = PyUnicode_FromStringAndSize("", 0); if (unlikely(!__pyx_empty_unicode)) __PYX_ERR(0, 1, __pyx_L1_error)
24382   #ifdef __Pyx_CyFunction_USED
24383   if (__pyx_CyFunction_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
24384   #endif
24385   #ifdef __Pyx_FusedFunction_USED
24386   if (__pyx_FusedFunction_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
24387   #endif
24388   #ifdef __Pyx_Coroutine_USED
24389   if (__pyx_Coroutine_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
24390   #endif
24391   #ifdef __Pyx_Generator_USED
24392   if (__pyx_Generator_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
24393   #endif
24394   #ifdef __Pyx_AsyncGen_USED
24395   if (__pyx_AsyncGen_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
24396   #endif
24397   #ifdef __Pyx_StopAsyncIteration_USED
24398   if (__pyx_StopAsyncIteration_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
24399   #endif
24400   /*--- Library function declarations ---*/
24401   /*--- Threads initialization code ---*/
24402   #if defined(__PYX_FORCE_INIT_THREADS) && __PYX_FORCE_INIT_THREADS
24403   #ifdef WITH_THREAD /* Python build with threading support? */
24404   PyEval_InitThreads();
24405   #endif
24406   #endif
24407   /*--- Module creation code ---*/
24408   #if CYTHON_PEP489_MULTI_PHASE_INIT
24409   __pyx_m = __pyx_pyinit_module;
24410   Py_INCREF(__pyx_m);
24411   #else
24412   #if PY_MAJOR_VERSION < 3
24413   __pyx_m = Py_InitModule4("spmatfuncs", __pyx_methods, 0, 0, PYTHON_API_VERSION); Py_XINCREF(__pyx_m);
24414   #else
24415   __pyx_m = PyModule_Create(&__pyx_moduledef);
24416   #endif
24417   if (unlikely(!__pyx_m)) __PYX_ERR(0, 1, __pyx_L1_error)
24418   #endif
24419   __pyx_d = PyModule_GetDict(__pyx_m); if (unlikely(!__pyx_d)) __PYX_ERR(0, 1, __pyx_L1_error)
24420   Py_INCREF(__pyx_d);
24421   __pyx_b = PyImport_AddModule(__Pyx_BUILTIN_MODULE_NAME); if (unlikely(!__pyx_b)) __PYX_ERR(0, 1, __pyx_L1_error)
24422   Py_INCREF(__pyx_b);
24423   __pyx_cython_runtime = PyImport_AddModule((char *) "cython_runtime"); if (unlikely(!__pyx_cython_runtime)) __PYX_ERR(0, 1, __pyx_L1_error)
24424   Py_INCREF(__pyx_cython_runtime);
24425   if (PyObject_SetAttrString(__pyx_m, "__builtins__", __pyx_b) < 0) __PYX_ERR(0, 1, __pyx_L1_error);
24426   /*--- Initialize various global constants etc. ---*/
24427   if (__Pyx_InitGlobals() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
24428   #if PY_MAJOR_VERSION < 3 && (__PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT)
24429   if (__Pyx_init_sys_getdefaultencoding_params() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
24430   #endif
24431   if (__pyx_module_is_main_qutip__cy__spmatfuncs) {
24432     if (PyObject_SetAttr(__pyx_m, __pyx_n_s_name_2, __pyx_n_s_main) < 0) __PYX_ERR(0, 1, __pyx_L1_error)
24433   }
24434   #if PY_MAJOR_VERSION >= 3
24435   {
24436     PyObject *modules = PyImport_GetModuleDict(); if (unlikely(!modules)) __PYX_ERR(0, 1, __pyx_L1_error)
24437     if (!PyDict_GetItemString(modules, "qutip.cy.spmatfuncs")) {
24438       if (unlikely(PyDict_SetItemString(modules, "qutip.cy.spmatfuncs", __pyx_m) < 0)) __PYX_ERR(0, 1, __pyx_L1_error)
24439     }
24440   }
24441   #endif
24442   /*--- Builtin init code ---*/
24443   if (__Pyx_InitCachedBuiltins() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
24444   /*--- Constants init code ---*/
24445   if (__Pyx_InitCachedConstants() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
24446   /*--- Global type/function init code ---*/
24447   (void)__Pyx_modinit_global_init_code();
24448   (void)__Pyx_modinit_variable_export_code();
24449   if (unlikely(__Pyx_modinit_function_export_code() < 0)) __PYX_ERR(0, 1, __pyx_L1_error)
24450   if (unlikely(__Pyx_modinit_type_init_code() < 0)) __PYX_ERR(0, 1, __pyx_L1_error)
24451   if (unlikely(__Pyx_modinit_type_import_code() < 0)) __PYX_ERR(0, 1, __pyx_L1_error)
24452   (void)__Pyx_modinit_variable_import_code();
24453   (void)__Pyx_modinit_function_import_code();
24454   /*--- Execution code ---*/
24455   #if defined(__Pyx_Generator_USED) || defined(__Pyx_Coroutine_USED)
24456   if (__Pyx_patch_abc() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
24457   #endif
24458 
24459   /* "qutip/cy/spmatfuncs.pyx":34
24460  * #    OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24461  * ###############################################################################
24462  * import numpy as np             # <<<<<<<<<<<<<<
24463  * cimport numpy as cnp
24464  * cimport cython
24465  */
24466   __pyx_t_1 = __Pyx_Import(__pyx_n_s_numpy, 0, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 34, __pyx_L1_error)
24467   __Pyx_GOTREF(__pyx_t_1);
24468   if (PyDict_SetItem(__pyx_d, __pyx_n_s_np, __pyx_t_1) < 0) __PYX_ERR(0, 34, __pyx_L1_error)
24469   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
24470 
24471   /* "qutip/cy/spmatfuncs.pyx":105
24472  * @cython.boundscheck(False)
24473  * @cython.wraparound(False)
24474  * def spmvpy_csr(complex[::1] data,             # <<<<<<<<<<<<<<
24475  *             int[::1] ind, int[::1] ptr, complex[::1] vec,
24476  *             complex alpha, complex[::1] out):
24477  */
24478   __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_5qutip_2cy_10spmatfuncs_5spmvpy_csr, NULL, __pyx_n_s_qutip_cy_spmatfuncs); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 105, __pyx_L1_error)
24479   __Pyx_GOTREF(__pyx_t_1);
24480   if (PyDict_SetItem(__pyx_d, __pyx_n_s_spmvpy_csr, __pyx_t_1) < 0) __PYX_ERR(0, 105, __pyx_L1_error)
24481   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
24482 
24483   /* "qutip/cy/spmatfuncs.pyx":495
24484  * @cython.boundscheck(False)
24485  * @cython.wraparound(False)
24486  * def expect_csr_ket(object A, object B, int isherm):             # <<<<<<<<<<<<<<
24487  *
24488  *     cdef complex[::1] Adata = A.data
24489  */
24490   __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_5qutip_2cy_10spmatfuncs_35expect_csr_ket, NULL, __pyx_n_s_qutip_cy_spmatfuncs); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 495, __pyx_L1_error)
24491   __Pyx_GOTREF(__pyx_t_1);
24492   if (PyDict_SetItem(__pyx_d, __pyx_n_s_expect_csr_ket, __pyx_t_1) < 0) __PYX_ERR(0, 495, __pyx_L1_error)
24493   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
24494 
24495   /* "qutip/cy/spmatfuncs.pyx":1
24496  * #cython: language_level=3             # <<<<<<<<<<<<<<
24497  * # This file is part of QuTiP: Quantum Toolbox in Python.
24498  * #
24499  */
24500   __pyx_t_1 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1, __pyx_L1_error)
24501   __Pyx_GOTREF(__pyx_t_1);
24502   if (PyDict_SetItem(__pyx_d, __pyx_n_s_test, __pyx_t_1) < 0) __PYX_ERR(0, 1, __pyx_L1_error)
24503   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
24504 
24505   /* "View.MemoryView":209
24506  *         info.obj = self
24507  *
24508  *     __pyx_getbuffer = capsule(<void *> &__pyx_array_getbuffer, "getbuffer(obj, view, flags)")             # <<<<<<<<<<<<<<
24509  *
24510  *     def __dealloc__(array self):
24511  */
24512   __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)
24513   __Pyx_GOTREF(__pyx_t_1);
24514   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)
24515   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
24516   PyType_Modified(__pyx_array_type);
24517 
24518   /* "View.MemoryView":286
24519  *         return self.name
24520  *
24521  * cdef generic = Enum("<strided and direct or indirect>")             # <<<<<<<<<<<<<<
24522  * cdef strided = Enum("<strided and direct>") # default
24523  * cdef indirect = Enum("<strided and indirect>")
24524  */
24525   __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)__pyx_MemviewEnum_type), __pyx_tuple__25, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 286, __pyx_L1_error)
24526   __Pyx_GOTREF(__pyx_t_1);
24527   __Pyx_XGOTREF(generic);
24528   __Pyx_DECREF_SET(generic, __pyx_t_1);
24529   __Pyx_GIVEREF(__pyx_t_1);
24530   __pyx_t_1 = 0;
24531 
24532   /* "View.MemoryView":287
24533  *
24534  * cdef generic = Enum("<strided and direct or indirect>")
24535  * cdef strided = Enum("<strided and direct>") # default             # <<<<<<<<<<<<<<
24536  * cdef indirect = Enum("<strided and indirect>")
24537  *
24538  */
24539   __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)__pyx_MemviewEnum_type), __pyx_tuple__26, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 287, __pyx_L1_error)
24540   __Pyx_GOTREF(__pyx_t_1);
24541   __Pyx_XGOTREF(strided);
24542   __Pyx_DECREF_SET(strided, __pyx_t_1);
24543   __Pyx_GIVEREF(__pyx_t_1);
24544   __pyx_t_1 = 0;
24545 
24546   /* "View.MemoryView":288
24547  * cdef generic = Enum("<strided and direct or indirect>")
24548  * cdef strided = Enum("<strided and direct>") # default
24549  * cdef indirect = Enum("<strided and indirect>")             # <<<<<<<<<<<<<<
24550  *
24551  *
24552  */
24553   __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)__pyx_MemviewEnum_type), __pyx_tuple__27, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 288, __pyx_L1_error)
24554   __Pyx_GOTREF(__pyx_t_1);
24555   __Pyx_XGOTREF(indirect);
24556   __Pyx_DECREF_SET(indirect, __pyx_t_1);
24557   __Pyx_GIVEREF(__pyx_t_1);
24558   __pyx_t_1 = 0;
24559 
24560   /* "View.MemoryView":291
24561  *
24562  *
24563  * cdef contiguous = Enum("<contiguous and direct>")             # <<<<<<<<<<<<<<
24564  * cdef indirect_contiguous = Enum("<contiguous and indirect>")
24565  *
24566  */
24567   __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)__pyx_MemviewEnum_type), __pyx_tuple__28, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 291, __pyx_L1_error)
24568   __Pyx_GOTREF(__pyx_t_1);
24569   __Pyx_XGOTREF(contiguous);
24570   __Pyx_DECREF_SET(contiguous, __pyx_t_1);
24571   __Pyx_GIVEREF(__pyx_t_1);
24572   __pyx_t_1 = 0;
24573 
24574   /* "View.MemoryView":292
24575  *
24576  * cdef contiguous = Enum("<contiguous and direct>")
24577  * cdef indirect_contiguous = Enum("<contiguous and indirect>")             # <<<<<<<<<<<<<<
24578  *
24579  *
24580  */
24581   __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)__pyx_MemviewEnum_type), __pyx_tuple__29, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 292, __pyx_L1_error)
24582   __Pyx_GOTREF(__pyx_t_1);
24583   __Pyx_XGOTREF(indirect_contiguous);
24584   __Pyx_DECREF_SET(indirect_contiguous, __pyx_t_1);
24585   __Pyx_GIVEREF(__pyx_t_1);
24586   __pyx_t_1 = 0;
24587 
24588   /* "View.MemoryView":316
24589  *
24590  * DEF THREAD_LOCKS_PREALLOCATED = 8
24591  * cdef int __pyx_memoryview_thread_locks_used = 0             # <<<<<<<<<<<<<<
24592  * cdef PyThread_type_lock[THREAD_LOCKS_PREALLOCATED] __pyx_memoryview_thread_locks = [
24593  *     PyThread_allocate_lock(),
24594  */
24595   __pyx_memoryview_thread_locks_used = 0;
24596 
24597   /* "View.MemoryView":317
24598  * DEF THREAD_LOCKS_PREALLOCATED = 8
24599  * cdef int __pyx_memoryview_thread_locks_used = 0
24600  * cdef PyThread_type_lock[THREAD_LOCKS_PREALLOCATED] __pyx_memoryview_thread_locks = [             # <<<<<<<<<<<<<<
24601  *     PyThread_allocate_lock(),
24602  *     PyThread_allocate_lock(),
24603  */
24604   __pyx_t_2[0] = PyThread_allocate_lock();
24605   __pyx_t_2[1] = PyThread_allocate_lock();
24606   __pyx_t_2[2] = PyThread_allocate_lock();
24607   __pyx_t_2[3] = PyThread_allocate_lock();
24608   __pyx_t_2[4] = PyThread_allocate_lock();
24609   __pyx_t_2[5] = PyThread_allocate_lock();
24610   __pyx_t_2[6] = PyThread_allocate_lock();
24611   __pyx_t_2[7] = PyThread_allocate_lock();
24612   memcpy(&(__pyx_memoryview_thread_locks[0]), __pyx_t_2, sizeof(__pyx_memoryview_thread_locks[0]) * (8));
24613 
24614   /* "View.MemoryView":549
24615  *         info.obj = self
24616  *
24617  *     __pyx_getbuffer = capsule(<void *> &__pyx_memoryview_getbuffer, "getbuffer(obj, view, flags)")             # <<<<<<<<<<<<<<
24618  *
24619  *
24620  */
24621   __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)
24622   __Pyx_GOTREF(__pyx_t_1);
24623   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)
24624   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
24625   PyType_Modified(__pyx_memoryview_type);
24626 
24627   /* "View.MemoryView":995
24628  *         return self.from_object
24629  *
24630  *     __pyx_getbuffer = capsule(<void *> &__pyx_memoryview_getbuffer, "getbuffer(obj, view, flags)")             # <<<<<<<<<<<<<<
24631  *
24632  *
24633  */
24634   __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)
24635   __Pyx_GOTREF(__pyx_t_1);
24636   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)
24637   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
24638   PyType_Modified(__pyx_memoryviewslice_type);
24639 
24640   /* "(tree fragment)":1
24641  * def __pyx_unpickle_Enum(__pyx_type, long __pyx_checksum, __pyx_state):             # <<<<<<<<<<<<<<
24642  *     cdef object __pyx_PickleError
24643  *     cdef object __pyx_result
24644  */
24645   __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)
24646   __Pyx_GOTREF(__pyx_t_1);
24647   if (PyDict_SetItem(__pyx_d, __pyx_n_s_pyx_unpickle_Enum, __pyx_t_1) < 0) __PYX_ERR(2, 1, __pyx_L1_error)
24648   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
24649 
24650   /* "(tree fragment)":11
24651  *         __pyx_unpickle_Enum__set_state(<Enum> __pyx_result, __pyx_state)
24652  *     return __pyx_result
24653  * cdef __pyx_unpickle_Enum__set_state(Enum __pyx_result, tuple __pyx_state):             # <<<<<<<<<<<<<<
24654  *     __pyx_result.name = __pyx_state[0]
24655  *     if len(__pyx_state) > 1 and hasattr(__pyx_result, '__dict__'):
24656  */
24657 
24658   /*--- Wrapped vars code ---*/
24659 
24660   goto __pyx_L0;
24661   __pyx_L1_error:;
24662   __Pyx_XDECREF(__pyx_t_1);
24663   if (__pyx_m) {
24664     if (__pyx_d) {
24665       __Pyx_AddTraceback("init qutip.cy.spmatfuncs", __pyx_clineno, __pyx_lineno, __pyx_filename);
24666     }
24667     Py_CLEAR(__pyx_m);
24668   } else if (!PyErr_Occurred()) {
24669     PyErr_SetString(PyExc_ImportError, "init qutip.cy.spmatfuncs");
24670   }
24671   __pyx_L0:;
24672   __Pyx_RefNannyFinishContext();
24673   #if CYTHON_PEP489_MULTI_PHASE_INIT
24674   return (__pyx_m != NULL) ? 0 : -1;
24675   #elif PY_MAJOR_VERSION >= 3
24676   return __pyx_m;
24677   #else
24678   return;
24679   #endif
24680 }
24681 
24682 /* --- Runtime support code --- */
24683 /* Refnanny */
24684 #if CYTHON_REFNANNY
__Pyx_RefNannyImportAPI(const char * modname)24685 static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname) {
24686     PyObject *m = NULL, *p = NULL;
24687     void *r = NULL;
24688     m = PyImport_ImportModule(modname);
24689     if (!m) goto end;
24690     p = PyObject_GetAttrString(m, "RefNannyAPI");
24691     if (!p) goto end;
24692     r = PyLong_AsVoidPtr(p);
24693 end:
24694     Py_XDECREF(p);
24695     Py_XDECREF(m);
24696     return (__Pyx_RefNannyAPIStruct *)r;
24697 }
24698 #endif
24699 
24700 /* PyObjectGetAttrStr */
24701 #if CYTHON_USE_TYPE_SLOTS
__Pyx_PyObject_GetAttrStr(PyObject * obj,PyObject * attr_name)24702 static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStr(PyObject* obj, PyObject* attr_name) {
24703     PyTypeObject* tp = Py_TYPE(obj);
24704     if (likely(tp->tp_getattro))
24705         return tp->tp_getattro(obj, attr_name);
24706 #if PY_MAJOR_VERSION < 3
24707     if (likely(tp->tp_getattr))
24708         return tp->tp_getattr(obj, PyString_AS_STRING(attr_name));
24709 #endif
24710     return PyObject_GetAttr(obj, attr_name);
24711 }
24712 #endif
24713 
24714 /* GetBuiltinName */
__Pyx_GetBuiltinName(PyObject * name)24715 static PyObject *__Pyx_GetBuiltinName(PyObject *name) {
24716     PyObject* result = __Pyx_PyObject_GetAttrStr(__pyx_b, name);
24717     if (unlikely(!result)) {
24718         PyErr_Format(PyExc_NameError,
24719 #if PY_MAJOR_VERSION >= 3
24720             "name '%U' is not defined", name);
24721 #else
24722             "name '%.200s' is not defined", PyString_AS_STRING(name));
24723 #endif
24724     }
24725     return result;
24726 }
24727 
24728 /* MemviewSliceInit */
24729 static int
__Pyx_init_memviewslice(struct __pyx_memoryview_obj * memview,int ndim,__Pyx_memviewslice * memviewslice,int memview_is_new_reference)24730 __Pyx_init_memviewslice(struct __pyx_memoryview_obj *memview,
24731                         int ndim,
24732                         __Pyx_memviewslice *memviewslice,
24733                         int memview_is_new_reference)
24734 {
24735     __Pyx_RefNannyDeclarations
24736     int i, retval=-1;
24737     Py_buffer *buf = &memview->view;
24738     __Pyx_RefNannySetupContext("init_memviewslice", 0);
24739     if (unlikely(memviewslice->memview || memviewslice->data)) {
24740         PyErr_SetString(PyExc_ValueError,
24741             "memviewslice is already initialized!");
24742         goto fail;
24743     }
24744     if (buf->strides) {
24745         for (i = 0; i < ndim; i++) {
24746             memviewslice->strides[i] = buf->strides[i];
24747         }
24748     } else {
24749         Py_ssize_t stride = buf->itemsize;
24750         for (i = ndim - 1; i >= 0; i--) {
24751             memviewslice->strides[i] = stride;
24752             stride *= buf->shape[i];
24753         }
24754     }
24755     for (i = 0; i < ndim; i++) {
24756         memviewslice->shape[i]   = buf->shape[i];
24757         if (buf->suboffsets) {
24758             memviewslice->suboffsets[i] = buf->suboffsets[i];
24759         } else {
24760             memviewslice->suboffsets[i] = -1;
24761         }
24762     }
24763     memviewslice->memview = memview;
24764     memviewslice->data = (char *)buf->buf;
24765     if (__pyx_add_acquisition_count(memview) == 0 && !memview_is_new_reference) {
24766         Py_INCREF(memview);
24767     }
24768     retval = 0;
24769     goto no_fail;
24770 fail:
24771     memviewslice->memview = 0;
24772     memviewslice->data = 0;
24773     retval = -1;
24774 no_fail:
24775     __Pyx_RefNannyFinishContext();
24776     return retval;
24777 }
24778 #ifndef Py_NO_RETURN
24779 #define Py_NO_RETURN
24780 #endif
__pyx_fatalerror(const char * fmt,...)24781 static void __pyx_fatalerror(const char *fmt, ...) Py_NO_RETURN {
24782     va_list vargs;
24783     char msg[200];
24784 #ifdef HAVE_STDARG_PROTOTYPES
24785     va_start(vargs, fmt);
24786 #else
24787     va_start(vargs);
24788 #endif
24789     vsnprintf(msg, 200, fmt, vargs);
24790     va_end(vargs);
24791     Py_FatalError(msg);
24792 }
24793 static CYTHON_INLINE int
__pyx_add_acquisition_count_locked(__pyx_atomic_int * acquisition_count,PyThread_type_lock lock)24794 __pyx_add_acquisition_count_locked(__pyx_atomic_int *acquisition_count,
24795                                    PyThread_type_lock lock)
24796 {
24797     int result;
24798     PyThread_acquire_lock(lock, 1);
24799     result = (*acquisition_count)++;
24800     PyThread_release_lock(lock);
24801     return result;
24802 }
24803 static CYTHON_INLINE int
__pyx_sub_acquisition_count_locked(__pyx_atomic_int * acquisition_count,PyThread_type_lock lock)24804 __pyx_sub_acquisition_count_locked(__pyx_atomic_int *acquisition_count,
24805                                    PyThread_type_lock lock)
24806 {
24807     int result;
24808     PyThread_acquire_lock(lock, 1);
24809     result = (*acquisition_count)--;
24810     PyThread_release_lock(lock);
24811     return result;
24812 }
24813 static CYTHON_INLINE void
__Pyx_INC_MEMVIEW(__Pyx_memviewslice * memslice,int have_gil,int lineno)24814 __Pyx_INC_MEMVIEW(__Pyx_memviewslice *memslice, int have_gil, int lineno)
24815 {
24816     int first_time;
24817     struct __pyx_memoryview_obj *memview = memslice->memview;
24818     if (unlikely(!memview || (PyObject *) memview == Py_None))
24819         return;
24820     if (unlikely(__pyx_get_slice_count(memview) < 0))
24821         __pyx_fatalerror("Acquisition count is %d (line %d)",
24822                          __pyx_get_slice_count(memview), lineno);
24823     first_time = __pyx_add_acquisition_count(memview) == 0;
24824     if (unlikely(first_time)) {
24825         if (have_gil) {
24826             Py_INCREF((PyObject *) memview);
24827         } else {
24828             PyGILState_STATE _gilstate = PyGILState_Ensure();
24829             Py_INCREF((PyObject *) memview);
24830             PyGILState_Release(_gilstate);
24831         }
24832     }
24833 }
__Pyx_XDEC_MEMVIEW(__Pyx_memviewslice * memslice,int have_gil,int lineno)24834 static CYTHON_INLINE void __Pyx_XDEC_MEMVIEW(__Pyx_memviewslice *memslice,
24835                                              int have_gil, int lineno) {
24836     int last_time;
24837     struct __pyx_memoryview_obj *memview = memslice->memview;
24838     if (unlikely(!memview || (PyObject *) memview == Py_None)) {
24839         memslice->memview = NULL;
24840         return;
24841     }
24842     if (unlikely(__pyx_get_slice_count(memview) <= 0))
24843         __pyx_fatalerror("Acquisition count is %d (line %d)",
24844                          __pyx_get_slice_count(memview), lineno);
24845     last_time = __pyx_sub_acquisition_count(memview) == 1;
24846     memslice->data = NULL;
24847     if (unlikely(last_time)) {
24848         if (have_gil) {
24849             Py_CLEAR(memslice->memview);
24850         } else {
24851             PyGILState_STATE _gilstate = PyGILState_Ensure();
24852             Py_CLEAR(memslice->memview);
24853             PyGILState_Release(_gilstate);
24854         }
24855     } else {
24856         memslice->memview = NULL;
24857     }
24858 }
24859 
24860 /* RaiseArgTupleInvalid */
__Pyx_RaiseArgtupleInvalid(const char * func_name,int exact,Py_ssize_t num_min,Py_ssize_t num_max,Py_ssize_t num_found)24861 static void __Pyx_RaiseArgtupleInvalid(
24862     const char* func_name,
24863     int exact,
24864     Py_ssize_t num_min,
24865     Py_ssize_t num_max,
24866     Py_ssize_t num_found)
24867 {
24868     Py_ssize_t num_expected;
24869     const char *more_or_less;
24870     if (num_found < num_min) {
24871         num_expected = num_min;
24872         more_or_less = "at least";
24873     } else {
24874         num_expected = num_max;
24875         more_or_less = "at most";
24876     }
24877     if (exact) {
24878         more_or_less = "exactly";
24879     }
24880     PyErr_Format(PyExc_TypeError,
24881                  "%.200s() takes %.8s %" CYTHON_FORMAT_SSIZE_T "d positional argument%.1s (%" CYTHON_FORMAT_SSIZE_T "d given)",
24882                  func_name, more_or_less, num_expected,
24883                  (num_expected == 1) ? "" : "s", num_found);
24884 }
24885 
24886 /* RaiseDoubleKeywords */
__Pyx_RaiseDoubleKeywordsError(const char * func_name,PyObject * kw_name)24887 static void __Pyx_RaiseDoubleKeywordsError(
24888     const char* func_name,
24889     PyObject* kw_name)
24890 {
24891     PyErr_Format(PyExc_TypeError,
24892         #if PY_MAJOR_VERSION >= 3
24893         "%s() got multiple values for keyword argument '%U'", func_name, kw_name);
24894         #else
24895         "%s() got multiple values for keyword argument '%s'", func_name,
24896         PyString_AsString(kw_name));
24897         #endif
24898 }
24899 
24900 /* ParseKeywords */
__Pyx_ParseOptionalKeywords(PyObject * kwds,PyObject ** argnames[],PyObject * kwds2,PyObject * values[],Py_ssize_t num_pos_args,const char * function_name)24901 static int __Pyx_ParseOptionalKeywords(
24902     PyObject *kwds,
24903     PyObject **argnames[],
24904     PyObject *kwds2,
24905     PyObject *values[],
24906     Py_ssize_t num_pos_args,
24907     const char* function_name)
24908 {
24909     PyObject *key = 0, *value = 0;
24910     Py_ssize_t pos = 0;
24911     PyObject*** name;
24912     PyObject*** first_kw_arg = argnames + num_pos_args;
24913     while (PyDict_Next(kwds, &pos, &key, &value)) {
24914         name = first_kw_arg;
24915         while (*name && (**name != key)) name++;
24916         if (*name) {
24917             values[name-argnames] = value;
24918             continue;
24919         }
24920         name = first_kw_arg;
24921         #if PY_MAJOR_VERSION < 3
24922         if (likely(PyString_Check(key))) {
24923             while (*name) {
24924                 if ((CYTHON_COMPILING_IN_PYPY || PyString_GET_SIZE(**name) == PyString_GET_SIZE(key))
24925                         && _PyString_Eq(**name, key)) {
24926                     values[name-argnames] = value;
24927                     break;
24928                 }
24929                 name++;
24930             }
24931             if (*name) continue;
24932             else {
24933                 PyObject*** argname = argnames;
24934                 while (argname != first_kw_arg) {
24935                     if ((**argname == key) || (
24936                             (CYTHON_COMPILING_IN_PYPY || PyString_GET_SIZE(**argname) == PyString_GET_SIZE(key))
24937                              && _PyString_Eq(**argname, key))) {
24938                         goto arg_passed_twice;
24939                     }
24940                     argname++;
24941                 }
24942             }
24943         } else
24944         #endif
24945         if (likely(PyUnicode_Check(key))) {
24946             while (*name) {
24947                 int cmp = (**name == key) ? 0 :
24948                 #if !CYTHON_COMPILING_IN_PYPY && PY_MAJOR_VERSION >= 3
24949                     (__Pyx_PyUnicode_GET_LENGTH(**name) != __Pyx_PyUnicode_GET_LENGTH(key)) ? 1 :
24950                 #endif
24951                     PyUnicode_Compare(**name, key);
24952                 if (cmp < 0 && unlikely(PyErr_Occurred())) goto bad;
24953                 if (cmp == 0) {
24954                     values[name-argnames] = value;
24955                     break;
24956                 }
24957                 name++;
24958             }
24959             if (*name) continue;
24960             else {
24961                 PyObject*** argname = argnames;
24962                 while (argname != first_kw_arg) {
24963                     int cmp = (**argname == key) ? 0 :
24964                     #if !CYTHON_COMPILING_IN_PYPY && PY_MAJOR_VERSION >= 3
24965                         (__Pyx_PyUnicode_GET_LENGTH(**argname) != __Pyx_PyUnicode_GET_LENGTH(key)) ? 1 :
24966                     #endif
24967                         PyUnicode_Compare(**argname, key);
24968                     if (cmp < 0 && unlikely(PyErr_Occurred())) goto bad;
24969                     if (cmp == 0) goto arg_passed_twice;
24970                     argname++;
24971                 }
24972             }
24973         } else
24974             goto invalid_keyword_type;
24975         if (kwds2) {
24976             if (unlikely(PyDict_SetItem(kwds2, key, value))) goto bad;
24977         } else {
24978             goto invalid_keyword;
24979         }
24980     }
24981     return 0;
24982 arg_passed_twice:
24983     __Pyx_RaiseDoubleKeywordsError(function_name, key);
24984     goto bad;
24985 invalid_keyword_type:
24986     PyErr_Format(PyExc_TypeError,
24987         "%.200s() keywords must be strings", function_name);
24988     goto bad;
24989 invalid_keyword:
24990     PyErr_Format(PyExc_TypeError,
24991     #if PY_MAJOR_VERSION < 3
24992         "%.200s() got an unexpected keyword argument '%.200s'",
24993         function_name, PyString_AsString(key));
24994     #else
24995         "%s() got an unexpected keyword argument '%U'",
24996         function_name, key);
24997     #endif
24998 bad:
24999     return -1;
25000 }
25001 
25002 /* None */
__Pyx_RaiseUnboundLocalError(const char * varname)25003 static CYTHON_INLINE void __Pyx_RaiseUnboundLocalError(const char *varname) {
25004     PyErr_Format(PyExc_UnboundLocalError, "local variable '%s' referenced before assignment", varname);
25005 }
25006 
25007 /* PyDictVersioning */
25008 #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_TYPE_SLOTS
__Pyx_get_tp_dict_version(PyObject * obj)25009 static CYTHON_INLINE PY_UINT64_T __Pyx_get_tp_dict_version(PyObject *obj) {
25010     PyObject *dict = Py_TYPE(obj)->tp_dict;
25011     return likely(dict) ? __PYX_GET_DICT_VERSION(dict) : 0;
25012 }
__Pyx_get_object_dict_version(PyObject * obj)25013 static CYTHON_INLINE PY_UINT64_T __Pyx_get_object_dict_version(PyObject *obj) {
25014     PyObject **dictptr = NULL;
25015     Py_ssize_t offset = Py_TYPE(obj)->tp_dictoffset;
25016     if (offset) {
25017 #if CYTHON_COMPILING_IN_CPYTHON
25018         dictptr = (likely(offset > 0)) ? (PyObject **) ((char *)obj + offset) : _PyObject_GetDictPtr(obj);
25019 #else
25020         dictptr = _PyObject_GetDictPtr(obj);
25021 #endif
25022     }
25023     return (dictptr && *dictptr) ? __PYX_GET_DICT_VERSION(*dictptr) : 0;
25024 }
__Pyx_object_dict_version_matches(PyObject * obj,PY_UINT64_T tp_dict_version,PY_UINT64_T obj_dict_version)25025 static CYTHON_INLINE int __Pyx_object_dict_version_matches(PyObject* obj, PY_UINT64_T tp_dict_version, PY_UINT64_T obj_dict_version) {
25026     PyObject *dict = Py_TYPE(obj)->tp_dict;
25027     if (unlikely(!dict) || unlikely(tp_dict_version != __PYX_GET_DICT_VERSION(dict)))
25028         return 0;
25029     return obj_dict_version == __Pyx_get_object_dict_version(obj);
25030 }
25031 #endif
25032 
25033 /* GetModuleGlobalName */
25034 #if CYTHON_USE_DICT_VERSIONS
__Pyx__GetModuleGlobalName(PyObject * name,PY_UINT64_T * dict_version,PyObject ** dict_cached_value)25035 static PyObject *__Pyx__GetModuleGlobalName(PyObject *name, PY_UINT64_T *dict_version, PyObject **dict_cached_value)
25036 #else
25037 static CYTHON_INLINE PyObject *__Pyx__GetModuleGlobalName(PyObject *name)
25038 #endif
25039 {
25040     PyObject *result;
25041 #if !CYTHON_AVOID_BORROWED_REFS
25042 #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030500A1
25043     result = _PyDict_GetItem_KnownHash(__pyx_d, name, ((PyASCIIObject *) name)->hash);
25044     __PYX_UPDATE_DICT_CACHE(__pyx_d, result, *dict_cached_value, *dict_version)
25045     if (likely(result)) {
25046         return __Pyx_NewRef(result);
25047     } else if (unlikely(PyErr_Occurred())) {
25048         return NULL;
25049     }
25050 #else
25051     result = PyDict_GetItem(__pyx_d, name);
25052     __PYX_UPDATE_DICT_CACHE(__pyx_d, result, *dict_cached_value, *dict_version)
25053     if (likely(result)) {
25054         return __Pyx_NewRef(result);
25055     }
25056 #endif
25057 #else
25058     result = PyObject_GetItem(__pyx_d, name);
25059     __PYX_UPDATE_DICT_CACHE(__pyx_d, result, *dict_cached_value, *dict_version)
25060     if (likely(result)) {
25061         return __Pyx_NewRef(result);
25062     }
25063     PyErr_Clear();
25064 #endif
25065     return __Pyx_GetBuiltinName(name);
25066 }
25067 
25068 /* PyObjectCall */
25069 #if CYTHON_COMPILING_IN_CPYTHON
__Pyx_PyObject_Call(PyObject * func,PyObject * arg,PyObject * kw)25070 static CYTHON_INLINE PyObject* __Pyx_PyObject_Call(PyObject *func, PyObject *arg, PyObject *kw) {
25071     PyObject *result;
25072     ternaryfunc call = func->ob_type->tp_call;
25073     if (unlikely(!call))
25074         return PyObject_Call(func, arg, kw);
25075     if (unlikely(Py_EnterRecursiveCall((char*)" while calling a Python object")))
25076         return NULL;
25077     result = (*call)(func, arg, kw);
25078     Py_LeaveRecursiveCall();
25079     if (unlikely(!result) && unlikely(!PyErr_Occurred())) {
25080         PyErr_SetString(
25081             PyExc_SystemError,
25082             "NULL result without error in PyObject_Call");
25083     }
25084     return result;
25085 }
25086 #endif
25087 
25088 /* ExtTypeTest */
__Pyx_TypeTest(PyObject * obj,PyTypeObject * type)25089 static CYTHON_INLINE int __Pyx_TypeTest(PyObject *obj, PyTypeObject *type) {
25090     if (unlikely(!type)) {
25091         PyErr_SetString(PyExc_SystemError, "Missing type object");
25092         return 0;
25093     }
25094     if (likely(__Pyx_TypeCheck(obj, type)))
25095         return 1;
25096     PyErr_Format(PyExc_TypeError, "Cannot convert %.200s to %.200s",
25097                  Py_TYPE(obj)->tp_name, type->tp_name);
25098     return 0;
25099 }
25100 
25101 /* IsLittleEndian */
__Pyx_Is_Little_Endian(void)25102 static CYTHON_INLINE int __Pyx_Is_Little_Endian(void)
25103 {
25104   union {
25105     uint32_t u32;
25106     uint8_t u8[4];
25107   } S;
25108   S.u32 = 0x01020304;
25109   return S.u8[0] == 4;
25110 }
25111 
25112 /* BufferFormatCheck */
__Pyx_BufFmt_Init(__Pyx_BufFmt_Context * ctx,__Pyx_BufFmt_StackElem * stack,__Pyx_TypeInfo * type)25113 static void __Pyx_BufFmt_Init(__Pyx_BufFmt_Context* ctx,
25114                               __Pyx_BufFmt_StackElem* stack,
25115                               __Pyx_TypeInfo* type) {
25116   stack[0].field = &ctx->root;
25117   stack[0].parent_offset = 0;
25118   ctx->root.type = type;
25119   ctx->root.name = "buffer dtype";
25120   ctx->root.offset = 0;
25121   ctx->head = stack;
25122   ctx->head->field = &ctx->root;
25123   ctx->fmt_offset = 0;
25124   ctx->head->parent_offset = 0;
25125   ctx->new_packmode = '@';
25126   ctx->enc_packmode = '@';
25127   ctx->new_count = 1;
25128   ctx->enc_count = 0;
25129   ctx->enc_type = 0;
25130   ctx->is_complex = 0;
25131   ctx->is_valid_array = 0;
25132   ctx->struct_alignment = 0;
25133   while (type->typegroup == 'S') {
25134     ++ctx->head;
25135     ctx->head->field = type->fields;
25136     ctx->head->parent_offset = 0;
25137     type = type->fields->type;
25138   }
25139 }
__Pyx_BufFmt_ParseNumber(const char ** ts)25140 static int __Pyx_BufFmt_ParseNumber(const char** ts) {
25141     int count;
25142     const char* t = *ts;
25143     if (*t < '0' || *t > '9') {
25144       return -1;
25145     } else {
25146         count = *t++ - '0';
25147         while (*t >= '0' && *t <= '9') {
25148             count *= 10;
25149             count += *t++ - '0';
25150         }
25151     }
25152     *ts = t;
25153     return count;
25154 }
__Pyx_BufFmt_ExpectNumber(const char ** ts)25155 static int __Pyx_BufFmt_ExpectNumber(const char **ts) {
25156     int number = __Pyx_BufFmt_ParseNumber(ts);
25157     if (number == -1)
25158         PyErr_Format(PyExc_ValueError,\
25159                      "Does not understand character buffer dtype format string ('%c')", **ts);
25160     return number;
25161 }
__Pyx_BufFmt_RaiseUnexpectedChar(char ch)25162 static void __Pyx_BufFmt_RaiseUnexpectedChar(char ch) {
25163   PyErr_Format(PyExc_ValueError,
25164                "Unexpected format string character: '%c'", ch);
25165 }
__Pyx_BufFmt_DescribeTypeChar(char ch,int is_complex)25166 static const char* __Pyx_BufFmt_DescribeTypeChar(char ch, int is_complex) {
25167   switch (ch) {
25168     case '?': return "'bool'";
25169     case 'c': return "'char'";
25170     case 'b': return "'signed char'";
25171     case 'B': return "'unsigned char'";
25172     case 'h': return "'short'";
25173     case 'H': return "'unsigned short'";
25174     case 'i': return "'int'";
25175     case 'I': return "'unsigned int'";
25176     case 'l': return "'long'";
25177     case 'L': return "'unsigned long'";
25178     case 'q': return "'long long'";
25179     case 'Q': return "'unsigned long long'";
25180     case 'f': return (is_complex ? "'complex float'" : "'float'");
25181     case 'd': return (is_complex ? "'complex double'" : "'double'");
25182     case 'g': return (is_complex ? "'complex long double'" : "'long double'");
25183     case 'T': return "a struct";
25184     case 'O': return "Python object";
25185     case 'P': return "a pointer";
25186     case 's': case 'p': return "a string";
25187     case 0: return "end";
25188     default: return "unparseable format string";
25189   }
25190 }
__Pyx_BufFmt_TypeCharToStandardSize(char ch,int is_complex)25191 static size_t __Pyx_BufFmt_TypeCharToStandardSize(char ch, int is_complex) {
25192   switch (ch) {
25193     case '?': case 'c': case 'b': case 'B': case 's': case 'p': return 1;
25194     case 'h': case 'H': return 2;
25195     case 'i': case 'I': case 'l': case 'L': return 4;
25196     case 'q': case 'Q': return 8;
25197     case 'f': return (is_complex ? 8 : 4);
25198     case 'd': return (is_complex ? 16 : 8);
25199     case 'g': {
25200       PyErr_SetString(PyExc_ValueError, "Python does not define a standard format string size for long double ('g')..");
25201       return 0;
25202     }
25203     case 'O': case 'P': return sizeof(void*);
25204     default:
25205       __Pyx_BufFmt_RaiseUnexpectedChar(ch);
25206       return 0;
25207     }
25208 }
__Pyx_BufFmt_TypeCharToNativeSize(char ch,int is_complex)25209 static size_t __Pyx_BufFmt_TypeCharToNativeSize(char ch, int is_complex) {
25210   switch (ch) {
25211     case '?': case 'c': case 'b': case 'B': case 's': case 'p': return 1;
25212     case 'h': case 'H': return sizeof(short);
25213     case 'i': case 'I': return sizeof(int);
25214     case 'l': case 'L': return sizeof(long);
25215     #ifdef HAVE_LONG_LONG
25216     case 'q': case 'Q': return sizeof(PY_LONG_LONG);
25217     #endif
25218     case 'f': return sizeof(float) * (is_complex ? 2 : 1);
25219     case 'd': return sizeof(double) * (is_complex ? 2 : 1);
25220     case 'g': return sizeof(long double) * (is_complex ? 2 : 1);
25221     case 'O': case 'P': return sizeof(void*);
25222     default: {
25223       __Pyx_BufFmt_RaiseUnexpectedChar(ch);
25224       return 0;
25225     }
25226   }
25227 }
25228 typedef struct { char c; short x; } __Pyx_st_short;
25229 typedef struct { char c; int x; } __Pyx_st_int;
25230 typedef struct { char c; long x; } __Pyx_st_long;
25231 typedef struct { char c; float x; } __Pyx_st_float;
25232 typedef struct { char c; double x; } __Pyx_st_double;
25233 typedef struct { char c; long double x; } __Pyx_st_longdouble;
25234 typedef struct { char c; void *x; } __Pyx_st_void_p;
25235 #ifdef HAVE_LONG_LONG
25236 typedef struct { char c; PY_LONG_LONG x; } __Pyx_st_longlong;
25237 #endif
__Pyx_BufFmt_TypeCharToAlignment(char ch,CYTHON_UNUSED int is_complex)25238 static size_t __Pyx_BufFmt_TypeCharToAlignment(char ch, CYTHON_UNUSED int is_complex) {
25239   switch (ch) {
25240     case '?': case 'c': case 'b': case 'B': case 's': case 'p': return 1;
25241     case 'h': case 'H': return sizeof(__Pyx_st_short) - sizeof(short);
25242     case 'i': case 'I': return sizeof(__Pyx_st_int) - sizeof(int);
25243     case 'l': case 'L': return sizeof(__Pyx_st_long) - sizeof(long);
25244 #ifdef HAVE_LONG_LONG
25245     case 'q': case 'Q': return sizeof(__Pyx_st_longlong) - sizeof(PY_LONG_LONG);
25246 #endif
25247     case 'f': return sizeof(__Pyx_st_float) - sizeof(float);
25248     case 'd': return sizeof(__Pyx_st_double) - sizeof(double);
25249     case 'g': return sizeof(__Pyx_st_longdouble) - sizeof(long double);
25250     case 'P': case 'O': return sizeof(__Pyx_st_void_p) - sizeof(void*);
25251     default:
25252       __Pyx_BufFmt_RaiseUnexpectedChar(ch);
25253       return 0;
25254     }
25255 }
25256 /* These are for computing the padding at the end of the struct to align
25257    on the first member of the struct. This will probably the same as above,
25258    but we don't have any guarantees.
25259  */
25260 typedef struct { short x; char c; } __Pyx_pad_short;
25261 typedef struct { int x; char c; } __Pyx_pad_int;
25262 typedef struct { long x; char c; } __Pyx_pad_long;
25263 typedef struct { float x; char c; } __Pyx_pad_float;
25264 typedef struct { double x; char c; } __Pyx_pad_double;
25265 typedef struct { long double x; char c; } __Pyx_pad_longdouble;
25266 typedef struct { void *x; char c; } __Pyx_pad_void_p;
25267 #ifdef HAVE_LONG_LONG
25268 typedef struct { PY_LONG_LONG x; char c; } __Pyx_pad_longlong;
25269 #endif
__Pyx_BufFmt_TypeCharToPadding(char ch,CYTHON_UNUSED int is_complex)25270 static size_t __Pyx_BufFmt_TypeCharToPadding(char ch, CYTHON_UNUSED int is_complex) {
25271   switch (ch) {
25272     case '?': case 'c': case 'b': case 'B': case 's': case 'p': return 1;
25273     case 'h': case 'H': return sizeof(__Pyx_pad_short) - sizeof(short);
25274     case 'i': case 'I': return sizeof(__Pyx_pad_int) - sizeof(int);
25275     case 'l': case 'L': return sizeof(__Pyx_pad_long) - sizeof(long);
25276 #ifdef HAVE_LONG_LONG
25277     case 'q': case 'Q': return sizeof(__Pyx_pad_longlong) - sizeof(PY_LONG_LONG);
25278 #endif
25279     case 'f': return sizeof(__Pyx_pad_float) - sizeof(float);
25280     case 'd': return sizeof(__Pyx_pad_double) - sizeof(double);
25281     case 'g': return sizeof(__Pyx_pad_longdouble) - sizeof(long double);
25282     case 'P': case 'O': return sizeof(__Pyx_pad_void_p) - sizeof(void*);
25283     default:
25284       __Pyx_BufFmt_RaiseUnexpectedChar(ch);
25285       return 0;
25286     }
25287 }
__Pyx_BufFmt_TypeCharToGroup(char ch,int is_complex)25288 static char __Pyx_BufFmt_TypeCharToGroup(char ch, int is_complex) {
25289   switch (ch) {
25290     case 'c':
25291         return 'H';
25292     case 'b': case 'h': case 'i':
25293     case 'l': case 'q': case 's': case 'p':
25294         return 'I';
25295     case '?': case 'B': case 'H': case 'I': case 'L': case 'Q':
25296         return 'U';
25297     case 'f': case 'd': case 'g':
25298         return (is_complex ? 'C' : 'R');
25299     case 'O':
25300         return 'O';
25301     case 'P':
25302         return 'P';
25303     default: {
25304       __Pyx_BufFmt_RaiseUnexpectedChar(ch);
25305       return 0;
25306     }
25307   }
25308 }
__Pyx_BufFmt_RaiseExpected(__Pyx_BufFmt_Context * ctx)25309 static void __Pyx_BufFmt_RaiseExpected(__Pyx_BufFmt_Context* ctx) {
25310   if (ctx->head == NULL || ctx->head->field == &ctx->root) {
25311     const char* expected;
25312     const char* quote;
25313     if (ctx->head == NULL) {
25314       expected = "end";
25315       quote = "";
25316     } else {
25317       expected = ctx->head->field->type->name;
25318       quote = "'";
25319     }
25320     PyErr_Format(PyExc_ValueError,
25321                  "Buffer dtype mismatch, expected %s%s%s but got %s",
25322                  quote, expected, quote,
25323                  __Pyx_BufFmt_DescribeTypeChar(ctx->enc_type, ctx->is_complex));
25324   } else {
25325     __Pyx_StructField* field = ctx->head->field;
25326     __Pyx_StructField* parent = (ctx->head - 1)->field;
25327     PyErr_Format(PyExc_ValueError,
25328                  "Buffer dtype mismatch, expected '%s' but got %s in '%s.%s'",
25329                  field->type->name, __Pyx_BufFmt_DescribeTypeChar(ctx->enc_type, ctx->is_complex),
25330                  parent->type->name, field->name);
25331   }
25332 }
__Pyx_BufFmt_ProcessTypeChunk(__Pyx_BufFmt_Context * ctx)25333 static int __Pyx_BufFmt_ProcessTypeChunk(__Pyx_BufFmt_Context* ctx) {
25334   char group;
25335   size_t size, offset, arraysize = 1;
25336   if (ctx->enc_type == 0) return 0;
25337   if (ctx->head->field->type->arraysize[0]) {
25338     int i, ndim = 0;
25339     if (ctx->enc_type == 's' || ctx->enc_type == 'p') {
25340         ctx->is_valid_array = ctx->head->field->type->ndim == 1;
25341         ndim = 1;
25342         if (ctx->enc_count != ctx->head->field->type->arraysize[0]) {
25343             PyErr_Format(PyExc_ValueError,
25344                          "Expected a dimension of size %zu, got %zu",
25345                          ctx->head->field->type->arraysize[0], ctx->enc_count);
25346             return -1;
25347         }
25348     }
25349     if (!ctx->is_valid_array) {
25350       PyErr_Format(PyExc_ValueError, "Expected %d dimensions, got %d",
25351                    ctx->head->field->type->ndim, ndim);
25352       return -1;
25353     }
25354     for (i = 0; i < ctx->head->field->type->ndim; i++) {
25355       arraysize *= ctx->head->field->type->arraysize[i];
25356     }
25357     ctx->is_valid_array = 0;
25358     ctx->enc_count = 1;
25359   }
25360   group = __Pyx_BufFmt_TypeCharToGroup(ctx->enc_type, ctx->is_complex);
25361   do {
25362     __Pyx_StructField* field = ctx->head->field;
25363     __Pyx_TypeInfo* type = field->type;
25364     if (ctx->enc_packmode == '@' || ctx->enc_packmode == '^') {
25365       size = __Pyx_BufFmt_TypeCharToNativeSize(ctx->enc_type, ctx->is_complex);
25366     } else {
25367       size = __Pyx_BufFmt_TypeCharToStandardSize(ctx->enc_type, ctx->is_complex);
25368     }
25369     if (ctx->enc_packmode == '@') {
25370       size_t align_at = __Pyx_BufFmt_TypeCharToAlignment(ctx->enc_type, ctx->is_complex);
25371       size_t align_mod_offset;
25372       if (align_at == 0) return -1;
25373       align_mod_offset = ctx->fmt_offset % align_at;
25374       if (align_mod_offset > 0) ctx->fmt_offset += align_at - align_mod_offset;
25375       if (ctx->struct_alignment == 0)
25376           ctx->struct_alignment = __Pyx_BufFmt_TypeCharToPadding(ctx->enc_type,
25377                                                                  ctx->is_complex);
25378     }
25379     if (type->size != size || type->typegroup != group) {
25380       if (type->typegroup == 'C' && type->fields != NULL) {
25381         size_t parent_offset = ctx->head->parent_offset + field->offset;
25382         ++ctx->head;
25383         ctx->head->field = type->fields;
25384         ctx->head->parent_offset = parent_offset;
25385         continue;
25386       }
25387       if ((type->typegroup == 'H' || group == 'H') && type->size == size) {
25388       } else {
25389           __Pyx_BufFmt_RaiseExpected(ctx);
25390           return -1;
25391       }
25392     }
25393     offset = ctx->head->parent_offset + field->offset;
25394     if (ctx->fmt_offset != offset) {
25395       PyErr_Format(PyExc_ValueError,
25396                    "Buffer dtype mismatch; next field is at offset %" CYTHON_FORMAT_SSIZE_T "d but %" CYTHON_FORMAT_SSIZE_T "d expected",
25397                    (Py_ssize_t)ctx->fmt_offset, (Py_ssize_t)offset);
25398       return -1;
25399     }
25400     ctx->fmt_offset += size;
25401     if (arraysize)
25402       ctx->fmt_offset += (arraysize - 1) * size;
25403     --ctx->enc_count;
25404     while (1) {
25405       if (field == &ctx->root) {
25406         ctx->head = NULL;
25407         if (ctx->enc_count != 0) {
25408           __Pyx_BufFmt_RaiseExpected(ctx);
25409           return -1;
25410         }
25411         break;
25412       }
25413       ctx->head->field = ++field;
25414       if (field->type == NULL) {
25415         --ctx->head;
25416         field = ctx->head->field;
25417         continue;
25418       } else if (field->type->typegroup == 'S') {
25419         size_t parent_offset = ctx->head->parent_offset + field->offset;
25420         if (field->type->fields->type == NULL) continue;
25421         field = field->type->fields;
25422         ++ctx->head;
25423         ctx->head->field = field;
25424         ctx->head->parent_offset = parent_offset;
25425         break;
25426       } else {
25427         break;
25428       }
25429     }
25430   } while (ctx->enc_count);
25431   ctx->enc_type = 0;
25432   ctx->is_complex = 0;
25433   return 0;
25434 }
25435 static PyObject *
__pyx_buffmt_parse_array(__Pyx_BufFmt_Context * ctx,const char ** tsp)25436 __pyx_buffmt_parse_array(__Pyx_BufFmt_Context* ctx, const char** tsp)
25437 {
25438     const char *ts = *tsp;
25439     int i = 0, number, ndim;
25440     ++ts;
25441     if (ctx->new_count != 1) {
25442         PyErr_SetString(PyExc_ValueError,
25443                         "Cannot handle repeated arrays in format string");
25444         return NULL;
25445     }
25446     if (__Pyx_BufFmt_ProcessTypeChunk(ctx) == -1) return NULL;
25447     ndim = ctx->head->field->type->ndim;
25448     while (*ts && *ts != ')') {
25449         switch (*ts) {
25450             case ' ': case '\f': case '\r': case '\n': case '\t': case '\v':  continue;
25451             default:  break;
25452         }
25453         number = __Pyx_BufFmt_ExpectNumber(&ts);
25454         if (number == -1) return NULL;
25455         if (i < ndim && (size_t) number != ctx->head->field->type->arraysize[i])
25456             return PyErr_Format(PyExc_ValueError,
25457                         "Expected a dimension of size %zu, got %d",
25458                         ctx->head->field->type->arraysize[i], number);
25459         if (*ts != ',' && *ts != ')')
25460             return PyErr_Format(PyExc_ValueError,
25461                                 "Expected a comma in format string, got '%c'", *ts);
25462         if (*ts == ',') ts++;
25463         i++;
25464     }
25465     if (i != ndim)
25466         return PyErr_Format(PyExc_ValueError, "Expected %d dimension(s), got %d",
25467                             ctx->head->field->type->ndim, i);
25468     if (!*ts) {
25469         PyErr_SetString(PyExc_ValueError,
25470                         "Unexpected end of format string, expected ')'");
25471         return NULL;
25472     }
25473     ctx->is_valid_array = 1;
25474     ctx->new_count = 1;
25475     *tsp = ++ts;
25476     return Py_None;
25477 }
__Pyx_BufFmt_CheckString(__Pyx_BufFmt_Context * ctx,const char * ts)25478 static const char* __Pyx_BufFmt_CheckString(__Pyx_BufFmt_Context* ctx, const char* ts) {
25479   int got_Z = 0;
25480   while (1) {
25481     switch(*ts) {
25482       case 0:
25483         if (ctx->enc_type != 0 && ctx->head == NULL) {
25484           __Pyx_BufFmt_RaiseExpected(ctx);
25485           return NULL;
25486         }
25487         if (__Pyx_BufFmt_ProcessTypeChunk(ctx) == -1) return NULL;
25488         if (ctx->head != NULL) {
25489           __Pyx_BufFmt_RaiseExpected(ctx);
25490           return NULL;
25491         }
25492         return ts;
25493       case ' ':
25494       case '\r':
25495       case '\n':
25496         ++ts;
25497         break;
25498       case '<':
25499         if (!__Pyx_Is_Little_Endian()) {
25500           PyErr_SetString(PyExc_ValueError, "Little-endian buffer not supported on big-endian compiler");
25501           return NULL;
25502         }
25503         ctx->new_packmode = '=';
25504         ++ts;
25505         break;
25506       case '>':
25507       case '!':
25508         if (__Pyx_Is_Little_Endian()) {
25509           PyErr_SetString(PyExc_ValueError, "Big-endian buffer not supported on little-endian compiler");
25510           return NULL;
25511         }
25512         ctx->new_packmode = '=';
25513         ++ts;
25514         break;
25515       case '=':
25516       case '@':
25517       case '^':
25518         ctx->new_packmode = *ts++;
25519         break;
25520       case 'T':
25521         {
25522           const char* ts_after_sub;
25523           size_t i, struct_count = ctx->new_count;
25524           size_t struct_alignment = ctx->struct_alignment;
25525           ctx->new_count = 1;
25526           ++ts;
25527           if (*ts != '{') {
25528             PyErr_SetString(PyExc_ValueError, "Buffer acquisition: Expected '{' after 'T'");
25529             return NULL;
25530           }
25531           if (__Pyx_BufFmt_ProcessTypeChunk(ctx) == -1) return NULL;
25532           ctx->enc_type = 0;
25533           ctx->enc_count = 0;
25534           ctx->struct_alignment = 0;
25535           ++ts;
25536           ts_after_sub = ts;
25537           for (i = 0; i != struct_count; ++i) {
25538             ts_after_sub = __Pyx_BufFmt_CheckString(ctx, ts);
25539             if (!ts_after_sub) return NULL;
25540           }
25541           ts = ts_after_sub;
25542           if (struct_alignment) ctx->struct_alignment = struct_alignment;
25543         }
25544         break;
25545       case '}':
25546         {
25547           size_t alignment = ctx->struct_alignment;
25548           ++ts;
25549           if (__Pyx_BufFmt_ProcessTypeChunk(ctx) == -1) return NULL;
25550           ctx->enc_type = 0;
25551           if (alignment && ctx->fmt_offset % alignment) {
25552             ctx->fmt_offset += alignment - (ctx->fmt_offset % alignment);
25553           }
25554         }
25555         return ts;
25556       case 'x':
25557         if (__Pyx_BufFmt_ProcessTypeChunk(ctx) == -1) return NULL;
25558         ctx->fmt_offset += ctx->new_count;
25559         ctx->new_count = 1;
25560         ctx->enc_count = 0;
25561         ctx->enc_type = 0;
25562         ctx->enc_packmode = ctx->new_packmode;
25563         ++ts;
25564         break;
25565       case 'Z':
25566         got_Z = 1;
25567         ++ts;
25568         if (*ts != 'f' && *ts != 'd' && *ts != 'g') {
25569           __Pyx_BufFmt_RaiseUnexpectedChar('Z');
25570           return NULL;
25571         }
25572         CYTHON_FALLTHROUGH;
25573       case '?': case 'c': case 'b': case 'B': case 'h': case 'H': case 'i': case 'I':
25574       case 'l': case 'L': case 'q': case 'Q':
25575       case 'f': case 'd': case 'g':
25576       case 'O': case 'p':
25577         if ((ctx->enc_type == *ts) && (got_Z == ctx->is_complex) &&
25578             (ctx->enc_packmode == ctx->new_packmode) && (!ctx->is_valid_array)) {
25579           ctx->enc_count += ctx->new_count;
25580           ctx->new_count = 1;
25581           got_Z = 0;
25582           ++ts;
25583           break;
25584         }
25585         CYTHON_FALLTHROUGH;
25586       case 's':
25587         if (__Pyx_BufFmt_ProcessTypeChunk(ctx) == -1) return NULL;
25588         ctx->enc_count = ctx->new_count;
25589         ctx->enc_packmode = ctx->new_packmode;
25590         ctx->enc_type = *ts;
25591         ctx->is_complex = got_Z;
25592         ++ts;
25593         ctx->new_count = 1;
25594         got_Z = 0;
25595         break;
25596       case ':':
25597         ++ts;
25598         while(*ts != ':') ++ts;
25599         ++ts;
25600         break;
25601       case '(':
25602         if (!__pyx_buffmt_parse_array(ctx, &ts)) return NULL;
25603         break;
25604       default:
25605         {
25606           int number = __Pyx_BufFmt_ExpectNumber(&ts);
25607           if (number == -1) return NULL;
25608           ctx->new_count = (size_t)number;
25609         }
25610     }
25611   }
25612 }
25613 
25614 /* BufferGetAndValidate */
__Pyx_SafeReleaseBuffer(Py_buffer * info)25615   static CYTHON_INLINE void __Pyx_SafeReleaseBuffer(Py_buffer* info) {
25616   if (unlikely(info->buf == NULL)) return;
25617   if (info->suboffsets == __Pyx_minusones) info->suboffsets = NULL;
25618   __Pyx_ReleaseBuffer(info);
25619 }
__Pyx_ZeroBuffer(Py_buffer * buf)25620 static void __Pyx_ZeroBuffer(Py_buffer* buf) {
25621   buf->buf = NULL;
25622   buf->obj = NULL;
25623   buf->strides = __Pyx_zeros;
25624   buf->shape = __Pyx_zeros;
25625   buf->suboffsets = __Pyx_minusones;
25626 }
__Pyx__GetBufferAndValidate(Py_buffer * buf,PyObject * obj,__Pyx_TypeInfo * dtype,int flags,int nd,int cast,__Pyx_BufFmt_StackElem * stack)25627 static int __Pyx__GetBufferAndValidate(
25628         Py_buffer* buf, PyObject* obj,  __Pyx_TypeInfo* dtype, int flags,
25629         int nd, int cast, __Pyx_BufFmt_StackElem* stack)
25630 {
25631   buf->buf = NULL;
25632   if (unlikely(__Pyx_GetBuffer(obj, buf, flags) == -1)) {
25633     __Pyx_ZeroBuffer(buf);
25634     return -1;
25635   }
25636   if (unlikely(buf->ndim != nd)) {
25637     PyErr_Format(PyExc_ValueError,
25638                  "Buffer has wrong number of dimensions (expected %d, got %d)",
25639                  nd, buf->ndim);
25640     goto fail;
25641   }
25642   if (!cast) {
25643     __Pyx_BufFmt_Context ctx;
25644     __Pyx_BufFmt_Init(&ctx, stack, dtype);
25645     if (!__Pyx_BufFmt_CheckString(&ctx, buf->format)) goto fail;
25646   }
25647   if (unlikely((size_t)buf->itemsize != dtype->size)) {
25648     PyErr_Format(PyExc_ValueError,
25649       "Item size of buffer (%" CYTHON_FORMAT_SSIZE_T "d byte%s) does not match size of '%s' (%" CYTHON_FORMAT_SSIZE_T "d byte%s)",
25650       buf->itemsize, (buf->itemsize > 1) ? "s" : "",
25651       dtype->name, (Py_ssize_t)dtype->size, (dtype->size > 1) ? "s" : "");
25652     goto fail;
25653   }
25654   if (buf->suboffsets == NULL) buf->suboffsets = __Pyx_minusones;
25655   return 0;
25656 fail:;
25657   __Pyx_SafeReleaseBuffer(buf);
25658   return -1;
25659 }
25660 
25661 /* PyErrFetchRestore */
25662   #if CYTHON_FAST_THREAD_STATE
__Pyx_ErrRestoreInState(PyThreadState * tstate,PyObject * type,PyObject * value,PyObject * tb)25663 static CYTHON_INLINE void __Pyx_ErrRestoreInState(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb) {
25664     PyObject *tmp_type, *tmp_value, *tmp_tb;
25665     tmp_type = tstate->curexc_type;
25666     tmp_value = tstate->curexc_value;
25667     tmp_tb = tstate->curexc_traceback;
25668     tstate->curexc_type = type;
25669     tstate->curexc_value = value;
25670     tstate->curexc_traceback = tb;
25671     Py_XDECREF(tmp_type);
25672     Py_XDECREF(tmp_value);
25673     Py_XDECREF(tmp_tb);
25674 }
__Pyx_ErrFetchInState(PyThreadState * tstate,PyObject ** type,PyObject ** value,PyObject ** tb)25675 static CYTHON_INLINE void __Pyx_ErrFetchInState(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) {
25676     *type = tstate->curexc_type;
25677     *value = tstate->curexc_value;
25678     *tb = tstate->curexc_traceback;
25679     tstate->curexc_type = 0;
25680     tstate->curexc_value = 0;
25681     tstate->curexc_traceback = 0;
25682 }
25683 #endif
25684 
25685 /* BufferIndexError */
__Pyx_RaiseBufferIndexError(int axis)25686   static void __Pyx_RaiseBufferIndexError(int axis) {
25687   PyErr_Format(PyExc_IndexError,
25688      "Out of bounds on buffer access (axis %d)", axis);
25689 }
25690 
25691 /* WriteUnraisableException */
__Pyx_WriteUnraisable(const char * name,CYTHON_UNUSED int clineno,CYTHON_UNUSED int lineno,CYTHON_UNUSED const char * filename,int full_traceback,CYTHON_UNUSED int nogil)25692   static void __Pyx_WriteUnraisable(const char *name, CYTHON_UNUSED int clineno,
25693                                   CYTHON_UNUSED int lineno, CYTHON_UNUSED const char *filename,
25694                                   int full_traceback, CYTHON_UNUSED int nogil) {
25695     PyObject *old_exc, *old_val, *old_tb;
25696     PyObject *ctx;
25697     __Pyx_PyThreadState_declare
25698 #ifdef WITH_THREAD
25699     PyGILState_STATE state;
25700     if (nogil)
25701         state = PyGILState_Ensure();
25702 #ifdef _MSC_VER
25703     else state = (PyGILState_STATE)-1;
25704 #endif
25705 #endif
25706     __Pyx_PyThreadState_assign
25707     __Pyx_ErrFetch(&old_exc, &old_val, &old_tb);
25708     if (full_traceback) {
25709         Py_XINCREF(old_exc);
25710         Py_XINCREF(old_val);
25711         Py_XINCREF(old_tb);
25712         __Pyx_ErrRestore(old_exc, old_val, old_tb);
25713         PyErr_PrintEx(1);
25714     }
25715     #if PY_MAJOR_VERSION < 3
25716     ctx = PyString_FromString(name);
25717     #else
25718     ctx = PyUnicode_FromString(name);
25719     #endif
25720     __Pyx_ErrRestore(old_exc, old_val, old_tb);
25721     if (!ctx) {
25722         PyErr_WriteUnraisable(Py_None);
25723     } else {
25724         PyErr_WriteUnraisable(ctx);
25725         Py_DECREF(ctx);
25726     }
25727 #ifdef WITH_THREAD
25728     if (nogil)
25729         PyGILState_Release(state);
25730 #endif
25731 }
25732 
25733 /* PyIntBinop */
25734   #if !CYTHON_COMPILING_IN_PYPY
__Pyx_PyInt_SubtractObjC(PyObject * op1,PyObject * op2,CYTHON_UNUSED long intval,int inplace,int zerodivision_check)25735 static PyObject* __Pyx_PyInt_SubtractObjC(PyObject *op1, PyObject *op2, CYTHON_UNUSED long intval, int inplace, int zerodivision_check) {
25736     (void)inplace;
25737     (void)zerodivision_check;
25738     #if PY_MAJOR_VERSION < 3
25739     if (likely(PyInt_CheckExact(op1))) {
25740         const long b = intval;
25741         long x;
25742         long a = PyInt_AS_LONG(op1);
25743             x = (long)((unsigned long)a - b);
25744             if (likely((x^a) >= 0 || (x^~b) >= 0))
25745                 return PyInt_FromLong(x);
25746             return PyLong_Type.tp_as_number->nb_subtract(op1, op2);
25747     }
25748     #endif
25749     #if CYTHON_USE_PYLONG_INTERNALS
25750     if (likely(PyLong_CheckExact(op1))) {
25751         const long b = intval;
25752         long a, x;
25753 #ifdef HAVE_LONG_LONG
25754         const PY_LONG_LONG llb = intval;
25755         PY_LONG_LONG lla, llx;
25756 #endif
25757         const digit* digits = ((PyLongObject*)op1)->ob_digit;
25758         const Py_ssize_t size = Py_SIZE(op1);
25759         if (likely(__Pyx_sst_abs(size) <= 1)) {
25760             a = likely(size) ? digits[0] : 0;
25761             if (size == -1) a = -a;
25762         } else {
25763             switch (size) {
25764                 case -2:
25765                     if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
25766                         a = -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
25767                         break;
25768 #ifdef HAVE_LONG_LONG
25769                     } else if (8 * sizeof(PY_LONG_LONG) - 1 > 2 * PyLong_SHIFT) {
25770                         lla = -(PY_LONG_LONG) (((((unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
25771                         goto long_long;
25772 #endif
25773                     }
25774                     CYTHON_FALLTHROUGH;
25775                 case 2:
25776                     if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
25777                         a = (long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
25778                         break;
25779 #ifdef HAVE_LONG_LONG
25780                     } else if (8 * sizeof(PY_LONG_LONG) - 1 > 2 * PyLong_SHIFT) {
25781                         lla = (PY_LONG_LONG) (((((unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
25782                         goto long_long;
25783 #endif
25784                     }
25785                     CYTHON_FALLTHROUGH;
25786                 case -3:
25787                     if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
25788                         a = -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
25789                         break;
25790 #ifdef HAVE_LONG_LONG
25791                     } else if (8 * sizeof(PY_LONG_LONG) - 1 > 3 * PyLong_SHIFT) {
25792                         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]));
25793                         goto long_long;
25794 #endif
25795                     }
25796                     CYTHON_FALLTHROUGH;
25797                 case 3:
25798                     if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
25799                         a = (long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
25800                         break;
25801 #ifdef HAVE_LONG_LONG
25802                     } else if (8 * sizeof(PY_LONG_LONG) - 1 > 3 * PyLong_SHIFT) {
25803                         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]));
25804                         goto long_long;
25805 #endif
25806                     }
25807                     CYTHON_FALLTHROUGH;
25808                 case -4:
25809                     if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) {
25810                         a = -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
25811                         break;
25812 #ifdef HAVE_LONG_LONG
25813                     } else if (8 * sizeof(PY_LONG_LONG) - 1 > 4 * PyLong_SHIFT) {
25814                         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]));
25815                         goto long_long;
25816 #endif
25817                     }
25818                     CYTHON_FALLTHROUGH;
25819                 case 4:
25820                     if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) {
25821                         a = (long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
25822                         break;
25823 #ifdef HAVE_LONG_LONG
25824                     } else if (8 * sizeof(PY_LONG_LONG) - 1 > 4 * PyLong_SHIFT) {
25825                         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]));
25826                         goto long_long;
25827 #endif
25828                     }
25829                     CYTHON_FALLTHROUGH;
25830                 default: return PyLong_Type.tp_as_number->nb_subtract(op1, op2);
25831             }
25832         }
25833                 x = a - b;
25834             return PyLong_FromLong(x);
25835 #ifdef HAVE_LONG_LONG
25836         long_long:
25837                 llx = lla - llb;
25838             return PyLong_FromLongLong(llx);
25839 #endif
25840 
25841 
25842     }
25843     #endif
25844     if (PyFloat_CheckExact(op1)) {
25845         const long b = intval;
25846         double a = PyFloat_AS_DOUBLE(op1);
25847             double result;
25848             PyFPE_START_PROTECT("subtract", return NULL)
25849             result = ((double)a) - (double)b;
25850             PyFPE_END_PROTECT(result)
25851             return PyFloat_FromDouble(result);
25852     }
25853     return (inplace ? PyNumber_InPlaceSubtract : PyNumber_Subtract)(op1, op2);
25854 }
25855 #endif
25856 
25857 /* GetItemInt */
__Pyx_GetItemInt_Generic(PyObject * o,PyObject * j)25858   static PyObject *__Pyx_GetItemInt_Generic(PyObject *o, PyObject* j) {
25859     PyObject *r;
25860     if (!j) return NULL;
25861     r = PyObject_GetItem(o, j);
25862     Py_DECREF(j);
25863     return r;
25864 }
__Pyx_GetItemInt_List_Fast(PyObject * o,Py_ssize_t i,CYTHON_NCP_UNUSED int wraparound,CYTHON_NCP_UNUSED int boundscheck)25865 static CYTHON_INLINE PyObject *__Pyx_GetItemInt_List_Fast(PyObject *o, Py_ssize_t i,
25866                                                               CYTHON_NCP_UNUSED int wraparound,
25867                                                               CYTHON_NCP_UNUSED int boundscheck) {
25868 #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
25869     Py_ssize_t wrapped_i = i;
25870     if (wraparound & unlikely(i < 0)) {
25871         wrapped_i += PyList_GET_SIZE(o);
25872     }
25873     if ((!boundscheck) || likely(__Pyx_is_valid_index(wrapped_i, PyList_GET_SIZE(o)))) {
25874         PyObject *r = PyList_GET_ITEM(o, wrapped_i);
25875         Py_INCREF(r);
25876         return r;
25877     }
25878     return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i));
25879 #else
25880     return PySequence_GetItem(o, i);
25881 #endif
25882 }
__Pyx_GetItemInt_Tuple_Fast(PyObject * o,Py_ssize_t i,CYTHON_NCP_UNUSED int wraparound,CYTHON_NCP_UNUSED int boundscheck)25883 static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Tuple_Fast(PyObject *o, Py_ssize_t i,
25884                                                               CYTHON_NCP_UNUSED int wraparound,
25885                                                               CYTHON_NCP_UNUSED int boundscheck) {
25886 #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
25887     Py_ssize_t wrapped_i = i;
25888     if (wraparound & unlikely(i < 0)) {
25889         wrapped_i += PyTuple_GET_SIZE(o);
25890     }
25891     if ((!boundscheck) || likely(__Pyx_is_valid_index(wrapped_i, PyTuple_GET_SIZE(o)))) {
25892         PyObject *r = PyTuple_GET_ITEM(o, wrapped_i);
25893         Py_INCREF(r);
25894         return r;
25895     }
25896     return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i));
25897 #else
25898     return PySequence_GetItem(o, i);
25899 #endif
25900 }
__Pyx_GetItemInt_Fast(PyObject * o,Py_ssize_t i,int is_list,CYTHON_NCP_UNUSED int wraparound,CYTHON_NCP_UNUSED int boundscheck)25901 static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Fast(PyObject *o, Py_ssize_t i, int is_list,
25902                                                      CYTHON_NCP_UNUSED int wraparound,
25903                                                      CYTHON_NCP_UNUSED int boundscheck) {
25904 #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS && CYTHON_USE_TYPE_SLOTS
25905     if (is_list || PyList_CheckExact(o)) {
25906         Py_ssize_t n = ((!wraparound) | likely(i >= 0)) ? i : i + PyList_GET_SIZE(o);
25907         if ((!boundscheck) || (likely(__Pyx_is_valid_index(n, PyList_GET_SIZE(o))))) {
25908             PyObject *r = PyList_GET_ITEM(o, n);
25909             Py_INCREF(r);
25910             return r;
25911         }
25912     }
25913     else if (PyTuple_CheckExact(o)) {
25914         Py_ssize_t n = ((!wraparound) | likely(i >= 0)) ? i : i + PyTuple_GET_SIZE(o);
25915         if ((!boundscheck) || likely(__Pyx_is_valid_index(n, PyTuple_GET_SIZE(o)))) {
25916             PyObject *r = PyTuple_GET_ITEM(o, n);
25917             Py_INCREF(r);
25918             return r;
25919         }
25920     } else {
25921         PySequenceMethods *m = Py_TYPE(o)->tp_as_sequence;
25922         if (likely(m && m->sq_item)) {
25923             if (wraparound && unlikely(i < 0) && likely(m->sq_length)) {
25924                 Py_ssize_t l = m->sq_length(o);
25925                 if (likely(l >= 0)) {
25926                     i += l;
25927                 } else {
25928                     if (!PyErr_ExceptionMatches(PyExc_OverflowError))
25929                         return NULL;
25930                     PyErr_Clear();
25931                 }
25932             }
25933             return m->sq_item(o, i);
25934         }
25935     }
25936 #else
25937     if (is_list || PySequence_Check(o)) {
25938         return PySequence_GetItem(o, i);
25939     }
25940 #endif
25941     return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i));
25942 }
25943 
25944 /* DictGetItem */
25945   #if PY_MAJOR_VERSION >= 3 && !CYTHON_COMPILING_IN_PYPY
__Pyx_PyDict_GetItem(PyObject * d,PyObject * key)25946 static PyObject *__Pyx_PyDict_GetItem(PyObject *d, PyObject* key) {
25947     PyObject *value;
25948     value = PyDict_GetItemWithError(d, key);
25949     if (unlikely(!value)) {
25950         if (!PyErr_Occurred()) {
25951             if (unlikely(PyTuple_Check(key))) {
25952                 PyObject* args = PyTuple_Pack(1, key);
25953                 if (likely(args)) {
25954                     PyErr_SetObject(PyExc_KeyError, args);
25955                     Py_DECREF(args);
25956                 }
25957             } else {
25958                 PyErr_SetObject(PyExc_KeyError, key);
25959             }
25960         }
25961         return NULL;
25962     }
25963     Py_INCREF(value);
25964     return value;
25965 }
25966 #endif
25967 
25968 /* ArgTypeTest */
__Pyx__ArgTypeTest(PyObject * obj,PyTypeObject * type,const char * name,int exact)25969   static int __Pyx__ArgTypeTest(PyObject *obj, PyTypeObject *type, const char *name, int exact)
25970 {
25971     if (unlikely(!type)) {
25972         PyErr_SetString(PyExc_SystemError, "Missing type object");
25973         return 0;
25974     }
25975     else if (exact) {
25976         #if PY_MAJOR_VERSION == 2
25977         if ((type == &PyBaseString_Type) && likely(__Pyx_PyBaseString_CheckExact(obj))) return 1;
25978         #endif
25979     }
25980     else {
25981         if (likely(__Pyx_TypeCheck(obj, type))) return 1;
25982     }
25983     PyErr_Format(PyExc_TypeError,
25984         "Argument '%.200s' has incorrect type (expected %.200s, got %.200s)",
25985         name, type->tp_name, Py_TYPE(obj)->tp_name);
25986     return 0;
25987 }
25988 
25989 /* PyFunctionFastCall */
25990   #if CYTHON_FAST_PYCALL
__Pyx_PyFunction_FastCallNoKw(PyCodeObject * co,PyObject ** args,Py_ssize_t na,PyObject * globals)25991 static PyObject* __Pyx_PyFunction_FastCallNoKw(PyCodeObject *co, PyObject **args, Py_ssize_t na,
25992                                                PyObject *globals) {
25993     PyFrameObject *f;
25994     PyThreadState *tstate = __Pyx_PyThreadState_Current;
25995     PyObject **fastlocals;
25996     Py_ssize_t i;
25997     PyObject *result;
25998     assert(globals != NULL);
25999     /* XXX Perhaps we should create a specialized
26000        PyFrame_New() that doesn't take locals, but does
26001        take builtins without sanity checking them.
26002        */
26003     assert(tstate != NULL);
26004     f = PyFrame_New(tstate, co, globals, NULL);
26005     if (f == NULL) {
26006         return NULL;
26007     }
26008     fastlocals = __Pyx_PyFrame_GetLocalsplus(f);
26009     for (i = 0; i < na; i++) {
26010         Py_INCREF(*args);
26011         fastlocals[i] = *args++;
26012     }
26013     result = PyEval_EvalFrameEx(f,0);
26014     ++tstate->recursion_depth;
26015     Py_DECREF(f);
26016     --tstate->recursion_depth;
26017     return result;
26018 }
26019 #if 1 || PY_VERSION_HEX < 0x030600B1
__Pyx_PyFunction_FastCallDict(PyObject * func,PyObject ** args,Py_ssize_t nargs,PyObject * kwargs)26020 static PyObject *__Pyx_PyFunction_FastCallDict(PyObject *func, PyObject **args, Py_ssize_t nargs, PyObject *kwargs) {
26021     PyCodeObject *co = (PyCodeObject *)PyFunction_GET_CODE(func);
26022     PyObject *globals = PyFunction_GET_GLOBALS(func);
26023     PyObject *argdefs = PyFunction_GET_DEFAULTS(func);
26024     PyObject *closure;
26025 #if PY_MAJOR_VERSION >= 3
26026     PyObject *kwdefs;
26027 #endif
26028     PyObject *kwtuple, **k;
26029     PyObject **d;
26030     Py_ssize_t nd;
26031     Py_ssize_t nk;
26032     PyObject *result;
26033     assert(kwargs == NULL || PyDict_Check(kwargs));
26034     nk = kwargs ? PyDict_Size(kwargs) : 0;
26035     if (Py_EnterRecursiveCall((char*)" while calling a Python object")) {
26036         return NULL;
26037     }
26038     if (
26039 #if PY_MAJOR_VERSION >= 3
26040             co->co_kwonlyargcount == 0 &&
26041 #endif
26042             likely(kwargs == NULL || nk == 0) &&
26043             co->co_flags == (CO_OPTIMIZED | CO_NEWLOCALS | CO_NOFREE)) {
26044         if (argdefs == NULL && co->co_argcount == nargs) {
26045             result = __Pyx_PyFunction_FastCallNoKw(co, args, nargs, globals);
26046             goto done;
26047         }
26048         else if (nargs == 0 && argdefs != NULL
26049                  && co->co_argcount == Py_SIZE(argdefs)) {
26050             /* function called with no arguments, but all parameters have
26051                a default value: use default values as arguments .*/
26052             args = &PyTuple_GET_ITEM(argdefs, 0);
26053             result =__Pyx_PyFunction_FastCallNoKw(co, args, Py_SIZE(argdefs), globals);
26054             goto done;
26055         }
26056     }
26057     if (kwargs != NULL) {
26058         Py_ssize_t pos, i;
26059         kwtuple = PyTuple_New(2 * nk);
26060         if (kwtuple == NULL) {
26061             result = NULL;
26062             goto done;
26063         }
26064         k = &PyTuple_GET_ITEM(kwtuple, 0);
26065         pos = i = 0;
26066         while (PyDict_Next(kwargs, &pos, &k[i], &k[i+1])) {
26067             Py_INCREF(k[i]);
26068             Py_INCREF(k[i+1]);
26069             i += 2;
26070         }
26071         nk = i / 2;
26072     }
26073     else {
26074         kwtuple = NULL;
26075         k = NULL;
26076     }
26077     closure = PyFunction_GET_CLOSURE(func);
26078 #if PY_MAJOR_VERSION >= 3
26079     kwdefs = PyFunction_GET_KW_DEFAULTS(func);
26080 #endif
26081     if (argdefs != NULL) {
26082         d = &PyTuple_GET_ITEM(argdefs, 0);
26083         nd = Py_SIZE(argdefs);
26084     }
26085     else {
26086         d = NULL;
26087         nd = 0;
26088     }
26089 #if PY_MAJOR_VERSION >= 3
26090     result = PyEval_EvalCodeEx((PyObject*)co, globals, (PyObject *)NULL,
26091                                args, (int)nargs,
26092                                k, (int)nk,
26093                                d, (int)nd, kwdefs, closure);
26094 #else
26095     result = PyEval_EvalCodeEx(co, globals, (PyObject *)NULL,
26096                                args, (int)nargs,
26097                                k, (int)nk,
26098                                d, (int)nd, closure);
26099 #endif
26100     Py_XDECREF(kwtuple);
26101 done:
26102     Py_LeaveRecursiveCall();
26103     return result;
26104 }
26105 #endif
26106 #endif
26107 
26108 /* PyCFunctionFastCall */
26109   #if CYTHON_FAST_PYCCALL
__Pyx_PyCFunction_FastCall(PyObject * func_obj,PyObject ** args,Py_ssize_t nargs)26110 static CYTHON_INLINE PyObject * __Pyx_PyCFunction_FastCall(PyObject *func_obj, PyObject **args, Py_ssize_t nargs) {
26111     PyCFunctionObject *func = (PyCFunctionObject*)func_obj;
26112     PyCFunction meth = PyCFunction_GET_FUNCTION(func);
26113     PyObject *self = PyCFunction_GET_SELF(func);
26114     int flags = PyCFunction_GET_FLAGS(func);
26115     assert(PyCFunction_Check(func));
26116     assert(METH_FASTCALL == (flags & ~(METH_CLASS | METH_STATIC | METH_COEXIST | METH_KEYWORDS | METH_STACKLESS)));
26117     assert(nargs >= 0);
26118     assert(nargs == 0 || args != NULL);
26119     /* _PyCFunction_FastCallDict() must not be called with an exception set,
26120        because it may clear it (directly or indirectly) and so the
26121        caller loses its exception */
26122     assert(!PyErr_Occurred());
26123     if ((PY_VERSION_HEX < 0x030700A0) || unlikely(flags & METH_KEYWORDS)) {
26124         return (*((__Pyx_PyCFunctionFastWithKeywords)(void*)meth)) (self, args, nargs, NULL);
26125     } else {
26126         return (*((__Pyx_PyCFunctionFast)(void*)meth)) (self, args, nargs);
26127     }
26128 }
26129 #endif
26130 
26131 /* GetTopmostException */
26132   #if CYTHON_USE_EXC_INFO_STACK
26133 static _PyErr_StackItem *
__Pyx_PyErr_GetTopmostException(PyThreadState * tstate)26134 __Pyx_PyErr_GetTopmostException(PyThreadState *tstate)
26135 {
26136     _PyErr_StackItem *exc_info = tstate->exc_info;
26137     while ((exc_info->exc_type == NULL || exc_info->exc_type == Py_None) &&
26138            exc_info->previous_item != NULL)
26139     {
26140         exc_info = exc_info->previous_item;
26141     }
26142     return exc_info;
26143 }
26144 #endif
26145 
26146 /* SaveResetException */
26147   #if CYTHON_FAST_THREAD_STATE
__Pyx__ExceptionSave(PyThreadState * tstate,PyObject ** type,PyObject ** value,PyObject ** tb)26148 static CYTHON_INLINE void __Pyx__ExceptionSave(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) {
26149     #if CYTHON_USE_EXC_INFO_STACK
26150     _PyErr_StackItem *exc_info = __Pyx_PyErr_GetTopmostException(tstate);
26151     *type = exc_info->exc_type;
26152     *value = exc_info->exc_value;
26153     *tb = exc_info->exc_traceback;
26154     #else
26155     *type = tstate->exc_type;
26156     *value = tstate->exc_value;
26157     *tb = tstate->exc_traceback;
26158     #endif
26159     Py_XINCREF(*type);
26160     Py_XINCREF(*value);
26161     Py_XINCREF(*tb);
26162 }
__Pyx__ExceptionReset(PyThreadState * tstate,PyObject * type,PyObject * value,PyObject * tb)26163 static CYTHON_INLINE void __Pyx__ExceptionReset(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb) {
26164     PyObject *tmp_type, *tmp_value, *tmp_tb;
26165     #if CYTHON_USE_EXC_INFO_STACK
26166     _PyErr_StackItem *exc_info = tstate->exc_info;
26167     tmp_type = exc_info->exc_type;
26168     tmp_value = exc_info->exc_value;
26169     tmp_tb = exc_info->exc_traceback;
26170     exc_info->exc_type = type;
26171     exc_info->exc_value = value;
26172     exc_info->exc_traceback = tb;
26173     #else
26174     tmp_type = tstate->exc_type;
26175     tmp_value = tstate->exc_value;
26176     tmp_tb = tstate->exc_traceback;
26177     tstate->exc_type = type;
26178     tstate->exc_value = value;
26179     tstate->exc_traceback = tb;
26180     #endif
26181     Py_XDECREF(tmp_type);
26182     Py_XDECREF(tmp_value);
26183     Py_XDECREF(tmp_tb);
26184 }
26185 #endif
26186 
26187 /* PyErrExceptionMatches */
26188   #if CYTHON_FAST_THREAD_STATE
__Pyx_PyErr_ExceptionMatchesTuple(PyObject * exc_type,PyObject * tuple)26189 static int __Pyx_PyErr_ExceptionMatchesTuple(PyObject *exc_type, PyObject *tuple) {
26190     Py_ssize_t i, n;
26191     n = PyTuple_GET_SIZE(tuple);
26192 #if PY_MAJOR_VERSION >= 3
26193     for (i=0; i<n; i++) {
26194         if (exc_type == PyTuple_GET_ITEM(tuple, i)) return 1;
26195     }
26196 #endif
26197     for (i=0; i<n; i++) {
26198         if (__Pyx_PyErr_GivenExceptionMatches(exc_type, PyTuple_GET_ITEM(tuple, i))) return 1;
26199     }
26200     return 0;
26201 }
__Pyx_PyErr_ExceptionMatchesInState(PyThreadState * tstate,PyObject * err)26202 static CYTHON_INLINE int __Pyx_PyErr_ExceptionMatchesInState(PyThreadState* tstate, PyObject* err) {
26203     PyObject *exc_type = tstate->curexc_type;
26204     if (exc_type == err) return 1;
26205     if (unlikely(!exc_type)) return 0;
26206     if (unlikely(PyTuple_Check(err)))
26207         return __Pyx_PyErr_ExceptionMatchesTuple(exc_type, err);
26208     return __Pyx_PyErr_GivenExceptionMatches(exc_type, err);
26209 }
26210 #endif
26211 
26212 /* GetException */
26213   #if CYTHON_FAST_THREAD_STATE
__Pyx__GetException(PyThreadState * tstate,PyObject ** type,PyObject ** value,PyObject ** tb)26214 static int __Pyx__GetException(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb)
26215 #else
26216 static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb)
26217 #endif
26218 {
26219     PyObject *local_type, *local_value, *local_tb;
26220 #if CYTHON_FAST_THREAD_STATE
26221     PyObject *tmp_type, *tmp_value, *tmp_tb;
26222     local_type = tstate->curexc_type;
26223     local_value = tstate->curexc_value;
26224     local_tb = tstate->curexc_traceback;
26225     tstate->curexc_type = 0;
26226     tstate->curexc_value = 0;
26227     tstate->curexc_traceback = 0;
26228 #else
26229     PyErr_Fetch(&local_type, &local_value, &local_tb);
26230 #endif
26231     PyErr_NormalizeException(&local_type, &local_value, &local_tb);
26232 #if CYTHON_FAST_THREAD_STATE
26233     if (unlikely(tstate->curexc_type))
26234 #else
26235     if (unlikely(PyErr_Occurred()))
26236 #endif
26237         goto bad;
26238     #if PY_MAJOR_VERSION >= 3
26239     if (local_tb) {
26240         if (unlikely(PyException_SetTraceback(local_value, local_tb) < 0))
26241             goto bad;
26242     }
26243     #endif
26244     Py_XINCREF(local_tb);
26245     Py_XINCREF(local_type);
26246     Py_XINCREF(local_value);
26247     *type = local_type;
26248     *value = local_value;
26249     *tb = local_tb;
26250 #if CYTHON_FAST_THREAD_STATE
26251     #if CYTHON_USE_EXC_INFO_STACK
26252     {
26253         _PyErr_StackItem *exc_info = tstate->exc_info;
26254         tmp_type = exc_info->exc_type;
26255         tmp_value = exc_info->exc_value;
26256         tmp_tb = exc_info->exc_traceback;
26257         exc_info->exc_type = local_type;
26258         exc_info->exc_value = local_value;
26259         exc_info->exc_traceback = local_tb;
26260     }
26261     #else
26262     tmp_type = tstate->exc_type;
26263     tmp_value = tstate->exc_value;
26264     tmp_tb = tstate->exc_traceback;
26265     tstate->exc_type = local_type;
26266     tstate->exc_value = local_value;
26267     tstate->exc_traceback = local_tb;
26268     #endif
26269     Py_XDECREF(tmp_type);
26270     Py_XDECREF(tmp_value);
26271     Py_XDECREF(tmp_tb);
26272 #else
26273     PyErr_SetExcInfo(local_type, local_value, local_tb);
26274 #endif
26275     return 0;
26276 bad:
26277     *type = 0;
26278     *value = 0;
26279     *tb = 0;
26280     Py_XDECREF(local_type);
26281     Py_XDECREF(local_value);
26282     Py_XDECREF(local_tb);
26283     return -1;
26284 }
26285 
26286 /* RaiseException */
26287   #if PY_MAJOR_VERSION < 3
__Pyx_Raise(PyObject * type,PyObject * value,PyObject * tb,CYTHON_UNUSED PyObject * cause)26288 static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb,
26289                         CYTHON_UNUSED PyObject *cause) {
26290     __Pyx_PyThreadState_declare
26291     Py_XINCREF(type);
26292     if (!value || value == Py_None)
26293         value = NULL;
26294     else
26295         Py_INCREF(value);
26296     if (!tb || tb == Py_None)
26297         tb = NULL;
26298     else {
26299         Py_INCREF(tb);
26300         if (!PyTraceBack_Check(tb)) {
26301             PyErr_SetString(PyExc_TypeError,
26302                 "raise: arg 3 must be a traceback or None");
26303             goto raise_error;
26304         }
26305     }
26306     if (PyType_Check(type)) {
26307 #if CYTHON_COMPILING_IN_PYPY
26308         if (!value) {
26309             Py_INCREF(Py_None);
26310             value = Py_None;
26311         }
26312 #endif
26313         PyErr_NormalizeException(&type, &value, &tb);
26314     } else {
26315         if (value) {
26316             PyErr_SetString(PyExc_TypeError,
26317                 "instance exception may not have a separate value");
26318             goto raise_error;
26319         }
26320         value = type;
26321         type = (PyObject*) Py_TYPE(type);
26322         Py_INCREF(type);
26323         if (!PyType_IsSubtype((PyTypeObject *)type, (PyTypeObject *)PyExc_BaseException)) {
26324             PyErr_SetString(PyExc_TypeError,
26325                 "raise: exception class must be a subclass of BaseException");
26326             goto raise_error;
26327         }
26328     }
26329     __Pyx_PyThreadState_assign
26330     __Pyx_ErrRestore(type, value, tb);
26331     return;
26332 raise_error:
26333     Py_XDECREF(value);
26334     Py_XDECREF(type);
26335     Py_XDECREF(tb);
26336     return;
26337 }
26338 #else
__Pyx_Raise(PyObject * type,PyObject * value,PyObject * tb,PyObject * cause)26339 static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause) {
26340     PyObject* owned_instance = NULL;
26341     if (tb == Py_None) {
26342         tb = 0;
26343     } else if (tb && !PyTraceBack_Check(tb)) {
26344         PyErr_SetString(PyExc_TypeError,
26345             "raise: arg 3 must be a traceback or None");
26346         goto bad;
26347     }
26348     if (value == Py_None)
26349         value = 0;
26350     if (PyExceptionInstance_Check(type)) {
26351         if (value) {
26352             PyErr_SetString(PyExc_TypeError,
26353                 "instance exception may not have a separate value");
26354             goto bad;
26355         }
26356         value = type;
26357         type = (PyObject*) Py_TYPE(value);
26358     } else if (PyExceptionClass_Check(type)) {
26359         PyObject *instance_class = NULL;
26360         if (value && PyExceptionInstance_Check(value)) {
26361             instance_class = (PyObject*) Py_TYPE(value);
26362             if (instance_class != type) {
26363                 int is_subclass = PyObject_IsSubclass(instance_class, type);
26364                 if (!is_subclass) {
26365                     instance_class = NULL;
26366                 } else if (unlikely(is_subclass == -1)) {
26367                     goto bad;
26368                 } else {
26369                     type = instance_class;
26370                 }
26371             }
26372         }
26373         if (!instance_class) {
26374             PyObject *args;
26375             if (!value)
26376                 args = PyTuple_New(0);
26377             else if (PyTuple_Check(value)) {
26378                 Py_INCREF(value);
26379                 args = value;
26380             } else
26381                 args = PyTuple_Pack(1, value);
26382             if (!args)
26383                 goto bad;
26384             owned_instance = PyObject_Call(type, args, NULL);
26385             Py_DECREF(args);
26386             if (!owned_instance)
26387                 goto bad;
26388             value = owned_instance;
26389             if (!PyExceptionInstance_Check(value)) {
26390                 PyErr_Format(PyExc_TypeError,
26391                              "calling %R should have returned an instance of "
26392                              "BaseException, not %R",
26393                              type, Py_TYPE(value));
26394                 goto bad;
26395             }
26396         }
26397     } else {
26398         PyErr_SetString(PyExc_TypeError,
26399             "raise: exception class must be a subclass of BaseException");
26400         goto bad;
26401     }
26402     if (cause) {
26403         PyObject *fixed_cause;
26404         if (cause == Py_None) {
26405             fixed_cause = NULL;
26406         } else if (PyExceptionClass_Check(cause)) {
26407             fixed_cause = PyObject_CallObject(cause, NULL);
26408             if (fixed_cause == NULL)
26409                 goto bad;
26410         } else if (PyExceptionInstance_Check(cause)) {
26411             fixed_cause = cause;
26412             Py_INCREF(fixed_cause);
26413         } else {
26414             PyErr_SetString(PyExc_TypeError,
26415                             "exception causes must derive from "
26416                             "BaseException");
26417             goto bad;
26418         }
26419         PyException_SetCause(value, fixed_cause);
26420     }
26421     PyErr_SetObject(type, value);
26422     if (tb) {
26423 #if CYTHON_COMPILING_IN_PYPY
26424         PyObject *tmp_type, *tmp_value, *tmp_tb;
26425         PyErr_Fetch(&tmp_type, &tmp_value, &tmp_tb);
26426         Py_INCREF(tb);
26427         PyErr_Restore(tmp_type, tmp_value, tb);
26428         Py_XDECREF(tmp_tb);
26429 #else
26430         PyThreadState *tstate = __Pyx_PyThreadState_Current;
26431         PyObject* tmp_tb = tstate->curexc_traceback;
26432         if (tb != tmp_tb) {
26433             Py_INCREF(tb);
26434             tstate->curexc_traceback = tb;
26435             Py_XDECREF(tmp_tb);
26436         }
26437 #endif
26438     }
26439 bad:
26440     Py_XDECREF(owned_instance);
26441     return;
26442 }
26443 #endif
26444 
26445 /* PyObjectCall2Args */
__Pyx_PyObject_Call2Args(PyObject * function,PyObject * arg1,PyObject * arg2)26446   static CYTHON_UNUSED PyObject* __Pyx_PyObject_Call2Args(PyObject* function, PyObject* arg1, PyObject* arg2) {
26447     PyObject *args, *result = NULL;
26448     #if CYTHON_FAST_PYCALL
26449     if (PyFunction_Check(function)) {
26450         PyObject *args[2] = {arg1, arg2};
26451         return __Pyx_PyFunction_FastCall(function, args, 2);
26452     }
26453     #endif
26454     #if CYTHON_FAST_PYCCALL
26455     if (__Pyx_PyFastCFunction_Check(function)) {
26456         PyObject *args[2] = {arg1, arg2};
26457         return __Pyx_PyCFunction_FastCall(function, args, 2);
26458     }
26459     #endif
26460     args = PyTuple_New(2);
26461     if (unlikely(!args)) goto done;
26462     Py_INCREF(arg1);
26463     PyTuple_SET_ITEM(args, 0, arg1);
26464     Py_INCREF(arg2);
26465     PyTuple_SET_ITEM(args, 1, arg2);
26466     Py_INCREF(function);
26467     result = __Pyx_PyObject_Call(function, args, NULL);
26468     Py_DECREF(args);
26469     Py_DECREF(function);
26470 done:
26471     return result;
26472 }
26473 
26474 /* PyObjectCallMethO */
26475   #if CYTHON_COMPILING_IN_CPYTHON
__Pyx_PyObject_CallMethO(PyObject * func,PyObject * arg)26476 static CYTHON_INLINE PyObject* __Pyx_PyObject_CallMethO(PyObject *func, PyObject *arg) {
26477     PyObject *self, *result;
26478     PyCFunction cfunc;
26479     cfunc = PyCFunction_GET_FUNCTION(func);
26480     self = PyCFunction_GET_SELF(func);
26481     if (unlikely(Py_EnterRecursiveCall((char*)" while calling a Python object")))
26482         return NULL;
26483     result = cfunc(self, arg);
26484     Py_LeaveRecursiveCall();
26485     if (unlikely(!result) && unlikely(!PyErr_Occurred())) {
26486         PyErr_SetString(
26487             PyExc_SystemError,
26488             "NULL result without error in PyObject_Call");
26489     }
26490     return result;
26491 }
26492 #endif
26493 
26494 /* PyObjectCallOneArg */
26495   #if CYTHON_COMPILING_IN_CPYTHON
__Pyx__PyObject_CallOneArg(PyObject * func,PyObject * arg)26496 static PyObject* __Pyx__PyObject_CallOneArg(PyObject *func, PyObject *arg) {
26497     PyObject *result;
26498     PyObject *args = PyTuple_New(1);
26499     if (unlikely(!args)) return NULL;
26500     Py_INCREF(arg);
26501     PyTuple_SET_ITEM(args, 0, arg);
26502     result = __Pyx_PyObject_Call(func, args, NULL);
26503     Py_DECREF(args);
26504     return result;
26505 }
__Pyx_PyObject_CallOneArg(PyObject * func,PyObject * arg)26506 static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg) {
26507 #if CYTHON_FAST_PYCALL
26508     if (PyFunction_Check(func)) {
26509         return __Pyx_PyFunction_FastCall(func, &arg, 1);
26510     }
26511 #endif
26512     if (likely(PyCFunction_Check(func))) {
26513         if (likely(PyCFunction_GET_FLAGS(func) & METH_O)) {
26514             return __Pyx_PyObject_CallMethO(func, arg);
26515 #if CYTHON_FAST_PYCCALL
26516         } else if (__Pyx_PyFastCFunction_Check(func)) {
26517             return __Pyx_PyCFunction_FastCall(func, &arg, 1);
26518 #endif
26519         }
26520     }
26521     return __Pyx__PyObject_CallOneArg(func, arg);
26522 }
26523 #else
__Pyx_PyObject_CallOneArg(PyObject * func,PyObject * arg)26524 static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg) {
26525     PyObject *result;
26526     PyObject *args = PyTuple_Pack(1, arg);
26527     if (unlikely(!args)) return NULL;
26528     result = __Pyx_PyObject_Call(func, args, NULL);
26529     Py_DECREF(args);
26530     return result;
26531 }
26532 #endif
26533 
26534 /* BytesEquals */
__Pyx_PyBytes_Equals(PyObject * s1,PyObject * s2,int equals)26535   static CYTHON_INLINE int __Pyx_PyBytes_Equals(PyObject* s1, PyObject* s2, int equals) {
26536 #if CYTHON_COMPILING_IN_PYPY
26537     return PyObject_RichCompareBool(s1, s2, equals);
26538 #else
26539     if (s1 == s2) {
26540         return (equals == Py_EQ);
26541     } else if (PyBytes_CheckExact(s1) & PyBytes_CheckExact(s2)) {
26542         const char *ps1, *ps2;
26543         Py_ssize_t length = PyBytes_GET_SIZE(s1);
26544         if (length != PyBytes_GET_SIZE(s2))
26545             return (equals == Py_NE);
26546         ps1 = PyBytes_AS_STRING(s1);
26547         ps2 = PyBytes_AS_STRING(s2);
26548         if (ps1[0] != ps2[0]) {
26549             return (equals == Py_NE);
26550         } else if (length == 1) {
26551             return (equals == Py_EQ);
26552         } else {
26553             int result;
26554 #if CYTHON_USE_UNICODE_INTERNALS
26555             Py_hash_t hash1, hash2;
26556             hash1 = ((PyBytesObject*)s1)->ob_shash;
26557             hash2 = ((PyBytesObject*)s2)->ob_shash;
26558             if (hash1 != hash2 && hash1 != -1 && hash2 != -1) {
26559                 return (equals == Py_NE);
26560             }
26561 #endif
26562             result = memcmp(ps1, ps2, (size_t)length);
26563             return (equals == Py_EQ) ? (result == 0) : (result != 0);
26564         }
26565     } else if ((s1 == Py_None) & PyBytes_CheckExact(s2)) {
26566         return (equals == Py_NE);
26567     } else if ((s2 == Py_None) & PyBytes_CheckExact(s1)) {
26568         return (equals == Py_NE);
26569     } else {
26570         int result;
26571         PyObject* py_result = PyObject_RichCompare(s1, s2, equals);
26572         if (!py_result)
26573             return -1;
26574         result = __Pyx_PyObject_IsTrue(py_result);
26575         Py_DECREF(py_result);
26576         return result;
26577     }
26578 #endif
26579 }
26580 
26581 /* UnicodeEquals */
__Pyx_PyUnicode_Equals(PyObject * s1,PyObject * s2,int equals)26582   static CYTHON_INLINE int __Pyx_PyUnicode_Equals(PyObject* s1, PyObject* s2, int equals) {
26583 #if CYTHON_COMPILING_IN_PYPY
26584     return PyObject_RichCompareBool(s1, s2, equals);
26585 #else
26586 #if PY_MAJOR_VERSION < 3
26587     PyObject* owned_ref = NULL;
26588 #endif
26589     int s1_is_unicode, s2_is_unicode;
26590     if (s1 == s2) {
26591         goto return_eq;
26592     }
26593     s1_is_unicode = PyUnicode_CheckExact(s1);
26594     s2_is_unicode = PyUnicode_CheckExact(s2);
26595 #if PY_MAJOR_VERSION < 3
26596     if ((s1_is_unicode & (!s2_is_unicode)) && PyString_CheckExact(s2)) {
26597         owned_ref = PyUnicode_FromObject(s2);
26598         if (unlikely(!owned_ref))
26599             return -1;
26600         s2 = owned_ref;
26601         s2_is_unicode = 1;
26602     } else if ((s2_is_unicode & (!s1_is_unicode)) && PyString_CheckExact(s1)) {
26603         owned_ref = PyUnicode_FromObject(s1);
26604         if (unlikely(!owned_ref))
26605             return -1;
26606         s1 = owned_ref;
26607         s1_is_unicode = 1;
26608     } else if (((!s2_is_unicode) & (!s1_is_unicode))) {
26609         return __Pyx_PyBytes_Equals(s1, s2, equals);
26610     }
26611 #endif
26612     if (s1_is_unicode & s2_is_unicode) {
26613         Py_ssize_t length;
26614         int kind;
26615         void *data1, *data2;
26616         if (unlikely(__Pyx_PyUnicode_READY(s1) < 0) || unlikely(__Pyx_PyUnicode_READY(s2) < 0))
26617             return -1;
26618         length = __Pyx_PyUnicode_GET_LENGTH(s1);
26619         if (length != __Pyx_PyUnicode_GET_LENGTH(s2)) {
26620             goto return_ne;
26621         }
26622 #if CYTHON_USE_UNICODE_INTERNALS
26623         {
26624             Py_hash_t hash1, hash2;
26625         #if CYTHON_PEP393_ENABLED
26626             hash1 = ((PyASCIIObject*)s1)->hash;
26627             hash2 = ((PyASCIIObject*)s2)->hash;
26628         #else
26629             hash1 = ((PyUnicodeObject*)s1)->hash;
26630             hash2 = ((PyUnicodeObject*)s2)->hash;
26631         #endif
26632             if (hash1 != hash2 && hash1 != -1 && hash2 != -1) {
26633                 goto return_ne;
26634             }
26635         }
26636 #endif
26637         kind = __Pyx_PyUnicode_KIND(s1);
26638         if (kind != __Pyx_PyUnicode_KIND(s2)) {
26639             goto return_ne;
26640         }
26641         data1 = __Pyx_PyUnicode_DATA(s1);
26642         data2 = __Pyx_PyUnicode_DATA(s2);
26643         if (__Pyx_PyUnicode_READ(kind, data1, 0) != __Pyx_PyUnicode_READ(kind, data2, 0)) {
26644             goto return_ne;
26645         } else if (length == 1) {
26646             goto return_eq;
26647         } else {
26648             int result = memcmp(data1, data2, (size_t)(length * kind));
26649             #if PY_MAJOR_VERSION < 3
26650             Py_XDECREF(owned_ref);
26651             #endif
26652             return (equals == Py_EQ) ? (result == 0) : (result != 0);
26653         }
26654     } else if ((s1 == Py_None) & s2_is_unicode) {
26655         goto return_ne;
26656     } else if ((s2 == Py_None) & s1_is_unicode) {
26657         goto return_ne;
26658     } else {
26659         int result;
26660         PyObject* py_result = PyObject_RichCompare(s1, s2, equals);
26661         #if PY_MAJOR_VERSION < 3
26662         Py_XDECREF(owned_ref);
26663         #endif
26664         if (!py_result)
26665             return -1;
26666         result = __Pyx_PyObject_IsTrue(py_result);
26667         Py_DECREF(py_result);
26668         return result;
26669     }
26670 return_eq:
26671     #if PY_MAJOR_VERSION < 3
26672     Py_XDECREF(owned_ref);
26673     #endif
26674     return (equals == Py_EQ);
26675 return_ne:
26676     #if PY_MAJOR_VERSION < 3
26677     Py_XDECREF(owned_ref);
26678     #endif
26679     return (equals == Py_NE);
26680 #endif
26681 }
26682 
26683 /* None */
__Pyx_div_Py_ssize_t(Py_ssize_t a,Py_ssize_t b)26684   static CYTHON_INLINE Py_ssize_t __Pyx_div_Py_ssize_t(Py_ssize_t a, Py_ssize_t b) {
26685     Py_ssize_t q = a / b;
26686     Py_ssize_t r = a - q*b;
26687     q -= ((r != 0) & ((r ^ b) < 0));
26688     return q;
26689 }
26690 
26691 /* GetAttr */
__Pyx_GetAttr(PyObject * o,PyObject * n)26692   static CYTHON_INLINE PyObject *__Pyx_GetAttr(PyObject *o, PyObject *n) {
26693 #if CYTHON_USE_TYPE_SLOTS
26694 #if PY_MAJOR_VERSION >= 3
26695     if (likely(PyUnicode_Check(n)))
26696 #else
26697     if (likely(PyString_Check(n)))
26698 #endif
26699         return __Pyx_PyObject_GetAttrStr(o, n);
26700 #endif
26701     return PyObject_GetAttr(o, n);
26702 }
26703 
26704 /* ObjectGetItem */
26705   #if CYTHON_USE_TYPE_SLOTS
__Pyx_PyObject_GetIndex(PyObject * obj,PyObject * index)26706 static PyObject *__Pyx_PyObject_GetIndex(PyObject *obj, PyObject* index) {
26707     PyObject *runerr;
26708     Py_ssize_t key_value;
26709     PySequenceMethods *m = Py_TYPE(obj)->tp_as_sequence;
26710     if (unlikely(!(m && m->sq_item))) {
26711         PyErr_Format(PyExc_TypeError, "'%.200s' object is not subscriptable", Py_TYPE(obj)->tp_name);
26712         return NULL;
26713     }
26714     key_value = __Pyx_PyIndex_AsSsize_t(index);
26715     if (likely(key_value != -1 || !(runerr = PyErr_Occurred()))) {
26716         return __Pyx_GetItemInt_Fast(obj, key_value, 0, 1, 1);
26717     }
26718     if (PyErr_GivenExceptionMatches(runerr, PyExc_OverflowError)) {
26719         PyErr_Clear();
26720         PyErr_Format(PyExc_IndexError, "cannot fit '%.200s' into an index-sized integer", Py_TYPE(index)->tp_name);
26721     }
26722     return NULL;
26723 }
__Pyx_PyObject_GetItem(PyObject * obj,PyObject * key)26724 static PyObject *__Pyx_PyObject_GetItem(PyObject *obj, PyObject* key) {
26725     PyMappingMethods *m = Py_TYPE(obj)->tp_as_mapping;
26726     if (likely(m && m->mp_subscript)) {
26727         return m->mp_subscript(obj, key);
26728     }
26729     return __Pyx_PyObject_GetIndex(obj, key);
26730 }
26731 #endif
26732 
26733 /* 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))26734   static CYTHON_INLINE PyObject* __Pyx_decode_c_string(
26735          const char* cstring, Py_ssize_t start, Py_ssize_t stop,
26736          const char* encoding, const char* errors,
26737          PyObject* (*decode_func)(const char *s, Py_ssize_t size, const char *errors)) {
26738     Py_ssize_t length;
26739     if (unlikely((start < 0) | (stop < 0))) {
26740         size_t slen = strlen(cstring);
26741         if (unlikely(slen > (size_t) PY_SSIZE_T_MAX)) {
26742             PyErr_SetString(PyExc_OverflowError,
26743                             "c-string too long to convert to Python");
26744             return NULL;
26745         }
26746         length = (Py_ssize_t) slen;
26747         if (start < 0) {
26748             start += length;
26749             if (start < 0)
26750                 start = 0;
26751         }
26752         if (stop < 0)
26753             stop += length;
26754     }
26755     if (unlikely(stop <= start))
26756         return __Pyx_NewRef(__pyx_empty_unicode);
26757     length = stop - start;
26758     cstring += start;
26759     if (decode_func) {
26760         return decode_func(cstring, length, errors);
26761     } else {
26762         return PyUnicode_Decode(cstring, length, encoding, errors);
26763     }
26764 }
26765 
26766 /* GetAttr3 */
__Pyx_GetAttr3Default(PyObject * d)26767   static PyObject *__Pyx_GetAttr3Default(PyObject *d) {
26768     __Pyx_PyThreadState_declare
26769     __Pyx_PyThreadState_assign
26770     if (unlikely(!__Pyx_PyErr_ExceptionMatches(PyExc_AttributeError)))
26771         return NULL;
26772     __Pyx_PyErr_Clear();
26773     Py_INCREF(d);
26774     return d;
26775 }
__Pyx_GetAttr3(PyObject * o,PyObject * n,PyObject * d)26776 static CYTHON_INLINE PyObject *__Pyx_GetAttr3(PyObject *o, PyObject *n, PyObject *d) {
26777     PyObject *r = __Pyx_GetAttr(o, n);
26778     return (likely(r)) ? r : __Pyx_GetAttr3Default(d);
26779 }
26780 
26781 /* RaiseTooManyValuesToUnpack */
__Pyx_RaiseTooManyValuesError(Py_ssize_t expected)26782   static CYTHON_INLINE void __Pyx_RaiseTooManyValuesError(Py_ssize_t expected) {
26783     PyErr_Format(PyExc_ValueError,
26784                  "too many values to unpack (expected %" CYTHON_FORMAT_SSIZE_T "d)", expected);
26785 }
26786 
26787 /* RaiseNeedMoreValuesToUnpack */
__Pyx_RaiseNeedMoreValuesError(Py_ssize_t index)26788   static CYTHON_INLINE void __Pyx_RaiseNeedMoreValuesError(Py_ssize_t index) {
26789     PyErr_Format(PyExc_ValueError,
26790                  "need more than %" CYTHON_FORMAT_SSIZE_T "d value%.1s to unpack",
26791                  index, (index == 1) ? "" : "s");
26792 }
26793 
26794 /* RaiseNoneIterError */
__Pyx_RaiseNoneNotIterableError(void)26795   static CYTHON_INLINE void __Pyx_RaiseNoneNotIterableError(void) {
26796     PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable");
26797 }
26798 
26799 /* SwapException */
26800   #if CYTHON_FAST_THREAD_STATE
__Pyx__ExceptionSwap(PyThreadState * tstate,PyObject ** type,PyObject ** value,PyObject ** tb)26801 static CYTHON_INLINE void __Pyx__ExceptionSwap(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) {
26802     PyObject *tmp_type, *tmp_value, *tmp_tb;
26803     #if CYTHON_USE_EXC_INFO_STACK
26804     _PyErr_StackItem *exc_info = tstate->exc_info;
26805     tmp_type = exc_info->exc_type;
26806     tmp_value = exc_info->exc_value;
26807     tmp_tb = exc_info->exc_traceback;
26808     exc_info->exc_type = *type;
26809     exc_info->exc_value = *value;
26810     exc_info->exc_traceback = *tb;
26811     #else
26812     tmp_type = tstate->exc_type;
26813     tmp_value = tstate->exc_value;
26814     tmp_tb = tstate->exc_traceback;
26815     tstate->exc_type = *type;
26816     tstate->exc_value = *value;
26817     tstate->exc_traceback = *tb;
26818     #endif
26819     *type = tmp_type;
26820     *value = tmp_value;
26821     *tb = tmp_tb;
26822 }
26823 #else
__Pyx_ExceptionSwap(PyObject ** type,PyObject ** value,PyObject ** tb)26824 static CYTHON_INLINE void __Pyx_ExceptionSwap(PyObject **type, PyObject **value, PyObject **tb) {
26825     PyObject *tmp_type, *tmp_value, *tmp_tb;
26826     PyErr_GetExcInfo(&tmp_type, &tmp_value, &tmp_tb);
26827     PyErr_SetExcInfo(*type, *value, *tb);
26828     *type = tmp_type;
26829     *value = tmp_value;
26830     *tb = tmp_tb;
26831 }
26832 #endif
26833 
26834 /* Import */
__Pyx_Import(PyObject * name,PyObject * from_list,int level)26835   static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, int level) {
26836     PyObject *empty_list = 0;
26837     PyObject *module = 0;
26838     PyObject *global_dict = 0;
26839     PyObject *empty_dict = 0;
26840     PyObject *list;
26841     #if PY_MAJOR_VERSION < 3
26842     PyObject *py_import;
26843     py_import = __Pyx_PyObject_GetAttrStr(__pyx_b, __pyx_n_s_import);
26844     if (!py_import)
26845         goto bad;
26846     #endif
26847     if (from_list)
26848         list = from_list;
26849     else {
26850         empty_list = PyList_New(0);
26851         if (!empty_list)
26852             goto bad;
26853         list = empty_list;
26854     }
26855     global_dict = PyModule_GetDict(__pyx_m);
26856     if (!global_dict)
26857         goto bad;
26858     empty_dict = PyDict_New();
26859     if (!empty_dict)
26860         goto bad;
26861     {
26862         #if PY_MAJOR_VERSION >= 3
26863         if (level == -1) {
26864             if ((1) && (strchr(__Pyx_MODULE_NAME, '.'))) {
26865                 module = PyImport_ImportModuleLevelObject(
26866                     name, global_dict, empty_dict, list, 1);
26867                 if (!module) {
26868                     if (!PyErr_ExceptionMatches(PyExc_ImportError))
26869                         goto bad;
26870                     PyErr_Clear();
26871                 }
26872             }
26873             level = 0;
26874         }
26875         #endif
26876         if (!module) {
26877             #if PY_MAJOR_VERSION < 3
26878             PyObject *py_level = PyInt_FromLong(level);
26879             if (!py_level)
26880                 goto bad;
26881             module = PyObject_CallFunctionObjArgs(py_import,
26882                 name, global_dict, empty_dict, list, py_level, (PyObject *)NULL);
26883             Py_DECREF(py_level);
26884             #else
26885             module = PyImport_ImportModuleLevelObject(
26886                 name, global_dict, empty_dict, list, level);
26887             #endif
26888         }
26889     }
26890 bad:
26891     #if PY_MAJOR_VERSION < 3
26892     Py_XDECREF(py_import);
26893     #endif
26894     Py_XDECREF(empty_list);
26895     Py_XDECREF(empty_dict);
26896     return module;
26897 }
26898 
26899 /* FastTypeChecks */
26900   #if CYTHON_COMPILING_IN_CPYTHON
__Pyx_InBases(PyTypeObject * a,PyTypeObject * b)26901 static int __Pyx_InBases(PyTypeObject *a, PyTypeObject *b) {
26902     while (a) {
26903         a = a->tp_base;
26904         if (a == b)
26905             return 1;
26906     }
26907     return b == &PyBaseObject_Type;
26908 }
__Pyx_IsSubtype(PyTypeObject * a,PyTypeObject * b)26909 static CYTHON_INLINE int __Pyx_IsSubtype(PyTypeObject *a, PyTypeObject *b) {
26910     PyObject *mro;
26911     if (a == b) return 1;
26912     mro = a->tp_mro;
26913     if (likely(mro)) {
26914         Py_ssize_t i, n;
26915         n = PyTuple_GET_SIZE(mro);
26916         for (i = 0; i < n; i++) {
26917             if (PyTuple_GET_ITEM(mro, i) == (PyObject *)b)
26918                 return 1;
26919         }
26920         return 0;
26921     }
26922     return __Pyx_InBases(a, b);
26923 }
26924 #if PY_MAJOR_VERSION == 2
__Pyx_inner_PyErr_GivenExceptionMatches2(PyObject * err,PyObject * exc_type1,PyObject * exc_type2)26925 static int __Pyx_inner_PyErr_GivenExceptionMatches2(PyObject *err, PyObject* exc_type1, PyObject* exc_type2) {
26926     PyObject *exception, *value, *tb;
26927     int res;
26928     __Pyx_PyThreadState_declare
26929     __Pyx_PyThreadState_assign
26930     __Pyx_ErrFetch(&exception, &value, &tb);
26931     res = exc_type1 ? PyObject_IsSubclass(err, exc_type1) : 0;
26932     if (unlikely(res == -1)) {
26933         PyErr_WriteUnraisable(err);
26934         res = 0;
26935     }
26936     if (!res) {
26937         res = PyObject_IsSubclass(err, exc_type2);
26938         if (unlikely(res == -1)) {
26939             PyErr_WriteUnraisable(err);
26940             res = 0;
26941         }
26942     }
26943     __Pyx_ErrRestore(exception, value, tb);
26944     return res;
26945 }
26946 #else
__Pyx_inner_PyErr_GivenExceptionMatches2(PyObject * err,PyObject * exc_type1,PyObject * exc_type2)26947 static CYTHON_INLINE int __Pyx_inner_PyErr_GivenExceptionMatches2(PyObject *err, PyObject* exc_type1, PyObject *exc_type2) {
26948     int res = exc_type1 ? __Pyx_IsSubtype((PyTypeObject*)err, (PyTypeObject*)exc_type1) : 0;
26949     if (!res) {
26950         res = __Pyx_IsSubtype((PyTypeObject*)err, (PyTypeObject*)exc_type2);
26951     }
26952     return res;
26953 }
26954 #endif
__Pyx_PyErr_GivenExceptionMatchesTuple(PyObject * exc_type,PyObject * tuple)26955 static int __Pyx_PyErr_GivenExceptionMatchesTuple(PyObject *exc_type, PyObject *tuple) {
26956     Py_ssize_t i, n;
26957     assert(PyExceptionClass_Check(exc_type));
26958     n = PyTuple_GET_SIZE(tuple);
26959 #if PY_MAJOR_VERSION >= 3
26960     for (i=0; i<n; i++) {
26961         if (exc_type == PyTuple_GET_ITEM(tuple, i)) return 1;
26962     }
26963 #endif
26964     for (i=0; i<n; i++) {
26965         PyObject *t = PyTuple_GET_ITEM(tuple, i);
26966         #if PY_MAJOR_VERSION < 3
26967         if (likely(exc_type == t)) return 1;
26968         #endif
26969         if (likely(PyExceptionClass_Check(t))) {
26970             if (__Pyx_inner_PyErr_GivenExceptionMatches2(exc_type, NULL, t)) return 1;
26971         } else {
26972         }
26973     }
26974     return 0;
26975 }
__Pyx_PyErr_GivenExceptionMatches(PyObject * err,PyObject * exc_type)26976 static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches(PyObject *err, PyObject* exc_type) {
26977     if (likely(err == exc_type)) return 1;
26978     if (likely(PyExceptionClass_Check(err))) {
26979         if (likely(PyExceptionClass_Check(exc_type))) {
26980             return __Pyx_inner_PyErr_GivenExceptionMatches2(err, NULL, exc_type);
26981         } else if (likely(PyTuple_Check(exc_type))) {
26982             return __Pyx_PyErr_GivenExceptionMatchesTuple(err, exc_type);
26983         } else {
26984         }
26985     }
26986     return PyErr_GivenExceptionMatches(err, exc_type);
26987 }
__Pyx_PyErr_GivenExceptionMatches2(PyObject * err,PyObject * exc_type1,PyObject * exc_type2)26988 static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches2(PyObject *err, PyObject *exc_type1, PyObject *exc_type2) {
26989     assert(PyExceptionClass_Check(exc_type1));
26990     assert(PyExceptionClass_Check(exc_type2));
26991     if (likely(err == exc_type1 || err == exc_type2)) return 1;
26992     if (likely(PyExceptionClass_Check(err))) {
26993         return __Pyx_inner_PyErr_GivenExceptionMatches2(err, exc_type1, exc_type2);
26994     }
26995     return (PyErr_GivenExceptionMatches(err, exc_type1) || PyErr_GivenExceptionMatches(err, exc_type2));
26996 }
26997 #endif
26998 
26999 /* PyIntBinop */
27000   #if !CYTHON_COMPILING_IN_PYPY
__Pyx_PyInt_AddObjC(PyObject * op1,PyObject * op2,CYTHON_UNUSED long intval,int inplace,int zerodivision_check)27001 static PyObject* __Pyx_PyInt_AddObjC(PyObject *op1, PyObject *op2, CYTHON_UNUSED long intval, int inplace, int zerodivision_check) {
27002     (void)inplace;
27003     (void)zerodivision_check;
27004     #if PY_MAJOR_VERSION < 3
27005     if (likely(PyInt_CheckExact(op1))) {
27006         const long b = intval;
27007         long x;
27008         long a = PyInt_AS_LONG(op1);
27009             x = (long)((unsigned long)a + b);
27010             if (likely((x^a) >= 0 || (x^b) >= 0))
27011                 return PyInt_FromLong(x);
27012             return PyLong_Type.tp_as_number->nb_add(op1, op2);
27013     }
27014     #endif
27015     #if CYTHON_USE_PYLONG_INTERNALS
27016     if (likely(PyLong_CheckExact(op1))) {
27017         const long b = intval;
27018         long a, x;
27019 #ifdef HAVE_LONG_LONG
27020         const PY_LONG_LONG llb = intval;
27021         PY_LONG_LONG lla, llx;
27022 #endif
27023         const digit* digits = ((PyLongObject*)op1)->ob_digit;
27024         const Py_ssize_t size = Py_SIZE(op1);
27025         if (likely(__Pyx_sst_abs(size) <= 1)) {
27026             a = likely(size) ? digits[0] : 0;
27027             if (size == -1) a = -a;
27028         } else {
27029             switch (size) {
27030                 case -2:
27031                     if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
27032                         a = -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
27033                         break;
27034 #ifdef HAVE_LONG_LONG
27035                     } else if (8 * sizeof(PY_LONG_LONG) - 1 > 2 * PyLong_SHIFT) {
27036                         lla = -(PY_LONG_LONG) (((((unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
27037                         goto long_long;
27038 #endif
27039                     }
27040                     CYTHON_FALLTHROUGH;
27041                 case 2:
27042                     if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
27043                         a = (long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
27044                         break;
27045 #ifdef HAVE_LONG_LONG
27046                     } else if (8 * sizeof(PY_LONG_LONG) - 1 > 2 * PyLong_SHIFT) {
27047                         lla = (PY_LONG_LONG) (((((unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
27048                         goto long_long;
27049 #endif
27050                     }
27051                     CYTHON_FALLTHROUGH;
27052                 case -3:
27053                     if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
27054                         a = -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
27055                         break;
27056 #ifdef HAVE_LONG_LONG
27057                     } else if (8 * sizeof(PY_LONG_LONG) - 1 > 3 * PyLong_SHIFT) {
27058                         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]));
27059                         goto long_long;
27060 #endif
27061                     }
27062                     CYTHON_FALLTHROUGH;
27063                 case 3:
27064                     if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
27065                         a = (long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
27066                         break;
27067 #ifdef HAVE_LONG_LONG
27068                     } else if (8 * sizeof(PY_LONG_LONG) - 1 > 3 * PyLong_SHIFT) {
27069                         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]));
27070                         goto long_long;
27071 #endif
27072                     }
27073                     CYTHON_FALLTHROUGH;
27074                 case -4:
27075                     if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) {
27076                         a = -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
27077                         break;
27078 #ifdef HAVE_LONG_LONG
27079                     } else if (8 * sizeof(PY_LONG_LONG) - 1 > 4 * PyLong_SHIFT) {
27080                         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]));
27081                         goto long_long;
27082 #endif
27083                     }
27084                     CYTHON_FALLTHROUGH;
27085                 case 4:
27086                     if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) {
27087                         a = (long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
27088                         break;
27089 #ifdef HAVE_LONG_LONG
27090                     } else if (8 * sizeof(PY_LONG_LONG) - 1 > 4 * PyLong_SHIFT) {
27091                         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]));
27092                         goto long_long;
27093 #endif
27094                     }
27095                     CYTHON_FALLTHROUGH;
27096                 default: return PyLong_Type.tp_as_number->nb_add(op1, op2);
27097             }
27098         }
27099                 x = a + b;
27100             return PyLong_FromLong(x);
27101 #ifdef HAVE_LONG_LONG
27102         long_long:
27103                 llx = lla + llb;
27104             return PyLong_FromLongLong(llx);
27105 #endif
27106 
27107 
27108     }
27109     #endif
27110     if (PyFloat_CheckExact(op1)) {
27111         const long b = intval;
27112         double a = PyFloat_AS_DOUBLE(op1);
27113             double result;
27114             PyFPE_START_PROTECT("add", return NULL)
27115             result = ((double)a) + (double)b;
27116             PyFPE_END_PROTECT(result)
27117             return PyFloat_FromDouble(result);
27118     }
27119     return (inplace ? PyNumber_InPlaceAdd : PyNumber_Add)(op1, op2);
27120 }
27121 #endif
27122 
27123 /* None */
__Pyx_div_long(long a,long b)27124   static CYTHON_INLINE long __Pyx_div_long(long a, long b) {
27125     long q = a / b;
27126     long r = a - q*b;
27127     q -= ((r != 0) & ((r ^ b) < 0));
27128     return q;
27129 }
27130 
27131 /* ImportFrom */
__Pyx_ImportFrom(PyObject * module,PyObject * name)27132   static PyObject* __Pyx_ImportFrom(PyObject* module, PyObject* name) {
27133     PyObject* value = __Pyx_PyObject_GetAttrStr(module, name);
27134     if (unlikely(!value) && PyErr_ExceptionMatches(PyExc_AttributeError)) {
27135         PyErr_Format(PyExc_ImportError,
27136         #if PY_MAJOR_VERSION < 3
27137             "cannot import name %.230s", PyString_AS_STRING(name));
27138         #else
27139             "cannot import name %S", name);
27140         #endif
27141     }
27142     return value;
27143 }
27144 
27145 /* HasAttr */
__Pyx_HasAttr(PyObject * o,PyObject * n)27146   static CYTHON_INLINE int __Pyx_HasAttr(PyObject *o, PyObject *n) {
27147     PyObject *r;
27148     if (unlikely(!__Pyx_PyBaseString_Check(n))) {
27149         PyErr_SetString(PyExc_TypeError,
27150                         "hasattr(): attribute name must be string");
27151         return -1;
27152     }
27153     r = __Pyx_GetAttr(o, n);
27154     if (unlikely(!r)) {
27155         PyErr_Clear();
27156         return 0;
27157     } else {
27158         Py_DECREF(r);
27159         return 1;
27160     }
27161 }
27162 
27163 /* PyObject_GenericGetAttrNoDict */
27164   #if CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP && PY_VERSION_HEX < 0x03070000
__Pyx_RaiseGenericGetAttributeError(PyTypeObject * tp,PyObject * attr_name)27165 static PyObject *__Pyx_RaiseGenericGetAttributeError(PyTypeObject *tp, PyObject *attr_name) {
27166     PyErr_Format(PyExc_AttributeError,
27167 #if PY_MAJOR_VERSION >= 3
27168                  "'%.50s' object has no attribute '%U'",
27169                  tp->tp_name, attr_name);
27170 #else
27171                  "'%.50s' object has no attribute '%.400s'",
27172                  tp->tp_name, PyString_AS_STRING(attr_name));
27173 #endif
27174     return NULL;
27175 }
__Pyx_PyObject_GenericGetAttrNoDict(PyObject * obj,PyObject * attr_name)27176 static CYTHON_INLINE PyObject* __Pyx_PyObject_GenericGetAttrNoDict(PyObject* obj, PyObject* attr_name) {
27177     PyObject *descr;
27178     PyTypeObject *tp = Py_TYPE(obj);
27179     if (unlikely(!PyString_Check(attr_name))) {
27180         return PyObject_GenericGetAttr(obj, attr_name);
27181     }
27182     assert(!tp->tp_dictoffset);
27183     descr = _PyType_Lookup(tp, attr_name);
27184     if (unlikely(!descr)) {
27185         return __Pyx_RaiseGenericGetAttributeError(tp, attr_name);
27186     }
27187     Py_INCREF(descr);
27188     #if PY_MAJOR_VERSION < 3
27189     if (likely(PyType_HasFeature(Py_TYPE(descr), Py_TPFLAGS_HAVE_CLASS)))
27190     #endif
27191     {
27192         descrgetfunc f = Py_TYPE(descr)->tp_descr_get;
27193         if (unlikely(f)) {
27194             PyObject *res = f(descr, obj, (PyObject *)tp);
27195             Py_DECREF(descr);
27196             return res;
27197         }
27198     }
27199     return descr;
27200 }
27201 #endif
27202 
27203 /* PyObject_GenericGetAttr */
27204   #if CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP && PY_VERSION_HEX < 0x03070000
__Pyx_PyObject_GenericGetAttr(PyObject * obj,PyObject * attr_name)27205 static PyObject* __Pyx_PyObject_GenericGetAttr(PyObject* obj, PyObject* attr_name) {
27206     if (unlikely(Py_TYPE(obj)->tp_dictoffset)) {
27207         return PyObject_GenericGetAttr(obj, attr_name);
27208     }
27209     return __Pyx_PyObject_GenericGetAttrNoDict(obj, attr_name);
27210 }
27211 #endif
27212 
27213 /* SetVTable */
__Pyx_SetVtable(PyObject * dict,void * vtable)27214   static int __Pyx_SetVtable(PyObject *dict, void *vtable) {
27215 #if PY_VERSION_HEX >= 0x02070000
27216     PyObject *ob = PyCapsule_New(vtable, 0, 0);
27217 #else
27218     PyObject *ob = PyCObject_FromVoidPtr(vtable, 0);
27219 #endif
27220     if (!ob)
27221         goto bad;
27222     if (PyDict_SetItem(dict, __pyx_n_s_pyx_vtable, ob) < 0)
27223         goto bad;
27224     Py_DECREF(ob);
27225     return 0;
27226 bad:
27227     Py_XDECREF(ob);
27228     return -1;
27229 }
27230 
27231 /* PyObjectGetAttrStrNoError */
__Pyx_PyObject_GetAttrStr_ClearAttributeError(void)27232   static void __Pyx_PyObject_GetAttrStr_ClearAttributeError(void) {
27233     __Pyx_PyThreadState_declare
27234     __Pyx_PyThreadState_assign
27235     if (likely(__Pyx_PyErr_ExceptionMatches(PyExc_AttributeError)))
27236         __Pyx_PyErr_Clear();
27237 }
__Pyx_PyObject_GetAttrStrNoError(PyObject * obj,PyObject * attr_name)27238 static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStrNoError(PyObject* obj, PyObject* attr_name) {
27239     PyObject *result;
27240 #if CYTHON_COMPILING_IN_CPYTHON && CYTHON_USE_TYPE_SLOTS && PY_VERSION_HEX >= 0x030700B1
27241     PyTypeObject* tp = Py_TYPE(obj);
27242     if (likely(tp->tp_getattro == PyObject_GenericGetAttr)) {
27243         return _PyObject_GenericGetAttrWithDict(obj, attr_name, NULL, 1);
27244     }
27245 #endif
27246     result = __Pyx_PyObject_GetAttrStr(obj, attr_name);
27247     if (unlikely(!result)) {
27248         __Pyx_PyObject_GetAttrStr_ClearAttributeError();
27249     }
27250     return result;
27251 }
27252 
27253 /* SetupReduce */
__Pyx_setup_reduce_is_named(PyObject * meth,PyObject * name)27254   static int __Pyx_setup_reduce_is_named(PyObject* meth, PyObject* name) {
27255   int ret;
27256   PyObject *name_attr;
27257   name_attr = __Pyx_PyObject_GetAttrStr(meth, __pyx_n_s_name_2);
27258   if (likely(name_attr)) {
27259       ret = PyObject_RichCompareBool(name_attr, name, Py_EQ);
27260   } else {
27261       ret = -1;
27262   }
27263   if (unlikely(ret < 0)) {
27264       PyErr_Clear();
27265       ret = 0;
27266   }
27267   Py_XDECREF(name_attr);
27268   return ret;
27269 }
__Pyx_setup_reduce(PyObject * type_obj)27270 static int __Pyx_setup_reduce(PyObject* type_obj) {
27271     int ret = 0;
27272     PyObject *object_reduce = NULL;
27273     PyObject *object_reduce_ex = NULL;
27274     PyObject *reduce = NULL;
27275     PyObject *reduce_ex = NULL;
27276     PyObject *reduce_cython = NULL;
27277     PyObject *setstate = NULL;
27278     PyObject *setstate_cython = NULL;
27279 #if CYTHON_USE_PYTYPE_LOOKUP
27280     if (_PyType_Lookup((PyTypeObject*)type_obj, __pyx_n_s_getstate)) goto __PYX_GOOD;
27281 #else
27282     if (PyObject_HasAttr(type_obj, __pyx_n_s_getstate)) goto __PYX_GOOD;
27283 #endif
27284 #if CYTHON_USE_PYTYPE_LOOKUP
27285     object_reduce_ex = _PyType_Lookup(&PyBaseObject_Type, __pyx_n_s_reduce_ex); if (!object_reduce_ex) goto __PYX_BAD;
27286 #else
27287     object_reduce_ex = __Pyx_PyObject_GetAttrStr((PyObject*)&PyBaseObject_Type, __pyx_n_s_reduce_ex); if (!object_reduce_ex) goto __PYX_BAD;
27288 #endif
27289     reduce_ex = __Pyx_PyObject_GetAttrStr(type_obj, __pyx_n_s_reduce_ex); if (unlikely(!reduce_ex)) goto __PYX_BAD;
27290     if (reduce_ex == object_reduce_ex) {
27291 #if CYTHON_USE_PYTYPE_LOOKUP
27292         object_reduce = _PyType_Lookup(&PyBaseObject_Type, __pyx_n_s_reduce); if (!object_reduce) goto __PYX_BAD;
27293 #else
27294         object_reduce = __Pyx_PyObject_GetAttrStr((PyObject*)&PyBaseObject_Type, __pyx_n_s_reduce); if (!object_reduce) goto __PYX_BAD;
27295 #endif
27296         reduce = __Pyx_PyObject_GetAttrStr(type_obj, __pyx_n_s_reduce); if (unlikely(!reduce)) goto __PYX_BAD;
27297         if (reduce == object_reduce || __Pyx_setup_reduce_is_named(reduce, __pyx_n_s_reduce_cython)) {
27298             reduce_cython = __Pyx_PyObject_GetAttrStrNoError(type_obj, __pyx_n_s_reduce_cython);
27299             if (likely(reduce_cython)) {
27300                 ret = PyDict_SetItem(((PyTypeObject*)type_obj)->tp_dict, __pyx_n_s_reduce, reduce_cython); if (unlikely(ret < 0)) goto __PYX_BAD;
27301                 ret = PyDict_DelItem(((PyTypeObject*)type_obj)->tp_dict, __pyx_n_s_reduce_cython); if (unlikely(ret < 0)) goto __PYX_BAD;
27302             } else if (reduce == object_reduce || PyErr_Occurred()) {
27303                 goto __PYX_BAD;
27304             }
27305             setstate = __Pyx_PyObject_GetAttrStr(type_obj, __pyx_n_s_setstate);
27306             if (!setstate) PyErr_Clear();
27307             if (!setstate || __Pyx_setup_reduce_is_named(setstate, __pyx_n_s_setstate_cython)) {
27308                 setstate_cython = __Pyx_PyObject_GetAttrStrNoError(type_obj, __pyx_n_s_setstate_cython);
27309                 if (likely(setstate_cython)) {
27310                     ret = PyDict_SetItem(((PyTypeObject*)type_obj)->tp_dict, __pyx_n_s_setstate, setstate_cython); if (unlikely(ret < 0)) goto __PYX_BAD;
27311                     ret = PyDict_DelItem(((PyTypeObject*)type_obj)->tp_dict, __pyx_n_s_setstate_cython); if (unlikely(ret < 0)) goto __PYX_BAD;
27312                 } else if (!setstate || PyErr_Occurred()) {
27313                     goto __PYX_BAD;
27314                 }
27315             }
27316             PyType_Modified((PyTypeObject*)type_obj);
27317         }
27318     }
27319     goto __PYX_GOOD;
27320 __PYX_BAD:
27321     if (!PyErr_Occurred())
27322         PyErr_Format(PyExc_RuntimeError, "Unable to initialize pickling for %s", ((PyTypeObject*)type_obj)->tp_name);
27323     ret = -1;
27324 __PYX_GOOD:
27325 #if !CYTHON_USE_PYTYPE_LOOKUP
27326     Py_XDECREF(object_reduce);
27327     Py_XDECREF(object_reduce_ex);
27328 #endif
27329     Py_XDECREF(reduce);
27330     Py_XDECREF(reduce_ex);
27331     Py_XDECREF(reduce_cython);
27332     Py_XDECREF(setstate);
27333     Py_XDECREF(setstate_cython);
27334     return ret;
27335 }
27336 
27337 /* TypeImport */
27338   #ifndef __PYX_HAVE_RT_ImportType
27339 #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)27340 static PyTypeObject *__Pyx_ImportType(PyObject *module, const char *module_name, const char *class_name,
27341     size_t size, enum __Pyx_ImportType_CheckSize check_size)
27342 {
27343     PyObject *result = 0;
27344     char warning[200];
27345     Py_ssize_t basicsize;
27346 #ifdef Py_LIMITED_API
27347     PyObject *py_basicsize;
27348 #endif
27349     result = PyObject_GetAttrString(module, class_name);
27350     if (!result)
27351         goto bad;
27352     if (!PyType_Check(result)) {
27353         PyErr_Format(PyExc_TypeError,
27354             "%.200s.%.200s is not a type object",
27355             module_name, class_name);
27356         goto bad;
27357     }
27358 #ifndef Py_LIMITED_API
27359     basicsize = ((PyTypeObject *)result)->tp_basicsize;
27360 #else
27361     py_basicsize = PyObject_GetAttrString(result, "__basicsize__");
27362     if (!py_basicsize)
27363         goto bad;
27364     basicsize = PyLong_AsSsize_t(py_basicsize);
27365     Py_DECREF(py_basicsize);
27366     py_basicsize = 0;
27367     if (basicsize == (Py_ssize_t)-1 && PyErr_Occurred())
27368         goto bad;
27369 #endif
27370     if ((size_t)basicsize < size) {
27371         PyErr_Format(PyExc_ValueError,
27372             "%.200s.%.200s size changed, may indicate binary incompatibility. "
27373             "Expected %zd from C header, got %zd from PyObject",
27374             module_name, class_name, size, basicsize);
27375         goto bad;
27376     }
27377     if (check_size == __Pyx_ImportType_CheckSize_Error && (size_t)basicsize != size) {
27378         PyErr_Format(PyExc_ValueError,
27379             "%.200s.%.200s size changed, may indicate binary incompatibility. "
27380             "Expected %zd from C header, got %zd from PyObject",
27381             module_name, class_name, size, basicsize);
27382         goto bad;
27383     }
27384     else if (check_size == __Pyx_ImportType_CheckSize_Warn && (size_t)basicsize > size) {
27385         PyOS_snprintf(warning, sizeof(warning),
27386             "%s.%s size changed, may indicate binary incompatibility. "
27387             "Expected %zd from C header, got %zd from PyObject",
27388             module_name, class_name, size, basicsize);
27389         if (PyErr_WarnEx(NULL, warning, 0) < 0) goto bad;
27390     }
27391     return (PyTypeObject *)result;
27392 bad:
27393     Py_XDECREF(result);
27394     return NULL;
27395 }
27396 #endif
27397 
27398 /* CLineInTraceback */
27399   #ifndef CYTHON_CLINE_IN_TRACEBACK
__Pyx_CLineForTraceback(CYTHON_NCP_UNUSED PyThreadState * tstate,int c_line)27400 static int __Pyx_CLineForTraceback(CYTHON_NCP_UNUSED PyThreadState *tstate, int c_line) {
27401     PyObject *use_cline;
27402     PyObject *ptype, *pvalue, *ptraceback;
27403 #if CYTHON_COMPILING_IN_CPYTHON
27404     PyObject **cython_runtime_dict;
27405 #endif
27406     if (unlikely(!__pyx_cython_runtime)) {
27407         return c_line;
27408     }
27409     __Pyx_ErrFetchInState(tstate, &ptype, &pvalue, &ptraceback);
27410 #if CYTHON_COMPILING_IN_CPYTHON
27411     cython_runtime_dict = _PyObject_GetDictPtr(__pyx_cython_runtime);
27412     if (likely(cython_runtime_dict)) {
27413         __PYX_PY_DICT_LOOKUP_IF_MODIFIED(
27414             use_cline, *cython_runtime_dict,
27415             __Pyx_PyDict_GetItemStr(*cython_runtime_dict, __pyx_n_s_cline_in_traceback))
27416     } else
27417 #endif
27418     {
27419       PyObject *use_cline_obj = __Pyx_PyObject_GetAttrStr(__pyx_cython_runtime, __pyx_n_s_cline_in_traceback);
27420       if (use_cline_obj) {
27421         use_cline = PyObject_Not(use_cline_obj) ? Py_False : Py_True;
27422         Py_DECREF(use_cline_obj);
27423       } else {
27424         PyErr_Clear();
27425         use_cline = NULL;
27426       }
27427     }
27428     if (!use_cline) {
27429         c_line = 0;
27430         PyObject_SetAttr(__pyx_cython_runtime, __pyx_n_s_cline_in_traceback, Py_False);
27431     }
27432     else if (use_cline == Py_False || (use_cline != Py_True && PyObject_Not(use_cline) != 0)) {
27433         c_line = 0;
27434     }
27435     __Pyx_ErrRestoreInState(tstate, ptype, pvalue, ptraceback);
27436     return c_line;
27437 }
27438 #endif
27439 
27440 /* CodeObjectCache */
__pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry * entries,int count,int code_line)27441   static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line) {
27442     int start = 0, mid = 0, end = count - 1;
27443     if (end >= 0 && code_line > entries[end].code_line) {
27444         return count;
27445     }
27446     while (start < end) {
27447         mid = start + (end - start) / 2;
27448         if (code_line < entries[mid].code_line) {
27449             end = mid;
27450         } else if (code_line > entries[mid].code_line) {
27451              start = mid + 1;
27452         } else {
27453             return mid;
27454         }
27455     }
27456     if (code_line <= entries[mid].code_line) {
27457         return mid;
27458     } else {
27459         return mid + 1;
27460     }
27461 }
__pyx_find_code_object(int code_line)27462 static PyCodeObject *__pyx_find_code_object(int code_line) {
27463     PyCodeObject* code_object;
27464     int pos;
27465     if (unlikely(!code_line) || unlikely(!__pyx_code_cache.entries)) {
27466         return NULL;
27467     }
27468     pos = __pyx_bisect_code_objects(__pyx_code_cache.entries, __pyx_code_cache.count, code_line);
27469     if (unlikely(pos >= __pyx_code_cache.count) || unlikely(__pyx_code_cache.entries[pos].code_line != code_line)) {
27470         return NULL;
27471     }
27472     code_object = __pyx_code_cache.entries[pos].code_object;
27473     Py_INCREF(code_object);
27474     return code_object;
27475 }
__pyx_insert_code_object(int code_line,PyCodeObject * code_object)27476 static void __pyx_insert_code_object(int code_line, PyCodeObject* code_object) {
27477     int pos, i;
27478     __Pyx_CodeObjectCacheEntry* entries = __pyx_code_cache.entries;
27479     if (unlikely(!code_line)) {
27480         return;
27481     }
27482     if (unlikely(!entries)) {
27483         entries = (__Pyx_CodeObjectCacheEntry*)PyMem_Malloc(64*sizeof(__Pyx_CodeObjectCacheEntry));
27484         if (likely(entries)) {
27485             __pyx_code_cache.entries = entries;
27486             __pyx_code_cache.max_count = 64;
27487             __pyx_code_cache.count = 1;
27488             entries[0].code_line = code_line;
27489             entries[0].code_object = code_object;
27490             Py_INCREF(code_object);
27491         }
27492         return;
27493     }
27494     pos = __pyx_bisect_code_objects(__pyx_code_cache.entries, __pyx_code_cache.count, code_line);
27495     if ((pos < __pyx_code_cache.count) && unlikely(__pyx_code_cache.entries[pos].code_line == code_line)) {
27496         PyCodeObject* tmp = entries[pos].code_object;
27497         entries[pos].code_object = code_object;
27498         Py_DECREF(tmp);
27499         return;
27500     }
27501     if (__pyx_code_cache.count == __pyx_code_cache.max_count) {
27502         int new_max = __pyx_code_cache.max_count + 64;
27503         entries = (__Pyx_CodeObjectCacheEntry*)PyMem_Realloc(
27504             __pyx_code_cache.entries, ((size_t)new_max) * sizeof(__Pyx_CodeObjectCacheEntry));
27505         if (unlikely(!entries)) {
27506             return;
27507         }
27508         __pyx_code_cache.entries = entries;
27509         __pyx_code_cache.max_count = new_max;
27510     }
27511     for (i=__pyx_code_cache.count; i>pos; i--) {
27512         entries[i] = entries[i-1];
27513     }
27514     entries[pos].code_line = code_line;
27515     entries[pos].code_object = code_object;
27516     __pyx_code_cache.count++;
27517     Py_INCREF(code_object);
27518 }
27519 
27520 /* AddTraceback */
27521   #include "compile.h"
27522 #include "frameobject.h"
27523 #include "traceback.h"
__Pyx_CreateCodeObjectForTraceback(const char * funcname,int c_line,int py_line,const char * filename)27524 static PyCodeObject* __Pyx_CreateCodeObjectForTraceback(
27525             const char *funcname, int c_line,
27526             int py_line, const char *filename) {
27527     PyCodeObject *py_code = 0;
27528     PyObject *py_srcfile = 0;
27529     PyObject *py_funcname = 0;
27530     #if PY_MAJOR_VERSION < 3
27531     py_srcfile = PyString_FromString(filename);
27532     #else
27533     py_srcfile = PyUnicode_FromString(filename);
27534     #endif
27535     if (!py_srcfile) goto bad;
27536     if (c_line) {
27537         #if PY_MAJOR_VERSION < 3
27538         py_funcname = PyString_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, c_line);
27539         #else
27540         py_funcname = PyUnicode_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, c_line);
27541         #endif
27542     }
27543     else {
27544         #if PY_MAJOR_VERSION < 3
27545         py_funcname = PyString_FromString(funcname);
27546         #else
27547         py_funcname = PyUnicode_FromString(funcname);
27548         #endif
27549     }
27550     if (!py_funcname) goto bad;
27551     py_code = __Pyx_PyCode_New(
27552         0,
27553         0,
27554         0,
27555         0,
27556         0,
27557         __pyx_empty_bytes, /*PyObject *code,*/
27558         __pyx_empty_tuple, /*PyObject *consts,*/
27559         __pyx_empty_tuple, /*PyObject *names,*/
27560         __pyx_empty_tuple, /*PyObject *varnames,*/
27561         __pyx_empty_tuple, /*PyObject *freevars,*/
27562         __pyx_empty_tuple, /*PyObject *cellvars,*/
27563         py_srcfile,   /*PyObject *filename,*/
27564         py_funcname,  /*PyObject *name,*/
27565         py_line,
27566         __pyx_empty_bytes  /*PyObject *lnotab*/
27567     );
27568     Py_DECREF(py_srcfile);
27569     Py_DECREF(py_funcname);
27570     return py_code;
27571 bad:
27572     Py_XDECREF(py_srcfile);
27573     Py_XDECREF(py_funcname);
27574     return NULL;
27575 }
__Pyx_AddTraceback(const char * funcname,int c_line,int py_line,const char * filename)27576 static void __Pyx_AddTraceback(const char *funcname, int c_line,
27577                                int py_line, const char *filename) {
27578     PyCodeObject *py_code = 0;
27579     PyFrameObject *py_frame = 0;
27580     PyThreadState *tstate = __Pyx_PyThreadState_Current;
27581     if (c_line) {
27582         c_line = __Pyx_CLineForTraceback(tstate, c_line);
27583     }
27584     py_code = __pyx_find_code_object(c_line ? -c_line : py_line);
27585     if (!py_code) {
27586         py_code = __Pyx_CreateCodeObjectForTraceback(
27587             funcname, c_line, py_line, filename);
27588         if (!py_code) goto bad;
27589         __pyx_insert_code_object(c_line ? -c_line : py_line, py_code);
27590     }
27591     py_frame = PyFrame_New(
27592         tstate,            /*PyThreadState *tstate,*/
27593         py_code,           /*PyCodeObject *code,*/
27594         __pyx_d,    /*PyObject *globals,*/
27595         0                  /*PyObject *locals*/
27596     );
27597     if (!py_frame) goto bad;
27598     __Pyx_PyFrame_SetLineNumber(py_frame, py_line);
27599     PyTraceBack_Here(py_frame);
27600 bad:
27601     Py_XDECREF(py_code);
27602     Py_XDECREF(py_frame);
27603 }
27604 
27605 /* Declarations */
27606   #if CYTHON_CCOMPLEX
27607   #ifdef __cplusplus
__pyx_t_double_complex_from_parts(double x,double y)27608     static CYTHON_INLINE __pyx_t_double_complex __pyx_t_double_complex_from_parts(double x, double y) {
27609       return ::std::complex< double >(x, y);
27610     }
27611   #else
__pyx_t_double_complex_from_parts(double x,double y)27612     static CYTHON_INLINE __pyx_t_double_complex __pyx_t_double_complex_from_parts(double x, double y) {
27613       return x + y*(__pyx_t_double_complex)_Complex_I;
27614     }
27615   #endif
27616 #else
__pyx_t_double_complex_from_parts(double x,double y)27617     static CYTHON_INLINE __pyx_t_double_complex __pyx_t_double_complex_from_parts(double x, double y) {
27618       __pyx_t_double_complex z;
27619       z.real = x;
27620       z.imag = y;
27621       return z;
27622     }
27623 #endif
27624 
27625 /* Arithmetic */
27626   #if CYTHON_CCOMPLEX
27627 #else
__Pyx_c_eq_double(__pyx_t_double_complex a,__pyx_t_double_complex b)27628     static CYTHON_INLINE int __Pyx_c_eq_double(__pyx_t_double_complex a, __pyx_t_double_complex b) {
27629        return (a.real == b.real) && (a.imag == b.imag);
27630     }
__Pyx_c_sum_double(__pyx_t_double_complex a,__pyx_t_double_complex b)27631     static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_sum_double(__pyx_t_double_complex a, __pyx_t_double_complex b) {
27632         __pyx_t_double_complex z;
27633         z.real = a.real + b.real;
27634         z.imag = a.imag + b.imag;
27635         return z;
27636     }
__Pyx_c_diff_double(__pyx_t_double_complex a,__pyx_t_double_complex b)27637     static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_diff_double(__pyx_t_double_complex a, __pyx_t_double_complex b) {
27638         __pyx_t_double_complex z;
27639         z.real = a.real - b.real;
27640         z.imag = a.imag - b.imag;
27641         return z;
27642     }
__Pyx_c_prod_double(__pyx_t_double_complex a,__pyx_t_double_complex b)27643     static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_prod_double(__pyx_t_double_complex a, __pyx_t_double_complex b) {
27644         __pyx_t_double_complex z;
27645         z.real = a.real * b.real - a.imag * b.imag;
27646         z.imag = a.real * b.imag + a.imag * b.real;
27647         return z;
27648     }
27649     #if 1
__Pyx_c_quot_double(__pyx_t_double_complex a,__pyx_t_double_complex b)27650     static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_quot_double(__pyx_t_double_complex a, __pyx_t_double_complex b) {
27651         if (b.imag == 0) {
27652             return __pyx_t_double_complex_from_parts(a.real / b.real, a.imag / b.real);
27653         } else if (fabs(b.real) >= fabs(b.imag)) {
27654             if (b.real == 0 && b.imag == 0) {
27655                 return __pyx_t_double_complex_from_parts(a.real / b.real, a.imag / b.imag);
27656             } else {
27657                 double r = b.imag / b.real;
27658                 double s = (double)(1.0) / (b.real + b.imag * r);
27659                 return __pyx_t_double_complex_from_parts(
27660                     (a.real + a.imag * r) * s, (a.imag - a.real * r) * s);
27661             }
27662         } else {
27663             double r = b.real / b.imag;
27664             double s = (double)(1.0) / (b.imag + b.real * r);
27665             return __pyx_t_double_complex_from_parts(
27666                 (a.real * r + a.imag) * s, (a.imag * r - a.real) * s);
27667         }
27668     }
27669     #else
__Pyx_c_quot_double(__pyx_t_double_complex a,__pyx_t_double_complex b)27670     static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_quot_double(__pyx_t_double_complex a, __pyx_t_double_complex b) {
27671         if (b.imag == 0) {
27672             return __pyx_t_double_complex_from_parts(a.real / b.real, a.imag / b.real);
27673         } else {
27674             double denom = b.real * b.real + b.imag * b.imag;
27675             return __pyx_t_double_complex_from_parts(
27676                 (a.real * b.real + a.imag * b.imag) / denom,
27677                 (a.imag * b.real - a.real * b.imag) / denom);
27678         }
27679     }
27680     #endif
__Pyx_c_neg_double(__pyx_t_double_complex a)27681     static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_neg_double(__pyx_t_double_complex a) {
27682         __pyx_t_double_complex z;
27683         z.real = -a.real;
27684         z.imag = -a.imag;
27685         return z;
27686     }
__Pyx_c_is_zero_double(__pyx_t_double_complex a)27687     static CYTHON_INLINE int __Pyx_c_is_zero_double(__pyx_t_double_complex a) {
27688        return (a.real == 0) && (a.imag == 0);
27689     }
__Pyx_c_conj_double(__pyx_t_double_complex a)27690     static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_conj_double(__pyx_t_double_complex a) {
27691         __pyx_t_double_complex z;
27692         z.real =  a.real;
27693         z.imag = -a.imag;
27694         return z;
27695     }
27696     #if 1
__Pyx_c_abs_double(__pyx_t_double_complex z)27697         static CYTHON_INLINE double __Pyx_c_abs_double(__pyx_t_double_complex z) {
27698           #if !defined(HAVE_HYPOT) || defined(_MSC_VER)
27699             return sqrt(z.real*z.real + z.imag*z.imag);
27700           #else
27701             return hypot(z.real, z.imag);
27702           #endif
27703         }
__Pyx_c_pow_double(__pyx_t_double_complex a,__pyx_t_double_complex b)27704         static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_pow_double(__pyx_t_double_complex a, __pyx_t_double_complex b) {
27705             __pyx_t_double_complex z;
27706             double r, lnr, theta, z_r, z_theta;
27707             if (b.imag == 0 && b.real == (int)b.real) {
27708                 if (b.real < 0) {
27709                     double denom = a.real * a.real + a.imag * a.imag;
27710                     a.real = a.real / denom;
27711                     a.imag = -a.imag / denom;
27712                     b.real = -b.real;
27713                 }
27714                 switch ((int)b.real) {
27715                     case 0:
27716                         z.real = 1;
27717                         z.imag = 0;
27718                         return z;
27719                     case 1:
27720                         return a;
27721                     case 2:
27722                         return __Pyx_c_prod_double(a, a);
27723                     case 3:
27724                         z = __Pyx_c_prod_double(a, a);
27725                         return __Pyx_c_prod_double(z, a);
27726                     case 4:
27727                         z = __Pyx_c_prod_double(a, a);
27728                         return __Pyx_c_prod_double(z, z);
27729                 }
27730             }
27731             if (a.imag == 0) {
27732                 if (a.real == 0) {
27733                     return a;
27734                 } else if (b.imag == 0) {
27735                     z.real = pow(a.real, b.real);
27736                     z.imag = 0;
27737                     return z;
27738                 } else if (a.real > 0) {
27739                     r = a.real;
27740                     theta = 0;
27741                 } else {
27742                     r = -a.real;
27743                     theta = atan2(0.0, -1.0);
27744                 }
27745             } else {
27746                 r = __Pyx_c_abs_double(a);
27747                 theta = atan2(a.imag, a.real);
27748             }
27749             lnr = log(r);
27750             z_r = exp(lnr * b.real - theta * b.imag);
27751             z_theta = theta * b.real + lnr * b.imag;
27752             z.real = z_r * cos(z_theta);
27753             z.imag = z_r * sin(z_theta);
27754             return z;
27755         }
27756     #endif
27757 #endif
27758 
27759 #if PY_MAJOR_VERSION < 3
__Pyx_GetBuffer(PyObject * obj,Py_buffer * view,int flags)27760 static int __Pyx_GetBuffer(PyObject *obj, Py_buffer *view, int flags) {
27761     if (PyObject_CheckBuffer(obj)) return PyObject_GetBuffer(obj, view, flags);
27762         if (__Pyx_TypeCheck(obj, __pyx_array_type)) return __pyx_array_getbuffer(obj, view, flags);
27763         if (__Pyx_TypeCheck(obj, __pyx_memoryview_type)) return __pyx_memoryview_getbuffer(obj, view, flags);
27764     PyErr_Format(PyExc_TypeError, "'%.200s' does not have the buffer interface", Py_TYPE(obj)->tp_name);
27765     return -1;
27766 }
__Pyx_ReleaseBuffer(Py_buffer * view)27767 static void __Pyx_ReleaseBuffer(Py_buffer *view) {
27768     PyObject *obj = view->obj;
27769     if (!obj) return;
27770     if (PyObject_CheckBuffer(obj)) {
27771         PyBuffer_Release(view);
27772         return;
27773     }
27774     if ((0)) {}
27775     view->obj = NULL;
27776     Py_DECREF(obj);
27777 }
27778 #endif
27779 
27780 
27781   /* MemviewSliceIsContig */
27782   static int
__pyx_memviewslice_is_contig(const __Pyx_memviewslice mvs,char order,int ndim)27783 __pyx_memviewslice_is_contig(const __Pyx_memviewslice mvs, char order, int ndim)
27784 {
27785     int i, index, step, start;
27786     Py_ssize_t itemsize = mvs.memview->view.itemsize;
27787     if (order == 'F') {
27788         step = 1;
27789         start = 0;
27790     } else {
27791         step = -1;
27792         start = ndim - 1;
27793     }
27794     for (i = 0; i < ndim; i++) {
27795         index = start + step * i;
27796         if (mvs.suboffsets[index] >= 0 || mvs.strides[index] != itemsize)
27797             return 0;
27798         itemsize *= mvs.shape[index];
27799     }
27800     return 1;
27801 }
27802 
27803 /* OverlappingSlices */
27804   static void
__pyx_get_array_memory_extents(__Pyx_memviewslice * slice,void ** out_start,void ** out_end,int ndim,size_t itemsize)27805 __pyx_get_array_memory_extents(__Pyx_memviewslice *slice,
27806                                void **out_start, void **out_end,
27807                                int ndim, size_t itemsize)
27808 {
27809     char *start, *end;
27810     int i;
27811     start = end = slice->data;
27812     for (i = 0; i < ndim; i++) {
27813         Py_ssize_t stride = slice->strides[i];
27814         Py_ssize_t extent = slice->shape[i];
27815         if (extent == 0) {
27816             *out_start = *out_end = start;
27817             return;
27818         } else {
27819             if (stride > 0)
27820                 end += stride * (extent - 1);
27821             else
27822                 start += stride * (extent - 1);
27823         }
27824     }
27825     *out_start = start;
27826     *out_end = end + itemsize;
27827 }
27828 static int
__pyx_slices_overlap(__Pyx_memviewslice * slice1,__Pyx_memviewslice * slice2,int ndim,size_t itemsize)27829 __pyx_slices_overlap(__Pyx_memviewslice *slice1,
27830                      __Pyx_memviewslice *slice2,
27831                      int ndim, size_t itemsize)
27832 {
27833     void *start1, *end1, *start2, *end2;
27834     __pyx_get_array_memory_extents(slice1, &start1, &end1, ndim, itemsize);
27835     __pyx_get_array_memory_extents(slice2, &start2, &end2, ndim, itemsize);
27836     return (start1 < end2) && (start2 < end1);
27837 }
27838 
27839 /* Capsule */
27840   static CYTHON_INLINE PyObject *
__pyx_capsule_create(void * p,CYTHON_UNUSED const char * sig)27841 __pyx_capsule_create(void *p, CYTHON_UNUSED const char *sig)
27842 {
27843     PyObject *cobj;
27844 #if PY_VERSION_HEX >= 0x02070000
27845     cobj = PyCapsule_New(p, sig, NULL);
27846 #else
27847     cobj = PyCObject_FromVoidPtr(p, NULL);
27848 #endif
27849     return cobj;
27850 }
27851 
27852 /* TypeInfoCompare */
27853   static int
__pyx_typeinfo_cmp(__Pyx_TypeInfo * a,__Pyx_TypeInfo * b)27854 __pyx_typeinfo_cmp(__Pyx_TypeInfo *a, __Pyx_TypeInfo *b)
27855 {
27856     int i;
27857     if (!a || !b)
27858         return 0;
27859     if (a == b)
27860         return 1;
27861     if (a->size != b->size || a->typegroup != b->typegroup ||
27862             a->is_unsigned != b->is_unsigned || a->ndim != b->ndim) {
27863         if (a->typegroup == 'H' || b->typegroup == 'H') {
27864             return a->size == b->size;
27865         } else {
27866             return 0;
27867         }
27868     }
27869     if (a->ndim) {
27870         for (i = 0; i < a->ndim; i++)
27871             if (a->arraysize[i] != b->arraysize[i])
27872                 return 0;
27873     }
27874     if (a->typegroup == 'S') {
27875         if (a->flags != b->flags)
27876             return 0;
27877         if (a->fields || b->fields) {
27878             if (!(a->fields && b->fields))
27879                 return 0;
27880             for (i = 0; a->fields[i].type && b->fields[i].type; i++) {
27881                 __Pyx_StructField *field_a = a->fields + i;
27882                 __Pyx_StructField *field_b = b->fields + i;
27883                 if (field_a->offset != field_b->offset ||
27884                     !__pyx_typeinfo_cmp(field_a->type, field_b->type))
27885                     return 0;
27886             }
27887             return !a->fields[i].type && !b->fields[i].type;
27888         }
27889     }
27890     return 1;
27891 }
27892 
27893 /* MemviewSliceValidateAndInit */
27894   static int
__pyx_check_strides(Py_buffer * buf,int dim,int ndim,int spec)27895 __pyx_check_strides(Py_buffer *buf, int dim, int ndim, int spec)
27896 {
27897     if (buf->shape[dim] <= 1)
27898         return 1;
27899     if (buf->strides) {
27900         if (spec & __Pyx_MEMVIEW_CONTIG) {
27901             if (spec & (__Pyx_MEMVIEW_PTR|__Pyx_MEMVIEW_FULL)) {
27902                 if (unlikely(buf->strides[dim] != sizeof(void *))) {
27903                     PyErr_Format(PyExc_ValueError,
27904                                  "Buffer is not indirectly contiguous "
27905                                  "in dimension %d.", dim);
27906                     goto fail;
27907                 }
27908             } else if (unlikely(buf->strides[dim] != buf->itemsize)) {
27909                 PyErr_SetString(PyExc_ValueError,
27910                                 "Buffer and memoryview are not contiguous "
27911                                 "in the same dimension.");
27912                 goto fail;
27913             }
27914         }
27915         if (spec & __Pyx_MEMVIEW_FOLLOW) {
27916             Py_ssize_t stride = buf->strides[dim];
27917             if (stride < 0)
27918                 stride = -stride;
27919             if (unlikely(stride < buf->itemsize)) {
27920                 PyErr_SetString(PyExc_ValueError,
27921                                 "Buffer and memoryview are not contiguous "
27922                                 "in the same dimension.");
27923                 goto fail;
27924             }
27925         }
27926     } else {
27927         if (unlikely(spec & __Pyx_MEMVIEW_CONTIG && dim != ndim - 1)) {
27928             PyErr_Format(PyExc_ValueError,
27929                          "C-contiguous buffer is not contiguous in "
27930                          "dimension %d", dim);
27931             goto fail;
27932         } else if (unlikely(spec & (__Pyx_MEMVIEW_PTR))) {
27933             PyErr_Format(PyExc_ValueError,
27934                          "C-contiguous buffer is not indirect in "
27935                          "dimension %d", dim);
27936             goto fail;
27937         } else if (unlikely(buf->suboffsets)) {
27938             PyErr_SetString(PyExc_ValueError,
27939                             "Buffer exposes suboffsets but no strides");
27940             goto fail;
27941         }
27942     }
27943     return 1;
27944 fail:
27945     return 0;
27946 }
27947 static int
__pyx_check_suboffsets(Py_buffer * buf,int dim,CYTHON_UNUSED int ndim,int spec)27948 __pyx_check_suboffsets(Py_buffer *buf, int dim, CYTHON_UNUSED int ndim, int spec)
27949 {
27950     if (spec & __Pyx_MEMVIEW_DIRECT) {
27951         if (unlikely(buf->suboffsets && buf->suboffsets[dim] >= 0)) {
27952             PyErr_Format(PyExc_ValueError,
27953                          "Buffer not compatible with direct access "
27954                          "in dimension %d.", dim);
27955             goto fail;
27956         }
27957     }
27958     if (spec & __Pyx_MEMVIEW_PTR) {
27959         if (unlikely(!buf->suboffsets || (buf->suboffsets[dim] < 0))) {
27960             PyErr_Format(PyExc_ValueError,
27961                          "Buffer is not indirectly accessible "
27962                          "in dimension %d.", dim);
27963             goto fail;
27964         }
27965     }
27966     return 1;
27967 fail:
27968     return 0;
27969 }
27970 static int
__pyx_verify_contig(Py_buffer * buf,int ndim,int c_or_f_flag)27971 __pyx_verify_contig(Py_buffer *buf, int ndim, int c_or_f_flag)
27972 {
27973     int i;
27974     if (c_or_f_flag & __Pyx_IS_F_CONTIG) {
27975         Py_ssize_t stride = 1;
27976         for (i = 0; i < ndim; i++) {
27977             if (unlikely(stride * buf->itemsize != buf->strides[i]  &&  buf->shape[i] > 1)) {
27978                 PyErr_SetString(PyExc_ValueError,
27979                     "Buffer not fortran contiguous.");
27980                 goto fail;
27981             }
27982             stride = stride * buf->shape[i];
27983         }
27984     } else if (c_or_f_flag & __Pyx_IS_C_CONTIG) {
27985         Py_ssize_t stride = 1;
27986         for (i = ndim - 1; i >- 1; i--) {
27987             if (unlikely(stride * buf->itemsize != buf->strides[i]  &&  buf->shape[i] > 1)) {
27988                 PyErr_SetString(PyExc_ValueError,
27989                     "Buffer not C contiguous.");
27990                 goto fail;
27991             }
27992             stride = stride * buf->shape[i];
27993         }
27994     }
27995     return 1;
27996 fail:
27997     return 0;
27998 }
__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)27999 static int __Pyx_ValidateAndInit_memviewslice(
28000                 int *axes_specs,
28001                 int c_or_f_flag,
28002                 int buf_flags,
28003                 int ndim,
28004                 __Pyx_TypeInfo *dtype,
28005                 __Pyx_BufFmt_StackElem stack[],
28006                 __Pyx_memviewslice *memviewslice,
28007                 PyObject *original_obj)
28008 {
28009     struct __pyx_memoryview_obj *memview, *new_memview;
28010     __Pyx_RefNannyDeclarations
28011     Py_buffer *buf;
28012     int i, spec = 0, retval = -1;
28013     __Pyx_BufFmt_Context ctx;
28014     int from_memoryview = __pyx_memoryview_check(original_obj);
28015     __Pyx_RefNannySetupContext("ValidateAndInit_memviewslice", 0);
28016     if (from_memoryview && __pyx_typeinfo_cmp(dtype, ((struct __pyx_memoryview_obj *)
28017                                                             original_obj)->typeinfo)) {
28018         memview = (struct __pyx_memoryview_obj *) original_obj;
28019         new_memview = NULL;
28020     } else {
28021         memview = (struct __pyx_memoryview_obj *) __pyx_memoryview_new(
28022                                             original_obj, buf_flags, 0, dtype);
28023         new_memview = memview;
28024         if (unlikely(!memview))
28025             goto fail;
28026     }
28027     buf = &memview->view;
28028     if (unlikely(buf->ndim != ndim)) {
28029         PyErr_Format(PyExc_ValueError,
28030                 "Buffer has wrong number of dimensions (expected %d, got %d)",
28031                 ndim, buf->ndim);
28032         goto fail;
28033     }
28034     if (new_memview) {
28035         __Pyx_BufFmt_Init(&ctx, stack, dtype);
28036         if (unlikely(!__Pyx_BufFmt_CheckString(&ctx, buf->format))) goto fail;
28037     }
28038     if (unlikely((unsigned) buf->itemsize != dtype->size)) {
28039         PyErr_Format(PyExc_ValueError,
28040                      "Item size of buffer (%" CYTHON_FORMAT_SSIZE_T "u byte%s) "
28041                      "does not match size of '%s' (%" CYTHON_FORMAT_SSIZE_T "u byte%s)",
28042                      buf->itemsize,
28043                      (buf->itemsize > 1) ? "s" : "",
28044                      dtype->name,
28045                      dtype->size,
28046                      (dtype->size > 1) ? "s" : "");
28047         goto fail;
28048     }
28049     if (buf->len > 0) {
28050         for (i = 0; i < ndim; i++) {
28051             spec = axes_specs[i];
28052             if (unlikely(!__pyx_check_strides(buf, i, ndim, spec)))
28053                 goto fail;
28054             if (unlikely(!__pyx_check_suboffsets(buf, i, ndim, spec)))
28055                 goto fail;
28056         }
28057         if (unlikely(buf->strides && !__pyx_verify_contig(buf, ndim, c_or_f_flag)))
28058             goto fail;
28059     }
28060     if (unlikely(__Pyx_init_memviewslice(memview, ndim, memviewslice,
28061                                          new_memview != NULL) == -1)) {
28062         goto fail;
28063     }
28064     retval = 0;
28065     goto no_fail;
28066 fail:
28067     Py_XDECREF(new_memview);
28068     retval = -1;
28069 no_fail:
28070     __Pyx_RefNannyFinishContext();
28071     return retval;
28072 }
28073 
28074 /* ObjectToMemviewSlice */
__Pyx_PyObject_to_MemoryviewSlice_dc___pyx_t_double_complex(PyObject * obj,int writable_flag)28075   static CYTHON_INLINE __Pyx_memviewslice __Pyx_PyObject_to_MemoryviewSlice_dc___pyx_t_double_complex(PyObject *obj, int writable_flag) {
28076     __Pyx_memviewslice result = { 0, 0, { 0 }, { 0 }, { 0 } };
28077     __Pyx_BufFmt_StackElem stack[1];
28078     int axes_specs[] = { (__Pyx_MEMVIEW_DIRECT | __Pyx_MEMVIEW_CONTIG) };
28079     int retcode;
28080     if (obj == Py_None) {
28081         result.memview = (struct __pyx_memoryview_obj *) Py_None;
28082         return result;
28083     }
28084     retcode = __Pyx_ValidateAndInit_memviewslice(axes_specs, __Pyx_IS_C_CONTIG,
28085                                                  (PyBUF_C_CONTIGUOUS | PyBUF_FORMAT) | writable_flag, 1,
28086                                                  &__Pyx_TypeInfo___pyx_t_double_complex, stack,
28087                                                  &result, obj);
28088     if (unlikely(retcode == -1))
28089         goto __pyx_fail;
28090     return result;
28091 __pyx_fail:
28092     result.memview = NULL;
28093     result.data = NULL;
28094     return result;
28095 }
28096 
28097 /* ObjectToMemviewSlice */
__Pyx_PyObject_to_MemoryviewSlice_dc_int(PyObject * obj,int writable_flag)28098   static CYTHON_INLINE __Pyx_memviewslice __Pyx_PyObject_to_MemoryviewSlice_dc_int(PyObject *obj, int writable_flag) {
28099     __Pyx_memviewslice result = { 0, 0, { 0 }, { 0 }, { 0 } };
28100     __Pyx_BufFmt_StackElem stack[1];
28101     int axes_specs[] = { (__Pyx_MEMVIEW_DIRECT | __Pyx_MEMVIEW_CONTIG) };
28102     int retcode;
28103     if (obj == Py_None) {
28104         result.memview = (struct __pyx_memoryview_obj *) Py_None;
28105         return result;
28106     }
28107     retcode = __Pyx_ValidateAndInit_memviewslice(axes_specs, __Pyx_IS_C_CONTIG,
28108                                                  (PyBUF_C_CONTIGUOUS | PyBUF_FORMAT) | writable_flag, 1,
28109                                                  &__Pyx_TypeInfo_int, stack,
28110                                                  &result, obj);
28111     if (unlikely(retcode == -1))
28112         goto __pyx_fail;
28113     return result;
28114 __pyx_fail:
28115     result.memview = NULL;
28116     result.data = NULL;
28117     return result;
28118 }
28119 
28120 /* FromPy */
__Pyx_PyComplex_As___pyx_t_double_complex(PyObject * o)28121   static __pyx_t_double_complex __Pyx_PyComplex_As___pyx_t_double_complex(PyObject* o) {
28122     Py_complex cval;
28123 #if !CYTHON_COMPILING_IN_PYPY
28124     if (PyComplex_CheckExact(o))
28125         cval = ((PyComplexObject *)o)->cval;
28126     else
28127 #endif
28128         cval = PyComplex_AsCComplex(o);
28129     return __pyx_t_double_complex_from_parts(
28130                (double)cval.real,
28131                (double)cval.imag);
28132 }
28133 
28134 /* ObjectToMemviewSlice */
__Pyx_PyObject_to_MemoryviewSlice_d_dc___pyx_t_double_complex(PyObject * obj,int writable_flag)28135   static CYTHON_INLINE __Pyx_memviewslice __Pyx_PyObject_to_MemoryviewSlice_d_dc___pyx_t_double_complex(PyObject *obj, int writable_flag) {
28136     __Pyx_memviewslice result = { 0, 0, { 0 }, { 0 }, { 0 } };
28137     __Pyx_BufFmt_StackElem stack[1];
28138     int axes_specs[] = { (__Pyx_MEMVIEW_DIRECT | __Pyx_MEMVIEW_FOLLOW), (__Pyx_MEMVIEW_DIRECT | __Pyx_MEMVIEW_CONTIG) };
28139     int retcode;
28140     if (obj == Py_None) {
28141         result.memview = (struct __pyx_memoryview_obj *) Py_None;
28142         return result;
28143     }
28144     retcode = __Pyx_ValidateAndInit_memviewslice(axes_specs, __Pyx_IS_C_CONTIG,
28145                                                  (PyBUF_C_CONTIGUOUS | PyBUF_FORMAT) | writable_flag, 2,
28146                                                  &__Pyx_TypeInfo___pyx_t_double_complex, stack,
28147                                                  &result, obj);
28148     if (unlikely(retcode == -1))
28149         goto __pyx_fail;
28150     return result;
28151 __pyx_fail:
28152     result.memview = NULL;
28153     result.data = NULL;
28154     return result;
28155 }
28156 
28157 /* ObjectToMemviewSlice */
__Pyx_PyObject_to_MemoryviewSlice_dcd____pyx_t_double_complex(PyObject * obj,int writable_flag)28158   static CYTHON_INLINE __Pyx_memviewslice __Pyx_PyObject_to_MemoryviewSlice_dcd____pyx_t_double_complex(PyObject *obj, int writable_flag) {
28159     __Pyx_memviewslice result = { 0, 0, { 0 }, { 0 }, { 0 } };
28160     __Pyx_BufFmt_StackElem stack[1];
28161     int axes_specs[] = { (__Pyx_MEMVIEW_DIRECT | __Pyx_MEMVIEW_CONTIG), (__Pyx_MEMVIEW_DIRECT | __Pyx_MEMVIEW_FOLLOW) };
28162     int retcode;
28163     if (obj == Py_None) {
28164         result.memview = (struct __pyx_memoryview_obj *) Py_None;
28165         return result;
28166     }
28167     retcode = __Pyx_ValidateAndInit_memviewslice(axes_specs, __Pyx_IS_F_CONTIG,
28168                                                  (PyBUF_F_CONTIGUOUS | PyBUF_FORMAT) | writable_flag, 2,
28169                                                  &__Pyx_TypeInfo___pyx_t_double_complex, stack,
28170                                                  &result, obj);
28171     if (unlikely(retcode == -1))
28172         goto __pyx_fail;
28173     return result;
28174 __pyx_fail:
28175     result.memview = NULL;
28176     result.data = NULL;
28177     return result;
28178 }
28179 
28180 /* CIntFromPyVerify */
28181   #define __PYX_VERIFY_RETURN_INT(target_type, func_type, func_value)\
28182     __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, 0)
28183 #define __PYX_VERIFY_RETURN_INT_EXC(target_type, func_type, func_value)\
28184     __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, 1)
28185 #define __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, exc)\
28186     {\
28187         func_type value = func_value;\
28188         if (sizeof(target_type) < sizeof(func_type)) {\
28189             if (unlikely(value != (func_type) (target_type) value)) {\
28190                 func_type zero = 0;\
28191                 if (exc && unlikely(value == (func_type)-1 && PyErr_Occurred()))\
28192                     return (target_type) -1;\
28193                 if (is_unsigned && unlikely(value < zero))\
28194                     goto raise_neg_overflow;\
28195                 else\
28196                     goto raise_overflow;\
28197             }\
28198         }\
28199         return (target_type) value;\
28200     }
28201 
28202 /* Declarations */
28203   #if CYTHON_CCOMPLEX
28204   #ifdef __cplusplus
__pyx_t_float_complex_from_parts(float x,float y)28205     static CYTHON_INLINE __pyx_t_float_complex __pyx_t_float_complex_from_parts(float x, float y) {
28206       return ::std::complex< float >(x, y);
28207     }
28208   #else
__pyx_t_float_complex_from_parts(float x,float y)28209     static CYTHON_INLINE __pyx_t_float_complex __pyx_t_float_complex_from_parts(float x, float y) {
28210       return x + y*(__pyx_t_float_complex)_Complex_I;
28211     }
28212   #endif
28213 #else
__pyx_t_float_complex_from_parts(float x,float y)28214     static CYTHON_INLINE __pyx_t_float_complex __pyx_t_float_complex_from_parts(float x, float y) {
28215       __pyx_t_float_complex z;
28216       z.real = x;
28217       z.imag = y;
28218       return z;
28219     }
28220 #endif
28221 
28222 /* Arithmetic */
28223   #if CYTHON_CCOMPLEX
28224 #else
__Pyx_c_eq_float(__pyx_t_float_complex a,__pyx_t_float_complex b)28225     static CYTHON_INLINE int __Pyx_c_eq_float(__pyx_t_float_complex a, __pyx_t_float_complex b) {
28226        return (a.real == b.real) && (a.imag == b.imag);
28227     }
__Pyx_c_sum_float(__pyx_t_float_complex a,__pyx_t_float_complex b)28228     static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_sum_float(__pyx_t_float_complex a, __pyx_t_float_complex b) {
28229         __pyx_t_float_complex z;
28230         z.real = a.real + b.real;
28231         z.imag = a.imag + b.imag;
28232         return z;
28233     }
__Pyx_c_diff_float(__pyx_t_float_complex a,__pyx_t_float_complex b)28234     static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_diff_float(__pyx_t_float_complex a, __pyx_t_float_complex b) {
28235         __pyx_t_float_complex z;
28236         z.real = a.real - b.real;
28237         z.imag = a.imag - b.imag;
28238         return z;
28239     }
__Pyx_c_prod_float(__pyx_t_float_complex a,__pyx_t_float_complex b)28240     static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_prod_float(__pyx_t_float_complex a, __pyx_t_float_complex b) {
28241         __pyx_t_float_complex z;
28242         z.real = a.real * b.real - a.imag * b.imag;
28243         z.imag = a.real * b.imag + a.imag * b.real;
28244         return z;
28245     }
28246     #if 1
__Pyx_c_quot_float(__pyx_t_float_complex a,__pyx_t_float_complex b)28247     static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_quot_float(__pyx_t_float_complex a, __pyx_t_float_complex b) {
28248         if (b.imag == 0) {
28249             return __pyx_t_float_complex_from_parts(a.real / b.real, a.imag / b.real);
28250         } else if (fabsf(b.real) >= fabsf(b.imag)) {
28251             if (b.real == 0 && b.imag == 0) {
28252                 return __pyx_t_float_complex_from_parts(a.real / b.real, a.imag / b.imag);
28253             } else {
28254                 float r = b.imag / b.real;
28255                 float s = (float)(1.0) / (b.real + b.imag * r);
28256                 return __pyx_t_float_complex_from_parts(
28257                     (a.real + a.imag * r) * s, (a.imag - a.real * r) * s);
28258             }
28259         } else {
28260             float r = b.real / b.imag;
28261             float s = (float)(1.0) / (b.imag + b.real * r);
28262             return __pyx_t_float_complex_from_parts(
28263                 (a.real * r + a.imag) * s, (a.imag * r - a.real) * s);
28264         }
28265     }
28266     #else
__Pyx_c_quot_float(__pyx_t_float_complex a,__pyx_t_float_complex b)28267     static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_quot_float(__pyx_t_float_complex a, __pyx_t_float_complex b) {
28268         if (b.imag == 0) {
28269             return __pyx_t_float_complex_from_parts(a.real / b.real, a.imag / b.real);
28270         } else {
28271             float denom = b.real * b.real + b.imag * b.imag;
28272             return __pyx_t_float_complex_from_parts(
28273                 (a.real * b.real + a.imag * b.imag) / denom,
28274                 (a.imag * b.real - a.real * b.imag) / denom);
28275         }
28276     }
28277     #endif
__Pyx_c_neg_float(__pyx_t_float_complex a)28278     static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_neg_float(__pyx_t_float_complex a) {
28279         __pyx_t_float_complex z;
28280         z.real = -a.real;
28281         z.imag = -a.imag;
28282         return z;
28283     }
__Pyx_c_is_zero_float(__pyx_t_float_complex a)28284     static CYTHON_INLINE int __Pyx_c_is_zero_float(__pyx_t_float_complex a) {
28285        return (a.real == 0) && (a.imag == 0);
28286     }
__Pyx_c_conj_float(__pyx_t_float_complex a)28287     static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_conj_float(__pyx_t_float_complex a) {
28288         __pyx_t_float_complex z;
28289         z.real =  a.real;
28290         z.imag = -a.imag;
28291         return z;
28292     }
28293     #if 1
__Pyx_c_abs_float(__pyx_t_float_complex z)28294         static CYTHON_INLINE float __Pyx_c_abs_float(__pyx_t_float_complex z) {
28295           #if !defined(HAVE_HYPOT) || defined(_MSC_VER)
28296             return sqrtf(z.real*z.real + z.imag*z.imag);
28297           #else
28298             return hypotf(z.real, z.imag);
28299           #endif
28300         }
__Pyx_c_pow_float(__pyx_t_float_complex a,__pyx_t_float_complex b)28301         static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_pow_float(__pyx_t_float_complex a, __pyx_t_float_complex b) {
28302             __pyx_t_float_complex z;
28303             float r, lnr, theta, z_r, z_theta;
28304             if (b.imag == 0 && b.real == (int)b.real) {
28305                 if (b.real < 0) {
28306                     float denom = a.real * a.real + a.imag * a.imag;
28307                     a.real = a.real / denom;
28308                     a.imag = -a.imag / denom;
28309                     b.real = -b.real;
28310                 }
28311                 switch ((int)b.real) {
28312                     case 0:
28313                         z.real = 1;
28314                         z.imag = 0;
28315                         return z;
28316                     case 1:
28317                         return a;
28318                     case 2:
28319                         return __Pyx_c_prod_float(a, a);
28320                     case 3:
28321                         z = __Pyx_c_prod_float(a, a);
28322                         return __Pyx_c_prod_float(z, a);
28323                     case 4:
28324                         z = __Pyx_c_prod_float(a, a);
28325                         return __Pyx_c_prod_float(z, z);
28326                 }
28327             }
28328             if (a.imag == 0) {
28329                 if (a.real == 0) {
28330                     return a;
28331                 } else if (b.imag == 0) {
28332                     z.real = powf(a.real, b.real);
28333                     z.imag = 0;
28334                     return z;
28335                 } else if (a.real > 0) {
28336                     r = a.real;
28337                     theta = 0;
28338                 } else {
28339                     r = -a.real;
28340                     theta = atan2f(0.0, -1.0);
28341                 }
28342             } else {
28343                 r = __Pyx_c_abs_float(a);
28344                 theta = atan2f(a.imag, a.real);
28345             }
28346             lnr = logf(r);
28347             z_r = expf(lnr * b.real - theta * b.imag);
28348             z_theta = theta * b.real + lnr * b.imag;
28349             z.real = z_r * cosf(z_theta);
28350             z.imag = z_r * sinf(z_theta);
28351             return z;
28352         }
28353     #endif
28354 #endif
28355 
28356 /* MemviewSliceCopyTemplate */
28357   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)28358 __pyx_memoryview_copy_new_contig(const __Pyx_memviewslice *from_mvs,
28359                                  const char *mode, int ndim,
28360                                  size_t sizeof_dtype, int contig_flag,
28361                                  int dtype_is_object)
28362 {
28363     __Pyx_RefNannyDeclarations
28364     int i;
28365     __Pyx_memviewslice new_mvs = { 0, 0, { 0 }, { 0 }, { 0 } };
28366     struct __pyx_memoryview_obj *from_memview = from_mvs->memview;
28367     Py_buffer *buf = &from_memview->view;
28368     PyObject *shape_tuple = NULL;
28369     PyObject *temp_int = NULL;
28370     struct __pyx_array_obj *array_obj = NULL;
28371     struct __pyx_memoryview_obj *memview_obj = NULL;
28372     __Pyx_RefNannySetupContext("__pyx_memoryview_copy_new_contig", 0);
28373     for (i = 0; i < ndim; i++) {
28374         if (unlikely(from_mvs->suboffsets[i] >= 0)) {
28375             PyErr_Format(PyExc_ValueError, "Cannot copy memoryview slice with "
28376                                            "indirect dimensions (axis %d)", i);
28377             goto fail;
28378         }
28379     }
28380     shape_tuple = PyTuple_New(ndim);
28381     if (unlikely(!shape_tuple)) {
28382         goto fail;
28383     }
28384     __Pyx_GOTREF(shape_tuple);
28385     for(i = 0; i < ndim; i++) {
28386         temp_int = PyInt_FromSsize_t(from_mvs->shape[i]);
28387         if(unlikely(!temp_int)) {
28388             goto fail;
28389         } else {
28390             PyTuple_SET_ITEM(shape_tuple, i, temp_int);
28391             temp_int = NULL;
28392         }
28393     }
28394     array_obj = __pyx_array_new(shape_tuple, sizeof_dtype, buf->format, (char *) mode, NULL);
28395     if (unlikely(!array_obj)) {
28396         goto fail;
28397     }
28398     __Pyx_GOTREF(array_obj);
28399     memview_obj = (struct __pyx_memoryview_obj *) __pyx_memoryview_new(
28400                                     (PyObject *) array_obj, contig_flag,
28401                                     dtype_is_object,
28402                                     from_mvs->memview->typeinfo);
28403     if (unlikely(!memview_obj))
28404         goto fail;
28405     if (unlikely(__Pyx_init_memviewslice(memview_obj, ndim, &new_mvs, 1) < 0))
28406         goto fail;
28407     if (unlikely(__pyx_memoryview_copy_contents(*from_mvs, new_mvs, ndim, ndim,
28408                                                 dtype_is_object) < 0))
28409         goto fail;
28410     goto no_fail;
28411 fail:
28412     __Pyx_XDECREF(new_mvs.memview);
28413     new_mvs.memview = NULL;
28414     new_mvs.data = NULL;
28415 no_fail:
28416     __Pyx_XDECREF(shape_tuple);
28417     __Pyx_XDECREF(temp_int);
28418     __Pyx_XDECREF(array_obj);
28419     __Pyx_RefNannyFinishContext();
28420     return new_mvs;
28421 }
28422 
28423 /* CIntFromPy */
__Pyx_PyInt_As_int(PyObject * x)28424   static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *x) {
28425 #ifdef __Pyx_HAS_GCC_DIAGNOSTIC
28426 #pragma GCC diagnostic push
28427 #pragma GCC diagnostic ignored "-Wconversion"
28428 #endif
28429     const int neg_one = (int) -1, const_zero = (int) 0;
28430 #ifdef __Pyx_HAS_GCC_DIAGNOSTIC
28431 #pragma GCC diagnostic pop
28432 #endif
28433     const int is_unsigned = neg_one > const_zero;
28434 #if PY_MAJOR_VERSION < 3
28435     if (likely(PyInt_Check(x))) {
28436         if (sizeof(int) < sizeof(long)) {
28437             __PYX_VERIFY_RETURN_INT(int, long, PyInt_AS_LONG(x))
28438         } else {
28439             long val = PyInt_AS_LONG(x);
28440             if (is_unsigned && unlikely(val < 0)) {
28441                 goto raise_neg_overflow;
28442             }
28443             return (int) val;
28444         }
28445     } else
28446 #endif
28447     if (likely(PyLong_Check(x))) {
28448         if (is_unsigned) {
28449 #if CYTHON_USE_PYLONG_INTERNALS
28450             const digit* digits = ((PyLongObject*)x)->ob_digit;
28451             switch (Py_SIZE(x)) {
28452                 case  0: return (int) 0;
28453                 case  1: __PYX_VERIFY_RETURN_INT(int, digit, digits[0])
28454                 case 2:
28455                     if (8 * sizeof(int) > 1 * PyLong_SHIFT) {
28456                         if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
28457                             __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
28458                         } else if (8 * sizeof(int) >= 2 * PyLong_SHIFT) {
28459                             return (int) (((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0]));
28460                         }
28461                     }
28462                     break;
28463                 case 3:
28464                     if (8 * sizeof(int) > 2 * PyLong_SHIFT) {
28465                         if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
28466                             __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
28467                         } else if (8 * sizeof(int) >= 3 * PyLong_SHIFT) {
28468                             return (int) (((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]));
28469                         }
28470                     }
28471                     break;
28472                 case 4:
28473                     if (8 * sizeof(int) > 3 * PyLong_SHIFT) {
28474                         if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
28475                             __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])))
28476                         } else if (8 * sizeof(int) >= 4 * PyLong_SHIFT) {
28477                             return (int) (((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]));
28478                         }
28479                     }
28480                     break;
28481             }
28482 #endif
28483 #if CYTHON_COMPILING_IN_CPYTHON
28484             if (unlikely(Py_SIZE(x) < 0)) {
28485                 goto raise_neg_overflow;
28486             }
28487 #else
28488             {
28489                 int result = PyObject_RichCompareBool(x, Py_False, Py_LT);
28490                 if (unlikely(result < 0))
28491                     return (int) -1;
28492                 if (unlikely(result == 1))
28493                     goto raise_neg_overflow;
28494             }
28495 #endif
28496             if (sizeof(int) <= sizeof(unsigned long)) {
28497                 __PYX_VERIFY_RETURN_INT_EXC(int, unsigned long, PyLong_AsUnsignedLong(x))
28498 #ifdef HAVE_LONG_LONG
28499             } else if (sizeof(int) <= sizeof(unsigned PY_LONG_LONG)) {
28500                 __PYX_VERIFY_RETURN_INT_EXC(int, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x))
28501 #endif
28502             }
28503         } else {
28504 #if CYTHON_USE_PYLONG_INTERNALS
28505             const digit* digits = ((PyLongObject*)x)->ob_digit;
28506             switch (Py_SIZE(x)) {
28507                 case  0: return (int) 0;
28508                 case -1: __PYX_VERIFY_RETURN_INT(int, sdigit, (sdigit) (-(sdigit)digits[0]))
28509                 case  1: __PYX_VERIFY_RETURN_INT(int,  digit, +digits[0])
28510                 case -2:
28511                     if (8 * sizeof(int) - 1 > 1 * PyLong_SHIFT) {
28512                         if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
28513                             __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
28514                         } else if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) {
28515                             return (int) (((int)-1)*(((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
28516                         }
28517                     }
28518                     break;
28519                 case 2:
28520                     if (8 * sizeof(int) > 1 * PyLong_SHIFT) {
28521                         if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
28522                             __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
28523                         } else if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) {
28524                             return (int) ((((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
28525                         }
28526                     }
28527                     break;
28528                 case -3:
28529                     if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) {
28530                         if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
28531                             __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
28532                         } else if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) {
28533                             return (int) (((int)-1)*(((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
28534                         }
28535                     }
28536                     break;
28537                 case 3:
28538                     if (8 * sizeof(int) > 2 * PyLong_SHIFT) {
28539                         if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
28540                             __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
28541                         } else if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) {
28542                             return (int) ((((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
28543                         }
28544                     }
28545                     break;
28546                 case -4:
28547                     if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) {
28548                         if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
28549                             __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])))
28550                         } else if (8 * sizeof(int) - 1 > 4 * PyLong_SHIFT) {
28551                             return (int) (((int)-1)*(((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
28552                         }
28553                     }
28554                     break;
28555                 case 4:
28556                     if (8 * sizeof(int) > 3 * PyLong_SHIFT) {
28557                         if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
28558                             __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])))
28559                         } else if (8 * sizeof(int) - 1 > 4 * PyLong_SHIFT) {
28560                             return (int) ((((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
28561                         }
28562                     }
28563                     break;
28564             }
28565 #endif
28566             if (sizeof(int) <= sizeof(long)) {
28567                 __PYX_VERIFY_RETURN_INT_EXC(int, long, PyLong_AsLong(x))
28568 #ifdef HAVE_LONG_LONG
28569             } else if (sizeof(int) <= sizeof(PY_LONG_LONG)) {
28570                 __PYX_VERIFY_RETURN_INT_EXC(int, PY_LONG_LONG, PyLong_AsLongLong(x))
28571 #endif
28572             }
28573         }
28574         {
28575 #if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray)
28576             PyErr_SetString(PyExc_RuntimeError,
28577                             "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers");
28578 #else
28579             int val;
28580             PyObject *v = __Pyx_PyNumber_IntOrLong(x);
28581  #if PY_MAJOR_VERSION < 3
28582             if (likely(v) && !PyLong_Check(v)) {
28583                 PyObject *tmp = v;
28584                 v = PyNumber_Long(tmp);
28585                 Py_DECREF(tmp);
28586             }
28587  #endif
28588             if (likely(v)) {
28589                 int one = 1; int is_little = (int)*(unsigned char *)&one;
28590                 unsigned char *bytes = (unsigned char *)&val;
28591                 int ret = _PyLong_AsByteArray((PyLongObject *)v,
28592                                               bytes, sizeof(val),
28593                                               is_little, !is_unsigned);
28594                 Py_DECREF(v);
28595                 if (likely(!ret))
28596                     return val;
28597             }
28598 #endif
28599             return (int) -1;
28600         }
28601     } else {
28602         int val;
28603         PyObject *tmp = __Pyx_PyNumber_IntOrLong(x);
28604         if (!tmp) return (int) -1;
28605         val = __Pyx_PyInt_As_int(tmp);
28606         Py_DECREF(tmp);
28607         return val;
28608     }
28609 raise_overflow:
28610     PyErr_SetString(PyExc_OverflowError,
28611         "value too large to convert to int");
28612     return (int) -1;
28613 raise_neg_overflow:
28614     PyErr_SetString(PyExc_OverflowError,
28615         "can't convert negative value to int");
28616     return (int) -1;
28617 }
28618 
28619 /* CIntToPy */
__Pyx_PyInt_From_unsigned_int(unsigned int value)28620   static CYTHON_INLINE PyObject* __Pyx_PyInt_From_unsigned_int(unsigned int value) {
28621 #ifdef __Pyx_HAS_GCC_DIAGNOSTIC
28622 #pragma GCC diagnostic push
28623 #pragma GCC diagnostic ignored "-Wconversion"
28624 #endif
28625     const unsigned int neg_one = (unsigned int) -1, const_zero = (unsigned int) 0;
28626 #ifdef __Pyx_HAS_GCC_DIAGNOSTIC
28627 #pragma GCC diagnostic pop
28628 #endif
28629     const int is_unsigned = neg_one > const_zero;
28630     if (is_unsigned) {
28631         if (sizeof(unsigned int) < sizeof(long)) {
28632             return PyInt_FromLong((long) value);
28633         } else if (sizeof(unsigned int) <= sizeof(unsigned long)) {
28634             return PyLong_FromUnsignedLong((unsigned long) value);
28635 #ifdef HAVE_LONG_LONG
28636         } else if (sizeof(unsigned int) <= sizeof(unsigned PY_LONG_LONG)) {
28637             return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value);
28638 #endif
28639         }
28640     } else {
28641         if (sizeof(unsigned int) <= sizeof(long)) {
28642             return PyInt_FromLong((long) value);
28643 #ifdef HAVE_LONG_LONG
28644         } else if (sizeof(unsigned int) <= sizeof(PY_LONG_LONG)) {
28645             return PyLong_FromLongLong((PY_LONG_LONG) value);
28646 #endif
28647         }
28648     }
28649     {
28650         int one = 1; int little = (int)*(unsigned char *)&one;
28651         unsigned char *bytes = (unsigned char *)&value;
28652         return _PyLong_FromByteArray(bytes, sizeof(unsigned int),
28653                                      little, !is_unsigned);
28654     }
28655 }
28656 
28657 /* CIntToPy */
__Pyx_PyInt_From_long(long value)28658   static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value) {
28659 #ifdef __Pyx_HAS_GCC_DIAGNOSTIC
28660 #pragma GCC diagnostic push
28661 #pragma GCC diagnostic ignored "-Wconversion"
28662 #endif
28663     const long neg_one = (long) -1, const_zero = (long) 0;
28664 #ifdef __Pyx_HAS_GCC_DIAGNOSTIC
28665 #pragma GCC diagnostic pop
28666 #endif
28667     const int is_unsigned = neg_one > const_zero;
28668     if (is_unsigned) {
28669         if (sizeof(long) < sizeof(long)) {
28670             return PyInt_FromLong((long) value);
28671         } else if (sizeof(long) <= sizeof(unsigned long)) {
28672             return PyLong_FromUnsignedLong((unsigned long) value);
28673 #ifdef HAVE_LONG_LONG
28674         } else if (sizeof(long) <= sizeof(unsigned PY_LONG_LONG)) {
28675             return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value);
28676 #endif
28677         }
28678     } else {
28679         if (sizeof(long) <= sizeof(long)) {
28680             return PyInt_FromLong((long) value);
28681 #ifdef HAVE_LONG_LONG
28682         } else if (sizeof(long) <= sizeof(PY_LONG_LONG)) {
28683             return PyLong_FromLongLong((PY_LONG_LONG) value);
28684 #endif
28685         }
28686     }
28687     {
28688         int one = 1; int little = (int)*(unsigned char *)&one;
28689         unsigned char *bytes = (unsigned char *)&value;
28690         return _PyLong_FromByteArray(bytes, sizeof(long),
28691                                      little, !is_unsigned);
28692     }
28693 }
28694 
28695 /* CIntFromPy */
__Pyx_PyInt_As_unsigned_int(PyObject * x)28696   static CYTHON_INLINE unsigned int __Pyx_PyInt_As_unsigned_int(PyObject *x) {
28697 #ifdef __Pyx_HAS_GCC_DIAGNOSTIC
28698 #pragma GCC diagnostic push
28699 #pragma GCC diagnostic ignored "-Wconversion"
28700 #endif
28701     const unsigned int neg_one = (unsigned int) -1, const_zero = (unsigned int) 0;
28702 #ifdef __Pyx_HAS_GCC_DIAGNOSTIC
28703 #pragma GCC diagnostic pop
28704 #endif
28705     const int is_unsigned = neg_one > const_zero;
28706 #if PY_MAJOR_VERSION < 3
28707     if (likely(PyInt_Check(x))) {
28708         if (sizeof(unsigned int) < sizeof(long)) {
28709             __PYX_VERIFY_RETURN_INT(unsigned int, long, PyInt_AS_LONG(x))
28710         } else {
28711             long val = PyInt_AS_LONG(x);
28712             if (is_unsigned && unlikely(val < 0)) {
28713                 goto raise_neg_overflow;
28714             }
28715             return (unsigned int) val;
28716         }
28717     } else
28718 #endif
28719     if (likely(PyLong_Check(x))) {
28720         if (is_unsigned) {
28721 #if CYTHON_USE_PYLONG_INTERNALS
28722             const digit* digits = ((PyLongObject*)x)->ob_digit;
28723             switch (Py_SIZE(x)) {
28724                 case  0: return (unsigned int) 0;
28725                 case  1: __PYX_VERIFY_RETURN_INT(unsigned int, digit, digits[0])
28726                 case 2:
28727                     if (8 * sizeof(unsigned int) > 1 * PyLong_SHIFT) {
28728                         if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
28729                             __PYX_VERIFY_RETURN_INT(unsigned int, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
28730                         } else if (8 * sizeof(unsigned int) >= 2 * PyLong_SHIFT) {
28731                             return (unsigned int) (((((unsigned int)digits[1]) << PyLong_SHIFT) | (unsigned int)digits[0]));
28732                         }
28733                     }
28734                     break;
28735                 case 3:
28736                     if (8 * sizeof(unsigned int) > 2 * PyLong_SHIFT) {
28737                         if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
28738                             __PYX_VERIFY_RETURN_INT(unsigned int, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
28739                         } else if (8 * sizeof(unsigned int) >= 3 * PyLong_SHIFT) {
28740                             return (unsigned int) (((((((unsigned int)digits[2]) << PyLong_SHIFT) | (unsigned int)digits[1]) << PyLong_SHIFT) | (unsigned int)digits[0]));
28741                         }
28742                     }
28743                     break;
28744                 case 4:
28745                     if (8 * sizeof(unsigned int) > 3 * PyLong_SHIFT) {
28746                         if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
28747                             __PYX_VERIFY_RETURN_INT(unsigned int, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
28748                         } else if (8 * sizeof(unsigned int) >= 4 * PyLong_SHIFT) {
28749                             return (unsigned int) (((((((((unsigned int)digits[3]) << PyLong_SHIFT) | (unsigned int)digits[2]) << PyLong_SHIFT) | (unsigned int)digits[1]) << PyLong_SHIFT) | (unsigned int)digits[0]));
28750                         }
28751                     }
28752                     break;
28753             }
28754 #endif
28755 #if CYTHON_COMPILING_IN_CPYTHON
28756             if (unlikely(Py_SIZE(x) < 0)) {
28757                 goto raise_neg_overflow;
28758             }
28759 #else
28760             {
28761                 int result = PyObject_RichCompareBool(x, Py_False, Py_LT);
28762                 if (unlikely(result < 0))
28763                     return (unsigned int) -1;
28764                 if (unlikely(result == 1))
28765                     goto raise_neg_overflow;
28766             }
28767 #endif
28768             if (sizeof(unsigned int) <= sizeof(unsigned long)) {
28769                 __PYX_VERIFY_RETURN_INT_EXC(unsigned int, unsigned long, PyLong_AsUnsignedLong(x))
28770 #ifdef HAVE_LONG_LONG
28771             } else if (sizeof(unsigned int) <= sizeof(unsigned PY_LONG_LONG)) {
28772                 __PYX_VERIFY_RETURN_INT_EXC(unsigned int, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x))
28773 #endif
28774             }
28775         } else {
28776 #if CYTHON_USE_PYLONG_INTERNALS
28777             const digit* digits = ((PyLongObject*)x)->ob_digit;
28778             switch (Py_SIZE(x)) {
28779                 case  0: return (unsigned int) 0;
28780                 case -1: __PYX_VERIFY_RETURN_INT(unsigned int, sdigit, (sdigit) (-(sdigit)digits[0]))
28781                 case  1: __PYX_VERIFY_RETURN_INT(unsigned int,  digit, +digits[0])
28782                 case -2:
28783                     if (8 * sizeof(unsigned int) - 1 > 1 * PyLong_SHIFT) {
28784                         if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
28785                             __PYX_VERIFY_RETURN_INT(unsigned int, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
28786                         } else if (8 * sizeof(unsigned int) - 1 > 2 * PyLong_SHIFT) {
28787                             return (unsigned int) (((unsigned int)-1)*(((((unsigned int)digits[1]) << PyLong_SHIFT) | (unsigned int)digits[0])));
28788                         }
28789                     }
28790                     break;
28791                 case 2:
28792                     if (8 * sizeof(unsigned int) > 1 * PyLong_SHIFT) {
28793                         if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
28794                             __PYX_VERIFY_RETURN_INT(unsigned int, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
28795                         } else if (8 * sizeof(unsigned int) - 1 > 2 * PyLong_SHIFT) {
28796                             return (unsigned int) ((((((unsigned int)digits[1]) << PyLong_SHIFT) | (unsigned int)digits[0])));
28797                         }
28798                     }
28799                     break;
28800                 case -3:
28801                     if (8 * sizeof(unsigned int) - 1 > 2 * PyLong_SHIFT) {
28802                         if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
28803                             __PYX_VERIFY_RETURN_INT(unsigned int, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
28804                         } else if (8 * sizeof(unsigned int) - 1 > 3 * PyLong_SHIFT) {
28805                             return (unsigned int) (((unsigned int)-1)*(((((((unsigned int)digits[2]) << PyLong_SHIFT) | (unsigned int)digits[1]) << PyLong_SHIFT) | (unsigned int)digits[0])));
28806                         }
28807                     }
28808                     break;
28809                 case 3:
28810                     if (8 * sizeof(unsigned int) > 2 * PyLong_SHIFT) {
28811                         if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
28812                             __PYX_VERIFY_RETURN_INT(unsigned int, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
28813                         } else if (8 * sizeof(unsigned int) - 1 > 3 * PyLong_SHIFT) {
28814                             return (unsigned int) ((((((((unsigned int)digits[2]) << PyLong_SHIFT) | (unsigned int)digits[1]) << PyLong_SHIFT) | (unsigned int)digits[0])));
28815                         }
28816                     }
28817                     break;
28818                 case -4:
28819                     if (8 * sizeof(unsigned int) - 1 > 3 * PyLong_SHIFT) {
28820                         if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
28821                             __PYX_VERIFY_RETURN_INT(unsigned int, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
28822                         } else if (8 * sizeof(unsigned int) - 1 > 4 * PyLong_SHIFT) {
28823                             return (unsigned int) (((unsigned int)-1)*(((((((((unsigned int)digits[3]) << PyLong_SHIFT) | (unsigned int)digits[2]) << PyLong_SHIFT) | (unsigned int)digits[1]) << PyLong_SHIFT) | (unsigned int)digits[0])));
28824                         }
28825                     }
28826                     break;
28827                 case 4:
28828                     if (8 * sizeof(unsigned int) > 3 * PyLong_SHIFT) {
28829                         if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
28830                             __PYX_VERIFY_RETURN_INT(unsigned int, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
28831                         } else if (8 * sizeof(unsigned int) - 1 > 4 * PyLong_SHIFT) {
28832                             return (unsigned int) ((((((((((unsigned int)digits[3]) << PyLong_SHIFT) | (unsigned int)digits[2]) << PyLong_SHIFT) | (unsigned int)digits[1]) << PyLong_SHIFT) | (unsigned int)digits[0])));
28833                         }
28834                     }
28835                     break;
28836             }
28837 #endif
28838             if (sizeof(unsigned int) <= sizeof(long)) {
28839                 __PYX_VERIFY_RETURN_INT_EXC(unsigned int, long, PyLong_AsLong(x))
28840 #ifdef HAVE_LONG_LONG
28841             } else if (sizeof(unsigned int) <= sizeof(PY_LONG_LONG)) {
28842                 __PYX_VERIFY_RETURN_INT_EXC(unsigned int, PY_LONG_LONG, PyLong_AsLongLong(x))
28843 #endif
28844             }
28845         }
28846         {
28847 #if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray)
28848             PyErr_SetString(PyExc_RuntimeError,
28849                             "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers");
28850 #else
28851             unsigned int val;
28852             PyObject *v = __Pyx_PyNumber_IntOrLong(x);
28853  #if PY_MAJOR_VERSION < 3
28854             if (likely(v) && !PyLong_Check(v)) {
28855                 PyObject *tmp = v;
28856                 v = PyNumber_Long(tmp);
28857                 Py_DECREF(tmp);
28858             }
28859  #endif
28860             if (likely(v)) {
28861                 int one = 1; int is_little = (int)*(unsigned char *)&one;
28862                 unsigned char *bytes = (unsigned char *)&val;
28863                 int ret = _PyLong_AsByteArray((PyLongObject *)v,
28864                                               bytes, sizeof(val),
28865                                               is_little, !is_unsigned);
28866                 Py_DECREF(v);
28867                 if (likely(!ret))
28868                     return val;
28869             }
28870 #endif
28871             return (unsigned int) -1;
28872         }
28873     } else {
28874         unsigned int val;
28875         PyObject *tmp = __Pyx_PyNumber_IntOrLong(x);
28876         if (!tmp) return (unsigned int) -1;
28877         val = __Pyx_PyInt_As_unsigned_int(tmp);
28878         Py_DECREF(tmp);
28879         return val;
28880     }
28881 raise_overflow:
28882     PyErr_SetString(PyExc_OverflowError,
28883         "value too large to convert to unsigned int");
28884     return (unsigned int) -1;
28885 raise_neg_overflow:
28886     PyErr_SetString(PyExc_OverflowError,
28887         "can't convert negative value to unsigned int");
28888     return (unsigned int) -1;
28889 }
28890 
28891 /* CIntToPy */
__Pyx_PyInt_From_int(int value)28892   static CYTHON_INLINE PyObject* __Pyx_PyInt_From_int(int value) {
28893 #ifdef __Pyx_HAS_GCC_DIAGNOSTIC
28894 #pragma GCC diagnostic push
28895 #pragma GCC diagnostic ignored "-Wconversion"
28896 #endif
28897     const int neg_one = (int) -1, const_zero = (int) 0;
28898 #ifdef __Pyx_HAS_GCC_DIAGNOSTIC
28899 #pragma GCC diagnostic pop
28900 #endif
28901     const int is_unsigned = neg_one > const_zero;
28902     if (is_unsigned) {
28903         if (sizeof(int) < sizeof(long)) {
28904             return PyInt_FromLong((long) value);
28905         } else if (sizeof(int) <= sizeof(unsigned long)) {
28906             return PyLong_FromUnsignedLong((unsigned long) value);
28907 #ifdef HAVE_LONG_LONG
28908         } else if (sizeof(int) <= sizeof(unsigned PY_LONG_LONG)) {
28909             return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value);
28910 #endif
28911         }
28912     } else {
28913         if (sizeof(int) <= sizeof(long)) {
28914             return PyInt_FromLong((long) value);
28915 #ifdef HAVE_LONG_LONG
28916         } else if (sizeof(int) <= sizeof(PY_LONG_LONG)) {
28917             return PyLong_FromLongLong((PY_LONG_LONG) value);
28918 #endif
28919         }
28920     }
28921     {
28922         int one = 1; int little = (int)*(unsigned char *)&one;
28923         unsigned char *bytes = (unsigned char *)&value;
28924         return _PyLong_FromByteArray(bytes, sizeof(int),
28925                                      little, !is_unsigned);
28926     }
28927 }
28928 
28929 /* CIntFromPy */
__Pyx_PyInt_As_size_t(PyObject * x)28930   static CYTHON_INLINE size_t __Pyx_PyInt_As_size_t(PyObject *x) {
28931 #ifdef __Pyx_HAS_GCC_DIAGNOSTIC
28932 #pragma GCC diagnostic push
28933 #pragma GCC diagnostic ignored "-Wconversion"
28934 #endif
28935     const size_t neg_one = (size_t) -1, const_zero = (size_t) 0;
28936 #ifdef __Pyx_HAS_GCC_DIAGNOSTIC
28937 #pragma GCC diagnostic pop
28938 #endif
28939     const int is_unsigned = neg_one > const_zero;
28940 #if PY_MAJOR_VERSION < 3
28941     if (likely(PyInt_Check(x))) {
28942         if (sizeof(size_t) < sizeof(long)) {
28943             __PYX_VERIFY_RETURN_INT(size_t, long, PyInt_AS_LONG(x))
28944         } else {
28945             long val = PyInt_AS_LONG(x);
28946             if (is_unsigned && unlikely(val < 0)) {
28947                 goto raise_neg_overflow;
28948             }
28949             return (size_t) val;
28950         }
28951     } else
28952 #endif
28953     if (likely(PyLong_Check(x))) {
28954         if (is_unsigned) {
28955 #if CYTHON_USE_PYLONG_INTERNALS
28956             const digit* digits = ((PyLongObject*)x)->ob_digit;
28957             switch (Py_SIZE(x)) {
28958                 case  0: return (size_t) 0;
28959                 case  1: __PYX_VERIFY_RETURN_INT(size_t, digit, digits[0])
28960                 case 2:
28961                     if (8 * sizeof(size_t) > 1 * PyLong_SHIFT) {
28962                         if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
28963                             __PYX_VERIFY_RETURN_INT(size_t, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
28964                         } else if (8 * sizeof(size_t) >= 2 * PyLong_SHIFT) {
28965                             return (size_t) (((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
28966                         }
28967                     }
28968                     break;
28969                 case 3:
28970                     if (8 * sizeof(size_t) > 2 * PyLong_SHIFT) {
28971                         if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
28972                             __PYX_VERIFY_RETURN_INT(size_t, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
28973                         } else if (8 * sizeof(size_t) >= 3 * PyLong_SHIFT) {
28974                             return (size_t) (((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
28975                         }
28976                     }
28977                     break;
28978                 case 4:
28979                     if (8 * sizeof(size_t) > 3 * PyLong_SHIFT) {
28980                         if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
28981                             __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])))
28982                         } else if (8 * sizeof(size_t) >= 4 * PyLong_SHIFT) {
28983                             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]));
28984                         }
28985                     }
28986                     break;
28987             }
28988 #endif
28989 #if CYTHON_COMPILING_IN_CPYTHON
28990             if (unlikely(Py_SIZE(x) < 0)) {
28991                 goto raise_neg_overflow;
28992             }
28993 #else
28994             {
28995                 int result = PyObject_RichCompareBool(x, Py_False, Py_LT);
28996                 if (unlikely(result < 0))
28997                     return (size_t) -1;
28998                 if (unlikely(result == 1))
28999                     goto raise_neg_overflow;
29000             }
29001 #endif
29002             if (sizeof(size_t) <= sizeof(unsigned long)) {
29003                 __PYX_VERIFY_RETURN_INT_EXC(size_t, unsigned long, PyLong_AsUnsignedLong(x))
29004 #ifdef HAVE_LONG_LONG
29005             } else if (sizeof(size_t) <= sizeof(unsigned PY_LONG_LONG)) {
29006                 __PYX_VERIFY_RETURN_INT_EXC(size_t, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x))
29007 #endif
29008             }
29009         } else {
29010 #if CYTHON_USE_PYLONG_INTERNALS
29011             const digit* digits = ((PyLongObject*)x)->ob_digit;
29012             switch (Py_SIZE(x)) {
29013                 case  0: return (size_t) 0;
29014                 case -1: __PYX_VERIFY_RETURN_INT(size_t, sdigit, (sdigit) (-(sdigit)digits[0]))
29015                 case  1: __PYX_VERIFY_RETURN_INT(size_t,  digit, +digits[0])
29016                 case -2:
29017                     if (8 * sizeof(size_t) - 1 > 1 * PyLong_SHIFT) {
29018                         if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
29019                             __PYX_VERIFY_RETURN_INT(size_t, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
29020                         } else if (8 * sizeof(size_t) - 1 > 2 * PyLong_SHIFT) {
29021                             return (size_t) (((size_t)-1)*(((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])));
29022                         }
29023                     }
29024                     break;
29025                 case 2:
29026                     if (8 * sizeof(size_t) > 1 * PyLong_SHIFT) {
29027                         if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
29028                             __PYX_VERIFY_RETURN_INT(size_t, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
29029                         } else if (8 * sizeof(size_t) - 1 > 2 * PyLong_SHIFT) {
29030                             return (size_t) ((((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])));
29031                         }
29032                     }
29033                     break;
29034                 case -3:
29035                     if (8 * sizeof(size_t) - 1 > 2 * PyLong_SHIFT) {
29036                         if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
29037                             __PYX_VERIFY_RETURN_INT(size_t, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
29038                         } else if (8 * sizeof(size_t) - 1 > 3 * PyLong_SHIFT) {
29039                             return (size_t) (((size_t)-1)*(((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])));
29040                         }
29041                     }
29042                     break;
29043                 case 3:
29044                     if (8 * sizeof(size_t) > 2 * PyLong_SHIFT) {
29045                         if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
29046                             __PYX_VERIFY_RETURN_INT(size_t, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
29047                         } else if (8 * sizeof(size_t) - 1 > 3 * PyLong_SHIFT) {
29048                             return (size_t) ((((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])));
29049                         }
29050                     }
29051                     break;
29052                 case -4:
29053                     if (8 * sizeof(size_t) - 1 > 3 * PyLong_SHIFT) {
29054                         if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
29055                             __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])))
29056                         } else if (8 * sizeof(size_t) - 1 > 4 * PyLong_SHIFT) {
29057                             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])));
29058                         }
29059                     }
29060                     break;
29061                 case 4:
29062                     if (8 * sizeof(size_t) > 3 * PyLong_SHIFT) {
29063                         if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
29064                             __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])))
29065                         } else if (8 * sizeof(size_t) - 1 > 4 * PyLong_SHIFT) {
29066                             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])));
29067                         }
29068                     }
29069                     break;
29070             }
29071 #endif
29072             if (sizeof(size_t) <= sizeof(long)) {
29073                 __PYX_VERIFY_RETURN_INT_EXC(size_t, long, PyLong_AsLong(x))
29074 #ifdef HAVE_LONG_LONG
29075             } else if (sizeof(size_t) <= sizeof(PY_LONG_LONG)) {
29076                 __PYX_VERIFY_RETURN_INT_EXC(size_t, PY_LONG_LONG, PyLong_AsLongLong(x))
29077 #endif
29078             }
29079         }
29080         {
29081 #if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray)
29082             PyErr_SetString(PyExc_RuntimeError,
29083                             "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers");
29084 #else
29085             size_t val;
29086             PyObject *v = __Pyx_PyNumber_IntOrLong(x);
29087  #if PY_MAJOR_VERSION < 3
29088             if (likely(v) && !PyLong_Check(v)) {
29089                 PyObject *tmp = v;
29090                 v = PyNumber_Long(tmp);
29091                 Py_DECREF(tmp);
29092             }
29093  #endif
29094             if (likely(v)) {
29095                 int one = 1; int is_little = (int)*(unsigned char *)&one;
29096                 unsigned char *bytes = (unsigned char *)&val;
29097                 int ret = _PyLong_AsByteArray((PyLongObject *)v,
29098                                               bytes, sizeof(val),
29099                                               is_little, !is_unsigned);
29100                 Py_DECREF(v);
29101                 if (likely(!ret))
29102                     return val;
29103             }
29104 #endif
29105             return (size_t) -1;
29106         }
29107     } else {
29108         size_t val;
29109         PyObject *tmp = __Pyx_PyNumber_IntOrLong(x);
29110         if (!tmp) return (size_t) -1;
29111         val = __Pyx_PyInt_As_size_t(tmp);
29112         Py_DECREF(tmp);
29113         return val;
29114     }
29115 raise_overflow:
29116     PyErr_SetString(PyExc_OverflowError,
29117         "value too large to convert to size_t");
29118     return (size_t) -1;
29119 raise_neg_overflow:
29120     PyErr_SetString(PyExc_OverflowError,
29121         "can't convert negative value to size_t");
29122     return (size_t) -1;
29123 }
29124 
29125 /* CIntFromPy */
__Pyx_PyInt_As_long(PyObject * x)29126   static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *x) {
29127 #ifdef __Pyx_HAS_GCC_DIAGNOSTIC
29128 #pragma GCC diagnostic push
29129 #pragma GCC diagnostic ignored "-Wconversion"
29130 #endif
29131     const long neg_one = (long) -1, const_zero = (long) 0;
29132 #ifdef __Pyx_HAS_GCC_DIAGNOSTIC
29133 #pragma GCC diagnostic pop
29134 #endif
29135     const int is_unsigned = neg_one > const_zero;
29136 #if PY_MAJOR_VERSION < 3
29137     if (likely(PyInt_Check(x))) {
29138         if (sizeof(long) < sizeof(long)) {
29139             __PYX_VERIFY_RETURN_INT(long, long, PyInt_AS_LONG(x))
29140         } else {
29141             long val = PyInt_AS_LONG(x);
29142             if (is_unsigned && unlikely(val < 0)) {
29143                 goto raise_neg_overflow;
29144             }
29145             return (long) val;
29146         }
29147     } else
29148 #endif
29149     if (likely(PyLong_Check(x))) {
29150         if (is_unsigned) {
29151 #if CYTHON_USE_PYLONG_INTERNALS
29152             const digit* digits = ((PyLongObject*)x)->ob_digit;
29153             switch (Py_SIZE(x)) {
29154                 case  0: return (long) 0;
29155                 case  1: __PYX_VERIFY_RETURN_INT(long, digit, digits[0])
29156                 case 2:
29157                     if (8 * sizeof(long) > 1 * PyLong_SHIFT) {
29158                         if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
29159                             __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
29160                         } else if (8 * sizeof(long) >= 2 * PyLong_SHIFT) {
29161                             return (long) (((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0]));
29162                         }
29163                     }
29164                     break;
29165                 case 3:
29166                     if (8 * sizeof(long) > 2 * PyLong_SHIFT) {
29167                         if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
29168                             __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
29169                         } else if (8 * sizeof(long) >= 3 * PyLong_SHIFT) {
29170                             return (long) (((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]));
29171                         }
29172                     }
29173                     break;
29174                 case 4:
29175                     if (8 * sizeof(long) > 3 * PyLong_SHIFT) {
29176                         if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
29177                             __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])))
29178                         } else if (8 * sizeof(long) >= 4 * PyLong_SHIFT) {
29179                             return (long) (((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]));
29180                         }
29181                     }
29182                     break;
29183             }
29184 #endif
29185 #if CYTHON_COMPILING_IN_CPYTHON
29186             if (unlikely(Py_SIZE(x) < 0)) {
29187                 goto raise_neg_overflow;
29188             }
29189 #else
29190             {
29191                 int result = PyObject_RichCompareBool(x, Py_False, Py_LT);
29192                 if (unlikely(result < 0))
29193                     return (long) -1;
29194                 if (unlikely(result == 1))
29195                     goto raise_neg_overflow;
29196             }
29197 #endif
29198             if (sizeof(long) <= sizeof(unsigned long)) {
29199                 __PYX_VERIFY_RETURN_INT_EXC(long, unsigned long, PyLong_AsUnsignedLong(x))
29200 #ifdef HAVE_LONG_LONG
29201             } else if (sizeof(long) <= sizeof(unsigned PY_LONG_LONG)) {
29202                 __PYX_VERIFY_RETURN_INT_EXC(long, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x))
29203 #endif
29204             }
29205         } else {
29206 #if CYTHON_USE_PYLONG_INTERNALS
29207             const digit* digits = ((PyLongObject*)x)->ob_digit;
29208             switch (Py_SIZE(x)) {
29209                 case  0: return (long) 0;
29210                 case -1: __PYX_VERIFY_RETURN_INT(long, sdigit, (sdigit) (-(sdigit)digits[0]))
29211                 case  1: __PYX_VERIFY_RETURN_INT(long,  digit, +digits[0])
29212                 case -2:
29213                     if (8 * sizeof(long) - 1 > 1 * PyLong_SHIFT) {
29214                         if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
29215                             __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
29216                         } else if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
29217                             return (long) (((long)-1)*(((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
29218                         }
29219                     }
29220                     break;
29221                 case 2:
29222                     if (8 * sizeof(long) > 1 * PyLong_SHIFT) {
29223                         if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
29224                             __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
29225                         } else if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
29226                             return (long) ((((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
29227                         }
29228                     }
29229                     break;
29230                 case -3:
29231                     if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
29232                         if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
29233                             __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
29234                         } else if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
29235                             return (long) (((long)-1)*(((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
29236                         }
29237                     }
29238                     break;
29239                 case 3:
29240                     if (8 * sizeof(long) > 2 * PyLong_SHIFT) {
29241                         if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
29242                             __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
29243                         } else if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
29244                             return (long) ((((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
29245                         }
29246                     }
29247                     break;
29248                 case -4:
29249                     if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
29250                         if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
29251                             __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])))
29252                         } else if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) {
29253                             return (long) (((long)-1)*(((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
29254                         }
29255                     }
29256                     break;
29257                 case 4:
29258                     if (8 * sizeof(long) > 3 * PyLong_SHIFT) {
29259                         if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
29260                             __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])))
29261                         } else if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) {
29262                             return (long) ((((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
29263                         }
29264                     }
29265                     break;
29266             }
29267 #endif
29268             if (sizeof(long) <= sizeof(long)) {
29269                 __PYX_VERIFY_RETURN_INT_EXC(long, long, PyLong_AsLong(x))
29270 #ifdef HAVE_LONG_LONG
29271             } else if (sizeof(long) <= sizeof(PY_LONG_LONG)) {
29272                 __PYX_VERIFY_RETURN_INT_EXC(long, PY_LONG_LONG, PyLong_AsLongLong(x))
29273 #endif
29274             }
29275         }
29276         {
29277 #if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray)
29278             PyErr_SetString(PyExc_RuntimeError,
29279                             "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers");
29280 #else
29281             long val;
29282             PyObject *v = __Pyx_PyNumber_IntOrLong(x);
29283  #if PY_MAJOR_VERSION < 3
29284             if (likely(v) && !PyLong_Check(v)) {
29285                 PyObject *tmp = v;
29286                 v = PyNumber_Long(tmp);
29287                 Py_DECREF(tmp);
29288             }
29289  #endif
29290             if (likely(v)) {
29291                 int one = 1; int is_little = (int)*(unsigned char *)&one;
29292                 unsigned char *bytes = (unsigned char *)&val;
29293                 int ret = _PyLong_AsByteArray((PyLongObject *)v,
29294                                               bytes, sizeof(val),
29295                                               is_little, !is_unsigned);
29296                 Py_DECREF(v);
29297                 if (likely(!ret))
29298                     return val;
29299             }
29300 #endif
29301             return (long) -1;
29302         }
29303     } else {
29304         long val;
29305         PyObject *tmp = __Pyx_PyNumber_IntOrLong(x);
29306         if (!tmp) return (long) -1;
29307         val = __Pyx_PyInt_As_long(tmp);
29308         Py_DECREF(tmp);
29309         return val;
29310     }
29311 raise_overflow:
29312     PyErr_SetString(PyExc_OverflowError,
29313         "value too large to convert to long");
29314     return (long) -1;
29315 raise_neg_overflow:
29316     PyErr_SetString(PyExc_OverflowError,
29317         "can't convert negative value to long");
29318     return (long) -1;
29319 }
29320 
29321 /* CIntFromPy */
__Pyx_PyInt_As_char(PyObject * x)29322   static CYTHON_INLINE char __Pyx_PyInt_As_char(PyObject *x) {
29323 #ifdef __Pyx_HAS_GCC_DIAGNOSTIC
29324 #pragma GCC diagnostic push
29325 #pragma GCC diagnostic ignored "-Wconversion"
29326 #endif
29327     const char neg_one = (char) -1, const_zero = (char) 0;
29328 #ifdef __Pyx_HAS_GCC_DIAGNOSTIC
29329 #pragma GCC diagnostic pop
29330 #endif
29331     const int is_unsigned = neg_one > const_zero;
29332 #if PY_MAJOR_VERSION < 3
29333     if (likely(PyInt_Check(x))) {
29334         if (sizeof(char) < sizeof(long)) {
29335             __PYX_VERIFY_RETURN_INT(char, long, PyInt_AS_LONG(x))
29336         } else {
29337             long val = PyInt_AS_LONG(x);
29338             if (is_unsigned && unlikely(val < 0)) {
29339                 goto raise_neg_overflow;
29340             }
29341             return (char) val;
29342         }
29343     } else
29344 #endif
29345     if (likely(PyLong_Check(x))) {
29346         if (is_unsigned) {
29347 #if CYTHON_USE_PYLONG_INTERNALS
29348             const digit* digits = ((PyLongObject*)x)->ob_digit;
29349             switch (Py_SIZE(x)) {
29350                 case  0: return (char) 0;
29351                 case  1: __PYX_VERIFY_RETURN_INT(char, digit, digits[0])
29352                 case 2:
29353                     if (8 * sizeof(char) > 1 * PyLong_SHIFT) {
29354                         if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
29355                             __PYX_VERIFY_RETURN_INT(char, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
29356                         } else if (8 * sizeof(char) >= 2 * PyLong_SHIFT) {
29357                             return (char) (((((char)digits[1]) << PyLong_SHIFT) | (char)digits[0]));
29358                         }
29359                     }
29360                     break;
29361                 case 3:
29362                     if (8 * sizeof(char) > 2 * PyLong_SHIFT) {
29363                         if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
29364                             __PYX_VERIFY_RETURN_INT(char, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
29365                         } else if (8 * sizeof(char) >= 3 * PyLong_SHIFT) {
29366                             return (char) (((((((char)digits[2]) << PyLong_SHIFT) | (char)digits[1]) << PyLong_SHIFT) | (char)digits[0]));
29367                         }
29368                     }
29369                     break;
29370                 case 4:
29371                     if (8 * sizeof(char) > 3 * PyLong_SHIFT) {
29372                         if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
29373                             __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])))
29374                         } else if (8 * sizeof(char) >= 4 * PyLong_SHIFT) {
29375                             return (char) (((((((((char)digits[3]) << PyLong_SHIFT) | (char)digits[2]) << PyLong_SHIFT) | (char)digits[1]) << PyLong_SHIFT) | (char)digits[0]));
29376                         }
29377                     }
29378                     break;
29379             }
29380 #endif
29381 #if CYTHON_COMPILING_IN_CPYTHON
29382             if (unlikely(Py_SIZE(x) < 0)) {
29383                 goto raise_neg_overflow;
29384             }
29385 #else
29386             {
29387                 int result = PyObject_RichCompareBool(x, Py_False, Py_LT);
29388                 if (unlikely(result < 0))
29389                     return (char) -1;
29390                 if (unlikely(result == 1))
29391                     goto raise_neg_overflow;
29392             }
29393 #endif
29394             if (sizeof(char) <= sizeof(unsigned long)) {
29395                 __PYX_VERIFY_RETURN_INT_EXC(char, unsigned long, PyLong_AsUnsignedLong(x))
29396 #ifdef HAVE_LONG_LONG
29397             } else if (sizeof(char) <= sizeof(unsigned PY_LONG_LONG)) {
29398                 __PYX_VERIFY_RETURN_INT_EXC(char, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x))
29399 #endif
29400             }
29401         } else {
29402 #if CYTHON_USE_PYLONG_INTERNALS
29403             const digit* digits = ((PyLongObject*)x)->ob_digit;
29404             switch (Py_SIZE(x)) {
29405                 case  0: return (char) 0;
29406                 case -1: __PYX_VERIFY_RETURN_INT(char, sdigit, (sdigit) (-(sdigit)digits[0]))
29407                 case  1: __PYX_VERIFY_RETURN_INT(char,  digit, +digits[0])
29408                 case -2:
29409                     if (8 * sizeof(char) - 1 > 1 * PyLong_SHIFT) {
29410                         if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
29411                             __PYX_VERIFY_RETURN_INT(char, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
29412                         } else if (8 * sizeof(char) - 1 > 2 * PyLong_SHIFT) {
29413                             return (char) (((char)-1)*(((((char)digits[1]) << PyLong_SHIFT) | (char)digits[0])));
29414                         }
29415                     }
29416                     break;
29417                 case 2:
29418                     if (8 * sizeof(char) > 1 * PyLong_SHIFT) {
29419                         if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
29420                             __PYX_VERIFY_RETURN_INT(char, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
29421                         } else if (8 * sizeof(char) - 1 > 2 * PyLong_SHIFT) {
29422                             return (char) ((((((char)digits[1]) << PyLong_SHIFT) | (char)digits[0])));
29423                         }
29424                     }
29425                     break;
29426                 case -3:
29427                     if (8 * sizeof(char) - 1 > 2 * PyLong_SHIFT) {
29428                         if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
29429                             __PYX_VERIFY_RETURN_INT(char, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
29430                         } else if (8 * sizeof(char) - 1 > 3 * PyLong_SHIFT) {
29431                             return (char) (((char)-1)*(((((((char)digits[2]) << PyLong_SHIFT) | (char)digits[1]) << PyLong_SHIFT) | (char)digits[0])));
29432                         }
29433                     }
29434                     break;
29435                 case 3:
29436                     if (8 * sizeof(char) > 2 * PyLong_SHIFT) {
29437                         if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
29438                             __PYX_VERIFY_RETURN_INT(char, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
29439                         } else if (8 * sizeof(char) - 1 > 3 * PyLong_SHIFT) {
29440                             return (char) ((((((((char)digits[2]) << PyLong_SHIFT) | (char)digits[1]) << PyLong_SHIFT) | (char)digits[0])));
29441                         }
29442                     }
29443                     break;
29444                 case -4:
29445                     if (8 * sizeof(char) - 1 > 3 * PyLong_SHIFT) {
29446                         if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
29447                             __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])))
29448                         } else if (8 * sizeof(char) - 1 > 4 * PyLong_SHIFT) {
29449                             return (char) (((char)-1)*(((((((((char)digits[3]) << PyLong_SHIFT) | (char)digits[2]) << PyLong_SHIFT) | (char)digits[1]) << PyLong_SHIFT) | (char)digits[0])));
29450                         }
29451                     }
29452                     break;
29453                 case 4:
29454                     if (8 * sizeof(char) > 3 * PyLong_SHIFT) {
29455                         if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
29456                             __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])))
29457                         } else if (8 * sizeof(char) - 1 > 4 * PyLong_SHIFT) {
29458                             return (char) ((((((((((char)digits[3]) << PyLong_SHIFT) | (char)digits[2]) << PyLong_SHIFT) | (char)digits[1]) << PyLong_SHIFT) | (char)digits[0])));
29459                         }
29460                     }
29461                     break;
29462             }
29463 #endif
29464             if (sizeof(char) <= sizeof(long)) {
29465                 __PYX_VERIFY_RETURN_INT_EXC(char, long, PyLong_AsLong(x))
29466 #ifdef HAVE_LONG_LONG
29467             } else if (sizeof(char) <= sizeof(PY_LONG_LONG)) {
29468                 __PYX_VERIFY_RETURN_INT_EXC(char, PY_LONG_LONG, PyLong_AsLongLong(x))
29469 #endif
29470             }
29471         }
29472         {
29473 #if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray)
29474             PyErr_SetString(PyExc_RuntimeError,
29475                             "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers");
29476 #else
29477             char val;
29478             PyObject *v = __Pyx_PyNumber_IntOrLong(x);
29479  #if PY_MAJOR_VERSION < 3
29480             if (likely(v) && !PyLong_Check(v)) {
29481                 PyObject *tmp = v;
29482                 v = PyNumber_Long(tmp);
29483                 Py_DECREF(tmp);
29484             }
29485  #endif
29486             if (likely(v)) {
29487                 int one = 1; int is_little = (int)*(unsigned char *)&one;
29488                 unsigned char *bytes = (unsigned char *)&val;
29489                 int ret = _PyLong_AsByteArray((PyLongObject *)v,
29490                                               bytes, sizeof(val),
29491                                               is_little, !is_unsigned);
29492                 Py_DECREF(v);
29493                 if (likely(!ret))
29494                     return val;
29495             }
29496 #endif
29497             return (char) -1;
29498         }
29499     } else {
29500         char val;
29501         PyObject *tmp = __Pyx_PyNumber_IntOrLong(x);
29502         if (!tmp) return (char) -1;
29503         val = __Pyx_PyInt_As_char(tmp);
29504         Py_DECREF(tmp);
29505         return val;
29506     }
29507 raise_overflow:
29508     PyErr_SetString(PyExc_OverflowError,
29509         "value too large to convert to char");
29510     return (char) -1;
29511 raise_neg_overflow:
29512     PyErr_SetString(PyExc_OverflowError,
29513         "can't convert negative value to char");
29514     return (char) -1;
29515 }
29516 
29517 /* CheckBinaryVersion */
__Pyx_check_binary_version(void)29518   static int __Pyx_check_binary_version(void) {
29519     char ctversion[4], rtversion[4];
29520     PyOS_snprintf(ctversion, 4, "%d.%d", PY_MAJOR_VERSION, PY_MINOR_VERSION);
29521     PyOS_snprintf(rtversion, 4, "%s", Py_GetVersion());
29522     if (ctversion[0] != rtversion[0] || ctversion[2] != rtversion[2]) {
29523         char message[200];
29524         PyOS_snprintf(message, sizeof(message),
29525                       "compiletime version %s of module '%.100s' "
29526                       "does not match runtime version %s",
29527                       ctversion, __Pyx_MODULE_NAME, rtversion);
29528         return PyErr_WarnEx(NULL, message, 1);
29529     }
29530     return 0;
29531 }
29532 
29533 /* FunctionExport */
__Pyx_ExportFunction(const char * name,void (* f)(void),const char * sig)29534   static int __Pyx_ExportFunction(const char *name, void (*f)(void), const char *sig) {
29535     PyObject *d = 0;
29536     PyObject *cobj = 0;
29537     union {
29538         void (*fp)(void);
29539         void *p;
29540     } tmp;
29541     d = PyObject_GetAttrString(__pyx_m, (char *)"__pyx_capi__");
29542     if (!d) {
29543         PyErr_Clear();
29544         d = PyDict_New();
29545         if (!d)
29546             goto bad;
29547         Py_INCREF(d);
29548         if (PyModule_AddObject(__pyx_m, (char *)"__pyx_capi__", d) < 0)
29549             goto bad;
29550     }
29551     tmp.fp = f;
29552 #if PY_VERSION_HEX >= 0x02070000
29553     cobj = PyCapsule_New(tmp.p, sig, 0);
29554 #else
29555     cobj = PyCObject_FromVoidPtrAndDesc(tmp.p, (void *)sig, 0);
29556 #endif
29557     if (!cobj)
29558         goto bad;
29559     if (PyDict_SetItemString(d, name, cobj) < 0)
29560         goto bad;
29561     Py_DECREF(cobj);
29562     Py_DECREF(d);
29563     return 0;
29564 bad:
29565     Py_XDECREF(cobj);
29566     Py_XDECREF(d);
29567     return -1;
29568 }
29569 
29570 /* InitStrings */
__Pyx_InitStrings(__Pyx_StringTabEntry * t)29571   static int __Pyx_InitStrings(__Pyx_StringTabEntry *t) {
29572     while (t->p) {
29573         #if PY_MAJOR_VERSION < 3
29574         if (t->is_unicode) {
29575             *t->p = PyUnicode_DecodeUTF8(t->s, t->n - 1, NULL);
29576         } else if (t->intern) {
29577             *t->p = PyString_InternFromString(t->s);
29578         } else {
29579             *t->p = PyString_FromStringAndSize(t->s, t->n - 1);
29580         }
29581         #else
29582         if (t->is_unicode | t->is_str) {
29583             if (t->intern) {
29584                 *t->p = PyUnicode_InternFromString(t->s);
29585             } else if (t->encoding) {
29586                 *t->p = PyUnicode_Decode(t->s, t->n - 1, t->encoding, NULL);
29587             } else {
29588                 *t->p = PyUnicode_FromStringAndSize(t->s, t->n - 1);
29589             }
29590         } else {
29591             *t->p = PyBytes_FromStringAndSize(t->s, t->n - 1);
29592         }
29593         #endif
29594         if (!*t->p)
29595             return -1;
29596         if (PyObject_Hash(*t->p) == -1)
29597             return -1;
29598         ++t;
29599     }
29600     return 0;
29601 }
29602 
__Pyx_PyUnicode_FromString(const char * c_str)29603 static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(const char* c_str) {
29604     return __Pyx_PyUnicode_FromStringAndSize(c_str, (Py_ssize_t)strlen(c_str));
29605 }
__Pyx_PyObject_AsString(PyObject * o)29606 static CYTHON_INLINE const char* __Pyx_PyObject_AsString(PyObject* o) {
29607     Py_ssize_t ignore;
29608     return __Pyx_PyObject_AsStringAndSize(o, &ignore);
29609 }
29610 #if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT
29611 #if !CYTHON_PEP393_ENABLED
__Pyx_PyUnicode_AsStringAndSize(PyObject * o,Py_ssize_t * length)29612 static const char* __Pyx_PyUnicode_AsStringAndSize(PyObject* o, Py_ssize_t *length) {
29613     char* defenc_c;
29614     PyObject* defenc = _PyUnicode_AsDefaultEncodedString(o, NULL);
29615     if (!defenc) return NULL;
29616     defenc_c = PyBytes_AS_STRING(defenc);
29617 #if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
29618     {
29619         char* end = defenc_c + PyBytes_GET_SIZE(defenc);
29620         char* c;
29621         for (c = defenc_c; c < end; c++) {
29622             if ((unsigned char) (*c) >= 128) {
29623                 PyUnicode_AsASCIIString(o);
29624                 return NULL;
29625             }
29626         }
29627     }
29628 #endif
29629     *length = PyBytes_GET_SIZE(defenc);
29630     return defenc_c;
29631 }
29632 #else
__Pyx_PyUnicode_AsStringAndSize(PyObject * o,Py_ssize_t * length)29633 static CYTHON_INLINE const char* __Pyx_PyUnicode_AsStringAndSize(PyObject* o, Py_ssize_t *length) {
29634     if (unlikely(__Pyx_PyUnicode_READY(o) == -1)) return NULL;
29635 #if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
29636     if (likely(PyUnicode_IS_ASCII(o))) {
29637         *length = PyUnicode_GET_LENGTH(o);
29638         return PyUnicode_AsUTF8(o);
29639     } else {
29640         PyUnicode_AsASCIIString(o);
29641         return NULL;
29642     }
29643 #else
29644     return PyUnicode_AsUTF8AndSize(o, length);
29645 #endif
29646 }
29647 #endif
29648 #endif
__Pyx_PyObject_AsStringAndSize(PyObject * o,Py_ssize_t * length)29649 static CYTHON_INLINE const char* __Pyx_PyObject_AsStringAndSize(PyObject* o, Py_ssize_t *length) {
29650 #if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT
29651     if (
29652 #if PY_MAJOR_VERSION < 3 && __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
29653             __Pyx_sys_getdefaultencoding_not_ascii &&
29654 #endif
29655             PyUnicode_Check(o)) {
29656         return __Pyx_PyUnicode_AsStringAndSize(o, length);
29657     } else
29658 #endif
29659 #if (!CYTHON_COMPILING_IN_PYPY) || (defined(PyByteArray_AS_STRING) && defined(PyByteArray_GET_SIZE))
29660     if (PyByteArray_Check(o)) {
29661         *length = PyByteArray_GET_SIZE(o);
29662         return PyByteArray_AS_STRING(o);
29663     } else
29664 #endif
29665     {
29666         char* result;
29667         int r = PyBytes_AsStringAndSize(o, &result, length);
29668         if (unlikely(r < 0)) {
29669             return NULL;
29670         } else {
29671             return result;
29672         }
29673     }
29674 }
__Pyx_PyObject_IsTrue(PyObject * x)29675 static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject* x) {
29676    int is_true = x == Py_True;
29677    if (is_true | (x == Py_False) | (x == Py_None)) return is_true;
29678    else return PyObject_IsTrue(x);
29679 }
__Pyx_PyObject_IsTrueAndDecref(PyObject * x)29680 static CYTHON_INLINE int __Pyx_PyObject_IsTrueAndDecref(PyObject* x) {
29681     int retval;
29682     if (unlikely(!x)) return -1;
29683     retval = __Pyx_PyObject_IsTrue(x);
29684     Py_DECREF(x);
29685     return retval;
29686 }
__Pyx_PyNumber_IntOrLongWrongResultType(PyObject * result,const char * type_name)29687 static PyObject* __Pyx_PyNumber_IntOrLongWrongResultType(PyObject* result, const char* type_name) {
29688 #if PY_MAJOR_VERSION >= 3
29689     if (PyLong_Check(result)) {
29690         if (PyErr_WarnFormat(PyExc_DeprecationWarning, 1,
29691                 "__int__ returned non-int (type %.200s).  "
29692                 "The ability to return an instance of a strict subclass of int "
29693                 "is deprecated, and may be removed in a future version of Python.",
29694                 Py_TYPE(result)->tp_name)) {
29695             Py_DECREF(result);
29696             return NULL;
29697         }
29698         return result;
29699     }
29700 #endif
29701     PyErr_Format(PyExc_TypeError,
29702                  "__%.4s__ returned non-%.4s (type %.200s)",
29703                  type_name, type_name, Py_TYPE(result)->tp_name);
29704     Py_DECREF(result);
29705     return NULL;
29706 }
__Pyx_PyNumber_IntOrLong(PyObject * x)29707 static CYTHON_INLINE PyObject* __Pyx_PyNumber_IntOrLong(PyObject* x) {
29708 #if CYTHON_USE_TYPE_SLOTS
29709   PyNumberMethods *m;
29710 #endif
29711   const char *name = NULL;
29712   PyObject *res = NULL;
29713 #if PY_MAJOR_VERSION < 3
29714   if (likely(PyInt_Check(x) || PyLong_Check(x)))
29715 #else
29716   if (likely(PyLong_Check(x)))
29717 #endif
29718     return __Pyx_NewRef(x);
29719 #if CYTHON_USE_TYPE_SLOTS
29720   m = Py_TYPE(x)->tp_as_number;
29721   #if PY_MAJOR_VERSION < 3
29722   if (m && m->nb_int) {
29723     name = "int";
29724     res = m->nb_int(x);
29725   }
29726   else if (m && m->nb_long) {
29727     name = "long";
29728     res = m->nb_long(x);
29729   }
29730   #else
29731   if (likely(m && m->nb_int)) {
29732     name = "int";
29733     res = m->nb_int(x);
29734   }
29735   #endif
29736 #else
29737   if (!PyBytes_CheckExact(x) && !PyUnicode_CheckExact(x)) {
29738     res = PyNumber_Int(x);
29739   }
29740 #endif
29741   if (likely(res)) {
29742 #if PY_MAJOR_VERSION < 3
29743     if (unlikely(!PyInt_Check(res) && !PyLong_Check(res))) {
29744 #else
29745     if (unlikely(!PyLong_CheckExact(res))) {
29746 #endif
29747         return __Pyx_PyNumber_IntOrLongWrongResultType(res, name);
29748     }
29749   }
29750   else if (!PyErr_Occurred()) {
29751     PyErr_SetString(PyExc_TypeError,
29752                     "an integer is required");
29753   }
29754   return res;
29755 }
29756 static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject* b) {
29757   Py_ssize_t ival;
29758   PyObject *x;
29759 #if PY_MAJOR_VERSION < 3
29760   if (likely(PyInt_CheckExact(b))) {
29761     if (sizeof(Py_ssize_t) >= sizeof(long))
29762         return PyInt_AS_LONG(b);
29763     else
29764         return PyInt_AsSsize_t(b);
29765   }
29766 #endif
29767   if (likely(PyLong_CheckExact(b))) {
29768     #if CYTHON_USE_PYLONG_INTERNALS
29769     const digit* digits = ((PyLongObject*)b)->ob_digit;
29770     const Py_ssize_t size = Py_SIZE(b);
29771     if (likely(__Pyx_sst_abs(size) <= 1)) {
29772         ival = likely(size) ? digits[0] : 0;
29773         if (size == -1) ival = -ival;
29774         return ival;
29775     } else {
29776       switch (size) {
29777          case 2:
29778            if (8 * sizeof(Py_ssize_t) > 2 * PyLong_SHIFT) {
29779              return (Py_ssize_t) (((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
29780            }
29781            break;
29782          case -2:
29783            if (8 * sizeof(Py_ssize_t) > 2 * PyLong_SHIFT) {
29784              return -(Py_ssize_t) (((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
29785            }
29786            break;
29787          case 3:
29788            if (8 * sizeof(Py_ssize_t) > 3 * PyLong_SHIFT) {
29789              return (Py_ssize_t) (((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
29790            }
29791            break;
29792          case -3:
29793            if (8 * sizeof(Py_ssize_t) > 3 * PyLong_SHIFT) {
29794              return -(Py_ssize_t) (((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
29795            }
29796            break;
29797          case 4:
29798            if (8 * sizeof(Py_ssize_t) > 4 * PyLong_SHIFT) {
29799              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]));
29800            }
29801            break;
29802          case -4:
29803            if (8 * sizeof(Py_ssize_t) > 4 * PyLong_SHIFT) {
29804              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]));
29805            }
29806            break;
29807       }
29808     }
29809     #endif
29810     return PyLong_AsSsize_t(b);
29811   }
29812   x = PyNumber_Index(b);
29813   if (!x) return -1;
29814   ival = PyInt_AsSsize_t(x);
29815   Py_DECREF(x);
29816   return ival;
29817 }
29818 static CYTHON_INLINE PyObject * __Pyx_PyBool_FromLong(long b) {
29819   return b ? __Pyx_NewRef(Py_True) : __Pyx_NewRef(Py_False);
29820 }
29821 static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t ival) {
29822     return PyInt_FromSize_t(ival);
29823 }
29824 
29825 
29826 #endif /* Py_PYTHON_H */
29827